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

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

Removed form-feed comments.

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