2018-01-27 06:41:52 +01:00
|
|
|
#include "global.h"
|
2019-09-09 03:07:54 +02:00
|
|
|
#include "malloc.h"
|
2019-01-02 02:11:02 +01:00
|
|
|
#include "bg.h"
|
2019-08-03 20:10:28 +02:00
|
|
|
#include "blit.h"
|
2018-01-30 00:26:36 +01:00
|
|
|
#include "dma3.h"
|
2018-02-07 03:37:54 +01:00
|
|
|
#include "event_data.h"
|
2019-01-02 02:11:02 +01:00
|
|
|
#include "graphics.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "menu_helpers.h"
|
|
|
|
#include "palette.h"
|
2018-02-07 03:37:54 +01:00
|
|
|
#include "pokedex.h"
|
2019-01-02 02:11:02 +01:00
|
|
|
#include "pokemon_icon.h"
|
2018-02-07 03:37:54 +01:00
|
|
|
#include "region_map.h"
|
2019-01-02 02:11:02 +01:00
|
|
|
#include "sound.h"
|
|
|
|
#include "string_util.h"
|
2018-02-07 07:07:42 +01:00
|
|
|
#include "strings.h"
|
2019-01-02 02:11:02 +01:00
|
|
|
#include "task.h"
|
|
|
|
#include "text_window.h"
|
|
|
|
#include "window.h"
|
|
|
|
#include "constants/songs.h"
|
2018-01-27 06:41:52 +01:00
|
|
|
|
2018-02-07 07:07:42 +01:00
|
|
|
#define DLG_WINDOW_PALETTE_NUM 15
|
|
|
|
#define DLG_WINDOW_BASE_TILE_NUM 0x200
|
|
|
|
#define STD_WINDOW_PALETTE_NUM 14
|
|
|
|
#define STD_WINDOW_BASE_TILE_NUM 0x214
|
|
|
|
|
2020-10-29 21:34:33 +01:00
|
|
|
struct MenuInfoIcon
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2018-03-28 00:33:08 +02:00
|
|
|
u8 width;
|
|
|
|
u8 height;
|
|
|
|
u16 offset;
|
2018-01-27 06:41:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Menu
|
|
|
|
{
|
|
|
|
u8 left;
|
|
|
|
u8 top;
|
|
|
|
s8 cursorPos;
|
|
|
|
s8 minCursorPos;
|
|
|
|
s8 maxCursorPos;
|
|
|
|
u8 windowId;
|
|
|
|
u8 fontId;
|
2018-01-28 00:46:32 +01:00
|
|
|
u8 optionWidth;
|
|
|
|
u8 optionHeight;
|
2019-04-02 15:06:44 +02:00
|
|
|
u8 columns;
|
|
|
|
u8 rows;
|
2018-01-28 00:46:32 +01:00
|
|
|
bool8 APressMuted;
|
2018-01-27 06:41:52 +01:00
|
|
|
};
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
static u16 AddWindowParameterized(u8, u8, u8, u8, u8, u8, u16);
|
|
|
|
static void WindowFunc_DrawStandardFrame(u8, u8, u8, u8, u8, u8);
|
|
|
|
static void WindowFunc_DrawDialogueFrame(u8, u8, u8, u8, u8, u8);
|
|
|
|
static void WindowFunc_ClearStdWindowAndFrame(u8, u8, u8, u8, u8, u8);
|
|
|
|
static void WindowFunc_ClearDialogWindowAndFrame(u8, u8, u8, u8, u8, u8);
|
|
|
|
static void WindowFunc_DrawDialogFrameWithCustomTileAndPalette(u8, u8, u8, u8, u8, u8);
|
|
|
|
static void WindowFunc_ClearDialogWindowAndFrameNullPalette(u8, u8, u8, u8, u8, u8);
|
|
|
|
static void WindowFunc_DrawStdFrameWithCustomTileAndPalette(u8, u8, u8, u8, u8, u8);
|
|
|
|
static void WindowFunc_ClearStdWindowAndFrameToTransparent(u8, u8, u8, u8, u8, u8);
|
|
|
|
static void task_free_buf_after_copying_tile_data_to_vram(u8 taskId);
|
|
|
|
|
2018-12-27 23:30:47 +01:00
|
|
|
static EWRAM_DATA u8 sStartMenuWindowId = 0;
|
|
|
|
static EWRAM_DATA u8 sMapNamePopupWindowId = 0;
|
2019-01-02 02:11:02 +01:00
|
|
|
static EWRAM_DATA struct Menu sMenu = {0};
|
|
|
|
static EWRAM_DATA u16 sTileNum = 0;
|
|
|
|
static EWRAM_DATA u8 sPaletteNum = 0;
|
|
|
|
static EWRAM_DATA u8 sYesNoWindowId = 0;
|
2021-11-03 21:06:58 +01:00
|
|
|
static EWRAM_DATA u8 sHofPCTopBarWindowId = 0;
|
2018-02-07 07:07:42 +01:00
|
|
|
static EWRAM_DATA u16 sFiller = 0; // needed to align
|
2020-06-20 01:58:56 +02:00
|
|
|
static EWRAM_DATA bool8 sScheduledBgCopiesToVram[4] = {FALSE};
|
|
|
|
static EWRAM_DATA u16 sTempTileDataBufferIdx = 0;
|
|
|
|
static EWRAM_DATA void *sTempTileDataBuffer[0x20] = {NULL};
|
2018-02-07 07:07:42 +01:00
|
|
|
|
2021-11-04 04:20:59 +01:00
|
|
|
const u16 gStandardMenuPalette[] = INCBIN_U16("graphics/interface/std_menu.gbapal");
|
2019-11-25 01:11:36 +01:00
|
|
|
|
2021-08-25 00:59:32 +02:00
|
|
|
static const u8 sTextSpeedFrameDelays[] =
|
|
|
|
{
|
|
|
|
[OPTIONS_TEXT_SPEED_SLOW] = 8,
|
|
|
|
[OPTIONS_TEXT_SPEED_MID] = 4,
|
|
|
|
[OPTIONS_TEXT_SPEED_FAST] = 1
|
2019-11-25 01:11:36 +01:00
|
|
|
};
|
2018-02-07 07:07:42 +01:00
|
|
|
|
2018-12-27 23:30:47 +01:00
|
|
|
static const struct WindowTemplate sStandardTextBox_WindowTemplates[] =
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2018-09-02 18:53:52 +02:00
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 2,
|
|
|
|
.tilemapTop = 15,
|
|
|
|
.width = 27,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x194
|
|
|
|
},
|
2018-02-07 07:07:42 +01:00
|
|
|
DUMMY_WIN_TEMPLATE
|
|
|
|
};
|
|
|
|
|
2018-12-27 23:30:47 +01:00
|
|
|
static const struct WindowTemplate sYesNo_WindowTemplates =
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
.bg = 0,
|
2018-09-02 18:53:52 +02:00
|
|
|
.tilemapLeft = 21,
|
|
|
|
.tilemapTop = 9,
|
|
|
|
.width = 5,
|
|
|
|
.height = 4,
|
|
|
|
.paletteNum = 15,
|
|
|
|
.baseBlock = 0x125
|
2018-02-07 07:07:42 +01:00
|
|
|
};
|
2018-01-27 06:41:52 +01:00
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
static const u16 sHofPC_TopBar_Pal[] = INCBIN_U16("graphics/interface/hof_pc_topbar.gbapal");
|
|
|
|
static const u8 sTextColors[] = { TEXT_DYNAMIC_COLOR_6, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY };
|
2018-03-28 00:33:08 +02:00
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
// Table of move info icon offsets in graphics/interface/menu_info.png
|
2020-10-29 21:34:33 +01:00
|
|
|
static const struct MenuInfoIcon sMenuInfoIcons[] =
|
2018-03-28 00:33:08 +02:00
|
|
|
{ // { width, height, offset }
|
2020-10-29 21:34:33 +01:00
|
|
|
{ 12, 12, 0x00 }, // Unused
|
|
|
|
[TYPE_NORMAL + 1] = { 32, 12, 0x20 },
|
|
|
|
[TYPE_FIGHTING + 1] = { 32, 12, 0x64 },
|
|
|
|
[TYPE_FLYING + 1] = { 32, 12, 0x60 },
|
|
|
|
[TYPE_POISON + 1] = { 32, 12, 0x80 },
|
|
|
|
[TYPE_GROUND + 1] = { 32, 12, 0x48 },
|
|
|
|
[TYPE_ROCK + 1] = { 32, 12, 0x44 },
|
|
|
|
[TYPE_BUG + 1] = { 32, 12, 0x6C },
|
|
|
|
[TYPE_GHOST + 1] = { 32, 12, 0x68 },
|
|
|
|
[TYPE_STEEL + 1] = { 32, 12, 0x88 },
|
|
|
|
[TYPE_MYSTERY + 1] = { 32, 12, 0xA4 },
|
|
|
|
[TYPE_FIRE + 1] = { 32, 12, 0x24 },
|
|
|
|
[TYPE_WATER + 1] = { 32, 12, 0x28 },
|
|
|
|
[TYPE_GRASS + 1] = { 32, 12, 0x2C },
|
|
|
|
[TYPE_ELECTRIC + 1] = { 32, 12, 0x40 },
|
|
|
|
[TYPE_PSYCHIC + 1] = { 32, 12, 0x84 },
|
|
|
|
[TYPE_ICE + 1] = { 32, 12, 0x4C },
|
|
|
|
[TYPE_DRAGON + 1] = { 32, 12, 0xA0 },
|
|
|
|
[TYPE_DARK + 1] = { 32, 12, 0x8C },
|
2021-01-03 06:11:47 +01:00
|
|
|
[TYPE_FAIRY + 1] = { 32, 12, 0x4 },
|
2020-10-29 21:34:33 +01:00
|
|
|
[MENU_INFO_ICON_TYPE] = { 42, 12, 0xA8 },
|
|
|
|
[MENU_INFO_ICON_POWER] = { 42, 12, 0xC0 },
|
|
|
|
[MENU_INFO_ICON_ACCURACY] = { 42, 12, 0xC8 },
|
|
|
|
[MENU_INFO_ICON_PP] = { 42, 12, 0xE0 },
|
|
|
|
[MENU_INFO_ICON_EFFECT] = { 42, 12, 0xE8 }, // Unused
|
|
|
|
[MENU_INFO_ICON_BALL_RED] = { 8, 8, 0xAE }, // For placed decorations in Secret Base
|
|
|
|
[MENU_INFO_ICON_BALL_BLUE] = { 8, 8, 0xAF }, // For placed decorations in player's room
|
2018-01-27 06:41:52 +01:00
|
|
|
};
|
|
|
|
|
2018-12-27 23:30:47 +01:00
|
|
|
void InitStandardTextBoxWindows(void)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2018-12-27 23:30:47 +01:00
|
|
|
InitWindows(sStandardTextBox_WindowTemplates);
|
2021-02-20 00:36:48 +01:00
|
|
|
sStartMenuWindowId = WINDOW_NONE;
|
|
|
|
sMapNamePopupWindowId = WINDOW_NONE;
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2018-12-27 23:30:47 +01:00
|
|
|
void FreeAllOverworldWindowBuffers(void)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
|
|
|
FreeAllWindowBuffers();
|
|
|
|
}
|
|
|
|
|
2020-06-20 01:58:56 +02:00
|
|
|
void InitTextBoxGfxAndPrinters(void)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2021-11-04 04:02:06 +01:00
|
|
|
ChangeBgX(0, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(0, 0, BG_COORD_SET);
|
2018-02-07 07:07:42 +01:00
|
|
|
DeactivateAllTextPrinters();
|
2020-02-07 18:48:47 +01:00
|
|
|
LoadMessageBoxAndBorderGfx();
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2018-09-14 19:15:46 +02:00
|
|
|
u16 RunTextPrintersAndIsPrinter0Active(void)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
|
|
|
RunTextPrinters();
|
|
|
|
return IsTextPrinterActive(0);
|
|
|
|
}
|
|
|
|
|
2018-11-06 17:44:48 +01:00
|
|
|
u16 AddTextPrinterParameterized2(u8 windowId, u8 fontId, const u8 *str, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16), u8 fgColor, u8 bgColor, u8 shadowColor)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2018-11-06 17:44:48 +01:00
|
|
|
struct TextPrinterTemplate printer;
|
2018-02-12 11:45:51 +01:00
|
|
|
|
2018-11-06 17:44:48 +01:00
|
|
|
printer.currentChar = str;
|
2018-02-07 07:07:42 +01:00
|
|
|
printer.windowId = windowId;
|
|
|
|
printer.fontId = fontId;
|
|
|
|
printer.x = 0;
|
|
|
|
printer.y = 1;
|
|
|
|
printer.currentX = 0;
|
|
|
|
printer.currentY = 1;
|
|
|
|
printer.letterSpacing = 0;
|
|
|
|
printer.lineSpacing = 0;
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
printer.unk = 0;
|
2018-02-07 07:07:42 +01:00
|
|
|
printer.fgColor = fgColor;
|
|
|
|
printer.bgColor = bgColor;
|
|
|
|
printer.shadowColor = shadowColor;
|
2018-02-12 11:45:51 +01:00
|
|
|
|
2018-11-06 18:30:21 +01:00
|
|
|
gTextFlags.useAlternateDownArrow = 0;
|
2018-02-12 11:45:51 +01:00
|
|
|
return AddTextPrinter(&printer, speed, callback);
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress)
|
|
|
|
{
|
2018-11-06 17:44:48 +01:00
|
|
|
void (*callback)(struct TextPrinterTemplate *, u16) = NULL;
|
|
|
|
gTextFlags.canABSpeedUpPrint = allowSkippingDelayWithButtonPress;
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized2(0, FONT_NORMAL, gStringVar4, GetPlayerTextSpeedDelay(), callback, 2, 1, 3);
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void AddTextPrinterForMessage_2(bool8 allowSkippingDelayWithButtonPress)
|
|
|
|
{
|
2018-11-06 17:44:48 +01:00
|
|
|
gTextFlags.canABSpeedUpPrint = allowSkippingDelayWithButtonPress;
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized2(0, FONT_NORMAL, gStringVar4, GetPlayerTextSpeedDelay(), NULL, 2, 1, 3);
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void AddTextPrinterWithCustomSpeedForMessage(bool8 allowSkippingDelayWithButtonPress, u8 speed)
|
|
|
|
{
|
2018-11-06 17:44:48 +01:00
|
|
|
gTextFlags.canABSpeedUpPrint = allowSkippingDelayWithButtonPress;
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized2(0, FONT_NORMAL, gStringVar4, speed, NULL, 2, 1, 3);
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2020-02-07 18:48:47 +01:00
|
|
|
void LoadMessageBoxAndBorderGfx(void)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2018-06-17 16:48:58 +02:00
|
|
|
LoadMessageBoxGfx(0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM * 0x10);
|
2018-07-15 13:23:38 +02:00
|
|
|
LoadUserWindowBorderGfx(0, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM * 0x10);
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2019-02-22 07:40:11 +01:00
|
|
|
void DrawDialogueFrame(u8 windowId, bool8 copyToVram)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
CallWindowFunction(windowId, WindowFunc_DrawDialogueFrame);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
|
2018-02-07 07:07:42 +01:00
|
|
|
PutWindowTilemap(windowId);
|
|
|
|
if (copyToVram == TRUE)
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_FULL);
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2019-02-22 07:40:11 +01:00
|
|
|
void DrawStdWindowFrame(u8 windowId, bool8 copyToVram)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
CallWindowFunction(windowId, WindowFunc_DrawStandardFrame);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
|
2018-02-07 07:07:42 +01:00
|
|
|
PutWindowTilemap(windowId);
|
|
|
|
if (copyToVram == TRUE)
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_FULL);
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2019-02-22 07:40:11 +01:00
|
|
|
void ClearDialogWindowAndFrame(u8 windowId, bool8 copyToVram)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
CallWindowFunction(windowId, WindowFunc_ClearDialogWindowAndFrame);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
|
2018-02-07 07:07:42 +01:00
|
|
|
ClearWindowTilemap(windowId);
|
|
|
|
if (copyToVram == TRUE)
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_FULL);
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2019-02-22 07:40:11 +01:00
|
|
|
void ClearStdWindowAndFrame(u8 windowId, bool8 copyToVram)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
CallWindowFunction(windowId, WindowFunc_ClearStdWindowAndFrame);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
|
2018-02-07 07:07:42 +01:00
|
|
|
ClearWindowTilemap(windowId);
|
|
|
|
if (copyToVram == TRUE)
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_FULL);
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
static void WindowFunc_DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
|
|
|
int i;
|
2018-02-12 11:45:51 +01:00
|
|
|
|
2018-02-07 07:07:42 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
STD_WINDOW_BASE_TILE_NUM + 0,
|
|
|
|
tilemapLeft - 1,
|
|
|
|
tilemapTop - 1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
STD_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
STD_WINDOW_BASE_TILE_NUM + 1,
|
|
|
|
tilemapLeft,
|
|
|
|
tilemapTop - 1,
|
|
|
|
width,
|
|
|
|
1,
|
|
|
|
STD_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
STD_WINDOW_BASE_TILE_NUM + 2,
|
|
|
|
tilemapLeft + width,
|
|
|
|
tilemapTop - 1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
STD_WINDOW_PALETTE_NUM);
|
2018-02-12 11:45:51 +01:00
|
|
|
|
2018-02-07 07:07:42 +01:00
|
|
|
for (i = tilemapTop; i < tilemapTop + height; i++)
|
|
|
|
{
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
STD_WINDOW_BASE_TILE_NUM + 3,
|
|
|
|
tilemapLeft - 1,
|
|
|
|
i,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
STD_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
STD_WINDOW_BASE_TILE_NUM + 5,
|
|
|
|
tilemapLeft + width,
|
|
|
|
i,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
STD_WINDOW_PALETTE_NUM);
|
|
|
|
}
|
2018-02-12 11:45:51 +01:00
|
|
|
|
2018-02-07 07:07:42 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
STD_WINDOW_BASE_TILE_NUM + 6,
|
|
|
|
tilemapLeft - 1,
|
|
|
|
tilemapTop + height,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
STD_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
STD_WINDOW_BASE_TILE_NUM + 7,
|
|
|
|
tilemapLeft,
|
|
|
|
tilemapTop + height,
|
|
|
|
width,
|
|
|
|
1,
|
|
|
|
STD_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
STD_WINDOW_BASE_TILE_NUM + 8,
|
|
|
|
tilemapLeft + width,
|
|
|
|
tilemapTop + height,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
STD_WINDOW_PALETTE_NUM);
|
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
static void WindowFunc_DrawDialogueFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
DLG_WINDOW_BASE_TILE_NUM + 1,
|
|
|
|
tilemapLeft - 2,
|
|
|
|
tilemapTop - 1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
DLG_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
DLG_WINDOW_BASE_TILE_NUM + 3,
|
|
|
|
tilemapLeft - 1,
|
|
|
|
tilemapTop - 1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
DLG_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
DLG_WINDOW_BASE_TILE_NUM + 4,
|
|
|
|
tilemapLeft,
|
|
|
|
tilemapTop - 1,
|
|
|
|
width - 1,
|
|
|
|
1,
|
|
|
|
DLG_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
DLG_WINDOW_BASE_TILE_NUM + 5,
|
|
|
|
tilemapLeft + width - 1,
|
|
|
|
tilemapTop - 1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
DLG_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
DLG_WINDOW_BASE_TILE_NUM + 6,
|
|
|
|
tilemapLeft + width,
|
|
|
|
tilemapTop - 1,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
DLG_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
DLG_WINDOW_BASE_TILE_NUM + 7,
|
|
|
|
tilemapLeft - 2,
|
|
|
|
tilemapTop,
|
|
|
|
1,
|
|
|
|
5,
|
|
|
|
DLG_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
DLG_WINDOW_BASE_TILE_NUM + 9,
|
|
|
|
tilemapLeft - 1,
|
|
|
|
tilemapTop,
|
|
|
|
width + 1,
|
|
|
|
5,
|
|
|
|
DLG_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
DLG_WINDOW_BASE_TILE_NUM + 10,
|
|
|
|
tilemapLeft + width,
|
|
|
|
tilemapTop,
|
|
|
|
1,
|
|
|
|
5,
|
|
|
|
DLG_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 1),
|
|
|
|
tilemapLeft - 2,
|
|
|
|
tilemapTop + height,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
DLG_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 3),
|
|
|
|
tilemapLeft - 1,
|
|
|
|
tilemapTop + height,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
DLG_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 4),
|
|
|
|
tilemapLeft,
|
|
|
|
tilemapTop + height,
|
|
|
|
width - 1,
|
|
|
|
1,
|
|
|
|
DLG_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 5),
|
|
|
|
tilemapLeft + width - 1,
|
|
|
|
tilemapTop + height,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
DLG_WINDOW_PALETTE_NUM);
|
|
|
|
FillBgTilemapBufferRect(bg,
|
|
|
|
BG_TILE_V_FLIP(DLG_WINDOW_BASE_TILE_NUM + 6),
|
|
|
|
tilemapLeft + width,
|
|
|
|
tilemapTop + height,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
DLG_WINDOW_PALETTE_NUM);
|
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
static void WindowFunc_ClearStdWindowAndFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
|
|
|
FillBgTilemapBufferRect(bg, 0, tilemapLeft - 1, tilemapTop - 1, width + 2, height + 2, STD_WINDOW_PALETTE_NUM);
|
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
static void WindowFunc_ClearDialogWindowAndFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
|
|
|
FillBgTilemapBufferRect(bg, 0, tilemapLeft - 3, tilemapTop - 1, width + 6, height + 2, STD_WINDOW_PALETTE_NUM);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetStandardWindowBorderStyle(u8 windowId, bool8 copyToVram)
|
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
DrawStdFrameWithCustomTileAndPalette(windowId, copyToVram, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM);
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2021-11-04 04:20:59 +01:00
|
|
|
void LoadMessageBoxAndFrameGfx(u8 windowId, bool8 copyToVram)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2018-06-17 16:48:58 +02:00
|
|
|
LoadMessageBoxGfx(windowId, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM * 0x10);
|
2019-02-22 07:40:11 +01:00
|
|
|
DrawDialogFrameWithCustomTileAndPalette(windowId, copyToVram, DLG_WINDOW_BASE_TILE_NUM, 0xF);
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2021-10-26 22:52:23 +02:00
|
|
|
void Menu_LoadStdPal(void)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2021-10-26 22:52:23 +02:00
|
|
|
LoadPalette(gStandardMenuPalette, STD_WINDOW_PALETTE_NUM * 0x10, 0x14);
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2019-04-01 00:59:52 +02:00
|
|
|
void Menu_LoadStdPalAt(u16 offset)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2021-10-26 22:52:23 +02:00
|
|
|
LoadPalette(gStandardMenuPalette, offset, 0x14);
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2021-10-26 22:52:23 +02:00
|
|
|
// Unused
|
|
|
|
static const u16 *Menu_GetStdPal(void)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2021-10-26 22:52:23 +02:00
|
|
|
return gStandardMenuPalette;
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2021-10-26 22:52:23 +02:00
|
|
|
// Unused
|
|
|
|
static u16 Menu_GetStdPalColor(u8 colorNum)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
|
|
|
if (colorNum > 15)
|
|
|
|
colorNum = 0;
|
2021-10-26 22:52:23 +02:00
|
|
|
return gStandardMenuPalette[colorNum];
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayItemMessageOnField(u8 taskId, const u8 *string, TaskFunc callback)
|
|
|
|
{
|
2020-02-07 18:48:47 +01:00
|
|
|
LoadMessageBoxAndBorderGfx();
|
2021-10-30 22:47:37 +02:00
|
|
|
DisplayMessageAndContinueTask(taskId, 0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM, FONT_NORMAL, GetPlayerTextSpeedDelay(), string, callback);
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(0, COPYWIN_FULL);
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 04:30:40 +01:00
|
|
|
void DisplayYesNoMenuDefaultYes(void)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2018-12-27 23:30:47 +01:00
|
|
|
CreateYesNoMenu(&sYesNo_WindowTemplates, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, 0);
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2019-02-27 04:30:40 +01:00
|
|
|
void DisplayYesNoMenuWithDefault(u8 initialCursorPos)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2018-12-27 23:30:47 +01:00
|
|
|
CreateYesNoMenu(&sYesNo_WindowTemplates, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM, initialCursorPos);
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2018-11-06 18:30:21 +01:00
|
|
|
u32 GetPlayerTextSpeed(void)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2018-11-06 18:30:21 +01:00
|
|
|
if (gTextFlags.forceMidTextSpeed)
|
|
|
|
return OPTIONS_TEXT_SPEED_MID;
|
2018-02-07 07:07:42 +01:00
|
|
|
return gSaveBlock2Ptr->optionsTextSpeed;
|
|
|
|
}
|
|
|
|
|
2018-11-06 18:30:21 +01:00
|
|
|
u8 GetPlayerTextSpeedDelay(void)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
|
|
|
u32 speed;
|
2018-11-06 18:30:21 +01:00
|
|
|
if (gSaveBlock2Ptr->optionsTextSpeed > OPTIONS_TEXT_SPEED_FAST)
|
|
|
|
gSaveBlock2Ptr->optionsTextSpeed = OPTIONS_TEXT_SPEED_MID;
|
|
|
|
speed = GetPlayerTextSpeed();
|
2019-11-25 01:11:36 +01:00
|
|
|
return sTextSpeedFrameDelays[speed];
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
u8 AddStartMenuWindow(u8 numActions)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2021-02-20 00:36:48 +01:00
|
|
|
if (sStartMenuWindowId == WINDOW_NONE)
|
2021-11-03 21:06:58 +01:00
|
|
|
sStartMenuWindowId = AddWindowParameterized(0, 22, 1, 7, (numActions * 2) + 2, 15, 0x139);
|
2018-12-27 23:30:47 +01:00
|
|
|
return sStartMenuWindowId;
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetStartMenuWindowId(void)
|
|
|
|
{
|
2018-12-27 23:30:47 +01:00
|
|
|
return sStartMenuWindowId;
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
2018-03-29 02:16:02 +02:00
|
|
|
void RemoveStartMenuWindow(void)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2021-02-20 00:36:48 +01:00
|
|
|
if (sStartMenuWindowId != WINDOW_NONE)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2018-12-27 23:30:47 +01:00
|
|
|
RemoveWindow(sStartMenuWindowId);
|
2021-02-20 00:36:48 +01:00
|
|
|
sStartMenuWindowId = WINDOW_NONE;
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-25 23:22:45 +02:00
|
|
|
// Unused
|
|
|
|
static u16 GetDialogFrameBaseTileNum(void)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
|
|
|
return DLG_WINDOW_BASE_TILE_NUM;
|
|
|
|
}
|
|
|
|
|
2021-04-25 23:22:45 +02:00
|
|
|
// Unused
|
|
|
|
static u16 GetStandardFrameBaseTileNum(void)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
|
|
|
return STD_WINDOW_BASE_TILE_NUM;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 AddMapNamePopUpWindow(void)
|
|
|
|
{
|
2021-02-20 00:36:48 +01:00
|
|
|
if (sMapNamePopupWindowId == WINDOW_NONE)
|
2021-11-03 21:06:58 +01:00
|
|
|
sMapNamePopupWindowId = AddWindowParameterized(0, 1, 1, 10, 3, 14, 0x107);
|
2018-12-27 23:30:47 +01:00
|
|
|
return sMapNamePopupWindowId;
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetMapNamePopUpWindowId(void)
|
|
|
|
{
|
2018-12-27 23:30:47 +01:00
|
|
|
return sMapNamePopupWindowId;
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void RemoveMapNamePopUpWindow(void)
|
|
|
|
{
|
2021-02-20 00:36:48 +01:00
|
|
|
if (sMapNamePopupWindowId != WINDOW_NONE)
|
2018-02-07 07:07:42 +01:00
|
|
|
{
|
2018-12-27 23:30:47 +01:00
|
|
|
RemoveWindow(sMapNamePopupWindowId);
|
2021-02-20 00:36:48 +01:00
|
|
|
sMapNamePopupWindowId = WINDOW_NONE;
|
2018-02-07 07:07:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-06 17:44:48 +01:00
|
|
|
void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextPrinterTemplate *, u16))
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2018-11-06 17:44:48 +01:00
|
|
|
gTextFlags.canABSpeedUpPrint = a1;
|
2021-10-30 22:47:37 +02:00
|
|
|
AddTextPrinterParameterized2(0, FONT_NORMAL, gStringVar4, GetPlayerTextSpeedDelay(), callback, 2, 1, 3);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
void EraseFieldMessageBox(bool8 copyToVram)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
FillBgTilemapBufferRect(0, 0, 0, 0, 32, 32, 0x11);
|
|
|
|
if (copyToVram == TRUE)
|
|
|
|
CopyBgTilemapBufferToVram(0);
|
|
|
|
}
|
|
|
|
|
2019-02-22 07:40:11 +01:00
|
|
|
void DrawDialogFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 tileNum, u8 paletteNum)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum = tileNum;
|
|
|
|
sPaletteNum = paletteNum;
|
2019-02-22 07:40:11 +01:00
|
|
|
CallWindowFunction(windowId, WindowFunc_DrawDialogFrameWithCustomTileAndPalette);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
|
2018-01-27 06:41:52 +01:00
|
|
|
PutWindowTilemap(windowId);
|
|
|
|
if (copyToVram == TRUE)
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_FULL);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-22 07:40:11 +01:00
|
|
|
// Never used.
|
2021-11-03 21:06:58 +01:00
|
|
|
static void DrawDialogFrameWithCustomTile(u8 windowId, bool8 copyToVram, u16 tileNum)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum = tileNum;
|
|
|
|
sPaletteNum = GetWindowAttribute(windowId, WINDOW_PALETTE_NUM);
|
2019-02-22 07:40:11 +01:00
|
|
|
CallWindowFunction(windowId, WindowFunc_DrawDialogFrameWithCustomTileAndPalette);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
|
2018-01-27 06:41:52 +01:00
|
|
|
PutWindowTilemap(windowId);
|
|
|
|
if (copyToVram == TRUE)
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_FULL);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
static void WindowFunc_DrawDialogFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum + 1,
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft - 2,
|
|
|
|
tilemapTop - 1,
|
|
|
|
1,
|
|
|
|
1,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum + 3,
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft - 1,
|
|
|
|
tilemapTop - 1,
|
|
|
|
1,
|
|
|
|
1,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum + 4,
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft,
|
|
|
|
tilemapTop - 1,
|
|
|
|
width - 1,
|
|
|
|
1,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum + 5,
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft + width - 1,
|
|
|
|
tilemapTop - 1,
|
|
|
|
1,
|
|
|
|
1,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum + 6,
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft + width,
|
|
|
|
tilemapTop - 1,
|
|
|
|
1,
|
|
|
|
1,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum + 7,
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft - 2,
|
|
|
|
tilemapTop,
|
|
|
|
1,
|
|
|
|
5,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum + 9,
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft - 1,
|
|
|
|
tilemapTop,
|
|
|
|
width + 1,
|
|
|
|
5,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum + 10,
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft + width,
|
|
|
|
tilemapTop,
|
|
|
|
1,
|
|
|
|
5,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
BG_TILE_V_FLIP(sTileNum + 1),
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft - 2,
|
|
|
|
tilemapTop + height,
|
|
|
|
1,
|
|
|
|
1,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
BG_TILE_V_FLIP(sTileNum + 3),
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft - 1,
|
|
|
|
tilemapTop + height,
|
|
|
|
1,
|
|
|
|
1,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
BG_TILE_V_FLIP(sTileNum + 4),
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft,
|
|
|
|
tilemapTop + height,
|
|
|
|
width - 1,
|
|
|
|
1,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
BG_TILE_V_FLIP(sTileNum + 5),
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft + width - 1,
|
|
|
|
tilemapTop + height,
|
|
|
|
1,
|
|
|
|
1,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
BG_TILE_V_FLIP(sTileNum + 6),
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft + width,
|
|
|
|
tilemapTop + height,
|
|
|
|
1,
|
|
|
|
1,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-22 07:40:11 +01:00
|
|
|
void ClearDialogWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
// The palette slot doesn't matter, since the tiles are transparent.
|
|
|
|
CallWindowFunction(windowId, WindowFunc_ClearDialogWindowAndFrameNullPalette);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(0));
|
2018-01-27 06:41:52 +01:00
|
|
|
ClearWindowTilemap(windowId);
|
|
|
|
if (copyToVram == TRUE)
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_FULL);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
static void WindowFunc_ClearDialogWindowAndFrameNullPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
FillBgTilemapBufferRect(bg, 0, tilemapLeft - 3, tilemapTop - 1, width + 6, height + 2, 0);
|
|
|
|
}
|
|
|
|
|
2019-02-22 07:40:11 +01:00
|
|
|
void DrawStdFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 baseTileNum, u8 paletteNum)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum = baseTileNum;
|
|
|
|
sPaletteNum = paletteNum;
|
2019-02-22 07:40:11 +01:00
|
|
|
CallWindowFunction(windowId, WindowFunc_DrawStdFrameWithCustomTileAndPalette);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
|
2018-01-27 06:41:52 +01:00
|
|
|
PutWindowTilemap(windowId);
|
|
|
|
if (copyToVram == TRUE)
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_FULL);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-22 07:40:11 +01:00
|
|
|
// Never used.
|
|
|
|
void DrawStdFrameWithCustomTile(u8 windowId, bool8 copyToVram, u16 baseTileNum)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum = baseTileNum;
|
|
|
|
sPaletteNum = GetWindowAttribute(windowId, WINDOW_PALETTE_NUM);
|
2019-02-22 07:40:11 +01:00
|
|
|
CallWindowFunction(windowId, WindowFunc_DrawStdFrameWithCustomTileAndPalette);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(1));
|
2018-01-27 06:41:52 +01:00
|
|
|
PutWindowTilemap(windowId);
|
|
|
|
if (copyToVram == TRUE)
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_FULL);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
static void WindowFunc_DrawStdFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum + 0,
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft - 1,
|
|
|
|
tilemapTop - 1,
|
|
|
|
1,
|
|
|
|
1,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum + 1,
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft,
|
|
|
|
tilemapTop - 1,
|
|
|
|
width,
|
|
|
|
1,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum + 2,
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft + width,
|
|
|
|
tilemapTop - 1,
|
|
|
|
1,
|
|
|
|
1,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum + 3,
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft - 1,
|
|
|
|
tilemapTop,
|
|
|
|
1,
|
|
|
|
height,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum + 5,
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft + width,
|
|
|
|
tilemapTop,
|
|
|
|
1,
|
|
|
|
height,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum + 6,
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft - 1,
|
|
|
|
tilemapTop + height,
|
|
|
|
1,
|
|
|
|
1,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum + 7,
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft,
|
|
|
|
tilemapTop + height,
|
|
|
|
width,
|
|
|
|
1,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
FillBgTilemapBufferRect(bg,
|
2019-01-02 02:11:02 +01:00
|
|
|
sTileNum + 8,
|
2018-01-27 06:41:52 +01:00
|
|
|
tilemapLeft + width,
|
|
|
|
tilemapTop + height,
|
|
|
|
1,
|
|
|
|
1,
|
2019-01-02 02:11:02 +01:00
|
|
|
sPaletteNum);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2019-02-22 07:40:11 +01:00
|
|
|
void ClearStdWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
CallWindowFunction(windowId, WindowFunc_ClearStdWindowAndFrameToTransparent);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelBuffer(windowId, PIXEL_FILL(0));
|
2018-01-27 06:41:52 +01:00
|
|
|
ClearWindowTilemap(windowId);
|
|
|
|
if (copyToVram == TRUE)
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_FULL);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
static void WindowFunc_ClearStdWindowAndFrameToTransparent(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
FillBgTilemapBufferRect(bg, 0, tilemapLeft - 1, tilemapTop - 1, width + 2, height + 2, 0);
|
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
// Creates the window used to display the info bar at the top of the HOF PC that shows the controls and team number.
|
|
|
|
u8 HofPCTopBar_AddWindow(u8 bg, u8 xPos, u8 yPos, u8 palette, u16 baseTile)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
struct WindowTemplate window;
|
|
|
|
memset(&window, 0, sizeof(window));
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-27 06:41:52 +01:00
|
|
|
if (bg > 3)
|
2018-10-27 00:53:07 +02:00
|
|
|
window.bg = 0;
|
2018-01-27 06:41:52 +01:00
|
|
|
else
|
2018-10-27 00:53:07 +02:00
|
|
|
window.bg = bg;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-27 06:41:52 +01:00
|
|
|
window.tilemapTop = yPos;
|
|
|
|
window.height = 2;
|
2021-11-03 21:06:58 +01:00
|
|
|
window.tilemapLeft = 30 - xPos;
|
2018-01-27 06:41:52 +01:00
|
|
|
window.width = xPos;
|
|
|
|
window.paletteNum = palette;
|
|
|
|
window.baseBlock = baseTile;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
sHofPCTopBarWindowId = AddWindow(&window);
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-27 06:41:52 +01:00
|
|
|
if (palette > 15)
|
|
|
|
palette = 15 * 16;
|
|
|
|
else
|
|
|
|
palette *= 16;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
LoadPalette(sHofPC_TopBar_Pal, palette, sizeof(sHofPC_TopBar_Pal));
|
|
|
|
return sHofPCTopBarWindowId;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
// All the below functions checking WINDOW_NONE only handle failure of AddWindow in the above function.
|
|
|
|
// Because sHofPCTopBarWindowId is not initialized to WINDOW_NONE anywhere it does not handle
|
|
|
|
// the window not having been drawn yet.
|
|
|
|
void HofPCTopBar_Print(const u8 *string, u8 left, bool8 copyToVram)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
u16 width = 0;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
if (sHofPCTopBarWindowId != WINDOW_NONE)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2021-11-03 21:06:58 +01:00
|
|
|
PutWindowTilemap(sHofPCTopBarWindowId);
|
|
|
|
FillWindowPixelBuffer(sHofPCTopBarWindowId, PIXEL_FILL(15));
|
2021-10-30 22:47:37 +02:00
|
|
|
width = GetStringWidth(FONT_SMALL, string, 0);
|
2021-11-03 21:06:58 +01:00
|
|
|
AddTextPrinterParameterized3(sHofPCTopBarWindowId,
|
2021-10-30 22:47:37 +02:00
|
|
|
FONT_SMALL,
|
2021-11-03 21:06:58 +01:00
|
|
|
236 - (GetWindowAttribute(sHofPCTopBarWindowId, WINDOW_TILEMAP_LEFT) * 8) - left - width,
|
2018-01-27 06:41:52 +01:00
|
|
|
1,
|
2019-12-10 19:48:20 +01:00
|
|
|
sTextColors,
|
2018-01-27 06:41:52 +01:00
|
|
|
0,
|
|
|
|
string);
|
|
|
|
if (copyToVram)
|
2021-11-03 21:06:58 +01:00
|
|
|
CopyWindowToVram(sHofPCTopBarWindowId, COPYWIN_FULL);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
void HofPCTopBar_PrintPair(const u8 *string, const u8 *string2, bool8 noBg, u8 left, bool8 copyToVram)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2018-02-07 03:37:54 +01:00
|
|
|
u8 color[3];
|
2018-01-27 06:41:52 +01:00
|
|
|
u16 width = 0;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
if (sHofPCTopBarWindowId != WINDOW_NONE)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2021-11-03 21:06:58 +01:00
|
|
|
if (noBg)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-12-10 19:48:20 +01:00
|
|
|
color[0] = TEXT_COLOR_TRANSPARENT;
|
|
|
|
color[1] = TEXT_COLOR_WHITE;
|
2021-04-10 04:39:34 +02:00
|
|
|
color[2] = TEXT_COLOR_DARK_GRAY;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-10 19:48:20 +01:00
|
|
|
color[0] = TEXT_DYNAMIC_COLOR_6;
|
|
|
|
color[1] = TEXT_COLOR_WHITE;
|
2021-04-10 04:39:34 +02:00
|
|
|
color[2] = TEXT_COLOR_DARK_GRAY;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
2021-11-03 21:06:58 +01:00
|
|
|
PutWindowTilemap(sHofPCTopBarWindowId);
|
|
|
|
FillWindowPixelBuffer(sHofPCTopBarWindowId, PIXEL_FILL(15));
|
2018-01-27 06:41:52 +01:00
|
|
|
if (string2 != NULL)
|
|
|
|
{
|
2021-10-30 22:47:37 +02:00
|
|
|
width = GetStringWidth(FONT_SMALL, string2, 0);
|
2021-11-03 21:06:58 +01:00
|
|
|
AddTextPrinterParameterized3(sHofPCTopBarWindowId,
|
2021-10-30 22:47:37 +02:00
|
|
|
FONT_SMALL,
|
2021-11-03 21:06:58 +01:00
|
|
|
236 - (GetWindowAttribute(sHofPCTopBarWindowId, WINDOW_TILEMAP_LEFT) * 8) - left - width,
|
2018-01-27 06:41:52 +01:00
|
|
|
1,
|
2018-02-07 03:37:54 +01:00
|
|
|
color,
|
2018-01-27 06:41:52 +01:00
|
|
|
0,
|
|
|
|
string2);
|
|
|
|
}
|
2021-11-03 21:06:58 +01:00
|
|
|
AddTextPrinterParameterized4(sHofPCTopBarWindowId, FONT_NORMAL, 4, 1, 0, 0, color, 0, string);
|
2018-01-27 06:41:52 +01:00
|
|
|
if (copyToVram)
|
2021-11-03 21:06:58 +01:00
|
|
|
CopyWindowToVram(sHofPCTopBarWindowId, COPYWIN_FULL);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
// Unused
|
|
|
|
static void HofPCTopBar_CopyToVram(void)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2021-11-03 21:06:58 +01:00
|
|
|
if (sHofPCTopBarWindowId != WINDOW_NONE)
|
|
|
|
CopyWindowToVram(sHofPCTopBarWindowId, COPYWIN_FULL);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
// Unused
|
|
|
|
static void HofPCTopBar_Clear(void)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2021-11-03 21:06:58 +01:00
|
|
|
if (sHofPCTopBarWindowId != WINDOW_NONE)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2021-11-03 21:06:58 +01:00
|
|
|
FillWindowPixelBuffer(sHofPCTopBarWindowId, PIXEL_FILL(15));
|
|
|
|
CopyWindowToVram(sHofPCTopBarWindowId, COPYWIN_FULL);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
void HofPCTopBar_RemoveWindow(void)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2021-11-03 21:06:58 +01:00
|
|
|
if (sHofPCTopBarWindowId != WINDOW_NONE)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2021-11-03 21:06:58 +01:00
|
|
|
FillWindowPixelBuffer(sHofPCTopBarWindowId, PIXEL_FILL(0));
|
|
|
|
ClearWindowTilemap(sHofPCTopBarWindowId);
|
|
|
|
CopyWindowToVram(sHofPCTopBarWindowId, COPYWIN_FULL);
|
|
|
|
RemoveWindow(sHofPCTopBarWindowId);
|
|
|
|
sHofPCTopBarWindowId = WINDOW_NONE;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
static u8 InitMenu(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 initialCursorPos, bool8 muteAPress)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
s32 pos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.left = left;
|
|
|
|
sMenu.top = top;
|
|
|
|
sMenu.minCursorPos = 0;
|
|
|
|
sMenu.maxCursorPos = numChoices - 1;
|
|
|
|
sMenu.windowId = windowId;
|
|
|
|
sMenu.fontId = fontId;
|
|
|
|
sMenu.optionHeight = cursorHeight;
|
2021-11-03 21:06:58 +01:00
|
|
|
sMenu.APressMuted = muteAPress;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-28 00:46:32 +01:00
|
|
|
pos = initialCursorPos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
if (pos < 0 || pos > sMenu.maxCursorPos)
|
|
|
|
sMenu.cursorPos = 0;
|
2018-01-27 06:41:52 +01:00
|
|
|
else
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.cursorPos = pos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
Menu_MoveCursor(0);
|
2019-01-02 02:11:02 +01:00
|
|
|
return sMenu.cursorPos;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
// There is no muted version of this, so the version that plays sound when A is pressed is the "Normal" one.
|
|
|
|
u8 InitMenuNormal(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 initialCursorPos)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2021-11-03 21:06:58 +01:00
|
|
|
return InitMenu(windowId, fontId, left, top, cursorHeight, numChoices, initialCursorPos, FALSE);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
// Unused
|
|
|
|
static u8 InitMenuDefaultCursorHeight(u8 windowId, u8 fontId, u8 left, u8 top, u8 numChoices, u8 initialCursorPos)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2018-01-28 00:46:32 +01:00
|
|
|
u8 cursorHeight = GetMenuCursorDimensionByFont(fontId, 1);
|
2021-11-03 21:06:58 +01:00
|
|
|
return InitMenuNormal(windowId, fontId, left, top, cursorHeight, numChoices, initialCursorPos);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void RedrawMenuCursor(u8 oldPos, u8 newPos)
|
|
|
|
{
|
|
|
|
u8 width, height;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
width = GetMenuCursorDimensionByFont(sMenu.fontId, 0);
|
|
|
|
height = GetMenuCursorDimensionByFont(sMenu.fontId, 1);
|
2019-03-02 23:25:39 +01:00
|
|
|
FillWindowPixelRect(sMenu.windowId, PIXEL_FILL(1), sMenu.left, sMenu.optionHeight * oldPos + sMenu.top, width, height);
|
2019-01-02 02:11:02 +01:00
|
|
|
AddTextPrinterParameterized(sMenu.windowId, sMenu.fontId, gText_SelectorArrow3, sMenu.left, sMenu.optionHeight * newPos + sMenu.top, 0, 0);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
u8 Menu_MoveCursor(s8 cursorDelta)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
u8 oldPos = sMenu.cursorPos;
|
|
|
|
int newPos = sMenu.cursorPos + cursorDelta;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
if (newPos < sMenu.minCursorPos)
|
|
|
|
sMenu.cursorPos = sMenu.maxCursorPos;
|
|
|
|
else if (newPos > sMenu.maxCursorPos)
|
|
|
|
sMenu.cursorPos = sMenu.minCursorPos;
|
2018-01-27 06:41:52 +01:00
|
|
|
else
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.cursorPos += cursorDelta;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
RedrawMenuCursor(oldPos, sMenu.cursorPos);
|
|
|
|
return sMenu.cursorPos;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
u8 Menu_MoveCursorNoWrapAround(s8 cursorDelta)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
u8 oldPos = sMenu.cursorPos;
|
|
|
|
int newPos = sMenu.cursorPos + cursorDelta;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
if (newPos < sMenu.minCursorPos)
|
|
|
|
sMenu.cursorPos = sMenu.minCursorPos;
|
|
|
|
else if (newPos > sMenu.maxCursorPos)
|
|
|
|
sMenu.cursorPos = sMenu.maxCursorPos;
|
2018-01-27 06:41:52 +01:00
|
|
|
else
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.cursorPos += cursorDelta;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
RedrawMenuCursor(oldPos, sMenu.cursorPos);
|
|
|
|
return sMenu.cursorPos;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
u8 Menu_GetCursorPos(void)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
return sMenu.cursorPos;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2018-11-05 21:45:54 +01:00
|
|
|
s8 Menu_ProcessInput(void)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
if (!sMenu.APressMuted)
|
2018-01-27 06:41:52 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2019-01-02 02:11:02 +01:00
|
|
|
return sMenu.cursorPos;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(B_BUTTON))
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_B_PRESSED;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(DPAD_UP))
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2018-12-16 21:10:01 +01:00
|
|
|
Menu_MoveCursor(-1);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(DPAD_DOWN))
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2018-12-16 21:10:01 +01:00
|
|
|
Menu_MoveCursor(1);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2018-11-05 21:45:54 +01:00
|
|
|
s8 Menu_ProcessInputNoWrap(void)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
u8 oldPos = sMenu.cursorPos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
if (!sMenu.APressMuted)
|
2018-01-27 06:41:52 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2019-01-02 02:11:02 +01:00
|
|
|
return sMenu.cursorPos;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(B_BUTTON))
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_B_PRESSED;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(DPAD_UP))
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2018-12-16 21:10:01 +01:00
|
|
|
if (oldPos != Menu_MoveCursorNoWrapAround(-1))
|
2018-01-27 06:41:52 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(DPAD_DOWN))
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2018-12-16 21:10:01 +01:00
|
|
|
if (oldPos != Menu_MoveCursorNoWrapAround(1))
|
2018-01-27 06:41:52 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
s8 ProcessMenuInput_other(void)
|
|
|
|
{
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
if (!sMenu.APressMuted)
|
2018-01-27 06:41:52 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2019-01-02 02:11:02 +01:00
|
|
|
return sMenu.cursorPos;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(B_BUTTON))
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_B_PRESSED;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_UP)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2018-12-16 21:10:01 +01:00
|
|
|
Menu_MoveCursor(-1);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
2020-11-03 02:02:39 +01:00
|
|
|
else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_DOWN)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2018-12-16 21:10:01 +01:00
|
|
|
Menu_MoveCursor(1);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2018-08-12 21:54:07 +02:00
|
|
|
s8 Menu_ProcessInputNoWrapAround_other(void)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
u8 oldPos = sMenu.cursorPos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
if (!sMenu.APressMuted)
|
2018-01-27 06:41:52 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2019-01-02 02:11:02 +01:00
|
|
|
return sMenu.cursorPos;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
2020-11-03 02:18:26 +01:00
|
|
|
else if (JOY_NEW(B_BUTTON))
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_B_PRESSED;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
2020-11-03 02:18:26 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_ANY) == DPAD_UP)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2018-12-16 21:10:01 +01:00
|
|
|
if (oldPos != Menu_MoveCursorNoWrapAround(-1))
|
2018-01-27 06:41:52 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
2020-11-03 02:18:26 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_ANY) == DPAD_DOWN)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2018-12-16 21:10:01 +01:00
|
|
|
if (oldPos != Menu_MoveCursorNoWrapAround(1))
|
2018-01-27 06:41:52 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
void PrintMenuActionTextsAtPos(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
for (i = 0; i < itemCount; i++)
|
2021-11-03 23:29:18 +01:00
|
|
|
AddTextPrinterParameterized(windowId, fontId, menuActions[i].text, left, (lineHeight * i) + top, TEXT_SKIP_DRAW, NULL);
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_GFX);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
// Unused
|
|
|
|
static void PrintMenuActionTextsWithSpacing(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, u8 letterSpacing, u8 lineSpacing)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
for (i = 0; i < itemCount; i++)
|
2021-11-03 23:29:18 +01:00
|
|
|
AddTextPrinterParameterized5(windowId, fontId, menuActions[i].text, left, (lineHeight * i) + top, TEXT_SKIP_DRAW, NULL, letterSpacing, lineSpacing);
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_GFX);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
// Unused
|
|
|
|
static void PrintMenuActionTextsAtTop(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2021-11-03 21:06:58 +01:00
|
|
|
PrintMenuActionTextsAtPos(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 1, lineHeight, itemCount, menuActions);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-04 04:20:59 +01:00
|
|
|
void PrintMenuActionTexts(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, const u8 *actionIds)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
2018-11-06 17:44:48 +01:00
|
|
|
struct TextPrinterTemplate printer;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-27 06:41:52 +01:00
|
|
|
printer.windowId = windowId;
|
|
|
|
printer.fontId = fontId;
|
2018-07-15 13:23:38 +02:00
|
|
|
printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND);
|
|
|
|
printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND);
|
|
|
|
printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW);
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
printer.unk = GetFontAttribute(fontId, FONTATTR_UNKNOWN);
|
2018-01-27 06:41:52 +01:00
|
|
|
printer.letterSpacing = letterSpacing;
|
2018-07-15 13:23:38 +02:00
|
|
|
printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING);
|
2018-01-27 06:41:52 +01:00
|
|
|
printer.x = left;
|
|
|
|
printer.currentX = left;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-27 06:41:52 +01:00
|
|
|
for (i = 0; i < itemCount; i++)
|
|
|
|
{
|
2021-08-03 08:17:01 +02:00
|
|
|
printer.currentChar = menuActions[actionIds[i]].text;
|
2018-01-27 06:41:52 +01:00
|
|
|
printer.y = (lineHeight * i) + top;
|
|
|
|
printer.currentY = printer.y;
|
2021-11-03 23:29:18 +01:00
|
|
|
AddTextPrinter(&printer, TEXT_SKIP_DRAW, NULL);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_GFX);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
// Unused
|
2021-11-04 04:20:59 +01:00
|
|
|
static void PrintMenuActionTextsAtTopById(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, const u8 *actionIds)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2021-11-04 04:20:59 +01:00
|
|
|
PrintMenuActionTexts(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 1, GetFontAttribute(fontId, FONTATTR_LETTER_SPACING), lineHeight, itemCount, menuActions, actionIds);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetWindowTemplateFields(struct WindowTemplate *template, u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock)
|
|
|
|
{
|
2018-10-27 00:53:07 +02:00
|
|
|
template->bg = bg;
|
2018-01-27 06:41:52 +01:00
|
|
|
template->tilemapLeft = left;
|
|
|
|
template->tilemapTop = top;
|
|
|
|
template->width = width;
|
|
|
|
template->height = height;
|
|
|
|
template->paletteNum = paletteNum;
|
|
|
|
template->baseBlock = baseBlock;
|
|
|
|
}
|
|
|
|
|
2018-08-09 08:53:21 +02:00
|
|
|
struct WindowTemplate CreateWindowTemplate(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
struct WindowTemplate template;
|
|
|
|
SetWindowTemplateFields(&template, bg, left, top, width, height, paletteNum, baseBlock);
|
|
|
|
return template;
|
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
u16 AddWindowParameterized(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
struct WindowTemplate template;
|
|
|
|
SetWindowTemplateFields(&template, bg, left, top, width, height, paletteNum, baseBlock);
|
|
|
|
return AddWindow(&template);
|
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
// As opposed to CreateYesNoMenu, which has a hard-coded position.
|
|
|
|
static void CreateYesNoMenuAtPos(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2018-11-06 17:44:48 +01:00
|
|
|
struct TextPrinterTemplate printer;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
sYesNoWindowId = AddWindow(window);
|
2019-02-22 07:40:11 +01:00
|
|
|
DrawStdFrameWithCustomTileAndPalette(sYesNoWindowId, TRUE, baseTileNum, paletteNum);
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-11-06 17:44:48 +01:00
|
|
|
printer.currentChar = gText_YesNo;
|
2019-01-02 02:11:02 +01:00
|
|
|
printer.windowId = sYesNoWindowId;
|
2018-01-27 06:41:52 +01:00
|
|
|
printer.fontId = fontId;
|
2018-07-15 13:23:38 +02:00
|
|
|
printer.x = GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH) + left;
|
2018-01-27 06:41:52 +01:00
|
|
|
printer.y = top;
|
|
|
|
printer.currentX = printer.x;
|
|
|
|
printer.currentY = printer.y;
|
2018-07-15 13:23:38 +02:00
|
|
|
printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND);
|
|
|
|
printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND);
|
|
|
|
printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW);
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
printer.unk = GetFontAttribute(fontId, FONTATTR_UNKNOWN);
|
2018-07-15 13:23:38 +02:00
|
|
|
printer.letterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING);
|
|
|
|
printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING);
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-11-03 23:29:18 +01:00
|
|
|
AddTextPrinter(&printer, TEXT_SKIP_DRAW, NULL);
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
InitMenuNormal(sYesNoWindowId, fontId, left, top, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_HEIGHT), 2, initialCursorPos);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
static void CreateYesNoMenuInTopLeft(const struct WindowTemplate *window, u8 fontId, u16 baseTileNum, u8 paletteNum)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2021-11-03 21:06:58 +01:00
|
|
|
CreateYesNoMenuAtPos(window, fontId, 0, 1, baseTileNum, paletteNum, 0);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2018-11-05 21:45:54 +01:00
|
|
|
s8 Menu_ProcessInputNoWrapClearOnChoose(void)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2018-11-05 21:45:54 +01:00
|
|
|
s8 result = Menu_ProcessInputNoWrap();
|
2018-02-07 07:07:42 +01:00
|
|
|
if (result != MENU_NOTHING_CHOSEN)
|
2021-11-03 20:29:18 +01:00
|
|
|
EraseYesNoWindow();
|
2018-01-27 06:41:52 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-11-03 20:29:18 +01:00
|
|
|
void EraseYesNoWindow(void)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2019-02-22 07:40:11 +01:00
|
|
|
ClearStdWindowAndFrameToTransparent(sYesNoWindowId, TRUE);
|
2019-01-02 02:11:02 +01:00
|
|
|
RemoveWindow(sYesNoWindowId);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-04 04:20:59 +01:00
|
|
|
static void PrintMenuActionGridText(u8 windowId, u8 fontId, u8 left, u8 top, u8 width, u8 height, u8 columns, u8 rows, const struct MenuAction *menuActions)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 j;
|
2021-11-04 04:20:59 +01:00
|
|
|
for (i = 0; i < rows; i++)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2021-11-04 04:20:59 +01:00
|
|
|
for (j = 0; j < columns; j++)
|
|
|
|
AddTextPrinterParameterized(windowId, fontId, menuActions[(i * columns) + j].text, (width * j) + left, (height * i) + top, TEXT_SKIP_DRAW, NULL);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_GFX);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-04 01:28:43 +01:00
|
|
|
// Unused
|
2021-11-04 04:20:59 +01:00
|
|
|
static void PrintMenuActionGridTextAtTop(u8 windowId, u8 fontId, u8 a2, u8 a3, u8 a4, u8 a5, const struct MenuAction *menuActions)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2021-11-04 04:20:59 +01:00
|
|
|
PrintMenuActionGridText(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 0, a2, a3, a4, a5, menuActions);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-08-03 08:17:01 +02:00
|
|
|
void PrintMenuActionGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth, u8 horizontalCount, u8 verticalCount, const struct MenuAction *menuActions, const u8 *actionIds)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 j;
|
2018-11-06 17:44:48 +01:00
|
|
|
struct TextPrinterTemplate printer;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-27 06:41:52 +01:00
|
|
|
printer.windowId = windowId;
|
|
|
|
printer.fontId = fontId;
|
2018-11-06 18:30:21 +01:00
|
|
|
printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND);
|
|
|
|
printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND);
|
|
|
|
printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW);
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
printer.unk = GetFontAttribute(fontId, FONTATTR_UNKNOWN);
|
2018-11-06 18:30:21 +01:00
|
|
|
printer.letterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING);
|
|
|
|
printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING);
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-04-23 00:49:54 +02:00
|
|
|
for (i = 0; i < verticalCount; i++)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2021-04-23 00:49:54 +02:00
|
|
|
for (j = 0; j < horizontalCount; j++)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2021-08-03 08:17:01 +02:00
|
|
|
printer.currentChar = menuActions[actionIds[(horizontalCount * i) + j]].text;
|
2021-04-23 00:49:54 +02:00
|
|
|
printer.x = (optionWidth * j) + left;
|
|
|
|
printer.y = (GetFontAttribute(fontId, FONTATTR_MAX_LETTER_HEIGHT) * i) + top;
|
2018-01-27 06:41:52 +01:00
|
|
|
printer.currentX = printer.x;
|
|
|
|
printer.currentY = printer.y;
|
2021-11-03 23:29:18 +01:00
|
|
|
AddTextPrinter(&printer, TEXT_SKIP_DRAW, NULL);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_GFX);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-04-23 00:49:54 +02:00
|
|
|
// Unused
|
2021-08-03 08:17:01 +02:00
|
|
|
static void PrintMenuActionGrid_TopLeft(u8 windowId, u8 fontId, u8 optionWidth, u8 unused, u8 horizontalCount, u8 verticalCount, const struct MenuAction *menuActions, const u8 *actionIds)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
2021-08-03 08:17:01 +02:00
|
|
|
PrintMenuActionGrid(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 0, optionWidth, horizontalCount, verticalCount, menuActions, actionIds);
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
|
|
|
|
2021-11-04 04:20:59 +01:00
|
|
|
static u8 InitMenuGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth, u8 optionHeight, u8 columns, u8 rows, u8 numChoices, u8 cursorPos)
|
2018-01-27 06:41:52 +01:00
|
|
|
{
|
|
|
|
s32 pos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.left = left;
|
|
|
|
sMenu.top = top;
|
|
|
|
sMenu.minCursorPos = 0;
|
|
|
|
sMenu.maxCursorPos = numChoices - 1;
|
|
|
|
sMenu.windowId = windowId;
|
|
|
|
sMenu.fontId = fontId;
|
2021-11-04 01:28:43 +01:00
|
|
|
sMenu.optionWidth = optionWidth;
|
|
|
|
sMenu.optionHeight = optionHeight;
|
|
|
|
sMenu.columns = columns;
|
|
|
|
sMenu.rows = rows;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-11-04 01:28:43 +01:00
|
|
|
pos = cursorPos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
if (pos < 0 || pos > sMenu.maxCursorPos)
|
|
|
|
sMenu.cursorPos = 0;
|
2018-01-27 06:41:52 +01:00
|
|
|
else
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.cursorPos = pos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
// Why call this when it's not gonna move?
|
2021-11-04 04:20:59 +01:00
|
|
|
ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_NONE);
|
2019-01-02 02:11:02 +01:00
|
|
|
return sMenu.cursorPos;
|
2018-01-27 06:41:52 +01:00
|
|
|
}
|
2018-01-28 00:46:32 +01:00
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
// Unused
|
2021-11-04 04:20:59 +01:00
|
|
|
static u8 InitMenuGridDefaultCursorHeight(u8 windowId, u8 fontId, u8 left, u8 top, u8 width, u8 columns, u8 rows, u8 cursorPos)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
|
|
|
u8 cursorHeight = GetMenuCursorDimensionByFont(fontId, 1);
|
2021-11-04 01:28:43 +01:00
|
|
|
u8 numChoices = columns * rows;
|
2021-11-04 04:20:59 +01:00
|
|
|
return InitMenuGrid(windowId, fontId, left, top, width, cursorHeight, columns, rows, numChoices, cursorPos);
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
|
2021-11-04 04:20:59 +01:00
|
|
|
// Erase cursor at old position, draw cursor at new position.
|
|
|
|
static void MoveMenuGridCursor(u8 oldCursorPos, u8 newCursorPos)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
u8 cursorWidth = GetMenuCursorDimensionByFont(sMenu.fontId, 0);
|
|
|
|
u8 cursorHeight = GetMenuCursorDimensionByFont(sMenu.fontId, 1);
|
2021-11-04 04:20:59 +01:00
|
|
|
|
2019-04-02 15:06:44 +02:00
|
|
|
u8 xPos = (oldCursorPos % sMenu.columns) * sMenu.optionWidth + sMenu.left;
|
|
|
|
u8 yPos = (oldCursorPos / sMenu.columns) * sMenu.optionHeight + sMenu.top;
|
2021-11-04 04:20:59 +01:00
|
|
|
FillWindowPixelRect(sMenu.windowId, PIXEL_FILL(1), xPos, yPos, cursorWidth, cursorHeight);
|
|
|
|
|
2019-04-02 15:06:44 +02:00
|
|
|
xPos = (newCursorPos % sMenu.columns) * sMenu.optionWidth + sMenu.left;
|
|
|
|
yPos = (newCursorPos / sMenu.columns) * sMenu.optionHeight + sMenu.top;
|
2021-11-04 04:20:59 +01:00
|
|
|
AddTextPrinterParameterized(sMenu.windowId, sMenu.fontId, gText_SelectorArrow3, xPos, yPos, 0, 0);
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
|
2021-11-04 04:20:59 +01:00
|
|
|
u8 ChangeMenuGridCursorPosition(s8 deltaX, s8 deltaY)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
u8 oldPos = sMenu.cursorPos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-28 00:46:32 +01:00
|
|
|
if (deltaX != 0)
|
|
|
|
{
|
2019-04-02 15:06:44 +02:00
|
|
|
if ((sMenu.cursorPos % sMenu.columns) + deltaX < 0)
|
|
|
|
sMenu.cursorPos += sMenu.columns - 1;
|
|
|
|
else if ((sMenu.cursorPos % sMenu.columns) + deltaX >= sMenu.columns)
|
|
|
|
sMenu.cursorPos = (sMenu.cursorPos / sMenu.columns) * sMenu.columns;
|
2018-01-28 00:46:32 +01:00
|
|
|
else
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.cursorPos += deltaX;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-28 00:46:32 +01:00
|
|
|
if (deltaY != 0)
|
|
|
|
{
|
2019-04-02 15:06:44 +02:00
|
|
|
if ((sMenu.cursorPos / sMenu.columns) + deltaY < 0)
|
|
|
|
sMenu.cursorPos += sMenu.columns * (sMenu.rows - 1);
|
|
|
|
else if ((sMenu.cursorPos / sMenu.columns) + deltaY >= sMenu.rows)
|
|
|
|
sMenu.cursorPos -= sMenu.columns * (sMenu.rows - 1);
|
2018-01-28 00:46:32 +01:00
|
|
|
else
|
2019-04-02 15:06:44 +02:00
|
|
|
sMenu.cursorPos += (sMenu.columns * deltaY);
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
if (sMenu.cursorPos > sMenu.maxCursorPos)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.cursorPos = oldPos;
|
|
|
|
return sMenu.cursorPos;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-04 04:20:59 +01:00
|
|
|
MoveMenuGridCursor(oldPos, sMenu.cursorPos);
|
2019-01-02 02:11:02 +01:00
|
|
|
return sMenu.cursorPos;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
u8 ChangeGridMenuCursorPosition(s8 deltaX, s8 deltaY)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
u8 oldPos = sMenu.cursorPos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-28 00:46:32 +01:00
|
|
|
if (deltaX != 0)
|
|
|
|
{
|
2019-04-02 15:06:44 +02:00
|
|
|
if (((sMenu.cursorPos % sMenu.columns) + deltaX >= 0) &&
|
|
|
|
((sMenu.cursorPos % sMenu.columns) + deltaX < sMenu.columns))
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.cursorPos += deltaX;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-28 00:46:32 +01:00
|
|
|
if (deltaY != 0)
|
|
|
|
{
|
2019-04-02 15:06:44 +02:00
|
|
|
if (((sMenu.cursorPos / sMenu.columns) + deltaY >= 0) &&
|
|
|
|
((sMenu.cursorPos / sMenu.columns) + deltaY < sMenu.rows))
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2019-04-02 15:06:44 +02:00
|
|
|
sMenu.cursorPos += (sMenu.columns * deltaY);
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
if (sMenu.cursorPos > sMenu.maxCursorPos)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.cursorPos = oldPos;
|
|
|
|
return sMenu.cursorPos;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-04 04:20:59 +01:00
|
|
|
MoveMenuGridCursor(oldPos, sMenu.cursorPos);
|
2019-01-02 02:11:02 +01:00
|
|
|
return sMenu.cursorPos;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-04 01:28:43 +01:00
|
|
|
// Unused
|
2021-11-04 04:20:59 +01:00
|
|
|
static s8 Menu_ProcessGridInput_NoSoundLimit(void)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2019-01-02 02:11:02 +01:00
|
|
|
return sMenu.cursorPos;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(B_BUTTON))
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_B_PRESSED;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(DPAD_UP))
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-11-04 04:20:59 +01:00
|
|
|
ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(DPAD_DOWN))
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-11-04 04:20:59 +01:00
|
|
|
ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-11-04 04:20:59 +01:00
|
|
|
ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-11-04 04:20:59 +01:00
|
|
|
ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
|
2021-11-04 04:20:59 +01:00
|
|
|
s8 Menu_ProcessGridInput(void)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
u8 oldPos = sMenu.cursorPos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2019-01-02 02:11:02 +01:00
|
|
|
return sMenu.cursorPos;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(B_BUTTON))
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_B_PRESSED;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(DPAD_UP))
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2020-08-28 19:31:58 +02:00
|
|
|
if (oldPos != ChangeGridMenuCursorPosition(0, -1))
|
2018-01-28 00:46:32 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(DPAD_DOWN))
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2020-08-28 19:31:58 +02:00
|
|
|
if (oldPos != ChangeGridMenuCursorPosition(0, 1))
|
2018-01-28 00:46:32 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2020-08-28 19:31:58 +02:00
|
|
|
if (oldPos != ChangeGridMenuCursorPosition(-1, 0))
|
2018-01-28 00:46:32 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2020-08-28 19:31:58 +02:00
|
|
|
if (oldPos != ChangeGridMenuCursorPosition(1, 0))
|
2018-01-28 00:46:32 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
|
2021-11-04 01:28:43 +01:00
|
|
|
// Unused
|
2021-11-04 04:20:59 +01:00
|
|
|
static s8 Menu_ProcessGridInputRepeat_NoSoundLimit(void)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2019-01-02 02:11:02 +01:00
|
|
|
return sMenu.cursorPos;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(B_BUTTON))
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_B_PRESSED;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2021-11-04 01:28:43 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_ANY) == DPAD_UP)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-11-04 04:20:59 +01:00
|
|
|
ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2021-11-04 01:28:43 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_ANY) == DPAD_DOWN)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-11-04 04:20:59 +01:00
|
|
|
ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2021-11-04 01:28:43 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_ANY) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-11-04 04:20:59 +01:00
|
|
|
ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2021-11-04 01:28:43 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_ANY) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2021-11-04 04:20:59 +01:00
|
|
|
ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
|
2021-11-04 01:28:43 +01:00
|
|
|
// Unused
|
2021-11-04 04:20:59 +01:00
|
|
|
static s8 Menu_ProcessGridInputRepeat(void)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2019-01-02 02:11:02 +01:00
|
|
|
u8 oldPos = sMenu.cursorPos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2020-09-05 03:11:55 +02:00
|
|
|
if (JOY_NEW(A_BUTTON))
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
2019-01-02 02:11:02 +01:00
|
|
|
return sMenu.cursorPos;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2020-09-05 03:11:55 +02:00
|
|
|
else if (JOY_NEW(B_BUTTON))
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_B_PRESSED;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2022-02-27 19:47:50 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_ANY) == DPAD_UP)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2020-08-28 19:31:58 +02:00
|
|
|
if (oldPos != ChangeGridMenuCursorPosition(0, -1))
|
2018-01-28 00:46:32 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2022-02-27 19:47:50 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_ANY) == DPAD_DOWN)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2020-08-28 19:31:58 +02:00
|
|
|
if (oldPos != ChangeGridMenuCursorPosition(0, 1))
|
2018-01-28 00:46:32 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2022-02-27 19:47:50 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_ANY) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2020-08-28 19:31:58 +02:00
|
|
|
if (oldPos != ChangeGridMenuCursorPosition(-1, 0))
|
2018-01-28 00:46:32 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2022-02-27 19:47:50 +01:00
|
|
|
else if (JOY_REPEAT(DPAD_ANY) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
2020-08-28 19:31:58 +02:00
|
|
|
if (oldPos != ChangeGridMenuCursorPosition(1, 0))
|
2018-01-28 00:46:32 +01:00
|
|
|
PlaySE(SE_SELECT);
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
|
2018-02-07 07:07:42 +01:00
|
|
|
return MENU_NOTHING_CHOSEN;
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 InitMenuInUpperLeftCorner(u8 windowId, u8 itemCount, u8 initialCursorPos, bool8 APressMuted)
|
|
|
|
{
|
|
|
|
s32 pos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.left = 0;
|
|
|
|
sMenu.top = 1;
|
|
|
|
sMenu.minCursorPos = 0;
|
|
|
|
sMenu.maxCursorPos = itemCount - 1;
|
|
|
|
sMenu.windowId = windowId;
|
2021-10-30 22:47:37 +02:00
|
|
|
sMenu.fontId = FONT_NORMAL;
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.optionHeight = 16;
|
|
|
|
sMenu.APressMuted = APressMuted;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-28 00:46:32 +01:00
|
|
|
pos = initialCursorPos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
if (pos < 0 || pos > sMenu.maxCursorPos)
|
|
|
|
sMenu.cursorPos = 0;
|
2018-01-28 00:46:32 +01:00
|
|
|
else
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.cursorPos = pos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-12-16 21:10:01 +01:00
|
|
|
return Menu_MoveCursor(0);
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
|
2021-11-03 21:06:58 +01:00
|
|
|
// There is no muted version of this function, so the version that plays sound when A is pressed is the "Normal" one.
|
|
|
|
u8 InitMenuInUpperLeftCornerNormal(u8 windowId, u8 itemCount, u8 initialCursorPos)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
|
|
|
return InitMenuInUpperLeftCorner(windowId, itemCount, initialCursorPos, FALSE);
|
|
|
|
}
|
|
|
|
|
2021-08-03 08:17:01 +02:00
|
|
|
void PrintMenuTable(u8 windowId, u8 itemCount, const struct MenuAction *menuActions)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
|
|
|
u32 i;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-28 00:46:32 +01:00
|
|
|
for (i = 0; i < itemCount; i++)
|
2021-11-03 23:29:18 +01:00
|
|
|
AddTextPrinterParameterized(windowId, 1, menuActions[i].text, 8, (i * 16) + 1, TEXT_SKIP_DRAW, NULL);
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_GFX);
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
|
|
|
|
2021-11-04 04:20:59 +01:00
|
|
|
void PrintMenuActionTextsInUpperLeftCorner(u8 windowId, u8 itemCount, const struct MenuAction *menuActions, const u8 *actionIds)
|
2018-01-28 00:46:32 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
2018-11-06 17:44:48 +01:00
|
|
|
struct TextPrinterTemplate printer;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-28 00:46:32 +01:00
|
|
|
printer.windowId = windowId;
|
2021-10-30 22:47:37 +02:00
|
|
|
printer.fontId = FONT_NORMAL;
|
|
|
|
printer.fgColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_FOREGROUND);
|
|
|
|
printer.bgColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_BACKGROUND);
|
|
|
|
printer.shadowColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_SHADOW);
|
|
|
|
printer.unk = GetFontAttribute(FONT_NORMAL, FONTATTR_UNKNOWN);
|
2018-01-28 00:46:32 +01:00
|
|
|
printer.letterSpacing = 0;
|
|
|
|
printer.lineSpacing = 0;
|
|
|
|
printer.x = 8;
|
|
|
|
printer.currentX = 8;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-28 00:46:32 +01:00
|
|
|
for (i = 0; i < itemCount; i++)
|
|
|
|
{
|
2021-08-03 08:17:01 +02:00
|
|
|
printer.currentChar = menuActions[actionIds[i]].text;
|
2018-01-28 00:46:32 +01:00
|
|
|
printer.y = (i * 16) + 1;
|
|
|
|
printer.currentY = (i * 16) + 1;
|
2021-11-03 23:29:18 +01:00
|
|
|
AddTextPrinter(&printer, TEXT_SKIP_DRAW, NULL);
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_GFX);
|
2018-01-28 00:46:32 +01:00
|
|
|
}
|
2018-01-30 00:26:36 +01:00
|
|
|
|
|
|
|
void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos)
|
|
|
|
{
|
2018-11-06 17:44:48 +01:00
|
|
|
struct TextPrinterTemplate printer;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
sYesNoWindowId = AddWindow(window);
|
2019-02-22 07:40:11 +01:00
|
|
|
DrawStdFrameWithCustomTileAndPalette(sYesNoWindowId, TRUE, baseTileNum, paletteNum);
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-11-06 17:44:48 +01:00
|
|
|
printer.currentChar = gText_YesNo;
|
2019-01-02 02:11:02 +01:00
|
|
|
printer.windowId = sYesNoWindowId;
|
2021-10-30 22:47:37 +02:00
|
|
|
printer.fontId = FONT_NORMAL;
|
2018-01-30 00:26:36 +01:00
|
|
|
printer.x = 8;
|
|
|
|
printer.y = 1;
|
|
|
|
printer.currentX = printer.x;
|
|
|
|
printer.currentY = printer.y;
|
2021-10-30 22:47:37 +02:00
|
|
|
printer.fgColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_FOREGROUND);
|
|
|
|
printer.bgColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_BACKGROUND);
|
|
|
|
printer.shadowColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_SHADOW);
|
|
|
|
printer.unk = GetFontAttribute(FONT_NORMAL, FONTATTR_UNKNOWN);
|
2018-01-30 00:26:36 +01:00
|
|
|
printer.letterSpacing = 0;
|
|
|
|
printer.lineSpacing = 0;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-11-03 23:29:18 +01:00
|
|
|
AddTextPrinter(&printer, TEXT_SKIP_DRAW, NULL);
|
2021-11-03 21:06:58 +01:00
|
|
|
InitMenuInUpperLeftCornerNormal(sYesNoWindowId, 2, initialCursorPos);
|
2018-01-30 00:26:36 +01:00
|
|
|
}
|
|
|
|
|
2021-08-03 08:17:01 +02:00
|
|
|
void PrintMenuGridTable(u8 windowId, u8 optionWidth, u8 columns, u8 rows, const struct MenuAction *menuActions)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
2019-04-02 13:35:52 +02:00
|
|
|
u32 i, j;
|
|
|
|
|
2019-04-02 15:06:44 +02:00
|
|
|
for (i = 0; i < rows; i++)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
2019-04-02 15:06:44 +02:00
|
|
|
for (j = 0; j < columns; j++)
|
2021-11-03 23:29:18 +01:00
|
|
|
AddTextPrinterParameterized(windowId, 1, menuActions[(i * columns) + j].text, (optionWidth * j) + 8, (i * 16) + 1, TEXT_SKIP_DRAW, NULL);
|
2018-01-30 00:26:36 +01:00
|
|
|
}
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_GFX);
|
2018-01-30 00:26:36 +01:00
|
|
|
}
|
|
|
|
|
2021-11-04 01:28:43 +01:00
|
|
|
// Unused
|
2021-11-04 04:20:59 +01:00
|
|
|
static void PrintMenuActionGridTextNoSpacing(u8 windowId, u8 optionWidth, u8 columns, u8 rows, const struct MenuAction *menuActions, const u8 *actionIds)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 j;
|
2018-11-06 17:44:48 +01:00
|
|
|
struct TextPrinterTemplate printer;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-30 00:26:36 +01:00
|
|
|
printer.windowId = windowId;
|
2021-10-30 22:47:37 +02:00
|
|
|
printer.fontId = FONT_NORMAL;
|
|
|
|
printer.fgColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_FOREGROUND);
|
|
|
|
printer.bgColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_BACKGROUND);
|
|
|
|
printer.shadowColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_SHADOW);
|
|
|
|
printer.unk = GetFontAttribute(FONT_NORMAL, FONTATTR_UNKNOWN);
|
2018-01-30 00:26:36 +01:00
|
|
|
printer.letterSpacing = 0;
|
|
|
|
printer.lineSpacing = 0;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-11-04 04:20:59 +01:00
|
|
|
for (i = 0; i < rows; i++)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
2021-11-04 04:20:59 +01:00
|
|
|
for (j = 0; j < columns; j++)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
2021-11-04 04:20:59 +01:00
|
|
|
printer.currentChar = menuActions[actionIds[(columns * i) + j]].text;
|
|
|
|
printer.x = (optionWidth * j) + 8;
|
2018-01-30 00:26:36 +01:00
|
|
|
printer.y = (16 * i) + 1;
|
|
|
|
printer.currentX = printer.x;
|
|
|
|
printer.currentY = printer.y;
|
2021-11-03 23:29:18 +01:00
|
|
|
AddTextPrinter(&printer, TEXT_SKIP_DRAW, NULL);
|
2018-01-30 00:26:36 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-11-03 20:29:18 +01:00
|
|
|
CopyWindowToVram(windowId, COPYWIN_GFX);
|
2018-01-30 00:26:36 +01:00
|
|
|
}
|
|
|
|
|
2021-04-23 00:49:54 +02:00
|
|
|
u8 InitMenuActionGrid(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initialCursorPos)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
|
|
|
s32 pos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.left = 0;
|
|
|
|
sMenu.top = 1;
|
|
|
|
sMenu.minCursorPos = 0;
|
2019-04-02 15:06:44 +02:00
|
|
|
sMenu.maxCursorPos = (columns * rows) - 1;
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.windowId = windowId;
|
2021-10-30 22:47:37 +02:00
|
|
|
sMenu.fontId = FONT_NORMAL;
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.optionWidth = optionWidth;
|
|
|
|
sMenu.optionHeight = 16;
|
2019-04-02 15:06:44 +02:00
|
|
|
sMenu.columns = columns;
|
|
|
|
sMenu.rows = rows;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-30 00:26:36 +01:00
|
|
|
pos = initialCursorPos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2019-01-02 02:11:02 +01:00
|
|
|
if (pos < 0 || pos > sMenu.maxCursorPos)
|
|
|
|
sMenu.cursorPos = 0;
|
2018-01-30 00:26:36 +01:00
|
|
|
else
|
2019-01-02 02:11:02 +01:00
|
|
|
sMenu.cursorPos = pos;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2020-08-28 19:31:58 +02:00
|
|
|
// Why call this when it's not gonna move?
|
2021-11-04 04:20:59 +01:00
|
|
|
ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_NONE);
|
2019-01-02 02:11:02 +01:00
|
|
|
return sMenu.cursorPos;
|
2018-01-30 00:26:36 +01:00
|
|
|
}
|
|
|
|
|
2020-06-20 01:58:56 +02:00
|
|
|
void ClearScheduledBgCopiesToVram(void)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
2020-06-20 01:58:56 +02:00
|
|
|
memset(sScheduledBgCopiesToVram, 0, sizeof(sScheduledBgCopiesToVram));
|
2018-01-30 00:26:36 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void ScheduleBgCopyTilemapToVram(u8 bgId)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
2020-06-20 01:58:56 +02:00
|
|
|
sScheduledBgCopiesToVram[bgId] = TRUE;
|
2018-01-30 00:26:36 +01:00
|
|
|
}
|
|
|
|
|
2020-06-20 01:58:56 +02:00
|
|
|
void DoScheduledBgTilemapCopiesToVram(void)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
2020-06-20 01:58:56 +02:00
|
|
|
if (sScheduledBgCopiesToVram[0] == TRUE)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
|
|
|
CopyBgTilemapBufferToVram(0);
|
2020-06-20 01:58:56 +02:00
|
|
|
sScheduledBgCopiesToVram[0] = FALSE;
|
2018-01-30 00:26:36 +01:00
|
|
|
}
|
2020-06-20 01:58:56 +02:00
|
|
|
if (sScheduledBgCopiesToVram[1] == TRUE)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
|
|
|
CopyBgTilemapBufferToVram(1);
|
2020-06-20 01:58:56 +02:00
|
|
|
sScheduledBgCopiesToVram[1] = FALSE;
|
2018-01-30 00:26:36 +01:00
|
|
|
}
|
2020-06-20 01:58:56 +02:00
|
|
|
if (sScheduledBgCopiesToVram[2] == TRUE)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
|
|
|
CopyBgTilemapBufferToVram(2);
|
2020-06-20 01:58:56 +02:00
|
|
|
sScheduledBgCopiesToVram[2] = FALSE;
|
2018-01-30 00:26:36 +01:00
|
|
|
}
|
2020-06-20 01:58:56 +02:00
|
|
|
if (sScheduledBgCopiesToVram[3] == TRUE)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
|
|
|
CopyBgTilemapBufferToVram(3);
|
2020-06-20 01:58:56 +02:00
|
|
|
sScheduledBgCopiesToVram[3] = FALSE;
|
2018-01-30 00:26:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void ResetTempTileDataBuffers(void)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
|
|
|
int i;
|
2020-06-20 01:58:56 +02:00
|
|
|
for (i = 0; i < (int)ARRAY_COUNT(sTempTileDataBuffer); i++)
|
|
|
|
sTempTileDataBuffer[i] = NULL;
|
|
|
|
sTempTileDataBufferIdx = 0;
|
2018-01-30 00:26:36 +01:00
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
bool8 FreeTempTileDataBuffersIfPossible(void)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
|
|
|
int i;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-30 00:26:36 +01:00
|
|
|
if (!IsDma3ManagerBusyWithBgCopy())
|
|
|
|
{
|
2020-06-20 01:58:56 +02:00
|
|
|
if (sTempTileDataBufferIdx)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
2020-06-20 01:58:56 +02:00
|
|
|
for (i = 0; i < sTempTileDataBufferIdx; i++)
|
|
|
|
FREE_AND_SET_NULL(sTempTileDataBuffer[i]);
|
|
|
|
sTempTileDataBufferIdx = 0;
|
2018-01-30 00:26:36 +01:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-14 10:37:09 +02:00
|
|
|
void *DecompressAndCopyTileDataToVram(u8 bgId, const void *src, u32 size, u16 offset, u8 mode)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
2018-12-15 23:58:47 +01:00
|
|
|
u32 sizeOut;
|
2020-06-20 01:58:56 +02:00
|
|
|
if (sTempTileDataBufferIdx < ARRAY_COUNT(sTempTileDataBuffer))
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
|
|
|
void *ptr = malloc_and_decompress(src, &sizeOut);
|
|
|
|
if (!size)
|
|
|
|
size = sizeOut;
|
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
copy_decompressed_tile_data_to_vram(bgId, ptr, size, offset, mode);
|
2020-06-20 01:58:56 +02:00
|
|
|
sTempTileDataBuffer[sTempTileDataBufferIdx++] = ptr;
|
2018-01-30 00:26:36 +01:00
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-12-15 23:58:47 +01:00
|
|
|
void DecompressAndLoadBgGfxUsingHeap(u8 bgId, const void *src, u32 size, u16 offset, u8 mode)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
2018-12-15 23:58:47 +01:00
|
|
|
u32 sizeOut;
|
2018-01-30 00:26:36 +01:00
|
|
|
void *ptr = malloc_and_decompress(src, &sizeOut);
|
|
|
|
if (!size)
|
|
|
|
size = sizeOut;
|
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
u8 taskId = CreateTask(task_free_buf_after_copying_tile_data_to_vram, 0);
|
|
|
|
gTasks[taskId].data[0] = copy_decompressed_tile_data_to_vram(bgId, ptr, size, offset, mode);
|
|
|
|
SetWordTaskArg(taskId, 1, (u32)ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void task_free_buf_after_copying_tile_data_to_vram(u8 taskId)
|
|
|
|
{
|
|
|
|
if (!CheckForSpaceForDma3Request(gTasks[taskId].data[0]))
|
|
|
|
{
|
|
|
|
Free((void *)GetWordTaskArg(taskId, 1));
|
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-15 23:58:47 +01:00
|
|
|
void *malloc_and_decompress(const void *src, u32 *size)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
|
|
|
void *ptr;
|
|
|
|
u8 *sizeAsBytes = (u8 *)size;
|
|
|
|
u8 *srcAsBytes = (u8 *)src;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-30 00:26:36 +01:00
|
|
|
sizeAsBytes[0] = srcAsBytes[1];
|
|
|
|
sizeAsBytes[1] = srcAsBytes[2];
|
|
|
|
sizeAsBytes[2] = srcAsBytes[3];
|
|
|
|
sizeAsBytes[3] = 0;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-30 00:26:36 +01:00
|
|
|
ptr = Alloc(*size);
|
|
|
|
if (ptr)
|
|
|
|
LZ77UnCompWram(src, ptr);
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
u16 copy_decompressed_tile_data_to_vram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode)
|
|
|
|
{
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return LoadBgTiles(bgId, src, size, offset);
|
|
|
|
case 1:
|
|
|
|
return LoadBgTilemap(bgId, src, size, offset);
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-26 03:55:01 +02:00
|
|
|
void SetBgTilemapPalette(u8 bgId, u8 left, u8 top, u8 width, u8 height, u8 palette)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 j;
|
|
|
|
u16 *ptr = GetBgTilemapBuffer(bgId);
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-30 00:26:36 +01:00
|
|
|
for (i = top; i < top + height; i++)
|
|
|
|
{
|
|
|
|
for (j = left; j < left + width; j++)
|
|
|
|
{
|
|
|
|
ptr[(i * 32) + j] = (ptr[(i * 32) + j] & 0xFFF) | (palette << 12);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-18 01:22:03 +02:00
|
|
|
void CopyToBufferFromBgTilemap(u8 bgId, u16 *dest, u8 left, u8 top, u8 width, u8 height)
|
2018-01-30 00:26:36 +01:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 j;
|
2018-02-06 21:35:23 +01:00
|
|
|
const u16 *src = GetBgTilemapBuffer(bgId);
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-01-30 00:26:36 +01:00
|
|
|
for (i = 0; i < height; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < width; j++)
|
2018-02-06 21:35:23 +01:00
|
|
|
dest[(i * width) + j] = src[(i + top) * 32 + j + left];
|
2018-01-30 00:26:36 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-06 21:35:23 +01:00
|
|
|
|
2021-11-04 01:28:43 +01:00
|
|
|
void AddValToTilemapBuffer(void *ptr, int delta, int width, int height, bool32 isAffine)
|
2018-02-06 21:35:23 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int area = width * height;
|
2021-11-04 01:28:43 +01:00
|
|
|
if (isAffine == TRUE)
|
2018-02-06 21:35:23 +01:00
|
|
|
{
|
|
|
|
u8 *as8BPP = ptr;
|
|
|
|
for (i = 0; i < area; i++)
|
|
|
|
as8BPP[i] += delta;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-04 01:28:43 +01:00
|
|
|
// Limit add to first 10 bits
|
2018-02-06 21:35:23 +01:00
|
|
|
u16 *as4BPP = ptr;
|
|
|
|
for (i = 0; i < area; i++)
|
|
|
|
as4BPP[i] = (as4BPP[i] & 0xFC00) | ((as4BPP[i] + delta) & 0x3FF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-07 05:34:30 +02:00
|
|
|
void ResetBgPositions(void)
|
2018-02-06 21:35:23 +01:00
|
|
|
{
|
2021-11-04 04:02:06 +01:00
|
|
|
ChangeBgX(0, 0, BG_COORD_SET);
|
|
|
|
ChangeBgX(1, 0, BG_COORD_SET);
|
|
|
|
ChangeBgX(2, 0, BG_COORD_SET);
|
|
|
|
ChangeBgX(3, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(0, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(1, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(2, 0, BG_COORD_SET);
|
|
|
|
ChangeBgY(3, 0, BG_COORD_SET);
|
2018-02-06 21:35:23 +01:00
|
|
|
}
|
|
|
|
|
2021-11-04 04:20:59 +01:00
|
|
|
void BgDmaFill(u32 bg, u8 value, int offset, int size)
|
2018-02-06 21:35:23 +01:00
|
|
|
{
|
2021-11-04 04:20:59 +01:00
|
|
|
int temp = (!GetBgAttribute(bg, BG_ATTR_PALETTEMODE)) ? 32 : 64;
|
|
|
|
void *addr = (void *)((GetBgAttribute(bg, BG_ATTR_CHARBASEINDEX) * 0x4000) + (GetBgAttribute(bg, BG_ATTR_BASETILE) + offset) * temp);
|
|
|
|
RequestDma3Fill(value << 24 | value << 16 | value << 8 | value, VRAM + addr, size * temp, 1);
|
2018-02-06 21:35:23 +01:00
|
|
|
}
|
|
|
|
|
2018-09-03 22:55:55 +02:00
|
|
|
void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 left, u8 top, const u8 *color, s8 speed, const u8 *str)
|
2018-02-06 21:35:23 +01:00
|
|
|
{
|
2018-11-06 17:44:48 +01:00
|
|
|
struct TextPrinterTemplate printer;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-11-06 17:44:48 +01:00
|
|
|
printer.currentChar = str;
|
2018-02-06 21:35:23 +01:00
|
|
|
printer.windowId = windowId;
|
|
|
|
printer.fontId = fontId;
|
|
|
|
printer.x = left;
|
|
|
|
printer.y = top;
|
|
|
|
printer.currentX = printer.x;
|
|
|
|
printer.currentY = printer.y;
|
2021-10-30 22:47:37 +02:00
|
|
|
printer.letterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING);
|
|
|
|
printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING);
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
printer.unk = 0;
|
2018-02-07 03:37:54 +01:00
|
|
|
printer.fgColor = color[1];
|
|
|
|
printer.bgColor = color[0];
|
|
|
|
printer.shadowColor = color[2];
|
2018-02-12 11:45:51 +01:00
|
|
|
|
2018-02-06 21:35:23 +01:00
|
|
|
AddTextPrinter(&printer, speed, NULL);
|
|
|
|
}
|
|
|
|
|
2018-09-08 23:38:30 +02:00
|
|
|
void AddTextPrinterParameterized4(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineSpacing, const u8 *color, s8 speed, const u8 *str)
|
2018-02-06 21:35:23 +01:00
|
|
|
{
|
2018-11-06 17:44:48 +01:00
|
|
|
struct TextPrinterTemplate printer;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-11-06 17:44:48 +01:00
|
|
|
printer.currentChar = str;
|
2018-02-06 21:35:23 +01:00
|
|
|
printer.windowId = windowId;
|
|
|
|
printer.fontId = fontId;
|
|
|
|
printer.x = left;
|
|
|
|
printer.y = top;
|
|
|
|
printer.currentX = printer.x;
|
|
|
|
printer.currentY = printer.y;
|
|
|
|
printer.letterSpacing = letterSpacing;
|
|
|
|
printer.lineSpacing = lineSpacing;
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
printer.unk = 0;
|
2018-02-07 03:37:54 +01:00
|
|
|
printer.fgColor = color[1];
|
|
|
|
printer.bgColor = color[0];
|
|
|
|
printer.shadowColor = color[2];
|
2018-02-12 11:45:51 +01:00
|
|
|
|
2018-02-06 21:35:23 +01:00
|
|
|
AddTextPrinter(&printer, speed, NULL);
|
|
|
|
}
|
|
|
|
|
2018-11-06 17:44:48 +01:00
|
|
|
void AddTextPrinterParameterized5(u8 windowId, u8 fontId, const u8 *str, u8 left, u8 top, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16), u8 letterSpacing, u8 lineSpacing)
|
2018-02-06 21:35:23 +01:00
|
|
|
{
|
2018-11-06 17:44:48 +01:00
|
|
|
struct TextPrinterTemplate printer;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-11-06 17:44:48 +01:00
|
|
|
printer.currentChar = str;
|
2018-02-06 21:35:23 +01:00
|
|
|
printer.windowId = windowId;
|
|
|
|
printer.fontId = fontId;
|
|
|
|
printer.x = left;
|
|
|
|
printer.y = top;
|
|
|
|
printer.currentX = left;
|
|
|
|
printer.currentY = top;
|
|
|
|
printer.letterSpacing = letterSpacing;
|
|
|
|
printer.lineSpacing = lineSpacing;
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
printer.unk = 0;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-10-30 22:47:37 +02:00
|
|
|
printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND);
|
|
|
|
printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND);
|
|
|
|
printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW);
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-02-06 21:35:23 +01:00
|
|
|
AddTextPrinter(&printer, speed, callback);
|
|
|
|
}
|
|
|
|
|
2018-03-28 00:33:08 +02:00
|
|
|
void PrintPlayerNameOnWindow(u8 windowId, const u8 *src, u16 x, u16 y)
|
2018-02-06 21:35:23 +01:00
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
while (gSaveBlock2Ptr->playerName[count] != EOS)
|
|
|
|
count++;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-02-06 21:35:23 +01:00
|
|
|
StringExpandPlaceholders(gStringVar4, src);
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-11-03 23:29:18 +01:00
|
|
|
AddTextPrinterParameterized(windowId, 1, gStringVar4, x, y, TEXT_SKIP_DRAW, 0);
|
2018-02-06 21:35:23 +01:00
|
|
|
}
|
|
|
|
|
2021-11-04 04:20:59 +01:00
|
|
|
static void UnusedBlitBitmapRect(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height)
|
2019-08-03 20:10:28 +02:00
|
|
|
{
|
|
|
|
int loopSrcY, loopDstY, loopSrcX, loopDstX, xEnd, yEnd, multiplierSrcY, multiplierDstY;
|
|
|
|
const u8 *pixelsSrc;
|
2020-11-26 07:30:59 +01:00
|
|
|
u8 *pixelsDst;
|
2019-08-03 20:10:28 +02:00
|
|
|
u16 toOrr;
|
2018-02-06 21:35:23 +01:00
|
|
|
|
2019-08-03 20:10:28 +02:00
|
|
|
if (dst->width - dstX < width)
|
|
|
|
xEnd = dst->width - dstX + srcX;
|
|
|
|
else
|
|
|
|
xEnd = width + srcX;
|
|
|
|
|
|
|
|
if (dst->height - dstY < height)
|
|
|
|
yEnd = srcY + dst->height - dstY;
|
|
|
|
else
|
|
|
|
yEnd = srcY + height;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2021-11-04 04:20:59 +01:00
|
|
|
multiplierSrcY = (src->width + (src->width % 8)) >> 3;
|
|
|
|
multiplierDstY = (dst->width + (dst->width % 8)) >> 3;
|
2019-08-03 20:10:28 +02:00
|
|
|
|
|
|
|
for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
|
|
|
|
{
|
|
|
|
for (loopSrcX = srcX, loopDstX = dstX; loopSrcX < xEnd; loopSrcX++, loopDstX++)
|
2018-02-06 22:29:12 +01:00
|
|
|
{
|
2021-03-30 23:38:09 +02:00
|
|
|
pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 29) >> 27);
|
|
|
|
pixelsDst = (void*) dst->pixels + ((loopDstX >> 1) & 3) + ((loopDstX >> 3) << 5) + ((( loopDstY >> 3) * multiplierDstY) << 5) + ((u32)(loopDstY << 29) >> 27);
|
2019-08-03 20:10:28 +02:00
|
|
|
|
2021-11-04 04:20:59 +01:00
|
|
|
if ((uintptr_t)pixelsDst & 1)
|
2018-02-06 22:29:12 +01:00
|
|
|
{
|
2020-11-26 07:30:59 +01:00
|
|
|
pixelsDst--;
|
2021-11-04 04:20:59 +01:00
|
|
|
if (loopDstX & 1)
|
2018-02-06 22:29:12 +01:00
|
|
|
{
|
2020-11-26 07:30:59 +01:00
|
|
|
toOrr = *(vu16*)pixelsDst;
|
|
|
|
toOrr &= 0x0fff;
|
2021-11-04 04:20:59 +01:00
|
|
|
if (loopSrcX & 1)
|
2020-11-26 07:30:59 +01:00
|
|
|
toOrr |= ((*pixelsSrc & 0xf0) << 8);
|
2018-02-06 22:29:12 +01:00
|
|
|
else
|
2020-11-26 07:30:59 +01:00
|
|
|
toOrr |= ((*pixelsSrc & 0x0f) << 12);
|
2018-02-06 22:29:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-26 07:30:59 +01:00
|
|
|
toOrr = *(vu16*)pixelsDst;
|
|
|
|
toOrr &= 0xf0ff;
|
2021-11-04 04:20:59 +01:00
|
|
|
if (loopSrcX & 1)
|
2020-11-26 07:30:59 +01:00
|
|
|
toOrr |= ((*pixelsSrc & 0xf0) << 4);
|
2018-02-06 22:29:12 +01:00
|
|
|
else
|
2020-11-26 07:30:59 +01:00
|
|
|
toOrr |= ((*pixelsSrc & 0x0f) << 8);
|
2018-02-06 22:29:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-03 20:10:28 +02:00
|
|
|
if (loopDstX & 1)
|
2018-02-06 22:29:12 +01:00
|
|
|
{
|
2020-11-26 07:30:59 +01:00
|
|
|
toOrr = *(vu16*)pixelsDst;
|
|
|
|
toOrr &= 0xff0f;
|
2019-08-03 20:10:28 +02:00
|
|
|
if (loopSrcX & 1)
|
2020-11-26 07:30:59 +01:00
|
|
|
toOrr |= ((*pixelsSrc & 0xf0) << 0);
|
2018-02-06 22:29:12 +01:00
|
|
|
else
|
2020-11-26 07:30:59 +01:00
|
|
|
toOrr |= ((*pixelsSrc & 0x0f) << 4);
|
2018-02-06 22:29:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-26 07:30:59 +01:00
|
|
|
toOrr = *(vu16*)pixelsDst;
|
|
|
|
toOrr &= 0xfff0;
|
2019-08-03 20:10:28 +02:00
|
|
|
if (loopSrcX & 1)
|
2020-11-26 07:30:59 +01:00
|
|
|
toOrr |= ((*pixelsSrc & 0xf0) >> 4);
|
2018-02-06 22:29:12 +01:00
|
|
|
else
|
2020-11-26 07:30:59 +01:00
|
|
|
toOrr |= ((*pixelsSrc & 0x0f) >> 0);
|
2018-02-06 22:29:12 +01:00
|
|
|
}
|
|
|
|
}
|
2020-11-26 07:30:59 +01:00
|
|
|
*(vu16*)pixelsDst = toOrr;
|
2018-02-06 22:29:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-06 21:35:23 +01:00
|
|
|
|
2021-11-04 01:28:43 +01:00
|
|
|
// Unused
|
2021-11-04 04:20:59 +01:00
|
|
|
static void LoadMonIconPalAtOffset(u8 palOffset, u16 speciesId)
|
2018-02-06 21:35:23 +01:00
|
|
|
{
|
|
|
|
LoadPalette(GetValidMonIconPalettePtr(speciesId), palOffset, 0x20);
|
|
|
|
}
|
|
|
|
|
2021-11-04 01:28:43 +01:00
|
|
|
// Unused
|
2021-11-04 04:20:59 +01:00
|
|
|
static void DrawMonIconAtPos(u8 windowId, u16 speciesId, u32 personality, u16 x, u16 y)
|
2018-02-06 21:35:23 +01:00
|
|
|
{
|
|
|
|
BlitBitmapToWindow(windowId, GetMonIconPtr(speciesId, personality, 1), x, y, 32, 32);
|
|
|
|
}
|
|
|
|
|
2020-05-30 10:09:21 +02:00
|
|
|
void ListMenuLoadStdPalAt(u8 palOffset, u8 palId)
|
2018-02-06 21:35:23 +01:00
|
|
|
{
|
|
|
|
const u16 *palette;
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-02-06 21:35:23 +01:00
|
|
|
switch (palId)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
default:
|
2021-11-03 21:06:58 +01:00
|
|
|
palette = gMenuInfoElements1_Pal;
|
2018-02-06 21:35:23 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-11-03 21:06:58 +01:00
|
|
|
palette = gMenuInfoElements2_Pal;
|
2018-02-06 21:35:23 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-11-03 21:06:58 +01:00
|
|
|
palette = gMenuInfoElements3_Pal;
|
2018-02-06 21:35:23 +01:00
|
|
|
break;
|
|
|
|
}
|
2018-02-06 22:29:12 +01:00
|
|
|
|
2018-02-06 21:35:23 +01:00
|
|
|
LoadPalette(palette, palOffset, 0x20);
|
|
|
|
}
|
|
|
|
|
2020-10-29 21:34:33 +01:00
|
|
|
void BlitMenuInfoIcon(u8 windowId, u8 iconId, u16 x, u16 y)
|
2018-02-06 21:35:23 +01:00
|
|
|
{
|
2021-11-03 21:06:58 +01:00
|
|
|
BlitBitmapRectToWindow(windowId, &gMenuInfoElements_Gfx[sMenuInfoIcons[iconId].offset * 32], 0, 0, 128, 128, x, y, sMenuInfoIcons[iconId].width, sMenuInfoIcons[iconId].height);
|
2018-02-06 21:35:23 +01:00
|
|
|
}
|
2018-02-07 03:37:54 +01:00
|
|
|
|
2020-02-07 18:48:47 +01:00
|
|
|
void BufferSaveMenuText(u8 textId, u8 *dest, u8 color)
|
2018-02-07 03:37:54 +01:00
|
|
|
{
|
|
|
|
s32 curFlag;
|
|
|
|
s32 flagCount;
|
|
|
|
u8 *endOfString;
|
2018-03-28 00:33:08 +02:00
|
|
|
u8 *string = dest;
|
2018-02-12 11:45:51 +01:00
|
|
|
|
2018-02-07 03:37:54 +01:00
|
|
|
*(string++) = EXT_CTRL_CODE_BEGIN;
|
|
|
|
*(string++) = EXT_CTRL_CODE_COLOR;
|
2018-03-28 00:33:08 +02:00
|
|
|
*(string++) = color;
|
2018-02-07 03:37:54 +01:00
|
|
|
*(string++) = EXT_CTRL_CODE_BEGIN;
|
|
|
|
*(string++) = EXT_CTRL_CODE_SHADOW;
|
2018-03-28 00:33:08 +02:00
|
|
|
*(string++) = color + 1;
|
2018-02-12 11:45:51 +01:00
|
|
|
|
2020-02-07 18:48:47 +01:00
|
|
|
switch (textId)
|
2018-02-07 03:37:54 +01:00
|
|
|
{
|
2020-02-07 18:48:47 +01:00
|
|
|
case SAVE_MENU_NAME:
|
2018-02-07 03:37:54 +01:00
|
|
|
StringCopy(string, gSaveBlock2Ptr->playerName);
|
|
|
|
break;
|
2020-02-07 18:48:47 +01:00
|
|
|
case SAVE_MENU_CAUGHT:
|
2018-02-07 03:37:54 +01:00
|
|
|
if (IsNationalPokedexEnabled())
|
2019-10-07 07:13:34 +02:00
|
|
|
string = ConvertIntToDecimalStringN(string, GetNationalPokedexCount(FLAG_GET_CAUGHT), STR_CONV_MODE_LEFT_ALIGN, 3);
|
2018-02-07 03:37:54 +01:00
|
|
|
else
|
2019-10-07 07:13:34 +02:00
|
|
|
string = ConvertIntToDecimalStringN(string, GetHoennPokedexCount(FLAG_GET_CAUGHT), STR_CONV_MODE_LEFT_ALIGN, 3);
|
2018-02-07 03:37:54 +01:00
|
|
|
*string = EOS;
|
|
|
|
break;
|
2020-02-07 18:48:47 +01:00
|
|
|
case SAVE_MENU_PLAY_TIME:
|
2019-09-30 21:43:44 +02:00
|
|
|
string = ConvertIntToDecimalStringN(string, gSaveBlock2Ptr->playTimeHours, STR_CONV_MODE_LEFT_ALIGN, 3);
|
2018-02-07 03:37:54 +01:00
|
|
|
*(string++) = CHAR_COLON;
|
2019-09-30 21:43:44 +02:00
|
|
|
ConvertIntToDecimalStringN(string, gSaveBlock2Ptr->playTimeMinutes, STR_CONV_MODE_LEADING_ZEROS, 2);
|
2018-02-07 03:37:54 +01:00
|
|
|
break;
|
2020-02-07 18:48:47 +01:00
|
|
|
case SAVE_MENU_LOCATION:
|
2019-10-18 01:22:03 +02:00
|
|
|
GetMapNameGeneric(string, gMapHeader.regionMapSectionId);
|
2018-02-07 03:37:54 +01:00
|
|
|
break;
|
2020-02-07 18:48:47 +01:00
|
|
|
case SAVE_MENU_BADGES:
|
|
|
|
for (curFlag = FLAG_BADGE01_GET, flagCount = 0, endOfString = string + 1; curFlag < FLAG_BADGE01_GET + NUM_BADGES; curFlag++)
|
2018-02-07 03:37:54 +01:00
|
|
|
{
|
|
|
|
if (FlagGet(curFlag))
|
|
|
|
flagCount++;
|
|
|
|
}
|
|
|
|
*string = flagCount + CHAR_0;
|
|
|
|
*endOfString = EOS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|