1 | /*
|
---|
2 | =============================================================================
|
---|
3 | fcnote.c -- MIDAS-VII note edit -- find complete note
|
---|
4 | Version 1 -- 1988-05-17 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include "all.h"
|
---|
9 |
|
---|
10 | #define TO_LFT (TO_BAK + 1)
|
---|
11 |
|
---|
12 | extern int32_t ctime; /* time at cursor */
|
---|
13 |
|
---|
14 | /*
|
---|
15 | =============================================================================
|
---|
16 | fcnote() -- find complete note
|
---|
17 |
|
---|
18 | Arguments:
|
---|
19 |
|
---|
20 | grp group number
|
---|
21 | tnote note number
|
---|
22 |
|
---|
23 | ctime cursor time to search from
|
---|
24 |
|
---|
25 | Returns:
|
---|
26 |
|
---|
27 | E_NULL couldn't find the note
|
---|
28 | ptr pointer to the begin event for the note
|
---|
29 |
|
---|
30 | p_nbeg pointer to note begin event
|
---|
31 | p_nend pointer to note end event
|
---|
32 | t_note duration of the note
|
---|
33 | =============================================================================
|
---|
34 | */
|
---|
35 |
|
---|
36 | /* |
---|
37 |
|
---|
38 | */
|
---|
39 |
|
---|
40 | struct n_entry *fcnote(int16_t grp, int16_t tnote)
|
---|
41 | {
|
---|
42 | register struct n_entry *bp, *ep;
|
---|
43 | register int16_t en, eg, et;
|
---|
44 | int32_t t_left;
|
---|
45 |
|
---|
46 | /* setup initial search parameters */
|
---|
47 |
|
---|
48 | bp = (struct n_entry *)ep_adj(p_cur, 0, ctime); /* cursor loc */
|
---|
49 | t_left = t_cur - TO_LFT; /* time at left edge of screen */
|
---|
50 | p_nbeg = (struct n_entry *)E_NULL; /* no begin yet */
|
---|
51 | p_nend = (struct n_entry *)E_NULL; /* no end yet */
|
---|
52 | t_note = 0L; /* no duration yet */
|
---|
53 |
|
---|
54 | FOREVER { /* scan left from cursor */
|
---|
55 |
|
---|
56 | et = 0x007F & bp->e_type;
|
---|
57 | en = bp->e_note;
|
---|
58 | eg = bp->e_group;
|
---|
59 |
|
---|
60 | if ((bp->e_time LT t_left) OR (et EQ EV_SCORE)) {
|
---|
61 |
|
---|
62 | /* done -- can't see begin, or note not there */
|
---|
63 |
|
---|
64 | return(E_NULL);
|
---|
65 |
|
---|
66 | } else if ((et EQ EV_NEND) AND (en EQ tnote) AND (eg EQ grp)) {
|
---|
67 |
|
---|
68 | /* done -- hit note end first -- notes overlap */
|
---|
69 |
|
---|
70 | return(E_NULL);
|
---|
71 | /* |
---|
72 |
|
---|
73 | */
|
---|
74 | } else if ((et EQ EV_NBEG) AND (en EQ tnote) AND (eg EQ grp)) {
|
---|
75 |
|
---|
76 | /* found note begin -- possible note starting at bp */
|
---|
77 |
|
---|
78 | ep = bp->e_fwd; /* scan to right of begin */
|
---|
79 |
|
---|
80 | FOREVER { /* scan right from note begin */
|
---|
81 |
|
---|
82 | et = 0x007F & ep->e_type; /* event type */
|
---|
83 | en = ep->e_note; /* note */
|
---|
84 | eg = ep->e_group; /* group */
|
---|
85 |
|
---|
86 | if ((et EQ EV_NBEG) AND (en EQ tnote) AND
|
---|
87 | (eg EQ grp)) {
|
---|
88 |
|
---|
89 | /* hit note begin first -- done -- notes overlap */
|
---|
90 |
|
---|
91 | return(E_NULL);
|
---|
92 | /* |
---|
93 |
|
---|
94 | */
|
---|
95 | } else if ((et EQ EV_NEND) AND (en EQ tnote) AND
|
---|
96 | (eg EQ grp)) {
|
---|
97 |
|
---|
98 | /* hit note end -- done -- found complete note */
|
---|
99 |
|
---|
100 | p_nbeg = bp; /* note begin */
|
---|
101 | p_nend = ep; /* note end */
|
---|
102 | t_note = ep->e_time - bp->e_time;
|
---|
103 | return(bp);
|
---|
104 |
|
---|
105 | } else if (et EQ EV_FINI) {
|
---|
106 |
|
---|
107 | /* hit score end -- done -- can't find end */
|
---|
108 |
|
---|
109 | return(E_NULL);
|
---|
110 | }
|
---|
111 |
|
---|
112 | ep = ep->e_fwd; /* scan right */
|
---|
113 |
|
---|
114 | } /* end FOREVER */
|
---|
115 |
|
---|
116 | } /* end if */
|
---|
117 |
|
---|
118 | bp = bp->e_bak; /* scan left */
|
---|
119 |
|
---|
120 | } /* end FOREVER */
|
---|
121 | }
|
---|
122 |
|
---|