2017-12-04 23:09:44 +01:00
|
|
|
#include "global.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "pokeblock.h"
|
2019-09-09 03:07:54 +02:00
|
|
|
#include "malloc.h"
|
2019-03-23 23:19:08 +01:00
|
|
|
#include "decompress.h"
|
|
|
|
#include "graphics.h"
|
2017-12-09 21:23:40 +01:00
|
|
|
#include "palette.h"
|
|
|
|
#include "pokenav.h"
|
2019-03-08 08:17:01 +01:00
|
|
|
#include "menu_specialized.h"
|
2018-01-29 17:47:12 +01:00
|
|
|
#include "scanline_effect.h"
|
2017-12-09 21:23:40 +01:00
|
|
|
#include "text.h"
|
|
|
|
#include "bg.h"
|
|
|
|
#include "window.h"
|
|
|
|
#include "text_window.h"
|
2019-02-23 18:08:07 +01:00
|
|
|
#include "constants/rgb.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "constants/songs.h"
|
|
|
|
#include "sprite.h"
|
|
|
|
#include "string_util.h"
|
|
|
|
#include "strings.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "gpu_regs.h"
|
|
|
|
#include "graphics.h"
|
2019-04-04 23:53:06 +02:00
|
|
|
#include "pokemon_summary_screen.h"
|
|
|
|
#include "item_menu.h"
|
2017-12-04 23:09:44 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
/*
|
|
|
|
This file handles the pokeblock screen where the player
|
|
|
|
chooses which pokemon to give a pokeblock to. The subsequent
|
|
|
|
scene of feeding the pokeblock to the pokemon is handled by
|
|
|
|
pokeblock_feed.c, and the rest of the pokeblock menu (and
|
|
|
|
other pokeblock-related functions) are in pokeblock.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum {
|
|
|
|
WIN_NAME,
|
|
|
|
WIN_NATURE,
|
|
|
|
WIN_TEXT,
|
|
|
|
WIN_COUNT
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UsePokeblockSession
|
2017-12-04 23:09:44 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
/*0x00*/ void (*callback)(void);
|
|
|
|
/*0x04*/ void (*exitCallback)(void);
|
2019-03-23 15:39:46 +01:00
|
|
|
/*0x08*/ struct Pokeblock *pokeblock;
|
2019-03-31 12:59:01 +02:00
|
|
|
/*0x0C*/ struct Pokemon *mon;
|
2019-03-23 15:39:46 +01:00
|
|
|
/*0x10*/ u8 stringBuffer[0x40];
|
2020-08-10 19:48:16 +02:00
|
|
|
/*0x50*/ u8 mainState;
|
|
|
|
/*0x51*/ u8 field_51; // unused
|
2019-03-23 15:39:46 +01:00
|
|
|
/*0x52*/ u8 field_52;
|
|
|
|
/*0x53*/ u8 field_53;
|
2020-08-10 19:48:16 +02:00
|
|
|
/*0x54*/ u8 numEnhancements;
|
|
|
|
/*0x55*/ u8 field_55; // unused
|
2019-03-23 15:39:46 +01:00
|
|
|
/*0x56*/ u8 field_56;
|
2020-08-10 19:48:16 +02:00
|
|
|
/*0x57*/ u8 field_57[FLAVOR_COUNT];
|
|
|
|
/*0x5C*/ u8 field_5c[FLAVOR_COUNT];
|
|
|
|
/*0x61*/ u8 field_61[FLAVOR_COUNT];
|
|
|
|
/*0x66*/ s16 field_66[FLAVOR_COUNT];
|
|
|
|
/*0x70*/ u8 field_70; // mon id + 1
|
|
|
|
/*0x71*/ u8 field_71; // mon id
|
|
|
|
/*0x74*/ u8 (*unk74)(void); // selection handler
|
|
|
|
/*0x78*/ u8 helperState;
|
|
|
|
/*0x79*/ u8 filler79[1]; // unused
|
|
|
|
/*0x7A*/ u8 field_7A[0x22]; // nature text buffer
|
2017-12-04 23:09:44 +01:00
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
// This struct is identical to PokenavMonList, the struct used for managing lists of pokemon in the pokenav
|
|
|
|
// Given that this screen is essentially duplicated in the poknav, this struct was probably the same one with
|
|
|
|
// a more general name/purpose
|
|
|
|
// TODO: Once the pokenav conditions screens are documented, resolve the above
|
|
|
|
struct UsePokeblockMenuPokemon
|
2019-03-23 17:16:53 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
u8 boxId; // Because this screen is never used for the PC this is always set to TOTAL_BOXES_COUNT to refer to party
|
|
|
|
u8 monId;
|
|
|
|
u16 data; // never read
|
2019-03-23 17:16:53 +01:00
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
struct UsePokeblockMenu
|
2017-12-04 23:09:44 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
/*0x0000*/ u8 filler0[4]; // unused
|
|
|
|
/*0x0000*/ u16 field_4[6][0x40]; // pal buffer
|
|
|
|
/*0x0304*/ u8 field_304[3][0x2000]; // sheet buffer
|
|
|
|
/*0x6304*/ u8 filler_6304[0x1000]; // unused?
|
2019-03-31 14:32:26 +02:00
|
|
|
/*0x7304*/ u8 tilemapBuffer[BG_SCREEN_SIZE + 2];
|
2020-08-10 19:48:16 +02:00
|
|
|
/*0x7B06*/ u8 field_7B06[7]; // sprite ids
|
|
|
|
/*0x7B0E*/ s16 field_7B0E; // x pos?
|
|
|
|
/*0x7B10*/ u8 field_7B10; // sprite id?
|
|
|
|
/*0x7B12*/ u16 field_7B12; // pal
|
|
|
|
/*0x7B12*/ u16 field_7B14; // sheet
|
2019-03-31 12:59:01 +02:00
|
|
|
/*0x7B12*/ u8 *field_7B18;
|
2020-08-10 19:48:16 +02:00
|
|
|
/*0x7B1C*/ struct Sprite *sparkles[10];
|
|
|
|
/*0x7B44*/ struct Sprite *condition[2];
|
2019-03-23 23:19:08 +01:00
|
|
|
/*0x7B4C*/ u8 field_7B4C;
|
2019-03-31 14:32:26 +02:00
|
|
|
/*0x7B4D*/ u8 field_7B4D[3][24];
|
2019-03-23 23:19:08 +01:00
|
|
|
/*0x7B95*/ u8 field_7B95[3][64];
|
2019-03-23 15:39:46 +01:00
|
|
|
/*0x7C58*/ struct UnknownStruct_81D1ED4 field_7C58;
|
2019-03-23 16:10:51 +01:00
|
|
|
/*0x7FB0*/ u8 unk7FB0[3];
|
2019-03-23 17:22:41 +01:00
|
|
|
/*0x7FB3*/ s8 field_7FB3;
|
|
|
|
/*0x7FB4*/ s8 field_7FB4;
|
|
|
|
/*0x7FB5*/ s8 field_7FB5;
|
2019-03-23 23:19:08 +01:00
|
|
|
/*0x7FB6*/ s8 field_7FB6;
|
2020-08-10 19:48:16 +02:00
|
|
|
/*0x7FB8*/ struct UsePokeblockMenuPokemon party[PARTY_SIZE];
|
|
|
|
/*0x7FD0*/ struct UsePokeblockSession info;
|
2017-12-04 23:09:44 +01:00
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
#define TAG_UP_DOWN 0
|
|
|
|
#define TAG_CONDITION 1
|
|
|
|
|
|
|
|
static void SetUsePokeblockCallback(void (*func)(void));
|
|
|
|
static void LoadUsePokeblockMenu(void);
|
|
|
|
static void sub_816631C(void);
|
|
|
|
static void sub_81662C0(void);
|
|
|
|
static void ShowUsePokeblockMenu(void);
|
|
|
|
static void sub_8166304(void);
|
|
|
|
static void sub_81668F8(void);
|
|
|
|
static void sub_8167420(void);
|
|
|
|
static void sub_8167760(void);
|
|
|
|
static u8 GetNumNonEggPartyMons(u8);
|
2019-03-23 23:19:08 +01:00
|
|
|
static bool8 sub_8168328(void);
|
2020-08-10 19:48:16 +02:00
|
|
|
static bool8 LoadUsePokeblockGfx(void);
|
|
|
|
static void sub_8167608(u8);
|
|
|
|
static void UpdateMonInfoText(u16, bool8);
|
|
|
|
static void UsePokeblockMenu(void);
|
2019-03-23 23:19:08 +01:00
|
|
|
static void sub_8167CA0(bool8);
|
2020-08-10 19:48:16 +02:00
|
|
|
static void CloseUsePokeblockMenu(void);
|
|
|
|
static void AskUsePokeblock(void);
|
|
|
|
static s8 HandleAskUsePokeblockInput(void);
|
|
|
|
static bool8 IsSheenMaxed(void);
|
|
|
|
static void PrintWontEatAnymore(void);
|
|
|
|
static void FeedPokeblockToMon(void);
|
|
|
|
static void EraseMenuWindow(void);
|
|
|
|
static u8 sub_81672A4(u8);
|
|
|
|
static void sub_8166A34(void);
|
|
|
|
static void sub_8167104(void);
|
|
|
|
static void sub_8167338(void);
|
|
|
|
static void sub_81681F4(u8);
|
|
|
|
static void sub_8166E24(void);
|
|
|
|
static bool8 sub_8166EDC(void);
|
|
|
|
static void BufferEnhancedStatText(u8 *, u8, s16);
|
|
|
|
static void PrintMenuWindowText(const u8 *);
|
|
|
|
static void sub_8167184(struct Pokeblock *, struct Pokemon *);
|
|
|
|
static void sub_81673DC(struct Sprite *);
|
|
|
|
static void sub_81674BC(void);
|
|
|
|
static void sub_816753C(s16, u8);
|
2019-03-23 23:19:08 +01:00
|
|
|
static u8 sub_8167EA4(void);
|
|
|
|
static u8 sub_8167FA4(void);
|
|
|
|
static u8 sub_8168048(void);
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_8168180(struct Sprite *);
|
|
|
|
static void sub_81681B4(struct Sprite *);
|
|
|
|
static void sub_8168168(struct Sprite *);
|
|
|
|
static void sub_8168374(struct Sprite *);
|
2017-12-09 21:23:40 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
extern const u16 gConditionGraphData_Pal[];
|
2019-02-23 18:08:07 +01:00
|
|
|
extern const u16 gUnknown_08623208[];
|
2019-03-23 23:19:08 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
// The below 3 are saved for returning to the screen after feeding a pokeblock to a mon
|
|
|
|
// so that the rest of the data can be freed
|
|
|
|
static EWRAM_DATA struct UsePokeblockSession *sInfo = NULL;
|
|
|
|
static EWRAM_DATA void (*sExitCallback)(void) = NULL;
|
|
|
|
static EWRAM_DATA struct Pokeblock *sPokeblock = NULL;
|
2017-12-10 16:38:27 +01:00
|
|
|
EWRAM_DATA u8 gPokeblockMonId = 0;
|
|
|
|
EWRAM_DATA s16 gPokeblockGain = 0;
|
2020-08-10 19:48:16 +02:00
|
|
|
static EWRAM_DATA u8 *sGraph_Tilemap = NULL;
|
|
|
|
static EWRAM_DATA u8 *sGraph_Gfx = NULL;
|
|
|
|
static EWRAM_DATA u8 *sMonFrame_TilemapPtr = NULL;
|
|
|
|
static EWRAM_DATA struct UsePokeblockMenu *sMenu = NULL;
|
2017-12-10 19:02:51 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const u32 sMonFrame_Pal[] = INCBIN_U32("graphics/pokeblock/use_screen/mon_frame_pal.bin"); // TODO: convert to .pal
|
|
|
|
static const u32 sMonFrame_Gfx[] = INCBIN_U32("graphics/pokeblock/use_screen/mon_frame.4bpp");
|
|
|
|
static const u32 sMonFrame_Tilemap[] = INCBIN_U32("graphics/pokeblock/use_screen/mon_frame.bin");
|
|
|
|
static const u32 sGraphData_Tilemap[] = INCBIN_U32("graphics/pokeblock/use_screen/graph_data.bin");
|
2019-07-31 02:21:17 +02:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const u32 gUnknown_085DFCB0[] =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
2019-07-31 02:25:19 +02:00
|
|
|
MON_DATA_COOL,
|
|
|
|
MON_DATA_TOUGH,
|
|
|
|
MON_DATA_SMART,
|
|
|
|
MON_DATA_CUTE,
|
|
|
|
MON_DATA_BEAUTY
|
2019-07-31 02:21:17 +02:00
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const u8 sFlavors[FLAVOR_COUNT] =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
FLAVOR_SPICY,
|
|
|
|
FLAVOR_SOUR,
|
|
|
|
FLAVOR_BITTER,
|
|
|
|
FLAVOR_SWEET,
|
|
|
|
FLAVOR_DRY
|
2019-07-31 02:21:17 +02:00
|
|
|
};
|
|
|
|
|
2019-12-10 19:48:20 +01:00
|
|
|
static const u8 sNatureTextColors[] =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
2019-12-10 19:48:20 +01:00
|
|
|
TEXT_COLOR_TRANSPARENT,
|
|
|
|
TEXT_COLOR_BLUE,
|
|
|
|
TEXT_COLOR_WHITE
|
2019-07-31 02:21:17 +02:00
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const struct BgTemplate sBgTemplates[4] =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
2019-07-31 02:25:19 +02:00
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.charBaseIndex = 2,
|
|
|
|
.mapBaseIndex = 0x1F,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.baseTile = 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 1,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 0x1E,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 3,
|
|
|
|
.baseTile = 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 3,
|
|
|
|
.charBaseIndex = 3,
|
|
|
|
.mapBaseIndex = 0x1D,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 2,
|
|
|
|
.baseTile = 0x100
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 2,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 0x17,
|
|
|
|
.screenSize = 0,
|
|
|
|
.paletteMode = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.baseTile = 0
|
|
|
|
}
|
2019-07-31 02:21:17 +02:00
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const struct WindowTemplate sWindowTemplates[WIN_COUNT + 1] =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
[WIN_NAME] = {
|
2019-07-31 02:25:19 +02:00
|
|
|
.bg = 0,
|
2020-08-10 19:48:16 +02:00
|
|
|
.tilemapLeft = 13,
|
2019-07-31 02:25:19 +02:00
|
|
|
.tilemapTop = 1,
|
2020-08-10 19:48:16 +02:00
|
|
|
.width = 13,
|
2019-07-31 02:25:19 +02:00
|
|
|
.height = 4,
|
2020-08-10 19:48:16 +02:00
|
|
|
.paletteNum = 15,
|
2019-07-31 02:25:19 +02:00
|
|
|
.baseBlock = 1
|
|
|
|
},
|
2020-08-10 19:48:16 +02:00
|
|
|
[WIN_NATURE] = {
|
2019-07-31 02:25:19 +02:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 0,
|
2020-08-10 19:48:16 +02:00
|
|
|
.tilemapTop = 14,
|
|
|
|
.width = 11,
|
2019-07-31 02:25:19 +02:00
|
|
|
.height = 2,
|
2020-08-10 19:48:16 +02:00
|
|
|
.paletteNum = 15,
|
2019-07-31 02:25:19 +02:00
|
|
|
.baseBlock = 0x35
|
|
|
|
},
|
2020-08-10 19:48:16 +02:00
|
|
|
[WIN_TEXT] = {
|
2019-07-31 02:25:19 +02:00
|
|
|
.bg = 0,
|
|
|
|
.tilemapLeft = 1,
|
2020-08-10 19:48:16 +02:00
|
|
|
.tilemapTop = 17,
|
|
|
|
.width = 28,
|
2019-07-31 02:25:19 +02:00
|
|
|
.height = 2,
|
2020-08-10 19:48:16 +02:00
|
|
|
.paletteNum = 15,
|
2019-07-31 02:25:19 +02:00
|
|
|
.baseBlock = 0x4B
|
|
|
|
},
|
|
|
|
DUMMY_WIN_TEMPLATE
|
2019-07-31 02:21:17 +02:00
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const struct WindowTemplate sUsePokeblockYesNoWinTemplate =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
2019-07-31 02:25:19 +02:00
|
|
|
.bg = 0,
|
2020-08-10 19:48:16 +02:00
|
|
|
.tilemapLeft = 24,
|
|
|
|
.tilemapTop = 11,
|
2019-07-31 02:25:19 +02:00
|
|
|
.width = 5,
|
|
|
|
.height = 4,
|
2020-08-10 19:48:16 +02:00
|
|
|
.paletteNum = 15,
|
2019-07-31 02:25:19 +02:00
|
|
|
.baseBlock = 0x83
|
2019-07-31 02:21:17 +02:00
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const u8 *const sContestStatNames[] =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
2019-07-31 02:25:19 +02:00
|
|
|
gText_Coolness,
|
|
|
|
gText_Toughness,
|
|
|
|
gText_Smartness,
|
|
|
|
gText_Cuteness,
|
|
|
|
gText_Beauty3
|
2019-07-31 02:21:17 +02:00
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const struct SpriteSheet sSpriteSheet_UpDown =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
gUsePokeblockUpDown_Gfx, 0x200, TAG_UP_DOWN
|
2019-07-31 02:21:17 +02:00
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const struct SpritePalette sSpritePalette_UpDown =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
gUsePokeblockUpDown_Pal, TAG_UP_DOWN
|
2019-07-31 02:21:17 +02:00
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const s16 gUnknown_085DFD28[][2] =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
2019-07-31 02:25:19 +02:00
|
|
|
{0x9C, 0x24},
|
|
|
|
{0x75, 0x3B},
|
|
|
|
{0x75, 0x76},
|
|
|
|
{0xC5, 0x76},
|
|
|
|
{0xC5, 0x3B}
|
2019-07-31 02:21:17 +02:00
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const struct OamData sOam_UpDown =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-12-04 21:25:13 +01:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-07-31 02:21:17 +02:00
|
|
|
.shape = SPRITE_SHAPE(32x16),
|
|
|
|
.x = 0,
|
|
|
|
.size = SPRITE_SIZE(32x16),
|
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.paletteNum = 0,
|
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const union AnimCmd sAnim_Up[] =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const union AnimCmd sAnim_Down[] =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(8, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const union AnimCmd *const sAnims_UpDown[] =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sAnim_Up,
|
|
|
|
sAnim_Down
|
2019-07-31 02:21:17 +02:00
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_UpDown =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
.tileTag = TAG_UP_DOWN,
|
|
|
|
.paletteTag = TAG_UP_DOWN,
|
|
|
|
.oam = &sOam_UpDown,
|
|
|
|
.anims = sAnims_UpDown,
|
2019-07-31 02:21:17 +02:00
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy,
|
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const struct OamData sOam_Condition =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-12-04 21:25:13 +01:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-07-31 02:21:17 +02:00
|
|
|
.shape = SPRITE_SHAPE(64x32),
|
|
|
|
.x = 0,
|
|
|
|
.size = SPRITE_SIZE(64x32),
|
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 1,
|
|
|
|
.paletteNum = 0,
|
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const union AnimCmd gSpriteAnim_085DFD7C[] =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const union AnimCmd gSpriteAnim_085DFD84[] =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(32, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const union AnimCmd gSpriteAnim_085DFD8C[] =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(64, 5),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const union AnimCmd *const sAnims_Condition[] =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
|
|
|
gSpriteAnim_085DFD7C,
|
|
|
|
gSpriteAnim_085DFD84,
|
|
|
|
gSpriteAnim_085DFD8C
|
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_Condition =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
.tileTag = TAG_CONDITION,
|
|
|
|
.paletteTag = TAG_CONDITION,
|
|
|
|
.oam = &sOam_Condition,
|
|
|
|
.anims = sAnims_Condition,
|
2019-07-31 02:21:17 +02:00
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = sub_8168374,
|
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static const struct SpritePalette sSpritePalette_Condition =
|
2019-07-31 02:21:17 +02:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
gUsePokeblockCondition_Pal, TAG_CONDITION
|
2019-07-31 02:21:17 +02:00
|
|
|
};
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
// When first opening the selection screen
|
2017-12-09 21:23:40 +01:00
|
|
|
void ChooseMonToGivePokeblock(struct Pokeblock *pokeblock, void (*callback)(void))
|
2017-12-04 23:09:44 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu = AllocZeroed(sizeof(*sMenu));
|
|
|
|
sInfo = &sMenu->info;
|
|
|
|
sInfo->pokeblock = pokeblock;
|
|
|
|
sInfo->exitCallback = callback;
|
|
|
|
SetUsePokeblockCallback(LoadUsePokeblockMenu);
|
2017-12-04 23:09:44 +01:00
|
|
|
SetMainCallback2(sub_816631C);
|
|
|
|
}
|
2017-12-09 21:23:40 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
// When returning to the selection screen after feeding a pokeblock to a mon
|
|
|
|
static void CB2_ReturnAndChooseMonToGivePokeblock(void)
|
2017-12-09 21:23:40 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu = AllocZeroed(sizeof(*sMenu));
|
|
|
|
sInfo = &sMenu->info;
|
|
|
|
sInfo->pokeblock = sPokeblock;
|
|
|
|
sInfo->exitCallback = sExitCallback;
|
|
|
|
gPokeblockMonId = GetNumNonEggPartyMons(gPokeblockMonId);
|
|
|
|
sInfo->field_56 = gPokeblockMonId < 4 ? 0 : 1;
|
|
|
|
SetUsePokeblockCallback(LoadUsePokeblockMenu);
|
2017-12-09 21:23:40 +01:00
|
|
|
SetMainCallback2(sub_81662C0);
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_81662C0(void)
|
2017-12-09 21:23:40 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->callback();
|
2017-12-09 21:23:40 +01:00
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
|
|
|
UpdatePaletteFade();
|
2020-08-10 19:48:16 +02:00
|
|
|
if (sInfo->callback == ShowUsePokeblockMenu)
|
2017-12-09 21:23:40 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState = 0;
|
2017-12-09 21:23:40 +01:00
|
|
|
SetMainCallback2(sub_8166304);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_8166304(void)
|
2017-12-09 21:23:40 +01:00
|
|
|
{
|
|
|
|
sub_81668F8();
|
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
|
|
|
UpdatePaletteFade();
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_816631C(void)
|
2017-12-09 21:23:40 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->callback();
|
2017-12-09 21:23:40 +01:00
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
|
|
|
RunTextPrinters();
|
|
|
|
UpdatePaletteFade();
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void VBlankCB_UsePokeblock(void)
|
2017-12-09 21:23:40 +01:00
|
|
|
{
|
|
|
|
LoadOam();
|
|
|
|
ProcessSpriteCopyRequests();
|
|
|
|
TransferPlttBuffer();
|
2020-08-10 19:48:16 +02:00
|
|
|
sub_81D2108(&sMenu->field_7C58);
|
2018-01-29 17:47:12 +01:00
|
|
|
ScanlineEffect_InitHBlankDmaTransfer();
|
2017-12-09 21:23:40 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void SetUsePokeblockCallback(void (*func)(void))
|
2017-12-09 21:23:40 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->callback = func;
|
|
|
|
sInfo->mainState = 0;
|
2017-12-09 21:23:40 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void LoadUsePokeblockMenu(void)
|
2017-12-09 21:23:40 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
switch (sInfo->mainState)
|
2017-12-09 21:23:40 +01:00
|
|
|
{
|
2019-03-23 16:41:09 +01:00
|
|
|
case 0:
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->field_7B10 = 0xFF;
|
|
|
|
sub_81D1ED4(&sMenu->field_7C58);
|
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ResetSpriteData();
|
|
|
|
FreeAllSpritePalettes();
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
SetVBlankCallback(NULL);
|
|
|
|
CpuFill32(0, (void*)(VRAM), VRAM_SIZE);
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
ResetBgsAndClearDma3BusyFlags(0);
|
2020-08-10 19:48:16 +02:00
|
|
|
InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
|
|
|
|
InitWindows(sWindowTemplates);
|
2019-03-23 16:41:09 +01:00
|
|
|
DeactivateAllTextPrinters();
|
|
|
|
LoadUserWindowBorderGfx(0, 0x97, 0xE0);
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if (!sub_8168328())
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
gKeyRepeatStartDelay = 20;
|
|
|
|
sub_8167420();
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 7:
|
2020-08-10 19:48:16 +02:00
|
|
|
if (!LoadUsePokeblockGfx())
|
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
sub_8167608(0);
|
|
|
|
sub_8167760();
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 9:
|
2020-08-10 19:48:16 +02:00
|
|
|
if (!sub_81D312C(&sMenu->field_7B0E))
|
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 10:
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 11:
|
2020-08-10 19:48:16 +02:00
|
|
|
sub_81D2754(sMenu->field_7C58.unk0[0], sMenu->field_7C58.unk14[0]);
|
|
|
|
sub_81D20AC(&sMenu->field_7C58);
|
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 12:
|
2020-08-10 19:48:16 +02:00
|
|
|
if (!sub_81D20BC(&sMenu->field_7C58))
|
2019-03-23 16:41:09 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sub_81D1F84(&sMenu->field_7C58, sMenu->field_7C58.unk14[0], sMenu->field_7C58.unk14[0]);
|
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 13:
|
2020-08-10 19:48:16 +02:00
|
|
|
sub_81D2230(&sMenu->field_7C58);
|
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 14:
|
2020-08-10 19:48:16 +02:00
|
|
|
PutWindowTilemap(WIN_NAME);
|
|
|
|
PutWindowTilemap(WIN_NATURE);
|
|
|
|
UpdateMonInfoText(0, TRUE);
|
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 15:
|
2020-08-10 19:48:16 +02:00
|
|
|
SetUsePokeblockCallback(ShowUsePokeblockMenu);
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
2017-12-09 21:23:40 +01:00
|
|
|
}
|
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void ShowUsePokeblockMenu(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
switch (sInfo->mainState)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-23 16:41:09 +01:00
|
|
|
case 0:
|
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
|
2020-08-10 19:48:16 +02:00
|
|
|
SetVBlankCallback(VBlankCB_UsePokeblock);
|
2019-03-23 16:41:09 +01:00
|
|
|
ShowBg(0);
|
|
|
|
ShowBg(1);
|
|
|
|
ShowBg(3);
|
|
|
|
ShowBg(2);
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
ResetConditionSparkleSprites(sMenu->sparkles);
|
|
|
|
if (sMenu->info.field_71 != sMenu->info.field_70 - 1)
|
2019-03-23 16:10:51 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
u8 var0 = sMenu->unk7FB0[sMenu->field_7FB3];
|
|
|
|
CreateConditionSparkleSprites(sMenu->sparkles, sMenu->field_7B10, var0);
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
2019-03-23 16:41:09 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
SetUsePokeblockCallback(UsePokeblockMenu);
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
|
|
|
break;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
enum {
|
|
|
|
STATE_HANDLE_INPUT,
|
|
|
|
STATE_UPDATE_SELECTION,
|
|
|
|
STATE_2, // unused state
|
|
|
|
STATE_CLOSE,
|
|
|
|
STATE_4, // unused state
|
|
|
|
STATE_CONFIRM_SELECTION,
|
|
|
|
STATE_HANDLE_CONFIRMATION,
|
|
|
|
STATE_WAIT_MSG,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void UsePokeblockMenu(void)
|
2019-03-31 12:59:01 +02:00
|
|
|
{
|
2019-03-23 16:41:09 +01:00
|
|
|
u8 var;
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
switch (sInfo->mainState)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
case STATE_HANDLE_INPUT:
|
|
|
|
if (JOY_HELD(DPAD_UP))
|
2019-03-23 16:41:09 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
sub_8167CA0(TRUE);
|
2020-08-10 19:48:16 +02:00
|
|
|
DestroyConditionSparkleSprites(sMenu->sparkles);
|
|
|
|
sInfo->mainState = STATE_UPDATE_SELECTION;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
2020-08-10 19:48:16 +02:00
|
|
|
else if (JOY_HELD(DPAD_DOWN))
|
2019-03-23 16:41:09 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
sub_8167CA0(FALSE);
|
2020-08-10 19:48:16 +02:00
|
|
|
DestroyConditionSparkleSprites(sMenu->sparkles);
|
|
|
|
sInfo->mainState = STATE_UPDATE_SELECTION;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
2020-08-10 19:48:16 +02:00
|
|
|
else if (JOY_NEW(B_BUTTON))
|
2019-03-23 16:41:09 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState = STATE_CLOSE;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
2020-08-10 19:48:16 +02:00
|
|
|
else if (JOY_NEW(A_BUTTON))
|
2019-03-23 16:41:09 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2020-08-10 19:48:16 +02:00
|
|
|
|
|
|
|
// If last item, selected Cancel. Otherwise selected mon
|
|
|
|
if (sMenu->info.field_71 == sMenu->info.field_70 - 1)
|
|
|
|
sInfo->mainState = STATE_CLOSE;
|
2019-03-23 16:41:09 +01:00
|
|
|
else
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState = STATE_CONFIRM_SELECTION;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
|
|
|
break;
|
2020-08-10 19:48:16 +02:00
|
|
|
case STATE_UPDATE_SELECTION:
|
|
|
|
var = sMenu->info.unk74();
|
2019-03-31 12:59:01 +02:00
|
|
|
if (!var)
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState = STATE_HANDLE_INPUT;
|
2019-03-31 12:59:01 +02:00
|
|
|
break;
|
2020-08-10 19:48:16 +02:00
|
|
|
case STATE_2:
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
2020-08-10 19:48:16 +02:00
|
|
|
case STATE_CLOSE:
|
|
|
|
SetUsePokeblockCallback(CloseUsePokeblockMenu);
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
2020-08-10 19:48:16 +02:00
|
|
|
case STATE_4:
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
2020-08-10 19:48:16 +02:00
|
|
|
case STATE_CONFIRM_SELECTION:
|
|
|
|
AskUsePokeblock();
|
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
2020-08-10 19:48:16 +02:00
|
|
|
case STATE_HANDLE_CONFIRMATION:
|
|
|
|
switch (HandleAskUsePokeblockInput())
|
2019-03-23 16:41:09 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
case 1: // NO
|
|
|
|
case MENU_B_PRESSED:
|
|
|
|
sInfo->mainState = STATE_HANDLE_INPUT;
|
2019-02-23 18:08:07 +01:00
|
|
|
break;
|
2020-08-10 19:48:16 +02:00
|
|
|
case 0: // YES
|
2019-03-31 12:59:01 +02:00
|
|
|
if (IsSheenMaxed())
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
PrintWontEatAnymore();
|
|
|
|
sInfo->mainState = STATE_WAIT_MSG;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
2019-03-23 16:41:09 +01:00
|
|
|
else
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
SetUsePokeblockCallback(FeedPokeblockToMon);
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
break;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
|
|
|
break;
|
2020-08-10 19:48:16 +02:00
|
|
|
case STATE_WAIT_MSG:
|
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON))
|
2019-03-23 16:41:09 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
EraseMenuWindow();
|
|
|
|
sInfo->mainState = STATE_HANDLE_INPUT;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
|
|
|
break;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void FeedPokeblockToMon(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
switch (sInfo->mainState)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-23 16:41:09 +01:00
|
|
|
case 0:
|
2020-08-10 19:48:16 +02:00
|
|
|
gPokeblockMonId = sub_81672A4(sMenu->info.field_71);
|
|
|
|
sExitCallback = sInfo->exitCallback;
|
|
|
|
sPokeblock = sInfo->pokeblock;
|
2019-03-23 16:41:09 +01:00
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
SetVBlankCallback(NULL);
|
2020-08-10 19:48:16 +02:00
|
|
|
FREE_AND_SET_NULL(sGraph_Tilemap);
|
|
|
|
FREE_AND_SET_NULL(sGraph_Gfx);
|
|
|
|
FREE_AND_SET_NULL(sMonFrame_TilemapPtr);
|
|
|
|
FREE_AND_SET_NULL(sMenu);
|
2019-03-23 16:41:09 +01:00
|
|
|
FreeAllWindowBuffers();
|
|
|
|
gMain.savedCallback = CB2_ReturnAndChooseMonToGivePokeblock;
|
|
|
|
CB2_PreparePokeblockFeedScene();
|
|
|
|
}
|
|
|
|
break;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_81668F8(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-23 16:41:09 +01:00
|
|
|
u16 var;
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
switch (sInfo->mainState)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-23 16:41:09 +01:00
|
|
|
case 0:
|
2020-08-10 19:48:16 +02:00
|
|
|
if (sMenu->info.field_71 != gPokeblockMonId)
|
2019-03-23 16:41:09 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sub_8167CA0(sInfo->field_56);
|
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState = 3;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2020-08-10 19:48:16 +02:00
|
|
|
var = sMenu->info.unk74();
|
2019-03-23 16:41:09 +01:00
|
|
|
if (!var)
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState = var;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
BlendPalettes(0xFFFFFFFF, 16, RGB_BLACK);
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
ShowBg(0);
|
|
|
|
ShowBg(1);
|
|
|
|
ShowBg(3);
|
|
|
|
ShowBg(2);
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 5:
|
2020-08-10 19:48:16 +02:00
|
|
|
SetVBlankCallback(VBlankCB_UsePokeblock);
|
2019-03-23 16:41:09 +01:00
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
ResetConditionSparkleSprites(sMenu->sparkles);
|
|
|
|
SetUsePokeblockCallback(sub_8166A34);
|
2019-03-23 16:41:09 +01:00
|
|
|
SetMainCallback2(sub_816631C);
|
|
|
|
}
|
|
|
|
break;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_8166A34(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-31 12:59:01 +02:00
|
|
|
u8 var;
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
switch (sInfo->mainState)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-31 12:59:01 +02:00
|
|
|
case 0:
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mon = gPlayerParty;
|
|
|
|
sInfo->mon += sMenu->party[sMenu->info.field_71].monId;
|
|
|
|
DestroyConditionSparkleSprites(sMenu->sparkles);
|
|
|
|
sInfo->mainState++;
|
2019-03-31 12:59:01 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-08-10 19:48:16 +02:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON))
|
|
|
|
sInfo->mainState++;
|
2019-03-31 12:59:01 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
sub_8167104();
|
2020-08-10 19:48:16 +02:00
|
|
|
sub_81D2754(sInfo->field_5c, sMenu->field_7C58.unk14[3]);
|
|
|
|
sub_81D1F84(&sMenu->field_7C58, sMenu->field_7C58.unk14[sMenu->field_7FB3], sMenu->field_7C58.unk14[3]);
|
2019-03-31 12:59:01 +02:00
|
|
|
sub_8167338();
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-31 12:59:01 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-08-10 19:48:16 +02:00
|
|
|
var = sub_81D2074(&sMenu->field_7C58);
|
2019-03-31 12:59:01 +02:00
|
|
|
if (!var)
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sub_81681F4(sub_81672A4(sMenu->info.field_71));
|
|
|
|
if (sMenu->info.field_71 != sMenu->info.field_70 - 1)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
u8 var0 = sMenu->unk7FB0[sMenu->field_7FB3];
|
|
|
|
CreateConditionSparkleSprites(sMenu->sparkles, sMenu->field_7B10, var0);
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->field_52 = 0;
|
|
|
|
sInfo->mainState++;
|
2019-03-31 12:59:01 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
2020-08-10 19:48:16 +02:00
|
|
|
if (++sInfo->field_52 > 16)
|
2019-03-31 12:59:01 +02:00
|
|
|
{
|
|
|
|
sub_8166E24();
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-31 12:59:01 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
2020-08-10 19:48:16 +02:00
|
|
|
if (JOY_NEW(A_BUTTON | B_BUTTON) && !sub_8166EDC())
|
2019-03-31 12:59:01 +02:00
|
|
|
{
|
|
|
|
TryClearPokeblock((u8)gSpecialVar_ItemId);
|
2020-08-10 19:48:16 +02:00
|
|
|
SetUsePokeblockCallback(CloseUsePokeblockMenu);
|
2019-03-31 12:59:01 +02:00
|
|
|
}
|
|
|
|
break;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void CloseUsePokeblockMenu(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-31 12:59:01 +02:00
|
|
|
u8 i, var;
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
switch (sInfo->mainState)
|
2019-03-31 12:59:01 +02:00
|
|
|
{
|
2019-03-23 16:41:09 +01:00
|
|
|
case 0:
|
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!gPaletteFade.active)
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState = 2;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
gScanlineEffect.state = 3;
|
|
|
|
ScanlineEffect_InitHBlankDmaTransfer();
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->mainState++;
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-08-10 19:48:16 +02:00
|
|
|
SetMainCallback2(sInfo->exitCallback);
|
|
|
|
FreeConditionSparkles(sMenu->sparkles);
|
|
|
|
for (i = 0; i < ARRAY_COUNT(sMenu->field_7B06); i++)
|
|
|
|
DestroySprite(&gSprites[sMenu->field_7B06[i]]);
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
FreeSpriteTilesByTag(TAG_UP_DOWN);
|
|
|
|
FreeSpriteTilesByTag(TAG_CONDITION);
|
|
|
|
FreeSpritePaletteByTag(TAG_UP_DOWN);
|
|
|
|
FreeSpritePaletteByTag(TAG_CONDITION);
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(sMenu->condition); i++)
|
|
|
|
DestroySprite(sMenu->condition[i]);
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
if (sMenu->field_7B10 != 0xFF)
|
|
|
|
DestroySprite(&gSprites[sMenu->field_7B10]);
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2019-03-23 16:41:09 +01:00
|
|
|
SetVBlankCallback(NULL);
|
2020-08-10 19:48:16 +02:00
|
|
|
FREE_AND_SET_NULL(sGraph_Tilemap);
|
|
|
|
FREE_AND_SET_NULL(sGraph_Gfx);
|
|
|
|
FREE_AND_SET_NULL(sMonFrame_TilemapPtr);
|
|
|
|
FREE_AND_SET_NULL(sMenu);
|
2019-03-23 16:41:09 +01:00
|
|
|
FreeAllWindowBuffers();
|
|
|
|
break;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void AskUsePokeblock(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-23 16:41:09 +01:00
|
|
|
u8 stringBuffer[0x40];
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
GetMonData(&gPlayerParty[sub_81672A4(sMenu->info.field_71)], MON_DATA_NICKNAME, stringBuffer);
|
2019-02-23 18:08:07 +01:00
|
|
|
StringGetEnd10(stringBuffer);
|
|
|
|
StringAppend(stringBuffer, gText_GetsAPokeBlockQuestion);
|
2019-03-23 16:41:09 +01:00
|
|
|
StringCopy(gStringVar4, stringBuffer);
|
2020-08-10 19:48:16 +02:00
|
|
|
FillWindowPixelBuffer(WIN_TEXT, 17);
|
|
|
|
DrawTextBorderOuter(WIN_TEXT, 151, 14);
|
|
|
|
AddTextPrinterParameterized(WIN_TEXT, 1, gStringVar4, 0, 1, 0, NULL);
|
|
|
|
PutWindowTilemap(WIN_TEXT);
|
|
|
|
CopyWindowToVram(WIN_TEXT, 3);
|
2019-07-31 02:21:17 +02:00
|
|
|
CreateYesNoMenu(&sUsePokeblockYesNoWinTemplate, 151, 14, 0);
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static s8 HandleAskUsePokeblockInput(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-31 12:59:01 +02:00
|
|
|
s8 menuItem = Menu_ProcessInputNoWrapClearOnChoose();
|
|
|
|
|
|
|
|
switch (menuItem)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
case 0: // YES
|
2019-03-23 16:41:09 +01:00
|
|
|
break;
|
2019-03-31 12:59:01 +02:00
|
|
|
case MENU_B_PRESSED:
|
2020-08-10 19:48:16 +02:00
|
|
|
case 1: // NO
|
2019-03-23 16:41:09 +01:00
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
rbox_fill_rectangle(2);
|
|
|
|
ClearWindowTilemap(2);
|
|
|
|
break;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
2019-03-31 12:59:01 +02:00
|
|
|
|
|
|
|
return menuItem;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_8166E24(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
DrawTextBorderOuter(WIN_TEXT, 151, 14);
|
|
|
|
FillWindowPixelBuffer(WIN_TEXT, 17);
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
for (sInfo->field_53 = 0; sInfo->field_53 < FLAVOR_COUNT; sInfo->field_53++)
|
2019-03-31 12:59:01 +02:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
if (sInfo->field_61[sInfo->field_53] != 0)
|
2019-03-31 12:59:01 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
if (sInfo->field_53 < FLAVOR_COUNT)
|
|
|
|
BufferEnhancedStatText(gStringVar4, sInfo->field_53, sInfo->field_61[sInfo->field_53]);
|
2019-03-23 16:41:09 +01:00
|
|
|
else
|
2020-08-10 19:48:16 +02:00
|
|
|
BufferEnhancedStatText(gStringVar4, sInfo->field_53, 0);
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
PrintMenuWindowText(gStringVar4);
|
|
|
|
PutWindowTilemap(WIN_TEXT);
|
|
|
|
CopyWindowToVram(WIN_TEXT, 3);
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static bool8 sub_8166EDC(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
FillWindowPixelBuffer(WIN_TEXT, 17);
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2019-02-23 18:08:07 +01:00
|
|
|
while (1)
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->field_53++;
|
|
|
|
if (sInfo->field_53 < FLAVOR_COUNT)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
if (sInfo->field_61[sInfo->field_53] != 0)
|
2019-02-23 18:08:07 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->field_53 = FLAVOR_COUNT;
|
2019-02-23 18:08:07 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
BufferEnhancedStatText(gStringVar4, sInfo->field_53, sInfo->field_61[sInfo->field_53]);
|
|
|
|
PrintMenuWindowText(gStringVar4);
|
|
|
|
CopyWindowToVram(WIN_TEXT, 2);
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2019-03-23 16:41:09 +01:00
|
|
|
return TRUE;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void PrintWontEatAnymore(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
FillWindowPixelBuffer(WIN_TEXT, 17);
|
|
|
|
DrawTextBorderOuter(WIN_TEXT, 151, 14);
|
|
|
|
AddTextPrinterParameterized(WIN_TEXT, 1, gText_WontEatAnymore, 0, 1, 0, NULL);
|
|
|
|
PutWindowTilemap(WIN_TEXT);
|
|
|
|
CopyWindowToVram(WIN_TEXT, 3);
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void EraseMenuWindow(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
rbox_fill_rectangle(WIN_TEXT);
|
|
|
|
ClearWindowTilemap(WIN_TEXT);
|
|
|
|
CopyWindowToVram(WIN_TEXT, 3);
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void PrintMenuWindowText(const u8 *message)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
AddTextPrinterParameterized(WIN_TEXT, 1, gStringVar4, 0, 1, 0, NULL);
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void BufferEnhancedStatText(u8 *dest, u8 statId, s16 enhancement)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
switch (enhancement)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
case 1 ... 32767: // if > 0
|
|
|
|
enhancement = 0;
|
2020-04-02 07:37:22 +02:00
|
|
|
// fallthrough
|
2020-08-10 19:48:16 +02:00
|
|
|
case -32768 ... -1: // if < 0
|
|
|
|
if (enhancement)
|
|
|
|
dest[(u16)enhancement] += 0; // something you can't imagine
|
2019-03-31 14:32:26 +02:00
|
|
|
StringCopy(dest, sContestStatNames[statId]);
|
2019-02-23 18:08:07 +01:00
|
|
|
StringAppend(dest, gText_WasEnhanced);
|
2020-04-02 07:37:22 +02:00
|
|
|
break;
|
|
|
|
case 0:
|
2019-03-23 16:41:09 +01:00
|
|
|
StringCopy(dest, gText_NothingChanged);
|
2020-04-02 07:37:22 +02:00
|
|
|
break;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void GetMonConditions(struct Pokemon *mon, u8 *data)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-23 17:16:53 +01:00
|
|
|
u16 i;
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2019-03-23 17:16:53 +01:00
|
|
|
for (i = 0; i < 5; i++)
|
2019-03-31 12:59:01 +02:00
|
|
|
data[i] = GetMonData(mon, gUnknown_085DFCB0[i]);
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_8167054(struct Pokeblock *pokeblock, struct Pokemon *mon)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
s16 cstat;
|
|
|
|
u8 data;
|
2019-03-31 12:59:01 +02:00
|
|
|
|
|
|
|
if (GetMonData(mon, MON_DATA_SHEEN) != 255)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-31 12:59:01 +02:00
|
|
|
sub_8167184(pokeblock, mon);
|
2020-08-10 19:48:16 +02:00
|
|
|
for (i = 0; i < FLAVOR_COUNT; i++)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-31 12:59:01 +02:00
|
|
|
data = GetMonData(mon, gUnknown_085DFCB0[i]);
|
2020-08-10 19:48:16 +02:00
|
|
|
cstat = data + sInfo->field_66[i];
|
2019-02-23 18:08:07 +01:00
|
|
|
if (cstat < 0)
|
|
|
|
cstat = 0;
|
|
|
|
if (cstat > 255)
|
|
|
|
cstat = 255;
|
|
|
|
data = cstat;
|
2019-03-31 12:59:01 +02:00
|
|
|
SetMonData(mon, gUnknown_085DFCB0[i], &data);
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
2019-03-23 17:16:53 +01:00
|
|
|
|
2019-03-31 12:59:01 +02:00
|
|
|
cstat = (u8)(GetMonData(mon, MON_DATA_SHEEN)) + pokeblock->feel;
|
2019-02-23 18:08:07 +01:00
|
|
|
if (cstat > 255)
|
|
|
|
cstat = 255;
|
2019-03-23 17:16:53 +01:00
|
|
|
|
2019-02-23 18:08:07 +01:00
|
|
|
data = cstat;
|
2019-03-31 12:59:01 +02:00
|
|
|
SetMonData(mon, MON_DATA_SHEEN, &data);
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_8167104(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
|
|
|
u16 i;
|
2019-03-31 12:59:01 +02:00
|
|
|
struct Pokemon *mon = gPlayerParty;
|
2020-08-10 19:48:16 +02:00
|
|
|
mon += sMenu->unk7FB0[sMenu->info.field_71 * 4 + 9];
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
GetMonConditions(mon, sInfo->field_57);
|
|
|
|
sub_8167054(sInfo->pokeblock, mon);
|
|
|
|
GetMonConditions(mon, sInfo->field_5c);
|
|
|
|
for (i = 0; i < FLAVOR_COUNT; i++)
|
|
|
|
sInfo->field_61[i] = sInfo->field_5c[i] - sInfo->field_57[i];
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_8167184(struct Pokeblock *pokeblock, struct Pokemon *mon)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-31 12:59:01 +02:00
|
|
|
s8 i, direction, taste;
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->field_66[0] = pokeblock->spicy;
|
|
|
|
sInfo->field_66[1] = pokeblock->sour;
|
|
|
|
sInfo->field_66[2] = pokeblock->bitter;
|
|
|
|
sInfo->field_66[3] = pokeblock->sweet;
|
|
|
|
sInfo->field_66[4] = pokeblock->dry;
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2019-02-23 18:08:07 +01:00
|
|
|
if (gPokeblockGain > 0)
|
|
|
|
direction = 1;
|
|
|
|
else if (gPokeblockGain < 0)
|
|
|
|
direction = -1;
|
|
|
|
else
|
|
|
|
return;
|
2019-03-23 17:16:53 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
for (i = 0; i < FLAVOR_COUNT; i++)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
s16 amount = sInfo->field_66[i];
|
2019-03-31 12:59:01 +02:00
|
|
|
s8 boost = amount / 10;
|
|
|
|
|
2019-02-23 18:08:07 +01:00
|
|
|
if (amount % 10 >= 5) // round to the nearest
|
|
|
|
boost++;
|
2019-03-23 17:16:53 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
taste = GetMonFlavorRelation(mon, sFlavors[i]);
|
2019-02-23 18:08:07 +01:00
|
|
|
if (taste == direction)
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->field_66[i] += boost * taste;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static bool8 IsSheenMaxed(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
if (GetBoxOrPartyMonData(sMenu->party[sMenu->info.field_71].boxId,
|
|
|
|
sMenu->party[sMenu->info.field_71].monId,
|
2019-03-31 12:59:01 +02:00
|
|
|
MON_DATA_SHEEN,
|
|
|
|
NULL) == 255)
|
2019-02-23 18:08:07 +01:00
|
|
|
return TRUE;
|
2019-03-31 12:59:01 +02:00
|
|
|
else
|
|
|
|
return FALSE;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static u8 sub_81672A4(u8 a0)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2019-03-23 17:16:53 +01:00
|
|
|
for (i = 0; i < PARTY_SIZE; i++)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
|
|
|
if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
|
|
|
|
{
|
|
|
|
if (a0 == 0)
|
|
|
|
return i;
|
|
|
|
a0--;
|
|
|
|
}
|
|
|
|
}
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2019-02-23 18:08:07 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
// TODO: Update
|
|
|
|
static u8 GetNumNonEggPartyMons(u8 partyCount)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-23 17:16:53 +01:00
|
|
|
u8 i, numEggs;
|
|
|
|
|
|
|
|
for (i = 0, numEggs = 0; i < partyCount; i++)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
|
|
|
if (GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
|
2019-03-23 17:16:53 +01:00
|
|
|
numEggs++;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
2019-03-23 17:16:53 +01:00
|
|
|
|
|
|
|
return partyCount - numEggs;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
// Unused
|
|
|
|
static u8 sub_8167324(u8 a0)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
|
|
|
return sub_81672A4(a0);
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_8167338(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-31 12:59:01 +02:00
|
|
|
u16 i, spriteId;
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
LoadSpriteSheet(&sSpriteSheet_UpDown);
|
|
|
|
LoadSpritePalette(&sSpritePalette_UpDown);
|
|
|
|
sInfo->numEnhancements = 0;
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
for (i = 0; i < FLAVOR_COUNT; i++)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
if (sInfo->field_61[i] != 0)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_UpDown, gUnknown_085DFD28[i][0], gUnknown_085DFD28[i][1], 0);
|
2019-03-31 12:59:01 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
if (sInfo->field_61[i] != 0)
|
2019-03-31 12:59:01 +02:00
|
|
|
gSprites[spriteId].callback = sub_81673DC;
|
2019-03-23 17:16:53 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->numEnhancements++;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_81673DC(struct Sprite *sprite)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-23 17:16:53 +01:00
|
|
|
if (sprite->data[0] < 6)
|
2019-02-23 18:08:07 +01:00
|
|
|
sprite->pos2.y -= 2;
|
2019-03-23 17:16:53 +01:00
|
|
|
else if (sprite->data[0] < 12)
|
2019-02-23 18:08:07 +01:00
|
|
|
sprite->pos2.y += 2;
|
2019-03-23 17:16:53 +01:00
|
|
|
|
|
|
|
if (++sprite->data[0] > 60)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
|
|
|
DestroySprite(sprite);
|
2020-08-10 19:48:16 +02:00
|
|
|
sInfo->numEnhancements--;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_8167420(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-23 16:41:09 +01:00
|
|
|
u16 i;
|
2019-03-23 17:16:53 +01:00
|
|
|
u16 numMons;
|
2019-03-31 12:59:01 +02:00
|
|
|
|
|
|
|
for (i = 0, numMons = 0; i < CalculatePlayerPartyCount(); i++)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
|
|
|
if (!GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->party[numMons].boxId = TOTAL_BOXES_COUNT;
|
|
|
|
sMenu->party[numMons].monId = i;
|
|
|
|
sMenu->party[numMons].data = 0;
|
2019-03-23 17:16:53 +01:00
|
|
|
numMons++;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
}
|
2019-03-23 17:16:53 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->info.field_71 = 0;
|
|
|
|
sMenu->info.field_70 = numMons + 1;
|
2019-03-23 16:41:09 +01:00
|
|
|
sub_81674BC();
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_81674BC(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-31 12:59:01 +02:00
|
|
|
s16 var, var2;
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
sub_816753C(sMenu->info.field_71, 0);
|
|
|
|
sMenu->field_7FB3 = 0;
|
|
|
|
sMenu->field_7FB4 = 1;
|
|
|
|
sMenu->field_7FB5 = 2;
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
var = sMenu->info.field_71 + 1;
|
|
|
|
if (var >= sMenu->info.field_70)
|
2019-03-23 16:41:09 +01:00
|
|
|
var = 0;
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
var2 = sMenu->info.field_71 - 1;
|
2019-03-23 17:22:41 +01:00
|
|
|
if (var2 < 0)
|
2020-08-10 19:48:16 +02:00
|
|
|
var2 = sMenu->info.field_70 - 1;
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2019-03-23 16:41:09 +01:00
|
|
|
sub_816753C(var, 1);
|
|
|
|
sub_816753C(var2, 2);
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_816753C(s16 id1, u8 id2)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
u8 boxId = sMenu->party[id1].boxId;
|
|
|
|
u8 monId = sMenu->party[id1].monId;
|
|
|
|
u8 r6 = sMenu->info.field_70;
|
2019-03-31 14:32:26 +02:00
|
|
|
bool8 r8 = FALSE;
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
sub_81D2ED4(sMenu->field_7B4D[id2], sMenu->field_7B95[id2], boxId, monId, id1, r6, r8);
|
|
|
|
sub_81D2F78(&sMenu->field_7C58, sMenu->unk7FB0, boxId, monId, id1, id2, r6, r8);
|
|
|
|
sub_81D3094(sMenu->field_304[id2], sMenu->field_4[id2], boxId, monId, id1, r6, r8);
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_8167608(u8 arg0)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-31 12:59:01 +02:00
|
|
|
u8 spriteId;
|
|
|
|
struct SpriteTemplate spriteTemplate;
|
|
|
|
struct SpriteSheet spriteSheet;
|
|
|
|
struct SpritePalette spritePal;
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
if (sMenu->field_7B10 == 0xFF)
|
2019-03-23 16:41:09 +01:00
|
|
|
{
|
2019-03-31 12:59:01 +02:00
|
|
|
sub_81D31D0(&spriteSheet, &spriteTemplate, &spritePal);
|
2020-08-10 19:48:16 +02:00
|
|
|
spriteSheet.data = sMenu->field_304[arg0];
|
|
|
|
spritePal.data = sMenu->field_4[arg0];
|
|
|
|
sMenu->field_7B12 = LoadSpritePalette(&spritePal);
|
|
|
|
sMenu->field_7B14 = LoadSpriteSheet(&spriteSheet);
|
2019-03-31 12:59:01 +02:00
|
|
|
spriteId = CreateSprite(&spriteTemplate, 38, 104, 0);
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->field_7B10 = spriteId;
|
2019-03-31 12:59:01 +02:00
|
|
|
if (spriteId == MAX_SPRITES)
|
2019-03-23 16:41:09 +01:00
|
|
|
{
|
|
|
|
FreeSpriteTilesByTag(100);
|
|
|
|
FreeSpritePaletteByTag(100);
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->field_7B10 = 0xFF;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->field_7B10 = spriteId;
|
|
|
|
gSprites[sMenu->field_7B10].callback = sub_8168168;
|
|
|
|
gSprites[sMenu->field_7B10].pos2.y -= 34;
|
|
|
|
sMenu->field_7B18 = (void*)(OBJ_VRAM0 + (sMenu->field_7B14 * 32));
|
|
|
|
sMenu->field_7B12 = (sMenu->field_7B12 * 16) + 0x100;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
do {} while(0); // Only needed to match, feel free to remove.
|
|
|
|
DmaCopy16Defvars(3, sMenu->field_304[arg0], sMenu->field_7B18, 0x800);
|
|
|
|
LoadPalette(sMenu->field_4[arg0], sMenu->field_7B12, 32);
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_8167760(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2019-03-31 12:59:01 +02:00
|
|
|
u16 i, spriteId;
|
|
|
|
struct SpriteSheet spriteSheets[4];
|
|
|
|
struct SpriteTemplate spriteTemplate;
|
|
|
|
struct SpritePalette spritePals[3];
|
|
|
|
struct SpriteSheet spriteSheet2;
|
|
|
|
struct SpritePalette spritePal2;
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
LoadConditionSelectionIcons(spriteSheets, &spriteTemplate, spritePals);
|
2019-03-31 12:59:01 +02:00
|
|
|
LoadSpriteSheets(spriteSheets);
|
|
|
|
LoadSpritePalettes(spritePals);
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
for (i = 0; i < sMenu->info.field_70 - 1; i++)
|
2019-03-23 16:41:09 +01:00
|
|
|
{
|
2019-03-31 12:59:01 +02:00
|
|
|
spriteId = CreateSprite(&spriteTemplate, 226, (i * 20) + 8, 0);
|
|
|
|
if (spriteId != MAX_SPRITES)
|
2019-03-23 16:41:09 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->field_7B06[i] = spriteId;
|
2019-03-31 12:59:01 +02:00
|
|
|
gSprites[spriteId].data[0] = i;
|
|
|
|
gSprites[spriteId].callback = sub_8168180;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->field_7B06[i] = -1;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
|
|
|
}
|
2019-03-31 12:59:01 +02:00
|
|
|
|
|
|
|
spriteTemplate.tileTag = 103;
|
|
|
|
for (; i < 6; i++)
|
2019-03-23 16:41:09 +01:00
|
|
|
{
|
2019-03-31 12:59:01 +02:00
|
|
|
spriteId = CreateSprite(&spriteTemplate, 230, (i * 20) + 8, 0);
|
|
|
|
if (spriteId != MAX_SPRITES)
|
2019-03-23 16:41:09 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->field_7B06[i] = spriteId;
|
2019-03-31 12:59:01 +02:00
|
|
|
gSprites[spriteId].oam.size = 0;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->field_7B06[i] = -1;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
|
|
|
}
|
2019-03-31 12:59:01 +02:00
|
|
|
|
|
|
|
spriteTemplate.tileTag = 102;
|
|
|
|
spriteTemplate.callback = sub_81681B4;
|
|
|
|
spriteId = CreateSprite(&spriteTemplate, 222, (i * 20) + 8, 0);
|
|
|
|
if (spriteId != MAX_SPRITES)
|
2019-03-23 16:41:09 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->field_7B06[i] = spriteId;
|
2019-12-05 03:00:45 +01:00
|
|
|
gSprites[spriteId].oam.shape = SPRITE_SHAPE(32x16);
|
|
|
|
gSprites[spriteId].oam.size = SPRITE_SIZE(32x16);
|
2019-03-31 12:59:01 +02:00
|
|
|
}
|
|
|
|
else
|
2019-03-23 16:41:09 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->field_7B06[i] = -1;
|
2019-03-23 16:41:09 +01:00
|
|
|
}
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
LoadConditionSparkle(&spriteSheet2, &spritePal2);
|
2019-03-31 12:59:01 +02:00
|
|
|
LoadSpriteSheet(&spriteSheet2);
|
|
|
|
LoadSpritePalette(&spritePal2);
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static bool8 LoadUsePokeblockGfx(void)
|
2019-02-23 18:08:07 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
switch (sMenu->info.helperState)
|
2019-03-31 12:59:01 +02:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ChangeBgX(0, 0, 0);
|
|
|
|
ChangeBgY(0, 0, 0);
|
|
|
|
ChangeBgX(1, 0, 0);
|
|
|
|
ChangeBgY(1, 0, 0);
|
|
|
|
ChangeBgX(2, 0, 0);
|
|
|
|
ChangeBgY(2, 0, 0);
|
|
|
|
ChangeBgX(3, 0, 0);
|
|
|
|
ChangeBgY(3, 136 << 6, 0);
|
2020-08-10 19:48:16 +02:00
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON | DISPCNT_WIN1_ON);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG2 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1);
|
2019-03-31 12:59:01 +02:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4));
|
|
|
|
break;
|
|
|
|
case 1:
|
2020-08-10 19:48:16 +02:00
|
|
|
sGraph_Gfx = Alloc(6656);
|
|
|
|
sGraph_Tilemap = Alloc(1280);
|
|
|
|
sMonFrame_TilemapPtr = Alloc(1280);
|
2019-03-31 12:59:01 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-08-10 19:48:16 +02:00
|
|
|
LZ77UnCompVram(sMonFrame_Tilemap, sMonFrame_TilemapPtr);
|
2019-03-31 12:59:01 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-08-10 19:48:16 +02:00
|
|
|
LoadBgTiles(3, sMonFrame_Gfx, 224, 0);
|
2019-03-31 12:59:01 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
2020-08-10 19:48:16 +02:00
|
|
|
LoadBgTilemap(3, sMonFrame_TilemapPtr, 1280, 0);
|
2019-03-31 12:59:01 +02:00
|
|
|
break;
|
|
|
|
case 5:
|
2020-08-10 19:48:16 +02:00
|
|
|
LoadPalette(sMonFrame_Pal, 208, 32);
|
|
|
|
sMenu->field_7B0E = -80;
|
2019-03-31 12:59:01 +02:00
|
|
|
break;
|
|
|
|
case 6:
|
2020-08-10 19:48:16 +02:00
|
|
|
LZ77UnCompVram(gUsePokeblockGraph_Gfx, sGraph_Gfx);
|
2019-03-31 12:59:01 +02:00
|
|
|
break;
|
|
|
|
case 7:
|
2020-08-10 19:48:16 +02:00
|
|
|
LZ77UnCompVram(gUsePokeblockGraph_Tilemap, sGraph_Tilemap);
|
2019-03-31 12:59:01 +02:00
|
|
|
LoadPalette(gUsePokeblockGraph_Pal, 32, 32);
|
|
|
|
break;
|
|
|
|
case 8:
|
2020-08-10 19:48:16 +02:00
|
|
|
LoadBgTiles(1, sGraph_Gfx, 6656, 160 << 2);
|
2019-03-31 12:59:01 +02:00
|
|
|
break;
|
|
|
|
case 9:
|
2020-08-10 19:48:16 +02:00
|
|
|
SetBgTilemapBuffer(1, sGraph_Tilemap);
|
2019-03-31 12:59:01 +02:00
|
|
|
CopyToBgTilemapBufferRect(1, gUsePokeblockNatureWin_Pal, 0, 13, 12, 4);
|
|
|
|
CopyBgTilemapBufferToVram(1);
|
|
|
|
break;
|
|
|
|
case 10:
|
2020-08-10 19:48:16 +02:00
|
|
|
LZ77UnCompVram(sGraphData_Tilemap, sMenu->tilemapBuffer);
|
2019-03-31 12:59:01 +02:00
|
|
|
break;
|
|
|
|
case 11:
|
2020-08-10 19:48:16 +02:00
|
|
|
LoadBgTilemap(2, sMenu->tilemapBuffer, 1280, 0);
|
|
|
|
LoadPalette(gConditionGraphData_Pal, 48, 32);
|
2019-03-31 12:59:01 +02:00
|
|
|
LoadPalette(gUnknown_08623208, 240, 32);
|
|
|
|
sub_81D21DC(2);
|
|
|
|
break;
|
|
|
|
default:
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->info.helperState = 0;
|
2019-03-31 12:59:01 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->info.helperState++;
|
2019-03-31 12:59:01 +02:00
|
|
|
return TRUE;
|
2019-02-23 18:08:07 +01:00
|
|
|
}
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void UpdateMonInfoText(u16 arg0, bool8 firstPrint)
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
|
|
|
u8 partyIndex;
|
|
|
|
u8 nature;
|
|
|
|
u8 *str;
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
FillWindowPixelBuffer(WIN_NAME, PIXEL_FILL(0));
|
|
|
|
FillWindowPixelBuffer(WIN_NATURE, PIXEL_FILL(0));
|
|
|
|
if (sMenu->info.field_71 != sMenu->info.field_70 - 1)
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
AddTextPrinterParameterized(WIN_NAME, 1, sMenu->field_7B95[arg0], 0, 1, 0, NULL);
|
|
|
|
partyIndex = sub_81672A4(sMenu->info.field_71);
|
2019-03-23 23:19:08 +01:00
|
|
|
nature = GetNature(&gPlayerParty[partyIndex]);
|
2020-08-10 19:48:16 +02:00
|
|
|
str = StringCopy(sMenu->info.field_7A, gText_NatureSlash);
|
2019-03-23 23:19:08 +01:00
|
|
|
str = StringCopy(str, gNatureNamePointers[nature]);
|
2020-08-10 19:48:16 +02:00
|
|
|
AddTextPrinterParameterized3(WIN_NATURE, 1, 2, 1, sNatureTextColors, 0, sMenu->info.field_7A);
|
2019-03-23 23:19:08 +01:00
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
if (firstPrint)
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
CopyWindowToVram(WIN_NAME, 3);
|
|
|
|
CopyWindowToVram(WIN_NATURE, 3);
|
2019-03-23 23:19:08 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
CopyWindowToVram(WIN_NAME, 2);
|
|
|
|
CopyWindowToVram(WIN_NATURE, 2);
|
2019-03-23 23:19:08 +01:00
|
|
|
}
|
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2019-03-23 23:19:08 +01:00
|
|
|
static void sub_8167CA0(bool8 arg0)
|
|
|
|
{
|
|
|
|
u16 var0;
|
2019-03-31 12:59:01 +02:00
|
|
|
bool32 r8, r4;
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2019-03-23 23:19:08 +01:00
|
|
|
if (arg0)
|
2020-08-10 19:48:16 +02:00
|
|
|
var0 = sMenu->field_7FB5;
|
2019-03-23 23:19:08 +01:00
|
|
|
else
|
2020-08-10 19:48:16 +02:00
|
|
|
var0 = sMenu->field_7FB4;
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2019-03-23 23:19:08 +01:00
|
|
|
sub_81D1F84(
|
2020-08-10 19:48:16 +02:00
|
|
|
&sMenu->field_7C58,
|
|
|
|
sMenu->field_7C58.unk14[sMenu->field_7FB3],
|
|
|
|
sMenu->field_7C58.unk14[var0]);
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
r8 = (sMenu->info.field_71 ^ (sMenu->info.field_70 - 1)) ? 1 : 0;
|
2019-03-23 23:19:08 +01:00
|
|
|
if (arg0)
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->field_7FB5 = sMenu->field_7FB4;
|
|
|
|
sMenu->field_7FB4 = sMenu->field_7FB3;
|
|
|
|
sMenu->field_7FB3 = var0;
|
|
|
|
sMenu->field_7FB6 = sMenu->field_7FB5;
|
|
|
|
|
|
|
|
sMenu->info.field_71 = (sMenu->info.field_71 == 0)
|
|
|
|
? sMenu->info.field_70 - 1
|
|
|
|
: sMenu->info.field_71 - 1;
|
|
|
|
|
|
|
|
sMenu->field_7B4C = (sMenu->info.field_71 == 0)
|
|
|
|
? sMenu->info.field_70 - 1
|
|
|
|
: sMenu->info.field_71 - 1;
|
2019-03-23 23:19:08 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->field_7FB4 = sMenu->field_7FB5;
|
|
|
|
sMenu->field_7FB5 = sMenu->field_7FB3;
|
|
|
|
sMenu->field_7FB3 = var0;
|
|
|
|
sMenu->field_7FB6 = sMenu->field_7FB4;
|
2019-03-23 23:19:08 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->info.field_71 = (sMenu->info.field_71 < sMenu->info.field_70 - 1)
|
|
|
|
? sMenu->info.field_71 + 1
|
2019-03-23 23:19:08 +01:00
|
|
|
: 0;
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->field_7B4C = (sMenu->info.field_71 < sMenu->info.field_70 - 1)
|
|
|
|
? sMenu->info.field_71 + 1
|
2019-03-23 23:19:08 +01:00
|
|
|
: 0;
|
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
r4 = (sMenu->info.field_71 ^ (sMenu->info.field_70 - 1)) ? 1 : 0;
|
|
|
|
DestroyConditionSparkleSprites(sMenu->sparkles);
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2019-03-23 23:19:08 +01:00
|
|
|
if (!r8)
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->info.unk74 = sub_8167EA4;
|
2019-03-23 23:19:08 +01:00
|
|
|
else if (!r4)
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->info.unk74 = sub_8167FA4;
|
2019-03-23 23:19:08 +01:00
|
|
|
else
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->info.unk74 = sub_8168048;
|
2019-03-23 23:19:08 +01:00
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2019-03-23 23:19:08 +01:00
|
|
|
static u8 sub_8167EA4(void)
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
switch (sMenu->info.helperState)
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2020-08-10 19:48:16 +02:00
|
|
|
sub_8167608(sMenu->field_7FB3);
|
|
|
|
sMenu->info.helperState++;
|
2019-03-23 23:19:08 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-08-10 19:48:16 +02:00
|
|
|
UpdateMonInfoText(sMenu->field_7FB3, FALSE);
|
|
|
|
sMenu->info.helperState++;
|
2019-03-23 23:19:08 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-08-10 19:48:16 +02:00
|
|
|
if (!sub_81D3178(&sMenu->field_7C58, &sMenu->field_7B0E))
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sub_816753C(sMenu->field_7B4C, sMenu->field_7FB6);
|
|
|
|
sMenu->info.helperState++;
|
2019-03-23 23:19:08 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2020-08-10 19:48:16 +02:00
|
|
|
ResetConditionSparkleSprites(sMenu->sparkles);
|
|
|
|
if (sMenu->info.field_71 != sMenu->info.field_70 - 1)
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
u8 var0 = sMenu->unk7FB0[sMenu->field_7FB3];
|
|
|
|
CreateConditionSparkleSprites(sMenu->sparkles, sMenu->field_7B10, var0);
|
2019-03-23 23:19:08 +01:00
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->info.helperState = 0;
|
2019-03-23 23:19:08 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2019-03-23 23:19:08 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2019-03-23 23:19:08 +01:00
|
|
|
static u8 sub_8167FA4(void)
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
switch (sMenu->info.helperState)
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2020-08-10 19:48:16 +02:00
|
|
|
if (!sub_81D31A4(&sMenu->field_7C58, &sMenu->field_7B0E))
|
|
|
|
sMenu->info.helperState++;
|
2019-03-23 23:19:08 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2020-08-10 19:48:16 +02:00
|
|
|
UpdateMonInfoText(sMenu->field_7FB3, FALSE);
|
|
|
|
sMenu->info.helperState++;
|
2019-03-23 23:19:08 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-08-10 19:48:16 +02:00
|
|
|
sub_816753C(sMenu->field_7B4C, sMenu->field_7FB6);
|
|
|
|
sMenu->info.helperState++;
|
2019-03-23 23:19:08 +01:00
|
|
|
break;
|
|
|
|
case 3:
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->info.helperState = 0;
|
2019-03-23 23:19:08 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2019-03-23 23:19:08 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2019-03-23 23:19:08 +01:00
|
|
|
static u8 sub_8168048(void)
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
switch (sMenu->info.helperState)
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
|
|
|
case 0:
|
2020-08-10 19:48:16 +02:00
|
|
|
sub_81D2074(&sMenu->field_7C58);
|
|
|
|
if (!sub_81D3150(&sMenu->field_7B0E))
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sub_8167608(sMenu->field_7FB3);
|
|
|
|
sMenu->info.helperState++;
|
2019-03-23 23:19:08 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2020-08-10 19:48:16 +02:00
|
|
|
UpdateMonInfoText(sMenu->field_7FB3, FALSE);
|
|
|
|
sMenu->info.helperState++;
|
2019-03-23 23:19:08 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2020-08-10 19:48:16 +02:00
|
|
|
if (!sub_81D3178(&sMenu->field_7C58, &sMenu->field_7B0E))
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sub_816753C(sMenu->field_7B4C, sMenu->field_7FB6);
|
|
|
|
sMenu->info.helperState++;
|
2019-03-23 23:19:08 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
2020-08-10 19:48:16 +02:00
|
|
|
ResetConditionSparkleSprites(sMenu->sparkles);
|
|
|
|
if (sMenu->info.field_71 != sMenu->info.field_70 - 1)
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
u8 var0 = sMenu->unk7FB0[sMenu->field_7FB3];
|
|
|
|
CreateConditionSparkleSprites(sMenu->sparkles, sMenu->field_7B10, var0);
|
2019-03-23 23:19:08 +01:00
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->info.helperState = 0;
|
2019-03-23 23:19:08 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2019-03-23 23:19:08 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_8168168(struct Sprite *sprite)
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
sprite->pos1.x = sMenu->field_7B0E + 38;
|
2019-03-23 23:19:08 +01:00
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_8168180(struct Sprite *sprite)
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
if (sprite->data[0] == sMenu->info.field_71)
|
2019-03-23 23:19:08 +01:00
|
|
|
StartSpriteAnim(sprite, 0);
|
|
|
|
else
|
|
|
|
StartSpriteAnim(sprite, 1);
|
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_81681B4(struct Sprite *sprite)
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
if (sMenu->info.field_71 == sMenu->info.field_70 - 1)
|
2019-03-23 23:19:08 +01:00
|
|
|
sprite->oam.paletteNum = IndexOfSpritePaletteTag(101);
|
|
|
|
else
|
|
|
|
sprite->oam.paletteNum = IndexOfSpritePaletteTag(102);
|
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_81681F4(u8 monIndex)
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
|
|
|
u8 sheen = GetMonData(&gPlayerParty[monIndex], MON_DATA_SHEEN);
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->unk7FB0[sMenu->field_7FB3] = (sheen != 255)
|
2019-03-23 23:19:08 +01:00
|
|
|
? sheen / 29
|
|
|
|
: 9;
|
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2019-03-23 23:19:08 +01:00
|
|
|
static void sub_8168248(void)
|
|
|
|
{
|
|
|
|
struct CompressedSpriteSheet spriteSheet;
|
|
|
|
struct SpritePalette spritePalette;
|
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
spritePalette = sSpritePalette_Condition;
|
2019-03-23 23:19:08 +01:00
|
|
|
spriteSheet.data = gUsePokeblockCondition_Gfx;
|
|
|
|
spriteSheet.size = 0x800;
|
2020-08-10 19:48:16 +02:00
|
|
|
spriteSheet.tag = TAG_CONDITION;
|
2019-03-23 23:19:08 +01:00
|
|
|
LoadCompressedSpriteSheet(&spriteSheet);
|
|
|
|
LoadSpritePalette(&spritePalette);
|
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2019-03-23 23:19:08 +01:00
|
|
|
static void sub_8168294(void)
|
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
s16 xDiff, xStart;
|
|
|
|
int yStart = 17;
|
|
|
|
int var = 8;
|
2020-08-10 19:48:16 +02:00
|
|
|
struct Sprite **sprites = sMenu->condition;
|
|
|
|
const struct SpriteTemplate *template = &sSpriteTemplate_Condition;
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2019-03-23 23:19:08 +01:00
|
|
|
for (i = 0, xDiff = 64, xStart = -96; i < 2; i++)
|
|
|
|
{
|
|
|
|
u8 spriteId = CreateSprite(template, i * xDiff + xStart, yStart, 0);
|
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
gSprites[spriteId].data[0] = var;
|
2019-03-31 12:59:01 +02:00
|
|
|
gSprites[spriteId].data[1] = (i * xDiff) | 0x20;
|
2019-03-23 23:19:08 +01:00
|
|
|
gSprites[spriteId].data[2] = i;
|
|
|
|
StartSpriteAnim(&gSprites[spriteId], i);
|
|
|
|
sprites[i] = &gSprites[spriteId];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2019-03-23 23:19:08 +01:00
|
|
|
static bool8 sub_8168328(void)
|
|
|
|
{
|
2020-08-10 19:48:16 +02:00
|
|
|
switch (sMenu->info.helperState)
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
sub_8168248();
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->info.helperState++;
|
2019-03-23 23:19:08 +01:00
|
|
|
return TRUE;
|
|
|
|
case 1:
|
|
|
|
sub_8168294();
|
2020-08-10 19:48:16 +02:00
|
|
|
sMenu->info.helperState = 0;
|
2019-03-23 23:19:08 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2019-03-23 23:19:08 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
2019-02-23 18:08:07 +01:00
|
|
|
|
2020-08-10 19:48:16 +02:00
|
|
|
static void sub_8168374(struct Sprite *sprite)
|
2019-03-23 23:19:08 +01:00
|
|
|
{
|
|
|
|
s16 prevX = sprite->pos1.x;
|
2019-03-31 12:59:01 +02:00
|
|
|
|
2019-03-23 23:19:08 +01:00
|
|
|
sprite->pos1.x += sprite->data[0];
|
|
|
|
if ((prevX <= sprite->data[1] && sprite->pos1.x >= sprite->data[1])
|
|
|
|
|| (prevX >= sprite->data[1] && sprite->pos1.x <= sprite->data[1]))
|
|
|
|
{
|
|
|
|
sprite->pos1.x = sprite->data[1];
|
|
|
|
sprite->callback = SpriteCallbackDummy;
|
|
|
|
}
|
|
|
|
}
|