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 * ----------------------------------------------------------------------- */
18 com32sys_t inreg
,outreg
; // Global register sets for use
20 /* Print character and attribute at cursor */
21 void cprint(char chr
,char attr
,unsigned int times
,char disppage
)
25 REG_BH(inreg
) = disppage
;
27 REG_CX(inreg
) = times
;
28 __intcall(0x10,&inreg
,&outreg
);
31 void setdisppage(char num
) // Set the display page to specified number
35 __intcall(0x10,&inreg
,&outreg
);
38 char getdisppage() // Get current display page
41 __intcall(0x10,&inreg
,&outreg
);
42 return REG_BH(outreg
);
45 void getpos(char * row
, char * col
, char page
)
49 __intcall(0x10,&inreg
,&outreg
);
50 *row
= REG_DH(outreg
);
51 *col
= REG_DL(outreg
);
54 void gotoxy(char row
,char col
, char page
)
58 REG_DX(inreg
) = (row
<< 8)+col
;
59 __intcall(0x10,&inreg
,&outreg
);
62 unsigned char sleep(unsigned int msec
)
64 unsigned long micro
= 1000*msec
;
67 REG_CX(inreg
) = (micro
>> 16);
68 REG_DX(inreg
) = (micro
& 0xFFFF);
69 __intcall(0x15,&inreg
,&outreg
);
70 return REG_AH(outreg
);
78 __intcall(0x10,&inreg
,&outreg
);
81 void scrollupwindow(char top
, char left
, char bot
, char right
, char attr
,char numlines
)
84 REG_AL(inreg
) = numlines
;
85 REG_BH(inreg
) = attr
; // Attribute to write blanks lines
86 REG_DX(inreg
) = (bot
<< 8) + right
; // BOT RIGHT corner of window
87 REG_CX(inreg
) = (top
<< 8) + left
; // TOP LEFT of window
88 __intcall(0x10,&inreg
,&outreg
);
91 char inputc(char * scancode
)
93 syslinux_idle(); /* So syslinux can perform periodic activity */
95 __intcall(0x16,&inreg
,&outreg
);
96 if (scancode
) *scancode
= REG_AH(outreg
);
97 return REG_AL(outreg
);
100 void getcursorshape(char *start
, char *end
)
102 char page
= getdisppage();
103 REG_AH(inreg
) = 0x03;
104 REG_BH(inreg
) = page
;
105 __intcall(0x10,&inreg
,&outreg
);
106 *start
= REG_CH(outreg
);
107 *end
= REG_CL(outreg
);
110 void setcursorshape(char start
, char end
)
112 REG_AH(inreg
) = 0x01;
113 REG_CH(inreg
) = start
;
115 __intcall(0x10,&inreg
,&outreg
);
120 REG_AH(inreg
) = 0x08;
121 __intcall(0x21,&inreg
,&outreg
);
122 return REG_AL(outreg
);
125 void setvideomode(char mode
)
127 REG_AH(inreg
) = 0x00;
128 REG_AL(inreg
) = mode
;
129 __intcall(0x10,&inreg
,&outreg
);
132 unsigned char checkkbdbuf()
134 REG_AH(inreg
) = 0x11;
135 __intcall(0x16,&inreg
,&outreg
);
136 return !(outreg
.eflags
.l
& EFLAGS_ZF
);
139 // Get char displayed at current position
140 unsigned char getcharat(char page
)
142 REG_AH(inreg
) = 0x08;
143 REG_BH(inreg
) = page
;
144 __intcall(0x16,&inreg
,&outreg
);
145 return REG_AL(outreg
);