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.05.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.0.1";
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: if (FlashingLights.FLR_ON) {
325: FlashingLights.flrInit ();
326: }
327: TextCopy.txcInit ();
328: ButtonFunction.bfnInit ();
329:
330:
331:
332: Settings.sgsMakeMenu ();
333: mdlMakeMenu ();
334: FDC.fdcMakeMenu ();
335: HDC.hdcMakeMenu ();
336: SPC.spcMakeMenu ();
337: mpuMakeMenu ();
338: SRAM.smrMakeMenu ();
339: clpMake ();
340: pnlMake ();
341: mnbMakeMenu ();
342: frmMake ();
343: dbgMakePopup ();
344:
345: if (FlashingLights.FLR_ON) {
346: FlashingLights.flrInform ();
347: }
348:
349:
350: final String flags = (
351: "" +
352: (EFPBox.CIR_DEBUG_TRACE ? " EFPBox.CIR_DEBUG_TRACE" : "") +
353: (FDC.FDC_DEBUG_TRACE ? " FDC.FDC_DEBUG_TRACE" : "") +
354: (FEFunction.FPK_DEBUG_TRACE ? " FEFunction.FPK_DEBUG_TRACE" : "") +
355: (HD63450.DMA_DEBUG_TRACE != 0 ? " HD63450.DMA_DEBUG_TRACE" : "") +
356: (HDC.HDC_DEBUG_TRACE ? " HDC.HDC_DEBUG_TRACE" : "") +
357: (HDC.HDC_DEBUG_COMMAND ? " HDC.HDC_DEBUG_COMMAND" : "") +
358: (HFS.HFS_DEBUG_TRACE ? " HFS.HFS_DEBUG_TRACE" : "") +
359: (HFS.HFS_DEBUG_FILE_INFO ? " HFS.HFS_DEBUG_FILE_INFO" : "") +
360: (HFS.HFS_COMMAND_TRACE ? " HFS.HFS_COMMAND_TRACE" : "") +
361: (HFS.HFS_BUFFER_TRACE ? " HFS.HFS_BUFFER_TRACE" : "") +
362: (IOInterrupt.IOI_DEBUG_TRACE ? " IOInterrupt.IOI_DEBUG_TRACE" : "") +
363: (Keyboard.KBD_DEBUG_LED ? " Keyboard.KBD_DEBUG_LED" : "") +
364: (MC68060.MMU_DEBUG_COMMAND ? " MC68060.MMU_DEBUG_COMMAND" : "") +
365: (MC68060.MMU_DEBUG_TRANSLATION ? " MC68060.MMU_DEBUG_TRANSLATION" : "") +
366: (MC68060.MMU_NOT_ALLOCATE_CACHE ? " MC68060.MMU_NOT_ALLOCATE_CACHE" : "") +
367: (RP5C15.RTC_DEBUG_TRACE ? " RP5C15.RTC_DEBUG_TRACE" : "") +
368: (SPC.SPC_DEBUG_ON ? " SPC.SPC_DEBUG_ON" : "") +
369: (Z8530.SCC_DEBUG_ON ? " Z8530.SCC_DEBUG_ON" : "")
370: );
371: if (!"".equals (flags)) {
372: pnlExitFullScreen (true);
373: JOptionPane.showMessageDialog (null, "debug flags:" + flags);
374: }
375:
376:
377:
378:
379: tmrStart ();
380:
381: Keyboard.kbdStart ();
382: Mouse.musStart ();
383: pnlStart ();
384: frmStart ();
385: SoundSource.sndStart ();
386:
387: if (DataBreakPoint.DBP_ON) {
388: DataBreakPoint.dbpStart ();
389: }
390: if (RasterBreakPoint.RBP_ON) {
391: RasterBreakPoint.rbpStart ();
392: }
393: if (ScreenModeTest.SMT_ON) {
394: ScreenModeTest.smtStart ();
395: }
396: if (OPMLog.OLG_ON) {
397: OPMLog.olgStart ();
398: }
399: SoundMonitor.smnStart ();
400: RS232CTerminal.trmStart ();
401: PPI.ppiStart ();
402: PrinterPort.prnStart ();
403: if (BranchLog.BLG_ON) {
404: BranchLog.blgStart ();
405: }
406: if (ProgramFlowVisualizer.PFV_ON) {
407: ProgramFlowVisualizer.pfvStart ();
408: }
409: RegisterList.drpStart ();
410: DisassembleList.ddpStart ();
411: MemoryDumpList.dmpStart ();
412: LogicalSpaceMonitor.atwStart ();
413: PhysicalSpaceMonitor.paaStart ();
414: DebugConsole.dgtStart ();
415: if (RootPointerList.RTL_ON) {
416: RootPointerList.rtlStart ();
417: }
418: if (SpritePatternViewer.SPV_ON) {
419: SpritePatternViewer.spvStart ();
420: }
421: if (PaletteViewer.PLV_ON) {
422: PaletteViewer.plvStart ();
423: }
424: if (ATCMonitor.ACM_ON) {
425: ATCMonitor.acmStart ();
426: }
427: ButtonFunction.bfnStart ();
428:
429: if (Settings.sgsSaveiconValue != null) {
430: String[] a = Settings.sgsSaveiconValue.split (",");
431: if (0 < a.length) {
432: saveIcon (a[0], LnF.LNF_ICON_IMAGES);
433: if (1 < a.length) {
434: saveImage (LnF.LNF_ICON_IMAGE_16, a[1]);
435: if (2 < a.length) {
436: saveImage (LnF.LNF_ICON_IMAGE_32, a[2]);
437: if (3 < a.length) {
438: saveImage (LnF.LNF_ICON_IMAGE_48, a[3]);
439: }
440: }
441: }
442: }
443: prgTini ();
444: return;
445: }
446:
447:
448: mpuReset (-1, -1);
449:
450: pnlBoot2 ();
451:
452: }
453:
454:
455:
456:
457:
458: public static void prgTini () {
459: try {
460: if (OPMLog.OLG_ON) {
461: OPMLog.olgTini ();
462: }
463: ButtonFunction.bfnTini ();
464: TextCopy.txcTini ();
465: GIFAnimation.gifTini ();
466: if (FlashingLights.FLR_ON) {
467: FlashingLights.flrTini ();
468: }
469: SoundSource.sndTini ();
470: Keyboard.kbdTini ();
471: Mouse.musTini ();
472: CONDevice.conTini ();
473: PPI.ppiTini ();
474: PrinterPort.prnTini ();
475: FDC.fdcTini ();
476: HDC.hdcTini ();
477: if (HostCDROM.HCD_ENABLED) {
478: HostCDROM.hcdTini ();
479: }
480: SPC.spcTini ();
481: HFS.hfsTini ();
482: Z8530.sccTini ();
483: CRTC.crtTini ();
484: SpriteScreen.sprTini ();
485: pnlTini ();
486: bnkTini ();
487: ROM.romTini ();
488: if (MercuryUnit.MU4_ON) {
489: MercuryUnit.mu4Tini ();
490: }
491: xt3Tini ();
492: mdlTini ();
493: SRAM.smrTini ();
494: tmrTini ();
495: busTini ();
496: if (SpritePatternViewer.SPV_ON) {
497: SpritePatternViewer.spvTini ();
498: }
499: if (PaletteViewer.PLV_ON) {
500: PaletteViewer.plvTini ();
501: }
502: RS232CTerminal.trmTini ();
503: LnF.lnfTini ();
504: Settings.sgsTini ();
505: } catch (Exception e) {
506: e.printStackTrace ();
507: }
508: System.exit (0);
509: }
510:
511:
512:
513: public static void prgOpenJavaDialog () {
514: pnlExitFullScreen (true);
515: JOptionPane.showMessageDialog (
516: frmFrame,
517: ComponentFactory.createGridPanel (
518: 3,
519: 6,
520: "paddingLeft=6,paddingRight=6",
521: "italic,right;left;left",
522: "italic,center;colSpan=3,widen",
523: "",
524:
525: null,
526: Multilingual.mlnJapanese ? "実行中" : "Running",
527: Multilingual.mlnJapanese ? "推奨" : "Recommended",
528:
529: ComponentFactory.createHorizontalSeparator (),
530:
531: Multilingual.mlnJapanese ? "Java のベンダー" : "Java Vendor",
532: prgJavaVendor,
533: PRG_JAVA_VENDOR,
534:
535: Multilingual.mlnJapanese ? "Java のバージョン" : "Java Version",
536: prgJavaVersion,
537: PRG_JAVA_VERSION,
538:
539: Multilingual.mlnJapanese ? "OS のアーキテクチャ" : "OS Architecture",
540: prgOsArch,
541: PRG_OS_ARCH,
542:
543: Multilingual.mlnJapanese ? "OS の名前" : "OS Name",
544: prgOsName,
545: PRG_OS_NAME
546: ),
547: Multilingual.mlnJapanese ? "Java 実行環境の情報" : "Java runtime environment information",
548: JOptionPane.PLAIN_MESSAGE);
549: }
550:
551:
552:
553: public static void prgOpenAboutDialog () {
554: pnlExitFullScreen (true);
555: JOptionPane.showMessageDialog (
556: frmFrame,
557: ComponentFactory.createGridPanel (
558: 2, 4, "paddingLeft=6,paddingRight=6", "italic,right;left", "", "",
559: Multilingual.mlnJapanese ? "タイトル" : "Title" ,
560: PRG_TITLE,
561: Multilingual.mlnJapanese ? "バージョン" : "Version",
562: PRG_VERSION,
563: Multilingual.mlnJapanese ? "作者" : "Author" ,
564: PRG_AUTHOR,
565: Multilingual.mlnJapanese ? "ウェブページ" : "Webpage",
566: PRG_WEBPAGE
567: ),
568: Multilingual.mlnJapanese ? "バージョン情報" : "Version information",
569: JOptionPane.PLAIN_MESSAGE);
570: }
571:
572:
573:
574: public static void prgOpenXEiJLicenseDialog () {
575: pnlExitFullScreen (true);
576: JOptionPane.showMessageDialog (
577: frmFrame,
578: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_XEiJ.txt"), 550, 300),
579: Multilingual.mlnJapanese ? "XEiJ 使用許諾条件" : "XEiJ License",
580: JOptionPane.PLAIN_MESSAGE);
581: }
582:
583:
584:
585: public static void prgOpenSHARPLicenseDialog () {
586: pnlExitFullScreen (true);
587: JOptionPane.showMessageDialog (
588: frmFrame,
589: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_FSHARP.txt", "Shift_JIS"), 550, 300),
590: Multilingual.mlnJapanese ? "無償公開された X68000 の基本ソフトウェア製品の許諾条件" : "License of the basic software products for X68000 that were distributed free of charge",
591: JOptionPane.PLAIN_MESSAGE);
592: }
593:
594:
595:
596: public static void prgOpenYmfmLicenseDialog () {
597: pnlExitFullScreen (true);
598: JOptionPane.showMessageDialog (
599: frmFrame,
600: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_ymfm.txt"), 550, 300),
601: "ymfm License",
602: JOptionPane.PLAIN_MESSAGE);
603: }
604:
605:
606:
607: public static void prgOpenJSerialCommLicenseDialog () {
608: pnlExitFullScreen (true);
609: JOptionPane.showMessageDialog (
610: frmFrame,
611: ComponentFactory.createVerticalSplitPane (
612: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-APACHE-2.0"), 550, 300),
613: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-LGPL-3.0"), 550, 300)
614: ),
615: "jSerialComm License",
616: JOptionPane.PLAIN_MESSAGE);
617: }
618:
619:
620:
621: public static void prgPrintClass (Object o) {
622: System.out.println (o.toString ());
623:
624: try {
625: Stack<Class<?>> s = new Stack<Class<?>> ();
626: for (Class<?> c = o.getClass (); c != null; c = c.getSuperclass ()) {
627: s.push (c);
628: }
629: for (int i = 0; !s.empty (); i++) {
630: for (int j = 0; j < i; j++) {
631: System.out.print (" ");
632: }
633: System.out.println (s.pop ().getName ());
634: }
635: } catch (Exception e) {
636: }
637: }
638:
639:
640:
641:
642: public static void prgPrintStackTrace () {
643: Exception e = new Exception ();
644: e.fillInStackTrace ();
645: prgPrintStackTraceOf (e);
646: }
647: public static void prgPrintStackTraceOf (Exception e) {
648:
649: System.out.println ("------------------------------------------------");
650: System.out.println (e.toString ());
651: System.out.println ("\t" + e.getMessage ());
652: for (StackTraceElement ste : e.getStackTrace ()) {
653: System.out.println ("\tat " + ste.toString ());
654: }
655: System.out.println ("------------------------------------------------");
656: }
657:
658:
659:
660:
661: public static boolean prgStopDone = false;
662: public static void prgStopOnce () {
663: if (!prgStopDone) {
664: prgStopDone = true;
665: mpuStop (null);
666: }
667: }
668:
669:
670:
671:
672:
673:
674:
675:
676:
677:
678:
679:
680:
681:
682:
683:
684:
685:
686:
687:
688:
689:
690:
691:
692:
693:
694:
695:
696:
697:
698:
699: public static final long TMR_FREQ = 1000000000000L;
700:
701:
702: public static final long TMR_DELAY = 10L;
703: public static final long TMR_INTERVAL = 10L;
704:
705:
706: public static java.util.Timer tmrTimer;
707:
708:
709:
710: public static void tmrStart () {
711: tmrTimer = new java.util.Timer ();
712: }
713:
714:
715:
716: public static void tmrTini () {
717: if (tmrTimer != null) {
718: tmrTimer.cancel ();
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:
747:
748:
749:
750:
751:
752:
753:
754:
755:
756: public static final int PNL_BM_OFFSET_BITS = 10;
757: public static final int PNL_BM_WIDTH = 1 << PNL_BM_OFFSET_BITS;
758: public static final int PNL_BM_HEIGHT = 1024;
759:
760:
761:
762:
763:
764: public static final String[] PNL_ASPECT_RESOLUTION_NAME = {
765: "256x256",
766: "384x256",
767: "512x512",
768: "640x480",
769: "768x512",
770: "1024x848",
771: };
772:
773: public static final int PNL_ASPECT_RESOLUTION_COUNT = PNL_ASPECT_RESOLUTION_NAME.length;
774:
775:
776: public static final String[] PNL_ASPECT_SCREEN_NAME = {
777: "1:1",
778: "64:53",
779: "4:3",
780: "7:5",
781: "13:9",
782: "3:2",
783: };
784:
785: public static final int PNL_ASPECT_RATIO_COUNT = PNL_ASPECT_SCREEN_NAME.length;
786:
787:
788:
789: public static final int[] PNL_ASPECT_DEFAULT_RATIO = {
790: 2,
791: 2,
792: 2,
793: 2,
794: 5,
795: 1,
796: };
797:
798:
799: public static final String[] PNL_ASPECT_PIXEL_NAME_02 = {
800: "1:1",
801: null,
802: "4:3",
803: "7:5",
804: "13:9",
805: "3:2",
806: };
807:
808:
809: public static final String[] PNL_ASPECT_PIXEL_NAME_14 = {
810: null,
811: null,
812: "8:9",
813: "14:15",
814: "26:27",
815: "1:1",
816: };
817:
818:
819: public static final String[] PNL_ASPECT_PIXEL_NAME_3 = {
820: null,
821: null,
822: "1:1",
823: "21:20",
824: "13:12",
825: "9:8",
826: };
827:
828:
829: public static final String[] PNL_ASPECT_PIXEL_NAME_5 = {
830: null,
831: "1:1",
832: "53:48",
833: "371:320",
834: "689:576",
835: "159:128",
836: };
837:
838:
839: public static final float[] PNL_ASPECT_SCREEN_RATIO = {
840: 1.0F / 1.0F,
841: 64.0F / 53.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_02 = {
850: 1.0F / 1.0F,
851: 0.0F,
852: 4.0F / 3.0F,
853: 7.0F / 5.0F,
854: 13.0F / 9.0F,
855: 3.0F / 2.0F,
856: };
857:
858:
859: public static final float[] PNL_ASPECT_PIXEL_RATIO_14 = {
860: 0.0F,
861: 0.0F,
862: 8.0F / 9.0F,
863: 14.0F / 15.0F,
864: 26.0F / 27.0F,
865: 1.0F / 1.0F,
866: };
867:
868:
869: public static final float[] PNL_ASPECT_PIXEL_RATIO_3 = {
870: 0.0F,
871: 0.0F,
872: 1.0F / 1.0F,
873: 21.0F / 20.0F,
874: 13.0F / 12.0F,
875: 9.0F / 8.0F,
876: };
877:
878:
879: public static final float[] PNL_ASPECT_PIXEL_RATIO_5 = {
880: 0.0F,
881: 1.0F / 1.0F,
882: 53.0F / 48.0F,
883: 371.0F / 320.0F,
884: 689.0F / 576.0F,
885: 159.0F / 128.0F,
886: };
887:
888:
889: public static final String[][] PNL_ASPECT_NAME_MATRIX = {
890: PNL_ASPECT_PIXEL_NAME_02,
891: PNL_ASPECT_PIXEL_NAME_14,
892: PNL_ASPECT_PIXEL_NAME_02,
893: PNL_ASPECT_PIXEL_NAME_3,
894: PNL_ASPECT_PIXEL_NAME_14,
895: PNL_ASPECT_PIXEL_NAME_5,
896: };
897:
898:
899: public static final float[][] PNL_ASPECT_RATIO_MATRIX = {
900: PNL_ASPECT_PIXEL_RATIO_02,
901: PNL_ASPECT_PIXEL_RATIO_14,
902: PNL_ASPECT_PIXEL_RATIO_02,
903: PNL_ASPECT_PIXEL_RATIO_3,
904: PNL_ASPECT_PIXEL_RATIO_14,
905: PNL_ASPECT_PIXEL_RATIO_5,
906: };
907:
908:
909: public static int[] pnlAspectMap;
910:
911:
912: public static float[] pnlAspectTableX;
913: public static float[] pnlAspectTableY;
914:
915:
916: public static final int PNL_MIN_WIDTH = 64;
917: public static final int PNL_MIN_HEIGHT = 64;
918: public static int pnlScreenWidth;
919: public static int pnlScreenHeight;
920: public static float pnlStretchModeX;
921: public static float pnlStretchModeY;
922: public static int pnlStretchWidth;
923: public static int pnlStretchHeight;
924:
925: public static boolean PNL_ROTATION_ON = true;
926: public static int pnlRotationMode;
927: public static AffineTransform pnlRotationTransformLeft;
928: public static AffineTransform pnlRotationTransformRight;
929: public static double pnlMatrixL00, pnlMatrixL10, pnlMatrixL01, pnlMatrixL11, pnlMatrixL02, pnlMatrixL12;
930: public static double pnlMatrixR00, pnlMatrixR10, pnlMatrixR01, pnlMatrixR11, pnlMatrixR02, pnlMatrixR12;
931: public static double pnlInverseL00, pnlInverseL10, pnlInverseL01, pnlInverseL11, pnlInverseL02, pnlInverseL12;
932: public static double pnlInverseR00, pnlInverseR10, pnlInverseR01, pnlInverseR11, pnlInverseR02, pnlInverseR12;
933: public static int pnlRotatedWidth;
934: public static int pnlRotatedHeight;
935:
936: public static int pnlZoomWidth;
937: public static int pnlZoomHeight;
938: public static int pnlZoomRatioOutX;
939: public static int pnlZoomRatioOutY;
940: public static int pnlZoomRatioInX;
941: public static int pnlZoomRatioInY;
942: public static int pnlWidth;
943: public static int pnlHeight;
944: public static Dimension pnlSize;
945: public static int pnlScreenX1;
946: public static int pnlScreenX2;
947: public static int pnlScreenX3;
948: public static int pnlScreenX4;
949: public static int pnlScreenY1;
950: public static int pnlScreenY2;
951: public static int pnlScreenY3;
952: public static int pnlScreenY4;
953: public static int pnlKeyboardX;
954: public static int pnlKeyboardY;
955: public static int pnlMinimumWidth;
956: public static int pnlMinimumHeight;
957: public static int pnlGlobalX;
958: public static int pnlGlobalY;
959:
960:
961: public static final boolean PNL_FILL_BACKGROUND = true;
962: public static boolean pnlFillBackgroundRequest;
963: public static boolean pnlIsFullScreenSupported;
964: public static boolean pnlPrevKeyboardOn;
965: public static boolean pnlHideKeyboard;
966:
967:
968:
969:
970:
971: public static Object pnlInterpolation;
972:
973:
974: public static final double PNL_MIN_RATE = 1.0;
975: public static final double PNL_MAX_RATE = 1000.0;
976: public static final double PNL_DEFAULT_RATE = 59.94;
977: public static double pnlRefreshRate;
978: public static double pnlFixedRate;
979: public static boolean pnlAdjustVsync;
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:
1020:
1021:
1022:
1023:
1024:
1025:
1026:
1027:
1028:
1029: public static final boolean PNL_STEREOSCOPIC_ON = true;
1030:
1031: public static final boolean PNL_USE_THREAD = true;
1032:
1033: public static BufferedImage[] pnlScreenImageLeftArray;
1034: public static BufferedImage[] pnlScreenImageRightArray;
1035:
1036: public static BufferedImage[] pnlScreenSubImageLeftArray;
1037: public static BufferedImage[] pnlScreenSubImageRightArray;
1038:
1039: public static int[][] pnlBMLeftArray;
1040: public static int[][] pnlBMRightArray;
1041: public static volatile int pnlBMWrite;
1042: public static volatile int pnlBMRead;
1043:
1044: public static BufferedImage pnlScreenImageLeft;
1045: public static BufferedImage pnlScreenImageRight;
1046:
1047: public static BufferedImage pnlScreenSubImageLeft;
1048: public static BufferedImage pnlScreenSubImageRight;
1049:
1050: public static int[] pnlBMLeft;
1051: public static int[] pnlBMRight;
1052:
1053: public static int[] pnlBM;
1054: public static boolean pnlStereoscopicOn;
1055: public static final int PNL_NAKED_EYE_CROSSING = 0;
1056: public static final int PNL_NAKED_EYE_PARALLEL = 1;
1057: public static final int PNL_SIDE_BY_SIDE = 2;
1058: public static final int PNL_TOP_AND_BOTTOM = 3;
1059: public static int pnlStereoscopicMethod;
1060: public static int pnlStereoscopicFactor;
1061: public static int pnlStereoscopicShutter;
1062:
1063:
1064: public static JPanel pnlPanel;
1065:
1066: public static Thread pnlThread;
1067: public static long pnlWakeupTime;
1068: public static long pnlWakeupTimeMNP;
1069: public static final boolean PNL_USE_CANVAS = PNL_USE_THREAD && true;
1070:
1071: public static boolean pnlUseCanvasRequest;
1072: public static boolean pnlUseCanvas;
1073: public static Canvas pnlCanvas;
1074: public static Component pnlCanvasOrPanel;
1075:
1076:
1077:
1078:
1079: public static int pnlFixedScale;
1080: public static SpinnerNumberModel pnlFixedModel;
1081: public static JSpinner pnlFixedSpinner;
1082:
1083:
1084:
1085: public static void pnlInit () {
1086: pnlInit2 ();
1087:
1088:
1089:
1090:
1091: pnlFixedScale = Math.max (10, Math.min (1000, Settings.sgsGetInt ("fixedscale")));
1092:
1093:
1094: pnlAspectMap = new int[PNL_ASPECT_RESOLUTION_COUNT];
1095: for (int resolutionNumber = 0; resolutionNumber < PNL_ASPECT_RESOLUTION_COUNT; resolutionNumber++) {
1096: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[resolutionNumber];
1097: String screenName = Settings.sgsGetString ("aspectratio" + resolutionName);
1098: int ratioNumber = PNL_ASPECT_DEFAULT_RATIO[resolutionNumber];
1099: for (int tempRatioNumber = 0; tempRatioNumber < PNL_ASPECT_RATIO_COUNT; tempRatioNumber++) {
1100: if (PNL_ASPECT_RATIO_MATRIX[resolutionNumber][tempRatioNumber] == 0.0F) {
1101: continue;
1102: }
1103: if (PNL_ASPECT_SCREEN_NAME[tempRatioNumber].equals (screenName)) {
1104: ratioNumber = tempRatioNumber;
1105: break;
1106: }
1107: }
1108: pnlAspectMap[resolutionNumber] = ratioNumber;
1109: }
1110: pnlAspectTableX = new float[64];
1111: pnlAspectTableY = new float[64];
1112: pnlUpdateAspectTable ();
1113:
1114:
1115: switch (Settings.sgsGetString ("interpolation").toLowerCase ()) {
1116: case "nearest":
1117: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
1118: break;
1119: case "bilinear":
1120: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
1121: break;
1122: case "bicubic":
1123: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
1124: break;
1125: default:
1126: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
1127: }
1128:
1129:
1130: pnlRefreshRate = 0.0;
1131: {
1132: String s = Settings.sgsGetString ("refreshrate");
1133: if (!s.equals ("")) {
1134: try {
1135: double rate = Double.parseDouble (s);
1136: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
1137: pnlRefreshRate = rate;
1138: }
1139: } catch (NumberFormatException nfe) {
1140: }
1141: }
1142: }
1143: pnlFixedRate = pnlRefreshRate;
1144: pnlAdjustVsync = Settings.sgsGetOnOff ("adjustvsync");
1145:
1146: pnlPrevKeyboardOn = true;
1147:
1148: pnlHideKeyboard = Settings.sgsGetOnOff ("hidekeyboard");
1149:
1150:
1151: if (PNL_USE_THREAD) {
1152: pnlScreenImageLeftArray = new BufferedImage[4];
1153: pnlScreenImageRightArray = new BufferedImage[4];
1154: if (PNL_ROTATION_ON) {
1155: pnlScreenSubImageLeftArray = new BufferedImage[4];
1156: pnlScreenSubImageRightArray = new BufferedImage[4];
1157: }
1158: pnlBMLeftArray = new int[4][];
1159: pnlBMRightArray = new int[4][];
1160: for (int n = 0; n < 4; n++) {
1161: pnlScreenImageLeftArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1162: pnlScreenImageRightArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1163: if (PNL_ROTATION_ON) {
1164: pnlScreenSubImageLeftArray[n] = null;
1165: pnlScreenSubImageRightArray[n] = null;
1166: }
1167: pnlBMLeftArray[n] = ((DataBufferInt) pnlScreenImageLeftArray[n].getRaster ().getDataBuffer ()).getData ();
1168: pnlBMRightArray[n] = ((DataBufferInt) pnlScreenImageRightArray[n].getRaster ().getDataBuffer ()).getData ();
1169: }
1170: pnlBMWrite = 0;
1171: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
1172: pnlBMRead = 0;
1173: pnlThread = null;
1174: pnlWakeupTime = 0L;
1175: pnlWakeupTimeMNP = 0L;
1176: if (PNL_USE_CANVAS) {
1177: pnlUseCanvasRequest = Settings.sgsGetOnOff ("usecanvas");
1178: pnlUseCanvas = pnlUseCanvasRequest;
1179: pnlCanvas = null;
1180: }
1181: } else {
1182: pnlScreenImageLeft = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1183: pnlScreenImageRight = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1184: if (PNL_ROTATION_ON) {
1185: pnlScreenSubImageLeft = null;
1186: pnlScreenSubImageRight = null;
1187: }
1188: pnlBMLeft = ((DataBufferInt) pnlScreenImageLeft.getRaster ().getDataBuffer ()).getData ();
1189: pnlBMRight = ((DataBufferInt) pnlScreenImageRight.getRaster ().getDataBuffer ()).getData ();
1190: pnlBM = pnlBMLeft;
1191: }
1192: pnlStereoscopicOn = Settings.sgsGetOnOff ("stereoscopic");
1193: switch (Settings.sgsGetString ("stereoscopicmethod").toLowerCase ()) {
1194: case "nakedeyecrossing":
1195: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
1196: break;
1197: case "nakedeyeparallel":
1198: pnlStereoscopicMethod = PNL_NAKED_EYE_PARALLEL;
1199: break;
1200: case "sidebyside":
1201: pnlStereoscopicMethod = PNL_SIDE_BY_SIDE;
1202: break;
1203: case "topandbottom":
1204: pnlStereoscopicMethod = PNL_TOP_AND_BOTTOM;
1205: break;
1206: default:
1207: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
1208: }
1209: pnlStereoscopicFactor = pnlStereoscopicOn && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1210: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1211: pnlStereoscopicShutter = 0;
1212:
1213:
1214: pnlScreenWidth = 768;
1215: pnlScreenHeight = 512;
1216: pnlStretchModeX = 1.0F;
1217: pnlStretchModeY = 1.0F;
1218: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchModeX);
1219: pnlStretchHeight = Math.round ((float) pnlScreenHeight * pnlStretchModeY);
1220:
1221: if (PNL_ROTATION_ON) {
1222: pnlRotationMode = Settings.sgsGetInt ("rotation", 0);
1223: if (pnlRotationMode < 0 || 3 < pnlRotationMode) {
1224: pnlRotationMode = 0;
1225: }
1226: pnlRotationTransformLeft = new AffineTransform ();
1227: pnlRotationTransformRight = new AffineTransform ();
1228: }
1229: pnlRotatedWidth = pnlStretchWidth;
1230: pnlRotatedHeight = pnlStretchHeight;
1231: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1232: pnlRotatedWidth = pnlStretchHeight;
1233: pnlRotatedHeight = pnlStretchWidth;
1234: }
1235:
1236: pnlZoomWidth = pnlRotatedWidth;
1237: pnlZoomHeight = pnlRotatedHeight;
1238: pnlWidth = Math.max (pnlZoomWidth * pnlStereoscopicFactor, Keyboard.kbdWidth);
1239: pnlHeight = pnlZoomHeight + Keyboard.kbdHeight;
1240: pnlSize = new Dimension (pnlWidth, pnlHeight);
1241: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1242: pnlScreenY1 = 0;
1243: pnlArrangementCommon ();
1244: pnlMinimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
1245: pnlMinimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
1246: pnlGlobalX = 0;
1247: pnlGlobalY = 0;
1248:
1249:
1250: if (!PNL_FILL_BACKGROUND) {
1251: pnlFillBackgroundRequest = true;
1252: }
1253:
1254:
1255: pnlFixedModel = new SpinnerNumberModel (pnlFixedScale, 10, 1000, 1);
1256: pnlFixedSpinner = ComponentFactory.createNumberSpinner (pnlFixedModel, 4, new ChangeListener () {
1257: @Override public void stateChanged (ChangeEvent ce) {
1258: if (pnlMode != PNL_FIXEDSCALE) {
1259: pnlSetMode (PNL_FIXEDSCALE);
1260: } else {
1261: pnlUpdateArrangement ();
1262: }
1263: }
1264: });
1265:
1266: if (PNL_ROUNDED_CORNER_ON) {
1267: pnlRoundedCornerModel = new SpinnerNumberModel (pnlRoundedCornerRatio, 0, 50, 1);
1268: pnlRoundedCornerSpinner = ComponentFactory.createNumberSpinner (pnlRoundedCornerModel, 2, new ChangeListener () {
1269: @Override public void stateChanged (ChangeEvent ce) {
1270: pnlRoundedCornerRatio = pnlRoundedCornerModel.getNumber ().intValue ();
1271: if (PNL_ROUNDED_CORNER_TEST || pnlMode == PNL_FULLSCREEN) {
1272: pnlUpdateArrangement ();
1273: }
1274: }
1275: });
1276: }
1277:
1278: }
1279:
1280:
1281:
1282: public static double pnlGetRefreshRate () {
1283: double rate = 0.0;
1284: GraphicsConfiguration gc = frmFrame.getGraphicsConfiguration ();
1285: if (gc != null) {
1286: GraphicsDevice gd = gc.getDevice ();
1287: DisplayMode dm = gd.getDisplayMode ();
1288: int i = dm.getRefreshRate ();
1289: if (i != DisplayMode.REFRESH_RATE_UNKNOWN) {
1290: rate = (i == 23 ? 23.98 :
1291: i == 29 ? 29.97 :
1292: i == 59 ? 59.94 :
1293: i == 119 ? 119.88 :
1294: i == 239 ? 239.76 :
1295: (double) i);
1296: if (rate < PNL_MIN_RATE || PNL_MAX_RATE < rate) {
1297: rate = 0.0;
1298: }
1299: }
1300: }
1301: if (rate == 0.0) {
1302: rate = PNL_DEFAULT_RATE;
1303: System.out.printf (Multilingual.mlnJapanese ?
1304: "ホストのリフレッシュレートを取得できません。デフォルトの %.2f Hz を使います\n" :
1305: "Cannot get host refresh rate. Use default %.2f Hz\n", rate);
1306: } else {
1307: System.out.printf (Multilingual.mlnJapanese ?
1308: "ホストのリフレッシュレートは %.2f Hz です\n" :
1309: "Host refresh rate is %.2f Hz\n", rate);
1310: }
1311: return rate;
1312: }
1313:
1314:
1315: public static void pnlSetStereoscopic (boolean on, int method) {
1316: if (pnlStereoscopicOn != on || pnlStereoscopicMethod != method) {
1317: pnlStereoscopicMethod = method;
1318: pnlStereoscopicFactor = on && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1319: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1320: if (!pnlStereoscopicOn && on) {
1321: if (PNL_USE_THREAD) {
1322: for (int n = 0; n < 4; n++) {
1323: System.arraycopy (pnlBMLeftArray[n], 0, pnlBMRightArray[n], 0, 1024 * 1024);
1324: }
1325: } else {
1326: System.arraycopy (pnlBMLeft, 0, pnlBMRight, 0, 1024 * 1024);
1327: }
1328: } else if (pnlStereoscopicOn && !on) {
1329: if (PNL_USE_THREAD) {
1330: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
1331: } else {
1332: pnlBM = pnlBMLeft;
1333: }
1334: }
1335: pnlStereoscopicOn = on;
1336: pnlUpdateArrangement ();
1337: }
1338: }
1339:
1340:
1341: public static void pnlTini () {
1342: pnlTini2 ();
1343: if (PNL_USE_THREAD) {
1344: if (pnlThread != null) {
1345: pnlThread.interrupt ();
1346: try {
1347: pnlThread.join ();
1348: } catch (InterruptedException ie) {
1349: }
1350: pnlThread = null;
1351: }
1352: }
1353:
1354:
1355: Settings.sgsPutInt ("fixedscale", pnlFixedScale);
1356:
1357:
1358: for (int resolutionNumber = 0; resolutionNumber < PNL_ASPECT_RESOLUTION_COUNT; resolutionNumber++) {
1359: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[resolutionNumber];
1360: int ratioNumber = pnlAspectMap[resolutionNumber];
1361: String screenName = PNL_ASPECT_SCREEN_NAME[ratioNumber];
1362: Settings.sgsPutString ("aspectratio" + resolutionName, screenName);
1363: }
1364:
1365:
1366: Settings.sgsPutString ("interpolation",
1367: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR ? "nearest" :
1368: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR ? "bilinear" :
1369: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC ? "bicubic" :
1370: "bilinear");
1371:
1372: if (pnlRefreshRate != PNL_DEFAULT_RATE) {
1373: Settings.sgsPutString ("refreshrate",
1374: pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate));
1375: }
1376: Settings.sgsPutOnOff ("adjustvsync", pnlAdjustVsync);
1377:
1378: Settings.sgsPutOnOff ("hidekeyboard", pnlHideKeyboard);
1379:
1380: if (PNL_USE_CANVAS) {
1381: Settings.sgsPutOnOff ("usecanvas", pnlUseCanvasRequest);
1382: }
1383:
1384:
1385: Settings.sgsPutOnOff ("stereoscopic", pnlStereoscopicOn);
1386: Settings.sgsPutString ("stereoscopicmethod",
1387: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ? "nakedeyecrossing" :
1388: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL ? "nakedeyeparallel" :
1389: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ? "sidebyside" :
1390: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM ? "topandbottom" :
1391: "nakedeyecrossing");
1392:
1393:
1394: if (PNL_ROTATION_ON) {
1395: Settings.sgsPutInt ("rotation", pnlRotationMode);
1396: }
1397:
1398: }
1399:
1400:
1401:
1402: public static void pnlUpdateAspectTable () {
1403: float[] ratio = new float[PNL_ASPECT_RESOLUTION_COUNT];
1404: for (int resolutionNumber = 0; resolutionNumber < PNL_ASPECT_RESOLUTION_COUNT; resolutionNumber++) {
1405: int ratioNumber = pnlAspectMap[resolutionNumber];
1406: ratio[resolutionNumber] = PNL_ASPECT_RATIO_MATRIX[resolutionNumber][ratioNumber];
1407: }
1408: Arrays.fill (pnlAspectTableY, 1.0F);
1409:
1410: pnlAspectTableX[0b0_00_00] = ratio[0] * 2.0F;
1411: pnlAspectTableX[0b0_00_01] = ratio[2];
1412: pnlAspectTableX[0b0_00_10] = ratio[4];
1413: pnlAspectTableX[0b0_00_11] = ratio[3];
1414: pnlAspectTableX[0b0_01_00] = ratio[0] * 2.0F;
1415: pnlAspectTableX[0b0_01_01] = ratio[2];
1416: pnlAspectTableX[0b0_01_10] = ratio[4];
1417: pnlAspectTableX[0b0_01_11] = ratio[3];
1418: pnlAspectTableX[0b0_10_00] = ratio[0] * 4.0F;
1419: pnlAspectTableX[0b0_10_01] = ratio[2] * 2.0F;
1420: pnlAspectTableX[0b0_10_10] = ratio[4] * 2.0F;
1421: pnlAspectTableX[0b0_10_11] = ratio[3] * 2.0F;
1422: pnlAspectTableX[0b0_11_00] = ratio[0] * 4.0F;
1423: pnlAspectTableX[0b0_11_01] = ratio[2] * 2.0F;
1424: pnlAspectTableX[0b0_11_10] = ratio[4] * 2.0F;
1425: pnlAspectTableX[0b0_11_11] = ratio[3] * 2.0F;
1426: pnlAspectTableX[0b1_00_00] = ratio[0] * 2.0F;
1427: pnlAspectTableX[0b1_00_01] = ratio[1] * 2.0F;
1428: pnlAspectTableX[0b1_00_10] = ratio[4];
1429: pnlAspectTableX[0b1_00_11] = ratio[3];
1430: pnlAspectTableX[0b1_01_00] = ratio[0] * 2.0F;
1431: pnlAspectTableX[0b1_01_01] = ratio[1] * 2.0F;
1432: pnlAspectTableX[0b1_01_10] = ratio[4];
1433: pnlAspectTableX[0b1_01_11] = ratio[3];
1434: pnlAspectTableX[0b1_10_00] = ratio[0] * 4.0F;
1435: pnlAspectTableX[0b1_10_01] = ratio[1] * 2.0F;
1436: pnlAspectTableX[0b1_10_10] = ratio[4] * 2.0F;
1437: pnlAspectTableX[0b1_10_11] = ratio[3] * 2.0F;
1438: pnlAspectTableX[0b1_11_00] = ratio[0] * 4.0F;
1439: pnlAspectTableX[0b1_11_01] = ratio[1] * 2.0F;
1440: pnlAspectTableX[0b1_11_10] = ratio[4] * 2.0F;
1441: pnlAspectTableX[0b1_11_11] = ratio[3] * 2.0F;
1442:
1443: for (int i = 0; i < 32; i++) {
1444: pnlAspectTableX[32 + i] = pnlAspectTableX[i];
1445: }
1446:
1447: pnlAspectTableX[32 + 0b0_00_10] = ratio[5];
1448: pnlAspectTableY[32 + 0b0_00_10] = 2.0F;
1449: pnlAspectTableX[32 + 0b0_01_10] = ratio[5];
1450: pnlAspectTableY[32 + 0b0_01_10] = 2.0F;
1451: pnlAspectTableX[32 + 0b0_10_10] = ratio[5];
1452: pnlAspectTableX[32 + 0b0_11_10] = ratio[5];
1453: pnlAspectTableX[32 + 0b1_00_01] = ratio[5];
1454: pnlAspectTableX[32 + 0b1_01_01] = ratio[5];
1455: pnlAspectTableX[32 + 0b1_10_01] = ratio[5] * 2.0F;
1456: pnlAspectTableX[32 + 0b1_11_01] = ratio[5] * 2.0F;
1457: }
1458:
1459:
1460:
1461: public static void pnlMake () {
1462: pnlMake2 ();
1463:
1464:
1465: if (PNL_USE_CANVAS && pnlUseCanvas) {
1466: pnlCanvas = new Canvas ();
1467: pnlPanel = new JPanel (new BorderLayout (0, 0));
1468: pnlPanel.add (pnlCanvas, BorderLayout.CENTER);
1469: pnlCanvasOrPanel = pnlCanvas;
1470: } else {
1471: pnlPanel = new JPanel () {
1472: @Override protected void paintComponent (Graphics g) {
1473: pnlPaintCommon (g);
1474: }
1475: @Override protected void paintBorder (Graphics g) {
1476: }
1477: @Override protected void paintChildren (Graphics g) {
1478: }
1479: };
1480: pnlCanvasOrPanel = pnlPanel;
1481: }
1482: pnlPanel.setBackground (Color.black);
1483: pnlPanel.setOpaque (true);
1484: pnlPanel.setPreferredSize (pnlSize);
1485:
1486: if (Mouse.musCursorAvailable) {
1487: pnlPanel.setCursor (Mouse.musCursorArray[1]);
1488: }
1489:
1490: }
1491:
1492:
1493:
1494: public static void pnlPaintCommon (Graphics g) {
1495: Graphics2D g2 = (Graphics2D) g;
1496: if (PNL_FILL_BACKGROUND || pnlFillBackgroundRequest) {
1497: if (!PNL_FILL_BACKGROUND) {
1498: pnlFillBackgroundRequest = false;
1499: }
1500: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1501: g2.setColor (Color.black);
1502: g2.fillRect (0, 0, pnlWidth, pnlHeight);
1503: }
1504: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, pnlInterpolation);
1505: boolean compositeSet = false;
1506: if (FlashingLights.FLR_ON &&
1507: FlashingLights.flrScreen) {
1508: float brightness = FlashingLights.flrBrightness[pnlBMRead & 3];
1509: if (brightness < 1.0F) {
1510: g2.setComposite (
1511: AlphaComposite.getInstance (AlphaComposite.SRC_OVER, brightness));
1512: compositeSet = true;
1513: }
1514: }
1515: if (PNL_USE_THREAD) {
1516: int d = pnlBMWrite - pnlBMRead;
1517: if (false) {
1518: System.out.print (d);
1519: }
1520: if (d < 1) {
1521: pnlBMRead += d - 1;
1522: } else if (3 < d) {
1523: pnlBMRead += d - 3;
1524: }
1525: int n = pnlBMRead++ & 3;
1526: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1527: BufferedImage leftImage;
1528: BufferedImage rightImage;
1529: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1530: leftImage = pnlScreenImageRightArray[n];
1531: rightImage = pnlScreenImageLeftArray[n];
1532: } else {
1533:
1534:
1535:
1536: leftImage = pnlScreenImageLeftArray[n];
1537: rightImage = pnlScreenImageRightArray[n];
1538: }
1539: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1540: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1541: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1542: } else {
1543: g2.drawImage (leftImage,
1544: pnlScreenX1, pnlScreenY1,
1545: pnlScreenX2, pnlScreenY2,
1546: 0, 0, pnlScreenWidth, pnlScreenHeight,
1547: null);
1548: g2.drawImage (rightImage,
1549: pnlScreenX3, pnlScreenY3,
1550: pnlScreenX4, pnlScreenY4,
1551: 0, 0, pnlScreenWidth, pnlScreenHeight,
1552: null);
1553: }
1554: } else {
1555: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1556: g2.drawImage (pnlScreenSubImageLeftArray[n], pnlRotationTransformLeft, null);
1557: } else {
1558: g2.drawImage (pnlScreenImageLeftArray[n],
1559: pnlScreenX1, pnlScreenY1,
1560: pnlScreenX2, pnlScreenY2,
1561: 0, 0, pnlScreenWidth, pnlScreenHeight,
1562: null);
1563: }
1564: }
1565: } else {
1566: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1567: BufferedImage leftImage;
1568: BufferedImage rightImage;
1569: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1570: leftImage = pnlScreenImageRight;
1571: rightImage = pnlScreenImageLeft;
1572: } else {
1573:
1574:
1575:
1576: leftImage = pnlScreenImageLeft;
1577: rightImage = pnlScreenImageRight;
1578: }
1579: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1580: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1581: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1582: } else {
1583: g2.drawImage (leftImage,
1584: pnlScreenX1, pnlScreenY1,
1585: pnlScreenX2, pnlScreenY2,
1586: 0, 0, pnlScreenWidth, pnlScreenHeight,
1587: null);
1588: g2.drawImage (rightImage,
1589: pnlScreenX3, pnlScreenY3,
1590: pnlScreenX4, pnlScreenY4,
1591: 0, 0, pnlScreenWidth, pnlScreenHeight,
1592: null);
1593: }
1594: } else {
1595: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1596: g2.drawImage (pnlScreenImageLeft, pnlRotationTransformLeft, null);
1597: } else {
1598: g2.drawImage (pnlScreenImageLeft,
1599: pnlScreenX1, pnlScreenY1,
1600: pnlScreenX2, pnlScreenY2,
1601: 0, 0, pnlScreenWidth, pnlScreenHeight,
1602: null);
1603: }
1604: }
1605: }
1606: if (compositeSet) {
1607: g2.setComposite (
1608: AlphaComposite.getInstance (
1609: AlphaComposite.SRC_OVER,
1610: 1.0F));
1611: }
1612: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1613: g2.drawImage (Keyboard.kbdImage, pnlKeyboardX, pnlKeyboardY, null);
1614:
1615: if (TextCopy.txcEncloseEachTime && 0 <= TextCopy.txcRow1) {
1616: int x = TextCopy.txcCol1 << 3;
1617: int w = (TextCopy.txcCol2 - TextCopy.txcCol1 + 1) << 3;
1618: int y = TextCopy.txcRow1 << 4;
1619: int h = (TextCopy.txcRow2 - TextCopy.txcRow1 + 1) << 4;
1620: x -= CRTC.crtR10TxXCurr;
1621: y -= CRTC.crtR11TxYCurr;
1622: g2.setColor (Color.red);
1623: if (PNL_ROTATION_ON) {
1624: AffineTransform savedTransform = g2.getTransform ();
1625: g2.transform (pnlRotationTransformLeft);
1626: g2.drawRect (x, y, w, h);
1627: g2.setTransform (savedTransform);
1628: } else {
1629: g2.drawRect (pnlScreenX1 + ((x * pnlZoomRatioOutX) >> 16),
1630: pnlScreenY1 + ((y * pnlZoomRatioOutY) >> 16),
1631: ((w * pnlZoomRatioOutX) >> 16) - 1,
1632: ((h * pnlZoomRatioOutY) >> 16) - 1);
1633: }
1634: }
1635: if (Bubble.BBL_ON) {
1636: Bubble.bblDraw (g2);
1637: }
1638: }
1639:
1640:
1641:
1642:
1643: public static void pnlStart () {
1644: pnlStart2 ();
1645:
1646:
1647: ComponentFactory.addListener (
1648: pnlPanel,
1649: new ComponentAdapter () {
1650: @Override public void componentResized (ComponentEvent ce) {
1651: pnlUpdateArrangement ();
1652: }
1653: });
1654:
1655: if (PNL_USE_THREAD) {
1656: if (PNL_USE_CANVAS && pnlUseCanvas) {
1657: pnlCanvas.createBufferStrategy (2);
1658: pnlThread = new Thread () {
1659: @Override public void run () {
1660: do {
1661: BufferStrategy bs = pnlCanvas.getBufferStrategy ();
1662: if (bs != null) {
1663: Graphics g = bs.getDrawGraphics ();
1664: pnlPaintCommon (g);
1665: g.dispose ();
1666: bs.show ();
1667: }
1668: } while (!isInterrupted () && pnlWakeupCommon ());
1669: }
1670: };
1671: } else {
1672: pnlThread = new Thread () {
1673: @Override public void run () {
1674: do {
1675: pnlPanel.repaint ();
1676: if (!pnlWakeupCommon ()) {
1677: break;
1678: }
1679: } while (!isInterrupted () && pnlWakeupCommon ());
1680: }
1681: };
1682: }
1683: pnlWakeupTime = System.currentTimeMillis ();
1684: pnlWakeupTimeMNP = 0L;
1685: pnlThread.start ();
1686: }
1687:
1688: }
1689:
1690: public static boolean pnlWakeupCommon () {
1691: long t = System.currentTimeMillis ();
1692: if (CRTC.crtTotalLength == 0L) {
1693: pnlWakeupTime += 40L;
1694: } else {
1695: pnlWakeupTime += CRTC.crtTotalLength;
1696: pnlWakeupTimeMNP += CRTC.crtTotalLengthMNP;
1697: if (1000000000L <= pnlWakeupTimeMNP) {
1698: pnlWakeupTime++;
1699: pnlWakeupTimeMNP -= 1000000000L;
1700: }
1701: }
1702: pnlWakeupTime = Math.max (pnlWakeupTime, t + 4L);
1703: try {
1704: Thread.sleep (pnlWakeupTime - t);
1705: } catch (InterruptedException ie) {
1706: return false;
1707: }
1708: return true;
1709: }
1710:
1711:
1712:
1713:
1714:
1715: public static void pnlExitFullScreen (boolean dialog) {
1716: if (prgIsMac || !dialog) {
1717: pnlSetFullScreenOn (false);
1718: }
1719: }
1720:
1721:
1722:
1723: public static void pnlToggleFullScreen () {
1724: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1725: pnlSetMode (PNL_FULLSCREEN);
1726: } else {
1727: pnlSetMode (pnlPrevMode);
1728: }
1729: }
1730:
1731:
1732:
1733: public static void pnlToggleMaximized () {
1734: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1735: pnlSetMode (PNL_MAXIMIZED);
1736: } else {
1737: pnlSetMode (pnlPrevMode);
1738: }
1739: }
1740:
1741:
1742:
1743: public static void pnlSetFullScreenOn (boolean on) {
1744: if (on) {
1745: pnlSetMode (PNL_FULLSCREEN);
1746: } else if (pnlMode == PNL_FULLSCREEN) {
1747: pnlSetMode (pnlPrevMode);
1748: }
1749: }
1750:
1751:
1752:
1753:
1754: public static void pnlSetFitInWindowOn (boolean on) {
1755: if (!on) {
1756: pnlSetMode (PNL_FIXEDSCALE);
1757: } else if (pnlMode == PNL_FIXEDSCALE) {
1758: pnlSetMode (PNL_FITINWINDOW);
1759: }
1760: }
1761:
1762:
1763:
1764:
1765:
1766:
1767:
1768:
1769:
1770:
1771: public static void pnlUpdateArrangement () {
1772: pnlWidth = pnlPanel.getWidth ();
1773: pnlHeight = pnlPanel.getHeight ();
1774: frmMarginWidth = frmFrame.getWidth () - pnlWidth;
1775: frmMarginHeight = frmFrame.getHeight () - pnlHeight;
1776: int stretchIndex = CRTC.crtHRLCurr << 4 | CRTC.crtVResoCurr << 2 | CRTC.crtHResoCurr;
1777: {
1778: int htotal = CRTC.crtR00HFrontEndCurr + 1;
1779: int vtotal = CRTC.crtR04VFrontEndCurr + 1;
1780: if (0 < htotal && 0 < vtotal) {
1781: int k = CRTC.crtHRLCurr << 3 | CRTC.crtHighResoCurr << 2 | CRTC.crtHResoCurr;
1782: double osc = (double) CRTC.crtFreqs[CRTC.CRT_OSCS[k]] * CRTC.crtVsyncMultiplier;
1783: int ratio = CRTC.CRT_DIVS[k];
1784: double hfreq = osc / (ratio * htotal << 3);
1785: if (24000.0 <= hfreq && hfreq < 25000.0) {
1786: stretchIndex += 32;
1787: }
1788: }
1789: }
1790: pnlStretchModeX = pnlAspectTableX[stretchIndex];
1791: pnlStretchModeY = pnlAspectTableY[stretchIndex];
1792: pnlScreenWidth = Math.max (PNL_MIN_WIDTH, (CRTC.crtR03HDispEndCurr - CRTC.crtR02HBackEndCurr) << 3);
1793: pnlScreenHeight = Math.max (PNL_MIN_HEIGHT, (CRTC.crtR07VDispEndCurr - CRTC.crtR06VBackEndCurr) << (CRTC.crtInterlace || CRTC.crtSlit ? 1 : 0));
1794: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchModeX);
1795: pnlStretchHeight = Math.round ((float) pnlScreenHeight * pnlStretchModeY);
1796: if (RasterBreakPoint.RBP_ON) {
1797:
1798: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
1799: RasterBreakPoint.rbpUpdateFrame ();
1800: }
1801: }
1802:
1803: pnlFixedScale = pnlFixedModel.getNumber ().intValue ();
1804:
1805: pnlRotatedWidth = pnlStretchWidth;
1806: pnlRotatedHeight = pnlStretchHeight;
1807: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1808: pnlRotatedWidth = pnlStretchHeight;
1809: pnlRotatedHeight = pnlStretchWidth;
1810: }
1811: if (pnlMode == PNL_FIXEDSCALE) {
1812:
1813:
1814:
1815:
1816:
1817: pnlZoomWidth = (pnlRotatedWidth * pnlFixedScale + 50) * 5243 >>> 19;
1818: pnlZoomHeight = (pnlRotatedHeight * pnlFixedScale + 50) * 5243 >>> 19;
1819: int width = Math.max (Math.max (PNL_MIN_WIDTH, pnlZoomWidth * pnlStereoscopicFactor), Keyboard.kbdWidth);
1820: int height = Math.max (PNL_MIN_HEIGHT, pnlZoomHeight) + Keyboard.kbdHeight;
1821: pnlScreenX1 = (width - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1822: pnlScreenY1 = (height - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1823: if (pnlWidth != width || pnlHeight != height) {
1824: pnlWidth = width;
1825: pnlHeight = height;
1826: pnlMinimumWidth = width;
1827: pnlMinimumHeight = height;
1828: pnlSize.setSize (width, height);
1829: pnlPanel.setMinimumSize (pnlSize);
1830: pnlPanel.setMaximumSize (pnlSize);
1831: pnlPanel.setPreferredSize (pnlSize);
1832: }
1833: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1834: frmFrame.setMinimumSize (frmMinimumSize);
1835: frmFrame.setMaximumSize (frmMinimumSize);
1836: frmFrame.setPreferredSize (frmMinimumSize);
1837: frmFrame.setResizable (false);
1838: frmFrame.pack ();
1839: } else {
1840:
1841: if (PNL_ROUNDED_CORNER_ON) {
1842:
1843: int screenWidth = pnlRotatedWidth * pnlStereoscopicFactor;
1844:
1845: int screenHeight = pnlRotatedHeight;
1846:
1847: int maximumWidth = pnlWidth;
1848:
1849: int maximumHeight = pnlHeight - Keyboard.kbdHeight;
1850:
1851:
1852:
1853: double cornerRadius = (!(PNL_ROUNDED_CORNER_TEST || pnlMode == PNL_FULLSCREEN) ||
1854: (pnlStereoscopicOn &&
1855: (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ||
1856: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM)) ? 0 :
1857: Math.min (pnlWidth, pnlHeight) * (double) pnlRoundedCornerRatio / 100.0);
1858:
1859: double cornerWidth = cornerRadius * 2.0;
1860:
1861: double cornerHeight = cornerRadius * (Keyboard.kbdHeight != 0 ? 1.0 : 2.0);
1862:
1863: double straightWidth = maximumWidth - cornerWidth;
1864:
1865: double straightHeight = maximumHeight - cornerHeight;
1866: if (maximumHeight * screenWidth <= straightWidth * screenHeight) {
1867:
1868:
1869:
1870: pnlZoomHeight = maximumHeight;
1871:
1872: pnlZoomWidth = (pnlZoomHeight * screenWidth + (screenHeight >> 1)) / screenHeight;
1873:
1874: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1875:
1876: pnlScreenX1 = ((maximumWidth >> 1) - (pnlZoomWidth >> 1)) >> 1;
1877: } else {
1878: pnlScreenX1 = (maximumWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1879: }
1880: pnlScreenY1 = 0;
1881: } else if (maximumWidth * screenHeight <= straightHeight * screenWidth) {
1882:
1883:
1884:
1885: pnlZoomWidth = maximumWidth;
1886:
1887: pnlZoomHeight = (pnlZoomWidth * screenHeight + (screenWidth >> 1)) / screenWidth;
1888:
1889: pnlScreenX1 = 0;
1890: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM) {
1891:
1892: pnlScreenY1 = ((maximumHeight >> 1) - (pnlZoomHeight >> 1)) >> 1;
1893: } else {
1894: pnlScreenY1 = (maximumHeight - pnlZoomHeight) >> 1;
1895: }
1896: } else {
1897:
1898:
1899:
1900:
1901:
1902:
1903:
1904:
1905:
1906:
1907:
1908:
1909:
1910:
1911:
1912:
1913:
1914:
1915:
1916:
1917:
1918:
1919:
1920: double ax = 1.0;
1921: double ay = 0.0;
1922: double bx = 0.0;
1923: double by = 1.0;
1924: for (int i = 0; i < 4; i++) {
1925: double mx;
1926: double my;
1927: if (false) {
1928: double t = (ax * bx - ay * by) * 0.5;
1929: mx = Math.sqrt (0.5 + t);
1930: my = Math.sqrt (0.5 - t);
1931: } else {
1932: double sx = ax + bx;
1933: double sy = ay + by;
1934: double t = Math.cbrt (2.0 + 3.0 * (ax * bx * sx + ay * by * sy));
1935: mx = sx / t;
1936: my = sy / t;
1937: }
1938:
1939: double temporaryWidth = straightWidth + mx * cornerWidth;
1940:
1941: double temporaryHeight = straightHeight + my * cornerHeight;
1942: if (temporaryHeight * screenWidth <= temporaryWidth * screenHeight) {
1943:
1944:
1945: ax = mx;
1946: ay = my;
1947: } else {
1948:
1949: bx = mx;
1950: by = my;
1951: }
1952: }
1953:
1954:
1955:
1956:
1957:
1958:
1959:
1960:
1961:
1962:
1963:
1964:
1965: double t = (((straightHeight + ay * cornerHeight) * screenWidth
1966: - (straightWidth + ax * cornerWidth) * screenHeight)
1967: / ((bx - ax) * cornerWidth * screenHeight
1968: - (by - ay) * cornerHeight * screenWidth));
1969:
1970: pnlZoomWidth = (int) Math.round (straightWidth + (ax + (bx - ax) * t) * cornerWidth);
1971: if (false) {
1972:
1973: pnlZoomHeight = (int) Math.round (straightHeight + (ay + (by - ay) * t) * cornerHeight);
1974: } else {
1975:
1976: pnlZoomHeight = (pnlZoomWidth * screenHeight + (screenWidth >> 1)) / screenWidth;
1977: }
1978:
1979: pnlScreenX1 = (maximumWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1980: pnlScreenY1 = (maximumHeight - pnlZoomHeight) >> 1;
1981: }
1982: } else {
1983: if (pnlWidth * pnlRotatedHeight >= (pnlHeight - Keyboard.kbdHeight) * (pnlRotatedWidth * pnlStereoscopicFactor)) {
1984:
1985:
1986:
1987:
1988:
1989:
1990:
1991:
1992:
1993:
1994:
1995:
1996: pnlZoomHeight = pnlHeight - Keyboard.kbdHeight;
1997: pnlZoomWidth = (pnlZoomHeight * pnlRotatedWidth + (pnlRotatedHeight >> 1)) / pnlRotatedHeight;
1998: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1999: pnlScreenX1 = ((pnlWidth >> 1) - (pnlZoomWidth >> 1)) >> 1;
2000: } else {
2001: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
2002: }
2003: pnlScreenY1 = 0;
2004: } else {
2005:
2006:
2007:
2008:
2009:
2010:
2011:
2012:
2013:
2014:
2015:
2016:
2017:
2018:
2019:
2020:
2021: pnlZoomWidth = pnlWidth / pnlStereoscopicFactor;
2022: pnlZoomHeight = (pnlZoomWidth * pnlStereoscopicFactor * pnlRotatedHeight + (pnlRotatedWidth * pnlStereoscopicFactor >> 1)) / (pnlRotatedWidth * pnlStereoscopicFactor);
2023: pnlScreenX1 = 0;
2024: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM) {
2025: pnlScreenY1 = (((pnlHeight - Keyboard.kbdHeight) >> 1) - (pnlZoomHeight >> 1)) >> 1;
2026: } else {
2027: pnlScreenY1 = (pnlHeight - (pnlZoomHeight + Keyboard.kbdHeight)) >> 1;
2028: }
2029: }
2030: }
2031:
2032: int minimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
2033: int minimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
2034: if (pnlMinimumWidth != minimumWidth || pnlMinimumHeight != minimumHeight) {
2035: pnlMinimumWidth = minimumWidth;
2036: pnlMinimumHeight = minimumHeight;
2037: }
2038: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
2039: frmFrame.setMinimumSize (frmMinimumSize);
2040: frmFrame.setMaximumSize (null);
2041: frmFrame.setResizable (true);
2042: }
2043:
2044: pnlArrangementCommon ();
2045: Mouse.musUpdateSpeedRatio ();
2046: if (!PNL_FILL_BACKGROUND) {
2047: pnlFillBackgroundRequest = true;
2048: }
2049: if (FlashingLights.FLR_ON &&
2050: FlashingLights.flrEnabled) {
2051: FlashingLights.flrMakeIndex ();
2052: }
2053: }
2054:
2055: public static void pnlArrangementCommon () {
2056: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
2057: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
2058: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) {
2059: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
2060: pnlScreenX3 = pnlScreenX2;
2061: pnlScreenX4 = pnlScreenX3 + pnlZoomWidth;
2062: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
2063: pnlScreenY3 = pnlScreenY1;
2064: pnlScreenY4 = pnlScreenY2;
2065: } else if (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
2066: pnlScreenX2 = pnlScreenX1 + (pnlZoomWidth >> 1);
2067: pnlScreenX3 = pnlScreenX2;
2068: pnlScreenX4 = pnlScreenX3 + (pnlZoomWidth >> 1);
2069: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
2070: pnlScreenY3 = pnlScreenY1;
2071: pnlScreenY4 = pnlScreenY2;
2072: } else {
2073: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
2074: pnlScreenX3 = pnlScreenX1;
2075: pnlScreenX4 = pnlScreenX2;
2076: pnlScreenY2 = pnlScreenY1 + (pnlZoomHeight >> 1);
2077: pnlScreenY3 = pnlScreenY2;
2078: pnlScreenY4 = pnlScreenY3 + (pnlZoomHeight >> 1);
2079: }
2080: } else {
2081: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
2082: pnlScreenX3 = pnlScreenX1;
2083: pnlScreenX4 = pnlScreenX2;
2084: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
2085: pnlScreenY3 = pnlScreenY1;
2086: pnlScreenY4 = pnlScreenY2;
2087: }
2088: pnlKeyboardX = (pnlWidth - Keyboard.kbdWidth) >> 1;
2089: pnlKeyboardY = pnlScreenY4;
2090: pnlZoomRatioOutX = ((pnlZoomWidth * pnlStereoscopicFactor) << 16) / pnlScreenWidth;
2091: pnlZoomRatioOutY = (pnlZoomHeight << 16) / pnlScreenHeight;
2092: pnlZoomRatioInX = (pnlScreenWidth << 16) / (pnlZoomWidth * pnlStereoscopicFactor);
2093: pnlZoomRatioInY = (pnlScreenHeight << 16) / pnlZoomHeight;
2094: if (PNL_ROTATION_ON) {
2095:
2096: if (PNL_USE_THREAD) {
2097: for (int n = 0; n < 4; n++) {
2098: pnlScreenSubImageLeftArray[n] = pnlScreenImageLeftArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
2099: pnlScreenSubImageRightArray[n] = pnlScreenImageRightArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
2100: }
2101: } else {
2102: pnlScreenSubImageLeft = pnlScreenImageLeft.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
2103: pnlScreenSubImageRight = pnlScreenImageRight.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
2104: }
2105:
2106:
2107:
2108:
2109: double ax = 0.0;
2110: double ay = 0.0;
2111: double bx = (double) pnlScreenWidth;
2112: double by = (double) pnlScreenHeight;
2113: double l00, l10, l01, l11, l02, l12;
2114: double r00, r10, r01, r11, r02, r12;
2115: if (pnlRotationMode == 0) {
2116: double cx = (double) pnlScreenX1;
2117: double cy = (double) pnlScreenY1;
2118: double dx = (double) pnlScreenX2;
2119: double dy = (double) pnlScreenY2;
2120: l00 = (cx - dx) / (ax - bx);
2121: l10 = 0.0;
2122: l01 = 0.0;
2123: l11 = (cy - dy) / (ay - by);
2124: l02 = (ax * dx - bx * cx) / (ax - bx);
2125: l12 = (ay * dy - by * cy) / (ay - by);
2126: cx = (double) pnlScreenX3;
2127: cy = (double) pnlScreenY3;
2128: dx = (double) pnlScreenX4;
2129: dy = (double) pnlScreenY4;
2130: r00 = (cx - dx) / (ax - bx);
2131: r10 = 0.0;
2132: r01 = 0.0;
2133: r11 = (cy - dy) / (ay - by);
2134: r02 = (ax * dx - bx * cx) / (ax - bx);
2135: r12 = (ay * dy - by * cy) / (ay - by);
2136: } else if (pnlRotationMode == 1) {
2137: double cx = (double) pnlScreenX1;
2138: double cy = (double) pnlScreenY1;
2139: double dx = (double) pnlScreenX2;
2140: double dy = (double) pnlScreenY2;
2141: l00 = 0.0;
2142: l10 = (dy - cy) / (ax - bx);
2143: l01 = (cx - dx) / (ay - by);
2144: l11 = 0.0;
2145: l02 = (ay * dx - by * cx) / (ay - by);
2146: l12 = (ax * cy - bx * dy) / (ax - bx);
2147: cx = (double) pnlScreenX3;
2148: cy = (double) pnlScreenY3;
2149: dx = (double) pnlScreenX4;
2150: dy = (double) pnlScreenY4;
2151: r00 = 0.0;
2152: r10 = (dy - cy) / (ax - bx);
2153: r01 = (cx - dx) / (ay - by);
2154: r11 = 0.0;
2155: r02 = (ay * dx - by * cx) / (ay - by);
2156: r12 = (ax * cy - bx * dy) / (ax - bx);
2157: } else if (pnlRotationMode == 2) {
2158: double cx = (double) pnlScreenX1;
2159: double cy = (double) pnlScreenY1;
2160: double dx = (double) pnlScreenX2;
2161: double dy = (double) pnlScreenY2;
2162: l00 = (dx - cx) / (ax - bx);
2163: l10 = 0.0;
2164: l01 = 0.0;
2165: l11 = (dy - cy) / (ay - by);
2166: l02 = (ax * cx - bx * dx) / (ax - bx);
2167: l12 = (ay * cy - by * dy) / (ay - by);
2168: cx = (double) pnlScreenX3;
2169: cy = (double) pnlScreenY3;
2170: dx = (double) pnlScreenX4;
2171: dy = (double) pnlScreenY4;
2172: r00 = (dx - cx) / (ax - bx);
2173: r10 = 0.0;
2174: r01 = 0.0;
2175: r11 = (dy - cy) / (ay - by);
2176: r02 = (ax * cx - bx * dx) / (ax - bx);
2177: r12 = (ay * cy - by * dy) / (ay - by);
2178: } else {
2179: double cx = (double) pnlScreenX1;
2180: double cy = (double) pnlScreenY1;
2181: double dx = (double) pnlScreenX2;
2182: double dy = (double) pnlScreenY2;
2183: l00 = 0.0;
2184: l10 = (cy - dy) / (ax - bx);
2185: l01 = (dx - cx) / (ay - by);
2186: l11 = 0.0;
2187: l02 = (ay * cx - by * dx) / (ay - by);
2188: l12 = (ax * dy - bx * cy) / (ax - bx);
2189: cx = (double) pnlScreenX3;
2190: cy = (double) pnlScreenY3;
2191: dx = (double) pnlScreenX4;
2192: dy = (double) pnlScreenY4;
2193: r00 = 0.0;
2194: r10 = (cy - dy) / (ax - bx);
2195: r01 = (dx - cx) / (ay - by);
2196: r11 = 0.0;
2197: r02 = (ay * cx - by * dx) / (ay - by);
2198: r12 = (ax * dy - bx * cy) / (ax - bx);
2199: }
2200: pnlRotationTransformLeft.setTransform (l00, l10, l01, l11, l02, l12);
2201: pnlRotationTransformRight.setTransform (r00, r10, r01, r11, r02, r12);
2202: pnlMatrixL00 = l00;
2203: pnlMatrixL10 = l10;
2204: pnlMatrixL01 = l01;
2205: pnlMatrixL11 = l11;
2206: pnlMatrixL02 = l02;
2207: pnlMatrixL12 = l12;
2208: pnlMatrixR00 = r00;
2209: pnlMatrixR10 = r10;
2210: pnlMatrixR01 = r01;
2211: pnlMatrixR11 = r11;
2212: pnlMatrixR02 = r02;
2213: pnlMatrixR12 = r12;
2214:
2215:
2216:
2217:
2218:
2219:
2220: double d = l00 * l11 - l01 * l10;
2221: pnlInverseL00 = l11 / d;
2222: pnlInverseL10 = -l10 / d;
2223: pnlInverseL01 = -l01 / d;
2224: pnlInverseL11 = l00 / d;
2225: pnlInverseL02 = (l01 * l12 - l02 * l11) / d;
2226: pnlInverseL12 = (l02 * l10 - l00 * l12) / d;
2227: d = r00 * r11 - r01 * r10;
2228: pnlInverseR00 = r11 / d;
2229: pnlInverseR10 = -r10 / d;
2230: pnlInverseR01 = -r01 / d;
2231: pnlInverseR11 = r00 / d;
2232: pnlInverseR02 = (r01 * r12 - r02 * r11) / d;
2233: pnlInverseR12 = (r02 * r10 - r00 * r12) / d;
2234: }
2235: }
2236:
2237:
2238:
2239:
2240: public static final int PNL_UNDEFINED = 0;
2241: public static final int PNL_FIXEDSCALE = 1;
2242: public static final int PNL_FITINWINDOW = 2;
2243: public static final int PNL_FULLSCREEN = 3;
2244: public static final int PNL_MAXIMIZED = 4;
2245: public static int pnlModeRequest;
2246: public static int pnlMode;
2247: public static int pnlPrevMode;
2248:
2249:
2250: public static JRadioButtonMenuItem mnbFullScreenMenuItem;
2251: public static JRadioButtonMenuItem mnbMaximizedMenuItem;
2252: public static JRadioButtonMenuItem mnbFitInWindowMenuItem;
2253: public static JRadioButtonMenuItem mnbFixedScaleMenuItem;
2254:
2255:
2256:
2257:
2258:
2259: public static boolean PNL_ROUNDED_CORNER_ON = true;
2260: public static boolean PNL_ROUNDED_CORNER_TEST = false;
2261: public static int pnlRoundedCornerRatio;
2262: public static SpinnerNumberModel pnlRoundedCornerModel;
2263: public static JSpinner pnlRoundedCornerSpinner;
2264:
2265:
2266: public static int PNL_BOOT_DELAY = 500;
2267: public static javax.swing.Timer pnlBootTimer;
2268:
2269:
2270:
2271: public static void pnlInit2 () {
2272: pnlModeRequest = PNL_UNDEFINED;
2273: pnlMode = PNL_FITINWINDOW;
2274: pnlPrevMode = PNL_FITINWINDOW;
2275: switch (Settings.sgsGetString ("scaling").toLowerCase ()) {
2276: case "fullscreen":
2277: pnlModeRequest = PNL_FULLSCREEN;
2278: break;
2279: case "maximized":
2280: pnlModeRequest = PNL_MAXIMIZED;
2281: break;
2282: case "fitinwindow":
2283: break;
2284: case "fixedscale":
2285: pnlMode = PNL_FIXEDSCALE;
2286: break;
2287: }
2288: if (PNL_ROUNDED_CORNER_ON) {
2289: pnlRoundedCornerRatio = Settings.sgsGetInt ("roundedcornerratio", 0, 0, 50);
2290: }
2291: }
2292:
2293:
2294:
2295: public static void pnlTini2 () {
2296: Settings.sgsPutString ("scaling",
2297: pnlMode == PNL_FULLSCREEN ? "fullscreen" :
2298: pnlMode == PNL_MAXIMIZED ? "maximized" :
2299: pnlMode == PNL_FITINWINDOW ? "fitinwindow" :
2300: "fixedscale");
2301: if (PNL_ROUNDED_CORNER_ON) {
2302: Settings.sgsPutInt ("roundedcornerratio", pnlRoundedCornerRatio);
2303: }
2304: }
2305:
2306:
2307:
2308: public static void pnlMake2 () {
2309:
2310: ActionListener listener = new ActionListener () {
2311: @Override public void actionPerformed (ActionEvent ae) {
2312: String command = ae.getActionCommand ();
2313: switch (command) {
2314: case "Full screen":
2315: pnlSetMode (PNL_FULLSCREEN);
2316: break;
2317: case "Maximized":
2318: pnlSetMode (PNL_MAXIMIZED);
2319: break;
2320: case "Resize the X68000 screen to fit the window":
2321: pnlSetMode (PNL_FITINWINDOW);
2322: break;
2323: case "Resize the window to fit the X68000 screen":
2324: pnlSetMode (PNL_FIXEDSCALE);
2325: break;
2326: }
2327: }
2328: };
2329: ButtonGroup group = new ButtonGroup ();
2330: mnbFullScreenMenuItem = ComponentFactory.setEnabled (
2331: Multilingual.mlnText (
2332: ComponentFactory.createRadioButtonMenuItem (
2333: group,
2334: pnlMode == PNL_FULLSCREEN,
2335: "Full screen",
2336: listener),
2337: "ja", "全画面表示"),
2338: pnlIsFullScreenSupported);
2339: mnbMaximizedMenuItem = Multilingual.mlnText (
2340: ComponentFactory.createRadioButtonMenuItem (
2341: group,
2342: pnlMode == PNL_MAXIMIZED,
2343: "Maximized",
2344: listener),
2345: "ja", "最大化");
2346: mnbFitInWindowMenuItem = Multilingual.mlnText (
2347: ComponentFactory.createRadioButtonMenuItem (
2348: group,
2349: pnlMode == PNL_FITINWINDOW,
2350: "Resize the X68000 screen to fit the window",
2351: 'W',
2352: MNB_MODIFIERS,
2353: listener),
2354: "ja", "X68000の画面をリサイズしてウインドウに合わせる");
2355: mnbFixedScaleMenuItem = Multilingual.mlnText (
2356: ComponentFactory.createRadioButtonMenuItem (
2357: group,
2358: pnlMode == PNL_FIXEDSCALE,
2359: "Resize the window to fit the X68000 screen",
2360: 'X',
2361: MNB_MODIFIERS,
2362: listener),
2363: "ja", "ウインドウをリサイズしてX68000の画面に合わせる");
2364: }
2365:
2366:
2367:
2368: public static void pnlStart2 () {
2369:
2370: frmFrame.addWindowStateListener (new WindowStateListener () {
2371: @Override public void windowStateChanged (WindowEvent we) {
2372: int state = frmFrame.getExtendedState ();
2373: if (pnlMode != PNL_MAXIMIZED &&
2374: (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
2375: pnlSetMode (PNL_MAXIMIZED);
2376: } else if (pnlMode == PNL_MAXIMIZED &&
2377: (state & Frame.MAXIMIZED_BOTH) != Frame.MAXIMIZED_BOTH) {
2378: pnlSetMode (pnlPrevMode);
2379: }
2380: }
2381: });
2382: }
2383:
2384:
2385:
2386: public static void pnlBoot2 () {
2387: if (pnlModeRequest != PNL_UNDEFINED) {
2388: pnlBootTimer = new javax.swing.Timer (PNL_BOOT_DELAY, new ActionListener () {
2389: public void actionPerformed (ActionEvent ae) {
2390: if (pnlModeRequest == PNL_FULLSCREEN) {
2391: mnbFullScreenMenuItem.doClick ();
2392: } else if (pnlModeRequest == PNL_MAXIMIZED) {
2393: mnbMaximizedMenuItem.doClick ();
2394: }
2395: pnlBootTimer.stop ();
2396: pnlBootTimer = null;
2397: }
2398: });
2399: pnlBootTimer.start ();
2400: }
2401: }
2402:
2403:
2404:
2405: public static void pnlSetMode (int mode) {
2406: do {
2407:
2408: if (pnlMode == mode) {
2409: break;
2410: }
2411:
2412: String text = null;
2413: if (mode == PNL_FULLSCREEN) {
2414: if (!pnlIsFullScreenSupported) {
2415: JOptionPane.showMessageDialog (
2416: frmFrame,
2417: Multilingual.mlnJapanese ?
2418: "全画面表示に対応していません" :
2419: "Full screen is not supported");
2420: break;
2421: }
2422: if (Bubble.BBL_ON) {
2423: text = ButtonFunction.bfnFullScreenText ();
2424: if (text == null) {
2425: JOptionPane.showMessageDialog (
2426: frmFrame,
2427: Multilingual.mlnJapanese ?
2428: "全画面表示を終了するキーまたはボタンがありません" :
2429: "No key or button to exit full screen");
2430: break;
2431: }
2432: }
2433: }
2434:
2435: if (pnlMode == PNL_FULLSCREEN) {
2436: pnlMode = pnlPrevMode;
2437: if (Bubble.BBL_ON) {
2438: Bubble.bblEnd ();
2439: }
2440: if (frmScreenDevice.getFullScreenWindow () == frmFrame) {
2441: frmScreenDevice.setFullScreenWindow (null);
2442: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.FRAME);
2443: }
2444: frmFrame.setJMenuBar (mnbMenuBar);
2445: if (pnlHideKeyboard) {
2446: if (pnlPrevKeyboardOn) {
2447: Keyboard.kbdSetOn (true);
2448: }
2449: }
2450: } else if (pnlMode == PNL_MAXIMIZED) {
2451: pnlMode = pnlPrevMode;
2452: if ((frmFrame.getExtendedState () & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
2453: frmFrame.setExtendedState (Frame.NORMAL);
2454: }
2455: }
2456:
2457: if (mode == PNL_FULLSCREEN) {
2458: pnlPrevMode = pnlMode;
2459: if (pnlHideKeyboard) {
2460: pnlPrevKeyboardOn = Keyboard.kbdImage != null;
2461: if (pnlPrevKeyboardOn) {
2462: Keyboard.kbdSetOn (false);
2463: }
2464: }
2465: frmFrame.setJMenuBar (null);
2466: if (frmScreenDevice.getFullScreenWindow () != frmFrame) {
2467: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.NONE);
2468: frmScreenDevice.setFullScreenWindow (frmFrame);
2469: }
2470: if (Bubble.BBL_ON) {
2471: if (text != null) {
2472: Bubble.bblStart (text + (Multilingual.mlnJapanese ? "で全画面表示を終了" : " to exit full screen"), 5000L);
2473: }
2474: }
2475: } else if (mode == PNL_MAXIMIZED) {
2476: pnlPrevMode = pnlMode;
2477: frmFrame.setExtendedState (Frame.MAXIMIZED_BOTH);
2478: }
2479: pnlMode = mode;
2480:
2481:
2482: pnlUpdateArrangement ();
2483: } while (false);
2484:
2485: if (pnlMode == PNL_FIXEDSCALE) {
2486: if (!mnbFixedScaleMenuItem.isSelected ()) {
2487: mnbFixedScaleMenuItem.setSelected (true);
2488: }
2489: } else if (pnlMode == PNL_FITINWINDOW) {
2490: if (!mnbFitInWindowMenuItem.isSelected ()) {
2491: mnbFitInWindowMenuItem.setSelected (true);
2492: }
2493: } else if (pnlMode == PNL_FULLSCREEN) {
2494: if (!mnbFullScreenMenuItem.isSelected ()) {
2495: mnbFullScreenMenuItem.setSelected (true);
2496: }
2497: } else if (pnlMode == PNL_MAXIMIZED) {
2498: if (!mnbMaximizedMenuItem.isSelected ()) {
2499: mnbMaximizedMenuItem.setSelected (true);
2500: }
2501: }
2502: }
2503:
2504:
2505:
2506:
2507:
2508:
2509: public static Robot rbtRobot;
2510:
2511:
2512: public static void rbtInit () {
2513:
2514:
2515: rbtRobot = null;
2516: try {
2517: rbtRobot = new Robot ();
2518: } catch (Exception e) {
2519: }
2520:
2521: }
2522:
2523:
2524:
2525:
2526:
2527:
2528:
2529: public static final int MNB_MODIFIERS = InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK;
2530:
2531:
2532: public static JMenuBar mnbMenuBar;
2533:
2534:
2535: public static JMenu mnbFileMenu;
2536: public static JMenu mnbDisplayMenu;
2537: public static JMenu mnbSoundMenu;
2538: public static JMenu mnbInputMenu;
2539: public static JMenu mnbConfigMenu;
2540: public static JMenu mnbLanguageMenu;
2541:
2542:
2543:
2544:
2545:
2546: public static JMenuItem mnbQuitMenuItem;
2547: public static JCheckBoxMenuItem mnbStereoscopicMenuItem;
2548: public static JCheckBoxMenuItem mnbPlayMenuItem;
2549: public static JMenuItem mnbPasteMenuItem;
2550: public static JRadioButtonMenuItem mnbStandardKeyboardMenuItem;
2551: public static JRadioButtonMenuItem mnbCompactKeyboardMenuItem;
2552: public static JRadioButtonMenuItem mnbNoKeyboardMenuItem;
2553: public static JLabel mnbVolumeLabel;
2554:
2555:
2556:
2557:
2558:
2559:
2560: public static JMenu mnbMakeFontSizeMenu () {
2561:
2562: ActionListener actionListener = new ActionListener () {
2563: @Override public void actionPerformed (ActionEvent ae) {
2564: String command = ae.getActionCommand ();
2565: switch (command) {
2566: case "Very small":
2567: LnF.lnfFontSizeRequest = 10;
2568: break;
2569: case "Small":
2570: LnF.lnfFontSizeRequest = 12;
2571: break;
2572: case "Medium":
2573: LnF.lnfFontSizeRequest = 14;
2574: break;
2575: case "Large":
2576: LnF.lnfFontSizeRequest = 16;
2577: break;
2578: case "Very large":
2579: LnF.lnfFontSizeRequest = 18;
2580: break;
2581: default:
2582: System.out.println ("unknown action command " + command);
2583: }
2584: }
2585: };
2586:
2587: ButtonGroup fontSizeGroup = new ButtonGroup ();
2588:
2589: return Multilingual.mlnText (
2590: ComponentFactory.createMenu (
2591: "Font size",
2592: Multilingual.mlnText (
2593: ComponentFactory.pointSize (
2594: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 10, "Very small", actionListener),
2595: 10),
2596: "ja", "極小"),
2597: Multilingual.mlnText (
2598: ComponentFactory.pointSize (
2599: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 12, "Small", actionListener),
2600: 12),
2601: "ja", "小"),
2602: Multilingual.mlnText (
2603: ComponentFactory.pointSize (
2604: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 14, "Medium", actionListener),
2605: 14),
2606: "ja", "中"),
2607: Multilingual.mlnText (
2608: ComponentFactory.pointSize (
2609: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 16, "Large", actionListener),
2610: 16),
2611: "ja", "大"),
2612: Multilingual.mlnText (
2613: ComponentFactory.pointSize (
2614: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 18, "Very large", actionListener),
2615: 18),
2616: "ja", "極大")),
2617: "ja", "フォントサイズ");
2618: }
2619:
2620:
2621:
2622: public static final DecimalSpinner[] mnbColorSpinners = new DecimalSpinner[9];
2623: public static final int[] mnbColorRGB = new int[15];
2624: public static JPanel mnbColorPanel;
2625:
2626:
2627:
2628: public static void mnbColorHSBToRGB () {
2629: for (int i = 0; i <= 14; i++) {
2630: int[] t = LnF.LNF_HSB_INTERPOLATION_TABLE[i];
2631: float h = (float) (t[0] * LnF.lnfHSB[0] + t[1] * LnF.lnfHSB[1] + t[2] * LnF.lnfHSB[2]) / (49.0F * 360.0F);
2632: float s = (float) (t[0] * LnF.lnfHSB[3] + t[1] * LnF.lnfHSB[4] + t[2] * LnF.lnfHSB[5]) / (49.0F * 100.0F);
2633: float b = (float) (t[0] * LnF.lnfHSB[6] + t[1] * LnF.lnfHSB[7] + t[2] * LnF.lnfHSB[8]) / (49.0F * 100.0F);
2634: mnbColorRGB[i] = Color.HSBtoRGB (h,
2635: Math.max (0.0F, Math.min (1.0F, s)),
2636: Math.max (0.0F, Math.min (1.0F, b)));
2637: }
2638: }
2639:
2640:
2641:
2642: public static JMenu mnbMakeColorMenu () {
2643: mnbColorHSBToRGB ();
2644:
2645: mnbColorPanel = ComponentFactory.setColor (
2646: ComponentFactory.setFixedSize (
2647: new JPanel () {
2648: @Override protected void paintComponent (Graphics g) {
2649: super.paintComponent (g);
2650: for (int i = 0; i <= 14; i++) {
2651: g.setColor (new Color (mnbColorRGB[i]));
2652: g.fillRect (LnF.lnfFontSize * i, 0, LnF.lnfFontSize, LnF.lnfFontSize * 5);
2653: }
2654: }
2655: },
2656: LnF.lnfFontSize * 15, LnF.lnfFontSize * 5),
2657: Color.white, Color.black);
2658:
2659: ChangeListener changeListener = new ChangeListener () {
2660: @Override public void stateChanged (ChangeEvent ce) {
2661: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
2662: LnF.lnfHSB[spinner.getOption ()] = spinner.getIntValue ();
2663: mnbColorHSBToRGB ();
2664: mnbColorPanel.repaint ();
2665: }
2666: };
2667:
2668: ActionListener actionListener = new ActionListener () {
2669: @Override public void actionPerformed (ActionEvent ae) {
2670: String command = ae.getActionCommand ();
2671: switch (command) {
2672: case "Reset to default values":
2673: for (int i = 0; i < 9; i++) {
2674: LnF.lnfHSB[i] = LnF.LNF_DEFAULT_HSB[i];
2675: mnbColorSpinners[i].setIntValue (LnF.lnfHSB[i]);
2676: }
2677: mnbColorHSBToRGB ();
2678: mnbColorPanel.repaint ();
2679: break;
2680: default:
2681: System.out.println ("unknown action command " + command);
2682: }
2683: }
2684: };
2685:
2686: for (int i = 0; i < 9; i++) {
2687: mnbColorSpinners[i] = ComponentFactory.createDecimalSpinner (
2688: LnF.lnfHSB[i], 0, i < 3 ? 720 : 100, 1, i, changeListener);
2689: }
2690:
2691: return Multilingual.mlnText (
2692: ComponentFactory.createMenu (
2693: "Color",
2694: ComponentFactory.createHorizontalBox (
2695: mnbColorSpinners[0],
2696: mnbColorSpinners[1],
2697: mnbColorSpinners[2],
2698: ComponentFactory.createLabel ("H °"),
2699: Box.createHorizontalGlue ()
2700: ),
2701: ComponentFactory.createHorizontalBox (
2702: mnbColorSpinners[3],
2703: mnbColorSpinners[4],
2704: mnbColorSpinners[5],
2705: ComponentFactory.createLabel ("S%"),
2706: Box.createHorizontalGlue ()
2707: ),
2708: ComponentFactory.createHorizontalBox (
2709: mnbColorSpinners[6],
2710: mnbColorSpinners[7],
2711: mnbColorSpinners[8],
2712: ComponentFactory.createLabel ("B%"),
2713: Box.createHorizontalGlue ()
2714: ),
2715: ComponentFactory.createHorizontalBox (
2716: ComponentFactory.setLineBorder (mnbColorPanel),
2717: Box.createHorizontalGlue ()
2718: ),
2719: Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset to default values", actionListener), "ja", "初期値に戻す")
2720: ),
2721: "ja", "色");
2722: }
2723:
2724:
2725:
2726:
2727:
2728: public static JMenu mnbMakeLanguageMenu () {
2729:
2730: ActionListener actionListener = new ActionListener () {
2731: @Override public void actionPerformed (ActionEvent ae) {
2732: String command = ae.getActionCommand ();
2733: switch (command) {
2734: case "English":
2735: Multilingual.mlnChange ("en");
2736: break;
2737: case "日本語":
2738: Multilingual.mlnChange ("ja");
2739: break;
2740: default:
2741: System.out.println ("unknown action command " + command);
2742: }
2743: }
2744: };
2745:
2746: ButtonGroup languageGroup = new ButtonGroup ();
2747:
2748: return mnbLanguageMenu = Multilingual.mlnText (
2749: ComponentFactory.createMenu (
2750: "Language", 'L',
2751: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnEnglish, "English", actionListener),
2752: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnJapanese, "日本語", actionListener)
2753: ),
2754: "ja", "言語");
2755: }
2756:
2757:
2758:
2759:
2760:
2761: public static void mnbMakeMenu () {
2762:
2763:
2764: ActionListener listener = new ActionListener () {
2765: @Override public void actionPerformed (ActionEvent ae) {
2766: Object source = ae.getSource ();
2767: String command = ae.getActionCommand ();
2768: switch (command) {
2769:
2770:
2771: case "Quit":
2772: prgTini ();
2773: break;
2774:
2775:
2776: case "50%":
2777: case "75%":
2778: case "100%":
2779: case "150%":
2780: case "200%":
2781: pnlFixedModel.setValue (Integer.valueOf (Integer.parseInt (command.substring (0, command.length () - 1))));
2782: break;
2783: case "Nearest neighbor":
2784: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
2785: break;
2786: case "Bilinear":
2787: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
2788: break;
2789: case "Bicubic":
2790: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
2791: break;
2792:
2793: case "Use canvas":
2794: pnlUseCanvasRequest = ((JCheckBoxMenuItem) source).isSelected ();
2795: break;
2796:
2797: case "Draw all changed pictures":
2798: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2799: CRTC.crtIntermittentInterval = 0;
2800: }
2801: break;
2802: case "Draw a changed picture once every two times":
2803: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2804: CRTC.crtIntermittentInterval = 1;
2805: }
2806: break;
2807: case "Draw a changed picture once every three times":
2808: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2809: CRTC.crtIntermittentInterval = 2;
2810: }
2811: break;
2812: case "Draw a changed picture once every four times":
2813: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2814: CRTC.crtIntermittentInterval = 3;
2815: }
2816: break;
2817: case "Draw a changed picture once every five times":
2818: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2819: CRTC.crtIntermittentInterval = 4;
2820: }
2821: break;
2822:
2823: case "Stereoscopic viewing":
2824: pnlSetStereoscopic (((JCheckBoxMenuItem) source).isSelected (), pnlStereoscopicMethod);
2825: break;
2826: case "Naked-eye crossing":
2827: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_CROSSING);
2828: break;
2829: case "Naked-eye parallel":
2830: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_PARALLEL);
2831: break;
2832: case "Side-by-side":
2833: pnlSetStereoscopic (pnlStereoscopicOn, PNL_SIDE_BY_SIDE);
2834: break;
2835: case "Top-and-bottom":
2836: pnlSetStereoscopic (pnlStereoscopicOn, PNL_TOP_AND_BOTTOM);
2837: break;
2838:
2839: case "Sprite pattern viewer":
2840: if (SpritePatternViewer.SPV_ON) {
2841: SpritePatternViewer.spvOpen ();
2842: }
2843: break;
2844: case "Palette viewer":
2845: if (PaletteViewer.PLV_ON) {
2846: PaletteViewer.plvOpen ();
2847: }
2848: break;
2849: case "Screen mode test":
2850: if (ScreenModeTest.SMT_ON) {
2851: ScreenModeTest.smtOpen ();
2852: }
2853: break;
2854:
2855:
2856: case "Play":
2857: SoundSource.sndSetPlayOn (((JCheckBoxMenuItem) source).isSelected ());
2858: break;
2859: case "OPM output":
2860: OPM.opmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2861: break;
2862: case "OPM log":
2863: OPMLog.olgOpen ();
2864: break;
2865:
2866: case "PCM output":
2867: ADPCM.pcmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2868: break;
2869: case "Sound thinning":
2870: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.THINNING_MONO : SoundSource.SNDRateConverter.THINNING_STEREO;
2871: break;
2872: case "Sound linear interpolation":
2873: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.LINEAR_MONO : SoundSource.SNDRateConverter.LINEAR_STEREO;
2874: break;
2875: case "Sound piecewise-constant area interpolation":
2876: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000;
2877: break;
2878: case "Sound linear area interpolation":
2879: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000;
2880: break;
2881: case "Sound monitor":
2882: SoundMonitor.smnOpen ();
2883: break;
2884: case "PCM piecewise-constant interpolation":
2885: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_CONSTANT);
2886: break;
2887: case "PCM linear interpolation":
2888: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_LINEAR);
2889: break;
2890: case "PCM hermite interpolation":
2891: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_HERMITE);
2892: break;
2893: case "PCM 8MHz/4MHz":
2894: ADPCM.pcmOSCFreqRequest = 0;
2895: break;
2896: case "PCM 8MHz/16MHz":
2897: ADPCM.pcmOSCFreqRequest = 1;
2898: break;
2899: case "Mercury-Unit V4 (MK-MU1)":
2900: MercuryUnit.mu4OnRequest = ((JCheckBoxMenuItem) source).isSelected ();
2901: break;
2902: case "MU4 output":
2903: MercuryUnit.mu4OutputEnable = ((JCheckBoxMenuItem) source).isSelected ();
2904: break;
2905:
2906:
2907: case "Paste":
2908: CONDevice.conDoPaste ();
2909: break;
2910: case "No keyboard":
2911: Keyboard.kbdSetOn (false);
2912: pnlUpdateArrangement ();
2913: break;
2914: case "Standard keyboard":
2915: Keyboard.kbdSetType (Keyboard.KBD_STANDARD_TYPE);
2916: Keyboard.kbdSetOn (true);
2917: pnlUpdateArrangement ();
2918: break;
2919: case "Compact keyboard":
2920: Keyboard.kbdSetType (Keyboard.KBD_COMPACT_TYPE);
2921: Keyboard.kbdSetOn (true);
2922: pnlUpdateArrangement ();
2923: break;
2924: case "Hide keyboard in full screen":
2925: pnlHideKeyboard = ((JCheckBoxMenuItem) source).isSelected ();
2926: if (pnlMode == PNL_FULLSCREEN) {
2927: pnlUpdateArrangement ();
2928: }
2929: break;
2930: case "Key assignments":
2931: Keyboard.kbdOpen ();
2932: break;
2933: case "Joystick port settings":
2934: PPI.ppiOpen ();
2935: break;
2936:
2937:
2938: case "RS-232C and terminal":
2939: RS232CTerminal.trmOpen ();
2940: break;
2941:
2942: case "Console":
2943: DebugConsole.dgtOpen ();
2944: break;
2945: case "Register list":
2946: RegisterList.drpOpen ();
2947: break;
2948: case "Disassemble list":
2949: DisassembleList.ddpOpen (-1, -1, true);
2950: break;
2951: case "Memory dump list":
2952: MemoryDumpList.dmpOpen (-1, -1, true);
2953: break;
2954: case "Logical space monitor":
2955: LogicalSpaceMonitor.atwOpen ();
2956: break;
2957: case "Physical space monitor":
2958: PhysicalSpaceMonitor.paaOpen ();
2959: break;
2960: case "Address translation caches monitor":
2961: if (ATCMonitor.ACM_ON) {
2962: ATCMonitor.acmOpen ();
2963: }
2964: break;
2965: case "Branch log":
2966: if (BranchLog.BLG_ON) {
2967: BranchLog.blgOpen (BranchLog.BLG_SELECT_NONE);
2968: }
2969: break;
2970: case "Program flow visualizer":
2971: if (ProgramFlowVisualizer.PFV_ON) {
2972: ProgramFlowVisualizer.pfvOpen ();
2973: }
2974: break;
2975: case "Raster break point":
2976: if (RasterBreakPoint.RBP_ON) {
2977: RasterBreakPoint.rbpOpen ();
2978: }
2979: break;
2980: case "Data break point":
2981: if (DataBreakPoint.DBP_ON) {
2982: DataBreakPoint.dbpOpen ();
2983: }
2984: break;
2985: case "Root pointer list":
2986: if (RootPointerList.RTL_ON) {
2987: RootPointerList.rtlOpen ();
2988: }
2989: break;
2990:
2991:
2992: case "Adjust clock to host":
2993: RP5C15.rtcSetByHost ();
2994: break;
2995:
2996:
2997:
2998: case "Printer":
2999: PrinterPort.prnOpen ();
3000: break;
3001:
3002: case "Print key and mouse button events":
3003: Mouse.musOutputButtonStatus = ((JCheckBoxMenuItem) source).isSelected ();
3004: break;
3005:
3006: case "Java runtime environment information":
3007: prgOpenJavaDialog ();
3008: break;
3009: case "Version information":
3010: prgOpenAboutDialog ();
3011: break;
3012: case "XEiJ License":
3013: prgOpenXEiJLicenseDialog ();
3014: break;
3015: case "FSHARP License":
3016: prgOpenSHARPLicenseDialog ();
3017: break;
3018: case "ymfm License":
3019: prgOpenYmfmLicenseDialog ();
3020: break;
3021: case "jSerialComm License":
3022: prgOpenJSerialCommLicenseDialog ();
3023: break;
3024:
3025: default:
3026: System.out.println ("unknown action command " + command);
3027:
3028: }
3029: }
3030: };
3031:
3032:
3033: ActionListener mainMemoryListener = new ActionListener () {
3034: @Override public void actionPerformed (ActionEvent ae) {
3035: Object source = ae.getSource ();
3036: String command = ae.getActionCommand ();
3037: switch (command) {
3038: case "1MB":
3039: MainMemory.mmrMemorySizeRequest = 0x00100000;
3040: break;
3041: case "2MB":
3042: MainMemory.mmrMemorySizeRequest = 0x00200000;
3043: break;
3044: case "4MB":
3045: MainMemory.mmrMemorySizeRequest = 0x00400000;
3046: break;
3047: case "6MB":
3048: MainMemory.mmrMemorySizeRequest = 0x00600000;
3049: break;
3050: case "8MB":
3051: MainMemory.mmrMemorySizeRequest = 0x00800000;
3052: break;
3053: case "10MB":
3054: MainMemory.mmrMemorySizeRequest = 0x00a00000;
3055: break;
3056: case "12MB":
3057: MainMemory.mmrMemorySizeRequest = 0x00c00000;
3058: break;
3059: case "Save contents on exit":
3060: MainMemory.mmrMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
3061: break;
3062: }
3063: }
3064: };
3065: ButtonGroup mainMemoryGroup = new ButtonGroup ();
3066: JMenu mainMemoryMenu = Multilingual.mlnText (
3067: ComponentFactory.createMenu (
3068: "Main memory",
3069: Multilingual.mlnText (
3070: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00100000, "1MB", mainMemoryListener),
3071: "ja", "1MB"),
3072: Multilingual.mlnText (
3073: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00200000, "2MB", mainMemoryListener),
3074: "ja", "2MB"),
3075: Multilingual.mlnText (
3076: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00400000, "4MB", mainMemoryListener),
3077: "ja", "4MB"),
3078: Multilingual.mlnText (
3079: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00600000, "6MB", mainMemoryListener),
3080: "ja", "6MB"),
3081: Multilingual.mlnText (
3082: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00800000, "8MB", mainMemoryListener),
3083: "ja", "8MB"),
3084: Multilingual.mlnText (
3085: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00a00000, "10MB", mainMemoryListener),
3086: "ja", "10MB"),
3087: Multilingual.mlnText (
3088: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00c00000, "12MB", mainMemoryListener),
3089: "ja", "12MB"),
3090: ComponentFactory.createHorizontalSeparator (),
3091: Multilingual.mlnText (
3092: ComponentFactory.createCheckBoxMenuItem (MainMemory.mmrMemorySaveOn, "Save contents on exit", mainMemoryListener),
3093: "ja", "終了時に内容を保存する"),
3094: SRAM.smrModifyMemorySizeMenuItem
3095: ),
3096: "ja", "メインメモリ");
3097:
3098:
3099: ActionListener highMemoryListener = new ActionListener () {
3100: @Override public void actionPerformed (ActionEvent ae) {
3101: Object source = ae.getSource ();
3102: String command = ae.getActionCommand ();
3103: switch (command) {
3104: case "None":
3105: busHighMemorySize = 0 << 20;
3106: break;
3107: case "16MB":
3108: busHighMemorySize = 16 << 20;
3109: break;
3110: case "Save contents on exit":
3111: busHighMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
3112: break;
3113: }
3114: }
3115: };
3116: ButtonGroup highMemoryGroup = new ButtonGroup ();
3117: JMenu highMemoryMenu = Multilingual.mlnText (
3118: ComponentFactory.createMenu (
3119: "High memory on X68030/Xellent30",
3120: Multilingual.mlnText (
3121: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 0 << 20, "None", highMemoryListener),
3122: "ja", "なし"),
3123: Multilingual.mlnText (
3124: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 16 << 20, "16MB", highMemoryListener),
3125: "ja", "16MB"),
3126: ComponentFactory.createHorizontalSeparator (),
3127: Multilingual.mlnText (
3128: ComponentFactory.createCheckBoxMenuItem (busHighMemorySaveOn, "Save contents on exit", highMemoryListener),
3129: "ja", "終了時に内容を保存する")
3130: ),
3131: "ja", "X68030/Xellent30 のハイメモリ");
3132:
3133:
3134: ActionListener localMemoryListener = new ActionListener () {
3135: @Override public void actionPerformed (ActionEvent ae) {
3136: Object source = ae.getSource ();
3137: String command = ae.getActionCommand ();
3138: switch (command) {
3139: case "None":
3140: busLocalMemorySize = 0 << 20;
3141: break;
3142: case "16MB":
3143: busLocalMemorySize = 16 << 20;
3144: break;
3145: case "32MB":
3146: busLocalMemorySize = 32 << 20;
3147: break;
3148: case "64MB":
3149: busLocalMemorySize = 64 << 20;
3150: break;
3151: case "128MB":
3152: busLocalMemorySize = 128 << 20;
3153: break;
3154: case "256MB":
3155: busLocalMemorySize = 256 << 20;
3156: break;
3157: case "384MB":
3158: busLocalMemorySize = 384 << 20;
3159: break;
3160: case "512MB":
3161: busLocalMemorySize = 512 << 20;
3162: break;
3163: case "768MB":
3164: busLocalMemorySize = 768 << 20;
3165: break;
3166: case "Save contents on exit":
3167: busLocalMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
3168: break;
3169: case "Available on X68000":
3170: busHimem68000 = ((JCheckBoxMenuItem) source).isSelected ();
3171: break;
3172: case "Available on X68030/Xellent30":
3173: busHighMemory060turboOn = ((JCheckBoxMenuItem) source).isSelected ();
3174: break;
3175: }
3176: }
3177: };
3178: ButtonGroup localMenoryGroup = new ButtonGroup ();
3179: JMenu localMemoryMenu = Multilingual.mlnText (
3180: ComponentFactory.createMenu (
3181: "High memory on 060turbo",
3182: Multilingual.mlnText (
3183: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 0 << 20, "None", localMemoryListener),
3184: "ja", "なし"),
3185: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 16 << 20, "16MB", localMemoryListener),
3186: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 32 << 20, "32MB", localMemoryListener),
3187: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 64 << 20, "64MB", localMemoryListener),
3188: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 128 << 20, "128MB", localMemoryListener),
3189: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 256 << 20, "256MB", localMemoryListener),
3190: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 384 << 20, "384MB", localMemoryListener),
3191: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 512 << 20, "512MB", localMemoryListener),
3192: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 768 << 20, "768MB", localMemoryListener),
3193: ComponentFactory.createHorizontalSeparator (),
3194: Multilingual.mlnText (
3195: ComponentFactory.createCheckBoxMenuItem (busLocalMemorySaveOn, "Save contents on exit", localMemoryListener),
3196: "ja", "終了時に内容を保存する"),
3197: ComponentFactory.createHorizontalSeparator (),
3198: Multilingual.mlnText (
3199: ComponentFactory.createCheckBoxMenuItem (busHimem68000, "Available on X68000", localMemoryListener),
3200: "ja", "X68000 でも有効"),
3201: Multilingual.mlnText (
3202: ComponentFactory.createCheckBoxMenuItem (busHighMemory060turboOn, "Available on X68030/Xellent30", localMemoryListener),
3203: "ja", "X68030/Xellent30 でも有効")
3204: ),
3205: "ja", "060turbo のハイメモリ");
3206:
3207:
3208: ActionListener xellent30Listener = new ActionListener () {
3209: @Override public void actionPerformed (ActionEvent ae) {
3210: Object source = ae.getSource ();
3211: String command = ae.getActionCommand ();
3212: switch (command) {
3213: case "$00EC0000-$00EC3FFF":
3214: xt3DIPSW = 0;
3215: break;
3216: case "$00EC4000-$00EC7FFF":
3217: xt3DIPSW = 1;
3218: break;
3219: case "$00EC8000-$00ECBFFF":
3220: xt3DIPSW = 2;
3221: break;
3222: case "$00ECC000-$00ECFFFF":
3223: xt3DIPSW = 3;
3224: break;
3225: case "256KB":
3226: xt3MemorySizeRequest = 1 << 18;
3227: break;
3228: case "1MB":
3229: xt3MemorySizeRequest = 1 << 20;
3230: break;
3231: case "Save contents on exit":
3232: xt3MemorySave = ((JCheckBoxMenuItem) source).isSelected ();
3233: break;
3234: }
3235: }
3236: };
3237: ButtonGroup xellent30PortGroup = new ButtonGroup ();
3238: ButtonGroup xellent30SizeGroup = new ButtonGroup ();
3239: JMenu xellent30Menu = ComponentFactory.createMenu (
3240: "Xellent30",
3241: ComponentFactory.createRadioButtonMenuItem (
3242: xellent30PortGroup,
3243: xt3DIPSW == 0,
3244: "$00EC0000-$00EC3FFF",
3245: xellent30Listener),
3246: ComponentFactory.createRadioButtonMenuItem (
3247: xellent30PortGroup,
3248: xt3DIPSW == 1,
3249: "$00EC4000-$00EC7FFF",
3250: xellent30Listener),
3251: ComponentFactory.createRadioButtonMenuItem (
3252: xellent30PortGroup,
3253: xt3DIPSW == 2,
3254: "$00EC8000-$00ECBFFF",
3255: xellent30Listener),
3256: ComponentFactory.createRadioButtonMenuItem (
3257: xellent30PortGroup,
3258: xt3DIPSW == 3,
3259: "$00ECC000-$00ECFFFF",
3260: xellent30Listener),
3261: ComponentFactory.createHorizontalSeparator (),
3262: ComponentFactory.createRadioButtonMenuItem (
3263: xellent30SizeGroup,
3264: xt3MemorySizeRequest == 1 << 18,
3265: "256KB",
3266: xellent30Listener),
3267: ComponentFactory.createRadioButtonMenuItem (
3268: xellent30SizeGroup,
3269: xt3MemorySizeRequest == 1 << 20,
3270: "1MB",
3271: xellent30Listener),
3272: ComponentFactory.createHorizontalSeparator (),
3273: Multilingual.mlnText (
3274: ComponentFactory.createCheckBoxMenuItem (xt3MemorySave, "Save contents on exit", xellent30Listener),
3275: "ja", "終了時に内容を保存する")
3276: );
3277:
3278:
3279: JMenu rotationMenu = null;
3280: if (PNL_ROTATION_ON) {
3281: ActionListener rotationListener = new ActionListener () {
3282: @Override public void actionPerformed (ActionEvent ae) {
3283: String command = ae.getActionCommand ();
3284: switch (command) {
3285: case "No rotation (landscape)":
3286: pnlRotationMode = 0;
3287: pnlUpdateArrangement ();
3288: break;
3289: case "90-degree rotation (portrait)":
3290: pnlRotationMode = 1;
3291: pnlUpdateArrangement ();
3292: break;
3293: case "180-degree rotation":
3294: pnlRotationMode = 2;
3295: pnlUpdateArrangement ();
3296: break;
3297: case "270-degree rotation":
3298: pnlRotationMode = 3;
3299: pnlUpdateArrangement ();
3300: break;
3301: default:
3302: System.out.println ("unknown action command " + command);
3303: }
3304: }
3305: };
3306: ButtonGroup rotationGroup = new ButtonGroup ();
3307: rotationMenu = Multilingual.mlnText (
3308: ComponentFactory.createMenu (
3309: "Rotation",
3310: Multilingual.mlnText (
3311: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 0, "No rotation (landscape)", rotationListener),
3312: "ja", "回転なし (横画面)"),
3313: Multilingual.mlnText (
3314: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 1, "90-degree rotation (portrait)", rotationListener),
3315: "ja", "90 度回転 (縦画面)"),
3316: Multilingual.mlnText (
3317: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 2, "180-degree rotation", rotationListener),
3318: "ja", "180 度回転"),
3319: Multilingual.mlnText (
3320: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 3, "270-degree rotation", rotationListener),
3321: "ja", "270 度回転")
3322: ),
3323: "ja", "回転");
3324: }
3325:
3326:
3327: ActionListener aspectListener = new ActionListener () {
3328: @Override public void actionPerformed (ActionEvent ae) {
3329: String command = ae.getActionCommand ();
3330: int i = command.indexOf (',');
3331: int resolutionNumber = Integer.parseInt (command.substring (0, i));
3332: int ratioNumber = Integer.parseInt (command.substring (i + 1));
3333: pnlAspectMap[resolutionNumber] = ratioNumber;
3334: pnlUpdateAspectTable ();
3335: pnlUpdateArrangement ();
3336: }
3337: };
3338: JMenu aspectMenu = ComponentFactory.createMenu ("Aspect ratio");
3339: for (int resolutionNumber = 0; resolutionNumber < PNL_ASPECT_RESOLUTION_COUNT; resolutionNumber++) {
3340: JMenu menu = ComponentFactory.createMenu (PNL_ASPECT_RESOLUTION_NAME[resolutionNumber]);
3341: ButtonGroup group = new ButtonGroup ();
3342: for (int ratioNumber = 0; ratioNumber < PNL_ASPECT_RATIO_COUNT; ratioNumber++) {
3343: if (PNL_ASPECT_RATIO_MATRIX[resolutionNumber][ratioNumber] == 0.0F) {
3344: continue;
3345: }
3346: menu.add (
3347: ComponentFactory.setText (
3348: ComponentFactory.createRadioButtonMenuItem (
3349: group,
3350: pnlAspectMap[resolutionNumber] == ratioNumber,
3351: resolutionNumber + "," + ratioNumber,
3352: aspectListener
3353: ),
3354: (PNL_ASPECT_RATIO_MATRIX[resolutionNumber] == PNL_ASPECT_PIXEL_RATIO_02 ?
3355: String.format ("%s (%.3f)",
3356: PNL_ASPECT_SCREEN_NAME[ratioNumber],
3357: PNL_ASPECT_SCREEN_RATIO[ratioNumber]) :
3358: String.format ("%s (%.3f) @ %s (%.3f)",
3359: PNL_ASPECT_SCREEN_NAME[ratioNumber],
3360: PNL_ASPECT_SCREEN_RATIO[ratioNumber],
3361: PNL_ASPECT_NAME_MATRIX[resolutionNumber][ratioNumber],
3362: PNL_ASPECT_RATIO_MATRIX[resolutionNumber][ratioNumber]))
3363: )
3364: );
3365: }
3366: aspectMenu.add (menu);
3367: }
3368: aspectMenu = Multilingual.mlnText (aspectMenu, "ja", "アスペクト比");
3369:
3370:
3371: ActionListener scanlineListener = new ActionListener () {
3372: @Override public void actionPerformed (ActionEvent ae) {
3373:
3374: String command = ae.getActionCommand ();
3375: switch (command) {
3376: case "Off":
3377: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.OFF;
3378: CRTC.crtAllStamp += 2;
3379: break;
3380: case "Weak":
3381: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.WEAK;
3382: CRTC.crtAllStamp += 2;
3383: break;
3384: case "Medium":
3385: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.MEDIUM;
3386: CRTC.crtAllStamp += 2;
3387: break;
3388: case "Strong":
3389: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.STRONG;
3390: CRTC.crtAllStamp += 2;
3391: break;
3392: case "Black":
3393: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.BLACK;
3394: CRTC.crtAllStamp += 2;
3395: break;
3396: }
3397: }
3398: };
3399: ButtonGroup scanlineGroup = new ButtonGroup ();
3400: JMenu scanlineMenu =
3401: Multilingual.mlnText (
3402: ComponentFactory.createMenu (
3403: "Scanline effect",
3404: Multilingual.mlnText (
3405: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.OFF, "Off", scanlineListener),
3406: "ja", "なし"),
3407: Multilingual.mlnText (
3408: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.WEAK, "Weak", scanlineListener),
3409: "ja", "弱"),
3410: Multilingual.mlnText (
3411: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.MEDIUM, "Medium", scanlineListener),
3412: "ja", "中"),
3413: Multilingual.mlnText (
3414: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.STRONG, "Strong", scanlineListener),
3415: "ja", "強"),
3416: Multilingual.mlnText (
3417: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.BLACK, "Black", scanlineListener),
3418: "ja", "黒")
3419: ),
3420: "ja", "走査線エフェクト");
3421:
3422:
3423: JTextField refreshRateTextField = ComponentFactory.createNumberField (pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate), 8);
3424: refreshRateTextField.addActionListener (
3425: new ActionListener () {
3426: @Override public void actionPerformed (ActionEvent ae) {
3427: JTextField textField = (JTextField) ae.getSource ();
3428: pnlRefreshRate = 0.0;
3429: String s = textField.getText ();
3430: if (!s.equals ("")) {
3431: double rate = 0.0;
3432: try {
3433: rate = Double.parseDouble (s);
3434: } catch (NumberFormatException nfe) {
3435: }
3436: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
3437: pnlRefreshRate = rate;
3438: } else {
3439: textField.setText ("");
3440: }
3441: }
3442: pnlFixedRate = pnlRefreshRate;
3443: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3444: pnlFixedRate = pnlGetRefreshRate ();
3445: }
3446: CRTC.crtUpdateLength ();
3447: }
3448: });
3449:
3450: ButtonGroup unitGroup = new ButtonGroup ();
3451: ButtonGroup frameGroup = new ButtonGroup ();
3452: ButtonGroup hintGroup = new ButtonGroup ();
3453: ButtonGroup vgaGroup = new ButtonGroup ();
3454: ButtonGroup intermittentGroup = new ButtonGroup ();
3455: ButtonGroup sterescopicGroup = new ButtonGroup ();
3456: ButtonGroup soundInterpolationGroup = new ButtonGroup ();
3457: ButtonGroup adpcmInterpolationGroup = new ButtonGroup ();
3458: ButtonGroup adpcmOSCFreqGroup = new ButtonGroup ();
3459: ButtonGroup keyboardGroup = new ButtonGroup ();
3460: ButtonGroup spritesGroup = new ButtonGroup ();
3461:
3462:
3463: DecimalSpinner[] freqSpinner = new DecimalSpinner[3];
3464: ChangeListener freqListener = new ChangeListener () {
3465: @Override public void stateChanged (ChangeEvent ce) {
3466: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
3467: int i = spinner.getOption ();
3468: CRTC.crtFreqsRequest[i] = spinner.getIntValue ();
3469: }
3470: };
3471: for (int i = 0; i < 3; i++) {
3472: freqSpinner[i] = ComponentFactory.createDecimalSpinner (
3473: CRTC.crtFreqsRequest[i], CRTC.CRT_MIN_FREQ, CRTC.CRT_MAX_FREQ, 1000000, i, freqListener
3474: );
3475: }
3476: DecimalSpinner sprrasSpinner = ComponentFactory.createDecimalSpinner (
3477: SpriteScreen.sprSpritesPerRaster, 0, 1016, 1, 0,
3478: new ChangeListener () {
3479: @Override public void stateChanged (ChangeEvent ce) {
3480: SpriteScreen.sprSpritesPerRaster = ((DecimalSpinner) ce.getSource ()).getIntValue ();
3481: }
3482: });
3483: ActionListener modificationListener = new ActionListener () {
3484: @Override public void actionPerformed (ActionEvent ae) {
3485: Object source = ae.getSource ();
3486: String command = ae.getActionCommand ();
3487: switch (command) {
3488:
3489: case "Adjust to host refresh rate":
3490: pnlAdjustVsync = ((JCheckBoxMenuItem) source).isSelected ();
3491: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3492: pnlFixedRate = pnlGetRefreshRate ();
3493: }
3494: CRTC.crtUpdateLength ();
3495: break;
3496: case "* Reset to default values":
3497: for (int i = 0; i < 3; i++) {
3498: if (CRTC.crtFreqsRequest[i] != CRTC.CRT_DEFAULT_FREQS[i]) {
3499: CRTC.crtFreqsRequest[i] = CRTC.CRT_DEFAULT_FREQS[i];
3500: freqSpinner[i].setIntValue (CRTC.crtFreqsRequest[i]);
3501: }
3502: }
3503: break;
3504: case "1024-dot non-interlaced":
3505: CRTC.crtEleventhBitRequest = ((JCheckBoxMenuItem) source).isSelected ();
3506: break;
3507: case "Can write 0 to bit 0 of CRTC R00":
3508: CRTC.crtR00Bit0Zero = ((JCheckBoxMenuItem) source).isSelected ();
3509: break;
3510:
3511: case "Extended graphic screen":
3512: CRTC.crtExtendedGraphicRequest = ((JCheckBoxMenuItem) source).isSelected ();
3513: break;
3514:
3515: case "Spherical scrolling of text screen":
3516: CRTC.crtSetSphericalScrolling (((JCheckBoxMenuItem) source).isSelected ());
3517: break;
3518:
3519: case "128 sprites":
3520: SpriteScreen.sprNumberOfSpritesRequest = 128;
3521: break;
3522: case "256 sprites":
3523: SpriteScreen.sprNumberOfSpritesRequest = 256;
3524: break;
3525: case "504 sprites":
3526: SpriteScreen.sprNumberOfSpritesRequest = 512;
3527: break;
3528: case "1016 sprites":
3529: SpriteScreen.sprNumberOfSpritesRequest = 1024;
3530: break;
3531:
3532:
3533:
3534: case "Full pattern memory":
3535: SpriteScreen.sprFPMRequest = ((JCheckBoxMenuItem) source).isSelected ();
3536: break;
3537: case "4096 patterns":
3538: SpriteScreen.sprBankOnRequest = ((JCheckBoxMenuItem) source).isSelected ();
3539: break;
3540: case "Sprites displayed in 768x512":
3541: SpriteScreen.spr768x512Request = ((JCheckBoxMenuItem) source).isSelected ();
3542: break;
3543: case "BG1 displayed in 512x512":
3544: SpriteScreen.spr512bg1Request = ((JCheckBoxMenuItem) source).isSelected ();
3545: break;
3546: case "Row and column scroll":
3547: if (SpriteScreen.SPR_RC_SCROLL_ON) {
3548: SpriteScreen.sprRcScrollRequest = ((JCheckBoxMenuItem) source).isSelected ();
3549: }
3550: break;
3551: case "** Reset to default values":
3552: if (SpriteScreen.sprSpritesPerRaster != 32) {
3553: SpriteScreen.sprSpritesPerRaster = 32;
3554: sprrasSpinner.setIntValue (SpriteScreen.sprSpritesPerRaster);
3555: }
3556: break;
3557: }
3558: }
3559: };
3560: JMenu modificationMenu =
3561: Multilingual.mlnText (
3562: ComponentFactory.createMenu (
3563: "Modification",
3564: Multilingual.mlnText (
3565: ComponentFactory.createMenu (
3566: "Dot clock",
3567: Multilingual.mlnText (
3568: ComponentFactory.createCheckBoxMenuItem (pnlAdjustVsync, "Adjust to host refresh rate", modificationListener),
3569: "ja", "ホストのリフレッシュレートに合わせる"),
3570: ComponentFactory.createHorizontalBox (
3571: Box.createHorizontalStrut (20),
3572: refreshRateTextField,
3573: ComponentFactory.createLabel (" Hz"),
3574: Box.createHorizontalGlue ()
3575: ),
3576: ComponentFactory.createHorizontalSeparator (),
3577: ComponentFactory.createHorizontalBox (
3578: Box.createHorizontalStrut (20),
3579: Multilingual.mlnText (ComponentFactory.createLabel ("Dot clock oscillattor"), "ja", "ドットクロックオシレータ"),
3580: Box.createHorizontalGlue ()
3581: ),
3582: ComponentFactory.createHorizontalBox (
3583: Box.createHorizontalStrut (20),
3584: freqSpinner[0],
3585: ComponentFactory.createLabel (" Hz *"),
3586: Box.createHorizontalGlue ()
3587: ),
3588: ComponentFactory.createHorizontalBox (
3589: Box.createHorizontalStrut (20),
3590: freqSpinner[1],
3591: ComponentFactory.createLabel (" Hz *"),
3592: Box.createHorizontalGlue ()
3593: ),
3594: ComponentFactory.createHorizontalBox (
3595: Box.createHorizontalStrut (20),
3596: freqSpinner[2],
3597: ComponentFactory.createLabel (" Hz *"),
3598: Box.createHorizontalGlue ()
3599: ),
3600: Multilingual.mlnText (
3601: ComponentFactory.createMenuItem ("* Reset to default values", modificationListener),
3602: "ja", "* 初期値に戻す"),
3603: ComponentFactory.createHorizontalSeparator (),
3604: Multilingual.mlnText (
3605: ComponentFactory.createCheckBoxMenuItem (CRTC.crtEleventhBitRequest, "1024-dot non-interlaced", modificationListener),
3606: "ja", "1024 ドットノンインターレース"),
3607: Multilingual.mlnText (
3608: ComponentFactory.createCheckBoxMenuItem (CRTC.crtR00Bit0Zero, "Can write 0 to bit 0 of CRTC R00", modificationListener),
3609: "ja", "CRTC R00 のビット 0 に 0 を書き込める")
3610: ),
3611: "ja", "ドットクロック"),
3612: Multilingual.mlnText (
3613: ComponentFactory.createMenu (
3614: "Graphic screen",
3615: !CRTC.CRT_EXTENDED_GRAPHIC ? null : Multilingual.mlnText (
3616: ComponentFactory.createCheckBoxMenuItem (CRTC.crtExtendedGraphicRequest, "Extended graphic screen", modificationListener),
3617: "ja", "拡張グラフィック画面")
3618: ),
3619: "ja", "グラフィック画面"),
3620: Multilingual.mlnText (
3621: ComponentFactory.createMenu (
3622: "Text screen",
3623: Multilingual.mlnText (
3624: ComponentFactory.createCheckBoxMenuItem (CRTC.crtSphericalScrolling, "Spherical scrolling of text screen", modificationListener),
3625: "ja", "テキスト画面の球面スクロール")
3626: ),
3627: "ja", "テキスト画面"),
3628: Multilingual.mlnText (
3629: ComponentFactory.createMenu (
3630: "Sprite screen",
3631: Multilingual.mlnText (
3632: ComponentFactory.createRadioButtonMenuItem (
3633: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 128, "128 sprites", modificationListener),
3634: "ja", "128 枚のスプライト"),
3635: Multilingual.mlnText (
3636: ComponentFactory.createRadioButtonMenuItem (
3637: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 256, "256 sprites", modificationListener),
3638: "ja", "256 枚のスプライト"),
3639: Multilingual.mlnText (
3640: ComponentFactory.createRadioButtonMenuItem (
3641: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 512, "504 sprites", modificationListener),
3642: "ja", "504 枚のスプライト"),
3643: Multilingual.mlnText (
3644: ComponentFactory.createRadioButtonMenuItem (
3645: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 1024, "1016 sprites", modificationListener),
3646: "ja", "1016 枚のスプライト"),
3647:
3648:
3649:
3650:
3651: ComponentFactory.createHorizontalSeparator (),
3652: Multilingual.mlnText (
3653: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprFPMRequest, "Full pattern memory", modificationListener),
3654: "ja", "フルパターンメモリ"),
3655: ComponentFactory.createHorizontalSeparator (),
3656: Multilingual.mlnText (
3657: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprBankOnRequest, "4096 patterns", modificationListener),
3658: "ja", "4096 個のパターン"),
3659: Multilingual.mlnText (
3660: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr768x512Request, "Sprites displayed in 768x512", modificationListener),
3661: "ja", "768x512 でスプライトを表示"),
3662: Multilingual.mlnText (
3663: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr512bg1Request, "BG1 displayed in 512x512", modificationListener),
3664: "ja", "512x512 で BG1 を表示"),
3665: !SpriteScreen.SPR_RC_SCROLL_ON ? null : Multilingual.mlnText (
3666: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprRcScrollRequest, "Row and column scroll", modificationListener),
3667: "ja", "行スクロールと列スクロール"),
3668: ComponentFactory.createHorizontalSeparator (),
3669: ComponentFactory.createHorizontalBox (
3670: Box.createHorizontalStrut (20),
3671: Multilingual.mlnText (ComponentFactory.createLabel ("Number of sprites per raster"), "ja", "ラスタあたりのスプライトの枚数"),
3672: Box.createHorizontalGlue ()
3673: ),
3674: ComponentFactory.createHorizontalBox (
3675: Box.createHorizontalStrut (20),
3676: sprrasSpinner,
3677: ComponentFactory.createLabel (" **"),
3678: Box.createHorizontalGlue ()
3679: ),
3680: Multilingual.mlnText (
3681: ComponentFactory.createMenuItem ("** Reset to default values", modificationListener),
3682: "ja", "** 初期値に戻す")
3683: ),
3684: "ja", "スプライト画面")
3685: ),
3686: "ja", "改造");
3687:
3688:
3689: mnbMenuBar = ComponentFactory.createMenuBar (
3690:
3691:
3692: mnbFileMenu = Multilingual.mlnText (
3693: ComponentFactory.createMenu (
3694: "File", 'F',
3695:
3696: FDC.fdcMenu,
3697:
3698: HDC.hdcMenu,
3699:
3700: SPC.spcMenu,
3701:
3702: HFS.hfsMenu,
3703: ComponentFactory.createHorizontalSeparator (),
3704: mnbQuitMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Quit", 'Q', MNB_MODIFIERS, listener), "ja", "終了")
3705: ),
3706: "ja", "ファイル"),
3707:
3708:
3709: mpuMenu,
3710:
3711:
3712: mnbDisplayMenu = Multilingual.mlnText (
3713: ComponentFactory.createMenu (
3714: "Display", 'D',
3715: mnbFullScreenMenuItem,
3716: !PNL_ROUNDED_CORNER_ON ? null : ComponentFactory.createHorizontalBox (
3717: Box.createHorizontalStrut (20),
3718: Multilingual.mlnText (
3719: ComponentFactory.createLabel ("Rounded corner ratio "),
3720: "ja", "角丸率 "),
3721: pnlRoundedCornerSpinner,
3722: ComponentFactory.createLabel ("%"),
3723: Box.createHorizontalGlue ()
3724: ),
3725: mnbMaximizedMenuItem,
3726: mnbFitInWindowMenuItem,
3727: mnbFixedScaleMenuItem,
3728: ComponentFactory.createHorizontalBox (
3729: Box.createHorizontalStrut (20),
3730: pnlFixedSpinner,
3731: Multilingual.mlnText (
3732: ComponentFactory.createLabel ("% Scale factor"),
3733: "ja", "% 倍率"),
3734: Box.createHorizontalGlue ()
3735: ),
3736: ComponentFactory.createMenuItem ("50%", listener),
3737: ComponentFactory.createMenuItem ("75%", listener),
3738: ComponentFactory.createMenuItem ("100%", listener),
3739: ComponentFactory.createMenuItem ("150%", listener),
3740: ComponentFactory.createMenuItem ("200%", listener),
3741: ComponentFactory.createHorizontalSeparator (),
3742:
3743: rotationMenu,
3744:
3745: aspectMenu,
3746:
3747: Multilingual.mlnText (
3748: ComponentFactory.createMenu (
3749: "Interpolation algorithm",
3750: Multilingual.mlnText (
3751: ComponentFactory.createRadioButtonMenuItem (
3752: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
3753: "Nearest neighbor", listener),
3754: "ja", "最近傍補間"),
3755: Multilingual.mlnText (
3756: ComponentFactory.createRadioButtonMenuItem (
3757: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR,
3758: "Bilinear", listener),
3759: "ja", "線形補間"),
3760: Multilingual.mlnText (
3761: ComponentFactory.createRadioButtonMenuItem (
3762: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC,
3763: "Bicubic", listener),
3764: "ja", "三次補間")
3765: ),
3766: "ja", "補間アルゴリズム"),
3767:
3768: scanlineMenu,
3769: !PNL_USE_CANVAS ? null : Multilingual.mlnText (
3770: ComponentFactory.createCheckBoxMenuItem (pnlUseCanvasRequest, "Use canvas", listener),
3771: "ja", "キャンバスを使う"),
3772:
3773: !CRTC.CRT_ENABLE_INTERMITTENT ? null : Multilingual.mlnText (
3774: ComponentFactory.createMenu (
3775: "Intermittent drawing",
3776: Multilingual.mlnText (
3777: ComponentFactory.createRadioButtonMenuItem (
3778: intermittentGroup, CRTC.crtIntermittentInterval == 0, "Draw all changed pictures", listener),
3779: "ja", "変化した画像をすべて描画する"),
3780: Multilingual.mlnText (
3781: ComponentFactory.createRadioButtonMenuItem (
3782: intermittentGroup, CRTC.crtIntermittentInterval == 1, "Draw a changed picture once every two times", listener),
3783: "ja", "変化した画像を 2 回に 1 回描画する"),
3784: Multilingual.mlnText (
3785: ComponentFactory.createRadioButtonMenuItem (
3786: intermittentGroup, CRTC.crtIntermittentInterval == 2, "Draw a changed picture once every three times", listener),
3787: "ja", "変化した画像を 3 回に 1 回描画する"),
3788: Multilingual.mlnText (
3789: ComponentFactory.createRadioButtonMenuItem (
3790: intermittentGroup, CRTC.crtIntermittentInterval == 3, "Draw a changed picture once every four times", listener),
3791: "ja", "変化した画像を 4 回に 1 回描画する"),
3792: Multilingual.mlnText (
3793: ComponentFactory.createRadioButtonMenuItem (
3794: intermittentGroup, CRTC.crtIntermittentInterval == 4, "Draw a changed picture once every five times", listener),
3795: "ja", "変化した画像を 5 回に 1 回描画する")
3796: ),
3797: "ja", "間欠描画"),
3798:
3799: !PNL_STEREOSCOPIC_ON ? null : ComponentFactory.createHorizontalSeparator (),
3800: mnbStereoscopicMenuItem = !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3801: ComponentFactory.createCheckBoxMenuItem (pnlStereoscopicOn, "Stereoscopic viewing", 'T', listener),
3802: "ja", "立体視"),
3803: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3804: ComponentFactory.createMenu (
3805: "Stereoscopic settings",
3806: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3807: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3808: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING,
3809: "Naked-eye crossing", listener),
3810: "ja", "裸眼交差法"),
3811: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3812: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3813: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL,
3814: "Naked-eye parallel", listener),
3815: "ja", "裸眼平行法"),
3816: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3817: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3818: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE,
3819: "Side-by-side", listener),
3820: "ja", "サイドバイサイド"),
3821: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3822: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3823: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM,
3824: "Top-and-bottom", listener),
3825: "ja", "トップアンドボトム")
3826: ),
3827: "ja", "立体視設定"),
3828:
3829: ComponentFactory.createHorizontalSeparator (),
3830: GIFAnimation.gifStartRecordingMenuItem,
3831: GIFAnimation.gifSettingsMenu,
3832:
3833: ComponentFactory.createHorizontalSeparator (),
3834: modificationMenu,
3835:
3836: SpritePatternViewer.SPV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Sprite pattern viewer", listener), "ja", "スプライトパターンビュア") : null,
3837: PaletteViewer.PLV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Palette viewer", listener), "ja", "パレットビュア") : null,
3838: ScreenModeTest.SMT_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Screen mode test", listener), "ja", "表示モードテスト") : null
3839: ),
3840: "ja", "画面"),
3841:
3842:
3843: mnbSoundMenu = ComponentFactory.setEnabled (
3844: Multilingual.mlnText (
3845: ComponentFactory.createMenu (
3846: "Sound", 'S',
3847: mnbPlayMenuItem = ComponentFactory.setEnabled (
3848: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (SoundSource.sndPlayOn, "Play", 'P', MNB_MODIFIERS, listener), "ja", "音声出力"),
3849: SoundSource.sndLine != null),
3850:
3851:
3852:
3853: ComponentFactory.createHorizontalBox (
3854: Box.createHorizontalGlue (),
3855: Multilingual.mlnText (ComponentFactory.createLabel ("Volume "), "ja", "音量 "),
3856: mnbVolumeLabel = ComponentFactory.createLabel (String.valueOf (SoundSource.sndVolume)),
3857: Box.createHorizontalGlue ()
3858: ),
3859:
3860:
3861: ComponentFactory.setPreferredSize (
3862: ComponentFactory.createHorizontalSlider (
3863: 0,
3864: SoundSource.SND_VOLUME_MAX,
3865: SoundSource.sndVolume,
3866: SoundSource.SND_VOLUME_STEP,
3867: 1,
3868: new ChangeListener () {
3869: @Override public void stateChanged (ChangeEvent ce) {
3870: SoundSource.sndSetVolume (((JSlider) ce.getSource ()).getValue ());
3871: }
3872: }),
3873: LnF.lnfFontSize * 18, LnF.lnfFontSize * 2 + 28),
3874: Multilingual.mlnText (
3875: ComponentFactory.createMenu (
3876: "Sound interpolation",
3877: Multilingual.mlnText (
3878: ComponentFactory.createRadioButtonMenuItem (
3879: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.THINNING_STEREO,
3880: "Sound thinning", listener),
3881: "ja", "音声 間引き"),
3882: Multilingual.mlnText (
3883: ComponentFactory.createRadioButtonMenuItem (
3884: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_STEREO,
3885: "Sound linear interpolation", listener),
3886: "ja", "音声 線形補間"),
3887: ComponentFactory.setEnabled (
3888: Multilingual.mlnText (
3889: ComponentFactory.createRadioButtonMenuItem (
3890: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000,
3891: "Sound piecewise-constant area interpolation", listener),
3892: "ja", "音声 区分定数面積補間"),
3893: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000),
3894: ComponentFactory.setEnabled (
3895: Multilingual.mlnText (
3896: ComponentFactory.createRadioButtonMenuItem (
3897: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000,
3898: "Sound linear area interpolation", listener),
3899: "ja", "音声 線形面積補間"),
3900: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000)
3901: ),
3902: "ja", "音声補間"),
3903: Multilingual.mlnText (ComponentFactory.createMenuItem ("Sound monitor", listener), "ja", "音声モニタ"),
3904:
3905: ComponentFactory.createHorizontalSeparator (),
3906:
3907: ComponentFactory.setEnabled (
3908: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (OPM.opmOutputMask != 0, "OPM output", listener), "ja", "OPM 出力"),
3909: SoundSource.sndLine != null),
3910: !OPMLog.OLG_ON ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("OPM log", listener), "ja", "OPM ログ"),
3911:
3912: ComponentFactory.createHorizontalSeparator (),
3913:
3914: ComponentFactory.setEnabled (
3915: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ADPCM.pcmOutputOn, "PCM output", listener), "ja", "PCM 出力"),
3916: SoundSource.sndLine != null),
3917: Multilingual.mlnText (
3918: ComponentFactory.createMenu (
3919: "PCM interpolation",
3920: Multilingual.mlnText (
3921: ComponentFactory.createRadioButtonMenuItem (
3922: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_CONSTANT,
3923: "PCM piecewise-constant interpolation", listener),
3924: "ja", "PCM 区分定数補間"),
3925: Multilingual.mlnText (
3926: ComponentFactory.createRadioButtonMenuItem (
3927: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_LINEAR,
3928: "PCM linear interpolation", listener),
3929: "ja", "PCM 線形補間"),
3930: Multilingual.mlnText (
3931: ComponentFactory.createRadioButtonMenuItem (
3932: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_HERMITE,
3933: "PCM hermite interpolation", listener),
3934: "ja", "PCM エルミート補間")
3935: ),
3936: "ja", "PCM 補間"),
3937: Multilingual.mlnText (
3938: ComponentFactory.createMenu (
3939: "PCM source oscillator frequency",
3940: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 0, "PCM 8MHz/4MHz", listener),
3941: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 1, "PCM 8MHz/16MHz", listener)
3942: ),
3943: "ja", "PCM 原発振周波数"),
3944:
3945: !MercuryUnit.MU4_ON ? null :
3946: ComponentFactory.createHorizontalSeparator (),
3947: !MercuryUnit.MU4_ON ? null :
3948: ComponentFactory.createCheckBoxMenuItem (
3949: MercuryUnit.mu4OnRequest,
3950: "Mercury-Unit V4 (MK-MU1)",
3951: listener),
3952: !MercuryUnit.MU4_ON ? null :
3953: Multilingual.mlnText (
3954: ComponentFactory.createCheckBoxMenuItem (
3955: MercuryUnit.mu4OutputEnable,
3956: "MU4 output",
3957: listener),
3958: "ja", "MU4 出力")
3959: ),
3960: "ja", "音声"),
3961: SoundSource.sndLine != null),
3962:
3963:
3964: mnbInputMenu = Multilingual.mlnText (
3965: ComponentFactory.createMenu (
3966: "Input", 'I',
3967: mnbPasteMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Paste", 'V', MNB_MODIFIERS, listener), "ja", "貼り付け"),
3968: CONDevice.conSettingsMenu,
3969: TextCopy.txcMakeMenuItem (),
3970: TextCopy.txcMakeSettingMenu (),
3971: ComponentFactory.createHorizontalSeparator (),
3972: mnbNoKeyboardMenuItem = Multilingual.mlnText (
3973: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, !Keyboard.kbdOn, "No keyboard", 'K', MNB_MODIFIERS, listener),
3974: "ja", "キーボードなし"),
3975: mnbStandardKeyboardMenuItem = Multilingual.mlnText (
3976: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_STANDARD_TYPE, "Standard keyboard", listener),
3977: "ja", "標準キーボード"),
3978: mnbCompactKeyboardMenuItem = Multilingual.mlnText (
3979: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_COMPACT_TYPE, "Compact keyboard", listener),
3980: "ja", "コンパクトキーボード"),
3981: Multilingual.mlnText (
3982: ComponentFactory.createCheckBoxMenuItem (pnlHideKeyboard, "Hide keyboard in full screen", listener),
3983: "ja", "全画面表示のときキーボードを隠す"),
3984: Multilingual.mlnText (ComponentFactory.createMenuItem ("Key assignments", listener), "ja", "キー割り当て"),
3985: ButtonFunction.bfnMakeMenuItem (),
3986: SRAM.smrRepeatDelayMenu,
3987: SRAM.smrRepeatIntervalMenu,
3988: !Keyboard.KBD_ZKEY_ON ? null : Keyboard.kbdZKeyMenu,
3989: ComponentFactory.createHorizontalSeparator (),
3990: Mouse.musSeamlessMouseCheckBox,
3991: Mouse.musFollowScrollCheckBox,
3992: Mouse.musCtrlRightCheckBox,
3993: Mouse.musEdgeAccelerationCheckBox,
3994: Mouse.musMouseCursorSpeedBox,
3995: Mouse.musSpeedSlider,
3996: Mouse.musHostsPixelUnitsCheckBox,
3997: ComponentFactory.createHorizontalSeparator (),
3998: Multilingual.mlnText (ComponentFactory.createMenuItem ("Joystick port settings", listener), "ja", "ジョイスティックポート設定")
3999: ),
4000: "ja", "入力"),
4001:
4002:
4003: mnbConfigMenu = Multilingual.mlnText (
4004: ComponentFactory.createMenu (
4005: "Config", 'G',
4006: Multilingual.mlnText (ComponentFactory.createMenuItem ("RS-232C and terminal", listener), "ja", "RS-232C とターミナル"),
4007: Multilingual.mlnText (
4008: ComponentFactory.createMenu (
4009: "Debug",
4010: Multilingual.mlnText (ComponentFactory.createMenuItem ("Console", listener), "ja", "コンソール"),
4011: Multilingual.mlnText (ComponentFactory.createMenuItem ("Register list", listener), "ja", "レジスタリスト"),
4012: Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble list", listener), "ja", "逆アセンブルリスト"),
4013: Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory dump list", listener), "ja", "メモリダンプリスト"),
4014: Multilingual.mlnText (ComponentFactory.createMenuItem ("Logical space monitor", listener), "ja", "論理空間モニタ"),
4015: Multilingual.mlnText (ComponentFactory.createMenuItem ("Physical space monitor", listener), "ja", "物理空間モニタ"),
4016: ATCMonitor.ACM_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Address translation caches monitor", listener), "ja", "アドレス変換キャッシュモニタ") : null,
4017: BranchLog.BLG_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Branch log", listener), "ja", "分岐ログ") : null,
4018: ProgramFlowVisualizer.PFV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Program flow visualizer", listener), "ja", "プログラムフロービジュアライザ") : null,
4019: RasterBreakPoint.RBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Raster break point", listener), "ja", "ラスタブレークポイント") : null,
4020: DataBreakPoint.DBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Data break point", listener), "ja", "データブレークポイント") : null,
4021: RootPointerList.RTL_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Root pointer list", listener), "ja", "ルートポインタリスト") : null,
4022: ComponentFactory.createHorizontalSeparator (),
4023: SRAM.smrRomdbMenu
4024: ),
4025: "ja", "デバッグ"),
4026: SRAM.smrBootMenu,
4027: mainMemoryMenu,
4028: highMemoryMenu,
4029: localMemoryMenu,
4030: xellent30Menu,
4031: ComponentFactory.createHorizontalSeparator (),
4032: ComponentFactory.createMenu (
4033: "RTC",
4034: Multilingual.mlnText (
4035: ComponentFactory.createMenuItem ("Adjust clock to host", listener),
4036: "ja", "時計をホストに合わせる")
4037: ),
4038: SRAM.smrMenu,
4039: Settings.sgsMenu,
4040: ComponentFactory.createHorizontalSeparator (),
4041: Multilingual.mlnText (ComponentFactory.createMenuItem ("Printer", listener), "ja", "プリンタ"),
4042: ROM.romMenu,
4043: Multilingual.mlnText (
4044: ComponentFactory.createMenu (
4045: "Miscellaneous",
4046: SlowdownTest.sdtCheckBoxMenuItem,
4047: SlowdownTest.sdtBox,
4048: Multilingual.mlnText (
4049: ComponentFactory.createCheckBoxMenuItem (Mouse.musOutputButtonStatus, "Print key and mouse button events", listener),
4050: "ja", "キーとマウスのボタンのイベントを表示"),
4051: Z8530.SCC_DEBUG_ON ? Z8530.sccDebugMenu : null
4052: ),
4053: "ja", "その他"),
4054: ComponentFactory.createHorizontalSeparator (),
4055: Multilingual.mlnText (
4056: ComponentFactory.createMenu (
4057: "Accessibility",
4058:
4059: !FlashingLights.FLR_ON ? null :
4060: FlashingLights.flrMakeMenu (),
4061: !FlashingLights.FLR_ON ? null :
4062: ComponentFactory.createHorizontalSeparator (),
4063:
4064: mnbMakeFontSizeMenu (),
4065:
4066: mnbMakeColorMenu ()
4067: ),
4068: "ja", "アクセシビリティ"),
4069: ComponentFactory.createHorizontalSeparator (),
4070: Multilingual.mlnText (
4071: ComponentFactory.createMenuItem ("Java runtime environment information", listener),
4072: "ja", "Java 実行環境の情報"),
4073: Multilingual.mlnText (
4074: ComponentFactory.createMenuItem ("Version information", listener),
4075: "ja", "バージョン情報"),
4076: Multilingual.mlnText (
4077: ComponentFactory.createMenu (
4078: "License",
4079: Multilingual.mlnText (ComponentFactory.createMenuItem ("XEiJ License", listener), "ja", "XEiJ 使用許諾条件"),
4080: Multilingual.mlnText (ComponentFactory.createMenuItem ("FSHARP License", listener), "ja", "FSHARP 許諾条件"),
4081: Multilingual.mlnText (ComponentFactory.createMenuItem ("ymfm License", listener), "ja", "ymfm License"),
4082: Multilingual.mlnText (ComponentFactory.createMenuItem ("jSerialComm License", listener), "ja", "jSerialComm License")
4083: ),
4084: "ja", "使用許諾条件")
4085: ),
4086: "ja", "設定"),
4087:
4088: mnbMakeLanguageMenu (),
4089:
4090:
4091: Box.createHorizontalGlue (),
4092: ComponentFactory.createVerticalBox (
4093: Box.createVerticalGlue (),
4094: Indicator.indBox,
4095: Box.createVerticalGlue ()
4096: ),
4097: Box.createHorizontalGlue ()
4098:
4099: );
4100: }
4101:
4102:
4103:
4104:
4105:
4106:
4107:
4108: public static boolean frmIsActive;
4109:
4110:
4111: public static JFrame frmFrame;
4112: public static int frmMarginWidth;
4113: public static int frmMarginHeight;
4114: public static Dimension frmMinimumSize;
4115:
4116:
4117: public static GraphicsDevice frmScreenDevice;
4118:
4119:
4120: public static DropTarget frmDropTarget;
4121:
4122:
4123:
4124: public static void frmInit () {
4125: frmIsActive = false;
4126: frmScreenDevice = GraphicsEnvironment.getLocalGraphicsEnvironment ().getDefaultScreenDevice ();
4127: pnlIsFullScreenSupported = frmScreenDevice.isFullScreenSupported ();
4128: }
4129:
4130:
4131:
4132: public static void frmMake () {
4133:
4134:
4135: frmFrame = ComponentFactory.createRestorableFrame (
4136: Settings.SGS_FRM_FRAME_KEY,
4137: PRG_TITLE + " version " + PRG_VERSION,
4138: mnbMenuBar,
4139: pnlPanel);
4140: frmUpdateTitle ();
4141: frmFrame.setIconImage (LnF.LNF_ICON_IMAGE_48);
4142: frmFrame.setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);
4143:
4144:
4145:
4146:
4147: frmMarginWidth = frmFrame.getWidth () - pnlPanel.getWidth ();
4148: frmMarginHeight = frmFrame.getHeight () - pnlPanel.getHeight ();
4149: frmMinimumSize = new Dimension (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
4150: frmFrame.setMinimumSize (frmMinimumSize);
4151:
4152:
4153:
4154: frmDropTarget = new DropTarget (pnlPanel, DnDConstants.ACTION_COPY, new DropTargetAdapter () {
4155: @Override public void dragOver (DropTargetDragEvent dtde) {
4156: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
4157: dtde.acceptDrag (DnDConstants.ACTION_COPY);
4158: return;
4159: }
4160: dtde.rejectDrag ();
4161: }
4162: @Override public void drop (DropTargetDropEvent dtde) {
4163: try {
4164: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
4165: dtde.acceptDrop (DnDConstants.ACTION_COPY);
4166: boolean reset = false;
4167: int fdu0 = -1;
4168: int fdu = 0;
4169: int hdu0 = -1;
4170: int hdu = 0;
4171: int scu0 = -1;
4172: int scu = 0;
4173: int hfu0 = -1;
4174: int hfu = 0;
4175: for (Object o : (java.util.List) dtde.getTransferable ().getTransferData (DataFlavor.javaFileListFlavor)) {
4176: if (o instanceof File) {
4177: File file = (File) o;
4178: if (file.isFile ()) {
4179: if (FDC.fdcFileFilter.accept (file)) {
4180: if (fdu < FDC.FDC_MAX_UNITS &&
4181: FDC.fdcUnitArray[fdu].insert (file.getPath (), false)) {
4182: if (fdu0 < 0) {
4183: fdu0 = fdu;
4184: }
4185: fdu++;
4186: continue;
4187: }
4188: }
4189: if (HDC.hdcFileFilter.accept (file)) {
4190: if (hdu < 16 &&
4191: HDC.hdcUnitArray[hdu].insert (file.getPath (), false)) {
4192: if (hdu0 < 0) {
4193: hdu0 = hdu;
4194: }
4195: hdu++;
4196: continue;
4197: }
4198: }
4199: if (SPC.spcFileFilter.accept (file)) {
4200: if (scu < 16 &&
4201: SPC.spcUnitArray[scu].insert (file.getPath (), false)) {
4202: if (scu0 < 0) {
4203: scu0 = scu;
4204: }
4205: scu++;
4206: continue;
4207: }
4208: }
4209: }
4210: if (HFS.hfsFileFilter.accept (file)) {
4211: if (hfu < HFS.HFS_MAX_UNITS &&
4212: HFS.hfsUnitArray[hfu].insert (file.getPath (), false)) {
4213: if (hfu0 < 0) {
4214: hfu0 = hfu;
4215: }
4216: hfu++;
4217: continue;
4218: }
4219: }
4220: }
4221: reset = false;
4222: }
4223: dtde.dropComplete (true);
4224: if (reset) {
4225: if (fdu0 >= 0) {
4226: mpuReset (0x9070 | fdu0 << 8, -1);
4227: } else if (hdu0 >= 0) {
4228: mpuReset (0x8000 | hdu0 << 8, -1);
4229: } else if (scu0 >= 0) {
4230: mpuReset (0xa000, SPC.SPC_HANDLE_EX + (scu0 << 2));
4231: } else if (hfu0 >= 0) {
4232: HFS.hfsBootUnit = hfu0;
4233: mpuReset (0xa000, HFS.HFS_BOOT_HANDLE);
4234: }
4235: }
4236: return;
4237: }
4238: } catch (UnsupportedFlavorException ufe) {
4239:
4240: } catch (IOException ioe) {
4241:
4242: }
4243: dtde.rejectDrop();
4244: }
4245: });
4246:
4247: }
4248:
4249:
4250:
4251: public static void frmUpdateTitle () {
4252: frmFrame.setTitle ((currentAccelerator == ACCELERATOR_HYBRID ? "X68000 Hybrid" :
4253: currentModel.getName () +
4254: (currentAccelerator == ACCELERATOR_XELLENT30 ? " with Xellent30" :
4255: currentAccelerator == ACCELERATOR_060TURBO ? " with 060turbo" :
4256: currentAccelerator == ACCELERATOR_060TURBOPRO ? " with 060turboPRO" : "")) +
4257: " - " + PRG_TITLE + " version " + PRG_VERSION);
4258: }
4259:
4260:
4261:
4262: public static void frmStart () {
4263:
4264:
4265:
4266:
4267:
4268:
4269:
4270:
4271: ComponentFactory.addListener (
4272: frmFrame,
4273: new WindowAdapter () {
4274: @Override public void windowActivated (WindowEvent we) {
4275: frmIsActive = true;
4276: }
4277: @Override public void windowClosing (WindowEvent we) {
4278: prgTini ();
4279: }
4280: @Override public void windowDeactivated (WindowEvent we) {
4281: frmIsActive = false;
4282:
4283: }
4284: @Override public void windowOpened (WindowEvent we) {
4285: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
4286: pnlFixedRate = pnlGetRefreshRate ();
4287: }
4288: }
4289: });
4290:
4291:
4292:
4293:
4294: ComponentFactory.addListener (
4295: frmFrame,
4296: new ComponentAdapter () {
4297: @Override public void componentMoved (ComponentEvent ce) {
4298: Point p = pnlPanel.getLocationOnScreen ();
4299: pnlGlobalX = p.x;
4300: pnlGlobalY = p.y;
4301: }
4302: @Override public void componentResized (ComponentEvent ce) {
4303: Point p = pnlPanel.getLocationOnScreen ();
4304: pnlGlobalX = p.x;
4305: pnlGlobalY = p.y;
4306: }
4307: });
4308:
4309: }
4310:
4311:
4312:
4313:
4314:
4315:
4316: public static BufferedImage clpClipboardImage;
4317: public static String clpClipboardString;
4318: public static Clipboard clpClipboard;
4319: public static Transferable clpImageContents;
4320: public static Transferable clpStringContents;
4321: public static ClipboardOwner clpClipboardOwner;
4322: public static boolean clpIsClipboardOwner;
4323:
4324:
4325:
4326:
4327: public static void clpMake () {
4328: Toolkit toolkit = Toolkit.getDefaultToolkit ();
4329: clpClipboard = null;
4330: try {
4331: clpClipboard = toolkit.getSystemClipboard ();
4332: } catch (Exception e) {
4333: return;
4334: }
4335: clpClipboardImage = null;
4336: clpClipboardString = null;
4337: clpImageContents = new Transferable () {
4338: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
4339: if (flavor == DataFlavor.imageFlavor) {
4340: return clpClipboardImage;
4341: } else {
4342: throw new UnsupportedFlavorException (flavor);
4343: }
4344: }
4345: public DataFlavor[] getTransferDataFlavors () {
4346: return new DataFlavor[] { DataFlavor.imageFlavor };
4347: }
4348: public boolean isDataFlavorSupported (DataFlavor flavor) {
4349: return flavor == DataFlavor.imageFlavor;
4350: }
4351: };
4352: clpStringContents = new Transferable () {
4353: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
4354: if (flavor == DataFlavor.stringFlavor) {
4355: return clpClipboardString;
4356: } else {
4357: throw new UnsupportedFlavorException (flavor);
4358: }
4359: }
4360: public DataFlavor[] getTransferDataFlavors () {
4361: return new DataFlavor[] { DataFlavor.stringFlavor };
4362: }
4363: public boolean isDataFlavorSupported (DataFlavor flavor) {
4364: return flavor == DataFlavor.stringFlavor;
4365: }
4366: };
4367: clpIsClipboardOwner = false;
4368:
4369:
4370: clpClipboardOwner = new ClipboardOwner () {
4371: @Override public void lostOwnership (Clipboard clipboard, Transferable contents) {
4372: clpIsClipboardOwner = false;
4373: }
4374: };
4375:
4376:
4377: clpClipboard.addFlavorListener (new FlavorListener () {
4378: @Override public void flavorsChanged (FlavorEvent fe) {
4379: boolean available = false;
4380: try {
4381: available = clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor);
4382: } catch (IllegalStateException ise) {
4383: }
4384: if (mnbPasteMenuItem != null) {
4385: mnbPasteMenuItem.setEnabled (available);
4386: }
4387: }
4388: });
4389: if (!clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor)) {
4390: if (mnbPasteMenuItem != null) {
4391: mnbPasteMenuItem.setEnabled (false);
4392: }
4393: }
4394: }
4395:
4396:
4397:
4398: public static void clpCopy (String s) {
4399: if (clpClipboard != null && s != null) {
4400: clpClipboardString = s;
4401: try {
4402: clpClipboard.setContents (clpStringContents, clpClipboardOwner);
4403: clpIsClipboardOwner = true;
4404: } catch (Exception e) {
4405: return;
4406: }
4407: }
4408: }
4409:
4410:
4411:
4412:
4413:
4414:
4415:
4416:
4417:
4418:
4419:
4420:
4421:
4422:
4423:
4424:
4425:
4426:
4427:
4428:
4429:
4430:
4431:
4432: public static int xt3DIPSWRequest;
4433: public static int xt3DIPSW;
4434: public static int xt3PortAddress;
4435:
4436:
4437: public static int xt3MemorySizeRequest;
4438: public static int xt3MemorySize;
4439: public static boolean xt3MemoryEnabled;
4440: public static int xt3MemoryPosition;
4441: public static int xt3MemoryStart;
4442: public static final byte[] xt3MemoryArray = new byte[1 << 20];
4443: public static boolean xt3MemorySave;
4444:
4445:
4446: public static int xt3SavedPC;
4447: public static final int[] xt3SavedRn = new int[16];
4448:
4449:
4450: public static void xt3Init () {
4451:
4452:
4453: xt3DIPSWRequest = Math.max (0, Math.min (3, Settings.sgsGetInt ("xt3dipsw")));
4454: xt3DIPSW = xt3DIPSWRequest;
4455:
4456:
4457: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4458:
4459:
4460: int memoryKB = Settings.sgsGetInt ("xt3memorykb");
4461: if (!(memoryKB == 1 << 8 || memoryKB == 1 << 10)) {
4462: memoryKB = 1 << 8;
4463: }
4464: xt3MemorySizeRequest = memoryKB << 10;
4465: xt3MemorySize = xt3MemorySizeRequest;
4466:
4467:
4468: xt3MemoryEnabled = false;
4469:
4470:
4471: xt3MemoryPosition = 11 << 20;
4472:
4473:
4474: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4475:
4476:
4477:
4478: byte[] memoryArray = Settings.sgsGetData ("xt3memorydata");
4479: Arrays.fill (xt3MemoryArray,
4480: (byte) 0);
4481: if (memoryArray.length != 0) {
4482: System.arraycopy (memoryArray, 0,
4483: xt3MemoryArray, 0,
4484: Math.min (memoryArray.length, xt3MemoryArray.length));
4485: if (memoryArray.length < xt3MemoryArray.length) {
4486: Arrays.fill (xt3MemoryArray,
4487: memoryArray.length,
4488: xt3MemoryArray.length,
4489: (byte) 0);
4490: }
4491: }
4492:
4493:
4494: xt3MemorySave = Settings.sgsGetOnOff ("xt3memorysave");
4495:
4496:
4497: xt3SavedPC = 0;
4498:
4499: Arrays.fill (xt3SavedRn, 0);
4500:
4501: xt3Reset ();
4502: }
4503:
4504:
4505: public static void xt3Tini () {
4506:
4507:
4508: Settings.sgsPutInt ("xt3dipsw", xt3DIPSW);
4509:
4510:
4511: Settings.sgsPutInt ("xt3memorykb", xt3MemorySizeRequest >> 10);
4512:
4513:
4514: boolean zero = true;
4515: if (xt3MemorySave) {
4516: for (int i = 0; i < 1 << 20; i++) {
4517: if (xt3MemoryArray[i] != 0) {
4518: zero = false;
4519: break;
4520: }
4521: }
4522: }
4523: Settings.sgsCurrentMap.put ("xt3memorydata",
4524: zero ? "" :
4525: ByteArray.byaEncodeBase64 (ByteArray.byaEncodeGzip (xt3MemoryArray, 0, 1 << 20)));
4526:
4527:
4528: Settings.sgsPutOnOff ("xt3memorysave", xt3MemorySave);
4529:
4530: }
4531:
4532:
4533: public static void xt3Reset () {
4534:
4535:
4536: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4537:
4538:
4539: xt3MemorySize = xt3MemorySizeRequest;
4540:
4541:
4542: xt3MemoryEnabled = false;
4543:
4544:
4545: xt3MemoryPosition = 11 << 20;
4546:
4547:
4548: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4549:
4550:
4551: xt3SavedPC = 0;
4552: Arrays.fill (xt3SavedRn, 0);
4553:
4554: }
4555:
4556:
4557: public static int xt3PortRead () {
4558: return (currentIsSecond ? 4 : 0) | (xt3MemoryEnabled ? 2 : 0) | (xt3MemoryPosition == 11 << 20 ? 0 : 1);
4559: }
4560:
4561:
4562: public static void xt3PortWrite (int d) {
4563: boolean nextIsSecond = (d & 4) != 0;
4564: boolean memoryEnabled = (d & 2) != 0;
4565: int memoryPosition = (d & 1) == 0 ? 11 << 20 : 15 << 20;
4566:
4567: if (xt3MemoryEnabled != memoryEnabled ||
4568: xt3MemoryPosition != memoryPosition) {
4569: if (xt3MemoryEnabled) {
4570: if (xt3MemoryPosition == 11 << 20) {
4571: if (MainMemory.mmrMemorySizeCurrent < 12 << 20) {
4572: busSuper (MemoryMappedDevice.MMD_NUL, (12 << 20) - xt3MemorySize, 12 << 20);
4573: } else {
4574: busUser (MemoryMappedDevice.MMD_MMR, (12 << 20) - xt3MemorySize, 12 << 20);
4575: }
4576: } else {
4577: busSuper (MemoryMappedDevice.MMD_ROM, (16 << 20) - xt3MemorySize, 16 << 20);
4578: }
4579: }
4580: xt3MemoryEnabled = memoryEnabled;
4581: xt3MemoryPosition = memoryPosition;
4582: if (xt3MemoryEnabled) {
4583: if (xt3MemoryPosition == 11 << 20) {
4584: busUser (MemoryMappedDevice.MMD_XTM, (12 << 20) - xt3MemorySize, 12 << 20);
4585: } else {
4586: busUser (MemoryMappedDevice.MMD_XTM, (16 << 20) - xt3MemorySize, 16 << 20);
4587: }
4588: }
4589: }
4590:
4591: if (currentIsSecond != nextIsSecond) {
4592:
4593: if (nextIsSecond) {
4594:
4595:
4596: xt3SavedPC = regPC;
4597: System.arraycopy (regRn, 0, xt3SavedRn, 0, 16);
4598:
4599:
4600: if (mpuTask != null) {
4601: mpuClockLimit = 0L;
4602: System.out.println (Multilingual.mlnJapanese ?
4603: Model.MPU_NAMES[currentFirstMPU] + " を停止します" :
4604: Model.MPU_NAMES[currentFirstMPU] + " stops");
4605: mpuTask.cancel ();
4606: mpuTask = null;
4607: }
4608:
4609:
4610: tmrTimer.schedule (new TimerTask () {
4611: @Override public void run () {
4612:
4613:
4614: currentIsSecond = true;
4615: currentMPU = currentSecondMPU;
4616: mpuSetCurrentClock (specifiedSecondClock);
4617:
4618: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
4619: MC68EC030.m30DivZeroVFlag = false;
4620: }
4621:
4622: RegisterList.drpSetMPU ();
4623: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4624: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4625: MC68060.mmuReset ();
4626:
4627: mpuIgnoreAddressError = true;
4628: fpuBox = fpuMotherboardCoprocessor;
4629: fpuBox.epbReset ();
4630: fpuFPn = fpuBox.epbFPn;
4631: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
4632: mpuSetWait ();
4633:
4634: regSRT1 = regSRT0 = 0;
4635: regSRS = REG_SR_S;
4636: regSRM = 0;
4637: regSRI = REG_SR_I;
4638: regCCR = 0;
4639: Arrays.fill (regRn, 0);
4640:
4641: regRn[15] = MainMemory.mmrRls (0x00000000);
4642: regPC = MainMemory.mmrRls (0x00000004);
4643:
4644: mpuIMR = 0;
4645: mpuIRR = 0;
4646: if (MC68901.MFP_DELAYED_INTERRUPT) {
4647: mpuDIRR = 0;
4648: }
4649: mpuISR = 0;
4650:
4651: mpuStart ();
4652: }
4653: }, TMR_DELAY);
4654:
4655: } else {
4656:
4657:
4658: if (mpuTask != null) {
4659: mpuClockLimit = 0L;
4660: System.out.println (Multilingual.mlnJapanese ? "MC68EC030 を停止します" : "MC68EC030 stops");
4661: mpuTask.cancel ();
4662: mpuTask = null;
4663: }
4664:
4665:
4666: tmrTimer.schedule (new TimerTask () {
4667: @Override public void run () {
4668:
4669:
4670: currentIsSecond = false;
4671: currentMPU = currentFirstMPU;
4672: mpuSetCurrentClock (specifiedFirstClock);
4673:
4674: RegisterList.drpSetMPU ();
4675: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4676: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4677: MC68060.mmuReset ();
4678:
4679: mpuIgnoreAddressError = false;
4680: mpuCacheOn = false;
4681: mpuSetWait ();
4682:
4683: regSRT1 = regSRT0 = 0;
4684: regSRS = REG_SR_S;
4685: regSRM = 0;
4686: regSRI = REG_SR_I;
4687: regCCR = 0;
4688:
4689: regPC = xt3SavedPC;
4690: System.arraycopy (xt3SavedRn, 0, regRn, 0, 16);
4691:
4692: mpuIMR = 0;
4693: mpuIRR = 0;
4694: if (MC68901.MFP_DELAYED_INTERRUPT) {
4695: mpuDIRR = 0;
4696: }
4697: mpuISR = 0;
4698:
4699: mpuStart ();
4700: }
4701: }, TMR_DELAY);
4702:
4703: }
4704: }
4705: }
4706:
4707:
4708:
4709:
4710:
4711:
4712: public static JMenu mdlMenu;
4713:
4714: public static JRadioButtonMenuItem mdlShodaiMenuItem;
4715: public static JRadioButtonMenuItem mdlACEMenuItem;
4716: public static JRadioButtonMenuItem mdlEXPERTMenuItem;
4717: public static JRadioButtonMenuItem mdlPROMenuItem;
4718: public static JRadioButtonMenuItem mdlSUPERMenuItem;
4719: public static JRadioButtonMenuItem mdlXVIMenuItem;
4720: public static JRadioButtonMenuItem mdlXellent30MenuItem;
4721: public static JRadioButtonMenuItem mdlCompactMenuItem;
4722: public static JRadioButtonMenuItem mdlHybridMenuItem;
4723: public static JRadioButtonMenuItem mdl060turboPROMenuItem;
4724: public static JRadioButtonMenuItem mdlX68030MenuItem;
4725: public static JRadioButtonMenuItem mdl030CompactMenuItem;
4726: public static JRadioButtonMenuItem mdl060turboMenuItem;
4727: public static JCheckBoxMenuItem mdlMC68010MenuItem;
4728:
4729: public static JMenu coproFPUMenu;
4730:
4731:
4732: public static final int ACCELERATOR_HYBRID = 1;
4733: public static final int ACCELERATOR_XELLENT30 = 2;
4734: public static final int ACCELERATOR_060TURBO = 3;
4735: public static final int ACCELERATOR_060TURBOPRO = 4;
4736: public static final double MHZ_HYBRID_VALUE = 100.0 / 3.0;
4737: public static final String MHZ_HYBRID_STRING = "33.3";
4738: public static final double MHZ_060TURBO_VALUE = 50.0;
4739: public static final String MHZ_060TURBO_STRING = "50";
4740:
4741:
4742:
4743: public static Model specifiedModel;
4744: public static int specifiedAccelerator;
4745: public static boolean mpu010;
4746:
4747: public static boolean specifiedIsSecond;
4748: public static int specifiedFirstMPU;
4749: public static int specifiedSecondMPU;
4750: public static int specifiedMPU;
4751:
4752: public static double specifiedFirstClock;
4753: public static double specifiedSecondClock;
4754: public static double specifiedClock;
4755:
4756: public static int specifiedCopro0;
4757: public static int specifiedCopro1;
4758: public static int specifiedCopro2;
4759: public static int specifiedOnchipFPU;
4760:
4761:
4762:
4763: public static Model currentModel;
4764: public static int currentAccelerator;
4765:
4766: public static boolean currentIsSecond;
4767: public static int currentFirstMPU;
4768: public static int currentSecondMPU;
4769: public static int currentMPU;
4770:
4771:
4772: public static int currentCopro0;
4773: public static int currentCopro1;
4774: public static int currentCopro2;
4775: public static int currentOnchipFPU;
4776:
4777:
4778:
4779: public static void mdlInit () {
4780:
4781:
4782: specifiedModel = Model.COMPACT;
4783: specifiedAccelerator = ACCELERATOR_HYBRID;
4784: mpu010 = Settings.sgsGetOnOff ("mpu010");
4785: {
4786: String paramModel = Settings.sgsGetString ("model");
4787: switch (paramModel.toLowerCase ()) {
4788: case "":
4789: case "none":
4790: case "hybrid":
4791: specifiedModel = Model.COMPACT;
4792: specifiedAccelerator = ACCELERATOR_HYBRID;
4793: break;
4794: case "xellent30":
4795: specifiedModel = Model.XVI;
4796: specifiedAccelerator = ACCELERATOR_XELLENT30;
4797: break;
4798: case "060turbo":
4799: specifiedModel = Model.X68030;
4800: specifiedAccelerator = ACCELERATOR_060TURBO;
4801: break;
4802: case "060turbopro":
4803: specifiedModel = Model.PRO;
4804: specifiedAccelerator = ACCELERATOR_060TURBOPRO;
4805: break;
4806: default:
4807: Model model = Model.fromTypeOrSynonym (paramModel);
4808: if (model != null) {
4809: specifiedModel = model;
4810: specifiedAccelerator = 0;
4811: } else {
4812: System.out.println (Multilingual.mlnJapanese ?
4813: paramModel + " は不明な機種です" :
4814: paramModel + " is unknown model");
4815: specifiedModel = Model.COMPACT;
4816: specifiedAccelerator = ACCELERATOR_HYBRID;
4817: }
4818: }
4819: }
4820:
4821: specifiedIsSecond = false;
4822: specifiedFirstMPU = specifiedModel.getMPU ();
4823: specifiedSecondMPU = Model.MPU_MC68EC030;
4824: {
4825: String[] paramMPUs = Settings.sgsGetString ("mpu").split (",");
4826: for (int i = 0; i < 2; i++) {
4827: int mpu = 0;
4828: String paramMPU = i < paramMPUs.length ? paramMPUs[i] : "";
4829: switch (paramMPU) {
4830: case "":
4831: case "none":
4832: case "-1":
4833: mpu = (i == 0 ?
4834: (specifiedAccelerator == ACCELERATOR_060TURBO ||
4835: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4836: specifiedModel.getMPU ()) :
4837: Model.MPU_MC68EC030);
4838: break;
4839: case "0":
4840: case "68000":
4841: case "mc68000":
4842: mpu = Model.MPU_MC68000;
4843: break;
4844: case "1":
4845: case "68010":
4846: case "mc68010":
4847: mpu = Model.MPU_MC68010;
4848: break;
4849:
4850:
4851:
4852:
4853:
4854: case "3":
4855: case "68ec030":
4856: case "mc68ec030":
4857: mpu = Model.MPU_MC68EC030;
4858: break;
4859:
4860:
4861:
4862:
4863:
4864:
4865:
4866:
4867:
4868:
4869:
4870:
4871:
4872:
4873:
4874:
4875:
4876: case "6":
4877: case "68060":
4878: case "mc68060":
4879: mpu = Model.MPU_MC68060;
4880: break;
4881: default:
4882: Model model = Model.fromTypeOrSynonym (paramMPU);
4883: if (model != null) {
4884: mpu = model.getMPU ();
4885: } else {
4886: System.out.println (Multilingual.mlnJapanese ?
4887: paramMPU + " は不明な MPU です" :
4888: paramMPU + " is unknown MPU");
4889: mpu = specifiedModel.getMPU ();
4890: }
4891: }
4892: if (i == 0) {
4893: specifiedFirstMPU = mpu;
4894: } else {
4895: specifiedSecondMPU = mpu;
4896: }
4897: }
4898: }
4899: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
4900:
4901: specifiedFirstClock = specifiedModel.getClock ();
4902: specifiedSecondClock = specifiedFirstClock * 2.0;
4903: {
4904: String[] paramClocks = Settings.sgsGetString ("clock").split (",");
4905: for (int i = 0; i < 2; i++) {
4906: double clock = 0.0;
4907: String paramClock = i < paramClocks.length ? paramClocks[i] : "";
4908: switch (paramClock.toLowerCase ()) {
4909: case "":
4910: case "none":
4911: case "-1":
4912: clock = (i == 0 ?
4913: (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4914: specifiedAccelerator == ACCELERATOR_060TURBO ||
4915: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4916: specifiedModel.getClock ()) :
4917: specifiedFirstClock * 2.0);
4918: break;
4919: case "hybrid":
4920: clock = MHZ_HYBRID_VALUE;
4921: break;
4922: case "060turbo":
4923: case "060turbopro":
4924: clock = MHZ_060TURBO_VALUE;
4925: break;
4926: case "16.7":
4927: case "xellent30":
4928: clock = 50.0 / 3.0;
4929: break;
4930: case "33.3":
4931: clock = 100.0 / 3.0;
4932: break;
4933: case "66.7":
4934: clock = 200.0 / 3.0;
4935: break;
4936: default:
4937: if (paramClock.matches ("^(?:" +
4938: "[-+]?" +
4939: "(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)" +
4940: "(?:[Ee][-+]?[0-9]+)?" +
4941: ")$")) {
4942: double d = Double.parseDouble (paramClock);
4943: if (1.0 <= d && d <= 1000.0) {
4944: clock = d;
4945: }
4946: } else {
4947: System.out.println (Multilingual.mlnJapanese ?
4948: paramClock + " は不明な動作周波数です" :
4949: paramClock + " is unknown clock frequency");
4950: clock = specifiedModel.getClock ();
4951: }
4952: }
4953: if (i == 0) {
4954: specifiedFirstClock = clock;
4955: } else {
4956: specifiedSecondClock = clock;
4957: }
4958: }
4959: }
4960: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4961:
4962: specifiedCopro0 = 15 & Settings.sgsGetInt ("copro0", 2);
4963: if (!((7 & specifiedCopro0) == 0 ||
4964: (7 & specifiedCopro0) == 1 ||
4965: (7 & specifiedCopro0) == 2 ||
4966: (7 & specifiedCopro0) == 7)) {
4967: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4968: }
4969: specifiedCopro1 = 15 & Settings.sgsGetInt ("copro1", 2);
4970: if (!((7 & specifiedCopro1) == 0 ||
4971: (7 & specifiedCopro1) == 1 ||
4972: (7 & specifiedCopro1) == 2 ||
4973: (7 & specifiedCopro1) == 7)) {
4974: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4975: }
4976: specifiedCopro2 = 15 & Settings.sgsGetInt ("copro2", 2);
4977: if (!((7 & specifiedCopro2) == 0 ||
4978: (7 & specifiedCopro2) == 1 ||
4979: (7 & specifiedCopro2) == 2 ||
4980: (7 & specifiedCopro2) == 7)) {
4981: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4982: }
4983: specifiedOnchipFPU = 15 & Settings.sgsGetInt ("onchipfpu", 7);
4984: if (!((7 & specifiedOnchipFPU) == 0 ||
4985: (7 & specifiedOnchipFPU) == 6 ||
4986: (7 & specifiedOnchipFPU) == 7)) {
4987: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4988: }
4989:
4990:
4991: currentModel = specifiedModel;
4992: currentAccelerator = specifiedAccelerator;
4993:
4994: currentIsSecond = specifiedIsSecond;
4995: currentFirstMPU = specifiedFirstMPU;
4996: currentSecondMPU = specifiedSecondMPU;
4997: currentMPU = specifiedMPU;
4998:
4999:
5000: currentCopro0 = specifiedCopro0;
5001: currentCopro1 = specifiedCopro1;
5002: currentCopro2 = specifiedCopro2;
5003: currentOnchipFPU = specifiedOnchipFPU;
5004:
5005:
5006: mpuUtilOn = Settings.sgsGetOnOff ("util");
5007: mpuUtilRatio = fmtParseInt (Settings.sgsGetString ("ratio"), 0, 1, 100, 100);
5008:
5009: mpuArbFreqMHz = fmtParseInt (Settings.sgsGetString ("mhz"), 0, 1, 1000, 100);
5010: if (mpuUtilOn) {
5011: mpuArbFreqOn = false;
5012: } else {
5013: mpuArbFreqOn = !(specifiedClock == 10.0 ||
5014: specifiedClock == 50.0 / 3.0 ||
5015: specifiedClock == 25.0 ||
5016: specifiedClock == 100.0 / 3.0 ||
5017: specifiedClock == 50.0 ||
5018: specifiedClock == 200.0 / 3.0 ||
5019: specifiedClock == 75.0 ||
5020: specifiedClock == 100.0);
5021: if (mpuArbFreqOn) {
5022: mpuArbFreqMHz = (int) specifiedClock;
5023: }
5024: }
5025:
5026:
5027: mpuROMWaitCycles = 0;
5028: mpuRAMWaitCycles = 0;
5029: mpuCacheOn = false;
5030:
5031: mpuNoWaitTime.ram = 0;
5032: mpuNoWaitTime.gvram = 0;
5033: mpuNoWaitTime.tvram = 0;
5034: mpuNoWaitTime.crtc = 0;
5035: mpuNoWaitTime.palet = 0;
5036: mpuNoWaitTime.vicon = 0;
5037: mpuNoWaitTime.dmac = 0;
5038: mpuNoWaitTime.mfp = 0;
5039: mpuNoWaitTime.rtc = 0;
5040: mpuNoWaitTime.prnport = 0;
5041: mpuNoWaitTime.sysport = 0;
5042: mpuNoWaitTime.opm = 0;
5043: mpuNoWaitTime.adpcm = 0;
5044: mpuNoWaitTime.fdc = 0;
5045: mpuNoWaitTime.fdd = 0;
5046: mpuNoWaitTime.hdc = 0;
5047: mpuNoWaitTime.scc = 0;
5048: mpuNoWaitTime.ppi = 0;
5049: mpuNoWaitTime.ioi = 0;
5050: mpuNoWaitTime.sprc = 0;
5051: mpuNoWaitTime.sram = 0;
5052: mpuNoWaitTime.rom = 0;
5053: mpuNoWaitTime.ramlong = mpuNoWaitTime.ram << 1;
5054: mpuNoWaitTime.romlong = mpuNoWaitTime.rom << 1;
5055:
5056: dmaNoWaitTime.ram = 0;
5057: dmaNoWaitTime.gvram = 0;
5058: dmaNoWaitTime.tvram = 0;
5059: dmaNoWaitTime.crtc = 0;
5060: dmaNoWaitTime.palet = 0;
5061: dmaNoWaitTime.vicon = 0;
5062: dmaNoWaitTime.dmac = 0;
5063: dmaNoWaitTime.mfp = 0;
5064: dmaNoWaitTime.rtc = 0;
5065: dmaNoWaitTime.prnport = 0;
5066: dmaNoWaitTime.sysport = 0;
5067: dmaNoWaitTime.opm = 0;
5068: dmaNoWaitTime.adpcm = 0;
5069: dmaNoWaitTime.fdc = 0;
5070: dmaNoWaitTime.fdd = 0;
5071: dmaNoWaitTime.hdc = 0;
5072: dmaNoWaitTime.scc = 0;
5073: dmaNoWaitTime.ppi = 0;
5074: dmaNoWaitTime.ioi = 0;
5075: dmaNoWaitTime.sprc = 0;
5076: dmaNoWaitTime.sram = 0;
5077: dmaNoWaitTime.rom = 0;
5078: dmaNoWaitTime.ramlong = dmaNoWaitTime.ram << 1;
5079: dmaNoWaitTime.romlong = dmaNoWaitTime.rom << 1;
5080:
5081:
5082: busWaitCyclesRequest = Settings.sgsGetOnOff ("waitcycles");
5083: busWaitCycles = busWaitCyclesRequest;
5084: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
5085:
5086: }
5087:
5088: public static void mdlTini () {
5089:
5090: Settings.sgsPutString ("model",
5091: specifiedAccelerator == ACCELERATOR_HYBRID ? "Hybrid" :
5092: specifiedAccelerator == ACCELERATOR_XELLENT30 ? "Xellent30" :
5093: specifiedAccelerator == ACCELERATOR_060TURBO ? "060turbo" :
5094: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? "060turboPRO" :
5095: specifiedModel.getSynonym () != null ? specifiedModel.getSynonym () :
5096: specifiedModel.getType ());
5097: Settings.sgsPutOnOff ("mpu010", mpu010);
5098:
5099:
5100: int defaultFirstMPU = (specifiedAccelerator == ACCELERATOR_060TURBO ||
5101: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
5102: specifiedModel.getMPU ());
5103: int defaultSecondMPU = Model.MPU_MC68EC030;
5104: Settings.sgsPutString ("mpu",
5105: (specifiedFirstMPU == defaultFirstMPU ? "" :
5106: Model.mpuNameOf (specifiedFirstMPU)) +
5107: (specifiedSecondMPU == defaultSecondMPU ? "" :
5108: "," + Model.mpuNameOf (specifiedSecondMPU)));
5109:
5110:
5111:
5112:
5113: double defaultFirstClock = (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
5114: specifiedAccelerator == ACCELERATOR_060TURBO ||
5115: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
5116: specifiedModel.getClock ());
5117: double defaultSecondClock = defaultFirstClock * 2.0;
5118: Settings.sgsPutString ("clock",
5119: (specifiedFirstClock == defaultFirstClock ? "" :
5120: specifiedFirstClock == 50.0 / 3.0 ? "16.7" :
5121: specifiedFirstClock == 100.0 / 3.0 ? "33.3" :
5122: specifiedFirstClock == 200.0 / 3.0 ? "66.7" :
5123: String.valueOf ((int) specifiedFirstClock)) +
5124: (specifiedSecondClock == defaultSecondClock ? "" :
5125: "," + (specifiedSecondClock == 50.0 / 3.0 ? "16.7" :
5126: specifiedSecondClock == 100.0 / 3.0 ? "33.3" :
5127: specifiedSecondClock == 200.0 / 3.0 ? "66.7" :
5128: String.valueOf ((int) specifiedSecondClock))));
5129:
5130: Settings.sgsPutInt ("copro0", specifiedCopro0);
5131: Settings.sgsPutInt ("copro1", specifiedCopro1);
5132: Settings.sgsPutInt ("copro2", specifiedCopro2);
5133: Settings.sgsPutInt ("onchipfpu", specifiedOnchipFPU);
5134:
5135: Settings.sgsPutOnOff ("util",
5136: mpuUtilOn);
5137: Settings.sgsPutString ("ratio",
5138: String.valueOf (mpuUtilRatio));
5139:
5140: Settings.sgsPutString ("mhz",
5141: String.valueOf (mpuArbFreqMHz));
5142:
5143: Settings.sgsPutOnOff ("waitcycles", busWaitCyclesRequest);
5144: }
5145:
5146: public static void mdlMakeMenu () {
5147:
5148:
5149: ActionListener listener = new ActionListener () {
5150: @Override public void actionPerformed (ActionEvent ae) {
5151: Object source = ae.getSource ();
5152: switch (ae.getActionCommand ()) {
5153: case "X68000 (10MHz)":
5154: mdlRequestModel (Model.SHODAI, 0);
5155: mpuReset (-1, -1);
5156: break;
5157: case "X68000 ACE (10MHz)":
5158: mdlRequestModel (Model.ACE, 0);
5159: mpuReset (-1, -1);
5160: break;
5161: case "X68000 EXPERT (10MHz)":
5162: mdlRequestModel (Model.EXPERT, 0);
5163: mpuReset (-1, -1);
5164: break;
5165: case "X68000 PRO (10MHz)":
5166: mdlRequestModel (Model.PRO, 0);
5167: mpuReset (-1, -1);
5168: break;
5169: case "X68000 SUPER (10MHz)":
5170: mdlRequestModel (Model.SUPER, 0);
5171: mpuReset (-1, -1);
5172: break;
5173: case "X68000 XVI (16.7MHz)":
5174: mdlRequestModel (Model.XVI, 0);
5175: mpuReset (-1, -1);
5176: break;
5177: case "X68000 Compact (16.7MHz)":
5178: mdlRequestModel (Model.COMPACT, 0);
5179: mpuReset (-1, -1);
5180: break;
5181:
5182: case "X68030 (25MHz)":
5183: mdlRequestModel (Model.X68030, 0);
5184: mpuReset (-1, -1);
5185: break;
5186: case "X68030 Compact (25MHz)":
5187: mdlRequestModel (Model.X68030COMPACT, 0);
5188: mpuReset (-1, -1);
5189: break;
5190:
5191: case "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)":
5192: mdlRequestModel (Model.COMPACT, ACCELERATOR_HYBRID);
5193: mpuReset (-1, -1);
5194: break;
5195: case "Xellent30 (33.3MHz)":
5196: mdlRequestModel (Model.XVI, ACCELERATOR_XELLENT30);
5197: mpuReset (-1, -1);
5198: break;
5199: case "060turbo (" + MHZ_060TURBO_STRING + "MHz)":
5200: mdlRequestModel (Model.X68030, ACCELERATOR_060TURBO);
5201: mpuReset (-1, -1);
5202: break;
5203: case "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)":
5204: mdlRequestModel (Model.PRO, ACCELERATOR_060TURBOPRO);
5205: mpuReset (-1, -1);
5206: break;
5207:
5208: case "MC68010":
5209: mpu010 = ((JCheckBoxMenuItem) source).isSelected ();
5210: break;
5211:
5212: }
5213: }
5214: };
5215:
5216:
5217: ButtonGroup modelGroup = new ButtonGroup ();
5218: mdlMenu = Multilingual.mlnText (
5219: ComponentFactory.createMenu (
5220: "Change the model and reset",
5221: mdlShodaiMenuItem = ComponentFactory.createRadioButtonMenuItem (
5222: modelGroup,
5223: specifiedModel == Model.SHODAI,
5224: "X68000 (10MHz)",
5225: listener),
5226: mdlACEMenuItem = ComponentFactory.createRadioButtonMenuItem (
5227: modelGroup,
5228: specifiedModel == Model.ACE,
5229: "X68000 ACE (10MHz)",
5230: listener),
5231: mdlEXPERTMenuItem = ComponentFactory.createRadioButtonMenuItem (
5232: modelGroup,
5233: specifiedModel == Model.EXPERT,
5234: "X68000 EXPERT (10MHz)",
5235: listener),
5236: mdlPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
5237: modelGroup,
5238: specifiedModel == Model.PRO && specifiedAccelerator == 0,
5239: "X68000 PRO (10MHz)",
5240: listener),
5241: mdlSUPERMenuItem = ComponentFactory.createRadioButtonMenuItem (
5242: modelGroup,
5243: specifiedModel == Model.SUPER,
5244: "X68000 SUPER (10MHz)",
5245: listener),
5246: mdlXVIMenuItem = ComponentFactory.createRadioButtonMenuItem (
5247: modelGroup,
5248: specifiedModel == Model.XVI && specifiedAccelerator == 0,
5249: "X68000 XVI (16.7MHz)",
5250: listener),
5251: mdlCompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
5252: modelGroup,
5253: specifiedModel == Model.COMPACT && specifiedAccelerator == 0,
5254: "X68000 Compact (16.7MHz)",
5255: listener),
5256:
5257: ComponentFactory.createHorizontalSeparator (),
5258:
5259: mdlX68030MenuItem = ComponentFactory.createRadioButtonMenuItem (
5260: modelGroup,
5261: specifiedModel == Model.X68030 && specifiedAccelerator == 0,
5262: "X68030 (25MHz)",
5263: listener),
5264: mdl030CompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
5265: modelGroup,
5266: specifiedModel == Model.X68030COMPACT,
5267: "X68030 Compact (25MHz)",
5268: listener),
5269:
5270: ComponentFactory.createHorizontalSeparator (),
5271:
5272: mdlHybridMenuItem = ComponentFactory.createRadioButtonMenuItem (
5273: modelGroup,
5274: specifiedModel == Model.COMPACT && specifiedAccelerator == ACCELERATOR_HYBRID,
5275: "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)",
5276: listener),
5277: mdlXellent30MenuItem = ComponentFactory.createRadioButtonMenuItem (
5278: modelGroup,
5279: specifiedModel == Model.XVI && specifiedAccelerator == ACCELERATOR_XELLENT30,
5280: "Xellent30 (33.3MHz)",
5281: listener),
5282: mdl060turboMenuItem = ComponentFactory.createRadioButtonMenuItem (
5283: modelGroup,
5284: specifiedModel == Model.X68030 && specifiedAccelerator == ACCELERATOR_060TURBO,
5285: "060turbo (" + MHZ_060TURBO_STRING + "MHz)",
5286: listener),
5287: mdl060turboPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
5288: modelGroup,
5289: specifiedModel == Model.PRO && specifiedAccelerator == ACCELERATOR_060TURBOPRO,
5290: "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)",
5291: listener),
5292:
5293: ComponentFactory.createHorizontalSeparator (),
5294:
5295: mdlMC68010MenuItem = ComponentFactory.createCheckBoxMenuItem (
5296: mpu010,
5297: "MC68010",
5298: listener)
5299: ),
5300: "ja", "機種を変更してリセット");
5301:
5302:
5303: ActionListener copro0Listener = new ActionListener () {
5304: @Override public void actionPerformed (ActionEvent ae) {
5305: String command = ae.getActionCommand ();
5306: switch (command) {
5307: case "Not installed":
5308: specifiedCopro0 = (8 & specifiedCopro0) | 0;
5309: break;
5310: case "MC68881":
5311: specifiedCopro0 = (8 & specifiedCopro0) | 1;
5312: break;
5313: case "MC68882":
5314: specifiedCopro0 = (8 & specifiedCopro0) | 2;
5315: break;
5316: case "Full specification":
5317: specifiedCopro0 = (8 & specifiedCopro0) | 7;
5318: break;
5319: case "Extended precision (19 digits)":
5320: specifiedCopro0 = 0 | (7 & specifiedCopro0);
5321: break;
5322: case "Triple precision (24 digits)":
5323: specifiedCopro0 = 8 | (7 & specifiedCopro0);
5324: break;
5325: default:
5326: System.out.println ("unknown action command " + command);
5327: }
5328: }
5329: };
5330:
5331: ActionListener copro1Listener = new ActionListener () {
5332: @Override public void actionPerformed (ActionEvent ae) {
5333: String command = ae.getActionCommand ();
5334: switch (command) {
5335: case "Not installed":
5336: specifiedCopro1 = (8 & specifiedCopro1) | 0;
5337: break;
5338: case "MC68881":
5339: specifiedCopro1 = (8 & specifiedCopro1) | 1;
5340: break;
5341: case "MC68882":
5342: specifiedCopro1 = (8 & specifiedCopro1) | 2;
5343: break;
5344: case "Full specification":
5345: specifiedCopro1 = (8 & specifiedCopro1) | 7;
5346: break;
5347: case "Extended precision (19 digits)":
5348: specifiedCopro1 = 0 | (7 & specifiedCopro1);
5349: break;
5350: case "Triple precision (24 digits)":
5351: specifiedCopro1 = 8 | (7 & specifiedCopro1);
5352: break;
5353: default:
5354: System.out.println ("unknown action command " + command);
5355: }
5356: }
5357: };
5358:
5359: ActionListener copro2Listener = new ActionListener () {
5360: @Override public void actionPerformed (ActionEvent ae) {
5361: String command = ae.getActionCommand ();
5362: switch (command) {
5363: case "Not installed":
5364: specifiedCopro2 = (8 & specifiedCopro2) | 0;
5365: break;
5366: case "MC68881":
5367: specifiedCopro2 = (8 & specifiedCopro2) | 1;
5368: break;
5369: case "MC68882":
5370: specifiedCopro2 = (8 & specifiedCopro2) | 2;
5371: break;
5372: case "Full specification":
5373: specifiedCopro2 = (8 & specifiedCopro2) | 7;
5374: break;
5375: case "Extended precision (19 digits)":
5376: specifiedCopro2 = 0 | (7 & specifiedCopro2);
5377: break;
5378: case "Triple precision (24 digits)":
5379: specifiedCopro2 = 8 | (7 & specifiedCopro2);
5380: break;
5381: default:
5382: System.out.println ("unknown action command " + command);
5383: }
5384: }
5385: };
5386:
5387: ActionListener onchipFPUListener = new ActionListener () {
5388: @Override public void actionPerformed (ActionEvent ae) {
5389: String command = ae.getActionCommand ();
5390: switch (command) {
5391: case "Not installed":
5392: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 0;
5393: break;
5394: case "MC68060":
5395: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 6;
5396: break;
5397: case "Full specification":
5398: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
5399: break;
5400: case "Extended precision (19 digits)":
5401: specifiedOnchipFPU = 0 | (7 & specifiedOnchipFPU);
5402: break;
5403: case "Triple precision (24 digits)":
5404: specifiedOnchipFPU = 8 | (7 & specifiedOnchipFPU);
5405: break;
5406: default:
5407: System.out.println ("unknown action command " + command);
5408: }
5409: }
5410: };
5411:
5412: ButtonGroup copro00Group = new ButtonGroup ();
5413: ButtonGroup copro01Group = new ButtonGroup ();
5414: ButtonGroup copro10Group = new ButtonGroup ();
5415: ButtonGroup copro11Group = new ButtonGroup ();
5416: ButtonGroup copro20Group = new ButtonGroup ();
5417: ButtonGroup copro21Group = new ButtonGroup ();
5418: ButtonGroup onchipFPU0Group = new ButtonGroup ();
5419: ButtonGroup onchipFPU1Group = new ButtonGroup ();
5420:
5421: coproFPUMenu = Multilingual.mlnText (
5422: ComponentFactory.createMenu (
5423: "Coprocessor and on-chip FPU",
5424:
5425: Multilingual.mlnText (
5426: ComponentFactory.createMenu (
5427: "Motherboard coprocessor",
5428: Multilingual.mlnText (
5429: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 0, "Not installed", copro0Listener),
5430: "ja", "なし"),
5431: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 1, "MC68881", copro0Listener),
5432: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 2, "MC68882", copro0Listener),
5433: Multilingual.mlnText (
5434: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 7, "Full specification", copro0Listener),
5435: "ja", "フルスペック"),
5436: ComponentFactory.createHorizontalSeparator (),
5437: Multilingual.mlnText (
5438: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) == 0, "Extended precision (19 digits)", copro0Listener),
5439: "ja", "拡張精度 (19 桁)"),
5440: Multilingual.mlnText (
5441: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) != 0, "Triple precision (24 digits)", copro0Listener),
5442: "ja", "三倍精度 (24 桁)")),
5443: "ja", "マザーボードコプロセッサ"),
5444:
5445: Multilingual.mlnText (
5446: ComponentFactory.createMenu (
5447: "Extension coprocessor #1",
5448: Multilingual.mlnText (
5449: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 0, "Not installed", copro1Listener),
5450: "ja", "なし"),
5451: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 1, "MC68881", copro1Listener),
5452: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 2, "MC68882", copro1Listener),
5453: Multilingual.mlnText (
5454: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 7, "Full specification", copro1Listener),
5455: "ja", "フルスペック"),
5456: ComponentFactory.createHorizontalSeparator (),
5457: Multilingual.mlnText (
5458: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) == 0, "Extended precision (19 digits)", copro1Listener),
5459: "ja", "拡張精度 (19 桁)"),
5460: Multilingual.mlnText (
5461: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) != 0, "Triple precision (24 digits)", copro1Listener),
5462: "ja", "三倍精度 (24 桁)")),
5463: "ja", "拡張コプロセッサ #1"),
5464:
5465: Multilingual.mlnText (
5466: ComponentFactory.createMenu (
5467: "Extension coprocessor #2",
5468: Multilingual.mlnText (
5469: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 0, "Not installed", copro2Listener),
5470: "ja", "なし"),
5471: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 1, "MC68881", copro2Listener),
5472: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 2, "MC68882", copro2Listener),
5473: Multilingual.mlnText (
5474: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 7, "Full specification", copro2Listener),
5475: "ja", "フルスペック"),
5476: ComponentFactory.createHorizontalSeparator (),
5477: Multilingual.mlnText (
5478: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) == 0, "Extended precision (19 digits)", copro2Listener),
5479: "ja", "拡張精度 (19 桁)"),
5480: Multilingual.mlnText (
5481: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) != 0, "Triple precision (24 digits)", copro2Listener),
5482: "ja", "三倍精度 (24 桁)")),
5483: "ja", "拡張コプロセッサ #2"),
5484:
5485: Multilingual.mlnText (
5486: ComponentFactory.createMenu (
5487: "On-chip FPU",
5488: Multilingual.mlnText (
5489: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 0, "Not installed", onchipFPUListener),
5490: "ja", "なし"),
5491: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 6, "MC68060", onchipFPUListener),
5492: Multilingual.mlnText (
5493: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 7, "Full specification", onchipFPUListener),
5494: "ja", "フルスペック"),
5495: ComponentFactory.createHorizontalSeparator (),
5496: Multilingual.mlnText (
5497: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) == 0, "Extended precision (19 digits)", onchipFPUListener),
5498: "ja", "拡張精度 (19 桁)"),
5499: Multilingual.mlnText (
5500: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) != 0, "Triple precision (24 digits)", onchipFPUListener),
5501: "ja", "三倍精度 (24 桁)")),
5502: "ja", "オンチップ FPU")),
5503: "ja", "コプロセッサとオンチップ FPU");
5504:
5505: }
5506:
5507: public static void mdlRequestModel (Model model, int accelerator) {
5508: specifiedModel = model;
5509: specifiedAccelerator = accelerator;
5510:
5511: specifiedIsSecond = false;
5512: specifiedFirstMPU = specifiedModel.getMPU ();
5513: specifiedSecondMPU = Model.MPU_MC68EC030;
5514: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
5515: specifiedFirstClock = specifiedModel.getClock ();
5516: specifiedSecondClock = specifiedFirstClock * 2.0;
5517: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5518:
5519: switch (accelerator) {
5520: case ACCELERATOR_HYBRID:
5521: specifiedFirstClock = MHZ_HYBRID_VALUE;
5522: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5523: break;
5524: case ACCELERATOR_XELLENT30:
5525: break;
5526: case ACCELERATOR_060TURBO:
5527: case ACCELERATOR_060TURBOPRO:
5528: specifiedFirstMPU = Model.MPU_MC68060;
5529: specifiedFirstClock = MHZ_060TURBO_VALUE;
5530: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5531: }
5532:
5533: mpuUtilOn = false;
5534: mpuArbFreqOn = false;
5535: mpuSetCurrentClock (specifiedClock);
5536:
5537: if (accelerator == ACCELERATOR_HYBRID) {
5538: mdlHybridMenuItem.setSelected (true);
5539: } else if (accelerator == ACCELERATOR_XELLENT30) {
5540: mdlXellent30MenuItem.setSelected (true);
5541: } else if (accelerator == ACCELERATOR_060TURBO) {
5542: mdl060turboMenuItem.setSelected (true);
5543: } else if (accelerator == ACCELERATOR_060TURBOPRO) {
5544: mdl060turboPROMenuItem.setSelected (true);
5545: } else if (specifiedModel == Model.SHODAI) {
5546: mdlShodaiMenuItem.setSelected (true);
5547: } else if (specifiedModel == Model.ACE) {
5548: mdlACEMenuItem.setSelected (true);
5549: } else if (specifiedModel == Model.EXPERT) {
5550: mdlEXPERTMenuItem.setSelected (true);
5551: } else if (specifiedModel == Model.PRO) {
5552: mdlPROMenuItem.setSelected (true);
5553: } else if (specifiedModel == Model.SUPER) {
5554: mdlSUPERMenuItem.setSelected (true);
5555: } else if (specifiedModel == Model.XVI) {
5556: mdlXVIMenuItem.setSelected (true);
5557: } else if (specifiedModel == Model.COMPACT) {
5558: mdlCompactMenuItem.setSelected (true);
5559: } else if (specifiedModel == Model.X68030) {
5560: mdlX68030MenuItem.setSelected (true);
5561: } else if (specifiedModel == Model.X68030COMPACT) {
5562: mdl030CompactMenuItem.setSelected (true);
5563: }
5564:
5565:
5566: HDC.hdcSASIMenuItem.setSelected (!currentModel.isSCSI ());
5567: SPC.spcSCSIINMenuItem.setSelected (currentModel.isSCSI ());
5568: }
5569:
5570:
5571:
5572:
5573:
5574:
5575:
5576: public static final boolean MPU_INLINE_EXCEPTION = true;
5577: public static final boolean MPU_COMPOUND_POSTINCREMENT = false;
5578:
5579: public static final boolean MPU_SWITCH_MISC_OPCODE = false;
5580: public static final boolean MPU_SWITCH_BCC_CONDITION = false;
5581: public static final boolean MPU_SWITCH_BCC_OFFSET = false;
5582: public static final boolean MPU_SWITCH_SCC_CONDITION = true;
5583:
5584: public static final boolean MPU_OMIT_EXTRA_READ = false;
5585: public static final boolean MPU_OMIT_OFFSET_READ = false;
5586:
5587:
5588:
5589:
5590: public static final long FAR_FUTURE = 0x7fffffffffffffffL;
5591:
5592:
5593:
5594:
5595:
5596:
5597:
5598:
5599: public static final int REG_SR_T1 = 0b10000000_00000000;
5600: public static final int REG_SR_T0 = 0b01000000_00000000;
5601:
5602:
5603:
5604:
5605:
5606:
5607: public static final int REG_SR_S = 0b00100000_00000000;
5608: public static final int REG_SR_M = 0b00010000_00000000;
5609:
5610: public static final int REG_SR_I = 0b00000111_00000000;
5611:
5612:
5613: public static final int REG_CCR_X = 0b00000000_00010000;
5614: public static final int REG_CCR_N = 0b00000000_00001000;
5615: public static final int REG_CCR_Z = 0b00000000_00000100;
5616: public static final int REG_CCR_V = 0b00000000_00000010;
5617: public static final int REG_CCR_C = 0b00000000_00000001;
5618: public static final int REG_CCR_MASK = REG_CCR_X | REG_CCR_N | REG_CCR_Z | REG_CCR_V | REG_CCR_C;
5619:
5620: public static char[] REG_CCRXMAP = "00000000000000001111111111111111".toCharArray ();
5621: public static char[] REG_CCRNMAP = "00000000111111110000000011111111".toCharArray ();
5622: public static char[] REG_CCRZMAP = "00001111000011110000111100001111".toCharArray ();
5623: public static char[] REG_CCRVMAP = "00110011001100110011001100110011".toCharArray ();
5624: public static char[] REG_CCRCMAP = "01010101010101010101010101010101".toCharArray ();
5625:
5626:
5627:
5628: public static final int MPU_IOI_INTERRUPT_LEVEL = 1;
5629: public static final int MPU_EB2_INTERRUPT_LEVEL = 2;
5630: public static final int MPU_DMA_INTERRUPT_LEVEL = 3;
5631: public static final int MPU_SCC_INTERRUPT_LEVEL = 5;
5632: public static final int MPU_MFP_INTERRUPT_LEVEL = 6;
5633: public static final int MPU_SYS_INTERRUPT_LEVEL = 7;
5634: public static final int MPU_IOI_INTERRUPT_MASK = 0x80 >> MPU_IOI_INTERRUPT_LEVEL;
5635: public static final int MPU_EB2_INTERRUPT_MASK = 0x80 >> MPU_EB2_INTERRUPT_LEVEL;
5636: public static final int MPU_DMA_INTERRUPT_MASK = 0x80 >> MPU_DMA_INTERRUPT_LEVEL;
5637: public static final int MPU_SCC_INTERRUPT_MASK = 0x80 >> MPU_SCC_INTERRUPT_LEVEL;
5638: public static final int MPU_MFP_INTERRUPT_MASK = 0x80 >> MPU_MFP_INTERRUPT_LEVEL;
5639: public static final int MPU_SYS_INTERRUPT_MASK = 0x80 >> MPU_SYS_INTERRUPT_LEVEL;
5640:
5641: public static final boolean MPU_INTERRUPT_SWITCH = true;
5642:
5643:
5644: public static final boolean T = true;
5645: public static final boolean F = false;
5646:
5647: public static final int CCCC_T = 0b0000;
5648: public static final int CCCC_F = 0b0001;
5649: public static final int CCCC_HI = 0b0010;
5650: public static final int CCCC_LS = 0b0011;
5651: public static final int CCCC_CC = 0b0100;
5652: public static final int CCCC_CS = 0b0101;
5653: public static final int CCCC_NE = 0b0110;
5654: public static final int CCCC_EQ = 0b0111;
5655: public static final int CCCC_VC = 0b1000;
5656: public static final int CCCC_VS = 0b1001;
5657: public static final int CCCC_PL = 0b1010;
5658: public static final int CCCC_MI = 0b1011;
5659: public static final int CCCC_GE = 0b1100;
5660: public static final int CCCC_LT = 0b1101;
5661: public static final int CCCC_GT = 0b1110;
5662: public static final int CCCC_LE = 0b1111;
5663:
5664:
5665:
5666:
5667:
5668:
5669: public static final boolean[] BCCMAP = {
5670: 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,
5671: 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,
5672: 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,
5673: 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,
5674: 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,
5675: 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,
5676: 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,
5677: 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,
5678: 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,
5679: 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,
5680: 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,
5681: 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,
5682: 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,
5683: 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,
5684: 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,
5685: 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,
5686: };
5687:
5688:
5689: public static final char[] MPU_CCCMAP = (
5690: "11111111111111111111111111111111" +
5691: "00000000000000000000000000000000" +
5692: "10100000101000001010000010100000" +
5693: "01011111010111110101111101011111" +
5694: "10101010101010101010101010101010" +
5695: "01010101010101010101010101010101" +
5696: "11110000111100001111000011110000" +
5697: "00001111000011110000111100001111" +
5698: "11001100110011001100110011001100" +
5699: "00110011001100110011001100110011" +
5700: "11111111000000001111111100000000" +
5701: "00000000111111110000000011111111" +
5702: "11001100001100111100110000110011" +
5703: "00110011110011000011001111001100" +
5704: "11000000001100001100000000110000" +
5705: "00111111110011110011111111001111").toCharArray ();
5706:
5707:
5708:
5709: public static final int MPU_CC_T = 0b11111111111111111111111111111111;
5710: public static final int MPU_CC_F = 0b00000000000000000000000000000000;
5711: public static final int MPU_CC_HI = 0b10100000101000001010000010100000;
5712: public static final int MPU_CC_LS = 0b01011111010111110101111101011111;
5713: public static final int MPU_CC_HS = 0b10101010101010101010101010101010;
5714: public static final int MPU_CC_LO = 0b01010101010101010101010101010101;
5715: public static final int MPU_CC_NE = 0b11110000111100001111000011110000;
5716: public static final int MPU_CC_EQ = 0b00001111000011110000111100001111;
5717: public static final int MPU_CC_VC = 0b11001100110011001100110011001100;
5718: public static final int MPU_CC_VS = 0b00110011001100110011001100110011;
5719: public static final int MPU_CC_PL = 0b11111111000000001111111100000000;
5720: public static final int MPU_CC_MI = 0b00000000111111110000000011111111;
5721: public static final int MPU_CC_GE = 0b11001100001100111100110000110011;
5722: public static final int MPU_CC_LT = 0b00110011110011000011001111001100;
5723: public static final int MPU_CC_GT = 0b11000000001100001100000000110000;
5724: public static final int MPU_CC_LE = 0b00111111110011110011111111001111;
5725:
5726:
5727:
5728:
5729:
5730:
5731:
5732:
5733:
5734:
5735:
5736:
5737:
5738:
5739:
5740:
5741:
5742:
5743:
5744:
5745:
5746:
5747:
5748:
5749:
5750:
5751:
5752:
5753:
5754:
5755:
5756:
5757:
5758:
5759:
5760:
5761:
5762:
5763:
5764:
5765:
5766:
5767:
5768:
5769:
5770:
5771:
5772:
5773:
5774: 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);
5775:
5776:
5777:
5778: public static final int[] MPU_BITREV_TABLE_0 = new int[2048];
5779: public static final int[] MPU_BITREV_TABLE_1 = new int[2048];
5780: public static final int[] MPU_BITREV_TABLE_2 = new int[2048];
5781: static {
5782: for (int i = 0; i < 2048; i++) {
5783: MPU_BITREV_TABLE_2[i] = (MPU_BITREV_TABLE_1[i] = (MPU_BITREV_TABLE_0[i] = Integer.reverse (i)) >>> 11) >>> 11;
5784: }
5785: }
5786:
5787:
5788:
5789: public static final int EA_DR = 0b000_000;
5790: public static final int EA_AR = 0b001_000;
5791: public static final int EA_MM = 0b010_000;
5792: public static final int EA_MP = 0b011_000;
5793: public static final int EA_MN = 0b100_000;
5794: public static final int EA_MW = 0b101_000;
5795: public static final int EA_MX = 0b110_000;
5796: public static final int EA_ZW = 0b111_000;
5797: public static final int EA_ZL = 0b111_001;
5798: public static final int EA_PW = 0b111_010;
5799: public static final int EA_PX = 0b111_011;
5800: public static final int EA_IM = 0b111_100;
5801: public static final int MMM_DR = EA_DR >> 3;
5802: public static final int MMM_AR = EA_AR >> 3;
5803: public static final int MMM_MM = EA_MM >> 3;
5804: public static final int MMM_MP = EA_MP >> 3;
5805: public static final int MMM_MN = EA_MN >> 3;
5806: public static final int MMM_MW = EA_MW >> 3;
5807: public static final int MMM_MX = EA_MX >> 3;
5808: public static final long EAM_DR = 0xff00000000000000L >>> EA_DR;
5809: public static final long EAM_AR = 0xff00000000000000L >>> EA_AR;
5810: public static final long EAM_MM = 0xff00000000000000L >>> EA_MM;
5811: public static final long EAM_MP = 0xff00000000000000L >>> EA_MP;
5812: public static final long EAM_MN = 0xff00000000000000L >>> EA_MN;
5813: public static final long EAM_MW = 0xff00000000000000L >>> EA_MW;
5814: public static final long EAM_MX = 0xff00000000000000L >>> EA_MX;
5815: public static final long EAM_ZW = 0x8000000000000000L >>> EA_ZW;
5816: public static final long EAM_ZL = 0x8000000000000000L >>> EA_ZL;
5817: public static final long EAM_PW = 0x8000000000000000L >>> EA_PW;
5818: public static final long EAM_PX = 0x8000000000000000L >>> EA_PX;
5819: public static final long EAM_IM = 0x8000000000000000L >>> EA_IM;
5820: 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;
5821: public static final long EAM_ALT = EAM_DR|EAM_AR|EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5822: 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;
5823: 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 ;
5824: public static final long EAM_DLT = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5825: public static final long EAM_DCN = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5826: public static final long EAM_DCL = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5827: 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;
5828: public static final long EAM_MEM = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5829: public static final long EAM_MLT = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5830: public static final long EAM_RDL = EAM_MM|EAM_MP |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5831: public static final long EAM_WTL = EAM_MM |EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5832: public static final long EAM_CNT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5833: public static final long EAM_CLT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5834:
5835:
5836:
5837:
5838:
5839:
5840:
5841:
5842:
5843:
5844:
5845: public static final int[] regRn = new int[16 + 1];
5846:
5847:
5848: public static int regPC;
5849: public static int regPC0;
5850:
5851:
5852: public static int regOC;
5853:
5854:
5855: public static int regSRT1;
5856: public static int regSRT0;
5857: public static int mpuTraceFlag;
5858: public static int regSRS;
5859: public static int regSRM;
5860: public static int regSRI;
5861:
5862:
5863: public static int regCCR;
5864:
5865:
5866:
5867:
5868:
5869:
5870:
5871:
5872:
5873:
5874:
5875:
5876:
5877:
5878:
5879:
5880:
5881:
5882:
5883:
5884: public static int mpuIMR;
5885:
5886:
5887:
5888:
5889:
5890:
5891: public static int mpuIRR;
5892: public static int mpuDIRR;
5893:
5894:
5895:
5896:
5897:
5898:
5899:
5900:
5901: public static int mpuISR;
5902:
5903:
5904: public static int mpuSFC;
5905: public static int mpuDFC;
5906: public static int mpuCACR;
5907:
5908:
5909:
5910:
5911:
5912: public static int mpuBUSCR;
5913: public static int mpuUSP;
5914: public static int mpuVBR;
5915: public static int mpuCAAR;
5916: public static int mpuMSP;
5917: public static int mpuISP;
5918:
5919:
5920:
5921: public static int mpuPCR;
5922:
5923:
5924:
5925: public static final int MPU_060_REV = 7;
5926:
5927:
5928:
5929: public static long mpuClockTime;
5930: public static long mpuClockLimit;
5931: public static double mpuClockMHz;
5932: public static double mpuCurrentMHz;
5933: public static int mpuCycleCount;
5934: public static long mpuCycleUnit;
5935: public static long mpuModifiedUnit;
5936: public static long dmaCycleUnit;
5937:
5938:
5939:
5940: public static TimerTask mpuTask;
5941:
5942:
5943: public static int mpuBootDevice;
5944: public static int mpuROMBootHandle;
5945: public static int mpuSavedBootDevice;
5946: public static int mpuSavedROMBootHandle;
5947:
5948:
5949: public static boolean mpuIgnoreAddressError;
5950:
5951:
5952: public static int mpuROMWaitCycles;
5953: public static int mpuRAMWaitCycles;
5954: public static boolean mpuCacheOn;
5955: public static final class WaitTime {
5956: public long ram;
5957: public long gvram;
5958: public long tvram;
5959: public long crtc;
5960: public long palet;
5961: public long vicon;
5962: public long dmac;
5963: public long mfp;
5964: public long rtc;
5965: public long prnport;
5966: public long sysport;
5967: public long opm;
5968: public long adpcm;
5969: public long fdc;
5970: public long fdd;
5971: public long hdc;
5972: public long scc;
5973: public long ppi;
5974: public long ioi;
5975: public long sprc;
5976: public long sram;
5977: public long rom;
5978: public long ramlong;
5979: public long romlong;
5980: public boolean isDma;
5981: public WaitTime (boolean isDma) {
5982: this.isDma = isDma;
5983: }
5984: }
5985: public static final WaitTime mpuNoWaitTime = new WaitTime (false);
5986: public static final WaitTime dmaNoWaitTime = new WaitTime (true);
5987: public static final WaitTime mpuWaitTime = new WaitTime (false);
5988: public static final WaitTime dmaWaitTime = new WaitTime (true);
5989: public static boolean busWaitCyclesRequest;
5990: public static boolean busWaitCycles;
5991: public static WaitTime busWaitTime;
5992:
5993:
5994: public static boolean mpuArbFreqOn;
5995: public static int mpuArbFreqMHz;
5996: public static SpinnerNumberModel mpuArbFreqModel;
5997: public static JSpinner mpuArbFreqSpinner;
5998: public static JRadioButtonMenuItem mpuArbFreqRadioButtonMenuItem;
5999:
6000:
6001: public static boolean mpuUtilOn;
6002: public static int mpuUtilRatio;
6003: public static SpinnerNumberModel mpuUtilModel;
6004: public static JSpinner mpuUtilSpinner;
6005: public static JRadioButtonMenuItem mpuUtilRadioButtonMenuItem;
6006:
6007:
6008: public static final int MPU_ADJUSTMENT_INTERVAL = 100;
6009: public static int mpuAdjustmentCounter;
6010: public static long mpuTotalNano;
6011: public static long mpuLastNano;
6012: public static double mpuCoreNano1;
6013: public static double mpuCoreNano2;
6014:
6015:
6016: public static JMenu mpuMenu;
6017: public static JMenuItem mpuResetMenuItem;
6018: public static JMenuItem mpuOpt1ResetMenuItem;
6019: public static JRadioButtonMenuItem mpuClock10MenuItem;
6020: public static JRadioButtonMenuItem mpuClock16MenuItem;
6021: public static JRadioButtonMenuItem mpuClock25MenuItem;
6022: public static JRadioButtonMenuItem mpuClock33MenuItem;
6023: public static JRadioButtonMenuItem mpuClock50MenuItem;
6024: public static JRadioButtonMenuItem mpuClock66MenuItem;
6025: public static JRadioButtonMenuItem mpuClock75MenuItem;
6026: public static JRadioButtonMenuItem mpuClock100MenuItem;
6027:
6028:
6029: public static ActionListener mpuDebugActionListener;
6030: public static ArrayList<AbstractButton> mpuButtonsRunning;
6031: public static ArrayList<AbstractButton> mpuButtonsStopped;
6032: public static ArrayList<JCheckBox> mpuOriIllegalCheckBoxList;
6033: public static ArrayList<JCheckBox> mpuStopOnErrorCheckBoxList;
6034: public static ArrayList<JCheckBox> mpuStopAtStartCheckBoxList;
6035:
6036: public static int mpuAdvanceCount;
6037: public static int mpuStepCount;
6038: public static boolean mpuContinue;
6039: public static int mpuUntilReturnSRS;
6040: public static int mpuUntilReturnRP;
6041: public static int mpuUntilReturnPC0;
6042: public static int mpuUntilReturnSP;
6043:
6044:
6045:
6046:
6047:
6048:
6049:
6050:
6051:
6052:
6053:
6054:
6055:
6056:
6057:
6058:
6059:
6060:
6061:
6062:
6063:
6064:
6065:
6066:
6067:
6068:
6069:
6070:
6071:
6072:
6073:
6074:
6075:
6076:
6077:
6078:
6079:
6080:
6081:
6082:
6083:
6084:
6085:
6086:
6087:
6088:
6089:
6090:
6091:
6092:
6093:
6094:
6095:
6096:
6097:
6098:
6099:
6100:
6101:
6102:
6103:
6104:
6105:
6106:
6107:
6108:
6109:
6110:
6111:
6112:
6113:
6114:
6115:
6116: public static final boolean MPU_SXMENU = false;
6117:
6118:
6119:
6120: public static void mpuInit () {
6121:
6122: mpuIgnoreAddressError = false;
6123:
6124:
6125:
6126: fpuInit ();
6127:
6128: mpuClockTime = 0L;
6129: mpuClockLimit = 0L;
6130: mpuCycleCount = 0;
6131:
6132: mpuTask = null;
6133:
6134: M68kException.m6eSignal = new M68kException ();
6135: M68kException.m6eNumber = 0;
6136: M68kException.m6eAddress = 0;
6137: M68kException.m6eDirection = MPU_WR_WRITE;
6138: M68kException.m6eSize = MPU_SS_BYTE;
6139:
6140: mpuBootDevice = -1;
6141: mpuROMBootHandle = -1;
6142: mpuSavedBootDevice = -1;
6143: mpuSavedROMBootHandle = -1;
6144:
6145:
6146:
6147:
6148:
6149:
6150:
6151:
6152:
6153:
6154:
6155:
6156:
6157:
6158:
6159: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
6160: mpuTotalNano = 0L;
6161: mpuLastNano = System.nanoTime ();
6162: mpuCoreNano1 = mpuCoreNano2 = 0.5 * 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
6163:
6164: mpuButtonsRunning = new ArrayList<AbstractButton> ();
6165: mpuButtonsStopped = new ArrayList<AbstractButton> ();
6166:
6167: mpuOriIllegalCheckBoxList = new ArrayList<JCheckBox> ();
6168: mpuStopOnErrorCheckBoxList = new ArrayList<JCheckBox> ();
6169: mpuStopAtStartCheckBoxList = new ArrayList<JCheckBox> ();
6170:
6171: mpuAdvanceCount = 0;
6172: mpuStepCount = 0;
6173: mpuContinue = false;
6174: mpuUntilReturnSRS = 0;
6175: mpuUntilReturnRP = 0;
6176: mpuUntilReturnPC0 = 0;
6177: mpuUntilReturnSP = 0;
6178:
6179:
6180: mpuDebugActionListener = new ActionListener () {
6181: @Override public void actionPerformed (ActionEvent ae) {
6182: Object source = ae.getSource ();
6183: switch (ae.getActionCommand ()) {
6184: case "Stop":
6185: if (RootPointerList.RTL_ON) {
6186: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6187: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6188: mpuStop (null);
6189: }
6190: } else {
6191: mpuStop (null);
6192: }
6193: break;
6194: case "Trace":
6195: mpuAdvance (1);
6196: break;
6197: case "Trace 10 times":
6198: mpuAdvance (10);
6199: break;
6200: case "Trace 100 times":
6201: mpuAdvance (100);
6202: break;
6203: case "Step":
6204: mpuStep (1);
6205: break;
6206: case "Step 10 times":
6207: mpuStep (10);
6208: break;
6209: case "Step 100 times":
6210: mpuStep (100);
6211: break;
6212: case "Step until return":
6213: mpuStepUntilReturn ();
6214: break;
6215: case "Run":
6216: mpuStart ();
6217: break;
6218:
6219: case "Consider ORI.B #$00,D0 as an illegal instruction" :
6220: if (DBG_ORI_BYTE_ZERO_D0) {
6221: dbgOriByteZeroD0 = ((JCheckBox) source).isSelected ();
6222: for (JCheckBox checkBox : mpuOriIllegalCheckBoxList) {
6223: if (checkBox.isSelected () != dbgOriByteZeroD0) {
6224: checkBox.setSelected (dbgOriByteZeroD0);
6225: }
6226: }
6227: }
6228: break;
6229: case "Stop on error":
6230: dbgStopOnError = ((JCheckBox) source).isSelected ();
6231: for (JCheckBox checkBox : mpuStopOnErrorCheckBoxList) {
6232: if (checkBox.isSelected () != dbgStopOnError) {
6233: checkBox.setSelected (dbgStopOnError);
6234: }
6235: }
6236: break;
6237: case "Stop at execution start position":
6238: dbgStopAtStart = ((JCheckBox) source).isSelected ();
6239: for (JCheckBox checkBox : mpuStopAtStartCheckBoxList) {
6240: if (checkBox.isSelected () != dbgStopAtStart) {
6241: checkBox.setSelected (dbgStopAtStart);
6242: }
6243: }
6244: break;
6245: }
6246: }
6247: };
6248:
6249: }
6250:
6251:
6252:
6253: public static JCheckBox mpuMakeOriIllegalCheckBox () {
6254: JCheckBox checkBox = Multilingual.mlnToolTipText (
6255: ComponentFactory.createIconCheckBox (
6256: DBG_ORI_BYTE_ZERO_D0 ? dbgOriByteZeroD0 : null,
6257: LnF.LNF_ORI_BYTE_ZERO_D0_IMAGE,
6258: LnF.LNF_ORI_BYTE_ZERO_D0_SELECTED_IMAGE,
6259: "Consider ORI.B #$00,D0 as an illegal instruction", mpuDebugActionListener),
6260: "ja", "ORI.B #$00,D0 を不当命令とみなす");
6261: mpuOriIllegalCheckBoxList.add (checkBox);
6262: return checkBox;
6263: }
6264:
6265:
6266:
6267: public static JCheckBox mpuMakeStopOnErrorCheckBox () {
6268: JCheckBox checkBox = Multilingual.mlnToolTipText (
6269: ComponentFactory.createIconCheckBox (
6270: dbgStopOnError,
6271: LnF.LNF_STOP_ON_ERROR_IMAGE,
6272: LnF.LNF_STOP_ON_ERROR_SELECTED_IMAGE,
6273: "Stop on error", mpuDebugActionListener),
6274: "ja", "エラーで停止する");
6275: mpuStopOnErrorCheckBoxList.add (checkBox);
6276: return checkBox;
6277: }
6278:
6279:
6280:
6281: public static JCheckBox mpuMakeStopAtStartCheckBox () {
6282: JCheckBox checkBox = Multilingual.mlnToolTipText (
6283: ComponentFactory.createIconCheckBox (
6284: dbgStopAtStart,
6285: LnF.LNF_STOP_AT_START_IMAGE,
6286: LnF.LNF_STOP_AT_START_SELECTED_IMAGE,
6287: "Stop at execution start position", mpuDebugActionListener),
6288: "ja", "実行開始位置で停止する");
6289: mpuStopAtStartCheckBoxList.add (checkBox);
6290: return checkBox;
6291: }
6292:
6293:
6294: public static void mpuMakeMenu () {
6295:
6296: ButtonGroup unitGroup = new ButtonGroup ();
6297: ActionListener listener = new ActionListener () {
6298: @Override public void actionPerformed (ActionEvent ae) {
6299: Object source = ae.getSource ();
6300: switch (ae.getActionCommand ()) {
6301: case "Reset":
6302: mpuReset (-1, -1);
6303: break;
6304: case "Hold down OPT.1 and reset":
6305: mpuReset (0, -1);
6306: break;
6307: case "Interrupt":
6308: sysInterrupt ();
6309: break;
6310: case "10MHz":
6311: mpuArbFreqOn = false;
6312: mpuUtilOn = false;
6313: mpuSetCurrentClock (10.0);
6314: break;
6315: case "16.7MHz":
6316: mpuArbFreqOn = false;
6317: mpuUtilOn = false;
6318: mpuSetCurrentClock (50.0 / 3.0);
6319: break;
6320: case "25MHz":
6321: mpuArbFreqOn = false;
6322: mpuUtilOn = false;
6323: mpuSetCurrentClock (25.0);
6324: break;
6325: case "33.3MHz":
6326: mpuArbFreqOn = false;
6327: mpuUtilOn = false;
6328: mpuSetCurrentClock (100.0 / 3.0);
6329: break;
6330: case "50MHz":
6331: mpuArbFreqOn = false;
6332: mpuUtilOn = false;
6333: mpuSetCurrentClock (50.0);
6334: break;
6335: case "66.7MHz":
6336: mpuArbFreqOn = false;
6337: mpuUtilOn = false;
6338: mpuSetCurrentClock (200.0 / 3.0);
6339: break;
6340: case "75MHz":
6341: mpuArbFreqOn = false;
6342: mpuUtilOn = false;
6343: mpuSetCurrentClock (75.0);
6344: break;
6345: case "100MHz":
6346: mpuArbFreqOn = false;
6347: mpuUtilOn = false;
6348: mpuSetCurrentClock (100.0);
6349: break;
6350: case "Arbitrary frequency":
6351: mpuArbFreqOn = true;
6352: mpuUtilOn = false;
6353: mpuSetCurrentClock ((double) mpuArbFreqMHz);
6354: break;
6355: case "Arbitrary load factor":
6356: mpuArbFreqOn = false;
6357: mpuUtilOn = true;
6358: break;
6359: case "FE function instruction":
6360: FEFunction.fpkOn = ((JCheckBoxMenuItem) source).isSelected ();
6361: break;
6362: case "Reject FLOATn.X":
6363: FEFunction.fpkRejectFloatOn = ((JCheckBoxMenuItem) source).isSelected ();
6364: break;
6365: case "Cut FC2 pin":
6366: busRequestCutFC2Pin = ((JCheckBoxMenuItem) source).isSelected ();
6367: break;
6368: case "Wait cycles":
6369: busWaitCyclesRequest = ((JCheckBoxMenuItem) source).isSelected ();
6370: break;
6371: case "Use IPLROM 1.6":
6372: ROM.romIPLROM16On = ((JCheckBoxMenuItem) source).isSelected ();
6373: break;
6374: case "Increase IPLROM to 256KB":
6375: ROM.romIPLROM256KOn = ((JCheckBoxMenuItem) source).isSelected ();
6376: break;
6377:
6378: case "Run / Stop":
6379: if (((JCheckBox) source).isSelected ()) {
6380: mpuStart ();
6381: } else {
6382: if (RootPointerList.RTL_ON) {
6383: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6384: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6385: mpuStop (null);
6386: }
6387: } else {
6388: mpuStop (null);
6389: }
6390: }
6391: pnlPanel.requestFocusInWindow ();
6392: break;
6393: }
6394: }
6395: };
6396: mpuMenu = ComponentFactory.createMenu (
6397: "MPU", 'M',
6398: mpuResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset", 'R', MNB_MODIFIERS, listener), "ja", "リセット"),
6399: mpuOpt1ResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Hold down OPT.1 and reset", 'O', MNB_MODIFIERS, listener), "ja", "OPT.1 を押しながらリセット"),
6400: Multilingual.mlnText (ComponentFactory.createMenuItem ("Interrupt", listener), "ja", "インタラプト"),
6401: ComponentFactory.createHorizontalSeparator (),
6402: mdlMenu,
6403: ComponentFactory.createHorizontalSeparator (),
6404: mpuClock10MenuItem = ComponentFactory.createRadioButtonMenuItem (
6405: unitGroup,
6406: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 10.0,
6407: "10MHz",
6408: listener),
6409: mpuClock16MenuItem = ComponentFactory.createRadioButtonMenuItem (
6410: unitGroup,
6411: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0 / 3.0,
6412: "16.7MHz",
6413: listener),
6414: mpuClock25MenuItem = ComponentFactory.createRadioButtonMenuItem (
6415: unitGroup,
6416: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 25.0,
6417: "25MHz",
6418: listener),
6419: mpuClock33MenuItem = ComponentFactory.createRadioButtonMenuItem (
6420: unitGroup,
6421: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0 / 3.0,
6422: "33.3MHz",
6423: listener),
6424: mpuClock50MenuItem = ComponentFactory.createRadioButtonMenuItem (
6425: unitGroup,
6426: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0,
6427: "50MHz",
6428: listener),
6429: mpuClock66MenuItem = ComponentFactory.createRadioButtonMenuItem (
6430: unitGroup,
6431: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 200.0 / 3.0,
6432: "66.7MHz",
6433: listener),
6434: mpuClock75MenuItem = ComponentFactory.createRadioButtonMenuItem (
6435: unitGroup,
6436: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 75.0,
6437: "75MHz",
6438: listener),
6439: mpuClock100MenuItem = ComponentFactory.createRadioButtonMenuItem (
6440: unitGroup,
6441: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0,
6442: "100MHz",
6443: listener),
6444: mpuArbFreqRadioButtonMenuItem = Multilingual.mlnText (
6445: ComponentFactory.createRadioButtonMenuItem (
6446: unitGroup,
6447: mpuArbFreqOn,
6448: "Arbitrary frequency",
6449: listener),
6450: "ja", "任意の周波数"),
6451: ComponentFactory.createHorizontalBox (
6452: Box.createHorizontalStrut (20),
6453: mpuArbFreqSpinner = ComponentFactory.createNumberSpinner (
6454: mpuArbFreqModel = new SpinnerNumberModel (mpuArbFreqMHz, 1, 1000, 1),
6455: 4,
6456: new ChangeListener () {
6457: @Override public void stateChanged (ChangeEvent ce) {
6458:
6459: mpuArbFreqMHz = mpuArbFreqModel.getNumber ().intValue ();
6460: if (mpuArbFreqOn) {
6461: mpuSetCurrentClock ((double) mpuArbFreqMHz);
6462: }
6463: }
6464: }
6465: ),
6466: ComponentFactory.createLabel ("MHz"),
6467: Box.createHorizontalGlue ()
6468: ),
6469: mpuUtilRadioButtonMenuItem = Multilingual.mlnText (
6470: ComponentFactory.createRadioButtonMenuItem (
6471: unitGroup,
6472: mpuUtilOn,
6473: "Arbitrary load factor",
6474: listener),
6475: "ja", "任意の負荷率"),
6476: ComponentFactory.createHorizontalBox (
6477: Box.createHorizontalStrut (20),
6478: mpuUtilSpinner = ComponentFactory.createNumberSpinner (
6479: mpuUtilModel = new SpinnerNumberModel (mpuUtilRatio, 1, 100, 1),
6480: 4,
6481: new ChangeListener () {
6482: @Override public void stateChanged (ChangeEvent ce) {
6483:
6484: mpuUtilRatio = mpuUtilModel.getNumber ().intValue ();
6485: }
6486: }
6487: ),
6488: ComponentFactory.createLabel ("%"),
6489: Box.createHorizontalGlue ()
6490: ),
6491: ComponentFactory.createHorizontalSeparator (),
6492:
6493: coproFPUMenu,
6494:
6495: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkOn, "FE function instruction", listener), "ja", "FE ファンクション命令"),
6496: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkRejectFloatOn, "Reject FLOATn.X", listener), "ja", "FLOATn.X を組み込まない"),
6497: ComponentFactory.createHorizontalSeparator (),
6498: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busRequestCutFC2Pin, "Cut FC2 pin", listener), "ja", "FC2 ピンをカットする"),
6499: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busWaitCyclesRequest, "Wait cycles", listener), "ja", "ウェイトサイクル"),
6500: ComponentFactory.createHorizontalSeparator (),
6501: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM16On, "Use IPLROM 1.6", listener), "ja", "IPLROM 1.6 を使う"),
6502: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM256KOn, "Increase IPLROM to 256KB", listener), "ja", "IPLROM を 256KB に増やす")
6503: );
6504: }
6505:
6506:
6507: public static void mpuSetCurrentClock (double clock) {
6508: specifiedClock = clock;
6509: if (currentIsSecond) {
6510: specifiedSecondClock = clock;
6511: } else {
6512: specifiedFirstClock = clock;
6513: }
6514: if (!mpuArbFreqOn && !mpuUtilOn) {
6515: if (specifiedClock == 10.0) {
6516: mpuClock10MenuItem.setSelected (true);
6517: } else if (specifiedClock == 50.0 / 3.0) {
6518: mpuClock16MenuItem.setSelected (true);
6519: } else if (specifiedClock == 25.0) {
6520: mpuClock25MenuItem.setSelected (true);
6521: } else if (specifiedClock == 100.0 / 3.0) {
6522: mpuClock33MenuItem.setSelected (true);
6523: } else if (specifiedClock == 50.0) {
6524: mpuClock50MenuItem.setSelected (true);
6525: } else if (specifiedClock == 200.0 / 3.0) {
6526: mpuClock66MenuItem.setSelected (true);
6527: } else if (specifiedClock == 75.0) {
6528: mpuClock75MenuItem.setSelected (true);
6529: } else if (specifiedClock == 100.0) {
6530: mpuClock100MenuItem.setSelected (true);
6531: }
6532: }
6533: mpuClockMHz = specifiedClock;
6534: mpuSetClockMHz (mpuClockMHz);
6535: }
6536:
6537:
6538:
6539:
6540:
6541:
6542:
6543:
6544:
6545:
6546:
6547: public static void mpuSetClockMHz (double mhz) {
6548: mhz = Math.max (1.0, Math.min (1000.0, mhz));
6549: double lastMHz = mpuCurrentMHz;
6550: mpuCurrentMHz = mhz;
6551: mpuCycleUnit = (long) (((double) TMR_FREQ / 1000000.0) / mhz + 0.5);
6552:
6553: mpuModifiedUnit = (currentMPU == Model.MPU_MC68EC030 ||
6554: currentMPU == Model.MPU_MC68030 ?
6555: (long) (((double) TMR_FREQ * 3.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6556: currentMPU == Model.MPU_MC68LC040 ||
6557: currentMPU == Model.MPU_MC68040 ?
6558: (long) (((double) TMR_FREQ * 2.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6559: mpuCycleUnit);
6560: if (lastMHz != mhz) {
6561: mpuSetWait ();
6562: }
6563: }
6564:
6565:
6566:
6567:
6568:
6569:
6570:
6571:
6572:
6573:
6574:
6575:
6576:
6577:
6578:
6579:
6580:
6581:
6582:
6583:
6584:
6585:
6586:
6587:
6588:
6589:
6590:
6591:
6592:
6593:
6594:
6595:
6596:
6597:
6598:
6599:
6600:
6601:
6602:
6603:
6604:
6605:
6606:
6607:
6608:
6609:
6610:
6611:
6612:
6613:
6614:
6615:
6616:
6617:
6618:
6619:
6620:
6621:
6622:
6623:
6624:
6625:
6626:
6627:
6628:
6629:
6630:
6631:
6632:
6633:
6634:
6635:
6636:
6637:
6638:
6639:
6640:
6641:
6642:
6643:
6644:
6645: public static void mpuSetWait () {
6646:
6647: if (currentMPU <= Model.MPU_MC68010) {
6648: mpuWaitTime.ram = mpuCycleUnit >> 3;
6649: mpuWaitTime.vicon = (long) (mpuCycleUnit * 0.6);
6650: mpuWaitTime.crtc =
6651: mpuWaitTime.prnport =
6652: mpuWaitTime.sysport =
6653: mpuWaitTime.sprc =
6654: mpuWaitTime.sram =
6655: mpuWaitTime.rom = mpuCycleUnit;
6656: mpuWaitTime.gvram = (long) (mpuCycleUnit * 1.1);
6657: mpuWaitTime.rtc =
6658: mpuWaitTime.opm =
6659: mpuWaitTime.adpcm =
6660: mpuWaitTime.fdc =
6661: mpuWaitTime.fdd =
6662: mpuWaitTime.hdc =
6663: mpuWaitTime.ppi =
6664: mpuWaitTime.ioi = (long) (mpuCycleUnit * 1.7);
6665: mpuWaitTime.tvram = mpuCycleUnit * 2;
6666: mpuWaitTime.palet = (long) (mpuCycleUnit * 2.6);
6667: mpuWaitTime.mfp = (long) (mpuCycleUnit * 4.3);
6668: mpuWaitTime.scc = mpuCycleUnit * 6;
6669: mpuWaitTime.dmac = mpuCycleUnit * 15;
6670: mpuWaitTime.ramlong = mpuWaitTime.ram << 1;
6671: mpuWaitTime.romlong = mpuWaitTime.rom << 1;
6672: } else if (currentMPU <= Model.MPU_MC68030) {
6673: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6674: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6675: mpuWaitTime.sram = mpuCycleUnit * 2;
6676: mpuWaitTime.prnport =
6677: mpuWaitTime.sysport = mpuCycleUnit * 4;
6678: mpuWaitTime.gvram =
6679: mpuWaitTime.crtc =
6680: mpuWaitTime.vicon =
6681: mpuWaitTime.sprc = mpuCycleUnit * 6;
6682: mpuWaitTime.tvram = mpuCycleUnit * 7;
6683: mpuWaitTime.palet = mpuCycleUnit * 11;
6684: mpuWaitTime.opm =
6685: mpuWaitTime.adpcm =
6686: mpuWaitTime.fdc =
6687: mpuWaitTime.fdd =
6688: mpuWaitTime.hdc =
6689: mpuWaitTime.ppi =
6690: mpuWaitTime.ioi = mpuCycleUnit * 15;
6691: mpuWaitTime.mfp = mpuCycleUnit * 19;
6692: mpuWaitTime.rtc = mpuCycleUnit * 28;
6693: mpuWaitTime.dmac = mpuCycleUnit * 34;
6694: mpuWaitTime.scc = mpuCycleUnit * 38;
6695: mpuWaitTime.ramlong = mpuWaitTime.ram;
6696: mpuWaitTime.romlong = mpuWaitTime.rom;
6697: } else {
6698: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6699: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6700: mpuWaitTime.sram = mpuCycleUnit * 13;
6701: mpuWaitTime.prnport =
6702: mpuWaitTime.sysport = mpuCycleUnit * 17;
6703: mpuWaitTime.gvram =
6704: mpuWaitTime.crtc =
6705: mpuWaitTime.vicon =
6706: mpuWaitTime.sprc = mpuCycleUnit * 21;
6707: mpuWaitTime.tvram = mpuCycleUnit * 22;
6708: mpuWaitTime.palet = mpuCycleUnit * 33;
6709: mpuWaitTime.opm =
6710: mpuWaitTime.adpcm =
6711: mpuWaitTime.fdc =
6712: mpuWaitTime.fdd =
6713: mpuWaitTime.hdc =
6714: mpuWaitTime.ppi =
6715: mpuWaitTime.ioi = mpuCycleUnit * 37;
6716: mpuWaitTime.mfp = mpuCycleUnit * 47;
6717: mpuWaitTime.dmac = mpuCycleUnit * 73;
6718: mpuWaitTime.rtc = mpuCycleUnit * 77;
6719: mpuWaitTime.scc = mpuCycleUnit * 97;
6720: mpuWaitTime.ramlong = mpuWaitTime.ram;
6721: mpuWaitTime.romlong = mpuWaitTime.rom;
6722: }
6723: if (true) {
6724:
6725: mpuNoWaitTime.sram = mpuWaitTime.sram;
6726: mpuNoWaitTime.rom = mpuWaitTime.rom;
6727: mpuNoWaitTime.romlong = mpuWaitTime.romlong;
6728: }
6729:
6730: dmaWaitTime.ram = dmaCycleUnit >> 3;
6731: dmaWaitTime.sram = 0;
6732: dmaWaitTime.rom = 0;
6733: dmaWaitTime.gvram =
6734: dmaWaitTime.crtc =
6735: dmaWaitTime.vicon =
6736: dmaWaitTime.prnport =
6737: dmaWaitTime.sysport =
6738: dmaWaitTime.sprc = dmaCycleUnit;
6739: dmaWaitTime.tvram =
6740: dmaWaitTime.rtc =
6741: dmaWaitTime.opm =
6742: dmaWaitTime.adpcm =
6743: dmaWaitTime.fdc =
6744: dmaWaitTime.fdd =
6745: dmaWaitTime.hdc =
6746: dmaWaitTime.ppi =
6747: dmaWaitTime.ioi = dmaCycleUnit * 2;
6748: dmaWaitTime.palet = dmaCycleUnit * 3;
6749: dmaWaitTime.mfp = dmaCycleUnit * 4;
6750: dmaWaitTime.scc = dmaCycleUnit * 6;
6751: dmaWaitTime.dmac = dmaCycleUnit * 15;
6752: dmaWaitTime.ramlong = dmaWaitTime.ram << 1;
6753: dmaWaitTime.romlong = dmaWaitTime.rom << 1;
6754: if (MC68060.CAT_ON) {
6755: if (Model.MPU_MC68LC060 <= currentMPU) {
6756: MC68060.catMainLongTime = mpuCycleUnit * 13;
6757: MC68060.catMainLineTime = mpuCycleUnit * 45;
6758: MC68060.catHighLongTime = mpuCycleUnit * 9;
6759: MC68060.catHighLineTime = mpuCycleUnit * 15;
6760: }
6761: }
6762: }
6763:
6764:
6765:
6766:
6767:
6768: public static void mpuReset (int device, int romHandle) {
6769:
6770: mpuBootDevice = device;
6771: mpuROMBootHandle = romHandle;
6772:
6773:
6774:
6775:
6776:
6777:
6778:
6779:
6780:
6781:
6782:
6783:
6784: if (mpuBootDevice == -1) {
6785: if (mpuSavedBootDevice != -1) {
6786: mpuBootDevice = mpuSavedBootDevice;
6787: mpuROMBootHandle = mpuSavedROMBootHandle;
6788: mpuSavedBootDevice = -1;
6789: mpuSavedROMBootHandle = -1;
6790: }
6791: } else {
6792: if (mpuSavedBootDevice == -1) {
6793: mpuSavedBootDevice = MainMemory.mmrRwz (0x00ed0018);
6794: mpuSavedROMBootHandle = MainMemory.mmrRls (0x00ed000c);
6795: }
6796: }
6797:
6798:
6799: if (mpu010) {
6800: if (specifiedFirstMPU == Model.MPU_MC68000) {
6801: specifiedFirstMPU = Model.MPU_MC68010;
6802: }
6803: if (specifiedSecondMPU == Model.MPU_MC68000) {
6804: specifiedSecondMPU = Model.MPU_MC68010;
6805: }
6806: } else {
6807: if (specifiedFirstMPU == Model.MPU_MC68010) {
6808: specifiedFirstMPU = Model.MPU_MC68000;
6809: }
6810: if (specifiedSecondMPU == Model.MPU_MC68010) {
6811: specifiedSecondMPU = Model.MPU_MC68000;
6812: }
6813: }
6814:
6815:
6816: specifiedIsSecond = false;
6817: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
6818: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
6819:
6820: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
6821: MC68EC030.m30DivZeroVFlag = false;
6822: }
6823:
6824: if (mpuTask != null) {
6825: mpuClockLimit = 0L;
6826: System.out.println (Multilingual.mlnJapanese ?
6827: "MPU を停止します" :
6828: "MPU stops");
6829: mpuTask.cancel ();
6830: mpuTask = null;
6831: }
6832:
6833: tmrTimer.schedule (new TimerTask () {
6834: @Override public void run () {
6835:
6836:
6837:
6838: currentModel = specifiedModel;
6839: currentAccelerator = specifiedAccelerator;
6840: frmUpdateTitle ();
6841:
6842: currentIsSecond = specifiedIsSecond;
6843: currentFirstMPU = specifiedFirstMPU;
6844: currentSecondMPU = specifiedSecondMPU;
6845: currentMPU = specifiedMPU;
6846:
6847: mpuSetCurrentClock (specifiedClock);
6848:
6849: currentCopro0 = specifiedCopro0;
6850: currentCopro1 = specifiedCopro1;
6851: currentCopro2 = specifiedCopro2;
6852: currentOnchipFPU = specifiedOnchipFPU;
6853:
6854:
6855: if (currentMPU < Model.MPU_MC68020) {
6856: if (busHimem68000) {
6857: busRequestExMemoryStart = 0x10000000;
6858: busRequestExMemorySize = busLocalMemorySize;
6859: busRequestExMemoryArray = busLocalMemoryArray;
6860: } else {
6861: busRequestExMemoryStart = 0x10000000;
6862: busRequestExMemorySize = 0 << 20;
6863: busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
6864: }
6865: } else if (currentMPU < Model.MPU_MC68LC040) {
6866: if (busHighMemory060turboOn) {
6867: busRequestExMemoryStart = 0x10000000;
6868: busRequestExMemorySize = busLocalMemorySize;
6869: busRequestExMemoryArray = busLocalMemoryArray;
6870: } else {
6871: busRequestExMemoryStart = 0x01000000;
6872: busRequestExMemorySize = busHighMemorySize;
6873: busRequestExMemoryArray = busHighMemoryArray;
6874: }
6875: } else {
6876: busRequestExMemoryStart = 0x10000000;
6877: busRequestExMemorySize = busLocalMemorySize;
6878: busRequestExMemoryArray = busLocalMemoryArray;
6879: }
6880: busUpdateMemoryMap ();
6881:
6882:
6883: ROM.romReset ();
6884:
6885: RegisterList.drpSetMPU ();
6886:
6887: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
6888: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6889: MC68060.mmuReset ();
6890:
6891:
6892: if (Model.MPU_MC68020 <= currentMPU) {
6893: if ((7 & currentCopro0) == 1) {
6894: fpuMotherboardCoprocessor.epbSetMC68881 ();
6895: } else if ((7 & currentCopro0) == 2) {
6896: fpuMotherboardCoprocessor.epbSetMC68882 ();
6897: } else {
6898: fpuMotherboardCoprocessor.epbSetFullSpec ();
6899: }
6900: if ((8 & currentCopro0) == 0) {
6901: fpuMotherboardCoprocessor.epbSetExtended ();
6902: } else {
6903: fpuMotherboardCoprocessor.epbSetTriple ();
6904: }
6905: }
6906:
6907: if ((7 & currentCopro1) == 1) {
6908: fpuCoproboard1.epbSetMC68881 ();
6909: } else if ((7 & currentCopro1) == 2) {
6910: fpuCoproboard1.epbSetMC68882 ();
6911: } else {
6912: fpuCoproboard1.epbSetFullSpec ();
6913: }
6914: if ((8 & currentCopro1) == 0) {
6915: fpuCoproboard1.epbSetExtended ();
6916: } else {
6917: fpuCoproboard1.epbSetTriple ();
6918: }
6919:
6920: if ((7 & currentCopro2) == 1) {
6921: fpuCoproboard2.epbSetMC68881 ();
6922: } else if ((7 & currentCopro2) == 2) {
6923: fpuCoproboard2.epbSetMC68882 ();
6924: } else {
6925: fpuCoproboard2.epbSetFullSpec ();
6926: }
6927: if ((8 & currentCopro2) == 0) {
6928: fpuCoproboard2.epbSetExtended ();
6929: } else {
6930: fpuCoproboard2.epbSetTriple ();
6931: }
6932:
6933: if (Model.MPU_MC68040 <= currentMPU) {
6934: if ((7 & currentOnchipFPU) == 6) {
6935: fpuOnChipFPU.epbSetMC68060 ();
6936: } else {
6937: fpuOnChipFPU.epbSetFullSpec ();
6938: }
6939: if ((8 & currentOnchipFPU) == 0) {
6940: fpuOnChipFPU.epbSetExtended ();
6941: } else {
6942: fpuOnChipFPU.epbSetTriple ();
6943: }
6944: }
6945:
6946: if (!currentModel.isX68030 ()) {
6947: dmaCycleUnit = TMR_FREQ / 10000000L;
6948: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6949: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6950: mpuROMWaitCycles = 1;
6951: mpuRAMWaitCycles = 0;
6952: } else {
6953: dmaCycleUnit = TMR_FREQ / 12500000L;
6954: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6955: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6956: mpuROMWaitCycles = 0;
6957: mpuRAMWaitCycles = 0;
6958: }
6959:
6960: busWaitCycles = busWaitCyclesRequest;
6961: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
6962:
6963: HD63450.dmaReadCycles = (currentModel.isPRO () ? 6 :
6964: currentModel.isCompact () ? 4 :
6965: 5);
6966: HD63450.dmaWriteCycles = (currentModel.isPRO () ? 6 :
6967: 5);
6968:
6969: if (currentMPU < Model.MPU_MC68020) {
6970:
6971: mpuIgnoreAddressError = false;
6972:
6973: mpuCacheOn = false;
6974:
6975: } else if (currentMPU < Model.MPU_MC68040) {
6976:
6977: mpuIgnoreAddressError = true;
6978: fpuBox = fpuMotherboardCoprocessor;
6979: fpuBox.epbReset ();
6980: fpuFPn = fpuBox.epbFPn;
6981:
6982: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
6983:
6984: } else {
6985:
6986: mpuIgnoreAddressError = true;
6987: fpuBox = fpuOnChipFPU;
6988: fpuBox.epbReset ();
6989: fpuFPn = fpuBox.epbFPn;
6990:
6991: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6992: mpuCacheOn = (mpuCACR & 0x80008000) != 0;
6993: if (MC68060.CAT_ON) {
6994: if (Model.MPU_MC68LC060 <= currentMPU) {
6995: MC68060.catReset ();
6996: }
6997: }
6998:
6999: }
7000:
7001: mpuSetWait ();
7002:
7003:
7004: regSRT1 = regSRT0 = 0;
7005: regSRS = REG_SR_S;
7006: regSRM = 0;
7007: regSRI = REG_SR_I;
7008: regCCR = 0;
7009: Arrays.fill (regRn, 0);
7010:
7011: regRn[15] = MainMemory.mmrRls (0x00ff0000);
7012: regPC = MainMemory.mmrRls (0x00ff0004);
7013:
7014: MainMemory.mmrReset ();
7015:
7016: busReset ();
7017: if (InstructionBreakPoint.IBP_ON) {
7018: InstructionBreakPoint.ibpOp1MemoryMap = InstructionBreakPoint.ibpOp1SuperMap;
7019: InstructionBreakPoint.ibpReset ();
7020: }
7021: if (BranchLog.BLG_ON) {
7022: BranchLog.blgReset ();
7023: }
7024:
7025: mpuIMR = 0;
7026: mpuIRR = 0;
7027: if (MC68901.MFP_DELAYED_INTERRUPT) {
7028: mpuDIRR = 0;
7029: }
7030: mpuISR = 0;
7031:
7032:
7033: mpuStart ();
7034: }
7035: }, TMR_DELAY);
7036:
7037: }
7038:
7039:
7040:
7041: public static void mpuStopAndStart () {
7042: if (mpuTask == null) {
7043: mpuStart ();
7044: } else {
7045: if (RootPointerList.RTL_ON) {
7046: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
7047: RootPointerList.rtlCurrentUserTaskIsStoppable) {
7048: mpuStop (null);
7049: }
7050: } else {
7051: mpuStop (null);
7052: }
7053: }
7054: }
7055:
7056:
7057:
7058:
7059:
7060: public static void mpuStart () {
7061: if (mpuTask != null) {
7062: mpuClockLimit = 0L;
7063: System.out.println (Multilingual.mlnJapanese ?
7064: "MPU を停止します" :
7065: "MPU stops");
7066: mpuTask.cancel ();
7067: mpuTask = null;
7068: }
7069:
7070: for (AbstractButton button : mpuButtonsStopped) {
7071: button.setEnabled (false);
7072: }
7073: DisassembleList.ddpStoppedBy = null;
7074: System.out.println (Model.mpuNameOf (currentMPU) + (Multilingual.mlnJapanese ? " を起動します" : " starts up"));
7075: mpuTask = new TimerTask () {
7076: @Override public void run () {
7077: mpuContinue = true;
7078: mpuClockLimit = mpuClockTime + TMR_FREQ * TMR_INTERVAL / 1000;
7079: mpuExecuteCore ();
7080: }
7081: };
7082: tmrTimer.scheduleAtFixedRate (mpuTask, TMR_DELAY, TMR_INTERVAL);
7083:
7084: for (AbstractButton button : mpuButtonsRunning) {
7085: button.setEnabled (true);
7086: }
7087: }
7088:
7089:
7090:
7091: public static void mpuExecuteCore () {
7092:
7093: long nanoStart = System.nanoTime ();
7094:
7095: busSuper (RP5C15.rtcFirst, 0x00e8a000, 0x00e8c000);
7096:
7097:
7098: if (currentMPU < Model.MPU_MC68010) {
7099: MC68000.mpuCore ();
7100: } else if (currentMPU < Model.MPU_MC68020) {
7101: MC68010.mpuCore ();
7102: } else if (currentMPU < Model.MPU_MC68LC040) {
7103: MC68EC030.mpuCore ();
7104: } else {
7105: MC68060.mpuCore ();
7106: }
7107:
7108: if (dbgVisibleMask != 0) {
7109: dbgUpdate ();
7110: }
7111:
7112: long nanoEnd = System.nanoTime ();
7113: mpuTotalNano += nanoEnd - nanoStart;
7114: if (--mpuAdjustmentCounter == 0) {
7115:
7116: final double expectedNano = 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
7117:
7118: double coreNano0 = (double) mpuTotalNano;
7119: mpuTotalNano = 0L;
7120: double coreNanoA = (coreNano0 * 2.0 + mpuCoreNano1 + mpuCoreNano2) * 0.25;
7121: mpuCoreNano2 = mpuCoreNano1;
7122: mpuCoreNano1 = coreNano0;
7123:
7124:
7125:
7126: double actualPercent = Math.max (1.0, 100.0 * coreNanoA / expectedNano);
7127:
7128: double maxPercent = SoundSource.sndPlayOn ? 90.0 : 100.0;
7129:
7130:
7131:
7132:
7133: if (mpuUtilOn) {
7134:
7135: double targetPercent = Math.min (maxPercent, (double) mpuUtilRatio);
7136: mpuSetClockMHz ((1.2 - 0.2 * actualPercent / targetPercent) * mpuCurrentMHz);
7137: } else {
7138: mpuSetClockMHz (Math.min (maxPercent / actualPercent,
7139: 1.2 - 0.2 * mpuCurrentMHz / mpuClockMHz) * mpuCurrentMHz);
7140: }
7141: Indicator.indUpdate (actualPercent);
7142: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
7143: }
7144: }
7145:
7146:
7147:
7148:
7149: public static void mpuStop (String message) {
7150:
7151: mpuAdvanceCount = 0;
7152: mpuStepCount = 0;
7153: mpuContinue = false;
7154: mpuStop1 (message);
7155: }
7156: public static void mpuStop1 (String message) {
7157: if (mpuTask == null) {
7158: return;
7159: }
7160: DisassembleList.ddpStoppedBy = message;
7161: mpuClockLimit = 0L;
7162: System.out.println (Multilingual.mlnJapanese ?
7163: "MPU を停止します" :
7164: "MPU stops");
7165: mpuTask.cancel ();
7166: mpuTask = null;
7167:
7168: if (mpuStepCount != 0 && mpuContinue) {
7169: if (mpuStepCount == -1 || --mpuStepCount != 0) {
7170: mpuStep (mpuStepCount);
7171: return;
7172: }
7173: }
7174: mpuAdvanceCount = 0;
7175: mpuStepCount = 0;
7176: mpuContinue = false;
7177:
7178: for (AbstractButton button : mpuButtonsRunning) {
7179: button.setEnabled (false);
7180: }
7181: tmrTimer.schedule (new TimerTask () {
7182: @Override public void run () {
7183: mpuUpdateWindow ();
7184: }
7185: }, TMR_DELAY);
7186: }
7187:
7188:
7189:
7190:
7191:
7192:
7193: public static void mpuAdvance (int n) {
7194: if (mpuTask != null) {
7195: return;
7196: }
7197: mpuAdvanceCount = n;
7198: DisassembleList.ddpStoppedBy = null;
7199: mpuTask = new TimerTask () {
7200: @Override public void run () {
7201: mpuContinue = true;
7202: do {
7203: mpuClockLimit = mpuClockTime + 1L;
7204: mpuExecuteCore ();
7205: } while (mpuContinue && --mpuAdvanceCount != 0);
7206: mpuClockLimit = 0L;
7207: if (mpuTask != null) {
7208: mpuTask.cancel ();
7209: mpuTask = null;
7210: }
7211: if (mpuStepCount != 0 && mpuContinue) {
7212: if (mpuStepCount == -1 || --mpuStepCount != 0) {
7213: mpuStep (mpuStepCount);
7214: return;
7215: }
7216: }
7217: mpuAdvanceCount = 0;
7218: mpuStepCount = 0;
7219: mpuContinue = false;
7220: mpuUpdateWindow ();
7221: }
7222: };
7223: tmrTimer.schedule (mpuTask, TMR_DELAY);
7224: }
7225:
7226:
7227:
7228:
7229:
7230:
7231: public static void mpuStep (int n) {
7232: if (mpuTask != null) {
7233: return;
7234: }
7235: mpuStepCount = n;
7236: Disassembler.disDisassemble (new StringBuilder (), regPC, regSRS);
7237: if ((Disassembler.disStatus & (Disassembler.DIS_ALWAYS_BRANCH | Disassembler.DIS_SOMETIMES_BRANCH)) != 0) {
7238: if (mpuStepCount == -1 &&
7239: (Disassembler.disOC == 0x4e73 ||
7240: Disassembler.disOC == 0x4e74 ||
7241: Disassembler.disOC == 0x4e75 ||
7242: Disassembler.disOC == 0x4e77) &&
7243: mpuUntilReturnSRS == regSRS &&
7244: (currentMPU < Model.MPU_MC68LC040 ||
7245: mpuUntilReturnRP == (regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP)) &&
7246: mpuUntilReturnPC0 != regPC0 &&
7247: Integer.compareUnsigned (mpuUntilReturnSP, regRn[15]) <= 0) {
7248: mpuAdvanceCount = 0;
7249: mpuStepCount = 0;
7250: mpuContinue = false;
7251: mpuUpdateWindow ();
7252: return;
7253: }
7254: mpuAdvance (1);
7255: } else {
7256: if (InstructionBreakPoint.IBP_ON) {
7257: InstructionBreakPoint.ibpInstant (Disassembler.disPC, DisassembleList.ddpSupervisorMode);
7258: mpuStart ();
7259: }
7260: }
7261: }
7262:
7263:
7264:
7265:
7266:
7267:
7268:
7269:
7270:
7271:
7272:
7273: public static void mpuStepUntilReturn () {
7274: if (mpuTask != null) {
7275: return;
7276: }
7277: mpuUntilReturnSRS = regSRS;
7278: mpuUntilReturnRP = regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP;
7279: mpuUntilReturnPC0 = regPC0;
7280: mpuUntilReturnSP = regRn[15];
7281: mpuStep (-1);
7282: }
7283:
7284:
7285:
7286: public static void mpuUpdateWindow () {
7287: if (dbgVisibleMask != 0) {
7288: if ((dbgVisibleMask & DBG_DDP_VISIBLE_MASK) != 0) {
7289: DisassembleList.ddpBacktraceRecord = -1L;
7290: DisassembleList.ddpUpdate (-1, -1, false);
7291: }
7292: if (BranchLog.BLG_ON) {
7293: if ((dbgVisibleMask & DBG_BLG_VISIBLE_MASK) != 0) {
7294: BranchLog.blgUpdate (BranchLog.BLG_SELECT_NEWEST);
7295: }
7296: }
7297: if (ProgramFlowVisualizer.PFV_ON) {
7298: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
7299: ProgramFlowVisualizer.pfvUpdate ();
7300: }
7301: }
7302: if (RasterBreakPoint.RBP_ON) {
7303: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
7304: RasterBreakPoint.rbpUpdateFrame ();
7305: }
7306: }
7307: if (ScreenModeTest.SMT_ON) {
7308: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
7309: ScreenModeTest.smtUpdateFrame ();
7310: }
7311: }
7312: if (RootPointerList.RTL_ON) {
7313: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
7314: RootPointerList.rtlUpdateFrame ();
7315: }
7316: }
7317: if (SpritePatternViewer.SPV_ON) {
7318: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
7319: SpritePatternViewer.spvUpdateFrame ();
7320: }
7321: }
7322: if (PaletteViewer.PLV_ON) {
7323: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
7324: PaletteViewer.plvUpdateFrame ();
7325: }
7326: }
7327: if (ATCMonitor.ACM_ON) {
7328: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
7329: ATCMonitor.acmUpdateFrame ();
7330: }
7331: }
7332: }
7333:
7334: if (DebugConsole.dgtRequestRegs != 0) {
7335: if ((DebugConsole.dgtRequestRegs & 1) != 0) {
7336: ExpressionEvaluator.ElementType.ETY_COMMAND_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
7337: }
7338: if ((DebugConsole.dgtRequestRegs & 2) != 0) {
7339: ExpressionEvaluator.ElementType.ETY_COMMAND_FLOAT_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
7340: }
7341: if ((DebugConsole.dgtRequestRegs & 4) != 0) {
7342: DebugConsole.dgtPrintPrompt ();
7343: }
7344: DebugConsole.dgtRequestRegs = 0;
7345: }
7346:
7347: for (AbstractButton button : mpuButtonsRunning) {
7348: button.setEnabled (false);
7349: }
7350:
7351: for (AbstractButton button : mpuButtonsStopped) {
7352: button.setEnabled (true);
7353: }
7354: }
7355:
7356:
7357:
7358: public static JButton mpuMakeBreakButton () {
7359: return mpuAddButtonRunning (
7360: Multilingual.mlnToolTipText (
7361: ComponentFactory.createImageButton (
7362: LnF.LNF_BREAK_IMAGE,
7363: LnF.LNF_BREAK_DISABLED_IMAGE,
7364: "Stop", mpuDebugActionListener),
7365: "ja", "停止")
7366: );
7367: }
7368:
7369:
7370:
7371: public static JButton mpuMakeTraceButton () {
7372: return mpuAddButtonStopped (
7373: Multilingual.mlnToolTipText (
7374: ComponentFactory.createImageButton (
7375: LnF.LNF_TRACE_IMAGE,
7376: LnF.LNF_TRACE_DISABLED_IMAGE,
7377: "Trace", mpuDebugActionListener),
7378: "ja", "トレース")
7379: );
7380: }
7381:
7382:
7383:
7384: public static JButton mpuMakeTrace10Button () {
7385: return mpuAddButtonStopped (
7386: Multilingual.mlnToolTipText (
7387: ComponentFactory.createImageButton (
7388: LnF.LNF_TRACE_10_IMAGE,
7389: LnF.LNF_TRACE_10_DISABLED_IMAGE,
7390: "Trace 10 times", mpuDebugActionListener),
7391: "ja", "トレース 10 回")
7392: );
7393: }
7394:
7395:
7396:
7397: public static JButton mpuMakeTrace100Button () {
7398: return mpuAddButtonStopped (
7399: Multilingual.mlnToolTipText (
7400: ComponentFactory.createImageButton (
7401: LnF.LNF_TRACE_100_IMAGE,
7402: LnF.LNF_TRACE_100_DISABLED_IMAGE,
7403: "Trace 100 times", mpuDebugActionListener),
7404: "ja", "トレース 100 回")
7405: );
7406: }
7407:
7408:
7409:
7410: public static JButton mpuMakeStepButton () {
7411: return mpuAddButtonStopped (
7412: Multilingual.mlnToolTipText (
7413: ComponentFactory.createImageButton (
7414: LnF.LNF_STEP_IMAGE,
7415: LnF.LNF_STEP_DISABLED_IMAGE,
7416: "Step", mpuDebugActionListener),
7417: "ja", "ステップ")
7418: );
7419: }
7420:
7421:
7422:
7423: public static JButton mpuMakeStep10Button () {
7424: return mpuAddButtonStopped (
7425: Multilingual.mlnToolTipText (
7426: ComponentFactory.createImageButton (
7427: LnF.LNF_STEP_10_IMAGE,
7428: LnF.LNF_STEP_10_DISABLED_IMAGE,
7429: "Step 10 times", mpuDebugActionListener),
7430: "ja", "ステップ 10 回")
7431: );
7432: }
7433:
7434:
7435:
7436: public static JButton mpuMakeStep100Button () {
7437: return mpuAddButtonStopped (
7438: Multilingual.mlnToolTipText (
7439: ComponentFactory.createImageButton (
7440: LnF.LNF_STEP_100_IMAGE,
7441: LnF.LNF_STEP_100_DISABLED_IMAGE,
7442: "Step 100 times", mpuDebugActionListener),
7443: "ja", "ステップ 100 回")
7444: );
7445: }
7446:
7447:
7448:
7449: public static JButton mpuMakeReturnButton () {
7450: return mpuAddButtonStopped (
7451: Multilingual.mlnToolTipText (
7452: ComponentFactory.createImageButton (
7453: LnF.LNF_STEP_UNTIL_RETURN_IMAGE,
7454: LnF.LNF_STEP_UNTIL_RETURN_DISABLED_IMAGE,
7455: "Step until return", mpuDebugActionListener),
7456: "ja", "ステップアンティルリターン")
7457: );
7458: }
7459:
7460:
7461:
7462: public static JButton mpuMakeRunButton () {
7463: return mpuAddButtonStopped (
7464: Multilingual.mlnToolTipText (
7465: ComponentFactory.createImageButton (
7466: LnF.LNF_RUN_IMAGE,
7467: LnF.LNF_RUN_DISABLED_IMAGE,
7468: "Run", mpuDebugActionListener),
7469: "ja", "実行")
7470: );
7471: }
7472:
7473:
7474:
7475: public static <T extends AbstractButton> T mpuAddButtonRunning (T button) {
7476: button.setEnabled (mpuTask != null);
7477: mpuButtonsRunning.add (button);
7478: return button;
7479: }
7480:
7481:
7482:
7483: public static <T extends AbstractButton> T mpuAddButtonStopped (T button) {
7484: button.setEnabled (mpuTask == null);
7485: mpuButtonsStopped.add (button);
7486: return button;
7487: }
7488:
7489:
7490:
7491:
7492:
7493:
7494:
7495:
7496:
7497:
7498:
7499:
7500:
7501:
7502:
7503:
7504: public static final int EMX_OPCODE_BASE = 0x4e00;
7505: public static final int EMX_OPCODE_HFSBOOT = EMX_OPCODE_BASE + 0x00;
7506: public static final int EMX_OPCODE_HFSINST = EMX_OPCODE_BASE + 0x01;
7507: public static final int EMX_OPCODE_HFSSTR = EMX_OPCODE_BASE + 0x02;
7508: public static final int EMX_OPCODE_HFSINT = EMX_OPCODE_BASE + 0x03;
7509: public static final int EMX_OPCODE_EMXNOP = EMX_OPCODE_BASE + 0x04;
7510: public static final int EMX_OPCODE_EMXWAIT = EMX_OPCODE_BASE + 0x05;
7511:
7512: public static final String[] EMX_MNEMONIC_ARRAY = {
7513: "hfsboot",
7514: "hfsinst",
7515: "hfsstr",
7516: "hfsint",
7517: "emxnop",
7518: "emxwait",
7519: };
7520:
7521:
7522:
7523:
7524: public static void emxNop () {
7525: if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x00007140) {
7526: int head = regRn[9];
7527: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7528:
7529:
7530: emxPatchPCM8A (head, tail);
7531:
7532:
7533: emxCheckRSDRV202 (head, tail);
7534: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000716c) {
7535: int head = regRn[9];
7536: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7537:
7538:
7539: emxPatch060turbosys (head, tail);
7540:
7541:
7542: if (Z8530.SCC_FSX_MOUSE) {
7543: emxCheckFSX (head, tail);
7544: }
7545:
7546:
7547: if (HFS.HFS_USE_TWENTY_ONE) {
7548: emxCheckTwentyOne (head, tail);
7549: }
7550:
7551:
7552: LabeledAddress.lblClear ();
7553: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000972c) {
7554: int head = regRn[8] + 256;
7555:
7556: int tail = MC68060.mmuPeekLong (head - 208, 1);
7557:
7558:
7559: emxCheckBSIO021 (head, tail);
7560:
7561:
7562: emxPatchPCM8A (head, tail);
7563:
7564:
7565: emxCheckTMSIO031 (head, tail);
7566:
7567:
7568: LabeledAddress.lblClear ();
7569:
7570:
7571: if (dbgStopAtStart) {
7572: InstructionBreakPoint.ibpInstant (regRn[12], 0);
7573: }
7574: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000a090) {
7575: int head = regRn[8] + 256;
7576: int tail = MC68060.mmuPeekLongData (regRn[8] + 8, 1);
7577: String name = MC68060.mmuPeekStringZ (head - 60, 1);
7578: if (name.equalsIgnoreCase ("fsx.x")) {
7579:
7580:
7581: if (Z8530.SCC_FSX_MOUSE) {
7582: emxCheckFSX (head, tail);
7583: }
7584: }
7585: if (name.equalsIgnoreCase ("TwentyOne.x")) {
7586:
7587:
7588: if (HFS.HFS_USE_TWENTY_ONE) {
7589: emxCheckTwentyOne (head, tail);
7590: }
7591: }
7592: }
7593: }
7594:
7595: public static final int[] emxPCM8AFFMap = {
7596: 0x00000138, 0x000001f6, 0x00000394, 0x000011ec, 0x0000120a, 0x00001400, 0x00001814, 0x00001870, 0x00001882, 0x0000188a,
7597: 0x00001892, 0x000018a2, 0x000018a8, 0x000018ca, 0x000018d4, 0x000018e0, 0x000018e8, 0x00001908, 0x000019e4, 0x00001afa,
7598: 0x00001b58, 0x00001b7c, 0x00001bac, 0x00001c38, 0x00001ccc, 0x000021f8, 0x00002250, 0x00002258, 0x00002290, 0x000022a6,
7599: 0x000022b0, 0x000022c0, 0x000022c8, 0x000022de, 0x000022ea, 0x000030c8, 0x000030de, 0x000030e6, 0x000030ea, 0x000030f6,
7600: 0x00003112, 0x00003188, 0x0000334c, 0x0000338a, 0x000033a2, 0x000033c4, 0x000033d0, 0x0000341a, 0x00003428, 0x00003496,
7601: 0x000034a6, 0x000034d6, 0x0000fe0e, 0x0000fec8, 0x0000feec, 0x0000ff46, 0x0000ff4e,
7602: };
7603:
7604:
7605:
7606: public static void emxPatchPCM8A (int head, int tail) {
7607: if (head + 0x0000ff60 <= tail &&
7608: MC68060.mmuPeekLongData (head + 0x10f8, 1) == 0x50434d38 &&
7609: MC68060.mmuPeekLongData (head + 0x10fc, 1) == 0x41313032) {
7610: System.out.println (Multilingual.mlnJapanese ?
7611: "PCM8A.X 1.02 があります" :
7612: "PCM8A.X 1.02 exists");
7613: int patched = 0;
7614: int failed = 0;
7615:
7616: for (int offset : emxPCM8AFFMap) {
7617: if (MC68060.mmuPeekByteZeroData (head + offset, 1) == 0xff) {
7618: MC68060.mmuPokeByteData (head + offset, 0x00, 1);
7619: patched++;
7620: } else {
7621: failed++;
7622: }
7623: }
7624: if (patched != 0) {
7625: System.out.printf (Multilingual.mlnJapanese ?
7626: "PCM8A.X 1.02 にパッチをあてました (%d/%d)\n" :
7627: "PCM8A.X 1.02 was patched (%d/%d)\n",
7628: patched, patched + failed);
7629: }
7630: }
7631: }
7632:
7633:
7634:
7635: public static void emxPatch060turbosys (int head, int tail) {
7636:
7637:
7638:
7639:
7640: if (head + 0x00002000 <= tail &&
7641: MC68060.mmuPeekLongData (head + 0x00000ec0, 1) == 0x203c302e &&
7642: MC68060.mmuPeekLongData (head + 0x00000ec4, 1) == 0x3536227c &&
7643: MC68060.mmuPeekLongData (head + 0x00000ec8, 1) == 0x30363054) {
7644: System.out.println (Multilingual.mlnJapanese ?
7645: "060turbo.sys 0.56 があります" :
7646: "060turbo.sys 0.56 exists");
7647:
7648:
7649:
7650: int patched = 0;
7651: int failed = 0;
7652: if (MC68060.mmuPeekLongData (head + 0x000021e6, 1) == 0x08f90004 &&
7653: MC68060.mmuPeekLongData (head + 0x000021ea, 1) == 0x00ed0070) {
7654: MC68060.mmuPokeWordData (head + 0x000021e6, 0x0839, 1);
7655: patched++;
7656: } else {
7657: failed++;
7658: }
7659: System.out.printf (Multilingual.mlnJapanese ?
7660: "060turbo.sys 0.56 にパッチをあてました (%d/%d)\n" :
7661: "060turbo.sys 0.56 was patched (%d/%d)\n",
7662: patched, patched + failed);
7663: }
7664: }
7665:
7666:
7667:
7668: public static void emxCheckFSX (int head, int tail) {
7669: if (Z8530.SCC_FSX_MOUSE) {
7670: if (head + 0x00063200 <= tail &&
7671: "\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))) {
7672: System.out.println (Multilingual.mlnJapanese ?
7673: "FSX.X 3.10 があります" :
7674: "FSX.X 3.10 exists");
7675: Z8530.sccFSXMouseHook = head + 0x04f82a;
7676: Z8530.sccFSXMouseWork = head + 0x063184;
7677: }
7678: }
7679: }
7680:
7681:
7682:
7683:
7684:
7685:
7686: public static void emxCheckRSDRV202 (int head, int tail) {
7687: if (head + 0x000ea6 <= tail &&
7688: MC68060.mmuPeekEquals (head + 0x000e4e, "RS-232C DRIVER for X68000 version 2.02")) {
7689: if (RS232CTerminal.trmRSDRV202Head != head) {
7690: RS232CTerminal.trmRSDRV202Head = head;
7691: int[] patchData = {
7692:
7693:
7694: 0x05f8, 0x000a, 0x000b,
7695:
7696: 0x0600, 0xd040, 0x2048,
7697:
7698: 0x060e, 0x3030, 0x4e90,
7699: 0x0610, 0x0000, 0x2048,
7700:
7701: 0x074e, 0x0821, 0x2041,
7702: 0x0750, 0x0410, 0x3200,
7703: 0x0752, 0x0207, 0x303c,
7704: 0x0754, 0x0102, 0x0823,
7705: 0x0756, 0x0080, 0xe268,
7706: 0x0758, 0x003f, 0x72fe,
7707: 0x075a, 0x001f, 0xd141,
7708: 0x075c, 0x000e, 0x2208,
7709: 0x075e, 0x0006, 0x4e75,
7710:
7711:
7712: 0x0ab0, 0x0040, 0x0400,
7713: 0x0ad2, 0x0040, 0x0400,
7714: 0x0af4, 0x0040, 0x0400,
7715: 0x0b16, 0x0040, 0x0400,
7716: 0x0b38, 0x0040, 0x0400,
7717:
7718:
7719: 0x0cae, 0x0009, 0x000b,
7720: };
7721: int patched = 0;
7722: int failed = 0;
7723: for (int i = 0; i < patchData.length; i += 3) {
7724: int a = head + patchData[i];
7725: int b = patchData[i + 1];
7726: int c = patchData[i + 2];
7727: int d = MC68060.mmuPeekWordZeroData (a, 1);
7728: if (d == b) {
7729: MC68060.mmuPokeWordData (a, c, 1);
7730: patched++;
7731: } else if (d != c) {
7732: failed++;
7733: }
7734: }
7735: System.out.printf ("RSDRV.SYS 2.02 found at %08X and patched (%d/%d)\n", head, patched, patched + failed);
7736: }
7737: }
7738: }
7739:
7740:
7741:
7742:
7743:
7744: public static void emxCheckTMSIO031 (int head, int tail) {
7745: if (head + 0x000fc4 <= tail &&
7746: MC68060.mmuPeekEquals (head + 0x000d1c, "TMSIO version 0.31 Copyright (C) 1990-93 by Miki Hoshino")) {
7747: if (RS232CTerminal.trmTMSIO031Head != head) {
7748: RS232CTerminal.trmTMSIO031Head = head;
7749: System.out.printf ("TMSIO 0.31 found at %08X\n", head);
7750: }
7751: }
7752: }
7753:
7754:
7755:
7756:
7757:
7758: public static void emxCheckBSIO021 (int head, int tail) {
7759: if (head + 0x001c2c <= tail &&
7760: MC68060.mmuPeekEquals (head + 0x001a66, "BSIO version 0.21 Copyright (C) 1994 By BAZU")) {
7761: if (RS232CTerminal.trmBSIO021Head != head) {
7762: RS232CTerminal.trmBSIO021Head = head;
7763: System.out.printf ("BSIO 0.21 found at %08X\n", head);
7764: }
7765: }
7766: }
7767:
7768:
7769:
7770: public static void emxCheckTwentyOne (int head, int tail) {
7771: if (HFS.HFS_USE_TWENTY_ONE &&
7772: head + 64 <= tail) {
7773: if (MainMemory.mmrTwentyOneOptionAddress != 0 ||
7774: MainMemory.mmrHumanVersion <= 0) {
7775: return;
7776: }
7777: int name1 = MC68060.mmuPeekLongData (head + 14, 1);
7778: if (name1 == ('*' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7779: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7780: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '*')) {
7781: MainMemory.mmrTwentyOneOptionAddress = -1;
7782: }
7783: } else if (name1 == ('?' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7784: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7785: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '?') ||
7786: name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | 'E')) {
7787: System.out.println (Multilingual.mlnJapanese ?
7788: "TwentyOne.x があります" :
7789: "TwentyOne.x exists");
7790: MainMemory.mmrTwentyOneOptionAddress = head + 22;
7791: }
7792: }
7793: }
7794: }
7795:
7796:
7797:
7798:
7799:
7800:
7801:
7802:
7803:
7804:
7805:
7806:
7807:
7808:
7809:
7810:
7811:
7812:
7813:
7814:
7815:
7816:
7817:
7818:
7819:
7820:
7821:
7822:
7823:
7824:
7825:
7826:
7827:
7828:
7829:
7830:
7831:
7832:
7833:
7834:
7835:
7836:
7837:
7838:
7839:
7840:
7841:
7842:
7843:
7844:
7845:
7846: public static final boolean IRP_BITREV_REVERSE = false;
7847: public static final boolean IRP_BITREV_SHIFT = false;
7848: public static final boolean IRP_BITREV_TABLE = true;
7849:
7850: public static final boolean IRP_MOVEM_MAINMEMORY = true;
7851: public static final boolean IRP_MOVEM_EXPAND = false;
7852: public static final boolean IRP_MOVEM_LOOP = false;
7853: public static final boolean IRP_MOVEM_SHIFT_LEFT = false;
7854: public static final boolean IRP_MOVEM_SHIFT_RIGHT = true;
7855: public static final boolean IRP_MOVEM_ZEROS = false;
7856:
7857:
7858: public static void irpReset () {
7859:
7860: CRTC.crtReset ();
7861: VideoController.vcnReset ();
7862: HD63450.dmaReset ();
7863: MC68901.mfpReset ();
7864: Keyboard.kbdReset ();
7865: RP5C15.rtcReset ();
7866: PrinterPort.prnReset ();
7867: SoundSource.sndReset ();
7868: OPM.opmReset ();
7869: ADPCM.pcmReset ();
7870: FDC.fdcReset ();
7871: IOInterrupt.ioiReset ();
7872: eb2Reset ();
7873: if (HostCDROM.HCD_ENABLED) {
7874: HostCDROM.hcdReset ();
7875: }
7876: SPC.spcReset ();
7877: Z8530.sccReset ();
7878: RS232CTerminal.trmReset ();
7879: PPI.ppiReset ();
7880: HFS.hfsReset ();
7881: SpriteScreen.sprReset ();
7882:
7883: if (MercuryUnit.MU4_ON) {
7884: MercuryUnit.mu4Reset ();
7885: }
7886: xt3Reset ();
7887: SRAM.smrReset ();
7888: CONDevice.conReset ();
7889: TextCopy.txcReset ();
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:
8413:
8414:
8415:
8416:
8417:
8418:
8419:
8420:
8421:
8422:
8423:
8424:
8425:
8426:
8427:
8428:
8429:
8430:
8431:
8432:
8433:
8434:
8435:
8436:
8437:
8438:
8439:
8440:
8441:
8442:
8443:
8444:
8445:
8446:
8447:
8448:
8449:
8450:
8451:
8452:
8453:
8454:
8455:
8456:
8457:
8458:
8459:
8460:
8461:
8462:
8463:
8464:
8465:
8466:
8467:
8468:
8469:
8470:
8471:
8472:
8473:
8474:
8475:
8476:
8477: 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);
8478:
8479: public static final boolean EFA_SEPARATE_AR = false;
8480:
8481:
8482:
8483:
8484:
8485:
8486: public static final boolean BUS_SPLIT_UNALIGNED_LONG = false;
8487:
8488:
8489: public static final int BUS_MOTHER_BITS = 24;
8490: public static final int BUS_MOTHER_SIZE = BUS_MOTHER_BITS < 32 ? 1 << BUS_MOTHER_BITS : 0;
8491: public static final int BUS_MOTHER_MASK = BUS_MOTHER_SIZE - 1;
8492:
8493: public static final int BUS_ARRAY_SIZE = BUS_MOTHER_SIZE;
8494:
8495:
8496: public static final int BUS_PAGE_BITS = 12;
8497: public static final int BUS_PAGE_SIZE = 1 << BUS_PAGE_BITS;
8498: public static final int BUS_PAGE_COUNT = 1 << (32 - BUS_PAGE_BITS);
8499:
8500:
8501: public static final int MPU_SS_BYTE = 0;
8502: public static final int MPU_SS_WORD = 1;
8503: public static final int MPU_SS_LONG = 2;
8504:
8505:
8506: public static final int MPU_WR_WRITE = 0;
8507: public static final int MPU_WR_READ = 1;
8508:
8509:
8510: public static final int MPU_US_USER = 0;
8511: public static final int MPU_US_SUPERVISOR = 1;
8512:
8513:
8514: public static final MemoryMappedDevice[] busUserMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8515: public static final MemoryMappedDevice[] busSuperMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8516: public static MemoryMappedDevice[] busMemoryMap;
8517:
8518:
8519: public static boolean busHimem68000;
8520:
8521:
8522: public static final int BUS_HIGH_MEMORY_START = 0x01000000;
8523: public static int busHighMemorySize;
8524: public static byte[] busHighMemoryArray;
8525: public static boolean busHighMemorySaveOn;
8526: public static boolean busHighMemory060turboOn;
8527:
8528:
8529: public static final int BUS_LOCAL_MEMORY_START = 0x10000000;
8530: public static int busLocalMemorySize;
8531: public static byte[] busLocalMemoryArray;
8532: public static boolean busLocalMemorySaveOn;
8533:
8534:
8535: public static final byte[] BUS_DUMMY_MEMORY_ARRAY = new byte[0];
8536: public static int busRequestExMemoryStart;
8537: public static int busRequestExMemorySize;
8538: public static byte[] busRequestExMemoryArray;
8539: public static int busExMemoryStart;
8540: public static int busExMemorySize;
8541: public static byte[] busExMemoryArray;
8542:
8543:
8544: public static boolean busRequestCutFC2Pin;
8545: public static boolean busCutFC2Pin;
8546:
8547:
8548:
8549: public static void busInit () {
8550:
8551:
8552: if (!DataBreakPoint.DBP_ON) {
8553: busMemoryMap = busSuperMap;
8554: }
8555:
8556:
8557: int highMemorySizeMB = Settings.sgsGetInt ("highmemory");
8558: busHighMemorySize = highMemorySizeMB == 16 ? highMemorySizeMB << 20 : 0 << 20;
8559: if (busHighMemorySize == 0) {
8560: System.out.println (Multilingual.mlnJapanese ?
8561: "X68030/Xellent30 のハイメモリはありません" :
8562: "X68030/Xellent30 high memory does not exists");
8563: } else {
8564: System.out.printf (Multilingual.mlnJapanese ?
8565: "X68030/Xellent30 のハイメモリのサイズは %dMB です\n" :
8566: "X68030/Xellent30 high memory size is %dMB\n",
8567: busHighMemorySize >> 20);
8568: }
8569: busHighMemoryArray = new byte[busHighMemorySize];
8570:
8571: busHimem68000 = Settings.sgsGetOnOff ("himem68000");
8572:
8573: busHighMemorySaveOn = Settings.sgsGetOnOff ("highmemorysave");
8574: busHighMemory060turboOn = Settings.sgsGetOnOff ("highmemory060turbo");
8575:
8576: byte[] highMemoryArray = Settings.sgsGetData ("highmemorydata");
8577: if (busHighMemorySize != 0) {
8578: if (highMemoryArray.length != 0) {
8579: System.out.println (Multilingual.mlnJapanese ?
8580: "X68030/Xellent30 のハイメモリのデータを復元します" :
8581: "X68030/Xellent30 high memory data is restored");
8582: System.arraycopy (highMemoryArray, 0, busHighMemoryArray, 0, Math.min (highMemoryArray.length, busHighMemorySize));
8583: } else {
8584: System.out.println (Multilingual.mlnJapanese ?
8585: "X68030/Xellent30 のハイメモリをゼロクリアします" :
8586: "X68030/Xellent30 high memory is zero-cleared");
8587: }
8588: if (highMemoryArray.length < busHighMemorySize) {
8589: Arrays.fill (busHighMemoryArray, highMemoryArray.length, busHighMemorySize, (byte) 0);
8590: }
8591: }
8592:
8593:
8594: int localMemorySizeMB = Settings.sgsGetInt ("localmemory");
8595: busLocalMemorySize = (localMemorySizeMB == 16 ||
8596: localMemorySizeMB == 32 ||
8597: localMemorySizeMB == 64 ||
8598: localMemorySizeMB == 128 ||
8599: localMemorySizeMB == 256 ||
8600: localMemorySizeMB == 384 ||
8601: localMemorySizeMB == 512 ||
8602: localMemorySizeMB == 768 ?
8603: localMemorySizeMB << 20 :
8604: 128 << 20);
8605: if (busLocalMemorySize == 0) {
8606: System.out.println (Multilingual.mlnJapanese ?
8607: "060turbo のハイメモリはありません" :
8608: "060turbo high memory does not exists");
8609: } else {
8610: System.out.printf (Multilingual.mlnJapanese ?
8611: "060turbo のハイメモリのサイズは %dMB です\n" :
8612: "060turbo high memory size is %dMB\n",
8613: busLocalMemorySize >> 20);
8614: }
8615: busLocalMemoryArray = new byte[busLocalMemorySize];
8616:
8617: busLocalMemorySaveOn = Settings.sgsGetOnOff ("localmemorysave");
8618:
8619: byte[] localMemoryArray = Settings.sgsGetData ("localmemorydata");
8620: if (busLocalMemorySize != 0) {
8621: if (localMemoryArray.length != 0) {
8622: System.out.println (Multilingual.mlnJapanese ?
8623: "060turbo のハイメモリのデータを復元します" :
8624: "060turbo high memory data is restored");
8625: System.arraycopy (localMemoryArray, 0, busLocalMemoryArray, 0, Math.min (localMemoryArray.length, busLocalMemorySize));
8626: } else {
8627: System.out.println (Multilingual.mlnJapanese ?
8628: "060turbo のハイメモリをゼロクリアします" :
8629: "060turbo high memory is zero-cleared");
8630: }
8631: if (localMemoryArray.length < busLocalMemorySize) {
8632: Arrays.fill (busLocalMemoryArray, localMemoryArray.length, busLocalMemorySize, (byte) 0);
8633: }
8634: }
8635:
8636:
8637: busExMemoryStart = busRequestExMemoryStart = 0x10000000;
8638: busExMemorySize = busRequestExMemorySize = 0 << 20;
8639: busExMemoryArray = busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
8640:
8641:
8642: busRequestCutFC2Pin = Settings.sgsGetOnOff ("cutfc2pin");
8643: busCutFC2Pin = !busRequestCutFC2Pin;
8644:
8645: busUpdateMemoryMap ();
8646:
8647: }
8648:
8649:
8650:
8651: public static void busTini () {
8652: Settings.sgsPutOnOff ("himem68000", busHimem68000);
8653: Settings.sgsPutInt ("highmemory", busHighMemorySize >>> 20);
8654: Settings.sgsPutOnOff ("highmemorysave", busHighMemorySaveOn);
8655: Settings.sgsPutOnOff ("highmemory060turbo", busHighMemory060turboOn);
8656: Settings.sgsPutData ("highmemorydata", busHighMemorySaveOn ? busHighMemoryArray : new byte[0]);
8657: Settings.sgsPutInt ("localmemory", busLocalMemorySize >>> 20);
8658: Settings.sgsPutOnOff ("localmemorysave", busLocalMemorySaveOn);
8659: Settings.sgsPutData ("localmemorydata", busLocalMemorySaveOn ? busLocalMemoryArray : new byte[0]);
8660: Settings.sgsPutOnOff ("cutfc2pin", busRequestCutFC2Pin);
8661: }
8662:
8663: public static void busUpdateMemoryMap () {
8664: if (busExMemoryStart == busRequestExMemoryStart &&
8665: busExMemorySize == busRequestExMemorySize &&
8666: busExMemoryArray == busRequestExMemoryArray &&
8667: busExMemoryArray.length == busExMemorySize &&
8668: busCutFC2Pin == busRequestCutFC2Pin) {
8669: return;
8670: }
8671:
8672: busExMemoryStart = busRequestExMemoryStart;
8673: busExMemorySize = busRequestExMemorySize;
8674: busExMemoryArray = busRequestExMemoryArray;
8675: if (busExMemoryArray.length != busExMemorySize) {
8676: byte[] newArray = new byte[busExMemorySize];
8677: int copySize = Math.min (busExMemoryArray.length, busExMemorySize);
8678: if (copySize > 0) {
8679: System.arraycopy (busExMemoryArray, 0, newArray, 0, copySize);
8680: }
8681: if (busExMemoryArray == busHighMemoryArray) {
8682: busHighMemoryArray = newArray;
8683: } else if (busExMemoryArray == busLocalMemoryArray) {
8684: busLocalMemoryArray = newArray;
8685: }
8686: busExMemoryArray = newArray;
8687: }
8688:
8689: busCutFC2Pin = busRequestCutFC2Pin;
8690:
8691:
8692:
8693:
8694:
8695:
8696:
8697:
8698:
8699:
8700:
8701:
8702: busSuper (MemoryMappedDevice.MMD_MMR, 0x00000000, 0x00002000);
8703: busUser ( MemoryMappedDevice.MMD_MMR, 0x00002000, 0x00c00000);
8704:
8705:
8706:
8707:
8708:
8709:
8710:
8711:
8712:
8713:
8714:
8715:
8716:
8717:
8718:
8719:
8720:
8721:
8722:
8723:
8724:
8725:
8726:
8727:
8728: busSuper (MemoryMappedDevice.MMD_GE0, 0x00c00000, 0x00c80000);
8729: busSuper (MemoryMappedDevice.MMD_GE1, 0x00c80000, 0x00d00000);
8730: busSuper (MemoryMappedDevice.MMD_GE2, 0x00d00000, 0x00d80000);
8731: busSuper (MemoryMappedDevice.MMD_GE3, 0x00d80000, 0x00e00000);
8732:
8733:
8734:
8735:
8736: busSuper (MemoryMappedDevice.MMD_TXT, 0x00e00000, 0x00e80000);
8737:
8738:
8739:
8740:
8741: busSuper (MemoryMappedDevice.MMD_CRT, 0x00e80000, 0x00e82000);
8742:
8743:
8744:
8745:
8746:
8747: busSuper (MemoryMappedDevice.MMD_VCN, 0x00e82000, 0x00e84000);
8748:
8749:
8750:
8751:
8752: busSuper (MemoryMappedDevice.MMD_DMA, 0x00e84000, 0x00e86000);
8753:
8754:
8755:
8756:
8757: busSuper (MemoryMappedDevice.MMD_SVS, 0x00e86000, 0x00e88000);
8758:
8759:
8760:
8761:
8762: busSuper (MemoryMappedDevice.MMD_MFP, 0x00e88000, 0x00e8a000);
8763:
8764:
8765:
8766:
8767: busSuper (MemoryMappedDevice.MMD_RTC_FIRST, 0x00e8a000, 0x00e8c000);
8768:
8769:
8770:
8771:
8772: busSuper (MemoryMappedDevice.MMD_PRN, 0x00e8c000, 0x00e8e000);
8773:
8774:
8775:
8776:
8777: busSuper (MemoryMappedDevice.MMD_SYS, 0x00e8e000, 0x00e90000);
8778:
8779:
8780:
8781:
8782: busSuper (MemoryMappedDevice.MMD_OPM, 0x00e90000, 0x00e92000);
8783:
8784:
8785:
8786:
8787: busSuper (MemoryMappedDevice.MMD_PCM, 0x00e92000, 0x00e94000);
8788:
8789:
8790:
8791:
8792: busSuper (MemoryMappedDevice.MMD_FDC, 0x00e94000, 0x00e96000);
8793:
8794:
8795:
8796:
8797:
8798: busSuper (MemoryMappedDevice.MMD_HDC, 0x00e96000, 0x00e98000);
8799:
8800:
8801:
8802:
8803: busSuper (MemoryMappedDevice.MMD_SCC, 0x00e98000, 0x00e9a000);
8804:
8805:
8806:
8807:
8808: busSuper (MemoryMappedDevice.MMD_PPI, 0x00e9a000, 0x00e9c000);
8809:
8810:
8811:
8812:
8813: busSuper (MemoryMappedDevice.MMD_IOI, 0x00e9c000, 0x00e9e000);
8814:
8815:
8816:
8817:
8818:
8819:
8820:
8821:
8822:
8823: busSuper (MemoryMappedDevice.MMD_XB1, 0x00e9e000, 0x00ea0000);
8824:
8825:
8826:
8827:
8828:
8829: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ea0000, 0x00eae000);
8830:
8831:
8832:
8833:
8834:
8835:
8836:
8837:
8838:
8839:
8840:
8841:
8842:
8843:
8844:
8845: busSuper (MemoryMappedDevice.MMD_XB2, 0x00eae000, 0x00eb0000);
8846:
8847:
8848:
8849:
8850:
8851:
8852:
8853:
8854: busSuper (MemoryMappedDevice.MMD_SPR, 0x00eb0000, 0x00ec0000);
8855:
8856:
8857:
8858:
8859:
8860:
8861:
8862:
8863:
8864:
8865:
8866:
8867:
8868: busSuper (MemoryMappedDevice.MMD_XB3, 0x00ec0000, 0x00ed0000);
8869:
8870:
8871:
8872:
8873:
8874:
8875: busSuper (MemoryMappedDevice.MMD_SMR, 0x00ed0000, 0x00ed0000 + 16384);
8876: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ed0000 + 16384, 0x00ed0000 + 65536);
8877:
8878:
8879:
8880:
8881:
8882:
8883:
8884:
8885: busSuper (MemoryMappedDevice.MMD_XB4, 0x00ee0000, 0x00f00000);
8886:
8887:
8888:
8889:
8890:
8891:
8892:
8893:
8894:
8895:
8896: busSuper (MemoryMappedDevice.MMD_ROM, 0x00f00000, 0x00f40000);
8897:
8898:
8899:
8900:
8901:
8902:
8903:
8904: busSuper (MemoryMappedDevice.MMD_ROM, 0x00f40000, 0x00fc0000);
8905:
8906:
8907:
8908:
8909:
8910:
8911:
8912:
8913:
8914:
8915:
8916:
8917:
8918:
8919: busSuper (MemoryMappedDevice.MMD_ROM, 0x00fc0000, 0x01000000);
8920:
8921: }
8922:
8923: public static void busReset () {
8924: if (regSRS != 0) {
8925: if (DataBreakPoint.DBP_ON) {
8926: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpSuperMap;
8927: } else {
8928: busMemoryMap = busSuperMap;
8929: }
8930: } else {
8931: if (DataBreakPoint.DBP_ON) {
8932: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpUserMap;
8933: } else {
8934: busMemoryMap = busUserMap;
8935: }
8936: }
8937: }
8938:
8939:
8940:
8941:
8942:
8943: public static void busUser (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8944: if (MC68060.CAT_ON) {
8945: if (Model.MPU_MC68LC060 <= currentMPU) {
8946: mmd = (mmd == MemoryMappedDevice.MMD_MMR ? MemoryMappedDevice.MMD_MM6 :
8947: mmd == MemoryMappedDevice.MMD_ROM ? MemoryMappedDevice.MMD_RO6 :
8948: mmd);
8949: }
8950: }
8951: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8952: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8953: if (false &&
8954: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8955: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8956: System.out.printf ("ERROR: busUser (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8957: }
8958: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8959: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8960: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8961: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8962: int startPage = blockStartPage + motherStartPage;
8963: int endPage = blockStartPage + motherEndPage;
8964: for (int page = startPage; page < endPage; page++) {
8965: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
8966: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
8967: if (MC68060.CAT_ON) {
8968: if (Model.MPU_MC68LC060 <= currentMPU &&
8969: isExMemory) {
8970: superMmd = MemoryMappedDevice.MMD_XM6;
8971: }
8972: }
8973: busUserMap[page] = busSuperMap[page] = superMmd;
8974: if (InstructionBreakPoint.IBP_ON) {
8975: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8976: InstructionBreakPoint.ibpUserMap[page] = superMmd;
8977: }
8978: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8979: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8980: }
8981: }
8982: if (DataBreakPoint.DBP_ON) {
8983: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8984: DataBreakPoint.dbpUserMap[page] = superMmd;
8985: }
8986: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8987: DataBreakPoint.dbpSuperMap[page] = superMmd;
8988: }
8989: }
8990: }
8991: }
8992: }
8993:
8994:
8995:
8996:
8997:
8998: public static void busSuper (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8999: if (MC68060.CAT_ON) {
9000: if (Model.MPU_MC68LC060 <= currentMPU) {
9001: mmd = (mmd == MemoryMappedDevice.MMD_MMR ? MemoryMappedDevice.MMD_MM6 :
9002: mmd == MemoryMappedDevice.MMD_ROM ? MemoryMappedDevice.MMD_RO6 :
9003: mmd);
9004: }
9005: }
9006: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
9007: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
9008: if (false &&
9009: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
9010: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
9011: System.out.printf ("ERROR: busSuper (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
9012: }
9013: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
9014: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
9015: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
9016: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
9017: int startPage = blockStartPage + motherStartPage;
9018: int endPage = blockStartPage + motherEndPage;
9019: for (int page = startPage; page < endPage; page++) {
9020: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
9021: MemoryMappedDevice userMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : busCutFC2Pin ? mmd : MemoryMappedDevice.MMD_NUL;
9022: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
9023: if (MC68060.CAT_ON) {
9024: if (Model.MPU_MC68LC060 <= currentMPU &&
9025: isExMemory) {
9026: userMmd = MemoryMappedDevice.MMD_XM6;
9027: superMmd = MemoryMappedDevice.MMD_XM6;
9028: }
9029: }
9030: busUserMap[page] = userMmd;
9031: busSuperMap[page] = superMmd;
9032: if (InstructionBreakPoint.IBP_ON) {
9033: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
9034: InstructionBreakPoint.ibpUserMap[page] = userMmd;
9035: }
9036: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
9037: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
9038: }
9039: }
9040: if (DataBreakPoint.DBP_ON) {
9041: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
9042: DataBreakPoint.dbpUserMap[page] = userMmd;
9043: }
9044: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
9045: DataBreakPoint.dbpSuperMap[page] = superMmd;
9046: }
9047: }
9048: }
9049: }
9050: }
9051:
9052:
9053:
9054: public static byte busPbs (int a) {
9055: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a);
9056: }
9057:
9058:
9059:
9060: public static int busPbz (int a) {
9061: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a);
9062: }
9063:
9064:
9065:
9066: public static int busPws (int a) {
9067: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9068: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
9069: } else {
9070: int a1 = a + 1;
9071: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
9072: }
9073: }
9074:
9075:
9076:
9077: public static int busPwse (int a) {
9078: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
9079: }
9080:
9081:
9082:
9083: public static int busPwz (int a) {
9084: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9085: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
9086: } else {
9087: int a1 = a + 1;
9088: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
9089: }
9090: }
9091:
9092:
9093:
9094: public static int busPwze (int a) {
9095: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
9096: }
9097:
9098:
9099:
9100: public static int busPls (int a) {
9101: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9102: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
9103: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9104: int a2 = a + 2;
9105: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a) << 16 | busSuperMap[a2 >>> BUS_PAGE_BITS].mmdPwz (a2);
9106: } else {
9107: int a1 = a + 1;
9108: int a3 = a + 3;
9109: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 24 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPwz (a1) << 8 | busSuperMap[a3 >>> BUS_PAGE_BITS].mmdPbz (a3);
9110: }
9111: }
9112:
9113:
9114:
9115: public static int busPlsf (int a) {
9116: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
9117: }
9118:
9119:
9120:
9121: public static long busPqs (int a) {
9122: return (long) busPls (a) << 32 | busPls (a + 4) & 0xffffffffL;
9123: }
9124:
9125:
9126:
9127: public static int busSearchByte (int start, int end, int c) {
9128: for (int a = start; a < end; a++) {
9129: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) == c) {
9130: return a;
9131: }
9132: }
9133: return -1;
9134: }
9135: public static int busSearchWord (int start, int end, int c) {
9136: for (int a = start; a < end; a += 2) {
9137: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) == c) {
9138: return a;
9139: }
9140: }
9141: return -1;
9142: }
9143: public static int busSearchByteArray (int start, int end, int[] array) {
9144: int l = array.length;
9145: end -= l;
9146: int c = array[0];
9147: a:
9148: for (int a = start; a <= end; a++) {
9149: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) != c) {
9150: continue a;
9151: }
9152: for (int i = 1, b = a + 1; i < l; i++, b++) {
9153: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPbz (b) != array[i]) {
9154: continue a;
9155: }
9156: }
9157: return a;
9158: }
9159: return -1;
9160: }
9161: public static int busSearchWordArray (int start, int end, int[] array) {
9162: int l = array.length;
9163: end -= l;
9164: int c = array[0];
9165: a:
9166: for (int a = start; a <= end; a += 2) {
9167: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) != c) {
9168: continue a;
9169: }
9170: for (int i = 1, b = a + 2; i < l; i++, b += 2) {
9171: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPwz (b) != array[i]) {
9172: continue a;
9173: }
9174: }
9175: return a;
9176: }
9177: return -1;
9178: }
9179:
9180:
9181:
9182:
9183: public static byte busRbs (int a) throws M68kException {
9184: if (DataBreakPoint.DBP_ON) {
9185: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
9186: } else {
9187: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
9188: }
9189: }
9190:
9191:
9192:
9193: public static int busRbz (int a) throws M68kException {
9194: if (DataBreakPoint.DBP_ON) {
9195: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
9196: } else {
9197: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
9198: }
9199: }
9200:
9201:
9202:
9203: public static int busRws (int a) throws M68kException {
9204: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9205: if (DataBreakPoint.DBP_ON) {
9206: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
9207: } else {
9208: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
9209: }
9210: } else if (mpuIgnoreAddressError) {
9211: int a1 = a + 1;
9212: if (DataBreakPoint.DBP_ON) {
9213: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
9214: } else {
9215: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
9216: }
9217: } else {
9218: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9219: M68kException.m6eAddress = a;
9220: M68kException.m6eDirection = MPU_WR_READ;
9221: M68kException.m6eSize = MPU_SS_WORD;
9222: throw M68kException.m6eSignal;
9223: }
9224: }
9225:
9226:
9227:
9228:
9229: public static int busRwse (int a) throws M68kException {
9230: if (DataBreakPoint.DBP_ON) {
9231: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
9232: } else {
9233: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
9234: }
9235: }
9236:
9237:
9238:
9239: public static int busRwz (int a) throws M68kException {
9240: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9241: if (DataBreakPoint.DBP_ON) {
9242: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9243: } else {
9244: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9245: }
9246: } else if (mpuIgnoreAddressError) {
9247: int a1 = a + 1;
9248: if (DataBreakPoint.DBP_ON) {
9249: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
9250: } else {
9251: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
9252: }
9253: } else {
9254: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9255: M68kException.m6eAddress = a;
9256: M68kException.m6eDirection = MPU_WR_READ;
9257: M68kException.m6eSize = MPU_SS_WORD;
9258: throw M68kException.m6eSignal;
9259: }
9260: }
9261:
9262:
9263:
9264:
9265: public static int busRwze (int a) throws M68kException {
9266: if (DataBreakPoint.DBP_ON) {
9267: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9268: } else {
9269: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9270: }
9271: }
9272:
9273:
9274:
9275: public static int busRls (int a) throws M68kException {
9276: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9277: if (DataBreakPoint.DBP_ON) {
9278: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9279: } else {
9280: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9281: }
9282: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9283: int a2 = a + 2;
9284: if (BUS_SPLIT_UNALIGNED_LONG) {
9285: if (DataBreakPoint.DBP_ON) {
9286: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9287: } else {
9288: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9289: }
9290: } else {
9291: MemoryMappedDevice mmd;
9292: MemoryMappedDevice mmd2;
9293: if (DataBreakPoint.DBP_ON) {
9294: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9295: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9296: } else {
9297: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9298: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9299: }
9300: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
9301: }
9302: } else if (mpuIgnoreAddressError) {
9303: int a1 = a + 1;
9304: int a3 = a + 3;
9305: if (DataBreakPoint.DBP_ON) {
9306: 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);
9307: } else {
9308: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 24 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRwz (a1) << 8 | busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdRbz (a3);
9309: }
9310: } else {
9311: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9312: M68kException.m6eAddress = a;
9313: M68kException.m6eDirection = MPU_WR_READ;
9314: M68kException.m6eSize = MPU_SS_LONG;
9315: throw M68kException.m6eSignal;
9316: }
9317: }
9318:
9319:
9320:
9321:
9322: public static int busRlse (int a) throws M68kException {
9323: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9324: if (DataBreakPoint.DBP_ON) {
9325: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9326: } else {
9327: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9328: }
9329: } else {
9330: int a2 = a + 2;
9331: if (BUS_SPLIT_UNALIGNED_LONG) {
9332: if (DataBreakPoint.DBP_ON) {
9333: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9334: } else {
9335: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9336: }
9337: } else {
9338: MemoryMappedDevice mmd;
9339: MemoryMappedDevice mmd2;
9340: if (DataBreakPoint.DBP_ON) {
9341: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9342: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9343: } else {
9344: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9345: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9346: }
9347: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
9348: }
9349: }
9350: }
9351:
9352:
9353:
9354:
9355: public static int busRlsf (int a) throws M68kException {
9356: if (DataBreakPoint.DBP_ON) {
9357: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9358: } else {
9359: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9360: }
9361: }
9362:
9363:
9364:
9365: public static long busRqs (int a) throws M68kException {
9366: return (long) busRls (a) << 32 | busRls (a + 4) & 0xffffffffL;
9367: }
9368:
9369:
9370:
9371: public static void busWb (int a, int d) throws M68kException {
9372: if (DataBreakPoint.DBP_ON) {
9373: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9374: } else {
9375: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9376: }
9377: }
9378:
9379:
9380:
9381: public static void busWw (int a, int d) throws M68kException {
9382: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9383: if (DataBreakPoint.DBP_ON) {
9384: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9385: } else {
9386: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9387: }
9388: } else if (mpuIgnoreAddressError) {
9389: int a1 = a + 1;
9390: if (DataBreakPoint.DBP_ON) {
9391: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
9392: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
9393: } else {
9394: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
9395: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
9396: }
9397: } else {
9398: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9399: M68kException.m6eAddress = a;
9400: M68kException.m6eDirection = MPU_WR_WRITE;
9401: M68kException.m6eSize = MPU_SS_WORD;
9402: throw M68kException.m6eSignal;
9403: }
9404: }
9405:
9406:
9407:
9408:
9409: public static void busWwe (int a, int d) throws M68kException {
9410: if (DataBreakPoint.DBP_ON) {
9411: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9412: } else {
9413: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9414: }
9415: }
9416:
9417:
9418:
9419: public static void busWl (int a, int d) throws M68kException {
9420: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9421: if (DataBreakPoint.DBP_ON) {
9422: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9423: } else {
9424: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9425: }
9426: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9427: int a2 = a + 2;
9428: if (BUS_SPLIT_UNALIGNED_LONG) {
9429: if (DataBreakPoint.DBP_ON) {
9430: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9431: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9432: } else {
9433: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9434: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9435: }
9436: } else {
9437: MemoryMappedDevice mmd;
9438: MemoryMappedDevice mmd2;
9439: if (DataBreakPoint.DBP_ON) {
9440: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9441: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9442: } else {
9443: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9444: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9445: }
9446: if (mmd == mmd2) {
9447: mmd.mmdWl (a, d);
9448: } else {
9449: mmd.mmdWw (a, d >> 16);
9450: mmd2.mmdWw (a2, d);
9451: }
9452: }
9453: } else if (mpuIgnoreAddressError) {
9454: int a1 = a + 1;
9455: int a3 = a + 3;
9456: if (DataBreakPoint.DBP_ON) {
9457: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
9458: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
9459: DataBreakPoint.dbpMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
9460: } else {
9461: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
9462: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
9463: busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
9464: }
9465: } else {
9466: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9467: M68kException.m6eAddress = a;
9468: M68kException.m6eDirection = MPU_WR_WRITE;
9469: M68kException.m6eSize = MPU_SS_LONG;
9470: throw M68kException.m6eSignal;
9471: }
9472: }
9473:
9474:
9475:
9476:
9477: public static void busWlf (int a, int d) throws M68kException {
9478: if (DataBreakPoint.DBP_ON) {
9479: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9480: } else {
9481: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9482: }
9483: }
9484:
9485:
9486:
9487:
9488: public static void busWle (int a, int d) throws M68kException {
9489: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9490: if (DataBreakPoint.DBP_ON) {
9491: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9492: } else {
9493: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9494: }
9495: } else {
9496: int a2 = a + 2;
9497: if (BUS_SPLIT_UNALIGNED_LONG) {
9498: if (DataBreakPoint.DBP_ON) {
9499: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9500: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9501: } else {
9502: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9503: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9504: }
9505: } else {
9506: MemoryMappedDevice mmd;
9507: MemoryMappedDevice mmd2;
9508: if (DataBreakPoint.DBP_ON) {
9509: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9510: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9511: } else {
9512: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9513: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9514: }
9515: if (mmd == mmd2) {
9516: mmd.mmdWl (a, d);
9517: } else {
9518: mmd.mmdWw (a, d >> 16);
9519: mmd2.mmdWw (a2, d);
9520: }
9521: }
9522: }
9523: }
9524:
9525:
9526:
9527: public static void busWq (int a, long d) throws M68kException {
9528: busWl (a, (int) (d >>> 32));
9529: busWl (a + 4, (int) d);
9530: }
9531:
9532:
9533:
9534:
9535:
9536: public static void busRbb (int a, byte[] bb, int o, int l) throws M68kException {
9537: if (false) {
9538: for (int i = 0; i < l; i++) {
9539: int ai = a + i;
9540: if (DataBreakPoint.DBP_ON) {
9541: bb[o + i] = DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9542: } else {
9543: bb[o + i] = busMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9544: }
9545: }
9546: } else {
9547: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9548: while (l > 0) {
9549: MemoryMappedDevice mmd;
9550: if (DataBreakPoint.DBP_ON) {
9551: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9552: } else {
9553: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9554: }
9555: int s = l <= r ? l : r;
9556: l -= s;
9557: if (true) {
9558: for (s -= 16; s >= 0; s -= 16) {
9559: bb[o ] = mmd.mmdRbs (a );
9560: bb[o + 1] = mmd.mmdRbs (a + 1);
9561: bb[o + 2] = mmd.mmdRbs (a + 2);
9562: bb[o + 3] = mmd.mmdRbs (a + 3);
9563: bb[o + 4] = mmd.mmdRbs (a + 4);
9564: bb[o + 5] = mmd.mmdRbs (a + 5);
9565: bb[o + 6] = mmd.mmdRbs (a + 6);
9566: bb[o + 7] = mmd.mmdRbs (a + 7);
9567: bb[o + 8] = mmd.mmdRbs (a + 8);
9568: bb[o + 9] = mmd.mmdRbs (a + 9);
9569: bb[o + 10] = mmd.mmdRbs (a + 10);
9570: bb[o + 11] = mmd.mmdRbs (a + 11);
9571: bb[o + 12] = mmd.mmdRbs (a + 12);
9572: bb[o + 13] = mmd.mmdRbs (a + 13);
9573: bb[o + 14] = mmd.mmdRbs (a + 14);
9574: bb[o + 15] = mmd.mmdRbs (a + 15);
9575: a += 16;
9576: o += 16;
9577: }
9578: s += 16;
9579: }
9580: for (int i = 0; i < s; i++) {
9581: bb[o + i] = mmd.mmdRbs (a + i);
9582: }
9583: a += s;
9584: o += s;
9585: r = BUS_PAGE_SIZE;
9586: }
9587: }
9588: }
9589:
9590:
9591:
9592: public static void busWbb (int a, byte[] bb, int o, int l) throws M68kException {
9593: if (false) {
9594: for (int i = 0; i < l; i++) {
9595: int ai = a + i;
9596: if (DataBreakPoint.DBP_ON) {
9597: DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9598: } else {
9599: busMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9600: }
9601: }
9602: } else {
9603: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9604: while (l > 0) {
9605: MemoryMappedDevice mmd;
9606: if (DataBreakPoint.DBP_ON) {
9607: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9608: } else {
9609: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9610: }
9611: int s = l <= r ? l : r;
9612: l -= s;
9613: if (true) {
9614: for (s -= 16; s >= 0; s -= 16) {
9615: mmd.mmdWb (a , bb[o ]);
9616: mmd.mmdWb (a + 1, bb[o + 1]);
9617: mmd.mmdWb (a + 2, bb[o + 2]);
9618: mmd.mmdWb (a + 3, bb[o + 3]);
9619: mmd.mmdWb (a + 4, bb[o + 4]);
9620: mmd.mmdWb (a + 5, bb[o + 5]);
9621: mmd.mmdWb (a + 6, bb[o + 6]);
9622: mmd.mmdWb (a + 7, bb[o + 7]);
9623: mmd.mmdWb (a + 8, bb[o + 8]);
9624: mmd.mmdWb (a + 9, bb[o + 9]);
9625: mmd.mmdWb (a + 10, bb[o + 10]);
9626: mmd.mmdWb (a + 11, bb[o + 11]);
9627: mmd.mmdWb (a + 12, bb[o + 12]);
9628: mmd.mmdWb (a + 13, bb[o + 13]);
9629: mmd.mmdWb (a + 14, bb[o + 14]);
9630: mmd.mmdWb (a + 15, bb[o + 15]);
9631: a += 16;
9632: o += 16;
9633: }
9634: s += 16;
9635: }
9636: for (int i = 0; i < s; i++) {
9637: mmd.mmdWb (a + i, bb[o + i]);
9638: }
9639: a += s;
9640: o += s;
9641: r = BUS_PAGE_SIZE;
9642: }
9643: }
9644: }
9645:
9646:
9647:
9648: public static void busVb (int a, int d) {
9649: try {
9650: if (DataBreakPoint.DBP_ON) {
9651: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9652: } else {
9653: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9654: }
9655: } catch (M68kException e) {
9656: }
9657: }
9658:
9659:
9660:
9661: public static void busVw (int a, int d) {
9662: try {
9663: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9664: if (DataBreakPoint.DBP_ON) {
9665: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9666: } else {
9667: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9668: }
9669: }
9670: } catch (M68kException e) {
9671: }
9672: }
9673:
9674:
9675:
9676: public static void busVl (int a, int d) {
9677: try {
9678: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9679: if (DataBreakPoint.DBP_ON) {
9680: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9681: } else {
9682: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9683: }
9684: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9685: int a2 = a + 2;
9686: MemoryMappedDevice mmd;
9687: MemoryMappedDevice mmd2;
9688: if (DataBreakPoint.DBP_ON) {
9689: mmd = (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS];
9690: mmd2 = (regSRS != 0 ? busSuperMap : busUserMap)[a2 >>> BUS_PAGE_BITS];
9691: } else {
9692: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9693: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9694: }
9695: if (mmd == mmd2) {
9696: mmd.mmdWl (a, d);
9697: } else {
9698: mmd.mmdWw (a, d >> 16);
9699: mmd2.mmdWw (a2, d);
9700: }
9701: }
9702: } catch (M68kException e) {
9703: }
9704: }
9705:
9706:
9707:
9708:
9709:
9710: public static final int SVS_AREASET = 0x00e86001;
9711:
9712:
9713:
9714:
9715:
9716:
9717:
9718:
9719:
9720: public static void svsInit () {
9721: }
9722:
9723:
9724:
9725:
9726:
9727:
9728:
9729:
9730:
9731:
9732:
9733:
9734:
9735:
9736:
9737:
9738:
9739:
9740:
9741:
9742:
9743:
9744:
9745:
9746:
9747:
9748:
9749:
9750:
9751:
9752:
9753:
9754:
9755:
9756:
9757: public static boolean sysNMIFlag;
9758:
9759:
9760:
9761: public static void sysInit () {
9762: sysNMIFlag = false;
9763: }
9764:
9765:
9766:
9767:
9768:
9769:
9770: public static int sysAcknowledge () {
9771: return M68kException.M6E_LEVEL_7_INTERRUPT_AUTOVECTOR;
9772: }
9773:
9774:
9775:
9776:
9777: public static void sysDone () {
9778: if (sysNMIFlag) {
9779: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9780: }
9781: }
9782:
9783:
9784:
9785: public static void sysInterrupt () {
9786: sysNMIFlag = true;
9787: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9788: }
9789:
9790:
9791:
9792: public static void sysResetNMI () {
9793: sysNMIFlag = false;
9794: }
9795:
9796:
9797:
9798:
9799:
9800:
9801: public static final int EB2_SPC_REQUEST = 0x4000;
9802: public static final int EB2_SPC_VECTOR = 0xf6;
9803:
9804:
9805:
9806: public static int eb2Request;
9807:
9808:
9809:
9810: public static void eb2Reset () {
9811: eb2Request = 0;
9812: }
9813:
9814:
9815:
9816:
9817:
9818: public static void eb2Interrupt (int mask) {
9819: eb2Request |= mask;
9820: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9821: }
9822:
9823:
9824:
9825:
9826:
9827:
9828:
9829: public static int eb2Acknowledge () {
9830: if ((eb2Request & EB2_SPC_REQUEST) != 0) {
9831: eb2Request &= ~EB2_SPC_REQUEST;
9832: return EB2_SPC_VECTOR;
9833: }
9834: return 0;
9835: }
9836:
9837:
9838:
9839:
9840:
9841: public static void eb2Done () {
9842: if (eb2Request != 0) {
9843: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9844: }
9845: }
9846:
9847:
9848:
9849:
9850:
9851:
9852:
9853:
9854:
9855:
9856:
9857:
9858:
9859:
9860:
9861:
9862:
9863:
9864:
9865:
9866:
9867:
9868:
9869:
9870:
9871:
9872:
9873:
9874:
9875:
9876:
9877:
9878:
9879:
9880:
9881:
9882:
9883:
9884:
9885:
9886:
9887:
9888:
9889:
9890:
9891:
9892:
9893:
9894:
9895:
9896:
9897:
9898:
9899:
9900:
9901:
9902:
9903:
9904:
9905:
9906:
9907:
9908:
9909:
9910: public static final int BNK_SIZE = 1024 * 1024 * 32;
9911: public static byte[] bnkMemory;
9912: public static int bnkPageStart;
9913: public static boolean bnkOn;
9914:
9915: public static void bnkInit () {
9916: bnkMemory = new byte[BNK_SIZE];
9917: byte[] array = Settings.sgsGetData ("bankdata");
9918: if (array.length != 0) {
9919: System.arraycopy (array, 0, bnkMemory, 0, Math.min (array.length, BNK_SIZE));
9920: }
9921: bnkPageStart = 0;
9922:
9923: bnkOn = false;
9924: }
9925:
9926: public static void bnkTini () {
9927: Settings.sgsPutData ("bankdata", bnkMemory, 0, BNK_SIZE);
9928: }
9929:
9930:
9931:
9932:
9933:
9934:
9935:
9936: public static ExpressionEvaluator fpuMotherboardCoprocessor;
9937: public static ExpressionEvaluator fpuOnChipFPU;
9938: public static ExpressionEvaluator fpuBox;
9939:
9940:
9941: public static EFPBox fpuCoproboard1;
9942: public static EFPBox fpuCoproboard2;
9943:
9944:
9945: public static EFPBox.EFP[] fpuFPn;
9946:
9947:
9948:
9949: public static final int FPU_FPCR_BSUN = 0b00000000_00000000_10000000_00000000;
9950: public static final int FPU_FPCR_SNAN = 0b00000000_00000000_01000000_00000000;
9951: public static final int FPU_FPCR_OPERR = 0b00000000_00000000_00100000_00000000;
9952: public static final int FPU_FPCR_OVFL = 0b00000000_00000000_00010000_00000000;
9953: public static final int FPU_FPCR_UNFL = 0b00000000_00000000_00001000_00000000;
9954: public static final int FPU_FPCR_DZ = 0b00000000_00000000_00000100_00000000;
9955: public static final int FPU_FPCR_INEX2 = 0b00000000_00000000_00000010_00000000;
9956: public static final int FPU_FPCR_INEX1 = 0b00000000_00000000_00000001_00000000;
9957:
9958:
9959: public static final int FPU_FPCR_PE = 0b00000000_00000000_00000000_00000000;
9960: public static final int FPU_FPCR_PS = 0b00000000_00000000_00000000_01000000;
9961: public static final int FPU_FPCR_PD = 0b00000000_00000000_00000000_10000000;
9962:
9963: public static final int FPU_FPCR_RN = 0b00000000_00000000_00000000_00000000;
9964: public static final int FPU_FPCR_RZ = 0b00000000_00000000_00000000_00010000;
9965: public static final int FPU_FPCR_RM = 0b00000000_00000000_00000000_00100000;
9966: public static final int FPU_FPCR_RP = 0b00000000_00000000_00000000_00110000;
9967:
9968:
9969:
9970: public static final int FPU_FPSR_N = 0b00001000_00000000_00000000_00000000;
9971: public static final int FPU_FPSR_Z = 0b00000100_00000000_00000000_00000000;
9972: public static final int FPU_FPSR_I = 0b00000010_00000000_00000000_00000000;
9973: public static final int FPU_FPSR_NAN = 0b00000001_00000000_00000000_00000000;
9974:
9975: public static final int FPU_FPSR_S = 0b00000000_10000000_00000000_00000000;
9976: public static final int FPU_FPSR_QUOTIENT = 0b00000000_01111111_00000000_00000000;
9977:
9978: public static final int FPU_FPSR_EXC_BSUN = 0b00000000_00000000_10000000_00000000;
9979: public static final int FPU_FPSR_EXC_SNAN = 0b00000000_00000000_01000000_00000000;
9980: public static final int FPU_FPSR_EXC_OPERR = 0b00000000_00000000_00100000_00000000;
9981: public static final int FPU_FPSR_EXC_OVFL = 0b00000000_00000000_00010000_00000000;
9982: public static final int FPU_FPSR_EXC_UNFL = 0b00000000_00000000_00001000_00000000;
9983: public static final int FPU_FPSR_EXC_DZ = 0b00000000_00000000_00000100_00000000;
9984: public static final int FPU_FPSR_EXC_INEX2 = 0b00000000_00000000_00000010_00000000;
9985: public static final int FPU_FPSR_EXC_INEX1 = 0b00000000_00000000_00000001_00000000;
9986:
9987: public static final int FPU_FPSR_AEXC_IOP = 0b00000000_00000000_00000000_10000000;
9988: public static final int FPU_FPSR_AEXC_OVFL = 0b00000000_00000000_00000000_01000000;
9989: public static final int FPU_FPSR_AEXC_UNFL = 0b00000000_00000000_00000000_00100000;
9990: public static final int FPU_FPSR_AEXC_DZ = 0b00000000_00000000_00000000_00010000;
9991: public static final int FPU_FPSR_AEXC_INEX = 0b00000000_00000000_00000000_00001000;
9992:
9993:
9994:
9995:
9996:
9997:
9998:
9999: public static final int[] FPU_FPSR_EXC_TO_AEXC = new int[256];
10000:
10001:
10002:
10003:
10004:
10005:
10006:
10007:
10008:
10009:
10010:
10011:
10012:
10013:
10014:
10015:
10016:
10017:
10018:
10019:
10020:
10021:
10022:
10023:
10024: public static final boolean[] FPU_CCMAP_882 = {
10025:
10026:
10027: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10028: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10029: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10030: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10031: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10032: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10033: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10034: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
10035: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10036: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10037: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10038: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10039: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10040: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10041: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
10042: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10043:
10044:
10045: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10046: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10047: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10048: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10049: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10050: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10051: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10052: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
10053: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10054: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10055: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10056: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10057: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10058: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10059: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
10060: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10061:
10062: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10063: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10064: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10065: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10066: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10067: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10068: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10069: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
10070: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10071: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10072: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10073: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10074: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10075: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10076: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
10077: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10078:
10079: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10080: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10081: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10082: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10083: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10084: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10085: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10086: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
10087: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10088: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10089: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10090: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10091: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10092: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10093: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
10094: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10095: };
10096:
10097:
10098:
10099:
10100:
10101:
10102:
10103: public static final boolean[] FPU_CCMAP_060 = {
10104:
10105:
10106: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10107: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10108: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10109: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10110: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10111: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10112: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10113: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
10114: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10115: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10116: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10117: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10118: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10119: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10120: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
10121: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10122:
10123:
10124: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10125: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10126: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10127: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10128: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10129: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10130: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10131: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
10132: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10133: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10134: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10135: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10136: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10137: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10138: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
10139: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10140:
10141: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10142: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10143: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10144: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10145: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10146: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10147: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10148: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
10149: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10150: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10151: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10152: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10153: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10154: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10155: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
10156: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10157:
10158: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10159: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10160: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10161: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10162: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10163: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10164: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10165: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
10166: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10167: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10168: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10169: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10170: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10171: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10172: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
10173: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10174: };
10175:
10176:
10177:
10178:
10179: public static void fpuInit () {
10180: for (int i = 0; i < 256; i++) {
10181: 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) |
10182: ((i << 8 & FPU_FPSR_EXC_OVFL) != 0 ? FPU_FPSR_AEXC_OVFL : 0) |
10183: ((i << 8 & (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2)) == (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2) ? FPU_FPSR_AEXC_UNFL : 0) |
10184: ((i << 8 & FPU_FPSR_EXC_DZ) != 0 ? FPU_FPSR_AEXC_DZ : 0) |
10185: ((i << 8 & (FPU_FPSR_EXC_OVFL | FPU_FPSR_EXC_INEX2 | FPU_FPSR_EXC_INEX1)) != 0 ? FPU_FPSR_AEXC_INEX : 0));
10186: }
10187:
10188: fpuMotherboardCoprocessor = new ExpressionEvaluator ();
10189:
10190: fpuOnChipFPU = new ExpressionEvaluator ();
10191:
10192: fpuBox = currentMPU < Model.MPU_MC68LC040 ? fpuMotherboardCoprocessor : fpuOnChipFPU;
10193:
10194: fpuFPn = fpuBox.epbFPn;
10195:
10196: fpuCoproboard1 = new EFPBox ();
10197: fpuCoproboard2 = new EFPBox ();
10198: }
10199:
10200:
10201:
10202:
10203:
10204:
10205: public static final boolean DBG_ORI_BYTE_ZERO_D0 = true;
10206:
10207: public static boolean dbgHexSelected;
10208: public static int dbgHexValue;
10209: public static int dbgSupervisorMode;
10210: public static JPopupMenu dbgPopupMenu;
10211: public static JMenu dbgPopupIBPMenu;
10212: public static SpinnerNumberModel dbgPopupIBPCurrentModel;
10213: public static int dbgPopupIBPCurrentValue;
10214: public static SpinnerNumberModel dbgPopupIBPThresholdModel;
10215: public static int dbgPopupIBPThresholdValue;
10216: public static JMenuItem dbgPopupIBPClearMenuItem;
10217: public static JMenu dbgPopupHexMenu;
10218: public static JMenuItem dbgPopupDisMenuItem;
10219: public static JMenuItem dbgPopupMemMenuItem;
10220: public static JMenuItem dbgPopupCopyMenuItem;
10221: public static JMenuItem dbgPopupSelectAllMenuItem;
10222: public static JTextArea dbgPopupTextArea;
10223: public static int dbgEventMask;
10224: public static boolean dbgStopOnError;
10225: public static boolean dbgOriByteZeroD0;
10226: public static boolean dbgStopAtStart;
10227:
10228:
10229:
10230: public static final char[] DBG_SPACES = (
10231:
10232:
10233: " ").toCharArray ();
10234:
10235: public static final int DBG_DRP_VISIBLE_MASK = 1;
10236: public static final int DBG_DDP_VISIBLE_MASK = 2;
10237: public static final int DBG_DMP_VISIBLE_MASK = 4;
10238: public static final int DBG_BLG_VISIBLE_MASK = 8;
10239: public static final int DBG_PFV_VISIBLE_MASK = 16;
10240: public static final int DBG_RBP_VISIBLE_MASK = 32;
10241: public static final int DBG_DBP_VISIBLE_MASK = 64;
10242: public static final int DBG_SMT_VISIBLE_MASK = 128;
10243: public static final int DBG_ATW_VISIBLE_MASK = 256;
10244: public static final int DBG_PAA_VISIBLE_MASK = 512;
10245: public static final int DBG_RTL_VISIBLE_MASK = 1024;
10246: public static final int DBG_SPV_VISIBLE_MASK = 2048;
10247: public static final int DBG_PLV_VISIBLE_MASK = 4096;
10248: public static final int DBG_ACM_VISIBLE_MASK = 8192;
10249: public static int dbgVisibleMask;
10250:
10251:
10252:
10253: public static void dbgInit () {
10254: dbgVisibleMask = 0;
10255: dbgHexSelected = false;
10256: dbgHexValue = 0;
10257: dbgSupervisorMode = 1;
10258: dbgPopupMenu = null;
10259: dbgPopupDisMenuItem = null;
10260: dbgPopupMemMenuItem = null;
10261: dbgPopupCopyMenuItem = null;
10262: dbgPopupSelectAllMenuItem = null;
10263: dbgPopupIBPMenu = null;
10264: dbgPopupIBPCurrentModel = null;
10265: dbgPopupIBPCurrentValue = 0;
10266: dbgPopupIBPThresholdModel = null;
10267: dbgPopupIBPThresholdValue = 0;
10268: dbgPopupHexMenu = null;
10269: dbgPopupTextArea = null;
10270: dbgEventMask = 0;
10271: dbgStopOnError = false;
10272: if (DBG_ORI_BYTE_ZERO_D0) {
10273: dbgOriByteZeroD0 = false;
10274: }
10275: dbgStopAtStart = false;
10276: }
10277:
10278:
10279:
10280: public static void dbgMakePopup () {
10281:
10282:
10283: ActionListener popupActionListener = new ActionListener () {
10284: @Override public void actionPerformed (ActionEvent ae) {
10285: switch (ae.getActionCommand ()) {
10286: case "Disassemble":
10287: DisassembleList.ddpBacktraceRecord = -1L;
10288: DisassembleList.ddpOpen (dbgHexValue, dbgSupervisorMode, false);
10289: break;
10290: case "Memory Dump":
10291: MemoryDumpList.dmpOpen (dbgHexValue, dbgSupervisorMode != 0 ? 5 : 1, false);
10292: break;
10293: case "Run to Here":
10294: if (InstructionBreakPoint.IBP_ON) {
10295: if (mpuTask == null) {
10296: InstructionBreakPoint.ibpInstant (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
10297: mpuStart ();
10298: }
10299: }
10300: break;
10301: case "Set Breakpoint":
10302: if (InstructionBreakPoint.IBP_ON) {
10303: InstructionBreakPoint.ibpPut (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode, dbgPopupIBPCurrentValue, dbgPopupIBPThresholdValue, null);
10304: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
10305: }
10306: break;
10307: case "Clear Breakpoint":
10308: if (InstructionBreakPoint.IBP_ON) {
10309: InstructionBreakPoint.ibpRemove (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
10310: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
10311: }
10312: break;
10313: case "Copy":
10314: dbgCopy ();
10315: break;
10316: case "Select All":
10317: dbgSelectAll ();
10318: break;
10319: }
10320: }
10321: };
10322: dbgPopupMenu = ComponentFactory.createPopupMenu (
10323: dbgPopupIBPMenu =
10324: InstructionBreakPoint.IBP_ON ?
10325: ComponentFactory.createMenu (
10326: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
10327: Multilingual.mlnText (ComponentFactory.createMenuItem ("Run to Here", 'R', popupActionListener), "ja", "ここまで実行"),
10328: ComponentFactory.createHorizontalSeparator (),
10329: Multilingual.mlnText (ComponentFactory.createMenuItem ("Set Breakpoint", 'S', popupActionListener), "ja", "ブレークポイントを設定"),
10330: ComponentFactory.createHorizontalBox (
10331: Box.createHorizontalStrut (7),
10332: Box.createHorizontalGlue (),
10333: ComponentFactory.setPreferredSize (
10334: Multilingual.mlnText (ComponentFactory.createLabel ("current"), "ja", "現在値"),
10335: 60, 16),
10336: ComponentFactory.createNumberSpinner (dbgPopupIBPCurrentModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
10337: @Override public void stateChanged (ChangeEvent ce) {
10338: dbgPopupIBPCurrentValue = dbgPopupIBPCurrentModel.getNumber ().intValue ();
10339: }
10340: }),
10341: Box.createHorizontalGlue ()
10342: ),
10343: ComponentFactory.createHorizontalBox (
10344: Box.createHorizontalStrut (7),
10345: Box.createHorizontalGlue (),
10346: ComponentFactory.setPreferredSize (
10347: Multilingual.mlnText (ComponentFactory.createLabel ("threshold"), "ja", "閾値"),
10348: 60, 16),
10349: ComponentFactory.createNumberSpinner (dbgPopupIBPThresholdModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
10350: @Override public void stateChanged (ChangeEvent ce) {
10351: dbgPopupIBPThresholdValue = dbgPopupIBPThresholdModel.getNumber ().intValue ();
10352: }
10353: }),
10354: Box.createHorizontalGlue ()
10355: ),
10356: dbgPopupIBPClearMenuItem =
10357: Multilingual.mlnText (ComponentFactory.createMenuItem ("Clear Breakpoint", 'C', popupActionListener), "ja", "ブレークポイントを消去")
10358: ) :
10359: null,
10360: dbgPopupHexMenu =
10361: ComponentFactory.createMenu (
10362: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
10363: dbgPopupDisMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble", 'D', popupActionListener), "ja", "逆アセンブル"),
10364: dbgPopupMemMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory Dump", 'M', popupActionListener), "ja", "メモリダンプ")
10365: ),
10366: dbgPopupCopyMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Copy", 'C', popupActionListener), "ja", "コピー"),
10367: dbgPopupSelectAllMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Select All", 'A', popupActionListener), "ja", "すべて選択")
10368: );
10369:
10370: }
10371:
10372:
10373:
10374: public static void dbgShowPopup (MouseEvent me, JTextArea textArea, boolean dis) {
10375: dbgEventMask++;
10376: int x = me.getX ();
10377: int y = me.getY ();
10378:
10379: int p = textArea.viewToModel2D (me.getPoint ());
10380: DisassembleList.ddpPopupAddress = -1;
10381: if (dis) {
10382: int i = Arrays.binarySearch (DisassembleList.ddpSplitArray, 1, DisassembleList.ddpItemCount, p + 1);
10383: i = (i >> 31 ^ i) - 1;
10384: DisassembleList.ddpPopupAddress = DisassembleList.ddpAddressArray[i];
10385: }
10386: int start = textArea.getSelectionStart ();
10387: int end = textArea.getSelectionEnd ();
10388: String text = textArea.getText ();
10389: int length = text.length ();
10390: if ((start == end ||
10391: p < start || end <= p) &&
10392: 0 <= p && p < length && isWord (text.charAt (p))) {
10393:
10394: for (start = p; 0 < start && isWord (text.charAt (start - 1)); start--) {
10395: }
10396: for (end = p + 1; end < length && isWord (text.charAt (end)); end++) {
10397: }
10398: textArea.select (start, end);
10399: }
10400: dbgHexSelected = false;
10401: if (start < end) {
10402: textArea.requestFocusInWindow ();
10403:
10404:
10405:
10406:
10407:
10408: dbgHexValue = 0;
10409: int n = 0;
10410: for (int i = start; i < end; i++) {
10411: int t;
10412: if ((t = Character.digit (text.charAt (i), 16)) >= 0) {
10413: dbgHexValue = dbgHexValue << 4 | t;
10414: if (n >= 8 ||
10415: i + 1 >= end || (t = Character.digit (text.charAt (i + 1), 16)) < 0) {
10416: n = 0;
10417: break;
10418: }
10419: dbgHexValue = dbgHexValue << 4 | t;
10420: n += 2;
10421: i++;
10422: } else if (isWord (text.charAt (i))) {
10423: n = 0;
10424: break;
10425: }
10426: }
10427: dbgHexSelected = n > 0;
10428: try {
10429:
10430: Rectangle r = textArea.modelToView2D (start).getBounds ();
10431:
10432: Rectangle s = textArea.modelToView2D (end - 1).getBounds ();
10433: if (r.y == s.y) {
10434:
10435: y = r.y + r.height;
10436: }
10437: } catch (BadLocationException ble) {
10438: }
10439: }
10440:
10441: if (InstructionBreakPoint.IBP_ON) {
10442: if (dis && mpuTask == null && DisassembleList.ddpPopupAddress != -1) {
10443: ComponentFactory.setText (dbgPopupIBPMenu, fmtHex8 (DisassembleList.ddpPopupAddress));
10444: TreeMap<Integer,InstructionBreakPoint.InstructionBreakRecord> pointTable = InstructionBreakPoint.ibpPointTable;
10445: InstructionBreakPoint.InstructionBreakRecord r = pointTable.get (DisassembleList.ddpPopupAddress);
10446: if (r != null) {
10447: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = r.ibrValue));
10448: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = r.ibrThreshold));
10449: dbgPopupIBPClearMenuItem.setEnabled (true);
10450: } else {
10451: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = 0));
10452: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = 0));
10453: dbgPopupIBPClearMenuItem.setEnabled (false);
10454: }
10455: ComponentFactory.setVisible (dbgPopupIBPMenu, true);
10456: } else {
10457: ComponentFactory.setVisible (dbgPopupIBPMenu, false);
10458: }
10459: }
10460:
10461: if (dbgHexSelected) {
10462: ComponentFactory.setText (dbgPopupHexMenu, fmtHex8 (dbgHexValue));
10463: ComponentFactory.setVisible (dbgPopupHexMenu, true);
10464: } else {
10465: ComponentFactory.setVisible (dbgPopupHexMenu, false);
10466: }
10467:
10468: ComponentFactory.setEnabled (dbgPopupCopyMenuItem, clpClipboard != null && start < end);
10469:
10470: ComponentFactory.setEnabled (dbgPopupSelectAllMenuItem, clpClipboard != null);
10471:
10472: dbgPopupTextArea = textArea;
10473: dbgPopupMenu.show (textArea, x, y);
10474: dbgEventMask--;
10475: }
10476:
10477: public static boolean isWord (char c) {
10478: return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '_';
10479: }
10480:
10481:
10482:
10483: public static void dbgCopy () {
10484: clpCopy (dbgPopupTextArea.getSelectedText ());
10485: }
10486:
10487:
10488:
10489: public static void dbgSelectAll () {
10490: if (clpClipboard != null) {
10491:
10492: dbgEventMask++;
10493: dbgPopupTextArea.selectAll ();
10494: dbgPopupTextArea.requestFocusInWindow ();
10495: dbgEventMask--;
10496: }
10497: }
10498:
10499:
10500:
10501:
10502: public static void dbgUpdate () {
10503: if ((dbgVisibleMask & DBG_DRP_VISIBLE_MASK) != 0) {
10504: RegisterList.drpUpdate ();
10505: }
10506: if (ProgramFlowVisualizer.PFV_ON) {
10507: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
10508: if (ProgramFlowVisualizer.pfvTimer == 0) {
10509: ProgramFlowVisualizer.pfvUpdate ();
10510: } else {
10511: ProgramFlowVisualizer.pfvTimer--;
10512: }
10513: }
10514: }
10515: if (RasterBreakPoint.RBP_ON) {
10516: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
10517: if (RasterBreakPoint.rbpTimer == 0) {
10518: RasterBreakPoint.rbpUpdateFrame ();
10519: } else {
10520: RasterBreakPoint.rbpTimer--;
10521: }
10522: }
10523: }
10524: if (ScreenModeTest.SMT_ON) {
10525: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
10526: if (ScreenModeTest.smtTimer == 0) {
10527: ScreenModeTest.smtUpdateFrame ();
10528: } else {
10529: ScreenModeTest.smtTimer--;
10530: }
10531: }
10532: }
10533: if (RootPointerList.RTL_ON) {
10534: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
10535: if (RootPointerList.rtlTimer == 0) {
10536: RootPointerList.rtlTimer = RootPointerList.RTL_INTERVAL - 1;
10537: RootPointerList.rtlUpdateFrame ();
10538: } else {
10539: RootPointerList.rtlTimer--;
10540: }
10541: }
10542: }
10543: if (SpritePatternViewer.SPV_ON) {
10544: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
10545: if (SpritePatternViewer.spvTimer == 0) {
10546: SpritePatternViewer.spvTimer = SpritePatternViewer.SPV_INTERVAL - 1;
10547: SpritePatternViewer.spvUpdateFrame ();
10548: } else {
10549: SpritePatternViewer.spvTimer--;
10550: }
10551: }
10552: }
10553: if (PaletteViewer.PLV_ON) {
10554: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
10555: if (PaletteViewer.plvTimer == 0) {
10556: PaletteViewer.plvTimer = PaletteViewer.PLV_INTERVAL - 1;
10557: PaletteViewer.plvUpdateFrame ();
10558: } else {
10559: PaletteViewer.plvTimer--;
10560: }
10561: }
10562: }
10563: if (ATCMonitor.ACM_ON) {
10564: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
10565: if (ATCMonitor.acmTimer == 0) {
10566: ATCMonitor.acmTimer = ATCMonitor.ACM_INTERVAL - 1;
10567: ATCMonitor.acmUpdateFrame ();
10568: } else {
10569: ATCMonitor.acmTimer--;
10570: }
10571: }
10572: }
10573: }
10574:
10575:
10576:
10577:
10578:
10579:
10580:
10581:
10582:
10583:
10584:
10585:
10586:
10587:
10588:
10589:
10590:
10591:
10592:
10593:
10594:
10595:
10596: public static boolean dbgDoStopOnError () {
10597: if (MainMemory.mmrHumanVersion <= 0) {
10598: return true;
10599: }
10600: if ((regOC & 0xff00) == 0xff00 &&
10601: M68kException.m6eNumber == M68kException.M6E_PRIVILEGE_VIOLATION) {
10602: return false;
10603: }
10604: String message = (
10605: M68kException.m6eNumber < 0 ?
10606: fmtHex8 (new StringBuilder ("breaked").append (" at "), regPC0).toString () :
10607: M68kException.m6eNumber <= M68kException.M6E_ADDRESS_ERROR ?
10608: fmtHex8 (fmtHex8 (new StringBuilder ("ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10609: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10610: .append (" at "), regPC0).toString () :
10611: fmtHex8 (new StringBuilder (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10612: .append (" at "), regPC0).toString ()
10613: );
10614: System.out.println (message);
10615: if (!(M68kException.m6eNumber == M68kException.M6E_ACCESS_FAULT &&
10616: 0x0000e100 <= regPC0 && regPC0 < 0x0000e500)) {
10617: mpuStop (message);
10618: return true;
10619: }
10620: return false;
10621: }
10622:
10623:
10624:
10625: public static void dbgDoubleBusFault () {
10626: String message =
10627: fmtHex8 (fmtHex8 (new StringBuilder ("FATAL ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10628: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10629: .append (" at "), regPC0).toString ();
10630: System.out.println (message);
10631: mpuStop (message);
10632: }
10633:
10634:
10635:
10636:
10637:
10638:
10639: public static final HashMap<String,byte[]> rscResourceCache = new HashMap<String,byte[]> ();
10640:
10641:
10642:
10643:
10644:
10645:
10646: public static byte[] rscGetResource (String name, int... sizes) {
10647: byte[] array = rscResourceCache.get (name);
10648: if (array != null) {
10649: return array;
10650: }
10651: array = new byte[1024 * 64];
10652: int size = 0;
10653: try (BufferedInputStream bis = new BufferedInputStream (XEiJ.class.getResourceAsStream ("../data/" + name))) {
10654: for (;;) {
10655: if (size == array.length) {
10656: byte[] newArray = new byte[array.length * 2];
10657: System.arraycopy (array, 0, newArray, 0, size);
10658: array = newArray;
10659: }
10660: int step = bis.read (array, size, array.length - size);
10661: if (step == -1) {
10662: break;
10663: }
10664: size += step;
10665: }
10666: if (size < array.length) {
10667: byte[] newArray = new byte[size];
10668: System.arraycopy (array, 0, newArray, 0, size);
10669: array = newArray;
10670: }
10671: boolean fit = sizes.length == 0;
10672: if (!fit) {
10673: for (int i = 0; i < sizes.length; i++) {
10674: if (size == sizes[i]) {
10675: fit = true;
10676: break;
10677: }
10678: }
10679: }
10680: if (fit) {
10681: System.out.println (Multilingual.mlnJapanese ?
10682: name + " を読み込みました" :
10683: name + " was read");
10684: rscResourceCache.put (name, array);
10685: return array;
10686: }
10687: System.out.println (Multilingual.mlnJapanese ?
10688: name + " のサイズが違います" :
10689: name + " has wrong size");
10690: return null;
10691: } catch (IOException ioe) {
10692: }
10693:
10694: System.out.println (Multilingual.mlnJapanese ?
10695: name + " を読み込めません" :
10696: name + " cannot be read");
10697: return null;
10698: }
10699:
10700:
10701:
10702: public static String rscGetResourceText (String name) {
10703: return rscGetResourceText (name, "UTF-8");
10704: }
10705: public static String rscGetResourceText (String name, String charset) {
10706: byte[] array = rscGetResource (name);
10707: if (name != null) {
10708: try {
10709: return new String (array, charset);
10710: } catch (UnsupportedEncodingException uee) {
10711: }
10712: }
10713: return "";
10714: }
10715:
10716: public static final Pattern RSC_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10717: public static String rscLastFileName = null;
10718:
10719:
10720:
10721:
10722:
10723:
10724: public static byte[] rscGetFile (String names, int... sizes) {
10725: for (String name : names.split (",")) {
10726: name = name.trim ();
10727: if (name.length () == 0 || name.equalsIgnoreCase ("none")) {
10728: continue;
10729: }
10730: String[] zipSplittedName = RSC_ZIP_SEPARATOR.split (name, 2);
10731: InputStream is = null;
10732: if (zipSplittedName.length < 2) {
10733: File file = new File (name);
10734: if (file.isFile ()) {
10735: try {
10736: is = new FileInputStream (file);
10737: } catch (IOException ioe) {
10738: }
10739: } else {
10740: System.out.println (Multilingual.mlnJapanese ?
10741: name + " がありません" :
10742: name + " does not exist");
10743: continue;
10744: }
10745: } else {
10746: String zipName = zipSplittedName[0];
10747: String entryName = zipSplittedName[1];
10748: if (new File (zipName).isFile ()) {
10749: try {
10750: ZipFile zipFile = new ZipFile (zipName);
10751: ZipEntry zipEntry = zipFile.getEntry (entryName);
10752: if (zipEntry != null) {
10753: is = zipFile.getInputStream (zipEntry);
10754: } else {
10755: System.out.println (Multilingual.mlnJapanese ?
10756: zipName + " に " + zipEntry + " がありません" :
10757: zipName + " does not include " + zipEntry);
10758: }
10759: } catch (IOException ioe) {
10760: }
10761: } else {
10762: System.out.println (Multilingual.mlnJapanese ?
10763: zipName + " がありません" :
10764: zipName + " does not exist");
10765: continue;
10766: }
10767: }
10768: if (is != null) {
10769: try {
10770: is = new BufferedInputStream (is);
10771: if (name.toLowerCase ().endsWith (".gz")) {
10772: is = new GZIPInputStream (is);
10773: }
10774: byte[] array = new byte[1024 * 64];
10775: int size = 0;
10776: for (;;) {
10777: if (size == array.length) {
10778: byte[] newArray = new byte[array.length * 2];
10779: System.arraycopy (array, 0, newArray, 0, size);
10780: array = newArray;
10781: }
10782: int step = is.read (array, size, array.length - size);
10783: if (step == -1) {
10784: break;
10785: }
10786: size += step;
10787: }
10788: is.close ();
10789: is = null;
10790: if (size < array.length) {
10791: byte[] newArray = new byte[size];
10792: System.arraycopy (array, 0, newArray, 0, size);
10793: array = newArray;
10794: }
10795: boolean fit = sizes.length == 0;
10796: if (!fit) {
10797: for (int i = 0; i < sizes.length; i++) {
10798: if (size == sizes[i]) {
10799: fit = true;
10800: break;
10801: }
10802: }
10803: }
10804: if (fit) {
10805: System.out.println (Multilingual.mlnJapanese ?
10806: name + " を読み込みました" :
10807: name + " was read");
10808: rscLastFileName = name;
10809: return array;
10810: }
10811: System.out.println (Multilingual.mlnJapanese ?
10812: name + " のサイズが違います" :
10813: name + " has wrong size");
10814: continue;
10815: } catch (IOException ioe) {
10816: }
10817: if (is != null) {
10818: try {
10819: is.close ();
10820: is = null;
10821: } catch (IOException ioe) {
10822: }
10823: }
10824: }
10825: System.out.println (Multilingual.mlnJapanese ?
10826: name + " を読み込めません" :
10827: name + " cannot be read");
10828: }
10829:
10830:
10831:
10832: return null;
10833: }
10834:
10835:
10836:
10837:
10838: public static String rscGetTextFile (String name) {
10839: return rscGetTextFile (name, "UTF-8");
10840: }
10841: public static String rscGetTextFile (String name, String charset) {
10842: byte[] array = rscGetFile (name);
10843: if (array != null) {
10844: try {
10845: return new String (array, charset);
10846: } catch (UnsupportedEncodingException uee) {
10847: }
10848: }
10849: return "";
10850: }
10851:
10852:
10853:
10854: public static final int RSC_A_MASK = 1;
10855: public static final int RSC_R_MASK = 2;
10856: public static final int RSC_I_MASK = 4;
10857: public static final String RSC_A_EN = "Abort";
10858: public static final String RSC_R_EN = "Retry";
10859: public static final String RSC_I_EN = "Ignore";
10860: public static final String RSC_A_JA = "中止";
10861: public static final String RSC_R_JA = "再実行";
10862: public static final String RSC_I_JA = "無視";
10863: public static final String[][] RSC_EN_OPTIONS = {
10864: { RSC_A_EN },
10865: { RSC_A_EN },
10866: { RSC_R_EN },
10867: { RSC_A_EN, RSC_R_EN },
10868: { RSC_I_EN },
10869: { RSC_A_EN, RSC_I_EN },
10870: { RSC_R_EN, RSC_I_EN },
10871: { RSC_A_EN, RSC_R_EN, RSC_I_EN },
10872: };
10873: public static final String[][] RSC_JA_OPTIONS = {
10874: { RSC_A_JA },
10875: { RSC_A_JA },
10876: { RSC_R_JA },
10877: { RSC_A_JA, RSC_R_JA },
10878: { RSC_I_JA },
10879: { RSC_A_JA, RSC_I_JA },
10880: { RSC_R_JA, RSC_I_JA },
10881: { RSC_A_JA, RSC_R_JA, RSC_I_JA },
10882: };
10883: public static int rscShowError (String message, int mask) {
10884: System.out.println (message);
10885: mask &= RSC_A_MASK | RSC_R_MASK | RSC_I_MASK;
10886: if (mask == 0) {
10887: mask = RSC_A_MASK;
10888: }
10889: String[] options = (Multilingual.mlnJapanese ? RSC_JA_OPTIONS : RSC_EN_OPTIONS)[mask];
10890: int def = Integer.numberOfTrailingZeros (mask);
10891: pnlExitFullScreen (true);
10892: int bit = JOptionPane.showOptionDialog (
10893: null,
10894: message,
10895: Multilingual.mlnJapanese ? "ファイル操作エラー" : "File operation error",
10896: JOptionPane.YES_NO_CANCEL_OPTION,
10897: JOptionPane.ERROR_MESSAGE,
10898: null,
10899: options,
10900: options[def]);
10901: if (bit == JOptionPane.CLOSED_OPTION) {
10902: bit = def;
10903: }
10904: return 1 << bit;
10905: }
10906:
10907:
10908:
10909:
10910:
10911:
10912: public static boolean rscPutTextFile (String name, String string) {
10913: return rscPutTextFile (name, string, "UTF-8");
10914: }
10915: public static boolean rscPutTextFile (String name, ArrayList<String> strings) {
10916: return rscPutTextFile (name, strings, "UTF-8");
10917: }
10918: public static boolean rscPutTextFile (String name, String string, String charset) {
10919: ArrayList<String> strings = new ArrayList<String> ();
10920: strings.add (string);
10921: return rscPutTextFile (name, strings, charset);
10922: }
10923: public static boolean rscPutTextFile (String name, ArrayList<String> strings, String charset) {
10924: String nameTmp = name + ".tmp";
10925: String nameBak = name + ".bak";
10926: File file = new File (name);
10927: File fileTmp = new File (nameTmp);
10928: File fileBak = new File (nameBak);
10929:
10930: File parentDirectory = file.getParentFile ();
10931: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10932: if (!parentDirectory.mkdirs ()) {
10933: System.out.println (parentDirectory.getPath () + (Multilingual.mlnJapanese ? " を作れません" : " cannot be created"));
10934: return false;
10935: }
10936: }
10937:
10938: if (fileTmp.exists ()) {
10939: if (!fileTmp.delete ()) {
10940: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10941: return false;
10942: }
10943: }
10944:
10945: try (BufferedWriter bw = new BufferedWriter (new FileWriter (nameTmp, Charset.forName (charset)))) {
10946: for (String string : strings) {
10947: bw.write (string);
10948: }
10949: } catch (IOException ioe) {
10950: ioe.printStackTrace ();
10951: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " に書き出せません" : " cannot be written"));
10952: return false;
10953: }
10954:
10955: boolean fileExists = file.exists ();
10956: if (fileExists) {
10957:
10958: if (fileBak.exists ()) {
10959: if (!fileBak.delete ()) {
10960: System.out.println (nameBak + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10961: return false;
10962: }
10963: }
10964:
10965: if (!file.renameTo (fileBak)) {
10966: System.out.println (name + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + nameBak + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10967: return false;
10968: }
10969: }
10970:
10971: if (!fileTmp.renameTo (file)) {
10972: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + name + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10973: return false;
10974: }
10975: if (fileExists) {
10976: System.out.println (name + (Multilingual.mlnJapanese ? " を更新しました" : " was updated"));
10977: } else {
10978: System.out.println (name + (Multilingual.mlnJapanese ? " を作りました" : " was created"));
10979: }
10980: return true;
10981: }
10982:
10983:
10984:
10985:
10986:
10987:
10988:
10989:
10990:
10991: public static boolean rscPutFile (String name, byte[] array) {
10992: return rscPutFile (name, array, 0, array.length, (long) array.length);
10993: }
10994: public static boolean rscPutFile (String name, byte[] array, int offset, int length) {
10995: return rscPutFile (name, array, offset, length, (long) length);
10996: }
10997: public static boolean rscPutFile (String name, byte[] array, int offset, int length, long longLength2) {
10998: if (RSC_ZIP_SEPARATOR.matcher (name).matches ()) {
10999:
11000: return false;
11001: }
11002: File file = new File (name);
11003: boolean fileExists = file.isFile ();
11004: if (fileExists && file.length () == longLength2) {
11005: comparison:
11006: {
11007: try (BufferedInputStream bis = new BufferedInputStream (new FileInputStream (file))) {
11008: byte[] buffer = new byte[(int) Math.min (Math.max ((long) length, longLength2 - (long) length), (long) (1024 * 1024))];
11009: int position = 0;
11010: while (position < length) {
11011: int step = bis.read (buffer, 0, Math.min (buffer.length, length - position));
11012: if (step == -1) {
11013: break comparison;
11014: }
11015: int offsetPosition = offset + position;
11016: for (int i = 0; i < step; i++) {
11017: if (buffer[i] != array[offsetPosition + i]) {
11018: break comparison;
11019: }
11020: }
11021: position += step;
11022: }
11023: long longPosition2 = (long) length;
11024: while (longPosition2 < longLength2) {
11025: int step = bis.read (buffer, 0, (int) Math.min ((long) buffer.length, longLength2 - longPosition2));
11026: if (step == -1) {
11027: break comparison;
11028: }
11029: for (int i = 0; i < step; i++) {
11030: if (buffer[i] != 0) {
11031: break comparison;
11032: }
11033: }
11034: longPosition2 += (long) step;
11035: }
11036: return true;
11037: } catch (IOException ioe) {
11038: }
11039: }
11040: }
11041: String nameTmp = name + ".tmp";
11042: File fileTmp = new File (nameTmp);
11043: String nameBak = name + ".bak";
11044: File fileBak = new File (nameBak);
11045: retry:
11046: for (;;) {
11047: File parentDirectory = file.getParentFile ();
11048: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
11049: String parentName = parentDirectory.getPath ();
11050: if (parentDirectory.mkdirs ()) {
11051: System.out.println (Multilingual.mlnJapanese ?
11052: parentName + " を作りました" :
11053: parentName + " was created");
11054: } else {
11055: switch (rscShowError (Multilingual.mlnJapanese ?
11056: parentName + " を作れません" :
11057: parentName + " cannot be created",
11058: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11059: case RSC_A_MASK:
11060: break retry;
11061: case RSC_R_MASK:
11062: continue retry;
11063: }
11064: }
11065: }
11066: if (fileTmp.isFile ()) {
11067: if (!fileTmp.delete ()) {
11068: switch (rscShowError (Multilingual.mlnJapanese ?
11069: nameTmp + " を削除できません" :
11070: nameTmp + " cannot be deleted",
11071: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11072: case RSC_A_MASK:
11073: break retry;
11074: case RSC_R_MASK:
11075: continue retry;
11076: }
11077: }
11078: }
11079: try (OutputStream os = name.toLowerCase ().endsWith (".gz") ?
11080: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11081: {
11082:
11083: def.setLevel (Deflater.DEFAULT_COMPRESSION);
11084:
11085: }
11086: } :
11087: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11088:
11089: os.write (array, offset, length);
11090:
11091:
11092: if ((long) length < longLength2) {
11093: byte[] buffer = new byte[(int) Math.min (longLength2 - (long) length, (long) (1024 * 1024))];
11094: Arrays.fill (buffer, 0, buffer.length, (byte) 0);
11095: long longPosition2 = (long) length;
11096: while (longPosition2 < longLength2) {
11097: int step = (int) Math.min ((long) buffer.length, longLength2 - longPosition2);
11098: os.write (buffer, 0, step);
11099: longPosition2 += (long) step;
11100: }
11101: }
11102: } catch (IOException ioe) {
11103: switch (rscShowError (Multilingual.mlnJapanese ?
11104: nameTmp + " に書き出せません" :
11105: nameTmp + " cannot be written",
11106: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11107: case RSC_A_MASK:
11108: break retry;
11109: case RSC_R_MASK:
11110: continue retry;
11111: }
11112: }
11113: if (fileExists && file.isFile ()) {
11114: if (fileBak.isFile ()) {
11115: if (!fileBak.delete ()) {
11116: switch (rscShowError (Multilingual.mlnJapanese ?
11117: nameBak + " を削除できません" :
11118: nameBak + " cannot be deleted",
11119: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11120: case RSC_A_MASK:
11121: break retry;
11122: case RSC_R_MASK:
11123: continue retry;
11124: }
11125: }
11126: }
11127: if (!file.renameTo (fileBak)) {
11128: switch (rscShowError (Multilingual.mlnJapanese ?
11129: name + " を " + nameBak + " にリネームできません" :
11130: name + " cannot be renamed to " + nameBak,
11131: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11132: case RSC_A_MASK:
11133: break retry;
11134: case RSC_R_MASK:
11135: continue retry;
11136: }
11137: }
11138: }
11139: if (fileTmp.renameTo (file)) {
11140: if (fileExists) {
11141: System.out.println (Multilingual.mlnJapanese ?
11142: name + " を更新しました" :
11143: name + " was updated");
11144: } else {
11145: System.out.println (Multilingual.mlnJapanese ?
11146: name + " を作りました" :
11147: name + " was created");
11148: }
11149: return true;
11150: } else {
11151: switch (rscShowError (Multilingual.mlnJapanese ?
11152: nameTmp + " を " + name + " にリネームできません" :
11153: nameTmp + " cannot be renamed to " + name,
11154: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11155: case RSC_A_MASK:
11156: break retry;
11157: case RSC_R_MASK:
11158: continue retry;
11159: }
11160: }
11161: break;
11162: }
11163: if (fileExists) {
11164: System.out.println (Multilingual.mlnJapanese ?
11165: name + " を更新できません" :
11166: name + " cannot be updated");
11167: } else {
11168: System.out.println (Multilingual.mlnJapanese ?
11169: name + " を作れません" :
11170: name + " cannot be created");
11171: }
11172: return false;
11173: }
11174:
11175:
11176:
11177:
11178:
11179:
11180: public static final Pattern ISM_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
11181:
11182:
11183:
11184:
11185:
11186:
11187:
11188:
11189:
11190:
11191:
11192: public static InputStream ismOpen (String name) {
11193: InputStream in = null;
11194: in = ismOpen (name, false);
11195: if (in == null && name.indexOf ('/') < 0 && name.indexOf ('\\') < 0) {
11196: in = ismOpen (name, true);
11197: }
11198: return in;
11199: }
11200: public static InputStream ismOpen (String name, boolean useGetResource) {
11201: boolean gzipped = name.toLowerCase ().endsWith (".gz");
11202: String[] zipSplittedName = ISM_ZIP_SEPARATOR.split (name, 2);
11203: String fileName = zipSplittedName[0];
11204: String zipEntryName = zipSplittedName.length < 2 ? null : zipSplittedName[1];
11205: InputStream in = null;
11206: try {
11207: if (useGetResource) {
11208: if (false) {
11209: URL url = XEiJ.class.getResource (fileName);
11210: if (url != null) {
11211: in = url.openStream ();
11212: }
11213: } else {
11214: in = XEiJ.class.getResourceAsStream (fileName);
11215: }
11216: } else {
11217: File file = new File (fileName);
11218: if (file.exists ()) {
11219: in = new FileInputStream (file);
11220: }
11221: }
11222: if (in != null && zipEntryName != null) {
11223: ZipInputStream zin = new ZipInputStream (in);
11224: in = null;
11225: ZipEntry entry;
11226: while ((entry = zin.getNextEntry ()) != null) {
11227: if (zipEntryName.equals (entry.getName ())) {
11228: in = zin;
11229: break;
11230: }
11231: }
11232: if (in == null) {
11233: System.out.println (Multilingual.mlnJapanese ? fileName + " の中に " + zipEntryName + " がありません" :
11234: zipEntryName + " does not exist in " + fileName);
11235: }
11236: }
11237: if (in != null && gzipped) {
11238: in = new GZIPInputStream (in);
11239: }
11240: if (in != null) {
11241: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " を読み込みます" :
11242: (useGetResource ? "Reading resource file " : "Reading file ") + name);
11243: return new BufferedInputStream (in);
11244: }
11245: } catch (Exception ioe) {
11246: if (prgVerbose) {
11247: prgPrintStackTraceOf (ioe);
11248: }
11249: }
11250: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " が見つかりません" :
11251: (useGetResource ? "Resource file " : "File ") + name + " is not found");
11252: return null;
11253: }
11254:
11255:
11256:
11257:
11258:
11259:
11260:
11261:
11262: public static int ismRead (InputStream in, byte[] bb, int o, int l) {
11263: try {
11264: int k = 0;
11265: while (k < l) {
11266: int t = in.read (bb, o + k, l - k);
11267: if (t < 0) {
11268: break;
11269: }
11270: k += t;
11271: }
11272: return k;
11273: } catch (IOException ioe) {
11274: if (prgVerbose) {
11275: prgPrintStackTraceOf (ioe);
11276: }
11277: }
11278: return -1;
11279: }
11280:
11281:
11282:
11283:
11284:
11285:
11286:
11287:
11288: public static int ismSkip (InputStream in, int l) {
11289: try {
11290: int k = 0;
11291: while (k < l) {
11292:
11293:
11294: if (in.read () < 0) {
11295: break;
11296: }
11297: k++;
11298: if (k < l) {
11299: int t = (int) in.skip ((long) (l - k));
11300: if (t < 0) {
11301: break;
11302: }
11303: k += t;
11304: }
11305: }
11306: return k;
11307: } catch (IOException ioe) {
11308: if (prgVerbose) {
11309: prgPrintStackTraceOf (ioe);
11310: }
11311: }
11312: return -1;
11313: }
11314:
11315:
11316:
11317:
11318:
11319: public static void ismClose (InputStream in) {
11320: try {
11321: if (in != null) {
11322: in.close ();
11323: }
11324: } catch (IOException ioe) {
11325: if (prgVerbose) {
11326: prgPrintStackTraceOf (ioe);
11327: }
11328: }
11329: }
11330:
11331:
11332:
11333:
11334:
11335:
11336: public static int ismLength (String name, int maxLength) {
11337: int length;
11338: InputStream in = ismOpen (name);
11339: if (in == null) {
11340: length = -1;
11341: } else {
11342: length = ismSkip (in, maxLength);
11343: ismClose (in);
11344: }
11345: return length;
11346: }
11347:
11348:
11349:
11350:
11351:
11352:
11353:
11354:
11355:
11356:
11357:
11358:
11359:
11360:
11361: public static boolean ismLoad (byte[] bb, int o, int l, String names) {
11362: for (String name : names.split (",")) {
11363: if (name.length () != 0) {
11364: InputStream in = ismOpen (name);
11365: if (in != null) {
11366: int k = ismRead (in, bb, o, l);
11367: ismClose (in);
11368: if (k == l) {
11369: return true;
11370: }
11371: }
11372: }
11373: }
11374: return false;
11375: }
11376:
11377:
11378:
11379:
11380:
11381:
11382:
11383:
11384:
11385: public static boolean ismSave (byte[] bb, int offset, long length, String path, boolean verbose) {
11386: if (ISM_ZIP_SEPARATOR.split (path, 2).length != 1) {
11387: if (verbose) {
11388: pnlExitFullScreen (true);
11389: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? path + " に書き出せません" : "Cannot write " + path);
11390: }
11391: return false;
11392: }
11393: long step = 0;
11394: byte[] zz = null;
11395: long pointer = (long) (bb.length - offset);
11396: if (pointer < length) {
11397: step = Math.min (1024L * 512, length - pointer);
11398: zz = new byte[(int) step];
11399: Arrays.fill (zz, (byte) 0);
11400: }
11401:
11402: File file = new File (path);
11403:
11404: if (step == 0 &&
11405: file.exists () && file.length () == length) {
11406:
11407: if (length == 0L) {
11408: return true;
11409: }
11410: InputStream in = ismOpen (path);
11411: if (in != null) {
11412: int l = (int) length;
11413: byte[] tt = new byte[l];
11414: int k = ismRead (in, tt, 0, l);
11415: ismClose (in);
11416: if (k == l &&
11417: Arrays.equals (tt, bb.length == l ? bb : Arrays.copyOfRange (bb, offset, offset + l))) {
11418: return true;
11419: }
11420: }
11421: }
11422:
11423: String pathTmp = path + ".tmp";
11424: String pathBak = path + ".bak";
11425: File fileTmp = new File (pathTmp);
11426: File fileBak = new File (pathBak);
11427:
11428: if (fileTmp.exists ()) {
11429: if (!fileTmp.delete ()) {
11430: if (verbose) {
11431: pnlExitFullScreen (true);
11432: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " を削除できません" : "Cannot delete " + pathTmp);
11433: }
11434: return false;
11435: }
11436: }
11437:
11438: try (OutputStream out = path.toLowerCase ().endsWith (".gz") ?
11439: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11440: {
11441:
11442: def.setLevel (Deflater.DEFAULT_COMPRESSION);
11443:
11444: }
11445: } :
11446: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11447: if (step == 0) {
11448: out.write (bb, offset, (int) length);
11449: } else {
11450: out.write (bb, offset, (int) pointer);
11451: for (; pointer < length; pointer += step) {
11452: out.write (zz, 0, (int) Math.min (step, length - pointer));
11453: }
11454: }
11455: } catch (IOException ioe) {
11456: if (verbose) {
11457: prgPrintStackTraceOf (ioe);
11458: pnlExitFullScreen (true);
11459: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " に書き出せません" : "Cannot write " + pathTmp);
11460: }
11461: return false;
11462: }
11463:
11464:
11465: if (file.exists ()) {
11466: if (fileBak.exists ()) {
11467: if (!fileBak.delete ()) {
11468: if (verbose) {
11469: pnlExitFullScreen (true);
11470: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathBak + " を削除できません" : "Cannot delete " + pathBak);
11471: }
11472: return false;
11473: }
11474: }
11475: if (!file.renameTo (fileBak)) {
11476: if (verbose) {
11477: pnlExitFullScreen (true);
11478: JOptionPane.showMessageDialog (
11479: null, Multilingual.mlnJapanese ? path + " を " + pathBak + " にリネームできません" : "Cannot rename " + path + " to " + pathBak);
11480: }
11481: return false;
11482: }
11483: }
11484:
11485:
11486: if (!fileTmp.renameTo (file)) {
11487: if (verbose) {
11488: pnlExitFullScreen (true);
11489: JOptionPane.showMessageDialog (
11490: null, Multilingual.mlnJapanese ? pathTmp + " を " + path + " にリネームできません" : "Cannot rename " + pathTmp + " to " + path);
11491: }
11492: return false;
11493: }
11494: return true;
11495: }
11496:
11497:
11498:
11499:
11500:
11501:
11502:
11503: public static final char[] FMT_TEMP = new char[32];
11504:
11505:
11506:
11507:
11508:
11509:
11510:
11511:
11512:
11513:
11514:
11515: public static final char[] FMT_AIN4_BASE = ".......*..*...**.*...*.*.**..****...*..**.*.*.****..**.****.****".toCharArray ();
11516: public static final char[] FMT_BIN4_BASE = "0000000100100011010001010110011110001001101010111100110111101111".toCharArray ();
11517:
11518:
11519:
11520:
11521:
11522:
11523:
11524:
11525: public static void fmtAin4 (char[] a, int o, int x) {
11526: a[o ] = (char) (x >> 1 & 4 ^ 46);
11527: a[o + 1] = (char) (x & 4 ^ 46);
11528: a[o + 2] = (char) (x << 1 & 4 ^ 46);
11529: a[o + 3] = (char) (x << 2 & 4 ^ 46);
11530: }
11531: public static void fmtBin4 (char[] a, int o, int x) {
11532: a[o ] = (char) (x >>> 3 & 1 | 48);
11533: a[o + 1] = (char) (x >>> 2 & 1 | 48);
11534: a[o + 2] = (char) (x >>> 1 & 1 | 48);
11535: a[o + 3] = (char) (x & 1 | 48);
11536: }
11537: public static String fmtAin4 (int x) {
11538: return String.valueOf (FMT_AIN4_BASE, (x & 15) << 2, 4);
11539: }
11540: public static String fmtBin4 (int x) {
11541: return String.valueOf (FMT_BIN4_BASE, (x & 15) << 2, 4);
11542: }
11543: public static StringBuilder fmtAin4 (StringBuilder sb, int x) {
11544: return sb.append (FMT_AIN4_BASE, (x & 15) << 2, 6);
11545: }
11546: public static StringBuilder fmtBin4 (StringBuilder sb, int x) {
11547: return sb.append (FMT_BIN4_BASE, (x & 15) << 2, 6);
11548: }
11549:
11550:
11551:
11552:
11553:
11554:
11555:
11556:
11557: public static void fmtAin6 (char[] a, int o, int x) {
11558: a[o ] = (char) (x >> 3 & 4 ^ 46);
11559: a[o + 1] = (char) (x >> 2 & 4 ^ 46);
11560: a[o + 2] = (char) (x >> 1 & 4 ^ 46);
11561: a[o + 3] = (char) (x & 4 ^ 46);
11562: a[o + 4] = (char) (x << 1 & 4 ^ 46);
11563: a[o + 5] = (char) (x << 2 & 4 ^ 46);
11564: }
11565: public static void fmtBin6 (char[] a, int o, int x) {
11566: a[o ] = (char) (x >>> 5 & 1 | 48);
11567: a[o + 1] = (char) (x >>> 4 & 1 | 48);
11568: a[o + 2] = (char) (x >>> 3 & 1 | 48);
11569: a[o + 3] = (char) (x >>> 2 & 1 | 48);
11570: a[o + 4] = (char) (x >>> 1 & 1 | 48);
11571: a[o + 5] = (char) (x & 1 | 48);
11572: }
11573: public static String fmtAin6 (int x) {
11574: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11575: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11576: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11577: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11578: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11579: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11580: return String.valueOf (FMT_TEMP, 0, 6);
11581: }
11582: public static String fmtBin6 (int x) {
11583: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11584: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11585: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11586: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11587: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11588: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11589: return String.valueOf (FMT_TEMP, 0, 6);
11590: }
11591: public static StringBuilder fmtAin6 (StringBuilder sb, int x) {
11592: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11593: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11594: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11595: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11596: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11597: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11598: return sb.append (FMT_TEMP, 0, 6);
11599: }
11600: public static StringBuilder fmtBin6 (StringBuilder sb, int x) {
11601: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11602: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11603: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11604: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11605: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11606: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11607: return sb.append (FMT_TEMP, 0, 6);
11608: }
11609:
11610:
11611:
11612:
11613:
11614:
11615:
11616:
11617: public static void fmtAin8 (char[] a, int o, int x) {
11618: a[o ] = (char) (x >> 5 & 4 ^ 46);
11619: a[o + 1] = (char) (x >> 4 & 4 ^ 46);
11620: a[o + 2] = (char) (x >> 3 & 4 ^ 46);
11621: a[o + 3] = (char) (x >> 2 & 4 ^ 46);
11622: a[o + 4] = (char) (x >> 1 & 4 ^ 46);
11623: a[o + 5] = (char) (x & 4 ^ 46);
11624: a[o + 6] = (char) (x << 1 & 4 ^ 46);
11625: a[o + 7] = (char) (x << 2 & 4 ^ 46);
11626: }
11627: public static void fmtBin8 (char[] a, int o, int x) {
11628: a[o ] = (char) (x >>> 7 & 1 | 48);
11629: a[o + 1] = (char) (x >>> 6 & 1 | 48);
11630: a[o + 2] = (char) (x >>> 5 & 1 | 48);
11631: a[o + 3] = (char) (x >>> 4 & 1 | 48);
11632: a[o + 4] = (char) (x >>> 3 & 1 | 48);
11633: a[o + 5] = (char) (x >>> 2 & 1 | 48);
11634: a[o + 6] = (char) (x >>> 1 & 1 | 48);
11635: a[o + 7] = (char) (x & 1 | 48);
11636: }
11637: public static String fmtAin8 (int x) {
11638: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11639: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11640: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11641: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11642: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11643: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11644: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11645: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11646: return String.valueOf (FMT_TEMP, 0, 8);
11647: }
11648: public static String fmtBin8 (int x) {
11649: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11650: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11651: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11652: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11653: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11654: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11655: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11656: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11657: return String.valueOf (FMT_TEMP, 0, 8);
11658: }
11659: public static StringBuilder fmtAin8 (StringBuilder sb, int x) {
11660: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11661: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11662: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11663: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11664: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11665: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11666: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11667: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11668: return sb.append (FMT_TEMP, 0, 8);
11669: }
11670: public static StringBuilder fmtBin8 (StringBuilder sb, int x) {
11671: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11672: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11673: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11674: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11675: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11676: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11677: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11678: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11679: return sb.append (FMT_TEMP, 0, 8);
11680: }
11681:
11682:
11683:
11684:
11685:
11686:
11687:
11688:
11689: public static void fmtAin12 (char[] a, int o, int x) {
11690: a[o ] = (char) (x >> 9 & 4 ^ 46);
11691: a[o + 1] = (char) (x >> 8 & 4 ^ 46);
11692: a[o + 2] = (char) (x >> 7 & 4 ^ 46);
11693: a[o + 3] = (char) (x >> 6 & 4 ^ 46);
11694: a[o + 4] = (char) (x >> 5 & 4 ^ 46);
11695: a[o + 5] = (char) (x >> 4 & 4 ^ 46);
11696: a[o + 6] = (char) (x >> 3 & 4 ^ 46);
11697: a[o + 7] = (char) (x >> 2 & 4 ^ 46);
11698: a[o + 8] = (char) (x >> 1 & 4 ^ 46);
11699: a[o + 9] = (char) (x & 4 ^ 46);
11700: a[o + 10] = (char) (x << 1 & 4 ^ 46);
11701: a[o + 11] = (char) (x << 2 & 4 ^ 46);
11702: }
11703: public static void fmtBin12 (char[] a, int o, int x) {
11704: a[o ] = (char) (x >>> 11 & 1 | 48);
11705: a[o + 1] = (char) (x >>> 10 & 1 | 48);
11706: a[o + 2] = (char) (x >>> 9 & 1 | 48);
11707: a[o + 3] = (char) (x >>> 8 & 1 | 48);
11708: a[o + 4] = (char) (x >>> 7 & 1 | 48);
11709: a[o + 5] = (char) (x >>> 6 & 1 | 48);
11710: a[o + 6] = (char) (x >>> 5 & 1 | 48);
11711: a[o + 7] = (char) (x >>> 4 & 1 | 48);
11712: a[o + 8] = (char) (x >>> 3 & 1 | 48);
11713: a[o + 9] = (char) (x >>> 2 & 1 | 48);
11714: a[o + 10] = (char) (x >>> 1 & 1 | 48);
11715: a[o + 11] = (char) (x & 1 | 48);
11716: }
11717: public static String fmtAin12 (int x) {
11718: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11719: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11720: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11721: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11722: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11723: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11724: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11725: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11726: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11727: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11728: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11729: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11730: return String.valueOf (FMT_TEMP, 0, 12);
11731: }
11732: public static String fmtBin12 (int x) {
11733: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11734: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11735: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11736: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11737: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11738: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11739: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11740: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11741: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11742: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11743: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11744: FMT_TEMP[11] = (char) (x & 1 | 48);
11745: return String.valueOf (FMT_TEMP, 0, 12);
11746: }
11747: public static StringBuilder fmtAin12 (StringBuilder sb, int x) {
11748: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11749: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11750: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11751: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11752: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11753: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11754: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11755: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11756: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11757: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11758: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11759: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11760: return sb.append (FMT_TEMP, 0, 12);
11761: }
11762: public static StringBuilder fmtBin12 (StringBuilder sb, int x) {
11763: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11764: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11765: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11766: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11767: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11768: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11769: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11770: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11771: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11772: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11773: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11774: FMT_TEMP[11] = (char) (x & 1 | 48);
11775: return sb.append (FMT_TEMP, 0, 12);
11776: }
11777:
11778:
11779:
11780:
11781:
11782:
11783:
11784:
11785: public static void fmtAin16 (char[] a, int o, int x) {
11786: a[o ] = (char) (x >> 13 & 4 ^ 46);
11787: a[o + 1] = (char) (x >> 12 & 4 ^ 46);
11788: a[o + 2] = (char) (x >> 11 & 4 ^ 46);
11789: a[o + 3] = (char) (x >> 10 & 4 ^ 46);
11790: a[o + 4] = (char) (x >> 9 & 4 ^ 46);
11791: a[o + 5] = (char) (x >> 8 & 4 ^ 46);
11792: a[o + 6] = (char) (x >> 7 & 4 ^ 46);
11793: a[o + 7] = (char) (x >> 6 & 4 ^ 46);
11794: a[o + 8] = (char) (x >> 5 & 4 ^ 46);
11795: a[o + 9] = (char) (x >> 4 & 4 ^ 46);
11796: a[o + 10] = (char) (x >> 3 & 4 ^ 46);
11797: a[o + 11] = (char) (x >> 2 & 4 ^ 46);
11798: a[o + 12] = (char) (x >> 1 & 4 ^ 46);
11799: a[o + 13] = (char) (x & 4 ^ 46);
11800: a[o + 14] = (char) (x << 1 & 4 ^ 46);
11801: a[o + 15] = (char) (x << 2 & 4 ^ 46);
11802: }
11803: public static void fmtBin16 (char[] a, int o, int x) {
11804: a[o ] = (char) (x >>> 15 & 1 | 48);
11805: a[o + 1] = (char) (x >>> 14 & 1 | 48);
11806: a[o + 2] = (char) (x >>> 13 & 1 | 48);
11807: a[o + 3] = (char) (x >>> 12 & 1 | 48);
11808: a[o + 4] = (char) (x >>> 11 & 1 | 48);
11809: a[o + 5] = (char) (x >>> 10 & 1 | 48);
11810: a[o + 6] = (char) (x >>> 9 & 1 | 48);
11811: a[o + 7] = (char) (x >>> 8 & 1 | 48);
11812: a[o + 8] = (char) (x >>> 7 & 1 | 48);
11813: a[o + 9] = (char) (x >>> 6 & 1 | 48);
11814: a[o + 10] = (char) (x >>> 5 & 1 | 48);
11815: a[o + 11] = (char) (x >>> 4 & 1 | 48);
11816: a[o + 12] = (char) (x >>> 3 & 1 | 48);
11817: a[o + 13] = (char) (x >>> 2 & 1 | 48);
11818: a[o + 14] = (char) (x >>> 1 & 1 | 48);
11819: a[o + 15] = (char) (x & 1 | 48);
11820: }
11821: public static String fmtAin16 (int x) {
11822: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11823: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11824: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11825: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11826: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11827: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11828: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11829: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11830: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11831: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11832: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11833: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11834: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11835: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11836: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11837: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11838: return String.valueOf (FMT_TEMP, 0, 16);
11839: }
11840: public static String fmtBin16 (int x) {
11841: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11842: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11843: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11844: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11845: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11846: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11847: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11848: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11849: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11850: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11851: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11852: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11853: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11854: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11855: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11856: FMT_TEMP[15] = (char) (x & 1 | 48);
11857: return String.valueOf (FMT_TEMP, 0, 16);
11858: }
11859: public static StringBuilder fmtAin16 (StringBuilder sb, int x) {
11860: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11861: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11862: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11863: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11864: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11865: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11866: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11867: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11868: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11869: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11870: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11871: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11872: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11873: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11874: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11875: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11876: return sb.append (FMT_TEMP, 0, 16);
11877: }
11878: public static StringBuilder fmtBin16 (StringBuilder sb, int x) {
11879: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11880: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11881: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11882: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11883: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11884: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11885: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11886: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11887: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11888: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11889: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11890: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11891: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11892: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11893: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11894: FMT_TEMP[15] = (char) (x & 1 | 48);
11895: return sb.append (FMT_TEMP, 0, 16);
11896: }
11897:
11898:
11899:
11900:
11901:
11902:
11903:
11904:
11905: public static void fmtAin24 (char[] a, int o, int x) {
11906: a[o ] = (char) (x >> 21 & 4 ^ 46);
11907: a[o + 1] = (char) (x >> 20 & 4 ^ 46);
11908: a[o + 2] = (char) (x >> 19 & 4 ^ 46);
11909: a[o + 3] = (char) (x >> 18 & 4 ^ 46);
11910: a[o + 4] = (char) (x >> 17 & 4 ^ 46);
11911: a[o + 5] = (char) (x >> 16 & 4 ^ 46);
11912: a[o + 6] = (char) (x >> 15 & 4 ^ 46);
11913: a[o + 7] = (char) (x >> 14 & 4 ^ 46);
11914: a[o + 8] = (char) (x >> 13 & 4 ^ 46);
11915: a[o + 9] = (char) (x >> 12 & 4 ^ 46);
11916: a[o + 10] = (char) (x >> 11 & 4 ^ 46);
11917: a[o + 11] = (char) (x >> 10 & 4 ^ 46);
11918: a[o + 12] = (char) (x >> 9 & 4 ^ 46);
11919: a[o + 13] = (char) (x >> 8 & 4 ^ 46);
11920: a[o + 14] = (char) (x >> 7 & 4 ^ 46);
11921: a[o + 15] = (char) (x >> 6 & 4 ^ 46);
11922: a[o + 16] = (char) (x >> 5 & 4 ^ 46);
11923: a[o + 17] = (char) (x >> 4 & 4 ^ 46);
11924: a[o + 18] = (char) (x >> 3 & 4 ^ 46);
11925: a[o + 19] = (char) (x >> 2 & 4 ^ 46);
11926: a[o + 20] = (char) (x >> 1 & 4 ^ 46);
11927: a[o + 21] = (char) (x & 4 ^ 46);
11928: a[o + 22] = (char) (x << 1 & 4 ^ 46);
11929: a[o + 23] = (char) (x << 2 & 4 ^ 46);
11930: }
11931: public static void fmtBin24 (char[] a, int o, int x) {
11932: a[o ] = (char) (x >>> 23 & 1 | 48);
11933: a[o + 1] = (char) (x >>> 22 & 1 | 48);
11934: a[o + 2] = (char) (x >>> 21 & 1 | 48);
11935: a[o + 3] = (char) (x >>> 20 & 1 | 48);
11936: a[o + 4] = (char) (x >>> 19 & 1 | 48);
11937: a[o + 5] = (char) (x >>> 18 & 1 | 48);
11938: a[o + 6] = (char) (x >>> 17 & 1 | 48);
11939: a[o + 7] = (char) (x >>> 16 & 1 | 48);
11940: a[o + 8] = (char) (x >>> 15 & 1 | 48);
11941: a[o + 9] = (char) (x >>> 14 & 1 | 48);
11942: a[o + 10] = (char) (x >>> 13 & 1 | 48);
11943: a[o + 11] = (char) (x >>> 12 & 1 | 48);
11944: a[o + 12] = (char) (x >>> 11 & 1 | 48);
11945: a[o + 13] = (char) (x >>> 10 & 1 | 48);
11946: a[o + 14] = (char) (x >>> 9 & 1 | 48);
11947: a[o + 15] = (char) (x >>> 8 & 1 | 48);
11948: a[o + 16] = (char) (x >>> 7 & 1 | 48);
11949: a[o + 17] = (char) (x >>> 6 & 1 | 48);
11950: a[o + 18] = (char) (x >>> 5 & 1 | 48);
11951: a[o + 19] = (char) (x >>> 4 & 1 | 48);
11952: a[o + 20] = (char) (x >>> 3 & 1 | 48);
11953: a[o + 21] = (char) (x >>> 2 & 1 | 48);
11954: a[o + 22] = (char) (x >>> 1 & 1 | 48);
11955: a[o + 23] = (char) (x & 1 | 48);
11956: }
11957: public static String fmtAin24 (int x) {
11958: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11959: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11960: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11961: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11962: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11963: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11964: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11965: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11966: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11967: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11968: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11969: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11970: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11971: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11972: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11973: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11974: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11975: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11976: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11977: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11978: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11979: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11980: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11981: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11982: return String.valueOf (FMT_TEMP, 0, 24);
11983: }
11984: public static String fmtBin24 (int x) {
11985: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11986: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11987: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11988: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11989: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11990: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11991: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11992: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11993: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11994: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11995: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11996: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11997: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11998: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11999: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
12000: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
12001: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
12002: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
12003: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
12004: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
12005: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
12006: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
12007: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
12008: FMT_TEMP[23] = (char) (x & 1 | 48);
12009: return String.valueOf (FMT_TEMP, 0, 24);
12010: }
12011: public static StringBuilder fmtAin24 (StringBuilder sb, int x) {
12012: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
12013: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
12014: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
12015: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
12016: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
12017: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
12018: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
12019: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
12020: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
12021: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
12022: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
12023: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
12024: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
12025: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
12026: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
12027: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
12028: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
12029: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
12030: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
12031: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
12032: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
12033: FMT_TEMP[21] = (char) (x & 4 ^ 46);
12034: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
12035: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
12036: return sb.append (FMT_TEMP, 0, 24);
12037: }
12038: public static StringBuilder fmtBin24 (StringBuilder sb, int x) {
12039: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
12040: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
12041: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
12042: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
12043: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
12044: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
12045: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
12046: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
12047: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
12048: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
12049: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
12050: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
12051: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
12052: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
12053: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
12054: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
12055: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
12056: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
12057: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
12058: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
12059: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
12060: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
12061: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
12062: FMT_TEMP[23] = (char) (x & 1 | 48);
12063: return sb.append (FMT_TEMP, 0, 24);
12064: }
12065:
12066:
12067:
12068:
12069:
12070:
12071:
12072:
12073:
12074:
12075:
12076:
12077:
12078:
12079:
12080:
12081:
12082:
12083:
12084:
12085:
12086:
12087:
12088:
12089:
12090:
12091:
12092:
12093:
12094:
12095:
12096:
12097:
12098: public static char fmtHexc (int x) {
12099: x &= 15;
12100: return (char) ((((9 - x) >> 4) & 7) + 48 + x);
12101: }
12102: public static void fmtHex1 (char[] a, int o, int x) {
12103: x &= 15;
12104: a[o] = (char) ((((9 - x) >> 4) & 7) + 48 + x);
12105: }
12106: public static String fmtHex1 (int x) {
12107: x &= 15;
12108: return Character.toString ((char) ((((9 - x) >> 4) & 7) + 48 + x));
12109: }
12110: public static StringBuilder fmtHex1 (StringBuilder sb, int x) {
12111: x &= 15;
12112: return sb.append ((char) ((((9 - x) >> 4) & 7) + 48 + x));
12113: }
12114:
12115:
12116:
12117:
12118:
12119:
12120: public static void fmtHex2 (char[] a, int o, int x) {
12121: int x0 = x & 15;
12122: int x1 = x >>> 4 & 15;
12123: a[o ] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
12124: a[o + 1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
12125: }
12126: public static String fmtHex2 (int x) {
12127:
12128: int x0 = x & 15;
12129: int x1 = x >>> 4 & 15;
12130: FMT_TEMP[0] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
12131: FMT_TEMP[1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
12132: return String.valueOf (FMT_TEMP, 0, 2);
12133: }
12134: public static StringBuilder fmtHex2 (StringBuilder sb, int x) {
12135: int x0 = x & 15;
12136: int x1 = x >>> 4 & 15;
12137: return (sb.
12138: append ((char) ((((9 - x1) >> 4) & 7) + 48 + x1)).
12139: append ((char) ((((9 - x0) >> 4) & 7) + 48 + x0)));
12140: }
12141:
12142:
12143:
12144:
12145:
12146:
12147: public static void fmtHex4 (char[] a, int o, int x) {
12148: int t;
12149: t = (char) x >>> 12;
12150: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12151: t = x >>> 8 & 15;
12152: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12153: t = x >>> 4 & 15;
12154: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12155: t = x & 15;
12156: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12157: }
12158: public static String fmtHex4 (int x) {
12159:
12160: int t;
12161: t = (char) x >>> 12;
12162: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12163: t = x >>> 8 & 15;
12164: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12165: t = x >>> 4 & 15;
12166: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12167: t = x & 15;
12168: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12169: return String.valueOf (FMT_TEMP, 0, 4);
12170: }
12171: public static StringBuilder fmtHex4 (StringBuilder sb, int x) {
12172:
12173: int t;
12174: t = (char) x >>> 12;
12175: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12176: t = x >>> 8 & 15;
12177: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12178: t = x >>> 4 & 15;
12179: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12180: t = x & 15;
12181: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12182: return sb.append (FMT_TEMP, 0, 4);
12183: }
12184:
12185:
12186:
12187:
12188:
12189:
12190: public static void fmtHex6 (char[] a, int o, int x) {
12191: int t;
12192: t = x >>> 20 & 15;
12193: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12194: t = x >>> 16 & 15;
12195: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12196: t = (char) x >>> 12;
12197: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12198: t = x >>> 8 & 15;
12199: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12200: t = x >>> 4 & 15;
12201: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12202: t = x & 15;
12203: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12204: }
12205: public static String fmtHex6 (int x) {
12206:
12207: int t;
12208: t = x >>> 20 & 15;
12209: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12210: t = x >>> 16 & 15;
12211: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12212: t = (char) x >>> 12;
12213: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12214: t = x >>> 8 & 15;
12215: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12216: t = x >>> 4 & 15;
12217: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12218: t = x & 15;
12219: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12220: return String.valueOf (FMT_TEMP, 0, 6);
12221: }
12222: public static StringBuilder fmtHex6 (StringBuilder sb, int x) {
12223:
12224: int t;
12225: t = x >>> 20 & 15;
12226: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12227: t = x >>> 16 & 15;
12228: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12229: t = (char) x >>> 12;
12230: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12231: t = x >>> 8 & 15;
12232: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12233: t = x >>> 4 & 15;
12234: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12235: t = x & 15;
12236: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12237: return sb.append (FMT_TEMP, 0, 6);
12238: }
12239:
12240:
12241:
12242:
12243:
12244:
12245: public static void fmtHex8 (char[] a, int o, int x) {
12246: int t;
12247: t = x >>> 28;
12248: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12249: t = x >>> 24 & 15;
12250: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12251: t = x >>> 20 & 15;
12252: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12253: t = x >>> 16 & 15;
12254: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12255: t = (char) x >>> 12;
12256: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12257: t = x >>> 8 & 15;
12258: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12259: t = x >>> 4 & 15;
12260: a[o + 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12261: t = x & 15;
12262: a[o + 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12263: }
12264: public static String fmtHex8 (int x) {
12265:
12266: int t;
12267: t = x >>> 28;
12268: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12269: t = x >>> 24 & 15;
12270: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12271: t = x >>> 20 & 15;
12272: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12273: t = x >>> 16 & 15;
12274: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12275: t = (char) x >>> 12;
12276: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12277: t = x >>> 8 & 15;
12278: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12279: t = x >>> 4 & 15;
12280: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12281: t = x & 15;
12282: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12283: return String.valueOf (FMT_TEMP, 0, 8);
12284: }
12285: public static StringBuilder fmtHex8 (StringBuilder sb, int x) {
12286:
12287: int t;
12288: t = x >>> 28;
12289: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12290: t = x >>> 24 & 15;
12291: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12292: t = x >>> 20 & 15;
12293: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12294: t = x >>> 16 & 15;
12295: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12296: t = (char) x >>> 12;
12297: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12298: t = x >>> 8 & 15;
12299: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12300: t = x >>> 4 & 15;
12301: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12302: t = x & 15;
12303: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12304: return sb.append (FMT_TEMP, 0, 8);
12305: }
12306:
12307: public static StringBuilder fmtHex16 (StringBuilder sb, long x) {
12308:
12309: int s, t;
12310: s = (int) (x >>> 32);
12311: t = s >>> 28;
12312: FMT_TEMP[ 0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12313: t = s >>> 24 & 15;
12314: FMT_TEMP[ 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12315: t = s >>> 20 & 15;
12316: FMT_TEMP[ 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12317: t = s >>> 16 & 15;
12318: FMT_TEMP[ 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12319: t = (char) s >>> 12;
12320: FMT_TEMP[ 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12321: t = s >>> 8 & 15;
12322: FMT_TEMP[ 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12323: t = s >>> 4 & 15;
12324: FMT_TEMP[ 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12325: t = s & 15;
12326: FMT_TEMP[ 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12327: s = (int) x;
12328: t = s >>> 28;
12329: FMT_TEMP[ 8] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12330: t = s >>> 24 & 15;
12331: FMT_TEMP[ 9] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12332: t = s >>> 20 & 15;
12333: FMT_TEMP[10] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12334: t = s >>> 16 & 15;
12335: FMT_TEMP[11] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12336: t = (char) s >>> 12;
12337: FMT_TEMP[12] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12338: t = s >>> 8 & 15;
12339: FMT_TEMP[13] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12340: t = s >>> 4 & 15;
12341: FMT_TEMP[14] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12342: t = s & 15;
12343: FMT_TEMP[15] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12344: return sb.append (FMT_TEMP, 0, 16);
12345: }
12346:
12347:
12348:
12349:
12350:
12351:
12352:
12353:
12354:
12355:
12356:
12357:
12358:
12359:
12360:
12361:
12362:
12363:
12364:
12365:
12366:
12367:
12368:
12369:
12370:
12371:
12372:
12373:
12374:
12375:
12376:
12377:
12378:
12379:
12380:
12381:
12382:
12383:
12384:
12385:
12386:
12387:
12388:
12389:
12390:
12391:
12392:
12393:
12394:
12395:
12396:
12397:
12398:
12399:
12400:
12401:
12402:
12403:
12404:
12405:
12406:
12407:
12408:
12409:
12410:
12411:
12412:
12413:
12414: public static final int[] FMT_BCD4 = new int[10000];
12415: public static final int[] FMT_DCB4 = new int[65536];
12416:
12417:
12418:
12419:
12420: public static void fmtInit () {
12421: Arrays.fill (FMT_DCB4, -1);
12422: int i = 0;
12423: int x = 0;
12424: for (int a = 0; a < 10; a++) {
12425: for (int b = 0; b < 10; b++) {
12426: for (int c = 0; c < 10; c++) {
12427: FMT_DCB4[FMT_BCD4[i ] = x ] = i;
12428: FMT_DCB4[FMT_BCD4[i + 1] = x + 1] = i + 1;
12429: FMT_DCB4[FMT_BCD4[i + 2] = x + 2] = i + 2;
12430: FMT_DCB4[FMT_BCD4[i + 3] = x + 3] = i + 3;
12431: FMT_DCB4[FMT_BCD4[i + 4] = x + 4] = i + 4;
12432: FMT_DCB4[FMT_BCD4[i + 5] = x + 5] = i + 5;
12433: FMT_DCB4[FMT_BCD4[i + 6] = x + 6] = i + 6;
12434: FMT_DCB4[FMT_BCD4[i + 7] = x + 7] = i + 7;
12435: FMT_DCB4[FMT_BCD4[i + 8] = x + 8] = i + 8;
12436: FMT_DCB4[FMT_BCD4[i + 9] = x + 9] = i + 9;
12437: i += 10;
12438: x += 1 << 4;
12439: }
12440: x += 6 << 4;
12441: }
12442: x += 6 << 8;
12443: }
12444: }
12445:
12446:
12447:
12448: public static int fmtBcd4 (int x) {
12449:
12450:
12451:
12452:
12453:
12454:
12455:
12456:
12457:
12458: return FMT_BCD4[Math.max (0, Math.min (9999, x))];
12459: }
12460:
12461:
12462:
12463: public static int fmtBcd8 (int x) {
12464: x = Math.max (0, Math.min (99999999, x));
12465:
12466:
12467: int q = (int) ((long) x * 109951163L >>> 40);
12468:
12469: return FMT_BCD4[q] << 16 | FMT_BCD4[x - 10000 * q];
12470: }
12471:
12472:
12473:
12474: public static long fmtBcd12 (long x) {
12475: x = Math.max (0L, Math.min (999999999999L, x));
12476: int q = (int) ((double) x / 100000000.0);
12477: int r = (int) (x - 100000000L * q);
12478:
12479:
12480: int rq = (int) ((long) r * 109951163L >>> 40);
12481:
12482: return (long) FMT_BCD4[q] << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
12483: }
12484:
12485:
12486:
12487: public static long fmtBcd16 (long x) {
12488: x = Math.max (0L, Math.min (9999999999999999L, x));
12489: int q = x <= (1L << 53) ? (int) ((double) x / 100000000.0) : (int) (x / 100000000L);
12490: int r = (int) (x - 100000000L * q);
12491:
12492:
12493: int qq = (int) ((long) q * 109951163L >>> 40);
12494:
12495:
12496:
12497: int rq = (int) ((long) r * 109951163L >>> 40);
12498:
12499: return (long) (FMT_BCD4[qq] << 16 | FMT_BCD4[q - 10000 * qq]) << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
12500: }
12501:
12502:
12503:
12504:
12505:
12506:
12507: public static int fmtCA02u (char[] a, int o, int x) {
12508: if (x < 0 || 99 < x) {
12509: x = 99;
12510: }
12511: x = FMT_BCD4[x];
12512: a[o ] = (char) ('0' | x >>> 4);
12513: a[o + 1] = (char) ('0' | x & 15);
12514: return o + 2;
12515: }
12516: public static StringBuilder fmtSB02u (StringBuilder sb, int x) {
12517: return sb.append (FMT_TEMP, 0, fmtCA02u (FMT_TEMP, 0, x));
12518: }
12519:
12520:
12521:
12522:
12523:
12524: public static int fmtCA2u (char[] a, int o, int x) {
12525: if (x < 0 || 99 < x) {
12526: x = 99;
12527: }
12528: x = FMT_BCD4[x];
12529: if (x <= 0x000f) {
12530: a[o++] = (char) ('0' | x);
12531: } else {
12532: a[o++] = (char) ('0' | x >>> 4);
12533: a[o++] = (char) ('0' | x & 15);
12534: }
12535: return o;
12536: }
12537: public static StringBuilder fmtSB2u (StringBuilder sb, int x) {
12538: return sb.append (FMT_TEMP, 0, fmtCA2u (FMT_TEMP, 0, x));
12539: }
12540:
12541:
12542:
12543:
12544:
12545: public static int fmtCA04u (char[] a, int o, int x) {
12546: if (x < 0 || 9999 < x) {
12547: x = 9999;
12548: }
12549: x = FMT_BCD4[x];
12550: a[o ] = (char) ('0' | x >>> 12);
12551: a[o + 1] = (char) ('0' | x >>> 8 & 15);
12552: a[o + 2] = (char) ('0' | x >>> 4 & 15);
12553: a[o + 3] = (char) ('0' | x & 15);
12554: return o + 4;
12555: }
12556: public static StringBuilder fmtSB04u (StringBuilder sb, int x) {
12557: return sb.append (FMT_TEMP, 0, fmtCA04u (FMT_TEMP, 0, x));
12558: }
12559:
12560:
12561:
12562:
12563:
12564: public static int fmtCA4u (char[] a, int o, int x) {
12565: if (x < 0 || 9999 < x) {
12566: x = 9999;
12567: }
12568: x = FMT_BCD4[x];
12569: if (x <= 0x000f) {
12570: a[o++] = (char) ('0' | x);
12571: } else if (x <= 0x00ff) {
12572: a[o++] = (char) ('0' | x >>> 4);
12573: a[o++] = (char) ('0' | x & 15);
12574: } else if (x <= 0x0fff) {
12575: a[o++] = (char) ('0' | x >>> 8);
12576: a[o++] = (char) ('0' | x >>> 4 & 15);
12577: a[o++] = (char) ('0' | x & 15);
12578: } else {
12579: a[o++] = (char) ('0' | x >>> 12);
12580: a[o++] = (char) ('0' | x >>> 8 & 15);
12581: a[o++] = (char) ('0' | x >>> 4 & 15);
12582: a[o++] = (char) ('0' | x & 15);
12583: }
12584: return o;
12585: }
12586: public static StringBuilder fmtSB4u (StringBuilder sb, int x) {
12587: return sb.append (FMT_TEMP, 0, fmtCA4u (FMT_TEMP, 0, x));
12588: }
12589:
12590:
12591:
12592:
12593:
12594: public static int fmtCA08u (char[] a, int o, int x) {
12595: if (x < 0 || 99999999 < x) {
12596: x = 99999999;
12597: }
12598:
12599:
12600: int h = (int) ((long) x * 109951163L >>> 40);
12601: return fmtCA04u (a, fmtCA04u (a, o, h), x - h * 10000);
12602: }
12603: public static StringBuilder fmtSB08u (StringBuilder sb, int x) {
12604: return sb.append (FMT_TEMP, 0, fmtCA08u (FMT_TEMP, 0, x));
12605: }
12606:
12607:
12608:
12609:
12610:
12611: public static int fmtCA8u (char[] a, int o, int x) {
12612: if (x < 0 || 99999999 < x) {
12613: x = 99999999;
12614: }
12615: if (x <= 9999) {
12616: return fmtCA4u (a, o, x);
12617: } else {
12618:
12619:
12620: int h = (int) ((long) x * 109951163L >>> 40);
12621: return fmtCA04u (a, fmtCA4u (a, o, h), x - h * 10000);
12622: }
12623: }
12624: public static StringBuilder fmtSB8u (StringBuilder sb, int x) {
12625: return sb.append (FMT_TEMP, 0, fmtCA8u (FMT_TEMP, 0, x));
12626: }
12627:
12628:
12629:
12630:
12631:
12632: public static int fmtCAd (char[] a, int o, long x) {
12633: if (x < 0L) {
12634: x = -x;
12635: a[o++] = '-';
12636: }
12637: if (x <= 99999999L) {
12638: return fmtCA8u (a, o, (int) x);
12639: } else if (x <= 9999999999999999L) {
12640: long h = x / 100000000L;
12641: return fmtCA08u (a, fmtCA8u (a, o, (int) h), (int) (x - h * 100000000L));
12642: } else {
12643: long hh = x / 10000000000000000L;
12644: x -= hh * 10000000000000000L;
12645: long h = x / 100000000L;
12646: return fmtCA08u (a, fmtCA08u (a, fmtCA4u (a, o, (int) hh), (int) h), (int) (x - h * 100000000L));
12647: }
12648: }
12649: public static StringBuilder fmtSBd (StringBuilder sb, long x) {
12650: return sb.append (FMT_TEMP, 0, fmtCAd (FMT_TEMP, 0, x));
12651: }
12652:
12653:
12654:
12655:
12656:
12657:
12658: public static int fmtCAnd (char[] a, int o, int n, long x) {
12659: int t = fmtCAd (a, o, x);
12660: n += o;
12661: if (t < n) {
12662: int i = n;
12663: while (o < t) {
12664: a[--i] = a[--t];
12665: }
12666: while (o < i) {
12667: a[--i] = ' ';
12668: }
12669: t = n;
12670: }
12671: return t;
12672: }
12673: public static StringBuilder fmtSBnd (StringBuilder sb, int n, int x) {
12674: return sb.append (FMT_TEMP, 0, fmtCAnd (FMT_TEMP, 0, n, x));
12675: }
12676:
12677:
12678:
12679:
12680:
12681:
12682:
12683:
12684:
12685:
12686:
12687:
12688:
12689: public static int fmtParseInt (String s, int i, int min, int max, int err) {
12690: return fmtParseIntRadix (s, i, min, max, err, 10);
12691: }
12692: public static int fmtParseIntRadix (String s, int i, int min, int max, int err, int radix) {
12693: if (s == null) {
12694: return err;
12695: }
12696: int l = s.length ();
12697: int c = i < l ? s.charAt (i++) : -1;
12698:
12699: while (c == ' ' || c == '\t') {
12700: c = i < l ? s.charAt (i++) : -1;
12701: }
12702:
12703: int n = 0;
12704: if (c == '+') {
12705: c = i < l ? s.charAt (i++) : -1;
12706: } else if (c == '-') {
12707: n = 1;
12708: c = i < l ? s.charAt (i++) : -1;
12709: }
12710:
12711:
12712:
12713:
12714: int o;
12715: int p;
12716: if (c == '$') {
12717: o = 0x07ffffff + n;
12718: p = 15 + n & 15;
12719: radix = 16;
12720: c = i < l ? s.charAt (i++) : -1;
12721: } else if (radix == 16) {
12722: o = 0x07ffffff + n;
12723: p = 15 + n & 15;
12724: } else if (radix == 8) {
12725: o = 0x0fffffff + n;
12726: p = 7 + n & 7;
12727: } else if (radix == 2) {
12728: o = 0x3fffffff + n;
12729: p = 1 + n & 1;
12730: } else {
12731: o = 214748364;
12732: p = 7 + n;
12733: radix = 10;
12734: }
12735:
12736: int x = Character.digit (c, radix);
12737: if (x < 0) {
12738: return err;
12739: }
12740: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12741: while (c >= 0) {
12742: int t = x - o;
12743: if (t > 0 || t == 0 && c > p) {
12744: return err;
12745: }
12746: x = x * radix + c;
12747: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12748: }
12749: if (n != 0) {
12750: x = -x;
12751: }
12752: return min <= x && x <= max ? x : err;
12753: }
12754:
12755:
12756:
12757:
12758:
12759:
12760:
12761:
12762:
12763:
12764: public static long matMax3 (long x1, long x2, long x3) {
12765: return Math.max (Math.max (x1, x2), x3);
12766: }
12767: public static long matMax4 (long x1, long x2, long x3, long x4) {
12768: return Math.max (Math.max (x1, x2), Math.max (x3, x4));
12769: }
12770: public static long matMax5 (long x1, long x2, long x3, long x4, long x5) {
12771: return Math.max (Math.max (Math.max (x1, x2), Math.max (x3, x4)), x5);
12772: }
12773:
12774:
12775:
12776:
12777:
12778: public static long matMin3 (long x1, long x2, long x3) {
12779: return Math.min (Math.min (x1, x2), x3);
12780: }
12781: public static long matMin4 (long x1, long x2, long x3, long x4) {
12782: return Math.min (Math.min (x1, x2), Math.min (x3, x4));
12783: }
12784: public static long matMin5 (long x1, long x2, long x3, long x4, long x5) {
12785: return Math.min (Math.min (Math.min (x1, x2), Math.min (x3, x4)), x5);
12786: }
12787:
12788:
12789:
12790:
12791:
12792:
12793:
12794:
12795:
12796:
12797:
12798:
12799: public static String strEncodeUTF8 (String s) {
12800: StringBuilder sb = new StringBuilder ();
12801: int l = s.length ();
12802: for (int i = 0; i < l; i++) {
12803: int u = s.charAt (i);
12804: if (0xd800 <= u && u <= 0xdbff && i + 1 < l) {
12805: int v = s.charAt (i + 1);
12806: if (0xdc00 <= v && v <= 0xdfff) {
12807: u = 0x10000 + ((u & 0x3ff) << 10) + (v & 0x3ff);
12808: i++;
12809: }
12810: }
12811: if ((u & 0xffffff80) == 0) {
12812: sb.append ((char) u);
12813: } else if ((u & 0xfffff800) == 0) {
12814: u = (0x0000c080 |
12815: (u & 0x000007c0) << 2 |
12816: (u & 0x0000003f));
12817: sb.append ((char) (u >> 8)).append ((char) (u & 0xff));
12818: } else if ((u & 0xffff0000) == 0 && !(0xd800 <= u && u <= 0xdfff)) {
12819: u = (0x00e08080 |
12820: (u & 0x0000f000) << 4 |
12821: (u & 0x00000fc0) << 2 |
12822: (u & 0x0000003f));
12823: sb.append ((char) (u >> 16)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12824: } else if ((u & 0xffe00000) == 0) {
12825: u = (0xf0808080 |
12826: (u & 0x001c0000) << 6 |
12827: (u & 0x0003f000) << 4 |
12828: (u & 0x00000fc0) << 2 |
12829: (u & 0x0000003f));
12830: sb.append ((char) ((u >> 24) & 0xff)).append ((char) ((u >> 16) & 0xff)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12831: } else {
12832: sb.append ((char) 0xef).append ((char) 0xbf).append ((char) 0xbd);
12833: }
12834: }
12835: return sb.toString ();
12836: }
12837:
12838:
12839:
12840:
12841:
12842:
12843:
12844: public static String strDecodeUTF8 (String s) {
12845: StringBuilder sb = new StringBuilder ();
12846: int l = s.length ();
12847: for (int i = 0; i < l; i++) {
12848: int c = s.charAt (i) & 0xff;
12849: for (int k = ((c & 0x80) == 0x00 ? 0 :
12850: (c & 0xe0) == 0xc0 ? 1 :
12851: (c & 0xf0) == 0xe0 ? 2 :
12852: (c & 0xf8) == 0xf0 ? 3 :
12853: -1);
12854: --k >= 0; ) {
12855: c = c << 8 | (i + 1 < l ? s.charAt (++i) & 0xff : 0);
12856: }
12857: int u = ((c & 0xffffff80) == 0x00000000 ? c :
12858: (c & 0xffffe0c0) == 0x0000c080 ? ((c & 0x00001f00) >> 2 |
12859: (c & 0x0000003f)) :
12860: (c & 0xfff0c0c0) == 0x00e08080 ? ((c & 0x000f0000) >> 4 |
12861: (c & 0x00003f00) >> 2 |
12862: (c & 0x0000003f)) :
12863: (c & 0xf8c0c0c0) == 0xf0808080 ? ((c & 0x07000000) >> 6 |
12864: (c & 0x003f0000) >> 4 |
12865: (c & 0x00003f00) >> 2 |
12866: (c & 0x0000003f)) :
12867: 0xfffd);
12868: if (u <= 0x0000ffff) {
12869: sb.append (0xd800 <= u && u <= 0xdfff ? '\ufffd' :
12870: (char) u);
12871: } else if (u <= 0x0010ffff) {
12872: u -= 0x000010000;
12873: sb.append ((char) (0xd800 + ((u >> 10) & 0x3ff))).append ((char) (0xdc00 + (u & 0x3ff)));
12874: }
12875: }
12876: return sb.toString ();
12877: }
12878:
12879:
12880:
12881:
12882:
12883: public static final int[] IsURIChar = {
12884:
12885:
12886: 0b00000000_00000000_00000000_00000000,
12887: 0b00000000_00000110_11111111_11000000,
12888: 0b01111111_11111111_11111111_11100001,
12889: 0b01111111_11111111_11111111_11100010,
12890: };
12891: public static String strEncodeURI (String s) {
12892: s = strEncodeUTF8 (s);
12893: StringBuilder sb = new StringBuilder ();
12894: int l = s.length ();
12895: for (int i = 0; i < l; i++) {
12896: int c = s.charAt (i);
12897: if (c < 0x80 && IsURIChar[c >> 5] << c < 0) {
12898: sb.append ((char) c);
12899: } else {
12900: fmtHex2 (sb.append ('%'), c);
12901: }
12902: }
12903: return sb.toString ();
12904: }
12905:
12906:
12907:
12908:
12909:
12910: public static final byte[] strIsHexChar = {
12911:
12912: -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,
12913: -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,
12914: -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,
12915: -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,
12916: };
12917: public static String strDecodeURI (String s) {
12918: StringBuilder sb = new StringBuilder ();
12919: int l = s.length ();
12920: for (int i = 0; i < l; i++) {
12921: int c = s.charAt (i);
12922: if (c == '%' && i + 2 < l) {
12923: int d = s.charAt (i + 1);
12924: int e = s.charAt (i + 2);
12925: if (d < 0x80 && (d = strIsHexChar[d]) >= 0 &&
12926: e < 0x80 && (e = strIsHexChar[e]) >= 0) {
12927: sb.append ((char) (d << 4 | e));
12928: } else {
12929: sb.append ((char) c);
12930: }
12931: } else {
12932: sb.append ((char) c);
12933: }
12934: }
12935: return sb.toString ();
12936: }
12937:
12938:
12939:
12940:
12941:
12942:
12943:
12944:
12945: public static BufferedImage createImage (int width, int height, String pattern, int... rgbs) {
12946: BufferedImage image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
12947: int[] bitmap = ((DataBufferInt) image.getRaster ().getDataBuffer ()).getData ();
12948: int length = width * height;
12949: for (int i = 0; i < length; i++) {
12950: char c = pattern.charAt (i);
12951: bitmap[i] = rgbs[c < '0' ? 0 : Character.digit (c, 16)];
12952: }
12953: return image;
12954: }
12955:
12956:
12957:
12958: public static ImageIcon createImageIcon (int width, int height, String pattern, int... rgbs) {
12959: return new ImageIcon (createImage (width, height, pattern, rgbs));
12960: }
12961:
12962:
12963:
12964: public static TexturePaint createTexturePaint (int width, int height, String pattern, int... rgbs) {
12965: return new TexturePaint (createImage (width, height, pattern, rgbs), new Rectangle (0, 0, width, height));
12966: }
12967:
12968:
12969:
12970: public static BufferedImage loadImage (String name) {
12971: BufferedImage image = null;
12972: try {
12973: image = ImageIO.read (new File (name));
12974: } catch (Exception e) {
12975: }
12976: return image;
12977: }
12978:
12979:
12980:
12981:
12982: public static boolean saveImage (BufferedImage image, String name) {
12983: return saveImage (image, name, 0.75F);
12984: }
12985: public static boolean saveImage (BufferedImage image, String name, float quality) {
12986: int index = name.lastIndexOf (".");
12987: if (index < 0) {
12988: return false;
12989: }
12990: if (name.substring (index).equalsIgnoreCase (".ico")) {
12991: return saveIcon (name, image);
12992: }
12993: Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix (name.substring (index + 1));
12994: if (!iterator.hasNext ()) {
12995: return false;
12996: }
12997: ImageWriter imageWriter = iterator.next ();
12998: ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam ();
12999: if (imageWriteParam.canWriteCompressed ()) {
13000: imageWriteParam.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);
13001: imageWriteParam.setCompressionQuality (quality);
13002: }
13003: try {
13004: File file = new File (name);
13005: ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream (file);
13006: imageWriter.setOutput (imageOutputStream);
13007: imageWriter.write (null, new IIOImage (image, null, null), imageWriteParam);
13008: imageOutputStream.close ();
13009: } catch (Exception e) {
13010:
13011: return false;
13012: }
13013: return true;
13014: }
13015:
13016:
13017:
13018:
13019:
13020:
13021:
13022:
13023:
13024:
13025:
13026:
13027:
13028:
13029:
13030:
13031:
13032:
13033:
13034:
13035:
13036:
13037:
13038:
13039:
13040:
13041:
13042:
13043:
13044:
13045:
13046:
13047:
13048:
13049:
13050:
13051:
13052:
13053:
13054:
13055:
13056:
13057:
13058:
13059:
13060:
13061:
13062:
13063:
13064:
13065:
13066:
13067:
13068:
13069:
13070:
13071:
13072:
13073:
13074:
13075:
13076:
13077:
13078:
13079:
13080:
13081:
13082:
13083:
13084:
13085:
13086:
13087:
13088: public static boolean saveIcon (String fileName, BufferedImage... arrayImage) {
13089: int iconCount = arrayImage.length;
13090: int[][] arrayPaletTable = new int[iconCount][];
13091: int[] arrayPaletCount = new int[iconCount];
13092: int[] arrayPixelBits = new int[iconCount];
13093: int[] arrayPatternLineSize = new int[iconCount];
13094: int[] arrayMaskLineSize = new int[iconCount];
13095: int[] arrayImageSize = new int[iconCount];
13096: int[] arrayImageOffset = new int[iconCount];
13097: int fileSize = 6 + 16 * iconCount;
13098: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
13099: BufferedImage image = arrayImage[iconNumber];
13100: int width = image.getWidth ();
13101: int height = image.getHeight ();
13102:
13103: int[] paletTable = new int[256];
13104: int paletCount = 0;
13105: countPalet:
13106: for (int y = height - 1; y >= 0; y--) {
13107: for (int x = 0; x < width; x++) {
13108: int rgb = image.getRGB (x, y);
13109: if (rgb >>> 24 != 0xff) {
13110: continue;
13111: }
13112: int l = 0;
13113: int r = paletCount;
13114: while (l < r) {
13115: int m = l + r >> 1;
13116: if (paletTable[m] < rgb) {
13117: l = m + 1;
13118: } else {
13119: r = m;
13120: }
13121: }
13122: if (l == paletCount || paletTable[l] != rgb) {
13123: if (paletCount == 256) {
13124: paletCount = 0;
13125: break countPalet;
13126: }
13127: for (int i = paletCount; i > l; i--) {
13128: paletTable[i] = paletTable[i - 1];
13129: }
13130: paletTable[l] = rgb;
13131: paletCount++;
13132: }
13133: }
13134: }
13135: int pixelBits = (paletCount == 0 ? 24 :
13136: paletCount > 16 ? 8 :
13137: paletCount > 4 ? 4 :
13138: paletCount > 2 ? 2 :
13139: 1);
13140: int patternLineSize = pixelBits * width + 31 >> 5 << 2;
13141: int maskLineSize = width + 31 >> 5 << 2;
13142: int imageSize = 40 + 4 * paletCount + patternLineSize * height + maskLineSize * height;
13143: arrayPaletTable[iconNumber] = paletTable;
13144: arrayPaletCount[iconNumber] = paletCount;
13145: arrayPixelBits[iconNumber] = pixelBits;
13146: arrayPatternLineSize[iconNumber] = patternLineSize;
13147: arrayMaskLineSize[iconNumber] = maskLineSize;
13148: arrayImageSize[iconNumber] = imageSize;
13149: arrayImageOffset[iconNumber] = fileSize;
13150: fileSize += imageSize;
13151: }
13152: byte[] bb = new byte[fileSize];
13153:
13154: ByteArray.byaWiw (bb, 0, 0);
13155: ByteArray.byaWiw (bb, 2, 1);
13156: ByteArray.byaWiw (bb, 4, iconCount);
13157: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
13158: BufferedImage image = arrayImage[iconNumber];
13159: int width = image.getWidth ();
13160: int height = image.getHeight ();
13161: int[] paletTable = arrayPaletTable[iconNumber];
13162: int paletCount = arrayPaletCount[iconNumber];
13163: int pixelBits = arrayPixelBits[iconNumber];
13164: int patternLineSize = arrayPatternLineSize[iconNumber];
13165: int maskLineSize = arrayMaskLineSize[iconNumber];
13166: int imageSize = arrayImageSize[iconNumber];
13167: int imageOffset = arrayImageOffset[iconNumber];
13168:
13169: int o = 6 + 16 * iconNumber;
13170: ByteArray.byaWb (bb, o, width);
13171: ByteArray.byaWb (bb, o + 1, height);
13172: ByteArray.byaWb (bb, o + 2, paletCount);
13173: ByteArray.byaWb (bb, o + 3, 0);
13174: ByteArray.byaWiw (bb, o + 4, 1);
13175: ByteArray.byaWiw (bb, o + 6, pixelBits);
13176: ByteArray.byaWil (bb, o + 8, imageSize);
13177: ByteArray.byaWil (bb, o + 12, imageOffset);
13178:
13179: o = imageOffset;
13180: ByteArray.byaWil (bb, o, 40);
13181: ByteArray.byaWil (bb, o + 4, width);
13182: ByteArray.byaWil (bb, o + 8, height * 2);
13183: ByteArray.byaWiw (bb, o + 12, 1);
13184: ByteArray.byaWiw (bb, o + 14, pixelBits);
13185: ByteArray.byaWil (bb, o + 16, 0);
13186: ByteArray.byaWil (bb, o + 20, 0);
13187: ByteArray.byaWil (bb, o + 24, 0);
13188: ByteArray.byaWil (bb, o + 28, 0);
13189: ByteArray.byaWil (bb, o + 32, paletCount);
13190: ByteArray.byaWil (bb, o + 36, 0);
13191:
13192: o += 40;
13193: for (int i = 0; i < paletCount; i++) {
13194: ByteArray.byaWil (bb, o, paletTable[i] & 0x00ffffff);
13195: o += 4;
13196: }
13197:
13198: for (int y = height - 1; y >= 0; y--) {
13199: for (int x = 0; x < width; x++) {
13200: int rgb = image.getRGB (x, y);
13201: if (rgb >>> 24 != 0xff) {
13202: continue;
13203: }
13204: if (pixelBits == 24) {
13205: bb[o + 3 * x] = (byte) rgb;
13206: bb[o + 3 * x + 1] = (byte) (rgb >> 8);
13207: bb[o + 3 * x + 2] = (byte) (rgb >> 16);
13208: continue;
13209: }
13210: int l = 0;
13211: int r = paletCount;
13212: while (l < r) {
13213: int m = l + r >> 1;
13214: if (paletTable[m] < rgb) {
13215: l = m + 1;
13216: } else {
13217: r = m;
13218: }
13219: }
13220: if (l != 0) {
13221: if (pixelBits == 8) {
13222: bb[o + x] = (byte) l;
13223: } else if (pixelBits == 4) {
13224: bb[o + (x >> 1)] |= (byte) (l << ((~x & 1) << 2));
13225: } else if (pixelBits == 2) {
13226: bb[o + (x >> 2)] |= (byte) (l << ((~x & 3) << 1));
13227: } else {
13228: bb[o + (x >> 3)] |= (byte) (l << (~x & 7));
13229: }
13230: }
13231: }
13232: o += patternLineSize;
13233: }
13234:
13235: for (int y = height - 1; y >= 0; y--) {
13236: for (int x = 0; x < width; x++) {
13237: int rgb = image.getRGB (x, y);
13238: if (rgb >>> 24 != 0xff) {
13239: bb[o + (x >> 3)] |= (byte) (1 << (~x & 7));
13240: }
13241: }
13242: o += maskLineSize;
13243: }
13244: }
13245: return rscPutFile (fileName, bb, 0, fileSize);
13246: }
13247:
13248:
13249:
13250: }
13251:
13252:
13253: