2017-01-14 19:53:20 +00:00
|
|
|
#ifndef GUARD_TEXT_H
|
|
|
|
#define GUARD_TEXT_H
|
|
|
|
|
2021-10-30 21:19:10 +01:00
|
|
|
#include "characters.h"
|
2021-09-24 19:30:15 +01:00
|
|
|
|
2021-11-03 22:29:18 +00:00
|
|
|
// Given as a text speed when all the text should be
|
|
|
|
// loaded at once but not copied to vram yet.
|
|
|
|
#define TEXT_SKIP_DRAW 0xFF
|
2017-11-19 21:48:46 +00:00
|
|
|
|
2024-01-17 06:12:04 +00:00
|
|
|
// See include/config/decap.h for decap configuration
|
2024-01-08 00:52:29 +00:00
|
|
|
#if DECAP_MIRRORING
|
|
|
|
#define ROM_MIRROR_MASK (0x02000000)
|
|
|
|
#define RAM_MIRROR_MASK (0x00800000)
|
|
|
|
#define ROM_MIRROR_PTR(x) ((void*)(((u32)(x)) | ROM_MIRROR_MASK))
|
|
|
|
#define RAM_MIRROR_PTR(x) ((void*)(((u32)(x)) | RAM_MIRROR_MASK))
|
|
|
|
#endif
|
|
|
|
|
2021-10-30 21:47:37 +01:00
|
|
|
enum {
|
|
|
|
FONT_SMALL,
|
|
|
|
FONT_NORMAL,
|
|
|
|
FONT_SHORT,
|
|
|
|
FONT_SHORT_COPY_1,
|
|
|
|
FONT_SHORT_COPY_2,
|
|
|
|
FONT_SHORT_COPY_3,
|
|
|
|
FONT_BRAILLE,
|
|
|
|
FONT_NARROW,
|
|
|
|
FONT_SMALL_NARROW, // Very similar to FONT_SMALL, some glyphs are narrower
|
|
|
|
FONT_BOLD, // JP glyph set only
|
|
|
|
};
|
|
|
|
|
2021-11-03 22:29:18 +00:00
|
|
|
// Return values for font functions
|
|
|
|
enum {
|
|
|
|
RENDER_PRINT,
|
|
|
|
RENDER_FINISH,
|
|
|
|
RENDER_REPEAT, // Run render function again, if e.g. a control code is encountered.
|
|
|
|
RENDER_UPDATE,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Text printer states read by RenderText / FontFunc_Braille
|
|
|
|
enum {
|
|
|
|
RENDER_STATE_HANDLE_CHAR,
|
|
|
|
RENDER_STATE_WAIT,
|
|
|
|
RENDER_STATE_CLEAR,
|
|
|
|
RENDER_STATE_SCROLL_START,
|
|
|
|
RENDER_STATE_SCROLL,
|
|
|
|
RENDER_STATE_WAIT_SE,
|
|
|
|
RENDER_STATE_PAUSE,
|
|
|
|
};
|
|
|
|
|
2021-10-30 21:47:37 +01:00
|
|
|
enum {
|
2018-07-15 12:23:38 +01:00
|
|
|
FONTATTR_MAX_LETTER_WIDTH,
|
|
|
|
FONTATTR_MAX_LETTER_HEIGHT,
|
|
|
|
FONTATTR_LETTER_SPACING,
|
|
|
|
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 08:22:50 +01:00
|
|
|
FONTATTR_UNKNOWN, // dunno what this is yet
|
2018-07-15 12:23:38 +01:00
|
|
|
FONTATTR_COLOR_FOREGROUND,
|
|
|
|
FONTATTR_COLOR_BACKGROUND,
|
|
|
|
FONTATTR_COLOR_SHADOW
|
|
|
|
};
|
|
|
|
|
2018-11-05 20:42:12 +00:00
|
|
|
struct TextPrinterSubStruct
|
2017-09-22 04:43:13 +01:00
|
|
|
{
|
2021-10-30 21:47:37 +01:00
|
|
|
u8 fontId:4; // 0x14
|
2018-11-06 16:44:48 +00:00
|
|
|
bool8 hasPrintBeenSpedUp:1;
|
2018-11-06 17:30:21 +00:00
|
|
|
u8 unk:3;
|
2018-11-06 16:44:48 +00:00
|
|
|
u8 downArrowDelay:5;
|
|
|
|
u8 downArrowYPosIdx:2;
|
2021-10-30 21:47:37 +01:00
|
|
|
bool8 hasFontIdBeenSet:1;
|
2018-11-06 17:30:21 +00:00
|
|
|
u8 autoScrollDelay;
|
2017-09-22 04:43:13 +01:00
|
|
|
};
|
|
|
|
|
2018-11-06 16:44:48 +00:00
|
|
|
struct TextPrinterTemplate
|
2017-09-26 21:39:59 +01:00
|
|
|
{
|
2022-07-29 15:17:58 +01:00
|
|
|
const u8 *currentChar;
|
2017-09-23 02:26:37 +01:00
|
|
|
u8 windowId;
|
|
|
|
u8 fontId;
|
|
|
|
u8 x;
|
|
|
|
u8 y;
|
|
|
|
u8 currentX; // 0x8
|
|
|
|
u8 currentY;
|
|
|
|
u8 letterSpacing;
|
|
|
|
u8 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 08:22:50 +01:00
|
|
|
u8 unk:4; // 0xC
|
2018-01-25 21:25:35 +00:00
|
|
|
u8 fgColor:4;
|
2017-09-23 02:26:37 +01:00
|
|
|
u8 bgColor:4;
|
|
|
|
u8 shadowColor:4;
|
|
|
|
};
|
|
|
|
|
2017-03-07 13:44:41 +00:00
|
|
|
struct TextPrinter
|
|
|
|
{
|
2018-11-06 16:44:48 +00:00
|
|
|
struct TextPrinterTemplate printerTemplate;
|
2017-09-06 16:19:08 +01:00
|
|
|
|
2018-11-06 16:44:48 +00:00
|
|
|
void (*callback)(struct TextPrinterTemplate *, u16); // 0x10
|
2017-09-06 16:19:08 +01:00
|
|
|
|
2020-05-21 03:07:49 +01:00
|
|
|
u8 subStructFields[7]; // always cast to struct TextPrinterSubStruct... so why bother
|
2018-11-05 20:42:12 +00:00
|
|
|
u8 active;
|
2017-03-07 13:44:41 +00:00
|
|
|
u8 state; // 0x1C
|
2018-11-05 20:42:12 +00:00
|
|
|
u8 textSpeed;
|
2017-03-07 13:44:41 +00:00
|
|
|
u8 delayCounter;
|
|
|
|
u8 scrollDistance;
|
|
|
|
u8 minLetterSpacing; // 0x20
|
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 08:22:50 +01:00
|
|
|
u8 japanese;
|
2024-01-08 00:52:29 +00:00
|
|
|
u8 lastChar; // used to determine whether to decap strings
|
2017-03-07 13:44:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct FontInfo
|
|
|
|
{
|
|
|
|
u16 (*fontFunction)(struct TextPrinter *x);
|
|
|
|
u8 maxLetterWidth;
|
|
|
|
u8 maxLetterHeight;
|
|
|
|
u8 letterSpacing;
|
|
|
|
u8 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 08:22:50 +01:00
|
|
|
u8 unk:4;
|
2018-01-25 21:25:35 +00:00
|
|
|
u8 fgColor:4;
|
2017-03-07 13:44:41 +00:00
|
|
|
u8 bgColor:4;
|
|
|
|
u8 shadowColor:4;
|
|
|
|
};
|
|
|
|
|
2017-09-22 04:43:13 +01:00
|
|
|
extern const struct FontInfo *gFonts;
|
|
|
|
|
2017-09-18 22:48:47 +01:00
|
|
|
struct GlyphWidthFunc
|
|
|
|
{
|
2018-11-06 17:30:21 +00:00
|
|
|
u32 fontId;
|
2017-03-28 01:30:49 +01:00
|
|
|
u32 (*func)(u16 glyphId, bool32 isJapanese);
|
|
|
|
};
|
|
|
|
|
2017-09-22 04:43:13 +01:00
|
|
|
typedef struct {
|
2018-11-06 17:30:21 +00:00
|
|
|
bool8 canABSpeedUpPrint:1;
|
|
|
|
bool8 useAlternateDownArrow:1;
|
|
|
|
bool8 autoScroll:1;
|
|
|
|
bool8 forceMidTextSpeed:1;
|
2017-09-22 04:43:13 +01:00
|
|
|
} TextFlags;
|
|
|
|
|
2021-03-29 17:20:00 +01:00
|
|
|
struct TextGlyph
|
2018-11-05 20:42:12 +00:00
|
|
|
{
|
2021-03-29 17:20:00 +01:00
|
|
|
u32 gfxBufferTop[16];
|
|
|
|
u32 gfxBufferBottom[16];
|
2020-10-21 09:26:45 +01:00
|
|
|
u8 width;
|
|
|
|
u8 height;
|
2018-11-05 20:42:12 +00:00
|
|
|
};
|
|
|
|
|
2017-09-22 04:43:13 +01:00
|
|
|
extern TextFlags gTextFlags;
|
|
|
|
|
2021-03-29 17:20:00 +01:00
|
|
|
extern u8 gDisableTextPrinters;
|
|
|
|
extern struct TextGlyph gCurGlyph;
|
2017-09-22 04:43:13 +01:00
|
|
|
|
2024-01-08 00:52:29 +00:00
|
|
|
extern const u16 gLowercaseDiffTable[];
|
2024-01-17 06:12:04 +00:00
|
|
|
// in gLowercaseDiffTable, 0x100 represents a character treated as uppercase,
|
|
|
|
// but that maps to itself; only the lower 8 bits are used for mapping
|
|
|
|
#define MARK_UPPER_FLAG 0x100
|
|
|
|
#define LOWERCASE_DIFF_MASK 0xFF
|
|
|
|
#define IS_UPPER(x) (gLowercaseDiffTable[(x) & LOWERCASE_DIFF_MASK])
|
|
|
|
#define TO_LOWER(x) (((x) + gLowercaseDiffTable[(x)]) & LOWERCASE_DIFF_MASK)
|
2024-01-08 00:52:29 +00:00
|
|
|
|
|
|
|
void * UnmirrorPtr(const void * ptr);
|
|
|
|
void * MirrorPtr(const void * ptr);
|
|
|
|
bool32 IsMirrorPtr(const void *ptr);
|
|
|
|
u16 AddTextPrinterFixedCaseParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16));
|
|
|
|
|
2017-09-18 17:36:05 +01:00
|
|
|
void DeactivateAllTextPrinters(void);
|
2018-11-06 16:44:48 +00:00
|
|
|
u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16));
|
2024-03-06 21:22:05 +00:00
|
|
|
bool32 AddTextPrinter(struct TextPrinterTemplate *template, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16));
|
2017-03-28 05:20:55 +01:00
|
|
|
void RunTextPrinters(void);
|
2024-03-06 21:22:05 +00:00
|
|
|
bool32 IsTextPrinterActive(u8 id);
|
2017-03-28 05:20:55 +01:00
|
|
|
void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor);
|
|
|
|
void SaveTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor);
|
|
|
|
void RestoreTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor);
|
2018-11-21 22:30:04 +00:00
|
|
|
void DecompressGlyphTile(const void *src_, void *dest_);
|
2017-03-28 05:20:55 +01:00
|
|
|
void CopyGlyphToWindow(struct TextPrinter *x);
|
|
|
|
void ClearTextSpan(struct TextPrinter *textPrinter, u32 width);
|
|
|
|
|
|
|
|
void TextPrinterInitDownArrowCounters(struct TextPrinter *textPrinter);
|
|
|
|
void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter);
|
|
|
|
void TextPrinterClearDownArrow(struct TextPrinter *textPrinter);
|
2024-03-06 21:22:05 +00:00
|
|
|
bool32 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter);
|
|
|
|
bool32 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter);
|
|
|
|
bool32 TextPrinterWait(struct TextPrinter *textPrinter);
|
|
|
|
void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool32 drawArrow, u8 *counter, u8 *yCoordIndex);
|
2018-12-15 22:58:47 +00:00
|
|
|
s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing);
|
2021-10-31 05:44:18 +00:00
|
|
|
u8 RenderTextHandleBold(u8 *pixels, u8 fontId, u8 *str);
|
2017-03-28 05:20:55 +01:00
|
|
|
u8 DrawKeypadIcon(u8 windowId, u8 keypadIconId, u16 x, u16 y);
|
|
|
|
u8 GetKeypadIconTileOffset(u8 keypadIconId);
|
|
|
|
u8 GetKeypadIconWidth(u8 keypadIconId);
|
|
|
|
u8 GetKeypadIconHeight(u8 keypadIconId);
|
|
|
|
void SetDefaultFontsPointer(void);
|
|
|
|
u8 GetFontAttribute(u8 fontId, u8 attributeId);
|
|
|
|
u8 GetMenuCursorDimensionByFont(u8 fontId, u8 whichDimension);
|
2021-10-30 21:47:37 +01:00
|
|
|
|
|
|
|
// braille.c
|
|
|
|
u16 FontFunc_Braille(struct TextPrinter *textPrinter);
|
|
|
|
u32 GetGlyphWidth_Braille(u16 glyphId, bool32 isJapanese);
|
2019-03-02 08:18:08 +00:00
|
|
|
|
2017-01-14 19:53:20 +00:00
|
|
|
#endif // GUARD_TEXT_H
|