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

Last change on this file was 00c31a2, checked in by Thomas Lopatic <thomas@…>, 6 years ago

Fixed parentheses and braces.

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