1 /*************************************************************************
2 MFB graphics and miscellaneous library for protected mode MSDOS.
3 Copyright (c) Stephen R. Whiteley 1992
4 Author: Stephen R. Whiteley
5 *************************************************************************/
6
7 #include "spice.h"
8 #include <stdio.h>
9
10 #ifndef MSDOS
11
12
13 void
cprint(clr,buf)14 cprint(clr,buf)
15 int clr;
16 char *buf;
17 {
18 printf(buf);
19 fflush(stdout);
20 }
21
22
getattr()23 char getattr()
24 {
25 return (0);
26 }
27
28 #else /* MSDOS */
29
30 #include <dos.h>
31 #include <ctype.h>
32
33 #ifdef __STDC__
34 static short getpage(void);
35 #else
36 static short getpage();
37 #endif
38
39
40 void
cprint(clr,buf)41 cprint(clr,buf)
42
43 /* print buf in color clr */
44 int clr;
45 unsigned char *buf;
46 {
47 union REGS r;
48
49 while (*buf) {
50 /* change attribute by printing space */
51 r.x.bx = getpage() + clr & 0xff;
52 r.x.cx = 1;
53 r.x.ax = 0x0900 + ' ';
54 int86(0x10,&r,&r);
55
56 /* now print character, advance cursor */
57 r.x.bx = getpage();
58 r.x.ax = 0x0e00 + *buf;
59 int86(0x10,&r,&r);
60
61 /* special case, go to beginning of line */
62 if (*buf == '\n') {
63 r.x.bx = getpage();
64 r.x.ax = 0x0e00 + '\r';
65 int86(0x10,&r,&r);
66 }
67 buf++;
68 }
69 }
70
71
72 char
getattr()73 getattr()
74
75 /* return the attribute at current position */
76 {
77 union REGS r;
78
79 r.x.bx = getpage();
80 r.x.ax = 0x0800;
81 int86(0x10,&r,&r);
82 return (r.x.ax >> 8);
83 }
84
85
86 static short
getpage()87 getpage()
88
89 /* return the current display page in upper byte */
90 {
91 union REGS r;
92
93 r.x.ax = 0x0f00;
94 int86(0x10,&r,&r);
95 return (r.x.bx & 0xff00);
96 }
97
98 #endif
99