MC68901.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13: package xeij;
14:
15: import java.lang.*;
16:
17: public class MC68901 {
18:
19: public static final boolean MFP_DELAYED_INTERRUPT = true;
20:
21:
22: public static final int MFP_GPIP_DATA = 0x00e88001;
23: public static final int MFP_AER = 0x00e88003;
24: public static final int MFP_DDR = 0x00e88005;
25: public static final int MFP_IERA = 0x00e88007;
26: public static final int MFP_IERB = 0x00e88009;
27: public static final int MFP_IPRA = 0x00e8800b;
28: public static final int MFP_IPRB = 0x00e8800d;
29: public static final int MFP_ISRA = 0x00e8800f;
30: public static final int MFP_ISRB = 0x00e88011;
31: public static final int MFP_IMRA = 0x00e88013;
32: public static final int MFP_IMRB = 0x00e88015;
33: public static final int MFP_VECTOR = 0x00e88017;
34: public static final int MFP_TACR = 0x00e88019;
35: public static final int MFP_TBCR = 0x00e8801b;
36: public static final int MFP_TCDCR = 0x00e8801d;
37:
38: public static final int MFP_TADR = 0x00e8801f;
39: public static final int MFP_TBDR = 0x00e88021;
40: public static final int MFP_TCDR = 0x00e88023;
41: public static final int MFP_TDDR = 0x00e88025;
42: public static final int MFP_SYNC_CHAR = 0x00e88027;
43: public static final int MFP_UCR = 0x00e88029;
44: public static final int MFP_RSR = 0x00e8802b;
45: public static final int MFP_TSR = 0x00e8802d;
46: public static final int MFP_UDR = 0x00e8802f;
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64: public static final int MFP_GPIP_ALARM_LEVEL = 0;
65: public static final int MFP_GPIP_EXPWON_LEVEL = 1;
66: public static final int MFP_GPIP_POWER_LEVEL = 2;
67: public static final int MFP_GPIP_OPMIRQ_LEVEL = 3;
68: public static final int MFP_GPIP_VDISP_LEVEL = 4;
69: public static final int MFP_GPIP_RINT_LEVEL = 6;
70: public static final int MFP_GPIP_HSYNC_LEVEL = 7;
71:
72:
73: public static final int MFP_GPIP_ALARM_MASK = 1 << MFP_GPIP_ALARM_LEVEL;
74: public static final int MFP_GPIP_EXPWON_MASK = 1 << MFP_GPIP_EXPWON_LEVEL;
75: public static final int MFP_GPIP_POWER_MASK = 1 << MFP_GPIP_POWER_LEVEL;
76: public static final int MFP_GPIP_OPMIRQ_MASK = 1 << MFP_GPIP_OPMIRQ_LEVEL;
77: public static final int MFP_GPIP_VDISP_MASK = 1 << MFP_GPIP_VDISP_LEVEL;
78: public static final int MFP_GPIP_RINT_MASK = 1 << MFP_GPIP_RINT_LEVEL;
79: public static final int MFP_GPIP_HSYNC_MASK = 1 << MFP_GPIP_HSYNC_LEVEL;
80:
81:
82: public static final int MFP_ALARM_LEVEL = 0;
83: public static final int MFP_EXPWON_LEVEL = 1;
84: public static final int MFP_POWER_LEVEL = 2;
85: public static final int MFP_OPMIRQ_LEVEL = 3;
86: public static final int MFP_TIMER_D_LEVEL = 4;
87: public static final int MFP_TIMER_C_LEVEL = 5;
88: public static final int MFP_VDISP_LEVEL = 6;
89: public static final int MFP_TIMER_B_LEVEL = 8;
90: public static final int MFP_OUTPUT_ERROR_LEVEL = 9;
91: public static final int MFP_OUTPUT_EMPTY_LEVEL = 10;
92: public static final int MFP_INPUT_ERROR_LEVEL = 11;
93: public static final int MFP_INPUT_FULL_LEVEL = 12;
94: public static final int MFP_TIMER_A_LEVEL = 13;
95: public static final int MFP_RINT_LEVEL = 14;
96: public static final int MFP_HSYNC_LEVEL = 15;
97:
98:
99: public static final int MFP_ALARM_MASK = 1 << MFP_ALARM_LEVEL;
100: public static final int MFP_EXPWON_MASK = 1 << MFP_EXPWON_LEVEL;
101: public static final int MFP_POWER_MASK = 1 << MFP_POWER_LEVEL;
102: public static final int MFP_OPMIRQ_MASK = 1 << MFP_OPMIRQ_LEVEL;
103: public static final int MFP_TIMER_D_MASK = 1 << MFP_TIMER_D_LEVEL;
104: public static final int MFP_TIMER_C_MASK = 1 << MFP_TIMER_C_LEVEL;
105: public static final int MFP_VDISP_MASK = 1 << MFP_VDISP_LEVEL;
106: public static final int MFP_TIMER_B_MASK = 1 << MFP_TIMER_B_LEVEL;
107: public static final int MFP_OUTPUT_ERROR_MASK = 1 << MFP_OUTPUT_ERROR_LEVEL;
108: public static final int MFP_OUTPUT_EMPTY_MASK = 1 << MFP_OUTPUT_EMPTY_LEVEL;
109: public static final int MFP_INPUT_ERROR_MASK = 1 << MFP_INPUT_ERROR_LEVEL;
110: public static final int MFP_INPUT_FULL_MASK = 1 << MFP_INPUT_FULL_LEVEL;
111: public static final int MFP_TIMER_A_MASK = 1 << MFP_TIMER_A_LEVEL;
112: public static final int MFP_RINT_MASK = 1 << MFP_RINT_LEVEL;
113: public static final int MFP_HSYNC_MASK = 1 << MFP_HSYNC_LEVEL;
114:
115: public static final long MFP_OSC_FREQ = 4000000L;
116:
117:
118: public static final long MFP_DELTA[] = {
119: XEiJ.FAR_FUTURE,
120: 4 * XEiJ.TMR_FREQ / MFP_OSC_FREQ,
121: 10 * XEiJ.TMR_FREQ / MFP_OSC_FREQ,
122: 16 * XEiJ.TMR_FREQ / MFP_OSC_FREQ,
123: 50 * XEiJ.TMR_FREQ / MFP_OSC_FREQ,
124: 64 * XEiJ.TMR_FREQ / MFP_OSC_FREQ,
125: 100 * XEiJ.TMR_FREQ / MFP_OSC_FREQ,
126: 200 * XEiJ.TMR_FREQ / MFP_OSC_FREQ,
127: };
128:
129:
130: public static final int MFP_UDR_QUEUE_BITS = 4;
131: public static final int MFP_UDR_QUEUE_SIZE = 1 << MFP_UDR_QUEUE_BITS;
132: public static final int MFP_UDR_QUEUE_MASK = MFP_UDR_QUEUE_SIZE - 1;
133:
134:
135:
136:
137: public static int mfpGpipAlarm;
138: public static int mfpGpipExpwon;
139: public static int mfpGpipPower;
140: public static int mfpGpipOpmirq;
141: public static int mfpGpipVdisp;
142: public static int mfpGpipRint;
143: public static int mfpGpipHsync;
144:
145:
146:
147: public static int mfpAer;
148: public static int mfpIer;
149: public static int mfpImr;
150: public static int mfpVectorHigh;
151: public static int mfpTaPrescale;
152: public static int mfpTbPrescale;
153: public static int mfpTcPrescale;
154: public static int mfpTdPrescale;
155: public static boolean mfpTaEventcount;
156: public static boolean mfpTbEventcount;
157: public static int mfpTaInitial;
158: public static int mfpTbInitial;
159: public static int mfpTcInitial;
160: public static int mfpTdInitial;
161: public static int mfpTaCurrent;
162: public static int mfpTbCurrent;
163: public static int mfpTcCurrent;
164: public static int mfpTdCurrent;
165: public static boolean mfpTbKeyboardOn;
166:
167: public static int mfpUCR;
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189: public static int mfpRSR;
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206: public static int mfpTSR;
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219: public static long mfpTSRBufferFullTime;
220: public static long mfpTSRBufferFullEnd;
221:
222:
223:
224:
225: public static final int[] mfpInnerRequest = new int[16];
226: public static final int[] mfpInnerAcknowledged = new int[16];
227: public static final boolean[] mfpInnerInService = new boolean[16];
228: public static int mfpInnerLevel;
229:
230:
231: public static long mfpTaStart;
232: public static long mfpTbStart;
233: public static long mfpTcStart;
234: public static long mfpTdStart;
235: public static long mfpTaDelta;
236: public static long mfpTbDelta;
237: public static long mfpTcDelta;
238: public static long mfpTdDelta;
239: public static long mfpTaClock;
240: public static long mfpTbClock;
241: public static long mfpTcClock;
242: public static long mfpTdClock;
243:
244:
245:
246:
247:
248:
249: public static final int[] mfpUdrQueueArray = new int[MFP_UDR_QUEUE_SIZE];
250: public static int mfpUdrQueueRead;
251: public static int mfpUdrQueueWrite;
252:
253:
254:
255: public static void mfpInit () {
256:
257:
258:
259:
260: for (int i = 0; i < MFP_UDR_QUEUE_SIZE; i++) {
261: mfpUdrQueueArray[i] = 0;
262: }
263: mfpUdrQueueRead = 0;
264: mfpUdrQueueWrite = 0;
265: mfpReset ();
266: }
267:
268:
269: public static void mfpReset () {
270: mfpGpipAlarm = 0;
271: mfpGpipExpwon = MFP_GPIP_EXPWON_MASK;
272: mfpGpipPower = 0;
273: mfpGpipOpmirq = MFP_GPIP_OPMIRQ_MASK;
274: mfpGpipVdisp = 0;
275: mfpGpipRint = MFP_GPIP_RINT_MASK;
276: mfpGpipHsync = 0;
277: mfpAer = 0;
278: mfpIer = 0;
279: for (int i = 0; i < 16; i++) {
280: mfpInnerRequest[i] = 0;
281: mfpInnerAcknowledged[i] = 0;
282: mfpInnerInService[i] = false;
283: }
284: mfpImr = 0;
285: mfpVectorHigh = 0;
286: mfpTaPrescale = 0;
287: mfpTbPrescale = 0;
288: mfpTcPrescale = 0;
289: mfpTdPrescale = 0;
290: mfpTaEventcount = false;
291: mfpTbEventcount = false;
292: mfpTaInitial = 256;
293: mfpTbInitial = 256;
294: mfpTcInitial = 256;
295: mfpTdInitial = 256;
296: mfpTaCurrent = 0;
297: mfpTbCurrent = 0;
298: mfpTcCurrent = 0;
299: mfpTdCurrent = 0;
300: mfpTaStart = 0L;
301: mfpTbStart = 0L;
302: mfpTcStart = 0L;
303: mfpTdStart = 0L;
304: mfpTaClock = XEiJ.FAR_FUTURE;
305: mfpTbClock = XEiJ.FAR_FUTURE;
306: mfpTcClock = XEiJ.FAR_FUTURE;
307: mfpTdClock = XEiJ.FAR_FUTURE;
308: mfpUCR = 0x88;
309: mfpRSR = 0x01;
310: mfpTSR = 0x01;
311: mfpTSRBufferFullTime = 0L;
312: mfpTSRBufferFullEnd = 0L;
313: if (MFP_KBD_ON) {
314:
315: mfpKbdReadPointer = 0;
316: mfpKbdWritePointer = 0;
317: mfpKbdLastData = 0;
318: mfpTkClock = XEiJ.FAR_FUTURE;
319:
320: }
321: TickerQueue.tkqRemove (mfpTaTicker);
322: TickerQueue.tkqRemove (mfpTbTicker);
323: TickerQueue.tkqRemove (mfpTcTicker);
324: TickerQueue.tkqRemove (mfpTdTicker);
325: TickerQueue.tkqRemove (mfpTkTicker);
326: }
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345: public static int mfpAcknowledge () {
346: for (int i = 15; i >= 0; i--) {
347: if ((mfpImr & 1 << i) != 0) {
348: int request = mfpInnerRequest[i];
349: if (mfpInnerAcknowledged[i] != request) {
350: mfpInnerAcknowledged[i] = request;
351: mfpInnerInService[mfpInnerLevel = i] = true;
352: return mfpVectorHigh + i;
353: }
354: }
355: }
356: return 0;
357: }
358:
359:
360:
361:
362: public static void mfpDone () {
363: mfpInnerInService[mfpInnerLevel] = false;
364: for (int i = 15; i >= 0; i--) {
365: if ((mfpImr & 1 << i) != 0 && mfpInnerAcknowledged[i] != mfpInnerRequest[i]) {
366: if (MFP_DELAYED_INTERRUPT) {
367: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
368: } else {
369: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
370: }
371: return;
372: }
373: }
374: }
375:
376:
377:
378:
379: public static void mfpKeyboardInput (int scanCode) {
380: if (!mfpTbKeyboardOn) {
381: return;
382: }
383: scanCode &= 0xff;
384: int write = mfpUdrQueueWrite + 1 & MFP_UDR_QUEUE_MASK;
385: if (mfpUdrQueueRead != write) {
386: mfpUdrQueueWrite = write;
387: mfpUdrQueueArray[mfpUdrQueueWrite] = scanCode;
388: if ((mfpIer & MFP_INPUT_FULL_MASK) != 0) {
389: mfpInnerRequest[MFP_INPUT_FULL_LEVEL]++;
390: if ((mfpImr & MFP_INPUT_FULL_MASK) != 0) {
391: if (MFP_DELAYED_INTERRUPT) {
392: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
393: } else {
394: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
395: }
396: }
397: }
398: }
399: }
400:
401:
402:
403: public static final TickerQueue.Ticker mfpTaTicker = new TickerQueue.Ticker () {
404: @Override protected void tick () {
405: if ((mfpIer & MFP_TIMER_A_MASK) != 0) {
406: mfpInnerRequest[MFP_TIMER_A_LEVEL]++;
407: if ((mfpImr & MFP_TIMER_A_MASK) != 0) {
408: if (MFP_DELAYED_INTERRUPT) {
409: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
410: } else {
411: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
412: }
413: }
414: }
415: mfpTaClock += mfpTaDelta * mfpTaInitial;
416: TickerQueue.tkqAdd (mfpTaTicker, mfpTaClock);
417: }
418: };
419:
420:
421: public static final TickerQueue.Ticker mfpTbTicker = new TickerQueue.Ticker () {
422: @Override protected void tick () {
423: if ((mfpIer & MFP_TIMER_B_MASK) != 0) {
424: mfpInnerRequest[MFP_TIMER_B_LEVEL]++;
425: if ((mfpImr & MFP_TIMER_B_MASK) != 0) {
426: if (MFP_DELAYED_INTERRUPT) {
427: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
428: } else {
429: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
430: }
431: }
432: }
433: mfpTbClock += mfpTbDelta * mfpTbInitial;
434: TickerQueue.tkqAdd (mfpTbTicker, mfpTbClock);
435: }
436: };
437:
438:
439: public static final TickerQueue.Ticker mfpTcTicker = new TickerQueue.Ticker () {
440: @Override protected void tick () {
441: if ((mfpIer & MFP_TIMER_C_MASK) != 0) {
442: mfpInnerRequest[MFP_TIMER_C_LEVEL]++;
443: if ((mfpImr & MFP_TIMER_C_MASK) != 0) {
444: if (MFP_DELAYED_INTERRUPT) {
445: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
446: } else {
447: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
448: }
449: }
450: }
451: mfpTcClock += mfpTcDelta * mfpTcInitial;
452: TickerQueue.tkqAdd (mfpTcTicker, mfpTcClock);
453: }
454: };
455:
456:
457: public static final TickerQueue.Ticker mfpTdTicker = new TickerQueue.Ticker () {
458: @Override protected void tick () {
459: if ((mfpIer & MFP_TIMER_D_MASK) != 0) {
460: mfpInnerRequest[MFP_TIMER_D_LEVEL]++;
461: if ((mfpImr & MFP_TIMER_D_MASK) != 0) {
462: if (MFP_DELAYED_INTERRUPT) {
463: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
464: } else {
465: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
466: }
467: }
468: }
469: mfpTdClock += mfpTdDelta * mfpTdInitial;
470: TickerQueue.tkqAdd (mfpTdTicker, mfpTdClock);
471: }
472: };
473:
474:
475: public static final TickerQueue.Ticker mfpTkTicker = new TickerQueue.Ticker () {
476: @Override protected void tick () {
477: if (MFP_KBD_ON) {
478:
479:
480: long time = System.currentTimeMillis () - 10L;
481: if (time < mfpTkTime) {
482: mfpTkClock = XEiJ.mpuClockTime + XEiJ.TMR_FREQ / 1000 * (mfpTkTime - time);
483: TickerQueue.tkqAdd (mfpTkTicker, mfpTkClock);
484: } else {
485: if (mfpTbKeyboardOn) {
486: if (mfpKbdReadPointer != mfpKbdWritePointer) {
487: if ((mfpIer & MFP_INPUT_FULL_MASK) != 0) {
488: mfpInnerRequest[MFP_INPUT_FULL_LEVEL]++;
489: if ((mfpImr & MFP_INPUT_FULL_MASK) != 0) {
490:
491: if (MFP_DELAYED_INTERRUPT) {
492: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
493: } else {
494: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
495: }
496: }
497: }
498: }
499: }
500: mfpTkClock = XEiJ.FAR_FUTURE;
501: TickerQueue.tkqRemove (mfpTkTicker);
502:
503: }
504: }
505: }
506: };
507:
508:
509:
510:
511:
512: public static void mfpAlarmRise () {
513: if (mfpGpipAlarm == 0) {
514: mfpGpipAlarm = MFP_GPIP_ALARM_MASK;
515: if ((mfpAer & MFP_GPIP_ALARM_MASK) != 0 && (mfpIer & MFP_ALARM_MASK) != 0) {
516: mfpInnerRequest[MFP_ALARM_LEVEL]++;
517: if ((mfpImr & MFP_ALARM_MASK) != 0) {
518: if (MFP_DELAYED_INTERRUPT) {
519: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
520: } else {
521: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
522: }
523: }
524: }
525: }
526: }
527: public static void mfpAlarmFall () {
528: if (mfpGpipAlarm != 0) {
529: mfpGpipAlarm = 0;
530: if ((mfpAer & MFP_GPIP_ALARM_MASK) == 0 && (mfpIer & MFP_ALARM_MASK) != 0) {
531: mfpInnerRequest[MFP_ALARM_LEVEL]++;
532: if ((mfpImr & MFP_ALARM_MASK) != 0) {
533: if (MFP_DELAYED_INTERRUPT) {
534: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
535: } else {
536: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
537: }
538: }
539: }
540: }
541: }
542:
543:
544: public static void mfpExpwonRise () {
545: if (mfpGpipExpwon == 0) {
546: mfpGpipExpwon = MFP_GPIP_EXPWON_MASK;
547: if ((mfpAer & MFP_GPIP_EXPWON_MASK) != 0 && (mfpIer & MFP_EXPWON_MASK) != 0) {
548: mfpInnerRequest[MFP_EXPWON_LEVEL]++;
549: if ((mfpImr & MFP_EXPWON_MASK) != 0) {
550: if (MFP_DELAYED_INTERRUPT) {
551: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
552: } else {
553: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
554: }
555: }
556: }
557: }
558: }
559: public static void mfpExpwonFall () {
560: if (mfpGpipExpwon != 0) {
561: mfpGpipExpwon = 0;
562: if ((mfpAer & MFP_GPIP_EXPWON_MASK) == 0 && (mfpIer & MFP_EXPWON_MASK) != 0) {
563: mfpInnerRequest[MFP_EXPWON_LEVEL]++;
564: if ((mfpImr & MFP_EXPWON_MASK) != 0) {
565: if (MFP_DELAYED_INTERRUPT) {
566: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
567: } else {
568: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
569: }
570: }
571: }
572: }
573: }
574:
575:
576: public static void mfpPowerRise () {
577: if (mfpGpipPower == 0) {
578: mfpGpipPower = MFP_GPIP_POWER_MASK;
579: if ((mfpAer & MFP_GPIP_POWER_MASK) != 0 && (mfpIer & MFP_POWER_MASK) != 0) {
580: mfpInnerRequest[MFP_POWER_LEVEL]++;
581: if ((mfpImr & MFP_POWER_MASK) != 0) {
582: if (MFP_DELAYED_INTERRUPT) {
583: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
584: } else {
585: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
586: }
587: }
588: }
589: }
590: }
591: public static void mfpPowerFall () {
592: if (mfpGpipPower != 0) {
593: mfpGpipPower = 0;
594: if ((mfpAer & MFP_GPIP_POWER_MASK) == 0 && (mfpIer & MFP_POWER_MASK) != 0) {
595: mfpInnerRequest[MFP_POWER_LEVEL]++;
596: if ((mfpImr & MFP_POWER_MASK) != 0) {
597: if (MFP_DELAYED_INTERRUPT) {
598: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
599: } else {
600: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
601: }
602: }
603: }
604: }
605: }
606:
607:
608: public static void mfpOpmirqRise () {
609: if (mfpGpipOpmirq == 0) {
610: mfpGpipOpmirq = MFP_GPIP_OPMIRQ_MASK;
611: if ((mfpAer & MFP_GPIP_OPMIRQ_MASK) != 0 && (mfpIer & MFP_OPMIRQ_MASK) != 0) {
612: mfpInnerRequest[MFP_OPMIRQ_LEVEL]++;
613: if ((mfpImr & MFP_OPMIRQ_MASK) != 0) {
614: if (MFP_DELAYED_INTERRUPT) {
615: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
616: } else {
617: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
618: }
619: }
620: }
621: }
622: }
623: public static void mfpOpmirqFall () {
624: if (mfpGpipOpmirq != 0) {
625: mfpGpipOpmirq = 0;
626: if ((mfpAer & MFP_GPIP_OPMIRQ_MASK) == 0 && (mfpIer & MFP_OPMIRQ_MASK) != 0) {
627: mfpInnerRequest[MFP_OPMIRQ_LEVEL]++;
628: if ((mfpImr & MFP_OPMIRQ_MASK) != 0) {
629: if (MFP_DELAYED_INTERRUPT) {
630: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
631: } else {
632: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
633: }
634: }
635: }
636: }
637: }
638:
639:
640: public static void mfpVdispRise () {
641:
642: mfpGpipVdisp = MFP_GPIP_VDISP_MASK;
643: if ((mfpAer & MFP_GPIP_VDISP_MASK) != 0) {
644: if ((mfpIer & MFP_VDISP_MASK) != 0) {
645: mfpInnerRequest[MFP_VDISP_LEVEL]++;
646: if ((mfpImr & MFP_VDISP_MASK) != 0) {
647: if (MFP_DELAYED_INTERRUPT) {
648: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
649: } else {
650: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
651: }
652: }
653: }
654: if (mfpTaEventcount && --mfpTaCurrent <= 0) {
655: mfpTaCurrent = mfpTaInitial;
656: if ((mfpIer & MFP_TIMER_A_MASK) != 0) {
657: mfpInnerRequest[MFP_TIMER_A_LEVEL]++;
658: if ((mfpImr & MFP_TIMER_A_MASK) != 0) {
659: if (MFP_DELAYED_INTERRUPT) {
660: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
661: } else {
662: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
663: }
664: }
665: }
666: }
667: }
668:
669: }
670: public static void mfpVdispFall () {
671:
672: mfpGpipVdisp = 0;
673: if ((mfpAer & MFP_GPIP_VDISP_MASK) == 0) {
674: if ((mfpIer & MFP_VDISP_MASK) != 0) {
675: mfpInnerRequest[MFP_VDISP_LEVEL]++;
676: if ((mfpImr & MFP_VDISP_MASK) != 0) {
677: if (MFP_DELAYED_INTERRUPT) {
678: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
679: } else {
680: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
681: }
682: }
683: }
684: if (mfpTaEventcount && --mfpTaCurrent <= 0) {
685: mfpTaCurrent = mfpTaInitial;
686: if ((mfpIer & MFP_TIMER_A_MASK) != 0) {
687: mfpInnerRequest[MFP_TIMER_A_LEVEL]++;
688: if ((mfpImr & MFP_TIMER_A_MASK) != 0) {
689: if (MFP_DELAYED_INTERRUPT) {
690: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
691: } else {
692: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
693: }
694: }
695: }
696: }
697: }
698:
699: }
700:
701:
702: public static void mfpRintRise () {
703:
704: mfpGpipRint = MFP_GPIP_RINT_MASK;
705: if ((mfpAer & MFP_GPIP_RINT_MASK) != 0 && (mfpIer & MFP_RINT_MASK) != 0) {
706: mfpInnerRequest[MFP_RINT_LEVEL]++;
707: if ((mfpImr & MFP_RINT_MASK) != 0) {
708: if (MFP_DELAYED_INTERRUPT) {
709: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
710: } else {
711: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
712: }
713: }
714: }
715:
716: }
717: public static void mfpRintFall () {
718:
719: mfpGpipRint = 0;
720: if ((mfpAer & MFP_GPIP_RINT_MASK) == 0 && (mfpIer & MFP_RINT_MASK) != 0) {
721: mfpInnerRequest[MFP_RINT_LEVEL]++;
722: if ((mfpImr & MFP_RINT_MASK) != 0) {
723: if (MFP_DELAYED_INTERRUPT) {
724: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
725: } else {
726: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
727: }
728: }
729: }
730:
731: }
732:
733:
734: public static void mfpHsyncRise () {
735:
736: mfpGpipHsync = MFP_GPIP_HSYNC_MASK;
737: if ((mfpAer & MFP_GPIP_HSYNC_MASK) != 0 && (mfpIer & MFP_HSYNC_MASK) != 0) {
738: mfpInnerRequest[MFP_HSYNC_LEVEL]++;
739: if ((mfpImr & MFP_HSYNC_MASK) != 0) {
740: if (MFP_DELAYED_INTERRUPT) {
741: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
742: } else {
743: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
744: }
745: }
746: }
747:
748: }
749: public static void mfpHsyncFall () {
750:
751: mfpGpipHsync = 0;
752: if ((mfpAer & MFP_GPIP_HSYNC_MASK) == 0 && (mfpIer & MFP_HSYNC_MASK) != 0) {
753: mfpInnerRequest[MFP_HSYNC_LEVEL]++;
754: if ((mfpImr & MFP_HSYNC_MASK) != 0) {
755: if (MFP_DELAYED_INTERRUPT) {
756: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
757: } else {
758: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
759: }
760: }
761: }
762:
763: }
764:
765:
766:
767:
768:
769:
770:
771:
772:
773:
774:
775:
776:
777:
778:
779:
780:
781:
782:
783:
784:
785:
786:
787:
788:
789:
790:
791:
792:
793:
794:
795:
796:
797:
798:
799:
800:
801:
802:
803:
804:
805:
806:
807:
808:
809:
810:
811:
812:
813:
814:
815:
816:
817:
818:
819:
820:
821: public static final boolean MFP_KBD_ON = true;
822: public static final int MFP_KBD_LIMIT = 512;
823: public static final int[] mfpKbdBuffer = new int[MFP_KBD_LIMIT];
824: public static int mfpKbdReadPointer;
825: public static int mfpKbdWritePointer;
826: public static int mfpKbdLastData;
827: public static long mfpTkClock;
828: public static long mfpTkTime;
829:
830:
831:
832:
833:
834: public static void mfpKbdInput (int data, boolean repeat) {
835: if (!mfpTbKeyboardOn) {
836: return;
837: }
838: int w = mfpKbdWritePointer;
839: int w1 = w + 2 & MFP_KBD_LIMIT - 2;
840: if (w1 != mfpKbdReadPointer) {
841: mfpKbdBuffer[w] = data;
842: mfpKbdBuffer[w + 1] = repeat ? 1 : 0;
843: mfpKbdWritePointer = w1;
844: if ((mfpIer & MFP_INPUT_FULL_MASK) != 0) {
845: mfpInnerRequest[MFP_INPUT_FULL_LEVEL]++;
846: if ((mfpImr & MFP_INPUT_FULL_MASK) != 0) {
847:
848: if (MFP_DELAYED_INTERRUPT) {
849: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
850: } else {
851: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
852: }
853: }
854: }
855: }
856: }
857:
858:
859:
860: public static int mfpKbdReadData () {
861: int r = mfpKbdReadPointer;
862: int w = mfpKbdWritePointer;
863: if (r != w) {
864: int r1 = r + 2 & MFP_KBD_LIMIT - 2;
865: int s = mfpKbdBuffer[r + 1];
866: if (r1 != w && s < 0) {
867: mfpKbdReadPointer = r = r1;
868: r1 = r + 2 & MFP_KBD_LIMIT - 2;
869: s = mfpKbdBuffer[r + 1];
870: }
871: mfpKbdLastData = mfpKbdBuffer[r];
872: if (r1 != w) {
873: mfpKbdReadPointer = r1;
874: if ((mfpIer & MFP_INPUT_FULL_MASK) != 0) {
875: mfpInnerRequest[MFP_INPUT_FULL_LEVEL]++;
876: if ((mfpImr & MFP_INPUT_FULL_MASK) != 0) {
877:
878: if (MFP_DELAYED_INTERRUPT) {
879: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
880: } else {
881: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
882: }
883: }
884: }
885: } else if (s == 0) {
886: mfpKbdReadPointer = r1;
887: } else if (s > 0) {
888: mfpKbdBuffer[r + 1] = -1;
889: if ((mfpIer & MFP_INPUT_FULL_MASK) != 0) {
890: mfpTkClock = XEiJ.mpuClockTime + XEiJ.TMR_FREQ / 1000 * Keyboard.kbdRepeatDelay;
891: TickerQueue.tkqAdd (mfpTkTicker, mfpTkClock);
892: mfpTkTime = System.currentTimeMillis () + Keyboard.kbdRepeatDelay;
893: }
894: } else {
895: if ((mfpIer & MFP_INPUT_FULL_MASK) != 0) {
896: mfpTkClock = XEiJ.mpuClockTime + XEiJ.TMR_FREQ / 1000 * Keyboard.kbdRepeatInterval;
897: TickerQueue.tkqAdd (mfpTkTicker, mfpTkClock);
898: mfpTkTime = System.currentTimeMillis () + Keyboard.kbdRepeatInterval;
899: }
900: }
901: }
902: return mfpKbdLastData;
903: }
904:
905:
906:
907:
908: public static int mfpPeekByte (int a) {
909: try {
910: return (a & (XEiJ.BUS_MOTHER_MASK & 0xffff803f)) == MFP_UDR ? mfpUdrQueueArray[mfpUdrQueueRead] : mfpReadByte (a);
911: } catch (M68kException e) {
912: }
913: return 0;
914: }
915:
916:
917: public static int mfpReadByte (int a) throws M68kException {
918: XEiJ.mpuClockTime += XEiJ.busWaitTime.mfp;
919: switch (a & (XEiJ.BUS_MOTHER_MASK & 0xffff803f)) {
920: case MFP_GPIP_DATA:
921: return mfpGpipHsync | mfpGpipRint | 0b00100000 | mfpGpipVdisp | mfpGpipOpmirq | mfpGpipPower | mfpGpipExpwon | mfpGpipAlarm;
922: case MFP_AER:
923: return mfpAer;
924: case MFP_DDR:
925: return 0x00;
926: case MFP_IERA:
927: return mfpIer >>> 8;
928: case MFP_IERB:
929: return mfpIer & 0xff;
930: case MFP_IPRA:
931: return ((mfpInnerRequest[15] != mfpInnerAcknowledged[15] ? 0b10000000 : 0) |
932: (mfpInnerRequest[14] != mfpInnerAcknowledged[14] ? 0b01000000 : 0) |
933: (mfpInnerRequest[13] != mfpInnerAcknowledged[13] ? 0b00100000 : 0) |
934: (mfpInnerRequest[12] != mfpInnerAcknowledged[12] ? 0b00010000 : 0) |
935: (mfpInnerRequest[11] != mfpInnerAcknowledged[11] ? 0b00001000 : 0) |
936: (mfpInnerRequest[10] != mfpInnerAcknowledged[10] ? 0b00000100 : 0) |
937: (mfpInnerRequest[ 9] != mfpInnerAcknowledged[ 9] ? 0b00000010 : 0) |
938: (mfpInnerRequest[ 8] != mfpInnerAcknowledged[ 8] ? 0b00000001 : 0));
939: case MFP_IPRB:
940: return ((mfpInnerRequest[ 7] != mfpInnerAcknowledged[ 7] ? 0b10000000 : 0) |
941: (mfpInnerRequest[ 6] != mfpInnerAcknowledged[ 6] ? 0b01000000 : 0) |
942: (mfpInnerRequest[ 5] != mfpInnerAcknowledged[ 5] ? 0b00100000 : 0) |
943: (mfpInnerRequest[ 4] != mfpInnerAcknowledged[ 4] ? 0b00010000 : 0) |
944: (mfpInnerRequest[ 3] != mfpInnerAcknowledged[ 3] ? 0b00001000 : 0) |
945: (mfpInnerRequest[ 2] != mfpInnerAcknowledged[ 2] ? 0b00000100 : 0) |
946: (mfpInnerRequest[ 1] != mfpInnerAcknowledged[ 1] ? 0b00000010 : 0) |
947: (mfpInnerRequest[ 0] != mfpInnerAcknowledged[ 0] ? 0b00000001 : 0));
948: case MFP_ISRA:
949: return ((mfpInnerInService[15] ? 0b10000000 : 0) |
950: (mfpInnerInService[14] ? 0b01000000 : 0) |
951: (mfpInnerInService[13] ? 0b00100000 : 0) |
952: (mfpInnerInService[12] ? 0b00010000 : 0) |
953: (mfpInnerInService[11] ? 0b00001000 : 0) |
954: (mfpInnerInService[10] ? 0b00000100 : 0) |
955: (mfpInnerInService[ 9] ? 0b00000010 : 0) |
956: (mfpInnerInService[ 8] ? 0b00000001 : 0));
957: case MFP_ISRB:
958: return ((mfpInnerInService[ 7] ? 0b10000000 : 0) |
959: (mfpInnerInService[ 6] ? 0b01000000 : 0) |
960: (mfpInnerInService[ 5] ? 0b00100000 : 0) |
961: (mfpInnerInService[ 4] ? 0b00010000 : 0) |
962: (mfpInnerInService[ 3] ? 0b00001000 : 0) |
963: (mfpInnerInService[ 2] ? 0b00000100 : 0) |
964: (mfpInnerInService[ 1] ? 0b00000010 : 0) |
965: (mfpInnerInService[ 0] ? 0b00000001 : 0));
966: case MFP_IMRA:
967: return mfpImr >>> 8;
968: case MFP_IMRB:
969: return mfpImr & 0xff;
970: case MFP_VECTOR:
971: return mfpVectorHigh;
972: case MFP_TACR:
973: return (mfpTaEventcount ? 0x08 : 0) | mfpTaPrescale;
974: case MFP_TBCR:
975: return (mfpTbEventcount ? 0x08 : 0) | mfpTbPrescale;
976: case MFP_TCDCR:
977: return mfpTcPrescale << 4 | mfpTdPrescale;
978: case MFP_TADR:
979: if (mfpTaEventcount || mfpTaPrescale == 0) {
980: return mfpTaCurrent & 0xff;
981: }
982: return mfpTaInitial - (int) (Math.floor ((double) (XEiJ.mpuClockTime - mfpTaStart) / mfpTaDelta) % mfpTaInitial) & 0xff;
983: case MFP_TBDR:
984: if (mfpTbEventcount || mfpTbPrescale == 0) {
985: return mfpTbCurrent & 0xff;
986: }
987: return mfpTbInitial - (int) (Math.floor ((double) (XEiJ.mpuClockTime - mfpTbStart) / mfpTbDelta) % mfpTbInitial) & 0xff;
988: case MFP_TCDR:
989: if (mfpTcPrescale == 0) {
990: return mfpTcCurrent & 0xff;
991: }
992: return mfpTcInitial - (int) (Math.floor ((double) (XEiJ.mpuClockTime - mfpTcStart) / mfpTcDelta) % mfpTcInitial) & 0xff;
993: case MFP_TDDR:
994: if (mfpTdPrescale == 0) {
995: return mfpTdCurrent & 0xff;
996: }
997: return mfpTdInitial - (int) (Math.floor ((double) (XEiJ.mpuClockTime - mfpTdStart) / mfpTdDelta) % mfpTdInitial) & 0xff;
998: case MFP_SYNC_CHAR:
999: return 0;
1000: case MFP_UCR:
1001: return mfpUCR;
1002: case MFP_RSR:
1003: if (MFP_KBD_ON) {
1004: return (mfpRSR |
1005: (mfpKbdReadPointer == mfpKbdWritePointer ? 0 : 0x80));
1006: } else {
1007: return (mfpRSR |
1008: (mfpUdrQueueRead == mfpUdrQueueWrite ? 0 : 0x80));
1009: }
1010: case MFP_TSR:
1011: return (mfpTSR |
1012: (XEiJ.mpuClockTime < mfpTSRBufferFullEnd ? 0 : 0x80));
1013: case MFP_UDR:
1014: if (MFP_KBD_ON) {
1015: return mfpKbdReadData ();
1016: } else {
1017: if (mfpUdrQueueRead != mfpUdrQueueWrite) {
1018: mfpUdrQueueRead = mfpUdrQueueRead + 1 & MFP_UDR_QUEUE_MASK;
1019: if (mfpUdrQueueRead != mfpUdrQueueWrite) {
1020: if ((mfpIer & MFP_INPUT_FULL_MASK) != 0) {
1021: mfpInnerRequest[MFP_INPUT_FULL_LEVEL]++;
1022: if ((mfpImr & MFP_INPUT_FULL_MASK) != 0) {
1023: if (MFP_DELAYED_INTERRUPT) {
1024: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
1025: } else {
1026: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
1027: }
1028: }
1029: }
1030: }
1031: }
1032: return mfpUdrQueueArray[mfpUdrQueueRead];
1033: }
1034: default:
1035: if ((a & 1) == 0 &&
1036: !XEiJ.currentIsSecond) {
1037: return MemoryMappedDevice.MMD_NUL.mmdRbz (a);
1038: }
1039: return 0xff;
1040: }
1041: }
1042:
1043:
1044: public static void mfpWriteByte (int a, int d) throws M68kException {
1045: XEiJ.mpuClockTime += XEiJ.busWaitTime.mfp;
1046: switch (a & (XEiJ.BUS_MOTHER_MASK & 0xffff803f)) {
1047: case MFP_GPIP_DATA:
1048: return;
1049: case MFP_AER:
1050: mfpAer = d & 0xff;
1051: return;
1052: case MFP_DDR:
1053: return;
1054: case MFP_IERA:
1055: d = (char) (d << 8);
1056: int oldIera = mfpIer;
1057: mfpIer = d | (mfpIer & 0xff);
1058:
1059: if ((short) d >= 0) {
1060: mfpInnerAcknowledged[15] = mfpInnerRequest[15];
1061: }
1062: if (d << 31 - 14 >= 0) {
1063: mfpInnerAcknowledged[14] = mfpInnerRequest[14];
1064: }
1065: if (d << 31 - 13 >= 0) {
1066: mfpInnerAcknowledged[13] = mfpInnerRequest[13];
1067: }
1068: if (d << 31 - 12 >= 0) {
1069: mfpInnerAcknowledged[12] = mfpInnerRequest[12];
1070: } else if (oldIera << 31 - 12 >= 0 &&
1071: (MFP_KBD_ON ?
1072: mfpKbdReadPointer != mfpKbdWritePointer :
1073: mfpUdrQueueRead != mfpUdrQueueWrite)) {
1074: mfpInnerRequest[MFP_INPUT_FULL_LEVEL]++;
1075: if ((mfpImr & MFP_INPUT_FULL_MASK) != 0) {
1076:
1077: if (MFP_DELAYED_INTERRUPT) {
1078: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
1079: } else {
1080: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
1081: }
1082: }
1083: }
1084: if (d << 31 - 11 >= 0) {
1085: mfpInnerAcknowledged[11] = mfpInnerRequest[11];
1086: }
1087: if (d << 31 - 10 >= 0) {
1088: mfpInnerAcknowledged[10] = mfpInnerRequest[10];
1089: }
1090: if (d << 31 - 9 >= 0) {
1091: mfpInnerAcknowledged[ 9] = mfpInnerRequest[ 9];
1092: }
1093: if (d << 31 - 8 >= 0) {
1094: mfpInnerAcknowledged[ 8] = mfpInnerRequest[ 8];
1095: }
1096: return;
1097: case MFP_IERB:
1098: mfpIer = (mfpIer & ~0xff) | (d & 0xff);
1099:
1100: if ((byte) d >= 0) {
1101: mfpInnerAcknowledged[ 7] = mfpInnerRequest[ 7];
1102: }
1103: if (d << 31 - 6 >= 0) {
1104: mfpInnerAcknowledged[ 6] = mfpInnerRequest[ 6];
1105: }
1106: if (d << 31 - 5 >= 0) {
1107: mfpInnerAcknowledged[ 5] = mfpInnerRequest[ 5];
1108: }
1109: if (d << 31 - 4 >= 0) {
1110: mfpInnerAcknowledged[ 4] = mfpInnerRequest[ 4];
1111: }
1112: if (XEiJ.TEST_BIT_3_SHIFT ? d << 31 - 3 >= 0 : (d & 8) == 0) {
1113: mfpInnerAcknowledged[ 3] = mfpInnerRequest[ 3];
1114: }
1115: if (XEiJ.TEST_BIT_2_SHIFT ? d << 31 - 2 >= 0 : (d & 4) == 0) {
1116: mfpInnerAcknowledged[ 2] = mfpInnerRequest[ 2];
1117: }
1118: if (XEiJ.TEST_BIT_1_SHIFT ? d << 31 - 1 >= 0 : (d & 2) == 0) {
1119: mfpInnerAcknowledged[ 1] = mfpInnerRequest[ 1];
1120: }
1121: if (XEiJ.TEST_BIT_0_SHIFT ? d << 31 - 0 >= 0 : (d & 1) == 0) {
1122: mfpInnerAcknowledged[ 0] = mfpInnerRequest[ 0];
1123: }
1124: return;
1125: case MFP_IPRA:
1126:
1127: switch (d & 0xff) {
1128: case 0b01111111:
1129: mfpInnerAcknowledged[15] = mfpInnerRequest[15];
1130: break;
1131: case 0b10111111:
1132: mfpInnerAcknowledged[14] = mfpInnerRequest[14];
1133: break;
1134: case 0b11011111:
1135: mfpInnerAcknowledged[13] = mfpInnerRequest[13];
1136: break;
1137: case 0b11101111:
1138: mfpInnerAcknowledged[12] = mfpInnerRequest[12];
1139: break;
1140: case 0b11110111:
1141: mfpInnerAcknowledged[11] = mfpInnerRequest[11];
1142: break;
1143: case 0b11111011:
1144: mfpInnerAcknowledged[10] = mfpInnerRequest[10];
1145: break;
1146: case 0b11111101:
1147: mfpInnerAcknowledged[ 9] = mfpInnerRequest[ 9];
1148: break;
1149: case 0b11111110:
1150: mfpInnerAcknowledged[ 8] = mfpInnerRequest[ 8];
1151: break;
1152: }
1153: return;
1154: case MFP_IPRB:
1155:
1156: switch (d & 0xff) {
1157: case 0b01111111:
1158: mfpInnerAcknowledged[ 7] = mfpInnerRequest[ 7];
1159: break;
1160: case 0b10111111:
1161: mfpInnerAcknowledged[ 6] = mfpInnerRequest[ 6];
1162: break;
1163: case 0b11011111:
1164: mfpInnerAcknowledged[ 5] = mfpInnerRequest[ 5];
1165: break;
1166: case 0b11101111:
1167: mfpInnerAcknowledged[ 4] = mfpInnerRequest[ 4];
1168: break;
1169: case 0b11110111:
1170: mfpInnerAcknowledged[ 3] = mfpInnerRequest[ 3];
1171: break;
1172: case 0b11111011:
1173: mfpInnerAcknowledged[ 2] = mfpInnerRequest[ 2];
1174: break;
1175: case 0b11111101:
1176: mfpInnerAcknowledged[ 1] = mfpInnerRequest[ 1];
1177: break;
1178: case 0b11111110:
1179: mfpInnerAcknowledged[ 0] = mfpInnerRequest[ 0];
1180: break;
1181: }
1182: return;
1183: case MFP_ISRA:
1184:
1185: switch (d & 0xff) {
1186: case 0b01111111:
1187: mfpInnerInService[15] = false;
1188: break;
1189: case 0b10111111:
1190: mfpInnerInService[14] = false;
1191: break;
1192: case 0b11011111:
1193: mfpInnerInService[13] = false;
1194: break;
1195: case 0b11101111:
1196: mfpInnerInService[12] = false;
1197: break;
1198: case 0b11110111:
1199: mfpInnerInService[11] = false;
1200: break;
1201: case 0b11111011:
1202: mfpInnerInService[10] = false;
1203: break;
1204: case 0b11111101:
1205: mfpInnerInService[ 9] = false;
1206: break;
1207: case 0b11111110:
1208: mfpInnerInService[ 8] = false;
1209: break;
1210: }
1211: return;
1212: case MFP_ISRB:
1213:
1214: switch (d & 0xff) {
1215: case 0b01111111:
1216: mfpInnerInService[ 7] = false;
1217: break;
1218: case 0b10111111:
1219: mfpInnerInService[ 6] = false;
1220: break;
1221: case 0b11011111:
1222: mfpInnerInService[ 5] = false;
1223: break;
1224: case 0b11101111:
1225: mfpInnerInService[ 4] = false;
1226: break;
1227: case 0b11110111:
1228: mfpInnerInService[ 3] = false;
1229: break;
1230: case 0b11111011:
1231: mfpInnerInService[ 2] = false;
1232: break;
1233: case 0b11111101:
1234: mfpInnerInService[ 1] = false;
1235: break;
1236: case 0b11111110:
1237: mfpInnerInService[ 0] = false;
1238: break;
1239: }
1240: return;
1241: case MFP_IMRA:
1242: mfpImr = (d & 0xff) << 8 | (mfpImr & 0xff);
1243:
1244: if ((byte) d < 0 && mfpInnerRequest[15] != mfpInnerAcknowledged[15] ||
1245: d << 31 - 6 < 0 && mfpInnerRequest[14] != mfpInnerAcknowledged[14] ||
1246: d << 31 - 5 < 0 && mfpInnerRequest[13] != mfpInnerAcknowledged[13] ||
1247: d << 31 - 4 < 0 && mfpInnerRequest[12] != mfpInnerAcknowledged[12] ||
1248: (XEiJ.TEST_BIT_3_SHIFT ? d << 31 - 3 < 0 : (d & 8) != 0) && mfpInnerRequest[11] != mfpInnerAcknowledged[11] ||
1249: (XEiJ.TEST_BIT_2_SHIFT ? d << 31 - 2 < 0 : (d & 4) != 0) && mfpInnerRequest[10] != mfpInnerAcknowledged[10] ||
1250: (XEiJ.TEST_BIT_1_SHIFT ? d << 31 - 1 < 0 : (d & 2) != 0) && mfpInnerRequest[ 9] != mfpInnerAcknowledged[ 9] ||
1251: (XEiJ.TEST_BIT_0_SHIFT ? d << 31 - 0 < 0 : (d & 1) != 0) && mfpInnerRequest[ 8] != mfpInnerAcknowledged[ 8]) {
1252: if (MFP_DELAYED_INTERRUPT) {
1253: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
1254: } else {
1255: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
1256: }
1257: }
1258: return;
1259: case MFP_IMRB:
1260: mfpImr = (mfpImr & ~0xff) | (d & 0xff);
1261:
1262: if ((byte) d < 0 && mfpInnerRequest[ 7] != mfpInnerAcknowledged[ 7] ||
1263: d << 31 - 6 < 0 && mfpInnerRequest[ 6] != mfpInnerAcknowledged[ 6] ||
1264: d << 31 - 5 < 0 && mfpInnerRequest[ 5] != mfpInnerAcknowledged[ 5] ||
1265: d << 31 - 4 < 0 && mfpInnerRequest[ 4] != mfpInnerAcknowledged[ 4] ||
1266: (XEiJ.TEST_BIT_3_SHIFT ? d << 31 - 3 < 0 : (d & 8) != 0) && mfpInnerRequest[ 3] != mfpInnerAcknowledged[ 3] ||
1267: (XEiJ.TEST_BIT_2_SHIFT ? d << 31 - 2 < 0 : (d & 4) != 0) && mfpInnerRequest[ 2] != mfpInnerAcknowledged[ 2] ||
1268: (XEiJ.TEST_BIT_1_SHIFT ? d << 31 - 1 < 0 : (d & 2) != 0) && mfpInnerRequest[ 1] != mfpInnerAcknowledged[ 1] ||
1269: (XEiJ.TEST_BIT_0_SHIFT ? d << 31 - 0 < 0 : (d & 1) != 0) && mfpInnerRequest[ 0] != mfpInnerAcknowledged[ 0]) {
1270: if (MFP_DELAYED_INTERRUPT) {
1271: XEiJ.mpuDIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
1272: } else {
1273: XEiJ.mpuIRR |= XEiJ.MPU_MFP_INTERRUPT_MASK;
1274: }
1275: }
1276: return;
1277: case MFP_VECTOR:
1278: mfpVectorHigh = 0xf0 & d;
1279: return;
1280: case MFP_TACR:
1281: {
1282: int prevPrescale = mfpTaPrescale;
1283: mfpTaEventcount = (d & 0x08) != 0;
1284: mfpTaPrescale = d & 0x07;
1285: if (mfpTaEventcount && mfpTaPrescale != 0) {
1286: mfpTaEventcount = false;
1287: mfpTaPrescale = 0;
1288: }
1289: if (mfpTaEventcount) {
1290: if (prevPrescale != 0) {
1291: mfpTaCurrent = mfpTaInitial - (int) (Math.floor ((double) (XEiJ.mpuClockTime - mfpTaStart) / mfpTaDelta) % mfpTaInitial);
1292: }
1293: mfpTaClock = XEiJ.FAR_FUTURE;
1294: TickerQueue.tkqRemove (mfpTaTicker);
1295: } else if (mfpTaPrescale != 0) {
1296:
1297: mfpTaClock = (mfpTaStart = XEiJ.mpuClockTime) + (mfpTaDelta = MFP_DELTA[mfpTaPrescale]) * mfpTaInitial;
1298: TickerQueue.tkqAdd (mfpTaTicker, mfpTaClock);
1299: } else {
1300: if (prevPrescale != 0) {
1301: mfpTaCurrent = mfpTaInitial - (int) (Math.floor ((double) (XEiJ.mpuClockTime - mfpTaStart) / mfpTaDelta) % mfpTaInitial);
1302: }
1303: mfpTaClock = XEiJ.FAR_FUTURE;
1304: TickerQueue.tkqRemove (mfpTaTicker);
1305: }
1306: }
1307: return;
1308: case MFP_TBCR:
1309: {
1310: int prevPrescale = mfpTbPrescale;
1311: mfpTbEventcount = (d & 0x08) != 0;
1312: mfpTbPrescale = d & 0x07;
1313: mfpTbKeyboardOn = !mfpTbEventcount && mfpTbPrescale == 0x01 && mfpTbInitial == 0x0d;
1314: if (mfpTbEventcount && mfpTbPrescale != 0) {
1315: mfpTbEventcount = false;
1316: mfpTbPrescale = 0;
1317: }
1318: if (mfpTbEventcount) {
1319: if (prevPrescale != 0) {
1320: mfpTbCurrent = mfpTbInitial - (int) (Math.floor ((double) (XEiJ.mpuClockTime - mfpTbStart) / mfpTbDelta) % mfpTbInitial);
1321: }
1322: mfpTbClock = XEiJ.FAR_FUTURE;
1323: TickerQueue.tkqRemove (mfpTbTicker);
1324: } else if (mfpTbPrescale != 0) {
1325:
1326: mfpTbClock = (mfpTbStart = XEiJ.mpuClockTime) + (mfpTbDelta = MFP_DELTA[mfpTbPrescale]) * mfpTbInitial;
1327: TickerQueue.tkqAdd (mfpTbTicker, mfpTbClock);
1328: } else {
1329: if (prevPrescale != 0) {
1330: mfpTbCurrent = mfpTbInitial - (int) (Math.floor ((double) (XEiJ.mpuClockTime - mfpTbStart) / mfpTbDelta) % mfpTbInitial);
1331: }
1332: mfpTbClock = XEiJ.FAR_FUTURE;
1333: TickerQueue.tkqRemove (mfpTbTicker);
1334: }
1335: }
1336: return;
1337: case MFP_TCDCR:
1338: {
1339: int prevPrescale = mfpTcPrescale;
1340: mfpTcPrescale = d >> 4 & 0x07;
1341: if (mfpTcPrescale != 0) {
1342:
1343: mfpTcClock = (mfpTcStart = XEiJ.mpuClockTime) + (mfpTcDelta = MFP_DELTA[mfpTcPrescale]) * mfpTcInitial;
1344: TickerQueue.tkqAdd (mfpTcTicker, mfpTcClock);
1345: } else {
1346: if (prevPrescale != 0) {
1347: mfpTcCurrent = mfpTcInitial - (int) (Math.floor ((double) (XEiJ.mpuClockTime - mfpTcStart) / mfpTcDelta) % mfpTcInitial);
1348: }
1349: mfpTcClock = XEiJ.FAR_FUTURE;
1350: TickerQueue.tkqRemove (mfpTcTicker);
1351: }
1352: }
1353: {
1354: int prevPrescale = mfpTdPrescale;
1355: mfpTdPrescale = d & 0x07;
1356: if (mfpTdPrescale != 0) {
1357:
1358: mfpTdClock = (mfpTdStart = XEiJ.mpuClockTime) + (mfpTdDelta = MFP_DELTA[mfpTdPrescale]) * mfpTdInitial;
1359: TickerQueue.tkqAdd (mfpTdTicker, mfpTdClock);
1360: } else {
1361: if (prevPrescale != 0) {
1362: mfpTdCurrent = mfpTdInitial - (int) (Math.floor ((double) (XEiJ.mpuClockTime - mfpTdStart) / mfpTdDelta) % mfpTdInitial);
1363: }
1364: mfpTdClock = XEiJ.FAR_FUTURE;
1365: TickerQueue.tkqRemove (mfpTdTicker);
1366: }
1367: }
1368: return;
1369: case MFP_TADR:
1370:
1371: d &= 0xff;
1372: mfpTaInitial = d == 0 ? 256 : d;
1373: if (!mfpTaEventcount && mfpTaPrescale == 0) {
1374: mfpTaCurrent = mfpTaInitial;
1375: }
1376: return;
1377: case MFP_TBDR:
1378:
1379: d &= 0xff;
1380: mfpTbInitial = d == 0 ? 256 : d;
1381: mfpTbKeyboardOn = !mfpTbEventcount && mfpTbPrescale == 0x01 && mfpTbInitial == 0x0d;
1382: if (!mfpTbEventcount && mfpTbPrescale == 0) {
1383: mfpTbCurrent = mfpTbInitial;
1384: }
1385: return;
1386: case MFP_TCDR:
1387:
1388: d &= 0xff;
1389: mfpTcInitial = d == 0 ? 256 : d;
1390: if (mfpTcPrescale == 0) {
1391: mfpTcCurrent = mfpTcInitial;
1392: }
1393: return;
1394: case MFP_TDDR:
1395:
1396: d &= 0xff;
1397: mfpTdInitial = d == 0 ? 256 : d;
1398: if (mfpTdPrescale == 0) {
1399: mfpTdCurrent = mfpTdInitial;
1400: }
1401: return;
1402: case MFP_SYNC_CHAR:
1403: return;
1404: case MFP_UCR:
1405: mfpUCR = d & 0b11111110;
1406: mfpTSRBufferFullTime = (mfpTbDelta * mfpTbInitial *
1407: 2 *
1408: ((mfpUCR & 0x80) != 0 ? 16 : 1) *
1409: ((1 * 2) +
1410: ((8 - ((mfpUCR >> 5) & 3)) * 2) +
1411: (((mfpUCR >> 3) & 3) + 1)) / 2);
1412: return;
1413: case MFP_RSR:
1414: mfpRSR = d & 0b00000001;
1415: return;
1416: case MFP_TSR:
1417: mfpTSR = d & 0b00000001;
1418: return;
1419: case MFP_UDR:
1420: if (mfpTbKeyboardOn) {
1421: if ((byte) d < 0) {
1422: Keyboard.kbdSetLedStatus (d);
1423: } else if ((d & 0xf8) == 0x40) {
1424: } else if ((d & 0xf8) == 0x48) {
1425: } else if ((d & 0xfc) == 0x54) {
1426: Keyboard.kbdSetLedBrightness (d);
1427: } else if ((d & 0xfc) == 0x58) {
1428: } else if ((d & 0xfc) == 0x5c) {
1429: } else if ((d & 0xf0) == 0x60) {
1430: Keyboard.kbdSetRepeatDelay (0x0f & d);
1431: } else if ((d & 0xf0) == 0x70) {
1432: Keyboard.kbdSetRepeatInterval (0x0f & d);
1433: }
1434: }
1435: mfpTSRBufferFullEnd = XEiJ.mpuClockTime + mfpTSRBufferFullTime;
1436: return;
1437: default:
1438: if ((a & 1) == 0 &&
1439: !XEiJ.currentIsSecond) {
1440: MemoryMappedDevice.MMD_NUL.mmdWb (a, d);
1441: }
1442: return;
1443: }
1444: }
1445:
1446:
1447:
1448: }
1449:
1450:
1451: