[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | sctrak.c -- advance the score to a given frame
|
---|
| 4 | Version 28 -- 1988-09-23 -- D.N. Lynx Crowe
|
---|
| 5 | =============================================================================
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #undef DEBUGGER /* define to enable debug trace */
|
---|
| 9 |
|
---|
| 10 | #undef DEBUG_TR /* define for sc_trak() debug */
|
---|
| 11 |
|
---|
| 12 | #undef CHECKPTR /* define to check pointers */
|
---|
| 13 |
|
---|
| 14 | #include "debug.h"
|
---|
| 15 |
|
---|
| 16 | #include "hwdefs.h"
|
---|
| 17 | #include "stddefs.h"
|
---|
| 18 | #include "score.h"
|
---|
| 19 | #include "scfns.h"
|
---|
| 20 | #include "memory.h"
|
---|
| 21 | #include "slice.h"
|
---|
| 22 |
|
---|
[e225e77] | 23 | #include "vsddsw.h"
|
---|
| 24 |
|
---|
| 25 | extern void dslocn(void);
|
---|
| 26 | extern void sc_adv(void);
|
---|
| 27 | extern void se_disp(struct s_entry *ep, int16_t sd, struct gdsel *gdstb[], int16_t cf);
|
---|
| 28 | extern void sreset(void);
|
---|
| 29 |
|
---|
[f40a309] | 30 | #ifdef DEBUG_TR
|
---|
| 31 | extern short debugsw;
|
---|
| 32 | #endif
|
---|
| 33 |
|
---|
[7258c6a] | 34 | extern int16_t ancmsw;
|
---|
| 35 | extern int16_t dubsw;
|
---|
| 36 | extern int16_t ndisp;
|
---|
| 37 | extern int16_t recsw;
|
---|
| 38 | extern int16_t sbase;
|
---|
| 39 | extern int16_t sd;
|
---|
| 40 | extern int16_t se;
|
---|
| 41 | extern int16_t soffset;
|
---|
[f40a309] | 42 |
|
---|
[7258c6a] | 43 | extern int16_t grpmode[];
|
---|
| 44 | extern int16_t grpstat[];
|
---|
[f40a309] | 45 |
|
---|
[7258c6a] | 46 | extern int16_t varmode[][16];
|
---|
[f40a309] | 47 |
|
---|
| 48 | extern struct gdsel *gdfsep;
|
---|
| 49 |
|
---|
| 50 | extern struct gdsel *gdstbc[];
|
---|
| 51 | extern struct gdsel *gdstbn[];
|
---|
| 52 | extern struct gdsel *gdstbp[];
|
---|
| 53 |
|
---|
| 54 | /* |
---|
| 55 |
|
---|
| 56 | */
|
---|
| 57 |
|
---|
| 58 | /*
|
---|
| 59 | =============================================================================
|
---|
| 60 | sc_trak(tval) -- position score display such that t_ctr EQ 'tval'
|
---|
| 61 | Assumes that the pointers are correct.
|
---|
| 62 | =============================================================================
|
---|
| 63 | */
|
---|
[7258c6a] | 64 |
|
---|
[f40a309] | 65 | int16_t sc_trak(int32_t tval)
|
---|
| 66 | {
|
---|
[7258c6a] | 67 | register struct s_entry *rpb, *rpc, *rpf;
|
---|
| 68 | register int32_t rtb, rtc, rtf;
|
---|
[f40a309] | 69 | register int16_t mod48 = 48;
|
---|
| 70 | struct gdsel *gdsp;
|
---|
| 71 |
|
---|
| 72 | DB_ENTR("sc_trak");
|
---|
| 73 |
|
---|
| 74 | if (ndisp NE 2) {
|
---|
| 75 |
|
---|
| 76 | DB_EXIT("sc_trak - ndisp NE 2");
|
---|
| 77 | return(FAILURE);
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | #ifdef CHECKPTR
|
---|
| 81 | Pcheck(p_fwd, "p_fwd - sc_trak - entry");
|
---|
| 82 | Pcheck(p_ctr, "p_ctr - sc_trak - entry");
|
---|
| 83 | Pcheck(p_bak, "p_bak - sc_trak - entry");
|
---|
| 84 | #endif
|
---|
| 85 |
|
---|
| 86 | if ((p_fwd EQ E_NULL) OR (p_ctr EQ E_NULL) OR (p_bak EQ E_NULL)) {
|
---|
| 87 |
|
---|
| 88 | DB_EXIT("sc_trak - NULL ptr");
|
---|
| 89 | return(FAILURE);
|
---|
| 90 | }
|
---|
| 91 | /* |
---|
| 92 |
|
---|
| 93 | */
|
---|
| 94 | if (v_regs[5] & 0x0180) /* setup for VSDD bank 0 */
|
---|
| 95 | vbank(0);
|
---|
| 96 |
|
---|
| 97 | rpf = p_fwd; /* forward event pointer */
|
---|
| 98 | rtf = t_fwd; /* forward event time */
|
---|
| 99 |
|
---|
| 100 | rpc = p_ctr; /* current event pointer */
|
---|
| 101 | rtc = t_ctr; /* current event time */
|
---|
| 102 |
|
---|
| 103 | rpb = p_bak; /* backward event pointer */
|
---|
| 104 | rtb = t_bak; /* backward event time */
|
---|
| 105 |
|
---|
| 106 | #ifdef DEBUG_TR
|
---|
| 107 | if (debugsw) {
|
---|
| 108 |
|
---|
| 109 | printf("\n## sc_trak(%10ld) ENTRY - fc_val=%10ld sd = %s sbase=%d soffset=%d\n",
|
---|
| 110 | tval, fc_val, sd ? "BAK" : "FWD", sbase, soffset);
|
---|
| 111 |
|
---|
| 112 | printf(" p_bak: %08lX p_ctr: %08lX p_fwd: %08lX\n",
|
---|
| 113 | p_bak, p_ctr, p_fwd);
|
---|
| 114 |
|
---|
| 115 | printf(" t_bak: %10ld t_ctr: %10ld t_fwd: %10ld\n",
|
---|
| 116 | t_bak, t_ctr, t_fwd);
|
---|
| 117 |
|
---|
| 118 | printf(" T.bak: %10ld T.ctr: %10ld T.fwd: %10ld\n",
|
---|
| 119 | p_bak->e_time, p_ctr->e_time, p_fwd->e_time);
|
---|
| 120 | }
|
---|
| 121 | #endif
|
---|
| 122 |
|
---|
| 123 | /* |
---|
| 124 |
|
---|
| 125 | */
|
---|
| 126 | DB_CMNT("sc_trak - update loop");
|
---|
| 127 |
|
---|
| 128 | if (sd EQ D_FWD) { /* scroll forward */
|
---|
| 129 |
|
---|
| 130 | DB_CMNT("sc_trak - forward");
|
---|
| 131 |
|
---|
| 132 | while (rtc++ LT tval) { /* advance to tval */
|
---|
| 133 |
|
---|
| 134 | sreset(); /* reset highlighting */
|
---|
| 135 |
|
---|
| 136 | ++rtb; /* update target time at p_bak */
|
---|
| 137 | ++rtf; /* update target time at p_fwd */
|
---|
| 138 |
|
---|
| 139 | if (rpb->e_type NE EV_FINI) { /* up to end of score */
|
---|
| 140 |
|
---|
| 141 | while (rpb->e_time EQ rtb) { /* check event time */
|
---|
| 142 |
|
---|
| 143 | se_disp(rpb, D_FWD, gdstbp, 0); /* display event */
|
---|
| 144 | rpb = rpb->e_fwd; /* point at next event */
|
---|
| 145 |
|
---|
| 146 | if (rpb->e_type EQ EV_FINI) /* stop at end of score */
|
---|
| 147 | break;
|
---|
| 148 | }
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | if (0 EQ (rtb % mod48)) { /* handle beat markers */
|
---|
| 152 |
|
---|
| 153 | if ((struct gdsel *)NULL NE (gdsp = gdfsep)) {
|
---|
| 154 |
|
---|
| 155 | gdfsep = gdsp->next;
|
---|
| 156 |
|
---|
| 157 | gdsp->next = gdstbp[12];
|
---|
| 158 | gdsp->note = 0x1111;
|
---|
| 159 | gdsp->code = 1;
|
---|
| 160 |
|
---|
| 161 | gdstbp[12] = gdsp;
|
---|
| 162 | }
|
---|
| 163 | }
|
---|
| 164 | /* |
---|
| 165 |
|
---|
| 166 | */
|
---|
| 167 | if (rpc->e_type NE EV_FINI) { /* up to end of score */
|
---|
| 168 |
|
---|
| 169 | while (rpc->e_time EQ rtc) { /* check event time */
|
---|
| 170 |
|
---|
| 171 | se_disp(rpc, D_FWD, gdstbc, 1); /* display event */
|
---|
| 172 | rpc = rpc->e_fwd; /* point at next event */
|
---|
| 173 |
|
---|
| 174 | if (rpc->e_type EQ EV_FINI) /* stop at end of score */
|
---|
| 175 | break;
|
---|
| 176 | }
|
---|
| 177 | }
|
---|
| 178 |
|
---|
| 179 | if (rpf->e_type NE EV_FINI) { /* up to end of score */
|
---|
| 180 |
|
---|
| 181 | while (rpf->e_time EQ rtf) { /* check event time */
|
---|
| 182 |
|
---|
| 183 | se_disp(rpf, D_FWD, gdstbn, 0); /* display event */
|
---|
| 184 | rpf = rpf->e_fwd; /* next event pointer */
|
---|
| 185 |
|
---|
| 186 | if (rpf->e_type EQ EV_FINI) /* stop at end of score */
|
---|
| 187 | break;
|
---|
| 188 | }
|
---|
| 189 | }
|
---|
| 190 |
|
---|
| 191 | if (0 EQ (rtf % mod48)) { /* handle beat markers */
|
---|
| 192 |
|
---|
| 193 | if ((struct gdsel *)NULL NE (gdsp = gdfsep)) {
|
---|
| 194 |
|
---|
| 195 | gdfsep = gdsp->next;
|
---|
| 196 |
|
---|
| 197 | gdsp->next = gdstbn[12];
|
---|
| 198 | gdsp->note = 0x1111;
|
---|
| 199 | gdsp->code = 1;
|
---|
| 200 |
|
---|
| 201 | gdstbn[12] = gdsp;
|
---|
| 202 | }
|
---|
| 203 | }
|
---|
| 204 |
|
---|
| 205 | sc_adv(); /* scroll the display */
|
---|
| 206 | }
|
---|
| 207 |
|
---|
| 208 | /* |
---|
| 209 |
|
---|
| 210 | */
|
---|
| 211 | } else { /* scroll backward */
|
---|
| 212 |
|
---|
| 213 | DB_CMNT("sc_trak - backward");
|
---|
| 214 |
|
---|
| 215 | while (rtc-- GT tval) { /* advance to tval */
|
---|
| 216 |
|
---|
| 217 | sreset(); /* reset highlighting */
|
---|
| 218 |
|
---|
| 219 | --rtb; /* update target time at p_bak */
|
---|
| 220 | --rtf; /* update target time at p_fwd */
|
---|
| 221 |
|
---|
| 222 | if (rpb->e_type NE EV_SCORE) { /* up to start of score */
|
---|
| 223 |
|
---|
| 224 | while (rpb->e_time EQ rtb) { /* check event time */
|
---|
| 225 |
|
---|
| 226 | se_disp(rpb, D_BAK, gdstbp, 0);
|
---|
| 227 | rpb = rpb->e_bak; /* point at next event */
|
---|
| 228 |
|
---|
| 229 | if (rpb->e_type EQ EV_SCORE) /* stop at end of score */
|
---|
| 230 | break;
|
---|
| 231 | }
|
---|
| 232 | }
|
---|
| 233 |
|
---|
| 234 | if (0 EQ (rtb % mod48)) { /* handle beat markers */
|
---|
| 235 |
|
---|
| 236 | if ((struct gdsel *)NULL NE (gdsp = gdfsep)) {
|
---|
| 237 |
|
---|
| 238 | gdfsep = gdsp->next;
|
---|
| 239 |
|
---|
| 240 | gdsp->next = gdstbp[12];
|
---|
| 241 | gdsp->note = 0x1111;
|
---|
| 242 | gdsp->code = 1;
|
---|
| 243 |
|
---|
| 244 | gdstbp[12] = gdsp;
|
---|
| 245 | }
|
---|
| 246 | }
|
---|
| 247 | /* |
---|
| 248 |
|
---|
| 249 | */
|
---|
| 250 | if (rpc->e_type NE EV_SCORE) { /* up to start of score */
|
---|
| 251 |
|
---|
| 252 | while (rpc->e_time EQ rtc) { /* check event time */
|
---|
| 253 |
|
---|
| 254 | se_disp(rpc, D_BAK, gdstbc, 1); /* display event */
|
---|
| 255 | rpc = rpc->e_bak; /* point at next event */
|
---|
| 256 |
|
---|
| 257 | if (rpc->e_type EQ EV_SCORE) /* stop at end of score */
|
---|
| 258 | break;
|
---|
| 259 | }
|
---|
| 260 | }
|
---|
| 261 |
|
---|
| 262 | if (rpf->e_type NE EV_SCORE) { /* up to end of score */
|
---|
| 263 |
|
---|
| 264 | while (rpf->e_time EQ rtf) { /* check event time */
|
---|
| 265 |
|
---|
| 266 | se_disp(rpf, D_BAK, gdstbn, 0); /* display event */
|
---|
| 267 | rpf = rpf->e_bak; /* next event pointer */
|
---|
| 268 |
|
---|
| 269 | if (rpf->e_type EQ EV_SCORE) /* stop at end of score */
|
---|
| 270 | break;
|
---|
| 271 | }
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | if (0 EQ (rtf % mod48)) { /* handle beat markers */
|
---|
| 275 |
|
---|
| 276 | if ((struct gdsel *)NULL NE (gdsp = gdfsep)) {
|
---|
| 277 |
|
---|
| 278 | gdfsep = gdsp->next;
|
---|
| 279 |
|
---|
| 280 | gdsp->next = gdstbn[12];
|
---|
| 281 | gdsp->note = 0x1111;
|
---|
| 282 | gdsp->code = 1;
|
---|
| 283 |
|
---|
| 284 | gdstbn[12] = gdsp;
|
---|
| 285 | }
|
---|
| 286 | }
|
---|
| 287 |
|
---|
| 288 | sc_adv(); /* scroll the display */
|
---|
| 289 | }
|
---|
| 290 | }
|
---|
| 291 | /* |
---|
| 292 |
|
---|
| 293 | */
|
---|
| 294 | p_fwd = rpf; /* update p_fwd */
|
---|
| 295 | t_fwd = tval + TO_FWD; /* update t_fwd */
|
---|
| 296 |
|
---|
| 297 | p_ctr = rpc; /* update p_ctr */
|
---|
| 298 | t_ctr = tval; /* update t_ctr */
|
---|
| 299 |
|
---|
| 300 | p_bak = rpb; /* update p_bak */
|
---|
| 301 | t_bak = tval - TO_BAK; /* update t_bak */
|
---|
| 302 |
|
---|
| 303 | DB_CMNT("sc_trak - dslocn");
|
---|
| 304 | dslocn(); /* display current location */
|
---|
| 305 |
|
---|
| 306 | #ifdef DEBUG_TR
|
---|
| 307 | if (debugsw) {
|
---|
| 308 |
|
---|
| 309 | printf("\n## sc_trak(%10ld) EXIT - fc_val=%10ld sbase=%d soffset=%d\n",
|
---|
| 310 | tval, fc_val, sbase, soffset);
|
---|
| 311 |
|
---|
| 312 | printf(" p_bak: %08lX, p_ctr: %08lX, p_fwd: %08lX\n",
|
---|
| 313 | p_bak, p_ctr, p_fwd);
|
---|
| 314 |
|
---|
| 315 | printf(" t_bak: %10ld, t_ctr: %10ld, t_fwd: %10ld\n",
|
---|
| 316 | t_bak, t_ctr, t_fwd);
|
---|
| 317 |
|
---|
| 318 | printf(" T.bak: %10ld T.ctr: %10ld T.fwd: %10ld\n",
|
---|
| 319 | p_bak->e_time, p_ctr->e_time, p_fwd->e_time);
|
---|
| 320 | }
|
---|
| 321 | #endif
|
---|
| 322 |
|
---|
| 323 | DB_EXIT("sc_trak");
|
---|
| 324 | return(SUCCESS);
|
---|
| 325 | }
|
---|
| 326 |
|
---|
| 327 | /* |
---|
| 328 |
|
---|
[7258c6a] | 329 | */
|
---|
[f40a309] | 330 |
|
---|
| 331 | /*
|
---|
[7258c6a] | 332 | =============================================================================
|
---|
| 333 | sc_trek(tval) -- follow score chain such that t_cur EQ 'tval'
|
---|
[f40a309] | 334 | =============================================================================
|
---|
| 335 | */
|
---|
| 336 |
|
---|
| 337 | int16_t sc_trek(int32_t tval)
|
---|
| 338 | {
|
---|
| 339 | register struct s_entry *rp, *ep;
|
---|
| 340 | register int32_t tc, rt;
|
---|
| 341 | register int16_t et, grp;
|
---|
| 342 |
|
---|
| 343 | DB_ENTR("sc_trek");
|
---|
| 344 |
|
---|
| 345 | #ifdef CHECKPTR
|
---|
| 346 | Pcheck(p_cur, "p_cur - sc_trek - entry");
|
---|
| 347 | #endif
|
---|
| 348 |
|
---|
| 349 | if (p_cur EQ E_NULL) {
|
---|
| 350 |
|
---|
| 351 | DB_EXIT("sc_trek - NULL ptr");
|
---|
| 352 | return(FAILURE);
|
---|
| 353 | }
|
---|
| 354 |
|
---|
| 355 | rp = p_cur; /* current event pointer */
|
---|
| 356 | rt = t_cur; /* current event time */
|
---|
| 357 |
|
---|
| 358 | DB_CMNT("sc_trek - chasing p_cur");
|
---|
| 359 |
|
---|
| 360 | #ifdef DEBUGGER
|
---|
| 361 | if (se EQ D_FWD)
|
---|
| 362 | DB_CMNT("sc_trek - forward");
|
---|
| 363 | else
|
---|
| 364 | DB_CMNT("sc_trek - backward");
|
---|
| 365 | #endif
|
---|
| 366 |
|
---|
| 367 | /* |
---|
| 368 |
|
---|
| 369 | */
|
---|
| 370 | while (rt NE tval) { /* track tval */
|
---|
| 371 |
|
---|
| 372 | if (se EQ D_FWD)
|
---|
| 373 | ++rt;
|
---|
| 374 | else
|
---|
| 375 | --rt;
|
---|
| 376 |
|
---|
| 377 | if (rp->e_type NE EV_FINI) {
|
---|
| 378 |
|
---|
| 379 | while (rp->e_time EQ rt) { /* process events a rt */
|
---|
| 380 |
|
---|
| 381 | /* "erase head" logic */
|
---|
| 382 |
|
---|
| 383 | if (recsw AND (se EQ D_FWD)) {
|
---|
| 384 |
|
---|
| 385 | et = 0x007F & rp->e_type;
|
---|
| 386 |
|
---|
| 387 | if ((NOT dubsw) AND
|
---|
| 388 | ((et EQ EV_NBEG) OR (et EQ EV_NEND))) {
|
---|
| 389 |
|
---|
| 390 | grp = rp->e_data2;
|
---|
| 391 |
|
---|
| 392 | if (grpstat[grp] AND (2 EQ grpmode[grp])) {
|
---|
| 393 |
|
---|
| 394 | DB_CMNT("sc_trek - erasing note");
|
---|
| 395 |
|
---|
| 396 | /* erasing a note */
|
---|
| 397 |
|
---|
| 398 | ep = rp->e_fwd;
|
---|
| 399 |
|
---|
| 400 | if (rp EQ p_bak)
|
---|
| 401 | p_bak = ep;
|
---|
| 402 |
|
---|
| 403 | if (rp EQ p_cur)
|
---|
| 404 | p_cur = ep;
|
---|
| 405 |
|
---|
| 406 | if (rp EQ p_ctr)
|
---|
| 407 | p_ctr = ep;
|
---|
| 408 |
|
---|
| 409 | if (rp EQ p_fwd)
|
---|
| 410 | p_fwd = ep;
|
---|
| 411 |
|
---|
| 412 | e_del(e_rmv(rp));
|
---|
| 413 | rp = ep;
|
---|
| 414 | goto nextev;
|
---|
| 415 | }
|
---|
| 416 | /* |
---|
| 417 |
|
---|
| 418 | */
|
---|
| 419 | } else if (et EQ EV_ANVL) {
|
---|
| 420 |
|
---|
| 421 | grp = 0x000F & rp->e_data1;
|
---|
| 422 |
|
---|
| 423 | if (grpstat[grp] AND (2 EQ (ancmsw ?
|
---|
| 424 | varmode[0x000F & (rp->e_data1 >> 4)][grp] :
|
---|
| 425 | grpmode[grp]))) {
|
---|
| 426 |
|
---|
| 427 | DB_CMNT("sc_trek - erasing var");
|
---|
| 428 |
|
---|
| 429 | /* erasing an analog variable */
|
---|
| 430 |
|
---|
| 431 | ep = rp->e_fwd;
|
---|
| 432 |
|
---|
| 433 | if (rp EQ p_bak)
|
---|
| 434 | p_bak = ep;
|
---|
| 435 |
|
---|
| 436 | if (rp EQ p_cur)
|
---|
| 437 | p_cur = ep;
|
---|
| 438 |
|
---|
| 439 | if (rp EQ p_ctr)
|
---|
| 440 | p_ctr = ep;
|
---|
| 441 |
|
---|
| 442 | if (rp EQ p_fwd)
|
---|
| 443 | p_fwd = ep;
|
---|
| 444 |
|
---|
| 445 | e_del(e_rmv(rp));
|
---|
| 446 | rp = ep;
|
---|
| 447 | goto nextev;
|
---|
| 448 | }
|
---|
| 449 | }
|
---|
| 450 | }
|
---|
| 451 |
|
---|
| 452 | if (rp->e_time EQ rt) { /* check event time */
|
---|
| 453 |
|
---|
| 454 | se_exec(rp, se); /* execute event */
|
---|
| 455 |
|
---|
| 456 | if (se EQ D_FWD)
|
---|
| 457 | rp = rp->e_fwd; /* point at next event */
|
---|
| 458 | else
|
---|
| 459 | rp = rp->e_bak; /* point at next event */
|
---|
| 460 | }
|
---|
| 461 |
|
---|
| 462 | nextev:
|
---|
| 463 | if (((se EQ D_FWD) AND (rp->e_type EQ EV_FINI)) OR
|
---|
| 464 | ((se EQ D_BAK) AND (rp->e_type EQ EV_SCORE)))
|
---|
| 465 | break;
|
---|
| 466 | }
|
---|
| 467 | }
|
---|
| 468 | }
|
---|
| 469 | /* |
---|
| 470 |
|
---|
| 471 | */
|
---|
| 472 | p_cur = rp; /* update p_cur */
|
---|
| 473 | t_cur = tval; /* update t_cur */
|
---|
| 474 |
|
---|
| 475 | DB_EXIT("sc_trek");
|
---|
| 476 | return(SUCCESS);
|
---|
| 477 | }
|
---|