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