source: buchla-68k/orig/RAM/ENTERIT.C@ ee49131

Last change on this file since ee49131 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

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