1 /* -*- c -*- ------------------------------------------------------------- *
3 * Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 * Boston MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
19 #define NULL ((void *)0)
22 /* BIOS Assisted output routines */
24 void cswprint(const char *str
, char attr
, char left
);
25 // Print a C str (NUL-terminated) respecting the left edge of window
26 // i.e. \n in str will move cursor to column left
27 // Print a C str (NUL-terminated)
29 static inline void csprint(const char *str
, char attr
)
34 void cprint(char chr
,char attr
,unsigned int times
, char disppage
); // Print a char
36 void setdisppage(char num
); // Set the display page to specified number
38 char getdisppage(); // Get current display page
40 void gotoxy(char row
,char col
, char page
);
42 void getpos(char * row
, char * col
, char page
);
44 char inputc(char * scancode
); // Return ASCII char by val, and scancode by reference
46 static inline void putch(char x
, char attr
, char page
)
48 cprint(x
,attr
,1,page
);
51 void setcursorshape(char start
,char end
); // Set cursor shape
52 void getcursorshape(char *start
,char *end
); // Get shape for current page
54 // Get char displayed at current position in specified page
55 unsigned char getcharat(char page
);
57 static inline void cursoroff(void) /* Turns off cursor */
59 setcursorshape(32,33);
62 static inline void cursoron(void) /* Turns on cursor */
67 static inline unsigned char readbiosb(unsigned int ofs
)
69 return *((unsigned char *)MK_PTR(0,ofs
));
72 static inline char getnumrows()
74 return readbiosb(0x484); // Actually numrows - 1
77 static inline char getnumcols(void)
79 return readbiosb(0x44a); // Actually numcols
82 static inline char getshiftflags(void)
84 return readbiosb(0x417);
87 void scrollupwindow(char top
, char left
, char bot
,char right
,char attr
,char numlines
); //Scroll up given window
89 static inline void scrollup(void) //Scroll up display screen by one line
91 scrollupwindow(0,0,getnumrows(),getnumcols(),0x07,1);
94 void setvideomode(char mode
); // Set the video mode.
96 static inline char getvideomode(void) // Get the current video mode
98 return readbiosb(0x449);
101 unsigned char sleep(unsigned int msec
); // Sleep for specified time
103 void beep(); // A Bell
105 unsigned char checkkbdbuf(); // Check to see if there is kbd buffer is non-empty?
107 static inline void clearkbdbuf() // Clear the kbd buffer (how many chars removed?)
109 while (checkkbdbuf()) inputc(NULL
);