mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 08:43:19 -04:00
This is white-space only change. No functional difference.
- Be consistent about placing spaces around keywords and operators; don't mix statements like "if(A==B)" and "if (X == Y)", "return(0)" and "return (-1)", "P=10" and "Q = 0", etc. - Consitently indent lines. It's not good to indent by 8 columns in one part of the file, and by 4 columns in the other part.
This commit is contained in:
parent
6b0d93bcea
commit
6c8e596705
1 changed files with 166 additions and 139 deletions
|
|
@ -105,24 +105,25 @@ vidc_init(int arg)
|
|||
int i;
|
||||
|
||||
if (vidc_started && arg == 0)
|
||||
return(0);
|
||||
return (0);
|
||||
vidc_started = 1;
|
||||
#ifdef TERM_EMU
|
||||
/* Init terminal emulator */
|
||||
end_term();
|
||||
get_pos();
|
||||
curs_move(curx,cury);
|
||||
fg_c=7;
|
||||
bg_c=0;
|
||||
curs_move(curx, cury);
|
||||
fg_c = 7;
|
||||
bg_c = 0;
|
||||
#endif
|
||||
for(i = 0; i < 10 && vidc_ischar(); i++)
|
||||
(void)vidc_getchar();
|
||||
return(0); /* XXX reinit? */
|
||||
for (i = 0; i < 10 && vidc_ischar(); i++)
|
||||
(void)vidc_getchar();
|
||||
return (0); /* XXX reinit? */
|
||||
}
|
||||
|
||||
static void
|
||||
vidc_biosputchar(int c)
|
||||
{
|
||||
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0xe00 | (c & 0xff);
|
||||
|
|
@ -135,7 +136,7 @@ vidc_rawputchar(int c)
|
|||
{
|
||||
int i;
|
||||
|
||||
if(c == '\t')
|
||||
if (c == '\t')
|
||||
/* lame tab expansion */
|
||||
for (i = 0; i < 8; i++)
|
||||
vidc_rawputchar(' ');
|
||||
|
|
@ -146,43 +147,43 @@ vidc_rawputchar(int c)
|
|||
/* Emulate AH=0eh (teletype output) */
|
||||
switch(c) {
|
||||
case '\a':
|
||||
vidc_biosputchar(c);
|
||||
return;
|
||||
vidc_biosputchar(c);
|
||||
return;
|
||||
case '\r':
|
||||
curx=0;
|
||||
curs_move(curx,cury);
|
||||
return;
|
||||
curx = 0;
|
||||
curs_move(curx, cury);
|
||||
return;
|
||||
case '\n':
|
||||
cury++;
|
||||
if(cury>24) {
|
||||
scroll_up(1,fg_c,bg_c);
|
||||
cury--;
|
||||
} else {
|
||||
curs_move(curx,cury);
|
||||
}
|
||||
return;
|
||||
cury++;
|
||||
if (cury > 24) {
|
||||
scroll_up(1, fg_c, bg_c);
|
||||
cury--;
|
||||
} else {
|
||||
curs_move(curx, cury);
|
||||
}
|
||||
return;
|
||||
case '\b':
|
||||
if(curx>0) {
|
||||
curx--;
|
||||
curs_move(curx,cury);
|
||||
/* write_char(' ',fg_c,bg_c); XXX destructive(!) */
|
||||
return;
|
||||
}
|
||||
if (curx > 0) {
|
||||
curx--;
|
||||
curs_move(curx, cury);
|
||||
/* write_char(' ', fg_c, bg_c); XXX destructive(!) */
|
||||
return;
|
||||
}
|
||||
return;
|
||||
default:
|
||||
write_char(c,fg_c,bg_c);
|
||||
curx++;
|
||||
if(curx>79) {
|
||||
curx=0;
|
||||
cury++;
|
||||
}
|
||||
if(cury>24) {
|
||||
curx=0;
|
||||
scroll_up(1,fg_c,bg_c);
|
||||
cury--;
|
||||
}
|
||||
write_char(c, fg_c, bg_c);
|
||||
curx++;
|
||||
if (curx > 79) {
|
||||
curx = 0;
|
||||
cury++;
|
||||
}
|
||||
if (cury > 24) {
|
||||
curx = 0;
|
||||
scroll_up(1, fg_c, bg_c);
|
||||
cury--;
|
||||
}
|
||||
}
|
||||
curs_move(curx,cury);
|
||||
curs_move(curx, cury);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
@ -195,38 +196,40 @@ vidc_rawputchar(int c)
|
|||
void
|
||||
get_pos(void)
|
||||
{
|
||||
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0x0300;
|
||||
v86.ebx = 0x0;
|
||||
v86int();
|
||||
curx=v86.edx & 0x00ff;
|
||||
cury=(v86.edx & 0xff00)>>8;
|
||||
curx = v86.edx & 0x00ff;
|
||||
cury = (v86.edx & 0xff00) >> 8;
|
||||
}
|
||||
|
||||
/* Move cursor to x rows and y cols (0-based). */
|
||||
void
|
||||
curs_move(int x, int y)
|
||||
{
|
||||
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0x0200;
|
||||
v86.ebx = 0x0;
|
||||
v86.edx = ((0x00ff & y)<<8)+(0x00ff & x);
|
||||
v86.edx = ((0x00ff & y) << 8) + (0x00ff & x);
|
||||
v86int();
|
||||
curx=x;
|
||||
cury=y;
|
||||
curx = x;
|
||||
cury = y;
|
||||
/* If there is ctrl char at this position, cursor would be invisible.
|
||||
* Make it a space instead.
|
||||
*/
|
||||
v86.ctl=0;
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0x0800;
|
||||
v86.ebx= 0x0;
|
||||
v86.ebx = 0x0;
|
||||
v86int();
|
||||
#define isvisible(c) (((c)>32) && ((c)<255))
|
||||
if(!isvisible(v86.eax & 0x00ff)) {
|
||||
write_char(' ',fg_c,bg_c);
|
||||
#define isvisible(c) (((c) > 32) && ((c) < 255))
|
||||
if (!isvisible(v86.eax & 0x00ff)) {
|
||||
write_char(' ', fg_c, bg_c);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -237,38 +240,41 @@ curs_move(int x, int y)
|
|||
void
|
||||
scroll_up(int rows, int fgcol, int bgcol)
|
||||
{
|
||||
if(rows==0) rows=25;
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0x0600+(0x00ff & rows);
|
||||
v86.ebx = (bgcol<<12)+(fgcol<<8);
|
||||
v86.ecx = 0x0;
|
||||
v86.edx = 0x184f;
|
||||
v86int();
|
||||
|
||||
if (rows == 0)
|
||||
rows = 25;
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0x0600 + (0x00ff & rows);
|
||||
v86.ebx = (bgcol << 12) + (fgcol << 8);
|
||||
v86.ecx = 0x0;
|
||||
v86.edx = 0x184f;
|
||||
v86int();
|
||||
}
|
||||
|
||||
/* Write character and attribute at cursor position. */
|
||||
void
|
||||
write_char(int c, int fgcol, int bgcol)
|
||||
{
|
||||
v86.ctl=0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0x0900+(0x00ff & c);
|
||||
v86.ebx = (bgcol<<4)+fgcol;
|
||||
v86.ecx = 0x1;
|
||||
v86int();
|
||||
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0x0900 + (0x00ff & c);
|
||||
v86.ebx = (bgcol << 4) + fgcol;
|
||||
v86.ecx = 0x1;
|
||||
v86int();
|
||||
}
|
||||
|
||||
/* Calculate power of 10 */
|
||||
int
|
||||
pow10(int i)
|
||||
{
|
||||
int res=1;
|
||||
int res = 1;
|
||||
|
||||
while(i-->0) {
|
||||
res*=10;
|
||||
}
|
||||
return res;
|
||||
while (i-- > 0) {
|
||||
res *= 10;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
|
|
@ -280,33 +286,37 @@ pow10(int i)
|
|||
|
||||
/* Set background color */
|
||||
void
|
||||
AB(void){
|
||||
bg_c=args[0];
|
||||
end_term();
|
||||
AB(void)
|
||||
{
|
||||
|
||||
bg_c = args[0];
|
||||
end_term();
|
||||
}
|
||||
|
||||
/* Set foreground color */
|
||||
void
|
||||
AF(void)
|
||||
{
|
||||
fg_c=args[0];
|
||||
end_term();
|
||||
|
||||
fg_c = args[0];
|
||||
end_term();
|
||||
}
|
||||
|
||||
/* Clear display from current position to end of screen */
|
||||
void
|
||||
CD(void)
|
||||
{
|
||||
|
||||
get_pos();
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x10;
|
||||
v86.eax = 0x0600;
|
||||
v86.ebx = (bg_c<<4)+fg_c;
|
||||
v86.ebx = (bg_c << 4) + fg_c;
|
||||
v86.ecx = v86.edx;
|
||||
v86.edx = 0x184f;
|
||||
v86int();
|
||||
curx=0;
|
||||
curs_move(curx,cury);
|
||||
curx = 0;
|
||||
curs_move(curx, cury);
|
||||
end_term();
|
||||
}
|
||||
|
||||
|
|
@ -316,9 +326,12 @@ CD(void)
|
|||
void
|
||||
CM(void)
|
||||
{
|
||||
if(args[0]>0) args[0]--;
|
||||
if(args[1]>0) args[1]--;
|
||||
curs_move(args[1],args[0]);
|
||||
|
||||
if (args[0] > 0)
|
||||
args[0]--;
|
||||
if (args[1] > 0)
|
||||
args[1]--;
|
||||
curs_move(args[1], args[0]);
|
||||
end_term();
|
||||
}
|
||||
|
||||
|
|
@ -326,53 +339,60 @@ CM(void)
|
|||
void
|
||||
HO(void)
|
||||
{
|
||||
argc=1;
|
||||
args[0]=args[1]=1;
|
||||
CM();
|
||||
|
||||
argc = 1;
|
||||
args[0] = args[1] = 1;
|
||||
CM();
|
||||
}
|
||||
|
||||
/* Exit attribute mode (reset fore/back-ground colors to defaults) */
|
||||
void
|
||||
ME(void)
|
||||
{
|
||||
fg_c=7;
|
||||
bg_c=0;
|
||||
end_term();
|
||||
|
||||
fg_c = 7;
|
||||
bg_c = 0;
|
||||
end_term();
|
||||
}
|
||||
|
||||
/* Clear internal state of the terminal emulation code */
|
||||
void
|
||||
end_term(void)
|
||||
{
|
||||
esc=0;
|
||||
argc=-1;
|
||||
fg=bg=br=0;
|
||||
args[0]=args[1]=0;
|
||||
dig=0;
|
||||
|
||||
esc = 0;
|
||||
argc = -1;
|
||||
fg = bg = br = 0;
|
||||
args[0] = args[1] = 0;
|
||||
dig = 0;
|
||||
}
|
||||
|
||||
/* Gracefully exit ESC-sequence processing in case of misunderstanding */
|
||||
void
|
||||
bail_out(int c)
|
||||
{
|
||||
char buf[6],*ch;
|
||||
char buf[6],*ch;
|
||||
|
||||
if(esc) vidc_rawputchar('\033');
|
||||
if(br) vidc_rawputchar('[');
|
||||
if(argc>-1) {
|
||||
sprintf(buf,"%d",args[0]);
|
||||
ch=buf;
|
||||
while(*ch) vidc_rawputchar(*ch++);
|
||||
if (esc)
|
||||
vidc_rawputchar('\033');
|
||||
if (br)
|
||||
vidc_rawputchar('[');
|
||||
if (argc > -1) {
|
||||
sprintf(buf, "%d", args[0]);
|
||||
ch = buf;
|
||||
while (*ch)
|
||||
vidc_rawputchar(*ch++);
|
||||
|
||||
if(argc>0) {
|
||||
vidc_rawputchar(';');
|
||||
sprintf(buf,"%d",args[1]);
|
||||
ch=buf;
|
||||
while(*ch) vidc_rawputchar(*ch++);
|
||||
}
|
||||
if (argc > 0) {
|
||||
vidc_rawputchar(';');
|
||||
sprintf(buf, "%d", args[1]);
|
||||
ch = buf;
|
||||
while (*ch)
|
||||
vidc_rawputchar(*ch++);
|
||||
}
|
||||
vidc_rawputchar(c);
|
||||
end_term();
|
||||
}
|
||||
vidc_rawputchar(c);
|
||||
end_term();
|
||||
}
|
||||
|
||||
/* Emulate basic capabilities of cons25 terminal */
|
||||
|
|
@ -380,9 +400,9 @@ void
|
|||
vidc_term_emu(int c)
|
||||
{
|
||||
|
||||
if(!esc) {
|
||||
if(c=='\033') {
|
||||
esc=1;
|
||||
if (!esc) {
|
||||
if (c == '\033') {
|
||||
esc = 1;
|
||||
} else {
|
||||
vidc_rawputchar(c);
|
||||
}
|
||||
|
|
@ -390,15 +410,15 @@ vidc_term_emu(int c)
|
|||
}
|
||||
|
||||
/* Do ESC sequences processing */
|
||||
switch(c) {
|
||||
switch (c) {
|
||||
case '\033':
|
||||
/* ESC in ESC sequence - error */
|
||||
bail_out(c);
|
||||
break;
|
||||
case '[':
|
||||
/* Check if it's first char after ESC */
|
||||
if(argc<0) {
|
||||
br=1;
|
||||
if (argc < 0) {
|
||||
br = 1;
|
||||
} else {
|
||||
bail_out(c);
|
||||
}
|
||||
|
|
@ -406,14 +426,16 @@ vidc_term_emu(int c)
|
|||
case 'H':
|
||||
/* Emulate \E[H (cursor home) and
|
||||
* \E%d;%dH (cursor absolute move) */
|
||||
if(br) {
|
||||
switch(argc) {
|
||||
if (br) {
|
||||
switch (argc) {
|
||||
case -1:
|
||||
HO();
|
||||
break;
|
||||
case 1:
|
||||
if(fg) args[0]+=pow10(dig)*3;
|
||||
if(bg) args[0]+=pow10(dig)*4;
|
||||
if (fg)
|
||||
args[0] += pow10(dig)*3;
|
||||
if (bg)
|
||||
args[0] += pow10(dig)*4;
|
||||
CM();
|
||||
break;
|
||||
default:
|
||||
|
|
@ -423,26 +445,28 @@ vidc_term_emu(int c)
|
|||
break;
|
||||
case 'J':
|
||||
/* Emulate \EJ (clear to end of screen) */
|
||||
if(br && argc<0) {
|
||||
if (br && argc < 0) {
|
||||
CD();
|
||||
} else bail_out(c);
|
||||
break;
|
||||
case ';':
|
||||
/* perhaps args separator */
|
||||
if(br && (argc>-1)) {
|
||||
if (br && (argc > -1)) {
|
||||
argc++;
|
||||
} else bail_out(c);
|
||||
break;
|
||||
case 'm':
|
||||
/* Change char attributes */
|
||||
if(br) {
|
||||
switch(argc) {
|
||||
if (br) {
|
||||
switch (argc) {
|
||||
case -1:
|
||||
ME();
|
||||
break;
|
||||
case 0:
|
||||
if(fg) AF();
|
||||
else AB();
|
||||
if (fg)
|
||||
AF();
|
||||
else
|
||||
AB();
|
||||
break;
|
||||
default:
|
||||
bail_out(c);
|
||||
|
|
@ -450,29 +474,30 @@ vidc_term_emu(int c)
|
|||
} else bail_out(c);
|
||||
break;
|
||||
default:
|
||||
if(isdigit(c)) {
|
||||
if (isdigit(c)) {
|
||||
/* Carefully collect numeric arguments */
|
||||
/* XXX this is ugly. */
|
||||
if(br) {
|
||||
if(argc==-1) {
|
||||
argc=0;
|
||||
args[argc]=0;
|
||||
dig=0;
|
||||
if (br) {
|
||||
if (argc == -1) {
|
||||
argc = 0;
|
||||
args[argc] = 0;
|
||||
dig = 0;
|
||||
/* in case we're in error... */
|
||||
if(c=='3') {
|
||||
fg=1;
|
||||
if (c == '3') {
|
||||
fg = 1;
|
||||
return;
|
||||
}
|
||||
if(c=='4') {
|
||||
bg=1;
|
||||
if (c == '4') {
|
||||
bg = 1;
|
||||
return;
|
||||
}
|
||||
args[argc]=(int)(c-'0');
|
||||
dig=1;
|
||||
args[argc+1]=0;
|
||||
args[argc] = (int)(c - '0');
|
||||
dig = 1;
|
||||
args[argc + 1] = 0;
|
||||
} else {
|
||||
args[argc]=args[argc]*10+(int)(c-'0');
|
||||
if(argc==0) dig++;
|
||||
args[argc] = args[argc]*10 + (int)(c - '0');
|
||||
if (argc == 0)
|
||||
dig++;
|
||||
}
|
||||
} else bail_out(c);
|
||||
} else bail_out(c);
|
||||
|
|
@ -494,25 +519,27 @@ vidc_putchar(int c)
|
|||
static int
|
||||
vidc_getchar(void)
|
||||
{
|
||||
|
||||
if (vidc_ischar()) {
|
||||
v86.ctl = 0;
|
||||
v86.addr = 0x16;
|
||||
v86.eax = 0x0;
|
||||
v86int();
|
||||
return(v86.eax & 0xff);
|
||||
return (v86.eax & 0xff);
|
||||
} else {
|
||||
return(-1);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
vidc_ischar(void)
|
||||
{
|
||||
|
||||
v86.ctl = V86_FLAGS;
|
||||
v86.addr = 0x16;
|
||||
v86.eax = 0x100;
|
||||
v86int();
|
||||
return(!(v86.efl & PSL_Z));
|
||||
return (!(v86.efl & PSL_Z));
|
||||
}
|
||||
|
||||
#if KEYBOARD_PROBE
|
||||
|
|
|
|||
Loading…
Reference in a new issue