source: buchla-68k/ram/vtyper.c@ 0580615

Last change on this file since 0580615 was 0580615, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Point of no return.

  • Property mode set to 100644
File size: 7.5 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(unsigned 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
81void vtsetup(unsigned *obj, short (*dsp)(), short col, char *ptr, short tr, short tc, short (*adv)(), short (*bsp)(), short (*cup)(), short (*cdn)(), short (*stop)(), unsigned fg, unsigned bg)
82{
83 vtobj = obj; /* setup object pointer */
84 vt_adv = adv; /* setup cursor advance function pointer */
85 vt_bsp = bsp; /* setup cursor backspace function pointer */
86 vt_cup = cup; /* setup cursor up function pointer */
87 vt_cdn = cdn; /* setup cursor down function pointer */
88 vt_dsp = dsp; /* setup display function pointer */
89 vt_stop = stop; /* setup exit typewriter function pointer */
90 vtwrow = tr; /* setup typewriter window row */
91 vtwcol = tc; /* setup typewriter window column */
92 vtdecol = col; /* setup data entry base column */
93 vtdeptr = ptr; /* setup data entry area base address */
94 vtfgval = exp_c(fg); /* setup foreground color value */
95 vtbgval = exp_c(bg); /* setup background color value */
96 SetPri(TTCURS, TTCPRI); /* turn on the typewriter cursor */
97 vtxval = CTOX(tc); /* setup vt x value */
98 vtyval = YTOR(tr); /* setup vt y value */
99 ttcpos(tr, tc); /* position the typewriter cusor */
100}
101
102/*
103
104*/
105
106/*
107 =============================================================================
108 vtcxupd() -- update virtual typewriter cursor x value
109
110 Standard cursor x update for use when the typewriter is displayed.
111
112 Reference this in the cursor x update for the particular display
113 when the virtual typewriter is displayed.
114 =============================================================================
115*/
116
117void vtcxupd(void)
118{
119 vtccol = XTOC(vtxval += cxrate);
120
121 if (vtccol > (vtwcol + 29))
122 vtxval = CTOX(vtccol = vtwcol + 29);
123 else if (vtccol < vtwcol)
124 vtxval = CTOX(vtccol = vtwcol);
125}
126
127/*
128 =============================================================================
129 vtcyupd() -- update virtual typewriter cursor y value
130
131 Standard cursor y update for use when the typewriter is displayed.
132
133 Reference this in the cursor y update for the particular display
134 when the virtual typewriter is displayed.
135 =============================================================================
136*/
137
138void vtcyupd(void)
139{
140 vtcrow = YTOR(vtyval += cyrate);
141
142 if (vtcrow > (vtwrow + 2))
143 vtyval = RTOY(vtcrow = vtwrow + 2);
144 else if (vtcrow < vtwrow)
145 vtyval = RTOY(vtcrow = vtwrow);
146}
147
148/*
149
150*/
151
152/*
153 =============================================================================
154 vtdisp() -- virtual typewriter data entry display (4 bit graphics)
155
156 Standard function for virtual typewriter output to a graphic screen.
157 Assumes that the graphic object is a 4 bit per pixel object in bank 0.
158 =============================================================================
159*/
160
161void vtdisp(unsigned *obj, unsigned fg, unsigned bg, short row, short col, char *buf)
162{
163
164 if (v_regs[5] & 0x0180)
165 vbank(0);
166
167 vcputsv(obj, 64, fg, bg, row, col, buf, 14);
168}
169
170/*
171
172*/
173
174/*
175 =============================================================================
176 vtyper() -- do data entry with the virtual typewriter
177
178 Called when enter is hit to do data entry from the select function
179 for the display. Returns TRUE if data entry occurred, FALSE otherwise.
180 =============================================================================
181*/
182
183int vtyper(void)
184{
185 /* check for data entry */
186
187 if (vtccol < (vtwcol + 26)) { /* enter data */
188
189 /* convert (vtcrow, vtccol) to data entry character */
190
191 if (vtcrow EQ vtwrow)
192 vtdechr = vtlin1[vtccol - vtwcol];
193 else if (vtcrow EQ (vtwrow + 1))
194 vtdechr = vtlin2[vtccol - vtwcol];
195 else if (vtcrow EQ (vtwrow + 2))
196 vtdechr = vtlin3[vtccol - vtwcol];
197 else {
198
199 vtdechr = '*'; /* error -- bad row */
200 return(FALSE);
201 }
202
203 vtdeptr[stccol - vtdecol] = vtdechr; /* update data area */
204
205 /* update the screen */
206
207 bfs[0] = vtdechr;
208 bfs[1] = '\0';
209
210 (*vt_dsp)(vtobj, vtfgval, vtbgval, stcrow, stccol, bfs);
211
212 (*vt_adv)(); /* advance cursor */
213 return(TRUE);
214/*
215
216*/
217 /* check for exit or cursor controls */
218
219 } else if ((vtcrow EQ (vtwrow + 1))
220 AND (vtccol EQ (vtwcol + 28))) { /* exit */
221
222 objclr(TTCPRI); /* turn off typewriter cursor */
223 (*vt_stop)(); /* refresh typewriter window */
224 return(FALSE);
225
226 } else if ((vtcrow EQ vtwrow)
227 AND (vtccol EQ (vtwcol + 28))) { /* cursor up */
228
229 (*vt_cup)(); /* move cursor up a row */
230 return(FALSE);
231
232 } else if ((vtcrow EQ (vtwrow + 2))
233 AND (vtccol EQ (vtwcol + 28))) { /* cursor down */
234
235 (*vt_cdn)(); /* move cursor down a row */
236 return(FALSE);
237
238 } else if ((vtcrow EQ (vtwrow + 1))
239 AND (vtccol EQ (vtwcol + 27))) { /* cursor lft */
240
241 (*vt_bsp)(); /* move cursor left a column */
242 return(FALSE);
243
244 } else if ((vtcrow EQ (vtwrow + 1))
245 AND (vtccol EQ (vtwcol + 29))) { /* cursor rgt */
246
247 (*vt_adv)(); /* move cursor right a column */
248 return(FALSE);
249 }
250}
251
Note: See TracBrowser for help on using the repository browser.