source: buchla-68k/orig/RAM/VTYPER.C@ 9bf0f86

Last change on this file since 9bf0f86 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 7.7 KB
Line 
1/*
2 =============================================================================
3 vtyper.c -- virtual typewriter support functions
4 Version 8 -- 1989-11-14 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#include "stddefs.h"
9#include "fields.h"
10#include "hwdefs.h"
11#include "vsdd.h"
12#include "graphdef.h"
13
14#include "midas.h"
15
16extern unsigned exp_c();
17
18extern short cxrate; /* data entry cursor x (col) update increment */
19extern short cyrate; /* data entry cursor y (row) update increment */
20extern short stccol; /* data entry text cursor column */
21extern short stcrow; /* data entry text cursor row */
22extern short vtccol; /* vtyper cursor column */
23extern short vtcrow; /* vtyper cursor row */
24extern short vtdecol; /* vtyper data entry column */
25extern short vtxval; /* vtyper cursor x value */
26extern short vtyval; /* vtyper cursor y value */
27
28extern char *vtdeptr; /* vtyper data entry pointer */
29
30extern char vtdechr; /* vtyper data entry character */
31
32extern char bfs[]; /* display string buffer */
33
34extern short vtwrow; /* vtyper window top row */
35extern short vtwcol; /* vtyper window left column */
36
37extern short (*vt_adv)(); /* vtyper data cursor advance function */
38extern short (*vt_bsp)(); /* vtyper data cursor backspace function */
39extern short (*vt_cdn)(); /* vtyper data cursor down function */
40extern short (*vt_cup)(); /* vtyper data cursor up function */
41extern short (*vt_stop)(); /* vtyper exit function */
42extern short (*vt_dsp)(); /* vtyper display function */
43
44extern unsigned *vtobj; /* vtyper display object pointer */
45extern unsigned vtfgval; /* vtyper data foreground color */
46extern unsigned vtbgval; /* vtyper data background color */
47
48/* virtual typewriter display line constants */
49
50/* "123456789012345678901234567890" */
51char vtlin1[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ | "; /* top */
52char vtlin2[] = "abcdefghijklmnopqrstuvwxyz -*-"; /* center */
53char vtlin3[] = " 0123456789+-/#().,:;!?&<> | "; /* bottom */
54
55/*
56
57*/
58
59/*
60 =============================================================================
61 vtsetup() -- setup the virtual typewriter for data entry
62
63 This sets up the parameters for the virtual typewriter:
64
65 obj VSDD display object pointer
66 dsp character display function
67 col data entry area -- leftmost column on the screen
68 ptr data string base pointer
69 tr typewriter window topmost row
70 tc typewriter window leftmost column
71 adv data entry cursor advance function
72 bsp data entry cursor backspace function
73 cup data entry cursor up function
74 cdn data entry cursor down function
75 stop virtual typewriter end function
76 fg data entry text foreground color
77 bg data entry text background color
78 =============================================================================
79*/
80
81vtsetup(obj, dsp, col, ptr, tr, tc, adv, bsp, cup, cdn, stop, fg, bg)
82unsigned *obj;
83short (*dsp)();
84short col;
85char *ptr;
86short tr, tc;
87short (*adv)(), (*bsp)(), (*cup)(), (*cdn)(), (*stop)();
88unsigned fg, bg;
89{
90 vtobj = obj; /* setup object pointer */
91 vt_adv = adv; /* setup cursor advance function pointer */
92 vt_bsp = bsp; /* setup cursor backspace function pointer */
93 vt_cup = cup; /* setup cursor up function pointer */
94 vt_cdn = cdn; /* setup cursor down function pointer */
95 vt_dsp = dsp; /* setup display function pointer */
96 vt_stop = stop; /* setup exit typewriter function pointer */
97 vtwrow = tr; /* setup typewriter window row */
98 vtwcol = tc; /* setup typewriter window column */
99 vtdecol = col; /* setup data entry base column */
100 vtdeptr = ptr; /* setup data entry area base address */
101 vtfgval = exp_c(fg); /* setup foreground color value */
102 vtbgval = exp_c(bg); /* setup background color value */
103 SetPri(TTCURS, TTCPRI); /* turn on the typewriter cursor */
104 vtxval = CTOX(tc); /* setup vt x value */
105 vtyval = YTOR(tr); /* setup vt y value */
106 ttcpos(tr, tc); /* position the typewriter cusor */
107}
108
109/*
110
111*/
112
113/*
114 =============================================================================
115 vtcxupd() -- update virtual typewriter cursor x value
116
117 Standard cursor x update for use when the typewriter is displayed.
118
119 Reference this in the cursor x update for the particular display
120 when the virtual typewriter is displayed.
121 =============================================================================
122*/
123
124vtcxupd()
125{
126 vtccol = XTOC(vtxval += cxrate);
127
128 if (vtccol > (vtwcol + 29))
129 vtxval = CTOX(vtccol = vtwcol + 29);
130 else if (vtccol < vtwcol)
131 vtxval = CTOX(vtccol = vtwcol);
132}
133
134/*
135 =============================================================================
136 vtcyupd() -- update virtual typewriter cursor y value
137
138 Standard cursor y update for use when the typewriter is displayed.
139
140 Reference this in the cursor y update for the particular display
141 when the virtual typewriter is displayed.
142 =============================================================================
143*/
144
145vtcyupd()
146{
147 vtcrow = YTOR(vtyval += cyrate);
148
149 if (vtcrow > (vtwrow + 2))
150 vtyval = RTOY(vtcrow = vtwrow + 2);
151 else if (vtcrow < vtwrow)
152 vtyval = RTOY(vtcrow = vtwrow);
153}
154
155/*
156
157*/
158
159/*
160 =============================================================================
161 vtdisp() -- virtual typewriter data entry display (4 bit graphics)
162
163 Standard function for virtual typewriter output to a graphic screen.
164 Assumes that the graphic object is a 4 bit per pixel object in bank 0.
165 =============================================================================
166*/
167
168vtdisp(obj, fg, bg, row, col, buf)
169unsigned *obj;
170unsigned fg, bg;
171short row, col;
172char *buf;
173{
174
175 if (v_regs[5] & 0x0180)
176 vbank(0);
177
178 vcputsv(obj, 64, fg, bg, row, col, buf, 14);
179}
180
181/*
182
183*/
184
185/*
186 =============================================================================
187 vtyper() -- do data entry with the virtual typewriter
188
189 Called when enter is hit to do data entry from the select function
190 for the display. Returns TRUE if data entry occurred, FALSE otherwise.
191 =============================================================================
192*/
193
194vtyper()
195{
196 /* check for data entry */
197
198 if (vtccol < (vtwcol + 26)) { /* enter data */
199
200 /* convert (vtcrow, vtccol) to data entry character */
201
202 if (vtcrow EQ vtwrow)
203 vtdechr = vtlin1[vtccol - vtwcol];
204 else if (vtcrow EQ (vtwrow + 1))
205 vtdechr = vtlin2[vtccol - vtwcol];
206 else if (vtcrow EQ (vtwrow + 2))
207 vtdechr = vtlin3[vtccol - vtwcol];
208 else {
209
210 vtdechr = '*'; /* error -- bad row */
211 return(FALSE);
212 }
213
214 vtdeptr[stccol - vtdecol] = vtdechr; /* update data area */
215
216 /* update the screen */
217
218 bfs[0] = vtdechr;
219 bfs[1] = '\0';
220
221 (*vt_dsp)(vtobj, vtfgval, vtbgval, stcrow, stccol, bfs);
222
223 (*vt_adv)(); /* advance cursor */
224 return(TRUE);
225/*
226
227*/
228 /* check for exit or cursor controls */
229
230 } else if ((vtcrow EQ (vtwrow + 1))
231 AND (vtccol EQ (vtwcol + 28))) { /* exit */
232
233 objclr(TTCPRI); /* turn off typewriter cursor */
234 (*vt_stop)(); /* refresh typewriter window */
235 return(FALSE);
236
237 } else if ((vtcrow EQ vtwrow)
238 AND (vtccol EQ (vtwcol + 28))) { /* cursor up */
239
240 (*vt_cup)(); /* move cursor up a row */
241 return(FALSE);
242
243 } else if ((vtcrow EQ (vtwrow + 2))
244 AND (vtccol EQ (vtwcol + 28))) { /* cursor down */
245
246 (*vt_cdn)(); /* move cursor down a row */
247 return(FALSE);
248
249 } else if ((vtcrow EQ (vtwrow + 1))
250 AND (vtccol EQ (vtwcol + 27))) { /* cursor lft */
251
252 (*vt_bsp)(); /* move cursor left a column */
253 return(FALSE);
254
255 } else if ((vtcrow EQ (vtwrow + 1))
256 AND (vtccol EQ (vtwcol + 29))) { /* cursor rgt */
257
258 (*vt_adv)(); /* move cursor right a column */
259 return(FALSE);
260 }
261}
262
Note: See TracBrowser for help on using the repository browser.