2018-01-24 03:30:13 +00:00
|
|
|
#include "global.h"
|
|
|
|
#include "naming_screen.h"
|
2019-09-09 02:07:54 +01:00
|
|
|
#include "malloc.h"
|
2018-01-24 03:30:13 +00:00
|
|
|
#include "palette.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "sprite.h"
|
|
|
|
#include "string_util.h"
|
|
|
|
#include "window.h"
|
|
|
|
#include "bg.h"
|
|
|
|
#include "gpu_regs.h"
|
|
|
|
#include "pokemon.h"
|
|
|
|
#include "field_specials.h"
|
|
|
|
#include "field_player_avatar.h"
|
2018-06-11 14:34:19 +01:00
|
|
|
#include "event_object_movement.h"
|
2018-01-24 03:30:13 +00:00
|
|
|
#include "event_data.h"
|
|
|
|
#include "constants/songs.h"
|
|
|
|
#include "pokemon_storage_system.h"
|
2018-10-21 08:24:57 +01:00
|
|
|
#include "graphics.h"
|
2018-01-24 03:30:13 +00:00
|
|
|
#include "sound.h"
|
|
|
|
#include "trig.h"
|
|
|
|
#include "field_effect.h"
|
|
|
|
#include "pokemon_icon.h"
|
2019-04-04 22:53:06 +01:00
|
|
|
#include "data.h"
|
2018-01-24 03:30:13 +00:00
|
|
|
#include "strings.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "text_window.h"
|
|
|
|
#include "overworld.h"
|
2018-06-12 01:11:48 +01:00
|
|
|
#include "constants/event_objects.h"
|
2019-04-04 22:05:46 +01:00
|
|
|
#include "constants/rgb.h"
|
2018-01-24 03:30:13 +00:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
enum {
|
|
|
|
INPUT_NONE,
|
|
|
|
INPUT_DPAD_UP,
|
|
|
|
INPUT_DPAD_DOWN,
|
|
|
|
INPUT_DPAD_LEFT,
|
|
|
|
INPUT_DPAD_RIGHT,
|
|
|
|
INPUT_A_BUTTON,
|
|
|
|
INPUT_B_BUTTON,
|
|
|
|
INPUT_LR_BUTTON,
|
|
|
|
INPUT_SELECT,
|
|
|
|
INPUT_START,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define KBROW_COUNT 4
|
|
|
|
#define KBCOL_COUNT 8
|
|
|
|
|
|
|
|
enum {
|
|
|
|
GFXTAG_BACK_BUTTON,
|
|
|
|
GFXTAG_OK_BUTTON,
|
|
|
|
GFXTAG_PAGE_SWITCH_BG,
|
|
|
|
GFXTAG_PAGE_SWITCH_BUTTON,
|
|
|
|
GFXTAG_PAGE_SWITCH_UPPER,
|
|
|
|
GFXTAG_PAGE_SWITCH_LOWER,
|
|
|
|
GFXTAG_PAGE_SWITCH_OTHERS,
|
|
|
|
GFXTAG_CURSOR,
|
|
|
|
GFXTAG_CURSOR_SQUISHED,
|
|
|
|
GFXTAG_CURSOR_FILLED,
|
|
|
|
GFXTAG_INPUT_ARROW,
|
|
|
|
GFXTAG_UNDERSCORE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PALTAG_PC_ICON,
|
|
|
|
PALTAG_1,
|
|
|
|
PALTAG_2,
|
|
|
|
PALTAG_3,
|
|
|
|
PALTAG_PAGE_SWITCH,
|
|
|
|
PALTAG_CURSOR,
|
|
|
|
PALTAG_BACK_BUTTON,
|
|
|
|
PALTAG_OK_BUTTON,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
WIN_KB_PAGE_1, // Which of these two windows is in front is cycled as the player swaps
|
|
|
|
WIN_KB_PAGE_2, // Initiall WIN_KB_PAGE_1 is in front, with WIN_KB_PAGE_2 on deck
|
|
|
|
WIN_TEXT_ENTRY,
|
|
|
|
WIN_TEXT_ENTRY_BOX,
|
|
|
|
WIN_BANNER,
|
|
|
|
WIN_COUNT,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
KBPAGE_LETTERS_LOWER,
|
|
|
|
KBPAGE_LETTERS_UPPER,
|
|
|
|
KBPAGE_SYMBOLS,
|
|
|
|
KBPAGE_COUNT,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
KEY_ROLE_CHAR,
|
|
|
|
KEY_ROLE_PAGE,
|
|
|
|
KEY_ROLE_BACKSPACE,
|
|
|
|
KEY_ROLE_OK,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
BUTTON_PAGE,
|
|
|
|
BUTTON_BACK,
|
|
|
|
BUTTON_OK,
|
|
|
|
BUTTON_COUNT,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
STATE_BEGIN_FADE_IN,
|
|
|
|
STATE_WAIT_FADE_IN,
|
|
|
|
STATE_HANDLE_INPUT,
|
|
|
|
STATE_MOVE_TO_OK_BUTTON,
|
|
|
|
STATE_START_PAGE_SWAP,
|
|
|
|
STATE_WAIT_PAGE_SWAP,
|
|
|
|
STATE_6,
|
|
|
|
STATE_UPDATE_SENT_TO_PC_MESSAGE,
|
|
|
|
STATE_BEGIN_FADE_OUT,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
INPUT_STATE_DISABLED,
|
|
|
|
INPUT_STATE_ENABLED,
|
|
|
|
INPUT_STATE_2,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct NamingScreenTemplate
|
|
|
|
{
|
|
|
|
u8 copyExistingString;
|
|
|
|
u8 maxChars;
|
|
|
|
u8 iconFunction;
|
|
|
|
u8 addGenderIcon;
|
|
|
|
u8 initialPage;
|
|
|
|
u8 unused;
|
|
|
|
const u8 *title;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct NamingScreenData
|
|
|
|
{
|
|
|
|
u8 tilemapBuffer1[0x800];
|
|
|
|
u8 tilemapBuffer2[0x800];
|
|
|
|
u8 tilemapBuffer3[0x800];
|
|
|
|
u8 textBuffer[16];
|
|
|
|
u8 tileBuffer[0x600];
|
|
|
|
u8 state;
|
|
|
|
u8 windows[WIN_COUNT];
|
|
|
|
u16 inputCharBaseXPos;
|
|
|
|
u16 bg1vOffset;
|
|
|
|
u16 bg2vOffset;
|
|
|
|
u16 bg1Priority;
|
|
|
|
u16 bg2Priority;
|
|
|
|
u8 bgToReveal;
|
|
|
|
u8 bgToHide;
|
|
|
|
u8 currentPage;
|
|
|
|
u8 cursorSpriteId;
|
|
|
|
u8 selectBtnFrameSpriteId;
|
|
|
|
u8 keyRepeatStartDelayCopy;
|
|
|
|
const struct NamingScreenTemplate *template;
|
|
|
|
u8 templateNum;
|
|
|
|
u8 *destBuffer;
|
|
|
|
u16 monSpecies;
|
|
|
|
u16 monGender;
|
|
|
|
u32 monPersonality;
|
|
|
|
MainCallback returnCallback;
|
|
|
|
};
|
|
|
|
|
|
|
|
EWRAM_DATA static struct NamingScreenData *sNamingScreen = NULL;
|
2018-01-24 03:30:13 +00:00
|
|
|
extern u16 gKeyRepeatStartDelay;
|
|
|
|
|
2018-01-24 03:34:15 +00:00
|
|
|
// extern text
|
2018-01-24 03:30:13 +00:00
|
|
|
extern const u8 gText_MoveOkBack[];
|
|
|
|
extern const u8 gText_YourName[];
|
|
|
|
extern const u8 gText_BoxName[];
|
|
|
|
extern const u8 gText_PkmnsNickname[];
|
|
|
|
extern const u8 gText_TellHimTheWords[];
|
2018-01-24 05:14:22 +00:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
|
|
|
|
// start of .rodata
|
2020-08-07 07:00:41 +01:00
|
|
|
static const u8 sPCIconOn_Gfx[] = INCBIN_U8("graphics/naming_screen/pc_icon/0.4bpp");
|
|
|
|
static const u8 sPCIconOff_Gfx[] = INCBIN_U8("graphics/naming_screen/pc_icon/1.4bpp");
|
|
|
|
static const u16 sKeyboard_Pal[] = INCBIN_U16("graphics/naming_screen/keyboard.gbapal");
|
|
|
|
static const u16 sUnused_Pal[] = INCBIN_U16("graphics/naming_screen/unused.gbapal");
|
2018-01-24 03:34:15 +00:00
|
|
|
|
2019-10-22 23:07:08 +01:00
|
|
|
static const u8 *const sTransferredToPCMessages[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
gText_PkmnTransferredSomeonesPC,
|
|
|
|
gText_PkmnTransferredLanettesPC,
|
2019-10-22 23:07:08 +01:00
|
|
|
gText_PkmnTransferredSomeonesPCBoxFull,
|
|
|
|
gText_PkmnTransferredLanettesPCBoxFull
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2019-12-10 18:48:20 +00:00
|
|
|
static const u8 sText_AlphabetUpperLower[] = _("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!");
|
2018-01-24 03:30:13 +00:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct BgTemplate sBgTemplates[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
.bg = 0,
|
|
|
|
.charBaseIndex = 0,
|
|
|
|
.mapBaseIndex = 30,
|
|
|
|
.priority = 0
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 1,
|
|
|
|
.charBaseIndex = 2,
|
|
|
|
.mapBaseIndex = 29,
|
|
|
|
.priority = 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 2,
|
|
|
|
.charBaseIndex = 2,
|
|
|
|
.mapBaseIndex = 28,
|
|
|
|
.priority = 2
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.bg = 3,
|
|
|
|
.charBaseIndex = 3,
|
|
|
|
.mapBaseIndex = 31,
|
|
|
|
.priority = 3
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct WindowTemplate sWindowTemplates[WIN_COUNT + 1] =
|
2018-09-02 17:53:52 +01:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
[WIN_KB_PAGE_1] = {
|
2018-10-26 23:53:07 +01:00
|
|
|
.bg = 1,
|
2018-09-02 17:53:52 +01:00
|
|
|
.tilemapLeft = 3,
|
|
|
|
.tilemapTop = 10,
|
|
|
|
.width = 19,
|
|
|
|
.height = 8,
|
|
|
|
.paletteNum = 10,
|
|
|
|
.baseBlock = 0x030
|
|
|
|
},
|
2020-08-07 07:00:41 +01:00
|
|
|
[WIN_KB_PAGE_2] = {
|
2018-10-26 23:53:07 +01:00
|
|
|
.bg = 2,
|
2018-09-02 17:53:52 +01:00
|
|
|
.tilemapLeft = 3,
|
|
|
|
.tilemapTop = 10,
|
|
|
|
.width = 19,
|
|
|
|
.height = 8,
|
|
|
|
.paletteNum = 10,
|
|
|
|
.baseBlock = 0x0C8
|
|
|
|
},
|
2020-08-07 07:00:41 +01:00
|
|
|
[WIN_TEXT_ENTRY] = {
|
2018-10-26 23:53:07 +01:00
|
|
|
.bg = 3,
|
2018-09-02 17:53:52 +01:00
|
|
|
.tilemapLeft = 8,
|
|
|
|
.tilemapTop = 6,
|
|
|
|
.width = 17,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 10,
|
|
|
|
.baseBlock = 0x030
|
|
|
|
},
|
2020-08-07 07:00:41 +01:00
|
|
|
[WIN_TEXT_ENTRY_BOX] = {
|
2018-10-26 23:53:07 +01:00
|
|
|
.bg = 3,
|
2018-09-02 17:53:52 +01:00
|
|
|
.tilemapLeft = 8,
|
|
|
|
.tilemapTop = 4,
|
|
|
|
.width = 17,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 10,
|
|
|
|
.baseBlock = 0x052
|
|
|
|
},
|
2020-08-07 07:00:41 +01:00
|
|
|
[WIN_BANNER] = {
|
2018-10-26 23:53:07 +01:00
|
|
|
.bg = 0,
|
2018-09-02 17:53:52 +01:00
|
|
|
.tilemapLeft = 0,
|
|
|
|
.tilemapTop = 0,
|
|
|
|
.width = 30,
|
|
|
|
.height = 2,
|
|
|
|
.paletteNum = 11,
|
|
|
|
.baseBlock = 0x074
|
|
|
|
},
|
2018-01-24 03:30:13 +00:00
|
|
|
DUMMY_WIN_TEMPLATE
|
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
// This handles what characters get inserted when a key is pressed
|
|
|
|
// The keys shown on the keyboard are handled separately by sNamingScreenKeyboardText
|
|
|
|
static const u8 sKeyboardChars[KBPAGE_COUNT * KBROW_COUNT * KBCOL_COUNT] = __(
|
|
|
|
"abcdef ."
|
|
|
|
"ghijkl ,"
|
|
|
|
"mnopqrs "
|
|
|
|
"tuvwxyz "
|
|
|
|
"ABCDEF ."
|
|
|
|
"GHIJKL ,"
|
|
|
|
"MNOPQRS "
|
|
|
|
"TUVWXYZ "
|
|
|
|
"01234 "
|
|
|
|
"56789 "
|
|
|
|
"!?♂♀/- "
|
|
|
|
"…“”‘' ");
|
|
|
|
|
|
|
|
static const u8 sPageColumnCounts[KBPAGE_COUNT] = {
|
|
|
|
[KBPAGE_LETTERS_LOWER] = KBCOL_COUNT,
|
|
|
|
[KBPAGE_LETTERS_UPPER] = KBCOL_COUNT,
|
|
|
|
[KBPAGE_SYMBOLS] = 6
|
|
|
|
};
|
|
|
|
static const u8 sPageColumnXPos[KBPAGE_COUNT * KBCOL_COUNT] = {
|
|
|
|
0, 12, 24, 56, 68, 80, 92, 123, // KBPAGE_LETTERS_LOWER
|
|
|
|
0, 12, 24, 56, 68, 80, 92, 123, // KBPAGE_LETTERS_UPPER
|
|
|
|
0, 22, 44, 66, 88, 110 // KBPAGE_SYMBOLS
|
|
|
|
};
|
2018-01-24 03:30:13 +00:00
|
|
|
|
|
|
|
// forward declarations
|
|
|
|
static const struct NamingScreenTemplate *const sNamingScreenTemplates[];
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct SubspriteTable sSubspriteTable_PageSwitchBg[];
|
|
|
|
static const struct SubspriteTable sSubspriteTable_PageSwitchText[];
|
|
|
|
static const struct SubspriteTable sSubspriteTable_Button[];
|
|
|
|
static const struct SubspriteTable sSubspriteTable_PCIcon[];
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_PageSwitchBg;
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_PageSwitchButton;
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_PageSwitchText;
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_BackButton;
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_OkButton;
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_Cursor;
|
2018-01-24 05:14:22 +00:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_InputArrow;
|
|
|
|
static const struct SpriteTemplate sSpriteTemplate_Underscore;
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_PCIcon;
|
2019-09-30 05:09:29 +01:00
|
|
|
static const u8* const sNamingScreenKeyboardText[KBPAGE_COUNT][KBROW_COUNT];
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct SpriteSheet sSpriteSheets[];
|
|
|
|
static const struct SpritePalette sSpritePalettes[];
|
2018-01-24 03:30:13 +00:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void CB2_LoadNamingScreen(void);
|
2018-01-24 03:30:13 +00:00
|
|
|
static void NamingScreen_Init(void);
|
2018-01-24 05:14:22 +00:00
|
|
|
static void NamingScreen_InitBGs(void);
|
2020-08-07 07:00:41 +01:00
|
|
|
static void CreateNamingScreenTask(void);
|
|
|
|
static void Task_NamingScreen(u8 taskId);
|
|
|
|
static bool8 MainState_FadeIn(void);
|
2018-01-24 03:30:13 +00:00
|
|
|
static bool8 MainState_WaitFadeIn(void);
|
|
|
|
static bool8 MainState_HandleInput(void);
|
|
|
|
static bool8 MainState_MoveToOKButton(void);
|
|
|
|
static bool8 MainState_6(void);
|
2020-08-07 07:00:41 +01:00
|
|
|
static bool8 MainState_FadeOut(void);
|
|
|
|
static bool8 MainState_Exit(void);
|
2018-01-24 03:30:13 +00:00
|
|
|
static void DisplaySentToPCMessage(void);
|
2020-08-07 07:00:41 +01:00
|
|
|
static bool8 MainState_7(void);
|
2018-01-24 03:30:13 +00:00
|
|
|
static bool8 MainState_StartPageSwap(void);
|
|
|
|
static bool8 MainState_WaitPageSwap(void);
|
|
|
|
static void StartPageSwapAnim(void);
|
|
|
|
static void Task_HandlePageSwapAnim(u8);
|
|
|
|
static bool8 IsPageSwapAnimNotInProgress(void);
|
2020-08-07 07:00:41 +01:00
|
|
|
static void TryStartButtonFlash(u8, bool8, bool8);
|
|
|
|
static void Task_UpdateButtonFlash(u8);
|
|
|
|
static u16 GetButtonPalOffset(u8);
|
|
|
|
static void RestoreButtonColor(u8);
|
|
|
|
static void StartButtonFlash(struct Task *, u8, bool8);
|
|
|
|
static void CreateSprites(void);
|
|
|
|
static void CreateCursorSprite(void);
|
2018-01-24 03:30:13 +00:00
|
|
|
static void SetCursorPos(s16, s16);
|
|
|
|
static void GetCursorPos(s16 *x, s16 *y);
|
|
|
|
static void MoveCursorToOKButton(void);
|
2020-08-07 07:00:41 +01:00
|
|
|
static void SetCursorInvisibility(u8);
|
|
|
|
static void SetCursorFlashing(bool8);
|
2018-01-24 03:30:13 +00:00
|
|
|
static u8 IsCursorAnimFinished(void);
|
|
|
|
static u8 GetCurrentPageColumnCount(void);
|
2018-01-24 05:14:22 +00:00
|
|
|
static void CreatePageSwitcherSprites(void);
|
2018-01-24 03:30:13 +00:00
|
|
|
static void sub_80E4050(void);
|
|
|
|
static void sub_80E41B8(u8, struct Sprite *, struct Sprite *);
|
2018-01-24 05:14:22 +00:00
|
|
|
static void CreateBackOkSprites(void);
|
2020-08-07 07:00:41 +01:00
|
|
|
static void CreateTextEntrySprites(void);
|
2018-01-24 05:14:22 +00:00
|
|
|
static void CreateInputTargetIcon(void);
|
2018-01-24 03:30:13 +00:00
|
|
|
static u8 HandleKeyboardEvent(void);
|
2020-08-07 07:00:41 +01:00
|
|
|
static u8 SwitchKeyboardPage(void);
|
2018-01-24 03:30:13 +00:00
|
|
|
static u8 GetInputEvent(void);
|
|
|
|
static void SetInputState(u8);
|
2020-08-07 07:00:41 +01:00
|
|
|
static void DrawTextEntryBox(void);
|
|
|
|
static u8 GetTextEntryPosition(void);
|
2018-01-24 03:30:13 +00:00
|
|
|
static void DeleteTextCharacter(void);
|
2020-08-07 07:00:41 +01:00
|
|
|
static bool8 AddTextCharacter(void);
|
|
|
|
static void BufferCharacter(u8);
|
|
|
|
static void SaveInputText(void);
|
|
|
|
static void LoadGfx(void);
|
|
|
|
static void CreateHelperTasks(void);
|
|
|
|
static void LoadPalettes(void);
|
|
|
|
static void DrawBgTilemap(u8, const void *);
|
|
|
|
static void NamingScreen_Dummy(u8, u8);
|
|
|
|
static void DrawTextEntry(void);
|
|
|
|
static void PrintKeyboardKeys(u8, u8);
|
|
|
|
static void DrawKeyboardPageOnDeck(void);
|
|
|
|
static void PrintControls(void);
|
|
|
|
static void CB2_NamingScreen(void);
|
|
|
|
static void NamingScreen_ResetVHBlank(void);
|
|
|
|
static void NamingScreen_SetVBlank(void);
|
2018-01-24 03:30:13 +00:00
|
|
|
static void VBlankCB_NamingScreen(void);
|
2020-08-07 07:00:41 +01:00
|
|
|
static void NamingScreen_ShowBgs(void);
|
|
|
|
static bool8 IsWideLetter(u8);
|
2018-01-24 03:30:13 +00:00
|
|
|
|
|
|
|
void DoNamingScreen(u8 templateNum, u8 *destBuffer, u16 monSpecies, u16 monGender, u32 monPersonality, MainCallback returnCallback)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen = Alloc(sizeof(struct NamingScreenData));
|
|
|
|
if (!sNamingScreen)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
SetMainCallback2(returnCallback);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->templateNum = templateNum;
|
|
|
|
sNamingScreen->monSpecies = monSpecies;
|
|
|
|
sNamingScreen->monGender = monGender;
|
|
|
|
sNamingScreen->monPersonality = monPersonality;
|
|
|
|
sNamingScreen->destBuffer = destBuffer;
|
|
|
|
sNamingScreen->returnCallback = returnCallback;
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
if (templateNum == NAMING_SCREEN_PLAYER)
|
2018-01-24 03:30:13 +00:00
|
|
|
StartTimer1();
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
SetMainCallback2(CB2_LoadNamingScreen);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void CB2_LoadNamingScreen(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
switch (gMain.state)
|
|
|
|
{
|
|
|
|
case 0:
|
2020-08-07 07:00:41 +01:00
|
|
|
NamingScreen_ResetVHBlank();
|
2018-01-24 03:30:13 +00:00
|
|
|
NamingScreen_Init();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 1:
|
2018-01-24 05:14:22 +00:00
|
|
|
NamingScreen_InitBGs();
|
2018-01-24 03:30:13 +00:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ResetPaletteFade();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
ResetSpriteData();
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
ResetTasks();
|
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 5:
|
2020-08-07 07:00:41 +01:00
|
|
|
LoadPalettes();
|
2018-01-24 03:30:13 +00:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 6:
|
2020-08-07 07:00:41 +01:00
|
|
|
LoadGfx();
|
2018-01-24 03:30:13 +00:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
case 7:
|
2020-08-07 07:00:41 +01:00
|
|
|
CreateSprites();
|
2018-01-24 03:30:13 +00:00
|
|
|
UpdatePaletteFade();
|
2020-08-07 07:00:41 +01:00
|
|
|
NamingScreen_ShowBgs();
|
2018-01-24 03:30:13 +00:00
|
|
|
gMain.state++;
|
|
|
|
break;
|
|
|
|
default:
|
2020-08-07 07:00:41 +01:00
|
|
|
CreateHelperTasks();
|
|
|
|
CreateNamingScreenTask();
|
2018-01-24 03:30:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void NamingScreen_Init(void)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->state = 0;
|
|
|
|
sNamingScreen->bg1vOffset = 0;
|
|
|
|
sNamingScreen->bg2vOffset = 0;
|
|
|
|
sNamingScreen->bg1Priority = BGCNT_PRIORITY(1);
|
|
|
|
sNamingScreen->bg2Priority = BGCNT_PRIORITY(2);
|
|
|
|
sNamingScreen->bgToReveal = 0;
|
|
|
|
sNamingScreen->bgToHide = 1;
|
|
|
|
sNamingScreen->template = sNamingScreenTemplates[sNamingScreen->templateNum];
|
|
|
|
sNamingScreen->currentPage = sNamingScreen->template->initialPage;
|
|
|
|
sNamingScreen->inputCharBaseXPos = (240 - sNamingScreen->template->maxChars * 8) / 2 + 6;
|
|
|
|
if (sNamingScreen->templateNum == NAMING_SCREEN_WALDA)
|
|
|
|
sNamingScreen->inputCharBaseXPos += 11;
|
|
|
|
sNamingScreen->keyRepeatStartDelayCopy = gKeyRepeatStartDelay;
|
|
|
|
memset(sNamingScreen->textBuffer, 0xFF, sizeof(sNamingScreen->textBuffer));
|
|
|
|
if (sNamingScreen->template->copyExistingString)
|
|
|
|
StringCopy(sNamingScreen->textBuffer, sNamingScreen->destBuffer);
|
2018-01-24 03:30:13 +00:00
|
|
|
gKeyRepeatStartDelay = 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80E2FA4(void)
|
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
for (i = 0; i < MAX_SPRITES; i++)
|
|
|
|
{
|
|
|
|
if (gSprites[i].inUse)
|
|
|
|
gSprites[i].invisible = FALSE;
|
|
|
|
}
|
2020-08-07 07:00:41 +01:00
|
|
|
SetCursorInvisibility(FALSE);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2018-01-24 05:14:22 +00:00
|
|
|
static void NamingScreen_InitBGs(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
u8 i;
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
DmaClearLarge16(3, (void *)VRAM, VRAM_SIZE, 0x1000);
|
|
|
|
DmaClear32(3, (void *)OAM, OAM_SIZE);
|
|
|
|
DmaClear16(3, (void *)PLTT, PLTT_SIZE);
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0);
|
|
|
|
ResetBgsAndClearDma3BusyFlags(0);
|
2020-08-07 07:00:41 +01:00
|
|
|
InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates));
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
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, 0, 0);
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-12-27 22:30:47 +00:00
|
|
|
InitStandardTextBoxWindows();
|
2020-06-20 00:58:56 +01:00
|
|
|
InitTextBoxGfxAndPrinters();
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
for (i = 0; i < WIN_COUNT; i++)
|
|
|
|
sNamingScreen->windows[i] = AddWindow(&sWindowTemplates[i]);
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON);
|
|
|
|
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2);
|
2020-08-07 07:00:41 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(12, 8));
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
SetBgTilemapBuffer(1, sNamingScreen->tilemapBuffer1);
|
|
|
|
SetBgTilemapBuffer(2, sNamingScreen->tilemapBuffer2);
|
|
|
|
SetBgTilemapBuffer(3, sNamingScreen->tilemapBuffer3);
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 0x20, 0x20);
|
|
|
|
FillBgTilemapBufferRect_Palette0(2, 0, 0, 0, 0x20, 0x20);
|
|
|
|
FillBgTilemapBufferRect_Palette0(3, 0, 0, 0, 0x20, 0x20);
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void CreateNamingScreenTask(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
CreateTask(Task_NamingScreen, 2);
|
|
|
|
SetMainCallback2(CB2_NamingScreen);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void Task_NamingScreen(u8 taskId)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
switch (sNamingScreen->state)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2020-08-07 07:00:41 +01:00
|
|
|
MainState_FadeIn();
|
2018-01-24 03:30:13 +00:00
|
|
|
sub_80E2FA4();
|
2020-08-07 07:00:41 +01:00
|
|
|
NamingScreen_SetVBlank();
|
2018-01-24 03:30:13 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
MainState_WaitFadeIn();
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
MainState_HandleInput();
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
MainState_MoveToOKButton();
|
|
|
|
MainState_HandleInput();
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
MainState_StartPageSwap();
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
MainState_WaitPageSwap();
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
MainState_6();
|
|
|
|
break;
|
|
|
|
case 7:
|
2020-08-07 07:00:41 +01:00
|
|
|
MainState_7();
|
2018-01-24 03:30:13 +00:00
|
|
|
break;
|
|
|
|
case 8:
|
2020-08-07 07:00:41 +01:00
|
|
|
MainState_FadeOut();
|
2018-01-24 03:30:13 +00:00
|
|
|
break;
|
|
|
|
case 9:
|
2020-08-07 07:00:41 +01:00
|
|
|
MainState_Exit();
|
2018-01-24 03:30:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-30 05:09:29 +01:00
|
|
|
static const u8 sPageOrderLowerFirst[] =
|
|
|
|
{
|
|
|
|
KBPAGE_LETTERS_LOWER,
|
|
|
|
KBPAGE_SYMBOLS,
|
|
|
|
KBPAGE_LETTERS_UPPER
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 sPageOrderUpperFirst[] =
|
|
|
|
{
|
|
|
|
KBPAGE_LETTERS_UPPER,
|
|
|
|
KBPAGE_LETTERS_LOWER,
|
|
|
|
KBPAGE_SYMBOLS
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 sPageOrderSymbolsFirst[] =
|
|
|
|
{
|
|
|
|
KBPAGE_SYMBOLS,
|
|
|
|
KBPAGE_LETTERS_UPPER,
|
|
|
|
KBPAGE_LETTERS_LOWER
|
|
|
|
};
|
2018-01-24 03:30:13 +00:00
|
|
|
|
|
|
|
static u8 sub_80E3244(u8 a1)
|
|
|
|
{
|
2019-09-30 05:09:29 +01:00
|
|
|
return sPageOrderLowerFirst[a1];
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u8 sub_80E3254(void)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
return sPageOrderUpperFirst[sNamingScreen->currentPage];
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u8 sub_80E3274(void)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
return sPageOrderSymbolsFirst[sNamingScreen->currentPage];
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static bool8 MainState_FadeIn(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
DrawBgTilemap(3, gUnknown_08DD4544);
|
|
|
|
sNamingScreen->currentPage = KBPAGE_LETTERS_UPPER;
|
|
|
|
DrawBgTilemap(2, gUnknown_08DD46E0);
|
|
|
|
DrawBgTilemap(1, gUnknown_08DD4620);
|
|
|
|
PrintKeyboardKeys(sNamingScreen->windows[WIN_KB_PAGE_2], KBPAGE_LETTERS_LOWER);
|
|
|
|
PrintKeyboardKeys(sNamingScreen->windows[WIN_KB_PAGE_1], KBPAGE_LETTERS_UPPER);
|
|
|
|
NamingScreen_Dummy(2, KBPAGE_LETTERS_LOWER);
|
|
|
|
NamingScreen_Dummy(1, KBPAGE_LETTERS_UPPER);
|
|
|
|
DrawTextEntry();
|
|
|
|
DrawTextEntryBox();
|
|
|
|
PrintControls();
|
2018-01-24 03:30:13 +00:00
|
|
|
CopyBgTilemapBufferToVram(1);
|
|
|
|
CopyBgTilemapBufferToVram(2);
|
|
|
|
CopyBgTilemapBufferToVram(3);
|
|
|
|
BlendPalettes(-1, 16, 0);
|
2019-04-04 22:05:46 +01:00
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->state++;
|
2018-01-24 03:30:13 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 MainState_WaitFadeIn(void)
|
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
|
|
|
SetInputState(INPUT_STATE_ENABLED);
|
2020-08-07 07:00:41 +01:00
|
|
|
SetCursorFlashing(TRUE);
|
|
|
|
sNamingScreen->state++;
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 MainState_HandleInput(void)
|
|
|
|
{
|
|
|
|
return HandleKeyboardEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 MainState_MoveToOKButton(void)
|
|
|
|
{
|
|
|
|
if (IsCursorAnimFinished())
|
|
|
|
{
|
|
|
|
SetInputState(INPUT_STATE_ENABLED);
|
|
|
|
MoveCursorToOKButton();
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->state = STATE_HANDLE_INPUT;
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 MainState_6(void)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
SaveInputText();
|
2018-01-24 03:30:13 +00:00
|
|
|
SetInputState(INPUT_STATE_DISABLED);
|
2020-08-07 07:00:41 +01:00
|
|
|
SetCursorFlashing(FALSE);
|
|
|
|
TryStartButtonFlash(BUTTON_COUNT, FALSE, TRUE);
|
|
|
|
if (sNamingScreen->templateNum == NAMING_SCREEN_CAUGHT_MON &&
|
|
|
|
CalculatePlayerPartyCount() >= PARTY_SIZE)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
DisplaySentToPCMessage();
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->state = STATE_UPDATE_SENT_TO_PC_MESSAGE;
|
2018-01-24 03:30:13 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->state = STATE_BEGIN_FADE_OUT;
|
2018-01-24 03:30:13 +00:00
|
|
|
return TRUE; //Exit the naming screen
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static bool8 MainState_FadeOut(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2019-04-04 22:05:46 +01:00
|
|
|
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->state++;
|
2018-01-24 03:30:13 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static bool8 MainState_Exit(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
if (sNamingScreen->templateNum == NAMING_SCREEN_PLAYER)
|
2018-01-24 03:30:13 +00:00
|
|
|
SeedRngAndSetTrainerId();
|
2020-08-07 07:00:41 +01:00
|
|
|
SetMainCallback2(sNamingScreen->returnCallback);
|
|
|
|
DestroyTask(FindTaskIdByFunc(Task_NamingScreen));
|
2018-01-24 03:30:13 +00:00
|
|
|
FreeAllWindowBuffers();
|
2020-08-07 07:00:41 +01:00
|
|
|
FREE_AND_SET_NULL(sNamingScreen);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DisplaySentToPCMessage(void)
|
|
|
|
{
|
|
|
|
u8 stringToDisplay = 0;
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2019-09-17 06:49:07 +01:00
|
|
|
if (!IsDestinationBoxFull())
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2019-09-17 06:49:07 +01:00
|
|
|
StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_PC_BOX_TO_SEND_MON)));
|
2020-08-07 07:00:41 +01:00
|
|
|
StringCopy(gStringVar2, sNamingScreen->destBuffer);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-17 06:49:07 +01:00
|
|
|
StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_PC_BOX_TO_SEND_MON)));
|
2020-08-07 07:00:41 +01:00
|
|
|
StringCopy(gStringVar2, sNamingScreen->destBuffer);
|
2019-09-17 06:49:07 +01:00
|
|
|
StringCopy(gStringVar3, GetBoxNamePtr(GetPCBoxToSendMon()));
|
2018-01-24 03:30:13 +00:00
|
|
|
stringToDisplay = 2;
|
|
|
|
}
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
if (FlagGet(FLAG_SYS_PC_LANETTE))
|
|
|
|
stringToDisplay++;
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2019-10-22 23:07:08 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, sTransferredToPCMessages[stringToDisplay]);
|
2019-02-22 06:40:11 +00:00
|
|
|
DrawDialogueFrame(0, 0);
|
2018-11-06 16:44:48 +00:00
|
|
|
gTextFlags.canABSpeedUpPrint = TRUE;
|
2018-11-06 17:30:21 +00:00
|
|
|
AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeedDelay(), 0, 2, 1, 3);
|
2018-01-24 03:30:13 +00:00
|
|
|
CopyWindowToVram(0, 3);
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static bool8 MainState_7(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
RunTextPrinters();
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
if (!IsTextPrinterActive(0) && JOY_NEW(A_BUTTON))
|
|
|
|
sNamingScreen->state = STATE_BEGIN_FADE_OUT;
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 MainState_StartPageSwap(void)
|
|
|
|
{
|
|
|
|
SetInputState(INPUT_STATE_DISABLED);
|
|
|
|
sub_80E4050();
|
|
|
|
StartPageSwapAnim();
|
2020-08-07 07:00:41 +01:00
|
|
|
SetCursorInvisibility(TRUE);
|
|
|
|
TryStartButtonFlash(BUTTON_PAGE, FALSE, TRUE);
|
2018-01-24 03:30:13 +00:00
|
|
|
PlaySE(SE_WIN_OPEN);
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->state = STATE_WAIT_PAGE_SWAP;
|
2018-01-24 03:30:13 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 MainState_WaitPageSwap(void)
|
|
|
|
{
|
|
|
|
s16 cursorX;
|
|
|
|
s16 cursorY;
|
|
|
|
bool32 var3;
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
if (IsPageSwapAnimNotInProgress())
|
|
|
|
{
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
GetCursorPos(&cursorX, &cursorY);
|
|
|
|
var3 = (cursorX == GetCurrentPageColumnCount());
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->state = STATE_HANDLE_INPUT;
|
|
|
|
sNamingScreen->currentPage++;
|
|
|
|
sNamingScreen->currentPage %= 3;
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
if (var3)
|
|
|
|
{
|
|
|
|
cursorX = GetCurrentPageColumnCount();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (cursorX >= GetCurrentPageColumnCount())
|
|
|
|
cursorX = GetCurrentPageColumnCount() - 1;
|
|
|
|
}
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
SetCursorPos(cursorX, cursorY);
|
2020-08-07 07:00:41 +01:00
|
|
|
DrawKeyboardPageOnDeck();
|
2018-01-24 03:30:13 +00:00
|
|
|
SetInputState(INPUT_STATE_ENABLED);
|
2020-08-07 07:00:41 +01:00
|
|
|
SetCursorInvisibility(FALSE);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
// Page Swap
|
|
|
|
//--------------------------------------------------
|
|
|
|
|
|
|
|
#define tState data[0]
|
|
|
|
#define tFrameCount data[1]
|
|
|
|
|
|
|
|
static bool8 PageSwapAnimState_Init(struct Task *);
|
|
|
|
static bool8 PageSwapAnimState_1(struct Task *);
|
|
|
|
static bool8 PageSwapAnimState_2(struct Task *);
|
|
|
|
static bool8 PageSwapAnimState_Done(struct Task *);
|
|
|
|
|
2018-04-13 13:21:49 +01:00
|
|
|
static bool8 (*const sPageSwapAnimStateFuncs[])(struct Task *) =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
PageSwapAnimState_Init,
|
|
|
|
PageSwapAnimState_1,
|
|
|
|
PageSwapAnimState_2,
|
|
|
|
PageSwapAnimState_Done,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void StartPageSwapAnim(void)
|
|
|
|
{
|
|
|
|
u8 taskId;
|
|
|
|
|
|
|
|
taskId = CreateTask(Task_HandlePageSwapAnim, 0);
|
|
|
|
Task_HandlePageSwapAnim(taskId);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Task_HandlePageSwapAnim(u8 taskId)
|
|
|
|
{
|
|
|
|
while (sPageSwapAnimStateFuncs[gTasks[taskId].tState](&gTasks[taskId]) != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 IsPageSwapAnimNotInProgress(void)
|
|
|
|
{
|
|
|
|
if (FindTaskIdByFunc(Task_HandlePageSwapAnim) == 0xFF)
|
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 PageSwapAnimState_Init(struct Task *task)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->bg1vOffset = 0;
|
|
|
|
sNamingScreen->bg2vOffset = 0;
|
2018-01-24 03:30:13 +00:00
|
|
|
task->tState++;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 PageSwapAnimState_1(struct Task *task)
|
|
|
|
{
|
|
|
|
u16 *const arr[] =
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
&sNamingScreen->bg2vOffset,
|
|
|
|
&sNamingScreen->bg1vOffset
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
task->tFrameCount += 4;
|
2020-08-07 07:00:41 +01:00
|
|
|
*arr[sNamingScreen->bgToReveal] = Sin(task->tFrameCount, 40);
|
|
|
|
*arr[sNamingScreen->bgToHide] = Sin((task->tFrameCount + 128) & 0xFF, 40);
|
2018-01-24 03:30:13 +00:00
|
|
|
if (task->tFrameCount >= 64)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
u8 temp = sNamingScreen->bg1Priority; //Why u8 and not u16?
|
2018-01-24 03:30:13 +00:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->bg1Priority = sNamingScreen->bg2Priority;
|
|
|
|
sNamingScreen->bg2Priority = temp;
|
2018-01-24 03:30:13 +00:00
|
|
|
task->tState++;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 PageSwapAnimState_2(struct Task *task)
|
|
|
|
{
|
2018-01-24 05:14:22 +00:00
|
|
|
u16 *const arr[] =
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
&sNamingScreen->bg2vOffset,
|
|
|
|
&sNamingScreen->bg1vOffset
|
2018-01-24 05:14:22 +00:00
|
|
|
};
|
2018-01-24 03:30:13 +00:00
|
|
|
|
|
|
|
task->tFrameCount += 4;
|
2020-08-07 07:00:41 +01:00
|
|
|
*arr[sNamingScreen->bgToReveal] = Sin(task->tFrameCount, 40);
|
|
|
|
*arr[sNamingScreen->bgToHide] = Sin((task->tFrameCount + 128) & 0xFF, 40);
|
2018-01-24 03:30:13 +00:00
|
|
|
if (task->tFrameCount >= 128)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
u8 temp = sNamingScreen->bgToReveal;
|
2018-01-24 03:30:13 +00:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->bgToReveal = sNamingScreen->bgToHide;
|
|
|
|
sNamingScreen->bgToHide = temp;
|
2018-01-24 03:30:13 +00:00
|
|
|
task->tState++;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 PageSwapAnimState_Done(struct Task *task)
|
|
|
|
{
|
|
|
|
DestroyTask(FindTaskIdByFunc(Task_HandlePageSwapAnim));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef tState
|
|
|
|
#undef tFrameCount
|
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
//
|
|
|
|
//--------------------------------------------------
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
#define tButtonId data[0]
|
|
|
|
#define tColor data[3]
|
|
|
|
|
|
|
|
static void CreateButtonFlashTask(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
u8 taskId;
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
taskId = CreateTask(Task_UpdateButtonFlash, 3);
|
|
|
|
gTasks[taskId].tButtonId = BUTTON_COUNT;
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void TryStartButtonFlash(u8 button, bool8 b, bool8 c)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
struct Task *task = &gTasks[FindTaskIdByFunc(Task_UpdateButtonFlash)];
|
2018-01-24 03:30:13 +00:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
if (button == task->tButtonId && !c)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
task->data[1] = b;
|
2020-08-07 07:00:41 +01:00
|
|
|
task->data[2] = TRUE;
|
2018-01-24 03:30:13 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-08-07 07:00:41 +01:00
|
|
|
if (button == BUTTON_COUNT && !task->data[1] && !c)
|
2018-01-24 03:30:13 +00:00
|
|
|
return;
|
2020-08-07 07:00:41 +01:00
|
|
|
|
|
|
|
if (task->tButtonId != BUTTON_COUNT)
|
|
|
|
RestoreButtonColor(task->tButtonId);
|
|
|
|
|
|
|
|
StartButtonFlash(task, button, b);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void Task_UpdateButtonFlash(u8 taskId)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
if (task->tButtonId == BUTTON_COUNT || !task->data[2])
|
2018-01-24 03:30:13 +00:00
|
|
|
return;
|
2020-08-07 07:00:41 +01:00
|
|
|
|
|
|
|
MultiplyInvertedPaletteRGBComponents(GetButtonPalOffset(task->tButtonId), task->tColor, task->tColor, task->tColor);
|
|
|
|
|
|
|
|
if (task->data[5] && --task->data[5])
|
|
|
|
return;
|
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
task->data[5] = 2;
|
|
|
|
if (task->data[4] >= 0)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
if (task->tColor < 14)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
task->tColor += task->data[4];
|
2018-01-24 03:30:13 +00:00
|
|
|
task->data[6] += task->data[4];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
task->tColor = 16;
|
2018-01-24 03:30:13 +00:00
|
|
|
task->data[6]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
task->tColor += task->data[4];
|
2018-01-24 03:30:13 +00:00
|
|
|
task->data[6] += task->data[4];
|
|
|
|
}
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
if (task->tColor == 16 && task->data[6] == 22)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
task->data[4] = -4;
|
|
|
|
}
|
2020-08-07 07:00:41 +01:00
|
|
|
else if (task->tColor == 0)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
task->data[2] = task->data[1];
|
|
|
|
task->data[4] = 2;
|
|
|
|
task->data[6] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static u16 GetButtonPalOffset(u8 button)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
const u16 palOffsets[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
[BUTTON_PAGE] = IndexOfSpritePaletteTag(PALTAG_PAGE_SWITCH) * 16 + 0x10E,
|
|
|
|
[BUTTON_BACK] = IndexOfSpritePaletteTag(PALTAG_BACK_BUTTON) * 16 + 0x10E,
|
|
|
|
[BUTTON_OK] = IndexOfSpritePaletteTag(PALTAG_OK_BUTTON) * 16 + 0x10E,
|
|
|
|
[BUTTON_COUNT] = IndexOfSpritePaletteTag(PALTAG_OK_BUTTON) * 16 + 0x101,
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
return palOffsets[button];
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void RestoreButtonColor(u8 button)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
u16 index = GetButtonPalOffset(button);
|
2018-01-24 03:30:13 +00:00
|
|
|
gPlttBufferFaded[index] = gPlttBufferUnfaded[index];
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void StartButtonFlash(struct Task *task, u8 button, bool8 c)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
task->tButtonId = button;
|
2018-01-24 03:30:13 +00:00
|
|
|
task->data[1] = c;
|
2020-08-07 07:00:41 +01:00
|
|
|
task->data[2] = TRUE;
|
|
|
|
task->tColor = 4;
|
2018-01-24 03:30:13 +00:00
|
|
|
task->data[4] = 2;
|
|
|
|
task->data[5] = 0;
|
|
|
|
task->data[6] = 4;
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
#undef tButtonId
|
|
|
|
#undef tColor
|
|
|
|
|
|
|
|
#define tInvisible data[4] & 0x00FF
|
|
|
|
#define tFlashing data[4] & 0xFF00
|
|
|
|
|
|
|
|
static void SpriteCB_Cursor(struct Sprite *sprite)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
if (sprite->animEnded)
|
|
|
|
StartSpriteAnim(sprite, 0);
|
2020-08-07 07:00:41 +01:00
|
|
|
sprite->invisible = sprite->tInvisible;
|
2018-01-24 03:30:13 +00:00
|
|
|
if (sprite->data[0] == GetCurrentPageColumnCount())
|
|
|
|
sprite->invisible = TRUE;
|
2020-08-07 07:00:41 +01:00
|
|
|
if (sprite->invisible || !(sprite->tFlashing)
|
2018-01-24 03:30:13 +00:00
|
|
|
|| sprite->data[0] != sprite->data[2] || sprite->data[1] != sprite->data[3])
|
|
|
|
{
|
|
|
|
sprite->data[5] = 0;
|
|
|
|
sprite->data[6] = 2;
|
|
|
|
sprite->data[7] = 2;
|
|
|
|
}
|
|
|
|
sprite->data[7]--;
|
|
|
|
if (sprite->data[7] == 0)
|
|
|
|
{
|
|
|
|
sprite->data[5] += sprite->data[6];
|
|
|
|
if (sprite->data[5] == 16 || sprite->data[5] == 0)
|
|
|
|
sprite->data[6] = -sprite->data[6];
|
|
|
|
sprite->data[7] = 2;
|
|
|
|
}
|
2020-08-07 07:00:41 +01:00
|
|
|
if (sprite->tFlashing)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
s8 gb = sprite->data[5];
|
|
|
|
s8 r = sprite->data[5] >> 1;
|
2020-08-07 07:00:41 +01:00
|
|
|
u16 index = IndexOfSpritePaletteTag(PALTAG_CURSOR) * 16 + 0x0101;
|
2018-01-24 03:30:13 +00:00
|
|
|
|
|
|
|
MultiplyInvertedPaletteRGBComponents(index, r, gb, gb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
#define sDelay data[0]
|
|
|
|
#define sXPosId data[1]
|
|
|
|
|
|
|
|
static void SpriteCB_InputArrow(struct Sprite *sprite)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
const s16 x[] = {0, -4, -2, -1};
|
2018-01-24 03:30:13 +00:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
if (sprite->sDelay == 0 || --sprite->sDelay == 0)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
sprite->sDelay = 8;
|
|
|
|
sprite->sXPosId = (sprite->sXPosId + 1) & (ARRAY_COUNT(x) - 1);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
2020-08-07 07:00:41 +01:00
|
|
|
sprite->pos2.x = x[sprite->sXPosId];
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
#undef sDelay
|
|
|
|
#undef sXPosId
|
|
|
|
|
|
|
|
static void SpriteCB_Underscore(struct Sprite *sprite)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
const s16 arr[] = {2, 3, 2, 1};
|
|
|
|
u8 var;
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
var = GetTextEntryPosition();
|
2018-01-24 03:30:13 +00:00
|
|
|
if (var != (u8)sprite->data[0])
|
|
|
|
{
|
|
|
|
sprite->pos2.y = 0;
|
|
|
|
sprite->data[1] = 0;
|
|
|
|
sprite->data[2] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprite->pos2.y = arr[sprite->data[1]];
|
|
|
|
sprite->data[2]++;
|
|
|
|
if (sprite->data[2] > 8)
|
|
|
|
{
|
|
|
|
sprite->data[1] = (sprite->data[1] + 1) & 3;
|
|
|
|
sprite->data[2] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void CreateSprites(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
CreateCursorSprite();
|
2018-01-24 05:14:22 +00:00
|
|
|
CreatePageSwitcherSprites();
|
|
|
|
CreateBackOkSprites();
|
2020-08-07 07:00:41 +01:00
|
|
|
CreateTextEntrySprites();
|
2018-01-24 05:14:22 +00:00
|
|
|
CreateInputTargetIcon();
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void CreateCursorSprite(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->cursorSpriteId = CreateSprite(&sSpriteTemplate_Cursor, 38, 88, 1);
|
|
|
|
SetCursorInvisibility(TRUE);
|
|
|
|
gSprites[sNamingScreen->cursorSpriteId].oam.priority = 1;
|
|
|
|
gSprites[sNamingScreen->cursorSpriteId].oam.objMode = ST_OAM_OBJ_BLEND;
|
|
|
|
gSprites[sNamingScreen->cursorSpriteId].data[6] = 1;
|
|
|
|
gSprites[sNamingScreen->cursorSpriteId].data[6] = 2;
|
2018-01-24 03:30:13 +00:00
|
|
|
SetCursorPos(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SetCursorPos(s16 x, s16 y)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
struct Sprite *cursorSprite = &gSprites[sNamingScreen->cursorSpriteId];
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
if (x < sPageColumnCounts[sub_80E3274()])
|
|
|
|
cursorSprite->pos1.x = sPageColumnXPos[x + sub_80E3274() * KBCOL_COUNT] + 38;
|
2018-01-24 03:30:13 +00:00
|
|
|
else
|
|
|
|
cursorSprite->pos1.x = 0;
|
|
|
|
|
|
|
|
cursorSprite->pos1.y = y * 16 + 88;
|
|
|
|
cursorSprite->data[2] = cursorSprite->data[0];
|
|
|
|
cursorSprite->data[3] = cursorSprite->data[1];
|
|
|
|
cursorSprite->data[0] = x;
|
|
|
|
cursorSprite->data[1] = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void GetCursorPos(s16 *x, s16 *y)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
struct Sprite *cursorSprite = &gSprites[sNamingScreen->cursorSpriteId];
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
*x = cursorSprite->data[0];
|
|
|
|
*y = cursorSprite->data[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void MoveCursorToOKButton(void)
|
|
|
|
{
|
|
|
|
SetCursorPos(GetCurrentPageColumnCount(), 2);
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void SetCursorInvisibility(bool8 invisible)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
gSprites[sNamingScreen->cursorSpriteId].data[4] &= 0xFF00;
|
|
|
|
gSprites[sNamingScreen->cursorSpriteId].data[4] |= invisible;
|
|
|
|
StartSpriteAnim(&gSprites[sNamingScreen->cursorSpriteId], 0);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void SetCursorFlashing(bool8 flashing)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
gSprites[sNamingScreen->cursorSpriteId].data[4] &= 0xFF;
|
|
|
|
gSprites[sNamingScreen->cursorSpriteId].data[4] |= flashing << 8;
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void SquishCursor(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
StartSpriteAnim(&gSprites[sNamingScreen->cursorSpriteId], 1);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 IsCursorAnimFinished(void)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
return gSprites[sNamingScreen->cursorSpriteId].animEnded;
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const u8 sButtonKeyRoles[] = {KEY_ROLE_PAGE, KEY_ROLE_BACKSPACE, KEY_ROLE_OK};
|
2018-01-24 03:30:13 +00:00
|
|
|
|
|
|
|
static u8 GetKeyRoleAtCursorPos(void)
|
|
|
|
{
|
|
|
|
s16 cursorX;
|
|
|
|
s16 cursorY;
|
|
|
|
|
|
|
|
GetCursorPos(&cursorX, &cursorY);
|
|
|
|
if (cursorX < GetCurrentPageColumnCount())
|
|
|
|
return KEY_ROLE_CHAR;
|
|
|
|
else
|
2020-08-07 07:00:41 +01:00
|
|
|
return sButtonKeyRoles[cursorY];
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
// If the cursor's x is equal to the column count, cursor is in the button column
|
2018-01-24 03:30:13 +00:00
|
|
|
static u8 GetCurrentPageColumnCount(void)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
return sPageColumnCounts[sub_80E3274()];
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2018-01-24 05:14:22 +00:00
|
|
|
static void CreatePageSwitcherSprites(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
u8 bgSpriteId;
|
|
|
|
u8 textSpriteId;
|
|
|
|
u8 buttonSpriteId;
|
2018-01-24 03:30:13 +00:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
bgSpriteId = CreateSprite(&sSpriteTemplate_PageSwitchBg, 204, 88, 0);
|
|
|
|
sNamingScreen->selectBtnFrameSpriteId = bgSpriteId;
|
|
|
|
SetSubspriteTables(&gSprites[bgSpriteId], sSubspriteTable_PageSwitchBg);
|
|
|
|
gSprites[bgSpriteId].invisible = TRUE;
|
2018-01-24 03:30:13 +00:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
textSpriteId = CreateSprite(&sSpriteTemplate_PageSwitchText, 204, 84, 1);
|
|
|
|
gSprites[bgSpriteId].data[6] = textSpriteId;
|
|
|
|
SetSubspriteTables(&gSprites[textSpriteId], sSubspriteTable_PageSwitchText);
|
|
|
|
gSprites[textSpriteId].invisible = TRUE;
|
2018-01-24 03:30:13 +00:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
buttonSpriteId = CreateSprite(&sSpriteTemplate_PageSwitchButton, 204, 83, 2);
|
|
|
|
gSprites[buttonSpriteId].oam.priority = 1;
|
|
|
|
gSprites[bgSpriteId].data[7] = buttonSpriteId;
|
|
|
|
gSprites[buttonSpriteId].invisible = TRUE;
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_80E4050(void)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
struct Sprite *sprite = &gSprites[sNamingScreen->selectBtnFrameSpriteId];
|
2018-01-24 03:30:13 +00:00
|
|
|
|
|
|
|
sprite->data[0] = 2;
|
2020-08-07 07:00:41 +01:00
|
|
|
sprite->data[1] = sNamingScreen->currentPage;
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u8 sub_80E40AC(struct Sprite *);
|
|
|
|
static u8 sub_80E4100(struct Sprite *);
|
|
|
|
static u8 sub_80E4104(struct Sprite *);
|
|
|
|
static u8 sub_80E4178(struct Sprite *);
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static u8 (*const sPageSwitchSpriteFuncs[])(struct Sprite *) =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
sub_80E40AC,
|
|
|
|
sub_80E4100,
|
|
|
|
sub_80E4104,
|
|
|
|
sub_80E4178,
|
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void SpriteCB_PageSwitch(struct Sprite *sprite)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
while (sPageSwitchSpriteFuncs[sprite->data[0]](sprite) != 0);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u8 sub_80E40AC(struct Sprite *sprite)
|
|
|
|
{
|
|
|
|
struct Sprite *sprite1 = &gSprites[sprite->data[6]];
|
|
|
|
struct Sprite *sprite2 = &gSprites[sprite->data[7]];
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
sub_80E41B8(sub_80E3244(sNamingScreen->currentPage), sprite1, sprite2);
|
2018-01-24 03:30:13 +00:00
|
|
|
sprite->data[0]++;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 sub_80E4100(struct Sprite *sprite)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 sub_80E4104(struct Sprite *sprite)
|
|
|
|
{
|
|
|
|
struct Sprite *r4 = &gSprites[sprite->data[6]];
|
|
|
|
struct Sprite *r5 = &gSprites[sprite->data[7]];
|
|
|
|
|
|
|
|
r4->pos2.y++;
|
|
|
|
if (r4->pos2.y > 7)
|
|
|
|
{
|
|
|
|
sprite->data[0]++;
|
|
|
|
r4->pos2.y = -4;
|
|
|
|
r4->invisible = TRUE;
|
|
|
|
sub_80E41B8(sub_80E3244(((u8)sprite->data[1] + 1) % 3), r4, r5);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 sub_80E4178(struct Sprite *sprite)
|
|
|
|
{
|
|
|
|
struct Sprite *r2 = &gSprites[sprite->data[6]];
|
|
|
|
|
|
|
|
r2->invisible = FALSE;
|
|
|
|
r2->pos2.y++;
|
|
|
|
if (r2->pos2.y >= 0)
|
|
|
|
{
|
|
|
|
r2->pos2.y = 0;
|
|
|
|
sprite->data[0] = 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const u16 gUnknown_0858BEF8[] = {
|
|
|
|
PALTAG_1,
|
|
|
|
PALTAG_3,
|
|
|
|
PALTAG_2
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u16 gUnknown_0858BEFE[] = {
|
|
|
|
GFXTAG_PAGE_SWITCH_UPPER,
|
|
|
|
GFXTAG_PAGE_SWITCH_OTHERS,
|
|
|
|
GFXTAG_PAGE_SWITCH_LOWER
|
|
|
|
};
|
2018-01-24 03:30:13 +00:00
|
|
|
|
|
|
|
static void sub_80E41B8(u8 a, struct Sprite *b, struct Sprite *c)
|
|
|
|
{
|
|
|
|
c->oam.paletteNum = IndexOfSpritePaletteTag(gUnknown_0858BEF8[a]);
|
|
|
|
b->sheetTileStart = GetSpriteTileStartByTag(gUnknown_0858BEFE[a]);
|
|
|
|
b->subspriteTableNum = a;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
2018-01-24 05:14:22 +00:00
|
|
|
static void CreateBackOkSprites(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_BackButton, 204, 116, 0);
|
|
|
|
SetSubspriteTables(&gSprites[spriteId], sSubspriteTable_Button);
|
2018-01-24 03:30:13 +00:00
|
|
|
gSprites[spriteId].invisible = TRUE;
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_OkButton, 204, 140, 0);
|
|
|
|
SetSubspriteTables(&gSprites[spriteId], sSubspriteTable_Button);
|
2018-01-24 03:30:13 +00:00
|
|
|
gSprites[spriteId].invisible = TRUE;
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void CreateTextEntrySprites(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
2018-01-24 05:14:22 +00:00
|
|
|
s16 xPos;
|
2018-01-24 03:30:13 +00:00
|
|
|
u8 i;
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
xPos = sNamingScreen->inputCharBaseXPos - 5;
|
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_InputArrow, xPos, 56, 0);
|
2018-01-24 03:30:13 +00:00
|
|
|
gSprites[spriteId].oam.priority = 3;
|
|
|
|
gSprites[spriteId].invisible = TRUE;
|
2020-08-07 07:00:41 +01:00
|
|
|
xPos = sNamingScreen->inputCharBaseXPos;
|
|
|
|
for (i = 0; i < sNamingScreen->template->maxChars; i++, xPos += 8)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_Underscore, xPos + 3, 60, 0);
|
2018-01-24 03:30:13 +00:00
|
|
|
gSprites[spriteId].oam.priority = 3;
|
|
|
|
gSprites[spriteId].data[0] = i;
|
|
|
|
gSprites[spriteId].invisible = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-24 05:14:22 +00:00
|
|
|
//--------------------------------------------------
|
|
|
|
// Icon creation (the thing you're naming or giving input to)
|
|
|
|
//--------------------------------------------------
|
2018-01-24 03:30:13 +00:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void NamingScreen_NoIcon(void);
|
2018-01-24 05:14:22 +00:00
|
|
|
static void NamingScreen_CreatePlayerIcon(void);
|
|
|
|
static void NamingScreen_CreatePCIcon(void);
|
|
|
|
static void NamingScreen_CreateMonIcon(void);
|
2020-08-07 07:00:41 +01:00
|
|
|
static void NamingScreen_CreateWaldaDadIcon(void);
|
2018-01-24 03:30:13 +00:00
|
|
|
|
2018-01-24 05:14:22 +00:00
|
|
|
static void (*const sIconFunctions[])(void) =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
NamingScreen_NoIcon,
|
2018-01-24 05:14:22 +00:00
|
|
|
NamingScreen_CreatePlayerIcon,
|
|
|
|
NamingScreen_CreatePCIcon,
|
|
|
|
NamingScreen_CreateMonIcon,
|
2020-08-07 07:00:41 +01:00
|
|
|
NamingScreen_CreateWaldaDadIcon,
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2018-01-24 05:14:22 +00:00
|
|
|
static void CreateInputTargetIcon(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
sIconFunctions[sNamingScreen->template->iconFunction]();
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void NamingScreen_NoIcon(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2018-01-24 05:14:22 +00:00
|
|
|
static void NamingScreen_CreatePlayerIcon(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
u8 rivalGfxId;
|
|
|
|
u8 spriteId;
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
rivalGfxId = GetRivalAvatarGraphicsIdByStateIdAndGender(0, sNamingScreen->monSpecies);
|
|
|
|
spriteId = AddPseudoObjectEvent(rivalGfxId, SpriteCallbackDummy, 56, 37, 0);
|
2018-01-24 03:30:13 +00:00
|
|
|
gSprites[spriteId].oam.priority = 3;
|
|
|
|
StartSpriteAnim(&gSprites[spriteId], 4);
|
|
|
|
}
|
|
|
|
|
2018-01-24 05:14:22 +00:00
|
|
|
static void NamingScreen_CreatePCIcon(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
spriteId = CreateSprite(&sSpriteTemplate_PCIcon, 56, 41, 0);
|
|
|
|
SetSubspriteTables(&gSprites[spriteId], sSubspriteTable_PCIcon);
|
2018-01-24 03:30:13 +00:00
|
|
|
gSprites[spriteId].oam.priority = 3;
|
|
|
|
}
|
|
|
|
|
2018-01-24 05:14:22 +00:00
|
|
|
static void NamingScreen_CreateMonIcon(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
|
2018-04-13 13:21:49 +01:00
|
|
|
LoadMonIconPalettes();
|
2020-08-07 07:00:41 +01:00
|
|
|
spriteId = CreateMonIcon(sNamingScreen->monSpecies, SpriteCallbackDummy, 56, 40, 0, sNamingScreen->monPersonality, 1);
|
2018-01-24 03:30:13 +00:00
|
|
|
gSprites[spriteId].oam.priority = 3;
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void NamingScreen_CreateWaldaDadIcon(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
spriteId = AddPseudoObjectEvent(OBJ_EVENT_GFX_MAN_1, SpriteCallbackDummy, 56, 37, 0);
|
2018-01-24 03:30:13 +00:00
|
|
|
gSprites[spriteId].oam.priority = 3;
|
|
|
|
StartSpriteAnim(&gSprites[spriteId], 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
// Keyboard handling
|
|
|
|
//--------------------------------------------------
|
|
|
|
|
|
|
|
static bool8 KeyboardKeyHandler_Character(u8);
|
|
|
|
static bool8 KeyboardKeyHandler_Page(u8);
|
|
|
|
static bool8 KeyboardKeyHandler_Backspace(u8);
|
|
|
|
static bool8 KeyboardKeyHandler_OK(u8);
|
|
|
|
|
|
|
|
static bool8 (*const sKeyboardKeyHandlers[])(u8) =
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
[KEY_ROLE_CHAR] = KeyboardKeyHandler_Character,
|
|
|
|
[KEY_ROLE_PAGE] = KeyboardKeyHandler_Page,
|
|
|
|
[KEY_ROLE_BACKSPACE] = KeyboardKeyHandler_Backspace,
|
|
|
|
[KEY_ROLE_OK] = KeyboardKeyHandler_OK,
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static bool8 HandleKeyboardEvent(void)
|
|
|
|
{
|
|
|
|
u8 event = GetInputEvent();
|
|
|
|
u8 keyRole = GetKeyRoleAtCursorPos();
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
if (event == INPUT_SELECT)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
return SwitchKeyboardPage();
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
2020-08-07 07:00:41 +01:00
|
|
|
else if (event == INPUT_B_BUTTON)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
DeleteTextCharacter();
|
|
|
|
return FALSE;
|
|
|
|
}
|
2020-08-07 07:00:41 +01:00
|
|
|
else if (event == INPUT_START)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
MoveCursorToOKButton();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return sKeyboardKeyHandlers[keyRole](event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 KeyboardKeyHandler_Character(u8 event)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
TryStartButtonFlash(BUTTON_COUNT, FALSE, FALSE);
|
|
|
|
if (event == INPUT_A_BUTTON)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
bool8 textFull = AddTextCharacter();
|
2018-01-24 03:30:13 +00:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
SquishCursor();
|
|
|
|
if (textFull)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
SetInputState(INPUT_STATE_2);
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->state = STATE_MOVE_TO_OK_BUTTON;
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 KeyboardKeyHandler_Page(u8 event)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
TryStartButtonFlash(BUTTON_PAGE, TRUE, FALSE);
|
|
|
|
if (event == INPUT_A_BUTTON)
|
|
|
|
return SwitchKeyboardPage();
|
2018-01-24 03:30:13 +00:00
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 KeyboardKeyHandler_Backspace(u8 event)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
TryStartButtonFlash(BUTTON_BACK, TRUE, FALSE);
|
|
|
|
if (event == INPUT_A_BUTTON)
|
2018-01-24 03:30:13 +00:00
|
|
|
DeleteTextCharacter();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool8 KeyboardKeyHandler_OK(u8 event)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
TryStartButtonFlash(BUTTON_OK, TRUE, FALSE);
|
|
|
|
if (event == INPUT_A_BUTTON)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->state = STATE_6;
|
2018-01-24 03:30:13 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static bool8 SwitchKeyboardPage(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->state = STATE_START_PAGE_SWAP;
|
2018-01-24 03:30:13 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
// Input handling
|
|
|
|
//--------------------------------------------------
|
|
|
|
|
|
|
|
#define tState data[0]
|
|
|
|
#define tKeyboardEvent data[1]
|
2020-08-07 07:00:41 +01:00
|
|
|
#define tButtonId data[2]
|
2018-01-24 03:30:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void InputState_Disabled(struct Task *);
|
|
|
|
static void InputState_Enabled(struct Task *);
|
|
|
|
static void InputState_2(struct Task *);
|
|
|
|
|
|
|
|
static void (*const sInputStateFuncs[])(struct Task *) =
|
|
|
|
{
|
|
|
|
InputState_Disabled,
|
|
|
|
InputState_Enabled,
|
|
|
|
InputState_2,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void Task_HandleInput(u8);
|
|
|
|
static void HandleDpadMovement(struct Task *);
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void CreateInputHandlerTask(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
CreateTask(Task_HandleInput, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 GetInputEvent(void)
|
|
|
|
{
|
|
|
|
u8 taskId = FindTaskIdByFunc(Task_HandleInput);
|
|
|
|
|
|
|
|
return gTasks[taskId].tKeyboardEvent;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SetInputState(u8 state)
|
|
|
|
{
|
|
|
|
u8 taskId = FindTaskIdByFunc(Task_HandleInput);
|
|
|
|
|
|
|
|
gTasks[taskId].tState = state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Task_HandleInput(u8 taskId)
|
|
|
|
{
|
|
|
|
sInputStateFuncs[gTasks[taskId].tState](&gTasks[taskId]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void InputState_Disabled(struct Task *task)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
task->tKeyboardEvent = INPUT_NONE;
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void InputState_Enabled(struct Task *task)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
task->tKeyboardEvent = INPUT_NONE;
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
|
|
|
task->tKeyboardEvent = INPUT_A_BUTTON;
|
|
|
|
else if (JOY_NEW(B_BUTTON))
|
|
|
|
task->tKeyboardEvent = INPUT_B_BUTTON;
|
|
|
|
else if (JOY_NEW(SELECT_BUTTON))
|
|
|
|
task->tKeyboardEvent = INPUT_SELECT;
|
|
|
|
else if (JOY_NEW(START_BUTTON))
|
|
|
|
task->tKeyboardEvent = INPUT_START;
|
2018-01-24 03:30:13 +00:00
|
|
|
else
|
|
|
|
HandleDpadMovement(task);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void InputState_2(struct Task *task)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
task->tKeyboardEvent = INPUT_NONE;
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void HandleDpadMovement(struct Task *task)
|
|
|
|
{
|
|
|
|
const s16 sDpadDeltaX[] =
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
[INPUT_NONE] = 0,
|
|
|
|
[INPUT_DPAD_UP] = 0,
|
|
|
|
[INPUT_DPAD_DOWN] = 0,
|
|
|
|
[INPUT_DPAD_LEFT] = -1,
|
|
|
|
[INPUT_DPAD_RIGHT] = 1
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const s16 sDpadDeltaY[] =
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
[INPUT_NONE] = 0,
|
|
|
|
[INPUT_DPAD_UP] = -1,
|
|
|
|
[INPUT_DPAD_DOWN] = 1,
|
|
|
|
[INPUT_DPAD_LEFT] = 0,
|
|
|
|
[INPUT_DPAD_RIGHT] = 0
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
const s16 sKeyRowToButtonRow[KBROW_COUNT] = {0, 1, 1, 2};
|
2018-01-24 03:30:13 +00:00
|
|
|
const s16 gUnknown_0858BF50[] = {0, 0, 3};
|
|
|
|
|
|
|
|
s16 cursorX;
|
|
|
|
s16 cursorY;
|
2020-08-07 07:00:41 +01:00
|
|
|
u16 input;
|
2018-01-24 03:30:13 +00:00
|
|
|
s16 prevCursorX;
|
|
|
|
|
|
|
|
GetCursorPos(&cursorX, &cursorY);
|
2020-08-07 07:00:41 +01:00
|
|
|
input = INPUT_NONE;
|
|
|
|
if (JOY_REPEAT(DPAD_UP))
|
|
|
|
input = INPUT_DPAD_UP;
|
|
|
|
if (JOY_REPEAT(DPAD_DOWN))
|
|
|
|
input = INPUT_DPAD_DOWN;
|
|
|
|
if (JOY_REPEAT(DPAD_LEFT))
|
|
|
|
input = INPUT_DPAD_LEFT;
|
|
|
|
if (JOY_REPEAT(DPAD_RIGHT))
|
|
|
|
input = INPUT_DPAD_RIGHT;
|
|
|
|
|
|
|
|
// Get new cursor position
|
2018-01-24 03:30:13 +00:00
|
|
|
prevCursorX = cursorX;
|
2020-08-07 07:00:41 +01:00
|
|
|
cursorX += sDpadDeltaX[input];
|
|
|
|
cursorY += sDpadDeltaY[input];
|
2018-01-24 03:30:13 +00:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
// Wrap cursor position in the X direction
|
2018-01-24 03:30:13 +00:00
|
|
|
if (cursorX < 0)
|
|
|
|
cursorX = GetCurrentPageColumnCount();
|
|
|
|
if (cursorX > GetCurrentPageColumnCount())
|
|
|
|
cursorX = 0;
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
|
|
|
|
// Handle moving on/off the button column
|
|
|
|
if (sDpadDeltaX[input] != 0)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
if (cursorX == GetCurrentPageColumnCount())
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
// Moved onto button column
|
|
|
|
task->tButtonId = cursorY;
|
|
|
|
cursorY = sKeyRowToButtonRow[cursorY];
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
else if (prevCursorX == GetCurrentPageColumnCount())
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
// Moved off button column
|
2018-01-24 03:30:13 +00:00
|
|
|
if (cursorY == 1)
|
2020-08-07 07:00:41 +01:00
|
|
|
cursorY = task->tButtonId;
|
2018-01-24 03:30:13 +00:00
|
|
|
else
|
|
|
|
cursorY = gUnknown_0858BF50[cursorY];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
// Wrap cursor position in the y direction
|
2018-01-24 03:30:13 +00:00
|
|
|
if (cursorX == GetCurrentPageColumnCount())
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
// There are only 3 keys in the button column
|
|
|
|
// so wrap Y accordingly
|
2018-01-24 03:30:13 +00:00
|
|
|
if (cursorY < 0)
|
2020-08-07 07:00:41 +01:00
|
|
|
cursorY = BUTTON_COUNT - 1;
|
|
|
|
if (cursorY >= BUTTON_COUNT)
|
2018-01-24 03:30:13 +00:00
|
|
|
cursorY = 0;
|
2020-08-07 07:00:41 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
if (cursorY == 0)
|
2020-08-07 07:00:41 +01:00
|
|
|
task->tButtonId = BUTTON_BACK;
|
|
|
|
else if (cursorY == BUTTON_COUNT - 1)
|
|
|
|
task->tButtonId = BUTTON_OK;
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (cursorY < 0)
|
2020-08-07 07:00:41 +01:00
|
|
|
cursorY = KBROW_COUNT - 1;
|
|
|
|
if (cursorY > KBROW_COUNT - 1)
|
2018-01-24 03:30:13 +00:00
|
|
|
cursorY = 0;
|
|
|
|
}
|
|
|
|
SetCursorPos(cursorX, cursorY);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef tState
|
|
|
|
#undef tKeyboardEvent
|
2020-08-07 07:00:41 +01:00
|
|
|
#undef tButtonId
|
2018-01-24 03:30:13 +00:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void DrawNormalTextEntryBox(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
FillWindowPixelBuffer(sNamingScreen->windows[WIN_TEXT_ENTRY_BOX], PIXEL_FILL(1));
|
|
|
|
AddTextPrinterParameterized(sNamingScreen->windows[WIN_TEXT_ENTRY_BOX], 1, sNamingScreen->template->title, 8, 1, 0, 0);
|
|
|
|
PutWindowTilemap(sNamingScreen->windows[WIN_TEXT_ENTRY_BOX]);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void DrawMonTextEntryBox(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
u8 buffer[32];
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
StringCopy(buffer, gSpeciesNames[sNamingScreen->monSpecies]);
|
|
|
|
StringAppendN(buffer, sNamingScreen->template->title, 15);
|
|
|
|
FillWindowPixelBuffer(sNamingScreen->windows[WIN_TEXT_ENTRY_BOX], PIXEL_FILL(1));
|
|
|
|
AddTextPrinterParameterized(sNamingScreen->windows[WIN_TEXT_ENTRY_BOX], 1, buffer, 8, 1, 0, 0);
|
|
|
|
PutWindowTilemap(sNamingScreen->windows[WIN_TEXT_ENTRY_BOX]);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void (*const sDrawTextEntryBoxFuncs[])(void) =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
[NAMING_SCREEN_PLAYER] = DrawNormalTextEntryBox,
|
|
|
|
[NAMING_SCREEN_BOX] = DrawNormalTextEntryBox,
|
|
|
|
[NAMING_SCREEN_CAUGHT_MON] = DrawMonTextEntryBox,
|
|
|
|
[NAMING_SCREEN_NICKNAME] = DrawMonTextEntryBox,
|
|
|
|
[NAMING_SCREEN_WALDA] = DrawNormalTextEntryBox,
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void DrawTextEntryBox(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
sDrawTextEntryBoxFuncs[sNamingScreen->templateNum]();
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void DummyGenderIcon(void);
|
|
|
|
static void DrawGenderIcon(void);
|
2018-01-24 03:30:13 +00:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void (*const sDrawGenderIconFuncs[])(void) =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
[FALSE] = DummyGenderIcon,
|
|
|
|
[TRUE] = DrawGenderIcon,
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void TryDrawGenderIcon(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
sDrawGenderIconFuncs[sNamingScreen->template->addGenderIcon]();
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void DummyGenderIcon(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2018-04-13 13:21:49 +01:00
|
|
|
static const u8 sGenderColors[2][3] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2019-12-10 18:48:20 +00:00
|
|
|
{TEXT_COLOR_TRANSPARENT, TEXT_COLOR_LIGHT_BLUE, TEXT_COLOR_BLUE},
|
|
|
|
{TEXT_COLOR_TRANSPARENT, TEXT_COLOR_LIGHT_RED, TEXT_COLOR_RED}
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void DrawGenderIcon(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
u8 text[2];
|
2018-01-24 03:30:13 +00:00
|
|
|
bool8 isFemale = FALSE;
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
StringCopy(text, gText_MaleSymbol);
|
|
|
|
if (sNamingScreen->monGender != MON_GENDERLESS)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
if (sNamingScreen->monGender == MON_FEMALE)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
StringCopy(text, gText_FemaleSymbol);
|
2018-01-24 03:30:13 +00:00
|
|
|
isFemale = TRUE;
|
|
|
|
}
|
2020-08-07 07:00:41 +01:00
|
|
|
AddTextPrinterParameterized3(sNamingScreen->windows[WIN_TEXT_ENTRY], 1, 0x68, 1, sGenderColors[isFemale], -1, text);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static u8 GetCharAtKeyboardPos(s16 x, s16 y)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
return sKeyboardChars[x + y * KBCOL_COUNT + sub_80E3274() * KBCOL_COUNT * KBROW_COUNT];
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static u8 GetTextEntryPosition(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
for (i = 0; i < sNamingScreen->template->maxChars; i++)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
if (sNamingScreen->textBuffer[i] == EOS)
|
2018-01-24 03:30:13 +00:00
|
|
|
return i;
|
|
|
|
}
|
2020-08-07 07:00:41 +01:00
|
|
|
return sNamingScreen->template->maxChars - 1;
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u8 GetPreviousTextCaretPosition(void)
|
|
|
|
{
|
|
|
|
s8 i;
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
for (i = sNamingScreen->template->maxChars - 1; i > 0; i--)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
if (sNamingScreen->textBuffer[i] != EOS)
|
2018-01-24 03:30:13 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DeleteTextCharacter(void)
|
|
|
|
{
|
|
|
|
u8 index;
|
|
|
|
u8 var2;
|
|
|
|
|
|
|
|
index = GetPreviousTextCaretPosition();
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->textBuffer[index] = 0;
|
|
|
|
DrawTextEntry();
|
2018-01-24 03:30:13 +00:00
|
|
|
CopyBgTilemapBufferToVram(3);
|
2020-08-07 07:00:41 +01:00
|
|
|
sNamingScreen->textBuffer[index] = EOS;
|
2018-01-24 03:30:13 +00:00
|
|
|
var2 = GetKeyRoleAtCursorPos();
|
|
|
|
if (var2 == 0 || var2 == 2)
|
2020-08-07 07:00:41 +01:00
|
|
|
TryStartButtonFlash(BUTTON_BACK, FALSE, TRUE);
|
2018-01-24 03:30:13 +00:00
|
|
|
PlaySE(SE_BOWA);
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
// Returns TRUE if the text entry is now full
|
|
|
|
static bool8 AddTextCharacter(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
|
|
|
|
GetCursorPos(&x, &y);
|
2020-08-07 07:00:41 +01:00
|
|
|
BufferCharacter(GetCharAtKeyboardPos(x, y));
|
|
|
|
DrawTextEntry();
|
2018-01-24 03:30:13 +00:00
|
|
|
CopyBgTilemapBufferToVram(3);
|
|
|
|
PlaySE(SE_SELECT);
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
if (GetPreviousTextCaretPosition() != sNamingScreen->template->maxChars - 1)
|
2018-01-24 03:30:13 +00:00
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void BufferCharacter(u8 ch)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
u8 index = GetTextEntryPosition();
|
|
|
|
sNamingScreen->textBuffer[index] = ch;
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void SaveInputText(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
for (i = 0; i < sNamingScreen->template->maxChars; i++)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
if (sNamingScreen->textBuffer[i] != CHAR_SPACE && sNamingScreen->textBuffer[i] != EOS)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
StringCopyN(sNamingScreen->destBuffer, sNamingScreen->textBuffer, sNamingScreen->template->maxChars + 1);
|
2018-01-24 03:30:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void LoadGfx(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
LZ77UnCompWram(gNamingScreenMenu_Gfx, sNamingScreen->tileBuffer);
|
|
|
|
LoadBgTiles(1, sNamingScreen->tileBuffer, sizeof(sNamingScreen->tileBuffer), 0);
|
|
|
|
LoadBgTiles(2, sNamingScreen->tileBuffer, sizeof(sNamingScreen->tileBuffer), 0);
|
|
|
|
LoadBgTiles(3, sNamingScreen->tileBuffer, sizeof(sNamingScreen->tileBuffer), 0);
|
|
|
|
LoadSpriteSheets(sSpriteSheets);
|
|
|
|
LoadSpritePalettes(sSpritePalettes);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void CreateHelperTasks(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
CreateInputHandlerTask();
|
|
|
|
CreateButtonFlashTask();
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void LoadPalettes(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
LoadPalette(gNamingScreenMenu_Pal, 0, 0xC0);
|
2020-08-07 07:00:41 +01:00
|
|
|
LoadPalette(sKeyboard_Pal, 0xA0, sizeof(sKeyboard_Pal));
|
|
|
|
LoadPalette(GetTextWindowPalette(2), 0xB0, 0x20);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void DrawBgTilemap(u8 bg, const void *src)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
CopyToBgTilemapBuffer(bg, src, 0, 0);
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void NamingScreen_Dummy(u8 bg, u8 page)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void DrawTextEntry(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 temp[2];
|
2020-08-07 07:00:41 +01:00
|
|
|
u16 extraWidth;
|
|
|
|
u8 maxChars = sNamingScreen->template->maxChars;
|
|
|
|
u16 x = sNamingScreen->inputCharBaseXPos - 0x40;
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
FillWindowPixelBuffer(sNamingScreen->windows[WIN_TEXT_ENTRY], PIXEL_FILL(1));
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
for (i = 0; i < maxChars; i++)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
temp[0] = sNamingScreen->textBuffer[i];
|
2019-12-05 20:33:36 +00:00
|
|
|
temp[1] = gText_ExpandedPlaceholder_Empty[0];
|
2020-08-07 07:00:41 +01:00
|
|
|
extraWidth = (IsWideLetter(temp[0]) == TRUE) ? 2 : 0;
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
AddTextPrinterParameterized(sNamingScreen->windows[WIN_TEXT_ENTRY], 1, temp, i * 8 + x + extraWidth, 1, 0xFF, NULL);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
TryDrawGenderIcon();
|
|
|
|
CopyWindowToVram(sNamingScreen->windows[WIN_TEXT_ENTRY], 2);
|
|
|
|
PutWindowTilemap(sNamingScreen->windows[WIN_TEXT_ENTRY]);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 18:48:20 +00:00
|
|
|
struct TextColor // Needed because of alignment
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2018-02-07 02:37:54 +00:00
|
|
|
u8 colors[3][4];
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2019-12-10 18:48:20 +00:00
|
|
|
static const struct TextColor sTextColorStruct =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2018-02-07 02:37:54 +00:00
|
|
|
{
|
2019-12-10 18:48:20 +00:00
|
|
|
{TEXT_DYNAMIC_COLOR_4, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY},
|
|
|
|
{TEXT_DYNAMIC_COLOR_5, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY},
|
|
|
|
{TEXT_DYNAMIC_COLOR_6, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY}
|
2018-02-07 02:37:54 +00:00
|
|
|
}
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2019-09-30 05:09:29 +01:00
|
|
|
static const u8 sFillValues[KBPAGE_COUNT] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
[KBPAGE_LETTERS_LOWER] = PIXEL_FILL(14),
|
|
|
|
[KBPAGE_LETTERS_UPPER] = PIXEL_FILL(13),
|
|
|
|
[KBPAGE_SYMBOLS] = PIXEL_FILL(15)
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2019-12-10 18:48:20 +00:00
|
|
|
static const u8 *const sKeyboardTextColors[KBPAGE_COUNT] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2019-12-10 18:48:20 +00:00
|
|
|
[KBPAGE_LETTERS_LOWER] = sTextColorStruct.colors[1],
|
|
|
|
[KBPAGE_LETTERS_UPPER] = sTextColorStruct.colors[0],
|
2020-08-07 07:00:41 +01:00
|
|
|
[KBPAGE_SYMBOLS] = sTextColorStruct.colors[2]
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void PrintKeyboardKeys(u8 window, u8 page)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
u8 i;
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2019-09-30 05:09:29 +01:00
|
|
|
FillWindowPixelBuffer(window, sFillValues[page]);
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2019-09-30 05:09:29 +01:00
|
|
|
for (i = 0; i < KBROW_COUNT; i++)
|
2019-12-10 18:48:20 +00:00
|
|
|
AddTextPrinterParameterized3(window, 1, 0, i * 16 + 1, sKeyboardTextColors[page], 0, sNamingScreenKeyboardText[page][i]);
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
PutWindowTilemap(window);
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const u8 *const sKeyboardPageTilemaps[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
[KBPAGE_LETTERS_LOWER] = gUnknown_08DD4620, // upper
|
|
|
|
[KBPAGE_LETTERS_UPPER] = gUnknown_08DD46E0, // lower
|
|
|
|
[KBPAGE_SYMBOLS] = gUnknown_08DD47A0 // symbols
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
// There are always 2 keyboard pages drawn, the current page and the one that will shown next if the player switches
|
|
|
|
// When the page switch is complete this function invisibly replaces the old page with the new next one
|
|
|
|
static void DrawKeyboardPageOnDeck(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
u8 bg;
|
|
|
|
u8 bg_;
|
|
|
|
u8 windowId;
|
2018-01-24 03:30:13 +00:00
|
|
|
u8 bg1Priority = GetGpuReg(REG_OFFSET_BG1CNT) & 3;
|
|
|
|
u8 bg2Priority = GetGpuReg(REG_OFFSET_BG2CNT) & 3;
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2018-01-24 03:30:13 +00:00
|
|
|
if (bg1Priority > bg2Priority)
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
bg = 1;
|
|
|
|
bg_ = 1;
|
|
|
|
windowId = sNamingScreen->windows[WIN_KB_PAGE_1];
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
bg = 2;
|
|
|
|
bg_ = 2;
|
|
|
|
windowId = sNamingScreen->windows[WIN_KB_PAGE_2];
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
DrawBgTilemap(bg, sKeyboardPageTilemaps[sNamingScreen->currentPage]);
|
|
|
|
PrintKeyboardKeys(windowId, sub_80E3254());
|
|
|
|
NamingScreen_Dummy(bg, sub_80E3254());
|
|
|
|
CopyBgTilemapBufferToVram(bg_);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void PrintControls(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2019-12-10 18:48:20 +00:00
|
|
|
const u8 color[3] = { TEXT_DYNAMIC_COLOR_6, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GREY };
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
FillWindowPixelBuffer(sNamingScreen->windows[WIN_BANNER], PIXEL_FILL(15));
|
|
|
|
AddTextPrinterParameterized3(sNamingScreen->windows[WIN_BANNER], 0, 2, 1, color, 0, gText_MoveOkBack);
|
|
|
|
PutWindowTilemap(sNamingScreen->windows[WIN_BANNER]);
|
|
|
|
CopyWindowToVram(sNamingScreen->windows[WIN_BANNER], 3);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void CB2_NamingScreen(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
RunTasks();
|
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
|
|
|
UpdatePaletteFade();
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void NamingScreen_ResetVHBlank(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
SetVBlankCallback(NULL);
|
|
|
|
SetHBlankCallback(NULL);
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void NamingScreen_SetVBlank(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
SetVBlankCallback(VBlankCB_NamingScreen);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void VBlankCB_NamingScreen(void)
|
|
|
|
{
|
|
|
|
LoadOam();
|
|
|
|
ProcessSpriteCopyRequests();
|
|
|
|
TransferPlttBuffer();
|
2020-08-07 07:00:41 +01:00
|
|
|
SetGpuReg(REG_OFFSET_BG1VOFS, sNamingScreen->bg1vOffset);
|
|
|
|
SetGpuReg(REG_OFFSET_BG2VOFS, sNamingScreen->bg2vOffset);
|
2018-01-24 03:30:13 +00:00
|
|
|
SetGpuReg(REG_OFFSET_BG1CNT, GetGpuReg(REG_OFFSET_BG1CNT) & 0xFFFC);
|
2020-08-07 07:00:41 +01:00
|
|
|
SetGpuRegBits(REG_OFFSET_BG1CNT, sNamingScreen->bg1Priority);
|
2018-01-24 03:30:13 +00:00
|
|
|
SetGpuReg(REG_OFFSET_BG2CNT, GetGpuReg(REG_OFFSET_BG2CNT) & 0xFFFC);
|
2020-08-07 07:00:41 +01:00
|
|
|
SetGpuRegBits(REG_OFFSET_BG2CNT, sNamingScreen->bg2Priority);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void NamingScreen_ShowBgs(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
ShowBg(0);
|
|
|
|
ShowBg(1);
|
|
|
|
ShowBg(2);
|
|
|
|
ShowBg(3);
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
// Always false (presumably for non-latin languages)
|
|
|
|
static bool8 IsWideLetter(u8 character)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
u8 i;
|
2018-04-13 13:21:49 +01:00
|
|
|
|
2019-12-10 18:48:20 +00:00
|
|
|
for (i = 0; sText_AlphabetUpperLower[i] != EOS; i++)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2019-12-10 18:48:20 +00:00
|
|
|
if (character == sText_AlphabetUpperLower[i])
|
2018-01-24 03:30:13 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
// Debug? Unused, and arguments aren't sensible for non-player screens.
|
|
|
|
static void Debug_NamingScreenPlayer(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
DoNamingScreen(NAMING_SCREEN_PLAYER, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, CB2_ReturnToFieldWithOpenMenu);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void Debug_NamingScreenBox(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
DoNamingScreen(NAMING_SCREEN_BOX, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, CB2_ReturnToFieldWithOpenMenu);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void Debug_NamingScreenCaughtMon(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
DoNamingScreen(NAMING_SCREEN_CAUGHT_MON, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, CB2_ReturnToFieldWithOpenMenu);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static void Debug_NamingScreenNickname(void)
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
DoNamingScreen(NAMING_SCREEN_NICKNAME, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, CB2_ReturnToFieldWithOpenMenu);
|
2018-01-24 03:30:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
// Forward-declared variables
|
|
|
|
//--------------------------------------------------
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct NamingScreenTemplate sPlayerNamingScreenTemplate =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
.copyExistingString = FALSE,
|
2018-01-24 03:30:13 +00:00
|
|
|
.maxChars = 7,
|
2018-01-24 05:14:22 +00:00
|
|
|
.iconFunction = 1,
|
2020-08-07 07:00:41 +01:00
|
|
|
.addGenderIcon = FALSE,
|
2019-09-30 05:09:29 +01:00
|
|
|
.initialPage = KBPAGE_LETTERS_UPPER,
|
2018-01-24 05:32:16 +00:00
|
|
|
.unused = 35,
|
2018-01-24 03:30:13 +00:00
|
|
|
.title = gText_YourName,
|
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct NamingScreenTemplate sPCBoxNamingTemplate =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
.copyExistingString = FALSE,
|
2018-01-24 03:30:13 +00:00
|
|
|
.maxChars = 8,
|
2018-01-24 05:14:22 +00:00
|
|
|
.iconFunction = 2,
|
2020-08-07 07:00:41 +01:00
|
|
|
.addGenderIcon = FALSE,
|
2019-09-30 05:09:29 +01:00
|
|
|
.initialPage = KBPAGE_LETTERS_UPPER,
|
2018-01-24 05:32:16 +00:00
|
|
|
.unused = 19,
|
2018-01-24 03:30:13 +00:00
|
|
|
.title = gText_BoxName,
|
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct NamingScreenTemplate sMonNamingScreenTemplate =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
.copyExistingString = FALSE,
|
2018-01-24 03:30:13 +00:00
|
|
|
.maxChars = 10,
|
2018-01-24 05:14:22 +00:00
|
|
|
.iconFunction = 3,
|
2020-08-07 07:00:41 +01:00
|
|
|
.addGenderIcon = TRUE,
|
2019-09-30 05:09:29 +01:00
|
|
|
.initialPage = KBPAGE_LETTERS_UPPER,
|
2018-01-24 05:32:16 +00:00
|
|
|
.unused = 35,
|
2018-01-24 03:30:13 +00:00
|
|
|
.title = gText_PkmnsNickname,
|
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct NamingScreenTemplate sWaldaWordsScreenTemplate =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
.copyExistingString = TRUE,
|
2018-01-24 03:30:13 +00:00
|
|
|
.maxChars = 15,
|
2018-01-24 05:14:22 +00:00
|
|
|
.iconFunction = 4,
|
2020-08-07 07:00:41 +01:00
|
|
|
.addGenderIcon = FALSE,
|
2019-09-30 05:09:29 +01:00
|
|
|
.initialPage = KBPAGE_LETTERS_UPPER,
|
2018-01-24 05:32:16 +00:00
|
|
|
.unused = 11,
|
2018-01-24 03:30:13 +00:00
|
|
|
.title = gText_TellHimTheWords,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct NamingScreenTemplate *const sNamingScreenTemplates[] =
|
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
[NAMING_SCREEN_PLAYER] = &sPlayerNamingScreenTemplate,
|
|
|
|
[NAMING_SCREEN_BOX] = &sPCBoxNamingTemplate,
|
|
|
|
[NAMING_SCREEN_CAUGHT_MON] = &sMonNamingScreenTemplate,
|
|
|
|
[NAMING_SCREEN_NICKNAME] = &sMonNamingScreenTemplate,
|
|
|
|
[NAMING_SCREEN_WALDA] = &sWaldaWordsScreenTemplate,
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct OamData sOam_8x8 =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-04-01 23:31:10 +01:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-03-11 07:12:15 +00:00
|
|
|
.shape = SPRITE_SHAPE(8x8),
|
2018-01-24 03:30:13 +00:00
|
|
|
.x = 0,
|
2019-03-11 07:12:15 +00:00
|
|
|
.size = SPRITE_SIZE(8x8),
|
2018-01-24 03:30:13 +00:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.paletteNum = 0,
|
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct OamData sOam_16x16 =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-04-01 23:31:10 +01:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-03-11 07:12:15 +00:00
|
|
|
.shape = SPRITE_SHAPE(16x16),
|
2018-01-24 03:30:13 +00:00
|
|
|
.x = 0,
|
2019-03-11 07:12:15 +00:00
|
|
|
.size = SPRITE_SIZE(16x16),
|
2018-01-24 03:30:13 +00:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.paletteNum = 0,
|
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct OamData sOam_32x16 =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
.y = 0,
|
2019-04-01 23:31:10 +01:00
|
|
|
.affineMode = ST_OAM_AFFINE_OFF,
|
|
|
|
.objMode = ST_OAM_OBJ_NORMAL,
|
|
|
|
.bpp = ST_OAM_4BPP,
|
2019-03-11 07:12:15 +00:00
|
|
|
.shape = SPRITE_SHAPE(32x16),
|
2018-01-24 03:30:13 +00:00
|
|
|
.x = 0,
|
2019-03-11 07:12:15 +00:00
|
|
|
.size = SPRITE_SIZE(32x16),
|
2018-01-24 03:30:13 +00:00
|
|
|
.tileNum = 0,
|
|
|
|
.priority = 0,
|
|
|
|
.paletteNum = 0,
|
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct Subsprite sSubsprites_PageSwitchBg[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2019-12-05 02:00:45 +00:00
|
|
|
{
|
|
|
|
.x = -20,
|
|
|
|
.y = -16,
|
|
|
|
.shape = SPRITE_SHAPE(32x8),
|
|
|
|
.size = SPRITE_SIZE(32x8),
|
|
|
|
.tileOffset = 0,
|
|
|
|
.priority = 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.x = 12,
|
|
|
|
.y = -16,
|
|
|
|
.shape = SPRITE_SHAPE(8x8),
|
|
|
|
.size = SPRITE_SIZE(8x8),
|
|
|
|
.tileOffset = 4,
|
|
|
|
.priority = 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.x = -20,
|
|
|
|
.y = -8,
|
|
|
|
.shape = SPRITE_SHAPE(32x8),
|
|
|
|
.size = SPRITE_SIZE(32x8),
|
|
|
|
.tileOffset = 5,
|
|
|
|
.priority = 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.x = 12,
|
|
|
|
.y = -8,
|
|
|
|
.shape = SPRITE_SHAPE(8x8),
|
|
|
|
.size = SPRITE_SIZE(8x8),
|
|
|
|
.tileOffset = 9,
|
|
|
|
.priority = 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.x = -20,
|
|
|
|
.y = 0,
|
|
|
|
.shape = SPRITE_SHAPE(32x8),
|
|
|
|
.size = SPRITE_SIZE(32x8),
|
|
|
|
.tileOffset = 10,
|
|
|
|
.priority = 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.x = 12,
|
|
|
|
.y = 0,
|
|
|
|
.shape = SPRITE_SHAPE(8x8),
|
|
|
|
.size = SPRITE_SIZE(8x8),
|
|
|
|
.tileOffset = 14,
|
|
|
|
.priority = 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.x = -20,
|
|
|
|
.y = 8,
|
|
|
|
.shape = SPRITE_SHAPE(32x8),
|
|
|
|
.size = SPRITE_SIZE(32x8),
|
|
|
|
.tileOffset = 15,
|
|
|
|
.priority = 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.x = 12,
|
|
|
|
.y = 8,
|
|
|
|
.shape = SPRITE_SHAPE(8x8),
|
|
|
|
.size = SPRITE_SIZE(8x8),
|
|
|
|
.tileOffset = 19,
|
|
|
|
.priority = 1
|
|
|
|
}
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct Subsprite sSubsprites_PageSwitchText[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2019-12-05 02:00:45 +00:00
|
|
|
{
|
|
|
|
.x = -12,
|
|
|
|
.y = -4,
|
|
|
|
.shape = SPRITE_SHAPE(16x8),
|
|
|
|
.size = SPRITE_SIZE(16x8),
|
|
|
|
.tileOffset = 0,
|
|
|
|
.priority = 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.x = 4,
|
|
|
|
.y = -4,
|
|
|
|
.shape = SPRITE_SHAPE(8x8),
|
|
|
|
.size = SPRITE_SIZE(8x8),
|
|
|
|
.tileOffset = 2,
|
|
|
|
.priority = 1
|
|
|
|
}
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct Subsprite sSubsprites_Button[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2019-12-05 02:00:45 +00:00
|
|
|
{
|
|
|
|
.x = -20,
|
|
|
|
.y = -12,
|
|
|
|
.shape = SPRITE_SHAPE(32x8),
|
|
|
|
.size = SPRITE_SIZE(32x8),
|
|
|
|
.tileOffset = 0,
|
|
|
|
.priority = 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.x = 12,
|
|
|
|
.y = -12,
|
|
|
|
.shape = SPRITE_SHAPE(8x8),
|
|
|
|
.size = SPRITE_SIZE(8x8),
|
|
|
|
.tileOffset = 4,
|
|
|
|
.priority = 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.x = -20,
|
|
|
|
.y = -4,
|
|
|
|
.shape = SPRITE_SHAPE(32x8),
|
|
|
|
.size = SPRITE_SIZE(32x8),
|
|
|
|
.tileOffset = 5,
|
|
|
|
.priority = 1
|
|
|
|
},
|
2019-12-06 03:38:01 +00:00
|
|
|
{
|
|
|
|
.x = 12,
|
2019-12-05 02:00:45 +00:00
|
|
|
.y = -4,
|
|
|
|
.shape = SPRITE_SHAPE(8x8),
|
|
|
|
.size = SPRITE_SIZE(8x8),
|
|
|
|
.tileOffset = 9,
|
|
|
|
.priority = 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.x = -20,
|
|
|
|
.y = 4,
|
|
|
|
.shape = SPRITE_SHAPE(32x8),
|
|
|
|
.size = SPRITE_SIZE(32x8),
|
|
|
|
.tileOffset = 10,
|
|
|
|
.priority = 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.x = 12,
|
|
|
|
.y = 4,
|
|
|
|
.shape = SPRITE_SHAPE(8x8),
|
|
|
|
.size = SPRITE_SIZE(8x8),
|
|
|
|
.tileOffset = 14,
|
|
|
|
.priority = 1
|
|
|
|
}
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct Subsprite sSubsprites_PCIcon[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2019-12-05 02:00:45 +00:00
|
|
|
{
|
|
|
|
.x = -8,
|
|
|
|
.y = -12,
|
|
|
|
.shape = SPRITE_SHAPE(16x8),
|
|
|
|
.size = SPRITE_SIZE(16x8),
|
|
|
|
.tileOffset = 0,
|
|
|
|
.priority = 3
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.x = -8,
|
|
|
|
.y = -4,
|
|
|
|
.shape = SPRITE_SHAPE(16x8),
|
|
|
|
.size = SPRITE_SIZE(16x8),
|
|
|
|
.tileOffset = 2,
|
|
|
|
.priority = 3
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.x = -8,
|
|
|
|
.y = 4,
|
|
|
|
.shape = SPRITE_SHAPE(16x8),
|
|
|
|
.size = SPRITE_SIZE(16x8),
|
|
|
|
.tileOffset = 4,
|
|
|
|
.priority = 3
|
|
|
|
}
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct SubspriteTable sSubspriteTable_PageSwitchBg[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
{ARRAY_COUNT(sSubsprites_PageSwitchBg), sSubsprites_PageSwitchBg}
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct SubspriteTable sSubspriteTable_PageSwitchText[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
{ARRAY_COUNT(sSubsprites_PageSwitchText), sSubsprites_PageSwitchText},
|
|
|
|
{ARRAY_COUNT(sSubsprites_PageSwitchText), sSubsprites_PageSwitchText},
|
|
|
|
{ARRAY_COUNT(sSubsprites_PageSwitchText), sSubsprites_PageSwitchText}
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct SubspriteTable sSubspriteTable_Button[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
{ARRAY_COUNT(sSubsprites_Button), sSubsprites_Button}
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct SubspriteTable sSubspriteTable_PCIcon[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
{ARRAY_COUNT(sSubsprites_PCIcon), sSubsprites_PCIcon}
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct SpriteFrameImage sImageTable_PCIcon[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
{sPCIconOn_Gfx, sizeof(sPCIconOn_Gfx)},
|
|
|
|
{sPCIconOff_Gfx, sizeof(sPCIconOff_Gfx)},
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2018-04-13 13:21:49 +01:00
|
|
|
static const union AnimCmd gSpriteAnim_858C090[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 1),
|
|
|
|
ANIMCMD_JUMP(0)
|
|
|
|
};
|
|
|
|
|
2018-04-13 13:21:49 +01:00
|
|
|
static const union AnimCmd gSpriteAnim_858C098[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(4, 8),
|
|
|
|
ANIMCMD_FRAME(8, 8),
|
|
|
|
ANIMCMD_END
|
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const union AnimCmd sAnim_PCIcon[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
|
|
|
ANIMCMD_FRAME(0, 2),
|
|
|
|
ANIMCMD_FRAME(1, 2),
|
|
|
|
ANIMCMD_JUMP(0)
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd *const gSpriteAnimTable_858C0B0[] =
|
|
|
|
{
|
|
|
|
gSpriteAnim_858C090
|
|
|
|
};
|
|
|
|
|
|
|
|
static const union AnimCmd *const gSpriteAnimTable_858C0B4[] =
|
|
|
|
{
|
|
|
|
gSpriteAnim_858C090,
|
|
|
|
gSpriteAnim_858C098
|
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const union AnimCmd *const sAnims_PCIcon[] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
sAnim_PCIcon
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_PageSwitchBg =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
.tileTag = GFXTAG_PAGE_SWITCH_BG,
|
|
|
|
.paletteTag = PALTAG_PAGE_SWITCH,
|
|
|
|
.oam = &sOam_8x8,
|
2018-01-24 03:30:13 +00:00
|
|
|
.anims = gSpriteAnimTable_858C0B0,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
2020-08-07 07:00:41 +01:00
|
|
|
.callback = SpriteCB_PageSwitch
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_PageSwitchButton =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
.tileTag = GFXTAG_PAGE_SWITCH_BUTTON,
|
|
|
|
.paletteTag = PALTAG_1,
|
|
|
|
.oam = &sOam_32x16,
|
2018-01-24 03:30:13 +00:00
|
|
|
.anims = gSpriteAnimTable_858C0B0,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_PageSwitchText =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
.tileTag = GFXTAG_PAGE_SWITCH_UPPER,
|
|
|
|
.paletteTag = PALTAG_PAGE_SWITCH,
|
|
|
|
.oam = &sOam_8x8,
|
2018-01-24 03:30:13 +00:00
|
|
|
.anims = gSpriteAnimTable_858C0B0,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_BackButton =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
.tileTag = GFXTAG_BACK_BUTTON,
|
|
|
|
.paletteTag = PALTAG_BACK_BUTTON,
|
|
|
|
.oam = &sOam_8x8,
|
2018-01-24 03:30:13 +00:00
|
|
|
.anims = gSpriteAnimTable_858C0B0,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_OkButton =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
.tileTag = GFXTAG_OK_BUTTON,
|
|
|
|
.paletteTag = PALTAG_OK_BUTTON,
|
|
|
|
.oam = &sOam_8x8,
|
2018-01-24 03:30:13 +00:00
|
|
|
.anims = gSpriteAnimTable_858C0B0,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_Cursor =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
.tileTag = GFXTAG_CURSOR,
|
|
|
|
.paletteTag = PALTAG_CURSOR,
|
|
|
|
.oam = &sOam_16x16,
|
2018-01-24 03:30:13 +00:00
|
|
|
.anims = gSpriteAnimTable_858C0B4,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
2020-08-07 07:00:41 +01:00
|
|
|
.callback = SpriteCB_Cursor
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2018-04-13 13:21:49 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_InputArrow =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
.tileTag = GFXTAG_INPUT_ARROW,
|
|
|
|
.paletteTag = PALTAG_3,
|
|
|
|
.oam = &sOam_8x8,
|
2018-01-24 03:30:13 +00:00
|
|
|
.anims = gSpriteAnimTable_858C0B0,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
2020-08-07 07:00:41 +01:00
|
|
|
.callback = SpriteCB_InputArrow
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2018-04-13 13:21:49 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_Underscore =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2020-08-07 07:00:41 +01:00
|
|
|
.tileTag = GFXTAG_UNDERSCORE,
|
|
|
|
.paletteTag = PALTAG_3,
|
|
|
|
.oam = &sOam_8x8,
|
2018-01-24 03:30:13 +00:00
|
|
|
.anims = gSpriteAnimTable_858C0B0,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
2020-08-07 07:00:41 +01:00
|
|
|
.callback = SpriteCB_Underscore
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct SpriteTemplate sSpriteTemplate_PCIcon =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2018-12-05 14:31:01 +00:00
|
|
|
.tileTag = 0xFFFF,
|
2020-08-07 07:00:41 +01:00
|
|
|
.paletteTag = PALTAG_PC_ICON,
|
|
|
|
.oam = &sOam_8x8,
|
|
|
|
.anims = sAnims_PCIcon,
|
|
|
|
.images = sImageTable_PCIcon,
|
2018-01-24 03:30:13 +00:00
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCallbackDummy
|
|
|
|
};
|
|
|
|
|
2019-09-30 05:09:29 +01:00
|
|
|
static const u8* const sNamingScreenKeyboardText[KBPAGE_COUNT][KBROW_COUNT] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2019-09-30 05:09:29 +01:00
|
|
|
[KBPAGE_LETTERS_LOWER] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2019-09-30 05:09:29 +01:00
|
|
|
gText_NamingScreenKeyboard_abcdef,
|
|
|
|
gText_NamingScreenKeyboard_ghijkl,
|
|
|
|
gText_NamingScreenKeyboard_mnopqrs,
|
|
|
|
gText_NamingScreenKeyboard_tuvwxyz
|
2018-01-24 03:30:13 +00:00
|
|
|
},
|
2019-09-30 05:09:29 +01:00
|
|
|
[KBPAGE_LETTERS_UPPER] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2019-09-30 05:09:29 +01:00
|
|
|
gText_NamingScreenKeyboard_ABCDEF,
|
|
|
|
gText_NamingScreenKeyboard_GHIJKL,
|
|
|
|
gText_NamingScreenKeyboard_MNOPQRS,
|
|
|
|
gText_NamingScreenKeyboard_TUVWXYZ
|
2018-01-24 03:30:13 +00:00
|
|
|
},
|
2019-09-30 05:09:29 +01:00
|
|
|
[KBPAGE_SYMBOLS] =
|
2018-01-24 03:30:13 +00:00
|
|
|
{
|
2019-09-30 05:09:29 +01:00
|
|
|
gText_NamingScreenKeyboard_01234,
|
|
|
|
gText_NamingScreenKeyboard_56789,
|
|
|
|
gText_NamingScreenKeyboard_Symbols1,
|
|
|
|
gText_NamingScreenKeyboard_Symbols2
|
2018-01-24 03:30:13 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-08-07 07:00:41 +01:00
|
|
|
static const struct SpriteSheet sSpriteSheets[] =
|
|
|
|
{
|
|
|
|
{gNamingScreenRWindow_Gfx + 0x280, 0x1E0, GFXTAG_BACK_BUTTON},
|
|
|
|
{gNamingScreenRWindow_Gfx + 0x460, 0x1E0, GFXTAG_OK_BUTTON},
|
|
|
|
{gNamingScreenRWindow_Gfx, 0x280, GFXTAG_PAGE_SWITCH_BG},
|
|
|
|
{gNamingScreenPageButton_Gfx + 0x20, 0x100, GFXTAG_PAGE_SWITCH_BUTTON},
|
|
|
|
{gNamingScreenROptions_Gfx, 0x060, GFXTAG_PAGE_SWITCH_UPPER},
|
|
|
|
{gNamingScreenROptions_Gfx + 0xA0, 0x060, GFXTAG_PAGE_SWITCH_LOWER},
|
|
|
|
{gNamingScreenROptions_Gfx + 0x140, 0x060, GFXTAG_PAGE_SWITCH_OTHERS},
|
|
|
|
{gNamingScreenCursor_Gfx, 0x080, GFXTAG_CURSOR},
|
|
|
|
{gNamingScreenCursor_Gfx + 0xA0, 0x080, GFXTAG_CURSOR_SQUISHED},
|
|
|
|
{gNamingScreenCursor_Gfx + 0x140, 0x080, GFXTAG_CURSOR_FILLED},
|
|
|
|
{gNamingScreenInputArrow_Gfx, 0x020, GFXTAG_INPUT_ARROW},
|
|
|
|
{gNamingScreenUnderscore_Gfx, 0x020, GFXTAG_UNDERSCORE},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct SpritePalette sSpritePalettes[] =
|
|
|
|
{
|
|
|
|
{gNamingScreenMenu_Pal, PALTAG_PC_ICON},
|
|
|
|
{gNamingScreenMenu_Pal + 0x10, PALTAG_1}, // upper switch button
|
|
|
|
{gNamingScreenMenu_Pal + 0x20, PALTAG_2}, // lower switch button
|
|
|
|
{gNamingScreenMenu_Pal + 0x30, PALTAG_3}, // symbols switch button
|
|
|
|
{gNamingScreenMenu_Pal + 0x40, PALTAG_PAGE_SWITCH},
|
|
|
|
{gNamingScreenMenu_Pal + 0x50, PALTAG_CURSOR},
|
|
|
|
{gNamingScreenMenu_Pal + 0x40, PALTAG_BACK_BUTTON},
|
|
|
|
{gNamingScreenMenu_Pal + 0x40, PALTAG_OK_BUTTON},
|
|
|
|
{}
|
2018-01-24 03:30:13 +00:00
|
|
|
};
|
2019-04-01 23:31:10 +01:00
|
|
|
|
|
|
|
|