1 | /*
|
---|
2 | =============================================================================
|
---|
3 | nedacc.c -- MIDAS-VII note edit functions
|
---|
4 | Version 11 -- 1988-08-16 -- D.N. Lynx Crowe
|
---|
5 |
|
---|
6 | This file contains the note edit operations:
|
---|
7 |
|
---|
8 | NOP_ACC Begin Acc ned_acc()
|
---|
9 | NOP_NAT Begin Nat ned_nat()
|
---|
10 | NOP_END End Note ned_end()
|
---|
11 | NOP_MVN Move Note ned_mvn()
|
---|
12 | NOP_MVB Move Begin ned_mvb()
|
---|
13 | NOP_MVE Move End ned_mve()
|
---|
14 |
|
---|
15 | and some related support functions:
|
---|
16 |
|
---|
17 | accnote()
|
---|
18 | donote()
|
---|
19 | nedesub()
|
---|
20 | =============================================================================
|
---|
21 | */
|
---|
22 |
|
---|
23 | #undef DEBUGGER /* define to enable debug trace */
|
---|
24 | #define DEBUGIT 0
|
---|
25 |
|
---|
26 | #include "ram.h"
|
---|
27 |
|
---|
28 | /* |
---|
29 |
|
---|
30 | */
|
---|
31 |
|
---|
32 | /*
|
---|
33 | =============================================================================
|
---|
34 | accnote() -- return accidental note number or -1 for errors
|
---|
35 | =============================================================================
|
---|
36 | */
|
---|
37 |
|
---|
38 | int16_t accnote(void)
|
---|
39 | {
|
---|
40 | register int16_t rc;
|
---|
41 |
|
---|
42 | DB_ENTR("accnote");
|
---|
43 |
|
---|
44 | rc = -1;
|
---|
45 |
|
---|
46 | if ((ac_code EQ N_SHARP) AND cflag) {
|
---|
47 |
|
---|
48 | DB_CMNT("accnote - N_SHARP");
|
---|
49 | rc = cnote + 1;
|
---|
50 |
|
---|
51 | } else if ((ac_code EQ N_FLAT) AND cflag) {
|
---|
52 |
|
---|
53 | DB_CMNT("accnote - N_FLAT");
|
---|
54 | rc = cnote - 1;
|
---|
55 |
|
---|
56 | } else {
|
---|
57 |
|
---|
58 | DB_CMNT("accnote - no accidental possible");
|
---|
59 | }
|
---|
60 |
|
---|
61 | #if DEBUGIT
|
---|
62 | if (debugsw)
|
---|
63 | printf("accnote(): cnote = %d, ac_code = %d, cflag = %d, rc = %d\n",
|
---|
64 | cnote, ac_code, cflag, rc);
|
---|
65 | #endif
|
---|
66 | DB_EXIT("accnote");
|
---|
67 | return(rc);
|
---|
68 | }
|
---|
69 |
|
---|
70 | /* |
---|
71 |
|
---|
72 | */
|
---|
73 |
|
---|
74 | /*
|
---|
75 | =============================================================================
|
---|
76 | ned_acc() -- enter accidental note
|
---|
77 | =============================================================================
|
---|
78 | */
|
---|
79 |
|
---|
80 | int16_t ned_acc(int16_t grp)
|
---|
81 | {
|
---|
82 | register int16_t nn;
|
---|
83 | register struct n_entry *ep;
|
---|
84 |
|
---|
85 | DB_ENTR("ned_acc");
|
---|
86 |
|
---|
87 | if (-1 EQ (nn = accnote())) {
|
---|
88 |
|
---|
89 | DB_EXIT("ned_acc - accnote() failed");
|
---|
90 | return(FAILURE);
|
---|
91 | }
|
---|
92 |
|
---|
93 | if (E_NULL NE (ep = (struct n_entry *)e_alc(E_SIZE1))) {
|
---|
94 |
|
---|
95 | #if DEBUGIT
|
---|
96 | if (debugsw)
|
---|
97 | printf("ned_acc(): NBEG g=%d, n=%d, t=%ld, ep=$%08lX\n",
|
---|
98 | grp, nn, ctime, ep);
|
---|
99 | #endif
|
---|
100 | DB_CMNT("ned_acc - entering note begin");
|
---|
101 | ep->e_time = ctime;
|
---|
102 | ep->e_type = EV_NBEG;
|
---|
103 | ep->e_note = nn;
|
---|
104 | ep->e_group = grp;
|
---|
105 | ep->e_vel = SM_SCALE(64);
|
---|
106 | e_ins((struct s_entry *)ep, ep_adj(p_cur, 0, ctime));
|
---|
107 | noteop = NOP_END; /* setup for end of note */
|
---|
108 | DB_EXIT("ned_acc - note begin entered");
|
---|
109 | return(SUCCESS);
|
---|
110 | }
|
---|
111 |
|
---|
112 | noteop = NOP_NUL; /* clear pending operation code */
|
---|
113 | DB_EXIT("ned_acc - no space for note begin");
|
---|
114 | return(FAILURE);
|
---|
115 | }
|
---|
116 |
|
---|
117 | /* |
---|
118 |
|
---|
119 | */
|
---|
120 |
|
---|
121 | /*
|
---|
122 | =============================================================================
|
---|
123 | ned_nat() -- enter natural note
|
---|
124 | =============================================================================
|
---|
125 | */
|
---|
126 |
|
---|
127 | int16_t ned_nat(int16_t grp)
|
---|
128 | {
|
---|
129 | register struct n_entry *ep;
|
---|
130 |
|
---|
131 | DB_ENTR("ned_nat");
|
---|
132 |
|
---|
133 | if (E_NULL NE (ep = (struct n_entry *)e_alc(E_SIZE1))) {
|
---|
134 |
|
---|
135 | #if DEBUGIT
|
---|
136 | if (debugsw)
|
---|
137 | printf("ned_nat(): NBEG g=%d, n=%d, t=%ld, ep=$%08lX\n",
|
---|
138 | grp, cnote, ctime, ep);
|
---|
139 | #endif
|
---|
140 | DB_CMNT("ned_nat - entering note begin");
|
---|
141 | ep->e_time = ctime;
|
---|
142 | ep->e_type = EV_NBEG;
|
---|
143 | ep->e_note = cnote;
|
---|
144 | ep->e_group = grp;
|
---|
145 | ep->e_vel = SM_SCALE(64);
|
---|
146 | e_ins((struct s_entry *)ep, ep_adj(p_cur, 0, ctime));
|
---|
147 | noteop = NOP_END; /* set up for end of note */
|
---|
148 | DB_EXIT("ned_nat - note begin entered");
|
---|
149 | return(SUCCESS);
|
---|
150 | }
|
---|
151 |
|
---|
152 | noteop = NOP_NUL; /* clear pending operation code */
|
---|
153 | DB_EXIT("ned_nat - no space for note begin");
|
---|
154 | return(FAILURE);
|
---|
155 | }
|
---|
156 |
|
---|
157 | /* |
---|
158 |
|
---|
159 | */
|
---|
160 |
|
---|
161 | /*
|
---|
162 | =============================================================================
|
---|
163 | nedesub() -- enter note end subroutine
|
---|
164 |
|
---|
165 | Returns:
|
---|
166 |
|
---|
167 | -1 note end not entered - out of space
|
---|
168 | 0 note end entered OK
|
---|
169 | 1 note end not entered - no matching begin
|
---|
170 | =============================================================================
|
---|
171 | */
|
---|
172 |
|
---|
173 | int16_t nedesub(int16_t grp, int16_t note)
|
---|
174 | {
|
---|
175 | register struct s_entry *ep;
|
---|
176 | register struct n_entry *np;
|
---|
177 | register int16_t et;
|
---|
178 |
|
---|
179 | DB_ENTR("nedesub");
|
---|
180 |
|
---|
181 | ep = ep_adj(p_cur, 0, ctime);
|
---|
182 |
|
---|
183 | #if DEBUGIT
|
---|
184 | if (debugsw)
|
---|
185 | printf("nedesub(%d, %d): ctime=%ld, ep=$%08lX, t_cur=%ld, p_cur=$%08lX\n",
|
---|
186 | grp, note, ctime, ep, t_cur, p_cur);
|
---|
187 | #endif
|
---|
188 |
|
---|
189 | /* |
---|
190 |
|
---|
191 | */
|
---|
192 | DB_CMNT("nedesub - left scan");
|
---|
193 |
|
---|
194 | FOREVER { /* left scan */
|
---|
195 |
|
---|
196 | et = 0x007F & ep->e_type;
|
---|
197 |
|
---|
198 | switch (et) { /* dispatch off of event type */
|
---|
199 |
|
---|
200 | case EV_NEND: /* note end */
|
---|
201 |
|
---|
202 | if ((ep->e_data1 EQ note) AND
|
---|
203 | (ep->e_data2 EQ grp)) {
|
---|
204 |
|
---|
205 | DB_EXIT("nedesub - note end hit");
|
---|
206 | return(1);
|
---|
207 | } else
|
---|
208 | break;
|
---|
209 |
|
---|
210 | case EV_SCORE: /* score begin */
|
---|
211 |
|
---|
212 | DB_EXIT("nedesub - score begin hit");
|
---|
213 | return(1);
|
---|
214 |
|
---|
215 | case EV_NBEG: /* note begin */
|
---|
216 |
|
---|
217 | if ((ep->e_data1 EQ note) AND
|
---|
218 | (ep->e_data2 EQ grp)) { /* group and note match */
|
---|
219 |
|
---|
220 | ep = ep->e_fwd; /* setup for scan */
|
---|
221 | DB_CMNT("nedesub - NBEG nit - right scan");
|
---|
222 | /* |
---|
223 |
|
---|
224 | */
|
---|
225 | FOREVER { /* right scan */
|
---|
226 |
|
---|
227 | et = 0x007F & ep->e_type;
|
---|
228 |
|
---|
229 | switch (et) {
|
---|
230 |
|
---|
231 | case EV_NEND:
|
---|
232 |
|
---|
233 | if ((ep->e_data1 EQ note) AND
|
---|
234 | (ep->e_data2 EQ grp)) {
|
---|
235 |
|
---|
236 | DB_EXIT("nedesub - note end hit");
|
---|
237 | return(1);
|
---|
238 |
|
---|
239 | } else
|
---|
240 | break;
|
---|
241 | /* |
---|
242 |
|
---|
243 | */
|
---|
244 | case EV_NBEG:
|
---|
245 |
|
---|
246 | if ((ep->e_data1 EQ note) AND
|
---|
247 | (ep->e_data2 EQ grp)) {
|
---|
248 |
|
---|
249 | case EV_FINI:
|
---|
250 |
|
---|
251 | DB_CMNT("nedesub - note begin / fini hit");
|
---|
252 |
|
---|
253 | if (E_NULL NE (np = (struct n_entry *)e_alc(E_SIZE1))) {
|
---|
254 |
|
---|
255 | #if DEBUGIT
|
---|
256 | if (debugsw)
|
---|
257 | printf("nedesub(): note end entered - $%08lX t=%ld g=%d n=%d\n",
|
---|
258 | np, ctime, grp, note);
|
---|
259 | #endif
|
---|
260 | DB_CMNT("nedesub - entering note end");
|
---|
261 | np->e_time = ctime;
|
---|
262 | np->e_type = EV_NEND;
|
---|
263 | np->e_note = note;
|
---|
264 | np->e_group = grp;
|
---|
265 | np->e_vel = SM_SCALE(64);
|
---|
266 | e_ins((struct s_entry *)np, ep_adj(p_cur, 0, ctime));
|
---|
267 | DB_EXIT("nedesub - note end entered");
|
---|
268 | return(0);
|
---|
269 |
|
---|
270 | } else {
|
---|
271 |
|
---|
272 | DB_EXIT("nedesub - no space for note end");
|
---|
273 | return(-1);
|
---|
274 | }
|
---|
275 |
|
---|
276 | } /* end if */
|
---|
277 |
|
---|
278 | } /* end switch */
|
---|
279 |
|
---|
280 | ep = ep->e_fwd; /* point at next event */
|
---|
281 |
|
---|
282 | } /* end FOREVER - right scan */
|
---|
283 |
|
---|
284 | } /* end if */
|
---|
285 |
|
---|
286 | } /* end switch */
|
---|
287 |
|
---|
288 | ep = ep->e_bak; /* back up to previous event */
|
---|
289 |
|
---|
290 | } /* end FOREVER - left scan */
|
---|
291 | }
|
---|
292 |
|
---|
293 | /* |
---|
294 |
|
---|
295 | */
|
---|
296 |
|
---|
297 | /*
|
---|
298 | =============================================================================
|
---|
299 | ned_end() -- enter note end
|
---|
300 | =============================================================================
|
---|
301 | */
|
---|
302 |
|
---|
303 | int16_t ned_end(int16_t grp)
|
---|
304 | {
|
---|
305 | register int16_t rc;
|
---|
306 |
|
---|
307 | DB_ENTR("ned_end");
|
---|
308 |
|
---|
309 | #if DEBUGIT
|
---|
310 | if (debugsw)
|
---|
311 | printf("ned_end(): trying grp = %d, note = %d\n",
|
---|
312 | grp, cnote);
|
---|
313 | #endif
|
---|
314 | DB_CMNT("ned_end - trying natural");
|
---|
315 |
|
---|
316 | if (-1 EQ (rc = nedesub(grp, cnote))) { /* try for a natural */
|
---|
317 |
|
---|
318 | noteop = NOP_NUL; /* clear pending operation code */
|
---|
319 | DB_EXIT("ned_end - nedesub returned -1 (no space)");
|
---|
320 | return(FAILURE);
|
---|
321 |
|
---|
322 | } else if (0 EQ rc) {
|
---|
323 |
|
---|
324 | noteop = NOP_NUL; /* clear pending operation code */
|
---|
325 | DB_EXIT("ned_end - natural note end entered");
|
---|
326 | return(SUCCESS);
|
---|
327 |
|
---|
328 | } else if (1 NE rc) {
|
---|
329 |
|
---|
330 | #if DEBUGIT
|
---|
331 | if (debugsw)
|
---|
332 | printf("ned_end(): nedesub(%d, %d) returned %d\n",
|
---|
333 | grp, cnote + 1, rc);
|
---|
334 | #endif
|
---|
335 |
|
---|
336 | noteop = NOP_NUL; /* clear pending operation code */
|
---|
337 | DB_EXIT("ned_end - nedesub returned non-zero (unknown error)");
|
---|
338 | return(FAILURE);
|
---|
339 | }
|
---|
340 | /* |
---|
341 |
|
---|
342 | */
|
---|
343 | #if DEBUGIT
|
---|
344 | if (debugsw)
|
---|
345 | printf("ned_end(): trying grp = %d, note = %d\n",
|
---|
346 | grp, cnote + 1);
|
---|
347 | #endif
|
---|
348 |
|
---|
349 | DB_CMNT("ned_end - trying accidental");
|
---|
350 |
|
---|
351 | if (-1 EQ (rc = nedesub(grp, cnote + 1))) { /* try for an accidental */
|
---|
352 |
|
---|
353 | noteop = NOP_NUL; /* clear pending operation code */
|
---|
354 | DB_EXIT("ned_end - nedesub returned -1 (no space)");
|
---|
355 | return(FAILURE);
|
---|
356 |
|
---|
357 | } else if (1 EQ rc) {
|
---|
358 |
|
---|
359 | noteop = NOP_NUL; /* clear pending operation code */
|
---|
360 | DB_EXIT("ned_end - nedesub returned 1 (no match)");
|
---|
361 | return(FAILURE);
|
---|
362 |
|
---|
363 | } else if (0 NE rc) {
|
---|
364 |
|
---|
365 | #if DEBUGIT
|
---|
366 | if (debugsw)
|
---|
367 | printf("ned_end(): nedesub(%d, %d) returned %d\n",
|
---|
368 | grp, cnote + 1, rc);
|
---|
369 | #endif
|
---|
370 |
|
---|
371 | noteop = NOP_NUL; /* clear pending operation code */
|
---|
372 | DB_EXIT("ned_end - nedesub returned non-zero (unknown error)");
|
---|
373 | return(FAILURE);
|
---|
374 | }
|
---|
375 |
|
---|
376 | noteop = NOP_NUL; /* clear pending operation code */
|
---|
377 | DB_EXIT("ned_end - accidental note end entered");
|
---|
378 | return(SUCCESS);
|
---|
379 | }
|
---|
380 |
|
---|
381 | /* |
---|
382 |
|
---|
383 | */
|
---|
384 |
|
---|
385 | /*
|
---|
386 | =============================================================================
|
---|
387 | ned_mvn() -- move entire note
|
---|
388 | =============================================================================
|
---|
389 | */
|
---|
390 |
|
---|
391 | int16_t ned_mvn(int16_t grp)
|
---|
392 | {
|
---|
393 | register struct n_entry *bp, *ep;
|
---|
394 | register int16_t note;
|
---|
395 |
|
---|
396 | DB_ENTR("ned_mvn");
|
---|
397 |
|
---|
398 | if (notesel) { /* note selected -- now do the dirty work */
|
---|
399 |
|
---|
400 | bp = p_nbeg; /* point at note begin event */
|
---|
401 | ep = p_nend; /* point at note end event */
|
---|
402 |
|
---|
403 | /* clip out the note begin event */
|
---|
404 |
|
---|
405 | DB_CMNT("ned_mvn - clipping out begin");
|
---|
406 |
|
---|
407 | if (p_bak EQ bp)
|
---|
408 | p_bak = bp->e_fwd;
|
---|
409 |
|
---|
410 | if (p_ctr EQ bp)
|
---|
411 | p_ctr = bp->e_fwd;
|
---|
412 |
|
---|
413 | if (p_cur EQ bp)
|
---|
414 | p_cur = bp->e_fwd;
|
---|
415 |
|
---|
416 | if (p_fwd EQ bp)
|
---|
417 | p_fwd = bp->e_fwd;
|
---|
418 |
|
---|
419 | e_rmv((struct s_entry *)bp);
|
---|
420 | /* |
---|
421 |
|
---|
422 | */
|
---|
423 | /* clip out the note end event */
|
---|
424 |
|
---|
425 | DB_CMNT("ned_mvn - clipping out end");
|
---|
426 |
|
---|
427 | if (p_bak EQ ep)
|
---|
428 | p_bak = ep->e_fwd;
|
---|
429 |
|
---|
430 | if (p_ctr EQ ep)
|
---|
431 | p_ctr = ep->e_fwd;
|
---|
432 |
|
---|
433 | if (p_cur EQ ep)
|
---|
434 | p_cur = ep->e_fwd;
|
---|
435 |
|
---|
436 | if (p_fwd EQ ep)
|
---|
437 | p_fwd = ep->e_fwd;
|
---|
438 |
|
---|
439 | e_rmv((struct s_entry *)ep);
|
---|
440 |
|
---|
441 | bp->e_time = ctime; /* correct begin time */
|
---|
442 | ep->e_time = ctime + t_note; /* correct end time */
|
---|
443 |
|
---|
444 | /* re-insert the note */
|
---|
445 |
|
---|
446 | DB_CMNT("ned_mvn - re-inserting note");
|
---|
447 |
|
---|
448 | e_ins((struct s_entry *)bp, ep_adj(p_cur, 0, ctime));
|
---|
449 | e_ins((struct s_entry *)ep, ep_adj(p_cur, 0, ctime + t_note));
|
---|
450 |
|
---|
451 | notesel = FALSE; /* note not selected */
|
---|
452 | noteop = NOP_NUL; /* clear pending operation code */
|
---|
453 | DB_EXIT("ned_mvn - note moved");
|
---|
454 | return(SUCCESS);
|
---|
455 |
|
---|
456 | } else {
|
---|
457 |
|
---|
458 | if (E_NULL NE fcnote(grp, cnote)) {
|
---|
459 |
|
---|
460 | notesel = TRUE; /* note selected */
|
---|
461 | DB_EXIT("ned_mvn - natural selected");
|
---|
462 | return(FAILURE);
|
---|
463 |
|
---|
464 | } else if (-1 NE (note = accnote())) {
|
---|
465 |
|
---|
466 | if (E_NULL NE (bp = fcnote(grp, note))) {
|
---|
467 |
|
---|
468 | notesel = TRUE; /* note selected */
|
---|
469 | DB_EXIT("ned_mvn - accidental selected");
|
---|
470 | return(FAILURE);
|
---|
471 | }
|
---|
472 | }
|
---|
473 |
|
---|
474 | notesel = FALSE; /* note not selected */
|
---|
475 | noteop = NOP_NUL; /* clear pending operation code */
|
---|
476 | DB_EXIT("ned_mvn - uanble to find note");
|
---|
477 | return(FAILURE);
|
---|
478 | }
|
---|
479 | }
|
---|
480 |
|
---|
481 | /* |
---|
482 |
|
---|
483 | */
|
---|
484 |
|
---|
485 | /*
|
---|
486 | =============================================================================
|
---|
487 | ned_mvb() -- move beginning of note
|
---|
488 | =============================================================================
|
---|
489 | */
|
---|
490 |
|
---|
491 | int16_t ned_mvb(int16_t grp)
|
---|
492 | {
|
---|
493 | register struct n_entry *bp, *ep;
|
---|
494 | register int16_t note;
|
---|
495 |
|
---|
496 | DB_ENTR("ned_mvb");
|
---|
497 |
|
---|
498 | if (notesel) { /* note selected -- now do the dirty work */
|
---|
499 |
|
---|
500 | bp = p_nbeg; /* point at note begin event */
|
---|
501 | ep = p_nend; /* point at note end event */
|
---|
502 |
|
---|
503 | if (ctime GE ep->e_time) { /* check move point */
|
---|
504 |
|
---|
505 | noteop = NOP_NUL; /* clear pending operation */
|
---|
506 | notesel = FALSE; /* note not selected */
|
---|
507 | DB_EXIT("ned_mvb - move point after end");
|
---|
508 | return(FAILURE);
|
---|
509 | }
|
---|
510 |
|
---|
511 | /* clip out the note begin event */
|
---|
512 |
|
---|
513 | DB_CMNT("ned_mvb - clipping out begin");
|
---|
514 |
|
---|
515 | if (p_bak EQ bp)
|
---|
516 | p_bak = bp->e_fwd;
|
---|
517 |
|
---|
518 | if (p_ctr EQ bp)
|
---|
519 | p_ctr = bp->e_fwd;
|
---|
520 |
|
---|
521 | if (p_cur EQ bp)
|
---|
522 | p_cur = bp->e_fwd;
|
---|
523 |
|
---|
524 | if (p_fwd EQ bp)
|
---|
525 | p_fwd = bp->e_fwd;
|
---|
526 |
|
---|
527 | e_rmv((struct s_entry *)bp);
|
---|
528 |
|
---|
529 | bp->e_time = ctime; /* correct begin time */
|
---|
530 |
|
---|
531 | /* re-insert begin event */
|
---|
532 |
|
---|
533 | e_ins((struct s_entry *)bp, ep_adj(p_cur, 0, ctime));
|
---|
534 |
|
---|
535 | noteop = NOP_NUL; /* clear pending operation */
|
---|
536 | notesel = FALSE; /* note not selected */
|
---|
537 | DB_EXIT("ned_mvb - begin moved");
|
---|
538 | return(SUCCESS);
|
---|
539 | /* |
---|
540 |
|
---|
541 | */
|
---|
542 | } else {
|
---|
543 |
|
---|
544 | if (E_NULL NE fcnote(grp, cnote)) { /* natural ? */
|
---|
545 |
|
---|
546 | notesel = TRUE; /* note selected */
|
---|
547 | DB_EXIT("ned_mvb - natural selected");
|
---|
548 | return(FAILURE);
|
---|
549 |
|
---|
550 | } else if (-1 NE (note = accnote())) { /* accidental ? */
|
---|
551 |
|
---|
552 | if (E_NULL NE (bp = fcnote(grp, note))) {
|
---|
553 |
|
---|
554 | notesel = TRUE; /* note selected */
|
---|
555 | DB_EXIT("ned_mvb - accidental selected");
|
---|
556 | return(FAILURE);
|
---|
557 | }
|
---|
558 | }
|
---|
559 |
|
---|
560 | notesel = FALSE; /* note not selected */
|
---|
561 | noteop = NOP_NUL; /* clear pending operation code */
|
---|
562 | DB_EXIT("ned_mvb - unable to find note");
|
---|
563 | return(FAILURE);
|
---|
564 | }
|
---|
565 | }
|
---|
566 |
|
---|
567 | /* |
---|
568 |
|
---|
569 | */
|
---|
570 |
|
---|
571 | /*
|
---|
572 | =============================================================================
|
---|
573 | ned_mve() -- move end of note
|
---|
574 | =============================================================================
|
---|
575 | */
|
---|
576 |
|
---|
577 | int16_t ned_mve(int16_t grp)
|
---|
578 | {
|
---|
579 | register struct n_entry *bp, *ep;
|
---|
580 | register int16_t note;
|
---|
581 |
|
---|
582 | DB_ENTR("ned_mve");
|
---|
583 |
|
---|
584 | if (notesel) { /* note selected -- now do the dirty work */
|
---|
585 |
|
---|
586 | bp = p_nbeg; /* point at note begin event */
|
---|
587 | ep = p_nend; /* point at note end event */
|
---|
588 |
|
---|
589 | if (ctime LE bp->e_time) { /* check move point */
|
---|
590 |
|
---|
591 | noteop = NOP_NUL; /* clear pending operation */
|
---|
592 | notesel = FALSE; /* note not selected */
|
---|
593 | DB_EXIT("ned_mve - move point before begin");
|
---|
594 | return(FAILURE);
|
---|
595 | }
|
---|
596 |
|
---|
597 | /* clip out the note end event */
|
---|
598 |
|
---|
599 | DB_CMNT("ned_mve - clipping out end");
|
---|
600 |
|
---|
601 | if (p_bak EQ ep)
|
---|
602 | p_bak = ep->e_fwd;
|
---|
603 |
|
---|
604 | if (p_ctr EQ ep)
|
---|
605 | p_ctr = ep->e_fwd;
|
---|
606 |
|
---|
607 | if (p_cur EQ ep)
|
---|
608 | p_cur = ep->e_fwd;
|
---|
609 |
|
---|
610 | if (p_fwd EQ ep)
|
---|
611 | p_fwd = ep->e_fwd;
|
---|
612 |
|
---|
613 | e_rmv((struct s_entry *)ep);
|
---|
614 |
|
---|
615 | ep->e_time = ctime; /* correct end time */
|
---|
616 |
|
---|
617 | /* re-insert end event */
|
---|
618 |
|
---|
619 | e_ins((struct s_entry *)ep, ep_adj(p_cur, 0, ctime));
|
---|
620 |
|
---|
621 | noteop = NOP_NUL; /* clear pending operation */
|
---|
622 | notesel = FALSE; /* note not selected */
|
---|
623 | DB_EXIT("ned_mve - end moved");
|
---|
624 | return(SUCCESS);
|
---|
625 |
|
---|
626 | } else {
|
---|
627 |
|
---|
628 | if (E_NULL NE fcnote(grp, cnote)) { /* natural ? */
|
---|
629 |
|
---|
630 | notesel = TRUE; /* note selected */
|
---|
631 | DB_EXIT("ned_mve - natural selected");
|
---|
632 | return(FAILURE);
|
---|
633 |
|
---|
634 | } else if (-1 NE (note = accnote())) {
|
---|
635 |
|
---|
636 | if (E_NULL NE (bp = fcnote(grp, note))) { /* accidental ? */
|
---|
637 |
|
---|
638 | notesel = TRUE; /* note selected */
|
---|
639 | DB_EXIT("ned_mve - accidental selected");
|
---|
640 | return(FAILURE);
|
---|
641 | }
|
---|
642 | }
|
---|
643 |
|
---|
644 | notesel = FALSE; /* note not selected */
|
---|
645 | noteop = NOP_NUL; /* clear pending operation code */
|
---|
646 | DB_EXIT("ned_mve - unable to find note");
|
---|
647 | return(FAILURE);
|
---|
648 | }
|
---|
649 | }
|
---|
650 |
|
---|
651 | /* |
---|
652 |
|
---|
653 | */
|
---|
654 |
|
---|
655 | /*
|
---|
656 | =============================================================================
|
---|
657 | donote() -- do a note operation
|
---|
658 | =============================================================================
|
---|
659 | */
|
---|
660 |
|
---|
661 | void donote(void)
|
---|
662 | {
|
---|
663 | register int16_t grp, i, gs;
|
---|
664 |
|
---|
665 | DB_ENTR("donote");
|
---|
666 |
|
---|
667 | if (scmctl NE -1) { /* area 1 menu must be down */
|
---|
668 |
|
---|
669 | DB_EXIT("donote - scmctl NE -1");
|
---|
670 | return;
|
---|
671 | }
|
---|
672 |
|
---|
673 | if (NOT recsw) { /* must be in record mode */
|
---|
674 |
|
---|
675 | DB_EXIT("donote - not in record mode");
|
---|
676 | return;
|
---|
677 | }
|
---|
678 |
|
---|
679 | /* determine which group we want to work with */
|
---|
680 |
|
---|
681 | gs = 0;
|
---|
682 | grp = -1;
|
---|
683 |
|
---|
684 | for (i = 0; i < 12; i++) { /* scan the groups */
|
---|
685 |
|
---|
686 | if ((grpmode[i] EQ 2) AND grpstat[i]) {
|
---|
687 |
|
---|
688 | grp = i; /* log the group */
|
---|
689 | ++gs; /* count enabled groups */
|
---|
690 | #if DEBUGIT
|
---|
691 | if (debugsw)
|
---|
692 | printf("donote(): gs = %d, grp = %d\n", gs, grp);
|
---|
693 | #endif
|
---|
694 | }
|
---|
695 | }
|
---|
696 |
|
---|
697 | #if DEBUGIT
|
---|
698 | if (debugsw)
|
---|
699 | printf("donote(): final gs = %d, grp = %d\n", gs, grp);
|
---|
700 | #endif
|
---|
701 |
|
---|
702 | /* |
---|
703 |
|
---|
704 | */
|
---|
705 | if (gs NE 1) { /* must have a single group enabled */
|
---|
706 |
|
---|
707 | DB_EXIT("donote - no single group enabled");
|
---|
708 | return;
|
---|
709 | }
|
---|
710 |
|
---|
711 | if (pix2mid()) { /* must point at a note position */
|
---|
712 |
|
---|
713 | #if DEBUGIT
|
---|
714 | if (debugsw)
|
---|
715 | printf("donote(): no note at cxval = %d, cyval = %d\n",
|
---|
716 | cxval, cyval);
|
---|
717 | #endif
|
---|
718 | DB_EXIT("donote - not at a note position");
|
---|
719 | return;
|
---|
720 | }
|
---|
721 | /* |
---|
722 |
|
---|
723 | */
|
---|
724 | #if DEBUGIT
|
---|
725 | if (debugsw)
|
---|
726 | printf("donote(): at (cxval=%d, cyval=%d): cnote=%d, cflag=%d, ctime=%ld\n",
|
---|
727 | cxval, cyval, cnote, cflag, ctime);
|
---|
728 | #endif
|
---|
729 |
|
---|
730 | DB_CMNT("donote - dispatching");
|
---|
731 |
|
---|
732 | switch (noteop) { /* dispatch off of note operation code */
|
---|
733 |
|
---|
734 | case NOP_ACC: /* Begin Acc */
|
---|
735 |
|
---|
736 | if (ned_acc(grp))
|
---|
737 | break;
|
---|
738 |
|
---|
739 | sc_refr(fc_val); /* refresh screen if successful */
|
---|
740 | break;
|
---|
741 |
|
---|
742 | case NOP_NAT: /* Begin Nat */
|
---|
743 |
|
---|
744 | if (ned_nat(grp))
|
---|
745 | break;
|
---|
746 |
|
---|
747 | sc_refr(fc_val); /* refresh screen if successful */
|
---|
748 | break;
|
---|
749 |
|
---|
750 | case NOP_END: /* End Note */
|
---|
751 |
|
---|
752 | if (ned_end(grp))
|
---|
753 | break;
|
---|
754 |
|
---|
755 | sc_refr(fc_val); /* refresh screen if successful */
|
---|
756 | break;
|
---|
757 | /* |
---|
758 |
|
---|
759 | */
|
---|
760 | case NOP_MVN: /* Move Note */
|
---|
761 |
|
---|
762 | if (ned_mvn(grp))
|
---|
763 | break;
|
---|
764 |
|
---|
765 | sc_refr(fc_val); /* refresh screen if successful */
|
---|
766 | break;
|
---|
767 |
|
---|
768 | case NOP_MVB: /* Move Begin */
|
---|
769 |
|
---|
770 | if (ned_mvb(grp))
|
---|
771 | break;
|
---|
772 |
|
---|
773 | sc_refr(fc_val); /* refresh screen if successful */
|
---|
774 | break;
|
---|
775 |
|
---|
776 | case NOP_MVE: /* Move End */
|
---|
777 |
|
---|
778 | if (ned_mve(grp))
|
---|
779 | break;
|
---|
780 |
|
---|
781 | sc_refr(fc_val); /* refresh screen if successful */
|
---|
782 | break;
|
---|
783 |
|
---|
784 | default:
|
---|
785 |
|
---|
786 | DB_CMNT("donote - bad operation");
|
---|
787 | noteop = NOP_NUL; /* clear pending operation code */
|
---|
788 | }
|
---|
789 |
|
---|
790 | dnedmod(); /* update note edit window */
|
---|
791 | DB_EXIT("donote");
|
---|
792 | return;
|
---|
793 | }
|
---|
794 |
|
---|