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