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