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

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

Added missing includes and declarations.

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