5const char STR_NULL_MESSAGE[] =
"\x82\x6D\x82\x95\x82\x8C\x82\x8C\x83\x81\x83\x62\x83\x5A\x81\x5B"
6 "\x83\x57\x82\xAA\x82\xED\x82\xBD\x82\xB3\x82\xEA\x82\xDC\x82\xB5\x82\xBD";
9 "\x83\x5A\x81\x5B\x83\x57\x82\xCC\x83\x8F\x81\x5B\x83\x4E\x82\xCE"
10 "\x82\xF1\x82\xB2\x82\xA4\x82\xAA\x82\xDD\x82\xBD\x82\xA2\x82\xA8\x82\xA4";
12const char STR_BAD_EXT_BUFFER[] =
"\x82\x64\x82\x98\x82\x94\x82\x6C\x82\x85\x82\x93\x82\x93\x81\x46"
13 "\x83\x81\x83\x62\x83\x5A\x81\x5B\x83\x57\x82\xCC\x83\x8F\x81\x5B"
14 "\x83\x4E\x82\xCE\x82\xF1\x82\xB2\x82\xA4\x82\xAA\x82\xDD\x82\xBD"
15 "\x82\xA2\x82\xA8\x82\xA4";
18 "\x82\xC4\x82\xA2\x82\xB3\x82\xEA\x82\xC4\x82\xA2\x82\xDC\x82\xB9\x82\xF1";
39 if (buf->
cap <= buf->
len) {
50 cap = (size & ~3) + 8;
101 buf[--len] = d +
'0';
115 for (i = 15, p = &buf[i]; i >= 0; i--) {
119 for (i = 0; buf[i] != 0; i++) {
128 if (index < 1 || index > 5) {
178 for (i = 5; i >= 0; i--) {
187 if (obj->
scale.vx == 0 && obj->
scale.vy == 0) {
194 RotMatrixYXZ_gte(&obj->
rot, &obj->
mat);
195 ScaleMatrix(&obj->
mat, &obj->
scale);
209 draw.
kind = (
u32)(c << 16) >> 24;
227 if (obj->
blend == -1) {
236 if (tpage != prevTpage) {
237 SetDrawTPage(draw.
prim.
tpage, 0, 1, prevTpage);
244 if (obj->
blend != -1) {
257 SetDrawTPage(draw.
prim.
tpage, 0, 1, tpage);
264 in[0].vx = in[2].vx = x - obj->
pivotX;
265 in[1].vx = in[3].vx = in[0].vx + draw.
glyph->
w;
266 in[0].vy = in[1].vy = y - obj->
pivotY;
267 in[2].vy = in[3].vy = in[0].vy + draw.
glyph->
h;
268 in[0].vz = in[1].vz = in[2].vz = in[3].vz = 0;
269 for (j = 0; j < 4; j++) {
270 ApplyMatrixSV(&obj->
mat, &in[j], &out);
278 if (obj->
blend != -1) {
279 setSemiTrans(draw.
prim.
ft4, 1);
300 SetDrawTPage(draw.
prim.
tpage, 0, 1, tpage);
318 if (obj->
state == 1) {
345 if (++lines < obj->lines) {
375 }
while (going != 0);
384 if (style < 1 || style > 3) {
438 if (x != 0 || y != 0) {
443 obj->fixedSpacing = 0;
467 obj->alignWidth = cls.
measure(&obj->text[0], obj->style, obj->spacingX);
481 for (pos = 0; pos < obj->
text[0].
len;) {
486 if (text->
sjis != 0) {
496 c = text->
data[pos + 1];
501 index = text->
data[pos + 2];
581 switch (draw->
kind) {
583 if (text->
sjis != 0) {
584 if ((
u8)draw->
code == 1) {
591 c = text->
data[*pos + 1];
600 return ret & ~0x8000;
603 if (text->
sjis != 0) {
612 if (n <= style->iconCount && n > 0) {
625 if (text->
sjis != 0) {
637 switch (buf->
data[buf->
pos + 1]) {
655 if (obj->
lines >= 2) {
673 if (buf->
data[buf->
pos + 2] < 5) {
696 while (buf->
pos < buf->
len) {
706 if (c == 5 || c == 8) {
741 draw->
kind = (
u32)(c << 16) >> 24;
742 if (draw->
kind == 2) {
757 if (buf->
data[buf->
pos + 2] < 0xFF) {
761 buf->
data[buf->
pos + 2] = 0xFF;
784 switch (obj->
state) {
824 for (i = 0; i < 6; i++) {
863 if (style < 1 || style > 3) {
GfxState GFX
GFX: the graphics state and its methods.
GameState GAME
The save data, the game mode and the methods.
Font FONT
decode is declared without a prototype, as callers would truncate the u8 mode, so decodeChar is cast ...
int strlen(const char *)
SDK functions declared here rather than from their PsyQ headers: strings.h and memory....
void * memcpy(void *dst, const void *src, int size)
Heap HEAP
The functions that return what a call left in v0 (allocMemHigh, findTask) and the ones that take othe...
#define MEM_MODE
the current mode's: freed by main whenever the mode task ends
PadState PAD
Controller input: cleared by initPad, then the methods.
SoundState SOUND
rsin and rcos (libgte) read rsin_tbl[a - 0x800] and the like: their addresses before the table fall i...
struct TextStyle * styles
[4], style 0 unused
s16(* decode)()
(text, sjis, style)
char name[0x18]
the player's
struct Layer *(* getLayer)(s32 id)
void(* setPrim)(void *next)
u8 page
0xFF: missing glyph
void *(* alloc)(s32 size, s32 tag)
void(* zero)(void *ptr, s32 size)
u_long *(* getOtEntry)(struct Layer *, s32 depth)
s32(* getButtonBit)(s32 pad, s32 button)
s32(* getPressed)(s32 pad)
short(* playSound)(s32 id)
returns the voice of a key-on
s16 sjis
two bytes per character; else font codes
Drawing state shared with the control-code handlers.
Text helpers (initTextTools)
char *(* getString)()
(table, index)
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.
void(* setState)(struct TextWindow *task, s32 state)
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)
void(* nextState)(struct TextWindow *task)
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
void initTextTools(TextTools *obj)
Clears a text tools object, gives it its methods and binds it.
void textWindowInsertPlayerName(TextWindow *obj)
Text window method: fills the work buffers that control code 8 asks for with the player's name.
s32 textCodeIgnore(void)
Control code 4: skipped.
void textWindowSetUnusedC4(TextWindow *obj, u8 value)
Text window method: sets unusedC4, which nothing reads.
void textWindowSetPalette(TextWindow *obj, u8 palette)
Text window method: the CLUT row of the glyphs.
s32 textWindowIsVisible(TextWindow *obj)
Text window method: whether the window is shown.
void textWindowSetSubString(TextWindow *obj, char *text, s32 id, s32 index)
Text window method: puts string id of a table (-1: text itself) into text buffer index
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 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 textCodePause(TextWindow *obj, TextBuffer *buf)
Control code 6: pauses the typing for some frames, once.
s32(* TEXT_CODE_HANDLERS[11])()
The handlers of the control codes 0x02 <code> (processTextChar)
void textWindowSetPos(TextWindow *obj, s16 x, s16 y)
Text window method: moves the window.
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 textWindowSetLines(TextWindow *obj, u8 lines)
Text window method: the lines of a page.
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.
const char STR_BAD_DIGIT_BUFFER[]
"Digit: the message's work number is not supported"
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 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 textWindowSetBlend(TextWindow *obj, u8 blend)
Text window method: the glyphs' blending.
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.
s32 textCodeWaitButton(TextWindow *obj, TextBuffer *buf)
Control code 2: waits for one of TEXT_WAIT_BUTTONS.
void textWindowSetSpacing(TextWindow *obj, s16 x, s16 y)
Text window method: a fixed advance and line height (0, 0: the style's)
void textWindowDraw(TextWindow *obj)
Text window method: draws the visible part of the text as sprites, running the control codes.
void setTextBuffer(TextWindow *obj, 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 textWindowSetRightAlign(TextWindow *obj, u8 type)
Text window method: aligns the text to its right end, or back to the left.
TextWindow * createTextWindow(s16 layerId, s16 style, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)
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,...
void textWindowSetTypeDelay(TextWindow *obj, s32 delay)
Text window method: types the text out a character every delay frames (0 or less: all at once)
s32 textWindowIsWaitingForButton(TextWindow *obj)
Text window method: whether the text waits for a button (control code 2)
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)
s32 TEXT_WAIT_BUTTONS[5]
The buttons a wait for a button (code 2) can wait for.
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.
s32 textWindowIsFinished(TextWindow *obj)
Text window method: whether the end of the text was reached.
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.