112#define PALETTE_WHITE 0
113#define PALETTE_BLUE 1
114#define PALETTE_DARK_BLUE 2
115#define PALETTE_YELLOW 3
116#define PALETTE_GREEN 4
118#define PALETTE_PURPLE 6
119#define PALETTE_GREY 7
The task system and its registry (task/)
#define TASK_HEADER(Type)
Display, drawing layers, the drawing helpers and the screen fade (gfx/)
A menu cursor: a text window showing one of the CURSOR_FRAMES glyphs.
void(* setPos)()
(cursor, x, y)
void(* setVisible)()
(cursor, visible)
s32 palette
PALETTE_*, its text window's.
The font (FONT): three text styles, the length of each control code, and decode(),...
struct TextStyle * styles
[4], style 0 unused
s16(* decode)()
(text, sjis, style)
Maps a Shift-JIS character to a glyph.
u8 pad
never read: the maps' entries are 4 bytes, for the u16
One glyph of a font sheet.
u8 page
0xFF: missing glyph
u8 unusedA
h, or 10 for the 9-high glyphs; nothing reads it
A drawing layer (GFX.funcs.createLayer): a DRAWENV with a pair of ordering tables,...
The frame of a message box: two halves of the bottom panel that grow from the sides (substate 0),...
The children of a message box (createMessageBox)
struct TextWindow * window
struct MessageBoxFrame * frame
The children of a TalkBox.
struct TextWindow * windows[2]
speaker, message
struct TalkBoxFrame * frame
struct ZoomBox * zoomBoxes[3]
Where the parts of a TalkBox go, for each of its four types.
DVECTOR sprite0Pos
also the ZoomBox's offset
DVECTOR sprite2Pos
its y only for types 2 and 3
DVECTOR arrow
where the talk box arrow is drawn
DVECTOR spritePos
the four positions drawTalkBoxFrame walks
A box with a speaker's name and a message (createTalkBox).
void(* setPos)(struct TalkBox *box, s32 x, s32 y)
Any task, seen through its header.
s16 sjis
two bytes per character; else font codes
Drawing state shared with the control-code handlers.
Text helpers (initTextTools)
void(* convert)()
(dst, src, mode): font codes <-> Shift-JIS
s32(* measure)()
(TextBuffer *, style, spacing)
A text window (createTextWindow): up to six text buffers (0 is shown, 1-5 are "work" buffers that con...
VECTOR scale
ScaleMatrix's.
s32(* isWaitingForButton)()
s8 blend
-1 (TextStyle.blend 0xFF): opaque
u8 unusedC4
only setUnusedC4 writes it, and nothing calls that
void(* setPalette)(struct TextWindow *obj, u8 arg)
s32(* isFinished)()
s32: callers don't truncate the result to a byte
s32(* isVisible)()
s32: callers don't truncate the result to a byte
void(* insertPlayerName)()
void(* setSpacing)()
no prototype: callers would truncate s16 args
void(* setRightAlign)()
no prototype: callers would truncate u8 args
void(* setLines)()
no prototype: callers would truncate u8 args
void(* setBlend)()
no prototype: callers would truncate u8 args
void(* setPos)(struct TextWindow *obj, s16 x, s16 y)
void(* setUnusedC4)()
no prototype: callers would truncate u8 args
void(* setVisible)(struct TextWindow *obj, u8 arg)
A blue rectangle outline that zooms in (or out, when closing) around a TalkBox.
s32 unused68
only cleared when the box starts; nothing reads it
VECTOR trans
the centre, set but not read
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.
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 ...
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.
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.
void drawTalkBoxFrame(struct TalkBoxFrame *task)
Draws a talk box's corner sprites and its semi-transparent panel.
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.
void updateTalkBoxFrame(TalkBoxFrame *task)
The talk box frame task: idle until the box opens, then draws the frame and the arrow.
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)
void textWindowSetText(TextWindow *obj, const char *text)
Text window method: shows a string.
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.
void cursorSetVisible(Cursor *task, s32 visible)
Cursor method: shows it (from its first frame) or hides it.
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...
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)
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.
MessageBoxFrame * createMessageBoxFrame(s32 layerId)
A message box frame on a layer, with the menu sound.
void cursorSetPos(Cursor *task, s32 x, s32 y)
Cursor method: moves it.
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)
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"
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.
TalkBoxLayout TALK_BOX_LAYOUTS[]
void updateCursor(Cursor *task, TextWindow **win)
The cursor task: creates its text window, then swings it every idleDelay vsyncs.
void updateTalkBox(TalkBox *task, TalkBoxChildren *children)
The talk box task: opens with its outlines, runs the text, then closes and ends.
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.
void bindTextTools(TextTools *obj)
Makes obj the text tools the methods work on.
void cursorSetFrameDelay(Cursor *task, s32 delay)
Cursor method: the vsyncs of each frame of a swing.
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"
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
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.
void textWindowSetString(TextWindow *obj, char *text, s32 id)
Text window method: shows string id of a string table (-1: text itself)
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.
void drawTalkBoxArrow(struct TalkBoxFrame *task)
Draws a talk box's blinking "next" arrow where its type puts it.
void drawMessageBoxFrame(struct MessageBoxFrame *task)
Draws the two halves of a message box's panel, growing, still or fading.
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.
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),...
char * CURSOR_FRAMES[]
The cursor's frames, the last one repeated as it swings back.
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...
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.
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.
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.
const char STR_MESSAGE_NOT_SET[]
"The message is not set"
void textWindowSetStyle(TextWindow *obj, s32 style)
Text window method: one of the three font styles (others pick style 1)
const char STR_BAD_EXT_BUFFER[]
"ExtMess: the message's work number is not supported"
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)
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.
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.