KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
biosfont.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 dc/biosfont.h
4 Copyright (C) 2000-2001 Megan Potter
5 Japanese Functions Copyright (C) 2002 Kazuaki Matsumoto
6 Copyright (C) 2017 Donald Haase
7 Copyright (C) 2024 Falco Girgis
8 Copyright (C) 2024 Andress Barajas
9
10*/
11
12/** \file dc/biosfont.h
13 \brief BIOS font drawing functions.
14 \ingroup bfont
15
16 This file provides support for utilizing the font built into the Dreamcast's
17 BIOS. These functions allow access to both the western character set and
18 Japanese characters.
19
20 \author Megan Potter
21 \author Kazuaki Matsumoto
22 \author Donald Haase
23 \author Falco Girgis
24
25 \todo
26 - More user-friendly way to fetch/print DC-specific icons.
27*/
28
29#ifndef __DC_BIOSFONT_H
30#define __DC_BIOSFONT_H
31
32#include <kos/cdefs.h>
33__BEGIN_DECLS
34
35#include <stdint.h>
36#include <stdbool.h>
37#include <stdarg.h>
38
39#include <arch/types.h>
40
41/** \defgroup bfont BIOS
42 \brief API for the Dreamcast's built-in BIOS font
43 \ingroup video_fonts
44 @{
45*/
46
47/** \defgroup bfont_size Dimensions
48 \brief Sizes for of the BIOS font's dimensions
49 @{
50*/
51#define BFONT_THIN_WIDTH 12 /**< \brief Width of Thin Font (ISO8859_1, half-JP) */
52#define BFONT_WIDE_WIDTH (BFONT_THIN_WIDTH * 2) /**< \brief Width of Wide Font (full-JP) */
53#define BFONT_HEIGHT 24 /**< \brief Height of All Fonts */
54/** @} */
55
56/** \brief Number of bytes to represent a single character within the BIOS font. */
57#define BFONT_BYTES_PER_CHAR (BFONT_THIN_WIDTH * BFONT_HEIGHT / 8)
58
59/** \defgroup bfont_indicies Structure
60 \brief Structure of the Bios Font
61 @{
62*/
63/** \brief Start of Narrow Characters in Font Block */
64#define BFONT_NARROW_START 0
65#define BFONT_OVERBAR BFONT_NARROW_START
66#define BFONT_ISO_8859_1_33_126 (BFONT_NARROW_START + ( 1 * BFONT_BYTES_PER_CHAR))
67#define BFONT_YEN (BFONT_NARROW_START + (95 * BFONT_BYTES_PER_CHAR))
68#define BFONT_ISO_8859_1_160_255 (BFONT_NARROW_START + (96 * BFONT_BYTES_PER_CHAR))
69
70/* JISX-0208 Rows 1-7 and 16-84 are encoded between BFONT_WIDE_START and BFONT_DREAMCAST_SPECIFIC.
71 Only the box-drawing characters (row 8) are missing. */
72/** \brief Size of a row for JISX-0208 characters */
73#define JISX_0208_ROW_SIZE 94
74/** \brief Start of Wide Characters in Font Block */
75#define BFONT_WIDE_START (288 * BFONT_BYTES_PER_CHAR)
76/** \brief Start of JISX-0208 Rows 1-7 in Font Block */
77#define BFONT_JISX_0208_ROW1 BFONT_WIDE_START
78/** \brief Start of JISX-0208 Row 16-47 (Start of Level 1) in Font Block */
79#define BFONT_JISX_0208_ROW16 (BFONT_WIDE_START + (658 * BFONT_BYTES_PER_CHAR))
80/** \brief JISX-0208 Row 48-84 (Start of Level 2) in Font Block */
81#define BFONT_JISX_0208_ROW48 (BFONT_JISX_0208_ROW16 + ((32 * JISX_0208_ROW_SIZE) * BFONT_BYTES_PER_CHAR))
82
83/** \brief Start of DC Specific Characters in Font Block */
84#define BFONT_DREAMCAST_SPECIFIC (BFONT_WIDE_START + (7056 * BFONT_BYTES_PER_CHAR))
85/** \brief Takes a DC-specific icon index and returns a character offset. */
86#define BFONT_DC_ICON(offset) (BFONT_DREAMCAST_SPECIFIC + ((offset) * BFONT_BYTES_PER_CHAR))
87
88/** \defgroup bfont_dc_indices Dreamcast-Specific
89 \brief Dreamcast-specific BIOS icon offsets.
90 @{
91*/
92#define BFONT_CIRCLECOPYRIGHT BFONT_DC_ICON(0) /**< \brief Circle copyright */
93#define BFONT_CIRCLER BFONT_DC_ICON(1) /**< \brief Circle restricted */
94#define BFONT_TRADEMARK BFONT_DC_ICON(2) /**< \brief Trademark */
95#define BFONT_UPARROW BFONT_DC_ICON(3) /**< \brief Up arrow */
96#define BFONT_DOWNARROW BFONT_DC_ICON(4) /**< \brief Down arrow */
97#define BFONT_LEFTARROW BFONT_DC_ICON(5) /**< \brief Left arrow */
98#define BFONT_RIGHTARROW BFONT_DC_ICON(6) /**< \brief Right arrow */
99#define BFONT_UPRIGHTARROW BFONT_DC_ICON(7) /**< \brief Up right arrow */
100#define BFONT_DOWNRIGHTARROW BFONT_DC_ICON(8) /**< \brief Down right arrow */
101#define BFONT_DOWNLEFTARROW BFONT_DC_ICON(9) /**< \brief Down left arrow */
102#define BFONT_UPLEFTARROW BFONT_DC_ICON(10) /**< \brief Up left arrow */
103#define BFONT_ABUTTON BFONT_DC_ICON(11) /**< \brief A button */
104#define BFONT_BBUTTON BFONT_DC_ICON(12) /**< \brief B button */
105#define BFONT_CBUTTON BFONT_DC_ICON(13) /**< \brief C button */
106#define BFONT_DBUTTON BFONT_DC_ICON(14) /**< \brief D button */
107#define BFONT_XBUTTON BFONT_DC_ICON(15) /**< \brief X button */
108#define BFONT_YBUTTON BFONT_DC_ICON(16) /**< \brief Y button */
109#define BFONT_ZBUTTON BFONT_DC_ICON(17) /**< \brief Z button */
110#define BFONT_LTRIGGER BFONT_DC_ICON(18) /**< \brief L trigger */
111#define BFONT_RTRIGGER BFONT_DC_ICON(19) /**< \brief R trigger */
112#define BFONT_STARTBUTTON BFONT_DC_ICON(20) /**< \brief Start button */
113#define BFONT_VMUICON BFONT_DC_ICON(21) /**< \brief VMU icon */
114/** @} */
115
116#define BFONT_ICON_DIMEN 32 /**< \brief Dimension of vmu icons */
117#define BFONT_VMU_DREAMCAST_SPECIFIC (BFONT_DREAMCAST_SPECIFIC+(22 * BFONT_BYTES_PER_CHAR))
118/** @} */
119
120/** \brief Builtin VMU Icons
121 \ingroup bfont_indicies
122
123 Builtin VMU volume user icons. The Dreamcast's
124 BIOS allows the user to set these when formatting the VMU.
125*/
126typedef enum bfont_vmu_icon {
127 BFONT_ICON_INVALID_VMU = 0x00, /**< \brief Invalid */
128 BFONT_ICON_HOURGLASS_ONE = 0x01, /**< \brief Hourglass 1 */
129 BFONT_ICON_HOURGLASS_TWO = 0x02, /**< \brief Hourglass 2 */
130 BFONT_ICON_HOURGLASS_THREE = 0x03, /**< \brief Hourglass 3 */
131 BFONT_ICON_HOURGLASS_FOUR = 0x04, /**< \brief Hourglass 4 */
132 BFONT_ICON_VMUICON = 0x05, /**< \brief VMU */
133 BFONT_ICON_EARTH = 0x06, /**< \brief Earth */
134 BFONT_ICON_SATURN = 0x07, /**< \brief Saturn */
135 BFONT_ICON_QUARTER_MOON = 0x08, /**< \brief Quarter moon */
136 BFONT_ICON_LAUGHING_FACE = 0x09, /**< \brief Laughing face */
137 BFONT_ICON_SMILING_FACE = 0x0A, /**< \brief Smiling face */
138 BFONT_ICON_CASUAL_FACE = 0x0B, /**< \brief Casual face */
139 BFONT_ICON_ANGRY_FACE = 0x0C, /**< \brief Angry face */
140 BFONT_ICON_COW = 0x0D, /**< \brief Cow */
141 BFONT_ICON_HORSE = 0x0E, /**< \brief Horse */
142 BFONT_ICON_RABBIT = 0x0F, /**< \brief Rabbit */
143 BFONT_ICON_CAT = 0x10, /**< \brief Cat */
144 BFONT_ICON_CHICK = 0x11, /**< \brief Chick */
145 BFONT_ICON_LION = 0x12, /**< \brief Lion */
146 BFONT_ICON_MONKEY = 0x13, /**< \brief Monkye */
147 BFONT_ICON_PANDA = 0x14, /**< \brief Panda */
148 BFONT_ICON_BEAR = 0x15, /**< \brief Bear */
149 BFONT_ICON_PIG = 0x16, /**< \brief Pig */
150 BFONT_ICON_DOG = 0x17, /**< \brief Dog */
151 BFONT_ICON_FISH = 0x18, /**< \brief Fish */
152 BFONT_ICON_OCTOPUS = 0x19, /**< \brief Octopus */
153 BFONT_ICON_SQUID = 0x1A, /**< \brief Squid */
154 BFONT_ICON_WHALE = 0x1B, /**< \brief Whale */
155 BFONT_ICON_CRAB = 0x1C, /**< \brief Crab */
156 BFONT_ICON_BUTTERFLY = 0x1D, /**< \brief Butterfly */
157 BFONT_ICON_LADYBUG = 0x1E, /**< \brief Ladybug */
158 BFONT_ICON_ANGLER_FISH = 0x1F, /**< \brief Angler fish */
159 BFONT_ICON_PENGUIN = 0x20, /**< \brief Penguin */
160 BFONT_ICON_CHERRIES = 0x21, /**< \brief Cherries */
161 BFONT_ICON_TULIP = 0x22, /**< \brief Tulip */
162 BFONT_ICON_LEAF = 0x23, /**< \brief Leaf */
163 BFONT_ICON_SAKURA = 0x24, /**< \brief Sakura */
164 BFONT_ICON_APPLE = 0x25, /**< \brief Apple */
165 BFONT_ICON_ICECREAM = 0x26, /**< \brief Ice cream */
166 BFONT_ICON_CACTUS = 0x27, /**< \brief Cactus */
167 BFONT_ICON_PIANO = 0x28, /**< \brief Piano */
168 BFONT_ICON_GUITAR = 0x29, /**< \brief Guitar */
169 BFONT_ICON_EIGHTH_NOTE = 0x2A, /**< \brief Eighth note */
170 BFONT_ICON_TREBLE_CLEF = 0x2B, /**< \brief Treble clef */
171 BFONT_ICON_BOAT = 0x2C, /**< \brief Boat */
172 BFONT_ICON_CAR = 0x2D, /**< \brief Car */
173 BFONT_ICON_HELMET = 0x2E, /**< \brief Helmet */
174 BFONT_ICON_MOTORCYCLE = 0x2F, /**< \brief Motorcycle */
175 BFONT_ICON_VAN = 0x30, /**< \brief Van */
176 BFONT_ICON_TRUCK = 0x31, /**< \brief Truck */
177 BFONT_ICON_CLOCK = 0x32, /**< \brief Clock */
178 BFONT_ICON_TELEPHONE = 0x33, /**< \brief Telephone */
179 BFONT_ICON_PENCIL = 0x34, /**< \brief Pencil */
180 BFONT_ICON_CUP = 0x35, /**< \brief Cup */
181 BFONT_ICON_SILVERWARE = 0x36, /**< \brief Silverware */
182 BFONT_ICON_HOUSE = 0x37, /**< \brief House */
183 BFONT_ICON_BELL = 0x38, /**< \brief Bell */
184 BFONT_ICON_CROWN = 0x39, /**< \brief Crown */
185 BFONT_ICON_SOCK = 0x3A, /**< \brief Sock */
186 BFONT_ICON_CAKE = 0x3B, /**< \brief cake */
187 BFONT_ICON_KEY = 0x3C, /**< \brief Key */
188 BFONT_ICON_BOOK = 0x3D, /**< \brief Book */
189 BFONT_ICON_BASEBALL = 0x3E, /**< \brief Baseball */
190 BFONT_ICON_SOCCER = 0x3F, /**< \brief Soccer */
191 BFONT_ICON_BULB = 0x40, /**< \brief Bulb */
192 BFONT_ICON_TEDDY_BEAR = 0x41, /**< \brief Teddy bear */
193 BFONT_ICON_BOW_TIE = 0x42, /**< \brief Bow tie */
194 BFONT_ICON_BOW_ARROW = 0x43, /**< \brief Bow and arrow */
195 BFONT_ICON_SNOWMAN = 0x44, /**< \brief Snowman */
196 BFONT_ICON_LIGHTNING = 0x45, /**< \brief Lightning */
197 BFONT_ICON_SUN = 0x46, /**< \brief Sun */
198 BFONT_ICON_CLOUD = 0x47, /**< \brief Cloud */
199 BFONT_ICON_UMBRELLA = 0x48, /**< \brief Umbrella */
200 BFONT_ICON_ONE_STAR = 0x49, /**< \brief One star */
201 BFONT_ICON_TWO_STARS = 0x4A, /**< \brief Two stars */
202 BFONT_ICON_THREE_STARS = 0x4B, /**< \brief Three stars */
203 BFONT_ICON_FOUR_STARS = 0x4C, /**< \brief Four stars */
204 BFONT_ICON_HEART = 0x4D, /**< \brief Heart */
205 BFONT_ICON_DIAMOND = 0x4E, /**< \brief Diamond */
206 BFONT_ICON_SPADE = 0x4F, /**< \brief Spade */
207 BFONT_ICON_CLUB = 0x50, /**< \brief Club */
208 BFONT_ICON_JACK = 0x51, /**< \brief Jack */
209 BFONT_ICON_QUEEN = 0x52, /**< \brief Queen */
210 BFONT_ICON_KING = 0x53, /**< \brief King */
211 BFONT_ICON_JOKER = 0x54, /**< \brief Joker */
212 BFONT_ICON_ISLAND = 0x55, /**< \brief Island */
213 BFONT_ICON_0 = 0x56, /**< \brief `0` digit */
214 BFONT_ICON_1 = 0x57, /**< \brief `1` digit */
215 BFONT_ICON_2 = 0x58, /**< \brief `2` digit */
216 BFONT_ICON_3 = 0x59, /**< \brief `3` digit */
217 BFONT_ICON_4 = 0x5A, /**< \brief `4` digit */
218 BFONT_ICON_5 = 0x5B, /**< \brief `5` digit */
219 BFONT_ICON_6 = 0x5C, /**< \brief `6` digit */
220 BFONT_ICON_7 = 0x5D, /**< \brief `7` digit */
221 BFONT_ICON_8 = 0x5E, /**< \brief `8` digit */
222 BFONT_ICON_9 = 0x5F, /**< \brief `9` digit */
223 BFONT_ICON_A = 0x60, /**< \brief `A` letter */
224 BFONT_ICON_B = 0x61, /**< \brief `B` letter */
225 BFONT_ICON_C = 0x62, /**< \brief `C` letter */
226 BFONT_ICON_D = 0x63, /**< \brief `D` letter */
227 BFONT_ICON_E = 0x64, /**< \brief `E` letter */
228 BFONT_ICON_F = 0x65, /**< \brief `F` letter */
229 BFONT_ICON_G = 0x66, /**< \brief `G` letter */
230 BFONT_ICON_H = 0x67, /**< \brief `H` letter */
231 BFONT_ICON_I = 0x68, /**< \brief `I` letter */
232 BFONT_ICON_J = 0x69, /**< \brief `J` letter */
233 BFONT_ICON_K = 0x6A, /**< \brief `K` letter */
234 BFONT_ICON_L = 0x6B, /**< \brief `L` letter */
235 BFONT_ICON_M = 0x6C, /**< \brief `M` letter */
236 BFONT_ICON_N = 0x6D, /**< \brief `N` letter */
237 BFONT_ICON_O = 0x6E, /**< \brief `O` letter */
238 BFONT_ICON_P = 0x6F, /**< \brief `P` letter */
239 BFONT_ICON_Q = 0x70, /**< \brief `Q` letter */
240 BFONT_ICON_R = 0x71, /**< \brief `R` letter */
241 BFONT_ICON_S = 0x72, /**< \brief `S` letter */
242 BFONT_ICON_T = 0x73, /**< \brief `T` letter */
243 BFONT_ICON_U = 0x74, /**< \brief `U` letter */
244 BFONT_ICON_V = 0x75, /**< \brief `V` letter */
245 BFONT_ICON_W = 0x76, /**< \brief `W` letter */
246 BFONT_ICON_X = 0x77, /**< \brief `X` letter */
247 BFONT_ICON_Y = 0x78, /**< \brief `Y` letter */
248 BFONT_ICON_Z = 0x79, /**< \brief `Z` letter */
249 BFONT_ICON_CHECKER_BOARD = 0x7A, /**< \brief Checker board */
250 BFONT_ICON_GRID = 0x7B, /**< \brief Grid */
251 BFONT_ICON_LIGHT_GRAY = 0x7C, /**< \brief Light gray */
252 BFONT_ICON_DIAG_GRID = 0x7D, /**< \brief Diagonal grid */
253 BFONT_ICON_PACMAN_GRID = 0x7E, /**< \brief Pacman grid */
254 BFONT_ICON_DARK_GRAY = 0x7F, /**< \brief Dark gray */
255 BFONT_ICON_EMBROIDERY = 0x80 /**< \brief Embroidery */
257/** @} */
258
259/** \name Coloring
260 \brief Methods for modifying the text color.
261 @{
262*/
263
264/** \brief Set the font foreground color.
265
266 This function selects the foreground color to draw when a pixel is opaque in
267 the font. The value passed in for the color should be in whatever pixel
268 format that you intend to use for the image produced.
269
270 \param c The color to use.
271 \return The old foreground color.
272
273 \sa bfont_set_background_color()
274*/
275uint32_t bfont_set_foreground_color(uint32_t c);
276
277/** \brief Set the font background color.
278
279 This function selects the background color to draw when a pixel is drawn in
280 the font. This color is only used for pixels not covered by the font when
281 you have selected to have the font be opaque.
282
283 \param c The color to use.
284 \return The old background color.
285
286 \sa bfont_set_foreground_color()
287*/
288uint32_t bfont_set_background_color(uint32_t c);
289
290/** @} */
291
292/* Constants for the function below */
293typedef enum bfont_code {
294 BFONT_CODE_ISO8859_1 = 0, /**< \brief ISO-8859-1 (western) charset */
295 BFONT_CODE_EUC = 1, /**< \brief EUC-JP charset */
296 BFONT_CODE_SJIS = 2, /**< \brief Shift-JIS charset */
297 BFONT_CODE_RAW = 3 /**< \brief Raw indexing to the BFONT */
299
300/** \brief Set the font encoding.
301
302 This function selects the font encoding that is used for the font. This
303 allows you to select between the various character sets available.
304
305 \param enc The character encoding in use
306*/
308
309/** \name Character Lookups
310 \brief Methods for finding various font characters and icons.
311 @{
312*/
313
314/** \brief Find an ISO-8859-1 character in the font.
315
316 This function retrieves a pointer to the font data for the specified
317 character in the font, if its available. Generally, you will not have to
318 use this function, use one of the bfont_draw_* functions instead.
319
320 \param ch The character to look up
321 \return A pointer to the raw character data
322*/
323uint8_t *bfont_find_char(uint32_t ch);
324
325/** \brief Find an full-width Japanese character in the font.
326
327 This function retrieves a pointer to the font data for the specified
328 character in the font, if its available. Generally, you will not have to
329 use this function, use one of the bfont_draw_* functions instead.
330
331 This function deals with full-width kana and kanji.
332
333 \param ch The character to look up
334 \return A pointer to the raw character data
335*/
336uint8_t *bfont_find_char_jp(uint32_t ch);
337
338/** \brief Find an half-width Japanese character in the font.
339
340 This function retrieves a pointer to the font data for the specified
341 character in the font, if its available. Generally, you will not have to
342 use this function, use one of the bfont_draw_* functions instead.
343
344 This function deals with half-width kana only.
345
346 \param ch The character to look up
347 \return A pointer to the raw character data
348*/
349uint8_t *bfont_find_char_jp_half(uint32_t ch);
350
351/** \brief Find a VMU icon.
352
353 This function retrieves a pointer to the icon data for the specified VMU
354 icon in the bios, if its available. The icon data is flipped both vertically
355 and horizontally. Each vmu icon has dimensions 32x32 pixels and is 128 bytes
356 long.
357
358 \param icon The VMU icon index to look up.
359 \return A pointer to the raw icon data or NULL if icon value
360 is incorrect.
361*/
363
364/** @} */
365
366/** \name Character Drawing
367 \brief Methods for rendering characters.
368 @{
369*/
370
371/** \brief Draw a single character of any sort to the buffer.
372
373 This function draws a single character in the set encoding to the given
374 buffer. This function sits under draw, draw_thin, and draw_wide, while
375 exposing the colors and bitdepths desired. This will allow the writing
376 of bfont characters to paletted textures.
377
378 \param buffer The buffer to draw to.
379 \param bufwidth The width of the buffer in pixels.
380 \param fg The foreground color to use.
381 \param bg The background color to use.
382 \param bpp The number of bits per pixel in the buffer.
383 \param opaque If true, overwrite background areas with black,
384 otherwise do not change them from what they are.
385 \param c The character to draw.
386 \param wide Draw a wide character.
387 \param iskana Draw a half-width kana character.
388 \return Amount of width covered in bytes.
389*/
390size_t bfont_draw_ex(void *buffer, uint32_t bufwidth, uint32_t fg,
391 uint32_t bg, uint8_t bpp, bool opaque, uint32_t c,
392 bool wide, bool iskana);
393
394/** \brief Draw a single character to a buffer.
395
396 This function draws a single character in the set encoding to the given
397 buffer. Calling this is equivalent to calling bfont_draw_thin() with 0 for
398 the final parameter.
399
400 \param buffer The buffer to draw to (at least 12 x 24 pixels)
401 \param bufwidth The width of the buffer in pixels
402 \param opaque If true, overwrite blank areas with black,
403 otherwise do not change them from what they are
404 \param c The character to draw
405 \return Amount of width covered in bytes.
406*/
407size_t bfont_draw(void *buffer, uint32_t bufwidth, bool opaque, uint32_t c);
408
409/** \brief Draw a single thin character to a buffer.
410
411 This function draws a single character in the set encoding to the given
412 buffer. This only works with ISO-8859-1 characters and half-width kana.
413
414 \param buffer The buffer to draw to (at least 12 x 24 pixels)
415 \param bufwidth The width of the buffer in pixels
416 \param opaque If true, overwrite blank areas with black,
417 otherwise do not change them from what they are
418 \param c The character to draw
419 \param iskana Set to 1 if the character is a kana, 0 if ISO-8859-1
420 \return Amount of width covered in bytes.
421*/
422size_t bfont_draw_thin(void *buffer, uint32_t bufwidth, bool opaque,
423 uint32_t c, bool iskana);
424
425/** \brief Draw a single wide character to a buffer.
426
427 This function draws a single character in the set encoding to the given
428 buffer. This only works with full-width kana and kanji.
429
430 \param buffer The buffer to draw to (at least 24 x 24 pixels)
431 \param bufwidth The width of the buffer in pixels
432 \param opaque If true, overwrite blank areas with black,
433 otherwise do not change them from what they are
434 \param c The character to draw
435 \return Amount of width covered in bytes.
436*/
437size_t bfont_draw_wide(void *buffer, uint32_t bufwidth, bool opaque,
438 uint32_t c);
439
440/** @} */
441
442/** \name String Drawing
443 \brief Methods for rendering formatted text.
444
445 @{
446*/
447
448/** \brief Draw a full string of any sort to any sort of buffer.
449
450 This function draws a NUL-terminated string in the set encoding to the given
451 buffer. This will automatically handle mixed half and full-width characters
452 if the encoding is set to one of the Japanese encodings. Colors and bitdepth
453 can be set.
454
455 \param b The buffer to draw to.
456 \param width The width of the buffer in pixels.
457 \param fg The foreground color to use.
458 \param bg The background color to use.
459 \param bpp The number of bits per pixel in the buffer.
460 \param opaque If true, overwrite background areas with black,
461 otherwise do not change them from what they are.
462 \param str The string to draw.
463
464 \sa bfont_draw_str_ex_fmt(), bfont_draw_str_ex_va()
465*/
466void bfont_draw_str_ex(void *b, uint32_t width, uint32_t fg, uint32_t bg,
467 uint8_t bpp, bool opaque, const char *str);
468
469/** \brief Draw a full formatted string of any sort to any sort of buffer.
470
471 This function is equivalent to bfont_draw_str_ex(), except that the string
472 is formatted as with the `printf()` function.
473
474 \param b The buffer to draw to.
475 \param width The width of the buffer in pixels.
476 \param fg The foreground color to use.
477 \param bg The background color to use.
478 \param bpp The number of bits per pixel in the buffer.
479 \param opaque If true, overwrite background areas with black,
480 otherwise do not change them from what they are.
481 \param fmt The printf-style format string to draw.
482 \param ... Additional printf-style variadic arguments
483
484 \sa bfont_draw_str_ex_vfmt()
485*/
486void bfont_draw_str_ex_fmt(void *b, uint32_t width, uint32_t fg, uint32_t bg,
487 uint8_t bpp, bool opaque, const char *fmt, ...)
488 __printflike(7, 8);
489
490/** \brief Draw formatted string of any sort to buffer (with va_args).
491
492 This function is equivalent to bfont_draw_str_ex_fmt(), except that the
493 variadic argument list is passed via a pointer to a va_list.
494
495 \param b The buffer to draw to.
496 \param width The width of the buffer in pixels.
497 \param fg The foreground color to use.
498 \param bg The background color to use.
499 \param bpp The number of bits per pixel in the buffer.
500 \param opaque If true, overwrite background areas with black,
501 otherwise do not change them from what they are.
502 \param fmt The printf-style format string to draw.
503 \param var_args Additional printf-style variadic arguments
504
505 \sa bfont_draw_str_ex_fmt()
506*/
507void bfont_draw_str_ex_vfmt(void *b, uint32_t width, uint32_t fg, uint32_t bg,
508 uint8_t bpp, bool opaque, const char *fmt,
509 va_list *var_args);
510
511/** \brief Draw a full string to a buffer.
512
513 This function draws a NUL-terminated string in the set encoding to the given
514 buffer. This will automatically handle mixed half and full-width characters
515 if the encoding is set to one of the Japanese encodings. Draws pre-set
516 16-bit colors.
517
518 \param b The buffer to draw to.
519 \param width The width of the buffer in pixels.
520 \param opaque If true, overwrite blank areas with bfont_bgcolor,
521 otherwise do not change them from what they are.
522 \param str The string to draw.
523*/
524void bfont_draw_str(void *b, uint32_t width, bool opaque, const char *str);
525
526/** \brief Draw a full formatted string to a buffer.
527
528 This function is equvalent to bfont_draw_str(), except that the string is
529 formatted as with the `printf()` function.
530
531 \param b The buffer to draw to.
532 \param width The width of the buffer in pixels.
533 \param opaque If true, overwrite blank areas with bfont_bgcolor,
534 otherwise do not change them from what they are.
535 \param fmt The printf-style format string to draw.
536 \param ... Additional printf-style variadic arguments.
537*/
538void bfont_draw_str_fmt(void *b, uint32_t width, bool opaque, const char *fmt,
539 ...) __printflike(4, 5);
540
541/** \brief Draw a full formatted string to video ram (with va_args).
542
543 This function is equivalent to bfont_draw_str_ex_vfmt(), except that
544 the variadic argument list is passed via a pointer to a va_list.
545
546 \param x The x position to start drawing at.
547 \param y The y position to start drawing at.
548 \param fg The foreground color to use.
549 \param bg The background color to use.
550 \param opaque If true, overwrite background areas with black,
551 otherwise do not change them from what they are.
552 \param fmt The printf-style format string to draw.
553 \param var_args Additional printf-style variadic arguments
554
555 \sa bfont_draw_str_ex()
556*/
557void bfont_draw_str_vram_vfmt(uint32_t x, uint32_t y, uint32_t fg, uint32_t bg,
558 bool opaque, const char *fmt,
559 va_list *var_args);
560
561/** \brief Draw a full string to video ram.
562
563 This function draws a NUL-terminated string in the set encoding to video
564 ram. This will automatically handle mixed half and full-width characters
565 if the encoding is set to one of the Japanese encodings. Draws pre-set
566 16-bit colors.
567
568 \param x The x position to start drawing at.
569 \param y The y position to start drawing at.
570 \param opaque If true, overwrite blank areas with bfont_bgcolor,
571 otherwise do not change them from what they are.
572 \param fmt The printf-style format string to draw.
573 \param ... Additional printf-style variadic arguments.
574*/
575void bfont_draw_str_vram_fmt(uint32_t x, uint32_t y, bool opaque, const char *fmt,
576 ...) __printflike(4, 5);
577
578/** @} */
579
580__END_DECLS
581
582#endif /* __DC_BIOSFONT_H */
void bfont_draw_str_ex_fmt(void *b, uint32_t width, uint32_t fg, uint32_t bg, uint8_t bpp, bool opaque, const char *fmt,...) __printflike(7
Draw a full formatted string of any sort to any sort of buffer.
void bfont_draw_str_vram_fmt(uint32_t x, uint32_t y, bool opaque, const char *fmt,...) __printflike(4
Draw a full string to video ram.
size_t bfont_draw_ex(void *buffer, uint32_t bufwidth, uint32_t fg, uint32_t bg, uint8_t bpp, bool opaque, uint32_t c, bool wide, bool iskana)
Draw a single character of any sort to the buffer.
size_t bfont_draw_thin(void *buffer, uint32_t bufwidth, bool opaque, uint32_t c, bool iskana)
Draw a single thin character to a buffer.
uint8_t * bfont_find_char_jp_half(uint32_t ch)
Find an half-width Japanese character in the font.
void bfont_draw_str_ex(void *b, uint32_t width, uint32_t fg, uint32_t bg, uint8_t bpp, bool opaque, const char *str)
Draw a full string of any sort to any sort of buffer.
size_t bfont_draw(void *buffer, uint32_t bufwidth, bool opaque, uint32_t c)
Draw a single character to a buffer.
void bfont_set_encoding(bfont_code_t enc)
Set the font encoding.
void void bfont_draw_str_ex_vfmt(void *b, uint32_t width, uint32_t fg, uint32_t bg, uint8_t bpp, bool opaque, const char *fmt, va_list *var_args)
Draw formatted string of any sort to buffer (with va_args).
uint32_t bfont_set_background_color(uint32_t c)
Set the font background color.
uint8_t * bfont_find_icon(bfont_vmu_icon_t icon)
Find a VMU icon.
void bfont_draw_str(void *b, uint32_t width, bool opaque, const char *str)
Draw a full string to a buffer.
void void bfont_draw_str_vram_vfmt(uint32_t x, uint32_t y, uint32_t fg, uint32_t bg, bool opaque, const char *fmt, va_list *var_args)
Draw a full formatted string to video ram (with va_args).
size_t bfont_draw_wide(void *buffer, uint32_t bufwidth, bool opaque, uint32_t c)
Draw a single wide character to a buffer.
uint32_t bfont_set_foreground_color(uint32_t c)
Set the font foreground color.
uint8_t * bfont_find_char(uint32_t ch)
Find an ISO-8859-1 character in the font.
bfont_code_t
Definition biosfont.h:293
@ BFONT_CODE_ISO8859_1
ISO-8859-1 (western) charset.
Definition biosfont.h:294
@ BFONT_CODE_RAW
Raw indexing to the BFONT.
Definition biosfont.h:297
@ BFONT_CODE_SJIS
Shift-JIS charset.
Definition biosfont.h:296
@ BFONT_CODE_EUC
EUC-JP charset.
Definition biosfont.h:295
void bfont_draw_str_fmt(void *b, uint32_t width, bool opaque, const char *fmt,...) __printflike(4
Draw a full formatted string to a buffer.
uint8_t * bfont_find_char_jp(uint32_t ch)
Find an full-width Japanese character in the font.
Definitions for builtin attributes and compiler directives.
bfont_vmu_icon_t
Builtin VMU Icons.
Definition biosfont.h:126
@ BFONT_ICON_INVALID_VMU
Invalid.
Definition biosfont.h:127
@ BFONT_ICON_BOAT
Boat.
Definition biosfont.h:171
@ BFONT_ICON_TREBLE_CLEF
Treble clef.
Definition biosfont.h:170
@ BFONT_ICON_CUP
Cup.
Definition biosfont.h:180
@ BFONT_ICON_GRID
Grid.
Definition biosfont.h:250
@ BFONT_ICON_HOURGLASS_FOUR
Hourglass 4.
Definition biosfont.h:131
@ BFONT_ICON_CLOCK
Clock.
Definition biosfont.h:177
@ BFONT_ICON_W
W letter
Definition biosfont.h:245
@ BFONT_ICON_TWO_STARS
Two stars.
Definition biosfont.h:201
@ BFONT_ICON_EMBROIDERY
Embroidery.
Definition biosfont.h:255
@ BFONT_ICON_HOURGLASS_THREE
Hourglass 3.
Definition biosfont.h:130
@ BFONT_ICON_Q
Q letter
Definition biosfont.h:239
@ BFONT_ICON_TEDDY_BEAR
Teddy bear.
Definition biosfont.h:192
@ BFONT_ICON_3
3 digit
Definition biosfont.h:216
@ BFONT_ICON_0
0 digit
Definition biosfont.h:213
@ BFONT_ICON_PIANO
Piano.
Definition biosfont.h:167
@ BFONT_ICON_G
G letter
Definition biosfont.h:229
@ BFONT_ICON_BULB
Bulb.
Definition biosfont.h:191
@ BFONT_ICON_CLOUD
Cloud.
Definition biosfont.h:198
@ BFONT_ICON_CACTUS
Cactus.
Definition biosfont.h:166
@ BFONT_ICON_UMBRELLA
Umbrella.
Definition biosfont.h:199
@ BFONT_ICON_TRUCK
Truck.
Definition biosfont.h:176
@ BFONT_ICON_C
C letter
Definition biosfont.h:225
@ BFONT_ICON_HOURGLASS_TWO
Hourglass 2.
Definition biosfont.h:129
@ BFONT_ICON_9
9 digit
Definition biosfont.h:222
@ BFONT_ICON_SATURN
Saturn.
Definition biosfont.h:134
@ BFONT_ICON_LAUGHING_FACE
Laughing face.
Definition biosfont.h:136
@ BFONT_ICON_CRAB
Crab.
Definition biosfont.h:155
@ BFONT_ICON_HOURGLASS_ONE
Hourglass 1.
Definition biosfont.h:128
@ BFONT_ICON_SAKURA
Sakura.
Definition biosfont.h:163
@ BFONT_ICON_MONKEY
Monkye.
Definition biosfont.h:146
@ BFONT_ICON_I
I letter
Definition biosfont.h:231
@ BFONT_ICON_K
K letter
Definition biosfont.h:233
@ BFONT_ICON_KING
King.
Definition biosfont.h:210
@ BFONT_ICON_LIGHTNING
Lightning.
Definition biosfont.h:196
@ BFONT_ICON_TELEPHONE
Telephone.
Definition biosfont.h:178
@ BFONT_ICON_BASEBALL
Baseball.
Definition biosfont.h:189
@ BFONT_ICON_BEAR
Bear.
Definition biosfont.h:148
@ BFONT_ICON_H
H letter
Definition biosfont.h:230
@ BFONT_ICON_R
R letter
Definition biosfont.h:240
@ BFONT_ICON_BOOK
Book.
Definition biosfont.h:188
@ BFONT_ICON_U
U letter
Definition biosfont.h:243
@ BFONT_ICON_4
4 digit
Definition biosfont.h:217
@ BFONT_ICON_QUARTER_MOON
Quarter moon.
Definition biosfont.h:135
@ BFONT_ICON_PANDA
Panda.
Definition biosfont.h:147
@ BFONT_ICON_CHERRIES
Cherries.
Definition biosfont.h:160
@ BFONT_ICON_LION
Lion.
Definition biosfont.h:145
@ BFONT_ICON_ANGRY_FACE
Angry face.
Definition biosfont.h:139
@ BFONT_ICON_HORSE
Horse.
Definition biosfont.h:141
@ BFONT_ICON_CROWN
Crown.
Definition biosfont.h:184
@ BFONT_ICON_F
F letter
Definition biosfont.h:228
@ BFONT_ICON_ANGLER_FISH
Angler fish.
Definition biosfont.h:158
@ BFONT_ICON_1
1 digit
Definition biosfont.h:214
@ BFONT_ICON_V
V letter
Definition biosfont.h:244
@ BFONT_ICON_B
B letter
Definition biosfont.h:224
@ BFONT_ICON_2
2 digit
Definition biosfont.h:215
@ BFONT_ICON_WHALE
Whale.
Definition biosfont.h:154
@ BFONT_ICON_X
X letter
Definition biosfont.h:246
@ BFONT_ICON_HELMET
Helmet.
Definition biosfont.h:173
@ BFONT_ICON_CLUB
Club.
Definition biosfont.h:207
@ BFONT_ICON_CHECKER_BOARD
Checker board.
Definition biosfont.h:249
@ BFONT_ICON_DIAMOND
Diamond.
Definition biosfont.h:205
@ BFONT_ICON_JACK
Jack.
Definition biosfont.h:208
@ BFONT_ICON_ISLAND
Island.
Definition biosfont.h:212
@ BFONT_ICON_APPLE
Apple.
Definition biosfont.h:164
@ BFONT_ICON_JOKER
Joker.
Definition biosfont.h:211
@ BFONT_ICON_DARK_GRAY
Dark gray.
Definition biosfont.h:254
@ BFONT_ICON_CAKE
cake
Definition biosfont.h:186
@ BFONT_ICON_VAN
Van.
Definition biosfont.h:175
@ BFONT_ICON_L
L letter
Definition biosfont.h:234
@ BFONT_ICON_CAR
Car.
Definition biosfont.h:172
@ BFONT_ICON_CASUAL_FACE
Casual face.
Definition biosfont.h:138
@ BFONT_ICON_CHICK
Chick.
Definition biosfont.h:144
@ BFONT_ICON_7
7 digit
Definition biosfont.h:220
@ BFONT_ICON_BELL
Bell.
Definition biosfont.h:183
@ BFONT_ICON_S
S letter
Definition biosfont.h:241
@ BFONT_ICON_PENGUIN
Penguin.
Definition biosfont.h:159
@ BFONT_ICON_DOG
Dog.
Definition biosfont.h:150
@ BFONT_ICON_LIGHT_GRAY
Light gray.
Definition biosfont.h:251
@ BFONT_ICON_BOW_ARROW
Bow and arrow.
Definition biosfont.h:194
@ BFONT_ICON_BOW_TIE
Bow tie.
Definition biosfont.h:193
@ BFONT_ICON_VMUICON
VMU.
Definition biosfont.h:132
@ BFONT_ICON_FOUR_STARS
Four stars.
Definition biosfont.h:203
@ BFONT_ICON_M
M letter
Definition biosfont.h:235
@ BFONT_ICON_OCTOPUS
Octopus.
Definition biosfont.h:152
@ BFONT_ICON_SNOWMAN
Snowman.
Definition biosfont.h:195
@ BFONT_ICON_FISH
Fish.
Definition biosfont.h:151
@ BFONT_ICON_SPADE
Spade.
Definition biosfont.h:206
@ BFONT_ICON_A
A letter
Definition biosfont.h:223
@ BFONT_ICON_LADYBUG
Ladybug.
Definition biosfont.h:157
@ BFONT_ICON_5
5 digit
Definition biosfont.h:218
@ BFONT_ICON_SUN
Sun.
Definition biosfont.h:197
@ BFONT_ICON_P
P letter
Definition biosfont.h:238
@ BFONT_ICON_SOCK
Sock.
Definition biosfont.h:185
@ BFONT_ICON_DIAG_GRID
Diagonal grid.
Definition biosfont.h:252
@ BFONT_ICON_D
D letter
Definition biosfont.h:226
@ BFONT_ICON_Y
Y letter
Definition biosfont.h:247
@ BFONT_ICON_E
E letter
Definition biosfont.h:227
@ BFONT_ICON_SOCCER
Soccer.
Definition biosfont.h:190
@ BFONT_ICON_RABBIT
Rabbit.
Definition biosfont.h:142
@ BFONT_ICON_EIGHTH_NOTE
Eighth note.
Definition biosfont.h:169
@ BFONT_ICON_ICECREAM
Ice cream.
Definition biosfont.h:165
@ BFONT_ICON_SILVERWARE
Silverware.
Definition biosfont.h:181
@ BFONT_ICON_LEAF
Leaf.
Definition biosfont.h:162
@ BFONT_ICON_HEART
Heart.
Definition biosfont.h:204
@ BFONT_ICON_PIG
Pig.
Definition biosfont.h:149
@ BFONT_ICON_COW
Cow.
Definition biosfont.h:140
@ BFONT_ICON_THREE_STARS
Three stars.
Definition biosfont.h:202
@ BFONT_ICON_O
O letter
Definition biosfont.h:237
@ BFONT_ICON_SMILING_FACE
Smiling face.
Definition biosfont.h:137
@ BFONT_ICON_T
T letter
Definition biosfont.h:242
@ BFONT_ICON_KEY
Key.
Definition biosfont.h:187
@ BFONT_ICON_GUITAR
Guitar.
Definition biosfont.h:168
@ BFONT_ICON_PACMAN_GRID
Pacman grid.
Definition biosfont.h:253
@ BFONT_ICON_QUEEN
Queen.
Definition biosfont.h:209
@ BFONT_ICON_CAT
Cat.
Definition biosfont.h:143
@ BFONT_ICON_EARTH
Earth.
Definition biosfont.h:133
@ BFONT_ICON_PENCIL
Pencil.
Definition biosfont.h:179
@ BFONT_ICON_ONE_STAR
One star.
Definition biosfont.h:200
@ BFONT_ICON_BUTTERFLY
Butterfly.
Definition biosfont.h:156
@ BFONT_ICON_TULIP
Tulip.
Definition biosfont.h:161
@ BFONT_ICON_HOUSE
House.
Definition biosfont.h:182
@ BFONT_ICON_SQUID
Squid.
Definition biosfont.h:153
@ BFONT_ICON_8
8 digit
Definition biosfont.h:221
@ BFONT_ICON_J
J letter
Definition biosfont.h:232
@ BFONT_ICON_Z
Z letter
Definition biosfont.h:248
@ BFONT_ICON_MOTORCYCLE
Motorcycle.
Definition biosfont.h:174
@ BFONT_ICON_N
N letter
Definition biosfont.h:236
@ BFONT_ICON_6
6 digit
Definition biosfont.h:219
#define __printflike(fmtarg, firstvararg)
Identify a function as accepting formatting like printf().
Definition cdefs.h:132
Common integer types.