SpriteScreen.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13: package xeij;
14:
15: import java.lang.*;
16: import java.util.*;
17:
18: public class SpriteScreen {
19:
20:
21: public static final int SPR_REG0_BG0_X = 0x00eb0800;
22: public static final int SPR_REG1_BG0_Y = 0x00eb0802;
23: public static final int SPR_REG2_BG1_X = 0x00eb0804;
24: public static final int SPR_REG3_BG1_Y = 0x00eb0806;
25: public static final int SPR_REG4_BG_CTRL = 0x00eb0808;
26:
27: public static final int SPR_MPUCS = 0x0400;
28: public static final int SPR_DISP = 0x0200;
29: public static final int SPR_B1CS = 0x0020;
30: public static final int SPR_B1TX = 0x0010;
31: public static final int SPR_B1ON = 0x0008;
32: public static final int SPR_B0CS = 0x0004;
33: public static final int SPR_B0TX = 0x0002;
34: public static final int SPR_B0ON = 0x0001;
35: public static boolean sprMpucs;
36: public static boolean sprDisp;
37: public static int sprB1tx;
38: public static boolean sprB1on;
39: public static int sprB0tx;
40: public static boolean sprB0on;
41:
42: public static final int SPR_REG5_H_FRONT_END = 0x00eb080a;
43: public static final int SPR_REG6_H_BACK_END = 0x00eb080c;
44: public static final int SPR_REG7_V_BACK_END = 0x00eb080e;
45: public static final int SPR_REG8_RESO = 0x00eb0810;
46:
47:
48:
49:
50:
51: public static final int SPR_REG9_BANK_CONTROL = 0x00eb0812;
52: public static final int SPR_REG10_BANK_SELECT = 0x00eb0814;
53:
54:
55:
56: public static int sprReg0Bg0XPort;
57: public static int sprReg0Bg0XMask;
58: public static int sprReg0Bg0XTest;
59: public static int sprReg0Bg0XCurr;
60: public static int sprReg1Bg0YPort;
61: public static int sprReg1Bg0YMask;
62: public static int sprReg1Bg0YTest;
63: public static int sprReg1Bg0YCurr;
64: public static int sprReg2Bg1XPort;
65: public static int sprReg2Bg1XMask;
66: public static int sprReg2Bg1XTest;
67: public static int sprReg2Bg1XCurr;
68: public static int sprReg3Bg1YPort;
69: public static int sprReg3Bg1YMask;
70: public static int sprReg3Bg1YTest;
71: public static int sprReg3Bg1YCurr;
72: public static int sprReg4BgCtrlPort;
73: public static int sprReg4BgCtrlMask;
74: public static int sprReg4BgCtrlTest;
75: public static int sprReg4BgCtrlCurr;
76: public static int sprReg5HFrontEndPort;
77: public static int sprReg5HFrontEndMask;
78: public static int sprReg5HFrontEndTest;
79: public static int sprReg5HFrontEndCurr;
80: public static int sprReg6HBackEndPort;
81: public static int sprReg6HBackEndMask;
82: public static int sprReg6HBackEndTest;
83: public static int sprReg6HBackEndCurr;
84: public static int sprReg7VBackEndPort;
85: public static int sprReg7VBackEndMask;
86: public static int sprReg7VBackEndTest;
87: public static int sprReg7VBackEndCurr;
88: public static int sprReg8ResoPort;
89: public static int sprReg8ResoMask;
90: public static int sprReg8ResoTest;
91: public static int sprReg8ResoCurr;
92:
93:
94: public static final int SPR_SHIFT = 10;
95: public static final int SPR_COUNT = 1 << SPR_SHIFT;
96: public static final short[] sprX = new short[SPR_COUNT];
97: public static final short[] sprY = new short[SPR_COUNT];
98: public static final short[] sprNumPort = new short[SPR_COUNT];
99: public static final short[] sprColPort = new short[SPR_COUNT];
100: public static final byte[] sprPrw = new byte[SPR_COUNT];
101: public static final boolean[] sprH = new boolean[SPR_COUNT];
102: public static final boolean[] sprV = new boolean[SPR_COUNT];
103: public static final boolean[] sprSPCS = new boolean[SPR_COUNT];
104:
105:
106:
107:
108:
109:
110:
111: public static final int[] sprRRmap = new int[1039 << (SPR_SHIFT - 5)];
112:
113:
114:
115:
116: public static final int[] sprPatPort = new int[32 * 4096];
117:
118:
119:
120:
121: public static final int[] sprPPmap = new int[4096 << (SPR_SHIFT - 5)];
122:
123:
124: public static final short[] sprTNum = new short[4096 * 4];
125: public static final short[] sprTColPort = new short[4096 * 4];
126: public static final boolean[] sprTH = new boolean[4096 * 4];
127: public static final boolean[] sprTV = new boolean[4096 * 4];
128:
129: public static final boolean SPR_THREE_STEPS = true;
130: public static int[] sprBuffer;
131: public static int[] sprShadowBuffer;
132:
133:
134:
135:
136:
137:
138:
139: public static boolean sprLatched;
140: public static boolean sprActive;
141:
142:
143: public static final boolean SPR_PATTEST_ON = true;
144: public static final int[] sprPatTest = new int[32 * 4096];
145: public static int[] sprPatCurr;
146: public static final short[] sprNumTest = new short[SPR_COUNT];
147: public static short[] sprNumCurr;
148: public static final short[] sprColTest = new short[SPR_COUNT];
149: public static short[] sprColCurr;
150: public static final short[] sprTColTest = new short[4096 * 4];
151: public static short[] sprTColCurr;
152:
153:
154: public static int sprSpritesPerRaster;
155:
156:
157: public static int sprNumberOfSpritesRequest;
158: public static int sprNumberOfSprites;
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230: public static boolean sprBankOnRequest;
231: public static boolean sprBankOn;
232: public static int sprBankMode;
233: public static boolean sprBankShifted;
234: public static int sprBankNumber;
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245: public static boolean spr768x512Request;
246: public static boolean spr768x512;
247: public static boolean sprAccessible;
248:
249:
250:
251:
252: public static boolean spr512bg1Request;
253: public static boolean spr512bg1;
254:
255:
256: public static final long SPR_WAIT_PATTERN_DISP_0 = XEiJ.TMR_FREQ * 215L / 1000000000L;
257: public static final long SPR_WAIT_SPRITE_DISP_0 = XEiJ.TMR_FREQ * 275L / 1000000000L;
258: public static final long SPR_WAIT_SPRITE_DISP_1 = XEiJ.TMR_FREQ * 400L / 1000000000L;
259: public static final long SPR_WAIT_PATTERN_DISP_1 = XEiJ.TMR_FREQ * 465L / 1000000000L;
260: public static long sprWaitSprite;
261: public static long sprWaitPattern;
262:
263:
264:
265:
266: public static final boolean SPR_RC_SCROLL_ON = true;
267: public static boolean sprRcScrollRequest;
268: public static boolean sprRcScrollOn;
269: public static final int[] sprRowScroll = new int[64 * 4];
270: public static final int[] sprColScroll = new int[64 * 4];
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283: public static boolean sprFPMRequest;
284: public static boolean sprFPM;
285:
286:
287:
288: public static void sprInit () {
289: sprReg0Bg0XPort = 0;
290: sprReg0Bg0XMask = 0;
291: sprReg0Bg0XTest = 0;
292: sprReg0Bg0XCurr = 0;
293: sprReg1Bg0YPort = 0;
294: sprReg1Bg0YMask = 0;
295: sprReg1Bg0YTest = 0;
296: sprReg1Bg0YCurr = 0;
297: sprReg2Bg1XPort = 0;
298: sprReg2Bg1XMask = 0;
299: sprReg2Bg1XTest = 0;
300: sprReg2Bg1XCurr = 0;
301: sprReg3Bg1YPort = 0;
302: sprReg3Bg1YMask = 0;
303: sprReg3Bg1YTest = 0;
304: sprReg3Bg1YCurr = 0;
305: sprReg4BgCtrlPort = 0;
306: sprReg4BgCtrlMask = 0;
307: sprReg4BgCtrlTest = 0;
308: sprReg4BgCtrlCurr = 0;
309: sprMpucs = false;
310: sprDisp = false;
311: sprB1tx = 0;
312: sprB1on = false;
313: sprB0tx = 0;
314: sprB0on = false;
315: sprReg5HFrontEndPort = 0;
316: sprReg5HFrontEndMask = 0;
317: sprReg5HFrontEndTest = 0;
318: sprReg5HFrontEndCurr = 0;
319: sprReg6HBackEndPort = 0;
320: sprReg6HBackEndMask = 0;
321: sprReg6HBackEndTest = 0;
322: sprReg6HBackEndCurr = 0;
323: sprReg7VBackEndPort = 0;
324: sprReg7VBackEndMask = 0;
325: sprReg7VBackEndTest = 0;
326: sprReg7VBackEndCurr = 0;
327: sprReg8ResoPort = 0;
328: sprReg8ResoMask = 0;
329: sprReg8ResoTest = 0;
330: sprReg8ResoCurr = 0;
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346: if (SPR_THREE_STEPS) {
347: sprBuffer = new int[1056 * 3];
348: sprShadowBuffer = new int[1056 * 3];
349: }
350:
351:
352:
353: if (SPR_PATTEST_ON) {
354:
355:
356: Arrays.fill (sprPatTest, 0x00000000);
357: for (int i = 0; i < 4 * 4096; i++) {
358:
359: if ((i & 3) == 0) {
360: sprPatTest[8 * i ] = 0b1111 * 0x11000000;
361: sprPatTest[8 * i + 1] = 0b1111 * 0x10000000;
362: } else if ((i & 3) == 1) {
363: sprPatTest[8 * i ] = 0b1111 * 0x10000000;
364: sprPatTest[8 * i + 1] = 0b1111 * 0x11000000;
365: } else if ((i & 3) == 2) {
366: sprPatTest[8 * i ] = 0b1111 * 0x11000000;
367: sprPatTest[8 * i + 1] = 0b1111 * 0x01000000;
368: } else {
369: sprPatTest[8 * i ] = 0b1111 * 0x01000000;
370: sprPatTest[8 * i + 1] = 0b1111 * 0x11000000;
371: }
372: if (4 <= i) {
373:
374: int t = i >> (2 + 8);
375: if (t != 0) {
376: t = Indicator.IND_ASCII_3X5[(((9 - t) >> 4) & ('A' - '0' - 10)) + '0' + t];
377: sprPatTest[8 * i ] |= 0b1010 * VideoController.VCN_TXP0[((t >> (12 - 4)) & 0b00010000) |
378: ((t >> ( 9 - 3)) & 0b00001000) |
379: ((t >> ( 6 - 2)) & 0b00000100) |
380: ((t >> ( 3 - 1)) & 0b00000010) |
381: ((t >> ( 0 - 0)) & 0b00000001)];
382: sprPatTest[8 * i + 1] |= 0b1010 * VideoController.VCN_TXP0[((t >> (13 - 4)) & 0b00010000) |
383: ((t >> (10 - 3)) & 0b00001000) |
384: ((t >> ( 7 - 2)) & 0b00000100) |
385: ((t >> ( 4 - 1)) & 0b00000010) |
386: ((t >> ( 1 - 0)) & 0b00000001)];
387: sprPatTest[8 * i + 2] |= 0b1010 * VideoController.VCN_TXP0[((t >> (14 - 4)) & 0b00010000) |
388: ((t >> (11 - 3)) & 0b00001000) |
389: ((t >> ( 8 - 2)) & 0b00000100) |
390: ((t >> ( 5 - 1)) & 0b00000010) |
391: ((t >> ( 2 - 0)) & 0b00000001)];
392: }
393:
394: t = (i >> (2 + 4)) & 15;
395: t = Indicator.IND_ASCII_3X5[(((9 - t) >> 4) & ('A' - '0' - 10)) + '0' + t];
396: sprPatTest[8 * i + 3] = 0b1100 * VideoController.VCN_TXP0[(t >> (12 - 5)) & 0b11100000];
397: sprPatTest[8 * i + 4] = 0b1100 * VideoController.VCN_TXP0[(t >> ( 9 - 5)) & 0b11100000];
398: sprPatTest[8 * i + 5] = 0b1100 * VideoController.VCN_TXP0[(t >> ( 6 - 5)) & 0b11100000];
399: sprPatTest[8 * i + 6] = 0b1100 * VideoController.VCN_TXP0[(t << ( 5 - 3)) & 0b11100000];
400: sprPatTest[8 * i + 7] = 0b1100 * VideoController.VCN_TXP0[(t << ( 5 - 0)) & 0b11100000];
401:
402: t = (i >> 2) & 15;
403: t = Indicator.IND_ASCII_3X5[(((9 - t) >> 4) & ('A' - '0' - 10)) + '0' + t];
404: sprPatTest[8 * i + 3] |= 0b1001 * VideoController.VCN_TXP0[(t >> (12 - 1)) & 0b00001110];
405: sprPatTest[8 * i + 4] |= 0b1001 * VideoController.VCN_TXP0[(t >> ( 9 - 1)) & 0b00001110];
406: sprPatTest[8 * i + 5] |= 0b1001 * VideoController.VCN_TXP0[(t >> ( 6 - 1)) & 0b00001110];
407: sprPatTest[8 * i + 6] |= 0b1001 * VideoController.VCN_TXP0[(t >> ( 3 - 1)) & 0b00001110];
408: sprPatTest[8 * i + 7] |= 0b1001 * VideoController.VCN_TXP0[(t << ( 1 - 0)) & 0b00001110];
409: }
410: }
411:
412:
413: for (int i = 0; i < SPR_COUNT; i++) {
414: sprNumTest[i] = (short) i;
415: }
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433: for (int i = 0; i < SPR_COUNT; i++) {
434: sprColTest[i] = (short) ((i < 64 ? 1 + (i >> 4) :
435: i < 128 ? 3 + (i >> 5) :
436: i < 256 ? 5 + (i >> 6) :
437: i < 512 ? 7 + (i >> 7) :
438: 11) << 4);
439: }
440:
441: for (int i = 0; i < 4; i++) {
442: Arrays.fill (sprTColTest,
443: 4096 * i,
444: 4096 * (i + 1),
445: (short) ((12 + i) << 4));
446: }
447: }
448: sprPatCurr = sprPatPort;
449: sprNumCurr = sprNumPort;
450: sprColCurr = sprColPort;
451: sprTColCurr = sprTColPort;
452:
453:
454: sprSpritesPerRaster = Math.max (0, Math.min (1016, Settings.sgsGetInt ("sprras")));
455:
456:
457: {
458: int n = Settings.sgsGetInt ("numspr");
459: n = (n == 128 || n == 256 ? n :
460: n == 504 || n == 1016 ? n + 8 :
461: 128);
462: if (n == 128 && Settings.sgsGetOnOff ("dblspr")) {
463: n = 256;
464: }
465: sprNumberOfSpritesRequest = n;
466: }
467:
468:
469: sprBankOnRequest = Settings.sgsGetOnOff ("sprbank");
470:
471:
472: spr768x512Request = Settings.sgsGetOnOff ("spr768x512");
473:
474:
475: spr512bg1Request = Settings.sgsGetOnOff ("spr512bg1");
476:
477:
478: sprWaitSprite = SPR_WAIT_SPRITE_DISP_0;
479: sprWaitPattern = SPR_WAIT_PATTERN_DISP_0;
480:
481: if (SPR_RC_SCROLL_ON) {
482:
483: sprRcScrollRequest = Settings.sgsGetOnOff ("sprrcscroll");
484:
485:
486: }
487:
488:
489: sprFPMRequest = Settings.sgsGetOnOff ("sprfpm");
490:
491: sprReset ();
492: }
493:
494: public static void sprTini () {
495:
496: Settings.sgsPutInt ("sprras", sprSpritesPerRaster);
497:
498: Settings.sgsPutOnOff ("dblspr", false);
499: Settings.sgsPutInt ("numspr", sprNumberOfSpritesRequest <= 256 ? sprNumberOfSpritesRequest : sprNumberOfSpritesRequest - 8);
500:
501: Settings.sgsPutOnOff ("sprbank", sprBankOnRequest);
502:
503: Settings.sgsPutOnOff ("spr768x512", spr768x512Request);
504:
505: Settings.sgsPutOnOff ("spr512bg1", spr512bg1Request);
506: if (SPR_RC_SCROLL_ON) {
507:
508: Settings.sgsPutOnOff ("sprrcscroll", sprRcScrollRequest);
509: }
510:
511: Settings.sgsPutOnOff ("sprfpm", sprFPMRequest);
512: }
513:
514:
515:
516: public static void sprReset () {
517:
518: sprNumberOfSprites = sprNumberOfSpritesRequest;
519:
520: sprBankOn = sprBankOnRequest;
521: sprBankMode = 0;
522: sprBankShifted = false;
523: sprBankNumber = (0 << 8);
524:
525: spr768x512 = spr768x512Request;
526: sprAccessible = spr768x512;
527:
528: spr512bg1 = spr512bg1Request;
529: if (SPR_RC_SCROLL_ON) {
530:
531: sprRcScrollOn = sprRcScrollRequest;
532: Arrays.fill (sprRowScroll, 0);
533: Arrays.fill (sprColScroll, 0);
534: }
535:
536: sprFPM = sprFPMRequest;
537:
538: Arrays.fill (sprX, (short) 0);
539: Arrays.fill (sprY, (short) 0);
540: Arrays.fill (sprNumPort, (short) 0);
541: Arrays.fill (sprColPort, (short) 0);
542: Arrays.fill (sprPrw, (byte) 0);
543: Arrays.fill (sprH, false);
544: Arrays.fill (sprV, false);
545: Arrays.fill (sprSPCS, false);
546: Arrays.fill (sprRRmap, 0);
547: if (sprBankOn) {
548:
549: Arrays.fill (sprPatPort, 0x00000000);
550: } else if (sprFPM) {
551:
552: Arrays.fill (sprPatPort, 0, 8192 * 2, 0x00000000);
553:
554: Arrays.fill (sprPatPort, 8192 * 2, 8192 * 16, 0xffffffff);
555: } else {
556:
557: Arrays.fill (sprPatPort, 0, 8192 * 1, 0x00000000);
558:
559: Arrays.fill (sprPatPort, 8192 * 1, 8192 * 16, 0xffffffff);
560: }
561: Arrays.fill (sprPPmap, 0);
562: if (sprFPM) {
563:
564: Arrays.fill (sprTNum, (short) (0x00 << 3));
565: Arrays.fill (sprTColPort, (short) (0x0 << 4));
566: Arrays.fill (sprTH, false);
567: Arrays.fill (sprTV, false);
568: } else {
569:
570: Arrays.fill (sprTNum, 0, 4096 * 2, (short) (0x00 << 3));
571: Arrays.fill (sprTColPort, 0, 4096 * 2, (short) (0x0 << 4));
572: Arrays.fill (sprTH, 0, 4096 * 2, false);
573: Arrays.fill (sprTV, 0, 4096 * 2, false);
574:
575: Arrays.fill (sprTNum, 4096 * 2, 4096 * 4, (short) (0xff << 3));
576: Arrays.fill (sprTColPort, 4096 * 2, 4096 * 4, (short) (0xf << 4));
577: Arrays.fill (sprTH, 4096 * 2, 4096 * 4, true);
578: Arrays.fill (sprTV, 4096 * 2, 4096 * 4, true);
579: }
580: }
581:
582:
583:
584:
585:
586:
587:
588:
589:
590:
591:
592:
593:
594:
595:
596:
597:
598:
599:
600:
601:
602:
603:
604:
605:
606:
607:
608:
609:
610:
611:
612:
613:
614:
615:
616:
617:
618:
619:
620:
621:
622:
623:
624:
625:
626:
627:
628:
629:
630:
631:
632:
633:
634:
635:
636:
637:
638:
639:
640:
641:
642:
643:
644:
645:
646:
647:
648:
649:
650:
651:
652:
653:
654:
655:
656:
657:
658:
659:
660:
661:
662:
663:
664: public static void sprSwap () {
665: int[] t = sprBuffer;
666: sprBuffer = sprShadowBuffer;
667: sprShadowBuffer = t;
668: }
669:
670:
671:
672:
673:
674:
675:
676:
677:
678:
679:
680:
681:
682:
683:
684: public static void sprStep1 (int src) {
685:
686:
687: Arrays.fill (sprBuffer, 0);
688:
689: src += sprReg7VBackEndCurr - CRTC.crtR06VBackEndCurr;
690: if (src < 0 || 1023 < src) {
691: return;
692: }
693:
694: int hStart = (sprReg6HBackEndCurr - CRTC.crtR02HBackEndCurr - 4) << 3;
695: int width16 = 16 + XEiJ.pnlScreenWidth;
696:
697: int cnt = sprSpritesPerRaster;
698: if (cnt == 0) {
699: return;
700: }
701: for (int i = (16 + src) << (SPR_SHIFT - 5), nn = 0; nn < sprNumberOfSprites; nn += 32) {
702: for (int map = sprRRmap[i++], n = nn; map != 0; map <<= 1, n++) {
703: if (0 <= map) {
704: continue;
705: }
706: int x = hStart + sprX[n];
707: if (x <= 0 || width16 <= x) {
708:
709: if (--cnt == 0) {
710: return;
711: }
712: continue;
713: }
714:
715:
716:
717:
718:
719:
720:
721: int a = (sprNumCurr[n] << 5) + (sprV[n] ? sprY[n] - src - 1 : 16 + src - sprY[n]);
722: int prw = sprPrw[n] << 3;
723: int col = sprColCurr[n] << prw >>> 4;
724: if (sprSPCS[n]) {
725: a = ((1 << 8) << 5) + (a & (((1 << 8) << 5) - 1));
726: }
727: int s, t;
728: if ((t = sprPatCurr[a]) != 0) {
729: if (sprH[n]) {
730: if ((s = 15 & t) != 0 && sprBuffer[2112 + 8 + x] >>> prw == 0) {
731: sprBuffer[2112 + 8 + x] = s << prw;
732: sprBuffer[1056 + 8 + x] = col;
733: }
734: if ((s = 15 << 4 & t) != 0 && sprBuffer[2112 + 9 + x] >>> prw == 0) {
735: sprBuffer[2112 + 9 + x] = s >>> 4 << prw;
736: sprBuffer[1056 + 9 + x] = col;
737: }
738: if ((s = 15 << 8 & t) != 0 && sprBuffer[2112 + 10 + x] >>> prw == 0) {
739: sprBuffer[2112 + 10 + x] = s >>> 8 << prw;
740: sprBuffer[1056 + 10 + x] = col;
741: }
742: if ((s = 15 << 12 & t) != 0 && sprBuffer[2112 + 11 + x] >>> prw == 0) {
743: sprBuffer[2112 + 11 + x] = s >>> 12 << prw;
744: sprBuffer[1056 + 11 + x] = col;
745: }
746: if ((s = 15 << 16 & t) != 0 && sprBuffer[2112 + 12 + x] >>> prw == 0) {
747: sprBuffer[2112 + 12 + x] = s >>> 16 << prw;
748: sprBuffer[1056 + 12 + x] = col;
749: }
750: if ((s = 15 << 20 & t) != 0 && sprBuffer[2112 + 13 + x] >>> prw == 0) {
751: sprBuffer[2112 + 13 + x] = s >>> 20 << prw;
752: sprBuffer[1056 + 13 + x] = col;
753: }
754: if ((s = 15 << 24 & t) != 0 && sprBuffer[2112 + 14 + x] >>> prw == 0) {
755: sprBuffer[2112 + 14 + x] = s >>> 24 << prw;
756: sprBuffer[1056 + 14 + x] = col;
757: }
758: if ((s = t >>> 28 ) != 0 && sprBuffer[2112 + 15 + x] >>> prw == 0) {
759: sprBuffer[2112 + 15 + x] = s << prw;
760: sprBuffer[1056 + 15 + x] = col;
761: }
762: } else {
763: if ((s = t >>> 28 ) != 0 && sprBuffer[2112 + x] >>> prw == 0) {
764: sprBuffer[2112 + x] = s << prw;
765: sprBuffer[1056 + x] = col;
766: }
767: if ((s = 15 << 24 & t) != 0 && sprBuffer[2112 + 1 + x] >>> prw == 0) {
768: sprBuffer[2112 + 1 + x] = s >>> 24 << prw;
769: sprBuffer[1056 + 1 + x] = col;
770: }
771: if ((s = 15 << 20 & t) != 0 && sprBuffer[2112 + 2 + x] >>> prw == 0) {
772: sprBuffer[2112 + 2 + x] = s >>> 20 << prw;
773: sprBuffer[1056 + 2 + x] = col;
774: }
775: if ((s = 15 << 16 & t) != 0 && sprBuffer[2112 + 3 + x] >>> prw == 0) {
776: sprBuffer[2112 + 3 + x] = s >>> 16 << prw;
777: sprBuffer[1056 + 3 + x] = col;
778: }
779: if ((s = 15 << 12 & t) != 0 && sprBuffer[2112 + 4 + x] >>> prw == 0) {
780: sprBuffer[2112 + 4 + x] = s >>> 12 << prw;
781: sprBuffer[1056 + 4 + x] = col;
782: }
783: if ((s = 15 << 8 & t) != 0 && sprBuffer[2112 + 5 + x] >>> prw == 0) {
784: sprBuffer[2112 + 5 + x] = s >>> 8 << prw;
785: sprBuffer[1056 + 5 + x] = col;
786: }
787: if ((s = 15 << 4 & t) != 0 && sprBuffer[2112 + 6 + x] >>> prw == 0) {
788: sprBuffer[2112 + 6 + x] = s >>> 4 << prw;
789: sprBuffer[1056 + 6 + x] = col;
790: }
791: if ((s = 15 & t) != 0 && sprBuffer[2112 + 7 + x] >>> prw == 0) {
792: sprBuffer[2112 + 7 + x] = s << prw;
793: sprBuffer[1056 + 7 + x] = col;
794: }
795: }
796: }
797: if ((t = sprPatCurr[16 + a]) != 0) {
798: if (sprH[n]) {
799: if ((s = 15 & t) != 0 && sprBuffer[2112 + x] >>> prw == 0) {
800: sprBuffer[2112 + x] = s << prw;
801: sprBuffer[1056 + x] = col;
802: }
803: if ((s = 15 << 4 & t) != 0 && sprBuffer[2112 + 1 + x] >>> prw == 0) {
804: sprBuffer[2112 + 1 + x] = s >>> 4 << prw;
805: sprBuffer[1056 + 1 + x] = col;
806: }
807: if ((s = 15 << 8 & t) != 0 && sprBuffer[2112 + 2 + x] >>> prw == 0) {
808: sprBuffer[2112 + 2 + x] = s >>> 8 << prw;
809: sprBuffer[1056 + 2 + x] = col;
810: }
811: if ((s = 15 << 12 & t) != 0 && sprBuffer[2112 + 3 + x] >>> prw == 0) {
812: sprBuffer[2112 + 3 + x] = s >>> 12 << prw;
813: sprBuffer[1056 + 3 + x] = col;
814: }
815: if ((s = 15 << 16 & t) != 0 && sprBuffer[2112 + 4 + x] >>> prw == 0) {
816: sprBuffer[2112 + 4 + x] = s >>> 16 << prw;
817: sprBuffer[1056 + 4 + x] = col;
818: }
819: if ((s = 15 << 20 & t) != 0 && sprBuffer[2112 + 5 + x] >>> prw == 0) {
820: sprBuffer[2112 + 5 + x] = s >>> 20 << prw;
821: sprBuffer[1056 + 5 + x] = col;
822: }
823: if ((s = 15 << 24 & t) != 0 && sprBuffer[2112 + 6 + x] >>> prw == 0) {
824: sprBuffer[2112 + 6 + x] = s >>> 24 << prw;
825: sprBuffer[1056 + 6 + x] = col;
826: }
827: if ((s = t >>> 28 ) != 0 && sprBuffer[2112 + 7 + x] >>> prw == 0) {
828: sprBuffer[2112 + 7 + x] = s << prw;
829: sprBuffer[1056 + 7 + x] = col;
830: }
831: } else {
832: if ((s = t >>> 28 ) != 0 && sprBuffer[2112 + 8 + x] >>> prw == 0) {
833: sprBuffer[2112 + 8 + x] = s << prw;
834: sprBuffer[1056 + 8 + x] = col;
835: }
836: if ((s = 15 << 24 & t) != 0 && sprBuffer[2112 + 9 + x] >>> prw == 0) {
837: sprBuffer[2112 + 9 + x] = s >>> 24 << prw;
838: sprBuffer[1056 + 9 + x] = col;
839: }
840: if ((s = 15 << 20 & t) != 0 && sprBuffer[2112 + 10 + x] >>> prw == 0) {
841: sprBuffer[2112 + 10 + x] = s >>> 20 << prw;
842: sprBuffer[1056 + 10 + x] = col;
843: }
844: if ((s = 15 << 16 & t) != 0 && sprBuffer[2112 + 11 + x] >>> prw == 0) {
845: sprBuffer[2112 + 11 + x] = s >>> 16 << prw;
846: sprBuffer[1056 + 11 + x] = col;
847: }
848: if ((s = 15 << 12 & t) != 0 && sprBuffer[2112 + 12 + x] >>> prw == 0) {
849: sprBuffer[2112 + 12 + x] = s >>> 12 << prw;
850: sprBuffer[1056 + 12 + x] = col;
851: }
852: if ((s = 15 << 8 & t) != 0 && sprBuffer[2112 + 13 + x] >>> prw == 0) {
853: sprBuffer[2112 + 13 + x] = s >>> 8 << prw;
854: sprBuffer[1056 + 13 + x] = col;
855: }
856: if ((s = 15 << 4 & t) != 0 && sprBuffer[2112 + 14 + x] >>> prw == 0) {
857: sprBuffer[2112 + 14 + x] = s >>> 4 << prw;
858: sprBuffer[1056 + 14 + x] = col;
859: }
860: if ((s = 15 & t) != 0 && sprBuffer[2112 + 15 + x] >>> prw == 0) {
861: sprBuffer[2112 + 15 + x] = s << prw;
862: sprBuffer[1056 + 15 + x] = col;
863: }
864: }
865: }
866: if (--cnt == 0) {
867: return;
868: }
869: }
870: }
871: }
872:
873:
874:
875:
876:
877:
878:
879:
880:
881:
882:
883:
884:
885:
886:
887: public static void sprStep2 (int src) {
888:
889: src += sprReg7VBackEndCurr - CRTC.crtR06VBackEndCurr;
890: if (src < 0 || 1023 < src) {
891: return;
892: }
893:
894: int hStart = (sprReg6HBackEndCurr - CRTC.crtR02HBackEndCurr - 4) << 3;
895: int width16 = 16 + XEiJ.pnlScreenWidth;
896: if ((sprReg8ResoCurr & 3) == 0) {
897: final short[] tnum = sprTNum, tcol = sprTColCurr;
898: final boolean[] th = sprTH, tv = sprTV;
899: int x, y = 0, sx, sy = 0, y0 = 0;
900:
901:
902: int ofst = sprB0tx;
903: if (SPR_RC_SCROLL_ON && sprRcScrollOn) {
904: y0 = (src + sprReg1Bg0YCurr) & 511;
905: x = 16 + hStart - sprReg0Bg0XCurr - sprRowScroll[y0 >> 3];
906: sx = (((x & 7) - x) >> 3) & 63;
907: x &= 7;
908: } else {
909: x = 16 + hStart - sprReg0Bg0XCurr;
910: y = (src + sprReg1Bg0YCurr) & 511;
911: sx = (((x & 7) - x) >> 3) & 63;
912: sy = ofst + ((y >> 3) << 6);
913: x &= 7;
914: y &= 7;
915: }
916: while (x < width16) {
917: if (SPR_RC_SCROLL_ON && sprRcScrollOn) {
918: y = (y0 + sprColScroll[sx]) & 511;
919: sy = ofst + ((y >> 3) << 6);
920: y &= 7;
921: }
922: int t;
923: if ((t = sprPatCurr[tnum[sy + sx] + (tv[sy + sx] ? 7 - y : y)]) != 0) {
924: if (th[sy + sx]) {
925: sprBuffer[2112 + x] |= (t & 15) << 20;
926: sprBuffer[2112 + 1 + x] |= (t >>> 4 & 15) << 20;
927: sprBuffer[2112 + 2 + x] |= (t >>> 8 & 15) << 20;
928: sprBuffer[2112 + 3 + x] |= (t >>> 12 & 15) << 20;
929: sprBuffer[2112 + 4 + x] |= (t >>> 16 & 15) << 20;
930: sprBuffer[2112 + 5 + x] |= (t >>> 20 & 15) << 20;
931: sprBuffer[2112 + 6 + x] |= (t >>> 24 & 15) << 20;
932: sprBuffer[2112 + 7 + x] |= (t >>> 28 ) << 20;
933: } else {
934: sprBuffer[2112 + x] |= (t >>> 28 ) << 20;
935: sprBuffer[2112 + 1 + x] |= (t >>> 24 & 15) << 20;
936: sprBuffer[2112 + 2 + x] |= (t >>> 20 & 15) << 20;
937: sprBuffer[2112 + 3 + x] |= (t >>> 16 & 15) << 20;
938: sprBuffer[2112 + 4 + x] |= (t >>> 12 & 15) << 20;
939: sprBuffer[2112 + 5 + x] |= (t >>> 8 & 15) << 20;
940: sprBuffer[2112 + 6 + x] |= (t >>> 4 & 15) << 20;
941: sprBuffer[2112 + 7 + x] |= (t & 15) << 20;
942: }
943: }
944: if ((t = tcol[sy + sx]) != 0) {
945: t <<= 20 - 4;
946: sprBuffer[1056 + x] |= t;
947: sprBuffer[1056 + 1 + x] |= t;
948: sprBuffer[1056 + 2 + x] |= t;
949: sprBuffer[1056 + 3 + x] |= t;
950: sprBuffer[1056 + 4 + x] |= t;
951: sprBuffer[1056 + 5 + x] |= t;
952: sprBuffer[1056 + 6 + x] |= t;
953: sprBuffer[1056 + 7 + x] |= t;
954: }
955: x += 8;
956: sx = (sx + 1) & 63;
957: }
958:
959:
960: ofst = sprB1tx;
961: if (SPR_RC_SCROLL_ON && sprRcScrollOn) {
962: y0 = (src + sprReg3Bg1YCurr) & 511;
963: x = 16 + hStart - sprReg2Bg1XCurr - sprRowScroll[64 * 1 + (y0 >> 3)];
964: sx = (((x & 7) - x) >> 3) & 63;
965: x &= 7;
966: } else {
967: x = 16 + hStart - sprReg2Bg1XCurr;
968: y = (src + sprReg3Bg1YCurr) & 511;
969: sx = (((x & 7) - x) >> 3) & 63;
970: sy = ofst + ((y >> 3) << 6);
971: x &= 7;
972: y &= 7;
973: }
974: while (x < width16) {
975: if (SPR_RC_SCROLL_ON && sprRcScrollOn) {
976: y = (y0 + sprColScroll[64 * 1 + sx]) & 511;
977: sy = ofst + ((y >> 3) << 6);
978: y &= 7;
979: }
980: int t;
981: if ((t = sprPatCurr[tnum[sy + sx] + (tv[sy + sx] ? 7 - y : y)]) != 0) {
982: if (th[sy + sx]) {
983: sprBuffer[2112 + x] |= (t & 15) << 12;
984: sprBuffer[2112 + 1 + x] |= (t >>> 4 & 15) << 12;
985: sprBuffer[2112 + 2 + x] |= (t >>> 8 & 15) << 12;
986: sprBuffer[2112 + 3 + x] |= (t >>> 12 & 15) << 12;
987: sprBuffer[2112 + 4 + x] |= (t >>> 16 & 15) << 12;
988: sprBuffer[2112 + 5 + x] |= (t >>> 20 & 15) << 12;
989: sprBuffer[2112 + 6 + x] |= (t >>> 24 & 15) << 12;
990: sprBuffer[2112 + 7 + x] |= (t >>> 28 ) << 12;
991: } else {
992: sprBuffer[2112 + x] |= (t >>> 28 ) << 12;
993: sprBuffer[2112 + 1 + x] |= (t >>> 24 & 15) << 12;
994: sprBuffer[2112 + 2 + x] |= (t >>> 20 & 15) << 12;
995: sprBuffer[2112 + 3 + x] |= (t >>> 16 & 15) << 12;
996: sprBuffer[2112 + 4 + x] |= (t >>> 12 & 15) << 12;
997: sprBuffer[2112 + 5 + x] |= (t >>> 8 & 15) << 12;
998: sprBuffer[2112 + 6 + x] |= (t >>> 4 & 15) << 12;
999: sprBuffer[2112 + 7 + x] |= (t & 15) << 12;
1000: }
1001: }
1002: if ((t = tcol[sy + sx]) != 0) {
1003: t <<= 12 - 4;
1004: sprBuffer[1056 + x] |= t;
1005: sprBuffer[1056 + 1 + x] |= t;
1006: sprBuffer[1056 + 2 + x] |= t;
1007: sprBuffer[1056 + 3 + x] |= t;
1008: sprBuffer[1056 + 4 + x] |= t;
1009: sprBuffer[1056 + 5 + x] |= t;
1010: sprBuffer[1056 + 6 + x] |= t;
1011: sprBuffer[1056 + 7 + x] |= t;
1012: }
1013: x += 8;
1014: sx = (sx + 1) & 63;
1015: }
1016: } else {
1017: final short[] tnum = sprTNum, tcol = sprTColCurr;
1018: final boolean[] th = sprTH, tv = sprTV;
1019: int x, y = 0, sx, sy = 0, y0 = 0;
1020:
1021:
1022: int ofst = sprB0tx;
1023: if (SPR_RC_SCROLL_ON && sprRcScrollOn) {
1024: y0 = (src + sprReg1Bg0YCurr) & 1023;
1025: x = 16 + hStart - sprReg0Bg0XCurr - sprRowScroll[y0 >> 4];
1026: sx = (((x & 15) - x) >> 4) & 63;
1027: x &= 15;
1028: } else {
1029: x = 16 + hStart - sprReg0Bg0XCurr;
1030: y = (src + sprReg1Bg0YCurr) & 1023;
1031: sx = (((x & 15) - x) >> 4) & 63;
1032: sy = ofst + ((y >> 4) << 6);
1033: x &= 15;
1034: y &= 15;
1035: }
1036: while (x < width16) {
1037: if (SPR_RC_SCROLL_ON && sprRcScrollOn) {
1038: y = (y0 + sprColScroll[sx]) & 1023;
1039: sy = ofst + ((y >> 4) << 6);
1040: y &= 15;
1041: }
1042: int a = (tnum[sy + sx] << 2) + (tv[sy + sx] ? 15 - y : y);
1043: int t;
1044: if ((t = sprPatCurr[a]) != 0) {
1045: if (th[sy + sx]) {
1046: sprBuffer[2112 + 8 + x] |= (t & 15) << 20;
1047: sprBuffer[2112 + 9 + x] |= (t >>> 4 & 15) << 20;
1048: sprBuffer[2112 + 10 + x] |= (t >>> 8 & 15) << 20;
1049: sprBuffer[2112 + 11 + x] |= (t >>> 12 & 15) << 20;
1050: sprBuffer[2112 + 12 + x] |= (t >>> 16 & 15) << 20;
1051: sprBuffer[2112 + 13 + x] |= (t >>> 20 & 15) << 20;
1052: sprBuffer[2112 + 14 + x] |= (t >>> 24 & 15) << 20;
1053: sprBuffer[2112 + 15 + x] |= (t >>> 28 ) << 20;
1054: } else {
1055: sprBuffer[2112 + x] |= (t >>> 28 ) << 20;
1056: sprBuffer[2112 + 1 + x] |= (t >>> 24 & 15) << 20;
1057: sprBuffer[2112 + 2 + x] |= (t >>> 20 & 15) << 20;
1058: sprBuffer[2112 + 3 + x] |= (t >>> 16 & 15) << 20;
1059: sprBuffer[2112 + 4 + x] |= (t >>> 12 & 15) << 20;
1060: sprBuffer[2112 + 5 + x] |= (t >>> 8 & 15) << 20;
1061: sprBuffer[2112 + 6 + x] |= (t >>> 4 & 15) << 20;
1062: sprBuffer[2112 + 7 + x] |= (t & 15) << 20;
1063: }
1064: }
1065: if ((t = sprPatCurr[16 + a]) != 0) {
1066: if (th[sy + sx]) {
1067: sprBuffer[2112 + x] |= (t & 15) << 20;
1068: sprBuffer[2112 + 1 + x] |= (t >>> 4 & 15) << 20;
1069: sprBuffer[2112 + 2 + x] |= (t >>> 8 & 15) << 20;
1070: sprBuffer[2112 + 3 + x] |= (t >>> 12 & 15) << 20;
1071: sprBuffer[2112 + 4 + x] |= (t >>> 16 & 15) << 20;
1072: sprBuffer[2112 + 5 + x] |= (t >>> 20 & 15) << 20;
1073: sprBuffer[2112 + 6 + x] |= (t >>> 24 & 15) << 20;
1074: sprBuffer[2112 + 7 + x] |= (t >>> 28 ) << 20;
1075: } else {
1076: sprBuffer[2112 + 8 + x] |= (t >>> 28 ) << 20;
1077: sprBuffer[2112 + 9 + x] |= (t >>> 24 & 15) << 20;
1078: sprBuffer[2112 + 10 + x] |= (t >>> 20 & 15) << 20;
1079: sprBuffer[2112 + 11 + x] |= (t >>> 16 & 15) << 20;
1080: sprBuffer[2112 + 12 + x] |= (t >>> 12 & 15) << 20;
1081: sprBuffer[2112 + 13 + x] |= (t >>> 8 & 15) << 20;
1082: sprBuffer[2112 + 14 + x] |= (t >>> 4 & 15) << 20;
1083: sprBuffer[2112 + 15 + x] |= (t & 15) << 20;
1084: }
1085: }
1086: if ((t = tcol[sy + sx]) != 0) {
1087: t <<= 20 - 4;
1088: sprBuffer[1056 + x] |= t;
1089: sprBuffer[1056 + 1 + x] |= t;
1090: sprBuffer[1056 + 2 + x] |= t;
1091: sprBuffer[1056 + 3 + x] |= t;
1092: sprBuffer[1056 + 4 + x] |= t;
1093: sprBuffer[1056 + 5 + x] |= t;
1094: sprBuffer[1056 + 6 + x] |= t;
1095: sprBuffer[1056 + 7 + x] |= t;
1096: sprBuffer[1056 + 8 + x] |= t;
1097: sprBuffer[1056 + 9 + x] |= t;
1098: sprBuffer[1056 + 10 + x] |= t;
1099: sprBuffer[1056 + 11 + x] |= t;
1100: sprBuffer[1056 + 12 + x] |= t;
1101: sprBuffer[1056 + 13 + x] |= t;
1102: sprBuffer[1056 + 14 + x] |= t;
1103: sprBuffer[1056 + 15 + x] |= t;
1104: }
1105: x += 16;
1106: sx = (sx + 1) & 63;
1107: }
1108: if (spr512bg1) {
1109:
1110:
1111: ofst = sprB1tx;
1112: if (SPR_RC_SCROLL_ON && sprRcScrollOn) {
1113: y0 = (src + sprReg3Bg1YCurr) & 1023;
1114: x = 16 + hStart - sprReg2Bg1XCurr - sprRowScroll[64 * 1 + (y0 >> 4)];
1115: sx = (((x & 15) - x) >> 4) & 63;
1116: x &= 15;
1117: } else {
1118: x = 16 + hStart - sprReg2Bg1XCurr;
1119: y = (src + sprReg3Bg1YCurr) & 1023;
1120: sx = (((x & 15) - x) >> 4) & 63;
1121: sy = ofst + ((y >> 4) << 6);
1122: x &= 15;
1123: y &= 15;
1124: }
1125: while (x < width16) {
1126: if (SPR_RC_SCROLL_ON && sprRcScrollOn) {
1127: y = (y0 + sprColScroll[64 * 1 + sx]) & 1023;
1128: sy = ofst + ((y >> 4) << 6);
1129: y &= 15;
1130: }
1131: int a = (tnum[sy + sx] << 2) + (tv[sy + sx] ? 15 - y : y);
1132: int t;
1133: if ((t = sprPatCurr[a]) != 0) {
1134: if (th[sy + sx]) {
1135: sprBuffer[2112 + 8 + x] |= (t & 15) << 12;
1136: sprBuffer[2112 + 9 + x] |= (t >>> 4 & 15) << 12;
1137: sprBuffer[2112 + 10 + x] |= (t >>> 8 & 15) << 12;
1138: sprBuffer[2112 + 11 + x] |= (t >>> 12 & 15) << 12;
1139: sprBuffer[2112 + 12 + x] |= (t >>> 16 & 15) << 12;
1140: sprBuffer[2112 + 13 + x] |= (t >>> 20 & 15) << 12;
1141: sprBuffer[2112 + 14 + x] |= (t >>> 24 & 15) << 12;
1142: sprBuffer[2112 + 15 + x] |= (t >>> 28 ) << 12;
1143: } else {
1144: sprBuffer[2112 + x] |= (t >>> 28 ) << 12;
1145: sprBuffer[2112 + 1 + x] |= (t >>> 24 & 15) << 12;
1146: sprBuffer[2112 + 2 + x] |= (t >>> 20 & 15) << 12;
1147: sprBuffer[2112 + 3 + x] |= (t >>> 16 & 15) << 12;
1148: sprBuffer[2112 + 4 + x] |= (t >>> 12 & 15) << 12;
1149: sprBuffer[2112 + 5 + x] |= (t >>> 8 & 15) << 12;
1150: sprBuffer[2112 + 6 + x] |= (t >>> 4 & 15) << 12;
1151: sprBuffer[2112 + 7 + x] |= (t & 15) << 12;
1152: }
1153: }
1154: if ((t = sprPatCurr[16 + a]) != 0) {
1155: if (th[sy + sx]) {
1156: sprBuffer[2112 + x] |= (t & 15) << 12;
1157: sprBuffer[2112 + 1 + x] |= (t >>> 4 & 15) << 12;
1158: sprBuffer[2112 + 2 + x] |= (t >>> 8 & 15) << 12;
1159: sprBuffer[2112 + 3 + x] |= (t >>> 12 & 15) << 12;
1160: sprBuffer[2112 + 4 + x] |= (t >>> 16 & 15) << 12;
1161: sprBuffer[2112 + 5 + x] |= (t >>> 20 & 15) << 12;
1162: sprBuffer[2112 + 6 + x] |= (t >>> 24 & 15) << 12;
1163: sprBuffer[2112 + 7 + x] |= (t >>> 28 ) << 12;
1164: } else {
1165: sprBuffer[2112 + 8 + x] |= (t >>> 28 ) << 12;
1166: sprBuffer[2112 + 9 + x] |= (t >>> 24 & 15) << 12;
1167: sprBuffer[2112 + 10 + x] |= (t >>> 20 & 15) << 12;
1168: sprBuffer[2112 + 11 + x] |= (t >>> 16 & 15) << 12;
1169: sprBuffer[2112 + 12 + x] |= (t >>> 12 & 15) << 12;
1170: sprBuffer[2112 + 13 + x] |= (t >>> 8 & 15) << 12;
1171: sprBuffer[2112 + 14 + x] |= (t >>> 4 & 15) << 12;
1172: sprBuffer[2112 + 15 + x] |= (t & 15) << 12;
1173: }
1174: }
1175: if ((t = tcol[sy + sx]) != 0) {
1176: t <<= 12 - 4;
1177: sprBuffer[1056 + x] |= t;
1178: sprBuffer[1056 + 1 + x] |= t;
1179: sprBuffer[1056 + 2 + x] |= t;
1180: sprBuffer[1056 + 3 + x] |= t;
1181: sprBuffer[1056 + 4 + x] |= t;
1182: sprBuffer[1056 + 5 + x] |= t;
1183: sprBuffer[1056 + 6 + x] |= t;
1184: sprBuffer[1056 + 7 + x] |= t;
1185: sprBuffer[1056 + 8 + x] |= t;
1186: sprBuffer[1056 + 9 + x] |= t;
1187: sprBuffer[1056 + 10 + x] |= t;
1188: sprBuffer[1056 + 11 + x] |= t;
1189: sprBuffer[1056 + 12 + x] |= t;
1190: sprBuffer[1056 + 13 + x] |= t;
1191: sprBuffer[1056 + 14 + x] |= t;
1192: sprBuffer[1056 + 15 + x] |= t;
1193: }
1194: x += 16;
1195: sx = (sx + 1) & 63;
1196: }
1197: }
1198: }
1199: }
1200:
1201:
1202:
1203:
1204:
1205:
1206:
1207:
1208:
1209:
1210:
1211:
1212:
1213:
1214:
1215:
1216:
1217:
1218: public static void sprStep3 () {
1219: int width16 = 16 + XEiJ.pnlScreenWidth;
1220: if (!sprActive ||
1221: !sprDisp) {
1222: Arrays.fill (sprBuffer, 16, width16, 0);
1223: } else {
1224: int mask = (15 << 24 |
1225: 15 << 16 |
1226: 15 << 8 |
1227: (sprB0on ? 15 << 20 : 0) |
1228: (sprB1on ? 15 << 12 : 0));
1229: for (int x = 16; x < width16; x++) {
1230: int l = sprBuffer[2112 + x];
1231: int h = sprBuffer[1056 + x];
1232: if ((l &= mask) != 0) {
1233: int i = Integer.numberOfLeadingZeros (l) & -4;
1234: sprBuffer[x] = h << i >>> 28 << 4 | l << i >>> 28;
1235: } else if ((h &= mask & (15 << 20 | 15 << 12)) != 0) {
1236: int i = Integer.numberOfTrailingZeros (h) & -4;
1237: sprBuffer[x] = (h >> i & 15) << 4 | l >> i & 15;
1238: } else {
1239: sprBuffer[x] = 0;
1240: }
1241: }
1242: }
1243: }
1244:
1245:
1246:
1247:
1248:
1249: public static int sprReadByte (int a) throws M68kException {
1250: return ((a & 1) == 0 ?
1251: sprReadWord (a) >> 8 :
1252: sprReadWord (a & ~1) & 0x00ff);
1253: }
1254:
1255:
1256:
1257: public static int sprReadWord (int a) throws M68kException {
1258: a &= XEiJ.BUS_MOTHER_MASK;
1259: if (a < 0x00eb0800 || (0x00eb0840 <= a && a < 0x00eb4000)) {
1260:
1261:
1262:
1263:
1264:
1265:
1266: if (!sprAccessible) {
1267: return MemoryMappedDevice.MMD_NUL.mmdRwz (a);
1268: }
1269:
1270: XEiJ.mpuClockTime += sprWaitSprite;
1271: int n = (a - 0x00eb0000) >> 3;
1272: if (sprNumberOfSprites <= n) {
1273: if (SPR_RC_SCROLL_ON && sprRcScrollOn) {
1274: if (0x00eb2000 <= a && a < 0x00eb20ff) {
1275: return sprRowScroll[(a >> 1) & (64 * 4 - 1)];
1276: } else if (0x00eb2200 <= a && a < 0x00eb22ff) {
1277: return sprColScroll[(a >> 1) & (64 * 4 - 1)];
1278: }
1279: }
1280: return 0xffff;
1281: }
1282:
1283: switch (a & 6) {
1284: case 0:
1285: return sprX[n];
1286: case 2:
1287: return sprY[n];
1288: case 4:
1289: {
1290: int v = sprV[n] ? 0x8000 : 0;
1291: int h = sprH[n] ? 0x4000 : 0;
1292: int col = sprColPort[n] << 4;
1293: int num = sprNumPort[n];
1294: if (sprBankOn) {
1295: if (sprBankMode == 0) {
1296: return (v | h | col | num);
1297: } else if (sprBankMode == 1) {
1298: return (v | h | (num & 0x0300) << 4 | col | (num & 0x00ff));
1299: } else {
1300: return ((num & 0x0f00) << 4 | col | (num & 0x00ff));
1301: }
1302: } else {
1303: return (v | h | col | num);
1304: }
1305: }
1306: default:
1307: if (sprBankOn &&
1308: sprBankMode == 3) {
1309: return ((sprV[n] ? 0x8000 : 0) |
1310: (sprH[n] ? 0x4000 : 0) |
1311: (sprSPCS[n] ? 0x0004 : 0) |
1312: sprPrw[n]);
1313: } else {
1314: return ((sprSPCS[n] ? 0x0004 : 0) |
1315: sprPrw[n]);
1316: }
1317: }
1318: } else if (a < 0x00eb4000) {
1319:
1320:
1321:
1322: switch (a) {
1323: case SPR_REG0_BG0_X:
1324: return sprReg0Bg0XPort;
1325: case SPR_REG1_BG0_Y:
1326: return sprReg1Bg0YPort;
1327: case SPR_REG2_BG1_X:
1328: return sprReg2Bg1XPort;
1329: case SPR_REG3_BG1_Y:
1330: return sprReg3Bg1YPort;
1331: case SPR_REG4_BG_CTRL:
1332: return sprReg4BgCtrlPort;
1333: case SPR_REG5_H_FRONT_END:
1334: return sprReg5HFrontEndPort;
1335: case SPR_REG6_H_BACK_END:
1336: return sprReg6HBackEndPort;
1337: case SPR_REG7_V_BACK_END:
1338: return sprReg7VBackEndPort;
1339: case SPR_REG8_RESO:
1340: return sprReg8ResoPort;
1341: case SPR_REG9_BANK_CONTROL:
1342: if (sprBankOn) {
1343: return sprBankMode << 1 | (sprBankShifted ? 1 : 0);
1344: } else {
1345: return 0xffff;
1346: }
1347: case SPR_REG10_BANK_SELECT:
1348: if (sprBankOn) {
1349: return sprBankNumber;
1350: } else {
1351: return 0xffff;
1352: }
1353: }
1354: return 0xffff;
1355: } else if (a < 0x00eb8000) {
1356:
1357:
1358:
1359:
1360:
1361:
1362:
1363: if (!sprBankOn ||
1364: !sprBankShifted) {
1365: return 0xffff;
1366: }
1367: if (!sprAccessible) {
1368: return MemoryMappedDevice.MMD_NUL.mmdRwz (a);
1369: }
1370:
1371: XEiJ.mpuClockTime += sprWaitPattern;
1372:
1373: int p = ((sprMpucs ? 8192 : 0) +
1374: ((a >> 1) & 8191));
1375:
1376: int v = sprTV[p] ? 0x8000 : 0;
1377: int h = sprTH[p] ? 0x4000 : 0;
1378: int col = sprTColPort[p] << 4;
1379: int num = sprTNum[p] >> 3;
1380: if (sprBankMode == 0) {
1381: return (v | h | col | num);
1382: } else if (sprBankMode == 1) {
1383: return (v | h | (num & 0x0300) << 4 | col | (num & 0x00ff));
1384: } else {
1385: return ((num & 0x0f00) << 4 | col | (num & 0x00ff));
1386: }
1387: } else {
1388:
1389:
1390:
1391:
1392:
1393: if (!sprAccessible) {
1394: return MemoryMappedDevice.MMD_NUL.mmdRwz (a);
1395: }
1396:
1397: XEiJ.mpuClockTime += sprWaitPattern;
1398:
1399: int i = ((sprMpucs ? (1 << 8) << 5 : sprBankNumber << 5) +
1400: ((a >> 2) & 8191));
1401:
1402: return ((a & 2) == 0 ?
1403: sprPatPort[i] >>> 16 :
1404: (char) sprPatPort[i]);
1405: }
1406: }
1407:
1408:
1409:
1410: public static int sprReadLong (int a) throws M68kException {
1411: return (sprReadWord (a) << 16 |
1412: sprReadWord (a + 2));
1413: }
1414:
1415:
1416:
1417:
1418:
1419: public static void sprWriteByte (int a, int d) throws M68kException {
1420: a &= XEiJ.BUS_MOTHER_MASK;
1421: if (a < 0x00eb0800 ||
1422: (sprBankOn && sprBankShifted ? 0x00eb4000 : 0x00eb8000) <= a) {
1423: sprWriteWord (a & ~1, d << 8 | (d & 0x00ff));
1424: } else {
1425: if ((a & 1) == 0) {
1426: sprWriteWord (a, d << 8 | (sprReadWord (a) & 0x00ff));
1427: } else {
1428: sprWriteWord (a & ~1, (sprReadWord (a & ~1) & 0xff00) | (d & 0x00ff));
1429: }
1430: }
1431: }
1432:
1433:
1434:
1435: public static void sprWriteWord (int a, int d) throws M68kException {
1436: a &= XEiJ.BUS_MOTHER_MASK;
1437: if (a < 0x00eb0800 || (0x00eb0840 <= a && a < 0x00eb4000)) {
1438:
1439:
1440:
1441:
1442:
1443:
1444:
1445:
1446: if (!sprAccessible) {
1447: MemoryMappedDevice.MMD_NUL.mmdWw (a, d);
1448: return;
1449: }
1450:
1451: XEiJ.mpuClockTime += sprWaitSprite;
1452: int n = (a - 0x00eb0000) >> 3;
1453: if (sprNumberOfSprites <= n) {
1454: if (SPR_RC_SCROLL_ON && sprRcScrollOn) {
1455: if (0x00eb2000 <= a && a < 0x00eb20ff) {
1456: sprRowScroll[(a >> 1) & (64 * 4 - 1)] = d & 1023;
1457: } else if (0x00eb2200 <= a && a < 0x00eb22ff) {
1458: sprColScroll[(a >> 1) & (64 * 4 - 1)] = d & 1023;
1459: }
1460: }
1461: return;
1462: }
1463:
1464: switch (a & 6) {
1465: case 0:
1466: sprX[n] = (short) (d & 1023);
1467: return;
1468: case 2:
1469: d &= 1023;
1470: if (sprY[n] != d) {
1471: int y = sprY[n];
1472: sprY[n] = (short) d;
1473: if (sprPrw[n] != 0) {
1474: int mask = ~(0x80000000 >>> n);
1475: int i = y << (SPR_SHIFT - 5) | n >> 5;
1476: sprRRmap[i ] &= mask;
1477: sprRRmap[i + ( 1 << (SPR_SHIFT - 5))] &= mask;
1478: sprRRmap[i + ( 2 << (SPR_SHIFT - 5))] &= mask;
1479: sprRRmap[i + ( 3 << (SPR_SHIFT - 5))] &= mask;
1480: sprRRmap[i + ( 4 << (SPR_SHIFT - 5))] &= mask;
1481: sprRRmap[i + ( 5 << (SPR_SHIFT - 5))] &= mask;
1482: sprRRmap[i + ( 6 << (SPR_SHIFT - 5))] &= mask;
1483: sprRRmap[i + ( 7 << (SPR_SHIFT - 5))] &= mask;
1484: sprRRmap[i + ( 8 << (SPR_SHIFT - 5))] &= mask;
1485: sprRRmap[i + ( 9 << (SPR_SHIFT - 5))] &= mask;
1486: sprRRmap[i + (10 << (SPR_SHIFT - 5))] &= mask;
1487: sprRRmap[i + (11 << (SPR_SHIFT - 5))] &= mask;
1488: sprRRmap[i + (12 << (SPR_SHIFT - 5))] &= mask;
1489: sprRRmap[i + (13 << (SPR_SHIFT - 5))] &= mask;
1490: sprRRmap[i + (14 << (SPR_SHIFT - 5))] &= mask;
1491: sprRRmap[i + (15 << (SPR_SHIFT - 5))] &= mask;
1492: mask = ~mask;
1493: i = d << (SPR_SHIFT - 5) | n >> 5;
1494: sprRRmap[i ] |= mask;
1495: sprRRmap[i + ( 1 << (SPR_SHIFT - 5))] |= mask;
1496: sprRRmap[i + ( 2 << (SPR_SHIFT - 5))] |= mask;
1497: sprRRmap[i + ( 3 << (SPR_SHIFT - 5))] |= mask;
1498: sprRRmap[i + ( 4 << (SPR_SHIFT - 5))] |= mask;
1499: sprRRmap[i + ( 5 << (SPR_SHIFT - 5))] |= mask;
1500: sprRRmap[i + ( 6 << (SPR_SHIFT - 5))] |= mask;
1501: sprRRmap[i + ( 7 << (SPR_SHIFT - 5))] |= mask;
1502: sprRRmap[i + ( 8 << (SPR_SHIFT - 5))] |= mask;
1503: sprRRmap[i + ( 9 << (SPR_SHIFT - 5))] |= mask;
1504: sprRRmap[i + (10 << (SPR_SHIFT - 5))] |= mask;
1505: sprRRmap[i + (11 << (SPR_SHIFT - 5))] |= mask;
1506: sprRRmap[i + (12 << (SPR_SHIFT - 5))] |= mask;
1507: sprRRmap[i + (13 << (SPR_SHIFT - 5))] |= mask;
1508: sprRRmap[i + (14 << (SPR_SHIFT - 5))] |= mask;
1509: sprRRmap[i + (15 << (SPR_SHIFT - 5))] |= mask;
1510: }
1511: }
1512: return;
1513: case 4:
1514: {
1515: int preNum = sprNumPort[n];
1516: int col = (d & 0x0f00) >> 4;
1517: int num = (d & 0x00ff);
1518: if (sprBankOn) {
1519: if (sprBankMode <= 1) {
1520: sprV[n] = (d & 0x8000) != 0;
1521: sprH[n] = (d & 0x4000) != 0;
1522: if (sprBankMode == 1) {
1523: num |= (d & 0x3000) >> 4;
1524: }
1525: } else {
1526:
1527: if (sprBankMode == 2) {
1528: sprV[n] = false;
1529: sprH[n] = false;
1530: }
1531: num |= (d & 0xf000) >> 4;
1532: }
1533: } else {
1534: sprV[n] = (d & 0x8000) != 0;
1535: sprH[n] = (d & 0x4000) != 0;
1536: }
1537: sprColPort[n] = (short) col;
1538: sprNumPort[n] = (short) num;
1539: if (sprPrw[n] != 0 && preNum != num) {
1540: int mask = 0x80000000 >>> n;
1541: sprPPmap[preNum << (SPR_SHIFT - 5) | n >> 5] &= ~mask;
1542: sprPPmap[num << (SPR_SHIFT - 5) | n >> 5] |= mask;
1543: }
1544: }
1545: return;
1546: default:
1547: {
1548: if (sprBankOn &&
1549: sprBankMode == 3) {
1550:
1551: sprV[n] = (d & 0x8000) != 0;
1552: sprH[n] = (d & 0x4000) != 0;
1553: }
1554: int prePrw = sprPrw[n];
1555: int prw = (d & 0x0003);
1556: sprPrw[n] = (byte) prw;
1557: if (prePrw == 0 && prw != 0) {
1558: int y = sprY[n];
1559: int mask = 0x80000000 >>> n;
1560: int i = y << (SPR_SHIFT - 5) | n >> 5;
1561: sprRRmap[i ] |= mask;
1562: sprRRmap[i + ( 1 << (SPR_SHIFT - 5))] |= mask;
1563: sprRRmap[i + ( 2 << (SPR_SHIFT - 5))] |= mask;
1564: sprRRmap[i + ( 3 << (SPR_SHIFT - 5))] |= mask;
1565: sprRRmap[i + ( 4 << (SPR_SHIFT - 5))] |= mask;
1566: sprRRmap[i + ( 5 << (SPR_SHIFT - 5))] |= mask;
1567: sprRRmap[i + ( 6 << (SPR_SHIFT - 5))] |= mask;
1568: sprRRmap[i + ( 7 << (SPR_SHIFT - 5))] |= mask;
1569: sprRRmap[i + ( 8 << (SPR_SHIFT - 5))] |= mask;
1570: sprRRmap[i + ( 9 << (SPR_SHIFT - 5))] |= mask;
1571: sprRRmap[i + (10 << (SPR_SHIFT - 5))] |= mask;
1572: sprRRmap[i + (11 << (SPR_SHIFT - 5))] |= mask;
1573: sprRRmap[i + (12 << (SPR_SHIFT - 5))] |= mask;
1574: sprRRmap[i + (13 << (SPR_SHIFT - 5))] |= mask;
1575: sprRRmap[i + (14 << (SPR_SHIFT - 5))] |= mask;
1576: sprRRmap[i + (15 << (SPR_SHIFT - 5))] |= mask;
1577: sprPPmap[sprNumPort[n] << (SPR_SHIFT - 5) | n >> 5] |= mask;
1578: } else if (prePrw != 0 && prw == 0) {
1579: int y = sprY[n];
1580: int mask = ~(0x80000000 >>> n);
1581: int i = y << (SPR_SHIFT - 5) | n >> 5;
1582: sprRRmap[i ] &= mask;
1583: sprRRmap[i + ( 1 << (SPR_SHIFT - 5))] &= mask;
1584: sprRRmap[i + ( 2 << (SPR_SHIFT - 5))] &= mask;
1585: sprRRmap[i + ( 3 << (SPR_SHIFT - 5))] &= mask;
1586: sprRRmap[i + ( 4 << (SPR_SHIFT - 5))] &= mask;
1587: sprRRmap[i + ( 5 << (SPR_SHIFT - 5))] &= mask;
1588: sprRRmap[i + ( 6 << (SPR_SHIFT - 5))] &= mask;
1589: sprRRmap[i + ( 7 << (SPR_SHIFT - 5))] &= mask;
1590: sprRRmap[i + ( 8 << (SPR_SHIFT - 5))] &= mask;
1591: sprRRmap[i + ( 9 << (SPR_SHIFT - 5))] &= mask;
1592: sprRRmap[i + (10 << (SPR_SHIFT - 5))] &= mask;
1593: sprRRmap[i + (11 << (SPR_SHIFT - 5))] &= mask;
1594: sprRRmap[i + (12 << (SPR_SHIFT - 5))] &= mask;
1595: sprRRmap[i + (13 << (SPR_SHIFT - 5))] &= mask;
1596: sprRRmap[i + (14 << (SPR_SHIFT - 5))] &= mask;
1597: sprRRmap[i + (15 << (SPR_SHIFT - 5))] &= mask;
1598: sprPPmap[sprNumPort[n] << (SPR_SHIFT - 5) | n >> 5] &= mask;
1599: }
1600: sprSPCS[n] = (d & 0x0004) != 0;
1601: }
1602: return;
1603: }
1604: } else if (a < 0x00eb4000) {
1605:
1606:
1607:
1608:
1609: switch (a) {
1610: case SPR_REG0_BG0_X:
1611: sprReg0Bg0XPort = (d & 1023);
1612: {
1613: int curr = sprReg0Bg0XMask == 0 ? sprReg0Bg0XPort : sprReg0Bg0XTest;
1614: if (sprReg0Bg0XCurr != curr) {
1615: sprReg0Bg0XCurr = curr;
1616: }
1617: }
1618: return;
1619: case SPR_REG1_BG0_Y:
1620: sprReg1Bg0YPort = (d & 1023);
1621: {
1622: int curr = sprReg1Bg0YMask == 0 ? sprReg1Bg0YPort : sprReg1Bg0YTest;
1623: if (sprReg1Bg0YCurr != curr) {
1624: sprReg1Bg0YCurr = curr;
1625: }
1626: }
1627: return;
1628: case SPR_REG2_BG1_X:
1629: sprReg2Bg1XPort = (d & 1023);
1630: {
1631: int curr = sprReg2Bg1XMask == 0 ? sprReg2Bg1XPort : sprReg2Bg1XTest;
1632: if (sprReg2Bg1XCurr != curr) {
1633: sprReg2Bg1XCurr = curr;
1634: }
1635: }
1636: return;
1637: case SPR_REG3_BG1_Y:
1638: sprReg3Bg1YPort = (d & 1023);
1639: {
1640: int curr = sprReg3Bg1YMask == 0 ? sprReg3Bg1YPort : sprReg3Bg1YTest;
1641: if (sprReg3Bg1YCurr != curr) {
1642: sprReg3Bg1YCurr = curr;
1643: }
1644: }
1645: return;
1646: case SPR_REG4_BG_CTRL:
1647: sprReg4BgCtrlPort = (d & 0x063f);
1648: {
1649: int curr = sprReg4BgCtrlPort & ~sprReg4BgCtrlMask | sprReg4BgCtrlTest & sprReg4BgCtrlMask;
1650: if (sprReg4BgCtrlCurr != curr) {
1651: sprReg4BgCtrlCurr = curr;
1652: sprMpucs = (sprReg4BgCtrlCurr & SPR_MPUCS) != 0;
1653: sprDisp = (sprReg4BgCtrlCurr & SPR_DISP) != 0;
1654: sprB1tx = (sprReg4BgCtrlCurr & (SPR_B1CS | SPR_B1TX)) << (12 - 4);
1655: sprB1on = (sprReg4BgCtrlCurr & SPR_B1ON) != 0;
1656: sprB0tx = (sprReg4BgCtrlCurr & (SPR_B0CS | SPR_B0TX)) << (12 - 1);
1657: sprB0on = (sprReg4BgCtrlCurr & SPR_B0ON) != 0;
1658: if (sprDisp) {
1659: sprWaitSprite = SPR_WAIT_SPRITE_DISP_1;
1660: sprWaitPattern = SPR_WAIT_PATTERN_DISP_1;
1661: if (SPR_THREE_STEPS) {
1662: sprLatched = true;
1663: }
1664: } else {
1665: sprWaitSprite = SPR_WAIT_SPRITE_DISP_0;
1666: sprWaitPattern = SPR_WAIT_PATTERN_DISP_0;
1667: }
1668: }
1669: }
1670: return;
1671: case SPR_REG5_H_FRONT_END:
1672: sprReg5HFrontEndPort = (d & 255);
1673: {
1674: int curr = sprReg5HFrontEndMask == 0 ? sprReg5HFrontEndPort : sprReg5HFrontEndTest;
1675: if (sprReg5HFrontEndCurr != curr) {
1676: sprReg5HFrontEndCurr = curr;
1677: }
1678: }
1679: return;
1680: case SPR_REG6_H_BACK_END:
1681: sprReg6HBackEndPort = (d & 63);
1682: {
1683: int curr = sprReg6HBackEndMask == 0 ? sprReg6HBackEndPort : sprReg6HBackEndTest;
1684: if (sprReg6HBackEndCurr != curr) {
1685: sprReg6HBackEndCurr = curr;
1686: }
1687: }
1688: return;
1689: case SPR_REG7_V_BACK_END:
1690: sprReg7VBackEndPort = (d & 255);
1691: {
1692: int curr = sprReg7VBackEndMask == 0 ? sprReg7VBackEndPort : sprReg7VBackEndTest;
1693: if (sprReg7VBackEndCurr != curr) {
1694: sprReg7VBackEndCurr = curr;
1695: }
1696: }
1697: return;
1698: case SPR_REG8_RESO:
1699: sprReg8ResoPort = (d & 31);
1700: {
1701: int curr = sprReg8ResoPort & ~sprReg8ResoMask | sprReg8ResoTest & sprReg8ResoMask;
1702: if (sprReg8ResoCurr != curr) {
1703: sprReg8ResoCurr = curr;
1704: CRTC.crtRestart ();
1705: }
1706: }
1707: return;
1708: case SPR_REG9_BANK_CONTROL:
1709: if (sprBankOn) {
1710: sprBankMode = (d & 6) >> 1;
1711: sprBankShifted = (d & 1) != 0;
1712: }
1713: return;
1714: case SPR_REG10_BANK_SELECT:
1715: if (sprBankOn) {
1716: sprBankNumber = (d & (15 << 8));
1717: }
1718: return;
1719: }
1720: return;
1721: } else if (a < 0x00eb8000) {
1722:
1723:
1724:
1725:
1726:
1727:
1728:
1729:
1730:
1731: if (!sprBankOn ||
1732: !sprBankShifted) {
1733: return;
1734: }
1735: if (!sprAccessible) {
1736: MemoryMappedDevice.MMD_NUL.mmdWw (a, d);
1737: return;
1738: }
1739:
1740: XEiJ.mpuClockTime += sprWaitPattern;
1741:
1742: int p = ((sprMpucs ? 8192 : 0) +
1743: ((a >> 1) & 8191));
1744:
1745: boolean v = (d & 0x8000) != 0;
1746: boolean h = (d & 0x4000) != 0;
1747: int col = (d & 0x0f00) >> 4;
1748: int num = (d & 0x00ff);
1749: if (sprBankMode == 0) {
1750: } else if (sprBankMode == 1) {
1751: num |= (d & 0x3000) >> 4;
1752: } else {
1753: v = false;
1754: h = false;
1755: num |= (d & 0xf000) >> 4;
1756: }
1757: sprTV[p] = v;
1758: sprTH[p] = h;
1759: sprTColPort[p] = (short) col;
1760: sprTNum[p] = (short) (num << 3);
1761: return;
1762: } else if (a < 0x00ebc000) {
1763:
1764:
1765:
1766:
1767:
1768:
1769:
1770:
1771:
1772: if (!sprAccessible) {
1773: MemoryMappedDevice.MMD_NUL.mmdWw (a, d);
1774: return;
1775: }
1776:
1777: XEiJ.mpuClockTime += sprWaitPattern;
1778: if (sprMpucs &&
1779: !sprBankOn &&
1780: !sprFPM) {
1781: return;
1782: }
1783:
1784: int i = ((sprMpucs ? (1 << 8) << 5 : sprBankNumber << 5) +
1785: ((a >> 2) & 8191));
1786:
1787: sprPatPort[i] = ((a & 2) == 0 ?
1788: d << 16 | (char) sprPatPort[i] :
1789: (sprPatPort[i] & 0xffff0000) | (char) d);
1790: return;
1791: } else {
1792:
1793:
1794:
1795:
1796:
1797:
1798:
1799:
1800:
1801:
1802:
1803:
1804:
1805: if (!sprAccessible) {
1806: MemoryMappedDevice.MMD_NUL.mmdWw (a, d);
1807: return;
1808: }
1809:
1810: XEiJ.mpuClockTime += sprWaitPattern;
1811: if (sprMpucs &&
1812: !sprBankOn &&
1813: !sprFPM) {
1814: return;
1815: }
1816:
1817: int i = ((sprMpucs ? (1 << 8) << 5 : sprBankNumber << 5) +
1818: ((a >> 2) & 8191));
1819:
1820: sprPatPort[i] = ((a & 2) == 0 ?
1821: d << 16 | (char) sprPatPort[i] :
1822: (sprPatPort[i] & 0xffff0000) | (char) d);
1823: if (sprBankOn &&
1824: (sprBankShifted ||
1825: sprBankNumber != (0 << 8))) {
1826: return;
1827: }
1828:
1829: int p = ((sprMpucs ? 8192 : 0) +
1830: ((a >> 1) & 8191));
1831:
1832: boolean v = (d & 0x8000) != 0;
1833: boolean h = (d & 0x4000) != 0;
1834: int col = (d & 0x0f00) >> 4;
1835: int num = (d & 0x00ff);
1836: if (sprBankOn) {
1837: if (sprBankMode == 0) {
1838: } else if (sprBankMode == 1) {
1839: num |= (d & 0x3000) >> 4;
1840: } else {
1841: v = false;
1842: h = false;
1843: num |= (d & 0xf000) >> 4;
1844: }
1845: }
1846: sprTV[p] = v;
1847: sprTH[p] = h;
1848: sprTColPort[p] = (short) col;
1849: sprTNum[p] = (short) (num << 3);
1850: return;
1851: }
1852: }
1853:
1854:
1855:
1856: public static void sprWriteLong (int a, int d) throws M68kException {
1857: sprWriteWord (a, d >> 16);
1858: sprWriteWord (a + 2, d);
1859: }
1860:
1861:
1862:
1863: }
1864:
1865:
1866: