conio.h

Go to the documentation of this file.
00001 /*
00002 ** conio.h for lseos in lseos-lib/libc/machdep
00003 ** 
00004 ** Copyright (c)2004 Vianney Rancurel
00005 ** Login   <vianney@epita.fr>
00006 ** 
00007 ** Started on  Thu Jul  3 15:00:17 2003 Vianney Rancurel
00008 ** Last update Mon Dec  6 12:28:23 2004 Vianney Rancurel
00009 */
00010 #ifndef __MACHDEP_CONIO_H__
00011 #define __MACHDEP_CONIO_H__     1
00012 #include <libc.h>
00013 
00014 /*
00015  * conio context
00016  */
00017 typedef struct          s_conio
00018 {
00019   u_int                 width;
00020   u_int                 height;
00021 #define CGA_WIDTH               80
00022 #define CGA_HEIGHT              25
00023   u_int                 status;
00024 #define CONIO_ESCAPE            (1<<0u)
00025 #define CONIO_CSI               (1<<1u)
00026 #define CONIO_PN                (1<<2u) 
00027 #define CONIO_LASTCOL           (1<<3u)
00028   int                   pn1;
00029   int                   pn2;
00030   u_char                *buf;
00031   u_char                attrib;
00032 }                       t_conio;
00033 
00034 /* attributes */
00035 enum 
00036 { 
00037   ATTRIB_BLACK = 0x0,
00038   ATTRIB_BLUE = 0x1,
00039   ATTRIB_GREEN = 0x2,
00040   ATTRIB_CYAN = 0x3,
00041   ATTRIB_RED = 0x4,
00042   ATTRIB_MAGENTA = 0x5,
00043   ATTRIB_YELLOW = 0x6,
00044   ATTRIB_WHITE = 0x7,
00045         
00046   ATTRIB_BRIGHT = 0x8,
00047         
00048   ATTRIB_BLACK_BG = 0x00,
00049   ATTRIB_BLUE_BG = 0x10,
00050   ATTRIB_GREEN_BG = 0x20,
00051   ATTRIB_CYAN_BG = 0x30,
00052   ATTRIB_RED_BG = 0x40,
00053   ATTRIB_MAGENTA_BG = 0x50,
00054   ATTRIB_YELLOW_BG = 0x60,
00055   ATTRIB_WHITE_BG = 0x70,
00056         
00057   ATTRIB_BLINK = 0x80
00058 };
00059 
00060 /* video card I/O ports */
00061 #define IO_CGA_INDEX    0x03D4
00062 #define IO_CGA_DATA     0x03D5
00063 
00064 /* video card index registers */
00065 #define CURSOR_LO       0x0F
00066 #define CURSOR_HI       0x0E
00067 
00068 #define CGA_BUF         0xb8000
00069 
00070 /*
00071  * useful macros
00072  */
00073 #define CONIO_PUTCHAR(Conio, PosX, PosY, Char, Attrib) \
00074   (Conio)->buf[((PosX) + (PosY) * (Conio)->width) * 2] = (Char);\
00075   (Conio)->buf[(((PosX) + (PosY) * (Conio)->width) * 2) + 1] = (Attrib);
00076 
00077 #define CONIO_GETCHAR(Conio, PosX, PosY) \
00078 ((Conio)->buf[((PosX) + (PosY) * (Conio)->width) * 2])
00079 
00080 #define CONIO_GETATTRIB(Conio, PosX, PosY) \
00081 ((Conio)->buf[(((PosX) + (PosY) * (Conio)->width) * 2) + 1])
00082 
00083 #define CONIO_FG(Attrib)        ((Attrib) & 0xf)
00084 #define CONIO_BG(Attrib)        ((Attrib & 0xf0) >> 4)
00085 
00086 extern t_conio          gl_conio;       
00088 /* PROTO conio.c */
00089 /* conio.c */
00090 void conio_gotoxy(t_conio *c, int x, int y);
00091 void conio_getxy(t_conio *c, int *x, int *y);
00092 void conio_clrscr(t_conio *c);
00093 void conio_scrollup(t_conio *c);
00094 void conio_process_buf(t_conio *c, char *buf, int len);
00095 void conio_process_char(t_conio *c, char ch);
00096 #endif

Generated on Wed May 24 23:04:17 2006 for LSE/OS by  doxygen 1.4.6