This repository has been archived on 2024-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
game-ctrl-01/displayTest.c

185 lines
4.1 KiB
C
Raw Permalink Normal View History

2024-03-08 09:57:47 +01:00
#include <stdlib.h>
#include "canvas.h"
#include "PontCoopScheduler.h"
2024-03-08 14:07:09 +01:00
#define MAX_COLOR 0x0d
2024-03-08 09:57:47 +01:00
2024-03-08 15:54:34 +01:00
typedef enum {
e_WIPE_LAST_COLUMN_DOWN,
e_PIXELS_UP,
e_WIPE_LAST_PIXEL_UP,
e_PIXELS_DOWN,
e_WIPE_LAST_PIXEL_DOWN,
e_ROWS_UP,
e_WIPE_LAST_ROW_UP,
e_ROWS_DOWN,
e_WIPE_LAST_ROW_DOWN,
e_COLUMNS_UP,
e_WIPE_LAST_COLUMN_UP,
e_COLUMNS_DOWN
} t_State;
2024-03-08 09:57:47 +01:00
void displayTestExec(void *args) {
2024-03-08 15:54:34 +01:00
static int16_t last = 0xff;
static int16_t current = 0;
2024-03-08 14:07:09 +01:00
static uint8_t color = 0x01;
2024-03-08 15:54:34 +01:00
static t_State state = e_PIXELS_UP;
2024-03-08 14:07:09 +01:00
switch (state) {
2024-03-08 15:54:34 +01:00
// wipe last column
case e_WIPE_LAST_COLUMN_DOWN:
2024-03-12 23:00:17 +01:00
for (uint16_t i = 0; i < canvas.height; i++) {
2024-03-08 14:07:09 +01:00
canvasSetPixel(last, i, 0);
}
last = 0xff;
2024-03-08 15:54:34 +01:00
state = e_PIXELS_UP;
// pixels up
case e_PIXELS_UP:
2024-03-08 14:07:09 +01:00
if (last != 0xff) {
2024-03-12 23:00:17 +01:00
*((canvas.canvas)+last) = 0x80;
2024-03-08 14:07:09 +01:00
}
last = current;
2024-03-12 23:00:17 +01:00
*((canvas.canvas)+current) = (color + 0x80);
2024-03-08 14:07:09 +01:00
current++;
2024-03-12 23:00:17 +01:00
if (current >= canvas.size) {
2024-03-08 14:07:09 +01:00
current = 0;
2024-03-08 15:54:34 +01:00
state = e_WIPE_LAST_PIXEL_UP;
}
break;
// wipe last pixel
case e_WIPE_LAST_PIXEL_UP:
2024-03-12 23:00:17 +01:00
*((canvas.canvas)+last) = 0x80;
2024-03-08 15:54:34 +01:00
last = 0xff;
2024-03-12 23:00:17 +01:00
current = canvas.size - 1;
2024-03-08 15:54:34 +01:00
state = e_PIXELS_DOWN;
// pixels down
case e_PIXELS_DOWN:
if (last != 0xff) {
2024-03-12 23:00:17 +01:00
*((canvas.canvas)+last) = 0x80;
2024-03-08 15:54:34 +01:00
}
last = current;
2024-03-12 23:00:17 +01:00
*((canvas.canvas)+current) = (color + 0x80);
2024-03-08 15:54:34 +01:00
current--;
if (current < 0) {
current = 0;
state = e_WIPE_LAST_PIXEL_DOWN;
2024-03-08 14:07:09 +01:00
}
break;
2024-03-08 15:54:34 +01:00
// wipe last pixel
case e_WIPE_LAST_PIXEL_DOWN:
2024-03-12 23:00:17 +01:00
*((canvas.canvas)+last) = 0x80;
2024-03-08 14:07:09 +01:00
last = 0xff;
2024-03-08 15:54:34 +01:00
state = e_ROWS_UP;
// rows up
case e_ROWS_UP:
2024-03-08 14:07:09 +01:00
if (last != 0xff) {
2024-03-12 23:00:17 +01:00
for (uint16_t i = 0; i < canvas.width; i++) {
2024-03-08 14:07:09 +01:00
canvasSetPixel(i, last, 0);
}
}
last = current;
2024-03-12 23:00:17 +01:00
for (uint16_t i = 0; i < canvas.width; i++) {
2024-03-08 14:07:09 +01:00
canvasSetPixel(i, current, color);
}
current++;
2024-03-12 23:00:17 +01:00
if (current >= canvas.height) {
2024-03-08 14:07:09 +01:00
current = 0;
2024-03-08 15:54:34 +01:00
state = e_WIPE_LAST_ROW_UP;
}
break;
// wipe last row
case e_WIPE_LAST_ROW_UP:
2024-03-12 23:00:17 +01:00
for (uint16_t i = 0; i < canvas.width; i++) {
2024-03-08 15:54:34 +01:00
canvasSetPixel(i, last, 0);
}
last = 0xff;
2024-03-12 23:00:17 +01:00
current = canvas.height - 1;
2024-03-08 15:54:34 +01:00
state = e_ROWS_DOWN;
// rows down
case e_ROWS_DOWN:
if (last != 0xff) {
2024-03-12 23:00:17 +01:00
for (uint16_t i = 0; i < canvas.width; i++) {
2024-03-08 15:54:34 +01:00
canvasSetPixel(i, last, 0);
}
}
last = current;
2024-03-12 23:00:17 +01:00
for (uint16_t i = 0; i < canvas.width; i++) {
2024-03-08 15:54:34 +01:00
canvasSetPixel(i, current, color);
}
current--;
if (current < 0) {
current = 0;
state = e_WIPE_LAST_ROW_DOWN;
2024-03-08 14:07:09 +01:00
}
break;
2024-03-08 15:54:34 +01:00
// wipe last row
case e_WIPE_LAST_ROW_DOWN:
2024-03-12 23:00:17 +01:00
for (uint16_t i = 0; i < canvas.width; i++) {
2024-03-08 14:07:09 +01:00
canvasSetPixel(i, last, 0);
}
last = 0xff;
2024-03-08 15:54:34 +01:00
state = e_COLUMNS_UP;
// columns up
case e_COLUMNS_UP:
2024-03-08 14:07:09 +01:00
if (last != 0xff) {
2024-03-12 23:00:17 +01:00
for (uint16_t i = 0; i < canvas.height; i++) {
2024-03-08 14:07:09 +01:00
canvasSetPixel(last, i, 0);
}
}
last = current;
2024-03-12 23:00:17 +01:00
for (uint16_t i = 0; i < canvas.height; i++) {
2024-03-08 14:07:09 +01:00
canvasSetPixel(current, i, color);
}
current++;
2024-03-12 23:00:17 +01:00
if (current >= canvas.width) {
2024-03-08 14:07:09 +01:00
current = 0;
2024-03-08 15:54:34 +01:00
state = e_WIPE_LAST_COLUMN_UP;
}
break;
// wipe last column
case e_WIPE_LAST_COLUMN_UP:
2024-03-12 23:00:17 +01:00
for (uint16_t i = 0; i < canvas.height; i++) {
2024-03-08 15:54:34 +01:00
canvasSetPixel(last, i, 0);
}
last = 0xff;
2024-03-12 23:00:17 +01:00
current = canvas.width - 1;
2024-03-08 15:54:34 +01:00
state = e_COLUMNS_DOWN;
// columns down
case e_COLUMNS_DOWN:
if (last != 0xff) {
2024-03-12 23:00:17 +01:00
for (uint16_t i = 0; i < canvas.height; i++) {
2024-03-08 15:54:34 +01:00
canvasSetPixel(last, i, 0);
}
}
last = current;
2024-03-12 23:00:17 +01:00
for (uint16_t i = 0; i < canvas.height; i++) {
2024-03-08 15:54:34 +01:00
canvasSetPixel(current, i, color);
}
current--;
if (current < 0) {
current = 0;
state = e_WIPE_LAST_COLUMN_DOWN;
2024-03-08 14:07:09 +01:00
}
break;
2024-03-08 09:57:47 +01:00
}
2024-03-08 14:07:09 +01:00
color++;
if (color > MAX_COLOR) {
color = 1;
2024-03-08 09:57:47 +01:00
}
canvasShow();
}
void displayTestInit() {
schAdd(displayTestExec, NULL, 0, 50);
}