Indicator.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13: package xeij;
14:
15: import java.awt.*;
16: import java.awt.image.*;
17: import java.util.*;
18: import javax.swing.*;
19:
20: public class Indicator {
21:
22:
23:
24:
25: public static final int IND_MPU_X = 0;
26: public static final int IND_CLOCK_X = 10;
27: public static final int IND_RATIO_X = 19;
28: public static final int IND_COLS = 25;
29: public static final int IND_FONT_WIDTH = 6;
30: public static final int IND_FONT_HEIGHT = 8;
31: public static final int IND_PADDING_LEFT = 6;
32: public static final int IND_PADDING_RIGHT = 6;
33: public static final int IND_PADDING_TOP = 3;
34: public static final int IND_PADDING_BOTTOM = 2;
35: public static final int IND_WIDTH = IND_PADDING_LEFT + IND_FONT_WIDTH * IND_COLS + IND_PADDING_RIGHT;
36: public static final int IND_HEIGHT = IND_PADDING_TOP + IND_FONT_HEIGHT + IND_PADDING_BOTTOM;
37:
38: public static int indBackGround;
39: public static int indColor00;
40: public static int indColor20;
41: public static int indColor40;
42: public static int indColor60;
43: public static int indColor80;
44:
45: public static int indLastMPU;
46:
47: public static BufferedImage indImage;
48: public static int[] indBitmap;
49: public static Box indBox;
50:
51: public static void indInit () {
52: indBackGround = LnF.lnfRGB[0];
53: indColor00 = LnF.lnfRGB[14];
54: indColor20 = 0xff00ffff;
55: indColor40 = 0xff00ff00;
56: indColor60 = 0xffffff00;
57: indColor80 = 0xffff0000;
58:
59: indLastMPU = 0;
60:
61: indImage = new BufferedImage (IND_WIDTH, IND_HEIGHT, BufferedImage.TYPE_INT_RGB);
62: indBitmap = ((DataBufferInt) indImage.getRaster ().getDataBuffer ()).getData ();
63: Arrays.fill (indBitmap, indBackGround);
64: indBox = ComponentFactory.setFixedSize (
65: new Box (BoxLayout.LINE_AXIS) {
66: @Override public void paint (Graphics g) {
67: g.drawImage (indImage, 0, 0, null);
68: }
69: @Override protected void paintComponent (Graphics g) {
70: }
71: @Override protected void paintBorder (Graphics g) {
72: }
73: @Override protected void paintChildren (Graphics g) {
74: }
75: @Override public void update (Graphics g) {
76: }
77: },
78: IND_WIDTH, IND_HEIGHT);
79: }
80:
81: public static void indUpdate (double actualPercent) {
82:
83:
84:
85:
86: if (indLastMPU != XEiJ.currentMPU) {
87: indLastMPU = XEiJ.currentMPU;
88: int color = indColor00;
89: String s = Model.mpuNameOf (XEiJ.currentMPU);
90: int l = s.length ();
91: for (int i = 0; i < 9; i++) {
92: indPutChar (IND_MPU_X + i, i < l ? s.charAt (i) : ' ', color);
93: }
94: }
95:
96: {
97: int color = indColor00;
98: int t = XEiJ.FMT_BCD4[Math.max (0, Math.min (9999, (int) (10.0 * XEiJ.mpuCurrentMHz + 0.5)))];
99: indPutChar (IND_CLOCK_X + 0, t < 0x1000 ? ' ' : (t >> 12) + '0', color);
100: indPutChar (IND_CLOCK_X + 1, t < 0x0100 ? ' ' : ((t >> 8) & 15) + '0', color);
101: indPutChar (IND_CLOCK_X + 2, ((t >> 4) & 15) + '0', color);
102: indPutChar (IND_CLOCK_X + 3, '.', color);
103: indPutChar (IND_CLOCK_X + 4, ( t & 15) + '0', color);
104: indPutChar (IND_CLOCK_X + 5, 'M', color);
105: indPutChar (IND_CLOCK_X + 6, 'H', color);
106: indPutChar (IND_CLOCK_X + 7, 'z', color);
107: }
108:
109: {
110: int t = XEiJ.FMT_BCD4[Math.max (0, Math.min (9999, (int) (10.0 * actualPercent + 0.5)))];
111: int color = (t < 0x0200 ? indColor00 :
112: t < 0x0400 ? indColor20 :
113: t < 0x0600 ? indColor40 :
114: t < 0x0800 ? indColor60 :
115: indColor80);
116: indPutChar (IND_RATIO_X + 0, t < 0x1000 ? ' ' : (t >> 12) + '0', color);
117: indPutChar (IND_RATIO_X + 1, t < 0x0100 ? ' ' : ((t >> 8) & 15) + '0', color);
118: indPutChar (IND_RATIO_X + 2, ((t >> 4) & 15) + '0', color);
119: indPutChar (IND_RATIO_X + 3, '.', color);
120: indPutChar (IND_RATIO_X + 4, ( t & 15) + '0', color);
121: indPutChar (IND_RATIO_X + 5, '%', color);
122: }
123: indBox.repaint ();
124: }
125:
126: public static void indPutChar (int col, int c, int color) {
127: if (IND_FONT_HEIGHT == 8) {
128: int src = IND_FONT_HEIGHT * c;
129: int dst = IND_PADDING_LEFT + IND_FONT_WIDTH * col + IND_WIDTH * IND_PADDING_TOP;
130: for (int v = 0; v < IND_FONT_HEIGHT; v++) {
131: int t = FontPage.Lcd.LCD6X8_FONT[src] << (32 - 8);
132: for (int u = 0; u < IND_FONT_WIDTH; u++) {
133: indBitmap[dst + u] = t < 0 ? color : indBackGround;
134: t <<= 1;
135: }
136: src++;
137: dst += IND_WIDTH;
138: }
139: } else {
140: int src = 0x00fef400 - 0x00fc0000 + IND_FONT_HEIGHT * c;
141: int dst = IND_PADDING_LEFT + IND_FONT_WIDTH * col + IND_WIDTH * IND_PADDING_TOP;
142: for (int v = 0; v < IND_FONT_HEIGHT; v++) {
143: int t = ROM.iplrom16scsi256[src] << (32 - 8);
144: for (int u = 0; u < IND_FONT_WIDTH; u++) {
145: indBitmap[dst + u] = t < 0 ? color : indBackGround;
146: t <<= 1;
147: }
148: src++;
149: dst += IND_WIDTH;
150: }
151: }
152: }
153:
154:
155:
156:
157:
158:
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:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482:
483:
484:
485:
486:
487:
488:
489:
490:
491:
492:
493:
494:
495:
496:
497:
498:
499:
500:
501:
502:
503:
504:
505:
506:
507:
508:
509:
510:
511:
512:
513:
514:
515:
516:
517:
518:
519:
520:
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533:
534:
535:
536:
537:
538:
539:
540:
541:
542:
543:
544:
545:
546:
547:
548:
549:
550:
551:
552:
553:
554:
555:
556:
557:
558:
559:
560:
561:
562:
563:
564:
565:
566:
567:
568:
569:
570:
571:
572:
573:
574:
575:
576:
577:
578:
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:
665:
666:
667:
668:
669:
670:
671:
672:
673:
674:
675:
676:
677:
678:
679:
680:
681:
682:
683:
684:
685:
686:
687:
688:
689:
690:
691:
692:
693:
694:
695:
696:
697:
698:
699:
700:
701:
702:
703:
704:
705:
706:
707:
708:
709:
710:
711:
712:
713:
714:
715:
716:
717:
718:
719:
720:
721:
722:
723:
724:
725:
726:
727:
728:
729:
730:
731: public static final char[] IND_ASCII_3X5 = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\u2482\u5a00\u5f7d\u3c9e\u5c9d\u6cae\u2400\u1491\u4494\u0aa8\u05d0\22\u01c0\2\u02a0\u7b6f\u2492\u73e7\u73cf\u5bc9\u79cf\u79ef\u7249\u7bef\u7bcf\u0410\u0412\u1511\u0e38\u4454\u6282\u2be3\u2bed\u6bae\u3923\u6b6e\u79e7\u79e4\u396b\u5bed\u7497\u124e\u5bad\u4927\u5fed\u6b6d\u2b6a\u6ba4\u2b7b\u6bad\u388e\u7492\u5b6f\u5b6a\u5bfd\u5aad\u5a92\u72a7\u3493\u0888\u6496\u2a00\7\u2200\u076b\u4d6e\u0723\u176b\u0773\u3e92\u3bce\u4d6d\u2092\u104e\u4bb5\u6492\u0dfd\u0d6d\u056a\u0d74\u0759\u0724\u068e\u2e91\u0b6b\u0b6a\u0bfb\u0a95\u0b54\u0e57\u1591\u2412\u44d4\u7000".toCharArray ();
732:
733: }