[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | wheel.c -- MIDAS-VII -- scroll wheel, trackball and mouse functions
|
---|
| 4 | Version 47 -- 1989-12-19 -- D.N. Lynx Crowe
|
---|
| 5 |
|
---|
| 6 | M8 Mouse driver -- uses 3 byte Microsoft format (default).
|
---|
| 7 | =============================================================================
|
---|
| 8 | */
|
---|
| 9 |
|
---|
| 10 | #define DEBUGMS 0
|
---|
| 11 | #define DEBUGTF 0
|
---|
| 12 | #define DEBUGTK 0
|
---|
| 13 |
|
---|
[b28a12e] | 14 | #include "ram.h"
|
---|
[e225e77] | 15 |
|
---|
[f40a309] | 16 | #define M_FL_CT 1024 /* mouse flush count */
|
---|
| 17 |
|
---|
| 18 | #define M_ST_TM 2
|
---|
| 19 | #define C_PER_S 500
|
---|
| 20 | #define MAXTRIES 10
|
---|
| 21 |
|
---|
| 22 | #define MATIME 2000 /* mouse activity timeout -- ms*/
|
---|
| 23 |
|
---|
| 24 | #define CFR0 (BR_1200|NSB_1) /* UART CFR0 1200 baud, 1 stop bit */
|
---|
| 25 | #define CFR1 (P_NONE|NDB_7) /* UART CFR1 7 data bits, no parity */
|
---|
| 26 |
|
---|
| 27 | #define M_NONE 0 /* No errors detected */
|
---|
| 28 | #define M_FLUSH 1 /* Unable to flush mouse buffer */
|
---|
| 29 | #define M_SYNC 2 /* Mouse out of sync */
|
---|
| 30 | #define M_NORESP 3 /* No response from mouse */
|
---|
| 31 | #define M_RESPNG 4 /* Bad response from mouse */
|
---|
| 32 |
|
---|
| 33 | #if DEBUGMS
|
---|
| 34 | short debugms;
|
---|
| 35 | #endif
|
---|
| 36 |
|
---|
| 37 | #if DEBUGTF
|
---|
| 38 | short debugtf;
|
---|
| 39 |
|
---|
| 40 | long txficnt;
|
---|
| 41 | long tyficnt;
|
---|
| 42 | #endif
|
---|
| 43 |
|
---|
| 44 | #if DEBUGTK
|
---|
| 45 | short debugtk;
|
---|
| 46 | #endif
|
---|
| 47 |
|
---|
[7258c6a] | 48 | int16_t M_error; /* mouse I/F error code */
|
---|
| 49 | int16_t M_state; /* mouse state */
|
---|
| 50 | int16_t M_oldbs; /* previous mouse button state */
|
---|
[f40a309] | 51 |
|
---|
[7258c6a] | 52 | int8_t M_strng[32]; /* mouse input string buffer */
|
---|
[f40a309] | 53 |
|
---|
[7258c6a] | 54 | int16_t msctrl; /* mouse control flag -- mouse update */
|
---|
| 55 | int16_t msflag; /* mouse control flag -- mouse movement */
|
---|
| 56 | int16_t msrtag; /* mouse control flag -- mouse reset */
|
---|
[9519422] | 57 | int16_t msxres; /* mouse x residue */
|
---|
[7258c6a] | 58 | int16_t msyres; /* mouse y residue */
|
---|
| 59 | int16_t msxmov; /* mouse x movement */
|
---|
| 60 | int16_t msymov; /* mouse y movement */
|
---|
| 61 | int16_t msxdiv; /* mouse x divisor */
|
---|
| 62 | int16_t msydiv; /* mouse y divisor */
|
---|
[f40a309] | 63 |
|
---|
[7258c6a] | 64 | int16_t tkboth; /* both trackball axes went active */
|
---|
[f40a309] | 65 |
|
---|
[7258c6a] | 66 | int16_t txdiv; /* text cursor X divider */
|
---|
| 67 | int16_t tydiv; /* text cursor Y divider */
|
---|
[f40a309] | 68 |
|
---|
[7258c6a] | 69 | int16_t tkxdvr = TKXDVR; /* text cursor X divisor */
|
---|
| 70 | int16_t tkydvr = TKYDVR; /* text cursor Y divisor */
|
---|
[f40a309] | 71 |
|
---|
[7258c6a] | 72 | int16_t tkhdvr = TKCDVR; /* text cursor horizontal movement threshold */
|
---|
| 73 | int16_t tkvdvr = TKCDVR; /* text cursor vertical movement threshold */
|
---|
[f40a309] | 74 |
|
---|
[7258c6a] | 75 | int16_t msxgdv[13] = { /* mouse x cursor divisor table */
|
---|
[f40a309] | 76 |
|
---|
| 77 | 1, /* -1 -- Main menu */
|
---|
| 78 | 1, /* 0 -- Librarian */
|
---|
| 79 | 1, /* 1 -- Patch editor */
|
---|
| 80 | 1, /* 2 -- Score editor */
|
---|
| 81 | 1, /* 3 -- Sequence editor */
|
---|
| 82 | 1, /* 4 -- Instrument editor */
|
---|
| 83 | 1, /* 5 -- Initialize system */
|
---|
| 84 | 1, /* 6 -- Waveshape editor */
|
---|
| 85 | 1, /* 7 -- Write program to disk */
|
---|
| 86 | 1, /* 8 -- Tuning editor */
|
---|
| 87 | 1, /* 9 -- Format disk */
|
---|
| 88 | 1, /* 10 -- Assignment editor */
|
---|
| 89 | 1 /* 11 -- Diagnostics */
|
---|
| 90 | };
|
---|
| 91 |
|
---|
[7258c6a] | 92 | int16_t msygdv[13] = { /* mouse y cursor divisor table */
|
---|
[f40a309] | 93 |
|
---|
| 94 | 2, /* -1 -- Main menu */
|
---|
| 95 | 2, /* 0 -- Librarian */
|
---|
| 96 | 2, /* 1 -- Patch editor */
|
---|
| 97 | 2, /* 2 -- Score editor */
|
---|
| 98 | 2, /* 3 -- Sequence editor */
|
---|
| 99 | 2, /* 4 -- Instrument editor */
|
---|
| 100 | 2, /* 5 -- Initialize system */
|
---|
| 101 | 2, /* 6 -- Waveshape editor */
|
---|
| 102 | 2, /* 7 -- Write program to disk */
|
---|
| 103 | 2, /* 8 -- Tuning editor */
|
---|
| 104 | 2, /* 9 -- Format disk */
|
---|
| 105 | 2, /* 10 -- Assignment editor */
|
---|
| 106 | 2 /* 11 -- Diagnostics */
|
---|
| 107 | };
|
---|
| 108 |
|
---|
| 109 | #include "swrtab.h" /* long swrtab[128]; */
|
---|
| 110 |
|
---|
| 111 | /*
|
---|
| 112 | =============================================================================
|
---|
| 113 | MouseRT() -- reset the mouse activity timer
|
---|
| 114 | =============================================================================
|
---|
| 115 | */
|
---|
| 116 |
|
---|
[7258c6a] | 117 | void MouseRT(uint16_t t)
|
---|
[f40a309] | 118 | {
|
---|
[7258c6a] | 119 | uint16_t oldi;
|
---|
[f40a309] | 120 |
|
---|
| 121 | oldi = setipl(TIM_DI); /* disable interrupts */
|
---|
| 122 |
|
---|
| 123 | timers[MUTIMER] = t; /* set the mouse timer */
|
---|
| 124 |
|
---|
| 125 | setipl(oldi); /* enable interrupts */
|
---|
| 126 |
|
---|
| 127 | #if DEBUGMS
|
---|
| 128 | if (debugms > 2)
|
---|
| 129 | printf("MouseRT(%d)\n", t);
|
---|
| 130 | #endif
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | /*
|
---|
| 134 | =============================================================================
|
---|
| 135 | MouseRD() -- read a string from the mouse
|
---|
| 136 | =============================================================================
|
---|
| 137 | */
|
---|
| 138 |
|
---|
[7258c6a] | 139 | int16_t MouseRD(int8_t *str, int16_t nc, int16_t nt)
|
---|
[f40a309] | 140 | {
|
---|
[7258c6a] | 141 | int32_t tc;
|
---|
[f40a309] | 142 |
|
---|
[7258c6a] | 143 | tc = nt * (int32_t)C_PER_S;
|
---|
[f40a309] | 144 |
|
---|
| 145 | while (nc > 0) {
|
---|
| 146 |
|
---|
| 147 | if (BIOS(B_RDAV, PRT_DEV)) {
|
---|
| 148 |
|
---|
[7258c6a] | 149 | *str++ = (int8_t)BIOS(B_GETC, PRT_DEV);
|
---|
[f40a309] | 150 | *str = '\0';
|
---|
| 151 | --nc;
|
---|
| 152 |
|
---|
| 153 | } else {
|
---|
| 154 |
|
---|
| 155 | if (tc-- LE 0)
|
---|
| 156 | return(FAILURE);
|
---|
| 157 | }
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | return(SUCCESS);
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | /*
|
---|
| 164 | =============================================================================
|
---|
| 165 | MouseWR() -- write a string to the mouse
|
---|
| 166 | =============================================================================
|
---|
| 167 | */
|
---|
| 168 |
|
---|
[7258c6a] | 169 | void MouseWR(int8_t *str)
|
---|
[f40a309] | 170 | {
|
---|
[7258c6a] | 171 | register uint16_t c;
|
---|
[f40a309] | 172 |
|
---|
| 173 | #if DEBUGMS
|
---|
| 174 | if (debugms > 1)
|
---|
| 175 | printf("OUT \"%s\"\n", str);
|
---|
| 176 | #endif
|
---|
| 177 |
|
---|
| 178 | while (c = 0x00FF & *str++) /* get a byte */
|
---|
| 179 | BIOS(B_PUTC, PRT_DEV, c); /* output it */
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | /*
|
---|
| 183 | =============================================================================
|
---|
| 184 | MouseFL() -- flush the mouse input buffer
|
---|
| 185 | =============================================================================
|
---|
| 186 | */
|
---|
| 187 |
|
---|
[7258c6a] | 188 | int16_t MouseFL(int16_t tc)
|
---|
[f40a309] | 189 | {
|
---|
[7258c6a] | 190 | int32_t flushed;
|
---|
[f40a309] | 191 |
|
---|
| 192 | flushed = 0L; /* reset the flush counter */
|
---|
| 193 |
|
---|
| 194 | M_state = 0; /* reset mouse state */
|
---|
| 195 | msflag = FALSE; /* reset mouse movement flag */
|
---|
| 196 | msctrl = FALSE; /* reset mouse update flag */
|
---|
| 197 |
|
---|
| 198 | while (BIOS(B_RDAV, PRT_DEV)) { /* check for data */
|
---|
| 199 |
|
---|
| 200 | BIOS(B_GETC, PRT_DEV); /* read a byte */
|
---|
| 201 | ++flushed; /* update flush count */
|
---|
| 202 |
|
---|
| 203 | if (--tc LE 0) { /* see if we've timed out */
|
---|
| 204 |
|
---|
| 205 | #if DEBUGMS
|
---|
| 206 | if (debugms)
|
---|
| 207 | printf("FLUSH %d %ld FAILURE\n", M_state, flushed);
|
---|
| 208 | #endif
|
---|
| 209 |
|
---|
| 210 | return(FAILURE); /* FAILED */
|
---|
| 211 | }
|
---|
| 212 | }
|
---|
| 213 |
|
---|
| 214 | #if DEBUGMS
|
---|
| 215 | if (debugms)
|
---|
| 216 | printf("FLUSH %d %ld SUCCESS\n", M_state, flushed);
|
---|
| 217 | #endif
|
---|
| 218 |
|
---|
| 219 | return(SUCCESS); /* SUCCEEDED */
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | /*
|
---|
| 223 | =============================================================================
|
---|
| 224 | MouseWK() -- wake up the mouse
|
---|
| 225 | =============================================================================
|
---|
| 226 | */
|
---|
| 227 |
|
---|
[7258c6a] | 228 | int16_t MouseWK(void)
|
---|
[f40a309] | 229 | {
|
---|
[7258c6a] | 230 | int16_t tries;
|
---|
[f40a309] | 231 |
|
---|
| 232 | M_error = M_NONE; /* reset mouse error flag */
|
---|
| 233 | M_oldbs = 0; /* reset mouse button state */
|
---|
| 234 | M_state = 0; /* reset the mouse state machine */
|
---|
| 235 |
|
---|
| 236 | /* set the UART to 1200 baud, 7 data bits, No parity, 1 stop bit */
|
---|
| 237 |
|
---|
| 238 | XBIOS(X_SETPRT, PRT_DEV, L_NUL, -1, CFR0, CFR1);
|
---|
| 239 |
|
---|
| 240 | if (MouseFL(M_FL_CT)) { /* flush the FIFO */
|
---|
| 241 |
|
---|
| 242 | M_error = M_FLUSH; /* error -- can't flush */
|
---|
| 243 |
|
---|
| 244 | #if DEBUGMS
|
---|
| 245 | if (debugms)
|
---|
| 246 | printf("MouseWK() -- FAILURE\n");
|
---|
| 247 | #endif
|
---|
| 248 |
|
---|
| 249 | return(FAILURE); /* return -- we failed */
|
---|
| 250 | }
|
---|
| 251 |
|
---|
| 252 | for (tries = 0; tries < MAXTRIES; tries++) {
|
---|
| 253 |
|
---|
| 254 | MouseWR("t"); /* ask the mouse its mode */
|
---|
| 255 |
|
---|
| 256 | if (MouseRD(M_strng, 2, M_ST_TM)) {
|
---|
| 257 |
|
---|
| 258 | M_error = M_NORESP;
|
---|
| 259 |
|
---|
| 260 | } else if (strcmp("VO", M_strng)) {
|
---|
| 261 |
|
---|
| 262 | M_error = M_RESPNG;
|
---|
| 263 |
|
---|
| 264 | if (MouseFL(M_FL_CT))
|
---|
| 265 | M_error = M_FLUSH;
|
---|
| 266 |
|
---|
| 267 | } else {
|
---|
| 268 |
|
---|
| 269 | M_error = M_NONE;
|
---|
| 270 | MouseRT(MATIME);
|
---|
| 271 |
|
---|
| 272 | #if DEBUGMS
|
---|
| 273 | if (debugms)
|
---|
| 274 | printf("MouseWK() -- SUCCESS\n");
|
---|
| 275 | #endif
|
---|
| 276 | return(SUCCESS);
|
---|
| 277 | }
|
---|
| 278 | }
|
---|
| 279 |
|
---|
| 280 | #if DEBUGMS
|
---|
| 281 | if (debugms)
|
---|
| 282 | printf("MouseWK() -- FAILURE\n");
|
---|
| 283 | #endif
|
---|
| 284 |
|
---|
| 285 | return(FAILURE);
|
---|
| 286 | }
|
---|
| 287 |
|
---|
| 288 | /*
|
---|
| 289 | =============================================================================
|
---|
| 290 | MouseEX() -- process a mouse report
|
---|
| 291 | =============================================================================
|
---|
| 292 | */
|
---|
| 293 |
|
---|
[7258c6a] | 294 | void MouseEX(int8_t *str)
|
---|
[f40a309] | 295 | {
|
---|
[7258c6a] | 296 | uint16_t oldi, msc, mst;
|
---|
[f40a309] | 297 |
|
---|
| 298 | #if DEBUGMS
|
---|
| 299 | if (debugms > 2)
|
---|
| 300 | printf("REPORT %02.2X %02.2X %02.2X\n",
|
---|
| 301 | str[0] & 0x00FF, str[1] & 0x00FF, str[2] & 0x00FF);
|
---|
| 302 | #endif
|
---|
| 303 |
|
---|
| 304 | M_error = M_NONE; /* reset error code */
|
---|
| 305 |
|
---|
| 306 | if ((str[0] & 0x0040) NE 0x0040) {
|
---|
| 307 |
|
---|
| 308 | if (MouseFL(M_FL_CT))
|
---|
| 309 | M_error = M_FLUSH;
|
---|
| 310 | else
|
---|
| 311 | M_error = M_SYNC;
|
---|
| 312 |
|
---|
| 313 | M_state = 0;
|
---|
| 314 | MouseRT(MATIME);
|
---|
| 315 |
|
---|
| 316 | #if DEBUGMS
|
---|
| 317 | if (debugms)
|
---|
| 318 | printf("SYNC\n");
|
---|
| 319 | #endif
|
---|
| 320 |
|
---|
| 321 | return;
|
---|
| 322 | }
|
---|
| 323 |
|
---|
| 324 | mst = str[0] & 0x0030; /* extract mouse buttons */
|
---|
| 325 | msc = M_oldbs ^ mst; /* see what changed */
|
---|
| 326 | M_oldbs = mst; /* update button state */
|
---|
| 327 |
|
---|
| 328 | if (msc) { /* check for button status change */
|
---|
| 329 |
|
---|
| 330 | if (msc & 0x0010) { /* m key ? (right mouse button) */
|
---|
| 331 |
|
---|
| 332 | astat = (mst & 0x0010) >> 4;
|
---|
| 333 | (*m_key)();
|
---|
| 334 | }
|
---|
| 335 |
|
---|
| 336 | if (msc & 0x0020) { /* e key ? (left mouse button) */
|
---|
| 337 |
|
---|
| 338 | astat = (mst & 0x0020) >> 5;
|
---|
| 339 | (*e_key)();
|
---|
| 340 | }
|
---|
| 341 | }
|
---|
| 342 |
|
---|
| 343 | if ((ss_ptsw NE 0) OR (ss_sqsw NE 0)) {
|
---|
| 344 |
|
---|
| 345 | cxrate = 0;
|
---|
| 346 | cyrate = 0;
|
---|
| 347 | return;
|
---|
| 348 | }
|
---|
| 349 |
|
---|
| 350 | msxmov = str[1] | ((str[0] & 0x0003) << 6);
|
---|
| 351 |
|
---|
| 352 | if (msxmov & 0x0080)
|
---|
| 353 | msxmov |= 0xFF80;
|
---|
| 354 |
|
---|
| 355 | msxmov += msxres;
|
---|
| 356 |
|
---|
| 357 | msymov = str[2] + ((str[0] & 0x000C) << 4);
|
---|
| 358 |
|
---|
| 359 | if (msymov & 0x0080)
|
---|
| 360 | msymov |= 0xFF80;
|
---|
| 361 |
|
---|
| 362 | msymov += msyres;
|
---|
| 363 |
|
---|
| 364 | msxdiv = msxgdv[ndisp + 1];
|
---|
| 365 | msydiv = msygdv[ndisp + 1];
|
---|
| 366 |
|
---|
| 367 | /* calculate rates */
|
---|
| 368 |
|
---|
| 369 | if (msxdiv > 1)
|
---|
| 370 | cxrate = msxmov / msxdiv;
|
---|
| 371 | else
|
---|
| 372 | cxrate = msxmov;
|
---|
| 373 |
|
---|
| 374 | if (msydiv > 1)
|
---|
| 375 | cyrate = msymov / msydiv;
|
---|
| 376 | else
|
---|
| 377 | cyrate = msymov;
|
---|
| 378 |
|
---|
| 379 | /* calculate residues */
|
---|
| 380 |
|
---|
| 381 | if (msxdiv > 1)
|
---|
| 382 | msxres = msxmov % msxdiv;
|
---|
| 383 | else
|
---|
| 384 | msxres = 0;
|
---|
| 385 |
|
---|
| 386 | if (msydiv > 1)
|
---|
| 387 | msyres = msymov % msydiv;
|
---|
| 388 | else
|
---|
| 389 | msyres = 0;
|
---|
| 390 |
|
---|
| 391 | if ((cxrate EQ 0) AND (cyrate EQ 0)) /* we're done if nothing changed */
|
---|
| 392 | return;
|
---|
| 393 |
|
---|
| 394 | msctrl = TRUE; /* setup movement switches */
|
---|
| 395 | cmfirst = FALSE;
|
---|
| 396 | trkball = FALSE;
|
---|
| 397 |
|
---|
| 398 | cvtime = 0; /* clear delays */
|
---|
| 399 | ncvwait = 0;
|
---|
| 400 | chtime = 0;
|
---|
| 401 | nchwait = 0;
|
---|
| 402 | curhold = 0;
|
---|
| 403 |
|
---|
| 404 | if (NOT msflag) /* if mouse just started moving ... */
|
---|
| 405 | (*xy_dn)(); /* ... process key down */
|
---|
| 406 |
|
---|
| 407 | oldi = setipl(TIM_DI); /* set the mouse movement timer */
|
---|
| 408 | timers[MSTIMER] = MSTOVAL;
|
---|
| 409 | setipl(oldi);
|
---|
| 410 |
|
---|
| 411 | msflag = TRUE; /* indicate the mouse has started moving */
|
---|
| 412 | }
|
---|
| 413 |
|
---|
| 414 | /*
|
---|
| 415 | =============================================================================
|
---|
| 416 | MouseIN() -- process a byte from the mouse
|
---|
| 417 | =============================================================================
|
---|
| 418 | */
|
---|
| 419 |
|
---|
[7258c6a] | 420 | void MouseIN(int16_t c)
|
---|
[f40a309] | 421 | {
|
---|
| 422 | c &= 0x00FF; /* mask off extraneous bits from mouse input */
|
---|
| 423 |
|
---|
| 424 | #if DEBUGMS
|
---|
| 425 | if (debugms > 2)
|
---|
| 426 | printf("IN %d %02.2X\n", M_state, c);
|
---|
| 427 | #endif
|
---|
| 428 |
|
---|
| 429 | if ((M_state GE 0) AND (M_state < 3)) {
|
---|
| 430 |
|
---|
| 431 | M_strng[M_state] = c;
|
---|
| 432 |
|
---|
| 433 | if (M_state EQ 2) {
|
---|
| 434 |
|
---|
| 435 | MouseEX(M_strng);
|
---|
| 436 | M_state = 0;
|
---|
| 437 |
|
---|
| 438 | } else {
|
---|
| 439 |
|
---|
| 440 | ++M_state;
|
---|
| 441 | }
|
---|
| 442 | }
|
---|
| 443 | }
|
---|
| 444 |
|
---|
| 445 | #if DEBUGTF
|
---|
| 446 | /*
|
---|
| 447 | =============================================================================
|
---|
| 448 | tfdump() -- dump a trackball FIFO
|
---|
| 449 | =============================================================================
|
---|
| 450 | */
|
---|
| 451 |
|
---|
| 452 | tfdump(msg, fifo, ndx, fin, cnt)
|
---|
| 453 | char *msg;
|
---|
| 454 | register short *fifo, ndx, fin;
|
---|
| 455 | long cnt;
|
---|
| 456 | {
|
---|
| 457 | register short nol = 0, i = fin, j = fin - 1;
|
---|
| 458 |
|
---|
| 459 | printf("Dump of %s FIFO\n", msg);
|
---|
| 460 | printf(" ndx=%d fin=%d cnt=%ld\n", ndx, fin, cnt);
|
---|
| 461 |
|
---|
| 462 | if (j < 0)
|
---|
| 463 | j = NTKFIFO - 1;
|
---|
| 464 |
|
---|
| 465 | do {
|
---|
| 466 |
|
---|
| 467 | if (nol EQ 0)
|
---|
| 468 | printf(" ");
|
---|
| 469 |
|
---|
| 470 | if (i EQ ndx)
|
---|
| 471 | printf("<%2d ", fifo[i]);
|
---|
| 472 | else if (i EQ j)
|
---|
| 473 | printf(" %2d> ", fifo[i]);
|
---|
| 474 | else
|
---|
| 475 | printf(" %2d ", fifo[i]);
|
---|
| 476 |
|
---|
| 477 | if (++nol GE 15) {
|
---|
| 478 |
|
---|
| 479 | printf("\n");
|
---|
| 480 | nol = 0;
|
---|
| 481 | }
|
---|
| 482 |
|
---|
| 483 | if (++i GE NTKFIFO)
|
---|
[9519422] | 484 | i = 0;
|
---|
[f40a309] | 485 |
|
---|
| 486 | } while (i NE fin);
|
---|
| 487 |
|
---|
| 488 | if (nol)
|
---|
| 489 | printf("\n");
|
---|
| 490 |
|
---|
| 491 | printf("\n");
|
---|
| 492 | }
|
---|
| 493 | #endif
|
---|
| 494 |
|
---|
| 495 | /*
|
---|
| 496 | =============================================================================
|
---|
| 497 | wheel() -- process inputs from the scroll wheel
|
---|
| 498 | =============================================================================
|
---|
| 499 | */
|
---|
| 500 |
|
---|
[0580615] | 501 | void wheel(void)
|
---|
[f40a309] | 502 | {
|
---|
[7258c6a] | 503 | register int16_t i, oldi;
|
---|
[f40a309] | 504 |
|
---|
| 505 | if (astat) { /* if it's touched ... */
|
---|
| 506 |
|
---|
| 507 | if (NOT swflag) {
|
---|
| 508 |
|
---|
| 509 | /* GOING DOWN */
|
---|
| 510 |
|
---|
| 511 | swflag = TRUE;
|
---|
| 512 | swctrl = FALSE;
|
---|
| 513 | swfiin = 0;
|
---|
| 514 | swlast = aval;
|
---|
| 515 | swstop = swwait;
|
---|
| 516 | swcount = 0;
|
---|
| 517 |
|
---|
| 518 | for (i = 0; i < NSWFIFO; i++)
|
---|
| 519 | swfifo[i] = aval;
|
---|
[fa38804] | 520 |
|
---|
[f40a309] | 521 | } else { /* finger moved */
|
---|
| 522 |
|
---|
| 523 | if (0 EQ swstop) {
|
---|
| 524 |
|
---|
| 525 | swdelta = swlast - aval;
|
---|
| 526 |
|
---|
| 527 | if (swdelta GE swthr) {
|
---|
| 528 |
|
---|
| 529 | if ((clkctl EQ CK_STEP) OR
|
---|
| 530 | ((clkctl NE CK_STEP) AND
|
---|
| 531 | (NOT clkrun))) {
|
---|
| 532 |
|
---|
| 533 | /* FINGER MOVED LEFT */
|
---|
| 534 |
|
---|
| 535 | swtemp = swdelta / swthr;
|
---|
| 536 | oldi = setipl(TIM_DI);
|
---|
| 537 | fc_val += swtemp;
|
---|
| 538 |
|
---|
| 539 | if (fc_val GE 0x00FFFFFFL)
|
---|
| 540 | fc_val = 0x00FFFFFFL;
|
---|
| 541 |
|
---|
| 542 | setipl(oldi);
|
---|
| 543 | swlast = aval;
|
---|
| 544 | }
|
---|
| 545 |
|
---|
| 546 | } else if ((swdelta = abs(swdelta)) GE swthr) {
|
---|
| 547 |
|
---|
| 548 | if ((clkctl EQ CK_STEP) OR
|
---|
| 549 | ((clkctl NE CK_STEP) AND
|
---|
| 550 | (NOT clkrun))) {
|
---|
| 551 |
|
---|
| 552 | /* FINGER MOVED RIGHT */
|
---|
| 553 |
|
---|
| 554 | swtemp = swdelta / swthr;
|
---|
| 555 | oldi = setipl(TIM_DI);
|
---|
| 556 | fc_val -= swtemp;
|
---|
| 557 |
|
---|
| 558 | if (fc_val LT 0L)
|
---|
| 559 | fc_val = 0L;
|
---|
| 560 |
|
---|
| 561 | setipl(oldi);
|
---|
| 562 | swlast = aval;
|
---|
| 563 | }
|
---|
| 564 | }
|
---|
| 565 |
|
---|
| 566 | } else {
|
---|
| 567 |
|
---|
| 568 | swlast = aval;
|
---|
| 569 | --swstop;
|
---|
| 570 | }
|
---|
| 571 | }
|
---|
[fa38804] | 572 |
|
---|
[f40a309] | 573 | } else { /* FINGER UP */
|
---|
| 574 |
|
---|
| 575 | swlast = aval;
|
---|
| 576 | swflag = FALSE;
|
---|
| 577 | swctrl = FALSE;
|
---|
| 578 |
|
---|
| 579 | if ((clkctl EQ CK_STEP) OR
|
---|
| 580 | ((clkctl NE CK_STEP) AND
|
---|
| 581 | (NOT clkrun))) {
|
---|
| 582 |
|
---|
| 583 | swndx = swfiin - swback;
|
---|
| 584 |
|
---|
| 585 | if (swndx < 0)
|
---|
| 586 | swndx += NSWFIFO;
|
---|
| 587 |
|
---|
| 588 | swrate = swfifo[swndx] - swlast;
|
---|
| 589 |
|
---|
| 590 | if (swrate > swrmin) {
|
---|
| 591 |
|
---|
| 592 | swdir = D_FWD; /* SCROLL FORWARD */
|
---|
| 593 | swrate = swrtab[swrate - swrmin];
|
---|
| 594 | swctrl = TRUE;
|
---|
| 595 |
|
---|
| 596 | } else if ((swrate = abs(swrate)) > swrmin) {
|
---|
| 597 |
|
---|
| 598 | swdir = D_BAK; /* SCROLL BACKWARD */
|
---|
| 599 | swrate = swrtab[swrate - swrmin];
|
---|
| 600 | swctrl = TRUE;
|
---|
| 601 |
|
---|
| 602 | } else {
|
---|
| 603 |
|
---|
| 604 | swrate = 0L; /* STOP SCROLLING */
|
---|
| 605 | }
|
---|
| 606 | }
|
---|
| 607 | }
|
---|
| 608 | }
|
---|
| 609 |
|
---|
| 610 | /*
|
---|
| 611 | =============================================================================
|
---|
| 612 | txyup() -- process trackball -- both axes inactive
|
---|
| 613 | =============================================================================
|
---|
| 614 | */
|
---|
| 615 |
|
---|
[0580615] | 616 | void txyup(void)
|
---|
[f40a309] | 617 | {
|
---|
[7258c6a] | 618 | register int16_t txndx, tyndx, txrate, tyrate;
|
---|
[f40a309] | 619 |
|
---|
| 620 | #if DEBUGTF
|
---|
| 621 | if (debugtf)
|
---|
| 622 | printf("txyup(): both inactive\n");
|
---|
| 623 | #endif
|
---|
| 624 |
|
---|
| 625 | tkboth = FALSE; /* both axes inactive now */
|
---|
| 626 |
|
---|
| 627 | txdiv = 0; /* reset text cursor dividers */
|
---|
| 628 | tydiv = 0;
|
---|
| 629 |
|
---|
| 630 | if ((txndx = txfiin - tkback) < 0) /* get fifo index */
|
---|
| 631 | txndx += NTKFIFO; /* adjust index */
|
---|
| 632 |
|
---|
| 633 | txrate = txfifo[txndx] - txlast; /* get movement */
|
---|
| 634 |
|
---|
| 635 | #if DEBUGTF
|
---|
| 636 | if (debugtf)
|
---|
| 637 | tfdump("X", txfifo, txndx, txfiin, txficnt);
|
---|
| 638 | #endif
|
---|
| 639 |
|
---|
| 640 | if (txrate GE tkrmin)
|
---|
| 641 | cxrate = -cratex[txrate - tkrmin]; /* tracking left */
|
---|
| 642 | else if ((txrate = abs(txrate)) GE tkrmin)
|
---|
| 643 | cxrate = cratex[txrate - tkrmin]; /* tracking right */
|
---|
| 644 | else
|
---|
| 645 | cxrate = 0; /* X inactive */
|
---|
| 646 |
|
---|
[fa38804] | 647 |
|
---|
[f40a309] | 648 | if ((tyndx = tyfiin - tkback) < 0) /* get fifo index */
|
---|
| 649 | tyndx += NTKFIFO; /* adjust index */
|
---|
| 650 |
|
---|
| 651 | tyrate = tyfifo[tyndx] - tylast; /* get movement */
|
---|
| 652 |
|
---|
| 653 | #if DEBUGTF
|
---|
| 654 | if (debugtf)
|
---|
| 655 | tfdump("Y", tyfifo, tyndx, tyfiin, tyficnt);
|
---|
| 656 | #endif
|
---|
| 657 |
|
---|
| 658 | if (tyrate GE tkrmin)
|
---|
| 659 | cyrate = cratey[tyrate - tkrmin]; /* tracking down */
|
---|
| 660 | else if ((tyrate = abs(tyrate)) GE tkrmin)
|
---|
| 661 | cyrate = -cratey[tyrate - tkrmin]; /* tracking up */
|
---|
| 662 | else
|
---|
| 663 | cyrate = 0; /* Y inactive */
|
---|
| 664 |
|
---|
| 665 | if ((cxrate EQ 0) AND (cyrate EQ 0)) {
|
---|
| 666 |
|
---|
| 667 | tkctrl = FALSE; /* STOP -- both rates are zero */
|
---|
| 668 | (*xy_up)();
|
---|
| 669 |
|
---|
| 670 | } else {
|
---|
| 671 |
|
---|
| 672 | tkctrl = TRUE; /* ROLL -- some rate is non-zero */
|
---|
| 673 | }
|
---|
| 674 |
|
---|
| 675 | #if DEBUGTK
|
---|
| 676 | if (debugtk)
|
---|
| 677 | printf("txyup(): %s rmin=%d txr=%d cxr=%d tyr=%d cyr=%d\n",
|
---|
| 678 | tkctrl ? "ROLL" : "STOP", tkrmin, txrate, cxrate, tyrate, cyrate);
|
---|
| 679 | #endif
|
---|
| 680 |
|
---|
| 681 | }
|
---|
| 682 |
|
---|
| 683 | /*
|
---|
| 684 | =============================================================================
|
---|
| 685 | txydn() -- process trackball -- both axes active
|
---|
| 686 | =============================================================================
|
---|
| 687 | */
|
---|
| 688 |
|
---|
[0580615] | 689 | void txydn(void)
|
---|
[f40a309] | 690 | {
|
---|
[7258c6a] | 691 | register int16_t i;
|
---|
[f40a309] | 692 |
|
---|
| 693 | #if DEBUGTK
|
---|
| 694 | if (debugtk)
|
---|
| 695 | printf("txydn(): both active txlast=%d tylast=%d\n",
|
---|
| 696 | txlast, tylast);
|
---|
| 697 | #endif
|
---|
| 698 |
|
---|
| 699 | tkboth = TRUE; /* both down now */
|
---|
| 700 | (*xy_dn)();
|
---|
| 701 |
|
---|
| 702 | tkctrl = FALSE; /* stop rolling */
|
---|
| 703 | cxrate = 0;
|
---|
| 704 | cyrate = 0;
|
---|
| 705 |
|
---|
| 706 | txfiin = 0; /* preset the FIFOs */
|
---|
| 707 | tyfiin = 0;
|
---|
| 708 |
|
---|
| 709 | for (i = 0; i < NTKFIFO; i++) {
|
---|
| 710 |
|
---|
| 711 | txfifo[i] = txlast;
|
---|
| 712 | tyfifo[i] = tylast;
|
---|
| 713 | }
|
---|
| 714 |
|
---|
| 715 | #if DEBUGTF
|
---|
| 716 | txficnt = 0;
|
---|
| 717 | tyficnt = 0;
|
---|
| 718 | #endif
|
---|
| 719 | }
|
---|
| 720 |
|
---|
| 721 | /*
|
---|
| 722 | =============================================================================
|
---|
| 723 | txstd() -- process inputs from the trackball X axis
|
---|
| 724 | =============================================================================
|
---|
| 725 | */
|
---|
| 726 |
|
---|
[0580615] | 727 | void txstd(void)
|
---|
[f40a309] | 728 | {
|
---|
[7ecfb7b] | 729 | register int16_t oldcx, txdelta, txcdvr;
|
---|
[f40a309] | 730 |
|
---|
| 731 | trkball = TRUE; /* set trackball mode */
|
---|
| 732 | cmfirst = FALSE;
|
---|
| 733 | chtime = tktime;
|
---|
| 734 | nchwait = tktime;
|
---|
| 735 | chwait = tktime;
|
---|
| 736 |
|
---|
| 737 |
|
---|
| 738 | /* get rate divisor */
|
---|
| 739 |
|
---|
| 740 | txcdvr = (cmtype EQ CT_GRAF) ? tkthr : tkhdvr;
|
---|
| 741 |
|
---|
| 742 | if (astat) { /* is axis active ? */
|
---|
| 743 |
|
---|
| 744 | if (NOT txflag) {
|
---|
| 745 |
|
---|
| 746 | /* GOING ACTIVE */
|
---|
| 747 |
|
---|
| 748 | txflag = TRUE;
|
---|
| 749 | txstop = tkwait;
|
---|
| 750 | txlast = aval;
|
---|
| 751 |
|
---|
| 752 | if (tyflag AND (NOT tkboth))
|
---|
| 753 | txydn(); /* both active now */
|
---|
| 754 |
|
---|
[fa38804] | 755 |
|
---|
[f40a309] | 756 | } else { /* finger moved ? */
|
---|
| 757 |
|
---|
| 758 | if (txstop LE 0) { /* debounced ? */
|
---|
| 759 |
|
---|
| 760 | txdelta = txlast - aval;
|
---|
| 761 | oldcx = cxval;
|
---|
| 762 |
|
---|
| 763 | if (txdelta GE txcdvr) {
|
---|
| 764 |
|
---|
| 765 | /* FINGER MOVED LEFT */
|
---|
| 766 |
|
---|
| 767 | cxrate = -(txdelta / txcdvr);
|
---|
| 768 |
|
---|
| 769 | (*cx_upd)(); /* update cxval */
|
---|
| 770 |
|
---|
| 771 | if (oldcx NE cxval) /* new cxval ? */
|
---|
| 772 | (*curmove)(); /* move cursor */
|
---|
| 773 |
|
---|
| 774 | txlast = aval;
|
---|
| 775 | cxrate = 0;
|
---|
| 776 |
|
---|
| 777 | } else if ((txdelta = abs(txdelta)) GE txcdvr) {
|
---|
| 778 |
|
---|
| 779 | /* FINGER MOVED RIGHT */
|
---|
| 780 |
|
---|
| 781 | cxrate = txdelta / txcdvr;
|
---|
| 782 |
|
---|
| 783 | (*cx_upd)(); /* update cxval */
|
---|
| 784 |
|
---|
| 785 | if (oldcx NE cxval) /* new cxval ? */
|
---|
| 786 | (*curmove)(); /* move cursor */
|
---|
| 787 |
|
---|
| 788 | txlast = aval;
|
---|
| 789 | cxrate = 0;
|
---|
| 790 | }
|
---|
| 791 |
|
---|
| 792 | } else { /* debounce data */
|
---|
| 793 |
|
---|
| 794 | txlast = aval;
|
---|
| 795 | --txstop;
|
---|
| 796 | }
|
---|
| 797 | }
|
---|
[fa38804] | 798 |
|
---|
[f40a309] | 799 | } else { /* AXIS GOING INACTIVE */
|
---|
| 800 |
|
---|
| 801 | txlast = aval; /* get current value */
|
---|
| 802 | txflag = FALSE; /* X axis inactive */
|
---|
| 803 |
|
---|
| 804 | if (NOT tyflag) /* check other axis */
|
---|
| 805 | txyup(); /* both inactive now */
|
---|
| 806 | }
|
---|
| 807 | }
|
---|
| 808 |
|
---|
| 809 | /*
|
---|
| 810 | =============================================================================
|
---|
| 811 | tystd() -- process inputs from the trackball Y axis
|
---|
| 812 | =============================================================================
|
---|
| 813 | */
|
---|
| 814 |
|
---|
[0580615] | 815 | void tystd(void)
|
---|
[f40a309] | 816 | {
|
---|
[7ecfb7b] | 817 | register int16_t oldcy, tydelta, tycdvr;
|
---|
[f40a309] | 818 |
|
---|
| 819 | trkball = TRUE; /* set trackball mode */
|
---|
| 820 | cmfirst = FALSE;
|
---|
| 821 | cvtime = tktime;
|
---|
| 822 | ncvwait = tktime;
|
---|
| 823 | cvwait = tktime;
|
---|
| 824 |
|
---|
| 825 | /* get rate divisor */
|
---|
| 826 |
|
---|
| 827 | tycdvr = (cmtype EQ CT_GRAF) ? tkthr : tkvdvr;
|
---|
| 828 |
|
---|
| 829 | if (astat) { /* if axis active ? */
|
---|
| 830 |
|
---|
| 831 | if (NOT tyflag) {
|
---|
| 832 |
|
---|
| 833 | /* GOING ACTIVE */
|
---|
| 834 |
|
---|
| 835 | tyflag = TRUE;
|
---|
| 836 | tystop = tkwait;
|
---|
| 837 | tylast = aval;
|
---|
| 838 |
|
---|
| 839 | if (txflag AND (NOT tkboth))
|
---|
| 840 | txydn(); /* both active now */
|
---|
[fa38804] | 841 |
|
---|
[f40a309] | 842 | } else { /* finger moved ? */
|
---|
| 843 |
|
---|
| 844 | if (tystop LE 0) { /* debounced ? */
|
---|
| 845 |
|
---|
| 846 | tydelta = tylast - aval;
|
---|
| 847 | oldcy = cyval;
|
---|
| 848 |
|
---|
| 849 | if (tydelta GE tycdvr) {
|
---|
| 850 |
|
---|
| 851 | /* FINGER MOVED DOWN */
|
---|
| 852 |
|
---|
| 853 | cyrate = tydelta / tycdvr;
|
---|
| 854 |
|
---|
| 855 | (*cy_upd)(); /* update cyval */
|
---|
| 856 |
|
---|
| 857 | if (oldcy NE cyval) /* new cyval ? */
|
---|
| 858 | (*curmove)(); /* move cursor */
|
---|
| 859 |
|
---|
| 860 | tylast = aval;
|
---|
| 861 | cyrate = 0;
|
---|
| 862 |
|
---|
| 863 | } else if ((tydelta = abs(tydelta)) GE tycdvr) {
|
---|
| 864 |
|
---|
| 865 | /* FINGER MOVED UP */
|
---|
| 866 |
|
---|
| 867 | cyrate = -(tydelta / tycdvr);
|
---|
| 868 |
|
---|
| 869 | (*cy_upd)(); /* udpate cyval */
|
---|
| 870 |
|
---|
| 871 | if (oldcy NE cyval) /* new cyval ? */
|
---|
| 872 | (*curmove)(); /* move cursor */
|
---|
| 873 |
|
---|
| 874 | tylast = aval;
|
---|
| 875 | cyrate = 0;
|
---|
| 876 | }
|
---|
| 877 |
|
---|
| 878 | } else { /* debounce data */
|
---|
| 879 |
|
---|
| 880 | tylast = aval;
|
---|
| 881 | --tystop;
|
---|
| 882 | }
|
---|
| 883 | }
|
---|
[fa38804] | 884 |
|
---|
[f40a309] | 885 | } else { /* AXIS GOING INACTIVE */
|
---|
| 886 |
|
---|
| 887 | tylast = aval; /* get current value */
|
---|
| 888 | tyflag = FALSE; /* Y axis inactive */
|
---|
| 889 |
|
---|
| 890 | if (NOT txflag) /* check other axis */
|
---|
| 891 | txyup(); /* both inactive now */
|
---|
| 892 | }
|
---|
| 893 | }
|
---|
| 894 |
|
---|
| 895 | /*
|
---|
| 896 | =============================================================================
|
---|
| 897 | curproc() -- process cursor trackball and scroll wheel updates
|
---|
| 898 | =============================================================================
|
---|
| 899 | */
|
---|
| 900 |
|
---|
[0580615] | 901 | void curproc(void)
|
---|
[f40a309] | 902 | {
|
---|
[7ecfb7b] | 903 | register int16_t cxprev, cyprev;
|
---|
[7258c6a] | 904 | int16_t oldcx, oldcy;
|
---|
| 905 | register uint16_t oldi;
|
---|
[f40a309] | 906 |
|
---|
| 907 | /* SET CURRENT WAIT COUNTS FROM TIMERS */
|
---|
| 908 |
|
---|
| 909 | chwait = timers[TXTIMER];
|
---|
| 910 | cvwait = timers[TYTIMER];
|
---|
| 911 |
|
---|
| 912 | if (trkball) { /* are we tracking ? */
|
---|
| 913 |
|
---|
| 914 | if (txflag AND (chwait LE 0)) {
|
---|
| 915 |
|
---|
| 916 | /* SAMPLE THE TRACKBALL X AXIS */
|
---|
| 917 |
|
---|
| 918 | txfifo[txfiin] = sigtab[55][0];
|
---|
| 919 |
|
---|
| 920 | #if DEBUGTF
|
---|
| 921 | ++txficnt;
|
---|
| 922 | #endif
|
---|
| 923 |
|
---|
| 924 | if (++txfiin GE NTKFIFO)
|
---|
| 925 | txfiin = 0;
|
---|
| 926 | }
|
---|
| 927 |
|
---|
| 928 | if (tyflag AND (cvwait LE 0)) {
|
---|
| 929 |
|
---|
| 930 | /* SAMPLE THE TRACKBALL Y AXIS */
|
---|
| 931 |
|
---|
| 932 | tyfifo[tyfiin] = sigtab[56][0];
|
---|
| 933 |
|
---|
| 934 | #if DEBUGTF
|
---|
| 935 | ++tyficnt;
|
---|
| 936 | #endif
|
---|
| 937 |
|
---|
| 938 | if (++tyfiin GE NTKFIFO)
|
---|
| 939 | tyfiin = 0;
|
---|
| 940 | }
|
---|
| 941 | }
|
---|
[fa38804] | 942 |
|
---|
[f40a309] | 943 | /* PROCESS MOUSE INPUTS */
|
---|
| 944 |
|
---|
| 945 | if (BIOS(B_RDAV, PRT_DEV)) {
|
---|
| 946 |
|
---|
[7258c6a] | 947 | MouseIN((int16_t)BIOS(B_GETC, PRT_DEV));
|
---|
[f40a309] | 948 |
|
---|
| 949 | MouseRT(MATIME); /* reset mouse activity timer */
|
---|
| 950 | }
|
---|
| 951 |
|
---|
| 952 | /* PROCESS THE CURSORS */
|
---|
| 953 |
|
---|
| 954 | if (cvwait LE 0) { /* has the vertical timer run out ? */
|
---|
| 955 |
|
---|
| 956 | if (ss_ptsw) /* see if the patches need scrolled */
|
---|
| 957 | smy_up(ss_ptsw); /* scroll the patch display */
|
---|
| 958 |
|
---|
| 959 | if (ss_sqsw) /* see if the sequences need scrolled */
|
---|
| 960 | sqy_up(ss_sqsw); /* scroll the sequence display */
|
---|
| 961 | }
|
---|
| 962 |
|
---|
| 963 | if (msctrl OR /* is the mouse moving ? */
|
---|
| 964 | (cvwait LE 0) OR (chwait LE 0)) { /* has X or Y timer runout ? */
|
---|
| 965 |
|
---|
| 966 | if (msctrl OR tkctrl OR (xkstat AND ykstat)) { /* cursor moving ? */
|
---|
| 967 |
|
---|
| 968 | oldcx = cxrate; /* save old cxrate, cyrate */
|
---|
| 969 | oldcy = cyrate;
|
---|
| 970 | cxprev = cxval; /* save old cxval, cyval */
|
---|
| 971 | cyprev = cyval;
|
---|
| 972 | vtprow = vtcrow; /* save old vtrow, vtcol */
|
---|
| 973 | vtpcol = vtccol;
|
---|
| 974 |
|
---|
| 975 | if (NOT msctrl) /* if it's not the mouse ... */
|
---|
| 976 | cmfix(); /* ... adjust the rates */
|
---|
| 977 |
|
---|
[fa38804] | 978 |
|
---|
[f40a309] | 979 | if ((cxrate NE 0) AND (msctrl OR (chwait LE 0))) /* UPDATE X VALUES */
|
---|
| 980 | (*cx_upd)();
|
---|
| 981 |
|
---|
| 982 | if ((cyrate NE 0) AND (msctrl OR (cvwait LE 0))) /* UPDATE Y VALUES */
|
---|
| 983 | (*cy_upd)();
|
---|
| 984 |
|
---|
| 985 | cxrate = oldcx;
|
---|
| 986 | cyrate = oldcy;
|
---|
| 987 |
|
---|
| 988 | /* see if cursor should be moved */
|
---|
| 989 |
|
---|
| 990 | if ( (cxprev NE cxval) OR (cyprev NE cyval) OR
|
---|
| 991 | (vtprow NE vtcrow) OR (vtpcol NE vtccol) ) {
|
---|
| 992 |
|
---|
| 993 | (*curmove)(); /* MOVE CURSOR */
|
---|
| 994 |
|
---|
| 995 | if (ebflag) { /* FIXUP EDIT BUFFER */
|
---|
| 996 |
|
---|
| 997 | if ((struct fet *)NULL NE curfet) {
|
---|
| 998 |
|
---|
| 999 | if (infield(stcrow, stccol, curfet)) {
|
---|
| 1000 |
|
---|
| 1001 | if ((cfetp NE NULL) AND
|
---|
| 1002 | (cfetp NE infetp)) {
|
---|
| 1003 |
|
---|
| 1004 | (*cfetp->redisp)(cfetp->ftags);
|
---|
| 1005 | ebflag = FALSE;
|
---|
| 1006 | }
|
---|
| 1007 |
|
---|
| 1008 | } else { /* isn't in a field */
|
---|
| 1009 |
|
---|
| 1010 | if (cfetp NE NULL)
|
---|
| 1011 | (*cfetp->redisp)(cfetp->ftags);
|
---|
| 1012 |
|
---|
| 1013 | ebflag = FALSE;
|
---|
| 1014 | }
|
---|
| 1015 |
|
---|
| 1016 | } else { /* no fet, no field */
|
---|
| 1017 |
|
---|
| 1018 | ebflag = FALSE;
|
---|
| 1019 | }
|
---|
| 1020 | }
|
---|
| 1021 | }
|
---|
| 1022 | }
|
---|
| 1023 | }
|
---|
[fa38804] | 1024 |
|
---|
[f40a309] | 1025 | /* CHECK THE MOUSE MOTION TIMER */
|
---|
| 1026 |
|
---|
| 1027 | if (msflag AND (0 EQ timers[MSTIMER])) {
|
---|
| 1028 |
|
---|
| 1029 | (*xy_up)(); /* indicate key up */
|
---|
| 1030 |
|
---|
| 1031 | msflag = FALSE; /* indicate mouse stopped */
|
---|
| 1032 | }
|
---|
| 1033 |
|
---|
| 1034 | msctrl = FALSE; /* indicate mouse movement processed */
|
---|
| 1035 |
|
---|
| 1036 |
|
---|
| 1037 | /* CHECK THE MOUSE ACTIVITY TIMER */
|
---|
| 1038 |
|
---|
| 1039 | if (0 EQ timers[MUTIMER]) {
|
---|
| 1040 |
|
---|
| 1041 | if (M_state)
|
---|
| 1042 | if (MouseFL(M_FL_CT))
|
---|
| 1043 | M_error = M_FLUSH;
|
---|
| 1044 |
|
---|
| 1045 | M_state = 0;
|
---|
| 1046 | MouseRT(MATIME);
|
---|
| 1047 |
|
---|
| 1048 | #if DEBUGMS
|
---|
| 1049 | if (debugms > 1)
|
---|
| 1050 | printf("MRESET\n");
|
---|
| 1051 | #endif
|
---|
| 1052 | }
|
---|
| 1053 |
|
---|
[fa38804] | 1054 |
|
---|
[f40a309] | 1055 | /* UPDATE THE CURSOR TIMERS */
|
---|
| 1056 |
|
---|
| 1057 | if (cvwait LE 0) { /* reset vertical timer */
|
---|
| 1058 |
|
---|
| 1059 | cvwait = ncvwait;
|
---|
| 1060 | ncvwait = cvtime;
|
---|
| 1061 |
|
---|
| 1062 | oldi = setipl(TIM_DI);
|
---|
| 1063 | timers[TYTIMER] = cvwait;
|
---|
| 1064 | setipl(oldi);
|
---|
| 1065 | }
|
---|
| 1066 |
|
---|
| 1067 |
|
---|
| 1068 | if (chwait LE 0) { /* reset horizontal timer */
|
---|
| 1069 |
|
---|
| 1070 | chwait = nchwait;
|
---|
| 1071 | nchwait = chtime;
|
---|
| 1072 |
|
---|
| 1073 | oldi = setipl(TIM_DI);
|
---|
| 1074 | timers[TXTIMER] = chwait;
|
---|
| 1075 | setipl(oldi);
|
---|
| 1076 | }
|
---|
[fa38804] | 1077 |
|
---|
[f40a309] | 1078 | /* PROCESS THE SCROLL WHEEL */
|
---|
| 1079 |
|
---|
| 1080 | if (0 EQ timers[SWTIMER]) { /* is it time ? */
|
---|
| 1081 |
|
---|
| 1082 | if (swflag) { /* SAMPLE THE SCROLL WHEEL */
|
---|
| 1083 |
|
---|
| 1084 | swfifo[swfiin] = sigtab[59][0];
|
---|
| 1085 |
|
---|
| 1086 | if (++swfiin GE NSWFIFO)
|
---|
| 1087 | swfiin = 0;
|
---|
| 1088 | }
|
---|
| 1089 |
|
---|
| 1090 | if (swctrl) { /* SCROLL ... */
|
---|
| 1091 |
|
---|
| 1092 | swtemp = swcount + swrate;
|
---|
| 1093 | swcount = swtemp & 0x0000FFFFL;
|
---|
| 1094 | swtemp >>= 16;
|
---|
| 1095 |
|
---|
| 1096 | if (swdir EQ D_FWD) { /* ... FORWARD */
|
---|
| 1097 |
|
---|
| 1098 | oldi = setipl(TIM_DI);
|
---|
| 1099 | fc_val += swtemp;
|
---|
| 1100 |
|
---|
| 1101 | if (fc_val GE 0x00FFFFFFL) {
|
---|
| 1102 |
|
---|
| 1103 | swctrl = FALSE;
|
---|
| 1104 | fc_val = 0x00FFFFFFL;
|
---|
| 1105 | }
|
---|
| 1106 |
|
---|
| 1107 | setipl(oldi);
|
---|
| 1108 |
|
---|
| 1109 | } else { /* ... BACKWARD */
|
---|
| 1110 |
|
---|
| 1111 | oldi = setipl(TIM_DI);
|
---|
| 1112 | fc_val -= swtemp;
|
---|
| 1113 |
|
---|
| 1114 | if (fc_val < 0) {
|
---|
| 1115 |
|
---|
| 1116 | swctrl = FALSE;
|
---|
| 1117 | fc_val = 0L;
|
---|
| 1118 | }
|
---|
| 1119 |
|
---|
| 1120 | setipl(oldi);
|
---|
| 1121 | }
|
---|
| 1122 | }
|
---|
[fa38804] | 1123 |
|
---|
[f40a309] | 1124 | if (swflag OR swctrl) { /* RESET THE SCROLL TIMER */
|
---|
| 1125 |
|
---|
| 1126 | oldi = setipl(TIM_DI);
|
---|
| 1127 | timers[SWTIMER] = swtime;
|
---|
| 1128 | setipl(oldi);
|
---|
| 1129 | }
|
---|
| 1130 | }
|
---|
| 1131 | }
|
---|
| 1132 |
|
---|
| 1133 | /*
|
---|
| 1134 | =============================================================================
|
---|
| 1135 | tkinit() -- initialize trackball variables
|
---|
| 1136 | =============================================================================
|
---|
| 1137 | */
|
---|
| 1138 |
|
---|
[0580615] | 1139 | void tkinit(void)
|
---|
[f40a309] | 1140 | {
|
---|
| 1141 | trkball = FALSE; /* stop the trackball */
|
---|
| 1142 | txflag = FALSE; /* ... */
|
---|
| 1143 | tyflag = FALSE; /* ... */
|
---|
| 1144 | tkctrl = FALSE; /* ... */
|
---|
| 1145 | tkboth = FALSE; /* ... */
|
---|
| 1146 |
|
---|
| 1147 | memsetw(txfifo, 0, NTKFIFO); /* clear trackball X fifo */
|
---|
| 1148 | txfiin = 0; /* ... */
|
---|
| 1149 |
|
---|
| 1150 | memsetw(tyfifo, 0, NTKFIFO); /* clear trackball Y fifo */
|
---|
| 1151 | tyfiin = 0; /* ... */
|
---|
| 1152 | }
|
---|
[6262b5c] | 1153 |
|
---|