[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | seccpy.c -- section operation functions
|
---|
| 4 | Version 12 -- 1988-07-16 -- D.N. Lynx Crowe
|
---|
| 5 |
|
---|
| 6 | This file contains the section operation functions for:
|
---|
| 7 |
|
---|
| 8 | SOP_CPY copy sec_cpy()
|
---|
| 9 | SOP_MRG merge sec_mrg()
|
---|
| 10 | SOP_MOV move sec_mov()
|
---|
| 11 | SOP_RMV remove sec_rmv()
|
---|
| 12 | SOP_GRP regroup sec_grp()
|
---|
| 13 | SOP_DGR delete groups sec_dgr()
|
---|
| 14 | SOP_DEV delete events sec_dev()
|
---|
| 15 | =============================================================================
|
---|
| 16 | */
|
---|
| 17 |
|
---|
| 18 | #undef DEBUGGER /* define to enable debug trace */
|
---|
| 19 | #define DEBUGIT 0
|
---|
| 20 |
|
---|
[b28a12e] | 21 | #include "ram.h"
|
---|
[f40a309] | 22 |
|
---|
| 23 | /*
|
---|
| 24 | =============================================================================
|
---|
| 25 | sec_cpy() -- copy section 'ns' into the score at t_cur
|
---|
| 26 |
|
---|
| 27 | ns section number to be copied
|
---|
| 28 |
|
---|
| 29 | returns SUCCESS or FAILURE
|
---|
| 30 | =============================================================================
|
---|
| 31 | */
|
---|
| 32 |
|
---|
[7258c6a] | 33 | int16_t sec_cpy(int16_t ns)
|
---|
[f40a309] | 34 | {
|
---|
| 35 | register struct s_entry *cp, *lp, *rp;
|
---|
[7258c6a] | 36 | register int32_t newet;
|
---|
[f40a309] | 37 |
|
---|
| 38 | DB_ENTR("sec_cpy");
|
---|
| 39 |
|
---|
| 40 | secopok = TRUE;
|
---|
| 41 |
|
---|
| 42 | if (chksec(ns)) { /* check that section is OK */
|
---|
| 43 |
|
---|
| 44 | DB_EXIT("sec_cpy - FAILED chksec");
|
---|
| 45 | return(FAILURE);
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | /* see if we have enough free event space to make the copy */
|
---|
| 49 |
|
---|
| 50 | if (sizesec() > evleft()) {
|
---|
| 51 |
|
---|
| 52 | DB_EXIT("sec_cpy - FAILED sizesec");
|
---|
| 53 | return(FAILURE);
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | /* make sure we won't overflow the time range */
|
---|
| 57 |
|
---|
| 58 | newet = t_sect + ((scp->e_bak)->e_bak)->e_time;
|
---|
| 59 |
|
---|
| 60 | if ((newet < 0) OR (newet GE 0x00FFFFFFL)) {
|
---|
| 61 |
|
---|
| 62 | DB_EXIT("sec_cpy - FAILED time check");
|
---|
| 63 | return(FAILURE);
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | /* |
---|
| 67 |
|
---|
| 68 | */
|
---|
| 69 | /* make a time adjusted copy of the section */
|
---|
| 70 |
|
---|
| 71 | if (E_NULL EQ (cp = madjsec(p_sbgn, t_cur))) {
|
---|
| 72 |
|
---|
| 73 | DB_EXIT("sec_cpy - FAILED madjsec");
|
---|
| 74 | return(FAILURE);
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | /* point at the events in the score that will surround the copy */
|
---|
| 78 |
|
---|
| 79 | lp = ep_adj(p_cur, 0, t_cur); /* events left of the copy */
|
---|
[9519422] | 80 | rp = lp->e_fwd; /* events right of the copy */
|
---|
[f40a309] | 81 |
|
---|
| 82 | /* adjust the times in the score past the copy */
|
---|
| 83 |
|
---|
| 84 | edelta(lp, t_cur, t_sect);
|
---|
| 85 |
|
---|
| 86 | /* insert the copy into the score */
|
---|
| 87 |
|
---|
| 88 | lp->e_fwd = p_cbgn; /* link copy to left events */
|
---|
| 89 | p_cbgn->e_bak = lp;
|
---|
| 90 |
|
---|
| 91 | rp->e_bak = p_cend; /* link copy to right events */
|
---|
| 92 | p_cend->e_fwd = rp;
|
---|
| 93 |
|
---|
| 94 | /* fix-up the event headers in the copy */
|
---|
| 95 |
|
---|
| 96 | ehfix(p_cbgn, p_cend);
|
---|
| 97 |
|
---|
| 98 | DB_EXIT("sec_cpy - SUCCESS");
|
---|
| 99 | return(SUCCESS);
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | /* |
---|
| 103 |
|
---|
| 104 | */
|
---|
| 105 |
|
---|
| 106 | /*
|
---|
| 107 | =============================================================================
|
---|
| 108 | sec_mrg() -- merge section 'ns' into the score at t_cur
|
---|
| 109 |
|
---|
| 110 | ns section number to be merged
|
---|
| 111 |
|
---|
| 112 | returns SUCCESS or FAILURE
|
---|
| 113 | =============================================================================
|
---|
[7258c6a] | 114 | */
|
---|
[f40a309] | 115 |
|
---|
| 116 | int16_t sec_mrg(int16_t ns)
|
---|
[7258c6a] | 117 | {
|
---|
| 118 | register struct s_entry *cp, *lp, *rp;
|
---|
[f40a309] | 119 | register int32_t newet;
|
---|
| 120 | register int16_t et;
|
---|
| 121 |
|
---|
| 122 | DB_ENTR("sec_mrg");
|
---|
| 123 |
|
---|
| 124 | secopok = TRUE;
|
---|
| 125 |
|
---|
| 126 | if (chksec(ns)) { /* check that section is OK */
|
---|
| 127 |
|
---|
| 128 | DB_EXIT("sec_mrg - FAILED chksec");
|
---|
| 129 | return(FAILURE);
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | /* see if we have enough free event space to make the copy */
|
---|
| 133 |
|
---|
| 134 | if (sizesec() > evleft()) {
|
---|
| 135 |
|
---|
| 136 | DB_EXIT("sec_mrg - FAILED sizesec");
|
---|
| 137 | return(FAILURE);
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | /* make sure we won't overflow the time range */
|
---|
| 141 |
|
---|
| 142 | newet = t_sect + ((scp->e_bak)->e_bak)->e_time;
|
---|
| 143 |
|
---|
| 144 | if ((newet < 0) OR (newet GE 0x00FFFFFFL)) {
|
---|
| 145 |
|
---|
| 146 | DB_EXIT("sec_mrg - FAILED time check");
|
---|
| 147 | return(FAILURE);
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | /* |
---|
| 151 |
|
---|
| 152 | */
|
---|
| 153 | /* make a time adjusted copy of the section */
|
---|
| 154 |
|
---|
| 155 | if (E_NULL EQ (cp = madjsec(p_sbgn, t_cur))) {
|
---|
| 156 |
|
---|
| 157 | DB_EXIT("sec_mrg - FAILED madjsec");
|
---|
| 158 | return(FAILURE);
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | DB_CMNT("sec_mrg - merging events");
|
---|
| 162 |
|
---|
| 163 | lp = ep_adj(p_cur, 0, t_cur); /* get merge point */
|
---|
| 164 |
|
---|
| 165 | while (cp) { /* merge events into score starting at p_cur */
|
---|
| 166 |
|
---|
| 167 | rp = cp->e_fwd; /* point at next event */
|
---|
| 168 | lp = ep_adj(lp, 0, cp->e_time); /* update merge point */
|
---|
| 169 | lp = e_ins(cp, lp); /* insert the element */
|
---|
| 170 | et = cp->e_type & 0x007F; /* get event type */
|
---|
| 171 |
|
---|
| 172 | if (-1 NE ehdlist[et]) /* see if it's a header */
|
---|
| 173 | eh_ins(cp, ehdlist[et]); /* update header list */
|
---|
| 174 |
|
---|
| 175 | cp = rp; /* update copy pointer */
|
---|
| 176 | }
|
---|
| 177 |
|
---|
| 178 | DB_EXIT("sec_mrg - SUCCESS");
|
---|
| 179 | return(SUCCESS);
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | /* |
---|
| 183 |
|
---|
| 184 | */
|
---|
| 185 |
|
---|
| 186 | /*
|
---|
| 187 | =============================================================================
|
---|
| 188 | sec_grp() -- regroup section 'ns'
|
---|
| 189 |
|
---|
| 190 | ns section number to be re-grouped
|
---|
| 191 |
|
---|
[7258c6a] | 192 | returns SUCCESS or FAILURE
|
---|
[f40a309] | 193 | =============================================================================
|
---|
| 194 | */
|
---|
[7258c6a] | 195 |
|
---|
[f40a309] | 196 | int16_t sec_grp(int16_t ns)
|
---|
| 197 | {
|
---|
| 198 | register struct s_entry *cp, *rp;
|
---|
| 199 | register int16_t et, nv, grp;
|
---|
| 200 |
|
---|
| 201 | DB_ENTR("sec_grp");
|
---|
| 202 |
|
---|
| 203 | secopok = TRUE;
|
---|
| 204 |
|
---|
| 205 | if (chksec(ns)) { /* check that section is OK */
|
---|
| 206 |
|
---|
| 207 | DB_EXIT("sec_grp - FAILED chksec");
|
---|
| 208 | return(FAILURE);
|
---|
| 209 | }
|
---|
| 210 |
|
---|
| 211 | cp = p_sbgn; /* point at start of section */
|
---|
| 212 |
|
---|
| 213 | while (cp NE p_send) { /* regroup events in section */
|
---|
| 214 |
|
---|
| 215 | rp = cp->e_fwd; /* point at next event */
|
---|
| 216 | et = cp->e_type & 0x007F; /* get event type */
|
---|
| 217 |
|
---|
| 218 | if (cmgtags[et]) { /* group sensitive ? */
|
---|
| 219 |
|
---|
| 220 | grp = 0x000F & (cmgtype[et] ?
|
---|
| 221 | cp->e_data2 : cp->e_data1);
|
---|
| 222 |
|
---|
| 223 | if ((et EQ EV_NBEG) OR (et EQ EV_NEND)) {
|
---|
| 224 |
|
---|
| 225 | /* regroup */
|
---|
| 226 |
|
---|
| 227 | cp->e_data2 = (cp->e_data2 & 0x00F0) |
|
---|
| 228 | grptmap[grp];
|
---|
| 229 |
|
---|
| 230 | /* transpose */
|
---|
| 231 |
|
---|
| 232 | nv = cp->e_data1 + grptran;
|
---|
| 233 |
|
---|
| 234 | if (nv > 127)
|
---|
| 235 | nv = 127;
|
---|
| 236 | else if (nv < 0)
|
---|
| 237 | nv = 0;
|
---|
| 238 |
|
---|
| 239 | cp->e_data1 = nv;
|
---|
| 240 |
|
---|
| 241 | } else if ((et EQ EV_ANRS) OR (et EQ EV_ANVL)) {
|
---|
| 242 |
|
---|
| 243 | /* regroup */
|
---|
| 244 |
|
---|
| 245 | cp->e_data1 = (cp->e_data1 & 0x000F) |
|
---|
| 246 | (grptmap[grp] << 4);
|
---|
| 247 |
|
---|
| 248 | } else {
|
---|
| 249 |
|
---|
| 250 | /* regroup */
|
---|
| 251 |
|
---|
| 252 | if (cmgtype[et])
|
---|
| 253 | cp->e_data2 = (cp->e_data2 & 0x00F0) |
|
---|
| 254 | grptmap[grp];
|
---|
| 255 | else
|
---|
| 256 | cp->e_data1 = (cp->e_data1 & 0x00F0) |
|
---|
| 257 | grptmap[grp];
|
---|
| 258 | }
|
---|
| 259 | }
|
---|
| 260 |
|
---|
| 261 | cp = rp; /* update event pointer */
|
---|
| 262 | }
|
---|
| 263 |
|
---|
| 264 | DB_EXIT("sec_grp - SUCCESS");
|
---|
| 265 | return(SUCCESS);
|
---|
| 266 | }
|
---|
| 267 |
|
---|
| 268 | /* |
---|
| 269 |
|
---|
| 270 | */
|
---|
| 271 |
|
---|
| 272 | /*
|
---|
| 273 | =============================================================================
|
---|
| 274 | sec_mov() -- move section 'ns' to t_cur
|
---|
| 275 |
|
---|
| 276 | ns section number to be moved
|
---|
[7258c6a] | 277 |
|
---|
[f40a309] | 278 | returns SUCCESS or FAILURE
|
---|
| 279 | =============================================================================
|
---|
[7258c6a] | 280 | */
|
---|
| 281 |
|
---|
[f40a309] | 282 | int16_t sec_mov(int16_t ns)
|
---|
| 283 | {
|
---|
| 284 | register struct s_entry *cp, *lp, *rp;
|
---|
| 285 | register int32_t newet;
|
---|
| 286 | register int16_t et, grp, nv;
|
---|
| 287 |
|
---|
| 288 | DB_ENTR("sec_mov");
|
---|
| 289 |
|
---|
| 290 | secopok = TRUE;
|
---|
| 291 |
|
---|
| 292 | if (chksec(ns)) { /* check that section is OK */
|
---|
| 293 |
|
---|
| 294 | DB_EXIT("sec_mov - FAILED chksec");
|
---|
| 295 | return(FAILURE);
|
---|
| 296 | }
|
---|
| 297 |
|
---|
| 298 | #if DEBUGIT
|
---|
| 299 | if (debugsw) {
|
---|
| 300 |
|
---|
| 301 | printf("sec_mov: t_cur = %ld, t_sbgn = %ld, t_send = %ld, t_sect = %ld\n",
|
---|
| 302 | t_cur, t_sbgn, t_send, t_sect);
|
---|
| 303 |
|
---|
| 304 | printf("sec_mov: p_cur = $%08lX, p_sbgn = $%08lX, p_send = $%08lX\n",
|
---|
| 305 | p_cur, p_sbgn, p_send);
|
---|
| 306 | }
|
---|
| 307 | #endif
|
---|
| 308 |
|
---|
| 309 | /* verify that section isn't being moved into itself */
|
---|
| 310 |
|
---|
| 311 | if ((t_cur GE t_sbgn) AND (t_cur LE t_send)) {
|
---|
| 312 |
|
---|
| 313 | DB_EXIT("sec_mov -- bad target");
|
---|
| 314 | return(FAILURE);
|
---|
| 315 | }
|
---|
| 316 |
|
---|
| 317 | /* |
---|
| 318 |
|
---|
| 319 | */
|
---|
| 320 | lp = ep_adj(p_cur, 0, t_cur); /* get left move point */
|
---|
| 321 | cp = p_send->e_fwd; /* get adjustment point */
|
---|
| 322 |
|
---|
| 323 | #if DEBUGIT
|
---|
| 324 | if (debugsw)
|
---|
| 325 | printf("sec_mov: lp = $%08lX, cp = $%08lX\n", lp, cp);
|
---|
| 326 | #endif
|
---|
| 327 |
|
---|
| 328 | /* clip out the section and close up the hole */
|
---|
| 329 |
|
---|
| 330 | (p_sbgn->e_bak)->e_fwd = p_send->e_fwd;
|
---|
| 331 | (p_send->e_fwd)->e_bak = p_sbgn->e_bak;
|
---|
| 332 | p_sbgn->e_bak = E_NULL;
|
---|
| 333 | p_send->e_fwd = E_NULL;
|
---|
| 334 |
|
---|
| 335 | /* adjust the times above the clip point to end of score */
|
---|
| 336 |
|
---|
| 337 | if (t_cur GE t_send) /* adjust t_cur if above clip point */
|
---|
| 338 | t_cur -= t_sect;
|
---|
| 339 |
|
---|
| 340 | #if DEBUGIT
|
---|
| 341 | if (debugsw)
|
---|
| 342 | printf("sec_mov: adjusted t_cur = %ld\n", t_cur);
|
---|
| 343 | #endif
|
---|
| 344 |
|
---|
| 345 | while (EV_FINI NE (et = 0x007F & cp->e_type)) {
|
---|
| 346 |
|
---|
| 347 | cp->e_time -= t_sect; /* adjust event time */
|
---|
| 348 | cp = cp->e_fwd; /* point at next event */
|
---|
| 349 | }
|
---|
| 350 |
|
---|
| 351 | /* |
---|
| 352 |
|
---|
| 353 | */
|
---|
| 354 | #if DEBUGIT
|
---|
| 355 | if (debugsw)
|
---|
| 356 | printf("sec_mov: adjusted p_cur->e_time = %ld\n",
|
---|
| 357 | p_cur->e_time);
|
---|
| 358 | #endif
|
---|
| 359 |
|
---|
| 360 | /* relativize the section to 0 and unlink event headers from hplist */
|
---|
| 361 |
|
---|
| 362 | rp = p_sbgn; /* start at the beginning */
|
---|
| 363 | newet = p_sbgn->e_time; /* relativize to begin time EQ 0 */
|
---|
| 364 |
|
---|
| 365 | while (rp) {
|
---|
| 366 |
|
---|
| 367 | rp->e_time -= newet; /* relativize the time */
|
---|
| 368 | et = 0x007F & rp->e_type; /* get event type */
|
---|
| 369 |
|
---|
| 370 | if (cmgtags[et]) { /* group sensitive ? */
|
---|
| 371 |
|
---|
| 372 | grp = 0x000F & (cmgtype[et] ?
|
---|
| 373 | rp->e_data2 : rp->e_data1);
|
---|
| 374 |
|
---|
| 375 | if ((et EQ EV_NBEG) OR (et EQ EV_NEND)) {
|
---|
| 376 |
|
---|
| 377 | /* regroup */
|
---|
| 378 |
|
---|
| 379 | rp->e_data2 = (rp->e_data2 & 0x00F0) |
|
---|
| 380 | grptmap[grp];
|
---|
| 381 |
|
---|
| 382 | /* transpose */
|
---|
| 383 |
|
---|
| 384 | nv = rp->e_data1 + grptran;
|
---|
| 385 |
|
---|
| 386 | if (nv > 127)
|
---|
| 387 | nv = 127;
|
---|
| 388 | else if (nv < 0)
|
---|
| 389 | nv = 0;
|
---|
| 390 |
|
---|
| 391 | rp->e_data1 = nv;
|
---|
| 392 |
|
---|
| 393 | } else if ((et EQ EV_ANRS) OR (et EQ EV_ANVL)) {
|
---|
| 394 |
|
---|
| 395 | /* regroup */
|
---|
| 396 |
|
---|
| 397 | rp->e_data1 = (rp->e_data1 & 0x000F) |
|
---|
| 398 | (grptmap[grp] << 4);
|
---|
| 399 |
|
---|
| 400 | } else {
|
---|
| 401 |
|
---|
| 402 | /* regroup */
|
---|
| 403 |
|
---|
| 404 | if (cmgtype[et])
|
---|
| 405 | rp->e_data2 = (rp->e_data2 & 0x00F0) |
|
---|
| 406 | grptmap[grp];
|
---|
| 407 | else
|
---|
| 408 | rp->e_data1 = (rp->e_data1 & 0x00F0) |
|
---|
| 409 | grptmap[grp];
|
---|
| 410 | }
|
---|
| 411 | }
|
---|
| 412 |
|
---|
| 413 | if (-1 NE ehdlist[et]) /* if it's a header ... */
|
---|
| 414 | eh_rmv(rp, ehdlist[et]); /* ... remove it from hplist */
|
---|
| 415 |
|
---|
| 416 | rp = rp->e_fwd; /* point at the next event */
|
---|
| 417 | }
|
---|
| 418 |
|
---|
| 419 | rp = lp->e_fwd; /* get right insert pointer */
|
---|
| 420 |
|
---|
| 421 | /* insert the moved section */
|
---|
| 422 |
|
---|
| 423 | p_sbgn->e_bak = lp;
|
---|
| 424 | p_send->e_fwd = rp;
|
---|
| 425 | lp->e_fwd = p_sbgn;
|
---|
| 426 | rp->e_bak = p_send;
|
---|
| 427 |
|
---|
| 428 | /* |
---|
| 429 |
|
---|
| 430 | */
|
---|
| 431 | /* derelativize the moved section and put headers back on hplist */
|
---|
| 432 |
|
---|
| 433 | cp = p_sbgn;
|
---|
| 434 | newet = t_cur;
|
---|
| 435 |
|
---|
| 436 | #if DEBUGIT
|
---|
| 437 | if (debugsw)
|
---|
| 438 | printf("sec_mov: lp = $%08lX, cp = $%08lX, rp = $%08lX, newet = %ld\n",
|
---|
| 439 | lp, cp, rp, newet);
|
---|
| 440 | #endif
|
---|
| 441 |
|
---|
| 442 | while (cp NE rp) {
|
---|
| 443 |
|
---|
| 444 | et = 0x007F & cp->e_type; /* get event type */
|
---|
| 445 | cp->e_time += newet; /* derelativize the time */
|
---|
| 446 |
|
---|
| 447 | if (-1 NE ehdlist[et]) /* if event is a header ... */
|
---|
| 448 | eh_ins(cp, ehdlist[et]); /* ... put event on hplist */
|
---|
| 449 |
|
---|
| 450 | cp = cp->e_fwd; /* point at next event */
|
---|
| 451 | }
|
---|
| 452 |
|
---|
| 453 | #if DEBUGIT
|
---|
| 454 | if (debugsw)
|
---|
| 455 | printf("sec_mov: adjusting times above $%08lx (%ld) by %ld\n",
|
---|
| 456 | cp, cp->e_time, t_sect);
|
---|
| 457 | #endif
|
---|
| 458 |
|
---|
| 459 | /* adjust times above move point */
|
---|
| 460 |
|
---|
| 461 | while (EV_FINI NE (et = 0x007F & cp->e_type)) {
|
---|
| 462 |
|
---|
| 463 | cp->e_time += t_sect; /* adjust the time */
|
---|
| 464 | cp = cp->e_fwd; /* point at next event */
|
---|
| 465 | }
|
---|
| 466 |
|
---|
| 467 | DB_EXIT("sec_mov - SUCCESS");
|
---|
| 468 | return(SUCCESS);
|
---|
| 469 | }
|
---|
| 470 |
|
---|
| 471 | /* |
---|
| 472 |
|
---|
| 473 | */
|
---|
| 474 |
|
---|
| 475 | /*
|
---|
[7258c6a] | 476 | =============================================================================
|
---|
[f40a309] | 477 | sec_rmv() --remove section 'ns'
|
---|
| 478 |
|
---|
[7258c6a] | 479 | ns section number to be removed
|
---|
[f40a309] | 480 |
|
---|
| 481 | returns SUCCESS or FAILURE
|
---|
| 482 | =============================================================================
|
---|
| 483 | */
|
---|
| 484 |
|
---|
| 485 | int16_t sec_rmv(int16_t ns)
|
---|
| 486 | {
|
---|
| 487 | register struct s_entry *cp, *lp, *rp;
|
---|
| 488 | register int16_t et;
|
---|
| 489 | struct s_entry *pp;
|
---|
| 490 |
|
---|
| 491 | DB_ENTR("sec_rmv");
|
---|
| 492 |
|
---|
| 493 | secopok = TRUE;
|
---|
| 494 |
|
---|
| 495 | if (chksec(ns)) { /* check that section is OK */
|
---|
| 496 |
|
---|
| 497 | DB_EXIT("sec_rmv - FAILED chksec");
|
---|
| 498 | return(FAILURE);
|
---|
| 499 | }
|
---|
| 500 |
|
---|
| 501 | pp = cp = p_send->e_fwd; /* get adjustment point */
|
---|
| 502 |
|
---|
| 503 | #if DEBUGIT
|
---|
| 504 | if (debugsw) {
|
---|
| 505 |
|
---|
| 506 | printf("sec_rmv: t_cur = %ld, t_sbgn = %ld, t_send = %ld, t_sect = %ld\n",
|
---|
| 507 | t_cur, t_sbgn, t_send, t_sect);
|
---|
| 508 |
|
---|
| 509 | printf("sec_rmv: p_cur = $%08lX, p_sbgn = $%08lX, p_send = $%08lX\n",
|
---|
| 510 | p_cur, p_sbgn, p_send);
|
---|
| 511 |
|
---|
| 512 | printf("sec_rmv: cp = $%08lX\n", cp);
|
---|
| 513 | }
|
---|
| 514 | #endif
|
---|
| 515 |
|
---|
| 516 | /* |
---|
| 517 |
|
---|
| 518 | */
|
---|
| 519 | /* clip out the section and close up the hole */
|
---|
| 520 |
|
---|
| 521 | (p_sbgn->e_bak)->e_fwd = p_send->e_fwd;
|
---|
| 522 | (p_send->e_fwd)->e_bak = p_sbgn->e_bak;
|
---|
| 523 | p_sbgn->e_bak = E_NULL;
|
---|
| 524 | p_send->e_fwd = E_NULL;
|
---|
| 525 |
|
---|
| 526 | /* adjust the times above the clip point to end of score */
|
---|
| 527 |
|
---|
| 528 | if (t_cur GE t_send) /* adjust t_cur if above clip point */
|
---|
| 529 | t_cur -= t_sect;
|
---|
| 530 |
|
---|
| 531 | #if DEBUGIT
|
---|
| 532 | if (debugsw)
|
---|
| 533 | printf("sec_rmv: adjusted t_cur = %ld\n", t_cur);
|
---|
| 534 | #endif
|
---|
| 535 |
|
---|
| 536 | while (EV_FINI NE (et = 0x007F & cp->e_type)) {
|
---|
| 537 |
|
---|
| 538 | cp->e_time -= t_sect; /* adjust event time */
|
---|
| 539 | cp = cp->e_fwd; /* point at next event */
|
---|
| 540 | }
|
---|
| 541 |
|
---|
| 542 | #if DEBUGIT
|
---|
| 543 | if (debugsw)
|
---|
| 544 | printf("sec_rmv: adjusted p_cur->e_time = %ld\n",
|
---|
| 545 | p_cur->e_time);
|
---|
| 546 | #endif
|
---|
| 547 |
|
---|
| 548 | /* unlink event headers from hplist, fix pointers, and delete events */
|
---|
| 549 |
|
---|
| 550 | rp = p_sbgn; /* start at the beginning */
|
---|
| 551 |
|
---|
| 552 | while (rp) {
|
---|
| 553 |
|
---|
| 554 | lp = rp->e_fwd; /* get next event pointer */
|
---|
| 555 | et = 0x007F & rp->e_type; /* get event type */
|
---|
| 556 |
|
---|
| 557 | if (p_bak EQ rp) /* fix p_bak */
|
---|
| 558 | p_bak = pp;
|
---|
| 559 |
|
---|
| 560 | if (p_cur EQ rp) /* fix p_cur */
|
---|
| 561 | p_cur = pp;
|
---|
| 562 |
|
---|
| 563 | if (p_ctr EQ rp) /* fix p_ctr */
|
---|
| 564 | p_ctr = pp;
|
---|
| 565 |
|
---|
| 566 | if (p_fwd EQ rp) /* fix p_fwd */
|
---|
| 567 | p_fwd = pp;
|
---|
| 568 |
|
---|
| 569 | if (-1 NE ehdlist[et]) /* if it's a header ... */
|
---|
| 570 | eh_rmv(rp, ehdlist[et]); /* ... remove it from hplist */
|
---|
| 571 |
|
---|
| 572 | e_del(e_rmv(rp)); /* delete the event */
|
---|
| 573 | rp = lp; /* point at next event */
|
---|
| 574 | }
|
---|
| 575 |
|
---|
| 576 | seclist[curscor][ns] = E_NULL; /* delete section from seclist */
|
---|
| 577 | DB_EXIT("sec_rmv");
|
---|
| 578 | return(SUCCESS);
|
---|
| 579 | }
|
---|
| 580 |
|
---|
| 581 | /* |
---|
| 582 |
|
---|
| 583 | */
|
---|
[7258c6a] | 584 |
|
---|
[f40a309] | 585 | /*
|
---|
| 586 | =============================================================================
|
---|
| 587 | sec_dgr() --delete notes in enabled groups in section 'ns'
|
---|
| 588 |
|
---|
| 589 | ns section number to be processed
|
---|
| 590 |
|
---|
| 591 | returns SUCCESS or FAILURE
|
---|
| 592 | =============================================================================
|
---|
| 593 | */
|
---|
| 594 |
|
---|
| 595 | int16_t sec_dgr(int16_t ns)
|
---|
| 596 | {
|
---|
| 597 | register struct s_entry *lp, *rp;
|
---|
| 598 |
|
---|
| 599 | DB_ENTR("sec_dgr");
|
---|
| 600 |
|
---|
| 601 | secopok = TRUE;
|
---|
| 602 |
|
---|
| 603 | if (chksec(ns)) { /* check that section is OK */
|
---|
| 604 |
|
---|
| 605 | DB_EXIT("sec_dgr - FAILED chksec");
|
---|
| 606 | return(FAILURE);
|
---|
| 607 | }
|
---|
| 608 |
|
---|
| 609 | #if DEBUGIT
|
---|
| 610 | if (debugsw) {
|
---|
| 611 |
|
---|
| 612 | printf("sec_dgr: t_cur = %ld, t_sbgn = %ld, t_send = %ld, t_sect = %ld\n",
|
---|
| 613 | t_cur, t_sbgn, t_send, t_sect);
|
---|
| 614 |
|
---|
| 615 | printf("sec_dgr: p_cur = $%08lX, p_sbgn = $%08lX, p_send = $%08lX\n",
|
---|
| 616 | p_cur, p_sbgn, p_send);
|
---|
| 617 | }
|
---|
| 618 | #endif
|
---|
| 619 |
|
---|
| 620 | /* |
---|
| 621 |
|
---|
| 622 | */
|
---|
| 623 | /* delete note events for record enabled groups */
|
---|
| 624 |
|
---|
| 625 | DB_CMNT("sec_dgr - deleting");
|
---|
| 626 |
|
---|
| 627 | rp = p_sbgn->e_fwd; /* start at the beginning */
|
---|
| 628 |
|
---|
| 629 | while (rp NE p_send) {
|
---|
| 630 |
|
---|
| 631 | lp = rp->e_fwd; /* get next event pointer */
|
---|
| 632 |
|
---|
| 633 | if (oktodg(rp)) { /* if it's one we want ... */
|
---|
| 634 |
|
---|
| 635 | if (p_bak EQ rp) /* fix p_bak */
|
---|
| 636 | p_bak = lp;
|
---|
| 637 |
|
---|
| 638 | if (p_cur EQ rp) /* fix p_cur */
|
---|
| 639 | p_cur = lp;
|
---|
| 640 |
|
---|
| 641 | if (p_ctr EQ rp) /* fix p_ctr */
|
---|
| 642 | p_ctr = lp;
|
---|
| 643 |
|
---|
| 644 | if (p_fwd EQ rp) /* fix p_fwd */
|
---|
| 645 | p_fwd = lp;
|
---|
| 646 |
|
---|
| 647 | e_del(e_rmv(rp)); /* ... delete it */
|
---|
| 648 | }
|
---|
| 649 |
|
---|
| 650 | rp = lp; /* point at next event */
|
---|
| 651 | }
|
---|
| 652 |
|
---|
| 653 | DB_EXIT("sec_dgr");
|
---|
| 654 | return(SUCCESS);
|
---|
| 655 | }
|
---|
| 656 |
|
---|
| 657 | /* |
---|
[7258c6a] | 658 |
|
---|
[f40a309] | 659 | */
|
---|
| 660 |
|
---|
| 661 | /*
|
---|
| 662 | =============================================================================
|
---|
| 663 | sec_dev() --delete non-note events in enabled groups in section 'ns'
|
---|
| 664 |
|
---|
| 665 | ns section number to be processed
|
---|
| 666 |
|
---|
| 667 | returns SUCCESS or FAILURE
|
---|
| 668 | =============================================================================
|
---|
| 669 | */
|
---|
| 670 |
|
---|
| 671 | int16_t sec_dev(int16_t ns)
|
---|
| 672 | {
|
---|
| 673 | register struct s_entry *lp, *rp;
|
---|
| 674 |
|
---|
| 675 | DB_ENTR("sec_dev");
|
---|
| 676 |
|
---|
| 677 | secopok = TRUE;
|
---|
| 678 |
|
---|
| 679 | if (chksec(ns)) { /* check that section is OK */
|
---|
| 680 |
|
---|
| 681 | DB_EXIT("sec_dev - FAILED chksec");
|
---|
| 682 | return(FAILURE);
|
---|
| 683 | }
|
---|
| 684 |
|
---|
| 685 | #if DEBUGIT
|
---|
| 686 | if (debugsw) {
|
---|
| 687 |
|
---|
| 688 | printf("sec_dev: t_cur = %ld, t_sbgn = %ld, t_send = %ld, t_sect = %ld\n",
|
---|
| 689 | t_cur, t_sbgn, t_send, t_sect);
|
---|
| 690 |
|
---|
| 691 | printf("sec_dev: p_cur = $%08lX, p_sbgn = $%08lX, p_send = $%08lX\n",
|
---|
| 692 | p_cur, p_sbgn, p_send);
|
---|
| 693 | }
|
---|
| 694 | #endif
|
---|
| 695 |
|
---|
| 696 | /* |
---|
| 697 |
|
---|
| 698 | */
|
---|
| 699 | /* delete non-note events for record enabled groups */
|
---|
| 700 |
|
---|
| 701 | DB_CMNT("sec_dev - deleting");
|
---|
| 702 |
|
---|
| 703 | rp = p_sbgn->e_fwd; /* start at the beginning */
|
---|
| 704 |
|
---|
| 705 | while (rp NE p_send) {
|
---|
| 706 |
|
---|
| 707 | lp = rp->e_fwd; /* get next event pointer */
|
---|
| 708 |
|
---|
| 709 | if (oktode(rp)) { /* if it's one we want ... */
|
---|
| 710 |
|
---|
| 711 | if (p_bak EQ rp) /* fix p_bak */
|
---|
| 712 | p_bak = lp;
|
---|
| 713 |
|
---|
| 714 | if (p_cur EQ rp) /* fix p_cur */
|
---|
| 715 | p_cur = lp;
|
---|
| 716 |
|
---|
| 717 | if (p_ctr EQ rp) /* fix p_ctr */
|
---|
[6262b5c] | 718 | p_ctr = lp;
|
---|
| 719 |
|
---|
| 720 | if (p_fwd EQ rp) /* fix p_fwd */
|
---|
| 721 | p_fwd = lp;
|
---|
| 722 |
|
---|
| 723 | e_del(e_rmv(rp)); /* ... delete it */
|
---|
| 724 | }
|
---|
| 725 |
|
---|
| 726 | rp = lp; /* point at next event */
|
---|
| 727 | }
|
---|
| 728 |
|
---|
| 729 | DB_EXIT("sec_dev");
|
---|
| 730 | return(SUCCESS);
|
---|
| 731 | }
|
---|
| 732 |
|
---|