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