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

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

Added include files for global functions and variables.

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