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