1 | /*
|
---|
2 | =============================================================================
|
---|
3 | enterit.c -- MIDAS data entry and cursor support functions
|
---|
4 | Version 40 -- 1989-12-15 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #define DEBUGIT 0
|
---|
9 |
|
---|
10 | #include "m7ver.h"
|
---|
11 | #include "stddefs.h"
|
---|
12 | #include "biosdefs.h"
|
---|
13 | #include "graphdef.h"
|
---|
14 | #include "vsdd.h"
|
---|
15 | #include "vsddsw.h"
|
---|
16 | #include "vsddvars.h"
|
---|
17 | #include "hwdefs.h"
|
---|
18 | #include "memory.h"
|
---|
19 | #include "fields.h"
|
---|
20 | #include "fpu.h"
|
---|
21 | #include "macros.h"
|
---|
22 | #include "panel.h"
|
---|
23 | #include "curpak.h"
|
---|
24 |
|
---|
25 | #include "midas.h"
|
---|
26 | #include "instdsp.h"
|
---|
27 | #include "score.h"
|
---|
28 | #include "scdsp.h"
|
---|
29 | #include "scfns.h"
|
---|
30 | #include "wsdsp.h"
|
---|
31 |
|
---|
32 | #if DEBUGIT
|
---|
33 | extern short debugsw;
|
---|
34 |
|
---|
35 | short debugen = 1;
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | extern short (*cx_key)(), (*cy_key)(), (*cx_upd)(), (*cy_upd)();
|
---|
39 | extern short (*xy_up)(), (*xy_dn)(), (*not_fld)();
|
---|
40 | extern short (*x_key)(), (*e_key)(), (*m_key)(), (*d_key)();
|
---|
41 | extern short (*premove)(), (*pstmove)(), (*curtype)();
|
---|
42 |
|
---|
43 | extern short *cratex;
|
---|
44 | extern short *cratey;
|
---|
45 |
|
---|
46 | extern short asig, aval, astat, aflag;
|
---|
47 | extern short xkstat, ykstat, xkcount, ykcount;
|
---|
48 | extern short cmtype, cmfirst, xycntr, curpos;
|
---|
49 | extern short cxrate, cyrate, cxval, cyval;
|
---|
50 | extern short ncvwait, nchwait, chwait, cvwait, cvtime, chtime;
|
---|
51 | extern short stcrow, stccol, runit, submenu, vtcrow, vtccol;
|
---|
52 | extern short trkball, tkctrl, txflag, tyflag;
|
---|
53 | extern short curhold, hcwval, thcwval, tvcwval, vcwval;
|
---|
54 |
|
---|
55 | extern short sigtab[128][2];
|
---|
56 |
|
---|
57 | extern short crate0[];
|
---|
58 |
|
---|
59 | short syrate = SMYRATE; /* smooth scroll vertical rate */
|
---|
60 |
|
---|
61 | short LastRow = -1;
|
---|
62 | short LastCol = -1;
|
---|
63 |
|
---|
64 | /* |
---|
65 |
|
---|
66 | */
|
---|
67 |
|
---|
68 | /*
|
---|
69 | =============================================================================
|
---|
70 | enterit() -- standard data entry (ENTER) function
|
---|
71 | =============================================================================
|
---|
72 | */
|
---|
73 |
|
---|
74 | void enterit(void)
|
---|
75 | {
|
---|
76 | if (NOT astat) /* only on closures */
|
---|
77 | return;
|
---|
78 |
|
---|
79 | #if DEBUGIT
|
---|
80 | if (debugsw AND debugen)
|
---|
81 | printf("enterit(): ENTRY row = %d col = %d curfet =$%lX\n",
|
---|
82 | stcrow, stccol, curfet);
|
---|
83 | #endif
|
---|
84 |
|
---|
85 | if (infield(stcrow, stccol, curfet)) { /* in a field ? */
|
---|
86 |
|
---|
87 | cfetp = infetp; /* set fet pointer */
|
---|
88 |
|
---|
89 | if ((cfetp) AND (NOT ebflag))
|
---|
90 | (*cfetp->ebto)(cfetp->ftags); /* load ebuf */
|
---|
91 |
|
---|
92 | if (cfetp)
|
---|
93 | (*cfetp->ebfrom)(cfetp->ftags); /* process ebuf */
|
---|
94 |
|
---|
95 | if (cfetp)
|
---|
96 | (*cfetp->redisp)(cfetp->ftags); /* redisplay */
|
---|
97 |
|
---|
98 | ebflag = FALSE;
|
---|
99 | }
|
---|
100 | }
|
---|
101 |
|
---|
102 | /* |
---|
103 |
|
---|
104 | */
|
---|
105 |
|
---|
106 | /*
|
---|
107 | =============================================================================
|
---|
108 | nokey() -- null key function
|
---|
109 | =============================================================================
|
---|
110 | */
|
---|
111 |
|
---|
112 | short nokey(void)
|
---|
113 | {
|
---|
114 | return(FALSE);
|
---|
115 | }
|
---|
116 |
|
---|
117 | /* |
---|
118 |
|
---|
119 | */
|
---|
120 |
|
---|
121 | /*
|
---|
122 | =============================================================================
|
---|
123 | cmvgen() -- general cursor mover
|
---|
124 | =============================================================================
|
---|
125 | */
|
---|
126 |
|
---|
127 | void cmvgen(void)
|
---|
128 | {
|
---|
129 | register short nc, newrow, newcol, newpos;
|
---|
130 |
|
---|
131 | (*premove)(); /* handle PRE-MOVE functions */
|
---|
132 |
|
---|
133 | nc = (*curtype)(); /* get new CURSOR TYPE wanted */
|
---|
134 |
|
---|
135 | newrow = YTOR(cyval); /* setup new row */
|
---|
136 | newcol = XTOC(cxval); /* setup new column */
|
---|
137 |
|
---|
138 | if (cmtype NE nc) { /* if changed ... */
|
---|
139 |
|
---|
140 | nchwait = curhold; /* set hold time */
|
---|
141 | ncvwait = curhold;
|
---|
142 |
|
---|
143 | LastRow = -1; /* reset last position */
|
---|
144 | LastCol = -1;
|
---|
145 | }
|
---|
146 |
|
---|
147 | /* see if we've got a new text cursor position */
|
---|
148 |
|
---|
149 | if ((newrow NE LastRow) OR (newcol NE LastCol))
|
---|
150 | newpos = TRUE;
|
---|
151 | else
|
---|
152 | newpos = FALSE;
|
---|
153 |
|
---|
154 | /* setup horizontal and vertical timer counts */
|
---|
155 |
|
---|
156 | chtime = (nc EQ CT_GRAF) ? hcwval : thcwval;
|
---|
157 | cvtime = (nc EQ CT_GRAF) ? vcwval : ((nc EQ CT_SMTH) ? syrate : tvcwval);
|
---|
158 |
|
---|
159 | switch (nc) { /* switch on new cursor type */
|
---|
160 |
|
---|
161 | case CT_GRAF: /* GRAPHIC CURSOR */
|
---|
162 |
|
---|
163 | if (cmtype EQ CT_SCOR) { /* change from score text */
|
---|
164 |
|
---|
165 | stcoff(); /* turn off text */
|
---|
166 | sgcon(); /* turn on graphics */
|
---|
167 | }
|
---|
168 |
|
---|
169 | cmtype = nc; /* set cursor type */
|
---|
170 | gcurpos(cxval, cyval); /* position cursor */
|
---|
171 | break;
|
---|
172 |
|
---|
173 | /* |
---|
174 |
|
---|
175 | */
|
---|
176 | case CT_TEXT: /* TEXT CURSOR */
|
---|
177 |
|
---|
178 | cmtype = nc; /* set cursor type */
|
---|
179 |
|
---|
180 | if (newpos)
|
---|
181 | itcpos(newrow, newcol); /* position cursor */
|
---|
182 |
|
---|
183 | break;
|
---|
184 |
|
---|
185 | case CT_VIRT: /* VIRTUAL TYPEWRITER CURSOR */
|
---|
186 |
|
---|
187 | cmtype = nc; /* set cursor type */
|
---|
188 | ttcpos(vtcrow, vtccol); /* position cursor */
|
---|
189 | break;
|
---|
190 |
|
---|
191 | case CT_SCOR: /* SCORE TEXT CURSOR */
|
---|
192 |
|
---|
193 | if (cmtype EQ CT_GRAF) /* change from graphics */
|
---|
194 | sgcoff(); /* turn off graphics */
|
---|
195 |
|
---|
196 | cmtype = nc; /* set cursor type */
|
---|
197 |
|
---|
198 | if (newpos)
|
---|
199 | stcpos(newrow, newcol); /* position cursor */
|
---|
200 |
|
---|
201 | break;
|
---|
202 |
|
---|
203 | case CT_SMTH: /* SMOOTH SCROLL TEXT CURSOR */
|
---|
204 |
|
---|
205 | cmtype = nc; /* set cursor type */
|
---|
206 |
|
---|
207 | if (newpos)
|
---|
208 | ctcpos(newrow, newcol); /* position cursor */
|
---|
209 |
|
---|
210 | break;
|
---|
211 |
|
---|
212 | case CT_MENU: /* SUBMENU CURSOR */
|
---|
213 |
|
---|
214 | cmtype = nc; /* set cursor type */
|
---|
215 | mtcpos(vtcrow, vtccol); /* position cursor */
|
---|
216 | break;
|
---|
217 | }
|
---|
218 |
|
---|
219 | LastRow = newrow;
|
---|
220 | LastCol = newcol;
|
---|
221 |
|
---|
222 | (*pstmove)(); /* handle POST-MOVE functions */
|
---|
223 | }
|
---|
224 |
|
---|
225 | /* |
---|
226 |
|
---|
227 | */
|
---|
228 |
|
---|
229 | /*
|
---|
230 | =============================================================================
|
---|
231 | crxrate() -- calculate cursor X rate
|
---|
232 | =============================================================================
|
---|
233 | */
|
---|
234 |
|
---|
235 | short crxrate(short cv)
|
---|
236 | {
|
---|
237 | register short cs;
|
---|
238 |
|
---|
239 | if (cv GE xycntr) {
|
---|
240 |
|
---|
241 | cv -= xycntr;
|
---|
242 | cs = 1;
|
---|
243 | curpos = -cv;
|
---|
244 |
|
---|
245 | } else {
|
---|
246 |
|
---|
247 | cv = xycntr - cv;
|
---|
248 | cs = 0;
|
---|
249 | curpos = cv;
|
---|
250 | }
|
---|
251 |
|
---|
252 | if (cv > 127)
|
---|
253 | cv = 127;
|
---|
254 |
|
---|
255 | return(cs ? -cratex[cv] : cratex[cv]);
|
---|
256 | }
|
---|
257 |
|
---|
258 | /* |
---|
259 |
|
---|
260 | */
|
---|
261 |
|
---|
262 | /*
|
---|
263 | =============================================================================
|
---|
264 | cryrate() -- calculate cursor Y rate
|
---|
265 | =============================================================================
|
---|
266 | */
|
---|
267 |
|
---|
268 | short cryrate(short cv)
|
---|
269 | {
|
---|
270 | register short cs;
|
---|
271 |
|
---|
272 | if (cv GE xycntr) {
|
---|
273 |
|
---|
274 | cv -= xycntr;
|
---|
275 | cs = 1;
|
---|
276 | curpos = -cv;
|
---|
277 |
|
---|
278 | } else {
|
---|
279 |
|
---|
280 | cv = xycntr - cv;
|
---|
281 | cs = 0;
|
---|
282 | curpos = cv;
|
---|
283 | }
|
---|
284 |
|
---|
285 | if (cv > 127)
|
---|
286 | cv = 127;
|
---|
287 |
|
---|
288 | return(cs ? -cratey[cv] : cratey[cv]);
|
---|
289 | }
|
---|
290 |
|
---|
291 | /* |
---|
292 |
|
---|
293 | */
|
---|
294 |
|
---|
295 | /*
|
---|
296 | =============================================================================
|
---|
297 | cmfix() -- cursor motion initial movement processing
|
---|
298 | =============================================================================
|
---|
299 | */
|
---|
300 |
|
---|
301 | void cmfix(void)
|
---|
302 | {
|
---|
303 | register short acx, acy, scx, scy;
|
---|
304 |
|
---|
305 | crxrate(sigtab[55][0]); /* get cursor x value */
|
---|
306 | acx = abs(curpos);
|
---|
307 |
|
---|
308 | cryrate(sigtab[56][0]); /* get cursor y value */
|
---|
309 | acy = abs(curpos);
|
---|
310 |
|
---|
311 | scx = sign(cxrate, 1);
|
---|
312 | scy = sign(cyrate, 1);
|
---|
313 |
|
---|
314 | if (cmfirst) { /* first motion ? */
|
---|
315 |
|
---|
316 | if (acx GE acy) { /* vertical movement */
|
---|
317 |
|
---|
318 | cyrate = 0;
|
---|
319 | cxrate = scx;
|
---|
320 | nchwait = curhold;
|
---|
321 | ncvwait = cvtime;
|
---|
322 |
|
---|
323 | } else { /* horizontal movement */
|
---|
324 |
|
---|
325 | cxrate = 0;
|
---|
326 | cyrate = scy;
|
---|
327 | ncvwait = curhold;
|
---|
328 | nchwait = chtime;
|
---|
329 | }
|
---|
330 |
|
---|
331 | cmfirst = FALSE;
|
---|
332 |
|
---|
333 | } else {
|
---|
334 |
|
---|
335 | /* limit text movement to 1 axis */
|
---|
336 |
|
---|
337 | if (cmtype NE CT_GRAF)
|
---|
338 | if (acx GE acy)
|
---|
339 | cyrate = 0;
|
---|
340 | else
|
---|
341 | cxrate = 0;
|
---|
342 | }
|
---|
343 | }
|
---|
344 |
|
---|
345 | /* |
---|
346 |
|
---|
347 | */
|
---|
348 |
|
---|
349 | /*
|
---|
350 | =============================================================================
|
---|
351 | cxkstd() -- standard cursor x rate calculation
|
---|
352 | =============================================================================
|
---|
353 | */
|
---|
354 |
|
---|
355 | void cxkstd(void)
|
---|
356 | {
|
---|
357 | trkball = FALSE;
|
---|
358 | tkctrl = FALSE;
|
---|
359 | txflag = FALSE;
|
---|
360 | tyflag = FALSE;
|
---|
361 |
|
---|
362 | if (astat) { /* contact */
|
---|
363 |
|
---|
364 | if (xkstat EQ FALSE) {
|
---|
365 |
|
---|
366 | if (xkcount) { /* debounce */
|
---|
367 |
|
---|
368 | xkcount--;
|
---|
369 | return;
|
---|
370 | }
|
---|
371 |
|
---|
372 | xkstat = TRUE;
|
---|
373 | chwait = 1;
|
---|
374 | nchwait = curhold;
|
---|
375 |
|
---|
376 | if (ykstat)
|
---|
377 | (*xy_dn)();
|
---|
378 | }
|
---|
379 |
|
---|
380 | cxrate = -crxrate(aval);
|
---|
381 | /* |
---|
382 |
|
---|
383 | */
|
---|
384 | } else { /* release */
|
---|
385 |
|
---|
386 | if (xkstat AND ykstat)
|
---|
387 | (*xy_up)();
|
---|
388 |
|
---|
389 | xkstat = FALSE;
|
---|
390 | xkcount = 1;
|
---|
391 | cxrate = 0;
|
---|
392 |
|
---|
393 | if (ykstat EQ FALSE) {
|
---|
394 |
|
---|
395 | cyrate = 0;
|
---|
396 | ykcount = 1;
|
---|
397 | nchwait = chtime;
|
---|
398 | ncvwait = cvtime;
|
---|
399 | chwait = 1;
|
---|
400 | cvwait = 1;
|
---|
401 | cmfirst = TRUE;
|
---|
402 | }
|
---|
403 | }
|
---|
404 |
|
---|
405 | return;
|
---|
406 | }
|
---|
407 |
|
---|
408 | /* |
---|
409 |
|
---|
410 | */
|
---|
411 |
|
---|
412 | /*
|
---|
413 | =============================================================================
|
---|
414 | cykstd() -- standard cursor y rate calculation
|
---|
415 | =============================================================================
|
---|
416 | */
|
---|
417 |
|
---|
418 | void cykstd(void)
|
---|
419 | {
|
---|
420 | trkball = FALSE;
|
---|
421 | tkctrl = FALSE;
|
---|
422 | txflag = FALSE;
|
---|
423 | tyflag = FALSE;
|
---|
424 |
|
---|
425 | if (astat) { /* contact */
|
---|
426 |
|
---|
427 | if (ykstat EQ FALSE) {
|
---|
428 |
|
---|
429 | if (ykcount) { /* debounce */
|
---|
430 |
|
---|
431 | ykcount--;
|
---|
432 | return;
|
---|
433 | }
|
---|
434 |
|
---|
435 | ykstat = TRUE;
|
---|
436 | cvwait = 1;
|
---|
437 | ncvwait = curhold;
|
---|
438 |
|
---|
439 | if (xkstat)
|
---|
440 | (*xy_dn)();
|
---|
441 | }
|
---|
442 |
|
---|
443 | cyrate = cryrate(aval);
|
---|
444 | /* |
---|
445 |
|
---|
446 | */
|
---|
447 | } else { /* release */
|
---|
448 |
|
---|
449 | if (xkstat AND ykstat)
|
---|
450 | (*xy_up)();
|
---|
451 |
|
---|
452 | ykstat = FALSE;
|
---|
453 | ykcount = 1;
|
---|
454 | cyrate = 0;
|
---|
455 |
|
---|
456 | if (xkstat EQ FALSE) {
|
---|
457 |
|
---|
458 | cxrate = 0;
|
---|
459 | xkcount = 1;
|
---|
460 | nchwait = chtime;
|
---|
461 | ncvwait = cvtime;
|
---|
462 | chwait = 1;
|
---|
463 | cvwait = 1;
|
---|
464 | cmfirst = TRUE;
|
---|
465 | }
|
---|
466 | }
|
---|
467 |
|
---|
468 | return;
|
---|
469 | }
|
---|
470 |
|
---|
471 | /* |
---|
472 |
|
---|
473 | */
|
---|
474 |
|
---|
475 | /*
|
---|
476 | =============================================================================
|
---|
477 | stdmkey() -- standard M key processing
|
---|
478 | =============================================================================
|
---|
479 | */
|
---|
480 |
|
---|
481 | void stdmkey(void)
|
---|
482 | {
|
---|
483 | if (astat) {
|
---|
484 |
|
---|
485 | runit = FALSE;
|
---|
486 | submenu = FALSE;
|
---|
487 | }
|
---|
488 | }
|
---|
489 |
|
---|
490 | /*
|
---|
491 | =============================================================================
|
---|
492 | stddkey() - standard data key processing
|
---|
493 | =============================================================================
|
---|
494 | */
|
---|
495 |
|
---|
496 | void stddkey(void)
|
---|
497 | {
|
---|
498 | if (infield(stcrow, stccol, curfet)) {
|
---|
499 |
|
---|
500 | cfetp = infetp; /* set field pointer */
|
---|
501 |
|
---|
502 | if (astat) { /* only do action on closures */
|
---|
503 |
|
---|
504 | if (!ebflag)
|
---|
505 | (*cfetp->ebto)(cfetp->ftags); /* setup ebuf */
|
---|
506 |
|
---|
507 | (*cfetp->datain)(cfetp->ftags, asig - 60); /* enter */
|
---|
508 | }
|
---|
509 |
|
---|
510 | } else {
|
---|
511 |
|
---|
512 | if (astat)
|
---|
513 | (*not_fld)(asig - 60); /* not in field */
|
---|
514 | }
|
---|
515 | }
|
---|
516 |
|
---|
517 | /* |
---|
518 |
|
---|
519 | */
|
---|
520 |
|
---|
521 | /*
|
---|
522 | =============================================================================
|
---|
523 | cxgen() -- standard cursor x update processing
|
---|
524 | =============================================================================
|
---|
525 | */
|
---|
526 |
|
---|
527 | void cxgen(void)
|
---|
528 | {
|
---|
529 | cxval += cxrate;
|
---|
530 |
|
---|
531 | if (cxval > CXMAX)
|
---|
532 | cxval = CXMAX;
|
---|
533 | else if (cxval < 0)
|
---|
534 | cxval = 0;
|
---|
535 |
|
---|
536 | return;
|
---|
537 | }
|
---|
538 |
|
---|
539 | /*
|
---|
540 | =============================================================================
|
---|
541 | cygen() -- standard cursor y update processing
|
---|
542 | =============================================================================
|
---|
543 | */
|
---|
544 |
|
---|
545 | void cygen(void)
|
---|
546 | {
|
---|
547 | cyval += cyrate;
|
---|
548 |
|
---|
549 | if (cyval > CYMAX)
|
---|
550 | cyval = CYMAX;
|
---|
551 | else if (cyval < 0)
|
---|
552 | cyval = 0;
|
---|
553 |
|
---|
554 | return;
|
---|
555 | }
|
---|