1 | /*
|
---|
2 | =============================================================================
|
---|
3 | scadv.c -- MIDAS-VII -- move score 1 frame forward or backward
|
---|
4 | Version 48 -- 1989-12-19 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #undef DEBUGGER /* define to enable debug trace */
|
---|
9 |
|
---|
10 | #undef TRACEIT /* define to enable step by step trace */
|
---|
11 |
|
---|
12 | #include "debug.h"
|
---|
13 |
|
---|
14 | #include "stddefs.h"
|
---|
15 | #include "hwdefs.h"
|
---|
16 | #include "graphdef.h"
|
---|
17 | #include "score.h"
|
---|
18 | #include "vsdd.h"
|
---|
19 |
|
---|
20 | #include "midas.h"
|
---|
21 | #include "scdsp.h"
|
---|
22 |
|
---|
23 | #ifdef TRACEIT
|
---|
24 | short tracesw;
|
---|
25 | #endif
|
---|
26 |
|
---|
27 | /* variables defined elsewhere */
|
---|
28 |
|
---|
29 | extern unsigned *consl;
|
---|
30 | extern unsigned *cursl;
|
---|
31 | extern unsigned *nxtsl;
|
---|
32 | extern unsigned *prvsl;
|
---|
33 | extern unsigned *saddr;
|
---|
34 |
|
---|
35 | extern unsigned scrl;
|
---|
36 | extern unsigned vi_sadr;
|
---|
37 | extern unsigned vi_scrl;
|
---|
38 |
|
---|
39 | extern short ctrsw;
|
---|
40 | extern short ndisp;
|
---|
41 | extern short sbase;
|
---|
42 | extern short sd;
|
---|
43 | extern short soffset;
|
---|
44 |
|
---|
45 | extern struct gdsel *gdstbc[];
|
---|
46 | extern struct gdsel *gdstbn[];
|
---|
47 | extern struct gdsel *gdstbp[];
|
---|
48 |
|
---|
49 | /* |
---|
50 |
|
---|
51 | */
|
---|
52 |
|
---|
53 | /* initialized stuff */
|
---|
54 |
|
---|
55 | short nbmoff = 3;
|
---|
56 | short wrdoff = 3;
|
---|
57 |
|
---|
58 | short nbmasks[4] = { /* nybble masks */
|
---|
59 |
|
---|
60 | 0x000F,
|
---|
61 | 0x00F0,
|
---|
62 | 0x0F00,
|
---|
63 | 0xF000
|
---|
64 | };
|
---|
65 |
|
---|
66 | /* |
---|
67 |
|
---|
68 | */
|
---|
69 |
|
---|
70 | /*
|
---|
71 | =============================================================================
|
---|
72 | sc_adv() -- advance the score display 1 frame
|
---|
73 |
|
---|
74 | Note that the score display actually only moves every other frame,
|
---|
75 | due to VSDD limitations, but it moves 2 pixels.
|
---|
76 | =============================================================================
|
---|
77 | */
|
---|
78 |
|
---|
79 | sc_adv()
|
---|
80 | {
|
---|
81 | register short masksl, maskpx, i;
|
---|
82 | register unsigned sword;
|
---|
83 | register long tl;
|
---|
84 | register unsigned *optr, *pptr, *fsl;
|
---|
85 | unsigned *qptr;
|
---|
86 | unsigned pscrl;
|
---|
87 |
|
---|
88 | DB_ENTR("sc_adv");
|
---|
89 |
|
---|
90 | #ifdef TRACEIT
|
---|
91 | if (tracesw) {
|
---|
92 |
|
---|
93 | printf("scadv ----------------------\n");
|
---|
94 | SEctrl();
|
---|
95 | }
|
---|
96 |
|
---|
97 | if (tracesw & 0x0001) {
|
---|
98 |
|
---|
99 | SCslice();
|
---|
100 | }
|
---|
101 | #endif
|
---|
102 |
|
---|
103 | if (v_regs[5] & 0x0180) /* make sure we're in bank 0 */
|
---|
104 | vbank(0);
|
---|
105 |
|
---|
106 | tl = 128L; /* setup VSDD line increment */
|
---|
107 |
|
---|
108 | DB_CMNT("sc_adv - center ucslice");
|
---|
109 |
|
---|
110 | ucslice(); /* update the center slice */
|
---|
111 |
|
---|
112 | /* |
---|
113 |
|
---|
114 | */
|
---|
115 | /* see if it's time to update VRAM from edges */
|
---|
116 |
|
---|
117 | if ((ndisp EQ 2) AND (soffset EQ ((sd EQ D_BAK) ? 0 : 3))) {
|
---|
118 |
|
---|
119 | if (sd EQ D_BAK) { /* set source and target pointers */
|
---|
120 |
|
---|
121 | fsl = prvsl;
|
---|
122 | optr = saddr + wrdoff;
|
---|
123 |
|
---|
124 | } else {
|
---|
125 |
|
---|
126 | fsl = nxtsl;
|
---|
127 | optr = saddr + tl;
|
---|
128 | }
|
---|
129 |
|
---|
130 | if (sbase > 28544) { /* possible double update ? */
|
---|
131 |
|
---|
132 | /* set target pointer #2 */
|
---|
133 |
|
---|
134 | pptr = saddr - ((sd EQ D_BAK) ? 28542L : 28545L);
|
---|
135 |
|
---|
136 | if (sbase < 28672) { /* double update - right and left */
|
---|
137 |
|
---|
138 | DB_CMNT("sc_adv - double update");
|
---|
139 |
|
---|
140 | for (i = 224; i--; ) {
|
---|
141 |
|
---|
142 | sword = *fsl++; /* copy a slice word to the VSDD */
|
---|
143 | *optr = sword;
|
---|
144 | *pptr = sword;
|
---|
145 | optr += tl; /* advance the VSDD pointers */
|
---|
146 | pptr += tl;
|
---|
147 | }
|
---|
148 |
|
---|
149 | } else { /* single update - left */
|
---|
150 |
|
---|
151 | DB_CMNT("sc_adv - left update");
|
---|
152 |
|
---|
153 | for (i = 224; i--; ) {
|
---|
154 |
|
---|
155 | *pptr = *fsl++; /* copy a slice word to the VSDD */
|
---|
156 | pptr += tl; /* advance the VSDD pointers */
|
---|
157 | }
|
---|
158 | }
|
---|
159 | /* |
---|
160 |
|
---|
161 | */
|
---|
162 | } else { /* single update - right */
|
---|
163 |
|
---|
164 | DB_CMNT("sc_adv - right update");
|
---|
165 |
|
---|
166 | for (i = 224; i--; ) {
|
---|
167 |
|
---|
168 | *optr = *fsl++; /* copy a slice word to the VSDD */
|
---|
169 | optr += tl; /* advance the VSDD pointers */
|
---|
170 | }
|
---|
171 | }
|
---|
172 |
|
---|
173 | optr = nxtsl; /* refresh update slices from constant slice */
|
---|
174 | pptr = cursl;
|
---|
175 | qptr = prvsl;
|
---|
176 | fsl = consl;
|
---|
177 |
|
---|
178 | for (i = 224; i--; ) {
|
---|
179 |
|
---|
180 | sword = *fsl++;
|
---|
181 | *optr++ = sword;
|
---|
182 | *pptr++ = sword;
|
---|
183 | *qptr++ = sword;
|
---|
184 | }
|
---|
185 |
|
---|
186 | DB_CMNT("sc_adv - slices refreshed");
|
---|
187 | }
|
---|
188 |
|
---|
189 | /* |
---|
190 |
|
---|
191 | */
|
---|
192 | if (sd EQ D_FWD) {
|
---|
193 |
|
---|
194 | if (++soffset > 3) { /* advance scroll counter */
|
---|
195 |
|
---|
196 | soffset = 0; /* roll over scroll counter */
|
---|
197 | ++saddr; /* advance VRAM address */
|
---|
198 |
|
---|
199 | if (++sbase > 28672) { /* advance scroll offset */
|
---|
200 |
|
---|
201 | saddr = v_score; /* roll over VRAM address */
|
---|
202 | sbase = 0; /* roll over scroll offset */
|
---|
203 | }
|
---|
204 | }
|
---|
205 |
|
---|
206 | } else {
|
---|
207 |
|
---|
208 | if (--soffset < 0) { /* decrement scroll counter */
|
---|
209 |
|
---|
210 | soffset = 3; /* roll over scroll counter */
|
---|
211 | --saddr; /* advance VRAM address */
|
---|
212 |
|
---|
213 | if (--sbase < 0) { /* advance scroll offset */
|
---|
214 |
|
---|
215 | saddr = v_score + 28672L; /* roll over VRAM address */
|
---|
216 | sbase = 28672; /* roll over scroll offset */
|
---|
217 | }
|
---|
218 | }
|
---|
219 | }
|
---|
220 | /* |
---|
221 |
|
---|
222 | */
|
---|
223 | pscrl = scrl; /* save old scrl value */
|
---|
224 |
|
---|
225 | DB_CMNT("sc_adv - edge uslice");
|
---|
226 |
|
---|
227 | maskpx = nbmasks[soffset]; /* setup source pixel mask */
|
---|
228 | masksl = ~maskpx; /* setup target pixel mask */
|
---|
229 |
|
---|
230 | uslice(prvsl, maskpx, masksl, gdstbp); /* update left edge */
|
---|
231 |
|
---|
232 | uslice(nxtsl, maskpx, masksl, gdstbn); /* update right edge */
|
---|
233 |
|
---|
234 | scrl = 0x8000 | ((soffset >> 1) ^ 0x0001);
|
---|
235 |
|
---|
236 | /* only update VSDD registers if score is up and scrl changed */
|
---|
237 |
|
---|
238 | if ((ndisp EQ 2) AND (scrl NE pscrl)) {
|
---|
239 |
|
---|
240 | sword = (unsigned)((long)saddr >> 1);
|
---|
241 |
|
---|
242 | setipl(VID_DI); /* disable video interrupts */
|
---|
243 |
|
---|
244 | vi_scrl = scrl;
|
---|
245 | vi_sadr = sword;
|
---|
246 |
|
---|
247 | setipl(VID_EI); /* enable video interrupts */
|
---|
248 | }
|
---|
249 |
|
---|
250 | ctrsw = FALSE;
|
---|
251 |
|
---|
252 | #ifdef TRACEIT
|
---|
253 | if (tracesw & 0x0002) {
|
---|
254 |
|
---|
255 | SCslice();
|
---|
256 | }
|
---|
257 | #endif
|
---|
258 |
|
---|
259 | DB_EXIT("sc_adv");
|
---|
260 | }
|
---|
261 |
|
---|
262 | /* |
---|
263 |
|
---|
264 | */
|
---|
265 |
|
---|
266 | /*
|
---|
267 | =============================================================================
|
---|
268 | scupd() -- update the center slice without scrolling
|
---|
269 | =============================================================================
|
---|
270 | */
|
---|
271 |
|
---|
272 | scupd()
|
---|
273 | {
|
---|
274 | register short masksl, maskpx, i;
|
---|
275 | register unsigned sword;
|
---|
276 | register long tl;
|
---|
277 | register unsigned *optr, *qptr, *fsl;
|
---|
278 | short soff;
|
---|
279 |
|
---|
280 | DB_ENTR("scupd");
|
---|
281 |
|
---|
282 | if (v_regs[5] & 0x0180) /* make sure we're in bank 0 */
|
---|
283 | vbank(0);
|
---|
284 |
|
---|
285 | soff = (nbmoff + soffset) & 3; /* calculate offset to use */
|
---|
286 | maskpx = nbmasks[(2 + soff) & 3]; /* setup source pixel mask */
|
---|
287 | masksl = ~maskpx; /* setup target pixel mask */
|
---|
288 | tl = 128L; /* setup VSDD line increment */
|
---|
289 |
|
---|
290 | /* update VRAM, if it's time */
|
---|
291 |
|
---|
292 | if (cslice(cursl, maskpx, masksl, gdstbc) AND (ndisp EQ 2)) {
|
---|
293 |
|
---|
294 | DB_CMNT("scupd - center write ...");
|
---|
295 |
|
---|
296 | fsl = cursl;
|
---|
297 | optr = saddr + ((soff > 1) ? 64L : 63L);
|
---|
298 | qptr = consl;
|
---|
299 |
|
---|
300 | for (i = 224; i--; ) {
|
---|
301 |
|
---|
302 | if (sword = maskpx & *fsl)
|
---|
303 | *optr = (*optr & masksl) | sword;
|
---|
304 |
|
---|
305 | *fsl++ = *qptr++; /* clean up the slice */
|
---|
306 | optr += tl;
|
---|
307 | }
|
---|
308 |
|
---|
309 | DB_CMNT("scupd - center written");
|
---|
310 | }
|
---|
311 |
|
---|
312 | ctrsw = FALSE;
|
---|
313 | }
|
---|