KallistiOS git master
Independent SDK for the Sega Dreamcast
|
BIOS font drawing functions. More...
#include <kos/cdefs.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdarg.h>
#include <arch/types.h>
Go to the source code of this file.
Macros | |
#define | BFONT_THIN_WIDTH 12 |
Width of Thin Font (ISO8859_1, half-JP) | |
#define | BFONT_WIDE_WIDTH (BFONT_THIN_WIDTH * 2) |
Width of Wide Font (full-JP) | |
#define | BFONT_HEIGHT 24 |
Height of All Fonts. | |
#define | BFONT_BYTES_PER_CHAR (BFONT_THIN_WIDTH * BFONT_HEIGHT / 8) |
Number of bytes to represent a single character within the BIOS font. | |
#define | BFONT_NARROW_START 0 |
Start of Narrow Characters in Font Block. | |
#define | BFONT_OVERBAR BFONT_NARROW_START |
#define | BFONT_ISO_8859_1_33_126 (BFONT_NARROW_START + ( 1 * BFONT_BYTES_PER_CHAR)) |
#define | BFONT_YEN (BFONT_NARROW_START + (95 * BFONT_BYTES_PER_CHAR)) |
#define | BFONT_ISO_8859_1_160_255 (BFONT_NARROW_START + (96 * BFONT_BYTES_PER_CHAR)) |
#define | JISX_0208_ROW_SIZE 94 |
Size of a row for JISX-0208 characters. | |
#define | BFONT_WIDE_START (288 * BFONT_BYTES_PER_CHAR) |
Start of Wide Characters in Font Block. | |
#define | BFONT_JISX_0208_ROW1 BFONT_WIDE_START |
Start of JISX-0208 Rows 1-7 in Font Block. | |
#define | BFONT_JISX_0208_ROW16 (BFONT_WIDE_START + (658 * BFONT_BYTES_PER_CHAR)) |
Start of JISX-0208 Row 16-47 (Start of Level 1) in Font Block. | |
#define | BFONT_JISX_0208_ROW48 (BFONT_JISX_0208_ROW16 + ((32 * JISX_0208_ROW_SIZE) * BFONT_BYTES_PER_CHAR)) |
JISX-0208 Row 48-84 (Start of Level 2) in Font Block. | |
#define | BFONT_DREAMCAST_SPECIFIC (BFONT_WIDE_START + (7056 * BFONT_BYTES_PER_CHAR)) |
Start of DC Specific Characters in Font Block. | |
#define | BFONT_DC_ICON(offset) (BFONT_DREAMCAST_SPECIFIC + ((offset) * BFONT_BYTES_PER_CHAR)) |
Takes a DC-specific icon index and returns a character offset. | |
#define | BFONT_CIRCLECOPYRIGHT BFONT_DC_ICON(0) |
Circle copyright. | |
#define | BFONT_CIRCLER BFONT_DC_ICON(1) |
Circle restricted. | |
#define | BFONT_TRADEMARK BFONT_DC_ICON(2) |
Trademark. | |
#define | BFONT_UPARROW BFONT_DC_ICON(3) |
Up arrow. | |
#define | BFONT_DOWNARROW BFONT_DC_ICON(4) |
Down arrow. | |
#define | BFONT_LEFTARROW BFONT_DC_ICON(5) |
Left arrow. | |
#define | BFONT_RIGHTARROW BFONT_DC_ICON(6) |
Right arrow. | |
#define | BFONT_UPRIGHTARROW BFONT_DC_ICON(7) |
Up right arrow. | |
#define | BFONT_DOWNRIGHTARROW BFONT_DC_ICON(8) |
Down right arrow. | |
#define | BFONT_DOWNLEFTARROW BFONT_DC_ICON(9) |
Down left arrow. | |
#define | BFONT_UPLEFTARROW BFONT_DC_ICON(10) |
Up left arrow. | |
#define | BFONT_ABUTTON BFONT_DC_ICON(11) |
A button. | |
#define | BFONT_BBUTTON BFONT_DC_ICON(12) |
B button. | |
#define | BFONT_CBUTTON BFONT_DC_ICON(13) |
C button. | |
#define | BFONT_DBUTTON BFONT_DC_ICON(14) |
D button. | |
#define | BFONT_XBUTTON BFONT_DC_ICON(15) |
X button. | |
#define | BFONT_YBUTTON BFONT_DC_ICON(16) |
Y button. | |
#define | BFONT_ZBUTTON BFONT_DC_ICON(17) |
Z button. | |
#define | BFONT_LTRIGGER BFONT_DC_ICON(18) |
L trigger. | |
#define | BFONT_RTRIGGER BFONT_DC_ICON(19) |
R trigger. | |
#define | BFONT_STARTBUTTON BFONT_DC_ICON(20) |
Start button. | |
#define | BFONT_VMUICON BFONT_DC_ICON(21) |
VMU icon. | |
#define | BFONT_ICON_DIMEN 32 |
Dimension of vmu icons. | |
#define | BFONT_VMU_DREAMCAST_SPECIFIC (BFONT_DREAMCAST_SPECIFIC+(22 * BFONT_BYTES_PER_CHAR)) |
Functions | |
void | bfont_set_encoding (bfont_code_t enc) |
Set the font encoding. | |
Coloring | |
Methods for modifying the text color. | |
uint32_t | bfont_set_foreground_color (uint32_t c) |
Set the font foreground color. | |
uint32_t | bfont_set_background_color (uint32_t c) |
Set the font background color. | |
Character Lookups | |
Methods for finding various font characters and icons. | |
uint8_t * | bfont_find_char (uint32_t ch) |
Find an ISO-8859-1 character in the font. | |
uint8_t * | bfont_find_char_jp (uint32_t ch) |
Find an full-width Japanese character in the font. | |
uint8_t * | bfont_find_char_jp_half (uint32_t ch) |
Find an half-width Japanese character in the font. | |
uint8_t * | bfont_find_icon (bfont_vmu_icon_t icon) |
Find a VMU icon. | |
Character Drawing | |
Methods for rendering characters. | |
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 (void *buffer, uint32_t bufwidth, bool opaque, uint32_t c) |
Draw a single character to a 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. | |
size_t | bfont_draw_wide (void *buffer, uint32_t bufwidth, bool opaque, uint32_t c) |
Draw a single wide character to a buffer. | |
String Drawing | |
Methods for rendering formatted text. | |
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. | |
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 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). | |
void | bfont_draw_str (void *b, uint32_t width, bool opaque, const char *str) |
Draw a full string to a buffer. | |
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. | |
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). | |
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. | |
BIOS font drawing functions.
This file provides support for utilizing the font built into the Dreamcast's BIOS. These functions allow access to both the western character set and Japanese characters.
enum bfont_code_t |
size_t bfont_draw | ( | void * | buffer, |
uint32_t | bufwidth, | ||
bool | opaque, | ||
uint32_t | c ) |
Draw a single character to a buffer.
This function draws a single character in the set encoding to the given buffer. Calling this is equivalent to calling bfont_draw_thin() with 0 for the final parameter.
buffer | The buffer to draw to (at least 12 x 24 pixels) |
bufwidth | The width of the buffer in pixels |
opaque | If true, overwrite blank areas with black, otherwise do not change them from what they are |
c | The character to draw |
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.
This function draws a single character in the set encoding to the given buffer. This function sits under draw, draw_thin, and draw_wide, while exposing the colors and bitdepths desired. This will allow the writing of bfont characters to paletted textures.
buffer | The buffer to draw to. |
bufwidth | The width of the buffer in pixels. |
fg | The foreground color to use. |
bg | The background color to use. |
bpp | The number of bits per pixel in the buffer. |
opaque | If true, overwrite background areas with black, otherwise do not change them from what they are. |
c | The character to draw. |
wide | Draw a wide character. |
iskana | Draw a half-width kana character. |
void bfont_draw_str | ( | void * | b, |
uint32_t | width, | ||
bool | opaque, | ||
const char * | str ) |
Draw a full string to a buffer.
This function draws a NUL-terminated string in the set encoding to the given buffer. This will automatically handle mixed half and full-width characters if the encoding is set to one of the Japanese encodings. Draws pre-set 16-bit colors.
b | The buffer to draw to. |
width | The width of the buffer in pixels. |
opaque | If true, overwrite blank areas with bfont_bgcolor, otherwise do not change them from what they are. |
str | The string to draw. |
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.
This function draws a NUL-terminated string in the set encoding to the given buffer. This will automatically handle mixed half and full-width characters if the encoding is set to one of the Japanese encodings. Colors and bitdepth can be set.
b | The buffer to draw to. |
width | The width of the buffer in pixels. |
fg | The foreground color to use. |
bg | The background color to use. |
bpp | The number of bits per pixel in the buffer. |
opaque | If true, overwrite background areas with black, otherwise do not change them from what they are. |
str | The string to draw. |
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, | ||
... ) |
Draw a full formatted string of any sort to any sort of buffer.
This function is equivalent to bfont_draw_str_ex(), except that the string is formatted as with the printf()
function.
b | The buffer to draw to. |
width | The width of the buffer in pixels. |
fg | The foreground color to use. |
bg | The background color to use. |
bpp | The number of bits per pixel in the buffer. |
opaque | If true, overwrite background areas with black, otherwise do not change them from what they are. |
fmt | The printf-style format string to draw. |
... | Additional printf-style variadic arguments |
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).
This function is equivalent to bfont_draw_str_ex_fmt(), except that the variadic argument list is passed via a pointer to a va_list.
b | The buffer to draw to. |
width | The width of the buffer in pixels. |
fg | The foreground color to use. |
bg | The background color to use. |
bpp | The number of bits per pixel in the buffer. |
opaque | If true, overwrite background areas with black, otherwise do not change them from what they are. |
fmt | The printf-style format string to draw. |
var_args | Additional printf-style variadic arguments |
void bfont_draw_str_fmt | ( | void * | b, |
uint32_t | width, | ||
bool | opaque, | ||
const char * | fmt, | ||
... ) |
Draw a full formatted string to a buffer.
This function is equvalent to bfont_draw_str(), except that the string is formatted as with the printf()
function.
b | The buffer to draw to. |
width | The width of the buffer in pixels. |
opaque | If true, overwrite blank areas with bfont_bgcolor, otherwise do not change them from what they are. |
fmt | The printf-style format string to draw. |
... | Additional printf-style variadic arguments. |
void bfont_draw_str_vram_fmt | ( | uint32_t | x, |
uint32_t | y, | ||
bool | opaque, | ||
const char * | fmt, | ||
... ) |
Draw a full string to video ram.
This function draws a NUL-terminated string in the set encoding to video ram. This will automatically handle mixed half and full-width characters if the encoding is set to one of the Japanese encodings. Draws pre-set 16-bit colors.
x | The x position to start drawing at. |
y | The y position to start drawing at. |
opaque | If true, overwrite blank areas with bfont_bgcolor, otherwise do not change them from what they are. |
fmt | The printf-style format string to draw. |
... | Additional printf-style variadic arguments. |
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).
This function is equivalent to bfont_draw_str_ex_vfmt(), except that the variadic argument list is passed via a pointer to a va_list.
x | The x position to start drawing at. |
y | The y position to start drawing at. |
fg | The foreground color to use. |
bg | The background color to use. |
opaque | If true, overwrite background areas with black, otherwise do not change them from what they are. |
fmt | The printf-style format string to draw. |
var_args | Additional printf-style variadic arguments |
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.
This function draws a single character in the set encoding to the given buffer. This only works with ISO-8859-1 characters and half-width kana.
buffer | The buffer to draw to (at least 12 x 24 pixels) |
bufwidth | The width of the buffer in pixels |
opaque | If true, overwrite blank areas with black, otherwise do not change them from what they are |
c | The character to draw |
iskana | Set to 1 if the character is a kana, 0 if ISO-8859-1 |
size_t bfont_draw_wide | ( | void * | buffer, |
uint32_t | bufwidth, | ||
bool | opaque, | ||
uint32_t | c ) |
Draw a single wide character to a buffer.
This function draws a single character in the set encoding to the given buffer. This only works with full-width kana and kanji.
buffer | The buffer to draw to (at least 24 x 24 pixels) |
bufwidth | The width of the buffer in pixels |
opaque | If true, overwrite blank areas with black, otherwise do not change them from what they are |
c | The character to draw |
uint8_t * bfont_find_char | ( | uint32_t | ch | ) |
Find an ISO-8859-1 character in the font.
This function retrieves a pointer to the font data for the specified character in the font, if its available. Generally, you will not have to use this function, use one of the bfont_draw_* functions instead.
ch | The character to look up |
uint8_t * bfont_find_char_jp | ( | uint32_t | ch | ) |
Find an full-width Japanese character in the font.
This function retrieves a pointer to the font data for the specified character in the font, if its available. Generally, you will not have to use this function, use one of the bfont_draw_* functions instead.
This function deals with full-width kana and kanji.
ch | The character to look up |
uint8_t * bfont_find_char_jp_half | ( | uint32_t | ch | ) |
Find an half-width Japanese character in the font.
This function retrieves a pointer to the font data for the specified character in the font, if its available. Generally, you will not have to use this function, use one of the bfont_draw_* functions instead.
This function deals with half-width kana only.
ch | The character to look up |
uint8_t * bfont_find_icon | ( | bfont_vmu_icon_t | icon | ) |
Find a VMU icon.
This function retrieves a pointer to the icon data for the specified VMU icon in the bios, if its available. The icon data is flipped both vertically and horizontally. Each vmu icon has dimensions 32x32 pixels and is 128 bytes long.
icon | The VMU icon index to look up. |
uint32_t bfont_set_background_color | ( | uint32_t | c | ) |
Set the font background color.
This function selects the background color to draw when a pixel is drawn in the font. This color is only used for pixels not covered by the font when you have selected to have the font be opaque.
c | The color to use. |
void bfont_set_encoding | ( | bfont_code_t | enc | ) |
Set the font encoding.
This function selects the font encoding that is used for the font. This allows you to select between the various character sets available.
enc | The character encoding in use |
uint32_t bfont_set_foreground_color | ( | uint32_t | c | ) |
Set the font foreground color.
This function selects the foreground color to draw when a pixel is opaque in the font. The value passed in for the color should be in whatever pixel format that you intend to use for the image produced.
c | The color to use. |