Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
text_tools.c File Reference
#include "engine/game.h"
#include <libgs.h>
#include <libetc.h>
#include <libsnd.h>
Include dependency graph for text_tools.c:

Go to the source code of this file.

Macros

#define SWAP16(x)   ((((x) & 0xFF00) >> 8) | (((x) & 0xFF) << 8))
 Swaps the bytes of a Shift-JIS code: the text has them big-endian.
 

Functions

void bindTextTools (TextTools *obj)
 Makes obj the text tools the methods work on.
 
char * getString (s32 *table, s32 index)
 String index of a string table (a count, then byte offsets from its start), or NULL.
 
s32 measureText (TextBuffer *text, TextStyle *style, s16 spacing)
 The width in pixels of the text's widest line in a style, with a fixed spacing per character unless spacing is 0.
 
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 an icon's), mode 1 back.
 
void initTextTools (TextTools *obj)
 Clears a text tools object, gives it its methods and binds it.
 

Variables

static TextTools * TEXT_TOOLS
 Small variables, addressed through $gp (see the Makefile)
 
GlyphMap FONT_GLYPH_MAP []
 The font's Shift-JIS codes of its glyphs and icons, up to 0xFFFF.
 
GlyphMap FONT_ICON_MAP []
 
Glyph FONT_UNUSED_GLYPH_0 = { 0xFF }
 Two empty glyphs that nothing reads.
 
Glyph FONT_UNUSED_GLYPH_1 = { 0xFF }
 
Glyph FONT_GLYPHS_1 [230]
 The font's three sheets (FONT_STYLES), each with its glyphs and its icons.
 
Glyph FONT_ICONS_1 [114]
 
Glyph FONT_GLYPHS_2 [230]
 
Glyph FONT_ICONS_2 [114]
 
Glyph FONT_GLYPHS_3 [230]
 
Glyph FONT_ICONS_3 [114]
 

Macro Definition Documentation

◆ SWAP16

#define SWAP16 (   x)    ((((x) & 0xFF00) >> 8) | (((x) & 0xFF) << 8))

Swaps the bytes of a Shift-JIS code: the text has them big-endian.

Definition at line 127 of file text_tools.c.

Function Documentation

◆ bindTextTools()

void bindTextTools ( TextTools *  obj)

Makes obj the text tools the methods work on.

Definition at line 10 of file text_tools.c.

Referenced by initTextTools().

Here is the caller graph for this function:

◆ getString()

char * getString ( s32 *  table,
s32  index 
)

String index of a string table (a count, then byte offsets from its start), or NULL.

Definition at line 15 of file text_tools.c.

Referenced by initTextTools().

Here is the caller graph for this function:

◆ measureText()

s32 measureText ( TextBuffer *  text,
TextStyle *  style,
s16  spacing 
)

The width in pixels of the text's widest line in a style, with a fixed spacing per character unless spacing is 0.

An old-style definition, as its unprototyped declaration and TextTools.measure suit: callers pass an int, which it takes as a short (converted once, on entry).

Definition at line 30 of file text_tools.c.

Referenced by initTextTools(), and measureText().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ convertText()

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 an icon's), mode 1 back.

Not terminated. The Shift-JIS side is a byte buffer written and read a halfword at a time.

Definition at line 134 of file text_tools.c.

Referenced by initTextTools().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initTextTools()

void initTextTools ( TextTools *  obj)

Clears a text tools object, gives it its methods and binds it.

Definition at line 193 of file text_tools.c.

Referenced by CARDGAME_drawCenteredText(), createTalkBox(), getName(), initNewGameData(), setName(), showMessageText(), STGMCARD_loadFiles(), textWindowSetRightAlign(), and textWindowSetSubString().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ TEXT_TOOLS

TextTools* TEXT_TOOLS
static

Small variables, addressed through $gp (see the Makefile)

Definition at line 7 of file text_tools.c.

Referenced by bindTextTools().

◆ FONT_GLYPH_MAP

GlyphMap FONT_GLYPH_MAP[]

The font's Shift-JIS codes of its glyphs and icons, up to 0xFFFF.

Definition at line 202 of file text_tools.c.

Referenced by convertText().

◆ FONT_ICON_MAP

GlyphMap FONT_ICON_MAP[]
Initial value:
= {
{ 0x0000, 0 }, { 0x8140, 1 }, { 0x8141, 2 }, { 0x8142, 3 }, { 0x8143, 4 }, { 0x8144, 5 },
{ 0x8145, 6 }, { 0x8146, 7 }, { 0x8147, 8 }, { 0x8148, 9 }, { 0x8149, 10 }, { 0x814F, 11 },
{ 0x8151, 12 }, { 0x815B, 13 }, { 0x815C, 14 }, { 0x815E, 15 }, { 0x815F, 16 }, { 0x8160, 17 },
{ 0x8163, 18 }, { 0x8166, 19 }, { 0x8168, 20 }, { 0x8169, 21 }, { 0x816A, 22 }, { 0x8175, 23 },
{ 0x8176, 24 }, { 0x817B, 25 }, { 0x817C, 26 }, { 0x817E, 27 }, { 0x8181, 28 }, { 0x8183, 29 },
{ 0x8184, 30 }, { 0x8185, 31 }, { 0x8186, 32 }, { 0x8187, 33 }, { 0x8188, 34 }, { 0x8189, 35 },
{ 0x818A, 36 }, { 0x818E, 37 }, { 0x818F, 38 }, { 0x8190, 39 }, { 0x8191, 40 }, { 0x8192, 41 },
{ 0x8193, 42 }, { 0x8195, 43 }, { 0x8198, 44 }, { 0x8199, 45 }, { 0x819A, 46 }, { 0x819B, 47 },
{ 0x819C, 48 }, { 0x819F, 49 }, { 0x81A0, 50 }, { 0x81A1, 51 }, { 0x81A2, 52 }, { 0x81A3, 53 },
{ 0x81A5, 54 }, { 0x81A8, 55 }, { 0x81A9, 56 }, { 0x81AA, 57 }, { 0x81AB, 58 }, { 0x889F, 59 },
{ 0x88A0, 60 }, { 0x88A1, 61 }, { 0x88A2, 62 }, { 0x88A3, 63 }, { 0x88A4, 64 }, { 0x88A5, 65 },
{ 0x88A6, 66 }, { 0x88A7, 67 }, { 0x88A8, 68 }, { 0x88A9, 69 }, { 0x88AA, 70 }, { 0x88AB, 71 },
{ 0x88AC, 72 }, { 0x88AD, 73 }, { 0x88AE, 74 }, { 0x88AF, 75 }, { 0x88B0, 76 }, { 0x88B1, 77 },
{ 0x88B2, 78 }, { 0x88B3, 79 }, { 0x88B4, 80 }, { 0x88B5, 81 }, { 0x88B6, 82 }, { 0x88B7, 83 },
{ 0x88B8, 84 }, { 0x88B9, 85 }, { 0x88BA, 86 }, { 0x88BB, 87 }, { 0x88BC, 88 }, { 0x88BD, 89 },
{ 0x88BE, 90 }, { 0x88BF, 91 }, { 0x88C0, 92 }, { 0x88C1, 93 }, { 0x88C2, 94 }, { 0x88C3, 95 },
{ 0x88C4, 96 }, { 0x88C5, 97 }, { 0x88C6, 98 }, { 0x88C7, 99 }, { 0x88C8, 100 }, { 0x88C9, 101 },
{ 0x88CA, 102 }, { 0x88CB, 103 }, { 0x88CC, 104 }, { 0x88CD, 105 }, { 0x88CE, 106 }, { 0x88CF, 107 },
{ 0x88D0, 108 }, { 0x88D1, 109 }, { 0x88D2, 110 }, { 0x88D3, 111 }, { 0x88D4, 112 }, { 0x88D5, 113 },
{ 0x88D6, 114 }, { 0xFFFF, 0 },
}

Definition at line 244 of file text_tools.c.

Referenced by convertText().

◆ FONT_UNUSED_GLYPH_0

Glyph FONT_UNUSED_GLYPH_0 = { 0xFF }

Two empty glyphs that nothing reads.

Definition at line 268 of file text_tools.c.

◆ FONT_UNUSED_GLYPH_1

Glyph FONT_UNUSED_GLYPH_1 = { 0xFF }

Definition at line 269 of file text_tools.c.

◆ FONT_GLYPHS_1

Glyph FONT_GLYPHS_1[230]

The font's three sheets (FONT_STYLES), each with its glyphs and its icons.

the three font sizes' glyphs and icons (text_tools.c)

Definition at line 272 of file text_tools.c.

◆ FONT_ICONS_1

Glyph FONT_ICONS_1[114]

Definition at line 431 of file text_tools.c.

◆ FONT_GLYPHS_2

Glyph FONT_GLYPHS_2[230]

Definition at line 512 of file text_tools.c.

◆ FONT_ICONS_2

Glyph FONT_ICONS_2[114]

Definition at line 671 of file text_tools.c.

◆ FONT_GLYPHS_3

Glyph FONT_GLYPHS_3[230]

Definition at line 752 of file text_tools.c.

◆ FONT_ICONS_3

Glyph FONT_ICONS_3[114]

Definition at line 911 of file text_tools.c.