1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
|
#ifndef GUARD_TEXT_H
#define GUARD_TEXT_H
#include "global.h"
#define CHAR_SPACE 0x00
#define CHAR_0 0xA1
#define CHAR_1 0xA2
#define CHAR_2 0xA3
#define CHAR_3 0xA4
#define CHAR_4 0xA5
#define CHAR_5 0xA6
#define CHAR_6 0xA7
#define CHAR_7 0xA8
#define CHAR_8 0xA9
#define CHAR_9 0xAA
#define CHAR_EXCL_MARK 0xAB
#define CHAR_QUESTION_MARK 0xAC
#define CHAR_PERIOD 0xAD
#define CHAR_HYPHEN 0xAE
#define CHAR_ELLIPSIS 0xB0
#define CHAR_DBL_QUOT_LEFT 0xB1
#define CHAR_DBL_QUOT_RIGHT 0xB2
#define CHAR_SGL_QUOT_LEFT 0xB3
#define CHAR_SGL_QUOT_RIGHT 0xB4
#define CHAR_MALE 0xB5
#define CHAR_FEMALE 0xB6
#define CHAR_CURRENCY 0xB7
#define CHAR_COMMA 0xB8
#define CHAR_MULT_SIGN 0xB9
#define CHAR_SLASH 0xBA
#define CHAR_A 0xBB
#define CHAR_B 0xBC
#define CHAR_C 0xBD
#define CHAR_D 0xBE
#define CHAR_E 0xBF
#define CHAR_F 0xC0
#define CHAR_G 0xC1
#define CHAR_H 0xC2
#define CHAR_I 0xC3
#define CHAR_J 0xC4
#define CHAR_K 0xC5
#define CHAR_L 0xC6
#define CHAR_M 0xC7
#define CHAR_N 0xC8
#define CHAR_O 0xC9
#define CHAR_P 0xCA
#define CHAR_Q 0xCB
#define CHAR_R 0xCC
#define CHAR_S 0xCD
#define CHAR_T 0xCE
#define CHAR_U 0xCF
#define CHAR_V 0xD0
#define CHAR_W 0xD1
#define CHAR_X 0xD2
#define CHAR_Y 0xD3
#define CHAR_Z 0xD4
#define CHAR_a 0xD5
#define CHAR_b 0xD6
#define CHAR_c 0xD7
#define CHAR_d 0xD8
#define CHAR_e 0xD9
#define CHAR_f 0xDA
#define CHAR_g 0xDB
#define CHAR_h 0xDC
#define CHAR_i 0xDD
#define CHAR_j 0xDE
#define CHAR_k 0xDF
#define CHAR_l 0xE0
#define CHAR_m 0xE1
#define CHAR_n 0xE2
#define CHAR_o 0xE3
#define CHAR_p 0xE4
#define CHAR_q 0xE5
#define CHAR_r 0xE6
#define CHAR_s 0xE7
#define CHAR_t 0xE8
#define CHAR_u 0xE9
#define CHAR_v 0xEA
#define CHAR_w 0xEB
#define CHAR_x 0xEC
#define CHAR_y 0xED
#define CHAR_z 0xEE
#define CHAR_COLON 0xF0
#define CHAR_DYNAMIC_PLACEHOLDER 0xF7
#define CHAR_KEYPAD_ICON 0xF8
#define CHAR_EXTRA_EMOJI 0xF9
#define CHAR_PROMPT_SCROLL 0xFA // waits for button press and scrolls dialog
#define CHAR_PROMPT_CLEAR 0xFB // waits for button press and clears dialog
#define EXT_CTRL_CODE_BEGIN 0xFC // extended control code
#define PLACEHOLDER_BEGIN 0xFD // string placeholder
#define CHAR_NEWLINE 0xFE
#define EOS 0xFF // end of string
#define TEXT_COLOR_TRANSPARENT 0x0
#define TEXT_COLOR_WHITE 0x1
#define TEXT_COLOR_DARK_GRAY 0x2
#define TEXT_COLOR_LIGHT_GRAY 0x3
#define TEXT_COLOR_RED 0x4
#define TEXT_COLOR_LIGHT_RED 0x5
#define TEXT_COLOR_GREEN 0x6
#define TEXT_COLOR_LIGHT_GREEN 0x7
#define TEXT_COLOR_BLUE 0x8
#define TEXT_COLOR_LIGHT_BLUE 0x9
#define TEXT_DYNAMIC_COLOR_1 0xA // Usually white
#define TEXT_DYNAMIC_COLOR_2 0xB // Usually white w/ tinge of green
#define TEXT_DYNAMIC_COLOR_3 0xC // Usually white
#define TEXT_DYNAMIC_COLOR_4 0xD // Usually aquamarine
#define TEXT_DYNAMIC_COLOR_5 0xE // Usually blue-green
#define TEXT_DYNAMIC_COLOR_6 0xF // Usually cerulean
#define PLACEHOLDER_ID_UNKNOWN 0x0
#define PLACEHOLDER_ID_PLAYER 0x1
#define PLACEHOLDER_ID_STRING_VAR_1 0x2
#define PLACEHOLDER_ID_STRING_VAR_2 0x3
#define PLACEHOLDER_ID_STRING_VAR_3 0x4
#define PLACEHOLDER_ID_KUN 0x5
#define PLACEHOLDER_ID_RIVAL 0x6
#define PLACEHOLDER_ID_VERSION 0x7
#define PLACEHOLDER_ID_MAGMA 0x8
#define PLACEHOLDER_ID_AQUA 0x9
#define PLACEHOLDER_ID_MAXIE 0xA
#define PLACEHOLDER_ID_ARCHIE 0xB
#define PLACEHOLDER_ID_GROUDON 0xC
#define PLACEHOLDER_ID_KYOGRE 0xD
// battle placeholders are located in battle_message.h
#define EXT_CTRL_CODE_COLOR 0x1
#define EXT_CTRL_CODE_HIGHLIGHT 0x2
#define EXT_CTRL_CODE_SHADOW 0x3
#define EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW 0x4
#define EXT_CTRL_CODE_PALETTE 0x5
#define EXT_CTRL_CODE_FONT 0x6
#define EXT_CTRL_CODE_RESET_FONT 0x7
#define EXT_CTRL_CODE_PAUSE 0x8
#define EXT_CTRL_CODE_WAIT_BUTTON 0x9
#define EXT_CTRL_CODE_WAIT_SE 0xA
#define EXT_CTRL_CODE_PLAY_BGM 0xB
#define EXT_CTRL_CODE_ESCAPE 0xC
#define EXT_CTRL_CODE_SHIFT_RIGHT 0xD
#define EXT_CTRL_CODE_SHIFT_DOWN 0xE
#define EXT_CTRL_CODE_FILL_WINDOW 0xF
#define EXT_CTRL_CODE_PLAY_SE 0x10
#define EXT_CTRL_CODE_CLEAR 0x11
#define EXT_CTRL_CODE_SKIP 0x12
#define EXT_CTRL_CODE_CLEAR_TO 0x13
#define EXT_CTRL_CODE_MIN_LETTER_SPACING 0x14
#define EXT_CTRL_CODE_JPN 0x15
#define EXT_CTRL_CODE_ENG 0x16
#define EXT_CTRL_CODE_STOP_BGM 0x17
#define EXT_CTRL_CODE_RESUME_BGM 0x18
#define NUM_TEXT_PRINTERS 32
#define TEXT_SPEED_INSTANT 0
#define TEXT_SPEED_FF 0xFF
enum
{
FONTATTR_MAX_LETTER_WIDTH,
FONTATTR_MAX_LETTER_HEIGHT,
FONTATTR_LETTER_SPACING,
FONTATTR_LINE_SPACING,
FONTATTR_UNKNOWN, // dunno what this is yet
FONTATTR_COLOR_FOREGROUND,
FONTATTR_COLOR_BACKGROUND,
FONTATTR_COLOR_SHADOW
};
struct GlyphInfo
{
u8 pixels[0x80];
u8 width;
u8 height;
};
extern struct GlyphInfo gGlyphInfo;
struct TextPrinterSubStruct
{
u8 glyphId:4; // 0x14
bool8 hasPrintBeenSpedUp:1;
u8 font_type_5:3;
u8 downArrowDelay:5;
u8 downArrowYPosIdx:2;
u8 hasGlyphIdBeenSet:1;
u8 autoScrollDelay;
};
struct TextPrinterTemplate // TODO: Better name
{
const u8* currentChar;
u8 windowId;
u8 fontId;
u8 x;
u8 y;
u8 currentX; // 0x8
u8 currentY;
u8 letterSpacing;
u8 lineSpacing;
u8 unk:4; // 0xC
u8 fgColor:4;
u8 bgColor:4;
u8 shadowColor:4;
};
struct TextPrinter
{
struct TextPrinterTemplate printerTemplate;
void (*callback)(struct TextPrinterTemplate *, u16); // 0x10
union __attribute__((packed)) {
struct TextPrinterSubStruct sub;
u8 fields[7];
} subUnion;
u8 active;
u8 state; // 0x1C
u8 textSpeed;
u8 delayCounter;
u8 scrollDistance;
u8 minLetterSpacing; // 0x20
u8 japanese;
};
struct FontInfo
{
u16 (*fontFunction)(struct TextPrinter *x);
u8 maxLetterWidth;
u8 maxLetterHeight;
u8 letterSpacing;
u8 lineSpacing;
u8 unk:4;
u8 fgColor:4;
u8 bgColor:4;
u8 shadowColor:4;
};
extern const struct FontInfo *gFonts;
struct GlyphWidthFunc
{
u32 fontId;
s32 (*func)(u16 glyphId, bool32 isJapanese);
};
struct KeypadIcon
{
u16 tileOffset;
u8 width;
u8 height;
};
typedef struct {
u8 canABSpeedUpPrint:1;
u8 useAlternateDownArrow:1;
u8 autoScroll:1;
u8 forceMidTextSpeed:1;
} TextFlags;
extern TextFlags gTextFlags;
extern u8 gStringVar1[];
extern u8 gStringVar2[];
extern u8 gStringVar3[];
extern u8 gStringVar4[];
extern const u8 gKeypadIconTiles[];
void SetFontsPointer(const struct FontInfo *fonts);
void DeactivateAllTextPrinters(void);
u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16));
bool16 AddTextPrinter(struct TextPrinterTemplate *textSubPrinter, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16));
void RunTextPrinters(void);
bool16 IsTextPrinterActive(u8 id);
u32 RenderFont(struct TextPrinter *textPrinter);
void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor);
void SaveTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor);
void RestoreTextColors(u8 *fgColor, u8 *bgColor, u8 *shadowColor);
void DecompressGlyphTile(const u16 *src, u16 *dest);
u8 GetLastTextColor(u8 colorType);
void CopyGlyphToWindow(struct TextPrinter *x);
void ClearTextSpan(struct TextPrinter *textPrinter, u32 width);
u16 Font0Func(struct TextPrinter *textPrinter);
u16 Font1Func(struct TextPrinter *textPrinter);
u16 Font2Func(struct TextPrinter *textPrinter);
u16 Font3Func(struct TextPrinter *textPrinter);
u16 Font4Func(struct TextPrinter *textPrinter);
u16 Font5Func(struct TextPrinter *textPrinter);
u16 Font7Func(struct TextPrinter *textPrinter);
u16 Font8Func(struct TextPrinter *textPrinter);
u16 Font6Func(struct TextPrinter *textPrinter);
void TextPrinterInitDownArrowCounters(struct TextPrinter *textPrinter);
void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter);
void TextPrinterClearDownArrow(struct TextPrinter *textPrinter);
bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter);
bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter);
bool16 TextPrinterWait(struct TextPrinter *textPrinter);
void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *counter, u8 *yCoordIndex);
u16 RenderText(struct TextPrinter *textPrinter);
s32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing);
s32 (*GetFontWidthFunc(u8 glyphId))(u16, bool32);
s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing);
u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str, int a3, int a4, int a5, int a6, int a7);
u8 DrawKeypadIcon(u8 windowId, u8 keypadIconId, u16 x, u16 y);
u8 GetKeypadIconTileOffset(u8 keypadIconId);
u8 GetKeypadIconWidth(u8 keypadIconId);
u8 GetKeypadIconHeight(u8 keypadIconId);
u8 GetFontAttribute(u8 fontId, u8 attributeId);
u8 GetMenuCursorDimensionByFont(u8 fontId, u8 whichDimension);
void DecompressGlyphFont0(u16 glyphId, bool32 isJapanese);
s32 GetGlyphWidthFont0(u16 glyphId, bool32 isJapanese);
void DecompressGlyphFont7(u16 glyphId, bool32 isJapanese);
s32 GetGlyphWidthFont7(u16 glyphId, bool32 isJapanese);
void DecompressGlyphFont8(u16 glyphId, bool32 isJapanese);
s32 GetGlyphWidthFont8(u16 glyphId, bool32 isJapanese);
void DecompressGlyphFont2(u16 glyphId, bool32 isJapanese);
s32 GetGlyphWidthFont2(u16 glyphId, bool32 isJapanese);
void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese);
s32 GetGlyphWidthFont1(u16 glyphId, bool32 isJapanese);
void DecompressGlyphFont9(u16 glyphId);
s32 GetGlyphWidthFont3(u16 glyphId, bool32 isJapanese);
s32 GetGlyphWidthFont4(u16 glyphId, bool32 isJapanese);
void DecompressGlyphFont5(u16 glyphId, bool32 isJapanese);
s32 GetGlyphWidthFont5(u16 glyphId, bool32 isJapanese);
void sub_80062B0(struct Sprite *sprite);
u8 CreateTextCursorSpriteForOakSpeech(u8 sheetId, u16 x, u16 y, u8 priority, u8 subpriority);
void DestroyTextCursorSprite(u8 spriteId);
s32 GetGlyphWidthFont6(u16 font_type, bool32 isJapanese);
#endif // GUARD_TEXT_H
|