KallistiOS  ##version##
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
biosfont.h
Go to the documentation of this file.
1 /* KallistiOS ##version##
2 
3  dc/biosfont.h
4  (c)2000-2001 Dan Potter
5  Japanese Functions (c)2002 Kazuaki Matsumoto
6 
7 */
8 
9 /** \file dc/biosfont.h
10  \brief BIOS font drawing functions.
11 
12  This file provides support for utilizing the font built into the Dreamcast's
13  BIOS. These functions allow access to both the western character set and
14  Japanese characters.
15 
16  \author Dan Potter
17  \author Kazuaki Matsumoto
18 */
19 
20 #ifndef __DC_BIOSFONT_H
21 #define __DC_BIOSFONT_H
22 
23 #include <sys/cdefs.h>
24 __BEGIN_DECLS
25 
26 #include <arch/types.h>
27 
28 /** \brief Set the font foreground color.
29 
30  This function selects the foreground color to draw when a pixel is opaque in
31  the font. The value passed in for the color should be in whatever pixel
32  format that you intend to use for the image produced.
33 
34  \param c The color to use.
35  \return The old foreground color.
36 */
38 
39 /** \brief Set the font background color.
40 
41  This function selects the background color to draw when a pixel is drawn in
42  the font. This color is only used for pixels not covered by the font when
43  you have selected to have the font be opaque.
44 
45  \param c The color to use.
46  \return The old background color.
47 */
49 
50 /** \brief Set the font to draw 32-bit color.
51 
52  This function changes whether the font draws colors as 32-bit or 16-bit. The
53  default is to use 16-bit.
54 
55  \param on Set to 0 to use 16-bit color, 32-bit otherwise.
56  \return The old state (1 = 32-bit, 0 = 16-bit).
57 */
58 int bfont_set_32bit_mode(int on);
59 
60 /* Constants for the function below */
61 #define BFONT_CODE_ISO8859_1 0 /**< \brief ISO-8859-1 (western) charset */
62 #define BFONT_CODE_EUC 1 /**< \brief EUC-JP charset */
63 #define BFONT_CODE_SJIS 2 /**< \brief Shift-JIS charset */
64 
65 /** \brief Set the font encoding.
66 
67  This function selects the font encoding that is used for the font. This
68  allows you to select between the various character sets available.
69 
70  \param enc The character encoding in use
71  \see BFONT_CODE_ISO8859_1
72  \see BFONT_CODE_EUC
73  \see BFONT_CODE_SJIS
74 */
75 void bfont_set_encoding(int enc);
76 
77 /** \brief Find an ISO-8859-1 character in the font.
78 
79  This function retrieves a pointer to the font data for the specified
80  character in the font, if its available. Generally, you will not have to
81  use this function, use one of the bfont_draw_* functions instead.
82 
83  \param ch The character to look up
84  \return A pointer to the raw character data
85 */
86 uint8 *bfont_find_char(int ch);
87 
88 /** \brief Find an full-width Japanese character in the font.
89 
90  This function retrieves a pointer to the font data for the specified
91  character in the font, if its available. Generally, you will not have to
92  use this function, use one of the bfont_draw_* functions instead.
93 
94  This function deals with full-width kana and kanji.
95 
96  \param ch The character to look up
97  \return A pointer to the raw character data
98 */
99 uint8 *bfont_find_char_jp(int ch);
100 
101 /** \brief Find an half-width Japanese character in the font.
102 
103  This function retrieves a pointer to the font data for the specified
104  character in the font, if its available. Generally, you will not have to
105  use this function, use one of the bfont_draw_* functions instead.
106 
107  This function deals with half-width kana only.
108 
109  \param ch The character to look up
110  \return A pointer to the raw character data
111 */
113 
114 /** \brief Draw a single character to a buffer.
115 
116  This function draws a single character in the set encoding to the given
117  buffer. Calling this is equivalent to calling bfont_draw_thin() with 0 for
118  the final parameter.
119 
120  \param buffer The buffer to draw to (at least 12 x 24 pixels)
121  \param bufwidth The width of the buffer in pixels
122  \param opaque If non-zero, overwrite blank areas with black,
123  otherwise do not change them from what they are
124  \param c The character to draw
125 */
126 void bfont_draw(void *buffer, int bufwidth, int opaque, int c);
127 
128 /** \brief Draw a single thin character to a buffer.
129 
130  This function draws a single character in the set encoding to the given
131  buffer. This only works with ISO-8859-1 characters and half-width kana.
132 
133  \param buffer The buffer to draw to (at least 12 x 24 pixels)
134  \param bufwidth The width of the buffer in pixels
135  \param opaque If non-zero, overwrite blank areas with black,
136  otherwise do not change them from what they are
137  \param c The character to draw
138  \param iskana Set to 1 if the character is a kana, 0 if ISO-8859-1
139 */
140 void bfont_draw_thin(void *buffer, int bufwidth, int opaque, int c, int iskana);
141 
142 /** \brief Draw a single wide character to a buffer.
143 
144  This function draws a single character in the set encoding to the given
145  buffer. This only works with full-width kana and kanji.
146 
147  \param buffer The buffer to draw to (at least 24 x 24 pixels)
148  \param bufwidth The width of the buffer in pixels
149  \param opaque If non-zero, overwrite blank areas with black,
150  otherwise do not change them from what they are
151  \param c The character to draw
152 */
153 void bfont_draw_wide(void *buffer, int bufwidth, int opaque, int c);
154 
155 /** \brief Draw a full string to a buffer.
156 
157  This function draws a NUL-terminated string in the set encoding to the given
158  buffer. This will automatially handle mixed half and full-width characters
159  if the encoding is set to one of the Japanese encodings.
160 
161  \param buffer The buffer to draw to
162  \param width The width of the buffer in pixels
163  \param opaque If non-zero, overwrite blank areas with black,
164  otherwise do not change them from what they are
165  \param str The string to draw
166 */
167 void bfont_draw_str(void *buffer, int width, int opaque, char *str);
168 
169 __END_DECLS
170 
171 #endif /* __DC_BIOSFONT_H */
void bfont_draw_str(void *buffer, int width, int opaque, char *str)
Draw a full string to a buffer.
uint32 bfont_set_foreground_color(uint32 c)
Set the font foreground color.
Common integer types.
uint8 * bfont_find_char_jp(int ch)
Find an full-width Japanese character in the font.
uint32 bfont_set_background_color(uint32 c)
Set the font background color.
void bfont_draw_thin(void *buffer, int bufwidth, int opaque, int c, int iskana)
Draw a single thin character to a buffer.
void bfont_draw_wide(void *buffer, int bufwidth, int opaque, int c)
Draw a single wide character to a buffer.
unsigned long uint32
32-bit unsigned integer
Definition: types.h:28
unsigned char uint8
8-bit unsigned integer
Definition: types.h:30
uint8 * bfont_find_char(int ch)
Find an ISO-8859-1 character in the font.
int bfont_set_32bit_mode(int on)
Set the font to draw 32-bit color.
uint8 * bfont_find_char_jp_half(int ch)
Find an half-width Japanese character in the font.
void bfont_set_encoding(int enc)
Set the font encoding.
void bfont_draw(void *buffer, int bufwidth, int opaque, int c)
Draw a single character to a buffer.