| 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 | */
|
|---|
| 24 |
|
|---|
| 25 | /*
|
|---|
| 26 | =============================================================================
|
|---|
| 27 | enterit() -- standard data entry (ENTER) function
|
|---|
| 28 | =============================================================================
|
|---|
| 29 | */
|
|---|
| 30 |
|
|---|
| 31 | void enterit(void)
|
|---|
| 32 | {
|
|---|
| 33 | if (NOT astat) /* only on closures */
|
|---|
| 34 | return;
|
|---|
| 35 |
|
|---|
| 36 | #if DEBUGIT
|
|---|
| 37 | if (debugsw AND debugen)
|
|---|
| 38 | printf("enterit(): ENTRY row = %d col = %d curfet =$%lX\n",
|
|---|
| 39 | stcrow, stccol, curfet);
|
|---|
| 40 | #endif
|
|---|
| 41 |
|
|---|
| 42 | if (infield(stcrow, stccol, curfet)) { /* in a field ? */
|
|---|
| 43 |
|
|---|
| 44 | cfetp = infetp; /* set fet pointer */
|
|---|
| 45 |
|
|---|
| 46 | if ((cfetp) AND (NOT ebflag))
|
|---|
| 47 | (*cfetp->ebto)(cfetp->ftags); /* load ebuf */
|
|---|
| 48 |
|
|---|
| 49 | if (cfetp)
|
|---|
| 50 | (*cfetp->ebfrom)(cfetp->ftags); /* process ebuf */
|
|---|
| 51 |
|
|---|
| 52 | if (cfetp)
|
|---|
| 53 | (*cfetp->redisp)(cfetp->ftags); /* redisplay */
|
|---|
| 54 |
|
|---|
| 55 | ebflag = FALSE;
|
|---|
| 56 | }
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | /* |
|---|
| 60 |
|
|---|
| 61 | */
|
|---|
| 62 |
|
|---|
| 63 | /*
|
|---|
| 64 | =============================================================================
|
|---|
| 65 | nokey() -- null key function
|
|---|
| 66 | =============================================================================
|
|---|
| 67 | */
|
|---|
| 68 |
|
|---|
| 69 | void nokey(void)
|
|---|
| 70 | {
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | /* |
|---|
| 74 |
|
|---|
| 75 | */
|
|---|
| 76 |
|
|---|
| 77 | /*
|
|---|
| 78 | =============================================================================
|
|---|
| 79 | nodkey() -- null d_key function
|
|---|
| 80 | =============================================================================
|
|---|
| 81 | */
|
|---|
| 82 |
|
|---|
| 83 | void nodkey(int16_t k)
|
|---|
| 84 | {
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | /* |
|---|
| 88 |
|
|---|
| 89 | */
|
|---|
| 90 |
|
|---|
| 91 | /*
|
|---|
| 92 | =============================================================================
|
|---|
| 93 | nonf() -- null non_fld function
|
|---|
| 94 | =============================================================================
|
|---|
| 95 | */
|
|---|
| 96 |
|
|---|
| 97 | int16_t nonf(int16_t k)
|
|---|
| 98 | {
|
|---|
| 99 | return(SUCCESS);
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | /* |
|---|
| 103 |
|
|---|
| 104 | */
|
|---|
| 105 |
|
|---|
| 106 | /*
|
|---|
| 107 | =============================================================================
|
|---|
| 108 | entbh() -- data entry box-hit function
|
|---|
| 109 | =============================================================================
|
|---|
| 110 | */
|
|---|
| 111 |
|
|---|
| 112 | int16_t entbh(int16_t n)
|
|---|
| 113 | {
|
|---|
| 114 | enterit();
|
|---|
| 115 | return(SUCCESS);
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | /* |
|---|
| 119 |
|
|---|
| 120 | */
|
|---|
| 121 |
|
|---|
| 122 | /*
|
|---|
| 123 | =============================================================================
|
|---|
| 124 | cmvgen() -- general cursor mover
|
|---|
| 125 | =============================================================================
|
|---|
| 126 | */
|
|---|
| 127 |
|
|---|
| 128 | void cmvgen(void)
|
|---|
| 129 | {
|
|---|
| 130 | register int16_t 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 |
|
|---|
| 236 | int16_t crxrate(int16_t cv)
|
|---|
| 237 | {
|
|---|
| 238 | register int16_t cs;
|
|---|
| 239 |
|
|---|
| 240 | if (cv GE xycntr) {
|
|---|
| 241 |
|
|---|
| 242 | cv -= xycntr;
|
|---|
| 243 | cs = 1;
|
|---|
| 244 | curpos = -cv;
|
|---|
| 245 |
|
|---|
| 246 | } else {
|
|---|
| 247 |
|
|---|
| 248 | cv = xycntr - cv;
|
|---|
| 249 | cs = 0;
|
|---|
| 250 | curpos = cv;
|
|---|
| 251 | }
|
|---|
| 252 |
|
|---|
| 253 | if (cv > 127)
|
|---|
| 254 | cv = 127;
|
|---|
| 255 |
|
|---|
| 256 | return(cs ? -cratex[cv] : cratex[cv]);
|
|---|
| 257 | }
|
|---|
| 258 |
|
|---|
| 259 | /* |
|---|
| 260 |
|
|---|
| 261 | */
|
|---|
| 262 |
|
|---|
| 263 | /*
|
|---|
| 264 | =============================================================================
|
|---|
| 265 | cryrate() -- calculate cursor Y rate
|
|---|
| 266 | =============================================================================
|
|---|
| 267 | */
|
|---|
| 268 |
|
|---|
| 269 | int16_t cryrate(int16_t cv)
|
|---|
| 270 | {
|
|---|
| 271 | register int16_t cs;
|
|---|
| 272 |
|
|---|
| 273 | if (cv GE xycntr) {
|
|---|
| 274 |
|
|---|
| 275 | cv -= xycntr;
|
|---|
| 276 | cs = 1;
|
|---|
| 277 | curpos = -cv;
|
|---|
| 278 |
|
|---|
| 279 | } else {
|
|---|
| 280 |
|
|---|
| 281 | cv = xycntr - cv;
|
|---|
| 282 | cs = 0;
|
|---|
| 283 | curpos = cv;
|
|---|
| 284 | }
|
|---|
| 285 |
|
|---|
| 286 | if (cv > 127)
|
|---|
| 287 | cv = 127;
|
|---|
| 288 |
|
|---|
| 289 | return(cs ? -cratey[cv] : cratey[cv]);
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | /* |
|---|
| 293 |
|
|---|
| 294 | */
|
|---|
| 295 |
|
|---|
| 296 | /*
|
|---|
| 297 | =============================================================================
|
|---|
| 298 | cmfix() -- cursor motion initial movement processing
|
|---|
| 299 | =============================================================================
|
|---|
| 300 | */
|
|---|
| 301 |
|
|---|
| 302 | void cmfix(void)
|
|---|
| 303 | {
|
|---|
| 304 | register int16_t acx, acy, scx, scy;
|
|---|
| 305 |
|
|---|
| 306 | crxrate(sigtab[55][0]); /* get cursor x value */
|
|---|
| 307 | acx = abs(curpos);
|
|---|
| 308 |
|
|---|
| 309 | cryrate(sigtab[56][0]); /* get cursor y value */
|
|---|
| 310 | acy = abs(curpos);
|
|---|
| 311 |
|
|---|
| 312 | scx = sign(cxrate, 1);
|
|---|
| 313 | scy = sign(cyrate, 1);
|
|---|
| 314 |
|
|---|
| 315 | if (cmfirst) { /* first motion ? */
|
|---|
| 316 |
|
|---|
| 317 | if (acx GE acy) { /* vertical movement */
|
|---|
| 318 |
|
|---|
| 319 | cyrate = 0;
|
|---|
| 320 | cxrate = scx;
|
|---|
| 321 | nchwait = curhold;
|
|---|
| 322 | ncvwait = cvtime;
|
|---|
| 323 |
|
|---|
| 324 | } else { /* horizontal movement */
|
|---|
| 325 |
|
|---|
| 326 | cxrate = 0;
|
|---|
| 327 | cyrate = scy;
|
|---|
| 328 | ncvwait = curhold;
|
|---|
| 329 | nchwait = chtime;
|
|---|
| 330 | }
|
|---|
| 331 |
|
|---|
| 332 | cmfirst = FALSE;
|
|---|
| 333 |
|
|---|
| 334 | } else {
|
|---|
| 335 |
|
|---|
| 336 | /* limit text movement to 1 axis */
|
|---|
| 337 |
|
|---|
| 338 | if (cmtype NE CT_GRAF)
|
|---|
| 339 | if (acx GE acy)
|
|---|
| 340 | cyrate = 0;
|
|---|
| 341 | else
|
|---|
| 342 | cxrate = 0;
|
|---|
| 343 | }
|
|---|
| 344 | }
|
|---|
| 345 |
|
|---|
| 346 | /* |
|---|
| 347 |
|
|---|
| 348 | */
|
|---|
| 349 |
|
|---|
| 350 | /*
|
|---|
| 351 | =============================================================================
|
|---|
| 352 | cxkstd() -- standard cursor x rate calculation
|
|---|
| 353 | =============================================================================
|
|---|
| 354 | */
|
|---|
| 355 |
|
|---|
| 356 | void cxkstd(void)
|
|---|
| 357 | {
|
|---|
| 358 | trkball = FALSE;
|
|---|
| 359 | tkctrl = FALSE;
|
|---|
| 360 | txflag = FALSE;
|
|---|
| 361 | tyflag = FALSE;
|
|---|
| 362 |
|
|---|
| 363 | if (astat) { /* contact */
|
|---|
| 364 |
|
|---|
| 365 | if (xkstat EQ FALSE) {
|
|---|
| 366 |
|
|---|
| 367 | if (xkcount) { /* debounce */
|
|---|
| 368 |
|
|---|
| 369 | xkcount--;
|
|---|
| 370 | return;
|
|---|
| 371 | }
|
|---|
| 372 |
|
|---|
| 373 | xkstat = TRUE;
|
|---|
| 374 | chwait = 1;
|
|---|
| 375 | nchwait = curhold;
|
|---|
| 376 |
|
|---|
| 377 | if (ykstat)
|
|---|
| 378 | (*xy_dn)();
|
|---|
| 379 | }
|
|---|
| 380 |
|
|---|
| 381 | cxrate = -crxrate(aval);
|
|---|
| 382 | /* |
|---|
| 383 |
|
|---|
| 384 | */
|
|---|
| 385 | } else { /* release */
|
|---|
| 386 |
|
|---|
| 387 | if (xkstat AND ykstat)
|
|---|
| 388 | (*xy_up)();
|
|---|
| 389 |
|
|---|
| 390 | xkstat = FALSE;
|
|---|
| 391 | xkcount = 1;
|
|---|
| 392 | cxrate = 0;
|
|---|
| 393 |
|
|---|
| 394 | if (ykstat EQ FALSE) {
|
|---|
| 395 |
|
|---|
| 396 | cyrate = 0;
|
|---|
| 397 | ykcount = 1;
|
|---|
| 398 | nchwait = chtime;
|
|---|
| 399 | ncvwait = cvtime;
|
|---|
| 400 | chwait = 1;
|
|---|
| 401 | cvwait = 1;
|
|---|
| 402 | cmfirst = TRUE;
|
|---|
| 403 | }
|
|---|
| 404 | }
|
|---|
| 405 |
|
|---|
| 406 | return;
|
|---|
| 407 | }
|
|---|
| 408 |
|
|---|
| 409 | /* |
|---|
| 410 |
|
|---|
| 411 | */
|
|---|
| 412 |
|
|---|
| 413 | /*
|
|---|
| 414 | =============================================================================
|
|---|
| 415 | cykstd() -- standard cursor y rate calculation
|
|---|
| 416 | =============================================================================
|
|---|
| 417 | */
|
|---|
| 418 |
|
|---|
| 419 | void cykstd(void)
|
|---|
| 420 | {
|
|---|
| 421 | trkball = FALSE;
|
|---|
| 422 | tkctrl = FALSE;
|
|---|
| 423 | txflag = FALSE;
|
|---|
| 424 | tyflag = FALSE;
|
|---|
| 425 |
|
|---|
| 426 | if (astat) { /* contact */
|
|---|
| 427 |
|
|---|
| 428 | if (ykstat EQ FALSE) {
|
|---|
| 429 |
|
|---|
| 430 | if (ykcount) { /* debounce */
|
|---|
| 431 |
|
|---|
| 432 | ykcount--;
|
|---|
| 433 | return;
|
|---|
| 434 | }
|
|---|
| 435 |
|
|---|
| 436 | ykstat = TRUE;
|
|---|
| 437 | cvwait = 1;
|
|---|
| 438 | ncvwait = curhold;
|
|---|
| 439 |
|
|---|
| 440 | if (xkstat)
|
|---|
| 441 | (*xy_dn)();
|
|---|
| 442 | }
|
|---|
| 443 |
|
|---|
| 444 | cyrate = cryrate(aval);
|
|---|
| 445 | /* |
|---|
| 446 |
|
|---|
| 447 | */
|
|---|
| 448 | } else { /* release */
|
|---|
| 449 |
|
|---|
| 450 | if (xkstat AND ykstat)
|
|---|
| 451 | (*xy_up)();
|
|---|
| 452 |
|
|---|
| 453 | ykstat = FALSE;
|
|---|
| 454 | ykcount = 1;
|
|---|
| 455 | cyrate = 0;
|
|---|
| 456 |
|
|---|
| 457 | if (xkstat EQ FALSE) {
|
|---|
| 458 |
|
|---|
| 459 | cxrate = 0;
|
|---|
| 460 | xkcount = 1;
|
|---|
| 461 | nchwait = chtime;
|
|---|
| 462 | ncvwait = cvtime;
|
|---|
| 463 | chwait = 1;
|
|---|
| 464 | cvwait = 1;
|
|---|
| 465 | cmfirst = TRUE;
|
|---|
| 466 | }
|
|---|
| 467 | }
|
|---|
| 468 |
|
|---|
| 469 | return;
|
|---|
| 470 | }
|
|---|
| 471 |
|
|---|
| 472 | /* |
|---|
| 473 |
|
|---|
| 474 | */
|
|---|
| 475 |
|
|---|
| 476 | /*
|
|---|
| 477 | =============================================================================
|
|---|
| 478 | stdmkey() -- standard M key processing
|
|---|
| 479 | =============================================================================
|
|---|
| 480 | */
|
|---|
| 481 |
|
|---|
| 482 | void stdmkey(void)
|
|---|
| 483 | {
|
|---|
| 484 | if (astat) {
|
|---|
| 485 |
|
|---|
| 486 | runit = FALSE;
|
|---|
| 487 | submenu = FALSE;
|
|---|
| 488 | }
|
|---|
| 489 | }
|
|---|
| 490 |
|
|---|
| 491 | /*
|
|---|
| 492 | =============================================================================
|
|---|
| 493 | stddkey() - standard data key processing
|
|---|
| 494 | =============================================================================
|
|---|
| 495 | */
|
|---|
| 496 |
|
|---|
| 497 | void stddkey(int16_t k)
|
|---|
| 498 | {
|
|---|
| 499 | if (infield(stcrow, stccol, curfet)) {
|
|---|
| 500 |
|
|---|
| 501 | cfetp = infetp; /* set field pointer */
|
|---|
| 502 |
|
|---|
| 503 | if (astat) { /* only do action on closures */
|
|---|
| 504 |
|
|---|
| 505 | if (!ebflag)
|
|---|
| 506 | (*cfetp->ebto)(cfetp->ftags); /* setup ebuf */
|
|---|
| 507 |
|
|---|
| 508 | (*cfetp->datain)(cfetp->ftags, asig - 60); /* enter */
|
|---|
| 509 | }
|
|---|
| 510 |
|
|---|
| 511 | } else {
|
|---|
| 512 |
|
|---|
| 513 | if (astat)
|
|---|
| 514 | (*not_fld)(asig - 60); /* not in field */
|
|---|
| 515 | }
|
|---|
| 516 | }
|
|---|
| 517 |
|
|---|
| 518 | /* |
|---|
| 519 |
|
|---|
| 520 | */
|
|---|
| 521 |
|
|---|
| 522 | /*
|
|---|
| 523 | =============================================================================
|
|---|
| 524 | cxgen() -- standard cursor x update processing
|
|---|
| 525 | =============================================================================
|
|---|
| 526 | */
|
|---|
| 527 |
|
|---|
| 528 | void cxgen(void)
|
|---|
| 529 | {
|
|---|
| 530 | cxval += cxrate;
|
|---|
| 531 |
|
|---|
| 532 | if (cxval > CXMAX)
|
|---|
| 533 | cxval = CXMAX;
|
|---|
| 534 | else if (cxval < 0)
|
|---|
| 535 | cxval = 0;
|
|---|
| 536 |
|
|---|
| 537 | return;
|
|---|
| 538 | }
|
|---|
| 539 |
|
|---|
| 540 | /*
|
|---|
| 541 | =============================================================================
|
|---|
| 542 | cygen() -- standard cursor y update processing
|
|---|
| 543 | =============================================================================
|
|---|
| 544 | */
|
|---|
| 545 |
|
|---|
| 546 | void cygen(void)
|
|---|
| 547 | {
|
|---|
| 548 | cyval += cyrate;
|
|---|
| 549 |
|
|---|
| 550 | if (cyval > CYMAX)
|
|---|
| 551 | cyval = CYMAX;
|
|---|
| 552 | else if (cyval < 0)
|
|---|
| 553 | cyval = 0;
|
|---|
| 554 |
|
|---|
| 555 | return;
|
|---|
| 556 | }
|
|---|
| 557 |
|
|---|