1.1 --- a/examples/vga/main.c Tue Nov 13 00:02:15 2018 +0100
1.2 +++ b/examples/vga/main.c Tue Nov 13 00:05:51 2018 +0100
1.3 @@ -84,7 +84,8 @@
1.4
1.5 /* Initialise memory for a multi-frame display. */
1.6
1.7 -static Display(display_config, LINE_LENGTH, LINE_COUNT, FRAME_COUNT);
1.8 +static Display(banner_config, LINE_LENGTH, 10, 1);
1.9 +static Display(display_config, LINE_LENGTH, LINE_COUNT - 10, FRAME_COUNT);
1.10
1.11
1.12
1.13 @@ -153,7 +154,7 @@
1.14
1.15 /* Update the display with the frame details. */
1.16
1.17 - vga_set_frame(&display_config);
1.18 + vga_set_frame(&display_config, 1);
1.19 wait(delay);
1.20
1.21 /* Select the next frame to plot to. */
1.22 @@ -190,36 +191,29 @@
1.23 }
1.24 }
1.25
1.26 -/* Fill the screen with characters. */
1.27 +/* Set up a banner. */
1.28
1.29 -static void write_chars(void)
1.30 +static void setup_banner(void)
1.31 {
1.32 - const int line_height = 9;
1.33 - int x = 0, y = 0;
1.34 - char c;
1.35 + int frame, x = 0, y = 0;
1.36
1.37 init_font(&font_config, fontchars, fonttable, fontbase, fontlimit);
1.38
1.39 - while (y + line_height < display_config.line_count)
1.40 + for (frame = 0; frame < banner_config.frames; frame++)
1.41 {
1.42 - for (c = (char) font_config.base; c < (char) font_config.limit; c++)
1.43 - {
1.44 - if (x + get_char_definition(&font_config, c)->width > display_config.line_length)
1.45 - {
1.46 - x = 0; y += line_height;
1.47 - }
1.48 + /* Obtain the frame. */
1.49 +
1.50 + display_select_frame(&banner_config, frame);
1.51
1.52 - if (y + line_height >= display_config.line_count)
1.53 - break;
1.54 + write_string(&banner_config, &font_config, "VGA display example", &x, &y, 0xff);
1.55 + }
1.56
1.57 - x = write_char(&display_config, &font_config, c, x, y, 0xff);
1.58 - }
1.59 - }
1.60 + display_select_frame(&banner_config, 0);
1.61 }
1.62
1.63 /* Set up a background. */
1.64
1.65 -static void setup(void)
1.66 +static void setup_background(void)
1.67 {
1.68 int frame;
1.69
1.70 @@ -234,15 +228,17 @@
1.71 image_tile_sprite(&scr, 0, 0, display_config.line_length,
1.72 display_config.line_count * scr.yscale,
1.73 0, 0);
1.74 -
1.75 - /* Write a sequence of characters. */
1.76 -
1.77 - write_chars();
1.78 }
1.79
1.80 display_select_frame(&display_config, 0);
1.81 }
1.82
1.83 +static void setup(void)
1.84 +{
1.85 + setup_banner();
1.86 + setup_background();
1.87 +}
1.88 +
1.89
1.90
1.91 /* Main program. */
1.92 @@ -277,13 +273,15 @@
1.93
1.94 /* Set the display to a well-defined state. */
1.95
1.96 + init_display(&banner_config);
1.97 init_display(&display_config);
1.98
1.99 /* Initialise VGA output with one or two line channels, configuring a line
1.100 timer and any transfer timer, with an initiating channel being introduced
1.101 if a transfer timer is specified. */
1.102
1.103 - init_vga_with_timers(&display_config, LINE_CHANNELS, LINE_TIMER, TRANSFER_TIMER);
1.104 + init_vga_with_timers(&banner_config, LINE_CHANNELS, LINE_TIMER, TRANSFER_TIMER);
1.105 + vga_add_window(&display_config);
1.106
1.107 /* Configure VGA output transfer to the output register, also configuring
1.108 output compare units for horizontal and vertical sync. */