XEiJ.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.datatransfer.*;
17: import java.awt.dnd.*;
18: import java.awt.event.*;
19: import java.awt.font.*;
20: import java.awt.geom.*;
21: import java.awt.image.*;
22: import java.io.*;
23: import java.lang.*;
24: import java.math.*;
25: import java.net.*;
26: import java.nio.*;
27: import java.nio.charset.*;
28: import java.nio.file.*;
29: import java.util.*;
30: import java.util.function.*;
31: import java.util.regex.*;
32: import java.util.stream.*;
33: import java.util.zip.*;
34: import javax.imageio.*;
35: import javax.imageio.stream.*;
36: import javax.swing.*;
37: import javax.swing.event.*;
38: import javax.swing.text.*;
39:
40: public class XEiJ {
41:
42:
43:
44:
45:
46: static {
47: System.setProperty ("sun.java2d.d3d", "false");
48: System.setProperty ("sun.java2d.xrender", "false");
49: }
50:
51:
52: public static final String PRG_TITLE = "XEiJ (X68000 Emulator in Java)";
53: public static final String PRG_VERSION = "0.26.04.08";
54: public static final String PRG_AUTHOR = "Makoto Kamada";
55: public static final String PRG_WEBPAGE = "https://stdkmd.net/xeij/";
56:
57: public static final String PRG_JAVA_VENDOR = "Oracle Corporation";
58: public static final String PRG_JAVA_VERSION = "26";
59: public static final String PRG_OS_ARCH = "amd64";
60: public static final String PRG_OS_NAME = "Windows 11";
61:
62:
63:
64:
65:
66:
67:
68: public static final boolean TEST_BIT_0_SHIFT = false;
69: public static final boolean TEST_BIT_1_SHIFT = false;
70: public static final boolean TEST_BIT_2_SHIFT = true;
71: public static final boolean TEST_BIT_3_SHIFT = true;
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89: public static final boolean SHORT_SATURATION_CAST = false;
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101: public static final Charset ISO_8859_1 = Charset.forName ("ISO-8859-1");
102: static {
103: if (false) {
104:
105: StringBuilder sb = new StringBuilder ();
106: for (int i = 0; i < 256; i++) {
107: sb.append ((char) i);
108: }
109: byte[] bb = sb.toString ().getBytes (ISO_8859_1);
110: for (int i = 0; i < 256; i++) {
111: System.out.printf ("%02x %02x %s\n", i, bb[i] & 255, i == (bb[i] & 255) ? "OK" : "ERROR");
112: }
113: }
114: }
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127: public static String prgJavaVendor;
128: public static String prgJavaVersion;
129: public static String prgOsArch;
130: public static String prgOsName;
131: public static boolean prgIsLinux;
132: public static boolean prgIsMac;
133: public static boolean prgIsWindows;
134:
135: public static boolean prgCaseIgnored;
136:
137: public static boolean prgVerbose;
138:
139: public static String[] prgArgs;
140:
141:
142:
143: public static void main (String[] args) {
144:
145:
146:
147:
148: if (true) {
149: try {
150: String def = System.getProperty ("os.name").toLowerCase ().contains ("win") ? "C:\\Temp" : "/tmp";
151: Stream.of (new File (System.getProperty ("java.io.tmpdir", def),
152: "jSerialComm").getCanonicalFile ().toPath (),
153: new File (System.getProperty ("user.home", def),
154: ".jSerialComm").getCanonicalFile ().toPath ())
155: .filter (Files::exists)
156: .forEach (dir -> {
157: try {
158: Files.walk (dir)
159: .sorted (Comparator.reverseOrder ())
160: .forEach (path -> {
161: if (Files.exists (path)) {
162: try {
163: Files.delete (path);
164:
165: } catch (IOException ioe) {
166: System.err.println ("Failed to delete: " + path + " (" + ioe.getMessage () + ")");
167: }
168: }
169: });
170: } catch (IOException ioe) {
171: System.err.println ("Failed to walk: " + dir + " (" + ioe.getMessage () + ")");
172: }
173: });
174: } catch (IOException ioe) {
175: }
176: }
177:
178: prgArgs = args;
179:
180:
181: SwingUtilities.invokeLater (new Runnable () {
182: @Override public void run () {
183: new XEiJ ();
184: }
185: });
186:
187: }
188:
189:
190:
191: public XEiJ () {
192:
193: prgJavaVendor = System.getProperty ("java.vendor");
194: prgJavaVersion = System.getProperty ("java.version");
195: prgOsArch = System.getProperty ("os.arch");
196: prgOsName = System.getProperty ("os.name");
197: prgIsLinux = 0 <= prgOsName.indexOf ("Linux");
198: prgIsMac = 0 <= prgOsName.indexOf ("Mac");
199: prgIsWindows = 0 <= prgOsName.indexOf ("Windows");
200:
201: System.out.print ("\n" +
202: "-------------------------------------------------\n" +
203: PRG_TITLE + " version " + PRG_VERSION + "\n" +
204: "-------------------------------------------------\n");
205:
206:
207:
208:
209: prgCaseIgnored = new File ("A").equals (new File ("a"));
210: fmtInit ();
211: Multilingual.mlnInit ();
212:
213: System.out.println (Multilingual.mlnJapanese ? "java.vendor は " + prgJavaVendor + " です" :
214: "java.vendor is " + prgJavaVendor);
215: System.out.println (Multilingual.mlnJapanese ? "java.version は " + prgJavaVersion + " です" :
216: "java.version is " + prgJavaVersion);
217: System.out.println (Multilingual.mlnJapanese ? "os.arch は " + prgOsArch + " です" :
218: "os.arch is " + prgOsArch);
219: System.out.println (Multilingual.mlnJapanese ? "os.name は " + prgOsName + " です" :
220: "os.name is " + prgOsName);
221:
222: rbtInit ();
223:
224: Settings.sgsInit ();
225: LnF.lnfInit ();
226: Bubble.bblInit ();
227:
228: CharacterCode.chrInit ();
229:
230: TickerQueue.tkqInit ();
231:
232: RS232CTerminal.trmInit ();
233:
234: if (MercuryUnit.MU4_ON) {
235: MercuryUnit.mu4Init ();
236: }
237: xt3Init ();
238: mdlInit ();
239:
240: if (InstructionBreakPoint.IBP_ON) {
241: InstructionBreakPoint.ibpInit ();
242: }
243: if (DataBreakPoint.DBP_ON) {
244: DataBreakPoint.dbpInit ();
245: }
246: busInit ();
247: MainMemory.mmrInit ();
248: ROM.romInit ();
249: CRTC.crtInit ();
250: VideoController.vcnInit ();
251: HD63450.dmaInit ();
252: svsInit ();
253: MC68901.mfpInit ();
254: RP5C15.rtcInit ();
255: sysInit ();
256: if (OPMLog.OLG_ON) {
257: OPMLog.olgInit ();
258: }
259: OPM.opmInit ();
260: ADPCM.pcmInit ();
261: FDC.fdcInit ();
262: HDC.hdcInit ();
263: if (HostCDROM.HCD_ENABLED) {
264: HostCDROM.hcdInit ();
265: }
266: SPC.spcInit ();
267: Z8530.sccInit ();
268: IOInterrupt.ioiInit ();
269: SpriteScreen.sprInit ();
270: bnkInit ();
271: SRAM.smrInit ();
272:
273: PPI.ppiInit ();
274: PrinterPort.prnInit ();
275: Indicator.indInit ();
276:
277: SlowdownTest.sdtInit ();
278: Keyboard.kbdInit ();
279: CONDevice.conInit ();
280: Mouse.musInit ();
281: pnlInit ();
282: frmInit ();
283:
284: dbgInit ();
285: RegisterList.drpInit ();
286: DisassembleList.ddpInit ();
287: MemoryDumpList.dmpInit ();
288: LogicalSpaceMonitor.atwInit ();
289: PhysicalSpaceMonitor.paaInit ();
290: DebugConsole.dgtInit ();
291: if (BranchLog.BLG_ON) {
292: BranchLog.blgInit ();
293: }
294: if (ProgramFlowVisualizer.PFV_ON) {
295: ProgramFlowVisualizer.pfvInit ();
296: }
297: if (RasterBreakPoint.RBP_ON) {
298: RasterBreakPoint.rbpInit ();
299: }
300: if (ScreenModeTest.SMT_ON) {
301: ScreenModeTest.smtInit ();
302: }
303: if (RootPointerList.RTL_ON) {
304: RootPointerList.rtlInit ();
305: }
306: if (SpritePatternViewer.SPV_ON) {
307: SpritePatternViewer.spvInit ();
308: }
309: if (PaletteViewer.PLV_ON) {
310: PaletteViewer.plvInit ();
311: }
312: if (ATCMonitor.ACM_ON) {
313: ATCMonitor.acmInit ();
314: }
315:
316: SoundSource.sndInit ();
317: FEFunction.fpkInit ();
318: mpuInit ();
319: MC68060.mmuInit ();
320: SoundMonitor.smnInit ();
321: HFS.hfsInit ();
322:
323: GIFAnimation.gifInit ();
324: TextCopy.txcInit ();
325: ButtonFunction.bfnInit ();
326:
327:
328:
329: Settings.sgsMakeMenu ();
330: mdlMakeMenu ();
331: FDC.fdcMakeMenu ();
332: HDC.hdcMakeMenu ();
333: SPC.spcMakeMenu ();
334: mpuMakeMenu ();
335: SRAM.smrMakeMenu ();
336: clpMake ();
337: pnlMake ();
338: mnbMakeMenu ();
339: frmMake ();
340: dbgMakePopup ();
341:
342:
343: final String flags = (
344: "" +
345: (EFPBox.CIR_DEBUG_TRACE ? " EFPBox.CIR_DEBUG_TRACE" : "") +
346: (FDC.FDC_DEBUG_TRACE ? " FDC.FDC_DEBUG_TRACE" : "") +
347: (FEFunction.FPK_DEBUG_TRACE ? " FEFunction.FPK_DEBUG_TRACE" : "") +
348: (HD63450.DMA_DEBUG_TRACE != 0 ? " HD63450.DMA_DEBUG_TRACE" : "") +
349: (HDC.HDC_DEBUG_TRACE ? " HDC.HDC_DEBUG_TRACE" : "") +
350: (HDC.HDC_DEBUG_COMMAND ? " HDC.HDC_DEBUG_COMMAND" : "") +
351: (HFS.HFS_DEBUG_TRACE ? " HFS.HFS_DEBUG_TRACE" : "") +
352: (HFS.HFS_DEBUG_FILE_INFO ? " HFS.HFS_DEBUG_FILE_INFO" : "") +
353: (HFS.HFS_COMMAND_TRACE ? " HFS.HFS_COMMAND_TRACE" : "") +
354: (HFS.HFS_BUFFER_TRACE ? " HFS.HFS_BUFFER_TRACE" : "") +
355: (IOInterrupt.IOI_DEBUG_TRACE ? " IOInterrupt.IOI_DEBUG_TRACE" : "") +
356: (Keyboard.KBD_DEBUG_LED ? " Keyboard.KBD_DEBUG_LED" : "") +
357: (MC68060.MMU_DEBUG_COMMAND ? " MC68060.MMU_DEBUG_COMMAND" : "") +
358: (MC68060.MMU_DEBUG_TRANSLATION ? " MC68060.MMU_DEBUG_TRANSLATION" : "") +
359: (MC68060.MMU_NOT_ALLOCATE_CACHE ? " MC68060.MMU_NOT_ALLOCATE_CACHE" : "") +
360: (RP5C15.RTC_DEBUG_TRACE ? " RP5C15.RTC_DEBUG_TRACE" : "") +
361: (SPC.SPC_DEBUG_ON ? " SPC.SPC_DEBUG_ON" : "") +
362: (Z8530.SCC_DEBUG_ON ? " Z8530.SCC_DEBUG_ON" : "")
363: );
364: if (!"".equals (flags)) {
365: pnlExitFullScreen (true);
366: JOptionPane.showMessageDialog (null, "debug flags:" + flags);
367: }
368:
369:
370:
371:
372: tmrStart ();
373:
374: Keyboard.kbdStart ();
375: Mouse.musStart ();
376: pnlStart ();
377: frmStart ();
378: SoundSource.sndStart ();
379:
380: if (DataBreakPoint.DBP_ON) {
381: DataBreakPoint.dbpStart ();
382: }
383: if (RasterBreakPoint.RBP_ON) {
384: RasterBreakPoint.rbpStart ();
385: }
386: if (ScreenModeTest.SMT_ON) {
387: ScreenModeTest.smtStart ();
388: }
389: if (OPMLog.OLG_ON) {
390: OPMLog.olgStart ();
391: }
392: SoundMonitor.smnStart ();
393: RS232CTerminal.trmStart ();
394: PPI.ppiStart ();
395: PrinterPort.prnStart ();
396: if (BranchLog.BLG_ON) {
397: BranchLog.blgStart ();
398: }
399: if (ProgramFlowVisualizer.PFV_ON) {
400: ProgramFlowVisualizer.pfvStart ();
401: }
402: RegisterList.drpStart ();
403: DisassembleList.ddpStart ();
404: MemoryDumpList.dmpStart ();
405: LogicalSpaceMonitor.atwStart ();
406: PhysicalSpaceMonitor.paaStart ();
407: DebugConsole.dgtStart ();
408: if (RootPointerList.RTL_ON) {
409: RootPointerList.rtlStart ();
410: }
411: if (SpritePatternViewer.SPV_ON) {
412: SpritePatternViewer.spvStart ();
413: }
414: if (PaletteViewer.PLV_ON) {
415: PaletteViewer.plvStart ();
416: }
417: if (ATCMonitor.ACM_ON) {
418: ATCMonitor.acmStart ();
419: }
420: ButtonFunction.bfnStart ();
421:
422: if (Settings.sgsSaveiconValue != null) {
423: String[] a = Settings.sgsSaveiconValue.split (",");
424: if (0 < a.length) {
425: saveIcon (a[0], LnF.LNF_ICON_IMAGES);
426: if (1 < a.length) {
427: saveImage (LnF.LNF_ICON_IMAGE_16, a[1]);
428: if (2 < a.length) {
429: saveImage (LnF.LNF_ICON_IMAGE_32, a[2]);
430: if (3 < a.length) {
431: saveImage (LnF.LNF_ICON_IMAGE_48, a[3]);
432: }
433: }
434: }
435: }
436: prgTini ();
437: return;
438: }
439:
440:
441: mpuReset (-1, -1);
442:
443: pnlBoot2 ();
444:
445: }
446:
447:
448:
449:
450:
451: public static void prgTini () {
452: try {
453: if (OPMLog.OLG_ON) {
454: OPMLog.olgTini ();
455: }
456: ButtonFunction.bfnTini ();
457: TextCopy.txcTini ();
458: GIFAnimation.gifTini ();
459: SoundSource.sndTini ();
460: Keyboard.kbdTini ();
461: Mouse.musTini ();
462: CONDevice.conTini ();
463: PPI.ppiTini ();
464: PrinterPort.prnTini ();
465: FDC.fdcTini ();
466: HDC.hdcTini ();
467: if (HostCDROM.HCD_ENABLED) {
468: HostCDROM.hcdTini ();
469: }
470: SPC.spcTini ();
471: HFS.hfsTini ();
472: Z8530.sccTini ();
473: CRTC.crtTini ();
474: SpriteScreen.sprTini ();
475: pnlTini ();
476: bnkTini ();
477: ROM.romTini ();
478: if (MercuryUnit.MU4_ON) {
479: MercuryUnit.mu4Tini ();
480: }
481: xt3Tini ();
482: mdlTini ();
483: SRAM.smrTini ();
484: tmrTini ();
485: busTini ();
486: if (SpritePatternViewer.SPV_ON) {
487: SpritePatternViewer.spvTini ();
488: }
489: if (PaletteViewer.PLV_ON) {
490: PaletteViewer.plvTini ();
491: }
492: RS232CTerminal.trmTini ();
493: LnF.lnfTini ();
494: Settings.sgsTini ();
495: } catch (Exception e) {
496: e.printStackTrace ();
497: }
498: System.exit (0);
499: }
500:
501:
502:
503: public static void prgOpenJavaDialog () {
504: pnlExitFullScreen (true);
505: JOptionPane.showMessageDialog (
506: frmFrame,
507: ComponentFactory.createGridPanel (
508: 3,
509: 6,
510: "paddingLeft=6,paddingRight=6",
511: "italic,right;left;left",
512: "italic,center;colSpan=3,widen",
513: "",
514:
515: null,
516: Multilingual.mlnJapanese ? "実行中" : "Running",
517: Multilingual.mlnJapanese ? "推奨" : "Recommended",
518:
519: ComponentFactory.createHorizontalSeparator (),
520:
521: Multilingual.mlnJapanese ? "Java のベンダー" : "Java Vendor",
522: prgJavaVendor,
523: PRG_JAVA_VENDOR,
524:
525: Multilingual.mlnJapanese ? "Java のバージョン" : "Java Version",
526: prgJavaVersion,
527: PRG_JAVA_VERSION,
528:
529: Multilingual.mlnJapanese ? "OS のアーキテクチャ" : "OS Architecture",
530: prgOsArch,
531: PRG_OS_ARCH,
532:
533: Multilingual.mlnJapanese ? "OS の名前" : "OS Name",
534: prgOsName,
535: PRG_OS_NAME
536: ),
537: Multilingual.mlnJapanese ? "Java 実行環境の情報" : "Java runtime environment information",
538: JOptionPane.PLAIN_MESSAGE);
539: }
540:
541:
542:
543: public static void prgOpenAboutDialog () {
544: pnlExitFullScreen (true);
545: JOptionPane.showMessageDialog (
546: frmFrame,
547: ComponentFactory.createGridPanel (
548: 2, 4, "paddingLeft=6,paddingRight=6", "italic,right;left", "", "",
549: Multilingual.mlnJapanese ? "タイトル" : "Title" ,
550: PRG_TITLE,
551: Multilingual.mlnJapanese ? "バージョン" : "Version",
552: PRG_VERSION,
553: Multilingual.mlnJapanese ? "作者" : "Author" ,
554: PRG_AUTHOR,
555: Multilingual.mlnJapanese ? "ウェブページ" : "Webpage",
556: PRG_WEBPAGE
557: ),
558: Multilingual.mlnJapanese ? "バージョン情報" : "Version information",
559: JOptionPane.PLAIN_MESSAGE);
560: }
561:
562:
563:
564: public static void prgOpenXEiJLicenseDialog () {
565: pnlExitFullScreen (true);
566: JOptionPane.showMessageDialog (
567: frmFrame,
568: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_XEiJ.txt"), 550, 300),
569: Multilingual.mlnJapanese ? "XEiJ 使用許諾条件" : "XEiJ License",
570: JOptionPane.PLAIN_MESSAGE);
571: }
572:
573:
574:
575: public static void prgOpenSHARPLicenseDialog () {
576: pnlExitFullScreen (true);
577: JOptionPane.showMessageDialog (
578: frmFrame,
579: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_FSHARP.txt", "Shift_JIS"), 550, 300),
580: Multilingual.mlnJapanese ? "無償公開された X68000 の基本ソフトウェア製品の許諾条件" : "License of the basic software products for X68000 that were distributed free of charge",
581: JOptionPane.PLAIN_MESSAGE);
582: }
583:
584:
585:
586: public static void prgOpenYmfmLicenseDialog () {
587: pnlExitFullScreen (true);
588: JOptionPane.showMessageDialog (
589: frmFrame,
590: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_ymfm.txt"), 550, 300),
591: "ymfm License",
592: JOptionPane.PLAIN_MESSAGE);
593: }
594:
595:
596:
597: public static void prgOpenJSerialCommLicenseDialog () {
598: pnlExitFullScreen (true);
599: JOptionPane.showMessageDialog (
600: frmFrame,
601: ComponentFactory.createVerticalSplitPane (
602: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-APACHE-2.0"), 550, 300),
603: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-LGPL-3.0"), 550, 300)
604: ),
605: "jSerialComm License",
606: JOptionPane.PLAIN_MESSAGE);
607: }
608:
609:
610:
611: public static void prgPrintClass (Object o) {
612: System.out.println (o.toString ());
613:
614: try {
615: Stack<Class<?>> s = new Stack<Class<?>> ();
616: for (Class<?> c = o.getClass (); c != null; c = c.getSuperclass ()) {
617: s.push (c);
618: }
619: for (int i = 0; !s.empty (); i++) {
620: for (int j = 0; j < i; j++) {
621: System.out.print (" ");
622: }
623: System.out.println (s.pop ().getName ());
624: }
625: } catch (Exception e) {
626: }
627: }
628:
629:
630:
631:
632: public static void prgPrintStackTrace () {
633: Exception e = new Exception ();
634: e.fillInStackTrace ();
635: prgPrintStackTraceOf (e);
636: }
637: public static void prgPrintStackTraceOf (Exception e) {
638:
639: System.out.println ("------------------------------------------------");
640: System.out.println (e.toString ());
641: System.out.println ("\t" + e.getMessage ());
642: for (StackTraceElement ste : e.getStackTrace ()) {
643: System.out.println ("\tat " + ste.toString ());
644: }
645: System.out.println ("------------------------------------------------");
646: }
647:
648:
649:
650:
651: public static boolean prgStopDone = false;
652: public static void prgStopOnce () {
653: if (!prgStopDone) {
654: prgStopDone = true;
655: mpuStop (null);
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: public static final long TMR_FREQ = 1000000000000L;
690:
691:
692: public static final long TMR_DELAY = 10L;
693: public static final long TMR_INTERVAL = 10L;
694:
695:
696: public static java.util.Timer tmrTimer;
697:
698:
699:
700: public static void tmrStart () {
701: tmrTimer = new java.util.Timer ();
702: }
703:
704:
705:
706: public static void tmrTini () {
707: if (tmrTimer != null) {
708: tmrTimer.cancel ();
709: }
710: }
711:
712:
713:
714:
715:
716:
717:
718:
719:
720:
721:
722:
723:
724:
725:
726:
727:
728:
729:
730:
731:
732:
733:
734:
735:
736:
737:
738:
739:
740:
741:
742:
743:
744:
745:
746: public static final int PNL_BM_OFFSET_BITS = 10;
747: public static final int PNL_BM_WIDTH = 1 << PNL_BM_OFFSET_BITS;
748: public static final int PNL_BM_HEIGHT = 1024;
749:
750:
751:
752:
753:
754: public static final String[] PNL_ASPECT_RESOLUTION_NAME = {
755: "256x256",
756: "384x256",
757: "512x512",
758: "640x480",
759: "768x512",
760: "1024x848",
761: };
762:
763: public static final int PNL_ASPECT_RESOLUTION_COUNT = PNL_ASPECT_RESOLUTION_NAME.length;
764:
765:
766: public static final String[] PNL_ASPECT_SCREEN_NAME = {
767: "1:1",
768: "64:53",
769: "4:3",
770: "7:5",
771: "13:9",
772: "3:2",
773: };
774:
775: public static final int PNL_ASPECT_RATIO_COUNT = PNL_ASPECT_SCREEN_NAME.length;
776:
777:
778:
779: public static final int[] PNL_ASPECT_DEFAULT_RATIO = {
780: 2,
781: 2,
782: 2,
783: 2,
784: 5,
785: 1,
786: };
787:
788:
789: public static final String[] PNL_ASPECT_PIXEL_NAME_02 = {
790: "1:1",
791: null,
792: "4:3",
793: "7:5",
794: "13:9",
795: "3:2",
796: };
797:
798:
799: public static final String[] PNL_ASPECT_PIXEL_NAME_14 = {
800: null,
801: null,
802: "8:9",
803: "14:15",
804: "26:27",
805: "1:1",
806: };
807:
808:
809: public static final String[] PNL_ASPECT_PIXEL_NAME_3 = {
810: null,
811: null,
812: "1:1",
813: "21:20",
814: "13:12",
815: "9:8",
816: };
817:
818:
819: public static final String[] PNL_ASPECT_PIXEL_NAME_5 = {
820: null,
821: "1:1",
822: "53:48",
823: "371:320",
824: "689:576",
825: "159:128",
826: };
827:
828:
829: public static final float[] PNL_ASPECT_SCREEN_RATIO = {
830: 1.0F / 1.0F,
831: 64.0F / 53.0F,
832: 4.0F / 3.0F,
833: 7.0F / 5.0F,
834: 13.0F / 9.0F,
835: 3.0F / 2.0F,
836: };
837:
838:
839: public static final float[] PNL_ASPECT_PIXEL_RATIO_02 = {
840: 1.0F / 1.0F,
841: 0.0F,
842: 4.0F / 3.0F,
843: 7.0F / 5.0F,
844: 13.0F / 9.0F,
845: 3.0F / 2.0F,
846: };
847:
848:
849: public static final float[] PNL_ASPECT_PIXEL_RATIO_14 = {
850: 0.0F,
851: 0.0F,
852: 8.0F / 9.0F,
853: 14.0F / 15.0F,
854: 26.0F / 27.0F,
855: 1.0F / 1.0F,
856: };
857:
858:
859: public static final float[] PNL_ASPECT_PIXEL_RATIO_3 = {
860: 0.0F,
861: 0.0F,
862: 1.0F / 1.0F,
863: 21.0F / 20.0F,
864: 13.0F / 12.0F,
865: 9.0F / 8.0F,
866: };
867:
868:
869: public static final float[] PNL_ASPECT_PIXEL_RATIO_5 = {
870: 0.0F,
871: 1.0F / 1.0F,
872: 53.0F / 48.0F,
873: 371.0F / 320.0F,
874: 689.0F / 576.0F,
875: 159.0F / 128.0F,
876: };
877:
878:
879: public static final String[][] PNL_ASPECT_NAME_MATRIX = {
880: PNL_ASPECT_PIXEL_NAME_02,
881: PNL_ASPECT_PIXEL_NAME_14,
882: PNL_ASPECT_PIXEL_NAME_02,
883: PNL_ASPECT_PIXEL_NAME_3,
884: PNL_ASPECT_PIXEL_NAME_14,
885: PNL_ASPECT_PIXEL_NAME_5,
886: };
887:
888:
889: public static final float[][] PNL_ASPECT_RATIO_MATRIX = {
890: PNL_ASPECT_PIXEL_RATIO_02,
891: PNL_ASPECT_PIXEL_RATIO_14,
892: PNL_ASPECT_PIXEL_RATIO_02,
893: PNL_ASPECT_PIXEL_RATIO_3,
894: PNL_ASPECT_PIXEL_RATIO_14,
895: PNL_ASPECT_PIXEL_RATIO_5,
896: };
897:
898:
899: public static int[] pnlAspectMap;
900:
901:
902: public static float[] pnlAspectTableX;
903: public static float[] pnlAspectTableY;
904:
905:
906: public static final int PNL_MIN_WIDTH = 64;
907: public static final int PNL_MIN_HEIGHT = 64;
908: public static int pnlScreenWidth;
909: public static int pnlScreenHeight;
910: public static float pnlStretchModeX;
911: public static float pnlStretchModeY;
912: public static int pnlStretchWidth;
913: public static int pnlStretchHeight;
914:
915: public static boolean PNL_ROTATION_ON = true;
916: public static int pnlRotationMode;
917: public static AffineTransform pnlRotationTransformLeft;
918: public static AffineTransform pnlRotationTransformRight;
919: public static double pnlMatrixL00, pnlMatrixL10, pnlMatrixL01, pnlMatrixL11, pnlMatrixL02, pnlMatrixL12;
920: public static double pnlMatrixR00, pnlMatrixR10, pnlMatrixR01, pnlMatrixR11, pnlMatrixR02, pnlMatrixR12;
921: public static double pnlInverseL00, pnlInverseL10, pnlInverseL01, pnlInverseL11, pnlInverseL02, pnlInverseL12;
922: public static double pnlInverseR00, pnlInverseR10, pnlInverseR01, pnlInverseR11, pnlInverseR02, pnlInverseR12;
923: public static int pnlRotatedWidth;
924: public static int pnlRotatedHeight;
925:
926: public static int pnlZoomWidth;
927: public static int pnlZoomHeight;
928: public static int pnlZoomRatioOutX;
929: public static int pnlZoomRatioOutY;
930: public static int pnlZoomRatioInX;
931: public static int pnlZoomRatioInY;
932: public static int pnlWidth;
933: public static int pnlHeight;
934: public static Dimension pnlSize;
935: public static int pnlScreenX1;
936: public static int pnlScreenX2;
937: public static int pnlScreenX3;
938: public static int pnlScreenX4;
939: public static int pnlScreenY1;
940: public static int pnlScreenY2;
941: public static int pnlScreenY3;
942: public static int pnlScreenY4;
943: public static int pnlKeyboardX;
944: public static int pnlKeyboardY;
945: public static int pnlMinimumWidth;
946: public static int pnlMinimumHeight;
947: public static int pnlGlobalX;
948: public static int pnlGlobalY;
949:
950:
951: public static final boolean PNL_FILL_BACKGROUND = true;
952: public static boolean pnlFillBackgroundRequest;
953: public static boolean pnlIsFullScreenSupported;
954: public static boolean pnlPrevKeyboardOn;
955: public static boolean pnlHideKeyboard;
956:
957:
958:
959:
960:
961: public static Object pnlInterpolation;
962:
963:
964: public static final double PNL_MIN_RATE = 1.0;
965: public static final double PNL_MAX_RATE = 1000.0;
966: public static final double PNL_DEFAULT_RATE = 59.94;
967: public static double pnlRefreshRate;
968: public static double pnlFixedRate;
969: public static boolean pnlAdjustVsync;
970:
971:
972:
973:
974:
975:
976:
977:
978:
979:
980:
981:
982:
983:
984:
985:
986:
987:
988:
989:
990:
991:
992:
993:
994:
995:
996:
997:
998:
999:
1000:
1001:
1002:
1003:
1004:
1005:
1006:
1007:
1008:
1009:
1010:
1011:
1012:
1013:
1014:
1015:
1016:
1017:
1018:
1019: public static final boolean PNL_STEREOSCOPIC_ON = true;
1020:
1021: public static final boolean PNL_USE_THREAD = true;
1022:
1023: public static BufferedImage[] pnlScreenImageLeftArray;
1024: public static BufferedImage[] pnlScreenImageRightArray;
1025:
1026: public static BufferedImage[] pnlScreenSubImageLeftArray;
1027: public static BufferedImage[] pnlScreenSubImageRightArray;
1028:
1029: public static int[][] pnlBMLeftArray;
1030: public static int[][] pnlBMRightArray;
1031: public static volatile int pnlBMWrite;
1032: public static volatile int pnlBMRead;
1033:
1034: public static BufferedImage pnlScreenImageLeft;
1035: public static BufferedImage pnlScreenImageRight;
1036:
1037: public static BufferedImage pnlScreenSubImageLeft;
1038: public static BufferedImage pnlScreenSubImageRight;
1039:
1040: public static int[] pnlBMLeft;
1041: public static int[] pnlBMRight;
1042:
1043: public static int[] pnlBM;
1044: public static boolean pnlStereoscopicOn;
1045: public static final int PNL_NAKED_EYE_CROSSING = 0;
1046: public static final int PNL_NAKED_EYE_PARALLEL = 1;
1047: public static final int PNL_SIDE_BY_SIDE = 2;
1048: public static final int PNL_TOP_AND_BOTTOM = 3;
1049: public static int pnlStereoscopicMethod;
1050: public static int pnlStereoscopicFactor;
1051: public static int pnlStereoscopicShutter;
1052:
1053:
1054: public static JPanel pnlPanel;
1055:
1056: public static Thread pnlThread;
1057: public static long pnlWakeupTime;
1058: public static long pnlWakeupTimeMNP;
1059: public static final boolean PNL_USE_CANVAS = PNL_USE_THREAD && true;
1060:
1061: public static boolean pnlUseCanvasRequest;
1062: public static boolean pnlUseCanvas;
1063: public static Canvas pnlCanvas;
1064: public static Component pnlCanvasOrPanel;
1065:
1066:
1067:
1068:
1069: public static int pnlFixedScale;
1070: public static SpinnerNumberModel pnlFixedModel;
1071: public static JSpinner pnlFixedSpinner;
1072:
1073:
1074:
1075: public static void pnlInit () {
1076: pnlInit2 ();
1077:
1078:
1079:
1080:
1081: pnlFixedScale = Math.max (10, Math.min (1000, Settings.sgsGetInt ("fixedscale")));
1082:
1083:
1084: pnlAspectMap = new int[PNL_ASPECT_RESOLUTION_COUNT];
1085: for (int resolutionNumber = 0; resolutionNumber < PNL_ASPECT_RESOLUTION_COUNT; resolutionNumber++) {
1086: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[resolutionNumber];
1087: String screenName = Settings.sgsGetString ("aspectratio" + resolutionName);
1088: int ratioNumber = PNL_ASPECT_DEFAULT_RATIO[resolutionNumber];
1089: for (int tempRatioNumber = 0; tempRatioNumber < PNL_ASPECT_RATIO_COUNT; tempRatioNumber++) {
1090: if (PNL_ASPECT_RATIO_MATRIX[resolutionNumber][tempRatioNumber] == 0.0F) {
1091: continue;
1092: }
1093: if (PNL_ASPECT_SCREEN_NAME[tempRatioNumber].equals (screenName)) {
1094: ratioNumber = tempRatioNumber;
1095: break;
1096: }
1097: }
1098: pnlAspectMap[resolutionNumber] = ratioNumber;
1099: }
1100: pnlAspectTableX = new float[64];
1101: pnlAspectTableY = new float[64];
1102: pnlUpdateAspectTable ();
1103:
1104:
1105: switch (Settings.sgsGetString ("interpolation").toLowerCase ()) {
1106: case "nearest":
1107: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
1108: break;
1109: case "bilinear":
1110: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
1111: break;
1112: case "bicubic":
1113: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
1114: break;
1115: default:
1116: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
1117: }
1118:
1119:
1120: pnlRefreshRate = 0.0;
1121: {
1122: String s = Settings.sgsGetString ("refreshrate");
1123: if (!s.equals ("")) {
1124: try {
1125: double rate = Double.parseDouble (s);
1126: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
1127: pnlRefreshRate = rate;
1128: }
1129: } catch (NumberFormatException nfe) {
1130: }
1131: }
1132: }
1133: pnlFixedRate = pnlRefreshRate;
1134: pnlAdjustVsync = Settings.sgsGetOnOff ("adjustvsync");
1135:
1136: pnlPrevKeyboardOn = true;
1137:
1138: pnlHideKeyboard = Settings.sgsGetOnOff ("hidekeyboard");
1139:
1140:
1141: if (PNL_USE_THREAD) {
1142: pnlScreenImageLeftArray = new BufferedImage[4];
1143: pnlScreenImageRightArray = new BufferedImage[4];
1144: if (PNL_ROTATION_ON) {
1145: pnlScreenSubImageLeftArray = new BufferedImage[4];
1146: pnlScreenSubImageRightArray = new BufferedImage[4];
1147: }
1148: pnlBMLeftArray = new int[4][];
1149: pnlBMRightArray = new int[4][];
1150: for (int n = 0; n < 4; n++) {
1151: pnlScreenImageLeftArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1152: pnlScreenImageRightArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1153: if (PNL_ROTATION_ON) {
1154: pnlScreenSubImageLeftArray[n] = null;
1155: pnlScreenSubImageRightArray[n] = null;
1156: }
1157: pnlBMLeftArray[n] = ((DataBufferInt) pnlScreenImageLeftArray[n].getRaster ().getDataBuffer ()).getData ();
1158: pnlBMRightArray[n] = ((DataBufferInt) pnlScreenImageRightArray[n].getRaster ().getDataBuffer ()).getData ();
1159: }
1160: pnlBMWrite = 0;
1161: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
1162: pnlBMRead = 0;
1163: pnlThread = null;
1164: pnlWakeupTime = 0L;
1165: pnlWakeupTimeMNP = 0L;
1166: if (PNL_USE_CANVAS) {
1167: pnlUseCanvasRequest = Settings.sgsGetOnOff ("usecanvas");
1168: pnlUseCanvas = pnlUseCanvasRequest;
1169: pnlCanvas = null;
1170: }
1171: } else {
1172: pnlScreenImageLeft = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1173: pnlScreenImageRight = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1174: if (PNL_ROTATION_ON) {
1175: pnlScreenSubImageLeft = null;
1176: pnlScreenSubImageRight = null;
1177: }
1178: pnlBMLeft = ((DataBufferInt) pnlScreenImageLeft.getRaster ().getDataBuffer ()).getData ();
1179: pnlBMRight = ((DataBufferInt) pnlScreenImageRight.getRaster ().getDataBuffer ()).getData ();
1180: pnlBM = pnlBMLeft;
1181: }
1182: pnlStereoscopicOn = Settings.sgsGetOnOff ("stereoscopic");
1183: switch (Settings.sgsGetString ("stereoscopicmethod").toLowerCase ()) {
1184: case "nakedeyecrossing":
1185: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
1186: break;
1187: case "nakedeyeparallel":
1188: pnlStereoscopicMethod = PNL_NAKED_EYE_PARALLEL;
1189: break;
1190: case "sidebyside":
1191: pnlStereoscopicMethod = PNL_SIDE_BY_SIDE;
1192: break;
1193: case "topandbottom":
1194: pnlStereoscopicMethod = PNL_TOP_AND_BOTTOM;
1195: break;
1196: default:
1197: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
1198: }
1199: pnlStereoscopicFactor = pnlStereoscopicOn && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1200: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1201: pnlStereoscopicShutter = 0;
1202:
1203:
1204: pnlScreenWidth = 768;
1205: pnlScreenHeight = 512;
1206: pnlStretchModeX = 1.0F;
1207: pnlStretchModeY = 1.0F;
1208: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchModeX);
1209: pnlStretchHeight = Math.round ((float) pnlScreenHeight * pnlStretchModeY);
1210:
1211: if (PNL_ROTATION_ON) {
1212: pnlRotationMode = Settings.sgsGetInt ("rotation", 0);
1213: if (pnlRotationMode < 0 || 3 < pnlRotationMode) {
1214: pnlRotationMode = 0;
1215: }
1216: pnlRotationTransformLeft = new AffineTransform ();
1217: pnlRotationTransformRight = new AffineTransform ();
1218: }
1219: pnlRotatedWidth = pnlStretchWidth;
1220: pnlRotatedHeight = pnlStretchHeight;
1221: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1222: pnlRotatedWidth = pnlStretchHeight;
1223: pnlRotatedHeight = pnlStretchWidth;
1224: }
1225:
1226: pnlZoomWidth = pnlRotatedWidth;
1227: pnlZoomHeight = pnlRotatedHeight;
1228: pnlWidth = Math.max (pnlZoomWidth * pnlStereoscopicFactor, Keyboard.kbdWidth);
1229: pnlHeight = pnlZoomHeight + Keyboard.kbdHeight;
1230: pnlSize = new Dimension (pnlWidth, pnlHeight);
1231: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1232: pnlScreenY1 = 0;
1233: pnlArrangementCommon ();
1234: pnlMinimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
1235: pnlMinimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
1236: pnlGlobalX = 0;
1237: pnlGlobalY = 0;
1238:
1239:
1240: if (!PNL_FILL_BACKGROUND) {
1241: pnlFillBackgroundRequest = true;
1242: }
1243:
1244:
1245: pnlFixedModel = new SpinnerNumberModel (pnlFixedScale, 10, 1000, 1);
1246: pnlFixedSpinner = ComponentFactory.createNumberSpinner (pnlFixedModel, 4, new ChangeListener () {
1247: @Override public void stateChanged (ChangeEvent ce) {
1248: if (pnlMode != PNL_FIXEDSCALE) {
1249: pnlSetMode (PNL_FIXEDSCALE);
1250: } else {
1251: pnlUpdateArrangement ();
1252: }
1253: }
1254: });
1255:
1256: if (PNL_ROUNDED_CORNER_ON) {
1257: pnlRoundedCornerModel = new SpinnerNumberModel (pnlRoundedCornerRatio, 0, 50, 1);
1258: pnlRoundedCornerSpinner = ComponentFactory.createNumberSpinner (pnlRoundedCornerModel, 2, new ChangeListener () {
1259: @Override public void stateChanged (ChangeEvent ce) {
1260: pnlRoundedCornerRatio = pnlRoundedCornerModel.getNumber ().intValue ();
1261: if (PNL_ROUNDED_CORNER_TEST || pnlMode == PNL_FULLSCREEN) {
1262: pnlUpdateArrangement ();
1263: }
1264: }
1265: });
1266: }
1267:
1268: }
1269:
1270:
1271:
1272: public static double pnlGetRefreshRate () {
1273: double rate = 0.0;
1274: GraphicsConfiguration gc = frmFrame.getGraphicsConfiguration ();
1275: if (gc != null) {
1276: GraphicsDevice gd = gc.getDevice ();
1277: DisplayMode dm = gd.getDisplayMode ();
1278: int i = dm.getRefreshRate ();
1279: if (i != DisplayMode.REFRESH_RATE_UNKNOWN) {
1280: rate = (i == 23 ? 23.98 :
1281: i == 29 ? 29.97 :
1282: i == 59 ? 59.94 :
1283: i == 119 ? 119.88 :
1284: i == 239 ? 239.76 :
1285: (double) i);
1286: if (rate < PNL_MIN_RATE || PNL_MAX_RATE < rate) {
1287: rate = 0.0;
1288: }
1289: }
1290: }
1291: if (rate == 0.0) {
1292: rate = PNL_DEFAULT_RATE;
1293: System.out.printf (Multilingual.mlnJapanese ?
1294: "ホストのリフレッシュレートを取得できません。デフォルトの %.2f Hz を使います\n" :
1295: "Cannot get host refresh rate. Use default %.2f Hz\n", rate);
1296: } else {
1297: System.out.printf (Multilingual.mlnJapanese ?
1298: "ホストのリフレッシュレートは %.2f Hz です\n" :
1299: "Host refresh rate is %.2f Hz\n", rate);
1300: }
1301: return rate;
1302: }
1303:
1304:
1305: public static void pnlSetStereoscopic (boolean on, int method) {
1306: if (pnlStereoscopicOn != on || pnlStereoscopicMethod != method) {
1307: pnlStereoscopicMethod = method;
1308: pnlStereoscopicFactor = on && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1309: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1310: if (!pnlStereoscopicOn && on) {
1311: if (PNL_USE_THREAD) {
1312: for (int n = 0; n < 4; n++) {
1313: System.arraycopy (pnlBMLeftArray[n], 0, pnlBMRightArray[n], 0, 1024 * 1024);
1314: }
1315: } else {
1316: System.arraycopy (pnlBMLeft, 0, pnlBMRight, 0, 1024 * 1024);
1317: }
1318: } else if (pnlStereoscopicOn && !on) {
1319: if (PNL_USE_THREAD) {
1320: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
1321: } else {
1322: pnlBM = pnlBMLeft;
1323: }
1324: }
1325: pnlStereoscopicOn = on;
1326: pnlUpdateArrangement ();
1327: }
1328: }
1329:
1330:
1331: public static void pnlTini () {
1332: pnlTini2 ();
1333: if (PNL_USE_THREAD) {
1334: if (pnlThread != null) {
1335: pnlThread.interrupt ();
1336: try {
1337: pnlThread.join ();
1338: } catch (InterruptedException ie) {
1339: }
1340: pnlThread = null;
1341: }
1342: }
1343:
1344:
1345: Settings.sgsPutInt ("fixedscale", pnlFixedScale);
1346:
1347:
1348: for (int resolutionNumber = 0; resolutionNumber < PNL_ASPECT_RESOLUTION_COUNT; resolutionNumber++) {
1349: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[resolutionNumber];
1350: int ratioNumber = pnlAspectMap[resolutionNumber];
1351: String screenName = PNL_ASPECT_SCREEN_NAME[ratioNumber];
1352: Settings.sgsPutString ("aspectratio" + resolutionName, screenName);
1353: }
1354:
1355:
1356: Settings.sgsPutString ("interpolation",
1357: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR ? "nearest" :
1358: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR ? "bilinear" :
1359: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC ? "bicubic" :
1360: "bilinear");
1361:
1362: if (pnlRefreshRate != PNL_DEFAULT_RATE) {
1363: Settings.sgsPutString ("refreshrate",
1364: pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate));
1365: }
1366: Settings.sgsPutOnOff ("adjustvsync", pnlAdjustVsync);
1367:
1368: Settings.sgsPutOnOff ("hidekeyboard", pnlHideKeyboard);
1369:
1370: if (PNL_USE_CANVAS) {
1371: Settings.sgsPutOnOff ("usecanvas", pnlUseCanvasRequest);
1372: }
1373:
1374:
1375: Settings.sgsPutOnOff ("stereoscopic", pnlStereoscopicOn);
1376: Settings.sgsPutString ("stereoscopicmethod",
1377: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ? "nakedeyecrossing" :
1378: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL ? "nakedeyeparallel" :
1379: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ? "sidebyside" :
1380: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM ? "topandbottom" :
1381: "nakedeyecrossing");
1382:
1383:
1384: if (PNL_ROTATION_ON) {
1385: Settings.sgsPutInt ("rotation", pnlRotationMode);
1386: }
1387:
1388: }
1389:
1390:
1391:
1392: public static void pnlUpdateAspectTable () {
1393: float[] ratio = new float[PNL_ASPECT_RESOLUTION_COUNT];
1394: for (int resolutionNumber = 0; resolutionNumber < PNL_ASPECT_RESOLUTION_COUNT; resolutionNumber++) {
1395: int ratioNumber = pnlAspectMap[resolutionNumber];
1396: ratio[resolutionNumber] = PNL_ASPECT_RATIO_MATRIX[resolutionNumber][ratioNumber];
1397: }
1398: Arrays.fill (pnlAspectTableY, 1.0F);
1399:
1400: pnlAspectTableX[0b0_00_00] = ratio[0] * 2.0F;
1401: pnlAspectTableX[0b0_00_01] = ratio[2];
1402: pnlAspectTableX[0b0_00_10] = ratio[4];
1403: pnlAspectTableX[0b0_00_11] = ratio[3];
1404: pnlAspectTableX[0b0_01_00] = ratio[0] * 2.0F;
1405: pnlAspectTableX[0b0_01_01] = ratio[2];
1406: pnlAspectTableX[0b0_01_10] = ratio[4];
1407: pnlAspectTableX[0b0_01_11] = ratio[3];
1408: pnlAspectTableX[0b0_10_00] = ratio[0] * 4.0F;
1409: pnlAspectTableX[0b0_10_01] = ratio[2] * 2.0F;
1410: pnlAspectTableX[0b0_10_10] = ratio[4] * 2.0F;
1411: pnlAspectTableX[0b0_10_11] = ratio[3] * 2.0F;
1412: pnlAspectTableX[0b0_11_00] = ratio[0] * 4.0F;
1413: pnlAspectTableX[0b0_11_01] = ratio[2] * 2.0F;
1414: pnlAspectTableX[0b0_11_10] = ratio[4] * 2.0F;
1415: pnlAspectTableX[0b0_11_11] = ratio[3] * 2.0F;
1416: pnlAspectTableX[0b1_00_00] = ratio[0] * 2.0F;
1417: pnlAspectTableX[0b1_00_01] = ratio[1] * 2.0F;
1418: pnlAspectTableX[0b1_00_10] = ratio[4];
1419: pnlAspectTableX[0b1_00_11] = ratio[3];
1420: pnlAspectTableX[0b1_01_00] = ratio[0] * 2.0F;
1421: pnlAspectTableX[0b1_01_01] = ratio[1] * 2.0F;
1422: pnlAspectTableX[0b1_01_10] = ratio[4];
1423: pnlAspectTableX[0b1_01_11] = ratio[3];
1424: pnlAspectTableX[0b1_10_00] = ratio[0] * 4.0F;
1425: pnlAspectTableX[0b1_10_01] = ratio[1] * 2.0F;
1426: pnlAspectTableX[0b1_10_10] = ratio[4] * 2.0F;
1427: pnlAspectTableX[0b1_10_11] = ratio[3] * 2.0F;
1428: pnlAspectTableX[0b1_11_00] = ratio[0] * 4.0F;
1429: pnlAspectTableX[0b1_11_01] = ratio[1] * 2.0F;
1430: pnlAspectTableX[0b1_11_10] = ratio[4] * 2.0F;
1431: pnlAspectTableX[0b1_11_11] = ratio[3] * 2.0F;
1432:
1433: for (int i = 0; i < 32; i++) {
1434: pnlAspectTableX[32 + i] = pnlAspectTableX[i];
1435: }
1436:
1437: pnlAspectTableX[32 + 0b0_00_10] = ratio[5];
1438: pnlAspectTableY[32 + 0b0_00_10] = 2.0F;
1439: pnlAspectTableX[32 + 0b0_01_10] = ratio[5];
1440: pnlAspectTableY[32 + 0b0_01_10] = 2.0F;
1441: pnlAspectTableX[32 + 0b0_10_10] = ratio[5];
1442: pnlAspectTableX[32 + 0b0_11_10] = ratio[5];
1443: pnlAspectTableX[32 + 0b1_00_01] = ratio[5];
1444: pnlAspectTableX[32 + 0b1_01_01] = ratio[5];
1445: pnlAspectTableX[32 + 0b1_10_01] = ratio[5] * 2.0F;
1446: pnlAspectTableX[32 + 0b1_11_01] = ratio[5] * 2.0F;
1447: }
1448:
1449:
1450:
1451: public static void pnlMake () {
1452: pnlMake2 ();
1453:
1454:
1455: if (PNL_USE_CANVAS && pnlUseCanvas) {
1456: pnlCanvas = new Canvas ();
1457: pnlPanel = new JPanel (new BorderLayout (0, 0));
1458: pnlPanel.add (pnlCanvas, BorderLayout.CENTER);
1459: pnlCanvasOrPanel = pnlCanvas;
1460: } else {
1461: pnlPanel = new JPanel () {
1462: @Override protected void paintComponent (Graphics g) {
1463: pnlPaintCommon (g);
1464: }
1465: @Override protected void paintBorder (Graphics g) {
1466: }
1467: @Override protected void paintChildren (Graphics g) {
1468: }
1469: };
1470: pnlCanvasOrPanel = pnlPanel;
1471: }
1472: pnlPanel.setBackground (Color.black);
1473: pnlPanel.setOpaque (true);
1474: pnlPanel.setPreferredSize (pnlSize);
1475:
1476: if (Mouse.musCursorAvailable) {
1477: pnlPanel.setCursor (Mouse.musCursorArray[1]);
1478: }
1479:
1480: }
1481:
1482:
1483:
1484: public static void pnlPaintCommon (Graphics g) {
1485: Graphics2D g2 = (Graphics2D) g;
1486: if (PNL_FILL_BACKGROUND || pnlFillBackgroundRequest) {
1487: if (!PNL_FILL_BACKGROUND) {
1488: pnlFillBackgroundRequest = false;
1489: }
1490: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1491: g2.setColor (Color.black);
1492: g2.fillRect (0, 0, pnlWidth, pnlHeight);
1493: }
1494: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, pnlInterpolation);
1495: if (PNL_USE_THREAD) {
1496: int d = pnlBMWrite - pnlBMRead;
1497: if (false) {
1498: System.out.print (d);
1499: }
1500: if (d < 1) {
1501: pnlBMRead += d - 1;
1502: } else if (3 < d) {
1503: pnlBMRead += d - 3;
1504: }
1505: int n = pnlBMRead++ & 3;
1506: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1507: BufferedImage leftImage;
1508: BufferedImage rightImage;
1509: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1510: leftImage = pnlScreenImageRightArray[n];
1511: rightImage = pnlScreenImageLeftArray[n];
1512: } else {
1513:
1514:
1515:
1516: leftImage = pnlScreenImageLeftArray[n];
1517: rightImage = pnlScreenImageRightArray[n];
1518: }
1519: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1520: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1521: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1522: } else {
1523: g2.drawImage (leftImage,
1524: pnlScreenX1, pnlScreenY1,
1525: pnlScreenX2, pnlScreenY2,
1526: 0, 0, pnlScreenWidth, pnlScreenHeight,
1527: null);
1528: g2.drawImage (rightImage,
1529: pnlScreenX3, pnlScreenY3,
1530: pnlScreenX4, pnlScreenY4,
1531: 0, 0, pnlScreenWidth, pnlScreenHeight,
1532: null);
1533: }
1534: } else {
1535: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1536: g2.drawImage (pnlScreenSubImageLeftArray[n], pnlRotationTransformLeft, null);
1537: } else {
1538: g2.drawImage (pnlScreenImageLeftArray[n],
1539: pnlScreenX1, pnlScreenY1,
1540: pnlScreenX2, pnlScreenY2,
1541: 0, 0, pnlScreenWidth, pnlScreenHeight,
1542: null);
1543: }
1544: }
1545: } else {
1546: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1547: BufferedImage leftImage;
1548: BufferedImage rightImage;
1549: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1550: leftImage = pnlScreenImageRight;
1551: rightImage = pnlScreenImageLeft;
1552: } else {
1553:
1554:
1555:
1556: leftImage = pnlScreenImageLeft;
1557: rightImage = pnlScreenImageRight;
1558: }
1559: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1560: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1561: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1562: } else {
1563: g2.drawImage (leftImage,
1564: pnlScreenX1, pnlScreenY1,
1565: pnlScreenX2, pnlScreenY2,
1566: 0, 0, pnlScreenWidth, pnlScreenHeight,
1567: null);
1568: g2.drawImage (rightImage,
1569: pnlScreenX3, pnlScreenY3,
1570: pnlScreenX4, pnlScreenY4,
1571: 0, 0, pnlScreenWidth, pnlScreenHeight,
1572: null);
1573: }
1574: } else {
1575: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1576: g2.drawImage (pnlScreenImageLeft, pnlRotationTransformLeft, null);
1577: } else {
1578: g2.drawImage (pnlScreenImageLeft,
1579: pnlScreenX1, pnlScreenY1,
1580: pnlScreenX2, pnlScreenY2,
1581: 0, 0, pnlScreenWidth, pnlScreenHeight,
1582: null);
1583: }
1584: }
1585: }
1586: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1587: g2.drawImage (Keyboard.kbdImage, pnlKeyboardX, pnlKeyboardY, null);
1588:
1589: if (TextCopy.txcEncloseEachTime && 0 <= TextCopy.txcRow1) {
1590: int x = TextCopy.txcCol1 << 3;
1591: int w = (TextCopy.txcCol2 - TextCopy.txcCol1 + 1) << 3;
1592: int y = TextCopy.txcRow1 << 4;
1593: int h = (TextCopy.txcRow2 - TextCopy.txcRow1 + 1) << 4;
1594: x -= CRTC.crtR10TxXCurr;
1595: y -= CRTC.crtR11TxYCurr;
1596: g2.setColor (Color.red);
1597: if (PNL_ROTATION_ON) {
1598: AffineTransform savedTransform = g2.getTransform ();
1599: g2.transform (pnlRotationTransformLeft);
1600: g2.drawRect (x, y, w, h);
1601: g2.setTransform (savedTransform);
1602: } else {
1603: g2.drawRect (pnlScreenX1 + ((x * pnlZoomRatioOutX) >> 16),
1604: pnlScreenY1 + ((y * pnlZoomRatioOutY) >> 16),
1605: ((w * pnlZoomRatioOutX) >> 16) - 1,
1606: ((h * pnlZoomRatioOutY) >> 16) - 1);
1607: }
1608: }
1609: if (Bubble.BBL_ON) {
1610: Bubble.bblDraw (g2);
1611: }
1612: }
1613:
1614:
1615:
1616:
1617: public static void pnlStart () {
1618: pnlStart2 ();
1619:
1620:
1621: ComponentFactory.addListener (
1622: pnlPanel,
1623: new ComponentAdapter () {
1624: @Override public void componentResized (ComponentEvent ce) {
1625: pnlUpdateArrangement ();
1626: }
1627: });
1628:
1629: if (PNL_USE_THREAD) {
1630: if (PNL_USE_CANVAS && pnlUseCanvas) {
1631: pnlCanvas.createBufferStrategy (2);
1632: pnlThread = new Thread () {
1633: @Override public void run () {
1634: do {
1635: BufferStrategy bs = pnlCanvas.getBufferStrategy ();
1636: if (bs != null) {
1637: Graphics g = bs.getDrawGraphics ();
1638: pnlPaintCommon (g);
1639: g.dispose ();
1640: bs.show ();
1641: }
1642: } while (!isInterrupted () && pnlWakeupCommon ());
1643: }
1644: };
1645: } else {
1646: pnlThread = new Thread () {
1647: @Override public void run () {
1648: do {
1649: pnlPanel.repaint ();
1650: if (!pnlWakeupCommon ()) {
1651: break;
1652: }
1653: } while (!isInterrupted () && pnlWakeupCommon ());
1654: }
1655: };
1656: }
1657: pnlWakeupTime = System.currentTimeMillis ();
1658: pnlWakeupTimeMNP = 0L;
1659: pnlThread.start ();
1660: }
1661:
1662: }
1663:
1664: public static boolean pnlWakeupCommon () {
1665: long t = System.currentTimeMillis ();
1666: if (CRTC.crtTotalLength == 0L) {
1667: pnlWakeupTime += 40L;
1668: } else {
1669: pnlWakeupTime += CRTC.crtTotalLength;
1670: pnlWakeupTimeMNP += CRTC.crtTotalLengthMNP;
1671: if (1000000000L <= pnlWakeupTimeMNP) {
1672: pnlWakeupTime++;
1673: pnlWakeupTimeMNP -= 1000000000L;
1674: }
1675: }
1676: pnlWakeupTime = Math.max (pnlWakeupTime, t + 4L);
1677: try {
1678: Thread.sleep (pnlWakeupTime - t);
1679: } catch (InterruptedException ie) {
1680: return false;
1681: }
1682: return true;
1683: }
1684:
1685:
1686:
1687:
1688:
1689: public static void pnlExitFullScreen (boolean dialog) {
1690: if (prgIsMac || !dialog) {
1691: pnlSetFullScreenOn (false);
1692: }
1693: }
1694:
1695:
1696:
1697: public static void pnlToggleFullScreen () {
1698: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1699: pnlSetMode (PNL_FULLSCREEN);
1700: } else {
1701: pnlSetMode (pnlPrevMode);
1702: }
1703: }
1704:
1705:
1706:
1707: public static void pnlToggleMaximized () {
1708: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1709: pnlSetMode (PNL_MAXIMIZED);
1710: } else {
1711: pnlSetMode (pnlPrevMode);
1712: }
1713: }
1714:
1715:
1716:
1717: public static void pnlSetFullScreenOn (boolean on) {
1718: if (on) {
1719: pnlSetMode (PNL_FULLSCREEN);
1720: } else if (pnlMode == PNL_FULLSCREEN) {
1721: pnlSetMode (pnlPrevMode);
1722: }
1723: }
1724:
1725:
1726:
1727:
1728: public static void pnlSetFitInWindowOn (boolean on) {
1729: if (!on) {
1730: pnlSetMode (PNL_FIXEDSCALE);
1731: } else if (pnlMode == PNL_FIXEDSCALE) {
1732: pnlSetMode (PNL_FITINWINDOW);
1733: }
1734: }
1735:
1736:
1737:
1738:
1739:
1740:
1741:
1742:
1743:
1744:
1745: public static void pnlUpdateArrangement () {
1746: pnlWidth = pnlPanel.getWidth ();
1747: pnlHeight = pnlPanel.getHeight ();
1748: frmMarginWidth = frmFrame.getWidth () - pnlWidth;
1749: frmMarginHeight = frmFrame.getHeight () - pnlHeight;
1750: int stretchIndex = CRTC.crtHRLCurr << 4 | CRTC.crtVResoCurr << 2 | CRTC.crtHResoCurr;
1751: {
1752: int htotal = CRTC.crtR00HFrontEndCurr + 1;
1753: int vtotal = CRTC.crtR04VFrontEndCurr + 1;
1754: if (0 < htotal && 0 < vtotal) {
1755: int k = CRTC.crtHRLCurr << 3 | CRTC.crtHighResoCurr << 2 | CRTC.crtHResoCurr;
1756: double osc = (double) CRTC.crtFreqs[CRTC.CRT_OSCS[k]] * CRTC.crtVsyncMultiplier;
1757: int ratio = CRTC.CRT_DIVS[k];
1758: double hfreq = osc / (ratio * htotal << 3);
1759: if (24000.0 <= hfreq && hfreq < 25000.0) {
1760: stretchIndex += 32;
1761: }
1762: }
1763: }
1764: pnlStretchModeX = pnlAspectTableX[stretchIndex];
1765: pnlStretchModeY = pnlAspectTableY[stretchIndex];
1766: pnlScreenWidth = Math.max (PNL_MIN_WIDTH, (CRTC.crtR03HDispEndCurr - CRTC.crtR02HBackEndCurr) << 3);
1767: pnlScreenHeight = Math.max (PNL_MIN_HEIGHT, (CRTC.crtR07VDispEndCurr - CRTC.crtR06VBackEndCurr) << (CRTC.crtInterlace || CRTC.crtSlit ? 1 : 0));
1768: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchModeX);
1769: pnlStretchHeight = Math.round ((float) pnlScreenHeight * pnlStretchModeY);
1770: if (RasterBreakPoint.RBP_ON) {
1771:
1772: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
1773: RasterBreakPoint.rbpUpdateFrame ();
1774: }
1775: }
1776:
1777: pnlFixedScale = pnlFixedModel.getNumber ().intValue ();
1778:
1779: pnlRotatedWidth = pnlStretchWidth;
1780: pnlRotatedHeight = pnlStretchHeight;
1781: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1782: pnlRotatedWidth = pnlStretchHeight;
1783: pnlRotatedHeight = pnlStretchWidth;
1784: }
1785: if (pnlMode == PNL_FIXEDSCALE) {
1786:
1787:
1788:
1789:
1790:
1791: pnlZoomWidth = (pnlRotatedWidth * pnlFixedScale + 50) * 5243 >>> 19;
1792: pnlZoomHeight = (pnlRotatedHeight * pnlFixedScale + 50) * 5243 >>> 19;
1793: int width = Math.max (Math.max (PNL_MIN_WIDTH, pnlZoomWidth * pnlStereoscopicFactor), Keyboard.kbdWidth);
1794: int height = Math.max (PNL_MIN_HEIGHT, pnlZoomHeight) + Keyboard.kbdHeight;
1795: pnlScreenX1 = (width - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1796: pnlScreenY1 = (height - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1797: if (pnlWidth != width || pnlHeight != height) {
1798: pnlWidth = width;
1799: pnlHeight = height;
1800: pnlMinimumWidth = width;
1801: pnlMinimumHeight = height;
1802: pnlSize.setSize (width, height);
1803: pnlPanel.setMinimumSize (pnlSize);
1804: pnlPanel.setMaximumSize (pnlSize);
1805: pnlPanel.setPreferredSize (pnlSize);
1806: }
1807: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1808: frmFrame.setMinimumSize (frmMinimumSize);
1809: frmFrame.setMaximumSize (frmMinimumSize);
1810: frmFrame.setPreferredSize (frmMinimumSize);
1811: frmFrame.setResizable (false);
1812: frmFrame.pack ();
1813: } else {
1814:
1815: if (PNL_ROUNDED_CORNER_ON) {
1816:
1817: int screenWidth = pnlRotatedWidth * pnlStereoscopicFactor;
1818:
1819: int screenHeight = pnlRotatedHeight;
1820:
1821: int maximumWidth = pnlWidth;
1822:
1823: int maximumHeight = pnlHeight - Keyboard.kbdHeight;
1824:
1825:
1826:
1827: double cornerRadius = (!(PNL_ROUNDED_CORNER_TEST || pnlMode == PNL_FULLSCREEN) ||
1828: (pnlStereoscopicOn &&
1829: (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ||
1830: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM)) ? 0 :
1831: Math.min (pnlWidth, pnlHeight) * (double) pnlRoundedCornerRatio / 100.0);
1832:
1833: double cornerWidth = cornerRadius * 2.0;
1834:
1835: double cornerHeight = cornerRadius * (Keyboard.kbdHeight != 0 ? 1.0 : 2.0);
1836:
1837: double straightWidth = maximumWidth - cornerWidth;
1838:
1839: double straightHeight = maximumHeight - cornerHeight;
1840: if (maximumHeight * screenWidth <= straightWidth * screenHeight) {
1841:
1842:
1843:
1844: pnlZoomHeight = maximumHeight;
1845:
1846: pnlZoomWidth = (pnlZoomHeight * screenWidth + (screenHeight >> 1)) / screenHeight;
1847:
1848: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1849:
1850: pnlScreenX1 = ((maximumWidth >> 1) - (pnlZoomWidth >> 1)) >> 1;
1851: } else {
1852: pnlScreenX1 = (maximumWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1853: }
1854: pnlScreenY1 = 0;
1855: } else if (maximumWidth * screenHeight <= straightHeight * screenWidth) {
1856:
1857:
1858:
1859: pnlZoomWidth = maximumWidth;
1860:
1861: pnlZoomHeight = (pnlZoomWidth * screenHeight + (screenWidth >> 1)) / screenWidth;
1862:
1863: pnlScreenX1 = 0;
1864: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM) {
1865:
1866: pnlScreenY1 = ((maximumHeight >> 1) - (pnlZoomHeight >> 1)) >> 1;
1867: } else {
1868: pnlScreenY1 = (maximumHeight - pnlZoomHeight) >> 1;
1869: }
1870: } else {
1871:
1872:
1873:
1874:
1875:
1876:
1877:
1878:
1879:
1880:
1881:
1882:
1883:
1884:
1885:
1886:
1887:
1888:
1889:
1890:
1891:
1892:
1893:
1894: double ax = 1.0;
1895: double ay = 0.0;
1896: double bx = 0.0;
1897: double by = 1.0;
1898: for (int i = 0; i < 4; i++) {
1899: double mx;
1900: double my;
1901: if (false) {
1902: double t = (ax * bx - ay * by) * 0.5;
1903: mx = Math.sqrt (0.5 + t);
1904: my = Math.sqrt (0.5 - t);
1905: } else {
1906: double sx = ax + bx;
1907: double sy = ay + by;
1908: double t = Math.cbrt (2.0 + 3.0 * (ax * bx * sx + ay * by * sy));
1909: mx = sx / t;
1910: my = sy / t;
1911: }
1912:
1913: double temporaryWidth = straightWidth + mx * cornerWidth;
1914:
1915: double temporaryHeight = straightHeight + my * cornerHeight;
1916: if (temporaryHeight * screenWidth <= temporaryWidth * screenHeight) {
1917:
1918:
1919: ax = mx;
1920: ay = my;
1921: } else {
1922:
1923: bx = mx;
1924: by = my;
1925: }
1926: }
1927:
1928:
1929:
1930:
1931:
1932:
1933:
1934:
1935:
1936:
1937:
1938:
1939: double t = (((straightHeight + ay * cornerHeight) * screenWidth
1940: - (straightWidth + ax * cornerWidth) * screenHeight)
1941: / ((bx - ax) * cornerWidth * screenHeight
1942: - (by - ay) * cornerHeight * screenWidth));
1943:
1944: pnlZoomWidth = (int) Math.round (straightWidth + (ax + (bx - ax) * t) * cornerWidth);
1945: if (false) {
1946:
1947: pnlZoomHeight = (int) Math.round (straightHeight + (ay + (by - ay) * t) * cornerHeight);
1948: } else {
1949:
1950: pnlZoomHeight = (pnlZoomWidth * screenHeight + (screenWidth >> 1)) / screenWidth;
1951: }
1952:
1953: pnlScreenX1 = (maximumWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1954: pnlScreenY1 = (maximumHeight - pnlZoomHeight) >> 1;
1955: }
1956: } else {
1957: if (pnlWidth * pnlRotatedHeight >= (pnlHeight - Keyboard.kbdHeight) * (pnlRotatedWidth * pnlStereoscopicFactor)) {
1958:
1959:
1960:
1961:
1962:
1963:
1964:
1965:
1966:
1967:
1968:
1969:
1970: pnlZoomHeight = pnlHeight - Keyboard.kbdHeight;
1971: pnlZoomWidth = (pnlZoomHeight * pnlRotatedWidth + (pnlRotatedHeight >> 1)) / pnlRotatedHeight;
1972: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1973: pnlScreenX1 = ((pnlWidth >> 1) - (pnlZoomWidth >> 1)) >> 1;
1974: } else {
1975: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1976: }
1977: pnlScreenY1 = 0;
1978: } else {
1979:
1980:
1981:
1982:
1983:
1984:
1985:
1986:
1987:
1988:
1989:
1990:
1991:
1992:
1993:
1994:
1995: pnlZoomWidth = pnlWidth / pnlStereoscopicFactor;
1996: pnlZoomHeight = (pnlZoomWidth * pnlStereoscopicFactor * pnlRotatedHeight + (pnlRotatedWidth * pnlStereoscopicFactor >> 1)) / (pnlRotatedWidth * pnlStereoscopicFactor);
1997: pnlScreenX1 = 0;
1998: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM) {
1999: pnlScreenY1 = (((pnlHeight - Keyboard.kbdHeight) >> 1) - (pnlZoomHeight >> 1)) >> 1;
2000: } else {
2001: pnlScreenY1 = (pnlHeight - (pnlZoomHeight + Keyboard.kbdHeight)) >> 1;
2002: }
2003: }
2004: }
2005:
2006: int minimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
2007: int minimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
2008: if (pnlMinimumWidth != minimumWidth || pnlMinimumHeight != minimumHeight) {
2009: pnlMinimumWidth = minimumWidth;
2010: pnlMinimumHeight = minimumHeight;
2011: }
2012: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
2013: frmFrame.setMinimumSize (frmMinimumSize);
2014: frmFrame.setMaximumSize (null);
2015: frmFrame.setResizable (true);
2016: }
2017:
2018: pnlArrangementCommon ();
2019: Mouse.musUpdateSpeedRatio ();
2020: if (!PNL_FILL_BACKGROUND) {
2021: pnlFillBackgroundRequest = true;
2022: }
2023: }
2024:
2025: public static void pnlArrangementCommon () {
2026: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
2027: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
2028: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) {
2029: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
2030: pnlScreenX3 = pnlScreenX2;
2031: pnlScreenX4 = pnlScreenX3 + pnlZoomWidth;
2032: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
2033: pnlScreenY3 = pnlScreenY1;
2034: pnlScreenY4 = pnlScreenY2;
2035: } else if (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
2036: pnlScreenX2 = pnlScreenX1 + (pnlZoomWidth >> 1);
2037: pnlScreenX3 = pnlScreenX2;
2038: pnlScreenX4 = pnlScreenX3 + (pnlZoomWidth >> 1);
2039: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
2040: pnlScreenY3 = pnlScreenY1;
2041: pnlScreenY4 = pnlScreenY2;
2042: } else {
2043: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
2044: pnlScreenX3 = pnlScreenX1;
2045: pnlScreenX4 = pnlScreenX2;
2046: pnlScreenY2 = pnlScreenY1 + (pnlZoomHeight >> 1);
2047: pnlScreenY3 = pnlScreenY2;
2048: pnlScreenY4 = pnlScreenY3 + (pnlZoomHeight >> 1);
2049: }
2050: } else {
2051: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
2052: pnlScreenX3 = pnlScreenX1;
2053: pnlScreenX4 = pnlScreenX2;
2054: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
2055: pnlScreenY3 = pnlScreenY1;
2056: pnlScreenY4 = pnlScreenY2;
2057: }
2058: pnlKeyboardX = (pnlWidth - Keyboard.kbdWidth) >> 1;
2059: pnlKeyboardY = pnlScreenY4;
2060: pnlZoomRatioOutX = ((pnlZoomWidth * pnlStereoscopicFactor) << 16) / pnlScreenWidth;
2061: pnlZoomRatioOutY = (pnlZoomHeight << 16) / pnlScreenHeight;
2062: pnlZoomRatioInX = (pnlScreenWidth << 16) / (pnlZoomWidth * pnlStereoscopicFactor);
2063: pnlZoomRatioInY = (pnlScreenHeight << 16) / pnlZoomHeight;
2064: if (PNL_ROTATION_ON) {
2065:
2066: if (PNL_USE_THREAD) {
2067: for (int n = 0; n < 4; n++) {
2068: pnlScreenSubImageLeftArray[n] = pnlScreenImageLeftArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
2069: pnlScreenSubImageRightArray[n] = pnlScreenImageRightArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
2070: }
2071: } else {
2072: pnlScreenSubImageLeft = pnlScreenImageLeft.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
2073: pnlScreenSubImageRight = pnlScreenImageRight.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
2074: }
2075:
2076:
2077:
2078:
2079: double ax = 0.0;
2080: double ay = 0.0;
2081: double bx = (double) pnlScreenWidth;
2082: double by = (double) pnlScreenHeight;
2083: double l00, l10, l01, l11, l02, l12;
2084: double r00, r10, r01, r11, r02, r12;
2085: if (pnlRotationMode == 0) {
2086: double cx = (double) pnlScreenX1;
2087: double cy = (double) pnlScreenY1;
2088: double dx = (double) pnlScreenX2;
2089: double dy = (double) pnlScreenY2;
2090: l00 = (cx - dx) / (ax - bx);
2091: l10 = 0.0;
2092: l01 = 0.0;
2093: l11 = (cy - dy) / (ay - by);
2094: l02 = (ax * dx - bx * cx) / (ax - bx);
2095: l12 = (ay * dy - by * cy) / (ay - by);
2096: cx = (double) pnlScreenX3;
2097: cy = (double) pnlScreenY3;
2098: dx = (double) pnlScreenX4;
2099: dy = (double) pnlScreenY4;
2100: r00 = (cx - dx) / (ax - bx);
2101: r10 = 0.0;
2102: r01 = 0.0;
2103: r11 = (cy - dy) / (ay - by);
2104: r02 = (ax * dx - bx * cx) / (ax - bx);
2105: r12 = (ay * dy - by * cy) / (ay - by);
2106: } else if (pnlRotationMode == 1) {
2107: double cx = (double) pnlScreenX1;
2108: double cy = (double) pnlScreenY1;
2109: double dx = (double) pnlScreenX2;
2110: double dy = (double) pnlScreenY2;
2111: l00 = 0.0;
2112: l10 = (dy - cy) / (ax - bx);
2113: l01 = (cx - dx) / (ay - by);
2114: l11 = 0.0;
2115: l02 = (ay * dx - by * cx) / (ay - by);
2116: l12 = (ax * cy - bx * dy) / (ax - bx);
2117: cx = (double) pnlScreenX3;
2118: cy = (double) pnlScreenY3;
2119: dx = (double) pnlScreenX4;
2120: dy = (double) pnlScreenY4;
2121: r00 = 0.0;
2122: r10 = (dy - cy) / (ax - bx);
2123: r01 = (cx - dx) / (ay - by);
2124: r11 = 0.0;
2125: r02 = (ay * dx - by * cx) / (ay - by);
2126: r12 = (ax * cy - bx * dy) / (ax - bx);
2127: } else if (pnlRotationMode == 2) {
2128: double cx = (double) pnlScreenX1;
2129: double cy = (double) pnlScreenY1;
2130: double dx = (double) pnlScreenX2;
2131: double dy = (double) pnlScreenY2;
2132: l00 = (dx - cx) / (ax - bx);
2133: l10 = 0.0;
2134: l01 = 0.0;
2135: l11 = (dy - cy) / (ay - by);
2136: l02 = (ax * cx - bx * dx) / (ax - bx);
2137: l12 = (ay * cy - by * dy) / (ay - by);
2138: cx = (double) pnlScreenX3;
2139: cy = (double) pnlScreenY3;
2140: dx = (double) pnlScreenX4;
2141: dy = (double) pnlScreenY4;
2142: r00 = (dx - cx) / (ax - bx);
2143: r10 = 0.0;
2144: r01 = 0.0;
2145: r11 = (dy - cy) / (ay - by);
2146: r02 = (ax * cx - bx * dx) / (ax - bx);
2147: r12 = (ay * cy - by * dy) / (ay - by);
2148: } else {
2149: double cx = (double) pnlScreenX1;
2150: double cy = (double) pnlScreenY1;
2151: double dx = (double) pnlScreenX2;
2152: double dy = (double) pnlScreenY2;
2153: l00 = 0.0;
2154: l10 = (cy - dy) / (ax - bx);
2155: l01 = (dx - cx) / (ay - by);
2156: l11 = 0.0;
2157: l02 = (ay * cx - by * dx) / (ay - by);
2158: l12 = (ax * dy - bx * cy) / (ax - bx);
2159: cx = (double) pnlScreenX3;
2160: cy = (double) pnlScreenY3;
2161: dx = (double) pnlScreenX4;
2162: dy = (double) pnlScreenY4;
2163: r00 = 0.0;
2164: r10 = (cy - dy) / (ax - bx);
2165: r01 = (dx - cx) / (ay - by);
2166: r11 = 0.0;
2167: r02 = (ay * cx - by * dx) / (ay - by);
2168: r12 = (ax * dy - bx * cy) / (ax - bx);
2169: }
2170: pnlRotationTransformLeft.setTransform (l00, l10, l01, l11, l02, l12);
2171: pnlRotationTransformRight.setTransform (r00, r10, r01, r11, r02, r12);
2172: pnlMatrixL00 = l00;
2173: pnlMatrixL10 = l10;
2174: pnlMatrixL01 = l01;
2175: pnlMatrixL11 = l11;
2176: pnlMatrixL02 = l02;
2177: pnlMatrixL12 = l12;
2178: pnlMatrixR00 = r00;
2179: pnlMatrixR10 = r10;
2180: pnlMatrixR01 = r01;
2181: pnlMatrixR11 = r11;
2182: pnlMatrixR02 = r02;
2183: pnlMatrixR12 = r12;
2184:
2185:
2186:
2187:
2188:
2189:
2190: double d = l00 * l11 - l01 * l10;
2191: pnlInverseL00 = l11 / d;
2192: pnlInverseL10 = -l10 / d;
2193: pnlInverseL01 = -l01 / d;
2194: pnlInverseL11 = l00 / d;
2195: pnlInverseL02 = (l01 * l12 - l02 * l11) / d;
2196: pnlInverseL12 = (l02 * l10 - l00 * l12) / d;
2197: d = r00 * r11 - r01 * r10;
2198: pnlInverseR00 = r11 / d;
2199: pnlInverseR10 = -r10 / d;
2200: pnlInverseR01 = -r01 / d;
2201: pnlInverseR11 = r00 / d;
2202: pnlInverseR02 = (r01 * r12 - r02 * r11) / d;
2203: pnlInverseR12 = (r02 * r10 - r00 * r12) / d;
2204: }
2205: }
2206:
2207:
2208:
2209:
2210: public static final int PNL_UNDEFINED = 0;
2211: public static final int PNL_FIXEDSCALE = 1;
2212: public static final int PNL_FITINWINDOW = 2;
2213: public static final int PNL_FULLSCREEN = 3;
2214: public static final int PNL_MAXIMIZED = 4;
2215: public static int pnlModeRequest;
2216: public static int pnlMode;
2217: public static int pnlPrevMode;
2218:
2219:
2220: public static JRadioButtonMenuItem mnbFullScreenMenuItem;
2221: public static JRadioButtonMenuItem mnbMaximizedMenuItem;
2222: public static JRadioButtonMenuItem mnbFitInWindowMenuItem;
2223: public static JRadioButtonMenuItem mnbFixedScaleMenuItem;
2224:
2225:
2226:
2227:
2228:
2229: public static boolean PNL_ROUNDED_CORNER_ON = true;
2230: public static boolean PNL_ROUNDED_CORNER_TEST = false;
2231: public static int pnlRoundedCornerRatio;
2232: public static SpinnerNumberModel pnlRoundedCornerModel;
2233: public static JSpinner pnlRoundedCornerSpinner;
2234:
2235:
2236: public static int PNL_BOOT_DELAY = 500;
2237: public static javax.swing.Timer pnlBootTimer;
2238:
2239:
2240:
2241: public static void pnlInit2 () {
2242: pnlModeRequest = PNL_UNDEFINED;
2243: pnlMode = PNL_FITINWINDOW;
2244: pnlPrevMode = PNL_FITINWINDOW;
2245: switch (Settings.sgsGetString ("scaling").toLowerCase ()) {
2246: case "fullscreen":
2247: pnlModeRequest = PNL_FULLSCREEN;
2248: break;
2249: case "maximized":
2250: pnlModeRequest = PNL_MAXIMIZED;
2251: break;
2252: case "fitinwindow":
2253: break;
2254: case "fixedscale":
2255: pnlMode = PNL_FIXEDSCALE;
2256: break;
2257: }
2258: if (PNL_ROUNDED_CORNER_ON) {
2259: pnlRoundedCornerRatio = Settings.sgsGetInt ("roundedcornerratio", 0, 0, 50);
2260: }
2261: }
2262:
2263:
2264:
2265: public static void pnlTini2 () {
2266: Settings.sgsPutString ("scaling",
2267: pnlMode == PNL_FULLSCREEN ? "fullscreen" :
2268: pnlMode == PNL_MAXIMIZED ? "maximized" :
2269: pnlMode == PNL_FITINWINDOW ? "fitinwindow" :
2270: "fixedscale");
2271: if (PNL_ROUNDED_CORNER_ON) {
2272: Settings.sgsPutInt ("roundedcornerratio", pnlRoundedCornerRatio);
2273: }
2274: }
2275:
2276:
2277:
2278: public static void pnlMake2 () {
2279:
2280: ActionListener listener = new ActionListener () {
2281: @Override public void actionPerformed (ActionEvent ae) {
2282: String command = ae.getActionCommand ();
2283: switch (command) {
2284: case "Full screen":
2285: pnlSetMode (PNL_FULLSCREEN);
2286: break;
2287: case "Maximized":
2288: pnlSetMode (PNL_MAXIMIZED);
2289: break;
2290: case "Fit in window":
2291: pnlSetMode (PNL_FITINWINDOW);
2292: break;
2293: case "Fixed scale":
2294: pnlSetMode (PNL_FIXEDSCALE);
2295: break;
2296: }
2297: }
2298: };
2299: ButtonGroup group = new ButtonGroup ();
2300: mnbFullScreenMenuItem = ComponentFactory.setEnabled (
2301: Multilingual.mlnText (
2302: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FULLSCREEN, "Full screen", listener),
2303: "ja", "全画面表示"),
2304: pnlIsFullScreenSupported);
2305: mnbMaximizedMenuItem = Multilingual.mlnText (
2306: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_MAXIMIZED, "Maximized", listener),
2307: "ja", "最大化");
2308: mnbFitInWindowMenuItem = Multilingual.mlnText (
2309: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FITINWINDOW, "Fit in window", 'W', MNB_MODIFIERS, listener),
2310: "ja", "ウインドウに合わせる");
2311: mnbFixedScaleMenuItem = Multilingual.mlnText (
2312: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FIXEDSCALE, "Fixed scale", 'X', MNB_MODIFIERS, listener),
2313: "ja", "固定倍率");
2314: }
2315:
2316:
2317:
2318: public static void pnlStart2 () {
2319:
2320: frmFrame.addWindowStateListener (new WindowStateListener () {
2321: @Override public void windowStateChanged (WindowEvent we) {
2322: int state = frmFrame.getExtendedState ();
2323: if (pnlMode != PNL_MAXIMIZED &&
2324: (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
2325: pnlSetMode (PNL_MAXIMIZED);
2326: } else if (pnlMode == PNL_MAXIMIZED &&
2327: (state & Frame.MAXIMIZED_BOTH) != Frame.MAXIMIZED_BOTH) {
2328: pnlSetMode (pnlPrevMode);
2329: }
2330: }
2331: });
2332: }
2333:
2334:
2335:
2336: public static void pnlBoot2 () {
2337: if (pnlModeRequest != PNL_UNDEFINED) {
2338: pnlBootTimer = new javax.swing.Timer (PNL_BOOT_DELAY, new ActionListener () {
2339: public void actionPerformed (ActionEvent ae) {
2340: if (pnlModeRequest == PNL_FULLSCREEN) {
2341: mnbFullScreenMenuItem.doClick ();
2342: } else if (pnlModeRequest == PNL_MAXIMIZED) {
2343: mnbMaximizedMenuItem.doClick ();
2344: }
2345: pnlBootTimer.stop ();
2346: pnlBootTimer = null;
2347: }
2348: });
2349: pnlBootTimer.start ();
2350: }
2351: }
2352:
2353:
2354:
2355: public static void pnlSetMode (int mode) {
2356: do {
2357:
2358: if (pnlMode == mode) {
2359: break;
2360: }
2361:
2362: String text = null;
2363: if (mode == PNL_FULLSCREEN) {
2364: if (!pnlIsFullScreenSupported) {
2365: JOptionPane.showMessageDialog (
2366: frmFrame,
2367: Multilingual.mlnJapanese ?
2368: "全画面表示に対応していません" :
2369: "Full screen is not supported");
2370: break;
2371: }
2372: if (Bubble.BBL_ON) {
2373: text = ButtonFunction.bfnFullScreenText ();
2374: if (text == null) {
2375: JOptionPane.showMessageDialog (
2376: frmFrame,
2377: Multilingual.mlnJapanese ?
2378: "全画面表示を終了するキーまたはボタンがありません" :
2379: "No key or button to exit full screen");
2380: break;
2381: }
2382: }
2383: }
2384:
2385: if (pnlMode == PNL_FULLSCREEN) {
2386: pnlMode = pnlPrevMode;
2387: if (Bubble.BBL_ON) {
2388: Bubble.bblEnd ();
2389: }
2390: if (frmScreenDevice.getFullScreenWindow () == frmFrame) {
2391: frmScreenDevice.setFullScreenWindow (null);
2392: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.FRAME);
2393: }
2394: frmFrame.setJMenuBar (mnbMenuBar);
2395: if (pnlHideKeyboard) {
2396: if (pnlPrevKeyboardOn) {
2397: Keyboard.kbdSetOn (true);
2398: }
2399: }
2400: } else if (pnlMode == PNL_MAXIMIZED) {
2401: pnlMode = pnlPrevMode;
2402: if ((frmFrame.getExtendedState () & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
2403: frmFrame.setExtendedState (Frame.NORMAL);
2404: }
2405: }
2406:
2407: if (mode == PNL_FULLSCREEN) {
2408: pnlPrevMode = pnlMode;
2409: if (pnlHideKeyboard) {
2410: pnlPrevKeyboardOn = Keyboard.kbdImage != null;
2411: if (pnlPrevKeyboardOn) {
2412: Keyboard.kbdSetOn (false);
2413: }
2414: }
2415: frmFrame.setJMenuBar (null);
2416: if (frmScreenDevice.getFullScreenWindow () != frmFrame) {
2417: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.NONE);
2418: frmScreenDevice.setFullScreenWindow (frmFrame);
2419: }
2420: if (Bubble.BBL_ON) {
2421: if (text != null) {
2422: Bubble.bblStart (text + (Multilingual.mlnJapanese ? "で全画面表示を終了" : " to exit full screen"), 5000L);
2423: }
2424: }
2425: } else if (mode == PNL_MAXIMIZED) {
2426: pnlPrevMode = pnlMode;
2427: frmFrame.setExtendedState (Frame.MAXIMIZED_BOTH);
2428: }
2429: pnlMode = mode;
2430:
2431:
2432: pnlUpdateArrangement ();
2433: } while (false);
2434:
2435: if (pnlMode == PNL_FIXEDSCALE) {
2436: if (!mnbFixedScaleMenuItem.isSelected ()) {
2437: mnbFixedScaleMenuItem.setSelected (true);
2438: }
2439: } else if (pnlMode == PNL_FITINWINDOW) {
2440: if (!mnbFitInWindowMenuItem.isSelected ()) {
2441: mnbFitInWindowMenuItem.setSelected (true);
2442: }
2443: } else if (pnlMode == PNL_FULLSCREEN) {
2444: if (!mnbFullScreenMenuItem.isSelected ()) {
2445: mnbFullScreenMenuItem.setSelected (true);
2446: }
2447: } else if (pnlMode == PNL_MAXIMIZED) {
2448: if (!mnbMaximizedMenuItem.isSelected ()) {
2449: mnbMaximizedMenuItem.setSelected (true);
2450: }
2451: }
2452: }
2453:
2454:
2455:
2456:
2457:
2458:
2459: public static Robot rbtRobot;
2460:
2461:
2462: public static void rbtInit () {
2463:
2464:
2465: rbtRobot = null;
2466: try {
2467: rbtRobot = new Robot ();
2468: } catch (Exception e) {
2469: }
2470:
2471: }
2472:
2473:
2474:
2475:
2476:
2477:
2478:
2479: public static final int MNB_MODIFIERS = InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK;
2480:
2481:
2482: public static JMenuBar mnbMenuBar;
2483:
2484:
2485: public static JMenu mnbFileMenu;
2486: public static JMenu mnbDisplayMenu;
2487: public static JMenu mnbSoundMenu;
2488: public static JMenu mnbInputMenu;
2489: public static JMenu mnbConfigMenu;
2490: public static JMenu mnbLanguageMenu;
2491:
2492:
2493:
2494:
2495:
2496: public static JMenuItem mnbQuitMenuItem;
2497: public static JCheckBoxMenuItem mnbStereoscopicMenuItem;
2498: public static JCheckBoxMenuItem mnbPlayMenuItem;
2499: public static JMenuItem mnbPasteMenuItem;
2500: public static JRadioButtonMenuItem mnbStandardKeyboardMenuItem;
2501: public static JRadioButtonMenuItem mnbCompactKeyboardMenuItem;
2502: public static JRadioButtonMenuItem mnbNoKeyboardMenuItem;
2503: public static JLabel mnbVolumeLabel;
2504:
2505:
2506:
2507:
2508:
2509:
2510: public static JMenu mnbMakeFontSizeMenu () {
2511:
2512: ActionListener actionListener = new ActionListener () {
2513: @Override public void actionPerformed (ActionEvent ae) {
2514: String command = ae.getActionCommand ();
2515: switch (command) {
2516: case "Very small":
2517: LnF.lnfFontSizeRequest = 10;
2518: break;
2519: case "Small":
2520: LnF.lnfFontSizeRequest = 12;
2521: break;
2522: case "Medium":
2523: LnF.lnfFontSizeRequest = 14;
2524: break;
2525: case "Large":
2526: LnF.lnfFontSizeRequest = 16;
2527: break;
2528: case "Very large":
2529: LnF.lnfFontSizeRequest = 18;
2530: break;
2531: default:
2532: System.out.println ("unknown action command " + command);
2533: }
2534: }
2535: };
2536:
2537: ButtonGroup fontSizeGroup = new ButtonGroup ();
2538:
2539: return Multilingual.mlnText (
2540: ComponentFactory.createMenu (
2541: "Font size",
2542: Multilingual.mlnText (
2543: ComponentFactory.pointSize (
2544: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 10, "Very small", actionListener),
2545: 10),
2546: "ja", "極小"),
2547: Multilingual.mlnText (
2548: ComponentFactory.pointSize (
2549: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 12, "Small", actionListener),
2550: 12),
2551: "ja", "小"),
2552: Multilingual.mlnText (
2553: ComponentFactory.pointSize (
2554: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 14, "Medium", actionListener),
2555: 14),
2556: "ja", "中"),
2557: Multilingual.mlnText (
2558: ComponentFactory.pointSize (
2559: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 16, "Large", actionListener),
2560: 16),
2561: "ja", "大"),
2562: Multilingual.mlnText (
2563: ComponentFactory.pointSize (
2564: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 18, "Very large", actionListener),
2565: 18),
2566: "ja", "極大")),
2567: "ja", "フォントサイズ");
2568: }
2569:
2570:
2571:
2572: public static final DecimalSpinner[] mnbColorSpinners = new DecimalSpinner[9];
2573: public static final int[] mnbColorRGB = new int[15];
2574: public static JPanel mnbColorPanel;
2575:
2576:
2577:
2578: public static void mnbColorHSBToRGB () {
2579: for (int i = 0; i <= 14; i++) {
2580: int[] t = LnF.LNF_HSB_INTERPOLATION_TABLE[i];
2581: float h = (float) (t[0] * LnF.lnfHSB[0] + t[1] * LnF.lnfHSB[1] + t[2] * LnF.lnfHSB[2]) / (49.0F * 360.0F);
2582: float s = (float) (t[0] * LnF.lnfHSB[3] + t[1] * LnF.lnfHSB[4] + t[2] * LnF.lnfHSB[5]) / (49.0F * 100.0F);
2583: float b = (float) (t[0] * LnF.lnfHSB[6] + t[1] * LnF.lnfHSB[7] + t[2] * LnF.lnfHSB[8]) / (49.0F * 100.0F);
2584: mnbColorRGB[i] = Color.HSBtoRGB (h,
2585: Math.max (0.0F, Math.min (1.0F, s)),
2586: Math.max (0.0F, Math.min (1.0F, b)));
2587: }
2588: }
2589:
2590:
2591:
2592: public static JMenu mnbMakeColorMenu () {
2593: mnbColorHSBToRGB ();
2594:
2595: mnbColorPanel = ComponentFactory.setColor (
2596: ComponentFactory.setFixedSize (
2597: new JPanel () {
2598: @Override protected void paintComponent (Graphics g) {
2599: super.paintComponent (g);
2600: for (int i = 0; i <= 14; i++) {
2601: g.setColor (new Color (mnbColorRGB[i]));
2602: g.fillRect (LnF.lnfFontSize * i, 0, LnF.lnfFontSize, LnF.lnfFontSize * 5);
2603: }
2604: }
2605: },
2606: LnF.lnfFontSize * 15, LnF.lnfFontSize * 5),
2607: Color.white, Color.black);
2608:
2609: ChangeListener changeListener = new ChangeListener () {
2610: @Override public void stateChanged (ChangeEvent ce) {
2611: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
2612: LnF.lnfHSB[spinner.getOption ()] = spinner.getIntValue ();
2613: mnbColorHSBToRGB ();
2614: mnbColorPanel.repaint ();
2615: }
2616: };
2617:
2618: ActionListener actionListener = new ActionListener () {
2619: @Override public void actionPerformed (ActionEvent ae) {
2620: String command = ae.getActionCommand ();
2621: switch (command) {
2622: case "Reset to default values":
2623: for (int i = 0; i < 9; i++) {
2624: LnF.lnfHSB[i] = LnF.LNF_DEFAULT_HSB[i];
2625: mnbColorSpinners[i].setIntValue (LnF.lnfHSB[i]);
2626: }
2627: mnbColorHSBToRGB ();
2628: mnbColorPanel.repaint ();
2629: break;
2630: default:
2631: System.out.println ("unknown action command " + command);
2632: }
2633: }
2634: };
2635:
2636: for (int i = 0; i < 9; i++) {
2637: mnbColorSpinners[i] = ComponentFactory.createDecimalSpinner (
2638: LnF.lnfHSB[i], 0, i < 3 ? 720 : 100, 1, i, changeListener);
2639: }
2640:
2641: return Multilingual.mlnText (
2642: ComponentFactory.createMenu (
2643: "Color",
2644: ComponentFactory.createHorizontalBox (
2645: mnbColorSpinners[0],
2646: mnbColorSpinners[1],
2647: mnbColorSpinners[2],
2648: ComponentFactory.createLabel ("H °"),
2649: Box.createHorizontalGlue ()
2650: ),
2651: ComponentFactory.createHorizontalBox (
2652: mnbColorSpinners[3],
2653: mnbColorSpinners[4],
2654: mnbColorSpinners[5],
2655: ComponentFactory.createLabel ("S%"),
2656: Box.createHorizontalGlue ()
2657: ),
2658: ComponentFactory.createHorizontalBox (
2659: mnbColorSpinners[6],
2660: mnbColorSpinners[7],
2661: mnbColorSpinners[8],
2662: ComponentFactory.createLabel ("B%"),
2663: Box.createHorizontalGlue ()
2664: ),
2665: ComponentFactory.createHorizontalBox (
2666: ComponentFactory.setLineBorder (mnbColorPanel),
2667: Box.createHorizontalGlue ()
2668: ),
2669: Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset to default values", actionListener), "ja", "初期値に戻す")
2670: ),
2671: "ja", "色");
2672: }
2673:
2674:
2675:
2676:
2677:
2678: public static JMenu mnbMakeLanguageMenu () {
2679:
2680: ActionListener actionListener = new ActionListener () {
2681: @Override public void actionPerformed (ActionEvent ae) {
2682: String command = ae.getActionCommand ();
2683: switch (command) {
2684: case "English":
2685: Multilingual.mlnChange ("en");
2686: break;
2687: case "日本語":
2688: Multilingual.mlnChange ("ja");
2689: break;
2690: default:
2691: System.out.println ("unknown action command " + command);
2692: }
2693: }
2694: };
2695:
2696: ButtonGroup languageGroup = new ButtonGroup ();
2697:
2698: return mnbLanguageMenu = Multilingual.mlnText (
2699: ComponentFactory.createMenu (
2700: "Language", 'L',
2701: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnEnglish, "English", actionListener),
2702: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnJapanese, "日本語", actionListener),
2703: ComponentFactory.createHorizontalSeparator (),
2704: mnbMakeFontSizeMenu (),
2705: mnbMakeColorMenu ()
2706: ),
2707: "ja", "言語");
2708: }
2709:
2710:
2711:
2712:
2713:
2714: public static void mnbMakeMenu () {
2715:
2716:
2717: ActionListener listener = new ActionListener () {
2718: @Override public void actionPerformed (ActionEvent ae) {
2719: Object source = ae.getSource ();
2720: String command = ae.getActionCommand ();
2721: switch (command) {
2722:
2723:
2724: case "Quit":
2725: prgTini ();
2726: break;
2727:
2728:
2729: case "50%":
2730: case "75%":
2731: case "100%":
2732: case "150%":
2733: case "200%":
2734: pnlFixedModel.setValue (Integer.valueOf (Integer.parseInt (command.substring (0, command.length () - 1))));
2735: break;
2736: case "Nearest neighbor":
2737: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
2738: break;
2739: case "Bilinear":
2740: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
2741: break;
2742: case "Bicubic":
2743: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
2744: break;
2745:
2746: case "Use canvas":
2747: pnlUseCanvasRequest = ((JCheckBoxMenuItem) source).isSelected ();
2748: break;
2749:
2750: case "Draw all changed pictures":
2751: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2752: CRTC.crtIntermittentInterval = 0;
2753: }
2754: break;
2755: case "Draw a changed picture once every two times":
2756: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2757: CRTC.crtIntermittentInterval = 1;
2758: }
2759: break;
2760: case "Draw a changed picture once every three times":
2761: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2762: CRTC.crtIntermittentInterval = 2;
2763: }
2764: break;
2765: case "Draw a changed picture once every four times":
2766: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2767: CRTC.crtIntermittentInterval = 3;
2768: }
2769: break;
2770: case "Draw a changed picture once every five times":
2771: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2772: CRTC.crtIntermittentInterval = 4;
2773: }
2774: break;
2775:
2776: case "Stereoscopic viewing":
2777: pnlSetStereoscopic (((JCheckBoxMenuItem) source).isSelected (), pnlStereoscopicMethod);
2778: break;
2779: case "Naked-eye crossing":
2780: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_CROSSING);
2781: break;
2782: case "Naked-eye parallel":
2783: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_PARALLEL);
2784: break;
2785: case "Side-by-side":
2786: pnlSetStereoscopic (pnlStereoscopicOn, PNL_SIDE_BY_SIDE);
2787: break;
2788: case "Top-and-bottom":
2789: pnlSetStereoscopic (pnlStereoscopicOn, PNL_TOP_AND_BOTTOM);
2790: break;
2791:
2792: case "Sprite pattern viewer":
2793: if (SpritePatternViewer.SPV_ON) {
2794: SpritePatternViewer.spvOpen ();
2795: }
2796: break;
2797: case "Palette viewer":
2798: if (PaletteViewer.PLV_ON) {
2799: PaletteViewer.plvOpen ();
2800: }
2801: break;
2802: case "Screen mode test":
2803: if (ScreenModeTest.SMT_ON) {
2804: ScreenModeTest.smtOpen ();
2805: }
2806: break;
2807:
2808:
2809: case "Play":
2810: SoundSource.sndSetPlayOn (((JCheckBoxMenuItem) source).isSelected ());
2811: break;
2812: case "OPM output":
2813: OPM.opmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2814: break;
2815: case "OPM log":
2816: OPMLog.olgOpen ();
2817: break;
2818:
2819: case "PCM output":
2820: ADPCM.pcmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2821: break;
2822: case "Sound thinning":
2823: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.THINNING_MONO : SoundSource.SNDRateConverter.THINNING_STEREO;
2824: break;
2825: case "Sound linear interpolation":
2826: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.LINEAR_MONO : SoundSource.SNDRateConverter.LINEAR_STEREO;
2827: break;
2828: case "Sound piecewise-constant area interpolation":
2829: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000;
2830: break;
2831: case "Sound linear area interpolation":
2832: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000;
2833: break;
2834: case "Sound monitor":
2835: SoundMonitor.smnOpen ();
2836: break;
2837: case "PCM piecewise-constant interpolation":
2838: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_CONSTANT);
2839: break;
2840: case "PCM linear interpolation":
2841: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_LINEAR);
2842: break;
2843: case "PCM hermite interpolation":
2844: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_HERMITE);
2845: break;
2846: case "PCM 8MHz/4MHz":
2847: ADPCM.pcmOSCFreqRequest = 0;
2848: break;
2849: case "PCM 8MHz/16MHz":
2850: ADPCM.pcmOSCFreqRequest = 1;
2851: break;
2852: case "Mercury-Unit V4 (MK-MU1)":
2853: MercuryUnit.mu4OnRequest = ((JCheckBoxMenuItem) source).isSelected ();
2854: break;
2855: case "MU4 output":
2856: MercuryUnit.mu4OutputEnable = ((JCheckBoxMenuItem) source).isSelected ();
2857: break;
2858:
2859:
2860: case "Paste":
2861: CONDevice.conDoPaste ();
2862: break;
2863: case "No keyboard":
2864: Keyboard.kbdSetOn (false);
2865: pnlUpdateArrangement ();
2866: break;
2867: case "Standard keyboard":
2868: Keyboard.kbdSetType (Keyboard.KBD_STANDARD_TYPE);
2869: Keyboard.kbdSetOn (true);
2870: pnlUpdateArrangement ();
2871: break;
2872: case "Compact keyboard":
2873: Keyboard.kbdSetType (Keyboard.KBD_COMPACT_TYPE);
2874: Keyboard.kbdSetOn (true);
2875: pnlUpdateArrangement ();
2876: break;
2877: case "Hide keyboard in full screen":
2878: pnlHideKeyboard = ((JCheckBoxMenuItem) source).isSelected ();
2879: if (pnlMode == PNL_FULLSCREEN) {
2880: pnlUpdateArrangement ();
2881: }
2882: break;
2883: case "Key assignments":
2884: Keyboard.kbdOpen ();
2885: break;
2886: case "Joystick port settings":
2887: PPI.ppiOpen ();
2888: break;
2889:
2890:
2891: case "RS-232C and terminal":
2892: RS232CTerminal.trmOpen ();
2893: break;
2894:
2895: case "Console":
2896: DebugConsole.dgtOpen ();
2897: break;
2898: case "Register list":
2899: RegisterList.drpOpen ();
2900: break;
2901: case "Disassemble list":
2902: DisassembleList.ddpOpen (-1, -1, true);
2903: break;
2904: case "Memory dump list":
2905: MemoryDumpList.dmpOpen (-1, -1, true);
2906: break;
2907: case "Logical space monitor":
2908: LogicalSpaceMonitor.atwOpen ();
2909: break;
2910: case "Physical space monitor":
2911: PhysicalSpaceMonitor.paaOpen ();
2912: break;
2913: case "Address translation caches monitor":
2914: if (ATCMonitor.ACM_ON) {
2915: ATCMonitor.acmOpen ();
2916: }
2917: break;
2918: case "Branch log":
2919: if (BranchLog.BLG_ON) {
2920: BranchLog.blgOpen (BranchLog.BLG_SELECT_NONE);
2921: }
2922: break;
2923: case "Program flow visualizer":
2924: if (ProgramFlowVisualizer.PFV_ON) {
2925: ProgramFlowVisualizer.pfvOpen ();
2926: }
2927: break;
2928: case "Raster break point":
2929: if (RasterBreakPoint.RBP_ON) {
2930: RasterBreakPoint.rbpOpen ();
2931: }
2932: break;
2933: case "Data break point":
2934: if (DataBreakPoint.DBP_ON) {
2935: DataBreakPoint.dbpOpen ();
2936: }
2937: break;
2938: case "Root pointer list":
2939: if (RootPointerList.RTL_ON) {
2940: RootPointerList.rtlOpen ();
2941: }
2942: break;
2943:
2944:
2945: case "Adjust clock to host":
2946: RP5C15.rtcSetByHost ();
2947: break;
2948:
2949:
2950:
2951: case "Printer":
2952: PrinterPort.prnOpen ();
2953: break;
2954:
2955: case "Print key and mouse button events":
2956: Mouse.musOutputButtonStatus = ((JCheckBoxMenuItem) source).isSelected ();
2957: break;
2958:
2959: case "Java runtime environment information":
2960: prgOpenJavaDialog ();
2961: break;
2962: case "Version information":
2963: prgOpenAboutDialog ();
2964: break;
2965: case "XEiJ License":
2966: prgOpenXEiJLicenseDialog ();
2967: break;
2968: case "FSHARP License":
2969: prgOpenSHARPLicenseDialog ();
2970: break;
2971: case "ymfm License":
2972: prgOpenYmfmLicenseDialog ();
2973: break;
2974: case "jSerialComm License":
2975: prgOpenJSerialCommLicenseDialog ();
2976: break;
2977:
2978: default:
2979: System.out.println ("unknown action command " + command);
2980:
2981: }
2982: }
2983: };
2984:
2985:
2986: ActionListener mainMemoryListener = new ActionListener () {
2987: @Override public void actionPerformed (ActionEvent ae) {
2988: Object source = ae.getSource ();
2989: String command = ae.getActionCommand ();
2990: switch (command) {
2991: case "1MB":
2992: MainMemory.mmrMemorySizeRequest = 0x00100000;
2993: break;
2994: case "2MB":
2995: MainMemory.mmrMemorySizeRequest = 0x00200000;
2996: break;
2997: case "4MB":
2998: MainMemory.mmrMemorySizeRequest = 0x00400000;
2999: break;
3000: case "6MB":
3001: MainMemory.mmrMemorySizeRequest = 0x00600000;
3002: break;
3003: case "8MB":
3004: MainMemory.mmrMemorySizeRequest = 0x00800000;
3005: break;
3006: case "10MB":
3007: MainMemory.mmrMemorySizeRequest = 0x00a00000;
3008: break;
3009: case "12MB":
3010: MainMemory.mmrMemorySizeRequest = 0x00c00000;
3011: break;
3012: case "Save contents on exit":
3013: MainMemory.mmrMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
3014: break;
3015: }
3016: }
3017: };
3018: ButtonGroup mainMemoryGroup = new ButtonGroup ();
3019: JMenu mainMemoryMenu = Multilingual.mlnText (
3020: ComponentFactory.createMenu (
3021: "Main memory",
3022: Multilingual.mlnText (
3023: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00100000, "1MB", mainMemoryListener),
3024: "ja", "1MB"),
3025: Multilingual.mlnText (
3026: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00200000, "2MB", mainMemoryListener),
3027: "ja", "2MB"),
3028: Multilingual.mlnText (
3029: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00400000, "4MB", mainMemoryListener),
3030: "ja", "4MB"),
3031: Multilingual.mlnText (
3032: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00600000, "6MB", mainMemoryListener),
3033: "ja", "6MB"),
3034: Multilingual.mlnText (
3035: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00800000, "8MB", mainMemoryListener),
3036: "ja", "8MB"),
3037: Multilingual.mlnText (
3038: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00a00000, "10MB", mainMemoryListener),
3039: "ja", "10MB"),
3040: Multilingual.mlnText (
3041: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00c00000, "12MB", mainMemoryListener),
3042: "ja", "12MB"),
3043: ComponentFactory.createHorizontalSeparator (),
3044: Multilingual.mlnText (
3045: ComponentFactory.createCheckBoxMenuItem (MainMemory.mmrMemorySaveOn, "Save contents on exit", mainMemoryListener),
3046: "ja", "終了時に内容を保存する"),
3047: SRAM.smrModifyMemorySizeMenuItem
3048: ),
3049: "ja", "メインメモリ");
3050:
3051:
3052: ActionListener highMemoryListener = new ActionListener () {
3053: @Override public void actionPerformed (ActionEvent ae) {
3054: Object source = ae.getSource ();
3055: String command = ae.getActionCommand ();
3056: switch (command) {
3057: case "None":
3058: busHighMemorySize = 0 << 20;
3059: break;
3060: case "16MB":
3061: busHighMemorySize = 16 << 20;
3062: break;
3063: case "Save contents on exit":
3064: busHighMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
3065: break;
3066: }
3067: }
3068: };
3069: ButtonGroup highMemoryGroup = new ButtonGroup ();
3070: JMenu highMemoryMenu = Multilingual.mlnText (
3071: ComponentFactory.createMenu (
3072: "High memory on X68030/Xellent30",
3073: Multilingual.mlnText (
3074: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 0 << 20, "None", highMemoryListener),
3075: "ja", "なし"),
3076: Multilingual.mlnText (
3077: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 16 << 20, "16MB", highMemoryListener),
3078: "ja", "16MB"),
3079: ComponentFactory.createHorizontalSeparator (),
3080: Multilingual.mlnText (
3081: ComponentFactory.createCheckBoxMenuItem (busHighMemorySaveOn, "Save contents on exit", highMemoryListener),
3082: "ja", "終了時に内容を保存する")
3083: ),
3084: "ja", "X68030/Xellent30 のハイメモリ");
3085:
3086:
3087: ActionListener localMemoryListener = new ActionListener () {
3088: @Override public void actionPerformed (ActionEvent ae) {
3089: Object source = ae.getSource ();
3090: String command = ae.getActionCommand ();
3091: switch (command) {
3092: case "None":
3093: busLocalMemorySize = 0 << 20;
3094: break;
3095: case "16MB":
3096: busLocalMemorySize = 16 << 20;
3097: break;
3098: case "32MB":
3099: busLocalMemorySize = 32 << 20;
3100: break;
3101: case "64MB":
3102: busLocalMemorySize = 64 << 20;
3103: break;
3104: case "128MB":
3105: busLocalMemorySize = 128 << 20;
3106: break;
3107: case "256MB":
3108: busLocalMemorySize = 256 << 20;
3109: break;
3110: case "384MB":
3111: busLocalMemorySize = 384 << 20;
3112: break;
3113: case "512MB":
3114: busLocalMemorySize = 512 << 20;
3115: break;
3116: case "768MB":
3117: busLocalMemorySize = 768 << 20;
3118: break;
3119: case "Save contents on exit":
3120: busLocalMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
3121: break;
3122: case "Available on X68000":
3123: busHimem68000 = ((JCheckBoxMenuItem) source).isSelected ();
3124: break;
3125: case "Available on X68030/Xellent30":
3126: busHighMemory060turboOn = ((JCheckBoxMenuItem) source).isSelected ();
3127: break;
3128: }
3129: }
3130: };
3131: ButtonGroup localMenoryGroup = new ButtonGroup ();
3132: JMenu localMemoryMenu = Multilingual.mlnText (
3133: ComponentFactory.createMenu (
3134: "High memory on 060turbo",
3135: Multilingual.mlnText (
3136: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 0 << 20, "None", localMemoryListener),
3137: "ja", "なし"),
3138: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 16 << 20, "16MB", localMemoryListener),
3139: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 32 << 20, "32MB", localMemoryListener),
3140: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 64 << 20, "64MB", localMemoryListener),
3141: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 128 << 20, "128MB", localMemoryListener),
3142: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 256 << 20, "256MB", localMemoryListener),
3143: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 384 << 20, "384MB", localMemoryListener),
3144: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 512 << 20, "512MB", localMemoryListener),
3145: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 768 << 20, "768MB", localMemoryListener),
3146: ComponentFactory.createHorizontalSeparator (),
3147: Multilingual.mlnText (
3148: ComponentFactory.createCheckBoxMenuItem (busLocalMemorySaveOn, "Save contents on exit", localMemoryListener),
3149: "ja", "終了時に内容を保存する"),
3150: ComponentFactory.createHorizontalSeparator (),
3151: Multilingual.mlnText (
3152: ComponentFactory.createCheckBoxMenuItem (busHimem68000, "Available on X68000", localMemoryListener),
3153: "ja", "X68000 でも有効"),
3154: Multilingual.mlnText (
3155: ComponentFactory.createCheckBoxMenuItem (busHighMemory060turboOn, "Available on X68030/Xellent30", localMemoryListener),
3156: "ja", "X68030/Xellent30 でも有効")
3157: ),
3158: "ja", "060turbo のハイメモリ");
3159:
3160:
3161: ActionListener xellent30Listener = new ActionListener () {
3162: @Override public void actionPerformed (ActionEvent ae) {
3163: Object source = ae.getSource ();
3164: String command = ae.getActionCommand ();
3165: switch (command) {
3166: case "$00EC0000-$00EC3FFF":
3167: xt3DIPSW = 0;
3168: break;
3169: case "$00EC4000-$00EC7FFF":
3170: xt3DIPSW = 1;
3171: break;
3172: case "$00EC8000-$00ECBFFF":
3173: xt3DIPSW = 2;
3174: break;
3175: case "$00ECC000-$00ECFFFF":
3176: xt3DIPSW = 3;
3177: break;
3178: case "256KB":
3179: xt3MemorySizeRequest = 1 << 18;
3180: break;
3181: case "1MB":
3182: xt3MemorySizeRequest = 1 << 20;
3183: break;
3184: case "Save contents on exit":
3185: xt3MemorySave = ((JCheckBoxMenuItem) source).isSelected ();
3186: break;
3187: }
3188: }
3189: };
3190: ButtonGroup xellent30PortGroup = new ButtonGroup ();
3191: ButtonGroup xellent30SizeGroup = new ButtonGroup ();
3192: JMenu xellent30Menu = ComponentFactory.createMenu (
3193: "Xellent30",
3194: ComponentFactory.createRadioButtonMenuItem (
3195: xellent30PortGroup,
3196: xt3DIPSW == 0,
3197: "$00EC0000-$00EC3FFF",
3198: xellent30Listener),
3199: ComponentFactory.createRadioButtonMenuItem (
3200: xellent30PortGroup,
3201: xt3DIPSW == 1,
3202: "$00EC4000-$00EC7FFF",
3203: xellent30Listener),
3204: ComponentFactory.createRadioButtonMenuItem (
3205: xellent30PortGroup,
3206: xt3DIPSW == 2,
3207: "$00EC8000-$00ECBFFF",
3208: xellent30Listener),
3209: ComponentFactory.createRadioButtonMenuItem (
3210: xellent30PortGroup,
3211: xt3DIPSW == 3,
3212: "$00ECC000-$00ECFFFF",
3213: xellent30Listener),
3214: ComponentFactory.createHorizontalSeparator (),
3215: ComponentFactory.createRadioButtonMenuItem (
3216: xellent30SizeGroup,
3217: xt3MemorySizeRequest == 1 << 18,
3218: "256KB",
3219: xellent30Listener),
3220: ComponentFactory.createRadioButtonMenuItem (
3221: xellent30SizeGroup,
3222: xt3MemorySizeRequest == 1 << 20,
3223: "1MB",
3224: xellent30Listener),
3225: ComponentFactory.createHorizontalSeparator (),
3226: Multilingual.mlnText (
3227: ComponentFactory.createCheckBoxMenuItem (xt3MemorySave, "Save contents on exit", xellent30Listener),
3228: "ja", "終了時に内容を保存する")
3229: );
3230:
3231:
3232: JMenu rotationMenu = null;
3233: if (PNL_ROTATION_ON) {
3234: ActionListener rotationListener = new ActionListener () {
3235: @Override public void actionPerformed (ActionEvent ae) {
3236: String command = ae.getActionCommand ();
3237: switch (command) {
3238: case "No rotation (landscape)":
3239: pnlRotationMode = 0;
3240: pnlUpdateArrangement ();
3241: break;
3242: case "90-degree rotation (portrait)":
3243: pnlRotationMode = 1;
3244: pnlUpdateArrangement ();
3245: break;
3246: case "180-degree rotation":
3247: pnlRotationMode = 2;
3248: pnlUpdateArrangement ();
3249: break;
3250: case "270-degree rotation":
3251: pnlRotationMode = 3;
3252: pnlUpdateArrangement ();
3253: break;
3254: default:
3255: System.out.println ("unknown action command " + command);
3256: }
3257: }
3258: };
3259: ButtonGroup rotationGroup = new ButtonGroup ();
3260: rotationMenu = Multilingual.mlnText (
3261: ComponentFactory.createMenu (
3262: "Rotation",
3263: Multilingual.mlnText (
3264: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 0, "No rotation (landscape)", rotationListener),
3265: "ja", "回転なし (横画面)"),
3266: Multilingual.mlnText (
3267: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 1, "90-degree rotation (portrait)", rotationListener),
3268: "ja", "90 度回転 (縦画面)"),
3269: Multilingual.mlnText (
3270: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 2, "180-degree rotation", rotationListener),
3271: "ja", "180 度回転"),
3272: Multilingual.mlnText (
3273: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 3, "270-degree rotation", rotationListener),
3274: "ja", "270 度回転")
3275: ),
3276: "ja", "回転");
3277: }
3278:
3279:
3280: ActionListener aspectListener = new ActionListener () {
3281: @Override public void actionPerformed (ActionEvent ae) {
3282: String command = ae.getActionCommand ();
3283: int i = command.indexOf (',');
3284: int resolutionNumber = Integer.parseInt (command.substring (0, i));
3285: int ratioNumber = Integer.parseInt (command.substring (i + 1));
3286: pnlAspectMap[resolutionNumber] = ratioNumber;
3287: pnlUpdateAspectTable ();
3288: pnlUpdateArrangement ();
3289: }
3290: };
3291: JMenu aspectMenu = ComponentFactory.createMenu ("Aspect ratio");
3292: for (int resolutionNumber = 0; resolutionNumber < PNL_ASPECT_RESOLUTION_COUNT; resolutionNumber++) {
3293: JMenu menu = ComponentFactory.createMenu (PNL_ASPECT_RESOLUTION_NAME[resolutionNumber]);
3294: ButtonGroup group = new ButtonGroup ();
3295: for (int ratioNumber = 0; ratioNumber < PNL_ASPECT_RATIO_COUNT; ratioNumber++) {
3296: if (PNL_ASPECT_RATIO_MATRIX[resolutionNumber][ratioNumber] == 0.0F) {
3297: continue;
3298: }
3299: menu.add (
3300: ComponentFactory.setText (
3301: ComponentFactory.createRadioButtonMenuItem (
3302: group,
3303: pnlAspectMap[resolutionNumber] == ratioNumber,
3304: resolutionNumber + "," + ratioNumber,
3305: aspectListener
3306: ),
3307: (PNL_ASPECT_RATIO_MATRIX[resolutionNumber] == PNL_ASPECT_PIXEL_RATIO_02 ?
3308: String.format ("%s (%.3f)",
3309: PNL_ASPECT_SCREEN_NAME[ratioNumber],
3310: PNL_ASPECT_SCREEN_RATIO[ratioNumber]) :
3311: String.format ("%s (%.3f) @ %s (%.3f)",
3312: PNL_ASPECT_SCREEN_NAME[ratioNumber],
3313: PNL_ASPECT_SCREEN_RATIO[ratioNumber],
3314: PNL_ASPECT_NAME_MATRIX[resolutionNumber][ratioNumber],
3315: PNL_ASPECT_RATIO_MATRIX[resolutionNumber][ratioNumber]))
3316: )
3317: );
3318: }
3319: aspectMenu.add (menu);
3320: }
3321: aspectMenu = Multilingual.mlnText (aspectMenu, "ja", "アスペクト比");
3322:
3323:
3324: ActionListener scanlineListener = new ActionListener () {
3325: @Override public void actionPerformed (ActionEvent ae) {
3326:
3327: String command = ae.getActionCommand ();
3328: switch (command) {
3329: case "Off":
3330: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.OFF;
3331: CRTC.crtAllStamp += 2;
3332: break;
3333: case "Weak":
3334: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.WEAK;
3335: CRTC.crtAllStamp += 2;
3336: break;
3337: case "Medium":
3338: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.MEDIUM;
3339: CRTC.crtAllStamp += 2;
3340: break;
3341: case "Strong":
3342: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.STRONG;
3343: CRTC.crtAllStamp += 2;
3344: break;
3345: case "Black":
3346: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.BLACK;
3347: CRTC.crtAllStamp += 2;
3348: break;
3349: }
3350: }
3351: };
3352: ButtonGroup scanlineGroup = new ButtonGroup ();
3353: JMenu scanlineMenu =
3354: Multilingual.mlnText (
3355: ComponentFactory.createMenu (
3356: "Scanline effect",
3357: Multilingual.mlnText (
3358: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.OFF, "Off", scanlineListener),
3359: "ja", "なし"),
3360: Multilingual.mlnText (
3361: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.WEAK, "Weak", scanlineListener),
3362: "ja", "弱"),
3363: Multilingual.mlnText (
3364: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.MEDIUM, "Medium", scanlineListener),
3365: "ja", "中"),
3366: Multilingual.mlnText (
3367: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.STRONG, "Strong", scanlineListener),
3368: "ja", "強"),
3369: Multilingual.mlnText (
3370: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.BLACK, "Black", scanlineListener),
3371: "ja", "黒")
3372: ),
3373: "ja", "走査線エフェクト");
3374:
3375:
3376: JTextField refreshRateTextField = ComponentFactory.createNumberField (pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate), 8);
3377: refreshRateTextField.addActionListener (
3378: new ActionListener () {
3379: @Override public void actionPerformed (ActionEvent ae) {
3380: JTextField textField = (JTextField) ae.getSource ();
3381: pnlRefreshRate = 0.0;
3382: String s = textField.getText ();
3383: if (!s.equals ("")) {
3384: double rate = 0.0;
3385: try {
3386: rate = Double.parseDouble (s);
3387: } catch (NumberFormatException nfe) {
3388: }
3389: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
3390: pnlRefreshRate = rate;
3391: } else {
3392: textField.setText ("");
3393: }
3394: }
3395: pnlFixedRate = pnlRefreshRate;
3396: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3397: pnlFixedRate = pnlGetRefreshRate ();
3398: }
3399: CRTC.crtUpdateLength ();
3400: }
3401: });
3402:
3403: ButtonGroup unitGroup = new ButtonGroup ();
3404: ButtonGroup frameGroup = new ButtonGroup ();
3405: ButtonGroup hintGroup = new ButtonGroup ();
3406: ButtonGroup vgaGroup = new ButtonGroup ();
3407: ButtonGroup intermittentGroup = new ButtonGroup ();
3408: ButtonGroup sterescopicGroup = new ButtonGroup ();
3409: ButtonGroup soundInterpolationGroup = new ButtonGroup ();
3410: ButtonGroup adpcmInterpolationGroup = new ButtonGroup ();
3411: ButtonGroup adpcmOSCFreqGroup = new ButtonGroup ();
3412: ButtonGroup keyboardGroup = new ButtonGroup ();
3413: ButtonGroup spritesGroup = new ButtonGroup ();
3414:
3415:
3416: DecimalSpinner[] freqSpinner = new DecimalSpinner[3];
3417: ChangeListener freqListener = new ChangeListener () {
3418: @Override public void stateChanged (ChangeEvent ce) {
3419: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
3420: int i = spinner.getOption ();
3421: CRTC.crtFreqsRequest[i] = spinner.getIntValue ();
3422: }
3423: };
3424: for (int i = 0; i < 3; i++) {
3425: freqSpinner[i] = ComponentFactory.createDecimalSpinner (
3426: CRTC.crtFreqsRequest[i], CRTC.CRT_MIN_FREQ, CRTC.CRT_MAX_FREQ, 1000000, i, freqListener
3427: );
3428: }
3429: DecimalSpinner sprrasSpinner = ComponentFactory.createDecimalSpinner (
3430: SpriteScreen.sprSpritesPerRaster, 0, 1016, 1, 0,
3431: new ChangeListener () {
3432: @Override public void stateChanged (ChangeEvent ce) {
3433: SpriteScreen.sprSpritesPerRaster = ((DecimalSpinner) ce.getSource ()).getIntValue ();
3434: }
3435: });
3436: ActionListener modificationListener = new ActionListener () {
3437: @Override public void actionPerformed (ActionEvent ae) {
3438: Object source = ae.getSource ();
3439: String command = ae.getActionCommand ();
3440: switch (command) {
3441:
3442: case "Adjust to host refresh rate":
3443: pnlAdjustVsync = ((JCheckBoxMenuItem) source).isSelected ();
3444: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3445: pnlFixedRate = pnlGetRefreshRate ();
3446: }
3447: CRTC.crtUpdateLength ();
3448: break;
3449: case "* Reset to default values":
3450: for (int i = 0; i < 3; i++) {
3451: if (CRTC.crtFreqsRequest[i] != CRTC.CRT_DEFAULT_FREQS[i]) {
3452: CRTC.crtFreqsRequest[i] = CRTC.CRT_DEFAULT_FREQS[i];
3453: freqSpinner[i].setIntValue (CRTC.crtFreqsRequest[i]);
3454: }
3455: }
3456: break;
3457: case "1024-dot non-interlaced":
3458: CRTC.crtEleventhBitRequest = ((JCheckBoxMenuItem) source).isSelected ();
3459: break;
3460: case "Can write 0 to bit 0 of CRTC R00":
3461: CRTC.crtR00Bit0Zero = ((JCheckBoxMenuItem) source).isSelected ();
3462: break;
3463:
3464: case "Extended graphic screen":
3465: CRTC.crtExtendedGraphicRequest = ((JCheckBoxMenuItem) source).isSelected ();
3466: break;
3467:
3468: case "Spherical scrolling of text screen":
3469: CRTC.crtSetSphericalScrolling (((JCheckBoxMenuItem) source).isSelected ());
3470: break;
3471:
3472: case "128 sprites":
3473: SpriteScreen.sprNumberOfSpritesRequest = 128;
3474: break;
3475: case "256 sprites":
3476: SpriteScreen.sprNumberOfSpritesRequest = 256;
3477: break;
3478: case "504 sprites":
3479: SpriteScreen.sprNumberOfSpritesRequest = 512;
3480: break;
3481: case "1016 sprites":
3482: SpriteScreen.sprNumberOfSpritesRequest = 1024;
3483: break;
3484:
3485:
3486:
3487: case "Full pattern memory":
3488: SpriteScreen.sprFPMRequest = ((JCheckBoxMenuItem) source).isSelected ();
3489: break;
3490: case "4096 patterns":
3491: SpriteScreen.sprBankOnRequest = ((JCheckBoxMenuItem) source).isSelected ();
3492: break;
3493: case "Sprites displayed in 768x512":
3494: SpriteScreen.spr768x512Request = ((JCheckBoxMenuItem) source).isSelected ();
3495: break;
3496: case "BG1 displayed in 512x512":
3497: SpriteScreen.spr512bg1Request = ((JCheckBoxMenuItem) source).isSelected ();
3498: break;
3499: case "Row and column scroll":
3500: if (SpriteScreen.SPR_RC_SCROLL_ON) {
3501: SpriteScreen.sprRcScrollRequest = ((JCheckBoxMenuItem) source).isSelected ();
3502: }
3503: break;
3504: case "** Reset to default values":
3505: if (SpriteScreen.sprSpritesPerRaster != 32) {
3506: SpriteScreen.sprSpritesPerRaster = 32;
3507: sprrasSpinner.setIntValue (SpriteScreen.sprSpritesPerRaster);
3508: }
3509: break;
3510: }
3511: }
3512: };
3513: JMenu modificationMenu =
3514: Multilingual.mlnText (
3515: ComponentFactory.createMenu (
3516: "Modification",
3517: Multilingual.mlnText (
3518: ComponentFactory.createMenu (
3519: "Dot clock",
3520: Multilingual.mlnText (
3521: ComponentFactory.createCheckBoxMenuItem (pnlAdjustVsync, "Adjust to host refresh rate", modificationListener),
3522: "ja", "ホストのリフレッシュレートに合わせる"),
3523: ComponentFactory.createHorizontalBox (
3524: Box.createHorizontalStrut (20),
3525: refreshRateTextField,
3526: ComponentFactory.createLabel (" Hz"),
3527: Box.createHorizontalGlue ()
3528: ),
3529: ComponentFactory.createHorizontalSeparator (),
3530: ComponentFactory.createHorizontalBox (
3531: Box.createHorizontalStrut (20),
3532: Multilingual.mlnText (ComponentFactory.createLabel ("Dot clock oscillattor"), "ja", "ドットクロックオシレータ"),
3533: Box.createHorizontalGlue ()
3534: ),
3535: ComponentFactory.createHorizontalBox (
3536: Box.createHorizontalStrut (20),
3537: freqSpinner[0],
3538: ComponentFactory.createLabel (" Hz *"),
3539: Box.createHorizontalGlue ()
3540: ),
3541: ComponentFactory.createHorizontalBox (
3542: Box.createHorizontalStrut (20),
3543: freqSpinner[1],
3544: ComponentFactory.createLabel (" Hz *"),
3545: Box.createHorizontalGlue ()
3546: ),
3547: ComponentFactory.createHorizontalBox (
3548: Box.createHorizontalStrut (20),
3549: freqSpinner[2],
3550: ComponentFactory.createLabel (" Hz *"),
3551: Box.createHorizontalGlue ()
3552: ),
3553: Multilingual.mlnText (
3554: ComponentFactory.createMenuItem ("* Reset to default values", modificationListener),
3555: "ja", "* 初期値に戻す"),
3556: ComponentFactory.createHorizontalSeparator (),
3557: Multilingual.mlnText (
3558: ComponentFactory.createCheckBoxMenuItem (CRTC.crtEleventhBitRequest, "1024-dot non-interlaced", modificationListener),
3559: "ja", "1024 ドットノンインターレース"),
3560: Multilingual.mlnText (
3561: ComponentFactory.createCheckBoxMenuItem (CRTC.crtR00Bit0Zero, "Can write 0 to bit 0 of CRTC R00", modificationListener),
3562: "ja", "CRTC R00 のビット 0 に 0 を書き込める")
3563: ),
3564: "ja", "ドットクロック"),
3565: Multilingual.mlnText (
3566: ComponentFactory.createMenu (
3567: "Graphic screen",
3568: !CRTC.CRT_EXTENDED_GRAPHIC ? null : Multilingual.mlnText (
3569: ComponentFactory.createCheckBoxMenuItem (CRTC.crtExtendedGraphicRequest, "Extended graphic screen", modificationListener),
3570: "ja", "拡張グラフィック画面")
3571: ),
3572: "ja", "グラフィック画面"),
3573: Multilingual.mlnText (
3574: ComponentFactory.createMenu (
3575: "Text screen",
3576: Multilingual.mlnText (
3577: ComponentFactory.createCheckBoxMenuItem (CRTC.crtSphericalScrolling, "Spherical scrolling of text screen", modificationListener),
3578: "ja", "テキスト画面の球面スクロール")
3579: ),
3580: "ja", "テキスト画面"),
3581: Multilingual.mlnText (
3582: ComponentFactory.createMenu (
3583: "Sprite screen",
3584: Multilingual.mlnText (
3585: ComponentFactory.createRadioButtonMenuItem (
3586: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 128, "128 sprites", modificationListener),
3587: "ja", "128 枚のスプライト"),
3588: Multilingual.mlnText (
3589: ComponentFactory.createRadioButtonMenuItem (
3590: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 256, "256 sprites", modificationListener),
3591: "ja", "256 枚のスプライト"),
3592: Multilingual.mlnText (
3593: ComponentFactory.createRadioButtonMenuItem (
3594: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 512, "504 sprites", modificationListener),
3595: "ja", "504 枚のスプライト"),
3596: Multilingual.mlnText (
3597: ComponentFactory.createRadioButtonMenuItem (
3598: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 1024, "1016 sprites", modificationListener),
3599: "ja", "1016 枚のスプライト"),
3600:
3601:
3602:
3603:
3604: ComponentFactory.createHorizontalSeparator (),
3605: Multilingual.mlnText (
3606: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprFPMRequest, "Full pattern memory", modificationListener),
3607: "ja", "フルパターンメモリ"),
3608: ComponentFactory.createHorizontalSeparator (),
3609: Multilingual.mlnText (
3610: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprBankOnRequest, "4096 patterns", modificationListener),
3611: "ja", "4096 個のパターン"),
3612: Multilingual.mlnText (
3613: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr768x512Request, "Sprites displayed in 768x512", modificationListener),
3614: "ja", "768x512 でスプライトを表示"),
3615: Multilingual.mlnText (
3616: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr512bg1Request, "BG1 displayed in 512x512", modificationListener),
3617: "ja", "512x512 で BG1 を表示"),
3618: !SpriteScreen.SPR_RC_SCROLL_ON ? null : Multilingual.mlnText (
3619: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprRcScrollRequest, "Row and column scroll", modificationListener),
3620: "ja", "行スクロールと列スクロール"),
3621: ComponentFactory.createHorizontalSeparator (),
3622: ComponentFactory.createHorizontalBox (
3623: Box.createHorizontalStrut (20),
3624: Multilingual.mlnText (ComponentFactory.createLabel ("Number of sprites per raster"), "ja", "ラスタあたりのスプライトの枚数"),
3625: Box.createHorizontalGlue ()
3626: ),
3627: ComponentFactory.createHorizontalBox (
3628: Box.createHorizontalStrut (20),
3629: sprrasSpinner,
3630: ComponentFactory.createLabel (" **"),
3631: Box.createHorizontalGlue ()
3632: ),
3633: Multilingual.mlnText (
3634: ComponentFactory.createMenuItem ("** Reset to default values", modificationListener),
3635: "ja", "** 初期値に戻す")
3636: ),
3637: "ja", "スプライト画面")
3638: ),
3639: "ja", "改造");
3640:
3641:
3642: mnbMenuBar = ComponentFactory.createMenuBar (
3643:
3644:
3645: mnbFileMenu = Multilingual.mlnText (
3646: ComponentFactory.createMenu (
3647: "File", 'F',
3648:
3649: FDC.fdcMenu,
3650:
3651: HDC.hdcMenu,
3652:
3653: SPC.spcMenu,
3654:
3655: HFS.hfsMenu,
3656: ComponentFactory.createHorizontalSeparator (),
3657: mnbQuitMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Quit", 'Q', MNB_MODIFIERS, listener), "ja", "終了")
3658: ),
3659: "ja", "ファイル"),
3660:
3661:
3662: mpuMenu,
3663:
3664:
3665: mnbDisplayMenu = Multilingual.mlnText (
3666: ComponentFactory.createMenu (
3667: "Display", 'D',
3668: mnbFullScreenMenuItem,
3669: !PNL_ROUNDED_CORNER_ON ? null : ComponentFactory.createHorizontalBox (
3670: Box.createHorizontalStrut (20),
3671: Multilingual.mlnText (
3672: ComponentFactory.createLabel ("Rounded corner ratio "),
3673: "ja", "角丸率 "),
3674: pnlRoundedCornerSpinner,
3675: ComponentFactory.createLabel ("%"),
3676: Box.createHorizontalGlue ()
3677: ),
3678: mnbMaximizedMenuItem,
3679: mnbFitInWindowMenuItem,
3680: mnbFixedScaleMenuItem,
3681: ComponentFactory.createHorizontalBox (
3682: Box.createHorizontalStrut (20),
3683: pnlFixedSpinner,
3684: ComponentFactory.createLabel ("%"),
3685: Box.createHorizontalGlue ()
3686: ),
3687: ComponentFactory.createMenuItem ("50%", listener),
3688: ComponentFactory.createMenuItem ("75%", listener),
3689: ComponentFactory.createMenuItem ("100%", listener),
3690: ComponentFactory.createMenuItem ("150%", listener),
3691: ComponentFactory.createMenuItem ("200%", listener),
3692:
3693: rotationMenu,
3694:
3695: aspectMenu,
3696:
3697: Multilingual.mlnText (
3698: ComponentFactory.createMenu (
3699: "Interpolation algorithm",
3700: Multilingual.mlnText (
3701: ComponentFactory.createRadioButtonMenuItem (
3702: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
3703: "Nearest neighbor", listener),
3704: "ja", "最近傍補間"),
3705: Multilingual.mlnText (
3706: ComponentFactory.createRadioButtonMenuItem (
3707: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR,
3708: "Bilinear", listener),
3709: "ja", "線形補間"),
3710: Multilingual.mlnText (
3711: ComponentFactory.createRadioButtonMenuItem (
3712: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC,
3713: "Bicubic", listener),
3714: "ja", "三次補間")
3715: ),
3716: "ja", "補間アルゴリズム"),
3717:
3718: scanlineMenu,
3719: !PNL_USE_CANVAS ? null : Multilingual.mlnText (
3720: ComponentFactory.createCheckBoxMenuItem (pnlUseCanvasRequest, "Use canvas", listener),
3721: "ja", "キャンバスを使う"),
3722:
3723: !CRTC.CRT_ENABLE_INTERMITTENT ? null : Multilingual.mlnText (
3724: ComponentFactory.createMenu (
3725: "Intermittent drawing",
3726: Multilingual.mlnText (
3727: ComponentFactory.createRadioButtonMenuItem (
3728: intermittentGroup, CRTC.crtIntermittentInterval == 0, "Draw all changed pictures", listener),
3729: "ja", "変化した画像をすべて描画する"),
3730: Multilingual.mlnText (
3731: ComponentFactory.createRadioButtonMenuItem (
3732: intermittentGroup, CRTC.crtIntermittentInterval == 1, "Draw a changed picture once every two times", listener),
3733: "ja", "変化した画像を 2 回に 1 回描画する"),
3734: Multilingual.mlnText (
3735: ComponentFactory.createRadioButtonMenuItem (
3736: intermittentGroup, CRTC.crtIntermittentInterval == 2, "Draw a changed picture once every three times", listener),
3737: "ja", "変化した画像を 3 回に 1 回描画する"),
3738: Multilingual.mlnText (
3739: ComponentFactory.createRadioButtonMenuItem (
3740: intermittentGroup, CRTC.crtIntermittentInterval == 3, "Draw a changed picture once every four times", listener),
3741: "ja", "変化した画像を 4 回に 1 回描画する"),
3742: Multilingual.mlnText (
3743: ComponentFactory.createRadioButtonMenuItem (
3744: intermittentGroup, CRTC.crtIntermittentInterval == 4, "Draw a changed picture once every five times", listener),
3745: "ja", "変化した画像を 5 回に 1 回描画する")
3746: ),
3747: "ja", "間欠描画"),
3748:
3749: !PNL_STEREOSCOPIC_ON ? null : ComponentFactory.createHorizontalSeparator (),
3750: mnbStereoscopicMenuItem = !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3751: ComponentFactory.createCheckBoxMenuItem (pnlStereoscopicOn, "Stereoscopic viewing", 'T', listener),
3752: "ja", "立体視"),
3753: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3754: ComponentFactory.createMenu (
3755: "Stereoscopic settings",
3756: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3757: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3758: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING,
3759: "Naked-eye crossing", listener),
3760: "ja", "裸眼交差法"),
3761: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3762: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3763: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL,
3764: "Naked-eye parallel", listener),
3765: "ja", "裸眼平行法"),
3766: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3767: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3768: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE,
3769: "Side-by-side", listener),
3770: "ja", "サイドバイサイド"),
3771: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3772: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3773: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM,
3774: "Top-and-bottom", listener),
3775: "ja", "トップアンドボトム")
3776: ),
3777: "ja", "立体視設定"),
3778:
3779: ComponentFactory.createHorizontalSeparator (),
3780: GIFAnimation.gifStartRecordingMenuItem,
3781: GIFAnimation.gifSettingsMenu,
3782:
3783: ComponentFactory.createHorizontalSeparator (),
3784: modificationMenu,
3785:
3786: SpritePatternViewer.SPV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Sprite pattern viewer", listener), "ja", "スプライトパターンビュア") : null,
3787: PaletteViewer.PLV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Palette viewer", listener), "ja", "パレットビュア") : null,
3788: ScreenModeTest.SMT_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Screen mode test", listener), "ja", "表示モードテスト") : null
3789: ),
3790: "ja", "画面"),
3791:
3792:
3793: mnbSoundMenu = ComponentFactory.setEnabled (
3794: Multilingual.mlnText (
3795: ComponentFactory.createMenu (
3796: "Sound", 'S',
3797: mnbPlayMenuItem = ComponentFactory.setEnabled (
3798: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (SoundSource.sndPlayOn, "Play", 'P', MNB_MODIFIERS, listener), "ja", "音声出力"),
3799: SoundSource.sndLine != null),
3800:
3801:
3802:
3803: ComponentFactory.createHorizontalBox (
3804: Box.createHorizontalGlue (),
3805: Multilingual.mlnText (ComponentFactory.createLabel ("Volume "), "ja", "音量 "),
3806: mnbVolumeLabel = ComponentFactory.createLabel (String.valueOf (SoundSource.sndVolume)),
3807: Box.createHorizontalGlue ()
3808: ),
3809:
3810:
3811: ComponentFactory.setPreferredSize (
3812: ComponentFactory.createHorizontalSlider (
3813: 0,
3814: SoundSource.SND_VOLUME_MAX,
3815: SoundSource.sndVolume,
3816: SoundSource.SND_VOLUME_STEP,
3817: 1,
3818: new ChangeListener () {
3819: @Override public void stateChanged (ChangeEvent ce) {
3820: SoundSource.sndSetVolume (((JSlider) ce.getSource ()).getValue ());
3821: }
3822: }),
3823: LnF.lnfFontSize * 18, LnF.lnfFontSize * 2 + 28),
3824: Multilingual.mlnText (
3825: ComponentFactory.createMenu (
3826: "Sound interpolation",
3827: Multilingual.mlnText (
3828: ComponentFactory.createRadioButtonMenuItem (
3829: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.THINNING_STEREO,
3830: "Sound thinning", listener),
3831: "ja", "音声 間引き"),
3832: Multilingual.mlnText (
3833: ComponentFactory.createRadioButtonMenuItem (
3834: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_STEREO,
3835: "Sound linear interpolation", listener),
3836: "ja", "音声 線形補間"),
3837: ComponentFactory.setEnabled (
3838: Multilingual.mlnText (
3839: ComponentFactory.createRadioButtonMenuItem (
3840: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000,
3841: "Sound piecewise-constant area interpolation", listener),
3842: "ja", "音声 区分定数面積補間"),
3843: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000),
3844: ComponentFactory.setEnabled (
3845: Multilingual.mlnText (
3846: ComponentFactory.createRadioButtonMenuItem (
3847: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000,
3848: "Sound linear area interpolation", listener),
3849: "ja", "音声 線形面積補間"),
3850: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000)
3851: ),
3852: "ja", "音声補間"),
3853: Multilingual.mlnText (ComponentFactory.createMenuItem ("Sound monitor", listener), "ja", "音声モニタ"),
3854:
3855: ComponentFactory.createHorizontalSeparator (),
3856:
3857: ComponentFactory.setEnabled (
3858: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (OPM.opmOutputMask != 0, "OPM output", listener), "ja", "OPM 出力"),
3859: SoundSource.sndLine != null),
3860: !OPMLog.OLG_ON ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("OPM log", listener), "ja", "OPM ログ"),
3861:
3862: ComponentFactory.createHorizontalSeparator (),
3863:
3864: ComponentFactory.setEnabled (
3865: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ADPCM.pcmOutputOn, "PCM output", listener), "ja", "PCM 出力"),
3866: SoundSource.sndLine != null),
3867: Multilingual.mlnText (
3868: ComponentFactory.createMenu (
3869: "PCM interpolation",
3870: Multilingual.mlnText (
3871: ComponentFactory.createRadioButtonMenuItem (
3872: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_CONSTANT,
3873: "PCM piecewise-constant interpolation", listener),
3874: "ja", "PCM 区分定数補間"),
3875: Multilingual.mlnText (
3876: ComponentFactory.createRadioButtonMenuItem (
3877: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_LINEAR,
3878: "PCM linear interpolation", listener),
3879: "ja", "PCM 線形補間"),
3880: Multilingual.mlnText (
3881: ComponentFactory.createRadioButtonMenuItem (
3882: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_HERMITE,
3883: "PCM hermite interpolation", listener),
3884: "ja", "PCM エルミート補間")
3885: ),
3886: "ja", "PCM 補間"),
3887: Multilingual.mlnText (
3888: ComponentFactory.createMenu (
3889: "PCM source oscillator frequency",
3890: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 0, "PCM 8MHz/4MHz", listener),
3891: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 1, "PCM 8MHz/16MHz", listener)
3892: ),
3893: "ja", "PCM 原発振周波数"),
3894:
3895: !MercuryUnit.MU4_ON ? null :
3896: ComponentFactory.createHorizontalSeparator (),
3897: !MercuryUnit.MU4_ON ? null :
3898: ComponentFactory.createCheckBoxMenuItem (
3899: MercuryUnit.mu4OnRequest,
3900: "Mercury-Unit V4 (MK-MU1)",
3901: listener),
3902: !MercuryUnit.MU4_ON ? null :
3903: Multilingual.mlnText (
3904: ComponentFactory.createCheckBoxMenuItem (
3905: MercuryUnit.mu4OutputEnable,
3906: "MU4 output",
3907: listener),
3908: "ja", "MU4 出力")
3909: ),
3910: "ja", "音声"),
3911: SoundSource.sndLine != null),
3912:
3913:
3914: mnbInputMenu = Multilingual.mlnText (
3915: ComponentFactory.createMenu (
3916: "Input", 'I',
3917: mnbPasteMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Paste", 'V', MNB_MODIFIERS, listener), "ja", "貼り付け"),
3918: CONDevice.conSettingsMenu,
3919: TextCopy.txcMakeMenuItem (),
3920: TextCopy.txcMakeSettingMenu (),
3921: ComponentFactory.createHorizontalSeparator (),
3922: mnbNoKeyboardMenuItem = Multilingual.mlnText (
3923: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, !Keyboard.kbdOn, "No keyboard", 'K', MNB_MODIFIERS, listener),
3924: "ja", "キーボードなし"),
3925: mnbStandardKeyboardMenuItem = Multilingual.mlnText (
3926: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_STANDARD_TYPE, "Standard keyboard", listener),
3927: "ja", "標準キーボード"),
3928: mnbCompactKeyboardMenuItem = Multilingual.mlnText (
3929: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_COMPACT_TYPE, "Compact keyboard", listener),
3930: "ja", "コンパクトキーボード"),
3931: Multilingual.mlnText (
3932: ComponentFactory.createCheckBoxMenuItem (pnlHideKeyboard, "Hide keyboard in full screen", listener),
3933: "ja", "全画面表示のときキーボードを隠す"),
3934: Multilingual.mlnText (ComponentFactory.createMenuItem ("Key assignments", listener), "ja", "キー割り当て"),
3935: ButtonFunction.bfnMakeMenuItem (),
3936: SRAM.smrRepeatDelayMenu,
3937: SRAM.smrRepeatIntervalMenu,
3938: !Keyboard.KBD_ZKEY_ON ? null : Keyboard.kbdZKeyMenu,
3939: ComponentFactory.createHorizontalSeparator (),
3940: Mouse.musSeamlessMouseCheckBox,
3941: Mouse.musFollowScrollCheckBox,
3942: Mouse.musCtrlRightCheckBox,
3943: Mouse.musEdgeAccelerationCheckBox,
3944: Mouse.musMouseCursorSpeedBox,
3945: Mouse.musSpeedSlider,
3946: Mouse.musHostsPixelUnitsCheckBox,
3947: ComponentFactory.createHorizontalSeparator (),
3948: Multilingual.mlnText (ComponentFactory.createMenuItem ("Joystick port settings", listener), "ja", "ジョイスティックポート設定")
3949: ),
3950: "ja", "入力"),
3951:
3952:
3953: mnbConfigMenu = Multilingual.mlnText (
3954: ComponentFactory.createMenu (
3955: "Config", 'G',
3956: Multilingual.mlnText (ComponentFactory.createMenuItem ("RS-232C and terminal", listener), "ja", "RS-232C とターミナル"),
3957: Multilingual.mlnText (
3958: ComponentFactory.createMenu (
3959: "Debug",
3960: Multilingual.mlnText (ComponentFactory.createMenuItem ("Console", listener), "ja", "コンソール"),
3961: Multilingual.mlnText (ComponentFactory.createMenuItem ("Register list", listener), "ja", "レジスタリスト"),
3962: Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble list", listener), "ja", "逆アセンブルリスト"),
3963: Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory dump list", listener), "ja", "メモリダンプリスト"),
3964: Multilingual.mlnText (ComponentFactory.createMenuItem ("Logical space monitor", listener), "ja", "論理空間モニタ"),
3965: Multilingual.mlnText (ComponentFactory.createMenuItem ("Physical space monitor", listener), "ja", "物理空間モニタ"),
3966: ATCMonitor.ACM_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Address translation caches monitor", listener), "ja", "アドレス変換キャッシュモニタ") : null,
3967: BranchLog.BLG_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Branch log", listener), "ja", "分岐ログ") : null,
3968: ProgramFlowVisualizer.PFV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Program flow visualizer", listener), "ja", "プログラムフロービジュアライザ") : null,
3969: RasterBreakPoint.RBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Raster break point", listener), "ja", "ラスタブレークポイント") : null,
3970: DataBreakPoint.DBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Data break point", listener), "ja", "データブレークポイント") : null,
3971: RootPointerList.RTL_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Root pointer list", listener), "ja", "ルートポインタリスト") : null,
3972: ComponentFactory.createHorizontalSeparator (),
3973: SRAM.smrRomdbMenu
3974: ),
3975: "ja", "デバッグ"),
3976: SRAM.smrBootMenu,
3977: mainMemoryMenu,
3978: highMemoryMenu,
3979: localMemoryMenu,
3980: xellent30Menu,
3981: ComponentFactory.createHorizontalSeparator (),
3982: ComponentFactory.createMenu (
3983: "RTC",
3984: Multilingual.mlnText (
3985: ComponentFactory.createMenuItem ("Adjust clock to host", listener),
3986: "ja", "時計をホストに合わせる")
3987: ),
3988: SRAM.smrMenu,
3989: Settings.sgsMenu,
3990: ComponentFactory.createHorizontalSeparator (),
3991: Multilingual.mlnText (ComponentFactory.createMenuItem ("Printer", listener), "ja", "プリンタ"),
3992: ROM.romMenu,
3993: Multilingual.mlnText (
3994: ComponentFactory.createMenu (
3995: "Miscellaneous",
3996: SlowdownTest.sdtCheckBoxMenuItem,
3997: SlowdownTest.sdtBox,
3998: Multilingual.mlnText (
3999: ComponentFactory.createCheckBoxMenuItem (Mouse.musOutputButtonStatus, "Print key and mouse button events", listener),
4000: "ja", "キーとマウスのボタンのイベントを表示"),
4001: Z8530.SCC_DEBUG_ON ? Z8530.sccDebugMenu : null
4002: ),
4003: "ja", "その他"),
4004: ComponentFactory.createHorizontalSeparator (),
4005: Multilingual.mlnText (
4006: ComponentFactory.createMenuItem ("Java runtime environment information", listener),
4007: "ja", "Java 実行環境の情報"),
4008: Multilingual.mlnText (
4009: ComponentFactory.createMenuItem ("Version information", listener),
4010: "ja", "バージョン情報"),
4011: Multilingual.mlnText (
4012: ComponentFactory.createMenu (
4013: "License",
4014: Multilingual.mlnText (ComponentFactory.createMenuItem ("XEiJ License", listener), "ja", "XEiJ 使用許諾条件"),
4015: Multilingual.mlnText (ComponentFactory.createMenuItem ("FSHARP License", listener), "ja", "FSHARP 許諾条件"),
4016: Multilingual.mlnText (ComponentFactory.createMenuItem ("ymfm License", listener), "ja", "ymfm License"),
4017: Multilingual.mlnText (ComponentFactory.createMenuItem ("jSerialComm License", listener), "ja", "jSerialComm License")
4018: ),
4019: "ja", "使用許諾条件")
4020: ),
4021: "ja", "設定"),
4022:
4023: mnbMakeLanguageMenu (),
4024:
4025:
4026: Box.createHorizontalGlue (),
4027: ComponentFactory.createVerticalBox (
4028: Box.createVerticalGlue (),
4029: Indicator.indBox,
4030: Box.createVerticalGlue ()
4031: ),
4032: Box.createHorizontalGlue ()
4033:
4034: );
4035: }
4036:
4037:
4038:
4039:
4040:
4041:
4042:
4043: public static boolean frmIsActive;
4044:
4045:
4046: public static JFrame frmFrame;
4047: public static int frmMarginWidth;
4048: public static int frmMarginHeight;
4049: public static Dimension frmMinimumSize;
4050:
4051:
4052: public static GraphicsDevice frmScreenDevice;
4053:
4054:
4055: public static DropTarget frmDropTarget;
4056:
4057:
4058:
4059: public static void frmInit () {
4060: frmIsActive = false;
4061: frmScreenDevice = GraphicsEnvironment.getLocalGraphicsEnvironment ().getDefaultScreenDevice ();
4062: pnlIsFullScreenSupported = frmScreenDevice.isFullScreenSupported ();
4063: }
4064:
4065:
4066:
4067: public static void frmMake () {
4068:
4069:
4070: frmFrame = ComponentFactory.createRestorableFrame (
4071: Settings.SGS_FRM_FRAME_KEY,
4072: PRG_TITLE + " version " + PRG_VERSION,
4073: mnbMenuBar,
4074: pnlPanel);
4075: frmUpdateTitle ();
4076: frmFrame.setIconImage (LnF.LNF_ICON_IMAGE_48);
4077: frmFrame.setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);
4078:
4079:
4080:
4081:
4082: frmMarginWidth = frmFrame.getWidth () - pnlPanel.getWidth ();
4083: frmMarginHeight = frmFrame.getHeight () - pnlPanel.getHeight ();
4084: frmMinimumSize = new Dimension (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
4085: frmFrame.setMinimumSize (frmMinimumSize);
4086:
4087:
4088:
4089: frmDropTarget = new DropTarget (pnlPanel, DnDConstants.ACTION_COPY, new DropTargetAdapter () {
4090: @Override public void dragOver (DropTargetDragEvent dtde) {
4091: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
4092: dtde.acceptDrag (DnDConstants.ACTION_COPY);
4093: return;
4094: }
4095: dtde.rejectDrag ();
4096: }
4097: @Override public void drop (DropTargetDropEvent dtde) {
4098: try {
4099: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
4100: dtde.acceptDrop (DnDConstants.ACTION_COPY);
4101: boolean reset = false;
4102: int fdu0 = -1;
4103: int fdu = 0;
4104: int hdu0 = -1;
4105: int hdu = 0;
4106: int scu0 = -1;
4107: int scu = 0;
4108: int hfu0 = -1;
4109: int hfu = 0;
4110: for (Object o : (java.util.List) dtde.getTransferable ().getTransferData (DataFlavor.javaFileListFlavor)) {
4111: if (o instanceof File) {
4112: File file = (File) o;
4113: if (file.isFile ()) {
4114: if (FDC.fdcFileFilter.accept (file)) {
4115: if (fdu < FDC.FDC_MAX_UNITS &&
4116: FDC.fdcUnitArray[fdu].insert (file.getPath (), false)) {
4117: if (fdu0 < 0) {
4118: fdu0 = fdu;
4119: }
4120: fdu++;
4121: continue;
4122: }
4123: }
4124: if (HDC.hdcFileFilter.accept (file)) {
4125: if (hdu < 16 &&
4126: HDC.hdcUnitArray[hdu].insert (file.getPath (), false)) {
4127: if (hdu0 < 0) {
4128: hdu0 = hdu;
4129: }
4130: hdu++;
4131: continue;
4132: }
4133: }
4134: if (SPC.spcFileFilter.accept (file)) {
4135: if (scu < 16 &&
4136: SPC.spcUnitArray[scu].insert (file.getPath (), false)) {
4137: if (scu0 < 0) {
4138: scu0 = scu;
4139: }
4140: scu++;
4141: continue;
4142: }
4143: }
4144: }
4145: if (HFS.hfsFileFilter.accept (file)) {
4146: if (hfu < HFS.HFS_MAX_UNITS &&
4147: HFS.hfsUnitArray[hfu].insert (file.getPath (), false)) {
4148: if (hfu0 < 0) {
4149: hfu0 = hfu;
4150: }
4151: hfu++;
4152: continue;
4153: }
4154: }
4155: }
4156: reset = false;
4157: }
4158: dtde.dropComplete (true);
4159: if (reset) {
4160: if (fdu0 >= 0) {
4161: mpuReset (0x9070 | fdu0 << 8, -1);
4162: } else if (hdu0 >= 0) {
4163: mpuReset (0x8000 | hdu0 << 8, -1);
4164: } else if (scu0 >= 0) {
4165: mpuReset (0xa000, SPC.SPC_HANDLE_EX + (scu0 << 2));
4166: } else if (hfu0 >= 0) {
4167: HFS.hfsBootUnit = hfu0;
4168: mpuReset (0xa000, HFS.HFS_BOOT_HANDLE);
4169: }
4170: }
4171: return;
4172: }
4173: } catch (UnsupportedFlavorException ufe) {
4174:
4175: } catch (IOException ioe) {
4176:
4177: }
4178: dtde.rejectDrop();
4179: }
4180: });
4181:
4182: }
4183:
4184:
4185:
4186: public static void frmUpdateTitle () {
4187: frmFrame.setTitle ((currentAccelerator == ACCELERATOR_HYBRID ? "X68000 Hybrid" :
4188: currentModel.getName () +
4189: (currentAccelerator == ACCELERATOR_XELLENT30 ? " with Xellent30" :
4190: currentAccelerator == ACCELERATOR_060TURBO ? " with 060turbo" :
4191: currentAccelerator == ACCELERATOR_060TURBOPRO ? " with 060turboPRO" : "")) +
4192: " - " + PRG_TITLE + " version " + PRG_VERSION);
4193: }
4194:
4195:
4196:
4197: public static void frmStart () {
4198:
4199:
4200:
4201:
4202:
4203:
4204:
4205:
4206: ComponentFactory.addListener (
4207: frmFrame,
4208: new WindowAdapter () {
4209: @Override public void windowActivated (WindowEvent we) {
4210: frmIsActive = true;
4211: }
4212: @Override public void windowClosing (WindowEvent we) {
4213: prgTini ();
4214: }
4215: @Override public void windowDeactivated (WindowEvent we) {
4216: frmIsActive = false;
4217:
4218: }
4219: @Override public void windowOpened (WindowEvent we) {
4220: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
4221: pnlFixedRate = pnlGetRefreshRate ();
4222: }
4223: }
4224: });
4225:
4226:
4227:
4228:
4229: ComponentFactory.addListener (
4230: frmFrame,
4231: new ComponentAdapter () {
4232: @Override public void componentMoved (ComponentEvent ce) {
4233: Point p = pnlPanel.getLocationOnScreen ();
4234: pnlGlobalX = p.x;
4235: pnlGlobalY = p.y;
4236: }
4237: @Override public void componentResized (ComponentEvent ce) {
4238: Point p = pnlPanel.getLocationOnScreen ();
4239: pnlGlobalX = p.x;
4240: pnlGlobalY = p.y;
4241: }
4242: });
4243:
4244: }
4245:
4246:
4247:
4248:
4249:
4250:
4251: public static BufferedImage clpClipboardImage;
4252: public static String clpClipboardString;
4253: public static Clipboard clpClipboard;
4254: public static Transferable clpImageContents;
4255: public static Transferable clpStringContents;
4256: public static ClipboardOwner clpClipboardOwner;
4257: public static boolean clpIsClipboardOwner;
4258:
4259:
4260:
4261:
4262: public static void clpMake () {
4263: Toolkit toolkit = Toolkit.getDefaultToolkit ();
4264: clpClipboard = null;
4265: try {
4266: clpClipboard = toolkit.getSystemClipboard ();
4267: } catch (Exception e) {
4268: return;
4269: }
4270: clpClipboardImage = null;
4271: clpClipboardString = null;
4272: clpImageContents = new Transferable () {
4273: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
4274: if (flavor == DataFlavor.imageFlavor) {
4275: return clpClipboardImage;
4276: } else {
4277: throw new UnsupportedFlavorException (flavor);
4278: }
4279: }
4280: public DataFlavor[] getTransferDataFlavors () {
4281: return new DataFlavor[] { DataFlavor.imageFlavor };
4282: }
4283: public boolean isDataFlavorSupported (DataFlavor flavor) {
4284: return flavor == DataFlavor.imageFlavor;
4285: }
4286: };
4287: clpStringContents = new Transferable () {
4288: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
4289: if (flavor == DataFlavor.stringFlavor) {
4290: return clpClipboardString;
4291: } else {
4292: throw new UnsupportedFlavorException (flavor);
4293: }
4294: }
4295: public DataFlavor[] getTransferDataFlavors () {
4296: return new DataFlavor[] { DataFlavor.stringFlavor };
4297: }
4298: public boolean isDataFlavorSupported (DataFlavor flavor) {
4299: return flavor == DataFlavor.stringFlavor;
4300: }
4301: };
4302: clpIsClipboardOwner = false;
4303:
4304:
4305: clpClipboardOwner = new ClipboardOwner () {
4306: @Override public void lostOwnership (Clipboard clipboard, Transferable contents) {
4307: clpIsClipboardOwner = false;
4308: }
4309: };
4310:
4311:
4312: clpClipboard.addFlavorListener (new FlavorListener () {
4313: @Override public void flavorsChanged (FlavorEvent fe) {
4314: boolean available = false;
4315: try {
4316: available = clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor);
4317: } catch (IllegalStateException ise) {
4318: }
4319: if (mnbPasteMenuItem != null) {
4320: mnbPasteMenuItem.setEnabled (available);
4321: }
4322: }
4323: });
4324: if (!clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor)) {
4325: if (mnbPasteMenuItem != null) {
4326: mnbPasteMenuItem.setEnabled (false);
4327: }
4328: }
4329: }
4330:
4331:
4332:
4333: public static void clpCopy (String s) {
4334: if (clpClipboard != null && s != null) {
4335: clpClipboardString = s;
4336: try {
4337: clpClipboard.setContents (clpStringContents, clpClipboardOwner);
4338: clpIsClipboardOwner = true;
4339: } catch (Exception e) {
4340: return;
4341: }
4342: }
4343: }
4344:
4345:
4346:
4347:
4348:
4349:
4350:
4351:
4352:
4353:
4354:
4355:
4356:
4357:
4358:
4359:
4360:
4361:
4362:
4363:
4364:
4365:
4366:
4367: public static int xt3DIPSWRequest;
4368: public static int xt3DIPSW;
4369: public static int xt3PortAddress;
4370:
4371:
4372: public static int xt3MemorySizeRequest;
4373: public static int xt3MemorySize;
4374: public static boolean xt3MemoryEnabled;
4375: public static int xt3MemoryPosition;
4376: public static int xt3MemoryStart;
4377: public static final byte[] xt3MemoryArray = new byte[1 << 20];
4378: public static boolean xt3MemorySave;
4379:
4380:
4381: public static int xt3SavedPC;
4382: public static final int[] xt3SavedRn = new int[16];
4383:
4384:
4385: public static void xt3Init () {
4386:
4387:
4388: xt3DIPSWRequest = Math.max (0, Math.min (3, Settings.sgsGetInt ("xt3dipsw")));
4389: xt3DIPSW = xt3DIPSWRequest;
4390:
4391:
4392: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4393:
4394:
4395: int memoryKB = Settings.sgsGetInt ("xt3memorykb");
4396: if (!(memoryKB == 1 << 8 || memoryKB == 1 << 10)) {
4397: memoryKB = 1 << 8;
4398: }
4399: xt3MemorySizeRequest = memoryKB << 10;
4400: xt3MemorySize = xt3MemorySizeRequest;
4401:
4402:
4403: xt3MemoryEnabled = false;
4404:
4405:
4406: xt3MemoryPosition = 11 << 20;
4407:
4408:
4409: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4410:
4411:
4412:
4413: byte[] memoryArray = Settings.sgsGetData ("xt3memorydata");
4414: Arrays.fill (xt3MemoryArray,
4415: (byte) 0);
4416: if (memoryArray.length != 0) {
4417: System.arraycopy (memoryArray, 0,
4418: xt3MemoryArray, 0,
4419: Math.min (memoryArray.length, xt3MemoryArray.length));
4420: if (memoryArray.length < xt3MemoryArray.length) {
4421: Arrays.fill (xt3MemoryArray,
4422: memoryArray.length,
4423: xt3MemoryArray.length,
4424: (byte) 0);
4425: }
4426: }
4427:
4428:
4429: xt3MemorySave = Settings.sgsGetOnOff ("xt3memorysave");
4430:
4431:
4432: xt3SavedPC = 0;
4433:
4434: Arrays.fill (xt3SavedRn, 0);
4435:
4436: xt3Reset ();
4437: }
4438:
4439:
4440: public static void xt3Tini () {
4441:
4442:
4443: Settings.sgsPutInt ("xt3dipsw", xt3DIPSW);
4444:
4445:
4446: Settings.sgsPutInt ("xt3memorykb", xt3MemorySizeRequest >> 10);
4447:
4448:
4449: boolean zero = true;
4450: if (xt3MemorySave) {
4451: for (int i = 0; i < 1 << 20; i++) {
4452: if (xt3MemoryArray[i] != 0) {
4453: zero = false;
4454: break;
4455: }
4456: }
4457: }
4458: Settings.sgsCurrentMap.put ("xt3memorydata",
4459: zero ? "" :
4460: ByteArray.byaEncodeBase64 (ByteArray.byaEncodeGzip (xt3MemoryArray, 0, 1 << 20)));
4461:
4462:
4463: Settings.sgsPutOnOff ("xt3memorysave", xt3MemorySave);
4464:
4465: }
4466:
4467:
4468: public static void xt3Reset () {
4469:
4470:
4471: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4472:
4473:
4474: xt3MemorySize = xt3MemorySizeRequest;
4475:
4476:
4477: xt3MemoryEnabled = false;
4478:
4479:
4480: xt3MemoryPosition = 11 << 20;
4481:
4482:
4483: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4484:
4485:
4486: xt3SavedPC = 0;
4487: Arrays.fill (xt3SavedRn, 0);
4488:
4489: }
4490:
4491:
4492: public static int xt3PortRead () {
4493: return (currentIsSecond ? 4 : 0) | (xt3MemoryEnabled ? 2 : 0) | (xt3MemoryPosition == 11 << 20 ? 0 : 1);
4494: }
4495:
4496:
4497: public static void xt3PortWrite (int d) {
4498: boolean nextIsSecond = (d & 4) != 0;
4499: boolean memoryEnabled = (d & 2) != 0;
4500: int memoryPosition = (d & 1) == 0 ? 11 << 20 : 15 << 20;
4501:
4502: if (xt3MemoryEnabled != memoryEnabled ||
4503: xt3MemoryPosition != memoryPosition) {
4504: if (xt3MemoryEnabled) {
4505: if (xt3MemoryPosition == 11 << 20) {
4506: if (MainMemory.mmrMemorySizeCurrent < 12 << 20) {
4507: busSuper (MemoryMappedDevice.MMD_NUL, (12 << 20) - xt3MemorySize, 12 << 20);
4508: } else {
4509: busUser (MemoryMappedDevice.MMD_MMR, (12 << 20) - xt3MemorySize, 12 << 20);
4510: }
4511: } else {
4512: busSuper (MemoryMappedDevice.MMD_ROM, (16 << 20) - xt3MemorySize, 16 << 20);
4513: }
4514: }
4515: xt3MemoryEnabled = memoryEnabled;
4516: xt3MemoryPosition = memoryPosition;
4517: if (xt3MemoryEnabled) {
4518: if (xt3MemoryPosition == 11 << 20) {
4519: busUser (MemoryMappedDevice.MMD_XTM, (12 << 20) - xt3MemorySize, 12 << 20);
4520: } else {
4521: busUser (MemoryMappedDevice.MMD_XTM, (16 << 20) - xt3MemorySize, 16 << 20);
4522: }
4523: }
4524: }
4525:
4526: if (currentIsSecond != nextIsSecond) {
4527:
4528: if (nextIsSecond) {
4529:
4530:
4531: xt3SavedPC = regPC;
4532: System.arraycopy (regRn, 0, xt3SavedRn, 0, 16);
4533:
4534:
4535: if (mpuTask != null) {
4536: mpuClockLimit = 0L;
4537: System.out.println (Multilingual.mlnJapanese ?
4538: Model.MPU_NAMES[currentFirstMPU] + " を停止します" :
4539: Model.MPU_NAMES[currentFirstMPU] + " stops");
4540: mpuTask.cancel ();
4541: mpuTask = null;
4542: }
4543:
4544:
4545: tmrTimer.schedule (new TimerTask () {
4546: @Override public void run () {
4547:
4548:
4549: currentIsSecond = true;
4550: currentMPU = currentSecondMPU;
4551: mpuSetCurrentClock (specifiedSecondClock);
4552:
4553: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
4554: MC68EC030.m30DivZeroVFlag = false;
4555: }
4556:
4557: RegisterList.drpSetMPU ();
4558: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4559: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4560: MC68060.mmuReset ();
4561:
4562: mpuIgnoreAddressError = true;
4563: fpuBox = fpuMotherboardCoprocessor;
4564: fpuBox.epbReset ();
4565: fpuFPn = fpuBox.epbFPn;
4566: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
4567: mpuSetWait ();
4568:
4569: regSRT1 = regSRT0 = 0;
4570: regSRS = REG_SR_S;
4571: regSRM = 0;
4572: regSRI = REG_SR_I;
4573: regCCR = 0;
4574: Arrays.fill (regRn, 0);
4575:
4576: regRn[15] = MainMemory.mmrRls (0x00000000);
4577: regPC = MainMemory.mmrRls (0x00000004);
4578:
4579: mpuIMR = 0;
4580: mpuIRR = 0;
4581: if (MC68901.MFP_DELAYED_INTERRUPT) {
4582: mpuDIRR = 0;
4583: }
4584: mpuISR = 0;
4585:
4586: mpuStart ();
4587: }
4588: }, TMR_DELAY);
4589:
4590: } else {
4591:
4592:
4593: if (mpuTask != null) {
4594: mpuClockLimit = 0L;
4595: System.out.println (Multilingual.mlnJapanese ? "MC68EC030 を停止します" : "MC68EC030 stops");
4596: mpuTask.cancel ();
4597: mpuTask = null;
4598: }
4599:
4600:
4601: tmrTimer.schedule (new TimerTask () {
4602: @Override public void run () {
4603:
4604:
4605: currentIsSecond = false;
4606: currentMPU = currentFirstMPU;
4607: mpuSetCurrentClock (specifiedFirstClock);
4608:
4609: RegisterList.drpSetMPU ();
4610: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4611: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4612: MC68060.mmuReset ();
4613:
4614: mpuIgnoreAddressError = false;
4615: mpuCacheOn = false;
4616: mpuSetWait ();
4617:
4618: regSRT1 = regSRT0 = 0;
4619: regSRS = REG_SR_S;
4620: regSRM = 0;
4621: regSRI = REG_SR_I;
4622: regCCR = 0;
4623:
4624: regPC = xt3SavedPC;
4625: System.arraycopy (xt3SavedRn, 0, regRn, 0, 16);
4626:
4627: mpuIMR = 0;
4628: mpuIRR = 0;
4629: if (MC68901.MFP_DELAYED_INTERRUPT) {
4630: mpuDIRR = 0;
4631: }
4632: mpuISR = 0;
4633:
4634: mpuStart ();
4635: }
4636: }, TMR_DELAY);
4637:
4638: }
4639: }
4640: }
4641:
4642:
4643:
4644:
4645:
4646:
4647: public static JMenu mdlMenu;
4648:
4649: public static JRadioButtonMenuItem mdlShodaiMenuItem;
4650: public static JRadioButtonMenuItem mdlACEMenuItem;
4651: public static JRadioButtonMenuItem mdlEXPERTMenuItem;
4652: public static JRadioButtonMenuItem mdlPROMenuItem;
4653: public static JRadioButtonMenuItem mdlSUPERMenuItem;
4654: public static JRadioButtonMenuItem mdlXVIMenuItem;
4655: public static JRadioButtonMenuItem mdlXellent30MenuItem;
4656: public static JRadioButtonMenuItem mdlCompactMenuItem;
4657: public static JRadioButtonMenuItem mdlHybridMenuItem;
4658: public static JRadioButtonMenuItem mdl060turboPROMenuItem;
4659: public static JRadioButtonMenuItem mdlX68030MenuItem;
4660: public static JRadioButtonMenuItem mdl030CompactMenuItem;
4661: public static JRadioButtonMenuItem mdl060turboMenuItem;
4662: public static JCheckBoxMenuItem mdlMC68010MenuItem;
4663:
4664: public static JMenu coproFPUMenu;
4665:
4666:
4667: public static final int ACCELERATOR_HYBRID = 1;
4668: public static final int ACCELERATOR_XELLENT30 = 2;
4669: public static final int ACCELERATOR_060TURBO = 3;
4670: public static final int ACCELERATOR_060TURBOPRO = 4;
4671: public static final double MHZ_HYBRID_VALUE = 100.0 / 3.0;
4672: public static final String MHZ_HYBRID_STRING = "33.3";
4673: public static final double MHZ_060TURBO_VALUE = 50.0;
4674: public static final String MHZ_060TURBO_STRING = "50";
4675:
4676:
4677:
4678: public static Model specifiedModel;
4679: public static int specifiedAccelerator;
4680: public static boolean mpu010;
4681:
4682: public static boolean specifiedIsSecond;
4683: public static int specifiedFirstMPU;
4684: public static int specifiedSecondMPU;
4685: public static int specifiedMPU;
4686:
4687: public static double specifiedFirstClock;
4688: public static double specifiedSecondClock;
4689: public static double specifiedClock;
4690:
4691: public static int specifiedCopro0;
4692: public static int specifiedCopro1;
4693: public static int specifiedCopro2;
4694: public static int specifiedOnchipFPU;
4695:
4696:
4697:
4698: public static Model currentModel;
4699: public static int currentAccelerator;
4700:
4701: public static boolean currentIsSecond;
4702: public static int currentFirstMPU;
4703: public static int currentSecondMPU;
4704: public static int currentMPU;
4705:
4706:
4707: public static int currentCopro0;
4708: public static int currentCopro1;
4709: public static int currentCopro2;
4710: public static int currentOnchipFPU;
4711:
4712:
4713:
4714: public static void mdlInit () {
4715:
4716:
4717: specifiedModel = Model.COMPACT;
4718: specifiedAccelerator = ACCELERATOR_HYBRID;
4719: mpu010 = Settings.sgsGetOnOff ("mpu010");
4720: {
4721: String paramModel = Settings.sgsGetString ("model");
4722: switch (paramModel.toLowerCase ()) {
4723: case "":
4724: case "none":
4725: case "hybrid":
4726: specifiedModel = Model.COMPACT;
4727: specifiedAccelerator = ACCELERATOR_HYBRID;
4728: break;
4729: case "xellent30":
4730: specifiedModel = Model.XVI;
4731: specifiedAccelerator = ACCELERATOR_XELLENT30;
4732: break;
4733: case "060turbo":
4734: specifiedModel = Model.X68030;
4735: specifiedAccelerator = ACCELERATOR_060TURBO;
4736: break;
4737: case "060turbopro":
4738: specifiedModel = Model.PRO;
4739: specifiedAccelerator = ACCELERATOR_060TURBOPRO;
4740: break;
4741: default:
4742: Model model = Model.fromTypeOrSynonym (paramModel);
4743: if (model != null) {
4744: specifiedModel = model;
4745: specifiedAccelerator = 0;
4746: } else {
4747: System.out.println (Multilingual.mlnJapanese ?
4748: paramModel + " は不明な機種です" :
4749: paramModel + " is unknown model");
4750: specifiedModel = Model.COMPACT;
4751: specifiedAccelerator = ACCELERATOR_HYBRID;
4752: }
4753: }
4754: }
4755:
4756: specifiedIsSecond = false;
4757: specifiedFirstMPU = specifiedModel.getMPU ();
4758: specifiedSecondMPU = Model.MPU_MC68EC030;
4759: {
4760: String[] paramMPUs = Settings.sgsGetString ("mpu").split (",");
4761: for (int i = 0; i < 2; i++) {
4762: int mpu = 0;
4763: String paramMPU = i < paramMPUs.length ? paramMPUs[i] : "";
4764: switch (paramMPU) {
4765: case "":
4766: case "none":
4767: case "-1":
4768: mpu = (i == 0 ?
4769: (specifiedAccelerator == ACCELERATOR_060TURBO ||
4770: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4771: specifiedModel.getMPU ()) :
4772: Model.MPU_MC68EC030);
4773: break;
4774: case "0":
4775: case "68000":
4776: case "mc68000":
4777: mpu = Model.MPU_MC68000;
4778: break;
4779: case "1":
4780: case "68010":
4781: case "mc68010":
4782: mpu = Model.MPU_MC68010;
4783: break;
4784:
4785:
4786:
4787:
4788:
4789: case "3":
4790: case "68ec030":
4791: case "mc68ec030":
4792: mpu = Model.MPU_MC68EC030;
4793: break;
4794:
4795:
4796:
4797:
4798:
4799:
4800:
4801:
4802:
4803:
4804:
4805:
4806:
4807:
4808:
4809:
4810:
4811: case "6":
4812: case "68060":
4813: case "mc68060":
4814: mpu = Model.MPU_MC68060;
4815: break;
4816: default:
4817: Model model = Model.fromTypeOrSynonym (paramMPU);
4818: if (model != null) {
4819: mpu = model.getMPU ();
4820: } else {
4821: System.out.println (Multilingual.mlnJapanese ?
4822: paramMPU + " は不明な MPU です" :
4823: paramMPU + " is unknown MPU");
4824: mpu = specifiedModel.getMPU ();
4825: }
4826: }
4827: if (i == 0) {
4828: specifiedFirstMPU = mpu;
4829: } else {
4830: specifiedSecondMPU = mpu;
4831: }
4832: }
4833: }
4834: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
4835:
4836: specifiedFirstClock = specifiedModel.getClock ();
4837: specifiedSecondClock = specifiedFirstClock * 2.0;
4838: {
4839: String[] paramClocks = Settings.sgsGetString ("clock").split (",");
4840: for (int i = 0; i < 2; i++) {
4841: double clock = 0.0;
4842: String paramClock = i < paramClocks.length ? paramClocks[i] : "";
4843: switch (paramClock.toLowerCase ()) {
4844: case "":
4845: case "none":
4846: case "-1":
4847: clock = (i == 0 ?
4848: (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4849: specifiedAccelerator == ACCELERATOR_060TURBO ||
4850: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4851: specifiedModel.getClock ()) :
4852: specifiedFirstClock * 2.0);
4853: break;
4854: case "hybrid":
4855: clock = MHZ_HYBRID_VALUE;
4856: break;
4857: case "060turbo":
4858: case "060turbopro":
4859: clock = MHZ_060TURBO_VALUE;
4860: break;
4861: case "16.7":
4862: case "xellent30":
4863: clock = 50.0 / 3.0;
4864: break;
4865: case "33.3":
4866: clock = 100.0 / 3.0;
4867: break;
4868: case "66.7":
4869: clock = 200.0 / 3.0;
4870: break;
4871: default:
4872: if (paramClock.matches ("^(?:" +
4873: "[-+]?" +
4874: "(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)" +
4875: "(?:[Ee][-+]?[0-9]+)?" +
4876: ")$")) {
4877: double d = Double.parseDouble (paramClock);
4878: if (1.0 <= d && d <= 1000.0) {
4879: clock = d;
4880: }
4881: } else {
4882: System.out.println (Multilingual.mlnJapanese ?
4883: paramClock + " は不明な動作周波数です" :
4884: paramClock + " is unknown clock frequency");
4885: clock = specifiedModel.getClock ();
4886: }
4887: }
4888: if (i == 0) {
4889: specifiedFirstClock = clock;
4890: } else {
4891: specifiedSecondClock = clock;
4892: }
4893: }
4894: }
4895: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4896:
4897: specifiedCopro0 = 15 & Settings.sgsGetInt ("copro0", 2);
4898: if (!((7 & specifiedCopro0) == 0 ||
4899: (7 & specifiedCopro0) == 1 ||
4900: (7 & specifiedCopro0) == 2 ||
4901: (7 & specifiedCopro0) == 7)) {
4902: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4903: }
4904: specifiedCopro1 = 15 & Settings.sgsGetInt ("copro1", 2);
4905: if (!((7 & specifiedCopro1) == 0 ||
4906: (7 & specifiedCopro1) == 1 ||
4907: (7 & specifiedCopro1) == 2 ||
4908: (7 & specifiedCopro1) == 7)) {
4909: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4910: }
4911: specifiedCopro2 = 15 & Settings.sgsGetInt ("copro2", 2);
4912: if (!((7 & specifiedCopro2) == 0 ||
4913: (7 & specifiedCopro2) == 1 ||
4914: (7 & specifiedCopro2) == 2 ||
4915: (7 & specifiedCopro2) == 7)) {
4916: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4917: }
4918: specifiedOnchipFPU = 15 & Settings.sgsGetInt ("onchipfpu", 7);
4919: if (!((7 & specifiedOnchipFPU) == 0 ||
4920: (7 & specifiedOnchipFPU) == 6 ||
4921: (7 & specifiedOnchipFPU) == 7)) {
4922: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4923: }
4924:
4925:
4926: currentModel = specifiedModel;
4927: currentAccelerator = specifiedAccelerator;
4928:
4929: currentIsSecond = specifiedIsSecond;
4930: currentFirstMPU = specifiedFirstMPU;
4931: currentSecondMPU = specifiedSecondMPU;
4932: currentMPU = specifiedMPU;
4933:
4934:
4935: currentCopro0 = specifiedCopro0;
4936: currentCopro1 = specifiedCopro1;
4937: currentCopro2 = specifiedCopro2;
4938: currentOnchipFPU = specifiedOnchipFPU;
4939:
4940:
4941: mpuUtilOn = Settings.sgsGetOnOff ("util");
4942: mpuUtilRatio = fmtParseInt (Settings.sgsGetString ("ratio"), 0, 1, 100, 100);
4943:
4944: mpuArbFreqMHz = fmtParseInt (Settings.sgsGetString ("mhz"), 0, 1, 1000, 100);
4945: if (mpuUtilOn) {
4946: mpuArbFreqOn = false;
4947: } else {
4948: mpuArbFreqOn = !(specifiedClock == 10.0 ||
4949: specifiedClock == 50.0 / 3.0 ||
4950: specifiedClock == 25.0 ||
4951: specifiedClock == 100.0 / 3.0 ||
4952: specifiedClock == 50.0 ||
4953: specifiedClock == 200.0 / 3.0 ||
4954: specifiedClock == 75.0 ||
4955: specifiedClock == 100.0);
4956: if (mpuArbFreqOn) {
4957: mpuArbFreqMHz = (int) specifiedClock;
4958: }
4959: }
4960:
4961:
4962: mpuROMWaitCycles = 0;
4963: mpuRAMWaitCycles = 0;
4964: mpuCacheOn = false;
4965:
4966: mpuNoWaitTime.ram = 0;
4967: mpuNoWaitTime.gvram = 0;
4968: mpuNoWaitTime.tvram = 0;
4969: mpuNoWaitTime.crtc = 0;
4970: mpuNoWaitTime.palet = 0;
4971: mpuNoWaitTime.vicon = 0;
4972: mpuNoWaitTime.dmac = 0;
4973: mpuNoWaitTime.mfp = 0;
4974: mpuNoWaitTime.rtc = 0;
4975: mpuNoWaitTime.prnport = 0;
4976: mpuNoWaitTime.sysport = 0;
4977: mpuNoWaitTime.opm = 0;
4978: mpuNoWaitTime.adpcm = 0;
4979: mpuNoWaitTime.fdc = 0;
4980: mpuNoWaitTime.fdd = 0;
4981: mpuNoWaitTime.hdc = 0;
4982: mpuNoWaitTime.scc = 0;
4983: mpuNoWaitTime.ppi = 0;
4984: mpuNoWaitTime.ioi = 0;
4985: mpuNoWaitTime.sprc = 0;
4986: mpuNoWaitTime.sram = 0;
4987: mpuNoWaitTime.rom = 0;
4988: mpuNoWaitTime.ramlong = mpuNoWaitTime.ram << 1;
4989: mpuNoWaitTime.romlong = mpuNoWaitTime.rom << 1;
4990:
4991: dmaNoWaitTime.ram = 0;
4992: dmaNoWaitTime.gvram = 0;
4993: dmaNoWaitTime.tvram = 0;
4994: dmaNoWaitTime.crtc = 0;
4995: dmaNoWaitTime.palet = 0;
4996: dmaNoWaitTime.vicon = 0;
4997: dmaNoWaitTime.dmac = 0;
4998: dmaNoWaitTime.mfp = 0;
4999: dmaNoWaitTime.rtc = 0;
5000: dmaNoWaitTime.prnport = 0;
5001: dmaNoWaitTime.sysport = 0;
5002: dmaNoWaitTime.opm = 0;
5003: dmaNoWaitTime.adpcm = 0;
5004: dmaNoWaitTime.fdc = 0;
5005: dmaNoWaitTime.fdd = 0;
5006: dmaNoWaitTime.hdc = 0;
5007: dmaNoWaitTime.scc = 0;
5008: dmaNoWaitTime.ppi = 0;
5009: dmaNoWaitTime.ioi = 0;
5010: dmaNoWaitTime.sprc = 0;
5011: dmaNoWaitTime.sram = 0;
5012: dmaNoWaitTime.rom = 0;
5013: dmaNoWaitTime.ramlong = dmaNoWaitTime.ram << 1;
5014: dmaNoWaitTime.romlong = dmaNoWaitTime.rom << 1;
5015:
5016:
5017: busWaitCyclesRequest = Settings.sgsGetOnOff ("waitcycles");
5018: busWaitCycles = busWaitCyclesRequest;
5019: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
5020:
5021: }
5022:
5023: public static void mdlTini () {
5024:
5025: Settings.sgsPutString ("model",
5026: specifiedAccelerator == ACCELERATOR_HYBRID ? "Hybrid" :
5027: specifiedAccelerator == ACCELERATOR_XELLENT30 ? "Xellent30" :
5028: specifiedAccelerator == ACCELERATOR_060TURBO ? "060turbo" :
5029: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? "060turboPRO" :
5030: specifiedModel.getSynonym () != null ? specifiedModel.getSynonym () :
5031: specifiedModel.getType ());
5032: Settings.sgsPutOnOff ("mpu010", mpu010);
5033:
5034:
5035: int defaultFirstMPU = (specifiedAccelerator == ACCELERATOR_060TURBO ||
5036: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
5037: specifiedModel.getMPU ());
5038: int defaultSecondMPU = Model.MPU_MC68EC030;
5039: Settings.sgsPutString ("mpu",
5040: (specifiedFirstMPU == defaultFirstMPU ? "" :
5041: Model.mpuNameOf (specifiedFirstMPU)) +
5042: (specifiedSecondMPU == defaultSecondMPU ? "" :
5043: "," + Model.mpuNameOf (specifiedSecondMPU)));
5044:
5045:
5046:
5047:
5048: double defaultFirstClock = (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
5049: specifiedAccelerator == ACCELERATOR_060TURBO ||
5050: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
5051: specifiedModel.getClock ());
5052: double defaultSecondClock = defaultFirstClock * 2.0;
5053: Settings.sgsPutString ("clock",
5054: (specifiedFirstClock == defaultFirstClock ? "" :
5055: specifiedFirstClock == 50.0 / 3.0 ? "16.7" :
5056: specifiedFirstClock == 100.0 / 3.0 ? "33.3" :
5057: specifiedFirstClock == 200.0 / 3.0 ? "66.7" :
5058: String.valueOf ((int) specifiedFirstClock)) +
5059: (specifiedSecondClock == defaultSecondClock ? "" :
5060: "," + (specifiedSecondClock == 50.0 / 3.0 ? "16.7" :
5061: specifiedSecondClock == 100.0 / 3.0 ? "33.3" :
5062: specifiedSecondClock == 200.0 / 3.0 ? "66.7" :
5063: String.valueOf ((int) specifiedSecondClock))));
5064:
5065: Settings.sgsPutInt ("copro0", specifiedCopro0);
5066: Settings.sgsPutInt ("copro1", specifiedCopro1);
5067: Settings.sgsPutInt ("copro2", specifiedCopro2);
5068: Settings.sgsPutInt ("onchipfpu", specifiedOnchipFPU);
5069:
5070: Settings.sgsPutOnOff ("util",
5071: mpuUtilOn);
5072: Settings.sgsPutString ("ratio",
5073: String.valueOf (mpuUtilRatio));
5074:
5075: Settings.sgsPutString ("mhz",
5076: String.valueOf (mpuArbFreqMHz));
5077:
5078: Settings.sgsPutOnOff ("waitcycles", busWaitCyclesRequest);
5079: }
5080:
5081: public static void mdlMakeMenu () {
5082:
5083:
5084: ActionListener listener = new ActionListener () {
5085: @Override public void actionPerformed (ActionEvent ae) {
5086: Object source = ae.getSource ();
5087: switch (ae.getActionCommand ()) {
5088: case "X68000 (10MHz)":
5089: mdlRequestModel (Model.SHODAI, 0);
5090: mpuReset (-1, -1);
5091: break;
5092: case "X68000 ACE (10MHz)":
5093: mdlRequestModel (Model.ACE, 0);
5094: mpuReset (-1, -1);
5095: break;
5096: case "X68000 EXPERT (10MHz)":
5097: mdlRequestModel (Model.EXPERT, 0);
5098: mpuReset (-1, -1);
5099: break;
5100: case "X68000 PRO (10MHz)":
5101: mdlRequestModel (Model.PRO, 0);
5102: mpuReset (-1, -1);
5103: break;
5104: case "X68000 SUPER (10MHz)":
5105: mdlRequestModel (Model.SUPER, 0);
5106: mpuReset (-1, -1);
5107: break;
5108: case "X68000 XVI (16.7MHz)":
5109: mdlRequestModel (Model.XVI, 0);
5110: mpuReset (-1, -1);
5111: break;
5112: case "X68000 Compact (16.7MHz)":
5113: mdlRequestModel (Model.COMPACT, 0);
5114: mpuReset (-1, -1);
5115: break;
5116:
5117: case "X68030 (25MHz)":
5118: mdlRequestModel (Model.X68030, 0);
5119: mpuReset (-1, -1);
5120: break;
5121: case "X68030 Compact (25MHz)":
5122: mdlRequestModel (Model.X68030COMPACT, 0);
5123: mpuReset (-1, -1);
5124: break;
5125:
5126: case "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)":
5127: mdlRequestModel (Model.COMPACT, ACCELERATOR_HYBRID);
5128: mpuReset (-1, -1);
5129: break;
5130: case "Xellent30 (33.3MHz)":
5131: mdlRequestModel (Model.XVI, ACCELERATOR_XELLENT30);
5132: mpuReset (-1, -1);
5133: break;
5134: case "060turbo (" + MHZ_060TURBO_STRING + "MHz)":
5135: mdlRequestModel (Model.X68030, ACCELERATOR_060TURBO);
5136: mpuReset (-1, -1);
5137: break;
5138: case "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)":
5139: mdlRequestModel (Model.PRO, ACCELERATOR_060TURBOPRO);
5140: mpuReset (-1, -1);
5141: break;
5142:
5143: case "MC68010":
5144: mpu010 = ((JCheckBoxMenuItem) source).isSelected ();
5145: break;
5146:
5147: }
5148: }
5149: };
5150:
5151:
5152: ButtonGroup modelGroup = new ButtonGroup ();
5153: mdlMenu = Multilingual.mlnText (
5154: ComponentFactory.createMenu (
5155: "Change the model and reset",
5156: mdlShodaiMenuItem = ComponentFactory.createRadioButtonMenuItem (
5157: modelGroup,
5158: specifiedModel == Model.SHODAI,
5159: "X68000 (10MHz)",
5160: listener),
5161: mdlACEMenuItem = ComponentFactory.createRadioButtonMenuItem (
5162: modelGroup,
5163: specifiedModel == Model.ACE,
5164: "X68000 ACE (10MHz)",
5165: listener),
5166: mdlEXPERTMenuItem = ComponentFactory.createRadioButtonMenuItem (
5167: modelGroup,
5168: specifiedModel == Model.EXPERT,
5169: "X68000 EXPERT (10MHz)",
5170: listener),
5171: mdlPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
5172: modelGroup,
5173: specifiedModel == Model.PRO && specifiedAccelerator == 0,
5174: "X68000 PRO (10MHz)",
5175: listener),
5176: mdlSUPERMenuItem = ComponentFactory.createRadioButtonMenuItem (
5177: modelGroup,
5178: specifiedModel == Model.SUPER,
5179: "X68000 SUPER (10MHz)",
5180: listener),
5181: mdlXVIMenuItem = ComponentFactory.createRadioButtonMenuItem (
5182: modelGroup,
5183: specifiedModel == Model.XVI && specifiedAccelerator == 0,
5184: "X68000 XVI (16.7MHz)",
5185: listener),
5186: mdlCompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
5187: modelGroup,
5188: specifiedModel == Model.COMPACT && specifiedAccelerator == 0,
5189: "X68000 Compact (16.7MHz)",
5190: listener),
5191:
5192: ComponentFactory.createHorizontalSeparator (),
5193:
5194: mdlX68030MenuItem = ComponentFactory.createRadioButtonMenuItem (
5195: modelGroup,
5196: specifiedModel == Model.X68030 && specifiedAccelerator == 0,
5197: "X68030 (25MHz)",
5198: listener),
5199: mdl030CompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
5200: modelGroup,
5201: specifiedModel == Model.X68030COMPACT,
5202: "X68030 Compact (25MHz)",
5203: listener),
5204:
5205: ComponentFactory.createHorizontalSeparator (),
5206:
5207: mdlHybridMenuItem = ComponentFactory.createRadioButtonMenuItem (
5208: modelGroup,
5209: specifiedModel == Model.COMPACT && specifiedAccelerator == ACCELERATOR_HYBRID,
5210: "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)",
5211: listener),
5212: mdlXellent30MenuItem = ComponentFactory.createRadioButtonMenuItem (
5213: modelGroup,
5214: specifiedModel == Model.XVI && specifiedAccelerator == ACCELERATOR_XELLENT30,
5215: "Xellent30 (33.3MHz)",
5216: listener),
5217: mdl060turboMenuItem = ComponentFactory.createRadioButtonMenuItem (
5218: modelGroup,
5219: specifiedModel == Model.X68030 && specifiedAccelerator == ACCELERATOR_060TURBO,
5220: "060turbo (" + MHZ_060TURBO_STRING + "MHz)",
5221: listener),
5222: mdl060turboPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
5223: modelGroup,
5224: specifiedModel == Model.PRO && specifiedAccelerator == ACCELERATOR_060TURBOPRO,
5225: "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)",
5226: listener),
5227:
5228: ComponentFactory.createHorizontalSeparator (),
5229:
5230: mdlMC68010MenuItem = ComponentFactory.createCheckBoxMenuItem (
5231: mpu010,
5232: "MC68010",
5233: listener)
5234: ),
5235: "ja", "機種を変更してリセット");
5236:
5237:
5238: ActionListener copro0Listener = new ActionListener () {
5239: @Override public void actionPerformed (ActionEvent ae) {
5240: String command = ae.getActionCommand ();
5241: switch (command) {
5242: case "Not installed":
5243: specifiedCopro0 = (8 & specifiedCopro0) | 0;
5244: break;
5245: case "MC68881":
5246: specifiedCopro0 = (8 & specifiedCopro0) | 1;
5247: break;
5248: case "MC68882":
5249: specifiedCopro0 = (8 & specifiedCopro0) | 2;
5250: break;
5251: case "Full specification":
5252: specifiedCopro0 = (8 & specifiedCopro0) | 7;
5253: break;
5254: case "Extended precision (19 digits)":
5255: specifiedCopro0 = 0 | (7 & specifiedCopro0);
5256: break;
5257: case "Triple precision (24 digits)":
5258: specifiedCopro0 = 8 | (7 & specifiedCopro0);
5259: break;
5260: default:
5261: System.out.println ("unknown action command " + command);
5262: }
5263: }
5264: };
5265:
5266: ActionListener copro1Listener = new ActionListener () {
5267: @Override public void actionPerformed (ActionEvent ae) {
5268: String command = ae.getActionCommand ();
5269: switch (command) {
5270: case "Not installed":
5271: specifiedCopro1 = (8 & specifiedCopro1) | 0;
5272: break;
5273: case "MC68881":
5274: specifiedCopro1 = (8 & specifiedCopro1) | 1;
5275: break;
5276: case "MC68882":
5277: specifiedCopro1 = (8 & specifiedCopro1) | 2;
5278: break;
5279: case "Full specification":
5280: specifiedCopro1 = (8 & specifiedCopro1) | 7;
5281: break;
5282: case "Extended precision (19 digits)":
5283: specifiedCopro1 = 0 | (7 & specifiedCopro1);
5284: break;
5285: case "Triple precision (24 digits)":
5286: specifiedCopro1 = 8 | (7 & specifiedCopro1);
5287: break;
5288: default:
5289: System.out.println ("unknown action command " + command);
5290: }
5291: }
5292: };
5293:
5294: ActionListener copro2Listener = new ActionListener () {
5295: @Override public void actionPerformed (ActionEvent ae) {
5296: String command = ae.getActionCommand ();
5297: switch (command) {
5298: case "Not installed":
5299: specifiedCopro2 = (8 & specifiedCopro2) | 0;
5300: break;
5301: case "MC68881":
5302: specifiedCopro2 = (8 & specifiedCopro2) | 1;
5303: break;
5304: case "MC68882":
5305: specifiedCopro2 = (8 & specifiedCopro2) | 2;
5306: break;
5307: case "Full specification":
5308: specifiedCopro2 = (8 & specifiedCopro2) | 7;
5309: break;
5310: case "Extended precision (19 digits)":
5311: specifiedCopro2 = 0 | (7 & specifiedCopro2);
5312: break;
5313: case "Triple precision (24 digits)":
5314: specifiedCopro2 = 8 | (7 & specifiedCopro2);
5315: break;
5316: default:
5317: System.out.println ("unknown action command " + command);
5318: }
5319: }
5320: };
5321:
5322: ActionListener onchipFPUListener = new ActionListener () {
5323: @Override public void actionPerformed (ActionEvent ae) {
5324: String command = ae.getActionCommand ();
5325: switch (command) {
5326: case "Not installed":
5327: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 0;
5328: break;
5329: case "MC68060":
5330: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 6;
5331: break;
5332: case "Full specification":
5333: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
5334: break;
5335: case "Extended precision (19 digits)":
5336: specifiedOnchipFPU = 0 | (7 & specifiedOnchipFPU);
5337: break;
5338: case "Triple precision (24 digits)":
5339: specifiedOnchipFPU = 8 | (7 & specifiedOnchipFPU);
5340: break;
5341: default:
5342: System.out.println ("unknown action command " + command);
5343: }
5344: }
5345: };
5346:
5347: ButtonGroup copro00Group = new ButtonGroup ();
5348: ButtonGroup copro01Group = new ButtonGroup ();
5349: ButtonGroup copro10Group = new ButtonGroup ();
5350: ButtonGroup copro11Group = new ButtonGroup ();
5351: ButtonGroup copro20Group = new ButtonGroup ();
5352: ButtonGroup copro21Group = new ButtonGroup ();
5353: ButtonGroup onchipFPU0Group = new ButtonGroup ();
5354: ButtonGroup onchipFPU1Group = new ButtonGroup ();
5355:
5356: coproFPUMenu = Multilingual.mlnText (
5357: ComponentFactory.createMenu (
5358: "Coprocessor and on-chip FPU",
5359:
5360: Multilingual.mlnText (
5361: ComponentFactory.createMenu (
5362: "Motherboard coprocessor",
5363: Multilingual.mlnText (
5364: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 0, "Not installed", copro0Listener),
5365: "ja", "なし"),
5366: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 1, "MC68881", copro0Listener),
5367: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 2, "MC68882", copro0Listener),
5368: Multilingual.mlnText (
5369: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 7, "Full specification", copro0Listener),
5370: "ja", "フルスペック"),
5371: ComponentFactory.createHorizontalSeparator (),
5372: Multilingual.mlnText (
5373: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) == 0, "Extended precision (19 digits)", copro0Listener),
5374: "ja", "拡張精度 (19 桁)"),
5375: Multilingual.mlnText (
5376: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) != 0, "Triple precision (24 digits)", copro0Listener),
5377: "ja", "三倍精度 (24 桁)")),
5378: "ja", "マザーボードコプロセッサ"),
5379:
5380: Multilingual.mlnText (
5381: ComponentFactory.createMenu (
5382: "Extension coprocessor #1",
5383: Multilingual.mlnText (
5384: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 0, "Not installed", copro1Listener),
5385: "ja", "なし"),
5386: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 1, "MC68881", copro1Listener),
5387: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 2, "MC68882", copro1Listener),
5388: Multilingual.mlnText (
5389: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 7, "Full specification", copro1Listener),
5390: "ja", "フルスペック"),
5391: ComponentFactory.createHorizontalSeparator (),
5392: Multilingual.mlnText (
5393: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) == 0, "Extended precision (19 digits)", copro1Listener),
5394: "ja", "拡張精度 (19 桁)"),
5395: Multilingual.mlnText (
5396: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) != 0, "Triple precision (24 digits)", copro1Listener),
5397: "ja", "三倍精度 (24 桁)")),
5398: "ja", "拡張コプロセッサ #1"),
5399:
5400: Multilingual.mlnText (
5401: ComponentFactory.createMenu (
5402: "Extension coprocessor #2",
5403: Multilingual.mlnText (
5404: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 0, "Not installed", copro2Listener),
5405: "ja", "なし"),
5406: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 1, "MC68881", copro2Listener),
5407: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 2, "MC68882", copro2Listener),
5408: Multilingual.mlnText (
5409: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 7, "Full specification", copro2Listener),
5410: "ja", "フルスペック"),
5411: ComponentFactory.createHorizontalSeparator (),
5412: Multilingual.mlnText (
5413: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) == 0, "Extended precision (19 digits)", copro2Listener),
5414: "ja", "拡張精度 (19 桁)"),
5415: Multilingual.mlnText (
5416: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) != 0, "Triple precision (24 digits)", copro2Listener),
5417: "ja", "三倍精度 (24 桁)")),
5418: "ja", "拡張コプロセッサ #2"),
5419:
5420: Multilingual.mlnText (
5421: ComponentFactory.createMenu (
5422: "On-chip FPU",
5423: Multilingual.mlnText (
5424: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 0, "Not installed", onchipFPUListener),
5425: "ja", "なし"),
5426: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 6, "MC68060", onchipFPUListener),
5427: Multilingual.mlnText (
5428: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 7, "Full specification", onchipFPUListener),
5429: "ja", "フルスペック"),
5430: ComponentFactory.createHorizontalSeparator (),
5431: Multilingual.mlnText (
5432: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) == 0, "Extended precision (19 digits)", onchipFPUListener),
5433: "ja", "拡張精度 (19 桁)"),
5434: Multilingual.mlnText (
5435: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) != 0, "Triple precision (24 digits)", onchipFPUListener),
5436: "ja", "三倍精度 (24 桁)")),
5437: "ja", "オンチップ FPU")),
5438: "ja", "コプロセッサとオンチップ FPU");
5439:
5440: }
5441:
5442: public static void mdlRequestModel (Model model, int accelerator) {
5443: specifiedModel = model;
5444: specifiedAccelerator = accelerator;
5445:
5446: specifiedIsSecond = false;
5447: specifiedFirstMPU = specifiedModel.getMPU ();
5448: specifiedSecondMPU = Model.MPU_MC68EC030;
5449: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
5450: specifiedFirstClock = specifiedModel.getClock ();
5451: specifiedSecondClock = specifiedFirstClock * 2.0;
5452: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5453:
5454: switch (accelerator) {
5455: case ACCELERATOR_HYBRID:
5456: specifiedFirstClock = MHZ_HYBRID_VALUE;
5457: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5458: break;
5459: case ACCELERATOR_XELLENT30:
5460: break;
5461: case ACCELERATOR_060TURBO:
5462: case ACCELERATOR_060TURBOPRO:
5463: specifiedFirstMPU = Model.MPU_MC68060;
5464: specifiedFirstClock = MHZ_060TURBO_VALUE;
5465: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5466: }
5467:
5468: mpuUtilOn = false;
5469: mpuArbFreqOn = false;
5470: mpuSetCurrentClock (specifiedClock);
5471:
5472: if (accelerator == ACCELERATOR_HYBRID) {
5473: mdlHybridMenuItem.setSelected (true);
5474: } else if (accelerator == ACCELERATOR_XELLENT30) {
5475: mdlXellent30MenuItem.setSelected (true);
5476: } else if (accelerator == ACCELERATOR_060TURBO) {
5477: mdl060turboMenuItem.setSelected (true);
5478: } else if (accelerator == ACCELERATOR_060TURBOPRO) {
5479: mdl060turboPROMenuItem.setSelected (true);
5480: } else if (specifiedModel == Model.SHODAI) {
5481: mdlShodaiMenuItem.setSelected (true);
5482: } else if (specifiedModel == Model.ACE) {
5483: mdlACEMenuItem.setSelected (true);
5484: } else if (specifiedModel == Model.EXPERT) {
5485: mdlEXPERTMenuItem.setSelected (true);
5486: } else if (specifiedModel == Model.PRO) {
5487: mdlPROMenuItem.setSelected (true);
5488: } else if (specifiedModel == Model.SUPER) {
5489: mdlSUPERMenuItem.setSelected (true);
5490: } else if (specifiedModel == Model.XVI) {
5491: mdlXVIMenuItem.setSelected (true);
5492: } else if (specifiedModel == Model.COMPACT) {
5493: mdlCompactMenuItem.setSelected (true);
5494: } else if (specifiedModel == Model.X68030) {
5495: mdlX68030MenuItem.setSelected (true);
5496: } else if (specifiedModel == Model.X68030COMPACT) {
5497: mdl030CompactMenuItem.setSelected (true);
5498: }
5499:
5500:
5501: HDC.hdcSASIMenuItem.setSelected (!currentModel.isSCSI ());
5502: SPC.spcSCSIINMenuItem.setSelected (currentModel.isSCSI ());
5503: }
5504:
5505:
5506:
5507:
5508:
5509:
5510:
5511: public static final boolean MPU_INLINE_EXCEPTION = true;
5512: public static final boolean MPU_COMPOUND_POSTINCREMENT = false;
5513:
5514: public static final boolean MPU_SWITCH_MISC_OPCODE = false;
5515: public static final boolean MPU_SWITCH_BCC_CONDITION = false;
5516: public static final boolean MPU_SWITCH_BCC_OFFSET = false;
5517: public static final boolean MPU_SWITCH_SCC_CONDITION = true;
5518:
5519: public static final boolean MPU_OMIT_EXTRA_READ = false;
5520: public static final boolean MPU_OMIT_OFFSET_READ = false;
5521:
5522:
5523:
5524:
5525: public static final long FAR_FUTURE = 0x7fffffffffffffffL;
5526:
5527:
5528:
5529:
5530:
5531:
5532:
5533:
5534: public static final int REG_SR_T1 = 0b10000000_00000000;
5535: public static final int REG_SR_T0 = 0b01000000_00000000;
5536:
5537:
5538:
5539:
5540:
5541:
5542: public static final int REG_SR_S = 0b00100000_00000000;
5543: public static final int REG_SR_M = 0b00010000_00000000;
5544:
5545: public static final int REG_SR_I = 0b00000111_00000000;
5546:
5547:
5548: public static final int REG_CCR_X = 0b00000000_00010000;
5549: public static final int REG_CCR_N = 0b00000000_00001000;
5550: public static final int REG_CCR_Z = 0b00000000_00000100;
5551: public static final int REG_CCR_V = 0b00000000_00000010;
5552: public static final int REG_CCR_C = 0b00000000_00000001;
5553: public static final int REG_CCR_MASK = REG_CCR_X | REG_CCR_N | REG_CCR_Z | REG_CCR_V | REG_CCR_C;
5554:
5555: public static char[] REG_CCRXMAP = "00000000000000001111111111111111".toCharArray ();
5556: public static char[] REG_CCRNMAP = "00000000111111110000000011111111".toCharArray ();
5557: public static char[] REG_CCRZMAP = "00001111000011110000111100001111".toCharArray ();
5558: public static char[] REG_CCRVMAP = "00110011001100110011001100110011".toCharArray ();
5559: public static char[] REG_CCRCMAP = "01010101010101010101010101010101".toCharArray ();
5560:
5561:
5562:
5563: public static final int MPU_IOI_INTERRUPT_LEVEL = 1;
5564: public static final int MPU_EB2_INTERRUPT_LEVEL = 2;
5565: public static final int MPU_DMA_INTERRUPT_LEVEL = 3;
5566: public static final int MPU_SCC_INTERRUPT_LEVEL = 5;
5567: public static final int MPU_MFP_INTERRUPT_LEVEL = 6;
5568: public static final int MPU_SYS_INTERRUPT_LEVEL = 7;
5569: public static final int MPU_IOI_INTERRUPT_MASK = 0x80 >> MPU_IOI_INTERRUPT_LEVEL;
5570: public static final int MPU_EB2_INTERRUPT_MASK = 0x80 >> MPU_EB2_INTERRUPT_LEVEL;
5571: public static final int MPU_DMA_INTERRUPT_MASK = 0x80 >> MPU_DMA_INTERRUPT_LEVEL;
5572: public static final int MPU_SCC_INTERRUPT_MASK = 0x80 >> MPU_SCC_INTERRUPT_LEVEL;
5573: public static final int MPU_MFP_INTERRUPT_MASK = 0x80 >> MPU_MFP_INTERRUPT_LEVEL;
5574: public static final int MPU_SYS_INTERRUPT_MASK = 0x80 >> MPU_SYS_INTERRUPT_LEVEL;
5575:
5576: public static final boolean MPU_INTERRUPT_SWITCH = true;
5577:
5578:
5579: public static final boolean T = true;
5580: public static final boolean F = false;
5581:
5582: public static final int CCCC_T = 0b0000;
5583: public static final int CCCC_F = 0b0001;
5584: public static final int CCCC_HI = 0b0010;
5585: public static final int CCCC_LS = 0b0011;
5586: public static final int CCCC_CC = 0b0100;
5587: public static final int CCCC_CS = 0b0101;
5588: public static final int CCCC_NE = 0b0110;
5589: public static final int CCCC_EQ = 0b0111;
5590: public static final int CCCC_VC = 0b1000;
5591: public static final int CCCC_VS = 0b1001;
5592: public static final int CCCC_PL = 0b1010;
5593: public static final int CCCC_MI = 0b1011;
5594: public static final int CCCC_GE = 0b1100;
5595: public static final int CCCC_LT = 0b1101;
5596: public static final int CCCC_GT = 0b1110;
5597: public static final int CCCC_LE = 0b1111;
5598:
5599:
5600:
5601:
5602:
5603:
5604: public static final boolean[] BCCMAP = {
5605: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
5606: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
5607: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
5608: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
5609: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
5610: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
5611: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
5612: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
5613: T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,
5614: F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,
5615: T,T,T,T,T,T,T,T,F,F,F,F,F,F,F,F,T,T,T,T,T,T,T,T,F,F,F,F,F,F,F,F,
5616: F,F,F,F,F,F,F,F,T,T,T,T,T,T,T,T,F,F,F,F,F,F,F,F,T,T,T,T,T,T,T,T,
5617: T,T,F,F,T,T,F,F,F,F,T,T,F,F,T,T,T,T,F,F,T,T,F,F,F,F,T,T,F,F,T,T,
5618: F,F,T,T,F,F,T,T,T,T,F,F,T,T,F,F,F,F,T,T,F,F,T,T,T,T,F,F,T,T,F,F,
5619: T,T,F,F,F,F,F,F,F,F,T,T,F,F,F,F,T,T,F,F,F,F,F,F,F,F,T,T,F,F,F,F,
5620: F,F,T,T,T,T,T,T,T,T,F,F,T,T,T,T,F,F,T,T,T,T,T,T,T,T,F,F,T,T,T,T,
5621: };
5622:
5623:
5624: public static final char[] MPU_CCCMAP = (
5625: "11111111111111111111111111111111" +
5626: "00000000000000000000000000000000" +
5627: "10100000101000001010000010100000" +
5628: "01011111010111110101111101011111" +
5629: "10101010101010101010101010101010" +
5630: "01010101010101010101010101010101" +
5631: "11110000111100001111000011110000" +
5632: "00001111000011110000111100001111" +
5633: "11001100110011001100110011001100" +
5634: "00110011001100110011001100110011" +
5635: "11111111000000001111111100000000" +
5636: "00000000111111110000000011111111" +
5637: "11001100001100111100110000110011" +
5638: "00110011110011000011001111001100" +
5639: "11000000001100001100000000110000" +
5640: "00111111110011110011111111001111").toCharArray ();
5641:
5642:
5643:
5644: public static final int MPU_CC_T = 0b11111111111111111111111111111111;
5645: public static final int MPU_CC_F = 0b00000000000000000000000000000000;
5646: public static final int MPU_CC_HI = 0b10100000101000001010000010100000;
5647: public static final int MPU_CC_LS = 0b01011111010111110101111101011111;
5648: public static final int MPU_CC_HS = 0b10101010101010101010101010101010;
5649: public static final int MPU_CC_LO = 0b01010101010101010101010101010101;
5650: public static final int MPU_CC_NE = 0b11110000111100001111000011110000;
5651: public static final int MPU_CC_EQ = 0b00001111000011110000111100001111;
5652: public static final int MPU_CC_VC = 0b11001100110011001100110011001100;
5653: public static final int MPU_CC_VS = 0b00110011001100110011001100110011;
5654: public static final int MPU_CC_PL = 0b11111111000000001111111100000000;
5655: public static final int MPU_CC_MI = 0b00000000111111110000000011111111;
5656: public static final int MPU_CC_GE = 0b11001100001100111100110000110011;
5657: public static final int MPU_CC_LT = 0b00110011110011000011001111001100;
5658: public static final int MPU_CC_GT = 0b11000000001100001100000000110000;
5659: public static final int MPU_CC_LE = 0b00111111110011110011111111001111;
5660:
5661:
5662:
5663:
5664:
5665:
5666:
5667:
5668:
5669:
5670:
5671:
5672:
5673:
5674:
5675:
5676:
5677:
5678:
5679:
5680:
5681:
5682:
5683:
5684:
5685:
5686:
5687:
5688:
5689:
5690:
5691:
5692:
5693:
5694:
5695:
5696:
5697:
5698:
5699:
5700:
5701:
5702:
5703:
5704:
5705:
5706:
5707:
5708:
5709: public static final byte[] MPU_TSTB_TABLE = "\4\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\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\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\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\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b".getBytes (XEiJ.ISO_8859_1);
5710:
5711:
5712:
5713: public static final int[] MPU_BITREV_TABLE_0 = new int[2048];
5714: public static final int[] MPU_BITREV_TABLE_1 = new int[2048];
5715: public static final int[] MPU_BITREV_TABLE_2 = new int[2048];
5716: static {
5717: for (int i = 0; i < 2048; i++) {
5718: MPU_BITREV_TABLE_2[i] = (MPU_BITREV_TABLE_1[i] = (MPU_BITREV_TABLE_0[i] = Integer.reverse (i)) >>> 11) >>> 11;
5719: }
5720: }
5721:
5722:
5723:
5724: public static final int EA_DR = 0b000_000;
5725: public static final int EA_AR = 0b001_000;
5726: public static final int EA_MM = 0b010_000;
5727: public static final int EA_MP = 0b011_000;
5728: public static final int EA_MN = 0b100_000;
5729: public static final int EA_MW = 0b101_000;
5730: public static final int EA_MX = 0b110_000;
5731: public static final int EA_ZW = 0b111_000;
5732: public static final int EA_ZL = 0b111_001;
5733: public static final int EA_PW = 0b111_010;
5734: public static final int EA_PX = 0b111_011;
5735: public static final int EA_IM = 0b111_100;
5736: public static final int MMM_DR = EA_DR >> 3;
5737: public static final int MMM_AR = EA_AR >> 3;
5738: public static final int MMM_MM = EA_MM >> 3;
5739: public static final int MMM_MP = EA_MP >> 3;
5740: public static final int MMM_MN = EA_MN >> 3;
5741: public static final int MMM_MW = EA_MW >> 3;
5742: public static final int MMM_MX = EA_MX >> 3;
5743: public static final long EAM_DR = 0xff00000000000000L >>> EA_DR;
5744: public static final long EAM_AR = 0xff00000000000000L >>> EA_AR;
5745: public static final long EAM_MM = 0xff00000000000000L >>> EA_MM;
5746: public static final long EAM_MP = 0xff00000000000000L >>> EA_MP;
5747: public static final long EAM_MN = 0xff00000000000000L >>> EA_MN;
5748: public static final long EAM_MW = 0xff00000000000000L >>> EA_MW;
5749: public static final long EAM_MX = 0xff00000000000000L >>> EA_MX;
5750: public static final long EAM_ZW = 0x8000000000000000L >>> EA_ZW;
5751: public static final long EAM_ZL = 0x8000000000000000L >>> EA_ZL;
5752: public static final long EAM_PW = 0x8000000000000000L >>> EA_PW;
5753: public static final long EAM_PX = 0x8000000000000000L >>> EA_PX;
5754: public static final long EAM_IM = 0x8000000000000000L >>> EA_IM;
5755: public static final long EAM_ALL = EAM_DR|EAM_AR|EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX|EAM_IM;
5756: public static final long EAM_ALT = EAM_DR|EAM_AR|EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5757: public static final long EAM_DAT = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX|EAM_IM;
5758: public static final long EAM_DME = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5759: public static final long EAM_DLT = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5760: public static final long EAM_DCN = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5761: public static final long EAM_DCL = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5762: public static final long EAM_ANY = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX|EAM_IM;
5763: public static final long EAM_MEM = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5764: public static final long EAM_MLT = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5765: public static final long EAM_RDL = EAM_MM|EAM_MP |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5766: public static final long EAM_WTL = EAM_MM |EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5767: public static final long EAM_CNT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5768: public static final long EAM_CLT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5769:
5770:
5771:
5772:
5773:
5774:
5775:
5776:
5777:
5778:
5779:
5780: public static final int[] regRn = new int[16 + 1];
5781:
5782:
5783: public static int regPC;
5784: public static int regPC0;
5785:
5786:
5787: public static int regOC;
5788:
5789:
5790: public static int regSRT1;
5791: public static int regSRT0;
5792: public static int mpuTraceFlag;
5793: public static int regSRS;
5794: public static int regSRM;
5795: public static int regSRI;
5796:
5797:
5798: public static int regCCR;
5799:
5800:
5801:
5802:
5803:
5804:
5805:
5806:
5807:
5808:
5809:
5810:
5811:
5812:
5813:
5814:
5815:
5816:
5817:
5818:
5819: public static int mpuIMR;
5820:
5821:
5822:
5823:
5824:
5825:
5826: public static int mpuIRR;
5827: public static int mpuDIRR;
5828:
5829:
5830:
5831:
5832:
5833:
5834:
5835:
5836: public static int mpuISR;
5837:
5838:
5839: public static int mpuSFC;
5840: public static int mpuDFC;
5841: public static int mpuCACR;
5842:
5843:
5844:
5845:
5846:
5847: public static int mpuBUSCR;
5848: public static int mpuUSP;
5849: public static int mpuVBR;
5850: public static int mpuCAAR;
5851: public static int mpuMSP;
5852: public static int mpuISP;
5853:
5854:
5855:
5856: public static int mpuPCR;
5857:
5858:
5859:
5860: public static final int MPU_060_REV = 7;
5861:
5862:
5863:
5864: public static long mpuClockTime;
5865: public static long mpuClockLimit;
5866: public static double mpuClockMHz;
5867: public static double mpuCurrentMHz;
5868: public static int mpuCycleCount;
5869: public static long mpuCycleUnit;
5870: public static long mpuModifiedUnit;
5871: public static long dmaCycleUnit;
5872:
5873:
5874:
5875: public static TimerTask mpuTask;
5876:
5877:
5878: public static int mpuBootDevice;
5879: public static int mpuROMBootHandle;
5880: public static int mpuSavedBootDevice;
5881: public static int mpuSavedROMBootHandle;
5882:
5883:
5884: public static boolean mpuIgnoreAddressError;
5885:
5886:
5887: public static int mpuROMWaitCycles;
5888: public static int mpuRAMWaitCycles;
5889: public static boolean mpuCacheOn;
5890: public static final class WaitTime {
5891: public long ram;
5892: public long gvram;
5893: public long tvram;
5894: public long crtc;
5895: public long palet;
5896: public long vicon;
5897: public long dmac;
5898: public long mfp;
5899: public long rtc;
5900: public long prnport;
5901: public long sysport;
5902: public long opm;
5903: public long adpcm;
5904: public long fdc;
5905: public long fdd;
5906: public long hdc;
5907: public long scc;
5908: public long ppi;
5909: public long ioi;
5910: public long sprc;
5911: public long sram;
5912: public long rom;
5913: public long ramlong;
5914: public long romlong;
5915: public boolean isDma;
5916: public WaitTime (boolean isDma) {
5917: this.isDma = isDma;
5918: }
5919: }
5920: public static final WaitTime mpuNoWaitTime = new WaitTime (false);
5921: public static final WaitTime dmaNoWaitTime = new WaitTime (true);
5922: public static final WaitTime mpuWaitTime = new WaitTime (false);
5923: public static final WaitTime dmaWaitTime = new WaitTime (true);
5924: public static boolean busWaitCyclesRequest;
5925: public static boolean busWaitCycles;
5926: public static WaitTime busWaitTime;
5927:
5928:
5929: public static boolean mpuArbFreqOn;
5930: public static int mpuArbFreqMHz;
5931: public static SpinnerNumberModel mpuArbFreqModel;
5932: public static JSpinner mpuArbFreqSpinner;
5933: public static JRadioButtonMenuItem mpuArbFreqRadioButtonMenuItem;
5934:
5935:
5936: public static boolean mpuUtilOn;
5937: public static int mpuUtilRatio;
5938: public static SpinnerNumberModel mpuUtilModel;
5939: public static JSpinner mpuUtilSpinner;
5940: public static JRadioButtonMenuItem mpuUtilRadioButtonMenuItem;
5941:
5942:
5943: public static final int MPU_ADJUSTMENT_INTERVAL = 100;
5944: public static int mpuAdjustmentCounter;
5945: public static long mpuTotalNano;
5946: public static long mpuLastNano;
5947: public static double mpuCoreNano1;
5948: public static double mpuCoreNano2;
5949:
5950:
5951: public static JMenu mpuMenu;
5952: public static JMenuItem mpuResetMenuItem;
5953: public static JMenuItem mpuOpt1ResetMenuItem;
5954: public static JRadioButtonMenuItem mpuClock10MenuItem;
5955: public static JRadioButtonMenuItem mpuClock16MenuItem;
5956: public static JRadioButtonMenuItem mpuClock25MenuItem;
5957: public static JRadioButtonMenuItem mpuClock33MenuItem;
5958: public static JRadioButtonMenuItem mpuClock50MenuItem;
5959: public static JRadioButtonMenuItem mpuClock66MenuItem;
5960: public static JRadioButtonMenuItem mpuClock75MenuItem;
5961: public static JRadioButtonMenuItem mpuClock100MenuItem;
5962:
5963:
5964: public static ActionListener mpuDebugActionListener;
5965: public static ArrayList<AbstractButton> mpuButtonsRunning;
5966: public static ArrayList<AbstractButton> mpuButtonsStopped;
5967: public static ArrayList<JCheckBox> mpuOriIllegalCheckBoxList;
5968: public static ArrayList<JCheckBox> mpuStopOnErrorCheckBoxList;
5969: public static ArrayList<JCheckBox> mpuStopAtStartCheckBoxList;
5970:
5971: public static int mpuAdvanceCount;
5972: public static int mpuStepCount;
5973: public static boolean mpuContinue;
5974: public static int mpuUntilReturnSRS;
5975: public static int mpuUntilReturnRP;
5976: public static int mpuUntilReturnPC0;
5977: public static int mpuUntilReturnSP;
5978:
5979:
5980:
5981:
5982:
5983:
5984:
5985:
5986:
5987:
5988:
5989:
5990:
5991:
5992:
5993:
5994:
5995:
5996:
5997:
5998:
5999:
6000:
6001:
6002:
6003:
6004:
6005:
6006:
6007:
6008:
6009:
6010:
6011:
6012:
6013:
6014:
6015:
6016:
6017:
6018:
6019:
6020:
6021:
6022:
6023:
6024:
6025:
6026:
6027:
6028:
6029:
6030:
6031:
6032:
6033:
6034:
6035:
6036:
6037:
6038:
6039:
6040:
6041:
6042:
6043:
6044:
6045:
6046:
6047:
6048:
6049:
6050:
6051: public static final boolean MPU_SXMENU = false;
6052:
6053:
6054:
6055: public static void mpuInit () {
6056:
6057: mpuIgnoreAddressError = false;
6058:
6059:
6060:
6061: fpuInit ();
6062:
6063: mpuClockTime = 0L;
6064: mpuClockLimit = 0L;
6065: mpuCycleCount = 0;
6066:
6067: mpuTask = null;
6068:
6069: M68kException.m6eSignal = new M68kException ();
6070: M68kException.m6eNumber = 0;
6071: M68kException.m6eAddress = 0;
6072: M68kException.m6eDirection = MPU_WR_WRITE;
6073: M68kException.m6eSize = MPU_SS_BYTE;
6074:
6075: mpuBootDevice = -1;
6076: mpuROMBootHandle = -1;
6077: mpuSavedBootDevice = -1;
6078: mpuSavedROMBootHandle = -1;
6079:
6080:
6081:
6082:
6083:
6084:
6085:
6086:
6087:
6088:
6089:
6090:
6091:
6092:
6093:
6094: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
6095: mpuTotalNano = 0L;
6096: mpuLastNano = System.nanoTime ();
6097: mpuCoreNano1 = mpuCoreNano2 = 0.5 * 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
6098:
6099: mpuButtonsRunning = new ArrayList<AbstractButton> ();
6100: mpuButtonsStopped = new ArrayList<AbstractButton> ();
6101:
6102: mpuOriIllegalCheckBoxList = new ArrayList<JCheckBox> ();
6103: mpuStopOnErrorCheckBoxList = new ArrayList<JCheckBox> ();
6104: mpuStopAtStartCheckBoxList = new ArrayList<JCheckBox> ();
6105:
6106: mpuAdvanceCount = 0;
6107: mpuStepCount = 0;
6108: mpuContinue = false;
6109: mpuUntilReturnSRS = 0;
6110: mpuUntilReturnRP = 0;
6111: mpuUntilReturnPC0 = 0;
6112: mpuUntilReturnSP = 0;
6113:
6114:
6115: mpuDebugActionListener = new ActionListener () {
6116: @Override public void actionPerformed (ActionEvent ae) {
6117: Object source = ae.getSource ();
6118: switch (ae.getActionCommand ()) {
6119: case "Stop":
6120: if (RootPointerList.RTL_ON) {
6121: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6122: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6123: mpuStop (null);
6124: }
6125: } else {
6126: mpuStop (null);
6127: }
6128: break;
6129: case "Trace":
6130: mpuAdvance (1);
6131: break;
6132: case "Trace 10 times":
6133: mpuAdvance (10);
6134: break;
6135: case "Trace 100 times":
6136: mpuAdvance (100);
6137: break;
6138: case "Step":
6139: mpuStep (1);
6140: break;
6141: case "Step 10 times":
6142: mpuStep (10);
6143: break;
6144: case "Step 100 times":
6145: mpuStep (100);
6146: break;
6147: case "Step until return":
6148: mpuStepUntilReturn ();
6149: break;
6150: case "Run":
6151: mpuStart ();
6152: break;
6153:
6154: case "Consider ORI.B #$00,D0 as an illegal instruction" :
6155: if (DBG_ORI_BYTE_ZERO_D0) {
6156: dbgOriByteZeroD0 = ((JCheckBox) source).isSelected ();
6157: for (JCheckBox checkBox : mpuOriIllegalCheckBoxList) {
6158: if (checkBox.isSelected () != dbgOriByteZeroD0) {
6159: checkBox.setSelected (dbgOriByteZeroD0);
6160: }
6161: }
6162: }
6163: break;
6164: case "Stop on error":
6165: dbgStopOnError = ((JCheckBox) source).isSelected ();
6166: for (JCheckBox checkBox : mpuStopOnErrorCheckBoxList) {
6167: if (checkBox.isSelected () != dbgStopOnError) {
6168: checkBox.setSelected (dbgStopOnError);
6169: }
6170: }
6171: break;
6172: case "Stop at execution start position":
6173: dbgStopAtStart = ((JCheckBox) source).isSelected ();
6174: for (JCheckBox checkBox : mpuStopAtStartCheckBoxList) {
6175: if (checkBox.isSelected () != dbgStopAtStart) {
6176: checkBox.setSelected (dbgStopAtStart);
6177: }
6178: }
6179: break;
6180: }
6181: }
6182: };
6183:
6184: }
6185:
6186:
6187:
6188: public static JCheckBox mpuMakeOriIllegalCheckBox () {
6189: JCheckBox checkBox = Multilingual.mlnToolTipText (
6190: ComponentFactory.createIconCheckBox (
6191: DBG_ORI_BYTE_ZERO_D0 ? dbgOriByteZeroD0 : null,
6192: LnF.LNF_ORI_BYTE_ZERO_D0_IMAGE,
6193: LnF.LNF_ORI_BYTE_ZERO_D0_SELECTED_IMAGE,
6194: "Consider ORI.B #$00,D0 as an illegal instruction", mpuDebugActionListener),
6195: "ja", "ORI.B #$00,D0 を不当命令とみなす");
6196: mpuOriIllegalCheckBoxList.add (checkBox);
6197: return checkBox;
6198: }
6199:
6200:
6201:
6202: public static JCheckBox mpuMakeStopOnErrorCheckBox () {
6203: JCheckBox checkBox = Multilingual.mlnToolTipText (
6204: ComponentFactory.createIconCheckBox (
6205: dbgStopOnError,
6206: LnF.LNF_STOP_ON_ERROR_IMAGE,
6207: LnF.LNF_STOP_ON_ERROR_SELECTED_IMAGE,
6208: "Stop on error", mpuDebugActionListener),
6209: "ja", "エラーで停止する");
6210: mpuStopOnErrorCheckBoxList.add (checkBox);
6211: return checkBox;
6212: }
6213:
6214:
6215:
6216: public static JCheckBox mpuMakeStopAtStartCheckBox () {
6217: JCheckBox checkBox = Multilingual.mlnToolTipText (
6218: ComponentFactory.createIconCheckBox (
6219: dbgStopAtStart,
6220: LnF.LNF_STOP_AT_START_IMAGE,
6221: LnF.LNF_STOP_AT_START_SELECTED_IMAGE,
6222: "Stop at execution start position", mpuDebugActionListener),
6223: "ja", "実行開始位置で停止する");
6224: mpuStopAtStartCheckBoxList.add (checkBox);
6225: return checkBox;
6226: }
6227:
6228:
6229: public static void mpuMakeMenu () {
6230:
6231: ButtonGroup unitGroup = new ButtonGroup ();
6232: ActionListener listener = new ActionListener () {
6233: @Override public void actionPerformed (ActionEvent ae) {
6234: Object source = ae.getSource ();
6235: switch (ae.getActionCommand ()) {
6236: case "Reset":
6237: mpuReset (-1, -1);
6238: break;
6239: case "Hold down OPT.1 and reset":
6240: mpuReset (0, -1);
6241: break;
6242: case "Interrupt":
6243: sysInterrupt ();
6244: break;
6245: case "10MHz":
6246: mpuArbFreqOn = false;
6247: mpuUtilOn = false;
6248: mpuSetCurrentClock (10.0);
6249: break;
6250: case "16.7MHz":
6251: mpuArbFreqOn = false;
6252: mpuUtilOn = false;
6253: mpuSetCurrentClock (50.0 / 3.0);
6254: break;
6255: case "25MHz":
6256: mpuArbFreqOn = false;
6257: mpuUtilOn = false;
6258: mpuSetCurrentClock (25.0);
6259: break;
6260: case "33.3MHz":
6261: mpuArbFreqOn = false;
6262: mpuUtilOn = false;
6263: mpuSetCurrentClock (100.0 / 3.0);
6264: break;
6265: case "50MHz":
6266: mpuArbFreqOn = false;
6267: mpuUtilOn = false;
6268: mpuSetCurrentClock (50.0);
6269: break;
6270: case "66.7MHz":
6271: mpuArbFreqOn = false;
6272: mpuUtilOn = false;
6273: mpuSetCurrentClock (200.0 / 3.0);
6274: break;
6275: case "75MHz":
6276: mpuArbFreqOn = false;
6277: mpuUtilOn = false;
6278: mpuSetCurrentClock (75.0);
6279: break;
6280: case "100MHz":
6281: mpuArbFreqOn = false;
6282: mpuUtilOn = false;
6283: mpuSetCurrentClock (100.0);
6284: break;
6285: case "Arbitrary frequency":
6286: mpuArbFreqOn = true;
6287: mpuUtilOn = false;
6288: mpuSetCurrentClock ((double) mpuArbFreqMHz);
6289: break;
6290: case "Arbitrary load factor":
6291: mpuArbFreqOn = false;
6292: mpuUtilOn = true;
6293: break;
6294: case "FE function instruction":
6295: FEFunction.fpkOn = ((JCheckBoxMenuItem) source).isSelected ();
6296: break;
6297: case "Reject FLOATn.X":
6298: FEFunction.fpkRejectFloatOn = ((JCheckBoxMenuItem) source).isSelected ();
6299: break;
6300: case "Cut FC2 pin":
6301: busRequestCutFC2Pin = ((JCheckBoxMenuItem) source).isSelected ();
6302: break;
6303: case "Wait cycles":
6304: busWaitCyclesRequest = ((JCheckBoxMenuItem) source).isSelected ();
6305: break;
6306: case "Use IPLROM 1.6":
6307: ROM.romIPLROM16On = ((JCheckBoxMenuItem) source).isSelected ();
6308: break;
6309: case "Increase IPLROM to 256KB":
6310: ROM.romIPLROM256KOn = ((JCheckBoxMenuItem) source).isSelected ();
6311: break;
6312:
6313: case "Run / Stop":
6314: if (((JCheckBox) source).isSelected ()) {
6315: mpuStart ();
6316: } else {
6317: if (RootPointerList.RTL_ON) {
6318: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6319: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6320: mpuStop (null);
6321: }
6322: } else {
6323: mpuStop (null);
6324: }
6325: }
6326: pnlPanel.requestFocusInWindow ();
6327: break;
6328: }
6329: }
6330: };
6331: mpuMenu = ComponentFactory.createMenu (
6332: "MPU", 'M',
6333: mpuResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset", 'R', MNB_MODIFIERS, listener), "ja", "リセット"),
6334: mpuOpt1ResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Hold down OPT.1 and reset", 'O', MNB_MODIFIERS, listener), "ja", "OPT.1 を押しながらリセット"),
6335: Multilingual.mlnText (ComponentFactory.createMenuItem ("Interrupt", listener), "ja", "インタラプト"),
6336: ComponentFactory.createHorizontalSeparator (),
6337: mdlMenu,
6338: ComponentFactory.createHorizontalSeparator (),
6339: mpuClock10MenuItem = ComponentFactory.createRadioButtonMenuItem (
6340: unitGroup,
6341: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 10.0,
6342: "10MHz",
6343: listener),
6344: mpuClock16MenuItem = ComponentFactory.createRadioButtonMenuItem (
6345: unitGroup,
6346: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0 / 3.0,
6347: "16.7MHz",
6348: listener),
6349: mpuClock25MenuItem = ComponentFactory.createRadioButtonMenuItem (
6350: unitGroup,
6351: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 25.0,
6352: "25MHz",
6353: listener),
6354: mpuClock33MenuItem = ComponentFactory.createRadioButtonMenuItem (
6355: unitGroup,
6356: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0 / 3.0,
6357: "33.3MHz",
6358: listener),
6359: mpuClock50MenuItem = ComponentFactory.createRadioButtonMenuItem (
6360: unitGroup,
6361: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0,
6362: "50MHz",
6363: listener),
6364: mpuClock66MenuItem = ComponentFactory.createRadioButtonMenuItem (
6365: unitGroup,
6366: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 200.0 / 3.0,
6367: "66.7MHz",
6368: listener),
6369: mpuClock75MenuItem = ComponentFactory.createRadioButtonMenuItem (
6370: unitGroup,
6371: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 75.0,
6372: "75MHz",
6373: listener),
6374: mpuClock100MenuItem = ComponentFactory.createRadioButtonMenuItem (
6375: unitGroup,
6376: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0,
6377: "100MHz",
6378: listener),
6379: mpuArbFreqRadioButtonMenuItem = Multilingual.mlnText (
6380: ComponentFactory.createRadioButtonMenuItem (
6381: unitGroup,
6382: mpuArbFreqOn,
6383: "Arbitrary frequency",
6384: listener),
6385: "ja", "任意の周波数"),
6386: ComponentFactory.createHorizontalBox (
6387: Box.createHorizontalStrut (20),
6388: mpuArbFreqSpinner = ComponentFactory.createNumberSpinner (
6389: mpuArbFreqModel = new SpinnerNumberModel (mpuArbFreqMHz, 1, 1000, 1),
6390: 4,
6391: new ChangeListener () {
6392: @Override public void stateChanged (ChangeEvent ce) {
6393:
6394: mpuArbFreqMHz = mpuArbFreqModel.getNumber ().intValue ();
6395: if (mpuArbFreqOn) {
6396: mpuSetCurrentClock ((double) mpuArbFreqMHz);
6397: }
6398: }
6399: }
6400: ),
6401: ComponentFactory.createLabel ("MHz"),
6402: Box.createHorizontalGlue ()
6403: ),
6404: mpuUtilRadioButtonMenuItem = Multilingual.mlnText (
6405: ComponentFactory.createRadioButtonMenuItem (
6406: unitGroup,
6407: mpuUtilOn,
6408: "Arbitrary load factor",
6409: listener),
6410: "ja", "任意の負荷率"),
6411: ComponentFactory.createHorizontalBox (
6412: Box.createHorizontalStrut (20),
6413: mpuUtilSpinner = ComponentFactory.createNumberSpinner (
6414: mpuUtilModel = new SpinnerNumberModel (mpuUtilRatio, 1, 100, 1),
6415: 4,
6416: new ChangeListener () {
6417: @Override public void stateChanged (ChangeEvent ce) {
6418:
6419: mpuUtilRatio = mpuUtilModel.getNumber ().intValue ();
6420: }
6421: }
6422: ),
6423: ComponentFactory.createLabel ("%"),
6424: Box.createHorizontalGlue ()
6425: ),
6426: ComponentFactory.createHorizontalSeparator (),
6427:
6428: coproFPUMenu,
6429:
6430: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkOn, "FE function instruction", listener), "ja", "FE ファンクション命令"),
6431: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkRejectFloatOn, "Reject FLOATn.X", listener), "ja", "FLOATn.X を組み込まない"),
6432: ComponentFactory.createHorizontalSeparator (),
6433: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busRequestCutFC2Pin, "Cut FC2 pin", listener), "ja", "FC2 ピンをカットする"),
6434: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busWaitCyclesRequest, "Wait cycles", listener), "ja", "ウェイトサイクル"),
6435: ComponentFactory.createHorizontalSeparator (),
6436: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM16On, "Use IPLROM 1.6", listener), "ja", "IPLROM 1.6 を使う"),
6437: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM256KOn, "Increase IPLROM to 256KB", listener), "ja", "IPLROM を 256KB に増やす")
6438: );
6439: }
6440:
6441:
6442: public static void mpuSetCurrentClock (double clock) {
6443: specifiedClock = clock;
6444: if (currentIsSecond) {
6445: specifiedSecondClock = clock;
6446: } else {
6447: specifiedFirstClock = clock;
6448: }
6449: if (!mpuArbFreqOn && !mpuUtilOn) {
6450: if (specifiedClock == 10.0) {
6451: mpuClock10MenuItem.setSelected (true);
6452: } else if (specifiedClock == 50.0 / 3.0) {
6453: mpuClock16MenuItem.setSelected (true);
6454: } else if (specifiedClock == 25.0) {
6455: mpuClock25MenuItem.setSelected (true);
6456: } else if (specifiedClock == 100.0 / 3.0) {
6457: mpuClock33MenuItem.setSelected (true);
6458: } else if (specifiedClock == 50.0) {
6459: mpuClock50MenuItem.setSelected (true);
6460: } else if (specifiedClock == 200.0 / 3.0) {
6461: mpuClock66MenuItem.setSelected (true);
6462: } else if (specifiedClock == 75.0) {
6463: mpuClock75MenuItem.setSelected (true);
6464: } else if (specifiedClock == 100.0) {
6465: mpuClock100MenuItem.setSelected (true);
6466: }
6467: }
6468: mpuClockMHz = specifiedClock;
6469: mpuSetClockMHz (mpuClockMHz);
6470: }
6471:
6472:
6473:
6474:
6475:
6476:
6477:
6478:
6479:
6480:
6481:
6482: public static void mpuSetClockMHz (double mhz) {
6483: mhz = Math.max (1.0, Math.min (1000.0, mhz));
6484: double lastMHz = mpuCurrentMHz;
6485: mpuCurrentMHz = mhz;
6486: mpuCycleUnit = (long) (((double) TMR_FREQ / 1000000.0) / mhz + 0.5);
6487:
6488: mpuModifiedUnit = (currentMPU == Model.MPU_MC68EC030 ||
6489: currentMPU == Model.MPU_MC68030 ?
6490: (long) (((double) TMR_FREQ * 3.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6491: currentMPU == Model.MPU_MC68LC040 ||
6492: currentMPU == Model.MPU_MC68040 ?
6493: (long) (((double) TMR_FREQ * 2.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6494: mpuCycleUnit);
6495: if (lastMHz != mhz) {
6496: mpuSetWait ();
6497: }
6498: }
6499:
6500:
6501:
6502:
6503:
6504:
6505:
6506:
6507:
6508:
6509:
6510:
6511:
6512:
6513:
6514:
6515:
6516:
6517:
6518:
6519:
6520:
6521:
6522:
6523:
6524:
6525:
6526:
6527:
6528:
6529:
6530:
6531:
6532:
6533:
6534:
6535:
6536:
6537:
6538:
6539:
6540:
6541:
6542:
6543:
6544:
6545:
6546:
6547:
6548:
6549:
6550:
6551:
6552:
6553:
6554:
6555:
6556:
6557:
6558:
6559:
6560:
6561:
6562:
6563:
6564:
6565:
6566:
6567:
6568:
6569:
6570:
6571:
6572:
6573:
6574:
6575:
6576:
6577:
6578:
6579:
6580: public static void mpuSetWait () {
6581:
6582: if (currentMPU <= Model.MPU_MC68010) {
6583: mpuWaitTime.ram = mpuCycleUnit >> 3;
6584: mpuWaitTime.vicon = (long) (mpuCycleUnit * 0.6);
6585: mpuWaitTime.crtc =
6586: mpuWaitTime.prnport =
6587: mpuWaitTime.sysport =
6588: mpuWaitTime.sprc =
6589: mpuWaitTime.sram =
6590: mpuWaitTime.rom = mpuCycleUnit;
6591: mpuWaitTime.gvram = (long) (mpuCycleUnit * 1.1);
6592: mpuWaitTime.rtc =
6593: mpuWaitTime.opm =
6594: mpuWaitTime.adpcm =
6595: mpuWaitTime.fdc =
6596: mpuWaitTime.fdd =
6597: mpuWaitTime.hdc =
6598: mpuWaitTime.ppi =
6599: mpuWaitTime.ioi = (long) (mpuCycleUnit * 1.7);
6600: mpuWaitTime.tvram = mpuCycleUnit * 2;
6601: mpuWaitTime.palet = (long) (mpuCycleUnit * 2.6);
6602: mpuWaitTime.mfp = (long) (mpuCycleUnit * 4.3);
6603: mpuWaitTime.scc = mpuCycleUnit * 6;
6604: mpuWaitTime.dmac = mpuCycleUnit * 15;
6605: mpuWaitTime.ramlong = mpuWaitTime.ram << 1;
6606: mpuWaitTime.romlong = mpuWaitTime.rom << 1;
6607: } else if (currentMPU <= Model.MPU_MC68030) {
6608: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6609: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6610: mpuWaitTime.sram = mpuCycleUnit * 2;
6611: mpuWaitTime.prnport =
6612: mpuWaitTime.sysport = mpuCycleUnit * 4;
6613: mpuWaitTime.gvram =
6614: mpuWaitTime.crtc =
6615: mpuWaitTime.vicon =
6616: mpuWaitTime.sprc = mpuCycleUnit * 6;
6617: mpuWaitTime.tvram = mpuCycleUnit * 7;
6618: mpuWaitTime.palet = mpuCycleUnit * 11;
6619: mpuWaitTime.opm =
6620: mpuWaitTime.adpcm =
6621: mpuWaitTime.fdc =
6622: mpuWaitTime.fdd =
6623: mpuWaitTime.hdc =
6624: mpuWaitTime.ppi =
6625: mpuWaitTime.ioi = mpuCycleUnit * 15;
6626: mpuWaitTime.mfp = mpuCycleUnit * 19;
6627: mpuWaitTime.rtc = mpuCycleUnit * 28;
6628: mpuWaitTime.dmac = mpuCycleUnit * 34;
6629: mpuWaitTime.scc = mpuCycleUnit * 38;
6630: mpuWaitTime.ramlong = mpuWaitTime.ram;
6631: mpuWaitTime.romlong = mpuWaitTime.rom;
6632: } else {
6633: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6634: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6635: mpuWaitTime.sram = mpuCycleUnit * 13;
6636: mpuWaitTime.prnport =
6637: mpuWaitTime.sysport = mpuCycleUnit * 17;
6638: mpuWaitTime.gvram =
6639: mpuWaitTime.crtc =
6640: mpuWaitTime.vicon =
6641: mpuWaitTime.sprc = mpuCycleUnit * 21;
6642: mpuWaitTime.tvram = mpuCycleUnit * 22;
6643: mpuWaitTime.palet = mpuCycleUnit * 33;
6644: mpuWaitTime.opm =
6645: mpuWaitTime.adpcm =
6646: mpuWaitTime.fdc =
6647: mpuWaitTime.fdd =
6648: mpuWaitTime.hdc =
6649: mpuWaitTime.ppi =
6650: mpuWaitTime.ioi = mpuCycleUnit * 37;
6651: mpuWaitTime.mfp = mpuCycleUnit * 47;
6652: mpuWaitTime.dmac = mpuCycleUnit * 73;
6653: mpuWaitTime.rtc = mpuCycleUnit * 77;
6654: mpuWaitTime.scc = mpuCycleUnit * 97;
6655: mpuWaitTime.ramlong = mpuWaitTime.ram;
6656: mpuWaitTime.romlong = mpuWaitTime.rom;
6657: }
6658: if (true) {
6659:
6660: mpuNoWaitTime.sram = mpuWaitTime.sram;
6661: mpuNoWaitTime.rom = mpuWaitTime.rom;
6662: mpuNoWaitTime.romlong = mpuWaitTime.romlong;
6663: }
6664:
6665: dmaWaitTime.ram = dmaCycleUnit >> 3;
6666: dmaWaitTime.sram = 0;
6667: dmaWaitTime.rom = 0;
6668: dmaWaitTime.gvram =
6669: dmaWaitTime.crtc =
6670: dmaWaitTime.vicon =
6671: dmaWaitTime.prnport =
6672: dmaWaitTime.sysport =
6673: dmaWaitTime.sprc = dmaCycleUnit;
6674: dmaWaitTime.tvram =
6675: dmaWaitTime.rtc =
6676: dmaWaitTime.opm =
6677: dmaWaitTime.adpcm =
6678: dmaWaitTime.fdc =
6679: dmaWaitTime.fdd =
6680: dmaWaitTime.hdc =
6681: dmaWaitTime.ppi =
6682: dmaWaitTime.ioi = dmaCycleUnit * 2;
6683: dmaWaitTime.palet = dmaCycleUnit * 3;
6684: dmaWaitTime.mfp = dmaCycleUnit * 4;
6685: dmaWaitTime.scc = dmaCycleUnit * 6;
6686: dmaWaitTime.dmac = dmaCycleUnit * 15;
6687: dmaWaitTime.ramlong = dmaWaitTime.ram << 1;
6688: dmaWaitTime.romlong = dmaWaitTime.rom << 1;
6689: if (MC68060.CAT_ON) {
6690: if (Model.MPU_MC68LC060 <= currentMPU) {
6691: MC68060.catMainLongTime = mpuCycleUnit * 13;
6692: MC68060.catMainLineTime = mpuCycleUnit * 45;
6693: MC68060.catHighLongTime = mpuCycleUnit * 9;
6694: MC68060.catHighLineTime = mpuCycleUnit * 15;
6695: }
6696: }
6697: }
6698:
6699:
6700:
6701:
6702:
6703: public static void mpuReset (int device, int romHandle) {
6704:
6705: mpuBootDevice = device;
6706: mpuROMBootHandle = romHandle;
6707:
6708:
6709:
6710:
6711:
6712:
6713:
6714:
6715:
6716:
6717:
6718:
6719: if (mpuBootDevice == -1) {
6720: if (mpuSavedBootDevice != -1) {
6721: mpuBootDevice = mpuSavedBootDevice;
6722: mpuROMBootHandle = mpuSavedROMBootHandle;
6723: mpuSavedBootDevice = -1;
6724: mpuSavedROMBootHandle = -1;
6725: }
6726: } else {
6727: if (mpuSavedBootDevice == -1) {
6728: mpuSavedBootDevice = MainMemory.mmrRwz (0x00ed0018);
6729: mpuSavedROMBootHandle = MainMemory.mmrRls (0x00ed000c);
6730: }
6731: }
6732:
6733:
6734: if (mpu010) {
6735: if (specifiedFirstMPU == Model.MPU_MC68000) {
6736: specifiedFirstMPU = Model.MPU_MC68010;
6737: }
6738: if (specifiedSecondMPU == Model.MPU_MC68000) {
6739: specifiedSecondMPU = Model.MPU_MC68010;
6740: }
6741: } else {
6742: if (specifiedFirstMPU == Model.MPU_MC68010) {
6743: specifiedFirstMPU = Model.MPU_MC68000;
6744: }
6745: if (specifiedSecondMPU == Model.MPU_MC68010) {
6746: specifiedSecondMPU = Model.MPU_MC68000;
6747: }
6748: }
6749:
6750:
6751: specifiedIsSecond = false;
6752: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
6753: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
6754:
6755: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
6756: MC68EC030.m30DivZeroVFlag = false;
6757: }
6758:
6759: if (mpuTask != null) {
6760: mpuClockLimit = 0L;
6761: System.out.println (Multilingual.mlnJapanese ?
6762: "MPU を停止します" :
6763: "MPU stops");
6764: mpuTask.cancel ();
6765: mpuTask = null;
6766: }
6767:
6768: tmrTimer.schedule (new TimerTask () {
6769: @Override public void run () {
6770:
6771:
6772:
6773: currentModel = specifiedModel;
6774: currentAccelerator = specifiedAccelerator;
6775: frmUpdateTitle ();
6776:
6777: currentIsSecond = specifiedIsSecond;
6778: currentFirstMPU = specifiedFirstMPU;
6779: currentSecondMPU = specifiedSecondMPU;
6780: currentMPU = specifiedMPU;
6781:
6782: mpuSetCurrentClock (specifiedClock);
6783:
6784: currentCopro0 = specifiedCopro0;
6785: currentCopro1 = specifiedCopro1;
6786: currentCopro2 = specifiedCopro2;
6787: currentOnchipFPU = specifiedOnchipFPU;
6788:
6789:
6790: if (currentMPU < Model.MPU_MC68020) {
6791: if (busHimem68000) {
6792: busRequestExMemoryStart = 0x10000000;
6793: busRequestExMemorySize = busLocalMemorySize;
6794: busRequestExMemoryArray = busLocalMemoryArray;
6795: } else {
6796: busRequestExMemoryStart = 0x10000000;
6797: busRequestExMemorySize = 0 << 20;
6798: busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
6799: }
6800: } else if (currentMPU < Model.MPU_MC68LC040) {
6801: if (busHighMemory060turboOn) {
6802: busRequestExMemoryStart = 0x10000000;
6803: busRequestExMemorySize = busLocalMemorySize;
6804: busRequestExMemoryArray = busLocalMemoryArray;
6805: } else {
6806: busRequestExMemoryStart = 0x01000000;
6807: busRequestExMemorySize = busHighMemorySize;
6808: busRequestExMemoryArray = busHighMemoryArray;
6809: }
6810: } else {
6811: busRequestExMemoryStart = 0x10000000;
6812: busRequestExMemorySize = busLocalMemorySize;
6813: busRequestExMemoryArray = busLocalMemoryArray;
6814: }
6815: busUpdateMemoryMap ();
6816:
6817:
6818: ROM.romReset ();
6819:
6820: RegisterList.drpSetMPU ();
6821:
6822: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
6823: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6824: MC68060.mmuReset ();
6825:
6826:
6827: if (Model.MPU_MC68020 <= currentMPU) {
6828: if ((7 & currentCopro0) == 1) {
6829: fpuMotherboardCoprocessor.epbSetMC68881 ();
6830: } else if ((7 & currentCopro0) == 2) {
6831: fpuMotherboardCoprocessor.epbSetMC68882 ();
6832: } else {
6833: fpuMotherboardCoprocessor.epbSetFullSpec ();
6834: }
6835: if ((8 & currentCopro0) == 0) {
6836: fpuMotherboardCoprocessor.epbSetExtended ();
6837: } else {
6838: fpuMotherboardCoprocessor.epbSetTriple ();
6839: }
6840: }
6841:
6842: if ((7 & currentCopro1) == 1) {
6843: fpuCoproboard1.epbSetMC68881 ();
6844: } else if ((7 & currentCopro1) == 2) {
6845: fpuCoproboard1.epbSetMC68882 ();
6846: } else {
6847: fpuCoproboard1.epbSetFullSpec ();
6848: }
6849: if ((8 & currentCopro1) == 0) {
6850: fpuCoproboard1.epbSetExtended ();
6851: } else {
6852: fpuCoproboard1.epbSetTriple ();
6853: }
6854:
6855: if ((7 & currentCopro2) == 1) {
6856: fpuCoproboard2.epbSetMC68881 ();
6857: } else if ((7 & currentCopro2) == 2) {
6858: fpuCoproboard2.epbSetMC68882 ();
6859: } else {
6860: fpuCoproboard2.epbSetFullSpec ();
6861: }
6862: if ((8 & currentCopro2) == 0) {
6863: fpuCoproboard2.epbSetExtended ();
6864: } else {
6865: fpuCoproboard2.epbSetTriple ();
6866: }
6867:
6868: if (Model.MPU_MC68040 <= currentMPU) {
6869: if ((7 & currentOnchipFPU) == 6) {
6870: fpuOnChipFPU.epbSetMC68060 ();
6871: } else {
6872: fpuOnChipFPU.epbSetFullSpec ();
6873: }
6874: if ((8 & currentOnchipFPU) == 0) {
6875: fpuOnChipFPU.epbSetExtended ();
6876: } else {
6877: fpuOnChipFPU.epbSetTriple ();
6878: }
6879: }
6880:
6881: if (!currentModel.isX68030 ()) {
6882: dmaCycleUnit = TMR_FREQ / 10000000L;
6883: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6884: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6885: mpuROMWaitCycles = 1;
6886: mpuRAMWaitCycles = 0;
6887: } else {
6888: dmaCycleUnit = TMR_FREQ / 12500000L;
6889: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6890: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6891: mpuROMWaitCycles = 0;
6892: mpuRAMWaitCycles = 0;
6893: }
6894:
6895: busWaitCycles = busWaitCyclesRequest;
6896: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
6897:
6898: HD63450.dmaReadCycles = (currentModel.isPRO () ? 6 :
6899: currentModel.isCompact () ? 4 :
6900: 5);
6901: HD63450.dmaWriteCycles = (currentModel.isPRO () ? 6 :
6902: 5);
6903:
6904: if (currentMPU < Model.MPU_MC68020) {
6905:
6906: mpuIgnoreAddressError = false;
6907:
6908: mpuCacheOn = false;
6909:
6910: } else if (currentMPU < Model.MPU_MC68040) {
6911:
6912: mpuIgnoreAddressError = true;
6913: fpuBox = fpuMotherboardCoprocessor;
6914: fpuBox.epbReset ();
6915: fpuFPn = fpuBox.epbFPn;
6916:
6917: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
6918:
6919: } else {
6920:
6921: mpuIgnoreAddressError = true;
6922: fpuBox = fpuOnChipFPU;
6923: fpuBox.epbReset ();
6924: fpuFPn = fpuBox.epbFPn;
6925:
6926: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6927: mpuCacheOn = (mpuCACR & 0x80008000) != 0;
6928: if (MC68060.CAT_ON) {
6929: if (Model.MPU_MC68LC060 <= currentMPU) {
6930: MC68060.catReset ();
6931: }
6932: }
6933:
6934: }
6935:
6936: mpuSetWait ();
6937:
6938:
6939: regSRT1 = regSRT0 = 0;
6940: regSRS = REG_SR_S;
6941: regSRM = 0;
6942: regSRI = REG_SR_I;
6943: regCCR = 0;
6944: Arrays.fill (regRn, 0);
6945:
6946: regRn[15] = MainMemory.mmrRls (0x00ff0000);
6947: regPC = MainMemory.mmrRls (0x00ff0004);
6948:
6949: MainMemory.mmrReset ();
6950:
6951: busReset ();
6952: if (InstructionBreakPoint.IBP_ON) {
6953: InstructionBreakPoint.ibpOp1MemoryMap = InstructionBreakPoint.ibpOp1SuperMap;
6954: InstructionBreakPoint.ibpReset ();
6955: }
6956: if (BranchLog.BLG_ON) {
6957: BranchLog.blgReset ();
6958: }
6959:
6960: mpuIMR = 0;
6961: mpuIRR = 0;
6962: if (MC68901.MFP_DELAYED_INTERRUPT) {
6963: mpuDIRR = 0;
6964: }
6965: mpuISR = 0;
6966:
6967:
6968: mpuStart ();
6969: }
6970: }, TMR_DELAY);
6971:
6972: }
6973:
6974:
6975:
6976: public static void mpuStopAndStart () {
6977: if (mpuTask == null) {
6978: mpuStart ();
6979: } else {
6980: if (RootPointerList.RTL_ON) {
6981: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6982: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6983: mpuStop (null);
6984: }
6985: } else {
6986: mpuStop (null);
6987: }
6988: }
6989: }
6990:
6991:
6992:
6993:
6994:
6995: public static void mpuStart () {
6996: if (mpuTask != null) {
6997: mpuClockLimit = 0L;
6998: System.out.println (Multilingual.mlnJapanese ?
6999: "MPU を停止します" :
7000: "MPU stops");
7001: mpuTask.cancel ();
7002: mpuTask = null;
7003: }
7004:
7005: for (AbstractButton button : mpuButtonsStopped) {
7006: button.setEnabled (false);
7007: }
7008: DisassembleList.ddpStoppedBy = null;
7009: System.out.println (Model.mpuNameOf (currentMPU) + (Multilingual.mlnJapanese ? " を起動します" : " starts up"));
7010: mpuTask = new TimerTask () {
7011: @Override public void run () {
7012: mpuContinue = true;
7013: mpuClockLimit = mpuClockTime + TMR_FREQ * TMR_INTERVAL / 1000;
7014: mpuExecuteCore ();
7015: }
7016: };
7017: tmrTimer.scheduleAtFixedRate (mpuTask, TMR_DELAY, TMR_INTERVAL);
7018:
7019: for (AbstractButton button : mpuButtonsRunning) {
7020: button.setEnabled (true);
7021: }
7022: }
7023:
7024:
7025:
7026: public static void mpuExecuteCore () {
7027:
7028: long nanoStart = System.nanoTime ();
7029:
7030: busSuper (RP5C15.rtcFirst, 0x00e8a000, 0x00e8c000);
7031:
7032:
7033: if (currentMPU < Model.MPU_MC68010) {
7034: MC68000.mpuCore ();
7035: } else if (currentMPU < Model.MPU_MC68020) {
7036: MC68010.mpuCore ();
7037: } else if (currentMPU < Model.MPU_MC68LC040) {
7038: MC68EC030.mpuCore ();
7039: } else {
7040: MC68060.mpuCore ();
7041: }
7042:
7043: if (dbgVisibleMask != 0) {
7044: dbgUpdate ();
7045: }
7046:
7047: long nanoEnd = System.nanoTime ();
7048: mpuTotalNano += nanoEnd - nanoStart;
7049: if (--mpuAdjustmentCounter == 0) {
7050:
7051: final double expectedNano = 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
7052:
7053: double coreNano0 = (double) mpuTotalNano;
7054: mpuTotalNano = 0L;
7055: double coreNanoA = (coreNano0 * 2.0 + mpuCoreNano1 + mpuCoreNano2) * 0.25;
7056: mpuCoreNano2 = mpuCoreNano1;
7057: mpuCoreNano1 = coreNano0;
7058:
7059:
7060:
7061: double actualPercent = Math.max (1.0, 100.0 * coreNanoA / expectedNano);
7062:
7063: double maxPercent = SoundSource.sndPlayOn ? 90.0 : 100.0;
7064:
7065:
7066:
7067:
7068: if (mpuUtilOn) {
7069:
7070: double targetPercent = Math.min (maxPercent, (double) mpuUtilRatio);
7071: mpuSetClockMHz ((1.2 - 0.2 * actualPercent / targetPercent) * mpuCurrentMHz);
7072: } else {
7073: mpuSetClockMHz (Math.min (maxPercent / actualPercent,
7074: 1.2 - 0.2 * mpuCurrentMHz / mpuClockMHz) * mpuCurrentMHz);
7075: }
7076: Indicator.indUpdate (actualPercent);
7077: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
7078: }
7079: }
7080:
7081:
7082:
7083:
7084: public static void mpuStop (String message) {
7085:
7086: mpuAdvanceCount = 0;
7087: mpuStepCount = 0;
7088: mpuContinue = false;
7089: mpuStop1 (message);
7090: }
7091: public static void mpuStop1 (String message) {
7092: if (mpuTask == null) {
7093: return;
7094: }
7095: DisassembleList.ddpStoppedBy = message;
7096: mpuClockLimit = 0L;
7097: System.out.println (Multilingual.mlnJapanese ?
7098: "MPU を停止します" :
7099: "MPU stops");
7100: mpuTask.cancel ();
7101: mpuTask = null;
7102:
7103: if (mpuStepCount != 0 && mpuContinue) {
7104: if (mpuStepCount == -1 || --mpuStepCount != 0) {
7105: mpuStep (mpuStepCount);
7106: return;
7107: }
7108: }
7109: mpuAdvanceCount = 0;
7110: mpuStepCount = 0;
7111: mpuContinue = false;
7112:
7113: for (AbstractButton button : mpuButtonsRunning) {
7114: button.setEnabled (false);
7115: }
7116: tmrTimer.schedule (new TimerTask () {
7117: @Override public void run () {
7118: mpuUpdateWindow ();
7119: }
7120: }, TMR_DELAY);
7121: }
7122:
7123:
7124:
7125:
7126:
7127:
7128: public static void mpuAdvance (int n) {
7129: if (mpuTask != null) {
7130: return;
7131: }
7132: mpuAdvanceCount = n;
7133: DisassembleList.ddpStoppedBy = null;
7134: mpuTask = new TimerTask () {
7135: @Override public void run () {
7136: mpuContinue = true;
7137: do {
7138: mpuClockLimit = mpuClockTime + 1L;
7139: mpuExecuteCore ();
7140: } while (mpuContinue && --mpuAdvanceCount != 0);
7141: mpuClockLimit = 0L;
7142: if (mpuTask != null) {
7143: mpuTask.cancel ();
7144: mpuTask = null;
7145: }
7146: if (mpuStepCount != 0 && mpuContinue) {
7147: if (mpuStepCount == -1 || --mpuStepCount != 0) {
7148: mpuStep (mpuStepCount);
7149: return;
7150: }
7151: }
7152: mpuAdvanceCount = 0;
7153: mpuStepCount = 0;
7154: mpuContinue = false;
7155: mpuUpdateWindow ();
7156: }
7157: };
7158: tmrTimer.schedule (mpuTask, TMR_DELAY);
7159: }
7160:
7161:
7162:
7163:
7164:
7165:
7166: public static void mpuStep (int n) {
7167: if (mpuTask != null) {
7168: return;
7169: }
7170: mpuStepCount = n;
7171: Disassembler.disDisassemble (new StringBuilder (), regPC, regSRS);
7172: if ((Disassembler.disStatus & (Disassembler.DIS_ALWAYS_BRANCH | Disassembler.DIS_SOMETIMES_BRANCH)) != 0) {
7173: if (mpuStepCount == -1 &&
7174: (Disassembler.disOC == 0x4e73 ||
7175: Disassembler.disOC == 0x4e74 ||
7176: Disassembler.disOC == 0x4e75 ||
7177: Disassembler.disOC == 0x4e77) &&
7178: mpuUntilReturnSRS == regSRS &&
7179: (currentMPU < Model.MPU_MC68LC040 ||
7180: mpuUntilReturnRP == (regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP)) &&
7181: mpuUntilReturnPC0 != regPC0 &&
7182: Integer.compareUnsigned (mpuUntilReturnSP, regRn[15]) <= 0) {
7183: mpuAdvanceCount = 0;
7184: mpuStepCount = 0;
7185: mpuContinue = false;
7186: mpuUpdateWindow ();
7187: return;
7188: }
7189: mpuAdvance (1);
7190: } else {
7191: if (InstructionBreakPoint.IBP_ON) {
7192: InstructionBreakPoint.ibpInstant (Disassembler.disPC, DisassembleList.ddpSupervisorMode);
7193: mpuStart ();
7194: }
7195: }
7196: }
7197:
7198:
7199:
7200:
7201:
7202:
7203:
7204:
7205:
7206:
7207:
7208: public static void mpuStepUntilReturn () {
7209: if (mpuTask != null) {
7210: return;
7211: }
7212: mpuUntilReturnSRS = regSRS;
7213: mpuUntilReturnRP = regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP;
7214: mpuUntilReturnPC0 = regPC0;
7215: mpuUntilReturnSP = regRn[15];
7216: mpuStep (-1);
7217: }
7218:
7219:
7220:
7221: public static void mpuUpdateWindow () {
7222: if (dbgVisibleMask != 0) {
7223: if ((dbgVisibleMask & DBG_DDP_VISIBLE_MASK) != 0) {
7224: DisassembleList.ddpBacktraceRecord = -1L;
7225: DisassembleList.ddpUpdate (-1, -1, false);
7226: }
7227: if (BranchLog.BLG_ON) {
7228: if ((dbgVisibleMask & DBG_BLG_VISIBLE_MASK) != 0) {
7229: BranchLog.blgUpdate (BranchLog.BLG_SELECT_NEWEST);
7230: }
7231: }
7232: if (ProgramFlowVisualizer.PFV_ON) {
7233: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
7234: ProgramFlowVisualizer.pfvUpdate ();
7235: }
7236: }
7237: if (RasterBreakPoint.RBP_ON) {
7238: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
7239: RasterBreakPoint.rbpUpdateFrame ();
7240: }
7241: }
7242: if (ScreenModeTest.SMT_ON) {
7243: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
7244: ScreenModeTest.smtUpdateFrame ();
7245: }
7246: }
7247: if (RootPointerList.RTL_ON) {
7248: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
7249: RootPointerList.rtlUpdateFrame ();
7250: }
7251: }
7252: if (SpritePatternViewer.SPV_ON) {
7253: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
7254: SpritePatternViewer.spvUpdateFrame ();
7255: }
7256: }
7257: if (PaletteViewer.PLV_ON) {
7258: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
7259: PaletteViewer.plvUpdateFrame ();
7260: }
7261: }
7262: if (ATCMonitor.ACM_ON) {
7263: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
7264: ATCMonitor.acmUpdateFrame ();
7265: }
7266: }
7267: }
7268:
7269: if (DebugConsole.dgtRequestRegs != 0) {
7270: if ((DebugConsole.dgtRequestRegs & 1) != 0) {
7271: ExpressionEvaluator.ElementType.ETY_COMMAND_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
7272: }
7273: if ((DebugConsole.dgtRequestRegs & 2) != 0) {
7274: ExpressionEvaluator.ElementType.ETY_COMMAND_FLOAT_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
7275: }
7276: if ((DebugConsole.dgtRequestRegs & 4) != 0) {
7277: DebugConsole.dgtPrintPrompt ();
7278: }
7279: DebugConsole.dgtRequestRegs = 0;
7280: }
7281:
7282: for (AbstractButton button : mpuButtonsRunning) {
7283: button.setEnabled (false);
7284: }
7285:
7286: for (AbstractButton button : mpuButtonsStopped) {
7287: button.setEnabled (true);
7288: }
7289: }
7290:
7291:
7292:
7293: public static JButton mpuMakeBreakButton () {
7294: return mpuAddButtonRunning (
7295: Multilingual.mlnToolTipText (
7296: ComponentFactory.createImageButton (
7297: LnF.LNF_BREAK_IMAGE,
7298: LnF.LNF_BREAK_DISABLED_IMAGE,
7299: "Stop", mpuDebugActionListener),
7300: "ja", "停止")
7301: );
7302: }
7303:
7304:
7305:
7306: public static JButton mpuMakeTraceButton () {
7307: return mpuAddButtonStopped (
7308: Multilingual.mlnToolTipText (
7309: ComponentFactory.createImageButton (
7310: LnF.LNF_TRACE_IMAGE,
7311: LnF.LNF_TRACE_DISABLED_IMAGE,
7312: "Trace", mpuDebugActionListener),
7313: "ja", "トレース")
7314: );
7315: }
7316:
7317:
7318:
7319: public static JButton mpuMakeTrace10Button () {
7320: return mpuAddButtonStopped (
7321: Multilingual.mlnToolTipText (
7322: ComponentFactory.createImageButton (
7323: LnF.LNF_TRACE_10_IMAGE,
7324: LnF.LNF_TRACE_10_DISABLED_IMAGE,
7325: "Trace 10 times", mpuDebugActionListener),
7326: "ja", "トレース 10 回")
7327: );
7328: }
7329:
7330:
7331:
7332: public static JButton mpuMakeTrace100Button () {
7333: return mpuAddButtonStopped (
7334: Multilingual.mlnToolTipText (
7335: ComponentFactory.createImageButton (
7336: LnF.LNF_TRACE_100_IMAGE,
7337: LnF.LNF_TRACE_100_DISABLED_IMAGE,
7338: "Trace 100 times", mpuDebugActionListener),
7339: "ja", "トレース 100 回")
7340: );
7341: }
7342:
7343:
7344:
7345: public static JButton mpuMakeStepButton () {
7346: return mpuAddButtonStopped (
7347: Multilingual.mlnToolTipText (
7348: ComponentFactory.createImageButton (
7349: LnF.LNF_STEP_IMAGE,
7350: LnF.LNF_STEP_DISABLED_IMAGE,
7351: "Step", mpuDebugActionListener),
7352: "ja", "ステップ")
7353: );
7354: }
7355:
7356:
7357:
7358: public static JButton mpuMakeStep10Button () {
7359: return mpuAddButtonStopped (
7360: Multilingual.mlnToolTipText (
7361: ComponentFactory.createImageButton (
7362: LnF.LNF_STEP_10_IMAGE,
7363: LnF.LNF_STEP_10_DISABLED_IMAGE,
7364: "Step 10 times", mpuDebugActionListener),
7365: "ja", "ステップ 10 回")
7366: );
7367: }
7368:
7369:
7370:
7371: public static JButton mpuMakeStep100Button () {
7372: return mpuAddButtonStopped (
7373: Multilingual.mlnToolTipText (
7374: ComponentFactory.createImageButton (
7375: LnF.LNF_STEP_100_IMAGE,
7376: LnF.LNF_STEP_100_DISABLED_IMAGE,
7377: "Step 100 times", mpuDebugActionListener),
7378: "ja", "ステップ 100 回")
7379: );
7380: }
7381:
7382:
7383:
7384: public static JButton mpuMakeReturnButton () {
7385: return mpuAddButtonStopped (
7386: Multilingual.mlnToolTipText (
7387: ComponentFactory.createImageButton (
7388: LnF.LNF_STEP_UNTIL_RETURN_IMAGE,
7389: LnF.LNF_STEP_UNTIL_RETURN_DISABLED_IMAGE,
7390: "Step until return", mpuDebugActionListener),
7391: "ja", "ステップアンティルリターン")
7392: );
7393: }
7394:
7395:
7396:
7397: public static JButton mpuMakeRunButton () {
7398: return mpuAddButtonStopped (
7399: Multilingual.mlnToolTipText (
7400: ComponentFactory.createImageButton (
7401: LnF.LNF_RUN_IMAGE,
7402: LnF.LNF_RUN_DISABLED_IMAGE,
7403: "Run", mpuDebugActionListener),
7404: "ja", "実行")
7405: );
7406: }
7407:
7408:
7409:
7410: public static <T extends AbstractButton> T mpuAddButtonRunning (T button) {
7411: button.setEnabled (mpuTask != null);
7412: mpuButtonsRunning.add (button);
7413: return button;
7414: }
7415:
7416:
7417:
7418: public static <T extends AbstractButton> T mpuAddButtonStopped (T button) {
7419: button.setEnabled (mpuTask == null);
7420: mpuButtonsStopped.add (button);
7421: return button;
7422: }
7423:
7424:
7425:
7426:
7427:
7428:
7429:
7430:
7431:
7432:
7433:
7434:
7435:
7436:
7437:
7438:
7439: public static final int EMX_OPCODE_BASE = 0x4e00;
7440: public static final int EMX_OPCODE_HFSBOOT = EMX_OPCODE_BASE + 0x00;
7441: public static final int EMX_OPCODE_HFSINST = EMX_OPCODE_BASE + 0x01;
7442: public static final int EMX_OPCODE_HFSSTR = EMX_OPCODE_BASE + 0x02;
7443: public static final int EMX_OPCODE_HFSINT = EMX_OPCODE_BASE + 0x03;
7444: public static final int EMX_OPCODE_EMXNOP = EMX_OPCODE_BASE + 0x04;
7445: public static final int EMX_OPCODE_EMXWAIT = EMX_OPCODE_BASE + 0x05;
7446:
7447: public static final String[] EMX_MNEMONIC_ARRAY = {
7448: "hfsboot",
7449: "hfsinst",
7450: "hfsstr",
7451: "hfsint",
7452: "emxnop",
7453: "emxwait",
7454: };
7455:
7456:
7457:
7458:
7459: public static void emxNop () {
7460: if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x00007140) {
7461: int head = regRn[9];
7462: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7463:
7464:
7465: emxPatchPCM8A (head, tail);
7466:
7467:
7468: emxCheckRSDRV202 (head, tail);
7469: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000716c) {
7470: int head = regRn[9];
7471: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7472:
7473:
7474: emxPatch060turbosys (head, tail);
7475:
7476:
7477: if (Z8530.SCC_FSX_MOUSE) {
7478: emxCheckFSX (head, tail);
7479: }
7480:
7481:
7482: if (HFS.HFS_USE_TWENTY_ONE) {
7483: emxCheckTwentyOne (head, tail);
7484: }
7485:
7486:
7487: LabeledAddress.lblClear ();
7488: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000972c) {
7489: int head = regRn[8] + 256;
7490:
7491: int tail = MC68060.mmuPeekLong (head - 208, 1);
7492:
7493:
7494: emxCheckBSIO021 (head, tail);
7495:
7496:
7497: emxPatchPCM8A (head, tail);
7498:
7499:
7500: emxCheckTMSIO031 (head, tail);
7501:
7502:
7503: LabeledAddress.lblClear ();
7504:
7505:
7506: if (dbgStopAtStart) {
7507: InstructionBreakPoint.ibpInstant (regRn[12], 0);
7508: }
7509: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000a090) {
7510: int head = regRn[8] + 256;
7511: int tail = MC68060.mmuPeekLongData (regRn[8] + 8, 1);
7512: String name = MC68060.mmuPeekStringZ (head - 60, 1);
7513: if (name.equalsIgnoreCase ("fsx.x")) {
7514:
7515:
7516: if (Z8530.SCC_FSX_MOUSE) {
7517: emxCheckFSX (head, tail);
7518: }
7519: }
7520: if (name.equalsIgnoreCase ("TwentyOne.x")) {
7521:
7522:
7523: if (HFS.HFS_USE_TWENTY_ONE) {
7524: emxCheckTwentyOne (head, tail);
7525: }
7526: }
7527: }
7528: }
7529:
7530: public static final int[] emxPCM8AFFMap = {
7531: 0x00000138, 0x000001f6, 0x00000394, 0x000011ec, 0x0000120a, 0x00001400, 0x00001814, 0x00001870, 0x00001882, 0x0000188a,
7532: 0x00001892, 0x000018a2, 0x000018a8, 0x000018ca, 0x000018d4, 0x000018e0, 0x000018e8, 0x00001908, 0x000019e4, 0x00001afa,
7533: 0x00001b58, 0x00001b7c, 0x00001bac, 0x00001c38, 0x00001ccc, 0x000021f8, 0x00002250, 0x00002258, 0x00002290, 0x000022a6,
7534: 0x000022b0, 0x000022c0, 0x000022c8, 0x000022de, 0x000022ea, 0x000030c8, 0x000030de, 0x000030e6, 0x000030ea, 0x000030f6,
7535: 0x00003112, 0x00003188, 0x0000334c, 0x0000338a, 0x000033a2, 0x000033c4, 0x000033d0, 0x0000341a, 0x00003428, 0x00003496,
7536: 0x000034a6, 0x000034d6, 0x0000fe0e, 0x0000fec8, 0x0000feec, 0x0000ff46, 0x0000ff4e,
7537: };
7538:
7539:
7540:
7541: public static void emxPatchPCM8A (int head, int tail) {
7542: if (head + 0x0000ff60 <= tail &&
7543: MC68060.mmuPeekLongData (head + 0x10f8, 1) == 0x50434d38 &&
7544: MC68060.mmuPeekLongData (head + 0x10fc, 1) == 0x41313032) {
7545: System.out.println (Multilingual.mlnJapanese ?
7546: "PCM8A.X 1.02 があります" :
7547: "PCM8A.X 1.02 exists");
7548: int patched = 0;
7549: int failed = 0;
7550:
7551: for (int offset : emxPCM8AFFMap) {
7552: if (MC68060.mmuPeekByteZeroData (head + offset, 1) == 0xff) {
7553: MC68060.mmuPokeByteData (head + offset, 0x00, 1);
7554: patched++;
7555: } else {
7556: failed++;
7557: }
7558: }
7559: if (patched != 0) {
7560: System.out.printf (Multilingual.mlnJapanese ?
7561: "PCM8A.X 1.02 にパッチをあてました (%d/%d)\n" :
7562: "PCM8A.X 1.02 was patched (%d/%d)\n",
7563: patched, patched + failed);
7564: }
7565: }
7566: }
7567:
7568:
7569:
7570: public static void emxPatch060turbosys (int head, int tail) {
7571:
7572:
7573:
7574:
7575: if (head + 0x00002000 <= tail &&
7576: MC68060.mmuPeekLongData (head + 0x00000ec0, 1) == 0x203c302e &&
7577: MC68060.mmuPeekLongData (head + 0x00000ec4, 1) == 0x3536227c &&
7578: MC68060.mmuPeekLongData (head + 0x00000ec8, 1) == 0x30363054) {
7579: System.out.println (Multilingual.mlnJapanese ?
7580: "060turbo.sys 0.56 があります" :
7581: "060turbo.sys 0.56 exists");
7582:
7583:
7584:
7585: int patched = 0;
7586: int failed = 0;
7587: if (MC68060.mmuPeekLongData (head + 0x000021e6, 1) == 0x08f90004 &&
7588: MC68060.mmuPeekLongData (head + 0x000021ea, 1) == 0x00ed0070) {
7589: MC68060.mmuPokeWordData (head + 0x000021e6, 0x0839, 1);
7590: patched++;
7591: } else {
7592: failed++;
7593: }
7594: System.out.printf (Multilingual.mlnJapanese ?
7595: "060turbo.sys 0.56 にパッチをあてました (%d/%d)\n" :
7596: "060turbo.sys 0.56 was patched (%d/%d)\n",
7597: patched, patched + failed);
7598: }
7599: }
7600:
7601:
7602:
7603: public static void emxCheckFSX (int head, int tail) {
7604: if (Z8530.SCC_FSX_MOUSE) {
7605: if (head + 0x00063200 <= tail &&
7606: "\r\nSX SYSTEM for X68000 version 3.10\r\nCopyright 1990,91,92,93,94 SHARP/First Class Technology\r\n".equals (MC68060.mmuPeekStringZ (head + 0x0001ae, 5))) {
7607: System.out.println (Multilingual.mlnJapanese ?
7608: "FSX.X 3.10 があります" :
7609: "FSX.X 3.10 exists");
7610: Z8530.sccFSXMouseHook = head + 0x04f82a;
7611: Z8530.sccFSXMouseWork = head + 0x063184;
7612: }
7613: }
7614: }
7615:
7616:
7617:
7618:
7619:
7620:
7621: public static void emxCheckRSDRV202 (int head, int tail) {
7622: if (head + 0x000ea6 <= tail &&
7623: MC68060.mmuPeekEquals (head + 0x000e4e, "RS-232C DRIVER for X68000 version 2.02")) {
7624: if (RS232CTerminal.trmRSDRV202Head != head) {
7625: RS232CTerminal.trmRSDRV202Head = head;
7626: int[] patchData = {
7627:
7628:
7629: 0x05f8, 0x000a, 0x000b,
7630:
7631: 0x0600, 0xd040, 0x2048,
7632:
7633: 0x060e, 0x3030, 0x4e90,
7634: 0x0610, 0x0000, 0x2048,
7635:
7636: 0x074e, 0x0821, 0x2041,
7637: 0x0750, 0x0410, 0x3200,
7638: 0x0752, 0x0207, 0x303c,
7639: 0x0754, 0x0102, 0x0823,
7640: 0x0756, 0x0080, 0xe268,
7641: 0x0758, 0x003f, 0x72fe,
7642: 0x075a, 0x001f, 0xd141,
7643: 0x075c, 0x000e, 0x2208,
7644: 0x075e, 0x0006, 0x4e75,
7645:
7646:
7647: 0x0ab0, 0x0040, 0x0400,
7648: 0x0ad2, 0x0040, 0x0400,
7649: 0x0af4, 0x0040, 0x0400,
7650: 0x0b16, 0x0040, 0x0400,
7651: 0x0b38, 0x0040, 0x0400,
7652:
7653:
7654: 0x0cae, 0x0009, 0x000b,
7655: };
7656: int patched = 0;
7657: int failed = 0;
7658: for (int i = 0; i < patchData.length; i += 3) {
7659: int a = head + patchData[i];
7660: int b = patchData[i + 1];
7661: int c = patchData[i + 2];
7662: int d = MC68060.mmuPeekWordZeroData (a, 1);
7663: if (d == b) {
7664: MC68060.mmuPokeWordData (a, c, 1);
7665: patched++;
7666: } else if (d != c) {
7667: failed++;
7668: }
7669: }
7670: System.out.printf ("RSDRV.SYS 2.02 found at %08X and patched (%d/%d)\n", head, patched, patched + failed);
7671: }
7672: }
7673: }
7674:
7675:
7676:
7677:
7678:
7679: public static void emxCheckTMSIO031 (int head, int tail) {
7680: if (head + 0x000fc4 <= tail &&
7681: MC68060.mmuPeekEquals (head + 0x000d1c, "TMSIO version 0.31 Copyright (C) 1990-93 by Miki Hoshino")) {
7682: if (RS232CTerminal.trmTMSIO031Head != head) {
7683: RS232CTerminal.trmTMSIO031Head = head;
7684: System.out.printf ("TMSIO 0.31 found at %08X\n", head);
7685: }
7686: }
7687: }
7688:
7689:
7690:
7691:
7692:
7693: public static void emxCheckBSIO021 (int head, int tail) {
7694: if (head + 0x001c2c <= tail &&
7695: MC68060.mmuPeekEquals (head + 0x001a66, "BSIO version 0.21 Copyright (C) 1994 By BAZU")) {
7696: if (RS232CTerminal.trmBSIO021Head != head) {
7697: RS232CTerminal.trmBSIO021Head = head;
7698: System.out.printf ("BSIO 0.21 found at %08X\n", head);
7699: }
7700: }
7701: }
7702:
7703:
7704:
7705: public static void emxCheckTwentyOne (int head, int tail) {
7706: if (HFS.HFS_USE_TWENTY_ONE &&
7707: head + 64 <= tail) {
7708: if (MainMemory.mmrTwentyOneOptionAddress != 0 ||
7709: MainMemory.mmrHumanVersion <= 0) {
7710: return;
7711: }
7712: int name1 = MC68060.mmuPeekLongData (head + 14, 1);
7713: if (name1 == ('*' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7714: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7715: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '*')) {
7716: MainMemory.mmrTwentyOneOptionAddress = -1;
7717: }
7718: } else if (name1 == ('?' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7719: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7720: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '?') ||
7721: name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | 'E')) {
7722: System.out.println (Multilingual.mlnJapanese ?
7723: "TwentyOne.x があります" :
7724: "TwentyOne.x exists");
7725: MainMemory.mmrTwentyOneOptionAddress = head + 22;
7726: }
7727: }
7728: }
7729: }
7730:
7731:
7732:
7733:
7734:
7735:
7736:
7737:
7738:
7739:
7740:
7741:
7742:
7743:
7744:
7745:
7746:
7747:
7748:
7749:
7750:
7751:
7752:
7753:
7754:
7755:
7756:
7757:
7758:
7759:
7760:
7761:
7762:
7763:
7764:
7765:
7766:
7767:
7768:
7769:
7770:
7771:
7772:
7773:
7774:
7775:
7776:
7777:
7778:
7779:
7780:
7781: public static final boolean IRP_BITREV_REVERSE = false;
7782: public static final boolean IRP_BITREV_SHIFT = false;
7783: public static final boolean IRP_BITREV_TABLE = true;
7784:
7785: public static final boolean IRP_MOVEM_MAINMEMORY = true;
7786: public static final boolean IRP_MOVEM_EXPAND = false;
7787: public static final boolean IRP_MOVEM_LOOP = false;
7788: public static final boolean IRP_MOVEM_SHIFT_LEFT = false;
7789: public static final boolean IRP_MOVEM_SHIFT_RIGHT = true;
7790: public static final boolean IRP_MOVEM_ZEROS = false;
7791:
7792:
7793: public static void irpReset () {
7794:
7795: CRTC.crtReset ();
7796: VideoController.vcnReset ();
7797: HD63450.dmaReset ();
7798: MC68901.mfpReset ();
7799: Keyboard.kbdReset ();
7800: RP5C15.rtcReset ();
7801: PrinterPort.prnReset ();
7802: SoundSource.sndReset ();
7803: OPM.opmReset ();
7804: ADPCM.pcmReset ();
7805: FDC.fdcReset ();
7806: IOInterrupt.ioiReset ();
7807: eb2Reset ();
7808: if (HostCDROM.HCD_ENABLED) {
7809: HostCDROM.hcdReset ();
7810: }
7811: SPC.spcReset ();
7812: Z8530.sccReset ();
7813: RS232CTerminal.trmReset ();
7814: PPI.ppiReset ();
7815: HFS.hfsReset ();
7816: SpriteScreen.sprReset ();
7817:
7818: if (MercuryUnit.MU4_ON) {
7819: MercuryUnit.mu4Reset ();
7820: }
7821: xt3Reset ();
7822: SRAM.smrReset ();
7823: CONDevice.conReset ();
7824: TextCopy.txcReset ();
7825: }
7826:
7827:
7828:
7829:
7830:
7831:
7832:
7833:
7834:
7835:
7836:
7837:
7838:
7839:
7840:
7841:
7842:
7843:
7844:
7845:
7846:
7847:
7848:
7849:
7850:
7851:
7852:
7853:
7854:
7855:
7856:
7857:
7858:
7859:
7860:
7861:
7862:
7863:
7864:
7865:
7866:
7867:
7868:
7869:
7870:
7871:
7872:
7873:
7874:
7875:
7876:
7877:
7878:
7879:
7880:
7881:
7882:
7883:
7884:
7885:
7886:
7887:
7888:
7889:
7890:
7891:
7892:
7893:
7894:
7895:
7896:
7897:
7898:
7899:
7900:
7901:
7902:
7903:
7904:
7905:
7906:
7907:
7908:
7909:
7910:
7911:
7912:
7913:
7914:
7915:
7916:
7917:
7918:
7919:
7920:
7921:
7922:
7923:
7924:
7925:
7926:
7927:
7928:
7929:
7930:
7931:
7932:
7933:
7934:
7935:
7936:
7937:
7938:
7939:
7940:
7941:
7942:
7943:
7944:
7945:
7946:
7947:
7948:
7949:
7950:
7951:
7952:
7953:
7954:
7955:
7956:
7957:
7958:
7959:
7960:
7961:
7962:
7963:
7964:
7965:
7966:
7967:
7968:
7969:
7970:
7971:
7972:
7973:
7974:
7975:
7976:
7977:
7978:
7979:
7980:
7981:
7982:
7983:
7984:
7985:
7986:
7987:
7988:
7989:
7990:
7991:
7992:
7993:
7994:
7995:
7996:
7997:
7998:
7999:
8000:
8001:
8002:
8003:
8004:
8005:
8006:
8007:
8008:
8009:
8010:
8011:
8012:
8013:
8014:
8015:
8016:
8017:
8018:
8019:
8020:
8021:
8022:
8023:
8024:
8025:
8026:
8027:
8028:
8029:
8030:
8031:
8032:
8033:
8034:
8035:
8036:
8037:
8038:
8039:
8040:
8041:
8042:
8043:
8044:
8045:
8046:
8047:
8048:
8049:
8050:
8051:
8052:
8053:
8054:
8055:
8056:
8057:
8058:
8059:
8060:
8061:
8062:
8063:
8064:
8065:
8066:
8067:
8068:
8069:
8070:
8071:
8072:
8073:
8074:
8075:
8076:
8077:
8078:
8079:
8080:
8081:
8082:
8083:
8084:
8085:
8086:
8087:
8088:
8089:
8090:
8091:
8092:
8093:
8094:
8095:
8096:
8097:
8098:
8099:
8100:
8101:
8102:
8103:
8104:
8105:
8106:
8107:
8108:
8109:
8110:
8111:
8112:
8113:
8114:
8115:
8116:
8117:
8118:
8119:
8120:
8121:
8122:
8123:
8124:
8125:
8126:
8127:
8128:
8129:
8130:
8131:
8132:
8133:
8134:
8135:
8136:
8137:
8138:
8139:
8140:
8141:
8142:
8143:
8144:
8145:
8146:
8147:
8148:
8149:
8150:
8151:
8152:
8153:
8154:
8155:
8156:
8157:
8158:
8159:
8160:
8161:
8162:
8163:
8164:
8165:
8166:
8167:
8168:
8169:
8170:
8171:
8172:
8173:
8174:
8175:
8176:
8177:
8178:
8179:
8180:
8181:
8182:
8183:
8184:
8185:
8186:
8187:
8188:
8189:
8190:
8191:
8192:
8193:
8194:
8195:
8196:
8197:
8198:
8199:
8200:
8201:
8202:
8203:
8204:
8205:
8206:
8207:
8208:
8209:
8210:
8211:
8212:
8213:
8214:
8215:
8216:
8217:
8218:
8219:
8220:
8221:
8222:
8223:
8224:
8225:
8226:
8227:
8228:
8229:
8230:
8231:
8232:
8233:
8234:
8235:
8236:
8237:
8238:
8239:
8240:
8241:
8242:
8243:
8244:
8245:
8246:
8247:
8248:
8249:
8250:
8251:
8252:
8253:
8254:
8255:
8256:
8257:
8258:
8259:
8260:
8261:
8262:
8263:
8264:
8265:
8266:
8267:
8268:
8269:
8270:
8271:
8272:
8273:
8274:
8275:
8276:
8277:
8278:
8279:
8280:
8281:
8282:
8283:
8284:
8285:
8286:
8287:
8288:
8289:
8290:
8291:
8292:
8293:
8294:
8295:
8296:
8297:
8298:
8299:
8300:
8301:
8302:
8303:
8304:
8305:
8306:
8307:
8308:
8309:
8310:
8311:
8312:
8313:
8314:
8315:
8316:
8317:
8318:
8319:
8320:
8321:
8322:
8323:
8324:
8325:
8326:
8327:
8328:
8329:
8330:
8331:
8332:
8333:
8334:
8335:
8336:
8337:
8338:
8339:
8340:
8341:
8342:
8343:
8344:
8345:
8346:
8347:
8348:
8349:
8350:
8351:
8352:
8353:
8354:
8355:
8356:
8357:
8358:
8359:
8360:
8361:
8362:
8363:
8364:
8365:
8366:
8367:
8368:
8369:
8370:
8371:
8372:
8373:
8374:
8375:
8376:
8377:
8378:
8379:
8380:
8381:
8382:
8383:
8384:
8385:
8386:
8387:
8388:
8389:
8390:
8391:
8392:
8393:
8394:
8395:
8396:
8397:
8398:
8399:
8400:
8401:
8402:
8403:
8404:
8405:
8406:
8407:
8408:
8409:
8410:
8411:
8412: public static final byte[] EFA_EXTENSION_CLK = "\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\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\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\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\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\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\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\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\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\4\f\20\24\4\f\20\24\4\f\20\24\4\f\20\24\b\20\24\30\b\20\24\30\b\20\24\30\b\20\24\30\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\4\f\20\24\4\f\20\24\4\f\20\24\4\f\20\24\b\20\24\30\b\20\24\30\b\20\24\30\b\20\24\30\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\4\f\20\24\4\f\20\24\4\f\20\24\4\f\20\24\b\20\24\30\b\20\24\30\b\20\24\30\b\20\24\30\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\0\b\f\20\4\f\20\24\4\f\20\24\4\f\20\24\4\f\20\24\b\20\24\30\b\20\24\30\b\20\24\30\b\20\24\30".getBytes (XEiJ.ISO_8859_1);
8413:
8414: public static final boolean EFA_SEPARATE_AR = false;
8415:
8416:
8417:
8418:
8419:
8420:
8421: public static final boolean BUS_SPLIT_UNALIGNED_LONG = false;
8422:
8423:
8424: public static final int BUS_MOTHER_BITS = 24;
8425: public static final int BUS_MOTHER_SIZE = BUS_MOTHER_BITS < 32 ? 1 << BUS_MOTHER_BITS : 0;
8426: public static final int BUS_MOTHER_MASK = BUS_MOTHER_SIZE - 1;
8427:
8428: public static final int BUS_ARRAY_SIZE = BUS_MOTHER_SIZE;
8429:
8430:
8431: public static final int BUS_PAGE_BITS = 12;
8432: public static final int BUS_PAGE_SIZE = 1 << BUS_PAGE_BITS;
8433: public static final int BUS_PAGE_COUNT = 1 << (32 - BUS_PAGE_BITS);
8434:
8435:
8436: public static final int MPU_SS_BYTE = 0;
8437: public static final int MPU_SS_WORD = 1;
8438: public static final int MPU_SS_LONG = 2;
8439:
8440:
8441: public static final int MPU_WR_WRITE = 0;
8442: public static final int MPU_WR_READ = 1;
8443:
8444:
8445: public static final int MPU_US_USER = 0;
8446: public static final int MPU_US_SUPERVISOR = 1;
8447:
8448:
8449: public static final MemoryMappedDevice[] busUserMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8450: public static final MemoryMappedDevice[] busSuperMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8451: public static MemoryMappedDevice[] busMemoryMap;
8452:
8453:
8454: public static boolean busHimem68000;
8455:
8456:
8457: public static final int BUS_HIGH_MEMORY_START = 0x01000000;
8458: public static int busHighMemorySize;
8459: public static byte[] busHighMemoryArray;
8460: public static boolean busHighMemorySaveOn;
8461: public static boolean busHighMemory060turboOn;
8462:
8463:
8464: public static final int BUS_LOCAL_MEMORY_START = 0x10000000;
8465: public static int busLocalMemorySize;
8466: public static byte[] busLocalMemoryArray;
8467: public static boolean busLocalMemorySaveOn;
8468:
8469:
8470: public static final byte[] BUS_DUMMY_MEMORY_ARRAY = new byte[0];
8471: public static int busRequestExMemoryStart;
8472: public static int busRequestExMemorySize;
8473: public static byte[] busRequestExMemoryArray;
8474: public static int busExMemoryStart;
8475: public static int busExMemorySize;
8476: public static byte[] busExMemoryArray;
8477:
8478:
8479: public static boolean busRequestCutFC2Pin;
8480: public static boolean busCutFC2Pin;
8481:
8482:
8483:
8484: public static void busInit () {
8485:
8486:
8487: if (!DataBreakPoint.DBP_ON) {
8488: busMemoryMap = busSuperMap;
8489: }
8490:
8491:
8492: int highMemorySizeMB = Settings.sgsGetInt ("highmemory");
8493: busHighMemorySize = highMemorySizeMB == 16 ? highMemorySizeMB << 20 : 0 << 20;
8494: if (busHighMemorySize == 0) {
8495: System.out.println (Multilingual.mlnJapanese ?
8496: "X68030/Xellent30 のハイメモリはありません" :
8497: "X68030/Xellent30 high memory does not exists");
8498: } else {
8499: System.out.printf (Multilingual.mlnJapanese ?
8500: "X68030/Xellent30 のハイメモリのサイズは %dMB です\n" :
8501: "X68030/Xellent30 high memory size is %dMB\n",
8502: busHighMemorySize >> 20);
8503: }
8504: busHighMemoryArray = new byte[busHighMemorySize];
8505:
8506: busHimem68000 = Settings.sgsGetOnOff ("himem68000");
8507:
8508: busHighMemorySaveOn = Settings.sgsGetOnOff ("highmemorysave");
8509: busHighMemory060turboOn = Settings.sgsGetOnOff ("highmemory060turbo");
8510:
8511: byte[] highMemoryArray = Settings.sgsGetData ("highmemorydata");
8512: if (busHighMemorySize != 0) {
8513: if (highMemoryArray.length != 0) {
8514: System.out.println (Multilingual.mlnJapanese ?
8515: "X68030/Xellent30 のハイメモリのデータを復元します" :
8516: "X68030/Xellent30 high memory data is restored");
8517: System.arraycopy (highMemoryArray, 0, busHighMemoryArray, 0, Math.min (highMemoryArray.length, busHighMemorySize));
8518: } else {
8519: System.out.println (Multilingual.mlnJapanese ?
8520: "X68030/Xellent30 のハイメモリをゼロクリアします" :
8521: "X68030/Xellent30 high memory is zero-cleared");
8522: }
8523: if (highMemoryArray.length < busHighMemorySize) {
8524: Arrays.fill (busHighMemoryArray, highMemoryArray.length, busHighMemorySize, (byte) 0);
8525: }
8526: }
8527:
8528:
8529: int localMemorySizeMB = Settings.sgsGetInt ("localmemory");
8530: busLocalMemorySize = (localMemorySizeMB == 16 ||
8531: localMemorySizeMB == 32 ||
8532: localMemorySizeMB == 64 ||
8533: localMemorySizeMB == 128 ||
8534: localMemorySizeMB == 256 ||
8535: localMemorySizeMB == 384 ||
8536: localMemorySizeMB == 512 ||
8537: localMemorySizeMB == 768 ?
8538: localMemorySizeMB << 20 :
8539: 128 << 20);
8540: if (busLocalMemorySize == 0) {
8541: System.out.println (Multilingual.mlnJapanese ?
8542: "060turbo のハイメモリはありません" :
8543: "060turbo high memory does not exists");
8544: } else {
8545: System.out.printf (Multilingual.mlnJapanese ?
8546: "060turbo のハイメモリのサイズは %dMB です\n" :
8547: "060turbo high memory size is %dMB\n",
8548: busLocalMemorySize >> 20);
8549: }
8550: busLocalMemoryArray = new byte[busLocalMemorySize];
8551:
8552: busLocalMemorySaveOn = Settings.sgsGetOnOff ("localmemorysave");
8553:
8554: byte[] localMemoryArray = Settings.sgsGetData ("localmemorydata");
8555: if (busLocalMemorySize != 0) {
8556: if (localMemoryArray.length != 0) {
8557: System.out.println (Multilingual.mlnJapanese ?
8558: "060turbo のハイメモリのデータを復元します" :
8559: "060turbo high memory data is restored");
8560: System.arraycopy (localMemoryArray, 0, busLocalMemoryArray, 0, Math.min (localMemoryArray.length, busLocalMemorySize));
8561: } else {
8562: System.out.println (Multilingual.mlnJapanese ?
8563: "060turbo のハイメモリをゼロクリアします" :
8564: "060turbo high memory is zero-cleared");
8565: }
8566: if (localMemoryArray.length < busLocalMemorySize) {
8567: Arrays.fill (busLocalMemoryArray, localMemoryArray.length, busLocalMemorySize, (byte) 0);
8568: }
8569: }
8570:
8571:
8572: busExMemoryStart = busRequestExMemoryStart = 0x10000000;
8573: busExMemorySize = busRequestExMemorySize = 0 << 20;
8574: busExMemoryArray = busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
8575:
8576:
8577: busRequestCutFC2Pin = Settings.sgsGetOnOff ("cutfc2pin");
8578: busCutFC2Pin = !busRequestCutFC2Pin;
8579:
8580: busUpdateMemoryMap ();
8581:
8582: }
8583:
8584:
8585:
8586: public static void busTini () {
8587: Settings.sgsPutOnOff ("himem68000", busHimem68000);
8588: Settings.sgsPutInt ("highmemory", busHighMemorySize >>> 20);
8589: Settings.sgsPutOnOff ("highmemorysave", busHighMemorySaveOn);
8590: Settings.sgsPutOnOff ("highmemory060turbo", busHighMemory060turboOn);
8591: Settings.sgsPutData ("highmemorydata", busHighMemorySaveOn ? busHighMemoryArray : new byte[0]);
8592: Settings.sgsPutInt ("localmemory", busLocalMemorySize >>> 20);
8593: Settings.sgsPutOnOff ("localmemorysave", busLocalMemorySaveOn);
8594: Settings.sgsPutData ("localmemorydata", busLocalMemorySaveOn ? busLocalMemoryArray : new byte[0]);
8595: Settings.sgsPutOnOff ("cutfc2pin", busRequestCutFC2Pin);
8596: }
8597:
8598: public static void busUpdateMemoryMap () {
8599: if (busExMemoryStart == busRequestExMemoryStart &&
8600: busExMemorySize == busRequestExMemorySize &&
8601: busExMemoryArray == busRequestExMemoryArray &&
8602: busExMemoryArray.length == busExMemorySize &&
8603: busCutFC2Pin == busRequestCutFC2Pin) {
8604: return;
8605: }
8606:
8607: busExMemoryStart = busRequestExMemoryStart;
8608: busExMemorySize = busRequestExMemorySize;
8609: busExMemoryArray = busRequestExMemoryArray;
8610: if (busExMemoryArray.length != busExMemorySize) {
8611: byte[] newArray = new byte[busExMemorySize];
8612: int copySize = Math.min (busExMemoryArray.length, busExMemorySize);
8613: if (copySize > 0) {
8614: System.arraycopy (busExMemoryArray, 0, newArray, 0, copySize);
8615: }
8616: if (busExMemoryArray == busHighMemoryArray) {
8617: busHighMemoryArray = newArray;
8618: } else if (busExMemoryArray == busLocalMemoryArray) {
8619: busLocalMemoryArray = newArray;
8620: }
8621: busExMemoryArray = newArray;
8622: }
8623:
8624: busCutFC2Pin = busRequestCutFC2Pin;
8625:
8626:
8627:
8628:
8629:
8630:
8631:
8632:
8633:
8634:
8635:
8636:
8637: busSuper (MemoryMappedDevice.MMD_MMR, 0x00000000, 0x00002000);
8638: busUser ( MemoryMappedDevice.MMD_MMR, 0x00002000, 0x00c00000);
8639:
8640:
8641:
8642:
8643:
8644:
8645:
8646:
8647:
8648:
8649:
8650:
8651:
8652:
8653:
8654:
8655:
8656:
8657:
8658:
8659:
8660:
8661:
8662:
8663: busSuper (MemoryMappedDevice.MMD_GE0, 0x00c00000, 0x00c80000);
8664: busSuper (MemoryMappedDevice.MMD_GE1, 0x00c80000, 0x00d00000);
8665: busSuper (MemoryMappedDevice.MMD_GE2, 0x00d00000, 0x00d80000);
8666: busSuper (MemoryMappedDevice.MMD_GE3, 0x00d80000, 0x00e00000);
8667:
8668:
8669:
8670:
8671: busSuper (MemoryMappedDevice.MMD_TXT, 0x00e00000, 0x00e80000);
8672:
8673:
8674:
8675:
8676: busSuper (MemoryMappedDevice.MMD_CRT, 0x00e80000, 0x00e82000);
8677:
8678:
8679:
8680:
8681:
8682: busSuper (MemoryMappedDevice.MMD_VCN, 0x00e82000, 0x00e84000);
8683:
8684:
8685:
8686:
8687: busSuper (MemoryMappedDevice.MMD_DMA, 0x00e84000, 0x00e86000);
8688:
8689:
8690:
8691:
8692: busSuper (MemoryMappedDevice.MMD_SVS, 0x00e86000, 0x00e88000);
8693:
8694:
8695:
8696:
8697: busSuper (MemoryMappedDevice.MMD_MFP, 0x00e88000, 0x00e8a000);
8698:
8699:
8700:
8701:
8702: busSuper (MemoryMappedDevice.MMD_RTC_FIRST, 0x00e8a000, 0x00e8c000);
8703:
8704:
8705:
8706:
8707: busSuper (MemoryMappedDevice.MMD_PRN, 0x00e8c000, 0x00e8e000);
8708:
8709:
8710:
8711:
8712: busSuper (MemoryMappedDevice.MMD_SYS, 0x00e8e000, 0x00e90000);
8713:
8714:
8715:
8716:
8717: busSuper (MemoryMappedDevice.MMD_OPM, 0x00e90000, 0x00e92000);
8718:
8719:
8720:
8721:
8722: busSuper (MemoryMappedDevice.MMD_PCM, 0x00e92000, 0x00e94000);
8723:
8724:
8725:
8726:
8727: busSuper (MemoryMappedDevice.MMD_FDC, 0x00e94000, 0x00e96000);
8728:
8729:
8730:
8731:
8732:
8733: busSuper (MemoryMappedDevice.MMD_HDC, 0x00e96000, 0x00e98000);
8734:
8735:
8736:
8737:
8738: busSuper (MemoryMappedDevice.MMD_SCC, 0x00e98000, 0x00e9a000);
8739:
8740:
8741:
8742:
8743: busSuper (MemoryMappedDevice.MMD_PPI, 0x00e9a000, 0x00e9c000);
8744:
8745:
8746:
8747:
8748: busSuper (MemoryMappedDevice.MMD_IOI, 0x00e9c000, 0x00e9e000);
8749:
8750:
8751:
8752:
8753:
8754:
8755:
8756:
8757:
8758: busSuper (MemoryMappedDevice.MMD_XB1, 0x00e9e000, 0x00ea0000);
8759:
8760:
8761:
8762:
8763:
8764: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ea0000, 0x00eae000);
8765:
8766:
8767:
8768:
8769:
8770:
8771:
8772:
8773:
8774:
8775:
8776:
8777:
8778:
8779:
8780: busSuper (MemoryMappedDevice.MMD_XB2, 0x00eae000, 0x00eb0000);
8781:
8782:
8783:
8784:
8785:
8786:
8787:
8788:
8789: busSuper (MemoryMappedDevice.MMD_SPR, 0x00eb0000, 0x00ec0000);
8790:
8791:
8792:
8793:
8794:
8795:
8796:
8797:
8798:
8799:
8800:
8801:
8802:
8803: busSuper (MemoryMappedDevice.MMD_XB3, 0x00ec0000, 0x00ed0000);
8804:
8805:
8806:
8807:
8808:
8809:
8810: busSuper (MemoryMappedDevice.MMD_SMR, 0x00ed0000, 0x00ed0000 + 16384);
8811: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ed0000 + 16384, 0x00ed0000 + 65536);
8812:
8813:
8814:
8815:
8816:
8817:
8818:
8819:
8820: busSuper (MemoryMappedDevice.MMD_XB4, 0x00ee0000, 0x00f00000);
8821:
8822:
8823:
8824:
8825:
8826:
8827:
8828:
8829:
8830:
8831: busSuper (MemoryMappedDevice.MMD_ROM, 0x00f00000, 0x00f40000);
8832:
8833:
8834:
8835:
8836:
8837:
8838:
8839: busSuper (MemoryMappedDevice.MMD_ROM, 0x00f40000, 0x00fc0000);
8840:
8841:
8842:
8843:
8844:
8845:
8846:
8847:
8848:
8849:
8850:
8851:
8852:
8853:
8854: busSuper (MemoryMappedDevice.MMD_ROM, 0x00fc0000, 0x01000000);
8855:
8856: }
8857:
8858: public static void busReset () {
8859: if (regSRS != 0) {
8860: if (DataBreakPoint.DBP_ON) {
8861: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpSuperMap;
8862: } else {
8863: busMemoryMap = busSuperMap;
8864: }
8865: } else {
8866: if (DataBreakPoint.DBP_ON) {
8867: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpUserMap;
8868: } else {
8869: busMemoryMap = busUserMap;
8870: }
8871: }
8872: }
8873:
8874:
8875:
8876:
8877:
8878: public static void busUser (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8879: if (MC68060.CAT_ON) {
8880: if (Model.MPU_MC68LC060 <= currentMPU) {
8881: mmd = (mmd == MemoryMappedDevice.MMD_MMR ? MemoryMappedDevice.MMD_MM6 :
8882: mmd == MemoryMappedDevice.MMD_ROM ? MemoryMappedDevice.MMD_RO6 :
8883: mmd);
8884: }
8885: }
8886: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8887: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8888: if (false &&
8889: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8890: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8891: System.out.printf ("ERROR: busUser (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8892: }
8893: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8894: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8895: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8896: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8897: int startPage = blockStartPage + motherStartPage;
8898: int endPage = blockStartPage + motherEndPage;
8899: for (int page = startPage; page < endPage; page++) {
8900: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
8901: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
8902: if (MC68060.CAT_ON) {
8903: if (Model.MPU_MC68LC060 <= currentMPU &&
8904: isExMemory) {
8905: superMmd = MemoryMappedDevice.MMD_XM6;
8906: }
8907: }
8908: busUserMap[page] = busSuperMap[page] = superMmd;
8909: if (InstructionBreakPoint.IBP_ON) {
8910: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8911: InstructionBreakPoint.ibpUserMap[page] = superMmd;
8912: }
8913: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8914: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8915: }
8916: }
8917: if (DataBreakPoint.DBP_ON) {
8918: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8919: DataBreakPoint.dbpUserMap[page] = superMmd;
8920: }
8921: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8922: DataBreakPoint.dbpSuperMap[page] = superMmd;
8923: }
8924: }
8925: }
8926: }
8927: }
8928:
8929:
8930:
8931:
8932:
8933: public static void busSuper (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8934: if (MC68060.CAT_ON) {
8935: if (Model.MPU_MC68LC060 <= currentMPU) {
8936: mmd = (mmd == MemoryMappedDevice.MMD_MMR ? MemoryMappedDevice.MMD_MM6 :
8937: mmd == MemoryMappedDevice.MMD_ROM ? MemoryMappedDevice.MMD_RO6 :
8938: mmd);
8939: }
8940: }
8941: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8942: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8943: if (false &&
8944: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8945: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8946: System.out.printf ("ERROR: busSuper (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8947: }
8948: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8949: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8950: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8951: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8952: int startPage = blockStartPage + motherStartPage;
8953: int endPage = blockStartPage + motherEndPage;
8954: for (int page = startPage; page < endPage; page++) {
8955: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
8956: MemoryMappedDevice userMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : busCutFC2Pin ? mmd : MemoryMappedDevice.MMD_NUL;
8957: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
8958: if (MC68060.CAT_ON) {
8959: if (Model.MPU_MC68LC060 <= currentMPU &&
8960: isExMemory) {
8961: userMmd = MemoryMappedDevice.MMD_XM6;
8962: superMmd = MemoryMappedDevice.MMD_XM6;
8963: }
8964: }
8965: busUserMap[page] = userMmd;
8966: busSuperMap[page] = superMmd;
8967: if (InstructionBreakPoint.IBP_ON) {
8968: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8969: InstructionBreakPoint.ibpUserMap[page] = userMmd;
8970: }
8971: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8972: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8973: }
8974: }
8975: if (DataBreakPoint.DBP_ON) {
8976: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8977: DataBreakPoint.dbpUserMap[page] = userMmd;
8978: }
8979: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8980: DataBreakPoint.dbpSuperMap[page] = superMmd;
8981: }
8982: }
8983: }
8984: }
8985: }
8986:
8987:
8988:
8989: public static byte busPbs (int a) {
8990: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a);
8991: }
8992:
8993:
8994:
8995: public static int busPbz (int a) {
8996: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a);
8997: }
8998:
8999:
9000:
9001: public static int busPws (int a) {
9002: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9003: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
9004: } else {
9005: int a1 = a + 1;
9006: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
9007: }
9008: }
9009:
9010:
9011:
9012: public static int busPwse (int a) {
9013: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
9014: }
9015:
9016:
9017:
9018: public static int busPwz (int a) {
9019: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9020: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
9021: } else {
9022: int a1 = a + 1;
9023: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
9024: }
9025: }
9026:
9027:
9028:
9029: public static int busPwze (int a) {
9030: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
9031: }
9032:
9033:
9034:
9035: public static int busPls (int a) {
9036: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9037: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
9038: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9039: int a2 = a + 2;
9040: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a) << 16 | busSuperMap[a2 >>> BUS_PAGE_BITS].mmdPwz (a2);
9041: } else {
9042: int a1 = a + 1;
9043: int a3 = a + 3;
9044: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 24 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPwz (a1) << 8 | busSuperMap[a3 >>> BUS_PAGE_BITS].mmdPbz (a3);
9045: }
9046: }
9047:
9048:
9049:
9050: public static int busPlsf (int a) {
9051: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
9052: }
9053:
9054:
9055:
9056: public static long busPqs (int a) {
9057: return (long) busPls (a) << 32 | busPls (a + 4) & 0xffffffffL;
9058: }
9059:
9060:
9061:
9062: public static int busSearchByte (int start, int end, int c) {
9063: for (int a = start; a < end; a++) {
9064: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) == c) {
9065: return a;
9066: }
9067: }
9068: return -1;
9069: }
9070: public static int busSearchWord (int start, int end, int c) {
9071: for (int a = start; a < end; a += 2) {
9072: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) == c) {
9073: return a;
9074: }
9075: }
9076: return -1;
9077: }
9078: public static int busSearchByteArray (int start, int end, int[] array) {
9079: int l = array.length;
9080: end -= l;
9081: int c = array[0];
9082: a:
9083: for (int a = start; a <= end; a++) {
9084: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) != c) {
9085: continue a;
9086: }
9087: for (int i = 1, b = a + 1; i < l; i++, b++) {
9088: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPbz (b) != array[i]) {
9089: continue a;
9090: }
9091: }
9092: return a;
9093: }
9094: return -1;
9095: }
9096: public static int busSearchWordArray (int start, int end, int[] array) {
9097: int l = array.length;
9098: end -= l;
9099: int c = array[0];
9100: a:
9101: for (int a = start; a <= end; a += 2) {
9102: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) != c) {
9103: continue a;
9104: }
9105: for (int i = 1, b = a + 2; i < l; i++, b += 2) {
9106: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPwz (b) != array[i]) {
9107: continue a;
9108: }
9109: }
9110: return a;
9111: }
9112: return -1;
9113: }
9114:
9115:
9116:
9117:
9118: public static byte busRbs (int a) throws M68kException {
9119: if (DataBreakPoint.DBP_ON) {
9120: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
9121: } else {
9122: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
9123: }
9124: }
9125:
9126:
9127:
9128: public static int busRbz (int a) throws M68kException {
9129: if (DataBreakPoint.DBP_ON) {
9130: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
9131: } else {
9132: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
9133: }
9134: }
9135:
9136:
9137:
9138: public static int busRws (int a) throws M68kException {
9139: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9140: if (DataBreakPoint.DBP_ON) {
9141: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
9142: } else {
9143: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
9144: }
9145: } else if (mpuIgnoreAddressError) {
9146: int a1 = a + 1;
9147: if (DataBreakPoint.DBP_ON) {
9148: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
9149: } else {
9150: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
9151: }
9152: } else {
9153: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9154: M68kException.m6eAddress = a;
9155: M68kException.m6eDirection = MPU_WR_READ;
9156: M68kException.m6eSize = MPU_SS_WORD;
9157: throw M68kException.m6eSignal;
9158: }
9159: }
9160:
9161:
9162:
9163:
9164: public static int busRwse (int a) throws M68kException {
9165: if (DataBreakPoint.DBP_ON) {
9166: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
9167: } else {
9168: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
9169: }
9170: }
9171:
9172:
9173:
9174: public static int busRwz (int a) throws M68kException {
9175: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9176: if (DataBreakPoint.DBP_ON) {
9177: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9178: } else {
9179: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9180: }
9181: } else if (mpuIgnoreAddressError) {
9182: int a1 = a + 1;
9183: if (DataBreakPoint.DBP_ON) {
9184: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
9185: } else {
9186: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
9187: }
9188: } else {
9189: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9190: M68kException.m6eAddress = a;
9191: M68kException.m6eDirection = MPU_WR_READ;
9192: M68kException.m6eSize = MPU_SS_WORD;
9193: throw M68kException.m6eSignal;
9194: }
9195: }
9196:
9197:
9198:
9199:
9200: public static int busRwze (int a) throws M68kException {
9201: if (DataBreakPoint.DBP_ON) {
9202: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9203: } else {
9204: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9205: }
9206: }
9207:
9208:
9209:
9210: public static int busRls (int a) throws M68kException {
9211: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9212: if (DataBreakPoint.DBP_ON) {
9213: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9214: } else {
9215: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9216: }
9217: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9218: int a2 = a + 2;
9219: if (BUS_SPLIT_UNALIGNED_LONG) {
9220: if (DataBreakPoint.DBP_ON) {
9221: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9222: } else {
9223: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9224: }
9225: } else {
9226: MemoryMappedDevice mmd;
9227: MemoryMappedDevice mmd2;
9228: if (DataBreakPoint.DBP_ON) {
9229: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9230: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9231: } else {
9232: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9233: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9234: }
9235: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
9236: }
9237: } else if (mpuIgnoreAddressError) {
9238: int a1 = a + 1;
9239: int a3 = a + 3;
9240: if (DataBreakPoint.DBP_ON) {
9241: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 24 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRwz (a1) << 8 | DataBreakPoint.dbpMemoryMap[a3 >>> BUS_PAGE_BITS].mmdRbz (a3);
9242: } else {
9243: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 24 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRwz (a1) << 8 | busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdRbz (a3);
9244: }
9245: } else {
9246: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9247: M68kException.m6eAddress = a;
9248: M68kException.m6eDirection = MPU_WR_READ;
9249: M68kException.m6eSize = MPU_SS_LONG;
9250: throw M68kException.m6eSignal;
9251: }
9252: }
9253:
9254:
9255:
9256:
9257: public static int busRlse (int a) throws M68kException {
9258: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9259: if (DataBreakPoint.DBP_ON) {
9260: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9261: } else {
9262: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9263: }
9264: } else {
9265: int a2 = a + 2;
9266: if (BUS_SPLIT_UNALIGNED_LONG) {
9267: if (DataBreakPoint.DBP_ON) {
9268: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9269: } else {
9270: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9271: }
9272: } else {
9273: MemoryMappedDevice mmd;
9274: MemoryMappedDevice mmd2;
9275: if (DataBreakPoint.DBP_ON) {
9276: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9277: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9278: } else {
9279: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9280: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9281: }
9282: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
9283: }
9284: }
9285: }
9286:
9287:
9288:
9289:
9290: public static int busRlsf (int a) throws M68kException {
9291: if (DataBreakPoint.DBP_ON) {
9292: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9293: } else {
9294: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9295: }
9296: }
9297:
9298:
9299:
9300: public static long busRqs (int a) throws M68kException {
9301: return (long) busRls (a) << 32 | busRls (a + 4) & 0xffffffffL;
9302: }
9303:
9304:
9305:
9306: public static void busWb (int a, int d) throws M68kException {
9307: if (DataBreakPoint.DBP_ON) {
9308: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9309: } else {
9310: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9311: }
9312: }
9313:
9314:
9315:
9316: public static void busWw (int a, int d) throws M68kException {
9317: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9318: if (DataBreakPoint.DBP_ON) {
9319: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9320: } else {
9321: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9322: }
9323: } else if (mpuIgnoreAddressError) {
9324: int a1 = a + 1;
9325: if (DataBreakPoint.DBP_ON) {
9326: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
9327: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
9328: } else {
9329: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
9330: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
9331: }
9332: } else {
9333: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9334: M68kException.m6eAddress = a;
9335: M68kException.m6eDirection = MPU_WR_WRITE;
9336: M68kException.m6eSize = MPU_SS_WORD;
9337: throw M68kException.m6eSignal;
9338: }
9339: }
9340:
9341:
9342:
9343:
9344: public static void busWwe (int a, int d) throws M68kException {
9345: if (DataBreakPoint.DBP_ON) {
9346: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9347: } else {
9348: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9349: }
9350: }
9351:
9352:
9353:
9354: public static void busWl (int a, int d) throws M68kException {
9355: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9356: if (DataBreakPoint.DBP_ON) {
9357: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9358: } else {
9359: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9360: }
9361: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9362: int a2 = a + 2;
9363: if (BUS_SPLIT_UNALIGNED_LONG) {
9364: if (DataBreakPoint.DBP_ON) {
9365: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9366: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9367: } else {
9368: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9369: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9370: }
9371: } else {
9372: MemoryMappedDevice mmd;
9373: MemoryMappedDevice mmd2;
9374: if (DataBreakPoint.DBP_ON) {
9375: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9376: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9377: } else {
9378: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9379: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9380: }
9381: if (mmd == mmd2) {
9382: mmd.mmdWl (a, d);
9383: } else {
9384: mmd.mmdWw (a, d >> 16);
9385: mmd2.mmdWw (a2, d);
9386: }
9387: }
9388: } else if (mpuIgnoreAddressError) {
9389: int a1 = a + 1;
9390: int a3 = a + 3;
9391: if (DataBreakPoint.DBP_ON) {
9392: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
9393: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
9394: DataBreakPoint.dbpMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
9395: } else {
9396: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
9397: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
9398: busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
9399: }
9400: } else {
9401: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9402: M68kException.m6eAddress = a;
9403: M68kException.m6eDirection = MPU_WR_WRITE;
9404: M68kException.m6eSize = MPU_SS_LONG;
9405: throw M68kException.m6eSignal;
9406: }
9407: }
9408:
9409:
9410:
9411:
9412: public static void busWlf (int a, int d) throws M68kException {
9413: if (DataBreakPoint.DBP_ON) {
9414: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9415: } else {
9416: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9417: }
9418: }
9419:
9420:
9421:
9422:
9423: public static void busWle (int a, int d) throws M68kException {
9424: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9425: if (DataBreakPoint.DBP_ON) {
9426: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9427: } else {
9428: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9429: }
9430: } else {
9431: int a2 = a + 2;
9432: if (BUS_SPLIT_UNALIGNED_LONG) {
9433: if (DataBreakPoint.DBP_ON) {
9434: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9435: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9436: } else {
9437: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9438: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9439: }
9440: } else {
9441: MemoryMappedDevice mmd;
9442: MemoryMappedDevice mmd2;
9443: if (DataBreakPoint.DBP_ON) {
9444: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9445: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9446: } else {
9447: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9448: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9449: }
9450: if (mmd == mmd2) {
9451: mmd.mmdWl (a, d);
9452: } else {
9453: mmd.mmdWw (a, d >> 16);
9454: mmd2.mmdWw (a2, d);
9455: }
9456: }
9457: }
9458: }
9459:
9460:
9461:
9462: public static void busWq (int a, long d) throws M68kException {
9463: busWl (a, (int) (d >>> 32));
9464: busWl (a + 4, (int) d);
9465: }
9466:
9467:
9468:
9469:
9470:
9471: public static void busRbb (int a, byte[] bb, int o, int l) throws M68kException {
9472: if (false) {
9473: for (int i = 0; i < l; i++) {
9474: int ai = a + i;
9475: if (DataBreakPoint.DBP_ON) {
9476: bb[o + i] = DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9477: } else {
9478: bb[o + i] = busMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9479: }
9480: }
9481: } else {
9482: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9483: while (l > 0) {
9484: MemoryMappedDevice mmd;
9485: if (DataBreakPoint.DBP_ON) {
9486: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9487: } else {
9488: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9489: }
9490: int s = l <= r ? l : r;
9491: l -= s;
9492: if (true) {
9493: for (s -= 16; s >= 0; s -= 16) {
9494: bb[o ] = mmd.mmdRbs (a );
9495: bb[o + 1] = mmd.mmdRbs (a + 1);
9496: bb[o + 2] = mmd.mmdRbs (a + 2);
9497: bb[o + 3] = mmd.mmdRbs (a + 3);
9498: bb[o + 4] = mmd.mmdRbs (a + 4);
9499: bb[o + 5] = mmd.mmdRbs (a + 5);
9500: bb[o + 6] = mmd.mmdRbs (a + 6);
9501: bb[o + 7] = mmd.mmdRbs (a + 7);
9502: bb[o + 8] = mmd.mmdRbs (a + 8);
9503: bb[o + 9] = mmd.mmdRbs (a + 9);
9504: bb[o + 10] = mmd.mmdRbs (a + 10);
9505: bb[o + 11] = mmd.mmdRbs (a + 11);
9506: bb[o + 12] = mmd.mmdRbs (a + 12);
9507: bb[o + 13] = mmd.mmdRbs (a + 13);
9508: bb[o + 14] = mmd.mmdRbs (a + 14);
9509: bb[o + 15] = mmd.mmdRbs (a + 15);
9510: a += 16;
9511: o += 16;
9512: }
9513: s += 16;
9514: }
9515: for (int i = 0; i < s; i++) {
9516: bb[o + i] = mmd.mmdRbs (a + i);
9517: }
9518: a += s;
9519: o += s;
9520: r = BUS_PAGE_SIZE;
9521: }
9522: }
9523: }
9524:
9525:
9526:
9527: public static void busWbb (int a, byte[] bb, int o, int l) throws M68kException {
9528: if (false) {
9529: for (int i = 0; i < l; i++) {
9530: int ai = a + i;
9531: if (DataBreakPoint.DBP_ON) {
9532: DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9533: } else {
9534: busMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9535: }
9536: }
9537: } else {
9538: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9539: while (l > 0) {
9540: MemoryMappedDevice mmd;
9541: if (DataBreakPoint.DBP_ON) {
9542: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9543: } else {
9544: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9545: }
9546: int s = l <= r ? l : r;
9547: l -= s;
9548: if (true) {
9549: for (s -= 16; s >= 0; s -= 16) {
9550: mmd.mmdWb (a , bb[o ]);
9551: mmd.mmdWb (a + 1, bb[o + 1]);
9552: mmd.mmdWb (a + 2, bb[o + 2]);
9553: mmd.mmdWb (a + 3, bb[o + 3]);
9554: mmd.mmdWb (a + 4, bb[o + 4]);
9555: mmd.mmdWb (a + 5, bb[o + 5]);
9556: mmd.mmdWb (a + 6, bb[o + 6]);
9557: mmd.mmdWb (a + 7, bb[o + 7]);
9558: mmd.mmdWb (a + 8, bb[o + 8]);
9559: mmd.mmdWb (a + 9, bb[o + 9]);
9560: mmd.mmdWb (a + 10, bb[o + 10]);
9561: mmd.mmdWb (a + 11, bb[o + 11]);
9562: mmd.mmdWb (a + 12, bb[o + 12]);
9563: mmd.mmdWb (a + 13, bb[o + 13]);
9564: mmd.mmdWb (a + 14, bb[o + 14]);
9565: mmd.mmdWb (a + 15, bb[o + 15]);
9566: a += 16;
9567: o += 16;
9568: }
9569: s += 16;
9570: }
9571: for (int i = 0; i < s; i++) {
9572: mmd.mmdWb (a + i, bb[o + i]);
9573: }
9574: a += s;
9575: o += s;
9576: r = BUS_PAGE_SIZE;
9577: }
9578: }
9579: }
9580:
9581:
9582:
9583: public static void busVb (int a, int d) {
9584: try {
9585: if (DataBreakPoint.DBP_ON) {
9586: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9587: } else {
9588: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9589: }
9590: } catch (M68kException e) {
9591: }
9592: }
9593:
9594:
9595:
9596: public static void busVw (int a, int d) {
9597: try {
9598: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9599: if (DataBreakPoint.DBP_ON) {
9600: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9601: } else {
9602: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9603: }
9604: }
9605: } catch (M68kException e) {
9606: }
9607: }
9608:
9609:
9610:
9611: public static void busVl (int a, int d) {
9612: try {
9613: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9614: if (DataBreakPoint.DBP_ON) {
9615: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9616: } else {
9617: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9618: }
9619: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9620: int a2 = a + 2;
9621: MemoryMappedDevice mmd;
9622: MemoryMappedDevice mmd2;
9623: if (DataBreakPoint.DBP_ON) {
9624: mmd = (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS];
9625: mmd2 = (regSRS != 0 ? busSuperMap : busUserMap)[a2 >>> BUS_PAGE_BITS];
9626: } else {
9627: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9628: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9629: }
9630: if (mmd == mmd2) {
9631: mmd.mmdWl (a, d);
9632: } else {
9633: mmd.mmdWw (a, d >> 16);
9634: mmd2.mmdWw (a2, d);
9635: }
9636: }
9637: } catch (M68kException e) {
9638: }
9639: }
9640:
9641:
9642:
9643:
9644:
9645: public static final int SVS_AREASET = 0x00e86001;
9646:
9647:
9648:
9649:
9650:
9651:
9652:
9653:
9654:
9655: public static void svsInit () {
9656: }
9657:
9658:
9659:
9660:
9661:
9662:
9663:
9664:
9665:
9666:
9667:
9668:
9669:
9670:
9671:
9672:
9673:
9674:
9675:
9676:
9677:
9678:
9679:
9680:
9681:
9682:
9683:
9684:
9685:
9686:
9687:
9688:
9689:
9690:
9691:
9692: public static boolean sysNMIFlag;
9693:
9694:
9695:
9696: public static void sysInit () {
9697: sysNMIFlag = false;
9698: }
9699:
9700:
9701:
9702:
9703:
9704:
9705: public static int sysAcknowledge () {
9706: return M68kException.M6E_LEVEL_7_INTERRUPT_AUTOVECTOR;
9707: }
9708:
9709:
9710:
9711:
9712: public static void sysDone () {
9713: if (sysNMIFlag) {
9714: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9715: }
9716: }
9717:
9718:
9719:
9720: public static void sysInterrupt () {
9721: sysNMIFlag = true;
9722: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9723: }
9724:
9725:
9726:
9727: public static void sysResetNMI () {
9728: sysNMIFlag = false;
9729: }
9730:
9731:
9732:
9733:
9734:
9735:
9736: public static final int EB2_SPC_REQUEST = 0x4000;
9737: public static final int EB2_SPC_VECTOR = 0xf6;
9738:
9739:
9740:
9741: public static int eb2Request;
9742:
9743:
9744:
9745: public static void eb2Reset () {
9746: eb2Request = 0;
9747: }
9748:
9749:
9750:
9751:
9752:
9753: public static void eb2Interrupt (int mask) {
9754: eb2Request |= mask;
9755: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9756: }
9757:
9758:
9759:
9760:
9761:
9762:
9763:
9764: public static int eb2Acknowledge () {
9765: if ((eb2Request & EB2_SPC_REQUEST) != 0) {
9766: eb2Request &= ~EB2_SPC_REQUEST;
9767: return EB2_SPC_VECTOR;
9768: }
9769: return 0;
9770: }
9771:
9772:
9773:
9774:
9775:
9776: public static void eb2Done () {
9777: if (eb2Request != 0) {
9778: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9779: }
9780: }
9781:
9782:
9783:
9784:
9785:
9786:
9787:
9788:
9789:
9790:
9791:
9792:
9793:
9794:
9795:
9796:
9797:
9798:
9799:
9800:
9801:
9802:
9803:
9804:
9805:
9806:
9807:
9808:
9809:
9810:
9811:
9812:
9813:
9814:
9815:
9816:
9817:
9818:
9819:
9820:
9821:
9822:
9823:
9824:
9825:
9826:
9827:
9828:
9829:
9830:
9831:
9832:
9833:
9834:
9835:
9836:
9837:
9838:
9839:
9840:
9841:
9842:
9843:
9844:
9845: public static final int BNK_SIZE = 1024 * 1024 * 32;
9846: public static byte[] bnkMemory;
9847: public static int bnkPageStart;
9848: public static boolean bnkOn;
9849:
9850: public static void bnkInit () {
9851: bnkMemory = new byte[BNK_SIZE];
9852: byte[] array = Settings.sgsGetData ("bankdata");
9853: if (array.length != 0) {
9854: System.arraycopy (array, 0, bnkMemory, 0, Math.min (array.length, BNK_SIZE));
9855: }
9856: bnkPageStart = 0;
9857:
9858: bnkOn = false;
9859: }
9860:
9861: public static void bnkTini () {
9862: Settings.sgsPutData ("bankdata", bnkMemory, 0, BNK_SIZE);
9863: }
9864:
9865:
9866:
9867:
9868:
9869:
9870:
9871: public static ExpressionEvaluator fpuMotherboardCoprocessor;
9872: public static ExpressionEvaluator fpuOnChipFPU;
9873: public static ExpressionEvaluator fpuBox;
9874:
9875:
9876: public static EFPBox fpuCoproboard1;
9877: public static EFPBox fpuCoproboard2;
9878:
9879:
9880: public static EFPBox.EFP[] fpuFPn;
9881:
9882:
9883:
9884: public static final int FPU_FPCR_BSUN = 0b00000000_00000000_10000000_00000000;
9885: public static final int FPU_FPCR_SNAN = 0b00000000_00000000_01000000_00000000;
9886: public static final int FPU_FPCR_OPERR = 0b00000000_00000000_00100000_00000000;
9887: public static final int FPU_FPCR_OVFL = 0b00000000_00000000_00010000_00000000;
9888: public static final int FPU_FPCR_UNFL = 0b00000000_00000000_00001000_00000000;
9889: public static final int FPU_FPCR_DZ = 0b00000000_00000000_00000100_00000000;
9890: public static final int FPU_FPCR_INEX2 = 0b00000000_00000000_00000010_00000000;
9891: public static final int FPU_FPCR_INEX1 = 0b00000000_00000000_00000001_00000000;
9892:
9893:
9894: public static final int FPU_FPCR_PE = 0b00000000_00000000_00000000_00000000;
9895: public static final int FPU_FPCR_PS = 0b00000000_00000000_00000000_01000000;
9896: public static final int FPU_FPCR_PD = 0b00000000_00000000_00000000_10000000;
9897:
9898: public static final int FPU_FPCR_RN = 0b00000000_00000000_00000000_00000000;
9899: public static final int FPU_FPCR_RZ = 0b00000000_00000000_00000000_00010000;
9900: public static final int FPU_FPCR_RM = 0b00000000_00000000_00000000_00100000;
9901: public static final int FPU_FPCR_RP = 0b00000000_00000000_00000000_00110000;
9902:
9903:
9904:
9905: public static final int FPU_FPSR_N = 0b00001000_00000000_00000000_00000000;
9906: public static final int FPU_FPSR_Z = 0b00000100_00000000_00000000_00000000;
9907: public static final int FPU_FPSR_I = 0b00000010_00000000_00000000_00000000;
9908: public static final int FPU_FPSR_NAN = 0b00000001_00000000_00000000_00000000;
9909:
9910: public static final int FPU_FPSR_S = 0b00000000_10000000_00000000_00000000;
9911: public static final int FPU_FPSR_QUOTIENT = 0b00000000_01111111_00000000_00000000;
9912:
9913: public static final int FPU_FPSR_EXC_BSUN = 0b00000000_00000000_10000000_00000000;
9914: public static final int FPU_FPSR_EXC_SNAN = 0b00000000_00000000_01000000_00000000;
9915: public static final int FPU_FPSR_EXC_OPERR = 0b00000000_00000000_00100000_00000000;
9916: public static final int FPU_FPSR_EXC_OVFL = 0b00000000_00000000_00010000_00000000;
9917: public static final int FPU_FPSR_EXC_UNFL = 0b00000000_00000000_00001000_00000000;
9918: public static final int FPU_FPSR_EXC_DZ = 0b00000000_00000000_00000100_00000000;
9919: public static final int FPU_FPSR_EXC_INEX2 = 0b00000000_00000000_00000010_00000000;
9920: public static final int FPU_FPSR_EXC_INEX1 = 0b00000000_00000000_00000001_00000000;
9921:
9922: public static final int FPU_FPSR_AEXC_IOP = 0b00000000_00000000_00000000_10000000;
9923: public static final int FPU_FPSR_AEXC_OVFL = 0b00000000_00000000_00000000_01000000;
9924: public static final int FPU_FPSR_AEXC_UNFL = 0b00000000_00000000_00000000_00100000;
9925: public static final int FPU_FPSR_AEXC_DZ = 0b00000000_00000000_00000000_00010000;
9926: public static final int FPU_FPSR_AEXC_INEX = 0b00000000_00000000_00000000_00001000;
9927:
9928:
9929:
9930:
9931:
9932:
9933:
9934: public static final int[] FPU_FPSR_EXC_TO_AEXC = new int[256];
9935:
9936:
9937:
9938:
9939:
9940:
9941:
9942:
9943:
9944:
9945:
9946:
9947:
9948:
9949:
9950:
9951:
9952:
9953:
9954:
9955:
9956:
9957:
9958:
9959: public static final boolean[] FPU_CCMAP_882 = {
9960:
9961:
9962: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9963: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9964: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9965: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9966: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9967: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9968: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9969: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9970: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9971: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9972: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9973: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9974: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9975: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9976: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9977: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9978:
9979:
9980: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9981: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9982: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9983: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9984: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9985: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9986: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9987: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9988: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9989: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9990: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9991: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9992: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9993: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9994: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9995: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9996:
9997: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9998: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9999: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10000: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10001: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10002: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10003: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10004: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
10005: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10006: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10007: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10008: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10009: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10010: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10011: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
10012: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10013:
10014: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10015: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10016: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10017: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10018: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10019: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10020: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10021: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
10022: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10023: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10024: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10025: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10026: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10027: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10028: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
10029: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10030: };
10031:
10032:
10033:
10034:
10035:
10036:
10037:
10038: public static final boolean[] FPU_CCMAP_060 = {
10039:
10040:
10041: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10042: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10043: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10044: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10045: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10046: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10047: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10048: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
10049: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10050: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10051: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10052: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10053: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10054: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10055: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
10056: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10057:
10058:
10059: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10060: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10061: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10062: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10063: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10064: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10065: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10066: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
10067: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10068: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10069: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10070: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10071: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10072: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10073: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
10074: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10075:
10076: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10077: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10078: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10079: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10080: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10081: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10082: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10083: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
10084: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10085: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10086: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10087: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10088: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10089: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10090: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
10091: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10092:
10093: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10094: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10095: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10096: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10097: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10098: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10099: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10100: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
10101: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10102: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10103: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10104: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10105: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10106: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10107: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
10108: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10109: };
10110:
10111:
10112:
10113:
10114: public static void fpuInit () {
10115: for (int i = 0; i < 256; i++) {
10116: FPU_FPSR_EXC_TO_AEXC[i] = (((i << 8 & (FPU_FPSR_EXC_BSUN | FPU_FPSR_EXC_SNAN | FPU_FPSR_EXC_OPERR)) != 0 ? FPU_FPSR_AEXC_IOP : 0) |
10117: ((i << 8 & FPU_FPSR_EXC_OVFL) != 0 ? FPU_FPSR_AEXC_OVFL : 0) |
10118: ((i << 8 & (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2)) == (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2) ? FPU_FPSR_AEXC_UNFL : 0) |
10119: ((i << 8 & FPU_FPSR_EXC_DZ) != 0 ? FPU_FPSR_AEXC_DZ : 0) |
10120: ((i << 8 & (FPU_FPSR_EXC_OVFL | FPU_FPSR_EXC_INEX2 | FPU_FPSR_EXC_INEX1)) != 0 ? FPU_FPSR_AEXC_INEX : 0));
10121: }
10122:
10123: fpuMotherboardCoprocessor = new ExpressionEvaluator ();
10124:
10125: fpuOnChipFPU = new ExpressionEvaluator ();
10126:
10127: fpuBox = currentMPU < Model.MPU_MC68LC040 ? fpuMotherboardCoprocessor : fpuOnChipFPU;
10128:
10129: fpuFPn = fpuBox.epbFPn;
10130:
10131: fpuCoproboard1 = new EFPBox ();
10132: fpuCoproboard2 = new EFPBox ();
10133: }
10134:
10135:
10136:
10137:
10138:
10139:
10140: public static final boolean DBG_ORI_BYTE_ZERO_D0 = true;
10141:
10142: public static boolean dbgHexSelected;
10143: public static int dbgHexValue;
10144: public static int dbgSupervisorMode;
10145: public static JPopupMenu dbgPopupMenu;
10146: public static JMenu dbgPopupIBPMenu;
10147: public static SpinnerNumberModel dbgPopupIBPCurrentModel;
10148: public static int dbgPopupIBPCurrentValue;
10149: public static SpinnerNumberModel dbgPopupIBPThresholdModel;
10150: public static int dbgPopupIBPThresholdValue;
10151: public static JMenuItem dbgPopupIBPClearMenuItem;
10152: public static JMenu dbgPopupHexMenu;
10153: public static JMenuItem dbgPopupDisMenuItem;
10154: public static JMenuItem dbgPopupMemMenuItem;
10155: public static JMenuItem dbgPopupCopyMenuItem;
10156: public static JMenuItem dbgPopupSelectAllMenuItem;
10157: public static JTextArea dbgPopupTextArea;
10158: public static int dbgEventMask;
10159: public static boolean dbgStopOnError;
10160: public static boolean dbgOriByteZeroD0;
10161: public static boolean dbgStopAtStart;
10162:
10163:
10164:
10165: public static final char[] DBG_SPACES = (
10166:
10167:
10168: " ").toCharArray ();
10169:
10170: public static final int DBG_DRP_VISIBLE_MASK = 1;
10171: public static final int DBG_DDP_VISIBLE_MASK = 2;
10172: public static final int DBG_DMP_VISIBLE_MASK = 4;
10173: public static final int DBG_BLG_VISIBLE_MASK = 8;
10174: public static final int DBG_PFV_VISIBLE_MASK = 16;
10175: public static final int DBG_RBP_VISIBLE_MASK = 32;
10176: public static final int DBG_DBP_VISIBLE_MASK = 64;
10177: public static final int DBG_SMT_VISIBLE_MASK = 128;
10178: public static final int DBG_ATW_VISIBLE_MASK = 256;
10179: public static final int DBG_PAA_VISIBLE_MASK = 512;
10180: public static final int DBG_RTL_VISIBLE_MASK = 1024;
10181: public static final int DBG_SPV_VISIBLE_MASK = 2048;
10182: public static final int DBG_PLV_VISIBLE_MASK = 4096;
10183: public static final int DBG_ACM_VISIBLE_MASK = 8192;
10184: public static int dbgVisibleMask;
10185:
10186:
10187:
10188: public static void dbgInit () {
10189: dbgVisibleMask = 0;
10190: dbgHexSelected = false;
10191: dbgHexValue = 0;
10192: dbgSupervisorMode = 1;
10193: dbgPopupMenu = null;
10194: dbgPopupDisMenuItem = null;
10195: dbgPopupMemMenuItem = null;
10196: dbgPopupCopyMenuItem = null;
10197: dbgPopupSelectAllMenuItem = null;
10198: dbgPopupIBPMenu = null;
10199: dbgPopupIBPCurrentModel = null;
10200: dbgPopupIBPCurrentValue = 0;
10201: dbgPopupIBPThresholdModel = null;
10202: dbgPopupIBPThresholdValue = 0;
10203: dbgPopupHexMenu = null;
10204: dbgPopupTextArea = null;
10205: dbgEventMask = 0;
10206: dbgStopOnError = false;
10207: if (DBG_ORI_BYTE_ZERO_D0) {
10208: dbgOriByteZeroD0 = false;
10209: }
10210: dbgStopAtStart = false;
10211: }
10212:
10213:
10214:
10215: public static void dbgMakePopup () {
10216:
10217:
10218: ActionListener popupActionListener = new ActionListener () {
10219: @Override public void actionPerformed (ActionEvent ae) {
10220: switch (ae.getActionCommand ()) {
10221: case "Disassemble":
10222: DisassembleList.ddpBacktraceRecord = -1L;
10223: DisassembleList.ddpOpen (dbgHexValue, dbgSupervisorMode, false);
10224: break;
10225: case "Memory Dump":
10226: MemoryDumpList.dmpOpen (dbgHexValue, dbgSupervisorMode != 0 ? 5 : 1, false);
10227: break;
10228: case "Run to Here":
10229: if (InstructionBreakPoint.IBP_ON) {
10230: if (mpuTask == null) {
10231: InstructionBreakPoint.ibpInstant (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
10232: mpuStart ();
10233: }
10234: }
10235: break;
10236: case "Set Breakpoint":
10237: if (InstructionBreakPoint.IBP_ON) {
10238: InstructionBreakPoint.ibpPut (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode, dbgPopupIBPCurrentValue, dbgPopupIBPThresholdValue, null);
10239: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
10240: }
10241: break;
10242: case "Clear Breakpoint":
10243: if (InstructionBreakPoint.IBP_ON) {
10244: InstructionBreakPoint.ibpRemove (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
10245: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
10246: }
10247: break;
10248: case "Copy":
10249: dbgCopy ();
10250: break;
10251: case "Select All":
10252: dbgSelectAll ();
10253: break;
10254: }
10255: }
10256: };
10257: dbgPopupMenu = ComponentFactory.createPopupMenu (
10258: dbgPopupIBPMenu =
10259: InstructionBreakPoint.IBP_ON ?
10260: ComponentFactory.createMenu (
10261: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
10262: Multilingual.mlnText (ComponentFactory.createMenuItem ("Run to Here", 'R', popupActionListener), "ja", "ここまで実行"),
10263: ComponentFactory.createHorizontalSeparator (),
10264: Multilingual.mlnText (ComponentFactory.createMenuItem ("Set Breakpoint", 'S', popupActionListener), "ja", "ブレークポイントを設定"),
10265: ComponentFactory.createHorizontalBox (
10266: Box.createHorizontalStrut (7),
10267: Box.createHorizontalGlue (),
10268: ComponentFactory.setPreferredSize (
10269: Multilingual.mlnText (ComponentFactory.createLabel ("current"), "ja", "現在値"),
10270: 60, 16),
10271: ComponentFactory.createNumberSpinner (dbgPopupIBPCurrentModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
10272: @Override public void stateChanged (ChangeEvent ce) {
10273: dbgPopupIBPCurrentValue = dbgPopupIBPCurrentModel.getNumber ().intValue ();
10274: }
10275: }),
10276: Box.createHorizontalGlue ()
10277: ),
10278: ComponentFactory.createHorizontalBox (
10279: Box.createHorizontalStrut (7),
10280: Box.createHorizontalGlue (),
10281: ComponentFactory.setPreferredSize (
10282: Multilingual.mlnText (ComponentFactory.createLabel ("threshold"), "ja", "閾値"),
10283: 60, 16),
10284: ComponentFactory.createNumberSpinner (dbgPopupIBPThresholdModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
10285: @Override public void stateChanged (ChangeEvent ce) {
10286: dbgPopupIBPThresholdValue = dbgPopupIBPThresholdModel.getNumber ().intValue ();
10287: }
10288: }),
10289: Box.createHorizontalGlue ()
10290: ),
10291: dbgPopupIBPClearMenuItem =
10292: Multilingual.mlnText (ComponentFactory.createMenuItem ("Clear Breakpoint", 'C', popupActionListener), "ja", "ブレークポイントを消去")
10293: ) :
10294: null,
10295: dbgPopupHexMenu =
10296: ComponentFactory.createMenu (
10297: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
10298: dbgPopupDisMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble", 'D', popupActionListener), "ja", "逆アセンブル"),
10299: dbgPopupMemMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory Dump", 'M', popupActionListener), "ja", "メモリダンプ")
10300: ),
10301: dbgPopupCopyMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Copy", 'C', popupActionListener), "ja", "コピー"),
10302: dbgPopupSelectAllMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Select All", 'A', popupActionListener), "ja", "すべて選択")
10303: );
10304:
10305: }
10306:
10307:
10308:
10309: public static void dbgShowPopup (MouseEvent me, JTextArea textArea, boolean dis) {
10310: dbgEventMask++;
10311: int x = me.getX ();
10312: int y = me.getY ();
10313:
10314: int p = textArea.viewToModel2D (me.getPoint ());
10315: DisassembleList.ddpPopupAddress = -1;
10316: if (dis) {
10317: int i = Arrays.binarySearch (DisassembleList.ddpSplitArray, 1, DisassembleList.ddpItemCount, p + 1);
10318: i = (i >> 31 ^ i) - 1;
10319: DisassembleList.ddpPopupAddress = DisassembleList.ddpAddressArray[i];
10320: }
10321: int start = textArea.getSelectionStart ();
10322: int end = textArea.getSelectionEnd ();
10323: String text = textArea.getText ();
10324: int length = text.length ();
10325: if ((start == end ||
10326: p < start || end <= p) &&
10327: 0 <= p && p < length && isWord (text.charAt (p))) {
10328:
10329: for (start = p; 0 < start && isWord (text.charAt (start - 1)); start--) {
10330: }
10331: for (end = p + 1; end < length && isWord (text.charAt (end)); end++) {
10332: }
10333: textArea.select (start, end);
10334: }
10335: dbgHexSelected = false;
10336: if (start < end) {
10337: textArea.requestFocusInWindow ();
10338:
10339:
10340:
10341:
10342:
10343: dbgHexValue = 0;
10344: int n = 0;
10345: for (int i = start; i < end; i++) {
10346: int t;
10347: if ((t = Character.digit (text.charAt (i), 16)) >= 0) {
10348: dbgHexValue = dbgHexValue << 4 | t;
10349: if (n >= 8 ||
10350: i + 1 >= end || (t = Character.digit (text.charAt (i + 1), 16)) < 0) {
10351: n = 0;
10352: break;
10353: }
10354: dbgHexValue = dbgHexValue << 4 | t;
10355: n += 2;
10356: i++;
10357: } else if (isWord (text.charAt (i))) {
10358: n = 0;
10359: break;
10360: }
10361: }
10362: dbgHexSelected = n > 0;
10363: try {
10364:
10365: Rectangle r = textArea.modelToView2D (start).getBounds ();
10366:
10367: Rectangle s = textArea.modelToView2D (end - 1).getBounds ();
10368: if (r.y == s.y) {
10369:
10370: y = r.y + r.height;
10371: }
10372: } catch (BadLocationException ble) {
10373: }
10374: }
10375:
10376: if (InstructionBreakPoint.IBP_ON) {
10377: if (dis && mpuTask == null && DisassembleList.ddpPopupAddress != -1) {
10378: ComponentFactory.setText (dbgPopupIBPMenu, fmtHex8 (DisassembleList.ddpPopupAddress));
10379: TreeMap<Integer,InstructionBreakPoint.InstructionBreakRecord> pointTable = InstructionBreakPoint.ibpPointTable;
10380: InstructionBreakPoint.InstructionBreakRecord r = pointTable.get (DisassembleList.ddpPopupAddress);
10381: if (r != null) {
10382: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = r.ibrValue));
10383: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = r.ibrThreshold));
10384: dbgPopupIBPClearMenuItem.setEnabled (true);
10385: } else {
10386: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = 0));
10387: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = 0));
10388: dbgPopupIBPClearMenuItem.setEnabled (false);
10389: }
10390: ComponentFactory.setVisible (dbgPopupIBPMenu, true);
10391: } else {
10392: ComponentFactory.setVisible (dbgPopupIBPMenu, false);
10393: }
10394: }
10395:
10396: if (dbgHexSelected) {
10397: ComponentFactory.setText (dbgPopupHexMenu, fmtHex8 (dbgHexValue));
10398: ComponentFactory.setVisible (dbgPopupHexMenu, true);
10399: } else {
10400: ComponentFactory.setVisible (dbgPopupHexMenu, false);
10401: }
10402:
10403: ComponentFactory.setEnabled (dbgPopupCopyMenuItem, clpClipboard != null && start < end);
10404:
10405: ComponentFactory.setEnabled (dbgPopupSelectAllMenuItem, clpClipboard != null);
10406:
10407: dbgPopupTextArea = textArea;
10408: dbgPopupMenu.show (textArea, x, y);
10409: dbgEventMask--;
10410: }
10411:
10412: public static boolean isWord (char c) {
10413: return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '_';
10414: }
10415:
10416:
10417:
10418: public static void dbgCopy () {
10419: clpCopy (dbgPopupTextArea.getSelectedText ());
10420: }
10421:
10422:
10423:
10424: public static void dbgSelectAll () {
10425: if (clpClipboard != null) {
10426:
10427: dbgEventMask++;
10428: dbgPopupTextArea.selectAll ();
10429: dbgPopupTextArea.requestFocusInWindow ();
10430: dbgEventMask--;
10431: }
10432: }
10433:
10434:
10435:
10436:
10437: public static void dbgUpdate () {
10438: if ((dbgVisibleMask & DBG_DRP_VISIBLE_MASK) != 0) {
10439: RegisterList.drpUpdate ();
10440: }
10441: if (ProgramFlowVisualizer.PFV_ON) {
10442: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
10443: if (ProgramFlowVisualizer.pfvTimer == 0) {
10444: ProgramFlowVisualizer.pfvUpdate ();
10445: } else {
10446: ProgramFlowVisualizer.pfvTimer--;
10447: }
10448: }
10449: }
10450: if (RasterBreakPoint.RBP_ON) {
10451: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
10452: if (RasterBreakPoint.rbpTimer == 0) {
10453: RasterBreakPoint.rbpUpdateFrame ();
10454: } else {
10455: RasterBreakPoint.rbpTimer--;
10456: }
10457: }
10458: }
10459: if (ScreenModeTest.SMT_ON) {
10460: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
10461: if (ScreenModeTest.smtTimer == 0) {
10462: ScreenModeTest.smtUpdateFrame ();
10463: } else {
10464: ScreenModeTest.smtTimer--;
10465: }
10466: }
10467: }
10468: if (RootPointerList.RTL_ON) {
10469: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
10470: if (RootPointerList.rtlTimer == 0) {
10471: RootPointerList.rtlTimer = RootPointerList.RTL_INTERVAL - 1;
10472: RootPointerList.rtlUpdateFrame ();
10473: } else {
10474: RootPointerList.rtlTimer--;
10475: }
10476: }
10477: }
10478: if (SpritePatternViewer.SPV_ON) {
10479: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
10480: if (SpritePatternViewer.spvTimer == 0) {
10481: SpritePatternViewer.spvTimer = SpritePatternViewer.SPV_INTERVAL - 1;
10482: SpritePatternViewer.spvUpdateFrame ();
10483: } else {
10484: SpritePatternViewer.spvTimer--;
10485: }
10486: }
10487: }
10488: if (PaletteViewer.PLV_ON) {
10489: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
10490: if (PaletteViewer.plvTimer == 0) {
10491: PaletteViewer.plvTimer = PaletteViewer.PLV_INTERVAL - 1;
10492: PaletteViewer.plvUpdateFrame ();
10493: } else {
10494: PaletteViewer.plvTimer--;
10495: }
10496: }
10497: }
10498: if (ATCMonitor.ACM_ON) {
10499: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
10500: if (ATCMonitor.acmTimer == 0) {
10501: ATCMonitor.acmTimer = ATCMonitor.ACM_INTERVAL - 1;
10502: ATCMonitor.acmUpdateFrame ();
10503: } else {
10504: ATCMonitor.acmTimer--;
10505: }
10506: }
10507: }
10508: }
10509:
10510:
10511:
10512:
10513:
10514:
10515:
10516:
10517:
10518:
10519:
10520:
10521:
10522:
10523:
10524:
10525:
10526:
10527:
10528:
10529:
10530:
10531: public static boolean dbgDoStopOnError () {
10532: if (MainMemory.mmrHumanVersion <= 0) {
10533: return true;
10534: }
10535: if ((regOC & 0xff00) == 0xff00 &&
10536: M68kException.m6eNumber == M68kException.M6E_PRIVILEGE_VIOLATION) {
10537: return false;
10538: }
10539: String message = (
10540: M68kException.m6eNumber < 0 ?
10541: fmtHex8 (new StringBuilder ("breaked").append (" at "), regPC0).toString () :
10542: M68kException.m6eNumber <= M68kException.M6E_ADDRESS_ERROR ?
10543: fmtHex8 (fmtHex8 (new StringBuilder ("ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10544: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10545: .append (" at "), regPC0).toString () :
10546: fmtHex8 (new StringBuilder (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10547: .append (" at "), regPC0).toString ()
10548: );
10549: System.out.println (message);
10550: if (!(M68kException.m6eNumber == M68kException.M6E_ACCESS_FAULT &&
10551: 0x0000e100 <= regPC0 && regPC0 < 0x0000e500)) {
10552: mpuStop (message);
10553: return true;
10554: }
10555: return false;
10556: }
10557:
10558:
10559:
10560: public static void dbgDoubleBusFault () {
10561: String message =
10562: fmtHex8 (fmtHex8 (new StringBuilder ("FATAL ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10563: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10564: .append (" at "), regPC0).toString ();
10565: System.out.println (message);
10566: mpuStop (message);
10567: }
10568:
10569:
10570:
10571:
10572:
10573:
10574: public static final HashMap<String,byte[]> rscResourceCache = new HashMap<String,byte[]> ();
10575:
10576:
10577:
10578:
10579:
10580:
10581: public static byte[] rscGetResource (String name, int... sizes) {
10582: byte[] array = rscResourceCache.get (name);
10583: if (array != null) {
10584: return array;
10585: }
10586: array = new byte[1024 * 64];
10587: int size = 0;
10588: try (BufferedInputStream bis = new BufferedInputStream (XEiJ.class.getResourceAsStream ("../data/" + name))) {
10589: for (;;) {
10590: if (size == array.length) {
10591: byte[] newArray = new byte[array.length * 2];
10592: System.arraycopy (array, 0, newArray, 0, size);
10593: array = newArray;
10594: }
10595: int step = bis.read (array, size, array.length - size);
10596: if (step == -1) {
10597: break;
10598: }
10599: size += step;
10600: }
10601: if (size < array.length) {
10602: byte[] newArray = new byte[size];
10603: System.arraycopy (array, 0, newArray, 0, size);
10604: array = newArray;
10605: }
10606: boolean fit = sizes.length == 0;
10607: if (!fit) {
10608: for (int i = 0; i < sizes.length; i++) {
10609: if (size == sizes[i]) {
10610: fit = true;
10611: break;
10612: }
10613: }
10614: }
10615: if (fit) {
10616: System.out.println (Multilingual.mlnJapanese ?
10617: name + " を読み込みました" :
10618: name + " was read");
10619: rscResourceCache.put (name, array);
10620: return array;
10621: }
10622: System.out.println (Multilingual.mlnJapanese ?
10623: name + " のサイズが違います" :
10624: name + " has wrong size");
10625: return null;
10626: } catch (IOException ioe) {
10627: }
10628:
10629: System.out.println (Multilingual.mlnJapanese ?
10630: name + " を読み込めません" :
10631: name + " cannot be read");
10632: return null;
10633: }
10634:
10635:
10636:
10637: public static String rscGetResourceText (String name) {
10638: return rscGetResourceText (name, "UTF-8");
10639: }
10640: public static String rscGetResourceText (String name, String charset) {
10641: byte[] array = rscGetResource (name);
10642: if (name != null) {
10643: try {
10644: return new String (array, charset);
10645: } catch (UnsupportedEncodingException uee) {
10646: }
10647: }
10648: return "";
10649: }
10650:
10651: public static final Pattern RSC_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10652: public static String rscLastFileName = null;
10653:
10654:
10655:
10656:
10657:
10658:
10659: public static byte[] rscGetFile (String names, int... sizes) {
10660: for (String name : names.split (",")) {
10661: name = name.trim ();
10662: if (name.length () == 0 || name.equalsIgnoreCase ("none")) {
10663: continue;
10664: }
10665: String[] zipSplittedName = RSC_ZIP_SEPARATOR.split (name, 2);
10666: InputStream is = null;
10667: if (zipSplittedName.length < 2) {
10668: File file = new File (name);
10669: if (file.isFile ()) {
10670: try {
10671: is = new FileInputStream (file);
10672: } catch (IOException ioe) {
10673: }
10674: } else {
10675: System.out.println (Multilingual.mlnJapanese ?
10676: name + " がありません" :
10677: name + " does not exist");
10678: continue;
10679: }
10680: } else {
10681: String zipName = zipSplittedName[0];
10682: String entryName = zipSplittedName[1];
10683: if (new File (zipName).isFile ()) {
10684: try {
10685: ZipFile zipFile = new ZipFile (zipName);
10686: ZipEntry zipEntry = zipFile.getEntry (entryName);
10687: if (zipEntry != null) {
10688: is = zipFile.getInputStream (zipEntry);
10689: } else {
10690: System.out.println (Multilingual.mlnJapanese ?
10691: zipName + " に " + zipEntry + " がありません" :
10692: zipName + " does not include " + zipEntry);
10693: }
10694: } catch (IOException ioe) {
10695: }
10696: } else {
10697: System.out.println (Multilingual.mlnJapanese ?
10698: zipName + " がありません" :
10699: zipName + " does not exist");
10700: continue;
10701: }
10702: }
10703: if (is != null) {
10704: try {
10705: is = new BufferedInputStream (is);
10706: if (name.toLowerCase ().endsWith (".gz")) {
10707: is = new GZIPInputStream (is);
10708: }
10709: byte[] array = new byte[1024 * 64];
10710: int size = 0;
10711: for (;;) {
10712: if (size == array.length) {
10713: byte[] newArray = new byte[array.length * 2];
10714: System.arraycopy (array, 0, newArray, 0, size);
10715: array = newArray;
10716: }
10717: int step = is.read (array, size, array.length - size);
10718: if (step == -1) {
10719: break;
10720: }
10721: size += step;
10722: }
10723: is.close ();
10724: is = null;
10725: if (size < array.length) {
10726: byte[] newArray = new byte[size];
10727: System.arraycopy (array, 0, newArray, 0, size);
10728: array = newArray;
10729: }
10730: boolean fit = sizes.length == 0;
10731: if (!fit) {
10732: for (int i = 0; i < sizes.length; i++) {
10733: if (size == sizes[i]) {
10734: fit = true;
10735: break;
10736: }
10737: }
10738: }
10739: if (fit) {
10740: System.out.println (Multilingual.mlnJapanese ?
10741: name + " を読み込みました" :
10742: name + " was read");
10743: rscLastFileName = name;
10744: return array;
10745: }
10746: System.out.println (Multilingual.mlnJapanese ?
10747: name + " のサイズが違います" :
10748: name + " has wrong size");
10749: continue;
10750: } catch (IOException ioe) {
10751: }
10752: if (is != null) {
10753: try {
10754: is.close ();
10755: is = null;
10756: } catch (IOException ioe) {
10757: }
10758: }
10759: }
10760: System.out.println (Multilingual.mlnJapanese ?
10761: name + " を読み込めません" :
10762: name + " cannot be read");
10763: }
10764:
10765:
10766:
10767: return null;
10768: }
10769:
10770:
10771:
10772:
10773: public static String rscGetTextFile (String name) {
10774: return rscGetTextFile (name, "UTF-8");
10775: }
10776: public static String rscGetTextFile (String name, String charset) {
10777: byte[] array = rscGetFile (name);
10778: if (array != null) {
10779: try {
10780: return new String (array, charset);
10781: } catch (UnsupportedEncodingException uee) {
10782: }
10783: }
10784: return "";
10785: }
10786:
10787:
10788:
10789: public static final int RSC_A_MASK = 1;
10790: public static final int RSC_R_MASK = 2;
10791: public static final int RSC_I_MASK = 4;
10792: public static final String RSC_A_EN = "Abort";
10793: public static final String RSC_R_EN = "Retry";
10794: public static final String RSC_I_EN = "Ignore";
10795: public static final String RSC_A_JA = "中止";
10796: public static final String RSC_R_JA = "再実行";
10797: public static final String RSC_I_JA = "無視";
10798: public static final String[][] RSC_EN_OPTIONS = {
10799: { RSC_A_EN },
10800: { RSC_A_EN },
10801: { RSC_R_EN },
10802: { RSC_A_EN, RSC_R_EN },
10803: { RSC_I_EN },
10804: { RSC_A_EN, RSC_I_EN },
10805: { RSC_R_EN, RSC_I_EN },
10806: { RSC_A_EN, RSC_R_EN, RSC_I_EN },
10807: };
10808: public static final String[][] RSC_JA_OPTIONS = {
10809: { RSC_A_JA },
10810: { RSC_A_JA },
10811: { RSC_R_JA },
10812: { RSC_A_JA, RSC_R_JA },
10813: { RSC_I_JA },
10814: { RSC_A_JA, RSC_I_JA },
10815: { RSC_R_JA, RSC_I_JA },
10816: { RSC_A_JA, RSC_R_JA, RSC_I_JA },
10817: };
10818: public static int rscShowError (String message, int mask) {
10819: System.out.println (message);
10820: mask &= RSC_A_MASK | RSC_R_MASK | RSC_I_MASK;
10821: if (mask == 0) {
10822: mask = RSC_A_MASK;
10823: }
10824: String[] options = (Multilingual.mlnJapanese ? RSC_JA_OPTIONS : RSC_EN_OPTIONS)[mask];
10825: int def = Integer.numberOfTrailingZeros (mask);
10826: pnlExitFullScreen (true);
10827: int bit = JOptionPane.showOptionDialog (
10828: null,
10829: message,
10830: Multilingual.mlnJapanese ? "ファイル操作エラー" : "File operation error",
10831: JOptionPane.YES_NO_CANCEL_OPTION,
10832: JOptionPane.ERROR_MESSAGE,
10833: null,
10834: options,
10835: options[def]);
10836: if (bit == JOptionPane.CLOSED_OPTION) {
10837: bit = def;
10838: }
10839: return 1 << bit;
10840: }
10841:
10842:
10843:
10844:
10845:
10846:
10847: public static boolean rscPutTextFile (String name, String string) {
10848: return rscPutTextFile (name, string, "UTF-8");
10849: }
10850: public static boolean rscPutTextFile (String name, ArrayList<String> strings) {
10851: return rscPutTextFile (name, strings, "UTF-8");
10852: }
10853: public static boolean rscPutTextFile (String name, String string, String charset) {
10854: ArrayList<String> strings = new ArrayList<String> ();
10855: strings.add (string);
10856: return rscPutTextFile (name, strings, charset);
10857: }
10858: public static boolean rscPutTextFile (String name, ArrayList<String> strings, String charset) {
10859: String nameTmp = name + ".tmp";
10860: String nameBak = name + ".bak";
10861: File file = new File (name);
10862: File fileTmp = new File (nameTmp);
10863: File fileBak = new File (nameBak);
10864:
10865: File parentDirectory = file.getParentFile ();
10866: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10867: if (!parentDirectory.mkdirs ()) {
10868: System.out.println (parentDirectory.getPath () + (Multilingual.mlnJapanese ? " を作れません" : " cannot be created"));
10869: return false;
10870: }
10871: }
10872:
10873: if (fileTmp.exists ()) {
10874: if (!fileTmp.delete ()) {
10875: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10876: return false;
10877: }
10878: }
10879:
10880: try (BufferedWriter bw = new BufferedWriter (new FileWriter (nameTmp, Charset.forName (charset)))) {
10881: for (String string : strings) {
10882: bw.write (string);
10883: }
10884: } catch (IOException ioe) {
10885: ioe.printStackTrace ();
10886: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " に書き出せません" : " cannot be written"));
10887: return false;
10888: }
10889:
10890: boolean fileExists = file.exists ();
10891: if (fileExists) {
10892:
10893: if (fileBak.exists ()) {
10894: if (!fileBak.delete ()) {
10895: System.out.println (nameBak + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10896: return false;
10897: }
10898: }
10899:
10900: if (!file.renameTo (fileBak)) {
10901: System.out.println (name + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + nameBak + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10902: return false;
10903: }
10904: }
10905:
10906: if (!fileTmp.renameTo (file)) {
10907: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + name + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10908: return false;
10909: }
10910: if (fileExists) {
10911: System.out.println (name + (Multilingual.mlnJapanese ? " を更新しました" : " was updated"));
10912: } else {
10913: System.out.println (name + (Multilingual.mlnJapanese ? " を作りました" : " was created"));
10914: }
10915: return true;
10916: }
10917:
10918:
10919:
10920:
10921:
10922:
10923:
10924:
10925:
10926: public static boolean rscPutFile (String name, byte[] array) {
10927: return rscPutFile (name, array, 0, array.length, (long) array.length);
10928: }
10929: public static boolean rscPutFile (String name, byte[] array, int offset, int length) {
10930: return rscPutFile (name, array, offset, length, (long) length);
10931: }
10932: public static boolean rscPutFile (String name, byte[] array, int offset, int length, long longLength2) {
10933: if (RSC_ZIP_SEPARATOR.matcher (name).matches ()) {
10934:
10935: return false;
10936: }
10937: File file = new File (name);
10938: boolean fileExists = file.isFile ();
10939: if (fileExists && file.length () == longLength2) {
10940: comparison:
10941: {
10942: try (BufferedInputStream bis = new BufferedInputStream (new FileInputStream (file))) {
10943: byte[] buffer = new byte[(int) Math.min (Math.max ((long) length, longLength2 - (long) length), (long) (1024 * 1024))];
10944: int position = 0;
10945: while (position < length) {
10946: int step = bis.read (buffer, 0, Math.min (buffer.length, length - position));
10947: if (step == -1) {
10948: break comparison;
10949: }
10950: int offsetPosition = offset + position;
10951: for (int i = 0; i < step; i++) {
10952: if (buffer[i] != array[offsetPosition + i]) {
10953: break comparison;
10954: }
10955: }
10956: position += step;
10957: }
10958: long longPosition2 = (long) length;
10959: while (longPosition2 < longLength2) {
10960: int step = bis.read (buffer, 0, (int) Math.min ((long) buffer.length, longLength2 - longPosition2));
10961: if (step == -1) {
10962: break comparison;
10963: }
10964: for (int i = 0; i < step; i++) {
10965: if (buffer[i] != 0) {
10966: break comparison;
10967: }
10968: }
10969: longPosition2 += (long) step;
10970: }
10971: return true;
10972: } catch (IOException ioe) {
10973: }
10974: }
10975: }
10976: String nameTmp = name + ".tmp";
10977: File fileTmp = new File (nameTmp);
10978: String nameBak = name + ".bak";
10979: File fileBak = new File (nameBak);
10980: retry:
10981: for (;;) {
10982: File parentDirectory = file.getParentFile ();
10983: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10984: String parentName = parentDirectory.getPath ();
10985: if (parentDirectory.mkdirs ()) {
10986: System.out.println (Multilingual.mlnJapanese ?
10987: parentName + " を作りました" :
10988: parentName + " was created");
10989: } else {
10990: switch (rscShowError (Multilingual.mlnJapanese ?
10991: parentName + " を作れません" :
10992: parentName + " cannot be created",
10993: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10994: case RSC_A_MASK:
10995: break retry;
10996: case RSC_R_MASK:
10997: continue retry;
10998: }
10999: }
11000: }
11001: if (fileTmp.isFile ()) {
11002: if (!fileTmp.delete ()) {
11003: switch (rscShowError (Multilingual.mlnJapanese ?
11004: nameTmp + " を削除できません" :
11005: nameTmp + " cannot be deleted",
11006: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11007: case RSC_A_MASK:
11008: break retry;
11009: case RSC_R_MASK:
11010: continue retry;
11011: }
11012: }
11013: }
11014: try (OutputStream os = name.toLowerCase ().endsWith (".gz") ?
11015: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11016: {
11017:
11018: def.setLevel (Deflater.DEFAULT_COMPRESSION);
11019:
11020: }
11021: } :
11022: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11023:
11024: os.write (array, offset, length);
11025:
11026:
11027: if ((long) length < longLength2) {
11028: byte[] buffer = new byte[(int) Math.min (longLength2 - (long) length, (long) (1024 * 1024))];
11029: Arrays.fill (buffer, 0, buffer.length, (byte) 0);
11030: long longPosition2 = (long) length;
11031: while (longPosition2 < longLength2) {
11032: int step = (int) Math.min ((long) buffer.length, longLength2 - longPosition2);
11033: os.write (buffer, 0, step);
11034: longPosition2 += (long) step;
11035: }
11036: }
11037: } catch (IOException ioe) {
11038: switch (rscShowError (Multilingual.mlnJapanese ?
11039: nameTmp + " に書き出せません" :
11040: nameTmp + " cannot be written",
11041: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11042: case RSC_A_MASK:
11043: break retry;
11044: case RSC_R_MASK:
11045: continue retry;
11046: }
11047: }
11048: if (fileExists && file.isFile ()) {
11049: if (fileBak.isFile ()) {
11050: if (!fileBak.delete ()) {
11051: switch (rscShowError (Multilingual.mlnJapanese ?
11052: nameBak + " を削除できません" :
11053: nameBak + " cannot be deleted",
11054: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11055: case RSC_A_MASK:
11056: break retry;
11057: case RSC_R_MASK:
11058: continue retry;
11059: }
11060: }
11061: }
11062: if (!file.renameTo (fileBak)) {
11063: switch (rscShowError (Multilingual.mlnJapanese ?
11064: name + " を " + nameBak + " にリネームできません" :
11065: name + " cannot be renamed to " + nameBak,
11066: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11067: case RSC_A_MASK:
11068: break retry;
11069: case RSC_R_MASK:
11070: continue retry;
11071: }
11072: }
11073: }
11074: if (fileTmp.renameTo (file)) {
11075: if (fileExists) {
11076: System.out.println (Multilingual.mlnJapanese ?
11077: name + " を更新しました" :
11078: name + " was updated");
11079: } else {
11080: System.out.println (Multilingual.mlnJapanese ?
11081: name + " を作りました" :
11082: name + " was created");
11083: }
11084: return true;
11085: } else {
11086: switch (rscShowError (Multilingual.mlnJapanese ?
11087: nameTmp + " を " + name + " にリネームできません" :
11088: nameTmp + " cannot be renamed to " + name,
11089: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11090: case RSC_A_MASK:
11091: break retry;
11092: case RSC_R_MASK:
11093: continue retry;
11094: }
11095: }
11096: break;
11097: }
11098: if (fileExists) {
11099: System.out.println (Multilingual.mlnJapanese ?
11100: name + " を更新できません" :
11101: name + " cannot be updated");
11102: } else {
11103: System.out.println (Multilingual.mlnJapanese ?
11104: name + " を作れません" :
11105: name + " cannot be created");
11106: }
11107: return false;
11108: }
11109:
11110:
11111:
11112:
11113:
11114:
11115: public static final Pattern ISM_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
11116:
11117:
11118:
11119:
11120:
11121:
11122:
11123:
11124:
11125:
11126:
11127: public static InputStream ismOpen (String name) {
11128: InputStream in = null;
11129: in = ismOpen (name, false);
11130: if (in == null && name.indexOf ('/') < 0 && name.indexOf ('\\') < 0) {
11131: in = ismOpen (name, true);
11132: }
11133: return in;
11134: }
11135: public static InputStream ismOpen (String name, boolean useGetResource) {
11136: boolean gzipped = name.toLowerCase ().endsWith (".gz");
11137: String[] zipSplittedName = ISM_ZIP_SEPARATOR.split (name, 2);
11138: String fileName = zipSplittedName[0];
11139: String zipEntryName = zipSplittedName.length < 2 ? null : zipSplittedName[1];
11140: InputStream in = null;
11141: try {
11142: if (useGetResource) {
11143: if (false) {
11144: URL url = XEiJ.class.getResource (fileName);
11145: if (url != null) {
11146: in = url.openStream ();
11147: }
11148: } else {
11149: in = XEiJ.class.getResourceAsStream (fileName);
11150: }
11151: } else {
11152: File file = new File (fileName);
11153: if (file.exists ()) {
11154: in = new FileInputStream (file);
11155: }
11156: }
11157: if (in != null && zipEntryName != null) {
11158: ZipInputStream zin = new ZipInputStream (in);
11159: in = null;
11160: ZipEntry entry;
11161: while ((entry = zin.getNextEntry ()) != null) {
11162: if (zipEntryName.equals (entry.getName ())) {
11163: in = zin;
11164: break;
11165: }
11166: }
11167: if (in == null) {
11168: System.out.println (Multilingual.mlnJapanese ? fileName + " の中に " + zipEntryName + " がありません" :
11169: zipEntryName + " does not exist in " + fileName);
11170: }
11171: }
11172: if (in != null && gzipped) {
11173: in = new GZIPInputStream (in);
11174: }
11175: if (in != null) {
11176: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " を読み込みます" :
11177: (useGetResource ? "Reading resource file " : "Reading file ") + name);
11178: return new BufferedInputStream (in);
11179: }
11180: } catch (Exception ioe) {
11181: if (prgVerbose) {
11182: prgPrintStackTraceOf (ioe);
11183: }
11184: }
11185: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " が見つかりません" :
11186: (useGetResource ? "Resource file " : "File ") + name + " is not found");
11187: return null;
11188: }
11189:
11190:
11191:
11192:
11193:
11194:
11195:
11196:
11197: public static int ismRead (InputStream in, byte[] bb, int o, int l) {
11198: try {
11199: int k = 0;
11200: while (k < l) {
11201: int t = in.read (bb, o + k, l - k);
11202: if (t < 0) {
11203: break;
11204: }
11205: k += t;
11206: }
11207: return k;
11208: } catch (IOException ioe) {
11209: if (prgVerbose) {
11210: prgPrintStackTraceOf (ioe);
11211: }
11212: }
11213: return -1;
11214: }
11215:
11216:
11217:
11218:
11219:
11220:
11221:
11222:
11223: public static int ismSkip (InputStream in, int l) {
11224: try {
11225: int k = 0;
11226: while (k < l) {
11227:
11228:
11229: if (in.read () < 0) {
11230: break;
11231: }
11232: k++;
11233: if (k < l) {
11234: int t = (int) in.skip ((long) (l - k));
11235: if (t < 0) {
11236: break;
11237: }
11238: k += t;
11239: }
11240: }
11241: return k;
11242: } catch (IOException ioe) {
11243: if (prgVerbose) {
11244: prgPrintStackTraceOf (ioe);
11245: }
11246: }
11247: return -1;
11248: }
11249:
11250:
11251:
11252:
11253:
11254: public static void ismClose (InputStream in) {
11255: try {
11256: if (in != null) {
11257: in.close ();
11258: }
11259: } catch (IOException ioe) {
11260: if (prgVerbose) {
11261: prgPrintStackTraceOf (ioe);
11262: }
11263: }
11264: }
11265:
11266:
11267:
11268:
11269:
11270:
11271: public static int ismLength (String name, int maxLength) {
11272: int length;
11273: InputStream in = ismOpen (name);
11274: if (in == null) {
11275: length = -1;
11276: } else {
11277: length = ismSkip (in, maxLength);
11278: ismClose (in);
11279: }
11280: return length;
11281: }
11282:
11283:
11284:
11285:
11286:
11287:
11288:
11289:
11290:
11291:
11292:
11293:
11294:
11295:
11296: public static boolean ismLoad (byte[] bb, int o, int l, String names) {
11297: for (String name : names.split (",")) {
11298: if (name.length () != 0) {
11299: InputStream in = ismOpen (name);
11300: if (in != null) {
11301: int k = ismRead (in, bb, o, l);
11302: ismClose (in);
11303: if (k == l) {
11304: return true;
11305: }
11306: }
11307: }
11308: }
11309: return false;
11310: }
11311:
11312:
11313:
11314:
11315:
11316:
11317:
11318:
11319:
11320: public static boolean ismSave (byte[] bb, int offset, long length, String path, boolean verbose) {
11321: if (ISM_ZIP_SEPARATOR.split (path, 2).length != 1) {
11322: if (verbose) {
11323: pnlExitFullScreen (true);
11324: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? path + " に書き出せません" : "Cannot write " + path);
11325: }
11326: return false;
11327: }
11328: long step = 0;
11329: byte[] zz = null;
11330: long pointer = (long) (bb.length - offset);
11331: if (pointer < length) {
11332: step = Math.min (1024L * 512, length - pointer);
11333: zz = new byte[(int) step];
11334: Arrays.fill (zz, (byte) 0);
11335: }
11336:
11337: File file = new File (path);
11338:
11339: if (step == 0 &&
11340: file.exists () && file.length () == length) {
11341:
11342: if (length == 0L) {
11343: return true;
11344: }
11345: InputStream in = ismOpen (path);
11346: if (in != null) {
11347: int l = (int) length;
11348: byte[] tt = new byte[l];
11349: int k = ismRead (in, tt, 0, l);
11350: ismClose (in);
11351: if (k == l &&
11352: Arrays.equals (tt, bb.length == l ? bb : Arrays.copyOfRange (bb, offset, offset + l))) {
11353: return true;
11354: }
11355: }
11356: }
11357:
11358: String pathTmp = path + ".tmp";
11359: String pathBak = path + ".bak";
11360: File fileTmp = new File (pathTmp);
11361: File fileBak = new File (pathBak);
11362:
11363: if (fileTmp.exists ()) {
11364: if (!fileTmp.delete ()) {
11365: if (verbose) {
11366: pnlExitFullScreen (true);
11367: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " を削除できません" : "Cannot delete " + pathTmp);
11368: }
11369: return false;
11370: }
11371: }
11372:
11373: try (OutputStream out = path.toLowerCase ().endsWith (".gz") ?
11374: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11375: {
11376:
11377: def.setLevel (Deflater.DEFAULT_COMPRESSION);
11378:
11379: }
11380: } :
11381: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11382: if (step == 0) {
11383: out.write (bb, offset, (int) length);
11384: } else {
11385: out.write (bb, offset, (int) pointer);
11386: for (; pointer < length; pointer += step) {
11387: out.write (zz, 0, (int) Math.min (step, length - pointer));
11388: }
11389: }
11390: } catch (IOException ioe) {
11391: if (verbose) {
11392: prgPrintStackTraceOf (ioe);
11393: pnlExitFullScreen (true);
11394: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " に書き出せません" : "Cannot write " + pathTmp);
11395: }
11396: return false;
11397: }
11398:
11399:
11400: if (file.exists ()) {
11401: if (fileBak.exists ()) {
11402: if (!fileBak.delete ()) {
11403: if (verbose) {
11404: pnlExitFullScreen (true);
11405: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathBak + " を削除できません" : "Cannot delete " + pathBak);
11406: }
11407: return false;
11408: }
11409: }
11410: if (!file.renameTo (fileBak)) {
11411: if (verbose) {
11412: pnlExitFullScreen (true);
11413: JOptionPane.showMessageDialog (
11414: null, Multilingual.mlnJapanese ? path + " を " + pathBak + " にリネームできません" : "Cannot rename " + path + " to " + pathBak);
11415: }
11416: return false;
11417: }
11418: }
11419:
11420:
11421: if (!fileTmp.renameTo (file)) {
11422: if (verbose) {
11423: pnlExitFullScreen (true);
11424: JOptionPane.showMessageDialog (
11425: null, Multilingual.mlnJapanese ? pathTmp + " を " + path + " にリネームできません" : "Cannot rename " + pathTmp + " to " + path);
11426: }
11427: return false;
11428: }
11429: return true;
11430: }
11431:
11432:
11433:
11434:
11435:
11436:
11437:
11438: public static final char[] FMT_TEMP = new char[32];
11439:
11440:
11441:
11442:
11443:
11444:
11445:
11446:
11447:
11448:
11449:
11450: public static final char[] FMT_AIN4_BASE = ".......*..*...**.*...*.*.**..****...*..**.*.*.****..**.****.****".toCharArray ();
11451: public static final char[] FMT_BIN4_BASE = "0000000100100011010001010110011110001001101010111100110111101111".toCharArray ();
11452:
11453:
11454:
11455:
11456:
11457:
11458:
11459:
11460: public static void fmtAin4 (char[] a, int o, int x) {
11461: a[o ] = (char) (x >> 1 & 4 ^ 46);
11462: a[o + 1] = (char) (x & 4 ^ 46);
11463: a[o + 2] = (char) (x << 1 & 4 ^ 46);
11464: a[o + 3] = (char) (x << 2 & 4 ^ 46);
11465: }
11466: public static void fmtBin4 (char[] a, int o, int x) {
11467: a[o ] = (char) (x >>> 3 & 1 | 48);
11468: a[o + 1] = (char) (x >>> 2 & 1 | 48);
11469: a[o + 2] = (char) (x >>> 1 & 1 | 48);
11470: a[o + 3] = (char) (x & 1 | 48);
11471: }
11472: public static String fmtAin4 (int x) {
11473: return String.valueOf (FMT_AIN4_BASE, (x & 15) << 2, 4);
11474: }
11475: public static String fmtBin4 (int x) {
11476: return String.valueOf (FMT_BIN4_BASE, (x & 15) << 2, 4);
11477: }
11478: public static StringBuilder fmtAin4 (StringBuilder sb, int x) {
11479: return sb.append (FMT_AIN4_BASE, (x & 15) << 2, 6);
11480: }
11481: public static StringBuilder fmtBin4 (StringBuilder sb, int x) {
11482: return sb.append (FMT_BIN4_BASE, (x & 15) << 2, 6);
11483: }
11484:
11485:
11486:
11487:
11488:
11489:
11490:
11491:
11492: public static void fmtAin6 (char[] a, int o, int x) {
11493: a[o ] = (char) (x >> 3 & 4 ^ 46);
11494: a[o + 1] = (char) (x >> 2 & 4 ^ 46);
11495: a[o + 2] = (char) (x >> 1 & 4 ^ 46);
11496: a[o + 3] = (char) (x & 4 ^ 46);
11497: a[o + 4] = (char) (x << 1 & 4 ^ 46);
11498: a[o + 5] = (char) (x << 2 & 4 ^ 46);
11499: }
11500: public static void fmtBin6 (char[] a, int o, int x) {
11501: a[o ] = (char) (x >>> 5 & 1 | 48);
11502: a[o + 1] = (char) (x >>> 4 & 1 | 48);
11503: a[o + 2] = (char) (x >>> 3 & 1 | 48);
11504: a[o + 3] = (char) (x >>> 2 & 1 | 48);
11505: a[o + 4] = (char) (x >>> 1 & 1 | 48);
11506: a[o + 5] = (char) (x & 1 | 48);
11507: }
11508: public static String fmtAin6 (int x) {
11509: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11510: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11511: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11512: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11513: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11514: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11515: return String.valueOf (FMT_TEMP, 0, 6);
11516: }
11517: public static String fmtBin6 (int x) {
11518: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11519: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11520: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11521: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11522: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11523: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11524: return String.valueOf (FMT_TEMP, 0, 6);
11525: }
11526: public static StringBuilder fmtAin6 (StringBuilder sb, int x) {
11527: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11528: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11529: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11530: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11531: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11532: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11533: return sb.append (FMT_TEMP, 0, 6);
11534: }
11535: public static StringBuilder fmtBin6 (StringBuilder sb, int x) {
11536: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11537: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11538: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11539: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11540: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11541: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11542: return sb.append (FMT_TEMP, 0, 6);
11543: }
11544:
11545:
11546:
11547:
11548:
11549:
11550:
11551:
11552: public static void fmtAin8 (char[] a, int o, int x) {
11553: a[o ] = (char) (x >> 5 & 4 ^ 46);
11554: a[o + 1] = (char) (x >> 4 & 4 ^ 46);
11555: a[o + 2] = (char) (x >> 3 & 4 ^ 46);
11556: a[o + 3] = (char) (x >> 2 & 4 ^ 46);
11557: a[o + 4] = (char) (x >> 1 & 4 ^ 46);
11558: a[o + 5] = (char) (x & 4 ^ 46);
11559: a[o + 6] = (char) (x << 1 & 4 ^ 46);
11560: a[o + 7] = (char) (x << 2 & 4 ^ 46);
11561: }
11562: public static void fmtBin8 (char[] a, int o, int x) {
11563: a[o ] = (char) (x >>> 7 & 1 | 48);
11564: a[o + 1] = (char) (x >>> 6 & 1 | 48);
11565: a[o + 2] = (char) (x >>> 5 & 1 | 48);
11566: a[o + 3] = (char) (x >>> 4 & 1 | 48);
11567: a[o + 4] = (char) (x >>> 3 & 1 | 48);
11568: a[o + 5] = (char) (x >>> 2 & 1 | 48);
11569: a[o + 6] = (char) (x >>> 1 & 1 | 48);
11570: a[o + 7] = (char) (x & 1 | 48);
11571: }
11572: public static String fmtAin8 (int x) {
11573: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11574: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11575: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11576: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11577: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11578: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11579: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11580: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11581: return String.valueOf (FMT_TEMP, 0, 8);
11582: }
11583: public static String fmtBin8 (int x) {
11584: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11585: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11586: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11587: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11588: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11589: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11590: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11591: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11592: return String.valueOf (FMT_TEMP, 0, 8);
11593: }
11594: public static StringBuilder fmtAin8 (StringBuilder sb, int x) {
11595: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11596: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11597: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11598: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11599: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11600: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11601: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11602: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11603: return sb.append (FMT_TEMP, 0, 8);
11604: }
11605: public static StringBuilder fmtBin8 (StringBuilder sb, int x) {
11606: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11607: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11608: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11609: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11610: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11611: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11612: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11613: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11614: return sb.append (FMT_TEMP, 0, 8);
11615: }
11616:
11617:
11618:
11619:
11620:
11621:
11622:
11623:
11624: public static void fmtAin12 (char[] a, int o, int x) {
11625: a[o ] = (char) (x >> 9 & 4 ^ 46);
11626: a[o + 1] = (char) (x >> 8 & 4 ^ 46);
11627: a[o + 2] = (char) (x >> 7 & 4 ^ 46);
11628: a[o + 3] = (char) (x >> 6 & 4 ^ 46);
11629: a[o + 4] = (char) (x >> 5 & 4 ^ 46);
11630: a[o + 5] = (char) (x >> 4 & 4 ^ 46);
11631: a[o + 6] = (char) (x >> 3 & 4 ^ 46);
11632: a[o + 7] = (char) (x >> 2 & 4 ^ 46);
11633: a[o + 8] = (char) (x >> 1 & 4 ^ 46);
11634: a[o + 9] = (char) (x & 4 ^ 46);
11635: a[o + 10] = (char) (x << 1 & 4 ^ 46);
11636: a[o + 11] = (char) (x << 2 & 4 ^ 46);
11637: }
11638: public static void fmtBin12 (char[] a, int o, int x) {
11639: a[o ] = (char) (x >>> 11 & 1 | 48);
11640: a[o + 1] = (char) (x >>> 10 & 1 | 48);
11641: a[o + 2] = (char) (x >>> 9 & 1 | 48);
11642: a[o + 3] = (char) (x >>> 8 & 1 | 48);
11643: a[o + 4] = (char) (x >>> 7 & 1 | 48);
11644: a[o + 5] = (char) (x >>> 6 & 1 | 48);
11645: a[o + 6] = (char) (x >>> 5 & 1 | 48);
11646: a[o + 7] = (char) (x >>> 4 & 1 | 48);
11647: a[o + 8] = (char) (x >>> 3 & 1 | 48);
11648: a[o + 9] = (char) (x >>> 2 & 1 | 48);
11649: a[o + 10] = (char) (x >>> 1 & 1 | 48);
11650: a[o + 11] = (char) (x & 1 | 48);
11651: }
11652: public static String fmtAin12 (int x) {
11653: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11654: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11655: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11656: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11657: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11658: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11659: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11660: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11661: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11662: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11663: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11664: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11665: return String.valueOf (FMT_TEMP, 0, 12);
11666: }
11667: public static String fmtBin12 (int x) {
11668: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11669: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11670: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11671: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11672: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11673: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11674: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11675: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11676: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11677: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11678: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11679: FMT_TEMP[11] = (char) (x & 1 | 48);
11680: return String.valueOf (FMT_TEMP, 0, 12);
11681: }
11682: public static StringBuilder fmtAin12 (StringBuilder sb, int x) {
11683: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11684: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11685: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11686: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11687: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11688: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11689: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11690: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11691: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11692: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11693: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11694: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11695: return sb.append (FMT_TEMP, 0, 12);
11696: }
11697: public static StringBuilder fmtBin12 (StringBuilder sb, int x) {
11698: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11699: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11700: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11701: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11702: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11703: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11704: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11705: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11706: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11707: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11708: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11709: FMT_TEMP[11] = (char) (x & 1 | 48);
11710: return sb.append (FMT_TEMP, 0, 12);
11711: }
11712:
11713:
11714:
11715:
11716:
11717:
11718:
11719:
11720: public static void fmtAin16 (char[] a, int o, int x) {
11721: a[o ] = (char) (x >> 13 & 4 ^ 46);
11722: a[o + 1] = (char) (x >> 12 & 4 ^ 46);
11723: a[o + 2] = (char) (x >> 11 & 4 ^ 46);
11724: a[o + 3] = (char) (x >> 10 & 4 ^ 46);
11725: a[o + 4] = (char) (x >> 9 & 4 ^ 46);
11726: a[o + 5] = (char) (x >> 8 & 4 ^ 46);
11727: a[o + 6] = (char) (x >> 7 & 4 ^ 46);
11728: a[o + 7] = (char) (x >> 6 & 4 ^ 46);
11729: a[o + 8] = (char) (x >> 5 & 4 ^ 46);
11730: a[o + 9] = (char) (x >> 4 & 4 ^ 46);
11731: a[o + 10] = (char) (x >> 3 & 4 ^ 46);
11732: a[o + 11] = (char) (x >> 2 & 4 ^ 46);
11733: a[o + 12] = (char) (x >> 1 & 4 ^ 46);
11734: a[o + 13] = (char) (x & 4 ^ 46);
11735: a[o + 14] = (char) (x << 1 & 4 ^ 46);
11736: a[o + 15] = (char) (x << 2 & 4 ^ 46);
11737: }
11738: public static void fmtBin16 (char[] a, int o, int x) {
11739: a[o ] = (char) (x >>> 15 & 1 | 48);
11740: a[o + 1] = (char) (x >>> 14 & 1 | 48);
11741: a[o + 2] = (char) (x >>> 13 & 1 | 48);
11742: a[o + 3] = (char) (x >>> 12 & 1 | 48);
11743: a[o + 4] = (char) (x >>> 11 & 1 | 48);
11744: a[o + 5] = (char) (x >>> 10 & 1 | 48);
11745: a[o + 6] = (char) (x >>> 9 & 1 | 48);
11746: a[o + 7] = (char) (x >>> 8 & 1 | 48);
11747: a[o + 8] = (char) (x >>> 7 & 1 | 48);
11748: a[o + 9] = (char) (x >>> 6 & 1 | 48);
11749: a[o + 10] = (char) (x >>> 5 & 1 | 48);
11750: a[o + 11] = (char) (x >>> 4 & 1 | 48);
11751: a[o + 12] = (char) (x >>> 3 & 1 | 48);
11752: a[o + 13] = (char) (x >>> 2 & 1 | 48);
11753: a[o + 14] = (char) (x >>> 1 & 1 | 48);
11754: a[o + 15] = (char) (x & 1 | 48);
11755: }
11756: public static String fmtAin16 (int x) {
11757: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11758: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11759: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11760: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11761: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11762: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11763: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11764: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11765: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11766: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11767: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11768: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11769: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11770: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11771: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11772: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11773: return String.valueOf (FMT_TEMP, 0, 16);
11774: }
11775: public static String fmtBin16 (int x) {
11776: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11777: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11778: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11779: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11780: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11781: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11782: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11783: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11784: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11785: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11786: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11787: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11788: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11789: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11790: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11791: FMT_TEMP[15] = (char) (x & 1 | 48);
11792: return String.valueOf (FMT_TEMP, 0, 16);
11793: }
11794: public static StringBuilder fmtAin16 (StringBuilder sb, int x) {
11795: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11796: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11797: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11798: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11799: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11800: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11801: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11802: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11803: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11804: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11805: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11806: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11807: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11808: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11809: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11810: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11811: return sb.append (FMT_TEMP, 0, 16);
11812: }
11813: public static StringBuilder fmtBin16 (StringBuilder sb, int x) {
11814: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11815: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11816: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11817: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11818: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11819: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11820: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11821: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11822: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11823: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11824: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11825: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11826: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11827: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11828: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11829: FMT_TEMP[15] = (char) (x & 1 | 48);
11830: return sb.append (FMT_TEMP, 0, 16);
11831: }
11832:
11833:
11834:
11835:
11836:
11837:
11838:
11839:
11840: public static void fmtAin24 (char[] a, int o, int x) {
11841: a[o ] = (char) (x >> 21 & 4 ^ 46);
11842: a[o + 1] = (char) (x >> 20 & 4 ^ 46);
11843: a[o + 2] = (char) (x >> 19 & 4 ^ 46);
11844: a[o + 3] = (char) (x >> 18 & 4 ^ 46);
11845: a[o + 4] = (char) (x >> 17 & 4 ^ 46);
11846: a[o + 5] = (char) (x >> 16 & 4 ^ 46);
11847: a[o + 6] = (char) (x >> 15 & 4 ^ 46);
11848: a[o + 7] = (char) (x >> 14 & 4 ^ 46);
11849: a[o + 8] = (char) (x >> 13 & 4 ^ 46);
11850: a[o + 9] = (char) (x >> 12 & 4 ^ 46);
11851: a[o + 10] = (char) (x >> 11 & 4 ^ 46);
11852: a[o + 11] = (char) (x >> 10 & 4 ^ 46);
11853: a[o + 12] = (char) (x >> 9 & 4 ^ 46);
11854: a[o + 13] = (char) (x >> 8 & 4 ^ 46);
11855: a[o + 14] = (char) (x >> 7 & 4 ^ 46);
11856: a[o + 15] = (char) (x >> 6 & 4 ^ 46);
11857: a[o + 16] = (char) (x >> 5 & 4 ^ 46);
11858: a[o + 17] = (char) (x >> 4 & 4 ^ 46);
11859: a[o + 18] = (char) (x >> 3 & 4 ^ 46);
11860: a[o + 19] = (char) (x >> 2 & 4 ^ 46);
11861: a[o + 20] = (char) (x >> 1 & 4 ^ 46);
11862: a[o + 21] = (char) (x & 4 ^ 46);
11863: a[o + 22] = (char) (x << 1 & 4 ^ 46);
11864: a[o + 23] = (char) (x << 2 & 4 ^ 46);
11865: }
11866: public static void fmtBin24 (char[] a, int o, int x) {
11867: a[o ] = (char) (x >>> 23 & 1 | 48);
11868: a[o + 1] = (char) (x >>> 22 & 1 | 48);
11869: a[o + 2] = (char) (x >>> 21 & 1 | 48);
11870: a[o + 3] = (char) (x >>> 20 & 1 | 48);
11871: a[o + 4] = (char) (x >>> 19 & 1 | 48);
11872: a[o + 5] = (char) (x >>> 18 & 1 | 48);
11873: a[o + 6] = (char) (x >>> 17 & 1 | 48);
11874: a[o + 7] = (char) (x >>> 16 & 1 | 48);
11875: a[o + 8] = (char) (x >>> 15 & 1 | 48);
11876: a[o + 9] = (char) (x >>> 14 & 1 | 48);
11877: a[o + 10] = (char) (x >>> 13 & 1 | 48);
11878: a[o + 11] = (char) (x >>> 12 & 1 | 48);
11879: a[o + 12] = (char) (x >>> 11 & 1 | 48);
11880: a[o + 13] = (char) (x >>> 10 & 1 | 48);
11881: a[o + 14] = (char) (x >>> 9 & 1 | 48);
11882: a[o + 15] = (char) (x >>> 8 & 1 | 48);
11883: a[o + 16] = (char) (x >>> 7 & 1 | 48);
11884: a[o + 17] = (char) (x >>> 6 & 1 | 48);
11885: a[o + 18] = (char) (x >>> 5 & 1 | 48);
11886: a[o + 19] = (char) (x >>> 4 & 1 | 48);
11887: a[o + 20] = (char) (x >>> 3 & 1 | 48);
11888: a[o + 21] = (char) (x >>> 2 & 1 | 48);
11889: a[o + 22] = (char) (x >>> 1 & 1 | 48);
11890: a[o + 23] = (char) (x & 1 | 48);
11891: }
11892: public static String fmtAin24 (int x) {
11893: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11894: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11895: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11896: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11897: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11898: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11899: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11900: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11901: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11902: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11903: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11904: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11905: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11906: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11907: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11908: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11909: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11910: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11911: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11912: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11913: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11914: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11915: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11916: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11917: return String.valueOf (FMT_TEMP, 0, 24);
11918: }
11919: public static String fmtBin24 (int x) {
11920: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11921: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11922: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11923: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11924: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11925: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11926: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11927: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11928: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11929: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11930: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11931: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11932: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11933: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11934: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11935: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11936: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11937: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11938: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11939: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11940: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11941: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11942: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11943: FMT_TEMP[23] = (char) (x & 1 | 48);
11944: return String.valueOf (FMT_TEMP, 0, 24);
11945: }
11946: public static StringBuilder fmtAin24 (StringBuilder sb, int x) {
11947: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11948: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11949: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11950: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11951: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11952: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11953: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11954: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11955: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11956: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11957: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11958: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11959: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11960: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11961: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11962: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11963: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11964: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11965: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11966: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11967: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11968: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11969: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11970: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11971: return sb.append (FMT_TEMP, 0, 24);
11972: }
11973: public static StringBuilder fmtBin24 (StringBuilder sb, int x) {
11974: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11975: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11976: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11977: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11978: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11979: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11980: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11981: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11982: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11983: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11984: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11985: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11986: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11987: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11988: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11989: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11990: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11991: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11992: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11993: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11994: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11995: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11996: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11997: FMT_TEMP[23] = (char) (x & 1 | 48);
11998: return sb.append (FMT_TEMP, 0, 24);
11999: }
12000:
12001:
12002:
12003:
12004:
12005:
12006:
12007:
12008:
12009:
12010:
12011:
12012:
12013:
12014:
12015:
12016:
12017:
12018:
12019:
12020:
12021:
12022:
12023:
12024:
12025:
12026:
12027:
12028:
12029:
12030:
12031:
12032:
12033: public static char fmtHexc (int x) {
12034: x &= 15;
12035: return (char) ((((9 - x) >> 4) & 7) + 48 + x);
12036: }
12037: public static void fmtHex1 (char[] a, int o, int x) {
12038: x &= 15;
12039: a[o] = (char) ((((9 - x) >> 4) & 7) + 48 + x);
12040: }
12041: public static String fmtHex1 (int x) {
12042: x &= 15;
12043: return Character.toString ((char) ((((9 - x) >> 4) & 7) + 48 + x));
12044: }
12045: public static StringBuilder fmtHex1 (StringBuilder sb, int x) {
12046: x &= 15;
12047: return sb.append ((char) ((((9 - x) >> 4) & 7) + 48 + x));
12048: }
12049:
12050:
12051:
12052:
12053:
12054:
12055: public static void fmtHex2 (char[] a, int o, int x) {
12056: int x0 = x & 15;
12057: int x1 = x >>> 4 & 15;
12058: a[o ] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
12059: a[o + 1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
12060: }
12061: public static String fmtHex2 (int x) {
12062:
12063: int x0 = x & 15;
12064: int x1 = x >>> 4 & 15;
12065: FMT_TEMP[0] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
12066: FMT_TEMP[1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
12067: return String.valueOf (FMT_TEMP, 0, 2);
12068: }
12069: public static StringBuilder fmtHex2 (StringBuilder sb, int x) {
12070: int x0 = x & 15;
12071: int x1 = x >>> 4 & 15;
12072: return (sb.
12073: append ((char) ((((9 - x1) >> 4) & 7) + 48 + x1)).
12074: append ((char) ((((9 - x0) >> 4) & 7) + 48 + x0)));
12075: }
12076:
12077:
12078:
12079:
12080:
12081:
12082: public static void fmtHex4 (char[] a, int o, int x) {
12083: int t;
12084: t = (char) x >>> 12;
12085: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12086: t = x >>> 8 & 15;
12087: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12088: t = x >>> 4 & 15;
12089: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12090: t = x & 15;
12091: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12092: }
12093: public static String fmtHex4 (int x) {
12094:
12095: int t;
12096: t = (char) x >>> 12;
12097: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12098: t = x >>> 8 & 15;
12099: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12100: t = x >>> 4 & 15;
12101: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12102: t = x & 15;
12103: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12104: return String.valueOf (FMT_TEMP, 0, 4);
12105: }
12106: public static StringBuilder fmtHex4 (StringBuilder sb, int x) {
12107:
12108: int t;
12109: t = (char) x >>> 12;
12110: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12111: t = x >>> 8 & 15;
12112: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12113: t = x >>> 4 & 15;
12114: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12115: t = x & 15;
12116: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12117: return sb.append (FMT_TEMP, 0, 4);
12118: }
12119:
12120:
12121:
12122:
12123:
12124:
12125: public static void fmtHex6 (char[] a, int o, int x) {
12126: int t;
12127: t = x >>> 20 & 15;
12128: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12129: t = x >>> 16 & 15;
12130: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12131: t = (char) x >>> 12;
12132: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12133: t = x >>> 8 & 15;
12134: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12135: t = x >>> 4 & 15;
12136: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12137: t = x & 15;
12138: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12139: }
12140: public static String fmtHex6 (int x) {
12141:
12142: int t;
12143: t = x >>> 20 & 15;
12144: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12145: t = x >>> 16 & 15;
12146: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12147: t = (char) x >>> 12;
12148: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12149: t = x >>> 8 & 15;
12150: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12151: t = x >>> 4 & 15;
12152: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12153: t = x & 15;
12154: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12155: return String.valueOf (FMT_TEMP, 0, 6);
12156: }
12157: public static StringBuilder fmtHex6 (StringBuilder sb, int x) {
12158:
12159: int t;
12160: t = x >>> 20 & 15;
12161: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12162: t = x >>> 16 & 15;
12163: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12164: t = (char) x >>> 12;
12165: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12166: t = x >>> 8 & 15;
12167: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12168: t = x >>> 4 & 15;
12169: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12170: t = x & 15;
12171: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12172: return sb.append (FMT_TEMP, 0, 6);
12173: }
12174:
12175:
12176:
12177:
12178:
12179:
12180: public static void fmtHex8 (char[] a, int o, int x) {
12181: int t;
12182: t = x >>> 28;
12183: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12184: t = x >>> 24 & 15;
12185: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12186: t = x >>> 20 & 15;
12187: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12188: t = x >>> 16 & 15;
12189: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12190: t = (char) x >>> 12;
12191: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12192: t = x >>> 8 & 15;
12193: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12194: t = x >>> 4 & 15;
12195: a[o + 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12196: t = x & 15;
12197: a[o + 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12198: }
12199: public static String fmtHex8 (int x) {
12200:
12201: int t;
12202: t = x >>> 28;
12203: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12204: t = x >>> 24 & 15;
12205: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12206: t = x >>> 20 & 15;
12207: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12208: t = x >>> 16 & 15;
12209: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12210: t = (char) x >>> 12;
12211: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12212: t = x >>> 8 & 15;
12213: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12214: t = x >>> 4 & 15;
12215: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12216: t = x & 15;
12217: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12218: return String.valueOf (FMT_TEMP, 0, 8);
12219: }
12220: public static StringBuilder fmtHex8 (StringBuilder sb, int x) {
12221:
12222: int t;
12223: t = x >>> 28;
12224: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12225: t = x >>> 24 & 15;
12226: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12227: t = x >>> 20 & 15;
12228: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12229: t = x >>> 16 & 15;
12230: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12231: t = (char) x >>> 12;
12232: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12233: t = x >>> 8 & 15;
12234: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12235: t = x >>> 4 & 15;
12236: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12237: t = x & 15;
12238: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12239: return sb.append (FMT_TEMP, 0, 8);
12240: }
12241:
12242: public static StringBuilder fmtHex16 (StringBuilder sb, long x) {
12243:
12244: int s, t;
12245: s = (int) (x >>> 32);
12246: t = s >>> 28;
12247: FMT_TEMP[ 0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12248: t = s >>> 24 & 15;
12249: FMT_TEMP[ 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12250: t = s >>> 20 & 15;
12251: FMT_TEMP[ 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12252: t = s >>> 16 & 15;
12253: FMT_TEMP[ 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12254: t = (char) s >>> 12;
12255: FMT_TEMP[ 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12256: t = s >>> 8 & 15;
12257: FMT_TEMP[ 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12258: t = s >>> 4 & 15;
12259: FMT_TEMP[ 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12260: t = s & 15;
12261: FMT_TEMP[ 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12262: s = (int) x;
12263: t = s >>> 28;
12264: FMT_TEMP[ 8] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12265: t = s >>> 24 & 15;
12266: FMT_TEMP[ 9] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12267: t = s >>> 20 & 15;
12268: FMT_TEMP[10] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12269: t = s >>> 16 & 15;
12270: FMT_TEMP[11] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12271: t = (char) s >>> 12;
12272: FMT_TEMP[12] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12273: t = s >>> 8 & 15;
12274: FMT_TEMP[13] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12275: t = s >>> 4 & 15;
12276: FMT_TEMP[14] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12277: t = s & 15;
12278: FMT_TEMP[15] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12279: return sb.append (FMT_TEMP, 0, 16);
12280: }
12281:
12282:
12283:
12284:
12285:
12286:
12287:
12288:
12289:
12290:
12291:
12292:
12293:
12294:
12295:
12296:
12297:
12298:
12299:
12300:
12301:
12302:
12303:
12304:
12305:
12306:
12307:
12308:
12309:
12310:
12311:
12312:
12313:
12314:
12315:
12316:
12317:
12318:
12319:
12320:
12321:
12322:
12323:
12324:
12325:
12326:
12327:
12328:
12329:
12330:
12331:
12332:
12333:
12334:
12335:
12336:
12337:
12338:
12339:
12340:
12341:
12342:
12343:
12344:
12345:
12346:
12347:
12348:
12349: public static final int[] FMT_BCD4 = new int[10000];
12350: public static final int[] FMT_DCB4 = new int[65536];
12351:
12352:
12353:
12354:
12355: public static void fmtInit () {
12356: Arrays.fill (FMT_DCB4, -1);
12357: int i = 0;
12358: int x = 0;
12359: for (int a = 0; a < 10; a++) {
12360: for (int b = 0; b < 10; b++) {
12361: for (int c = 0; c < 10; c++) {
12362: FMT_DCB4[FMT_BCD4[i ] = x ] = i;
12363: FMT_DCB4[FMT_BCD4[i + 1] = x + 1] = i + 1;
12364: FMT_DCB4[FMT_BCD4[i + 2] = x + 2] = i + 2;
12365: FMT_DCB4[FMT_BCD4[i + 3] = x + 3] = i + 3;
12366: FMT_DCB4[FMT_BCD4[i + 4] = x + 4] = i + 4;
12367: FMT_DCB4[FMT_BCD4[i + 5] = x + 5] = i + 5;
12368: FMT_DCB4[FMT_BCD4[i + 6] = x + 6] = i + 6;
12369: FMT_DCB4[FMT_BCD4[i + 7] = x + 7] = i + 7;
12370: FMT_DCB4[FMT_BCD4[i + 8] = x + 8] = i + 8;
12371: FMT_DCB4[FMT_BCD4[i + 9] = x + 9] = i + 9;
12372: i += 10;
12373: x += 1 << 4;
12374: }
12375: x += 6 << 4;
12376: }
12377: x += 6 << 8;
12378: }
12379: }
12380:
12381:
12382:
12383: public static int fmtBcd4 (int x) {
12384:
12385:
12386:
12387:
12388:
12389:
12390:
12391:
12392:
12393: return FMT_BCD4[Math.max (0, Math.min (9999, x))];
12394: }
12395:
12396:
12397:
12398: public static int fmtBcd8 (int x) {
12399: x = Math.max (0, Math.min (99999999, x));
12400:
12401:
12402: int q = (int) ((long) x * 109951163L >>> 40);
12403:
12404: return FMT_BCD4[q] << 16 | FMT_BCD4[x - 10000 * q];
12405: }
12406:
12407:
12408:
12409: public static long fmtBcd12 (long x) {
12410: x = Math.max (0L, Math.min (999999999999L, x));
12411: int q = (int) ((double) x / 100000000.0);
12412: int r = (int) (x - 100000000L * q);
12413:
12414:
12415: int rq = (int) ((long) r * 109951163L >>> 40);
12416:
12417: return (long) FMT_BCD4[q] << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
12418: }
12419:
12420:
12421:
12422: public static long fmtBcd16 (long x) {
12423: x = Math.max (0L, Math.min (9999999999999999L, x));
12424: int q = x <= (1L << 53) ? (int) ((double) x / 100000000.0) : (int) (x / 100000000L);
12425: int r = (int) (x - 100000000L * q);
12426:
12427:
12428: int qq = (int) ((long) q * 109951163L >>> 40);
12429:
12430:
12431:
12432: int rq = (int) ((long) r * 109951163L >>> 40);
12433:
12434: return (long) (FMT_BCD4[qq] << 16 | FMT_BCD4[q - 10000 * qq]) << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
12435: }
12436:
12437:
12438:
12439:
12440:
12441:
12442: public static int fmtCA02u (char[] a, int o, int x) {
12443: if (x < 0 || 99 < x) {
12444: x = 99;
12445: }
12446: x = FMT_BCD4[x];
12447: a[o ] = (char) ('0' | x >>> 4);
12448: a[o + 1] = (char) ('0' | x & 15);
12449: return o + 2;
12450: }
12451: public static StringBuilder fmtSB02u (StringBuilder sb, int x) {
12452: return sb.append (FMT_TEMP, 0, fmtCA02u (FMT_TEMP, 0, x));
12453: }
12454:
12455:
12456:
12457:
12458:
12459: public static int fmtCA2u (char[] a, int o, int x) {
12460: if (x < 0 || 99 < x) {
12461: x = 99;
12462: }
12463: x = FMT_BCD4[x];
12464: if (x <= 0x000f) {
12465: a[o++] = (char) ('0' | x);
12466: } else {
12467: a[o++] = (char) ('0' | x >>> 4);
12468: a[o++] = (char) ('0' | x & 15);
12469: }
12470: return o;
12471: }
12472: public static StringBuilder fmtSB2u (StringBuilder sb, int x) {
12473: return sb.append (FMT_TEMP, 0, fmtCA2u (FMT_TEMP, 0, x));
12474: }
12475:
12476:
12477:
12478:
12479:
12480: public static int fmtCA04u (char[] a, int o, int x) {
12481: if (x < 0 || 9999 < x) {
12482: x = 9999;
12483: }
12484: x = FMT_BCD4[x];
12485: a[o ] = (char) ('0' | x >>> 12);
12486: a[o + 1] = (char) ('0' | x >>> 8 & 15);
12487: a[o + 2] = (char) ('0' | x >>> 4 & 15);
12488: a[o + 3] = (char) ('0' | x & 15);
12489: return o + 4;
12490: }
12491: public static StringBuilder fmtSB04u (StringBuilder sb, int x) {
12492: return sb.append (FMT_TEMP, 0, fmtCA04u (FMT_TEMP, 0, x));
12493: }
12494:
12495:
12496:
12497:
12498:
12499: public static int fmtCA4u (char[] a, int o, int x) {
12500: if (x < 0 || 9999 < x) {
12501: x = 9999;
12502: }
12503: x = FMT_BCD4[x];
12504: if (x <= 0x000f) {
12505: a[o++] = (char) ('0' | x);
12506: } else if (x <= 0x00ff) {
12507: a[o++] = (char) ('0' | x >>> 4);
12508: a[o++] = (char) ('0' | x & 15);
12509: } else if (x <= 0x0fff) {
12510: a[o++] = (char) ('0' | x >>> 8);
12511: a[o++] = (char) ('0' | x >>> 4 & 15);
12512: a[o++] = (char) ('0' | x & 15);
12513: } else {
12514: a[o++] = (char) ('0' | x >>> 12);
12515: a[o++] = (char) ('0' | x >>> 8 & 15);
12516: a[o++] = (char) ('0' | x >>> 4 & 15);
12517: a[o++] = (char) ('0' | x & 15);
12518: }
12519: return o;
12520: }
12521: public static StringBuilder fmtSB4u (StringBuilder sb, int x) {
12522: return sb.append (FMT_TEMP, 0, fmtCA4u (FMT_TEMP, 0, x));
12523: }
12524:
12525:
12526:
12527:
12528:
12529: public static int fmtCA08u (char[] a, int o, int x) {
12530: if (x < 0 || 99999999 < x) {
12531: x = 99999999;
12532: }
12533:
12534:
12535: int h = (int) ((long) x * 109951163L >>> 40);
12536: return fmtCA04u (a, fmtCA04u (a, o, h), x - h * 10000);
12537: }
12538: public static StringBuilder fmtSB08u (StringBuilder sb, int x) {
12539: return sb.append (FMT_TEMP, 0, fmtCA08u (FMT_TEMP, 0, x));
12540: }
12541:
12542:
12543:
12544:
12545:
12546: public static int fmtCA8u (char[] a, int o, int x) {
12547: if (x < 0 || 99999999 < x) {
12548: x = 99999999;
12549: }
12550: if (x <= 9999) {
12551: return fmtCA4u (a, o, x);
12552: } else {
12553:
12554:
12555: int h = (int) ((long) x * 109951163L >>> 40);
12556: return fmtCA04u (a, fmtCA4u (a, o, h), x - h * 10000);
12557: }
12558: }
12559: public static StringBuilder fmtSB8u (StringBuilder sb, int x) {
12560: return sb.append (FMT_TEMP, 0, fmtCA8u (FMT_TEMP, 0, x));
12561: }
12562:
12563:
12564:
12565:
12566:
12567: public static int fmtCAd (char[] a, int o, long x) {
12568: if (x < 0L) {
12569: x = -x;
12570: a[o++] = '-';
12571: }
12572: if (x <= 99999999L) {
12573: return fmtCA8u (a, o, (int) x);
12574: } else if (x <= 9999999999999999L) {
12575: long h = x / 100000000L;
12576: return fmtCA08u (a, fmtCA8u (a, o, (int) h), (int) (x - h * 100000000L));
12577: } else {
12578: long hh = x / 10000000000000000L;
12579: x -= hh * 10000000000000000L;
12580: long h = x / 100000000L;
12581: return fmtCA08u (a, fmtCA08u (a, fmtCA4u (a, o, (int) hh), (int) h), (int) (x - h * 100000000L));
12582: }
12583: }
12584: public static StringBuilder fmtSBd (StringBuilder sb, long x) {
12585: return sb.append (FMT_TEMP, 0, fmtCAd (FMT_TEMP, 0, x));
12586: }
12587:
12588:
12589:
12590:
12591:
12592:
12593: public static int fmtCAnd (char[] a, int o, int n, long x) {
12594: int t = fmtCAd (a, o, x);
12595: n += o;
12596: if (t < n) {
12597: int i = n;
12598: while (o < t) {
12599: a[--i] = a[--t];
12600: }
12601: while (o < i) {
12602: a[--i] = ' ';
12603: }
12604: t = n;
12605: }
12606: return t;
12607: }
12608: public static StringBuilder fmtSBnd (StringBuilder sb, int n, int x) {
12609: return sb.append (FMT_TEMP, 0, fmtCAnd (FMT_TEMP, 0, n, x));
12610: }
12611:
12612:
12613:
12614:
12615:
12616:
12617:
12618:
12619:
12620:
12621:
12622:
12623:
12624: public static int fmtParseInt (String s, int i, int min, int max, int err) {
12625: return fmtParseIntRadix (s, i, min, max, err, 10);
12626: }
12627: public static int fmtParseIntRadix (String s, int i, int min, int max, int err, int radix) {
12628: if (s == null) {
12629: return err;
12630: }
12631: int l = s.length ();
12632: int c = i < l ? s.charAt (i++) : -1;
12633:
12634: while (c == ' ' || c == '\t') {
12635: c = i < l ? s.charAt (i++) : -1;
12636: }
12637:
12638: int n = 0;
12639: if (c == '+') {
12640: c = i < l ? s.charAt (i++) : -1;
12641: } else if (c == '-') {
12642: n = 1;
12643: c = i < l ? s.charAt (i++) : -1;
12644: }
12645:
12646:
12647:
12648:
12649: int o;
12650: int p;
12651: if (c == '$') {
12652: o = 0x07ffffff + n;
12653: p = 15 + n & 15;
12654: radix = 16;
12655: c = i < l ? s.charAt (i++) : -1;
12656: } else if (radix == 16) {
12657: o = 0x07ffffff + n;
12658: p = 15 + n & 15;
12659: } else if (radix == 8) {
12660: o = 0x0fffffff + n;
12661: p = 7 + n & 7;
12662: } else if (radix == 2) {
12663: o = 0x3fffffff + n;
12664: p = 1 + n & 1;
12665: } else {
12666: o = 214748364;
12667: p = 7 + n;
12668: radix = 10;
12669: }
12670:
12671: int x = Character.digit (c, radix);
12672: if (x < 0) {
12673: return err;
12674: }
12675: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12676: while (c >= 0) {
12677: int t = x - o;
12678: if (t > 0 || t == 0 && c > p) {
12679: return err;
12680: }
12681: x = x * radix + c;
12682: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12683: }
12684: if (n != 0) {
12685: x = -x;
12686: }
12687: return min <= x && x <= max ? x : err;
12688: }
12689:
12690:
12691:
12692:
12693:
12694:
12695:
12696:
12697:
12698:
12699: public static long matMax3 (long x1, long x2, long x3) {
12700: return Math.max (Math.max (x1, x2), x3);
12701: }
12702: public static long matMax4 (long x1, long x2, long x3, long x4) {
12703: return Math.max (Math.max (x1, x2), Math.max (x3, x4));
12704: }
12705: public static long matMax5 (long x1, long x2, long x3, long x4, long x5) {
12706: return Math.max (Math.max (Math.max (x1, x2), Math.max (x3, x4)), x5);
12707: }
12708:
12709:
12710:
12711:
12712:
12713: public static long matMin3 (long x1, long x2, long x3) {
12714: return Math.min (Math.min (x1, x2), x3);
12715: }
12716: public static long matMin4 (long x1, long x2, long x3, long x4) {
12717: return Math.min (Math.min (x1, x2), Math.min (x3, x4));
12718: }
12719: public static long matMin5 (long x1, long x2, long x3, long x4, long x5) {
12720: return Math.min (Math.min (Math.min (x1, x2), Math.min (x3, x4)), x5);
12721: }
12722:
12723:
12724:
12725:
12726:
12727:
12728:
12729:
12730:
12731:
12732:
12733:
12734: public static String strEncodeUTF8 (String s) {
12735: StringBuilder sb = new StringBuilder ();
12736: int l = s.length ();
12737: for (int i = 0; i < l; i++) {
12738: int u = s.charAt (i);
12739: if (0xd800 <= u && u <= 0xdbff && i + 1 < l) {
12740: int v = s.charAt (i + 1);
12741: if (0xdc00 <= v && v <= 0xdfff) {
12742: u = 0x10000 + ((u & 0x3ff) << 10) + (v & 0x3ff);
12743: i++;
12744: }
12745: }
12746: if ((u & 0xffffff80) == 0) {
12747: sb.append ((char) u);
12748: } else if ((u & 0xfffff800) == 0) {
12749: u = (0x0000c080 |
12750: (u & 0x000007c0) << 2 |
12751: (u & 0x0000003f));
12752: sb.append ((char) (u >> 8)).append ((char) (u & 0xff));
12753: } else if ((u & 0xffff0000) == 0 && !(0xd800 <= u && u <= 0xdfff)) {
12754: u = (0x00e08080 |
12755: (u & 0x0000f000) << 4 |
12756: (u & 0x00000fc0) << 2 |
12757: (u & 0x0000003f));
12758: sb.append ((char) (u >> 16)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12759: } else if ((u & 0xffe00000) == 0) {
12760: u = (0xf0808080 |
12761: (u & 0x001c0000) << 6 |
12762: (u & 0x0003f000) << 4 |
12763: (u & 0x00000fc0) << 2 |
12764: (u & 0x0000003f));
12765: sb.append ((char) ((u >> 24) & 0xff)).append ((char) ((u >> 16) & 0xff)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12766: } else {
12767: sb.append ((char) 0xef).append ((char) 0xbf).append ((char) 0xbd);
12768: }
12769: }
12770: return sb.toString ();
12771: }
12772:
12773:
12774:
12775:
12776:
12777:
12778:
12779: public static String strDecodeUTF8 (String s) {
12780: StringBuilder sb = new StringBuilder ();
12781: int l = s.length ();
12782: for (int i = 0; i < l; i++) {
12783: int c = s.charAt (i) & 0xff;
12784: for (int k = ((c & 0x80) == 0x00 ? 0 :
12785: (c & 0xe0) == 0xc0 ? 1 :
12786: (c & 0xf0) == 0xe0 ? 2 :
12787: (c & 0xf8) == 0xf0 ? 3 :
12788: -1);
12789: --k >= 0; ) {
12790: c = c << 8 | (i + 1 < l ? s.charAt (++i) & 0xff : 0);
12791: }
12792: int u = ((c & 0xffffff80) == 0x00000000 ? c :
12793: (c & 0xffffe0c0) == 0x0000c080 ? ((c & 0x00001f00) >> 2 |
12794: (c & 0x0000003f)) :
12795: (c & 0xfff0c0c0) == 0x00e08080 ? ((c & 0x000f0000) >> 4 |
12796: (c & 0x00003f00) >> 2 |
12797: (c & 0x0000003f)) :
12798: (c & 0xf8c0c0c0) == 0xf0808080 ? ((c & 0x07000000) >> 6 |
12799: (c & 0x003f0000) >> 4 |
12800: (c & 0x00003f00) >> 2 |
12801: (c & 0x0000003f)) :
12802: 0xfffd);
12803: if (u <= 0x0000ffff) {
12804: sb.append (0xd800 <= u && u <= 0xdfff ? '\ufffd' :
12805: (char) u);
12806: } else if (u <= 0x0010ffff) {
12807: u -= 0x000010000;
12808: sb.append ((char) (0xd800 + ((u >> 10) & 0x3ff))).append ((char) (0xdc00 + (u & 0x3ff)));
12809: }
12810: }
12811: return sb.toString ();
12812: }
12813:
12814:
12815:
12816:
12817:
12818: public static final int[] IsURIChar = {
12819:
12820:
12821: 0b00000000_00000000_00000000_00000000,
12822: 0b00000000_00000110_11111111_11000000,
12823: 0b01111111_11111111_11111111_11100001,
12824: 0b01111111_11111111_11111111_11100010,
12825: };
12826: public static String strEncodeURI (String s) {
12827: s = strEncodeUTF8 (s);
12828: StringBuilder sb = new StringBuilder ();
12829: int l = s.length ();
12830: for (int i = 0; i < l; i++) {
12831: int c = s.charAt (i);
12832: if (c < 0x80 && IsURIChar[c >> 5] << c < 0) {
12833: sb.append ((char) c);
12834: } else {
12835: fmtHex2 (sb.append ('%'), c);
12836: }
12837: }
12838: return sb.toString ();
12839: }
12840:
12841:
12842:
12843:
12844:
12845: public static final byte[] strIsHexChar = {
12846:
12847: -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
12848: -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1,
12849: -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
12850: -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
12851: };
12852: public static String strDecodeURI (String s) {
12853: StringBuilder sb = new StringBuilder ();
12854: int l = s.length ();
12855: for (int i = 0; i < l; i++) {
12856: int c = s.charAt (i);
12857: if (c == '%' && i + 2 < l) {
12858: int d = s.charAt (i + 1);
12859: int e = s.charAt (i + 2);
12860: if (d < 0x80 && (d = strIsHexChar[d]) >= 0 &&
12861: e < 0x80 && (e = strIsHexChar[e]) >= 0) {
12862: sb.append ((char) (d << 4 | e));
12863: } else {
12864: sb.append ((char) c);
12865: }
12866: } else {
12867: sb.append ((char) c);
12868: }
12869: }
12870: return sb.toString ();
12871: }
12872:
12873:
12874:
12875:
12876:
12877:
12878:
12879:
12880: public static BufferedImage createImage (int width, int height, String pattern, int... rgbs) {
12881: BufferedImage image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
12882: int[] bitmap = ((DataBufferInt) image.getRaster ().getDataBuffer ()).getData ();
12883: int length = width * height;
12884: for (int i = 0; i < length; i++) {
12885: char c = pattern.charAt (i);
12886: bitmap[i] = rgbs[c < '0' ? 0 : Character.digit (c, 16)];
12887: }
12888: return image;
12889: }
12890:
12891:
12892:
12893: public static ImageIcon createImageIcon (int width, int height, String pattern, int... rgbs) {
12894: return new ImageIcon (createImage (width, height, pattern, rgbs));
12895: }
12896:
12897:
12898:
12899: public static TexturePaint createTexturePaint (int width, int height, String pattern, int... rgbs) {
12900: return new TexturePaint (createImage (width, height, pattern, rgbs), new Rectangle (0, 0, width, height));
12901: }
12902:
12903:
12904:
12905: public static BufferedImage loadImage (String name) {
12906: BufferedImage image = null;
12907: try {
12908: image = ImageIO.read (new File (name));
12909: } catch (Exception e) {
12910: }
12911: return image;
12912: }
12913:
12914:
12915:
12916:
12917: public static boolean saveImage (BufferedImage image, String name) {
12918: return saveImage (image, name, 0.75F);
12919: }
12920: public static boolean saveImage (BufferedImage image, String name, float quality) {
12921: int index = name.lastIndexOf (".");
12922: if (index < 0) {
12923: return false;
12924: }
12925: if (name.substring (index).equalsIgnoreCase (".ico")) {
12926: return saveIcon (name, image);
12927: }
12928: Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix (name.substring (index + 1));
12929: if (!iterator.hasNext ()) {
12930: return false;
12931: }
12932: ImageWriter imageWriter = iterator.next ();
12933: ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam ();
12934: if (imageWriteParam.canWriteCompressed ()) {
12935: imageWriteParam.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);
12936: imageWriteParam.setCompressionQuality (quality);
12937: }
12938: try {
12939: File file = new File (name);
12940: ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream (file);
12941: imageWriter.setOutput (imageOutputStream);
12942: imageWriter.write (null, new IIOImage (image, null, null), imageWriteParam);
12943: imageOutputStream.close ();
12944: } catch (Exception e) {
12945:
12946: return false;
12947: }
12948: return true;
12949: }
12950:
12951:
12952:
12953:
12954:
12955:
12956:
12957:
12958:
12959:
12960:
12961:
12962:
12963:
12964:
12965:
12966:
12967:
12968:
12969:
12970:
12971:
12972:
12973:
12974:
12975:
12976:
12977:
12978:
12979:
12980:
12981:
12982:
12983:
12984:
12985:
12986:
12987:
12988:
12989:
12990:
12991:
12992:
12993:
12994:
12995:
12996:
12997:
12998:
12999:
13000:
13001:
13002:
13003:
13004:
13005:
13006:
13007:
13008:
13009:
13010:
13011:
13012:
13013:
13014:
13015:
13016:
13017:
13018:
13019:
13020:
13021:
13022:
13023: public static boolean saveIcon (String fileName, BufferedImage... arrayImage) {
13024: int iconCount = arrayImage.length;
13025: int[][] arrayPaletTable = new int[iconCount][];
13026: int[] arrayPaletCount = new int[iconCount];
13027: int[] arrayPixelBits = new int[iconCount];
13028: int[] arrayPatternLineSize = new int[iconCount];
13029: int[] arrayMaskLineSize = new int[iconCount];
13030: int[] arrayImageSize = new int[iconCount];
13031: int[] arrayImageOffset = new int[iconCount];
13032: int fileSize = 6 + 16 * iconCount;
13033: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
13034: BufferedImage image = arrayImage[iconNumber];
13035: int width = image.getWidth ();
13036: int height = image.getHeight ();
13037:
13038: int[] paletTable = new int[256];
13039: int paletCount = 0;
13040: countPalet:
13041: for (int y = height - 1; y >= 0; y--) {
13042: for (int x = 0; x < width; x++) {
13043: int rgb = image.getRGB (x, y);
13044: if (rgb >>> 24 != 0xff) {
13045: continue;
13046: }
13047: int l = 0;
13048: int r = paletCount;
13049: while (l < r) {
13050: int m = l + r >> 1;
13051: if (paletTable[m] < rgb) {
13052: l = m + 1;
13053: } else {
13054: r = m;
13055: }
13056: }
13057: if (l == paletCount || paletTable[l] != rgb) {
13058: if (paletCount == 256) {
13059: paletCount = 0;
13060: break countPalet;
13061: }
13062: for (int i = paletCount; i > l; i--) {
13063: paletTable[i] = paletTable[i - 1];
13064: }
13065: paletTable[l] = rgb;
13066: paletCount++;
13067: }
13068: }
13069: }
13070: int pixelBits = (paletCount == 0 ? 24 :
13071: paletCount > 16 ? 8 :
13072: paletCount > 4 ? 4 :
13073: paletCount > 2 ? 2 :
13074: 1);
13075: int patternLineSize = pixelBits * width + 31 >> 5 << 2;
13076: int maskLineSize = width + 31 >> 5 << 2;
13077: int imageSize = 40 + 4 * paletCount + patternLineSize * height + maskLineSize * height;
13078: arrayPaletTable[iconNumber] = paletTable;
13079: arrayPaletCount[iconNumber] = paletCount;
13080: arrayPixelBits[iconNumber] = pixelBits;
13081: arrayPatternLineSize[iconNumber] = patternLineSize;
13082: arrayMaskLineSize[iconNumber] = maskLineSize;
13083: arrayImageSize[iconNumber] = imageSize;
13084: arrayImageOffset[iconNumber] = fileSize;
13085: fileSize += imageSize;
13086: }
13087: byte[] bb = new byte[fileSize];
13088:
13089: ByteArray.byaWiw (bb, 0, 0);
13090: ByteArray.byaWiw (bb, 2, 1);
13091: ByteArray.byaWiw (bb, 4, iconCount);
13092: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
13093: BufferedImage image = arrayImage[iconNumber];
13094: int width = image.getWidth ();
13095: int height = image.getHeight ();
13096: int[] paletTable = arrayPaletTable[iconNumber];
13097: int paletCount = arrayPaletCount[iconNumber];
13098: int pixelBits = arrayPixelBits[iconNumber];
13099: int patternLineSize = arrayPatternLineSize[iconNumber];
13100: int maskLineSize = arrayMaskLineSize[iconNumber];
13101: int imageSize = arrayImageSize[iconNumber];
13102: int imageOffset = arrayImageOffset[iconNumber];
13103:
13104: int o = 6 + 16 * iconNumber;
13105: ByteArray.byaWb (bb, o, width);
13106: ByteArray.byaWb (bb, o + 1, height);
13107: ByteArray.byaWb (bb, o + 2, paletCount);
13108: ByteArray.byaWb (bb, o + 3, 0);
13109: ByteArray.byaWiw (bb, o + 4, 1);
13110: ByteArray.byaWiw (bb, o + 6, pixelBits);
13111: ByteArray.byaWil (bb, o + 8, imageSize);
13112: ByteArray.byaWil (bb, o + 12, imageOffset);
13113:
13114: o = imageOffset;
13115: ByteArray.byaWil (bb, o, 40);
13116: ByteArray.byaWil (bb, o + 4, width);
13117: ByteArray.byaWil (bb, o + 8, height * 2);
13118: ByteArray.byaWiw (bb, o + 12, 1);
13119: ByteArray.byaWiw (bb, o + 14, pixelBits);
13120: ByteArray.byaWil (bb, o + 16, 0);
13121: ByteArray.byaWil (bb, o + 20, 0);
13122: ByteArray.byaWil (bb, o + 24, 0);
13123: ByteArray.byaWil (bb, o + 28, 0);
13124: ByteArray.byaWil (bb, o + 32, paletCount);
13125: ByteArray.byaWil (bb, o + 36, 0);
13126:
13127: o += 40;
13128: for (int i = 0; i < paletCount; i++) {
13129: ByteArray.byaWil (bb, o, paletTable[i] & 0x00ffffff);
13130: o += 4;
13131: }
13132:
13133: for (int y = height - 1; y >= 0; y--) {
13134: for (int x = 0; x < width; x++) {
13135: int rgb = image.getRGB (x, y);
13136: if (rgb >>> 24 != 0xff) {
13137: continue;
13138: }
13139: if (pixelBits == 24) {
13140: bb[o + 3 * x] = (byte) rgb;
13141: bb[o + 3 * x + 1] = (byte) (rgb >> 8);
13142: bb[o + 3 * x + 2] = (byte) (rgb >> 16);
13143: continue;
13144: }
13145: int l = 0;
13146: int r = paletCount;
13147: while (l < r) {
13148: int m = l + r >> 1;
13149: if (paletTable[m] < rgb) {
13150: l = m + 1;
13151: } else {
13152: r = m;
13153: }
13154: }
13155: if (l != 0) {
13156: if (pixelBits == 8) {
13157: bb[o + x] = (byte) l;
13158: } else if (pixelBits == 4) {
13159: bb[o + (x >> 1)] |= (byte) (l << ((~x & 1) << 2));
13160: } else if (pixelBits == 2) {
13161: bb[o + (x >> 2)] |= (byte) (l << ((~x & 3) << 1));
13162: } else {
13163: bb[o + (x >> 3)] |= (byte) (l << (~x & 7));
13164: }
13165: }
13166: }
13167: o += patternLineSize;
13168: }
13169:
13170: for (int y = height - 1; y >= 0; y--) {
13171: for (int x = 0; x < width; x++) {
13172: int rgb = image.getRGB (x, y);
13173: if (rgb >>> 24 != 0xff) {
13174: bb[o + (x >> 3)] |= (byte) (1 << (~x & 7));
13175: }
13176: }
13177: o += maskLineSize;
13178: }
13179: }
13180: return rscPutFile (fileName, bb, 0, fileSize);
13181: }
13182:
13183:
13184:
13185: }
13186:
13187:
13188: