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

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

Use standard integer types.

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