| 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
|
|---|
| 13 | short debugen = 1;
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| 16 | int16_t syrate = SMYRATE; /* smooth scroll vertical rate */
|
|---|
| 17 |
|
|---|
| 18 | int16_t LastRow = -1;
|
|---|
| 19 | int16_t LastCol = -1;
|
|---|
| 20 |
|
|---|
| 21 | /*
|
|---|
| 22 | =============================================================================
|
|---|
| 23 | enterit() -- standard data entry (ENTER) function
|
|---|
| 24 | =============================================================================
|
|---|
| 25 | */
|
|---|
| 26 |
|
|---|
| 27 | void 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 |
|
|---|
| 61 | void nokey(void)
|
|---|
| 62 | {
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | /*
|
|---|
| 66 | =============================================================================
|
|---|
| 67 | nodkey() -- null d_key function
|
|---|
| 68 | =============================================================================
|
|---|
| 69 | */
|
|---|
| 70 |
|
|---|
| 71 | void nodkey(int16_t k)
|
|---|
| 72 | {
|
|---|
| 73 | (void)k;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | /*
|
|---|
| 77 | =============================================================================
|
|---|
| 78 | nonf() -- null non_fld function
|
|---|
| 79 | =============================================================================
|
|---|
| 80 | */
|
|---|
| 81 |
|
|---|
| 82 | int16_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 |
|
|---|
| 95 | int16_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 |
|
|---|
| 109 | void 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 |
|
|---|
| 211 | int16_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 |
|
|---|
| 240 | int16_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 |
|
|---|
| 269 | void 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 | cxkstd() -- standard cursor x rate calculation
|
|---|
| 316 | =============================================================================
|
|---|
| 317 | */
|
|---|
| 318 |
|
|---|
| 319 | void cxkstd(void)
|
|---|
| 320 | {
|
|---|
| 321 | trkball = FALSE;
|
|---|
| 322 | tkctrl = FALSE;
|
|---|
| 323 | txflag = FALSE;
|
|---|
| 324 | tyflag = FALSE;
|
|---|
| 325 |
|
|---|
| 326 | if (astat) { /* contact */
|
|---|
| 327 |
|
|---|
| 328 | if (xkstat EQ FALSE) {
|
|---|
| 329 |
|
|---|
| 330 | if (xkcount) { /* debounce */
|
|---|
| 331 |
|
|---|
| 332 | xkcount--;
|
|---|
| 333 | return;
|
|---|
| 334 | }
|
|---|
| 335 |
|
|---|
| 336 | xkstat = TRUE;
|
|---|
| 337 | chwait = 1;
|
|---|
| 338 | nchwait = curhold;
|
|---|
| 339 |
|
|---|
| 340 | if (ykstat)
|
|---|
| 341 | (*xy_dn)();
|
|---|
| 342 | }
|
|---|
| 343 |
|
|---|
| 344 | cxrate = -crxrate(aval);
|
|---|
| 345 |
|
|---|
| 346 | } else { /* release */
|
|---|
| 347 |
|
|---|
| 348 | if (xkstat AND ykstat)
|
|---|
| 349 | (*xy_up)();
|
|---|
| 350 |
|
|---|
| 351 | xkstat = FALSE;
|
|---|
| 352 | xkcount = 1;
|
|---|
| 353 | cxrate = 0;
|
|---|
| 354 |
|
|---|
| 355 | if (ykstat EQ FALSE) {
|
|---|
| 356 |
|
|---|
| 357 | cyrate = 0;
|
|---|
| 358 | ykcount = 1;
|
|---|
| 359 | nchwait = chtime;
|
|---|
| 360 | ncvwait = cvtime;
|
|---|
| 361 | chwait = 1;
|
|---|
| 362 | cvwait = 1;
|
|---|
| 363 | cmfirst = TRUE;
|
|---|
| 364 | }
|
|---|
| 365 | }
|
|---|
| 366 |
|
|---|
| 367 | return;
|
|---|
| 368 | }
|
|---|
| 369 |
|
|---|
| 370 | /*
|
|---|
| 371 | =============================================================================
|
|---|
| 372 | cykstd() -- standard cursor y rate calculation
|
|---|
| 373 | =============================================================================
|
|---|
| 374 | */
|
|---|
| 375 |
|
|---|
| 376 | void cykstd(void)
|
|---|
| 377 | {
|
|---|
| 378 | trkball = FALSE;
|
|---|
| 379 | tkctrl = FALSE;
|
|---|
| 380 | txflag = FALSE;
|
|---|
| 381 | tyflag = FALSE;
|
|---|
| 382 |
|
|---|
| 383 | if (astat) { /* contact */
|
|---|
| 384 |
|
|---|
| 385 | if (ykstat EQ FALSE) {
|
|---|
| 386 |
|
|---|
| 387 | if (ykcount) { /* debounce */
|
|---|
| 388 |
|
|---|
| 389 | ykcount--;
|
|---|
| 390 | return;
|
|---|
| 391 | }
|
|---|
| 392 |
|
|---|
| 393 | ykstat = TRUE;
|
|---|
| 394 | cvwait = 1;
|
|---|
| 395 | ncvwait = curhold;
|
|---|
| 396 |
|
|---|
| 397 | if (xkstat)
|
|---|
| 398 | (*xy_dn)();
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | cyrate = cryrate(aval);
|
|---|
| 402 |
|
|---|
| 403 | } else { /* release */
|
|---|
| 404 |
|
|---|
| 405 | if (xkstat AND ykstat)
|
|---|
| 406 | (*xy_up)();
|
|---|
| 407 |
|
|---|
| 408 | ykstat = FALSE;
|
|---|
| 409 | ykcount = 1;
|
|---|
| 410 | cyrate = 0;
|
|---|
| 411 |
|
|---|
| 412 | if (xkstat EQ FALSE) {
|
|---|
| 413 |
|
|---|
| 414 | cxrate = 0;
|
|---|
| 415 | xkcount = 1;
|
|---|
| 416 | nchwait = chtime;
|
|---|
| 417 | ncvwait = cvtime;
|
|---|
| 418 | chwait = 1;
|
|---|
| 419 | cvwait = 1;
|
|---|
| 420 | cmfirst = TRUE;
|
|---|
| 421 | }
|
|---|
| 422 | }
|
|---|
| 423 |
|
|---|
| 424 | return;
|
|---|
| 425 | }
|
|---|
| 426 |
|
|---|
| 427 | /*
|
|---|
| 428 | =============================================================================
|
|---|
| 429 | stdmkey() -- standard M key processing
|
|---|
| 430 | =============================================================================
|
|---|
| 431 | */
|
|---|
| 432 |
|
|---|
| 433 | void stdmkey(void)
|
|---|
| 434 | {
|
|---|
| 435 | if (astat) {
|
|---|
| 436 |
|
|---|
| 437 | runit = FALSE;
|
|---|
| 438 | submenu = FALSE;
|
|---|
| 439 | }
|
|---|
| 440 | }
|
|---|
| 441 |
|
|---|
| 442 | /*
|
|---|
| 443 | =============================================================================
|
|---|
| 444 | stddkey() - standard data key processing
|
|---|
| 445 | =============================================================================
|
|---|
| 446 | */
|
|---|
| 447 |
|
|---|
| 448 | void stddkey(int16_t k)
|
|---|
| 449 | {
|
|---|
| 450 | (void)k;
|
|---|
| 451 |
|
|---|
| 452 | if (infield(stcrow, stccol, curfet)) {
|
|---|
| 453 |
|
|---|
| 454 | cfetp = infetp; /* set field pointer */
|
|---|
| 455 |
|
|---|
| 456 | if (astat) { /* only do action on closures */
|
|---|
| 457 |
|
|---|
| 458 | if (!ebflag)
|
|---|
| 459 | (*cfetp->ebto)(cfetp->ftags); /* setup ebuf */
|
|---|
| 460 |
|
|---|
| 461 | (*cfetp->datain)(cfetp->ftags, asig - 60); /* enter */
|
|---|
| 462 | }
|
|---|
| 463 |
|
|---|
| 464 | } else {
|
|---|
| 465 |
|
|---|
| 466 | if (astat)
|
|---|
| 467 | (*not_fld)(asig - 60); /* not in field */
|
|---|
| 468 | }
|
|---|
| 469 | }
|
|---|
| 470 |
|
|---|
| 471 | /*
|
|---|
| 472 | =============================================================================
|
|---|
| 473 | cxgen() -- standard cursor x update processing
|
|---|
| 474 | =============================================================================
|
|---|
| 475 | */
|
|---|
| 476 |
|
|---|
| 477 | void cxgen(void)
|
|---|
| 478 | {
|
|---|
| 479 | cxval += cxrate;
|
|---|
| 480 |
|
|---|
| 481 | if (cxval > CXMAX)
|
|---|
| 482 | cxval = CXMAX;
|
|---|
| 483 | else if (cxval < 0)
|
|---|
| 484 | cxval = 0;
|
|---|
| 485 |
|
|---|
| 486 | return;
|
|---|
| 487 | }
|
|---|
| 488 |
|
|---|
| 489 | /*
|
|---|
| 490 | =============================================================================
|
|---|
| 491 | cygen() -- standard cursor y update processing
|
|---|
| 492 | =============================================================================
|
|---|
| 493 | */
|
|---|
| 494 |
|
|---|
| 495 | void cygen(void)
|
|---|
| 496 | {
|
|---|
| 497 | cyval += cyrate;
|
|---|
| 498 |
|
|---|
| 499 | if (cyval > CYMAX)
|
|---|
| 500 | cyval = CYMAX;
|
|---|
| 501 | else if (cyval < 0)
|
|---|
| 502 | cyval = 0;
|
|---|
| 503 |
|
|---|
| 504 | return;
|
|---|
| 505 | }
|
|---|
| 506 |
|
|---|