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