XEiJ.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13: package xeij;
14:
15: import java.awt.*;
16: import java.awt.datatransfer.*;
17: import java.awt.dnd.*;
18: import java.awt.event.*;
19: import java.awt.font.*;
20: import java.awt.geom.*;
21: import java.awt.image.*;
22: import java.io.*;
23: import java.lang.*;
24: import java.math.*;
25: import java.net.*;
26: import java.nio.*;
27: import java.nio.charset.*;
28: import java.nio.file.*;
29: import java.util.*;
30: import java.util.function.*;
31: import java.util.regex.*;
32: import java.util.stream.*;
33: import java.util.zip.*;
34: import javax.imageio.*;
35: import javax.imageio.stream.*;
36: import javax.swing.*;
37: import javax.swing.event.*;
38: import javax.swing.text.*;
39:
40: public class XEiJ {
41:
42:
43:
44:
45:
46: static {
47: System.setProperty ("sun.java2d.d3d", "false");
48: System.setProperty ("sun.java2d.xrender", "false");
49: }
50:
51:
52: public static final String PRG_TITLE = "XEiJ (X68000 Emulator in Java)";
53: public static final String PRG_VERSION = "0.26.04.28";
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 "Fit in window":
2321: pnlSetMode (PNL_FITINWINDOW);
2322: break;
2323: case "Fixed scale":
2324: pnlSetMode (PNL_FIXEDSCALE);
2325: break;
2326: }
2327: }
2328: };
2329: ButtonGroup group = new ButtonGroup ();
2330: mnbFullScreenMenuItem = ComponentFactory.setEnabled (
2331: Multilingual.mlnText (
2332: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FULLSCREEN, "Full screen", listener),
2333: "ja", "全画面表示"),
2334: pnlIsFullScreenSupported);
2335: mnbMaximizedMenuItem = Multilingual.mlnText (
2336: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_MAXIMIZED, "Maximized", listener),
2337: "ja", "最大化");
2338: mnbFitInWindowMenuItem = Multilingual.mlnText (
2339: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FITINWINDOW, "Fit in window", 'W', MNB_MODIFIERS, listener),
2340: "ja", "ウインドウに合わせる");
2341: mnbFixedScaleMenuItem = Multilingual.mlnText (
2342: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FIXEDSCALE, "Fixed scale", 'X', MNB_MODIFIERS, listener),
2343: "ja", "固定倍率");
2344: }
2345:
2346:
2347:
2348: public static void pnlStart2 () {
2349:
2350: frmFrame.addWindowStateListener (new WindowStateListener () {
2351: @Override public void windowStateChanged (WindowEvent we) {
2352: int state = frmFrame.getExtendedState ();
2353: if (pnlMode != PNL_MAXIMIZED &&
2354: (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
2355: pnlSetMode (PNL_MAXIMIZED);
2356: } else if (pnlMode == PNL_MAXIMIZED &&
2357: (state & Frame.MAXIMIZED_BOTH) != Frame.MAXIMIZED_BOTH) {
2358: pnlSetMode (pnlPrevMode);
2359: }
2360: }
2361: });
2362: }
2363:
2364:
2365:
2366: public static void pnlBoot2 () {
2367: if (pnlModeRequest != PNL_UNDEFINED) {
2368: pnlBootTimer = new javax.swing.Timer (PNL_BOOT_DELAY, new ActionListener () {
2369: public void actionPerformed (ActionEvent ae) {
2370: if (pnlModeRequest == PNL_FULLSCREEN) {
2371: mnbFullScreenMenuItem.doClick ();
2372: } else if (pnlModeRequest == PNL_MAXIMIZED) {
2373: mnbMaximizedMenuItem.doClick ();
2374: }
2375: pnlBootTimer.stop ();
2376: pnlBootTimer = null;
2377: }
2378: });
2379: pnlBootTimer.start ();
2380: }
2381: }
2382:
2383:
2384:
2385: public static void pnlSetMode (int mode) {
2386: do {
2387:
2388: if (pnlMode == mode) {
2389: break;
2390: }
2391:
2392: String text = null;
2393: if (mode == PNL_FULLSCREEN) {
2394: if (!pnlIsFullScreenSupported) {
2395: JOptionPane.showMessageDialog (
2396: frmFrame,
2397: Multilingual.mlnJapanese ?
2398: "全画面表示に対応していません" :
2399: "Full screen is not supported");
2400: break;
2401: }
2402: if (Bubble.BBL_ON) {
2403: text = ButtonFunction.bfnFullScreenText ();
2404: if (text == null) {
2405: JOptionPane.showMessageDialog (
2406: frmFrame,
2407: Multilingual.mlnJapanese ?
2408: "全画面表示を終了するキーまたはボタンがありません" :
2409: "No key or button to exit full screen");
2410: break;
2411: }
2412: }
2413: }
2414:
2415: if (pnlMode == PNL_FULLSCREEN) {
2416: pnlMode = pnlPrevMode;
2417: if (Bubble.BBL_ON) {
2418: Bubble.bblEnd ();
2419: }
2420: if (frmScreenDevice.getFullScreenWindow () == frmFrame) {
2421: frmScreenDevice.setFullScreenWindow (null);
2422: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.FRAME);
2423: }
2424: frmFrame.setJMenuBar (mnbMenuBar);
2425: if (pnlHideKeyboard) {
2426: if (pnlPrevKeyboardOn) {
2427: Keyboard.kbdSetOn (true);
2428: }
2429: }
2430: } else if (pnlMode == PNL_MAXIMIZED) {
2431: pnlMode = pnlPrevMode;
2432: if ((frmFrame.getExtendedState () & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
2433: frmFrame.setExtendedState (Frame.NORMAL);
2434: }
2435: }
2436:
2437: if (mode == PNL_FULLSCREEN) {
2438: pnlPrevMode = pnlMode;
2439: if (pnlHideKeyboard) {
2440: pnlPrevKeyboardOn = Keyboard.kbdImage != null;
2441: if (pnlPrevKeyboardOn) {
2442: Keyboard.kbdSetOn (false);
2443: }
2444: }
2445: frmFrame.setJMenuBar (null);
2446: if (frmScreenDevice.getFullScreenWindow () != frmFrame) {
2447: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.NONE);
2448: frmScreenDevice.setFullScreenWindow (frmFrame);
2449: }
2450: if (Bubble.BBL_ON) {
2451: if (text != null) {
2452: Bubble.bblStart (text + (Multilingual.mlnJapanese ? "で全画面表示を終了" : " to exit full screen"), 5000L);
2453: }
2454: }
2455: } else if (mode == PNL_MAXIMIZED) {
2456: pnlPrevMode = pnlMode;
2457: frmFrame.setExtendedState (Frame.MAXIMIZED_BOTH);
2458: }
2459: pnlMode = mode;
2460:
2461:
2462: pnlUpdateArrangement ();
2463: } while (false);
2464:
2465: if (pnlMode == PNL_FIXEDSCALE) {
2466: if (!mnbFixedScaleMenuItem.isSelected ()) {
2467: mnbFixedScaleMenuItem.setSelected (true);
2468: }
2469: } else if (pnlMode == PNL_FITINWINDOW) {
2470: if (!mnbFitInWindowMenuItem.isSelected ()) {
2471: mnbFitInWindowMenuItem.setSelected (true);
2472: }
2473: } else if (pnlMode == PNL_FULLSCREEN) {
2474: if (!mnbFullScreenMenuItem.isSelected ()) {
2475: mnbFullScreenMenuItem.setSelected (true);
2476: }
2477: } else if (pnlMode == PNL_MAXIMIZED) {
2478: if (!mnbMaximizedMenuItem.isSelected ()) {
2479: mnbMaximizedMenuItem.setSelected (true);
2480: }
2481: }
2482: }
2483:
2484:
2485:
2486:
2487:
2488:
2489: public static Robot rbtRobot;
2490:
2491:
2492: public static void rbtInit () {
2493:
2494:
2495: rbtRobot = null;
2496: try {
2497: rbtRobot = new Robot ();
2498: } catch (Exception e) {
2499: }
2500:
2501: }
2502:
2503:
2504:
2505:
2506:
2507:
2508:
2509: public static final int MNB_MODIFIERS = InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK;
2510:
2511:
2512: public static JMenuBar mnbMenuBar;
2513:
2514:
2515: public static JMenu mnbFileMenu;
2516: public static JMenu mnbDisplayMenu;
2517: public static JMenu mnbSoundMenu;
2518: public static JMenu mnbInputMenu;
2519: public static JMenu mnbConfigMenu;
2520: public static JMenu mnbLanguageMenu;
2521:
2522:
2523:
2524:
2525:
2526: public static JMenuItem mnbQuitMenuItem;
2527: public static JCheckBoxMenuItem mnbStereoscopicMenuItem;
2528: public static JCheckBoxMenuItem mnbPlayMenuItem;
2529: public static JMenuItem mnbPasteMenuItem;
2530: public static JRadioButtonMenuItem mnbStandardKeyboardMenuItem;
2531: public static JRadioButtonMenuItem mnbCompactKeyboardMenuItem;
2532: public static JRadioButtonMenuItem mnbNoKeyboardMenuItem;
2533: public static JLabel mnbVolumeLabel;
2534:
2535:
2536:
2537:
2538:
2539:
2540: public static JMenu mnbMakeFontSizeMenu () {
2541:
2542: ActionListener actionListener = new ActionListener () {
2543: @Override public void actionPerformed (ActionEvent ae) {
2544: String command = ae.getActionCommand ();
2545: switch (command) {
2546: case "Very small":
2547: LnF.lnfFontSizeRequest = 10;
2548: break;
2549: case "Small":
2550: LnF.lnfFontSizeRequest = 12;
2551: break;
2552: case "Medium":
2553: LnF.lnfFontSizeRequest = 14;
2554: break;
2555: case "Large":
2556: LnF.lnfFontSizeRequest = 16;
2557: break;
2558: case "Very large":
2559: LnF.lnfFontSizeRequest = 18;
2560: break;
2561: default:
2562: System.out.println ("unknown action command " + command);
2563: }
2564: }
2565: };
2566:
2567: ButtonGroup fontSizeGroup = new ButtonGroup ();
2568:
2569: return Multilingual.mlnText (
2570: ComponentFactory.createMenu (
2571: "Font size",
2572: Multilingual.mlnText (
2573: ComponentFactory.pointSize (
2574: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 10, "Very small", actionListener),
2575: 10),
2576: "ja", "極小"),
2577: Multilingual.mlnText (
2578: ComponentFactory.pointSize (
2579: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 12, "Small", actionListener),
2580: 12),
2581: "ja", "小"),
2582: Multilingual.mlnText (
2583: ComponentFactory.pointSize (
2584: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 14, "Medium", actionListener),
2585: 14),
2586: "ja", "中"),
2587: Multilingual.mlnText (
2588: ComponentFactory.pointSize (
2589: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 16, "Large", actionListener),
2590: 16),
2591: "ja", "大"),
2592: Multilingual.mlnText (
2593: ComponentFactory.pointSize (
2594: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 18, "Very large", actionListener),
2595: 18),
2596: "ja", "極大")),
2597: "ja", "フォントサイズ");
2598: }
2599:
2600:
2601:
2602: public static final DecimalSpinner[] mnbColorSpinners = new DecimalSpinner[9];
2603: public static final int[] mnbColorRGB = new int[15];
2604: public static JPanel mnbColorPanel;
2605:
2606:
2607:
2608: public static void mnbColorHSBToRGB () {
2609: for (int i = 0; i <= 14; i++) {
2610: int[] t = LnF.LNF_HSB_INTERPOLATION_TABLE[i];
2611: float h = (float) (t[0] * LnF.lnfHSB[0] + t[1] * LnF.lnfHSB[1] + t[2] * LnF.lnfHSB[2]) / (49.0F * 360.0F);
2612: float s = (float) (t[0] * LnF.lnfHSB[3] + t[1] * LnF.lnfHSB[4] + t[2] * LnF.lnfHSB[5]) / (49.0F * 100.0F);
2613: float b = (float) (t[0] * LnF.lnfHSB[6] + t[1] * LnF.lnfHSB[7] + t[2] * LnF.lnfHSB[8]) / (49.0F * 100.0F);
2614: mnbColorRGB[i] = Color.HSBtoRGB (h,
2615: Math.max (0.0F, Math.min (1.0F, s)),
2616: Math.max (0.0F, Math.min (1.0F, b)));
2617: }
2618: }
2619:
2620:
2621:
2622: public static JMenu mnbMakeColorMenu () {
2623: mnbColorHSBToRGB ();
2624:
2625: mnbColorPanel = ComponentFactory.setColor (
2626: ComponentFactory.setFixedSize (
2627: new JPanel () {
2628: @Override protected void paintComponent (Graphics g) {
2629: super.paintComponent (g);
2630: for (int i = 0; i <= 14; i++) {
2631: g.setColor (new Color (mnbColorRGB[i]));
2632: g.fillRect (LnF.lnfFontSize * i, 0, LnF.lnfFontSize, LnF.lnfFontSize * 5);
2633: }
2634: }
2635: },
2636: LnF.lnfFontSize * 15, LnF.lnfFontSize * 5),
2637: Color.white, Color.black);
2638:
2639: ChangeListener changeListener = new ChangeListener () {
2640: @Override public void stateChanged (ChangeEvent ce) {
2641: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
2642: LnF.lnfHSB[spinner.getOption ()] = spinner.getIntValue ();
2643: mnbColorHSBToRGB ();
2644: mnbColorPanel.repaint ();
2645: }
2646: };
2647:
2648: ActionListener actionListener = new ActionListener () {
2649: @Override public void actionPerformed (ActionEvent ae) {
2650: String command = ae.getActionCommand ();
2651: switch (command) {
2652: case "Reset to default values":
2653: for (int i = 0; i < 9; i++) {
2654: LnF.lnfHSB[i] = LnF.LNF_DEFAULT_HSB[i];
2655: mnbColorSpinners[i].setIntValue (LnF.lnfHSB[i]);
2656: }
2657: mnbColorHSBToRGB ();
2658: mnbColorPanel.repaint ();
2659: break;
2660: default:
2661: System.out.println ("unknown action command " + command);
2662: }
2663: }
2664: };
2665:
2666: for (int i = 0; i < 9; i++) {
2667: mnbColorSpinners[i] = ComponentFactory.createDecimalSpinner (
2668: LnF.lnfHSB[i], 0, i < 3 ? 720 : 100, 1, i, changeListener);
2669: }
2670:
2671: return Multilingual.mlnText (
2672: ComponentFactory.createMenu (
2673: "Color",
2674: ComponentFactory.createHorizontalBox (
2675: mnbColorSpinners[0],
2676: mnbColorSpinners[1],
2677: mnbColorSpinners[2],
2678: ComponentFactory.createLabel ("H °"),
2679: Box.createHorizontalGlue ()
2680: ),
2681: ComponentFactory.createHorizontalBox (
2682: mnbColorSpinners[3],
2683: mnbColorSpinners[4],
2684: mnbColorSpinners[5],
2685: ComponentFactory.createLabel ("S%"),
2686: Box.createHorizontalGlue ()
2687: ),
2688: ComponentFactory.createHorizontalBox (
2689: mnbColorSpinners[6],
2690: mnbColorSpinners[7],
2691: mnbColorSpinners[8],
2692: ComponentFactory.createLabel ("B%"),
2693: Box.createHorizontalGlue ()
2694: ),
2695: ComponentFactory.createHorizontalBox (
2696: ComponentFactory.setLineBorder (mnbColorPanel),
2697: Box.createHorizontalGlue ()
2698: ),
2699: Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset to default values", actionListener), "ja", "初期値に戻す")
2700: ),
2701: "ja", "色");
2702: }
2703:
2704:
2705:
2706:
2707:
2708: public static JMenu mnbMakeLanguageMenu () {
2709:
2710: ActionListener actionListener = new ActionListener () {
2711: @Override public void actionPerformed (ActionEvent ae) {
2712: String command = ae.getActionCommand ();
2713: switch (command) {
2714: case "English":
2715: Multilingual.mlnChange ("en");
2716: break;
2717: case "日本語":
2718: Multilingual.mlnChange ("ja");
2719: break;
2720: default:
2721: System.out.println ("unknown action command " + command);
2722: }
2723: }
2724: };
2725:
2726: ButtonGroup languageGroup = new ButtonGroup ();
2727:
2728: return mnbLanguageMenu = Multilingual.mlnText (
2729: ComponentFactory.createMenu (
2730: "Language", 'L',
2731: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnEnglish, "English", actionListener),
2732: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnJapanese, "日本語", actionListener)
2733: ),
2734: "ja", "言語");
2735: }
2736:
2737:
2738:
2739:
2740:
2741: public static void mnbMakeMenu () {
2742:
2743:
2744: ActionListener listener = new ActionListener () {
2745: @Override public void actionPerformed (ActionEvent ae) {
2746: Object source = ae.getSource ();
2747: String command = ae.getActionCommand ();
2748: switch (command) {
2749:
2750:
2751: case "Quit":
2752: prgTini ();
2753: break;
2754:
2755:
2756: case "50%":
2757: case "75%":
2758: case "100%":
2759: case "150%":
2760: case "200%":
2761: pnlFixedModel.setValue (Integer.valueOf (Integer.parseInt (command.substring (0, command.length () - 1))));
2762: break;
2763: case "Nearest neighbor":
2764: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
2765: break;
2766: case "Bilinear":
2767: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
2768: break;
2769: case "Bicubic":
2770: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
2771: break;
2772:
2773: case "Use canvas":
2774: pnlUseCanvasRequest = ((JCheckBoxMenuItem) source).isSelected ();
2775: break;
2776:
2777: case "Draw all changed pictures":
2778: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2779: CRTC.crtIntermittentInterval = 0;
2780: }
2781: break;
2782: case "Draw a changed picture once every two times":
2783: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2784: CRTC.crtIntermittentInterval = 1;
2785: }
2786: break;
2787: case "Draw a changed picture once every three times":
2788: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2789: CRTC.crtIntermittentInterval = 2;
2790: }
2791: break;
2792: case "Draw a changed picture once every four times":
2793: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2794: CRTC.crtIntermittentInterval = 3;
2795: }
2796: break;
2797: case "Draw a changed picture once every five times":
2798: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2799: CRTC.crtIntermittentInterval = 4;
2800: }
2801: break;
2802:
2803: case "Stereoscopic viewing":
2804: pnlSetStereoscopic (((JCheckBoxMenuItem) source).isSelected (), pnlStereoscopicMethod);
2805: break;
2806: case "Naked-eye crossing":
2807: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_CROSSING);
2808: break;
2809: case "Naked-eye parallel":
2810: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_PARALLEL);
2811: break;
2812: case "Side-by-side":
2813: pnlSetStereoscopic (pnlStereoscopicOn, PNL_SIDE_BY_SIDE);
2814: break;
2815: case "Top-and-bottom":
2816: pnlSetStereoscopic (pnlStereoscopicOn, PNL_TOP_AND_BOTTOM);
2817: break;
2818:
2819: case "Sprite pattern viewer":
2820: if (SpritePatternViewer.SPV_ON) {
2821: SpritePatternViewer.spvOpen ();
2822: }
2823: break;
2824: case "Palette viewer":
2825: if (PaletteViewer.PLV_ON) {
2826: PaletteViewer.plvOpen ();
2827: }
2828: break;
2829: case "Screen mode test":
2830: if (ScreenModeTest.SMT_ON) {
2831: ScreenModeTest.smtOpen ();
2832: }
2833: break;
2834:
2835:
2836: case "Play":
2837: SoundSource.sndSetPlayOn (((JCheckBoxMenuItem) source).isSelected ());
2838: break;
2839: case "OPM output":
2840: OPM.opmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2841: break;
2842: case "OPM log":
2843: OPMLog.olgOpen ();
2844: break;
2845:
2846: case "PCM output":
2847: ADPCM.pcmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2848: break;
2849: case "Sound thinning":
2850: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.THINNING_MONO : SoundSource.SNDRateConverter.THINNING_STEREO;
2851: break;
2852: case "Sound linear interpolation":
2853: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.LINEAR_MONO : SoundSource.SNDRateConverter.LINEAR_STEREO;
2854: break;
2855: case "Sound piecewise-constant area interpolation":
2856: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000;
2857: break;
2858: case "Sound linear area interpolation":
2859: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000;
2860: break;
2861: case "Sound monitor":
2862: SoundMonitor.smnOpen ();
2863: break;
2864: case "PCM piecewise-constant interpolation":
2865: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_CONSTANT);
2866: break;
2867: case "PCM linear interpolation":
2868: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_LINEAR);
2869: break;
2870: case "PCM hermite interpolation":
2871: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_HERMITE);
2872: break;
2873: case "PCM 8MHz/4MHz":
2874: ADPCM.pcmOSCFreqRequest = 0;
2875: break;
2876: case "PCM 8MHz/16MHz":
2877: ADPCM.pcmOSCFreqRequest = 1;
2878: break;
2879: case "Mercury-Unit V4 (MK-MU1)":
2880: MercuryUnit.mu4OnRequest = ((JCheckBoxMenuItem) source).isSelected ();
2881: break;
2882: case "MU4 output":
2883: MercuryUnit.mu4OutputEnable = ((JCheckBoxMenuItem) source).isSelected ();
2884: break;
2885:
2886:
2887: case "Paste":
2888: CONDevice.conDoPaste ();
2889: break;
2890: case "No keyboard":
2891: Keyboard.kbdSetOn (false);
2892: pnlUpdateArrangement ();
2893: break;
2894: case "Standard keyboard":
2895: Keyboard.kbdSetType (Keyboard.KBD_STANDARD_TYPE);
2896: Keyboard.kbdSetOn (true);
2897: pnlUpdateArrangement ();
2898: break;
2899: case "Compact keyboard":
2900: Keyboard.kbdSetType (Keyboard.KBD_COMPACT_TYPE);
2901: Keyboard.kbdSetOn (true);
2902: pnlUpdateArrangement ();
2903: break;
2904: case "Hide keyboard in full screen":
2905: pnlHideKeyboard = ((JCheckBoxMenuItem) source).isSelected ();
2906: if (pnlMode == PNL_FULLSCREEN) {
2907: pnlUpdateArrangement ();
2908: }
2909: break;
2910: case "Key assignments":
2911: Keyboard.kbdOpen ();
2912: break;
2913: case "Joystick port settings":
2914: PPI.ppiOpen ();
2915: break;
2916:
2917:
2918: case "RS-232C and terminal":
2919: RS232CTerminal.trmOpen ();
2920: break;
2921:
2922: case "Console":
2923: DebugConsole.dgtOpen ();
2924: break;
2925: case "Register list":
2926: RegisterList.drpOpen ();
2927: break;
2928: case "Disassemble list":
2929: DisassembleList.ddpOpen (-1, -1, true);
2930: break;
2931: case "Memory dump list":
2932: MemoryDumpList.dmpOpen (-1, -1, true);
2933: break;
2934: case "Logical space monitor":
2935: LogicalSpaceMonitor.atwOpen ();
2936: break;
2937: case "Physical space monitor":
2938: PhysicalSpaceMonitor.paaOpen ();
2939: break;
2940: case "Address translation caches monitor":
2941: if (ATCMonitor.ACM_ON) {
2942: ATCMonitor.acmOpen ();
2943: }
2944: break;
2945: case "Branch log":
2946: if (BranchLog.BLG_ON) {
2947: BranchLog.blgOpen (BranchLog.BLG_SELECT_NONE);
2948: }
2949: break;
2950: case "Program flow visualizer":
2951: if (ProgramFlowVisualizer.PFV_ON) {
2952: ProgramFlowVisualizer.pfvOpen ();
2953: }
2954: break;
2955: case "Raster break point":
2956: if (RasterBreakPoint.RBP_ON) {
2957: RasterBreakPoint.rbpOpen ();
2958: }
2959: break;
2960: case "Data break point":
2961: if (DataBreakPoint.DBP_ON) {
2962: DataBreakPoint.dbpOpen ();
2963: }
2964: break;
2965: case "Root pointer list":
2966: if (RootPointerList.RTL_ON) {
2967: RootPointerList.rtlOpen ();
2968: }
2969: break;
2970:
2971:
2972: case "Adjust clock to host":
2973: RP5C15.rtcSetByHost ();
2974: break;
2975:
2976:
2977:
2978: case "Printer":
2979: PrinterPort.prnOpen ();
2980: break;
2981:
2982: case "Print key and mouse button events":
2983: Mouse.musOutputButtonStatus = ((JCheckBoxMenuItem) source).isSelected ();
2984: break;
2985:
2986: case "Java runtime environment information":
2987: prgOpenJavaDialog ();
2988: break;
2989: case "Version information":
2990: prgOpenAboutDialog ();
2991: break;
2992: case "XEiJ License":
2993: prgOpenXEiJLicenseDialog ();
2994: break;
2995: case "FSHARP License":
2996: prgOpenSHARPLicenseDialog ();
2997: break;
2998: case "ymfm License":
2999: prgOpenYmfmLicenseDialog ();
3000: break;
3001: case "jSerialComm License":
3002: prgOpenJSerialCommLicenseDialog ();
3003: break;
3004:
3005: default:
3006: System.out.println ("unknown action command " + command);
3007:
3008: }
3009: }
3010: };
3011:
3012:
3013: ActionListener mainMemoryListener = new ActionListener () {
3014: @Override public void actionPerformed (ActionEvent ae) {
3015: Object source = ae.getSource ();
3016: String command = ae.getActionCommand ();
3017: switch (command) {
3018: case "1MB":
3019: MainMemory.mmrMemorySizeRequest = 0x00100000;
3020: break;
3021: case "2MB":
3022: MainMemory.mmrMemorySizeRequest = 0x00200000;
3023: break;
3024: case "4MB":
3025: MainMemory.mmrMemorySizeRequest = 0x00400000;
3026: break;
3027: case "6MB":
3028: MainMemory.mmrMemorySizeRequest = 0x00600000;
3029: break;
3030: case "8MB":
3031: MainMemory.mmrMemorySizeRequest = 0x00800000;
3032: break;
3033: case "10MB":
3034: MainMemory.mmrMemorySizeRequest = 0x00a00000;
3035: break;
3036: case "12MB":
3037: MainMemory.mmrMemorySizeRequest = 0x00c00000;
3038: break;
3039: case "Save contents on exit":
3040: MainMemory.mmrMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
3041: break;
3042: }
3043: }
3044: };
3045: ButtonGroup mainMemoryGroup = new ButtonGroup ();
3046: JMenu mainMemoryMenu = Multilingual.mlnText (
3047: ComponentFactory.createMenu (
3048: "Main memory",
3049: Multilingual.mlnText (
3050: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00100000, "1MB", mainMemoryListener),
3051: "ja", "1MB"),
3052: Multilingual.mlnText (
3053: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00200000, "2MB", mainMemoryListener),
3054: "ja", "2MB"),
3055: Multilingual.mlnText (
3056: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00400000, "4MB", mainMemoryListener),
3057: "ja", "4MB"),
3058: Multilingual.mlnText (
3059: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00600000, "6MB", mainMemoryListener),
3060: "ja", "6MB"),
3061: Multilingual.mlnText (
3062: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00800000, "8MB", mainMemoryListener),
3063: "ja", "8MB"),
3064: Multilingual.mlnText (
3065: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00a00000, "10MB", mainMemoryListener),
3066: "ja", "10MB"),
3067: Multilingual.mlnText (
3068: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00c00000, "12MB", mainMemoryListener),
3069: "ja", "12MB"),
3070: ComponentFactory.createHorizontalSeparator (),
3071: Multilingual.mlnText (
3072: ComponentFactory.createCheckBoxMenuItem (MainMemory.mmrMemorySaveOn, "Save contents on exit", mainMemoryListener),
3073: "ja", "終了時に内容を保存する"),
3074: SRAM.smrModifyMemorySizeMenuItem
3075: ),
3076: "ja", "メインメモリ");
3077:
3078:
3079: ActionListener highMemoryListener = new ActionListener () {
3080: @Override public void actionPerformed (ActionEvent ae) {
3081: Object source = ae.getSource ();
3082: String command = ae.getActionCommand ();
3083: switch (command) {
3084: case "None":
3085: busHighMemorySize = 0 << 20;
3086: break;
3087: case "16MB":
3088: busHighMemorySize = 16 << 20;
3089: break;
3090: case "Save contents on exit":
3091: busHighMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
3092: break;
3093: }
3094: }
3095: };
3096: ButtonGroup highMemoryGroup = new ButtonGroup ();
3097: JMenu highMemoryMenu = Multilingual.mlnText (
3098: ComponentFactory.createMenu (
3099: "High memory on X68030/Xellent30",
3100: Multilingual.mlnText (
3101: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 0 << 20, "None", highMemoryListener),
3102: "ja", "なし"),
3103: Multilingual.mlnText (
3104: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 16 << 20, "16MB", highMemoryListener),
3105: "ja", "16MB"),
3106: ComponentFactory.createHorizontalSeparator (),
3107: Multilingual.mlnText (
3108: ComponentFactory.createCheckBoxMenuItem (busHighMemorySaveOn, "Save contents on exit", highMemoryListener),
3109: "ja", "終了時に内容を保存する")
3110: ),
3111: "ja", "X68030/Xellent30 のハイメモリ");
3112:
3113:
3114: ActionListener localMemoryListener = new ActionListener () {
3115: @Override public void actionPerformed (ActionEvent ae) {
3116: Object source = ae.getSource ();
3117: String command = ae.getActionCommand ();
3118: switch (command) {
3119: case "None":
3120: busLocalMemorySize = 0 << 20;
3121: break;
3122: case "16MB":
3123: busLocalMemorySize = 16 << 20;
3124: break;
3125: case "32MB":
3126: busLocalMemorySize = 32 << 20;
3127: break;
3128: case "64MB":
3129: busLocalMemorySize = 64 << 20;
3130: break;
3131: case "128MB":
3132: busLocalMemorySize = 128 << 20;
3133: break;
3134: case "256MB":
3135: busLocalMemorySize = 256 << 20;
3136: break;
3137: case "384MB":
3138: busLocalMemorySize = 384 << 20;
3139: break;
3140: case "512MB":
3141: busLocalMemorySize = 512 << 20;
3142: break;
3143: case "768MB":
3144: busLocalMemorySize = 768 << 20;
3145: break;
3146: case "Save contents on exit":
3147: busLocalMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
3148: break;
3149: case "Available on X68000":
3150: busHimem68000 = ((JCheckBoxMenuItem) source).isSelected ();
3151: break;
3152: case "Available on X68030/Xellent30":
3153: busHighMemory060turboOn = ((JCheckBoxMenuItem) source).isSelected ();
3154: break;
3155: }
3156: }
3157: };
3158: ButtonGroup localMenoryGroup = new ButtonGroup ();
3159: JMenu localMemoryMenu = Multilingual.mlnText (
3160: ComponentFactory.createMenu (
3161: "High memory on 060turbo",
3162: Multilingual.mlnText (
3163: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 0 << 20, "None", localMemoryListener),
3164: "ja", "なし"),
3165: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 16 << 20, "16MB", localMemoryListener),
3166: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 32 << 20, "32MB", localMemoryListener),
3167: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 64 << 20, "64MB", localMemoryListener),
3168: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 128 << 20, "128MB", localMemoryListener),
3169: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 256 << 20, "256MB", localMemoryListener),
3170: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 384 << 20, "384MB", localMemoryListener),
3171: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 512 << 20, "512MB", localMemoryListener),
3172: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 768 << 20, "768MB", localMemoryListener),
3173: ComponentFactory.createHorizontalSeparator (),
3174: Multilingual.mlnText (
3175: ComponentFactory.createCheckBoxMenuItem (busLocalMemorySaveOn, "Save contents on exit", localMemoryListener),
3176: "ja", "終了時に内容を保存する"),
3177: ComponentFactory.createHorizontalSeparator (),
3178: Multilingual.mlnText (
3179: ComponentFactory.createCheckBoxMenuItem (busHimem68000, "Available on X68000", localMemoryListener),
3180: "ja", "X68000 でも有効"),
3181: Multilingual.mlnText (
3182: ComponentFactory.createCheckBoxMenuItem (busHighMemory060turboOn, "Available on X68030/Xellent30", localMemoryListener),
3183: "ja", "X68030/Xellent30 でも有効")
3184: ),
3185: "ja", "060turbo のハイメモリ");
3186:
3187:
3188: ActionListener xellent30Listener = new ActionListener () {
3189: @Override public void actionPerformed (ActionEvent ae) {
3190: Object source = ae.getSource ();
3191: String command = ae.getActionCommand ();
3192: switch (command) {
3193: case "$00EC0000-$00EC3FFF":
3194: xt3DIPSW = 0;
3195: break;
3196: case "$00EC4000-$00EC7FFF":
3197: xt3DIPSW = 1;
3198: break;
3199: case "$00EC8000-$00ECBFFF":
3200: xt3DIPSW = 2;
3201: break;
3202: case "$00ECC000-$00ECFFFF":
3203: xt3DIPSW = 3;
3204: break;
3205: case "256KB":
3206: xt3MemorySizeRequest = 1 << 18;
3207: break;
3208: case "1MB":
3209: xt3MemorySizeRequest = 1 << 20;
3210: break;
3211: case "Save contents on exit":
3212: xt3MemorySave = ((JCheckBoxMenuItem) source).isSelected ();
3213: break;
3214: }
3215: }
3216: };
3217: ButtonGroup xellent30PortGroup = new ButtonGroup ();
3218: ButtonGroup xellent30SizeGroup = new ButtonGroup ();
3219: JMenu xellent30Menu = ComponentFactory.createMenu (
3220: "Xellent30",
3221: ComponentFactory.createRadioButtonMenuItem (
3222: xellent30PortGroup,
3223: xt3DIPSW == 0,
3224: "$00EC0000-$00EC3FFF",
3225: xellent30Listener),
3226: ComponentFactory.createRadioButtonMenuItem (
3227: xellent30PortGroup,
3228: xt3DIPSW == 1,
3229: "$00EC4000-$00EC7FFF",
3230: xellent30Listener),
3231: ComponentFactory.createRadioButtonMenuItem (
3232: xellent30PortGroup,
3233: xt3DIPSW == 2,
3234: "$00EC8000-$00ECBFFF",
3235: xellent30Listener),
3236: ComponentFactory.createRadioButtonMenuItem (
3237: xellent30PortGroup,
3238: xt3DIPSW == 3,
3239: "$00ECC000-$00ECFFFF",
3240: xellent30Listener),
3241: ComponentFactory.createHorizontalSeparator (),
3242: ComponentFactory.createRadioButtonMenuItem (
3243: xellent30SizeGroup,
3244: xt3MemorySizeRequest == 1 << 18,
3245: "256KB",
3246: xellent30Listener),
3247: ComponentFactory.createRadioButtonMenuItem (
3248: xellent30SizeGroup,
3249: xt3MemorySizeRequest == 1 << 20,
3250: "1MB",
3251: xellent30Listener),
3252: ComponentFactory.createHorizontalSeparator (),
3253: Multilingual.mlnText (
3254: ComponentFactory.createCheckBoxMenuItem (xt3MemorySave, "Save contents on exit", xellent30Listener),
3255: "ja", "終了時に内容を保存する")
3256: );
3257:
3258:
3259: JMenu rotationMenu = null;
3260: if (PNL_ROTATION_ON) {
3261: ActionListener rotationListener = new ActionListener () {
3262: @Override public void actionPerformed (ActionEvent ae) {
3263: String command = ae.getActionCommand ();
3264: switch (command) {
3265: case "No rotation (landscape)":
3266: pnlRotationMode = 0;
3267: pnlUpdateArrangement ();
3268: break;
3269: case "90-degree rotation (portrait)":
3270: pnlRotationMode = 1;
3271: pnlUpdateArrangement ();
3272: break;
3273: case "180-degree rotation":
3274: pnlRotationMode = 2;
3275: pnlUpdateArrangement ();
3276: break;
3277: case "270-degree rotation":
3278: pnlRotationMode = 3;
3279: pnlUpdateArrangement ();
3280: break;
3281: default:
3282: System.out.println ("unknown action command " + command);
3283: }
3284: }
3285: };
3286: ButtonGroup rotationGroup = new ButtonGroup ();
3287: rotationMenu = Multilingual.mlnText (
3288: ComponentFactory.createMenu (
3289: "Rotation",
3290: Multilingual.mlnText (
3291: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 0, "No rotation (landscape)", rotationListener),
3292: "ja", "回転なし (横画面)"),
3293: Multilingual.mlnText (
3294: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 1, "90-degree rotation (portrait)", rotationListener),
3295: "ja", "90 度回転 (縦画面)"),
3296: Multilingual.mlnText (
3297: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 2, "180-degree rotation", rotationListener),
3298: "ja", "180 度回転"),
3299: Multilingual.mlnText (
3300: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 3, "270-degree rotation", rotationListener),
3301: "ja", "270 度回転")
3302: ),
3303: "ja", "回転");
3304: }
3305:
3306:
3307: ActionListener aspectListener = new ActionListener () {
3308: @Override public void actionPerformed (ActionEvent ae) {
3309: String command = ae.getActionCommand ();
3310: int i = command.indexOf (',');
3311: int resolutionNumber = Integer.parseInt (command.substring (0, i));
3312: int ratioNumber = Integer.parseInt (command.substring (i + 1));
3313: pnlAspectMap[resolutionNumber] = ratioNumber;
3314: pnlUpdateAspectTable ();
3315: pnlUpdateArrangement ();
3316: }
3317: };
3318: JMenu aspectMenu = ComponentFactory.createMenu ("Aspect ratio");
3319: for (int resolutionNumber = 0; resolutionNumber < PNL_ASPECT_RESOLUTION_COUNT; resolutionNumber++) {
3320: JMenu menu = ComponentFactory.createMenu (PNL_ASPECT_RESOLUTION_NAME[resolutionNumber]);
3321: ButtonGroup group = new ButtonGroup ();
3322: for (int ratioNumber = 0; ratioNumber < PNL_ASPECT_RATIO_COUNT; ratioNumber++) {
3323: if (PNL_ASPECT_RATIO_MATRIX[resolutionNumber][ratioNumber] == 0.0F) {
3324: continue;
3325: }
3326: menu.add (
3327: ComponentFactory.setText (
3328: ComponentFactory.createRadioButtonMenuItem (
3329: group,
3330: pnlAspectMap[resolutionNumber] == ratioNumber,
3331: resolutionNumber + "," + ratioNumber,
3332: aspectListener
3333: ),
3334: (PNL_ASPECT_RATIO_MATRIX[resolutionNumber] == PNL_ASPECT_PIXEL_RATIO_02 ?
3335: String.format ("%s (%.3f)",
3336: PNL_ASPECT_SCREEN_NAME[ratioNumber],
3337: PNL_ASPECT_SCREEN_RATIO[ratioNumber]) :
3338: String.format ("%s (%.3f) @ %s (%.3f)",
3339: PNL_ASPECT_SCREEN_NAME[ratioNumber],
3340: PNL_ASPECT_SCREEN_RATIO[ratioNumber],
3341: PNL_ASPECT_NAME_MATRIX[resolutionNumber][ratioNumber],
3342: PNL_ASPECT_RATIO_MATRIX[resolutionNumber][ratioNumber]))
3343: )
3344: );
3345: }
3346: aspectMenu.add (menu);
3347: }
3348: aspectMenu = Multilingual.mlnText (aspectMenu, "ja", "アスペクト比");
3349:
3350:
3351: ActionListener scanlineListener = new ActionListener () {
3352: @Override public void actionPerformed (ActionEvent ae) {
3353:
3354: String command = ae.getActionCommand ();
3355: switch (command) {
3356: case "Off":
3357: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.OFF;
3358: CRTC.crtAllStamp += 2;
3359: break;
3360: case "Weak":
3361: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.WEAK;
3362: CRTC.crtAllStamp += 2;
3363: break;
3364: case "Medium":
3365: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.MEDIUM;
3366: CRTC.crtAllStamp += 2;
3367: break;
3368: case "Strong":
3369: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.STRONG;
3370: CRTC.crtAllStamp += 2;
3371: break;
3372: case "Black":
3373: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.BLACK;
3374: CRTC.crtAllStamp += 2;
3375: break;
3376: }
3377: }
3378: };
3379: ButtonGroup scanlineGroup = new ButtonGroup ();
3380: JMenu scanlineMenu =
3381: Multilingual.mlnText (
3382: ComponentFactory.createMenu (
3383: "Scanline effect",
3384: Multilingual.mlnText (
3385: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.OFF, "Off", scanlineListener),
3386: "ja", "なし"),
3387: Multilingual.mlnText (
3388: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.WEAK, "Weak", scanlineListener),
3389: "ja", "弱"),
3390: Multilingual.mlnText (
3391: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.MEDIUM, "Medium", scanlineListener),
3392: "ja", "中"),
3393: Multilingual.mlnText (
3394: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.STRONG, "Strong", scanlineListener),
3395: "ja", "強"),
3396: Multilingual.mlnText (
3397: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.BLACK, "Black", scanlineListener),
3398: "ja", "黒")
3399: ),
3400: "ja", "走査線エフェクト");
3401:
3402:
3403: JTextField refreshRateTextField = ComponentFactory.createNumberField (pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate), 8);
3404: refreshRateTextField.addActionListener (
3405: new ActionListener () {
3406: @Override public void actionPerformed (ActionEvent ae) {
3407: JTextField textField = (JTextField) ae.getSource ();
3408: pnlRefreshRate = 0.0;
3409: String s = textField.getText ();
3410: if (!s.equals ("")) {
3411: double rate = 0.0;
3412: try {
3413: rate = Double.parseDouble (s);
3414: } catch (NumberFormatException nfe) {
3415: }
3416: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
3417: pnlRefreshRate = rate;
3418: } else {
3419: textField.setText ("");
3420: }
3421: }
3422: pnlFixedRate = pnlRefreshRate;
3423: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3424: pnlFixedRate = pnlGetRefreshRate ();
3425: }
3426: CRTC.crtUpdateLength ();
3427: }
3428: });
3429:
3430: ButtonGroup unitGroup = new ButtonGroup ();
3431: ButtonGroup frameGroup = new ButtonGroup ();
3432: ButtonGroup hintGroup = new ButtonGroup ();
3433: ButtonGroup vgaGroup = new ButtonGroup ();
3434: ButtonGroup intermittentGroup = new ButtonGroup ();
3435: ButtonGroup sterescopicGroup = new ButtonGroup ();
3436: ButtonGroup soundInterpolationGroup = new ButtonGroup ();
3437: ButtonGroup adpcmInterpolationGroup = new ButtonGroup ();
3438: ButtonGroup adpcmOSCFreqGroup = new ButtonGroup ();
3439: ButtonGroup keyboardGroup = new ButtonGroup ();
3440: ButtonGroup spritesGroup = new ButtonGroup ();
3441:
3442:
3443: DecimalSpinner[] freqSpinner = new DecimalSpinner[3];
3444: ChangeListener freqListener = new ChangeListener () {
3445: @Override public void stateChanged (ChangeEvent ce) {
3446: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
3447: int i = spinner.getOption ();
3448: CRTC.crtFreqsRequest[i] = spinner.getIntValue ();
3449: }
3450: };
3451: for (int i = 0; i < 3; i++) {
3452: freqSpinner[i] = ComponentFactory.createDecimalSpinner (
3453: CRTC.crtFreqsRequest[i], CRTC.CRT_MIN_FREQ, CRTC.CRT_MAX_FREQ, 1000000, i, freqListener
3454: );
3455: }
3456: DecimalSpinner sprrasSpinner = ComponentFactory.createDecimalSpinner (
3457: SpriteScreen.sprSpritesPerRaster, 0, 1016, 1, 0,
3458: new ChangeListener () {
3459: @Override public void stateChanged (ChangeEvent ce) {
3460: SpriteScreen.sprSpritesPerRaster = ((DecimalSpinner) ce.getSource ()).getIntValue ();
3461: }
3462: });
3463: ActionListener modificationListener = new ActionListener () {
3464: @Override public void actionPerformed (ActionEvent ae) {
3465: Object source = ae.getSource ();
3466: String command = ae.getActionCommand ();
3467: switch (command) {
3468:
3469: case "Adjust to host refresh rate":
3470: pnlAdjustVsync = ((JCheckBoxMenuItem) source).isSelected ();
3471: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3472: pnlFixedRate = pnlGetRefreshRate ();
3473: }
3474: CRTC.crtUpdateLength ();
3475: break;
3476: case "* Reset to default values":
3477: for (int i = 0; i < 3; i++) {
3478: if (CRTC.crtFreqsRequest[i] != CRTC.CRT_DEFAULT_FREQS[i]) {
3479: CRTC.crtFreqsRequest[i] = CRTC.CRT_DEFAULT_FREQS[i];
3480: freqSpinner[i].setIntValue (CRTC.crtFreqsRequest[i]);
3481: }
3482: }
3483: break;
3484: case "1024-dot non-interlaced":
3485: CRTC.crtEleventhBitRequest = ((JCheckBoxMenuItem) source).isSelected ();
3486: break;
3487: case "Can write 0 to bit 0 of CRTC R00":
3488: CRTC.crtR00Bit0Zero = ((JCheckBoxMenuItem) source).isSelected ();
3489: break;
3490:
3491: case "Extended graphic screen":
3492: CRTC.crtExtendedGraphicRequest = ((JCheckBoxMenuItem) source).isSelected ();
3493: break;
3494:
3495: case "Spherical scrolling of text screen":
3496: CRTC.crtSetSphericalScrolling (((JCheckBoxMenuItem) source).isSelected ());
3497: break;
3498:
3499: case "128 sprites":
3500: SpriteScreen.sprNumberOfSpritesRequest = 128;
3501: break;
3502: case "256 sprites":
3503: SpriteScreen.sprNumberOfSpritesRequest = 256;
3504: break;
3505: case "504 sprites":
3506: SpriteScreen.sprNumberOfSpritesRequest = 512;
3507: break;
3508: case "1016 sprites":
3509: SpriteScreen.sprNumberOfSpritesRequest = 1024;
3510: break;
3511:
3512:
3513:
3514: case "Full pattern memory":
3515: SpriteScreen.sprFPMRequest = ((JCheckBoxMenuItem) source).isSelected ();
3516: break;
3517: case "4096 patterns":
3518: SpriteScreen.sprBankOnRequest = ((JCheckBoxMenuItem) source).isSelected ();
3519: break;
3520: case "Sprites displayed in 768x512":
3521: SpriteScreen.spr768x512Request = ((JCheckBoxMenuItem) source).isSelected ();
3522: break;
3523: case "BG1 displayed in 512x512":
3524: SpriteScreen.spr512bg1Request = ((JCheckBoxMenuItem) source).isSelected ();
3525: break;
3526: case "Row and column scroll":
3527: if (SpriteScreen.SPR_RC_SCROLL_ON) {
3528: SpriteScreen.sprRcScrollRequest = ((JCheckBoxMenuItem) source).isSelected ();
3529: }
3530: break;
3531: case "** Reset to default values":
3532: if (SpriteScreen.sprSpritesPerRaster != 32) {
3533: SpriteScreen.sprSpritesPerRaster = 32;
3534: sprrasSpinner.setIntValue (SpriteScreen.sprSpritesPerRaster);
3535: }
3536: break;
3537: }
3538: }
3539: };
3540: JMenu modificationMenu =
3541: Multilingual.mlnText (
3542: ComponentFactory.createMenu (
3543: "Modification",
3544: Multilingual.mlnText (
3545: ComponentFactory.createMenu (
3546: "Dot clock",
3547: Multilingual.mlnText (
3548: ComponentFactory.createCheckBoxMenuItem (pnlAdjustVsync, "Adjust to host refresh rate", modificationListener),
3549: "ja", "ホストのリフレッシュレートに合わせる"),
3550: ComponentFactory.createHorizontalBox (
3551: Box.createHorizontalStrut (20),
3552: refreshRateTextField,
3553: ComponentFactory.createLabel (" Hz"),
3554: Box.createHorizontalGlue ()
3555: ),
3556: ComponentFactory.createHorizontalSeparator (),
3557: ComponentFactory.createHorizontalBox (
3558: Box.createHorizontalStrut (20),
3559: Multilingual.mlnText (ComponentFactory.createLabel ("Dot clock oscillattor"), "ja", "ドットクロックオシレータ"),
3560: Box.createHorizontalGlue ()
3561: ),
3562: ComponentFactory.createHorizontalBox (
3563: Box.createHorizontalStrut (20),
3564: freqSpinner[0],
3565: ComponentFactory.createLabel (" Hz *"),
3566: Box.createHorizontalGlue ()
3567: ),
3568: ComponentFactory.createHorizontalBox (
3569: Box.createHorizontalStrut (20),
3570: freqSpinner[1],
3571: ComponentFactory.createLabel (" Hz *"),
3572: Box.createHorizontalGlue ()
3573: ),
3574: ComponentFactory.createHorizontalBox (
3575: Box.createHorizontalStrut (20),
3576: freqSpinner[2],
3577: ComponentFactory.createLabel (" Hz *"),
3578: Box.createHorizontalGlue ()
3579: ),
3580: Multilingual.mlnText (
3581: ComponentFactory.createMenuItem ("* Reset to default values", modificationListener),
3582: "ja", "* 初期値に戻す"),
3583: ComponentFactory.createHorizontalSeparator (),
3584: Multilingual.mlnText (
3585: ComponentFactory.createCheckBoxMenuItem (CRTC.crtEleventhBitRequest, "1024-dot non-interlaced", modificationListener),
3586: "ja", "1024 ドットノンインターレース"),
3587: Multilingual.mlnText (
3588: ComponentFactory.createCheckBoxMenuItem (CRTC.crtR00Bit0Zero, "Can write 0 to bit 0 of CRTC R00", modificationListener),
3589: "ja", "CRTC R00 のビット 0 に 0 を書き込める")
3590: ),
3591: "ja", "ドットクロック"),
3592: Multilingual.mlnText (
3593: ComponentFactory.createMenu (
3594: "Graphic screen",
3595: !CRTC.CRT_EXTENDED_GRAPHIC ? null : Multilingual.mlnText (
3596: ComponentFactory.createCheckBoxMenuItem (CRTC.crtExtendedGraphicRequest, "Extended graphic screen", modificationListener),
3597: "ja", "拡張グラフィック画面")
3598: ),
3599: "ja", "グラフィック画面"),
3600: Multilingual.mlnText (
3601: ComponentFactory.createMenu (
3602: "Text screen",
3603: Multilingual.mlnText (
3604: ComponentFactory.createCheckBoxMenuItem (CRTC.crtSphericalScrolling, "Spherical scrolling of text screen", modificationListener),
3605: "ja", "テキスト画面の球面スクロール")
3606: ),
3607: "ja", "テキスト画面"),
3608: Multilingual.mlnText (
3609: ComponentFactory.createMenu (
3610: "Sprite screen",
3611: Multilingual.mlnText (
3612: ComponentFactory.createRadioButtonMenuItem (
3613: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 128, "128 sprites", modificationListener),
3614: "ja", "128 枚のスプライト"),
3615: Multilingual.mlnText (
3616: ComponentFactory.createRadioButtonMenuItem (
3617: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 256, "256 sprites", modificationListener),
3618: "ja", "256 枚のスプライト"),
3619: Multilingual.mlnText (
3620: ComponentFactory.createRadioButtonMenuItem (
3621: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 512, "504 sprites", modificationListener),
3622: "ja", "504 枚のスプライト"),
3623: Multilingual.mlnText (
3624: ComponentFactory.createRadioButtonMenuItem (
3625: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 1024, "1016 sprites", modificationListener),
3626: "ja", "1016 枚のスプライト"),
3627:
3628:
3629:
3630:
3631: ComponentFactory.createHorizontalSeparator (),
3632: Multilingual.mlnText (
3633: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprFPMRequest, "Full pattern memory", modificationListener),
3634: "ja", "フルパターンメモリ"),
3635: ComponentFactory.createHorizontalSeparator (),
3636: Multilingual.mlnText (
3637: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprBankOnRequest, "4096 patterns", modificationListener),
3638: "ja", "4096 個のパターン"),
3639: Multilingual.mlnText (
3640: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr768x512Request, "Sprites displayed in 768x512", modificationListener),
3641: "ja", "768x512 でスプライトを表示"),
3642: Multilingual.mlnText (
3643: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr512bg1Request, "BG1 displayed in 512x512", modificationListener),
3644: "ja", "512x512 で BG1 を表示"),
3645: !SpriteScreen.SPR_RC_SCROLL_ON ? null : Multilingual.mlnText (
3646: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprRcScrollRequest, "Row and column scroll", modificationListener),
3647: "ja", "行スクロールと列スクロール"),
3648: ComponentFactory.createHorizontalSeparator (),
3649: ComponentFactory.createHorizontalBox (
3650: Box.createHorizontalStrut (20),
3651: Multilingual.mlnText (ComponentFactory.createLabel ("Number of sprites per raster"), "ja", "ラスタあたりのスプライトの枚数"),
3652: Box.createHorizontalGlue ()
3653: ),
3654: ComponentFactory.createHorizontalBox (
3655: Box.createHorizontalStrut (20),
3656: sprrasSpinner,
3657: ComponentFactory.createLabel (" **"),
3658: Box.createHorizontalGlue ()
3659: ),
3660: Multilingual.mlnText (
3661: ComponentFactory.createMenuItem ("** Reset to default values", modificationListener),
3662: "ja", "** 初期値に戻す")
3663: ),
3664: "ja", "スプライト画面")
3665: ),
3666: "ja", "改造");
3667:
3668:
3669: mnbMenuBar = ComponentFactory.createMenuBar (
3670:
3671:
3672: mnbFileMenu = Multilingual.mlnText (
3673: ComponentFactory.createMenu (
3674: "File", 'F',
3675:
3676: FDC.fdcMenu,
3677:
3678: HDC.hdcMenu,
3679:
3680: SPC.spcMenu,
3681:
3682: HFS.hfsMenu,
3683: ComponentFactory.createHorizontalSeparator (),
3684: mnbQuitMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Quit", 'Q', MNB_MODIFIERS, listener), "ja", "終了")
3685: ),
3686: "ja", "ファイル"),
3687:
3688:
3689: mpuMenu,
3690:
3691:
3692: mnbDisplayMenu = Multilingual.mlnText (
3693: ComponentFactory.createMenu (
3694: "Display", 'D',
3695: mnbFullScreenMenuItem,
3696: !PNL_ROUNDED_CORNER_ON ? null : ComponentFactory.createHorizontalBox (
3697: Box.createHorizontalStrut (20),
3698: Multilingual.mlnText (
3699: ComponentFactory.createLabel ("Rounded corner ratio "),
3700: "ja", "角丸率 "),
3701: pnlRoundedCornerSpinner,
3702: ComponentFactory.createLabel ("%"),
3703: Box.createHorizontalGlue ()
3704: ),
3705: mnbMaximizedMenuItem,
3706: mnbFitInWindowMenuItem,
3707: mnbFixedScaleMenuItem,
3708: ComponentFactory.createHorizontalBox (
3709: Box.createHorizontalStrut (20),
3710: pnlFixedSpinner,
3711: ComponentFactory.createLabel ("%"),
3712: Box.createHorizontalGlue ()
3713: ),
3714: ComponentFactory.createMenuItem ("50%", listener),
3715: ComponentFactory.createMenuItem ("75%", listener),
3716: ComponentFactory.createMenuItem ("100%", listener),
3717: ComponentFactory.createMenuItem ("150%", listener),
3718: ComponentFactory.createMenuItem ("200%", listener),
3719:
3720: rotationMenu,
3721:
3722: aspectMenu,
3723:
3724: Multilingual.mlnText (
3725: ComponentFactory.createMenu (
3726: "Interpolation algorithm",
3727: Multilingual.mlnText (
3728: ComponentFactory.createRadioButtonMenuItem (
3729: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
3730: "Nearest neighbor", listener),
3731: "ja", "最近傍補間"),
3732: Multilingual.mlnText (
3733: ComponentFactory.createRadioButtonMenuItem (
3734: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR,
3735: "Bilinear", listener),
3736: "ja", "線形補間"),
3737: Multilingual.mlnText (
3738: ComponentFactory.createRadioButtonMenuItem (
3739: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC,
3740: "Bicubic", listener),
3741: "ja", "三次補間")
3742: ),
3743: "ja", "補間アルゴリズム"),
3744:
3745: scanlineMenu,
3746: !PNL_USE_CANVAS ? null : Multilingual.mlnText (
3747: ComponentFactory.createCheckBoxMenuItem (pnlUseCanvasRequest, "Use canvas", listener),
3748: "ja", "キャンバスを使う"),
3749:
3750: !CRTC.CRT_ENABLE_INTERMITTENT ? null : Multilingual.mlnText (
3751: ComponentFactory.createMenu (
3752: "Intermittent drawing",
3753: Multilingual.mlnText (
3754: ComponentFactory.createRadioButtonMenuItem (
3755: intermittentGroup, CRTC.crtIntermittentInterval == 0, "Draw all changed pictures", listener),
3756: "ja", "変化した画像をすべて描画する"),
3757: Multilingual.mlnText (
3758: ComponentFactory.createRadioButtonMenuItem (
3759: intermittentGroup, CRTC.crtIntermittentInterval == 1, "Draw a changed picture once every two times", listener),
3760: "ja", "変化した画像を 2 回に 1 回描画する"),
3761: Multilingual.mlnText (
3762: ComponentFactory.createRadioButtonMenuItem (
3763: intermittentGroup, CRTC.crtIntermittentInterval == 2, "Draw a changed picture once every three times", listener),
3764: "ja", "変化した画像を 3 回に 1 回描画する"),
3765: Multilingual.mlnText (
3766: ComponentFactory.createRadioButtonMenuItem (
3767: intermittentGroup, CRTC.crtIntermittentInterval == 3, "Draw a changed picture once every four times", listener),
3768: "ja", "変化した画像を 4 回に 1 回描画する"),
3769: Multilingual.mlnText (
3770: ComponentFactory.createRadioButtonMenuItem (
3771: intermittentGroup, CRTC.crtIntermittentInterval == 4, "Draw a changed picture once every five times", listener),
3772: "ja", "変化した画像を 5 回に 1 回描画する")
3773: ),
3774: "ja", "間欠描画"),
3775:
3776: !PNL_STEREOSCOPIC_ON ? null : ComponentFactory.createHorizontalSeparator (),
3777: mnbStereoscopicMenuItem = !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3778: ComponentFactory.createCheckBoxMenuItem (pnlStereoscopicOn, "Stereoscopic viewing", 'T', listener),
3779: "ja", "立体視"),
3780: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3781: ComponentFactory.createMenu (
3782: "Stereoscopic settings",
3783: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3784: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3785: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING,
3786: "Naked-eye crossing", listener),
3787: "ja", "裸眼交差法"),
3788: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3789: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3790: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL,
3791: "Naked-eye parallel", listener),
3792: "ja", "裸眼平行法"),
3793: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3794: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3795: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE,
3796: "Side-by-side", listener),
3797: "ja", "サイドバイサイド"),
3798: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3799: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3800: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM,
3801: "Top-and-bottom", listener),
3802: "ja", "トップアンドボトム")
3803: ),
3804: "ja", "立体視設定"),
3805:
3806: ComponentFactory.createHorizontalSeparator (),
3807: GIFAnimation.gifStartRecordingMenuItem,
3808: GIFAnimation.gifSettingsMenu,
3809:
3810: ComponentFactory.createHorizontalSeparator (),
3811: modificationMenu,
3812:
3813: SpritePatternViewer.SPV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Sprite pattern viewer", listener), "ja", "スプライトパターンビュア") : null,
3814: PaletteViewer.PLV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Palette viewer", listener), "ja", "パレットビュア") : null,
3815: ScreenModeTest.SMT_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Screen mode test", listener), "ja", "表示モードテスト") : null
3816: ),
3817: "ja", "画面"),
3818:
3819:
3820: mnbSoundMenu = ComponentFactory.setEnabled (
3821: Multilingual.mlnText (
3822: ComponentFactory.createMenu (
3823: "Sound", 'S',
3824: mnbPlayMenuItem = ComponentFactory.setEnabled (
3825: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (SoundSource.sndPlayOn, "Play", 'P', MNB_MODIFIERS, listener), "ja", "音声出力"),
3826: SoundSource.sndLine != null),
3827:
3828:
3829:
3830: ComponentFactory.createHorizontalBox (
3831: Box.createHorizontalGlue (),
3832: Multilingual.mlnText (ComponentFactory.createLabel ("Volume "), "ja", "音量 "),
3833: mnbVolumeLabel = ComponentFactory.createLabel (String.valueOf (SoundSource.sndVolume)),
3834: Box.createHorizontalGlue ()
3835: ),
3836:
3837:
3838: ComponentFactory.setPreferredSize (
3839: ComponentFactory.createHorizontalSlider (
3840: 0,
3841: SoundSource.SND_VOLUME_MAX,
3842: SoundSource.sndVolume,
3843: SoundSource.SND_VOLUME_STEP,
3844: 1,
3845: new ChangeListener () {
3846: @Override public void stateChanged (ChangeEvent ce) {
3847: SoundSource.sndSetVolume (((JSlider) ce.getSource ()).getValue ());
3848: }
3849: }),
3850: LnF.lnfFontSize * 18, LnF.lnfFontSize * 2 + 28),
3851: Multilingual.mlnText (
3852: ComponentFactory.createMenu (
3853: "Sound interpolation",
3854: Multilingual.mlnText (
3855: ComponentFactory.createRadioButtonMenuItem (
3856: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.THINNING_STEREO,
3857: "Sound thinning", listener),
3858: "ja", "音声 間引き"),
3859: Multilingual.mlnText (
3860: ComponentFactory.createRadioButtonMenuItem (
3861: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_STEREO,
3862: "Sound linear interpolation", listener),
3863: "ja", "音声 線形補間"),
3864: ComponentFactory.setEnabled (
3865: Multilingual.mlnText (
3866: ComponentFactory.createRadioButtonMenuItem (
3867: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000,
3868: "Sound piecewise-constant area interpolation", listener),
3869: "ja", "音声 区分定数面積補間"),
3870: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000),
3871: ComponentFactory.setEnabled (
3872: Multilingual.mlnText (
3873: ComponentFactory.createRadioButtonMenuItem (
3874: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000,
3875: "Sound linear area interpolation", listener),
3876: "ja", "音声 線形面積補間"),
3877: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000)
3878: ),
3879: "ja", "音声補間"),
3880: Multilingual.mlnText (ComponentFactory.createMenuItem ("Sound monitor", listener), "ja", "音声モニタ"),
3881:
3882: ComponentFactory.createHorizontalSeparator (),
3883:
3884: ComponentFactory.setEnabled (
3885: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (OPM.opmOutputMask != 0, "OPM output", listener), "ja", "OPM 出力"),
3886: SoundSource.sndLine != null),
3887: !OPMLog.OLG_ON ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("OPM log", listener), "ja", "OPM ログ"),
3888:
3889: ComponentFactory.createHorizontalSeparator (),
3890:
3891: ComponentFactory.setEnabled (
3892: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ADPCM.pcmOutputOn, "PCM output", listener), "ja", "PCM 出力"),
3893: SoundSource.sndLine != null),
3894: Multilingual.mlnText (
3895: ComponentFactory.createMenu (
3896: "PCM interpolation",
3897: Multilingual.mlnText (
3898: ComponentFactory.createRadioButtonMenuItem (
3899: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_CONSTANT,
3900: "PCM piecewise-constant interpolation", listener),
3901: "ja", "PCM 区分定数補間"),
3902: Multilingual.mlnText (
3903: ComponentFactory.createRadioButtonMenuItem (
3904: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_LINEAR,
3905: "PCM linear interpolation", listener),
3906: "ja", "PCM 線形補間"),
3907: Multilingual.mlnText (
3908: ComponentFactory.createRadioButtonMenuItem (
3909: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_HERMITE,
3910: "PCM hermite interpolation", listener),
3911: "ja", "PCM エルミート補間")
3912: ),
3913: "ja", "PCM 補間"),
3914: Multilingual.mlnText (
3915: ComponentFactory.createMenu (
3916: "PCM source oscillator frequency",
3917: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 0, "PCM 8MHz/4MHz", listener),
3918: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 1, "PCM 8MHz/16MHz", listener)
3919: ),
3920: "ja", "PCM 原発振周波数"),
3921:
3922: !MercuryUnit.MU4_ON ? null :
3923: ComponentFactory.createHorizontalSeparator (),
3924: !MercuryUnit.MU4_ON ? null :
3925: ComponentFactory.createCheckBoxMenuItem (
3926: MercuryUnit.mu4OnRequest,
3927: "Mercury-Unit V4 (MK-MU1)",
3928: listener),
3929: !MercuryUnit.MU4_ON ? null :
3930: Multilingual.mlnText (
3931: ComponentFactory.createCheckBoxMenuItem (
3932: MercuryUnit.mu4OutputEnable,
3933: "MU4 output",
3934: listener),
3935: "ja", "MU4 出力")
3936: ),
3937: "ja", "音声"),
3938: SoundSource.sndLine != null),
3939:
3940:
3941: mnbInputMenu = Multilingual.mlnText (
3942: ComponentFactory.createMenu (
3943: "Input", 'I',
3944: mnbPasteMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Paste", 'V', MNB_MODIFIERS, listener), "ja", "貼り付け"),
3945: CONDevice.conSettingsMenu,
3946: TextCopy.txcMakeMenuItem (),
3947: TextCopy.txcMakeSettingMenu (),
3948: ComponentFactory.createHorizontalSeparator (),
3949: mnbNoKeyboardMenuItem = Multilingual.mlnText (
3950: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, !Keyboard.kbdOn, "No keyboard", 'K', MNB_MODIFIERS, listener),
3951: "ja", "キーボードなし"),
3952: mnbStandardKeyboardMenuItem = Multilingual.mlnText (
3953: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_STANDARD_TYPE, "Standard keyboard", listener),
3954: "ja", "標準キーボード"),
3955: mnbCompactKeyboardMenuItem = Multilingual.mlnText (
3956: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_COMPACT_TYPE, "Compact keyboard", listener),
3957: "ja", "コンパクトキーボード"),
3958: Multilingual.mlnText (
3959: ComponentFactory.createCheckBoxMenuItem (pnlHideKeyboard, "Hide keyboard in full screen", listener),
3960: "ja", "全画面表示のときキーボードを隠す"),
3961: Multilingual.mlnText (ComponentFactory.createMenuItem ("Key assignments", listener), "ja", "キー割り当て"),
3962: ButtonFunction.bfnMakeMenuItem (),
3963: SRAM.smrRepeatDelayMenu,
3964: SRAM.smrRepeatIntervalMenu,
3965: !Keyboard.KBD_ZKEY_ON ? null : Keyboard.kbdZKeyMenu,
3966: ComponentFactory.createHorizontalSeparator (),
3967: Mouse.musSeamlessMouseCheckBox,
3968: Mouse.musFollowScrollCheckBox,
3969: Mouse.musCtrlRightCheckBox,
3970: Mouse.musEdgeAccelerationCheckBox,
3971: Mouse.musMouseCursorSpeedBox,
3972: Mouse.musSpeedSlider,
3973: Mouse.musHostsPixelUnitsCheckBox,
3974: ComponentFactory.createHorizontalSeparator (),
3975: Multilingual.mlnText (ComponentFactory.createMenuItem ("Joystick port settings", listener), "ja", "ジョイスティックポート設定")
3976: ),
3977: "ja", "入力"),
3978:
3979:
3980: mnbConfigMenu = Multilingual.mlnText (
3981: ComponentFactory.createMenu (
3982: "Config", 'G',
3983: Multilingual.mlnText (ComponentFactory.createMenuItem ("RS-232C and terminal", listener), "ja", "RS-232C とターミナル"),
3984: Multilingual.mlnText (
3985: ComponentFactory.createMenu (
3986: "Debug",
3987: Multilingual.mlnText (ComponentFactory.createMenuItem ("Console", listener), "ja", "コンソール"),
3988: Multilingual.mlnText (ComponentFactory.createMenuItem ("Register list", listener), "ja", "レジスタリスト"),
3989: Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble list", listener), "ja", "逆アセンブルリスト"),
3990: Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory dump list", listener), "ja", "メモリダンプリスト"),
3991: Multilingual.mlnText (ComponentFactory.createMenuItem ("Logical space monitor", listener), "ja", "論理空間モニタ"),
3992: Multilingual.mlnText (ComponentFactory.createMenuItem ("Physical space monitor", listener), "ja", "物理空間モニタ"),
3993: ATCMonitor.ACM_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Address translation caches monitor", listener), "ja", "アドレス変換キャッシュモニタ") : null,
3994: BranchLog.BLG_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Branch log", listener), "ja", "分岐ログ") : null,
3995: ProgramFlowVisualizer.PFV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Program flow visualizer", listener), "ja", "プログラムフロービジュアライザ") : null,
3996: RasterBreakPoint.RBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Raster break point", listener), "ja", "ラスタブレークポイント") : null,
3997: DataBreakPoint.DBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Data break point", listener), "ja", "データブレークポイント") : null,
3998: RootPointerList.RTL_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Root pointer list", listener), "ja", "ルートポインタリスト") : null,
3999: ComponentFactory.createHorizontalSeparator (),
4000: SRAM.smrRomdbMenu
4001: ),
4002: "ja", "デバッグ"),
4003: SRAM.smrBootMenu,
4004: mainMemoryMenu,
4005: highMemoryMenu,
4006: localMemoryMenu,
4007: xellent30Menu,
4008: ComponentFactory.createHorizontalSeparator (),
4009: ComponentFactory.createMenu (
4010: "RTC",
4011: Multilingual.mlnText (
4012: ComponentFactory.createMenuItem ("Adjust clock to host", listener),
4013: "ja", "時計をホストに合わせる")
4014: ),
4015: SRAM.smrMenu,
4016: Settings.sgsMenu,
4017: ComponentFactory.createHorizontalSeparator (),
4018: Multilingual.mlnText (ComponentFactory.createMenuItem ("Printer", listener), "ja", "プリンタ"),
4019: ROM.romMenu,
4020: Multilingual.mlnText (
4021: ComponentFactory.createMenu (
4022: "Miscellaneous",
4023: SlowdownTest.sdtCheckBoxMenuItem,
4024: SlowdownTest.sdtBox,
4025: Multilingual.mlnText (
4026: ComponentFactory.createCheckBoxMenuItem (Mouse.musOutputButtonStatus, "Print key and mouse button events", listener),
4027: "ja", "キーとマウスのボタンのイベントを表示"),
4028: Z8530.SCC_DEBUG_ON ? Z8530.sccDebugMenu : null
4029: ),
4030: "ja", "その他"),
4031: ComponentFactory.createHorizontalSeparator (),
4032: Multilingual.mlnText (
4033: ComponentFactory.createMenu (
4034: "Accessibility",
4035:
4036: !FlashingLights.FLR_ON ? null :
4037: FlashingLights.flrMakeMenu (),
4038: !FlashingLights.FLR_ON ? null :
4039: ComponentFactory.createHorizontalSeparator (),
4040:
4041: mnbMakeFontSizeMenu (),
4042:
4043: mnbMakeColorMenu ()
4044: ),
4045: "ja", "アクセシビリティ"),
4046: ComponentFactory.createHorizontalSeparator (),
4047: Multilingual.mlnText (
4048: ComponentFactory.createMenuItem ("Java runtime environment information", listener),
4049: "ja", "Java 実行環境の情報"),
4050: Multilingual.mlnText (
4051: ComponentFactory.createMenuItem ("Version information", listener),
4052: "ja", "バージョン情報"),
4053: Multilingual.mlnText (
4054: ComponentFactory.createMenu (
4055: "License",
4056: Multilingual.mlnText (ComponentFactory.createMenuItem ("XEiJ License", listener), "ja", "XEiJ 使用許諾条件"),
4057: Multilingual.mlnText (ComponentFactory.createMenuItem ("FSHARP License", listener), "ja", "FSHARP 許諾条件"),
4058: Multilingual.mlnText (ComponentFactory.createMenuItem ("ymfm License", listener), "ja", "ymfm License"),
4059: Multilingual.mlnText (ComponentFactory.createMenuItem ("jSerialComm License", listener), "ja", "jSerialComm License")
4060: ),
4061: "ja", "使用許諾条件")
4062: ),
4063: "ja", "設定"),
4064:
4065: mnbMakeLanguageMenu (),
4066:
4067:
4068: Box.createHorizontalGlue (),
4069: ComponentFactory.createVerticalBox (
4070: Box.createVerticalGlue (),
4071: Indicator.indBox,
4072: Box.createVerticalGlue ()
4073: ),
4074: Box.createHorizontalGlue ()
4075:
4076: );
4077: }
4078:
4079:
4080:
4081:
4082:
4083:
4084:
4085: public static boolean frmIsActive;
4086:
4087:
4088: public static JFrame frmFrame;
4089: public static int frmMarginWidth;
4090: public static int frmMarginHeight;
4091: public static Dimension frmMinimumSize;
4092:
4093:
4094: public static GraphicsDevice frmScreenDevice;
4095:
4096:
4097: public static DropTarget frmDropTarget;
4098:
4099:
4100:
4101: public static void frmInit () {
4102: frmIsActive = false;
4103: frmScreenDevice = GraphicsEnvironment.getLocalGraphicsEnvironment ().getDefaultScreenDevice ();
4104: pnlIsFullScreenSupported = frmScreenDevice.isFullScreenSupported ();
4105: }
4106:
4107:
4108:
4109: public static void frmMake () {
4110:
4111:
4112: frmFrame = ComponentFactory.createRestorableFrame (
4113: Settings.SGS_FRM_FRAME_KEY,
4114: PRG_TITLE + " version " + PRG_VERSION,
4115: mnbMenuBar,
4116: pnlPanel);
4117: frmUpdateTitle ();
4118: frmFrame.setIconImage (LnF.LNF_ICON_IMAGE_48);
4119: frmFrame.setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);
4120:
4121:
4122:
4123:
4124: frmMarginWidth = frmFrame.getWidth () - pnlPanel.getWidth ();
4125: frmMarginHeight = frmFrame.getHeight () - pnlPanel.getHeight ();
4126: frmMinimumSize = new Dimension (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
4127: frmFrame.setMinimumSize (frmMinimumSize);
4128:
4129:
4130:
4131: frmDropTarget = new DropTarget (pnlPanel, DnDConstants.ACTION_COPY, new DropTargetAdapter () {
4132: @Override public void dragOver (DropTargetDragEvent dtde) {
4133: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
4134: dtde.acceptDrag (DnDConstants.ACTION_COPY);
4135: return;
4136: }
4137: dtde.rejectDrag ();
4138: }
4139: @Override public void drop (DropTargetDropEvent dtde) {
4140: try {
4141: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
4142: dtde.acceptDrop (DnDConstants.ACTION_COPY);
4143: boolean reset = false;
4144: int fdu0 = -1;
4145: int fdu = 0;
4146: int hdu0 = -1;
4147: int hdu = 0;
4148: int scu0 = -1;
4149: int scu = 0;
4150: int hfu0 = -1;
4151: int hfu = 0;
4152: for (Object o : (java.util.List) dtde.getTransferable ().getTransferData (DataFlavor.javaFileListFlavor)) {
4153: if (o instanceof File) {
4154: File file = (File) o;
4155: if (file.isFile ()) {
4156: if (FDC.fdcFileFilter.accept (file)) {
4157: if (fdu < FDC.FDC_MAX_UNITS &&
4158: FDC.fdcUnitArray[fdu].insert (file.getPath (), false)) {
4159: if (fdu0 < 0) {
4160: fdu0 = fdu;
4161: }
4162: fdu++;
4163: continue;
4164: }
4165: }
4166: if (HDC.hdcFileFilter.accept (file)) {
4167: if (hdu < 16 &&
4168: HDC.hdcUnitArray[hdu].insert (file.getPath (), false)) {
4169: if (hdu0 < 0) {
4170: hdu0 = hdu;
4171: }
4172: hdu++;
4173: continue;
4174: }
4175: }
4176: if (SPC.spcFileFilter.accept (file)) {
4177: if (scu < 16 &&
4178: SPC.spcUnitArray[scu].insert (file.getPath (), false)) {
4179: if (scu0 < 0) {
4180: scu0 = scu;
4181: }
4182: scu++;
4183: continue;
4184: }
4185: }
4186: }
4187: if (HFS.hfsFileFilter.accept (file)) {
4188: if (hfu < HFS.HFS_MAX_UNITS &&
4189: HFS.hfsUnitArray[hfu].insert (file.getPath (), false)) {
4190: if (hfu0 < 0) {
4191: hfu0 = hfu;
4192: }
4193: hfu++;
4194: continue;
4195: }
4196: }
4197: }
4198: reset = false;
4199: }
4200: dtde.dropComplete (true);
4201: if (reset) {
4202: if (fdu0 >= 0) {
4203: mpuReset (0x9070 | fdu0 << 8, -1);
4204: } else if (hdu0 >= 0) {
4205: mpuReset (0x8000 | hdu0 << 8, -1);
4206: } else if (scu0 >= 0) {
4207: mpuReset (0xa000, SPC.SPC_HANDLE_EX + (scu0 << 2));
4208: } else if (hfu0 >= 0) {
4209: HFS.hfsBootUnit = hfu0;
4210: mpuReset (0xa000, HFS.HFS_BOOT_HANDLE);
4211: }
4212: }
4213: return;
4214: }
4215: } catch (UnsupportedFlavorException ufe) {
4216:
4217: } catch (IOException ioe) {
4218:
4219: }
4220: dtde.rejectDrop();
4221: }
4222: });
4223:
4224: }
4225:
4226:
4227:
4228: public static void frmUpdateTitle () {
4229: frmFrame.setTitle ((currentAccelerator == ACCELERATOR_HYBRID ? "X68000 Hybrid" :
4230: currentModel.getName () +
4231: (currentAccelerator == ACCELERATOR_XELLENT30 ? " with Xellent30" :
4232: currentAccelerator == ACCELERATOR_060TURBO ? " with 060turbo" :
4233: currentAccelerator == ACCELERATOR_060TURBOPRO ? " with 060turboPRO" : "")) +
4234: " - " + PRG_TITLE + " version " + PRG_VERSION);
4235: }
4236:
4237:
4238:
4239: public static void frmStart () {
4240:
4241:
4242:
4243:
4244:
4245:
4246:
4247:
4248: ComponentFactory.addListener (
4249: frmFrame,
4250: new WindowAdapter () {
4251: @Override public void windowActivated (WindowEvent we) {
4252: frmIsActive = true;
4253: }
4254: @Override public void windowClosing (WindowEvent we) {
4255: prgTini ();
4256: }
4257: @Override public void windowDeactivated (WindowEvent we) {
4258: frmIsActive = false;
4259:
4260: }
4261: @Override public void windowOpened (WindowEvent we) {
4262: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
4263: pnlFixedRate = pnlGetRefreshRate ();
4264: }
4265: }
4266: });
4267:
4268:
4269:
4270:
4271: ComponentFactory.addListener (
4272: frmFrame,
4273: new ComponentAdapter () {
4274: @Override public void componentMoved (ComponentEvent ce) {
4275: Point p = pnlPanel.getLocationOnScreen ();
4276: pnlGlobalX = p.x;
4277: pnlGlobalY = p.y;
4278: }
4279: @Override public void componentResized (ComponentEvent ce) {
4280: Point p = pnlPanel.getLocationOnScreen ();
4281: pnlGlobalX = p.x;
4282: pnlGlobalY = p.y;
4283: }
4284: });
4285:
4286: }
4287:
4288:
4289:
4290:
4291:
4292:
4293: public static BufferedImage clpClipboardImage;
4294: public static String clpClipboardString;
4295: public static Clipboard clpClipboard;
4296: public static Transferable clpImageContents;
4297: public static Transferable clpStringContents;
4298: public static ClipboardOwner clpClipboardOwner;
4299: public static boolean clpIsClipboardOwner;
4300:
4301:
4302:
4303:
4304: public static void clpMake () {
4305: Toolkit toolkit = Toolkit.getDefaultToolkit ();
4306: clpClipboard = null;
4307: try {
4308: clpClipboard = toolkit.getSystemClipboard ();
4309: } catch (Exception e) {
4310: return;
4311: }
4312: clpClipboardImage = null;
4313: clpClipboardString = null;
4314: clpImageContents = new Transferable () {
4315: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
4316: if (flavor == DataFlavor.imageFlavor) {
4317: return clpClipboardImage;
4318: } else {
4319: throw new UnsupportedFlavorException (flavor);
4320: }
4321: }
4322: public DataFlavor[] getTransferDataFlavors () {
4323: return new DataFlavor[] { DataFlavor.imageFlavor };
4324: }
4325: public boolean isDataFlavorSupported (DataFlavor flavor) {
4326: return flavor == DataFlavor.imageFlavor;
4327: }
4328: };
4329: clpStringContents = new Transferable () {
4330: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
4331: if (flavor == DataFlavor.stringFlavor) {
4332: return clpClipboardString;
4333: } else {
4334: throw new UnsupportedFlavorException (flavor);
4335: }
4336: }
4337: public DataFlavor[] getTransferDataFlavors () {
4338: return new DataFlavor[] { DataFlavor.stringFlavor };
4339: }
4340: public boolean isDataFlavorSupported (DataFlavor flavor) {
4341: return flavor == DataFlavor.stringFlavor;
4342: }
4343: };
4344: clpIsClipboardOwner = false;
4345:
4346:
4347: clpClipboardOwner = new ClipboardOwner () {
4348: @Override public void lostOwnership (Clipboard clipboard, Transferable contents) {
4349: clpIsClipboardOwner = false;
4350: }
4351: };
4352:
4353:
4354: clpClipboard.addFlavorListener (new FlavorListener () {
4355: @Override public void flavorsChanged (FlavorEvent fe) {
4356: boolean available = false;
4357: try {
4358: available = clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor);
4359: } catch (IllegalStateException ise) {
4360: }
4361: if (mnbPasteMenuItem != null) {
4362: mnbPasteMenuItem.setEnabled (available);
4363: }
4364: }
4365: });
4366: if (!clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor)) {
4367: if (mnbPasteMenuItem != null) {
4368: mnbPasteMenuItem.setEnabled (false);
4369: }
4370: }
4371: }
4372:
4373:
4374:
4375: public static void clpCopy (String s) {
4376: if (clpClipboard != null && s != null) {
4377: clpClipboardString = s;
4378: try {
4379: clpClipboard.setContents (clpStringContents, clpClipboardOwner);
4380: clpIsClipboardOwner = true;
4381: } catch (Exception e) {
4382: return;
4383: }
4384: }
4385: }
4386:
4387:
4388:
4389:
4390:
4391:
4392:
4393:
4394:
4395:
4396:
4397:
4398:
4399:
4400:
4401:
4402:
4403:
4404:
4405:
4406:
4407:
4408:
4409: public static int xt3DIPSWRequest;
4410: public static int xt3DIPSW;
4411: public static int xt3PortAddress;
4412:
4413:
4414: public static int xt3MemorySizeRequest;
4415: public static int xt3MemorySize;
4416: public static boolean xt3MemoryEnabled;
4417: public static int xt3MemoryPosition;
4418: public static int xt3MemoryStart;
4419: public static final byte[] xt3MemoryArray = new byte[1 << 20];
4420: public static boolean xt3MemorySave;
4421:
4422:
4423: public static int xt3SavedPC;
4424: public static final int[] xt3SavedRn = new int[16];
4425:
4426:
4427: public static void xt3Init () {
4428:
4429:
4430: xt3DIPSWRequest = Math.max (0, Math.min (3, Settings.sgsGetInt ("xt3dipsw")));
4431: xt3DIPSW = xt3DIPSWRequest;
4432:
4433:
4434: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4435:
4436:
4437: int memoryKB = Settings.sgsGetInt ("xt3memorykb");
4438: if (!(memoryKB == 1 << 8 || memoryKB == 1 << 10)) {
4439: memoryKB = 1 << 8;
4440: }
4441: xt3MemorySizeRequest = memoryKB << 10;
4442: xt3MemorySize = xt3MemorySizeRequest;
4443:
4444:
4445: xt3MemoryEnabled = false;
4446:
4447:
4448: xt3MemoryPosition = 11 << 20;
4449:
4450:
4451: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4452:
4453:
4454:
4455: byte[] memoryArray = Settings.sgsGetData ("xt3memorydata");
4456: Arrays.fill (xt3MemoryArray,
4457: (byte) 0);
4458: if (memoryArray.length != 0) {
4459: System.arraycopy (memoryArray, 0,
4460: xt3MemoryArray, 0,
4461: Math.min (memoryArray.length, xt3MemoryArray.length));
4462: if (memoryArray.length < xt3MemoryArray.length) {
4463: Arrays.fill (xt3MemoryArray,
4464: memoryArray.length,
4465: xt3MemoryArray.length,
4466: (byte) 0);
4467: }
4468: }
4469:
4470:
4471: xt3MemorySave = Settings.sgsGetOnOff ("xt3memorysave");
4472:
4473:
4474: xt3SavedPC = 0;
4475:
4476: Arrays.fill (xt3SavedRn, 0);
4477:
4478: xt3Reset ();
4479: }
4480:
4481:
4482: public static void xt3Tini () {
4483:
4484:
4485: Settings.sgsPutInt ("xt3dipsw", xt3DIPSW);
4486:
4487:
4488: Settings.sgsPutInt ("xt3memorykb", xt3MemorySizeRequest >> 10);
4489:
4490:
4491: boolean zero = true;
4492: if (xt3MemorySave) {
4493: for (int i = 0; i < 1 << 20; i++) {
4494: if (xt3MemoryArray[i] != 0) {
4495: zero = false;
4496: break;
4497: }
4498: }
4499: }
4500: Settings.sgsCurrentMap.put ("xt3memorydata",
4501: zero ? "" :
4502: ByteArray.byaEncodeBase64 (ByteArray.byaEncodeGzip (xt3MemoryArray, 0, 1 << 20)));
4503:
4504:
4505: Settings.sgsPutOnOff ("xt3memorysave", xt3MemorySave);
4506:
4507: }
4508:
4509:
4510: public static void xt3Reset () {
4511:
4512:
4513: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4514:
4515:
4516: xt3MemorySize = xt3MemorySizeRequest;
4517:
4518:
4519: xt3MemoryEnabled = false;
4520:
4521:
4522: xt3MemoryPosition = 11 << 20;
4523:
4524:
4525: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4526:
4527:
4528: xt3SavedPC = 0;
4529: Arrays.fill (xt3SavedRn, 0);
4530:
4531: }
4532:
4533:
4534: public static int xt3PortRead () {
4535: return (currentIsSecond ? 4 : 0) | (xt3MemoryEnabled ? 2 : 0) | (xt3MemoryPosition == 11 << 20 ? 0 : 1);
4536: }
4537:
4538:
4539: public static void xt3PortWrite (int d) {
4540: boolean nextIsSecond = (d & 4) != 0;
4541: boolean memoryEnabled = (d & 2) != 0;
4542: int memoryPosition = (d & 1) == 0 ? 11 << 20 : 15 << 20;
4543:
4544: if (xt3MemoryEnabled != memoryEnabled ||
4545: xt3MemoryPosition != memoryPosition) {
4546: if (xt3MemoryEnabled) {
4547: if (xt3MemoryPosition == 11 << 20) {
4548: if (MainMemory.mmrMemorySizeCurrent < 12 << 20) {
4549: busSuper (MemoryMappedDevice.MMD_NUL, (12 << 20) - xt3MemorySize, 12 << 20);
4550: } else {
4551: busUser (MemoryMappedDevice.MMD_MMR, (12 << 20) - xt3MemorySize, 12 << 20);
4552: }
4553: } else {
4554: busSuper (MemoryMappedDevice.MMD_ROM, (16 << 20) - xt3MemorySize, 16 << 20);
4555: }
4556: }
4557: xt3MemoryEnabled = memoryEnabled;
4558: xt3MemoryPosition = memoryPosition;
4559: if (xt3MemoryEnabled) {
4560: if (xt3MemoryPosition == 11 << 20) {
4561: busUser (MemoryMappedDevice.MMD_XTM, (12 << 20) - xt3MemorySize, 12 << 20);
4562: } else {
4563: busUser (MemoryMappedDevice.MMD_XTM, (16 << 20) - xt3MemorySize, 16 << 20);
4564: }
4565: }
4566: }
4567:
4568: if (currentIsSecond != nextIsSecond) {
4569:
4570: if (nextIsSecond) {
4571:
4572:
4573: xt3SavedPC = regPC;
4574: System.arraycopy (regRn, 0, xt3SavedRn, 0, 16);
4575:
4576:
4577: if (mpuTask != null) {
4578: mpuClockLimit = 0L;
4579: System.out.println (Multilingual.mlnJapanese ?
4580: Model.MPU_NAMES[currentFirstMPU] + " を停止します" :
4581: Model.MPU_NAMES[currentFirstMPU] + " stops");
4582: mpuTask.cancel ();
4583: mpuTask = null;
4584: }
4585:
4586:
4587: tmrTimer.schedule (new TimerTask () {
4588: @Override public void run () {
4589:
4590:
4591: currentIsSecond = true;
4592: currentMPU = currentSecondMPU;
4593: mpuSetCurrentClock (specifiedSecondClock);
4594:
4595: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
4596: MC68EC030.m30DivZeroVFlag = false;
4597: }
4598:
4599: RegisterList.drpSetMPU ();
4600: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4601: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4602: MC68060.mmuReset ();
4603:
4604: mpuIgnoreAddressError = true;
4605: fpuBox = fpuMotherboardCoprocessor;
4606: fpuBox.epbReset ();
4607: fpuFPn = fpuBox.epbFPn;
4608: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
4609: mpuSetWait ();
4610:
4611: regSRT1 = regSRT0 = 0;
4612: regSRS = REG_SR_S;
4613: regSRM = 0;
4614: regSRI = REG_SR_I;
4615: regCCR = 0;
4616: Arrays.fill (regRn, 0);
4617:
4618: regRn[15] = MainMemory.mmrRls (0x00000000);
4619: regPC = MainMemory.mmrRls (0x00000004);
4620:
4621: mpuIMR = 0;
4622: mpuIRR = 0;
4623: if (MC68901.MFP_DELAYED_INTERRUPT) {
4624: mpuDIRR = 0;
4625: }
4626: mpuISR = 0;
4627:
4628: mpuStart ();
4629: }
4630: }, TMR_DELAY);
4631:
4632: } else {
4633:
4634:
4635: if (mpuTask != null) {
4636: mpuClockLimit = 0L;
4637: System.out.println (Multilingual.mlnJapanese ? "MC68EC030 を停止します" : "MC68EC030 stops");
4638: mpuTask.cancel ();
4639: mpuTask = null;
4640: }
4641:
4642:
4643: tmrTimer.schedule (new TimerTask () {
4644: @Override public void run () {
4645:
4646:
4647: currentIsSecond = false;
4648: currentMPU = currentFirstMPU;
4649: mpuSetCurrentClock (specifiedFirstClock);
4650:
4651: RegisterList.drpSetMPU ();
4652: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4653: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4654: MC68060.mmuReset ();
4655:
4656: mpuIgnoreAddressError = false;
4657: mpuCacheOn = false;
4658: mpuSetWait ();
4659:
4660: regSRT1 = regSRT0 = 0;
4661: regSRS = REG_SR_S;
4662: regSRM = 0;
4663: regSRI = REG_SR_I;
4664: regCCR = 0;
4665:
4666: regPC = xt3SavedPC;
4667: System.arraycopy (xt3SavedRn, 0, regRn, 0, 16);
4668:
4669: mpuIMR = 0;
4670: mpuIRR = 0;
4671: if (MC68901.MFP_DELAYED_INTERRUPT) {
4672: mpuDIRR = 0;
4673: }
4674: mpuISR = 0;
4675:
4676: mpuStart ();
4677: }
4678: }, TMR_DELAY);
4679:
4680: }
4681: }
4682: }
4683:
4684:
4685:
4686:
4687:
4688:
4689: public static JMenu mdlMenu;
4690:
4691: public static JRadioButtonMenuItem mdlShodaiMenuItem;
4692: public static JRadioButtonMenuItem mdlACEMenuItem;
4693: public static JRadioButtonMenuItem mdlEXPERTMenuItem;
4694: public static JRadioButtonMenuItem mdlPROMenuItem;
4695: public static JRadioButtonMenuItem mdlSUPERMenuItem;
4696: public static JRadioButtonMenuItem mdlXVIMenuItem;
4697: public static JRadioButtonMenuItem mdlXellent30MenuItem;
4698: public static JRadioButtonMenuItem mdlCompactMenuItem;
4699: public static JRadioButtonMenuItem mdlHybridMenuItem;
4700: public static JRadioButtonMenuItem mdl060turboPROMenuItem;
4701: public static JRadioButtonMenuItem mdlX68030MenuItem;
4702: public static JRadioButtonMenuItem mdl030CompactMenuItem;
4703: public static JRadioButtonMenuItem mdl060turboMenuItem;
4704: public static JCheckBoxMenuItem mdlMC68010MenuItem;
4705:
4706: public static JMenu coproFPUMenu;
4707:
4708:
4709: public static final int ACCELERATOR_HYBRID = 1;
4710: public static final int ACCELERATOR_XELLENT30 = 2;
4711: public static final int ACCELERATOR_060TURBO = 3;
4712: public static final int ACCELERATOR_060TURBOPRO = 4;
4713: public static final double MHZ_HYBRID_VALUE = 100.0 / 3.0;
4714: public static final String MHZ_HYBRID_STRING = "33.3";
4715: public static final double MHZ_060TURBO_VALUE = 50.0;
4716: public static final String MHZ_060TURBO_STRING = "50";
4717:
4718:
4719:
4720: public static Model specifiedModel;
4721: public static int specifiedAccelerator;
4722: public static boolean mpu010;
4723:
4724: public static boolean specifiedIsSecond;
4725: public static int specifiedFirstMPU;
4726: public static int specifiedSecondMPU;
4727: public static int specifiedMPU;
4728:
4729: public static double specifiedFirstClock;
4730: public static double specifiedSecondClock;
4731: public static double specifiedClock;
4732:
4733: public static int specifiedCopro0;
4734: public static int specifiedCopro1;
4735: public static int specifiedCopro2;
4736: public static int specifiedOnchipFPU;
4737:
4738:
4739:
4740: public static Model currentModel;
4741: public static int currentAccelerator;
4742:
4743: public static boolean currentIsSecond;
4744: public static int currentFirstMPU;
4745: public static int currentSecondMPU;
4746: public static int currentMPU;
4747:
4748:
4749: public static int currentCopro0;
4750: public static int currentCopro1;
4751: public static int currentCopro2;
4752: public static int currentOnchipFPU;
4753:
4754:
4755:
4756: public static void mdlInit () {
4757:
4758:
4759: specifiedModel = Model.COMPACT;
4760: specifiedAccelerator = ACCELERATOR_HYBRID;
4761: mpu010 = Settings.sgsGetOnOff ("mpu010");
4762: {
4763: String paramModel = Settings.sgsGetString ("model");
4764: switch (paramModel.toLowerCase ()) {
4765: case "":
4766: case "none":
4767: case "hybrid":
4768: specifiedModel = Model.COMPACT;
4769: specifiedAccelerator = ACCELERATOR_HYBRID;
4770: break;
4771: case "xellent30":
4772: specifiedModel = Model.XVI;
4773: specifiedAccelerator = ACCELERATOR_XELLENT30;
4774: break;
4775: case "060turbo":
4776: specifiedModel = Model.X68030;
4777: specifiedAccelerator = ACCELERATOR_060TURBO;
4778: break;
4779: case "060turbopro":
4780: specifiedModel = Model.PRO;
4781: specifiedAccelerator = ACCELERATOR_060TURBOPRO;
4782: break;
4783: default:
4784: Model model = Model.fromTypeOrSynonym (paramModel);
4785: if (model != null) {
4786: specifiedModel = model;
4787: specifiedAccelerator = 0;
4788: } else {
4789: System.out.println (Multilingual.mlnJapanese ?
4790: paramModel + " は不明な機種です" :
4791: paramModel + " is unknown model");
4792: specifiedModel = Model.COMPACT;
4793: specifiedAccelerator = ACCELERATOR_HYBRID;
4794: }
4795: }
4796: }
4797:
4798: specifiedIsSecond = false;
4799: specifiedFirstMPU = specifiedModel.getMPU ();
4800: specifiedSecondMPU = Model.MPU_MC68EC030;
4801: {
4802: String[] paramMPUs = Settings.sgsGetString ("mpu").split (",");
4803: for (int i = 0; i < 2; i++) {
4804: int mpu = 0;
4805: String paramMPU = i < paramMPUs.length ? paramMPUs[i] : "";
4806: switch (paramMPU) {
4807: case "":
4808: case "none":
4809: case "-1":
4810: mpu = (i == 0 ?
4811: (specifiedAccelerator == ACCELERATOR_060TURBO ||
4812: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4813: specifiedModel.getMPU ()) :
4814: Model.MPU_MC68EC030);
4815: break;
4816: case "0":
4817: case "68000":
4818: case "mc68000":
4819: mpu = Model.MPU_MC68000;
4820: break;
4821: case "1":
4822: case "68010":
4823: case "mc68010":
4824: mpu = Model.MPU_MC68010;
4825: break;
4826:
4827:
4828:
4829:
4830:
4831: case "3":
4832: case "68ec030":
4833: case "mc68ec030":
4834: mpu = Model.MPU_MC68EC030;
4835: break;
4836:
4837:
4838:
4839:
4840:
4841:
4842:
4843:
4844:
4845:
4846:
4847:
4848:
4849:
4850:
4851:
4852:
4853: case "6":
4854: case "68060":
4855: case "mc68060":
4856: mpu = Model.MPU_MC68060;
4857: break;
4858: default:
4859: Model model = Model.fromTypeOrSynonym (paramMPU);
4860: if (model != null) {
4861: mpu = model.getMPU ();
4862: } else {
4863: System.out.println (Multilingual.mlnJapanese ?
4864: paramMPU + " は不明な MPU です" :
4865: paramMPU + " is unknown MPU");
4866: mpu = specifiedModel.getMPU ();
4867: }
4868: }
4869: if (i == 0) {
4870: specifiedFirstMPU = mpu;
4871: } else {
4872: specifiedSecondMPU = mpu;
4873: }
4874: }
4875: }
4876: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
4877:
4878: specifiedFirstClock = specifiedModel.getClock ();
4879: specifiedSecondClock = specifiedFirstClock * 2.0;
4880: {
4881: String[] paramClocks = Settings.sgsGetString ("clock").split (",");
4882: for (int i = 0; i < 2; i++) {
4883: double clock = 0.0;
4884: String paramClock = i < paramClocks.length ? paramClocks[i] : "";
4885: switch (paramClock.toLowerCase ()) {
4886: case "":
4887: case "none":
4888: case "-1":
4889: clock = (i == 0 ?
4890: (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4891: specifiedAccelerator == ACCELERATOR_060TURBO ||
4892: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4893: specifiedModel.getClock ()) :
4894: specifiedFirstClock * 2.0);
4895: break;
4896: case "hybrid":
4897: clock = MHZ_HYBRID_VALUE;
4898: break;
4899: case "060turbo":
4900: case "060turbopro":
4901: clock = MHZ_060TURBO_VALUE;
4902: break;
4903: case "16.7":
4904: case "xellent30":
4905: clock = 50.0 / 3.0;
4906: break;
4907: case "33.3":
4908: clock = 100.0 / 3.0;
4909: break;
4910: case "66.7":
4911: clock = 200.0 / 3.0;
4912: break;
4913: default:
4914: if (paramClock.matches ("^(?:" +
4915: "[-+]?" +
4916: "(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)" +
4917: "(?:[Ee][-+]?[0-9]+)?" +
4918: ")$")) {
4919: double d = Double.parseDouble (paramClock);
4920: if (1.0 <= d && d <= 1000.0) {
4921: clock = d;
4922: }
4923: } else {
4924: System.out.println (Multilingual.mlnJapanese ?
4925: paramClock + " は不明な動作周波数です" :
4926: paramClock + " is unknown clock frequency");
4927: clock = specifiedModel.getClock ();
4928: }
4929: }
4930: if (i == 0) {
4931: specifiedFirstClock = clock;
4932: } else {
4933: specifiedSecondClock = clock;
4934: }
4935: }
4936: }
4937: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4938:
4939: specifiedCopro0 = 15 & Settings.sgsGetInt ("copro0", 2);
4940: if (!((7 & specifiedCopro0) == 0 ||
4941: (7 & specifiedCopro0) == 1 ||
4942: (7 & specifiedCopro0) == 2 ||
4943: (7 & specifiedCopro0) == 7)) {
4944: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4945: }
4946: specifiedCopro1 = 15 & Settings.sgsGetInt ("copro1", 2);
4947: if (!((7 & specifiedCopro1) == 0 ||
4948: (7 & specifiedCopro1) == 1 ||
4949: (7 & specifiedCopro1) == 2 ||
4950: (7 & specifiedCopro1) == 7)) {
4951: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4952: }
4953: specifiedCopro2 = 15 & Settings.sgsGetInt ("copro2", 2);
4954: if (!((7 & specifiedCopro2) == 0 ||
4955: (7 & specifiedCopro2) == 1 ||
4956: (7 & specifiedCopro2) == 2 ||
4957: (7 & specifiedCopro2) == 7)) {
4958: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4959: }
4960: specifiedOnchipFPU = 15 & Settings.sgsGetInt ("onchipfpu", 7);
4961: if (!((7 & specifiedOnchipFPU) == 0 ||
4962: (7 & specifiedOnchipFPU) == 6 ||
4963: (7 & specifiedOnchipFPU) == 7)) {
4964: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4965: }
4966:
4967:
4968: currentModel = specifiedModel;
4969: currentAccelerator = specifiedAccelerator;
4970:
4971: currentIsSecond = specifiedIsSecond;
4972: currentFirstMPU = specifiedFirstMPU;
4973: currentSecondMPU = specifiedSecondMPU;
4974: currentMPU = specifiedMPU;
4975:
4976:
4977: currentCopro0 = specifiedCopro0;
4978: currentCopro1 = specifiedCopro1;
4979: currentCopro2 = specifiedCopro2;
4980: currentOnchipFPU = specifiedOnchipFPU;
4981:
4982:
4983: mpuUtilOn = Settings.sgsGetOnOff ("util");
4984: mpuUtilRatio = fmtParseInt (Settings.sgsGetString ("ratio"), 0, 1, 100, 100);
4985:
4986: mpuArbFreqMHz = fmtParseInt (Settings.sgsGetString ("mhz"), 0, 1, 1000, 100);
4987: if (mpuUtilOn) {
4988: mpuArbFreqOn = false;
4989: } else {
4990: mpuArbFreqOn = !(specifiedClock == 10.0 ||
4991: specifiedClock == 50.0 / 3.0 ||
4992: specifiedClock == 25.0 ||
4993: specifiedClock == 100.0 / 3.0 ||
4994: specifiedClock == 50.0 ||
4995: specifiedClock == 200.0 / 3.0 ||
4996: specifiedClock == 75.0 ||
4997: specifiedClock == 100.0);
4998: if (mpuArbFreqOn) {
4999: mpuArbFreqMHz = (int) specifiedClock;
5000: }
5001: }
5002:
5003:
5004: mpuROMWaitCycles = 0;
5005: mpuRAMWaitCycles = 0;
5006: mpuCacheOn = false;
5007:
5008: mpuNoWaitTime.ram = 0;
5009: mpuNoWaitTime.gvram = 0;
5010: mpuNoWaitTime.tvram = 0;
5011: mpuNoWaitTime.crtc = 0;
5012: mpuNoWaitTime.palet = 0;
5013: mpuNoWaitTime.vicon = 0;
5014: mpuNoWaitTime.dmac = 0;
5015: mpuNoWaitTime.mfp = 0;
5016: mpuNoWaitTime.rtc = 0;
5017: mpuNoWaitTime.prnport = 0;
5018: mpuNoWaitTime.sysport = 0;
5019: mpuNoWaitTime.opm = 0;
5020: mpuNoWaitTime.adpcm = 0;
5021: mpuNoWaitTime.fdc = 0;
5022: mpuNoWaitTime.fdd = 0;
5023: mpuNoWaitTime.hdc = 0;
5024: mpuNoWaitTime.scc = 0;
5025: mpuNoWaitTime.ppi = 0;
5026: mpuNoWaitTime.ioi = 0;
5027: mpuNoWaitTime.sprc = 0;
5028: mpuNoWaitTime.sram = 0;
5029: mpuNoWaitTime.rom = 0;
5030: mpuNoWaitTime.ramlong = mpuNoWaitTime.ram << 1;
5031: mpuNoWaitTime.romlong = mpuNoWaitTime.rom << 1;
5032:
5033: dmaNoWaitTime.ram = 0;
5034: dmaNoWaitTime.gvram = 0;
5035: dmaNoWaitTime.tvram = 0;
5036: dmaNoWaitTime.crtc = 0;
5037: dmaNoWaitTime.palet = 0;
5038: dmaNoWaitTime.vicon = 0;
5039: dmaNoWaitTime.dmac = 0;
5040: dmaNoWaitTime.mfp = 0;
5041: dmaNoWaitTime.rtc = 0;
5042: dmaNoWaitTime.prnport = 0;
5043: dmaNoWaitTime.sysport = 0;
5044: dmaNoWaitTime.opm = 0;
5045: dmaNoWaitTime.adpcm = 0;
5046: dmaNoWaitTime.fdc = 0;
5047: dmaNoWaitTime.fdd = 0;
5048: dmaNoWaitTime.hdc = 0;
5049: dmaNoWaitTime.scc = 0;
5050: dmaNoWaitTime.ppi = 0;
5051: dmaNoWaitTime.ioi = 0;
5052: dmaNoWaitTime.sprc = 0;
5053: dmaNoWaitTime.sram = 0;
5054: dmaNoWaitTime.rom = 0;
5055: dmaNoWaitTime.ramlong = dmaNoWaitTime.ram << 1;
5056: dmaNoWaitTime.romlong = dmaNoWaitTime.rom << 1;
5057:
5058:
5059: busWaitCyclesRequest = Settings.sgsGetOnOff ("waitcycles");
5060: busWaitCycles = busWaitCyclesRequest;
5061: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
5062:
5063: }
5064:
5065: public static void mdlTini () {
5066:
5067: Settings.sgsPutString ("model",
5068: specifiedAccelerator == ACCELERATOR_HYBRID ? "Hybrid" :
5069: specifiedAccelerator == ACCELERATOR_XELLENT30 ? "Xellent30" :
5070: specifiedAccelerator == ACCELERATOR_060TURBO ? "060turbo" :
5071: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? "060turboPRO" :
5072: specifiedModel.getSynonym () != null ? specifiedModel.getSynonym () :
5073: specifiedModel.getType ());
5074: Settings.sgsPutOnOff ("mpu010", mpu010);
5075:
5076:
5077: int defaultFirstMPU = (specifiedAccelerator == ACCELERATOR_060TURBO ||
5078: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
5079: specifiedModel.getMPU ());
5080: int defaultSecondMPU = Model.MPU_MC68EC030;
5081: Settings.sgsPutString ("mpu",
5082: (specifiedFirstMPU == defaultFirstMPU ? "" :
5083: Model.mpuNameOf (specifiedFirstMPU)) +
5084: (specifiedSecondMPU == defaultSecondMPU ? "" :
5085: "," + Model.mpuNameOf (specifiedSecondMPU)));
5086:
5087:
5088:
5089:
5090: double defaultFirstClock = (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
5091: specifiedAccelerator == ACCELERATOR_060TURBO ||
5092: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
5093: specifiedModel.getClock ());
5094: double defaultSecondClock = defaultFirstClock * 2.0;
5095: Settings.sgsPutString ("clock",
5096: (specifiedFirstClock == defaultFirstClock ? "" :
5097: specifiedFirstClock == 50.0 / 3.0 ? "16.7" :
5098: specifiedFirstClock == 100.0 / 3.0 ? "33.3" :
5099: specifiedFirstClock == 200.0 / 3.0 ? "66.7" :
5100: String.valueOf ((int) specifiedFirstClock)) +
5101: (specifiedSecondClock == defaultSecondClock ? "" :
5102: "," + (specifiedSecondClock == 50.0 / 3.0 ? "16.7" :
5103: specifiedSecondClock == 100.0 / 3.0 ? "33.3" :
5104: specifiedSecondClock == 200.0 / 3.0 ? "66.7" :
5105: String.valueOf ((int) specifiedSecondClock))));
5106:
5107: Settings.sgsPutInt ("copro0", specifiedCopro0);
5108: Settings.sgsPutInt ("copro1", specifiedCopro1);
5109: Settings.sgsPutInt ("copro2", specifiedCopro2);
5110: Settings.sgsPutInt ("onchipfpu", specifiedOnchipFPU);
5111:
5112: Settings.sgsPutOnOff ("util",
5113: mpuUtilOn);
5114: Settings.sgsPutString ("ratio",
5115: String.valueOf (mpuUtilRatio));
5116:
5117: Settings.sgsPutString ("mhz",
5118: String.valueOf (mpuArbFreqMHz));
5119:
5120: Settings.sgsPutOnOff ("waitcycles", busWaitCyclesRequest);
5121: }
5122:
5123: public static void mdlMakeMenu () {
5124:
5125:
5126: ActionListener listener = new ActionListener () {
5127: @Override public void actionPerformed (ActionEvent ae) {
5128: Object source = ae.getSource ();
5129: switch (ae.getActionCommand ()) {
5130: case "X68000 (10MHz)":
5131: mdlRequestModel (Model.SHODAI, 0);
5132: mpuReset (-1, -1);
5133: break;
5134: case "X68000 ACE (10MHz)":
5135: mdlRequestModel (Model.ACE, 0);
5136: mpuReset (-1, -1);
5137: break;
5138: case "X68000 EXPERT (10MHz)":
5139: mdlRequestModel (Model.EXPERT, 0);
5140: mpuReset (-1, -1);
5141: break;
5142: case "X68000 PRO (10MHz)":
5143: mdlRequestModel (Model.PRO, 0);
5144: mpuReset (-1, -1);
5145: break;
5146: case "X68000 SUPER (10MHz)":
5147: mdlRequestModel (Model.SUPER, 0);
5148: mpuReset (-1, -1);
5149: break;
5150: case "X68000 XVI (16.7MHz)":
5151: mdlRequestModel (Model.XVI, 0);
5152: mpuReset (-1, -1);
5153: break;
5154: case "X68000 Compact (16.7MHz)":
5155: mdlRequestModel (Model.COMPACT, 0);
5156: mpuReset (-1, -1);
5157: break;
5158:
5159: case "X68030 (25MHz)":
5160: mdlRequestModel (Model.X68030, 0);
5161: mpuReset (-1, -1);
5162: break;
5163: case "X68030 Compact (25MHz)":
5164: mdlRequestModel (Model.X68030COMPACT, 0);
5165: mpuReset (-1, -1);
5166: break;
5167:
5168: case "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)":
5169: mdlRequestModel (Model.COMPACT, ACCELERATOR_HYBRID);
5170: mpuReset (-1, -1);
5171: break;
5172: case "Xellent30 (33.3MHz)":
5173: mdlRequestModel (Model.XVI, ACCELERATOR_XELLENT30);
5174: mpuReset (-1, -1);
5175: break;
5176: case "060turbo (" + MHZ_060TURBO_STRING + "MHz)":
5177: mdlRequestModel (Model.X68030, ACCELERATOR_060TURBO);
5178: mpuReset (-1, -1);
5179: break;
5180: case "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)":
5181: mdlRequestModel (Model.PRO, ACCELERATOR_060TURBOPRO);
5182: mpuReset (-1, -1);
5183: break;
5184:
5185: case "MC68010":
5186: mpu010 = ((JCheckBoxMenuItem) source).isSelected ();
5187: break;
5188:
5189: }
5190: }
5191: };
5192:
5193:
5194: ButtonGroup modelGroup = new ButtonGroup ();
5195: mdlMenu = Multilingual.mlnText (
5196: ComponentFactory.createMenu (
5197: "Change the model and reset",
5198: mdlShodaiMenuItem = ComponentFactory.createRadioButtonMenuItem (
5199: modelGroup,
5200: specifiedModel == Model.SHODAI,
5201: "X68000 (10MHz)",
5202: listener),
5203: mdlACEMenuItem = ComponentFactory.createRadioButtonMenuItem (
5204: modelGroup,
5205: specifiedModel == Model.ACE,
5206: "X68000 ACE (10MHz)",
5207: listener),
5208: mdlEXPERTMenuItem = ComponentFactory.createRadioButtonMenuItem (
5209: modelGroup,
5210: specifiedModel == Model.EXPERT,
5211: "X68000 EXPERT (10MHz)",
5212: listener),
5213: mdlPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
5214: modelGroup,
5215: specifiedModel == Model.PRO && specifiedAccelerator == 0,
5216: "X68000 PRO (10MHz)",
5217: listener),
5218: mdlSUPERMenuItem = ComponentFactory.createRadioButtonMenuItem (
5219: modelGroup,
5220: specifiedModel == Model.SUPER,
5221: "X68000 SUPER (10MHz)",
5222: listener),
5223: mdlXVIMenuItem = ComponentFactory.createRadioButtonMenuItem (
5224: modelGroup,
5225: specifiedModel == Model.XVI && specifiedAccelerator == 0,
5226: "X68000 XVI (16.7MHz)",
5227: listener),
5228: mdlCompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
5229: modelGroup,
5230: specifiedModel == Model.COMPACT && specifiedAccelerator == 0,
5231: "X68000 Compact (16.7MHz)",
5232: listener),
5233:
5234: ComponentFactory.createHorizontalSeparator (),
5235:
5236: mdlX68030MenuItem = ComponentFactory.createRadioButtonMenuItem (
5237: modelGroup,
5238: specifiedModel == Model.X68030 && specifiedAccelerator == 0,
5239: "X68030 (25MHz)",
5240: listener),
5241: mdl030CompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
5242: modelGroup,
5243: specifiedModel == Model.X68030COMPACT,
5244: "X68030 Compact (25MHz)",
5245: listener),
5246:
5247: ComponentFactory.createHorizontalSeparator (),
5248:
5249: mdlHybridMenuItem = ComponentFactory.createRadioButtonMenuItem (
5250: modelGroup,
5251: specifiedModel == Model.COMPACT && specifiedAccelerator == ACCELERATOR_HYBRID,
5252: "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)",
5253: listener),
5254: mdlXellent30MenuItem = ComponentFactory.createRadioButtonMenuItem (
5255: modelGroup,
5256: specifiedModel == Model.XVI && specifiedAccelerator == ACCELERATOR_XELLENT30,
5257: "Xellent30 (33.3MHz)",
5258: listener),
5259: mdl060turboMenuItem = ComponentFactory.createRadioButtonMenuItem (
5260: modelGroup,
5261: specifiedModel == Model.X68030 && specifiedAccelerator == ACCELERATOR_060TURBO,
5262: "060turbo (" + MHZ_060TURBO_STRING + "MHz)",
5263: listener),
5264: mdl060turboPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
5265: modelGroup,
5266: specifiedModel == Model.PRO && specifiedAccelerator == ACCELERATOR_060TURBOPRO,
5267: "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)",
5268: listener),
5269:
5270: ComponentFactory.createHorizontalSeparator (),
5271:
5272: mdlMC68010MenuItem = ComponentFactory.createCheckBoxMenuItem (
5273: mpu010,
5274: "MC68010",
5275: listener)
5276: ),
5277: "ja", "機種を変更してリセット");
5278:
5279:
5280: ActionListener copro0Listener = new ActionListener () {
5281: @Override public void actionPerformed (ActionEvent ae) {
5282: String command = ae.getActionCommand ();
5283: switch (command) {
5284: case "Not installed":
5285: specifiedCopro0 = (8 & specifiedCopro0) | 0;
5286: break;
5287: case "MC68881":
5288: specifiedCopro0 = (8 & specifiedCopro0) | 1;
5289: break;
5290: case "MC68882":
5291: specifiedCopro0 = (8 & specifiedCopro0) | 2;
5292: break;
5293: case "Full specification":
5294: specifiedCopro0 = (8 & specifiedCopro0) | 7;
5295: break;
5296: case "Extended precision (19 digits)":
5297: specifiedCopro0 = 0 | (7 & specifiedCopro0);
5298: break;
5299: case "Triple precision (24 digits)":
5300: specifiedCopro0 = 8 | (7 & specifiedCopro0);
5301: break;
5302: default:
5303: System.out.println ("unknown action command " + command);
5304: }
5305: }
5306: };
5307:
5308: ActionListener copro1Listener = new ActionListener () {
5309: @Override public void actionPerformed (ActionEvent ae) {
5310: String command = ae.getActionCommand ();
5311: switch (command) {
5312: case "Not installed":
5313: specifiedCopro1 = (8 & specifiedCopro1) | 0;
5314: break;
5315: case "MC68881":
5316: specifiedCopro1 = (8 & specifiedCopro1) | 1;
5317: break;
5318: case "MC68882":
5319: specifiedCopro1 = (8 & specifiedCopro1) | 2;
5320: break;
5321: case "Full specification":
5322: specifiedCopro1 = (8 & specifiedCopro1) | 7;
5323: break;
5324: case "Extended precision (19 digits)":
5325: specifiedCopro1 = 0 | (7 & specifiedCopro1);
5326: break;
5327: case "Triple precision (24 digits)":
5328: specifiedCopro1 = 8 | (7 & specifiedCopro1);
5329: break;
5330: default:
5331: System.out.println ("unknown action command " + command);
5332: }
5333: }
5334: };
5335:
5336: ActionListener copro2Listener = new ActionListener () {
5337: @Override public void actionPerformed (ActionEvent ae) {
5338: String command = ae.getActionCommand ();
5339: switch (command) {
5340: case "Not installed":
5341: specifiedCopro2 = (8 & specifiedCopro2) | 0;
5342: break;
5343: case "MC68881":
5344: specifiedCopro2 = (8 & specifiedCopro2) | 1;
5345: break;
5346: case "MC68882":
5347: specifiedCopro2 = (8 & specifiedCopro2) | 2;
5348: break;
5349: case "Full specification":
5350: specifiedCopro2 = (8 & specifiedCopro2) | 7;
5351: break;
5352: case "Extended precision (19 digits)":
5353: specifiedCopro2 = 0 | (7 & specifiedCopro2);
5354: break;
5355: case "Triple precision (24 digits)":
5356: specifiedCopro2 = 8 | (7 & specifiedCopro2);
5357: break;
5358: default:
5359: System.out.println ("unknown action command " + command);
5360: }
5361: }
5362: };
5363:
5364: ActionListener onchipFPUListener = new ActionListener () {
5365: @Override public void actionPerformed (ActionEvent ae) {
5366: String command = ae.getActionCommand ();
5367: switch (command) {
5368: case "Not installed":
5369: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 0;
5370: break;
5371: case "MC68060":
5372: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 6;
5373: break;
5374: case "Full specification":
5375: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
5376: break;
5377: case "Extended precision (19 digits)":
5378: specifiedOnchipFPU = 0 | (7 & specifiedOnchipFPU);
5379: break;
5380: case "Triple precision (24 digits)":
5381: specifiedOnchipFPU = 8 | (7 & specifiedOnchipFPU);
5382: break;
5383: default:
5384: System.out.println ("unknown action command " + command);
5385: }
5386: }
5387: };
5388:
5389: ButtonGroup copro00Group = new ButtonGroup ();
5390: ButtonGroup copro01Group = new ButtonGroup ();
5391: ButtonGroup copro10Group = new ButtonGroup ();
5392: ButtonGroup copro11Group = new ButtonGroup ();
5393: ButtonGroup copro20Group = new ButtonGroup ();
5394: ButtonGroup copro21Group = new ButtonGroup ();
5395: ButtonGroup onchipFPU0Group = new ButtonGroup ();
5396: ButtonGroup onchipFPU1Group = new ButtonGroup ();
5397:
5398: coproFPUMenu = Multilingual.mlnText (
5399: ComponentFactory.createMenu (
5400: "Coprocessor and on-chip FPU",
5401:
5402: Multilingual.mlnText (
5403: ComponentFactory.createMenu (
5404: "Motherboard coprocessor",
5405: Multilingual.mlnText (
5406: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 0, "Not installed", copro0Listener),
5407: "ja", "なし"),
5408: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 1, "MC68881", copro0Listener),
5409: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 2, "MC68882", copro0Listener),
5410: Multilingual.mlnText (
5411: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 7, "Full specification", copro0Listener),
5412: "ja", "フルスペック"),
5413: ComponentFactory.createHorizontalSeparator (),
5414: Multilingual.mlnText (
5415: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) == 0, "Extended precision (19 digits)", copro0Listener),
5416: "ja", "拡張精度 (19 桁)"),
5417: Multilingual.mlnText (
5418: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) != 0, "Triple precision (24 digits)", copro0Listener),
5419: "ja", "三倍精度 (24 桁)")),
5420: "ja", "マザーボードコプロセッサ"),
5421:
5422: Multilingual.mlnText (
5423: ComponentFactory.createMenu (
5424: "Extension coprocessor #1",
5425: Multilingual.mlnText (
5426: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 0, "Not installed", copro1Listener),
5427: "ja", "なし"),
5428: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 1, "MC68881", copro1Listener),
5429: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 2, "MC68882", copro1Listener),
5430: Multilingual.mlnText (
5431: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 7, "Full specification", copro1Listener),
5432: "ja", "フルスペック"),
5433: ComponentFactory.createHorizontalSeparator (),
5434: Multilingual.mlnText (
5435: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) == 0, "Extended precision (19 digits)", copro1Listener),
5436: "ja", "拡張精度 (19 桁)"),
5437: Multilingual.mlnText (
5438: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) != 0, "Triple precision (24 digits)", copro1Listener),
5439: "ja", "三倍精度 (24 桁)")),
5440: "ja", "拡張コプロセッサ #1"),
5441:
5442: Multilingual.mlnText (
5443: ComponentFactory.createMenu (
5444: "Extension coprocessor #2",
5445: Multilingual.mlnText (
5446: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 0, "Not installed", copro2Listener),
5447: "ja", "なし"),
5448: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 1, "MC68881", copro2Listener),
5449: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 2, "MC68882", copro2Listener),
5450: Multilingual.mlnText (
5451: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 7, "Full specification", copro2Listener),
5452: "ja", "フルスペック"),
5453: ComponentFactory.createHorizontalSeparator (),
5454: Multilingual.mlnText (
5455: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) == 0, "Extended precision (19 digits)", copro2Listener),
5456: "ja", "拡張精度 (19 桁)"),
5457: Multilingual.mlnText (
5458: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) != 0, "Triple precision (24 digits)", copro2Listener),
5459: "ja", "三倍精度 (24 桁)")),
5460: "ja", "拡張コプロセッサ #2"),
5461:
5462: Multilingual.mlnText (
5463: ComponentFactory.createMenu (
5464: "On-chip FPU",
5465: Multilingual.mlnText (
5466: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 0, "Not installed", onchipFPUListener),
5467: "ja", "なし"),
5468: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 6, "MC68060", onchipFPUListener),
5469: Multilingual.mlnText (
5470: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 7, "Full specification", onchipFPUListener),
5471: "ja", "フルスペック"),
5472: ComponentFactory.createHorizontalSeparator (),
5473: Multilingual.mlnText (
5474: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) == 0, "Extended precision (19 digits)", onchipFPUListener),
5475: "ja", "拡張精度 (19 桁)"),
5476: Multilingual.mlnText (
5477: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) != 0, "Triple precision (24 digits)", onchipFPUListener),
5478: "ja", "三倍精度 (24 桁)")),
5479: "ja", "オンチップ FPU")),
5480: "ja", "コプロセッサとオンチップ FPU");
5481:
5482: }
5483:
5484: public static void mdlRequestModel (Model model, int accelerator) {
5485: specifiedModel = model;
5486: specifiedAccelerator = accelerator;
5487:
5488: specifiedIsSecond = false;
5489: specifiedFirstMPU = specifiedModel.getMPU ();
5490: specifiedSecondMPU = Model.MPU_MC68EC030;
5491: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
5492: specifiedFirstClock = specifiedModel.getClock ();
5493: specifiedSecondClock = specifiedFirstClock * 2.0;
5494: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5495:
5496: switch (accelerator) {
5497: case ACCELERATOR_HYBRID:
5498: specifiedFirstClock = MHZ_HYBRID_VALUE;
5499: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5500: break;
5501: case ACCELERATOR_XELLENT30:
5502: break;
5503: case ACCELERATOR_060TURBO:
5504: case ACCELERATOR_060TURBOPRO:
5505: specifiedFirstMPU = Model.MPU_MC68060;
5506: specifiedFirstClock = MHZ_060TURBO_VALUE;
5507: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5508: }
5509:
5510: mpuUtilOn = false;
5511: mpuArbFreqOn = false;
5512: mpuSetCurrentClock (specifiedClock);
5513:
5514: if (accelerator == ACCELERATOR_HYBRID) {
5515: mdlHybridMenuItem.setSelected (true);
5516: } else if (accelerator == ACCELERATOR_XELLENT30) {
5517: mdlXellent30MenuItem.setSelected (true);
5518: } else if (accelerator == ACCELERATOR_060TURBO) {
5519: mdl060turboMenuItem.setSelected (true);
5520: } else if (accelerator == ACCELERATOR_060TURBOPRO) {
5521: mdl060turboPROMenuItem.setSelected (true);
5522: } else if (specifiedModel == Model.SHODAI) {
5523: mdlShodaiMenuItem.setSelected (true);
5524: } else if (specifiedModel == Model.ACE) {
5525: mdlACEMenuItem.setSelected (true);
5526: } else if (specifiedModel == Model.EXPERT) {
5527: mdlEXPERTMenuItem.setSelected (true);
5528: } else if (specifiedModel == Model.PRO) {
5529: mdlPROMenuItem.setSelected (true);
5530: } else if (specifiedModel == Model.SUPER) {
5531: mdlSUPERMenuItem.setSelected (true);
5532: } else if (specifiedModel == Model.XVI) {
5533: mdlXVIMenuItem.setSelected (true);
5534: } else if (specifiedModel == Model.COMPACT) {
5535: mdlCompactMenuItem.setSelected (true);
5536: } else if (specifiedModel == Model.X68030) {
5537: mdlX68030MenuItem.setSelected (true);
5538: } else if (specifiedModel == Model.X68030COMPACT) {
5539: mdl030CompactMenuItem.setSelected (true);
5540: }
5541:
5542:
5543: HDC.hdcSASIMenuItem.setSelected (!currentModel.isSCSI ());
5544: SPC.spcSCSIINMenuItem.setSelected (currentModel.isSCSI ());
5545: }
5546:
5547:
5548:
5549:
5550:
5551:
5552:
5553: public static final boolean MPU_INLINE_EXCEPTION = true;
5554: public static final boolean MPU_COMPOUND_POSTINCREMENT = false;
5555:
5556: public static final boolean MPU_SWITCH_MISC_OPCODE = false;
5557: public static final boolean MPU_SWITCH_BCC_CONDITION = false;
5558: public static final boolean MPU_SWITCH_BCC_OFFSET = false;
5559: public static final boolean MPU_SWITCH_SCC_CONDITION = true;
5560:
5561: public static final boolean MPU_OMIT_EXTRA_READ = false;
5562: public static final boolean MPU_OMIT_OFFSET_READ = false;
5563:
5564:
5565:
5566:
5567: public static final long FAR_FUTURE = 0x7fffffffffffffffL;
5568:
5569:
5570:
5571:
5572:
5573:
5574:
5575:
5576: public static final int REG_SR_T1 = 0b10000000_00000000;
5577: public static final int REG_SR_T0 = 0b01000000_00000000;
5578:
5579:
5580:
5581:
5582:
5583:
5584: public static final int REG_SR_S = 0b00100000_00000000;
5585: public static final int REG_SR_M = 0b00010000_00000000;
5586:
5587: public static final int REG_SR_I = 0b00000111_00000000;
5588:
5589:
5590: public static final int REG_CCR_X = 0b00000000_00010000;
5591: public static final int REG_CCR_N = 0b00000000_00001000;
5592: public static final int REG_CCR_Z = 0b00000000_00000100;
5593: public static final int REG_CCR_V = 0b00000000_00000010;
5594: public static final int REG_CCR_C = 0b00000000_00000001;
5595: public static final int REG_CCR_MASK = REG_CCR_X | REG_CCR_N | REG_CCR_Z | REG_CCR_V | REG_CCR_C;
5596:
5597: public static char[] REG_CCRXMAP = "00000000000000001111111111111111".toCharArray ();
5598: public static char[] REG_CCRNMAP = "00000000111111110000000011111111".toCharArray ();
5599: public static char[] REG_CCRZMAP = "00001111000011110000111100001111".toCharArray ();
5600: public static char[] REG_CCRVMAP = "00110011001100110011001100110011".toCharArray ();
5601: public static char[] REG_CCRCMAP = "01010101010101010101010101010101".toCharArray ();
5602:
5603:
5604:
5605: public static final int MPU_IOI_INTERRUPT_LEVEL = 1;
5606: public static final int MPU_EB2_INTERRUPT_LEVEL = 2;
5607: public static final int MPU_DMA_INTERRUPT_LEVEL = 3;
5608: public static final int MPU_SCC_INTERRUPT_LEVEL = 5;
5609: public static final int MPU_MFP_INTERRUPT_LEVEL = 6;
5610: public static final int MPU_SYS_INTERRUPT_LEVEL = 7;
5611: public static final int MPU_IOI_INTERRUPT_MASK = 0x80 >> MPU_IOI_INTERRUPT_LEVEL;
5612: public static final int MPU_EB2_INTERRUPT_MASK = 0x80 >> MPU_EB2_INTERRUPT_LEVEL;
5613: public static final int MPU_DMA_INTERRUPT_MASK = 0x80 >> MPU_DMA_INTERRUPT_LEVEL;
5614: public static final int MPU_SCC_INTERRUPT_MASK = 0x80 >> MPU_SCC_INTERRUPT_LEVEL;
5615: public static final int MPU_MFP_INTERRUPT_MASK = 0x80 >> MPU_MFP_INTERRUPT_LEVEL;
5616: public static final int MPU_SYS_INTERRUPT_MASK = 0x80 >> MPU_SYS_INTERRUPT_LEVEL;
5617:
5618: public static final boolean MPU_INTERRUPT_SWITCH = true;
5619:
5620:
5621: public static final boolean T = true;
5622: public static final boolean F = false;
5623:
5624: public static final int CCCC_T = 0b0000;
5625: public static final int CCCC_F = 0b0001;
5626: public static final int CCCC_HI = 0b0010;
5627: public static final int CCCC_LS = 0b0011;
5628: public static final int CCCC_CC = 0b0100;
5629: public static final int CCCC_CS = 0b0101;
5630: public static final int CCCC_NE = 0b0110;
5631: public static final int CCCC_EQ = 0b0111;
5632: public static final int CCCC_VC = 0b1000;
5633: public static final int CCCC_VS = 0b1001;
5634: public static final int CCCC_PL = 0b1010;
5635: public static final int CCCC_MI = 0b1011;
5636: public static final int CCCC_GE = 0b1100;
5637: public static final int CCCC_LT = 0b1101;
5638: public static final int CCCC_GT = 0b1110;
5639: public static final int CCCC_LE = 0b1111;
5640:
5641:
5642:
5643:
5644:
5645:
5646: public static final boolean[] BCCMAP = {
5647: 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,
5648: 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,
5649: 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,
5650: 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,
5651: 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,
5652: 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,
5653: 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,
5654: 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,
5655: 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,
5656: 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,
5657: 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,
5658: 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,
5659: 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,
5660: 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,
5661: 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,
5662: 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,
5663: };
5664:
5665:
5666: public static final char[] MPU_CCCMAP = (
5667: "11111111111111111111111111111111" +
5668: "00000000000000000000000000000000" +
5669: "10100000101000001010000010100000" +
5670: "01011111010111110101111101011111" +
5671: "10101010101010101010101010101010" +
5672: "01010101010101010101010101010101" +
5673: "11110000111100001111000011110000" +
5674: "00001111000011110000111100001111" +
5675: "11001100110011001100110011001100" +
5676: "00110011001100110011001100110011" +
5677: "11111111000000001111111100000000" +
5678: "00000000111111110000000011111111" +
5679: "11001100001100111100110000110011" +
5680: "00110011110011000011001111001100" +
5681: "11000000001100001100000000110000" +
5682: "00111111110011110011111111001111").toCharArray ();
5683:
5684:
5685:
5686: public static final int MPU_CC_T = 0b11111111111111111111111111111111;
5687: public static final int MPU_CC_F = 0b00000000000000000000000000000000;
5688: public static final int MPU_CC_HI = 0b10100000101000001010000010100000;
5689: public static final int MPU_CC_LS = 0b01011111010111110101111101011111;
5690: public static final int MPU_CC_HS = 0b10101010101010101010101010101010;
5691: public static final int MPU_CC_LO = 0b01010101010101010101010101010101;
5692: public static final int MPU_CC_NE = 0b11110000111100001111000011110000;
5693: public static final int MPU_CC_EQ = 0b00001111000011110000111100001111;
5694: public static final int MPU_CC_VC = 0b11001100110011001100110011001100;
5695: public static final int MPU_CC_VS = 0b00110011001100110011001100110011;
5696: public static final int MPU_CC_PL = 0b11111111000000001111111100000000;
5697: public static final int MPU_CC_MI = 0b00000000111111110000000011111111;
5698: public static final int MPU_CC_GE = 0b11001100001100111100110000110011;
5699: public static final int MPU_CC_LT = 0b00110011110011000011001111001100;
5700: public static final int MPU_CC_GT = 0b11000000001100001100000000110000;
5701: public static final int MPU_CC_LE = 0b00111111110011110011111111001111;
5702:
5703:
5704:
5705:
5706:
5707:
5708:
5709:
5710:
5711:
5712:
5713:
5714:
5715:
5716:
5717:
5718:
5719:
5720:
5721:
5722:
5723:
5724:
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: 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);
5752:
5753:
5754:
5755: public static final int[] MPU_BITREV_TABLE_0 = new int[2048];
5756: public static final int[] MPU_BITREV_TABLE_1 = new int[2048];
5757: public static final int[] MPU_BITREV_TABLE_2 = new int[2048];
5758: static {
5759: for (int i = 0; i < 2048; i++) {
5760: MPU_BITREV_TABLE_2[i] = (MPU_BITREV_TABLE_1[i] = (MPU_BITREV_TABLE_0[i] = Integer.reverse (i)) >>> 11) >>> 11;
5761: }
5762: }
5763:
5764:
5765:
5766: public static final int EA_DR = 0b000_000;
5767: public static final int EA_AR = 0b001_000;
5768: public static final int EA_MM = 0b010_000;
5769: public static final int EA_MP = 0b011_000;
5770: public static final int EA_MN = 0b100_000;
5771: public static final int EA_MW = 0b101_000;
5772: public static final int EA_MX = 0b110_000;
5773: public static final int EA_ZW = 0b111_000;
5774: public static final int EA_ZL = 0b111_001;
5775: public static final int EA_PW = 0b111_010;
5776: public static final int EA_PX = 0b111_011;
5777: public static final int EA_IM = 0b111_100;
5778: public static final int MMM_DR = EA_DR >> 3;
5779: public static final int MMM_AR = EA_AR >> 3;
5780: public static final int MMM_MM = EA_MM >> 3;
5781: public static final int MMM_MP = EA_MP >> 3;
5782: public static final int MMM_MN = EA_MN >> 3;
5783: public static final int MMM_MW = EA_MW >> 3;
5784: public static final int MMM_MX = EA_MX >> 3;
5785: public static final long EAM_DR = 0xff00000000000000L >>> EA_DR;
5786: public static final long EAM_AR = 0xff00000000000000L >>> EA_AR;
5787: public static final long EAM_MM = 0xff00000000000000L >>> EA_MM;
5788: public static final long EAM_MP = 0xff00000000000000L >>> EA_MP;
5789: public static final long EAM_MN = 0xff00000000000000L >>> EA_MN;
5790: public static final long EAM_MW = 0xff00000000000000L >>> EA_MW;
5791: public static final long EAM_MX = 0xff00000000000000L >>> EA_MX;
5792: public static final long EAM_ZW = 0x8000000000000000L >>> EA_ZW;
5793: public static final long EAM_ZL = 0x8000000000000000L >>> EA_ZL;
5794: public static final long EAM_PW = 0x8000000000000000L >>> EA_PW;
5795: public static final long EAM_PX = 0x8000000000000000L >>> EA_PX;
5796: public static final long EAM_IM = 0x8000000000000000L >>> EA_IM;
5797: 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;
5798: public static final long EAM_ALT = EAM_DR|EAM_AR|EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5799: 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;
5800: 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 ;
5801: public static final long EAM_DLT = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5802: public static final long EAM_DCN = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5803: public static final long EAM_DCL = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5804: 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;
5805: public static final long EAM_MEM = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5806: public static final long EAM_MLT = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5807: public static final long EAM_RDL = EAM_MM|EAM_MP |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5808: public static final long EAM_WTL = EAM_MM |EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5809: public static final long EAM_CNT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5810: public static final long EAM_CLT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5811:
5812:
5813:
5814:
5815:
5816:
5817:
5818:
5819:
5820:
5821:
5822: public static final int[] regRn = new int[16 + 1];
5823:
5824:
5825: public static int regPC;
5826: public static int regPC0;
5827:
5828:
5829: public static int regOC;
5830:
5831:
5832: public static int regSRT1;
5833: public static int regSRT0;
5834: public static int mpuTraceFlag;
5835: public static int regSRS;
5836: public static int regSRM;
5837: public static int regSRI;
5838:
5839:
5840: public static int regCCR;
5841:
5842:
5843:
5844:
5845:
5846:
5847:
5848:
5849:
5850:
5851:
5852:
5853:
5854:
5855:
5856:
5857:
5858:
5859:
5860:
5861: public static int mpuIMR;
5862:
5863:
5864:
5865:
5866:
5867:
5868: public static int mpuIRR;
5869: public static int mpuDIRR;
5870:
5871:
5872:
5873:
5874:
5875:
5876:
5877:
5878: public static int mpuISR;
5879:
5880:
5881: public static int mpuSFC;
5882: public static int mpuDFC;
5883: public static int mpuCACR;
5884:
5885:
5886:
5887:
5888:
5889: public static int mpuBUSCR;
5890: public static int mpuUSP;
5891: public static int mpuVBR;
5892: public static int mpuCAAR;
5893: public static int mpuMSP;
5894: public static int mpuISP;
5895:
5896:
5897:
5898: public static int mpuPCR;
5899:
5900:
5901:
5902: public static final int MPU_060_REV = 7;
5903:
5904:
5905:
5906: public static long mpuClockTime;
5907: public static long mpuClockLimit;
5908: public static double mpuClockMHz;
5909: public static double mpuCurrentMHz;
5910: public static int mpuCycleCount;
5911: public static long mpuCycleUnit;
5912: public static long mpuModifiedUnit;
5913: public static long dmaCycleUnit;
5914:
5915:
5916:
5917: public static TimerTask mpuTask;
5918:
5919:
5920: public static int mpuBootDevice;
5921: public static int mpuROMBootHandle;
5922: public static int mpuSavedBootDevice;
5923: public static int mpuSavedROMBootHandle;
5924:
5925:
5926: public static boolean mpuIgnoreAddressError;
5927:
5928:
5929: public static int mpuROMWaitCycles;
5930: public static int mpuRAMWaitCycles;
5931: public static boolean mpuCacheOn;
5932: public static final class WaitTime {
5933: public long ram;
5934: public long gvram;
5935: public long tvram;
5936: public long crtc;
5937: public long palet;
5938: public long vicon;
5939: public long dmac;
5940: public long mfp;
5941: public long rtc;
5942: public long prnport;
5943: public long sysport;
5944: public long opm;
5945: public long adpcm;
5946: public long fdc;
5947: public long fdd;
5948: public long hdc;
5949: public long scc;
5950: public long ppi;
5951: public long ioi;
5952: public long sprc;
5953: public long sram;
5954: public long rom;
5955: public long ramlong;
5956: public long romlong;
5957: public boolean isDma;
5958: public WaitTime (boolean isDma) {
5959: this.isDma = isDma;
5960: }
5961: }
5962: public static final WaitTime mpuNoWaitTime = new WaitTime (false);
5963: public static final WaitTime dmaNoWaitTime = new WaitTime (true);
5964: public static final WaitTime mpuWaitTime = new WaitTime (false);
5965: public static final WaitTime dmaWaitTime = new WaitTime (true);
5966: public static boolean busWaitCyclesRequest;
5967: public static boolean busWaitCycles;
5968: public static WaitTime busWaitTime;
5969:
5970:
5971: public static boolean mpuArbFreqOn;
5972: public static int mpuArbFreqMHz;
5973: public static SpinnerNumberModel mpuArbFreqModel;
5974: public static JSpinner mpuArbFreqSpinner;
5975: public static JRadioButtonMenuItem mpuArbFreqRadioButtonMenuItem;
5976:
5977:
5978: public static boolean mpuUtilOn;
5979: public static int mpuUtilRatio;
5980: public static SpinnerNumberModel mpuUtilModel;
5981: public static JSpinner mpuUtilSpinner;
5982: public static JRadioButtonMenuItem mpuUtilRadioButtonMenuItem;
5983:
5984:
5985: public static final int MPU_ADJUSTMENT_INTERVAL = 100;
5986: public static int mpuAdjustmentCounter;
5987: public static long mpuTotalNano;
5988: public static long mpuLastNano;
5989: public static double mpuCoreNano1;
5990: public static double mpuCoreNano2;
5991:
5992:
5993: public static JMenu mpuMenu;
5994: public static JMenuItem mpuResetMenuItem;
5995: public static JMenuItem mpuOpt1ResetMenuItem;
5996: public static JRadioButtonMenuItem mpuClock10MenuItem;
5997: public static JRadioButtonMenuItem mpuClock16MenuItem;
5998: public static JRadioButtonMenuItem mpuClock25MenuItem;
5999: public static JRadioButtonMenuItem mpuClock33MenuItem;
6000: public static JRadioButtonMenuItem mpuClock50MenuItem;
6001: public static JRadioButtonMenuItem mpuClock66MenuItem;
6002: public static JRadioButtonMenuItem mpuClock75MenuItem;
6003: public static JRadioButtonMenuItem mpuClock100MenuItem;
6004:
6005:
6006: public static ActionListener mpuDebugActionListener;
6007: public static ArrayList<AbstractButton> mpuButtonsRunning;
6008: public static ArrayList<AbstractButton> mpuButtonsStopped;
6009: public static ArrayList<JCheckBox> mpuOriIllegalCheckBoxList;
6010: public static ArrayList<JCheckBox> mpuStopOnErrorCheckBoxList;
6011: public static ArrayList<JCheckBox> mpuStopAtStartCheckBoxList;
6012:
6013: public static int mpuAdvanceCount;
6014: public static int mpuStepCount;
6015: public static boolean mpuContinue;
6016: public static int mpuUntilReturnSRS;
6017: public static int mpuUntilReturnRP;
6018: public static int mpuUntilReturnPC0;
6019: public static int mpuUntilReturnSP;
6020:
6021:
6022:
6023:
6024:
6025:
6026:
6027:
6028:
6029:
6030:
6031:
6032:
6033:
6034:
6035:
6036:
6037:
6038:
6039:
6040:
6041:
6042:
6043:
6044:
6045:
6046:
6047:
6048:
6049:
6050:
6051:
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: public static final boolean MPU_SXMENU = false;
6094:
6095:
6096:
6097: public static void mpuInit () {
6098:
6099: mpuIgnoreAddressError = false;
6100:
6101:
6102:
6103: fpuInit ();
6104:
6105: mpuClockTime = 0L;
6106: mpuClockLimit = 0L;
6107: mpuCycleCount = 0;
6108:
6109: mpuTask = null;
6110:
6111: M68kException.m6eSignal = new M68kException ();
6112: M68kException.m6eNumber = 0;
6113: M68kException.m6eAddress = 0;
6114: M68kException.m6eDirection = MPU_WR_WRITE;
6115: M68kException.m6eSize = MPU_SS_BYTE;
6116:
6117: mpuBootDevice = -1;
6118: mpuROMBootHandle = -1;
6119: mpuSavedBootDevice = -1;
6120: mpuSavedROMBootHandle = -1;
6121:
6122:
6123:
6124:
6125:
6126:
6127:
6128:
6129:
6130:
6131:
6132:
6133:
6134:
6135:
6136: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
6137: mpuTotalNano = 0L;
6138: mpuLastNano = System.nanoTime ();
6139: mpuCoreNano1 = mpuCoreNano2 = 0.5 * 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
6140:
6141: mpuButtonsRunning = new ArrayList<AbstractButton> ();
6142: mpuButtonsStopped = new ArrayList<AbstractButton> ();
6143:
6144: mpuOriIllegalCheckBoxList = new ArrayList<JCheckBox> ();
6145: mpuStopOnErrorCheckBoxList = new ArrayList<JCheckBox> ();
6146: mpuStopAtStartCheckBoxList = new ArrayList<JCheckBox> ();
6147:
6148: mpuAdvanceCount = 0;
6149: mpuStepCount = 0;
6150: mpuContinue = false;
6151: mpuUntilReturnSRS = 0;
6152: mpuUntilReturnRP = 0;
6153: mpuUntilReturnPC0 = 0;
6154: mpuUntilReturnSP = 0;
6155:
6156:
6157: mpuDebugActionListener = new ActionListener () {
6158: @Override public void actionPerformed (ActionEvent ae) {
6159: Object source = ae.getSource ();
6160: switch (ae.getActionCommand ()) {
6161: case "Stop":
6162: if (RootPointerList.RTL_ON) {
6163: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6164: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6165: mpuStop (null);
6166: }
6167: } else {
6168: mpuStop (null);
6169: }
6170: break;
6171: case "Trace":
6172: mpuAdvance (1);
6173: break;
6174: case "Trace 10 times":
6175: mpuAdvance (10);
6176: break;
6177: case "Trace 100 times":
6178: mpuAdvance (100);
6179: break;
6180: case "Step":
6181: mpuStep (1);
6182: break;
6183: case "Step 10 times":
6184: mpuStep (10);
6185: break;
6186: case "Step 100 times":
6187: mpuStep (100);
6188: break;
6189: case "Step until return":
6190: mpuStepUntilReturn ();
6191: break;
6192: case "Run":
6193: mpuStart ();
6194: break;
6195:
6196: case "Consider ORI.B #$00,D0 as an illegal instruction" :
6197: if (DBG_ORI_BYTE_ZERO_D0) {
6198: dbgOriByteZeroD0 = ((JCheckBox) source).isSelected ();
6199: for (JCheckBox checkBox : mpuOriIllegalCheckBoxList) {
6200: if (checkBox.isSelected () != dbgOriByteZeroD0) {
6201: checkBox.setSelected (dbgOriByteZeroD0);
6202: }
6203: }
6204: }
6205: break;
6206: case "Stop on error":
6207: dbgStopOnError = ((JCheckBox) source).isSelected ();
6208: for (JCheckBox checkBox : mpuStopOnErrorCheckBoxList) {
6209: if (checkBox.isSelected () != dbgStopOnError) {
6210: checkBox.setSelected (dbgStopOnError);
6211: }
6212: }
6213: break;
6214: case "Stop at execution start position":
6215: dbgStopAtStart = ((JCheckBox) source).isSelected ();
6216: for (JCheckBox checkBox : mpuStopAtStartCheckBoxList) {
6217: if (checkBox.isSelected () != dbgStopAtStart) {
6218: checkBox.setSelected (dbgStopAtStart);
6219: }
6220: }
6221: break;
6222: }
6223: }
6224: };
6225:
6226: }
6227:
6228:
6229:
6230: public static JCheckBox mpuMakeOriIllegalCheckBox () {
6231: JCheckBox checkBox = Multilingual.mlnToolTipText (
6232: ComponentFactory.createIconCheckBox (
6233: DBG_ORI_BYTE_ZERO_D0 ? dbgOriByteZeroD0 : null,
6234: LnF.LNF_ORI_BYTE_ZERO_D0_IMAGE,
6235: LnF.LNF_ORI_BYTE_ZERO_D0_SELECTED_IMAGE,
6236: "Consider ORI.B #$00,D0 as an illegal instruction", mpuDebugActionListener),
6237: "ja", "ORI.B #$00,D0 を不当命令とみなす");
6238: mpuOriIllegalCheckBoxList.add (checkBox);
6239: return checkBox;
6240: }
6241:
6242:
6243:
6244: public static JCheckBox mpuMakeStopOnErrorCheckBox () {
6245: JCheckBox checkBox = Multilingual.mlnToolTipText (
6246: ComponentFactory.createIconCheckBox (
6247: dbgStopOnError,
6248: LnF.LNF_STOP_ON_ERROR_IMAGE,
6249: LnF.LNF_STOP_ON_ERROR_SELECTED_IMAGE,
6250: "Stop on error", mpuDebugActionListener),
6251: "ja", "エラーで停止する");
6252: mpuStopOnErrorCheckBoxList.add (checkBox);
6253: return checkBox;
6254: }
6255:
6256:
6257:
6258: public static JCheckBox mpuMakeStopAtStartCheckBox () {
6259: JCheckBox checkBox = Multilingual.mlnToolTipText (
6260: ComponentFactory.createIconCheckBox (
6261: dbgStopAtStart,
6262: LnF.LNF_STOP_AT_START_IMAGE,
6263: LnF.LNF_STOP_AT_START_SELECTED_IMAGE,
6264: "Stop at execution start position", mpuDebugActionListener),
6265: "ja", "実行開始位置で停止する");
6266: mpuStopAtStartCheckBoxList.add (checkBox);
6267: return checkBox;
6268: }
6269:
6270:
6271: public static void mpuMakeMenu () {
6272:
6273: ButtonGroup unitGroup = new ButtonGroup ();
6274: ActionListener listener = new ActionListener () {
6275: @Override public void actionPerformed (ActionEvent ae) {
6276: Object source = ae.getSource ();
6277: switch (ae.getActionCommand ()) {
6278: case "Reset":
6279: mpuReset (-1, -1);
6280: break;
6281: case "Hold down OPT.1 and reset":
6282: mpuReset (0, -1);
6283: break;
6284: case "Interrupt":
6285: sysInterrupt ();
6286: break;
6287: case "10MHz":
6288: mpuArbFreqOn = false;
6289: mpuUtilOn = false;
6290: mpuSetCurrentClock (10.0);
6291: break;
6292: case "16.7MHz":
6293: mpuArbFreqOn = false;
6294: mpuUtilOn = false;
6295: mpuSetCurrentClock (50.0 / 3.0);
6296: break;
6297: case "25MHz":
6298: mpuArbFreqOn = false;
6299: mpuUtilOn = false;
6300: mpuSetCurrentClock (25.0);
6301: break;
6302: case "33.3MHz":
6303: mpuArbFreqOn = false;
6304: mpuUtilOn = false;
6305: mpuSetCurrentClock (100.0 / 3.0);
6306: break;
6307: case "50MHz":
6308: mpuArbFreqOn = false;
6309: mpuUtilOn = false;
6310: mpuSetCurrentClock (50.0);
6311: break;
6312: case "66.7MHz":
6313: mpuArbFreqOn = false;
6314: mpuUtilOn = false;
6315: mpuSetCurrentClock (200.0 / 3.0);
6316: break;
6317: case "75MHz":
6318: mpuArbFreqOn = false;
6319: mpuUtilOn = false;
6320: mpuSetCurrentClock (75.0);
6321: break;
6322: case "100MHz":
6323: mpuArbFreqOn = false;
6324: mpuUtilOn = false;
6325: mpuSetCurrentClock (100.0);
6326: break;
6327: case "Arbitrary frequency":
6328: mpuArbFreqOn = true;
6329: mpuUtilOn = false;
6330: mpuSetCurrentClock ((double) mpuArbFreqMHz);
6331: break;
6332: case "Arbitrary load factor":
6333: mpuArbFreqOn = false;
6334: mpuUtilOn = true;
6335: break;
6336: case "FE function instruction":
6337: FEFunction.fpkOn = ((JCheckBoxMenuItem) source).isSelected ();
6338: break;
6339: case "Reject FLOATn.X":
6340: FEFunction.fpkRejectFloatOn = ((JCheckBoxMenuItem) source).isSelected ();
6341: break;
6342: case "Cut FC2 pin":
6343: busRequestCutFC2Pin = ((JCheckBoxMenuItem) source).isSelected ();
6344: break;
6345: case "Wait cycles":
6346: busWaitCyclesRequest = ((JCheckBoxMenuItem) source).isSelected ();
6347: break;
6348: case "Use IPLROM 1.6":
6349: ROM.romIPLROM16On = ((JCheckBoxMenuItem) source).isSelected ();
6350: break;
6351: case "Increase IPLROM to 256KB":
6352: ROM.romIPLROM256KOn = ((JCheckBoxMenuItem) source).isSelected ();
6353: break;
6354:
6355: case "Run / Stop":
6356: if (((JCheckBox) source).isSelected ()) {
6357: mpuStart ();
6358: } else {
6359: if (RootPointerList.RTL_ON) {
6360: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6361: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6362: mpuStop (null);
6363: }
6364: } else {
6365: mpuStop (null);
6366: }
6367: }
6368: pnlPanel.requestFocusInWindow ();
6369: break;
6370: }
6371: }
6372: };
6373: mpuMenu = ComponentFactory.createMenu (
6374: "MPU", 'M',
6375: mpuResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset", 'R', MNB_MODIFIERS, listener), "ja", "リセット"),
6376: mpuOpt1ResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Hold down OPT.1 and reset", 'O', MNB_MODIFIERS, listener), "ja", "OPT.1 を押しながらリセット"),
6377: Multilingual.mlnText (ComponentFactory.createMenuItem ("Interrupt", listener), "ja", "インタラプト"),
6378: ComponentFactory.createHorizontalSeparator (),
6379: mdlMenu,
6380: ComponentFactory.createHorizontalSeparator (),
6381: mpuClock10MenuItem = ComponentFactory.createRadioButtonMenuItem (
6382: unitGroup,
6383: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 10.0,
6384: "10MHz",
6385: listener),
6386: mpuClock16MenuItem = ComponentFactory.createRadioButtonMenuItem (
6387: unitGroup,
6388: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0 / 3.0,
6389: "16.7MHz",
6390: listener),
6391: mpuClock25MenuItem = ComponentFactory.createRadioButtonMenuItem (
6392: unitGroup,
6393: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 25.0,
6394: "25MHz",
6395: listener),
6396: mpuClock33MenuItem = ComponentFactory.createRadioButtonMenuItem (
6397: unitGroup,
6398: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0 / 3.0,
6399: "33.3MHz",
6400: listener),
6401: mpuClock50MenuItem = ComponentFactory.createRadioButtonMenuItem (
6402: unitGroup,
6403: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0,
6404: "50MHz",
6405: listener),
6406: mpuClock66MenuItem = ComponentFactory.createRadioButtonMenuItem (
6407: unitGroup,
6408: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 200.0 / 3.0,
6409: "66.7MHz",
6410: listener),
6411: mpuClock75MenuItem = ComponentFactory.createRadioButtonMenuItem (
6412: unitGroup,
6413: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 75.0,
6414: "75MHz",
6415: listener),
6416: mpuClock100MenuItem = ComponentFactory.createRadioButtonMenuItem (
6417: unitGroup,
6418: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0,
6419: "100MHz",
6420: listener),
6421: mpuArbFreqRadioButtonMenuItem = Multilingual.mlnText (
6422: ComponentFactory.createRadioButtonMenuItem (
6423: unitGroup,
6424: mpuArbFreqOn,
6425: "Arbitrary frequency",
6426: listener),
6427: "ja", "任意の周波数"),
6428: ComponentFactory.createHorizontalBox (
6429: Box.createHorizontalStrut (20),
6430: mpuArbFreqSpinner = ComponentFactory.createNumberSpinner (
6431: mpuArbFreqModel = new SpinnerNumberModel (mpuArbFreqMHz, 1, 1000, 1),
6432: 4,
6433: new ChangeListener () {
6434: @Override public void stateChanged (ChangeEvent ce) {
6435:
6436: mpuArbFreqMHz = mpuArbFreqModel.getNumber ().intValue ();
6437: if (mpuArbFreqOn) {
6438: mpuSetCurrentClock ((double) mpuArbFreqMHz);
6439: }
6440: }
6441: }
6442: ),
6443: ComponentFactory.createLabel ("MHz"),
6444: Box.createHorizontalGlue ()
6445: ),
6446: mpuUtilRadioButtonMenuItem = Multilingual.mlnText (
6447: ComponentFactory.createRadioButtonMenuItem (
6448: unitGroup,
6449: mpuUtilOn,
6450: "Arbitrary load factor",
6451: listener),
6452: "ja", "任意の負荷率"),
6453: ComponentFactory.createHorizontalBox (
6454: Box.createHorizontalStrut (20),
6455: mpuUtilSpinner = ComponentFactory.createNumberSpinner (
6456: mpuUtilModel = new SpinnerNumberModel (mpuUtilRatio, 1, 100, 1),
6457: 4,
6458: new ChangeListener () {
6459: @Override public void stateChanged (ChangeEvent ce) {
6460:
6461: mpuUtilRatio = mpuUtilModel.getNumber ().intValue ();
6462: }
6463: }
6464: ),
6465: ComponentFactory.createLabel ("%"),
6466: Box.createHorizontalGlue ()
6467: ),
6468: ComponentFactory.createHorizontalSeparator (),
6469:
6470: coproFPUMenu,
6471:
6472: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkOn, "FE function instruction", listener), "ja", "FE ファンクション命令"),
6473: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkRejectFloatOn, "Reject FLOATn.X", listener), "ja", "FLOATn.X を組み込まない"),
6474: ComponentFactory.createHorizontalSeparator (),
6475: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busRequestCutFC2Pin, "Cut FC2 pin", listener), "ja", "FC2 ピンをカットする"),
6476: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busWaitCyclesRequest, "Wait cycles", listener), "ja", "ウェイトサイクル"),
6477: ComponentFactory.createHorizontalSeparator (),
6478: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM16On, "Use IPLROM 1.6", listener), "ja", "IPLROM 1.6 を使う"),
6479: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM256KOn, "Increase IPLROM to 256KB", listener), "ja", "IPLROM を 256KB に増やす")
6480: );
6481: }
6482:
6483:
6484: public static void mpuSetCurrentClock (double clock) {
6485: specifiedClock = clock;
6486: if (currentIsSecond) {
6487: specifiedSecondClock = clock;
6488: } else {
6489: specifiedFirstClock = clock;
6490: }
6491: if (!mpuArbFreqOn && !mpuUtilOn) {
6492: if (specifiedClock == 10.0) {
6493: mpuClock10MenuItem.setSelected (true);
6494: } else if (specifiedClock == 50.0 / 3.0) {
6495: mpuClock16MenuItem.setSelected (true);
6496: } else if (specifiedClock == 25.0) {
6497: mpuClock25MenuItem.setSelected (true);
6498: } else if (specifiedClock == 100.0 / 3.0) {
6499: mpuClock33MenuItem.setSelected (true);
6500: } else if (specifiedClock == 50.0) {
6501: mpuClock50MenuItem.setSelected (true);
6502: } else if (specifiedClock == 200.0 / 3.0) {
6503: mpuClock66MenuItem.setSelected (true);
6504: } else if (specifiedClock == 75.0) {
6505: mpuClock75MenuItem.setSelected (true);
6506: } else if (specifiedClock == 100.0) {
6507: mpuClock100MenuItem.setSelected (true);
6508: }
6509: }
6510: mpuClockMHz = specifiedClock;
6511: mpuSetClockMHz (mpuClockMHz);
6512: }
6513:
6514:
6515:
6516:
6517:
6518:
6519:
6520:
6521:
6522:
6523:
6524: public static void mpuSetClockMHz (double mhz) {
6525: mhz = Math.max (1.0, Math.min (1000.0, mhz));
6526: double lastMHz = mpuCurrentMHz;
6527: mpuCurrentMHz = mhz;
6528: mpuCycleUnit = (long) (((double) TMR_FREQ / 1000000.0) / mhz + 0.5);
6529:
6530: mpuModifiedUnit = (currentMPU == Model.MPU_MC68EC030 ||
6531: currentMPU == Model.MPU_MC68030 ?
6532: (long) (((double) TMR_FREQ * 3.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6533: currentMPU == Model.MPU_MC68LC040 ||
6534: currentMPU == Model.MPU_MC68040 ?
6535: (long) (((double) TMR_FREQ * 2.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6536: mpuCycleUnit);
6537: if (lastMHz != mhz) {
6538: mpuSetWait ();
6539: }
6540: }
6541:
6542:
6543:
6544:
6545:
6546:
6547:
6548:
6549:
6550:
6551:
6552:
6553:
6554:
6555:
6556:
6557:
6558:
6559:
6560:
6561:
6562:
6563:
6564:
6565:
6566:
6567:
6568:
6569:
6570:
6571:
6572:
6573:
6574:
6575:
6576:
6577:
6578:
6579:
6580:
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: public static void mpuSetWait () {
6623:
6624: if (currentMPU <= Model.MPU_MC68010) {
6625: mpuWaitTime.ram = mpuCycleUnit >> 3;
6626: mpuWaitTime.vicon = (long) (mpuCycleUnit * 0.6);
6627: mpuWaitTime.crtc =
6628: mpuWaitTime.prnport =
6629: mpuWaitTime.sysport =
6630: mpuWaitTime.sprc =
6631: mpuWaitTime.sram =
6632: mpuWaitTime.rom = mpuCycleUnit;
6633: mpuWaitTime.gvram = (long) (mpuCycleUnit * 1.1);
6634: mpuWaitTime.rtc =
6635: mpuWaitTime.opm =
6636: mpuWaitTime.adpcm =
6637: mpuWaitTime.fdc =
6638: mpuWaitTime.fdd =
6639: mpuWaitTime.hdc =
6640: mpuWaitTime.ppi =
6641: mpuWaitTime.ioi = (long) (mpuCycleUnit * 1.7);
6642: mpuWaitTime.tvram = mpuCycleUnit * 2;
6643: mpuWaitTime.palet = (long) (mpuCycleUnit * 2.6);
6644: mpuWaitTime.mfp = (long) (mpuCycleUnit * 4.3);
6645: mpuWaitTime.scc = mpuCycleUnit * 6;
6646: mpuWaitTime.dmac = mpuCycleUnit * 15;
6647: mpuWaitTime.ramlong = mpuWaitTime.ram << 1;
6648: mpuWaitTime.romlong = mpuWaitTime.rom << 1;
6649: } else if (currentMPU <= Model.MPU_MC68030) {
6650: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6651: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6652: mpuWaitTime.sram = mpuCycleUnit * 2;
6653: mpuWaitTime.prnport =
6654: mpuWaitTime.sysport = mpuCycleUnit * 4;
6655: mpuWaitTime.gvram =
6656: mpuWaitTime.crtc =
6657: mpuWaitTime.vicon =
6658: mpuWaitTime.sprc = mpuCycleUnit * 6;
6659: mpuWaitTime.tvram = mpuCycleUnit * 7;
6660: mpuWaitTime.palet = mpuCycleUnit * 11;
6661: mpuWaitTime.opm =
6662: mpuWaitTime.adpcm =
6663: mpuWaitTime.fdc =
6664: mpuWaitTime.fdd =
6665: mpuWaitTime.hdc =
6666: mpuWaitTime.ppi =
6667: mpuWaitTime.ioi = mpuCycleUnit * 15;
6668: mpuWaitTime.mfp = mpuCycleUnit * 19;
6669: mpuWaitTime.rtc = mpuCycleUnit * 28;
6670: mpuWaitTime.dmac = mpuCycleUnit * 34;
6671: mpuWaitTime.scc = mpuCycleUnit * 38;
6672: mpuWaitTime.ramlong = mpuWaitTime.ram;
6673: mpuWaitTime.romlong = mpuWaitTime.rom;
6674: } else {
6675: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6676: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6677: mpuWaitTime.sram = mpuCycleUnit * 13;
6678: mpuWaitTime.prnport =
6679: mpuWaitTime.sysport = mpuCycleUnit * 17;
6680: mpuWaitTime.gvram =
6681: mpuWaitTime.crtc =
6682: mpuWaitTime.vicon =
6683: mpuWaitTime.sprc = mpuCycleUnit * 21;
6684: mpuWaitTime.tvram = mpuCycleUnit * 22;
6685: mpuWaitTime.palet = mpuCycleUnit * 33;
6686: mpuWaitTime.opm =
6687: mpuWaitTime.adpcm =
6688: mpuWaitTime.fdc =
6689: mpuWaitTime.fdd =
6690: mpuWaitTime.hdc =
6691: mpuWaitTime.ppi =
6692: mpuWaitTime.ioi = mpuCycleUnit * 37;
6693: mpuWaitTime.mfp = mpuCycleUnit * 47;
6694: mpuWaitTime.dmac = mpuCycleUnit * 73;
6695: mpuWaitTime.rtc = mpuCycleUnit * 77;
6696: mpuWaitTime.scc = mpuCycleUnit * 97;
6697: mpuWaitTime.ramlong = mpuWaitTime.ram;
6698: mpuWaitTime.romlong = mpuWaitTime.rom;
6699: }
6700: if (true) {
6701:
6702: mpuNoWaitTime.sram = mpuWaitTime.sram;
6703: mpuNoWaitTime.rom = mpuWaitTime.rom;
6704: mpuNoWaitTime.romlong = mpuWaitTime.romlong;
6705: }
6706:
6707: dmaWaitTime.ram = dmaCycleUnit >> 3;
6708: dmaWaitTime.sram = 0;
6709: dmaWaitTime.rom = 0;
6710: dmaWaitTime.gvram =
6711: dmaWaitTime.crtc =
6712: dmaWaitTime.vicon =
6713: dmaWaitTime.prnport =
6714: dmaWaitTime.sysport =
6715: dmaWaitTime.sprc = dmaCycleUnit;
6716: dmaWaitTime.tvram =
6717: dmaWaitTime.rtc =
6718: dmaWaitTime.opm =
6719: dmaWaitTime.adpcm =
6720: dmaWaitTime.fdc =
6721: dmaWaitTime.fdd =
6722: dmaWaitTime.hdc =
6723: dmaWaitTime.ppi =
6724: dmaWaitTime.ioi = dmaCycleUnit * 2;
6725: dmaWaitTime.palet = dmaCycleUnit * 3;
6726: dmaWaitTime.mfp = dmaCycleUnit * 4;
6727: dmaWaitTime.scc = dmaCycleUnit * 6;
6728: dmaWaitTime.dmac = dmaCycleUnit * 15;
6729: dmaWaitTime.ramlong = dmaWaitTime.ram << 1;
6730: dmaWaitTime.romlong = dmaWaitTime.rom << 1;
6731: if (MC68060.CAT_ON) {
6732: if (Model.MPU_MC68LC060 <= currentMPU) {
6733: MC68060.catMainLongTime = mpuCycleUnit * 13;
6734: MC68060.catMainLineTime = mpuCycleUnit * 45;
6735: MC68060.catHighLongTime = mpuCycleUnit * 9;
6736: MC68060.catHighLineTime = mpuCycleUnit * 15;
6737: }
6738: }
6739: }
6740:
6741:
6742:
6743:
6744:
6745: public static void mpuReset (int device, int romHandle) {
6746:
6747: mpuBootDevice = device;
6748: mpuROMBootHandle = romHandle;
6749:
6750:
6751:
6752:
6753:
6754:
6755:
6756:
6757:
6758:
6759:
6760:
6761: if (mpuBootDevice == -1) {
6762: if (mpuSavedBootDevice != -1) {
6763: mpuBootDevice = mpuSavedBootDevice;
6764: mpuROMBootHandle = mpuSavedROMBootHandle;
6765: mpuSavedBootDevice = -1;
6766: mpuSavedROMBootHandle = -1;
6767: }
6768: } else {
6769: if (mpuSavedBootDevice == -1) {
6770: mpuSavedBootDevice = MainMemory.mmrRwz (0x00ed0018);
6771: mpuSavedROMBootHandle = MainMemory.mmrRls (0x00ed000c);
6772: }
6773: }
6774:
6775:
6776: if (mpu010) {
6777: if (specifiedFirstMPU == Model.MPU_MC68000) {
6778: specifiedFirstMPU = Model.MPU_MC68010;
6779: }
6780: if (specifiedSecondMPU == Model.MPU_MC68000) {
6781: specifiedSecondMPU = Model.MPU_MC68010;
6782: }
6783: } else {
6784: if (specifiedFirstMPU == Model.MPU_MC68010) {
6785: specifiedFirstMPU = Model.MPU_MC68000;
6786: }
6787: if (specifiedSecondMPU == Model.MPU_MC68010) {
6788: specifiedSecondMPU = Model.MPU_MC68000;
6789: }
6790: }
6791:
6792:
6793: specifiedIsSecond = false;
6794: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
6795: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
6796:
6797: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
6798: MC68EC030.m30DivZeroVFlag = false;
6799: }
6800:
6801: if (mpuTask != null) {
6802: mpuClockLimit = 0L;
6803: System.out.println (Multilingual.mlnJapanese ?
6804: "MPU を停止します" :
6805: "MPU stops");
6806: mpuTask.cancel ();
6807: mpuTask = null;
6808: }
6809:
6810: tmrTimer.schedule (new TimerTask () {
6811: @Override public void run () {
6812:
6813:
6814:
6815: currentModel = specifiedModel;
6816: currentAccelerator = specifiedAccelerator;
6817: frmUpdateTitle ();
6818:
6819: currentIsSecond = specifiedIsSecond;
6820: currentFirstMPU = specifiedFirstMPU;
6821: currentSecondMPU = specifiedSecondMPU;
6822: currentMPU = specifiedMPU;
6823:
6824: mpuSetCurrentClock (specifiedClock);
6825:
6826: currentCopro0 = specifiedCopro0;
6827: currentCopro1 = specifiedCopro1;
6828: currentCopro2 = specifiedCopro2;
6829: currentOnchipFPU = specifiedOnchipFPU;
6830:
6831:
6832: if (currentMPU < Model.MPU_MC68020) {
6833: if (busHimem68000) {
6834: busRequestExMemoryStart = 0x10000000;
6835: busRequestExMemorySize = busLocalMemorySize;
6836: busRequestExMemoryArray = busLocalMemoryArray;
6837: } else {
6838: busRequestExMemoryStart = 0x10000000;
6839: busRequestExMemorySize = 0 << 20;
6840: busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
6841: }
6842: } else if (currentMPU < Model.MPU_MC68LC040) {
6843: if (busHighMemory060turboOn) {
6844: busRequestExMemoryStart = 0x10000000;
6845: busRequestExMemorySize = busLocalMemorySize;
6846: busRequestExMemoryArray = busLocalMemoryArray;
6847: } else {
6848: busRequestExMemoryStart = 0x01000000;
6849: busRequestExMemorySize = busHighMemorySize;
6850: busRequestExMemoryArray = busHighMemoryArray;
6851: }
6852: } else {
6853: busRequestExMemoryStart = 0x10000000;
6854: busRequestExMemorySize = busLocalMemorySize;
6855: busRequestExMemoryArray = busLocalMemoryArray;
6856: }
6857: busUpdateMemoryMap ();
6858:
6859:
6860: ROM.romReset ();
6861:
6862: RegisterList.drpSetMPU ();
6863:
6864: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
6865: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6866: MC68060.mmuReset ();
6867:
6868:
6869: if (Model.MPU_MC68020 <= currentMPU) {
6870: if ((7 & currentCopro0) == 1) {
6871: fpuMotherboardCoprocessor.epbSetMC68881 ();
6872: } else if ((7 & currentCopro0) == 2) {
6873: fpuMotherboardCoprocessor.epbSetMC68882 ();
6874: } else {
6875: fpuMotherboardCoprocessor.epbSetFullSpec ();
6876: }
6877: if ((8 & currentCopro0) == 0) {
6878: fpuMotherboardCoprocessor.epbSetExtended ();
6879: } else {
6880: fpuMotherboardCoprocessor.epbSetTriple ();
6881: }
6882: }
6883:
6884: if ((7 & currentCopro1) == 1) {
6885: fpuCoproboard1.epbSetMC68881 ();
6886: } else if ((7 & currentCopro1) == 2) {
6887: fpuCoproboard1.epbSetMC68882 ();
6888: } else {
6889: fpuCoproboard1.epbSetFullSpec ();
6890: }
6891: if ((8 & currentCopro1) == 0) {
6892: fpuCoproboard1.epbSetExtended ();
6893: } else {
6894: fpuCoproboard1.epbSetTriple ();
6895: }
6896:
6897: if ((7 & currentCopro2) == 1) {
6898: fpuCoproboard2.epbSetMC68881 ();
6899: } else if ((7 & currentCopro2) == 2) {
6900: fpuCoproboard2.epbSetMC68882 ();
6901: } else {
6902: fpuCoproboard2.epbSetFullSpec ();
6903: }
6904: if ((8 & currentCopro2) == 0) {
6905: fpuCoproboard2.epbSetExtended ();
6906: } else {
6907: fpuCoproboard2.epbSetTriple ();
6908: }
6909:
6910: if (Model.MPU_MC68040 <= currentMPU) {
6911: if ((7 & currentOnchipFPU) == 6) {
6912: fpuOnChipFPU.epbSetMC68060 ();
6913: } else {
6914: fpuOnChipFPU.epbSetFullSpec ();
6915: }
6916: if ((8 & currentOnchipFPU) == 0) {
6917: fpuOnChipFPU.epbSetExtended ();
6918: } else {
6919: fpuOnChipFPU.epbSetTriple ();
6920: }
6921: }
6922:
6923: if (!currentModel.isX68030 ()) {
6924: dmaCycleUnit = TMR_FREQ / 10000000L;
6925: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6926: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6927: mpuROMWaitCycles = 1;
6928: mpuRAMWaitCycles = 0;
6929: } else {
6930: dmaCycleUnit = TMR_FREQ / 12500000L;
6931: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6932: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6933: mpuROMWaitCycles = 0;
6934: mpuRAMWaitCycles = 0;
6935: }
6936:
6937: busWaitCycles = busWaitCyclesRequest;
6938: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
6939:
6940: HD63450.dmaReadCycles = (currentModel.isPRO () ? 6 :
6941: currentModel.isCompact () ? 4 :
6942: 5);
6943: HD63450.dmaWriteCycles = (currentModel.isPRO () ? 6 :
6944: 5);
6945:
6946: if (currentMPU < Model.MPU_MC68020) {
6947:
6948: mpuIgnoreAddressError = false;
6949:
6950: mpuCacheOn = false;
6951:
6952: } else if (currentMPU < Model.MPU_MC68040) {
6953:
6954: mpuIgnoreAddressError = true;
6955: fpuBox = fpuMotherboardCoprocessor;
6956: fpuBox.epbReset ();
6957: fpuFPn = fpuBox.epbFPn;
6958:
6959: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
6960:
6961: } else {
6962:
6963: mpuIgnoreAddressError = true;
6964: fpuBox = fpuOnChipFPU;
6965: fpuBox.epbReset ();
6966: fpuFPn = fpuBox.epbFPn;
6967:
6968: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6969: mpuCacheOn = (mpuCACR & 0x80008000) != 0;
6970: if (MC68060.CAT_ON) {
6971: if (Model.MPU_MC68LC060 <= currentMPU) {
6972: MC68060.catReset ();
6973: }
6974: }
6975:
6976: }
6977:
6978: mpuSetWait ();
6979:
6980:
6981: regSRT1 = regSRT0 = 0;
6982: regSRS = REG_SR_S;
6983: regSRM = 0;
6984: regSRI = REG_SR_I;
6985: regCCR = 0;
6986: Arrays.fill (regRn, 0);
6987:
6988: regRn[15] = MainMemory.mmrRls (0x00ff0000);
6989: regPC = MainMemory.mmrRls (0x00ff0004);
6990:
6991: MainMemory.mmrReset ();
6992:
6993: busReset ();
6994: if (InstructionBreakPoint.IBP_ON) {
6995: InstructionBreakPoint.ibpOp1MemoryMap = InstructionBreakPoint.ibpOp1SuperMap;
6996: InstructionBreakPoint.ibpReset ();
6997: }
6998: if (BranchLog.BLG_ON) {
6999: BranchLog.blgReset ();
7000: }
7001:
7002: mpuIMR = 0;
7003: mpuIRR = 0;
7004: if (MC68901.MFP_DELAYED_INTERRUPT) {
7005: mpuDIRR = 0;
7006: }
7007: mpuISR = 0;
7008:
7009:
7010: mpuStart ();
7011: }
7012: }, TMR_DELAY);
7013:
7014: }
7015:
7016:
7017:
7018: public static void mpuStopAndStart () {
7019: if (mpuTask == null) {
7020: mpuStart ();
7021: } else {
7022: if (RootPointerList.RTL_ON) {
7023: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
7024: RootPointerList.rtlCurrentUserTaskIsStoppable) {
7025: mpuStop (null);
7026: }
7027: } else {
7028: mpuStop (null);
7029: }
7030: }
7031: }
7032:
7033:
7034:
7035:
7036:
7037: public static void mpuStart () {
7038: if (mpuTask != null) {
7039: mpuClockLimit = 0L;
7040: System.out.println (Multilingual.mlnJapanese ?
7041: "MPU を停止します" :
7042: "MPU stops");
7043: mpuTask.cancel ();
7044: mpuTask = null;
7045: }
7046:
7047: for (AbstractButton button : mpuButtonsStopped) {
7048: button.setEnabled (false);
7049: }
7050: DisassembleList.ddpStoppedBy = null;
7051: System.out.println (Model.mpuNameOf (currentMPU) + (Multilingual.mlnJapanese ? " を起動します" : " starts up"));
7052: mpuTask = new TimerTask () {
7053: @Override public void run () {
7054: mpuContinue = true;
7055: mpuClockLimit = mpuClockTime + TMR_FREQ * TMR_INTERVAL / 1000;
7056: mpuExecuteCore ();
7057: }
7058: };
7059: tmrTimer.scheduleAtFixedRate (mpuTask, TMR_DELAY, TMR_INTERVAL);
7060:
7061: for (AbstractButton button : mpuButtonsRunning) {
7062: button.setEnabled (true);
7063: }
7064: }
7065:
7066:
7067:
7068: public static void mpuExecuteCore () {
7069:
7070: long nanoStart = System.nanoTime ();
7071:
7072: busSuper (RP5C15.rtcFirst, 0x00e8a000, 0x00e8c000);
7073:
7074:
7075: if (currentMPU < Model.MPU_MC68010) {
7076: MC68000.mpuCore ();
7077: } else if (currentMPU < Model.MPU_MC68020) {
7078: MC68010.mpuCore ();
7079: } else if (currentMPU < Model.MPU_MC68LC040) {
7080: MC68EC030.mpuCore ();
7081: } else {
7082: MC68060.mpuCore ();
7083: }
7084:
7085: if (dbgVisibleMask != 0) {
7086: dbgUpdate ();
7087: }
7088:
7089: long nanoEnd = System.nanoTime ();
7090: mpuTotalNano += nanoEnd - nanoStart;
7091: if (--mpuAdjustmentCounter == 0) {
7092:
7093: final double expectedNano = 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
7094:
7095: double coreNano0 = (double) mpuTotalNano;
7096: mpuTotalNano = 0L;
7097: double coreNanoA = (coreNano0 * 2.0 + mpuCoreNano1 + mpuCoreNano2) * 0.25;
7098: mpuCoreNano2 = mpuCoreNano1;
7099: mpuCoreNano1 = coreNano0;
7100:
7101:
7102:
7103: double actualPercent = Math.max (1.0, 100.0 * coreNanoA / expectedNano);
7104:
7105: double maxPercent = SoundSource.sndPlayOn ? 90.0 : 100.0;
7106:
7107:
7108:
7109:
7110: if (mpuUtilOn) {
7111:
7112: double targetPercent = Math.min (maxPercent, (double) mpuUtilRatio);
7113: mpuSetClockMHz ((1.2 - 0.2 * actualPercent / targetPercent) * mpuCurrentMHz);
7114: } else {
7115: mpuSetClockMHz (Math.min (maxPercent / actualPercent,
7116: 1.2 - 0.2 * mpuCurrentMHz / mpuClockMHz) * mpuCurrentMHz);
7117: }
7118: Indicator.indUpdate (actualPercent);
7119: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
7120: }
7121: }
7122:
7123:
7124:
7125:
7126: public static void mpuStop (String message) {
7127:
7128: mpuAdvanceCount = 0;
7129: mpuStepCount = 0;
7130: mpuContinue = false;
7131: mpuStop1 (message);
7132: }
7133: public static void mpuStop1 (String message) {
7134: if (mpuTask == null) {
7135: return;
7136: }
7137: DisassembleList.ddpStoppedBy = message;
7138: mpuClockLimit = 0L;
7139: System.out.println (Multilingual.mlnJapanese ?
7140: "MPU を停止します" :
7141: "MPU stops");
7142: mpuTask.cancel ();
7143: mpuTask = null;
7144:
7145: if (mpuStepCount != 0 && mpuContinue) {
7146: if (mpuStepCount == -1 || --mpuStepCount != 0) {
7147: mpuStep (mpuStepCount);
7148: return;
7149: }
7150: }
7151: mpuAdvanceCount = 0;
7152: mpuStepCount = 0;
7153: mpuContinue = false;
7154:
7155: for (AbstractButton button : mpuButtonsRunning) {
7156: button.setEnabled (false);
7157: }
7158: tmrTimer.schedule (new TimerTask () {
7159: @Override public void run () {
7160: mpuUpdateWindow ();
7161: }
7162: }, TMR_DELAY);
7163: }
7164:
7165:
7166:
7167:
7168:
7169:
7170: public static void mpuAdvance (int n) {
7171: if (mpuTask != null) {
7172: return;
7173: }
7174: mpuAdvanceCount = n;
7175: DisassembleList.ddpStoppedBy = null;
7176: mpuTask = new TimerTask () {
7177: @Override public void run () {
7178: mpuContinue = true;
7179: do {
7180: mpuClockLimit = mpuClockTime + 1L;
7181: mpuExecuteCore ();
7182: } while (mpuContinue && --mpuAdvanceCount != 0);
7183: mpuClockLimit = 0L;
7184: if (mpuTask != null) {
7185: mpuTask.cancel ();
7186: mpuTask = null;
7187: }
7188: if (mpuStepCount != 0 && mpuContinue) {
7189: if (mpuStepCount == -1 || --mpuStepCount != 0) {
7190: mpuStep (mpuStepCount);
7191: return;
7192: }
7193: }
7194: mpuAdvanceCount = 0;
7195: mpuStepCount = 0;
7196: mpuContinue = false;
7197: mpuUpdateWindow ();
7198: }
7199: };
7200: tmrTimer.schedule (mpuTask, TMR_DELAY);
7201: }
7202:
7203:
7204:
7205:
7206:
7207:
7208: public static void mpuStep (int n) {
7209: if (mpuTask != null) {
7210: return;
7211: }
7212: mpuStepCount = n;
7213: Disassembler.disDisassemble (new StringBuilder (), regPC, regSRS);
7214: if ((Disassembler.disStatus & (Disassembler.DIS_ALWAYS_BRANCH | Disassembler.DIS_SOMETIMES_BRANCH)) != 0) {
7215: if (mpuStepCount == -1 &&
7216: (Disassembler.disOC == 0x4e73 ||
7217: Disassembler.disOC == 0x4e74 ||
7218: Disassembler.disOC == 0x4e75 ||
7219: Disassembler.disOC == 0x4e77) &&
7220: mpuUntilReturnSRS == regSRS &&
7221: (currentMPU < Model.MPU_MC68LC040 ||
7222: mpuUntilReturnRP == (regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP)) &&
7223: mpuUntilReturnPC0 != regPC0 &&
7224: Integer.compareUnsigned (mpuUntilReturnSP, regRn[15]) <= 0) {
7225: mpuAdvanceCount = 0;
7226: mpuStepCount = 0;
7227: mpuContinue = false;
7228: mpuUpdateWindow ();
7229: return;
7230: }
7231: mpuAdvance (1);
7232: } else {
7233: if (InstructionBreakPoint.IBP_ON) {
7234: InstructionBreakPoint.ibpInstant (Disassembler.disPC, DisassembleList.ddpSupervisorMode);
7235: mpuStart ();
7236: }
7237: }
7238: }
7239:
7240:
7241:
7242:
7243:
7244:
7245:
7246:
7247:
7248:
7249:
7250: public static void mpuStepUntilReturn () {
7251: if (mpuTask != null) {
7252: return;
7253: }
7254: mpuUntilReturnSRS = regSRS;
7255: mpuUntilReturnRP = regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP;
7256: mpuUntilReturnPC0 = regPC0;
7257: mpuUntilReturnSP = regRn[15];
7258: mpuStep (-1);
7259: }
7260:
7261:
7262:
7263: public static void mpuUpdateWindow () {
7264: if (dbgVisibleMask != 0) {
7265: if ((dbgVisibleMask & DBG_DDP_VISIBLE_MASK) != 0) {
7266: DisassembleList.ddpBacktraceRecord = -1L;
7267: DisassembleList.ddpUpdate (-1, -1, false);
7268: }
7269: if (BranchLog.BLG_ON) {
7270: if ((dbgVisibleMask & DBG_BLG_VISIBLE_MASK) != 0) {
7271: BranchLog.blgUpdate (BranchLog.BLG_SELECT_NEWEST);
7272: }
7273: }
7274: if (ProgramFlowVisualizer.PFV_ON) {
7275: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
7276: ProgramFlowVisualizer.pfvUpdate ();
7277: }
7278: }
7279: if (RasterBreakPoint.RBP_ON) {
7280: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
7281: RasterBreakPoint.rbpUpdateFrame ();
7282: }
7283: }
7284: if (ScreenModeTest.SMT_ON) {
7285: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
7286: ScreenModeTest.smtUpdateFrame ();
7287: }
7288: }
7289: if (RootPointerList.RTL_ON) {
7290: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
7291: RootPointerList.rtlUpdateFrame ();
7292: }
7293: }
7294: if (SpritePatternViewer.SPV_ON) {
7295: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
7296: SpritePatternViewer.spvUpdateFrame ();
7297: }
7298: }
7299: if (PaletteViewer.PLV_ON) {
7300: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
7301: PaletteViewer.plvUpdateFrame ();
7302: }
7303: }
7304: if (ATCMonitor.ACM_ON) {
7305: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
7306: ATCMonitor.acmUpdateFrame ();
7307: }
7308: }
7309: }
7310:
7311: if (DebugConsole.dgtRequestRegs != 0) {
7312: if ((DebugConsole.dgtRequestRegs & 1) != 0) {
7313: ExpressionEvaluator.ElementType.ETY_COMMAND_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
7314: }
7315: if ((DebugConsole.dgtRequestRegs & 2) != 0) {
7316: ExpressionEvaluator.ElementType.ETY_COMMAND_FLOAT_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
7317: }
7318: if ((DebugConsole.dgtRequestRegs & 4) != 0) {
7319: DebugConsole.dgtPrintPrompt ();
7320: }
7321: DebugConsole.dgtRequestRegs = 0;
7322: }
7323:
7324: for (AbstractButton button : mpuButtonsRunning) {
7325: button.setEnabled (false);
7326: }
7327:
7328: for (AbstractButton button : mpuButtonsStopped) {
7329: button.setEnabled (true);
7330: }
7331: }
7332:
7333:
7334:
7335: public static JButton mpuMakeBreakButton () {
7336: return mpuAddButtonRunning (
7337: Multilingual.mlnToolTipText (
7338: ComponentFactory.createImageButton (
7339: LnF.LNF_BREAK_IMAGE,
7340: LnF.LNF_BREAK_DISABLED_IMAGE,
7341: "Stop", mpuDebugActionListener),
7342: "ja", "停止")
7343: );
7344: }
7345:
7346:
7347:
7348: public static JButton mpuMakeTraceButton () {
7349: return mpuAddButtonStopped (
7350: Multilingual.mlnToolTipText (
7351: ComponentFactory.createImageButton (
7352: LnF.LNF_TRACE_IMAGE,
7353: LnF.LNF_TRACE_DISABLED_IMAGE,
7354: "Trace", mpuDebugActionListener),
7355: "ja", "トレース")
7356: );
7357: }
7358:
7359:
7360:
7361: public static JButton mpuMakeTrace10Button () {
7362: return mpuAddButtonStopped (
7363: Multilingual.mlnToolTipText (
7364: ComponentFactory.createImageButton (
7365: LnF.LNF_TRACE_10_IMAGE,
7366: LnF.LNF_TRACE_10_DISABLED_IMAGE,
7367: "Trace 10 times", mpuDebugActionListener),
7368: "ja", "トレース 10 回")
7369: );
7370: }
7371:
7372:
7373:
7374: public static JButton mpuMakeTrace100Button () {
7375: return mpuAddButtonStopped (
7376: Multilingual.mlnToolTipText (
7377: ComponentFactory.createImageButton (
7378: LnF.LNF_TRACE_100_IMAGE,
7379: LnF.LNF_TRACE_100_DISABLED_IMAGE,
7380: "Trace 100 times", mpuDebugActionListener),
7381: "ja", "トレース 100 回")
7382: );
7383: }
7384:
7385:
7386:
7387: public static JButton mpuMakeStepButton () {
7388: return mpuAddButtonStopped (
7389: Multilingual.mlnToolTipText (
7390: ComponentFactory.createImageButton (
7391: LnF.LNF_STEP_IMAGE,
7392: LnF.LNF_STEP_DISABLED_IMAGE,
7393: "Step", mpuDebugActionListener),
7394: "ja", "ステップ")
7395: );
7396: }
7397:
7398:
7399:
7400: public static JButton mpuMakeStep10Button () {
7401: return mpuAddButtonStopped (
7402: Multilingual.mlnToolTipText (
7403: ComponentFactory.createImageButton (
7404: LnF.LNF_STEP_10_IMAGE,
7405: LnF.LNF_STEP_10_DISABLED_IMAGE,
7406: "Step 10 times", mpuDebugActionListener),
7407: "ja", "ステップ 10 回")
7408: );
7409: }
7410:
7411:
7412:
7413: public static JButton mpuMakeStep100Button () {
7414: return mpuAddButtonStopped (
7415: Multilingual.mlnToolTipText (
7416: ComponentFactory.createImageButton (
7417: LnF.LNF_STEP_100_IMAGE,
7418: LnF.LNF_STEP_100_DISABLED_IMAGE,
7419: "Step 100 times", mpuDebugActionListener),
7420: "ja", "ステップ 100 回")
7421: );
7422: }
7423:
7424:
7425:
7426: public static JButton mpuMakeReturnButton () {
7427: return mpuAddButtonStopped (
7428: Multilingual.mlnToolTipText (
7429: ComponentFactory.createImageButton (
7430: LnF.LNF_STEP_UNTIL_RETURN_IMAGE,
7431: LnF.LNF_STEP_UNTIL_RETURN_DISABLED_IMAGE,
7432: "Step until return", mpuDebugActionListener),
7433: "ja", "ステップアンティルリターン")
7434: );
7435: }
7436:
7437:
7438:
7439: public static JButton mpuMakeRunButton () {
7440: return mpuAddButtonStopped (
7441: Multilingual.mlnToolTipText (
7442: ComponentFactory.createImageButton (
7443: LnF.LNF_RUN_IMAGE,
7444: LnF.LNF_RUN_DISABLED_IMAGE,
7445: "Run", mpuDebugActionListener),
7446: "ja", "実行")
7447: );
7448: }
7449:
7450:
7451:
7452: public static <T extends AbstractButton> T mpuAddButtonRunning (T button) {
7453: button.setEnabled (mpuTask != null);
7454: mpuButtonsRunning.add (button);
7455: return button;
7456: }
7457:
7458:
7459:
7460: public static <T extends AbstractButton> T mpuAddButtonStopped (T button) {
7461: button.setEnabled (mpuTask == null);
7462: mpuButtonsStopped.add (button);
7463: return button;
7464: }
7465:
7466:
7467:
7468:
7469:
7470:
7471:
7472:
7473:
7474:
7475:
7476:
7477:
7478:
7479:
7480:
7481: public static final int EMX_OPCODE_BASE = 0x4e00;
7482: public static final int EMX_OPCODE_HFSBOOT = EMX_OPCODE_BASE + 0x00;
7483: public static final int EMX_OPCODE_HFSINST = EMX_OPCODE_BASE + 0x01;
7484: public static final int EMX_OPCODE_HFSSTR = EMX_OPCODE_BASE + 0x02;
7485: public static final int EMX_OPCODE_HFSINT = EMX_OPCODE_BASE + 0x03;
7486: public static final int EMX_OPCODE_EMXNOP = EMX_OPCODE_BASE + 0x04;
7487: public static final int EMX_OPCODE_EMXWAIT = EMX_OPCODE_BASE + 0x05;
7488:
7489: public static final String[] EMX_MNEMONIC_ARRAY = {
7490: "hfsboot",
7491: "hfsinst",
7492: "hfsstr",
7493: "hfsint",
7494: "emxnop",
7495: "emxwait",
7496: };
7497:
7498:
7499:
7500:
7501: public static void emxNop () {
7502: if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x00007140) {
7503: int head = regRn[9];
7504: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7505:
7506:
7507: emxPatchPCM8A (head, tail);
7508:
7509:
7510: emxCheckRSDRV202 (head, tail);
7511: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000716c) {
7512: int head = regRn[9];
7513: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7514:
7515:
7516: emxPatch060turbosys (head, tail);
7517:
7518:
7519: if (Z8530.SCC_FSX_MOUSE) {
7520: emxCheckFSX (head, tail);
7521: }
7522:
7523:
7524: if (HFS.HFS_USE_TWENTY_ONE) {
7525: emxCheckTwentyOne (head, tail);
7526: }
7527:
7528:
7529: LabeledAddress.lblClear ();
7530: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000972c) {
7531: int head = regRn[8] + 256;
7532:
7533: int tail = MC68060.mmuPeekLong (head - 208, 1);
7534:
7535:
7536: emxCheckBSIO021 (head, tail);
7537:
7538:
7539: emxPatchPCM8A (head, tail);
7540:
7541:
7542: emxCheckTMSIO031 (head, tail);
7543:
7544:
7545: LabeledAddress.lblClear ();
7546:
7547:
7548: if (dbgStopAtStart) {
7549: InstructionBreakPoint.ibpInstant (regRn[12], 0);
7550: }
7551: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000a090) {
7552: int head = regRn[8] + 256;
7553: int tail = MC68060.mmuPeekLongData (regRn[8] + 8, 1);
7554: String name = MC68060.mmuPeekStringZ (head - 60, 1);
7555: if (name.equalsIgnoreCase ("fsx.x")) {
7556:
7557:
7558: if (Z8530.SCC_FSX_MOUSE) {
7559: emxCheckFSX (head, tail);
7560: }
7561: }
7562: if (name.equalsIgnoreCase ("TwentyOne.x")) {
7563:
7564:
7565: if (HFS.HFS_USE_TWENTY_ONE) {
7566: emxCheckTwentyOne (head, tail);
7567: }
7568: }
7569: }
7570: }
7571:
7572: public static final int[] emxPCM8AFFMap = {
7573: 0x00000138, 0x000001f6, 0x00000394, 0x000011ec, 0x0000120a, 0x00001400, 0x00001814, 0x00001870, 0x00001882, 0x0000188a,
7574: 0x00001892, 0x000018a2, 0x000018a8, 0x000018ca, 0x000018d4, 0x000018e0, 0x000018e8, 0x00001908, 0x000019e4, 0x00001afa,
7575: 0x00001b58, 0x00001b7c, 0x00001bac, 0x00001c38, 0x00001ccc, 0x000021f8, 0x00002250, 0x00002258, 0x00002290, 0x000022a6,
7576: 0x000022b0, 0x000022c0, 0x000022c8, 0x000022de, 0x000022ea, 0x000030c8, 0x000030de, 0x000030e6, 0x000030ea, 0x000030f6,
7577: 0x00003112, 0x00003188, 0x0000334c, 0x0000338a, 0x000033a2, 0x000033c4, 0x000033d0, 0x0000341a, 0x00003428, 0x00003496,
7578: 0x000034a6, 0x000034d6, 0x0000fe0e, 0x0000fec8, 0x0000feec, 0x0000ff46, 0x0000ff4e,
7579: };
7580:
7581:
7582:
7583: public static void emxPatchPCM8A (int head, int tail) {
7584: if (head + 0x0000ff60 <= tail &&
7585: MC68060.mmuPeekLongData (head + 0x10f8, 1) == 0x50434d38 &&
7586: MC68060.mmuPeekLongData (head + 0x10fc, 1) == 0x41313032) {
7587: System.out.println (Multilingual.mlnJapanese ?
7588: "PCM8A.X 1.02 があります" :
7589: "PCM8A.X 1.02 exists");
7590: int patched = 0;
7591: int failed = 0;
7592:
7593: for (int offset : emxPCM8AFFMap) {
7594: if (MC68060.mmuPeekByteZeroData (head + offset, 1) == 0xff) {
7595: MC68060.mmuPokeByteData (head + offset, 0x00, 1);
7596: patched++;
7597: } else {
7598: failed++;
7599: }
7600: }
7601: if (patched != 0) {
7602: System.out.printf (Multilingual.mlnJapanese ?
7603: "PCM8A.X 1.02 にパッチをあてました (%d/%d)\n" :
7604: "PCM8A.X 1.02 was patched (%d/%d)\n",
7605: patched, patched + failed);
7606: }
7607: }
7608: }
7609:
7610:
7611:
7612: public static void emxPatch060turbosys (int head, int tail) {
7613:
7614:
7615:
7616:
7617: if (head + 0x00002000 <= tail &&
7618: MC68060.mmuPeekLongData (head + 0x00000ec0, 1) == 0x203c302e &&
7619: MC68060.mmuPeekLongData (head + 0x00000ec4, 1) == 0x3536227c &&
7620: MC68060.mmuPeekLongData (head + 0x00000ec8, 1) == 0x30363054) {
7621: System.out.println (Multilingual.mlnJapanese ?
7622: "060turbo.sys 0.56 があります" :
7623: "060turbo.sys 0.56 exists");
7624:
7625:
7626:
7627: int patched = 0;
7628: int failed = 0;
7629: if (MC68060.mmuPeekLongData (head + 0x000021e6, 1) == 0x08f90004 &&
7630: MC68060.mmuPeekLongData (head + 0x000021ea, 1) == 0x00ed0070) {
7631: MC68060.mmuPokeWordData (head + 0x000021e6, 0x0839, 1);
7632: patched++;
7633: } else {
7634: failed++;
7635: }
7636: System.out.printf (Multilingual.mlnJapanese ?
7637: "060turbo.sys 0.56 にパッチをあてました (%d/%d)\n" :
7638: "060turbo.sys 0.56 was patched (%d/%d)\n",
7639: patched, patched + failed);
7640: }
7641: }
7642:
7643:
7644:
7645: public static void emxCheckFSX (int head, int tail) {
7646: if (Z8530.SCC_FSX_MOUSE) {
7647: if (head + 0x00063200 <= tail &&
7648: "\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))) {
7649: System.out.println (Multilingual.mlnJapanese ?
7650: "FSX.X 3.10 があります" :
7651: "FSX.X 3.10 exists");
7652: Z8530.sccFSXMouseHook = head + 0x04f82a;
7653: Z8530.sccFSXMouseWork = head + 0x063184;
7654: }
7655: }
7656: }
7657:
7658:
7659:
7660:
7661:
7662:
7663: public static void emxCheckRSDRV202 (int head, int tail) {
7664: if (head + 0x000ea6 <= tail &&
7665: MC68060.mmuPeekEquals (head + 0x000e4e, "RS-232C DRIVER for X68000 version 2.02")) {
7666: if (RS232CTerminal.trmRSDRV202Head != head) {
7667: RS232CTerminal.trmRSDRV202Head = head;
7668: int[] patchData = {
7669:
7670:
7671: 0x05f8, 0x000a, 0x000b,
7672:
7673: 0x0600, 0xd040, 0x2048,
7674:
7675: 0x060e, 0x3030, 0x4e90,
7676: 0x0610, 0x0000, 0x2048,
7677:
7678: 0x074e, 0x0821, 0x2041,
7679: 0x0750, 0x0410, 0x3200,
7680: 0x0752, 0x0207, 0x303c,
7681: 0x0754, 0x0102, 0x0823,
7682: 0x0756, 0x0080, 0xe268,
7683: 0x0758, 0x003f, 0x72fe,
7684: 0x075a, 0x001f, 0xd141,
7685: 0x075c, 0x000e, 0x2208,
7686: 0x075e, 0x0006, 0x4e75,
7687:
7688:
7689: 0x0ab0, 0x0040, 0x0400,
7690: 0x0ad2, 0x0040, 0x0400,
7691: 0x0af4, 0x0040, 0x0400,
7692: 0x0b16, 0x0040, 0x0400,
7693: 0x0b38, 0x0040, 0x0400,
7694:
7695:
7696: 0x0cae, 0x0009, 0x000b,
7697: };
7698: int patched = 0;
7699: int failed = 0;
7700: for (int i = 0; i < patchData.length; i += 3) {
7701: int a = head + patchData[i];
7702: int b = patchData[i + 1];
7703: int c = patchData[i + 2];
7704: int d = MC68060.mmuPeekWordZeroData (a, 1);
7705: if (d == b) {
7706: MC68060.mmuPokeWordData (a, c, 1);
7707: patched++;
7708: } else if (d != c) {
7709: failed++;
7710: }
7711: }
7712: System.out.printf ("RSDRV.SYS 2.02 found at %08X and patched (%d/%d)\n", head, patched, patched + failed);
7713: }
7714: }
7715: }
7716:
7717:
7718:
7719:
7720:
7721: public static void emxCheckTMSIO031 (int head, int tail) {
7722: if (head + 0x000fc4 <= tail &&
7723: MC68060.mmuPeekEquals (head + 0x000d1c, "TMSIO version 0.31 Copyright (C) 1990-93 by Miki Hoshino")) {
7724: if (RS232CTerminal.trmTMSIO031Head != head) {
7725: RS232CTerminal.trmTMSIO031Head = head;
7726: System.out.printf ("TMSIO 0.31 found at %08X\n", head);
7727: }
7728: }
7729: }
7730:
7731:
7732:
7733:
7734:
7735: public static void emxCheckBSIO021 (int head, int tail) {
7736: if (head + 0x001c2c <= tail &&
7737: MC68060.mmuPeekEquals (head + 0x001a66, "BSIO version 0.21 Copyright (C) 1994 By BAZU")) {
7738: if (RS232CTerminal.trmBSIO021Head != head) {
7739: RS232CTerminal.trmBSIO021Head = head;
7740: System.out.printf ("BSIO 0.21 found at %08X\n", head);
7741: }
7742: }
7743: }
7744:
7745:
7746:
7747: public static void emxCheckTwentyOne (int head, int tail) {
7748: if (HFS.HFS_USE_TWENTY_ONE &&
7749: head + 64 <= tail) {
7750: if (MainMemory.mmrTwentyOneOptionAddress != 0 ||
7751: MainMemory.mmrHumanVersion <= 0) {
7752: return;
7753: }
7754: int name1 = MC68060.mmuPeekLongData (head + 14, 1);
7755: if (name1 == ('*' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7756: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7757: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '*')) {
7758: MainMemory.mmrTwentyOneOptionAddress = -1;
7759: }
7760: } else if (name1 == ('?' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7761: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7762: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '?') ||
7763: name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | 'E')) {
7764: System.out.println (Multilingual.mlnJapanese ?
7765: "TwentyOne.x があります" :
7766: "TwentyOne.x exists");
7767: MainMemory.mmrTwentyOneOptionAddress = head + 22;
7768: }
7769: }
7770: }
7771: }
7772:
7773:
7774:
7775:
7776:
7777:
7778:
7779:
7780:
7781:
7782:
7783:
7784:
7785:
7786:
7787:
7788:
7789:
7790:
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: public static final boolean IRP_BITREV_REVERSE = false;
7824: public static final boolean IRP_BITREV_SHIFT = false;
7825: public static final boolean IRP_BITREV_TABLE = true;
7826:
7827: public static final boolean IRP_MOVEM_MAINMEMORY = true;
7828: public static final boolean IRP_MOVEM_EXPAND = false;
7829: public static final boolean IRP_MOVEM_LOOP = false;
7830: public static final boolean IRP_MOVEM_SHIFT_LEFT = false;
7831: public static final boolean IRP_MOVEM_SHIFT_RIGHT = true;
7832: public static final boolean IRP_MOVEM_ZEROS = false;
7833:
7834:
7835: public static void irpReset () {
7836:
7837: CRTC.crtReset ();
7838: VideoController.vcnReset ();
7839: HD63450.dmaReset ();
7840: MC68901.mfpReset ();
7841: Keyboard.kbdReset ();
7842: RP5C15.rtcReset ();
7843: PrinterPort.prnReset ();
7844: SoundSource.sndReset ();
7845: OPM.opmReset ();
7846: ADPCM.pcmReset ();
7847: FDC.fdcReset ();
7848: IOInterrupt.ioiReset ();
7849: eb2Reset ();
7850: if (HostCDROM.HCD_ENABLED) {
7851: HostCDROM.hcdReset ();
7852: }
7853: SPC.spcReset ();
7854: Z8530.sccReset ();
7855: RS232CTerminal.trmReset ();
7856: PPI.ppiReset ();
7857: HFS.hfsReset ();
7858: SpriteScreen.sprReset ();
7859:
7860: if (MercuryUnit.MU4_ON) {
7861: MercuryUnit.mu4Reset ();
7862: }
7863: xt3Reset ();
7864: SRAM.smrReset ();
7865: CONDevice.conReset ();
7866: TextCopy.txcReset ();
7867: }
7868:
7869:
7870:
7871:
7872:
7873:
7874:
7875:
7876:
7877:
7878:
7879:
7880:
7881:
7882:
7883:
7884:
7885:
7886:
7887:
7888:
7889:
7890:
7891:
7892:
7893:
7894:
7895:
7896:
7897:
7898:
7899:
7900:
7901:
7902:
7903:
7904:
7905:
7906:
7907:
7908:
7909:
7910:
7911:
7912:
7913:
7914:
7915:
7916:
7917:
7918:
7919:
7920:
7921:
7922:
7923:
7924:
7925:
7926:
7927:
7928:
7929:
7930:
7931:
7932:
7933:
7934:
7935:
7936:
7937:
7938:
7939:
7940:
7941:
7942:
7943:
7944:
7945:
7946:
7947:
7948:
7949:
7950:
7951:
7952:
7953:
7954:
7955:
7956:
7957:
7958:
7959:
7960:
7961:
7962:
7963:
7964:
7965:
7966:
7967:
7968:
7969:
7970:
7971:
7972:
7973:
7974:
7975:
7976:
7977:
7978:
7979:
7980:
7981:
7982:
7983:
7984:
7985:
7986:
7987:
7988:
7989:
7990:
7991:
7992:
7993:
7994:
7995:
7996:
7997:
7998:
7999:
8000:
8001:
8002:
8003:
8004:
8005:
8006:
8007:
8008:
8009:
8010:
8011:
8012:
8013:
8014:
8015:
8016:
8017:
8018:
8019:
8020:
8021:
8022:
8023:
8024:
8025:
8026:
8027:
8028:
8029:
8030:
8031:
8032:
8033:
8034:
8035:
8036:
8037:
8038:
8039:
8040:
8041:
8042:
8043:
8044:
8045:
8046:
8047:
8048:
8049:
8050:
8051:
8052:
8053:
8054:
8055:
8056:
8057:
8058:
8059:
8060:
8061:
8062:
8063:
8064:
8065:
8066:
8067:
8068:
8069:
8070:
8071:
8072:
8073:
8074:
8075:
8076:
8077:
8078:
8079:
8080:
8081:
8082:
8083:
8084:
8085:
8086:
8087:
8088:
8089:
8090:
8091:
8092:
8093:
8094:
8095:
8096:
8097:
8098:
8099:
8100:
8101:
8102:
8103:
8104:
8105:
8106:
8107:
8108:
8109:
8110:
8111:
8112:
8113:
8114:
8115:
8116:
8117:
8118:
8119:
8120:
8121:
8122:
8123:
8124:
8125:
8126:
8127:
8128:
8129:
8130:
8131:
8132:
8133:
8134:
8135:
8136:
8137:
8138:
8139:
8140:
8141:
8142:
8143:
8144:
8145:
8146:
8147:
8148:
8149:
8150:
8151:
8152:
8153:
8154:
8155:
8156:
8157:
8158:
8159:
8160:
8161:
8162:
8163:
8164:
8165:
8166:
8167:
8168:
8169:
8170:
8171:
8172:
8173:
8174:
8175:
8176:
8177:
8178:
8179:
8180:
8181:
8182:
8183:
8184:
8185:
8186:
8187:
8188:
8189:
8190:
8191:
8192:
8193:
8194:
8195:
8196:
8197:
8198:
8199:
8200:
8201:
8202:
8203:
8204:
8205:
8206:
8207:
8208:
8209:
8210:
8211:
8212:
8213:
8214:
8215:
8216:
8217:
8218:
8219:
8220:
8221:
8222:
8223:
8224:
8225:
8226:
8227:
8228:
8229:
8230:
8231:
8232:
8233:
8234:
8235:
8236:
8237:
8238:
8239:
8240:
8241:
8242:
8243:
8244:
8245:
8246:
8247:
8248:
8249:
8250:
8251:
8252:
8253:
8254:
8255:
8256:
8257:
8258:
8259:
8260:
8261:
8262:
8263:
8264:
8265:
8266:
8267:
8268:
8269:
8270:
8271:
8272:
8273:
8274:
8275:
8276:
8277:
8278:
8279:
8280:
8281:
8282:
8283:
8284:
8285:
8286:
8287:
8288:
8289:
8290:
8291:
8292:
8293:
8294:
8295:
8296:
8297:
8298:
8299:
8300:
8301:
8302:
8303:
8304:
8305:
8306:
8307:
8308:
8309:
8310:
8311:
8312:
8313:
8314:
8315:
8316:
8317:
8318:
8319:
8320:
8321:
8322:
8323:
8324:
8325:
8326:
8327:
8328:
8329:
8330:
8331:
8332:
8333:
8334:
8335:
8336:
8337:
8338:
8339:
8340:
8341:
8342:
8343:
8344:
8345:
8346:
8347:
8348:
8349:
8350:
8351:
8352:
8353:
8354:
8355:
8356:
8357:
8358:
8359:
8360:
8361:
8362:
8363:
8364:
8365:
8366:
8367:
8368:
8369:
8370:
8371:
8372:
8373:
8374:
8375:
8376:
8377:
8378:
8379:
8380:
8381:
8382:
8383:
8384:
8385:
8386:
8387:
8388:
8389:
8390:
8391:
8392:
8393:
8394:
8395:
8396:
8397:
8398:
8399:
8400:
8401:
8402:
8403:
8404:
8405:
8406:
8407:
8408:
8409:
8410:
8411:
8412:
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: 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);
8455:
8456: public static final boolean EFA_SEPARATE_AR = false;
8457:
8458:
8459:
8460:
8461:
8462:
8463: public static final boolean BUS_SPLIT_UNALIGNED_LONG = false;
8464:
8465:
8466: public static final int BUS_MOTHER_BITS = 24;
8467: public static final int BUS_MOTHER_SIZE = BUS_MOTHER_BITS < 32 ? 1 << BUS_MOTHER_BITS : 0;
8468: public static final int BUS_MOTHER_MASK = BUS_MOTHER_SIZE - 1;
8469:
8470: public static final int BUS_ARRAY_SIZE = BUS_MOTHER_SIZE;
8471:
8472:
8473: public static final int BUS_PAGE_BITS = 12;
8474: public static final int BUS_PAGE_SIZE = 1 << BUS_PAGE_BITS;
8475: public static final int BUS_PAGE_COUNT = 1 << (32 - BUS_PAGE_BITS);
8476:
8477:
8478: public static final int MPU_SS_BYTE = 0;
8479: public static final int MPU_SS_WORD = 1;
8480: public static final int MPU_SS_LONG = 2;
8481:
8482:
8483: public static final int MPU_WR_WRITE = 0;
8484: public static final int MPU_WR_READ = 1;
8485:
8486:
8487: public static final int MPU_US_USER = 0;
8488: public static final int MPU_US_SUPERVISOR = 1;
8489:
8490:
8491: public static final MemoryMappedDevice[] busUserMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8492: public static final MemoryMappedDevice[] busSuperMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8493: public static MemoryMappedDevice[] busMemoryMap;
8494:
8495:
8496: public static boolean busHimem68000;
8497:
8498:
8499: public static final int BUS_HIGH_MEMORY_START = 0x01000000;
8500: public static int busHighMemorySize;
8501: public static byte[] busHighMemoryArray;
8502: public static boolean busHighMemorySaveOn;
8503: public static boolean busHighMemory060turboOn;
8504:
8505:
8506: public static final int BUS_LOCAL_MEMORY_START = 0x10000000;
8507: public static int busLocalMemorySize;
8508: public static byte[] busLocalMemoryArray;
8509: public static boolean busLocalMemorySaveOn;
8510:
8511:
8512: public static final byte[] BUS_DUMMY_MEMORY_ARRAY = new byte[0];
8513: public static int busRequestExMemoryStart;
8514: public static int busRequestExMemorySize;
8515: public static byte[] busRequestExMemoryArray;
8516: public static int busExMemoryStart;
8517: public static int busExMemorySize;
8518: public static byte[] busExMemoryArray;
8519:
8520:
8521: public static boolean busRequestCutFC2Pin;
8522: public static boolean busCutFC2Pin;
8523:
8524:
8525:
8526: public static void busInit () {
8527:
8528:
8529: if (!DataBreakPoint.DBP_ON) {
8530: busMemoryMap = busSuperMap;
8531: }
8532:
8533:
8534: int highMemorySizeMB = Settings.sgsGetInt ("highmemory");
8535: busHighMemorySize = highMemorySizeMB == 16 ? highMemorySizeMB << 20 : 0 << 20;
8536: if (busHighMemorySize == 0) {
8537: System.out.println (Multilingual.mlnJapanese ?
8538: "X68030/Xellent30 のハイメモリはありません" :
8539: "X68030/Xellent30 high memory does not exists");
8540: } else {
8541: System.out.printf (Multilingual.mlnJapanese ?
8542: "X68030/Xellent30 のハイメモリのサイズは %dMB です\n" :
8543: "X68030/Xellent30 high memory size is %dMB\n",
8544: busHighMemorySize >> 20);
8545: }
8546: busHighMemoryArray = new byte[busHighMemorySize];
8547:
8548: busHimem68000 = Settings.sgsGetOnOff ("himem68000");
8549:
8550: busHighMemorySaveOn = Settings.sgsGetOnOff ("highmemorysave");
8551: busHighMemory060turboOn = Settings.sgsGetOnOff ("highmemory060turbo");
8552:
8553: byte[] highMemoryArray = Settings.sgsGetData ("highmemorydata");
8554: if (busHighMemorySize != 0) {
8555: if (highMemoryArray.length != 0) {
8556: System.out.println (Multilingual.mlnJapanese ?
8557: "X68030/Xellent30 のハイメモリのデータを復元します" :
8558: "X68030/Xellent30 high memory data is restored");
8559: System.arraycopy (highMemoryArray, 0, busHighMemoryArray, 0, Math.min (highMemoryArray.length, busHighMemorySize));
8560: } else {
8561: System.out.println (Multilingual.mlnJapanese ?
8562: "X68030/Xellent30 のハイメモリをゼロクリアします" :
8563: "X68030/Xellent30 high memory is zero-cleared");
8564: }
8565: if (highMemoryArray.length < busHighMemorySize) {
8566: Arrays.fill (busHighMemoryArray, highMemoryArray.length, busHighMemorySize, (byte) 0);
8567: }
8568: }
8569:
8570:
8571: int localMemorySizeMB = Settings.sgsGetInt ("localmemory");
8572: busLocalMemorySize = (localMemorySizeMB == 16 ||
8573: localMemorySizeMB == 32 ||
8574: localMemorySizeMB == 64 ||
8575: localMemorySizeMB == 128 ||
8576: localMemorySizeMB == 256 ||
8577: localMemorySizeMB == 384 ||
8578: localMemorySizeMB == 512 ||
8579: localMemorySizeMB == 768 ?
8580: localMemorySizeMB << 20 :
8581: 128 << 20);
8582: if (busLocalMemorySize == 0) {
8583: System.out.println (Multilingual.mlnJapanese ?
8584: "060turbo のハイメモリはありません" :
8585: "060turbo high memory does not exists");
8586: } else {
8587: System.out.printf (Multilingual.mlnJapanese ?
8588: "060turbo のハイメモリのサイズは %dMB です\n" :
8589: "060turbo high memory size is %dMB\n",
8590: busLocalMemorySize >> 20);
8591: }
8592: busLocalMemoryArray = new byte[busLocalMemorySize];
8593:
8594: busLocalMemorySaveOn = Settings.sgsGetOnOff ("localmemorysave");
8595:
8596: byte[] localMemoryArray = Settings.sgsGetData ("localmemorydata");
8597: if (busLocalMemorySize != 0) {
8598: if (localMemoryArray.length != 0) {
8599: System.out.println (Multilingual.mlnJapanese ?
8600: "060turbo のハイメモリのデータを復元します" :
8601: "060turbo high memory data is restored");
8602: System.arraycopy (localMemoryArray, 0, busLocalMemoryArray, 0, Math.min (localMemoryArray.length, busLocalMemorySize));
8603: } else {
8604: System.out.println (Multilingual.mlnJapanese ?
8605: "060turbo のハイメモリをゼロクリアします" :
8606: "060turbo high memory is zero-cleared");
8607: }
8608: if (localMemoryArray.length < busLocalMemorySize) {
8609: Arrays.fill (busLocalMemoryArray, localMemoryArray.length, busLocalMemorySize, (byte) 0);
8610: }
8611: }
8612:
8613:
8614: busExMemoryStart = busRequestExMemoryStart = 0x10000000;
8615: busExMemorySize = busRequestExMemorySize = 0 << 20;
8616: busExMemoryArray = busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
8617:
8618:
8619: busRequestCutFC2Pin = Settings.sgsGetOnOff ("cutfc2pin");
8620: busCutFC2Pin = !busRequestCutFC2Pin;
8621:
8622: busUpdateMemoryMap ();
8623:
8624: }
8625:
8626:
8627:
8628: public static void busTini () {
8629: Settings.sgsPutOnOff ("himem68000", busHimem68000);
8630: Settings.sgsPutInt ("highmemory", busHighMemorySize >>> 20);
8631: Settings.sgsPutOnOff ("highmemorysave", busHighMemorySaveOn);
8632: Settings.sgsPutOnOff ("highmemory060turbo", busHighMemory060turboOn);
8633: Settings.sgsPutData ("highmemorydata", busHighMemorySaveOn ? busHighMemoryArray : new byte[0]);
8634: Settings.sgsPutInt ("localmemory", busLocalMemorySize >>> 20);
8635: Settings.sgsPutOnOff ("localmemorysave", busLocalMemorySaveOn);
8636: Settings.sgsPutData ("localmemorydata", busLocalMemorySaveOn ? busLocalMemoryArray : new byte[0]);
8637: Settings.sgsPutOnOff ("cutfc2pin", busRequestCutFC2Pin);
8638: }
8639:
8640: public static void busUpdateMemoryMap () {
8641: if (busExMemoryStart == busRequestExMemoryStart &&
8642: busExMemorySize == busRequestExMemorySize &&
8643: busExMemoryArray == busRequestExMemoryArray &&
8644: busExMemoryArray.length == busExMemorySize &&
8645: busCutFC2Pin == busRequestCutFC2Pin) {
8646: return;
8647: }
8648:
8649: busExMemoryStart = busRequestExMemoryStart;
8650: busExMemorySize = busRequestExMemorySize;
8651: busExMemoryArray = busRequestExMemoryArray;
8652: if (busExMemoryArray.length != busExMemorySize) {
8653: byte[] newArray = new byte[busExMemorySize];
8654: int copySize = Math.min (busExMemoryArray.length, busExMemorySize);
8655: if (copySize > 0) {
8656: System.arraycopy (busExMemoryArray, 0, newArray, 0, copySize);
8657: }
8658: if (busExMemoryArray == busHighMemoryArray) {
8659: busHighMemoryArray = newArray;
8660: } else if (busExMemoryArray == busLocalMemoryArray) {
8661: busLocalMemoryArray = newArray;
8662: }
8663: busExMemoryArray = newArray;
8664: }
8665:
8666: busCutFC2Pin = busRequestCutFC2Pin;
8667:
8668:
8669:
8670:
8671:
8672:
8673:
8674:
8675:
8676:
8677:
8678:
8679: busSuper (MemoryMappedDevice.MMD_MMR, 0x00000000, 0x00002000);
8680: busUser ( MemoryMappedDevice.MMD_MMR, 0x00002000, 0x00c00000);
8681:
8682:
8683:
8684:
8685:
8686:
8687:
8688:
8689:
8690:
8691:
8692:
8693:
8694:
8695:
8696:
8697:
8698:
8699:
8700:
8701:
8702:
8703:
8704:
8705: busSuper (MemoryMappedDevice.MMD_GE0, 0x00c00000, 0x00c80000);
8706: busSuper (MemoryMappedDevice.MMD_GE1, 0x00c80000, 0x00d00000);
8707: busSuper (MemoryMappedDevice.MMD_GE2, 0x00d00000, 0x00d80000);
8708: busSuper (MemoryMappedDevice.MMD_GE3, 0x00d80000, 0x00e00000);
8709:
8710:
8711:
8712:
8713: busSuper (MemoryMappedDevice.MMD_TXT, 0x00e00000, 0x00e80000);
8714:
8715:
8716:
8717:
8718: busSuper (MemoryMappedDevice.MMD_CRT, 0x00e80000, 0x00e82000);
8719:
8720:
8721:
8722:
8723:
8724: busSuper (MemoryMappedDevice.MMD_VCN, 0x00e82000, 0x00e84000);
8725:
8726:
8727:
8728:
8729: busSuper (MemoryMappedDevice.MMD_DMA, 0x00e84000, 0x00e86000);
8730:
8731:
8732:
8733:
8734: busSuper (MemoryMappedDevice.MMD_SVS, 0x00e86000, 0x00e88000);
8735:
8736:
8737:
8738:
8739: busSuper (MemoryMappedDevice.MMD_MFP, 0x00e88000, 0x00e8a000);
8740:
8741:
8742:
8743:
8744: busSuper (MemoryMappedDevice.MMD_RTC_FIRST, 0x00e8a000, 0x00e8c000);
8745:
8746:
8747:
8748:
8749: busSuper (MemoryMappedDevice.MMD_PRN, 0x00e8c000, 0x00e8e000);
8750:
8751:
8752:
8753:
8754: busSuper (MemoryMappedDevice.MMD_SYS, 0x00e8e000, 0x00e90000);
8755:
8756:
8757:
8758:
8759: busSuper (MemoryMappedDevice.MMD_OPM, 0x00e90000, 0x00e92000);
8760:
8761:
8762:
8763:
8764: busSuper (MemoryMappedDevice.MMD_PCM, 0x00e92000, 0x00e94000);
8765:
8766:
8767:
8768:
8769: busSuper (MemoryMappedDevice.MMD_FDC, 0x00e94000, 0x00e96000);
8770:
8771:
8772:
8773:
8774:
8775: busSuper (MemoryMappedDevice.MMD_HDC, 0x00e96000, 0x00e98000);
8776:
8777:
8778:
8779:
8780: busSuper (MemoryMappedDevice.MMD_SCC, 0x00e98000, 0x00e9a000);
8781:
8782:
8783:
8784:
8785: busSuper (MemoryMappedDevice.MMD_PPI, 0x00e9a000, 0x00e9c000);
8786:
8787:
8788:
8789:
8790: busSuper (MemoryMappedDevice.MMD_IOI, 0x00e9c000, 0x00e9e000);
8791:
8792:
8793:
8794:
8795:
8796:
8797:
8798:
8799:
8800: busSuper (MemoryMappedDevice.MMD_XB1, 0x00e9e000, 0x00ea0000);
8801:
8802:
8803:
8804:
8805:
8806: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ea0000, 0x00eae000);
8807:
8808:
8809:
8810:
8811:
8812:
8813:
8814:
8815:
8816:
8817:
8818:
8819:
8820:
8821:
8822: busSuper (MemoryMappedDevice.MMD_XB2, 0x00eae000, 0x00eb0000);
8823:
8824:
8825:
8826:
8827:
8828:
8829:
8830:
8831: busSuper (MemoryMappedDevice.MMD_SPR, 0x00eb0000, 0x00ec0000);
8832:
8833:
8834:
8835:
8836:
8837:
8838:
8839:
8840:
8841:
8842:
8843:
8844:
8845: busSuper (MemoryMappedDevice.MMD_XB3, 0x00ec0000, 0x00ed0000);
8846:
8847:
8848:
8849:
8850:
8851:
8852: busSuper (MemoryMappedDevice.MMD_SMR, 0x00ed0000, 0x00ed0000 + 16384);
8853: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ed0000 + 16384, 0x00ed0000 + 65536);
8854:
8855:
8856:
8857:
8858:
8859:
8860:
8861:
8862: busSuper (MemoryMappedDevice.MMD_XB4, 0x00ee0000, 0x00f00000);
8863:
8864:
8865:
8866:
8867:
8868:
8869:
8870:
8871:
8872:
8873: busSuper (MemoryMappedDevice.MMD_ROM, 0x00f00000, 0x00f40000);
8874:
8875:
8876:
8877:
8878:
8879:
8880:
8881: busSuper (MemoryMappedDevice.MMD_ROM, 0x00f40000, 0x00fc0000);
8882:
8883:
8884:
8885:
8886:
8887:
8888:
8889:
8890:
8891:
8892:
8893:
8894:
8895:
8896: busSuper (MemoryMappedDevice.MMD_ROM, 0x00fc0000, 0x01000000);
8897:
8898: }
8899:
8900: public static void busReset () {
8901: if (regSRS != 0) {
8902: if (DataBreakPoint.DBP_ON) {
8903: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpSuperMap;
8904: } else {
8905: busMemoryMap = busSuperMap;
8906: }
8907: } else {
8908: if (DataBreakPoint.DBP_ON) {
8909: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpUserMap;
8910: } else {
8911: busMemoryMap = busUserMap;
8912: }
8913: }
8914: }
8915:
8916:
8917:
8918:
8919:
8920: public static void busUser (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8921: if (MC68060.CAT_ON) {
8922: if (Model.MPU_MC68LC060 <= currentMPU) {
8923: mmd = (mmd == MemoryMappedDevice.MMD_MMR ? MemoryMappedDevice.MMD_MM6 :
8924: mmd == MemoryMappedDevice.MMD_ROM ? MemoryMappedDevice.MMD_RO6 :
8925: mmd);
8926: }
8927: }
8928: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8929: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8930: if (false &&
8931: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8932: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8933: System.out.printf ("ERROR: busUser (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8934: }
8935: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8936: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8937: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8938: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8939: int startPage = blockStartPage + motherStartPage;
8940: int endPage = blockStartPage + motherEndPage;
8941: for (int page = startPage; page < endPage; page++) {
8942: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
8943: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
8944: if (MC68060.CAT_ON) {
8945: if (Model.MPU_MC68LC060 <= currentMPU &&
8946: isExMemory) {
8947: superMmd = MemoryMappedDevice.MMD_XM6;
8948: }
8949: }
8950: busUserMap[page] = busSuperMap[page] = superMmd;
8951: if (InstructionBreakPoint.IBP_ON) {
8952: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8953: InstructionBreakPoint.ibpUserMap[page] = superMmd;
8954: }
8955: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8956: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8957: }
8958: }
8959: if (DataBreakPoint.DBP_ON) {
8960: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8961: DataBreakPoint.dbpUserMap[page] = superMmd;
8962: }
8963: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8964: DataBreakPoint.dbpSuperMap[page] = superMmd;
8965: }
8966: }
8967: }
8968: }
8969: }
8970:
8971:
8972:
8973:
8974:
8975: public static void busSuper (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8976: if (MC68060.CAT_ON) {
8977: if (Model.MPU_MC68LC060 <= currentMPU) {
8978: mmd = (mmd == MemoryMappedDevice.MMD_MMR ? MemoryMappedDevice.MMD_MM6 :
8979: mmd == MemoryMappedDevice.MMD_ROM ? MemoryMappedDevice.MMD_RO6 :
8980: mmd);
8981: }
8982: }
8983: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8984: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8985: if (false &&
8986: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8987: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8988: System.out.printf ("ERROR: busSuper (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8989: }
8990: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8991: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8992: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8993: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8994: int startPage = blockStartPage + motherStartPage;
8995: int endPage = blockStartPage + motherEndPage;
8996: for (int page = startPage; page < endPage; page++) {
8997: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
8998: MemoryMappedDevice userMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : busCutFC2Pin ? mmd : MemoryMappedDevice.MMD_NUL;
8999: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
9000: if (MC68060.CAT_ON) {
9001: if (Model.MPU_MC68LC060 <= currentMPU &&
9002: isExMemory) {
9003: userMmd = MemoryMappedDevice.MMD_XM6;
9004: superMmd = MemoryMappedDevice.MMD_XM6;
9005: }
9006: }
9007: busUserMap[page] = userMmd;
9008: busSuperMap[page] = superMmd;
9009: if (InstructionBreakPoint.IBP_ON) {
9010: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
9011: InstructionBreakPoint.ibpUserMap[page] = userMmd;
9012: }
9013: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
9014: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
9015: }
9016: }
9017: if (DataBreakPoint.DBP_ON) {
9018: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
9019: DataBreakPoint.dbpUserMap[page] = userMmd;
9020: }
9021: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
9022: DataBreakPoint.dbpSuperMap[page] = superMmd;
9023: }
9024: }
9025: }
9026: }
9027: }
9028:
9029:
9030:
9031: public static byte busPbs (int a) {
9032: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a);
9033: }
9034:
9035:
9036:
9037: public static int busPbz (int a) {
9038: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a);
9039: }
9040:
9041:
9042:
9043: public static int busPws (int a) {
9044: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9045: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
9046: } else {
9047: int a1 = a + 1;
9048: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
9049: }
9050: }
9051:
9052:
9053:
9054: public static int busPwse (int a) {
9055: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
9056: }
9057:
9058:
9059:
9060: public static int busPwz (int a) {
9061: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9062: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
9063: } else {
9064: int a1 = a + 1;
9065: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
9066: }
9067: }
9068:
9069:
9070:
9071: public static int busPwze (int a) {
9072: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
9073: }
9074:
9075:
9076:
9077: public static int busPls (int a) {
9078: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9079: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
9080: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9081: int a2 = a + 2;
9082: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a) << 16 | busSuperMap[a2 >>> BUS_PAGE_BITS].mmdPwz (a2);
9083: } else {
9084: int a1 = a + 1;
9085: int a3 = a + 3;
9086: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 24 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPwz (a1) << 8 | busSuperMap[a3 >>> BUS_PAGE_BITS].mmdPbz (a3);
9087: }
9088: }
9089:
9090:
9091:
9092: public static int busPlsf (int a) {
9093: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
9094: }
9095:
9096:
9097:
9098: public static long busPqs (int a) {
9099: return (long) busPls (a) << 32 | busPls (a + 4) & 0xffffffffL;
9100: }
9101:
9102:
9103:
9104: public static int busSearchByte (int start, int end, int c) {
9105: for (int a = start; a < end; a++) {
9106: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) == c) {
9107: return a;
9108: }
9109: }
9110: return -1;
9111: }
9112: public static int busSearchWord (int start, int end, int c) {
9113: for (int a = start; a < end; a += 2) {
9114: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) == c) {
9115: return a;
9116: }
9117: }
9118: return -1;
9119: }
9120: public static int busSearchByteArray (int start, int end, int[] array) {
9121: int l = array.length;
9122: end -= l;
9123: int c = array[0];
9124: a:
9125: for (int a = start; a <= end; a++) {
9126: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) != c) {
9127: continue a;
9128: }
9129: for (int i = 1, b = a + 1; i < l; i++, b++) {
9130: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPbz (b) != array[i]) {
9131: continue a;
9132: }
9133: }
9134: return a;
9135: }
9136: return -1;
9137: }
9138: public static int busSearchWordArray (int start, int end, int[] array) {
9139: int l = array.length;
9140: end -= l;
9141: int c = array[0];
9142: a:
9143: for (int a = start; a <= end; a += 2) {
9144: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) != c) {
9145: continue a;
9146: }
9147: for (int i = 1, b = a + 2; i < l; i++, b += 2) {
9148: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPwz (b) != array[i]) {
9149: continue a;
9150: }
9151: }
9152: return a;
9153: }
9154: return -1;
9155: }
9156:
9157:
9158:
9159:
9160: public static byte busRbs (int a) throws M68kException {
9161: if (DataBreakPoint.DBP_ON) {
9162: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
9163: } else {
9164: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
9165: }
9166: }
9167:
9168:
9169:
9170: public static int busRbz (int a) throws M68kException {
9171: if (DataBreakPoint.DBP_ON) {
9172: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
9173: } else {
9174: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
9175: }
9176: }
9177:
9178:
9179:
9180: public static int busRws (int a) throws M68kException {
9181: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9182: if (DataBreakPoint.DBP_ON) {
9183: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
9184: } else {
9185: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
9186: }
9187: } else if (mpuIgnoreAddressError) {
9188: int a1 = a + 1;
9189: if (DataBreakPoint.DBP_ON) {
9190: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
9191: } else {
9192: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
9193: }
9194: } else {
9195: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9196: M68kException.m6eAddress = a;
9197: M68kException.m6eDirection = MPU_WR_READ;
9198: M68kException.m6eSize = MPU_SS_WORD;
9199: throw M68kException.m6eSignal;
9200: }
9201: }
9202:
9203:
9204:
9205:
9206: public static int busRwse (int a) throws M68kException {
9207: if (DataBreakPoint.DBP_ON) {
9208: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
9209: } else {
9210: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
9211: }
9212: }
9213:
9214:
9215:
9216: public static int busRwz (int a) throws M68kException {
9217: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9218: if (DataBreakPoint.DBP_ON) {
9219: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9220: } else {
9221: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9222: }
9223: } else if (mpuIgnoreAddressError) {
9224: int a1 = a + 1;
9225: if (DataBreakPoint.DBP_ON) {
9226: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
9227: } else {
9228: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
9229: }
9230: } else {
9231: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9232: M68kException.m6eAddress = a;
9233: M68kException.m6eDirection = MPU_WR_READ;
9234: M68kException.m6eSize = MPU_SS_WORD;
9235: throw M68kException.m6eSignal;
9236: }
9237: }
9238:
9239:
9240:
9241:
9242: public static int busRwze (int a) throws M68kException {
9243: if (DataBreakPoint.DBP_ON) {
9244: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9245: } else {
9246: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9247: }
9248: }
9249:
9250:
9251:
9252: public static int busRls (int a) throws M68kException {
9253: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9254: if (DataBreakPoint.DBP_ON) {
9255: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9256: } else {
9257: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9258: }
9259: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9260: int a2 = a + 2;
9261: if (BUS_SPLIT_UNALIGNED_LONG) {
9262: if (DataBreakPoint.DBP_ON) {
9263: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9264: } else {
9265: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9266: }
9267: } else {
9268: MemoryMappedDevice mmd;
9269: MemoryMappedDevice mmd2;
9270: if (DataBreakPoint.DBP_ON) {
9271: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9272: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9273: } else {
9274: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9275: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9276: }
9277: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
9278: }
9279: } else if (mpuIgnoreAddressError) {
9280: int a1 = a + 1;
9281: int a3 = a + 3;
9282: if (DataBreakPoint.DBP_ON) {
9283: 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);
9284: } else {
9285: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 24 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRwz (a1) << 8 | busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdRbz (a3);
9286: }
9287: } else {
9288: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9289: M68kException.m6eAddress = a;
9290: M68kException.m6eDirection = MPU_WR_READ;
9291: M68kException.m6eSize = MPU_SS_LONG;
9292: throw M68kException.m6eSignal;
9293: }
9294: }
9295:
9296:
9297:
9298:
9299: public static int busRlse (int a) throws M68kException {
9300: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9301: if (DataBreakPoint.DBP_ON) {
9302: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9303: } else {
9304: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9305: }
9306: } else {
9307: int a2 = a + 2;
9308: if (BUS_SPLIT_UNALIGNED_LONG) {
9309: if (DataBreakPoint.DBP_ON) {
9310: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9311: } else {
9312: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9313: }
9314: } else {
9315: MemoryMappedDevice mmd;
9316: MemoryMappedDevice mmd2;
9317: if (DataBreakPoint.DBP_ON) {
9318: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9319: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9320: } else {
9321: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9322: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9323: }
9324: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
9325: }
9326: }
9327: }
9328:
9329:
9330:
9331:
9332: public static int busRlsf (int a) throws M68kException {
9333: if (DataBreakPoint.DBP_ON) {
9334: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9335: } else {
9336: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9337: }
9338: }
9339:
9340:
9341:
9342: public static long busRqs (int a) throws M68kException {
9343: return (long) busRls (a) << 32 | busRls (a + 4) & 0xffffffffL;
9344: }
9345:
9346:
9347:
9348: public static void busWb (int a, int d) throws M68kException {
9349: if (DataBreakPoint.DBP_ON) {
9350: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9351: } else {
9352: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9353: }
9354: }
9355:
9356:
9357:
9358: public static void busWw (int a, int d) throws M68kException {
9359: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9360: if (DataBreakPoint.DBP_ON) {
9361: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9362: } else {
9363: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9364: }
9365: } else if (mpuIgnoreAddressError) {
9366: int a1 = a + 1;
9367: if (DataBreakPoint.DBP_ON) {
9368: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
9369: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
9370: } else {
9371: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
9372: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
9373: }
9374: } else {
9375: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9376: M68kException.m6eAddress = a;
9377: M68kException.m6eDirection = MPU_WR_WRITE;
9378: M68kException.m6eSize = MPU_SS_WORD;
9379: throw M68kException.m6eSignal;
9380: }
9381: }
9382:
9383:
9384:
9385:
9386: public static void busWwe (int a, int d) throws M68kException {
9387: if (DataBreakPoint.DBP_ON) {
9388: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9389: } else {
9390: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9391: }
9392: }
9393:
9394:
9395:
9396: public static void busWl (int a, int d) throws M68kException {
9397: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9398: if (DataBreakPoint.DBP_ON) {
9399: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9400: } else {
9401: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9402: }
9403: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9404: int a2 = a + 2;
9405: if (BUS_SPLIT_UNALIGNED_LONG) {
9406: if (DataBreakPoint.DBP_ON) {
9407: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9408: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9409: } else {
9410: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9411: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9412: }
9413: } else {
9414: MemoryMappedDevice mmd;
9415: MemoryMappedDevice mmd2;
9416: if (DataBreakPoint.DBP_ON) {
9417: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9418: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9419: } else {
9420: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9421: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9422: }
9423: if (mmd == mmd2) {
9424: mmd.mmdWl (a, d);
9425: } else {
9426: mmd.mmdWw (a, d >> 16);
9427: mmd2.mmdWw (a2, d);
9428: }
9429: }
9430: } else if (mpuIgnoreAddressError) {
9431: int a1 = a + 1;
9432: int a3 = a + 3;
9433: if (DataBreakPoint.DBP_ON) {
9434: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
9435: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
9436: DataBreakPoint.dbpMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
9437: } else {
9438: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
9439: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
9440: busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
9441: }
9442: } else {
9443: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9444: M68kException.m6eAddress = a;
9445: M68kException.m6eDirection = MPU_WR_WRITE;
9446: M68kException.m6eSize = MPU_SS_LONG;
9447: throw M68kException.m6eSignal;
9448: }
9449: }
9450:
9451:
9452:
9453:
9454: public static void busWlf (int a, int d) throws M68kException {
9455: if (DataBreakPoint.DBP_ON) {
9456: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9457: } else {
9458: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9459: }
9460: }
9461:
9462:
9463:
9464:
9465: public static void busWle (int a, int d) throws M68kException {
9466: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9467: if (DataBreakPoint.DBP_ON) {
9468: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9469: } else {
9470: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9471: }
9472: } else {
9473: int a2 = a + 2;
9474: if (BUS_SPLIT_UNALIGNED_LONG) {
9475: if (DataBreakPoint.DBP_ON) {
9476: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9477: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9478: } else {
9479: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9480: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9481: }
9482: } else {
9483: MemoryMappedDevice mmd;
9484: MemoryMappedDevice mmd2;
9485: if (DataBreakPoint.DBP_ON) {
9486: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9487: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9488: } else {
9489: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9490: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9491: }
9492: if (mmd == mmd2) {
9493: mmd.mmdWl (a, d);
9494: } else {
9495: mmd.mmdWw (a, d >> 16);
9496: mmd2.mmdWw (a2, d);
9497: }
9498: }
9499: }
9500: }
9501:
9502:
9503:
9504: public static void busWq (int a, long d) throws M68kException {
9505: busWl (a, (int) (d >>> 32));
9506: busWl (a + 4, (int) d);
9507: }
9508:
9509:
9510:
9511:
9512:
9513: public static void busRbb (int a, byte[] bb, int o, int l) throws M68kException {
9514: if (false) {
9515: for (int i = 0; i < l; i++) {
9516: int ai = a + i;
9517: if (DataBreakPoint.DBP_ON) {
9518: bb[o + i] = DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9519: } else {
9520: bb[o + i] = busMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9521: }
9522: }
9523: } else {
9524: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9525: while (l > 0) {
9526: MemoryMappedDevice mmd;
9527: if (DataBreakPoint.DBP_ON) {
9528: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9529: } else {
9530: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9531: }
9532: int s = l <= r ? l : r;
9533: l -= s;
9534: if (true) {
9535: for (s -= 16; s >= 0; s -= 16) {
9536: bb[o ] = mmd.mmdRbs (a );
9537: bb[o + 1] = mmd.mmdRbs (a + 1);
9538: bb[o + 2] = mmd.mmdRbs (a + 2);
9539: bb[o + 3] = mmd.mmdRbs (a + 3);
9540: bb[o + 4] = mmd.mmdRbs (a + 4);
9541: bb[o + 5] = mmd.mmdRbs (a + 5);
9542: bb[o + 6] = mmd.mmdRbs (a + 6);
9543: bb[o + 7] = mmd.mmdRbs (a + 7);
9544: bb[o + 8] = mmd.mmdRbs (a + 8);
9545: bb[o + 9] = mmd.mmdRbs (a + 9);
9546: bb[o + 10] = mmd.mmdRbs (a + 10);
9547: bb[o + 11] = mmd.mmdRbs (a + 11);
9548: bb[o + 12] = mmd.mmdRbs (a + 12);
9549: bb[o + 13] = mmd.mmdRbs (a + 13);
9550: bb[o + 14] = mmd.mmdRbs (a + 14);
9551: bb[o + 15] = mmd.mmdRbs (a + 15);
9552: a += 16;
9553: o += 16;
9554: }
9555: s += 16;
9556: }
9557: for (int i = 0; i < s; i++) {
9558: bb[o + i] = mmd.mmdRbs (a + i);
9559: }
9560: a += s;
9561: o += s;
9562: r = BUS_PAGE_SIZE;
9563: }
9564: }
9565: }
9566:
9567:
9568:
9569: public static void busWbb (int a, byte[] bb, int o, int l) throws M68kException {
9570: if (false) {
9571: for (int i = 0; i < l; i++) {
9572: int ai = a + i;
9573: if (DataBreakPoint.DBP_ON) {
9574: DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9575: } else {
9576: busMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9577: }
9578: }
9579: } else {
9580: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9581: while (l > 0) {
9582: MemoryMappedDevice mmd;
9583: if (DataBreakPoint.DBP_ON) {
9584: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9585: } else {
9586: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9587: }
9588: int s = l <= r ? l : r;
9589: l -= s;
9590: if (true) {
9591: for (s -= 16; s >= 0; s -= 16) {
9592: mmd.mmdWb (a , bb[o ]);
9593: mmd.mmdWb (a + 1, bb[o + 1]);
9594: mmd.mmdWb (a + 2, bb[o + 2]);
9595: mmd.mmdWb (a + 3, bb[o + 3]);
9596: mmd.mmdWb (a + 4, bb[o + 4]);
9597: mmd.mmdWb (a + 5, bb[o + 5]);
9598: mmd.mmdWb (a + 6, bb[o + 6]);
9599: mmd.mmdWb (a + 7, bb[o + 7]);
9600: mmd.mmdWb (a + 8, bb[o + 8]);
9601: mmd.mmdWb (a + 9, bb[o + 9]);
9602: mmd.mmdWb (a + 10, bb[o + 10]);
9603: mmd.mmdWb (a + 11, bb[o + 11]);
9604: mmd.mmdWb (a + 12, bb[o + 12]);
9605: mmd.mmdWb (a + 13, bb[o + 13]);
9606: mmd.mmdWb (a + 14, bb[o + 14]);
9607: mmd.mmdWb (a + 15, bb[o + 15]);
9608: a += 16;
9609: o += 16;
9610: }
9611: s += 16;
9612: }
9613: for (int i = 0; i < s; i++) {
9614: mmd.mmdWb (a + i, bb[o + i]);
9615: }
9616: a += s;
9617: o += s;
9618: r = BUS_PAGE_SIZE;
9619: }
9620: }
9621: }
9622:
9623:
9624:
9625: public static void busVb (int a, int d) {
9626: try {
9627: if (DataBreakPoint.DBP_ON) {
9628: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9629: } else {
9630: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9631: }
9632: } catch (M68kException e) {
9633: }
9634: }
9635:
9636:
9637:
9638: public static void busVw (int a, int d) {
9639: try {
9640: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9641: if (DataBreakPoint.DBP_ON) {
9642: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9643: } else {
9644: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9645: }
9646: }
9647: } catch (M68kException e) {
9648: }
9649: }
9650:
9651:
9652:
9653: public static void busVl (int a, int d) {
9654: try {
9655: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9656: if (DataBreakPoint.DBP_ON) {
9657: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9658: } else {
9659: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9660: }
9661: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9662: int a2 = a + 2;
9663: MemoryMappedDevice mmd;
9664: MemoryMappedDevice mmd2;
9665: if (DataBreakPoint.DBP_ON) {
9666: mmd = (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS];
9667: mmd2 = (regSRS != 0 ? busSuperMap : busUserMap)[a2 >>> BUS_PAGE_BITS];
9668: } else {
9669: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9670: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9671: }
9672: if (mmd == mmd2) {
9673: mmd.mmdWl (a, d);
9674: } else {
9675: mmd.mmdWw (a, d >> 16);
9676: mmd2.mmdWw (a2, d);
9677: }
9678: }
9679: } catch (M68kException e) {
9680: }
9681: }
9682:
9683:
9684:
9685:
9686:
9687: public static final int SVS_AREASET = 0x00e86001;
9688:
9689:
9690:
9691:
9692:
9693:
9694:
9695:
9696:
9697: public static void svsInit () {
9698: }
9699:
9700:
9701:
9702:
9703:
9704:
9705:
9706:
9707:
9708:
9709:
9710:
9711:
9712:
9713:
9714:
9715:
9716:
9717:
9718:
9719:
9720:
9721:
9722:
9723:
9724:
9725:
9726:
9727:
9728:
9729:
9730:
9731:
9732:
9733:
9734: public static boolean sysNMIFlag;
9735:
9736:
9737:
9738: public static void sysInit () {
9739: sysNMIFlag = false;
9740: }
9741:
9742:
9743:
9744:
9745:
9746:
9747: public static int sysAcknowledge () {
9748: return M68kException.M6E_LEVEL_7_INTERRUPT_AUTOVECTOR;
9749: }
9750:
9751:
9752:
9753:
9754: public static void sysDone () {
9755: if (sysNMIFlag) {
9756: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9757: }
9758: }
9759:
9760:
9761:
9762: public static void sysInterrupt () {
9763: sysNMIFlag = true;
9764: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9765: }
9766:
9767:
9768:
9769: public static void sysResetNMI () {
9770: sysNMIFlag = false;
9771: }
9772:
9773:
9774:
9775:
9776:
9777:
9778: public static final int EB2_SPC_REQUEST = 0x4000;
9779: public static final int EB2_SPC_VECTOR = 0xf6;
9780:
9781:
9782:
9783: public static int eb2Request;
9784:
9785:
9786:
9787: public static void eb2Reset () {
9788: eb2Request = 0;
9789: }
9790:
9791:
9792:
9793:
9794:
9795: public static void eb2Interrupt (int mask) {
9796: eb2Request |= mask;
9797: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9798: }
9799:
9800:
9801:
9802:
9803:
9804:
9805:
9806: public static int eb2Acknowledge () {
9807: if ((eb2Request & EB2_SPC_REQUEST) != 0) {
9808: eb2Request &= ~EB2_SPC_REQUEST;
9809: return EB2_SPC_VECTOR;
9810: }
9811: return 0;
9812: }
9813:
9814:
9815:
9816:
9817:
9818: public static void eb2Done () {
9819: if (eb2Request != 0) {
9820: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9821: }
9822: }
9823:
9824:
9825:
9826:
9827:
9828:
9829:
9830:
9831:
9832:
9833:
9834:
9835:
9836:
9837:
9838:
9839:
9840:
9841:
9842:
9843:
9844:
9845:
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: public static final int BNK_SIZE = 1024 * 1024 * 32;
9888: public static byte[] bnkMemory;
9889: public static int bnkPageStart;
9890: public static boolean bnkOn;
9891:
9892: public static void bnkInit () {
9893: bnkMemory = new byte[BNK_SIZE];
9894: byte[] array = Settings.sgsGetData ("bankdata");
9895: if (array.length != 0) {
9896: System.arraycopy (array, 0, bnkMemory, 0, Math.min (array.length, BNK_SIZE));
9897: }
9898: bnkPageStart = 0;
9899:
9900: bnkOn = false;
9901: }
9902:
9903: public static void bnkTini () {
9904: Settings.sgsPutData ("bankdata", bnkMemory, 0, BNK_SIZE);
9905: }
9906:
9907:
9908:
9909:
9910:
9911:
9912:
9913: public static ExpressionEvaluator fpuMotherboardCoprocessor;
9914: public static ExpressionEvaluator fpuOnChipFPU;
9915: public static ExpressionEvaluator fpuBox;
9916:
9917:
9918: public static EFPBox fpuCoproboard1;
9919: public static EFPBox fpuCoproboard2;
9920:
9921:
9922: public static EFPBox.EFP[] fpuFPn;
9923:
9924:
9925:
9926: public static final int FPU_FPCR_BSUN = 0b00000000_00000000_10000000_00000000;
9927: public static final int FPU_FPCR_SNAN = 0b00000000_00000000_01000000_00000000;
9928: public static final int FPU_FPCR_OPERR = 0b00000000_00000000_00100000_00000000;
9929: public static final int FPU_FPCR_OVFL = 0b00000000_00000000_00010000_00000000;
9930: public static final int FPU_FPCR_UNFL = 0b00000000_00000000_00001000_00000000;
9931: public static final int FPU_FPCR_DZ = 0b00000000_00000000_00000100_00000000;
9932: public static final int FPU_FPCR_INEX2 = 0b00000000_00000000_00000010_00000000;
9933: public static final int FPU_FPCR_INEX1 = 0b00000000_00000000_00000001_00000000;
9934:
9935:
9936: public static final int FPU_FPCR_PE = 0b00000000_00000000_00000000_00000000;
9937: public static final int FPU_FPCR_PS = 0b00000000_00000000_00000000_01000000;
9938: public static final int FPU_FPCR_PD = 0b00000000_00000000_00000000_10000000;
9939:
9940: public static final int FPU_FPCR_RN = 0b00000000_00000000_00000000_00000000;
9941: public static final int FPU_FPCR_RZ = 0b00000000_00000000_00000000_00010000;
9942: public static final int FPU_FPCR_RM = 0b00000000_00000000_00000000_00100000;
9943: public static final int FPU_FPCR_RP = 0b00000000_00000000_00000000_00110000;
9944:
9945:
9946:
9947: public static final int FPU_FPSR_N = 0b00001000_00000000_00000000_00000000;
9948: public static final int FPU_FPSR_Z = 0b00000100_00000000_00000000_00000000;
9949: public static final int FPU_FPSR_I = 0b00000010_00000000_00000000_00000000;
9950: public static final int FPU_FPSR_NAN = 0b00000001_00000000_00000000_00000000;
9951:
9952: public static final int FPU_FPSR_S = 0b00000000_10000000_00000000_00000000;
9953: public static final int FPU_FPSR_QUOTIENT = 0b00000000_01111111_00000000_00000000;
9954:
9955: public static final int FPU_FPSR_EXC_BSUN = 0b00000000_00000000_10000000_00000000;
9956: public static final int FPU_FPSR_EXC_SNAN = 0b00000000_00000000_01000000_00000000;
9957: public static final int FPU_FPSR_EXC_OPERR = 0b00000000_00000000_00100000_00000000;
9958: public static final int FPU_FPSR_EXC_OVFL = 0b00000000_00000000_00010000_00000000;
9959: public static final int FPU_FPSR_EXC_UNFL = 0b00000000_00000000_00001000_00000000;
9960: public static final int FPU_FPSR_EXC_DZ = 0b00000000_00000000_00000100_00000000;
9961: public static final int FPU_FPSR_EXC_INEX2 = 0b00000000_00000000_00000010_00000000;
9962: public static final int FPU_FPSR_EXC_INEX1 = 0b00000000_00000000_00000001_00000000;
9963:
9964: public static final int FPU_FPSR_AEXC_IOP = 0b00000000_00000000_00000000_10000000;
9965: public static final int FPU_FPSR_AEXC_OVFL = 0b00000000_00000000_00000000_01000000;
9966: public static final int FPU_FPSR_AEXC_UNFL = 0b00000000_00000000_00000000_00100000;
9967: public static final int FPU_FPSR_AEXC_DZ = 0b00000000_00000000_00000000_00010000;
9968: public static final int FPU_FPSR_AEXC_INEX = 0b00000000_00000000_00000000_00001000;
9969:
9970:
9971:
9972:
9973:
9974:
9975:
9976: public static final int[] FPU_FPSR_EXC_TO_AEXC = new int[256];
9977:
9978:
9979:
9980:
9981:
9982:
9983:
9984:
9985:
9986:
9987:
9988:
9989:
9990:
9991:
9992:
9993:
9994:
9995:
9996:
9997:
9998:
9999:
10000:
10001: public static final boolean[] FPU_CCMAP_882 = {
10002:
10003:
10004: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10005: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10006: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10007: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10008: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10009: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10010: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10011: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
10012: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10013: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10014: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10015: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10016: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10017: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10018: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
10019: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10020:
10021:
10022: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10023: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10024: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10025: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10026: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10027: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10028: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10029: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
10030: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10031: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10032: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10033: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10034: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10035: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10036: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
10037: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10038:
10039: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10040: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10041: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10042: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10043: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10044: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10045: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10046: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
10047: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10048: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10049: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10050: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10051: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10052: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10053: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
10054: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10055:
10056: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10057: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10058: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10059: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10060: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10061: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10062: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10063: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
10064: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10065: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10066: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10067: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10068: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10069: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10070: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
10071: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10072: };
10073:
10074:
10075:
10076:
10077:
10078:
10079:
10080: public static final boolean[] FPU_CCMAP_060 = {
10081:
10082:
10083: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10084: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10085: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10086: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10087: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10088: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10089: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10090: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
10091: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10092: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10093: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10094: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10095: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10096: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10097: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
10098: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10099:
10100:
10101: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10102: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10103: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10104: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10105: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10106: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10107: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10108: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
10109: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10110: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10111: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10112: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10113: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10114: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10115: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
10116: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10117:
10118: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10119: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10120: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10121: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10122: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10123: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10124: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10125: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
10126: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10127: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10128: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10129: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10130: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10131: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10132: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
10133: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10134:
10135: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10136: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10137: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10138: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10139: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10140: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10141: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10142: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
10143: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10144: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10145: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10146: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10147: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10148: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10149: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
10150: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10151: };
10152:
10153:
10154:
10155:
10156: public static void fpuInit () {
10157: for (int i = 0; i < 256; i++) {
10158: 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) |
10159: ((i << 8 & FPU_FPSR_EXC_OVFL) != 0 ? FPU_FPSR_AEXC_OVFL : 0) |
10160: ((i << 8 & (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2)) == (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2) ? FPU_FPSR_AEXC_UNFL : 0) |
10161: ((i << 8 & FPU_FPSR_EXC_DZ) != 0 ? FPU_FPSR_AEXC_DZ : 0) |
10162: ((i << 8 & (FPU_FPSR_EXC_OVFL | FPU_FPSR_EXC_INEX2 | FPU_FPSR_EXC_INEX1)) != 0 ? FPU_FPSR_AEXC_INEX : 0));
10163: }
10164:
10165: fpuMotherboardCoprocessor = new ExpressionEvaluator ();
10166:
10167: fpuOnChipFPU = new ExpressionEvaluator ();
10168:
10169: fpuBox = currentMPU < Model.MPU_MC68LC040 ? fpuMotherboardCoprocessor : fpuOnChipFPU;
10170:
10171: fpuFPn = fpuBox.epbFPn;
10172:
10173: fpuCoproboard1 = new EFPBox ();
10174: fpuCoproboard2 = new EFPBox ();
10175: }
10176:
10177:
10178:
10179:
10180:
10181:
10182: public static final boolean DBG_ORI_BYTE_ZERO_D0 = true;
10183:
10184: public static boolean dbgHexSelected;
10185: public static int dbgHexValue;
10186: public static int dbgSupervisorMode;
10187: public static JPopupMenu dbgPopupMenu;
10188: public static JMenu dbgPopupIBPMenu;
10189: public static SpinnerNumberModel dbgPopupIBPCurrentModel;
10190: public static int dbgPopupIBPCurrentValue;
10191: public static SpinnerNumberModel dbgPopupIBPThresholdModel;
10192: public static int dbgPopupIBPThresholdValue;
10193: public static JMenuItem dbgPopupIBPClearMenuItem;
10194: public static JMenu dbgPopupHexMenu;
10195: public static JMenuItem dbgPopupDisMenuItem;
10196: public static JMenuItem dbgPopupMemMenuItem;
10197: public static JMenuItem dbgPopupCopyMenuItem;
10198: public static JMenuItem dbgPopupSelectAllMenuItem;
10199: public static JTextArea dbgPopupTextArea;
10200: public static int dbgEventMask;
10201: public static boolean dbgStopOnError;
10202: public static boolean dbgOriByteZeroD0;
10203: public static boolean dbgStopAtStart;
10204:
10205:
10206:
10207: public static final char[] DBG_SPACES = (
10208:
10209:
10210: " ").toCharArray ();
10211:
10212: public static final int DBG_DRP_VISIBLE_MASK = 1;
10213: public static final int DBG_DDP_VISIBLE_MASK = 2;
10214: public static final int DBG_DMP_VISIBLE_MASK = 4;
10215: public static final int DBG_BLG_VISIBLE_MASK = 8;
10216: public static final int DBG_PFV_VISIBLE_MASK = 16;
10217: public static final int DBG_RBP_VISIBLE_MASK = 32;
10218: public static final int DBG_DBP_VISIBLE_MASK = 64;
10219: public static final int DBG_SMT_VISIBLE_MASK = 128;
10220: public static final int DBG_ATW_VISIBLE_MASK = 256;
10221: public static final int DBG_PAA_VISIBLE_MASK = 512;
10222: public static final int DBG_RTL_VISIBLE_MASK = 1024;
10223: public static final int DBG_SPV_VISIBLE_MASK = 2048;
10224: public static final int DBG_PLV_VISIBLE_MASK = 4096;
10225: public static final int DBG_ACM_VISIBLE_MASK = 8192;
10226: public static int dbgVisibleMask;
10227:
10228:
10229:
10230: public static void dbgInit () {
10231: dbgVisibleMask = 0;
10232: dbgHexSelected = false;
10233: dbgHexValue = 0;
10234: dbgSupervisorMode = 1;
10235: dbgPopupMenu = null;
10236: dbgPopupDisMenuItem = null;
10237: dbgPopupMemMenuItem = null;
10238: dbgPopupCopyMenuItem = null;
10239: dbgPopupSelectAllMenuItem = null;
10240: dbgPopupIBPMenu = null;
10241: dbgPopupIBPCurrentModel = null;
10242: dbgPopupIBPCurrentValue = 0;
10243: dbgPopupIBPThresholdModel = null;
10244: dbgPopupIBPThresholdValue = 0;
10245: dbgPopupHexMenu = null;
10246: dbgPopupTextArea = null;
10247: dbgEventMask = 0;
10248: dbgStopOnError = false;
10249: if (DBG_ORI_BYTE_ZERO_D0) {
10250: dbgOriByteZeroD0 = false;
10251: }
10252: dbgStopAtStart = false;
10253: }
10254:
10255:
10256:
10257: public static void dbgMakePopup () {
10258:
10259:
10260: ActionListener popupActionListener = new ActionListener () {
10261: @Override public void actionPerformed (ActionEvent ae) {
10262: switch (ae.getActionCommand ()) {
10263: case "Disassemble":
10264: DisassembleList.ddpBacktraceRecord = -1L;
10265: DisassembleList.ddpOpen (dbgHexValue, dbgSupervisorMode, false);
10266: break;
10267: case "Memory Dump":
10268: MemoryDumpList.dmpOpen (dbgHexValue, dbgSupervisorMode != 0 ? 5 : 1, false);
10269: break;
10270: case "Run to Here":
10271: if (InstructionBreakPoint.IBP_ON) {
10272: if (mpuTask == null) {
10273: InstructionBreakPoint.ibpInstant (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
10274: mpuStart ();
10275: }
10276: }
10277: break;
10278: case "Set Breakpoint":
10279: if (InstructionBreakPoint.IBP_ON) {
10280: InstructionBreakPoint.ibpPut (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode, dbgPopupIBPCurrentValue, dbgPopupIBPThresholdValue, null);
10281: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
10282: }
10283: break;
10284: case "Clear Breakpoint":
10285: if (InstructionBreakPoint.IBP_ON) {
10286: InstructionBreakPoint.ibpRemove (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
10287: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
10288: }
10289: break;
10290: case "Copy":
10291: dbgCopy ();
10292: break;
10293: case "Select All":
10294: dbgSelectAll ();
10295: break;
10296: }
10297: }
10298: };
10299: dbgPopupMenu = ComponentFactory.createPopupMenu (
10300: dbgPopupIBPMenu =
10301: InstructionBreakPoint.IBP_ON ?
10302: ComponentFactory.createMenu (
10303: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
10304: Multilingual.mlnText (ComponentFactory.createMenuItem ("Run to Here", 'R', popupActionListener), "ja", "ここまで実行"),
10305: ComponentFactory.createHorizontalSeparator (),
10306: Multilingual.mlnText (ComponentFactory.createMenuItem ("Set Breakpoint", 'S', popupActionListener), "ja", "ブレークポイントを設定"),
10307: ComponentFactory.createHorizontalBox (
10308: Box.createHorizontalStrut (7),
10309: Box.createHorizontalGlue (),
10310: ComponentFactory.setPreferredSize (
10311: Multilingual.mlnText (ComponentFactory.createLabel ("current"), "ja", "現在値"),
10312: 60, 16),
10313: ComponentFactory.createNumberSpinner (dbgPopupIBPCurrentModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
10314: @Override public void stateChanged (ChangeEvent ce) {
10315: dbgPopupIBPCurrentValue = dbgPopupIBPCurrentModel.getNumber ().intValue ();
10316: }
10317: }),
10318: Box.createHorizontalGlue ()
10319: ),
10320: ComponentFactory.createHorizontalBox (
10321: Box.createHorizontalStrut (7),
10322: Box.createHorizontalGlue (),
10323: ComponentFactory.setPreferredSize (
10324: Multilingual.mlnText (ComponentFactory.createLabel ("threshold"), "ja", "閾値"),
10325: 60, 16),
10326: ComponentFactory.createNumberSpinner (dbgPopupIBPThresholdModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
10327: @Override public void stateChanged (ChangeEvent ce) {
10328: dbgPopupIBPThresholdValue = dbgPopupIBPThresholdModel.getNumber ().intValue ();
10329: }
10330: }),
10331: Box.createHorizontalGlue ()
10332: ),
10333: dbgPopupIBPClearMenuItem =
10334: Multilingual.mlnText (ComponentFactory.createMenuItem ("Clear Breakpoint", 'C', popupActionListener), "ja", "ブレークポイントを消去")
10335: ) :
10336: null,
10337: dbgPopupHexMenu =
10338: ComponentFactory.createMenu (
10339: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
10340: dbgPopupDisMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble", 'D', popupActionListener), "ja", "逆アセンブル"),
10341: dbgPopupMemMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory Dump", 'M', popupActionListener), "ja", "メモリダンプ")
10342: ),
10343: dbgPopupCopyMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Copy", 'C', popupActionListener), "ja", "コピー"),
10344: dbgPopupSelectAllMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Select All", 'A', popupActionListener), "ja", "すべて選択")
10345: );
10346:
10347: }
10348:
10349:
10350:
10351: public static void dbgShowPopup (MouseEvent me, JTextArea textArea, boolean dis) {
10352: dbgEventMask++;
10353: int x = me.getX ();
10354: int y = me.getY ();
10355:
10356: int p = textArea.viewToModel2D (me.getPoint ());
10357: DisassembleList.ddpPopupAddress = -1;
10358: if (dis) {
10359: int i = Arrays.binarySearch (DisassembleList.ddpSplitArray, 1, DisassembleList.ddpItemCount, p + 1);
10360: i = (i >> 31 ^ i) - 1;
10361: DisassembleList.ddpPopupAddress = DisassembleList.ddpAddressArray[i];
10362: }
10363: int start = textArea.getSelectionStart ();
10364: int end = textArea.getSelectionEnd ();
10365: String text = textArea.getText ();
10366: int length = text.length ();
10367: if ((start == end ||
10368: p < start || end <= p) &&
10369: 0 <= p && p < length && isWord (text.charAt (p))) {
10370:
10371: for (start = p; 0 < start && isWord (text.charAt (start - 1)); start--) {
10372: }
10373: for (end = p + 1; end < length && isWord (text.charAt (end)); end++) {
10374: }
10375: textArea.select (start, end);
10376: }
10377: dbgHexSelected = false;
10378: if (start < end) {
10379: textArea.requestFocusInWindow ();
10380:
10381:
10382:
10383:
10384:
10385: dbgHexValue = 0;
10386: int n = 0;
10387: for (int i = start; i < end; i++) {
10388: int t;
10389: if ((t = Character.digit (text.charAt (i), 16)) >= 0) {
10390: dbgHexValue = dbgHexValue << 4 | t;
10391: if (n >= 8 ||
10392: i + 1 >= end || (t = Character.digit (text.charAt (i + 1), 16)) < 0) {
10393: n = 0;
10394: break;
10395: }
10396: dbgHexValue = dbgHexValue << 4 | t;
10397: n += 2;
10398: i++;
10399: } else if (isWord (text.charAt (i))) {
10400: n = 0;
10401: break;
10402: }
10403: }
10404: dbgHexSelected = n > 0;
10405: try {
10406:
10407: Rectangle r = textArea.modelToView2D (start).getBounds ();
10408:
10409: Rectangle s = textArea.modelToView2D (end - 1).getBounds ();
10410: if (r.y == s.y) {
10411:
10412: y = r.y + r.height;
10413: }
10414: } catch (BadLocationException ble) {
10415: }
10416: }
10417:
10418: if (InstructionBreakPoint.IBP_ON) {
10419: if (dis && mpuTask == null && DisassembleList.ddpPopupAddress != -1) {
10420: ComponentFactory.setText (dbgPopupIBPMenu, fmtHex8 (DisassembleList.ddpPopupAddress));
10421: TreeMap<Integer,InstructionBreakPoint.InstructionBreakRecord> pointTable = InstructionBreakPoint.ibpPointTable;
10422: InstructionBreakPoint.InstructionBreakRecord r = pointTable.get (DisassembleList.ddpPopupAddress);
10423: if (r != null) {
10424: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = r.ibrValue));
10425: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = r.ibrThreshold));
10426: dbgPopupIBPClearMenuItem.setEnabled (true);
10427: } else {
10428: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = 0));
10429: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = 0));
10430: dbgPopupIBPClearMenuItem.setEnabled (false);
10431: }
10432: ComponentFactory.setVisible (dbgPopupIBPMenu, true);
10433: } else {
10434: ComponentFactory.setVisible (dbgPopupIBPMenu, false);
10435: }
10436: }
10437:
10438: if (dbgHexSelected) {
10439: ComponentFactory.setText (dbgPopupHexMenu, fmtHex8 (dbgHexValue));
10440: ComponentFactory.setVisible (dbgPopupHexMenu, true);
10441: } else {
10442: ComponentFactory.setVisible (dbgPopupHexMenu, false);
10443: }
10444:
10445: ComponentFactory.setEnabled (dbgPopupCopyMenuItem, clpClipboard != null && start < end);
10446:
10447: ComponentFactory.setEnabled (dbgPopupSelectAllMenuItem, clpClipboard != null);
10448:
10449: dbgPopupTextArea = textArea;
10450: dbgPopupMenu.show (textArea, x, y);
10451: dbgEventMask--;
10452: }
10453:
10454: public static boolean isWord (char c) {
10455: return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '_';
10456: }
10457:
10458:
10459:
10460: public static void dbgCopy () {
10461: clpCopy (dbgPopupTextArea.getSelectedText ());
10462: }
10463:
10464:
10465:
10466: public static void dbgSelectAll () {
10467: if (clpClipboard != null) {
10468:
10469: dbgEventMask++;
10470: dbgPopupTextArea.selectAll ();
10471: dbgPopupTextArea.requestFocusInWindow ();
10472: dbgEventMask--;
10473: }
10474: }
10475:
10476:
10477:
10478:
10479: public static void dbgUpdate () {
10480: if ((dbgVisibleMask & DBG_DRP_VISIBLE_MASK) != 0) {
10481: RegisterList.drpUpdate ();
10482: }
10483: if (ProgramFlowVisualizer.PFV_ON) {
10484: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
10485: if (ProgramFlowVisualizer.pfvTimer == 0) {
10486: ProgramFlowVisualizer.pfvUpdate ();
10487: } else {
10488: ProgramFlowVisualizer.pfvTimer--;
10489: }
10490: }
10491: }
10492: if (RasterBreakPoint.RBP_ON) {
10493: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
10494: if (RasterBreakPoint.rbpTimer == 0) {
10495: RasterBreakPoint.rbpUpdateFrame ();
10496: } else {
10497: RasterBreakPoint.rbpTimer--;
10498: }
10499: }
10500: }
10501: if (ScreenModeTest.SMT_ON) {
10502: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
10503: if (ScreenModeTest.smtTimer == 0) {
10504: ScreenModeTest.smtUpdateFrame ();
10505: } else {
10506: ScreenModeTest.smtTimer--;
10507: }
10508: }
10509: }
10510: if (RootPointerList.RTL_ON) {
10511: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
10512: if (RootPointerList.rtlTimer == 0) {
10513: RootPointerList.rtlTimer = RootPointerList.RTL_INTERVAL - 1;
10514: RootPointerList.rtlUpdateFrame ();
10515: } else {
10516: RootPointerList.rtlTimer--;
10517: }
10518: }
10519: }
10520: if (SpritePatternViewer.SPV_ON) {
10521: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
10522: if (SpritePatternViewer.spvTimer == 0) {
10523: SpritePatternViewer.spvTimer = SpritePatternViewer.SPV_INTERVAL - 1;
10524: SpritePatternViewer.spvUpdateFrame ();
10525: } else {
10526: SpritePatternViewer.spvTimer--;
10527: }
10528: }
10529: }
10530: if (PaletteViewer.PLV_ON) {
10531: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
10532: if (PaletteViewer.plvTimer == 0) {
10533: PaletteViewer.plvTimer = PaletteViewer.PLV_INTERVAL - 1;
10534: PaletteViewer.plvUpdateFrame ();
10535: } else {
10536: PaletteViewer.plvTimer--;
10537: }
10538: }
10539: }
10540: if (ATCMonitor.ACM_ON) {
10541: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
10542: if (ATCMonitor.acmTimer == 0) {
10543: ATCMonitor.acmTimer = ATCMonitor.ACM_INTERVAL - 1;
10544: ATCMonitor.acmUpdateFrame ();
10545: } else {
10546: ATCMonitor.acmTimer--;
10547: }
10548: }
10549: }
10550: }
10551:
10552:
10553:
10554:
10555:
10556:
10557:
10558:
10559:
10560:
10561:
10562:
10563:
10564:
10565:
10566:
10567:
10568:
10569:
10570:
10571:
10572:
10573: public static boolean dbgDoStopOnError () {
10574: if (MainMemory.mmrHumanVersion <= 0) {
10575: return true;
10576: }
10577: if ((regOC & 0xff00) == 0xff00 &&
10578: M68kException.m6eNumber == M68kException.M6E_PRIVILEGE_VIOLATION) {
10579: return false;
10580: }
10581: String message = (
10582: M68kException.m6eNumber < 0 ?
10583: fmtHex8 (new StringBuilder ("breaked").append (" at "), regPC0).toString () :
10584: M68kException.m6eNumber <= M68kException.M6E_ADDRESS_ERROR ?
10585: fmtHex8 (fmtHex8 (new StringBuilder ("ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10586: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10587: .append (" at "), regPC0).toString () :
10588: fmtHex8 (new StringBuilder (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10589: .append (" at "), regPC0).toString ()
10590: );
10591: System.out.println (message);
10592: if (!(M68kException.m6eNumber == M68kException.M6E_ACCESS_FAULT &&
10593: 0x0000e100 <= regPC0 && regPC0 < 0x0000e500)) {
10594: mpuStop (message);
10595: return true;
10596: }
10597: return false;
10598: }
10599:
10600:
10601:
10602: public static void dbgDoubleBusFault () {
10603: String message =
10604: fmtHex8 (fmtHex8 (new StringBuilder ("FATAL ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10605: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10606: .append (" at "), regPC0).toString ();
10607: System.out.println (message);
10608: mpuStop (message);
10609: }
10610:
10611:
10612:
10613:
10614:
10615:
10616: public static final HashMap<String,byte[]> rscResourceCache = new HashMap<String,byte[]> ();
10617:
10618:
10619:
10620:
10621:
10622:
10623: public static byte[] rscGetResource (String name, int... sizes) {
10624: byte[] array = rscResourceCache.get (name);
10625: if (array != null) {
10626: return array;
10627: }
10628: array = new byte[1024 * 64];
10629: int size = 0;
10630: try (BufferedInputStream bis = new BufferedInputStream (XEiJ.class.getResourceAsStream ("../data/" + name))) {
10631: for (;;) {
10632: if (size == array.length) {
10633: byte[] newArray = new byte[array.length * 2];
10634: System.arraycopy (array, 0, newArray, 0, size);
10635: array = newArray;
10636: }
10637: int step = bis.read (array, size, array.length - size);
10638: if (step == -1) {
10639: break;
10640: }
10641: size += step;
10642: }
10643: if (size < array.length) {
10644: byte[] newArray = new byte[size];
10645: System.arraycopy (array, 0, newArray, 0, size);
10646: array = newArray;
10647: }
10648: boolean fit = sizes.length == 0;
10649: if (!fit) {
10650: for (int i = 0; i < sizes.length; i++) {
10651: if (size == sizes[i]) {
10652: fit = true;
10653: break;
10654: }
10655: }
10656: }
10657: if (fit) {
10658: System.out.println (Multilingual.mlnJapanese ?
10659: name + " を読み込みました" :
10660: name + " was read");
10661: rscResourceCache.put (name, array);
10662: return array;
10663: }
10664: System.out.println (Multilingual.mlnJapanese ?
10665: name + " のサイズが違います" :
10666: name + " has wrong size");
10667: return null;
10668: } catch (IOException ioe) {
10669: }
10670:
10671: System.out.println (Multilingual.mlnJapanese ?
10672: name + " を読み込めません" :
10673: name + " cannot be read");
10674: return null;
10675: }
10676:
10677:
10678:
10679: public static String rscGetResourceText (String name) {
10680: return rscGetResourceText (name, "UTF-8");
10681: }
10682: public static String rscGetResourceText (String name, String charset) {
10683: byte[] array = rscGetResource (name);
10684: if (name != null) {
10685: try {
10686: return new String (array, charset);
10687: } catch (UnsupportedEncodingException uee) {
10688: }
10689: }
10690: return "";
10691: }
10692:
10693: public static final Pattern RSC_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10694: public static String rscLastFileName = null;
10695:
10696:
10697:
10698:
10699:
10700:
10701: public static byte[] rscGetFile (String names, int... sizes) {
10702: for (String name : names.split (",")) {
10703: name = name.trim ();
10704: if (name.length () == 0 || name.equalsIgnoreCase ("none")) {
10705: continue;
10706: }
10707: String[] zipSplittedName = RSC_ZIP_SEPARATOR.split (name, 2);
10708: InputStream is = null;
10709: if (zipSplittedName.length < 2) {
10710: File file = new File (name);
10711: if (file.isFile ()) {
10712: try {
10713: is = new FileInputStream (file);
10714: } catch (IOException ioe) {
10715: }
10716: } else {
10717: System.out.println (Multilingual.mlnJapanese ?
10718: name + " がありません" :
10719: name + " does not exist");
10720: continue;
10721: }
10722: } else {
10723: String zipName = zipSplittedName[0];
10724: String entryName = zipSplittedName[1];
10725: if (new File (zipName).isFile ()) {
10726: try {
10727: ZipFile zipFile = new ZipFile (zipName);
10728: ZipEntry zipEntry = zipFile.getEntry (entryName);
10729: if (zipEntry != null) {
10730: is = zipFile.getInputStream (zipEntry);
10731: } else {
10732: System.out.println (Multilingual.mlnJapanese ?
10733: zipName + " に " + zipEntry + " がありません" :
10734: zipName + " does not include " + zipEntry);
10735: }
10736: } catch (IOException ioe) {
10737: }
10738: } else {
10739: System.out.println (Multilingual.mlnJapanese ?
10740: zipName + " がありません" :
10741: zipName + " does not exist");
10742: continue;
10743: }
10744: }
10745: if (is != null) {
10746: try {
10747: is = new BufferedInputStream (is);
10748: if (name.toLowerCase ().endsWith (".gz")) {
10749: is = new GZIPInputStream (is);
10750: }
10751: byte[] array = new byte[1024 * 64];
10752: int size = 0;
10753: for (;;) {
10754: if (size == array.length) {
10755: byte[] newArray = new byte[array.length * 2];
10756: System.arraycopy (array, 0, newArray, 0, size);
10757: array = newArray;
10758: }
10759: int step = is.read (array, size, array.length - size);
10760: if (step == -1) {
10761: break;
10762: }
10763: size += step;
10764: }
10765: is.close ();
10766: is = null;
10767: if (size < array.length) {
10768: byte[] newArray = new byte[size];
10769: System.arraycopy (array, 0, newArray, 0, size);
10770: array = newArray;
10771: }
10772: boolean fit = sizes.length == 0;
10773: if (!fit) {
10774: for (int i = 0; i < sizes.length; i++) {
10775: if (size == sizes[i]) {
10776: fit = true;
10777: break;
10778: }
10779: }
10780: }
10781: if (fit) {
10782: System.out.println (Multilingual.mlnJapanese ?
10783: name + " を読み込みました" :
10784: name + " was read");
10785: rscLastFileName = name;
10786: return array;
10787: }
10788: System.out.println (Multilingual.mlnJapanese ?
10789: name + " のサイズが違います" :
10790: name + " has wrong size");
10791: continue;
10792: } catch (IOException ioe) {
10793: }
10794: if (is != null) {
10795: try {
10796: is.close ();
10797: is = null;
10798: } catch (IOException ioe) {
10799: }
10800: }
10801: }
10802: System.out.println (Multilingual.mlnJapanese ?
10803: name + " を読み込めません" :
10804: name + " cannot be read");
10805: }
10806:
10807:
10808:
10809: return null;
10810: }
10811:
10812:
10813:
10814:
10815: public static String rscGetTextFile (String name) {
10816: return rscGetTextFile (name, "UTF-8");
10817: }
10818: public static String rscGetTextFile (String name, String charset) {
10819: byte[] array = rscGetFile (name);
10820: if (array != null) {
10821: try {
10822: return new String (array, charset);
10823: } catch (UnsupportedEncodingException uee) {
10824: }
10825: }
10826: return "";
10827: }
10828:
10829:
10830:
10831: public static final int RSC_A_MASK = 1;
10832: public static final int RSC_R_MASK = 2;
10833: public static final int RSC_I_MASK = 4;
10834: public static final String RSC_A_EN = "Abort";
10835: public static final String RSC_R_EN = "Retry";
10836: public static final String RSC_I_EN = "Ignore";
10837: public static final String RSC_A_JA = "中止";
10838: public static final String RSC_R_JA = "再実行";
10839: public static final String RSC_I_JA = "無視";
10840: public static final String[][] RSC_EN_OPTIONS = {
10841: { RSC_A_EN },
10842: { RSC_A_EN },
10843: { RSC_R_EN },
10844: { RSC_A_EN, RSC_R_EN },
10845: { RSC_I_EN },
10846: { RSC_A_EN, RSC_I_EN },
10847: { RSC_R_EN, RSC_I_EN },
10848: { RSC_A_EN, RSC_R_EN, RSC_I_EN },
10849: };
10850: public static final String[][] RSC_JA_OPTIONS = {
10851: { RSC_A_JA },
10852: { RSC_A_JA },
10853: { RSC_R_JA },
10854: { RSC_A_JA, RSC_R_JA },
10855: { RSC_I_JA },
10856: { RSC_A_JA, RSC_I_JA },
10857: { RSC_R_JA, RSC_I_JA },
10858: { RSC_A_JA, RSC_R_JA, RSC_I_JA },
10859: };
10860: public static int rscShowError (String message, int mask) {
10861: System.out.println (message);
10862: mask &= RSC_A_MASK | RSC_R_MASK | RSC_I_MASK;
10863: if (mask == 0) {
10864: mask = RSC_A_MASK;
10865: }
10866: String[] options = (Multilingual.mlnJapanese ? RSC_JA_OPTIONS : RSC_EN_OPTIONS)[mask];
10867: int def = Integer.numberOfTrailingZeros (mask);
10868: pnlExitFullScreen (true);
10869: int bit = JOptionPane.showOptionDialog (
10870: null,
10871: message,
10872: Multilingual.mlnJapanese ? "ファイル操作エラー" : "File operation error",
10873: JOptionPane.YES_NO_CANCEL_OPTION,
10874: JOptionPane.ERROR_MESSAGE,
10875: null,
10876: options,
10877: options[def]);
10878: if (bit == JOptionPane.CLOSED_OPTION) {
10879: bit = def;
10880: }
10881: return 1 << bit;
10882: }
10883:
10884:
10885:
10886:
10887:
10888:
10889: public static boolean rscPutTextFile (String name, String string) {
10890: return rscPutTextFile (name, string, "UTF-8");
10891: }
10892: public static boolean rscPutTextFile (String name, ArrayList<String> strings) {
10893: return rscPutTextFile (name, strings, "UTF-8");
10894: }
10895: public static boolean rscPutTextFile (String name, String string, String charset) {
10896: ArrayList<String> strings = new ArrayList<String> ();
10897: strings.add (string);
10898: return rscPutTextFile (name, strings, charset);
10899: }
10900: public static boolean rscPutTextFile (String name, ArrayList<String> strings, String charset) {
10901: String nameTmp = name + ".tmp";
10902: String nameBak = name + ".bak";
10903: File file = new File (name);
10904: File fileTmp = new File (nameTmp);
10905: File fileBak = new File (nameBak);
10906:
10907: File parentDirectory = file.getParentFile ();
10908: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10909: if (!parentDirectory.mkdirs ()) {
10910: System.out.println (parentDirectory.getPath () + (Multilingual.mlnJapanese ? " を作れません" : " cannot be created"));
10911: return false;
10912: }
10913: }
10914:
10915: if (fileTmp.exists ()) {
10916: if (!fileTmp.delete ()) {
10917: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10918: return false;
10919: }
10920: }
10921:
10922: try (BufferedWriter bw = new BufferedWriter (new FileWriter (nameTmp, Charset.forName (charset)))) {
10923: for (String string : strings) {
10924: bw.write (string);
10925: }
10926: } catch (IOException ioe) {
10927: ioe.printStackTrace ();
10928: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " に書き出せません" : " cannot be written"));
10929: return false;
10930: }
10931:
10932: boolean fileExists = file.exists ();
10933: if (fileExists) {
10934:
10935: if (fileBak.exists ()) {
10936: if (!fileBak.delete ()) {
10937: System.out.println (nameBak + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10938: return false;
10939: }
10940: }
10941:
10942: if (!file.renameTo (fileBak)) {
10943: System.out.println (name + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + nameBak + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10944: return false;
10945: }
10946: }
10947:
10948: if (!fileTmp.renameTo (file)) {
10949: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + name + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10950: return false;
10951: }
10952: if (fileExists) {
10953: System.out.println (name + (Multilingual.mlnJapanese ? " を更新しました" : " was updated"));
10954: } else {
10955: System.out.println (name + (Multilingual.mlnJapanese ? " を作りました" : " was created"));
10956: }
10957: return true;
10958: }
10959:
10960:
10961:
10962:
10963:
10964:
10965:
10966:
10967:
10968: public static boolean rscPutFile (String name, byte[] array) {
10969: return rscPutFile (name, array, 0, array.length, (long) array.length);
10970: }
10971: public static boolean rscPutFile (String name, byte[] array, int offset, int length) {
10972: return rscPutFile (name, array, offset, length, (long) length);
10973: }
10974: public static boolean rscPutFile (String name, byte[] array, int offset, int length, long longLength2) {
10975: if (RSC_ZIP_SEPARATOR.matcher (name).matches ()) {
10976:
10977: return false;
10978: }
10979: File file = new File (name);
10980: boolean fileExists = file.isFile ();
10981: if (fileExists && file.length () == longLength2) {
10982: comparison:
10983: {
10984: try (BufferedInputStream bis = new BufferedInputStream (new FileInputStream (file))) {
10985: byte[] buffer = new byte[(int) Math.min (Math.max ((long) length, longLength2 - (long) length), (long) (1024 * 1024))];
10986: int position = 0;
10987: while (position < length) {
10988: int step = bis.read (buffer, 0, Math.min (buffer.length, length - position));
10989: if (step == -1) {
10990: break comparison;
10991: }
10992: int offsetPosition = offset + position;
10993: for (int i = 0; i < step; i++) {
10994: if (buffer[i] != array[offsetPosition + i]) {
10995: break comparison;
10996: }
10997: }
10998: position += step;
10999: }
11000: long longPosition2 = (long) length;
11001: while (longPosition2 < longLength2) {
11002: int step = bis.read (buffer, 0, (int) Math.min ((long) buffer.length, longLength2 - longPosition2));
11003: if (step == -1) {
11004: break comparison;
11005: }
11006: for (int i = 0; i < step; i++) {
11007: if (buffer[i] != 0) {
11008: break comparison;
11009: }
11010: }
11011: longPosition2 += (long) step;
11012: }
11013: return true;
11014: } catch (IOException ioe) {
11015: }
11016: }
11017: }
11018: String nameTmp = name + ".tmp";
11019: File fileTmp = new File (nameTmp);
11020: String nameBak = name + ".bak";
11021: File fileBak = new File (nameBak);
11022: retry:
11023: for (;;) {
11024: File parentDirectory = file.getParentFile ();
11025: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
11026: String parentName = parentDirectory.getPath ();
11027: if (parentDirectory.mkdirs ()) {
11028: System.out.println (Multilingual.mlnJapanese ?
11029: parentName + " を作りました" :
11030: parentName + " was created");
11031: } else {
11032: switch (rscShowError (Multilingual.mlnJapanese ?
11033: parentName + " を作れません" :
11034: parentName + " cannot be created",
11035: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11036: case RSC_A_MASK:
11037: break retry;
11038: case RSC_R_MASK:
11039: continue retry;
11040: }
11041: }
11042: }
11043: if (fileTmp.isFile ()) {
11044: if (!fileTmp.delete ()) {
11045: switch (rscShowError (Multilingual.mlnJapanese ?
11046: nameTmp + " を削除できません" :
11047: nameTmp + " cannot be deleted",
11048: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11049: case RSC_A_MASK:
11050: break retry;
11051: case RSC_R_MASK:
11052: continue retry;
11053: }
11054: }
11055: }
11056: try (OutputStream os = name.toLowerCase ().endsWith (".gz") ?
11057: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11058: {
11059:
11060: def.setLevel (Deflater.DEFAULT_COMPRESSION);
11061:
11062: }
11063: } :
11064: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11065:
11066: os.write (array, offset, length);
11067:
11068:
11069: if ((long) length < longLength2) {
11070: byte[] buffer = new byte[(int) Math.min (longLength2 - (long) length, (long) (1024 * 1024))];
11071: Arrays.fill (buffer, 0, buffer.length, (byte) 0);
11072: long longPosition2 = (long) length;
11073: while (longPosition2 < longLength2) {
11074: int step = (int) Math.min ((long) buffer.length, longLength2 - longPosition2);
11075: os.write (buffer, 0, step);
11076: longPosition2 += (long) step;
11077: }
11078: }
11079: } catch (IOException ioe) {
11080: switch (rscShowError (Multilingual.mlnJapanese ?
11081: nameTmp + " に書き出せません" :
11082: nameTmp + " cannot be written",
11083: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11084: case RSC_A_MASK:
11085: break retry;
11086: case RSC_R_MASK:
11087: continue retry;
11088: }
11089: }
11090: if (fileExists && file.isFile ()) {
11091: if (fileBak.isFile ()) {
11092: if (!fileBak.delete ()) {
11093: switch (rscShowError (Multilingual.mlnJapanese ?
11094: nameBak + " を削除できません" :
11095: nameBak + " cannot be deleted",
11096: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11097: case RSC_A_MASK:
11098: break retry;
11099: case RSC_R_MASK:
11100: continue retry;
11101: }
11102: }
11103: }
11104: if (!file.renameTo (fileBak)) {
11105: switch (rscShowError (Multilingual.mlnJapanese ?
11106: name + " を " + nameBak + " にリネームできません" :
11107: name + " cannot be renamed to " + nameBak,
11108: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11109: case RSC_A_MASK:
11110: break retry;
11111: case RSC_R_MASK:
11112: continue retry;
11113: }
11114: }
11115: }
11116: if (fileTmp.renameTo (file)) {
11117: if (fileExists) {
11118: System.out.println (Multilingual.mlnJapanese ?
11119: name + " を更新しました" :
11120: name + " was updated");
11121: } else {
11122: System.out.println (Multilingual.mlnJapanese ?
11123: name + " を作りました" :
11124: name + " was created");
11125: }
11126: return true;
11127: } else {
11128: switch (rscShowError (Multilingual.mlnJapanese ?
11129: nameTmp + " を " + name + " にリネームできません" :
11130: nameTmp + " cannot be renamed to " + name,
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: break;
11139: }
11140: if (fileExists) {
11141: System.out.println (Multilingual.mlnJapanese ?
11142: name + " を更新できません" :
11143: name + " cannot be updated");
11144: } else {
11145: System.out.println (Multilingual.mlnJapanese ?
11146: name + " を作れません" :
11147: name + " cannot be created");
11148: }
11149: return false;
11150: }
11151:
11152:
11153:
11154:
11155:
11156:
11157: public static final Pattern ISM_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
11158:
11159:
11160:
11161:
11162:
11163:
11164:
11165:
11166:
11167:
11168:
11169: public static InputStream ismOpen (String name) {
11170: InputStream in = null;
11171: in = ismOpen (name, false);
11172: if (in == null && name.indexOf ('/') < 0 && name.indexOf ('\\') < 0) {
11173: in = ismOpen (name, true);
11174: }
11175: return in;
11176: }
11177: public static InputStream ismOpen (String name, boolean useGetResource) {
11178: boolean gzipped = name.toLowerCase ().endsWith (".gz");
11179: String[] zipSplittedName = ISM_ZIP_SEPARATOR.split (name, 2);
11180: String fileName = zipSplittedName[0];
11181: String zipEntryName = zipSplittedName.length < 2 ? null : zipSplittedName[1];
11182: InputStream in = null;
11183: try {
11184: if (useGetResource) {
11185: if (false) {
11186: URL url = XEiJ.class.getResource (fileName);
11187: if (url != null) {
11188: in = url.openStream ();
11189: }
11190: } else {
11191: in = XEiJ.class.getResourceAsStream (fileName);
11192: }
11193: } else {
11194: File file = new File (fileName);
11195: if (file.exists ()) {
11196: in = new FileInputStream (file);
11197: }
11198: }
11199: if (in != null && zipEntryName != null) {
11200: ZipInputStream zin = new ZipInputStream (in);
11201: in = null;
11202: ZipEntry entry;
11203: while ((entry = zin.getNextEntry ()) != null) {
11204: if (zipEntryName.equals (entry.getName ())) {
11205: in = zin;
11206: break;
11207: }
11208: }
11209: if (in == null) {
11210: System.out.println (Multilingual.mlnJapanese ? fileName + " の中に " + zipEntryName + " がありません" :
11211: zipEntryName + " does not exist in " + fileName);
11212: }
11213: }
11214: if (in != null && gzipped) {
11215: in = new GZIPInputStream (in);
11216: }
11217: if (in != null) {
11218: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " を読み込みます" :
11219: (useGetResource ? "Reading resource file " : "Reading file ") + name);
11220: return new BufferedInputStream (in);
11221: }
11222: } catch (Exception ioe) {
11223: if (prgVerbose) {
11224: prgPrintStackTraceOf (ioe);
11225: }
11226: }
11227: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " が見つかりません" :
11228: (useGetResource ? "Resource file " : "File ") + name + " is not found");
11229: return null;
11230: }
11231:
11232:
11233:
11234:
11235:
11236:
11237:
11238:
11239: public static int ismRead (InputStream in, byte[] bb, int o, int l) {
11240: try {
11241: int k = 0;
11242: while (k < l) {
11243: int t = in.read (bb, o + k, l - k);
11244: if (t < 0) {
11245: break;
11246: }
11247: k += t;
11248: }
11249: return k;
11250: } catch (IOException ioe) {
11251: if (prgVerbose) {
11252: prgPrintStackTraceOf (ioe);
11253: }
11254: }
11255: return -1;
11256: }
11257:
11258:
11259:
11260:
11261:
11262:
11263:
11264:
11265: public static int ismSkip (InputStream in, int l) {
11266: try {
11267: int k = 0;
11268: while (k < l) {
11269:
11270:
11271: if (in.read () < 0) {
11272: break;
11273: }
11274: k++;
11275: if (k < l) {
11276: int t = (int) in.skip ((long) (l - k));
11277: if (t < 0) {
11278: break;
11279: }
11280: k += t;
11281: }
11282: }
11283: return k;
11284: } catch (IOException ioe) {
11285: if (prgVerbose) {
11286: prgPrintStackTraceOf (ioe);
11287: }
11288: }
11289: return -1;
11290: }
11291:
11292:
11293:
11294:
11295:
11296: public static void ismClose (InputStream in) {
11297: try {
11298: if (in != null) {
11299: in.close ();
11300: }
11301: } catch (IOException ioe) {
11302: if (prgVerbose) {
11303: prgPrintStackTraceOf (ioe);
11304: }
11305: }
11306: }
11307:
11308:
11309:
11310:
11311:
11312:
11313: public static int ismLength (String name, int maxLength) {
11314: int length;
11315: InputStream in = ismOpen (name);
11316: if (in == null) {
11317: length = -1;
11318: } else {
11319: length = ismSkip (in, maxLength);
11320: ismClose (in);
11321: }
11322: return length;
11323: }
11324:
11325:
11326:
11327:
11328:
11329:
11330:
11331:
11332:
11333:
11334:
11335:
11336:
11337:
11338: public static boolean ismLoad (byte[] bb, int o, int l, String names) {
11339: for (String name : names.split (",")) {
11340: if (name.length () != 0) {
11341: InputStream in = ismOpen (name);
11342: if (in != null) {
11343: int k = ismRead (in, bb, o, l);
11344: ismClose (in);
11345: if (k == l) {
11346: return true;
11347: }
11348: }
11349: }
11350: }
11351: return false;
11352: }
11353:
11354:
11355:
11356:
11357:
11358:
11359:
11360:
11361:
11362: public static boolean ismSave (byte[] bb, int offset, long length, String path, boolean verbose) {
11363: if (ISM_ZIP_SEPARATOR.split (path, 2).length != 1) {
11364: if (verbose) {
11365: pnlExitFullScreen (true);
11366: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? path + " に書き出せません" : "Cannot write " + path);
11367: }
11368: return false;
11369: }
11370: long step = 0;
11371: byte[] zz = null;
11372: long pointer = (long) (bb.length - offset);
11373: if (pointer < length) {
11374: step = Math.min (1024L * 512, length - pointer);
11375: zz = new byte[(int) step];
11376: Arrays.fill (zz, (byte) 0);
11377: }
11378:
11379: File file = new File (path);
11380:
11381: if (step == 0 &&
11382: file.exists () && file.length () == length) {
11383:
11384: if (length == 0L) {
11385: return true;
11386: }
11387: InputStream in = ismOpen (path);
11388: if (in != null) {
11389: int l = (int) length;
11390: byte[] tt = new byte[l];
11391: int k = ismRead (in, tt, 0, l);
11392: ismClose (in);
11393: if (k == l &&
11394: Arrays.equals (tt, bb.length == l ? bb : Arrays.copyOfRange (bb, offset, offset + l))) {
11395: return true;
11396: }
11397: }
11398: }
11399:
11400: String pathTmp = path + ".tmp";
11401: String pathBak = path + ".bak";
11402: File fileTmp = new File (pathTmp);
11403: File fileBak = new File (pathBak);
11404:
11405: if (fileTmp.exists ()) {
11406: if (!fileTmp.delete ()) {
11407: if (verbose) {
11408: pnlExitFullScreen (true);
11409: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " を削除できません" : "Cannot delete " + pathTmp);
11410: }
11411: return false;
11412: }
11413: }
11414:
11415: try (OutputStream out = path.toLowerCase ().endsWith (".gz") ?
11416: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11417: {
11418:
11419: def.setLevel (Deflater.DEFAULT_COMPRESSION);
11420:
11421: }
11422: } :
11423: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11424: if (step == 0) {
11425: out.write (bb, offset, (int) length);
11426: } else {
11427: out.write (bb, offset, (int) pointer);
11428: for (; pointer < length; pointer += step) {
11429: out.write (zz, 0, (int) Math.min (step, length - pointer));
11430: }
11431: }
11432: } catch (IOException ioe) {
11433: if (verbose) {
11434: prgPrintStackTraceOf (ioe);
11435: pnlExitFullScreen (true);
11436: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " に書き出せません" : "Cannot write " + pathTmp);
11437: }
11438: return false;
11439: }
11440:
11441:
11442: if (file.exists ()) {
11443: if (fileBak.exists ()) {
11444: if (!fileBak.delete ()) {
11445: if (verbose) {
11446: pnlExitFullScreen (true);
11447: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathBak + " を削除できません" : "Cannot delete " + pathBak);
11448: }
11449: return false;
11450: }
11451: }
11452: if (!file.renameTo (fileBak)) {
11453: if (verbose) {
11454: pnlExitFullScreen (true);
11455: JOptionPane.showMessageDialog (
11456: null, Multilingual.mlnJapanese ? path + " を " + pathBak + " にリネームできません" : "Cannot rename " + path + " to " + pathBak);
11457: }
11458: return false;
11459: }
11460: }
11461:
11462:
11463: if (!fileTmp.renameTo (file)) {
11464: if (verbose) {
11465: pnlExitFullScreen (true);
11466: JOptionPane.showMessageDialog (
11467: null, Multilingual.mlnJapanese ? pathTmp + " を " + path + " にリネームできません" : "Cannot rename " + pathTmp + " to " + path);
11468: }
11469: return false;
11470: }
11471: return true;
11472: }
11473:
11474:
11475:
11476:
11477:
11478:
11479:
11480: public static final char[] FMT_TEMP = new char[32];
11481:
11482:
11483:
11484:
11485:
11486:
11487:
11488:
11489:
11490:
11491:
11492: public static final char[] FMT_AIN4_BASE = ".......*..*...**.*...*.*.**..****...*..**.*.*.****..**.****.****".toCharArray ();
11493: public static final char[] FMT_BIN4_BASE = "0000000100100011010001010110011110001001101010111100110111101111".toCharArray ();
11494:
11495:
11496:
11497:
11498:
11499:
11500:
11501:
11502: public static void fmtAin4 (char[] a, int o, int x) {
11503: a[o ] = (char) (x >> 1 & 4 ^ 46);
11504: a[o + 1] = (char) (x & 4 ^ 46);
11505: a[o + 2] = (char) (x << 1 & 4 ^ 46);
11506: a[o + 3] = (char) (x << 2 & 4 ^ 46);
11507: }
11508: public static void fmtBin4 (char[] a, int o, int x) {
11509: a[o ] = (char) (x >>> 3 & 1 | 48);
11510: a[o + 1] = (char) (x >>> 2 & 1 | 48);
11511: a[o + 2] = (char) (x >>> 1 & 1 | 48);
11512: a[o + 3] = (char) (x & 1 | 48);
11513: }
11514: public static String fmtAin4 (int x) {
11515: return String.valueOf (FMT_AIN4_BASE, (x & 15) << 2, 4);
11516: }
11517: public static String fmtBin4 (int x) {
11518: return String.valueOf (FMT_BIN4_BASE, (x & 15) << 2, 4);
11519: }
11520: public static StringBuilder fmtAin4 (StringBuilder sb, int x) {
11521: return sb.append (FMT_AIN4_BASE, (x & 15) << 2, 6);
11522: }
11523: public static StringBuilder fmtBin4 (StringBuilder sb, int x) {
11524: return sb.append (FMT_BIN4_BASE, (x & 15) << 2, 6);
11525: }
11526:
11527:
11528:
11529:
11530:
11531:
11532:
11533:
11534: public static void fmtAin6 (char[] a, int o, int x) {
11535: a[o ] = (char) (x >> 3 & 4 ^ 46);
11536: a[o + 1] = (char) (x >> 2 & 4 ^ 46);
11537: a[o + 2] = (char) (x >> 1 & 4 ^ 46);
11538: a[o + 3] = (char) (x & 4 ^ 46);
11539: a[o + 4] = (char) (x << 1 & 4 ^ 46);
11540: a[o + 5] = (char) (x << 2 & 4 ^ 46);
11541: }
11542: public static void fmtBin6 (char[] a, int o, int x) {
11543: a[o ] = (char) (x >>> 5 & 1 | 48);
11544: a[o + 1] = (char) (x >>> 4 & 1 | 48);
11545: a[o + 2] = (char) (x >>> 3 & 1 | 48);
11546: a[o + 3] = (char) (x >>> 2 & 1 | 48);
11547: a[o + 4] = (char) (x >>> 1 & 1 | 48);
11548: a[o + 5] = (char) (x & 1 | 48);
11549: }
11550: public static String fmtAin6 (int x) {
11551: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11552: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11553: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11554: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11555: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11556: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11557: return String.valueOf (FMT_TEMP, 0, 6);
11558: }
11559: public static String fmtBin6 (int x) {
11560: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11561: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11562: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11563: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11564: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11565: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11566: return String.valueOf (FMT_TEMP, 0, 6);
11567: }
11568: public static StringBuilder fmtAin6 (StringBuilder sb, int x) {
11569: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11570: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11571: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11572: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11573: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11574: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11575: return sb.append (FMT_TEMP, 0, 6);
11576: }
11577: public static StringBuilder fmtBin6 (StringBuilder sb, int x) {
11578: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11579: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11580: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11581: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11582: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11583: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11584: return sb.append (FMT_TEMP, 0, 6);
11585: }
11586:
11587:
11588:
11589:
11590:
11591:
11592:
11593:
11594: public static void fmtAin8 (char[] a, int o, int x) {
11595: a[o ] = (char) (x >> 5 & 4 ^ 46);
11596: a[o + 1] = (char) (x >> 4 & 4 ^ 46);
11597: a[o + 2] = (char) (x >> 3 & 4 ^ 46);
11598: a[o + 3] = (char) (x >> 2 & 4 ^ 46);
11599: a[o + 4] = (char) (x >> 1 & 4 ^ 46);
11600: a[o + 5] = (char) (x & 4 ^ 46);
11601: a[o + 6] = (char) (x << 1 & 4 ^ 46);
11602: a[o + 7] = (char) (x << 2 & 4 ^ 46);
11603: }
11604: public static void fmtBin8 (char[] a, int o, int x) {
11605: a[o ] = (char) (x >>> 7 & 1 | 48);
11606: a[o + 1] = (char) (x >>> 6 & 1 | 48);
11607: a[o + 2] = (char) (x >>> 5 & 1 | 48);
11608: a[o + 3] = (char) (x >>> 4 & 1 | 48);
11609: a[o + 4] = (char) (x >>> 3 & 1 | 48);
11610: a[o + 5] = (char) (x >>> 2 & 1 | 48);
11611: a[o + 6] = (char) (x >>> 1 & 1 | 48);
11612: a[o + 7] = (char) (x & 1 | 48);
11613: }
11614: public static String fmtAin8 (int x) {
11615: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11616: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11617: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11618: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11619: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11620: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11621: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11622: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11623: return String.valueOf (FMT_TEMP, 0, 8);
11624: }
11625: public static String fmtBin8 (int x) {
11626: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11627: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11628: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11629: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11630: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11631: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11632: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11633: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11634: return String.valueOf (FMT_TEMP, 0, 8);
11635: }
11636: public static StringBuilder fmtAin8 (StringBuilder sb, int x) {
11637: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11638: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11639: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11640: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11641: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11642: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11643: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11644: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11645: return sb.append (FMT_TEMP, 0, 8);
11646: }
11647: public static StringBuilder fmtBin8 (StringBuilder sb, int x) {
11648: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11649: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11650: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11651: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11652: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11653: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11654: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11655: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11656: return sb.append (FMT_TEMP, 0, 8);
11657: }
11658:
11659:
11660:
11661:
11662:
11663:
11664:
11665:
11666: public static void fmtAin12 (char[] a, int o, int x) {
11667: a[o ] = (char) (x >> 9 & 4 ^ 46);
11668: a[o + 1] = (char) (x >> 8 & 4 ^ 46);
11669: a[o + 2] = (char) (x >> 7 & 4 ^ 46);
11670: a[o + 3] = (char) (x >> 6 & 4 ^ 46);
11671: a[o + 4] = (char) (x >> 5 & 4 ^ 46);
11672: a[o + 5] = (char) (x >> 4 & 4 ^ 46);
11673: a[o + 6] = (char) (x >> 3 & 4 ^ 46);
11674: a[o + 7] = (char) (x >> 2 & 4 ^ 46);
11675: a[o + 8] = (char) (x >> 1 & 4 ^ 46);
11676: a[o + 9] = (char) (x & 4 ^ 46);
11677: a[o + 10] = (char) (x << 1 & 4 ^ 46);
11678: a[o + 11] = (char) (x << 2 & 4 ^ 46);
11679: }
11680: public static void fmtBin12 (char[] a, int o, int x) {
11681: a[o ] = (char) (x >>> 11 & 1 | 48);
11682: a[o + 1] = (char) (x >>> 10 & 1 | 48);
11683: a[o + 2] = (char) (x >>> 9 & 1 | 48);
11684: a[o + 3] = (char) (x >>> 8 & 1 | 48);
11685: a[o + 4] = (char) (x >>> 7 & 1 | 48);
11686: a[o + 5] = (char) (x >>> 6 & 1 | 48);
11687: a[o + 6] = (char) (x >>> 5 & 1 | 48);
11688: a[o + 7] = (char) (x >>> 4 & 1 | 48);
11689: a[o + 8] = (char) (x >>> 3 & 1 | 48);
11690: a[o + 9] = (char) (x >>> 2 & 1 | 48);
11691: a[o + 10] = (char) (x >>> 1 & 1 | 48);
11692: a[o + 11] = (char) (x & 1 | 48);
11693: }
11694: public static String fmtAin12 (int x) {
11695: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11696: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11697: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11698: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11699: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11700: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11701: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11702: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11703: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11704: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11705: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11706: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11707: return String.valueOf (FMT_TEMP, 0, 12);
11708: }
11709: public static String fmtBin12 (int x) {
11710: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11711: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11712: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11713: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11714: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11715: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11716: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11717: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11718: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11719: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11720: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11721: FMT_TEMP[11] = (char) (x & 1 | 48);
11722: return String.valueOf (FMT_TEMP, 0, 12);
11723: }
11724: public static StringBuilder fmtAin12 (StringBuilder sb, int x) {
11725: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11726: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11727: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11728: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11729: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11730: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11731: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11732: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11733: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11734: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11735: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11736: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11737: return sb.append (FMT_TEMP, 0, 12);
11738: }
11739: public static StringBuilder fmtBin12 (StringBuilder sb, int x) {
11740: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11741: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11742: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11743: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11744: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11745: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11746: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11747: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11748: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11749: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11750: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11751: FMT_TEMP[11] = (char) (x & 1 | 48);
11752: return sb.append (FMT_TEMP, 0, 12);
11753: }
11754:
11755:
11756:
11757:
11758:
11759:
11760:
11761:
11762: public static void fmtAin16 (char[] a, int o, int x) {
11763: a[o ] = (char) (x >> 13 & 4 ^ 46);
11764: a[o + 1] = (char) (x >> 12 & 4 ^ 46);
11765: a[o + 2] = (char) (x >> 11 & 4 ^ 46);
11766: a[o + 3] = (char) (x >> 10 & 4 ^ 46);
11767: a[o + 4] = (char) (x >> 9 & 4 ^ 46);
11768: a[o + 5] = (char) (x >> 8 & 4 ^ 46);
11769: a[o + 6] = (char) (x >> 7 & 4 ^ 46);
11770: a[o + 7] = (char) (x >> 6 & 4 ^ 46);
11771: a[o + 8] = (char) (x >> 5 & 4 ^ 46);
11772: a[o + 9] = (char) (x >> 4 & 4 ^ 46);
11773: a[o + 10] = (char) (x >> 3 & 4 ^ 46);
11774: a[o + 11] = (char) (x >> 2 & 4 ^ 46);
11775: a[o + 12] = (char) (x >> 1 & 4 ^ 46);
11776: a[o + 13] = (char) (x & 4 ^ 46);
11777: a[o + 14] = (char) (x << 1 & 4 ^ 46);
11778: a[o + 15] = (char) (x << 2 & 4 ^ 46);
11779: }
11780: public static void fmtBin16 (char[] a, int o, int x) {
11781: a[o ] = (char) (x >>> 15 & 1 | 48);
11782: a[o + 1] = (char) (x >>> 14 & 1 | 48);
11783: a[o + 2] = (char) (x >>> 13 & 1 | 48);
11784: a[o + 3] = (char) (x >>> 12 & 1 | 48);
11785: a[o + 4] = (char) (x >>> 11 & 1 | 48);
11786: a[o + 5] = (char) (x >>> 10 & 1 | 48);
11787: a[o + 6] = (char) (x >>> 9 & 1 | 48);
11788: a[o + 7] = (char) (x >>> 8 & 1 | 48);
11789: a[o + 8] = (char) (x >>> 7 & 1 | 48);
11790: a[o + 9] = (char) (x >>> 6 & 1 | 48);
11791: a[o + 10] = (char) (x >>> 5 & 1 | 48);
11792: a[o + 11] = (char) (x >>> 4 & 1 | 48);
11793: a[o + 12] = (char) (x >>> 3 & 1 | 48);
11794: a[o + 13] = (char) (x >>> 2 & 1 | 48);
11795: a[o + 14] = (char) (x >>> 1 & 1 | 48);
11796: a[o + 15] = (char) (x & 1 | 48);
11797: }
11798: public static String fmtAin16 (int x) {
11799: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11800: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11801: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11802: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11803: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11804: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11805: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11806: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11807: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11808: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11809: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11810: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11811: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11812: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11813: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11814: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11815: return String.valueOf (FMT_TEMP, 0, 16);
11816: }
11817: public static String fmtBin16 (int x) {
11818: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11819: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11820: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11821: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11822: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11823: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11824: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11825: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11826: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11827: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11828: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11829: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11830: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11831: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11832: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11833: FMT_TEMP[15] = (char) (x & 1 | 48);
11834: return String.valueOf (FMT_TEMP, 0, 16);
11835: }
11836: public static StringBuilder fmtAin16 (StringBuilder sb, int x) {
11837: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11838: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11839: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11840: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11841: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11842: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11843: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11844: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11845: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11846: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11847: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11848: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11849: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11850: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11851: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11852: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11853: return sb.append (FMT_TEMP, 0, 16);
11854: }
11855: public static StringBuilder fmtBin16 (StringBuilder sb, int x) {
11856: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11857: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11858: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11859: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11860: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11861: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11862: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11863: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11864: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11865: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11866: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11867: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11868: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11869: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11870: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11871: FMT_TEMP[15] = (char) (x & 1 | 48);
11872: return sb.append (FMT_TEMP, 0, 16);
11873: }
11874:
11875:
11876:
11877:
11878:
11879:
11880:
11881:
11882: public static void fmtAin24 (char[] a, int o, int x) {
11883: a[o ] = (char) (x >> 21 & 4 ^ 46);
11884: a[o + 1] = (char) (x >> 20 & 4 ^ 46);
11885: a[o + 2] = (char) (x >> 19 & 4 ^ 46);
11886: a[o + 3] = (char) (x >> 18 & 4 ^ 46);
11887: a[o + 4] = (char) (x >> 17 & 4 ^ 46);
11888: a[o + 5] = (char) (x >> 16 & 4 ^ 46);
11889: a[o + 6] = (char) (x >> 15 & 4 ^ 46);
11890: a[o + 7] = (char) (x >> 14 & 4 ^ 46);
11891: a[o + 8] = (char) (x >> 13 & 4 ^ 46);
11892: a[o + 9] = (char) (x >> 12 & 4 ^ 46);
11893: a[o + 10] = (char) (x >> 11 & 4 ^ 46);
11894: a[o + 11] = (char) (x >> 10 & 4 ^ 46);
11895: a[o + 12] = (char) (x >> 9 & 4 ^ 46);
11896: a[o + 13] = (char) (x >> 8 & 4 ^ 46);
11897: a[o + 14] = (char) (x >> 7 & 4 ^ 46);
11898: a[o + 15] = (char) (x >> 6 & 4 ^ 46);
11899: a[o + 16] = (char) (x >> 5 & 4 ^ 46);
11900: a[o + 17] = (char) (x >> 4 & 4 ^ 46);
11901: a[o + 18] = (char) (x >> 3 & 4 ^ 46);
11902: a[o + 19] = (char) (x >> 2 & 4 ^ 46);
11903: a[o + 20] = (char) (x >> 1 & 4 ^ 46);
11904: a[o + 21] = (char) (x & 4 ^ 46);
11905: a[o + 22] = (char) (x << 1 & 4 ^ 46);
11906: a[o + 23] = (char) (x << 2 & 4 ^ 46);
11907: }
11908: public static void fmtBin24 (char[] a, int o, int x) {
11909: a[o ] = (char) (x >>> 23 & 1 | 48);
11910: a[o + 1] = (char) (x >>> 22 & 1 | 48);
11911: a[o + 2] = (char) (x >>> 21 & 1 | 48);
11912: a[o + 3] = (char) (x >>> 20 & 1 | 48);
11913: a[o + 4] = (char) (x >>> 19 & 1 | 48);
11914: a[o + 5] = (char) (x >>> 18 & 1 | 48);
11915: a[o + 6] = (char) (x >>> 17 & 1 | 48);
11916: a[o + 7] = (char) (x >>> 16 & 1 | 48);
11917: a[o + 8] = (char) (x >>> 15 & 1 | 48);
11918: a[o + 9] = (char) (x >>> 14 & 1 | 48);
11919: a[o + 10] = (char) (x >>> 13 & 1 | 48);
11920: a[o + 11] = (char) (x >>> 12 & 1 | 48);
11921: a[o + 12] = (char) (x >>> 11 & 1 | 48);
11922: a[o + 13] = (char) (x >>> 10 & 1 | 48);
11923: a[o + 14] = (char) (x >>> 9 & 1 | 48);
11924: a[o + 15] = (char) (x >>> 8 & 1 | 48);
11925: a[o + 16] = (char) (x >>> 7 & 1 | 48);
11926: a[o + 17] = (char) (x >>> 6 & 1 | 48);
11927: a[o + 18] = (char) (x >>> 5 & 1 | 48);
11928: a[o + 19] = (char) (x >>> 4 & 1 | 48);
11929: a[o + 20] = (char) (x >>> 3 & 1 | 48);
11930: a[o + 21] = (char) (x >>> 2 & 1 | 48);
11931: a[o + 22] = (char) (x >>> 1 & 1 | 48);
11932: a[o + 23] = (char) (x & 1 | 48);
11933: }
11934: public static String fmtAin24 (int x) {
11935: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11936: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11937: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11938: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11939: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11940: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11941: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11942: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11943: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11944: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11945: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11946: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11947: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11948: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11949: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11950: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11951: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11952: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11953: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11954: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11955: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11956: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11957: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11958: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11959: return String.valueOf (FMT_TEMP, 0, 24);
11960: }
11961: public static String fmtBin24 (int x) {
11962: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11963: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11964: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11965: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11966: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11967: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11968: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11969: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11970: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11971: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11972: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11973: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11974: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11975: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11976: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11977: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11978: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11979: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11980: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11981: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11982: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11983: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11984: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11985: FMT_TEMP[23] = (char) (x & 1 | 48);
11986: return String.valueOf (FMT_TEMP, 0, 24);
11987: }
11988: public static StringBuilder fmtAin24 (StringBuilder sb, int x) {
11989: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11990: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11991: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11992: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11993: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11994: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11995: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11996: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11997: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11998: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11999: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
12000: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
12001: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
12002: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
12003: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
12004: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
12005: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
12006: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
12007: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
12008: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
12009: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
12010: FMT_TEMP[21] = (char) (x & 4 ^ 46);
12011: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
12012: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
12013: return sb.append (FMT_TEMP, 0, 24);
12014: }
12015: public static StringBuilder fmtBin24 (StringBuilder sb, int x) {
12016: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
12017: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
12018: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
12019: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
12020: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
12021: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
12022: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
12023: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
12024: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
12025: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
12026: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
12027: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
12028: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
12029: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
12030: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
12031: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
12032: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
12033: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
12034: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
12035: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
12036: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
12037: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
12038: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
12039: FMT_TEMP[23] = (char) (x & 1 | 48);
12040: return sb.append (FMT_TEMP, 0, 24);
12041: }
12042:
12043:
12044:
12045:
12046:
12047:
12048:
12049:
12050:
12051:
12052:
12053:
12054:
12055:
12056:
12057:
12058:
12059:
12060:
12061:
12062:
12063:
12064:
12065:
12066:
12067:
12068:
12069:
12070:
12071:
12072:
12073:
12074:
12075: public static char fmtHexc (int x) {
12076: x &= 15;
12077: return (char) ((((9 - x) >> 4) & 7) + 48 + x);
12078: }
12079: public static void fmtHex1 (char[] a, int o, int x) {
12080: x &= 15;
12081: a[o] = (char) ((((9 - x) >> 4) & 7) + 48 + x);
12082: }
12083: public static String fmtHex1 (int x) {
12084: x &= 15;
12085: return Character.toString ((char) ((((9 - x) >> 4) & 7) + 48 + x));
12086: }
12087: public static StringBuilder fmtHex1 (StringBuilder sb, int x) {
12088: x &= 15;
12089: return sb.append ((char) ((((9 - x) >> 4) & 7) + 48 + x));
12090: }
12091:
12092:
12093:
12094:
12095:
12096:
12097: public static void fmtHex2 (char[] a, int o, int x) {
12098: int x0 = x & 15;
12099: int x1 = x >>> 4 & 15;
12100: a[o ] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
12101: a[o + 1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
12102: }
12103: public static String fmtHex2 (int x) {
12104:
12105: int x0 = x & 15;
12106: int x1 = x >>> 4 & 15;
12107: FMT_TEMP[0] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
12108: FMT_TEMP[1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
12109: return String.valueOf (FMT_TEMP, 0, 2);
12110: }
12111: public static StringBuilder fmtHex2 (StringBuilder sb, int x) {
12112: int x0 = x & 15;
12113: int x1 = x >>> 4 & 15;
12114: return (sb.
12115: append ((char) ((((9 - x1) >> 4) & 7) + 48 + x1)).
12116: append ((char) ((((9 - x0) >> 4) & 7) + 48 + x0)));
12117: }
12118:
12119:
12120:
12121:
12122:
12123:
12124: public static void fmtHex4 (char[] a, int o, int x) {
12125: int t;
12126: t = (char) x >>> 12;
12127: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12128: t = x >>> 8 & 15;
12129: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12130: t = x >>> 4 & 15;
12131: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12132: t = x & 15;
12133: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12134: }
12135: public static String fmtHex4 (int x) {
12136:
12137: int t;
12138: t = (char) x >>> 12;
12139: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12140: t = x >>> 8 & 15;
12141: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12142: t = x >>> 4 & 15;
12143: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12144: t = x & 15;
12145: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12146: return String.valueOf (FMT_TEMP, 0, 4);
12147: }
12148: public static StringBuilder fmtHex4 (StringBuilder sb, int x) {
12149:
12150: int t;
12151: t = (char) x >>> 12;
12152: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12153: t = x >>> 8 & 15;
12154: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12155: t = x >>> 4 & 15;
12156: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12157: t = x & 15;
12158: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12159: return sb.append (FMT_TEMP, 0, 4);
12160: }
12161:
12162:
12163:
12164:
12165:
12166:
12167: public static void fmtHex6 (char[] a, int o, int x) {
12168: int t;
12169: t = x >>> 20 & 15;
12170: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12171: t = x >>> 16 & 15;
12172: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12173: t = (char) x >>> 12;
12174: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12175: t = x >>> 8 & 15;
12176: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12177: t = x >>> 4 & 15;
12178: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12179: t = x & 15;
12180: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12181: }
12182: public static String fmtHex6 (int x) {
12183:
12184: int t;
12185: t = x >>> 20 & 15;
12186: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12187: t = x >>> 16 & 15;
12188: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12189: t = (char) x >>> 12;
12190: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12191: t = x >>> 8 & 15;
12192: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12193: t = x >>> 4 & 15;
12194: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12195: t = x & 15;
12196: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12197: return String.valueOf (FMT_TEMP, 0, 6);
12198: }
12199: public static StringBuilder fmtHex6 (StringBuilder sb, int x) {
12200:
12201: int t;
12202: t = x >>> 20 & 15;
12203: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12204: t = x >>> 16 & 15;
12205: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12206: t = (char) x >>> 12;
12207: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12208: t = x >>> 8 & 15;
12209: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12210: t = x >>> 4 & 15;
12211: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12212: t = x & 15;
12213: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12214: return sb.append (FMT_TEMP, 0, 6);
12215: }
12216:
12217:
12218:
12219:
12220:
12221:
12222: public static void fmtHex8 (char[] a, int o, int x) {
12223: int t;
12224: t = x >>> 28;
12225: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12226: t = x >>> 24 & 15;
12227: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12228: t = x >>> 20 & 15;
12229: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12230: t = x >>> 16 & 15;
12231: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12232: t = (char) x >>> 12;
12233: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12234: t = x >>> 8 & 15;
12235: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12236: t = x >>> 4 & 15;
12237: a[o + 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12238: t = x & 15;
12239: a[o + 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12240: }
12241: public static String fmtHex8 (int x) {
12242:
12243: int t;
12244: t = x >>> 28;
12245: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12246: t = x >>> 24 & 15;
12247: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12248: t = x >>> 20 & 15;
12249: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12250: t = x >>> 16 & 15;
12251: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12252: t = (char) x >>> 12;
12253: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12254: t = x >>> 8 & 15;
12255: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12256: t = x >>> 4 & 15;
12257: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12258: t = x & 15;
12259: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12260: return String.valueOf (FMT_TEMP, 0, 8);
12261: }
12262: public static StringBuilder fmtHex8 (StringBuilder sb, int x) {
12263:
12264: int t;
12265: t = x >>> 28;
12266: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12267: t = x >>> 24 & 15;
12268: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12269: t = x >>> 20 & 15;
12270: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12271: t = x >>> 16 & 15;
12272: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12273: t = (char) x >>> 12;
12274: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12275: t = x >>> 8 & 15;
12276: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12277: t = x >>> 4 & 15;
12278: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12279: t = x & 15;
12280: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12281: return sb.append (FMT_TEMP, 0, 8);
12282: }
12283:
12284: public static StringBuilder fmtHex16 (StringBuilder sb, long x) {
12285:
12286: int s, t;
12287: s = (int) (x >>> 32);
12288: t = s >>> 28;
12289: FMT_TEMP[ 0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12290: t = s >>> 24 & 15;
12291: FMT_TEMP[ 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12292: t = s >>> 20 & 15;
12293: FMT_TEMP[ 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12294: t = s >>> 16 & 15;
12295: FMT_TEMP[ 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12296: t = (char) s >>> 12;
12297: FMT_TEMP[ 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12298: t = s >>> 8 & 15;
12299: FMT_TEMP[ 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12300: t = s >>> 4 & 15;
12301: FMT_TEMP[ 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12302: t = s & 15;
12303: FMT_TEMP[ 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12304: s = (int) x;
12305: t = s >>> 28;
12306: FMT_TEMP[ 8] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12307: t = s >>> 24 & 15;
12308: FMT_TEMP[ 9] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12309: t = s >>> 20 & 15;
12310: FMT_TEMP[10] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12311: t = s >>> 16 & 15;
12312: FMT_TEMP[11] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12313: t = (char) s >>> 12;
12314: FMT_TEMP[12] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12315: t = s >>> 8 & 15;
12316: FMT_TEMP[13] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12317: t = s >>> 4 & 15;
12318: FMT_TEMP[14] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12319: t = s & 15;
12320: FMT_TEMP[15] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12321: return sb.append (FMT_TEMP, 0, 16);
12322: }
12323:
12324:
12325:
12326:
12327:
12328:
12329:
12330:
12331:
12332:
12333:
12334:
12335:
12336:
12337:
12338:
12339:
12340:
12341:
12342:
12343:
12344:
12345:
12346:
12347:
12348:
12349:
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: public static final int[] FMT_BCD4 = new int[10000];
12392: public static final int[] FMT_DCB4 = new int[65536];
12393:
12394:
12395:
12396:
12397: public static void fmtInit () {
12398: Arrays.fill (FMT_DCB4, -1);
12399: int i = 0;
12400: int x = 0;
12401: for (int a = 0; a < 10; a++) {
12402: for (int b = 0; b < 10; b++) {
12403: for (int c = 0; c < 10; c++) {
12404: FMT_DCB4[FMT_BCD4[i ] = x ] = i;
12405: FMT_DCB4[FMT_BCD4[i + 1] = x + 1] = i + 1;
12406: FMT_DCB4[FMT_BCD4[i + 2] = x + 2] = i + 2;
12407: FMT_DCB4[FMT_BCD4[i + 3] = x + 3] = i + 3;
12408: FMT_DCB4[FMT_BCD4[i + 4] = x + 4] = i + 4;
12409: FMT_DCB4[FMT_BCD4[i + 5] = x + 5] = i + 5;
12410: FMT_DCB4[FMT_BCD4[i + 6] = x + 6] = i + 6;
12411: FMT_DCB4[FMT_BCD4[i + 7] = x + 7] = i + 7;
12412: FMT_DCB4[FMT_BCD4[i + 8] = x + 8] = i + 8;
12413: FMT_DCB4[FMT_BCD4[i + 9] = x + 9] = i + 9;
12414: i += 10;
12415: x += 1 << 4;
12416: }
12417: x += 6 << 4;
12418: }
12419: x += 6 << 8;
12420: }
12421: }
12422:
12423:
12424:
12425: public static int fmtBcd4 (int x) {
12426:
12427:
12428:
12429:
12430:
12431:
12432:
12433:
12434:
12435: return FMT_BCD4[Math.max (0, Math.min (9999, x))];
12436: }
12437:
12438:
12439:
12440: public static int fmtBcd8 (int x) {
12441: x = Math.max (0, Math.min (99999999, x));
12442:
12443:
12444: int q = (int) ((long) x * 109951163L >>> 40);
12445:
12446: return FMT_BCD4[q] << 16 | FMT_BCD4[x - 10000 * q];
12447: }
12448:
12449:
12450:
12451: public static long fmtBcd12 (long x) {
12452: x = Math.max (0L, Math.min (999999999999L, x));
12453: int q = (int) ((double) x / 100000000.0);
12454: int r = (int) (x - 100000000L * q);
12455:
12456:
12457: int rq = (int) ((long) r * 109951163L >>> 40);
12458:
12459: return (long) FMT_BCD4[q] << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
12460: }
12461:
12462:
12463:
12464: public static long fmtBcd16 (long x) {
12465: x = Math.max (0L, Math.min (9999999999999999L, x));
12466: int q = x <= (1L << 53) ? (int) ((double) x / 100000000.0) : (int) (x / 100000000L);
12467: int r = (int) (x - 100000000L * q);
12468:
12469:
12470: int qq = (int) ((long) q * 109951163L >>> 40);
12471:
12472:
12473:
12474: int rq = (int) ((long) r * 109951163L >>> 40);
12475:
12476: return (long) (FMT_BCD4[qq] << 16 | FMT_BCD4[q - 10000 * qq]) << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
12477: }
12478:
12479:
12480:
12481:
12482:
12483:
12484: public static int fmtCA02u (char[] a, int o, int x) {
12485: if (x < 0 || 99 < x) {
12486: x = 99;
12487: }
12488: x = FMT_BCD4[x];
12489: a[o ] = (char) ('0' | x >>> 4);
12490: a[o + 1] = (char) ('0' | x & 15);
12491: return o + 2;
12492: }
12493: public static StringBuilder fmtSB02u (StringBuilder sb, int x) {
12494: return sb.append (FMT_TEMP, 0, fmtCA02u (FMT_TEMP, 0, x));
12495: }
12496:
12497:
12498:
12499:
12500:
12501: public static int fmtCA2u (char[] a, int o, int x) {
12502: if (x < 0 || 99 < x) {
12503: x = 99;
12504: }
12505: x = FMT_BCD4[x];
12506: if (x <= 0x000f) {
12507: a[o++] = (char) ('0' | x);
12508: } else {
12509: a[o++] = (char) ('0' | x >>> 4);
12510: a[o++] = (char) ('0' | x & 15);
12511: }
12512: return o;
12513: }
12514: public static StringBuilder fmtSB2u (StringBuilder sb, int x) {
12515: return sb.append (FMT_TEMP, 0, fmtCA2u (FMT_TEMP, 0, x));
12516: }
12517:
12518:
12519:
12520:
12521:
12522: public static int fmtCA04u (char[] a, int o, int x) {
12523: if (x < 0 || 9999 < x) {
12524: x = 9999;
12525: }
12526: x = FMT_BCD4[x];
12527: a[o ] = (char) ('0' | x >>> 12);
12528: a[o + 1] = (char) ('0' | x >>> 8 & 15);
12529: a[o + 2] = (char) ('0' | x >>> 4 & 15);
12530: a[o + 3] = (char) ('0' | x & 15);
12531: return o + 4;
12532: }
12533: public static StringBuilder fmtSB04u (StringBuilder sb, int x) {
12534: return sb.append (FMT_TEMP, 0, fmtCA04u (FMT_TEMP, 0, x));
12535: }
12536:
12537:
12538:
12539:
12540:
12541: public static int fmtCA4u (char[] a, int o, int x) {
12542: if (x < 0 || 9999 < x) {
12543: x = 9999;
12544: }
12545: x = FMT_BCD4[x];
12546: if (x <= 0x000f) {
12547: a[o++] = (char) ('0' | x);
12548: } else if (x <= 0x00ff) {
12549: a[o++] = (char) ('0' | x >>> 4);
12550: a[o++] = (char) ('0' | x & 15);
12551: } else if (x <= 0x0fff) {
12552: a[o++] = (char) ('0' | x >>> 8);
12553: a[o++] = (char) ('0' | x >>> 4 & 15);
12554: a[o++] = (char) ('0' | x & 15);
12555: } else {
12556: a[o++] = (char) ('0' | x >>> 12);
12557: a[o++] = (char) ('0' | x >>> 8 & 15);
12558: a[o++] = (char) ('0' | x >>> 4 & 15);
12559: a[o++] = (char) ('0' | x & 15);
12560: }
12561: return o;
12562: }
12563: public static StringBuilder fmtSB4u (StringBuilder sb, int x) {
12564: return sb.append (FMT_TEMP, 0, fmtCA4u (FMT_TEMP, 0, x));
12565: }
12566:
12567:
12568:
12569:
12570:
12571: public static int fmtCA08u (char[] a, int o, int x) {
12572: if (x < 0 || 99999999 < x) {
12573: x = 99999999;
12574: }
12575:
12576:
12577: int h = (int) ((long) x * 109951163L >>> 40);
12578: return fmtCA04u (a, fmtCA04u (a, o, h), x - h * 10000);
12579: }
12580: public static StringBuilder fmtSB08u (StringBuilder sb, int x) {
12581: return sb.append (FMT_TEMP, 0, fmtCA08u (FMT_TEMP, 0, x));
12582: }
12583:
12584:
12585:
12586:
12587:
12588: public static int fmtCA8u (char[] a, int o, int x) {
12589: if (x < 0 || 99999999 < x) {
12590: x = 99999999;
12591: }
12592: if (x <= 9999) {
12593: return fmtCA4u (a, o, x);
12594: } else {
12595:
12596:
12597: int h = (int) ((long) x * 109951163L >>> 40);
12598: return fmtCA04u (a, fmtCA4u (a, o, h), x - h * 10000);
12599: }
12600: }
12601: public static StringBuilder fmtSB8u (StringBuilder sb, int x) {
12602: return sb.append (FMT_TEMP, 0, fmtCA8u (FMT_TEMP, 0, x));
12603: }
12604:
12605:
12606:
12607:
12608:
12609: public static int fmtCAd (char[] a, int o, long x) {
12610: if (x < 0L) {
12611: x = -x;
12612: a[o++] = '-';
12613: }
12614: if (x <= 99999999L) {
12615: return fmtCA8u (a, o, (int) x);
12616: } else if (x <= 9999999999999999L) {
12617: long h = x / 100000000L;
12618: return fmtCA08u (a, fmtCA8u (a, o, (int) h), (int) (x - h * 100000000L));
12619: } else {
12620: long hh = x / 10000000000000000L;
12621: x -= hh * 10000000000000000L;
12622: long h = x / 100000000L;
12623: return fmtCA08u (a, fmtCA08u (a, fmtCA4u (a, o, (int) hh), (int) h), (int) (x - h * 100000000L));
12624: }
12625: }
12626: public static StringBuilder fmtSBd (StringBuilder sb, long x) {
12627: return sb.append (FMT_TEMP, 0, fmtCAd (FMT_TEMP, 0, x));
12628: }
12629:
12630:
12631:
12632:
12633:
12634:
12635: public static int fmtCAnd (char[] a, int o, int n, long x) {
12636: int t = fmtCAd (a, o, x);
12637: n += o;
12638: if (t < n) {
12639: int i = n;
12640: while (o < t) {
12641: a[--i] = a[--t];
12642: }
12643: while (o < i) {
12644: a[--i] = ' ';
12645: }
12646: t = n;
12647: }
12648: return t;
12649: }
12650: public static StringBuilder fmtSBnd (StringBuilder sb, int n, int x) {
12651: return sb.append (FMT_TEMP, 0, fmtCAnd (FMT_TEMP, 0, n, x));
12652: }
12653:
12654:
12655:
12656:
12657:
12658:
12659:
12660:
12661:
12662:
12663:
12664:
12665:
12666: public static int fmtParseInt (String s, int i, int min, int max, int err) {
12667: return fmtParseIntRadix (s, i, min, max, err, 10);
12668: }
12669: public static int fmtParseIntRadix (String s, int i, int min, int max, int err, int radix) {
12670: if (s == null) {
12671: return err;
12672: }
12673: int l = s.length ();
12674: int c = i < l ? s.charAt (i++) : -1;
12675:
12676: while (c == ' ' || c == '\t') {
12677: c = i < l ? s.charAt (i++) : -1;
12678: }
12679:
12680: int n = 0;
12681: if (c == '+') {
12682: c = i < l ? s.charAt (i++) : -1;
12683: } else if (c == '-') {
12684: n = 1;
12685: c = i < l ? s.charAt (i++) : -1;
12686: }
12687:
12688:
12689:
12690:
12691: int o;
12692: int p;
12693: if (c == '$') {
12694: o = 0x07ffffff + n;
12695: p = 15 + n & 15;
12696: radix = 16;
12697: c = i < l ? s.charAt (i++) : -1;
12698: } else if (radix == 16) {
12699: o = 0x07ffffff + n;
12700: p = 15 + n & 15;
12701: } else if (radix == 8) {
12702: o = 0x0fffffff + n;
12703: p = 7 + n & 7;
12704: } else if (radix == 2) {
12705: o = 0x3fffffff + n;
12706: p = 1 + n & 1;
12707: } else {
12708: o = 214748364;
12709: p = 7 + n;
12710: radix = 10;
12711: }
12712:
12713: int x = Character.digit (c, radix);
12714: if (x < 0) {
12715: return err;
12716: }
12717: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12718: while (c >= 0) {
12719: int t = x - o;
12720: if (t > 0 || t == 0 && c > p) {
12721: return err;
12722: }
12723: x = x * radix + c;
12724: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12725: }
12726: if (n != 0) {
12727: x = -x;
12728: }
12729: return min <= x && x <= max ? x : err;
12730: }
12731:
12732:
12733:
12734:
12735:
12736:
12737:
12738:
12739:
12740:
12741: public static long matMax3 (long x1, long x2, long x3) {
12742: return Math.max (Math.max (x1, x2), x3);
12743: }
12744: public static long matMax4 (long x1, long x2, long x3, long x4) {
12745: return Math.max (Math.max (x1, x2), Math.max (x3, x4));
12746: }
12747: public static long matMax5 (long x1, long x2, long x3, long x4, long x5) {
12748: return Math.max (Math.max (Math.max (x1, x2), Math.max (x3, x4)), x5);
12749: }
12750:
12751:
12752:
12753:
12754:
12755: public static long matMin3 (long x1, long x2, long x3) {
12756: return Math.min (Math.min (x1, x2), x3);
12757: }
12758: public static long matMin4 (long x1, long x2, long x3, long x4) {
12759: return Math.min (Math.min (x1, x2), Math.min (x3, x4));
12760: }
12761: public static long matMin5 (long x1, long x2, long x3, long x4, long x5) {
12762: return Math.min (Math.min (Math.min (x1, x2), Math.min (x3, x4)), x5);
12763: }
12764:
12765:
12766:
12767:
12768:
12769:
12770:
12771:
12772:
12773:
12774:
12775:
12776: public static String strEncodeUTF8 (String s) {
12777: StringBuilder sb = new StringBuilder ();
12778: int l = s.length ();
12779: for (int i = 0; i < l; i++) {
12780: int u = s.charAt (i);
12781: if (0xd800 <= u && u <= 0xdbff && i + 1 < l) {
12782: int v = s.charAt (i + 1);
12783: if (0xdc00 <= v && v <= 0xdfff) {
12784: u = 0x10000 + ((u & 0x3ff) << 10) + (v & 0x3ff);
12785: i++;
12786: }
12787: }
12788: if ((u & 0xffffff80) == 0) {
12789: sb.append ((char) u);
12790: } else if ((u & 0xfffff800) == 0) {
12791: u = (0x0000c080 |
12792: (u & 0x000007c0) << 2 |
12793: (u & 0x0000003f));
12794: sb.append ((char) (u >> 8)).append ((char) (u & 0xff));
12795: } else if ((u & 0xffff0000) == 0 && !(0xd800 <= u && u <= 0xdfff)) {
12796: u = (0x00e08080 |
12797: (u & 0x0000f000) << 4 |
12798: (u & 0x00000fc0) << 2 |
12799: (u & 0x0000003f));
12800: sb.append ((char) (u >> 16)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12801: } else if ((u & 0xffe00000) == 0) {
12802: u = (0xf0808080 |
12803: (u & 0x001c0000) << 6 |
12804: (u & 0x0003f000) << 4 |
12805: (u & 0x00000fc0) << 2 |
12806: (u & 0x0000003f));
12807: sb.append ((char) ((u >> 24) & 0xff)).append ((char) ((u >> 16) & 0xff)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12808: } else {
12809: sb.append ((char) 0xef).append ((char) 0xbf).append ((char) 0xbd);
12810: }
12811: }
12812: return sb.toString ();
12813: }
12814:
12815:
12816:
12817:
12818:
12819:
12820:
12821: public static String strDecodeUTF8 (String s) {
12822: StringBuilder sb = new StringBuilder ();
12823: int l = s.length ();
12824: for (int i = 0; i < l; i++) {
12825: int c = s.charAt (i) & 0xff;
12826: for (int k = ((c & 0x80) == 0x00 ? 0 :
12827: (c & 0xe0) == 0xc0 ? 1 :
12828: (c & 0xf0) == 0xe0 ? 2 :
12829: (c & 0xf8) == 0xf0 ? 3 :
12830: -1);
12831: --k >= 0; ) {
12832: c = c << 8 | (i + 1 < l ? s.charAt (++i) & 0xff : 0);
12833: }
12834: int u = ((c & 0xffffff80) == 0x00000000 ? c :
12835: (c & 0xffffe0c0) == 0x0000c080 ? ((c & 0x00001f00) >> 2 |
12836: (c & 0x0000003f)) :
12837: (c & 0xfff0c0c0) == 0x00e08080 ? ((c & 0x000f0000) >> 4 |
12838: (c & 0x00003f00) >> 2 |
12839: (c & 0x0000003f)) :
12840: (c & 0xf8c0c0c0) == 0xf0808080 ? ((c & 0x07000000) >> 6 |
12841: (c & 0x003f0000) >> 4 |
12842: (c & 0x00003f00) >> 2 |
12843: (c & 0x0000003f)) :
12844: 0xfffd);
12845: if (u <= 0x0000ffff) {
12846: sb.append (0xd800 <= u && u <= 0xdfff ? '\ufffd' :
12847: (char) u);
12848: } else if (u <= 0x0010ffff) {
12849: u -= 0x000010000;
12850: sb.append ((char) (0xd800 + ((u >> 10) & 0x3ff))).append ((char) (0xdc00 + (u & 0x3ff)));
12851: }
12852: }
12853: return sb.toString ();
12854: }
12855:
12856:
12857:
12858:
12859:
12860: public static final int[] IsURIChar = {
12861:
12862:
12863: 0b00000000_00000000_00000000_00000000,
12864: 0b00000000_00000110_11111111_11000000,
12865: 0b01111111_11111111_11111111_11100001,
12866: 0b01111111_11111111_11111111_11100010,
12867: };
12868: public static String strEncodeURI (String s) {
12869: s = strEncodeUTF8 (s);
12870: StringBuilder sb = new StringBuilder ();
12871: int l = s.length ();
12872: for (int i = 0; i < l; i++) {
12873: int c = s.charAt (i);
12874: if (c < 0x80 && IsURIChar[c >> 5] << c < 0) {
12875: sb.append ((char) c);
12876: } else {
12877: fmtHex2 (sb.append ('%'), c);
12878: }
12879: }
12880: return sb.toString ();
12881: }
12882:
12883:
12884:
12885:
12886:
12887: public static final byte[] strIsHexChar = {
12888:
12889: -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,
12890: -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,
12891: -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,
12892: -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,
12893: };
12894: public static String strDecodeURI (String s) {
12895: StringBuilder sb = new StringBuilder ();
12896: int l = s.length ();
12897: for (int i = 0; i < l; i++) {
12898: int c = s.charAt (i);
12899: if (c == '%' && i + 2 < l) {
12900: int d = s.charAt (i + 1);
12901: int e = s.charAt (i + 2);
12902: if (d < 0x80 && (d = strIsHexChar[d]) >= 0 &&
12903: e < 0x80 && (e = strIsHexChar[e]) >= 0) {
12904: sb.append ((char) (d << 4 | e));
12905: } else {
12906: sb.append ((char) c);
12907: }
12908: } else {
12909: sb.append ((char) c);
12910: }
12911: }
12912: return sb.toString ();
12913: }
12914:
12915:
12916:
12917:
12918:
12919:
12920:
12921:
12922: public static BufferedImage createImage (int width, int height, String pattern, int... rgbs) {
12923: BufferedImage image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
12924: int[] bitmap = ((DataBufferInt) image.getRaster ().getDataBuffer ()).getData ();
12925: int length = width * height;
12926: for (int i = 0; i < length; i++) {
12927: char c = pattern.charAt (i);
12928: bitmap[i] = rgbs[c < '0' ? 0 : Character.digit (c, 16)];
12929: }
12930: return image;
12931: }
12932:
12933:
12934:
12935: public static ImageIcon createImageIcon (int width, int height, String pattern, int... rgbs) {
12936: return new ImageIcon (createImage (width, height, pattern, rgbs));
12937: }
12938:
12939:
12940:
12941: public static TexturePaint createTexturePaint (int width, int height, String pattern, int... rgbs) {
12942: return new TexturePaint (createImage (width, height, pattern, rgbs), new Rectangle (0, 0, width, height));
12943: }
12944:
12945:
12946:
12947: public static BufferedImage loadImage (String name) {
12948: BufferedImage image = null;
12949: try {
12950: image = ImageIO.read (new File (name));
12951: } catch (Exception e) {
12952: }
12953: return image;
12954: }
12955:
12956:
12957:
12958:
12959: public static boolean saveImage (BufferedImage image, String name) {
12960: return saveImage (image, name, 0.75F);
12961: }
12962: public static boolean saveImage (BufferedImage image, String name, float quality) {
12963: int index = name.lastIndexOf (".");
12964: if (index < 0) {
12965: return false;
12966: }
12967: if (name.substring (index).equalsIgnoreCase (".ico")) {
12968: return saveIcon (name, image);
12969: }
12970: Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix (name.substring (index + 1));
12971: if (!iterator.hasNext ()) {
12972: return false;
12973: }
12974: ImageWriter imageWriter = iterator.next ();
12975: ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam ();
12976: if (imageWriteParam.canWriteCompressed ()) {
12977: imageWriteParam.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);
12978: imageWriteParam.setCompressionQuality (quality);
12979: }
12980: try {
12981: File file = new File (name);
12982: ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream (file);
12983: imageWriter.setOutput (imageOutputStream);
12984: imageWriter.write (null, new IIOImage (image, null, null), imageWriteParam);
12985: imageOutputStream.close ();
12986: } catch (Exception e) {
12987:
12988: return false;
12989: }
12990: return true;
12991: }
12992:
12993:
12994:
12995:
12996:
12997:
12998:
12999:
13000:
13001:
13002:
13003:
13004:
13005:
13006:
13007:
13008:
13009:
13010:
13011:
13012:
13013:
13014:
13015:
13016:
13017:
13018:
13019:
13020:
13021:
13022:
13023:
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: public static boolean saveIcon (String fileName, BufferedImage... arrayImage) {
13066: int iconCount = arrayImage.length;
13067: int[][] arrayPaletTable = new int[iconCount][];
13068: int[] arrayPaletCount = new int[iconCount];
13069: int[] arrayPixelBits = new int[iconCount];
13070: int[] arrayPatternLineSize = new int[iconCount];
13071: int[] arrayMaskLineSize = new int[iconCount];
13072: int[] arrayImageSize = new int[iconCount];
13073: int[] arrayImageOffset = new int[iconCount];
13074: int fileSize = 6 + 16 * iconCount;
13075: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
13076: BufferedImage image = arrayImage[iconNumber];
13077: int width = image.getWidth ();
13078: int height = image.getHeight ();
13079:
13080: int[] paletTable = new int[256];
13081: int paletCount = 0;
13082: countPalet:
13083: for (int y = height - 1; y >= 0; y--) {
13084: for (int x = 0; x < width; x++) {
13085: int rgb = image.getRGB (x, y);
13086: if (rgb >>> 24 != 0xff) {
13087: continue;
13088: }
13089: int l = 0;
13090: int r = paletCount;
13091: while (l < r) {
13092: int m = l + r >> 1;
13093: if (paletTable[m] < rgb) {
13094: l = m + 1;
13095: } else {
13096: r = m;
13097: }
13098: }
13099: if (l == paletCount || paletTable[l] != rgb) {
13100: if (paletCount == 256) {
13101: paletCount = 0;
13102: break countPalet;
13103: }
13104: for (int i = paletCount; i > l; i--) {
13105: paletTable[i] = paletTable[i - 1];
13106: }
13107: paletTable[l] = rgb;
13108: paletCount++;
13109: }
13110: }
13111: }
13112: int pixelBits = (paletCount == 0 ? 24 :
13113: paletCount > 16 ? 8 :
13114: paletCount > 4 ? 4 :
13115: paletCount > 2 ? 2 :
13116: 1);
13117: int patternLineSize = pixelBits * width + 31 >> 5 << 2;
13118: int maskLineSize = width + 31 >> 5 << 2;
13119: int imageSize = 40 + 4 * paletCount + patternLineSize * height + maskLineSize * height;
13120: arrayPaletTable[iconNumber] = paletTable;
13121: arrayPaletCount[iconNumber] = paletCount;
13122: arrayPixelBits[iconNumber] = pixelBits;
13123: arrayPatternLineSize[iconNumber] = patternLineSize;
13124: arrayMaskLineSize[iconNumber] = maskLineSize;
13125: arrayImageSize[iconNumber] = imageSize;
13126: arrayImageOffset[iconNumber] = fileSize;
13127: fileSize += imageSize;
13128: }
13129: byte[] bb = new byte[fileSize];
13130:
13131: ByteArray.byaWiw (bb, 0, 0);
13132: ByteArray.byaWiw (bb, 2, 1);
13133: ByteArray.byaWiw (bb, 4, iconCount);
13134: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
13135: BufferedImage image = arrayImage[iconNumber];
13136: int width = image.getWidth ();
13137: int height = image.getHeight ();
13138: int[] paletTable = arrayPaletTable[iconNumber];
13139: int paletCount = arrayPaletCount[iconNumber];
13140: int pixelBits = arrayPixelBits[iconNumber];
13141: int patternLineSize = arrayPatternLineSize[iconNumber];
13142: int maskLineSize = arrayMaskLineSize[iconNumber];
13143: int imageSize = arrayImageSize[iconNumber];
13144: int imageOffset = arrayImageOffset[iconNumber];
13145:
13146: int o = 6 + 16 * iconNumber;
13147: ByteArray.byaWb (bb, o, width);
13148: ByteArray.byaWb (bb, o + 1, height);
13149: ByteArray.byaWb (bb, o + 2, paletCount);
13150: ByteArray.byaWb (bb, o + 3, 0);
13151: ByteArray.byaWiw (bb, o + 4, 1);
13152: ByteArray.byaWiw (bb, o + 6, pixelBits);
13153: ByteArray.byaWil (bb, o + 8, imageSize);
13154: ByteArray.byaWil (bb, o + 12, imageOffset);
13155:
13156: o = imageOffset;
13157: ByteArray.byaWil (bb, o, 40);
13158: ByteArray.byaWil (bb, o + 4, width);
13159: ByteArray.byaWil (bb, o + 8, height * 2);
13160: ByteArray.byaWiw (bb, o + 12, 1);
13161: ByteArray.byaWiw (bb, o + 14, pixelBits);
13162: ByteArray.byaWil (bb, o + 16, 0);
13163: ByteArray.byaWil (bb, o + 20, 0);
13164: ByteArray.byaWil (bb, o + 24, 0);
13165: ByteArray.byaWil (bb, o + 28, 0);
13166: ByteArray.byaWil (bb, o + 32, paletCount);
13167: ByteArray.byaWil (bb, o + 36, 0);
13168:
13169: o += 40;
13170: for (int i = 0; i < paletCount; i++) {
13171: ByteArray.byaWil (bb, o, paletTable[i] & 0x00ffffff);
13172: o += 4;
13173: }
13174:
13175: for (int y = height - 1; y >= 0; y--) {
13176: for (int x = 0; x < width; x++) {
13177: int rgb = image.getRGB (x, y);
13178: if (rgb >>> 24 != 0xff) {
13179: continue;
13180: }
13181: if (pixelBits == 24) {
13182: bb[o + 3 * x] = (byte) rgb;
13183: bb[o + 3 * x + 1] = (byte) (rgb >> 8);
13184: bb[o + 3 * x + 2] = (byte) (rgb >> 16);
13185: continue;
13186: }
13187: int l = 0;
13188: int r = paletCount;
13189: while (l < r) {
13190: int m = l + r >> 1;
13191: if (paletTable[m] < rgb) {
13192: l = m + 1;
13193: } else {
13194: r = m;
13195: }
13196: }
13197: if (l != 0) {
13198: if (pixelBits == 8) {
13199: bb[o + x] = (byte) l;
13200: } else if (pixelBits == 4) {
13201: bb[o + (x >> 1)] |= (byte) (l << ((~x & 1) << 2));
13202: } else if (pixelBits == 2) {
13203: bb[o + (x >> 2)] |= (byte) (l << ((~x & 3) << 1));
13204: } else {
13205: bb[o + (x >> 3)] |= (byte) (l << (~x & 7));
13206: }
13207: }
13208: }
13209: o += patternLineSize;
13210: }
13211:
13212: for (int y = height - 1; y >= 0; y--) {
13213: for (int x = 0; x < width; x++) {
13214: int rgb = image.getRGB (x, y);
13215: if (rgb >>> 24 != 0xff) {
13216: bb[o + (x >> 3)] |= (byte) (1 << (~x & 7));
13217: }
13218: }
13219: o += maskLineSize;
13220: }
13221: }
13222: return rscPutFile (fileName, bb, 0, fileSize);
13223: }
13224:
13225:
13226:
13227: }
13228:
13229:
13230: