1.1 --- a/data/font.S Tue Nov 13 00:34:10 2018 +0100
1.2 +++ b/data/font.S Tue Nov 13 12:57:52 2018 +0100
1.3 @@ -5,9 +5,6 @@
1.4
1.5 .section .flash, "a"
1.6
1.7 -fontbase:
1.8 -.word 33
1.9 -
1.10 fontchars:
1.11 /* 33 */
1.12 .byte 2 /* width in pixels */
1.13 @@ -1325,6 +1322,9 @@
1.14 .byte 0b000000
1.15 .byte 0b000000
1.16
1.17 +fontbase:
1.18 +.word 33
1.19 +
1.20 fontlimit:
1.21 .word 127
1.22 fonttable:
2.1 --- a/examples/vga/main.c Tue Nov 13 00:34:10 2018 +0100
2.2 +++ b/examples/vga/main.c Tue Nov 13 12:57:52 2018 +0100
2.3 @@ -97,10 +97,9 @@
2.4 static SpriteOverwriting(scr, &screendata, &display_config, SOURCE_YSTEP);
2.5
2.6 extern uint8_t fontchars[];
2.7 -extern uint32_t fonttable[];
2.8 -extern uint32_t fontbase, fontlimit;
2.9 +extern font_range_t fontbase;
2.10
2.11 -static font_config_t font_config;
2.12 +static Font(font_config, fontchars, &fontbase);
2.13
2.14
2.15
2.16 @@ -197,8 +196,6 @@
2.17 {
2.18 int frame, x = 0, y = 0;
2.19
2.20 - init_font(&font_config, fontchars, fonttable, fontbase, fontlimit);
2.21 -
2.22 for (frame = 0; frame < banner_config.frames; frame++)
2.23 {
2.24 /* Obtain the frame. */
3.1 --- a/include/font.h Tue Nov 13 00:34:10 2018 +0100
3.2 +++ b/include/font.h Tue Nov 13 12:57:52 2018 +0100
3.3 @@ -34,23 +34,36 @@
3.4
3.5 } char_definition_t;
3.6
3.7 +typedef struct
3.8 +{
3.9 + uint32_t base;
3.10 + uint32_t limit;
3.11 + uint32_t table[];
3.12 +
3.13 +} font_range_t;
3.14 +
3.15 /* Font configuration type. */
3.16
3.17 typedef struct
3.18 {
3.19 char_definition_t *chars;
3.20 - uint32_t *table;
3.21 - uint32_t base;
3.22 - uint32_t limit;
3.23 + font_range_t *range;
3.24
3.25 } font_config_t;
3.26
3.27
3.28
3.29 -/* Access functions. */
3.30 +/* Initialise a font.
3.31 +
3.32 + Font(<name>, uint8_t *chars, font_range_t *range)
3.33 +*/
3.34
3.35 -void init_font(font_config_t *cfg, uint8_t *chars, uint32_t *table,
3.36 - uint32_t base, uint32_t limit);
3.37 +#define Font(NAME, CHARS, RANGE) \
3.38 + font_config_t NAME = { \
3.39 + .chars = (char_definition_t *) (CHARS), \
3.40 + .range = RANGE};
3.41 +
3.42 +/* Access functions. */
3.43
3.44 char_definition_t *get_char_definition(font_config_t *cfg, char c);
3.45
4.1 --- a/lib/font.c Tue Nov 13 00:34:10 2018 +0100
4.2 +++ b/lib/font.c Tue Nov 13 12:57:52 2018 +0100
4.3 @@ -32,19 +32,6 @@
4.4
4.5
4.6
4.7 -/* Initialise a font configuration. */
4.8 -
4.9 -void init_font(font_config_t *cfg, uint8_t *chars, uint32_t *table,
4.10 - uint32_t base, uint32_t limit)
4.11 -{
4.12 - cfg->chars = (char_definition_t *) chars;
4.13 - cfg->table = table;
4.14 - cfg->base = base;
4.15 - cfg->limit = limit;
4.16 -}
4.17 -
4.18 -
4.19 -
4.20 /* Return the character definition for the given character. */
4.21
4.22 char_definition_t *get_char_definition(font_config_t *fcfg, char c)
4.23 @@ -52,8 +39,8 @@
4.24 /* Obtain the offset from the table and combine it with the character
4.25 definitions base address. */
4.26
4.27 - if ((c >= fcfg->base) && (c < fcfg->limit))
4.28 - return (char_definition_t *) ((uint8_t *) fcfg->chars + fcfg->table[c - fcfg->base]);
4.29 + if ((c >= fcfg->range->base) && (c < fcfg->range->limit))
4.30 + return (char_definition_t *) ((uint8_t *) fcfg->chars + fcfg->range->table[c - fcfg->range->base]);
4.31 else
4.32 return &space;
4.33 }
5.1 --- a/tools/makefont.py Tue Nov 13 00:34:10 2018 +0100
5.2 +++ b/tools/makefont.py Tue Nov 13 12:57:52 2018 +0100
5.3 @@ -76,10 +76,7 @@
5.4
5.5 .section .flash, "a"
5.6
5.7 -fontbase:
5.8 -.word %d
5.9 -
5.10 -fontchars:""" % base
5.11 +fontchars:"""
5.12
5.13 lineno = 1
5.14 offset = 0
5.15 @@ -108,8 +105,11 @@
5.16 # Write the limit of characters.
5.17
5.18 print >>f_out, """\
5.19 +fontbase:
5.20 +.word %d
5.21 +
5.22 fontlimit:
5.23 -.word %d""" % point
5.24 +.word %d""" % (base, point)
5.25
5.26 # Write the offset table.
5.27