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