2017-10-03 03:51:22 +02:00
|
|
|
#include "global.h"
|
2019-09-09 03:07:54 +02:00
|
|
|
#include "malloc.h"
|
2018-08-12 16:40:31 +02:00
|
|
|
#include "bg.h"
|
2019-04-04 23:53:06 +02:00
|
|
|
#include "data.h"
|
2018-12-10 23:42:44 +01:00
|
|
|
#include "decompress.h"
|
2018-12-09 16:44:01 +01:00
|
|
|
#include "dma3.h"
|
2018-12-12 23:19:50 +01:00
|
|
|
#include "dynamic_placeholder_text_util.h"
|
2018-11-14 01:01:50 +01:00
|
|
|
#include "event_data.h"
|
2018-12-08 22:05:11 +01:00
|
|
|
#include "field_screen_effect.h"
|
2018-08-12 16:40:31 +02:00
|
|
|
#include "field_weather.h"
|
2018-12-24 00:02:29 +01:00
|
|
|
#include "fldeff_misc.h"
|
2018-11-14 01:01:50 +01:00
|
|
|
#include "gpu_regs.h"
|
2018-12-10 23:42:44 +01:00
|
|
|
#include "graphics.h"
|
2018-08-12 16:40:31 +02:00
|
|
|
#include "international_string_util.h"
|
2018-12-09 21:06:43 +01:00
|
|
|
#include "item.h"
|
2018-12-19 22:47:27 +01:00
|
|
|
#include "item_icon.h"
|
2018-12-09 16:44:01 +01:00
|
|
|
#include "item_menu.h"
|
2018-12-09 21:06:43 +01:00
|
|
|
#include "mail.h"
|
2018-11-14 01:01:50 +01:00
|
|
|
#include "main.h"
|
|
|
|
#include "menu.h"
|
2018-12-09 16:44:01 +01:00
|
|
|
#include "mon_markings.h"
|
2018-12-10 21:36:52 +01:00
|
|
|
#include "naming_screen.h"
|
2018-11-14 01:01:50 +01:00
|
|
|
#include "overworld.h"
|
|
|
|
#include "palette.h"
|
2018-12-19 22:47:27 +01:00
|
|
|
#include "pc_screen_effect.h"
|
2018-11-14 01:01:50 +01:00
|
|
|
#include "pokemon.h"
|
2018-12-12 23:19:50 +01:00
|
|
|
#include "pokemon_icon.h"
|
2018-12-10 21:36:52 +01:00
|
|
|
#include "pokemon_summary_screen.h"
|
2018-11-14 01:01:50 +01:00
|
|
|
#include "pokemon_storage_system.h"
|
|
|
|
#include "script.h"
|
2018-08-12 16:40:31 +02:00
|
|
|
#include "sound.h"
|
2018-11-14 01:01:50 +01:00
|
|
|
#include "string_util.h"
|
|
|
|
#include "strings.h"
|
|
|
|
#include "text.h"
|
2018-12-09 16:44:01 +01:00
|
|
|
#include "text_window.h"
|
2018-12-15 23:58:47 +01:00
|
|
|
#include "trig.h"
|
2018-11-14 01:01:50 +01:00
|
|
|
#include "walda_phrase.h"
|
|
|
|
#include "window.h"
|
2020-03-09 02:27:29 +01:00
|
|
|
#include "constants/items.h"
|
2018-12-15 23:58:47 +01:00
|
|
|
#include "constants/maps.h"
|
|
|
|
#include "constants/moves.h"
|
2018-12-09 16:44:01 +01:00
|
|
|
#include "constants/rgb.h"
|
2018-08-12 16:40:31 +02:00
|
|
|
#include "constants/songs.h"
|
2017-10-03 03:51:22 +02:00
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
/*
|
|
|
|
NOTE: This file is large. Some general groups of functions have
|
|
|
|
been labeled with commented headers to make navigation easier.
|
|
|
|
Search for "SECTION:" to locate them. These sections are not
|
|
|
|
hard and fast rules, but give a basic idea of where certain
|
|
|
|
types of functions are likely located.
|
|
|
|
*/
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
// PC main menu options
|
2021-04-15 19:31:18 +02:00
|
|
|
enum {
|
2021-04-15 23:31:50 +02:00
|
|
|
OPTION_WITHDRAW,
|
|
|
|
OPTION_DEPOSIT,
|
|
|
|
OPTION_MOVE_MONS,
|
|
|
|
OPTION_MOVE_ITEMS,
|
|
|
|
OPTION_EXIT,
|
|
|
|
OPTIONS_COUNT
|
2021-04-15 19:31:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// IDs for messages to print with PrintMessage
|
|
|
|
enum {
|
|
|
|
MSG_EXIT_BOX,
|
|
|
|
MSG_WHAT_YOU_DO,
|
|
|
|
MSG_PICK_A_THEME,
|
|
|
|
MSG_PICK_A_WALLPAPER,
|
|
|
|
MSG_IS_SELECTED,
|
|
|
|
MSG_JUMP_TO_WHICH_BOX,
|
|
|
|
MSG_DEPOSIT_IN_WHICH_BOX,
|
|
|
|
MSG_WAS_DEPOSITED,
|
|
|
|
MSG_BOX_IS_FULL,
|
|
|
|
MSG_RELEASE_POKE,
|
|
|
|
MSG_WAS_RELEASED,
|
|
|
|
MSG_BYE_BYE,
|
|
|
|
MSG_MARK_POKE,
|
|
|
|
MSG_LAST_POKE,
|
|
|
|
MSG_PARTY_FULL,
|
|
|
|
MSG_HOLDING_POKE,
|
|
|
|
MSG_WHICH_ONE_WILL_TAKE,
|
|
|
|
MSG_CANT_RELEASE_EGG,
|
|
|
|
MSG_CONTINUE_BOX,
|
|
|
|
MSG_CAME_BACK,
|
|
|
|
MSG_WORRIED,
|
|
|
|
MSG_SURPRISE,
|
|
|
|
MSG_PLEASE_REMOVE_MAIL,
|
|
|
|
MSG_IS_SELECTED2,
|
|
|
|
MSG_GIVE_TO_MON,
|
|
|
|
MSG_PLACED_IN_BAG,
|
|
|
|
MSG_BAG_FULL,
|
|
|
|
MSG_PUT_IN_BAG,
|
|
|
|
MSG_ITEM_IS_HELD,
|
|
|
|
MSG_CHANGED_TO_ITEM,
|
|
|
|
MSG_CANT_STORE_MAIL,
|
|
|
|
};
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
// IDs for how to resolve variables in the above messages
|
2021-04-15 19:31:18 +02:00
|
|
|
enum {
|
2021-04-16 05:27:05 +02:00
|
|
|
MSG_VAR_NONE,
|
|
|
|
MSG_VAR_MON_NAME_1,
|
|
|
|
MSG_VAR_MON_NAME_2, // Unused
|
|
|
|
MSG_VAR_MON_NAME_3, // Unused
|
|
|
|
MSG_VAR_RELEASE_MON_1,
|
|
|
|
MSG_VAR_RELEASE_MON_2, // Unused
|
|
|
|
MSG_VAR_RELEASE_MON_3,
|
|
|
|
MSG_VAR_ITEM_NAME,
|
2021-04-15 19:31:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// IDs for menu selection items. See SetMenuText, HandleMenuInput, etc
|
|
|
|
enum {
|
|
|
|
MENU_CANCEL,
|
|
|
|
MENU_STORE,
|
|
|
|
MENU_WITHDRAW,
|
|
|
|
MENU_MOVE,
|
|
|
|
MENU_SHIFT,
|
|
|
|
MENU_PLACE,
|
|
|
|
MENU_SUMMARY,
|
|
|
|
MENU_RELEASE,
|
|
|
|
MENU_MARK,
|
|
|
|
MENU_JUMP,
|
|
|
|
MENU_WALLPAPER,
|
|
|
|
MENU_NAME,
|
|
|
|
MENU_TAKE,
|
|
|
|
MENU_GIVE,
|
|
|
|
MENU_GIVE_2,
|
|
|
|
MENU_SWITCH,
|
|
|
|
MENU_BAG,
|
|
|
|
MENU_INFO,
|
|
|
|
MENU_SCENERY_1,
|
|
|
|
MENU_SCENERY_2,
|
|
|
|
MENU_SCENERY_3,
|
|
|
|
MENU_ETCETERA,
|
|
|
|
MENU_FRIENDS,
|
|
|
|
MENU_FOREST,
|
|
|
|
MENU_CITY,
|
|
|
|
MENU_DESERT,
|
|
|
|
MENU_SAVANNA,
|
|
|
|
MENU_CRAG,
|
|
|
|
MENU_VOLCANO,
|
|
|
|
MENU_SNOW,
|
|
|
|
MENU_CAVE,
|
|
|
|
MENU_BEACH,
|
|
|
|
MENU_SEAFLOOR,
|
|
|
|
MENU_RIVER,
|
|
|
|
MENU_SKY,
|
|
|
|
MENU_POLKADOT,
|
|
|
|
MENU_POKECENTER,
|
|
|
|
MENU_MACHINE,
|
|
|
|
MENU_SIMPLE,
|
|
|
|
};
|
2021-04-15 20:06:25 +02:00
|
|
|
#define MENU_WALLPAPER_SETS_START MENU_SCENERY_1
|
2021-04-15 19:31:18 +02:00
|
|
|
#define MENU_WALLPAPERS_START MENU_FOREST
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
// Return IDs for input handlers
|
|
|
|
enum {
|
|
|
|
INPUT_NONE,
|
2021-04-17 06:49:51 +02:00
|
|
|
INPUT_MOVE_CURSOR,
|
2021-04-15 23:31:50 +02:00
|
|
|
INPUT_2, // Unused
|
|
|
|
INPUT_3, // Unused
|
2021-04-16 23:05:44 +02:00
|
|
|
INPUT_CLOSE_BOX,
|
|
|
|
INPUT_SHOW_PARTY,
|
|
|
|
INPUT_HIDE_PARTY,
|
|
|
|
INPUT_BOX_OPTIONS,
|
|
|
|
INPUT_IN_MENU,
|
|
|
|
INPUT_SCROLL_RIGHT,
|
|
|
|
INPUT_SCROLL_LEFT,
|
|
|
|
INPUT_DEPOSIT,
|
|
|
|
INPUT_WITHDRAW,
|
|
|
|
INPUT_MOVE_MON,
|
|
|
|
INPUT_SHIFT_MON,
|
|
|
|
INPUT_PLACE_MON,
|
|
|
|
INPUT_TAKE_ITEM,
|
|
|
|
INPUT_GIVE_ITEM,
|
|
|
|
INPUT_SWITCH_ITEMS,
|
|
|
|
INPUT_PRESSED_B,
|
|
|
|
INPUT_MULTIMOVE_START,
|
|
|
|
INPUT_MULTIMOVE_CHANGE_SELECTION,
|
|
|
|
INPUT_MULTIMOVE_SINGLE,
|
|
|
|
INPUT_MULTIMOVE_GRAB_SELECTION,
|
|
|
|
INPUT_MULTIMOVE_UNABLE,
|
|
|
|
INPUT_MULTIMOVE_MOVE_MONS,
|
|
|
|
INPUT_MULTIMOVE_PLACE_MONS,
|
2021-04-15 23:31:50 +02:00
|
|
|
};
|
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
enum {
|
|
|
|
SCREEN_CHANGE_EXIT_BOX,
|
|
|
|
SCREEN_CHANGE_SUMMARY_SCREEN,
|
|
|
|
SCREEN_CHANGE_NAME_BOX,
|
|
|
|
SCREEN_CHANGE_ITEM_FROM_BAG,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
MODE_PARTY,
|
|
|
|
MODE_BOX,
|
|
|
|
MODE_MOVE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
CURSOR_AREA_IN_BOX,
|
|
|
|
CURSOR_AREA_IN_PARTY,
|
2021-04-17 06:49:51 +02:00
|
|
|
CURSOR_AREA_BOX_TITLE,
|
2021-04-15 19:31:18 +02:00
|
|
|
CURSOR_AREA_BUTTONS, // Party Pokemon and Close Box
|
|
|
|
};
|
2021-04-17 06:49:51 +02:00
|
|
|
#define CURSOR_AREA_IN_HAND CURSOR_AREA_BOX_TITLE // Alt name for cursor area used by Move Items
|
2021-04-16 01:17:53 +02:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
enum {
|
|
|
|
CURSOR_ANIM_BOUNCE,
|
|
|
|
CURSOR_ANIM_STILL,
|
|
|
|
CURSOR_ANIM_OPEN,
|
|
|
|
CURSOR_ANIM_FIST,
|
|
|
|
};
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
// Special box ids for the choose box menu
|
|
|
|
#define BOXID_NONE_CHOSEN 200
|
|
|
|
#define BOXID_CANCELED 201
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
enum {
|
|
|
|
PALTAG_MON_ICON_0 = 56000,
|
|
|
|
PALTAG_MON_ICON_1, // Used implicitly in CreateMonIconSprite
|
|
|
|
PALTAG_MON_ICON_2, // Used implicitly in CreateMonIconSprite
|
2021-04-16 05:27:05 +02:00
|
|
|
PALTAG_3, // Unused
|
|
|
|
PALTAG_4, // Unused
|
|
|
|
PALTAG_5, // Unused
|
|
|
|
PALTAG_DISPLAY_MON,
|
2021-04-18 05:55:24 +02:00
|
|
|
PALTAG_MISC_1,
|
2021-04-16 05:27:05 +02:00
|
|
|
PALTAG_MARKING_COMBO,
|
2021-04-16 01:17:53 +02:00
|
|
|
PALTAG_BOX_TITLE,
|
2021-04-18 05:55:24 +02:00
|
|
|
PALTAG_MISC_2,
|
2021-04-16 01:17:53 +02:00
|
|
|
PALTAG_ITEM_ICON_0,
|
|
|
|
PALTAG_ITEM_ICON_1, // Used implicitly in CreateItemIconSprites
|
|
|
|
PALTAG_ITEM_ICON_2, // Used implicitly in CreateItemIconSprites
|
2021-04-16 05:27:05 +02:00
|
|
|
PALTAG_MARKING_MENU,
|
2021-04-16 01:17:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2021-04-16 05:27:05 +02:00
|
|
|
GFXTAG_CURSOR,
|
|
|
|
GFXTAG_CURSOR_SHADOW,
|
|
|
|
GFXTAG_DISPLAY_MON,
|
2021-04-16 01:17:53 +02:00
|
|
|
GFXTAG_BOX_TITLE,
|
|
|
|
GFXTAG_BOX_TITLE_ALT,
|
|
|
|
GFXTAG_WAVEFORM,
|
|
|
|
GFXTAG_ARROW,
|
|
|
|
GFXTAG_ITEM_ICON_0,
|
|
|
|
GFXTAG_ITEM_ICON_1, // Used implicitly in CreateItemIconSprites
|
|
|
|
GFXTAG_ITEM_ICON_2, // Used implicitly in CreateItemIconSprites
|
|
|
|
GFXTAG_CHOOSE_BOX_MENU,
|
|
|
|
GFXTAG_CHOOSE_BOX_MENU_SIDES, // Used implicitly in LoadChooseBoxMenuGfx
|
2021-04-16 05:27:05 +02:00
|
|
|
GFXTAG_12, // Unused
|
|
|
|
GFXTAG_MARKING_MENU,
|
|
|
|
GFXTAG_14, // Unused
|
|
|
|
GFXTAG_15, // Unused
|
|
|
|
GFXTAG_MARKING_COMBO,
|
|
|
|
GFXTAG_17, // Unused
|
2021-04-17 06:49:51 +02:00
|
|
|
GFXTAG_MON_ICON,
|
2018-12-12 23:19:50 +01:00
|
|
|
};
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
// The maximum number of Pokémon icons that can appear on-screen.
|
|
|
|
// By default the limit is 40 (though in practice only 37 can be).
|
|
|
|
#define MAX_MON_ICONS (IN_BOX_COUNT + PARTY_SIZE + 1 >= 40 ? IN_BOX_COUNT + PARTY_SIZE + 1 : 40)
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
// The maximum number of item icons that can appear on-screen while
|
|
|
|
// moving held items. 1 in the cursor, and 2 more while switching
|
|
|
|
// between 2 Pokémon with held items
|
|
|
|
#define MAX_ITEM_ICONS 3
|
|
|
|
|
|
|
|
// IDs for the item icons affine anims
|
|
|
|
enum {
|
|
|
|
ITEM_ANIM_NONE,
|
|
|
|
ITEM_ANIM_APPEAR,
|
|
|
|
ITEM_ANIM_DISAPPEAR,
|
|
|
|
ITEM_ANIM_PICK_UP,
|
|
|
|
ITEM_ANIM_PUT_DOWN,
|
|
|
|
ITEM_ANIM_PUT_AWAY,
|
|
|
|
ITEM_ANIM_LARGE,
|
|
|
|
};
|
|
|
|
|
|
|
|
// IDs for the item icon sprite callbacks
|
|
|
|
enum {
|
|
|
|
ITEM_CB_WAIT_ANIM,
|
|
|
|
ITEM_CB_TO_HAND,
|
|
|
|
ITEM_CB_TO_MON,
|
|
|
|
ITEM_CB_SWAP_TO_HAND,
|
|
|
|
ITEM_CB_SWAP_TO_MON,
|
|
|
|
ITEM_CB_UNUSED_1,
|
|
|
|
ITEM_CB_UNUSED_2,
|
|
|
|
ITEM_CB_HIDE_PARTY,
|
|
|
|
};
|
2021-04-15 20:06:25 +02:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
enum {
|
|
|
|
RELEASE_ANIM_RELEASE,
|
|
|
|
RELEASE_ANIM_CAME_BACK,
|
|
|
|
};
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
// IDs for InitMonPlaceChange
|
|
|
|
enum {
|
|
|
|
CHANGE_GRAB,
|
|
|
|
CHANGE_PLACE,
|
|
|
|
CHANGE_SHIFT,
|
|
|
|
};
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
// Modes for selecting and moving Pokémon in the box.
|
|
|
|
// "MULTIPLE" mode allows up to an entire box to be
|
|
|
|
// picked up at once by pressing Select then holding
|
|
|
|
// down the A button. While holding A down, the player
|
|
|
|
// may move the cursor around to select multiple Pokémon.
|
|
|
|
// This is MOVE_MODE_MULTIPLE_SELECTING. After releasing A
|
|
|
|
// those Pokémon will be picked up and can be moved around
|
|
|
|
// as a single unit. This is MOVE_MODE_MULTIPLE_MOVING
|
|
|
|
enum {
|
|
|
|
MOVE_MODE_NORMAL,
|
|
|
|
MOVE_MODE_MULTIPLE_SELECTING,
|
|
|
|
MOVE_MODE_MULTIPLE_MOVING,
|
|
|
|
};
|
|
|
|
|
|
|
|
// IDs for the main functions for moving multiple Pokémon.
|
|
|
|
// Given as arguments to MultiMove_SetFunction
|
|
|
|
enum {
|
|
|
|
MULTIMOVE_START,
|
2021-04-17 06:49:51 +02:00
|
|
|
MULTIMOVE_CANCEL, // If only 1 Pokémon is grabbed
|
2021-04-16 23:05:44 +02:00
|
|
|
MULTIMOVE_CHANGE_SELECTION,
|
|
|
|
MULTIMOVE_GRAB_SELECTION,
|
|
|
|
MULTIMOVE_MOVE_MONS,
|
|
|
|
MULTIMOVE_PLACE_MONS,
|
|
|
|
};
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
// IDs for TilemapUtil
|
2021-04-17 23:28:18 +02:00
|
|
|
enum {
|
|
|
|
TILEMAPID_PKMN_DATA, // The "Pkmn Data" text at the top of the display
|
|
|
|
TILEMAPID_PARTY_MENU,
|
|
|
|
TILEMAPID_CLOSE_BUTTON,
|
|
|
|
TILEMAPID_COUNT
|
|
|
|
};
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
struct Wallpaper
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2018-12-12 23:19:50 +01:00
|
|
|
const u32 *tiles;
|
2021-04-15 20:06:25 +02:00
|
|
|
const u32 *tilemap;
|
2018-12-12 23:19:50 +01:00
|
|
|
const u16 *palettes;
|
2018-12-19 22:47:27 +01:00
|
|
|
};
|
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
struct StorageMessage
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
const u8 *text;
|
|
|
|
u8 format;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct StorageMenu
|
|
|
|
{
|
|
|
|
const u8 *text;
|
|
|
|
int textId;
|
|
|
|
};
|
|
|
|
|
2021-04-18 05:31:29 +02:00
|
|
|
struct UnkUtilData
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-18 05:31:29 +02:00
|
|
|
const u8 *src;
|
|
|
|
u8 *dest;
|
|
|
|
u16 size;
|
|
|
|
u16 unk;
|
|
|
|
u16 height;
|
|
|
|
void (*func)(struct UnkUtilData *data);
|
2018-12-19 22:47:27 +01:00
|
|
|
};
|
|
|
|
|
2021-04-18 05:31:29 +02:00
|
|
|
struct UnkUtil
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-18 05:31:29 +02:00
|
|
|
struct UnkUtilData *data;
|
|
|
|
u8 numActive;
|
|
|
|
u8 max;
|
2018-12-19 22:47:27 +01:00
|
|
|
};
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
struct ChooseBoxMenu
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
struct Sprite *menuSprite;
|
|
|
|
struct Sprite *menuSideSprites[4];
|
2021-04-16 05:27:05 +02:00
|
|
|
u32 unused1[3];
|
2021-04-15 20:06:25 +02:00
|
|
|
struct Sprite *arrowSprites[2];
|
2021-04-16 05:27:05 +02:00
|
|
|
u8 unused2[0x214];
|
2021-04-15 23:31:50 +02:00
|
|
|
bool32 loadedPalette;
|
|
|
|
u16 tileTag;
|
|
|
|
u16 paletteTag;
|
2018-12-19 22:47:27 +01:00
|
|
|
u8 curBox;
|
2021-04-16 05:27:05 +02:00
|
|
|
u8 unused3;
|
2021-04-15 23:31:50 +02:00
|
|
|
u8 subpriority;
|
2018-12-19 22:47:27 +01:00
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
struct ItemIcon
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
struct Sprite *sprite;
|
|
|
|
u8 *tiles;
|
|
|
|
u16 palIndex;
|
2021-04-16 05:27:05 +02:00
|
|
|
u8 area;
|
|
|
|
u8 pos;
|
2021-04-16 01:17:53 +02:00
|
|
|
bool8 active;
|
2018-12-19 22:47:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PokemonStorageSystemData
|
|
|
|
{
|
|
|
|
u8 state;
|
|
|
|
u8 boxOption;
|
|
|
|
u8 screenChangeType;
|
2021-04-18 05:40:27 +02:00
|
|
|
bool8 isReopening;
|
2018-12-19 22:47:27 +01:00
|
|
|
u8 taskId;
|
2021-04-18 05:31:29 +02:00
|
|
|
struct UnkUtil unkUtil;
|
|
|
|
struct UnkUtilData unkUtilData[8];
|
2021-04-17 06:49:51 +02:00
|
|
|
u16 partyMenuTilemapBuffer[0x108];
|
2021-04-18 05:55:24 +02:00
|
|
|
u16 partyMenuUnused1; // Never read
|
2021-04-17 06:49:51 +02:00
|
|
|
u16 partyMenuY;
|
2021-04-18 05:55:24 +02:00
|
|
|
u8 partyMenuUnused2; // Unused
|
2021-04-17 06:49:51 +02:00
|
|
|
u8 partyMenuMoveTimer;
|
2018-12-19 22:47:27 +01:00
|
|
|
u8 showPartyMenuState;
|
2021-04-17 06:49:51 +02:00
|
|
|
bool8 closeBoxFlashing;
|
|
|
|
u8 closeBoxFlashTimer;
|
|
|
|
bool8 closeBoxFlashState;
|
2018-12-19 22:47:27 +01:00
|
|
|
s16 newCurrBoxId;
|
|
|
|
u16 bg2_X;
|
2021-04-15 23:31:50 +02:00
|
|
|
s16 scrollSpeed;
|
2021-04-17 06:49:51 +02:00
|
|
|
u16 scrollTimer;
|
2021-04-15 20:06:25 +02:00
|
|
|
u8 wallpaperOffset;
|
2021-04-17 06:49:51 +02:00
|
|
|
u8 scrollUnused1; // Never read
|
|
|
|
u8 scrollToBoxIdUnused; // Never read
|
|
|
|
u16 scrollUnused2; // Never read
|
|
|
|
s16 scrollDirectionUnused; // Never read.
|
|
|
|
u16 scrollUnused3; // Never read
|
|
|
|
u16 scrollUnused4; // Never read
|
|
|
|
u16 scrollUnused5; // Never read
|
|
|
|
u16 scrollUnused6; // Never read
|
2021-04-18 05:55:24 +02:00
|
|
|
u8 filler1[22];
|
2021-04-15 20:06:25 +02:00
|
|
|
u8 boxTitleTiles[1024];
|
|
|
|
u8 boxTitleCycleId;
|
|
|
|
u8 wallpaperLoadState; // Written to, but never read.
|
|
|
|
u8 wallpaperLoadBoxId;
|
|
|
|
s8 wallpaperLoadDir;
|
|
|
|
u16 boxTitlePal[16];
|
|
|
|
u16 boxTitlePalOffset;
|
|
|
|
u16 boxTitleAltPalOffset;
|
|
|
|
struct Sprite *curBoxTitleSprites[2];
|
|
|
|
struct Sprite *nextBoxTitleSprites[2];
|
|
|
|
struct Sprite *arrowSprites[2];
|
2021-04-18 05:55:24 +02:00
|
|
|
u32 wallpaperPalBits;
|
|
|
|
u8 filler2[80]; // Unused
|
|
|
|
u16 unkUnused1; // Never read.
|
2018-12-19 22:47:27 +01:00
|
|
|
s16 wallpaperSetId;
|
|
|
|
s16 wallpaperId;
|
2021-04-15 20:06:25 +02:00
|
|
|
u16 wallpaperTilemap[360];
|
2018-12-19 22:47:27 +01:00
|
|
|
u8 wallpaperChangeState;
|
2021-04-15 20:06:25 +02:00
|
|
|
u8 scrollState;
|
|
|
|
u8 scrollToBoxId;
|
|
|
|
s8 scrollDirection;
|
2018-12-19 22:47:27 +01:00
|
|
|
u8 *wallpaperTiles;
|
|
|
|
struct Sprite *movingMonSprite;
|
|
|
|
struct Sprite *partySprites[PARTY_SIZE];
|
|
|
|
struct Sprite *boxMonsSprites[IN_BOX_COUNT];
|
2021-04-18 05:55:24 +02:00
|
|
|
struct Sprite **shiftMonSpritePtr;
|
2021-04-16 05:27:05 +02:00
|
|
|
struct Sprite **releaseMonSpritePtr;
|
|
|
|
u16 numIconsPerSpecies[MAX_MON_ICONS];
|
|
|
|
u16 iconSpeciesList[MAX_MON_ICONS];
|
2018-12-19 22:47:27 +01:00
|
|
|
u16 boxSpecies[IN_BOX_COUNT];
|
|
|
|
u32 boxPersonalities[IN_BOX_COUNT];
|
2021-04-18 05:55:24 +02:00
|
|
|
u8 incomingBoxId;
|
|
|
|
u8 shiftTimer;
|
2021-04-17 20:33:00 +02:00
|
|
|
u8 numPartyToCompact;
|
2021-04-18 01:28:31 +02:00
|
|
|
u16 iconScrollDistance;
|
|
|
|
s16 iconScrollPos;
|
|
|
|
s16 iconScrollSpeed;
|
|
|
|
u16 iconScrollNumIncoming;
|
|
|
|
u8 iconScrollCurColumn;
|
|
|
|
s8 iconScrollDirection; // Unnecessary duplicate of scrollDirection
|
|
|
|
u8 iconScrollState;
|
|
|
|
u8 iconScrollToBoxId; // Unnecessary duplicate of scrollToBoxId
|
2018-12-19 22:47:27 +01:00
|
|
|
struct WindowTemplate menuWindow;
|
|
|
|
struct StorageMenu menuItems[7];
|
|
|
|
u8 menuItemsCount;
|
|
|
|
u8 menuWidth;
|
2021-04-17 06:49:51 +02:00
|
|
|
u8 menuUnusedField; // Never read.
|
2021-04-15 19:31:18 +02:00
|
|
|
u16 menuWindowId;
|
2021-04-16 05:27:05 +02:00
|
|
|
struct Sprite *cursorSprite;
|
2021-04-17 06:49:51 +02:00
|
|
|
struct Sprite *cursorShadowSprite;
|
|
|
|
s32 cursorNewX;
|
|
|
|
s32 cursorNewY;
|
|
|
|
u32 cursorSpeedX;
|
|
|
|
u32 cursorSpeedY;
|
|
|
|
s16 cursorTargetX;
|
|
|
|
s16 cursorTargetY;
|
2021-04-16 23:05:44 +02:00
|
|
|
u16 cursorMoveSteps;
|
2021-04-17 06:49:51 +02:00
|
|
|
s8 cursorVerticalWrap;
|
|
|
|
s8 cursorHorizontalWrap;
|
|
|
|
u8 newCursorArea;
|
|
|
|
u8 newCursorPosition;
|
|
|
|
u8 cursorPrevHorizPos;
|
|
|
|
u8 cursorFlipTimer;
|
2021-04-16 05:27:05 +02:00
|
|
|
u8 cursorPalNums[2];
|
|
|
|
const u32 *displayMonPalette;
|
|
|
|
u32 displayMonPersonality;
|
|
|
|
u16 displayMonSpecies;
|
|
|
|
u16 displayMonItemId;
|
2021-04-17 06:49:51 +02:00
|
|
|
u16 displayUnusedVar;
|
2018-12-20 22:14:36 +01:00
|
|
|
bool8 setMosaic;
|
2021-04-16 05:27:05 +02:00
|
|
|
u8 displayMonMarkings;
|
|
|
|
u8 displayMonLevel;
|
|
|
|
bool8 displayMonIsEgg;
|
|
|
|
u8 displayMonName[POKEMON_NAME_LENGTH + 1];
|
|
|
|
u8 displayMonNameText[36];
|
|
|
|
u8 displayMonSpeciesName[36];
|
|
|
|
u8 displayMonGenderLvlText[36];
|
|
|
|
u8 displayMonItemName[36];
|
2018-12-19 22:47:27 +01:00
|
|
|
bool8 (*monPlaceChangeFunc)(void);
|
|
|
|
u8 monPlaceChangeState;
|
2021-04-18 05:55:24 +02:00
|
|
|
u8 shiftBoxId;
|
2021-04-16 01:17:53 +02:00
|
|
|
struct Sprite *markingComboSprite;
|
|
|
|
struct Sprite *waveformSprites[2];
|
|
|
|
u16 *markingComboTilesPtr;
|
2021-02-28 23:42:11 +01:00
|
|
|
struct MonMarkingsMenu markMenu;
|
2021-04-15 23:31:50 +02:00
|
|
|
struct ChooseBoxMenu chooseBoxMenu;
|
2018-12-19 22:47:27 +01:00
|
|
|
struct Pokemon movingMon;
|
2021-04-16 05:27:05 +02:00
|
|
|
struct Pokemon tempMon;
|
|
|
|
s8 canReleaseMon;
|
|
|
|
bool8 releaseStatusResolved;
|
|
|
|
s8 releaseCheckBoxId;
|
|
|
|
s8 releaseCheckBoxPos;
|
|
|
|
s8 releaseBoxId;
|
|
|
|
s8 releaseBoxPos;
|
|
|
|
u16 releaseCheckState;
|
|
|
|
u16 restrictedReleaseMonMoves;
|
|
|
|
u16 restrictedMoveList[8];
|
2021-04-17 06:49:51 +02:00
|
|
|
u8 summaryMaxPos;
|
|
|
|
u8 summaryStartPos;
|
2021-04-15 23:31:50 +02:00
|
|
|
u8 summaryScreenMode;
|
2018-12-19 22:47:27 +01:00
|
|
|
union
|
|
|
|
{
|
|
|
|
struct Pokemon *mon;
|
|
|
|
struct BoxPokemon *box;
|
2021-04-17 06:49:51 +02:00
|
|
|
} summaryMon;
|
|
|
|
u8 messageText[40];
|
2021-04-15 20:06:25 +02:00
|
|
|
u8 boxTitleText[40];
|
2021-04-16 05:27:05 +02:00
|
|
|
u8 releaseMonName[POKEMON_NAME_LENGTH + 1];
|
2018-12-20 22:14:36 +01:00
|
|
|
u8 itemName[20];
|
2018-12-19 22:47:27 +01:00
|
|
|
u8 inBoxMovingMode;
|
2021-04-16 23:05:44 +02:00
|
|
|
u16 multiMoveWindowId;
|
2021-04-16 01:17:53 +02:00
|
|
|
struct ItemIcon itemIcons[MAX_ITEM_ICONS];
|
|
|
|
u16 movingItemId;
|
|
|
|
u16 itemInfoWindowOffset;
|
2021-04-18 05:55:24 +02:00
|
|
|
u8 unkUnused2; // Unused
|
2021-04-16 05:27:05 +02:00
|
|
|
u16 displayMonPalOffset;
|
|
|
|
u16 *displayMonTilePtr;
|
|
|
|
struct Sprite *displayMonSprite;
|
|
|
|
u16 displayMonPalBuffer[0x40];
|
2021-04-16 01:17:53 +02:00
|
|
|
u8 tileBuffer[0x800];
|
2021-04-18 05:55:24 +02:00
|
|
|
u8 unusedBuffer[0x1800]; // Unused
|
|
|
|
u8 itemIconBuffer[0x800];
|
2021-04-15 20:06:25 +02:00
|
|
|
u8 wallpaperBgTilemapBuffer[0x1000];
|
2021-04-17 06:49:51 +02:00
|
|
|
u8 displayMenuTilemapBuffer[0x800];
|
2018-12-19 22:47:27 +01:00
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static u32 sItemIconGfxBuffer[98];
|
2018-12-20 22:14:36 +01:00
|
|
|
|
|
|
|
EWRAM_DATA static u8 sPreviousBoxOption = 0;
|
2021-04-15 23:31:50 +02:00
|
|
|
EWRAM_DATA static struct ChooseBoxMenu *sChooseBoxMenu = NULL;
|
2021-04-18 05:40:27 +02:00
|
|
|
EWRAM_DATA static struct PokemonStorageSystemData *sStorage = NULL;
|
2018-12-20 22:14:36 +01:00
|
|
|
EWRAM_DATA static bool8 sInPartyMenu = 0;
|
|
|
|
EWRAM_DATA static u8 sCurrentBoxOption = 0;
|
2021-04-15 23:31:50 +02:00
|
|
|
EWRAM_DATA static u8 sDepositBoxId = 0;
|
2018-12-20 22:14:36 +01:00
|
|
|
EWRAM_DATA static u8 sWhichToReshow = 0;
|
2019-09-17 07:49:07 +02:00
|
|
|
EWRAM_DATA static u8 sLastUsedBox = 0;
|
2020-03-08 02:45:04 +01:00
|
|
|
EWRAM_DATA static u16 sMovingItemId = 0;
|
2021-04-17 06:49:51 +02:00
|
|
|
EWRAM_DATA static struct Pokemon sSavedMovingMon = {0};
|
2021-04-16 23:05:44 +02:00
|
|
|
EWRAM_DATA static s8 sCursorArea = 0;
|
|
|
|
EWRAM_DATA static s8 sCursorPosition = 0;
|
2018-12-20 22:14:36 +01:00
|
|
|
EWRAM_DATA static bool8 sIsMonBeingMoved = 0;
|
|
|
|
EWRAM_DATA static u8 sMovingMonOrigBoxId = 0;
|
|
|
|
EWRAM_DATA static u8 sMovingMonOrigBoxPos = 0;
|
2021-04-16 23:05:44 +02:00
|
|
|
EWRAM_DATA static bool8 sAutoActionOn = 0;
|
2018-12-09 16:44:01 +01:00
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
// Main tasks
|
2021-04-18 05:40:27 +02:00
|
|
|
static void EnterPokeStorage(u8);
|
|
|
|
static void Task_InitPokeStorage(u8);
|
|
|
|
static void Task_PlaceMon(u8);
|
|
|
|
static void Task_ChangeScreen(u8);
|
|
|
|
static void Task_ShowPokeStorage(u8);
|
|
|
|
static void Task_OnBPressed(u8);
|
|
|
|
static void Task_HandleBoxOptions(u8);
|
|
|
|
static void Task_OnSelectedMon(u8);
|
|
|
|
static void Task_OnCloseBoxPressed(u8);
|
|
|
|
static void Task_HidePartyPokemon(u8);
|
|
|
|
static void Task_DepositMenu(u8);
|
|
|
|
static void Task_MoveMon(u8);
|
|
|
|
static void Task_GiveMovingItemToMon(u8);
|
|
|
|
static void Task_SwitchSelectedItem(u8);
|
|
|
|
static void Task_TakeItemForMoving(u8);
|
|
|
|
static void Task_WithdrawMon(u8);
|
|
|
|
static void Task_ShiftMon(u8);
|
|
|
|
static void Task_ShowPartyPokemon(u8);
|
|
|
|
static void Task_ShowItemInfo(u8);
|
|
|
|
static void Task_GiveItemFromBag(u8);
|
|
|
|
static void Task_ItemToBag(u8);
|
|
|
|
static void Task_TakeItemForMoving(u8);
|
|
|
|
static void Task_ShowMarkMenu(u8);
|
|
|
|
static void Task_ShowMonSummary(u8);
|
|
|
|
static void Task_ReleaseMon(u8);
|
|
|
|
static void Task_ReshowPokeStorage(u8);
|
|
|
|
static void Task_PokeStorageMain(u8);
|
|
|
|
static void Task_JumpBox(u8);
|
|
|
|
static void Task_HandleWallpapers(u8);
|
|
|
|
static void Task_NameBox(u8);
|
|
|
|
static void Task_PrintCantStoreMail(u8);
|
|
|
|
static void Task_HandleMovingMonFromParty(u8);
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
// Input handlers
|
|
|
|
static u8 InBoxInput_Normal(void);
|
|
|
|
static u8 InBoxInput_MovingMultiple(void);
|
|
|
|
static u8 InBoxInput_SelectingMultiple(void);
|
|
|
|
static u8 HandleInput(void);
|
|
|
|
static void AddBoxOptionsMenu(void);
|
|
|
|
static u8 SetSelectionMenuTexts(void);
|
|
|
|
static bool8 SetMenuTexts_Mon(void);
|
|
|
|
static bool8 SetMenuTexts_Item(void);
|
|
|
|
|
|
|
|
// Choose box menu
|
|
|
|
static void ChooseBoxMenu_CreateSprites(u8);
|
|
|
|
static void ChooseBoxMenu_DestroySprites(void);
|
|
|
|
static void ChooseBoxMenu_MoveLeft(void);
|
|
|
|
static void ChooseBoxMenu_MoveRight(void);
|
|
|
|
static void ChooseBoxMenu_PrintInfo(void);
|
|
|
|
static void SpriteCB_ChooseBoxArrow(struct Sprite *);
|
|
|
|
|
|
|
|
// Options menus
|
|
|
|
static void InitMenu(void);
|
|
|
|
static void SetMenuText(u8);
|
|
|
|
static s8 GetMenuItemTextId(u8);
|
|
|
|
static void AddMenu(void);
|
|
|
|
static bool8 IsMenuLoading(void);
|
2021-04-15 19:31:18 +02:00
|
|
|
static s16 HandleMenuInput(void);
|
2021-04-18 05:55:24 +02:00
|
|
|
static void RemoveMenu(void);
|
|
|
|
|
|
|
|
// Pokémon sprites
|
|
|
|
static void InitMonIconFields(void);
|
|
|
|
static void SpriteCB_BoxMonIconScrollOut(struct Sprite *);
|
|
|
|
static void GetIncomingBoxMonData(u8);
|
|
|
|
static void CreatePartyMonsSprites(bool8);
|
|
|
|
static void CompactPartySprites(void);
|
|
|
|
static u8 GetNumPartySpritesCompacting(void);
|
|
|
|
static void MovePartySpriteToNextSlot(struct Sprite *, u16);
|
2021-04-17 20:33:00 +02:00
|
|
|
static void SpriteCB_MovePartyMonToNextSlot(struct Sprite *);
|
2021-04-17 06:49:51 +02:00
|
|
|
static void MovePartySprites(s16);
|
2021-04-18 05:55:24 +02:00
|
|
|
static void DestroyAllPartyMonIcons(void);
|
|
|
|
static void ReshowReleaseMon(void);
|
|
|
|
static bool8 ResetReleaseMonSpritePtr(void);
|
|
|
|
static void SetMovingMonPriority(u8);
|
|
|
|
static void SpriteCB_HeldMon(struct Sprite *);
|
2021-04-15 23:31:50 +02:00
|
|
|
static struct Sprite *CreateMonIconSprite(u16, u32, s16, s16, u8, u8);
|
|
|
|
static void DestroyBoxMonIcon(struct Sprite *);
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
// Pokémon data
|
|
|
|
static void MoveMon(void);
|
|
|
|
static void PlaceMon(void);
|
|
|
|
static void RefreshDisplayMon(void);
|
2021-04-17 06:49:51 +02:00
|
|
|
static void SetMovingMonData(u8, u8);
|
2021-04-15 23:31:50 +02:00
|
|
|
static void SetPlacedMonData(u8, u8);
|
|
|
|
static void PurgeMonOrBoxMon(u8, u8);
|
2021-04-18 05:55:24 +02:00
|
|
|
static void SetShiftedMonData(u8, u8);
|
|
|
|
static bool8 TryStorePartyMonInBox(u8);
|
|
|
|
static void ResetSelectionAfterDeposit(void);
|
|
|
|
static void InitReleaseMon(void);
|
|
|
|
static bool8 TryHideReleaseMon(void);
|
|
|
|
static void InitCanReleaseMonVars(void);
|
|
|
|
static void ReleaseMon(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static bool32 AtLeastThreeUsableMons(void);
|
2021-04-18 05:55:24 +02:00
|
|
|
static s8 RunCanReleaseMon(void);
|
|
|
|
static void SaveMovingMon(void);
|
|
|
|
static void LoadSavedMovingMon(void);
|
|
|
|
static void InitSummaryScreenData(void);
|
|
|
|
static void SetSelectionAfterSummaryScreen(void);
|
|
|
|
static void SetMonMarkings(u8);
|
|
|
|
static bool8 IsRemovingLastPartyMon(void);
|
|
|
|
static bool8 CanShiftMon(void);
|
|
|
|
static bool8 IsMonBeingMoved(void);
|
|
|
|
static void TryRefreshDisplayMon(void);
|
|
|
|
static void ReshowDisplayMon(void);
|
|
|
|
static void SetDisplayMonData(void *, u8);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
// Moving multiple Pokémon at once
|
2021-04-16 23:05:44 +02:00
|
|
|
static void MultiMove_Free(void);
|
|
|
|
static bool8 MultiMove_Init(void);
|
|
|
|
static bool8 MultiMove_RunFunction(void);
|
|
|
|
static bool8 MultiMove_TryMoveGroup(u8);
|
|
|
|
static bool8 MultiMove_CanPlaceSelection(void);
|
|
|
|
static void MultiMove_SetFunction(u8);
|
|
|
|
static u8 MultiMove_GetOrigin(void);
|
|
|
|
static bool8 MultiMove_Start(void);
|
|
|
|
static bool8 MultiMove_Cancel(void);
|
|
|
|
static bool8 MultiMove_ChangeSelection(void);
|
|
|
|
static bool8 MultiMove_GrabSelection(void);
|
|
|
|
static bool8 MultiMove_MoveMons(void);
|
|
|
|
static bool8 MultiMove_PlaceMons(void);
|
|
|
|
static void MultiMove_SetIconToBg(u8, u8);
|
|
|
|
static void MultiMove_ClearIconFromBg(u8, u8);
|
|
|
|
static void MultiMove_ResetBg(void);
|
|
|
|
static void MultiMove_UpdateSelectedIcons(void);
|
|
|
|
static void MultiMove_InitMove(u16, u16, u16);
|
|
|
|
static void MultiMove_GetMonsFromSelection(void);
|
|
|
|
static void MultiMove_RemoveMonsFromBox(void);
|
|
|
|
static void MultiMove_CreatePlacedMonIcons(void);
|
|
|
|
static void MultiMove_SetPlacedMonData(void);
|
|
|
|
static u8 MultiMove_UpdateMove(void);
|
|
|
|
static void MultiMove_DeselectRow(u8, u8, u8);
|
|
|
|
static void MultiMove_SelectRow(u8, u8, u8);
|
|
|
|
static void MultiMove_SelectColumn(u8, u8, u8);
|
|
|
|
static void MultiMove_DeselectColumn(u8, u8, u8);
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
// Move Items mode
|
2021-04-17 06:49:51 +02:00
|
|
|
static bool32 IsItemIconAtPosition(u8, u8);
|
|
|
|
static const u32 *GetItemIconPic(u16);
|
|
|
|
static const u32 *GetItemIconPalette(u16);
|
|
|
|
static u8 GetNewItemIconIdx(void);
|
|
|
|
static void SetItemIconPosition(u8, u8, u8);
|
|
|
|
static void LoadItemIconGfx(u8, const u32 *, const u32 *);
|
|
|
|
static void SetItemIconAffineAnim(u8, u8);
|
|
|
|
static void SetItemIconActive(u8, bool8);
|
|
|
|
static u8 GetItemIconIdxByPosition(u8, u8);
|
2021-04-18 05:55:24 +02:00
|
|
|
static void CreateItemIconSprites(void);
|
|
|
|
static void TryLoadItemIconAtPos(u8, u8);
|
|
|
|
static void TryHideItemIconAtPos(u8, u8);
|
|
|
|
static void TakeItemFromMon(u8, u8);
|
|
|
|
static void InitItemIconInCursor(u16);
|
|
|
|
static void SwapItemsWithMon(u8, u8);
|
|
|
|
static void GiveItemToMon(u8, u8);
|
|
|
|
static void MoveItemFromMonToBag(u8, u8);
|
|
|
|
static void MoveItemFromCursorToBag(void);
|
|
|
|
static void MoveHeldItemWithPartyMenu(void);
|
|
|
|
static bool8 IsItemIconAnimActive(void);
|
|
|
|
static bool8 IsMovingItem(void);
|
|
|
|
static const u8 *GetMovingItemName(void);
|
|
|
|
static u16 GetMovingItemId(void);
|
|
|
|
static void PrintItemDescription(void);
|
|
|
|
static void InitItemInfoWindow(void);
|
|
|
|
static bool8 UpdateItemInfoWindowSlideIn(void);
|
|
|
|
static bool8 UpdateItemInfoWindowSlideOut(void);
|
|
|
|
static void DrawItemInfoWindow(u32);
|
2021-04-17 06:49:51 +02:00
|
|
|
static void SetItemIconCallback(u8, u8, u8, u8);
|
|
|
|
static void SpriteCB_ItemIcon_SetPosToCursor(struct Sprite *);
|
|
|
|
static void SpriteCB_ItemIcon_WaitAnim(struct Sprite *);
|
|
|
|
static void SpriteCB_ItemIcon_ToHand(struct Sprite *);
|
|
|
|
static void SpriteCB_ItemIcon_ToMon(struct Sprite *);
|
|
|
|
static void SpriteCB_ItemIcon_SwapToHand(struct Sprite *);
|
|
|
|
static void SpriteCB_ItemIcon_HideParty(struct Sprite *);
|
|
|
|
static void SpriteCB_ItemIcon_SwapToMon(struct Sprite *);
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
// Cursor
|
|
|
|
static void CreateCursorSprites(void);
|
|
|
|
static void ToggleCursorAutoAction(void);
|
|
|
|
static u8 GetCursorPosition(void);
|
|
|
|
static void StartCursorAnim(u8);
|
|
|
|
static void TryHideItemAtCursor(void);
|
|
|
|
static void TryShowItemAtCursor(void);
|
|
|
|
static void InitCursor(void);
|
|
|
|
static void InitCursorOnReopen(void);
|
|
|
|
static void GetCursorCoordsByPos(u8, u8, u16 *, u16 *);
|
|
|
|
static bool8 UpdateCursorPos(void);
|
|
|
|
static void DoCursorNewPosUpdate(void);
|
|
|
|
static void SetCursorInParty(void);
|
|
|
|
static void SetCursorBoxPosition(u8);
|
|
|
|
static void ClearSavedCursorPos(void);
|
|
|
|
static void SaveCursorPos(void);
|
|
|
|
static u8 GetSavedCursorPos(void);
|
|
|
|
static void InitMonPlaceChange(u8);
|
|
|
|
static bool8 DoMonPlaceChange(void);
|
|
|
|
static bool8 MonPlaceChange_Shift(void);
|
|
|
|
static bool8 MonPlaceChange_Grab(void);
|
|
|
|
static bool8 MonPlaceChange_Place(void);
|
|
|
|
static bool8 MultiMonPlaceChange_Up(void);
|
|
|
|
static bool8 MultiMonPlaceChange_Down(void);
|
|
|
|
static bool8 MonPlaceChange_CursorDown(void);
|
|
|
|
static bool8 MonPlaceChange_CursorUp(void);
|
|
|
|
static void TrySetCursorFistAnim(void);
|
|
|
|
static bool8 IsCursorOnCloseBox(void);
|
|
|
|
static bool8 IsCursorOnBoxTitle(void);
|
|
|
|
static bool8 IsCursorInBox(void);
|
2018-12-09 16:44:01 +01:00
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
// Scroll arrows
|
|
|
|
static void CreateBoxScrollArrows(void);
|
|
|
|
static void StartBoxScrollArrowsSlide(s8);
|
|
|
|
static void StopBoxScrollArrowsSlide(void);
|
|
|
|
static void AnimateBoxScrollArrows(bool8);
|
|
|
|
static void SpriteCB_Arrow(struct Sprite *);
|
|
|
|
static struct Sprite *CreateChooseBoxArrows(u16, u16, u8, u8, u8);
|
|
|
|
|
|
|
|
// Box title
|
|
|
|
static void InitBoxTitle(u8);
|
|
|
|
static void CreateIncomingBoxTitle(u8, s8);
|
|
|
|
static void CycleBoxTitleSprites(void);
|
|
|
|
static void SpriteCB_IncomingBoxTitle(struct Sprite *);
|
|
|
|
static void SpriteCB_OutgoingBoxTitle(struct Sprite *);
|
|
|
|
static void CycleBoxTitleColor(void);
|
|
|
|
static s16 GetBoxTitleBaseX(const u8 *);
|
|
|
|
|
|
|
|
// Wallpaper
|
|
|
|
static void SetWallpaperForCurrentBox(u8);
|
|
|
|
static bool8 DoWallpaperGfxChange(void);
|
|
|
|
static void LoadWallpaperGfx(u8, s8);
|
|
|
|
static bool32 WaitForWallpaperGfxLoad(void);
|
|
|
|
static void DrawWallpaper(const void *, s8, u8);
|
|
|
|
static void TrimOldWallpaper(void *);
|
|
|
|
static void AddWallpaperSetsMenu(void);
|
|
|
|
static void AddWallpapersMenu(u8);
|
|
|
|
static u8 GetBoxWallpaper(u8);
|
|
|
|
static void SetBoxWallpaper(u8, u8);
|
|
|
|
|
|
|
|
// General box
|
|
|
|
static void CreateInitBoxTask(u8);
|
|
|
|
static bool8 IsInitBoxActive(void);
|
|
|
|
static void Task_InitBox(u8);
|
|
|
|
static void SetUpScrollToBox(u8);
|
|
|
|
static bool8 ScrollToBox(void);
|
|
|
|
static s8 DetermineBoxScrollDirection(u8);
|
|
|
|
static void SetCurrentBox(u8);
|
|
|
|
|
|
|
|
// Misc
|
|
|
|
static void CreateMainMenu(u8, s16 *);
|
2018-12-19 22:47:27 +01:00
|
|
|
static u8 GetCurrentBoxOption(void);
|
|
|
|
static void ScrollBackground(void);
|
2021-04-18 05:55:24 +02:00
|
|
|
static void UpdateCloseBoxButtonFlash(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static void GiveChosenBagItem(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void SetUpHidePartyMenu(void);
|
2021-04-18 05:55:24 +02:00
|
|
|
static void LoadPokeStorageMenuGfx(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static void LoadWaveformSpritePalette(void);
|
2021-04-18 05:55:24 +02:00
|
|
|
static void InitPokeStorageBg0(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void SetScrollingBackground(void);
|
2021-04-18 05:55:24 +02:00
|
|
|
static void UpdateBoxToSendMons(void);
|
|
|
|
static void InitCursorItemIcon(void);
|
|
|
|
static void InitPalettesAndSprites(void);
|
|
|
|
static void RefreshDisplayMonData(void);
|
|
|
|
static void CreateDisplayMonSprite(void);
|
|
|
|
static void CreateMarkingComboSprite(void);
|
|
|
|
static void CreateWaveformSprites(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static void ClearBottomWindow(void);
|
2021-04-18 05:55:24 +02:00
|
|
|
static void InitSupplementalTilemaps(void);
|
|
|
|
static void PrintDisplayMonInfo(void);
|
|
|
|
static void UpdateWaveformAnimation(void);
|
|
|
|
static void SetPartySlotTilemaps(void);
|
|
|
|
static void StopFlashingCloseBoxButton(void);
|
|
|
|
static void FreePokeStorageData(void);
|
|
|
|
static void UpdatePartySlotColors(void);
|
|
|
|
static void StartFlashingCloseBoxButton(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void SetUpDoShowPartyMenu(void);
|
2021-04-18 05:55:24 +02:00
|
|
|
static void StartDisplayMonMosaicEffect(void);
|
|
|
|
static bool8 InitPokeStorageWindows(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 DoShowPartyMenu(void);
|
|
|
|
static bool8 HidePartyMenu(void);
|
2021-04-18 05:55:24 +02:00
|
|
|
static bool8 IsDisplayMosaicActive(void);
|
|
|
|
static void ShowYesNoWindow(s8);
|
|
|
|
static void UpdateCloseBoxButtonTilemap(bool8);
|
|
|
|
static void PrintMessage(u8 id);
|
|
|
|
static void LoadDisplayMonGfx(u16, u32);
|
|
|
|
static void SpriteCB_DisplayMonMosaic(struct Sprite *);
|
|
|
|
static void SetPartySlotTilemap(u8, bool8);
|
|
|
|
|
|
|
|
// Tilemap utility
|
2021-04-17 23:28:18 +02:00
|
|
|
static void TilemapUtil_SetRect(u8, u16, u16, u16, u16);
|
|
|
|
static void TilemapUtil_Move(u8, u8, s8);
|
|
|
|
static void TilemapUtil_SetMap(u8, u8, const void *, u16, u16);
|
|
|
|
static void TilemapUtil_SetPos(u8, u16, u16);
|
|
|
|
static void TilemapUtil_Init(u8);
|
|
|
|
static void TilemapUtil_Free(void);
|
|
|
|
static void TilemapUtil_Update(u8);
|
|
|
|
static void TilemapUtil_DrawPrev(u8);
|
|
|
|
static void TilemapUtil_Draw(u8);
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
// Unknown utility
|
2021-04-18 05:31:29 +02:00
|
|
|
static void UnkUtil_Init(struct UnkUtil *, struct UnkUtilData *, u32);
|
|
|
|
static void UnkUtil_Run(void);
|
|
|
|
static void UnkUtil_CpuRun(struct UnkUtilData *);
|
|
|
|
static void UnkUtil_DmaRun(struct UnkUtilData *);
|
|
|
|
|
2021-09-29 05:48:03 +02:00
|
|
|
// Form changing
|
|
|
|
void SetArceusFormPSS(struct BoxPokemon *boxMon);
|
|
|
|
void UpdateSpeciesSpritePSS(struct BoxPokemon *boxmon);
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
struct {
|
|
|
|
const u8 *text;
|
|
|
|
const u8 *desc;
|
|
|
|
} static const sMainMenuTexts[OPTIONS_COUNT] =
|
2017-12-22 20:10:51 +01:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
[OPTION_WITHDRAW] = {gText_WithdrawPokemon, gText_WithdrawMonDescription},
|
|
|
|
[OPTION_DEPOSIT] = {gText_DepositPokemon, gText_DepositMonDescription},
|
|
|
|
[OPTION_MOVE_MONS] = {gText_MovePokemon, gText_MoveMonDescription},
|
|
|
|
[OPTION_MOVE_ITEMS] = {gText_MoveItems, gText_MoveItemsDescription},
|
|
|
|
[OPTION_EXIT] = {gText_SeeYa, gText_SeeYaDescription}
|
2017-12-22 20:10:51 +01:00
|
|
|
};
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static const struct WindowTemplate sWindowTemplate_MainMenu =
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 1,
|
|
|
|
.tilemapTop = 1,
|
|
|
|
.width = 17,
|
|
|
|
.height = 10,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x1,
|
|
|
|
};
|
2017-12-22 20:10:51 +01:00
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static const union AnimCmd sAnim_ChooseBoxMenu_TopLeft[] =
|
2017-12-22 20:10:51 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static const union AnimCmd sAnim_ChooseBoxMenu_BottomLeft[] =
|
2017-12-22 20:10:51 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(4, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static const union AnimCmd sAnim_ChooseBoxMenu_TopRight[] =
|
2017-12-22 20:10:51 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(6, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static const union AnimCmd sAnim_ChooseBoxMenu_BottomRight[] =
|
2017-12-22 20:10:51 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(10, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static const union AnimCmd *const sAnims_ChooseBoxMenu[] =
|
2017-12-22 20:10:51 +01:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
sAnim_ChooseBoxMenu_TopLeft,
|
|
|
|
sAnim_ChooseBoxMenu_BottomLeft,
|
|
|
|
sAnim_ChooseBoxMenu_TopRight,
|
|
|
|
sAnim_ChooseBoxMenu_BottomRight
|
2017-12-22 20:10:51 +01:00
|
|
|
};
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static const union AffineAnimCmd sAffineAnim_ChooseBoxMenu[] =
|
2017-12-22 20:10:51 +01:00
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(0xE0, 0xE0, 0, 0),
|
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
// Unused
|
|
|
|
static const union AffineAnimCmd *const sAffineAnims_ChooseBoxMenu[] =
|
2017-12-22 20:10:51 +01:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
sAffineAnim_ChooseBoxMenu
|
2017-12-22 20:10:51 +01:00
|
|
|
};
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static const u8 sChooseBoxMenu_TextColors[] = {TEXT_COLOR_RED, TEXT_DYNAMIC_COLOR_6, TEXT_DYNAMIC_COLOR_5};
|
2019-12-10 19:48:20 +01:00
|
|
|
static const u8 sText_OutOf30[] = _("/30");
|
2017-12-22 20:10:51 +01:00
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static const u16 sChooseBoxMenu_Pal[] = INCBIN_U16("graphics/pokemon_storage/box_selection_popup.gbapal");
|
2021-04-15 23:31:50 +02:00
|
|
|
static const u8 sChooseBoxMenuCenter_Gfx[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_center.4bpp");
|
2021-04-17 23:28:18 +02:00
|
|
|
static const u8 sChooseBoxMenuSides_Gfx[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_sides.4bpp");
|
|
|
|
static const u32 sScrollingBg_Gfx[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.4bpp.lz");
|
|
|
|
static const u32 sScrollingBg_Tilemap[] = INCBIN_U32("graphics/pokemon_storage/scrolling_bg.bin.lz");
|
|
|
|
static const u16 sDisplayMenu_Pal[] = INCBIN_U16("graphics/pokemon_storage/display_menu.gbapal"); // Unused
|
|
|
|
static const u32 sDisplayMenu_Tilemap[] = INCBIN_U32("graphics/pokemon_storage/display_menu.bin.lz");
|
2018-12-09 16:44:01 +01:00
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static const u16 sPkmnData_Tilemap[] =
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x0106, 0x0107, 0x0108, 0x0111, 0x0112, 0x0113, 0x0114, 0x0115, 0x0116, 0x0117, 0x0118,
|
|
|
|
0x2101, 0x2102, 0x2103, 0x2104, 0x2105, 0x2106, 0x2107, 0x2108, 0x2111, 0x2112, 0x2113, 0x2114, 0x2115, 0x2116, 0x2117, 0x2118,
|
|
|
|
};
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
// sInterface_Pal - parts of the display frame, "PkmnData"'s normal color, Close Box
|
|
|
|
static const u16 sInterface_Pal[] = INCBIN_U16("graphics/pokemon_storage/interface.gbapal");
|
|
|
|
static const u16 sPkmnDataGray_Pal[] = INCBIN_U16("graphics/pokemon_storage/pkmn_data_gray.gbapal");
|
|
|
|
static const u16 sBg_Pal[] = INCBIN_U16("graphics/pokemon_storage/bg.gbapal");
|
|
|
|
static const u16 sBgMoveItems_Pal[] = INCBIN_U16("graphics/pokemon_storage/bg_move_items.gbapal");
|
2018-12-09 16:44:01 +01:00
|
|
|
|
2021-04-17 20:33:00 +02:00
|
|
|
static const u16 sCloseBoxButton_Tilemap[] =
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
0x014c, 0x014d, 0x014e, 0x014f, 0x0170, 0x0171, 0x0172, 0x0173, 0x0174, 0x015c, 0x015d, 0x015e, 0x015f, 0x0180, 0x0181, 0x0182,
|
2018-12-21 22:35:01 +01:00
|
|
|
0x0183, 0x0184, 0x0175, 0x0176, 0x0177, 0x0178, 0x0179, 0x017a, 0x017b, 0x017c, 0x017d, 0x0185, 0x0186, 0x0187, 0x0188, 0x0189,
|
|
|
|
0x018a, 0x018b, 0x018c, 0x018d
|
2018-12-09 16:44:01 +01:00
|
|
|
};
|
2021-04-17 20:33:00 +02:00
|
|
|
static const u16 sPartySlotFilled_Tilemap[] =
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
0x1140, 0x1141, 0x1141, 0x1142, 0x1150, 0x1151, 0x1151, 0x1152, 0x1160, 0x1161, 0x1161, 0x1162,
|
|
|
|
};
|
2021-04-17 20:33:00 +02:00
|
|
|
static const u16 sPartySlotEmpty_Tilemap[] =
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
0x1143, 0x1144, 0x1144, 0x1145, 0x1153, 0x1154, 0x1154, 0x1155, 0x1163, 0x1164, 0x1164, 0x1165,
|
|
|
|
};
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static const u16 sWaveform_Pal[] = INCBIN_U16("graphics/pokemon_storage/waveform.gbapal");
|
|
|
|
static const u32 sWaveform_Gfx[] = INCBIN_U32("graphics/pokemon_storage/waveform.4bpp");
|
2021-04-18 05:55:24 +02:00
|
|
|
static const u16 sUnused_Pal[] = INCBIN_U16("graphics/pokemon_storage/unused.gbapal");
|
|
|
|
static const u16 sUnknown_Pal[] = INCBIN_U16("graphics/pokemon_storage/unknown.gbapal");
|
2018-12-09 16:44:01 +01:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static const struct WindowTemplate sWindowTemplates[] =
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
{
|
2018-12-09 16:44:01 +01:00
|
|
|
.bg = 1,
|
|
|
|
.tilemapLeft = 0,
|
|
|
|
.tilemapTop = 11,
|
|
|
|
.width = 9,
|
|
|
|
.height = 7,
|
|
|
|
.paletteNum = 3,
|
|
|
|
.baseBlock = 0xC0,
|
|
|
|
},
|
2021-04-16 05:27:05 +02:00
|
|
|
{
|
2018-12-09 16:44:01 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 11,
|
|
|
|
.tilemapTop = 17,
|
|
|
|
.width = 18,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x14,
|
|
|
|
},
|
2021-04-16 05:27:05 +02:00
|
|
|
{
|
2018-12-09 16:44:01 +01:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 0,
|
|
|
|
.tilemapTop = 13,
|
|
|
|
.width = 21,
|
|
|
|
.height = 7,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x14,
|
|
|
|
},
|
|
|
|
DUMMY_WIN_TEMPLATE
|
|
|
|
};
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static const struct BgTemplate sBgTemplates[] =
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 29,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.baseTile = 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 1,
|
|
|
|
.charBaseIndex = 1,
|
|
|
|
.mapBaseIndex = 30,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.baseTile = 0x100
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 2,
|
|
|
|
.charBaseIndex = 2,
|
|
|
|
.mapBaseIndex = 27,
|
|
|
|
.screenSize = 1,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 2,
|
|
|
|
.baseTile = 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 3,
|
|
|
|
.charBaseIndex = 3,
|
|
|
|
.mapBaseIndex = 31,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 3,
|
|
|
|
.baseTile = 0
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static const struct SpritePalette gWaveformSpritePalette =
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:55:24 +02:00
|
|
|
sWaveform_Pal, PALTAG_MISC_2
|
2018-12-09 16:44:01 +01:00
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const struct SpriteSheet sSpriteSheet_Waveform =
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
sWaveform_Gfx, sizeof(sWaveform_Gfx), GFXTAG_WAVEFORM
|
2018-12-09 16:44:01 +01:00
|
|
|
};
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static const struct OamData sOamData_DisplayMon;
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_DisplayMon =
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
.tileTag = GFXTAG_DISPLAY_MON,
|
|
|
|
.paletteTag = PALTAG_DISPLAY_MON,
|
|
|
|
.oam = &sOamData_DisplayMon,
|
2018-12-09 16:44:01 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
};
|
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
static const struct StorageMessage sMessages[] =
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
[MSG_EXIT_BOX] = {gText_ExitFromBox, MSG_VAR_NONE},
|
|
|
|
[MSG_WHAT_YOU_DO] = {gText_WhatDoYouWantToDo, MSG_VAR_NONE},
|
|
|
|
[MSG_PICK_A_THEME] = {gText_PleasePickATheme, MSG_VAR_NONE},
|
|
|
|
[MSG_PICK_A_WALLPAPER] = {gText_PickTheWallpaper, MSG_VAR_NONE},
|
|
|
|
[MSG_IS_SELECTED] = {gText_PkmnIsSelected, MSG_VAR_MON_NAME_1},
|
|
|
|
[MSG_JUMP_TO_WHICH_BOX] = {gText_JumpToWhichBox, MSG_VAR_NONE},
|
|
|
|
[MSG_DEPOSIT_IN_WHICH_BOX] = {gText_DepositInWhichBox, MSG_VAR_NONE},
|
|
|
|
[MSG_WAS_DEPOSITED] = {gText_PkmnWasDeposited, MSG_VAR_MON_NAME_1},
|
|
|
|
[MSG_BOX_IS_FULL] = {gText_BoxIsFull2, MSG_VAR_NONE},
|
|
|
|
[MSG_RELEASE_POKE] = {gText_ReleaseThisPokemon, MSG_VAR_NONE},
|
|
|
|
[MSG_WAS_RELEASED] = {gText_PkmnWasReleased, MSG_VAR_RELEASE_MON_1},
|
|
|
|
[MSG_BYE_BYE] = {gText_ByeByePkmn, MSG_VAR_RELEASE_MON_3},
|
|
|
|
[MSG_MARK_POKE] = {gText_MarkYourPkmn, MSG_VAR_NONE},
|
|
|
|
[MSG_LAST_POKE] = {gText_ThatsYourLastPkmn, MSG_VAR_NONE},
|
|
|
|
[MSG_PARTY_FULL] = {gText_YourPartysFull, MSG_VAR_NONE},
|
|
|
|
[MSG_HOLDING_POKE] = {gText_YoureHoldingAPkmn, MSG_VAR_NONE},
|
|
|
|
[MSG_WHICH_ONE_WILL_TAKE] = {gText_WhichOneWillYouTake, MSG_VAR_NONE},
|
|
|
|
[MSG_CANT_RELEASE_EGG] = {gText_YouCantReleaseAnEgg, MSG_VAR_NONE},
|
|
|
|
[MSG_CONTINUE_BOX] = {gText_ContinueBoxOperations, MSG_VAR_NONE},
|
|
|
|
[MSG_CAME_BACK] = {gText_PkmnCameBack, MSG_VAR_MON_NAME_1},
|
|
|
|
[MSG_WORRIED] = {gText_WasItWorriedAboutYou, MSG_VAR_NONE},
|
|
|
|
[MSG_SURPRISE] = {gText_FourEllipsesExclamation, MSG_VAR_NONE},
|
|
|
|
[MSG_PLEASE_REMOVE_MAIL] = {gText_PleaseRemoveTheMail, MSG_VAR_NONE},
|
|
|
|
[MSG_IS_SELECTED2] = {gText_PkmnIsSelected, MSG_VAR_ITEM_NAME},
|
|
|
|
[MSG_GIVE_TO_MON] = {gText_GiveToAPkmn, MSG_VAR_NONE},
|
|
|
|
[MSG_PLACED_IN_BAG] = {gText_PlacedItemInBag, MSG_VAR_ITEM_NAME},
|
|
|
|
[MSG_BAG_FULL] = {gText_BagIsFull2, MSG_VAR_NONE},
|
|
|
|
[MSG_PUT_IN_BAG] = {gText_PutItemInBag, MSG_VAR_NONE},
|
|
|
|
[MSG_ITEM_IS_HELD] = {gText_ItemIsNowHeld, MSG_VAR_ITEM_NAME},
|
|
|
|
[MSG_CHANGED_TO_ITEM] = {gText_ChangedToNewItem, MSG_VAR_ITEM_NAME},
|
|
|
|
[MSG_CANT_STORE_MAIL] = {gText_MailCantBeStored, MSG_VAR_NONE},
|
2018-12-09 16:44:01 +01:00
|
|
|
};
|
2018-08-12 16:40:31 +02:00
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static const struct WindowTemplate sYesNoWindowTemplate =
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 24,
|
|
|
|
.tilemapTop = 11,
|
|
|
|
.width = 5,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x5C,
|
|
|
|
};
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static const struct OamData sOamData_DisplayMon =
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-12-04 21:25:13 +01:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
2018-12-10 23:42:44 +01:00
|
|
|
.mosaic = 0,
|
2019-12-04 21:25:13 +01:00
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(64x64),
|
2018-12-10 23:42:44 +01:00
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
2019-03-11 08:12:15 +01:00
|
|
|
.size = SPRITE_SIZE(64x64),
|
2018-12-10 23:42:44 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0
|
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const struct OamData sOamData_Waveform =
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-12-04 21:25:13 +01:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
2018-12-10 23:42:44 +01:00
|
|
|
.mosaic = 0,
|
2019-12-04 21:25:13 +01:00
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(16x8),
|
2018-12-10 23:42:44 +01:00
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
2019-03-11 08:12:15 +01:00
|
|
|
.size = SPRITE_SIZE(16x8),
|
2018-12-10 23:42:44 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0
|
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const union AnimCmd sAnim_Waveform_LeftOff[] =
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const union AnimCmd sAnim_Waveform_LeftOn[] =
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(2, 8),
|
|
|
|
ANIMCMD_FRAME(4, 8),
|
|
|
|
ANIMCMD_FRAME(6, 8),
|
|
|
|
ANIMCMD_JUMP(0)
|
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const union AnimCmd sAnim_Waveform_RightOff[] =
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(8, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const union AnimCmd sAnim_Waveform_RightOn[] =
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(10, 8),
|
|
|
|
ANIMCMD_FRAME(4, 8),
|
|
|
|
ANIMCMD_FRAME(12, 8),
|
|
|
|
ANIMCMD_JUMP(0)
|
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const union AnimCmd *const sAnims_Waveform[] =
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
sAnim_Waveform_LeftOff,
|
|
|
|
sAnim_Waveform_LeftOn,
|
|
|
|
sAnim_Waveform_RightOff,
|
|
|
|
sAnim_Waveform_RightOn
|
2018-12-10 23:42:44 +01:00
|
|
|
};
|
|
|
|
|
2018-12-21 22:35:01 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_Waveform =
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
.tileTag = GFXTAG_WAVEFORM,
|
2021-04-18 05:55:24 +02:00
|
|
|
.paletteTag = PALTAG_MISC_2,
|
2021-04-16 01:17:53 +02:00
|
|
|
.oam = &sOamData_Waveform,
|
|
|
|
.anims = sAnims_Waveform,
|
2018-12-10 23:42:44 +01:00
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
};
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static const struct OamData sOamData_MonIcon;
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_MonIcon =
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
.tileTag = GFXTAG_MON_ICON,
|
2021-04-16 01:17:53 +02:00
|
|
|
.paletteTag = PALTAG_MON_ICON_0,
|
2021-04-16 05:27:05 +02:00
|
|
|
.oam = &sOamData_MonIcon,
|
2018-12-10 23:42:44 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
};
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static const struct OamData sOamData_MonIcon =
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-12-04 21:25:13 +01:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
2018-12-10 23:42:44 +01:00
|
|
|
.mosaic = 0,
|
2019-12-04 21:25:13 +01:00
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(32x32),
|
2018-12-10 23:42:44 +01:00
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
2019-03-11 08:12:15 +01:00
|
|
|
.size = SPRITE_SIZE(32x32),
|
2018-12-10 23:42:44 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0
|
|
|
|
};
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static const union AffineAnimCmd sAffineAnim_ReleaseMon_Release[] =
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(-2, -2, 0, 120),
|
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static const union AffineAnimCmd sAffineAnim_ReleaseMon_CameBack[] =
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(16, 16, 0, 0),
|
|
|
|
AFFINEANIMCMD_FRAME(16, 16, 0, 15),
|
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static const union AffineAnimCmd *const sAffineAnims_ReleaseMon[] =
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
[RELEASE_ANIM_RELEASE] = sAffineAnim_ReleaseMon_Release,
|
|
|
|
[RELEASE_ANIM_CAME_BACK] = sAffineAnim_ReleaseMon_CameBack
|
2018-12-12 23:19:50 +01:00
|
|
|
};
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
#include "data/wallpapers.h"
|
2018-12-12 23:19:50 +01:00
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const u16 sUnusedColor = RGB(26, 29, 8);
|
2018-12-12 23:19:50 +01:00
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static const struct SpriteSheet sSpriteSheet_Arrow = {sArrow_Gfx, 0x80, GFXTAG_ARROW};
|
2018-12-12 23:19:50 +01:00
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static const struct OamData sOamData_BoxTitle =
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(32x16),
|
|
|
|
.size = SPRITE_SIZE(32x16),
|
2018-12-15 23:58:47 +01:00
|
|
|
.priority = 2
|
|
|
|
};
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static const union AnimCmd sAnim_BoxTitle_Left[] =
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static const union AnimCmd sAnim_BoxTitle_Right[] =
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(8, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static const union AnimCmd *const sAnims_BoxTitle[] =
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
sAnim_BoxTitle_Left,
|
|
|
|
sAnim_BoxTitle_Right
|
2018-12-15 23:58:47 +01:00
|
|
|
};
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_BoxTitle =
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
.tileTag = GFXTAG_BOX_TITLE,
|
|
|
|
.paletteTag = PALTAG_BOX_TITLE,
|
|
|
|
.oam = &sOamData_BoxTitle,
|
|
|
|
.anims = sAnims_BoxTitle,
|
2021-04-18 05:55:24 +02:00
|
|
|
.images = NULL,
|
2021-04-15 20:06:25 +02:00
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
2018-12-15 23:58:47 +01:00
|
|
|
};
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static const struct OamData sOamData_Arrow =
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(8x16),
|
|
|
|
.size = SPRITE_SIZE(8x16),
|
2018-12-15 23:58:47 +01:00
|
|
|
.priority = 2
|
|
|
|
};
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static const union AnimCmd sAnim_Arrow_Left[] =
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static const union AnimCmd sAnim_Arrow_Right[] =
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(2, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static const union AnimCmd *const sAnims_Arrow[] =
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
sAnim_Arrow_Left,
|
|
|
|
sAnim_Arrow_Right
|
2018-12-15 23:58:47 +01:00
|
|
|
};
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_Arrow =
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
.tileTag = GFXTAG_ARROW,
|
2021-04-18 05:55:24 +02:00
|
|
|
.paletteTag = PALTAG_MISC_2,
|
2021-04-15 20:06:25 +02:00
|
|
|
.oam = &sOamData_Arrow,
|
|
|
|
.anims = sAnims_Arrow,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCB_Arrow
|
2018-12-15 23:58:47 +01:00
|
|
|
};
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static const u16 sHandCursor_Pal[] = INCBIN_U16("graphics/pokemon_storage/hand_cursor.gbapal");
|
|
|
|
static const u8 sHandCursor_Gfx[] = INCBIN_U8("graphics/pokemon_storage/hand_cursor.4bpp");
|
|
|
|
static const u8 sHandCursorShadow_Gfx[] = INCBIN_U8("graphics/pokemon_storage/hand_cursor_shadow.4bpp");
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: Misc utility
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2019-10-07 04:58:25 +02:00
|
|
|
void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero2, s32 bytesToBuffer)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
2019-10-11 00:46:42 +02:00
|
|
|
s32 i, tileBytesToBuffer, remainingBytes;
|
2019-01-26 19:20:14 +01:00
|
|
|
u16 windowId;
|
|
|
|
u8 txtColor[3];
|
|
|
|
u8 *tileData1, *tileData2;
|
|
|
|
struct WindowTemplate winTemplate = {0};
|
|
|
|
|
|
|
|
winTemplate.width = 24;
|
|
|
|
winTemplate.height = 2;
|
|
|
|
windowId = AddWindow(&winTemplate);
|
2019-10-04 01:39:37 +02:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(zero2));
|
2019-01-26 19:20:14 +01:00
|
|
|
tileData1 = (u8*) GetWindowAttribute(windowId, WINDOW_TILE_DATA);
|
|
|
|
tileData2 = (winTemplate.width * 32) + tileData1;
|
|
|
|
|
2019-10-04 01:39:37 +02:00
|
|
|
if (!zero1)
|
|
|
|
txtColor[0] = TEXT_COLOR_TRANSPARENT;
|
2019-01-26 19:20:14 +01:00
|
|
|
else
|
2019-10-04 01:39:37 +02:00
|
|
|
txtColor[0] = zero2;
|
2019-10-05 16:41:37 +02:00
|
|
|
txtColor[1] = TEXT_DYNAMIC_COLOR_6;
|
|
|
|
txtColor[2] = TEXT_DYNAMIC_COLOR_5;
|
2019-01-26 19:20:14 +01:00
|
|
|
AddTextPrinterParameterized4(windowId, 1, 0, 1, 0, 0, txtColor, -1, string);
|
|
|
|
|
2019-10-07 04:58:25 +02:00
|
|
|
tileBytesToBuffer = bytesToBuffer;
|
|
|
|
if (tileBytesToBuffer > 6u)
|
|
|
|
tileBytesToBuffer = 6;
|
2019-10-11 00:46:42 +02:00
|
|
|
remainingBytes = bytesToBuffer - 6;
|
2019-10-07 04:58:25 +02:00
|
|
|
if (tileBytesToBuffer > 0)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
2019-10-07 04:58:25 +02:00
|
|
|
for (i = tileBytesToBuffer; i != 0; i--)
|
2019-01-26 19:20:14 +01:00
|
|
|
{
|
|
|
|
CpuCopy16(tileData1, dst, 0x80);
|
|
|
|
CpuCopy16(tileData2, dst + 0x80, 0x80);
|
|
|
|
tileData1 += 0x80;
|
|
|
|
tileData2 += 0x80;
|
|
|
|
dst += 0x100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-11 00:46:42 +02:00
|
|
|
// Never used. bytesToBuffer is always passed <= 6, so remainingBytes is always <= 0 here
|
|
|
|
if (remainingBytes > 0)
|
|
|
|
CpuFill16((zero2 << 4) | zero2, dst, (u32)(remainingBytes) * 0x100);
|
2019-01-26 19:20:14 +01:00
|
|
|
|
|
|
|
RemoveWindow(windowId);
|
|
|
|
}
|
|
|
|
|
2019-01-26 20:56:06 +01:00
|
|
|
// Unused
|
2021-04-17 23:28:18 +02:00
|
|
|
static void UnusedDrawTextWindow(const u8 *string, void *dst, u16 offset, u8 bgColor, u8 fgColor, u8 shadowColor)
|
2019-01-26 20:56:06 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
u32 tileSize;
|
2019-01-26 20:56:06 +01:00
|
|
|
u8 windowId;
|
|
|
|
u8 txtColor[3];
|
|
|
|
u8 *tileData1, *tileData2;
|
|
|
|
struct WindowTemplate winTemplate = {0};
|
|
|
|
|
|
|
|
winTemplate.width = StringLength_Multibyte(string);
|
|
|
|
winTemplate.height = 2;
|
2021-04-17 23:28:18 +02:00
|
|
|
tileSize = winTemplate.width * 32;
|
2019-01-26 20:56:06 +01:00
|
|
|
windowId = AddWindow(&winTemplate);
|
2021-04-17 23:28:18 +02:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(bgColor));
|
2019-01-26 20:56:06 +01:00
|
|
|
tileData1 = (u8*) GetWindowAttribute(windowId, WINDOW_TILE_DATA);
|
|
|
|
tileData2 = (winTemplate.width * 32) + tileData1;
|
2021-04-17 23:28:18 +02:00
|
|
|
txtColor[0] = bgColor;
|
|
|
|
txtColor[1] = fgColor;
|
|
|
|
txtColor[2] = shadowColor;
|
2019-01-26 20:56:06 +01:00
|
|
|
AddTextPrinterParameterized4(windowId, 1, 0, 2, 0, 0, txtColor, -1, string);
|
2021-04-17 23:28:18 +02:00
|
|
|
CpuCopy16(tileData1, dst, tileSize);
|
|
|
|
CpuCopy16(tileData2, dst + offset, tileSize);
|
2019-01-26 20:56:06 +01:00
|
|
|
RemoveWindow(windowId);
|
2019-01-26 19:20:14 +01:00
|
|
|
}
|
|
|
|
|
2017-11-11 14:45:08 +01:00
|
|
|
u8 CountMonsInBox(u8 boxId)
|
|
|
|
{
|
|
|
|
u16 i, count;
|
2017-10-03 03:51:22 +02:00
|
|
|
|
2017-11-11 14:45:08 +01:00
|
|
|
for (i = 0, count = 0; i < IN_BOX_COUNT; i++)
|
|
|
|
{
|
2018-12-15 23:58:47 +01:00
|
|
|
if (GetBoxMonDataAt(boxId, i, MON_DATA_SPECIES) != SPECIES_NONE)
|
2017-11-11 14:45:08 +01:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
s16 GetFirstFreeBoxSpot(u8 boxId)
|
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
for (i = 0; i < IN_BOX_COUNT; i++)
|
|
|
|
{
|
2018-12-15 23:58:47 +01:00
|
|
|
if (GetBoxMonDataAt(boxId, i, MON_DATA_SPECIES) == SPECIES_NONE)
|
2017-11-11 14:45:08 +01:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1; // all spots are taken
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 CountPartyNonEggMons(void)
|
|
|
|
{
|
|
|
|
u16 i, count;
|
|
|
|
|
|
|
|
for (i = 0, count = 0; i < PARTY_SIZE; i++)
|
|
|
|
{
|
|
|
|
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE
|
|
|
|
&& !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
|
|
|
|
{
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 CountPartyAliveNonEggMonsExcept(u8 slotToIgnore)
|
|
|
|
{
|
|
|
|
u16 i, count;
|
|
|
|
|
|
|
|
for (i = 0, count = 0; i < PARTY_SIZE; i++)
|
|
|
|
{
|
|
|
|
if (i != slotToIgnore
|
|
|
|
&& GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE
|
|
|
|
&& !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)
|
|
|
|
&& GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0)
|
|
|
|
{
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
u16 CountPartyAliveNonEggMons_IgnoreVar0x8004Slot(void)
|
|
|
|
{
|
|
|
|
return CountPartyAliveNonEggMonsExcept(gSpecialVar_0x8004);
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 CountPartyMons(void)
|
|
|
|
{
|
|
|
|
u16 i, count;
|
|
|
|
|
|
|
|
for (i = 0, count = 0; i < PARTY_SIZE; i++)
|
|
|
|
{
|
|
|
|
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE)
|
|
|
|
{
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2018-12-10 23:42:44 +01:00
|
|
|
u8 *StringCopyAndFillWithSpaces(u8 *dst, const u8 *src, u16 n)
|
2017-11-11 14:45:08 +01:00
|
|
|
{
|
|
|
|
u8 *str;
|
|
|
|
|
|
|
|
for (str = StringCopy(dst, src); str < dst + n; str++)
|
|
|
|
*str = CHAR_SPACE;
|
|
|
|
|
|
|
|
*str = EOS;
|
|
|
|
return str;
|
|
|
|
}
|
2017-10-03 03:51:22 +02:00
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
// Unused
|
|
|
|
static void UnusedWriteRectCpu(u16 *dest, u16 dest_left, u16 dest_top, const u16 *src, u16 src_left, u16 src_top, u16 dest_width, u16 dest_height, u16 src_width)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
dest_width *= 2;
|
|
|
|
dest += dest_top * 0x20 + dest_left;
|
|
|
|
src += src_top * src_width + src_left;
|
|
|
|
for (i = 0; i < dest_height; i++)
|
|
|
|
{
|
|
|
|
CpuCopy16(src, dest, dest_width);
|
|
|
|
dest += 0x20;
|
|
|
|
src += src_width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
// Unused
|
|
|
|
static void UnusedWriteRectDma(u16 *dest, u16 dest_left, u16 dest_top, u16 width, u16 height)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
dest += dest_top * 0x20 + dest_left;
|
|
|
|
width *= 2;
|
|
|
|
for (i = 0; i < height; dest += 0x20, i++)
|
|
|
|
Dma3FillLarge16_(0, dest, width);
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: Main menu
|
|
|
|
//
|
|
|
|
// The below functions generally handle the PC main menu where the main
|
|
|
|
// options can be selected (Withdraw, Deposit, etc.), as well as exiting
|
|
|
|
// Pokémon Storage back to this menu.
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
enum {
|
|
|
|
STATE_LOAD,
|
|
|
|
STATE_FADE_IN,
|
|
|
|
STATE_HANDLE_INPUT,
|
|
|
|
STATE_ERROR_MSG,
|
|
|
|
STATE_ENTER_PC,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define tState data[0]
|
|
|
|
#define tSelectedOption data[1]
|
|
|
|
#define tInput data[2]
|
|
|
|
#define tNextOption data[3]
|
|
|
|
#define tWindowId data[15]
|
|
|
|
|
|
|
|
static void Task_PCMainMenu(u8 taskId)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2018-12-10 21:36:52 +01:00
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
switch (task->tState)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
case STATE_LOAD:
|
|
|
|
CreateMainMenu(task->tSelectedOption, &task->tWindowId);
|
2020-02-07 18:48:47 +01:00
|
|
|
LoadMessageBoxAndBorderGfx();
|
2019-02-22 07:40:11 +01:00
|
|
|
DrawDialogueFrame(0, 0);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(0, PIXEL_FILL(1));
|
2021-04-15 23:31:50 +02:00
|
|
|
AddTextPrinterParameterized2(0, 1, sMainMenuTexts[task->tSelectedOption].desc, TEXT_SPEED_FF, NULL, 2, 1, 3);
|
2018-08-12 16:40:31 +02:00
|
|
|
CopyWindowToVram(0, 3);
|
2021-04-15 23:31:50 +02:00
|
|
|
CopyWindowToVram(task->tWindowId, 3);
|
|
|
|
task->tState++;
|
2018-08-12 16:40:31 +02:00
|
|
|
break;
|
2021-04-15 23:31:50 +02:00
|
|
|
case STATE_FADE_IN:
|
2018-08-12 16:40:31 +02:00
|
|
|
if (IsWeatherNotFadingIn())
|
2021-04-15 23:31:50 +02:00
|
|
|
task->tState++;
|
2018-08-12 16:40:31 +02:00
|
|
|
break;
|
2021-04-15 23:31:50 +02:00
|
|
|
case STATE_HANDLE_INPUT:
|
|
|
|
task->tInput = Menu_ProcessInput();
|
|
|
|
switch(task->tInput)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2019-02-02 11:04:38 +01:00
|
|
|
case MENU_NOTHING_CHOSEN:
|
2021-04-15 23:31:50 +02:00
|
|
|
task->tNextOption = task->tSelectedOption;
|
|
|
|
if (JOY_NEW(DPAD_UP) && --task->tNextOption < 0)
|
|
|
|
task->tNextOption = OPTIONS_COUNT - 1;
|
|
|
|
if (JOY_NEW(DPAD_DOWN) && ++task->tNextOption > OPTIONS_COUNT - 1)
|
|
|
|
task->tNextOption = 0;
|
2018-08-12 16:40:31 +02:00
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
if (task->tSelectedOption != task->tNextOption)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
task->tSelectedOption = task->tNextOption;
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(0, PIXEL_FILL(1));
|
2021-04-15 23:31:50 +02:00
|
|
|
AddTextPrinterParameterized2(0, 1, sMainMenuTexts[task->tSelectedOption].desc, 0, NULL, 2, 1, 3);
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
break;
|
2019-02-02 11:04:38 +01:00
|
|
|
case MENU_B_PRESSED:
|
2021-04-15 23:31:50 +02:00
|
|
|
case OPTION_EXIT:
|
|
|
|
ClearStdWindowAndFrame(task->tWindowId, TRUE);
|
2018-08-12 16:40:31 +02:00
|
|
|
ScriptContext2_Disable();
|
|
|
|
EnableBothScriptContexts();
|
2021-04-15 23:31:50 +02:00
|
|
|
RemoveWindow(task->tWindowId);
|
2018-08-12 16:40:31 +02:00
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
default:
|
2021-04-15 23:31:50 +02:00
|
|
|
if (task->tInput == OPTION_WITHDRAW && CountPartyMons() == PARTY_SIZE)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
// Can't withdraw
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(0, PIXEL_FILL(1));
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized2(0, 1, gText_PartyFull, 0, NULL, 2, 1, 3);
|
2021-04-15 23:31:50 +02:00
|
|
|
task->tState = STATE_ERROR_MSG;
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
2021-04-15 23:31:50 +02:00
|
|
|
else if (task->tInput == OPTION_DEPOSIT && CountPartyMons() == 1)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
// Can't deposit
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(0, PIXEL_FILL(1));
|
2018-09-08 23:38:30 +02:00
|
|
|
AddTextPrinterParameterized2(0, 1, gText_JustOnePkmn, 0, NULL, 2, 1, 3);
|
2021-04-15 23:31:50 +02:00
|
|
|
task->tState = STATE_ERROR_MSG;
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
// Enter PC
|
2019-12-15 17:42:50 +01:00
|
|
|
FadeScreen(FADE_TO_BLACK, 0);
|
2021-04-15 23:31:50 +02:00
|
|
|
task->tState = STATE_ENTER_PC;
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2021-04-15 23:31:50 +02:00
|
|
|
case STATE_ERROR_MSG:
|
|
|
|
// Printed "can't do PC option message"
|
|
|
|
// Wait for new input after message
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON))
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(0, PIXEL_FILL(1));
|
2021-04-15 23:31:50 +02:00
|
|
|
AddTextPrinterParameterized2(0, 1, sMainMenuTexts[task->tSelectedOption].desc, 0, NULL, 2, 1, 3);
|
|
|
|
task->tState = STATE_HANDLE_INPUT;
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(DPAD_UP))
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
if (--task->tSelectedOption < 0)
|
|
|
|
task->tSelectedOption = OPTIONS_COUNT - 1;
|
2018-12-16 21:10:01 +01:00
|
|
|
Menu_MoveCursor(-1);
|
2021-04-15 23:31:50 +02:00
|
|
|
task->tSelectedOption = Menu_GetCursorPos();
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(0, PIXEL_FILL(1));
|
2021-04-15 23:31:50 +02:00
|
|
|
AddTextPrinterParameterized2(0, 1, sMainMenuTexts[task->tSelectedOption].desc, 0, NULL, 2, 1, 3);
|
|
|
|
task->tState = STATE_HANDLE_INPUT;
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(DPAD_DOWN))
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
if (++task->tSelectedOption >= OPTIONS_COUNT - 1)
|
|
|
|
task->tSelectedOption = 0;
|
2018-12-16 21:10:01 +01:00
|
|
|
Menu_MoveCursor(1);
|
2021-04-15 23:31:50 +02:00
|
|
|
task->tSelectedOption = Menu_GetCursorPos();
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(0, PIXEL_FILL(1));
|
2021-04-15 23:31:50 +02:00
|
|
|
AddTextPrinterParameterized2(0, 1, sMainMenuTexts[task->tSelectedOption].desc, 0, NULL, 2, 1, 3);
|
|
|
|
task->tState = STATE_HANDLE_INPUT;
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
break;
|
2021-04-15 23:31:50 +02:00
|
|
|
case STATE_ENTER_PC:
|
2018-08-12 16:40:31 +02:00
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2018-12-27 23:30:47 +01:00
|
|
|
CleanupOverworldWindowsAndTilemaps();
|
2021-04-18 05:40:27 +02:00
|
|
|
EnterPokeStorage(task->tInput);
|
2021-04-15 23:31:50 +02:00
|
|
|
RemoveWindow(task->tWindowId);
|
2018-08-12 16:40:31 +02:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-10 21:36:52 +01:00
|
|
|
void ShowPokemonStorageSystemPC(void)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
u8 taskId = CreateTask(Task_PCMainMenu, 80);
|
|
|
|
gTasks[taskId].tState = 0;
|
|
|
|
gTasks[taskId].tSelectedOption = 0;
|
2018-08-12 16:40:31 +02:00
|
|
|
ScriptContext2_Enable();
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void FieldTask_ReturnToPcMenu(void)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
|
|
|
u8 taskId;
|
|
|
|
MainCallback vblankCb = gMain.vblankCallback;
|
|
|
|
|
|
|
|
SetVBlankCallback(NULL);
|
2021-04-15 23:31:50 +02:00
|
|
|
taskId = CreateTask(Task_PCMainMenu, 80);
|
|
|
|
gTasks[taskId].tState = 0;
|
|
|
|
gTasks[taskId].tSelectedOption = sPreviousBoxOption;
|
|
|
|
Task_PCMainMenu(taskId);
|
2018-08-12 16:40:31 +02:00
|
|
|
SetVBlankCallback(vblankCb);
|
2019-12-17 09:24:44 +01:00
|
|
|
FadeInFromBlack();
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
#undef tState
|
|
|
|
#undef tSelectedOption
|
|
|
|
#undef tInput
|
|
|
|
#undef tNextOption
|
|
|
|
#undef tWindowId
|
|
|
|
|
|
|
|
static void CreateMainMenu(u8 whichMenu, s16 *windowIdPtr)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
|
|
|
s16 windowId;
|
2021-04-15 23:31:50 +02:00
|
|
|
struct WindowTemplate template = sWindowTemplate_MainMenu;
|
|
|
|
template.width = GetMaxWidthInMenuTable((void *)sMainMenuTexts, OPTIONS_COUNT);
|
|
|
|
windowId = AddWindow(&template);
|
2018-08-12 16:40:31 +02:00
|
|
|
|
2019-02-22 07:40:11 +01:00
|
|
|
DrawStdWindowFrame(windowId, FALSE);
|
2021-04-15 23:31:50 +02:00
|
|
|
PrintMenuTable(windowId, OPTIONS_COUNT, (void *)sMainMenuTexts);
|
|
|
|
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, OPTIONS_COUNT, whichMenu);
|
2018-08-12 16:40:31 +02:00
|
|
|
*windowIdPtr = windowId;
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void CB2_ExitPokeStorage(void)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2018-12-12 23:19:50 +01:00
|
|
|
sPreviousBoxOption = GetCurrentBoxOption();
|
2021-04-18 05:40:27 +02:00
|
|
|
gFieldCallback = FieldTask_ReturnToPcMenu;
|
2018-08-12 16:40:31 +02:00
|
|
|
SetMainCallback2(CB2_ReturnToField);
|
|
|
|
}
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
// Unused
|
2018-12-19 22:47:27 +01:00
|
|
|
static s16 StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx, u8 mode)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
|
|
|
s16 i;
|
|
|
|
s16 direction;
|
|
|
|
if (mode == 0 || mode == 1)
|
|
|
|
{
|
|
|
|
direction = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
direction = -1;
|
|
|
|
}
|
|
|
|
if (mode == 1 || mode == 3)
|
|
|
|
{
|
|
|
|
for (i = startIdx + direction; i >= 0 && i <= stopIdx; i += direction)
|
|
|
|
{
|
|
|
|
if (GetBoxMonData(box + i, MON_DATA_SPECIES) != 0)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = startIdx + direction; i >= 0 && i <= stopIdx; i += direction)
|
|
|
|
{
|
|
|
|
if (GetBoxMonData(box + i, MON_DATA_SPECIES) != 0 && !GetBoxMonData(box + i, MON_DATA_IS_EGG))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResetPokemonStorageSystem(void)
|
|
|
|
{
|
2018-12-15 23:58:47 +01:00
|
|
|
u16 boxId, boxPosition;
|
2018-08-12 16:40:31 +02:00
|
|
|
|
|
|
|
SetCurrentBox(0);
|
|
|
|
for (boxId = 0; boxId < TOTAL_BOXES_COUNT; boxId++)
|
|
|
|
{
|
2018-12-15 23:58:47 +01:00
|
|
|
for (boxPosition = 0; boxPosition < IN_BOX_COUNT; boxPosition++)
|
|
|
|
ZeroBoxMonAt(boxId, boxPosition);
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
for (boxId = 0; boxId < TOTAL_BOXES_COUNT; boxId++)
|
|
|
|
{
|
|
|
|
u8 *dest = StringCopy(GetBoxNamePtr(boxId), gText_Box);
|
|
|
|
ConvertIntToDecimalStringN(dest, boxId + 1, STR_CONV_MODE_LEFT_ALIGN, 2);
|
|
|
|
}
|
2021-04-15 20:06:25 +02:00
|
|
|
|
2018-08-12 16:40:31 +02:00
|
|
|
for (boxId = 0; boxId < TOTAL_BOXES_COUNT; boxId++)
|
2021-04-15 20:06:25 +02:00
|
|
|
SetBoxWallpaper(boxId, boxId % (MAX_DEFAULT_WALLPAPER + 1));
|
|
|
|
|
2018-08-12 16:40:31 +02:00
|
|
|
ResetWaldaWallpaper();
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: Choose Box menu
|
|
|
|
//
|
|
|
|
// The below functions handle the popup menu that allows the player to cycle
|
|
|
|
// through the boxes and select one. Used when storing Pokémon in Deposit mode
|
|
|
|
// and for the Jump feature.
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static void LoadChooseBoxMenuGfx(struct ChooseBoxMenu *menu, u16 tileTag, u16 palTag, u8 subpriority, bool32 loadPal)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
|
|
|
struct SpritePalette palette =
|
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
sChooseBoxMenu_Pal, palTag
|
2018-08-12 16:40:31 +02:00
|
|
|
};
|
|
|
|
struct SpriteSheet sheets[] =
|
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
{sChooseBoxMenuCenter_Gfx, 0x800, tileTag},
|
|
|
|
{sChooseBoxMenuSides_Gfx, 0x180, tileTag + 1},
|
2018-08-12 16:40:31 +02:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
if (loadPal) // Always false
|
2018-08-12 16:40:31 +02:00
|
|
|
LoadSpritePalette(&palette);
|
|
|
|
|
|
|
|
LoadSpriteSheets(sheets);
|
2021-04-15 23:31:50 +02:00
|
|
|
sChooseBoxMenu = menu;
|
|
|
|
menu->tileTag = tileTag;
|
|
|
|
menu->paletteTag = palTag;
|
|
|
|
menu->subpriority = subpriority;
|
|
|
|
menu->loadedPalette = loadPal;
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static void FreeChooseBoxMenu(void)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sChooseBoxMenu->loadedPalette)
|
|
|
|
FreeSpritePaletteByTag(sChooseBoxMenu->paletteTag);
|
|
|
|
FreeSpriteTilesByTag(sChooseBoxMenu->tileTag);
|
|
|
|
FreeSpriteTilesByTag(sChooseBoxMenu->tileTag + 1);
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static void CreateChooseBoxMenuSprites(u8 curBox)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
ChooseBoxMenu_CreateSprites(curBox);
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static void DestroyChooseBoxMenuSprites(void)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
ChooseBoxMenu_DestroySprites();
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
// For the popout window when choosing a box to deposit in or jump to
|
|
|
|
static u8 HandleChooseBoxMenuInput(void)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(B_BUTTON))
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-15 23:31:50 +02:00
|
|
|
return BOXID_CANCELED;
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-15 23:31:50 +02:00
|
|
|
return sChooseBoxMenu->curBox;
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(DPAD_LEFT))
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-15 23:31:50 +02:00
|
|
|
ChooseBoxMenu_MoveLeft();
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(DPAD_RIGHT))
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-15 23:31:50 +02:00
|
|
|
ChooseBoxMenu_MoveRight();
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
2021-04-15 23:31:50 +02:00
|
|
|
return BOXID_NONE_CHOSEN;
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static void ChooseBoxMenu_CreateSprites(u8 curBox)
|
2017-11-11 14:45:08 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
2018-08-12 16:40:31 +02:00
|
|
|
u8 spriteId;
|
|
|
|
struct SpriteTemplate template;
|
|
|
|
struct OamData oamData = {};
|
2019-03-11 08:12:15 +01:00
|
|
|
oamData.size = SPRITE_SIZE(64x64);
|
2018-08-12 16:40:31 +02:00
|
|
|
oamData.paletteNum = 1;
|
|
|
|
template = (struct SpriteTemplate){
|
|
|
|
0, 0, &oamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
sChooseBoxMenu->curBox = curBox;
|
|
|
|
template.tileTag = sChooseBoxMenu->tileTag;
|
|
|
|
template.paletteTag = sChooseBoxMenu->paletteTag;
|
2018-08-12 16:40:31 +02:00
|
|
|
|
2018-12-22 23:00:22 +01:00
|
|
|
spriteId = CreateSprite(&template, 160, 96, 0);
|
2021-04-15 23:31:50 +02:00
|
|
|
sChooseBoxMenu->menuSprite = &gSprites[spriteId];
|
2018-08-12 16:40:31 +02:00
|
|
|
|
2019-03-11 08:12:15 +01:00
|
|
|
oamData.shape = SPRITE_SHAPE(8x32);
|
|
|
|
oamData.size = SPRITE_SIZE(8x32);
|
2021-04-15 23:31:50 +02:00
|
|
|
template.tileTag = sChooseBoxMenu->tileTag + 1;
|
|
|
|
template.anims = sAnims_ChooseBoxMenu;
|
|
|
|
for (i = 0; i < ARRAY_COUNT(sChooseBoxMenu->menuSideSprites); i++)
|
|
|
|
{
|
|
|
|
u16 anim;
|
|
|
|
spriteId = CreateSprite(&template, 124, 80, sChooseBoxMenu->subpriority);
|
|
|
|
sChooseBoxMenu->menuSideSprites[i] = &gSprites[spriteId];
|
|
|
|
anim = 0;
|
2018-08-12 16:40:31 +02:00
|
|
|
if (i & 2)
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sChooseBoxMenu->menuSideSprites[i]->x = 196;
|
2021-04-15 23:31:50 +02:00
|
|
|
anim = 2;
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
if (i & 1)
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sChooseBoxMenu->menuSideSprites[i]->y = 112;
|
2021-04-15 23:31:50 +02:00
|
|
|
sChooseBoxMenu->menuSideSprites[i]->oam.size = 0;
|
|
|
|
anim++;
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
2021-04-15 23:31:50 +02:00
|
|
|
StartSpriteAnim(sChooseBoxMenu->menuSideSprites[i], anim);
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
2021-04-15 23:31:50 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sChooseBoxMenu->arrowSprites); i++)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
sChooseBoxMenu->arrowSprites[i] = CreateChooseBoxArrows(72 * i + 124, 88, i, 0, sChooseBoxMenu->subpriority);
|
|
|
|
if (sChooseBoxMenu->arrowSprites[i])
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
sChooseBoxMenu->arrowSprites[i]->data[0] = (i == 0 ? -1 : 1);
|
|
|
|
sChooseBoxMenu->arrowSprites[i]->callback = SpriteCB_ChooseBoxArrow;
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
}
|
2021-04-15 23:31:50 +02:00
|
|
|
ChooseBoxMenu_PrintInfo();
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static void ChooseBoxMenu_DestroySprites(void)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
|
|
|
u16 i;
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sChooseBoxMenu->menuSprite)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
DestroySprite(sChooseBoxMenu->menuSprite);
|
|
|
|
sChooseBoxMenu->menuSprite = NULL;
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
2021-04-15 23:31:50 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sChooseBoxMenu->menuSideSprites); i++)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sChooseBoxMenu->menuSideSprites[i])
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
DestroySprite(sChooseBoxMenu->menuSideSprites[i]);
|
|
|
|
sChooseBoxMenu->menuSideSprites[i] = NULL;
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
}
|
2021-04-15 23:31:50 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sChooseBoxMenu->arrowSprites); i++)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sChooseBoxMenu->arrowSprites[i])
|
|
|
|
DestroySprite(sChooseBoxMenu->arrowSprites[i]);
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
}
|
2017-10-03 03:51:22 +02:00
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static void ChooseBoxMenu_MoveRight(void)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
if (++sChooseBoxMenu->curBox >= TOTAL_BOXES_COUNT)
|
|
|
|
sChooseBoxMenu->curBox = 0;
|
|
|
|
ChooseBoxMenu_PrintInfo();
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static void ChooseBoxMenu_MoveLeft(void)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
sChooseBoxMenu->curBox = (sChooseBoxMenu->curBox == 0 ? TOTAL_BOXES_COUNT - 1 : sChooseBoxMenu->curBox - 1);
|
|
|
|
ChooseBoxMenu_PrintInfo();
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
2017-10-03 03:51:22 +02:00
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static void ChooseBoxMenu_PrintInfo(void)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2019-12-10 19:48:20 +01:00
|
|
|
u8 numBoxMonsText[16];
|
2021-04-15 23:31:50 +02:00
|
|
|
struct WindowTemplate template;
|
2018-08-12 16:40:31 +02:00
|
|
|
u8 windowId;
|
2021-04-15 23:31:50 +02:00
|
|
|
u8 *boxName = GetBoxNamePtr(sChooseBoxMenu->curBox);
|
|
|
|
u8 numInBox = CountMonsInBox(sChooseBoxMenu->curBox);
|
2018-08-12 16:40:31 +02:00
|
|
|
u32 winTileData;
|
|
|
|
s32 center;
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
memset(&template, 0, sizeof(template));
|
|
|
|
template.width = 8;
|
|
|
|
template.height = 4;
|
2018-08-12 16:40:31 +02:00
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
windowId = AddWindow(&template);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(4));
|
2018-08-12 16:40:31 +02:00
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
// Print box name
|
2018-12-22 23:00:22 +01:00
|
|
|
center = GetStringCenterAlignXOffset(1, boxName, 64);
|
2021-04-15 23:31:50 +02:00
|
|
|
AddTextPrinterParameterized3(windowId, 1, center, 1, sChooseBoxMenu_TextColors, TEXT_SPEED_FF, boxName);
|
2018-08-12 16:40:31 +02:00
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
// Print #/30 for number of Pokémon in the box
|
|
|
|
ConvertIntToDecimalStringN(numBoxMonsText, numInBox, STR_CONV_MODE_RIGHT_ALIGN, 2);
|
2019-12-10 19:48:20 +01:00
|
|
|
StringAppend(numBoxMonsText, sText_OutOf30);
|
|
|
|
center = GetStringCenterAlignXOffset(1, numBoxMonsText, 64);
|
2021-04-15 23:31:50 +02:00
|
|
|
AddTextPrinterParameterized3(windowId, 1, center, 17, sChooseBoxMenu_TextColors, TEXT_SPEED_FF, numBoxMonsText);
|
2018-08-12 16:40:31 +02:00
|
|
|
|
|
|
|
winTileData = GetWindowAttribute(windowId, WINDOW_TILE_DATA);
|
2021-04-15 23:31:50 +02:00
|
|
|
CpuCopy32((void *)winTileData, (void *)OBJ_VRAM0 + 0x100 + (GetSpriteTileStartByTag(sChooseBoxMenu->tileTag) * 32), 0x400);
|
2018-08-12 16:40:31 +02:00
|
|
|
|
|
|
|
RemoveWindow(windowId);
|
|
|
|
}
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
static void SpriteCB_ChooseBoxArrow(struct Sprite *sprite)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
|
|
|
if (++sprite->data[1] > 3)
|
2017-11-11 14:45:08 +01:00
|
|
|
{
|
2018-08-12 16:40:31 +02:00
|
|
|
sprite->data[1] = 0;
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 += sprite->data[0];
|
2018-08-12 16:40:31 +02:00
|
|
|
if (++sprite->data[2] > 5)
|
2017-11-11 14:45:08 +01:00
|
|
|
{
|
2018-08-12 16:40:31 +02:00
|
|
|
sprite->data[2] = 0;
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 = 0;
|
2017-11-11 14:45:08 +01:00
|
|
|
}
|
|
|
|
}
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: Main tasks
|
|
|
|
//
|
|
|
|
// Below are the main task callbacks that handle the primary actions the
|
|
|
|
// player can take in the PC. The most 'important' of these tasks is the
|
|
|
|
// primary one, Task_PokeStorageMain. Also included are some basic
|
|
|
|
// initialization functions.
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void VBlankCB_PokeStorage(void)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
|
|
|
LoadOam();
|
|
|
|
ProcessSpriteCopyRequests();
|
2021-04-18 05:31:29 +02:00
|
|
|
UnkUtil_Run();
|
2018-08-12 16:40:31 +02:00
|
|
|
TransferPlttBuffer();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetGpuReg(REG_OFFSET_BG2HOFS, sStorage->bg2_X);
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void CB2_PokeStorage(void)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
|
|
|
RunTasks();
|
2020-06-20 01:58:56 +02:00
|
|
|
DoScheduledBgTilemapCopiesToVram();
|
2018-12-10 23:42:44 +01:00
|
|
|
ScrollBackground();
|
2021-04-17 06:49:51 +02:00
|
|
|
UpdateCloseBoxButtonFlash();
|
2018-08-12 16:40:31 +02:00
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
|
|
|
}
|
2018-12-09 16:44:01 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void EnterPokeStorage(u8 boxOption)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
ResetTasks();
|
2018-12-12 23:19:50 +01:00
|
|
|
sCurrentBoxOption = boxOption;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage = Alloc(sizeof(*sStorage));
|
|
|
|
if (sStorage == NULL)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetMainCallback2(CB2_ExitPokeStorage);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxOption = boxOption;
|
|
|
|
sStorage->isReopening = FALSE;
|
2020-03-09 02:27:29 +01:00
|
|
|
sMovingItemId = ITEM_NONE;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 0;
|
|
|
|
sStorage->taskId = CreateTask(Task_InitPokeStorage, 3);
|
2019-09-17 07:49:07 +02:00
|
|
|
sLastUsedBox = StorageGetCurrentBox();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetMainCallback2(CB2_PokeStorage);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void CB2_ReturnToPokeStorage(void)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
ResetTasks();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage = Alloc(sizeof(*sStorage));
|
|
|
|
if (sStorage == NULL)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetMainCallback2(CB2_ExitPokeStorage);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxOption = sCurrentBoxOption;
|
|
|
|
sStorage->isReopening = TRUE;
|
|
|
|
sStorage->state = 0;
|
|
|
|
sStorage->taskId = CreateTask(Task_InitPokeStorage, 3);
|
|
|
|
SetMainCallback2(CB2_PokeStorage);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void ResetAllBgCoords(void)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
SetGpuReg(REG_OFFSET_BG0HOFS, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BG1HOFS, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BG1VOFS, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BG2HOFS, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BG2VOFS, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BG3HOFS, 0);
|
|
|
|
SetGpuReg(REG_OFFSET_BG3VOFS, 0);
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
static void ResetForPokeStorage(void)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
ResetPaletteFade();
|
|
|
|
ResetSpriteData();
|
|
|
|
FreeSpriteTileRanges();
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
ClearDma3Requests();
|
|
|
|
gReservedSpriteTileCount = 0x280;
|
2021-04-18 05:40:27 +02:00
|
|
|
UnkUtil_Init(&sStorage->unkUtil, sStorage->unkUtilData, ARRAY_COUNT(sStorage->unkUtilData));
|
2018-12-09 16:44:01 +01:00
|
|
|
gKeyRepeatStartDelay = 20;
|
2020-06-20 01:58:56 +02:00
|
|
|
ClearScheduledBgCopiesToVram();
|
2021-04-17 23:28:18 +02:00
|
|
|
TilemapUtil_Init(TILEMAPID_COUNT);
|
|
|
|
TilemapUtil_SetMap(TILEMAPID_PKMN_DATA, 1, sPkmnData_Tilemap, 8, 4);
|
|
|
|
TilemapUtil_SetPos(TILEMAPID_PKMN_DATA, 1, 0);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->closeBoxFlashing = FALSE;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
static void InitStartingPosData(void)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
ClearSavedCursorPos();
|
2021-04-18 05:40:27 +02:00
|
|
|
sInPartyMenu = (sStorage->boxOption == OPTION_DEPOSIT);
|
2021-04-15 23:31:50 +02:00
|
|
|
sDepositBoxId = 0;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
|
2020-03-08 03:05:22 +01:00
|
|
|
static void SetMonIconTransparency(void)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption == OPTION_MOVE_ITEMS)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(7, 11));
|
|
|
|
}
|
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_BG_ALL_ON | DISPCNT_OBJ_1D_MAP);
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void SetPokeStorageTask(TaskFunc newFunc)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
gTasks[sStorage->taskId].func = newFunc;
|
|
|
|
sStorage->state = 0;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_InitPokeStorage(u8 taskId)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
SetVBlankCallback(NULL);
|
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
2021-04-18 05:55:24 +02:00
|
|
|
ResetForPokeStorage();
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->isReopening)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sWhichToReshow)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
case SCREEN_CHANGE_NAME_BOX - 1:
|
|
|
|
// Return from naming box
|
|
|
|
LoadSavedMovingMon();
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-17 06:49:51 +02:00
|
|
|
case SCREEN_CHANGE_SUMMARY_SCREEN - 1:
|
|
|
|
// Return from summary screen
|
2021-04-18 01:28:31 +02:00
|
|
|
SetSelectionAfterSummaryScreen();
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-17 06:49:51 +02:00
|
|
|
case SCREEN_CHANGE_ITEM_FROM_BAG - 1:
|
|
|
|
// Return from bag menu
|
2018-12-10 23:42:44 +01:00
|
|
|
GiveChosenBagItem();
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
LoadPokeStorageMenuGfx();
|
2018-12-10 23:42:44 +01:00
|
|
|
LoadWaveformSpritePalette();
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-18 05:40:27 +02:00
|
|
|
if (!InitPokeStorageWindows())
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_ChangeScreen);
|
2018-12-09 16:44:01 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
PutWindowTilemap(0);
|
|
|
|
ClearWindowTilemap(1);
|
|
|
|
CpuFill32(0, (void *)VRAM, 0x200);
|
|
|
|
LoadUserWindowBorderGfx(1, 0xB, 0xE0);
|
|
|
|
break;
|
|
|
|
case 3:
|
2018-12-10 23:42:44 +01:00
|
|
|
ResetAllBgCoords();
|
2021-04-18 05:40:27 +02:00
|
|
|
if (!sStorage->isReopening)
|
2021-04-18 05:55:24 +02:00
|
|
|
InitStartingPosData();
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2021-04-16 05:27:05 +02:00
|
|
|
InitMonIconFields();
|
2021-04-18 05:40:27 +02:00
|
|
|
if (!sStorage->isReopening)
|
2021-04-18 05:55:24 +02:00
|
|
|
InitCursor();
|
2018-12-09 16:44:01 +01:00
|
|
|
else
|
2021-04-18 05:55:24 +02:00
|
|
|
InitCursorOnReopen();
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
2021-04-16 23:05:44 +02:00
|
|
|
if (!MultiMove_Init())
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_ChangeScreen);
|
2018-12-09 16:44:01 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-10 23:42:44 +01:00
|
|
|
SetScrollingBackground();
|
2021-04-18 05:55:24 +02:00
|
|
|
InitPokeStorageBg0();
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 6:
|
2021-04-18 05:55:24 +02:00
|
|
|
InitPalettesAndSprites();
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
case 7:
|
2021-04-17 23:28:18 +02:00
|
|
|
InitSupplementalTilemaps();
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
case 8:
|
2021-04-15 20:06:25 +02:00
|
|
|
CreateInitBoxTask(StorageGetCurrentBox());
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
case 9:
|
2021-04-15 20:06:25 +02:00
|
|
|
if (IsInitBoxActive())
|
2018-12-09 16:44:01 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->markMenu.baseTileTag = GFXTAG_MARKING_MENU;
|
|
|
|
sStorage->markMenu.basePaletteTag = PALTAG_MARKING_MENU;
|
|
|
|
InitMonMarkingsMenu(&sStorage->markMenu);
|
2021-02-28 23:22:26 +01:00
|
|
|
BufferMonMarkingsMenuTiles();
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
CreateItemIconSprites();
|
2021-04-18 05:55:24 +02:00
|
|
|
InitCursorItemIcon();
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 10:
|
2020-03-08 03:05:22 +01:00
|
|
|
SetMonIconTransparency();
|
2021-04-18 05:40:27 +02:00
|
|
|
if (!sStorage->isReopening)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
BlendPalettes(PALETTES_ALL, 16, RGB_BLACK);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_ShowPokeStorage);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
BlendPalettes(PALETTES_ALL, 16, RGB_BLACK);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_ReshowPokeStorage);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
SetVBlankCallback(VBlankCB_PokeStorage);
|
2018-12-09 16:44:01 +01:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_ShowPokeStorage(u8 taskId)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
PlaySE(SE_PC_LOGIN);
|
2020-06-29 17:41:09 +02:00
|
|
|
ComputerScreenOpenEffect(20, 0, 1);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-06-29 17:41:09 +02:00
|
|
|
if (!IsComputerScreenOpenEffectActive())
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_ReshowPokeStorage(u8 taskId)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-24 17:01:02 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, -1, 0x10, 0, RGB_BLACK);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!UpdatePaletteFade())
|
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
if (sWhichToReshow == SCREEN_CHANGE_ITEM_FROM_BAG - 1 && gSpecialVar_ItemId != ITEM_NONE)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_ITEM_IS_HELD);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (!IsDma3ManagerBusyWithBgCopy() && JOY_NEW(A_BUTTON | B_BUTTON))
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-09 21:06:43 +01:00
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
// States for the outer switch in Task_PokeStorageMain
|
2021-04-16 23:05:44 +02:00
|
|
|
enum {
|
|
|
|
MSTATE_HANDLE_INPUT,
|
2021-04-17 06:49:51 +02:00
|
|
|
MSTATE_MOVE_CURSOR,
|
2021-04-16 23:05:44 +02:00
|
|
|
MSTATE_SCROLL_BOX,
|
|
|
|
MSTATE_WAIT_MSG,
|
|
|
|
MSTATE_ERROR_LAST_PARTY_MON,
|
|
|
|
MSTATE_ERROR_HAS_MAIL,
|
|
|
|
MSTATE_WAIT_ERROR_MSG,
|
|
|
|
MSTATE_MULTIMOVE_RUN,
|
|
|
|
MSTATE_MULTIMOVE_RUN_CANCEL,
|
|
|
|
MSTATE_MULTIMOVE_RUN_MOVED,
|
|
|
|
MSTATE_SCROLL_BOX_ITEM,
|
|
|
|
MSTATE_WAIT_ITEM_ANIM,
|
|
|
|
};
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_PokeStorageMain(u8 taskId)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
case MSTATE_HANDLE_INPUT:
|
2018-12-16 21:10:01 +01:00
|
|
|
switch (HandleInput())
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
case INPUT_MOVE_CURSOR:
|
2018-12-09 16:44:01 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_MOVE_CURSOR;
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_SHOW_PARTY:
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_MONS && sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_WHICH_ONE_WILL_TAKE);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_WAIT_MSG;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
ClearSavedCursorPos();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_ShowPartyPokemon);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_HIDE_PARTY:
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption == OPTION_MOVE_MONS)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (IsMonBeingMoved() && ItemIsMail(sStorage->displayMonItemId))
|
|
|
|
sStorage->state = MSTATE_ERROR_HAS_MAIL;
|
2018-12-09 16:44:01 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_HidePartyPokemon);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
else if (sStorage->boxOption == OPTION_MOVE_ITEMS)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_HidePartyPokemon);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_CLOSE_BOX:
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_OnCloseBoxPressed);
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_PRESSED_B:
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_OnBPressed);
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_BOX_OPTIONS:
|
2018-12-09 16:44:01 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_HandleBoxOptions);
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_IN_MENU:
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_OnSelectedMon);
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_SCROLL_RIGHT:
|
2018-12-09 16:44:01 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->newCurrBoxId = StorageGetCurrentBox() + 1;
|
|
|
|
if (sStorage->newCurrBoxId >= TOTAL_BOXES_COUNT)
|
|
|
|
sStorage->newCurrBoxId = 0;
|
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetUpScrollToBox(sStorage->newCurrBoxId);
|
|
|
|
sStorage->state = MSTATE_SCROLL_BOX;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
TryHideItemAtCursor();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_SCROLL_BOX_ITEM;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_SCROLL_LEFT:
|
2018-12-09 16:44:01 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->newCurrBoxId = StorageGetCurrentBox() - 1;
|
|
|
|
if (sStorage->newCurrBoxId < 0)
|
|
|
|
sStorage->newCurrBoxId = TOTAL_BOXES_COUNT - 1;
|
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetUpScrollToBox(sStorage->newCurrBoxId);
|
|
|
|
sStorage->state = MSTATE_SCROLL_BOX;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
TryHideItemAtCursor();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_SCROLL_BOX_ITEM;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_DEPOSIT:
|
|
|
|
if (!IsRemovingLastPartyMon())
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (ItemIsMail(sStorage->displayMonItemId))
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_ERROR_HAS_MAIL;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_DepositMenu);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_ERROR_LAST_PARTY_MON;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_MOVE_MON:
|
|
|
|
if (IsRemovingLastPartyMon())
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_ERROR_LAST_PARTY_MON;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_MoveMon);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_SHIFT_MON:
|
2018-12-22 23:00:22 +01:00
|
|
|
if (!CanShiftMon())
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_ERROR_LAST_PARTY_MON;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_ShiftMon);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_WITHDRAW:
|
2018-12-09 16:44:01 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_WithdrawMon);
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_PLACE_MON:
|
2018-12-09 16:44:01 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PlaceMon);
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_TAKE_ITEM:
|
2018-12-09 16:44:01 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_TakeItemForMoving);
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_GIVE_ITEM:
|
2018-12-09 16:44:01 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_GiveMovingItemToMon);
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_SWITCH_ITEMS:
|
2018-12-09 16:44:01 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_SwitchSelectedItem);
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_MULTIMOVE_START:
|
2018-12-09 16:44:01 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-16 23:05:44 +02:00
|
|
|
MultiMove_SetFunction(MULTIMOVE_START);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_MULTIMOVE_RUN;
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_MULTIMOVE_SINGLE:
|
|
|
|
MultiMove_SetFunction(MULTIMOVE_CANCEL);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_MULTIMOVE_RUN_CANCEL;
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_MULTIMOVE_CHANGE_SELECTION:
|
2018-12-09 16:44:01 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-16 23:05:44 +02:00
|
|
|
MultiMove_SetFunction(MULTIMOVE_CHANGE_SELECTION);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_MULTIMOVE_RUN_MOVED;
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_MULTIMOVE_GRAB_SELECTION:
|
|
|
|
MultiMove_SetFunction(MULTIMOVE_GRAB_SELECTION);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_MULTIMOVE_RUN;
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_MULTIMOVE_MOVE_MONS:
|
2018-12-09 16:44:01 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-16 23:05:44 +02:00
|
|
|
MultiMove_SetFunction(MULTIMOVE_MOVE_MONS);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_MULTIMOVE_RUN_MOVED;
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_MULTIMOVE_PLACE_MONS:
|
2018-12-09 16:44:01 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-16 23:05:44 +02:00
|
|
|
MultiMove_SetFunction(MULTIMOVE_PLACE_MONS);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_MULTIMOVE_RUN;
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_MULTIMOVE_UNABLE:
|
|
|
|
// When selecting/moving multiple Pokémon the
|
|
|
|
// cursor may not wrap around the edges.
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_FAILURE);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-17 06:49:51 +02:00
|
|
|
case MSTATE_MOVE_CURSOR:
|
2021-04-16 23:05:44 +02:00
|
|
|
if (!UpdateCursorPos())
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-09 21:06:43 +01:00
|
|
|
if (IsCursorOnCloseBox())
|
2021-04-17 06:49:51 +02:00
|
|
|
StartFlashingCloseBoxButton();
|
2018-12-09 16:44:01 +01:00
|
|
|
else
|
2021-04-17 06:49:51 +02:00
|
|
|
StopFlashingCloseBoxButton();
|
2018-12-10 21:36:52 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->setMosaic)
|
2021-04-16 05:27:05 +02:00
|
|
|
StartDisplayMonMosaicEffect();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_HANDLE_INPUT;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case MSTATE_SCROLL_BOX:
|
2018-12-09 21:06:43 +01:00
|
|
|
if (!ScrollToBox())
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetCurrentBox(sStorage->newCurrBoxId);
|
2018-12-09 21:06:43 +01:00
|
|
|
if (!sInPartyMenu && !IsMonBeingMoved())
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
RefreshDisplayMon();
|
2021-04-16 05:27:05 +02:00
|
|
|
StartDisplayMonMosaicEffect();
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
2018-12-09 21:06:43 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption == OPTION_MOVE_ITEMS)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
TryShowItemAtCursor();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_WAIT_ITEM_ANIM;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_HANDLE_INPUT;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case MSTATE_WAIT_MSG:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-09 21:06:43 +01:00
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_HANDLE_INPUT;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case MSTATE_ERROR_LAST_PARTY_MON:
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_FAILURE);
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_LAST_POKE);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_WAIT_ERROR_MSG;
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case MSTATE_ERROR_HAS_MAIL:
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_FAILURE);
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_PLEASE_REMOVE_MAIL);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_WAIT_ERROR_MSG;
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case MSTATE_WAIT_ERROR_MSG:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-09 21:06:43 +01:00
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case MSTATE_MULTIMOVE_RUN:
|
|
|
|
if (!MultiMove_RunFunction())
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_HANDLE_INPUT;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case MSTATE_MULTIMOVE_RUN_CANCEL:
|
|
|
|
// Began a multiple Pokémon selection but
|
|
|
|
// ended up selecting a single Pokémon.
|
|
|
|
// Wait for multi move to cancel, then
|
|
|
|
// do a normal move.
|
|
|
|
if (!MultiMove_RunFunction())
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_MoveMon);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case MSTATE_MULTIMOVE_RUN_MOVED:
|
|
|
|
if (!MultiMove_RunFunction())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->setMosaic)
|
2021-04-16 05:27:05 +02:00
|
|
|
StartDisplayMonMosaicEffect();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_HANDLE_INPUT;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case MSTATE_SCROLL_BOX_ITEM:
|
2021-04-16 01:17:53 +02:00
|
|
|
if (!IsItemIconAnimActive())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetUpScrollToBox(sStorage->newCurrBoxId);
|
|
|
|
sStorage->state = MSTATE_SCROLL_BOX;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case MSTATE_WAIT_ITEM_ANIM:
|
2021-04-16 01:17:53 +02:00
|
|
|
if (!IsItemIconAnimActive())
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = MSTATE_HANDLE_INPUT;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_ShowPartyPokemon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2018-12-12 23:19:50 +01:00
|
|
|
SetUpDoShowPartyMenu();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2018-12-12 23:19:50 +01:00
|
|
|
if (!DoShowPartyMenu())
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_HidePartyPokemon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
PlaySE(SE_SELECT);
|
2018-12-12 23:19:50 +01:00
|
|
|
SetUpHidePartyMenu();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2018-12-12 23:19:50 +01:00
|
|
|
if (!HidePartyMenu())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCursorBoxPosition(GetSavedCursorPos());
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-16 23:05:44 +02:00
|
|
|
if (!UpdateCursorPos())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->setMosaic)
|
2021-04-16 05:27:05 +02:00
|
|
|
StartDisplayMonMosaicEffect();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_OnSelectedMon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-16 05:27:05 +02:00
|
|
|
if (!IsDisplayMosaicActive())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_IS_SELECTED);
|
2021-04-18 05:40:27 +02:00
|
|
|
else if (IsMovingItem() || sStorage->displayMonItemId != ITEM_NONE)
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_IS_SELECTED2);
|
2018-12-09 21:06:43 +01:00
|
|
|
else
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_GIVE_TO_MON);
|
2018-12-09 21:06:43 +01:00
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
AddMenu();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 1;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-15 20:06:25 +02:00
|
|
|
case 1:
|
|
|
|
if (!IsMenuLoading())
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 2;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-15 19:31:18 +02:00
|
|
|
switch (HandleMenuInput())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_B_PRESSED:
|
|
|
|
case MENU_CANCEL:
|
2018-12-09 21:06:43 +01:00
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_MOVE:
|
2021-04-16 23:05:44 +02:00
|
|
|
if (IsRemovingLastPartyMon())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 3;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_MoveMon);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_PLACE:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PlaceMon);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_SHIFT:
|
2018-12-22 23:00:22 +01:00
|
|
|
if (!CanShiftMon())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 3;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_ShiftMon);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_WITHDRAW:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_WithdrawMon);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_STORE:
|
2021-04-16 23:05:44 +02:00
|
|
|
if (IsRemovingLastPartyMon())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 3;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
else if (ItemIsMail(sStorage->displayMonItemId))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 4;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_DepositMenu);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_RELEASE:
|
2021-04-16 23:05:44 +02:00
|
|
|
if (IsRemovingLastPartyMon())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 3;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
else if (sStorage->displayMonIsEgg)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 5; // Cannot release an Egg.
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
else if (ItemIsMail(sStorage->displayMonItemId))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 4;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_ReleaseMon);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_SUMMARY:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_ShowMonSummary);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_MARK:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_ShowMarkMenu);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_TAKE:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_TakeItemForMoving);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_GIVE:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_GiveMovingItemToMon);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_BAG:
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_ItemToBag);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_SWITCH:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_SwitchSelectedItem);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_GIVE_2:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_GiveItemFromBag);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_INFO:
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_ShowItemInfo);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_FAILURE);
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_LAST_POKE);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 6;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_FAILURE);
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_CANT_RELEASE_EGG);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 6;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_FAILURE);
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_PLEASE_REMOVE_MAIL);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 6;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 6:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_MoveMon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-17 23:28:18 +02:00
|
|
|
InitMonPlaceChange(CHANGE_GRAB);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2018-12-15 23:58:47 +01:00
|
|
|
if (!DoMonPlaceChange())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
if (sInPartyMenu)
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_HandleMovingMonFromParty);
|
2018-12-09 21:06:43 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_PlaceMon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-17 23:28:18 +02:00
|
|
|
InitMonPlaceChange(CHANGE_PLACE);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2018-12-15 23:58:47 +01:00
|
|
|
if (!DoMonPlaceChange())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
if (sInPartyMenu)
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_HandleMovingMonFromParty);
|
2018-12-09 21:06:43 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_ShiftMon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-17 23:28:18 +02:00
|
|
|
InitMonPlaceChange(CHANGE_SHIFT);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2018-12-15 23:58:47 +01:00
|
|
|
if (!DoMonPlaceChange())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
StartDisplayMonMosaicEffect();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_WithdrawMon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (CalculatePlayerPartyCount() == PARTY_SIZE)
|
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_PARTY_FULL);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 1;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SaveCursorPos();
|
2021-04-17 23:28:18 +02:00
|
|
|
InitMonPlaceChange(CHANGE_GRAB);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 2;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2018-12-15 23:58:47 +01:00
|
|
|
if (!DoMonPlaceChange())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-16 21:10:01 +01:00
|
|
|
SetMovingMonPriority(1);
|
2018-12-12 23:19:50 +01:00
|
|
|
SetUpDoShowPartyMenu();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2018-12-12 23:19:50 +01:00
|
|
|
if (!DoShowPartyMenu())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
InitMonPlaceChange(CHANGE_PLACE);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
2018-12-15 23:58:47 +01:00
|
|
|
if (!DoMonPlaceChange())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
UpdatePartySlotColors();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_HidePartyPokemon);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_DepositMenu(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-15 23:58:47 +01:00
|
|
|
u8 boxId;
|
2018-12-09 21:06:43 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_DEPOSIT_IN_WHICH_BOX);
|
2021-04-18 05:55:24 +02:00
|
|
|
LoadChooseBoxMenuGfx(&sStorage->chooseBoxMenu, GFXTAG_CHOOSE_BOX_MENU, PALTAG_MISC_1, 3, FALSE);
|
2021-04-15 23:31:50 +02:00
|
|
|
CreateChooseBoxMenuSprites(sDepositBoxId);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-15 23:31:50 +02:00
|
|
|
boxId = HandleChooseBoxMenuInput();
|
|
|
|
switch (boxId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
case BOXID_NONE_CHOSEN:
|
|
|
|
break;
|
|
|
|
case BOXID_CANCELED:
|
2018-12-09 21:06:43 +01:00
|
|
|
ClearBottomWindow();
|
2021-04-15 23:31:50 +02:00
|
|
|
DestroyChooseBoxMenuSprites();
|
|
|
|
FreeChooseBoxMenu();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2021-04-15 23:31:50 +02:00
|
|
|
break;
|
|
|
|
default:
|
2018-12-15 23:58:47 +01:00
|
|
|
if (TryStorePartyMonInBox(boxId))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
sDepositBoxId = boxId;
|
2018-12-09 21:06:43 +01:00
|
|
|
ClearBottomWindow();
|
2021-04-15 23:31:50 +02:00
|
|
|
DestroyChooseBoxMenuSprites();
|
|
|
|
FreeChooseBoxMenu();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 2;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_BOX_IS_FULL);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 4;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
2021-04-15 23:31:50 +02:00
|
|
|
break;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
CompactPartySlots();
|
2021-04-17 20:33:00 +02:00
|
|
|
CompactPartySprites();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2021-04-17 20:33:00 +02:00
|
|
|
if (GetNumPartySpritesCompacting() == 0)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:55:24 +02:00
|
|
|
ResetSelectionAfterDeposit();
|
2021-04-16 05:27:05 +02:00
|
|
|
StartDisplayMonMosaicEffect();
|
2021-04-17 23:28:18 +02:00
|
|
|
UpdatePartySlotColors();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_DEPOSIT_IN_WHICH_BOX);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 1;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_ReleaseMon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_RELEASE_POKE);
|
2018-12-12 23:19:50 +01:00
|
|
|
ShowYesNoWindow(1);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
// fallthrough
|
|
|
|
case 1:
|
|
|
|
switch (Menu_ProcessInputNoWrapClearOnChoose())
|
|
|
|
{
|
2018-12-22 23:00:22 +01:00
|
|
|
case MENU_B_PRESSED:
|
2021-04-16 05:27:05 +02:00
|
|
|
case 1: // No
|
2018-12-15 23:58:47 +01:00
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
2021-04-16 05:27:05 +02:00
|
|
|
case 0: // Yes
|
2018-12-15 23:58:47 +01:00
|
|
|
ClearBottomWindow();
|
2021-04-16 05:27:05 +02:00
|
|
|
InitCanReleaseMonVars();
|
|
|
|
InitReleaseMon();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2018-12-16 21:10:01 +01:00
|
|
|
RunCanReleaseMon();
|
2021-04-16 05:27:05 +02:00
|
|
|
if (!TryHideReleaseMon())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
while (1)
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
s8 canRelease = RunCanReleaseMon();
|
|
|
|
if (canRelease == TRUE)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
2021-04-16 05:27:05 +02:00
|
|
|
else if (!canRelease)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 8;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2018-12-16 21:10:01 +01:00
|
|
|
ReleaseMon();
|
2021-04-16 05:27:05 +02:00
|
|
|
RefreshDisplayMonData();
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_WAS_RELEASED);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_BYE_BYE);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
|
|
|
if (sInPartyMenu)
|
|
|
|
{
|
|
|
|
CompactPartySlots();
|
2021-04-17 20:33:00 +02:00
|
|
|
CompactPartySprites();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 7;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 6:
|
2021-04-17 20:33:00 +02:00
|
|
|
if (GetNumPartySpritesCompacting() == 0)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
RefreshDisplayMon();
|
2021-04-16 05:27:05 +02:00
|
|
|
StartDisplayMonMosaicEffect();
|
2021-04-17 23:28:18 +02:00
|
|
|
UpdatePartySlotColors();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 7:
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 8:
|
2021-04-16 05:27:05 +02:00
|
|
|
// Start "can't release" sequence
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_WAS_RELEASED);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 9:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_SURPRISE);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 10:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2021-04-16 05:27:05 +02:00
|
|
|
ReshowReleaseMon();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 11:
|
2021-04-16 05:27:05 +02:00
|
|
|
if (!ResetReleaseMonSpritePtr())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
TrySetCursorFistAnim();
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_CAME_BACK);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 12:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_WORRIED);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 13:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_ShowMarkMenu(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_MARK_POKE);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->markMenu.markings = sStorage->displayMonMarkings;
|
|
|
|
OpenMonMarkingsMenu(sStorage->displayMonMarkings, 0xb0, 0x10);
|
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-02-28 23:22:26 +01:00
|
|
|
if (!HandleMonMarkingsMenuInput())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-02-28 23:22:26 +01:00
|
|
|
FreeMonMarkingsMenu();
|
2018-12-09 21:06:43 +01:00
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetMonMarkings(sStorage->markMenu.markings);
|
2021-04-16 05:27:05 +02:00
|
|
|
RefreshDisplayMonData();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_TakeItemForMoving(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-18 05:40:27 +02:00
|
|
|
if (!ItemIsMail(sStorage->displayMonItemId))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PrintCantStoreMail);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-16 05:27:05 +02:00
|
|
|
StartCursorAnim(CURSOR_ANIM_OPEN);
|
2021-04-17 06:49:51 +02:00
|
|
|
TakeItemFromMon(sInPartyMenu ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetCursorPosition());
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-16 01:17:53 +02:00
|
|
|
if (!IsItemIconAnimActive())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
StartCursorAnim(CURSOR_ANIM_FIST);
|
2018-12-09 21:06:43 +01:00
|
|
|
ClearBottomWindow();
|
2021-04-17 06:49:51 +02:00
|
|
|
RefreshDisplayMon();
|
2021-04-16 05:27:05 +02:00
|
|
|
PrintDisplayMonInfo();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_GiveMovingItemToMon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-16 05:27:05 +02:00
|
|
|
StartCursorAnim(CURSOR_ANIM_OPEN);
|
2021-04-17 06:49:51 +02:00
|
|
|
GiveItemToMon(sInPartyMenu ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetCursorPosition());
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-16 01:17:53 +02:00
|
|
|
if (!IsItemIconAnimActive())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
StartCursorAnim(CURSOR_ANIM_BOUNCE);
|
2021-04-17 06:49:51 +02:00
|
|
|
RefreshDisplayMon();
|
2021-04-16 05:27:05 +02:00
|
|
|
PrintDisplayMonInfo();
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_ITEM_IS_HELD);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_ItemToBag(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-18 05:40:27 +02:00
|
|
|
if (!AddBagItem(sStorage->displayMonItemId, 1))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_FAILURE);
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_BAG_FULL);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 3;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-17 06:49:51 +02:00
|
|
|
MoveItemFromMonToBag(sInPartyMenu ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetCursorPosition());
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 1;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-16 01:17:53 +02:00
|
|
|
if (!IsItemIconAnimActive())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_PLACED_IN_BAG);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 2;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2021-04-17 06:49:51 +02:00
|
|
|
RefreshDisplayMon();
|
2021-04-16 05:27:05 +02:00
|
|
|
PrintDisplayMonInfo();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 4;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_SwitchSelectedItem(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-18 05:40:27 +02:00
|
|
|
if (!ItemIsMail(sStorage->displayMonItemId))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PrintCantStoreMail);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-16 05:27:05 +02:00
|
|
|
StartCursorAnim(CURSOR_ANIM_OPEN);
|
2021-04-17 06:49:51 +02:00
|
|
|
SwapItemsWithMon(sInPartyMenu ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetCursorPosition());
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-16 01:17:53 +02:00
|
|
|
if (!IsItemIconAnimActive())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
StartCursorAnim(CURSOR_ANIM_FIST);
|
2021-04-17 06:49:51 +02:00
|
|
|
RefreshDisplayMon();
|
2021-04-16 05:27:05 +02:00
|
|
|
PrintDisplayMonInfo();
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_CHANGED_TO_ITEM);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_ShowItemInfo(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
|
|
|
PlaySE(SE_WIN_OPEN);
|
2018-12-19 22:47:27 +01:00
|
|
|
PrintItemDescription();
|
2021-04-16 01:17:53 +02:00
|
|
|
InitItemInfoWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-16 01:17:53 +02:00
|
|
|
if (!UpdateItemInfoWindowSlideIn())
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_WIN_OPEN);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
2021-04-16 01:17:53 +02:00
|
|
|
if (!UpdateItemInfoWindowSlideOut())
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_CloseBoxWhileHoldingItem(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_PUT_IN_BAG);
|
2018-12-12 23:19:50 +01:00
|
|
|
ShowYesNoWindow(0);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 1;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
switch (Menu_ProcessInputNoWrapClearOnChoose())
|
|
|
|
{
|
2018-12-22 23:00:22 +01:00
|
|
|
case MENU_B_PRESSED:
|
2021-04-16 01:17:53 +02:00
|
|
|
case 1: // No
|
2018-12-09 21:06:43 +01:00
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-16 01:17:53 +02:00
|
|
|
case 0:// Yes
|
2021-04-18 05:40:27 +02:00
|
|
|
if (AddBagItem(sStorage->movingItemId, 1) == TRUE)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 3;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_BAG_FULL);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 2;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 5;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-04-17 06:49:51 +02:00
|
|
|
MoveItemFromCursorToBag();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 4;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2021-04-16 01:17:53 +02:00
|
|
|
if (!IsItemIconAnimActive())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
StartCursorAnim(CURSOR_ANIM_BOUNCE);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_HandleMovingMonFromParty(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
CompactPartySlots();
|
2021-04-17 20:33:00 +02:00
|
|
|
CompactPartySprites();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-17 20:33:00 +02:00
|
|
|
if (GetNumPartySpritesCompacting() == 0)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
UpdatePartySlotColors();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_PrintCantStoreMail(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_CANT_STORE_MAIL);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
// Handle options menu that shows when the box title bar is selected
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_HandleBoxOptions(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_WHAT_YOU_DO);
|
2018-12-16 21:10:01 +01:00
|
|
|
AddMenu();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-15 20:06:25 +02:00
|
|
|
if (IsMenuLoading())
|
2018-12-09 21:06:43 +01:00
|
|
|
return;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
case 2:
|
2021-04-15 19:31:18 +02:00
|
|
|
switch (HandleMenuInput())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_B_PRESSED:
|
|
|
|
case MENU_CANCEL:
|
2021-04-15 20:06:25 +02:00
|
|
|
AnimateBoxScrollArrows(TRUE);
|
2018-12-09 21:06:43 +01:00
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_NAME:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_NameBox);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_WALLPAPER:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_HandleWallpapers);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_JUMP:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_JumpBox);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_HandleWallpapers(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2018-12-16 21:10:01 +01:00
|
|
|
AddWallpaperSetsMenu();
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_PICK_A_THEME);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-15 20:06:25 +02:00
|
|
|
if (!IsMenuLoading())
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->wallpaperSetId = HandleMenuInput();
|
|
|
|
switch (sStorage->wallpaperSetId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_B_PRESSED:
|
2021-04-15 20:06:25 +02:00
|
|
|
AnimateBoxScrollArrows(TRUE);
|
2018-12-09 21:06:43 +01:00
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_SCENERY_1:
|
|
|
|
case MENU_SCENERY_2:
|
|
|
|
case MENU_SCENERY_3:
|
|
|
|
case MENU_ETCETERA:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-15 19:31:18 +02:00
|
|
|
RemoveMenu();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->wallpaperSetId -= MENU_WALLPAPER_SETS_START;
|
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_FRIENDS:
|
|
|
|
// New wallpaper from Walda.
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->wallpaperId = WALLPAPER_FRIENDS;
|
2021-04-15 19:31:18 +02:00
|
|
|
RemoveMenu();
|
2018-12-09 21:06:43 +01:00
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 6;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
AddWallpapersMenu(sStorage->wallpaperSetId);
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_PICK_A_WALLPAPER);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->wallpaperId = HandleMenuInput();
|
|
|
|
switch (sStorage->wallpaperId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_NOTHING_CHOSEN:
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_B_PRESSED:
|
2018-12-09 21:06:43 +01:00
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 0;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->wallpaperId -= MENU_WALLPAPERS_START;
|
|
|
|
SetWallpaperForCurrentBox(sStorage->wallpaperId);
|
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if (!DoWallpaperGfxChange())
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
AnimateBoxScrollArrows(TRUE);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetWallpaperForCurrentBox(sStorage->wallpaperId);
|
|
|
|
sStorage->state = 5;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_JumpBox(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_JUMP_TO_WHICH_BOX);
|
2021-04-18 05:55:24 +02:00
|
|
|
LoadChooseBoxMenuGfx(&sStorage->chooseBoxMenu, GFXTAG_CHOOSE_BOX_MENU, PALTAG_MISC_1, 3, FALSE);
|
2021-04-15 23:31:50 +02:00
|
|
|
CreateChooseBoxMenuSprites(StorageGetCurrentBox());
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->newCurrBoxId = HandleChooseBoxMenuInput();
|
|
|
|
switch (sStorage->newCurrBoxId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
case BOXID_NONE_CHOSEN:
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ClearBottomWindow();
|
2021-04-15 23:31:50 +02:00
|
|
|
DestroyChooseBoxMenuSprites();
|
|
|
|
FreeChooseBoxMenu();
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->newCurrBoxId == BOXID_CANCELED || sStorage->newCurrBoxId == StorageGetCurrentBox())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
AnimateBoxScrollArrows(TRUE);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-18 05:40:27 +02:00
|
|
|
SetUpScrollToBox(sStorage->newCurrBoxId);
|
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!ScrollToBox())
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetCurrentBox(sStorage->newCurrBoxId);
|
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_NameBox(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-17 06:49:51 +02:00
|
|
|
SaveMovingMon();
|
2021-02-24 17:01:02 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!UpdatePaletteFade())
|
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
sWhichToReshow = SCREEN_CHANGE_NAME_BOX - 1;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->screenChangeType = SCREEN_CHANGE_NAME_BOX;
|
|
|
|
SetPokeStorageTask(Task_ChangeScreen);
|
2018-12-10 21:36:52 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_ShowMonSummary(u8 taskId)
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-17 06:49:51 +02:00
|
|
|
InitSummaryScreenData();
|
2021-02-24 17:01:02 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-10 21:36:52 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!UpdatePaletteFade())
|
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
sWhichToReshow = SCREEN_CHANGE_SUMMARY_SCREEN - 1;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->screenChangeType = SCREEN_CHANGE_SUMMARY_SCREEN;
|
|
|
|
SetPokeStorageTask(Task_ChangeScreen);
|
2018-12-10 21:36:52 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_GiveItemFromBag(u8 taskId)
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-02-24 17:01:02 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-10 21:36:52 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!UpdatePaletteFade())
|
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
sWhichToReshow = SCREEN_CHANGE_ITEM_FROM_BAG - 1;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->screenChangeType = SCREEN_CHANGE_ITEM_FROM_BAG;
|
|
|
|
SetPokeStorageTask(Task_ChangeScreen);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-12-10 21:36:52 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_OnCloseBoxPressed(u8 taskId)
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (IsMonBeingMoved())
|
|
|
|
{
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_FAILURE);
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_HOLDING_POKE);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 1;
|
2018-12-10 21:36:52 +01:00
|
|
|
}
|
2021-04-16 01:17:53 +02:00
|
|
|
else if (IsMovingItem())
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_CloseBoxWhileHoldingItem);
|
2018-12-10 21:36:52 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_EXIT_BOX);
|
2018-12-12 23:19:50 +01:00
|
|
|
ShowYesNoWindow(0);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 2;
|
2018-12-10 21:36:52 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-10 21:36:52 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
switch (Menu_ProcessInputNoWrapClearOnChoose())
|
|
|
|
{
|
2018-12-22 23:00:22 +01:00
|
|
|
case MENU_B_PRESSED:
|
2018-12-10 21:36:52 +01:00
|
|
|
case 1:
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-10 21:36:52 +01:00
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
PlaySE(SE_PC_OFF);
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-10 21:36:52 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2020-06-29 17:41:09 +02:00
|
|
|
ComputerScreenCloseEffect(20, 0, 1);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-10 21:36:52 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2020-06-29 17:41:09 +02:00
|
|
|
if (!IsComputerScreenCloseEffectActive())
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
2021-04-18 05:55:24 +02:00
|
|
|
UpdateBoxToSendMons();
|
2018-12-10 21:36:52 +01:00
|
|
|
gPlayerPartyCount = CalculatePlayerPartyCount();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->screenChangeType = SCREEN_CHANGE_EXIT_BOX;
|
|
|
|
SetPokeStorageTask(Task_ChangeScreen);
|
2018-12-10 21:36:52 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_OnBPressed(u8 taskId)
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->state)
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (IsMonBeingMoved())
|
|
|
|
{
|
2020-08-21 00:02:00 +02:00
|
|
|
PlaySE(SE_FAILURE);
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_HOLDING_POKE);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 1;
|
2018-12-10 21:36:52 +01:00
|
|
|
}
|
2021-04-16 01:17:53 +02:00
|
|
|
else if (IsMovingItem())
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_CloseBoxWhileHoldingItem);
|
2018-12-10 21:36:52 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_CONTINUE_BOX);
|
2018-12-12 23:19:50 +01:00
|
|
|
ShowYesNoWindow(0);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state = 2;
|
2018-12-10 21:36:52 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY))
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-10 21:36:52 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
switch (Menu_ProcessInputNoWrapClearOnChoose())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
SetPokeStorageTask(Task_PokeStorageMain);
|
2018-12-10 21:36:52 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2018-12-22 23:00:22 +01:00
|
|
|
case MENU_B_PRESSED:
|
2018-12-10 21:36:52 +01:00
|
|
|
PlaySE(SE_PC_OFF);
|
|
|
|
ClearBottomWindow();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-10 21:36:52 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2020-06-29 17:41:09 +02:00
|
|
|
ComputerScreenCloseEffect(20, 0, 0);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->state++;
|
2018-12-10 21:36:52 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2020-06-29 17:41:09 +02:00
|
|
|
if (!IsComputerScreenCloseEffectActive())
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
2021-04-18 05:55:24 +02:00
|
|
|
UpdateBoxToSendMons();
|
2018-12-10 21:36:52 +01:00
|
|
|
gPlayerPartyCount = CalculatePlayerPartyCount();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->screenChangeType = SCREEN_CHANGE_EXIT_BOX;
|
|
|
|
SetPokeStorageTask(Task_ChangeScreen);
|
2018-12-10 21:36:52 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void Task_ChangeScreen(u8 taskId)
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
|
|
|
struct BoxPokemon *boxMons;
|
|
|
|
u8 mode, monIndex, maxMonIndex;
|
2021-04-18 05:40:27 +02:00
|
|
|
u8 screenChangeType = sStorage->screenChangeType;
|
2018-12-10 21:36:52 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption == OPTION_MOVE_ITEMS && IsMovingItem() == TRUE)
|
2021-04-16 01:17:53 +02:00
|
|
|
sMovingItemId = GetMovingItemId();
|
2018-12-10 21:36:52 +01:00
|
|
|
else
|
2020-03-09 02:27:29 +01:00
|
|
|
sMovingItemId = ITEM_NONE;
|
2018-12-10 21:36:52 +01:00
|
|
|
|
|
|
|
switch (screenChangeType)
|
|
|
|
{
|
|
|
|
case SCREEN_CHANGE_EXIT_BOX:
|
|
|
|
default:
|
2021-04-18 05:40:27 +02:00
|
|
|
FreePokeStorageData();
|
|
|
|
SetMainCallback2(CB2_ExitPokeStorage);
|
2018-12-10 21:36:52 +01:00
|
|
|
break;
|
|
|
|
case SCREEN_CHANGE_SUMMARY_SCREEN:
|
2021-04-18 05:40:27 +02:00
|
|
|
boxMons = sStorage->summaryMon.box;
|
|
|
|
monIndex = sStorage->summaryStartPos;
|
|
|
|
maxMonIndex = sStorage->summaryMaxPos;
|
|
|
|
mode = sStorage->summaryScreenMode;
|
|
|
|
FreePokeStorageData();
|
2021-04-17 06:49:51 +02:00
|
|
|
if (mode == SUMMARY_MODE_NORMAL && boxMons == &sSavedMovingMon.box)
|
2021-04-18 05:40:27 +02:00
|
|
|
ShowPokemonSummaryScreenSet40EF(mode, boxMons, monIndex, maxMonIndex, CB2_ReturnToPokeStorage);
|
2018-12-10 21:36:52 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
ShowPokemonSummaryScreen(mode, boxMons, monIndex, maxMonIndex, CB2_ReturnToPokeStorage);
|
2018-12-10 21:36:52 +01:00
|
|
|
break;
|
|
|
|
case SCREEN_CHANGE_NAME_BOX:
|
2021-04-18 05:40:27 +02:00
|
|
|
FreePokeStorageData();
|
|
|
|
DoNamingScreen(NAMING_SCREEN_BOX, GetBoxNamePtr(StorageGetCurrentBox()), 0, 0, 0, CB2_ReturnToPokeStorage);
|
2018-12-10 21:36:52 +01:00
|
|
|
break;
|
|
|
|
case SCREEN_CHANGE_ITEM_FROM_BAG:
|
2021-04-18 05:40:27 +02:00
|
|
|
FreePokeStorageData();
|
|
|
|
GoToBagMenu(ITEMMENULOCATION_PCBOX, 0, CB2_ReturnToPokeStorage);
|
2018-12-10 21:36:52 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
2018-12-10 23:42:44 +01:00
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void GiveChosenBagItem(void)
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
u16 itemId = gSpecialVar_ItemId;
|
2018-12-10 23:42:44 +01:00
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
if (itemId != ITEM_NONE)
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
u8 pos = GetCursorPosition();
|
2018-12-10 23:42:44 +01:00
|
|
|
if (sInPartyMenu)
|
2021-04-16 23:05:44 +02:00
|
|
|
SetMonData(&gPlayerParty[pos], MON_DATA_HELD_ITEM, &itemId);
|
2018-12-10 23:42:44 +01:00
|
|
|
else
|
2021-04-16 23:05:44 +02:00
|
|
|
SetCurrentBoxMonData(pos, MON_DATA_HELD_ITEM, &itemId);
|
2018-12-10 23:42:44 +01:00
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
RemoveBagItem(itemId, 1);
|
2018-12-10 23:42:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void FreePokeStorageData(void)
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
TilemapUtil_Free();
|
2021-04-16 23:05:44 +02:00
|
|
|
MultiMove_Free();
|
2021-04-18 05:40:27 +02:00
|
|
|
FREE_AND_SET_NULL(sStorage);
|
2018-12-10 23:42:44 +01:00
|
|
|
FreeAllWindowBuffers();
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: Misc
|
|
|
|
//
|
|
|
|
// No real uniform section below. Misc functions including more initialization,
|
|
|
|
// showing/hiding the party menu, updating the Close Box button, printing
|
|
|
|
// messages, doing the mosaic effect when transitioning between Pokémon, etc.
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void SetScrollingBackground(void)
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
SetGpuReg(REG_OFFSET_BG3CNT, BGCNT_PRIORITY(3) | BGCNT_CHARBASE(3) | BGCNT_16COLOR | BGCNT_SCREENBASE(31));
|
2021-04-16 05:27:05 +02:00
|
|
|
DecompressAndLoadBgGfxUsingHeap(3, sScrollingBg_Gfx, 0, 0, 0);
|
|
|
|
LZ77UnCompVram(sScrollingBg_Tilemap, (void *)BG_SCREEN_ADDR(31));
|
2018-12-10 23:42:44 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void ScrollBackground(void)
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
ChangeBgX(3, 128, 1);
|
|
|
|
ChangeBgY(3, 128, 2);
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static void LoadPokeStorageMenuGfx(void)
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
|
|
|
|
DecompressAndLoadBgGfxUsingHeap(1, gStorageSystemMenu_Gfx, 0, 0, 0);
|
2021-04-18 05:40:27 +02:00
|
|
|
LZ77UnCompWram(sDisplayMenu_Tilemap, sStorage->displayMenuTilemapBuffer);
|
|
|
|
SetBgTilemapBuffer(1, sStorage->displayMenuTilemapBuffer);
|
2018-12-10 23:42:44 +01:00
|
|
|
ShowBg(1);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2018-12-10 23:42:44 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
static bool8 InitPokeStorageWindows(void)
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
if (!InitWindows(sWindowTemplates))
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DeactivateAllTextPrinters();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void LoadWaveformSpritePalette(void)
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
LoadSpritePalette(&gWaveformSpritePalette);
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
static void InitPalettesAndSprites(void)
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
LoadPalette(sInterface_Pal, 0, sizeof(sInterface_Pal));
|
|
|
|
LoadPalette(sPkmnDataGray_Pal, 0x20, sizeof(sPkmnDataGray_Pal));
|
2021-04-18 05:55:24 +02:00
|
|
|
LoadPalette(sUnknown_Pal, 0xF0, sizeof(sUnknown_Pal));
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2021-04-17 23:28:18 +02:00
|
|
|
LoadPalette(sBg_Pal, 0x30, sizeof(sBg_Pal));
|
2018-12-10 23:42:44 +01:00
|
|
|
else
|
2021-04-17 23:28:18 +02:00
|
|
|
LoadPalette(sBgMoveItems_Pal, 0x30, sizeof(sBgMoveItems_Pal));
|
2018-12-10 23:42:44 +01:00
|
|
|
|
|
|
|
SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(1) | BGCNT_CHARBASE(1) | BGCNT_16COLOR | BGCNT_SCREENBASE(30));
|
2021-04-16 05:27:05 +02:00
|
|
|
CreateDisplayMonSprite();
|
2021-04-16 01:17:53 +02:00
|
|
|
CreateMarkingComboSprite();
|
|
|
|
CreateWaveformSprites();
|
2021-04-16 05:27:05 +02:00
|
|
|
RefreshDisplayMonData();
|
2018-12-10 23:42:44 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void CreateMarkingComboSprite(void)
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->markingComboSprite = CreateMonMarkingComboSprite(GFXTAG_MARKING_COMBO, PALTAG_MARKING_COMBO, NULL);
|
|
|
|
sStorage->markingComboSprite->oam.priority = 1;
|
|
|
|
sStorage->markingComboSprite->subpriority = 1;
|
2021-07-07 15:11:52 +02:00
|
|
|
sStorage->markingComboSprite->x = 40;
|
|
|
|
sStorage->markingComboSprite->y = 150;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->markingComboTilesPtr = (void*) OBJ_VRAM0 + 32 * GetSpriteTileStartByTag(GFXTAG_MARKING_COMBO);
|
2018-12-10 23:42:44 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void CreateWaveformSprites(void)
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
2021-04-16 01:17:53 +02:00
|
|
|
struct SpriteSheet sheet = sSpriteSheet_Waveform;
|
2018-12-10 23:42:44 +01:00
|
|
|
|
|
|
|
LoadSpriteSheet(&sheet);
|
2021-04-18 05:40:27 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sStorage->waveformSprites); i++)
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
2018-12-21 22:35:01 +01:00
|
|
|
u8 spriteId = CreateSprite(&sSpriteTemplate_Waveform, i * 63 + 8, 9, 2);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->waveformSprites[i] = &gSprites[spriteId];
|
2018-12-10 23:42:44 +01:00
|
|
|
}
|
|
|
|
}
|
2018-12-11 23:09:12 +01:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void RefreshDisplayMonData(void)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
LoadDisplayMonGfx(sStorage->displayMonSpecies, sStorage->displayMonPersonality);
|
2021-04-16 05:27:05 +02:00
|
|
|
PrintDisplayMonInfo();
|
2021-04-16 01:17:53 +02:00
|
|
|
UpdateWaveformAnimation();
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void StartDisplayMonMosaicEffect(void)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
RefreshDisplayMonData();
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->displayMonSprite)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->displayMonSprite->oam.mosaic = TRUE;
|
|
|
|
sStorage->displayMonSprite->data[0] = 10;
|
|
|
|
sStorage->displayMonSprite->data[1] = 1;
|
|
|
|
sStorage->displayMonSprite->callback = SpriteCB_DisplayMonMosaic;
|
|
|
|
SetGpuReg(REG_OFFSET_MOSAIC, (sStorage->displayMonSprite->data[0] << 12) | (sStorage->displayMonSprite->data[0] << 8));
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static u8 IsDisplayMosaicActive(void)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
return sStorage->displayMonSprite->oam.mosaic;
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void SpriteCB_DisplayMonMosaic(struct Sprite *sprite)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
|
|
|
sprite->data[0] -= sprite->data[1];
|
|
|
|
if (sprite->data[0] < 0)
|
|
|
|
sprite->data[0] = 0;
|
|
|
|
SetGpuReg(REG_OFFSET_MOSAIC, (sprite->data[0] << 12) | (sprite->data[0] << 8));
|
|
|
|
if (sprite->data[0] == 0)
|
|
|
|
{
|
|
|
|
sprite->oam.mosaic = FALSE;
|
|
|
|
sprite->callback = SpriteCallbackDummy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void CreateDisplayMonSprite(void)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
u16 tileStart;
|
|
|
|
u8 palSlot;
|
|
|
|
u8 spriteId;
|
2021-04-18 05:40:27 +02:00
|
|
|
struct SpriteSheet sheet = {sStorage->tileBuffer, MON_PIC_SIZE, GFXTAG_DISPLAY_MON};
|
|
|
|
struct SpritePalette palette = {sStorage->displayMonPalBuffer, PALTAG_DISPLAY_MON};
|
2021-04-16 05:27:05 +02:00
|
|
|
struct SpriteTemplate template = sSpriteTemplate_DisplayMon;
|
2018-12-11 23:09:12 +01:00
|
|
|
|
2021-03-29 15:38:19 +02:00
|
|
|
for (i = 0; i < MON_PIC_SIZE; i++)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->tileBuffer[i] = 0;
|
2021-04-16 01:17:53 +02:00
|
|
|
for (i = 0; i < 16; i++)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->displayMonPalBuffer[i] = 0;
|
2018-12-11 23:09:12 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->displayMonSprite = NULL;
|
2018-12-11 23:09:12 +01:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
tileStart = LoadSpriteSheet(&sheet);
|
|
|
|
if (tileStart == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
palSlot = LoadSpritePalette(&palette);
|
|
|
|
if (palSlot == 0xFF)
|
|
|
|
break;
|
|
|
|
|
|
|
|
spriteId = CreateSprite(&template, 40, 48, 0);
|
|
|
|
if (spriteId == MAX_SPRITES)
|
|
|
|
break;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->displayMonSprite = &gSprites[spriteId];
|
|
|
|
sStorage->displayMonPalOffset = palSlot * 16 + 0x100;
|
|
|
|
sStorage->displayMonTilePtr = (void*) OBJ_VRAM0 + tileStart * 32;
|
2018-12-11 23:09:12 +01:00
|
|
|
} while (0);
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->displayMonSprite == NULL)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
FreeSpriteTilesByTag(GFXTAG_DISPLAY_MON);
|
|
|
|
FreeSpritePaletteByTag(PALTAG_DISPLAY_MON);
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void LoadDisplayMonGfx(u16 species, u32 pid)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->displayMonSprite == NULL)
|
2018-12-11 23:09:12 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (species != SPECIES_NONE)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
LoadSpecialPokePic(&gMonFrontPicTable[species], sStorage->tileBuffer, species, pid, TRUE);
|
|
|
|
LZ77UnCompWram(sStorage->displayMonPalette, sStorage->displayMonPalBuffer);
|
|
|
|
CpuCopy32(sStorage->tileBuffer, sStorage->displayMonTilePtr, MON_PIC_SIZE);
|
|
|
|
LoadPalette(sStorage->displayMonPalBuffer, sStorage->displayMonPalOffset, 0x20);
|
|
|
|
sStorage->displayMonSprite->invisible = FALSE;
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->displayMonSprite->invisible = TRUE;
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void PrintDisplayMonInfo(void)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(0, PIXEL_FILL(1));
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
AddTextPrinterParameterized(0, 1, sStorage->displayMonNameText, 6, 0, TEXT_SPEED_FF, NULL);
|
|
|
|
AddTextPrinterParameterized(0, 2, sStorage->displayMonSpeciesName, 6, 15, TEXT_SPEED_FF, NULL);
|
|
|
|
AddTextPrinterParameterized(0, 2, sStorage->displayMonGenderLvlText, 10, 29, TEXT_SPEED_FF, NULL);
|
|
|
|
AddTextPrinterParameterized(0, 0, sStorage->displayMonItemName, 6, 43, TEXT_SPEED_FF, NULL);
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
AddTextPrinterParameterized(0, 0, sStorage->displayMonItemName, 6, 0, TEXT_SPEED_FF, NULL);
|
|
|
|
AddTextPrinterParameterized(0, 1, sStorage->displayMonNameText, 6, 13, TEXT_SPEED_FF, NULL);
|
|
|
|
AddTextPrinterParameterized(0, 2, sStorage->displayMonSpeciesName, 6, 28, TEXT_SPEED_FF, NULL);
|
|
|
|
AddTextPrinterParameterized(0, 2, sStorage->displayMonGenderLvlText, 10, 42, TEXT_SPEED_FF, NULL);
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CopyWindowToVram(0, 2);
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->displayMonSpecies != SPECIES_NONE)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
UpdateMonMarkingTiles(sStorage->displayMonMarkings, sStorage->markingComboTilesPtr);
|
|
|
|
sStorage->markingComboSprite->invisible = FALSE;
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->markingComboSprite->invisible = TRUE;
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
// Turn the wave animation on the sides of "Pkmn Data" on/off
|
|
|
|
static void UpdateWaveformAnimation(void)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->displayMonSpecies != SPECIES_NONE)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
// Start waveform animation and color "Pkmn Data"
|
|
|
|
TilemapUtil_SetRect(TILEMAPID_PKMN_DATA, 0, 0, 8, 2);
|
2021-04-18 05:40:27 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sStorage->waveformSprites); i++)
|
|
|
|
StartSpriteAnimIfDifferent(sStorage->waveformSprites[i], i * 2 + 1);
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
// Stop waveform animation and gray out "Pkmn Data"
|
|
|
|
TilemapUtil_SetRect(TILEMAPID_PKMN_DATA, 0, 2, 8, 2);
|
2021-04-18 05:40:27 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sStorage->waveformSprites); i++)
|
|
|
|
StartSpriteAnim(sStorage->waveformSprites[i], i * 2);
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
TilemapUtil_Update(TILEMAPID_PKMN_DATA);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
2018-12-12 23:19:50 +01:00
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static void InitSupplementalTilemaps(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
LZ77UnCompWram(gStorageSystemPartyMenu_Tilemap, sStorage->partyMenuTilemapBuffer);
|
2021-04-17 06:49:51 +02:00
|
|
|
LoadPalette(gStorageSystemPartyMenu_Pal, 0x10, 0x20);
|
2021-04-18 05:40:27 +02:00
|
|
|
TilemapUtil_SetMap(TILEMAPID_PARTY_MENU, 1, sStorage->partyMenuTilemapBuffer, 12, 22);
|
2021-04-17 23:28:18 +02:00
|
|
|
TilemapUtil_SetMap(TILEMAPID_CLOSE_BUTTON, 1, sCloseBoxButton_Tilemap, 9, 4);
|
|
|
|
TilemapUtil_SetPos(TILEMAPID_PARTY_MENU, 10, 0);
|
|
|
|
TilemapUtil_SetPos(TILEMAPID_CLOSE_BUTTON, 21, 0);
|
2021-04-17 20:33:00 +02:00
|
|
|
SetPartySlotTilemaps();
|
2018-12-12 23:19:50 +01:00
|
|
|
if (sInPartyMenu)
|
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
UpdateCloseBoxButtonTilemap(TRUE);
|
2018-12-15 23:58:47 +01:00
|
|
|
CreatePartyMonsSprites(TRUE);
|
2021-04-17 23:28:18 +02:00
|
|
|
TilemapUtil_Update(TILEMAPID_CLOSE_BUTTON);
|
|
|
|
TilemapUtil_Update(TILEMAPID_PARTY_MENU);
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
TilemapUtil_SetRect(TILEMAPID_PARTY_MENU, 0, 20, 12, 2);
|
|
|
|
UpdateCloseBoxButtonTilemap(TRUE);
|
|
|
|
TilemapUtil_Update(TILEMAPID_PARTY_MENU);
|
|
|
|
TilemapUtil_Update(TILEMAPID_CLOSE_BUTTON);
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->closeBoxFlashing = FALSE;
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void SetUpShowPartyMenu(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->partyMenuUnused1 = 20;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->partyMenuY = 2;
|
|
|
|
sStorage->partyMenuMoveTimer = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
CreatePartyMonsSprites(FALSE);
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 ShowPartyMenu(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->partyMenuMoveTimer == 20)
|
2018-12-12 23:19:50 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->partyMenuUnused1--;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->partyMenuY++;
|
2021-04-17 23:28:18 +02:00
|
|
|
TilemapUtil_Move(TILEMAPID_PARTY_MENU, 3, 1);
|
|
|
|
TilemapUtil_Update(TILEMAPID_PARTY_MENU);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2021-04-17 06:49:51 +02:00
|
|
|
MovePartySprites(8);
|
2021-04-18 05:40:27 +02:00
|
|
|
if (++sStorage->partyMenuMoveTimer == 20)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
|
|
|
sInPartyMenu = TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void SetUpHidePartyMenu(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->partyMenuUnused1 = 0;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->partyMenuY = 22;
|
|
|
|
sStorage->partyMenuMoveTimer = 0;
|
|
|
|
if (sStorage->boxOption == OPTION_MOVE_ITEMS)
|
2021-04-17 06:49:51 +02:00
|
|
|
MoveHeldItemWithPartyMenu();
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 HidePartyMenu(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->partyMenuMoveTimer != 20)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->partyMenuUnused1++;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->partyMenuY--;
|
2021-04-17 23:28:18 +02:00
|
|
|
TilemapUtil_Move(TILEMAPID_PARTY_MENU, 3, -1);
|
|
|
|
TilemapUtil_Update(TILEMAPID_PARTY_MENU);
|
2021-04-18 05:40:27 +02:00
|
|
|
FillBgTilemapBufferRect_Palette0(1, 0x100, 10, sStorage->partyMenuY, 12, 1);
|
2021-04-17 06:49:51 +02:00
|
|
|
MovePartySprites(-8);
|
2021-04-18 05:40:27 +02:00
|
|
|
if (++sStorage->partyMenuMoveTimer != 20)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2018-12-12 23:19:50 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sInPartyMenu = FALSE;
|
2018-12-15 23:58:47 +01:00
|
|
|
DestroyAllPartyMonIcons();
|
2018-12-12 23:19:50 +01:00
|
|
|
CompactPartySlots();
|
2021-04-17 23:28:18 +02:00
|
|
|
|
|
|
|
// The close box button gets partially covered by
|
|
|
|
// the party menu, restore it
|
|
|
|
TilemapUtil_SetRect(TILEMAPID_CLOSE_BUTTON, 0, 0, 9, 2);
|
|
|
|
TilemapUtil_Update(TILEMAPID_CLOSE_BUTTON);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2018-12-12 23:19:50 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static void UpdateCloseBoxButtonTilemap(bool8 normal)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
if (normal)
|
2021-04-17 23:28:18 +02:00
|
|
|
TilemapUtil_SetRect(TILEMAPID_CLOSE_BUTTON, 0, 0, 9, 2);
|
2021-04-17 06:49:51 +02:00
|
|
|
else // flashing
|
2021-04-17 23:28:18 +02:00
|
|
|
TilemapUtil_SetRect(TILEMAPID_CLOSE_BUTTON, 0, 2, 9, 2);
|
2018-12-12 23:19:50 +01:00
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
TilemapUtil_Update(TILEMAPID_CLOSE_BUTTON);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void StartFlashingCloseBoxButton(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->closeBoxFlashing = TRUE;
|
|
|
|
sStorage->closeBoxFlashTimer = 30;
|
|
|
|
sStorage->closeBoxFlashState = TRUE;
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void StopFlashingCloseBoxButton(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->closeBoxFlashing)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->closeBoxFlashing = FALSE;
|
2021-04-17 23:28:18 +02:00
|
|
|
UpdateCloseBoxButtonTilemap(TRUE);
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void UpdateCloseBoxButtonFlash(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->closeBoxFlashing && ++sStorage->closeBoxFlashTimer > 30)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->closeBoxFlashTimer = 0;
|
|
|
|
sStorage->closeBoxFlashState = (sStorage->closeBoxFlashState == FALSE);
|
|
|
|
UpdateCloseBoxButtonTilemap(sStorage->closeBoxFlashState);
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 20:33:00 +02:00
|
|
|
static void SetPartySlotTilemaps(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2021-04-17 20:33:00 +02:00
|
|
|
// Skips first party slot, it should always be drawn
|
|
|
|
// as if it has a Pokémon in it
|
2018-12-12 23:19:50 +01:00
|
|
|
for (i = 1; i < PARTY_SIZE; i++)
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
s32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES);
|
2021-04-17 20:33:00 +02:00
|
|
|
SetPartySlotTilemap(i, species != SPECIES_NONE);
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 20:33:00 +02:00
|
|
|
static void SetPartySlotTilemap(u8 partyId, bool8 hasMon)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
|
|
|
u16 i, j, index;
|
|
|
|
const u16 *data;
|
|
|
|
|
2021-04-17 20:33:00 +02:00
|
|
|
if (hasMon)
|
|
|
|
data = sPartySlotFilled_Tilemap;
|
2018-12-12 23:19:50 +01:00
|
|
|
else
|
2021-04-17 20:33:00 +02:00
|
|
|
data = sPartySlotEmpty_Tilemap;
|
2018-12-12 23:19:50 +01:00
|
|
|
|
2021-04-17 20:33:00 +02:00
|
|
|
index = 3 * (3 * (partyId - 1) + 1);
|
2018-12-12 23:19:50 +01:00
|
|
|
index *= 4;
|
|
|
|
index += 7;
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < 4; j++)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->partyMenuTilemapBuffer[index + j] = data[j];
|
2021-04-17 06:49:51 +02:00
|
|
|
|
2018-12-12 23:19:50 +01:00
|
|
|
data += 4;
|
|
|
|
index += 12;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static void UpdatePartySlotColors(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-17 20:33:00 +02:00
|
|
|
SetPartySlotTilemaps();
|
2021-04-17 23:28:18 +02:00
|
|
|
TilemapUtil_SetRect(TILEMAPID_PARTY_MENU, 0, 0, 12, 22);
|
|
|
|
TilemapUtil_Update(TILEMAPID_PARTY_MENU);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void SetUpDoShowPartyMenu(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->showPartyMenuState = 0;
|
2018-12-12 23:19:50 +01:00
|
|
|
PlaySE(SE_WIN_OPEN);
|
|
|
|
SetUpShowPartyMenu();
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 DoShowPartyMenu(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->showPartyMenuState)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (!ShowPartyMenu())
|
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCursorInParty();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->showPartyMenuState++;
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-16 23:05:44 +02:00
|
|
|
if (!UpdateCursorPos())
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->setMosaic)
|
2021-04-16 05:27:05 +02:00
|
|
|
StartDisplayMonMosaicEffect();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->showPartyMenuState++;
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
static void UpdateBoxToSendMons(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
if (sLastUsedBox != StorageGetCurrentBox())
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2019-09-17 07:49:07 +02:00
|
|
|
FlagClear(FLAG_SHOWN_BOX_WAS_FULL_MESSAGE);
|
|
|
|
VarSet(VAR_PC_BOX_TO_SEND_MON, StorageGetCurrentBox());
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
static void InitPokeStorageBg0(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
|
|
|
SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(29));
|
|
|
|
LoadUserWindowBorderGfx(1, 2, 208);
|
|
|
|
FillBgTilemapBufferRect(0, 0, 0, 0, 32, 20, 17);
|
|
|
|
CopyBgTilemapBufferToVram(0);
|
|
|
|
}
|
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
static void PrintMessage(u8 id)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
|
|
|
u8 *txtPtr;
|
|
|
|
|
|
|
|
DynamicPlaceholderTextUtil_Reset();
|
2021-04-15 19:31:18 +02:00
|
|
|
switch (sMessages[id].format)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
case MSG_VAR_NONE:
|
2018-12-12 23:19:50 +01:00
|
|
|
break;
|
2021-04-16 05:27:05 +02:00
|
|
|
case MSG_VAR_MON_NAME_1:
|
|
|
|
case MSG_VAR_MON_NAME_2:
|
|
|
|
case MSG_VAR_MON_NAME_3:
|
2021-04-18 05:40:27 +02:00
|
|
|
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sStorage->displayMonName);
|
2018-12-12 23:19:50 +01:00
|
|
|
break;
|
2021-04-16 05:27:05 +02:00
|
|
|
case MSG_VAR_RELEASE_MON_1:
|
|
|
|
case MSG_VAR_RELEASE_MON_2:
|
|
|
|
case MSG_VAR_RELEASE_MON_3:
|
2021-04-18 05:40:27 +02:00
|
|
|
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sStorage->releaseMonName);
|
2018-12-12 23:19:50 +01:00
|
|
|
break;
|
2021-04-16 05:27:05 +02:00
|
|
|
case MSG_VAR_ITEM_NAME:
|
2021-04-16 01:17:53 +02:00
|
|
|
if (IsMovingItem())
|
2021-04-18 05:40:27 +02:00
|
|
|
txtPtr = StringCopy(sStorage->itemName, GetMovingItemName());
|
2018-12-12 23:19:50 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
txtPtr = StringCopy(sStorage->itemName, sStorage->displayMonItemName);
|
2018-12-12 23:19:50 +01:00
|
|
|
|
|
|
|
while (*(txtPtr - 1) == CHAR_SPACE)
|
|
|
|
txtPtr--;
|
|
|
|
|
|
|
|
*txtPtr = EOS;
|
2021-04-18 05:40:27 +02:00
|
|
|
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sStorage->itemName);
|
2018-12-12 23:19:50 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
DynamicPlaceholderTextUtil_ExpandPlaceholders(sStorage->messageText, sMessages[id].text);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(1, PIXEL_FILL(1));
|
2021-04-18 05:40:27 +02:00
|
|
|
AddTextPrinterParameterized(1, 1, sStorage->messageText, 0, 1, TEXT_SPEED_FF, NULL);
|
2019-04-01 00:59:52 +02:00
|
|
|
DrawTextBorderOuter(1, 2, 14);
|
2018-12-12 23:19:50 +01:00
|
|
|
PutWindowTilemap(1);
|
|
|
|
CopyWindowToVram(1, 2);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void ShowYesNoWindow(s8 cursorPos)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
|
|
|
CreateYesNoMenu(&sYesNoWindowTemplate, 11, 14, 0);
|
2018-12-16 21:10:01 +01:00
|
|
|
Menu_MoveCursorNoWrapAround(cursorPos);
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void ClearBottomWindow(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearStdWindowAndFrameToTransparent(1, FALSE);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void AddWallpaperSetsMenu(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2018-12-16 21:10:01 +01:00
|
|
|
InitMenu();
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_SCENERY_1);
|
|
|
|
SetMenuText(MENU_SCENERY_2);
|
|
|
|
SetMenuText(MENU_SCENERY_3);
|
|
|
|
SetMenuText(MENU_ETCETERA);
|
2018-12-12 23:19:50 +01:00
|
|
|
if (IsWaldaWallpaperUnlocked())
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_FRIENDS);
|
2018-12-16 21:10:01 +01:00
|
|
|
AddMenu();
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void AddWallpapersMenu(u8 wallpaperSet)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2018-12-16 21:10:01 +01:00
|
|
|
InitMenu();
|
2018-12-12 23:19:50 +01:00
|
|
|
switch (wallpaperSet)
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
case MENU_SCENERY_1 - MENU_WALLPAPER_SETS_START:
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_FOREST);
|
|
|
|
SetMenuText(MENU_CITY);
|
|
|
|
SetMenuText(MENU_DESERT);
|
|
|
|
SetMenuText(MENU_SAVANNA);
|
2018-12-12 23:19:50 +01:00
|
|
|
break;
|
2021-04-15 20:06:25 +02:00
|
|
|
case MENU_SCENERY_2 - MENU_WALLPAPER_SETS_START:
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_CRAG);
|
|
|
|
SetMenuText(MENU_VOLCANO);
|
|
|
|
SetMenuText(MENU_SNOW);
|
|
|
|
SetMenuText(MENU_CAVE);
|
2018-12-12 23:19:50 +01:00
|
|
|
break;
|
2021-04-15 20:06:25 +02:00
|
|
|
case MENU_SCENERY_3 - MENU_WALLPAPER_SETS_START:
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_BEACH);
|
|
|
|
SetMenuText(MENU_SEAFLOOR);
|
|
|
|
SetMenuText(MENU_RIVER);
|
|
|
|
SetMenuText(MENU_SKY);
|
2018-12-12 23:19:50 +01:00
|
|
|
break;
|
2021-04-15 20:06:25 +02:00
|
|
|
case MENU_ETCETERA - MENU_WALLPAPER_SETS_START:
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_POLKADOT);
|
|
|
|
SetMenuText(MENU_POKECENTER);
|
|
|
|
SetMenuText(MENU_MACHINE);
|
|
|
|
SetMenuText(MENU_SIMPLE);
|
2018-12-12 23:19:50 +01:00
|
|
|
break;
|
|
|
|
}
|
2018-12-16 21:10:01 +01:00
|
|
|
AddMenu();
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static u8 GetCurrentBoxOption(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
|
|
|
return sCurrentBoxOption;
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
static void InitCursorItemIcon(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
if (!IsCursorOnBoxTitle())
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
|
|
|
if (sInPartyMenu)
|
2021-04-17 06:49:51 +02:00
|
|
|
TryLoadItemIconAtPos(CURSOR_AREA_IN_PARTY, GetCursorPosition());
|
2018-12-12 23:19:50 +01:00
|
|
|
else
|
2021-04-17 06:49:51 +02:00
|
|
|
TryLoadItemIconAtPos(CURSOR_AREA_IN_BOX, GetCursorPosition());
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
|
2020-03-09 02:27:29 +01:00
|
|
|
if (sMovingItemId != ITEM_NONE)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
InitItemIconInCursor(sMovingItemId);
|
2021-04-16 05:27:05 +02:00
|
|
|
StartCursorAnim(CURSOR_ANIM_FIST);
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: Pokémon sprites
|
|
|
|
//
|
|
|
|
// The below functions generally handle the Pokémon icon sprites, including
|
|
|
|
// moving them with a scrolling box, shifting the party sprites, and
|
|
|
|
// animating released Pokémon.
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void InitMonIconFields(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
LoadMonIconPalettes();
|
2021-04-16 05:27:05 +02:00
|
|
|
for (i = 0; i < MAX_MON_ICONS; i++)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->numIconsPerSpecies[i] = 0;
|
2021-04-16 05:27:05 +02:00
|
|
|
for (i = 0; i < MAX_MON_ICONS; i++)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->iconSpeciesList[i] = SPECIES_NONE;
|
2018-12-12 23:19:50 +01:00
|
|
|
for (i = 0; i < PARTY_SIZE; i++)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->partySprites[i] = NULL;
|
2018-12-12 23:19:50 +01:00
|
|
|
for (i = 0; i < IN_BOX_COUNT; i++)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxMonsSprites[i] = NULL;
|
2018-12-12 23:19:50 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingMonSprite = NULL;
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->unkUnused1 = 0;
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static u8 GetMonIconPriorityByCursorPos(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
return (IsCursorInBox() ? 2 : 1);
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void CreateMovingMonIcon(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
u32 personality = GetMonData(&sStorage->movingMon, MON_DATA_PERSONALITY);
|
|
|
|
u16 species = GetMonData(&sStorage->movingMon, MON_DATA_SPECIES2);
|
2021-04-16 05:27:05 +02:00
|
|
|
u8 priority = GetMonIconPriorityByCursorPos();
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingMonSprite = CreateMonIconSprite(species, personality, 0, 0, priority, 7);
|
|
|
|
sStorage->movingMonSprite->callback = SpriteCB_HeldMon;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static void InitBoxMonSprites(u8 boxId)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u8 boxPosition;
|
|
|
|
u16 i, j, count;
|
|
|
|
u16 species;
|
|
|
|
u32 personality;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
boxPosition = 0;
|
2021-04-15 20:06:25 +02:00
|
|
|
|
|
|
|
// For each box slot, create a Pokémon icon if a species is present
|
2021-04-16 11:14:35 +02:00
|
|
|
for (i = 0; i < IN_BOX_ROWS; i++)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 11:14:35 +02:00
|
|
|
for (j = 0; j < IN_BOX_COLUMNS; j++)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
species = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2);
|
|
|
|
if (species != SPECIES_NONE)
|
|
|
|
{
|
|
|
|
personality = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxMonsSprites[count] = CreateMonIconSprite(species, personality, 8 * (3 * j) + 100, 8 * (3 * i) + 44, 2, 19 - j);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxMonsSprites[count] = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
boxPosition++;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
// If in item mode, set all Pokémon icons with no item to be transparent
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption == OPTION_MOVE_ITEMS)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
for (boxPosition = 0; boxPosition < IN_BOX_COUNT; boxPosition++)
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
if (GetBoxMonDataAt(boxId, boxPosition, MON_DATA_HELD_ITEM) == ITEM_NONE)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 01:28:31 +02:00
|
|
|
static void CreateBoxMonIconAtPos(u8 boxPosition)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u16 species = GetCurrentBoxMonData(boxPosition, MON_DATA_SPECIES2);
|
|
|
|
|
|
|
|
if (species != SPECIES_NONE)
|
|
|
|
{
|
2021-04-16 11:14:35 +02:00
|
|
|
s16 x = 8 * (3 * (boxPosition % IN_BOX_COLUMNS)) + 100;
|
|
|
|
s16 y = 8 * (3 * (boxPosition / IN_BOX_COLUMNS)) + 44;
|
2018-12-15 23:58:47 +01:00
|
|
|
u32 personality = GetCurrentBoxMonData(boxPosition, MON_DATA_PERSONALITY);
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxMonsSprites[boxPosition] = CreateMonIconSprite(species, personality, x, y, 2, 19 - (boxPosition % IN_BOX_COLUMNS));
|
|
|
|
if (sStorage->boxOption == OPTION_MOVE_ITEMS)
|
|
|
|
sStorage->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 01:28:31 +02:00
|
|
|
#define sDistance data[1]
|
|
|
|
#define sSpeed data[2]
|
|
|
|
#define sScrollInDestX data[3]
|
|
|
|
#define sDelay data[4]
|
|
|
|
#define sScrollOutX data[5]
|
|
|
|
|
|
|
|
static void StartBoxMonIconsScrollOut(s16 speed)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
for (i = 0; i < IN_BOX_COUNT; i++)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxMonsSprites[i] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxMonsSprites[i]->sSpeed = speed;
|
|
|
|
sStorage->boxMonsSprites[i]->sDelay = 1;
|
|
|
|
sStorage->boxMonsSprites[i]->callback = SpriteCB_BoxMonIconScrollOut;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 01:28:31 +02:00
|
|
|
static void SpriteCB_BoxMonIconScrollIn(struct Sprite *sprite)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 01:28:31 +02:00
|
|
|
if (sprite->sDistance != 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 01:28:31 +02:00
|
|
|
// Icon moving
|
|
|
|
sprite->sDistance--;
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x += sprite->sSpeed;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 01:28:31 +02:00
|
|
|
// Icon arrived
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->iconScrollNumIncoming--;
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = sprite->sScrollInDestX;
|
2018-12-15 23:58:47 +01:00
|
|
|
sprite->callback = SpriteCallbackDummy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 01:28:31 +02:00
|
|
|
static void SpriteCB_BoxMonIconScrollOut(struct Sprite *sprite)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 01:28:31 +02:00
|
|
|
if (sprite->sDelay != 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 01:28:31 +02:00
|
|
|
sprite->sDelay--;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 01:28:31 +02:00
|
|
|
// Icon moving
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x += sprite->sSpeed;
|
|
|
|
sprite->sScrollOutX = sprite->x + sprite->x2;
|
2021-04-18 01:28:31 +02:00
|
|
|
|
|
|
|
// Check if icon offscreen
|
|
|
|
if (sprite->sScrollOutX <= 68 || sprite->sScrollOutX >= 252)
|
2018-12-15 23:58:47 +01:00
|
|
|
sprite->callback = SpriteCallbackDummy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 01:28:31 +02:00
|
|
|
// Sprites for Pokémon icons are destroyed during
|
|
|
|
// the box scroll once they've gone offscreen
|
|
|
|
static void DestroyBoxMonIconsInColumn(u8 column)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 11:14:35 +02:00
|
|
|
u16 row;
|
|
|
|
u8 boxPosition = column;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-16 11:14:35 +02:00
|
|
|
for (row = 0; row < IN_BOX_ROWS; row++)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxMonsSprites[boxPosition] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
DestroyBoxMonIcon(sStorage->boxMonsSprites[boxPosition]);
|
|
|
|
sStorage->boxMonsSprites[boxPosition] = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-16 11:14:35 +02:00
|
|
|
boxPosition += IN_BOX_COLUMNS;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 01:28:31 +02:00
|
|
|
// Create the appearing icons for the incoming scrolling box
|
|
|
|
static u8 CreateBoxMonIconsInColumn(u8 column, u16 distance, s16 speed)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
u16 y = 44;
|
2021-04-18 01:28:31 +02:00
|
|
|
s16 xDest = 8 * (3 * column) + 100;
|
|
|
|
u16 x = xDest - ((distance + 1) * speed);
|
|
|
|
u8 subpriority = 19 - column;
|
|
|
|
u8 iconsCreated = 0;
|
|
|
|
u8 boxPosition = column;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 11:14:35 +02:00
|
|
|
for (i = 0; i < IN_BOX_ROWS; i++)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxSpecies[boxPosition] != SPECIES_NONE)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxMonsSprites[boxPosition] = CreateMonIconSprite(sStorage->boxSpecies[boxPosition],
|
|
|
|
sStorage->boxPersonalities[boxPosition],
|
2018-12-15 23:58:47 +01:00
|
|
|
x, y, 2, subpriority);
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxMonsSprites[boxPosition] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxMonsSprites[boxPosition]->sDistance = distance;
|
|
|
|
sStorage->boxMonsSprites[boxPosition]->sSpeed = speed;
|
|
|
|
sStorage->boxMonsSprites[boxPosition]->sScrollInDestX = xDest;
|
|
|
|
sStorage->boxMonsSprites[boxPosition]->callback = SpriteCB_BoxMonIconScrollIn;
|
2021-04-18 01:28:31 +02:00
|
|
|
iconsCreated++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
2021-04-16 11:14:35 +02:00
|
|
|
boxPosition += IN_BOX_COLUMNS;
|
2018-12-15 23:58:47 +01:00
|
|
|
y += 24;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 01:28:31 +02:00
|
|
|
// Separate case for Move Items mode is used
|
|
|
|
// to create the icons with the proper blend
|
2021-04-16 11:14:35 +02:00
|
|
|
for (i = 0; i < IN_BOX_ROWS; i++)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxSpecies[boxPosition] != SPECIES_NONE)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxMonsSprites[boxPosition] = CreateMonIconSprite(sStorage->boxSpecies[boxPosition],
|
|
|
|
sStorage->boxPersonalities[boxPosition],
|
2018-12-15 23:58:47 +01:00
|
|
|
x, y, 2, subpriority);
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxMonsSprites[boxPosition] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxMonsSprites[boxPosition]->sDistance = distance;
|
|
|
|
sStorage->boxMonsSprites[boxPosition]->sSpeed = speed;
|
|
|
|
sStorage->boxMonsSprites[boxPosition]->sScrollInDestX = xDest;
|
|
|
|
sStorage->boxMonsSprites[boxPosition]->callback = SpriteCB_BoxMonIconScrollIn;
|
2021-04-18 05:55:24 +02:00
|
|
|
if (GetBoxMonDataAt(sStorage->incomingBoxId, boxPosition, MON_DATA_HELD_ITEM) == ITEM_NONE)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND;
|
2021-04-18 01:28:31 +02:00
|
|
|
iconsCreated++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
2021-04-16 11:14:35 +02:00
|
|
|
boxPosition += IN_BOX_COLUMNS;
|
2018-12-15 23:58:47 +01:00
|
|
|
y += 24;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 01:28:31 +02:00
|
|
|
return iconsCreated;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 01:28:31 +02:00
|
|
|
#undef sDistance
|
|
|
|
#undef sSpeed
|
|
|
|
#undef sScrollInDestX
|
|
|
|
#undef sDelay
|
|
|
|
#undef sScrollOutX
|
|
|
|
|
|
|
|
static void InitBoxMonIconScroll(u8 boxId, s8 direction)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->iconScrollState = 0;
|
|
|
|
sStorage->iconScrollToBoxId = boxId;
|
|
|
|
sStorage->iconScrollDirection = direction;
|
|
|
|
sStorage->iconScrollDistance = 32;
|
|
|
|
sStorage->iconScrollSpeed = -(6 * direction);
|
|
|
|
sStorage->iconScrollNumIncoming = 0;
|
2021-04-18 05:55:24 +02:00
|
|
|
GetIncomingBoxMonData(boxId);
|
2018-12-15 23:58:47 +01:00
|
|
|
if (direction > 0)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->iconScrollCurColumn = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->iconScrollCurColumn = IN_BOX_COLUMNS - 1;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->iconScrollPos = (24 * sStorage->iconScrollCurColumn) + 100;
|
|
|
|
StartBoxMonIconsScrollOut(sStorage->iconScrollSpeed);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 01:28:31 +02:00
|
|
|
static bool8 UpdateBoxMonIconScroll(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->iconScrollDistance != 0)
|
|
|
|
sStorage->iconScrollDistance--;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->iconScrollState)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->iconScrollPos += sStorage->iconScrollSpeed;
|
|
|
|
if (sStorage->iconScrollPos <= 64 || sStorage->iconScrollPos >= 252)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 01:28:31 +02:00
|
|
|
// A column of icons has gone offscreen, destroy them
|
2021-04-18 05:40:27 +02:00
|
|
|
DestroyBoxMonIconsInColumn(sStorage->iconScrollCurColumn);
|
|
|
|
sStorage->iconScrollPos += sStorage->iconScrollDirection * 24;
|
|
|
|
sStorage->iconScrollState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-18 01:28:31 +02:00
|
|
|
// Create the new incoming column of icons
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->iconScrollPos += sStorage->iconScrollSpeed;
|
|
|
|
sStorage->iconScrollNumIncoming += CreateBoxMonIconsInColumn(sStorage->iconScrollCurColumn, sStorage->iconScrollDistance, sStorage->iconScrollSpeed);
|
2021-04-18 01:28:31 +02:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if ((sStorage->iconScrollDirection > 0 && sStorage->iconScrollCurColumn == IN_BOX_COLUMNS - 1)
|
|
|
|
|| (sStorage->iconScrollDirection < 0 && sStorage->iconScrollCurColumn == 0))
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 01:28:31 +02:00
|
|
|
// Scroll has reached final column
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->iconScrollState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 01:28:31 +02:00
|
|
|
// Continue scrolling
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->iconScrollCurColumn += sStorage->iconScrollDirection;
|
|
|
|
sStorage->iconScrollState = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-18 01:28:31 +02:00
|
|
|
// Wait to make sure all icons have arrived
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->iconScrollNumIncoming == 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->iconScrollDistance++;
|
2018-12-15 23:58:47 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
static void GetIncomingBoxMonData(u8 boxId)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
s32 i, j, boxPosition;
|
|
|
|
|
|
|
|
boxPosition = 0;
|
2021-04-16 11:14:35 +02:00
|
|
|
for (i = 0; i < IN_BOX_ROWS; i++)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 11:14:35 +02:00
|
|
|
for (j = 0; j < IN_BOX_COLUMNS; j++)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxSpecies[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2);
|
|
|
|
if (sStorage->boxSpecies[boxPosition] != SPECIES_NONE)
|
|
|
|
sStorage->boxPersonalities[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY);
|
2018-12-15 23:58:47 +01:00
|
|
|
boxPosition++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->incomingBoxId = boxId;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void DestroyBoxMonIconAtPosition(u8 boxPosition)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxMonsSprites[boxPosition] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
DestroyBoxMonIcon(sStorage->boxMonsSprites[boxPosition]);
|
|
|
|
sStorage->boxMonsSprites[boxPosition] = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void SetBoxMonIconObjMode(u8 boxPosition, u8 objMode)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxMonsSprites[boxPosition] != NULL)
|
|
|
|
sStorage->boxMonsSprites[boxPosition]->oam.objMode = objMode;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static void CreatePartyMonsSprites(bool8 visible)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u16 i, count;
|
|
|
|
u16 species = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES2);
|
|
|
|
u32 personality = GetMonData(&gPlayerParty[0], MON_DATA_PERSONALITY);
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->partySprites[0] = CreateMonIconSprite(species, personality, 104, 64, 1, 12);
|
2018-12-15 23:58:47 +01:00
|
|
|
count = 1;
|
|
|
|
for (i = 1; i < PARTY_SIZE; i++)
|
|
|
|
{
|
|
|
|
species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2);
|
|
|
|
if (species != SPECIES_NONE)
|
|
|
|
{
|
|
|
|
personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->partySprites[i] = CreateMonIconSprite(species, personality, 152, 8 * (3 * (i - 1)) + 16, 1, 12);
|
2018-12-15 23:58:47 +01:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->partySprites[i] = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
if (!visible)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sStorage->partySprites[i]->y -= DISPLAY_HEIGHT;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->partySprites[i]->invisible = TRUE;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption == OPTION_MOVE_ITEMS)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
for (i = 0; i < PARTY_SIZE; i++)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->partySprites[i] != NULL && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == ITEM_NONE)
|
|
|
|
sStorage->partySprites[i]->oam.objMode = ST_OAM_OBJ_BLEND;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 20:33:00 +02:00
|
|
|
static void CompactPartySprites(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 20:33:00 +02:00
|
|
|
u16 i, targetSlot;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->numPartyToCompact = 0;
|
2021-04-17 20:33:00 +02:00
|
|
|
for (i = 0, targetSlot = 0; i < PARTY_SIZE; i++)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->partySprites[i] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 20:33:00 +02:00
|
|
|
if (i != targetSlot)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
MovePartySpriteToNextSlot(sStorage->partySprites[i], targetSlot);
|
|
|
|
sStorage->partySprites[i] = NULL;
|
|
|
|
sStorage->numPartyToCompact++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-17 20:33:00 +02:00
|
|
|
targetSlot++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 20:33:00 +02:00
|
|
|
static u8 GetNumPartySpritesCompacting(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
return sStorage->numPartyToCompact;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 20:33:00 +02:00
|
|
|
#define sPartyId data[1]
|
|
|
|
#define sMonX data[2]
|
|
|
|
#define sMonY data[3]
|
|
|
|
#define sSpeedX data[4]
|
|
|
|
#define sSpeedY data[5]
|
|
|
|
#define sMoveSteps data[6]
|
|
|
|
|
|
|
|
static void MovePartySpriteToNextSlot(struct Sprite *sprite, u16 partyId)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
s16 x, y;
|
|
|
|
|
2021-04-17 20:33:00 +02:00
|
|
|
sprite->sPartyId = partyId;
|
2018-12-15 23:58:47 +01:00
|
|
|
if (partyId == 0)
|
|
|
|
x = 104, y = 64;
|
|
|
|
else
|
|
|
|
x = 152, y = 8 * (3 * (partyId - 1)) + 16;
|
|
|
|
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->sMonX = (u16)(sprite->x) * 8;
|
|
|
|
sprite->sMonY = (u16)(sprite->y) * 8;
|
2021-04-17 20:33:00 +02:00
|
|
|
sprite->sSpeedX = ((x * 8) - sprite->sMonX) / 8;
|
|
|
|
sprite->sSpeedY = ((y * 8) - sprite->sMonY) / 8;
|
2018-12-15 23:58:47 +01:00
|
|
|
sprite->data[6] = 8;
|
2021-04-17 20:33:00 +02:00
|
|
|
sprite->callback = SpriteCB_MovePartyMonToNextSlot;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 20:33:00 +02:00
|
|
|
static void SpriteCB_MovePartyMonToNextSlot(struct Sprite *sprite)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 20:33:00 +02:00
|
|
|
if (sprite->sMoveSteps != 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 20:33:00 +02:00
|
|
|
s16 x = sprite->sMonX += sprite->sSpeedX;
|
|
|
|
s16 y = sprite->sMonY += sprite->sSpeedY;
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = x / 8u;
|
|
|
|
sprite->y = y / 8u;
|
2021-04-17 20:33:00 +02:00
|
|
|
sprite->sMoveSteps--;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-17 20:33:00 +02:00
|
|
|
if (sprite->sPartyId == 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = 104;
|
|
|
|
sprite->y = 64;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = 152;
|
|
|
|
sprite->y = 8 * (3 * (sprite->sPartyId - 1)) + 16;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
sprite->callback = SpriteCallbackDummy;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->partySprites[sprite->sPartyId] = sprite;
|
|
|
|
sStorage->numPartyToCompact--;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 20:33:00 +02:00
|
|
|
#undef sPartyId
|
|
|
|
#undef sMonX
|
|
|
|
#undef sMonY
|
|
|
|
#undef sSpeedX
|
|
|
|
#undef sSpeedY
|
|
|
|
#undef sMoveSteps
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void DestroyMovingMonIcon(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->movingMonSprite != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
DestroyBoxMonIcon(sStorage->movingMonSprite);
|
|
|
|
sStorage->movingMonSprite = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void MovePartySprites(s16 yDelta)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u16 i, posY;
|
|
|
|
|
|
|
|
for (i = 0; i < PARTY_SIZE; i++)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->partySprites[i] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sStorage->partySprites[i]->y += yDelta;
|
|
|
|
posY = sStorage->partySprites[i]->y + sStorage->partySprites[i]->y2 + sStorage->partySprites[i]->centerToCornerVecY;
|
2018-12-15 23:58:47 +01:00
|
|
|
posY += 16;
|
|
|
|
if (posY > 192)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->partySprites[i]->invisible = TRUE;
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->partySprites[i]->invisible = FALSE;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void DestroyPartyMonIcon(u8 partyId)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->partySprites[partyId] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
DestroyBoxMonIcon(sStorage->partySprites[partyId]);
|
|
|
|
sStorage->partySprites[partyId] = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void DestroyAllPartyMonIcons(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
for (i = 0; i < PARTY_SIZE; i++)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->partySprites[i] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
DestroyBoxMonIcon(sStorage->partySprites[i]);
|
|
|
|
sStorage->partySprites[i] = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void SetPartyMonIconObjMode(u8 partyId, u8 objMode)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->partySprites[partyId] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->partySprites[partyId]->oam.objMode = objMode;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void SetMovingMonSprite(u8 mode, u8 id)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (mode == MODE_PARTY)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingMonSprite = sStorage->partySprites[id];
|
|
|
|
sStorage->partySprites[id] = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else if (mode == MODE_BOX)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingMonSprite = sStorage->boxMonsSprites[id];
|
|
|
|
sStorage->boxMonsSprites[id] = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingMonSprite->callback = SpriteCB_HeldMon;
|
|
|
|
sStorage->movingMonSprite->oam.priority = GetMonIconPriorityByCursorPos();
|
|
|
|
sStorage->movingMonSprite->subpriority = 7;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
static void SetPlacedMonSprite(u8 boxId, u8 position)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (boxId == TOTAL_BOXES_COUNT) // party mon
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->partySprites[position] = sStorage->movingMonSprite;
|
|
|
|
sStorage->partySprites[position]->oam.priority = 1;
|
|
|
|
sStorage->partySprites[position]->subpriority = 12;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxMonsSprites[position] = sStorage->movingMonSprite;
|
|
|
|
sStorage->boxMonsSprites[position]->oam.priority = 2;
|
|
|
|
sStorage->boxMonsSprites[position]->subpriority = 19 - (position % IN_BOX_COLUMNS);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingMonSprite->callback = SpriteCallbackDummy;
|
|
|
|
sStorage->movingMonSprite = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
static void SaveMonSpriteAtPos(u8 boxId, u8 position)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (boxId == TOTAL_BOXES_COUNT) // party mon
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->shiftMonSpritePtr = &sStorage->partySprites[position];
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->shiftMonSpritePtr = &sStorage->boxMonsSprites[position];
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingMonSprite->callback = SpriteCallbackDummy;
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->shiftTimer = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
static bool8 MoveShiftingMons(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:55:24 +02:00
|
|
|
if (sStorage->shiftTimer == 16)
|
2018-12-15 23:58:47 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->shiftTimer++;
|
|
|
|
if (sStorage->shiftTimer & 1)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
(*sStorage->shiftMonSpritePtr)->y--;
|
|
|
|
sStorage->movingMonSprite->y++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-07-07 15:11:52 +02:00
|
|
|
(*sStorage->shiftMonSpritePtr)->x2 = gSineTable[sStorage->shiftTimer * 8] / 16;
|
|
|
|
sStorage->movingMonSprite->x2 = -(gSineTable[sStorage->shiftTimer * 8] / 16);
|
2021-04-18 05:55:24 +02:00
|
|
|
if (sStorage->shiftTimer == 8)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->movingMonSprite->oam.priority = (*sStorage->shiftMonSpritePtr)->oam.priority;
|
|
|
|
sStorage->movingMonSprite->subpriority = (*sStorage->shiftMonSpritePtr)->subpriority;
|
|
|
|
(*sStorage->shiftMonSpritePtr)->oam.priority = GetMonIconPriorityByCursorPos();
|
|
|
|
(*sStorage->shiftMonSpritePtr)->subpriority = 7;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
if (sStorage->shiftTimer == 16)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
struct Sprite *sprite = sStorage->movingMonSprite;
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->movingMonSprite = (*sStorage->shiftMonSpritePtr);
|
|
|
|
*sStorage->shiftMonSpritePtr = sprite;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingMonSprite->callback = SpriteCB_HeldMon;
|
2021-04-18 05:55:24 +02:00
|
|
|
(*sStorage->shiftMonSpritePtr)->callback = SpriteCallbackDummy;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void SetReleaseMon(u8 mode, u8 position)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case MODE_PARTY:
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->releaseMonSpritePtr = &sStorage->partySprites[position];
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case MODE_BOX:
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->releaseMonSpritePtr = &sStorage->boxMonsSprites[position];
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
2020-03-09 02:27:29 +01:00
|
|
|
case MODE_MOVE:
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->releaseMonSpritePtr = &sStorage->movingMonSprite;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (*sStorage->releaseMonSpritePtr != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
InitSpriteAffineAnim(*sStorage->releaseMonSpritePtr);
|
|
|
|
(*sStorage->releaseMonSpritePtr)->oam.affineMode = ST_OAM_AFFINE_NORMAL;
|
|
|
|
(*sStorage->releaseMonSpritePtr)->affineAnims = sAffineAnims_ReleaseMon;
|
|
|
|
StartSpriteAffineAnim(*sStorage->releaseMonSpritePtr, RELEASE_ANIM_RELEASE);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static bool8 TryHideReleaseMonSprite(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (*sStorage->releaseMonSpritePtr == NULL
|
|
|
|
|| (*sStorage->releaseMonSpritePtr)->invisible)
|
2018-12-15 23:58:47 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if ((*sStorage->releaseMonSpritePtr)->affineAnimEnded)
|
|
|
|
(*sStorage->releaseMonSpritePtr)->invisible = TRUE;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void DestroyReleaseMonIcon(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (*sStorage->releaseMonSpritePtr != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
FreeOamMatrix((*sStorage->releaseMonSpritePtr)->oam.matrixNum);
|
|
|
|
DestroyBoxMonIcon(*sStorage->releaseMonSpritePtr);
|
|
|
|
*sStorage->releaseMonSpritePtr = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void ReshowReleaseMon(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (*sStorage->releaseMonSpritePtr != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
(*sStorage->releaseMonSpritePtr)->invisible = FALSE;
|
|
|
|
StartSpriteAffineAnim(*sStorage->releaseMonSpritePtr, RELEASE_ANIM_CAME_BACK);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static bool8 ResetReleaseMonSpritePtr(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->releaseMonSpritePtr == NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if ((*sStorage->releaseMonSpritePtr)->affineAnimEnded)
|
|
|
|
sStorage->releaseMonSpritePtr = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void SetMovingMonPriority(u8 priority)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingMonSprite->oam.priority = priority;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void SpriteCB_HeldMon(struct Sprite *sprite)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = sStorage->cursorSprite->x;
|
|
|
|
sprite->y = sStorage->cursorSprite->y + sStorage->cursorSprite->y2 + 4;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-29 03:58:38 +02:00
|
|
|
static u16 TryLoadMonIconTiles(u16 species, u32 personality)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
u16 i, offset;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
// Search icon list for this species
|
|
|
|
for (i = 0; i < MAX_MON_ICONS; i++)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->iconSpeciesList[i] == species)
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
if (i == MAX_MON_ICONS)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
// Species not present in the list
|
|
|
|
// Find first empty spot in the list to put it
|
|
|
|
for (i = 0; i < MAX_MON_ICONS; i++)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->iconSpeciesList[i] == 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
}
|
2021-04-16 05:27:05 +02:00
|
|
|
|
|
|
|
// Failed to find an empty spot
|
|
|
|
if (i == MAX_MON_ICONS)
|
2018-12-15 23:58:47 +01:00
|
|
|
return 0xFFFF;
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
// Add species to icon list and load tiles
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->iconSpeciesList[i] = species;
|
|
|
|
sStorage->numIconsPerSpecies[i]++;
|
2021-04-16 05:27:05 +02:00
|
|
|
offset = 16 * i;
|
2021-04-29 03:58:38 +02:00
|
|
|
CpuCopy32(GetMonIconTiles(species, personality), (void*)(OBJ_VRAM0) + offset * 32, 0x200);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
return offset;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void RemoveSpeciesFromIconList(u16 species)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
for (i = 0; i < MAX_MON_ICONS; i++)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->iconSpeciesList[i] == species)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (--sStorage->numIconsPerSpecies[i] == 0)
|
|
|
|
sStorage->iconSpeciesList[i] = SPECIES_NONE;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct Sprite *CreateMonIconSprite(u16 species, u32 personality, s16 x, s16 y, u8 oamPriority, u8 subpriority)
|
|
|
|
{
|
|
|
|
u16 tileNum;
|
|
|
|
u8 spriteId;
|
2021-04-16 05:27:05 +02:00
|
|
|
struct SpriteTemplate template = sSpriteTemplate_MonIcon;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
|
|
|
species = GetIconSpecies(species, personality);
|
2021-04-16 01:17:53 +02:00
|
|
|
template.paletteTag = PALTAG_MON_ICON_0 + gMonIconPaletteIndices[species];
|
2021-04-29 03:58:38 +02:00
|
|
|
tileNum = TryLoadMonIconTiles(species, personality);
|
2018-12-15 23:58:47 +01:00
|
|
|
if (tileNum == 0xFFFF)
|
|
|
|
return NULL;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
spriteId = CreateSprite(&template, x, y, subpriority);
|
2018-12-15 23:58:47 +01:00
|
|
|
if (spriteId == MAX_SPRITES)
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
RemoveSpeciesFromIconList(species);
|
2018-12-15 23:58:47 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
gSprites[spriteId].oam.tileNum = tileNum;
|
|
|
|
gSprites[spriteId].oam.priority = oamPriority;
|
|
|
|
gSprites[spriteId].data[0] = species;
|
|
|
|
return &gSprites[spriteId];
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void DestroyBoxMonIcon(struct Sprite *sprite)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
RemoveSpeciesFromIconList(sprite->data[0]);
|
2018-12-15 23:58:47 +01:00
|
|
|
DestroySprite(sprite);
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: General box
|
|
|
|
//
|
|
|
|
// Some basic box functions, including initializing the box and scrolling.
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
#define tState data[0]
|
|
|
|
#define tDmaIdx data[1]
|
|
|
|
#define tBoxId data[2]
|
|
|
|
|
|
|
|
static void CreateInitBoxTask(u8 boxId)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
u8 taskId = CreateTask(Task_InitBox, 2);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
gTasks[taskId].tBoxId = boxId;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static bool8 IsInitBoxActive(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
return FuncIsActiveTask(Task_InitBox);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static void Task_InitBox(u8 taskId)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
switch (task->tState)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->wallpaperOffset = 0;
|
|
|
|
sStorage->bg2_X = 0;
|
|
|
|
task->tDmaIdx = RequestDma3Fill(0, sStorage->wallpaperBgTilemapBuffer, sizeof(sStorage->wallpaperBgTilemapBuffer), 1);
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-15 20:06:25 +02:00
|
|
|
if (CheckForSpaceForDma3Request(task->tDmaIdx) == -1)
|
2018-12-15 23:58:47 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
SetBgTilemapBuffer(2, sStorage->wallpaperBgTilemapBuffer);
|
2018-12-15 23:58:47 +01:00
|
|
|
ShowBg(2);
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-15 20:06:25 +02:00
|
|
|
LoadWallpaperGfx(task->tBoxId, 0);
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!WaitForWallpaperGfxLoad())
|
|
|
|
return;
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
InitBoxTitle(task->tBoxId);
|
|
|
|
CreateBoxScrollArrows();
|
|
|
|
InitBoxMonSprites(task->tBoxId);
|
2018-12-15 23:58:47 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BG2CNT, BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(27) | BGCNT_TXT512x256);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
DestroyTask(taskId);
|
|
|
|
break;
|
|
|
|
default:
|
2021-04-15 20:06:25 +02:00
|
|
|
task->tState = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
task->tState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
#undef tState
|
|
|
|
#undef tDmaIdx
|
|
|
|
#undef tBoxId
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void SetUpScrollToBox(u8 boxId)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2020-07-19 03:58:01 +02:00
|
|
|
s8 direction = DetermineBoxScrollDirection(boxId);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->scrollSpeed = (direction > 0) ? 6 : -6;
|
|
|
|
sStorage->scrollUnused1 = (direction > 0) ? 1 : 2;
|
|
|
|
sStorage->scrollTimer = 32;
|
|
|
|
sStorage->scrollToBoxIdUnused = boxId;
|
|
|
|
sStorage->scrollUnused2 = (direction <= 0) ? 5 : 0;
|
|
|
|
sStorage->scrollDirectionUnused = direction;
|
2021-04-15 20:06:25 +02:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->scrollUnused3 = (direction > 0) ? 264 : 56;
|
|
|
|
sStorage->scrollUnused4 = (direction <= 0) ? 5 : 0;
|
|
|
|
sStorage->scrollUnused5 = 0;
|
|
|
|
sStorage->scrollUnused6 = 2;
|
|
|
|
sStorage->scrollToBoxId = boxId;
|
|
|
|
sStorage->scrollDirection = direction;
|
|
|
|
sStorage->scrollState = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static bool8 ScrollToBox(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 01:28:31 +02:00
|
|
|
bool8 iconsScrolling;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->scrollState)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-18 05:40:27 +02:00
|
|
|
LoadWallpaperGfx(sStorage->scrollToBoxId, sStorage->scrollDirection);
|
|
|
|
sStorage->scrollState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
case 1:
|
|
|
|
if (!WaitForWallpaperGfxLoad())
|
|
|
|
return TRUE;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
InitBoxMonIconScroll(sStorage->scrollToBoxId, sStorage->scrollDirection);
|
|
|
|
CreateIncomingBoxTitle(sStorage->scrollToBoxId, sStorage->scrollDirection);
|
|
|
|
StartBoxScrollArrowsSlide(sStorage->scrollDirection);
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-18 01:28:31 +02:00
|
|
|
iconsScrolling = UpdateBoxMonIconScroll();
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->scrollTimer != 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->bg2_X += sStorage->scrollSpeed;
|
|
|
|
if (--sStorage->scrollTimer != 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
return TRUE;
|
2021-04-15 20:06:25 +02:00
|
|
|
CycleBoxTitleSprites();
|
|
|
|
StopBoxScrollArrowsSlide();
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-18 01:28:31 +02:00
|
|
|
return iconsScrolling;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->scrollState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-07-19 03:58:01 +02:00
|
|
|
static s8 DetermineBoxScrollDirection(u8 boxId)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 currentBox = StorageGetCurrentBox();
|
|
|
|
|
|
|
|
for (i = 0; currentBox != boxId; i++)
|
|
|
|
{
|
|
|
|
currentBox++;
|
|
|
|
if (currentBox >= TOTAL_BOXES_COUNT)
|
|
|
|
currentBox = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (i < TOTAL_BOXES_COUNT / 2) ? 1 : -1;
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: Wallpaper gfx
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void SetWallpaperForCurrentBox(u8 wallpaperId)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u8 boxId = StorageGetCurrentBox();
|
|
|
|
SetBoxWallpaper(boxId, wallpaperId);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->wallpaperChangeState = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 DoWallpaperGfxChange(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->wallpaperChangeState)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-18 05:55:24 +02:00
|
|
|
BeginNormalPaletteFade(sStorage->wallpaperPalBits, 1, 0, 16, RGB_WHITEALPHA);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->wallpaperChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!UpdatePaletteFade())
|
|
|
|
{
|
|
|
|
u8 curBox = StorageGetCurrentBox();
|
|
|
|
LoadWallpaperGfx(curBox, 0);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->wallpaperChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (WaitForWallpaperGfxLoad() == TRUE)
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
CycleBoxTitleColor();
|
2021-04-18 05:55:24 +02:00
|
|
|
BeginNormalPaletteFade(sStorage->wallpaperPalBits, 1, 16, 0, RGB_WHITEALPHA);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->wallpaperChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!UpdatePaletteFade())
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->wallpaperChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void LoadWallpaperGfx(u8 boxId, s8 direction)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u8 wallpaperId;
|
2021-04-15 20:06:25 +02:00
|
|
|
const struct Wallpaper *wallpaper;
|
2018-12-15 23:58:47 +01:00
|
|
|
void *iconGfx;
|
2021-04-15 20:06:25 +02:00
|
|
|
u32 tilesSize, iconSize;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->wallpaperLoadState = 0;
|
|
|
|
sStorage->wallpaperLoadBoxId = boxId;
|
|
|
|
sStorage->wallpaperLoadDir = direction;
|
|
|
|
if (sStorage->wallpaperLoadDir != 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->wallpaperOffset = (sStorage->wallpaperOffset == 0);
|
|
|
|
TrimOldWallpaper(sStorage->wallpaperBgTilemapBuffer);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
wallpaperId = GetBoxWallpaper(sStorage->wallpaperLoadBoxId);
|
2018-12-15 23:58:47 +01:00
|
|
|
if (wallpaperId != WALLPAPER_FRIENDS)
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
wallpaper = &sWallpapers[wallpaperId];
|
2021-04-18 05:40:27 +02:00
|
|
|
LZ77UnCompWram(wallpaper->tilemap, sStorage->wallpaperTilemap);
|
|
|
|
DrawWallpaper(sStorage->wallpaperTilemap, sStorage->wallpaperLoadDir, sStorage->wallpaperOffset);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->wallpaperLoadDir != 0)
|
|
|
|
LoadPalette(wallpaper->palettes, (sStorage->wallpaperOffset * 32) + 0x40, 0x40);
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
CpuCopy16(wallpaper->palettes, &gPlttBufferUnfaded[(sStorage->wallpaperOffset * 32) + 0x40], 0x40);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->wallpaperTiles = malloc_and_decompress(wallpaper->tiles, &tilesSize);
|
|
|
|
LoadBgTiles(2, sStorage->wallpaperTiles, tilesSize, sStorage->wallpaperOffset << 8);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
wallpaper = &sWaldaWallpapers[GetWaldaWallpaperPatternId()];
|
2021-04-18 05:40:27 +02:00
|
|
|
LZ77UnCompWram(wallpaper->tilemap, sStorage->wallpaperTilemap);
|
|
|
|
DrawWallpaper(sStorage->wallpaperTilemap, sStorage->wallpaperLoadDir, sStorage->wallpaperOffset);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
CpuCopy16(wallpaper->palettes, sStorage->wallpaperTilemap, 0x40);
|
|
|
|
CpuCopy16(GetWaldaWallpaperColorsPtr(), &sStorage->wallpaperTilemap[1], 4);
|
|
|
|
CpuCopy16(GetWaldaWallpaperColorsPtr(), &sStorage->wallpaperTilemap[17], 4);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->wallpaperLoadDir != 0)
|
|
|
|
LoadPalette(sStorage->wallpaperTilemap, (sStorage->wallpaperOffset * 32) + 0x40, 0x40);
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
CpuCopy16(sStorage->wallpaperTilemap, &gPlttBufferUnfaded[(sStorage->wallpaperOffset * 32) + 0x40], 0x40);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->wallpaperTiles = malloc_and_decompress(wallpaper->tiles, &tilesSize);
|
2021-04-15 20:06:25 +02:00
|
|
|
iconGfx = malloc_and_decompress(sWaldaWallpaperIcons[GetWaldaWallpaperIconId()], &iconSize);
|
2021-04-18 05:40:27 +02:00
|
|
|
CpuCopy32(iconGfx, sStorage->wallpaperTiles + 0x800, iconSize);
|
2018-12-15 23:58:47 +01:00
|
|
|
Free(iconGfx);
|
2021-04-18 05:40:27 +02:00
|
|
|
LoadBgTiles(2, sStorage->wallpaperTiles, tilesSize, sStorage->wallpaperOffset << 8);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CopyBgTilemapBufferToVram(2);
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static bool32 WaitForWallpaperGfxLoad(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (IsDma3ManagerBusyWithBgCopy())
|
|
|
|
return FALSE;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->wallpaperTiles != NULL)
|
|
|
|
FREE_AND_SET_NULL(sStorage->wallpaperTiles);
|
2021-04-15 23:31:50 +02:00
|
|
|
|
2018-12-15 23:58:47 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static void DrawWallpaper(const void *tilemap, s8 direction, u8 offset)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-05-25 10:03:11 +02:00
|
|
|
s16 var = offset * 256;
|
|
|
|
s16 var2 = (offset * 2) + 3;
|
2021-04-18 05:40:27 +02:00
|
|
|
s16 x = ((sStorage->bg2_X / 8 + 10) + (direction * 24)) & 0x3F;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-05-25 10:03:11 +02:00
|
|
|
CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 0x14, 0x12, x, 2, 0x14, 0x12, 0x11, var, var2);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
|
|
|
if (direction == 0)
|
|
|
|
return;
|
2020-11-03 02:02:39 +01:00
|
|
|
if (direction > 0)
|
2021-05-25 10:32:47 +02:00
|
|
|
x += 0x14;
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
|
|
|
x -= 4;
|
|
|
|
|
|
|
|
FillBgTilemapBufferRect(2, 0, x, 2, 4, 0x12, 0x11);
|
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static void TrimOldWallpaper(void *tilemap)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
2021-04-15 20:06:25 +02:00
|
|
|
u16 *dest = tilemap;
|
2021-04-18 05:40:27 +02:00
|
|
|
s16 r3 = ((sStorage->bg2_X / 8) + 30) & 0x3F;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
|
|
|
if (r3 <= 31)
|
|
|
|
dest += r3 + 0x260;
|
|
|
|
else
|
|
|
|
dest += r3 + 0x640;
|
|
|
|
|
|
|
|
for (i = 0; i < 0x2C; i++)
|
|
|
|
{
|
|
|
|
*dest++ = 0;
|
|
|
|
r3 = (r3 + 1) & 0x3F;
|
|
|
|
if (r3 == 0)
|
|
|
|
dest -= 0x420;
|
|
|
|
if (r3 == 0x20)
|
|
|
|
dest += 0x3e0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: Box Title
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static void InitBoxTitle(u8 boxId)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u8 tagIndex;
|
2021-04-15 20:06:25 +02:00
|
|
|
s16 x;
|
2018-12-15 23:58:47 +01:00
|
|
|
u16 i;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
struct SpriteSheet spriteSheet = {sStorage->boxTitleTiles, 0x200, GFXTAG_BOX_TITLE};
|
2018-12-15 23:58:47 +01:00
|
|
|
struct SpritePalette palettes[] = {
|
2021-04-18 05:40:27 +02:00
|
|
|
{sStorage->boxTitlePal, PALTAG_BOX_TITLE},
|
2018-12-15 23:58:47 +01:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
u16 wallpaperId = GetBoxWallpaper(boxId);
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxTitlePal[14] = sBoxTitleColors[wallpaperId][0]; // Shadow color
|
|
|
|
sStorage->boxTitlePal[15] = sBoxTitleColors[wallpaperId][1]; // Text Color
|
2018-12-15 23:58:47 +01:00
|
|
|
LoadSpritePalettes(palettes);
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->wallpaperPalBits = 0x3f0;
|
2021-04-15 20:06:25 +02:00
|
|
|
|
|
|
|
tagIndex = IndexOfSpritePaletteTag(PALTAG_BOX_TITLE);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxTitlePalOffset = 0x10e + 16 * tagIndex;
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->wallpaperPalBits |= 0x10000 << tagIndex;
|
2021-04-15 20:06:25 +02:00
|
|
|
|
|
|
|
// The below seems intended to have separately tracked
|
|
|
|
// the incoming wallpaper title's palette, but as they now
|
|
|
|
// share a palette tag, all colors (and fields in some cases)
|
|
|
|
// this is redundant along with the use of boxTitleAltPalOffset
|
|
|
|
tagIndex = IndexOfSpritePaletteTag(PALTAG_BOX_TITLE);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxTitleAltPalOffset = 0x10e + 16 * tagIndex;
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->wallpaperPalBits |= 0x10000 << tagIndex;
|
2021-04-15 20:06:25 +02:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
StringCopyPadded(sStorage->boxTitleText, GetBoxNamePtr(boxId), 0, 8);
|
|
|
|
DrawTextWindowAndBufferTiles(sStorage->boxTitleText, sStorage->boxTitleTiles, 0, 0, 2);
|
2018-12-15 23:58:47 +01:00
|
|
|
LoadSpriteSheet(&spriteSheet);
|
2021-04-15 20:06:25 +02:00
|
|
|
x = GetBoxTitleBaseX(GetBoxNamePtr(boxId));
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
// Title is split across two sprites
|
2018-12-15 23:58:47 +01:00
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
u8 spriteId = CreateSprite(&sSpriteTemplate_BoxTitle, x + i * 32, 28, 24);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->curBoxTitleSprites[i] = &gSprites[spriteId];
|
|
|
|
StartSpriteAnim(sStorage->curBoxTitleSprites[i], i);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxTitleCycleId = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
// Sprite data for moving title text
|
|
|
|
#define sSpeed data[0]
|
|
|
|
// Flipped between incoming/outgoing for some reason
|
|
|
|
#define sIncomingX data[1]
|
|
|
|
#define sIncomingDelay data[2]
|
|
|
|
#define sOutgoingDelay data[1]
|
|
|
|
#define sOutgoingX data[2]
|
|
|
|
|
|
|
|
static void CreateIncomingBoxTitle(u8 boxId, s8 direction)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
u16 palOffset;
|
|
|
|
s16 x, adjustedX;
|
2018-12-15 23:58:47 +01:00
|
|
|
u16 i;
|
2021-04-18 05:40:27 +02:00
|
|
|
struct SpriteSheet spriteSheet = {sStorage->boxTitleTiles, 0x200, GFXTAG_BOX_TITLE};
|
2021-04-15 20:06:25 +02:00
|
|
|
struct SpriteTemplate template = sSpriteTemplate_BoxTitle;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->boxTitleCycleId = (sStorage->boxTitleCycleId == 0);
|
|
|
|
if (sStorage->boxTitleCycleId == 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
spriteSheet.tag = GFXTAG_BOX_TITLE;
|
2021-04-18 05:40:27 +02:00
|
|
|
palOffset = sStorage->boxTitlePalOffset;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
spriteSheet.tag = GFXTAG_BOX_TITLE_ALT;
|
2021-04-18 05:40:27 +02:00
|
|
|
palOffset = sStorage->boxTitlePalOffset;
|
2021-04-15 20:06:25 +02:00
|
|
|
template.tileTag = GFXTAG_BOX_TITLE_ALT;
|
|
|
|
template.paletteTag = PALTAG_BOX_TITLE;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
StringCopyPadded(sStorage->boxTitleText, GetBoxNamePtr(boxId), 0, 8);
|
|
|
|
DrawTextWindowAndBufferTiles(sStorage->boxTitleText, sStorage->boxTitleTiles, 0, 0, 2);
|
2018-12-15 23:58:47 +01:00
|
|
|
LoadSpriteSheet(&spriteSheet);
|
2021-04-17 23:28:18 +02:00
|
|
|
LoadPalette(sBoxTitleColors[GetBoxWallpaper(boxId)], palOffset, sizeof(sBoxTitleColors[0]));
|
2021-04-15 20:06:25 +02:00
|
|
|
x = GetBoxTitleBaseX(GetBoxNamePtr(boxId));
|
|
|
|
adjustedX = x;
|
|
|
|
adjustedX += direction * 192;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
// Title is split across two sprites
|
2018-12-15 23:58:47 +01:00
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
u8 spriteId = CreateSprite(&template, i * 32 + adjustedX, 28, 24);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->nextBoxTitleSprites[i] = &gSprites[spriteId];
|
|
|
|
sStorage->nextBoxTitleSprites[i]->sSpeed = (-direction) * 6;
|
|
|
|
sStorage->nextBoxTitleSprites[i]->sIncomingX = i * 32 + x;
|
|
|
|
sStorage->nextBoxTitleSprites[i]->sIncomingDelay = 0;
|
|
|
|
sStorage->nextBoxTitleSprites[i]->callback = SpriteCB_IncomingBoxTitle;
|
|
|
|
StartSpriteAnim(sStorage->nextBoxTitleSprites[i], i);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->curBoxTitleSprites[i]->sSpeed = (-direction) * 6;
|
|
|
|
sStorage->curBoxTitleSprites[i]->sOutgoingDelay = 1;
|
|
|
|
sStorage->curBoxTitleSprites[i]->callback = SpriteCB_OutgoingBoxTitle;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static void CycleBoxTitleSprites(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxTitleCycleId == 0)
|
2021-04-15 20:06:25 +02:00
|
|
|
FreeSpriteTilesByTag(GFXTAG_BOX_TITLE_ALT);
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-15 20:06:25 +02:00
|
|
|
FreeSpriteTilesByTag(GFXTAG_BOX_TITLE);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->curBoxTitleSprites[0] = sStorage->nextBoxTitleSprites[0];
|
|
|
|
sStorage->curBoxTitleSprites[1] = sStorage->nextBoxTitleSprites[1];
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static void SpriteCB_IncomingBoxTitle(struct Sprite *sprite)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
if (sprite->sIncomingDelay != 0)
|
|
|
|
sprite->sIncomingDelay--;
|
2021-07-07 15:11:52 +02:00
|
|
|
else if ((sprite->x += sprite->sSpeed) == sprite->sIncomingX)
|
2018-12-15 23:58:47 +01:00
|
|
|
sprite->callback = SpriteCallbackDummy;
|
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static void SpriteCB_OutgoingBoxTitle(struct Sprite *sprite)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
if (sprite->sOutgoingDelay != 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
sprite->sOutgoingDelay--;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x += sprite->sSpeed;
|
|
|
|
sprite->sOutgoingX = sprite->x + sprite->x2;
|
2021-04-15 20:06:25 +02:00
|
|
|
if (sprite->sOutgoingX < 64 || sprite->sOutgoingX > DISPLAY_WIDTH + 16)
|
2018-12-15 23:58:47 +01:00
|
|
|
DestroySprite(sprite);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
#undef sSpeed
|
|
|
|
#undef sIncomingX
|
|
|
|
#undef sIncomingDelay
|
|
|
|
#undef sOutgoingDelay
|
|
|
|
#undef sOutgoingX
|
|
|
|
|
|
|
|
static void CycleBoxTitleColor(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u8 boxId = StorageGetCurrentBox();
|
|
|
|
u8 wallpaperId = GetBoxWallpaper(boxId);
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxTitleCycleId == 0)
|
|
|
|
CpuCopy16(sBoxTitleColors[wallpaperId], gPlttBufferUnfaded + sStorage->boxTitlePalOffset, 4);
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
CpuCopy16(sBoxTitleColors[wallpaperId], gPlttBufferUnfaded + sStorage->boxTitleAltPalOffset, 4);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static s16 GetBoxTitleBaseX(const u8 *string)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
return DISPLAY_WIDTH - 64 - GetStringWidth(1, string, 0) / 2;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: Scroll arrows
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
// Sprite data for box scroll arrows
|
|
|
|
#define sState data[0]
|
|
|
|
#define sTimer data[1]
|
|
|
|
#define sSpeed data[3]
|
|
|
|
|
|
|
|
static void CreateBoxScrollArrows(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
LoadSpriteSheet(&sSpriteSheet_Arrow);
|
2018-12-15 23:58:47 +01:00
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
u8 spriteId = CreateSprite(&sSpriteTemplate_Arrow, 92 + i * 136, 28, 22);
|
2018-12-15 23:58:47 +01:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
struct Sprite *sprite = &gSprites[spriteId];
|
|
|
|
StartSpriteAnim(sprite, i);
|
2021-04-15 20:06:25 +02:00
|
|
|
sprite->sSpeed = (i == 0) ? -1 : 1;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->arrowSprites[i] = sprite;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
2021-04-17 06:49:51 +02:00
|
|
|
if (IsCursorOnBoxTitle())
|
2021-04-15 20:06:25 +02:00
|
|
|
AnimateBoxScrollArrows(TRUE);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
// Slide box scroll arrows horizontally for box change
|
|
|
|
static void StartBoxScrollArrowsSlide(s8 direction)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sStorage->arrowSprites[i]->x2 = 0;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->arrowSprites[i]->sState = 2;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
if (direction < 0)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->arrowSprites[0]->sTimer = 29;
|
|
|
|
sStorage->arrowSprites[1]->sTimer = 5;
|
|
|
|
sStorage->arrowSprites[0]->data[2] = 72;
|
|
|
|
sStorage->arrowSprites[1]->data[2] = 72;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->arrowSprites[0]->sTimer = 5;
|
|
|
|
sStorage->arrowSprites[1]->sTimer = 29;
|
|
|
|
sStorage->arrowSprites[0]->data[2] = DISPLAY_WIDTH + 8;
|
|
|
|
sStorage->arrowSprites[1]->data[2] = DISPLAY_WIDTH + 8;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->arrowSprites[0]->data[7] = 0;
|
|
|
|
sStorage->arrowSprites[1]->data[7] = 1;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
// New box's scroll arrows have entered, stop sliding and set their position
|
|
|
|
static void StopBoxScrollArrowsSlide(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sStorage->arrowSprites[i]->x = 136 * i + 92;
|
|
|
|
sStorage->arrowSprites[i]->x2 = 0;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->arrowSprites[i]->invisible = FALSE;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-15 20:06:25 +02:00
|
|
|
AnimateBoxScrollArrows(TRUE);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
// Bounce scroll arrows while title is selected
|
|
|
|
static void AnimateBoxScrollArrows(bool8 animate)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
if (animate)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
// Start arrows moving
|
2018-12-15 23:58:47 +01:00
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->arrowSprites[i]->sState = 1;
|
|
|
|
sStorage->arrowSprites[i]->sTimer = 0;
|
|
|
|
sStorage->arrowSprites[i]->data[2] = 0;
|
|
|
|
sStorage->arrowSprites[i]->data[4] = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
// Stop arrows moving
|
2018-12-15 23:58:47 +01:00
|
|
|
for (i = 0; i < 2; i++)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->arrowSprites[i]->sState = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static void SpriteCB_Arrow(struct Sprite *sprite)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
switch (sprite->sState)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-15 20:06:25 +02:00
|
|
|
if (++sprite->sTimer > 3)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
sprite->sTimer = 0;
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 += sprite->sSpeed;
|
2018-12-15 23:58:47 +01:00
|
|
|
if (++sprite->data[2] > 5)
|
|
|
|
{
|
|
|
|
sprite->data[2] = 0;
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-15 20:06:25 +02:00
|
|
|
sprite->sState = 3;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x -= sStorage->scrollSpeed;
|
|
|
|
if (sprite->x <= 72 || sprite->x >= DISPLAY_WIDTH + 8)
|
2018-12-15 23:58:47 +01:00
|
|
|
sprite->invisible = TRUE;
|
2021-04-15 20:06:25 +02:00
|
|
|
if (--sprite->sTimer == 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = sprite->data[2];
|
2018-12-15 23:58:47 +01:00
|
|
|
sprite->invisible = FALSE;
|
2021-04-15 20:06:25 +02:00
|
|
|
sprite->sState = 4;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x -= sStorage->scrollSpeed;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
#undef sState
|
|
|
|
#undef sSpeed
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
// Arrows for Deposit/Jump Box selection
|
|
|
|
static struct Sprite *CreateChooseBoxArrows(u16 x, u16 y, u8 animId, u8 priority, u8 subpriority)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
u8 spriteId = CreateSprite(&sSpriteTemplate_Arrow, x, y, subpriority);
|
2018-12-15 23:58:47 +01:00
|
|
|
if (spriteId == MAX_SPRITES)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
animId %= 2;
|
|
|
|
StartSpriteAnim(&gSprites[spriteId], animId);
|
|
|
|
gSprites[spriteId].oam.priority = priority;
|
|
|
|
gSprites[spriteId].callback = SpriteCallbackDummy;
|
|
|
|
return &gSprites[spriteId];
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: Cursor movement
|
|
|
|
//
|
|
|
|
// The functions below generally handle the cursor's movement, including
|
|
|
|
// moving around the box and picking up/putting down Pokémon.
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
static void InitCursor(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_DEPOSIT)
|
2021-04-16 23:05:44 +02:00
|
|
|
sCursorArea = CURSOR_AREA_IN_BOX;
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-16 23:05:44 +02:00
|
|
|
sCursorArea = CURSOR_AREA_IN_PARTY;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
sCursorPosition = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
sIsMonBeingMoved = FALSE;
|
|
|
|
sMovingMonOrigBoxId = 0;
|
|
|
|
sMovingMonOrigBoxPos = 0;
|
2021-04-16 23:05:44 +02:00
|
|
|
sAutoActionOn = FALSE;
|
2021-04-17 06:49:51 +02:00
|
|
|
ClearSavedCursorPos();
|
|
|
|
CreateCursorSprites();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorPrevHorizPos = 1;
|
|
|
|
sStorage->inBoxMovingMode = MOVE_MODE_NORMAL;
|
2021-04-17 06:49:51 +02:00
|
|
|
TryRefreshDisplayMon();
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
static void InitCursorOnReopen(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
CreateCursorSprites();
|
2021-04-17 23:28:18 +02:00
|
|
|
ReshowDisplayMon();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorPrevHorizPos = 1;
|
|
|
|
sStorage->inBoxMovingMode = MOVE_MODE_NORMAL;
|
2018-12-15 23:58:47 +01:00
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingMon = sSavedMovingMon;
|
2018-12-16 21:10:01 +01:00
|
|
|
CreateMovingMonIcon();
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void GetCursorCoordsByPos(u8 cursorArea, u8 cursorPosition, u16 *x, u16 *y)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-16 21:10:01 +01:00
|
|
|
switch (cursorArea)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-16 21:10:01 +01:00
|
|
|
case CURSOR_AREA_IN_BOX:
|
2021-04-16 11:14:35 +02:00
|
|
|
*x = (cursorPosition % IN_BOX_COLUMNS) * 24 + 100;
|
|
|
|
*y = (cursorPosition / IN_BOX_COLUMNS) * 24 + 32;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
2018-12-16 21:10:01 +01:00
|
|
|
case CURSOR_AREA_IN_PARTY:
|
|
|
|
if (cursorPosition == 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
*x = 104;
|
|
|
|
*y = 52;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2018-12-16 21:10:01 +01:00
|
|
|
else if (cursorPosition == PARTY_SIZE)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
*x = 152;
|
|
|
|
*y = 132;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
*x = 152;
|
2018-12-16 21:10:01 +01:00
|
|
|
*y = (cursorPosition - 1) * 24 + 4;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-17 06:49:51 +02:00
|
|
|
case CURSOR_AREA_BOX_TITLE:
|
2021-04-16 05:27:05 +02:00
|
|
|
*x = 162;
|
|
|
|
*y = 12;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
2018-12-16 21:10:01 +01:00
|
|
|
case CURSOR_AREA_BUTTONS:
|
|
|
|
*y = sIsMonBeingMoved ? 8 : 14;
|
2021-04-16 05:27:05 +02:00
|
|
|
*x = cursorPosition * 88 + 120;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2021-04-16 05:27:05 +02:00
|
|
|
*x = 160;
|
|
|
|
*y = 96;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static u16 GetSpeciesAtCursorPosition(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
switch (sCursorArea)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case CURSOR_AREA_IN_PARTY:
|
2021-04-16 23:05:44 +02:00
|
|
|
return GetMonData(&gPlayerParty[sCursorPosition], MON_DATA_SPECIES);
|
2018-12-15 23:58:47 +01:00
|
|
|
case CURSOR_AREA_IN_BOX:
|
2021-04-16 23:05:44 +02:00
|
|
|
return GetCurrentBoxMonData(sCursorPosition, MON_DATA_SPECIES);
|
2018-12-15 23:58:47 +01:00
|
|
|
default:
|
|
|
|
return SPECIES_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static bool8 UpdateCursorPos(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
s16 tmp;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->cursorMoveSteps == 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-15 23:58:47 +01:00
|
|
|
return FALSE;
|
|
|
|
else
|
2021-04-16 01:17:53 +02:00
|
|
|
return IsItemIconAnimActive();
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
else if (--sStorage->cursorMoveSteps != 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
// Update position toward target
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorNewX += sStorage->cursorSpeedX;
|
|
|
|
sStorage->cursorNewY += sStorage->cursorSpeedY;
|
2021-07-07 15:11:52 +02:00
|
|
|
sStorage->cursorSprite->x = sStorage->cursorNewX >> 8;
|
|
|
|
sStorage->cursorSprite->y = sStorage->cursorNewY >> 8;
|
2021-04-17 06:49:51 +02:00
|
|
|
|
|
|
|
// Limit cursor on right
|
2021-07-07 15:11:52 +02:00
|
|
|
if (sStorage->cursorSprite->x > DISPLAY_WIDTH + 16)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
tmp = sStorage->cursorSprite->x - (DISPLAY_WIDTH + 16);
|
|
|
|
sStorage->cursorSprite->x = tmp + 64;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-17 06:49:51 +02:00
|
|
|
|
|
|
|
// Limit cursor on left
|
2021-07-07 15:11:52 +02:00
|
|
|
if (sStorage->cursorSprite->x < 64)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
tmp = 64 - sStorage->cursorSprite->x;
|
|
|
|
sStorage->cursorSprite->x = DISPLAY_WIDTH + 16 - tmp;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-17 06:49:51 +02:00
|
|
|
|
|
|
|
// Limit cursor on bottom
|
2021-07-07 15:11:52 +02:00
|
|
|
if (sStorage->cursorSprite->y > DISPLAY_HEIGHT + 16)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
tmp = sStorage->cursorSprite->y - (DISPLAY_HEIGHT + 16);
|
|
|
|
sStorage->cursorSprite->y = tmp - 16;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-17 06:49:51 +02:00
|
|
|
|
|
|
|
// Limit cursor on top
|
2021-07-07 15:11:52 +02:00
|
|
|
if (sStorage->cursorSprite->y < -16)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
tmp = -16 - sStorage->cursorSprite->y;
|
|
|
|
sStorage->cursorSprite->y = DISPLAY_HEIGHT + 16 - tmp;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-17 06:49:51 +02:00
|
|
|
|
|
|
|
// Cursor flips vertically when moving on/off the top buttons
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->cursorFlipTimer && --sStorage->cursorFlipTimer == 0)
|
|
|
|
sStorage->cursorSprite->vFlip = (sStorage->cursorSprite->vFlip == FALSE);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
// Time is up for cursor movement, make sure it's exactly at target
|
2021-07-07 15:11:52 +02:00
|
|
|
sStorage->cursorSprite->x = sStorage->cursorTargetX;
|
|
|
|
sStorage->cursorSprite->y = sStorage->cursorTargetY;
|
2021-04-17 06:49:51 +02:00
|
|
|
DoCursorNewPosUpdate();
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void InitNewCursorPos(u8 newCursorArea, u8 newCursorPosition)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u16 x, y;
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
GetCursorCoordsByPos(newCursorArea, newCursorPosition, &x, &y);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->newCursorArea = newCursorArea;
|
|
|
|
sStorage->newCursorPosition = newCursorPosition;
|
|
|
|
sStorage->cursorTargetX = x;
|
|
|
|
sStorage->cursorTargetY = y;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void InitCursorMove(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
int yDistance, xDistance;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->cursorVerticalWrap != 0 || sStorage->cursorHorizontalWrap != 0)
|
|
|
|
sStorage->cursorMoveSteps = 12;
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorMoveSteps = 6;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->cursorFlipTimer)
|
|
|
|
sStorage->cursorFlipTimer = sStorage->cursorMoveSteps >> 1;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->cursorVerticalWrap)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
default: // No wrap
|
2021-07-07 15:11:52 +02:00
|
|
|
yDistance = sStorage->cursorTargetY - sStorage->cursorSprite->y;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
2021-04-17 06:49:51 +02:00
|
|
|
case -1: // Wrap from top to bottom
|
2021-07-07 15:11:52 +02:00
|
|
|
yDistance = sStorage->cursorTargetY - 192 - sStorage->cursorSprite->y;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
2021-04-17 06:49:51 +02:00
|
|
|
case 1: // Wrap from bottom to top
|
2021-07-07 15:11:52 +02:00
|
|
|
yDistance = sStorage->cursorTargetY + 192 - sStorage->cursorSprite->y;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->cursorHorizontalWrap)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
default: // No Wrap
|
2021-07-07 15:11:52 +02:00
|
|
|
xDistance = sStorage->cursorTargetX - sStorage->cursorSprite->x;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
2021-04-17 06:49:51 +02:00
|
|
|
case -1: // Wrap from left to right
|
2021-07-07 15:11:52 +02:00
|
|
|
xDistance = sStorage->cursorTargetX - 192 - sStorage->cursorSprite->x;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
2021-04-17 06:49:51 +02:00
|
|
|
case 1: // Wrap from right to left
|
2021-07-07 15:11:52 +02:00
|
|
|
xDistance = sStorage->cursorTargetX + 192 - sStorage->cursorSprite->x;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
yDistance <<= 8;
|
|
|
|
xDistance <<= 8;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorSpeedX = xDistance / sStorage->cursorMoveSteps;
|
|
|
|
sStorage->cursorSpeedY = yDistance / sStorage->cursorMoveSteps;
|
2021-07-07 15:11:52 +02:00
|
|
|
sStorage->cursorNewX = sStorage->cursorSprite->x << 8;
|
|
|
|
sStorage->cursorNewY = sStorage->cursorSprite->y << 8;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void SetCursorPosition(u8 newCursorArea, u8 newCursorPosition)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
InitNewCursorPos(newCursorArea, newCursorPosition);
|
|
|
|
InitCursorMove();
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->inBoxMovingMode == MOVE_MODE_NORMAL && !sIsMonBeingMoved)
|
|
|
|
StartSpriteAnim(sStorage->cursorSprite, CURSOR_ANIM_STILL);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
if (!IsMovingItem())
|
2021-04-18 05:40:27 +02:00
|
|
|
StartSpriteAnim(sStorage->cursorSprite, CURSOR_ANIM_STILL);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption == OPTION_MOVE_ITEMS)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorArea == CURSOR_AREA_IN_BOX)
|
2021-04-17 06:49:51 +02:00
|
|
|
TryHideItemIconAtPos(CURSOR_AREA_IN_BOX, sCursorPosition);
|
2021-04-16 23:05:44 +02:00
|
|
|
else if (sCursorArea == CURSOR_AREA_IN_PARTY)
|
2021-04-17 06:49:51 +02:00
|
|
|
TryHideItemIconAtPos(CURSOR_AREA_IN_PARTY, sCursorPosition);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-02-05 08:59:26 +01:00
|
|
|
if (newCursorArea == CURSOR_AREA_IN_BOX)
|
2021-04-17 06:49:51 +02:00
|
|
|
TryLoadItemIconAtPos(newCursorArea, newCursorPosition);
|
2021-02-05 08:59:26 +01:00
|
|
|
else if (newCursorArea == CURSOR_AREA_IN_PARTY)
|
2021-04-17 06:49:51 +02:00
|
|
|
TryLoadItemIconAtPos(newCursorArea, newCursorPosition);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
if (newCursorArea == CURSOR_AREA_IN_PARTY && sCursorArea != CURSOR_AREA_IN_PARTY)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorPrevHorizPos = 1;
|
|
|
|
sStorage->cursorShadowSprite->invisible = TRUE;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-02-05 08:59:26 +01:00
|
|
|
switch (newCursorArea)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-16 21:10:01 +01:00
|
|
|
case CURSOR_AREA_IN_PARTY:
|
2021-04-17 06:49:51 +02:00
|
|
|
case CURSOR_AREA_BOX_TITLE:
|
2018-12-16 21:10:01 +01:00
|
|
|
case CURSOR_AREA_BUTTONS:
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorSprite->oam.priority = 1;
|
|
|
|
sStorage->cursorShadowSprite->invisible = TRUE;
|
|
|
|
sStorage->cursorShadowSprite->oam.priority = 1;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
2018-12-16 21:10:01 +01:00
|
|
|
case CURSOR_AREA_IN_BOX:
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->inBoxMovingMode != MOVE_MODE_NORMAL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorSprite->oam.priority = 0;
|
|
|
|
sStorage->cursorShadowSprite->invisible = TRUE;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorSprite->oam.priority = 2;
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorArea == CURSOR_AREA_IN_BOX && sIsMonBeingMoved)
|
2018-12-16 21:10:01 +01:00
|
|
|
SetMovingMonPriority(2);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void DoCursorNewPosUpdate(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sCursorArea = sStorage->newCursorArea;
|
|
|
|
sCursorPosition = sStorage->newCursorPosition;
|
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->inBoxMovingMode == MOVE_MODE_NORMAL && !sIsMonBeingMoved)
|
|
|
|
StartSpriteAnim(sStorage->cursorSprite, CURSOR_ANIM_BOUNCE);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
if (!IsMovingItem())
|
2021-04-18 05:40:27 +02:00
|
|
|
StartSpriteAnim(sStorage->cursorSprite, CURSOR_ANIM_BOUNCE);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
TryRefreshDisplayMon();
|
2021-04-16 23:05:44 +02:00
|
|
|
switch (sCursorArea)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case CURSOR_AREA_BUTTONS:
|
2018-12-16 21:10:01 +01:00
|
|
|
SetMovingMonPriority(1);
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
2021-04-17 06:49:51 +02:00
|
|
|
case CURSOR_AREA_BOX_TITLE:
|
2021-04-15 20:06:25 +02:00
|
|
|
AnimateBoxScrollArrows(TRUE);
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case CURSOR_AREA_IN_PARTY:
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorShadowSprite->subpriority = 13;
|
2018-12-16 21:10:01 +01:00
|
|
|
SetMovingMonPriority(1);
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case CURSOR_AREA_IN_BOX:
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->inBoxMovingMode == MOVE_MODE_NORMAL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorSprite->oam.priority = 1;
|
|
|
|
sStorage->cursorShadowSprite->oam.priority = 2;
|
|
|
|
sStorage->cursorShadowSprite->subpriority = 21;
|
|
|
|
sStorage->cursorShadowSprite->invisible = FALSE;
|
2018-12-16 21:10:01 +01:00
|
|
|
SetMovingMonPriority(2);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void SetCursorInParty(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u8 partyCount;
|
|
|
|
|
|
|
|
if (!sIsMonBeingMoved)
|
|
|
|
{
|
|
|
|
partyCount = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
partyCount = CalculatePlayerPartyCount();
|
|
|
|
if (partyCount >= PARTY_SIZE)
|
|
|
|
partyCount = PARTY_SIZE - 1;
|
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->cursorSprite->vFlip)
|
|
|
|
sStorage->cursorFlipTimer = 1;
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCursorPosition(CURSOR_AREA_IN_PARTY, partyCount);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void SetCursorBoxPosition(u8 cursorBoxPosition)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCursorPosition(CURSOR_AREA_IN_BOX, cursorBoxPosition);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
EWRAM_DATA static u8 sSavedCursorPosition = 0;
|
2018-12-20 22:14:36 +01:00
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void ClearSavedCursorPos(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
sSavedCursorPosition = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void SaveCursorPos(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
sSavedCursorPosition = sCursorPosition;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static u8 GetSavedCursorPos(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
return sSavedCursorPosition;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static void InitMonPlaceChange(u8 type)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 (*const placeChangeFuncs[])(void) =
|
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
[CHANGE_GRAB] = MonPlaceChange_Grab,
|
|
|
|
[CHANGE_PLACE] = MonPlaceChange_Place,
|
|
|
|
[CHANGE_SHIFT] = MonPlaceChange_Shift,
|
2018-12-16 21:10:01 +01:00
|
|
|
};
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->monPlaceChangeFunc = placeChangeFuncs[type];
|
|
|
|
sStorage->monPlaceChangeState = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
// No Shift while moving multiple Pokémon, only grab and place
|
|
|
|
// For both grab/place, the cursor moves down, then up
|
|
|
|
static void InitMultiMonPlaceChange(bool8 up)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
if (!up)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->monPlaceChangeFunc = MultiMonPlaceChange_Down;
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->monPlaceChangeFunc = MultiMonPlaceChange_Up;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->monPlaceChangeState = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static bool8 DoMonPlaceChange(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
return sStorage->monPlaceChangeFunc();
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static bool8 MonPlaceChange_Grab(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->monPlaceChangeState)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
return FALSE;
|
2021-04-18 05:40:27 +02:00
|
|
|
StartSpriteAnim(sStorage->cursorSprite, CURSOR_ANIM_OPEN);
|
|
|
|
sStorage->monPlaceChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-17 23:28:18 +02:00
|
|
|
if (!MonPlaceChange_CursorDown())
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
StartSpriteAnim(sStorage->cursorSprite, CURSOR_ANIM_FIST);
|
2018-12-15 23:58:47 +01:00
|
|
|
MoveMon();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->monPlaceChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-17 23:28:18 +02:00
|
|
|
if (!MonPlaceChange_CursorUp())
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->monPlaceChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 MonPlaceChange_Place(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->monPlaceChangeState)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-17 23:28:18 +02:00
|
|
|
if (!MonPlaceChange_CursorDown())
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
StartSpriteAnim(sStorage->cursorSprite, CURSOR_ANIM_OPEN);
|
2018-12-15 23:58:47 +01:00
|
|
|
PlaceMon();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->monPlaceChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-17 23:28:18 +02:00
|
|
|
if (!MonPlaceChange_CursorUp())
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
StartSpriteAnim(sStorage->cursorSprite, CURSOR_ANIM_BOUNCE);
|
|
|
|
sStorage->monPlaceChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 MonPlaceChange_Shift(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->monPlaceChangeState)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-16 23:05:44 +02:00
|
|
|
switch (sCursorArea)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case CURSOR_AREA_IN_PARTY:
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->shiftBoxId = TOTAL_BOXES_COUNT;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case CURSOR_AREA_IN_BOX:
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->shiftBoxId = StorageGetCurrentBox();
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
StartSpriteAnim(sStorage->cursorSprite, CURSOR_ANIM_OPEN);
|
2021-04-18 05:55:24 +02:00
|
|
|
SaveMonSpriteAtPos(sStorage->shiftBoxId, sCursorPosition);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->monPlaceChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-18 05:55:24 +02:00
|
|
|
if (!MoveShiftingMons())
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
StartSpriteAnim(sStorage->cursorSprite, CURSOR_ANIM_FIST);
|
2021-04-18 05:55:24 +02:00
|
|
|
SetShiftedMonData(sStorage->shiftBoxId, sCursorPosition);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->monPlaceChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static bool8 MultiMonPlaceChange_Down(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
return MonPlaceChange_CursorDown();
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static bool8 MultiMonPlaceChange_Up(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
return MonPlaceChange_CursorUp();
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static bool8 MonPlaceChange_CursorDown(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
switch (sStorage->cursorSprite->y2)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
default:
|
2021-07-07 15:11:52 +02:00
|
|
|
sStorage->cursorSprite->y2++;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 0:
|
2021-07-07 15:11:52 +02:00
|
|
|
sStorage->cursorSprite->y2++;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
2021-04-17 23:28:18 +02:00
|
|
|
case 8: // Cursor has reached bottom
|
2018-12-15 23:58:47 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static bool8 MonPlaceChange_CursorUp(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
switch (sStorage->cursorSprite->y2)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
case 0: // Cursor has reached top
|
2018-12-15 23:58:47 +01:00
|
|
|
return FALSE;
|
|
|
|
default:
|
2021-07-07 15:11:52 +02:00
|
|
|
sStorage->cursorSprite->y2--;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: Pokémon data
|
|
|
|
//
|
|
|
|
// The functions below handle moving Pokémon data around while using the PC,
|
|
|
|
// including changing the positions of Pokémon, releasing Pokémon, viewing the
|
|
|
|
// summary screen, and updating the display of the currently selected Pokémon.
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void MoveMon(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
switch (sCursorArea)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case CURSOR_AREA_IN_PARTY:
|
2021-04-17 06:49:51 +02:00
|
|
|
SetMovingMonData(TOTAL_BOXES_COUNT, sCursorPosition);
|
|
|
|
SetMovingMonSprite(MODE_PARTY, sCursorPosition);
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case CURSOR_AREA_IN_BOX:
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->inBoxMovingMode == MOVE_MODE_NORMAL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SetMovingMonData(StorageGetCurrentBox(), sCursorPosition);
|
|
|
|
SetMovingMonSprite(MODE_BOX, sCursorPosition);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sIsMonBeingMoved = TRUE;
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void PlaceMon(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u8 boxId;
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
switch (sCursorArea)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case CURSOR_AREA_IN_PARTY:
|
2021-04-16 23:05:44 +02:00
|
|
|
SetPlacedMonData(TOTAL_BOXES_COUNT, sCursorPosition);
|
2021-04-18 05:55:24 +02:00
|
|
|
SetPlacedMonSprite(TOTAL_BOXES_COUNT, sCursorPosition);
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case CURSOR_AREA_IN_BOX:
|
|
|
|
boxId = StorageGetCurrentBox();
|
2021-04-16 23:05:44 +02:00
|
|
|
SetPlacedMonData(boxId, sCursorPosition);
|
2021-04-18 05:55:24 +02:00
|
|
|
SetPlacedMonSprite(boxId, sCursorPosition);
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sIsMonBeingMoved = FALSE;
|
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void RefreshDisplayMon(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
TryRefreshDisplayMon();
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void SetMovingMonData(u8 boxId, u8 position)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (boxId == TOTAL_BOXES_COUNT)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingMon = gPlayerParty[sCursorPosition];
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
BoxMonAtToMon(boxId, position, &sStorage->movingMon);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
|
|
|
PurgeMonOrBoxMon(boxId, position);
|
|
|
|
sMovingMonOrigBoxId = boxId;
|
|
|
|
sMovingMonOrigBoxPos = position;
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void SetPlacedMonData(u8 boxId, u8 position)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (boxId == TOTAL_BOXES_COUNT)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
gPlayerParty[position] = sStorage->movingMon;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
BoxMonRestorePP(&sStorage->movingMon.box);
|
|
|
|
SetBoxMonAt(boxId, position, &sStorage->movingMon.box);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void PurgeMonOrBoxMon(u8 boxId, u8 position)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (boxId == TOTAL_BOXES_COUNT)
|
|
|
|
ZeroMonData(&gPlayerParty[position]);
|
|
|
|
else
|
|
|
|
ZeroBoxMonAt(boxId, position);
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void SetShiftedMonData(u8 boxId, u8 position)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (boxId == TOTAL_BOXES_COUNT)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->tempMon = gPlayerParty[position];
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
BoxMonAtToMon(boxId, position, &sStorage->tempMon);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
|
|
|
SetPlacedMonData(boxId, position);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingMon = sStorage->tempMon;
|
|
|
|
SetDisplayMonData(&sStorage->movingMon, MODE_PARTY);
|
2018-12-15 23:58:47 +01:00
|
|
|
sMovingMonOrigBoxId = boxId;
|
|
|
|
sMovingMonOrigBoxPos = position;
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 TryStorePartyMonInBox(u8 boxId)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
s16 boxPosition = GetFirstFreeBoxSpot(boxId);
|
|
|
|
if (boxPosition == -1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
{
|
|
|
|
SetPlacedMonData(boxId, boxPosition);
|
2018-12-16 21:10:01 +01:00
|
|
|
DestroyMovingMonIcon();
|
2018-12-15 23:58:47 +01:00
|
|
|
sIsMonBeingMoved = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SetMovingMonData(TOTAL_BOXES_COUNT, sCursorPosition);
|
2018-12-15 23:58:47 +01:00
|
|
|
SetPlacedMonData(boxId, boxPosition);
|
2021-04-16 23:05:44 +02:00
|
|
|
DestroyPartyMonIcon(sCursorPosition);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (boxId == StorageGetCurrentBox())
|
2021-04-18 01:28:31 +02:00
|
|
|
CreateBoxMonIconAtPos(boxPosition);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
StartSpriteAnim(sStorage->cursorSprite, CURSOR_ANIM_STILL);
|
2018-12-15 23:58:47 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
static void ResetSelectionAfterDeposit(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
StartSpriteAnim(sStorage->cursorSprite, CURSOR_ANIM_BOUNCE);
|
2021-04-17 06:49:51 +02:00
|
|
|
TryRefreshDisplayMon();
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void InitReleaseMon(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u8 mode;
|
|
|
|
|
|
|
|
if (sIsMonBeingMoved)
|
2020-03-09 02:27:29 +01:00
|
|
|
mode = MODE_MOVE;
|
2021-04-16 23:05:44 +02:00
|
|
|
else if (sCursorArea == CURSOR_AREA_IN_PARTY)
|
2018-12-15 23:58:47 +01:00
|
|
|
mode = MODE_PARTY;
|
|
|
|
else
|
|
|
|
mode = MODE_BOX;
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
SetReleaseMon(mode, sCursorPosition);
|
2021-04-18 05:40:27 +02:00
|
|
|
StringCopy(sStorage->releaseMonName, sStorage->displayMonName);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static bool8 TryHideReleaseMon(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
if (!TryHideReleaseMonSprite())
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
StartSpriteAnim(sStorage->cursorSprite, CURSOR_ANIM_BOUNCE);
|
2018-12-15 23:58:47 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void ReleaseMon(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u8 boxId;
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
DestroyReleaseMonIcon();
|
2018-12-15 23:58:47 +01:00
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
{
|
|
|
|
sIsMonBeingMoved = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorArea == CURSOR_AREA_IN_PARTY)
|
2018-12-15 23:58:47 +01:00
|
|
|
boxId = TOTAL_BOXES_COUNT;
|
|
|
|
else
|
|
|
|
boxId = StorageGetCurrentBox();
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
PurgeMonOrBoxMon(boxId, sCursorPosition);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-17 06:49:51 +02:00
|
|
|
TryRefreshDisplayMon();
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void TrySetCursorFistAnim(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (sIsMonBeingMoved)
|
2021-04-18 05:40:27 +02:00
|
|
|
StartSpriteAnim(sStorage->cursorSprite, CURSOR_ANIM_FIST);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
// If the player is on the listed map (or any map, if none is specified),
|
|
|
|
// they may not release their last Pokémon that knows the specified move.
|
|
|
|
// This is to stop the player from softlocking themselves by not having
|
|
|
|
// a Pokémon that knows a required field move.
|
2018-12-16 21:10:01 +01:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
s8 mapGroup;
|
|
|
|
s8 mapNum;
|
|
|
|
u16 move;
|
2021-04-16 05:27:05 +02:00
|
|
|
} static const sRestrictedReleaseMoves[] =
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
{MAP_GROUPS_COUNT, 0, MOVE_SURF},
|
|
|
|
{MAP_GROUPS_COUNT, 0, MOVE_DIVE},
|
|
|
|
{MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MOVE_STRENGTH},
|
|
|
|
{MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_1F), MOVE_ROCK_SMASH},
|
|
|
|
{MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MOVE_STRENGTH},
|
|
|
|
{MAP_GROUP(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MAP_NUM(EVER_GRANDE_CITY_POKEMON_LEAGUE_2F), MOVE_ROCK_SMASH},
|
|
|
|
};
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void GetRestrictedReleaseMoves(u16 *moves)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sRestrictedReleaseMoves); i++)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
if (sRestrictedReleaseMoves[i].mapGroup == MAP_GROUPS_COUNT
|
|
|
|
|| (sRestrictedReleaseMoves[i].mapGroup == gSaveBlock1Ptr->location.mapGroup
|
|
|
|
&& sRestrictedReleaseMoves[i].mapNum == gSaveBlock1Ptr->location.mapNum))
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
*moves = sRestrictedReleaseMoves[i].move;
|
2018-12-15 23:58:47 +01:00
|
|
|
moves++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*moves = MOVES_COUNT;
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void InitCanReleaseMonVars(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (!AtLeastThreeUsableMons())
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
// The player only has 1 or 2 usable
|
|
|
|
// Pokémon, this one can't be released
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->releaseStatusResolved = TRUE;
|
|
|
|
sStorage->canReleaseMon = FALSE;
|
2018-12-15 23:58:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->tempMon = sStorage->movingMon;
|
|
|
|
sStorage->releaseBoxId = -1;
|
|
|
|
sStorage->releaseBoxPos = -1;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorArea == CURSOR_AREA_IN_PARTY)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->tempMon = gPlayerParty[sCursorPosition];
|
|
|
|
sStorage->releaseBoxId = TOTAL_BOXES_COUNT;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
BoxMonAtToMon(StorageGetCurrentBox(), sCursorPosition, &sStorage->tempMon);
|
|
|
|
sStorage->releaseBoxId = StorageGetCurrentBox();
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->releaseBoxPos = sCursorPosition;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
GetRestrictedReleaseMoves(sStorage->restrictedMoveList);
|
|
|
|
sStorage->restrictedReleaseMonMoves = GetMonData(&sStorage->tempMon, MON_DATA_KNOWN_MOVES, (u8*)sStorage->restrictedMoveList);
|
|
|
|
if (sStorage->restrictedReleaseMonMoves != 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
// Pokémon knows at least one restricted release move
|
|
|
|
// Need to check if another Pokémon has this move first
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->releaseStatusResolved = FALSE;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
// Pokémon knows no restricted moves, can be released
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->releaseStatusResolved = TRUE;
|
|
|
|
sStorage->canReleaseMon = TRUE;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->releaseCheckState = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static bool32 AtLeastThreeUsableMons(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
s32 i, j;
|
|
|
|
s32 count = (sIsMonBeingMoved != FALSE);
|
|
|
|
|
|
|
|
// Check party for usable Pokémon
|
2018-12-15 23:58:47 +01:00
|
|
|
for (j = 0; j < PARTY_SIZE; j++)
|
|
|
|
{
|
|
|
|
if (GetMonData(&gPlayerParty[j], MON_DATA_SANITY_HAS_SPECIES))
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count >= 3)
|
|
|
|
return TRUE;
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
// Check PC for usable Pokémon
|
2018-12-15 23:58:47 +01:00
|
|
|
for (i = 0; i < TOTAL_BOXES_COUNT; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < IN_BOX_COUNT; j++)
|
|
|
|
{
|
2018-12-22 23:00:22 +01:00
|
|
|
if (CheckBoxMonSanityAt(i, j))
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (++count >= 3)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static s8 RunCanReleaseMon(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
u16 knownMoves;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->releaseStatusResolved)
|
|
|
|
return sStorage->canReleaseMon;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->releaseCheckState)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-16 05:27:05 +02:00
|
|
|
// Check party for other Pokémon that know any restricted
|
|
|
|
// moves the release Pokémon knows
|
2018-12-15 23:58:47 +01:00
|
|
|
for (i = 0; i < PARTY_SIZE; i++)
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
// Make sure party Pokémon isn't the one we're releasing first
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->releaseBoxId != TOTAL_BOXES_COUNT || sStorage->releaseBoxPos != i)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
knownMoves = GetMonData(&gPlayerParty[i], MON_DATA_KNOWN_MOVES, (u8*)sStorage->restrictedMoveList);
|
|
|
|
sStorage->restrictedReleaseMonMoves &= ~(knownMoves);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->restrictedReleaseMonMoves == 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
// No restricted moves on release Pokémon that
|
|
|
|
// aren't resolved by the party, it can be released.
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->releaseStatusResolved = TRUE;
|
|
|
|
sStorage->canReleaseMon = TRUE;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
// Release Pokémon has restricted moves not resolved by the party.
|
|
|
|
// Continue and check the PC next
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->releaseCheckBoxId = 0;
|
|
|
|
sStorage->releaseCheckBoxPos = 0;
|
|
|
|
sStorage->releaseCheckState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-16 05:27:05 +02:00
|
|
|
// Check PC for other Pokémon that know any restricted
|
|
|
|
// moves the release Pokémon knows
|
2018-12-15 23:58:47 +01:00
|
|
|
for (i = 0; i < IN_BOX_COUNT; i++)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
knownMoves = GetAndCopyBoxMonDataAt(sStorage->releaseCheckBoxId, sStorage->releaseCheckBoxPos, MON_DATA_KNOWN_MOVES, (u8*)sStorage->restrictedMoveList);
|
|
|
|
if (knownMoves != 0 && !(sStorage->releaseBoxId == sStorage->releaseCheckBoxId
|
|
|
|
&& sStorage->releaseBoxPos == sStorage->releaseCheckBoxPos))
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
// Found PC Pokémon with restricted move, clear move from list
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->restrictedReleaseMonMoves &= ~(knownMoves);
|
|
|
|
if (sStorage->restrictedReleaseMonMoves == 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
// No restricted moves on release Pokémon that
|
|
|
|
// aren't resolved, it can be released.
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->releaseStatusResolved = TRUE;
|
|
|
|
sStorage->canReleaseMon = TRUE;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
if (++sStorage->releaseCheckBoxPos >= IN_BOX_COUNT)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->releaseCheckBoxPos = 0;
|
|
|
|
if (++sStorage->releaseCheckBoxId >= TOTAL_BOXES_COUNT)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
// Checked every Pokémon in the PC, release Pokémon is
|
|
|
|
// the sole owner of at least one restricted move.
|
|
|
|
// It cannot be released.
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->releaseStatusResolved = TRUE;
|
|
|
|
sStorage->canReleaseMon = FALSE;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void SaveMovingMon(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
if (sIsMonBeingMoved)
|
2021-04-18 05:40:27 +02:00
|
|
|
sSavedMovingMon = sStorage->movingMon;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void LoadSavedMovingMon(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
// If it came from the party load a struct Pokemon,
|
|
|
|
// otherwise load a BoxPokemon
|
2018-12-16 21:10:01 +01:00
|
|
|
if (sMovingMonOrigBoxId == TOTAL_BOXES_COUNT)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingMon = sSavedMovingMon;
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingMon.box = sSavedMovingMon.box;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void InitSummaryScreenData(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SaveMovingMon();
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->summaryMon.mon = &sSavedMovingMon;
|
|
|
|
sStorage->summaryStartPos = 0;
|
|
|
|
sStorage->summaryMaxPos = 0;
|
|
|
|
sStorage->summaryScreenMode = SUMMARY_MODE_NORMAL;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2021-04-16 23:05:44 +02:00
|
|
|
else if (sCursorArea == CURSOR_AREA_IN_PARTY)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->summaryMon.mon = gPlayerParty;
|
|
|
|
sStorage->summaryStartPos = sCursorPosition;
|
|
|
|
sStorage->summaryMaxPos = CountPartyMons() - 1;
|
|
|
|
sStorage->summaryScreenMode = SUMMARY_MODE_NORMAL;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->summaryMon.box = GetBoxedMonPtr(StorageGetCurrentBox(), 0);
|
|
|
|
sStorage->summaryStartPos = sCursorPosition;
|
|
|
|
sStorage->summaryMaxPos = IN_BOX_COUNT - 1;
|
|
|
|
sStorage->summaryScreenMode = SUMMARY_MODE_BOX;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 01:28:31 +02:00
|
|
|
static void SetSelectionAfterSummaryScreen(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
if (sIsMonBeingMoved)
|
2021-04-17 06:49:51 +02:00
|
|
|
LoadSavedMovingMon();
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
2021-04-16 23:05:44 +02:00
|
|
|
sCursorPosition = gLastViewedMonIndex;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
s16 CompactPartySlots(void)
|
|
|
|
{
|
|
|
|
s16 retVal = -1;
|
|
|
|
u16 i, last;
|
|
|
|
|
|
|
|
for (i = 0, last = 0; i < PARTY_SIZE; i++)
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES);
|
2018-12-16 21:10:01 +01:00
|
|
|
if (species != SPECIES_NONE)
|
|
|
|
{
|
|
|
|
if (i != last)
|
|
|
|
gPlayerParty[last] = gPlayerParty[i];
|
|
|
|
last++;
|
|
|
|
}
|
|
|
|
else if (retVal == -1)
|
2018-12-22 23:00:22 +01:00
|
|
|
{
|
2018-12-16 21:10:01 +01:00
|
|
|
retVal = i;
|
2018-12-22 23:00:22 +01:00
|
|
|
}
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
for (; last < PARTY_SIZE; last++)
|
2021-04-16 05:27:05 +02:00
|
|
|
ZeroMonData(&gPlayerParty[last]);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SetMonMarkings(u8 markings)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->displayMonMarkings = markings;
|
2018-12-16 21:10:01 +01:00
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetMonData(&sStorage->movingMon, MON_DATA_MARKINGS, &markings);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorArea == CURSOR_AREA_IN_PARTY)
|
|
|
|
SetMonData(&gPlayerParty[sCursorPosition], MON_DATA_MARKINGS, &markings);
|
|
|
|
if (sCursorArea == CURSOR_AREA_IN_BOX)
|
|
|
|
SetCurrentBoxMonData(sCursorPosition, MON_DATA_MARKINGS, &markings);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static bool8 IsRemovingLastPartyMon(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorArea == CURSOR_AREA_IN_PARTY && !sIsMonBeingMoved && CountPartyAliveNonEggMonsExcept(sCursorPosition) == 0)
|
2018-12-16 21:10:01 +01:00
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-12-22 23:00:22 +01:00
|
|
|
static bool8 CanShiftMon(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorArea == CURSOR_AREA_IN_PARTY && CountPartyAliveNonEggMonsExcept(sCursorPosition) == 0)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->displayMonIsEgg || GetMonData(&sStorage->movingMon, MON_DATA_HP) == 0)
|
2018-12-16 21:10:01 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 IsMonBeingMoved(void)
|
|
|
|
{
|
|
|
|
return sIsMonBeingMoved;
|
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static bool8 IsCursorOnBoxTitle(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
return (sCursorArea == CURSOR_AREA_BOX_TITLE);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 IsCursorOnCloseBox(void)
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
return (sCursorArea == CURSOR_AREA_BUTTONS && sCursorPosition == 1);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 IsCursorInBox(void)
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
return (sCursorArea == CURSOR_AREA_IN_BOX);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void TryRefreshDisplayMon(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
// If a Pokémon is currently being moved, don't start
|
|
|
|
// mosaic or update display. Keep displaying the
|
|
|
|
// currently held Pokémon.
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->setMosaic = (sIsMonBeingMoved == FALSE);
|
2018-12-16 21:10:01 +01:00
|
|
|
if (!sIsMonBeingMoved)
|
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
// Update display Pokémon
|
2021-04-16 23:05:44 +02:00
|
|
|
switch (sCursorArea)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
case CURSOR_AREA_IN_PARTY:
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorPosition < PARTY_SIZE)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
SetDisplayMonData(&gPlayerParty[sCursorPosition], MODE_PARTY);
|
2018-12-16 21:10:01 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// fallthrough
|
|
|
|
case CURSOR_AREA_BUTTONS:
|
2021-04-17 06:49:51 +02:00
|
|
|
case CURSOR_AREA_BOX_TITLE:
|
2021-04-16 05:27:05 +02:00
|
|
|
SetDisplayMonData(NULL, MODE_MOVE);
|
2018-12-16 21:10:01 +01:00
|
|
|
break;
|
|
|
|
case CURSOR_AREA_IN_BOX:
|
2021-04-16 23:05:44 +02:00
|
|
|
SetDisplayMonData(GetBoxedMonPtr(StorageGetCurrentBox(), sCursorPosition), MODE_BOX);
|
2018-12-16 21:10:01 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static void ReshowDisplayMon(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
if (sIsMonBeingMoved)
|
2021-04-17 06:49:51 +02:00
|
|
|
SetDisplayMonData(&sSavedMovingMon, MODE_PARTY);
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
2021-04-17 06:49:51 +02:00
|
|
|
TryRefreshDisplayMon();
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-09-29 05:48:03 +02:00
|
|
|
void SetArceusFormPSS(struct BoxPokemon *boxMon)
|
|
|
|
{
|
|
|
|
u16 species = GetMonData(boxMon, MON_DATA_SPECIES);
|
|
|
|
u16 targetSpecies = GetFormChangeTargetSpeciesBoxMon(boxMon, FORM_ITEM_HOLD, 0);
|
|
|
|
if (targetSpecies != SPECIES_NONE)
|
|
|
|
{
|
|
|
|
//PlayCry2(targetSpecies, 0, 0x7D, 0xA);
|
|
|
|
SetBoxMonData(boxMon, MON_DATA_SPECIES, &targetSpecies);
|
|
|
|
UpdateSpeciesSpritePSS(boxMon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void SetDisplayMonData(void *pokemon, u8 mode)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
u8 *txtPtr;
|
|
|
|
u16 gender;
|
2020-11-16 19:36:38 +01:00
|
|
|
bool8 sanityIsBadEgg;
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->displayMonItemId = ITEM_NONE;
|
2018-12-16 21:10:01 +01:00
|
|
|
gender = MON_MALE;
|
2020-11-16 19:36:38 +01:00
|
|
|
sanityIsBadEgg = FALSE;
|
2018-12-16 21:10:01 +01:00
|
|
|
if (mode == MODE_PARTY)
|
|
|
|
{
|
|
|
|
struct Pokemon *mon = (struct Pokemon *)pokemon;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->displayMonSpecies = GetMonData(mon, MON_DATA_SPECIES2);
|
|
|
|
if (sStorage->displayMonSpecies != SPECIES_NONE)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2020-11-16 19:36:38 +01:00
|
|
|
sanityIsBadEgg = GetMonData(mon, MON_DATA_SANITY_IS_BAD_EGG);
|
|
|
|
if (sanityIsBadEgg)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->displayMonIsEgg = TRUE;
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->displayMonIsEgg = GetMonData(mon, MON_DATA_IS_EGG);
|
|
|
|
|
|
|
|
GetMonData(mon, MON_DATA_NICKNAME, sStorage->displayMonName);
|
|
|
|
StringGetEnd10(sStorage->displayMonName);
|
|
|
|
sStorage->displayMonLevel = GetMonData(mon, MON_DATA_LEVEL);
|
|
|
|
sStorage->displayMonMarkings = GetMonData(mon, MON_DATA_MARKINGS);
|
|
|
|
sStorage->displayMonPersonality = GetMonData(mon, MON_DATA_PERSONALITY);
|
|
|
|
sStorage->displayMonPalette = GetMonFrontSpritePal(mon);
|
2018-12-16 21:10:01 +01:00
|
|
|
gender = GetMonGender(mon);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->displayMonItemId = GetMonData(mon, MON_DATA_HELD_ITEM);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mode == MODE_BOX)
|
|
|
|
{
|
|
|
|
struct BoxPokemon *boxMon = (struct BoxPokemon *)pokemon;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->displayMonSpecies = GetBoxMonData(pokemon, MON_DATA_SPECIES2);
|
|
|
|
if (sStorage->displayMonSpecies != SPECIES_NONE)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
u32 otId = GetBoxMonData(boxMon, MON_DATA_OT_ID);
|
2020-11-16 19:36:38 +01:00
|
|
|
sanityIsBadEgg = GetBoxMonData(boxMon, MON_DATA_SANITY_IS_BAD_EGG);
|
|
|
|
if (sanityIsBadEgg)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->displayMonIsEgg = TRUE;
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->displayMonIsEgg = GetBoxMonData(boxMon, MON_DATA_IS_EGG);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
GetBoxMonData(boxMon, MON_DATA_NICKNAME, sStorage->displayMonName);
|
|
|
|
StringGetEnd10(sStorage->displayMonName);
|
|
|
|
sStorage->displayMonLevel = GetLevelFromBoxMonExp(boxMon);
|
|
|
|
sStorage->displayMonMarkings = GetBoxMonData(boxMon, MON_DATA_MARKINGS);
|
|
|
|
sStorage->displayMonPersonality = GetBoxMonData(boxMon, MON_DATA_PERSONALITY);
|
|
|
|
sStorage->displayMonPalette = GetMonSpritePalFromSpeciesAndPersonality(sStorage->displayMonSpecies, otId, sStorage->displayMonPersonality);
|
|
|
|
gender = GetGenderFromSpeciesAndPersonality(sStorage->displayMonSpecies, sStorage->displayMonPersonality);
|
|
|
|
sStorage->displayMonItemId = GetBoxMonData(boxMon, MON_DATA_HELD_ITEM);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->displayMonSpecies = SPECIES_NONE;
|
|
|
|
sStorage->displayMonItemId = ITEM_NONE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->displayMonSpecies == SPECIES_NONE)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
StringFill(sStorage->displayMonName, CHAR_SPACE, 5);
|
|
|
|
StringFill(sStorage->displayMonNameText, CHAR_SPACE, 8);
|
|
|
|
StringFill(sStorage->displayMonSpeciesName, CHAR_SPACE, 8);
|
|
|
|
StringFill(sStorage->displayMonGenderLvlText, CHAR_SPACE, 8);
|
|
|
|
StringFill(sStorage->displayMonItemName, CHAR_SPACE, 8);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
else if (sStorage->displayMonIsEgg)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2020-11-16 19:36:38 +01:00
|
|
|
if (sanityIsBadEgg)
|
2021-04-18 05:40:27 +02:00
|
|
|
StringCopyPadded(sStorage->displayMonNameText, sStorage->displayMonName, CHAR_SPACE, 5);
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
StringCopyPadded(sStorage->displayMonNameText, gText_EggNickname, CHAR_SPACE, 8);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
StringFill(sStorage->displayMonSpeciesName, CHAR_SPACE, 8);
|
|
|
|
StringFill(sStorage->displayMonGenderLvlText, CHAR_SPACE, 8);
|
|
|
|
StringFill(sStorage->displayMonItemName, CHAR_SPACE, 8);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->displayMonSpecies == SPECIES_NIDORAN_F || sStorage->displayMonSpecies == SPECIES_NIDORAN_M)
|
2018-12-16 21:10:01 +01:00
|
|
|
gender = MON_GENDERLESS;
|
2021-09-29 05:48:03 +02:00
|
|
|
|
|
|
|
SetArceusFormPSS(pokemon);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
StringCopyPadded(sStorage->displayMonNameText, sStorage->displayMonName, CHAR_SPACE, 5);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
txtPtr = sStorage->displayMonSpeciesName;
|
2018-12-16 21:10:01 +01:00
|
|
|
*(txtPtr)++ = CHAR_SLASH;
|
2021-04-18 05:40:27 +02:00
|
|
|
StringCopyPadded(txtPtr, gSpeciesNames[sStorage->displayMonSpecies], CHAR_SPACE, 5);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
txtPtr = sStorage->displayMonGenderLvlText;
|
2018-12-16 21:10:01 +01:00
|
|
|
*(txtPtr)++ = EXT_CTRL_CODE_BEGIN;
|
2020-08-11 05:50:49 +02:00
|
|
|
*(txtPtr)++ = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
|
2018-12-16 21:10:01 +01:00
|
|
|
switch (gender)
|
|
|
|
{
|
|
|
|
case MON_MALE:
|
2020-08-11 05:50:49 +02:00
|
|
|
*(txtPtr)++ = TEXT_COLOR_RED;
|
|
|
|
*(txtPtr)++ = TEXT_COLOR_WHITE;
|
|
|
|
*(txtPtr)++ = TEXT_COLOR_LIGHT_RED;
|
2018-12-16 21:10:01 +01:00
|
|
|
*(txtPtr)++ = CHAR_MALE;
|
|
|
|
break;
|
|
|
|
case MON_FEMALE:
|
2020-08-11 05:50:49 +02:00
|
|
|
*(txtPtr)++ = TEXT_COLOR_GREEN;
|
|
|
|
*(txtPtr)++ = TEXT_COLOR_WHITE;
|
|
|
|
*(txtPtr)++ = TEXT_COLOR_LIGHT_GREEN;
|
2018-12-16 21:10:01 +01:00
|
|
|
*(txtPtr)++ = CHAR_FEMALE;
|
|
|
|
break;
|
|
|
|
default:
|
2021-04-10 04:39:34 +02:00
|
|
|
*(txtPtr)++ = TEXT_COLOR_DARK_GRAY;
|
2020-08-11 05:50:49 +02:00
|
|
|
*(txtPtr)++ = TEXT_COLOR_WHITE;
|
2021-04-10 04:39:34 +02:00
|
|
|
*(txtPtr)++ = TEXT_COLOR_LIGHT_GRAY;
|
2021-04-17 06:49:51 +02:00
|
|
|
*(txtPtr)++ = CHAR_GENDERLESS;
|
2018-12-16 21:10:01 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
*(txtPtr++) = EXT_CTRL_CODE_BEGIN;
|
2020-08-11 05:50:49 +02:00
|
|
|
*(txtPtr++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
|
2021-04-10 04:39:34 +02:00
|
|
|
*(txtPtr++) = TEXT_COLOR_DARK_GRAY;
|
2020-08-11 05:50:49 +02:00
|
|
|
*(txtPtr++) = TEXT_COLOR_WHITE;
|
2021-04-10 04:39:34 +02:00
|
|
|
*(txtPtr++) = TEXT_COLOR_LIGHT_GRAY;
|
2020-08-11 05:50:49 +02:00
|
|
|
*(txtPtr++) = CHAR_SPACE;
|
|
|
|
*(txtPtr++) = CHAR_EXTRA_SYMBOL;
|
2020-02-01 06:25:50 +01:00
|
|
|
*(txtPtr++) = CHAR_LV_2;
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
txtPtr = ConvertIntToDecimalStringN(txtPtr, sStorage->displayMonLevel, STR_CONV_MODE_LEFT_ALIGN, 3);
|
2018-12-16 21:10:01 +01:00
|
|
|
txtPtr[0] = CHAR_SPACE;
|
|
|
|
txtPtr[1] = EOS;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->displayMonItemId != ITEM_NONE)
|
|
|
|
StringCopyPadded(sStorage->displayMonItemName, ItemId_GetName(sStorage->displayMonItemId), CHAR_SPACE, 8);
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
StringFill(sStorage->displayMonItemName, CHAR_SPACE, 8);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: Input handlers
|
|
|
|
//
|
|
|
|
// The functions below process context-dependent input
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static u8 HandleInput_InBox(void)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->inBoxMovingMode)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
case MOVE_MODE_NORMAL:
|
2018-12-16 21:10:01 +01:00
|
|
|
default:
|
|
|
|
return InBoxInput_Normal();
|
2021-04-16 23:05:44 +02:00
|
|
|
case MOVE_MODE_MULTIPLE_SELECTING:
|
|
|
|
return InBoxInput_SelectingMultiple();
|
|
|
|
case MOVE_MODE_MULTIPLE_MOVING:
|
2018-12-16 21:10:01 +01:00
|
|
|
return InBoxInput_MovingMultiple();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 InBoxInput_Normal(void)
|
|
|
|
{
|
|
|
|
u8 retVal;
|
2020-05-21 19:04:13 +02:00
|
|
|
s8 cursorArea;
|
|
|
|
s8 cursorPosition;
|
2019-05-26 11:07:30 +02:00
|
|
|
|
|
|
|
do
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
cursorArea = sCursorArea;
|
|
|
|
cursorPosition = sCursorPosition;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorVerticalWrap = 0;
|
|
|
|
sStorage->cursorHorizontalWrap = 0;
|
|
|
|
sStorage->cursorFlipTimer = 0;
|
2020-05-21 19:04:13 +02:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_UP))
|
2019-05-26 11:07:30 +02:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
retVal = INPUT_MOVE_CURSOR;
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorPosition >= IN_BOX_COLUMNS)
|
2019-05-26 11:07:30 +02:00
|
|
|
{
|
2021-04-16 11:14:35 +02:00
|
|
|
cursorPosition -= IN_BOX_COLUMNS;
|
2019-05-26 11:07:30 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
cursorArea = CURSOR_AREA_BOX_TITLE;
|
2019-05-26 11:07:30 +02:00
|
|
|
cursorPosition = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_DOWN))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
retVal = INPUT_MOVE_CURSOR;
|
2021-04-16 11:14:35 +02:00
|
|
|
cursorPosition += IN_BOX_COLUMNS;
|
2018-12-16 21:10:01 +01:00
|
|
|
if (cursorPosition >= IN_BOX_COUNT)
|
|
|
|
{
|
|
|
|
cursorArea = CURSOR_AREA_BUTTONS;
|
|
|
|
cursorPosition -= IN_BOX_COUNT;
|
|
|
|
cursorPosition /= 3;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorVerticalWrap = 1;
|
|
|
|
sStorage->cursorFlipTimer = 1;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2019-05-26 11:07:30 +02:00
|
|
|
break;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_LEFT))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
retVal = INPUT_MOVE_CURSOR;
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorPosition % IN_BOX_COLUMNS != 0)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
cursorPosition--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorHorizontalWrap = -1;
|
2021-04-16 11:14:35 +02:00
|
|
|
cursorPosition += (IN_BOX_COLUMNS - 1);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2019-05-26 11:07:30 +02:00
|
|
|
break;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_RIGHT))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
retVal = INPUT_MOVE_CURSOR;
|
2021-04-16 23:05:44 +02:00
|
|
|
if ((sCursorPosition + 1) % IN_BOX_COLUMNS != 0)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
cursorPosition++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorHorizontalWrap = 1;
|
2021-04-16 11:14:35 +02:00
|
|
|
cursorPosition -= (IN_BOX_COLUMNS - 1);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2019-05-26 11:07:30 +02:00
|
|
|
break;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(START_BUTTON))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
retVal = INPUT_MOVE_CURSOR;
|
|
|
|
cursorArea = CURSOR_AREA_BOX_TITLE;
|
2018-12-16 21:10:01 +01:00
|
|
|
cursorPosition = 0;
|
2019-05-26 11:07:30 +02:00
|
|
|
break;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2019-05-26 11:07:30 +02:00
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
if ((JOY_NEW(A_BUTTON)) && SetSelectionMenuTexts())
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (!sAutoActionOn)
|
|
|
|
return INPUT_IN_MENU;
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_MONS || sIsMonBeingMoved == TRUE)
|
2019-05-26 11:07:30 +02:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
switch (GetMenuItemTextId(0))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_STORE:
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_DEPOSIT;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_WITHDRAW:
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_WITHDRAW;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_MOVE:
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MOVE_MON;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_SHIFT:
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_SHIFT_MON;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_PLACE:
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_PLACE_MON;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_TAKE:
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_TAKE_ITEM;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_GIVE:
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_GIVE_ITEM;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_SWITCH:
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_SWITCH_ITEMS;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
2019-05-26 11:07:30 +02:00
|
|
|
else
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->inBoxMovingMode = MOVE_MODE_MULTIPLE_SELECTING;
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_START;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
2019-05-26 11:07:30 +02:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(B_BUTTON))
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_PRESSED_B;
|
2019-05-26 11:07:30 +02:00
|
|
|
|
|
|
|
if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_HELD(L_BUTTON))
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_SCROLL_LEFT;
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_HELD(R_BUTTON))
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_SCROLL_RIGHT;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2019-05-26 11:07:30 +02:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(SELECT_BUTTON))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
ToggleCursorAutoAction();
|
2021-04-15 23:31:50 +02:00
|
|
|
return INPUT_NONE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2019-05-26 11:07:30 +02:00
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
retVal = INPUT_NONE;
|
2019-05-26 11:07:30 +02:00
|
|
|
|
|
|
|
} while (0);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
|
|
|
if (retVal)
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCursorPosition(cursorArea, cursorPosition);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static u8 InBoxInput_SelectingMultiple(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_HELD(A_BUTTON))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_UP))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorPosition / IN_BOX_COLUMNS != 0)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCursorPosition(CURSOR_AREA_IN_BOX, sCursorPosition - IN_BOX_COLUMNS);
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_CHANGE_SELECTION;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_UNABLE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_DOWN))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorPosition + IN_BOX_COLUMNS < IN_BOX_COUNT)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCursorPosition(CURSOR_AREA_IN_BOX, sCursorPosition + IN_BOX_COLUMNS);
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_CHANGE_SELECTION;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_UNABLE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_LEFT))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorPosition % IN_BOX_COLUMNS != 0)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCursorPosition(CURSOR_AREA_IN_BOX, sCursorPosition - 1);
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_CHANGE_SELECTION;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_UNABLE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_RIGHT))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if ((sCursorPosition + 1) % IN_BOX_COLUMNS != 0)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCursorPosition(CURSOR_AREA_IN_BOX, sCursorPosition + 1);
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_CHANGE_SELECTION;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_UNABLE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
return INPUT_NONE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (MultiMove_GetOrigin() == sCursorPosition)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
// Doing a multiple mon selection but only chose 1 mon
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->inBoxMovingMode = MOVE_MODE_NORMAL;
|
|
|
|
sStorage->cursorShadowSprite->invisible = FALSE;
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_SINGLE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sIsMonBeingMoved = (sStorage->displayMonSpecies != SPECIES_NONE);
|
|
|
|
sStorage->inBoxMovingMode = MOVE_MODE_MULTIPLE_MOVING;
|
2018-12-16 21:10:01 +01:00
|
|
|
sMovingMonOrigBoxId = StorageGetCurrentBox();
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_GRAB_SELECTION;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 InBoxInput_MovingMultiple(void)
|
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_UP))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (MultiMove_TryMoveGroup(0))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCursorPosition(CURSOR_AREA_IN_BOX, sCursorPosition - IN_BOX_COLUMNS);
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_MOVE_MONS;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_UNABLE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_DOWN))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (MultiMove_TryMoveGroup(1))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCursorPosition(CURSOR_AREA_IN_BOX, sCursorPosition + IN_BOX_COLUMNS);
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_MOVE_MONS;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_UNABLE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_LEFT))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (MultiMove_TryMoveGroup(2))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCursorPosition(CURSOR_AREA_IN_BOX, sCursorPosition - 1);
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_MOVE_MONS;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_SCROLL_LEFT;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_RIGHT))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (MultiMove_TryMoveGroup(3))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCursorPosition(CURSOR_AREA_IN_BOX, sCursorPosition + 1);
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_MOVE_MONS;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_SCROLL_RIGHT;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(A_BUTTON))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (MultiMove_CanPlaceSelection())
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
sIsMonBeingMoved = FALSE;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->inBoxMovingMode = MOVE_MODE_NORMAL;
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_PLACE_MONS;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_UNABLE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(B_BUTTON))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MULTIMOVE_UNABLE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
|
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_HELD(L_BUTTON))
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_SCROLL_LEFT;
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_HELD(R_BUTTON))
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_SCROLL_RIGHT;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
return INPUT_NONE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 HandleInput_InParty(void)
|
|
|
|
{
|
|
|
|
u8 retVal;
|
|
|
|
bool8 gotoBox;
|
2020-05-21 19:04:13 +02:00
|
|
|
s8 cursorArea;
|
|
|
|
s8 cursorPosition;
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2019-05-26 11:07:30 +02:00
|
|
|
do
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
cursorArea = sCursorArea;
|
|
|
|
cursorPosition = sCursorPosition;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorHorizontalWrap = 0;
|
|
|
|
sStorage->cursorVerticalWrap = 0;
|
|
|
|
sStorage->cursorFlipTimer = 0;
|
2020-05-21 19:04:13 +02:00
|
|
|
gotoBox = FALSE;
|
2021-04-15 23:31:50 +02:00
|
|
|
retVal = INPUT_NONE;
|
2020-05-21 19:04:13 +02:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_UP))
|
2019-05-26 11:07:30 +02:00
|
|
|
{
|
|
|
|
if (--cursorPosition < 0)
|
|
|
|
cursorPosition = PARTY_SIZE;
|
2021-04-16 23:05:44 +02:00
|
|
|
if (cursorPosition != sCursorPosition)
|
2021-04-17 06:49:51 +02:00
|
|
|
retVal = INPUT_MOVE_CURSOR;
|
2019-05-26 11:07:30 +02:00
|
|
|
break;
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_DOWN))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
if (++cursorPosition > PARTY_SIZE)
|
|
|
|
cursorPosition = 0;
|
2021-04-16 23:05:44 +02:00
|
|
|
if (cursorPosition != sCursorPosition)
|
2021-04-17 06:49:51 +02:00
|
|
|
retVal = INPUT_MOVE_CURSOR;
|
2019-05-26 11:07:30 +02:00
|
|
|
break;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2021-04-16 23:05:44 +02:00
|
|
|
else if (JOY_REPEAT(DPAD_LEFT) && sCursorPosition != 0)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
retVal = INPUT_MOVE_CURSOR;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorPrevHorizPos = sCursorPosition;
|
2018-12-16 21:10:01 +01:00
|
|
|
cursorPosition = 0;
|
2019-05-26 11:07:30 +02:00
|
|
|
break;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_RIGHT))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorPosition == 0)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
retVal = INPUT_MOVE_CURSOR;
|
2021-04-18 05:40:27 +02:00
|
|
|
cursorPosition = sStorage->cursorPrevHorizPos;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
retVal = INPUT_HIDE_PARTY;
|
2018-12-16 21:10:01 +01:00
|
|
|
cursorArea = CURSOR_AREA_IN_BOX;
|
|
|
|
cursorPosition = 0;
|
|
|
|
}
|
2019-05-26 11:07:30 +02:00
|
|
|
break;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2019-05-26 11:07:30 +02:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorPosition == PARTY_SIZE)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption == OPTION_DEPOSIT)
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_CLOSE_BOX;
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2019-05-26 11:07:30 +02:00
|
|
|
gotoBox = TRUE;
|
|
|
|
}
|
2021-04-16 23:05:44 +02:00
|
|
|
else if (SetSelectionMenuTexts())
|
2019-05-26 11:07:30 +02:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (!sAutoActionOn)
|
|
|
|
return INPUT_IN_MENU;
|
2019-05-26 11:07:30 +02:00
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
switch (GetMenuItemTextId(0))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_STORE:
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_DEPOSIT;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_WITHDRAW:
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_WITHDRAW;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_MOVE:
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_MOVE_MON;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_SHIFT:
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_SHIFT_MON;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_PLACE:
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_PLACE_MON;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_TAKE:
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_TAKE_ITEM;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_GIVE:
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_GIVE_ITEM;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_SWITCH:
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_SWITCH_ITEMS;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
2019-05-26 11:07:30 +02:00
|
|
|
}
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(B_BUTTON))
|
2019-05-26 11:07:30 +02:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption == OPTION_DEPOSIT)
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_PRESSED_B;
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2019-05-26 11:07:30 +02:00
|
|
|
gotoBox = TRUE;
|
|
|
|
}
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2019-05-26 11:07:30 +02:00
|
|
|
if (gotoBox)
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
retVal = INPUT_HIDE_PARTY;
|
2019-05-26 11:07:30 +02:00
|
|
|
cursorArea = CURSOR_AREA_IN_BOX;
|
|
|
|
cursorPosition = 0;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(SELECT_BUTTON))
|
2019-05-26 11:07:30 +02:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
ToggleCursorAutoAction();
|
2021-04-15 23:31:50 +02:00
|
|
|
return INPUT_NONE;
|
2019-05-26 11:07:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} while (0);
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
if (retVal != INPUT_NONE)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (retVal != INPUT_HIDE_PARTY)
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCursorPosition(cursorArea, cursorPosition);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2018-12-21 22:35:01 +01:00
|
|
|
return retVal;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2020-05-21 19:04:13 +02:00
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static u8 HandleInput_OnBox(void)
|
|
|
|
{
|
|
|
|
u8 retVal;
|
2019-05-26 11:07:30 +02:00
|
|
|
s8 cursorArea;
|
|
|
|
s8 cursorPosition;
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2019-05-26 11:07:30 +02:00
|
|
|
do
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorHorizontalWrap = 0;
|
|
|
|
sStorage->cursorVerticalWrap = 0;
|
|
|
|
sStorage->cursorFlipTimer = 0;
|
2020-05-21 19:04:13 +02:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_UP))
|
2019-05-26 11:07:30 +02:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
retVal = INPUT_MOVE_CURSOR;
|
2019-05-26 11:07:30 +02:00
|
|
|
cursorArea = CURSOR_AREA_BUTTONS;
|
|
|
|
cursorPosition = 0;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorFlipTimer = 1;
|
2019-05-26 11:07:30 +02:00
|
|
|
break;
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_DOWN))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
retVal = INPUT_MOVE_CURSOR;
|
2018-12-16 21:10:01 +01:00
|
|
|
cursorArea = CURSOR_AREA_IN_BOX;
|
|
|
|
cursorPosition = 2;
|
2019-05-26 11:07:30 +02:00
|
|
|
break;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2019-05-26 11:07:30 +02:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_HELD(DPAD_LEFT))
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_SCROLL_LEFT;
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_HELD(DPAD_RIGHT))
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_SCROLL_RIGHT;
|
2019-05-26 11:07:30 +02:00
|
|
|
|
|
|
|
if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_HELD(L_BUTTON))
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_SCROLL_LEFT;
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_HELD(R_BUTTON))
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_SCROLL_RIGHT;
|
2019-05-26 11:07:30 +02:00
|
|
|
}
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2019-05-26 11:07:30 +02:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
AnimateBoxScrollArrows(FALSE);
|
2021-04-18 05:55:24 +02:00
|
|
|
AddBoxOptionsMenu();
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_BOX_OPTIONS;
|
2019-05-26 11:07:30 +02:00
|
|
|
}
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(B_BUTTON))
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_PRESSED_B;
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(SELECT_BUTTON))
|
2019-05-26 11:07:30 +02:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
ToggleCursorAutoAction();
|
2021-04-15 23:31:50 +02:00
|
|
|
return INPUT_NONE;
|
2019-05-26 11:07:30 +02:00
|
|
|
}
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
retVal = INPUT_NONE;
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2019-05-26 11:07:30 +02:00
|
|
|
} while (0);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
if (retVal != INPUT_NONE)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
if (cursorArea != CURSOR_AREA_BOX_TITLE)
|
2021-04-15 20:06:25 +02:00
|
|
|
AnimateBoxScrollArrows(FALSE);
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCursorPosition(cursorArea, cursorPosition);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
2020-05-21 19:04:13 +02:00
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static u8 HandleInput_OnButtons(void)
|
|
|
|
{
|
|
|
|
u8 retVal;
|
2020-05-21 19:04:13 +02:00
|
|
|
s8 cursorArea;
|
|
|
|
s8 cursorPosition;
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2019-05-26 11:07:30 +02:00
|
|
|
do
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
cursorArea = sCursorArea;
|
|
|
|
cursorPosition = sCursorPosition;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorHorizontalWrap = 0;
|
|
|
|
sStorage->cursorVerticalWrap = 0;
|
|
|
|
sStorage->cursorFlipTimer = 0;
|
2020-05-21 19:04:13 +02:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_UP))
|
2019-05-26 11:07:30 +02:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
retVal = INPUT_MOVE_CURSOR;
|
2019-05-26 11:07:30 +02:00
|
|
|
cursorArea = CURSOR_AREA_IN_BOX;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorVerticalWrap = -1;
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorPosition == 0)
|
2020-05-21 19:04:13 +02:00
|
|
|
cursorPosition = IN_BOX_COUNT - 1 - 5;
|
|
|
|
else
|
|
|
|
cursorPosition = IN_BOX_COUNT - 1;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorFlipTimer = 1;
|
2019-05-26 11:07:30 +02:00
|
|
|
break;
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
|
|
|
|
if (JOY_REPEAT(DPAD_DOWN | START_BUTTON))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
retVal = INPUT_MOVE_CURSOR;
|
|
|
|
cursorArea = CURSOR_AREA_BOX_TITLE;
|
2018-12-16 21:10:01 +01:00
|
|
|
cursorPosition = 0;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorFlipTimer = 1;
|
2019-05-26 11:07:30 +02:00
|
|
|
break;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2019-05-26 11:07:30 +02:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_LEFT))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
retVal = INPUT_MOVE_CURSOR;
|
2018-12-16 21:10:01 +01:00
|
|
|
if (--cursorPosition < 0)
|
|
|
|
cursorPosition = 1;
|
2019-05-26 11:07:30 +02:00
|
|
|
break;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_RIGHT))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
retVal = INPUT_MOVE_CURSOR;
|
2018-12-16 21:10:01 +01:00
|
|
|
if (++cursorPosition > 1)
|
|
|
|
cursorPosition = 0;
|
2019-05-26 11:07:30 +02:00
|
|
|
break;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2019-05-26 11:07:30 +02:00
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
// Button was pressed, determine which
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2021-04-16 23:05:44 +02:00
|
|
|
return (cursorPosition == 0) ? INPUT_SHOW_PARTY : INPUT_CLOSE_BOX;
|
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(B_BUTTON))
|
2021-04-16 23:05:44 +02:00
|
|
|
return INPUT_PRESSED_B;
|
2019-05-26 11:07:30 +02:00
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(SELECT_BUTTON))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
ToggleCursorAutoAction();
|
2021-04-15 23:31:50 +02:00
|
|
|
return INPUT_NONE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2019-05-26 11:07:30 +02:00
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
retVal = INPUT_NONE;
|
2019-05-26 11:07:30 +02:00
|
|
|
} while (0);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
if (retVal != INPUT_NONE)
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCursorPosition(cursorArea, cursorPosition);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 HandleInput(void)
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
u8 (*func)(void);
|
|
|
|
s8 area;
|
2021-04-15 23:31:50 +02:00
|
|
|
} static const inputFuncs[] =
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
{HandleInput_InBox, CURSOR_AREA_IN_BOX},
|
|
|
|
{HandleInput_InParty, CURSOR_AREA_IN_PARTY},
|
2021-04-17 06:49:51 +02:00
|
|
|
{HandleInput_OnBox, CURSOR_AREA_BOX_TITLE},
|
2018-12-16 21:10:01 +01:00
|
|
|
{HandleInput_OnButtons, CURSOR_AREA_BUTTONS},
|
2021-04-15 23:31:50 +02:00
|
|
|
{},
|
2018-12-16 21:10:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
u16 i = 0;
|
|
|
|
while (inputFuncs[i].func != NULL)
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (inputFuncs[i].area == sCursorArea)
|
2018-12-16 21:10:01 +01:00
|
|
|
return inputFuncs[i].func();
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
return INPUT_NONE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
static void AddBoxOptionsMenu(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
InitMenu();
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_JUMP);
|
|
|
|
SetMenuText(MENU_WALLPAPER);
|
|
|
|
SetMenuText(MENU_NAME);
|
|
|
|
SetMenuText(MENU_CANCEL);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static u8 SetSelectionMenuTexts(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
InitMenu();
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2021-04-16 23:05:44 +02:00
|
|
|
return SetMenuTexts_Mon();
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
2021-04-16 23:05:44 +02:00
|
|
|
return SetMenuTexts_Item();
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static bool8 SetMenuTexts_Mon(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
u16 species = GetSpeciesAtCursorPosition();
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
switch (sStorage->boxOption)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
case OPTION_DEPOSIT:
|
2021-04-16 05:27:05 +02:00
|
|
|
if (species != SPECIES_NONE)
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_STORE);
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
break;
|
2021-04-15 23:31:50 +02:00
|
|
|
case OPTION_WITHDRAW:
|
2021-04-16 05:27:05 +02:00
|
|
|
if (species != SPECIES_NONE)
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_WITHDRAW);
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
break;
|
2021-04-15 23:31:50 +02:00
|
|
|
case OPTION_MOVE_MONS:
|
2018-12-16 21:10:01 +01:00
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
if (species != SPECIES_NONE)
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_SHIFT);
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_PLACE);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
if (species != SPECIES_NONE)
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_MOVE);
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
2021-04-15 23:31:50 +02:00
|
|
|
case OPTION_MOVE_ITEMS:
|
2018-12-16 21:10:01 +01:00
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_SUMMARY);
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption == OPTION_MOVE_MONS)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorArea == CURSOR_AREA_IN_BOX)
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_WITHDRAW);
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_STORE);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_MARK);
|
|
|
|
SetMenuText(MENU_RELEASE);
|
|
|
|
SetMenuText(MENU_CANCEL);
|
2018-12-16 21:10:01 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static bool8 SetMenuTexts_Item(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->displayMonSpecies == SPECIES_EGG)
|
2018-12-16 21:10:01 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
if (!IsMovingItem())
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->displayMonItemId == ITEM_NONE)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->displayMonSpecies == SPECIES_NONE)
|
2018-12-16 21:10:01 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_GIVE_2);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (!ItemIsMail(sStorage->displayMonItemId))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_TAKE);
|
|
|
|
SetMenuText(MENU_BAG);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_INFO);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->displayMonItemId == ITEM_NONE)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->displayMonSpecies == SPECIES_NONE)
|
2018-12-16 21:10:01 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_GIVE);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (ItemIsMail(sStorage->displayMonItemId) == TRUE)
|
2018-12-16 21:10:01 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_SWITCH);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
SetMenuText(MENU_CANCEL);
|
2018-12-16 21:10:01 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: Cursor
|
|
|
|
//
|
|
|
|
// The functions below handle a few of the generic cursor features.
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void SpriteCB_CursorShadow(struct Sprite *sprite)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = sStorage->cursorSprite->x;
|
|
|
|
sprite->y = sStorage->cursorSprite->y + 20;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void CreateCursorSprites(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
u16 x, y;
|
|
|
|
u8 spriteId;
|
|
|
|
u8 priority, subpriority;
|
|
|
|
struct SpriteSheet spriteSheets[] =
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
{sHandCursor_Gfx, 0x800, GFXTAG_CURSOR},
|
|
|
|
{sHandCursorShadow_Gfx, 0x80, GFXTAG_CURSOR_SHADOW},
|
2018-12-16 21:10:01 +01:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SpritePalette spritePalettes[] =
|
|
|
|
{
|
2021-04-18 05:55:24 +02:00
|
|
|
{sHandCursor_Pal, PALTAG_MISC_1},
|
2018-12-16 21:10:01 +01:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static const struct OamData sOamData_Cursor =
|
2018-12-22 23:00:22 +01:00
|
|
|
{
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(32x32),
|
|
|
|
.size = SPRITE_SIZE(32x32),
|
2018-12-22 23:00:22 +01:00
|
|
|
.priority = 1,
|
|
|
|
};
|
2021-04-16 05:27:05 +02:00
|
|
|
static const struct OamData sOamData_CursorShadow =
|
2018-12-22 23:00:22 +01:00
|
|
|
{
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(16x16),
|
|
|
|
.size = SPRITE_SIZE(16x16),
|
2018-12-22 23:00:22 +01:00
|
|
|
.priority = 1,
|
|
|
|
};
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static const union AnimCmd sAnim_Cursor_Bouncing[] =
|
2018-12-22 23:00:22 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 30),
|
|
|
|
ANIMCMD_FRAME(16, 30),
|
|
|
|
ANIMCMD_JUMP(0)
|
|
|
|
};
|
2021-04-16 05:27:05 +02:00
|
|
|
static const union AnimCmd sAnim_Cursor_Still[] =
|
2018-12-22 23:00:22 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
2021-04-16 05:27:05 +02:00
|
|
|
static const union AnimCmd sAnim_Cursor_Open[] =
|
2018-12-22 23:00:22 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(32, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
2021-04-16 05:27:05 +02:00
|
|
|
static const union AnimCmd sAnim_Cursor_Fist[] =
|
2018-12-22 23:00:22 +01:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(48, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static const union AnimCmd *const sAnims_Cursor[] =
|
2018-12-22 23:00:22 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
[CURSOR_ANIM_BOUNCE] = sAnim_Cursor_Bouncing,
|
|
|
|
[CURSOR_ANIM_STILL] = sAnim_Cursor_Still,
|
|
|
|
[CURSOR_ANIM_OPEN] = sAnim_Cursor_Open,
|
|
|
|
[CURSOR_ANIM_FIST] = sAnim_Cursor_Fist
|
2018-12-22 23:00:22 +01:00
|
|
|
};
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_Cursor =
|
2018-12-22 23:00:22 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
.tileTag = GFXTAG_CURSOR,
|
2021-04-18 05:55:24 +02:00
|
|
|
.paletteTag = PALTAG_MISC_2,
|
2021-04-16 05:27:05 +02:00
|
|
|
.oam = &sOamData_Cursor,
|
|
|
|
.anims = sAnims_Cursor,
|
2018-12-22 23:00:22 +01:00
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
};
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_CursorShadow =
|
2018-12-22 23:00:22 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
.tileTag = GFXTAG_CURSOR_SHADOW,
|
2021-04-18 05:55:24 +02:00
|
|
|
.paletteTag = PALTAG_MISC_2,
|
2021-04-16 05:27:05 +02:00
|
|
|
.oam = &sOamData_CursorShadow,
|
2018-12-22 23:00:22 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
2021-04-16 05:27:05 +02:00
|
|
|
.callback = SpriteCB_CursorShadow,
|
2018-12-22 23:00:22 +01:00
|
|
|
};
|
2018-12-16 21:10:01 +01:00
|
|
|
|
|
|
|
LoadSpriteSheets(spriteSheets);
|
|
|
|
LoadSpritePalettes(spritePalettes);
|
2021-04-18 05:55:24 +02:00
|
|
|
sStorage->cursorPalNums[0] = IndexOfSpritePaletteTag(PALTAG_MISC_2); // White hand, normal
|
|
|
|
sStorage->cursorPalNums[1] = IndexOfSpritePaletteTag(PALTAG_MISC_1); // Yellow hand, when auto-action is on
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
GetCursorCoordsByPos(sCursorArea, sCursorPosition, &x, &y);
|
2021-04-16 05:27:05 +02:00
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_Cursor, x, y, 6);
|
2018-12-16 21:10:01 +01:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorSprite = &gSprites[spriteId];
|
|
|
|
sStorage->cursorSprite->oam.paletteNum = sStorage->cursorPalNums[sAutoActionOn];
|
|
|
|
sStorage->cursorSprite->oam.priority = 1;
|
2018-12-16 21:10:01 +01:00
|
|
|
if (sIsMonBeingMoved)
|
2021-04-18 05:40:27 +02:00
|
|
|
StartSpriteAnim(sStorage->cursorSprite, CURSOR_ANIM_FIST);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorSprite = NULL;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorArea == CURSOR_AREA_IN_PARTY)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
subpriority = 13;
|
|
|
|
priority = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
subpriority = 21;
|
|
|
|
priority = 2;
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_CursorShadow, 0, 0, subpriority);
|
2018-12-16 21:10:01 +01:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorShadowSprite = &gSprites[spriteId];
|
|
|
|
sStorage->cursorShadowSprite->oam.priority = priority;
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorArea)
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorShadowSprite->invisible = TRUE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorShadowSprite = NULL;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static void ToggleCursorAutoAction(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
sAutoActionOn = !sAutoActionOn;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorSprite->oam.paletteNum = sStorage->cursorPalNums[sAutoActionOn];
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static u8 GetCursorPosition(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
return sCursorPosition;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static void GetCursorBoxColumnAndRow(u8 *column, u8 *row)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorArea == CURSOR_AREA_IN_BOX)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
*column = sCursorPosition % IN_BOX_COLUMNS;
|
|
|
|
*row = sCursorPosition / IN_BOX_COLUMNS;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
*column = 0;
|
|
|
|
*row = 0;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void StartCursorAnim(u8 animNum)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
StartSpriteAnim(sStorage->cursorSprite, animNum);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
// Unused
|
|
|
|
static u8 GetMovingMonOriginalBoxId(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
return sMovingMonOrigBoxId;
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void SetCursorPriorityTo1(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->cursorSprite->oam.priority = 1;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void TryHideItemAtCursor(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorArea == CURSOR_AREA_IN_BOX)
|
2021-04-17 06:49:51 +02:00
|
|
|
TryHideItemIconAtPos(CURSOR_AREA_IN_BOX, sCursorPosition);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void TryShowItemAtCursor(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorArea == CURSOR_AREA_IN_BOX)
|
2021-04-17 06:49:51 +02:00
|
|
|
TryLoadItemIconAtPos(CURSOR_AREA_IN_BOX, sCursorPosition);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: Menu
|
|
|
|
//
|
|
|
|
// The functions below handle the generic options menu that comes up whenever
|
|
|
|
// something in the PC is selected.
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void InitMenu(void)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->menuItemsCount = 0;
|
|
|
|
sStorage->menuWidth = 0;
|
|
|
|
sStorage->menuWindow.bg = 0;
|
|
|
|
sStorage->menuWindow.paletteNum = 15;
|
|
|
|
sStorage->menuWindow.baseBlock = 92;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
static const u8 *const sMenuTexts[] =
|
|
|
|
{
|
|
|
|
[MENU_CANCEL] = gPCText_Cancel,
|
|
|
|
[MENU_STORE] = gPCText_Store,
|
|
|
|
[MENU_WITHDRAW] = gPCText_Withdraw,
|
|
|
|
[MENU_MOVE] = gPCText_Move,
|
|
|
|
[MENU_SHIFT] = gPCText_Shift,
|
|
|
|
[MENU_PLACE] = gPCText_Place,
|
|
|
|
[MENU_SUMMARY] = gPCText_Summary,
|
|
|
|
[MENU_RELEASE] = gPCText_Release,
|
|
|
|
[MENU_MARK] = gPCText_Mark,
|
|
|
|
[MENU_JUMP] = gPCText_Jump,
|
|
|
|
[MENU_WALLPAPER] = gPCText_Wallpaper,
|
|
|
|
[MENU_NAME] = gPCText_Name,
|
|
|
|
[MENU_TAKE] = gPCText_Take,
|
|
|
|
[MENU_GIVE] = gPCText_Give,
|
|
|
|
[MENU_GIVE_2] = gPCText_Give,
|
|
|
|
[MENU_SWITCH] = gPCText_Switch,
|
|
|
|
[MENU_BAG] = gPCText_Bag,
|
|
|
|
[MENU_INFO] = gPCText_Info,
|
|
|
|
[MENU_SCENERY_1] = gPCText_Scenery1,
|
|
|
|
[MENU_SCENERY_2] = gPCText_Scenery2,
|
|
|
|
[MENU_SCENERY_3] = gPCText_Scenery3,
|
|
|
|
[MENU_ETCETERA] = gPCText_Etcetera,
|
|
|
|
[MENU_FRIENDS] = gPCText_Friends,
|
|
|
|
[MENU_FOREST] = gPCText_Forest,
|
|
|
|
[MENU_CITY] = gPCText_City,
|
|
|
|
[MENU_DESERT] = gPCText_Desert,
|
|
|
|
[MENU_SAVANNA] = gPCText_Savanna,
|
|
|
|
[MENU_CRAG] = gPCText_Crag,
|
|
|
|
[MENU_VOLCANO] = gPCText_Volcano,
|
|
|
|
[MENU_SNOW] = gPCText_Snow,
|
|
|
|
[MENU_CAVE] = gPCText_Cave,
|
|
|
|
[MENU_BEACH] = gPCText_Beach,
|
|
|
|
[MENU_SEAFLOOR] = gPCText_Seafloor,
|
|
|
|
[MENU_RIVER] = gPCText_River,
|
|
|
|
[MENU_SKY] = gPCText_Sky,
|
|
|
|
[MENU_POLKADOT] = gPCText_PolkaDot,
|
|
|
|
[MENU_POKECENTER] = gPCText_Pokecenter,
|
|
|
|
[MENU_MACHINE] = gPCText_Machine,
|
|
|
|
[MENU_SIMPLE] = gPCText_Simple,
|
2018-12-16 21:10:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static void SetMenuText(u8 textId)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->menuItemsCount < ARRAY_COUNT(sStorage->menuItems))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
u8 len;
|
2021-04-18 05:40:27 +02:00
|
|
|
struct StorageMenu *menu = &sStorage->menuItems[sStorage->menuItemsCount];
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
menu->text = sMenuTexts[textId];
|
2018-12-16 21:10:01 +01:00
|
|
|
menu->textId = textId;
|
|
|
|
len = StringLength(menu->text);
|
2021-04-18 05:40:27 +02:00
|
|
|
if (len > sStorage->menuWidth)
|
|
|
|
sStorage->menuWidth = len;
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->menuItemsCount++;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
static s8 GetMenuItemTextId(u8 menuIdx)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (menuIdx >= sStorage->menuItemsCount)
|
2018-12-16 21:10:01 +01:00
|
|
|
return -1;
|
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
return sStorage->menuItems[menuIdx].textId;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void AddMenu(void)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->menuWindow.width = sStorage->menuWidth + 2;
|
|
|
|
sStorage->menuWindow.height = 2 * sStorage->menuItemsCount;
|
|
|
|
sStorage->menuWindow.tilemapLeft = 29 - sStorage->menuWindow.width;
|
|
|
|
sStorage->menuWindow.tilemapTop = 15 - sStorage->menuWindow.height;
|
|
|
|
sStorage->menuWindowId = AddWindow(&sStorage->menuWindow);
|
|
|
|
ClearWindowTilemap(sStorage->menuWindowId);
|
|
|
|
DrawStdFrameWithCustomTileAndPalette(sStorage->menuWindowId, FALSE, 11, 14);
|
|
|
|
PrintMenuTable(sStorage->menuWindowId, sStorage->menuItemsCount, (void*)sStorage->menuItems);
|
|
|
|
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sStorage->menuWindowId, sStorage->menuItemsCount, 0);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->menuUnusedField = 0;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
// Called after AddMenu to determine whether or not the handler callback should
|
|
|
|
// wait to move on to the next state. Evidently there was no need to wait, and
|
|
|
|
// now it always returns FALSE
|
|
|
|
static bool8 IsMenuLoading(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2018-12-22 23:00:22 +01:00
|
|
|
return FALSE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
static s16 HandleMenuInput(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
s32 input = MENU_NOTHING_CHOSEN;
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2019-05-26 11:07:30 +02:00
|
|
|
do
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2019-05-26 11:07:30 +02:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
input = Menu_GetCursorPos();
|
2019-05-26 11:07:30 +02:00
|
|
|
break;
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(B_BUTTON))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-15 19:31:18 +02:00
|
|
|
input = MENU_B_PRESSED;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_NEW(DPAD_UP))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
Menu_MoveCursor(-1);
|
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if (JOY_NEW(DPAD_DOWN))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
Menu_MoveCursor(1);
|
|
|
|
}
|
2019-05-26 11:07:30 +02:00
|
|
|
} while (0);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
if (input != MENU_NOTHING_CHOSEN)
|
|
|
|
RemoveMenu();
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
if (input >= 0)
|
2021-04-18 05:40:27 +02:00
|
|
|
input = sStorage->menuItems[input].textId;
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
return input;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
static void RemoveMenu(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
ClearStdWindowAndFrameToTransparent(sStorage->menuWindowId, TRUE);
|
|
|
|
RemoveWindow(sStorage->menuWindowId);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2018-12-17 23:00:08 +01:00
|
|
|
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
//------------------------------------------------------------------------------
|
2021-04-17 06:49:51 +02:00
|
|
|
// SECTION: MultiMove
|
2021-04-16 23:05:44 +02:00
|
|
|
//
|
|
|
|
// The functions below handle moving and selecting multiple Pokémon at once.
|
|
|
|
// The icon sprites are moved to bg 0, and this bg is manipulated to move
|
|
|
|
// them as a group.
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
static const struct WindowTemplate sWindowTemplate_MultiMove =
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 10,
|
|
|
|
.tilemapTop = 3,
|
|
|
|
.width = 20,
|
|
|
|
.height = 18,
|
|
|
|
.paletteNum = 9,
|
|
|
|
.baseBlock = 0xA,
|
|
|
|
};
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
EWRAM_DATA static struct
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
u8 funcId;
|
2018-12-20 22:14:36 +01:00
|
|
|
u8 state;
|
|
|
|
u8 fromColumn;
|
2021-04-16 11:14:35 +02:00
|
|
|
u8 fromRow;
|
2018-12-20 22:14:36 +01:00
|
|
|
u8 toColumn;
|
2021-04-16 11:14:35 +02:00
|
|
|
u8 toRow;
|
2021-04-16 23:05:44 +02:00
|
|
|
u8 cursorColumn;
|
|
|
|
u8 cursorRow;
|
2018-12-20 22:14:36 +01:00
|
|
|
u8 minColumn;
|
2021-04-16 11:14:35 +02:00
|
|
|
u8 minRow;
|
|
|
|
u8 columnsTotal;
|
2018-12-20 22:14:36 +01:00
|
|
|
u8 rowsTotal;
|
|
|
|
u16 bgX;
|
|
|
|
u16 bgY;
|
2021-04-16 23:05:44 +02:00
|
|
|
u16 bgMoveSteps;
|
2018-12-20 22:14:36 +01:00
|
|
|
struct BoxPokemon boxMons[IN_BOX_COUNT];
|
2021-04-16 23:05:44 +02:00
|
|
|
} *sMultiMove = NULL;
|
2018-12-20 22:14:36 +01:00
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static bool8 MultiMove_Init(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove = Alloc(sizeof(*sMultiMove));
|
|
|
|
if (sMultiMove != NULL)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->multiMoveWindowId = AddWindow8Bit(&sWindowTemplate_MultiMove);
|
|
|
|
if (sStorage->multiMoveWindowId != WINDOW_NONE)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
FillWindowPixelBuffer(sStorage->multiMoveWindowId, PIXEL_FILL(0));
|
2018-12-17 23:00:08 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static void MultiMove_Free(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sMultiMove != NULL)
|
|
|
|
Free(sMultiMove);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static void MultiMove_SetFunction(u8 id)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->funcId = id;
|
|
|
|
sMultiMove->state = 0;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
// Returns TRUE if the called function has more to do, FALSE otherwise
|
|
|
|
static bool8 MultiMove_RunFunction(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
switch (sMultiMove->funcId)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
case MULTIMOVE_START:
|
|
|
|
return MultiMove_Start();
|
|
|
|
case MULTIMOVE_CANCEL:
|
|
|
|
return MultiMove_Cancel();
|
|
|
|
case MULTIMOVE_CHANGE_SELECTION:
|
|
|
|
return MultiMove_ChangeSelection();
|
|
|
|
case MULTIMOVE_GRAB_SELECTION:
|
|
|
|
return MultiMove_GrabSelection();
|
|
|
|
case MULTIMOVE_MOVE_MONS:
|
|
|
|
return MultiMove_MoveMons();
|
|
|
|
case MULTIMOVE_PLACE_MONS:
|
|
|
|
return MultiMove_PlaceMons();
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static bool8 MultiMove_Start(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
switch (sMultiMove->state)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
HideBg(0);
|
|
|
|
sub_80D304C(0x80);
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->state++;
|
2018-12-17 23:00:08 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-16 23:05:44 +02:00
|
|
|
GetCursorBoxColumnAndRow(&sMultiMove->fromColumn, &sMultiMove->fromRow);
|
|
|
|
sMultiMove->toColumn = sMultiMove->fromColumn;
|
|
|
|
sMultiMove->toRow = sMultiMove->fromRow;
|
2018-12-17 23:00:08 +01:00
|
|
|
ChangeBgX(0, -1024, 0);
|
|
|
|
ChangeBgY(0, -1024, 0);
|
|
|
|
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
|
2021-04-18 05:40:27 +02:00
|
|
|
FillWindowPixelBuffer8Bit(sStorage->multiMoveWindowId, PIXEL_FILL(0));
|
2021-04-16 23:05:44 +02:00
|
|
|
MultiMove_SetIconToBg(sMultiMove->fromColumn, sMultiMove->fromRow);
|
2018-12-26 13:05:02 +01:00
|
|
|
SetBgAttribute(0, BG_ATTR_PALETTEMODE, 1);
|
2021-04-18 05:40:27 +02:00
|
|
|
PutWindowTilemap(sStorage->multiMoveWindowId);
|
|
|
|
CopyWindowToVram8Bit(sStorage->multiMoveWindowId, 3);
|
2018-12-21 22:35:01 +01:00
|
|
|
BlendPalettes(0x3F00, 8, RGB_WHITE);
|
2021-04-16 05:27:05 +02:00
|
|
|
StartCursorAnim(CURSOR_ANIM_OPEN);
|
2018-12-17 23:00:08 +01:00
|
|
|
SetGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR);
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->state++;
|
2018-12-17 23:00:08 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
|
|
|
ShowBg(0);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static bool8 MultiMove_Cancel(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
switch (sMultiMove->state)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
HideBg(0);
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->state++;
|
2018-12-17 23:00:08 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-16 23:05:44 +02:00
|
|
|
MultiMove_ResetBg();
|
2021-04-16 05:27:05 +02:00
|
|
|
StartCursorAnim(CURSOR_ANIM_BOUNCE);
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->state++;
|
2018-12-17 23:00:08 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
SetCursorPriorityTo1();
|
2020-08-07 08:00:41 +02:00
|
|
|
LoadPalette(GetTextWindowPalette(3), 0xD0, 0x20);
|
2018-12-17 23:00:08 +01:00
|
|
|
ShowBg(0);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static bool8 MultiMove_ChangeSelection(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
switch (sMultiMove->state)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-16 23:05:44 +02:00
|
|
|
if (!UpdateCursorPos())
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
GetCursorBoxColumnAndRow(&sMultiMove->cursorColumn, &sMultiMove->cursorRow);
|
|
|
|
MultiMove_UpdateSelectedIcons();
|
|
|
|
sMultiMove->toColumn = sMultiMove->cursorColumn;
|
|
|
|
sMultiMove->toRow = sMultiMove->cursorRow;
|
2021-04-18 05:40:27 +02:00
|
|
|
CopyWindowToVram8Bit(sStorage->multiMoveWindowId, 2);
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->state++;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
return IsDma3ManagerBusyWithBgCopy();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static bool8 MultiMove_GrabSelection(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
bool8 movingBg, movingMon;
|
2018-12-17 23:00:08 +01:00
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
switch (sMultiMove->state)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-16 23:05:44 +02:00
|
|
|
MultiMove_GetMonsFromSelection();
|
|
|
|
MultiMove_RemoveMonsFromBox();
|
2021-04-17 23:28:18 +02:00
|
|
|
InitMultiMonPlaceChange(FALSE);
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->state++;
|
2018-12-17 23:00:08 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!DoMonPlaceChange())
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
StartCursorAnim(CURSOR_ANIM_FIST);
|
2021-04-16 23:05:44 +02:00
|
|
|
MultiMove_InitMove(0, 256, 8);
|
2021-04-17 23:28:18 +02:00
|
|
|
InitMultiMonPlaceChange(TRUE);
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->state++;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-16 23:05:44 +02:00
|
|
|
movingBg = MultiMove_UpdateMove();
|
|
|
|
movingMon = DoMonPlaceChange();
|
|
|
|
if (!movingBg && !movingMon)
|
|
|
|
return FALSE; // Finished
|
2018-12-17 23:00:08 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static bool8 MultiMove_MoveMons(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
bool8 movingCursor = UpdateCursorPos();
|
|
|
|
bool8 movingBg = MultiMove_UpdateMove();
|
2018-12-17 23:00:08 +01:00
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
if (!movingCursor && !movingBg)
|
2018-12-17 23:00:08 +01:00
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static bool8 MultiMove_PlaceMons(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
switch (sMultiMove->state)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-16 23:05:44 +02:00
|
|
|
MultiMove_SetPlacedMonData();
|
|
|
|
MultiMove_InitMove(0, -256, 8);
|
2021-04-17 23:28:18 +02:00
|
|
|
InitMultiMonPlaceChange(FALSE);
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->state++;
|
2018-12-17 23:00:08 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-16 23:05:44 +02:00
|
|
|
if (!DoMonPlaceChange() && !MultiMove_UpdateMove())
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
MultiMove_CreatePlacedMonIcons();
|
2021-04-16 05:27:05 +02:00
|
|
|
StartCursorAnim(CURSOR_ANIM_OPEN);
|
2021-04-17 23:28:18 +02:00
|
|
|
InitMultiMonPlaceChange(TRUE);
|
2018-12-17 23:00:08 +01:00
|
|
|
HideBg(0);
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->state++;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!DoMonPlaceChange())
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
StartCursorAnim(CURSOR_ANIM_BOUNCE);
|
2021-04-16 23:05:44 +02:00
|
|
|
MultiMove_ResetBg();
|
|
|
|
sMultiMove->state++;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2020-08-07 08:00:41 +02:00
|
|
|
LoadPalette(GetTextWindowPalette(3), 0xD0, 0x20);
|
2021-04-16 05:27:05 +02:00
|
|
|
SetCursorPriorityTo1();
|
2018-12-17 23:00:08 +01:00
|
|
|
ShowBg(0);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
// Returns TRUE if the movement was successful, FALSE otherwise
|
|
|
|
static bool8 MultiMove_TryMoveGroup(u8 dir)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
switch (dir)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
case 0: // Up
|
|
|
|
if (sMultiMove->minRow == 0)
|
2018-12-17 23:00:08 +01:00
|
|
|
return FALSE;
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->minRow--;
|
|
|
|
MultiMove_InitMove(0, 1024, 6);
|
2018-12-17 23:00:08 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case 1: // Down
|
|
|
|
if (sMultiMove->minRow + sMultiMove->rowsTotal >= IN_BOX_ROWS)
|
2018-12-17 23:00:08 +01:00
|
|
|
return FALSE;
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->minRow++;
|
|
|
|
MultiMove_InitMove(0, -1024, 6);
|
2018-12-17 23:00:08 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case 2: // Left
|
|
|
|
if (sMultiMove->minColumn == 0)
|
2018-12-17 23:00:08 +01:00
|
|
|
return FALSE;
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->minColumn--;
|
|
|
|
MultiMove_InitMove(1024, 0, 6);
|
2018-12-17 23:00:08 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case 3: // Right
|
|
|
|
if (sMultiMove->minColumn + sMultiMove->columnsTotal >= IN_BOX_COLUMNS)
|
2018-12-17 23:00:08 +01:00
|
|
|
return FALSE;
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->minColumn++;
|
|
|
|
MultiMove_InitMove(-1024, 0, 6);
|
2018-12-17 23:00:08 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static void MultiMove_UpdateSelectedIcons(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
s16 columnChange = (abs(sMultiMove->fromColumn - sMultiMove->cursorColumn)) - (abs(sMultiMove->fromColumn - sMultiMove->toColumn));
|
|
|
|
s16 rowChange = (abs(sMultiMove->fromRow - sMultiMove->cursorRow)) - (abs(sMultiMove->fromRow - sMultiMove->toRow));
|
2018-12-17 23:00:08 +01:00
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
if (columnChange > 0)
|
|
|
|
MultiMove_SelectColumn(sMultiMove->cursorColumn, sMultiMove->fromRow, sMultiMove->toRow);
|
2018-12-17 23:00:08 +01:00
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
if (columnChange < 0)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
MultiMove_DeselectColumn(sMultiMove->toColumn, sMultiMove->fromRow, sMultiMove->toRow);
|
|
|
|
MultiMove_SelectColumn(sMultiMove->cursorColumn, sMultiMove->fromRow, sMultiMove->toRow);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
if (rowChange > 0)
|
|
|
|
MultiMove_SelectRow(sMultiMove->cursorRow, sMultiMove->fromColumn, sMultiMove->toColumn);
|
2018-12-17 23:00:08 +01:00
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
if (rowChange < 0)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
MultiMove_DeselectRow(sMultiMove->toRow, sMultiMove->fromColumn, sMultiMove->toColumn);
|
|
|
|
MultiMove_SelectRow(sMultiMove->cursorRow, sMultiMove->fromColumn, sMultiMove->toColumn);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static void MultiMove_SelectColumn(u8 column, u8 minRow, u8 maxRow)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (minRow > maxRow)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
u8 temp;
|
|
|
|
SWAP(minRow, maxRow, temp);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
while (minRow <= maxRow)
|
|
|
|
MultiMove_SetIconToBg(column, minRow++);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static void MultiMove_SelectRow(u8 row, u8 minColumn, u8 maxColumn)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (minColumn > maxColumn)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
u8 temp;
|
|
|
|
SWAP(minColumn, maxColumn, temp);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
while (minColumn <= maxColumn)
|
|
|
|
MultiMove_SetIconToBg(minColumn++, row);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static void MultiMove_DeselectColumn(u8 column, u8 minRow, u8 maxRow)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (minRow > maxRow)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
u8 temp;
|
|
|
|
SWAP(minRow, maxRow, temp);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
while (minRow <= maxRow)
|
|
|
|
MultiMove_ClearIconFromBg(column, minRow++);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static void MultiMove_DeselectRow(u8 row, u8 minColumn, u8 maxColumn)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (minColumn > maxColumn)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
u8 temp;
|
|
|
|
SWAP(minColumn, maxColumn, temp);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
while (minColumn <= maxColumn)
|
|
|
|
MultiMove_ClearIconFromBg(minColumn++, row);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static void MultiMove_SetIconToBg(u8 x, u8 y)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 11:14:35 +02:00
|
|
|
u8 position = x + (IN_BOX_COLUMNS * y);
|
2018-12-17 23:00:08 +01:00
|
|
|
u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2);
|
|
|
|
u32 personality = GetCurrentBoxMonData(position, MON_DATA_PERSONALITY);
|
|
|
|
|
|
|
|
if (species != SPECIES_NONE)
|
|
|
|
{
|
2020-12-22 07:39:19 +01:00
|
|
|
const u8 *iconGfx = GetMonIconPtr(species, personality);
|
2018-12-17 23:00:08 +01:00
|
|
|
u8 index = GetValidMonIconPalIndex(species) + 8;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
BlitBitmapRectToWindow4BitTo8Bit(sStorage->multiMoveWindowId,
|
2018-12-17 23:00:08 +01:00
|
|
|
iconGfx,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
32,
|
|
|
|
32,
|
2021-04-16 11:14:35 +02:00
|
|
|
24 * x,
|
|
|
|
24 * y,
|
2018-12-17 23:00:08 +01:00
|
|
|
32,
|
|
|
|
32,
|
|
|
|
index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static void MultiMove_ClearIconFromBg(u8 x, u8 y)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 11:14:35 +02:00
|
|
|
u8 position = x + (IN_BOX_COLUMNS * y);
|
2018-12-17 23:00:08 +01:00
|
|
|
u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2);
|
|
|
|
|
|
|
|
if (species != SPECIES_NONE)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
FillWindowPixelRect8Bit(sStorage->multiMoveWindowId,
|
2019-03-02 23:25:39 +01:00
|
|
|
PIXEL_FILL(0),
|
2021-04-16 11:14:35 +02:00
|
|
|
24 * x,
|
|
|
|
24 * y,
|
2018-12-17 23:00:08 +01:00
|
|
|
32,
|
|
|
|
32);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static void MultiMove_InitMove(u16 x, u16 y, u16 arg2)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->bgX = x;
|
|
|
|
sMultiMove->bgY = y;
|
|
|
|
sMultiMove->bgMoveSteps = arg2;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static u8 MultiMove_UpdateMove(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sMultiMove->bgMoveSteps != 0)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
ChangeBgX(0, sMultiMove->bgX, 1);
|
|
|
|
ChangeBgY(0, sMultiMove->bgY, 1);
|
|
|
|
sMultiMove->bgMoveSteps--;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
return sMultiMove->bgMoveSteps;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
// Store the Pokémon that the player is picking up
|
|
|
|
static void MultiMove_GetMonsFromSelection(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-01-19 23:50:52 +01:00
|
|
|
s32 i, j;
|
2021-04-16 11:14:35 +02:00
|
|
|
s32 columnCount, rowCount;
|
2018-12-17 23:00:08 +01:00
|
|
|
u8 boxId;
|
|
|
|
u8 monArrayId;
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->minColumn = min(sMultiMove->fromColumn, sMultiMove->toColumn);
|
|
|
|
sMultiMove->minRow = min(sMultiMove->fromRow, sMultiMove->toRow);
|
|
|
|
sMultiMove->columnsTotal = abs(sMultiMove->fromColumn - sMultiMove->toColumn) + 1;
|
|
|
|
sMultiMove->rowsTotal = abs(sMultiMove->fromRow - sMultiMove->toRow) + 1;
|
2018-12-17 23:00:08 +01:00
|
|
|
boxId = StorageGetCurrentBox();
|
|
|
|
monArrayId = 0;
|
2021-04-16 23:05:44 +02:00
|
|
|
columnCount = sMultiMove->minColumn + sMultiMove->columnsTotal;
|
|
|
|
rowCount = sMultiMove->minRow + sMultiMove->rowsTotal;
|
|
|
|
for (i = sMultiMove->minRow; i < rowCount; i++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
u8 boxPosition = (IN_BOX_COLUMNS * i) + sMultiMove->minColumn;
|
|
|
|
for (j = sMultiMove->minColumn; j < columnCount; j++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
struct BoxPokemon *boxMon = GetBoxedMonPtr(boxId, boxPosition);
|
2020-12-27 02:47:36 +01:00
|
|
|
// UB: possible null dereference
|
|
|
|
#ifdef UBFIX
|
|
|
|
if (boxMon != NULL)
|
|
|
|
#endif
|
2021-04-16 23:05:44 +02:00
|
|
|
sMultiMove->boxMons[monArrayId] = *boxMon;
|
|
|
|
|
2018-12-17 23:00:08 +01:00
|
|
|
monArrayId++;
|
|
|
|
boxPosition++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
// The Pokémon the player has picked up have been stored, now delete
|
|
|
|
// them from their original positions
|
|
|
|
static void MultiMove_RemoveMonsFromBox(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
s32 i, j;
|
2021-04-16 23:05:44 +02:00
|
|
|
s32 columnCount = sMultiMove->minColumn + sMultiMove->columnsTotal;
|
|
|
|
s32 rowCount = sMultiMove->minRow + sMultiMove->rowsTotal;
|
2018-12-17 23:00:08 +01:00
|
|
|
u8 boxId = StorageGetCurrentBox();
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
for (i = sMultiMove->minRow; i < rowCount; i++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
u8 boxPosition = (IN_BOX_COLUMNS * i) + sMultiMove->minColumn;
|
|
|
|
for (j = sMultiMove->minColumn; j < columnCount; j++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-09-29 06:59:31 +02:00
|
|
|
DestroyBoxMonIconAtPosition(boxPosition);//bookmark
|
2018-12-17 23:00:08 +01:00
|
|
|
ZeroBoxMonAt(boxId, boxPosition);
|
|
|
|
boxPosition++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static void MultiMove_CreatePlacedMonIcons(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
s32 i, j;
|
2021-04-16 23:05:44 +02:00
|
|
|
s32 columnCount = sMultiMove->minColumn + sMultiMove->columnsTotal;
|
|
|
|
s32 rowCount = sMultiMove->minRow + sMultiMove->rowsTotal;
|
2018-12-17 23:00:08 +01:00
|
|
|
u8 monArrayId = 0;
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
for (i = sMultiMove->minRow; i < rowCount; i++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
u8 boxPosition = (IN_BOX_COLUMNS * i) + sMultiMove->minColumn;
|
|
|
|
for (j = sMultiMove->minColumn; j < columnCount; j++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (GetBoxMonData(&sMultiMove->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES))
|
2021-04-18 01:28:31 +02:00
|
|
|
CreateBoxMonIconAtPos(boxPosition);
|
2018-12-17 23:00:08 +01:00
|
|
|
monArrayId++;
|
|
|
|
boxPosition++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static void MultiMove_SetPlacedMonData(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
s32 i, j;
|
2021-04-16 23:05:44 +02:00
|
|
|
s32 columnCount = sMultiMove->minColumn + sMultiMove->columnsTotal;
|
|
|
|
s32 rowCount = sMultiMove->minRow + sMultiMove->rowsTotal;
|
2018-12-17 23:00:08 +01:00
|
|
|
u8 boxId = StorageGetCurrentBox();
|
|
|
|
u8 monArrayId = 0;
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
for (i = sMultiMove->minRow; i < rowCount; i++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
u8 boxPosition = (IN_BOX_COLUMNS * i) + sMultiMove->minColumn;
|
|
|
|
for (j = sMultiMove->minColumn; j < columnCount; j++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (GetBoxMonData(&sMultiMove->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES))
|
|
|
|
SetBoxMonAt(boxId, boxPosition, &sMultiMove->boxMons[monArrayId]);
|
2018-12-17 23:00:08 +01:00
|
|
|
boxPosition++;
|
|
|
|
monArrayId++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static void MultiMove_ResetBg(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
ChangeBgX(0, 0, 0);
|
|
|
|
ChangeBgY(0, 0, 0);
|
2018-12-26 13:05:02 +01:00
|
|
|
SetBgAttribute(0, BG_ATTR_PALETTEMODE, 0);
|
2018-12-17 23:00:08 +01:00
|
|
|
ClearGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR);
|
|
|
|
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32);
|
|
|
|
CopyBgTilemapBufferToVram(0);
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static u8 MultiMove_GetOrigin(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
return (IN_BOX_COLUMNS * sMultiMove->fromRow) + sMultiMove->fromColumn;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
static bool8 MultiMove_CanPlaceSelection(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
s32 i, j;
|
2021-04-16 23:05:44 +02:00
|
|
|
s32 columnCount = sMultiMove->minColumn + sMultiMove->columnsTotal;
|
|
|
|
s32 rowCount = sMultiMove->minRow + sMultiMove->rowsTotal;
|
2018-12-17 23:00:08 +01:00
|
|
|
u8 monArrayId = 0;
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
for (i = sMultiMove->minRow; i < rowCount; i++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
u8 boxPosition = (IN_BOX_COLUMNS * i) + sMultiMove->minColumn;
|
|
|
|
for (j = sMultiMove->minColumn; j < columnCount; j++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (GetBoxMonData(&sMultiMove->boxMons[monArrayId], MON_DATA_SANITY_HAS_SPECIES)
|
2018-12-17 23:00:08 +01:00
|
|
|
&& GetCurrentBoxMonData(boxPosition, MON_DATA_SANITY_HAS_SPECIES))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
monArrayId++;
|
|
|
|
boxPosition++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: Item mode
|
|
|
|
//
|
|
|
|
// The functions below handle the Move Items mode
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
|
|
|
|
static const u32 sItemInfoFrame_Gfx[] = INCBIN_U32("graphics/pokemon_storage/item_info_frame.4bpp");
|
|
|
|
|
|
|
|
static const struct OamData sOamData_ItemIcon =
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-12-04 21:25:13 +01:00
|
|
|
.affineMode = ST_OAM_AFFINE_NORMAL,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
2018-12-17 23:00:08 +01:00
|
|
|
.mosaic = 0,
|
2019-12-04 21:25:13 +01:00
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-03-11 08:12:15 +01:00
|
|
|
.shape = SPRITE_SHAPE(32x32),
|
2018-12-17 23:00:08 +01:00
|
|
|
.x = 0,
|
|
|
|
.matrixNum = 0,
|
2019-03-11 08:12:15 +01:00
|
|
|
.size = SPRITE_SIZE(32x32),
|
2018-12-17 23:00:08 +01:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.paletteNum = 0,
|
|
|
|
.affineParam = 0
|
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const union AffineAnimCmd sAffineAnim_ItemIcon_Small[] =
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(128, 128, 0, 0),
|
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const union AffineAnimCmd sAffineAnim_ItemIcon_Appear[] =
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(88, 88, 0, 0),
|
|
|
|
AFFINEANIMCMD_FRAME(5, 5, 0, 8),
|
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const union AffineAnimCmd sAffineAnim_ItemIcon_Disappear[] =
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(128, 128, 0, 0),
|
|
|
|
AFFINEANIMCMD_FRAME(-5, -5, 0, 8),
|
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const union AffineAnimCmd sAffineAnim_ItemIcon_PickUp[] =
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(128, 128, 0, 0),
|
|
|
|
AFFINEANIMCMD_FRAME(10, 10, 0, 12),
|
|
|
|
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
|
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const union AffineAnimCmd sAffineAnim_ItemIcon_PutDown[] =
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
|
|
|
|
AFFINEANIMCMD_FRAME(-10, -10, 0, 12),
|
|
|
|
AFFINEANIMCMD_FRAME(128, 128, 0, 0),
|
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const union AffineAnimCmd sAffineAnim_ItemIcon_PutAway[] =
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
|
|
|
|
AFFINEANIMCMD_FRAME(-5, -5, 0, 16),
|
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const union AffineAnimCmd sAffineAnim_ItemIcon_Large[] =
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
AFFINEANIMCMD_FRAME(256, 256, 0, 0),
|
|
|
|
AFFINEANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const union AffineAnimCmd *const sAffineAnims_ItemIcon[] =
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
[ITEM_ANIM_NONE] = sAffineAnim_ItemIcon_Small,
|
|
|
|
[ITEM_ANIM_APPEAR] = sAffineAnim_ItemIcon_Appear,
|
|
|
|
[ITEM_ANIM_DISAPPEAR] = sAffineAnim_ItemIcon_Disappear,
|
|
|
|
[ITEM_ANIM_PICK_UP] = sAffineAnim_ItemIcon_PickUp,
|
|
|
|
[ITEM_ANIM_PUT_DOWN] = sAffineAnim_ItemIcon_PutDown,
|
|
|
|
[ITEM_ANIM_PUT_AWAY] = sAffineAnim_ItemIcon_PutAway,
|
|
|
|
[ITEM_ANIM_LARGE] = sAffineAnim_ItemIcon_Large
|
2018-12-17 23:00:08 +01:00
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_ItemIcon =
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
.tileTag = GFXTAG_ITEM_ICON_0,
|
|
|
|
.paletteTag = PALTAG_ITEM_ICON_0,
|
|
|
|
.oam = &sOamData_ItemIcon,
|
2018-12-17 23:00:08 +01:00
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
2021-04-16 01:17:53 +02:00
|
|
|
.affineAnims = sAffineAnims_ItemIcon,
|
2018-12-17 23:00:08 +01:00
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void CreateItemIconSprites(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
u8 spriteId;
|
|
|
|
struct CompressedSpriteSheet spriteSheet;
|
|
|
|
struct SpriteTemplate spriteTemplate;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption == OPTION_MOVE_ITEMS)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
spriteSheet.data = sItemIconGfxBuffer;
|
2018-12-17 23:00:08 +01:00
|
|
|
spriteSheet.size = 0x200;
|
2021-04-16 01:17:53 +02:00
|
|
|
spriteTemplate = sSpriteTemplate_ItemIcon;
|
2018-12-17 23:00:08 +01:00
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
for (i = 0; i < MAX_ITEM_ICONS; i++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
spriteSheet.tag = GFXTAG_ITEM_ICON_0 + i;
|
2018-12-17 23:00:08 +01:00
|
|
|
LoadCompressedSpriteSheet(&spriteSheet);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->itemIcons[i].tiles = GetSpriteTileStartByTag(spriteSheet.tag) * 32 + (void*)(OBJ_VRAM0);
|
|
|
|
sStorage->itemIcons[i].palIndex = AllocSpritePalette(PALTAG_ITEM_ICON_0 + i);
|
|
|
|
sStorage->itemIcons[i].palIndex *= 16;
|
|
|
|
sStorage->itemIcons[i].palIndex += 0x100;
|
2021-04-16 01:17:53 +02:00
|
|
|
spriteTemplate.tileTag = GFXTAG_ITEM_ICON_0 + i;
|
|
|
|
spriteTemplate.paletteTag = PALTAG_ITEM_ICON_0 + i;
|
2018-12-17 23:00:08 +01:00
|
|
|
spriteId = CreateSprite(&spriteTemplate, 0, 0, 11);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->itemIcons[i].sprite = &gSprites[spriteId];
|
|
|
|
sStorage->itemIcons[i].sprite->invisible = TRUE;
|
|
|
|
sStorage->itemIcons[i].active = FALSE;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingItemId = ITEM_NONE;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void TryLoadItemIconAtPos(u8 cursorArea, u8 cursorPos)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
u16 heldItem;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-17 23:00:08 +01:00
|
|
|
return;
|
2021-04-16 01:17:53 +02:00
|
|
|
|
|
|
|
// If we've already loaded the item here, stop
|
|
|
|
if (IsItemIconAtPosition(cursorArea, cursorPos))
|
2018-12-17 23:00:08 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
switch (cursorArea)
|
|
|
|
{
|
|
|
|
case CURSOR_AREA_IN_BOX:
|
|
|
|
if (!GetCurrentBoxMonData(cursorPos, MON_DATA_SANITY_HAS_SPECIES))
|
|
|
|
return;
|
|
|
|
heldItem = GetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM);
|
|
|
|
break;
|
|
|
|
case CURSOR_AREA_IN_PARTY:
|
|
|
|
if (cursorPos >= PARTY_SIZE || !GetMonData(&gPlayerParty[cursorPos], MON_DATA_SANITY_HAS_SPECIES))
|
|
|
|
return;
|
|
|
|
heldItem = GetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
if (heldItem != ITEM_NONE)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
const u32 *tiles = GetItemIconPic(heldItem);
|
2018-12-19 22:47:27 +01:00
|
|
|
const u32 *pal = GetItemIconPalette(heldItem);
|
2021-04-16 01:17:53 +02:00
|
|
|
u8 id = GetNewItemIconIdx();
|
2018-12-17 23:00:08 +01:00
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
SetItemIconPosition(id, cursorArea, cursorPos);
|
|
|
|
LoadItemIconGfx(id, tiles, pal);
|
|
|
|
SetItemIconAffineAnim(id, ITEM_ANIM_APPEAR);
|
|
|
|
SetItemIconActive(id, TRUE);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void TryHideItemIconAtPos(u8 cursorArea, u8 cursorPos)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
u8 id;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-17 23:00:08 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
id = GetItemIconIdxByPosition(cursorArea, cursorPos);
|
|
|
|
SetItemIconAffineAnim(id, ITEM_ANIM_DISAPPEAR);
|
|
|
|
SetItemIconCallback(id, ITEM_CB_WAIT_ANIM, cursorArea, cursorPos);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void TakeItemFromMon(u8 cursorArea, u8 cursorPos)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
u8 id;
|
2021-04-16 01:17:53 +02:00
|
|
|
u16 itemId;
|
2018-12-17 23:00:08 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-17 23:00:08 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
id = GetItemIconIdxByPosition(cursorArea, cursorPos);
|
|
|
|
itemId = ITEM_NONE;
|
|
|
|
SetItemIconAffineAnim(id, ITEM_ANIM_PICK_UP);
|
|
|
|
SetItemIconCallback(id, ITEM_CB_TO_HAND, cursorArea, cursorPos);
|
|
|
|
SetItemIconPosition(id, CURSOR_AREA_IN_HAND, 0);
|
|
|
|
if (cursorArea == CURSOR_AREA_IN_BOX)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &itemId);
|
2018-12-17 23:00:08 +01:00
|
|
|
SetBoxMonIconObjMode(cursorPos, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &itemId);
|
2018-12-17 23:00:08 +01:00
|
|
|
SetPartyMonIconObjMode(cursorPos, 1);
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingItemId = sStorage->displayMonItemId;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void InitItemIconInCursor(u16 itemId)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
const u32 *tiles = GetItemIconPic(itemId);
|
|
|
|
const u32 *pal = GetItemIconPalette(itemId);
|
|
|
|
u8 id = GetNewItemIconIdx();
|
|
|
|
LoadItemIconGfx(id, tiles, pal);
|
|
|
|
SetItemIconAffineAnim(id, ITEM_ANIM_LARGE);
|
|
|
|
SetItemIconCallback(id, ITEM_CB_TO_HAND, CURSOR_AREA_IN_BOX, 0);
|
|
|
|
SetItemIconPosition(id, CURSOR_AREA_IN_HAND, 0);
|
|
|
|
SetItemIconActive(id, TRUE);
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->movingItemId = itemId;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void SwapItemsWithMon(u8 cursorArea, u8 cursorPos)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
u8 id;
|
2021-04-16 01:17:53 +02:00
|
|
|
u16 itemId;
|
2018-12-17 23:00:08 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-17 23:00:08 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
id = GetItemIconIdxByPosition(cursorArea, cursorPos);
|
|
|
|
SetItemIconAffineAnim(id, ITEM_ANIM_PICK_UP);
|
|
|
|
SetItemIconCallback(id, ITEM_CB_SWAP_TO_HAND, CURSOR_AREA_IN_HAND, 0);
|
2018-12-17 23:00:08 +01:00
|
|
|
if (cursorArea == CURSOR_AREA_IN_BOX)
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
itemId = GetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &sStorage->movingItemId);
|
|
|
|
sStorage->movingItemId = itemId;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
itemId = GetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM);
|
2021-04-18 05:40:27 +02:00
|
|
|
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sStorage->movingItemId);
|
|
|
|
sStorage->movingItemId = itemId;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
id = GetItemIconIdxByPosition(CURSOR_AREA_IN_HAND, 0);
|
|
|
|
SetItemIconAffineAnim(id, ITEM_ANIM_PUT_DOWN);
|
|
|
|
SetItemIconCallback(id, ITEM_CB_SWAP_TO_MON, cursorArea, cursorPos);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void GiveItemToMon(u8 cursorArea, u8 cursorPos)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
u8 id;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-17 23:00:08 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
id = GetItemIconIdxByPosition(CURSOR_AREA_IN_HAND, 0);
|
|
|
|
SetItemIconAffineAnim(id, ITEM_ANIM_PUT_DOWN);
|
|
|
|
SetItemIconCallback(id, ITEM_CB_TO_MON, cursorArea, cursorPos);
|
2018-12-17 23:00:08 +01:00
|
|
|
if (cursorArea == CURSOR_AREA_IN_BOX)
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &sStorage->movingItemId);
|
2018-12-17 23:00:08 +01:00
|
|
|
SetBoxMonIconObjMode(cursorPos, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sStorage->movingItemId);
|
2018-12-17 23:00:08 +01:00
|
|
|
SetPartyMonIconObjMode(cursorPos, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void MoveItemFromMonToBag(u8 cursorArea, u8 cursorPos)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
u8 id;
|
2021-04-17 06:49:51 +02:00
|
|
|
u16 itemId;
|
2018-12-17 23:00:08 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-17 23:00:08 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
itemId = ITEM_NONE;
|
2021-04-16 01:17:53 +02:00
|
|
|
id = GetItemIconIdxByPosition(cursorArea, cursorPos);
|
|
|
|
SetItemIconAffineAnim(id, ITEM_ANIM_DISAPPEAR);
|
|
|
|
SetItemIconCallback(id, ITEM_CB_WAIT_ANIM, cursorArea, cursorPos);
|
|
|
|
if (cursorArea == CURSOR_AREA_IN_BOX)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &itemId);
|
2018-12-17 23:00:08 +01:00
|
|
|
SetBoxMonIconObjMode(cursorPos, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &itemId);
|
2018-12-17 23:00:08 +01:00
|
|
|
SetPartyMonIconObjMode(cursorPos, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
static void MoveItemFromCursorToBag(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption == OPTION_MOVE_ITEMS)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
u8 id = GetItemIconIdxByPosition(CURSOR_AREA_IN_HAND, 0);
|
|
|
|
SetItemIconAffineAnim(id, ITEM_ANIM_PUT_AWAY);
|
|
|
|
SetItemIconCallback(id, ITEM_CB_WAIT_ANIM, CURSOR_AREA_IN_HAND, 0);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
// The party menu is being closed, if the cursor is on
|
|
|
|
// a Pokémon that has a held item make sure it slides
|
|
|
|
// up along with the closing menu.
|
|
|
|
static void MoveHeldItemWithPartyMenu(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-17 23:00:08 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
for (i = 0; i < MAX_ITEM_ICONS; i++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->itemIcons[i].active
|
|
|
|
&& sStorage->itemIcons[i].area == CURSOR_AREA_IN_PARTY)
|
2021-04-16 01:17:53 +02:00
|
|
|
SetItemIconCallback(i, ITEM_CB_HIDE_PARTY, CURSOR_AREA_IN_HAND, 0);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static bool8 IsItemIconAnimActive(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
for (i = 0; i < MAX_ITEM_ICONS; i++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->itemIcons[i].active)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (!sStorage->itemIcons[i].sprite->affineAnimEnded
|
|
|
|
&& sStorage->itemIcons[i].sprite->affineAnimBeginning)
|
2018-12-17 23:00:08 +01:00
|
|
|
return TRUE;
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->itemIcons[i].sprite->callback != SpriteCallbackDummy
|
|
|
|
&& sStorage->itemIcons[i].sprite->callback != SpriteCB_ItemIcon_SetPosToCursor)
|
2018-12-17 23:00:08 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static bool8 IsMovingItem(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->boxOption == OPTION_MOVE_ITEMS)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
for (i = 0; i < MAX_ITEM_ICONS; i++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->itemIcons[i].active
|
|
|
|
&& sStorage->itemIcons[i].area == CURSOR_AREA_IN_HAND)
|
2018-12-17 23:00:08 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static const u8 *GetMovingItemName(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
return ItemId_GetName(sStorage->movingItemId);
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static u16 GetMovingItemId(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
return sStorage->movingItemId;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static u8 GetNewItemIconIdx(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
for (i = 0; i < MAX_ITEM_ICONS; i++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (!sStorage->itemIcons[i].active)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->itemIcons[i].active = TRUE;
|
2018-12-17 23:00:08 +01:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
2021-04-16 01:17:53 +02:00
|
|
|
return MAX_ITEM_ICONS;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static bool32 IsItemIconAtPosition(u8 cursorArea, u8 cursorPos)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
for (i = 0; i < MAX_ITEM_ICONS; i++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->itemIcons[i].active
|
|
|
|
&& sStorage->itemIcons[i].area == cursorArea
|
|
|
|
&& sStorage->itemIcons[i].pos == cursorPos)
|
2018-12-17 23:00:08 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static u8 GetItemIconIdxByPosition(u8 cursorArea, u8 cursorPos)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
for (i = 0; i < MAX_ITEM_ICONS; i++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->itemIcons[i].active
|
|
|
|
&& sStorage->itemIcons[i].area == cursorArea
|
|
|
|
&& sStorage->itemIcons[i].pos == cursorPos)
|
2018-12-17 23:00:08 +01:00
|
|
|
return i;
|
|
|
|
}
|
2021-04-16 01:17:53 +02:00
|
|
|
return MAX_ITEM_ICONS;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static u8 GetItemIconIdxBySprite(struct Sprite *sprite)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
for (i = 0; i < MAX_ITEM_ICONS; i++)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->itemIcons[i].active
|
|
|
|
&& sStorage->itemIcons[i].sprite == sprite)
|
2018-12-17 23:00:08 +01:00
|
|
|
return i;
|
|
|
|
}
|
2021-04-16 01:17:53 +02:00
|
|
|
return MAX_ITEM_ICONS;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
2018-12-19 22:47:27 +01:00
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void SetItemIconPosition(u8 id, u8 cursorArea, u8 cursorPos)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-16 11:14:35 +02:00
|
|
|
u8 x, y;
|
2018-12-19 22:47:27 +01:00
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
if (id >= MAX_ITEM_ICONS)
|
2018-12-19 22:47:27 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
switch (cursorArea)
|
|
|
|
{
|
|
|
|
case CURSOR_AREA_IN_BOX:
|
2021-04-16 11:14:35 +02:00
|
|
|
x = cursorPos % IN_BOX_COLUMNS;
|
|
|
|
y = cursorPos / IN_BOX_COLUMNS;
|
2021-07-07 15:11:52 +02:00
|
|
|
sStorage->itemIcons[id].sprite->x = (24 * x) + 112;
|
|
|
|
sStorage->itemIcons[id].sprite->y = (24 * y) + 56;
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->itemIcons[id].sprite->oam.priority = 2;
|
2018-12-19 22:47:27 +01:00
|
|
|
break;
|
|
|
|
case CURSOR_AREA_IN_PARTY:
|
|
|
|
if (cursorPos == 0)
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sStorage->itemIcons[id].sprite->x = 116;
|
|
|
|
sStorage->itemIcons[id].sprite->y = 76;
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sStorage->itemIcons[id].sprite->x = 164;
|
|
|
|
sStorage->itemIcons[id].sprite->y = 24 * (cursorPos - 1) + 28;
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->itemIcons[id].sprite->oam.priority = 1;
|
2018-12-19 22:47:27 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->itemIcons[id].area = cursorArea;
|
|
|
|
sStorage->itemIcons[id].pos = cursorPos;
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void LoadItemIconGfx(u8 id, const u32 *itemTiles, const u32 *itemPal)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
if (id >= MAX_ITEM_ICONS)
|
2018-12-19 22:47:27 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
CpuFastFill(0, sStorage->itemIconBuffer, 0x200);
|
2021-04-18 05:40:27 +02:00
|
|
|
LZ77UnCompWram(itemTiles, sStorage->tileBuffer);
|
2018-12-19 22:47:27 +01:00
|
|
|
for (i = 0; i < 3; i++)
|
2021-04-18 05:55:24 +02:00
|
|
|
CpuFastCopy(&sStorage->tileBuffer[i * 0x60], &sStorage->itemIconBuffer[i * 0x80], 0x60);
|
2018-12-19 22:47:27 +01:00
|
|
|
|
2021-04-18 05:55:24 +02:00
|
|
|
CpuFastCopy(sStorage->itemIconBuffer, sStorage->itemIcons[id].tiles, 0x200);
|
|
|
|
LZ77UnCompWram(itemPal, sStorage->itemIconBuffer);
|
|
|
|
LoadPalette(sStorage->itemIconBuffer, sStorage->itemIcons[id].palIndex, 0x20);
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void SetItemIconAffineAnim(u8 id, u8 animNum)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
if (id >= MAX_ITEM_ICONS)
|
2018-12-19 22:47:27 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
StartSpriteAffineAnim(sStorage->itemIcons[id].sprite, animNum);
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
#define sItemIconId data[0]
|
|
|
|
#define sState data[0]
|
|
|
|
#define sCursorArea data[6]
|
|
|
|
#define sCursorPos data[7]
|
|
|
|
|
|
|
|
static void SetItemIconCallback(u8 id, u8 callbackId, u8 cursorArea, u8 cursorPos)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
if (id >= MAX_ITEM_ICONS)
|
2018-12-19 22:47:27 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
switch (callbackId)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
case ITEM_CB_WAIT_ANIM:
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->itemIcons[id].sprite->sItemIconId = id;
|
|
|
|
sStorage->itemIcons[id].sprite->callback = SpriteCB_ItemIcon_WaitAnim;
|
2018-12-19 22:47:27 +01:00
|
|
|
break;
|
2021-04-16 01:17:53 +02:00
|
|
|
case ITEM_CB_TO_HAND:
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->itemIcons[id].sprite->sState = 0;
|
|
|
|
sStorage->itemIcons[id].sprite->callback = SpriteCB_ItemIcon_ToHand;
|
2018-12-19 22:47:27 +01:00
|
|
|
break;
|
2021-04-16 01:17:53 +02:00
|
|
|
case ITEM_CB_TO_MON:
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->itemIcons[id].sprite->sState = 0;
|
|
|
|
sStorage->itemIcons[id].sprite->sCursorArea = cursorArea;
|
|
|
|
sStorage->itemIcons[id].sprite->sCursorPos = cursorPos;
|
|
|
|
sStorage->itemIcons[id].sprite->callback = SpriteCB_ItemIcon_ToMon;
|
2018-12-19 22:47:27 +01:00
|
|
|
break;
|
2021-04-16 01:17:53 +02:00
|
|
|
case ITEM_CB_SWAP_TO_HAND:
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->itemIcons[id].sprite->sState = 0;
|
|
|
|
sStorage->itemIcons[id].sprite->callback = SpriteCB_ItemIcon_SwapToHand;
|
|
|
|
sStorage->itemIcons[id].sprite->sCursorArea = cursorArea;
|
|
|
|
sStorage->itemIcons[id].sprite->sCursorPos = cursorPos;
|
2018-12-19 22:47:27 +01:00
|
|
|
break;
|
2021-04-16 01:17:53 +02:00
|
|
|
case ITEM_CB_SWAP_TO_MON:
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->itemIcons[id].sprite->sState = 0;
|
|
|
|
sStorage->itemIcons[id].sprite->sCursorArea = cursorArea;
|
|
|
|
sStorage->itemIcons[id].sprite->sCursorPos = cursorPos;
|
|
|
|
sStorage->itemIcons[id].sprite->callback = SpriteCB_ItemIcon_SwapToMon;
|
2018-12-19 22:47:27 +01:00
|
|
|
break;
|
2021-04-16 01:17:53 +02:00
|
|
|
case ITEM_CB_HIDE_PARTY:
|
|
|
|
// If cursor is on a Pokémon with a held item and
|
|
|
|
// the player closes the party menu, have the held
|
|
|
|
// item follow the Pokémon as the menu slides out
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->itemIcons[id].sprite->callback = SpriteCB_ItemIcon_HideParty;
|
2018-12-19 22:47:27 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void SetItemIconActive(u8 id, bool8 active)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
if (id >= MAX_ITEM_ICONS)
|
2018-12-19 22:47:27 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->itemIcons[id].active = active;
|
|
|
|
sStorage->itemIcons[id].sprite->invisible = (active == FALSE);
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const u32 *GetItemIconPic(u16 itemId)
|
|
|
|
{
|
|
|
|
return GetItemIconPicOrPalette(itemId, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const u32 *GetItemIconPalette(u16 itemId)
|
|
|
|
{
|
|
|
|
return GetItemIconPicOrPalette(itemId, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PrintItemDescription(void)
|
|
|
|
{
|
|
|
|
const u8 *description;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
if (IsMovingItem())
|
2021-04-18 05:40:27 +02:00
|
|
|
description = ItemId_GetDescription(sStorage->movingItemId);
|
2018-12-19 22:47:27 +01:00
|
|
|
else
|
2021-04-18 05:40:27 +02:00
|
|
|
description = ItemId_GetDescription(sStorage->displayMonItemId);
|
2018-12-19 22:47:27 +01:00
|
|
|
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(2, PIXEL_FILL(1));
|
2018-12-19 22:47:27 +01:00
|
|
|
AddTextPrinterParameterized5(2, 1, description, 4, 0, 0, NULL, 0, 1);
|
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void InitItemInfoWindow(void)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->itemInfoWindowOffset = 21;
|
2021-04-16 01:17:53 +02:00
|
|
|
LoadBgTiles(0, sItemInfoFrame_Gfx, 0x80, 0x13A);
|
|
|
|
DrawItemInfoWindow(0);
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static bool8 UpdateItemInfoWindowSlideIn(void)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
s32 i, pos;
|
2018-12-19 22:47:27 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->itemInfoWindowOffset == 0)
|
2018-12-19 22:47:27 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->itemInfoWindowOffset--;
|
|
|
|
pos = 21 - sStorage->itemInfoWindowOffset;
|
2021-04-16 01:17:53 +02:00
|
|
|
for (i = 0; i < pos; i++)
|
2021-04-18 05:40:27 +02:00
|
|
|
WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, BG_ATTR_BASETILE) + 0x14 + sStorage->itemInfoWindowOffset + i, i, 13, 1, 7, 15, 21);
|
2018-12-19 22:47:27 +01:00
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
DrawItemInfoWindow(pos);
|
2021-04-18 05:40:27 +02:00
|
|
|
return (sStorage->itemInfoWindowOffset != 0);
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static bool8 UpdateItemInfoWindowSlideOut(void)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
s32 i, pos;
|
2018-12-19 22:47:27 +01:00
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->itemInfoWindowOffset == 22)
|
2018-12-19 22:47:27 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
if (sStorage->itemInfoWindowOffset == 0)
|
2018-12-19 22:47:27 +01:00
|
|
|
FillBgTilemapBufferRect(0, 0, 21, 12, 1, 9, 17);
|
|
|
|
|
2021-04-18 05:40:27 +02:00
|
|
|
sStorage->itemInfoWindowOffset++;
|
|
|
|
pos = 21 - sStorage->itemInfoWindowOffset;
|
2021-04-16 01:17:53 +02:00
|
|
|
for (i = 0; i < pos; i++)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-18 05:40:27 +02:00
|
|
|
WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, BG_ATTR_BASETILE) + 0x14 + sStorage->itemInfoWindowOffset + i, i, 13, 1, 7, 15, 21);
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
if (pos >= 0)
|
|
|
|
DrawItemInfoWindow(pos);
|
2018-12-19 22:47:27 +01:00
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
FillBgTilemapBufferRect(0, 0, pos + 1, 12, 1, 9, 0x11);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-12-19 22:47:27 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void DrawItemInfoWindow(u32 pos)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
if (pos != 0)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
FillBgTilemapBufferRect(0, 0x13A, 0, 0xC, pos, 1, 0xFu);
|
|
|
|
FillBgTilemapBufferRect(0, 0x93A, 0, 0x14, pos, 1, 0xFu);
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
2021-04-16 01:17:53 +02:00
|
|
|
FillBgTilemapBufferRect(0, 0x13B, pos, 0xD, 1, 7, 0xFu);
|
|
|
|
FillBgTilemapBufferRect(0, 0x13C, pos, 0xC, 1, 1, 0xFu);
|
|
|
|
FillBgTilemapBufferRect(0, 0x13D, pos, 0x14, 1, 1, 0xFu);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void SpriteCB_ItemIcon_WaitAnim(struct Sprite *sprite)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
if (sprite->affineAnimEnded)
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
SetItemIconActive(sprite->sItemIconId, FALSE);
|
2018-12-19 22:47:27 +01:00
|
|
|
sprite->callback = SpriteCallbackDummy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void SpriteCB_ItemIcon_ToHand(struct Sprite *sprite)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
switch (sprite->sState)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->data[1] = sprite->x << 4;
|
|
|
|
sprite->data[2] = sprite->y << 4;
|
2018-12-19 22:47:27 +01:00
|
|
|
sprite->data[3] = 10;
|
|
|
|
sprite->data[4] = 21;
|
|
|
|
sprite->data[5] = 0;
|
2021-04-16 01:17:53 +02:00
|
|
|
sprite->sState++;
|
2018-12-19 22:47:27 +01:00
|
|
|
case 1:
|
|
|
|
sprite->data[1] -= sprite->data[3];
|
|
|
|
sprite->data[2] -= sprite->data[4];
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = sprite->data[1] >> 4;
|
|
|
|
sprite->y = sprite->data[2] >> 4;
|
2018-12-19 22:47:27 +01:00
|
|
|
if (++sprite->data[5] > 11)
|
2021-04-16 01:17:53 +02:00
|
|
|
sprite->callback = SpriteCB_ItemIcon_SetPosToCursor;
|
2018-12-19 22:47:27 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void SpriteCB_ItemIcon_SetPosToCursor(struct Sprite *sprite)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = sStorage->cursorSprite->x + 4;
|
|
|
|
sprite->y = sStorage->cursorSprite->y + sStorage->cursorSprite->y2 + 8;
|
2021-04-18 05:40:27 +02:00
|
|
|
sprite->oam.priority = sStorage->cursorSprite->oam.priority;
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void SpriteCB_ItemIcon_ToMon(struct Sprite *sprite)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
switch (sprite->sState)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->data[1] = sprite->x << 4;
|
|
|
|
sprite->data[2] = sprite->y << 4;
|
2018-12-19 22:47:27 +01:00
|
|
|
sprite->data[3] = 10;
|
|
|
|
sprite->data[4] = 21;
|
|
|
|
sprite->data[5] = 0;
|
2021-04-16 01:17:53 +02:00
|
|
|
sprite->sState++;
|
2018-12-19 22:47:27 +01:00
|
|
|
case 1:
|
|
|
|
sprite->data[1] += sprite->data[3];
|
|
|
|
sprite->data[2] += sprite->data[4];
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = sprite->data[1] >> 4;
|
|
|
|
sprite->y = sprite->data[2] >> 4;
|
2018-12-19 22:47:27 +01:00
|
|
|
if (++sprite->data[5] > 11)
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
SetItemIconPosition(GetItemIconIdxBySprite(sprite), sprite->sCursorArea, sprite->sCursorPos);
|
2018-12-19 22:47:27 +01:00
|
|
|
sprite->callback = SpriteCallbackDummy;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void SpriteCB_ItemIcon_SwapToHand(struct Sprite *sprite)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
switch (sprite->sState)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->data[1] = sprite->x << 4;
|
|
|
|
sprite->data[2] = sprite->y << 4;
|
2018-12-19 22:47:27 +01:00
|
|
|
sprite->data[3] = 10;
|
|
|
|
sprite->data[4] = 21;
|
|
|
|
sprite->data[5] = 0;
|
2021-04-16 01:17:53 +02:00
|
|
|
sprite->sState++;
|
2018-12-19 22:47:27 +01:00
|
|
|
case 1:
|
|
|
|
sprite->data[1] -= sprite->data[3];
|
|
|
|
sprite->data[2] -= sprite->data[4];
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = sprite->data[1] >> 4;
|
|
|
|
sprite->y = sprite->data[2] >> 4;
|
|
|
|
sprite->x2 = gSineTable[sprite->data[5] * 8] >> 4;
|
2018-12-19 22:47:27 +01:00
|
|
|
if (++sprite->data[5] > 11)
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
SetItemIconPosition(GetItemIconIdxBySprite(sprite), sprite->sCursorArea, sprite->sCursorPos);
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 = 0;
|
2021-04-16 01:17:53 +02:00
|
|
|
sprite->callback = SpriteCB_ItemIcon_SetPosToCursor;
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void SpriteCB_ItemIcon_SwapToMon(struct Sprite *sprite)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
switch (sprite->sState)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->data[1] = sprite->x << 4;
|
|
|
|
sprite->data[2] = sprite->y << 4;
|
2018-12-19 22:47:27 +01:00
|
|
|
sprite->data[3] = 10;
|
|
|
|
sprite->data[4] = 21;
|
|
|
|
sprite->data[5] = 0;
|
2021-04-16 01:17:53 +02:00
|
|
|
sprite->sState++;
|
2018-12-19 22:47:27 +01:00
|
|
|
case 1:
|
|
|
|
sprite->data[1] += sprite->data[3];
|
|
|
|
sprite->data[2] += sprite->data[4];
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = sprite->data[1] >> 4;
|
|
|
|
sprite->y = sprite->data[2] >> 4;
|
|
|
|
sprite->x2 = -(gSineTable[sprite->data[5] * 8] >> 4);
|
2018-12-19 22:47:27 +01:00
|
|
|
if (++sprite->data[5] > 11)
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
SetItemIconPosition(GetItemIconIdxBySprite(sprite), sprite->sCursorArea, sprite->sCursorPos);
|
2018-12-19 22:47:27 +01:00
|
|
|
sprite->callback = SpriteCallbackDummy;
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 = 0;
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void SpriteCB_ItemIcon_HideParty(struct Sprite *sprite)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y -= 8;
|
|
|
|
if (sprite->y + sprite->y2 < -16)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
sprite->callback = SpriteCallbackDummy;
|
2021-04-16 01:17:53 +02:00
|
|
|
SetItemIconActive(GetItemIconIdxBySprite(sprite), FALSE);
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
#undef sState
|
|
|
|
#undef sItemIconId
|
|
|
|
#undef sCursorArea
|
|
|
|
#undef sCursorPos
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: General utility
|
|
|
|
//------------------------------------------------------------------------------
|
2018-12-19 22:47:27 +01:00
|
|
|
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
// Unused, leftover from FRLG
|
|
|
|
static void BackupPokemonStorage(void/*struct PokemonStorage * dest*/)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
//*dest = *gPokemonStoragePtr;
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
// Unused, leftover from FRLG
|
|
|
|
static void RestorePokemonStorage(void/*struct PokemonStorage * src*/)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
//*gPokemonStoragePtr = *src;
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Functions here are general utility functions.
|
|
|
|
u8 StorageGetCurrentBox(void)
|
|
|
|
{
|
|
|
|
return gPokemonStoragePtr->currentBox;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SetCurrentBox(u8 boxId)
|
|
|
|
{
|
|
|
|
if (boxId < TOTAL_BOXES_COUNT)
|
|
|
|
gPokemonStoragePtr->currentBox = boxId;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 GetBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request)
|
|
|
|
{
|
|
|
|
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
|
|
|
return GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], request);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, const void *value)
|
|
|
|
{
|
|
|
|
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
|
|
|
SetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], request, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 GetCurrentBoxMonData(u8 boxPosition, s32 request)
|
|
|
|
{
|
|
|
|
return GetBoxMonDataAt(gPokemonStoragePtr->currentBox, boxPosition, request);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetCurrentBoxMonData(u8 boxPosition, s32 request, const void *value)
|
|
|
|
{
|
|
|
|
SetBoxMonDataAt(gPokemonStoragePtr->currentBox, boxPosition, request, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetBoxMonNickAt(u8 boxId, u8 boxPosition, u8 *dst)
|
|
|
|
{
|
|
|
|
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
|
|
|
GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_NICKNAME, dst);
|
|
|
|
else
|
|
|
|
*dst = EOS;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 GetBoxMonLevelAt(u8 boxId, u8 boxPosition)
|
|
|
|
{
|
|
|
|
u32 lvl;
|
|
|
|
|
|
|
|
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT && GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SANITY_HAS_SPECIES))
|
|
|
|
lvl = GetLevelFromBoxMonExp(&gPokemonStoragePtr->boxes[boxId][boxPosition]);
|
2021-04-16 05:27:05 +02:00
|
|
|
#ifdef BUGFIX
|
2020-12-13 05:28:01 +01:00
|
|
|
else
|
2021-04-16 05:27:05 +02:00
|
|
|
#endif
|
2018-12-19 22:47:27 +01:00
|
|
|
lvl = 0;
|
|
|
|
|
|
|
|
return lvl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetBoxMonNickAt(u8 boxId, u8 boxPosition, const u8 *nick)
|
|
|
|
{
|
|
|
|
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
|
|
|
SetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_NICKNAME, nick);
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 GetAndCopyBoxMonDataAt(u8 boxId, u8 boxPosition, s32 request, void *dst)
|
|
|
|
{
|
|
|
|
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
|
|
|
return GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], request, dst);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon *src)
|
|
|
|
{
|
|
|
|
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
|
|
|
gPokemonStoragePtr->boxes[boxId][boxPosition] = *src;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CopyBoxMonAt(u8 boxId, u8 boxPosition, struct BoxPokemon *dst)
|
|
|
|
{
|
|
|
|
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
|
|
|
*dst = gPokemonStoragePtr->boxes[boxId][boxPosition];
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateBoxMonAt(u8 boxId, u8 boxPosition, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 personality, u8 otIDType, u32 otID)
|
|
|
|
{
|
|
|
|
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
|
|
|
{
|
|
|
|
CreateBoxMon(&gPokemonStoragePtr->boxes[boxId][boxPosition],
|
|
|
|
species,
|
|
|
|
level,
|
|
|
|
fixedIV,
|
|
|
|
hasFixedPersonality, personality,
|
|
|
|
otIDType, otID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ZeroBoxMonAt(u8 boxId, u8 boxPosition)
|
|
|
|
{
|
|
|
|
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
|
|
|
ZeroBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoxMonAtToMon(u8 boxId, u8 boxPosition, struct Pokemon *dst)
|
|
|
|
{
|
|
|
|
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
|
|
|
BoxMonToMon(&gPokemonStoragePtr->boxes[boxId][boxPosition], dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct BoxPokemon *GetBoxedMonPtr(u8 boxId, u8 boxPosition)
|
|
|
|
{
|
|
|
|
if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT)
|
|
|
|
return &gPokemonStoragePtr->boxes[boxId][boxPosition];
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 *GetBoxNamePtr(u8 boxId)
|
|
|
|
{
|
|
|
|
if (boxId < TOTAL_BOXES_COUNT)
|
|
|
|
return gPokemonStoragePtr->boxNames[boxId];
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static u8 GetBoxWallpaper(u8 boxId)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
if (boxId < TOTAL_BOXES_COUNT)
|
|
|
|
return gPokemonStoragePtr->boxWallpapers[boxId];
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static void SetBoxWallpaper(u8 boxId, u8 wallpaperId)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2018-12-22 23:00:22 +01:00
|
|
|
if (boxId < TOTAL_BOXES_COUNT && wallpaperId < WALLPAPER_COUNT)
|
2018-12-19 22:47:27 +01:00
|
|
|
gPokemonStoragePtr->boxWallpapers[boxId] = wallpaperId;
|
|
|
|
}
|
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
// For moving to the next Pokémon while viewing the summary screen
|
|
|
|
s16 AdvanceStorageMonIndex(struct BoxPokemon *boxMons, u8 currIndex, u8 maxIndex, u8 mode)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
s16 i;
|
2021-04-17 06:49:51 +02:00
|
|
|
s16 direction = -1;
|
2018-12-19 22:47:27 +01:00
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
if (mode == 0 || mode == 1)
|
|
|
|
direction = 1;
|
2018-12-19 22:47:27 +01:00
|
|
|
|
2021-04-17 06:49:51 +02:00
|
|
|
if (mode == 1 || mode == 3)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
for (i = (s8)currIndex + direction; i >= 0 && i <= maxIndex; i += direction)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
if (GetBoxMonData(&boxMons[i], MON_DATA_SPECIES) != SPECIES_NONE)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-17 06:49:51 +02:00
|
|
|
for (i = (s8)currIndex + direction; i >= 0 && i <= maxIndex; i += direction)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
if (GetBoxMonData(&boxMons[i], MON_DATA_SPECIES) != SPECIES_NONE
|
|
|
|
&& !GetBoxMonData(&boxMons[i], MON_DATA_IS_EGG))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool8 CheckFreePokemonStorageSpace(void)
|
|
|
|
{
|
|
|
|
s32 i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < TOTAL_BOXES_COUNT; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < IN_BOX_COUNT; j++)
|
|
|
|
{
|
|
|
|
if (!GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_HAS_SPECIES))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-12-22 23:00:22 +01:00
|
|
|
bool32 CheckBoxMonSanityAt(u32 boxId, u32 boxPosition)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
if (boxId < TOTAL_BOXES_COUNT
|
|
|
|
&& boxPosition < IN_BOX_COUNT
|
|
|
|
&& GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SANITY_HAS_SPECIES)
|
|
|
|
&& !GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SANITY_IS_EGG)
|
|
|
|
&& !GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SANITY_IS_BAD_EGG))
|
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 CountStorageNonEggMons(void)
|
|
|
|
{
|
|
|
|
s32 i, j;
|
|
|
|
u32 count = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < TOTAL_BOXES_COUNT; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < IN_BOX_COUNT; j++)
|
|
|
|
{
|
|
|
|
if (GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_HAS_SPECIES)
|
|
|
|
&& !GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_IS_EGG))
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 CountAllStorageMons(void)
|
|
|
|
{
|
|
|
|
s32 i, j;
|
|
|
|
u32 count = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < TOTAL_BOXES_COUNT; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < IN_BOX_COUNT; j++)
|
|
|
|
{
|
|
|
|
if (GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_HAS_SPECIES)
|
|
|
|
|| GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_IS_EGG))
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool32 AnyStorageMonWithMove(u16 moveId)
|
|
|
|
{
|
|
|
|
u16 moves[] = {moveId, MOVES_COUNT};
|
|
|
|
s32 i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < TOTAL_BOXES_COUNT; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < IN_BOX_COUNT; j++)
|
|
|
|
{
|
|
|
|
if (GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_HAS_SPECIES)
|
|
|
|
&& !GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_SANITY_IS_EGG)
|
2019-03-03 09:14:08 +01:00
|
|
|
&& GetBoxMonData(&gPokemonStoragePtr->boxes[i][j], MON_DATA_KNOWN_MOVES, (u8*)moves))
|
2018-12-19 22:47:27 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: Walda
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
void ResetWaldaWallpaper(void)
|
|
|
|
{
|
|
|
|
gSaveBlock1Ptr->waldaPhrase.iconId = 0;
|
|
|
|
gSaveBlock1Ptr->waldaPhrase.patternId = 0;
|
|
|
|
gSaveBlock1Ptr->waldaPhrase.patternUnlocked = FALSE;
|
2018-12-21 22:35:01 +01:00
|
|
|
gSaveBlock1Ptr->waldaPhrase.colors[0] = RGB(21, 25, 30);
|
|
|
|
gSaveBlock1Ptr->waldaPhrase.colors[1] = RGB(6, 12, 24);
|
2018-12-19 22:47:27 +01:00
|
|
|
gSaveBlock1Ptr->waldaPhrase.text[0] = EOS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetWaldaWallpaperLockedOrUnlocked(bool32 unlocked)
|
|
|
|
{
|
|
|
|
gSaveBlock1Ptr->waldaPhrase.patternUnlocked = unlocked;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool32 IsWaldaWallpaperUnlocked(void)
|
|
|
|
{
|
|
|
|
return gSaveBlock1Ptr->waldaPhrase.patternUnlocked;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 GetWaldaWallpaperPatternId(void)
|
|
|
|
{
|
|
|
|
return gSaveBlock1Ptr->waldaPhrase.patternId;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetWaldaWallpaperPatternId(u8 id)
|
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
if (id < ARRAY_COUNT(sWaldaWallpapers))
|
2018-12-19 22:47:27 +01:00
|
|
|
gSaveBlock1Ptr->waldaPhrase.patternId = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 GetWaldaWallpaperIconId(void)
|
|
|
|
{
|
|
|
|
return gSaveBlock1Ptr->waldaPhrase.iconId;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetWaldaWallpaperIconId(u8 id)
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
if (id < ARRAY_COUNT(sWaldaWallpaperIcons))
|
2018-12-19 22:47:27 +01:00
|
|
|
gSaveBlock1Ptr->waldaPhrase.iconId = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
u16 *GetWaldaWallpaperColorsPtr(void)
|
|
|
|
{
|
|
|
|
return gSaveBlock1Ptr->waldaPhrase.colors;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetWaldaWallpaperColors(u16 color1, u16 color2)
|
|
|
|
{
|
|
|
|
gSaveBlock1Ptr->waldaPhrase.colors[0] = color1;
|
|
|
|
gSaveBlock1Ptr->waldaPhrase.colors[1] = color2;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 *GetWaldaPhrasePtr(void)
|
|
|
|
{
|
|
|
|
return gSaveBlock1Ptr->waldaPhrase.text;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetWaldaPhrase(const u8 *src)
|
|
|
|
{
|
|
|
|
StringCopy(gSaveBlock1Ptr->waldaPhrase.text, src);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool32 IsWaldaPhraseEmpty(void)
|
|
|
|
{
|
|
|
|
return (gSaveBlock1Ptr->waldaPhrase.text[0] == EOS);
|
|
|
|
}
|
2018-12-20 22:14:36 +01:00
|
|
|
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: TilemapUtil
|
|
|
|
//
|
|
|
|
// Handles 3 particular tilemaps in a somewhat unusual way.
|
|
|
|
// For example, while the cursor is on the Close Box button it flashes between
|
|
|
|
// two states alternately. Both these states are their own part of the same
|
|
|
|
// tilemap that's always present. The utility shifts the tilemap up and down
|
|
|
|
// to show/hide the states, and limits the view with a rectangle that only
|
|
|
|
// reveals one at a time.
|
|
|
|
// Each tilemap is tracked with a TILEMAPID that can be used to reference it.
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
struct TilemapUtil_RectData
|
|
|
|
{
|
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
u16 width;
|
|
|
|
u16 height;
|
|
|
|
s16 destX;
|
|
|
|
s16 destY;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TilemapUtil
|
|
|
|
{
|
|
|
|
struct TilemapUtil_RectData prev; // Only read in unused function
|
|
|
|
struct TilemapUtil_RectData cur;
|
|
|
|
const void *savedTilemap; // Only written in unused function
|
|
|
|
const void *tilemap;
|
|
|
|
u16 altWidth;
|
|
|
|
u16 altHeight; // Never read
|
|
|
|
u16 width;
|
|
|
|
u16 height; // Never read
|
|
|
|
u16 rowSize; // Never read
|
|
|
|
u8 tileSize;
|
|
|
|
u8 bg;
|
|
|
|
bool8 active;
|
|
|
|
};
|
|
|
|
|
|
|
|
EWRAM_DATA static struct TilemapUtil *sTilemapUtil = NULL;
|
|
|
|
EWRAM_DATA static u16 sNumTilemapUtilIds = 0;
|
2018-12-20 22:14:36 +01:00
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static void TilemapUtil_Init(u8 count)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil = Alloc(sizeof(*sTilemapUtil) * count);
|
|
|
|
sNumTilemapUtilIds = (sTilemapUtil == NULL) ? 0 : count;
|
|
|
|
for (i = 0; i < sNumTilemapUtilIds; i++)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[i].savedTilemap = NULL;
|
|
|
|
sTilemapUtil[i].active = FALSE;
|
2018-12-20 22:14:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static void TilemapUtil_Free(void)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
Free(sTilemapUtil);
|
2018-12-20 22:14:36 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
// Unused
|
|
|
|
static void TilemapUtil_UpdateAll(void)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
for (i = 0; i < sNumTilemapUtilIds; i++)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
if (sTilemapUtil[i].active == TRUE)
|
|
|
|
TilemapUtil_Update(i);
|
2018-12-20 22:14:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
u16 width;
|
|
|
|
u16 height;
|
|
|
|
} static const sTilemapDimensions[][4] =
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2018-12-22 23:00:22 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
{ 256, 256},
|
|
|
|
{ 512, 256},
|
|
|
|
{ 256, 512},
|
|
|
|
{ 512, 512},
|
2018-12-22 23:00:22 +01:00
|
|
|
},
|
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
{ 128, 128},
|
|
|
|
{ 256, 256},
|
|
|
|
{ 512, 512},
|
|
|
|
{1024, 1024},
|
2018-12-22 23:00:22 +01:00
|
|
|
},
|
2018-12-20 22:14:36 +01:00
|
|
|
};
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static void TilemapUtil_SetMap(u8 id, u8 bg, const void *tilemap, u16 width, u16 height)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2018-12-26 13:05:02 +01:00
|
|
|
u16 bgScreenSize, bgType;
|
2018-12-20 22:14:36 +01:00
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
if (id >= sNumTilemapUtilIds)
|
2018-12-20 22:14:36 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].savedTilemap = NULL;
|
|
|
|
sTilemapUtil[id].tilemap = tilemap;
|
|
|
|
sTilemapUtil[id].bg = bg;
|
|
|
|
sTilemapUtil[id].width = width;
|
|
|
|
sTilemapUtil[id].height = height;
|
2018-12-20 22:14:36 +01:00
|
|
|
|
2018-12-26 13:05:02 +01:00
|
|
|
bgScreenSize = GetBgAttribute(bg, BG_ATTR_SCREENSIZE);
|
|
|
|
bgType = GetBgAttribute(bg, BG_ATTR_TYPE);
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].altWidth = sTilemapDimensions[bgType][bgScreenSize].width;
|
|
|
|
sTilemapUtil[id].altHeight = sTilemapDimensions[bgType][bgScreenSize].height;
|
2018-12-26 13:05:02 +01:00
|
|
|
if (bgType != 0)
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].tileSize = 1;
|
2018-12-20 22:14:36 +01:00
|
|
|
else
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].tileSize = 2;
|
2018-12-20 22:14:36 +01:00
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].rowSize = sTilemapUtil[id].tileSize * width;
|
|
|
|
sTilemapUtil[id].cur.width = width;
|
|
|
|
sTilemapUtil[id].cur.height = height;
|
|
|
|
sTilemapUtil[id].cur.x = 0;
|
|
|
|
sTilemapUtil[id].cur.y = 0;
|
|
|
|
sTilemapUtil[id].cur.destX = 0;
|
|
|
|
sTilemapUtil[id].cur.destY = 0;
|
|
|
|
sTilemapUtil[id].prev = sTilemapUtil[id].cur;
|
|
|
|
sTilemapUtil[id].active = TRUE;
|
2018-12-20 22:14:36 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
// Unused
|
|
|
|
static void TilemapUtil_SetSavedMap(u8 id, const void *tilemap)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
if (id >= sNumTilemapUtilIds)
|
2018-12-20 22:14:36 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].savedTilemap = tilemap;
|
|
|
|
sTilemapUtil[id].active = TRUE;
|
2018-12-20 22:14:36 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static void TilemapUtil_SetPos(u8 id, u16 x, u16 y)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
if (id >= sNumTilemapUtilIds)
|
2018-12-20 22:14:36 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].cur.destX = x;
|
|
|
|
sTilemapUtil[id].cur.destY = y;
|
|
|
|
sTilemapUtil[id].active = TRUE;
|
2018-12-20 22:14:36 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static void TilemapUtil_SetRect(u8 id, u16 x, u16 y, u16 width, u16 height)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
if (id >= sNumTilemapUtilIds)
|
2018-12-20 22:14:36 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].cur.x = x;
|
|
|
|
sTilemapUtil[id].cur.y = y;
|
|
|
|
sTilemapUtil[id].cur.width = width;
|
|
|
|
sTilemapUtil[id].cur.height = height;
|
|
|
|
sTilemapUtil[id].active = TRUE;
|
2018-12-20 22:14:36 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static void TilemapUtil_Move(u8 id, u8 mode, s8 val)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
if (id >= sNumTilemapUtilIds)
|
2018-12-20 22:14:36 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
switch (mode)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].cur.destX += val;
|
|
|
|
sTilemapUtil[id].cur.width -= val;
|
2018-12-20 22:14:36 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].cur.x += val;
|
|
|
|
sTilemapUtil[id].cur.width += val;
|
2018-12-20 22:14:36 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].cur.destY += val;
|
|
|
|
sTilemapUtil[id].cur.height -= val;
|
2018-12-20 22:14:36 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].cur.y -= val;
|
|
|
|
sTilemapUtil[id].cur.height += val;
|
2018-12-20 22:14:36 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].cur.destX += val;
|
2018-12-20 22:14:36 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].cur.destY += val;
|
2018-12-20 22:14:36 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].active = TRUE;
|
2018-12-20 22:14:36 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static void TilemapUtil_Update(u8 id)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
if (id >= sNumTilemapUtilIds)
|
2018-12-20 22:14:36 +01:00
|
|
|
return;
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
if (sTilemapUtil[id].savedTilemap != NULL)
|
|
|
|
TilemapUtil_DrawPrev(id); // Never called, above always FALSE
|
2018-12-20 22:14:36 +01:00
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
TilemapUtil_Draw(id);
|
|
|
|
sTilemapUtil[id].prev = sTilemapUtil[id].cur;
|
2018-12-20 22:14:36 +01:00
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static void TilemapUtil_DrawPrev(u8 id)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
2021-04-17 23:28:18 +02:00
|
|
|
u32 adder = sTilemapUtil[id].tileSize * sTilemapUtil[id].altWidth;
|
|
|
|
const void *tiles = (sTilemapUtil[id].savedTilemap + (adder * sTilemapUtil[id].prev.destY))
|
|
|
|
+ (sTilemapUtil[id].tileSize * sTilemapUtil[id].prev.destX);
|
2018-12-20 22:14:36 +01:00
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
for (i = 0; i < sTilemapUtil[id].prev.height; i++)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
CopyToBgTilemapBufferRect(sTilemapUtil[id].bg,
|
2018-12-20 22:14:36 +01:00
|
|
|
tiles,
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].prev.destX,
|
|
|
|
sTilemapUtil[id].prev.destY + i,
|
|
|
|
sTilemapUtil[id].prev.width,
|
2018-12-20 22:14:36 +01:00
|
|
|
1);
|
|
|
|
tiles += adder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
static void TilemapUtil_Draw(u8 id)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
2021-04-17 23:28:18 +02:00
|
|
|
u32 adder = sTilemapUtil[id].tileSize * sTilemapUtil[id].width;
|
|
|
|
const void *tiles = (sTilemapUtil[id].tilemap + (adder * sTilemapUtil[id].cur.y))
|
|
|
|
+ (sTilemapUtil[id].tileSize * sTilemapUtil[id].cur.x);
|
2018-12-20 22:14:36 +01:00
|
|
|
|
2021-04-17 23:28:18 +02:00
|
|
|
for (i = 0; i < sTilemapUtil[id].cur.height; i++)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-17 23:28:18 +02:00
|
|
|
CopyToBgTilemapBufferRect(sTilemapUtil[id].bg,
|
2018-12-20 22:14:36 +01:00
|
|
|
tiles,
|
2021-04-17 23:28:18 +02:00
|
|
|
sTilemapUtil[id].cur.destX,
|
|
|
|
sTilemapUtil[id].cur.destY + i,
|
|
|
|
sTilemapUtil[id].cur.width,
|
2018-12-20 22:14:36 +01:00
|
|
|
1);
|
|
|
|
tiles += adder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-18 05:31:29 +02:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// SECTION: UnkUtil
|
|
|
|
//
|
|
|
|
// Some data transfer utility that goes functionally unused.
|
|
|
|
// It gets initialized with UnkUtil_Init, and run every vblank in Pokémon
|
|
|
|
// Storage with UnkUtil_Run, but neither of the Add functions are ever used,
|
|
|
|
// so UnkUtil_Run performs no actions.
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
EWRAM_DATA static struct UnkUtil *sUnkUtil = NULL;
|
|
|
|
|
|
|
|
static void UnkUtil_Init(struct UnkUtil *util, struct UnkUtilData *data, u32 max)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-18 05:31:29 +02:00
|
|
|
sUnkUtil = util;
|
|
|
|
util->data = data;
|
|
|
|
util->max = max;
|
|
|
|
util->numActive = 0;
|
2018-12-20 22:14:36 +01:00
|
|
|
}
|
|
|
|
|
2021-04-18 05:31:29 +02:00
|
|
|
static void UnkUtil_Run(void)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
2021-04-18 05:31:29 +02:00
|
|
|
if (sUnkUtil->numActive)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-18 05:31:29 +02:00
|
|
|
for (i = 0; i < sUnkUtil->numActive; i++)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-18 05:31:29 +02:00
|
|
|
struct UnkUtilData *data = &sUnkUtil->data[i];
|
|
|
|
data->func(data);
|
2018-12-20 22:14:36 +01:00
|
|
|
}
|
2021-04-18 05:31:29 +02:00
|
|
|
sUnkUtil->numActive = 0;
|
2018-12-20 22:14:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:31:29 +02:00
|
|
|
// Unused
|
|
|
|
static bool8 UnkUtil_CpuAdd(u8 *dest, u16 dLeft, u16 dTop, const u8 *src, u16 sLeft, u16 sTop, u16 width, u16 height, u16 unkArg)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-18 05:31:29 +02:00
|
|
|
struct UnkUtilData *data;
|
2018-12-20 22:14:36 +01:00
|
|
|
|
2021-04-18 05:31:29 +02:00
|
|
|
if (sUnkUtil->numActive >= sUnkUtil->max)
|
2018-12-20 22:14:36 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-18 05:31:29 +02:00
|
|
|
data = &sUnkUtil->data[sUnkUtil->numActive++];
|
|
|
|
data->size = width * 2;
|
|
|
|
data->dest = dest + 2 * (dTop * 32 + dLeft);
|
|
|
|
data->src = src + 2 * (sTop * unkArg + sLeft);
|
|
|
|
data->height = height;
|
|
|
|
data->unk = unkArg;
|
|
|
|
data->func = UnkUtil_CpuRun;
|
2018-12-20 22:14:36 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:31:29 +02:00
|
|
|
// Functionally unused
|
|
|
|
static void UnkUtil_CpuRun(struct UnkUtilData *data)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
2021-04-18 05:31:29 +02:00
|
|
|
for (i = 0; i < data->height; i++)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-18 05:31:29 +02:00
|
|
|
CpuSet(data->src, data->dest, data->size / 2);
|
|
|
|
data->dest += 64;
|
|
|
|
data->src += data->unk * 2;
|
2018-12-20 22:14:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:31:29 +02:00
|
|
|
// Unused
|
|
|
|
static bool8 UnkUtil_DmaAdd(void *dest, u16 dLeft, u16 dTop, u16 width, u16 height)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-18 05:31:29 +02:00
|
|
|
struct UnkUtilData *data;
|
2018-12-20 22:14:36 +01:00
|
|
|
|
2021-04-18 05:31:29 +02:00
|
|
|
if (sUnkUtil->numActive >= sUnkUtil->max)
|
2018-12-20 22:14:36 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-18 05:31:29 +02:00
|
|
|
data = &sUnkUtil->data[sUnkUtil->numActive++];
|
|
|
|
data->size = width * 2;
|
|
|
|
data->dest = dest + (dTop * 32 + dLeft) * 2;
|
|
|
|
data->height = height;
|
|
|
|
data->func = UnkUtil_DmaRun;
|
2018-12-20 22:14:36 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-18 05:31:29 +02:00
|
|
|
// Functionally unused
|
|
|
|
static void UnkUtil_DmaRun(struct UnkUtilData *data)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
2021-04-18 05:31:29 +02:00
|
|
|
for (i = 0; i < data->height; i++)
|
2018-12-20 22:14:36 +01:00
|
|
|
{
|
2021-04-18 05:31:29 +02:00
|
|
|
Dma3FillLarge16_(0, data->dest, data->size);
|
|
|
|
data->dest += 64;
|
2018-12-20 22:14:36 +01:00
|
|
|
}
|
|
|
|
}
|
2021-09-29 05:48:03 +02:00
|
|
|
|
|
|
|
void UpdateSpeciesSpritePSS(struct BoxPokemon *boxMon)
|
|
|
|
{
|
|
|
|
u16 species = GetBoxMonData(boxMon, MON_DATA_SPECIES);
|
|
|
|
u32 otId = GetBoxMonData(boxMon, MON_DATA_OT_ID);
|
|
|
|
u32 pid = GetBoxMonData(boxMon, MON_DATA_PERSONALITY);
|
|
|
|
|
|
|
|
// Update front sprite
|
2021-09-29 05:58:41 +02:00
|
|
|
StartDisplayMonMosaicEffect();
|
2021-09-29 05:48:03 +02:00
|
|
|
sStorage->displayMonSpecies = species;
|
|
|
|
sStorage->displayMonPalette = GetMonSpritePalFromSpeciesAndPersonality(species, otId, pid);
|
|
|
|
LoadDisplayMonGfx(species, pid);
|
2021-09-29 06:49:18 +02:00
|
|
|
|
|
|
|
// Recreate icon sprite
|
|
|
|
if (sInPartyMenu)
|
|
|
|
{
|
2021-09-29 06:59:31 +02:00
|
|
|
DestroyAllPartyMonIcons();
|
2021-09-29 06:49:18 +02:00
|
|
|
CreatePartyMonsSprites(TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DestroyBoxMonIcon(sStorage->boxMonsSprites[sCursorPosition]);
|
|
|
|
CreateBoxMonIconAtPos(sCursorPosition);
|
|
|
|
SetBoxMonIconObjMode(sCursorPosition, GetMonData(boxMon, MON_DATA_HELD_ITEM) == ITEM_NONE);
|
|
|
|
}
|
2021-09-29 05:48:03 +02:00
|
|
|
}
|