# HG changeset patch # User Paul Boddie # Date 1541259737 -3600 # Node ID 51cbfbb4c17e00d139836f07d39cd24fb9c9c792 # Parent 254ee12221e275699dd9252be7b494bc13b4c7f3 Maintain separate addresses for updating the display, permitting access to off-screen framebuffers. diff -r 254ee12221e2 -r 51cbfbb4c17e examples/vga/main.c --- a/examples/vga/main.c Sat Nov 03 14:05:05 2018 +0100 +++ b/examples/vga/main.c Sat Nov 03 16:42:17 2018 +0100 @@ -163,6 +163,9 @@ sprite_width, sprite_height, x, y, 0x8c, 1); + /* Update the display with the frame details. */ + + vga_set_frame(&display_config); wait(delay); /* Copy to the display from the store, restoring the original diff -r 254ee12221e2 -r 51cbfbb4c17e include/vga_display.h --- a/include/vga_display.h Sat Nov 03 14:05:05 2018 +0100 +++ b/include/vga_display.h Sat Nov 03 16:42:17 2018 +0100 @@ -50,9 +50,13 @@ uint32_t line; - /* Pointers to pixel lines. */ + /* Screen start address, frame limit, current pixel line. */ + + uint8_t *screen_start, *screen_limit, *linedata; - uint8_t *linedata; + /* Screen size, used to wrap the current line pointer. */ + + uint32_t screen_size; /* General display configuration. */ @@ -84,6 +88,10 @@ void vga_configure_zero_channel(int channel, int int_num, int initiating, uint32_t output); +/* Frame selection. */ + +void vga_set_frame(display_config_t *display_config); + /* Interrupt handlers. */ void vga_interrupt_handler(void); diff -r 254ee12221e2 -r 51cbfbb4c17e lib/vga_display.c --- a/lib/vga_display.c Sat Nov 03 14:05:05 2018 +0100 +++ b/lib/vga_display.c Sat Nov 03 16:42:17 2018 +0100 @@ -58,6 +58,10 @@ Otherwise, transfers are initiated by the line timer. */ vga_display.transfer_int_num = transfer_int_num; + + /* Update the addresses used for the display. */ + + vga_set_frame(display_config); } /* Initialise a separate transfer timer if different from the general display @@ -243,6 +247,17 @@ +/* Update the display addresses from the general display configuration. */ + +void vga_set_frame(display_config_t *display_config) +{ + vga_display.screen_start = display_config->screen_start; + vga_display.screen_limit = display_config->screen_limit; + vga_display.screen_size = display_config->screen_size; +} + + + /* Display state machine interrupt handler. */ void vga_interrupt_handler(void) @@ -325,7 +340,7 @@ /* Set the line address. */ - vga_display.linedata = vga_display.display_config->screen_start; + vga_display.linedata = vga_display.screen_start; if (vga_display.line_channels) start_visible(); @@ -345,8 +360,8 @@ { vga_display.linedata += cfg->line_length; - if (vga_display.linedata >= cfg->screen_limit) - vga_display.linedata -= cfg->screen_size; + if (vga_display.linedata >= vga_display.screen_limit) + vga_display.linedata -= vga_display.screen_size; } if (vga_display.line_channels)