pokeemerald/src/battle_factory_screen.c

4305 lines
146 KiB
C
Raw Normal View History

2018-11-11 16:44:27 +01:00
#include "global.h"
#include "battle.h"
2018-11-11 16:44:27 +01:00
#include "battle_factory_screen.h"
#include "battle_factory.h"
#include "sprite.h"
#include "event_data.h"
#include "overworld.h"
#include "random.h"
#include "battle_tower.h"
#include "text.h"
#include "palette.h"
#include "task.h"
#include "main.h"
#include "malloc.h"
2018-11-11 16:44:27 +01:00
#include "bg.h"
#include "gpu_regs.h"
#include "string_util.h"
#include "international_string_util.h"
#include "window.h"
2019-04-04 23:53:06 +02:00
#include "data.h"
2018-11-11 16:44:27 +01:00
#include "decompress.h"
#include "pokemon_summary_screen.h"
#include "sound.h"
#include "pokedex.h"
#include "util.h"
#include "trainer_pokemon_sprites.h"
2020-07-06 23:22:37 +02:00
#include "starter_choose.h"
2020-12-28 23:32:08 +01:00
#include "strings.h"
#include "graphics.h"
2018-11-11 16:44:27 +01:00
#include "constants/battle_frontier.h"
#include "constants/songs.h"
#include "constants/rgb.h"
2020-12-28 23:32:08 +01:00
// Select_ refers to the first Pokemon selection screen where you choose your initial 3 rental Pokemon.
// Swap_ refers to the subsequent selection screens where you can swap a Pokemon with one from the beaten trainer
2018-11-11 16:44:27 +01:00
2020-12-28 23:32:08 +01:00
// Note that, generally, "Action" will refer to the immediate actions that can be taken on each screen,
// i.e. selecting a pokemon or selecting the Cancel button
// The "Options menu" will refer to the popup menu that shows when some actions have been selected
2020-12-28 23:32:08 +01:00
#define SWAP_PLAYER_SCREEN 0 // The screen where the player selects which of their pokemon to swap away
#define SWAP_ENEMY_SCREEN 1 // The screen where the player selects which new pokemon from the defeated party to swap for
2018-11-11 16:44:27 +01:00
#define SELECTABLE_MONS_COUNT 6
2020-12-30 23:35:33 +01:00
enum {
PALTAG_BALL_GRAY = 100,
PALTAG_BALL_SELECTED,
PALTAG_INTERFACE,
PALTAG_MON_PIC_BG,
};
enum {
GFXTAG_BALL = 100,
GFXTAG_ARROW,
GFXTAG_MENU_HIGHLIGHT_LEFT,
GFXTAG_MENU_HIGHLIGHT_RIGHT,
GFXTAG_ACTION_BOX_LEFT,
GFXTAG_ACTION_BOX_RIGHT,
GFXTAG_ACTION_HIGHLIGHT_LEFT,
GFXTAG_ACTION_HIGHLIGHT_MIDDLE,
GFXTAG_ACTION_HIGHLIGHT_RIGHT,
GFXTAG_MON_PIC_BG_ANIM,
};
2018-11-11 16:44:27 +01:00
2020-12-28 23:32:08 +01:00
// Tasks in this file universally use data[0] as a state for switches
#define tState data[0]
// States for both Select/Swap versions of Task_FadeSpeciesName
enum {
FADESTATE_INIT,
FADESTATE_RUN,
FADESTATE_DELAY
};
2020-12-30 23:35:33 +01:00
// Return states for the Select Actions
enum {
SELECT_SUMMARY,
SELECT_CONTINUE_CHOOSING,
SELECT_CONFIRM_MONS,
SELECT_INVALID_MON,
};
struct FactorySelectableMon
2018-11-11 16:44:27 +01:00
{
u16 monId;
2020-12-28 23:32:08 +01:00
u16 ballSpriteId;
2018-11-11 16:44:27 +01:00
u8 selectedId; // 0 - not selected, 1 - first pokemon, 2 - second pokemon, 3 - third pokemon
struct Pokemon monData;
};
2020-12-28 23:32:08 +01:00
struct FactoryMonPic
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
u8 monSpriteId;
u8 bgSpriteId;
2018-11-11 16:44:27 +01:00
};
struct FactorySelectScreen
2018-11-11 16:44:27 +01:00
{
u8 menuCursorPos;
u8 menuCursor1SpriteId;
u8 menuCursor2SpriteId;
u8 cursorPos;
u8 cursorSpriteId;
u8 selectingMonsState;
bool8 fromSummaryScreen;
u8 yesNoCursorPos;
2020-12-28 23:32:08 +01:00
u8 unused;
struct FactorySelectableMon mons[SELECTABLE_MONS_COUNT];
2020-12-28 23:32:08 +01:00
struct FactoryMonPic monPics[FRONTIER_PARTY_SIZE]; // Array so all chosen mons can be shown at once
bool8 monPicAnimating;
2018-11-11 16:44:27 +01:00
u8 fadeSpeciesNameTaskId;
2020-12-28 23:32:08 +01:00
bool8 fadeSpeciesNameActive;
u16 speciesNameColorBackup;
2020-12-28 23:32:08 +01:00
bool8 fadeSpeciesNameFadeOut;
u8 fadeSpeciesNameCoeffDelay;
u8 fadeSpeciesNameCoeff;
u8 faceSpeciesNameDelay;
2018-11-11 16:44:27 +01:00
};
struct SwapScreenAction
2018-11-11 16:44:27 +01:00
{
u8 id;
void (*func)(u8 taskId);
};
struct FactorySwapScreen
2018-11-11 16:44:27 +01:00
{
u8 menuCursorPos;
u8 menuCursor1SpriteId;
u8 menuCursor2SpriteId;
u8 cursorPos;
u8 cursorSpriteId;
u8 ballSpriteIds[FRONTIER_PARTY_SIZE];
2020-12-28 23:32:08 +01:00
u8 pkmnForSwapButtonSpriteIds[2][3]; // For this and sprite ID array below, [0][i] is the button background, [1][i] is the button highlight
u8 cancelButtonSpriteIds[2][2];
2018-11-11 16:44:27 +01:00
u8 playerMonId;
u8 enemyMonId;
bool8 inEnemyScreen;
bool8 fromSummaryScreen;
u8 yesNoCursorPos;
u8 actionsCount;
const struct SwapScreenAction *actionsData;
2020-12-30 23:35:33 +01:00
u8 unused[4];
2018-11-11 16:44:27 +01:00
bool8 monSwapped;
u8 fadeSpeciesNameTaskId;
2020-12-28 23:32:08 +01:00
bool8 fadeSpeciesNameActive;
u16 speciesNameColorBackup;
bool8 fadeSpeciesNameFadeOut;
u8 fadeSpeciesNameCoeffDelay;
u8 fadeSpeciesNameCoeff;
u8 faceSpeciesNameDelay;
struct FactoryMonPic monPic;
bool8 monPicAnimating;
2018-11-11 16:44:27 +01:00
};
2020-12-28 23:32:08 +01:00
static void SpriteCB_Pokeball(struct Sprite *);
static void SpriteCB_OpenMonPic(struct Sprite *);
static void OpenMonPic(u8 *, bool8 *, bool8);
static void HideMonPic(struct FactoryMonPic, bool8 *);
static void CloseMonPic(struct FactoryMonPic, bool8 *, bool8);
static void Task_OpenMonPic(u8);
static void Task_CloseMonPic(u8);
// Select screen
2018-11-11 16:44:27 +01:00
static void CB2_InitSelectScreen(void);
2020-12-28 23:32:08 +01:00
static void Select_SetWinRegs(s16, s16, s16, s16);
2018-11-11 16:44:27 +01:00
static void Select_InitMonsData(void);
static void Select_InitAllSprites(void);
static void Select_ReshowMonSprite(void);
2018-11-11 16:44:27 +01:00
static void Select_PrintSelectMonString(void);
static void Select_PrintMonSpecies(void);
static void Select_PrintMonCategory(void);
static void Select_PrintRentalPkmnString(void);
static void Select_CopyMonsToPlayerParty(void);
2020-12-30 23:35:33 +01:00
static void Select_ShowChosenMons(void);
2018-11-11 16:44:27 +01:00
static void Select_ShowYesNoOptions(void);
2020-12-30 23:35:33 +01:00
static void Select_HideChosenMons(void);
2018-11-11 16:44:27 +01:00
static void Select_ShowMenuOptions(void);
static void Select_PrintMenuOptions(void);
static void Select_PrintYesNoOptions(void);
2020-12-28 23:32:08 +01:00
static void Select_Task_FadeSpeciesName(u8);
2020-12-30 23:35:33 +01:00
static void Select_Task_OpenChosenMonPics(u8);
2020-12-28 23:32:08 +01:00
static void Select_Task_HandleChooseMons(u8);
static void Select_Task_HandleMenu(u8);
static void CreateFrontierFactorySelectableMons(u8);
static void CreateSlateportTentSelectableMons(u8);
static void Select_SetBallSpritePaletteNum(u8);
2020-12-30 23:35:33 +01:00
static void Select_ErasePopupMenu(u8);
2018-11-11 16:44:27 +01:00
static u8 Select_RunMenuOptionFunc(void);
2020-12-30 23:35:33 +01:00
static u8 Select_DeclineChosenMons(void);
2018-11-11 16:44:27 +01:00
static u8 Select_OptionSummary(void);
static u8 Select_OptionOthers(void);
static u8 Select_OptionRentDeselect(void);
2020-12-28 23:32:08 +01:00
static bool32 Select_AreSpeciesValid(u16);
// Swap screen
static void CB2_InitSwapScreen(void);
2018-11-11 16:44:27 +01:00
static void Swap_DestroyAllSprites(void);
static void Swap_ShowYesNoOptions(void);
2020-12-28 23:32:08 +01:00
static void Swap_HideActionButtonHighlights(void);
2020-12-31 06:26:14 +01:00
static void Swap_EraseSpeciesWindow(void);
2020-12-28 23:32:08 +01:00
static void Swap_UpdateYesNoCursorPosition(s8);
static void Swap_UpdateMenuCursorPosition(s8);
static void Swap_ErasePopupMenu(u8);
2020-12-31 06:26:14 +01:00
static void Swap_Task_ScreenInfoTransitionIn(u8);
2020-12-28 23:32:08 +01:00
static void Swap_Task_HandleChooseMons(u8);
2020-12-31 06:26:14 +01:00
static void Swap_Task_ScreenInfoTransitionOut(u8);
2020-12-28 23:32:08 +01:00
static void Swap_PrintOnInfoWindow(const u8 *);
2018-11-11 16:44:27 +01:00
static void Swap_ShowMenuOptions(void);
static void Swap_PrintMenuOptions(void);
static void Swap_PrintYesNoOptions(void);
static void Swap_PrintMonSpecies(void);
2020-12-31 06:26:14 +01:00
static void Swap_PrintMonSpeciesAtFade(void);
static void Swap_PrintMonSpeciesForTransition(void);
2018-11-11 16:44:27 +01:00
static void Swap_PrintMonCategory(void);
static void Swap_InitAllSprites(void);
static void Swap_PrintPkmnSwap(void);
2020-12-31 06:26:14 +01:00
static void Swap_EraseSpeciesAtFadeWindow(void);
static void Swap_EraseActionFadeWindow(void);
2018-11-11 16:44:27 +01:00
static void Swap_ShowSummaryMonSprite(void);
2020-12-28 23:32:08 +01:00
static void Swap_UpdateActionCursorPosition(s8);
static void Swap_UpdateBallCursorPosition(s8);
static void Swap_RunMenuOptionFunc(u8);
static void Swap_OptionSwap(u8);
static void Swap_OptionSummary(u8);
static void Swap_OptionRechoose(u8);
static void Swap_RunActionFunc(u8);
static void Swap_TaskCantHaveSameMons(u8);
2020-09-03 07:19:08 +02:00
static void Swap_CreateMonSprite(void);
2018-11-11 16:44:27 +01:00
static void Swap_PrintActionStrings(void);
static void Swap_PrintActionStrings2(void);
2020-12-28 23:32:08 +01:00
static void Swap_PrintOneActionString(u8);
static void Swap_InitActions(u8);
static void Swap_HighlightActionButton(u8);
static bool8 Swap_AlreadyHasSameSpecies(u8);
static void Swap_ActionMon(u8);
static void Swap_ActionCancel(u8);
static void Swap_ActionPkmnForSwap(u8);
2018-11-11 16:44:27 +01:00
static EWRAM_DATA u8 *sSelectMenuTilesetBuffer = NULL;
static EWRAM_DATA u8 *sSelectMonPicBgTilesetBuffer = NULL;
2018-11-11 16:44:27 +01:00
static EWRAM_DATA u8 *sSelectMenuTilemapBuffer = NULL;
static EWRAM_DATA u8 *sSelectMonPicBgTilemapBuffer = NULL;
2018-11-11 16:44:27 +01:00
static EWRAM_DATA struct Pokemon *sFactorySelectMons = NULL;
static EWRAM_DATA u8 *sSwapMenuTilesetBuffer = NULL;
static EWRAM_DATA u8 *sSwapMonPicBgTilesetBuffer = NULL;
2018-11-11 16:44:27 +01:00
static EWRAM_DATA u8 *sSwapMenuTilemapBuffer = NULL;
static EWRAM_DATA u8 *sSwapMonPicBgTilemapBuffer = NULL;
static struct FactorySelectScreen *sFactorySelectScreen;
static void (*sSwap_CurrentOptionFunc)(u8 taskId);
static struct FactorySwapScreen *sFactorySwapScreen;
u8 (*gFactorySelect_CurrentOptionFunc)(void);
static const u16 sPokeballGray_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/pokeball_gray.gbapal");
static const u16 sPokeballSelected_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/pokeball_selected.gbapal");
static const u16 sInterface_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/interface.gbapal"); // Arrow, menu/action highlights, action box, etc
static const u8 sPokeball_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/pokeball.4bpp"); // Unused, gPokeballSelection_Gfx used instead
static const u8 sArrow_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/arrow.4bpp");
static const u8 sMenuHighlightLeft_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/menu_highlight_left.4bpp");
static const u8 sMenuHighlightRight_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/menu_highlight_right.4bpp");
static const u8 sActionBoxLeft_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_box_left.4bpp");
static const u8 sActionBoxRight_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_box_right.4bpp");
static const u8 sActionHighlightLeft_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_highlight_left.4bpp");
static const u8 sActionHighlightMiddle_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_highlight_middle.4bpp");
static const u8 sActionHighlightRight_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/action_highlight_right.4bpp");
static const u8 sMonPicBgAnim_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/mon_pic_bg_anim.4bpp");
static const u8 sMonPicBg_Tilemap[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/mon_pic_bg.bin");
static const u8 sMonPicBg_Gfx[] = INCBIN_U8( "graphics/battle_frontier/factory_screen/mon_pic_bg.4bpp");
static const u16 sMonPicBg_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/mon_pic_bg.gbapal");
static const struct SpriteSheet sSelect_SpriteSheets[] =
{
{sArrow_Gfx, sizeof(sArrow_Gfx), GFXTAG_ARROW},
{sMenuHighlightLeft_Gfx, sizeof(sMenuHighlightLeft_Gfx), GFXTAG_MENU_HIGHLIGHT_LEFT},
{sMenuHighlightRight_Gfx, sizeof(sMenuHighlightRight_Gfx), GFXTAG_MENU_HIGHLIGHT_RIGHT},
{sMonPicBgAnim_Gfx, sizeof(sMonPicBgAnim_Gfx), GFXTAG_MON_PIC_BG_ANIM},
2018-11-11 16:44:27 +01:00
{},
};
static const struct CompressedSpriteSheet sSelect_BallGfx[] =
2018-11-11 16:44:27 +01:00
{
{gPokeballSelection_Gfx, 0x800, GFXTAG_BALL},
2018-11-11 16:44:27 +01:00
{},
};
static const struct SpritePalette sSelect_SpritePalettes[] =
2018-11-11 16:44:27 +01:00
{
{sPokeballGray_Pal, PALTAG_BALL_GRAY},
{sPokeballSelected_Pal, PALTAG_BALL_SELECTED},
{sInterface_Pal, PALTAG_INTERFACE},
{sMonPicBg_Pal, PALTAG_MON_PIC_BG},
2018-11-11 16:44:27 +01:00
{},
};
2020-12-28 23:32:08 +01:00
u8 static (* const sSelect_MenuOptionFuncs[])(void) =
2018-11-11 16:44:27 +01:00
{
Select_OptionSummary,
Select_OptionRentDeselect,
Select_OptionOthers
2018-11-11 16:44:27 +01:00
};
static const struct BgTemplate sSelect_BgTemplates[] =
{
{
.bg = 0,
.charBaseIndex = 0,
.mapBaseIndex = 24,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
},
{
.bg = 1,
.charBaseIndex = 1,
.mapBaseIndex = 25,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0
},
{
.bg = 3,
.charBaseIndex = 2,
.mapBaseIndex = 27,
.screenSize = 0,
.paletteMode = 0,
.priority = 2,
.baseTile = 0
},
};
2020-12-28 23:32:08 +01:00
enum {
SELECT_WIN_TITLE,
SELECT_WIN_SPECIES,
SELECT_WIN_INFO,
SELECT_WIN_OPTIONS,
SELECT_WIN_YES_NO,
SELECT_WIN_MON_CATEGORY,
};
2018-11-11 16:44:27 +01:00
static const struct WindowTemplate sSelect_WindowTemplates[] =
{
2020-12-28 23:32:08 +01:00
[SELECT_WIN_TITLE] = {
2018-11-11 16:44:27 +01:00
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 2,
.width = 12,
.height = 2,
.paletteNum = 15,
.baseBlock = 0x0001,
},
2020-12-28 23:32:08 +01:00
[SELECT_WIN_SPECIES] = {
2018-11-11 16:44:27 +01:00
.bg = 0,
.tilemapLeft = 19,
.tilemapTop = 2,
.width = 11,
.height = 2,
.paletteNum = 14,
.baseBlock = 0x0019,
},
2020-12-28 23:32:08 +01:00
[SELECT_WIN_INFO] = {
2018-11-11 16:44:27 +01:00
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 15,
.width = 20,
.height = 3,
.paletteNum = 15,
.baseBlock = 0x002f,
},
2020-12-28 23:32:08 +01:00
[SELECT_WIN_OPTIONS] = {
2018-11-11 16:44:27 +01:00
.bg = 0,
.tilemapLeft = 22,
.tilemapTop = 14,
.width = 8,
.height = 6,
.paletteNum = 15,
.baseBlock = 0x006b,
},
2020-12-28 23:32:08 +01:00
[SELECT_WIN_YES_NO] = {
2018-11-11 16:44:27 +01:00
.bg = 0,
.tilemapLeft = 22,
.tilemapTop = 14,
.width = 8,
.height = 4,
.paletteNum = 15,
.baseBlock = 0x009b,
},
2020-12-28 23:32:08 +01:00
[SELECT_WIN_MON_CATEGORY] = {
2018-11-11 16:44:27 +01:00
.bg = 0,
.tilemapLeft = 15,
.tilemapTop = 0,
.width = 15,
.height = 2,
.paletteNum = 15,
.baseBlock = 0x00bb,
},
DUMMY_WIN_TEMPLATE,
};
static const u16 sSelectText_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/text.gbapal");
2021-04-10 04:39:34 +02:00
static const u8 sMenuOptionTextColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_TRANSPARENT};
2019-12-10 19:48:20 +01:00
static const u8 sSpeciesNameTextColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_RED, TEXT_COLOR_TRANSPARENT};
2018-11-11 16:44:27 +01:00
static const struct OamData sOam_Select_Pokeball =
2018-11-11 16:44:27 +01:00
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
2018-11-11 16:44:27 +01:00
.mosaic = 0,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(32x32),
2018-11-11 16:44:27 +01:00
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(32x32),
2018-11-11 16:44:27 +01:00
.tileNum = 0,
.priority = 3,
.paletteNum = 0,
.affineParam = 0,
};
static const struct OamData sOam_Select_Arrow =
2018-11-11 16:44:27 +01:00
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
2018-11-11 16:44:27 +01:00
.mosaic = 0,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(16x16),
2018-11-11 16:44:27 +01:00
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(16x16),
2018-11-11 16:44:27 +01:00
.tileNum = 0,
.priority = 3,
.paletteNum = 0,
.affineParam = 0,
};
static const struct OamData sOam_Select_MenuHighlight =
2018-11-11 16:44:27 +01:00
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
2018-11-11 16:44:27 +01:00
.mosaic = 0,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(32x16),
2018-11-11 16:44:27 +01:00
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(32x16),
2018-11-11 16:44:27 +01:00
.tileNum = 0,
.priority = 2,
.paletteNum = 0,
.affineParam = 0,
};
static const struct OamData sOam_Select_MonPicBgAnim =
2018-11-11 16:44:27 +01:00
{
.y = 0,
.affineMode = ST_OAM_AFFINE_DOUBLE,
.objMode = ST_OAM_OBJ_BLEND,
2018-11-11 16:44:27 +01:00
.mosaic = 0,
.bpp = ST_OAM_4BPP,
.shape = SPRITE_SHAPE(64x64),
2018-11-11 16:44:27 +01:00
.x = 0,
.matrixNum = 0,
.size = SPRITE_SIZE(64x64),
2018-11-11 16:44:27 +01:00
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
.affineParam = 1,
};
static const union AnimCmd sAnim_Select_Interface[] =
2018-11-11 16:44:27 +01:00
{
ANIMCMD_FRAME(0, 1),
ANIMCMD_END,
};
static const union AnimCmd sAnim_Select_MonPicBgAnim[] =
2018-11-11 16:44:27 +01:00
{
ANIMCMD_FRAME(0, 1),
ANIMCMD_END,
};
static const union AnimCmd sAnim_Select_Pokeball_Still[] =
2018-11-11 16:44:27 +01:00
{
ANIMCMD_FRAME(0, 30),
ANIMCMD_END,
};
static const union AnimCmd sAnim_Select_Pokeball_Moving[] =
2018-11-11 16:44:27 +01:00
{
ANIMCMD_FRAME(16, 4),
ANIMCMD_FRAME(0, 4),
ANIMCMD_FRAME(32, 4),
ANIMCMD_FRAME(0, 4),
ANIMCMD_FRAME(16, 4),
ANIMCMD_FRAME(0, 4),
ANIMCMD_FRAME(32, 4),
ANIMCMD_FRAME(0, 4),
ANIMCMD_FRAME(0, 32),
ANIMCMD_FRAME(16, 8),
ANIMCMD_FRAME(0, 8),
ANIMCMD_FRAME(32, 8),
ANIMCMD_FRAME(0, 8),
ANIMCMD_FRAME(16, 8),
ANIMCMD_FRAME(0, 8),
ANIMCMD_FRAME(32, 8),
ANIMCMD_FRAME(0, 8),
ANIMCMD_END,
};
static const union AnimCmd * const sAnims_Select_Interface[] =
2018-11-11 16:44:27 +01:00
{
sAnim_Select_Interface,
2018-11-11 16:44:27 +01:00
};
static const union AnimCmd * const sAnims_Select_MonPicBgAnim[] =
2018-11-11 16:44:27 +01:00
{
sAnim_Select_MonPicBgAnim,
2018-11-11 16:44:27 +01:00
};
static const union AnimCmd * const sAnims_Select_Pokeball[] =
2018-11-11 16:44:27 +01:00
{
sAnim_Select_Pokeball_Still,
sAnim_Select_Pokeball_Moving,
2018-11-11 16:44:27 +01:00
};
2021-03-21 04:47:08 +01:00
static const union AffineAnimCmd sAffineAnim_Select_MonPicBg_Opening[] =
2018-11-11 16:44:27 +01:00
{
AFFINEANIMCMD_FRAME(5, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(16, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(32, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(64, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(128, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(256, 5, 0, 0),
AFFINEANIMCMD_END,
};
2021-03-21 04:47:08 +01:00
static const union AffineAnimCmd sAffineAnim_Select_MonPicBg_Closing[] =
2018-11-11 16:44:27 +01:00
{
AFFINEANIMCMD_FRAME(128, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(64, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(32, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(16, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(5, 5, 0, 0),
AFFINEANIMCMD_END,
};
2021-03-21 04:47:08 +01:00
static const union AffineAnimCmd sAffineAnim_Select_MonPicBg_Open[] =
2018-11-11 16:44:27 +01:00
{
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
AFFINEANIMCMD_END,
};
static const union AffineAnimCmd * const sAffineAnims_Select_MonPicBgAnim[] =
2018-11-11 16:44:27 +01:00
{
2021-03-21 04:47:08 +01:00
sAffineAnim_Select_MonPicBg_Opening,
sAffineAnim_Select_MonPicBg_Closing,
sAffineAnim_Select_MonPicBg_Open,
2018-11-11 16:44:27 +01:00
};
static const struct SpriteTemplate sSpriteTemplate_Select_Pokeball =
2018-11-11 16:44:27 +01:00
{
.tileTag = GFXTAG_BALL,
.paletteTag = PALTAG_BALL_GRAY,
.oam = &sOam_Select_Pokeball,
.anims = sAnims_Select_Pokeball,
2018-11-11 16:44:27 +01:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_Pokeball
2018-11-11 16:44:27 +01:00
};
static const struct SpriteTemplate sSpriteTemplate_Select_Arrow =
2018-11-11 16:44:27 +01:00
{
.tileTag = GFXTAG_ARROW,
.paletteTag = PALTAG_INTERFACE,
.oam = &sOam_Select_Arrow,
.anims = sAnims_Select_Interface,
2018-11-11 16:44:27 +01:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
static const struct SpriteTemplate sSpriteTemplate_Select_MenuHighlightLeft =
2018-11-11 16:44:27 +01:00
{
.tileTag = GFXTAG_MENU_HIGHLIGHT_LEFT,
.paletteTag = PALTAG_INTERFACE,
.oam = &sOam_Select_MenuHighlight,
.anims = sAnims_Select_Interface,
2018-11-11 16:44:27 +01:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
static const struct SpriteTemplate sSpriteTemplate_Select_MenuHighlightRight =
2018-11-11 16:44:27 +01:00
{
.tileTag = GFXTAG_MENU_HIGHLIGHT_RIGHT,
.paletteTag = PALTAG_INTERFACE,
.oam = &sOam_Select_MenuHighlight,
.anims = sAnims_Select_Interface,
2018-11-11 16:44:27 +01:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
static const struct SpriteTemplate sSpriteTemplate_Select_MonPicBgAnim =
2018-11-11 16:44:27 +01:00
{
.tileTag = GFXTAG_MON_PIC_BG_ANIM,
.paletteTag = PALTAG_MON_PIC_BG,
.oam = &sOam_Select_MonPicBgAnim,
.anims = sAnims_Select_MonPicBgAnim,
2018-11-11 16:44:27 +01:00
.images = NULL,
.affineAnims = sAffineAnims_Select_MonPicBgAnim,
2018-11-11 16:44:27 +01:00
.callback = SpriteCallbackDummy
};
static const struct SpriteSheet sSwap_SpriteSheets[] =
{
{sArrow_Gfx, sizeof(sArrow_Gfx), GFXTAG_ARROW},
{sMenuHighlightLeft_Gfx, sizeof(sMenuHighlightLeft_Gfx), GFXTAG_MENU_HIGHLIGHT_LEFT},
{sMenuHighlightRight_Gfx, sizeof(sMenuHighlightRight_Gfx), GFXTAG_MENU_HIGHLIGHT_RIGHT},
{sActionBoxLeft_Gfx, sizeof(sActionBoxLeft_Gfx), GFXTAG_ACTION_BOX_LEFT},
{sActionBoxRight_Gfx, sizeof(sActionBoxRight_Gfx), GFXTAG_ACTION_BOX_RIGHT},
{sActionHighlightLeft_Gfx, 0x100, GFXTAG_ACTION_HIGHLIGHT_LEFT},
{sActionHighlightMiddle_Gfx, sizeof(sActionHighlightMiddle_Gfx), GFXTAG_ACTION_HIGHLIGHT_MIDDLE},
{sActionHighlightRight_Gfx, sizeof(sActionHighlightRight_Gfx), GFXTAG_ACTION_HIGHLIGHT_RIGHT},
{sMonPicBgAnim_Gfx, sizeof(sMonPicBgAnim_Gfx), GFXTAG_MON_PIC_BG_ANIM},
2018-11-11 16:44:27 +01:00
{},
};
static const struct CompressedSpriteSheet sSwap_BallGfx[] =
2018-11-11 16:44:27 +01:00
{
{gPokeballSelection_Gfx, 0x800, GFXTAG_BALL},
2018-11-11 16:44:27 +01:00
{},
};
static const struct SpritePalette sSwap_SpritePalettes[] =
2018-11-11 16:44:27 +01:00
{
{sPokeballGray_Pal, PALTAG_BALL_GRAY},
{sPokeballSelected_Pal, PALTAG_BALL_SELECTED},
{sInterface_Pal, PALTAG_INTERFACE},
{sMonPicBg_Pal, PALTAG_MON_PIC_BG},
2018-11-11 16:44:27 +01:00
{},
};
static const struct OamData sOam_Swap_Pokeball =
2018-11-11 16:44:27 +01:00
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
2018-11-11 16:44:27 +01:00
.mosaic = 0,
.bpp = ST_OAM_4BPP,
2019-12-05 04:26:43 +01:00
.shape = SPRITE_SHAPE(32x32),
2018-11-11 16:44:27 +01:00
.x = 0,
.matrixNum = 0,
2019-12-05 04:26:43 +01:00
.size = SPRITE_SIZE(32x32),
2018-11-11 16:44:27 +01:00
.tileNum = 0,
.priority = 3,
.paletteNum = 0,
.affineParam = 0,
};
static const struct OamData sOam_Swap_Arrow =
2018-11-11 16:44:27 +01:00
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
2018-11-11 16:44:27 +01:00
.mosaic = 0,
.bpp = ST_OAM_4BPP,
2019-12-05 04:26:43 +01:00
.shape = SPRITE_SHAPE(16x16),
2018-11-11 16:44:27 +01:00
.x = 0,
.matrixNum = 0,
2019-12-05 04:26:43 +01:00
.size = SPRITE_SIZE(16x16),
2018-11-11 16:44:27 +01:00
.tileNum = 0,
.priority = 3,
.paletteNum = 0,
.affineParam = 0,
};
static const struct OamData sOam_Swap_MenuHighlight =
2018-11-11 16:44:27 +01:00
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
.objMode = ST_OAM_OBJ_NORMAL,
2018-11-11 16:44:27 +01:00
.mosaic = 0,
.bpp = ST_OAM_4BPP,
2019-12-05 04:26:43 +01:00
.shape = SPRITE_SHAPE(32x16),
2018-11-11 16:44:27 +01:00
.x = 0,
.matrixNum = 0,
2019-12-05 04:26:43 +01:00
.size = SPRITE_SIZE(32x16),
2018-11-11 16:44:27 +01:00
.tileNum = 0,
.priority = 2,
.paletteNum = 0,
.affineParam = 0,
};
2020-12-28 23:32:08 +01:00
static const struct OamData sOam_Swap_MonPicBgAnim =
2018-11-11 16:44:27 +01:00
{
.y = 0,
.affineMode = ST_OAM_AFFINE_DOUBLE,
.objMode = ST_OAM_OBJ_BLEND,
2018-11-11 16:44:27 +01:00
.mosaic = 0,
.bpp = ST_OAM_4BPP,
2019-12-05 04:26:43 +01:00
.shape = SPRITE_SHAPE(64x64),
2018-11-11 16:44:27 +01:00
.x = 0,
.matrixNum = 0,
2019-12-05 04:26:43 +01:00
.size = SPRITE_SIZE(64x64),
2018-11-11 16:44:27 +01:00
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
.affineParam = 1,
};
static const union AnimCmd sAnim_Swap_Interface[] =
2018-11-11 16:44:27 +01:00
{
ANIMCMD_FRAME(0, 1),
ANIMCMD_END,
};
2020-12-28 23:32:08 +01:00
static const union AnimCmd sAnim_Swap_MonPicBgAnim[] =
2018-11-11 16:44:27 +01:00
{
ANIMCMD_FRAME(0, 1),
ANIMCMD_END,
};
static const union AnimCmd sAnim_Swap_Pokeball_Still[] =
2018-11-11 16:44:27 +01:00
{
ANIMCMD_FRAME(0, 30),
ANIMCMD_END,
};
static const union AnimCmd sAnim_Swap_Pokeball_Moving[] =
2018-11-11 16:44:27 +01:00
{
ANIMCMD_FRAME(16, 4),
ANIMCMD_FRAME(0, 4),
ANIMCMD_FRAME(32, 4),
ANIMCMD_FRAME(0, 4),
ANIMCMD_FRAME(16, 4),
ANIMCMD_FRAME(0, 4),
ANIMCMD_FRAME(32, 4),
ANIMCMD_FRAME(0, 4),
ANIMCMD_FRAME(0, 32),
ANIMCMD_FRAME(16, 8),
ANIMCMD_FRAME(0, 8),
ANIMCMD_FRAME(32, 8),
ANIMCMD_FRAME(0, 8),
ANIMCMD_FRAME(16, 8),
ANIMCMD_FRAME(0, 8),
ANIMCMD_FRAME(32, 8),
ANIMCMD_FRAME(0, 8),
ANIMCMD_END,
};
static const union AnimCmd * const sAnims_Swap_Interface[] =
2018-11-11 16:44:27 +01:00
{
sAnim_Swap_Interface,
2018-11-11 16:44:27 +01:00
};
2020-12-28 23:32:08 +01:00
static const union AnimCmd * const sAnims_Swap_MonPicBgAnim[] =
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
sAnim_Swap_MonPicBgAnim,
2018-11-11 16:44:27 +01:00
};
static const union AnimCmd * const sAnims_Swap_Pokeball[] =
2018-11-11 16:44:27 +01:00
{
sAnim_Swap_Pokeball_Still,
sAnim_Swap_Pokeball_Moving,
2018-11-11 16:44:27 +01:00
};
2021-03-21 04:47:08 +01:00
static const union AffineAnimCmd sAffineAnim_Swap_MonPicBg_Opening[] =
2018-11-11 16:44:27 +01:00
{
AFFINEANIMCMD_FRAME(5, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(16, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(32, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(64, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(128, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(256, 5, 0, 0),
AFFINEANIMCMD_END,
};
2021-03-21 04:47:08 +01:00
static const union AffineAnimCmd sAffineAnim_Swap_MonPicBg_Closing[] =
2018-11-11 16:44:27 +01:00
{
AFFINEANIMCMD_FRAME(128, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(64, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(32, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(16, 5, 0, 0),
AFFINEANIMCMD_FRAME(0, 0, 0, 1),
AFFINEANIMCMD_FRAME(5, 5, 0, 0),
AFFINEANIMCMD_END,
};
2021-03-21 04:47:08 +01:00
static const union AffineAnimCmd sAffineAnim_Swap_MonPicBg_Open[] =
2018-11-11 16:44:27 +01:00
{
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
AFFINEANIMCMD_END,
};
2020-12-28 23:32:08 +01:00
static const union AffineAnimCmd * const sAffineAnims_Swap_MonPicBgAnim[] =
2018-11-11 16:44:27 +01:00
{
2021-03-21 04:47:08 +01:00
sAffineAnim_Swap_MonPicBg_Opening,
sAffineAnim_Swap_MonPicBg_Closing,
sAffineAnim_Swap_MonPicBg_Open,
2018-11-11 16:44:27 +01:00
};
static const struct SpriteTemplate sSpriteTemplate_Swap_Pokeball =
2018-11-11 16:44:27 +01:00
{
.tileTag = GFXTAG_BALL,
.paletteTag = PALTAG_BALL_GRAY,
.oam = &sOam_Swap_Pokeball,
.anims = sAnims_Swap_Pokeball,
2018-11-11 16:44:27 +01:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCB_Pokeball
2018-11-11 16:44:27 +01:00
};
static const struct SpriteTemplate sSpriteTemplate_Swap_Arrow =
2018-11-11 16:44:27 +01:00
{
.tileTag = GFXTAG_ARROW,
.paletteTag = PALTAG_INTERFACE,
.oam = &sOam_Swap_Arrow,
.anims = sAnims_Swap_Interface,
2018-11-11 16:44:27 +01:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
static const struct SpriteTemplate sSpriteTemplate_Swap_MenuHighlightLeft =
2018-11-11 16:44:27 +01:00
{
.tileTag = GFXTAG_MENU_HIGHLIGHT_LEFT,
.paletteTag = PALTAG_INTERFACE,
.oam = &sOam_Swap_MenuHighlight,
.anims = sAnims_Swap_Interface,
2018-11-11 16:44:27 +01:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
static const struct SpriteTemplate sSpriteTemplate_Swap_MenuHighlightRight =
2018-11-11 16:44:27 +01:00
{
.tileTag = GFXTAG_MENU_HIGHLIGHT_RIGHT,
.paletteTag = PALTAG_INTERFACE,
.oam = &sOam_Swap_MenuHighlight,
.anims = sAnims_Swap_Interface,
2018-11-11 16:44:27 +01:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
static const struct SpriteTemplate sSpriteTemplate_Swap_MonPicBgAnim =
2018-11-11 16:44:27 +01:00
{
.tileTag = GFXTAG_MON_PIC_BG_ANIM,
.paletteTag = PALTAG_MON_PIC_BG,
2020-12-28 23:32:08 +01:00
.oam = &sOam_Swap_MonPicBgAnim,
.anims = sAnims_Swap_MonPicBgAnim,
2018-11-11 16:44:27 +01:00
.images = NULL,
2020-12-28 23:32:08 +01:00
.affineAnims = sAffineAnims_Swap_MonPicBgAnim,
2018-11-11 16:44:27 +01:00
.callback = SpriteCallbackDummy
};
2020-12-28 23:32:08 +01:00
void static (* const sSwap_MenuOptionFuncs[])(u8 taskId) =
2018-11-11 16:44:27 +01:00
{
Swap_OptionSummary,
Swap_OptionSwap,
Swap_OptionRechoose,
2018-11-11 16:44:27 +01:00
};
static const struct BgTemplate sSwap_BgTemplates[4] =
{
{
.bg = 0,
.charBaseIndex = 0,
.mapBaseIndex = 24,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0
},
{
.bg = 1,
.charBaseIndex = 1,
.mapBaseIndex = 25,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0
},
{
.bg = 2,
.charBaseIndex = 2,
.mapBaseIndex = 26,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
},
{
.bg = 3,
.charBaseIndex = 2,
.mapBaseIndex = 27,
.screenSize = 0,
.paletteMode = 0,
.priority = 2,
.baseTile = 0
},
};
2020-12-28 23:32:08 +01:00
enum {
SWAP_WIN_TITLE,
SWAP_WIN_SPECIES,
SWAP_WIN_INFO,
SWAP_WIN_OPTIONS,
SWAP_WIN_YES_NO,
2020-12-31 06:26:14 +01:00
SWAP_WIN_ACTION_FADE, // Used for action text fading out during screen transition
SWAP_WIN_UNUSED,
SWAP_WIN_SPECIES_AT_FADE, // Used to print species name stopped at current fade level
2020-12-28 23:32:08 +01:00
SWAP_WIN_MON_CATEGORY,
};
2018-11-11 16:44:27 +01:00
static const struct WindowTemplate sSwap_WindowTemplates[] =
{
2020-12-28 23:32:08 +01:00
[SWAP_WIN_TITLE] = {
2018-11-11 16:44:27 +01:00
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 2,
.width = 12,
.height = 2,
.paletteNum = 15,
.baseBlock = 0x0001,
},
2020-12-28 23:32:08 +01:00
[SWAP_WIN_SPECIES] = {
2018-11-11 16:44:27 +01:00
.bg = 2,
.tilemapLeft = 19,
.tilemapTop = 2,
.width = 11,
.height = 2,
.paletteNum = 14,
.baseBlock = 0x0019,
},
2020-12-28 23:32:08 +01:00
[SWAP_WIN_INFO] = {
2018-11-11 16:44:27 +01:00
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 15,
.width = 20,
.height = 3,
.paletteNum = 15,
.baseBlock = 0x002f,
},
2020-12-28 23:32:08 +01:00
[SWAP_WIN_OPTIONS] = {
2018-11-11 16:44:27 +01:00
.bg = 0,
.tilemapLeft = 21,
.tilemapTop = 14,
.width = 9,
.height = 6,
.paletteNum = 15,
.baseBlock = 0x006b,
},
2020-12-28 23:32:08 +01:00
[SWAP_WIN_YES_NO] = {
2018-11-11 16:44:27 +01:00
.bg = 0,
.tilemapLeft = 22,
.tilemapTop = 14,
.width = 8,
.height = 4,
.paletteNum = 15,
.baseBlock = 0x00a1,
},
2020-12-31 06:26:14 +01:00
[SWAP_WIN_ACTION_FADE] = {
2018-11-11 16:44:27 +01:00
.bg = 2,
.tilemapLeft = 21,
.tilemapTop = 15,
.width = 9,
.height = 5,
.paletteNum = 14,
.baseBlock = 0x006b,
},
2020-12-31 06:26:14 +01:00
[SWAP_WIN_UNUSED] = {
2018-11-11 16:44:27 +01:00
.bg = 2,
.tilemapLeft = 10,
.tilemapTop = 2,
.width = 4,
.height = 2,
.paletteNum = 14,
.baseBlock = 0x00c1,
},
2020-12-31 06:26:14 +01:00
[SWAP_WIN_SPECIES_AT_FADE] = {
2018-11-11 16:44:27 +01:00
.bg = 0,
.tilemapLeft = 19,
.tilemapTop = 2,
.width = 11,
.height = 2,
.paletteNum = 15,
.baseBlock = 0x00c9,
},
2020-12-28 23:32:08 +01:00
[SWAP_WIN_MON_CATEGORY] = {
2018-11-11 16:44:27 +01:00
.bg = 0,
.tilemapLeft = 15,
.tilemapTop = 0,
.width = 15,
.height = 2,
.paletteNum = 15,
.baseBlock = 0x00df,
},
DUMMY_WIN_TEMPLATE,
};
static const u16 sSwapText_Pal[] = INCBIN_U16("graphics/battle_frontier/factory_screen/text.gbapal"); // Identical to sSelectText_Pal
2021-04-10 04:39:34 +02:00
static const u8 sSwapMenuOptionsTextColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_TRANSPARENT};
2019-12-10 19:48:20 +01:00
static const u8 sSwapSpeciesNameTextColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_RED, TEXT_COLOR_TRANSPARENT};
2018-11-11 16:44:27 +01:00
2020-12-28 23:32:08 +01:00
#define SWAPACTION_MON 1
#define SWAPACTION_PKMN_FOR_SWAP 2
#define SWAPACTION_CANCEL 3
static const struct SwapScreenAction sSwap_PlayerScreenActions[] =
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
{.id = SWAPACTION_MON, .func = Swap_ActionMon},
{.id = SWAPACTION_MON, .func = Swap_ActionMon},
{.id = SWAPACTION_MON, .func = Swap_ActionMon},
{.id = SWAPACTION_CANCEL, .func = Swap_ActionCancel},
2018-11-11 16:44:27 +01:00
};
static const struct SwapScreenAction sSwap_EnemyScreenActions[] =
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
{.id = SWAPACTION_MON, .func = Swap_ActionMon},
{.id = SWAPACTION_MON, .func = Swap_ActionMon},
{.id = SWAPACTION_MON, .func = Swap_ActionMon},
{.id = SWAPACTION_PKMN_FOR_SWAP, .func = Swap_ActionPkmnForSwap},
{.id = SWAPACTION_CANCEL, .func = Swap_ActionCancel},
2018-11-11 16:44:27 +01:00
};
static void SpriteCB_Pokeball(struct Sprite *sprite)
2018-11-11 16:44:27 +01:00
{
if (sprite->oam.paletteNum == IndexOfSpritePaletteTag(PALTAG_BALL_SELECTED))
2018-11-11 16:44:27 +01:00
{
// Pokeball selected, do rocking animation
2018-11-11 16:44:27 +01:00
if (sprite->animEnded)
{
if (sprite->data[0] != 0)
{
sprite->data[0]--;
}
else if (Random() % 5 == 0)
{
StartSpriteAnim(sprite, 0);
sprite->data[0] = 32;
}
else
{
StartSpriteAnim(sprite, 1);
}
}
else
{
StartSpriteAnimIfDifferent(sprite, 1);
}
}
else
{
// Pokeball not selected, remain still
2018-11-11 16:44:27 +01:00
StartSpriteAnimIfDifferent(sprite, 0);
}
}
static void CB2_SelectScreen(void)
2018-11-11 16:44:27 +01:00
{
AnimateSprites();
BuildOamBuffer();
RunTextPrinters();
UpdatePaletteFade();
RunTasks();
}
static void VBlankCB_SelectScreen(void)
2018-11-11 16:44:27 +01:00
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
void DoBattleFactorySelectScreen(void)
{
sFactorySelectScreen = NULL;
SetMainCallback2(CB2_InitSelectScreen);
}
2020-12-31 06:26:14 +01:00
// Main select states
2020-12-30 23:35:33 +01:00
// States for the main tasks of the Select_ functions after initialization, including:
// Select_Task_OpenSummaryScreen, Select_Task_HandleYesNo, Select_Task_HandleMenu, and Select_Task_HandleChooseMons
// Unnecessarily complicated, could easily have just kept states numbered in each task always starting at 0
// There's only one instance (Select_Task_HandleChooseMons) where a non-initial case is used
// Select_Task_Exit has its own straightforward states
#define STATE_CHOOSE_MONS_INIT 0
#define STATE_CHOOSE_MONS_HANDLE_INPUT 1
#define STATE_MENU_INIT 2
#define STATE_MENU_HANDLE_INPUT 3
#define STATE_YESNO_SHOW_OPTIONS 4
#define STATE_YESNO_HANDLE_INPUT 5
#define STATE_SUMMARY_FADE 6
#define STATE_SUMMARY_CLEAN 7
#define STATE_SUMMARY_SHOW 8
#define STATE_MENU_SHOW_OPTIONS 9
#define STATE_YESNO_SHOW_MONS 10
#define STATE_CHOOSE_MONS_INVALID 11
#define STATE_MENU_REINIT 12
#define STATE_MENU_RESHOW 13
2018-11-11 16:44:27 +01:00
static void CB2_InitSelectScreen(void)
{
u8 taskId;
switch (gMain.state)
{
case 0:
if (sFactorySelectMons != NULL)
FREE_AND_SET_NULL(sFactorySelectMons);
SetHBlankCallback(NULL);
SetVBlankCallback(NULL);
CpuFill32(0, (void *)VRAM, VRAM_SIZE);
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sSelect_BgTemplates, ARRAY_COUNT(sSelect_BgTemplates));
InitWindows(sSelect_WindowTemplates);
DeactivateAllTextPrinters();
gMain.state++;
break;
case 1:
sSelectMenuTilesetBuffer = Alloc(0x440);
sSelectMonPicBgTilesetBuffer = AllocZeroed(0x440);
sSelectMenuTilemapBuffer = Alloc(BG_SCREEN_SIZE);
sSelectMonPicBgTilemapBuffer = AllocZeroed(BG_SCREEN_SIZE);
2021-11-04 04:02:06 +01:00
ChangeBgX(0, 0, BG_COORD_SET);
ChangeBgY(0, 0, BG_COORD_SET);
ChangeBgX(1, 0, BG_COORD_SET);
ChangeBgY(1, 0, BG_COORD_SET);
ChangeBgX(3, 0, BG_COORD_SET);
ChangeBgY(3, 0, BG_COORD_SET);
2018-11-11 16:44:27 +01:00
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
SetGpuReg(REG_OFFSET_BLDY, 0);
SetGpuReg(REG_OFFSET_MOSAIC, 0);
SetGpuReg(REG_OFFSET_WIN0H, 0);
SetGpuReg(REG_OFFSET_WIN0V, 0);
SetGpuReg(REG_OFFSET_WIN1H, 0);
SetGpuReg(REG_OFFSET_WIN1V, 0);
SetGpuReg(REG_OFFSET_WININ, 0);
SetGpuReg(REG_OFFSET_WINOUT, 0);
gMain.state++;
break;
case 2:
ResetPaletteFade();
ResetSpriteData();
ResetTasks();
FreeAllSpritePalettes();
CpuCopy16(gFrontierFactorySelectMenu_Gfx, sSelectMenuTilesetBuffer, 0x440);
CpuCopy16(sMonPicBg_Gfx, sSelectMonPicBgTilesetBuffer, 0x60);
2018-11-11 16:44:27 +01:00
LoadBgTiles(1, sSelectMenuTilesetBuffer, 0x440, 0);
LoadBgTiles(3, sSelectMonPicBgTilesetBuffer, 0x60, 0);
CpuCopy16(gFrontierFactorySelectMenu_Tilemap, sSelectMenuTilemapBuffer, BG_SCREEN_SIZE);
LoadBgTilemap(1, sSelectMenuTilemapBuffer, BG_SCREEN_SIZE, 0);
2018-11-11 16:44:27 +01:00
LoadPalette(gFrontierFactorySelectMenu_Pal, 0, 0x40);
LoadPalette(sSelectText_Pal, 0xF0, 8);
LoadPalette(sSelectText_Pal, 0xE0, 10);
2020-12-31 06:44:43 +01:00
#ifdef UBFIX
if (sFactorySelectScreen && sFactorySelectScreen->fromSummaryScreen)
#else
2018-11-11 16:44:27 +01:00
if (sFactorySelectScreen->fromSummaryScreen == TRUE)
#endif
gPlttBufferUnfaded[228] = sFactorySelectScreen->speciesNameColorBackup;
LoadPalette(sMonPicBg_Pal, 0x20, 4);
2018-11-11 16:44:27 +01:00
gMain.state++;
break;
case 3:
SetBgTilemapBuffer(3, sSelectMonPicBgTilemapBuffer);
CopyToBgTilemapBufferRect(3, sMonPicBg_Tilemap, 11, 4, 8, 8);
CopyToBgTilemapBufferRect(3, sMonPicBg_Tilemap, 2, 4, 8, 8);
CopyToBgTilemapBufferRect(3, sMonPicBg_Tilemap, 20, 4, 8, 8);
2018-11-11 16:44:27 +01:00
CopyBgTilemapBufferToVram(3);
gMain.state++;
break;
case 4:
LoadSpritePalettes(sSelect_SpritePalettes);
LoadSpriteSheets(sSelect_SpriteSheets);
LoadCompressedSpriteSheet(sSelect_BallGfx);
2018-11-11 16:44:27 +01:00
ShowBg(0);
ShowBg(1);
SetVBlankCallback(VBlankCB_SelectScreen);
2021-02-24 17:01:02 +01:00
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK);
2018-11-11 16:44:27 +01:00
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_OBJ_1D_MAP);
2020-12-31 06:44:43 +01:00
#ifdef UBFIX
if (sFactorySelectScreen && sFactorySelectScreen->fromSummaryScreen)
#else
2018-11-11 16:44:27 +01:00
if (sFactorySelectScreen->fromSummaryScreen == TRUE)
#endif
2018-11-11 16:44:27 +01:00
{
Select_SetWinRegs(88, 152, 32, 96);
ShowBg(3);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG3 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_OBJ);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4));
}
else
{
HideBg(3);
}
gMain.state++;
break;
case 5:
2020-12-31 06:44:43 +01:00
#ifdef UBFIX
if (sFactorySelectScreen && sFactorySelectScreen->fromSummaryScreen)
#else
2018-11-11 16:44:27 +01:00
if (sFactorySelectScreen->fromSummaryScreen == TRUE)
#endif
sFactorySelectScreen->cursorPos = gLastViewedMonIndex;
2018-11-11 16:44:27 +01:00
Select_InitMonsData();
Select_InitAllSprites();
if (sFactorySelectScreen->fromSummaryScreen == TRUE)
Select_ReshowMonSprite();
2018-11-11 16:44:27 +01:00
gMain.state++;
break;
case 6:
Select_PrintSelectMonString();
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SELECT_WIN_INFO);
2018-11-11 16:44:27 +01:00
gMain.state++;
break;
case 7:
Select_PrintMonCategory();
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SELECT_WIN_MON_CATEGORY);
2018-11-11 16:44:27 +01:00
gMain.state++;
break;
case 8:
Select_PrintMonSpecies();
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SELECT_WIN_SPECIES);
2018-11-11 16:44:27 +01:00
gMain.state++;
break;
case 9:
Select_PrintRentalPkmnString();
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SELECT_WIN_TITLE);
2018-11-11 16:44:27 +01:00
gMain.state++;
break;
case 10:
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->fadeSpeciesNameTaskId = CreateTask(Select_Task_FadeSpeciesName, 0);
2018-11-11 16:44:27 +01:00
if (!sFactorySelectScreen->fromSummaryScreen)
{
2020-12-31 06:26:14 +01:00
gTasks[sFactorySelectScreen->fadeSpeciesNameTaskId].tState = FADESTATE_INIT;
2020-12-28 23:32:08 +01:00
taskId = CreateTask(Select_Task_HandleChooseMons, 0);
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_CHOOSE_MONS_INIT;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-31 06:26:14 +01:00
gTasks[sFactorySelectScreen->fadeSpeciesNameTaskId].tState = FADESTATE_RUN;
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->fadeSpeciesNameActive = FALSE;
taskId = CreateTask(Select_Task_HandleMenu, 0);
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_MENU_RESHOW;
2018-11-11 16:44:27 +01:00
}
SetMainCallback2(CB2_SelectScreen);
2018-11-11 16:44:27 +01:00
break;
}
}
static void Select_InitMonsData(void)
{
u8 i;
if (sFactorySelectScreen != NULL)
return;
sFactorySelectScreen = AllocZeroed(sizeof(*sFactorySelectScreen));
sFactorySelectScreen->cursorPos = 0;
sFactorySelectScreen->selectingMonsState = 1;
sFactorySelectScreen->fromSummaryScreen = FALSE;
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
sFactorySelectScreen->mons[i].selectedId = 0;
if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_TENT)
CreateFrontierFactorySelectableMons(0);
else
2020-12-28 23:32:08 +01:00
CreateSlateportTentSelectableMons(0);
2018-11-11 16:44:27 +01:00
}
static void Select_InitAllSprites(void)
{
u8 i, cursorPos;
s16 x;
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
{
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->mons[i].ballSpriteId = CreateSprite(&sSpriteTemplate_Select_Pokeball, (35 * i) + 32, 64, 1);
gSprites[sFactorySelectScreen->mons[i].ballSpriteId].data[0] = 0;
2018-11-11 16:44:27 +01:00
Select_SetBallSpritePaletteNum(i);
}
cursorPos = sFactorySelectScreen->cursorPos;
2021-07-07 15:11:52 +02:00
x = gSprites[sFactorySelectScreen->mons[cursorPos].ballSpriteId].x;
sFactorySelectScreen->cursorSpriteId = CreateSprite(&sSpriteTemplate_Select_Arrow, x, 88, 0);
sFactorySelectScreen->menuCursor1SpriteId = CreateSprite(&sSpriteTemplate_Select_MenuHighlightLeft, 176, 112, 0);
sFactorySelectScreen->menuCursor2SpriteId = CreateSprite(&sSpriteTemplate_Select_MenuHighlightRight, 176, 144, 0);
2018-11-11 16:44:27 +01:00
gSprites[sFactorySelectScreen->menuCursor1SpriteId].invisible = TRUE;
gSprites[sFactorySelectScreen->menuCursor2SpriteId].invisible = TRUE;
gSprites[sFactorySelectScreen->menuCursor1SpriteId].centerToCornerVecX = 0;
gSprites[sFactorySelectScreen->menuCursor1SpriteId].centerToCornerVecY = 0;
gSprites[sFactorySelectScreen->menuCursor2SpriteId].centerToCornerVecX = 0;
gSprites[sFactorySelectScreen->menuCursor2SpriteId].centerToCornerVecY = 0;
}
static void Select_DestroyAllSprites(void)
{
u8 i;
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
2020-12-28 23:32:08 +01:00
DestroySprite(&gSprites[sFactorySelectScreen->mons[i].ballSpriteId]);
2018-11-11 16:44:27 +01:00
DestroySprite(&gSprites[sFactorySelectScreen->cursorSpriteId]);
DestroySprite(&gSprites[sFactorySelectScreen->menuCursor1SpriteId]);
DestroySprite(&gSprites[sFactorySelectScreen->menuCursor2SpriteId]);
}
static void Select_UpdateBallCursorPosition(s8 direction)
{
u8 cursorPos;
if (direction > 0) // Move cursor right.
{
if (sFactorySelectScreen->cursorPos != SELECTABLE_MONS_COUNT - 1)
sFactorySelectScreen->cursorPos++;
else
sFactorySelectScreen->cursorPos = 0;
}
else // Move cursor left.
{
if (sFactorySelectScreen->cursorPos != 0)
sFactorySelectScreen->cursorPos--;
else
sFactorySelectScreen->cursorPos = SELECTABLE_MONS_COUNT - 1;
}
cursorPos = sFactorySelectScreen->cursorPos;
2021-07-07 15:11:52 +02:00
gSprites[sFactorySelectScreen->cursorSpriteId].x = gSprites[sFactorySelectScreen->mons[cursorPos].ballSpriteId].x;
2018-11-11 16:44:27 +01:00
}
static void Select_UpdateMenuCursorPosition(s8 direction)
{
if (direction > 0) // Move cursor down.
{
2020-12-28 23:32:08 +01:00
if (sFactorySelectScreen->menuCursorPos != ARRAY_COUNT(sSelect_MenuOptionFuncs) - 1)
2018-11-11 16:44:27 +01:00
sFactorySelectScreen->menuCursorPos++;
else
sFactorySelectScreen->menuCursorPos = 0;
}
else // Move cursor up.
{
if (sFactorySelectScreen->menuCursorPos != 0)
sFactorySelectScreen->menuCursorPos--;
else
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->menuCursorPos = ARRAY_COUNT(sSelect_MenuOptionFuncs) - 1;
2018-11-11 16:44:27 +01:00
}
2021-07-07 15:11:52 +02:00
gSprites[sFactorySelectScreen->menuCursor1SpriteId].y = (sFactorySelectScreen->menuCursorPos * 16) + 112;
gSprites[sFactorySelectScreen->menuCursor2SpriteId].y = (sFactorySelectScreen->menuCursorPos * 16) + 112;
2018-11-11 16:44:27 +01:00
}
static void Select_UpdateYesNoCursorPosition(s8 direction)
{
if (direction > 0) // Move cursor down.
{
if (sFactorySelectScreen->yesNoCursorPos != 1)
sFactorySelectScreen->yesNoCursorPos++;
else
sFactorySelectScreen->yesNoCursorPos = 0;
}
else // Move cursor up.
{
if (sFactorySelectScreen->yesNoCursorPos != 0)
sFactorySelectScreen->yesNoCursorPos--;
else
sFactorySelectScreen->yesNoCursorPos = 1;
}
2021-07-07 15:11:52 +02:00
gSprites[sFactorySelectScreen->menuCursor1SpriteId].y = (sFactorySelectScreen->yesNoCursorPos * 16) + 112;
gSprites[sFactorySelectScreen->menuCursor2SpriteId].y = (sFactorySelectScreen->yesNoCursorPos * 16) + 112;
2018-11-11 16:44:27 +01:00
}
static void Select_HandleMonSelectionChange(void)
{
u8 i, paletteNum;
u8 cursorPos = sFactorySelectScreen->cursorPos;
if (sFactorySelectScreen->mons[cursorPos].selectedId) // Deselect a mon.
{
paletteNum = IndexOfSpritePaletteTag(PALTAG_BALL_GRAY);
if (sFactorySelectScreen->selectingMonsState == FRONTIER_PARTY_SIZE
2020-12-30 23:35:33 +01:00
&& sFactorySelectScreen->mons[cursorPos].selectedId == 1)
2018-11-11 16:44:27 +01:00
{
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
{
2020-12-30 23:35:33 +01:00
if (sFactorySelectScreen->mons[i].selectedId == FRONTIER_PARTY_SIZE - 1)
2018-11-11 16:44:27 +01:00
break;
}
if (i == SELECTABLE_MONS_COUNT)
return;
else
sFactorySelectScreen->mons[i].selectedId = 1;
}
sFactorySelectScreen->mons[cursorPos].selectedId = 0;
sFactorySelectScreen->selectingMonsState--;
}
else // Select a mon.
{
paletteNum = IndexOfSpritePaletteTag(PALTAG_BALL_SELECTED);
2018-11-11 16:44:27 +01:00
sFactorySelectScreen->mons[cursorPos].selectedId = sFactorySelectScreen->selectingMonsState;
sFactorySelectScreen->selectingMonsState++;
}
2020-12-28 23:32:08 +01:00
gSprites[sFactorySelectScreen->mons[cursorPos].ballSpriteId].oam.paletteNum = paletteNum;
2018-11-11 16:44:27 +01:00
}
static void Select_SetBallSpritePaletteNum(u8 id)
{
u8 palNum;
if (sFactorySelectScreen->mons[id].selectedId)
palNum = IndexOfSpritePaletteTag(PALTAG_BALL_SELECTED);
2018-11-11 16:44:27 +01:00
else
palNum = IndexOfSpritePaletteTag(PALTAG_BALL_GRAY);
2018-11-11 16:44:27 +01:00
2020-12-28 23:32:08 +01:00
gSprites[sFactorySelectScreen->mons[id].ballSpriteId].oam.paletteNum = palNum;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
static void Select_Task_OpenSummaryScreen(u8 taskId)
2018-11-11 16:44:27 +01:00
{
u8 i;
u8 currMonId;
2020-12-28 23:32:08 +01:00
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
2020-12-30 23:35:33 +01:00
case STATE_SUMMARY_FADE:
2018-11-11 16:44:27 +01:00
gPlttBufferUnfaded[228] = gPlttBufferFaded[228];
2021-02-24 17:01:02 +01:00
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_SUMMARY_CLEAN;
2018-11-11 16:44:27 +01:00
break;
2020-12-30 23:35:33 +01:00
case STATE_SUMMARY_CLEAN:
2018-11-11 16:44:27 +01:00
if (!gPaletteFade.active)
{
DestroyTask(sFactorySelectScreen->fadeSpeciesNameTaskId);
2020-12-28 23:32:08 +01:00
HideMonPic(sFactorySelectScreen->monPics[1], &sFactorySelectScreen->monPicAnimating);
2018-11-11 16:44:27 +01:00
Select_DestroyAllSprites();
FREE_AND_SET_NULL(sSelectMenuTilesetBuffer);
FREE_AND_SET_NULL(sSelectMonPicBgTilesetBuffer);
2018-11-11 16:44:27 +01:00
FREE_AND_SET_NULL(sSelectMenuTilemapBuffer);
FREE_AND_SET_NULL(sSelectMonPicBgTilemapBuffer);
2018-11-11 16:44:27 +01:00
FreeAllWindowBuffers();
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_SUMMARY_SHOW;
2018-11-11 16:44:27 +01:00
}
break;
2020-12-30 23:35:33 +01:00
case STATE_SUMMARY_SHOW:
sFactorySelectScreen->speciesNameColorBackup = gPlttBufferUnfaded[228];
2018-11-11 16:44:27 +01:00
DestroyTask(taskId);
sFactorySelectScreen->fromSummaryScreen = TRUE;
currMonId = sFactorySelectScreen->cursorPos;
sFactorySelectMons = AllocZeroed(sizeof(struct Pokemon) * SELECTABLE_MONS_COUNT);
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
sFactorySelectMons[i] = sFactorySelectScreen->mons[i].monData;
ShowPokemonSummaryScreen(SUMMARY_MODE_LOCK_MOVES, sFactorySelectMons, currMonId, SELECTABLE_MONS_COUNT - 1, CB2_InitSelectScreen);
2018-11-11 16:44:27 +01:00
break;
}
}
2020-12-28 23:32:08 +01:00
static void Select_Task_Exit(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
if (sFactorySelectScreen->monPicAnimating == TRUE)
return;
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
case 0:
2021-02-24 17:01:02 +01:00
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
break;
case 1:
if (!UpdatePaletteFade())
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
Select_CopyMonsToPlayerParty();
DestroyTask(sFactorySelectScreen->fadeSpeciesNameTaskId);
Select_DestroyAllSprites();
FREE_AND_SET_NULL(sSelectMenuTilesetBuffer);
FREE_AND_SET_NULL(sSelectMenuTilemapBuffer);
FREE_AND_SET_NULL(sSelectMonPicBgTilemapBuffer);
FREE_AND_SET_NULL(sFactorySelectScreen);
FreeAllWindowBuffers();
SetMainCallback2(CB2_ReturnToFieldContinueScript);
DestroyTask(taskId);
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
break;
2018-11-11 16:44:27 +01:00
}
}
2020-12-30 23:35:33 +01:00
// Handles the Yes/No prompt when confirming the 3 selected rental pokemon
2020-12-28 23:32:08 +01:00
static void Select_Task_HandleYesNo(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
if (sFactorySelectScreen->monPicAnimating == TRUE)
return;
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
2020-12-30 23:35:33 +01:00
case STATE_YESNO_SHOW_MONS:
Select_ShowChosenMons();
gTasks[taskId].tState = STATE_YESNO_SHOW_OPTIONS;
2020-12-28 23:32:08 +01:00
break;
2020-12-30 23:35:33 +01:00
case STATE_YESNO_SHOW_OPTIONS:
2020-12-28 23:32:08 +01:00
Select_ShowYesNoOptions();
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_YESNO_HANDLE_INPUT;
2020-12-28 23:32:08 +01:00
break;
2020-12-30 23:35:33 +01:00
case STATE_YESNO_HANDLE_INPUT:
2020-12-28 23:32:08 +01:00
if (JOY_NEW(A_BUTTON))
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
PlaySE(SE_SELECT);
if (sFactorySelectScreen->yesNoCursorPos == 0)
2018-11-11 16:44:27 +01:00
{
2020-12-30 23:35:33 +01:00
// Selected Yes, confirmed selected pokemon
Select_HideChosenMons();
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState = 0;
gTasks[taskId].func = Select_Task_Exit;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
else
2018-11-11 16:44:27 +01:00
{
2020-12-30 23:35:33 +01:00
// Selected No, continue choosing pokemon
Select_ErasePopupMenu(SELECT_WIN_YES_NO);
Select_DeclineChosenMons();
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->fadeSpeciesNameActive = TRUE;
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_CHOOSE_MONS_HANDLE_INPUT;
2020-12-28 23:32:08 +01:00
gTasks[taskId].func = Select_Task_HandleChooseMons;
2018-11-11 16:44:27 +01:00
}
}
2020-12-28 23:32:08 +01:00
else if (JOY_NEW(B_BUTTON))
{
2020-12-30 23:35:33 +01:00
// Pressed B, Continue choosing pokemon
2020-12-28 23:32:08 +01:00
PlaySE(SE_SELECT);
2020-12-30 23:35:33 +01:00
Select_ErasePopupMenu(SELECT_WIN_YES_NO);
Select_DeclineChosenMons();
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->fadeSpeciesNameActive = TRUE;
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_CHOOSE_MONS_HANDLE_INPUT;
2020-12-28 23:32:08 +01:00
gTasks[taskId].func = Select_Task_HandleChooseMons;
}
else if (JOY_REPEAT(DPAD_UP))
{
PlaySE(SE_SELECT);
Select_UpdateYesNoCursorPosition(-1);
}
else if (JOY_REPEAT(DPAD_DOWN))
{
PlaySE(SE_SELECT);
Select_UpdateYesNoCursorPosition(1);
}
break;
2018-11-11 16:44:27 +01:00
}
}
2020-12-30 23:35:33 +01:00
// Handles the popup menu that shows when a pokemon is selected
2020-12-28 23:32:08 +01:00
static void Select_Task_HandleMenu(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
2020-12-30 23:35:33 +01:00
case STATE_MENU_INIT:
2018-11-11 16:44:27 +01:00
if (!sFactorySelectScreen->fromSummaryScreen)
2020-12-28 23:32:08 +01:00
OpenMonPic(&sFactorySelectScreen->monPics[1].bgSpriteId, &sFactorySelectScreen->monPicAnimating, FALSE);
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_MENU_SHOW_OPTIONS;
2018-11-11 16:44:27 +01:00
break;
2020-12-30 23:35:33 +01:00
case STATE_MENU_SHOW_OPTIONS:
2020-12-28 23:32:08 +01:00
if (sFactorySelectScreen->monPicAnimating != TRUE)
2018-11-11 16:44:27 +01:00
{
Select_ShowMenuOptions();
sFactorySelectScreen->fromSummaryScreen = FALSE;
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_MENU_HANDLE_INPUT;
2018-11-11 16:44:27 +01:00
}
break;
2020-12-30 23:35:33 +01:00
case STATE_MENU_HANDLE_INPUT:
2020-12-28 23:32:08 +01:00
if (JOY_NEW(A_BUTTON))
2018-11-11 16:44:27 +01:00
{
u8 retVal;
PlaySE(SE_SELECT);
retVal = Select_RunMenuOptionFunc();
2020-12-30 23:35:33 +01:00
if (retVal == SELECT_CONTINUE_CHOOSING)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->fadeSpeciesNameActive = TRUE;
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_CHOOSE_MONS_HANDLE_INPUT;
2020-12-28 23:32:08 +01:00
gTasks[taskId].func = Select_Task_HandleChooseMons;
2018-11-11 16:44:27 +01:00
}
2020-12-30 23:35:33 +01:00
else if (retVal == SELECT_CONFIRM_MONS)
2018-11-11 16:44:27 +01:00
{
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_YESNO_SHOW_MONS;
2020-12-28 23:32:08 +01:00
gTasks[taskId].func = Select_Task_HandleYesNo;
2018-11-11 16:44:27 +01:00
}
2020-12-30 23:35:33 +01:00
else if (retVal == SELECT_INVALID_MON)
2018-11-11 16:44:27 +01:00
{
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_CHOOSE_MONS_INVALID;
2020-12-28 23:32:08 +01:00
gTasks[taskId].func = Select_Task_HandleChooseMons;
2018-11-11 16:44:27 +01:00
}
2020-12-30 23:35:33 +01:00
else // SELECT_SUMMARY
2018-11-11 16:44:27 +01:00
{
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_SUMMARY_FADE;
2020-12-28 23:32:08 +01:00
gTasks[taskId].func = Select_Task_OpenSummaryScreen;
2018-11-11 16:44:27 +01:00
}
}
2020-12-28 23:32:08 +01:00
else if (JOY_NEW(B_BUTTON))
2018-11-11 16:44:27 +01:00
{
PlaySE(SE_SELECT);
2020-12-28 23:32:08 +01:00
CloseMonPic(sFactorySelectScreen->monPics[1], &sFactorySelectScreen->monPicAnimating, FALSE);
2020-12-30 23:35:33 +01:00
Select_ErasePopupMenu(SELECT_WIN_OPTIONS);
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->fadeSpeciesNameActive = TRUE;
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_CHOOSE_MONS_HANDLE_INPUT;
2020-12-28 23:32:08 +01:00
gTasks[taskId].func = Select_Task_HandleChooseMons;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
else if (JOY_REPEAT(DPAD_UP))
2018-11-11 16:44:27 +01:00
{
PlaySE(SE_SELECT);
Select_UpdateMenuCursorPosition(-1);
}
2020-12-28 23:32:08 +01:00
else if (JOY_REPEAT(DPAD_DOWN))
2018-11-11 16:44:27 +01:00
{
PlaySE(SE_SELECT);
Select_UpdateMenuCursorPosition(1);
}
break;
2020-12-30 23:35:33 +01:00
case STATE_MENU_REINIT:
2018-11-11 16:44:27 +01:00
if (!gPaletteFade.active)
{
if (sFactorySelectScreen->fromSummaryScreen == TRUE)
{
gPlttBufferFaded[228] = sFactorySelectScreen->speciesNameColorBackup;
2018-11-11 16:44:27 +01:00
gPlttBufferUnfaded[228] = gPlttBufferUnfaded[244];
}
sFactorySelectScreen->fromSummaryScreen = FALSE;
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_MENU_HANDLE_INPUT;
2018-11-11 16:44:27 +01:00
}
break;
2020-12-30 23:35:33 +01:00
case STATE_MENU_RESHOW:
2018-11-11 16:44:27 +01:00
Select_ShowMenuOptions();
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_MENU_REINIT;
2018-11-11 16:44:27 +01:00
break;
}
}
2020-12-30 23:35:33 +01:00
// Handles input on the main selection screen, when no popup menu is open
2020-12-28 23:32:08 +01:00
static void Select_Task_HandleChooseMons(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
if (sFactorySelectScreen->monPicAnimating == TRUE)
return;
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
2020-12-30 23:35:33 +01:00
case STATE_CHOOSE_MONS_INIT:
2020-12-28 23:32:08 +01:00
if (!gPaletteFade.active)
2018-11-11 16:44:27 +01:00
{
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_CHOOSE_MONS_HANDLE_INPUT;
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->fadeSpeciesNameActive = TRUE;
}
break;
2020-12-30 23:35:33 +01:00
case STATE_CHOOSE_MONS_HANDLE_INPUT:
2020-12-28 23:32:08 +01:00
if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
sFactorySelectScreen->fadeSpeciesNameActive = FALSE;
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_MENU_INIT;
2020-12-28 23:32:08 +01:00
gTasks[taskId].func = Select_Task_HandleMenu;
}
else if (JOY_REPEAT(DPAD_LEFT))
{
PlaySE(SE_SELECT);
Select_UpdateBallCursorPosition(-1);
Select_PrintMonCategory();
Select_PrintMonSpecies();
}
else if (JOY_REPEAT(DPAD_RIGHT))
{
PlaySE(SE_SELECT);
Select_UpdateBallCursorPosition(1);
Select_PrintMonCategory();
Select_PrintMonSpecies();
}
break;
2020-12-30 23:35:33 +01:00
case STATE_CHOOSE_MONS_INVALID:
2020-12-28 23:32:08 +01:00
if (JOY_NEW(A_BUTTON))
{
PlaySE(SE_SELECT);
CloseMonPic(sFactorySelectScreen->monPics[1], &sFactorySelectScreen->monPicAnimating, FALSE);
Select_PrintSelectMonString();
sFactorySelectScreen->fadeSpeciesNameActive = TRUE;
2020-12-30 23:35:33 +01:00
gTasks[taskId].tState = STATE_CHOOSE_MONS_HANDLE_INPUT;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
break;
2018-11-11 16:44:27 +01:00
}
}
2020-12-31 06:26:14 +01:00
#undef STATE_CHOOSE_MONS_INIT
#undef STATE_CHOOSE_MONS_HANDLE_INPUT
#undef STATE_MENU_INIT
#undef STATE_MENU_HANDLE_INPUT
#undef STATE_YESNO_SHOW_OPTIONS
#undef STATE_YESNO_HANDLE_INPUT
#undef STATE_SUMMARY_FADE
#undef STATE_SUMMARY_CLEAN
#undef STATE_SUMMARY_SHOW
#undef STATE_MENU_SHOW_OPTIONS
#undef STATE_YESNO_SHOW_MONS
#undef STATE_CHOOSE_MONS_INVALID
#undef STATE_MENU_REINIT
#undef STATE_MENU_RESHOW
2018-11-11 16:44:27 +01:00
static void CreateFrontierFactorySelectableMons(u8 firstMonId)
{
u8 i, j = 0;
u8 ivs = 0;
u8 level = 0;
u8 friendship = 0;
2018-11-11 16:44:27 +01:00
u32 otId = 0;
u8 battleMode = VarGet(VAR_FRONTIER_BATTLE_MODE);
u8 lvlMode = gSaveBlock2Ptr->frontier.lvlMode;
u8 challengeNum = gSaveBlock2Ptr->frontier.factoryWinStreaks[battleMode][lvlMode] / 7;
u8 rentalRank = 0;
2018-11-11 16:44:27 +01:00
gFacilityTrainerMons = gBattleFrontierMons;
if (gSaveBlock2Ptr->frontier.lvlMode != FRONTIER_LVL_50)
level = 100;
else
level = 50;
rentalRank = GetNumPastRentalsRank(battleMode, lvlMode);
2018-11-11 16:44:27 +01:00
otId = T1_READ_32(gSaveBlock2Ptr->playerTrainerId);
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
{
u16 monId = gSaveBlock2Ptr->frontier.rentalMons[i].monId;
sFactorySelectScreen->mons[i + firstMonId].monId = monId;
if (i < rentalRank)
2018-11-11 16:44:27 +01:00
ivs = GetFactoryMonFixedIV(challengeNum + 1, 0);
else
ivs = GetFactoryMonFixedIV(challengeNum, 0);
CreateMonWithEVSpreadNatureOTID(&sFactorySelectScreen->mons[i + firstMonId].monData,
gFacilityTrainerMons[monId].species,
2018-11-11 16:44:27 +01:00
level,
gFacilityTrainerMons[monId].nature,
2018-11-11 16:44:27 +01:00
ivs,
gFacilityTrainerMons[monId].evSpread,
2018-11-11 16:44:27 +01:00
otId);
friendship = 0;
for (j = 0; j < MAX_MON_MOVES; j++)
SetMonMoveAvoidReturn(&sFactorySelectScreen->mons[i + firstMonId].monData, gFacilityTrainerMons[monId].moves[j], j);
SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_FRIENDSHIP, &friendship);
SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]);
2018-11-11 16:44:27 +01:00
}
}
2020-12-28 23:32:08 +01:00
static void CreateSlateportTentSelectableMons(u8 firstMonId)
2018-11-11 16:44:27 +01:00
{
u8 i, j;
u8 ivs = 0;
u8 level = 30;
u8 friendship = 0;
2018-11-11 16:44:27 +01:00
u32 otId = 0;
gFacilityTrainerMons = gSlateportBattleTentMons;
otId = T1_READ_32(gSaveBlock2Ptr->playerTrainerId);
for (i = 0; i < SELECTABLE_MONS_COUNT; i++)
{
u16 monId = gSaveBlock2Ptr->frontier.rentalMons[i].monId;
sFactorySelectScreen->mons[i + firstMonId].monId = monId;
2018-11-11 16:44:27 +01:00
CreateMonWithEVSpreadNatureOTID(&sFactorySelectScreen->mons[i + firstMonId].monData,
gFacilityTrainerMons[monId].species,
2018-11-11 16:44:27 +01:00
level,
gFacilityTrainerMons[monId].nature,
2018-11-11 16:44:27 +01:00
ivs,
gFacilityTrainerMons[monId].evSpread,
2018-11-11 16:44:27 +01:00
otId);
friendship = 0;
for (j = 0; j < MAX_MON_MOVES; j++)
SetMonMoveAvoidReturn(&sFactorySelectScreen->mons[i + firstMonId].monData, gFacilityTrainerMons[monId].moves[j], j);
SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_FRIENDSHIP, &friendship);
SetMonData(&sFactorySelectScreen->mons[i + firstMonId].monData, MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]);
2018-11-11 16:44:27 +01:00
}
}
static void Select_CopyMonsToPlayerParty(void)
{
u8 i, j;
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
2018-11-11 16:44:27 +01:00
{
for (j = 0; j < SELECTABLE_MONS_COUNT; j++)
{
if (sFactorySelectScreen->mons[j].selectedId == i + 1)
{
gPlayerParty[i] = sFactorySelectScreen->mons[j].monData;
gSaveBlock2Ptr->frontier.rentalMons[i].monId = sFactorySelectScreen->mons[j].monId;
2019-03-03 09:14:08 +01:00
gSaveBlock2Ptr->frontier.rentalMons[i].personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY, NULL);
2019-05-14 15:22:16 +02:00
gSaveBlock2Ptr->frontier.rentalMons[i].abilityNum = GetBoxMonData(&gPlayerParty[i].box, MON_DATA_ABILITY_NUM, NULL);
2019-02-07 19:58:09 +01:00
gSaveBlock2Ptr->frontier.rentalMons[i].ivs = GetBoxMonData(&gPlayerParty[i].box, MON_DATA_ATK_IV, NULL);
2018-11-11 16:44:27 +01:00
break;
}
}
}
CalculatePlayerPartyCount();
}
static void Select_ShowMenuOptions(void)
{
if (!sFactorySelectScreen->fromSummaryScreen)
sFactorySelectScreen->menuCursorPos = 0;
2021-07-07 15:11:52 +02:00
gSprites[sFactorySelectScreen->menuCursor1SpriteId].x = 176;
gSprites[sFactorySelectScreen->menuCursor1SpriteId].y = (sFactorySelectScreen->menuCursorPos * 16) + 112;
gSprites[sFactorySelectScreen->menuCursor2SpriteId].x = 208;
gSprites[sFactorySelectScreen->menuCursor2SpriteId].y = (sFactorySelectScreen->menuCursorPos * 16) + 112;
2018-11-11 16:44:27 +01:00
gSprites[sFactorySelectScreen->menuCursor1SpriteId].invisible = FALSE;
gSprites[sFactorySelectScreen->menuCursor2SpriteId].invisible = FALSE;
Select_PrintMenuOptions();
}
static void Select_ShowYesNoOptions(void)
{
sFactorySelectScreen->yesNoCursorPos = 0;
2021-07-07 15:11:52 +02:00
gSprites[sFactorySelectScreen->menuCursor1SpriteId].x = 176;
gSprites[sFactorySelectScreen->menuCursor1SpriteId].y = 112;
gSprites[sFactorySelectScreen->menuCursor2SpriteId].x = 208;
gSprites[sFactorySelectScreen->menuCursor2SpriteId].y = 112;
2018-11-11 16:44:27 +01:00
gSprites[sFactorySelectScreen->menuCursor1SpriteId].invisible = FALSE;
gSprites[sFactorySelectScreen->menuCursor2SpriteId].invisible = FALSE;
Select_PrintYesNoOptions();
}
2020-12-30 23:35:33 +01:00
static void Select_ErasePopupMenu(u8 windowId)
2018-11-11 16:44:27 +01:00
{
gSprites[sFactorySelectScreen->menuCursor1SpriteId].invisible = TRUE;
gSprites[sFactorySelectScreen->menuCursor2SpriteId].invisible = TRUE;
FillWindowPixelBuffer(windowId, PIXEL_FILL(0));
2021-11-03 20:29:18 +01:00
CopyWindowToVram(windowId, COPYWIN_GFX);
2018-11-11 16:44:27 +01:00
ClearWindowTilemap(windowId);
}
static void Select_PrintRentalPkmnString(void)
{
2020-12-28 23:32:08 +01:00
FillWindowPixelBuffer(SELECT_WIN_TITLE, PIXEL_FILL(0));
2021-10-30 22:47:37 +02:00
AddTextPrinterParameterized(SELECT_WIN_TITLE, FONT_NORMAL, gText_RentalPkmn2, 2, 1, 0, NULL);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SELECT_WIN_TITLE, COPYWIN_FULL);
2018-11-11 16:44:27 +01:00
}
static void Select_PrintMonSpecies(void)
{
u16 species;
u8 x;
u8 monId = sFactorySelectScreen->cursorPos;
2020-12-28 23:32:08 +01:00
FillWindowPixelBuffer(SELECT_WIN_SPECIES, PIXEL_FILL(0));
2018-11-11 16:44:27 +01:00
species = GetMonData(&sFactorySelectScreen->mons[monId].monData, MON_DATA_SPECIES, NULL);
StringCopy(gStringVar4, gSpeciesNames[species]);
2021-10-30 22:47:37 +02:00
x = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 86);
AddTextPrinterParameterized3(SELECT_WIN_SPECIES, FONT_NORMAL, x, 1, sSpeciesNameTextColors, 0, gStringVar4);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SELECT_WIN_SPECIES, COPYWIN_GFX);
2018-11-11 16:44:27 +01:00
}
static void Select_PrintSelectMonString(void)
{
const u8 *str = NULL;
2020-12-28 23:32:08 +01:00
FillWindowPixelBuffer(SELECT_WIN_INFO, PIXEL_FILL(0));
2018-11-11 16:44:27 +01:00
if (sFactorySelectScreen->selectingMonsState == 1)
str = gText_SelectFirstPkmn;
else if (sFactorySelectScreen->selectingMonsState == 2)
str = gText_SelectSecondPkmn;
else if (sFactorySelectScreen->selectingMonsState == 3)
str = gText_SelectThirdPkmn;
else
str = gText_TheseThreePkmnOkay;
2021-10-30 22:47:37 +02:00
AddTextPrinterParameterized(SELECT_WIN_INFO, FONT_NORMAL, str, 2, 5, 0, NULL);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SELECT_WIN_INFO, COPYWIN_GFX);
2018-11-11 16:44:27 +01:00
}
static void Select_PrintCantSelectSameMon(void)
{
2020-12-28 23:32:08 +01:00
FillWindowPixelBuffer(SELECT_WIN_INFO, PIXEL_FILL(0));
2021-10-30 22:47:37 +02:00
AddTextPrinterParameterized(SELECT_WIN_INFO, FONT_NORMAL, gText_CantSelectSamePkmn, 2, 5, 0, NULL);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SELECT_WIN_INFO, COPYWIN_GFX);
2018-11-11 16:44:27 +01:00
}
static void Select_PrintMenuOptions(void)
{
u8 selectedId = sFactorySelectScreen->mons[sFactorySelectScreen->cursorPos].selectedId;
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SELECT_WIN_OPTIONS);
FillWindowPixelBuffer(SELECT_WIN_OPTIONS, PIXEL_FILL(0));
2021-10-30 22:47:37 +02:00
AddTextPrinterParameterized3(SELECT_WIN_OPTIONS, FONT_NORMAL, 7, 1, sMenuOptionTextColors, 0, gText_Summary);
2018-11-11 16:44:27 +01:00
if (selectedId != 0)
2021-10-30 22:47:37 +02:00
AddTextPrinterParameterized3(SELECT_WIN_OPTIONS, FONT_NORMAL, 7, 17, sMenuOptionTextColors, 0, gText_Deselect);
2018-11-11 16:44:27 +01:00
else
2021-10-30 22:47:37 +02:00
AddTextPrinterParameterized3(SELECT_WIN_OPTIONS, FONT_NORMAL, 7, 17, sMenuOptionTextColors, 0, gText_Rent);
2018-11-11 16:44:27 +01:00
2021-10-30 22:47:37 +02:00
AddTextPrinterParameterized3(SELECT_WIN_OPTIONS, FONT_NORMAL, 7, 33, sMenuOptionTextColors, 0, gText_Others2);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SELECT_WIN_OPTIONS, COPYWIN_FULL);
2018-11-11 16:44:27 +01:00
}
static void Select_PrintYesNoOptions(void)
{
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SELECT_WIN_YES_NO);
FillWindowPixelBuffer(SELECT_WIN_YES_NO, PIXEL_FILL(0));
2021-10-30 22:47:37 +02:00
AddTextPrinterParameterized3(SELECT_WIN_YES_NO, FONT_NORMAL, 7, 1, sMenuOptionTextColors, 0, gText_Yes2);
AddTextPrinterParameterized3(SELECT_WIN_YES_NO, FONT_NORMAL, 7, 17, sMenuOptionTextColors, 0, gText_No2);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SELECT_WIN_YES_NO, COPYWIN_FULL);
2018-11-11 16:44:27 +01:00
}
static u8 Select_RunMenuOptionFunc(void)
{
gFactorySelect_CurrentOptionFunc = sSelect_MenuOptionFuncs[sFactorySelectScreen->menuCursorPos];
return gFactorySelect_CurrentOptionFunc();
2018-11-11 16:44:27 +01:00
}
static u8 Select_OptionRentDeselect(void)
{
u8 selectedId = sFactorySelectScreen->mons[sFactorySelectScreen->cursorPos].selectedId;
u16 monId = sFactorySelectScreen->mons[sFactorySelectScreen->cursorPos].monId;
if (selectedId == 0 && !Select_AreSpeciesValid(monId))
2018-11-11 16:44:27 +01:00
{
Select_PrintCantSelectSameMon();
2020-12-30 23:35:33 +01:00
Select_ErasePopupMenu(SELECT_WIN_OPTIONS);
return SELECT_INVALID_MON;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-28 23:32:08 +01:00
CloseMonPic(sFactorySelectScreen->monPics[1], &sFactorySelectScreen->monPicAnimating, FALSE);
2018-11-11 16:44:27 +01:00
Select_HandleMonSelectionChange();
Select_PrintSelectMonString();
2020-12-30 23:35:33 +01:00
Select_ErasePopupMenu(SELECT_WIN_OPTIONS);
if (sFactorySelectScreen->selectingMonsState > FRONTIER_PARTY_SIZE)
return SELECT_CONFIRM_MONS;
2018-11-11 16:44:27 +01:00
else
2020-12-30 23:35:33 +01:00
return SELECT_CONTINUE_CHOOSING;
2018-11-11 16:44:27 +01:00
}
}
2020-12-30 23:35:33 +01:00
static u8 Select_DeclineChosenMons(void)
2018-11-11 16:44:27 +01:00
{
2020-12-30 23:35:33 +01:00
Select_HideChosenMons();
2018-11-11 16:44:27 +01:00
Select_HandleMonSelectionChange();
Select_PrintSelectMonString();
2020-12-30 23:35:33 +01:00
Select_ErasePopupMenu(SELECT_WIN_OPTIONS);
if (sFactorySelectScreen->selectingMonsState > FRONTIER_PARTY_SIZE)
2018-11-11 16:44:27 +01:00
return 2;
else
return 1;
}
static u8 Select_OptionSummary(void)
{
2020-12-30 23:35:33 +01:00
return SELECT_SUMMARY;
2018-11-11 16:44:27 +01:00
}
static u8 Select_OptionOthers(void)
{
2020-12-28 23:32:08 +01:00
CloseMonPic(sFactorySelectScreen->monPics[1], &sFactorySelectScreen->monPicAnimating, FALSE);
2020-12-30 23:35:33 +01:00
Select_ErasePopupMenu(SELECT_WIN_OPTIONS);
return SELECT_CONTINUE_CHOOSING;
2018-11-11 16:44:27 +01:00
}
static void Select_PrintMonCategory(void)
{
u16 species;
u8 text[30];
u8 x;
u8 monId = sFactorySelectScreen->cursorPos;
if (monId < SELECTABLE_MONS_COUNT)
{
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SELECT_WIN_MON_CATEGORY);
FillWindowPixelBuffer(SELECT_WIN_MON_CATEGORY, PIXEL_FILL(0));
2018-11-11 16:44:27 +01:00
species = GetMonData(&sFactorySelectScreen->mons[monId].monData, MON_DATA_SPECIES, NULL);
CopyMonCategoryText(SpeciesToNationalPokedexNum(species), text);
2021-10-30 22:47:37 +02:00
x = GetStringRightAlignXOffset(FONT_NORMAL, text, 0x76);
AddTextPrinterParameterized(SELECT_WIN_MON_CATEGORY, FONT_NORMAL, text, x, 1, 0, NULL);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SELECT_WIN_MON_CATEGORY, COPYWIN_GFX);
2018-11-11 16:44:27 +01:00
}
}
2020-12-28 23:32:08 +01:00
static void Select_CreateMonSprite(void)
2018-11-11 16:44:27 +01:00
{
u8 monId = sFactorySelectScreen->cursorPos;
struct Pokemon *mon = &sFactorySelectScreen->mons[monId].monData;
u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL);
u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL);
u32 otId = GetMonData(mon, MON_DATA_OT_ID, NULL);
2021-09-14 19:14:14 +02:00
sFactorySelectScreen->monPics[1].monSpriteId = CreateMonPicSprite_HandleDeoxys(species, otId, personality, TRUE, 88, 32, 15, TAG_NONE);
2020-12-28 23:32:08 +01:00
gSprites[sFactorySelectScreen->monPics[1].monSpriteId].centerToCornerVecX = 0;
gSprites[sFactorySelectScreen->monPics[1].monSpriteId].centerToCornerVecY = 0;
2018-11-11 16:44:27 +01:00
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->monPicAnimating = FALSE;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
static void Select_SetMonPicAnimating(bool8 animating)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->monPicAnimating = animating;
2018-11-11 16:44:27 +01:00
}
static void Select_ReshowMonSprite(void)
2018-11-11 16:44:27 +01:00
{
struct Pokemon *mon;
u16 species;
u32 personality, otId;
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->monPics[1].bgSpriteId = CreateSprite(&sSpriteTemplate_Select_MonPicBgAnim, 120, 64, 1);
StartSpriteAffineAnim(&gSprites[sFactorySelectScreen->monPics[1].bgSpriteId], 2);
2018-11-11 16:44:27 +01:00
mon = &sFactorySelectScreen->mons[sFactorySelectScreen->cursorPos].monData;
species = GetMonData(mon, MON_DATA_SPECIES, NULL);
personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL);
otId = GetMonData(mon, MON_DATA_OT_ID, NULL);
2021-09-14 19:14:14 +02:00
sFactorySelectScreen->monPics[1].monSpriteId = CreateMonPicSprite_HandleDeoxys(species, otId, personality, TRUE, 88, 32, 15, TAG_NONE);
2020-12-28 23:32:08 +01:00
gSprites[sFactorySelectScreen->monPics[1].monSpriteId].centerToCornerVecX = 0;
gSprites[sFactorySelectScreen->monPics[1].monSpriteId].centerToCornerVecY = 0;
2018-11-11 16:44:27 +01:00
2020-12-28 23:32:08 +01:00
gSprites[sFactorySelectScreen->monPics[1].bgSpriteId].invisible = TRUE;
2018-11-11 16:44:27 +01:00
}
2020-12-30 23:35:33 +01:00
static void Select_CreateChosenMonsSprites(void)
2018-11-11 16:44:27 +01:00
{
u8 i, j;
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
2018-11-11 16:44:27 +01:00
{
for (j = 0; j < SELECTABLE_MONS_COUNT; j++)
{
if (sFactorySelectScreen->mons[j].selectedId == i + 1)
{
struct Pokemon *mon = &sFactorySelectScreen->mons[j].monData;
u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL);
u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL);
u32 otId = GetMonData(mon, MON_DATA_OT_ID, NULL);
2021-09-14 19:14:14 +02:00
sFactorySelectScreen->monPics[i].monSpriteId = CreateMonPicSprite_HandleDeoxys(species, otId, personality, TRUE, (i * 72) + 16, 32, i + 13, TAG_NONE);
2020-12-28 23:32:08 +01:00
gSprites[sFactorySelectScreen->monPics[i].monSpriteId].centerToCornerVecX = 0;
gSprites[sFactorySelectScreen->monPics[i].monSpriteId].centerToCornerVecY = 0;
2018-11-11 16:44:27 +01:00
break;
}
}
}
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->monPicAnimating = FALSE;
2018-11-11 16:44:27 +01:00
}
2020-12-30 23:35:33 +01:00
static void SpriteCB_OpenChosenMonPics(struct Sprite *sprite)
2018-11-11 16:44:27 +01:00
{
u8 taskId;
2020-12-30 23:35:33 +01:00
// Current sprite is monPics[1]
2018-11-11 16:44:27 +01:00
if (sprite->affineAnimEnded
2020-12-28 23:32:08 +01:00
&& gSprites[sFactorySelectScreen->monPics[0].bgSpriteId].affineAnimEnded
&& gSprites[sFactorySelectScreen->monPics[2].bgSpriteId].affineAnimEnded)
2018-11-11 16:44:27 +01:00
{
sprite->invisible = TRUE;
2020-12-28 23:32:08 +01:00
gSprites[sFactorySelectScreen->monPics[0].bgSpriteId].invisible = TRUE;
gSprites[sFactorySelectScreen->monPics[2].bgSpriteId].invisible = TRUE;
2018-11-11 16:44:27 +01:00
2020-12-30 23:35:33 +01:00
taskId = CreateTask(Select_Task_OpenChosenMonPics, 1);
2018-11-11 16:44:27 +01:00
gTasks[taskId].func(taskId);
sprite->callback = SpriteCallbackDummy;
}
}
2020-12-30 23:35:33 +01:00
static void SpriteCB_CloseChosenMonPics(struct Sprite *sprite)
2018-11-11 16:44:27 +01:00
{
2020-12-30 23:35:33 +01:00
// Current sprite is monPics[1]
2018-11-11 16:44:27 +01:00
if (sprite->affineAnimEnded
2020-12-28 23:32:08 +01:00
&& gSprites[sFactorySelectScreen->monPics[0].bgSpriteId].affineAnimEnded
&& gSprites[sFactorySelectScreen->monPics[2].bgSpriteId].affineAnimEnded)
2018-11-11 16:44:27 +01:00
{
FreeOamMatrix(sprite->oam.matrixNum);
2020-12-28 23:32:08 +01:00
FreeOamMatrix(gSprites[sFactorySelectScreen->monPics[0].bgSpriteId].oam.matrixNum);
FreeOamMatrix(gSprites[sFactorySelectScreen->monPics[2].bgSpriteId].oam.matrixNum);
2018-11-11 16:44:27 +01:00
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->monPicAnimating = FALSE;
2018-11-11 16:44:27 +01:00
2020-12-28 23:32:08 +01:00
DestroySprite(&gSprites[sFactorySelectScreen->monPics[0].bgSpriteId]);
DestroySprite(&gSprites[sFactorySelectScreen->monPics[2].bgSpriteId]);
2018-11-11 16:44:27 +01:00
DestroySprite(sprite);
}
}
2020-12-30 23:35:33 +01:00
// Task data for Select_Task_OpenChosenMonPics, Select_Task_CloseChosenMonPics, Task_CloseMonPic, and Task_OpenMonPic
2020-12-28 23:32:08 +01:00
#define tWinLeft data[3]
#ifndef UBFIX
#define tWinRight data[24] // UB: Typo? Likely meant data[4], 24 is out of bounds
#else
#define tWinRight data[4]
#endif
#define tWinTop data[5]
#define tWinBottom data[8]
#define tSpriteId data[6] // TODO: Clarify, what sprite
#define tIsSwapScreen data[7]
2020-12-30 23:35:33 +01:00
static void Select_Task_OpenChosenMonPics(u8 taskId)
2018-11-11 16:44:27 +01:00
{
struct Task *task = &gTasks[taskId];
2020-12-28 23:32:08 +01:00
switch (task->tState)
2018-11-11 16:44:27 +01:00
{
case 0:
2020-12-28 23:32:08 +01:00
task->tWinLeft = 16;
task->tWinRight = DISPLAY_WIDTH - 16;
task->tWinTop = 64;
task->tWinBottom = 65;
2018-11-11 16:44:27 +01:00
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
2020-12-28 23:32:08 +01:00
SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->tWinLeft, task->tWinRight));
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom));
2018-11-11 16:44:27 +01:00
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ);
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ);
break;
case 1:
ShowBg(3);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG3 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_OBJ);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4));
break;
case 2:
2020-12-28 23:32:08 +01:00
task->tWinTop -= 4;
task->tWinBottom += 4;
if (task->tWinTop <= 32 || task->tWinBottom >= 96)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
task->tWinTop = 32;
task->tWinBottom = 96;
2018-11-11 16:44:27 +01:00
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
}
2020-12-28 23:32:08 +01:00
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom));
if (task->tWinTop != 32)
2018-11-11 16:44:27 +01:00
return;
break;
default:
DestroyTask(taskId);
2020-12-30 23:35:33 +01:00
Select_CreateChosenMonsSprites();
2018-11-11 16:44:27 +01:00
return;
}
2020-12-28 23:32:08 +01:00
task->tState++;
2018-11-11 16:44:27 +01:00
}
2020-12-30 23:35:33 +01:00
static void Select_Task_CloseChosenMonPics(u8 taskId)
2018-11-11 16:44:27 +01:00
{
struct Task *task = &gTasks[taskId];
2020-12-28 23:32:08 +01:00
switch (task->tState)
2018-11-11 16:44:27 +01:00
{
case 0:
2020-12-28 23:32:08 +01:00
task->tWinLeft = 16;
task->tWinRight = DISPLAY_WIDTH - 16;
task->tWinTop = 32;
task->tWinBottom = 96;
2018-11-11 16:44:27 +01:00
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
2020-12-28 23:32:08 +01:00
SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->tWinLeft, task->tWinRight));
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom));
2018-11-11 16:44:27 +01:00
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ);
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ);
2020-12-28 23:32:08 +01:00
task->tState++;
2018-11-11 16:44:27 +01:00
break;
case 1:
2020-12-28 23:32:08 +01:00
task->tWinTop += 4;
task->tWinBottom -= 4;
if (task->tWinTop >= 64 || task->tWinBottom <= 65)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
task->tWinTop = 64;
task->tWinBottom = 65;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom));
if (task->tWinTop == 64)
task->tState++;
2018-11-11 16:44:27 +01:00
break;
2020-12-30 23:35:33 +01:00
default:
HideBg(3);
gSprites[sFactorySelectScreen->monPics[1].bgSpriteId].invisible = FALSE;
gSprites[sFactorySelectScreen->monPics[1].bgSpriteId].callback = SpriteCB_CloseChosenMonPics;
gSprites[sFactorySelectScreen->monPics[0].bgSpriteId].invisible = FALSE;
gSprites[sFactorySelectScreen->monPics[0].bgSpriteId].callback = SpriteCallbackDummy;
gSprites[sFactorySelectScreen->monPics[2].bgSpriteId].invisible = FALSE;
gSprites[sFactorySelectScreen->monPics[2].bgSpriteId].callback = SpriteCallbackDummy;
StartSpriteAffineAnim(&gSprites[sFactorySelectScreen->monPics[1].bgSpriteId], 1);
StartSpriteAffineAnim(&gSprites[sFactorySelectScreen->monPics[0].bgSpriteId], 1);
StartSpriteAffineAnim(&gSprites[sFactorySelectScreen->monPics[2].bgSpriteId], 1);
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
DestroyTask(taskId);
break;
2018-11-11 16:44:27 +01:00
}
}
2020-12-30 23:35:33 +01:00
static void Select_ShowChosenMons(void)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->monPics[1].bgSpriteId = CreateSprite(&sSpriteTemplate_Select_MonPicBgAnim, 120, 64, 1);
sFactorySelectScreen->monPics[0].bgSpriteId = CreateSprite(&sSpriteTemplate_Select_MonPicBgAnim, 44, 64, 1);
sFactorySelectScreen->monPics[2].bgSpriteId = CreateSprite(&sSpriteTemplate_Select_MonPicBgAnim, 196, 64, 1);
2018-11-11 16:44:27 +01:00
2020-12-30 23:35:33 +01:00
gSprites[sFactorySelectScreen->monPics[1].bgSpriteId].callback = SpriteCB_OpenChosenMonPics;
2020-12-28 23:32:08 +01:00
gSprites[sFactorySelectScreen->monPics[0].bgSpriteId].callback = SpriteCallbackDummy;
gSprites[sFactorySelectScreen->monPics[2].bgSpriteId].callback = SpriteCallbackDummy;
2018-11-11 16:44:27 +01:00
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->monPicAnimating = TRUE;
2018-11-11 16:44:27 +01:00
}
2020-12-30 23:35:33 +01:00
static void Select_HideChosenMons(void)
2018-11-11 16:44:27 +01:00
{
u8 taskId;
2020-12-28 23:32:08 +01:00
FreeAndDestroyMonPicSprite(sFactorySelectScreen->monPics[0].monSpriteId);
FreeAndDestroyMonPicSprite(sFactorySelectScreen->monPics[1].monSpriteId);
FreeAndDestroyMonPicSprite(sFactorySelectScreen->monPics[2].monSpriteId);
2018-11-11 16:44:27 +01:00
2020-12-30 23:35:33 +01:00
taskId = CreateTask(Select_Task_CloseChosenMonPics, 1);
2018-11-11 16:44:27 +01:00
gTasks[taskId].func(taskId);
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->monPicAnimating = TRUE;
2018-11-11 16:44:27 +01:00
}
static void Select_SetWinRegs(s16 mWin0H, s16 nWin0H, s16 mWin0V, s16 nWin0V)
{
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(mWin0H, nWin0H));
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(mWin0V, nWin0V));
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ);
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ);
}
static bool32 Select_AreSpeciesValid(u16 monId)
2018-11-11 16:44:27 +01:00
{
u8 i, j;
u32 species = gFacilityTrainerMons[monId].species;
2018-11-11 16:44:27 +01:00
u8 selectState = sFactorySelectScreen->selectingMonsState;
for (i = 1; i < selectState; i++)
{
for (j = 0; j < SELECTABLE_MONS_COUNT; j++)
{
if (sFactorySelectScreen->mons[j].selectedId == i)
{
if (gFacilityTrainerMons[sFactorySelectScreen->mons[j].monId].species == species)
2018-11-11 16:44:27 +01:00
return FALSE;
break;
}
}
}
return TRUE;
}
2020-12-28 23:32:08 +01:00
static void Select_Task_FadeSpeciesName(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
case FADESTATE_INIT:
sFactorySelectScreen->fadeSpeciesNameCoeffDelay = 0;
sFactorySelectScreen->fadeSpeciesNameCoeff = 0;
sFactorySelectScreen->fadeSpeciesNameFadeOut = TRUE;
gTasks[taskId].tState = FADESTATE_RUN;
2018-11-11 16:44:27 +01:00
break;
2020-12-28 23:32:08 +01:00
case FADESTATE_RUN:
if (sFactorySelectScreen->fadeSpeciesNameActive)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
if (sFactorySelectScreen->faceSpeciesNameDelay)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState = FADESTATE_DELAY;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->fadeSpeciesNameCoeffDelay++;
if (sFactorySelectScreen->fadeSpeciesNameCoeffDelay > 6)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->fadeSpeciesNameCoeffDelay = 0;
if (!sFactorySelectScreen->fadeSpeciesNameFadeOut)
sFactorySelectScreen->fadeSpeciesNameCoeff--;
2018-11-11 16:44:27 +01:00
else
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->fadeSpeciesNameCoeff++;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
BlendPalettes(0x4000, sFactorySelectScreen->fadeSpeciesNameCoeff, 0);
if (sFactorySelectScreen->fadeSpeciesNameCoeff > 5)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->fadeSpeciesNameFadeOut = FALSE;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
else if (sFactorySelectScreen->fadeSpeciesNameCoeff == 0)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState = FADESTATE_DELAY;
sFactorySelectScreen->fadeSpeciesNameFadeOut = TRUE;
2018-11-11 16:44:27 +01:00
}
}
}
break;
2020-12-28 23:32:08 +01:00
case FADESTATE_DELAY:
if (sFactorySelectScreen->faceSpeciesNameDelay > 14)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->faceSpeciesNameDelay = 0;
gTasks[taskId].tState = FADESTATE_RUN;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-28 23:32:08 +01:00
sFactorySelectScreen->faceSpeciesNameDelay++;
2018-11-11 16:44:27 +01:00
}
break;
}
}
// Swap Screen's section begins here.
static void Swap_CB2(void)
{
AnimateSprites();
BuildOamBuffer();
RunTextPrinters();
UpdatePaletteFade();
RunTasks();
}
static void Swap_VblankCb(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
static void CopySwappedMonData(void)
{
u8 friendship;
2018-11-11 16:44:27 +01:00
gPlayerParty[sFactorySwapScreen->playerMonId] = gEnemyParty[sFactorySwapScreen->enemyMonId];
friendship = 0;
SetMonData(&gPlayerParty[sFactorySwapScreen->playerMonId], MON_DATA_FRIENDSHIP, &friendship);
gSaveBlock2Ptr->frontier.rentalMons[sFactorySwapScreen->playerMonId].monId = gSaveBlock2Ptr->frontier.rentalMons[sFactorySwapScreen->enemyMonId + FRONTIER_PARTY_SIZE].monId;
gSaveBlock2Ptr->frontier.rentalMons[sFactorySwapScreen->playerMonId].ivs = gSaveBlock2Ptr->frontier.rentalMons[sFactorySwapScreen->enemyMonId + FRONTIER_PARTY_SIZE].ivs;
2019-02-07 19:58:09 +01:00
gSaveBlock2Ptr->frontier.rentalMons[sFactorySwapScreen->playerMonId].personality = GetMonData(&gEnemyParty[sFactorySwapScreen->enemyMonId], MON_DATA_PERSONALITY, NULL);
2019-05-14 15:22:16 +02:00
gSaveBlock2Ptr->frontier.rentalMons[sFactorySwapScreen->playerMonId].abilityNum = GetBoxMonData(&gEnemyParty[sFactorySwapScreen->enemyMonId].box, MON_DATA_ABILITY_NUM, NULL);
2018-11-11 16:44:27 +01:00
}
2020-12-31 06:26:14 +01:00
// Main swap states
// States for the main tasks of the Swap_ functions after initialization, including:
// Swap_Task_OpenSummaryScreen, Swap_Task_HandleYesNo, Swap_Task_HandleMenu, and Swap_Task_HandleChooseMons
// Tasks sharing states was unnecessary, see "Main select states"
#define STATE_CHOOSE_MONS_INIT 0
#define STATE_CHOOSE_MONS_HANDLE_INPUT 1
#define STATE_MENU_INIT 2
#define STATE_MENU_HANDLE_INPUT 3
#define STATE_YESNO_SHOW 4
#define STATE_YESNO_HANDLE_INPUT 5
#define STATE_SUMMARY_FADE 6
#define STATE_SUMMARY_CLEAN 7
#define STATE_SUMMARY_SHOW 8
#define STATE_MENU_SHOW_OPTIONS 9
2020-12-28 23:32:08 +01:00
static void Swap_Task_OpenSummaryScreen(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
case STATE_SUMMARY_FADE:
2021-02-24 17:01:02 +01:00
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
2020-12-31 06:26:14 +01:00
gTasks[taskId].tState = STATE_SUMMARY_CLEAN;
2018-11-11 16:44:27 +01:00
break;
2020-12-31 06:26:14 +01:00
case STATE_SUMMARY_CLEAN:
2018-11-11 16:44:27 +01:00
if (!gPaletteFade.active)
{
DestroyTask(sFactorySwapScreen->fadeSpeciesNameTaskId);
2020-12-28 23:32:08 +01:00
HideMonPic(sFactorySwapScreen->monPic, &sFactorySwapScreen->monPicAnimating);
2018-11-11 16:44:27 +01:00
Swap_DestroyAllSprites();
FREE_AND_SET_NULL(sSwapMenuTilesetBuffer);
FREE_AND_SET_NULL(sSwapMonPicBgTilesetBuffer);
2018-11-11 16:44:27 +01:00
FREE_AND_SET_NULL(sSwapMenuTilemapBuffer);
FREE_AND_SET_NULL(sSwapMonPicBgTilemapBuffer);
2018-11-11 16:44:27 +01:00
FreeAllWindowBuffers();
2020-12-31 06:26:14 +01:00
gTasks[taskId].tState = STATE_SUMMARY_SHOW;
2018-11-11 16:44:27 +01:00
}
break;
2020-12-31 06:26:14 +01:00
case STATE_SUMMARY_SHOW:
2018-11-11 16:44:27 +01:00
DestroyTask(taskId);
sFactorySwapScreen->fromSummaryScreen = TRUE;
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->speciesNameColorBackup = gPlttBufferUnfaded[244];
ShowPokemonSummaryScreen(SUMMARY_MODE_NORMAL, gPlayerParty, sFactorySwapScreen->cursorPos, FRONTIER_PARTY_SIZE - 1, CB2_InitSwapScreen);
2018-11-11 16:44:27 +01:00
break;
}
}
2020-12-28 23:32:08 +01:00
static void Swap_Task_Exit(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
if (sFactorySwapScreen->monPicAnimating == TRUE)
return;
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
case 0:
// Set return value for script
// TRUE if player kept their current pokemon
if (sFactorySwapScreen->monSwapped == TRUE)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
gSpecialVar_Result = FALSE;
}
else
{
gTasks[taskId].tState = 2;
gSpecialVar_Result = TRUE;
}
break;
case 1:
if (sFactorySwapScreen->monSwapped == TRUE)
{
sFactorySwapScreen->enemyMonId = sFactorySwapScreen->cursorPos;
CopySwappedMonData();
}
gTasks[taskId].tState++;
break;
case 2:
2021-02-24 17:01:02 +01:00
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
break;
case 3:
if (!UpdatePaletteFade())
{
DestroyTask(sFactorySwapScreen->fadeSpeciesNameTaskId);
Swap_DestroyAllSprites();
FREE_AND_SET_NULL(sSwapMenuTilesetBuffer);
FREE_AND_SET_NULL(sSwapMonPicBgTilesetBuffer);
FREE_AND_SET_NULL(sSwapMenuTilemapBuffer);
FREE_AND_SET_NULL(sSwapMonPicBgTilemapBuffer);
FREE_AND_SET_NULL(sFactorySwapScreen);
FreeAllWindowBuffers();
SetMainCallback2(CB2_ReturnToFieldContinueScript);
DestroyTask(taskId);
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
break;
2018-11-11 16:44:27 +01:00
}
}
2020-12-31 06:26:14 +01:00
#define tSaidYes data[1]
2020-12-28 23:32:08 +01:00
#define tFollowUpTaskState data[5]
#define tFollowUpTaskPtrHi data[6]
#define tFollowUpTaskPtrLo data[7]
static void Swap_Task_HandleYesNo(u8 taskId)
2018-11-11 16:44:27 +01:00
{
u16 loPtr, hiPtr;
2020-12-28 23:32:08 +01:00
if (sFactorySwapScreen->monPicAnimating == TRUE)
return;
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
case STATE_YESNO_SHOW:
2020-12-28 23:32:08 +01:00
Swap_ShowYesNoOptions();
2020-12-31 06:26:14 +01:00
gTasks[taskId].tState = STATE_YESNO_HANDLE_INPUT;
2020-12-28 23:32:08 +01:00
break;
2020-12-31 06:26:14 +01:00
case STATE_YESNO_HANDLE_INPUT:
2020-12-28 23:32:08 +01:00
if (JOY_NEW(A_BUTTON))
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
PlaySE(SE_SELECT);
if (sFactorySwapScreen->yesNoCursorPos == 0)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
// Selected Yes
gTasks[taskId].tSaidYes = TRUE;
hiPtr = gTasks[taskId].tFollowUpTaskPtrHi;
loPtr = gTasks[taskId].tFollowUpTaskPtrLo;
2018-11-11 16:44:27 +01:00
gTasks[taskId].func = (void*)((hiPtr << 16) | loPtr);
}
2020-12-28 23:32:08 +01:00
else
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
// Selected No
gTasks[taskId].tSaidYes = FALSE;
Swap_ErasePopupMenu(SWAP_WIN_YES_NO);
hiPtr = gTasks[taskId].tFollowUpTaskPtrHi;
loPtr = gTasks[taskId].tFollowUpTaskPtrLo;
gTasks[taskId].func = (void*)((hiPtr << 16) | loPtr);
2018-11-11 16:44:27 +01:00
}
}
2020-12-28 23:32:08 +01:00
else if (JOY_NEW(B_BUTTON))
{
PlaySE(SE_SELECT);
gTasks[taskId].tSaidYes = FALSE;
Swap_ErasePopupMenu(SWAP_WIN_YES_NO);
hiPtr = gTasks[taskId].tFollowUpTaskPtrHi;
loPtr = gTasks[taskId].tFollowUpTaskPtrLo;
gTasks[taskId].func = (void*)((hiPtr << 16) | loPtr);
}
else if (JOY_REPEAT(DPAD_UP))
{
PlaySE(SE_SELECT);
Swap_UpdateYesNoCursorPosition(-1);
}
else if (JOY_REPEAT(DPAD_DOWN))
{
PlaySE(SE_SELECT);
Swap_UpdateYesNoCursorPosition(1);
}
break;
2018-11-11 16:44:27 +01:00
}
}
2020-12-28 23:32:08 +01:00
static void Swap_HandleQuitSwappingResposne(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
if (gTasks[taskId].tSaidYes == TRUE)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState = 0;
gTasks[taskId].func = Swap_Task_Exit;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState = 0;
gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_Task_HandleChooseMons) >> 16;
gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_Task_HandleChooseMons);
2020-12-31 06:26:14 +01:00
gTasks[taskId].tFollowUpTaskState = STATE_CHOOSE_MONS_HANDLE_INPUT;
gTasks[taskId].func = Swap_Task_ScreenInfoTransitionIn;
2018-11-11 16:44:27 +01:00
}
}
2020-12-28 23:32:08 +01:00
static void Swap_AskQuitSwapping(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
if (gTasks[taskId].tState == 0)
2018-11-11 16:44:27 +01:00
{
Swap_PrintOnInfoWindow(gText_QuitSwapping);
sFactorySwapScreen->monSwapped = FALSE;
2020-12-31 06:26:14 +01:00
gTasks[taskId].tState = STATE_YESNO_SHOW;
2020-12-28 23:32:08 +01:00
gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_HandleQuitSwappingResposne) >> 16;
gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_HandleQuitSwappingResposne);
gTasks[taskId].func = Swap_Task_HandleYesNo;
2018-11-11 16:44:27 +01:00
}
}
2020-12-28 23:32:08 +01:00
static void Swap_HandleAcceptMonResponse(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
CloseMonPic(sFactorySwapScreen->monPic, &sFactorySwapScreen->monPicAnimating, TRUE);
if (gTasks[taskId].tSaidYes == TRUE)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState = 0;
gTasks[taskId].func = Swap_Task_Exit;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState = 0;
gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_Task_HandleChooseMons) >> 16;
gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_Task_HandleChooseMons);
2020-12-31 06:26:14 +01:00
gTasks[taskId].tFollowUpTaskState = STATE_CHOOSE_MONS_HANDLE_INPUT;
gTasks[taskId].func = Swap_Task_ScreenInfoTransitionIn;
2018-11-11 16:44:27 +01:00
}
}
2020-12-28 23:32:08 +01:00
static void Swap_AskAcceptMon(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
if (gTasks[taskId].tState == 0)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
OpenMonPic(&sFactorySwapScreen->monPic.bgSpriteId, &sFactorySwapScreen->monPicAnimating, TRUE);
2018-11-11 16:44:27 +01:00
Swap_PrintOnInfoWindow(gText_AcceptThisPkmn);
sFactorySwapScreen->monSwapped = TRUE;
2020-12-31 06:26:14 +01:00
gTasks[taskId].tState = STATE_YESNO_SHOW;
2020-12-28 23:32:08 +01:00
gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_HandleAcceptMonResponse) >> 16;
gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_HandleAcceptMonResponse);
gTasks[taskId].func = Swap_Task_HandleYesNo;
2018-11-11 16:44:27 +01:00
}
}
2020-12-28 23:32:08 +01:00
static void Swap_Task_HandleMenu(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
case STATE_MENU_INIT:
2018-11-11 16:44:27 +01:00
if (!sFactorySwapScreen->fromSummaryScreen)
2020-12-28 23:32:08 +01:00
OpenMonPic(&sFactorySwapScreen->monPic.bgSpriteId, &sFactorySwapScreen->monPicAnimating, TRUE);
2020-12-31 06:26:14 +01:00
gTasks[taskId].tState = STATE_MENU_SHOW_OPTIONS;
2018-11-11 16:44:27 +01:00
break;
2020-12-31 06:26:14 +01:00
case STATE_MENU_SHOW_OPTIONS:
2020-12-28 23:32:08 +01:00
if (sFactorySwapScreen->monPicAnimating != TRUE)
2018-11-11 16:44:27 +01:00
{
Swap_ShowMenuOptions();
2020-12-31 06:26:14 +01:00
gTasks[taskId].tState = STATE_MENU_HANDLE_INPUT;
2018-11-11 16:44:27 +01:00
}
break;
2020-12-31 06:26:14 +01:00
case STATE_MENU_HANDLE_INPUT:
2020-12-28 23:32:08 +01:00
if (sFactorySwapScreen->monPicAnimating != TRUE)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
if (JOY_NEW(A_BUTTON))
2018-11-11 16:44:27 +01:00
{
PlaySE(SE_SELECT);
Swap_RunMenuOptionFunc(taskId);
}
2020-12-28 23:32:08 +01:00
else if (JOY_NEW(B_BUTTON))
2018-11-11 16:44:27 +01:00
{
PlaySE(SE_SELECT);
2020-12-28 23:32:08 +01:00
CloseMonPic(sFactorySwapScreen->monPic, &sFactorySwapScreen->monPicAnimating, TRUE);
Swap_ErasePopupMenu(SWAP_WIN_OPTIONS);
gTasks[taskId].tState = 0;
gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_Task_HandleChooseMons) >> 16;
gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_Task_HandleChooseMons);
2020-12-31 06:26:14 +01:00
gTasks[taskId].tFollowUpTaskState = STATE_CHOOSE_MONS_HANDLE_INPUT;
gTasks[taskId].func = Swap_Task_ScreenInfoTransitionIn;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
else if (JOY_REPEAT(DPAD_UP))
2018-11-11 16:44:27 +01:00
{
Swap_UpdateMenuCursorPosition(-1);
}
2020-12-28 23:32:08 +01:00
else if (JOY_REPEAT(DPAD_DOWN))
2018-11-11 16:44:27 +01:00
{
Swap_UpdateMenuCursorPosition(1);
}
}
break;
}
}
2020-12-31 06:26:14 +01:00
// Handles input on the two main swap screens (choosing a current pokeon to get rid of, and choosing a new pokemon to receive)
2020-12-28 23:32:08 +01:00
static void Swap_Task_HandleChooseMons(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
case STATE_CHOOSE_MONS_INIT:
2018-11-11 16:44:27 +01:00
if (!gPaletteFade.active)
{
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->fadeSpeciesNameActive = TRUE;
2020-12-31 06:26:14 +01:00
gTasks[taskId].tState = STATE_CHOOSE_MONS_HANDLE_INPUT;
2018-11-11 16:44:27 +01:00
}
break;
2020-12-31 06:26:14 +01:00
case STATE_CHOOSE_MONS_HANDLE_INPUT:
2020-12-28 23:32:08 +01:00
if (JOY_NEW(A_BUTTON))
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
// Run whatever action is currently selected (a pokeball, the Cancel button, etc.)
2018-11-11 16:44:27 +01:00
PlaySE(SE_SELECT);
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->fadeSpeciesNameActive = FALSE;
2020-12-31 06:26:14 +01:00
Swap_PrintMonSpeciesAtFade();
Swap_EraseSpeciesWindow();
2018-11-11 16:44:27 +01:00
Swap_RunActionFunc(taskId);
}
2020-12-28 23:32:08 +01:00
else if (JOY_NEW(B_BUTTON))
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
// Ask if player wants to quit swapping
2018-11-11 16:44:27 +01:00
PlaySE(SE_SELECT);
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->fadeSpeciesNameActive = FALSE;
2020-12-31 06:26:14 +01:00
Swap_PrintMonSpeciesAtFade();
Swap_EraseSpeciesWindow();
2020-12-28 23:32:08 +01:00
gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_AskQuitSwapping) >> 16;
gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_AskQuitSwapping);
gTasks[taskId].tState = 0;
gTasks[taskId].tFollowUpTaskState = 0;
2020-12-31 06:26:14 +01:00
gTasks[taskId].func = Swap_Task_ScreenInfoTransitionOut;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
else if (JOY_REPEAT(DPAD_LEFT))
2018-11-11 16:44:27 +01:00
{
Swap_UpdateBallCursorPosition(-1);
Swap_PrintMonCategory();
Swap_PrintMonSpecies();
}
2020-12-28 23:32:08 +01:00
else if (JOY_REPEAT(DPAD_RIGHT))
2018-11-11 16:44:27 +01:00
{
Swap_UpdateBallCursorPosition(1);
Swap_PrintMonCategory();
Swap_PrintMonSpecies();
}
2020-12-28 23:32:08 +01:00
else if (JOY_REPEAT(DPAD_DOWN))
2018-11-11 16:44:27 +01:00
{
Swap_UpdateActionCursorPosition(1);
Swap_PrintMonCategory();
Swap_PrintMonSpecies();
}
2020-12-28 23:32:08 +01:00
else if (JOY_REPEAT(DPAD_UP))
2018-11-11 16:44:27 +01:00
{
Swap_UpdateActionCursorPosition(-1);
Swap_PrintMonCategory();
Swap_PrintMonSpecies();
}
break;
}
}
2020-12-28 23:32:08 +01:00
static void Swap_Task_FadeSpeciesName(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
case FADESTATE_INIT:
sFactorySwapScreen->fadeSpeciesNameCoeffDelay = 0;
sFactorySwapScreen->fadeSpeciesNameCoeff = 0;
sFactorySwapScreen->fadeSpeciesNameFadeOut = TRUE;
gTasks[taskId].tState = FADESTATE_RUN;
2018-11-11 16:44:27 +01:00
break;
2020-12-28 23:32:08 +01:00
case FADESTATE_RUN:
if (sFactorySwapScreen->fadeSpeciesNameActive)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
if (sFactorySwapScreen->faceSpeciesNameDelay)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState = FADESTATE_DELAY;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->fadeSpeciesNameCoeffDelay++;
if (sFactorySwapScreen->fadeSpeciesNameCoeffDelay > 6)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->fadeSpeciesNameCoeffDelay = 0;
if (!sFactorySwapScreen->fadeSpeciesNameFadeOut)
sFactorySwapScreen->fadeSpeciesNameCoeff--;
2018-11-11 16:44:27 +01:00
else
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->fadeSpeciesNameCoeff++;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
BlendPalettes(0x4000, sFactorySwapScreen->fadeSpeciesNameCoeff, 0);
if (sFactorySwapScreen->fadeSpeciesNameCoeff > 5)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->fadeSpeciesNameFadeOut = FALSE;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
else if (sFactorySwapScreen->fadeSpeciesNameCoeff == 0)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState = FADESTATE_DELAY;
sFactorySwapScreen->fadeSpeciesNameFadeOut = TRUE;
2018-11-11 16:44:27 +01:00
}
}
}
break;
2020-12-28 23:32:08 +01:00
case FADESTATE_DELAY:
if (sFactorySwapScreen->faceSpeciesNameDelay > 14)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->faceSpeciesNameDelay = 0;
gTasks[taskId].tState = FADESTATE_RUN;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->faceSpeciesNameDelay++;
2018-11-11 16:44:27 +01:00
}
break;
}
}
2020-12-31 06:26:14 +01:00
#define tFadeOutFinished data[4]
static void Swap_Task_FadeOutSpeciesName(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
case 0:
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->fadeSpeciesNameCoeffDelay = 0;
2020-12-31 06:26:14 +01:00
gTasks[taskId].tFadeOutFinished = FALSE;
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
break;
case 1:
LoadPalette(&gPlttBufferUnfaded[0xF0], 0xE0, 0xA);
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
break;
case 2:
2020-12-28 23:32:08 +01:00
if (sFactorySwapScreen->fadeSpeciesNameCoeff > 15)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
gTasks[taskId].tFadeOutFinished = TRUE;
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->fadeSpeciesNameCoeffDelay++;
if (sFactorySwapScreen->fadeSpeciesNameCoeffDelay > 3)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->fadeSpeciesNameCoeffDelay = 0;
2018-11-11 16:44:27 +01:00
gPlttBufferUnfaded[244] = gPlttBufferFaded[228];
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->fadeSpeciesNameCoeff++;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
BlendPalettes(0x4000, sFactorySwapScreen->fadeSpeciesNameCoeff, 0);
2018-11-11 16:44:27 +01:00
break;
}
}
2020-12-31 06:26:14 +01:00
// Slide current pokeballs offscreen to the right and new pokeballs onscreen from
// the left during transition between player's/enemy's party screens
#define tBallCycled(i) data[(i) + 1]
static void Swap_Task_SlideCycleBalls(u8 taskId)
2018-11-11 16:44:27 +01:00
{
s8 i;
2020-12-31 06:26:14 +01:00
u8 lastX;
bool8 finished;
2018-11-11 16:44:27 +01:00
2020-12-28 23:32:08 +01:00
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
case 0:
2020-12-31 06:26:14 +01:00
gTasks[taskId].tBallCycled(0) = FALSE;
gTasks[taskId].tBallCycled(1) = FALSE;
gTasks[taskId].tBallCycled(2) = FALSE;
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState = 1;
2018-11-11 16:44:27 +01:00
break;
case 1:
2020-12-31 06:26:14 +01:00
lastX = 0;
for (i = FRONTIER_PARTY_SIZE - 1; i >= 0; i--)
2018-11-11 16:44:27 +01:00
{
if (i != FRONTIER_PARTY_SIZE - 1)
2018-11-11 16:44:27 +01:00
{
2021-07-07 15:11:52 +02:00
u8 posX = lastX - gSprites[sFactorySwapScreen->ballSpriteIds[i]].x;
2020-12-31 06:26:14 +01:00
if (posX == 16 || gTasks[taskId].tBallCycled(i + 1) == TRUE)
2018-11-11 16:44:27 +01:00
{
2021-07-07 15:11:52 +02:00
lastX = gSprites[sFactorySwapScreen->ballSpriteIds[i]].x;
gSprites[sFactorySwapScreen->ballSpriteIds[i]].x += 10;
2018-11-11 16:44:27 +01:00
}
else if (posX > 16)
{
2021-07-07 15:11:52 +02:00
gSprites[sFactorySwapScreen->ballSpriteIds[i]].x = gSprites[sFactorySwapScreen->ballSpriteIds[i + 1]].x - 48;
2018-11-11 16:44:27 +01:00
}
}
else
{
2021-07-07 15:11:52 +02:00
lastX = gSprites[sFactorySwapScreen->ballSpriteIds[i]].x;
gSprites[sFactorySwapScreen->ballSpriteIds[i]].x += 10;
2018-11-11 16:44:27 +01:00
}
2020-12-31 06:26:14 +01:00
if (gTasks[taskId].tBallCycled(i) == TRUE)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
// New ball coming in from left, check if it has reached dest
2021-07-07 15:11:52 +02:00
if (gSprites[sFactorySwapScreen->ballSpriteIds[i]].x > (i * 48) + 72)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
// Overshot dest, set x and finish
2021-07-07 15:11:52 +02:00
gSprites[sFactorySwapScreen->ballSpriteIds[i]].x = (i * 48) + 72;
2020-12-31 06:26:14 +01:00
finished = TRUE;
2018-11-11 16:44:27 +01:00
}
2021-07-07 15:11:52 +02:00
else if (gSprites[sFactorySwapScreen->ballSpriteIds[i]].x == (i * 48) + 72)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
finished = TRUE;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-31 06:26:14 +01:00
finished = FALSE;
2018-11-11 16:44:27 +01:00
}
}
else
{
2020-12-31 06:26:14 +01:00
finished = FALSE;
2018-11-11 16:44:27 +01:00
}
2021-07-07 15:11:52 +02:00
if (gSprites[sFactorySwapScreen->ballSpriteIds[i]].x - 16 > DISPLAY_WIDTH)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
// Ball is offscreen right, cycle its palette and move to left side of screen
2021-07-07 15:11:52 +02:00
lastX = gSprites[sFactorySwapScreen->ballSpriteIds[i]].x;
gSprites[sFactorySwapScreen->ballSpriteIds[i]].x = -16;
2018-11-11 16:44:27 +01:00
if (sFactorySwapScreen->inEnemyScreen == TRUE)
gSprites[sFactorySwapScreen->ballSpriteIds[i]].oam.paletteNum = IndexOfSpritePaletteTag(PALTAG_BALL_SELECTED);
2018-11-11 16:44:27 +01:00
else
gSprites[sFactorySwapScreen->ballSpriteIds[i]].oam.paletteNum = IndexOfSpritePaletteTag(PALTAG_BALL_GRAY);
2018-11-11 16:44:27 +01:00
2020-12-31 06:26:14 +01:00
gTasks[taskId].tBallCycled(i) = TRUE;
2018-11-11 16:44:27 +01:00
}
}
2020-12-31 06:26:14 +01:00
if (finished == TRUE)
2018-11-11 16:44:27 +01:00
DestroyTask(taskId);
break;
}
}
2020-12-31 06:26:14 +01:00
// For sliding the action buttons (Cancel, Pkmn for Swap) on/off screen
#define SLIDE_BUTTON_PKMN 0
#define SLIDE_BUTTON_CANCEL 1
#define tTaskId data[1]
#define tSlidingOn data[2]
#define tXIncrement data[3]
// Data to be used by the task that creates this task
#define tSecondSlideDelay data[2]
#define tSlideFinishedPkmn data[3]
#define tSlideFinishedCancel data[4]
static void Swap_Task_SlideButtonOnOffScreen(u8 taskId)
2018-11-11 16:44:27 +01:00
{
u8 i, j;
s32 posX = 0;
2020-12-31 06:26:14 +01:00
s8 deltaX = gTasks[taskId].tXIncrement;
bool8 sliding;
2018-11-11 16:44:27 +01:00
s16 currPosX;
2020-12-31 06:26:14 +01:00
u8 prevTaskId;
2018-11-11 16:44:27 +01:00
2020-12-31 06:26:14 +01:00
if (gTasks[taskId].tSlidingOn == TRUE)
deltaX *= -1;
2018-11-11 16:44:27 +01:00
2020-12-28 23:32:08 +01:00
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
case SLIDE_BUTTON_PKMN:
2021-07-07 15:11:52 +02:00
currPosX = gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0][0]].x;
2020-12-31 06:26:14 +01:00
if (!gTasks[taskId].tSlidingOn)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
// Sliding "Pkmn for Swap" offscreen
if (currPosX + deltaX < DISPLAY_WIDTH)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
sliding = TRUE;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-31 06:26:14 +01:00
sliding = FALSE;
2020-12-28 23:32:08 +01:00
posX = DISPLAY_WIDTH;
2018-11-11 16:44:27 +01:00
}
}
else
{
2020-12-31 06:26:14 +01:00
// Sliding "Pkmn for Swap" onscreen
if (currPosX + deltaX > 160)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
sliding = TRUE;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-31 06:26:14 +01:00
sliding = FALSE;
posX = 160;
2018-11-11 16:44:27 +01:00
}
}
2020-12-31 06:26:14 +01:00
if (sliding == TRUE)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
// Do movement
2020-12-28 23:32:08 +01:00
for (i = 0; i < ARRAY_COUNT(sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0]); i++)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
for (j = 0; j < ARRAY_COUNT(sFactorySwapScreen->pkmnForSwapButtonSpriteIds); j++)
2021-07-07 15:11:52 +02:00
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[j][i]].x += deltaX;
2018-11-11 16:44:27 +01:00
}
}
else
{
2020-12-31 06:26:14 +01:00
// Set final position
2020-12-28 23:32:08 +01:00
for (j = 0; j < ARRAY_COUNT(sFactorySwapScreen->pkmnForSwapButtonSpriteIds); j++)
2018-11-11 16:44:27 +01:00
{
2021-07-07 15:11:52 +02:00
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[j][0]].x = posX;
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[j][1]].x = posX + 16;
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[j][2]].x = posX + 48;
2018-11-11 16:44:27 +01:00
}
2020-12-31 06:26:14 +01:00
prevTaskId = gTasks[taskId].tTaskId;
gTasks[prevTaskId].tSlideFinishedPkmn = TRUE;
2018-11-11 16:44:27 +01:00
DestroyTask(taskId);
}
break;
2020-12-31 06:26:14 +01:00
case SLIDE_BUTTON_CANCEL:
2021-07-07 15:11:52 +02:00
currPosX = gSprites[sFactorySwapScreen->cancelButtonSpriteIds[0][0]].x;
2020-12-31 06:26:14 +01:00
if (!gTasks[taskId].tSlidingOn)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
// Sliding "Cancel" offscreen
if (currPosX + deltaX < DISPLAY_WIDTH)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
sliding = TRUE;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-31 06:26:14 +01:00
sliding = FALSE;
2020-12-28 23:32:08 +01:00
posX = DISPLAY_WIDTH;
2018-11-11 16:44:27 +01:00
}
}
else
{
2020-12-31 06:26:14 +01:00
// Sliding "Cancel" onscreen
if (currPosX + deltaX > 192)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
sliding = TRUE;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-31 06:26:14 +01:00
sliding = FALSE;
posX = 192;
2018-11-11 16:44:27 +01:00
}
}
2020-12-31 06:26:14 +01:00
if (sliding == TRUE)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
// Do movement
2020-12-28 23:32:08 +01:00
for (i = 0; i < ARRAY_COUNT(sFactorySwapScreen->cancelButtonSpriteIds); i++)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
for (j = 0; j < ARRAY_COUNT(sFactorySwapScreen->cancelButtonSpriteIds[0]); j++)
2021-07-07 15:11:52 +02:00
gSprites[sFactorySwapScreen->cancelButtonSpriteIds[j][i]].x += deltaX;
2018-11-11 16:44:27 +01:00
}
}
else
{
2020-12-31 06:26:14 +01:00
// Set final position
2020-12-28 23:32:08 +01:00
for (j = 0; j < ARRAY_COUNT(sFactorySwapScreen->cancelButtonSpriteIds); j++)
2018-11-11 16:44:27 +01:00
{
2021-07-07 15:11:52 +02:00
gSprites[sFactorySwapScreen->cancelButtonSpriteIds[j][0]].x = posX;
gSprites[sFactorySwapScreen->cancelButtonSpriteIds[j][1]].x = posX + 16;
2018-11-11 16:44:27 +01:00
}
2020-12-31 06:26:14 +01:00
prevTaskId = gTasks[taskId].tTaskId;
gTasks[prevTaskId].tSlideFinishedCancel = TRUE;
2018-11-11 16:44:27 +01:00
DestroyTask(taskId);
}
break;
}
}
2020-12-31 06:26:14 +01:00
// Slide action buttons offscreen
static void Swap_Task_ScreenInfoTransitionOut(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
u8 slideTaskId;
2020-12-28 23:32:08 +01:00
u16 hiPtr, loPtr;
2018-11-11 16:44:27 +01:00
2020-12-28 23:32:08 +01:00
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
case 0:
LoadPalette(sSwapText_Pal, 0xE0, sizeof(sSwapText_Pal));
2018-11-11 16:44:27 +01:00
Swap_PrintActionStrings();
2020-12-31 06:26:14 +01:00
PutWindowTilemap(SWAP_WIN_ACTION_FADE);
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
break;
case 1:
2020-12-28 23:32:08 +01:00
Swap_ErasePopupMenu(SWAP_WIN_OPTIONS);
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
break;
case 2:
2020-12-28 23:32:08 +01:00
BeginNormalPaletteFade(0x4000, 0, 0, 16, sPokeballGray_Pal[37]);
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
break;
case 3:
if (!gPaletteFade.active)
{
2020-12-31 06:26:14 +01:00
FillWindowPixelBuffer(SWAP_WIN_ACTION_FADE, PIXEL_FILL(0));
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_ACTION_FADE, COPYWIN_GFX);
2018-11-11 16:44:27 +01:00
if (sFactorySwapScreen->inEnemyScreen == TRUE)
{
2020-12-31 06:26:14 +01:00
// Start "Pkmn for Swap" button slide offscreen
slideTaskId = CreateTask(Swap_Task_SlideButtonOnOffScreen, 0);
gTasks[taskId].tSlideFinishedPkmn = FALSE;
gTasks[slideTaskId].tTaskId = taskId;
gTasks[slideTaskId].tState = SLIDE_BUTTON_PKMN;
gTasks[slideTaskId].tSlidingOn = FALSE;
gTasks[slideTaskId].tXIncrement = 6;
gTasks[taskId].tSecondSlideDelay = 5;
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-31 06:26:14 +01:00
// Start "Cancel" button slide offscreen
slideTaskId = CreateTask(Swap_Task_SlideButtonOnOffScreen, 0);
gTasks[taskId].tSlideFinishedPkmn = TRUE;
gTasks[taskId].tSlideFinishedCancel = FALSE;
gTasks[slideTaskId].tTaskId = taskId;
gTasks[slideTaskId].tState = SLIDE_BUTTON_CANCEL;
gTasks[slideTaskId].tSlidingOn = FALSE;
gTasks[slideTaskId].tXIncrement = 6;
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState += 2;
2018-11-11 16:44:27 +01:00
}
}
break;
case 4:
2020-12-31 06:26:14 +01:00
// Start "Cancel" button slide offscreen for screens with both buttons
if (gTasks[taskId].tSecondSlideDelay == 0)
{
slideTaskId = CreateTask(Swap_Task_SlideButtonOnOffScreen, 0);
gTasks[taskId].tSlideFinishedCancel = FALSE;
gTasks[slideTaskId].tTaskId = taskId;
gTasks[slideTaskId].tState = SLIDE_BUTTON_CANCEL;
gTasks[slideTaskId].tSlidingOn = FALSE;
gTasks[slideTaskId].tXIncrement = 6;
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-31 06:26:14 +01:00
gTasks[taskId].tSecondSlideDelay--;
2018-11-11 16:44:27 +01:00
}
break;
case 5:
if (gTasks[taskId].tSlideFinishedPkmn == TRUE
2020-12-31 06:26:14 +01:00
&& gTasks[taskId].tSlideFinishedCancel == TRUE)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState = gTasks[taskId].tFollowUpTaskState;
hiPtr = gTasks[taskId].tFollowUpTaskPtrHi;
loPtr = gTasks[taskId].tFollowUpTaskPtrLo;
gTasks[taskId].func = (void *)((hiPtr << 16) | (loPtr));
2018-11-11 16:44:27 +01:00
}
break;
}
}
2020-12-31 06:26:14 +01:00
// Slide action buttons onscreen, reprint swap dialogue and mon info
static void Swap_Task_ScreenInfoTransitionIn(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
u8 slideTaskId;
2020-12-28 23:32:08 +01:00
u16 hiPtr, loPtr;
if (sFactorySwapScreen->monPicAnimating == TRUE)
2018-11-11 16:44:27 +01:00
return;
2020-12-28 23:32:08 +01:00
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
case 0:
if (sFactorySwapScreen->inEnemyScreen == TRUE)
{
2020-12-31 06:26:14 +01:00
// Start "Pkmn for Swap" button slide onscreen
slideTaskId = CreateTask(Swap_Task_SlideButtonOnOffScreen, 0);
gTasks[taskId].tSlideFinishedPkmn = FALSE;
gTasks[slideTaskId].tTaskId = taskId;
gTasks[slideTaskId].tState = SLIDE_BUTTON_PKMN;
gTasks[slideTaskId].tSlidingOn = TRUE;
gTasks[slideTaskId].tXIncrement = 6;
gTasks[taskId].tSecondSlideDelay = 10;
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-31 06:26:14 +01:00
// Start "Cancel" button slide onscreen
slideTaskId = CreateTask(Swap_Task_SlideButtonOnOffScreen, 0);
gTasks[taskId].tSlideFinishedPkmn = TRUE;
gTasks[taskId].tSlideFinishedCancel = FALSE;
gTasks[slideTaskId].tTaskId = taskId;
gTasks[slideTaskId].tState = SLIDE_BUTTON_CANCEL;
gTasks[slideTaskId].tSlidingOn = TRUE;
gTasks[slideTaskId].tXIncrement = 6;
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState += 2;
2018-11-11 16:44:27 +01:00
}
break;
case 1:
2020-12-31 06:26:14 +01:00
// Start "Cancel" button slide onscreen for screens with both buttons
if (gTasks[taskId].tSecondSlideDelay == 0)
{
slideTaskId = CreateTask(Swap_Task_SlideButtonOnOffScreen, 0);
gTasks[taskId].tSlideFinishedCancel = FALSE;
gTasks[slideTaskId].tTaskId = taskId;
gTasks[slideTaskId].tState = SLIDE_BUTTON_CANCEL;
gTasks[slideTaskId].tSlidingOn = TRUE;
gTasks[slideTaskId].tXIncrement = 6;
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-31 06:26:14 +01:00
gTasks[taskId].tSecondSlideDelay--;
2018-11-11 16:44:27 +01:00
}
break;
case 2:
if (gTasks[taskId].tSlideFinishedPkmn == TRUE
2020-12-31 06:26:14 +01:00
&& gTasks[taskId].tSlideFinishedCancel == TRUE)
2018-11-11 16:44:27 +01:00
{
gPlttBufferFaded[226] = sPokeballGray_Pal[37];
2018-11-11 16:44:27 +01:00
Swap_PrintActionStrings();
2020-12-31 06:26:14 +01:00
PutWindowTilemap(SWAP_WIN_ACTION_FADE);
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
}
break;
case 3:
2020-12-28 23:32:08 +01:00
BeginNormalPaletteFade(0x4000, 0, 16, 0, sPokeballGray_Pal[37]);
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
break;
case 4:
if (!gPaletteFade.active)
{
Swap_PrintOneActionString(0);
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
}
break;
case 5:
Swap_PrintOneActionString(1);
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SWAP_WIN_OPTIONS);
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
break;
case 6:
2020-12-31 06:26:14 +01:00
FillWindowPixelBuffer(SWAP_WIN_ACTION_FADE, PIXEL_FILL(0));
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_ACTION_FADE, COPYWIN_GFX);
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
break;
case 7:
if (!sFactorySwapScreen->inEnemyScreen)
Swap_PrintOnInfoWindow(gText_SelectPkmnToSwap);
else
Swap_PrintOnInfoWindow(gText_SelectPkmnToAccept);
if (sFactorySwapScreen->cursorPos < FRONTIER_PARTY_SIZE)
2018-11-11 16:44:27 +01:00
gSprites[sFactorySwapScreen->cursorSpriteId].invisible = FALSE;
Swap_PrintMonCategory();
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
break;
case 8:
2020-12-31 06:26:14 +01:00
Swap_PrintMonSpeciesForTransition();
Swap_EraseSpeciesAtFadeWindow();
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->fadeSpeciesNameActive = TRUE;
gTasks[taskId].tState = gTasks[taskId].tFollowUpTaskState;
hiPtr = gTasks[taskId].tFollowUpTaskPtrHi;
loPtr = gTasks[taskId].tFollowUpTaskPtrLo;
gTasks[taskId].func = (void *)((hiPtr << 16) | (loPtr));
2018-11-11 16:44:27 +01:00
break;
}
}
2020-12-31 06:26:14 +01:00
#undef tTaskId
#undef tSlidingOn
#undef tXIncrement
#undef tSlideFinishedPkmn
#undef tSlideFinishedCancel
// For switching between the swap screens with the player's / enemy's parties
static void Swap_Task_SwitchPartyScreen(u8 taskId)
2018-11-11 16:44:27 +01:00
{
u8 i;
2020-12-28 23:32:08 +01:00
if (sFactorySwapScreen->monPicAnimating == TRUE)
2018-11-11 16:44:27 +01:00
return;
2020-12-28 23:32:08 +01:00
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
case 0:
2020-12-31 06:26:14 +01:00
Swap_PrintMonSpeciesForTransition();
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
break;
case 1:
2020-12-31 06:26:14 +01:00
Swap_EraseSpeciesAtFadeWindow();
2018-11-11 16:44:27 +01:00
gSprites[sFactorySwapScreen->cursorSpriteId].invisible = TRUE;
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
break;
case 2:
2020-12-31 06:26:14 +01:00
CreateTask(Swap_Task_SlideCycleBalls, 0);
gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].func = Swap_Task_FadeOutSpeciesName;
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
break;
case 3:
if (!FuncIsActiveTask(Swap_Task_SlideCycleBalls)
2020-12-31 06:26:14 +01:00
&& gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].tFadeOutFinished == TRUE)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
Swap_EraseSpeciesWindow();
2018-11-11 16:44:27 +01:00
if (!sFactorySwapScreen->inEnemyScreen)
{
2020-12-28 23:32:08 +01:00
Swap_InitActions(SWAP_ENEMY_SCREEN);
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-28 23:32:08 +01:00
Swap_InitActions(SWAP_PLAYER_SCREEN);
// Hide "Pkmn for Swap" button
for (i = 0; i < ARRAY_COUNT(sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0]); i++)
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[1][i]].invisible = TRUE;
2018-11-11 16:44:27 +01:00
}
2021-07-07 15:11:52 +02:00
gSprites[sFactorySwapScreen->cursorSpriteId].x = gSprites[sFactorySwapScreen->ballSpriteIds[sFactorySwapScreen->cursorPos]].x;
2020-12-28 23:32:08 +01:00
gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].func = Swap_Task_FadeSpeciesName;
sFactorySwapScreen->fadeSpeciesNameCoeffDelay = 0;
sFactorySwapScreen->fadeSpeciesNameCoeff = 6;
sFactorySwapScreen->fadeSpeciesNameFadeOut = FALSE;
2020-12-31 06:26:14 +01:00
gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].tState = FADESTATE_RUN;
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
}
break;
case 4:
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState = 0;
gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_Task_HandleChooseMons) >> 16;
gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_Task_HandleChooseMons);
2020-12-31 06:26:14 +01:00
gTasks[taskId].tFollowUpTaskState = STATE_CHOOSE_MONS_HANDLE_INPUT;
gTasks[taskId].func = Swap_Task_ScreenInfoTransitionIn;
2018-11-11 16:44:27 +01:00
break;
}
}
2020-12-31 06:26:14 +01:00
#undef tFadeOutFinished
2018-11-11 16:44:27 +01:00
static void Swap_InitStruct(void)
{
if (sFactorySwapScreen == NULL)
{
sFactorySwapScreen = AllocZeroed(sizeof(*sFactorySwapScreen));
sFactorySwapScreen->cursorPos = 0;
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->monPicAnimating = FALSE;
2018-11-11 16:44:27 +01:00
sFactorySwapScreen->fromSummaryScreen = FALSE;
}
}
void DoBattleFactorySwapScreen(void)
{
sFactorySwapScreen = NULL;
SetMainCallback2(CB2_InitSwapScreen);
}
static void CB2_InitSwapScreen(void)
{
u8 taskId;
switch (gMain.state)
{
case 0:
SetHBlankCallback(NULL);
SetVBlankCallback(NULL);
CpuFill32(0, (void *)VRAM, VRAM_SIZE);
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sSwap_BgTemplates, ARRAY_COUNT(sSwap_BgTemplates));
InitWindows(sSwap_WindowTemplates);
DeactivateAllTextPrinters();
gMain.state++;
break;
case 1:
sSwapMenuTilesetBuffer = Alloc(0x440);
sSwapMonPicBgTilesetBuffer = AllocZeroed(0x440);
sSwapMenuTilemapBuffer = Alloc(BG_SCREEN_SIZE);
sSwapMonPicBgTilemapBuffer = AllocZeroed(BG_SCREEN_SIZE);
2021-11-04 04:02:06 +01:00
ChangeBgX(0, 0, BG_COORD_SET);
ChangeBgY(0, 0, BG_COORD_SET);
ChangeBgX(1, 0, BG_COORD_SET);
ChangeBgY(1, 0, BG_COORD_SET);
ChangeBgX(2, 0, BG_COORD_SET);
ChangeBgY(2, 0, BG_COORD_SET);
ChangeBgX(3, 0, BG_COORD_SET);
ChangeBgY(3, 0, BG_COORD_SET);
2018-11-11 16:44:27 +01:00
SetGpuReg(REG_OFFSET_BLDY, 0);
SetGpuReg(REG_OFFSET_MOSAIC, 0);
SetGpuReg(REG_OFFSET_WIN0H, 0);
SetGpuReg(REG_OFFSET_WIN0V, 0);
SetGpuReg(REG_OFFSET_WIN1H, 0);
SetGpuReg(REG_OFFSET_WIN1V, 0);
SetGpuReg(REG_OFFSET_WININ, 0);
SetGpuReg(REG_OFFSET_WINOUT, 0);
gMain.state++;
break;
case 2:
ResetPaletteFade();
ResetSpriteData();
ResetTasks();
FreeAllSpritePalettes();
ResetAllPicSprites();
CpuCopy16(gFrontierFactorySelectMenu_Gfx, sSwapMenuTilesetBuffer, 0x440);
CpuCopy16(sMonPicBg_Gfx, sSwapMonPicBgTilesetBuffer, 0x60);
2018-11-11 16:44:27 +01:00
LoadBgTiles(1, sSwapMenuTilesetBuffer, 0x440, 0);
LoadBgTiles(3, sSwapMonPicBgTilesetBuffer, 0x60, 0);
CpuCopy16(gFrontierFactorySelectMenu_Tilemap, sSwapMenuTilemapBuffer, BG_SCREEN_SIZE);
LoadBgTilemap(1, sSwapMenuTilemapBuffer, BG_SCREEN_SIZE, 0);
2018-11-11 16:44:27 +01:00
LoadPalette(gFrontierFactorySelectMenu_Pal, 0, 0x40);
LoadPalette(sSwapText_Pal, 0xF0, sizeof(sSwapText_Pal));
LoadPalette(sSwapText_Pal, 0xE0, sizeof(sSwapText_Pal));
LoadPalette(sMonPicBg_Pal, 0x20, 4);
2018-11-11 16:44:27 +01:00
gMain.state++;
break;
case 3:
SetBgTilemapBuffer(3, sSwapMonPicBgTilemapBuffer);
CopyToBgTilemapBufferRect(3, sMonPicBg_Tilemap, 11, 4, 8, 8);
2018-11-11 16:44:27 +01:00
CopyBgTilemapBufferToVram(3);
gMain.state++;
break;
case 4:
LoadSpritePalettes(sSwap_SpritePalettes);
LoadSpriteSheets(sSwap_SpriteSheets);
LoadCompressedSpriteSheet(sSwap_BallGfx);
2018-11-11 16:44:27 +01:00
SetVBlankCallback(Swap_VblankCb);
gMain.state++;
break;
case 5:
2020-12-31 06:44:43 +01:00
#ifdef UBFIX
if (sFactorySwapScreen && sFactorySwapScreen->fromSummaryScreen)
#else
2018-11-11 16:44:27 +01:00
if (sFactorySwapScreen->fromSummaryScreen == TRUE)
#endif
sFactorySwapScreen->cursorPos = gLastViewedMonIndex;
2018-11-11 16:44:27 +01:00
gMain.state++;
break;
case 6:
Swap_InitStruct();
Swap_InitAllSprites();
if (sFactorySwapScreen->fromSummaryScreen == TRUE)
Swap_ShowSummaryMonSprite();
2020-12-28 23:32:08 +01:00
Swap_InitActions(SWAP_PLAYER_SCREEN);
2018-11-11 16:44:27 +01:00
gMain.state++;
break;
case 7:
Swap_PrintOnInfoWindow(gText_SelectPkmnToSwap);
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SWAP_WIN_INFO);
2018-11-11 16:44:27 +01:00
gMain.state++;
break;
case 8:
Swap_PrintMonCategory();
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SWAP_WIN_MON_CATEGORY);
2018-11-11 16:44:27 +01:00
gMain.state++;
break;
case 9:
if (!sFactorySwapScreen->fromSummaryScreen)
Swap_PrintMonSpecies();
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SWAP_WIN_SPECIES);
2018-11-11 16:44:27 +01:00
gMain.state++;
break;
case 10:
Swap_PrintPkmnSwap();
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SWAP_WIN_TITLE);
2018-11-11 16:44:27 +01:00
gMain.state++;
break;
case 11:
gMain.state++;
break;
case 12:
if (sFactorySwapScreen->fromSummaryScreen)
2020-12-31 06:26:14 +01:00
Swap_PrintMonSpeciesAtFade();
2018-11-11 16:44:27 +01:00
gMain.state++;
break;
case 13:
Swap_PrintActionStrings2();
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SWAP_WIN_OPTIONS);
2018-11-11 16:44:27 +01:00
gMain.state++;
break;
case 14:
2021-02-24 17:01:02 +01:00
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK);
2018-11-11 16:44:27 +01:00
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
ShowBg(0);
ShowBg(1);
ShowBg(2);
if (sFactorySwapScreen->fromSummaryScreen == TRUE)
{
ShowBg(3);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG3 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_OBJ);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4));
}
else
{
HideBg(3);
}
gMain.state++;
break;
case 15:
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->fadeSpeciesNameTaskId = CreateTask(Swap_Task_FadeSpeciesName, 0);
2018-11-11 16:44:27 +01:00
if (!sFactorySwapScreen->fromSummaryScreen)
{
2020-12-31 06:26:14 +01:00
gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].tState = FADESTATE_INIT;
2020-12-28 23:32:08 +01:00
taskId = CreateTask(Swap_Task_HandleChooseMons, 0);
2020-12-31 06:26:14 +01:00
gTasks[taskId].tState = STATE_CHOOSE_MONS_INIT;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-31 06:26:14 +01:00
Swap_EraseActionFadeWindow();
gTasks[sFactorySwapScreen->fadeSpeciesNameTaskId].tState = FADESTATE_RUN;
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->fadeSpeciesNameActive = FALSE;
taskId = CreateTask(Swap_Task_HandleMenu, 0);
2020-12-31 06:26:14 +01:00
gTasks[taskId].tState = STATE_MENU_INIT;
2018-11-11 16:44:27 +01:00
}
SetMainCallback2(Swap_CB2);
break;
}
}
static void Swap_InitAllSprites(void)
{
u8 i;
u8 x;
struct SpriteTemplate spriteTemplate;
spriteTemplate = sSpriteTemplate_Swap_Pokeball;
spriteTemplate.paletteTag = PALTAG_BALL_SELECTED;
2018-11-11 16:44:27 +01:00
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
2018-11-11 16:44:27 +01:00
{
sFactorySwapScreen->ballSpriteIds[i] = CreateSprite(&spriteTemplate, (48 * i) + 72, 64, 1);
gSprites[sFactorySwapScreen->ballSpriteIds[i]].data[0] = 0;
}
2021-07-07 15:11:52 +02:00
sFactorySwapScreen->cursorSpriteId = CreateSprite(&sSpriteTemplate_Swap_Arrow, gSprites[sFactorySwapScreen->ballSpriteIds[sFactorySwapScreen->cursorPos]].x, 88, 0);
sFactorySwapScreen->menuCursor1SpriteId = CreateSprite(&sSpriteTemplate_Swap_MenuHighlightLeft, 176, 112, 0);
sFactorySwapScreen->menuCursor2SpriteId = CreateSprite(&sSpriteTemplate_Swap_MenuHighlightRight, 176, 144, 0);
2018-11-11 16:44:27 +01:00
gSprites[sFactorySwapScreen->menuCursor1SpriteId].invisible = TRUE;
gSprites[sFactorySwapScreen->menuCursor2SpriteId].invisible = TRUE;
gSprites[sFactorySwapScreen->menuCursor1SpriteId].centerToCornerVecX = 0;
gSprites[sFactorySwapScreen->menuCursor1SpriteId].centerToCornerVecY = 0;
gSprites[sFactorySwapScreen->menuCursor2SpriteId].centerToCornerVecX = 0;
gSprites[sFactorySwapScreen->menuCursor2SpriteId].centerToCornerVecY = 0;
if (sFactorySwapScreen->fromSummaryScreen == TRUE)
2020-12-28 23:32:08 +01:00
x = DISPLAY_WIDTH;
2018-11-11 16:44:27 +01:00
else
2020-12-28 23:32:08 +01:00
x = DISPLAY_WIDTH - 48;
2018-11-11 16:44:27 +01:00
// Unusual way to create sprites
// The sprite template for the selector arrow is re-used
// with the tiles swapped out
spriteTemplate = sSpriteTemplate_Swap_Arrow;
spriteTemplate.tileTag = GFXTAG_ACTION_BOX_LEFT;
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0][0] = CreateSprite(&spriteTemplate, DISPLAY_WIDTH, 120, 10);
2018-11-11 16:44:27 +01:00
spriteTemplate = sSpriteTemplate_Swap_MenuHighlightLeft;
spriteTemplate.tileTag = GFXTAG_ACTION_BOX_RIGHT;
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0][1] = CreateSprite(&spriteTemplate, DISPLAY_WIDTH + 16, 120, 10);
sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0][2] = CreateSprite(&spriteTemplate, DISPLAY_WIDTH + 48, 120, 10);
2018-11-11 16:44:27 +01:00
spriteTemplate = sSpriteTemplate_Swap_Arrow;
spriteTemplate.tileTag = GFXTAG_ACTION_HIGHLIGHT_LEFT;
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->pkmnForSwapButtonSpriteIds[1][0] = CreateSprite(&spriteTemplate, DISPLAY_WIDTH, 120, 1);
2018-11-11 16:44:27 +01:00
spriteTemplate = sSpriteTemplate_Swap_MenuHighlightLeft;
spriteTemplate.tileTag = GFXTAG_ACTION_HIGHLIGHT_MIDDLE;
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->pkmnForSwapButtonSpriteIds[1][1] = CreateSprite(&spriteTemplate, DISPLAY_WIDTH + 16, 120, 1);
spriteTemplate.tileTag = GFXTAG_ACTION_HIGHLIGHT_RIGHT;
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->pkmnForSwapButtonSpriteIds[1][2] = CreateSprite(&spriteTemplate, DISPLAY_WIDTH + 48, 120, 1);
2018-11-11 16:44:27 +01:00
spriteTemplate = sSpriteTemplate_Swap_Arrow;
spriteTemplate.tileTag = GFXTAG_ACTION_BOX_LEFT;
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->cancelButtonSpriteIds[0][0] = CreateSprite(&spriteTemplate, x, 144, 10);
2018-11-11 16:44:27 +01:00
spriteTemplate = sSpriteTemplate_Swap_MenuHighlightLeft;
spriteTemplate.tileTag = GFXTAG_ACTION_BOX_RIGHT;
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->cancelButtonSpriteIds[0][1] = CreateSprite(&spriteTemplate, x + 16, 144, 10);
2018-11-11 16:44:27 +01:00
spriteTemplate = sSpriteTemplate_Swap_Arrow;
spriteTemplate.tileTag = GFXTAG_ACTION_HIGHLIGHT_LEFT;
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->cancelButtonSpriteIds[1][0] = CreateSprite(&spriteTemplate, x, 144, 1);
2018-11-11 16:44:27 +01:00
spriteTemplate = sSpriteTemplate_Swap_MenuHighlightLeft;
spriteTemplate.tileTag = GFXTAG_ACTION_HIGHLIGHT_RIGHT;
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->cancelButtonSpriteIds[1][1] = CreateSprite(&spriteTemplate, x + 16, 144, 1);
2018-11-11 16:44:27 +01:00
for (i = 0; i < 2; i++)
{
2020-12-28 23:32:08 +01:00
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][0]].centerToCornerVecX = 0;
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][0]].centerToCornerVecY = 0;
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][1]].centerToCornerVecX = 0;
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][1]].centerToCornerVecY = 0;
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][2]].centerToCornerVecX = 0;
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][2]].centerToCornerVecY = 0;
gSprites[sFactorySwapScreen->cancelButtonSpriteIds[i][0]].centerToCornerVecX = 0;
gSprites[sFactorySwapScreen->cancelButtonSpriteIds[i][0]].centerToCornerVecY = 0;
gSprites[sFactorySwapScreen->cancelButtonSpriteIds[i][1]].centerToCornerVecX = 0;
gSprites[sFactorySwapScreen->cancelButtonSpriteIds[i][1]].centerToCornerVecY = 0;
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][0]].invisible = TRUE;
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][1]].invisible = TRUE;
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][2]].invisible = TRUE;
gSprites[sFactorySwapScreen->cancelButtonSpriteIds[i][0]].invisible = TRUE;
gSprites[sFactorySwapScreen->cancelButtonSpriteIds[i][1]].invisible = TRUE;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
gSprites[sFactorySwapScreen->cancelButtonSpriteIds[0][0]].invisible = FALSE;
gSprites[sFactorySwapScreen->cancelButtonSpriteIds[0][1]].invisible = FALSE;
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0][0]].invisible = FALSE;
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0][1]].invisible = FALSE;
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0][2]].invisible = FALSE;
2018-11-11 16:44:27 +01:00
}
static void Swap_DestroyAllSprites(void)
{
u8 i, j;
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
2018-11-11 16:44:27 +01:00
DestroySprite(&gSprites[sFactorySwapScreen->ballSpriteIds[i]]);
DestroySprite(&gSprites[sFactorySwapScreen->cursorSpriteId]);
DestroySprite(&gSprites[sFactorySwapScreen->menuCursor1SpriteId]);
DestroySprite(&gSprites[sFactorySwapScreen->menuCursor2SpriteId]);
2020-12-28 23:32:08 +01:00
for (i = 0; i < ARRAY_COUNT(sFactorySwapScreen->pkmnForSwapButtonSpriteIds); i++)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
for (j = 0; j < ARRAY_COUNT(sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0]); j++)
DestroySprite(&gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[i][j]]);
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
for (i = 0; i < ARRAY_COUNT(sFactorySwapScreen->cancelButtonSpriteIds); i++)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
for (j = 0; j < ARRAY_COUNT(sFactorySwapScreen->cancelButtonSpriteIds[0]); j++)
DestroySprite(&gSprites[sFactorySwapScreen->cancelButtonSpriteIds[i][j]]);
2018-11-11 16:44:27 +01:00
}
}
static void Swap_HandleActionCursorChange(u8 cursorId)
{
if (cursorId < FRONTIER_PARTY_SIZE)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
// Cursor is on one of the pokemon
2018-11-11 16:44:27 +01:00
gSprites[sFactorySwapScreen->cursorSpriteId].invisible = FALSE;
2020-12-28 23:32:08 +01:00
Swap_HideActionButtonHighlights();
2021-07-07 15:11:52 +02:00
gSprites[sFactorySwapScreen->cursorSpriteId].x = gSprites[sFactorySwapScreen->ballSpriteIds[cursorId]].x;
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-28 23:32:08 +01:00
// Cursor is on an action button
2018-11-11 16:44:27 +01:00
gSprites[sFactorySwapScreen->cursorSpriteId].invisible = TRUE;
2020-12-28 23:32:08 +01:00
Swap_HighlightActionButton(sFactorySwapScreen->actionsData[cursorId].id);
2018-11-11 16:44:27 +01:00
}
}
static void Swap_UpdateBallCursorPosition(s8 direction)
{
u8 cursorPos;
PlaySE(SE_SELECT);
if (direction > 0) // Move cursor right.
{
if (sFactorySwapScreen->cursorPos + 1 != sFactorySwapScreen->actionsCount)
sFactorySwapScreen->cursorPos++;
else
sFactorySwapScreen->cursorPos = 0;
}
else // Move cursor left.
{
if (sFactorySwapScreen->cursorPos != 0)
sFactorySwapScreen->cursorPos--;
else
sFactorySwapScreen->cursorPos = sFactorySwapScreen->actionsCount - 1;
}
cursorPos = sFactorySwapScreen->cursorPos;
Swap_HandleActionCursorChange(cursorPos);
}
static void Swap_UpdateActionCursorPosition(s8 direction)
{
u8 cursorPos;
PlaySE(SE_SELECT);
if (direction > 0) // Move cursor down.
{
if (sFactorySwapScreen->cursorPos < FRONTIER_PARTY_SIZE)
sFactorySwapScreen->cursorPos = FRONTIER_PARTY_SIZE;
2018-11-11 16:44:27 +01:00
else if (sFactorySwapScreen->cursorPos + 1 != sFactorySwapScreen->actionsCount)
sFactorySwapScreen->cursorPos++;
else
sFactorySwapScreen->cursorPos = 0;
}
else // Move cursor up.
{
if (sFactorySwapScreen->cursorPos < FRONTIER_PARTY_SIZE)
2018-11-11 16:44:27 +01:00
sFactorySwapScreen->cursorPos = sFactorySwapScreen->actionsCount - 1;
else if (sFactorySwapScreen->cursorPos != 0)
sFactorySwapScreen->cursorPos--;
else
sFactorySwapScreen->cursorPos = sFactorySwapScreen->actionsCount - 1;
}
cursorPos = sFactorySwapScreen->cursorPos;
Swap_HandleActionCursorChange(cursorPos);
}
static void Swap_UpdateYesNoCursorPosition(s8 direction)
{
if (direction > 0) // Move cursor down.
{
if (sFactorySwapScreen->yesNoCursorPos != 1)
sFactorySwapScreen->yesNoCursorPos++;
else
sFactorySwapScreen->yesNoCursorPos = 0;
}
else // Move cursor up.
{
if (sFactorySwapScreen->yesNoCursorPos != 0)
sFactorySwapScreen->yesNoCursorPos--;
else
sFactorySwapScreen->yesNoCursorPos = 1;
}
2021-07-07 15:11:52 +02:00
gSprites[sFactorySwapScreen->menuCursor1SpriteId].y = (sFactorySwapScreen->yesNoCursorPos * 16) + 112;
gSprites[sFactorySwapScreen->menuCursor2SpriteId].y = (sFactorySwapScreen->yesNoCursorPos * 16) + 112;
2018-11-11 16:44:27 +01:00
}
static void Swap_UpdateMenuCursorPosition(s8 direction)
{
PlaySE(SE_SELECT);
if (direction > 0) // Move cursor down.
{
2020-12-28 23:32:08 +01:00
if (sFactorySwapScreen->menuCursorPos != ARRAY_COUNT(sSwap_MenuOptionFuncs) - 1)
2018-11-11 16:44:27 +01:00
sFactorySwapScreen->menuCursorPos++;
else
sFactorySwapScreen->menuCursorPos = 0;
}
else // Move cursor up.
{
if (sFactorySwapScreen->menuCursorPos != 0)
sFactorySwapScreen->menuCursorPos--;
else
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->menuCursorPos = ARRAY_COUNT(sSwap_MenuOptionFuncs) - 1;
2018-11-11 16:44:27 +01:00
}
2021-07-07 15:11:52 +02:00
gSprites[sFactorySwapScreen->menuCursor1SpriteId].y = (sFactorySwapScreen->menuCursorPos * 16) + 112;
gSprites[sFactorySwapScreen->menuCursor2SpriteId].y = (sFactorySwapScreen->menuCursorPos * 16) + 112;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
static void Swap_HighlightActionButton(u8 actionId)
2018-11-11 16:44:27 +01:00
{
u8 i;
2020-12-28 23:32:08 +01:00
for (i = 0; i < ARRAY_COUNT(sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0]); i++)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
if (actionId == SWAPACTION_PKMN_FOR_SWAP)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
// Show button highlight on "Pkmn for Swap"
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[1][i]].invisible = FALSE;
// Hide button highlight on Cancel
if (i < ARRAY_COUNT(sFactorySwapScreen->cancelButtonSpriteIds[0]))
gSprites[sFactorySwapScreen->cancelButtonSpriteIds[1][i]].invisible = TRUE;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
else if (actionId == SWAPACTION_CANCEL)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
// Show button highlight on Cancel
if (i < ARRAY_COUNT(sFactorySwapScreen->cancelButtonSpriteIds[0]))
gSprites[sFactorySwapScreen->cancelButtonSpriteIds[1][i]].invisible = FALSE;
// Hide button highlight on "Pkmn for Swap"
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[1][i]].invisible = TRUE;
2018-11-11 16:44:27 +01:00
}
}
}
2020-12-28 23:32:08 +01:00
static void Swap_HideActionButtonHighlights(void)
2018-11-11 16:44:27 +01:00
{
u8 i;
2020-12-28 23:32:08 +01:00
for (i = 0; i < ARRAY_COUNT(sFactorySwapScreen->pkmnForSwapButtonSpriteIds[0]); i++)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
// Hide button highlight on "Pkmn for Swap"
gSprites[sFactorySwapScreen->pkmnForSwapButtonSpriteIds[1][i]].invisible = TRUE;
2020-12-28 23:32:08 +01:00
// Hide button highlight on Cancel
if (i < ARRAY_COUNT(sFactorySwapScreen->cancelButtonSpriteIds[0]))
gSprites[sFactorySwapScreen->cancelButtonSpriteIds[1][i]].invisible = TRUE;
2018-11-11 16:44:27 +01:00
}
}
static void Swap_ShowMenuOptions(void)
{
if (sFactorySwapScreen->fromSummaryScreen == TRUE)
sFactorySwapScreen->fromSummaryScreen = FALSE;
else
sFactorySwapScreen->menuCursorPos = 0;
2021-07-07 15:11:52 +02:00
gSprites[sFactorySwapScreen->menuCursor1SpriteId].x = 176;
gSprites[sFactorySwapScreen->menuCursor1SpriteId].y = (sFactorySwapScreen->menuCursorPos * 16) + 112;
gSprites[sFactorySwapScreen->menuCursor2SpriteId].x = 208;
gSprites[sFactorySwapScreen->menuCursor2SpriteId].y = (sFactorySwapScreen->menuCursorPos * 16) + 112;
2018-11-11 16:44:27 +01:00
gSprites[sFactorySwapScreen->menuCursor1SpriteId].invisible = FALSE;
gSprites[sFactorySwapScreen->menuCursor2SpriteId].invisible = FALSE;
Swap_PrintMenuOptions();
}
static void Swap_ShowYesNoOptions(void)
{
sFactorySwapScreen->yesNoCursorPos = 0;
2021-07-07 15:11:52 +02:00
gSprites[sFactorySwapScreen->menuCursor1SpriteId].x = 176;
gSprites[sFactorySwapScreen->menuCursor1SpriteId].y = 112;
gSprites[sFactorySwapScreen->menuCursor2SpriteId].x = 208;
gSprites[sFactorySwapScreen->menuCursor2SpriteId].y = 112;
2018-11-11 16:44:27 +01:00
gSprites[sFactorySwapScreen->menuCursor1SpriteId].invisible = FALSE;
gSprites[sFactorySwapScreen->menuCursor2SpriteId].invisible = FALSE;
Swap_PrintYesNoOptions();
}
2020-12-28 23:32:08 +01:00
static void Swap_ErasePopupMenu(u8 windowId)
2018-11-11 16:44:27 +01:00
{
gSprites[sFactorySwapScreen->menuCursor1SpriteId].invisible = TRUE;
gSprites[sFactorySwapScreen->menuCursor2SpriteId].invisible = TRUE;
FillWindowPixelBuffer(windowId, PIXEL_FILL(0));
2021-11-03 20:29:18 +01:00
CopyWindowToVram(windowId, COPYWIN_GFX);
2018-11-11 16:44:27 +01:00
ClearWindowTilemap(windowId);
}
2020-12-31 06:26:14 +01:00
static void Swap_EraseSpeciesWindow(void)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SWAP_WIN_SPECIES);
FillWindowPixelBuffer(SWAP_WIN_SPECIES, PIXEL_FILL(0));
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_SPECIES, COPYWIN_GFX);
2018-11-11 16:44:27 +01:00
}
2020-12-31 06:26:14 +01:00
static void Swap_EraseSpeciesAtFadeWindow(void)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
PutWindowTilemap(SWAP_WIN_SPECIES_AT_FADE);
FillWindowPixelBuffer(SWAP_WIN_SPECIES_AT_FADE, PIXEL_FILL(0));
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_SPECIES_AT_FADE, COPYWIN_GFX);
2018-11-11 16:44:27 +01:00
}
2020-12-31 06:26:14 +01:00
static void Swap_EraseActionFadeWindow(void)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
Swap_EraseSpeciesWindow();
PutWindowTilemap(SWAP_WIN_ACTION_FADE);
FillWindowPixelBuffer(SWAP_WIN_ACTION_FADE, PIXEL_FILL(0));
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_ACTION_FADE, COPYWIN_GFX);
2018-11-11 16:44:27 +01:00
}
static void Swap_PrintPkmnSwap(void)
{
2020-12-28 23:32:08 +01:00
FillWindowPixelBuffer(SWAP_WIN_TITLE, PIXEL_FILL(1));
2021-10-30 22:47:37 +02:00
AddTextPrinterParameterized(SWAP_WIN_TITLE, FONT_NORMAL, gText_PkmnSwap, 2, 1, 0, NULL);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_TITLE, COPYWIN_FULL);
2018-11-11 16:44:27 +01:00
}
static void Swap_PrintMonSpecies(void)
{
u16 species;
u8 x;
2020-12-28 23:32:08 +01:00
FillWindowPixelBuffer(SWAP_WIN_SPECIES, PIXEL_FILL(0));
if (sFactorySwapScreen->cursorPos >= FRONTIER_PARTY_SIZE)
2018-11-11 16:44:27 +01:00
{
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_SPECIES, COPYWIN_GFX);
2018-11-11 16:44:27 +01:00
}
else
{
u8 monId = sFactorySwapScreen->cursorPos;
if (!sFactorySwapScreen->inEnemyScreen)
species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, NULL);
else
species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, NULL);
StringCopy(gStringVar4, gSpeciesNames[species]);
2021-10-30 22:47:37 +02:00
x = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 86);
AddTextPrinterParameterized3(SWAP_WIN_SPECIES, FONT_NORMAL, x, 1, sSwapSpeciesNameTextColors, 0, gStringVar4);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_SPECIES, COPYWIN_FULL);
2018-11-11 16:44:27 +01:00
}
}
static void Swap_PrintOnInfoWindow(const u8 *str)
{
2020-12-28 23:32:08 +01:00
FillWindowPixelBuffer(SWAP_WIN_INFO, PIXEL_FILL(0));
2021-10-30 22:47:37 +02:00
AddTextPrinterParameterized(SWAP_WIN_INFO, FONT_NORMAL, str, 2, 5, 0, NULL);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_INFO, COPYWIN_GFX);
2018-11-11 16:44:27 +01:00
}
static void Swap_PrintMenuOptions(void)
{
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SWAP_WIN_OPTIONS);
FillWindowPixelBuffer(SWAP_WIN_OPTIONS, PIXEL_FILL(0));
2021-10-30 22:47:37 +02:00
AddTextPrinterParameterized3(SWAP_WIN_OPTIONS, FONT_NORMAL, 15, 1, sSwapMenuOptionsTextColors, 0, gText_Summary2);
AddTextPrinterParameterized3(SWAP_WIN_OPTIONS, FONT_NORMAL, 15, 17, sSwapMenuOptionsTextColors, 0, gText_Swap);
AddTextPrinterParameterized3(SWAP_WIN_OPTIONS, FONT_NORMAL, 15, 33, sSwapMenuOptionsTextColors, 0, gText_Rechoose);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_OPTIONS, COPYWIN_FULL);
2018-11-11 16:44:27 +01:00
}
static void Swap_PrintYesNoOptions(void)
{
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SWAP_WIN_YES_NO);
FillWindowPixelBuffer(SWAP_WIN_YES_NO, PIXEL_FILL(0));
2021-10-30 22:47:37 +02:00
AddTextPrinterParameterized3(SWAP_WIN_YES_NO, FONT_NORMAL, 7, 1, sSwapMenuOptionsTextColors, 0, gText_Yes3);
AddTextPrinterParameterized3(SWAP_WIN_YES_NO, FONT_NORMAL, 7, 17, sSwapMenuOptionsTextColors, 0, gText_No3);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_YES_NO, COPYWIN_FULL);
2018-11-11 16:44:27 +01:00
}
static void Swap_PrintActionString(const u8 *str, u32 y, u32 windowId)
{
2021-10-30 22:47:37 +02:00
s32 x = GetStringRightAlignXOffset(FONT_SMALL, str, 0x46);
AddTextPrinterParameterized3(windowId, FONT_SMALL, x, y, sSwapMenuOptionsTextColors, 0, str);
2018-11-11 16:44:27 +01:00
}
static void Swap_PrintActionStrings(void)
{
2020-12-31 06:26:14 +01:00
FillWindowPixelBuffer(SWAP_WIN_ACTION_FADE, PIXEL_FILL(0));
2018-11-11 16:44:27 +01:00
switch (sFactorySwapScreen->inEnemyScreen)
{
case TRUE:
2020-12-31 06:26:14 +01:00
Swap_PrintActionString(gText_PkmnForSwap, 0, SWAP_WIN_ACTION_FADE);
2018-11-11 16:44:27 +01:00
case FALSE:
2020-12-31 06:26:14 +01:00
Swap_PrintActionString(gText_Cancel3, 24, SWAP_WIN_ACTION_FADE);
2018-11-11 16:44:27 +01:00
break;
}
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_ACTION_FADE, COPYWIN_FULL);
2018-11-11 16:44:27 +01:00
}
static void Swap_PrintActionStrings2(void)
{
2020-12-28 23:32:08 +01:00
FillWindowPixelBuffer(SWAP_WIN_OPTIONS, PIXEL_FILL(0));
2018-11-11 16:44:27 +01:00
switch (sFactorySwapScreen->inEnemyScreen)
{
case TRUE:
2020-12-28 23:32:08 +01:00
Swap_PrintActionString(gText_PkmnForSwap, 8, SWAP_WIN_OPTIONS);
2018-11-11 16:44:27 +01:00
case FALSE:
2020-12-28 23:32:08 +01:00
Swap_PrintActionString(gText_Cancel3, 32, SWAP_WIN_OPTIONS);
2018-11-11 16:44:27 +01:00
break;
}
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_OPTIONS, COPYWIN_FULL);
2018-11-11 16:44:27 +01:00
}
static void Swap_PrintOneActionString(u8 which)
{
switch (which)
{
case 0:
if (sFactorySwapScreen->inEnemyScreen == TRUE)
2020-12-28 23:32:08 +01:00
Swap_PrintActionString(gText_PkmnForSwap, 8, SWAP_WIN_OPTIONS);
2018-11-11 16:44:27 +01:00
break;
case 1:
2020-12-28 23:32:08 +01:00
Swap_PrintActionString(gText_Cancel3, 32, SWAP_WIN_OPTIONS);
2018-11-11 16:44:27 +01:00
break;
}
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_OPTIONS, COPYWIN_FULL);
2018-11-11 16:44:27 +01:00
}
2020-12-31 06:26:14 +01:00
// For printing the species name once its selected. Keep the current fade but don't keep fading in and out
static void Swap_PrintMonSpeciesAtFade(void)
2018-11-11 16:44:27 +01:00
{
u16 species;
u8 x;
u16 pal[5];
CpuCopy16(sSwapText_Pal, pal, 8);
2018-11-11 16:44:27 +01:00
if (!sFactorySwapScreen->fromSummaryScreen)
pal[4] = gPlttBufferFaded[228];
else
2020-12-28 23:32:08 +01:00
pal[4] = sFactorySwapScreen->speciesNameColorBackup;
LoadPalette(pal, 0xF0, sizeof(sSwapText_Pal));
2018-11-11 16:44:27 +01:00
2020-12-31 06:26:14 +01:00
PutWindowTilemap(SWAP_WIN_SPECIES_AT_FADE);
FillWindowPixelBuffer(SWAP_WIN_SPECIES_AT_FADE, PIXEL_FILL(0));
if (sFactorySwapScreen->cursorPos >= FRONTIER_PARTY_SIZE)
2018-11-11 16:44:27 +01:00
{
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_SPECIES_AT_FADE, COPYWIN_FULL);
2018-11-11 16:44:27 +01:00
}
else
{
u8 monId = sFactorySwapScreen->cursorPos;
if (!sFactorySwapScreen->inEnemyScreen)
species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, NULL);
else
species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, NULL);
StringCopy(gStringVar4, gSpeciesNames[species]);
2021-10-30 22:47:37 +02:00
x = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 86);
AddTextPrinterParameterized3(SWAP_WIN_SPECIES_AT_FADE, FONT_NORMAL, x, 1, sSwapSpeciesNameTextColors, 0, gStringVar4);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_SPECIES_AT_FADE, COPYWIN_FULL);
2018-11-11 16:44:27 +01:00
}
}
2020-12-31 06:26:14 +01:00
// Reprints the species name over the faded one after a transition
static void Swap_PrintMonSpeciesForTransition(void)
2018-11-11 16:44:27 +01:00
{
u16 species;
u8 x;
LoadPalette(sSwapText_Pal, 0xE0, sizeof(sSwapText_Pal));
2020-12-28 23:32:08 +01:00
CpuCopy16(&gPlttBufferUnfaded[240], &gPlttBufferFaded[224], 10);
2018-11-11 16:44:27 +01:00
if (sFactorySwapScreen->cursorPos >= FRONTIER_PARTY_SIZE)
2018-11-11 16:44:27 +01:00
{
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_SPECIES, COPYWIN_GFX);
2018-11-11 16:44:27 +01:00
}
else
{
u8 monId = sFactorySwapScreen->cursorPos;
if (!sFactorySwapScreen->inEnemyScreen)
species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, NULL);
else
species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, NULL);
StringCopy(gStringVar4, gSpeciesNames[species]);
2021-10-30 22:47:37 +02:00
x = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 86);
AddTextPrinterParameterized3(SWAP_WIN_SPECIES, FONT_NORMAL, x, 1, sSwapSpeciesNameTextColors, 0, gStringVar4);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_SPECIES, COPYWIN_FULL);
2018-11-11 16:44:27 +01:00
}
}
static void Swap_PrintMonCategory(void)
{
u16 species;
u8 text[30];
u8 x;
u8 monId = sFactorySwapScreen->cursorPos;
2020-12-28 23:32:08 +01:00
FillWindowPixelBuffer(SWAP_WIN_MON_CATEGORY, PIXEL_FILL(0));
if (monId >= FRONTIER_PARTY_SIZE)
2018-11-11 16:44:27 +01:00
{
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_MON_CATEGORY, COPYWIN_GFX);
2018-11-11 16:44:27 +01:00
}
else
{
2020-12-28 23:32:08 +01:00
PutWindowTilemap(SWAP_WIN_MON_CATEGORY);
2018-11-11 16:44:27 +01:00
if (!sFactorySwapScreen->inEnemyScreen)
species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, NULL);
else
species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, NULL);
CopyMonCategoryText(SpeciesToNationalPokedexNum(species), text);
2021-10-30 22:47:37 +02:00
x = GetStringRightAlignXOffset(FONT_NORMAL, text, 0x76);
AddTextPrinterParameterized(SWAP_WIN_MON_CATEGORY, FONT_NORMAL, text, x, 1, 0, NULL);
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_MON_CATEGORY, COPYWIN_GFX);
2018-11-11 16:44:27 +01:00
}
}
static void Swap_InitActions(u8 id)
{
if (sFactorySwapScreen->fromSummaryScreen != TRUE)
{
switch (id)
{
2020-12-28 23:32:08 +01:00
case SWAP_PLAYER_SCREEN:
2018-11-11 16:44:27 +01:00
sFactorySwapScreen->inEnemyScreen = FALSE;
sFactorySwapScreen->cursorPos = 0;
sFactorySwapScreen->actionsCount = ARRAY_COUNT(sSwap_PlayerScreenActions);
sFactorySwapScreen->actionsData = sSwap_PlayerScreenActions;
break;
2020-12-28 23:32:08 +01:00
case SWAP_ENEMY_SCREEN:
2018-11-11 16:44:27 +01:00
sFactorySwapScreen->inEnemyScreen = TRUE;
sFactorySwapScreen->cursorPos = 0;
sFactorySwapScreen->actionsCount = ARRAY_COUNT(sSwap_EnemyScreenActions);
sFactorySwapScreen->actionsData = sSwap_EnemyScreenActions;
break;
}
}
}
static void Swap_RunMenuOptionFunc(u8 taskId)
{
sSwap_CurrentOptionFunc = sSwap_MenuOptionFuncs[sFactorySwapScreen->menuCursorPos];
sSwap_CurrentOptionFunc(taskId);
2018-11-11 16:44:27 +01:00
}
static void Swap_OptionSwap(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
CloseMonPic(sFactorySwapScreen->monPic, &sFactorySwapScreen->monPicAnimating, TRUE);
2018-11-11 16:44:27 +01:00
sFactorySwapScreen->playerMonId = sFactorySwapScreen->cursorPos;
2020-12-28 23:32:08 +01:00
Swap_ErasePopupMenu(SWAP_WIN_OPTIONS);
gTasks[taskId].tState = 0;
2020-12-31 06:26:14 +01:00
gTasks[taskId].func = Swap_Task_SwitchPartyScreen;
2018-11-11 16:44:27 +01:00
}
static void Swap_OptionSummary(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
gTasks[taskId].tState = STATE_SUMMARY_FADE;
2020-12-28 23:32:08 +01:00
gTasks[taskId].func = Swap_Task_OpenSummaryScreen;
2018-11-11 16:44:27 +01:00
}
static void Swap_OptionRechoose(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
CloseMonPic(sFactorySwapScreen->monPic, &sFactorySwapScreen->monPicAnimating, TRUE);
Swap_ErasePopupMenu(SWAP_WIN_OPTIONS);
gTasks[taskId].tState = 0;
gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_Task_HandleChooseMons) >> 16;
gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_Task_HandleChooseMons);
2020-12-31 06:26:14 +01:00
gTasks[taskId].tFollowUpTaskState = STATE_CHOOSE_MONS_HANDLE_INPUT;
gTasks[taskId].func = Swap_Task_ScreenInfoTransitionIn;
2018-11-11 16:44:27 +01:00
}
static void Swap_RunActionFunc(u8 taskId)
{
sSwap_CurrentOptionFunc = sFactorySwapScreen->actionsData[sFactorySwapScreen->cursorPos].func;
sSwap_CurrentOptionFunc(taskId);
2018-11-11 16:44:27 +01:00
}
static void Swap_ActionCancel(u8 taskId)
{
2020-12-28 23:32:08 +01:00
gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_AskQuitSwapping) >> 16;
gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_AskQuitSwapping);
gTasks[taskId].tState = 0;
gTasks[taskId].tFollowUpTaskState = 0;
2020-12-31 06:26:14 +01:00
gTasks[taskId].func = Swap_Task_ScreenInfoTransitionOut;
2018-11-11 16:44:27 +01:00
}
static void Swap_ActionPkmnForSwap(u8 taskId)
{
2020-12-31 06:26:14 +01:00
gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_Task_SwitchPartyScreen) >> 16;
gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_Task_SwitchPartyScreen);
2020-12-28 23:32:08 +01:00
gTasks[taskId].tFollowUpTaskState = 0;
gTasks[taskId].tState = 0;
2020-12-31 06:26:14 +01:00
gTasks[taskId].func = Swap_Task_ScreenInfoTransitionOut;
2018-11-11 16:44:27 +01:00
}
static void Swap_ActionMon(u8 taskId)
{
if (!sFactorySwapScreen->inEnemyScreen)
{
2020-12-28 23:32:08 +01:00
gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_Task_HandleMenu) >> 16;
gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_Task_HandleMenu);
2020-12-31 06:26:14 +01:00
gTasks[taskId].tFollowUpTaskState = STATE_MENU_INIT;
2018-11-11 16:44:27 +01:00
}
else if (Swap_AlreadyHasSameSpecies(sFactorySwapScreen->cursorPos) == TRUE)
{
2020-12-28 23:32:08 +01:00
OpenMonPic(&sFactorySwapScreen->monPic.bgSpriteId, &sFactorySwapScreen->monPicAnimating, TRUE);
gTasks[taskId].tState = 0;
2020-12-31 06:26:14 +01:00
gTasks[taskId].tFollowUpTaskState = STATE_CHOOSE_MONS_HANDLE_INPUT;
2020-12-28 23:32:08 +01:00
gTasks[taskId].func = Swap_TaskCantHaveSameMons;
2018-11-11 16:44:27 +01:00
return;
}
else
{
2020-12-28 23:32:08 +01:00
gTasks[taskId].tFollowUpTaskPtrHi = (u32)(Swap_AskAcceptMon) >> 16;
gTasks[taskId].tFollowUpTaskPtrLo = (u32)(Swap_AskAcceptMon);
gTasks[taskId].tFollowUpTaskState = 0;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState = 0;
2020-12-31 06:26:14 +01:00
gTasks[taskId].func = Swap_Task_ScreenInfoTransitionOut;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
#define sIsSwapScreen data[7]
static void OpenMonPic(u8 *spriteId, bool8 *animating, bool8 swapScreen)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
*spriteId = CreateSprite(&sSpriteTemplate_Swap_MonPicBgAnim, 120, 64, 1);
gSprites[*spriteId].callback = SpriteCB_OpenMonPic;
gSprites[*spriteId].sIsSwapScreen = swapScreen;
*animating = TRUE;
2018-11-11 16:44:27 +01:00
}
static void Swap_ShowSummaryMonSprite(void)
{
struct Pokemon *mon;
u16 species;
u32 personality, otId;
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->monPic.bgSpriteId = CreateSprite(&sSpriteTemplate_Swap_MonPicBgAnim, 120, 64, 1);
StartSpriteAffineAnim(&gSprites[sFactorySwapScreen->monPic.bgSpriteId], 2);
2018-11-11 16:44:27 +01:00
mon = &gPlayerParty[sFactorySwapScreen->cursorPos];
species = GetMonData(mon, MON_DATA_SPECIES, NULL);
personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL);
otId = GetMonData(mon, MON_DATA_OT_ID, NULL);
#ifdef BUGFIX
2021-09-14 19:14:14 +02:00
sFactorySwapScreen->monPic.monSpriteId = CreateMonPicSprite_HandleDeoxys(species, otId, personality, TRUE, 88, 32, 15, TAG_NONE);
#else
2021-09-14 19:14:14 +02:00
sFactorySwapScreen->monPic.monSpriteId = CreateMonPicSprite_HandleDeoxys(species, personality, otId, TRUE, 88, 32, 15, TAG_NONE);
#endif
2020-12-28 23:32:08 +01:00
gSprites[sFactorySwapScreen->monPic.monSpriteId].centerToCornerVecX = 0;
gSprites[sFactorySwapScreen->monPic.monSpriteId].centerToCornerVecY = 0;
2018-11-11 16:44:27 +01:00
2020-12-28 23:32:08 +01:00
gSprites[sFactorySwapScreen->monPic.bgSpriteId].invisible = TRUE;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
static void CloseMonPic(struct FactoryMonPic pic, bool8 *animating, bool8 swapScreen)
2018-11-11 16:44:27 +01:00
{
u8 taskId;
2020-12-28 23:32:08 +01:00
FreeAndDestroyMonPicSprite(pic.monSpriteId);
2020-09-03 07:19:08 +02:00
taskId = CreateTask(Task_CloseMonPic, 1);
gTasks[taskId].tIsSwapScreen = swapScreen;
2020-12-28 23:32:08 +01:00
gTasks[taskId].tSpriteId = pic.bgSpriteId;
2018-11-11 16:44:27 +01:00
gTasks[taskId].func(taskId);
2020-12-28 23:32:08 +01:00
*animating = TRUE;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
static void HideMonPic(struct FactoryMonPic pic, bool8 *animating)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
FreeAndDestroyMonPicSprite(pic.monSpriteId);
FreeOamMatrix(gSprites[pic.bgSpriteId].oam.matrixNum);
DestroySprite(&gSprites[pic.bgSpriteId]);
*animating = FALSE;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
static void Swap_TaskCantHaveSameMons(u8 taskId)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
if (sFactorySwapScreen->monPicAnimating == TRUE)
2018-11-11 16:44:27 +01:00
return;
2020-12-28 23:32:08 +01:00
switch (gTasks[taskId].tState)
2018-11-11 16:44:27 +01:00
{
case 0:
Swap_PrintOnInfoWindow(gText_SamePkmnInPartyAlready);
sFactorySwapScreen->monSwapped = FALSE;
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
break;
case 1:
2020-12-28 23:32:08 +01:00
if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
2018-11-11 16:44:27 +01:00
{
PlaySE(SE_SELECT);
2020-12-28 23:32:08 +01:00
CloseMonPic(sFactorySwapScreen->monPic, &sFactorySwapScreen->monPicAnimating, TRUE);
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
}
break;
case 2:
2020-12-28 23:32:08 +01:00
if (sFactorySwapScreen->monPicAnimating != TRUE)
2018-11-11 16:44:27 +01:00
{
2020-12-31 06:26:14 +01:00
FillWindowPixelBuffer(SWAP_WIN_ACTION_FADE, PIXEL_FILL(0));
2021-11-03 20:29:18 +01:00
CopyWindowToVram(SWAP_WIN_ACTION_FADE, COPYWIN_GFX);
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
}
break;
case 3:
Swap_PrintOnInfoWindow(gText_SelectPkmnToAccept);
2020-12-28 23:32:08 +01:00
gTasks[taskId].tState++;
2018-11-11 16:44:27 +01:00
break;
case 4:
2020-12-31 06:26:14 +01:00
Swap_PrintMonSpeciesForTransition();
Swap_EraseSpeciesAtFadeWindow();
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->fadeSpeciesNameActive = TRUE;
gTasks[taskId].tState = gTasks[taskId].tFollowUpTaskState;
gTasks[taskId].func = Swap_Task_HandleChooseMons;
2018-11-11 16:44:27 +01:00
break;
}
}
static bool8 Swap_AlreadyHasSameSpecies(u8 monId)
{
u8 i;
u16 species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, NULL);
for (i = 0; i < FRONTIER_PARTY_SIZE; i++)
2018-11-11 16:44:27 +01:00
{
if (i != sFactorySwapScreen->playerMonId && (u16)(GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL)) == species)
return TRUE;
}
return FALSE;
}
2020-09-03 07:19:08 +02:00
static void SpriteCB_OpenMonPic(struct Sprite *sprite)
2018-11-11 16:44:27 +01:00
{
u8 taskId;
if (sprite->affineAnimEnded)
{
sprite->invisible = TRUE;
2020-09-03 07:19:08 +02:00
taskId = CreateTask(Task_OpenMonPic, 1);
2020-12-28 23:32:08 +01:00
gTasks[taskId].tIsSwapScreen = sprite->sIsSwapScreen;
2018-11-11 16:44:27 +01:00
gTasks[taskId].func(taskId);
sprite->callback = SpriteCallbackDummy;
}
}
2020-12-30 23:35:33 +01:00
static void SpriteCB_CloseMonPic(struct Sprite *sprite)
2018-11-11 16:44:27 +01:00
{
if (sprite->affineAnimEnded)
{
FreeOamMatrix(sprite->oam.matrixNum);
2020-12-28 23:32:08 +01:00
if (sprite->sIsSwapScreen == TRUE)
sFactorySwapScreen->monPicAnimating = FALSE;
2018-11-11 16:44:27 +01:00
else
2020-12-28 23:32:08 +01:00
Select_SetMonPicAnimating(FALSE);
2018-11-11 16:44:27 +01:00
DestroySprite(sprite);
}
}
2020-09-03 07:19:08 +02:00
static void Task_OpenMonPic(u8 taskId)
2018-11-11 16:44:27 +01:00
{
struct Task *task = &gTasks[taskId];
2020-12-28 23:32:08 +01:00
switch (task->tState)
2018-11-11 16:44:27 +01:00
{
case 0:
2020-12-30 23:35:33 +01:00
// Init
2020-09-03 07:19:08 +02:00
task->tWinLeft = 88;
2020-12-28 23:32:08 +01:00
task->tWinRight = DISPLAY_WIDTH - 88;
task->tWinTop = 64;
task->tWinBottom = 65;
2018-11-11 16:44:27 +01:00
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
2020-09-03 07:19:08 +02:00
SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->tWinLeft, task->tWinRight));
2020-12-28 23:32:08 +01:00
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom));
2018-11-11 16:44:27 +01:00
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ);
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ);
break;
case 1:
2020-12-30 23:35:33 +01:00
// Show mon pic bg
2018-11-11 16:44:27 +01:00
ShowBg(3);
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG3 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_OBJ);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4));
break;
case 2:
2020-12-30 23:35:33 +01:00
// Animate mon pic bg
2020-12-28 23:32:08 +01:00
task->tWinTop -= 4;
task->tWinBottom += 4;
if (task->tWinTop <= 32 || task->tWinBottom >= 96)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
task->tWinTop = 32;
task->tWinBottom = 96;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom));
if (task->tWinTop != 32)
2018-11-11 16:44:27 +01:00
return;
break;
default:
2021-05-15 22:56:17 +02:00
#ifndef UBFIX
2018-11-11 16:44:27 +01:00
DestroyTask(taskId);
2021-05-15 22:56:17 +02:00
#endif
2018-11-11 16:44:27 +01:00
// UB: Should not use the task after it has been deleted.
2020-09-03 07:19:08 +02:00
if (gTasks[taskId].tIsSwapScreen == TRUE)
Swap_CreateMonSprite();
2018-11-11 16:44:27 +01:00
else
2020-12-28 23:32:08 +01:00
Select_CreateMonSprite();
2021-05-15 22:56:17 +02:00
#ifdef UBFIX
DestroyTask(taskId);
#endif
2018-11-11 16:44:27 +01:00
return;
}
2020-12-28 23:32:08 +01:00
task->tState++;
2018-11-11 16:44:27 +01:00
}
2020-09-03 07:19:08 +02:00
static void Task_CloseMonPic(u8 taskId)
2018-11-11 16:44:27 +01:00
{
struct Task *task = &gTasks[taskId];
2020-09-03 07:19:08 +02:00
switch (task->tState)
2018-11-11 16:44:27 +01:00
{
case 0:
2020-12-30 23:35:33 +01:00
// Init
2020-09-03 07:19:08 +02:00
task->tWinLeft = 88;
2020-12-28 23:32:08 +01:00
task->tWinRight = DISPLAY_WIDTH - 88;
task->tWinTop = 32;
task->tWinBottom = 96;
2018-11-11 16:44:27 +01:00
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
2020-09-03 07:19:08 +02:00
SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(task->tWinLeft, task->tWinRight));
2020-12-28 23:32:08 +01:00
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom));
2018-11-11 16:44:27 +01:00
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_CLR | WININ_WIN0_OBJ);
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_CLR | WINOUT_WIN01_OBJ);
2020-12-28 23:32:08 +01:00
task->tState++;
2018-11-11 16:44:27 +01:00
break;
case 1:
2020-12-30 23:35:33 +01:00
// Animate bg
2020-12-28 23:32:08 +01:00
task->tWinTop += 4;
task->tWinBottom -= 4;
if (task->tWinTop >= 64 || task->tWinBottom <= 65)
2018-11-11 16:44:27 +01:00
{
2020-12-28 23:32:08 +01:00
task->tWinTop = 64;
task->tWinBottom = 65;
2018-11-11 16:44:27 +01:00
}
2020-12-28 23:32:08 +01:00
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(task->tWinTop, task->tWinBottom));
if (task->tWinTop == 64)
task->tState++;
2018-11-11 16:44:27 +01:00
break;
2020-12-30 23:35:33 +01:00
default:
// Hide bg
HideBg(3);
gSprites[task->tSpriteId].sIsSwapScreen = task->tIsSwapScreen;
gSprites[task->tSpriteId].invisible = FALSE;
gSprites[task->tSpriteId].callback = SpriteCB_CloseMonPic;
StartSpriteAffineAnim(&gSprites[task->tSpriteId], 1);
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
DestroyTask(taskId);
break;
2018-11-11 16:44:27 +01:00
}
}
2020-09-03 07:19:08 +02:00
static void Swap_CreateMonSprite(void)
2018-11-11 16:44:27 +01:00
{
struct Pokemon *mon;
u16 species;
u32 personality, otId;
if (!sFactorySwapScreen->inEnemyScreen)
mon = &gPlayerParty[sFactorySwapScreen->cursorPos];
else
mon = &gEnemyParty[sFactorySwapScreen->cursorPos];
species = GetMonData(mon, MON_DATA_SPECIES, NULL);
personality = GetMonData(mon, MON_DATA_PERSONALITY, NULL);
otId = GetMonData(mon, MON_DATA_OT_ID, NULL);
2021-09-14 19:14:14 +02:00
sFactorySwapScreen->monPic.monSpriteId = CreateMonPicSprite_HandleDeoxys(species, otId, personality, TRUE, 88, 32, 15, TAG_NONE);
2020-12-28 23:32:08 +01:00
gSprites[sFactorySwapScreen->monPic.monSpriteId].centerToCornerVecX = 0;
gSprites[sFactorySwapScreen->monPic.monSpriteId].centerToCornerVecY = 0;
2018-11-11 16:44:27 +01:00
2020-12-28 23:32:08 +01:00
sFactorySwapScreen->monPicAnimating = FALSE;
2018-11-11 16:44:27 +01:00
}