X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcrt.h;h=f92c99ad6d249020ad5c377f9824d3c6361a90fa;hb=8b6118c4edcdd61ca2312ae5ced001a98607a693;hp=a46affa3fef3e97704b19b2a53123c8d1eed07be;hpb=a1766d2d378710f924391784d0ffc736d59678db;p=sympathy.git diff --git a/src/crt.h b/src/crt.h index a46affa..f92c99a 100644 --- a/src/crt.h +++ b/src/crt.h @@ -12,6 +12,15 @@ /* * $Log$ + * Revision 1.4 2008/02/07 12:16:04 james + * *** empty log message *** + * + * Revision 1.3 2008/02/06 11:30:37 james + * *** empty log message *** + * + * Revision 1.2 2008/02/04 20:23:55 james + * *** empty log message *** + * * Revision 1.1 2008/02/03 23:31:25 james * *** empty log message *** * @@ -24,8 +33,8 @@ #define CRT_COLS 80 #define CRT_CELS (CRT_ROWS*CRT_COLS) -#define CRT_ADDR(r,c) (((r)*CRT_ROWS)+(c)) -#define CRT_ADDR_POS(p) ((((p)->y)*CRT_ROWS)+((p)->x)) +#define CRT_ADDR(r,c) (((r)*CRT_COLS)+(c)) +#define CRT_ADDR_POS(p) ((((p)->y)*CRT_COLS)+((p)->x)) #define CRT_ATTR_NORMAL 0x0 #define CRT_ATTR_UNDERLINE 0x1 @@ -33,26 +42,59 @@ #define CRT_ATTR_BLINK 0x4 #define CRT_ATTR_BOLD 0x8 -typedef struct { - uint8_t chr; - uint8_t attr; + +#define CRT_COLOR_BLACK 0x0 +#define CRT_COLOR_RED 0x1 +#define CRT_COLOR_GREEN 0x2 +#define CRT_COLOR_YELLOW 0x3 +#define CRT_COLOR_BLUE 0x4 +#define CRT_COLOR_MAGENTA 0x5 +#define CRT_COLOR_CYAN 0x6 +#define CRT_COLOR_WHITE 0x7 +#define CRT_COLOR_INTENSITY 0x8 + +#define CRT_COLOR_FG_MASK 0xf0 +#define CRT_COLOR_FG_SHIFT 4 + +#define CRT_COLOR_BG_MASK 0xf +#define CRT_COLOR_BG_SHIFT 0 + +#define CRT_COLOR_BG(a) (((a) & CRT_COLOR_BG_MASK) >> CRT_COLOR_BG_SHIFT) +#define CRT_COLOR_FG(a) (((a) & CRT_COLOR_FG_MASK) >> CRT_COLOR_FG_SHIFT) + +#define CRT_MAKE_COLOR(f,b) (((f) << CRT_COLOR_FG_SHIFT)|(b)) + +#define CRT_BGCOLOR_NORMAL CRT_COLOR_BLACK +#define CRT_FGCOLOR_NORMAL CRT_COLOR_WHITE + +#define CRT_COLOR_NORMAL CRT_MAKE_COLOR(CRT_FGCOLOR_NORMAL,CRT_BGCOLOR_NORMAL) + +typedef struct +{ + uint8_t chr; + uint8_t attr; + uint8_t color; } CRT_CA; -typedef struct { - int x; - int y; +typedef struct +{ + int x; + int y; } CRT_Pos; -typedef struct { - CRT_CA screen[CRT_CELS]; - CRT_Pos pos; - int hide_cursor; +typedef struct +{ + CRT_CA screen[CRT_CELS]; + CRT_Pos pos; + int hide_cursor; } CRT; -static inline crt_ca_cmp(CRT_CA a,CRT_CA b) { - return memcmp(&a,&b,sizeof(a)); +static inline +crt_ca_cmp (CRT_CA a, CRT_CA b) +{ + return memcmp (&a, &b, sizeof (a)); } #endif /* __CRT_H__ */