changed pixels considered in showCanvas
This commit is contained in:
parent
0a474f59d8
commit
e73f486116
28
test01.c
28
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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user