1.1 --- a/examples/vga/main.c Tue Oct 30 23:59:47 2018 +0100
1.2 +++ b/examples/vga/main.c Wed Oct 31 18:02:07 2018 +0100
1.3 @@ -113,23 +113,75 @@
1.4 {
1.5 uint8_t background[sprite_width * sprite_height];
1.6 int x, y;
1.7 + int dir[] = {1, 0, -1, 0, 1}, i = 0, width, column_width;
1.8 + int xsource, xdisplay, xorigin = 0;
1.9
1.10 while (1)
1.11 + {
1.12 for (y = 0; y < screendata_height - sprite_height; y++)
1.13 + {
1.14 for (x = 0; x < screendata_width - sprite_width; x++)
1.15 {
1.16 /* Copy to the store from the display, then blit the image. */
1.17
1.18 - copy_display(&display_config, background, sprite_width, sprite_height, x, y, -1, 0);
1.19 - copy_display(&display_config, sprite, sprite_width, sprite_height, x, y, 0x8c, 1);
1.20 + copy_display(&display_config, background,
1.21 + sprite_width, sprite_height,
1.22 + x, y, -1, 0);
1.23 + copy_display(&display_config, sprite,
1.24 + sprite_width, sprite_height,
1.25 + x, y, 0x8c, 1);
1.26
1.27 wait(delay);
1.28
1.29 /* Copy to the display from the store, restoring the original
1.30 background. */
1.31
1.32 - copy_display(&display_config, background, sprite_width, sprite_height, x, y, -1, 1);
1.33 + copy_display(&display_config, background,
1.34 + sprite_width, sprite_height,
1.35 + x, y, -1, 1);
1.36 +
1.37 + /* Scroll in the indicated direction. */
1.38 +
1.39 + scroll_display(&display_config, dir[i], dir[i + 1]);
1.40 +
1.41 + /* For horizontal scrolling, plot the exposed column at the left
1.42 + (if scrolling left) or at the right (if scrolling right). */
1.43 +
1.44 + if (dir[i])
1.45 + {
1.46 + /* Due to the effect of a simple screen start increment in
1.47 + the dual channel configuration, horizontal scrolling
1.48 + involves two pixel increments and thus requires a two-
1.49 + pixel column to be plotted. */
1.50 +
1.51 + width = dir[i] * LINE_CHANNELS;
1.52 + column_width = width < 0 ? -width : width;
1.53 +
1.54 + /* Plot either at the left or right edge. */
1.55 +
1.56 + xdisplay = width < 0 ? 0 : screendata_width - width;
1.57 +
1.58 + /* Determine the location of the column to be plotted. */
1.59 +
1.60 + xorigin += width;
1.61 + xsource = (xdisplay + xorigin) % screendata_width;
1.62 +
1.63 + copy_display_section(&display_config, screendata,
1.64 + screendata_width, screendata_height,
1.65 + xsource, 0,
1.66 + column_width, screendata_height,
1.67 + xdisplay, 0,
1.68 + -1, 1);
1.69 + }
1.70 }
1.71 +
1.72 + /* Switch direction periodically. */
1.73 +
1.74 + i++;
1.75 + if (i == 4)
1.76 + i = 0;
1.77 + }
1.78 + }
1.79 }
1.80
1.81 /* Fill the screen with characters. */
1.82 @@ -203,7 +255,8 @@
1.83 /* Plot the image centred on the screen. */
1.84
1.85 copy_display(&display_config, screendata, screendata_width, screendata_height,
1.86 - (LINE_LENGTH - screendata_width) / 2, (LINE_COUNT - screendata_height) / 2, -1, 1);
1.87 + (LINE_LENGTH - screendata_width) / 2,
1.88 + (LINE_COUNT - screendata_height) / 2, -1, 1);
1.89
1.90 /* Write a sequence of characters. */
1.91
1.92 @@ -211,7 +264,7 @@
1.93
1.94 /* Move a sprite around on the screen with a delay between each movement. */
1.95
1.96 - animate(1 << 24);
1.97 + animate(1 << 21);
1.98 }
1.99
1.100