Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
font.c
Go to the documentation of this file.
1#include "engine/game.h"
2
3/* Loads the font's images into VRAM and starts loading the menu sprites */
13
14
15/* The next character as kind << 8 | value (see Font); `mode` set for Shift-JIS text */
16s16 decodeChar(u8 *s, u8 mode, TextStyle *font) {
17 u16 code;
18 GlyphMap *map;
19 s32 i;
20
21 if (s[0] == 0) {
22 return 0x400;
23 }
24 if (mode != 0) {
25 if (s[0] < 4) {
26 return (s[0] << 8) | s[1];
27 }
28 if (s[0] == 0xA) {
29 return 0x201;
30 }
31 code = s[0] << 8;
32 code |= s[1];
33 if ((u16)(code - 0x824F) < 0x146) {
34 map = font->sjisMap;
35 for (i = 4; map[i].code != 0xFFFF; i++) {
36 if (code == map[i].code) {
37 return map[i].index;
38 }
39 }
40 } else {
41 map = font->iconMap;
42 for (i = 0; map[i].code != 0xFFFF; i++) {
43 if (code == map[i].code) {
44 return map[i].index | 0x100;
45 }
46 }
47 }
48 } else {
49 if (s[0] == 1) {
50 if (s[1] > font->iconCount) {
51 return (((u16)font->iconCount + 1) & 0xFF) | 0x100;
52 }
53 return (s[0] << 8) | s[1];
54 }
55 if (s[0] < 4) {
56 return (s[0] << 8) | s[1];
57 }
58 if (s[0] < font->glyphCount) {
59 return s[0];
60 }
61 }
62 return 0x300;
63}
64
65/* Style 0 is unused; the others have lines of 14, 11 and 9 pixels */
67 { 0xFF, 0, 0, 0, NULL, NULL, 0, 0 },
68 { 0xFF, 14, FONT_GLYPHS_1, FONT_ICONS_1, FONT_GLYPH_MAP, FONT_ICON_MAP, 234, 114 },
69 { 0xFF, 11, FONT_GLYPHS_2, FONT_ICONS_2, FONT_GLYPH_MAP, FONT_ICON_MAP, 234, 114 },
71};
72
73/* The length of each control code, with its arguments */
74s32 FONT_CODE_LENGTHS[11] = { 1, 2, 3, 2, 5, 3, 3, 2, 3, 2, 0 };
75
76/* decode is declared without a prototype, as callers would truncate the
77 u8 mode, so decodeChar is cast to it */
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
signed short s16
Definition common.h:9
unsigned short u16
Definition common.h:10
unsigned char u8
Definition common.h:8
#define FILE_FONT
Definition file.h:189
#define FILE_MENU_SPRITES
Files the engine loads by number.
Definition file.h:188
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
Font FONT
decode is declared without a prototype, as callers would truncate the u8 mode, so decodeChar is cast ...
Definition font.c:78
s32 FONT_CODE_LENGTHS[11]
The length of each control code, with its arguments.
Definition font.c:74
void loadFont(void)
Loads the font's images into VRAM and starts loading the menu sprites.
Definition font.c:4
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
TextStyle FONT_STYLES[4]
Style 0 is unused; the others have lines of 14, 11 and 9 pixels.
Definition font.c:66
void(* free)(s32 file)
Definition file.h:93
void(* request)(s32 file)
Definition file.h:90
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
The font (FONT): three text styles, the length of each control code, and decode(),...
Definition text.h:211
Maps a Shift-JIS character to a glyph.
Definition text.h:219
u8 index
Definition text.h:221
u16 code
Definition text.h:220
GlyphMap * sjisMap
Definition text.h:230
s16 glyphCount
Definition text.h:232
GlyphMap * iconMap
Definition text.h:231
s16 iconCount
Definition text.h:233
Uploads TIM images to VRAM (initTimLoader); acts on TIM_LOADER.
Definition gfx.h:325
void(* setImagePos)()
(x, y)
Definition gfx.h:336
void(* loadArchive)()
(archive): each image 64 halfwords to the right
Definition gfx.h:338
GlyphMap FONT_ICON_MAP[]
Definition text_tools.c:244
GlyphMap FONT_GLYPH_MAP[]
The font's Shift-JIS codes of its glyphs and icons, up to 0xFFFF.
Definition text_tools.c:202
Glyph FONT_ICONS_2[114]
Definition text_tools.c:671
Glyph FONT_GLYPHS_3[230]
Definition text_tools.c:752
Glyph FONT_ICONS_1[114]
Definition text_tools.c:431
Glyph FONT_GLYPHS_2[230]
Definition text_tools.c:512
Glyph FONT_ICONS_3[114]
Definition text_tools.c:911
Glyph FONT_GLYPHS_1[230]
The font's three sheets (FONT_STYLES), each with its glyphs and its icons.
Definition text_tools.c:272
void initTimLoader(TimLoader *obj)
Clears a TIM loader, gives it its methods and binds it.
Definition tim_loader.c:119