1.1 --- a/examples/vga/main.c Sun Nov 04 16:14:58 2018 +0100
1.2 +++ b/examples/vga/main.c Sun Nov 04 18:13:06 2018 +0100
1.3 @@ -81,6 +81,16 @@
1.4
1.5
1.6
1.7 +/* Define the relationship between source images and the screen. */
1.8 +
1.9 +#ifndef SOURCE_HEIGHT
1.10 +#define SOURCE_HEIGHT 256
1.11 +#endif
1.12 +
1.13 +#define SOURCE_YSTEP (SOURCE_HEIGHT / LINE_COUNT)
1.14 +
1.15 +
1.16 +
1.17 /* Framebuffer memory. */
1.18
1.19 static uint8_t framebuffer[FRAME_SIZE * FRAME_COUNT];
1.20 @@ -135,10 +145,10 @@
1.21 static void plot_sprite(uint8_t *background, int x, int y)
1.22 {
1.23 copy_display(&display_config, background,
1.24 - sprite_width, sprite_height,
1.25 + sprite_width, sprite_height / SOURCE_YSTEP, 1,
1.26 x, y, -1, 0);
1.27 copy_display(&display_config, sprite,
1.28 - sprite_width, sprite_height,
1.29 + sprite_width, sprite_height, SOURCE_YSTEP,
1.30 x, y, 0x8c, 1);
1.31 }
1.32
1.33 @@ -147,7 +157,7 @@
1.34 static void unplot_sprite(uint8_t *background, int x, int y)
1.35 {
1.36 copy_display(&display_config, background,
1.37 - sprite_width, sprite_height,
1.38 + sprite_width, sprite_height / SOURCE_YSTEP, 1,
1.39 x, y, -1, 1);
1.40 }
1.41
1.42 @@ -177,6 +187,7 @@
1.43 screendata_width, screendata_height,
1.44 xsource, yorigin,
1.45 width, screendata_height - yorigin,
1.46 + SOURCE_YSTEP,
1.47 xdisplay, 0,
1.48 -1, 1);
1.49
1.50 @@ -190,7 +201,8 @@
1.51 screendata_width, screendata_height,
1.52 xsource, 0,
1.53 width, yorigin,
1.54 - xdisplay, screendata_height - yorigin,
1.55 + SOURCE_YSTEP,
1.56 + xdisplay, (screendata_height - yorigin) / SOURCE_YSTEP,
1.57 -1, 1);
1.58 }
1.59
1.60 @@ -213,7 +225,7 @@
1.61 {
1.62 /* Stored region behind the sprite. */
1.63
1.64 - uint8_t background[sprite_width * sprite_height];
1.65 + uint8_t background[(sprite_width * sprite_height) / SOURCE_YSTEP];
1.66
1.67 /* Sprite position. */
1.68
1.69 @@ -257,7 +269,8 @@
1.70 /* Update the vertical origin if appropriate. */
1.71
1.72 if (ydir)
1.73 - yorigin = wrap_value(yorigin + ydir, screendata_height);
1.74 + yorigin = wrap_value(yorigin + ydir * SOURCE_YSTEP,
1.75 + screendata_height);
1.76
1.77 /* For horizontal scrolling, plot the exposed column at the left
1.78 (if scrolling left) or at the right (if scrolling right). */
1.79 @@ -326,9 +339,12 @@
1.80
1.81 /* Plot the image centred on the screen. */
1.82
1.83 - copy_display(&display_config, screendata, screendata_width, screendata_height,
1.84 + copy_display(&display_config, screendata,
1.85 + screendata_width, screendata_height,
1.86 + SOURCE_YSTEP,
1.87 (display_config.line_length - screendata_width) / 2,
1.88 - (display_config.line_count - screendata_height) / 2, -1, 1);
1.89 + (display_config.line_count - (screendata_height / SOURCE_YSTEP)) / 2,
1.90 + -1, 1);
1.91
1.92 /* Write a sequence of characters. */
1.93