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

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

Added missing includes and declarations.

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