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

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

Strip trailing tabs and spaces.

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