1 /*
2  * OS2NONPM.C
3  *
4  * The routines in this file provide video and keyboard support using the
5  * OS/2 Vio and Kbd functions (not the presentation manager).
6  *
7  * The os2putc, os2eeol and os2eeop routines modify the logical video
8  * buffer.  Os2flush calls VioShowBuf to update the physical video buffer.
9  * An earlier version used VioWrtTTy with ANSI processing (easy to do, but
10  * sloooow).  A later version using VioWrtNCell was better, but not as
11  * good as manipulating the logical buffer.
12  */
13 
14 #define INCL_BASE
15 #include	<os2.h>
16 
17 #define	termdef	1			/* don't define "term" external */
18 
19 #include	<stdio.h>
20 
21 #undef	PASCAL
22 #undef	NEAR
23 #undef	HIBYTE
24 
25 #include	"estruct.h"
26 #include	"eproto.h"
27 #include	"edef.h"
28 #include	"elang.h"
29 
30 #if     OS2NPM
31 /*
32  * Os2def.h defines COLOR, but no MSC stuff needs it.
33  * We need COLOR as defined in estruct.h, so edit it out of os2def.h.
34  */
35 #include	<conio.h>
36 
37 #define	NROW    102		/* Screen size.                 */
38 #define	NCOL    80		/* Edit if you want to.         */
39 #define	MARGIN	8		/* size of minimim margin and	*/
40 #define	SCRSIZ	64		/* scroll size for extended lines */
41 #define	NPAUSE	100		/* # times thru update to pause */
42 
43 #define CDCGA	0		/* color graphics adapter	*/
44 #define CDMONO	1		/* monochrome display adapter	*/
45 #define CDEGA	2		/* EGA				*/
46 #define CDVGA	3		/* VGA				*/
47 
48 #define NDRIVE	4		/* number of video modes	*/
49 
50 int dtype = -1;				/* current video mode	*/
51 char drvname[][8] = {			/* names of video modes	*/
52 	"CGA", "MONO", "EGA", "VGA"
53 };
54 
55 /* Forward references.          */
56 
57 PASCAL NEAR os2move();
58 PASCAL NEAR os2eeol();
59 PASCAL NEAR os2eeop();
60 PASCAL NEAR os2beep();
61 PASCAL NEAR os2open();
62 PASCAL NEAR os2close();
63 PASCAL NEAR os2getc();
64 PASCAL NEAR os2putc();
65 PASCAL NEAR os2flush();
66 PASCAL NEAR os2rev();
67 PASCAL NEAR os2kclose();
68 PASCAL NEAR os2kopen();
69 PASCAL NEAR os2cres();
70 PASCAL NEAR os2parm();
71 #if	COLOR
72 PASCAL NEAR os2fcol();
73 PASCAL NEAR os2bcol();
74 #endif
75 
76 struct {			/* Current screen attribute for ORing	*/
77 	BYTE	filler;		/* with character to be displayed.	*/
78 	BYTE	attr;
79 } os2cell = {0, 0x07};
80 
81 struct {			/* Current reverse screen attribute for	*/
82 	BYTE	filler;		/* ORing with character to be displayed.*/
83 	BYTE	attr;
84 } os2rcell = {0, 0x07};
85 
86 static struct {				/* initial states		*/
87 	USHORT		ansiState;	/* ANSI translation		*/
88 	VIOCONFIGINFO	vioConfigInfo;	/* video configuration		*/
89 	VIOMODEINFO	vioModeInfo;	/* video mode			*/
90 	KBDINFO		kbdInfo;	/* keyboard info		*/
91 } initial;
92 
93 static int	cfcolor = -1;		/* current foreground color	*/
94 static int	cbcolor = -1;		/* current background color	*/
95 static int	ctrans[] =	/* ansi to ibm color translation table	*/
96 	{0, 4, 2, 6, 1, 5, 3, 7,
97 	 8, 12, 10, 14, 9, 13, 11, 15};
98 
99 static short	 os2row;		/* current cursor row	*/
100 static short	 os2col;		/* current cursor col	*/
101 
102 int revflag = FALSE;			/* are we currently in rev video? */
103 
104 /*
105  * To minimize the amount of buffer that VioShowBuf has to update, we
106  * keep track of the lowest and highest bytes in the logical video
107  * buffer which have been modified.
108  */
109 static USHORT	*lvb;			/* logical video buffer	*/
110 static USHORT	 lvbLen;		/* length of buffer	*/
111 static USHORT	 lvbMin;		/* min index of modified byte	*/
112 static USHORT	 lvbMax;		/* max index of modified byte	*/
113 
114 /*
115  * Standard terminal interface dispatch table.
116  */
117 TERM    term    = {
118 	NROW-1,
119 	NROW-1,
120 	NCOL,
121 	NCOL,
122 	0, 0,
123 	MARGIN,
124 	SCRSIZ,
125 	NPAUSE,
126 	os2open,
127 	os2close,
128 	os2kopen,
129 	os2kclose,
130 	os2getc,
131 	os2putc,
132 	os2flush,
133 	os2move,
134 	os2eeol,
135 	os2eeop,
136 	os2eeop,
137 	os2beep,
138 	os2rev,
139 	os2cres
140 #if	COLOR
141 	, os2fcol,
142 	os2bcol
143 #endif
144 };
145 
146 #if	MOUSE
147 /*	Mousing global variable	*/
148 static int mexist;	/* is the mouse driver installed? */
149 static int nbuttons;	/* number of buttons on the mouse */
150 static int oldbut;	/* Previous state of mouse buttons */
151 static int oldcol;	/* previous x position of mouse */
152 static int oldrow;	/* previous y position of mouse */
153 HMOU mouse_handle;	/* handle to opened mouse */
154 #endif
155 
156 /*	input buffers and pointers	*/
157 
158 #define	IBUFSIZE	64	/* this must be a power of 2 */
159 
160 unsigned char in_buf[IBUFSIZE];	/* input character buffer */
161 int in_next = 0;		/* pos to retrieve next input character */
162 int in_last = 0;		/* pos to place most recent input character */
163 
in_init()164 in_init()	/* initialize the input buffer */
165 
166 {
167 	in_next = in_last = 0;
168 }
169 
in_check()170 in_check()	/* is the input buffer non-empty? */
171 
172 {
173 	if (in_next == in_last)
174 		return(FALSE);
175 	else
176 		return(TRUE);
177 }
178 
in_put(event)179 in_put(event)
180 
181 int event;	/* event to enter into the input buffer */
182 
183 {
184 	in_buf[in_last++] = event;
185 	in_last &= (IBUFSIZE - 1);
186 }
187 
in_get()188 int in_get()	/* get an event from the input buffer */
189 
190 {
191 	register int event;	/* event to return */
192 
193 	event = in_buf[in_next++];
194 	in_next &= (IBUFSIZE - 1);
195 	return(event);
196 }
197 
198 #if	COLOR
199 /*----------------------------------------------------------------------*/
200 /*	os2fcol()							*/
201 /* Set the current foreground color.					*/
202 /*----------------------------------------------------------------------*/
203 
os2fcol(int color)204 PASCAL NEAR os2fcol(
205 	int color)			/* color to set */
206 {
207 	if (dtype != CDMONO)
208 		cfcolor = ctrans[color];
209 	else
210 		cfcolor = 7;
211 
212 	/* set the normal attribute */
213 	os2cell.attr &= 0xF0;
214 	os2cell.attr |= cfcolor;
215 
216 	/* set the reverse attribute */
217 	os2rcell.attr &= 0x07;
218 	os2rcell.attr |= cfcolor << 4;
219 }
220 
221 /*----------------------------------------------------------------------*/
222 /*	os2bcol()							*/
223 /* Set the current background color.					*/
224 /*----------------------------------------------------------------------*/
225 
os2bcol(int color)226 PASCAL NEAR os2bcol(
227 	int color)		/* color to set */
228 {
229 	if (dtype != CDMONO)
230 		cbcolor = ctrans[color];
231 	else
232 		cbcolor = 0;
233 
234 	/* set normal background attribute */
235 	os2cell.attr &= 0x0F;
236 	os2cell.attr |= cbcolor << 4;
237 
238 	/* set reverse background attribute */
239 	os2rcell.attr &= 0x70;
240 	os2rcell.attr |= cbcolor;
241 }
242 #endif
243 
244 
245 /*----------------------------------------------------------------------*/
246 /*	os2move()							*/
247 /* Move the cursor.							*/
248 /*----------------------------------------------------------------------*/
249 
os2move(int row,int col)250 PASCAL NEAR os2move(
251 	int row,
252 	int col)
253 {
254 	os2row = row;
255 	os2col = col;
256 	VioSetCurPos(os2row, os2col, 0);
257 }
258 
259 
260 /*----------------------------------------------------------------------*/
261 /*	os2flush()							*/
262 /* Update the physical video buffer from the logical video buffer.	*/
263 /*----------------------------------------------------------------------*/
264 
os2flush(void)265 PASCAL NEAR os2flush(void)
266 {
267 	if (lvbMin <= lvbMax) {		/* did anything change?	*/
268 		VioShowBuf(lvbMin * 2, (lvbMax - lvbMin + 1) * 2, 0);
269 		VioSetCurPos(os2row, os2col, 0);
270 	}
271 	lvbMin = lvbLen;
272 	lvbMax = 0;
273 }
274 
275 
276 /*----------------------------------------------------------------------*/
277 /*	os2char()							*/
278 /* Get a character from the keyboard.					*/
279 /* Function keys, editing keys and alt- keys queue extra bytes into     */
280 /* input queue.
281 /*----------------------------------------------------------------------*/
282 
os2char()283 PASCAL NEAR os2char()
284 {
285 	register c;		/* extended key code for special keys */
286 	KBDKEYINFO keyInfo;
287 
288 	KbdCharIn(&keyInfo, IO_WAIT, 0);	/* get a character	*/
289 
290 	/* Function, edit or alt- key?	*/
291 	if (keyInfo.chChar == 0  ||  keyInfo.chChar == 0xE0) {
292 		c = extcode(keyInfo.chScan); /* hold on to scan code */
293 		in_put(c >> 8);		/* queue up prefix byte */
294 		in_put(c & 0xFF);	/* queue up event byte */
295 		return(0);
296 	}
297 	return(keyInfo.chChar & 255);
298 }
299 
300 /*
301  * Read a character from the terminal, performing no editing and doing no echo
302  * at all. Also mouse events are forced into the input stream here.
303  */
os2getc()304 PASCAL NEAR os2getc()
305 
306 {
307 	register int c;		/* character read */
308 #if	MOUSE
309 	NOPTRRECT mouse_rect;
310 #endif
311 
312 	os2flush();
313 
314 ttc:	/* return any keystrokes waiting in the
315 	   type ahead buffer */
316 	if (in_check())
317 		return(in_get());
318 
319 #if	TYPEAH
320 	if (typahead())
321 		return(os2char());
322 
323 	/* with no mouse, this is a simple get char routine */
324 	if (mexist == FALSE || mouseflag == FALSE)
325 		return(os2char());
326 
327 #if	MOUSE
328 	/* turn the mouse cursor on */
329 	MouDrawPtr(mouse_handle);
330 
331 	/* loop waiting for something to happen */
332 	while (TRUE) {
333 		if (typahead())
334 			break;
335 		if (checkmouse())
336 			break;
337 		DosSleep(10L);	/* let others have some CPU! */
338 	}
339 
340 	/* turn the mouse cursor back off */
341 	mouse_rect.row = 0;
342 	mouse_rect.col = 0;
343 	mouse_rect.cRow = 24;
344 	mouse_rect.cCol = 79;
345 	MouRemovePtr(&mouse_rect, mouse_handle);
346 
347 	goto ttc;
348 #endif	/* MOUSE */
349 #else	/* TYPEAH */
350 	return(os2char());
351 #endif	/* TYPEAH */
352 }
353 
354 #if	MOUSE
checkmouse()355 checkmouse()
356 
357 {
358 	register int k;		/* current bit/button of mouse */
359 	register int etype;	/* event type byte */
360 	register int event;	/* encoded mouse event */
361 	int mousecol;		/* current mouse column */
362 	int mouserow;		/* current mouse row */
363 	int sstate;		/* current shift key status */
364 	int newbut;		/* new state of the mouse buttons */
365 	MOUEVENTINFO mouse_event;	/* info about a mouse event */
366 	MOUQUEINFO mouse_queue;	/* holds info about the mouse queue */
367 	USHORT wait_flag;	/* wait flag for read mouse queue call */
368 	KBDINFO kbd_info;	/* keyboard information */
369 
370 	/* is there a mouse event queued up? */
371 	MouGetNumQueEl(&mouse_queue, mouse_handle);
372 	if (mouse_queue.cEvents == 0)
373 		return(FALSE);
374 
375 	/* get the current mouse event */
376 	wait_flag = MOU_WAIT;
377 	MouReadEventQue(&mouse_event, &wait_flag, mouse_handle);
378 
379 	/* build a simple bit field out of OS/2's rather complex one */
380 	newbut = 0;
381 	if (mouse_event.fs & MOUSE_BN1_DOWN)
382 		newbut |= 1;
383 	if (mouse_event.fs & MOUSE_MOTION_WITH_BN1_DOWN)
384 		newbut |= 1;
385 	if (mouse_event.fs & MOUSE_BN2_DOWN)
386 		newbut |= 2;
387 	if (mouse_event.fs & MOUSE_MOTION_WITH_BN2_DOWN)
388 		newbut |= 2;
389 	if (mouse_event.fs & MOUSE_BN3_DOWN)
390 		newbut |= 4;
391 	if (mouse_event.fs & MOUSE_MOTION_WITH_BN3_DOWN)
392 		newbut |= 4;
393 
394 	/* check to see if any mouse buttons are different */
395 	mousecol = mouse_event.col;
396 	mouserow = mouse_event.row;
397 
398 	/* only notice changes */
399 	if ((oldbut == newbut) && (mousecol == oldcol)
400 	    && (mouserow == oldrow))
401 		return(FALSE);
402 
403 	/* get the shift key status as well */
404 	KbdGetStatus(&kbd_info, 0);
405 	etype = MOUS >> 8;
406 	sstate = kbd_info.fsState;
407 	if (sstate & (RIGHTSHIFT | LEFTSHIFT)) /* shifted */
408 		etype |= (SHFT >> 8);
409 	else if (sstate & CONTROL)	/* controled? */
410 		etype |= (CTRL >> 8);
411 
412 	/* no buttons changes */
413 	if (oldbut == newbut) {
414 
415 		/* generate a mouse movement */
416 		if (((mouse_move == 1) && (mmove_flag == TRUE)) ||
417 		    (mouse_move == 2)) {
418 			in_put(0);
419 			in_put(etype);
420 			in_put(mousecol);
421 			in_put(mouserow);
422 			in_put('m');
423 		}
424 		oldcol = mousecol;
425 		oldrow = mouserow;
426 		return(TRUE);
427 	}
428 
429 	/* only on screen presses are legit! */
430 	if (mousecol < 0)
431 		mousecol = 0;
432 	if (mouserow < 0)
433 		mouserow = 0;
434 
435 	for (k = 1; k != (1 << nbuttons); k = k << 1) {
436 
437 		/* For each button on the mouse */
438 		if ((oldbut&k) != (newbut&k)) {
439 			/* This button changed, generate an event */
440 			in_put(0);
441 			in_put(etype);
442 			in_put(mousecol);
443 			in_put(mouserow);
444 
445 			event = ((newbut&k) ? 0 : 1);	/* up or down? */
446 			if (k == 2)			/* center button? */
447 				event += 4;
448 			if (k == 4)			/* right button? */
449 				event += 2;
450 			event += 'a';		/* plain */
451 			in_put(event);
452 			oldbut = newbut;
453 			oldcol = mousecol;
454 			oldrow = mouserow;
455 			return(TRUE);
456 		}
457 	}
458 	return(TRUE);
459 }
460 #endif
461 
462 #if	TYPEAH
463 /*----------------------------------------------------------------------*/
464 /*	typahead()							*/
465 /* Returns true if a key has been pressed.				*/
466 /*----------------------------------------------------------------------*/
467 
typahead()468 PASCAL NEAR typahead()
469 
470 {
471 	KBDKEYINFO kbdinfo;
472 
473 	KbdPeek(&kbdinfo, 0);
474 	return(kbdinfo.fbStatus != 0);
475 }
476 #endif
477 
478 
479 /*----------------------------------------------------------------------*/
480 /*	os2putc()							*/
481 /* Put a character at the current position in the current colors.	*/
482 /* Note that this does not behave the same as putc() or VioWrtTTy().	*/
483 /* This routine does nothing with returns and linefeeds.  For backspace */
484 /* it puts a space in the previous column and moves the cursor to the	*/
485 /* previous column.  For all other characters, it will display the	*/
486 /* graphic representation of the character and put the cursor in the	*/
487 /* next column (even if that is off the screen.  In practice this isn't	*/
488 /* a problem.								*/
489 /*----------------------------------------------------------------------*/
490 
os2putc(int c)491 PASCAL NEAR os2putc(int c)
492 {
493 	USHORT	cell;
494 	USHORT	i;
495 
496 	if (c == '\n' || c == '\r') {		/* returns and linefeeds */
497 		return;
498 	}
499 	if (c == '\b') {			/* backspace		*/
500 		cell = ' ' | (revflag ? *(USHORT *)&os2rcell : *(USHORT *)&os2cell);
501 		--os2col;			/* move cursor back	*/
502 		i = os2row * term.t_ncol + os2col;
503 	}
504 	else {
505 		cell = (0x00ff & c) | (revflag ? *(USHORT *)&os2rcell : *(USHORT *)&os2cell);
506 		i = os2row * term.t_ncol + os2col;
507 		++os2col;			/* move cursor forward	*/
508 	}
509 	lvb[i] = cell;
510 	if (i < lvbMin)
511 		lvbMin = i;
512 	if (i > lvbMax)
513 		lvbMax = i;
514 }
515 
516 
517 /*----------------------------------------------------------------------*/
518 /*	os2eeol()							*/
519 /* Erase to end of line.						*/
520 /*----------------------------------------------------------------------*/
521 
os2eeol()522 PASCAL NEAR os2eeol()
523 {
524 	USHORT	cell = ' ';
525 	USHORT  i;
526 
527 	cell |= (revflag ? *(USHORT *)&os2rcell : *(USHORT *)&os2cell);
528 
529 	i = os2row * term.t_ncol + os2col;  /* current cursor position	*/
530 	if (i < lvbMin)
531 		lvbMin = i;
532 	while (i < os2row * term.t_ncol + term.t_ncol)
533 		lvb[ i++] = cell;
534 	if (--i > lvbMax)
535 		lvbMax = i;
536 }
537 
538 
539 /*----------------------------------------------------------------------*/
540 /*	os2eeop()							*/
541 /* Erase to end of page.						*/
542 /*----------------------------------------------------------------------*/
543 
os2eeop()544 PASCAL NEAR os2eeop()
545 {
546 	USHORT	cell = ' ';
547 	USHORT  i;
548 
549 #if COLOR
550 	if (dtype != CDMONO)
551 		cell |= (ctrans[gbcolor] << 4 | ctrans[gfcolor]) << 8;
552 	else
553 		cell |= 0x0700;
554 #else
555 	cell |= 0x0700;
556 #endif
557 
558 	i = os2row * term.t_ncol + os2col;  /* current cursor position	*/
559 	if (i < lvbMin)
560 		lvbMin = i;
561 	while (i < term.t_nrow * term.t_ncol + term.t_ncol)
562 		lvb[ i++] = cell;
563 	if (--i > lvbMax)
564 		lvbMax = i;
565 }
566 
567 /*----------------------------------------------------------------------*/
568 /*	os2rev()							*/
569 /* Change reverse video state.  					*/
570 /*----------------------------------------------------------------------*/
571 
os2rev(state)572 PASCAL NEAR os2rev(state)
573 
574 int state;	/* TRUE = reverse, FALSE = normal */
575 
576 {
577 	revflag = state;
578 }
579 
580 /*----------------------------------------------------------------------*/
581 /*	os2cres()							*/
582 /* Change the screen resolution.					*/
583 /*----------------------------------------------------------------------*/
584 
os2cres(char * res)585 PASCAL NEAR os2cres(char *res)		/* name of desired video mode	*/
586 {
587 	USHORT	err;
588 	int	type;			/* video mode type	*/
589 	VIOMODEINFO vioModeInfo;
590 
591 	vioModeInfo = initial.vioModeInfo;
592 
593 	/* From the name, find the type of video mode.	*/
594 	for (type = 0; type < NDRIVE; type++) {
595 		if (strcmp(res, drvname[type]) == 0)
596 			break;
597 	}
598 	if (type == NDRIVE)
599 		return(FALSE);	/* not a mode we know about	*/
600 
601 
602 	switch (type) {
603 		case CDMONO:
604 		case CDCGA:
605 			vioModeInfo.row = 25;
606 			break;
607 		case CDEGA:
608 			vioModeInfo.row = 43;
609 			break;
610 		case CDVGA:
611 			vioModeInfo.row = 50;
612 			break;
613 	}
614 
615 	if (VioSetMode(&vioModeInfo, 0))	/* change modes 	*/
616 		return(FALSE);			/* couldn't do it	*/
617 
618 	newsize(TRUE, vioModeInfo.row);
619 
620 	/* reset the $sres environment variable */
621 	strcpy(sres, drvname[type]);
622 	dtype = type;				/* set the current mode	*/
623 
624 	return TRUE;
625 }
626 
627 
628 /*----------------------------------------------------------------------*/
629 /*	spal()								*/
630 /* Change pallette settings.  (Does nothing.)				*/
631 /*----------------------------------------------------------------------*/
632 
spal(char * dummy)633 PASCAL NEAR spal(char *dummy)
634 {
635 }
636 
637 
638 /*----------------------------------------------------------------------*/
639 /*	os2beep()							*/
640 /*----------------------------------------------------------------------*/
641 
os2beep()642 PASCAL NEAR os2beep()
643 {
644 	DosBeep(1200, 175);
645 }
646 
647 
648 /*----------------------------------------------------------------------*/
649 /*	os2open()							*/
650 /* Find out what kind of video adapter we have and the current video	*/
651 /* mode.  Even if the adapter supports a higher resolution mode than is */
652 /* in use, we still use the current mode.				*/
653 /*----------------------------------------------------------------------*/
654 
os2open()655 PASCAL NEAR os2open()
656 {
657 #if	MOUSE
658 	PTRLOC mouse_pos;	/* position to place mouse */
659 	USHORT event_mask;		/* event mask for mouse handling */
660 #endif
661 
662 	initial.vioConfigInfo.cb = 0x0A;
663 	VioGetConfig(0, &initial.vioConfigInfo, 0);
664 	switch (initial.vioConfigInfo.adapter) {
665 		case DISPLAY_VGA:
666 			dtype = CDVGA;
667 			break;
668 		case DISPLAY_EGA:
669 			dtype = CDEGA;
670 			break;
671 		case DISPLAY_CGA:
672 		case 8:	/* some new mode in OS/2 2.0 */
673 			dtype = CDCGA;
674 			break;
675 		case DISPLAY_MONOCHROME:
676 		default:
677 			dtype = CDMONO;
678 	}
679 	strcpy(sres, drvname[dtype]);
680 
681 	initial.vioModeInfo.cb = 0x0E;
682 	VioGetMode(&initial.vioModeInfo, 0);
683 	newsize(TRUE, initial.vioModeInfo.row);
684 
685 	VioGetAnsi(&initial.ansiState, 0);
686 	VioGetBuf((PULONG)&lvb, &lvbLen, 0);
687 	lvbMin = lvbLen;
688 	lvbMax = 0;
689 
690 	revexist = TRUE;
691 	revflag = FALSE;
692 
693 	/* initialize our character input queue */
694 	in_init();
695 	strcpy(os, "OS2");
696 
697 #if	MOUSE
698 	/* find out if we have a mouse */
699 	if (MouOpen((PSZ)0, &mouse_handle) != 0) {
700 		mexist = FALSE;
701 		return;
702 	}
703 
704 	/* find out some info about the mouse */
705 	mexist = TRUE;
706 	MouGetNumButtons(&nbuttons, mouse_handle);
707 
708 	/* tell it what events were interested in */
709 /*	event_mask = MOUSE_BN1_DOWN | MOUSE_BN2_DOWN | MOUSE_BN3_DOWN;*/
710 	event_mask = 0xff;
711 	MouSetEventMask(&event_mask, mouse_handle);
712 
713 	/* get the mouse in the upper right corner */
714 	oldrow = mouse_pos.row = 0;	/* top row of display */
715 	oldcol = mouse_pos.col = (term.t_ncol - 1); /* last col of display */
716 	MouSetPtrPos(&mouse_pos, mouse_handle);
717 #else
718 	mexist = FALSE;
719 #endif
720 }
721 
722 /*----------------------------------------------------------------------*/
723 /*	os2close()							*/
724 /* Restore the original video settings.					*/
725 /*----------------------------------------------------------------------*/
726 
os2close()727 PASCAL NEAR os2close()
728 {
729 #if	MOUSE
730 	/* close our use of the mouse */
731 	if (mexist)
732 		MouClose(mouse_handle);
733 #endif
734 
735 	VioSetAnsi(initial.ansiState, 0);
736 	VioSetMode(&initial.vioModeInfo, 0);
737 	VioSetCurPos(initial.vioModeInfo.row - 1,
738 			 initial.vioModeInfo.col - 1, 0);
739 }
740 
741 /*----------------------------------------------------------------------*/
742 /*	os2kopen()							*/
743 /* Open the keyboard.							*/
744 /*----------------------------------------------------------------------*/
745 
os2kopen()746 PASCAL NEAR os2kopen()
747 {
748 	KBDINFO	kbdInfo;
749 
750 	initial.kbdInfo.cb = 0x000A;
751 	KbdGetStatus(&initial.kbdInfo, 0);
752 	kbdInfo = initial.kbdInfo;
753 	kbdInfo.fsMask &= ~0x0001;		/* not echo on		*/
754 	kbdInfo.fsMask |= 0x0002;		/* echo off		*/
755 	kbdInfo.fsMask &= ~0x0008;		/* cooked mode off	*/
756 	kbdInfo.fsMask |= 0x0004;		/* raw mode		*/
757 	kbdInfo.fsMask &= ~0x0100;		/* shift report	off	*/
758 	KbdSetStatus(&kbdInfo, 0);
759 }
760 
761 
762 /*----------------------------------------------------------------------*/
763 /*	os2kclose()							*/
764 /* Close the keyboard.							*/
765 /*----------------------------------------------------------------------*/
766 
os2kclose()767 PASCAL NEAR os2kclose()
768 {
769 	KbdSetStatus(&initial.kbdInfo, 0); /* restore original state	*/
770 }
771 
772 #if	FLABEL
fnclabel(f,n)773 PASCAL NEAR fnclabel(f, n)	/* label a function key */
774 
775 int f,n;	/* default flag, numeric argument [unused] */
776 
777 {
778 	/* on machines with no function keys...don't bother */
779 	return(TRUE);
780 }
781 #endif
782 
783 #if 0
784 /*----------------------------------------------------------------------*/
785 /*	scwrite()							*/
786 /* Write a line to the screen.
787 /* I tried using this routine with MEMMAP = 1, but there were too many	*/
788 /* problems with the cursor and flushing the buffer.			*/
789 /*----------------------------------------------------------------------*/
790 
791 scwrite(
792 	int	 row,	/* row of screen to place outstr on */
793 	char	*outstr,/* string to write out (must be term.t_ncol long) */
794 	int	 forg,	/* foreground color of string to write */
795 	int	 bacg,	/* background color */
796 {
797 	USHORT	 attr;
798 	int	 i;
799 
800 	attr = (((ctrans[bacg] & 15) << 4) | (forg & 15)) << 8;
801 
802 	for (i = row * term.t_ncol;  i < (row + 1) * term.t_ncol;  i++)
803 		lvb[i] = attr | *(outstr++);
804 
805 	if (i < lvbMin)
806 		lvbMin = i;
807 	if (i > lvbMax)
808 		lvbMax = i;
809 }
810 #endif
811 #endif
812 
813