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-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,
|
|
|
|
INPUT_1,
|
|
|
|
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,
|
|
|
|
CURSOR_AREA_BOX,
|
|
|
|
CURSOR_AREA_BUTTONS, // Party Pokemon and Close Box
|
|
|
|
};
|
2021-04-16 01:17:53 +02:00
|
|
|
#define CURSOR_AREA_IN_HAND CURSOR_AREA_BOX // Alt name for cursor area used by Move Items
|
|
|
|
|
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-16 01:17:53 +02:00
|
|
|
PALTAG_7,
|
2021-04-16 05:27:05 +02:00
|
|
|
PALTAG_MARKING_COMBO,
|
2021-04-16 01:17:53 +02:00
|
|
|
PALTAG_BOX_TITLE,
|
|
|
|
PALTAG_10,
|
|
|
|
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-16 01:17:53 +02:00
|
|
|
GFXTAG_18,
|
|
|
|
};
|
2021-04-15 19:31:18 +02: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-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,
|
|
|
|
MULTIMOVE_CANCEL,
|
|
|
|
MULTIMOVE_CHANGE_SELECTION,
|
|
|
|
MULTIMOVE_GRAB_SELECTION,
|
|
|
|
MULTIMOVE_MOVE_MONS,
|
|
|
|
MULTIMOVE_PLACE_MONS,
|
|
|
|
};
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
struct Wallpaper
|
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
|
|
|
struct PokemonStorageSystemFunc
|
|
|
|
{
|
|
|
|
u8 (*func)(void);
|
|
|
|
s8 unk4;
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UnkStruct_2000028
|
|
|
|
{
|
|
|
|
const u8 *unk_00;
|
|
|
|
u8 *unk_04;
|
|
|
|
u16 unk_08;
|
|
|
|
u16 unk_0a;
|
2018-12-20 22:14:36 +01:00
|
|
|
u16 newField;
|
2018-12-19 22:47:27 +01:00
|
|
|
void (*unk_0c)(struct UnkStruct_2000028 *data);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UnkStruct_2000020
|
|
|
|
{
|
|
|
|
struct UnkStruct_2000028 *unk_00;
|
|
|
|
u8 unk_04;
|
|
|
|
u8 unk_05;
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
bool8 isReshowingPSS;
|
|
|
|
u8 taskId;
|
|
|
|
struct UnkStruct_2000020 unk_0020;
|
|
|
|
struct UnkStruct_2000028 unk_0028[8];
|
|
|
|
u16 field_B0[528 / 2];
|
|
|
|
u16 field_2C0;
|
|
|
|
u16 field_2C2;
|
2020-07-19 03:58:01 +02:00
|
|
|
u8 field_2C4; // Unused
|
2018-12-19 22:47:27 +01:00
|
|
|
u8 field_2C5;
|
|
|
|
u8 showPartyMenuState;
|
|
|
|
u8 unk_02C7;
|
|
|
|
u8 unk_02C8;
|
|
|
|
bool8 unk_02C9;
|
|
|
|
s16 newCurrBoxId;
|
|
|
|
u16 bg2_X;
|
2021-04-15 23:31:50 +02:00
|
|
|
s16 scrollSpeed;
|
2018-12-19 22:47:27 +01:00
|
|
|
u16 field_2D0;
|
2021-04-15 20:06:25 +02:00
|
|
|
u8 wallpaperOffset;
|
2020-07-19 03:58:01 +02:00
|
|
|
u8 field_2D3; // Written to, but never read.
|
2021-04-15 20:06:25 +02:00
|
|
|
u8 scrollToBoxIdUnused; // Written to, but never read.
|
2020-07-19 03:58:01 +02:00
|
|
|
u16 field_2D6; // Written to, but never read.
|
2021-04-15 20:06:25 +02:00
|
|
|
s16 scrollDirectionUnused; // Written to, but never read.
|
2020-07-19 03:58:01 +02:00
|
|
|
u16 field_2DA; // Written to, but never read.
|
|
|
|
u16 field_2DC; // Written to, but never read.
|
|
|
|
u16 field_2DE; // Written to, but never read.
|
|
|
|
u16 field_2E0; // Written to, but never read.
|
2018-12-20 22:14:36 +01:00
|
|
|
u8 filler[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];
|
|
|
|
u32 boxTitlePalBits;
|
2020-07-19 03:58:01 +02:00
|
|
|
u8 field_73C[80]; // Unused
|
|
|
|
u16 field_78C; // Written to, but 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];
|
|
|
|
struct Sprite **field_B00;
|
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];
|
|
|
|
u8 field_C5C;
|
|
|
|
u8 field_C5D;
|
|
|
|
u8 field_C5E;
|
|
|
|
u16 field_C60;
|
|
|
|
s16 field_C62;
|
|
|
|
s16 field_C64;
|
|
|
|
u16 field_C66;
|
|
|
|
u8 field_C68;
|
|
|
|
s8 field_C69;
|
|
|
|
u8 field_C6A;
|
2020-07-19 03:58:01 +02:00
|
|
|
u8 field_C6B; // Written to, but never read.
|
2018-12-19 22:47:27 +01:00
|
|
|
struct WindowTemplate menuWindow;
|
|
|
|
struct StorageMenu menuItems[7];
|
|
|
|
u8 menuItemsCount;
|
|
|
|
u8 menuWidth;
|
2020-07-19 03:58:01 +02:00
|
|
|
u8 field_CAE; // Written to, but never read.
|
2021-04-15 19:31:18 +02:00
|
|
|
u16 menuWindowId;
|
2021-04-16 05:27:05 +02:00
|
|
|
struct Sprite *cursorSprite;
|
2018-12-19 22:47:27 +01:00
|
|
|
struct Sprite *field_CB8;
|
|
|
|
s32 field_CBC;
|
|
|
|
s32 field_CC0;
|
|
|
|
u32 field_CC4;
|
|
|
|
u32 field_CC8;
|
|
|
|
s16 field_CCC;
|
|
|
|
s16 field_CCE;
|
2021-04-16 23:05:44 +02:00
|
|
|
u16 cursorMoveSteps;
|
2018-12-19 22:47:27 +01:00
|
|
|
s8 field_CD2;
|
|
|
|
s8 field_CD3;
|
|
|
|
u8 field_CD4;
|
|
|
|
u8 field_CD5;
|
|
|
|
u8 field_CD6;
|
|
|
|
u8 field_CD7;
|
2021-04-16 05:27:05 +02:00
|
|
|
u8 cursorPalNums[2];
|
|
|
|
const u32 *displayMonPalette;
|
|
|
|
u32 displayMonPersonality;
|
|
|
|
u16 displayMonSpecies;
|
|
|
|
u16 displayMonItemId;
|
2018-12-19 22:47:27 +01:00
|
|
|
u16 field_CE8;
|
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;
|
|
|
|
u8 field_D91;
|
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];
|
2018-12-19 22:47:27 +01:00
|
|
|
u8 field_2186;
|
|
|
|
u8 field_2187;
|
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;
|
|
|
|
} field_218C;
|
|
|
|
u8 field_2190[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;
|
2020-07-19 03:58:01 +02:00
|
|
|
u8 field_2238; // 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];
|
2020-07-19 03:58:01 +02:00
|
|
|
u8 field_2AC4[0x1800]; // Unused
|
2018-12-19 22:47:27 +01:00
|
|
|
u8 field_42C4[0x800];
|
2021-04-15 20:06:25 +02:00
|
|
|
u8 wallpaperBgTilemapBuffer[0x1000];
|
2018-12-19 22:47:27 +01:00
|
|
|
u8 field_5AC4[0x800];
|
|
|
|
};
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
struct UnkSubStruct_2039D84
|
|
|
|
{
|
|
|
|
s16 field_0;
|
|
|
|
s16 field_2;
|
|
|
|
u16 field_4;
|
|
|
|
u16 field_6;
|
|
|
|
s16 field_8;
|
|
|
|
s16 field_A;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UnkStruct_2039D84
|
|
|
|
{
|
|
|
|
struct UnkSubStruct_2039D84 field_0[2];
|
|
|
|
const void *field_18;
|
|
|
|
const void *field_1C;
|
|
|
|
u16 field_20;
|
|
|
|
u16 field_22;
|
|
|
|
u16 field_24;
|
|
|
|
u16 field_26;
|
|
|
|
u16 field_28;
|
|
|
|
u8 field_2A;
|
|
|
|
u8 field_2B;
|
|
|
|
u8 field_2C;
|
|
|
|
u8 field_2D;
|
|
|
|
};
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static u32 sItemIconGfxBuffer[98];
|
2017-10-03 03:51:22 +02:00
|
|
|
|
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;
|
2018-12-20 22:14:36 +01:00
|
|
|
EWRAM_DATA static struct PokemonStorageSystemData *sPSSData = NULL;
|
|
|
|
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;
|
2018-12-20 22:14:36 +01:00
|
|
|
EWRAM_DATA static struct Pokemon gUnknown_02039D14 = {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-15 23:31:50 +02:00
|
|
|
static void CreateMainMenu(u8, s16 *);
|
2021-04-15 20:06:25 +02:00
|
|
|
static void Cb2_EnterPSS(u8);
|
2018-12-19 22:47:27 +01:00
|
|
|
static u8 GetCurrentBoxOption(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static u8 HandleInput(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static u8 sub_80CDC2C(void);
|
|
|
|
static u8 sub_80CB9BC(void);
|
2021-04-15 20:06:25 +02:00
|
|
|
static void LoadWallpaperGfx(u8, s8);
|
|
|
|
static void CreateIncomingBoxTitle(u8, s8);
|
|
|
|
static void StartBoxScrollArrowsSlide(s8);
|
|
|
|
static void SetCurrentBox(u8);
|
|
|
|
static void CreateInitBoxTask(u8);
|
2021-04-15 23:31:50 +02:00
|
|
|
static void ChooseBoxMenu_CreateSprites(u8);
|
2021-04-15 20:06:25 +02:00
|
|
|
static void TrimOldWallpaper(void *);
|
2021-04-15 23:31:50 +02:00
|
|
|
static void ChooseBoxMenu_DestroySprites(void);
|
|
|
|
static void ChooseBoxMenu_MoveLeft(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static void ScrollBackground(void);
|
2021-04-15 23:31:50 +02:00
|
|
|
static void ChooseBoxMenu_MoveRight(void);
|
|
|
|
static void ChooseBoxMenu_PrintInfo(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CAA14(void);
|
2021-04-16 23:05:44 +02:00
|
|
|
static void ToggleCursorAutoAction(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CE790(void);
|
|
|
|
static void sub_80CE8E4(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);
|
|
|
|
static void DestroyAllPartyMonIcons(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static void sub_80D11CC(void);
|
|
|
|
static void LoadPSSMenuGfx(void);
|
|
|
|
static void LoadWaveformSpritePalette(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CDC18(void);
|
|
|
|
static void sub_80CD36C(void);
|
|
|
|
static void sub_80CD3EC(void);
|
|
|
|
static void sub_80CAC1C(void);
|
|
|
|
static void sub_80CEBDC(void);
|
|
|
|
static void SetScrollingBackground(void);
|
|
|
|
static void sub_80CABE0(void);
|
|
|
|
static void sub_80CAEAC(void);
|
2021-04-16 01:17:53 +02:00
|
|
|
static void CreateItemIconSprites(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static void sub_80CFEA8(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CDC0C(void);
|
2021-04-16 05:27:05 +02:00
|
|
|
static void InitMonIconFields(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CA0D8(void);
|
|
|
|
static void AddMenu(void);
|
2021-04-16 05:27:05 +02:00
|
|
|
static void InitReleaseMon(void);
|
|
|
|
static void InitCanReleaseMonVars(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static void ReleaseMon(void);
|
2021-04-16 05:27:05 +02:00
|
|
|
static void RefreshDisplayMonData(void);
|
|
|
|
static void CreateDisplayMonSprite(void);
|
2021-04-16 01:17:53 +02:00
|
|
|
static void CreateMarkingComboSprite(void);
|
|
|
|
static void CreateWaveformSprites(void);
|
2021-04-16 05:27:05 +02:00
|
|
|
static void ReshowReleaseMon(void);
|
|
|
|
static void TrySetCursorFistAnim(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static void ClearBottomWindow(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CA704(void);
|
2021-04-15 19:31:18 +02:00
|
|
|
static void RemoveMenu(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CE00C(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static void sub_80D1194(void);
|
2021-04-16 05:27:05 +02:00
|
|
|
static void PrintDisplayMonInfo(void);
|
2021-04-16 01:17:53 +02:00
|
|
|
static void UpdateWaveformAnimation(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void AddWallpaperSetsMenu(void);
|
2021-04-15 20:06:25 +02:00
|
|
|
static void CreateBoxScrollArrows(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void InitMenu(void);
|
2021-04-15 20:06:25 +02:00
|
|
|
static void StopBoxScrollArrowsSlide(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static void sub_80CFC14(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CEB40(void);
|
2021-04-15 20:06:25 +02:00
|
|
|
static void CycleBoxTitleSprites(void);
|
2021-04-16 01:17:53 +02:00
|
|
|
static void InitItemInfoWindow(void);
|
|
|
|
static void DrawItemInfoWindow(u32);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CAA74(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static void PrintItemDescription(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CE760(void);
|
|
|
|
static void sub_80CDBA0(void);
|
|
|
|
static void sub_80CE7E8(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static void sub_80CFECC(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CA9EC(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static void FreePSSData(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void AddBoxMenu(void);
|
2021-04-15 20:06:25 +02:00
|
|
|
static void CycleBoxTitleColor(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static void MoveMon(void);
|
|
|
|
static void PlaceMon(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CAB20(void);
|
|
|
|
static void sub_80CE22C(void);
|
|
|
|
static void sub_80CDA68(void);
|
|
|
|
static void sub_80CB950(void);
|
|
|
|
static void sub_80CA9C0(void);
|
|
|
|
static void SetUpDoShowPartyMenu(void);
|
2021-04-16 05:27:05 +02:00
|
|
|
static void StartDisplayMonMosaicEffect(void);
|
2021-04-15 23:31:50 +02:00
|
|
|
static void SpriteCB_ChooseBoxArrow(struct Sprite *);
|
2021-04-16 05:27:05 +02:00
|
|
|
static void SpriteCB_HeldMon(struct Sprite *);
|
2021-04-15 20:06:25 +02:00
|
|
|
static void sub_80CB278(struct Sprite *);
|
|
|
|
static void SpriteCB_Arrow(struct Sprite *);
|
2018-12-19 22:47:27 +01:00
|
|
|
static bool32 WaitForWallpaperGfxLoad(void);
|
|
|
|
static bool8 InitPSSWindows(void);
|
2021-04-16 05:27:05 +02:00
|
|
|
static bool8 ResetReleaseMonSpritePtr(void);
|
|
|
|
static bool8 TryHideReleaseMon(void);
|
2021-04-15 20:06:25 +02:00
|
|
|
static bool8 IsInitBoxActive(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 sub_80CDED4(void);
|
|
|
|
static bool8 sub_80CDF08(void);
|
2021-04-16 01:17:53 +02:00
|
|
|
static bool8 UpdateItemInfoWindowSlideIn(void);
|
|
|
|
static bool8 UpdateItemInfoWindowSlideOut(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 DoShowPartyMenu(void);
|
2021-04-16 01:17:53 +02:00
|
|
|
static bool8 IsItemIconAnimActive(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static bool8 ScrollToBox(void);
|
2021-04-16 23:05:44 +02:00
|
|
|
static bool8 UpdateCursorPos(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 HidePartyMenu(void);
|
2021-04-16 01:17:53 +02:00
|
|
|
static bool8 IsMovingItem(void);
|
2021-04-16 05:27:05 +02:00
|
|
|
static bool8 IsDisplayMosaicActive(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 DoWallpaperGfxChange(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static bool8 DoMonPlaceChange(void);
|
2021-04-15 20:06:25 +02:00
|
|
|
static bool8 IsMenuLoading(void);
|
2021-04-16 23:05:44 +02:00
|
|
|
static bool8 IsRemovingLastPartyMon(void);
|
2018-12-22 23:00:22 +01:00
|
|
|
static bool8 CanShiftMon(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 IsCursorOnCloseBox(void);
|
|
|
|
static bool8 IsCursorOnBox(void);
|
|
|
|
static bool8 IsCursorInBox(void);
|
|
|
|
static bool8 IsMonBeingMoved(void);
|
2021-04-15 20:06:25 +02:00
|
|
|
static bool8 TryStorePartyMonInBox(u8);
|
2021-04-15 23:31:50 +02:00
|
|
|
static void Cb_InitPSS(u8);
|
|
|
|
static void Cb_PlaceMon(u8);
|
|
|
|
static void Cb_ChangeScreen(u8);
|
|
|
|
static void Cb_ShowPSS(u8);
|
|
|
|
static void Cb_OnBPressed(u8);
|
|
|
|
static void Cb_HandleBoxOptions(u8);
|
|
|
|
static void Cb_OnSelectedMon(u8);
|
|
|
|
static void Cb_OnCloseBoxPressed(u8);
|
|
|
|
static void Cb_HidePartyPokemon(u8);
|
|
|
|
static void Cb_DepositMenu(u8);
|
|
|
|
static void Cb_MoveMon(u8);
|
|
|
|
static void Cb_GiveMovingItemToMon(u8);
|
|
|
|
static void Cb_SwitchSelectedItem(u8);
|
|
|
|
static void Cb_TakeItemForMoving(u8);
|
|
|
|
static void Cb_WithdrawMon(u8);
|
|
|
|
static void Cb_ShiftMon(u8);
|
|
|
|
static void Cb_ShowPartyPokemon(u8);
|
|
|
|
static void Cb_ShowItemInfo(u8);
|
|
|
|
static void Cb_GiveItemFromBag(u8);
|
|
|
|
static void Cb_ItemToBag(u8);
|
|
|
|
static void Cb_TakeItemForMoving(u8);
|
|
|
|
static void Cb_ShowMarkMenu(u8);
|
|
|
|
static void Cb_ShowMonSummary(u8);
|
|
|
|
static void Cb_ReleaseMon(u8);
|
|
|
|
static void Cb_ReshowPSS(u8);
|
|
|
|
static void Cb_MainPSS(u8);
|
|
|
|
static void Cb_JumpBox(u8);
|
|
|
|
static void Cb_HandleWallpapers(u8);
|
|
|
|
static void Cb_NameBox(u8);
|
|
|
|
static void Cb_PrintCantStoreMail(u8);
|
|
|
|
static void Cb_HandleMovingMonFromParty(u8);
|
2021-04-15 20:06:25 +02:00
|
|
|
static void SetUpScrollToBox(u8);
|
2021-04-16 05:27:05 +02:00
|
|
|
static void StartCursorAnim(u8);
|
2021-04-15 20:06:25 +02:00
|
|
|
static void SetMovingMonPriority(u8);
|
|
|
|
static void InitMonPlaceChange(u8);
|
|
|
|
static void SetMonMarkings(u8);
|
|
|
|
static void ShowYesNoWindow(s8);
|
|
|
|
static void sub_80CDBF8(u8);
|
|
|
|
static void AnimateBoxScrollArrows(bool8);
|
|
|
|
static void sub_80CA984(bool8);
|
|
|
|
static void CreatePartyMonsSprites(bool8);
|
2021-04-15 19:31:18 +02:00
|
|
|
static void PrintMessage(u8 id);
|
|
|
|
static s16 HandleMenuInput(void);
|
2018-12-19 22:47:27 +01:00
|
|
|
static s8 RunCanReleaseMon(void);
|
2021-04-16 23:05:44 +02:00
|
|
|
static u8 GetCursorPosition(void);
|
2021-04-15 20:06:25 +02:00
|
|
|
static void Item_FromMonToMoving(u8, u8);
|
|
|
|
static void Item_GiveMovingToMon(u8, u8);
|
|
|
|
static void Item_TakeMons(u8, u8);
|
|
|
|
static void Item_SwitchMonsWithMoving(u8, u8);
|
2021-04-15 23:31:50 +02:00
|
|
|
static struct Sprite *CreateChooseBoxArrows(u16, u16, u8, u8, u8);
|
2021-04-15 20:06:25 +02:00
|
|
|
static void SetWallpaperForCurrentBox(u8);
|
|
|
|
static void AddWallpapersMenu(u8);
|
2021-04-16 01:17:53 +02:00
|
|
|
static u16 GetMovingItemId(void);
|
2021-04-16 05:27:05 +02:00
|
|
|
static void LoadDisplayMonGfx(u16, u32);
|
|
|
|
static void SpriteCB_DisplayMonMosaic(struct Sprite *);
|
2021-04-15 20:06:25 +02:00
|
|
|
static void SpriteCB_OutgoingBoxTitle(struct Sprite *);
|
2021-04-15 23:31:50 +02:00
|
|
|
static void sub_80CBA3C(struct Sprite *);
|
2021-04-15 20:06:25 +02:00
|
|
|
static void SpriteCB_IncomingBoxTitle(struct Sprite *);
|
2021-04-15 23:31:50 +02:00
|
|
|
static void sub_80CBAF0(s16);
|
|
|
|
static void sub_80CAAA8(u8, bool8);
|
2018-12-19 22:47:27 +01:00
|
|
|
static const u8 *GetMovingItemName(void);
|
2021-04-15 23:31:50 +02:00
|
|
|
static void SetMenuText(u8);
|
|
|
|
static void sub_80D0D8C(u8, u8);
|
|
|
|
static void sub_80D0E50(u8, u8);
|
|
|
|
static void sub_80D0F38(u16);
|
|
|
|
static struct Sprite *CreateMonIconSprite(u16, u32, s16, s16, u8, u8);
|
|
|
|
static void DestroyBoxMonIcon(struct Sprite *);
|
2021-04-15 20:06:25 +02:00
|
|
|
static void SetBoxSpeciesAndPersonalities(u8);
|
|
|
|
static void sub_80CB9D0(struct Sprite *, u16);
|
2021-04-15 23:31:50 +02:00
|
|
|
static void Task_InitBox(u8);
|
|
|
|
static void InitBoxTitle(u8);
|
|
|
|
static s8 DetermineBoxScrollDirection(u8);
|
2021-04-15 20:06:25 +02:00
|
|
|
static void DrawWallpaper(const void *, s8, u8);
|
|
|
|
static s16 GetBoxTitleBaseX(const u8 *);
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 MonPlaceChange_Shift(void);
|
|
|
|
static bool8 MonPlaceChange_Move(void);
|
|
|
|
static bool8 MonPlaceChange_Place(void);
|
|
|
|
static bool8 sub_80CDEC4(void);
|
|
|
|
static bool8 sub_80CDEB4(void);
|
2021-04-16 05:27:05 +02:00
|
|
|
static void GetCursorCoordsByPos(u8, u8, u16 *, u16 *);
|
2021-04-15 23:31:50 +02:00
|
|
|
static void SetShiftedMonData(u8, u8);
|
|
|
|
static void SetMovedMonData(u8, u8);
|
|
|
|
static void SetPlacedMonData(u8, u8);
|
|
|
|
static void PurgeMonOrBoxMon(u8, u8);
|
2021-04-16 05:27:05 +02:00
|
|
|
static void SetDisplayMonData(void *, u8);
|
2018-12-19 22:47:27 +01:00
|
|
|
static bool32 AtLeastThreeUsableMons(void);
|
2018-12-16 21:10:01 +01:00
|
|
|
static u8 InBoxInput_Normal(void);
|
|
|
|
static u8 InBoxInput_MovingMultiple(void);
|
2021-04-16 23:05:44 +02:00
|
|
|
static u8 InBoxInput_SelectingMultiple(void);
|
2021-04-15 19:31:18 +02:00
|
|
|
static s8 GetMenuItemTextId(u8);
|
2021-04-16 23:05:44 +02:00
|
|
|
static u8 SetSelectionMenuTexts(void);
|
|
|
|
static bool8 SetMenuTexts_Mon(void);
|
|
|
|
static bool8 SetMenuTexts_Item(void);
|
2021-04-15 23:31:50 +02:00
|
|
|
static void sub_80D27AC(u8, u16, u16, u16, u16);
|
|
|
|
static void sub_80D27F4(u8, u8, s8);
|
|
|
|
static void sub_80D2644(u8, u8, const void *, u16, u16);
|
|
|
|
static void sub_80D2770(u8, u16, u16);
|
|
|
|
static void sub_80D259C(u8);
|
2018-12-20 22:14:36 +01:00
|
|
|
static void sub_80D25F0(void);
|
2021-04-15 23:31:50 +02:00
|
|
|
static void sub_80D2918(u8);
|
|
|
|
static void sub_80D2960(u8);
|
|
|
|
static void sub_80D29F8(u8);
|
|
|
|
static void sub_80D2A90(struct UnkStruct_2000020 *, struct UnkStruct_2000028 *, u32);
|
2018-12-20 22:14:36 +01:00
|
|
|
static void sub_80D2AA4(void);
|
2021-04-15 23:31:50 +02:00
|
|
|
static void sub_80D2B88(struct UnkStruct_2000028 *);
|
|
|
|
static void sub_80D2C1C(struct UnkStruct_2000028 *);
|
2021-04-15 20:06:25 +02:00
|
|
|
static u8 GetBoxWallpaper(u8);
|
|
|
|
static void SetBoxWallpaper(u8, u8);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
// Functions for moving multiple Pokémon at once
|
|
|
|
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-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-15 23:31:50 +02:00
|
|
|
static const u16 sChooseBoxMenu_Pal[] = INCBIN_U16("graphics/pokemon_storage/box_selection_popup.gbapal");
|
|
|
|
static const u8 sChooseBoxMenuCenter_Gfx[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_center.4bpp");
|
|
|
|
static const u8 sChooseBoxMenuSides_Gfx[] = INCBIN_U8("graphics/pokemon_storage/box_selection_popup_sides.4bpp");
|
2021-04-16 05:27:05 +02:00
|
|
|
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");
|
2018-12-16 21:10:01 +01:00
|
|
|
static const u32 gUnknown_08572280[] = INCBIN_U32("graphics/unknown/unknown_572280.gbapal");
|
|
|
|
static const u32 gUnknown_085722A0[] = INCBIN_U32("graphics/unknown/unknown_5722A0.bin.lz");
|
2018-12-09 16:44:01 +01:00
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static const u16 gUnknown_0857239C[] =
|
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,
|
|
|
|
};
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static const u16 gUnknown_085723DC[] = INCBIN_U16("graphics/unknown/unknown_5723DC.gbapal"); // Left-most part and Close Box.
|
|
|
|
static const u16 gUnknown_085723FC[] = INCBIN_U16("graphics/unknown/unknown_5723FC.gbapal");
|
|
|
|
static const u16 gUnknown_0857241C[] = INCBIN_U16("graphics/unknown/unknown_57241C.gbapal");
|
|
|
|
static const u16 gUnknown_0857243C[] = INCBIN_U16("graphics/unknown/unknown_57243C.gbapal");
|
2018-12-09 16:44:01 +01:00
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static const u16 gUnknown_0857245C[] =
|
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
|
|
|
};
|
2018-12-16 21:10:01 +01:00
|
|
|
static const u16 gUnknown_085724A4[] =
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
0x1140, 0x1141, 0x1141, 0x1142, 0x1150, 0x1151, 0x1151, 0x1152, 0x1160, 0x1161, 0x1161, 0x1162,
|
|
|
|
};
|
2018-12-16 21:10:01 +01:00
|
|
|
static const u16 gUnknown_085724BC[] =
|
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");
|
2018-12-16 21:10:01 +01:00
|
|
|
static const u32 gUnknown_085726B4[] = INCBIN_U32("graphics/unused/unknown_5726B4.gbapal");
|
|
|
|
static const u32 gUnknown_085726F4[] = INCBIN_U32("graphics/unknown/unknown_5726F4.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
|
|
|
|
};
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static const struct BgTemplate gUnknown_08572734[] =
|
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-16 05:27:05 +02:00
|
|
|
sWaveform_Pal, PALTAG_10
|
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,
|
|
|
|
.paletteTag = PALTAG_10,
|
|
|
|
.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-16 01:17:53 +02:00
|
|
|
.tileTag = GFXTAG_18,
|
|
|
|
.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-10 23:42:44 +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-10 23:42:44 +01:00
|
|
|
};
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
#include "data/wallpapers.h"
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static const u16 sUnusedColor = RGB(26, 29, 8);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
static const struct SpriteSheet sSpriteSheet_Arrow = {sArrow_Gfx, 0x80, GFXTAG_ARROW};
|
2018-12-15 23:58:47 +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,
|
|
|
|
.images NULL,
|
|
|
|
.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-16 01:17:53 +02:00
|
|
|
.paletteTag = PALTAG_10,
|
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
|
|
|
|
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
|
|
|
|
void sub_80C6EAC(const u8 *string, void *dst, u16 arg2, u8 arg3, u8 clr2, u8 clr3)
|
|
|
|
{
|
|
|
|
u32 var;
|
|
|
|
u8 windowId;
|
|
|
|
u8 txtColor[3];
|
|
|
|
u8 *tileData1, *tileData2;
|
|
|
|
struct WindowTemplate winTemplate = {0};
|
|
|
|
|
|
|
|
winTemplate.width = StringLength_Multibyte(string);
|
|
|
|
winTemplate.height = 2;
|
|
|
|
var = winTemplate.width * 32;
|
|
|
|
windowId = AddWindow(&winTemplate);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(arg3));
|
2019-01-26 20:56:06 +01:00
|
|
|
tileData1 = (u8*) GetWindowAttribute(windowId, WINDOW_TILE_DATA);
|
|
|
|
tileData2 = (winTemplate.width * 32) + tileData1;
|
|
|
|
txtColor[0] = arg3;
|
|
|
|
txtColor[1] = clr2;
|
|
|
|
txtColor[2] = clr3;
|
|
|
|
AddTextPrinterParameterized4(windowId, 1, 0, 2, 0, 0, txtColor, -1, string);
|
|
|
|
CpuCopy16(tileData1, dst, var);
|
|
|
|
CpuCopy16(tileData2, dst + arg2, var);
|
|
|
|
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
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80C7128(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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80C71A4(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-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-15 23:31:50 +02:00
|
|
|
Cb2_EnterPSS(task->tInput);
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void FieldCb_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;
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void Cb2_ExitPSS(void)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
2018-12-12 23:19:50 +01:00
|
|
|
sPreviousBoxOption = GetCurrentBoxOption();
|
2018-12-10 21:36:52 +01:00
|
|
|
gFieldCallback = FieldCb_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-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-04-15 23:31:50 +02:00
|
|
|
sChooseBoxMenu->menuSideSprites[i]->pos1.x = 196;
|
|
|
|
anim = 2;
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
if (i & 1)
|
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
sChooseBoxMenu->menuSideSprites[i]->pos1.y = 112;
|
|
|
|
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;
|
|
|
|
sprite->pos2.x += sprite->data[0];
|
|
|
|
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;
|
|
|
|
sprite->pos2.x = 0;
|
2017-11-11 14:45:08 +01:00
|
|
|
}
|
|
|
|
}
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void VblankCb_PSS(void)
|
2018-08-12 16:40:31 +02:00
|
|
|
{
|
|
|
|
LoadOam();
|
|
|
|
ProcessSpriteCopyRequests();
|
|
|
|
sub_80D2AA4();
|
|
|
|
TransferPlttBuffer();
|
2018-12-20 22:14:36 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BG2HOFS, sPSSData->bg2_X);
|
2018-08-12 16:40:31 +02:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void Cb2_PSS(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();
|
2018-08-12 16:40:31 +02:00
|
|
|
sub_80CAA14();
|
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
|
|
|
}
|
2018-12-09 16:44:01 +01:00
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void Cb2_EnterPSS(u8 boxOption)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
ResetTasks();
|
2018-12-12 23:19:50 +01:00
|
|
|
sCurrentBoxOption = boxOption;
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
sPSSData = Alloc(sizeof(*sPSSData));
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData == NULL)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-10 21:36:52 +01:00
|
|
|
SetMainCallback2(Cb2_ExitPSS);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->boxOption = boxOption;
|
|
|
|
sPSSData->isReshowingPSS = FALSE;
|
2020-03-09 02:27:29 +01:00
|
|
|
sMovingItemId = ITEM_NONE;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 0;
|
|
|
|
sPSSData->taskId = CreateTask(Cb_InitPSS, 3);
|
2019-09-17 07:49:07 +02:00
|
|
|
sLastUsedBox = StorageGetCurrentBox();
|
2018-12-10 23:42:44 +01:00
|
|
|
SetMainCallback2(Cb2_PSS);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void Cb2_ReturnToPSS(void)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
ResetTasks();
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
sPSSData = Alloc(sizeof(*sPSSData));
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData == NULL)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-10 21:36:52 +01:00
|
|
|
SetMainCallback2(Cb2_ExitPSS);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->boxOption = sCurrentBoxOption;
|
|
|
|
sPSSData->isReshowingPSS = TRUE;
|
|
|
|
sPSSData->state = 0;
|
|
|
|
sPSSData->taskId = CreateTask(Cb_InitPSS, 3);
|
2018-12-10 23:42:44 +01:00
|
|
|
SetMainCallback2(Cb2_PSS);
|
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);
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80C7E98(void)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
ResetPaletteFade();
|
|
|
|
ResetSpriteData();
|
|
|
|
FreeSpriteTileRanges();
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
ClearDma3Requests();
|
|
|
|
gReservedSpriteTileCount = 0x280;
|
2018-12-20 22:14:36 +01:00
|
|
|
sub_80D2A90(&sPSSData->unk_0020, sPSSData->unk_0028, 8);
|
2018-12-09 16:44:01 +01:00
|
|
|
gKeyRepeatStartDelay = 20;
|
2020-06-20 01:58:56 +02:00
|
|
|
ClearScheduledBgCopiesToVram();
|
2018-12-09 16:44:01 +01:00
|
|
|
sub_80D259C(3);
|
|
|
|
sub_80D2644(0, 1, gUnknown_0857239C, 8, 4);
|
|
|
|
sub_80D2770(0, 1, 0);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->unk_02C7 = 0;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80C7F1C(void)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
sub_80CDC0C();
|
2021-04-15 23:31:50 +02:00
|
|
|
sInPartyMenu = (sPSSData->boxOption == OPTION_DEPOSIT);
|
|
|
|
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-15 23:31:50 +02:00
|
|
|
if (sPSSData->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);
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void SetPSSCallback(TaskFunc newFunc)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
gTasks[sPSSData->taskId].func = newFunc;
|
|
|
|
sPSSData->state = 0;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_InitPSS(u8 taskId)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->state)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
SetVBlankCallback(NULL);
|
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
|
|
|
sub_80C7E98();
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->isReshowingPSS)
|
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
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
sub_80CE790();
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
sub_80CE8E4();
|
|
|
|
break;
|
|
|
|
case 2:
|
2018-12-10 23:42:44 +01:00
|
|
|
GiveChosenBagItem();
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-12-10 23:42:44 +01:00
|
|
|
LoadPSSMenuGfx();
|
|
|
|
LoadWaveformSpritePalette();
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2018-12-10 23:42:44 +01:00
|
|
|
if (!InitPSSWindows())
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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();
|
2018-12-20 22:14:36 +01:00
|
|
|
if (!sPSSData->isReshowingPSS)
|
2018-12-09 16:44:01 +01:00
|
|
|
sub_80C7F1C();
|
|
|
|
break;
|
|
|
|
case 4:
|
2021-04-16 05:27:05 +02:00
|
|
|
InitMonIconFields();
|
2018-12-20 22:14:36 +01:00
|
|
|
if (!sPSSData->isReshowingPSS)
|
2018-12-09 16:44:01 +01:00
|
|
|
sub_80CD36C();
|
|
|
|
else
|
|
|
|
sub_80CD3EC();
|
|
|
|
break;
|
|
|
|
case 5:
|
2021-04-16 23:05:44 +02:00
|
|
|
if (!MultiMove_Init())
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_ChangeScreen);
|
2018-12-09 16:44:01 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-10 23:42:44 +01:00
|
|
|
SetScrollingBackground();
|
2018-12-09 16:44:01 +01:00
|
|
|
sub_80CAC1C();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
sub_80CA0D8();
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
sub_80CA704();
|
|
|
|
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-15 23:31:50 +02:00
|
|
|
if (sPSSData->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->markMenu.baseTileTag = GFXTAG_MARKING_MENU;
|
|
|
|
sPSSData->markMenu.basePaletteTag = PALTAG_MARKING_MENU;
|
2021-02-28 23:22:26 +01:00
|
|
|
InitMonMarkingsMenu(&sPSSData->markMenu);
|
|
|
|
BufferMonMarkingsMenuTiles();
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
CreateItemIconSprites();
|
2018-12-09 16:44:01 +01:00
|
|
|
sub_80CAEAC();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 10:
|
2020-03-08 03:05:22 +01:00
|
|
|
SetMonIconTransparency();
|
2018-12-20 22:14:36 +01:00
|
|
|
if (!sPSSData->isReshowingPSS)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
BlendPalettes(PALETTES_ALL, 16, RGB_BLACK);
|
2018-12-10 23:42:44 +01:00
|
|
|
SetPSSCallback(Cb_ShowPSS);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
BlendPalettes(PALETTES_ALL, 16, RGB_BLACK);
|
2018-12-12 23:19:50 +01:00
|
|
|
SetPSSCallback(Cb_ReshowPSS);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
2018-12-10 23:42:44 +01:00
|
|
|
SetVBlankCallback(VblankCb_PSS);
|
2018-12-09 16:44:01 +01:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_ShowPSS(u8 taskId)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-06-29 17:41:09 +02:00
|
|
|
if (!IsComputerScreenOpenEffectActive())
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_ReshowPSS(u8 taskId)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!UpdatePaletteFade())
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sWhichToReshow == 2 && gSpecialVar_ItemId != 0)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_ITEM_IS_HELD);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
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();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
// States for the outer switch in Cb_MainPSS
|
|
|
|
enum {
|
|
|
|
MSTATE_HANDLE_INPUT,
|
|
|
|
MSTATE_1,
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_MainPSS(u8 taskId)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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-15 23:31:50 +02:00
|
|
|
case INPUT_1:
|
2018-12-09 16:44:01 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->state = MSTATE_1;
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_SHOW_PARTY:
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->boxOption != OPTION_MOVE_MONS && sPSSData->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-16 23:05:44 +02:00
|
|
|
sPSSData->state = MSTATE_WAIT_MSG;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sub_80CDC0C();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_ShowPartyPokemon);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_HIDE_PARTY:
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->boxOption == OPTION_MOVE_MONS)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
if (IsMonBeingMoved() && ItemIsMail(sPSSData->displayMonItemId))
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->state = MSTATE_ERROR_HAS_MAIL;
|
2018-12-09 16:44:01 +01:00
|
|
|
else
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_HidePartyPokemon);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
2021-04-15 23:31:50 +02:00
|
|
|
else if (sPSSData->boxOption == OPTION_MOVE_ITEMS)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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:
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_OnCloseBoxPressed);
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_PRESSED_B:
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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);
|
2018-12-09 21:06:43 +01:00
|
|
|
SetPSSCallback(Cb_HandleBoxOptions);
|
2018-12-09 16:44:01 +01:00
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case INPUT_IN_MENU:
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->newCurrBoxId = StorageGetCurrentBox() + 1;
|
|
|
|
if (sPSSData->newCurrBoxId >= TOTAL_BOXES_COUNT)
|
|
|
|
sPSSData->newCurrBoxId = 0;
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
SetUpScrollToBox(sPSSData->newCurrBoxId);
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->state = MSTATE_SCROLL_BOX;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sub_80CFEA8();
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->newCurrBoxId = StorageGetCurrentBox() - 1;
|
|
|
|
if (sPSSData->newCurrBoxId < 0)
|
|
|
|
sPSSData->newCurrBoxId = TOTAL_BOXES_COUNT - 1;
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
SetUpScrollToBox(sPSSData->newCurrBoxId);
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->state = MSTATE_SCROLL_BOX;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sub_80CFEA8();
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->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-16 05:27:05 +02:00
|
|
|
if (ItemIsMail(sPSSData->displayMonItemId))
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->state = MSTATE_ERROR_HAS_MAIL;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_DepositMenu);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->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-16 23:05:44 +02:00
|
|
|
sPSSData->state = MSTATE_ERROR_LAST_PARTY_MON;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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-16 23:05:44 +02:00
|
|
|
sPSSData->state = MSTATE_ERROR_LAST_PARTY_MON;
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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);
|
2018-12-09 21:06:43 +01:00
|
|
|
SetPSSCallback(Cb_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);
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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);
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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);
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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);
|
2018-12-09 21:06:43 +01:00
|
|
|
SetPSSCallback(Cb_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);
|
|
|
|
sPSSData->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);
|
|
|
|
sPSSData->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);
|
|
|
|
sPSSData->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);
|
|
|
|
sPSSData->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);
|
|
|
|
sPSSData->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);
|
|
|
|
sPSSData->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-16 23:05:44 +02:00
|
|
|
case MSTATE_1:
|
|
|
|
if (!UpdateCursorPos())
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-09 21:06:43 +01:00
|
|
|
if (IsCursorOnCloseBox())
|
|
|
|
sub_80CA9C0();
|
2018-12-09 16:44:01 +01:00
|
|
|
else
|
2018-12-09 21:06:43 +01:00
|
|
|
sub_80CA9EC();
|
2018-12-10 21:36:52 +01:00
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->setMosaic)
|
2021-04-16 05:27:05 +02:00
|
|
|
StartDisplayMonMosaicEffect();
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
SetCurrentBox(sPSSData->newCurrBoxId);
|
2018-12-09 21:06:43 +01:00
|
|
|
if (!sInPartyMenu && !IsMonBeingMoved())
|
2018-12-09 16:44:01 +01:00
|
|
|
{
|
2018-12-09 21:06:43 +01:00
|
|
|
sub_80CE00C();
|
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-15 23:31:50 +02:00
|
|
|
if (sPSSData->boxOption == OPTION_MOVE_ITEMS)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
sub_80CFECC();
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->state = MSTATE_WAIT_ITEM_ANIM;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->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-16 23:05:44 +02:00
|
|
|
sPSSData->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-16 23:05:44 +02:00
|
|
|
sPSSData->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-16 23:05:44 +02:00
|
|
|
sPSSData->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();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-16 23:05:44 +02:00
|
|
|
case MSTATE_MULTIMOVE_RUN:
|
|
|
|
if (!MultiMove_RunFunction())
|
|
|
|
sPSSData->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())
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->setMosaic)
|
2021-04-16 05:27:05 +02:00
|
|
|
StartDisplayMonMosaicEffect();
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
SetUpScrollToBox(sPSSData->newCurrBoxId);
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->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-16 23:05:44 +02:00
|
|
|
sPSSData->state = MSTATE_HANDLE_INPUT;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_ShowPartyPokemon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2018-12-12 23:19:50 +01:00
|
|
|
SetUpDoShowPartyMenu();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2018-12-12 23:19:50 +01:00
|
|
|
if (!DoShowPartyMenu())
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_HidePartyPokemon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
PlaySE(SE_SELECT);
|
2018-12-12 23:19:50 +01:00
|
|
|
SetUpHidePartyMenu();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
{
|
|
|
|
sub_80CDBF8(sub_80CDC2C());
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->setMosaic)
|
2021-04-16 05:27:05 +02:00
|
|
|
StartDisplayMonMosaicEffect();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_OnSelectedMon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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-15 23:31:50 +02:00
|
|
|
if (sPSSData->boxOption != OPTION_MOVE_ITEMS)
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_IS_SELECTED);
|
2021-04-16 05:27:05 +02:00
|
|
|
else if (IsMovingItem() || sPSSData->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();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 1;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-04-15 20:06:25 +02:00
|
|
|
case 1:
|
|
|
|
if (!IsMenuLoading())
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 3;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
ClearBottomWindow();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 3;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
ClearBottomWindow();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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();
|
|
|
|
SetPSSCallback(Cb_WithdrawMon);
|
|
|
|
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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 3;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
2021-04-16 05:27:05 +02:00
|
|
|
else if (ItemIsMail(sPSSData->displayMonItemId))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 4;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
ClearBottomWindow();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 3;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
2021-04-16 05:27:05 +02:00
|
|
|
else if (sPSSData->displayMonIsEgg)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 5; // Cannot release an Egg.
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
2021-04-16 05:27:05 +02:00
|
|
|
else if (ItemIsMail(sPSSData->displayMonItemId))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 4;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
SetPSSCallback(Cb_ReleaseMon);
|
|
|
|
}
|
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_SUMMARY:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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);
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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);
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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);
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_GiveMovingItemToMon);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_BAG:
|
2018-12-09 21:06:43 +01:00
|
|
|
SetPSSCallback(Cb_ItemToBag);
|
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_SWITCH:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
SetPSSCallback(Cb_SwitchSelectedItem);
|
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_GIVE_2:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_GiveItemFromBag);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_INFO:
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_MoveMon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2018-12-15 23:58:47 +01:00
|
|
|
InitMonPlaceChange(0);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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)
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_HandleMovingMonFromParty);
|
2018-12-09 21:06:43 +01:00
|
|
|
else
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_PlaceMon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2018-12-15 23:58:47 +01:00
|
|
|
InitMonPlaceChange(1);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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)
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_HandleMovingMonFromParty);
|
2018-12-09 21:06:43 +01:00
|
|
|
else
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_ShiftMon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2018-12-15 23:58:47 +01:00
|
|
|
InitMonPlaceChange(2);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_WithdrawMon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 1;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sub_80CDC18();
|
2018-12-15 23:58:47 +01:00
|
|
|
InitMonPlaceChange(0);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
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();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
{
|
2018-12-15 23:58:47 +01:00
|
|
|
InitMonPlaceChange(1);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
{
|
|
|
|
sub_80CAB20();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_HidePartyPokemon);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_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
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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-16 01:17:53 +02:00
|
|
|
LoadChooseBoxMenuGfx(&sPSSData->chooseBoxMenu, GFXTAG_CHOOSE_BOX_MENU, PALTAG_7, 3, FALSE);
|
2021-04-15 23:31:50 +02:00
|
|
|
CreateChooseBoxMenuSprites(sDepositBoxId);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
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();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 2;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_BOX_IS_FULL);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
|
|
|
sub_80CB950();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!sub_80CB9BC())
|
|
|
|
{
|
|
|
|
sub_80CE22C();
|
2021-04-16 05:27:05 +02:00
|
|
|
StartDisplayMonMosaicEffect();
|
2018-12-09 21:06:43 +01:00
|
|
|
sub_80CAB20();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 1;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_ReleaseMon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
|
|
|
SetPSSCallback(Cb_MainPSS);
|
|
|
|
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();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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-16 05:27:05 +02:00
|
|
|
sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
|
|
|
sub_80CB950();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 7;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
if (!sub_80CB9BC())
|
|
|
|
{
|
|
|
|
sub_80CE00C();
|
2021-04-16 05:27:05 +02:00
|
|
|
StartDisplayMonMosaicEffect();
|
2018-12-09 21:06:43 +01:00
|
|
|
sub_80CAB20();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 7:
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_ShowMarkMenu(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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-16 05:27:05 +02:00
|
|
|
sPSSData->markMenu.markings = sPSSData->displayMonMarkings;
|
|
|
|
OpenMonMarkingsMenu(sPSSData->displayMonMarkings, 0xb0, 0x10);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
2020-03-09 02:27:29 +01:00
|
|
|
SetMonMarkings(sPSSData->markMenu.markings);
|
2021-04-16 05:27:05 +02:00
|
|
|
RefreshDisplayMonData();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_TakeItemForMoving(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-16 05:27:05 +02:00
|
|
|
if (!ItemIsMail(sPSSData->displayMonItemId))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetPSSCallback(Cb_PrintCantStoreMail);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-16 05:27:05 +02:00
|
|
|
StartCursorAnim(CURSOR_ANIM_OPEN);
|
2021-04-16 23:05:44 +02:00
|
|
|
Item_FromMonToMoving((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetCursorPosition());
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
|
|
|
sub_80CE00C();
|
2021-04-16 05:27:05 +02:00
|
|
|
PrintDisplayMonInfo();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_GiveMovingItemToMon(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ClearBottomWindow();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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-16 23:05:44 +02:00
|
|
|
Item_GiveMovingToMon((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetCursorPosition());
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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);
|
2018-12-09 21:06:43 +01:00
|
|
|
sub_80CE00C();
|
2021-04-16 05:27:05 +02:00
|
|
|
PrintDisplayMonInfo();
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_ITEM_IS_HELD);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_ItemToBag(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-16 05:27:05 +02:00
|
|
|
if (!AddBagItem(sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 3;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-04-16 23:05:44 +02:00
|
|
|
Item_TakeMons((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetCursorPosition());
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
|
|
|
sub_80CE00C();
|
2021-04-16 05:27:05 +02:00
|
|
|
PrintDisplayMonInfo();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 4;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
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();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_SwitchSelectedItem(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-16 05:27:05 +02:00
|
|
|
if (!ItemIsMail(sPSSData->displayMonItemId))
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetPSSCallback(Cb_PrintCantStoreMail);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-16 05:27:05 +02:00
|
|
|
StartCursorAnim(CURSOR_ANIM_OPEN);
|
2021-04-16 23:05:44 +02:00
|
|
|
Item_SwitchMonsWithMoving((sInPartyMenu != FALSE) ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetCursorPosition());
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
sub_80CE00C();
|
2021-04-16 05:27:05 +02:00
|
|
|
PrintDisplayMonInfo();
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_CHANGED_TO_ITEM);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_ShowItemInfo(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ClearBottomWindow();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-16 01:17:53 +02:00
|
|
|
if (!UpdateItemInfoWindowSlideIn())
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
2021-04-16 01:17:53 +02:00
|
|
|
if (!UpdateItemInfoWindowSlideOut())
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_CloseBoxWhileHoldingItem(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
2021-04-16 01:17:53 +02:00
|
|
|
case 0:// Yes
|
|
|
|
if (AddBagItem(sPSSData->movingItemId, 1) == TRUE)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
ClearBottomWindow();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 3;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_BAG_FULL);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 5;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
sub_80D1194();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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);
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_HandleMovingMonFromParty(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
CompactPartySlots();
|
|
|
|
sub_80CB950();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!sub_80CB9BC())
|
|
|
|
{
|
|
|
|
sub_80CAB20();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_PrintCantStoreMail(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_CANT_STORE_MAIL);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
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
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_HandleBoxOptions(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
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);
|
|
|
|
SetPSSCallback(Cb_NameBox);
|
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_WALLPAPER:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
ClearBottomWindow();
|
|
|
|
SetPSSCallback(Cb_HandleWallpapers);
|
|
|
|
break;
|
2021-04-15 19:31:18 +02:00
|
|
|
case MENU_JUMP:
|
2018-12-09 21:06:43 +01:00
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
ClearBottomWindow();
|
|
|
|
SetPSSCallback(Cb_JumpBox);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_HandleWallpapers(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-15 20:06:25 +02:00
|
|
|
if (!IsMenuLoading())
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-04-15 19:31:18 +02:00
|
|
|
sPSSData->wallpaperSetId = HandleMenuInput();
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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();
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
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-15 20:06:25 +02:00
|
|
|
sPSSData->wallpaperSetId -= MENU_WALLPAPER_SETS_START;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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-15 20:06:25 +02:00
|
|
|
sPSSData->wallpaperId = WALLPAPER_FRIENDS;
|
2021-04-15 19:31:18 +02:00
|
|
|
RemoveMenu();
|
2018-12-09 21:06:43 +01:00
|
|
|
ClearBottomWindow();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 6;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
AddWallpapersMenu(sPSSData->wallpaperSetId);
|
2021-04-15 19:31:18 +02:00
|
|
|
PrintMessage(MSG_PICK_A_WALLPAPER);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
2021-04-15 19:31:18 +02:00
|
|
|
sPSSData->wallpaperId = HandleMenuInput();
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state = 0;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
ClearBottomWindow();
|
2021-04-15 19:31:18 +02:00
|
|
|
sPSSData->wallpaperId -= MENU_WALLPAPERS_START;
|
2018-12-20 22:14:36 +01:00
|
|
|
SetWallpaperForCurrentBox(sPSSData->wallpaperId);
|
|
|
|
sPSSData->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);
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
SetWallpaperForCurrentBox(sPSSData->wallpaperId);
|
|
|
|
sPSSData->state = 5;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_JumpBox(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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-16 01:17:53 +02:00
|
|
|
LoadChooseBoxMenuGfx(&sPSSData->chooseBoxMenu, GFXTAG_CHOOSE_BOX_MENU, PALTAG_7, 3, FALSE);
|
2021-04-15 23:31:50 +02:00
|
|
|
CreateChooseBoxMenuSprites(StorageGetCurrentBox());
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-15 23:31:50 +02:00
|
|
|
sPSSData->newCurrBoxId = HandleChooseBoxMenuInput();
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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();
|
|
|
|
if (sPSSData->newCurrBoxId == BOXID_CANCELED || sPSSData->newCurrBoxId == StorageGetCurrentBox())
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
AnimateBoxScrollArrows(TRUE);
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2018-12-20 22:14:36 +01:00
|
|
|
SetUpScrollToBox(sPSSData->newCurrBoxId);
|
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!ScrollToBox())
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
SetCurrentBox(sPSSData->newCurrBoxId);
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_MainPSS);
|
2018-12-09 21:06:43 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_NameBox(u8 taskId)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->state)
|
2018-12-09 21:06:43 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
sub_80CE760();
|
2021-02-24 17:01:02 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-09 21:06:43 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!UpdatePaletteFade())
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sWhichToReshow = 1;
|
|
|
|
sPSSData->screenChangeType = SCREEN_CHANGE_NAME_BOX;
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_ChangeScreen);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_ShowMonSummary(u8 taskId)
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->state)
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
sub_80CE7E8();
|
2021-02-24 17:01:02 +01:00
|
|
|
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-10 21:36:52 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!UpdatePaletteFade())
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sWhichToReshow = 0;
|
|
|
|
sPSSData->screenChangeType = SCREEN_CHANGE_SUMMARY_SCREEN;
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_ChangeScreen);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_GiveItemFromBag(u8 taskId)
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->state++;
|
2018-12-10 21:36:52 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!UpdatePaletteFade())
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sWhichToReshow = 2;
|
|
|
|
sPSSData->screenChangeType = SCREEN_CHANGE_ITEM_FROM_BAG;
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_ChangeScreen);
|
2018-12-09 16:44:01 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-12-10 21:36:52 +01:00
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_OnCloseBoxPressed(u8 taskId)
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
{
|
|
|
|
SetPSSCallback(Cb_CloseBoxWhileHoldingItem);
|
|
|
|
}
|
|
|
|
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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
|
|
|
SetPSSCallback(Cb_MainPSS);
|
|
|
|
}
|
|
|
|
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();
|
|
|
|
SetPSSCallback(Cb_MainPSS);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
PlaySE(SE_PC_OFF);
|
|
|
|
ClearBottomWindow();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
{
|
|
|
|
sub_80CABE0();
|
|
|
|
gPlayerPartyCount = CalculatePlayerPartyCount();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->screenChangeType = SCREEN_CHANGE_EXIT_BOX;
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_ChangeScreen);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_OnBPressed(u8 taskId)
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
{
|
|
|
|
SetPSSCallback(Cb_CloseBoxWhileHoldingItem);
|
|
|
|
}
|
|
|
|
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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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();
|
|
|
|
SetPSSCallback(Cb_MainPSS);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
switch (Menu_ProcessInputNoWrapClearOnChoose())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ClearBottomWindow();
|
|
|
|
SetPSSCallback(Cb_MainPSS);
|
|
|
|
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();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
{
|
|
|
|
sub_80CABE0();
|
|
|
|
gPlayerPartyCount = CalculatePlayerPartyCount();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->screenChangeType = SCREEN_CHANGE_EXIT_BOX;
|
2018-12-10 21:36:52 +01:00
|
|
|
SetPSSCallback(Cb_ChangeScreen);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void Cb_ChangeScreen(u8 taskId)
|
2018-12-10 21:36:52 +01:00
|
|
|
{
|
|
|
|
struct BoxPokemon *boxMons;
|
|
|
|
u8 mode, monIndex, maxMonIndex;
|
2018-12-20 22:14:36 +01:00
|
|
|
u8 screenChangeType = sPSSData->screenChangeType;
|
2018-12-10 21:36:52 +01:00
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
if (sPSSData->boxOption == OPTION_MOVE_ITEMS && IsMovingItem() == TRUE)
|
|
|
|
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:
|
|
|
|
FreePSSData();
|
|
|
|
SetMainCallback2(Cb2_ExitPSS);
|
|
|
|
break;
|
|
|
|
case SCREEN_CHANGE_SUMMARY_SCREEN:
|
2018-12-20 22:14:36 +01:00
|
|
|
boxMons = sPSSData->field_218C.box;
|
|
|
|
monIndex = sPSSData->field_2187;
|
|
|
|
maxMonIndex = sPSSData->field_2186;
|
2021-04-15 23:31:50 +02:00
|
|
|
mode = sPSSData->summaryScreenMode;
|
2018-12-10 21:36:52 +01:00
|
|
|
FreePSSData();
|
2021-04-15 23:31:50 +02:00
|
|
|
if (mode == SUMMARY_MODE_NORMAL && boxMons == &gUnknown_02039D14.box)
|
2018-12-10 21:36:52 +01:00
|
|
|
ShowPokemonSummaryScreenSet40EF(mode, boxMons, monIndex, maxMonIndex, Cb2_ReturnToPSS);
|
|
|
|
else
|
|
|
|
ShowPokemonSummaryScreen(mode, boxMons, monIndex, maxMonIndex, Cb2_ReturnToPSS);
|
|
|
|
break;
|
|
|
|
case SCREEN_CHANGE_NAME_BOX:
|
|
|
|
FreePSSData();
|
|
|
|
DoNamingScreen(NAMING_SCREEN_BOX, GetBoxNamePtr(StorageGetCurrentBox()), 0, 0, 0, Cb2_ReturnToPSS);
|
|
|
|
break;
|
|
|
|
case SCREEN_CHANGE_ITEM_FROM_BAG:
|
|
|
|
FreePSSData();
|
2020-05-14 10:37:09 +02:00
|
|
|
GoToBagMenu(ITEMMENULOCATION_PCBOX, 0, Cb2_ReturnToPSS);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void FreePSSData(void)
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
sub_80D25F0();
|
2021-04-16 23:05:44 +02:00
|
|
|
MultiMove_Free();
|
2018-12-20 22:14:36 +01:00
|
|
|
FREE_AND_SET_NULL(sPSSData);
|
2018-12-10 23:42:44 +01:00
|
|
|
FreeAllWindowBuffers();
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void LoadPSSMenuGfx(void)
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
InitBgsFromTemplates(0, gUnknown_08572734, ARRAY_COUNT(gUnknown_08572734));
|
|
|
|
DecompressAndLoadBgGfxUsingHeap(1, gPSSMenu_Gfx, 0, 0, 0);
|
2018-12-20 22:14:36 +01:00
|
|
|
LZ77UnCompWram(gUnknown_085722A0, sPSSData->field_5AC4);
|
|
|
|
SetBgTilemapBuffer(1, sPSSData->field_5AC4);
|
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
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static bool8 InitPSSWindows(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);
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CA0D8(void)
|
2018-12-10 23:42:44 +01:00
|
|
|
{
|
|
|
|
LoadPalette(gUnknown_085723DC, 0, 0x20);
|
|
|
|
LoadPalette(gUnknown_085723FC, 0x20, 0x20);
|
|
|
|
LoadPalette(gUnknown_085726F4, 0xF0, 0x20);
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-10 23:42:44 +01:00
|
|
|
LoadPalette(gUnknown_0857241C, 0x30, 0x20);
|
|
|
|
else
|
|
|
|
LoadPalette(gUnknown_0857243C, 0x30, 0x20);
|
|
|
|
|
|
|
|
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-16 05:27:05 +02:00
|
|
|
sPSSData->markingComboSprite = CreateMonMarkingComboSprite(GFXTAG_MARKING_COMBO, PALTAG_MARKING_COMBO, NULL);
|
2021-04-16 01:17:53 +02:00
|
|
|
sPSSData->markingComboSprite->oam.priority = 1;
|
|
|
|
sPSSData->markingComboSprite->subpriority = 1;
|
|
|
|
sPSSData->markingComboSprite->pos1.x = 40;
|
|
|
|
sPSSData->markingComboSprite->pos1.y = 150;
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->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-16 01:17:53 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sPSSData->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-16 01:17:53 +02:00
|
|
|
sPSSData->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-16 05:27:05 +02:00
|
|
|
LoadDisplayMonGfx(sPSSData->displayMonSpecies, sPSSData->displayMonPersonality);
|
|
|
|
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();
|
|
|
|
if (sPSSData->displayMonSprite)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->displayMonSprite->oam.mosaic = TRUE;
|
|
|
|
sPSSData->displayMonSprite->data[0] = 10;
|
|
|
|
sPSSData->displayMonSprite->data[1] = 1;
|
|
|
|
sPSSData->displayMonSprite->callback = SpriteCB_DisplayMonMosaic;
|
|
|
|
SetGpuReg(REG_OFFSET_MOSAIC, (sPSSData->displayMonSprite->data[0] << 12) | (sPSSData->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-16 05:27:05 +02:00
|
|
|
return sPSSData->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-16 05:27:05 +02:00
|
|
|
struct SpriteSheet sheet = {sPSSData->tileBuffer, MON_PIC_SIZE, GFXTAG_DISPLAY_MON};
|
|
|
|
struct SpritePalette palette = {sPSSData->displayMonPalBuffer, PALTAG_DISPLAY_MON};
|
|
|
|
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-16 01:17:53 +02:00
|
|
|
sPSSData->tileBuffer[i] = 0;
|
|
|
|
for (i = 0; i < 16; i++)
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->displayMonPalBuffer[i] = 0;
|
2018-12-11 23:09:12 +01:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->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-16 05:27:05 +02:00
|
|
|
sPSSData->displayMonSprite = &gSprites[spriteId];
|
|
|
|
sPSSData->displayMonPalOffset = palSlot * 16 + 0x100;
|
|
|
|
sPSSData->displayMonTilePtr = (void*) OBJ_VRAM0 + tileStart * 32;
|
2018-12-11 23:09:12 +01:00
|
|
|
} while (0);
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
if (sPSSData->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-16 05:27:05 +02:00
|
|
|
if (sPSSData->displayMonSprite == NULL)
|
2018-12-11 23:09:12 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (species != SPECIES_NONE)
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
LoadSpecialPokePic(&gMonFrontPicTable[species], sPSSData->tileBuffer, species, pid, TRUE);
|
2021-04-16 05:27:05 +02:00
|
|
|
LZ77UnCompWram(sPSSData->displayMonPalette, sPSSData->displayMonPalBuffer);
|
|
|
|
CpuCopy32(sPSSData->tileBuffer, sPSSData->displayMonTilePtr, MON_PIC_SIZE);
|
|
|
|
LoadPalette(sPSSData->displayMonPalBuffer, sPSSData->displayMonPalOffset, 0x20);
|
|
|
|
sPSSData->displayMonSprite->invisible = FALSE;
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->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-15 23:31:50 +02:00
|
|
|
if (sPSSData->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
AddTextPrinterParameterized(0, 1, sPSSData->displayMonNameText, 6, 0, TEXT_SPEED_FF, NULL);
|
|
|
|
AddTextPrinterParameterized(0, 2, sPSSData->displayMonSpeciesName, 6, 15, TEXT_SPEED_FF, NULL);
|
|
|
|
AddTextPrinterParameterized(0, 2, sPSSData->displayMonGenderLvlText, 10, 29, TEXT_SPEED_FF, NULL);
|
|
|
|
AddTextPrinterParameterized(0, 0, sPSSData->displayMonItemName, 6, 43, TEXT_SPEED_FF, NULL);
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
AddTextPrinterParameterized(0, 0, sPSSData->displayMonItemName, 6, 0, TEXT_SPEED_FF, NULL);
|
|
|
|
AddTextPrinterParameterized(0, 1, sPSSData->displayMonNameText, 6, 13, TEXT_SPEED_FF, NULL);
|
|
|
|
AddTextPrinterParameterized(0, 2, sPSSData->displayMonSpeciesName, 6, 28, TEXT_SPEED_FF, NULL);
|
|
|
|
AddTextPrinterParameterized(0, 2, sPSSData->displayMonGenderLvlText, 10, 42, TEXT_SPEED_FF, NULL);
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CopyWindowToVram(0, 2);
|
2021-04-16 05:27:05 +02:00
|
|
|
if (sPSSData->displayMonSpecies != SPECIES_NONE)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
UpdateMonMarkingTiles(sPSSData->displayMonMarkings, sPSSData->markingComboTilesPtr);
|
2021-04-16 01:17:53 +02:00
|
|
|
sPSSData->markingComboSprite->invisible = FALSE;
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
sPSSData->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-16 05:27:05 +02:00
|
|
|
if (sPSSData->displayMonSpecies != SPECIES_NONE)
|
2018-12-11 23:09:12 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
// Start animation
|
2018-12-11 23:09:12 +01:00
|
|
|
sub_80D27AC(0, 0, 0, 8, 2);
|
2021-04-16 01:17:53 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sPSSData->waveformSprites); i++)
|
|
|
|
StartSpriteAnimIfDifferent(sPSSData->waveformSprites[i], i * 2 + 1);
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
// Stop animation
|
2018-12-11 23:09:12 +01:00
|
|
|
sub_80D27AC(0, 0, 2, 8, 2);
|
2021-04-16 01:17:53 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sPSSData->waveformSprites); i++)
|
|
|
|
StartSpriteAnim(sPSSData->waveformSprites[i], i * 2);
|
2018-12-11 23:09:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub_80D2918(0);
|
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
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CA704(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
LZ77UnCompWram(gUnknown_08DD36C8, sPSSData->field_B0);
|
2018-12-12 23:19:50 +01:00
|
|
|
LoadPalette(gPSSMenu_Pal, 0x10, 0x20);
|
2018-12-20 22:14:36 +01:00
|
|
|
sub_80D2644(1, 1, sPSSData->field_B0, 12, 22);
|
2018-12-12 23:19:50 +01:00
|
|
|
sub_80D2644(2, 1, gUnknown_0857245C, 9, 4);
|
|
|
|
sub_80D2770(1, 10, 0);
|
|
|
|
sub_80D2770(2, 21, 0);
|
|
|
|
sub_80CAA74();
|
|
|
|
if (sInPartyMenu)
|
|
|
|
{
|
|
|
|
sub_80CA984(TRUE);
|
2018-12-15 23:58:47 +01:00
|
|
|
CreatePartyMonsSprites(TRUE);
|
2018-12-12 23:19:50 +01:00
|
|
|
sub_80D2918(2);
|
|
|
|
sub_80D2918(1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sub_80D27AC(1, 0, 20, 12, 2);
|
|
|
|
sub_80CA984(TRUE);
|
|
|
|
sub_80D2918(1);
|
|
|
|
sub_80D2918(2);
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->unk_02C7 = 0;
|
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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_2C0 = 20;
|
|
|
|
sPSSData->field_2C2 = 2;
|
|
|
|
sPSSData->field_2C5 = 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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->field_2C5 == 20)
|
2018-12-12 23:19:50 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_2C0--;
|
|
|
|
sPSSData->field_2C2++;
|
2018-12-12 23:19:50 +01:00
|
|
|
sub_80D27F4(1, 3, 1);
|
|
|
|
sub_80D2918(1);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2018-12-12 23:19:50 +01:00
|
|
|
sub_80CBAF0(8);
|
2018-12-20 22:14:36 +01:00
|
|
|
if (++sPSSData->field_2C5 == 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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_2C0 = 0;
|
|
|
|
sPSSData->field_2C2 = 22;
|
|
|
|
sPSSData->field_2C5 = 0;
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->boxOption == OPTION_MOVE_ITEMS)
|
2018-12-12 23:19:50 +01:00
|
|
|
sub_80D11CC();
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 HidePartyMenu(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->field_2C5 != 20)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_2C0++;
|
|
|
|
sPSSData->field_2C2--;
|
2018-12-12 23:19:50 +01:00
|
|
|
sub_80D27F4(1, 3, -1);
|
|
|
|
sub_80D2918(1);
|
2018-12-20 22:14:36 +01:00
|
|
|
FillBgTilemapBufferRect_Palette0(1, 0x100, 10, sPSSData->field_2C2, 12, 1);
|
2018-12-12 23:19:50 +01:00
|
|
|
sub_80CBAF0(-8);
|
2018-12-20 22:14:36 +01:00
|
|
|
if (++sPSSData->field_2C5 != 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();
|
|
|
|
sub_80D27AC(2, 0, 0, 9, 2);
|
|
|
|
sub_80D2918(2);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(1);
|
2018-12-12 23:19:50 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CA984(bool8 arg0)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
|
|
|
if (arg0)
|
|
|
|
sub_80D27AC(2, 0, 0, 9, 2);
|
|
|
|
else
|
|
|
|
sub_80D27AC(2, 0, 2, 9, 2);
|
|
|
|
|
|
|
|
sub_80D2918(2);
|
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 sub_80CA9C0(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->unk_02C7 = 1;
|
|
|
|
sPSSData->unk_02C8 = 30;
|
|
|
|
sPSSData->unk_02C9 = TRUE;
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CA9EC(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->unk_02C7)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->unk_02C7 = 0;
|
2018-12-12 23:19:50 +01:00
|
|
|
sub_80CA984(TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CAA14(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->unk_02C7 && ++sPSSData->unk_02C8 > 30)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->unk_02C8 = 0;
|
|
|
|
sPSSData->unk_02C9 = (sPSSData->unk_02C9 == FALSE);
|
|
|
|
sub_80CA984(sPSSData->unk_02C9);
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CAA74(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
|
|
|
for (i = 1; i < PARTY_SIZE; i++)
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
s32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES);
|
2018-12-12 23:19:50 +01:00
|
|
|
sub_80CAAA8(i, (species != SPECIES_NONE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CAAA8(u8 arg0, bool8 isPartyMon)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
|
|
|
u16 i, j, index;
|
|
|
|
const u16 *data;
|
|
|
|
|
|
|
|
if (isPartyMon)
|
|
|
|
data = gUnknown_085724A4;
|
|
|
|
else
|
|
|
|
data = gUnknown_085724BC;
|
|
|
|
|
|
|
|
index = 3 * (3 * (arg0 - 1) + 1);
|
|
|
|
index *= 4;
|
|
|
|
index += 7;
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < 4; j++)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_B0[index + j] = data[j];
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
data += 4;
|
|
|
|
index += 12;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CAB20(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
|
|
|
sub_80CAA74();
|
|
|
|
sub_80D27AC(1, 0, 0, 12, 22);
|
|
|
|
sub_80D2918(1);
|
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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->showPartyMenuState)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (!ShowPartyMenu())
|
|
|
|
{
|
|
|
|
sub_80CDBA0();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->setMosaic)
|
2021-04-16 05:27:05 +02:00
|
|
|
StartDisplayMonMosaicEffect();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->showPartyMenuState++;
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CABE0(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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CAC1C(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:
|
|
|
|
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sPSSData->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:
|
|
|
|
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sPSSData->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())
|
2018-12-20 22:14:36 +01:00
|
|
|
txtPtr = StringCopy(sPSSData->itemName, GetMovingItemName());
|
2018-12-12 23:19:50 +01:00
|
|
|
else
|
2021-04-16 05:27:05 +02:00
|
|
|
txtPtr = StringCopy(sPSSData->itemName, sPSSData->displayMonItemName);
|
2018-12-12 23:19:50 +01:00
|
|
|
|
|
|
|
while (*(txtPtr - 1) == CHAR_SPACE)
|
|
|
|
txtPtr--;
|
|
|
|
|
|
|
|
*txtPtr = EOS;
|
2018-12-20 22:14:36 +01:00
|
|
|
DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sPSSData->itemName);
|
2018-12-12 23:19:50 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-04-15 19:31:18 +02:00
|
|
|
DynamicPlaceholderTextUtil_ExpandPlaceholders(sPSSData->field_2190, sMessages[id].text);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(1, PIXEL_FILL(1));
|
2018-12-20 22:14:36 +01:00
|
|
|
AddTextPrinterParameterized(1, 1, sPSSData->field_2190, 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;
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CAEAC(void)
|
2018-12-12 23:19:50 +01:00
|
|
|
{
|
|
|
|
if (!IsCursorOnBox())
|
|
|
|
{
|
|
|
|
if (sInPartyMenu)
|
2021-04-16 23:05:44 +02:00
|
|
|
sub_80D0D8C(CURSOR_AREA_IN_PARTY, GetCursorPosition());
|
2018-12-12 23:19:50 +01:00
|
|
|
else
|
2021-04-16 23:05:44 +02:00
|
|
|
sub_80D0D8C(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
|
|
|
{
|
2020-03-08 02:45:04 +01:00
|
|
|
sub_80D0F38(sMovingItemId);
|
2021-04-16 05:27:05 +02:00
|
|
|
StartCursorAnim(CURSOR_ANIM_FIST);
|
2018-12-12 23:19:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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++)
|
|
|
|
sPSSData->numIconsPerSpecies[i] = 0;
|
|
|
|
for (i = 0; i < MAX_MON_ICONS; i++)
|
|
|
|
sPSSData->iconSpeciesList[i] = SPECIES_NONE;
|
2018-12-12 23:19:50 +01:00
|
|
|
for (i = 0; i < PARTY_SIZE; i++)
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->partySprites[i] = NULL;
|
2018-12-12 23:19:50 +01:00
|
|
|
for (i = 0; i < IN_BOX_COUNT; i++)
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->boxMonsSprites[i] = NULL;
|
2018-12-12 23:19:50 +01:00
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->movingMonSprite = NULL;
|
|
|
|
sPSSData->field_78C = 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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
u32 personality = GetMonData(&sPSSData->movingMon, MON_DATA_PERSONALITY);
|
|
|
|
u16 species = GetMonData(&sPSSData->movingMon, MON_DATA_SPECIES2);
|
2021-04-16 05:27:05 +02:00
|
|
|
u8 priority = GetMonIconPriorityByCursorPos();
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->movingMonSprite = CreateMonIconSprite(species, personality, 0, 0, priority, 7);
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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-15 23:31:50 +02:00
|
|
|
if (sPSSData->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)
|
2019-12-05 03:00:45 +01:00
|
|
|
sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void sub_80CB140(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-16 11:14:35 +02:00
|
|
|
sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(species, personality, x, y, 2, 19 - (boxPosition % IN_BOX_COLUMNS));
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->boxOption == OPTION_MOVE_ITEMS)
|
2019-12-05 03:00:45 +01:00
|
|
|
sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CB1F0(s16 arg0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
for (i = 0; i < IN_BOX_COUNT; i++)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->boxMonsSprites[i] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->boxMonsSprites[i]->data[2] = arg0;
|
|
|
|
sPSSData->boxMonsSprites[i]->data[4] = 1;
|
|
|
|
sPSSData->boxMonsSprites[i]->callback = sub_80CB278;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CB234(struct Sprite *sprite)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (sprite->data[1] != 0)
|
|
|
|
{
|
|
|
|
sprite->data[1]--;
|
|
|
|
sprite->pos1.x += sprite->data[2];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_C66--;
|
2018-12-15 23:58:47 +01:00
|
|
|
sprite->pos1.x = sprite->data[3];
|
|
|
|
sprite->callback = SpriteCallbackDummy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CB278(struct Sprite *sprite)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (sprite->data[4] != 0)
|
|
|
|
{
|
|
|
|
sprite->data[4]--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprite->pos1.x += sprite->data[2];
|
|
|
|
sprite->data[5] = sprite->pos1.x + sprite->pos2.x;
|
|
|
|
if (sprite->data[5] <= 68 || sprite->data[5] >= 252)
|
|
|
|
sprite->callback = SpriteCallbackDummy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-16 11:14:35 +02:00
|
|
|
static void DestroyAllIconsInColumn(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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->boxMonsSprites[boxPosition] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
DestroyBoxMonIcon(sPSSData->boxMonsSprites[boxPosition]);
|
|
|
|
sPSSData->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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static u8 sub_80CB2F8(u8 row, u16 times, s16 xDelta)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
u16 y = 44;
|
|
|
|
s16 xDest = 8 * (3 * row) + 100;
|
|
|
|
u16 x = xDest - ((times + 1) * xDelta);
|
|
|
|
u8 subpriority = 19 - row;
|
|
|
|
u8 count = 0;
|
|
|
|
u8 boxPosition = row;
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(sPSSData->boxSpecies[boxPosition],
|
|
|
|
sPSSData->boxPersonalities[boxPosition],
|
2018-12-15 23:58:47 +01:00
|
|
|
x, y, 2, subpriority);
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->boxMonsSprites[boxPosition] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->boxMonsSprites[boxPosition]->data[1] = times;
|
|
|
|
sPSSData->boxMonsSprites[boxPosition]->data[2] = xDelta;
|
|
|
|
sPSSData->boxMonsSprites[boxPosition]->data[3] = xDest;
|
|
|
|
sPSSData->boxMonsSprites[boxPosition]->callback = sub_80CB234;
|
2018-12-15 23:58:47 +01:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
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-16 11:14:35 +02:00
|
|
|
for (i = 0; i < IN_BOX_ROWS; i++)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->boxMonsSprites[boxPosition] = CreateMonIconSprite(sPSSData->boxSpecies[boxPosition],
|
|
|
|
sPSSData->boxPersonalities[boxPosition],
|
2018-12-15 23:58:47 +01:00
|
|
|
x, y, 2, subpriority);
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->boxMonsSprites[boxPosition] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->boxMonsSprites[boxPosition]->data[1] = times;
|
|
|
|
sPSSData->boxMonsSprites[boxPosition]->data[2] = xDelta;
|
|
|
|
sPSSData->boxMonsSprites[boxPosition]->data[3] = xDest;
|
|
|
|
sPSSData->boxMonsSprites[boxPosition]->callback = sub_80CB234;
|
|
|
|
if (GetBoxMonDataAt(sPSSData->field_C5C, boxPosition, MON_DATA_HELD_ITEM) == 0)
|
2019-12-05 03:00:45 +01:00
|
|
|
sPSSData->boxMonsSprites[boxPosition]->oam.objMode = ST_OAM_OBJ_BLEND;
|
2018-12-15 23:58:47 +01:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
2021-04-16 11:14:35 +02:00
|
|
|
boxPosition += IN_BOX_COLUMNS;
|
2018-12-15 23:58:47 +01:00
|
|
|
y += 24;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CB4CC(u8 boxId, s8 direction)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_C6A = 0;
|
|
|
|
sPSSData->field_C6B = boxId;
|
|
|
|
sPSSData->field_C69 = direction;
|
|
|
|
sPSSData->field_C60 = 32;
|
|
|
|
sPSSData->field_C64 = -(6 * direction);
|
|
|
|
sPSSData->field_C66 = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
SetBoxSpeciesAndPersonalities(boxId);
|
|
|
|
if (direction > 0)
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_C68 = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-16 11:14:35 +02:00
|
|
|
sPSSData->field_C68 = IN_BOX_COLUMNS - 1;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_C62 = (24 * sPSSData->field_C68) + 100;
|
|
|
|
sub_80CB1F0(sPSSData->field_C64);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 sub_80CB584(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->field_C60 != 0)
|
|
|
|
sPSSData->field_C60--;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->field_C6A)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_C62 += sPSSData->field_C64;
|
|
|
|
if (sPSSData->field_C62 <= 64 || sPSSData->field_C62 >= 252)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 11:14:35 +02:00
|
|
|
DestroyAllIconsInColumn(sPSSData->field_C68);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_C62 += sPSSData->field_C69 * 24;
|
|
|
|
sPSSData->field_C6A++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_C62 += sPSSData->field_C64;
|
|
|
|
sPSSData->field_C66 += sub_80CB2F8(sPSSData->field_C68, sPSSData->field_C60, sPSSData->field_C64);
|
2021-04-16 11:14:35 +02:00
|
|
|
if ((sPSSData->field_C69 > 0 && sPSSData->field_C68 == IN_BOX_COLUMNS - 1)
|
2018-12-20 22:14:36 +01:00
|
|
|
|| (sPSSData->field_C69 < 0 && sPSSData->field_C68 == 0))
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_C6A++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_C68 += sPSSData->field_C69;
|
|
|
|
sPSSData->field_C6A = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->field_C66 == 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_C60++;
|
2018-12-15 23:58:47 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void SetBoxSpeciesAndPersonalities(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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->boxSpecies[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2);
|
|
|
|
if (sPSSData->boxSpecies[boxPosition] != SPECIES_NONE)
|
|
|
|
sPSSData->boxPersonalities[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY);
|
2018-12-15 23:58:47 +01:00
|
|
|
boxPosition++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_C5C = 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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->boxMonsSprites[boxPosition] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
DestroyBoxMonIcon(sPSSData->boxMonsSprites[boxPosition]);
|
|
|
|
sPSSData->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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->boxMonsSprites[boxPosition] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->boxMonsSprites[boxPosition]->oam.objMode = objMode;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void CreatePartyMonsSprites(bool8 arg0)
|
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);
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->partySprites[i] = CreateMonIconSprite(species, personality, 152, 8 * (3 * (i - 1)) + 16, 1, 12);
|
2018-12-15 23:58:47 +01:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->partySprites[i] = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!arg0)
|
|
|
|
{
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->partySprites[i]->pos1.y -= 160;
|
|
|
|
sPSSData->partySprites[i]->invisible = TRUE;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->boxOption == OPTION_MOVE_ITEMS)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
for (i = 0; i < PARTY_SIZE; i++)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->partySprites[i] != NULL && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == 0)
|
2019-12-05 03:00:45 +01:00
|
|
|
sPSSData->partySprites[i]->oam.objMode = ST_OAM_OBJ_BLEND;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CB950(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u16 i, count;
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_C5E = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
for (i = 0, count = 0; i < PARTY_SIZE; i++)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->partySprites[i] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (i != count)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sub_80CB9D0(sPSSData->partySprites[i], count);
|
|
|
|
sPSSData->partySprites[i] = NULL;
|
|
|
|
sPSSData->field_C5E++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static u8 sub_80CB9BC(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
return sPSSData->field_C5E;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CB9D0(struct Sprite *sprite, u16 partyId)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
s16 x, y;
|
|
|
|
|
|
|
|
sprite->data[1] = partyId;
|
|
|
|
if (partyId == 0)
|
|
|
|
x = 104, y = 64;
|
|
|
|
else
|
|
|
|
x = 152, y = 8 * (3 * (partyId - 1)) + 16;
|
|
|
|
|
|
|
|
sprite->data[2] = (u16)(sprite->pos1.x) * 8;
|
|
|
|
sprite->data[3] = (u16)(sprite->pos1.y) * 8;
|
|
|
|
sprite->data[4] = ((x * 8) - sprite->data[2]) / 8;
|
|
|
|
sprite->data[5] = ((y * 8) - sprite->data[3]) / 8;
|
|
|
|
sprite->data[6] = 8;
|
|
|
|
sprite->callback = sub_80CBA3C;
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CBA3C(struct Sprite *sprite)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (sprite->data[6] != 0)
|
|
|
|
{
|
|
|
|
s16 x = sprite->data[2] += sprite->data[4];
|
|
|
|
s16 y = sprite->data[3] += sprite->data[5];
|
|
|
|
sprite->pos1.x = x / 8u;
|
|
|
|
sprite->pos1.y = y / 8u;
|
|
|
|
sprite->data[6]--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sprite->data[1] == 0)
|
|
|
|
{
|
|
|
|
sprite->pos1.x = 104;
|
|
|
|
sprite->pos1.y = 64;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprite->pos1.x = 152;
|
|
|
|
sprite->pos1.y = 8 * (3 * (sprite->data[1] - 1)) + 16;
|
|
|
|
}
|
|
|
|
sprite->callback = SpriteCallbackDummy;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->partySprites[sprite->data[1]] = sprite;
|
|
|
|
sPSSData->field_C5E--;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void DestroyMovingMonIcon(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->movingMonSprite != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
DestroyBoxMonIcon(sPSSData->movingMonSprite);
|
|
|
|
sPSSData->movingMonSprite = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CBAF0(s16 yDelta)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
u16 i, posY;
|
|
|
|
|
|
|
|
for (i = 0; i < PARTY_SIZE; i++)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->partySprites[i] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->partySprites[i]->pos1.y += yDelta;
|
|
|
|
posY = sPSSData->partySprites[i]->pos1.y + sPSSData->partySprites[i]->pos2.y + sPSSData->partySprites[i]->centerToCornerVecY;
|
2018-12-15 23:58:47 +01:00
|
|
|
posY += 16;
|
|
|
|
if (posY > 192)
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->partySprites[i]->invisible = TRUE;
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->partySprites[partyId] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
DestroyBoxMonIcon(sPSSData->partySprites[partyId]);
|
|
|
|
sPSSData->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++)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->partySprites[i] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
DestroyBoxMonIcon(sPSSData->partySprites[i]);
|
|
|
|
sPSSData->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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->partySprites[partyId] != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->partySprites[partyId]->oam.objMode = objMode;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CBC14(u8 mode, u8 id)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (mode == MODE_PARTY)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->movingMonSprite = sPSSData->partySprites[id];
|
|
|
|
sPSSData->partySprites[id] = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else if (mode == MODE_BOX)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->movingMonSprite = sPSSData->boxMonsSprites[id];
|
|
|
|
sPSSData->boxMonsSprites[id] = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->movingMonSprite->callback = SpriteCB_HeldMon;
|
|
|
|
sPSSData->movingMonSprite->oam.priority = GetMonIconPriorityByCursorPos();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->movingMonSprite->subpriority = 7;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CBCAC(u8 boxId, u8 position)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (boxId == TOTAL_BOXES_COUNT) // party mon
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->partySprites[position] = sPSSData->movingMonSprite;
|
|
|
|
sPSSData->partySprites[position]->oam.priority = 1;
|
|
|
|
sPSSData->partySprites[position]->subpriority = 12;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->boxMonsSprites[position] = sPSSData->movingMonSprite;
|
|
|
|
sPSSData->boxMonsSprites[position]->oam.priority = 2;
|
2021-04-16 11:14:35 +02:00
|
|
|
sPSSData->boxMonsSprites[position]->subpriority = 19 - (position % IN_BOX_COLUMNS);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->movingMonSprite->callback = SpriteCallbackDummy;
|
|
|
|
sPSSData->movingMonSprite = NULL;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CBD5C(u8 boxId, u8 position)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (boxId == TOTAL_BOXES_COUNT) // party mon
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_B00 = &sPSSData->partySprites[position];
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_B00 = &sPSSData->boxMonsSprites[position];
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->movingMonSprite->callback = SpriteCallbackDummy;
|
|
|
|
sPSSData->field_C5D = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 sub_80CBDC4(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->field_C5D == 16)
|
2018-12-15 23:58:47 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_C5D++;
|
|
|
|
if (sPSSData->field_C5D & 1)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
(*sPSSData->field_B00)->pos1.y--;
|
|
|
|
sPSSData->movingMonSprite->pos1.y++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
(*sPSSData->field_B00)->pos2.x = gSineTable[sPSSData->field_C5D * 8] / 16;
|
|
|
|
sPSSData->movingMonSprite->pos2.x = -(gSineTable[sPSSData->field_C5D * 8] / 16);
|
|
|
|
if (sPSSData->field_C5D == 8)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->movingMonSprite->oam.priority = (*sPSSData->field_B00)->oam.priority;
|
|
|
|
sPSSData->movingMonSprite->subpriority = (*sPSSData->field_B00)->subpriority;
|
2021-04-16 05:27:05 +02:00
|
|
|
(*sPSSData->field_B00)->oam.priority = GetMonIconPriorityByCursorPos();
|
2018-12-20 22:14:36 +01:00
|
|
|
(*sPSSData->field_B00)->subpriority = 7;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->field_C5D == 16)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
struct Sprite *sprite = sPSSData->movingMonSprite;
|
|
|
|
sPSSData->movingMonSprite = (*sPSSData->field_B00);
|
|
|
|
*sPSSData->field_B00 = sprite;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->movingMonSprite->callback = SpriteCB_HeldMon;
|
2018-12-20 22:14:36 +01:00
|
|
|
(*sPSSData->field_B00)->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-16 05:27:05 +02:00
|
|
|
sPSSData->releaseMonSpritePtr = &sPSSData->partySprites[position];
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case MODE_BOX:
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->releaseMonSpritePtr = &sPSSData->boxMonsSprites[position];
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
2020-03-09 02:27:29 +01:00
|
|
|
case MODE_MOVE:
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->releaseMonSpritePtr = &sPSSData->movingMonSprite;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
if (*sPSSData->releaseMonSpritePtr != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
InitSpriteAffineAnim(*sPSSData->releaseMonSpritePtr);
|
|
|
|
(*sPSSData->releaseMonSpritePtr)->oam.affineMode = ST_OAM_AFFINE_NORMAL;
|
|
|
|
(*sPSSData->releaseMonSpritePtr)->affineAnims = sAffineAnims_ReleaseMon;
|
|
|
|
StartSpriteAffineAnim(*sPSSData->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-16 05:27:05 +02:00
|
|
|
if (*sPSSData->releaseMonSpritePtr == NULL
|
|
|
|
|| (*sPSSData->releaseMonSpritePtr)->invisible)
|
2018-12-15 23:58:47 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
if ((*sPSSData->releaseMonSpritePtr)->affineAnimEnded)
|
|
|
|
(*sPSSData->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-16 05:27:05 +02:00
|
|
|
if (*sPSSData->releaseMonSpritePtr != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
FreeOamMatrix((*sPSSData->releaseMonSpritePtr)->oam.matrixNum);
|
|
|
|
DestroyBoxMonIcon(*sPSSData->releaseMonSpritePtr);
|
|
|
|
*sPSSData->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-16 05:27:05 +02:00
|
|
|
if (*sPSSData->releaseMonSpritePtr != NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
(*sPSSData->releaseMonSpritePtr)->invisible = FALSE;
|
|
|
|
StartSpriteAffineAnim(*sPSSData->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-16 05:27:05 +02:00
|
|
|
if (sPSSData->releaseMonSpritePtr == NULL)
|
2018-12-15 23:58:47 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
if ((*sPSSData->releaseMonSpritePtr)->affineAnimEnded)
|
|
|
|
sPSSData->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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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-04-16 05:27:05 +02:00
|
|
|
sprite->pos1.x = sPSSData->cursorSprite->pos1.x;
|
|
|
|
sprite->pos1.y = sPSSData->cursorSprite->pos1.y + sPSSData->cursorSprite->pos2.y + 4;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static u16 TryLoadMonIconTiles(u16 species)
|
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-16 05:27:05 +02:00
|
|
|
if (sPSSData->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-16 05:27:05 +02:00
|
|
|
if (sPSSData->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
|
|
|
|
sPSSData->iconSpeciesList[i] = species;
|
|
|
|
sPSSData->numIconsPerSpecies[i]++;
|
|
|
|
offset = 16 * i;
|
|
|
|
CpuCopy32(GetMonIconTiles(species, TRUE), (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-16 05:27:05 +02:00
|
|
|
if (sPSSData->iconSpeciesList[i] == species)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
if (--sPSSData->numIconsPerSpecies[i] == 0)
|
|
|
|
sPSSData->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-16 05:27:05 +02:00
|
|
|
tileNum = TryLoadMonIconTiles(species);
|
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-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-15 20:06:25 +02:00
|
|
|
sPSSData->wallpaperOffset = 0;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->bg2_X = 0;
|
2021-04-15 20:06:25 +02:00
|
|
|
task->tDmaIdx = RequestDma3Fill(0, sPSSData->wallpaperBgTilemapBuffer, sizeof(sPSSData->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-15 20:06:25 +02:00
|
|
|
SetBgTilemapBuffer(2, sPSSData->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-15 23:31:50 +02:00
|
|
|
sPSSData->scrollSpeed = (direction > 0) ? 6 : -6;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_2D3 = (direction > 0) ? 1 : 2;
|
|
|
|
sPSSData->field_2D0 = 32;
|
2021-04-15 20:06:25 +02:00
|
|
|
sPSSData->scrollToBoxIdUnused = boxId;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_2D6 = (direction <= 0) ? 5 : 0;
|
2021-04-15 20:06:25 +02:00
|
|
|
sPSSData->scrollDirectionUnused = direction;
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_2DA = (direction > 0) ? 264 : 56;
|
|
|
|
sPSSData->field_2DC = (direction <= 0) ? 5 : 0;
|
|
|
|
sPSSData->field_2DE = 0;
|
|
|
|
sPSSData->field_2E0 = 2;
|
2021-04-15 20:06:25 +02:00
|
|
|
sPSSData->scrollToBoxId = boxId;
|
|
|
|
sPSSData->scrollDirection = direction;
|
|
|
|
sPSSData->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
|
|
|
{
|
|
|
|
bool8 var;
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
switch (sPSSData->scrollState)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-15 20:06:25 +02:00
|
|
|
LoadWallpaperGfx(sPSSData->scrollToBoxId, sPSSData->scrollDirection);
|
|
|
|
sPSSData->scrollState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
case 1:
|
|
|
|
if (!WaitForWallpaperGfxLoad())
|
|
|
|
return TRUE;
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
sub_80CB4CC(sPSSData->scrollToBoxId, sPSSData->scrollDirection);
|
|
|
|
CreateIncomingBoxTitle(sPSSData->scrollToBoxId, sPSSData->scrollDirection);
|
|
|
|
StartBoxScrollArrowsSlide(sPSSData->scrollDirection);
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
var = sub_80CB584();
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->field_2D0 != 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
sPSSData->bg2_X += sPSSData->scrollSpeed;
|
2018-12-20 22:14:36 +01:00
|
|
|
if (--sPSSData->field_2D0 != 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
|
|
|
}
|
|
|
|
return var;
|
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
sPSSData->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;
|
|
|
|
}
|
|
|
|
|
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);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->wallpaperChangeState)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2021-04-15 20:06:25 +02:00
|
|
|
BeginNormalPaletteFade(sPSSData->boxTitlePalBits, 1, 0, 16, RGB_WHITEALPHA);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->wallpaperChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!UpdatePaletteFade())
|
|
|
|
{
|
|
|
|
u8 curBox = StorageGetCurrentBox();
|
|
|
|
LoadWallpaperGfx(curBox, 0);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->wallpaperChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (WaitForWallpaperGfxLoad() == TRUE)
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
CycleBoxTitleColor();
|
|
|
|
BeginNormalPaletteFade(sPSSData->boxTitlePalBits, 1, 16, 0, RGB_WHITEALPHA);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->wallpaperChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!UpdatePaletteFade())
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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-15 20:06:25 +02:00
|
|
|
sPSSData->wallpaperLoadState = 0;
|
|
|
|
sPSSData->wallpaperLoadBoxId = boxId;
|
|
|
|
sPSSData->wallpaperLoadDir = direction;
|
|
|
|
if (sPSSData->wallpaperLoadDir != 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
sPSSData->wallpaperOffset = (sPSSData->wallpaperOffset == 0);
|
|
|
|
TrimOldWallpaper(sPSSData->wallpaperBgTilemapBuffer);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
wallpaperId = GetBoxWallpaper(sPSSData->wallpaperLoadBoxId);
|
2018-12-15 23:58:47 +01:00
|
|
|
if (wallpaperId != WALLPAPER_FRIENDS)
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
wallpaper = &sWallpapers[wallpaperId];
|
|
|
|
LZ77UnCompWram(wallpaper->tilemap, sPSSData->wallpaperTilemap);
|
|
|
|
DrawWallpaper(sPSSData->wallpaperTilemap, sPSSData->wallpaperLoadDir, sPSSData->wallpaperOffset);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
if (sPSSData->wallpaperLoadDir != 0)
|
|
|
|
LoadPalette(wallpaper->palettes, (sPSSData->wallpaperOffset * 32) + 0x40, 0x40);
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-15 20:06:25 +02:00
|
|
|
CpuCopy16(wallpaper->palettes, &gPlttBufferUnfaded[(sPSSData->wallpaperOffset * 32) + 0x40], 0x40);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
sPSSData->wallpaperTiles = malloc_and_decompress(wallpaper->tiles, &tilesSize);
|
|
|
|
LoadBgTiles(2, sPSSData->wallpaperTiles, tilesSize, sPSSData->wallpaperOffset << 8);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
wallpaper = &sWaldaWallpapers[GetWaldaWallpaperPatternId()];
|
|
|
|
LZ77UnCompWram(wallpaper->tilemap, sPSSData->wallpaperTilemap);
|
|
|
|
DrawWallpaper(sPSSData->wallpaperTilemap, sPSSData->wallpaperLoadDir, sPSSData->wallpaperOffset);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
CpuCopy16(wallpaper->palettes, sPSSData->wallpaperTilemap, 0x40);
|
|
|
|
CpuCopy16(GetWaldaWallpaperColorsPtr(), &sPSSData->wallpaperTilemap[1], 4);
|
|
|
|
CpuCopy16(GetWaldaWallpaperColorsPtr(), &sPSSData->wallpaperTilemap[17], 4);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
if (sPSSData->wallpaperLoadDir != 0)
|
|
|
|
LoadPalette(sPSSData->wallpaperTilemap, (sPSSData->wallpaperOffset * 32) + 0x40, 0x40);
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-15 20:06:25 +02:00
|
|
|
CpuCopy16(sPSSData->wallpaperTilemap, &gPlttBufferUnfaded[(sPSSData->wallpaperOffset * 32) + 0x40], 0x40);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
sPSSData->wallpaperTiles = malloc_and_decompress(wallpaper->tiles, &tilesSize);
|
|
|
|
iconGfx = malloc_and_decompress(sWaldaWallpaperIcons[GetWaldaWallpaperIconId()], &iconSize);
|
|
|
|
CpuCopy32(iconGfx, sPSSData->wallpaperTiles + 0x800, iconSize);
|
2018-12-15 23:58:47 +01:00
|
|
|
Free(iconGfx);
|
2021-04-15 20:06:25 +02:00
|
|
|
LoadBgTiles(2, sPSSData->wallpaperTiles, tilesSize, sPSSData->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;
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->wallpaperTiles != NULL)
|
2021-04-15 23:31:50 +02:00
|
|
|
FREE_AND_SET_NULL(sPSSData->wallpaperTiles);
|
|
|
|
|
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-04-15 20:06:25 +02:00
|
|
|
s16 var = (offset * 2) + 3;
|
2018-12-20 22:14:36 +01:00
|
|
|
s16 x = ((sPSSData->bg2_X / 8 + 10) + (direction * 24)) & 0x3F;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 0x14, 0x12, x, 2, 0x14, 0x12, 0x11, offset << 8, var);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
|
|
|
if (direction == 0)
|
|
|
|
return;
|
2020-11-03 02:02:39 +01:00
|
|
|
if (direction > 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
x *= 1, x += 0x14; // x * 1 is needed to match, but can be safely removed as it makes no functional difference
|
|
|
|
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;
|
2018-12-20 22:14:36 +01:00
|
|
|
s16 r3 = ((sPSSData->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-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-15 20:06:25 +02:00
|
|
|
struct SpriteSheet spriteSheet = {sPSSData->boxTitleTiles, 0x200, GFXTAG_BOX_TITLE};
|
2018-12-15 23:58:47 +01:00
|
|
|
struct SpritePalette palettes[] = {
|
2021-04-15 20:06:25 +02:00
|
|
|
{sPSSData->boxTitlePal, PALTAG_BOX_TITLE},
|
2018-12-15 23:58:47 +01:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
u16 wallpaperId = GetBoxWallpaper(boxId);
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
sPSSData->boxTitlePal[14] = sBoxTitleColors[wallpaperId][0]; // Shadow color
|
|
|
|
sPSSData->boxTitlePal[15] = sBoxTitleColors[wallpaperId][1]; // Text Color
|
2018-12-15 23:58:47 +01:00
|
|
|
LoadSpritePalettes(palettes);
|
2021-04-15 20:06:25 +02:00
|
|
|
sPSSData->boxTitlePalBits = 0x3f0;
|
|
|
|
|
|
|
|
tagIndex = IndexOfSpritePaletteTag(PALTAG_BOX_TITLE);
|
|
|
|
sPSSData->boxTitlePalOffset = 0x10e + 16 * tagIndex;
|
|
|
|
sPSSData->boxTitlePalBits |= 0x10000 << tagIndex;
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
sPSSData->boxTitleAltPalOffset = 0x10e + 16 * tagIndex;
|
|
|
|
sPSSData->boxTitlePalBits |= 0x10000 << tagIndex;
|
|
|
|
|
|
|
|
StringCopyPadded(sPSSData->boxTitleText, GetBoxNamePtr(boxId), 0, 8);
|
|
|
|
DrawTextWindowAndBufferTiles(sPSSData->boxTitleText, sPSSData->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);
|
|
|
|
sPSSData->curBoxTitleSprites[i] = &gSprites[spriteId];
|
|
|
|
StartSpriteAnim(sPSSData->curBoxTitleSprites[i], i);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-15 20:06:25 +02:00
|
|
|
sPSSData->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-15 20:06:25 +02:00
|
|
|
struct SpriteSheet spriteSheet = {sPSSData->boxTitleTiles, 0x200, GFXTAG_BOX_TITLE};
|
|
|
|
struct SpriteTemplate template = sSpriteTemplate_BoxTitle;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
sPSSData->boxTitleCycleId = (sPSSData->boxTitleCycleId == 0);
|
|
|
|
if (sPSSData->boxTitleCycleId == 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
spriteSheet.tag = GFXTAG_BOX_TITLE;
|
|
|
|
palOffset = sPSSData->boxTitlePalOffset;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
spriteSheet.tag = GFXTAG_BOX_TITLE_ALT;
|
|
|
|
palOffset = sPSSData->boxTitlePalOffset;
|
|
|
|
template.tileTag = GFXTAG_BOX_TITLE_ALT;
|
|
|
|
template.paletteTag = PALTAG_BOX_TITLE;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
StringCopyPadded(sPSSData->boxTitleText, GetBoxNamePtr(boxId), 0, 8);
|
|
|
|
DrawTextWindowAndBufferTiles(sPSSData->boxTitleText, sPSSData->boxTitleTiles, 0, 0, 2);
|
2018-12-15 23:58:47 +01:00
|
|
|
LoadSpriteSheet(&spriteSheet);
|
2021-04-15 20:06:25 +02:00
|
|
|
LoadPalette(sBoxTitleColors[GetBoxWallpaper(boxId)], palOffset, 4);
|
|
|
|
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-15 20:06:25 +02:00
|
|
|
sPSSData->nextBoxTitleSprites[i] = &gSprites[spriteId];
|
|
|
|
sPSSData->nextBoxTitleSprites[i]->sSpeed = (-direction) * 6;
|
|
|
|
sPSSData->nextBoxTitleSprites[i]->sIncomingX = i * 32 + x;
|
|
|
|
sPSSData->nextBoxTitleSprites[i]->sIncomingDelay = 0;
|
|
|
|
sPSSData->nextBoxTitleSprites[i]->callback = SpriteCB_IncomingBoxTitle;
|
|
|
|
StartSpriteAnim(sPSSData->nextBoxTitleSprites[i], i);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-15 20:06:25 +02:00
|
|
|
sPSSData->curBoxTitleSprites[i]->sSpeed = (-direction) * 6;
|
|
|
|
sPSSData->curBoxTitleSprites[i]->sOutgoingDelay = 1;
|
|
|
|
sPSSData->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-15 20:06:25 +02:00
|
|
|
if (sPSSData->boxTitleCycleId == 0)
|
|
|
|
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-15 20:06:25 +02:00
|
|
|
sPSSData->curBoxTitleSprites[0] = sPSSData->nextBoxTitleSprites[0];
|
|
|
|
sPSSData->curBoxTitleSprites[1] = sPSSData->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--;
|
|
|
|
else if ((sprite->pos1.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-04-15 20:06:25 +02:00
|
|
|
sprite->pos1.x += sprite->sSpeed;
|
|
|
|
sprite->sOutgoingX = sprite->pos1.x + sprite->pos2.x;
|
|
|
|
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-15 20:06:25 +02:00
|
|
|
if (sPSSData->boxTitleCycleId == 0)
|
|
|
|
CpuCopy16(sBoxTitleColors[wallpaperId], gPlttBufferUnfaded + sPSSData->boxTitlePalOffset, 4);
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-15 20:06:25 +02:00
|
|
|
CpuCopy16(sBoxTitleColors[wallpaperId], gPlttBufferUnfaded + sPSSData->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-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;
|
|
|
|
sPSSData->arrowSprites[i] = sprite;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (IsCursorOnBox())
|
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-04-15 20:06:25 +02:00
|
|
|
sPSSData->arrowSprites[i]->pos2.x = 0;
|
|
|
|
sPSSData->arrowSprites[i]->sState = 2;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
if (direction < 0)
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
sPSSData->arrowSprites[0]->sTimer = 29;
|
|
|
|
sPSSData->arrowSprites[1]->sTimer = 5;
|
|
|
|
sPSSData->arrowSprites[0]->data[2] = 72;
|
|
|
|
sPSSData->arrowSprites[1]->data[2] = 72;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-15 20:06:25 +02:00
|
|
|
sPSSData->arrowSprites[0]->sTimer = 5;
|
|
|
|
sPSSData->arrowSprites[1]->sTimer = 29;
|
|
|
|
sPSSData->arrowSprites[0]->data[2] = DISPLAY_WIDTH + 8;
|
|
|
|
sPSSData->arrowSprites[1]->data[2] = DISPLAY_WIDTH + 8;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-15 20:06:25 +02:00
|
|
|
sPSSData->arrowSprites[0]->data[7] = 0;
|
|
|
|
sPSSData->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-04-15 20:06:25 +02:00
|
|
|
sPSSData->arrowSprites[i]->pos1.x = 136 * i + 92;
|
|
|
|
sPSSData->arrowSprites[i]->pos2.x = 0;
|
|
|
|
sPSSData->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-15 20:06:25 +02:00
|
|
|
sPSSData->arrowSprites[i]->sState = 1;
|
|
|
|
sPSSData->arrowSprites[i]->sTimer = 0;
|
|
|
|
sPSSData->arrowSprites[i]->data[2] = 0;
|
|
|
|
sPSSData->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-15 20:06:25 +02:00
|
|
|
sPSSData->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:
|
|
|
|
sprite->pos2.x = 0;
|
|
|
|
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;
|
|
|
|
sprite->pos2.x += sprite->sSpeed;
|
2018-12-15 23:58:47 +01:00
|
|
|
if (++sprite->data[2] > 5)
|
|
|
|
{
|
|
|
|
sprite->data[2] = 0;
|
|
|
|
sprite->pos2.x = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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-04-15 23:31:50 +02:00
|
|
|
sprite->pos1.x -= sPSSData->scrollSpeed;
|
2021-04-15 20:06:25 +02:00
|
|
|
if (sprite->pos1.x <= 72 || sprite->pos1.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
|
|
|
{
|
|
|
|
sprite->pos1.x = sprite->data[2];
|
|
|
|
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-04-15 23:31:50 +02:00
|
|
|
sprite->pos1.x -= sPSSData->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];
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CD36C(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->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;
|
2018-12-15 23:58:47 +01:00
|
|
|
sub_80CDC0C();
|
|
|
|
sub_80CFC14();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CD6 = 1;
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->inBoxMovingMode = MOVE_MODE_NORMAL;
|
2018-12-15 23:58:47 +01:00
|
|
|
sub_80CEB40();
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CD3EC(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
sub_80CFC14();
|
|
|
|
sub_80CEBDC();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CD6 = 1;
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->inBoxMovingMode = MOVE_MODE_NORMAL;
|
2018-12-15 23:58:47 +01:00
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->movingMon = gUnknown_02039D14;
|
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;
|
2018-12-16 21:10:01 +01:00
|
|
|
case CURSOR_AREA_BOX:
|
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-16 23:05:44 +02:00
|
|
|
if (sPSSData->cursorMoveSteps == 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->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-16 23:05:44 +02:00
|
|
|
else if (--sPSSData->cursorMoveSteps != 0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CBC += sPSSData->field_CC4;
|
|
|
|
sPSSData->field_CC0 += sPSSData->field_CC8;
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->cursorSprite->pos1.x = sPSSData->field_CBC >> 8;
|
|
|
|
sPSSData->cursorSprite->pos1.y = sPSSData->field_CC0 >> 8;
|
|
|
|
if (sPSSData->cursorSprite->pos1.x > DISPLAY_WIDTH + 16)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
tmp = sPSSData->cursorSprite->pos1.x - (DISPLAY_WIDTH + 16);
|
|
|
|
sPSSData->cursorSprite->pos1.x = tmp + 64;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-16 05:27:05 +02:00
|
|
|
if (sPSSData->cursorSprite->pos1.x < 64)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
tmp = 64 - sPSSData->cursorSprite->pos1.x;
|
|
|
|
sPSSData->cursorSprite->pos1.x = DISPLAY_WIDTH + 16 - tmp;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-16 05:27:05 +02:00
|
|
|
if (sPSSData->cursorSprite->pos1.y > DISPLAY_HEIGHT + 16)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
tmp = sPSSData->cursorSprite->pos1.y - (DISPLAY_HEIGHT + 16);
|
|
|
|
sPSSData->cursorSprite->pos1.y = tmp - 16;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-16 05:27:05 +02:00
|
|
|
if (sPSSData->cursorSprite->pos1.y < -16)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
tmp = -16 - sPSSData->cursorSprite->pos1.y;
|
|
|
|
sPSSData->cursorSprite->pos1.y = DISPLAY_HEIGHT + 16 - tmp;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->field_CD7 && --sPSSData->field_CD7 == 0)
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->cursorSprite->vFlip = (sPSSData->cursorSprite->vFlip == FALSE);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->cursorSprite->pos1.x = sPSSData->field_CCC;
|
|
|
|
sPSSData->cursorSprite->pos1.y = sPSSData->field_CCE;
|
2018-12-15 23:58:47 +01:00
|
|
|
sub_80CDA68();
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-02-05 08:59:26 +01:00
|
|
|
static void sub_80CD6AC(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-02-05 08:59:26 +01:00
|
|
|
sPSSData->field_CD4 = newCursorArea;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CD5 = newCursorPosition;
|
|
|
|
sPSSData->field_CCC = x;
|
|
|
|
sPSSData->field_CCE = y;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CD70C(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
int r7, r0;
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->field_CD2 != 0 || sPSSData->field_CD3 != 0)
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->cursorMoveSteps = 12;
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->cursorMoveSteps = 6;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
if (sPSSData->field_CD7)
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->field_CD7 = sPSSData->cursorMoveSteps >> 1;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->field_CD2)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
default:
|
2021-04-16 05:27:05 +02:00
|
|
|
r7 = sPSSData->field_CCE - sPSSData->cursorSprite->pos1.y;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case -1:
|
2021-04-16 05:27:05 +02:00
|
|
|
r7 = sPSSData->field_CCE - 0xc0 - sPSSData->cursorSprite->pos1.y;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-16 05:27:05 +02:00
|
|
|
r7 = sPSSData->field_CCE + 0xc0 - sPSSData->cursorSprite->pos1.y;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->field_CD3)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
default:
|
2021-04-16 05:27:05 +02:00
|
|
|
r0 = sPSSData->field_CCC - sPSSData->cursorSprite->pos1.x;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case -1:
|
2021-04-16 05:27:05 +02:00
|
|
|
r0 = sPSSData->field_CCC - 0xc0 - sPSSData->cursorSprite->pos1.x;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-04-16 05:27:05 +02:00
|
|
|
r0 = sPSSData->field_CCC + 0xc0 - sPSSData->cursorSprite->pos1.x;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
r7 <<= 8;
|
|
|
|
r0 <<= 8;
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->field_CC4 = r0 / sPSSData->cursorMoveSteps;
|
|
|
|
sPSSData->field_CC8 = r7 / sPSSData->cursorMoveSteps;
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->field_CBC = sPSSData->cursorSprite->pos1.x << 8;
|
|
|
|
sPSSData->field_CC0 = sPSSData->cursorSprite->pos1.y << 8;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-02-05 08:59:26 +01:00
|
|
|
static void sub_80CD894(u8 newCursorArea, u8 newCursorPosition)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-02-05 08:59:26 +01:00
|
|
|
sub_80CD6AC(newCursorArea, newCursorPosition);
|
2018-12-15 23:58:47 +01:00
|
|
|
sub_80CD70C();
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sPSSData->inBoxMovingMode == MOVE_MODE_NORMAL && !sIsMonBeingMoved)
|
2021-04-16 05:27:05 +02:00
|
|
|
StartSpriteAnim(sPSSData->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-16 05:27:05 +02:00
|
|
|
StartSpriteAnim(sPSSData->cursorSprite, CURSOR_ANIM_STILL);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->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)
|
|
|
|
sub_80D0E50(CURSOR_AREA_IN_BOX, sCursorPosition);
|
|
|
|
else if (sCursorArea == CURSOR_AREA_IN_PARTY)
|
|
|
|
sub_80D0E50(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)
|
|
|
|
sub_80D0D8C(newCursorArea, newCursorPosition);
|
|
|
|
else if (newCursorArea == CURSOR_AREA_IN_PARTY)
|
|
|
|
sub_80D0D8C(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-02-05 08:59:26 +01:00
|
|
|
sPSSData->field_CD6 = newCursorArea;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CB8->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:
|
|
|
|
case CURSOR_AREA_BOX:
|
|
|
|
case CURSOR_AREA_BUTTONS:
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->cursorSprite->oam.priority = 1;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CB8->invisible = TRUE;
|
|
|
|
sPSSData->field_CB8->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-16 23:05:44 +02:00
|
|
|
if (sPSSData->inBoxMovingMode != MOVE_MODE_NORMAL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->cursorSprite->oam.priority = 0;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CB8->invisible = TRUE;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CDA68(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
sCursorArea = sPSSData->field_CD4;
|
|
|
|
sCursorPosition = sPSSData->field_CD5;
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sPSSData->inBoxMovingMode == MOVE_MODE_NORMAL && !sIsMonBeingMoved)
|
2021-04-16 05:27:05 +02:00
|
|
|
StartSpriteAnim(sPSSData->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-16 05:27:05 +02:00
|
|
|
StartSpriteAnim(sPSSData->cursorSprite, CURSOR_ANIM_BOUNCE);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub_80CEB40();
|
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;
|
|
|
|
case CURSOR_AREA_BOX:
|
2021-04-15 20:06:25 +02:00
|
|
|
AnimateBoxScrollArrows(TRUE);
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case CURSOR_AREA_IN_PARTY:
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CB8->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-16 23:05:44 +02:00
|
|
|
if (sPSSData->inBoxMovingMode == MOVE_MODE_NORMAL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->cursorSprite->oam.priority = 1;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CB8->oam.priority = 2;
|
|
|
|
sPSSData->field_CB8->subpriority = 21;
|
|
|
|
sPSSData->field_CB8->invisible = FALSE;
|
2018-12-16 21:10:01 +01:00
|
|
|
SetMovingMonPriority(2);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CDBA0(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-16 05:27:05 +02:00
|
|
|
if (sPSSData->cursorSprite->vFlip)
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CD7 = 1;
|
2018-12-16 21:10:01 +01:00
|
|
|
sub_80CD894(CURSOR_AREA_IN_PARTY, partyCount);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CDBF8(u8 cursorBoxPosition)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-16 21:10:01 +01:00
|
|
|
sub_80CD894(CURSOR_AREA_IN_BOX, cursorBoxPosition);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
EWRAM_DATA static u8 gUnknown_02039D7E = 0;
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CDC0C(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
gUnknown_02039D7E = 0;
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CDC18(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
gUnknown_02039D7E = sCursorPosition;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static u8 sub_80CDC2C(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
return gUnknown_02039D7E;
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void InitMonPlaceChange(u8 a0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 (*const placeChangeFuncs[])(void) =
|
|
|
|
{
|
|
|
|
MonPlaceChange_Move,
|
|
|
|
MonPlaceChange_Place,
|
|
|
|
MonPlaceChange_Shift,
|
|
|
|
};
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->monPlaceChangeFunc = placeChangeFuncs[a0];
|
|
|
|
sPSSData->monPlaceChangeState = 0;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void sub_80CDC64(bool8 arg0)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (!arg0)
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->monPlaceChangeFunc = sub_80CDEB4;
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->monPlaceChangeFunc = sub_80CDEC4;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
return sPSSData->monPlaceChangeFunc();
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 MonPlaceChange_Move(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->monPlaceChangeState)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
return FALSE;
|
2021-04-16 05:27:05 +02:00
|
|
|
StartSpriteAnim(sPSSData->cursorSprite, CURSOR_ANIM_OPEN);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->monPlaceChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!sub_80CDED4())
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
StartSpriteAnim(sPSSData->cursorSprite, CURSOR_ANIM_FIST);
|
2018-12-15 23:58:47 +01:00
|
|
|
MoveMon();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->monPlaceChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!sub_80CDF08())
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->monPlaceChangeState)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (!sub_80CDED4())
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
StartSpriteAnim(sPSSData->cursorSprite, CURSOR_ANIM_OPEN);
|
2018-12-15 23:58:47 +01:00
|
|
|
PlaceMon();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->monPlaceChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!sub_80CDF08())
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
StartSpriteAnim(sPSSData->cursorSprite, CURSOR_ANIM_BOUNCE);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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:
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_D91 = TOTAL_BOXES_COUNT;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case CURSOR_AREA_IN_BOX:
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_D91 = StorageGetCurrentBox();
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
2021-04-16 05:27:05 +02:00
|
|
|
StartSpriteAnim(sPSSData->cursorSprite, CURSOR_ANIM_OPEN);
|
2021-04-16 23:05:44 +02:00
|
|
|
sub_80CBD5C(sPSSData->field_D91, sCursorPosition);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->monPlaceChangeState++;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!sub_80CBDC4())
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
StartSpriteAnim(sPSSData->cursorSprite, CURSOR_ANIM_FIST);
|
2021-04-16 23:05:44 +02:00
|
|
|
SetShiftedMonData(sPSSData->field_D91, sCursorPosition);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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 sub_80CDEB4(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
return sub_80CDED4();
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 sub_80CDEC4(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
return sub_80CDF08();
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 sub_80CDED4(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
switch (sPSSData->cursorSprite->pos2.y)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
default:
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->cursorSprite->pos2.y++;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 0:
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->cursorSprite->pos2.y++;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static bool8 sub_80CDF08(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
switch (sPSSData->cursorSprite->pos2.y)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return FALSE;
|
|
|
|
default:
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->cursorSprite->pos2.y--;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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-16 23:05:44 +02:00
|
|
|
SetMovedMonData(TOTAL_BOXES_COUNT, sCursorPosition);
|
|
|
|
sub_80CBC14(MODE_PARTY, sCursorPosition);
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
case CURSOR_AREA_IN_BOX:
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sPSSData->inBoxMovingMode == MOVE_MODE_NORMAL)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
SetMovedMonData(StorageGetCurrentBox(), sCursorPosition);
|
|
|
|
sub_80CBC14(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);
|
|
|
|
sub_80CBCAC(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);
|
|
|
|
sub_80CBCAC(boxId, sCursorPosition);
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sIsMonBeingMoved = FALSE;
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CE00C(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
sub_80CEB40();
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void SetMovedMonData(u8 boxId, u8 position)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (boxId == TOTAL_BOXES_COUNT)
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->movingMon = gPlayerParty[sCursorPosition];
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2018-12-20 22:14:36 +01:00
|
|
|
BoxMonAtToMon(boxId, position, &sPSSData->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)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
gPlayerParty[position] = sPSSData->movingMon;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
BoxMonRestorePP(&sPSSData->movingMon.box);
|
|
|
|
SetBoxMonAt(boxId, position, &sPSSData->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-16 05:27:05 +02:00
|
|
|
sPSSData->tempMon = gPlayerParty[position];
|
2018-12-15 23:58:47 +01:00
|
|
|
else
|
2021-04-16 05:27:05 +02:00
|
|
|
BoxMonAtToMon(boxId, position, &sPSSData->tempMon);
|
2018-12-15 23:58:47 +01:00
|
|
|
|
|
|
|
SetPlacedMonData(boxId, position);
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->movingMon = sPSSData->tempMon;
|
|
|
|
SetDisplayMonData(&sPSSData->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-16 23:05:44 +02:00
|
|
|
SetMovedMonData(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())
|
|
|
|
sub_80CB140(boxPosition);
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
StartSpriteAnim(sPSSData->cursorSprite, CURSOR_ANIM_STILL);
|
2018-12-15 23:58:47 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
static void sub_80CE22C(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
StartSpriteAnim(sPSSData->cursorSprite, CURSOR_ANIM_BOUNCE);
|
2018-12-15 23:58:47 +01:00
|
|
|
sub_80CEB40();
|
|
|
|
}
|
|
|
|
|
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-16 05:27:05 +02:00
|
|
|
StringCopy(sPSSData->releaseMonName, sPSSData->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-16 05:27:05 +02:00
|
|
|
StartSpriteAnim(sPSSData->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
|
|
|
}
|
|
|
|
sub_80CEB40();
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
static void TrySetCursorFistAnim(void)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
|
|
|
if (sIsMonBeingMoved)
|
2021-04-16 05:27:05 +02:00
|
|
|
StartSpriteAnim(sPSSData->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
|
|
|
|
sPSSData->releaseStatusResolved = TRUE;
|
|
|
|
sPSSData->canReleaseMon = FALSE;
|
2018-12-15 23:58:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->tempMon = sPSSData->movingMon;
|
|
|
|
sPSSData->releaseBoxId = -1;
|
|
|
|
sPSSData->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-16 23:05:44 +02:00
|
|
|
sPSSData->tempMon = gPlayerParty[sCursorPosition];
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->releaseBoxId = TOTAL_BOXES_COUNT;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
BoxMonAtToMon(StorageGetCurrentBox(), sCursorPosition, &sPSSData->tempMon);
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->releaseBoxId = StorageGetCurrentBox();
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->releaseBoxPos = sCursorPosition;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
GetRestrictedReleaseMoves(sPSSData->restrictedMoveList);
|
|
|
|
sPSSData->restrictedReleaseMonMoves = GetMonData(&sPSSData->tempMon, MON_DATA_KNOWN_MOVES, (u8*)sPSSData->restrictedMoveList);
|
|
|
|
if (sPSSData->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
|
|
|
|
sPSSData->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
|
|
|
|
sPSSData->releaseStatusResolved = TRUE;
|
|
|
|
sPSSData->canReleaseMon = TRUE;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->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-16 05:27:05 +02:00
|
|
|
if (sPSSData->releaseStatusResolved)
|
|
|
|
return sPSSData->canReleaseMon;
|
2018-12-15 23:58:47 +01:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
switch (sPSSData->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
|
|
|
|
if (sPSSData->releaseBoxId != TOTAL_BOXES_COUNT || sPSSData->releaseBoxPos != i)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
knownMoves = GetMonData(&gPlayerParty[i], MON_DATA_KNOWN_MOVES, (u8*)sPSSData->restrictedMoveList);
|
|
|
|
sPSSData->restrictedReleaseMonMoves &= ~(knownMoves);
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
2021-04-16 05:27:05 +02:00
|
|
|
if (sPSSData->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.
|
|
|
|
sPSSData->releaseStatusResolved = TRUE;
|
|
|
|
sPSSData->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
|
|
|
|
sPSSData->releaseCheckBoxId = 0;
|
|
|
|
sPSSData->releaseCheckBoxPos = 0;
|
|
|
|
sPSSData->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-16 05:27:05 +02:00
|
|
|
knownMoves = GetAndCopyBoxMonDataAt(sPSSData->releaseCheckBoxId, sPSSData->releaseCheckBoxPos, MON_DATA_KNOWN_MOVES, (u8*)sPSSData->restrictedMoveList);
|
|
|
|
if (knownMoves != 0 && !(sPSSData->releaseBoxId == sPSSData->releaseCheckBoxId
|
|
|
|
&& sPSSData->releaseBoxPos == sPSSData->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
|
|
|
|
sPSSData->restrictedReleaseMonMoves &= ~(knownMoves);
|
|
|
|
if (sPSSData->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.
|
|
|
|
sPSSData->releaseStatusResolved = TRUE;
|
|
|
|
sPSSData->canReleaseMon = TRUE;
|
2018-12-15 23:58:47 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-04-16 05:27:05 +02:00
|
|
|
if (++sPSSData->releaseCheckBoxPos >= IN_BOX_COUNT)
|
2018-12-15 23:58:47 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->releaseCheckBoxPos = 0;
|
|
|
|
if (++sPSSData->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.
|
|
|
|
sPSSData->releaseStatusResolved = TRUE;
|
|
|
|
sPSSData->canReleaseMon = FALSE;
|
2018-12-15 23:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2018-12-16 21:10:01 +01:00
|
|
|
|
|
|
|
static void sub_80CE760(void)
|
|
|
|
{
|
|
|
|
if (sIsMonBeingMoved)
|
2018-12-20 22:14:36 +01:00
|
|
|
gUnknown_02039D14 = sPSSData->movingMon;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80CE790(void)
|
|
|
|
{
|
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
{
|
|
|
|
if (sMovingMonOrigBoxId == TOTAL_BOXES_COUNT)
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->movingMon = gUnknown_02039D14;
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->movingMon.box = gUnknown_02039D14.box;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80CE7E8(void)
|
|
|
|
{
|
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
{
|
|
|
|
sub_80CE760();
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_218C.mon = &gUnknown_02039D14;
|
|
|
|
sPSSData->field_2187 = 0;
|
|
|
|
sPSSData->field_2186 = 0;
|
2021-04-15 23:31:50 +02:00
|
|
|
sPSSData->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
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_218C.mon = gPlayerParty;
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->field_2187 = sCursorPosition;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_2186 = CountPartyMons() - 1;
|
2021-04-15 23:31:50 +02:00
|
|
|
sPSSData->summaryScreenMode = SUMMARY_MODE_NORMAL;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_218C.box = GetBoxedMonPtr(StorageGetCurrentBox(), 0);
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->field_2187 = sCursorPosition;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_2186 = IN_BOX_COUNT - 1;
|
2021-04-15 23:31:50 +02:00
|
|
|
sPSSData->summaryScreenMode = SUMMARY_MODE_BOX;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80CE8E4(void)
|
|
|
|
{
|
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
sub_80CE790();
|
|
|
|
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-16 05:27:05 +02:00
|
|
|
sPSSData->displayMonMarkings = markings;
|
2018-12-16 21:10:01 +01:00
|
|
|
if (sIsMonBeingMoved)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
SetMonData(&sPSSData->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-16 05:27:05 +02:00
|
|
|
if (sPSSData->displayMonIsEgg || GetMonData(&sPSSData->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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 IsCursorOnBox(void)
|
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
return (sCursorArea == CURSOR_AREA_BOX);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80CEB40(void)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->setMosaic = (sIsMonBeingMoved == FALSE);
|
2018-12-16 21:10:01 +01:00
|
|
|
if (!sIsMonBeingMoved)
|
|
|
|
{
|
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:
|
|
|
|
case CURSOR_AREA_BOX:
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80CEBDC(void)
|
|
|
|
{
|
|
|
|
if (sIsMonBeingMoved)
|
2021-04-16 05:27:05 +02:00
|
|
|
SetDisplayMonData(&gUnknown_02039D14, MODE_PARTY);
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
|
|
|
sub_80CEB40();
|
|
|
|
}
|
|
|
|
|
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-16 05:27:05 +02:00
|
|
|
sPSSData->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-16 05:27:05 +02:00
|
|
|
sPSSData->displayMonSpecies = GetMonData(mon, MON_DATA_SPECIES2);
|
|
|
|
if (sPSSData->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-16 05:27:05 +02:00
|
|
|
sPSSData->displayMonIsEgg = TRUE;
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->displayMonIsEgg = GetMonData(mon, MON_DATA_IS_EGG);
|
|
|
|
|
|
|
|
GetMonData(mon, MON_DATA_NICKNAME, sPSSData->displayMonName);
|
|
|
|
StringGetEnd10(sPSSData->displayMonName);
|
|
|
|
sPSSData->displayMonLevel = GetMonData(mon, MON_DATA_LEVEL);
|
|
|
|
sPSSData->displayMonMarkings = GetMonData(mon, MON_DATA_MARKINGS);
|
|
|
|
sPSSData->displayMonPersonality = GetMonData(mon, MON_DATA_PERSONALITY);
|
|
|
|
sPSSData->displayMonPalette = GetMonFrontSpritePal(mon);
|
2018-12-16 21:10:01 +01:00
|
|
|
gender = GetMonGender(mon);
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->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-16 05:27:05 +02:00
|
|
|
sPSSData->displayMonSpecies = GetBoxMonData(pokemon, MON_DATA_SPECIES2);
|
|
|
|
if (sPSSData->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-16 05:27:05 +02:00
|
|
|
sPSSData->displayMonIsEgg = TRUE;
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->displayMonIsEgg = GetBoxMonData(boxMon, MON_DATA_IS_EGG);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
GetBoxMonData(boxMon, MON_DATA_NICKNAME, sPSSData->displayMonName);
|
|
|
|
StringGetEnd10(sPSSData->displayMonName);
|
|
|
|
sPSSData->displayMonLevel = GetLevelFromBoxMonExp(boxMon);
|
|
|
|
sPSSData->displayMonMarkings = GetBoxMonData(boxMon, MON_DATA_MARKINGS);
|
|
|
|
sPSSData->displayMonPersonality = GetBoxMonData(boxMon, MON_DATA_PERSONALITY);
|
|
|
|
sPSSData->displayMonPalette = GetMonSpritePalFromSpeciesAndPersonality(sPSSData->displayMonSpecies, otId, sPSSData->displayMonPersonality);
|
|
|
|
gender = GetGenderFromSpeciesAndPersonality(sPSSData->displayMonSpecies, sPSSData->displayMonPersonality);
|
|
|
|
sPSSData->displayMonItemId = GetBoxMonData(boxMon, MON_DATA_HELD_ITEM);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->displayMonSpecies = SPECIES_NONE;
|
|
|
|
sPSSData->displayMonItemId = ITEM_NONE;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
if (sPSSData->displayMonSpecies == SPECIES_NONE)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
StringFill(sPSSData->displayMonName, CHAR_SPACE, 5);
|
|
|
|
StringFill(sPSSData->displayMonNameText, CHAR_SPACE, 8);
|
|
|
|
StringFill(sPSSData->displayMonSpeciesName, CHAR_SPACE, 8);
|
|
|
|
StringFill(sPSSData->displayMonGenderLvlText, CHAR_SPACE, 8);
|
|
|
|
StringFill(sPSSData->displayMonItemName, CHAR_SPACE, 8);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
2021-04-16 05:27:05 +02:00
|
|
|
else if (sPSSData->displayMonIsEgg)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2020-11-16 19:36:38 +01:00
|
|
|
if (sanityIsBadEgg)
|
2021-04-16 05:27:05 +02:00
|
|
|
StringCopyPadded(sPSSData->displayMonNameText, sPSSData->displayMonName, CHAR_SPACE, 5);
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
2021-04-16 05:27:05 +02:00
|
|
|
StringCopyPadded(sPSSData->displayMonNameText, gText_EggNickname, CHAR_SPACE, 8);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
StringFill(sPSSData->displayMonSpeciesName, CHAR_SPACE, 8);
|
|
|
|
StringFill(sPSSData->displayMonGenderLvlText, CHAR_SPACE, 8);
|
|
|
|
StringFill(sPSSData->displayMonItemName, CHAR_SPACE, 8);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
if (sPSSData->displayMonSpecies == SPECIES_NIDORAN_F || sPSSData->displayMonSpecies == SPECIES_NIDORAN_M)
|
2018-12-16 21:10:01 +01:00
|
|
|
gender = MON_GENDERLESS;
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
StringCopyPadded(sPSSData->displayMonNameText, sPSSData->displayMonName, CHAR_SPACE, 5);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
txtPtr = sPSSData->displayMonSpeciesName;
|
2018-12-16 21:10:01 +01:00
|
|
|
*(txtPtr)++ = CHAR_SLASH;
|
2021-04-16 05:27:05 +02:00
|
|
|
StringCopyPadded(txtPtr, gSpeciesNames[sPSSData->displayMonSpecies], CHAR_SPACE, 5);
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
txtPtr = sPSSData->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;
|
2020-08-11 05:50:49 +02:00
|
|
|
*(txtPtr)++ = CHAR_UNK_SPACER;
|
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-16 05:27:05 +02:00
|
|
|
txtPtr = ConvertIntToDecimalStringN(txtPtr, sPSSData->displayMonLevel, STR_CONV_MODE_LEFT_ALIGN, 3);
|
2018-12-16 21:10:01 +01:00
|
|
|
txtPtr[0] = CHAR_SPACE;
|
|
|
|
txtPtr[1] = EOS;
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
if (sPSSData->displayMonItemId != ITEM_NONE)
|
|
|
|
StringCopyPadded(sPSSData->displayMonItemName, ItemId_GetName(sPSSData->displayMonItemId), CHAR_SPACE, 8);
|
2018-12-16 21:10:01 +01:00
|
|
|
else
|
2021-04-16 05:27:05 +02:00
|
|
|
StringFill(sPSSData->displayMonItemName, CHAR_SPACE, 8);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 HandleInput_InBox(void)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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;
|
2020-05-21 19:04:13 +02:00
|
|
|
sPSSData->field_CD2 = 0;
|
|
|
|
sPSSData->field_CD3 = 0;
|
|
|
|
sPSSData->field_CD7 = 0;
|
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_UP))
|
2019-05-26 11:07:30 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
retVal = INPUT_1;
|
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
|
|
|
|
{
|
|
|
|
cursorArea = CURSOR_AREA_BOX;
|
|
|
|
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-15 23:31:50 +02:00
|
|
|
retVal = INPUT_1;
|
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;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CD2 = 1;
|
|
|
|
sPSSData->field_CD7 = 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-15 23:31:50 +02:00
|
|
|
retVal = INPUT_1;
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorPosition % IN_BOX_COLUMNS != 0)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
cursorPosition--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CD3 = -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-15 23:31:50 +02:00
|
|
|
retVal = INPUT_1;
|
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
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CD3 = 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-15 23:31:50 +02:00
|
|
|
retVal = INPUT_1;
|
2018-12-16 21:10:01 +01:00
|
|
|
cursorArea = CURSOR_AREA_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
|
|
|
|
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-15 23:31:50 +02:00
|
|
|
if (sPSSData->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-16 23:05:44 +02:00
|
|
|
sPSSData->inBoxMovingMode = MOVE_MODE_MULTIPLE_SELECTING;
|
|
|
|
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)
|
|
|
|
sub_80CD894(cursorArea, cursorPosition);
|
|
|
|
|
|
|
|
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-16 23:05:44 +02:00
|
|
|
sub_80CD894(CURSOR_AREA_IN_BOX, sCursorPosition - IN_BOX_COLUMNS);
|
|
|
|
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-16 23:05:44 +02:00
|
|
|
sub_80CD894(CURSOR_AREA_IN_BOX, sCursorPosition + IN_BOX_COLUMNS);
|
|
|
|
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-16 23:05:44 +02:00
|
|
|
sub_80CD894(CURSOR_AREA_IN_BOX, sCursorPosition - 1);
|
|
|
|
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-16 23:05:44 +02:00
|
|
|
sub_80CD894(CURSOR_AREA_IN_BOX, sCursorPosition + 1);
|
|
|
|
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
|
|
|
|
sPSSData->inBoxMovingMode = MOVE_MODE_NORMAL;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CB8->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-16 05:27:05 +02:00
|
|
|
sIsMonBeingMoved = (sPSSData->displayMonSpecies != SPECIES_NONE);
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->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-16 23:05:44 +02:00
|
|
|
sub_80CD894(CURSOR_AREA_IN_BOX, sCursorPosition - IN_BOX_COLUMNS);
|
|
|
|
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-16 23:05:44 +02:00
|
|
|
sub_80CD894(CURSOR_AREA_IN_BOX, sCursorPosition + IN_BOX_COLUMNS);
|
|
|
|
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-16 23:05:44 +02:00
|
|
|
sub_80CD894(CURSOR_AREA_IN_BOX, sCursorPosition - 1);
|
|
|
|
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-16 23:05:44 +02:00
|
|
|
sub_80CD894(CURSOR_AREA_IN_BOX, sCursorPosition + 1);
|
|
|
|
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-16 23:05:44 +02:00
|
|
|
sPSSData->inBoxMovingMode = MOVE_MODE_NORMAL;
|
|
|
|
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;
|
2020-05-21 19:04:13 +02:00
|
|
|
sPSSData->field_CD3 = 0;
|
|
|
|
sPSSData->field_CD2 = 0;
|
|
|
|
sPSSData->field_CD7 = 0;
|
|
|
|
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-15 23:31:50 +02:00
|
|
|
retVal = INPUT_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
|
|
|
{
|
|
|
|
if (++cursorPosition > PARTY_SIZE)
|
|
|
|
cursorPosition = 0;
|
2021-04-16 23:05:44 +02:00
|
|
|
if (cursorPosition != sCursorPosition)
|
2021-04-15 23:31:50 +02:00
|
|
|
retVal = INPUT_1;
|
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-15 23:31:50 +02:00
|
|
|
retVal = INPUT_1;
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->field_CD6 = 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-15 23:31:50 +02:00
|
|
|
retVal = INPUT_1;
|
2018-12-20 22:14:36 +01:00
|
|
|
cursorPosition = sPSSData->field_CD6;
|
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-15 23:31:50 +02:00
|
|
|
if (sPSSData->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-15 23:31:50 +02:00
|
|
|
if (sPSSData->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)
|
2018-12-16 21:10:01 +01:00
|
|
|
sub_80CD894(cursorArea, cursorPosition);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2020-05-21 19:04:13 +02:00
|
|
|
sPSSData->field_CD3 = 0;
|
|
|
|
sPSSData->field_CD2 = 0;
|
|
|
|
sPSSData->field_CD7 = 0;
|
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_UP))
|
2019-05-26 11:07:30 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
retVal = INPUT_1;
|
2019-05-26 11:07:30 +02:00
|
|
|
cursorArea = CURSOR_AREA_BUTTONS;
|
|
|
|
cursorPosition = 0;
|
|
|
|
sPSSData->field_CD7 = 1;
|
|
|
|
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-15 23:31:50 +02:00
|
|
|
retVal = INPUT_1;
|
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);
|
2019-05-26 11:07:30 +02:00
|
|
|
AddBoxMenu();
|
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
|
|
|
{
|
|
|
|
if (cursorArea != CURSOR_AREA_BOX)
|
2021-04-15 20:06:25 +02:00
|
|
|
AnimateBoxScrollArrows(FALSE);
|
2018-12-16 21:10:01 +01:00
|
|
|
sub_80CD894(cursorArea, cursorPosition);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2020-05-21 19:04:13 +02:00
|
|
|
sPSSData->field_CD3 = 0;
|
|
|
|
sPSSData->field_CD2 = 0;
|
|
|
|
sPSSData->field_CD7 = 0;
|
|
|
|
|
2020-11-03 02:02:39 +01:00
|
|
|
if (JOY_REPEAT(DPAD_UP))
|
2019-05-26 11:07:30 +02:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
retVal = INPUT_1;
|
2019-05-26 11:07:30 +02:00
|
|
|
cursorArea = CURSOR_AREA_IN_BOX;
|
|
|
|
sPSSData->field_CD2 = -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;
|
2019-05-26 11:07:30 +02:00
|
|
|
sPSSData->field_CD7 = 1;
|
|
|
|
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-15 23:31:50 +02:00
|
|
|
retVal = INPUT_1;
|
2018-12-16 21:10:01 +01:00
|
|
|
cursorArea = CURSOR_AREA_BOX;
|
|
|
|
cursorPosition = 0;
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CD7 = 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-15 23:31:50 +02:00
|
|
|
retVal = INPUT_1;
|
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-15 23:31:50 +02:00
|
|
|
retVal = INPUT_1;
|
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)
|
2018-12-16 21:10:01 +01:00
|
|
|
sub_80CD894(cursorArea, cursorPosition);
|
|
|
|
|
|
|
|
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},
|
|
|
|
{HandleInput_OnBox, CURSOR_AREA_BOX},
|
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
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void AddBoxMenu(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-15 23:31:50 +02:00
|
|
|
if (sPSSData->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
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
switch (sPSSData->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-15 23:31:50 +02:00
|
|
|
if (sPSSData->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-16 05:27:05 +02:00
|
|
|
if (sPSSData->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-16 05:27:05 +02:00
|
|
|
if (sPSSData->displayMonItemId == ITEM_NONE)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
if (sPSSData->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-16 05:27:05 +02:00
|
|
|
if (!ItemIsMail(sPSSData->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-16 05:27:05 +02:00
|
|
|
if (sPSSData->displayMonItemId == ITEM_NONE)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
if (sPSSData->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-16 05:27:05 +02:00
|
|
|
if (ItemIsMail(sPSSData->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-16 05:27:05 +02:00
|
|
|
static void SpriteCB_CursorShadow(struct Sprite *sprite)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
sprite->pos1.x = sPSSData->cursorSprite->pos1.x;
|
|
|
|
sprite->pos1.y = sPSSData->cursorSprite->pos1.y + 20;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void sub_80CFC14(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-16 05:27:05 +02:00
|
|
|
{sHandCursor_Pal, PALTAG_7},
|
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-16 01:17:53 +02:00
|
|
|
.paletteTag = PALTAG_10,
|
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-16 01:17:53 +02:00
|
|
|
.paletteTag = PALTAG_10,
|
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-16 23:05:44 +02:00
|
|
|
sPSSData->cursorPalNums[0] = IndexOfSpritePaletteTag(PALTAG_10); // White hand, normal
|
|
|
|
sPSSData->cursorPalNums[1] = IndexOfSpritePaletteTag(PALTAG_7); // 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-16 05:27:05 +02:00
|
|
|
sPSSData->cursorSprite = &gSprites[spriteId];
|
2021-04-16 23:05:44 +02:00
|
|
|
sPSSData->cursorSprite->oam.paletteNum = sPSSData->cursorPalNums[sAutoActionOn];
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->cursorSprite->oam.priority = 1;
|
2018-12-16 21:10:01 +01:00
|
|
|
if (sIsMonBeingMoved)
|
2021-04-16 05:27:05 +02:00
|
|
|
StartSpriteAnim(sPSSData->cursorSprite, CURSOR_ANIM_FIST);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->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)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CB8 = &gSprites[spriteId];
|
|
|
|
sPSSData->field_CB8->oam.priority = priority;
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorArea)
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CB8->invisible = 1;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CB8 = 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;
|
|
|
|
sPSSData->cursorSprite->oam.paletteNum = sPSSData->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-16 05:27:05 +02:00
|
|
|
StartSpriteAnim(sPSSData->cursorSprite, animNum);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static u8 sub_80CFE78(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-16 05:27:05 +02:00
|
|
|
sPSSData->cursorSprite->oam.priority = 1;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void sub_80CFEA8(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorArea == CURSOR_AREA_IN_BOX)
|
|
|
|
sub_80D0E50(CURSOR_AREA_IN_BOX, sCursorPosition);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void sub_80CFECC(void)
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
if (sCursorArea == CURSOR_AREA_IN_BOX)
|
|
|
|
sub_80D0D8C(CURSOR_AREA_IN_BOX, sCursorPosition);
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void InitMenu(void)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->menuItemsCount = 0;
|
|
|
|
sPSSData->menuWidth = 0;
|
|
|
|
sPSSData->menuWindow.bg = 0;
|
|
|
|
sPSSData->menuWindow.paletteNum = 15;
|
|
|
|
sPSSData->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-15 19:31:18 +02:00
|
|
|
if (sPSSData->menuItemsCount < ARRAY_COUNT(sPSSData->menuItems))
|
2018-12-16 21:10:01 +01:00
|
|
|
{
|
|
|
|
u8 len;
|
2018-12-20 22:14:36 +01:00
|
|
|
struct StorageMenu *menu = &sPSSData->menuItems[sPSSData->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);
|
2018-12-20 22:14:36 +01:00
|
|
|
if (len > sPSSData->menuWidth)
|
|
|
|
sPSSData->menuWidth = len;
|
2018-12-16 21:10:01 +01:00
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->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-15 19:31:18 +02:00
|
|
|
if (menuIdx >= sPSSData->menuItemsCount)
|
2018-12-16 21:10:01 +01:00
|
|
|
return -1;
|
|
|
|
else
|
2021-04-15 19:31:18 +02:00
|
|
|
return sPSSData->menuItems[menuIdx].textId;
|
2018-12-16 21:10:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void AddMenu(void)
|
|
|
|
{
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->menuWindow.width = sPSSData->menuWidth + 2;
|
|
|
|
sPSSData->menuWindow.height = 2 * sPSSData->menuItemsCount;
|
|
|
|
sPSSData->menuWindow.tilemapLeft = 29 - sPSSData->menuWindow.width;
|
|
|
|
sPSSData->menuWindow.tilemapTop = 15 - sPSSData->menuWindow.height;
|
2021-04-15 19:31:18 +02:00
|
|
|
sPSSData->menuWindowId = AddWindow(&sPSSData->menuWindow);
|
|
|
|
ClearWindowTilemap(sPSSData->menuWindowId);
|
|
|
|
DrawStdFrameWithCustomTileAndPalette(sPSSData->menuWindowId, FALSE, 11, 14);
|
|
|
|
PrintMenuTable(sPSSData->menuWindowId, sPSSData->menuItemsCount, (void*)sPSSData->menuItems);
|
|
|
|
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sPSSData->menuWindowId, sPSSData->menuItemsCount, 0);
|
2020-05-14 10:37:09 +02:00
|
|
|
ScheduleBgCopyTilemapToVram(0);
|
2018-12-20 22:14:36 +01:00
|
|
|
sPSSData->field_CAE = 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)
|
|
|
|
input = sPSSData->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-15 19:31:18 +02:00
|
|
|
ClearStdWindowAndFrameToTransparent(sPSSData->menuWindowId, TRUE);
|
|
|
|
RemoveWindow(sPSSData->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
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// MultiMove
|
|
|
|
//
|
|
|
|
// 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-16 23:05:44 +02:00
|
|
|
sPSSData->multiMoveWindowId = AddWindow8Bit(&sWindowTemplate_MultiMove);
|
|
|
|
if (sPSSData->multiMoveWindowId != WINDOW_NONE)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 23:05:44 +02:00
|
|
|
FillWindowPixelBuffer(sPSSData->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-16 23:05:44 +02:00
|
|
|
FillWindowPixelBuffer8Bit(sPSSData->multiMoveWindowId, PIXEL_FILL(0));
|
|
|
|
MultiMove_SetIconToBg(sMultiMove->fromColumn, sMultiMove->fromRow);
|
2018-12-26 13:05:02 +01:00
|
|
|
SetBgAttribute(0, BG_ATTR_PALETTEMODE, 1);
|
2021-04-16 23:05:44 +02:00
|
|
|
PutWindowTilemap(sPSSData->multiMoveWindowId);
|
|
|
|
CopyWindowToVram8Bit(sPSSData->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;
|
|
|
|
CopyWindowToVram8Bit(sPSSData->multiMoveWindowId, 2);
|
|
|
|
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();
|
2018-12-17 23:00:08 +01:00
|
|
|
sub_80CDC64(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);
|
2018-12-17 23:00:08 +01:00
|
|
|
sub_80CDC64(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);
|
2018-12-17 23:00:08 +01:00
|
|
|
sub_80CDC64(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);
|
2018-12-17 23:00:08 +01:00
|
|
|
sub_80CDC64(TRUE);
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
const u8 *iconGfx = GetMonIconPtr(species, personality, 1);
|
|
|
|
u8 index = GetValidMonIconPalIndex(species) + 8;
|
|
|
|
|
2021-04-16 23:05:44 +02:00
|
|
|
BlitBitmapRectToWindow4BitTo8Bit(sPSSData->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-16 23:05:44 +02:00
|
|
|
FillWindowPixelRect8Bit(sPSSData->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
|
|
|
{
|
|
|
|
DestroyBoxMonIconAtPosition(boxPosition);
|
|
|
|
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))
|
2018-12-17 23:00:08 +01:00
|
|
|
sub_80CB140(boxPosition);
|
|
|
|
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-16 01:17:53 +02:00
|
|
|
// The functions below handle new features of MOVE_ITEMS box option.
|
|
|
|
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);
|
|
|
|
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 *);
|
|
|
|
|
|
|
|
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-15 23:31:50 +02:00
|
|
|
if (sPSSData->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-16 01:17:53 +02:00
|
|
|
sPSSData->itemIcons[i].tiles = GetSpriteTileStartByTag(spriteSheet.tag) * 32 + (void*)(OBJ_VRAM0);
|
|
|
|
sPSSData->itemIcons[i].palIndex = AllocSpritePalette(PALTAG_ITEM_ICON_0 + i);
|
|
|
|
sPSSData->itemIcons[i].palIndex *= 16;
|
|
|
|
sPSSData->itemIcons[i].palIndex += 0x100;
|
|
|
|
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-16 01:17:53 +02:00
|
|
|
sPSSData->itemIcons[i].sprite = &gSprites[spriteId];
|
|
|
|
sPSSData->itemIcons[i].sprite->invisible = TRUE;
|
|
|
|
sPSSData->itemIcons[i].active = FALSE;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
}
|
2021-04-16 01:17:53 +02:00
|
|
|
sPSSData->movingItemId = ITEM_NONE;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void sub_80D0D8C(u8 cursorArea, u8 cursorPos)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
u16 heldItem;
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void sub_80D0E50(u8 cursorArea, u8 cursorPos)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
u8 id;
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->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
|
|
|
}
|
|
|
|
|
|
|
|
static void Item_FromMonToMoving(u8 cursorArea, u8 cursorPos)
|
|
|
|
{
|
|
|
|
u8 id;
|
2021-04-16 01:17:53 +02:00
|
|
|
u16 itemId;
|
2018-12-17 23:00:08 +01:00
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->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-16 05:27:05 +02:00
|
|
|
sPSSData->movingItemId = sPSSData->displayMonItemId;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void sub_80D0F38(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);
|
|
|
|
sPSSData->movingItemId = itemId;
|
2018-12-17 23:00:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void Item_SwitchMonsWithMoving(u8 cursorArea, u8 cursorPos)
|
|
|
|
{
|
|
|
|
u8 id;
|
2021-04-16 01:17:53 +02:00
|
|
|
u16 itemId;
|
2018-12-17 23:00:08 +01:00
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->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);
|
|
|
|
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &sPSSData->movingItemId);
|
|
|
|
sPSSData->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);
|
|
|
|
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sPSSData->movingItemId);
|
|
|
|
sPSSData->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
|
|
|
}
|
|
|
|
|
|
|
|
static void Item_GiveMovingToMon(u8 cursorArea, u8 cursorPos)
|
|
|
|
{
|
|
|
|
u8 id;
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->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-16 01:17:53 +02:00
|
|
|
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &sPSSData->movingItemId);
|
2018-12-17 23:00:08 +01:00
|
|
|
SetBoxMonIconObjMode(cursorPos, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sPSSData->movingItemId);
|
2018-12-17 23:00:08 +01:00
|
|
|
SetPartyMonIconObjMode(cursorPos, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Item_TakeMons(u8 cursorArea, u8 cursorPos)
|
|
|
|
{
|
|
|
|
u8 id;
|
|
|
|
u16 item;
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->boxOption != OPTION_MOVE_ITEMS)
|
2018-12-17 23:00:08 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
item = 0;
|
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
|
|
|
{
|
|
|
|
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &item);
|
|
|
|
SetBoxMonIconObjMode(cursorPos, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &item);
|
|
|
|
SetPartyMonIconObjMode(cursorPos, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void sub_80D1194(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 22:47:27 +01:00
|
|
|
static void sub_80D11CC(void)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
2021-04-15 23:31:50 +02:00
|
|
|
if (sPSSData->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-16 01:17:53 +02:00
|
|
|
if (sPSSData->itemIcons[i].active
|
2021-04-16 05:27:05 +02:00
|
|
|
&& sPSSData->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-16 01:17:53 +02:00
|
|
|
if (sPSSData->itemIcons[i].active)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
if (!sPSSData->itemIcons[i].sprite->affineAnimEnded
|
|
|
|
&& sPSSData->itemIcons[i].sprite->affineAnimBeginning)
|
2018-12-17 23:00:08 +01:00
|
|
|
return TRUE;
|
2021-04-16 01:17:53 +02:00
|
|
|
if (sPSSData->itemIcons[i].sprite->callback != SpriteCallbackDummy
|
|
|
|
&& sPSSData->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-15 23:31:50 +02:00
|
|
|
if (sPSSData->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-16 01:17:53 +02:00
|
|
|
if (sPSSData->itemIcons[i].active
|
2021-04-16 05:27:05 +02:00
|
|
|
&& sPSSData->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-16 01:17:53 +02:00
|
|
|
return ItemId_GetName(sPSSData->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-16 01:17:53 +02:00
|
|
|
return sPSSData->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-16 01:17:53 +02:00
|
|
|
if (!sPSSData->itemIcons[i].active)
|
2018-12-17 23:00:08 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
sPSSData->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-16 01:17:53 +02:00
|
|
|
if (sPSSData->itemIcons[i].active
|
2021-04-16 05:27:05 +02:00
|
|
|
&& sPSSData->itemIcons[i].area == cursorArea
|
|
|
|
&& sPSSData->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-16 01:17:53 +02:00
|
|
|
if (sPSSData->itemIcons[i].active
|
2021-04-16 05:27:05 +02:00
|
|
|
&& sPSSData->itemIcons[i].area == cursorArea
|
|
|
|
&& sPSSData->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-16 01:17:53 +02:00
|
|
|
if (sPSSData->itemIcons[i].active
|
|
|
|
&& sPSSData->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;
|
|
|
|
sPSSData->itemIcons[id].sprite->pos1.x = (24 * x) + 112;
|
|
|
|
sPSSData->itemIcons[id].sprite->pos1.y = (24 * y) + 56;
|
2021-04-16 01:17:53 +02:00
|
|
|
sPSSData->itemIcons[id].sprite->oam.priority = 2;
|
2018-12-19 22:47:27 +01:00
|
|
|
break;
|
|
|
|
case CURSOR_AREA_IN_PARTY:
|
|
|
|
if (cursorPos == 0)
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
sPSSData->itemIcons[id].sprite->pos1.x = 116;
|
|
|
|
sPSSData->itemIcons[id].sprite->pos1.y = 76;
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
sPSSData->itemIcons[id].sprite->pos1.x = 164;
|
|
|
|
sPSSData->itemIcons[id].sprite->pos1.y = 24 * (cursorPos - 1) + 28;
|
2018-12-19 22:47:27 +01:00
|
|
|
}
|
2021-04-16 01:17:53 +02:00
|
|
|
sPSSData->itemIcons[id].sprite->oam.priority = 1;
|
2018-12-19 22:47:27 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-04-16 05:27:05 +02:00
|
|
|
sPSSData->itemIcons[id].area = cursorArea;
|
|
|
|
sPSSData->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;
|
|
|
|
|
2018-12-20 22:14:36 +01:00
|
|
|
CpuFastFill(0, sPSSData->field_42C4, 0x200);
|
2021-04-16 01:17:53 +02:00
|
|
|
LZ77UnCompWram(itemTiles, sPSSData->tileBuffer);
|
2018-12-19 22:47:27 +01:00
|
|
|
for (i = 0; i < 3; i++)
|
2021-04-16 01:17:53 +02:00
|
|
|
CpuFastCopy(&sPSSData->tileBuffer[i * 0x60], &sPSSData->field_42C4[i * 0x80], 0x60);
|
2018-12-19 22:47:27 +01:00
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
CpuFastCopy(sPSSData->field_42C4, sPSSData->itemIcons[id].tiles, 0x200);
|
2018-12-20 22:14:36 +01:00
|
|
|
LZ77UnCompWram(itemPal, sPSSData->field_42C4);
|
2021-04-16 01:17:53 +02:00
|
|
|
LoadPalette(sPSSData->field_42C4, sPSSData->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-16 01:17:53 +02:00
|
|
|
StartSpriteAffineAnim(sPSSData->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:
|
|
|
|
sPSSData->itemIcons[id].sprite->sItemIconId = id;
|
|
|
|
sPSSData->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:
|
|
|
|
sPSSData->itemIcons[id].sprite->sState = 0;
|
|
|
|
sPSSData->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:
|
|
|
|
sPSSData->itemIcons[id].sprite->sState = 0;
|
|
|
|
sPSSData->itemIcons[id].sprite->sCursorArea = cursorArea;
|
|
|
|
sPSSData->itemIcons[id].sprite->sCursorPos = cursorPos;
|
|
|
|
sPSSData->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:
|
|
|
|
sPSSData->itemIcons[id].sprite->sState = 0;
|
|
|
|
sPSSData->itemIcons[id].sprite->callback = SpriteCB_ItemIcon_SwapToHand;
|
|
|
|
sPSSData->itemIcons[id].sprite->sCursorArea = cursorArea;
|
|
|
|
sPSSData->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:
|
|
|
|
sPSSData->itemIcons[id].sprite->sState = 0;
|
|
|
|
sPSSData->itemIcons[id].sprite->sCursorArea = cursorArea;
|
|
|
|
sPSSData->itemIcons[id].sprite->sCursorPos = cursorPos;
|
|
|
|
sPSSData->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
|
|
|
|
sPSSData->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-16 01:17:53 +02:00
|
|
|
sPSSData->itemIcons[id].active = active;
|
|
|
|
sPSSData->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())
|
|
|
|
description = ItemId_GetDescription(sPSSData->movingItemId);
|
2018-12-19 22:47:27 +01:00
|
|
|
else
|
2021-04-16 05:27:05 +02:00
|
|
|
description = ItemId_GetDescription(sPSSData->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-16 01:17:53 +02:00
|
|
|
sPSSData->itemInfoWindowOffset = 21;
|
|
|
|
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-16 01:17:53 +02:00
|
|
|
if (sPSSData->itemInfoWindowOffset == 0)
|
2018-12-19 22:47:27 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
sPSSData->itemInfoWindowOffset--;
|
|
|
|
pos = 21 - sPSSData->itemInfoWindowOffset;
|
|
|
|
for (i = 0; i < pos; i++)
|
|
|
|
WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, BG_ATTR_BASETILE) + 0x14 + sPSSData->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);
|
|
|
|
return (sPSSData->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-16 01:17:53 +02:00
|
|
|
if (sPSSData->itemInfoWindowOffset == 22)
|
2018-12-19 22:47:27 +01:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
if (sPSSData->itemInfoWindowOffset == 0)
|
2018-12-19 22:47:27 +01:00
|
|
|
FillBgTilemapBufferRect(0, 0, 21, 12, 1, 9, 17);
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
sPSSData->itemInfoWindowOffset++;
|
|
|
|
pos = 21 - sPSSData->itemInfoWindowOffset;
|
|
|
|
for (i = 0; i < pos; i++)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
2021-04-16 01:17:53 +02:00
|
|
|
WriteSequenceToBgTilemapBuffer(0, GetBgAttribute(0, BG_ATTR_BASETILE) + 0x14 + sPSSData->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:
|
|
|
|
sprite->data[1] = sprite->pos1.x << 4;
|
|
|
|
sprite->data[2] = sprite->pos1.y << 4;
|
|
|
|
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];
|
|
|
|
sprite->pos1.x = sprite->data[1] >> 4;
|
|
|
|
sprite->pos1.y = sprite->data[2] >> 4;
|
|
|
|
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-04-16 05:27:05 +02:00
|
|
|
sprite->pos1.x = sPSSData->cursorSprite->pos1.x + 4;
|
|
|
|
sprite->pos1.y = sPSSData->cursorSprite->pos1.y + sPSSData->cursorSprite->pos2.y + 8;
|
|
|
|
sprite->oam.priority = sPSSData->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:
|
|
|
|
sprite->data[1] = sprite->pos1.x << 4;
|
|
|
|
sprite->data[2] = sprite->pos1.y << 4;
|
|
|
|
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];
|
|
|
|
sprite->pos1.x = sprite->data[1] >> 4;
|
|
|
|
sprite->pos1.y = sprite->data[2] >> 4;
|
|
|
|
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:
|
|
|
|
sprite->data[1] = sprite->pos1.x << 4;
|
|
|
|
sprite->data[2] = sprite->pos1.y << 4;
|
|
|
|
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];
|
|
|
|
sprite->pos1.x = sprite->data[1] >> 4;
|
|
|
|
sprite->pos1.y = sprite->data[2] >> 4;
|
|
|
|
sprite->pos2.x = gSineTable[sprite->data[5] * 8] >> 4;
|
|
|
|
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->pos2.x = 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:
|
|
|
|
sprite->data[1] = sprite->pos1.x << 4;
|
|
|
|
sprite->data[2] = sprite->pos1.y << 4;
|
|
|
|
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];
|
|
|
|
sprite->pos1.x = sprite->data[1] >> 4;
|
|
|
|
sprite->pos1.y = sprite->data[2] >> 4;
|
|
|
|
sprite->pos2.x = -(gSineTable[sprite->data[5] * 8] >> 4);
|
|
|
|
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;
|
|
|
|
sprite->pos2.x = 0;
|
|
|
|
}
|
|
|
|
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
|
|
|
{
|
|
|
|
sprite->pos1.y -= 8;
|
|
|
|
if (sprite->pos1.y + sprite->pos2.y < -16)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
|
static void ItemIconDummy_1(void)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-04-16 01:17:53 +02:00
|
|
|
static void ItemIconDummy_2(void)
|
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;
|
|
|
|
}
|
|
|
|
|
2018-12-20 22:53:08 +01:00
|
|
|
s16 sub_80D214C(struct BoxPokemon *boxMons, u8 currIndex, u8 maxIndex, u8 arg3)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
s16 i;
|
|
|
|
s16 adder = -1;
|
|
|
|
|
|
|
|
if (arg3 < 2)
|
|
|
|
adder = 1;
|
|
|
|
|
|
|
|
if (arg3 == 1 || arg3 == 3)
|
|
|
|
{
|
2018-12-20 22:53:08 +01:00
|
|
|
for (i = (s8)currIndex + adder; i >= 0 && i <= maxIndex; i += adder)
|
2018-12-19 22:47:27 +01:00
|
|
|
{
|
|
|
|
if (GetBoxMonData(&boxMons[i], MON_DATA_SPECIES) != SPECIES_NONE)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-20 22:53:08 +01:00
|
|
|
for (i = (s8)currIndex + adder; i >= 0 && i <= maxIndex; i += adder)
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
// Not sure what the purpose of these functions is.
|
|
|
|
// They seem to only be called while PSS is initialized.
|
|
|
|
|
|
|
|
EWRAM_DATA static struct UnkStruct_2039D84 *gUnknown_02039D84 = NULL;
|
|
|
|
EWRAM_DATA static u16 gUnknown_02039D88 = 0;
|
|
|
|
|
|
|
|
static void sub_80D259C(u8 count)
|
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
gUnknown_02039D84 = Alloc(sizeof(*gUnknown_02039D84) * count);
|
|
|
|
gUnknown_02039D88 = (gUnknown_02039D84 == NULL) ? 0 : count;
|
|
|
|
for (i = 0; i < gUnknown_02039D88; i++)
|
|
|
|
{
|
|
|
|
gUnknown_02039D84[i].field_18 = NULL;
|
|
|
|
gUnknown_02039D84[i].field_2C = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80D25F0(void)
|
|
|
|
{
|
|
|
|
Free(gUnknown_02039D84);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80D2604(void)
|
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
for (i = 0; i < gUnknown_02039D88; i++)
|
|
|
|
{
|
|
|
|
if (gUnknown_02039D84[i].field_2C == 1)
|
|
|
|
sub_80D2918(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
u16 a;
|
|
|
|
u16 b;
|
|
|
|
}
|
|
|
|
static const sUnkVars[][4] =
|
|
|
|
{
|
2018-12-22 23:00:22 +01:00
|
|
|
{
|
|
|
|
{0x0100, 0x0100},
|
|
|
|
{0x0200, 0x0100},
|
|
|
|
{0x0100, 0x0200},
|
|
|
|
{0x0200, 0x0200},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{0x0080, 0x0080},
|
|
|
|
{0x0100, 0x0100},
|
|
|
|
{0x0200, 0x0200},
|
|
|
|
{0x0400, 0x0400},
|
|
|
|
},
|
2018-12-20 22:14:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static void sub_80D2644(u8 id, u8 bg, const void *arg2, u16 arg3, u16 arg4)
|
|
|
|
{
|
2018-12-26 13:05:02 +01:00
|
|
|
u16 bgScreenSize, bgType;
|
2018-12-20 22:14:36 +01:00
|
|
|
|
|
|
|
if (id >= gUnknown_02039D88)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gUnknown_02039D84[id].field_18 = NULL;
|
|
|
|
gUnknown_02039D84[id].field_1C = arg2;
|
|
|
|
gUnknown_02039D84[id].field_2B = bg;
|
|
|
|
gUnknown_02039D84[id].field_24 = arg3;
|
|
|
|
gUnknown_02039D84[id].field_26 = arg4;
|
|
|
|
|
2018-12-26 13:05:02 +01:00
|
|
|
bgScreenSize = GetBgAttribute(bg, BG_ATTR_SCREENSIZE);
|
|
|
|
bgType = GetBgAttribute(bg, BG_ATTR_TYPE);
|
|
|
|
gUnknown_02039D84[id].field_20 = sUnkVars[bgType][bgScreenSize].a;
|
|
|
|
gUnknown_02039D84[id].field_22 = sUnkVars[bgType][bgScreenSize].b;
|
|
|
|
if (bgType != 0)
|
2018-12-20 22:14:36 +01:00
|
|
|
gUnknown_02039D84[id].field_2A = 1;
|
|
|
|
else
|
|
|
|
gUnknown_02039D84[id].field_2A = 2;
|
|
|
|
|
|
|
|
gUnknown_02039D84[id].field_28 = gUnknown_02039D84[id].field_2A * arg3;
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_4 = arg3;
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_6 = arg4;
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_0 = 0;
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_2 = 0;
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_8 = 0;
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_A = 0;
|
|
|
|
gUnknown_02039D84[id].field_0[0] = gUnknown_02039D84[id].field_0[1];
|
|
|
|
gUnknown_02039D84[id].field_2C = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80D2740(u8 id, const void *arg1)
|
|
|
|
{
|
|
|
|
if (id >= gUnknown_02039D88)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gUnknown_02039D84[id].field_18 = arg1;
|
|
|
|
gUnknown_02039D84[id].field_2C = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80D2770(u8 id, u16 arg1, u16 arg2)
|
|
|
|
{
|
|
|
|
if (id >= gUnknown_02039D88)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_8 = arg1;
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_A = arg2;
|
|
|
|
gUnknown_02039D84[id].field_2C = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80D27AC(u8 id, u16 arg1, u16 arg2, u16 arg3, u16 arg4)
|
|
|
|
{
|
|
|
|
if (id >= gUnknown_02039D88)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_0 = arg1;
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_2 = arg2;
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_4 = arg3;
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_6 = arg4;
|
|
|
|
gUnknown_02039D84[id].field_2C = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80D27F4(u8 id, u8 arg1, s8 arg2)
|
|
|
|
{
|
|
|
|
if (id >= gUnknown_02039D88)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (arg1)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_8 += arg2;
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_4 -= arg2;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_0 += arg2;
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_4 += arg2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_A += arg2;
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_6 -= arg2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_2 -= arg2;
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_6 += arg2;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_8 += arg2;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_A += arg2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gUnknown_02039D84[id].field_2C = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80D2918(u8 id)
|
|
|
|
{
|
|
|
|
if (id >= gUnknown_02039D88)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (gUnknown_02039D84[id].field_18 != NULL)
|
|
|
|
sub_80D2960(id);
|
|
|
|
|
|
|
|
sub_80D29F8(id);
|
|
|
|
gUnknown_02039D84[id].field_0[0] = gUnknown_02039D84[id].field_0[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80D2960(u8 id)
|
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
u32 adder = gUnknown_02039D84[id].field_2A * gUnknown_02039D84[id].field_20;
|
|
|
|
const void *tiles = (gUnknown_02039D84[id].field_18 + (adder * gUnknown_02039D84[id].field_0[0].field_A))
|
|
|
|
+ (gUnknown_02039D84[id].field_2A * gUnknown_02039D84[id].field_0[0].field_8);
|
|
|
|
|
|
|
|
for (i = 0; i < gUnknown_02039D84[id].field_0[0].field_6; i++)
|
|
|
|
{
|
|
|
|
CopyToBgTilemapBufferRect(gUnknown_02039D84[id].field_2B,
|
|
|
|
tiles,
|
|
|
|
gUnknown_02039D84[id].field_0[0].field_8,
|
|
|
|
gUnknown_02039D84[id].field_0[0].field_A + i,
|
|
|
|
gUnknown_02039D84[id].field_0[0].field_4,
|
|
|
|
1);
|
|
|
|
tiles += adder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80D29F8(u8 id)
|
|
|
|
{
|
|
|
|
s32 i;
|
|
|
|
u32 adder = gUnknown_02039D84[id].field_2A * gUnknown_02039D84[id].field_24;
|
|
|
|
const void *tiles = (gUnknown_02039D84[id].field_1C + (adder * gUnknown_02039D84[id].field_0[1].field_2))
|
|
|
|
+ (gUnknown_02039D84[id].field_2A * gUnknown_02039D84[id].field_0[1].field_0);
|
|
|
|
|
|
|
|
for (i = 0; i < gUnknown_02039D84[id].field_0[1].field_6; i++)
|
|
|
|
{
|
|
|
|
CopyToBgTilemapBufferRect(gUnknown_02039D84[id].field_2B,
|
|
|
|
tiles,
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_8,
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_A + i,
|
|
|
|
gUnknown_02039D84[id].field_0[1].field_4,
|
|
|
|
1);
|
|
|
|
tiles += adder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EWRAM_DATA static struct UnkStruct_2000020 *gUnknown_02039D8C = NULL;
|
|
|
|
|
|
|
|
static void sub_80D2A90(struct UnkStruct_2000020 *arg0, struct UnkStruct_2000028 *arg1, u32 arg2)
|
|
|
|
{
|
|
|
|
gUnknown_02039D8C = arg0;
|
|
|
|
arg0->unk_00 = arg1;
|
|
|
|
arg0->unk_05 = arg2;
|
|
|
|
arg0->unk_04 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80D2AA4(void)
|
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
if (gUnknown_02039D8C->unk_04)
|
|
|
|
{
|
|
|
|
for (i = 0; i < gUnknown_02039D8C->unk_04; i++)
|
|
|
|
{
|
|
|
|
struct UnkStruct_2000028 *unkStruct = &gUnknown_02039D8C->unk_00[i];
|
|
|
|
unkStruct->unk_0c(unkStruct);
|
|
|
|
}
|
|
|
|
|
|
|
|
gUnknown_02039D8C->unk_04 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 sub_80D2AEC(u8 *dest, u16 dLeft, u16 dTop, const u8 *src, u16 sLeft, u16 sTop, u16 width, u16 height, u16 unkArg)
|
|
|
|
{
|
|
|
|
struct UnkStruct_2000028 *unkStruct;
|
|
|
|
|
|
|
|
if (gUnknown_02039D8C->unk_04 >= gUnknown_02039D8C->unk_05)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
unkStruct = &gUnknown_02039D8C->unk_00[gUnknown_02039D8C->unk_04++];
|
|
|
|
unkStruct->unk_08 = width * 2;
|
|
|
|
unkStruct->unk_04 = dest + 2 * (dTop * 32 + dLeft);
|
|
|
|
unkStruct->unk_00 = src + 2 * (sTop * unkArg + sLeft);
|
|
|
|
unkStruct->newField = height;
|
|
|
|
unkStruct->unk_0a = unkArg;
|
|
|
|
unkStruct->unk_0c = sub_80D2B88;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80D2B88(struct UnkStruct_2000028 *unkStruct)
|
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
for (i = 0; i < unkStruct->newField; i++)
|
|
|
|
{
|
|
|
|
CpuSet(unkStruct->unk_00, unkStruct->unk_04, (unkStruct->unk_08 / 2));
|
|
|
|
unkStruct->unk_04 += 64;
|
|
|
|
unkStruct->unk_00 += (unkStruct->unk_0a * 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 sub_80D2BC0(void *dest, u16 dLeft, u16 dTop, u16 width, u16 height)
|
|
|
|
{
|
|
|
|
struct UnkStruct_2000028 *unkStruct;
|
|
|
|
|
|
|
|
if (gUnknown_02039D8C->unk_04 >= gUnknown_02039D8C->unk_05)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
unkStruct = &gUnknown_02039D8C->unk_00[gUnknown_02039D8C->unk_04++];
|
|
|
|
unkStruct->unk_08 = width * 2;
|
|
|
|
unkStruct->unk_04 = dest + ((dTop * 32) + dLeft) * 2;
|
|
|
|
unkStruct->newField = height;
|
|
|
|
unkStruct->unk_0c = sub_80D2C1C;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80D2C1C(struct UnkStruct_2000028 *unkStruct)
|
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
for (i = 0; i < unkStruct->newField; i++)
|
|
|
|
{
|
|
|
|
Dma3FillLarge_(0, unkStruct->unk_04, unkStruct->unk_08, 16);
|
|
|
|
unkStruct->unk_04 += 64;
|
|
|
|
}
|
|
|
|
}
|