1.1 --- a/examples/vga-timer/Makefile Sun Nov 04 16:14:58 2018 +0100
1.2 +++ b/examples/vga-timer/Makefile Sun Nov 04 18:13:06 2018 +0100
1.3 @@ -33,6 +33,6 @@
1.4 # Application-specific adjustments.
1.5 # See: examples/vga/Makefile
1.6
1.7 -CFLAGS += -DLINE_CHANNELS=2 -DTRANSFER_TIMER=3 -I../vga
1.8 +CFLAGS += -DLINE_CHANNELS=2 -DTRANSFER_TIMER=3 -DSOURCE_HEIGHT=128 -I../vga
1.9
1.10 include ../../mk/rules.mk
2.1 --- a/examples/vga/main.c Sun Nov 04 16:14:58 2018 +0100
2.2 +++ b/examples/vga/main.c Sun Nov 04 18:13:06 2018 +0100
2.3 @@ -81,6 +81,16 @@
2.4
2.5
2.6
2.7 +/* Define the relationship between source images and the screen. */
2.8 +
2.9 +#ifndef SOURCE_HEIGHT
2.10 +#define SOURCE_HEIGHT 256
2.11 +#endif
2.12 +
2.13 +#define SOURCE_YSTEP (SOURCE_HEIGHT / LINE_COUNT)
2.14 +
2.15 +
2.16 +
2.17 /* Framebuffer memory. */
2.18
2.19 static uint8_t framebuffer[FRAME_SIZE * FRAME_COUNT];
2.20 @@ -135,10 +145,10 @@
2.21 static void plot_sprite(uint8_t *background, int x, int y)
2.22 {
2.23 copy_display(&display_config, background,
2.24 - sprite_width, sprite_height,
2.25 + sprite_width, sprite_height / SOURCE_YSTEP, 1,
2.26 x, y, -1, 0);
2.27 copy_display(&display_config, sprite,
2.28 - sprite_width, sprite_height,
2.29 + sprite_width, sprite_height, SOURCE_YSTEP,
2.30 x, y, 0x8c, 1);
2.31 }
2.32
2.33 @@ -147,7 +157,7 @@
2.34 static void unplot_sprite(uint8_t *background, int x, int y)
2.35 {
2.36 copy_display(&display_config, background,
2.37 - sprite_width, sprite_height,
2.38 + sprite_width, sprite_height / SOURCE_YSTEP, 1,
2.39 x, y, -1, 1);
2.40 }
2.41
2.42 @@ -177,6 +187,7 @@
2.43 screendata_width, screendata_height,
2.44 xsource, yorigin,
2.45 width, screendata_height - yorigin,
2.46 + SOURCE_YSTEP,
2.47 xdisplay, 0,
2.48 -1, 1);
2.49
2.50 @@ -190,7 +201,8 @@
2.51 screendata_width, screendata_height,
2.52 xsource, 0,
2.53 width, yorigin,
2.54 - xdisplay, screendata_height - yorigin,
2.55 + SOURCE_YSTEP,
2.56 + xdisplay, (screendata_height - yorigin) / SOURCE_YSTEP,
2.57 -1, 1);
2.58 }
2.59
2.60 @@ -213,7 +225,7 @@
2.61 {
2.62 /* Stored region behind the sprite. */
2.63
2.64 - uint8_t background[sprite_width * sprite_height];
2.65 + uint8_t background[(sprite_width * sprite_height) / SOURCE_YSTEP];
2.66
2.67 /* Sprite position. */
2.68
2.69 @@ -257,7 +269,8 @@
2.70 /* Update the vertical origin if appropriate. */
2.71
2.72 if (ydir)
2.73 - yorigin = wrap_value(yorigin + ydir, screendata_height);
2.74 + yorigin = wrap_value(yorigin + ydir * SOURCE_YSTEP,
2.75 + screendata_height);
2.76
2.77 /* For horizontal scrolling, plot the exposed column at the left
2.78 (if scrolling left) or at the right (if scrolling right). */
2.79 @@ -326,9 +339,12 @@
2.80
2.81 /* Plot the image centred on the screen. */
2.82
2.83 - copy_display(&display_config, screendata, screendata_width, screendata_height,
2.84 + copy_display(&display_config, screendata,
2.85 + screendata_width, screendata_height,
2.86 + SOURCE_YSTEP,
2.87 (display_config.line_length - screendata_width) / 2,
2.88 - (display_config.line_count - screendata_height) / 2, -1, 1);
2.89 + (display_config.line_count - (screendata_height / SOURCE_YSTEP)) / 2,
2.90 + -1, 1);
2.91
2.92 /* Write a sequence of characters. */
2.93
3.1 --- a/include/display.h Sun Nov 04 16:14:58 2018 +0100
3.2 +++ b/include/display.h Sun Nov 04 18:13:06 2018 +0100
3.3 @@ -105,12 +105,13 @@
3.4
3.5 void test_linedata(display_config_t *cfg);
3.6
3.7 -void copy_display(display_config_t *cfg, uint8_t *store, int width, int height,
3.8 +void copy_display(display_config_t *cfg, uint8_t *store,
3.9 + int width, int height, int ystep,
3.10 int x, int y, int key, int to_display);
3.11
3.12 void copy_display_section(display_config_t *cfg, uint8_t *store,
3.13 int width, int height,
3.14 - int xstart, int ystart, int xsize, int ysize,
3.15 + int xstart, int ystart, int xsize, int ysize, int ystep,
3.16 int x, int y, int key, int to_display);
3.17
3.18 void scroll_display(display_config_t *cfg, int x, int y);
4.1 --- a/lib/display.c Sun Nov 04 16:14:58 2018 +0100
4.2 +++ b/lib/display.c Sun Nov 04 18:13:06 2018 +0100
4.3 @@ -153,18 +153,20 @@
4.4
4.5 /* Copying from/to the display to/from a backing store. */
4.6
4.7 -void copy_display(display_config_t *cfg, uint8_t *store, int width, int height,
4.8 +void copy_display(display_config_t *cfg, uint8_t *store,
4.9 + int width, int height, int ystep,
4.10 int x, int y, int key, int to_display)
4.11 {
4.12 - copy_display_section(cfg, store, width, height, 0, 0, width, height, x, y,
4.13 - key, to_display);
4.14 + copy_display_section(cfg, store, width, height,
4.15 + 0, 0, width, height, ystep,
4.16 + x, y, key, to_display);
4.17 }
4.18
4.19 /* Copying from/to the display to/from a backing store region. */
4.20
4.21 void copy_display_section(display_config_t *cfg, uint8_t *store,
4.22 int width, int height,
4.23 - int xstart, int ystart, int xsize, int ysize,
4.24 + int xstart, int ystart, int xsize, int ysize, int ystep,
4.25 int x, int y, int key, int to_display)
4.26 {
4.27 int sx, sy, dx, dy;
4.28 @@ -184,7 +186,7 @@
4.29
4.30 /* Perform the copying between the store and display. */
4.31
4.32 - for (sy = ystart, dy = y; (sy < ylimit) && (dy < cfg->line_count); sy++, dy++)
4.33 + for (sy = ystart, dy = y; (sy < ylimit) && (dy < cfg->line_count); sy += ystep, dy++)
4.34 {
4.35 for (sx = xstart, dx = x; (sx < xlimit) && (dx < cfg->line_length); sx++, dx++)
4.36 {
4.37 @@ -198,7 +200,7 @@
4.38 storeline[sx] = displayline[get_position(cfg, dx)];
4.39 }
4.40
4.41 - storeline += width;
4.42 + storeline += width * ystep;
4.43 displayline = wrap_screen_pointer(cfg, displayline + cfg->line_length);
4.44 }
4.45 }