From e73f4861161e20dc2c2ea7eeca798ea4df6087e0 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Sat, 2 Mar 2024 18:49:44 +0100 Subject: [PATCH] changed pixels considered in showCanvas --- test01.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/test01.c b/test01.c index 377ecfe..1ad4c96 100644 --- a/test01.c +++ b/test01.c @@ -50,10 +50,18 @@ void showCanvas() { for (uint8_t y = 0; y < CANVAS_HEIGHT; y++) { for (uint8_t x = 0; x < CANVAS_WIDTH; x++) { printf("%02x ", canvas[x][y]); - canvas[x][y] &= ~0x80; } printf("\n"); } + printf("Changed pixels: "); + for (uint8_t y = 0; y < CANVAS_HEIGHT; y++) { + for (uint8_t x = 0; x < CANVAS_WIDTH; x++) { + if (canvas[x][y] & 0x80) { + canvas[x][y] &= ~0x80; + printf("0x%02x,0x%02x=0x%02x ", x, y, canvas[x][y]); + } + } + } printf("\n"); } @@ -82,33 +90,33 @@ void initObject(t_shape shape, uint8_t x, uint8_t y) { } void drawObject() { + // the bit7 set marks changed pixels if (object.initial == 0) { // wipe switch (object.shape) { case e_O: switch (object.last_rotation) { case 0: - canvas[object.last_x][object.last_y] = 0; - canvas[object.last_x][object.last_y+1] = 0; - canvas[object.last_x+1][object.last_y] = 0; - canvas[object.last_x+1][object.last_y+1] = 0; + canvas[object.last_x][object.last_y] = 0 | 0x80; + canvas[object.last_x][object.last_y+1] = 0 | 0x80; + canvas[object.last_x+1][object.last_y] = 0 | 0x80; + canvas[object.last_x+1][object.last_y+1] = 0 | 0x80; break; } break; case e_I: switch (object.last_rotation) { case 0: - canvas[object.last_x][object.last_y] = 0; - canvas[object.last_x][object.last_y+1] = 0; - canvas[object.last_x][object.last_y+2] = 0; - canvas[object.last_x][object.last_y+3] = 0; + canvas[object.last_x][object.last_y] = 0 | 0x80; + canvas[object.last_x][object.last_y+1] = 0 | 0x80; + canvas[object.last_x][object.last_y+2] = 0 | 0x80; + canvas[object.last_x][object.last_y+3] = 0 | 0x80; break; } break; } } // draw - // the bit7 set marks changed pixels switch (object.shape) { case e_O: switch (object.rotation) {