1.1 --- a/examples/vga/main.c Sat Nov 03 14:05:05 2018 +0100
1.2 +++ b/examples/vga/main.c Sat Nov 03 16:42:17 2018 +0100
1.3 @@ -163,6 +163,9 @@
1.4 sprite_width, sprite_height,
1.5 x, y, 0x8c, 1);
1.6
1.7 + /* Update the display with the frame details. */
1.8 +
1.9 + vga_set_frame(&display_config);
1.10 wait(delay);
1.11
1.12 /* Copy to the display from the store, restoring the original
2.1 --- a/include/vga_display.h Sat Nov 03 14:05:05 2018 +0100
2.2 +++ b/include/vga_display.h Sat Nov 03 16:42:17 2018 +0100
2.3 @@ -50,9 +50,13 @@
2.4
2.5 uint32_t line;
2.6
2.7 - /* Pointers to pixel lines. */
2.8 + /* Screen start address, frame limit, current pixel line. */
2.9 +
2.10 + uint8_t *screen_start, *screen_limit, *linedata;
2.11
2.12 - uint8_t *linedata;
2.13 + /* Screen size, used to wrap the current line pointer. */
2.14 +
2.15 + uint32_t screen_size;
2.16
2.17 /* General display configuration. */
2.18
2.19 @@ -84,6 +88,10 @@
2.20 void vga_configure_zero_channel(int channel, int int_num, int initiating,
2.21 uint32_t output);
2.22
2.23 +/* Frame selection. */
2.24 +
2.25 +void vga_set_frame(display_config_t *display_config);
2.26 +
2.27 /* Interrupt handlers. */
2.28
2.29 void vga_interrupt_handler(void);
3.1 --- a/lib/vga_display.c Sat Nov 03 14:05:05 2018 +0100
3.2 +++ b/lib/vga_display.c Sat Nov 03 16:42:17 2018 +0100
3.3 @@ -58,6 +58,10 @@
3.4 Otherwise, transfers are initiated by the line timer. */
3.5
3.6 vga_display.transfer_int_num = transfer_int_num;
3.7 +
3.8 + /* Update the addresses used for the display. */
3.9 +
3.10 + vga_set_frame(display_config);
3.11 }
3.12
3.13 /* Initialise a separate transfer timer if different from the general display
3.14 @@ -243,6 +247,17 @@
3.15
3.16
3.17
3.18 +/* Update the display addresses from the general display configuration. */
3.19 +
3.20 +void vga_set_frame(display_config_t *display_config)
3.21 +{
3.22 + vga_display.screen_start = display_config->screen_start;
3.23 + vga_display.screen_limit = display_config->screen_limit;
3.24 + vga_display.screen_size = display_config->screen_size;
3.25 +}
3.26 +
3.27 +
3.28 +
3.29 /* Display state machine interrupt handler. */
3.30
3.31 void vga_interrupt_handler(void)
3.32 @@ -325,7 +340,7 @@
3.33
3.34 /* Set the line address. */
3.35
3.36 - vga_display.linedata = vga_display.display_config->screen_start;
3.37 + vga_display.linedata = vga_display.screen_start;
3.38
3.39 if (vga_display.line_channels)
3.40 start_visible();
3.41 @@ -345,8 +360,8 @@
3.42 {
3.43 vga_display.linedata += cfg->line_length;
3.44
3.45 - if (vga_display.linedata >= cfg->screen_limit)
3.46 - vga_display.linedata -= cfg->screen_size;
3.47 + if (vga_display.linedata >= vga_display.screen_limit)
3.48 + vga_display.linedata -= vga_display.screen_size;
3.49 }
3.50
3.51 if (vga_display.line_channels)