MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / GetFontCode

Function GetFontCode

src/dolphin/src/os/OSFont.c:213–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213static int GetFontCode(u16 code)
214{
215 int preCode;
216 int lastByte;
217
218 if (OSGetFontEncode() == OS_FONT_ENCODE_SJIS)
219 {
220 if (code >= 0x20 && code <= 0xDF)
221 {
222 return HankakuToCode[code - 0x20];
223 }
224
225 if (code > 0x889E && code <= 0x9872)
226 {
227 preCode = ((code >> 8) - 0x88) * 188;
228 lastByte = code & 0xFF;
229
230 if (!IsSjisTrailByte(lastByte))
231 {
232 return 0;
233 }
234
235 lastByte -= 0x40;
236
237 if (lastByte >= 0x40)
238 {
239 lastByte--;
240 }
241
242 return (preCode + lastByte + 0x2BE);
243 }
244
245 if (code >= 0x8140 && code < 0x879E)
246 {
247 preCode = ((code >> 8) - 0x81) * 188;
248 lastByte = code & 0xFF;
249
250 if (!IsSjisTrailByte(lastByte))
251 {
252 return 0;
253 }
254
255 lastByte -= 0x40;
256
257 if (lastByte >= 0x40)
258 {
259 lastByte--;
260 }
261
262 return Zenkaku2Code[preCode + lastByte];
263 }
264 }
265 else if (code > 0x20 && code <= 0xFF)
266 {
267 return code - 0x20;
268 }
269
270 return 0;

Callers 2

OSLoadFontFunction · 0.85
OSGetFontTextureFunction · 0.85

Calls 2

OSGetFontEncodeFunction · 0.85
IsSjisTrailByteFunction · 0.85

Tested by

no test coverage detected