source: buchla-68k/ram/scadv.c@ 28c0933

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

Fixed scadv.c.

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