source: buchla-68k/orig/RAM/SCGOTO.C@ c93e44d

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

Imported original source code.

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