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

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

Removed form-feed comments.

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