1.1 --- a/examples/vga/main.c Tue Oct 30 18:22:22 2018 +0100
1.2 +++ b/examples/vga/main.c Tue Oct 30 19:21:53 2018 +0100
1.3 @@ -24,11 +24,12 @@
1.4
1.5 /* Specific functionality. */
1.6
1.7 -#include "main.h"
1.8 #include "devconfig.h"
1.9 -#include "vga.h"
1.10 #include "display.h"
1.11 #include "display_config.h"
1.12 +#include "font.h"
1.13 +#include "main.h"
1.14 +#include "vga.h"
1.15 #include "vga_display.h"
1.16
1.17
1.18 @@ -63,13 +64,19 @@
1.19
1.20
1.21
1.22 -/* Bundled image data. */
1.23 +/* Bundled image and font data. */
1.24
1.25 extern uint8_t screendata[];
1.26 extern uint32_t screendata_width, screendata_height;
1.27 extern uint8_t sprite[];
1.28 extern uint32_t sprite_width, sprite_height;
1.29
1.30 +extern uint8_t fontchars[];
1.31 +extern uint32_t fonttable[];
1.32 +extern uint32_t fontbase, fontlimit;
1.33 +
1.34 +static font_config_t font_config;
1.35 +
1.36
1.37
1.38 /* Busy wait. */
1.39 @@ -125,6 +132,30 @@
1.40 }
1.41 }
1.42
1.43 +/* Fill the screen with characters. */
1.44 +
1.45 +static void write_chars(void)
1.46 +{
1.47 + int x = 0, y = 0;
1.48 + char c;
1.49 +
1.50 + font_config.chars = (char_definition_t *) fontchars;
1.51 + font_config.table = fonttable;
1.52 + font_config.base = fontbase;
1.53 + font_config.limit = fontlimit;
1.54 +
1.55 + while (y < display_config.line_count)
1.56 + for (c = (char) font_config.base; c < (char) font_config.limit; c++)
1.57 + {
1.58 + x = write_char(&display_config, &font_config, c, x, y, 0xff);
1.59 +
1.60 + if (x > display_config.line_length)
1.61 + {
1.62 + x = 0; y += 9;
1.63 + }
1.64 + }
1.65 +}
1.66 +
1.67
1.68
1.69 /* Main program. */
1.70 @@ -174,6 +205,10 @@
1.71 copy_display(&display_config, screendata, screendata_width, screendata_height,
1.72 (LINE_LENGTH - screendata_width) / 2, (LINE_COUNT - screendata_height) / 2, -1, 1);
1.73
1.74 + /* Write a sequence of characters. */
1.75 +
1.76 + write_chars();
1.77 +
1.78 /* Move a sprite around on the screen with a delay between each movement. */
1.79
1.80 animate(1 << 24);