1.1 --- a/lib/display.c Mon Oct 29 01:43:42 2018 +0100
1.2 +++ b/lib/display.c Mon Oct 29 01:46:31 2018 +0100
1.3 @@ -55,21 +55,31 @@
1.4 }
1.5 }
1.6
1.7 -/* Copy to framebuffer. */
1.8 +/* Copying from/to the display to/from a backing store. */
1.9
1.10 -void copy_to_framebuffer(display_config_t *cfg, uint8_t *image, int width, int height)
1.11 +void copy_display(display_config_t *cfg, uint8_t *store, int width, int height,
1.12 + int x, int y, int key, int to_display)
1.13 {
1.14 - int sx, sy, tx, ty;
1.15 - uint8_t *targetline = cfg->framebuffer, *sourceline = image;
1.16 + int sx, sy, dx, dy;
1.17 + uint8_t *storeline = store,
1.18 + *displayline = cfg->framebuffer + y * cfg->line_length,
1.19 + pixel;
1.20
1.21 - for (sy = 0, ty = 0; (sy < height) && (ty < cfg->line_count); sy++, ty++)
1.22 + for (sy = 0, dy = y; (sy < height) && (dy < cfg->line_count); sy++, dy++)
1.23 {
1.24 - for (sx = 0, tx = 0; (tx < cfg->line_length); sx++, tx++)
1.25 + for (sx = 0, dx = x; (sx < width) && (dx < cfg->line_length); sx++, dx++)
1.26 {
1.27 - targetline[get_position(cfg, tx)] = (sx < width) ? sourceline[sx] : 0;
1.28 + if (to_display)
1.29 + {
1.30 + pixel = storeline[sx];
1.31 + if ((key < 0) || (pixel != key))
1.32 + displayline[get_position(cfg, dx)] = pixel;
1.33 + }
1.34 + else
1.35 + storeline[sx] = displayline[get_position(cfg, dx)];
1.36 }
1.37
1.38 - sourceline += width;
1.39 - targetline += cfg->line_length;
1.40 + storeline += width;
1.41 + displayline += cfg->line_length;
1.42 }
1.43 }