Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
text.h
Go to the documentation of this file.
1#ifndef DW3_TEXT_H
2#define DW3_TEXT_H
3
4/* Text windows, the cursor, the message and talk boxes, the font and the
5 text helpers (text/) */
6
7#include "common.h"
8#include <sys/types.h>
9#include <libgte.h>
10#include <libgpu.h>
11#include "engine/task.h"
12#include "engine/gfx.h"
13
14/*
15 * A menu cursor: a text window showing one of the CURSOR_FRAMES glyphs.
16 * It waits idleDelay vsyncs, then plays the five frames (substate 1) at
17 * frameDelay vsyncs each.
18 */
19typedef struct Cursor {
21 /* 0x50 */ s32 layerId;
22 /* 0x54 */ s32 depth;
23 /* 0x58 */ s32 x;
24 /* 0x5C */ s32 y;
25 /* 0x60 */ s32 palette; /* PALETTE_*, its text window's */
26 /* 0x64 */ s32 visible;
27 /* 0x68 */ s32 dirty;
28 /* 0x6C */ s32 frame;
29 /* 0x70 */ s32 time;
30 /* 0x74 */ s32 idleDelay;
31 /* 0x78 */ s32 frameDelay;
32 /* 0x7C */ s32 still; /* stay on frame 0 */
33 /* 0x80 */ void (*setVisible)(); /* (cursor, visible) */
34 /* 0x84 */ void (*setPos)(); /* (cursor, x, y) */
35 /* 0x88 */ void (*setPalette)();
36 /* 0x8C */ void (*setIdleDelay)();
37 /* 0x90 */ void (*setFrameDelay)();
38 /* 0x94 */ void (*setStill)();
39} Cursor;
40
41/*
42 * The frame of a message box: two halves of the bottom panel that grow from
43 * the sides (substate 0), stay with a "next" arrow when showArrow is set
44 * (substate 1), and fade out through five palette rows (substate 2).
45 */
46typedef struct MessageBoxFrame {
48 /* 0x50 */ s32 layerId;
49 /* 0x54 */ s32 time;
50 /* 0x58 */ s32 fadeRow;
51 /* 0x5C */ s32 showArrow;
52 /* 0x60 */ s32 arrowTime;
53 /* 0x64 */ s32 arrowFrame;
54 /* 0x68 */ s16 scale;
55 /* 0x6A */ s16 scaleStep;
57
58/* The children of a TalkBox */
59typedef struct TalkBoxChildren {
60 /* 0x00 */ struct ZoomBox *zoomBoxes[3];
61 /* 0x0C */ struct TextWindow *windows[2]; /* speaker, message */
62 /* 0x14 */ struct TalkBoxFrame *frame;
64
65/*
66 * A box with a speaker's name and a message (createTalkBox). It opens and
67 * closes with three ZoomBox outlines (substate 0 opens, 1 closes) and
68 * type (0-3) picks one of the TALK_BOX_LAYOUTS.
69 */
70typedef struct TalkBox {
72 /* 0x50 */ void *strings;
73 /* 0x54 */ s32 layerId;
74 /* 0x58 */ s32 type;
75 /* 0x5C */ s32 timer;
76 /* 0x60 */ s16 x;
77 /* 0x62 */ s16 y;
78 /* 0x64 */ s16 w;
79 /* 0x66 */ s16 h;
80 /* 0x68 */ void (*setPos)(struct TalkBox *box, s32 x, s32 y);
81} TalkBox;
82
83/* Draws a TalkBox's panel */
84typedef struct TalkBoxFrame {
86 /* 0x50 */ TalkBox *parent;
87 /* 0x54 */ s32 arrowFrame;
88 /* 0x58 */ s32 arrowTime;
89 /* 0x5C */ u8 showArrow;
91
92/* Text helpers (initTextTools) */
93typedef struct TextTools {
94 /* 0x0 */ char *(*getString)(); /* (table, index) */
95 /* 0x4 */ s32 (*measure)(); /* (TextBuffer *, style, spacing) */
96 /* 0x8 */ void (*convert)(); /* (dst, src, mode): font codes <-> Shift-JIS */
97} TextTools;
98
99typedef struct TextBuffer {
100 /* 0x0 */ u8 *data;
101 /* 0x4 */ s16 cap;
102 /* 0x6 */ s16 len;
103 /* 0x8 */ s16 pos;
104 /* 0xA */ s16 sjis; /* two bytes per character; else font codes */
105} TextBuffer;
106
107/*
108 * The text windows' palettes (TextWindow.palette, setPalette): rows of the
109 * font's CLUTs, named by the colour of the letters (white letters with a
110 * grey shade in PALETTE_WHITE, the default)
111 */
112#define PALETTE_WHITE 0
113#define PALETTE_BLUE 1 /* a light blue: what is highlighted or current */
114#define PALETTE_DARK_BLUE 2
115#define PALETTE_YELLOW 3
116#define PALETTE_GREEN 4
117#define PALETTE_RED 5
118#define PALETTE_PURPLE 6
119#define PALETTE_GREY 7 /* what is unavailable */
120
121/*
122 * A text window (createTextWindow): up to six text buffers (0 is shown, 1-5
123 * are "work" buffers that control code 5 inserts), drawn glyph by glyph as
124 * sprites, optionally typed out one character every typeDelay frames.
125 * Control codes are 0x02 <code> <args> (TEXT_CODE_HANDLERS). The game's
126 * own debug strings call these "messages" (STR_NULL_MESSAGE...).
127 * States: 1 shows the text, 2 waits (substate 0: `step` frames,
128 * substate 1: button TEXT_WAIT_BUTTONS[step], then patches the code at
129 * `counter` so that it does not wait again), 3 frees the buffers.
130 */
131typedef struct TextWindow {
133 /* 0x50 */ struct TextStyle *style;
134 /* 0x54 */ s32 layerId;
135 /* 0x58 */ s32 depth;
136 /* 0x5C */ TextBuffer text[6];
137 /* 0xA4 */ u16 visibleEnd;
138 /* 0xA6 */ s16 start;
139 /* 0xA8 */ s16 typeTimer;
140 /* 0xAA */ s16 typeDelay;
141 /* 0xAC */ s16 texX;
142 /* 0xAE */ s16 texY;
143 /* 0xB0 */ s16 x;
144 /* 0xB2 */ s16 y;
145 /* 0xB4 */ s16 spacingX;
146 /* 0xB6 */ s16 spacingY;
147 /* 0xB8 */ s16 cursorX;
148 /* 0xBA */ u16 cursorY;
149 /* 0xBC */ s16 alignWidth;
150 /* 0xBE */ s8 blend; /* -1 (TextStyle.blend 0xFF): opaque */
151 /* 0xBF */ u8 lines;
152 /* 0xC0 */ u8 palette; /* PALETTE_* */
153 /* 0xC1 */ u8 visible;
154 /* 0xC2 */ u8 fixedSpacing;
155 /* 0xC3 */ u8 finished;
156 /* 0xC4 */ u8 unusedC4; /* only setUnusedC4 writes it, and nothing calls that */
157 /* 0xC8 */ s32 typeSound;
158 /* 0xCC */ s32 scaled;
159 /* 0xD0 */ VECTOR scale; /* ScaleMatrix's */
160 /* 0xE0 */ s32 pivotX;
161 /* 0xE4 */ s32 pivotY;
162 /* 0xE8 */ SVECTOR rot;
163 /* 0xF0 */ MATRIX mat;
164 /* 0x110 */ void (*setText)();
165 /* 0x114 */ void (*setString)();
166 /* 0x118 */ void (*setNumber)();
167 /* 0x11C */ void (*setSubText)();
168 /* 0x120 */ void (*setSubString)();
169 /* 0x124 */ void (*draw)();
170 /* 0x128 */ void (*showPage)();
171 /* 0x12C */ void (*setStyle)();
172 /* 0x130 */ void (*setTypeDelay)();
173 /* 0x134 */ void (*setPos)(struct TextWindow *obj, s16 x, s16 y);
174 /* 0x138 */ void (*setPalette)(struct TextWindow *obj, u8 arg);
175 /* 0x13C */ void (*setBlend)(); /* no prototype: callers would truncate u8 args */
176 /* 0x140 */ void (*setSpacing)(); /* no prototype: callers would truncate s16 args */
177 /* 0x144 */ void (*setVisible)(struct TextWindow *obj, u8 arg);
178 /* 0x148 */ void (*setRightAlign)(); /* no prototype: callers would truncate u8 args */
179 /* 0x14C */ void (*insertPlayerName)();
180 /* 0x150 */ void (*setTypeSound)();
181 /* 0x154 */ void (*setScale)();
182 /* 0x158 */ void (*setPivot)();
183 /* 0x15C */ void (*setDepth)();
184 /* 0x160 */ void (*setLines)(); /* no prototype: callers would truncate u8 args */
185 /* 0x164 */ void (*setUnusedC4)(); /* no prototype: callers would truncate u8 args */
186 /* 0x168 */ s32 (*isFinished)(); /* s32: callers don't truncate the result to a byte */
187 /* 0x16C */ s32 (*isVisible)(); /* s32: callers don't truncate the result to a byte */
188 /* 0x170 */ s32 (*isWaitingForButton)();
189} TextWindow;
190
191/* Where the parts of a TalkBox go, for each of its four types */
192typedef struct TalkBoxLayout {
193 /* 0x00 */ s32 sprite;
194 /* 0x04 */ DVECTOR spritePos; /* the four positions drawTalkBoxFrame walks */
195 /* 0x08 */ DVECTOR sprite0Pos; /* also the ZoomBox's offset */
196 /* 0x0C */ DVECTOR panel;
197 /* 0x10 */ DVECTOR sprite2Pos; /* its y only for types 2 and 3 */
198 /* 0x14 */ s16 nameX;
199 /* 0x16 */ s16 nameY;
200 /* 0x18 */ s16 textX;
201 /* 0x1A */ s16 textY;
202 /* 0x1C */ DVECTOR arrow; /* where the talk box arrow is drawn */
204
205/*
206 * The font (FONT): three text styles, the length of each control code, and
207 * decode(), which turns the next character into kind << 8 | value:
208 * kind 0 a glyph (value - 4 indexes glyphs), 1 an icon, 2 a control code,
209 * 3 a missing character, 4 the end.
210 */
211typedef struct Font {
212 /* 0x0 */ struct TextStyle *styles; /* [4], style 0 unused */
213 /* 0x4 */ s32 *codeLengths;
214 /* 0x8 */ void (*load)();
215 /* 0xC */ s16 (*decode)(); /* (text, sjis, style) */
216} Font;
217
218/* Maps a Shift-JIS character to a glyph */
219typedef struct GlyphMap {
220 /* 0x0 */ u16 code;
221 /* 0x2 */ u8 index;
222 /* 0x3 */ u8 pad; /* never read: the maps' entries are 4 bytes, for the u16 */
223} GlyphMap;
224
225typedef struct TextStyle {
226 /* 0x00 */ u8 blend; /* 0xFF: opaque */
227 /* 0x01 */ s8 lineHeight;
228 /* 0x04 */ struct Glyph *glyphs;
229 /* 0x08 */ struct Glyph *icons;
230 /* 0x0C */ GlyphMap *sjisMap;
231 /* 0x10 */ GlyphMap *iconMap;
232 /* 0x14 */ s16 glyphCount;
233 /* 0x16 */ s16 iconCount;
234} TextStyle;
235
236/* One glyph of a font sheet */
237typedef struct Glyph {
238 /* 0x0 */ u8 page; /* 0xFF: missing glyph */
239 /* 0x1 */ u8 u;
240 /* 0x2 */ u8 v;
241 /* 0x3 */ u8 clutX;
242 /* 0x4 */ u8 clutY;
243 /* 0x5 */ u8 w;
244 /* 0x6 */ u8 h;
245 /* 0x7 */ s8 dx;
246 /* 0x8 */ s8 dy;
247 /* 0x9 */ u8 advance;
248 /* 0xA */ u8 unusedA; /* h, or 10 for the 9-high glyphs; nothing reads it */
249} Glyph;
250
251/* Drawing state shared with the control-code handlers */
252typedef struct TextDraw {
253 /* 0x00 */ PrimPtr prim;
254 /* 0x04 */ Layer *layer;
255 /* 0x08 */ u_long *ot;
256 /* 0x0C */ Glyph *glyph;
257 /* 0x10 */ s32 pageStart;
258 /* 0x14 */ s16 code; /* from Font.decode */
259 /* 0x16 */ s16 kind;
260 /* 0x18 */ s16 lineCount;
261} TextDraw;
262
263/* The children of a message box (createMessageBox) */
264typedef struct MessageBox {
265 /* 0x0 */ struct TextWindow *window;
266 /* 0x4 */ struct MessageBoxFrame *frame;
267} MessageBox;
268
269/* A blue rectangle outline that zooms in (or out, when closing) around a TalkBox */
270typedef struct ZoomBox {
272 /* 0x50 */ s16 left;
273 /* 0x52 */ s16 top;
274 /* 0x54 */ s16 x; /* the zoom's centre */
275 /* 0x56 */ s16 y;
276 /* 0x58 */ s16 w;
277 /* 0x5A */ s16 h;
278 /* 0x5C */ s16 speed;
279 /* 0x60 */ s32 zoom; /* 0-ONE */
280 /* 0x64 */ s32 layerId;
281 /* 0x68 */ s32 unused68; /* only cleared when the box starts; nothing reads it */
282 /* 0x6C */ s16 offsetX;
283 /* 0x6E */ s16 offsetY;
284 /* 0x70 */ VECTOR scale;
285 /* 0x80 */ SVECTOR rot;
286 /* 0x88 */ VECTOR trans; /* the centre, set but not read */
287 /* 0x98 */ MATRIX matrix;
288 /* 0xB8 */ s32 closing;
289 /* 0xBC */ s32 opened;
290} ZoomBox;
291
292void drawMessageBoxFrame(struct MessageBoxFrame *task);
293void drawMessageBoxArrow(struct MessageBoxFrame *task);
294void setTextBuffer(struct TextWindow *obj, struct TextBuffer *buf, const char *text);
295void textWindowSetSubString(struct TextWindow *obj, char *text, s32 id, s32 index);
296void drawZoomBox(ZoomBox *task);
297void drawTalkBoxArrow(struct TalkBoxFrame *task);
298void drawTalkBoxFrame(struct TalkBoxFrame *task);
299void textWindowSetText(TextWindow *obj, const char *text);
300void textWindowSetString(TextWindow *obj, char *text, s32 id);
301void formatNumber(u8 *buf, s32 value);
302void textWindowSetNumber(TextWindow *obj, u32 index, s32 value);
303void textWindowSetSubText(TextWindow *obj, const char *text, s32 index);
305void textWindowSetPos(TextWindow *obj, s16 x, s16 y);
306void textWindowSetPalette(TextWindow *obj, u8 palette);
307void textWindowSetBlend(TextWindow *obj, s32 blend); /* old-style: u8 blend */
308void textWindowSetSpacing(TextWindow *obj, s32 x, s32 y); /* old-style: s16 x, y */
309void textWindowSetVisible(TextWindow *obj, u8 visible);
310void textWindowSetRightAlign(TextWindow *obj, s32 type); /* old-style: u8 type */
312void textWindowSetTypeSound(TextWindow *obj, s32 sound);
313void textWindowSetScale(TextWindow *obj, s32 x, s32 y);
314void textWindowSetPivot(TextWindow *obj, s32 x, s32 y);
315void textWindowSetDepth(TextWindow *obj, s32 depth);
316void textWindowSetLines(TextWindow *obj, s32 lines); /* old-style: u8 lines */
317void textWindowSetUnusedC4(TextWindow *obj, s32 value); /* old-style: u8 value */
322void textWindowSetStyle(TextWindow *obj, s32 style);
323void textWindowDraw(struct TextWindow *obj);
324void cursorSetVisible(Cursor *task, s32 visible);
325void cursorSetPos(Cursor *task, s32 x, s32 y);
326void cursorSetPalette(Cursor *task, s32 palette);
327void cursorSetIdleDelay(Cursor *task, s32 delay);
328void cursorSetFrameDelay(Cursor *task, s32 delay);
329void cursorSetStill(Cursor *task, s32 still);
330void updateCursor(Cursor *task, TextWindow **win);
331Cursor *createCursor(s16 layerId, s32 depth, s16 x, s16 y);
332void updateMessageBox(Task *task, struct MessageBox *data);
333s32 processTextChar(TextWindow *obj, TextBuffer *text, TextDraw *draw, s16 *pos);
338s32 textCodeIgnore(void);
343void updateZoomBox(struct ZoomBox *task);
344ZoomBox *createZoomBox(s32 layerId, s16 x, s16 y, s32 w, s32 h, s32 type);
345void talkBoxSetPos(TalkBox *task, s32 x, s32 y);
346void updateTalkBox(TalkBox *task, TalkBoxChildren *children);
347TextWindow *createTextWindow(s16 id, s16 type, s16 x, s16 y);
348void updateMessageBoxFrame(struct MessageBoxFrame *task);
352Task *createMessageBox(s32 layerId, void *strings, s32 index);
353TalkBox *createTalkBox(s32 id, s16 x, s16 y, void *strings, s32 index, u32 type);
354void bindTextTools(TextTools *obj);
355char *getString(s32 *table, s32 index);
356s32 measureText(TextBuffer *text, TextStyle *style, s32 spacing); /* old-style: s16 spacing */
357void initTextTools(TextTools *obj);
358void convertText(void *buf, void *text, s32 mode);
359void loadFont(void);
360s16 decodeChar(u8 *s, u8 mode, TextStyle *font);
361
362extern const char STR_NULL_MESSAGE[];
363extern const char STR_BAD_DIGIT_BUFFER[];
364extern const char STR_BAD_EXT_BUFFER[];
365extern const char STR_MESSAGE_NOT_SET[];
366extern char *CURSOR_FRAMES[];
367extern s32 TEXT_WAIT_BUTTONS[];
368extern Font FONT;
369extern s32 (*TEXT_CODE_HANDLERS[])(); /* (obj, text, wait): most handlers take only the first two */
370extern GlyphMap FONT_GLYPH_MAP[];
371extern GlyphMap FONT_ICON_MAP[];
372extern Glyph FONT_GLYPHS_1[]; /* the three font sizes' glyphs and icons (text_tools.c) */
373extern Glyph FONT_ICONS_1[];
374extern Glyph FONT_GLYPHS_2[];
375extern Glyph FONT_ICONS_2[];
376extern Glyph FONT_GLYPHS_3[];
377extern Glyph FONT_ICONS_3[];
379
380#endif /* DW3_TEXT_H */
signed int s32
Definition common.h:11
unsigned int u32
Definition common.h:12
signed char s8
Definition common.h:7
signed short s16
Definition common.h:9
unsigned short u16
Definition common.h:10
unsigned char u8
Definition common.h:8
The task system and its registry (task/)
#define TASK_HEADER(Type)
Definition task.h:39
Display, drawing layers, the drawing helpers and the screen fade (gfx/)
A menu cursor: a text window showing one of the CURSOR_FRAMES glyphs.
Definition text.h:19
s32 idleDelay
Definition text.h:30
void(* setIdleDelay)()
Definition text.h:36
s32 frame
Definition text.h:28
s32 visible
Definition text.h:26
s32 dirty
Definition text.h:27
void(* setPalette)()
Definition text.h:35
void(* setPos)()
(cursor, x, y)
Definition text.h:34
void(* setFrameDelay)()
Definition text.h:37
void(* setStill)()
Definition text.h:38
s32 frameDelay
Definition text.h:31
s32 y
Definition text.h:24
void(* setVisible)()
(cursor, visible)
Definition text.h:33
s32 depth
Definition text.h:22
s32 palette
PALETTE_*, its text window's.
Definition text.h:25
s32 x
Definition text.h:23
s32 time
Definition text.h:29
s32 still
stay on frame 0
Definition text.h:32
s32 layerId
Definition text.h:21
The font (FONT): three text styles, the length of each control code, and decode(),...
Definition text.h:211
struct TextStyle * styles
[4], style 0 unused
Definition text.h:212
void(* load)()
Definition text.h:214
s32 * codeLengths
Definition text.h:213
s16(* decode)()
(text, sjis, style)
Definition text.h:215
Maps a Shift-JIS character to a glyph.
Definition text.h:219
u8 index
Definition text.h:221
u16 code
Definition text.h:220
u8 pad
never read: the maps' entries are 4 bytes, for the u16
Definition text.h:222
One glyph of a font sheet.
Definition text.h:237
s8 dy
Definition text.h:246
u8 clutX
Definition text.h:241
u8 page
0xFF: missing glyph
Definition text.h:238
u8 unusedA
h, or 10 for the 9-high glyphs; nothing reads it
Definition text.h:248
u8 u
Definition text.h:239
u8 h
Definition text.h:244
s8 dx
Definition text.h:245
u8 advance
Definition text.h:247
u8 w
Definition text.h:243
u8 v
Definition text.h:240
u8 clutY
Definition text.h:242
A drawing layer (GFX.funcs.createLayer): a DRAWENV with a pair of ordering tables,...
Definition gfx.h:128
The frame of a message box: two halves of the bottom panel that grow from the sides (substate 0),...
Definition text.h:46
s32 fadeRow
Definition text.h:50
s32 arrowFrame
Definition text.h:53
s32 arrowTime
Definition text.h:52
s32 layerId
Definition text.h:48
s16 scaleStep
Definition text.h:55
s32 showArrow
Definition text.h:51
The children of a message box (createMessageBox)
Definition text.h:264
struct TextWindow * window
Definition text.h:265
struct MessageBoxFrame * frame
Definition text.h:266
The children of a TalkBox.
Definition text.h:59
struct TextWindow * windows[2]
speaker, message
Definition text.h:61
struct TalkBoxFrame * frame
Definition text.h:62
struct ZoomBox * zoomBoxes[3]
Definition text.h:60
Draws a TalkBox's panel.
Definition text.h:84
TalkBox * parent
Definition text.h:86
u8 showArrow
Definition text.h:89
s32 arrowTime
Definition text.h:88
s32 arrowFrame
Definition text.h:87
Where the parts of a TalkBox go, for each of its four types.
Definition text.h:192
s16 textX
Definition text.h:200
DVECTOR sprite0Pos
also the ZoomBox's offset
Definition text.h:195
s16 nameY
Definition text.h:199
DVECTOR sprite2Pos
its y only for types 2 and 3
Definition text.h:197
DVECTOR arrow
where the talk box arrow is drawn
Definition text.h:202
s16 nameX
Definition text.h:198
s16 textY
Definition text.h:201
DVECTOR panel
Definition text.h:196
DVECTOR spritePos
the four positions drawTalkBoxFrame walks
Definition text.h:194
s32 sprite
Definition text.h:193
A box with a speaker's name and a message (createTalkBox).
Definition text.h:70
s16 x
Definition text.h:76
s16 h
Definition text.h:79
void * strings
Definition text.h:72
s32 timer
Definition text.h:75
s32 type
Definition text.h:74
s32 layerId
Definition text.h:73
void(* setPos)(struct TalkBox *box, s32 x, s32 y)
Definition text.h:80
s16 y
Definition text.h:77
s16 w
Definition text.h:78
Any task, seen through its header.
Definition task.h:62
s16 len
Definition text.h:102
s16 cap
Definition text.h:101
s16 sjis
two bytes per character; else font codes
Definition text.h:104
s16 pos
Definition text.h:103
u8 * data
Definition text.h:100
Drawing state shared with the control-code handlers.
Definition text.h:252
PrimPtr prim
Definition text.h:253
Layer * layer
Definition text.h:254
s16 code
from Font.decode
Definition text.h:258
Glyph * glyph
Definition text.h:256
s32 pageStart
Definition text.h:257
s16 kind
Definition text.h:259
u_long * ot
Definition text.h:255
s16 lineCount
Definition text.h:260
GlyphMap * sjisMap
Definition text.h:230
u8 blend
0xFF: opaque
Definition text.h:226
s16 glyphCount
Definition text.h:232
GlyphMap * iconMap
Definition text.h:231
struct Glyph * icons
Definition text.h:229
struct Glyph * glyphs
Definition text.h:228
s8 lineHeight
Definition text.h:227
s16 iconCount
Definition text.h:233
Text helpers (initTextTools)
Definition text.h:93
void(* convert)()
(dst, src, mode): font codes <-> Shift-JIS
Definition text.h:96
s32(* measure)()
(TextBuffer *, style, spacing)
Definition text.h:95
A text window (createTextWindow): up to six text buffers (0 is shown, 1-5 are "work" buffers that con...
Definition text.h:131
s16 x
Definition text.h:143
VECTOR scale
ScaleMatrix's.
Definition text.h:159
SVECTOR rot
Definition text.h:162
s16 texY
Definition text.h:142
s16 y
Definition text.h:144
void(* setStyle)()
Definition text.h:171
void(* setScale)()
Definition text.h:181
s32 typeSound
Definition text.h:157
s32 pivotY
Definition text.h:161
s32(* isWaitingForButton)()
Definition text.h:188
s8 blend
-1 (TextStyle.blend 0xFF): opaque
Definition text.h:150
s16 cursorX
Definition text.h:147
u8 unusedC4
only setUnusedC4 writes it, and nothing calls that
Definition text.h:156
void(* setPalette)(struct TextWindow *obj, u8 arg)
Definition text.h:174
TextBuffer text[6]
Definition text.h:136
s16 typeDelay
Definition text.h:140
s32(* isFinished)()
s32: callers don't truncate the result to a byte
Definition text.h:186
s32(* isVisible)()
s32: callers don't truncate the result to a byte
Definition text.h:187
void(* setPivot)()
Definition text.h:182
void(* insertPlayerName)()
Definition text.h:179
void(* setTypeSound)()
Definition text.h:180
void(* setDepth)()
Definition text.h:183
void(* setSpacing)()
no prototype: callers would truncate s16 args
Definition text.h:176
void(* setRightAlign)()
no prototype: callers would truncate u8 args
Definition text.h:178
void(* setTypeDelay)()
Definition text.h:172
void(* setLines)()
no prototype: callers would truncate u8 args
Definition text.h:184
s32 depth
Definition text.h:135
MATRIX mat
Definition text.h:163
u16 cursorY
Definition text.h:148
void(* setSubString)()
Definition text.h:168
void(* setNumber)()
Definition text.h:166
void(* setBlend)()
no prototype: callers would truncate u8 args
Definition text.h:175
void(* draw)()
Definition text.h:169
u16 visibleEnd
Definition text.h:137
s32 layerId
Definition text.h:134
s16 start
Definition text.h:138
void(* setPos)(struct TextWindow *obj, s16 x, s16 y)
Definition text.h:173
void(* setText)()
Definition text.h:164
u8 lines
Definition text.h:151
void(* setString)()
Definition text.h:165
s16 spacingX
Definition text.h:145
s32 scaled
Definition text.h:158
void(* showPage)()
Definition text.h:170
void(* setUnusedC4)()
no prototype: callers would truncate u8 args
Definition text.h:185
struct TextStyle * style
Definition text.h:133
s16 spacingY
Definition text.h:146
void(* setSubText)()
Definition text.h:167
s16 texX
Definition text.h:141
void(* setVisible)(struct TextWindow *obj, u8 arg)
Definition text.h:177
s16 typeTimer
Definition text.h:139
u8 visible
Definition text.h:153
u8 fixedSpacing
Definition text.h:154
u8 palette
PALETTE_*.
Definition text.h:152
s16 alignWidth
Definition text.h:149
u8 finished
Definition text.h:155
s32 pivotX
Definition text.h:160
A blue rectangle outline that zooms in (or out, when closing) around a TalkBox.
Definition text.h:270
s16 offsetY
Definition text.h:283
s16 speed
Definition text.h:278
s16 x
the zoom's centre
Definition text.h:274
s16 top
Definition text.h:273
s32 closing
Definition text.h:288
s32 opened
Definition text.h:289
MATRIX matrix
Definition text.h:287
s32 zoom
0-ONE
Definition text.h:279
s32 layerId
Definition text.h:280
s16 h
Definition text.h:277
s32 unused68
only cleared when the box starts; nothing reads it
Definition text.h:281
s16 y
Definition text.h:275
VECTOR trans
the centre, set but not read
Definition text.h:286
VECTOR scale
Definition text.h:284
s16 w
Definition text.h:276
s16 left
Definition text.h:272
SVECTOR rot
Definition text.h:285
s16 offsetX
Definition text.h:282
GlyphMap FONT_ICON_MAP[]
Definition text_tools.c:244
void textWindowInsertPlayerName(TextWindow *obj)
Text window method: fills the work buffers that control code 8 asks for with the player's name.
void updateZoomBox(struct ZoomBox *task)
The zoom box task: starts zoomed out (opening) or in (closing), then draws.
Definition talk_box.c:196
s32 textCodeIgnore(void)
Control code 4: skipped.
Font FONT
decode is declared without a prototype, as callers would truncate the u8 mode, so decodeChar is cast ...
Definition font.c:78
void textWindowSetRightAlign(TextWindow *obj, s32 type)
old-style: u8 type
char * getString(s32 *table, s32 index)
String index of a string table (a count, then byte offsets from its start), or NULL.
Definition text_tools.c:15
void textWindowSetPalette(TextWindow *obj, u8 palette)
Text window method: the CLUT row of the glyphs.
GlyphMap FONT_GLYPH_MAP[]
The font's Shift-JIS codes of its glyphs and icons, up to 0xFFFF.
Definition text_tools.c:202
void drawTalkBoxFrame(struct TalkBoxFrame *task)
Draws a talk box's corner sprites and its semi-transparent panel.
Definition talk_box.c:35
s32 textWindowIsVisible(TextWindow *obj)
Text window method: whether the window is shown.
void textWindowSetLines(TextWindow *obj, s32 lines)
old-style: u8 lines
void updateMessageBox(Task *task, struct MessageBox *data)
The message box task: shows the text once the frame is open, closes when the text ends.
Definition message_box.c:96
void updateTalkBoxFrame(TalkBoxFrame *task)
The talk box frame task: idle until the box opens, then draws the frame and the arrow.
Definition talk_box.c:111
Glyph FONT_ICONS_3[]
Definition text_tools.c:911
TextWindow * createTextWindow(s16 id, s16 type, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)
ZoomBox * createZoomBox(s32 layerId, s16 x, s16 y, s32 w, s32 h, s32 type)
A zoom box around a talk box of type type at (x, y)
Definition talk_box.c:221
void textWindowSetText(TextWindow *obj, const char *text)
Text window method: shows a string.
Definition text_window.c:68
void textWindowSetNumber(TextWindow *obj, u32 index, s32 value)
Text window method: puts a number into text buffer index, in the font's digit glyphs.
void loadFont(void)
Loads the font's images into VRAM and starts loading the menu sprites.
Definition font.c:4
void cursorSetVisible(Cursor *task, s32 visible)
Cursor method: shows it (from its first frame) or hides it.
Definition cursor.c:4
void setTextBuffer(struct TextWindow *obj, struct TextBuffer *buf, const char *text)
Copies a string into one of a window's text buffers, growing it as needed (NULL shows STR_NULL_MESSAG...
Definition text_window.c:24
void textWindowSetDepth(TextWindow *obj, s32 depth)
Text window method: the OT depth the glyphs are drawn at.
void formatNumber(u8 *buf, s32 value)
Writes a number's decimal digits (0 for zero or less)
Definition text_window.c:78
s32 measureText(TextBuffer *text, TextStyle *style, s32 spacing)
old-style: s16 spacing
s16 decodeChar(u8 *s, u8 mode, TextStyle *font)
The next character as kind << 8 | value (see Font); mode set for Shift-JIS text.
Definition font.c:16
MessageBoxFrame * createMessageBoxFrame(s32 layerId)
A message box frame on a layer, with the menu sound.
Definition message_box.c:87
void cursorSetPos(Cursor *task, s32 x, s32 y)
Cursor method: moves it.
Definition cursor.c:14
s32 textCodePause(TextWindow *obj, TextBuffer *buf)
Control code 6: pauses the typing for some frames, once.
Cursor * createCursor(s16 layerId, s32 depth, s16 x, s16 y)
A menu cursor on a layer at (x, y)
Definition cursor.c:92
void textWindowSetPos(TextWindow *obj, s16 x, s16 y)
Text window method: moves the window.
void textWindowSetSpacing(TextWindow *obj, s32 x, s32 y)
old-style: s16 x, y
const char STR_NULL_MESSAGE[]
"Null message was passed"
Definition text_window.c:5
s32 textCodePlayerName(TextWindow *obj, TextBuffer *buf)
Control code 8: puts the player's name into a work buffer, once.
void initTextTools(TextTools *obj)
Clears a text tools object, gives it its methods and binds it.
Definition text_tools.c:193
TalkBoxLayout TALK_BOX_LAYOUTS[]
Definition talk_box.c:422
void updateCursor(Cursor *task, TextWindow **win)
The cursor task: creates its text window, then swings it every idleDelay vsyncs.
Definition cursor.c:42
void updateTalkBox(TalkBox *task, TalkBoxChildren *children)
The talk box task: opens with its outlines, runs the text, then closes and ends.
Definition talk_box.c:285
void textWindowSetTypeDelay(TextWindow *, s32)
Text window method: types the text out a character every delay frames (0 or less: all at once)
s32 textCodeDefault(TextWindow *obj, TextBuffer *buf)
Control codes 0, 7 and 9: show the page, or (code 7) start the text after a speaker's name.
TalkBoxFrame * createTalkBoxFrame(TalkBox *parent)
The frame of a talk box.
Definition talk_box.c:128
void bindTextTools(TextTools *obj)
Makes obj the text tools the methods work on.
Definition text_tools.c:10
void cursorSetFrameDelay(Cursor *task, s32 delay)
Cursor method: the vsyncs of each frame of a swing.
Definition cursor.c:32
void textWindowDraw(struct TextWindow *obj)
Text window method: draws the visible part of the text as sprites, running the control codes.
void textWindowSetBlend(TextWindow *obj, s32 blend)
old-style: u8 blend
const char STR_BAD_DIGIT_BUFFER[]
"Digit: the message's work number is not supported"
Definition text_window.c:8
void textWindowSetSubString(struct TextWindow *obj, char *text, s32 id, s32 index)
Text window method: puts string id of a table (-1: text itself) into text buffer index
Glyph FONT_GLYPHS_2[]
Definition text_tools.c:512
Task * createMessageBox(s32 layerId, void *strings, s32 index)
A message box with string index of a table, typed out in three-line pages.
s32(* TEXT_CODE_HANDLERS[])()
(obj, text, wait): most handlers take only the first two
s32 textCodeInsert(TextWindow *obj, TextBuffer *buf, TextDraw *draw)
Control code 5: draws the next character of a work buffer in its place.
void textWindowSetVisible(TextWindow *obj, u8 visible)
Text window method: shows or hides the window (an empty text stays hidden)
void cursorSetPalette(Cursor *task, s32 palette)
Cursor method: the CLUT row of its glyph.
Definition cursor.c:21
void textWindowSetString(TextWindow *obj, char *text, s32 id)
Text window method: shows string id of a string table (-1: text itself)
Definition text_window.c:73
void textWindowSetTypeSound(TextWindow *obj, s32 sound)
Text window method: the sound each typed character plays (0 for none)
void textWindowSetUnusedC4(TextWindow *obj, s32 value)
old-style: u8 value
void cursorSetStill(Cursor *task, s32 still)
Cursor method: keeps it on its first frame.
Definition cursor.c:37
void drawTalkBoxArrow(struct TalkBoxFrame *task)
Draws a talk box's blinking "next" arrow where its type puts it.
Definition talk_box.c:4
void drawMessageBoxFrame(struct MessageBoxFrame *task)
Draws the two halves of a message box's panel, growing, still or fading.
Definition message_box.c:4
void textWindowSetSubText(TextWindow *obj, const char *text, s32 index)
Text window method: puts a string into work buffer index (1-5), for control code 5.
void talkBoxSetPos(TalkBox *task, s32 x, s32 y)
Talk box method: moves the box with its outlines and windows.
Definition talk_box.c:241
TalkBox * createTalkBox(s32 id, s16 x, s16 y, void *strings, s32 index, u32 type)
A talk box with string index of a table (an optional speaker's name between 02 07 codes),...
Definition talk_box.c:359
Glyph FONT_GLYPHS_3[]
Definition text_tools.c:752
char * CURSOR_FRAMES[]
The cursor's frames, the last one repeated as it swings back.
Definition cursor.c:119
Glyph FONT_ICONS_1[]
Definition text_tools.c:431
void convertText(void *buf, void *text, s32 mode)
Converts the string text to buf: mode 0 from font codes to Shift-JIS (a code below 4 is followed by a...
Definition text_tools.c:134
s32 textCodeWaitButton(TextWindow *obj, TextBuffer *buf)
Control code 2: waits for one of TEXT_WAIT_BUTTONS.
void cursorSetIdleDelay(Cursor *task, s32 delay)
Cursor method: the vsyncs it rests between two swings.
Definition cursor.c:27
s32 TEXT_WAIT_BUTTONS[]
The buttons a wait for a button (code 2) can wait for.
void drawMessageBoxArrow(struct MessageBoxFrame *task)
Draws a message box's blinking "next" arrow.
Definition message_box.c:29
s32 textCodeNewLine(TextWindow *obj, TextBuffer *buf, TextDraw *draw)
Control code 1: a new line, or a new page when the page is full.
void textWindowSetScale(TextWindow *obj, s32 x, s32 y)
Text window method: scales the glyphs.
void updateTextWindow(TextWindow *obj)
The text window task: types and draws the text, waits where the control codes say,...
s32 textWindowIsWaitingForButton(TextWindow *obj)
Text window method: whether the text waits for a button (control code 2)
void drawZoomBox(ZoomBox *task)
Zooms the outline one frame in or out and draws it as four lines; ends when done.
Definition talk_box.c:143
const char STR_MESSAGE_NOT_SET[]
"The message is not set"
Definition text_window.c:17
void textWindowSetStyle(TextWindow *obj, s32 style)
Text window method: one of the three font styles (others pick style 1)
Glyph FONT_ICONS_2[]
Definition text_tools.c:671
const char STR_BAD_EXT_BUFFER[]
"ExtMess: the message's work number is not supported"
Definition text_window.c:12
void textWindowSetPivot(TextWindow *obj, s32 x, s32 y)
Text window method: the point the glyphs scale around.
s32 processTextChar(TextWindow *obj, TextBuffer *text, TextDraw *draw, s16 *pos)
Picks the glyph of the next character, or runs its control code; returns what the drawing does next.
Glyph FONT_GLYPHS_1[]
the three font sizes' glyphs and icons (text_tools.c)
Definition text_tools.c:272
s32 textWindowIsFinished(TextWindow *obj)
Text window method: whether the end of the text was reached.
void updateMessageBoxFrame(struct MessageBoxFrame *task)
The message box frame task: grows, waits with the arrow when asked, then fades out and ends.
Definition message_box.c:46
s32 textCodePageBreak(TextWindow *obj, TextBuffer *buf)
Control code 3: starts a new page.
void textWindowShowPage(TextWindow *obj)
Text window method: makes the whole current page visible at once.
The next free primitive of the packet buffer (getPrim), written as the kind that is drawn next.
Definition gfx.h:344