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