2008-12-03 05:40:16 +00:00
|
|
|
#ifndef PIXEL_H
|
|
|
|
#define PIXEL_H
|
|
|
|
|
|
|
|
#define LINEBYTES (((NUM_COLS-1)/8)+1)
|
|
|
|
|
|
|
|
extern unsigned char shl_table[];
|
|
|
|
extern unsigned char pixmap[NUMPLANE][NUM_ROWS][LINEBYTES];
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned char x;
|
|
|
|
unsigned char y;
|
|
|
|
} pixel;
|
|
|
|
|
|
|
|
|
2011-02-25 04:31:34 +00:00
|
|
|
enum direction{
|
|
|
|
up,
|
|
|
|
right,
|
|
|
|
down,
|
|
|
|
left
|
|
|
|
};
|
|
|
|
#ifdef NDEBUG
|
|
|
|
typedef unsigned char direction_t;
|
|
|
|
#else
|
|
|
|
typedef enum direction direction_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
enum pixelmode{
|
|
|
|
clear,
|
|
|
|
set
|
|
|
|
};
|
|
|
|
#ifdef NDEBUG
|
|
|
|
typedef unsigned char pixelmode_t;
|
|
|
|
#else
|
|
|
|
typedef enum pixelmode pixelmode_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct cursor{
|
2008-12-03 05:40:16 +00:00
|
|
|
pixel pos;
|
2011-02-25 04:31:34 +00:00
|
|
|
direction_t dir;
|
|
|
|
pixelmode_t mode;
|
|
|
|
} cursor_t;
|
2008-12-03 05:40:16 +00:00
|
|
|
|
2014-03-20 23:12:30 +00:00
|
|
|
|
|
|
|
#if NUM_ROWS < 64 && NUM_COLS < 64
|
|
|
|
/** use 8 bit operands where feasible */
|
|
|
|
typedef signed char operand_t;
|
|
|
|
#else
|
|
|
|
/** use 16 bit operands if either width or height are >= 64 */
|
|
|
|
typedef int operand_t;
|
|
|
|
#endif
|
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* Pixel routines
|
|
|
|
*/
|
2011-02-23 10:34:41 +00:00
|
|
|
|
|
|
|
unsigned char get_pixel(pixel p);
|
|
|
|
|
2011-02-25 04:31:34 +00:00
|
|
|
inline static pixel next_pixel(pixel pix, direction_t dir){
|
2011-02-23 10:34:41 +00:00
|
|
|
static char const nDelta[] = {0, -1, 0, 1, 0};
|
|
|
|
return (pixel){pix.x + nDelta[dir], pix.y + nDelta[dir + 1]};
|
|
|
|
}
|
|
|
|
|
2011-02-24 23:13:01 +00:00
|
|
|
|
2011-02-25 04:31:34 +00:00
|
|
|
inline static unsigned char get_next_pixel(pixel p, direction_t dir){
|
2011-02-23 10:34:41 +00:00
|
|
|
return get_pixel(next_pixel(p, dir));
|
|
|
|
}
|
|
|
|
|
2011-02-24 23:13:01 +00:00
|
|
|
|
2011-02-25 04:31:34 +00:00
|
|
|
inline static direction_t direction_r(direction_t dir){
|
2012-09-08 01:35:32 +00:00
|
|
|
return (dir + 1u) % 4u;
|
2011-02-23 10:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
void clear_screen(unsigned char value);
|
|
|
|
|
2009-02-18 22:26:46 +00:00
|
|
|
|
2011-02-24 23:13:01 +00:00
|
|
|
void setpixel(pixel p, unsigned char value);
|
|
|
|
#define clearpixel(p) setpixel(p, 0);
|
2009-02-18 22:26:46 +00:00
|
|
|
|
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
void shift_pixmap_l();
|
|
|
|
|
|
|
|
|
2011-02-25 04:31:34 +00:00
|
|
|
static inline void set_cursor(cursor_t* cur, pixel p){
|
2011-02-23 10:34:41 +00:00
|
|
|
cur->pos = p;
|
|
|
|
setpixel(p, cur->mode ? 3 : 0);
|
|
|
|
}
|
2008-12-03 05:40:16 +00:00
|
|
|
|
2014-03-20 23:12:30 +00:00
|
|
|
void line(pixel p1,
|
|
|
|
pixel const p2,
|
|
|
|
unsigned char const color);
|
|
|
|
|
2008-12-03 05:40:16 +00:00
|
|
|
#endif // PIXEL_H
|