Adding debian version 3.35-1.
[syslinux-debian/hramrach.git] / menu / libmenu / com32io.c
blob31aec5dfc66c84aa916487506e8c124ee7411b94
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 * ----------------------------------------------------------------------- */
13 #include <string.h>
14 #include <com32.h>
15 #include "com32io.h"
16 #include "syslnx.h"
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)
23 REG_AH(inreg) = 0x09;
24 REG_AL(inreg) = chr;
25 REG_BH(inreg) = disppage;
26 REG_BL(inreg) = attr;
27 REG_CX(inreg) = times;
28 __intcall(0x10,&inreg,&outreg);
31 void setdisppage(char num) // Set the display page to specified number
33 REG_AH(inreg) = 0x05;
34 REG_AL(inreg) = num;
35 __intcall(0x10,&inreg,&outreg);
38 char getdisppage() // Get current display page
40 REG_AH(inreg) = 0x0f;
41 __intcall(0x10,&inreg,&outreg);
42 return REG_BH(outreg);
45 void getpos(char * row, char * col, char page)
47 REG_AH(inreg) = 0x03;
48 REG_BH(inreg) = 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)
56 REG_AH(inreg) = 0x02;
57 REG_BH(inreg) = 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;
66 REG_AH(inreg) = 0x86;
67 REG_CX(inreg) = (micro >> 16);
68 REG_DX(inreg) = (micro & 0xFFFF);
69 __intcall(0x15,&inreg,&outreg);
70 return REG_AH(outreg);
73 void beep()
75 REG_AH(inreg) = 0x0E;
76 REG_AL(inreg) = 0x07;
77 REG_BH(inreg) = 0;
78 __intcall(0x10,&inreg,&outreg);
81 void scrollupwindow(char top, char left, char bot, char right, char attr,char numlines)
83 REG_AH(inreg) = 0x06;
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 */
94 REG_AH(inreg) = 0x10;
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;
114 REG_CL(inreg) = end;
115 __intcall(0x10,&inreg,&outreg);
118 char getchar(void)
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);