1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
#include "global.h"
#include "font.h"
#include "gf_gfx_loader.h"
#include "graphic/font.naix"
#include "render_text.h"
#include "string16.h"
#include "unk_02021590.h"
#include "text.h"
#include "unk_0201B8B8.h"
struct UnkStruct_02002C14 *UNK_02106FC8;
struct UnkStruct_02002C14 UNK_02106FCC;
const u16 UNK_020ECB54[4][2] = {
{ NARC_font_narc_0000_bin, FALSE },
{ NARC_font_narc_0001_bin, FALSE },
{ NARC_font_narc_0002_bin, FALSE },
{ NARC_font_narc_0003_bin, FALSE }
};
const struct FontInfo gFontInfos[5] = {
{ 0x0B, 0x10, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x02 },
{ 0x0B, 0x10, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x02 },
{ 0x0B, 0x10, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x02 },
{ 0x0B, 0x10, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x02 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
};
THUMB_FUNC void FUN_02002C14()
{
UNK_02106FC8 = &UNK_02106FCC;
for (u32 i = 0; i < 4; i++)
{
UNK_02106FC8->unk84[i] = NULL;
UNK_02106FC8->unk94[i] = NULL;
}
SetFontsPointer(&gFontInfos[0]);
}
THUMB_FUNC void FUN_02002C50(u32 font_id, u32 heap_id)
{
UNK_02106FC8->unk94[font_id] =
FontData_new(NARC_GRAPHIC_FONT, UNK_020ECB54[font_id][0], 1, UNK_020ECB54[font_id][1], heap_id);
}
THUMB_FUNC void FUN_02002C84(s32 param0, u32 param1)
{
GF_ASSERT(param0 < 4);
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
FontData_ModeSwitch(UNK_02106FC8->unk94[param0], 0, param1);
}
THUMB_FUNC void FUN_02002CC0(s32 param0)
{
GF_ASSERT(param0 < 4);
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
FontData_ModeSwitch(UNK_02106FC8->unk94[param0], 1, 0);
}
THUMB_FUNC void FUN_02002CF8(int param0)
{
GF_ASSERT(param0 < 4);
if (UNK_02106FC8->unk84[param0] != NULL)
{
u32 i;
for (i = 0; i < 4; i++)
{
if (i != param0 && UNK_020ECB54[i][0] == UNK_020ECB54[param0][0] &&
UNK_02106FC8->unk94[i] != NULL)
{
UNK_02106FC8->unk84[i] = UNK_02106FC8->unk84[param0];
break;
}
}
if (i == 4)
{
FreeToHeap(UNK_02106FC8->unk84[param0]);
UNK_02106FC8->unk84[param0] = NULL;
}
}
if (UNK_02106FC8->unk94[param0] != NULL)
{
FontData_delete(UNK_02106FC8->unk94[param0]);
UNK_02106FC8->unk94[param0] = NULL;
}
}
THUMB_FUNC struct UnkStruct_02002C14_sub *FUN_02002D94(u32 param0, u32 param1)
{
TryLoadGlyph(UNK_02106FC8->unk94[param0], param1, &UNK_02106FC8->unk00);
return &UNK_02106FC8->unk00;
}
THUMB_FUNC u32 FontFunc(u32 fontId, struct TextPrinter *printer)
{
struct TextPrinterSubStruct *subStruct =
(struct TextPrinterSubStruct *)(&printer->subStructFields);
if (subStruct->hasGlyphIdBeenSet == 0)
{
subStruct->glyphId = fontId;
subStruct->hasGlyphIdBeenSet = 1;
}
return RenderText(printer);
}
THUMB_FUNC u32 FUN_02002DE0(u32 param0, u16 *str, u32 param2)
{
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
return GetStringWidth(UNK_02106FC8->unk94[param0], str, param2);
}
THUMB_FUNC u32 FUN_02002E14(u32 param0, struct String *str, u32 param2)
{
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
return GetStringWidth(UNK_02106FC8->unk94[param0], String_c_str(str), param2);
}
THUMB_FUNC s32 GetFontAttribute(u8 fontId, s32 attr)
{
u8 ret = 0;
switch (attr)
{
case 0:
ret = gFontInfos[fontId].maxLetterWidth;
break;
case 1:
ret = gFontInfos[fontId].maxLetterHeight;
break;
case 2:
ret = gFontInfos[fontId].letterSpacing;
break;
case 3:
ret = gFontInfos[fontId].lineSpacing;
break;
case 4:
ret = gFontInfos[fontId].unk;
break;
case 5:
ret = gFontInfos[fontId].fgColor;
break;
case 6:
ret = gFontInfos[fontId].bgColor;
break;
case 7:
ret = gFontInfos[fontId].shadowColor;
break;
}
return ret;
}
THUMB_FUNC void FUN_02002ED0(enum GFBgLayer layer, u32 baseAddr, u32 heap_id)
{
GfGfxLoader_GXLoadPal(
NARC_GRAPHIC_FONT, NARC_font_narc_0006_NCLR, layer, baseAddr, 0x20, heap_id);
}
THUMB_FUNC void FUN_02002EEC(enum GFBgLayer layer, u32 baseAddr, u32 heap_id)
{
GfGfxLoader_GXLoadPal(
NARC_GRAPHIC_FONT, NARC_font_narc_0007_NCLR, layer, baseAddr, 0x20, heap_id);
}
THUMB_FUNC s32 FUN_02002F08(u32 param0, struct String *str, u32 param2)
{
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
return GetStringWidthMultiline(UNK_02106FC8->unk94[param0], String_c_str(str), param2);
}
THUMB_FUNC u32 FUN_02002F40(u32 param0, struct String *str, u32 param2, u32 param3)
{
u32 r0 = FUN_02002E14(param0, str, param2);
if (r0 < param3)
{
return (param3 - r0) / 2;
}
return 0;
}
THUMB_FUNC u32 FUN_02002F58(const u16 *str)
{
u32 r5 = 1;
while (*str != EOS)
{
if (*str == 0xFFFE)
{
str = MsgArray_SkipControlCode(str);
continue;
}
if (*str == 0xE000)
{
r5++;
str++;
continue;
}
str++;
}
return r5;
}
THUMB_FUNC u32 FUN_02002F90(struct String *str)
{
return FUN_02002F58(String_c_str(str));
}
THUMB_FUNC s32 FUN_02002F9C(u32 param0, struct String *str)
{
GF_ASSERT(UNK_02106FC8->unk94[param0] != NULL);
return StringGetWidth_SingleLine_HandleClearToControlCode(
UNK_02106FC8->unk94[param0], String_c_str(str));
}
|