-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtipc.c
207 lines (166 loc) · 5.09 KB
/
tipc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*
* The routines in this file provide support for the TI-PC and other
* compatible terminals. It goes directly to the graphics RAM to do
* screen output. It compiles into nothing if not a TI-PC driver
*/
#define termdef 1 /* don't define "term" external */
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#if TIPC
#define NROW 25 /* Screen size. */
#define NCOL 80 /* Edit if you want to. */
#define MARGIN 8 /* size of minimim margin and */
#define SCRSIZ 64 /* scroll size for extended lines */
#define NPAUSE 200 /* # times thru update to pause */
#define BEL 0x07 /* BEL character. */
#define ESC 0x1B /* ESC character. */
#define SPACE 32 /* space character */
#define SCADD 0xDE000L /* address of screen RAM */
#define CHAR_ENABLE 0x08 /* TI attribute to show char */
#define TI_REVERSE 0x10 /* TI attribute to reverse char */
#define BLACK 0+CHAR_ENABLE /* TI attribute for Black */
#define BLUE 1+CHAR_ENABLE /* TI attribute for Blue */
#define RED 2+CHAR_ENABLE /* TI attribute for Red */
#define MAGENTA 3+CHAR_ENABLE /* TI attribute for Magenta */
#define GREEN 4+CHAR_ENABLE /* TI attribute for Green */
#define CYAN 5+CHAR_ENABLE /* TI attribute for Cyan */
#define YELLOW 6+CHAR_ENABLE /* TI attribute for Yellow */
#define WHITE 7+CHAR_ENABLE /* TI attribute for White */
extern VOID timove(); /* Forward references. */
extern VOID tieeol();
extern VOID tieeop();
extern VOID tibeep();
extern int tiopen();
extern VOID tirev();
extern int ticres();
extern int ticlose();
extern int tiputc();
#if COLOR
extern VOID tifcol();
extern VOID tibcol();
int cfcolor = -1; /* current forground color */
int cbcolor = -1; /* current background color */
int ctrans[] = /* ansi to ti color translation table */
{BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE};
#endif
/*
* Standard terminal interface dispatch table. Most of the fields point into
* "termio" code.
*/
TERM term = {
NROW-1,
NROW-1,
NCOL,
NCOL,
MARGIN,
SCRSIZ,
NPAUSE,
tiopen,
ticlose,
ttgetc,
tiputc,
ttflush,
timove,
tieeol,
tieeop,
tibeep,
tirev,
ticres
#if COLOR
, tifcol,
tibcol
#endif
};
extern union REGS rg;
#if COLOR
setatt( attr )
int attr;
{
rg.h.ah = 0x16; /* set the forground character attribute */
rg.h.bl = attr;
int86( 0x49, &rg, &rg );
}
VOID tifcol(color) /* set the current output color */
int color; /* color to set */
{
cfcolor = ctrans[color];
setatt ( cfcolor );
}
VOID tibcol(color) /* set the current background color */
int color; /* color to set */
{
cbcolor = ctrans[color];
}
#endif
VOID timove(row, col)
{
rg.h.ah = 2; /* set cursor position function code */
rg.h.dh = col;
rg.h.dl = row;
int86(0x49, &rg, &rg);
}
VOID tieeol() /* erase to the end of the line */
{
int ccol; /* current column cursor lives */
int crow; /* row */
/* find the current cursor position */
rg.h.ah = 3; /* read cursor position function code */
int86(0x49, &rg, &rg);
ccol = rg.h.dh; /* record current column */
crow = rg.h.dl; /* and row */
rg.h.ah = 0x09; /* Write character at cursor position */
rg.h.al = ' '; /* Space */
rg.h.bl = cfcolor;
rg.x.cx = NCOL-ccol; /* Number of characters to write */
int86(0x49, &rg, &rg);
}
tiputc(ch) /* put a character at the current position in the
current colors */
int ch;
{
rg.h.ah = 0x0E; /* write char to screen with current attrs */
rg.h.al = ch;
int86(0x49, &rg, &rg);
}
VOID tieeop() /* Actually a clear screen */
{
rg.h.ah = 0x13; /* Clear Text Screen and Home Cursor */
int86(0x49, &rg, &rg);
}
VOID tirev(state) /* change reverse video state */
int state; /* TRUE = reverse, FALSE = normal */
{
setatt( state ? cbcolor : cfcolor );
}
ticres() /* change screen resolution */
{
return(TRUE);
}
spal() /* change palette string */
{
/* Does nothing here */
}
VOID tibeep()
{
bdos(6, BEL, 0);
}
tiopen()
{
strcpy(sres, "NORMAL");
revexist = TRUE;
ttopen();
}
ticlose()
{
#if COLOR
tifcol(7);
tibcol(0);
#endif
ttclose();
}
#else
VOID tihello()
{
}
#endif