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