source: buchla-68k/ram/enterit.c@ 6262b5c

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

Added include files for global functions and variables.

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