syslinux-3.08-2 sources from FC4
[bootcd.git] / syslinux / menu / libmenu / com32io.h
1 /* -*- c -*- ------------------------------------------------------------- *
2  *   
3  *   Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
4  *
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.
10  *
11  * ----------------------------------------------------------------------- */
12
13 #ifndef __COM32IO_H__
14 #define __COM32IO_H__
15
16 #include <com32.h>
17
18 #ifndef NULL
19 #define NULL ((void *)0)
20 #endif
21
22 /* BIOS Assisted output routines */
23
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)
28
29 static inline void csprint(const char *str, char attr)
30 {
31   cswprint(str,attr,0);
32 }
33
34 void cprint(char chr,char attr,unsigned int times, char disppage); // Print a char 
35
36 void setdisppage(char num); // Set the display page to specified number
37
38 char getdisppage(); // Get current display page 
39
40 void gotoxy(char row,char col, char page);
41
42 void getpos(char * row, char * col, char page);
43
44 char inputc(char * scancode); // Return ASCII char by val, and scancode by reference
45
46 static inline void putch(char x, char attr, char page)
47
48    cprint(x,attr,1,page);
49 }
50
51 void setcursorshape(char start,char end); // Set cursor shape
52 void getcursorshape(char *start,char *end); // Get shape for current page
53
54 // Get char displayed at current position in specified page
55 unsigned char getcharat(char page); 
56
57 static inline void cursoroff(void) /* Turns off cursor */
58 {
59    setcursorshape(32,33);
60 }
61
62 static inline void cursoron(void) /* Turns on cursor */
63 {
64    setcursorshape(6,7);
65 }
66
67 static inline unsigned char readbiosb(unsigned int ofs)
68 {
69    return *((unsigned char *)MK_PTR(0,ofs));
70 }
71
72 static inline char getnumrows()
73 {
74     return readbiosb(0x484); // Actually numrows - 1
75 }
76
77 static inline char getnumcols(void)
78 {
79     return readbiosb(0x44a); // Actually numcols
80 }
81
82 void scrollup(); //Scroll up display screen by one line
83  
84 void setvideomode(char mode); // Set the video mode.
85
86 unsigned char sleep(unsigned int msec); // Sleep for specified time
87
88 void beep(); // A Bell
89
90 unsigned char checkkbdbuf(); // Check to see if there is kbd buffer is non-empty?
91
92 static inline void clearkbdbuf()   // Clear the kbd buffer (how many chars removed?)
93
94    while (checkkbdbuf()) inputc(NULL);
95
96
97 #endif