Z8530.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20: package xeij;
21:
22: import java.awt.event.*;
23: import java.util.*;
24: import javax.swing.*;
25:
26: public class Z8530 {
27:
28: public static final boolean SCC_DEBUG_ON = false;
29: public static int sccDebugOn;
30:
31:
32: public static double sccFreq = 5000000.0;
33:
34:
35: public static JMenu sccMenu;
36:
37:
38: public static final int SCC_0B_COMMAND = 0x00e98001;
39: public static final int SCC_0B_DATA = 0x00e98003;
40: public static final int SCC_1A_COMMAND = 0x00e98005;
41: public static final int SCC_1A_DATA = 0x00e98007;
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70: public static int sccInterruptVector;
71: public static int sccVectorInclude;
72: public static int sccMIE;
73:
74: public static final int SCC_0B_RECEIVE_VECTOR = 2;
75: public static final int SCC_0B_RECEIVE_MASK = 0x04;
76: public static int scc0bReceiveMask;
77: public static int scc0bReceiveRR3;
78: public static int scc0bReceiveRequest;
79: public static int scc0bReceiveVector;
80:
81: public static final int SCC_1A_RECEIVE_VECTOR = 6;
82: public static final int SCC_1A_RECEIVE_MASK = 0x20;
83: public static int scc1aReceiveMask;
84: public static int scc1aReceiveRR3;
85: public static int scc1aReceiveRequest;
86: public static int scc1aReceiveVector;
87:
88: public static final int SCC_1A_SEND_VECTOR = 4;
89: public static final int SCC_1A_SEND_MASK = 0x10;
90: public static int scc1aSendMask;
91: public static int scc1aSendRR3;
92: public static int scc1aSendRequest;
93: public static int scc1aSendVector;
94:
95:
96: public static int scc0bRegisterNumber;
97: public static int scc0bRts;
98: public static int scc0bBaudRateGen;
99: public static int scc0bInputCounter;
100: public static int scc0bData1;
101: public static int scc0bData2;
102:
103: public static final boolean SCC_FSX_MOUSE = true;
104: public static int sccFSXMouseHook;
105: public static int sccFSXMouseWork;
106:
107:
108: public static final int SCC_1A_INPUT_BITS = 16;
109: public static final int SCC_1A_INPUT_SIZE = 1 << SCC_1A_INPUT_BITS;
110: public static final int SCC_1A_INPUT_MASK = SCC_1A_INPUT_SIZE - 1;
111: public static int scc1aRegisterNumber;
112: public static final int[] scc1aInputBuffer = new int[SCC_1A_INPUT_SIZE];
113: public static int scc1aInputRead;
114: public static int scc1aInputWrite;
115:
116: public static int scc1aBRGEnable;
117: public static int scc1aClockModeShift;
118: public static int scc1aBaudRateGen;
119: public static long scc1aInterval;
120:
121: public static int scc1aRxBits;
122: public static int scc1aRxEnable;
123: public static int scc1aStop;
124: public static int scc1aParity;
125: public static int scc1aTxBits;
126: public static int scc1aTxEnable;
127:
128:
129:
130:
131: public static void sccInit () {
132:
133: sccFreq = 5000000 < Settings.sgsGetInt ("sccfreq") ? 7372800.0 : 5000000.0;
134:
135: if (SCC_DEBUG_ON) {
136: sccDebugOn = 2;
137: }
138:
139:
140:
141: sccReset ();
142:
143: }
144:
145:
146:
147:
148: public static void sccTini () {
149: Settings.sgsPutInt ("sccfreq", (int) sccFreq);
150: }
151:
152:
153:
154: public static JMenu sccMakeMenu () {
155: ActionListener listener = new ActionListener () {
156: @Override public void actionPerformed (ActionEvent ae) {
157: Object source = ae.getSource ();
158: String command = ae.getActionCommand ();
159: switch (command) {
160: case "5MHz":
161: sccFreq = 5000000.0;
162: break;
163: case "7.3728MHz":
164: sccFreq = 7372800.0;
165: break;
166: case "Port 0B":
167: if (SCC_DEBUG_ON) {
168: sccDebugOn = ((sccDebugOn & ~1) |
169: (((JCheckBoxMenuItem) source).isSelected () ? 1 : 0));
170: }
171: break;
172: case "Port 1A":
173: if (SCC_DEBUG_ON) {
174: sccDebugOn = ((sccDebugOn & ~2) |
175: (((JCheckBoxMenuItem) source).isSelected () ? 2 : 0));
176: }
177: break;
178: case "Interrupt":
179: if (SCC_DEBUG_ON) {
180: sccDebugOn = ((sccDebugOn & ~4) |
181: (((JCheckBoxMenuItem) source).isSelected () ? 4 : 0));
182: }
183: break;
184: default:
185: System.out.println ("unknown action command " + command);
186: }
187: }
188: };
189: ButtonGroup freqGroup = new ButtonGroup ();
190: return ComponentFactory.createMenu (
191: "SCC",
192: ComponentFactory.createRadioButtonMenuItem (
193: freqGroup,
194: sccFreq == 5000000.0,
195: "5MHz",
196: listener),
197: ComponentFactory.createRadioButtonMenuItem (
198: freqGroup,
199: sccFreq == 7372800.0,
200: "7.3728MHz",
201: listener),
202: !SCC_DEBUG_ON ? null :
203: ComponentFactory.createHorizontalSeparator (),
204: !SCC_DEBUG_ON ? null :
205: ComponentFactory.createMenu (
206: "Debug",
207: ComponentFactory.createCheckBoxMenuItem (
208: (sccDebugOn & 1) != 0, "Port 0B", listener),
209: ComponentFactory.createCheckBoxMenuItem (
210: (sccDebugOn & 2) != 0, "Port 1A", listener),
211: ComponentFactory.createCheckBoxMenuItem (
212: (sccDebugOn & 4) != 0, "Interrupt", listener)
213: )
214: );
215: }
216:
217:
218:
219: public static void sccReset () {
220:
221: sccInterruptVector = 0x00;
222: sccVectorInclude = 0x00;
223: sccMIE = 0;
224: scc0bReceiveMask = 0;
225: scc0bReceiveRR3 = 0;
226: scc0bReceiveRequest = 0;
227: scc0bReceiveVector = 0;
228: scc1aReceiveMask = 0;
229: scc1aReceiveRR3 = 0;
230: scc1aReceiveRequest = 0;
231: scc1aReceiveVector = 0;
232: scc1aSendMask = 0;
233: scc1aSendRR3 = 0;
234: scc1aSendRequest = 0;
235: scc1aSendVector = 0;
236:
237: scc0bRegisterNumber = 0;
238: scc0bRts = 0;
239: scc0bBaudRateGen = 31;
240: scc0bInputCounter = 0;
241: scc0bData1 = 0;
242: scc0bData2 = 0;
243: if (SCC_FSX_MOUSE) {
244: sccFSXMouseHook = 0;
245: sccFSXMouseWork = 0;
246: }
247:
248: scc1aRegisterNumber = 0;
249: Arrays.fill (scc1aInputBuffer, 0);
250: scc1aInputRead = 0;
251: scc1aInputWrite = 0;
252: scc1aRxBits = 3;
253: scc1aRxEnable = 0;
254: scc1aStop = 1;
255: scc1aParity = 0;
256: scc1aTxBits = 3;
257: scc1aTxEnable = 0;
258: scc1aBRGEnable = 0;
259: scc1aClockModeShift = 4;
260: scc1aBaudRateGen = 14;
261: double rate = sccFreq / (double) ((scc1aBaudRateGen + 2) << (scc1aClockModeShift + 1));
262: double bits = (1.0 +
263: (scc1aRxBits == 0 ? 5.0 :
264: scc1aRxBits == 1 ? 7.0 :
265: scc1aRxBits == 2 ? 6.0 : 8.0) +
266: ((scc1aParity & 1) == 0 ? 0.0 : 1.0) +
267: (scc1aStop == 0 ? 0.0 :
268: scc1aStop == 1 ? 1.0 :
269: scc1aStop == 2 ? 1.5 : 2.0));
270: double interval = bits / rate;
271: scc1aInterval = Math.round (interval * (double) XEiJ.TMR_FREQ);
272:
273: RS232CTerminal.trmAUXReset ();
274: }
275:
276:
277:
278:
279:
280:
281: public static int sccAcknowledge () {
282: int d = 0;
283:
284: if (scc1aReceiveRequest != 0) {
285: scc1aReceiveRequest = 0;
286: d = scc1aReceiveVector;
287: } else if (scc1aSendRequest != 0) {
288: scc1aSendRequest = 0;
289: d = scc1aSendVector;
290: } else if (scc0bReceiveRequest != 0) {
291: scc0bReceiveRequest = 0;
292: d = scc0bReceiveVector;
293: }
294: if (SCC_DEBUG_ON && (sccDebugOn & 4) != 0) {
295: System.out.printf ("%08x sccAcknowledge()=0x%02x\n", XEiJ.regPC0, d);
296: }
297: return d;
298: }
299:
300:
301:
302:
303: public static void sccDone () {
304: if (SCC_DEBUG_ON && (sccDebugOn & 4) != 0) {
305: System.out.printf ("%08x sccDone()\n", XEiJ.regPC0);
306: }
307: if ((scc1aReceiveRequest | scc1aSendRequest | scc0bReceiveRequest) != 0) {
308: XEiJ.mpuIRR |= XEiJ.MPU_SCC_INTERRUPT_MASK;
309: }
310: }
311:
312:
313:
314:
315: public static void sccUpdateVector () {
316: if (sccVectorInclude == 0x00) {
317: scc0bReceiveVector = sccInterruptVector;
318: scc1aReceiveVector = sccInterruptVector;
319: scc1aSendVector = sccInterruptVector;
320: } else if (sccVectorInclude == 0x01) {
321: int t = sccInterruptVector & 0b11110001;
322: scc0bReceiveVector = t | SCC_0B_RECEIVE_VECTOR << 1;
323: scc1aReceiveVector = t | SCC_1A_RECEIVE_VECTOR << 1;
324: scc1aSendVector = t | SCC_1A_SEND_VECTOR << 1;
325: } else {
326: int t = sccInterruptVector & 0b10001111;
327: scc0bReceiveVector = t | SCC_0B_RECEIVE_VECTOR << 4;
328: scc1aReceiveVector = t | SCC_1A_RECEIVE_VECTOR << 4;
329: scc1aSendVector = t | SCC_1A_SEND_VECTOR << 4;
330: }
331: if (SCC_DEBUG_ON && (sccDebugOn & 4) != 0) {
332: System.out.printf ("scc0bReceiveVector=0x%02x\n", scc0bReceiveVector);
333: System.out.printf ("scc1aReceiveVector=0x%02x\n", scc1aReceiveVector);
334: System.out.printf ("scc1aSendVector=0x%02x\n", scc1aSendVector);
335: }
336: }
337:
338:
339:
340: public static int sccReadByte (int a, boolean peek) {
341: XEiJ.mpuClockTime += XEiJ.busWaitTime.scc;
342: int d = 0;
343: switch (a & 7) {
344:
345: case SCC_0B_COMMAND & 7:
346: switch (scc0bRegisterNumber) {
347: case 0:
348:
349:
350:
351:
352:
353:
354:
355:
356: d = (RS232CTerminal.trmMUSReadRR0 () |
357: 1 << 2 |
358: (scc0bInputCounter < 3 ? 1 << 0 : 0 << 0));
359: break;
360: case 2:
361:
362:
363: d = (scc1aReceiveRequest != 0 ? scc1aReceiveVector :
364: scc1aSendRequest != 0 ? scc1aSendVector :
365: scc0bReceiveRequest != 0 ? scc0bReceiveVector :
366: sccInterruptVector);
367: break;
368: case 3:
369:
370:
371:
372: break;
373: case 12:
374: d = scc0bBaudRateGen & 0xff;
375: break;
376: case 13:
377: d = scc0bBaudRateGen >> 8 & 0xff;
378: break;
379: default:
380: if (SCC_DEBUG_ON && sccDebugOn != 0) {
381: System.out.println ("unimplemented register");
382: }
383: }
384: if (peek) {
385: break;
386: }
387: scc0bRegisterNumber = 0;
388: break;
389:
390: case SCC_0B_DATA & 7:
391: if (scc0bInputCounter == 0) {
392: d = Mouse.musExtraData;
393: if (XEiJ.mpuClockTime < Mouse.musWheelReleaseTime) {
394: d |= Mouse.musWheelButton;
395: }
396: if (peek) {
397: break;
398: }
399: Mouse.musExtraData = Mouse.musData;
400: if (!Mouse.musOnScreen) {
401:
402: if (Mouse.musCursorNumber != 1 && Mouse.musCursorAvailable) {
403: Mouse.musCursorNumber = 1;
404: XEiJ.pnlPanel.setCursor (Mouse.musCursorArray[1]);
405: }
406: scc0bData1 = scc0bData2 = 0;
407: } else if (Mouse.musSeamlessOn) {
408: int on, dx, dy, coeff = 256;
409: if (XEiJ.currentMPU < Model.MPU_MC68LC040) {
410: if (SCC_FSX_MOUSE &&
411: sccFSXMouseHook != 0 &&
412: MainMemory.mmrRls (0x0938) == sccFSXMouseHook) {
413: on = MainMemory.mmrRws (sccFSXMouseWork + 0x2e) == 0 ? 1 : 0;
414: int xy = MainMemory.mmrRls (sccFSXMouseWork + 0x0a);
415: dx = (xy >> 16) - CRTC.crtR10TxXPort;
416: dy = (short) xy - CRTC.crtR11TxYPort;
417: coeff = MainMemory.mmrRwz (sccFSXMouseWork + 0x04);
418: } else {
419: on = MainMemory.mmrRbs (0x0aa2);
420: int xy = MainMemory.mmrRls (0x0ace);
421: dx = xy >> 16;
422: dy = (short) xy;
423: if (Mouse.musFollowScrollOn) {
424: dx -= CRTC.crtR10TxXPort;
425: dy -= CRTC.crtR11TxYPort;
426: }
427: }
428: } else {
429: if (SCC_FSX_MOUSE &&
430: sccFSXMouseHook != 0 &&
431: MC68060.mmuPeekLongData (0x0938, 1) == sccFSXMouseHook) {
432: on = MC68060.mmuPeekWordSignData (sccFSXMouseWork + 0x2e, 1) == 0 ? 1 : 0;
433: int xy = MC68060.mmuPeekLongData (sccFSXMouseWork + 0x0a, 1);
434: dx = (xy >> 16) - CRTC.crtR10TxXPort;
435: dy = (short) xy - CRTC.crtR11TxYPort;
436: coeff = MC68060.mmuPeekWordZeroData (sccFSXMouseWork + 0x04, 1);
437: } else {
438: on = MC68060.mmuPeekByteSignData (0x0aa2, 1);
439: int xy = MC68060.mmuPeekLongData (0x0ace, 1);
440: dx = xy >> 16;
441: dy = (short) xy;
442: if (Mouse.musFollowScrollOn) {
443: dx -= CRTC.crtR10TxXPort;
444: dy -= CRTC.crtR11TxYPort;
445: }
446: }
447: }
448: dx = Mouse.musScreenX - dx;
449: dy = Mouse.musScreenY - dy;
450: if (Mouse.musEdgeAccelerationOn) {
451: final int range = 10;
452: final int speed = 10;
453: if (Mouse.musScreenX < range) {
454: dx = -speed;
455: } else if (XEiJ.pnlScreenWidth - range <= Mouse.musScreenX) {
456: dx = speed;
457: }
458: if (Mouse.musScreenY < range) {
459: dy = -speed;
460: } else if (XEiJ.pnlScreenHeight - range <= Mouse.musScreenY) {
461: dy = speed;
462: }
463: }
464: if (on != 0) {
465:
466: if (Mouse.musCursorNumber != 0 && Mouse.musCursorAvailable) {
467: Mouse.musCursorNumber = 0;
468: XEiJ.pnlPanel.setCursor (Mouse.musCursorArray[0]);
469: }
470: } else {
471:
472: if (Mouse.musCursorNumber != 1 && Mouse.musCursorAvailable) {
473: Mouse.musCursorNumber = 1;
474: XEiJ.pnlPanel.setCursor (Mouse.musCursorArray[1]);
475: }
476: }
477: if (coeff != 256 && coeff != 0) {
478:
479: dx = (dx << 8) / coeff;
480: dy = (dy << 8) / coeff;
481: }
482:
483:
484: scc0bData1 = (dx == 0 ? 0 : dx >= 0 ?
485: Mouse.MUS_DEACCELERATION_TABLE[Math.min (1024, dx)] :
486: -Mouse.MUS_DEACCELERATION_TABLE[Math.min (1024, -dx)] & 0xff);
487: scc0bData2 = (dy == 0 ? 0 : dy >= 0 ?
488: Mouse.MUS_DEACCELERATION_TABLE[Math.min (1024, dy)] :
489: -Mouse.MUS_DEACCELERATION_TABLE[Math.min (1024, -dy)] & 0xff);
490: } else if (!XEiJ.frmIsActive) {
491:
492: if (Mouse.musCursorNumber != 1 && Mouse.musCursorAvailable) {
493: Mouse.musCursorNumber = 1;
494: XEiJ.pnlPanel.setCursor (Mouse.musCursorArray[1]);
495: }
496: scc0bData1 = scc0bData2 = 0;
497: Mouse.musExclusiveStart = true;
498: } else {
499:
500: if (Mouse.musCursorNumber != 0 && Mouse.musCursorAvailable) {
501: Mouse.musCursorNumber = 0;
502: XEiJ.pnlPanel.setCursor (Mouse.musCursorArray[0]);
503: }
504: int dx, dy;
505: if (XEiJ.PNL_ROTATION_ON) {
506: int ox = (XEiJ.pnlScreenX1 + XEiJ.pnlScreenX2) >> 1;
507: int oy = (XEiJ.pnlScreenY1 + XEiJ.pnlScreenY2) >> 1;
508: int tx = Mouse.musPanelX - ox;
509: int ty = Mouse.musPanelY - oy;
510: XEiJ.rbtRobot.mouseMove (XEiJ.pnlGlobalX + ox,
511: XEiJ.pnlGlobalY + oy);
512: dx = (int) Math.round (XEiJ.pnlInverseL00 * (double) tx + XEiJ.pnlInverseL01 * (double) ty);
513: dy = (int) Math.round (XEiJ.pnlInverseL10 * (double) tx + XEiJ.pnlInverseL11 * (double) ty);
514: } else {
515: int ox = XEiJ.pnlScreenX1 + (XEiJ.pnlZoomWidth >> 1);
516: int oy = XEiJ.pnlScreenY1 + (XEiJ.pnlZoomHeight >> 1);
517: XEiJ.rbtRobot.mouseMove (XEiJ.pnlGlobalX + ox, XEiJ.pnlGlobalY + oy);
518: dx = Mouse.musPanelX - ox;
519: dy = Mouse.musPanelY - oy;
520: }
521: if (Mouse.musExclusiveStart) {
522:
523:
524: dx = 0;
525: dy = 0;
526: Mouse.musExclusiveStart = false;
527: }
528:
529:
530: if (dx != 0) {
531: if (dx >= 0) {
532:
533: dx = dx * Mouse.musSpeedRatioX >> 16;
534: if (127 < dx) {
535: d |= 0x10;
536: dx = 127;
537: }
538: } else {
539:
540: dx = -(-dx * Mouse.musSpeedRatioX >> 16);
541: if (dx < -128) {
542: d |= 0x20;
543: dx = -128;
544: }
545: dx &= 0xff;
546: }
547: }
548: if (dy != 0) {
549: if (dy >= 0) {
550:
551: dy = dy * Mouse.musSpeedRatioY >> 16;
552: if (127 < dy) {
553: d |= 0x40;
554: dy = 127;
555: }
556: } else {
557:
558: dy = -(-dy * Mouse.musSpeedRatioY >> 16);
559: if (dy < -128) {
560: d |= 0x80;
561: dy = -128;
562: }
563: dy &= 0xff;
564: }
565: }
566: scc0bData1 = dx;
567: scc0bData2 = dy;
568: }
569: scc0bInputCounter = 1;
570: } else if (scc0bInputCounter == 1) {
571: d = scc0bData1;
572: if (peek) {
573: break;
574: }
575: scc0bInputCounter = 2;
576: } else if (scc0bInputCounter == 2) {
577: d = scc0bData2;
578: if (peek) {
579: break;
580: }
581: scc0bInputCounter = 3;
582: }
583: break;
584:
585: case SCC_1A_COMMAND & 7:
586: switch (scc1aRegisterNumber) {
587: case 0:
588: d = RS232CTerminal.trmAUXReadRR0 ();
589: break;
590: case 2:
591:
592:
593: d = sccInterruptVector;
594: break;
595: case 3:
596:
597:
598:
599: d = scc1aReceiveRR3 | scc1aSendRR3 | scc0bReceiveRR3;
600: break;
601: case 12:
602: d = scc1aBaudRateGen & 0xff;
603: break;
604: case 13:
605: d = scc1aBaudRateGen >> 8 & 0xff;
606: break;
607: default:
608: if (SCC_DEBUG_ON && sccDebugOn != 0) {
609: System.out.println ("unimplemented register");
610: }
611: }
612: if (peek) {
613: break;
614: }
615: scc1aRegisterNumber = 0;
616: break;
617:
618: case SCC_1A_DATA & 7:
619: d = RS232CTerminal.trmAUXReadData ();
620: break;
621:
622: default:
623: d = 0xff;
624: }
625: if (SCC_DEBUG_ON && ((a & 4) == 0 ? (sccDebugOn & 1) != 0 : (sccDebugOn & 2) != 0)) {
626: System.out.printf ("%08x sccRead(0x%08x)=0x%02x\n", XEiJ.regPC0, a, d);
627: }
628: return d;
629: }
630:
631:
632:
633:
634:
635: public static void sccWriteByte (int a, int d) {
636: XEiJ.mpuClockTime += XEiJ.busWaitTime.scc;
637: d &= 0xff;
638: if (SCC_DEBUG_ON && ((a & 4) == 0 ? (sccDebugOn & 1) != 0 : (sccDebugOn & 2) != 0)) {
639: System.out.printf ("%08x sccWrite(0x%08x,0x%02x)\n", XEiJ.regPC0, a, d);
640: }
641: switch (a & 7) {
642:
643: case SCC_0B_COMMAND & 7:
644: switch (scc0bRegisterNumber) {
645: case 0:
646: if ((d & 0xf0) == 0) {
647: scc0bRegisterNumber = d;
648: } else if (d == 0x38) {
649: if (scc0bReceiveRR3 != 0) {
650: scc0bReceiveRR3 = 0;
651: if (scc0bInputCounter < 3) {
652: if (scc0bReceiveMask != 0) {
653: scc0bReceiveRR3 = SCC_0B_RECEIVE_MASK;
654: scc0bReceiveRequest = SCC_0B_RECEIVE_MASK;
655: XEiJ.mpuIRR |= XEiJ.MPU_SCC_INTERRUPT_MASK;
656: }
657: }
658: }
659: } else if (d == 0x10) {
660: } else if (d == 0x30) {
661: } else if (d == 0x80) {
662: } else {
663: if (SCC_DEBUG_ON && sccDebugOn != 0) {
664: System.out.println ("unimplemented command");
665: }
666: }
667: return;
668: case 1:
669: scc0bReceiveMask = (d & 0x18) != 0 ? SCC_0B_RECEIVE_MASK : 0;
670: if ((d & 0xec) != 0x00) {
671: if (SCC_DEBUG_ON && sccDebugOn != 0) {
672: System.out.println ("unimplemented interrupt mode");
673: }
674: }
675: break;
676: case 2:
677: sccInterruptVector = d;
678: if (SCC_DEBUG_ON && sccDebugOn != 0) {
679: System.out.printf ("sccInterruptVector=0x%02x\n", sccInterruptVector);
680: }
681: sccUpdateVector ();
682: break;
683: case 3:
684: if (d == 0xc0) {
685: } else if (d == 0xc1) {
686: } else {
687: if (SCC_DEBUG_ON && sccDebugOn != 0) {
688: System.out.println ("unimplemented receiver configuration");
689: }
690: }
691: break;
692: case 4:
693: break;
694: case 5:
695:
696:
697:
698:
699:
700:
701:
702: {
703: int rts = d >> 1 & 1;
704: if ((~scc0bRts & rts) != 0) {
705: scc0bInputCounter = 0;
706:
707: if ((sccMIE & scc0bReceiveMask) != 0) {
708: scc0bReceiveRR3 = SCC_0B_RECEIVE_MASK;
709: scc0bReceiveRequest = SCC_0B_RECEIVE_MASK;
710: XEiJ.mpuIRR |= XEiJ.MPU_SCC_INTERRUPT_MASK;
711: }
712: }
713: scc0bRts = rts;
714: if ((d & 0x75) == 0x60) {
715: } else {
716: if (SCC_DEBUG_ON && sccDebugOn != 0) {
717: System.out.println ("unimplemented sender configuration");
718: }
719: }
720: }
721: break;
722: case 6:
723: break;
724: case 7:
725: break;
726: case 9:
727: sccWriteWR9 (d);
728: break;
729: case 10:
730: if (d == 0x00) {
731: } else {
732: if (SCC_DEBUG_ON && sccDebugOn != 0) {
733: System.out.println ("unimplemented SDLC configuration");
734: }
735: }
736: break;
737: case 11:
738: if (d == 0x50) {
739: } else if (d == 0x56) {
740: } else {
741: if (SCC_DEBUG_ON && sccDebugOn != 0) {
742: System.out.println ("unimplemented clock control");
743: }
744: }
745: break;
746: case 12:
747: scc0bBaudRateGen = (scc0bBaudRateGen & ~0xff) | d;
748: break;
749: case 13:
750: scc0bBaudRateGen = d << 8 | (scc0bBaudRateGen & 0xff);
751: break;
752: case 14:
753: if (d == 0x02) {
754: } else if (d == 0x03) {
755: } else {
756: if (SCC_DEBUG_ON && sccDebugOn != 0) {
757: System.out.println ("unimplemented DPLL configuration");
758: }
759: }
760: break;
761: case 15:
762: if (d == 0x00) {
763: } else if (d == 0x80) {
764: } else if (d == 0x88) {
765: } else {
766: if (SCC_DEBUG_ON && sccDebugOn != 0) {
767: System.out.println ("unimplemented status interrupt configuration");
768: }
769: }
770: break;
771: default:
772: if (SCC_DEBUG_ON && sccDebugOn != 0) {
773: System.out.println ("unimplemented register");
774: }
775: }
776: scc0bRegisterNumber = 0;
777: return;
778:
779: case SCC_0B_DATA & 7:
780: return;
781:
782: case SCC_1A_COMMAND & 7:
783: switch (scc1aRegisterNumber) {
784: case 0:
785: if ((d & 0xf0) == 0) {
786: scc1aRegisterNumber = d;
787: } else if (d == 0x38) {
788: if (scc1aReceiveRR3 != 0) {
789: scc1aReceiveRR3 = 0;
790: } else if (scc1aSendRR3 != 0) {
791: scc1aSendRR3 = 0;
792: }
793: } else if (d == 0x10) {
794: } else if (d == 0x30) {
795: } else if (d == 0x80) {
796: } else {
797: if (SCC_DEBUG_ON && sccDebugOn != 0) {
798: System.out.println ("unimplemented command");
799: }
800: }
801: return;
802: case 1:
803:
804:
805:
806:
807:
808:
809:
810:
811:
812:
813:
814:
815: scc1aReceiveMask = (d & 0x18) != 0 ? SCC_1A_RECEIVE_MASK : 0;
816: scc1aSendMask = (d & 0x02) != 0 ? SCC_1A_SEND_MASK : 0;
817: if ((d & 0xe3) != 0x00) {
818: if (SCC_DEBUG_ON && sccDebugOn != 0) {
819: System.out.println ("unimplemented interrupt mode");
820: }
821: }
822: break;
823: case 2:
824: sccInterruptVector = d;
825: if (SCC_DEBUG_ON && sccDebugOn != 0) {
826: System.out.printf ("sccInterruptVector=0x%02x\n", sccInterruptVector);
827: }
828: sccUpdateVector ();
829: break;
830: case 3:
831:
832:
833:
834:
835:
836:
837:
838:
839:
840:
841:
842:
843: if ((d & 0x3e) == 0x00) {
844: scc1aRxBits = d >> 6;
845: } else {
846: if (SCC_DEBUG_ON && sccDebugOn != 0) {
847: System.out.println ("unimplemented receiver configuration");
848: }
849: }
850: break;
851: case 4:
852:
853:
854:
855:
856:
857:
858:
859:
860:
861:
862:
863:
864:
865:
866:
867:
868:
869: scc1aClockModeShift = d >> 6 == 0 ? 0 : (d >> 6) + 3;
870: scc1aStop = d >> 2 & 3;
871: scc1aParity = d & 3;
872: break;
873: case 5:
874:
875:
876:
877:
878:
879:
880:
881:
882:
883:
884:
885:
886:
887:
888:
889: RS232CTerminal.trmAUXSetNotReceiving ((d & 0x02) == 0);
890: scc1aTxBits = d >> 5 & 3;
891: scc1aTxEnable = d >> 3 & 1;
892: RS232CTerminal.trmAUXSetDTR ((d & 0x80) != 0);
893: if ((d & 0x15) != 0x00) {
894: if (SCC_DEBUG_ON && sccDebugOn != 0) {
895: System.out.println ("unimplemented sender configuration");
896: }
897: }
898: break;
899: case 6:
900: break;
901: case 7:
902: break;
903: case 9:
904: sccWriteWR9 (d);
905: break;
906: case 10:
907: if (d == 0x00) {
908: } else {
909: if (SCC_DEBUG_ON && sccDebugOn != 0) {
910: System.out.println ("unimplemented SDLC configuration");
911: }
912: }
913: break;
914: case 11:
915: if (d == 0x50) {
916: } else if (d == 0x56) {
917: } else {
918: if (SCC_DEBUG_ON && sccDebugOn != 0) {
919: System.out.println ("unimplemented clock control");
920: }
921: }
922: break;
923: case 12:
924:
925:
926:
927:
928:
929:
930:
931:
932:
933:
934:
935:
936:
937:
938:
939:
940: scc1aBaudRateGen = (scc1aBaudRateGen & ~0xff) | d;
941: break;
942: case 13:
943:
944:
945:
946: scc1aBaudRateGen = d << 8 | (scc1aBaudRateGen & 0xff);
947: break;
948: case 14:
949:
950:
951:
952:
953:
954:
955:
956:
957:
958:
959:
960:
961:
962:
963:
964:
965:
966: if ((d & 0xfe) == 0x02) {
967: scc1aBRGEnable = d & 1;
968: if (scc1aBRGEnable != 0) {
969:
970:
971:
972:
973:
974:
975:
976:
977: RS232CTerminal.trmReflectSettings (1);
978: }
979: } else {
980: if (SCC_DEBUG_ON && sccDebugOn != 0) {
981: System.out.println ("unimplemented DPLL configuration");
982: }
983: }
984: break;
985: case 15:
986:
987:
988:
989:
990:
991:
992:
993:
994:
995:
996:
997:
998:
999:
1000:
1001: if (d == 0x00) {
1002: } else if (d == 0x80) {
1003: } else if (d == 0x88) {
1004: } else {
1005: if (SCC_DEBUG_ON && sccDebugOn != 0) {
1006: System.out.println ("unimplemented status interrupt configuration");
1007: }
1008: }
1009: break;
1010: default:
1011: if (SCC_DEBUG_ON && sccDebugOn != 0) {
1012: System.out.println ("unimplemented register");
1013: }
1014: }
1015: scc1aRegisterNumber = 0;
1016: return;
1017:
1018: case SCC_1A_DATA & 7:
1019: RS232CTerminal.trmAUXWriteData (d);
1020: return;
1021:
1022: default:
1023: ;
1024: }
1025: }
1026:
1027:
1028:
1029:
1030:
1031:
1032:
1033:
1034:
1035:
1036:
1037:
1038:
1039:
1040:
1041:
1042: public static void sccWriteWR9 (int d) {
1043:
1044: switch (d & 0xc0) {
1045: case 0x40:
1046: scc0bRts = 0;
1047: break;
1048: case 0x80:
1049: scc1aBRGEnable = 0;
1050: scc1aRxEnable = 0;
1051: scc1aTxEnable = 0;
1052: RS232CTerminal.trmAUXReset ();
1053: break;
1054: case 0xc0:
1055: scc0bRts = 0;
1056: scc1aBRGEnable = 0;
1057: scc1aRxEnable = 0;
1058: scc1aTxEnable = 0;
1059: RS232CTerminal.trmAUXReset ();
1060: break;
1061: }
1062:
1063: sccVectorInclude = d & 0x11;
1064: if (SCC_DEBUG_ON && sccDebugOn != 0) {
1065: System.out.printf ("sccVectorInclude=0x%02x\n", sccVectorInclude);
1066: }
1067: sccUpdateVector ();
1068: sccMIE = (d & 0x08) != 0 ? -1 : 0;
1069: if ((d & 0x26) != 0) {
1070: if (SCC_DEBUG_ON && sccDebugOn != 0) {
1071: System.out.println ("unimplemented interrupt configuration");
1072: }
1073: }
1074: }
1075:
1076:
1077: }
1078:
1079:
1080: