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