1.1 --- a/lib/display.c Tue Oct 23 22:14:20 2018 +0200
1.2 +++ b/lib/display.c Tue Oct 23 23:25:47 2018 +0200
1.3 @@ -19,42 +19,38 @@
1.4
1.5 #include "display.h"
1.6
1.7 -/* Provided by the application. */
1.8 -
1.9 -#include "vga.h"
1.10 -
1.11
1.12
1.13 /* Return the line data position for the given pixel. */
1.14
1.15 -int get_position(int x)
1.16 +int get_position(display_config_t *cfg, int x)
1.17 {
1.18 - int cell = x / CELL_SIZE, offset = x % CELL_SIZE;
1.19 - int pos = (cell / 2) * CELL_SIZE + offset;
1.20 + int cell = x / cfg->cell_size, offset = x % cfg->cell_size;
1.21 + int pos = (cell / 2) * cfg->cell_size + offset;
1.22
1.23 - return cell % 2 ? pos + LINE_LENGTH / 2 : pos;
1.24 + return cell % 2 ? pos + cfg->line_length / 2 : pos;
1.25 }
1.26
1.27 /* Provide a pattern to test the line data. */
1.28
1.29 -void test_linedata(uint8_t *framebuffer)
1.30 +void test_linedata(display_config_t *cfg)
1.31 {
1.32 int x, y;
1.33 - uint8_t *linedata = framebuffer;
1.34 + uint8_t *linedata = cfg->framebuffer;
1.35
1.36 - for (y = 0; y < LINE_COUNT; y++)
1.37 + for (y = 0; y < cfg->line_count; y++)
1.38 {
1.39 - for (x = 0; x < LINE_LENGTH; x++)
1.40 + for (x = 0; x < cfg->line_length; x++)
1.41 {
1.42 /* Pixel: I0RRGGBB = Y0YYYYXX */
1.43
1.44 - linedata[get_position(x)] = (x % 2) ?
1.45 - (((y / (LINE_COUNT / 32)) & 0b1) << 7) |
1.46 - (((y / (LINE_COUNT / 16)) & 0b1111) << 2) |
1.47 - ((x / (LINE_LENGTH / 4)) & 0b11) :
1.48 + linedata[get_position(cfg, x)] = (x % 2) ?
1.49 + (((y / (cfg->line_count / 32)) & 0b1) << 7) |
1.50 + (((y / (cfg->line_count / 16)) & 0b1111) << 2) |
1.51 + ((x / (cfg->line_length / 4)) & 0b11) :
1.52 0x00;
1.53 }
1.54
1.55 - linedata += LINE_LENGTH;
1.56 + linedata += cfg->line_length;
1.57 }
1.58 }