changed pixel bit added
This commit is contained in:
parent
35113cc6cd
commit
0a474f59d8
21
test01.c
21
test01.c
@ -14,7 +14,7 @@ uint8_t canvas[CANVAS_WIDTH][CANVAS_HEIGHT];
|
|||||||
|
|
||||||
#define I_HEIGHT 4
|
#define I_HEIGHT 4
|
||||||
#define I_WIDTH 1
|
#define I_WIDTH 1
|
||||||
#define I_COLOR 1
|
#define I_COLOR 2
|
||||||
|
|
||||||
typedef enum {e_O, e_I} t_shape;
|
typedef enum {e_O, e_I} t_shape;
|
||||||
|
|
||||||
@ -50,6 +50,7 @@ void showCanvas() {
|
|||||||
for (uint8_t y = 0; y < CANVAS_HEIGHT; y++) {
|
for (uint8_t y = 0; y < CANVAS_HEIGHT; y++) {
|
||||||
for (uint8_t x = 0; x < CANVAS_WIDTH; x++) {
|
for (uint8_t x = 0; x < CANVAS_WIDTH; x++) {
|
||||||
printf("%02x ", canvas[x][y]);
|
printf("%02x ", canvas[x][y]);
|
||||||
|
canvas[x][y] &= ~0x80;
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
@ -107,24 +108,25 @@ void drawObject() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// draw
|
// draw
|
||||||
|
// the bit7 set marks changed pixels
|
||||||
switch (object.shape) {
|
switch (object.shape) {
|
||||||
case e_O:
|
case e_O:
|
||||||
switch (object.rotation) {
|
switch (object.rotation) {
|
||||||
case 0:
|
case 0:
|
||||||
canvas[object.x][object.y] = object.O[0][0];
|
canvas[object.x][object.y] = object.O[0][0] | 0x80;
|
||||||
canvas[object.x][object.y+1] = object.O[0][1];
|
canvas[object.x][object.y+1] = object.O[0][1] | 0x80;
|
||||||
canvas[object.x+1][object.y] = object.O[1][0];
|
canvas[object.x+1][object.y] = object.O[1][0] | 0x80;
|
||||||
canvas[object.x+1][object.y+1] = object.O[1][1];
|
canvas[object.x+1][object.y+1] = object.O[1][1] | 0x80;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case e_I:
|
case e_I:
|
||||||
switch (object.rotation) {
|
switch (object.rotation) {
|
||||||
case 0:
|
case 0:
|
||||||
canvas[object.x][object.y] = object.O[0][0];
|
canvas[object.x][object.y] = object.O[0][0] | 0x80;
|
||||||
canvas[object.x][object.y+1] = object.O[0][1];
|
canvas[object.x][object.y+1] = object.O[0][1] | 0x80;
|
||||||
canvas[object.x][object.y+2] = object.O[0][2];
|
canvas[object.x][object.y+2] = object.O[0][2] | 0x80;
|
||||||
canvas[object.x][object.y+3] = object.O[0][3];
|
canvas[object.x][object.y+3] = object.O[0][3] | 0x80;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -163,6 +165,7 @@ int checkCanvasBordersForObject() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int checkOtherObjectsTouchedForObject() {
|
int checkOtherObjectsTouchedForObject() {
|
||||||
|
return 0;
|
||||||
// return true if another object is touched
|
// return true if another object is touched
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user