source: buchla-68k/ram/scgoto.c@ b28a12e

Last change on this file since b28a12e was b28a12e, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Zero redundant declarations.

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/*
2 =============================================================================
3 scgoto.c -- position display at a given frame time
4 Version 48 -- 1988-09-23 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define DEBUG_GO 0 /* define non-zero for sc_goto() debug */
9#define CHECKPTR 0 /* define non-zero to check pointers */
10
11#include "ram.h"
12
13/*
14
15*/
16
17/*
18 =============================================================================
19 sc_goto(tval) -- position score display at time 'tval'
20 =============================================================================
21*/
22
23int16_t sc_goto(int32_t tval)
24{
25 register struct gdsel *gdsp;
26 register struct s_entry *rp;
27 register int32_t tf, rt;
28 register int16_t mod48 = 48;
29
30#if CHECKPTR
31 Pcheck(p_fwd, "p_fwd - sc_goto entry");
32 Pcheck(p_ctr, "p_ctr - sc_goto entry");
33 Pcheck(p_bak, "p_bak - sc_goto entry");
34 Pcheck(p_cur, "p_cur - sc_goto entry");
35#endif
36
37 /* quick check of pointers so we don't crash */
38
39 if ((p_fwd EQ E_NULL) OR (p_cur EQ E_NULL) OR
40 (p_bak EQ E_NULL) OR (p_ctr EQ E_NULL))
41 return(FAILURE);
42
43 if (v_regs[5] & 0x0180) /* setup for VSDD bank 0 */
44 vbank(0);
45
46 sd = D_FWD; /* set display and scroll direction */
47 swctrl = FALSE; /* stop scroll wheel */
48 swflag = FALSE; /* ... */
49
50 recsw = FALSE; /* force play mode on goto */
51 dsrpmod(); /* update video and LCD displays */
52
53 if (ndisp EQ 2)
54 sreset(); /* reset highlighting if score is up */
55
56 quiet(-1, -1); /* quiet the instrument */
57 clrnl(); /* clear note entry lists */
58 clrsctl(); /* clear slice control data */
59
60 t_bak = tval - TO_BAK; /* set target time at p_bak */
61 t_fwd = t_bak; /* set target time at p_fwd */
62 t_ctr = tval; /* set target time at p_ctr */
63 t_cur = tval; /* set target time at p_cur */
64
65 p_bak = frfind(t_bak, 0); /* position p_bak at t_bak */
66 p_cur = frfind(t_cur, 1); /* position p_cur at t_cur */
67 p_fwd = frfind(t_fwd, 1); /* position p_fwd at t_fwd */
68
69/*
70
71*/
72 /* reset the display pointers to the target time */
73
74 if ((t_fwd LE 0) AND (p_fwd->e_type EQ EV_SCORE))
75 p_fwd = p_fwd->e_fwd; /* skip score header */
76
77 rp = p_fwd; /* current forward event pointer */
78 rt = t_fwd; /* current forward event time */
79 tf = tval + TO_FWD; /* target event time */
80
81#if DEBUG_GO
82 if (verbose) {
83
84 printf("## sc_goto(%8ld) ENTRY - tf: %8ld\n", tval, tf);
85
86 printf(" t_bak: %8ld t_ctr: %8ld t_fwd: %8ld t_cur: %8ld\n",
87 t_bak, t_ctr, t_fwd, t_cur);
88
89 printf(" p_bak: %08lX p_ctr: %08lX p_fwd: %08lX p_cur: %08lX\n",
90 p_bak, p_ctr, p_fwd, p_cur);
91 }
92#endif
93
94/*
95
96*/
97
98 while (rt++ LT tf) { /* advance p_fwd chain to tf */
99
100 if (rp->e_type NE EV_FINI) { /* don't pass end of score */
101
102 while (rp->e_time LE rt) { /* check event time */
103
104 if (ndisp EQ 2) /* display event */
105 se_disp(rp, D_FWD, gdstbn, 0);
106
107 rp = rp->e_fwd; /* point at next event */
108
109 if (rp->e_type EQ EV_FINI) /* done if at end */
110 break;
111 }
112 }
113
114 if (ndisp EQ 2) {
115
116 if (0 EQ (rt % mod48)) { /* handle beat markers */
117
118 if ((struct gdsel *)NULL NE (gdsp = gdfsep)) {
119
120 gdfsep = gdsp->next;
121
122 gdsp->next = gdstbn[12];
123 gdsp->note = 0x1111;
124 gdsp->code = 1;
125
126 gdstbn[12] = gdsp;
127 }
128 }
129
130 sc_adv(); /* scroll the display */
131 }
132 }
133
134 p_fwd = rp; /* update p_fwd for next event */
135 t_fwd = tf; /* update t_fwd */
136
137/*
138
139*/
140 /* execute & display things at current time to start things out right */
141
142 if (ndisp EQ 2) /* if score is up ... */
143 dssect(); /* display section */
144
145 rp = p_cur; /* current event pointer */
146 rt = t_cur; /* current event time */
147
148 if ((rt LE 0) AND (rp->e_type EQ EV_SCORE)) /* skip score header */
149 rp = rp->e_fwd;
150
151 if (rp->e_type NE EV_FINI) { /* if we aren't at end of score */
152
153 while (rp->e_time EQ rt) { /* do events at current time */
154
155 se_exec(rp, D_FWD); /* execute event */
156
157 if (ndisp EQ 2)
158 se_disp(rp, D_FWD, gdstbc, 1); /* update center slice */
159
160 rp = rp->e_fwd; /* point at next event */
161
162 if (rp->e_type EQ EV_FINI) /* done if at end */
163 break;
164 }
165 }
166
167 p_cur = rp; /* update p_cur */
168 p_ctr = rp; /* update p_ctr */
169
170 if (ndisp EQ 2) { /* if score is up ... */
171
172 scupd(); /* update event display */
173 sdwins(); /* refresh windows */
174 }
175
176/*
177
178*/
179
180#if DEBUG_GO
181 if (verbose) {
182
183 printf("## sc_goto(%8ld) EXIT\n");
184
185 printf(" t_bak: %8ld t_ctr: %8ld t_fwd: %8ld t_cur: %8ld\n",
186 t_bak, t_ctr, t_fwd, t_cur);
187
188 printf(" p_bak: %08lx p_ctr: %08lx p_fwd: %08lx p_cur: %08lx\n",
189 p_bak, p_ctr, p_fwd, p_cur);
190 }
191#endif
192
193#if CHECKPTR
194 Pcheck(p_fwd, "p_fwd - sc_goto exiting");
195 Pcheck(p_ctr, "p_ctr - sc_goto exiting");
196 Pcheck(p_bak, "p_bak - sc_goto exiting");
197 Pcheck(p_cur, "p_cur - sc_goto exiting");
198#endif
199
200 return(SUCCESS);
201}
202
203/*
204
205*/
206
207/*
208 =============================================================================
209 sc_refr() -- refresh the display to a particular time
210 =============================================================================
211*/
212
213int16_t sc_refr(int32_t t)
214{
215 int16_t oldrs, rc;
216
217 oldrs = recsw; /* save recsw */
218 rc = sc_goto(t); /* refresh the display via a goto */
219 recsw = oldrs; /* restore recsw */
220 dsrpmod(); /* update display of recsw */
221 return(rc); /* return status from sc_goto */
222}
223
Note: See TracBrowser for help on using the repository browser.