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.util.*;
29: import java.util.function.*;
30: import java.util.regex.*;
31: import java.util.zip.*;
32: import javax.imageio.*;
33: import javax.imageio.stream.*;
34: import javax.swing.*;
35: import javax.swing.event.*;
36: import javax.swing.text.*;
37:
38: public class XEiJ {
39:
40:
41: public static final String PRG_TITLE = "XEiJ (X68000 Emulator in Java)";
42: public static final String PRG_VERSION = "0.25.08.08";
43: public static final String PRG_AUTHOR = "Makoto Kamada";
44: public static final String PRG_WEBPAGE = "https://stdkmd.net/xeij/";
45:
46: public static final String PRG_JAVA_VENDOR = "Oracle Corporation";
47: public static final String PRG_JAVA_VERSION = "24.0.2";
48: public static final String PRG_OS_ARCH = "amd64";
49: public static final String PRG_OS_NAME = "Windows 11";
50:
51:
52:
53:
54:
55:
56:
57: public static final boolean TEST_BIT_0_SHIFT = false;
58: public static final boolean TEST_BIT_1_SHIFT = false;
59: public static final boolean TEST_BIT_2_SHIFT = true;
60: public static final boolean TEST_BIT_3_SHIFT = true;
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78: public static final boolean SHORT_SATURATION_CAST = false;
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90: public static final Charset ISO_8859_1 = Charset.forName ("ISO-8859-1");
91: static {
92: if (false) {
93:
94: StringBuilder sb = new StringBuilder ();
95: for (int i = 0; i < 256; i++) {
96: sb.append ((char) i);
97: }
98: byte[] bb = sb.toString ().getBytes (ISO_8859_1);
99: for (int i = 0; i < 256; i++) {
100: System.out.printf ("%02x %02x %s\n", i, bb[i] & 255, i == (bb[i] & 255) ? "OK" : "ERROR");
101: }
102: }
103: }
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116: public static String prgJavaVendor;
117: public static String prgJavaVersion;
118: public static String prgOsArch;
119: public static String prgOsName;
120: public static boolean prgIsLinux;
121: public static boolean prgIsMac;
122: public static boolean prgIsWindows;
123:
124: public static boolean prgCaseIgnored;
125:
126: public static boolean prgVerbose;
127:
128: public static String[] prgArgs;
129:
130:
131:
132: public static void main (String[] args) {
133:
134: prgArgs = args;
135:
136:
137: SwingUtilities.invokeLater (new Runnable () {
138: @Override public void run () {
139: new XEiJ ();
140: }
141: });
142:
143: }
144:
145:
146:
147: public XEiJ () {
148:
149: prgJavaVendor = System.getProperty ("java.vendor");
150: prgJavaVersion = System.getProperty ("java.version");
151: prgOsArch = System.getProperty ("os.arch");
152: prgOsName = System.getProperty ("os.name");
153: prgIsLinux = 0 <= prgOsName.indexOf ("Linux");
154: prgIsMac = 0 <= prgOsName.indexOf ("Mac");
155: prgIsWindows = 0 <= prgOsName.indexOf ("Windows");
156:
157: System.out.print ("\n" +
158: "-------------------------------------------------\n" +
159: PRG_TITLE + " version " + PRG_VERSION + "\n" +
160: "-------------------------------------------------\n");
161:
162:
163:
164:
165: prgCaseIgnored = new File ("A").equals (new File ("a"));
166: fmtInit ();
167: Multilingual.mlnInit ();
168:
169: System.out.println (Multilingual.mlnJapanese ? "java.vendor は " + prgJavaVendor + " です" :
170: "java.vendor is " + prgJavaVendor);
171: System.out.println (Multilingual.mlnJapanese ? "java.version は " + prgJavaVersion + " です" :
172: "java.version is " + prgJavaVersion);
173: System.out.println (Multilingual.mlnJapanese ? "os.arch は " + prgOsArch + " です" :
174: "os.arch is " + prgOsArch);
175: System.out.println (Multilingual.mlnJapanese ? "os.name は " + prgOsName + " です" :
176: "os.name is " + prgOsName);
177:
178: rbtInit ();
179:
180: Settings.sgsInit ();
181: LnF.lnfInit ();
182: Bubble.bblInit ();
183:
184: CharacterCode.chrInit ();
185:
186: TickerQueue.tkqInit ();
187:
188: RS232CTerminal.trmInit ();
189:
190: xt3Init ();
191: mdlInit ();
192:
193: if (InstructionBreakPoint.IBP_ON) {
194: InstructionBreakPoint.ibpInit ();
195: }
196: if (DataBreakPoint.DBP_ON) {
197: DataBreakPoint.dbpInit ();
198: }
199: busInit ();
200: MainMemory.mmrInit ();
201: ROM.romInit ();
202: CRTC.crtInit ();
203: VideoController.vcnInit ();
204: HD63450.dmaInit ();
205: svsInit ();
206: MC68901.mfpInit ();
207: RP5C15.rtcInit ();
208: sysInit ();
209: if (OPMLog.OLG_ON) {
210: OPMLog.olgInit ();
211: }
212: OPM.opmInit ();
213: ADPCM.pcmInit ();
214: FDC.fdcInit ();
215: HDC.hdcInit ();
216: SPC.spcInit ();
217: Z8530.sccInit ();
218: IOInterrupt.ioiInit ();
219: SpriteScreen.sprInit ();
220: bnkInit ();
221: SRAM.smrInit ();
222:
223: PPI.ppiInit ();
224: PrinterPort.prnInit ();
225: Indicator.indInit ();
226:
227: SlowdownTest.sdtInit ();
228: Keyboard.kbdInit ();
229: CONDevice.conInit ();
230: Mouse.musInit ();
231: pnlInit ();
232: frmInit ();
233:
234: dbgInit ();
235: RegisterList.drpInit ();
236: DisassembleList.ddpInit ();
237: MemoryDumpList.dmpInit ();
238: LogicalSpaceMonitor.atwInit ();
239: PhysicalSpaceMonitor.paaInit ();
240: DebugConsole.dgtInit ();
241: if (BranchLog.BLG_ON) {
242: BranchLog.blgInit ();
243: }
244: if (ProgramFlowVisualizer.PFV_ON) {
245: ProgramFlowVisualizer.pfvInit ();
246: }
247: if (RasterBreakPoint.RBP_ON) {
248: RasterBreakPoint.rbpInit ();
249: }
250: if (ScreenModeTest.SMT_ON) {
251: ScreenModeTest.smtInit ();
252: }
253: if (RootPointerList.RTL_ON) {
254: RootPointerList.rtlInit ();
255: }
256: if (SpritePatternViewer.SPV_ON) {
257: SpritePatternViewer.spvInit ();
258: }
259: if (ATCMonitor.ACM_ON) {
260: ATCMonitor.acmInit ();
261: }
262:
263: SoundSource.sndInit ();
264: FEFunction.fpkInit ();
265: mpuInit ();
266: MC68060.mmuInit ();
267: SoundMonitor.smnInit ();
268: HFS.hfsInit ();
269:
270: GIFAnimation.gifInit ();
271: TextCopy.txcInit ();
272: ButtonFunction.bfnInit ();
273:
274:
275:
276: Settings.sgsMakeMenu ();
277: mdlMakeMenu ();
278: FDC.fdcMakeMenu ();
279: HDC.hdcMakeMenu ();
280: SPC.spcMakeMenu ();
281: mpuMakeMenu ();
282: SRAM.smrMakeMenu ();
283: clpMake ();
284: pnlMake ();
285: mnbMakeMenu ();
286: frmMake ();
287: dbgMakePopup ();
288:
289:
290: final String flags = (
291: "" +
292: (EFPBox.CIR_DEBUG_TRACE ? " EFPBox.CIR_DEBUG_TRACE" : "") +
293: (FDC.FDC_DEBUG_TRACE ? " FDC.FDC_DEBUG_TRACE" : "") +
294: (FEFunction.FPK_DEBUG_TRACE ? " FEFunction.FPK_DEBUG_TRACE" : "") +
295: (HD63450.DMA_DEBUG_TRACE != 0 ? " HD63450.DMA_DEBUG_TRACE" : "") +
296: (HDC.HDC_DEBUG_TRACE ? " HDC.HDC_DEBUG_TRACE" : "") +
297: (HDC.HDC_DEBUG_COMMAND ? " HDC.HDC_DEBUG_COMMAND" : "") +
298: (HFS.HFS_DEBUG_TRACE ? " HFS.HFS_DEBUG_TRACE" : "") +
299: (HFS.HFS_DEBUG_FILE_INFO ? " HFS.HFS_DEBUG_FILE_INFO" : "") +
300: (HFS.HFS_COMMAND_TRACE ? " HFS.HFS_COMMAND_TRACE" : "") +
301: (HFS.HFS_BUFFER_TRACE ? " HFS.HFS_BUFFER_TRACE" : "") +
302: (IOInterrupt.IOI_DEBUG_TRACE ? " IOInterrupt.IOI_DEBUG_TRACE" : "") +
303: (Keyboard.KBD_DEBUG_LED ? " Keyboard.KBD_DEBUG_LED" : "") +
304: (MC68060.MMU_DEBUG_COMMAND ? " MC68060.MMU_DEBUG_COMMAND" : "") +
305: (MC68060.MMU_DEBUG_TRANSLATION ? " MC68060.MMU_DEBUG_TRANSLATION" : "") +
306: (MC68060.MMU_NOT_ALLOCATE_CACHE ? " MC68060.MMU_NOT_ALLOCATE_CACHE" : "") +
307: (RP5C15.RTC_DEBUG_TRACE ? " RP5C15.RTC_DEBUG_TRACE" : "") +
308: (SPC.SPC_DEBUG_ON ? " SPC.SPC_DEBUG_ON" : "") +
309: (Z8530.SCC_DEBUG_ON ? " Z8530.SCC_DEBUG_ON" : "")
310: );
311: if (!"".equals (flags)) {
312: pnlExitFullScreen (true);
313: JOptionPane.showMessageDialog (null, "debug flags:" + flags);
314: }
315:
316:
317:
318:
319: tmrStart ();
320:
321: Keyboard.kbdStart ();
322: Mouse.musStart ();
323: pnlStart ();
324: frmStart ();
325: SoundSource.sndStart ();
326:
327: if (DataBreakPoint.DBP_ON) {
328: DataBreakPoint.dbpStart ();
329: }
330: if (RasterBreakPoint.RBP_ON) {
331: RasterBreakPoint.rbpStart ();
332: }
333: if (ScreenModeTest.SMT_ON) {
334: ScreenModeTest.smtStart ();
335: }
336: if (OPMLog.OLG_ON) {
337: OPMLog.olgStart ();
338: }
339: SoundMonitor.smnStart ();
340: RS232CTerminal.trmStart ();
341: PPI.ppiStart ();
342: PrinterPort.prnStart ();
343: if (BranchLog.BLG_ON) {
344: BranchLog.blgStart ();
345: }
346: if (ProgramFlowVisualizer.PFV_ON) {
347: ProgramFlowVisualizer.pfvStart ();
348: }
349: RegisterList.drpStart ();
350: DisassembleList.ddpStart ();
351: MemoryDumpList.dmpStart ();
352: LogicalSpaceMonitor.atwStart ();
353: PhysicalSpaceMonitor.paaStart ();
354: DebugConsole.dgtStart ();
355: if (RootPointerList.RTL_ON) {
356: RootPointerList.rtlStart ();
357: }
358: if (SpritePatternViewer.SPV_ON) {
359: SpritePatternViewer.spvStart ();
360: }
361: if (ATCMonitor.ACM_ON) {
362: ATCMonitor.acmStart ();
363: }
364: ButtonFunction.bfnStart ();
365:
366: if (Settings.sgsSaveiconValue != null) {
367: String[] a = Settings.sgsSaveiconValue.split (",");
368: if (0 < a.length) {
369: saveIcon (a[0], LnF.LNF_ICON_IMAGES);
370: if (1 < a.length) {
371: saveImage (LnF.LNF_ICON_IMAGE_16, a[1]);
372: if (2 < a.length) {
373: saveImage (LnF.LNF_ICON_IMAGE_32, a[2]);
374: if (3 < a.length) {
375: saveImage (LnF.LNF_ICON_IMAGE_48, a[3]);
376: }
377: }
378: }
379: }
380: prgTini ();
381: return;
382: }
383:
384:
385: mpuReset (-1, -1);
386:
387: pnlBoot2 ();
388:
389: }
390:
391:
392:
393:
394:
395: public static void prgTini () {
396: try {
397: if (OPMLog.OLG_ON) {
398: OPMLog.olgTini ();
399: }
400: ButtonFunction.bfnTini ();
401: TextCopy.txcTini ();
402: GIFAnimation.gifTini ();
403: SoundSource.sndTini ();
404: Keyboard.kbdTini ();
405: Mouse.musTini ();
406: CONDevice.conTini ();
407: PPI.ppiTini ();
408: PrinterPort.prnTini ();
409: FDC.fdcTini ();
410: HDC.hdcTini ();
411: SPC.spcTini ();
412: HFS.hfsTini ();
413: Z8530.sccTini ();
414: CRTC.crtTini ();
415: SpriteScreen.sprTini ();
416: pnlTini ();
417: bnkTini ();
418: ROM.romTini ();
419: xt3Tini ();
420: mdlTini ();
421: SRAM.smrTini ();
422: tmrTini ();
423: busTini ();
424: RS232CTerminal.trmTini ();
425: LnF.lnfTini ();
426: Settings.sgsTini ();
427: } catch (Exception e) {
428: e.printStackTrace ();
429: }
430: System.exit (0);
431: }
432:
433:
434:
435: public static void prgOpenJavaDialog () {
436: pnlExitFullScreen (true);
437: JOptionPane.showMessageDialog (
438: frmFrame,
439: ComponentFactory.createGridPanel (
440: 3,
441: 6,
442: "paddingLeft=6,paddingRight=6",
443: "italic,right;left;left",
444: "italic,center;colSpan=3,widen",
445: "",
446:
447: null,
448: Multilingual.mlnJapanese ? "実行中" : "Running",
449: Multilingual.mlnJapanese ? "推奨" : "Recommended",
450:
451: ComponentFactory.createHorizontalSeparator (),
452:
453: Multilingual.mlnJapanese ? "Java のベンダー" : "Java Vendor",
454: prgJavaVendor,
455: PRG_JAVA_VENDOR,
456:
457: Multilingual.mlnJapanese ? "Java のバージョン" : "Java Version",
458: prgJavaVersion,
459: PRG_JAVA_VERSION,
460:
461: Multilingual.mlnJapanese ? "OS のアーキテクチャ" : "OS Architecture",
462: prgOsArch,
463: PRG_OS_ARCH,
464:
465: Multilingual.mlnJapanese ? "OS の名前" : "OS Name",
466: prgOsName,
467: PRG_OS_NAME
468: ),
469: Multilingual.mlnJapanese ? "Java 実行環境の情報" : "Java runtime environment information",
470: JOptionPane.PLAIN_MESSAGE);
471: }
472:
473:
474:
475: public static void prgOpenAboutDialog () {
476: pnlExitFullScreen (true);
477: JOptionPane.showMessageDialog (
478: frmFrame,
479: ComponentFactory.createGridPanel (
480: 2, 4, "paddingLeft=6,paddingRight=6", "italic,right;left", "", "",
481: Multilingual.mlnJapanese ? "タイトル" : "Title" ,
482: PRG_TITLE,
483: Multilingual.mlnJapanese ? "バージョン" : "Version",
484: PRG_VERSION,
485: Multilingual.mlnJapanese ? "作者" : "Author" ,
486: PRG_AUTHOR,
487: Multilingual.mlnJapanese ? "ウェブページ" : "Webpage",
488: PRG_WEBPAGE
489: ),
490: Multilingual.mlnJapanese ? "バージョン情報" : "Version information",
491: JOptionPane.PLAIN_MESSAGE);
492: }
493:
494:
495:
496: public static void prgOpenXEiJLicenseDialog () {
497: pnlExitFullScreen (true);
498: JOptionPane.showMessageDialog (
499: frmFrame,
500: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_XEiJ.txt"), 550, 300),
501: Multilingual.mlnJapanese ? "XEiJ 使用許諾条件" : "XEiJ License",
502: JOptionPane.PLAIN_MESSAGE);
503: }
504:
505:
506:
507: public static void prgOpenSHARPLicenseDialog () {
508: pnlExitFullScreen (true);
509: JOptionPane.showMessageDialog (
510: frmFrame,
511: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_FSHARP.txt", "Shift_JIS"), 550, 300),
512: Multilingual.mlnJapanese ? "無償公開された X68000 の基本ソフトウェア製品の許諾条件" : "License of the basic software products for X68000 that were distributed free of charge",
513: JOptionPane.PLAIN_MESSAGE);
514: }
515:
516:
517:
518: public static void prgOpenYmfmLicenseDialog () {
519: pnlExitFullScreen (true);
520: JOptionPane.showMessageDialog (
521: frmFrame,
522: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_ymfm.txt"), 550, 300),
523: "ymfm License",
524: JOptionPane.PLAIN_MESSAGE);
525: }
526:
527:
528:
529: public static void prgOpenJSerialCommLicenseDialog () {
530: pnlExitFullScreen (true);
531: JOptionPane.showMessageDialog (
532: frmFrame,
533: ComponentFactory.createVerticalSplitPane (
534: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-APACHE-2.0"), 550, 300),
535: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-LGPL-3.0"), 550, 300)
536: ),
537: "jSerialComm License",
538: JOptionPane.PLAIN_MESSAGE);
539: }
540:
541:
542:
543: public static void prgPrintClass (Object o) {
544: System.out.println (o.toString ());
545:
546: try {
547: Stack<Class<?>> s = new Stack<Class<?>> ();
548: for (Class<?> c = o.getClass (); c != null; c = c.getSuperclass ()) {
549: s.push (c);
550: }
551: for (int i = 0; !s.empty (); i++) {
552: for (int j = 0; j < i; j++) {
553: System.out.print (" ");
554: }
555: System.out.println (s.pop ().getName ());
556: }
557: } catch (Exception e) {
558: }
559: }
560:
561:
562:
563:
564: public static void prgPrintStackTrace () {
565: Exception e = new Exception ();
566: e.fillInStackTrace ();
567: prgPrintStackTraceOf (e);
568: }
569: public static void prgPrintStackTraceOf (Exception e) {
570:
571: System.out.println ("------------------------------------------------");
572: System.out.println (e.toString ());
573: System.out.println ("\t" + e.getMessage ());
574: for (StackTraceElement ste : e.getStackTrace ()) {
575: System.out.println ("\tat " + ste.toString ());
576: }
577: System.out.println ("------------------------------------------------");
578: }
579:
580:
581:
582:
583: public static boolean prgStopDone = false;
584: public static void prgStopOnce () {
585: if (!prgStopDone) {
586: prgStopDone = true;
587: mpuStop (null);
588: }
589: }
590:
591:
592:
593:
594:
595:
596:
597:
598:
599:
600:
601:
602:
603:
604:
605:
606:
607:
608:
609:
610:
611:
612:
613:
614:
615:
616:
617:
618:
619:
620:
621: public static final long TMR_FREQ = 1000000000000L;
622:
623:
624: public static final long TMR_DELAY = 10L;
625: public static final long TMR_INTERVAL = 10L;
626:
627:
628: public static java.util.Timer tmrTimer;
629:
630:
631:
632: public static void tmrStart () {
633: tmrTimer = new java.util.Timer ();
634: }
635:
636:
637:
638: public static void tmrTini () {
639: if (tmrTimer != null) {
640: tmrTimer.cancel ();
641: }
642: }
643:
644:
645:
646:
647:
648:
649:
650:
651:
652:
653:
654:
655:
656:
657:
658:
659:
660:
661:
662:
663:
664:
665:
666:
667:
668:
669:
670:
671:
672:
673:
674:
675:
676:
677:
678: public static final int PNL_BM_OFFSET_BITS = 10;
679: public static final int PNL_BM_WIDTH = 1 << PNL_BM_OFFSET_BITS;
680: public static final int PNL_BM_HEIGHT = 1024;
681:
682:
683: public static final int PNL_ASPECT_KEYS = 4;
684: public static final int PNL_ASPECT_VALUES = 4;
685: public static final int[] PNL_ASPECT_DEFAULT_VALUE = { 0, 0, 0, 3 };
686: public static final String[] PNL_ASPECT_RESOLUTION_NAME = { "256x256", "384x256", "512x512", "768x512" };
687: public static final String[] PNL_ASPECT_SCREEN_NAME = { "4:3", "7:5", "13:9", "3:2" };
688: public static final String[] PNL_ASPECT_PIXEL_NAME = { "8:9", "14:15", "26:27", "1:1" };
689: public static final float[] PNL_ASPECT_SCREEN_RATIO = { 4.0F / 3.0F, 7.0F / 5.0F, 13.0F / 9.0F, 3.0F / 2.0F };
690: public static final float[] PNL_ASPECT_PIXEL_RATIO = { 8.0F / 9.0F, 14.0F / 15.0F, 26.0F / 27.0F, 1.0F / 1.0F };
691: public static final float[][] PNL_ASPECT_MATRIX = {
692: PNL_ASPECT_SCREEN_RATIO,
693: PNL_ASPECT_PIXEL_RATIO,
694: PNL_ASPECT_SCREEN_RATIO,
695: PNL_ASPECT_PIXEL_RATIO,
696: };
697: public static int[] pnlAspectMap;
698: public static float[] pnlAspectTable;
699:
700:
701: public static final int PNL_MIN_WIDTH = 64;
702: public static final int PNL_MIN_HEIGHT = 64;
703: public static int pnlScreenWidth;
704: public static int pnlScreenHeight;
705: public static float pnlStretchMode;
706: public static int pnlStretchWidth;
707:
708: public static boolean PNL_ROTATION_ON = true;
709: public static int pnlRotationMode;
710: public static AffineTransform pnlRotationTransformLeft;
711: public static AffineTransform pnlRotationTransformRight;
712: public static double pnlMatrixL00, pnlMatrixL10, pnlMatrixL01, pnlMatrixL11, pnlMatrixL02, pnlMatrixL12;
713: public static double pnlMatrixR00, pnlMatrixR10, pnlMatrixR01, pnlMatrixR11, pnlMatrixR02, pnlMatrixR12;
714: public static double pnlInverseL00, pnlInverseL10, pnlInverseL01, pnlInverseL11, pnlInverseL02, pnlInverseL12;
715: public static double pnlInverseR00, pnlInverseR10, pnlInverseR01, pnlInverseR11, pnlInverseR02, pnlInverseR12;
716: public static int pnlRotatedWidth;
717: public static int pnlRotatedHeight;
718:
719: public static int pnlZoomWidth;
720: public static int pnlZoomHeight;
721: public static int pnlZoomRatioOutX;
722: public static int pnlZoomRatioOutY;
723: public static int pnlZoomRatioInX;
724: public static int pnlZoomRatioInY;
725: public static int pnlWidth;
726: public static int pnlHeight;
727: public static Dimension pnlSize;
728: public static int pnlScreenX1;
729: public static int pnlScreenX2;
730: public static int pnlScreenX3;
731: public static int pnlScreenX4;
732: public static int pnlScreenY1;
733: public static int pnlScreenY2;
734: public static int pnlScreenY3;
735: public static int pnlScreenY4;
736: public static int pnlKeyboardX;
737: public static int pnlKeyboardY;
738: public static int pnlMinimumWidth;
739: public static int pnlMinimumHeight;
740: public static int pnlGlobalX;
741: public static int pnlGlobalY;
742:
743:
744: public static final boolean PNL_FILL_BACKGROUND = true;
745: public static boolean pnlFillBackgroundRequest;
746: public static boolean pnlIsFullScreenSupported;
747: public static boolean pnlPrevKeyboardOn;
748: public static boolean pnlHideKeyboard;
749:
750:
751:
752:
753:
754: public static Object pnlInterpolation;
755:
756:
757: public static final double PNL_MIN_RATE = 1.0;
758: public static final double PNL_MAX_RATE = 1000.0;
759: public static final double PNL_DEFAULT_RATE = 59.94;
760: public static double pnlRefreshRate;
761: public static double pnlFixedRate;
762: public static boolean pnlAdjustVsync;
763:
764:
765:
766:
767:
768:
769:
770:
771:
772:
773:
774:
775:
776:
777:
778:
779:
780:
781:
782:
783:
784:
785:
786:
787:
788:
789:
790:
791:
792:
793:
794:
795:
796:
797:
798:
799:
800:
801:
802:
803:
804:
805:
806:
807:
808:
809:
810:
811:
812: public static final boolean PNL_STEREOSCOPIC_ON = true;
813:
814: public static final boolean PNL_USE_THREAD = true;
815:
816: public static BufferedImage[] pnlScreenImageLeftArray;
817: public static BufferedImage[] pnlScreenImageRightArray;
818:
819: public static BufferedImage[] pnlScreenSubImageLeftArray;
820: public static BufferedImage[] pnlScreenSubImageRightArray;
821:
822: public static int[][] pnlBMLeftArray;
823: public static int[][] pnlBMRightArray;
824: public static volatile int pnlBMWrite;
825: public static volatile int pnlBMRead;
826:
827: public static BufferedImage pnlScreenImageLeft;
828: public static BufferedImage pnlScreenImageRight;
829:
830: public static BufferedImage pnlScreenSubImageLeft;
831: public static BufferedImage pnlScreenSubImageRight;
832:
833: public static int[] pnlBMLeft;
834: public static int[] pnlBMRight;
835:
836: public static int[] pnlBM;
837: public static boolean pnlStereoscopicOn;
838: public static final int PNL_NAKED_EYE_CROSSING = 0;
839: public static final int PNL_NAKED_EYE_PARALLEL = 1;
840: public static final int PNL_SIDE_BY_SIDE = 2;
841: public static final int PNL_TOP_AND_BOTTOM = 3;
842: public static int pnlStereoscopicMethod;
843: public static int pnlStereoscopicFactor;
844: public static int pnlStereoscopicShutter;
845:
846:
847: public static JPanel pnlPanel;
848:
849: public static Thread pnlThread;
850: public static long pnlWakeupTime;
851: public static long pnlWakeupTimeMNP;
852: public static final boolean PNL_USE_CANVAS = PNL_USE_THREAD && true;
853:
854: public static boolean pnlUseCanvasRequest;
855: public static boolean pnlUseCanvas;
856: public static Canvas pnlCanvas;
857: public static Component pnlCanvasOrPanel;
858:
859:
860:
861:
862: public static int pnlFixedScale;
863: public static SpinnerNumberModel pnlFixedModel;
864: public static JSpinner pnlFixedSpinner;
865:
866:
867:
868: public static void pnlInit () {
869: pnlInit2 ();
870:
871:
872:
873:
874: pnlFixedScale = Math.max (10, Math.min (1000, Settings.sgsGetInt ("fixedscale")));
875:
876:
877: pnlAspectMap = new int[PNL_ASPECT_KEYS];
878: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
879: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[key];
880: String screenName = Settings.sgsGetString ("aspectratio" + resolutionName);
881: int value = PNL_ASPECT_DEFAULT_VALUE[key];
882: for (int tempValue = 0; tempValue < PNL_ASPECT_VALUES; tempValue++) {
883: if (PNL_ASPECT_SCREEN_NAME[tempValue].equals (screenName)) {
884: value = tempValue;
885: break;
886: }
887: }
888: pnlAspectMap[key] = value;
889: }
890: pnlAspectTable = new float[8];
891: pnlUpdateAspectTable ();
892:
893:
894: switch (Settings.sgsGetString ("interpolation").toLowerCase ()) {
895: case "nearest":
896: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
897: break;
898: case "bilinear":
899: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
900: break;
901: case "bicubic":
902: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
903: break;
904: default:
905: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
906: }
907:
908:
909: pnlRefreshRate = 0.0;
910: {
911: String s = Settings.sgsGetString ("refreshrate");
912: if (!s.equals ("")) {
913: try {
914: double rate = Double.parseDouble (s);
915: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
916: pnlRefreshRate = rate;
917: }
918: } catch (NumberFormatException nfe) {
919: }
920: }
921: }
922: pnlFixedRate = pnlRefreshRate;
923: pnlAdjustVsync = Settings.sgsGetOnOff ("adjustvsync");
924:
925: pnlPrevKeyboardOn = true;
926:
927: pnlHideKeyboard = Settings.sgsGetOnOff ("hidekeyboard");
928:
929:
930: if (PNL_USE_THREAD) {
931: pnlScreenImageLeftArray = new BufferedImage[4];
932: pnlScreenImageRightArray = new BufferedImage[4];
933: if (PNL_ROTATION_ON) {
934: pnlScreenSubImageLeftArray = new BufferedImage[4];
935: pnlScreenSubImageRightArray = new BufferedImage[4];
936: }
937: pnlBMLeftArray = new int[4][];
938: pnlBMRightArray = new int[4][];
939: for (int n = 0; n < 4; n++) {
940: pnlScreenImageLeftArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
941: pnlScreenImageRightArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
942: if (PNL_ROTATION_ON) {
943: pnlScreenSubImageLeftArray[n] = null;
944: pnlScreenSubImageRightArray[n] = null;
945: }
946: pnlBMLeftArray[n] = ((DataBufferInt) pnlScreenImageLeftArray[n].getRaster ().getDataBuffer ()).getData ();
947: pnlBMRightArray[n] = ((DataBufferInt) pnlScreenImageRightArray[n].getRaster ().getDataBuffer ()).getData ();
948: }
949: pnlBMWrite = 0;
950: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
951: pnlBMRead = 0;
952: pnlThread = null;
953: pnlWakeupTime = 0L;
954: pnlWakeupTimeMNP = 0L;
955: if (PNL_USE_CANVAS) {
956: pnlUseCanvasRequest = Settings.sgsGetOnOff ("usecanvas");
957: pnlUseCanvas = pnlUseCanvasRequest;
958: pnlCanvas = null;
959: }
960: } else {
961: pnlScreenImageLeft = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
962: pnlScreenImageRight = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
963: if (PNL_ROTATION_ON) {
964: pnlScreenSubImageLeft = null;
965: pnlScreenSubImageRight = null;
966: }
967: pnlBMLeft = ((DataBufferInt) pnlScreenImageLeft.getRaster ().getDataBuffer ()).getData ();
968: pnlBMRight = ((DataBufferInt) pnlScreenImageRight.getRaster ().getDataBuffer ()).getData ();
969: pnlBM = pnlBMLeft;
970: }
971: pnlStereoscopicOn = Settings.sgsGetOnOff ("stereoscopic");
972: switch (Settings.sgsGetString ("stereoscopicmethod").toLowerCase ()) {
973: case "nakedeyecrossing":
974: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
975: break;
976: case "nakedeyeparallel":
977: pnlStereoscopicMethod = PNL_NAKED_EYE_PARALLEL;
978: break;
979: case "sidebyside":
980: pnlStereoscopicMethod = PNL_SIDE_BY_SIDE;
981: break;
982: case "topandbottom":
983: pnlStereoscopicMethod = PNL_TOP_AND_BOTTOM;
984: break;
985: default:
986: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
987: }
988: pnlStereoscopicFactor = pnlStereoscopicOn && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
989: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
990: pnlStereoscopicShutter = 0;
991:
992:
993: pnlScreenWidth = 768;
994: pnlScreenHeight = 512;
995: pnlStretchMode = 1.0F;
996: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchMode);
997:
998: if (PNL_ROTATION_ON) {
999: pnlRotationMode = Settings.sgsGetInt ("rotation", 0);
1000: if (pnlRotationMode < 0 || 3 < pnlRotationMode) {
1001: pnlRotationMode = 0;
1002: }
1003: pnlRotationTransformLeft = new AffineTransform ();
1004: pnlRotationTransformRight = new AffineTransform ();
1005: }
1006: pnlRotatedWidth = pnlStretchWidth;
1007: pnlRotatedHeight = pnlScreenHeight;
1008: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1009: pnlRotatedWidth = pnlScreenHeight;
1010: pnlRotatedHeight = pnlStretchWidth;
1011: }
1012:
1013: pnlZoomWidth = pnlRotatedWidth;
1014: pnlZoomHeight = pnlRotatedHeight;
1015: pnlWidth = Math.max (pnlZoomWidth * pnlStereoscopicFactor, Keyboard.kbdWidth);
1016: pnlHeight = pnlZoomHeight + Keyboard.kbdHeight;
1017: pnlSize = new Dimension (pnlWidth, pnlHeight);
1018: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1019: pnlScreenY1 = 0;
1020: pnlArrangementCommon ();
1021: pnlMinimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
1022: pnlMinimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
1023: pnlGlobalX = 0;
1024: pnlGlobalY = 0;
1025:
1026:
1027: if (!PNL_FILL_BACKGROUND) {
1028: pnlFillBackgroundRequest = true;
1029: }
1030:
1031:
1032: pnlFixedModel = new SpinnerNumberModel (pnlFixedScale, 10, 1000, 1);
1033: pnlFixedSpinner = ComponentFactory.createNumberSpinner (pnlFixedModel, 4, new ChangeListener () {
1034: @Override public void stateChanged (ChangeEvent ce) {
1035: if (pnlMode != PNL_FIXEDSCALE) {
1036: pnlSetMode (PNL_FIXEDSCALE);
1037: } else {
1038: pnlUpdateArrangement ();
1039: }
1040: }
1041: });
1042:
1043: }
1044:
1045:
1046:
1047: public static double pnlGetRefreshRate () {
1048: double rate = 0.0;
1049: GraphicsConfiguration gc = frmFrame.getGraphicsConfiguration ();
1050: if (gc != null) {
1051: GraphicsDevice gd = gc.getDevice ();
1052: DisplayMode dm = gd.getDisplayMode ();
1053: int i = dm.getRefreshRate ();
1054: if (i != DisplayMode.REFRESH_RATE_UNKNOWN) {
1055: rate = (i == 23 ? 23.98 :
1056: i == 29 ? 29.97 :
1057: i == 59 ? 59.94 :
1058: i == 119 ? 119.88 :
1059: i == 239 ? 239.76 :
1060: (double) i);
1061: if (rate < PNL_MIN_RATE || PNL_MAX_RATE < rate) {
1062: rate = 0.0;
1063: }
1064: }
1065: }
1066: if (rate == 0.0) {
1067: rate = PNL_DEFAULT_RATE;
1068: System.out.printf (Multilingual.mlnJapanese ?
1069: "ホストのリフレッシュレートを取得できません。デフォルトの %.2f Hz を使います\n" :
1070: "Cannot get host refresh rate. Use default %.2f Hz\n", rate);
1071: } else {
1072: System.out.printf (Multilingual.mlnJapanese ?
1073: "ホストのリフレッシュレートは %.2f Hz です\n" :
1074: "Host refresh rate is %.2f Hz\n", rate);
1075: }
1076: return rate;
1077: }
1078:
1079:
1080: public static void pnlSetStereoscopic (boolean on, int method) {
1081: if (pnlStereoscopicOn != on || pnlStereoscopicMethod != method) {
1082: pnlStereoscopicMethod = method;
1083: pnlStereoscopicFactor = on && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1084: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1085: if (!pnlStereoscopicOn && on) {
1086: if (PNL_USE_THREAD) {
1087: for (int n = 0; n < 4; n++) {
1088: System.arraycopy (pnlBMLeftArray[n], 0, pnlBMRightArray[n], 0, 1024 * 1024);
1089: }
1090: } else {
1091: System.arraycopy (pnlBMLeft, 0, pnlBMRight, 0, 1024 * 1024);
1092: }
1093: } else if (pnlStereoscopicOn && !on) {
1094: if (PNL_USE_THREAD) {
1095: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
1096: } else {
1097: pnlBM = pnlBMLeft;
1098: }
1099: }
1100: pnlStereoscopicOn = on;
1101: pnlUpdateArrangement ();
1102: }
1103: }
1104:
1105:
1106: public static void pnlTini () {
1107: pnlTini2 ();
1108: if (PNL_USE_THREAD) {
1109: if (pnlThread != null) {
1110: pnlThread.interrupt ();
1111: try {
1112: pnlThread.join ();
1113: } catch (InterruptedException ie) {
1114: }
1115: pnlThread = null;
1116: }
1117: }
1118:
1119:
1120: Settings.sgsPutInt ("fixedscale", pnlFixedScale);
1121:
1122:
1123: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
1124: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[key];
1125: int value = pnlAspectMap[key];
1126: String screenName = PNL_ASPECT_SCREEN_NAME[value];
1127: Settings.sgsPutString ("aspectratio" + resolutionName, screenName);
1128: }
1129:
1130:
1131: Settings.sgsPutString ("interpolation",
1132: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR ? "nearest" :
1133: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR ? "bilinear" :
1134: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC ? "bicubic" :
1135: "bilinear");
1136:
1137: if (pnlRefreshRate != PNL_DEFAULT_RATE) {
1138: Settings.sgsPutString ("refreshrate",
1139: pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate));
1140: }
1141: Settings.sgsPutOnOff ("adjustvsync", pnlAdjustVsync);
1142:
1143: Settings.sgsPutOnOff ("hidekeyboard", pnlHideKeyboard);
1144:
1145: if (PNL_USE_CANVAS) {
1146: Settings.sgsPutOnOff ("usecanvas", pnlUseCanvasRequest);
1147: }
1148:
1149:
1150: Settings.sgsPutOnOff ("stereoscopic", pnlStereoscopicOn);
1151: Settings.sgsPutString ("stereoscopicmethod",
1152: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ? "nakedeyecrossing" :
1153: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL ? "nakedeyeparallel" :
1154: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ? "sidebyside" :
1155: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM ? "topandbottom" :
1156: "nakedeyecrossing");
1157:
1158:
1159: if (PNL_ROTATION_ON) {
1160: Settings.sgsPutInt ("rotation", pnlRotationMode);
1161: }
1162:
1163: }
1164:
1165:
1166:
1167: public static void pnlUpdateAspectTable () {
1168: float[] ratio = new float[PNL_ASPECT_KEYS];
1169: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
1170: int value = pnlAspectMap[key];
1171: ratio[key] = PNL_ASPECT_MATRIX[key][value];
1172: }
1173: pnlAspectTable[0] = ratio[0] * 2.0F;
1174: pnlAspectTable[1] = ratio[2];
1175: pnlAspectTable[2] = ratio[3];
1176: pnlAspectTable[3] = ratio[3];
1177: pnlAspectTable[4] = ratio[1] * 4.0F;
1178: pnlAspectTable[5] = ratio[1] * 2.0F;
1179: pnlAspectTable[6] = ratio[3];
1180: pnlAspectTable[7] = ratio[3];
1181: }
1182:
1183:
1184:
1185: public static void pnlMake () {
1186: pnlMake2 ();
1187:
1188:
1189: if (PNL_USE_CANVAS && pnlUseCanvas) {
1190: pnlCanvas = new Canvas ();
1191: pnlPanel = new JPanel (new BorderLayout (0, 0));
1192: pnlPanel.add (pnlCanvas, BorderLayout.CENTER);
1193: pnlCanvasOrPanel = pnlCanvas;
1194: } else {
1195: pnlPanel = new JPanel () {
1196: @Override protected void paintComponent (Graphics g) {
1197: pnlPaintCommon (g);
1198: }
1199: @Override protected void paintBorder (Graphics g) {
1200: }
1201: @Override protected void paintChildren (Graphics g) {
1202: }
1203: };
1204: pnlCanvasOrPanel = pnlPanel;
1205: }
1206: pnlPanel.setBackground (Color.black);
1207: pnlPanel.setOpaque (true);
1208: pnlPanel.setPreferredSize (pnlSize);
1209:
1210: if (Mouse.musCursorAvailable) {
1211: pnlPanel.setCursor (Mouse.musCursorArray[1]);
1212: }
1213:
1214: }
1215:
1216:
1217:
1218: public static void pnlPaintCommon (Graphics g) {
1219: Graphics2D g2 = (Graphics2D) g;
1220: if (PNL_FILL_BACKGROUND || pnlFillBackgroundRequest) {
1221: if (!PNL_FILL_BACKGROUND) {
1222: pnlFillBackgroundRequest = false;
1223: }
1224: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1225: g2.setColor (Color.black);
1226: g2.fillRect (0, 0, pnlWidth, pnlHeight);
1227: }
1228: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, pnlInterpolation);
1229: if (PNL_USE_THREAD) {
1230: int d = pnlBMWrite - pnlBMRead;
1231: if (false) {
1232: System.out.print (d);
1233: }
1234: if (d < 1) {
1235: pnlBMRead += d - 1;
1236: } else if (3 < d) {
1237: pnlBMRead += d - 3;
1238: }
1239: int n = pnlBMRead++ & 3;
1240: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1241: BufferedImage leftImage;
1242: BufferedImage rightImage;
1243: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1244: leftImage = pnlScreenImageRightArray[n];
1245: rightImage = pnlScreenImageLeftArray[n];
1246: } else {
1247:
1248:
1249:
1250: leftImage = pnlScreenImageLeftArray[n];
1251: rightImage = pnlScreenImageRightArray[n];
1252: }
1253: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1254: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1255: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1256: } else {
1257: g2.drawImage (leftImage,
1258: pnlScreenX1, pnlScreenY1,
1259: pnlScreenX2, pnlScreenY2,
1260: 0, 0, pnlScreenWidth, pnlScreenHeight,
1261: null);
1262: g2.drawImage (rightImage,
1263: pnlScreenX3, pnlScreenY3,
1264: pnlScreenX4, pnlScreenY4,
1265: 0, 0, pnlScreenWidth, pnlScreenHeight,
1266: null);
1267: }
1268: } else {
1269: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1270: g2.drawImage (pnlScreenSubImageLeftArray[n], pnlRotationTransformLeft, null);
1271: } else {
1272: g2.drawImage (pnlScreenImageLeftArray[n],
1273: pnlScreenX1, pnlScreenY1,
1274: pnlScreenX2, pnlScreenY2,
1275: 0, 0, pnlScreenWidth, pnlScreenHeight,
1276: null);
1277: }
1278: }
1279: } else {
1280: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1281: BufferedImage leftImage;
1282: BufferedImage rightImage;
1283: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1284: leftImage = pnlScreenImageRight;
1285: rightImage = pnlScreenImageLeft;
1286: } else {
1287:
1288:
1289:
1290: leftImage = pnlScreenImageLeft;
1291: rightImage = pnlScreenImageRight;
1292: }
1293: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1294: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1295: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1296: } else {
1297: g2.drawImage (leftImage,
1298: pnlScreenX1, pnlScreenY1,
1299: pnlScreenX2, pnlScreenY2,
1300: 0, 0, pnlScreenWidth, pnlScreenHeight,
1301: null);
1302: g2.drawImage (rightImage,
1303: pnlScreenX3, pnlScreenY3,
1304: pnlScreenX4, pnlScreenY4,
1305: 0, 0, pnlScreenWidth, pnlScreenHeight,
1306: null);
1307: }
1308: } else {
1309: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1310: g2.drawImage (pnlScreenImageLeft, pnlRotationTransformLeft, null);
1311: } else {
1312: g2.drawImage (pnlScreenImageLeft,
1313: pnlScreenX1, pnlScreenY1,
1314: pnlScreenX2, pnlScreenY2,
1315: 0, 0, pnlScreenWidth, pnlScreenHeight,
1316: null);
1317: }
1318: }
1319: }
1320: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1321: g2.drawImage (Keyboard.kbdImage, pnlKeyboardX, pnlKeyboardY, null);
1322:
1323: if (TextCopy.txcEncloseEachTime && 0 <= TextCopy.txcRow1) {
1324: int x = TextCopy.txcCol1 << 3;
1325: int w = (TextCopy.txcCol2 - TextCopy.txcCol1 + 1) << 3;
1326: int y = TextCopy.txcRow1 << 4;
1327: int h = (TextCopy.txcRow2 - TextCopy.txcRow1 + 1) << 4;
1328: x -= CRTC.crtR10TxXCurr;
1329: y -= CRTC.crtR11TxYCurr;
1330: g2.setColor (Color.red);
1331: if (PNL_ROTATION_ON) {
1332: AffineTransform savedTransform = g2.getTransform ();
1333: g2.setTransform (pnlRotationTransformLeft);
1334: g2.drawRect (x, y, w, h);
1335: g2.setTransform (savedTransform);
1336: } else {
1337: g2.drawRect (pnlScreenX1 + ((x * pnlZoomRatioOutX) >> 16),
1338: pnlScreenY1 + ((y * pnlZoomRatioOutY) >> 16),
1339: ((w * pnlZoomRatioOutX) >> 16) - 1,
1340: ((h * pnlZoomRatioOutY) >> 16) - 1);
1341: }
1342: }
1343: if (Bubble.BBL_ON) {
1344: Bubble.bblDraw (g2);
1345: }
1346: }
1347:
1348:
1349:
1350:
1351: public static void pnlStart () {
1352: pnlStart2 ();
1353:
1354:
1355: ComponentFactory.addListener (
1356: pnlPanel,
1357: new ComponentAdapter () {
1358: @Override public void componentResized (ComponentEvent ce) {
1359: pnlUpdateArrangement ();
1360: }
1361: });
1362:
1363: if (PNL_USE_THREAD) {
1364: if (PNL_USE_CANVAS && pnlUseCanvas) {
1365: pnlCanvas.createBufferStrategy (2);
1366: pnlThread = new Thread () {
1367: @Override public void run () {
1368: do {
1369: BufferStrategy bs = pnlCanvas.getBufferStrategy ();
1370: if (bs != null) {
1371: Graphics g = bs.getDrawGraphics ();
1372: pnlPaintCommon (g);
1373: g.dispose ();
1374: bs.show ();
1375: }
1376: } while (!isInterrupted () && pnlWakeupCommon ());
1377: }
1378: };
1379: } else {
1380: pnlThread = new Thread () {
1381: @Override public void run () {
1382: do {
1383: pnlPanel.repaint ();
1384: if (!pnlWakeupCommon ()) {
1385: break;
1386: }
1387: } while (!isInterrupted () && pnlWakeupCommon ());
1388: }
1389: };
1390: }
1391: pnlWakeupTime = System.currentTimeMillis ();
1392: pnlWakeupTimeMNP = 0L;
1393: pnlThread.start ();
1394: }
1395:
1396: }
1397:
1398: public static boolean pnlWakeupCommon () {
1399: long t = System.currentTimeMillis ();
1400: if (CRTC.crtTotalLength == 0L) {
1401: pnlWakeupTime += 40L;
1402: } else {
1403: pnlWakeupTime += CRTC.crtTotalLength;
1404: pnlWakeupTimeMNP += CRTC.crtTotalLengthMNP;
1405: if (1000000000L <= pnlWakeupTimeMNP) {
1406: pnlWakeupTime++;
1407: pnlWakeupTimeMNP -= 1000000000L;
1408: }
1409: }
1410: pnlWakeupTime = Math.max (pnlWakeupTime, t + 4L);
1411: try {
1412: Thread.sleep (pnlWakeupTime - t);
1413: } catch (InterruptedException ie) {
1414: return false;
1415: }
1416: return true;
1417: }
1418:
1419:
1420:
1421:
1422:
1423: public static void pnlExitFullScreen (boolean dialog) {
1424: if (prgIsMac || !dialog) {
1425: pnlSetFullScreenOn (false);
1426: }
1427: }
1428:
1429:
1430:
1431: public static void pnlToggleFullScreen () {
1432: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1433: pnlSetMode (PNL_FULLSCREEN);
1434: } else {
1435: pnlSetMode (pnlPrevMode);
1436: }
1437: }
1438:
1439:
1440:
1441: public static void pnlToggleMaximized () {
1442: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1443: pnlSetMode (PNL_MAXIMIZED);
1444: } else {
1445: pnlSetMode (pnlPrevMode);
1446: }
1447: }
1448:
1449:
1450:
1451: public static void pnlSetFullScreenOn (boolean on) {
1452: if (on) {
1453: pnlSetMode (PNL_FULLSCREEN);
1454: } else if (pnlMode == PNL_FULLSCREEN) {
1455: pnlSetMode (pnlPrevMode);
1456: }
1457: }
1458:
1459:
1460:
1461:
1462: public static void pnlSetFitInWindowOn (boolean on) {
1463: if (!on) {
1464: pnlSetMode (PNL_FIXEDSCALE);
1465: } else if (pnlMode == PNL_FIXEDSCALE) {
1466: pnlSetMode (PNL_FITINWINDOW);
1467: }
1468: }
1469:
1470:
1471:
1472:
1473:
1474:
1475:
1476:
1477:
1478:
1479: public static void pnlUpdateArrangement () {
1480: pnlWidth = pnlPanel.getWidth ();
1481: pnlHeight = pnlPanel.getHeight ();
1482: frmMarginWidth = frmFrame.getWidth () - pnlWidth;
1483: frmMarginHeight = frmFrame.getHeight () - pnlHeight;
1484: pnlStretchMode = pnlAspectTable[CRTC.crtHRLCurr << 2 | CRTC.crtHResoCurr];
1485: pnlScreenWidth = Math.max (PNL_MIN_WIDTH, (CRTC.crtR03HDispEndCurr - CRTC.crtR02HBackEndCurr) << 3);
1486: pnlScreenHeight = Math.max (PNL_MIN_HEIGHT, (CRTC.crtR07VDispEndCurr - CRTC.crtR06VBackEndCurr) << (CRTC.crtInterlace || CRTC.crtSlit ? 1 : 0));
1487: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchMode);
1488: if (RasterBreakPoint.RBP_ON) {
1489:
1490: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
1491: RasterBreakPoint.rbpUpdateFrame ();
1492: }
1493: }
1494:
1495: pnlFixedScale = pnlFixedModel.getNumber ().intValue ();
1496:
1497: pnlRotatedWidth = pnlStretchWidth;
1498: pnlRotatedHeight = pnlScreenHeight;
1499: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1500: pnlRotatedWidth = pnlScreenHeight;
1501: pnlRotatedHeight = pnlStretchWidth;
1502: }
1503: if (pnlMode == PNL_FIXEDSCALE) {
1504:
1505:
1506:
1507:
1508:
1509: pnlZoomWidth = (pnlRotatedWidth * pnlFixedScale + 50) * 5243 >>> 19;
1510: pnlZoomHeight = (pnlRotatedHeight * pnlFixedScale + 50) * 5243 >>> 19;
1511: int width = Math.max (Math.max (PNL_MIN_WIDTH, pnlZoomWidth * pnlStereoscopicFactor), Keyboard.kbdWidth);
1512: int height = Math.max (PNL_MIN_HEIGHT, pnlZoomHeight) + Keyboard.kbdHeight;
1513: pnlScreenX1 = (width - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1514: pnlScreenY1 = (height - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1515: if (pnlWidth != width || pnlHeight != height) {
1516: pnlWidth = width;
1517: pnlHeight = height;
1518: pnlMinimumWidth = width;
1519: pnlMinimumHeight = height;
1520: pnlSize.setSize (width, height);
1521: pnlPanel.setMinimumSize (pnlSize);
1522: pnlPanel.setMaximumSize (pnlSize);
1523: pnlPanel.setPreferredSize (pnlSize);
1524: }
1525: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1526: frmFrame.setMinimumSize (frmMinimumSize);
1527: frmFrame.setMaximumSize (frmMinimumSize);
1528: frmFrame.setPreferredSize (frmMinimumSize);
1529: frmFrame.setResizable (false);
1530: frmFrame.pack ();
1531: } else {
1532:
1533: if (pnlWidth * pnlRotatedHeight >= (pnlHeight - Keyboard.kbdHeight) * (pnlRotatedWidth * pnlStereoscopicFactor)) {
1534:
1535:
1536:
1537:
1538:
1539:
1540:
1541:
1542:
1543:
1544:
1545:
1546: pnlZoomHeight = pnlHeight - Keyboard.kbdHeight;
1547: pnlZoomWidth = (pnlZoomHeight * pnlRotatedWidth + (pnlRotatedHeight >> 1)) / pnlRotatedHeight;
1548: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1549: pnlScreenX1 = ((pnlWidth >> 1) - (pnlZoomWidth >> 1)) >> 1;
1550: } else {
1551: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1552: }
1553: pnlScreenY1 = 0;
1554: } else {
1555:
1556:
1557:
1558:
1559:
1560:
1561:
1562:
1563:
1564:
1565:
1566:
1567:
1568:
1569:
1570:
1571: pnlZoomWidth = pnlWidth / pnlStereoscopicFactor;
1572: pnlZoomHeight = (pnlZoomWidth * pnlStereoscopicFactor * pnlRotatedHeight + (pnlRotatedWidth * pnlStereoscopicFactor >> 1)) / (pnlRotatedWidth * pnlStereoscopicFactor);
1573: pnlScreenX1 = 0;
1574: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM) {
1575: pnlScreenY1 = (((pnlHeight - Keyboard.kbdHeight) >> 1) - (pnlZoomHeight >> 1)) >> 1;
1576: } else {
1577: pnlScreenY1 = (pnlHeight - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1578: }
1579: }
1580:
1581: int minimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
1582: int minimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
1583: if (pnlMinimumWidth != minimumWidth || pnlMinimumHeight != minimumHeight) {
1584: pnlMinimumWidth = minimumWidth;
1585: pnlMinimumHeight = minimumHeight;
1586: }
1587: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1588: frmFrame.setMinimumSize (frmMinimumSize);
1589: frmFrame.setMaximumSize (null);
1590: frmFrame.setResizable (true);
1591: }
1592:
1593: pnlArrangementCommon ();
1594: Mouse.musUpdateSpeedRatio ();
1595: if (!PNL_FILL_BACKGROUND) {
1596: pnlFillBackgroundRequest = true;
1597: }
1598: }
1599:
1600: public static void pnlArrangementCommon () {
1601: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1602: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1603: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) {
1604: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1605: pnlScreenX3 = pnlScreenX2;
1606: pnlScreenX4 = pnlScreenX3 + pnlZoomWidth;
1607: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1608: pnlScreenY3 = pnlScreenY1;
1609: pnlScreenY4 = pnlScreenY2;
1610: } else if (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1611: pnlScreenX2 = pnlScreenX1 + (pnlZoomWidth >> 1);
1612: pnlScreenX3 = pnlScreenX2;
1613: pnlScreenX4 = pnlScreenX3 + (pnlZoomWidth >> 1);
1614: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1615: pnlScreenY3 = pnlScreenY1;
1616: pnlScreenY4 = pnlScreenY2;
1617: } else {
1618: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1619: pnlScreenX3 = pnlScreenX1;
1620: pnlScreenX4 = pnlScreenX2;
1621: pnlScreenY2 = pnlScreenY1 + (pnlZoomHeight >> 1);
1622: pnlScreenY3 = pnlScreenY2;
1623: pnlScreenY4 = pnlScreenY3 + (pnlZoomHeight >> 1);
1624: }
1625: } else {
1626: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1627: pnlScreenX3 = pnlScreenX1;
1628: pnlScreenX4 = pnlScreenX2;
1629: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1630: pnlScreenY3 = pnlScreenY1;
1631: pnlScreenY4 = pnlScreenY2;
1632: }
1633: pnlKeyboardX = (pnlWidth - Keyboard.kbdWidth) >> 1;
1634: pnlKeyboardY = pnlScreenY4;
1635: pnlZoomRatioOutX = ((pnlZoomWidth * pnlStereoscopicFactor) << 16) / pnlScreenWidth;
1636: pnlZoomRatioOutY = (pnlZoomHeight << 16) / pnlScreenHeight;
1637: pnlZoomRatioInX = (pnlScreenWidth << 16) / (pnlZoomWidth * pnlStereoscopicFactor);
1638: pnlZoomRatioInY = (pnlScreenHeight << 16) / pnlZoomHeight;
1639: if (PNL_ROTATION_ON) {
1640:
1641: if (PNL_USE_THREAD) {
1642: for (int n = 0; n < 4; n++) {
1643: pnlScreenSubImageLeftArray[n] = pnlScreenImageLeftArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1644: pnlScreenSubImageRightArray[n] = pnlScreenImageRightArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1645: }
1646: } else {
1647: pnlScreenSubImageLeft = pnlScreenImageLeft.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1648: pnlScreenSubImageRight = pnlScreenImageRight.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1649: }
1650:
1651:
1652:
1653:
1654: double ax = 0.0;
1655: double ay = 0.0;
1656: double bx = (double) pnlScreenWidth;
1657: double by = (double) pnlScreenHeight;
1658: double l00, l10, l01, l11, l02, l12;
1659: double r00, r10, r01, r11, r02, r12;
1660: if (pnlRotationMode == 0) {
1661: double cx = (double) pnlScreenX1;
1662: double cy = (double) pnlScreenY1;
1663: double dx = (double) pnlScreenX2;
1664: double dy = (double) pnlScreenY2;
1665: l00 = (cx - dx) / (ax - bx);
1666: l10 = 0.0;
1667: l01 = 0.0;
1668: l11 = (cy - dy) / (ay - by);
1669: l02 = (ax * dx - bx * cx) / (ax - bx);
1670: l12 = (ay * dy - by * cy) / (ay - by);
1671: cx = (double) pnlScreenX3;
1672: cy = (double) pnlScreenY3;
1673: dx = (double) pnlScreenX4;
1674: dy = (double) pnlScreenY4;
1675: r00 = (cx - dx) / (ax - bx);
1676: r10 = 0.0;
1677: r01 = 0.0;
1678: r11 = (cy - dy) / (ay - by);
1679: r02 = (ax * dx - bx * cx) / (ax - bx);
1680: r12 = (ay * dy - by * cy) / (ay - by);
1681: } else if (pnlRotationMode == 1) {
1682: double cx = (double) pnlScreenX1;
1683: double cy = (double) pnlScreenY1;
1684: double dx = (double) pnlScreenX2;
1685: double dy = (double) pnlScreenY2;
1686: l00 = 0.0;
1687: l10 = (dy - cy) / (ax - bx);
1688: l01 = (cx - dx) / (ay - by);
1689: l11 = 0.0;
1690: l02 = (ay * dx - by * cx) / (ay - by);
1691: l12 = (ax * cy - bx * dy) / (ax - bx);
1692: cx = (double) pnlScreenX3;
1693: cy = (double) pnlScreenY3;
1694: dx = (double) pnlScreenX4;
1695: dy = (double) pnlScreenY4;
1696: r00 = 0.0;
1697: r10 = (dy - cy) / (ax - bx);
1698: r01 = (cx - dx) / (ay - by);
1699: r11 = 0.0;
1700: r02 = (ay * dx - by * cx) / (ay - by);
1701: r12 = (ax * cy - bx * dy) / (ax - bx);
1702: } else if (pnlRotationMode == 2) {
1703: double cx = (double) pnlScreenX1;
1704: double cy = (double) pnlScreenY1;
1705: double dx = (double) pnlScreenX2;
1706: double dy = (double) pnlScreenY2;
1707: l00 = (dx - cx) / (ax - bx);
1708: l10 = 0.0;
1709: l01 = 0.0;
1710: l11 = (dy - cy) / (ay - by);
1711: l02 = (ax * cx - bx * dx) / (ax - bx);
1712: l12 = (ay * cy - by * dy) / (ay - by);
1713: cx = (double) pnlScreenX3;
1714: cy = (double) pnlScreenY3;
1715: dx = (double) pnlScreenX4;
1716: dy = (double) pnlScreenY4;
1717: r00 = (dx - cx) / (ax - bx);
1718: r10 = 0.0;
1719: r01 = 0.0;
1720: r11 = (dy - cy) / (ay - by);
1721: r02 = (ax * cx - bx * dx) / (ax - bx);
1722: r12 = (ay * cy - by * dy) / (ay - by);
1723: } else {
1724: double cx = (double) pnlScreenX1;
1725: double cy = (double) pnlScreenY1;
1726: double dx = (double) pnlScreenX2;
1727: double dy = (double) pnlScreenY2;
1728: l00 = 0.0;
1729: l10 = (cy - dy) / (ax - bx);
1730: l01 = (dx - cx) / (ay - by);
1731: l11 = 0.0;
1732: l02 = (ay * cx - by * dx) / (ay - by);
1733: l12 = (ax * dy - bx * cy) / (ax - bx);
1734: cx = (double) pnlScreenX3;
1735: cy = (double) pnlScreenY3;
1736: dx = (double) pnlScreenX4;
1737: dy = (double) pnlScreenY4;
1738: r00 = 0.0;
1739: r10 = (cy - dy) / (ax - bx);
1740: r01 = (dx - cx) / (ay - by);
1741: r11 = 0.0;
1742: r02 = (ay * cx - by * dx) / (ay - by);
1743: r12 = (ax * dy - bx * cy) / (ax - bx);
1744: }
1745: pnlRotationTransformLeft.setTransform (l00, l10, l01, l11, l02, l12);
1746: pnlRotationTransformRight.setTransform (r00, r10, r01, r11, r02, r12);
1747: pnlMatrixL00 = l00;
1748: pnlMatrixL10 = l10;
1749: pnlMatrixL01 = l01;
1750: pnlMatrixL11 = l11;
1751: pnlMatrixL02 = l02;
1752: pnlMatrixL12 = l12;
1753: pnlMatrixR00 = r00;
1754: pnlMatrixR10 = r10;
1755: pnlMatrixR01 = r01;
1756: pnlMatrixR11 = r11;
1757: pnlMatrixR02 = r02;
1758: pnlMatrixR12 = r12;
1759:
1760:
1761:
1762:
1763:
1764:
1765: double d = l00 * l11 - l01 * l10;
1766: pnlInverseL00 = l11 / d;
1767: pnlInverseL10 = -l10 / d;
1768: pnlInverseL01 = -l01 / d;
1769: pnlInverseL11 = l00 / d;
1770: pnlInverseL02 = (l01 * l12 - l02 * l11) / d;
1771: pnlInverseL12 = (l02 * l10 - l00 * l12) / d;
1772: d = r00 * r11 - r01 * r10;
1773: pnlInverseR00 = r11 / d;
1774: pnlInverseR10 = -r10 / d;
1775: pnlInverseR01 = -r01 / d;
1776: pnlInverseR11 = r00 / d;
1777: pnlInverseR02 = (r01 * r12 - r02 * r11) / d;
1778: pnlInverseR12 = (r02 * r10 - r00 * r12) / d;
1779: }
1780: }
1781:
1782:
1783:
1784:
1785: public static final int PNL_UNDEFINED = 0;
1786: public static final int PNL_FIXEDSCALE = 1;
1787: public static final int PNL_FITINWINDOW = 2;
1788: public static final int PNL_FULLSCREEN = 3;
1789: public static final int PNL_MAXIMIZED = 4;
1790: public static int pnlModeRequest;
1791: public static int pnlMode;
1792: public static int pnlPrevMode;
1793:
1794:
1795: public static JRadioButtonMenuItem mnbFullScreenMenuItem;
1796: public static JRadioButtonMenuItem mnbMaximizedMenuItem;
1797: public static JRadioButtonMenuItem mnbFitInWindowMenuItem;
1798: public static JRadioButtonMenuItem mnbFixedScaleMenuItem;
1799:
1800:
1801: public static int PNL_BOOT_DELAY = 500;
1802: public static javax.swing.Timer pnlBootTimer;
1803:
1804:
1805:
1806: public static void pnlInit2 () {
1807: pnlModeRequest = PNL_UNDEFINED;
1808: pnlMode = PNL_FITINWINDOW;
1809: pnlPrevMode = PNL_FITINWINDOW;
1810: switch (Settings.sgsGetString ("scaling").toLowerCase ()) {
1811: case "fullscreen":
1812: pnlModeRequest = PNL_FULLSCREEN;
1813: break;
1814: case "maximized":
1815: pnlModeRequest = PNL_MAXIMIZED;
1816: break;
1817: case "fitinwindow":
1818: break;
1819: case "fixedscale":
1820: pnlMode = PNL_FIXEDSCALE;
1821: break;
1822: }
1823: }
1824:
1825:
1826:
1827: public static void pnlTini2 () {
1828: Settings.sgsPutString ("scaling",
1829: pnlMode == PNL_FULLSCREEN ? "fullscreen" :
1830: pnlMode == PNL_MAXIMIZED ? "maximized" :
1831: pnlMode == PNL_FITINWINDOW ? "fitinwindow" :
1832: "fixedscale");
1833: }
1834:
1835:
1836:
1837: public static void pnlMake2 () {
1838:
1839: ActionListener listener = new ActionListener () {
1840: @Override public void actionPerformed (ActionEvent ae) {
1841: String command = ae.getActionCommand ();
1842: switch (command) {
1843: case "Full screen":
1844: pnlSetMode (PNL_FULLSCREEN);
1845: break;
1846: case "Maximized":
1847: pnlSetMode (PNL_MAXIMIZED);
1848: break;
1849: case "Fit in window":
1850: pnlSetMode (PNL_FITINWINDOW);
1851: break;
1852: case "Fixed scale":
1853: pnlSetMode (PNL_FIXEDSCALE);
1854: break;
1855: }
1856: }
1857: };
1858: ButtonGroup group = new ButtonGroup ();
1859: mnbFullScreenMenuItem = ComponentFactory.setEnabled (
1860: Multilingual.mlnText (
1861: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FULLSCREEN, "Full screen", listener),
1862: "ja", "全画面表示"),
1863: pnlIsFullScreenSupported);
1864: mnbMaximizedMenuItem = Multilingual.mlnText (
1865: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_MAXIMIZED, "Maximized", listener),
1866: "ja", "最大化");
1867: mnbFitInWindowMenuItem = Multilingual.mlnText (
1868: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FITINWINDOW, "Fit in window", 'W', MNB_MODIFIERS, listener),
1869: "ja", "ウインドウに合わせる");
1870: mnbFixedScaleMenuItem = Multilingual.mlnText (
1871: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FIXEDSCALE, "Fixed scale", 'X', MNB_MODIFIERS, listener),
1872: "ja", "固定倍率");
1873: }
1874:
1875:
1876:
1877: public static void pnlStart2 () {
1878:
1879: frmFrame.addWindowStateListener (new WindowStateListener () {
1880: @Override public void windowStateChanged (WindowEvent we) {
1881: int state = frmFrame.getExtendedState ();
1882: if (pnlMode != PNL_MAXIMIZED &&
1883: (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
1884: pnlSetMode (PNL_MAXIMIZED);
1885: } else if (pnlMode == PNL_MAXIMIZED &&
1886: (state & Frame.MAXIMIZED_BOTH) != Frame.MAXIMIZED_BOTH) {
1887: pnlSetMode (pnlPrevMode);
1888: }
1889: }
1890: });
1891: }
1892:
1893:
1894:
1895: public static void pnlBoot2 () {
1896: if (pnlModeRequest != PNL_UNDEFINED) {
1897: pnlBootTimer = new javax.swing.Timer (PNL_BOOT_DELAY, new ActionListener () {
1898: public void actionPerformed (ActionEvent ae) {
1899: if (pnlModeRequest == PNL_FULLSCREEN) {
1900: mnbFullScreenMenuItem.doClick ();
1901: } else if (pnlModeRequest == PNL_MAXIMIZED) {
1902: mnbMaximizedMenuItem.doClick ();
1903: }
1904: pnlBootTimer.stop ();
1905: pnlBootTimer = null;
1906: }
1907: });
1908: pnlBootTimer.start ();
1909: }
1910: }
1911:
1912:
1913:
1914: public static void pnlSetMode (int mode) {
1915: do {
1916:
1917: if (pnlMode == mode) {
1918: break;
1919: }
1920:
1921: String text = null;
1922: if (mode == PNL_FULLSCREEN) {
1923: if (!pnlIsFullScreenSupported) {
1924: JOptionPane.showMessageDialog (
1925: frmFrame,
1926: Multilingual.mlnJapanese ?
1927: "全画面表示に対応していません" :
1928: "Full screen is not supported");
1929: break;
1930: }
1931: if (Bubble.BBL_ON) {
1932: text = ButtonFunction.bfnFullScreenText ();
1933: if (text == null) {
1934: JOptionPane.showMessageDialog (
1935: frmFrame,
1936: Multilingual.mlnJapanese ?
1937: "全画面表示を終了するキーまたはボタンがありません" :
1938: "No key or button to exit full screen");
1939: break;
1940: }
1941: }
1942: }
1943:
1944: if (pnlMode == PNL_FULLSCREEN) {
1945: pnlMode = pnlPrevMode;
1946: if (Bubble.BBL_ON) {
1947: Bubble.bblEnd ();
1948: }
1949: if (frmScreenDevice.getFullScreenWindow () == frmFrame) {
1950: frmScreenDevice.setFullScreenWindow (null);
1951: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.FRAME);
1952: }
1953: frmFrame.setJMenuBar (mnbMenuBar);
1954: if (pnlHideKeyboard) {
1955: if (pnlPrevKeyboardOn) {
1956: Keyboard.kbdSetOn (true);
1957: }
1958: }
1959: } else if (pnlMode == PNL_MAXIMIZED) {
1960: pnlMode = pnlPrevMode;
1961: if ((frmFrame.getExtendedState () & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
1962: frmFrame.setExtendedState (Frame.NORMAL);
1963: }
1964: }
1965:
1966: if (mode == PNL_FULLSCREEN) {
1967: pnlPrevMode = pnlMode;
1968: if (pnlHideKeyboard) {
1969: pnlPrevKeyboardOn = Keyboard.kbdImage != null;
1970: if (pnlPrevKeyboardOn) {
1971: Keyboard.kbdSetOn (false);
1972: }
1973: }
1974: frmFrame.setJMenuBar (null);
1975: if (frmScreenDevice.getFullScreenWindow () != frmFrame) {
1976: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.NONE);
1977: frmScreenDevice.setFullScreenWindow (frmFrame);
1978: }
1979: if (Bubble.BBL_ON) {
1980: if (text != null) {
1981: Bubble.bblStart (text + (Multilingual.mlnJapanese ? "で全画面表示を終了" : " to exit full screen"), 5000L);
1982: }
1983: }
1984: } else if (mode == PNL_MAXIMIZED) {
1985: pnlPrevMode = pnlMode;
1986: frmFrame.setExtendedState (Frame.MAXIMIZED_BOTH);
1987: }
1988: pnlMode = mode;
1989:
1990:
1991: pnlUpdateArrangement ();
1992: } while (false);
1993:
1994: if (pnlMode == PNL_FIXEDSCALE) {
1995: if (!mnbFixedScaleMenuItem.isSelected ()) {
1996: mnbFixedScaleMenuItem.setSelected (true);
1997: }
1998: } else if (pnlMode == PNL_FITINWINDOW) {
1999: if (!mnbFitInWindowMenuItem.isSelected ()) {
2000: mnbFitInWindowMenuItem.setSelected (true);
2001: }
2002: } else if (pnlMode == PNL_FULLSCREEN) {
2003: if (!mnbFullScreenMenuItem.isSelected ()) {
2004: mnbFullScreenMenuItem.setSelected (true);
2005: }
2006: } else if (pnlMode == PNL_MAXIMIZED) {
2007: if (!mnbMaximizedMenuItem.isSelected ()) {
2008: mnbMaximizedMenuItem.setSelected (true);
2009: }
2010: }
2011: }
2012:
2013:
2014:
2015:
2016:
2017:
2018: public static Robot rbtRobot;
2019:
2020:
2021: public static void rbtInit () {
2022:
2023:
2024: rbtRobot = null;
2025: try {
2026: rbtRobot = new Robot ();
2027: } catch (Exception e) {
2028: }
2029:
2030: }
2031:
2032:
2033:
2034:
2035:
2036:
2037:
2038: public static final int MNB_MODIFIERS = InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK;
2039:
2040:
2041: public static JMenuBar mnbMenuBar;
2042:
2043:
2044: public static JMenu mnbFileMenu;
2045: public static JMenu mnbDisplayMenu;
2046: public static JMenu mnbSoundMenu;
2047: public static JMenu mnbInputMenu;
2048: public static JMenu mnbConfigMenu;
2049: public static JMenu mnbLanguageMenu;
2050:
2051:
2052:
2053:
2054:
2055: public static JMenuItem mnbQuitMenuItem;
2056: public static JCheckBoxMenuItem mnbStereoscopicMenuItem;
2057: public static JCheckBoxMenuItem mnbPlayMenuItem;
2058: public static JMenuItem mnbPasteMenuItem;
2059: public static JRadioButtonMenuItem mnbStandardKeyboardMenuItem;
2060: public static JRadioButtonMenuItem mnbCompactKeyboardMenuItem;
2061: public static JRadioButtonMenuItem mnbNoKeyboardMenuItem;
2062: public static JLabel mnbVolumeLabel;
2063:
2064:
2065:
2066:
2067:
2068:
2069: public static JMenu mnbMakeFontSizeMenu () {
2070:
2071: ActionListener actionListener = new ActionListener () {
2072: @Override public void actionPerformed (ActionEvent ae) {
2073: String command = ae.getActionCommand ();
2074: switch (command) {
2075: case "Very small":
2076: LnF.lnfFontSizeRequest = 10;
2077: break;
2078: case "Small":
2079: LnF.lnfFontSizeRequest = 12;
2080: break;
2081: case "Medium":
2082: LnF.lnfFontSizeRequest = 14;
2083: break;
2084: case "Large":
2085: LnF.lnfFontSizeRequest = 16;
2086: break;
2087: case "Very large":
2088: LnF.lnfFontSizeRequest = 18;
2089: break;
2090: default:
2091: System.out.println ("unknown action command " + command);
2092: }
2093: }
2094: };
2095:
2096: ButtonGroup fontSizeGroup = new ButtonGroup ();
2097:
2098: return Multilingual.mlnText (
2099: ComponentFactory.createMenu (
2100: "Font size",
2101: Multilingual.mlnText (
2102: ComponentFactory.pointSize (
2103: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 10, "Very small", actionListener),
2104: 10),
2105: "ja", "極小"),
2106: Multilingual.mlnText (
2107: ComponentFactory.pointSize (
2108: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 12, "Small", actionListener),
2109: 12),
2110: "ja", "小"),
2111: Multilingual.mlnText (
2112: ComponentFactory.pointSize (
2113: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 14, "Medium", actionListener),
2114: 14),
2115: "ja", "中"),
2116: Multilingual.mlnText (
2117: ComponentFactory.pointSize (
2118: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 16, "Large", actionListener),
2119: 16),
2120: "ja", "大"),
2121: Multilingual.mlnText (
2122: ComponentFactory.pointSize (
2123: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 18, "Very large", actionListener),
2124: 18),
2125: "ja", "極大")),
2126: "ja", "フォントサイズ");
2127: }
2128:
2129:
2130:
2131: public static final DecimalSpinner[] mnbColorSpinners = new DecimalSpinner[9];
2132: public static final int[] mnbColorRGB = new int[15];
2133: public static JPanel mnbColorPanel;
2134:
2135:
2136:
2137: public static void mnbColorHSBToRGB () {
2138: for (int i = 0; i <= 14; i++) {
2139: int[] t = LnF.LNF_HSB_INTERPOLATION_TABLE[i];
2140: float h = (float) (t[0] * LnF.lnfHSB[0] + t[1] * LnF.lnfHSB[1] + t[2] * LnF.lnfHSB[2]) / (49.0F * 360.0F);
2141: float s = (float) (t[0] * LnF.lnfHSB[3] + t[1] * LnF.lnfHSB[4] + t[2] * LnF.lnfHSB[5]) / (49.0F * 100.0F);
2142: float b = (float) (t[0] * LnF.lnfHSB[6] + t[1] * LnF.lnfHSB[7] + t[2] * LnF.lnfHSB[8]) / (49.0F * 100.0F);
2143: mnbColorRGB[i] = Color.HSBtoRGB (h,
2144: Math.max (0.0F, Math.min (1.0F, s)),
2145: Math.max (0.0F, Math.min (1.0F, b)));
2146: }
2147: }
2148:
2149:
2150:
2151: public static JMenu mnbMakeColorMenu () {
2152: mnbColorHSBToRGB ();
2153:
2154: mnbColorPanel = ComponentFactory.setColor (
2155: ComponentFactory.setFixedSize (
2156: new JPanel () {
2157: @Override protected void paintComponent (Graphics g) {
2158: super.paintComponent (g);
2159: for (int i = 0; i <= 14; i++) {
2160: g.setColor (new Color (mnbColorRGB[i]));
2161: g.fillRect (LnF.lnfFontSize * i, 0, LnF.lnfFontSize, LnF.lnfFontSize * 5);
2162: }
2163: }
2164: },
2165: LnF.lnfFontSize * 15, LnF.lnfFontSize * 5),
2166: Color.white, Color.black);
2167:
2168: ChangeListener changeListener = new ChangeListener () {
2169: @Override public void stateChanged (ChangeEvent ce) {
2170: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
2171: LnF.lnfHSB[spinner.getOption ()] = spinner.getIntValue ();
2172: mnbColorHSBToRGB ();
2173: mnbColorPanel.repaint ();
2174: }
2175: };
2176:
2177: ActionListener actionListener = new ActionListener () {
2178: @Override public void actionPerformed (ActionEvent ae) {
2179: String command = ae.getActionCommand ();
2180: switch (command) {
2181: case "Reset to default values":
2182: for (int i = 0; i < 9; i++) {
2183: LnF.lnfHSB[i] = LnF.LNF_DEFAULT_HSB[i];
2184: mnbColorSpinners[i].setIntValue (LnF.lnfHSB[i]);
2185: }
2186: mnbColorHSBToRGB ();
2187: mnbColorPanel.repaint ();
2188: break;
2189: default:
2190: System.out.println ("unknown action command " + command);
2191: }
2192: }
2193: };
2194:
2195: for (int i = 0; i < 9; i++) {
2196: mnbColorSpinners[i] = ComponentFactory.createDecimalSpinner (
2197: LnF.lnfHSB[i], 0, i < 3 ? 720 : 100, 1, i, changeListener);
2198: }
2199:
2200: return Multilingual.mlnText (
2201: ComponentFactory.createMenu (
2202: "Color",
2203: ComponentFactory.createHorizontalBox (
2204: mnbColorSpinners[0],
2205: mnbColorSpinners[1],
2206: mnbColorSpinners[2],
2207: ComponentFactory.createLabel ("H °"),
2208: Box.createHorizontalGlue ()
2209: ),
2210: ComponentFactory.createHorizontalBox (
2211: mnbColorSpinners[3],
2212: mnbColorSpinners[4],
2213: mnbColorSpinners[5],
2214: ComponentFactory.createLabel ("S%"),
2215: Box.createHorizontalGlue ()
2216: ),
2217: ComponentFactory.createHorizontalBox (
2218: mnbColorSpinners[6],
2219: mnbColorSpinners[7],
2220: mnbColorSpinners[8],
2221: ComponentFactory.createLabel ("B%"),
2222: Box.createHorizontalGlue ()
2223: ),
2224: ComponentFactory.createHorizontalBox (
2225: ComponentFactory.setLineBorder (mnbColorPanel),
2226: Box.createHorizontalGlue ()
2227: ),
2228: Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset to default values", actionListener), "ja", "初期値に戻す")
2229: ),
2230: "ja", "色");
2231: }
2232:
2233:
2234:
2235:
2236:
2237: public static JMenu mnbMakeLanguageMenu () {
2238:
2239: ActionListener actionListener = new ActionListener () {
2240: @Override public void actionPerformed (ActionEvent ae) {
2241: String command = ae.getActionCommand ();
2242: switch (command) {
2243: case "English":
2244: Multilingual.mlnChange ("en");
2245: break;
2246: case "日本語":
2247: Multilingual.mlnChange ("ja");
2248: break;
2249: default:
2250: System.out.println ("unknown action command " + command);
2251: }
2252: }
2253: };
2254:
2255: ButtonGroup languageGroup = new ButtonGroup ();
2256:
2257: return mnbLanguageMenu = Multilingual.mlnText (
2258: ComponentFactory.createMenu (
2259: "Language", 'L',
2260: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnEnglish, "English", actionListener),
2261: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnJapanese, "日本語", actionListener),
2262: ComponentFactory.createHorizontalSeparator (),
2263: mnbMakeFontSizeMenu (),
2264: mnbMakeColorMenu ()
2265: ),
2266: "ja", "言語");
2267: }
2268:
2269:
2270:
2271:
2272:
2273: public static void mnbMakeMenu () {
2274:
2275:
2276: ActionListener listener = new ActionListener () {
2277: @Override public void actionPerformed (ActionEvent ae) {
2278: Object source = ae.getSource ();
2279: String command = ae.getActionCommand ();
2280: switch (command) {
2281:
2282:
2283: case "Quit":
2284: prgTini ();
2285: break;
2286:
2287:
2288: case "50%":
2289: case "75%":
2290: case "100%":
2291: case "150%":
2292: case "200%":
2293: pnlFixedModel.setValue (Integer.valueOf (Integer.parseInt (command.substring (0, command.length () - 1))));
2294: break;
2295: case "Nearest neighbor":
2296: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
2297: break;
2298: case "Bilinear":
2299: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
2300: break;
2301: case "Bicubic":
2302: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
2303: break;
2304:
2305: case "Use canvas":
2306: pnlUseCanvasRequest = ((JCheckBoxMenuItem) source).isSelected ();
2307: break;
2308:
2309: case "Draw all changed pictures":
2310: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2311: CRTC.crtIntermittentInterval = 0;
2312: }
2313: break;
2314: case "Draw a changed picture once every two times":
2315: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2316: CRTC.crtIntermittentInterval = 1;
2317: }
2318: break;
2319: case "Draw a changed picture once every three times":
2320: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2321: CRTC.crtIntermittentInterval = 2;
2322: }
2323: break;
2324: case "Draw a changed picture once every four times":
2325: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2326: CRTC.crtIntermittentInterval = 3;
2327: }
2328: break;
2329: case "Draw a changed picture once every five times":
2330: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2331: CRTC.crtIntermittentInterval = 4;
2332: }
2333: break;
2334:
2335: case "Stereoscopic viewing":
2336: pnlSetStereoscopic (((JCheckBoxMenuItem) source).isSelected (), pnlStereoscopicMethod);
2337: break;
2338: case "Naked-eye crossing":
2339: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_CROSSING);
2340: break;
2341: case "Naked-eye parallel":
2342: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_PARALLEL);
2343: break;
2344: case "Side-by-side":
2345: pnlSetStereoscopic (pnlStereoscopicOn, PNL_SIDE_BY_SIDE);
2346: break;
2347: case "Top-and-bottom":
2348: pnlSetStereoscopic (pnlStereoscopicOn, PNL_TOP_AND_BOTTOM);
2349: break;
2350:
2351: case "Sprite pattern viewer":
2352: if (SpritePatternViewer.SPV_ON) {
2353: SpritePatternViewer.spvOpen ();
2354: }
2355: break;
2356: case "Screen mode test":
2357: if (ScreenModeTest.SMT_ON) {
2358: ScreenModeTest.smtOpen ();
2359: }
2360: break;
2361:
2362:
2363: case "Play":
2364: SoundSource.sndSetPlayOn (((JCheckBoxMenuItem) source).isSelected ());
2365: break;
2366: case "OPM output":
2367: OPM.opmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2368: break;
2369: case "OPM log":
2370: OPMLog.olgOpen ();
2371: break;
2372:
2373: case "PCM output":
2374: ADPCM.pcmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2375: break;
2376: case "Sound thinning":
2377: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.THINNING_MONO : SoundSource.SNDRateConverter.THINNING_STEREO;
2378: break;
2379: case "Sound linear interpolation":
2380: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.LINEAR_MONO : SoundSource.SNDRateConverter.LINEAR_STEREO;
2381: break;
2382: case "Sound piecewise-constant area interpolation":
2383: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000;
2384: break;
2385: case "Sound linear area interpolation":
2386: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000;
2387: break;
2388: case "Sound monitor":
2389: SoundMonitor.smnOpen ();
2390: break;
2391: case "PCM piecewise-constant interpolation":
2392: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_CONSTANT);
2393: break;
2394: case "PCM linear interpolation":
2395: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_LINEAR);
2396: break;
2397: case "PCM hermite interpolation":
2398: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_HERMITE);
2399: break;
2400: case "PCM 8MHz/4MHz":
2401: ADPCM.pcmOSCFreqRequest = 0;
2402: break;
2403: case "PCM 8MHz/16MHz":
2404: ADPCM.pcmOSCFreqRequest = 1;
2405: break;
2406:
2407:
2408: case "Paste":
2409: CONDevice.conDoPaste ();
2410: break;
2411: case "No keyboard":
2412: Keyboard.kbdSetOn (false);
2413: pnlUpdateArrangement ();
2414: break;
2415: case "Standard keyboard":
2416: Keyboard.kbdSetType (Keyboard.KBD_STANDARD_TYPE);
2417: Keyboard.kbdSetOn (true);
2418: pnlUpdateArrangement ();
2419: break;
2420: case "Compact keyboard":
2421: Keyboard.kbdSetType (Keyboard.KBD_COMPACT_TYPE);
2422: Keyboard.kbdSetOn (true);
2423: pnlUpdateArrangement ();
2424: break;
2425: case "Hide keyboard in full screen":
2426: pnlHideKeyboard = ((JCheckBoxMenuItem) source).isSelected ();
2427: if (pnlMode == PNL_FULLSCREEN) {
2428: pnlUpdateArrangement ();
2429: }
2430: break;
2431: case "Key assignments":
2432: Keyboard.kbdOpen ();
2433: break;
2434: case "Joystick port settings":
2435: PPI.ppiOpen ();
2436: break;
2437:
2438:
2439: case "RS-232C and terminal":
2440: RS232CTerminal.trmOpen ();
2441: break;
2442:
2443: case "Console":
2444: DebugConsole.dgtOpen ();
2445: break;
2446: case "Register list":
2447: RegisterList.drpOpen ();
2448: break;
2449: case "Disassemble list":
2450: DisassembleList.ddpOpen (-1, -1, true);
2451: break;
2452: case "Memory dump list":
2453: MemoryDumpList.dmpOpen (-1, -1, true);
2454: break;
2455: case "Logical space monitor":
2456: LogicalSpaceMonitor.atwOpen ();
2457: break;
2458: case "Physical space monitor":
2459: PhysicalSpaceMonitor.paaOpen ();
2460: break;
2461: case "Address translation caches monitor":
2462: if (ATCMonitor.ACM_ON) {
2463: ATCMonitor.acmOpen ();
2464: }
2465: break;
2466: case "Branch log":
2467: if (BranchLog.BLG_ON) {
2468: BranchLog.blgOpen (BranchLog.BLG_SELECT_NONE);
2469: }
2470: break;
2471: case "Program flow visualizer":
2472: if (ProgramFlowVisualizer.PFV_ON) {
2473: ProgramFlowVisualizer.pfvOpen ();
2474: }
2475: break;
2476: case "Raster break point":
2477: if (RasterBreakPoint.RBP_ON) {
2478: RasterBreakPoint.rbpOpen ();
2479: }
2480: break;
2481: case "Data break point":
2482: if (DataBreakPoint.DBP_ON) {
2483: DataBreakPoint.dbpOpen ();
2484: }
2485: break;
2486: case "Root pointer list":
2487: if (RootPointerList.RTL_ON) {
2488: RootPointerList.rtlOpen ();
2489: }
2490: break;
2491:
2492:
2493: case "Adjust clock to host":
2494: RP5C15.rtcSetByHost ();
2495: break;
2496:
2497:
2498:
2499: case "Printer":
2500: PrinterPort.prnOpen ();
2501: break;
2502:
2503: case "Mouse button status":
2504: Mouse.musOutputButtonStatus = ((JCheckBoxMenuItem) source).isSelected ();
2505: break;
2506:
2507: case "Java runtime environment information":
2508: prgOpenJavaDialog ();
2509: break;
2510: case "Version information":
2511: prgOpenAboutDialog ();
2512: break;
2513: case "XEiJ License":
2514: prgOpenXEiJLicenseDialog ();
2515: break;
2516: case "FSHARP License":
2517: prgOpenSHARPLicenseDialog ();
2518: break;
2519: case "ymfm License":
2520: prgOpenYmfmLicenseDialog ();
2521: break;
2522: case "jSerialComm License":
2523: prgOpenJSerialCommLicenseDialog ();
2524: break;
2525:
2526: default:
2527: System.out.println ("unknown action command " + command);
2528:
2529: }
2530: }
2531: };
2532:
2533:
2534: ActionListener mainMemoryListener = new ActionListener () {
2535: @Override public void actionPerformed (ActionEvent ae) {
2536: Object source = ae.getSource ();
2537: String command = ae.getActionCommand ();
2538: switch (command) {
2539: case "1MB":
2540: MainMemory.mmrMemorySizeRequest = 0x00100000;
2541: break;
2542: case "2MB":
2543: MainMemory.mmrMemorySizeRequest = 0x00200000;
2544: break;
2545: case "4MB":
2546: MainMemory.mmrMemorySizeRequest = 0x00400000;
2547: break;
2548: case "6MB":
2549: MainMemory.mmrMemorySizeRequest = 0x00600000;
2550: break;
2551: case "8MB":
2552: MainMemory.mmrMemorySizeRequest = 0x00800000;
2553: break;
2554: case "10MB":
2555: MainMemory.mmrMemorySizeRequest = 0x00a00000;
2556: break;
2557: case "12MB":
2558: MainMemory.mmrMemorySizeRequest = 0x00c00000;
2559: break;
2560: case "Save contents on exit":
2561: MainMemory.mmrMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2562: break;
2563: }
2564: }
2565: };
2566: ButtonGroup mainMemoryGroup = new ButtonGroup ();
2567: JMenu mainMemoryMenu = Multilingual.mlnText (
2568: ComponentFactory.createMenu (
2569: "Main memory",
2570: Multilingual.mlnText (
2571: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00100000, "1MB", mainMemoryListener),
2572: "ja", "1MB"),
2573: Multilingual.mlnText (
2574: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00200000, "2MB", mainMemoryListener),
2575: "ja", "2MB"),
2576: Multilingual.mlnText (
2577: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00400000, "4MB", mainMemoryListener),
2578: "ja", "4MB"),
2579: Multilingual.mlnText (
2580: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00600000, "6MB", mainMemoryListener),
2581: "ja", "6MB"),
2582: Multilingual.mlnText (
2583: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00800000, "8MB", mainMemoryListener),
2584: "ja", "8MB"),
2585: Multilingual.mlnText (
2586: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00a00000, "10MB", mainMemoryListener),
2587: "ja", "10MB"),
2588: Multilingual.mlnText (
2589: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00c00000, "12MB", mainMemoryListener),
2590: "ja", "12MB"),
2591: ComponentFactory.createHorizontalSeparator (),
2592: Multilingual.mlnText (
2593: ComponentFactory.createCheckBoxMenuItem (MainMemory.mmrMemorySaveOn, "Save contents on exit", mainMemoryListener),
2594: "ja", "終了時に内容を保存する"),
2595: SRAM.smrModifyMemorySizeMenuItem
2596: ),
2597: "ja", "メインメモリ");
2598:
2599:
2600: ActionListener highMemoryListener = new ActionListener () {
2601: @Override public void actionPerformed (ActionEvent ae) {
2602: Object source = ae.getSource ();
2603: String command = ae.getActionCommand ();
2604: switch (command) {
2605: case "None":
2606: busHighMemorySize = 0 << 20;
2607: break;
2608: case "16MB":
2609: busHighMemorySize = 16 << 20;
2610: break;
2611: case "Save contents on exit":
2612: busHighMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2613: break;
2614: }
2615: }
2616: };
2617: ButtonGroup highMemoryGroup = new ButtonGroup ();
2618: JMenu highMemoryMenu = Multilingual.mlnText (
2619: ComponentFactory.createMenu (
2620: "High memory on X68030/Xellent30",
2621: Multilingual.mlnText (
2622: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 0 << 20, "None", highMemoryListener),
2623: "ja", "なし"),
2624: Multilingual.mlnText (
2625: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 16 << 20, "16MB", highMemoryListener),
2626: "ja", "16MB"),
2627: ComponentFactory.createHorizontalSeparator (),
2628: Multilingual.mlnText (
2629: ComponentFactory.createCheckBoxMenuItem (busHighMemorySaveOn, "Save contents on exit", highMemoryListener),
2630: "ja", "終了時に内容を保存する")
2631: ),
2632: "ja", "X68030/Xellent30 のハイメモリ");
2633:
2634:
2635: ActionListener localMemoryListener = new ActionListener () {
2636: @Override public void actionPerformed (ActionEvent ae) {
2637: Object source = ae.getSource ();
2638: String command = ae.getActionCommand ();
2639: switch (command) {
2640: case "None":
2641: busLocalMemorySize = 0 << 20;
2642: break;
2643: case "16MB":
2644: busLocalMemorySize = 16 << 20;
2645: break;
2646: case "32MB":
2647: busLocalMemorySize = 32 << 20;
2648: break;
2649: case "64MB":
2650: busLocalMemorySize = 64 << 20;
2651: break;
2652: case "128MB":
2653: busLocalMemorySize = 128 << 20;
2654: break;
2655: case "256MB":
2656: busLocalMemorySize = 256 << 20;
2657: break;
2658: case "384MB":
2659: busLocalMemorySize = 384 << 20;
2660: break;
2661: case "512MB":
2662: busLocalMemorySize = 512 << 20;
2663: break;
2664: case "768MB":
2665: busLocalMemorySize = 768 << 20;
2666: break;
2667: case "Save contents on exit":
2668: busLocalMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2669: break;
2670: case "Available on X68000":
2671: busHimem68000 = ((JCheckBoxMenuItem) source).isSelected ();
2672: break;
2673: case "Available on X68030/Xellent30":
2674: busHighMemory060turboOn = ((JCheckBoxMenuItem) source).isSelected ();
2675: break;
2676: }
2677: }
2678: };
2679: ButtonGroup localMenoryGroup = new ButtonGroup ();
2680: JMenu localMemoryMenu = Multilingual.mlnText (
2681: ComponentFactory.createMenu (
2682: "High memory on 060turbo",
2683: Multilingual.mlnText (
2684: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 0 << 20, "None", localMemoryListener),
2685: "ja", "なし"),
2686: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 16 << 20, "16MB", localMemoryListener),
2687: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 32 << 20, "32MB", localMemoryListener),
2688: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 64 << 20, "64MB", localMemoryListener),
2689: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 128 << 20, "128MB", localMemoryListener),
2690: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 256 << 20, "256MB", localMemoryListener),
2691: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 384 << 20, "384MB", localMemoryListener),
2692: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 512 << 20, "512MB", localMemoryListener),
2693: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 768 << 20, "768MB", localMemoryListener),
2694: ComponentFactory.createHorizontalSeparator (),
2695: Multilingual.mlnText (
2696: ComponentFactory.createCheckBoxMenuItem (busLocalMemorySaveOn, "Save contents on exit", localMemoryListener),
2697: "ja", "終了時に内容を保存する"),
2698: ComponentFactory.createHorizontalSeparator (),
2699: Multilingual.mlnText (
2700: ComponentFactory.createCheckBoxMenuItem (busHimem68000, "Available on X68000", localMemoryListener),
2701: "ja", "X68000 でも有効"),
2702: Multilingual.mlnText (
2703: ComponentFactory.createCheckBoxMenuItem (busHighMemory060turboOn, "Available on X68030/Xellent30", localMemoryListener),
2704: "ja", "X68030/Xellent30 でも有効")
2705: ),
2706: "ja", "060turbo のハイメモリ");
2707:
2708:
2709: ActionListener xellent30Listener = new ActionListener () {
2710: @Override public void actionPerformed (ActionEvent ae) {
2711: Object source = ae.getSource ();
2712: String command = ae.getActionCommand ();
2713: switch (command) {
2714: case "$00EC0000-$00EC3FFF":
2715: xt3DIPSW = 0;
2716: break;
2717: case "$00EC4000-$00EC7FFF":
2718: xt3DIPSW = 1;
2719: break;
2720: case "$00EC8000-$00ECBFFF":
2721: xt3DIPSW = 2;
2722: break;
2723: case "$00ECC000-$00ECFFFF":
2724: xt3DIPSW = 3;
2725: break;
2726: case "256KB":
2727: xt3MemorySizeRequest = 1 << 18;
2728: break;
2729: case "1MB":
2730: xt3MemorySizeRequest = 1 << 20;
2731: break;
2732: case "Save contents on exit":
2733: xt3MemorySave = ((JCheckBoxMenuItem) source).isSelected ();
2734: break;
2735: }
2736: }
2737: };
2738: ButtonGroup xellent30PortGroup = new ButtonGroup ();
2739: ButtonGroup xellent30SizeGroup = new ButtonGroup ();
2740: JMenu xellent30Menu = ComponentFactory.createMenu (
2741: "Xellent30",
2742: ComponentFactory.createRadioButtonMenuItem (
2743: xellent30PortGroup,
2744: xt3DIPSW == 0,
2745: "$00EC0000-$00EC3FFF",
2746: xellent30Listener),
2747: ComponentFactory.createRadioButtonMenuItem (
2748: xellent30PortGroup,
2749: xt3DIPSW == 1,
2750: "$00EC4000-$00EC7FFF",
2751: xellent30Listener),
2752: ComponentFactory.createRadioButtonMenuItem (
2753: xellent30PortGroup,
2754: xt3DIPSW == 2,
2755: "$00EC8000-$00ECBFFF",
2756: xellent30Listener),
2757: ComponentFactory.createRadioButtonMenuItem (
2758: xellent30PortGroup,
2759: xt3DIPSW == 3,
2760: "$00ECC000-$00ECFFFF",
2761: xellent30Listener),
2762: ComponentFactory.createHorizontalSeparator (),
2763: ComponentFactory.createRadioButtonMenuItem (
2764: xellent30SizeGroup,
2765: xt3MemorySizeRequest == 1 << 18,
2766: "256KB",
2767: xellent30Listener),
2768: ComponentFactory.createRadioButtonMenuItem (
2769: xellent30SizeGroup,
2770: xt3MemorySizeRequest == 1 << 20,
2771: "1MB",
2772: xellent30Listener),
2773: ComponentFactory.createHorizontalSeparator (),
2774: Multilingual.mlnText (
2775: ComponentFactory.createCheckBoxMenuItem (xt3MemorySave, "Save contents on exit", xellent30Listener),
2776: "ja", "終了時に内容を保存する")
2777: );
2778:
2779:
2780: JMenu rotationMenu = null;
2781: if (PNL_ROTATION_ON) {
2782: ActionListener rotationListener = new ActionListener () {
2783: @Override public void actionPerformed (ActionEvent ae) {
2784: String command = ae.getActionCommand ();
2785: switch (command) {
2786: case "No rotation (landscape)":
2787: pnlRotationMode = 0;
2788: pnlUpdateArrangement ();
2789: break;
2790: case "90-degree rotation (portrait)":
2791: pnlRotationMode = 1;
2792: pnlUpdateArrangement ();
2793: break;
2794: case "180-degree rotation":
2795: pnlRotationMode = 2;
2796: pnlUpdateArrangement ();
2797: break;
2798: case "270-degree rotation":
2799: pnlRotationMode = 3;
2800: pnlUpdateArrangement ();
2801: break;
2802: default:
2803: System.out.println ("unknown action command " + command);
2804: }
2805: }
2806: };
2807: ButtonGroup rotationGroup = new ButtonGroup ();
2808: rotationMenu = Multilingual.mlnText (
2809: ComponentFactory.createMenu (
2810: "Rotation",
2811: Multilingual.mlnText (
2812: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 0, "No rotation (landscape)", rotationListener),
2813: "ja", "回転なし (横画面)"),
2814: Multilingual.mlnText (
2815: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 1, "90-degree rotation (portrait)", rotationListener),
2816: "ja", "90 度回転 (縦画面)"),
2817: Multilingual.mlnText (
2818: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 2, "180-degree rotation", rotationListener),
2819: "ja", "180 度回転"),
2820: Multilingual.mlnText (
2821: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 3, "270-degree rotation", rotationListener),
2822: "ja", "270 度回転")
2823: ),
2824: "ja", "回転");
2825: }
2826:
2827:
2828: ActionListener aspectListener = new ActionListener () {
2829: @Override public void actionPerformed (ActionEvent ae) {
2830: String command = ae.getActionCommand ();
2831: int i = command.indexOf (',');
2832: int key = Integer.parseInt (command.substring (0, i));
2833: int value = Integer.parseInt (command.substring (i + 1));
2834: pnlAspectMap[key] = value;
2835: pnlUpdateAspectTable ();
2836: pnlUpdateArrangement ();
2837: }
2838: };
2839: JMenu aspectMenu = ComponentFactory.createMenu ("Aspect ratio");
2840: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
2841: if (key != 0) {
2842: aspectMenu.add (ComponentFactory.createHorizontalSeparator ());
2843: }
2844: ButtonGroup group = new ButtonGroup ();
2845: for (int value = 0; value < PNL_ASPECT_VALUES; value++) {
2846: aspectMenu.add (
2847: ComponentFactory.setText (
2848: ComponentFactory.createRadioButtonMenuItem (
2849: group,
2850: pnlAspectMap[key] == value,
2851: key + "," + value,
2852: aspectListener
2853: ),
2854: (PNL_ASPECT_MATRIX[key] == PNL_ASPECT_SCREEN_RATIO ?
2855: String.format ("%s %s (%.3f)",
2856: PNL_ASPECT_RESOLUTION_NAME[key],
2857: PNL_ASPECT_SCREEN_NAME[value],
2858: PNL_ASPECT_SCREEN_RATIO[value]) :
2859: String.format ("%s %s (%.3f) @ %s (%.3f)",
2860: PNL_ASPECT_RESOLUTION_NAME[key],
2861: PNL_ASPECT_SCREEN_NAME[value],
2862: PNL_ASPECT_SCREEN_RATIO[value],
2863: PNL_ASPECT_PIXEL_NAME[value],
2864: PNL_ASPECT_PIXEL_RATIO[value]))
2865: )
2866: );
2867: }
2868: }
2869: aspectMenu = Multilingual.mlnText (aspectMenu, "ja", "アスペクト比");
2870:
2871:
2872: ActionListener scanlineListener = new ActionListener () {
2873: @Override public void actionPerformed (ActionEvent ae) {
2874:
2875: String command = ae.getActionCommand ();
2876: switch (command) {
2877: case "Off":
2878: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.OFF;
2879: CRTC.crtAllStamp += 2;
2880: break;
2881: case "Weak":
2882: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.WEAK;
2883: CRTC.crtAllStamp += 2;
2884: break;
2885: case "Medium":
2886: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.MEDIUM;
2887: CRTC.crtAllStamp += 2;
2888: break;
2889: case "Strong":
2890: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.STRONG;
2891: CRTC.crtAllStamp += 2;
2892: break;
2893: case "Black":
2894: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.BLACK;
2895: CRTC.crtAllStamp += 2;
2896: break;
2897: }
2898: }
2899: };
2900: ButtonGroup scanlineGroup = new ButtonGroup ();
2901: JMenu scanlineMenu =
2902: Multilingual.mlnText (
2903: ComponentFactory.createMenu (
2904: "Scanline effect",
2905: Multilingual.mlnText (
2906: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.OFF, "Off", scanlineListener),
2907: "ja", "なし"),
2908: Multilingual.mlnText (
2909: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.WEAK, "Weak", scanlineListener),
2910: "ja", "弱"),
2911: Multilingual.mlnText (
2912: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.MEDIUM, "Medium", scanlineListener),
2913: "ja", "中"),
2914: Multilingual.mlnText (
2915: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.STRONG, "Strong", scanlineListener),
2916: "ja", "強"),
2917: Multilingual.mlnText (
2918: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.BLACK, "Black", scanlineListener),
2919: "ja", "黒")
2920: ),
2921: "ja", "走査線エフェクト");
2922:
2923:
2924: JTextField refreshRateTextField = ComponentFactory.createNumberField (pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate), 8);
2925: refreshRateTextField.addActionListener (
2926: new ActionListener () {
2927: @Override public void actionPerformed (ActionEvent ae) {
2928: JTextField textField = (JTextField) ae.getSource ();
2929: pnlRefreshRate = 0.0;
2930: String s = textField.getText ();
2931: if (!s.equals ("")) {
2932: double rate = 0.0;
2933: try {
2934: rate = Double.parseDouble (s);
2935: } catch (NumberFormatException nfe) {
2936: }
2937: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
2938: pnlRefreshRate = rate;
2939: } else {
2940: textField.setText ("");
2941: }
2942: }
2943: pnlFixedRate = pnlRefreshRate;
2944: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
2945: pnlFixedRate = pnlGetRefreshRate ();
2946: }
2947: CRTC.crtUpdateLength ();
2948: }
2949: });
2950:
2951: ButtonGroup unitGroup = new ButtonGroup ();
2952: ButtonGroup frameGroup = new ButtonGroup ();
2953: ButtonGroup hintGroup = new ButtonGroup ();
2954: ButtonGroup vgaGroup = new ButtonGroup ();
2955: ButtonGroup intermittentGroup = new ButtonGroup ();
2956: ButtonGroup sterescopicGroup = new ButtonGroup ();
2957: ButtonGroup soundInterpolationGroup = new ButtonGroup ();
2958: ButtonGroup adpcmInterpolationGroup = new ButtonGroup ();
2959: ButtonGroup adpcmOSCFreqGroup = new ButtonGroup ();
2960: ButtonGroup keyboardGroup = new ButtonGroup ();
2961: ButtonGroup spritesGroup = new ButtonGroup ();
2962:
2963:
2964: DecimalSpinner[] freqSpinner = new DecimalSpinner[3];
2965: ChangeListener freqListener = new ChangeListener () {
2966: @Override public void stateChanged (ChangeEvent ce) {
2967: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
2968: int i = spinner.getOption ();
2969: CRTC.crtFreqsRequest[i] = spinner.getIntValue ();
2970: }
2971: };
2972: for (int i = 0; i < 3; i++) {
2973: freqSpinner[i] = ComponentFactory.createDecimalSpinner (
2974: CRTC.crtFreqsRequest[i], CRTC.CRT_MIN_FREQ, CRTC.CRT_MAX_FREQ, 1000000, i, freqListener
2975: );
2976: }
2977: DecimalSpinner sprrasSpinner = ComponentFactory.createDecimalSpinner (
2978: SpriteScreen.sprSpritesPerRaster, 0, 1016, 1, 0,
2979: new ChangeListener () {
2980: @Override public void stateChanged (ChangeEvent ce) {
2981: SpriteScreen.sprSpritesPerRaster = ((DecimalSpinner) ce.getSource ()).getIntValue ();
2982: }
2983: });
2984: ActionListener modificationListener = new ActionListener () {
2985: @Override public void actionPerformed (ActionEvent ae) {
2986: Object source = ae.getSource ();
2987: String command = ae.getActionCommand ();
2988: switch (command) {
2989:
2990: case "Adjust to host refresh rate":
2991: pnlAdjustVsync = ((JCheckBoxMenuItem) source).isSelected ();
2992: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
2993: pnlFixedRate = pnlGetRefreshRate ();
2994: }
2995: CRTC.crtUpdateLength ();
2996: break;
2997: case "* Reset to default values":
2998: for (int i = 0; i < 3; i++) {
2999: if (CRTC.crtFreqsRequest[i] != CRTC.CRT_DEFAULT_FREQS[i]) {
3000: CRTC.crtFreqsRequest[i] = CRTC.CRT_DEFAULT_FREQS[i];
3001: freqSpinner[i].setIntValue (CRTC.crtFreqsRequest[i]);
3002: }
3003: }
3004: break;
3005: case "1024-dot non-interlaced":
3006: CRTC.crtEleventhBitRequest = ((JCheckBoxMenuItem) source).isSelected ();
3007: break;
3008: case "Can write 0 to bit 0 of CRTC R00":
3009: CRTC.crtR00Bit0Zero = ((JCheckBoxMenuItem) source).isSelected ();
3010: break;
3011:
3012: case "Extended graphic screen":
3013: CRTC.crtExtendedGraphicRequest = ((JCheckBoxMenuItem) source).isSelected ();
3014: break;
3015:
3016: case "Spherical scrolling of text screen":
3017: CRTC.crtSetSphericalScrolling (((JCheckBoxMenuItem) source).isSelected ());
3018: break;
3019:
3020: case "128 sprites":
3021: SpriteScreen.sprNumberOfSpritesRequest = 128;
3022: break;
3023: case "256 sprites":
3024: SpriteScreen.sprNumberOfSpritesRequest = 256;
3025: break;
3026: case "504 sprites":
3027: SpriteScreen.sprNumberOfSpritesRequest = 512;
3028: break;
3029: case "1016 sprites":
3030: SpriteScreen.sprNumberOfSpritesRequest = 1024;
3031: break;
3032:
3033:
3034:
3035: case "4096 patterns":
3036: SpriteScreen.sprBankOnRequest = ((JCheckBoxMenuItem) source).isSelected ();
3037: break;
3038: case "Sprites displayed in 768x512":
3039: SpriteScreen.spr768x512Request = ((JCheckBoxMenuItem) source).isSelected ();
3040: break;
3041: case "BG1 displayed in 512x512":
3042: SpriteScreen.spr512bg1Request = ((JCheckBoxMenuItem) source).isSelected ();
3043: break;
3044: case "Row and column scroll":
3045: if (SpriteScreen.SPR_RC_SCROLL_ON) {
3046: SpriteScreen.sprRcScrollRequest = ((JCheckBoxMenuItem) source).isSelected ();
3047: }
3048: break;
3049: case "** Reset to default values":
3050: if (SpriteScreen.sprSpritesPerRaster != 32) {
3051: SpriteScreen.sprSpritesPerRaster = 32;
3052: sprrasSpinner.setIntValue (SpriteScreen.sprSpritesPerRaster);
3053: }
3054: break;
3055: }
3056: }
3057: };
3058: JMenu modificationMenu =
3059: Multilingual.mlnText (
3060: ComponentFactory.createMenu (
3061: "Modification",
3062: Multilingual.mlnText (
3063: ComponentFactory.createMenu (
3064: "Dot clock",
3065: Multilingual.mlnText (
3066: ComponentFactory.createCheckBoxMenuItem (pnlAdjustVsync, "Adjust to host refresh rate", modificationListener),
3067: "ja", "ホストのリフレッシュレートに合わせる"),
3068: ComponentFactory.createHorizontalBox (
3069: Box.createHorizontalStrut (20),
3070: refreshRateTextField,
3071: ComponentFactory.createLabel (" Hz"),
3072: Box.createHorizontalGlue ()
3073: ),
3074: ComponentFactory.createHorizontalSeparator (),
3075: ComponentFactory.createHorizontalBox (
3076: Box.createHorizontalStrut (20),
3077: Multilingual.mlnText (ComponentFactory.createLabel ("Dot clock oscillattor"), "ja", "ドットクロックオシレータ"),
3078: Box.createHorizontalGlue ()
3079: ),
3080: ComponentFactory.createHorizontalBox (
3081: Box.createHorizontalStrut (20),
3082: freqSpinner[0],
3083: ComponentFactory.createLabel (" Hz *"),
3084: Box.createHorizontalGlue ()
3085: ),
3086: ComponentFactory.createHorizontalBox (
3087: Box.createHorizontalStrut (20),
3088: freqSpinner[1],
3089: ComponentFactory.createLabel (" Hz *"),
3090: Box.createHorizontalGlue ()
3091: ),
3092: ComponentFactory.createHorizontalBox (
3093: Box.createHorizontalStrut (20),
3094: freqSpinner[2],
3095: ComponentFactory.createLabel (" Hz *"),
3096: Box.createHorizontalGlue ()
3097: ),
3098: Multilingual.mlnText (
3099: ComponentFactory.createMenuItem ("* Reset to default values", modificationListener),
3100: "ja", "* 初期値に戻す"),
3101: ComponentFactory.createHorizontalSeparator (),
3102: Multilingual.mlnText (
3103: ComponentFactory.createCheckBoxMenuItem (CRTC.crtEleventhBitRequest, "1024-dot non-interlaced", modificationListener),
3104: "ja", "1024 ドットノンインターレース"),
3105: Multilingual.mlnText (
3106: ComponentFactory.createCheckBoxMenuItem (CRTC.crtR00Bit0Zero, "Can write 0 to bit 0 of CRTC R00", modificationListener),
3107: "ja", "CRTC R00 のビット 0 に 0 を書き込める")
3108: ),
3109: "ja", "ドットクロック"),
3110: Multilingual.mlnText (
3111: ComponentFactory.createMenu (
3112: "Graphic screen",
3113: !CRTC.CRT_EXTENDED_GRAPHIC ? null : Multilingual.mlnText (
3114: ComponentFactory.createCheckBoxMenuItem (CRTC.crtExtendedGraphicRequest, "Extended graphic screen", modificationListener),
3115: "ja", "拡張グラフィック画面")
3116: ),
3117: "ja", "グラフィック画面"),
3118: Multilingual.mlnText (
3119: ComponentFactory.createMenu (
3120: "Text screen",
3121: Multilingual.mlnText (
3122: ComponentFactory.createCheckBoxMenuItem (CRTC.crtSphericalScrolling, "Spherical scrolling of text screen", modificationListener),
3123: "ja", "テキスト画面の球面スクロール")
3124: ),
3125: "ja", "テキスト画面"),
3126: Multilingual.mlnText (
3127: ComponentFactory.createMenu (
3128: "Sprite screen",
3129: Multilingual.mlnText (
3130: ComponentFactory.createRadioButtonMenuItem (
3131: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 128, "128 sprites", modificationListener),
3132: "ja", "128 枚のスプライト"),
3133: Multilingual.mlnText (
3134: ComponentFactory.createRadioButtonMenuItem (
3135: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 256, "256 sprites", modificationListener),
3136: "ja", "256 枚のスプライト"),
3137: Multilingual.mlnText (
3138: ComponentFactory.createRadioButtonMenuItem (
3139: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 512, "504 sprites", modificationListener),
3140: "ja", "504 枚のスプライト"),
3141: Multilingual.mlnText (
3142: ComponentFactory.createRadioButtonMenuItem (
3143: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 1024, "1016 sprites", modificationListener),
3144: "ja", "1016 枚のスプライト"),
3145:
3146:
3147:
3148:
3149: ComponentFactory.createHorizontalSeparator (),
3150: Multilingual.mlnText (
3151: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprBankOnRequest, "4096 patterns", modificationListener),
3152: "ja", "4096 個のパターン"),
3153: Multilingual.mlnText (
3154: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr768x512Request, "Sprites displayed in 768x512", modificationListener),
3155: "ja", "768x512 でスプライトを表示"),
3156: Multilingual.mlnText (
3157: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr512bg1Request, "BG1 displayed in 512x512", modificationListener),
3158: "ja", "512x512 で BG1 を表示"),
3159: !SpriteScreen.SPR_RC_SCROLL_ON ? null : Multilingual.mlnText (
3160: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprRcScrollRequest, "Row and column scroll", modificationListener),
3161: "ja", "行スクロールと列スクロール"),
3162: ComponentFactory.createHorizontalSeparator (),
3163: ComponentFactory.createHorizontalBox (
3164: Box.createHorizontalStrut (20),
3165: Multilingual.mlnText (ComponentFactory.createLabel ("Number of sprites per raster"), "ja", "ラスタあたりのスプライトの枚数"),
3166: Box.createHorizontalGlue ()
3167: ),
3168: ComponentFactory.createHorizontalBox (
3169: Box.createHorizontalStrut (20),
3170: sprrasSpinner,
3171: ComponentFactory.createLabel (" *"),
3172: Box.createHorizontalGlue ()
3173: ),
3174: Multilingual.mlnText (
3175: ComponentFactory.createMenuItem ("** Reset to default values", modificationListener),
3176: "ja", "** 初期値に戻す")
3177: ),
3178: "ja", "スプライト画面")
3179: ),
3180: "ja", "改造");
3181:
3182:
3183: mnbMenuBar = ComponentFactory.createMenuBar (
3184:
3185:
3186: mnbFileMenu = Multilingual.mlnText (
3187: ComponentFactory.createMenu (
3188: "File", 'F',
3189:
3190: FDC.fdcMenu,
3191:
3192: HDC.hdcMenu,
3193:
3194: SPC.spcMenu,
3195:
3196: HFS.hfsMenu,
3197: ComponentFactory.createHorizontalSeparator (),
3198: mnbQuitMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Quit", 'Q', MNB_MODIFIERS, listener), "ja", "終了")
3199: ),
3200: "ja", "ファイル"),
3201:
3202:
3203: mpuMenu,
3204:
3205:
3206: mnbDisplayMenu = Multilingual.mlnText (
3207: ComponentFactory.createMenu (
3208: "Display", 'D',
3209: mnbFullScreenMenuItem,
3210: mnbMaximizedMenuItem,
3211: mnbFitInWindowMenuItem,
3212: mnbFixedScaleMenuItem,
3213: ComponentFactory.createHorizontalBox (
3214: Box.createHorizontalStrut (20),
3215: pnlFixedSpinner,
3216: ComponentFactory.createLabel ("%"),
3217: Box.createHorizontalGlue ()
3218: ),
3219: ComponentFactory.createMenuItem ("50%", listener),
3220: ComponentFactory.createMenuItem ("75%", listener),
3221: ComponentFactory.createMenuItem ("100%", listener),
3222: ComponentFactory.createMenuItem ("150%", listener),
3223: ComponentFactory.createMenuItem ("200%", listener),
3224:
3225: rotationMenu,
3226:
3227: aspectMenu,
3228:
3229: Multilingual.mlnText (
3230: ComponentFactory.createMenu (
3231: "Interpolation algorithm",
3232: Multilingual.mlnText (
3233: ComponentFactory.createRadioButtonMenuItem (
3234: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
3235: "Nearest neighbor", listener),
3236: "ja", "最近傍補間"),
3237: Multilingual.mlnText (
3238: ComponentFactory.createRadioButtonMenuItem (
3239: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR,
3240: "Bilinear", listener),
3241: "ja", "線形補間"),
3242: Multilingual.mlnText (
3243: ComponentFactory.createRadioButtonMenuItem (
3244: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC,
3245: "Bicubic", listener),
3246: "ja", "三次補間")
3247: ),
3248: "ja", "補間アルゴリズム"),
3249:
3250: scanlineMenu,
3251: !PNL_USE_CANVAS ? null : Multilingual.mlnText (
3252: ComponentFactory.createCheckBoxMenuItem (pnlUseCanvasRequest, "Use canvas", listener),
3253: "ja", "キャンバスを使う"),
3254:
3255: !CRTC.CRT_ENABLE_INTERMITTENT ? null : Multilingual.mlnText (
3256: ComponentFactory.createMenu (
3257: "Intermittent drawing",
3258: Multilingual.mlnText (
3259: ComponentFactory.createRadioButtonMenuItem (
3260: intermittentGroup, CRTC.crtIntermittentInterval == 0, "Draw all changed pictures", listener),
3261: "ja", "変化した画像をすべて描画する"),
3262: Multilingual.mlnText (
3263: ComponentFactory.createRadioButtonMenuItem (
3264: intermittentGroup, CRTC.crtIntermittentInterval == 1, "Draw a changed picture once every two times", listener),
3265: "ja", "変化した画像を 2 回に 1 回描画する"),
3266: Multilingual.mlnText (
3267: ComponentFactory.createRadioButtonMenuItem (
3268: intermittentGroup, CRTC.crtIntermittentInterval == 2, "Draw a changed picture once every three times", listener),
3269: "ja", "変化した画像を 3 回に 1 回描画する"),
3270: Multilingual.mlnText (
3271: ComponentFactory.createRadioButtonMenuItem (
3272: intermittentGroup, CRTC.crtIntermittentInterval == 3, "Draw a changed picture once every four times", listener),
3273: "ja", "変化した画像を 4 回に 1 回描画する"),
3274: Multilingual.mlnText (
3275: ComponentFactory.createRadioButtonMenuItem (
3276: intermittentGroup, CRTC.crtIntermittentInterval == 4, "Draw a changed picture once every five times", listener),
3277: "ja", "変化した画像を 5 回に 1 回描画する")
3278: ),
3279: "ja", "間欠描画"),
3280:
3281: !PNL_STEREOSCOPIC_ON ? null : ComponentFactory.createHorizontalSeparator (),
3282: mnbStereoscopicMenuItem = !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3283: ComponentFactory.createCheckBoxMenuItem (pnlStereoscopicOn, "Stereoscopic viewing", 'T', listener),
3284: "ja", "立体視"),
3285: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3286: ComponentFactory.createMenu (
3287: "Stereoscopic settings",
3288: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3289: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3290: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING,
3291: "Naked-eye crossing", listener),
3292: "ja", "裸眼交差法"),
3293: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3294: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3295: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL,
3296: "Naked-eye parallel", listener),
3297: "ja", "裸眼平行法"),
3298: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3299: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3300: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE,
3301: "Side-by-side", listener),
3302: "ja", "サイドバイサイド"),
3303: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3304: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3305: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM,
3306: "Top-and-bottom", listener),
3307: "ja", "トップアンドボトム")
3308: ),
3309: "ja", "立体視設定"),
3310:
3311: ComponentFactory.createHorizontalSeparator (),
3312: GIFAnimation.gifStartRecordingMenuItem,
3313: GIFAnimation.gifSettingsMenu,
3314:
3315: ComponentFactory.createHorizontalSeparator (),
3316: modificationMenu,
3317:
3318: SpritePatternViewer.SPV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Sprite pattern viewer", listener), "ja", "スプライトパターンビュア") : null,
3319: ScreenModeTest.SMT_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Screen mode test", listener), "ja", "表示モードテスト") : null
3320: ),
3321: "ja", "画面"),
3322:
3323:
3324: mnbSoundMenu = ComponentFactory.setEnabled (
3325: Multilingual.mlnText (
3326: ComponentFactory.createMenu (
3327: "Sound", 'S',
3328: mnbPlayMenuItem = ComponentFactory.setEnabled (
3329: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (SoundSource.sndPlayOn, "Play", 'P', MNB_MODIFIERS, listener), "ja", "音声出力"),
3330: SoundSource.sndLine != null),
3331:
3332:
3333:
3334: ComponentFactory.createHorizontalBox (
3335: Box.createHorizontalGlue (),
3336: Multilingual.mlnText (ComponentFactory.createLabel ("Volume "), "ja", "音量 "),
3337: mnbVolumeLabel = ComponentFactory.createLabel (String.valueOf (SoundSource.sndVolume)),
3338: Box.createHorizontalGlue ()
3339: ),
3340:
3341:
3342: ComponentFactory.setPreferredSize (
3343: ComponentFactory.createHorizontalSlider (
3344: 0,
3345: SoundSource.SND_VOLUME_MAX,
3346: SoundSource.sndVolume,
3347: SoundSource.SND_VOLUME_STEP,
3348: 1,
3349: new ChangeListener () {
3350: @Override public void stateChanged (ChangeEvent ce) {
3351: SoundSource.sndSetVolume (((JSlider) ce.getSource ()).getValue ());
3352: }
3353: }),
3354: LnF.lnfFontSize * 18, LnF.lnfFontSize * 2 + 28),
3355: Multilingual.mlnText (
3356: ComponentFactory.createMenu (
3357: "Sound interpolation",
3358: Multilingual.mlnText (
3359: ComponentFactory.createRadioButtonMenuItem (
3360: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.THINNING_STEREO,
3361: "Sound thinning", listener),
3362: "ja", "音声 間引き"),
3363: Multilingual.mlnText (
3364: ComponentFactory.createRadioButtonMenuItem (
3365: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_STEREO,
3366: "Sound linear interpolation", listener),
3367: "ja", "音声 線形補間"),
3368: ComponentFactory.setEnabled (
3369: Multilingual.mlnText (
3370: ComponentFactory.createRadioButtonMenuItem (
3371: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000,
3372: "Sound piecewise-constant area interpolation", listener),
3373: "ja", "音声 区分定数面積補間"),
3374: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000),
3375: ComponentFactory.setEnabled (
3376: Multilingual.mlnText (
3377: ComponentFactory.createRadioButtonMenuItem (
3378: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000,
3379: "Sound linear area interpolation", listener),
3380: "ja", "音声 線形面積補間"),
3381: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000)
3382: ),
3383: "ja", "音声補間"),
3384: Multilingual.mlnText (ComponentFactory.createMenuItem ("Sound monitor", listener), "ja", "音声モニタ"),
3385:
3386: ComponentFactory.createHorizontalSeparator (),
3387:
3388: ComponentFactory.setEnabled (
3389: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (OPM.opmOutputMask != 0, "OPM output", listener), "ja", "OPM 出力"),
3390: SoundSource.sndLine != null),
3391: !OPMLog.OLG_ON ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("OPM log", listener), "ja", "OPM ログ"),
3392:
3393: ComponentFactory.createHorizontalSeparator (),
3394:
3395: ComponentFactory.setEnabled (
3396: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ADPCM.pcmOutputOn, "PCM output", listener), "ja", "PCM 出力"),
3397: SoundSource.sndLine != null),
3398: Multilingual.mlnText (
3399: ComponentFactory.createMenu (
3400: "PCM interpolation",
3401: Multilingual.mlnText (
3402: ComponentFactory.createRadioButtonMenuItem (
3403: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_CONSTANT,
3404: "PCM piecewise-constant interpolation", listener),
3405: "ja", "PCM 区分定数補間"),
3406: Multilingual.mlnText (
3407: ComponentFactory.createRadioButtonMenuItem (
3408: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_LINEAR,
3409: "PCM linear interpolation", listener),
3410: "ja", "PCM 線形補間"),
3411: Multilingual.mlnText (
3412: ComponentFactory.createRadioButtonMenuItem (
3413: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_HERMITE,
3414: "PCM hermite interpolation", listener),
3415: "ja", "PCM エルミート補間")
3416: ),
3417: "ja", "PCM 補間"),
3418: Multilingual.mlnText (
3419: ComponentFactory.createMenu (
3420: "PCM source oscillator frequency",
3421: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 0, "PCM 8MHz/4MHz", listener),
3422: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 1, "PCM 8MHz/16MHz", listener)
3423: ),
3424: "ja", "PCM 原発振周波数")
3425: ),
3426: "ja", "音声"),
3427: SoundSource.sndLine != null),
3428:
3429:
3430: mnbInputMenu = Multilingual.mlnText (
3431: ComponentFactory.createMenu (
3432: "Input", 'I',
3433: mnbPasteMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Paste", 'V', MNB_MODIFIERS, listener), "ja", "貼り付け"),
3434: CONDevice.conSettingsMenu,
3435: TextCopy.txcMakeMenuItem (),
3436: TextCopy.txcMakeSettingMenu (),
3437: ComponentFactory.createHorizontalSeparator (),
3438: mnbNoKeyboardMenuItem = Multilingual.mlnText (
3439: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, !Keyboard.kbdOn, "No keyboard", 'K', MNB_MODIFIERS, listener),
3440: "ja", "キーボードなし"),
3441: mnbStandardKeyboardMenuItem = Multilingual.mlnText (
3442: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_STANDARD_TYPE, "Standard keyboard", listener),
3443: "ja", "標準キーボード"),
3444: mnbCompactKeyboardMenuItem = Multilingual.mlnText (
3445: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_COMPACT_TYPE, "Compact keyboard", listener),
3446: "ja", "コンパクトキーボード"),
3447: Multilingual.mlnText (
3448: ComponentFactory.createCheckBoxMenuItem (pnlHideKeyboard, "Hide keyboard in full screen", listener),
3449: "ja", "全画面表示のときキーボードを隠す"),
3450: Multilingual.mlnText (ComponentFactory.createMenuItem ("Key assignments", listener), "ja", "キー割り当て"),
3451: ButtonFunction.bfnMakeMenuItem (),
3452: SRAM.smrRepeatDelayMenu,
3453: SRAM.smrRepeatIntervalMenu,
3454: !Keyboard.KBD_ZKEY_ON ? null : Keyboard.kbdZKeyMenu,
3455: ComponentFactory.createHorizontalSeparator (),
3456: Mouse.musSeamlessMouseCheckBox,
3457: Mouse.musFollowScrollCheckBox,
3458: Mouse.musCtrlRightCheckBox,
3459: Mouse.musEdgeAccelerationCheckBox,
3460: Mouse.musMouseCursorSpeedBox,
3461: Mouse.musSpeedSlider,
3462: Mouse.musHostsPixelUnitsCheckBox,
3463: ComponentFactory.createHorizontalSeparator (),
3464: Multilingual.mlnText (ComponentFactory.createMenuItem ("Joystick port settings", listener), "ja", "ジョイスティックポート設定")
3465: ),
3466: "ja", "入力"),
3467:
3468:
3469: mnbConfigMenu = Multilingual.mlnText (
3470: ComponentFactory.createMenu (
3471: "Config", 'G',
3472: Multilingual.mlnText (ComponentFactory.createMenuItem ("RS-232C and terminal", listener), "ja", "RS-232C とターミナル"),
3473: Multilingual.mlnText (
3474: ComponentFactory.createMenu (
3475: "Debug",
3476: Multilingual.mlnText (ComponentFactory.createMenuItem ("Console", listener), "ja", "コンソール"),
3477: Multilingual.mlnText (ComponentFactory.createMenuItem ("Register list", listener), "ja", "レジスタリスト"),
3478: Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble list", listener), "ja", "逆アセンブルリスト"),
3479: Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory dump list", listener), "ja", "メモリダンプリスト"),
3480: Multilingual.mlnText (ComponentFactory.createMenuItem ("Logical space monitor", listener), "ja", "論理空間モニタ"),
3481: Multilingual.mlnText (ComponentFactory.createMenuItem ("Physical space monitor", listener), "ja", "物理空間モニタ"),
3482: ATCMonitor.ACM_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Address translation caches monitor", listener), "ja", "アドレス変換キャッシュモニタ") : null,
3483: BranchLog.BLG_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Branch log", listener), "ja", "分岐ログ") : null,
3484: ProgramFlowVisualizer.PFV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Program flow visualizer", listener), "ja", "プログラムフロービジュアライザ") : null,
3485: RasterBreakPoint.RBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Raster break point", listener), "ja", "ラスタブレークポイント") : null,
3486: DataBreakPoint.DBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Data break point", listener), "ja", "データブレークポイント") : null,
3487: RootPointerList.RTL_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Root pointer list", listener), "ja", "ルートポインタリスト") : null,
3488: ComponentFactory.createHorizontalSeparator (),
3489: SRAM.smrRomdbMenu
3490: ),
3491: "ja", "デバッグ"),
3492: SRAM.smrBootMenu,
3493: mainMemoryMenu,
3494: highMemoryMenu,
3495: localMemoryMenu,
3496: xellent30Menu,
3497: ComponentFactory.createHorizontalSeparator (),
3498: ComponentFactory.createMenu (
3499: "RTC",
3500: Multilingual.mlnText (
3501: ComponentFactory.createMenuItem ("Adjust clock to host", listener),
3502: "ja", "時計をホストに合わせる")
3503: ),
3504: SRAM.smrMenu,
3505: Settings.sgsMenu,
3506: ComponentFactory.createHorizontalSeparator (),
3507: Multilingual.mlnText (ComponentFactory.createMenuItem ("Printer", listener), "ja", "プリンタ"),
3508: ROM.romMenu,
3509: Multilingual.mlnText (
3510: ComponentFactory.createMenu (
3511: "Miscellaneous",
3512: SlowdownTest.sdtCheckBoxMenuItem,
3513: SlowdownTest.sdtBox,
3514: Multilingual.mlnText (
3515: ComponentFactory.createCheckBoxMenuItem (Mouse.musOutputButtonStatus, "Mouse button status", listener),
3516: "ja", "マウスのボタンの状態"),
3517: Z8530.SCC_DEBUG_ON ? Z8530.sccDebugMenu : null
3518: ),
3519: "ja", "その他"),
3520: ComponentFactory.createHorizontalSeparator (),
3521: Multilingual.mlnText (
3522: ComponentFactory.createMenuItem ("Java runtime environment information", listener),
3523: "ja", "Java 実行環境の情報"),
3524: Multilingual.mlnText (
3525: ComponentFactory.createMenuItem ("Version information", listener),
3526: "ja", "バージョン情報"),
3527: Multilingual.mlnText (
3528: ComponentFactory.createMenu (
3529: "License",
3530: Multilingual.mlnText (ComponentFactory.createMenuItem ("XEiJ License", listener), "ja", "XEiJ 使用許諾条件"),
3531: Multilingual.mlnText (ComponentFactory.createMenuItem ("FSHARP License", listener), "ja", "FSHARP 許諾条件"),
3532: Multilingual.mlnText (ComponentFactory.createMenuItem ("ymfm License", listener), "ja", "ymfm License"),
3533: Multilingual.mlnText (ComponentFactory.createMenuItem ("jSerialComm License", listener), "ja", "jSerialComm License")
3534: ),
3535: "ja", "使用許諾条件")
3536: ),
3537: "ja", "設定"),
3538:
3539: mnbMakeLanguageMenu (),
3540:
3541:
3542: Box.createHorizontalGlue (),
3543: ComponentFactory.createVerticalBox (
3544: Box.createVerticalGlue (),
3545: Indicator.indBox,
3546: Box.createVerticalGlue ()
3547: ),
3548: Box.createHorizontalGlue ()
3549:
3550: );
3551: }
3552:
3553:
3554:
3555:
3556:
3557:
3558:
3559: public static boolean frmIsActive;
3560:
3561:
3562: public static JFrame frmFrame;
3563: public static int frmMarginWidth;
3564: public static int frmMarginHeight;
3565: public static Dimension frmMinimumSize;
3566:
3567:
3568: public static GraphicsDevice frmScreenDevice;
3569:
3570:
3571: public static DropTarget frmDropTarget;
3572:
3573:
3574:
3575: public static void frmInit () {
3576: frmIsActive = false;
3577: frmScreenDevice = GraphicsEnvironment.getLocalGraphicsEnvironment ().getDefaultScreenDevice ();
3578: pnlIsFullScreenSupported = frmScreenDevice.isFullScreenSupported ();
3579: }
3580:
3581:
3582:
3583: public static void frmMake () {
3584:
3585:
3586: frmFrame = ComponentFactory.createRestorableFrame (
3587: Settings.SGS_FRM_FRAME_KEY,
3588: PRG_TITLE + " version " + PRG_VERSION,
3589: mnbMenuBar,
3590: pnlPanel);
3591: frmUpdateTitle ();
3592: frmFrame.setIconImage (LnF.LNF_ICON_IMAGE_48);
3593: frmFrame.setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);
3594:
3595:
3596:
3597:
3598: frmMarginWidth = frmFrame.getWidth () - pnlPanel.getWidth ();
3599: frmMarginHeight = frmFrame.getHeight () - pnlPanel.getHeight ();
3600: frmMinimumSize = new Dimension (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
3601: frmFrame.setMinimumSize (frmMinimumSize);
3602:
3603:
3604:
3605: frmDropTarget = new DropTarget (pnlPanel, DnDConstants.ACTION_COPY, new DropTargetAdapter () {
3606: @Override public void dragOver (DropTargetDragEvent dtde) {
3607: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
3608: dtde.acceptDrag (DnDConstants.ACTION_COPY);
3609: return;
3610: }
3611: dtde.rejectDrag ();
3612: }
3613: @Override public void drop (DropTargetDropEvent dtde) {
3614: try {
3615: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
3616: dtde.acceptDrop (DnDConstants.ACTION_COPY);
3617: boolean reset = false;
3618: int fdu0 = -1;
3619: int fdu = 0;
3620: int hdu0 = -1;
3621: int hdu = 0;
3622: int scu0 = -1;
3623: int scu = 0;
3624: int hfu0 = -1;
3625: int hfu = 0;
3626: for (Object o : (java.util.List) dtde.getTransferable ().getTransferData (DataFlavor.javaFileListFlavor)) {
3627: if (o instanceof File) {
3628: File file = (File) o;
3629: if (file.isFile ()) {
3630: if (FDC.fdcFileFilter.accept (file)) {
3631: if (fdu < FDC.FDC_MAX_UNITS &&
3632: FDC.fdcUnitArray[fdu].insert (file.getPath (), false)) {
3633: if (fdu0 < 0) {
3634: fdu0 = fdu;
3635: }
3636: fdu++;
3637: continue;
3638: }
3639: }
3640: if (HDC.hdcFileFilter.accept (file)) {
3641: if (hdu < 16 &&
3642: HDC.hdcUnitArray[hdu].insert (file.getPath (), false)) {
3643: if (hdu0 < 0) {
3644: hdu0 = hdu;
3645: }
3646: hdu++;
3647: continue;
3648: }
3649: }
3650: if (SPC.spcFileFilter.accept (file)) {
3651: if (scu < 16 &&
3652: SPC.spcUnitArray[scu].insert (file.getPath (), false)) {
3653: if (scu0 < 0) {
3654: scu0 = scu;
3655: }
3656: scu++;
3657: continue;
3658: }
3659: }
3660: }
3661: if (HFS.hfsFileFilter.accept (file)) {
3662: if (hfu < HFS.HFS_MAX_UNITS &&
3663: HFS.hfsUnitArray[hfu].insert (file.getPath (), false)) {
3664: if (hfu0 < 0) {
3665: hfu0 = hfu;
3666: }
3667: hfu++;
3668: continue;
3669: }
3670: }
3671: }
3672: reset = false;
3673: }
3674: dtde.dropComplete (true);
3675: if (reset) {
3676: if (fdu0 >= 0) {
3677: mpuReset (0x9070 | fdu0 << 8, -1);
3678: } else if (hdu0 >= 0) {
3679: mpuReset (0x8000 | hdu0 << 8, -1);
3680: } else if (scu0 >= 0) {
3681: mpuReset (0xa000, SPC.SPC_HANDLE_EX + (scu0 << 2));
3682: } else if (hfu0 >= 0) {
3683: HFS.hfsBootUnit = hfu0;
3684: mpuReset (0xa000, HFS.HFS_BOOT_HANDLE);
3685: }
3686: }
3687: return;
3688: }
3689: } catch (UnsupportedFlavorException ufe) {
3690:
3691: } catch (IOException ioe) {
3692:
3693: }
3694: dtde.rejectDrop();
3695: }
3696: });
3697:
3698: }
3699:
3700:
3701:
3702: public static void frmUpdateTitle () {
3703: frmFrame.setTitle ((currentAccelerator == ACCELERATOR_HYBRID ? "X68000 Hybrid" :
3704: currentModel.getName () +
3705: (currentAccelerator == ACCELERATOR_XELLENT30 ? " with Xellent30" :
3706: currentAccelerator == ACCELERATOR_060TURBO ? " with 060turbo" :
3707: currentAccelerator == ACCELERATOR_060TURBOPRO ? " with 060turboPRO" : "")) +
3708: " - " + PRG_TITLE + " version " + PRG_VERSION);
3709: }
3710:
3711:
3712:
3713: public static void frmStart () {
3714:
3715:
3716:
3717:
3718:
3719:
3720:
3721:
3722: ComponentFactory.addListener (
3723: frmFrame,
3724: new WindowAdapter () {
3725: @Override public void windowActivated (WindowEvent we) {
3726: frmIsActive = true;
3727: }
3728: @Override public void windowClosing (WindowEvent we) {
3729: prgTini ();
3730: }
3731: @Override public void windowDeactivated (WindowEvent we) {
3732: frmIsActive = false;
3733:
3734: }
3735: @Override public void windowOpened (WindowEvent we) {
3736: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3737: pnlFixedRate = pnlGetRefreshRate ();
3738: }
3739: }
3740: });
3741:
3742:
3743:
3744:
3745: ComponentFactory.addListener (
3746: frmFrame,
3747: new ComponentAdapter () {
3748: @Override public void componentMoved (ComponentEvent ce) {
3749: Point p = pnlPanel.getLocationOnScreen ();
3750: pnlGlobalX = p.x;
3751: pnlGlobalY = p.y;
3752: }
3753: @Override public void componentResized (ComponentEvent ce) {
3754: Point p = pnlPanel.getLocationOnScreen ();
3755: pnlGlobalX = p.x;
3756: pnlGlobalY = p.y;
3757: }
3758: });
3759:
3760: }
3761:
3762:
3763:
3764:
3765:
3766:
3767: public static BufferedImage clpClipboardImage;
3768: public static String clpClipboardString;
3769: public static Clipboard clpClipboard;
3770: public static Transferable clpImageContents;
3771: public static Transferable clpStringContents;
3772: public static ClipboardOwner clpClipboardOwner;
3773: public static boolean clpIsClipboardOwner;
3774:
3775:
3776:
3777:
3778: public static void clpMake () {
3779: Toolkit toolkit = Toolkit.getDefaultToolkit ();
3780: clpClipboard = null;
3781: try {
3782: clpClipboard = toolkit.getSystemClipboard ();
3783: } catch (Exception e) {
3784: return;
3785: }
3786: clpClipboardImage = null;
3787: clpClipboardString = null;
3788: clpImageContents = new Transferable () {
3789: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
3790: if (flavor == DataFlavor.imageFlavor) {
3791: return clpClipboardImage;
3792: } else {
3793: throw new UnsupportedFlavorException (flavor);
3794: }
3795: }
3796: public DataFlavor[] getTransferDataFlavors () {
3797: return new DataFlavor[] { DataFlavor.imageFlavor };
3798: }
3799: public boolean isDataFlavorSupported (DataFlavor flavor) {
3800: return flavor == DataFlavor.imageFlavor;
3801: }
3802: };
3803: clpStringContents = new Transferable () {
3804: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
3805: if (flavor == DataFlavor.stringFlavor) {
3806: return clpClipboardString;
3807: } else {
3808: throw new UnsupportedFlavorException (flavor);
3809: }
3810: }
3811: public DataFlavor[] getTransferDataFlavors () {
3812: return new DataFlavor[] { DataFlavor.stringFlavor };
3813: }
3814: public boolean isDataFlavorSupported (DataFlavor flavor) {
3815: return flavor == DataFlavor.stringFlavor;
3816: }
3817: };
3818: clpIsClipboardOwner = false;
3819:
3820:
3821: clpClipboardOwner = new ClipboardOwner () {
3822: @Override public void lostOwnership (Clipboard clipboard, Transferable contents) {
3823: clpIsClipboardOwner = false;
3824: }
3825: };
3826:
3827:
3828: clpClipboard.addFlavorListener (new FlavorListener () {
3829: @Override public void flavorsChanged (FlavorEvent fe) {
3830: boolean available = false;
3831: try {
3832: available = clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor);
3833: } catch (IllegalStateException ise) {
3834: }
3835: if (mnbPasteMenuItem != null) {
3836: mnbPasteMenuItem.setEnabled (available);
3837: }
3838: }
3839: });
3840: if (!clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor)) {
3841: if (mnbPasteMenuItem != null) {
3842: mnbPasteMenuItem.setEnabled (false);
3843: }
3844: }
3845: }
3846:
3847:
3848:
3849: public static void clpCopy (String s) {
3850: if (clpClipboard != null && s != null) {
3851: clpClipboardString = s;
3852: try {
3853: clpClipboard.setContents (clpStringContents, clpClipboardOwner);
3854: clpIsClipboardOwner = true;
3855: } catch (Exception e) {
3856: return;
3857: }
3858: }
3859: }
3860:
3861:
3862:
3863:
3864:
3865:
3866:
3867:
3868:
3869:
3870:
3871:
3872:
3873:
3874:
3875:
3876:
3877:
3878:
3879:
3880:
3881:
3882:
3883: public static int xt3DIPSWRequest;
3884: public static int xt3DIPSW;
3885: public static int xt3PortAddress;
3886:
3887:
3888: public static int xt3MemorySizeRequest;
3889: public static int xt3MemorySize;
3890: public static boolean xt3MemoryEnabled;
3891: public static int xt3MemoryPosition;
3892: public static int xt3MemoryStart;
3893: public static final byte[] xt3MemoryArray = new byte[1 << 20];
3894: public static boolean xt3MemorySave;
3895:
3896:
3897: public static int xt3SavedPC;
3898: public static final int[] xt3SavedRn = new int[16];
3899:
3900:
3901: public static void xt3Init () {
3902:
3903:
3904: xt3DIPSWRequest = Math.max (0, Math.min (3, Settings.sgsGetInt ("xt3dipsw")));
3905: xt3DIPSW = xt3DIPSWRequest;
3906:
3907:
3908: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
3909:
3910:
3911: int memoryKB = Settings.sgsGetInt ("xt3memorykb");
3912: if (!(memoryKB == 1 << 8 || memoryKB == 1 << 10)) {
3913: memoryKB = 1 << 8;
3914: }
3915: xt3MemorySizeRequest = memoryKB << 10;
3916: xt3MemorySize = xt3MemorySizeRequest;
3917:
3918:
3919: xt3MemoryEnabled = false;
3920:
3921:
3922: xt3MemoryPosition = 11 << 20;
3923:
3924:
3925: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
3926:
3927:
3928:
3929: byte[] memoryArray = Settings.sgsGetData ("xt3memorydata");
3930: Arrays.fill (xt3MemoryArray,
3931: (byte) 0);
3932: if (memoryArray.length != 0) {
3933: System.arraycopy (memoryArray, 0,
3934: xt3MemoryArray, 0,
3935: Math.min (memoryArray.length, xt3MemoryArray.length));
3936: if (memoryArray.length < xt3MemoryArray.length) {
3937: Arrays.fill (xt3MemoryArray,
3938: memoryArray.length,
3939: xt3MemoryArray.length,
3940: (byte) 0);
3941: }
3942: }
3943:
3944:
3945: xt3MemorySave = Settings.sgsGetOnOff ("xt3memorysave");
3946:
3947:
3948: xt3SavedPC = 0;
3949:
3950: Arrays.fill (xt3SavedRn, 0);
3951:
3952: xt3Reset ();
3953: }
3954:
3955:
3956: public static void xt3Tini () {
3957:
3958:
3959: Settings.sgsPutInt ("xt3dipsw", xt3DIPSW);
3960:
3961:
3962: Settings.sgsPutInt ("xt3memorykb", xt3MemorySizeRequest >> 10);
3963:
3964:
3965: boolean zero = true;
3966: if (xt3MemorySave) {
3967: for (int i = 0; i < 1 << 20; i++) {
3968: if (xt3MemoryArray[i] != 0) {
3969: zero = false;
3970: break;
3971: }
3972: }
3973: }
3974: Settings.sgsCurrentMap.put ("xt3memorydata",
3975: zero ? "" :
3976: ByteArray.byaEncodeBase64 (ByteArray.byaEncodeGzip (xt3MemoryArray, 0, 1 << 20)));
3977:
3978:
3979: Settings.sgsPutOnOff ("xt3memorysave", xt3MemorySave);
3980:
3981: }
3982:
3983:
3984: public static void xt3Reset () {
3985:
3986:
3987: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
3988:
3989:
3990: xt3MemorySize = xt3MemorySizeRequest;
3991:
3992:
3993: xt3MemoryEnabled = false;
3994:
3995:
3996: xt3MemoryPosition = 11 << 20;
3997:
3998:
3999: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4000:
4001:
4002: xt3SavedPC = 0;
4003: Arrays.fill (xt3SavedRn, 0);
4004:
4005: }
4006:
4007:
4008: public static int xt3PortRead () {
4009: return (currentIsSecond ? 4 : 0) | (xt3MemoryEnabled ? 2 : 0) | (xt3MemoryPosition == 11 << 20 ? 0 : 1);
4010: }
4011:
4012:
4013: public static void xt3PortWrite (int d) {
4014: boolean nextIsSecond = (d & 4) != 0;
4015: boolean memoryEnabled = (d & 2) != 0;
4016: int memoryPosition = (d & 1) == 0 ? 11 << 20 : 15 << 20;
4017:
4018: if (xt3MemoryEnabled != memoryEnabled ||
4019: xt3MemoryPosition != memoryPosition) {
4020: if (xt3MemoryEnabled) {
4021: if (xt3MemoryPosition == 11 << 20) {
4022: if (MainMemory.mmrMemorySizeCurrent < 12 << 20) {
4023: busSuper (MemoryMappedDevice.MMD_NUL, (12 << 20) - xt3MemorySize, 12 << 20);
4024: } else {
4025: busUser (MemoryMappedDevice.MMD_MMR, (12 << 20) - xt3MemorySize, 12 << 20);
4026: }
4027: } else {
4028: busSuper (MemoryMappedDevice.MMD_ROM, (16 << 20) - xt3MemorySize, 16 << 20);
4029: }
4030: }
4031: xt3MemoryEnabled = memoryEnabled;
4032: xt3MemoryPosition = memoryPosition;
4033: if (xt3MemoryEnabled) {
4034: if (xt3MemoryPosition == 11 << 20) {
4035: busUser (MemoryMappedDevice.MMD_XTM, (12 << 20) - xt3MemorySize, 12 << 20);
4036: } else {
4037: busUser (MemoryMappedDevice.MMD_XTM, (16 << 20) - xt3MemorySize, 16 << 20);
4038: }
4039: }
4040: }
4041:
4042: if (currentIsSecond != nextIsSecond) {
4043:
4044: if (nextIsSecond) {
4045:
4046:
4047: xt3SavedPC = regPC;
4048: System.arraycopy (regRn, 0, xt3SavedRn, 0, 16);
4049:
4050:
4051: if (mpuTask != null) {
4052: mpuClockLimit = 0L;
4053: System.out.println (Multilingual.mlnJapanese ?
4054: Model.MPU_NAMES[currentFirstMPU] + " を停止します" :
4055: Model.MPU_NAMES[currentFirstMPU] + " stops");
4056: mpuTask.cancel ();
4057: mpuTask = null;
4058: }
4059:
4060:
4061: tmrTimer.schedule (new TimerTask () {
4062: @Override public void run () {
4063:
4064:
4065: currentIsSecond = true;
4066: currentMPU = currentSecondMPU;
4067: mpuSetCurrentClock (specifiedSecondClock);
4068:
4069: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
4070: MC68EC030.m30DivZeroVFlag = false;
4071: }
4072:
4073: RegisterList.drpSetMPU ();
4074: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4075: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4076: MC68060.mmuReset ();
4077:
4078: mpuIgnoreAddressError = true;
4079: fpuBox = fpuMotherboardCoprocessor;
4080: fpuBox.epbReset ();
4081: fpuFPn = fpuBox.epbFPn;
4082: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
4083: mpuSetWait ();
4084:
4085: regSRT1 = regSRT0 = 0;
4086: regSRS = REG_SR_S;
4087: regSRM = 0;
4088: regSRI = REG_SR_I;
4089: regCCR = 0;
4090: Arrays.fill (regRn, 0);
4091:
4092: regRn[15] = MainMemory.mmrRls (0x00000000);
4093: regPC = MainMemory.mmrRls (0x00000004);
4094:
4095: mpuIMR = 0;
4096: mpuIRR = 0;
4097: if (MC68901.MFP_DELAYED_INTERRUPT) {
4098: mpuDIRR = 0;
4099: }
4100: mpuISR = 0;
4101:
4102: mpuStart ();
4103: }
4104: }, TMR_DELAY);
4105:
4106: } else {
4107:
4108:
4109: if (mpuTask != null) {
4110: mpuClockLimit = 0L;
4111: System.out.println (Multilingual.mlnJapanese ? "MC68EC030 を停止します" : "MC68EC030 stops");
4112: mpuTask.cancel ();
4113: mpuTask = null;
4114: }
4115:
4116:
4117: tmrTimer.schedule (new TimerTask () {
4118: @Override public void run () {
4119:
4120:
4121: currentIsSecond = false;
4122: currentMPU = currentFirstMPU;
4123: mpuSetCurrentClock (specifiedFirstClock);
4124:
4125: RegisterList.drpSetMPU ();
4126: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4127: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4128: MC68060.mmuReset ();
4129:
4130: mpuIgnoreAddressError = false;
4131: mpuCacheOn = false;
4132: mpuSetWait ();
4133:
4134: regSRT1 = regSRT0 = 0;
4135: regSRS = REG_SR_S;
4136: regSRM = 0;
4137: regSRI = REG_SR_I;
4138: regCCR = 0;
4139:
4140: regPC = xt3SavedPC;
4141: System.arraycopy (xt3SavedRn, 0, regRn, 0, 16);
4142:
4143: mpuIMR = 0;
4144: mpuIRR = 0;
4145: if (MC68901.MFP_DELAYED_INTERRUPT) {
4146: mpuDIRR = 0;
4147: }
4148: mpuISR = 0;
4149:
4150: mpuStart ();
4151: }
4152: }, TMR_DELAY);
4153:
4154: }
4155: }
4156: }
4157:
4158:
4159:
4160:
4161:
4162:
4163: public static JMenu mdlMenu;
4164:
4165: public static JRadioButtonMenuItem mdlShodaiMenuItem;
4166: public static JRadioButtonMenuItem mdlACEMenuItem;
4167: public static JRadioButtonMenuItem mdlEXPERTMenuItem;
4168: public static JRadioButtonMenuItem mdlPROMenuItem;
4169: public static JRadioButtonMenuItem mdlSUPERMenuItem;
4170: public static JRadioButtonMenuItem mdlXVIMenuItem;
4171: public static JRadioButtonMenuItem mdlXellent30MenuItem;
4172: public static JRadioButtonMenuItem mdlCompactMenuItem;
4173: public static JRadioButtonMenuItem mdlHybridMenuItem;
4174: public static JRadioButtonMenuItem mdl060turboPROMenuItem;
4175: public static JRadioButtonMenuItem mdlX68030MenuItem;
4176: public static JRadioButtonMenuItem mdl030CompactMenuItem;
4177: public static JRadioButtonMenuItem mdl060turboMenuItem;
4178: public static JCheckBoxMenuItem mdlMC68010MenuItem;
4179:
4180: public static JMenu coproFPUMenu;
4181:
4182:
4183: public static final int ACCELERATOR_HYBRID = 1;
4184: public static final int ACCELERATOR_XELLENT30 = 2;
4185: public static final int ACCELERATOR_060TURBO = 3;
4186: public static final int ACCELERATOR_060TURBOPRO = 4;
4187: public static final double MHZ_HYBRID_VALUE = 100.0 / 3.0;
4188: public static final String MHZ_HYBRID_STRING = "33.3";
4189: public static final double MHZ_060TURBO_VALUE = 50.0;
4190: public static final String MHZ_060TURBO_STRING = "50";
4191:
4192:
4193:
4194: public static Model specifiedModel;
4195: public static int specifiedAccelerator;
4196: public static boolean mpu010;
4197:
4198: public static boolean specifiedIsSecond;
4199: public static int specifiedFirstMPU;
4200: public static int specifiedSecondMPU;
4201: public static int specifiedMPU;
4202:
4203: public static double specifiedFirstClock;
4204: public static double specifiedSecondClock;
4205: public static double specifiedClock;
4206:
4207: public static int specifiedCopro0;
4208: public static int specifiedCopro1;
4209: public static int specifiedCopro2;
4210: public static int specifiedOnchipFPU;
4211:
4212:
4213:
4214: public static Model currentModel;
4215: public static int currentAccelerator;
4216:
4217: public static boolean currentIsSecond;
4218: public static int currentFirstMPU;
4219: public static int currentSecondMPU;
4220: public static int currentMPU;
4221:
4222:
4223: public static int currentCopro0;
4224: public static int currentCopro1;
4225: public static int currentCopro2;
4226: public static int currentOnchipFPU;
4227:
4228:
4229:
4230: public static void mdlInit () {
4231:
4232:
4233: specifiedModel = Model.COMPACT;
4234: specifiedAccelerator = ACCELERATOR_HYBRID;
4235: mpu010 = Settings.sgsGetOnOff ("mpu010");
4236: {
4237: String paramModel = Settings.sgsGetString ("model");
4238: switch (paramModel.toLowerCase ()) {
4239: case "":
4240: case "none":
4241: case "hybrid":
4242: specifiedModel = Model.COMPACT;
4243: specifiedAccelerator = ACCELERATOR_HYBRID;
4244: break;
4245: case "xellent30":
4246: specifiedModel = Model.XVI;
4247: specifiedAccelerator = ACCELERATOR_XELLENT30;
4248: break;
4249: case "060turbo":
4250: specifiedModel = Model.X68030;
4251: specifiedAccelerator = ACCELERATOR_060TURBO;
4252: break;
4253: case "060turbopro":
4254: specifiedModel = Model.PRO;
4255: specifiedAccelerator = ACCELERATOR_060TURBOPRO;
4256: break;
4257: default:
4258: Model model = Model.fromTypeOrSynonym (paramModel);
4259: if (model != null) {
4260: specifiedModel = model;
4261: specifiedAccelerator = 0;
4262: } else {
4263: System.out.println (Multilingual.mlnJapanese ?
4264: paramModel + " は不明な機種です" :
4265: paramModel + " is unknown model");
4266: specifiedModel = Model.COMPACT;
4267: specifiedAccelerator = ACCELERATOR_HYBRID;
4268: }
4269: }
4270: }
4271:
4272: specifiedIsSecond = false;
4273: specifiedFirstMPU = specifiedModel.getMPU ();
4274: specifiedSecondMPU = Model.MPU_MC68EC030;
4275: {
4276: String[] paramMPUs = Settings.sgsGetString ("mpu").split (",");
4277: for (int i = 0; i < 2; i++) {
4278: int mpu = 0;
4279: String paramMPU = i < paramMPUs.length ? paramMPUs[i] : "";
4280: switch (paramMPU) {
4281: case "":
4282: case "none":
4283: case "-1":
4284: mpu = (i == 0 ?
4285: (specifiedAccelerator == ACCELERATOR_060TURBO ||
4286: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4287: specifiedModel.getMPU ()) :
4288: Model.MPU_MC68EC030);
4289: break;
4290: case "0":
4291: case "68000":
4292: case "mc68000":
4293: mpu = Model.MPU_MC68000;
4294: break;
4295: case "1":
4296: case "68010":
4297: case "mc68010":
4298: mpu = Model.MPU_MC68010;
4299: break;
4300:
4301:
4302:
4303:
4304:
4305: case "3":
4306: case "68ec030":
4307: case "mc68ec030":
4308: mpu = Model.MPU_MC68EC030;
4309: break;
4310:
4311:
4312:
4313:
4314:
4315:
4316:
4317:
4318:
4319:
4320:
4321:
4322:
4323:
4324:
4325:
4326:
4327: case "6":
4328: case "68060":
4329: case "mc68060":
4330: mpu = Model.MPU_MC68060;
4331: break;
4332: default:
4333: Model model = Model.fromTypeOrSynonym (paramMPU);
4334: if (model != null) {
4335: mpu = model.getMPU ();
4336: } else {
4337: System.out.println (Multilingual.mlnJapanese ?
4338: paramMPU + " は不明な MPU です" :
4339: paramMPU + " is unknown MPU");
4340: mpu = specifiedModel.getMPU ();
4341: }
4342: }
4343: if (i == 0) {
4344: specifiedFirstMPU = mpu;
4345: } else {
4346: specifiedSecondMPU = mpu;
4347: }
4348: }
4349: }
4350: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
4351:
4352: specifiedFirstClock = specifiedModel.getClock ();
4353: specifiedSecondClock = specifiedFirstClock * 2.0;
4354: {
4355: String[] paramClocks = Settings.sgsGetString ("clock").split (",");
4356: for (int i = 0; i < 2; i++) {
4357: double clock = 0.0;
4358: String paramClock = i < paramClocks.length ? paramClocks[i] : "";
4359: switch (paramClock.toLowerCase ()) {
4360: case "":
4361: case "none":
4362: case "-1":
4363: clock = (i == 0 ?
4364: (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4365: specifiedAccelerator == ACCELERATOR_060TURBO ||
4366: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4367: specifiedModel.getClock ()) :
4368: specifiedFirstClock * 2.0);
4369: break;
4370: case "hybrid":
4371: clock = MHZ_HYBRID_VALUE;
4372: break;
4373: case "060turbo":
4374: case "060turbopro":
4375: clock = MHZ_060TURBO_VALUE;
4376: break;
4377: case "16.7":
4378: case "xellent30":
4379: clock = 50.0 / 3.0;
4380: break;
4381: case "33.3":
4382: clock = 100.0 / 3.0;
4383: break;
4384: case "66.7":
4385: clock = 200.0 / 3.0;
4386: break;
4387: default:
4388: if (paramClock.matches ("^(?:" +
4389: "[-+]?" +
4390: "(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)" +
4391: "(?:[Ee][-+]?[0-9]+)?" +
4392: ")$")) {
4393: double d = Double.parseDouble (paramClock);
4394: if (1.0 <= d && d <= 1000.0) {
4395: clock = d;
4396: }
4397: } else {
4398: System.out.println (Multilingual.mlnJapanese ?
4399: paramClock + " は不明な動作周波数です" :
4400: paramClock + " is unknown clock frequency");
4401: clock = specifiedModel.getClock ();
4402: }
4403: }
4404: if (i == 0) {
4405: specifiedFirstClock = clock;
4406: } else {
4407: specifiedSecondClock = clock;
4408: }
4409: }
4410: }
4411: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4412:
4413: specifiedCopro0 = 15 & Settings.sgsGetInt ("copro0", 2);
4414: if (!((7 & specifiedCopro0) == 0 ||
4415: (7 & specifiedCopro0) == 1 ||
4416: (7 & specifiedCopro0) == 2 ||
4417: (7 & specifiedCopro0) == 7)) {
4418: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4419: }
4420: specifiedCopro1 = 15 & Settings.sgsGetInt ("copro1", 2);
4421: if (!((7 & specifiedCopro1) == 0 ||
4422: (7 & specifiedCopro1) == 1 ||
4423: (7 & specifiedCopro1) == 2 ||
4424: (7 & specifiedCopro1) == 7)) {
4425: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4426: }
4427: specifiedCopro2 = 15 & Settings.sgsGetInt ("copro2", 2);
4428: if (!((7 & specifiedCopro2) == 0 ||
4429: (7 & specifiedCopro2) == 1 ||
4430: (7 & specifiedCopro2) == 2 ||
4431: (7 & specifiedCopro2) == 7)) {
4432: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4433: }
4434: specifiedOnchipFPU = 15 & Settings.sgsGetInt ("onchipfpu", 7);
4435: if (!((7 & specifiedOnchipFPU) == 0 ||
4436: (7 & specifiedOnchipFPU) == 6 ||
4437: (7 & specifiedOnchipFPU) == 7)) {
4438: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4439: }
4440:
4441:
4442: currentModel = specifiedModel;
4443: currentAccelerator = specifiedAccelerator;
4444:
4445: currentIsSecond = specifiedIsSecond;
4446: currentFirstMPU = specifiedFirstMPU;
4447: currentSecondMPU = specifiedSecondMPU;
4448: currentMPU = specifiedMPU;
4449:
4450:
4451: currentCopro0 = specifiedCopro0;
4452: currentCopro1 = specifiedCopro1;
4453: currentCopro2 = specifiedCopro2;
4454: currentOnchipFPU = specifiedOnchipFPU;
4455:
4456:
4457: mpuUtilOn = Settings.sgsGetOnOff ("util");
4458: mpuUtilRatio = fmtParseInt (Settings.sgsGetString ("ratio"), 0, 1, 100, 100);
4459:
4460: mpuArbFreqMHz = fmtParseInt (Settings.sgsGetString ("mhz"), 0, 1, 1000, 100);
4461: if (mpuUtilOn) {
4462: mpuArbFreqOn = false;
4463: } else {
4464: mpuArbFreqOn = !(specifiedClock == 10.0 ||
4465: specifiedClock == 50.0 / 3.0 ||
4466: specifiedClock == 25.0 ||
4467: specifiedClock == 100.0 / 3.0 ||
4468: specifiedClock == 50.0 ||
4469: specifiedClock == 200.0 / 3.0 ||
4470: specifiedClock == 75.0 ||
4471: specifiedClock == 100.0);
4472: if (mpuArbFreqOn) {
4473: mpuArbFreqMHz = (int) specifiedClock;
4474: }
4475: }
4476:
4477:
4478: mpuROMWaitCycles = 0;
4479: mpuRAMWaitCycles = 0;
4480: mpuCacheOn = false;
4481:
4482: mpuNoWaitTime.ram = 0;
4483: mpuNoWaitTime.gvram = 0;
4484: mpuNoWaitTime.tvram = 0;
4485: mpuNoWaitTime.crtc = 0;
4486: mpuNoWaitTime.palet = 0;
4487: mpuNoWaitTime.vicon = 0;
4488: mpuNoWaitTime.dmac = 0;
4489: mpuNoWaitTime.mfp = 0;
4490: mpuNoWaitTime.rtc = 0;
4491: mpuNoWaitTime.prnport = 0;
4492: mpuNoWaitTime.sysport = 0;
4493: mpuNoWaitTime.opm = 0;
4494: mpuNoWaitTime.adpcm = 0;
4495: mpuNoWaitTime.fdc = 0;
4496: mpuNoWaitTime.fdd = 0;
4497: mpuNoWaitTime.hdc = 0;
4498: mpuNoWaitTime.scc = 0;
4499: mpuNoWaitTime.ppi = 0;
4500: mpuNoWaitTime.ioi = 0;
4501: mpuNoWaitTime.sprc = 0;
4502: mpuNoWaitTime.sram = 0;
4503: mpuNoWaitTime.rom = 0;
4504: mpuNoWaitTime.ramlong = mpuNoWaitTime.ram << 1;
4505: mpuNoWaitTime.romlong = mpuNoWaitTime.rom << 1;
4506:
4507: dmaNoWaitTime.ram = 0;
4508: dmaNoWaitTime.gvram = 0;
4509: dmaNoWaitTime.tvram = 0;
4510: dmaNoWaitTime.crtc = 0;
4511: dmaNoWaitTime.palet = 0;
4512: dmaNoWaitTime.vicon = 0;
4513: dmaNoWaitTime.dmac = 0;
4514: dmaNoWaitTime.mfp = 0;
4515: dmaNoWaitTime.rtc = 0;
4516: dmaNoWaitTime.prnport = 0;
4517: dmaNoWaitTime.sysport = 0;
4518: dmaNoWaitTime.opm = 0;
4519: dmaNoWaitTime.adpcm = 0;
4520: dmaNoWaitTime.fdc = 0;
4521: dmaNoWaitTime.fdd = 0;
4522: dmaNoWaitTime.hdc = 0;
4523: dmaNoWaitTime.scc = 0;
4524: dmaNoWaitTime.ppi = 0;
4525: dmaNoWaitTime.ioi = 0;
4526: dmaNoWaitTime.sprc = 0;
4527: dmaNoWaitTime.sram = 0;
4528: dmaNoWaitTime.rom = 0;
4529: dmaNoWaitTime.ramlong = dmaNoWaitTime.ram << 1;
4530: dmaNoWaitTime.romlong = dmaNoWaitTime.rom << 1;
4531:
4532:
4533: busWaitCyclesRequest = Settings.sgsGetOnOff ("waitcycles");
4534: busWaitCycles = busWaitCyclesRequest;
4535: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
4536:
4537: }
4538:
4539: public static void mdlTini () {
4540:
4541: Settings.sgsPutString ("model",
4542: specifiedAccelerator == ACCELERATOR_HYBRID ? "Hybrid" :
4543: specifiedAccelerator == ACCELERATOR_XELLENT30 ? "Xellent30" :
4544: specifiedAccelerator == ACCELERATOR_060TURBO ? "060turbo" :
4545: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? "060turboPRO" :
4546: specifiedModel.getSynonym () != null ? specifiedModel.getSynonym () :
4547: specifiedModel.getType ());
4548: Settings.sgsPutOnOff ("mpu010", mpu010);
4549:
4550:
4551: int defaultFirstMPU = (specifiedAccelerator == ACCELERATOR_060TURBO ||
4552: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4553: specifiedModel.getMPU ());
4554: int defaultSecondMPU = Model.MPU_MC68EC030;
4555: Settings.sgsPutString ("mpu",
4556: (specifiedFirstMPU == defaultFirstMPU ? "" :
4557: Model.mpuNameOf (specifiedFirstMPU)) +
4558: (specifiedSecondMPU == defaultSecondMPU ? "" :
4559: "," + Model.mpuNameOf (specifiedSecondMPU)));
4560:
4561:
4562:
4563:
4564: double defaultFirstClock = (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4565: specifiedAccelerator == ACCELERATOR_060TURBO ||
4566: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4567: specifiedModel.getClock ());
4568: double defaultSecondClock = defaultFirstClock * 2.0;
4569: Settings.sgsPutString ("clock",
4570: (specifiedFirstClock == defaultFirstClock ? "" :
4571: specifiedFirstClock == 50.0 / 3.0 ? "16.7" :
4572: specifiedFirstClock == 100.0 / 3.0 ? "33.3" :
4573: specifiedFirstClock == 200.0 / 3.0 ? "66.7" :
4574: String.valueOf ((int) specifiedFirstClock)) +
4575: (specifiedSecondClock == defaultSecondClock ? "" :
4576: "," + (specifiedSecondClock == 50.0 / 3.0 ? "16.7" :
4577: specifiedSecondClock == 100.0 / 3.0 ? "33.3" :
4578: specifiedSecondClock == 200.0 / 3.0 ? "66.7" :
4579: String.valueOf ((int) specifiedSecondClock))));
4580:
4581: Settings.sgsPutInt ("copro0", specifiedCopro0);
4582: Settings.sgsPutInt ("copro1", specifiedCopro1);
4583: Settings.sgsPutInt ("copro2", specifiedCopro2);
4584: Settings.sgsPutInt ("onchipfpu", specifiedOnchipFPU);
4585:
4586: Settings.sgsPutOnOff ("util",
4587: mpuUtilOn);
4588: Settings.sgsPutString ("ratio",
4589: String.valueOf (mpuUtilRatio));
4590:
4591: Settings.sgsPutString ("mhz",
4592: String.valueOf (mpuArbFreqMHz));
4593:
4594: Settings.sgsPutOnOff ("waitcycles", busWaitCyclesRequest);
4595: }
4596:
4597: public static void mdlMakeMenu () {
4598:
4599:
4600: ActionListener listener = new ActionListener () {
4601: @Override public void actionPerformed (ActionEvent ae) {
4602: Object source = ae.getSource ();
4603: switch (ae.getActionCommand ()) {
4604: case "X68000 (10MHz)":
4605: mdlRequestModel (Model.SHODAI, 0);
4606: mpuReset (-1, -1);
4607: break;
4608: case "X68000 ACE (10MHz)":
4609: mdlRequestModel (Model.ACE, 0);
4610: mpuReset (-1, -1);
4611: break;
4612: case "X68000 EXPERT (10MHz)":
4613: mdlRequestModel (Model.EXPERT, 0);
4614: mpuReset (-1, -1);
4615: break;
4616: case "X68000 PRO (10MHz)":
4617: mdlRequestModel (Model.PRO, 0);
4618: mpuReset (-1, -1);
4619: break;
4620: case "X68000 SUPER (10MHz)":
4621: mdlRequestModel (Model.SUPER, 0);
4622: mpuReset (-1, -1);
4623: break;
4624: case "X68000 XVI (16.7MHz)":
4625: mdlRequestModel (Model.XVI, 0);
4626: mpuReset (-1, -1);
4627: break;
4628: case "X68000 Compact (16.7MHz)":
4629: mdlRequestModel (Model.COMPACT, 0);
4630: mpuReset (-1, -1);
4631: break;
4632:
4633: case "X68030 (25MHz)":
4634: mdlRequestModel (Model.X68030, 0);
4635: mpuReset (-1, -1);
4636: break;
4637: case "X68030 Compact (25MHz)":
4638: mdlRequestModel (Model.X68030COMPACT, 0);
4639: mpuReset (-1, -1);
4640: break;
4641:
4642: case "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)":
4643: mdlRequestModel (Model.COMPACT, ACCELERATOR_HYBRID);
4644: mpuReset (-1, -1);
4645: break;
4646: case "Xellent30 (33.3MHz)":
4647: mdlRequestModel (Model.XVI, ACCELERATOR_XELLENT30);
4648: mpuReset (-1, -1);
4649: break;
4650: case "060turbo (" + MHZ_060TURBO_STRING + "MHz)":
4651: mdlRequestModel (Model.X68030, ACCELERATOR_060TURBO);
4652: mpuReset (-1, -1);
4653: break;
4654: case "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)":
4655: mdlRequestModel (Model.PRO, ACCELERATOR_060TURBOPRO);
4656: mpuReset (-1, -1);
4657: break;
4658:
4659: case "MC68010":
4660: mpu010 = ((JCheckBoxMenuItem) source).isSelected ();
4661: break;
4662:
4663: }
4664: }
4665: };
4666:
4667:
4668: ButtonGroup modelGroup = new ButtonGroup ();
4669: mdlMenu = Multilingual.mlnText (
4670: ComponentFactory.createMenu (
4671: "Change the model and reset",
4672: mdlShodaiMenuItem = ComponentFactory.createRadioButtonMenuItem (
4673: modelGroup,
4674: specifiedModel == Model.SHODAI,
4675: "X68000 (10MHz)",
4676: listener),
4677: mdlACEMenuItem = ComponentFactory.createRadioButtonMenuItem (
4678: modelGroup,
4679: specifiedModel == Model.ACE,
4680: "X68000 ACE (10MHz)",
4681: listener),
4682: mdlEXPERTMenuItem = ComponentFactory.createRadioButtonMenuItem (
4683: modelGroup,
4684: specifiedModel == Model.EXPERT,
4685: "X68000 EXPERT (10MHz)",
4686: listener),
4687: mdlPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
4688: modelGroup,
4689: specifiedModel == Model.PRO && specifiedAccelerator == 0,
4690: "X68000 PRO (10MHz)",
4691: listener),
4692: mdlSUPERMenuItem = ComponentFactory.createRadioButtonMenuItem (
4693: modelGroup,
4694: specifiedModel == Model.SUPER,
4695: "X68000 SUPER (10MHz)",
4696: listener),
4697: mdlXVIMenuItem = ComponentFactory.createRadioButtonMenuItem (
4698: modelGroup,
4699: specifiedModel == Model.XVI && specifiedAccelerator == 0,
4700: "X68000 XVI (16.7MHz)",
4701: listener),
4702: mdlCompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
4703: modelGroup,
4704: specifiedModel == Model.COMPACT && specifiedAccelerator == 0,
4705: "X68000 Compact (16.7MHz)",
4706: listener),
4707:
4708: ComponentFactory.createHorizontalSeparator (),
4709:
4710: mdlX68030MenuItem = ComponentFactory.createRadioButtonMenuItem (
4711: modelGroup,
4712: specifiedModel == Model.X68030 && specifiedAccelerator == 0,
4713: "X68030 (25MHz)",
4714: listener),
4715: mdl030CompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
4716: modelGroup,
4717: specifiedModel == Model.X68030COMPACT,
4718: "X68030 Compact (25MHz)",
4719: listener),
4720:
4721: ComponentFactory.createHorizontalSeparator (),
4722:
4723: mdlHybridMenuItem = ComponentFactory.createRadioButtonMenuItem (
4724: modelGroup,
4725: specifiedModel == Model.COMPACT && specifiedAccelerator == ACCELERATOR_HYBRID,
4726: "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)",
4727: listener),
4728: mdlXellent30MenuItem = ComponentFactory.createRadioButtonMenuItem (
4729: modelGroup,
4730: specifiedModel == Model.XVI && specifiedAccelerator == ACCELERATOR_XELLENT30,
4731: "Xellent30 (33.3MHz)",
4732: listener),
4733: mdl060turboMenuItem = ComponentFactory.createRadioButtonMenuItem (
4734: modelGroup,
4735: specifiedModel == Model.X68030 && specifiedAccelerator == ACCELERATOR_060TURBO,
4736: "060turbo (" + MHZ_060TURBO_STRING + "MHz)",
4737: listener),
4738: mdl060turboPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
4739: modelGroup,
4740: specifiedModel == Model.PRO && specifiedAccelerator == ACCELERATOR_060TURBOPRO,
4741: "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)",
4742: listener),
4743:
4744: ComponentFactory.createHorizontalSeparator (),
4745:
4746: mdlMC68010MenuItem = ComponentFactory.createCheckBoxMenuItem (
4747: mpu010,
4748: "MC68010",
4749: listener)
4750: ),
4751: "ja", "機種を変更してリセット");
4752:
4753:
4754: ActionListener copro0Listener = new ActionListener () {
4755: @Override public void actionPerformed (ActionEvent ae) {
4756: String command = ae.getActionCommand ();
4757: switch (command) {
4758: case "Not installed":
4759: specifiedCopro0 = (8 & specifiedCopro0) | 0;
4760: break;
4761: case "MC68881":
4762: specifiedCopro0 = (8 & specifiedCopro0) | 1;
4763: break;
4764: case "MC68882":
4765: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4766: break;
4767: case "Full specification":
4768: specifiedCopro0 = (8 & specifiedCopro0) | 7;
4769: break;
4770: case "Extended precision (19 digits)":
4771: specifiedCopro0 = 0 | (7 & specifiedCopro0);
4772: break;
4773: case "Triple precision (24 digits)":
4774: specifiedCopro0 = 8 | (7 & specifiedCopro0);
4775: break;
4776: default:
4777: System.out.println ("unknown action command " + command);
4778: }
4779: }
4780: };
4781:
4782: ActionListener copro1Listener = new ActionListener () {
4783: @Override public void actionPerformed (ActionEvent ae) {
4784: String command = ae.getActionCommand ();
4785: switch (command) {
4786: case "Not installed":
4787: specifiedCopro1 = (8 & specifiedCopro1) | 0;
4788: break;
4789: case "MC68881":
4790: specifiedCopro1 = (8 & specifiedCopro1) | 1;
4791: break;
4792: case "MC68882":
4793: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4794: break;
4795: case "Full specification":
4796: specifiedCopro1 = (8 & specifiedCopro1) | 7;
4797: break;
4798: case "Extended precision (19 digits)":
4799: specifiedCopro1 = 0 | (7 & specifiedCopro1);
4800: break;
4801: case "Triple precision (24 digits)":
4802: specifiedCopro1 = 8 | (7 & specifiedCopro1);
4803: break;
4804: default:
4805: System.out.println ("unknown action command " + command);
4806: }
4807: }
4808: };
4809:
4810: ActionListener copro2Listener = new ActionListener () {
4811: @Override public void actionPerformed (ActionEvent ae) {
4812: String command = ae.getActionCommand ();
4813: switch (command) {
4814: case "Not installed":
4815: specifiedCopro2 = (8 & specifiedCopro2) | 0;
4816: break;
4817: case "MC68881":
4818: specifiedCopro2 = (8 & specifiedCopro2) | 1;
4819: break;
4820: case "MC68882":
4821: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4822: break;
4823: case "Full specification":
4824: specifiedCopro2 = (8 & specifiedCopro2) | 7;
4825: break;
4826: case "Extended precision (19 digits)":
4827: specifiedCopro2 = 0 | (7 & specifiedCopro2);
4828: break;
4829: case "Triple precision (24 digits)":
4830: specifiedCopro2 = 8 | (7 & specifiedCopro2);
4831: break;
4832: default:
4833: System.out.println ("unknown action command " + command);
4834: }
4835: }
4836: };
4837:
4838: ActionListener onchipFPUListener = new ActionListener () {
4839: @Override public void actionPerformed (ActionEvent ae) {
4840: String command = ae.getActionCommand ();
4841: switch (command) {
4842: case "Not installed":
4843: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 0;
4844: break;
4845: case "MC68060":
4846: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 6;
4847: break;
4848: case "Full specification":
4849: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4850: break;
4851: case "Extended precision (19 digits)":
4852: specifiedOnchipFPU = 0 | (7 & specifiedOnchipFPU);
4853: break;
4854: case "Triple precision (24 digits)":
4855: specifiedOnchipFPU = 8 | (7 & specifiedOnchipFPU);
4856: break;
4857: default:
4858: System.out.println ("unknown action command " + command);
4859: }
4860: }
4861: };
4862:
4863: ButtonGroup copro00Group = new ButtonGroup ();
4864: ButtonGroup copro01Group = new ButtonGroup ();
4865: ButtonGroup copro10Group = new ButtonGroup ();
4866: ButtonGroup copro11Group = new ButtonGroup ();
4867: ButtonGroup copro20Group = new ButtonGroup ();
4868: ButtonGroup copro21Group = new ButtonGroup ();
4869: ButtonGroup onchipFPU0Group = new ButtonGroup ();
4870: ButtonGroup onchipFPU1Group = new ButtonGroup ();
4871:
4872: coproFPUMenu = Multilingual.mlnText (
4873: ComponentFactory.createMenu (
4874: "Coprocessor and on-chip FPU",
4875:
4876: Multilingual.mlnText (
4877: ComponentFactory.createMenu (
4878: "Motherboard coprocessor",
4879: Multilingual.mlnText (
4880: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 0, "Not installed", copro0Listener),
4881: "ja", "なし"),
4882: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 1, "MC68881", copro0Listener),
4883: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 2, "MC68882", copro0Listener),
4884: Multilingual.mlnText (
4885: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 7, "Full specification", copro0Listener),
4886: "ja", "フルスペック"),
4887: ComponentFactory.createHorizontalSeparator (),
4888: Multilingual.mlnText (
4889: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) == 0, "Extended precision (19 digits)", copro0Listener),
4890: "ja", "拡張精度 (19 桁)"),
4891: Multilingual.mlnText (
4892: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) != 0, "Triple precision (24 digits)", copro0Listener),
4893: "ja", "三倍精度 (24 桁)")),
4894: "ja", "マザーボードコプロセッサ"),
4895:
4896: Multilingual.mlnText (
4897: ComponentFactory.createMenu (
4898: "Extension coprocessor #1",
4899: Multilingual.mlnText (
4900: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 0, "Not installed", copro1Listener),
4901: "ja", "なし"),
4902: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 1, "MC68881", copro1Listener),
4903: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 2, "MC68882", copro1Listener),
4904: Multilingual.mlnText (
4905: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 7, "Full specification", copro1Listener),
4906: "ja", "フルスペック"),
4907: ComponentFactory.createHorizontalSeparator (),
4908: Multilingual.mlnText (
4909: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) == 0, "Extended precision (19 digits)", copro1Listener),
4910: "ja", "拡張精度 (19 桁)"),
4911: Multilingual.mlnText (
4912: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) != 0, "Triple precision (24 digits)", copro1Listener),
4913: "ja", "三倍精度 (24 桁)")),
4914: "ja", "拡張コプロセッサ #1"),
4915:
4916: Multilingual.mlnText (
4917: ComponentFactory.createMenu (
4918: "Extension coprocessor #2",
4919: Multilingual.mlnText (
4920: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 0, "Not installed", copro2Listener),
4921: "ja", "なし"),
4922: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 1, "MC68881", copro2Listener),
4923: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 2, "MC68882", copro2Listener),
4924: Multilingual.mlnText (
4925: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 7, "Full specification", copro2Listener),
4926: "ja", "フルスペック"),
4927: ComponentFactory.createHorizontalSeparator (),
4928: Multilingual.mlnText (
4929: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) == 0, "Extended precision (19 digits)", copro2Listener),
4930: "ja", "拡張精度 (19 桁)"),
4931: Multilingual.mlnText (
4932: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) != 0, "Triple precision (24 digits)", copro2Listener),
4933: "ja", "三倍精度 (24 桁)")),
4934: "ja", "拡張コプロセッサ #2"),
4935:
4936: Multilingual.mlnText (
4937: ComponentFactory.createMenu (
4938: "On-chip FPU",
4939: Multilingual.mlnText (
4940: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 0, "Not installed", onchipFPUListener),
4941: "ja", "なし"),
4942: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 6, "MC68060", onchipFPUListener),
4943: Multilingual.mlnText (
4944: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 7, "Full specification", onchipFPUListener),
4945: "ja", "フルスペック"),
4946: ComponentFactory.createHorizontalSeparator (),
4947: Multilingual.mlnText (
4948: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) == 0, "Extended precision (19 digits)", onchipFPUListener),
4949: "ja", "拡張精度 (19 桁)"),
4950: Multilingual.mlnText (
4951: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) != 0, "Triple precision (24 digits)", onchipFPUListener),
4952: "ja", "三倍精度 (24 桁)")),
4953: "ja", "オンチップ FPU")),
4954: "ja", "コプロセッサとオンチップ FPU");
4955:
4956: }
4957:
4958: public static void mdlRequestModel (Model model, int accelerator) {
4959: specifiedModel = model;
4960: specifiedAccelerator = accelerator;
4961:
4962: specifiedIsSecond = false;
4963: specifiedFirstMPU = specifiedModel.getMPU ();
4964: specifiedSecondMPU = Model.MPU_MC68EC030;
4965: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
4966: specifiedFirstClock = specifiedModel.getClock ();
4967: specifiedSecondClock = specifiedFirstClock * 2.0;
4968: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4969:
4970: switch (accelerator) {
4971: case ACCELERATOR_HYBRID:
4972: specifiedFirstClock = MHZ_HYBRID_VALUE;
4973: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4974: break;
4975: case ACCELERATOR_XELLENT30:
4976: break;
4977: case ACCELERATOR_060TURBO:
4978: case ACCELERATOR_060TURBOPRO:
4979: specifiedFirstMPU = Model.MPU_MC68060;
4980: specifiedFirstClock = MHZ_060TURBO_VALUE;
4981: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4982: }
4983:
4984: mpuUtilOn = false;
4985: mpuArbFreqOn = false;
4986: mpuSetCurrentClock (specifiedClock);
4987:
4988: if (accelerator == ACCELERATOR_HYBRID) {
4989: mdlHybridMenuItem.setSelected (true);
4990: } else if (accelerator == ACCELERATOR_XELLENT30) {
4991: mdlXellent30MenuItem.setSelected (true);
4992: } else if (accelerator == ACCELERATOR_060TURBO) {
4993: mdl060turboMenuItem.setSelected (true);
4994: } else if (accelerator == ACCELERATOR_060TURBOPRO) {
4995: mdl060turboPROMenuItem.setSelected (true);
4996: } else if (specifiedModel == Model.SHODAI) {
4997: mdlShodaiMenuItem.setSelected (true);
4998: } else if (specifiedModel == Model.ACE) {
4999: mdlACEMenuItem.setSelected (true);
5000: } else if (specifiedModel == Model.EXPERT) {
5001: mdlEXPERTMenuItem.setSelected (true);
5002: } else if (specifiedModel == Model.PRO) {
5003: mdlPROMenuItem.setSelected (true);
5004: } else if (specifiedModel == Model.SUPER) {
5005: mdlSUPERMenuItem.setSelected (true);
5006: } else if (specifiedModel == Model.XVI) {
5007: mdlXVIMenuItem.setSelected (true);
5008: } else if (specifiedModel == Model.COMPACT) {
5009: mdlCompactMenuItem.setSelected (true);
5010: } else if (specifiedModel == Model.X68030) {
5011: mdlX68030MenuItem.setSelected (true);
5012: } else if (specifiedModel == Model.X68030COMPACT) {
5013: mdl030CompactMenuItem.setSelected (true);
5014: }
5015:
5016:
5017: HDC.hdcSASIMenuItem.setSelected (!currentModel.isSCSI ());
5018: SPC.spcSCSIINMenuItem.setSelected (currentModel.isSCSI ());
5019: }
5020:
5021:
5022:
5023:
5024:
5025:
5026:
5027: public static final boolean MPU_INLINE_EXCEPTION = true;
5028: public static final boolean MPU_COMPOUND_POSTINCREMENT = false;
5029:
5030: public static final boolean MPU_SWITCH_MISC_OPCODE = false;
5031: public static final boolean MPU_SWITCH_BCC_CONDITION = false;
5032: public static final boolean MPU_SWITCH_BCC_OFFSET = false;
5033: public static final boolean MPU_SWITCH_SCC_CONDITION = true;
5034:
5035: public static final boolean MPU_OMIT_EXTRA_READ = false;
5036: public static final boolean MPU_OMIT_OFFSET_READ = false;
5037:
5038:
5039:
5040:
5041: public static final long FAR_FUTURE = 0x7fffffffffffffffL;
5042:
5043:
5044:
5045:
5046:
5047:
5048:
5049:
5050: public static final int REG_SR_T1 = 0b10000000_00000000;
5051: public static final int REG_SR_T0 = 0b01000000_00000000;
5052:
5053:
5054:
5055:
5056:
5057:
5058: public static final int REG_SR_S = 0b00100000_00000000;
5059: public static final int REG_SR_M = 0b00010000_00000000;
5060:
5061: public static final int REG_SR_I = 0b00000111_00000000;
5062:
5063:
5064: public static final int REG_CCR_X = 0b00000000_00010000;
5065: public static final int REG_CCR_N = 0b00000000_00001000;
5066: public static final int REG_CCR_Z = 0b00000000_00000100;
5067: public static final int REG_CCR_V = 0b00000000_00000010;
5068: public static final int REG_CCR_C = 0b00000000_00000001;
5069: public static final int REG_CCR_MASK = REG_CCR_X | REG_CCR_N | REG_CCR_Z | REG_CCR_V | REG_CCR_C;
5070:
5071: public static char[] REG_CCRXMAP = "00000000000000001111111111111111".toCharArray ();
5072: public static char[] REG_CCRNMAP = "00000000111111110000000011111111".toCharArray ();
5073: public static char[] REG_CCRZMAP = "00001111000011110000111100001111".toCharArray ();
5074: public static char[] REG_CCRVMAP = "00110011001100110011001100110011".toCharArray ();
5075: public static char[] REG_CCRCMAP = "01010101010101010101010101010101".toCharArray ();
5076:
5077:
5078:
5079: public static final int MPU_IOI_INTERRUPT_LEVEL = 1;
5080: public static final int MPU_EB2_INTERRUPT_LEVEL = 2;
5081: public static final int MPU_DMA_INTERRUPT_LEVEL = 3;
5082: public static final int MPU_SCC_INTERRUPT_LEVEL = 5;
5083: public static final int MPU_MFP_INTERRUPT_LEVEL = 6;
5084: public static final int MPU_SYS_INTERRUPT_LEVEL = 7;
5085: public static final int MPU_IOI_INTERRUPT_MASK = 0x80 >> MPU_IOI_INTERRUPT_LEVEL;
5086: public static final int MPU_EB2_INTERRUPT_MASK = 0x80 >> MPU_EB2_INTERRUPT_LEVEL;
5087: public static final int MPU_DMA_INTERRUPT_MASK = 0x80 >> MPU_DMA_INTERRUPT_LEVEL;
5088: public static final int MPU_SCC_INTERRUPT_MASK = 0x80 >> MPU_SCC_INTERRUPT_LEVEL;
5089: public static final int MPU_MFP_INTERRUPT_MASK = 0x80 >> MPU_MFP_INTERRUPT_LEVEL;
5090: public static final int MPU_SYS_INTERRUPT_MASK = 0x80 >> MPU_SYS_INTERRUPT_LEVEL;
5091:
5092: public static final boolean MPU_INTERRUPT_SWITCH = true;
5093:
5094:
5095: public static final boolean T = true;
5096: public static final boolean F = false;
5097:
5098: public static final int CCCC_T = 0b0000;
5099: public static final int CCCC_F = 0b0001;
5100: public static final int CCCC_HI = 0b0010;
5101: public static final int CCCC_LS = 0b0011;
5102: public static final int CCCC_CC = 0b0100;
5103: public static final int CCCC_CS = 0b0101;
5104: public static final int CCCC_NE = 0b0110;
5105: public static final int CCCC_EQ = 0b0111;
5106: public static final int CCCC_VC = 0b1000;
5107: public static final int CCCC_VS = 0b1001;
5108: public static final int CCCC_PL = 0b1010;
5109: public static final int CCCC_MI = 0b1011;
5110: public static final int CCCC_GE = 0b1100;
5111: public static final int CCCC_LT = 0b1101;
5112: public static final int CCCC_GT = 0b1110;
5113: public static final int CCCC_LE = 0b1111;
5114:
5115:
5116:
5117:
5118:
5119:
5120: public static final boolean[] BCCMAP = {
5121: 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,
5122: 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,
5123: 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,
5124: 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,
5125: 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,
5126: 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,
5127: 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,
5128: 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,
5129: 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,
5130: 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,
5131: 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,
5132: 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,
5133: 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,
5134: 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,
5135: 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,
5136: 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,
5137: };
5138:
5139:
5140: public static final char[] MPU_CCCMAP = (
5141: "11111111111111111111111111111111" +
5142: "00000000000000000000000000000000" +
5143: "10100000101000001010000010100000" +
5144: "01011111010111110101111101011111" +
5145: "10101010101010101010101010101010" +
5146: "01010101010101010101010101010101" +
5147: "11110000111100001111000011110000" +
5148: "00001111000011110000111100001111" +
5149: "11001100110011001100110011001100" +
5150: "00110011001100110011001100110011" +
5151: "11111111000000001111111100000000" +
5152: "00000000111111110000000011111111" +
5153: "11001100001100111100110000110011" +
5154: "00110011110011000011001111001100" +
5155: "11000000001100001100000000110000" +
5156: "00111111110011110011111111001111").toCharArray ();
5157:
5158:
5159:
5160: public static final int MPU_CC_T = 0b11111111111111111111111111111111;
5161: public static final int MPU_CC_F = 0b00000000000000000000000000000000;
5162: public static final int MPU_CC_HI = 0b10100000101000001010000010100000;
5163: public static final int MPU_CC_LS = 0b01011111010111110101111101011111;
5164: public static final int MPU_CC_HS = 0b10101010101010101010101010101010;
5165: public static final int MPU_CC_LO = 0b01010101010101010101010101010101;
5166: public static final int MPU_CC_NE = 0b11110000111100001111000011110000;
5167: public static final int MPU_CC_EQ = 0b00001111000011110000111100001111;
5168: public static final int MPU_CC_VC = 0b11001100110011001100110011001100;
5169: public static final int MPU_CC_VS = 0b00110011001100110011001100110011;
5170: public static final int MPU_CC_PL = 0b11111111000000001111111100000000;
5171: public static final int MPU_CC_MI = 0b00000000111111110000000011111111;
5172: public static final int MPU_CC_GE = 0b11001100001100111100110000110011;
5173: public static final int MPU_CC_LT = 0b00110011110011000011001111001100;
5174: public static final int MPU_CC_GT = 0b11000000001100001100000000110000;
5175: public static final int MPU_CC_LE = 0b00111111110011110011111111001111;
5176:
5177:
5178:
5179:
5180:
5181:
5182:
5183:
5184:
5185:
5186:
5187:
5188:
5189:
5190:
5191:
5192:
5193:
5194:
5195:
5196:
5197:
5198:
5199:
5200:
5201:
5202:
5203:
5204:
5205:
5206:
5207:
5208:
5209:
5210:
5211:
5212:
5213:
5214:
5215:
5216:
5217:
5218:
5219:
5220:
5221:
5222:
5223:
5224:
5225: 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);
5226:
5227:
5228:
5229: public static final int[] MPU_BITREV_TABLE_0 = new int[2048];
5230: public static final int[] MPU_BITREV_TABLE_1 = new int[2048];
5231: public static final int[] MPU_BITREV_TABLE_2 = new int[2048];
5232: static {
5233: for (int i = 0; i < 2048; i++) {
5234: MPU_BITREV_TABLE_2[i] = (MPU_BITREV_TABLE_1[i] = (MPU_BITREV_TABLE_0[i] = Integer.reverse (i)) >>> 11) >>> 11;
5235: }
5236: }
5237:
5238:
5239:
5240: public static final int EA_DR = 0b000_000;
5241: public static final int EA_AR = 0b001_000;
5242: public static final int EA_MM = 0b010_000;
5243: public static final int EA_MP = 0b011_000;
5244: public static final int EA_MN = 0b100_000;
5245: public static final int EA_MW = 0b101_000;
5246: public static final int EA_MX = 0b110_000;
5247: public static final int EA_ZW = 0b111_000;
5248: public static final int EA_ZL = 0b111_001;
5249: public static final int EA_PW = 0b111_010;
5250: public static final int EA_PX = 0b111_011;
5251: public static final int EA_IM = 0b111_100;
5252: public static final int MMM_DR = EA_DR >> 3;
5253: public static final int MMM_AR = EA_AR >> 3;
5254: public static final int MMM_MM = EA_MM >> 3;
5255: public static final int MMM_MP = EA_MP >> 3;
5256: public static final int MMM_MN = EA_MN >> 3;
5257: public static final int MMM_MW = EA_MW >> 3;
5258: public static final int MMM_MX = EA_MX >> 3;
5259: public static final long EAM_DR = 0xff00000000000000L >>> EA_DR;
5260: public static final long EAM_AR = 0xff00000000000000L >>> EA_AR;
5261: public static final long EAM_MM = 0xff00000000000000L >>> EA_MM;
5262: public static final long EAM_MP = 0xff00000000000000L >>> EA_MP;
5263: public static final long EAM_MN = 0xff00000000000000L >>> EA_MN;
5264: public static final long EAM_MW = 0xff00000000000000L >>> EA_MW;
5265: public static final long EAM_MX = 0xff00000000000000L >>> EA_MX;
5266: public static final long EAM_ZW = 0x8000000000000000L >>> EA_ZW;
5267: public static final long EAM_ZL = 0x8000000000000000L >>> EA_ZL;
5268: public static final long EAM_PW = 0x8000000000000000L >>> EA_PW;
5269: public static final long EAM_PX = 0x8000000000000000L >>> EA_PX;
5270: public static final long EAM_IM = 0x8000000000000000L >>> EA_IM;
5271: 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;
5272: public static final long EAM_ALT = EAM_DR|EAM_AR|EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5273: 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;
5274: 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 ;
5275: public static final long EAM_DLT = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5276: public static final long EAM_DCN = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5277: public static final long EAM_DCL = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5278: 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;
5279: public static final long EAM_MEM = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5280: public static final long EAM_MLT = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5281: public static final long EAM_RDL = EAM_MM|EAM_MP |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5282: public static final long EAM_WTL = EAM_MM |EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5283: public static final long EAM_CNT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5284: public static final long EAM_CLT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5285:
5286:
5287:
5288:
5289:
5290:
5291:
5292:
5293:
5294:
5295:
5296: public static final int[] regRn = new int[16 + 1];
5297:
5298:
5299: public static int regPC;
5300: public static int regPC0;
5301:
5302:
5303: public static int regOC;
5304:
5305:
5306: public static int regSRT1;
5307: public static int regSRT0;
5308: public static int mpuTraceFlag;
5309: public static int regSRS;
5310: public static int regSRM;
5311: public static int regSRI;
5312:
5313:
5314: public static int regCCR;
5315:
5316:
5317:
5318:
5319:
5320:
5321:
5322:
5323:
5324:
5325:
5326:
5327:
5328:
5329:
5330:
5331:
5332:
5333:
5334:
5335: public static int mpuIMR;
5336:
5337:
5338:
5339:
5340:
5341:
5342: public static int mpuIRR;
5343: public static int mpuDIRR;
5344:
5345:
5346:
5347:
5348:
5349:
5350:
5351:
5352: public static int mpuISR;
5353:
5354:
5355: public static int mpuSFC;
5356: public static int mpuDFC;
5357: public static int mpuCACR;
5358:
5359:
5360:
5361:
5362:
5363: public static int mpuBUSCR;
5364: public static int mpuUSP;
5365: public static int mpuVBR;
5366: public static int mpuCAAR;
5367: public static int mpuMSP;
5368: public static int mpuISP;
5369:
5370:
5371:
5372: public static int mpuPCR;
5373:
5374:
5375:
5376: public static final int MPU_060_REV = 7;
5377:
5378:
5379:
5380: public static long mpuClockTime;
5381: public static long mpuClockLimit;
5382: public static double mpuClockMHz;
5383: public static double mpuCurrentMHz;
5384: public static int mpuCycleCount;
5385: public static long mpuCycleUnit;
5386: public static long mpuModifiedUnit;
5387: public static long dmaCycleUnit;
5388:
5389:
5390:
5391: public static TimerTask mpuTask;
5392:
5393:
5394: public static int mpuBootDevice;
5395: public static int mpuROMBootHandle;
5396: public static int mpuSavedBootDevice;
5397: public static int mpuSavedROMBootHandle;
5398:
5399:
5400: public static boolean mpuIgnoreAddressError;
5401:
5402:
5403: public static int mpuROMWaitCycles;
5404: public static int mpuRAMWaitCycles;
5405: public static boolean mpuCacheOn;
5406: public static final class WaitTime {
5407: public long ram;
5408: public long gvram;
5409: public long tvram;
5410: public long crtc;
5411: public long palet;
5412: public long vicon;
5413: public long dmac;
5414: public long mfp;
5415: public long rtc;
5416: public long prnport;
5417: public long sysport;
5418: public long opm;
5419: public long adpcm;
5420: public long fdc;
5421: public long fdd;
5422: public long hdc;
5423: public long scc;
5424: public long ppi;
5425: public long ioi;
5426: public long sprc;
5427: public long sram;
5428: public long rom;
5429: public long ramlong;
5430: public long romlong;
5431: }
5432: public static final WaitTime mpuNoWaitTime = new WaitTime ();
5433: public static final WaitTime dmaNoWaitTime = new WaitTime ();
5434: public static final WaitTime mpuWaitTime = new WaitTime ();
5435: public static final WaitTime dmaWaitTime = new WaitTime ();
5436: public static boolean busWaitCyclesRequest;
5437: public static boolean busWaitCycles;
5438: public static WaitTime busWaitTime;
5439:
5440:
5441: public static boolean mpuArbFreqOn;
5442: public static int mpuArbFreqMHz;
5443: public static SpinnerNumberModel mpuArbFreqModel;
5444: public static JSpinner mpuArbFreqSpinner;
5445: public static JRadioButtonMenuItem mpuArbFreqRadioButtonMenuItem;
5446:
5447:
5448: public static boolean mpuUtilOn;
5449: public static int mpuUtilRatio;
5450: public static SpinnerNumberModel mpuUtilModel;
5451: public static JSpinner mpuUtilSpinner;
5452: public static JRadioButtonMenuItem mpuUtilRadioButtonMenuItem;
5453:
5454:
5455: public static final int MPU_ADJUSTMENT_INTERVAL = 100;
5456: public static int mpuAdjustmentCounter;
5457: public static long mpuTotalNano;
5458: public static long mpuLastNano;
5459: public static double mpuCoreNano1;
5460: public static double mpuCoreNano2;
5461:
5462:
5463: public static JMenu mpuMenu;
5464: public static JMenuItem mpuResetMenuItem;
5465: public static JMenuItem mpuOpt1ResetMenuItem;
5466: public static JRadioButtonMenuItem mpuClock10MenuItem;
5467: public static JRadioButtonMenuItem mpuClock16MenuItem;
5468: public static JRadioButtonMenuItem mpuClock25MenuItem;
5469: public static JRadioButtonMenuItem mpuClock33MenuItem;
5470: public static JRadioButtonMenuItem mpuClock50MenuItem;
5471: public static JRadioButtonMenuItem mpuClock66MenuItem;
5472: public static JRadioButtonMenuItem mpuClock75MenuItem;
5473: public static JRadioButtonMenuItem mpuClock100MenuItem;
5474:
5475:
5476: public static ActionListener mpuDebugActionListener;
5477: public static ArrayList<AbstractButton> mpuButtonsRunning;
5478: public static ArrayList<AbstractButton> mpuButtonsStopped;
5479: public static ArrayList<JCheckBox> mpuOriIllegalCheckBoxList;
5480: public static ArrayList<JCheckBox> mpuStopOnErrorCheckBoxList;
5481: public static ArrayList<JCheckBox> mpuStopAtStartCheckBoxList;
5482:
5483: public static int mpuAdvanceCount;
5484: public static int mpuStepCount;
5485: public static boolean mpuContinue;
5486: public static int mpuUntilReturnSRS;
5487: public static int mpuUntilReturnRP;
5488: public static int mpuUntilReturnPC0;
5489: public static int mpuUntilReturnSP;
5490:
5491:
5492:
5493:
5494:
5495:
5496:
5497:
5498:
5499:
5500:
5501:
5502:
5503:
5504:
5505:
5506:
5507:
5508:
5509:
5510:
5511:
5512:
5513:
5514:
5515:
5516:
5517:
5518:
5519:
5520:
5521:
5522:
5523:
5524:
5525:
5526:
5527:
5528:
5529:
5530:
5531:
5532:
5533:
5534:
5535:
5536:
5537:
5538:
5539:
5540:
5541:
5542:
5543:
5544:
5545:
5546:
5547:
5548:
5549:
5550:
5551:
5552:
5553:
5554:
5555:
5556:
5557:
5558:
5559:
5560:
5561:
5562:
5563: public static final boolean MPU_SXMENU = false;
5564:
5565:
5566:
5567: public static void mpuInit () {
5568:
5569: mpuIgnoreAddressError = false;
5570:
5571:
5572:
5573: fpuInit ();
5574:
5575: mpuClockTime = 0L;
5576: mpuClockLimit = 0L;
5577: mpuCycleCount = 0;
5578:
5579: mpuTask = null;
5580:
5581: M68kException.m6eSignal = new M68kException ();
5582: M68kException.m6eNumber = 0;
5583: M68kException.m6eAddress = 0;
5584: M68kException.m6eDirection = MPU_WR_WRITE;
5585: M68kException.m6eSize = MPU_SS_BYTE;
5586:
5587: mpuBootDevice = -1;
5588: mpuROMBootHandle = -1;
5589: mpuSavedBootDevice = -1;
5590: mpuSavedROMBootHandle = -1;
5591:
5592:
5593:
5594:
5595:
5596:
5597:
5598:
5599:
5600:
5601:
5602:
5603:
5604:
5605:
5606: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
5607: mpuTotalNano = 0L;
5608: mpuLastNano = System.nanoTime ();
5609: mpuCoreNano1 = mpuCoreNano2 = 0.5 * 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
5610:
5611: mpuButtonsRunning = new ArrayList<AbstractButton> ();
5612: mpuButtonsStopped = new ArrayList<AbstractButton> ();
5613:
5614: mpuOriIllegalCheckBoxList = new ArrayList<JCheckBox> ();
5615: mpuStopOnErrorCheckBoxList = new ArrayList<JCheckBox> ();
5616: mpuStopAtStartCheckBoxList = new ArrayList<JCheckBox> ();
5617:
5618: mpuAdvanceCount = 0;
5619: mpuStepCount = 0;
5620: mpuContinue = false;
5621: mpuUntilReturnSRS = 0;
5622: mpuUntilReturnRP = 0;
5623: mpuUntilReturnPC0 = 0;
5624: mpuUntilReturnSP = 0;
5625:
5626:
5627: mpuDebugActionListener = new ActionListener () {
5628: @Override public void actionPerformed (ActionEvent ae) {
5629: Object source = ae.getSource ();
5630: switch (ae.getActionCommand ()) {
5631: case "Stop":
5632: if (RootPointerList.RTL_ON) {
5633: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
5634: RootPointerList.rtlCurrentUserTaskIsStoppable) {
5635: mpuStop (null);
5636: }
5637: } else {
5638: mpuStop (null);
5639: }
5640: break;
5641: case "Trace":
5642: mpuAdvance (1);
5643: break;
5644: case "Trace 10 times":
5645: mpuAdvance (10);
5646: break;
5647: case "Trace 100 times":
5648: mpuAdvance (100);
5649: break;
5650: case "Step":
5651: mpuStep (1);
5652: break;
5653: case "Step 10 times":
5654: mpuStep (10);
5655: break;
5656: case "Step 100 times":
5657: mpuStep (100);
5658: break;
5659: case "Step until return":
5660: mpuStepUntilReturn ();
5661: break;
5662: case "Run":
5663: mpuStart ();
5664: break;
5665:
5666: case "Consider ORI.B #$00,D0 as an illegal instruction" :
5667: if (DBG_ORI_BYTE_ZERO_D0) {
5668: dbgOriByteZeroD0 = ((JCheckBox) source).isSelected ();
5669: for (JCheckBox checkBox : mpuOriIllegalCheckBoxList) {
5670: if (checkBox.isSelected () != dbgOriByteZeroD0) {
5671: checkBox.setSelected (dbgOriByteZeroD0);
5672: }
5673: }
5674: }
5675: break;
5676: case "Stop on error":
5677: dbgStopOnError = ((JCheckBox) source).isSelected ();
5678: for (JCheckBox checkBox : mpuStopOnErrorCheckBoxList) {
5679: if (checkBox.isSelected () != dbgStopOnError) {
5680: checkBox.setSelected (dbgStopOnError);
5681: }
5682: }
5683: break;
5684: case "Stop at execution start position":
5685: dbgStopAtStart = ((JCheckBox) source).isSelected ();
5686: for (JCheckBox checkBox : mpuStopAtStartCheckBoxList) {
5687: if (checkBox.isSelected () != dbgStopAtStart) {
5688: checkBox.setSelected (dbgStopAtStart);
5689: }
5690: }
5691: break;
5692: }
5693: }
5694: };
5695:
5696: }
5697:
5698:
5699:
5700: public static JCheckBox mpuMakeOriIllegalCheckBox () {
5701: JCheckBox checkBox = Multilingual.mlnToolTipText (
5702: ComponentFactory.createIconCheckBox (
5703: DBG_ORI_BYTE_ZERO_D0 ? dbgOriByteZeroD0 : null,
5704: LnF.LNF_ORI_BYTE_ZERO_D0_IMAGE,
5705: LnF.LNF_ORI_BYTE_ZERO_D0_SELECTED_IMAGE,
5706: "Consider ORI.B #$00,D0 as an illegal instruction", mpuDebugActionListener),
5707: "ja", "ORI.B #$00,D0 を不当命令とみなす");
5708: mpuOriIllegalCheckBoxList.add (checkBox);
5709: return checkBox;
5710: }
5711:
5712:
5713:
5714: public static JCheckBox mpuMakeStopOnErrorCheckBox () {
5715: JCheckBox checkBox = Multilingual.mlnToolTipText (
5716: ComponentFactory.createIconCheckBox (
5717: dbgStopOnError,
5718: LnF.LNF_STOP_ON_ERROR_IMAGE,
5719: LnF.LNF_STOP_ON_ERROR_SELECTED_IMAGE,
5720: "Stop on error", mpuDebugActionListener),
5721: "ja", "エラーで停止する");
5722: mpuStopOnErrorCheckBoxList.add (checkBox);
5723: return checkBox;
5724: }
5725:
5726:
5727:
5728: public static JCheckBox mpuMakeStopAtStartCheckBox () {
5729: JCheckBox checkBox = Multilingual.mlnToolTipText (
5730: ComponentFactory.createIconCheckBox (
5731: dbgStopAtStart,
5732: LnF.LNF_STOP_AT_START_IMAGE,
5733: LnF.LNF_STOP_AT_START_SELECTED_IMAGE,
5734: "Stop at execution start position", mpuDebugActionListener),
5735: "ja", "実行開始位置で停止する");
5736: mpuStopAtStartCheckBoxList.add (checkBox);
5737: return checkBox;
5738: }
5739:
5740:
5741: public static void mpuMakeMenu () {
5742:
5743: ButtonGroup unitGroup = new ButtonGroup ();
5744: ActionListener listener = new ActionListener () {
5745: @Override public void actionPerformed (ActionEvent ae) {
5746: Object source = ae.getSource ();
5747: switch (ae.getActionCommand ()) {
5748: case "Reset":
5749: mpuReset (-1, -1);
5750: break;
5751: case "Hold down OPT.1 and reset":
5752: mpuReset (0, -1);
5753: break;
5754: case "Interrupt":
5755: sysInterrupt ();
5756: break;
5757: case "10MHz":
5758: mpuArbFreqOn = false;
5759: mpuUtilOn = false;
5760: mpuSetCurrentClock (10.0);
5761: break;
5762: case "16.7MHz":
5763: mpuArbFreqOn = false;
5764: mpuUtilOn = false;
5765: mpuSetCurrentClock (50.0 / 3.0);
5766: break;
5767: case "25MHz":
5768: mpuArbFreqOn = false;
5769: mpuUtilOn = false;
5770: mpuSetCurrentClock (25.0);
5771: break;
5772: case "33.3MHz":
5773: mpuArbFreqOn = false;
5774: mpuUtilOn = false;
5775: mpuSetCurrentClock (100.0 / 3.0);
5776: break;
5777: case "50MHz":
5778: mpuArbFreqOn = false;
5779: mpuUtilOn = false;
5780: mpuSetCurrentClock (50.0);
5781: break;
5782: case "66.7MHz":
5783: mpuArbFreqOn = false;
5784: mpuUtilOn = false;
5785: mpuSetCurrentClock (200.0 / 3.0);
5786: break;
5787: case "75MHz":
5788: mpuArbFreqOn = false;
5789: mpuUtilOn = false;
5790: mpuSetCurrentClock (75.0);
5791: break;
5792: case "100MHz":
5793: mpuArbFreqOn = false;
5794: mpuUtilOn = false;
5795: mpuSetCurrentClock (100.0);
5796: break;
5797: case "Arbitrary frequency":
5798: mpuArbFreqOn = true;
5799: mpuUtilOn = false;
5800: mpuSetCurrentClock ((double) mpuArbFreqMHz);
5801: break;
5802: case "Arbitrary load factor":
5803: mpuArbFreqOn = false;
5804: mpuUtilOn = true;
5805: break;
5806: case "FE function instruction":
5807: FEFunction.fpkOn = ((JCheckBoxMenuItem) source).isSelected ();
5808: break;
5809: case "Reject FLOATn.X":
5810: FEFunction.fpkRejectFloatOn = ((JCheckBoxMenuItem) source).isSelected ();
5811: break;
5812: case "Cut FC2 pin":
5813: busRequestCutFC2Pin = ((JCheckBoxMenuItem) source).isSelected ();
5814: break;
5815: case "Wait cycles":
5816: busWaitCyclesRequest = ((JCheckBoxMenuItem) source).isSelected ();
5817: break;
5818: case "Use IPLROM 1.6":
5819: ROM.romIPLROM16On = ((JCheckBoxMenuItem) source).isSelected ();
5820: break;
5821: case "Increase IPLROM to 256KB":
5822: ROM.romIPLROM256KOn = ((JCheckBoxMenuItem) source).isSelected ();
5823: break;
5824:
5825: case "Run / Stop":
5826: if (((JCheckBox) source).isSelected ()) {
5827: mpuStart ();
5828: } else {
5829: if (RootPointerList.RTL_ON) {
5830: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
5831: RootPointerList.rtlCurrentUserTaskIsStoppable) {
5832: mpuStop (null);
5833: }
5834: } else {
5835: mpuStop (null);
5836: }
5837: }
5838: pnlPanel.requestFocusInWindow ();
5839: break;
5840: }
5841: }
5842: };
5843: mpuMenu = ComponentFactory.createMenu (
5844: "MPU", 'M',
5845: mpuResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset", 'R', MNB_MODIFIERS, listener), "ja", "リセット"),
5846: mpuOpt1ResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Hold down OPT.1 and reset", 'O', MNB_MODIFIERS, listener), "ja", "OPT.1 を押しながらリセット"),
5847: Multilingual.mlnText (ComponentFactory.createMenuItem ("Interrupt", listener), "ja", "インタラプト"),
5848: ComponentFactory.createHorizontalSeparator (),
5849: mdlMenu,
5850: ComponentFactory.createHorizontalSeparator (),
5851: mpuClock10MenuItem = ComponentFactory.createRadioButtonMenuItem (
5852: unitGroup,
5853: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 10.0,
5854: "10MHz",
5855: listener),
5856: mpuClock16MenuItem = ComponentFactory.createRadioButtonMenuItem (
5857: unitGroup,
5858: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0 / 3.0,
5859: "16.7MHz",
5860: listener),
5861: mpuClock25MenuItem = ComponentFactory.createRadioButtonMenuItem (
5862: unitGroup,
5863: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 25.0,
5864: "25MHz",
5865: listener),
5866: mpuClock33MenuItem = ComponentFactory.createRadioButtonMenuItem (
5867: unitGroup,
5868: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0 / 3.0,
5869: "33.3MHz",
5870: listener),
5871: mpuClock50MenuItem = ComponentFactory.createRadioButtonMenuItem (
5872: unitGroup,
5873: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0,
5874: "50MHz",
5875: listener),
5876: mpuClock66MenuItem = ComponentFactory.createRadioButtonMenuItem (
5877: unitGroup,
5878: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 200.0 / 3.0,
5879: "66.7MHz",
5880: listener),
5881: mpuClock75MenuItem = ComponentFactory.createRadioButtonMenuItem (
5882: unitGroup,
5883: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 75.0,
5884: "75MHz",
5885: listener),
5886: mpuClock100MenuItem = ComponentFactory.createRadioButtonMenuItem (
5887: unitGroup,
5888: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0,
5889: "100MHz",
5890: listener),
5891: mpuArbFreqRadioButtonMenuItem = Multilingual.mlnText (
5892: ComponentFactory.createRadioButtonMenuItem (
5893: unitGroup,
5894: mpuArbFreqOn,
5895: "Arbitrary frequency",
5896: listener),
5897: "ja", "任意の周波数"),
5898: ComponentFactory.createHorizontalBox (
5899: Box.createHorizontalStrut (20),
5900: mpuArbFreqSpinner = ComponentFactory.createNumberSpinner (
5901: mpuArbFreqModel = new SpinnerNumberModel (mpuArbFreqMHz, 1, 1000, 1),
5902: 4,
5903: new ChangeListener () {
5904: @Override public void stateChanged (ChangeEvent ce) {
5905:
5906: mpuArbFreqMHz = mpuArbFreqModel.getNumber ().intValue ();
5907: if (mpuArbFreqOn) {
5908: mpuSetCurrentClock ((double) mpuArbFreqMHz);
5909: }
5910: }
5911: }
5912: ),
5913: ComponentFactory.createLabel ("MHz"),
5914: Box.createHorizontalGlue ()
5915: ),
5916: mpuUtilRadioButtonMenuItem = Multilingual.mlnText (
5917: ComponentFactory.createRadioButtonMenuItem (
5918: unitGroup,
5919: mpuUtilOn,
5920: "Arbitrary load factor",
5921: listener),
5922: "ja", "任意の負荷率"),
5923: ComponentFactory.createHorizontalBox (
5924: Box.createHorizontalStrut (20),
5925: mpuUtilSpinner = ComponentFactory.createNumberSpinner (
5926: mpuUtilModel = new SpinnerNumberModel (mpuUtilRatio, 1, 100, 1),
5927: 4,
5928: new ChangeListener () {
5929: @Override public void stateChanged (ChangeEvent ce) {
5930:
5931: mpuUtilRatio = mpuUtilModel.getNumber ().intValue ();
5932: }
5933: }
5934: ),
5935: ComponentFactory.createLabel ("%"),
5936: Box.createHorizontalGlue ()
5937: ),
5938: ComponentFactory.createHorizontalSeparator (),
5939:
5940: coproFPUMenu,
5941:
5942: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkOn, "FE function instruction", listener), "ja", "FE ファンクション命令"),
5943: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkRejectFloatOn, "Reject FLOATn.X", listener), "ja", "FLOATn.X を組み込まない"),
5944: ComponentFactory.createHorizontalSeparator (),
5945: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busRequestCutFC2Pin, "Cut FC2 pin", listener), "ja", "FC2 ピンをカットする"),
5946: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busWaitCyclesRequest, "Wait cycles", listener), "ja", "ウェイトサイクル"),
5947: ComponentFactory.createHorizontalSeparator (),
5948: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM16On, "Use IPLROM 1.6", listener), "ja", "IPLROM 1.6 を使う"),
5949: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM256KOn, "Increase IPLROM to 256KB", listener), "ja", "IPLROM を 256KB に増やす")
5950: );
5951: }
5952:
5953:
5954: public static void mpuSetCurrentClock (double clock) {
5955: specifiedClock = clock;
5956: if (currentIsSecond) {
5957: specifiedSecondClock = clock;
5958: } else {
5959: specifiedFirstClock = clock;
5960: }
5961: if (!mpuArbFreqOn && !mpuUtilOn) {
5962: if (specifiedClock == 10.0) {
5963: mpuClock10MenuItem.setSelected (true);
5964: } else if (specifiedClock == 50.0 / 3.0) {
5965: mpuClock16MenuItem.setSelected (true);
5966: } else if (specifiedClock == 25.0) {
5967: mpuClock25MenuItem.setSelected (true);
5968: } else if (specifiedClock == 100.0 / 3.0) {
5969: mpuClock33MenuItem.setSelected (true);
5970: } else if (specifiedClock == 50.0) {
5971: mpuClock50MenuItem.setSelected (true);
5972: } else if (specifiedClock == 200.0 / 3.0) {
5973: mpuClock66MenuItem.setSelected (true);
5974: } else if (specifiedClock == 75.0) {
5975: mpuClock75MenuItem.setSelected (true);
5976: } else if (specifiedClock == 100.0) {
5977: mpuClock100MenuItem.setSelected (true);
5978: }
5979: }
5980: mpuClockMHz = specifiedClock;
5981: mpuSetClockMHz (mpuClockMHz);
5982: }
5983:
5984:
5985:
5986:
5987:
5988:
5989:
5990:
5991:
5992:
5993:
5994: public static void mpuSetClockMHz (double mhz) {
5995: mhz = Math.max (1.0, Math.min (1000.0, mhz));
5996: double lastMHz = mpuCurrentMHz;
5997: mpuCurrentMHz = mhz;
5998: mpuCycleUnit = (long) (((double) TMR_FREQ / 1000000.0) / mhz + 0.5);
5999:
6000: mpuModifiedUnit = (currentMPU == Model.MPU_MC68EC030 ||
6001: currentMPU == Model.MPU_MC68030 ?
6002: (long) (((double) TMR_FREQ * 3.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6003: currentMPU == Model.MPU_MC68LC040 ||
6004: currentMPU == Model.MPU_MC68040 ?
6005: (long) (((double) TMR_FREQ * 2.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6006: mpuCycleUnit);
6007: if (lastMHz != mhz) {
6008: mpuSetWait ();
6009: }
6010: }
6011:
6012:
6013:
6014:
6015:
6016:
6017:
6018:
6019:
6020:
6021:
6022:
6023:
6024:
6025:
6026:
6027:
6028:
6029:
6030:
6031:
6032:
6033:
6034:
6035:
6036:
6037:
6038:
6039:
6040:
6041:
6042:
6043:
6044:
6045:
6046:
6047:
6048:
6049:
6050:
6051:
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: public static void mpuSetWait () {
6093:
6094: if (currentMPU <= Model.MPU_MC68010) {
6095: mpuWaitTime.ram = mpuCycleUnit >> 3;
6096: mpuWaitTime.vicon = (long) (mpuCycleUnit * 0.6);
6097: mpuWaitTime.crtc =
6098: mpuWaitTime.prnport =
6099: mpuWaitTime.sysport =
6100: mpuWaitTime.sprc =
6101: mpuWaitTime.sram =
6102: mpuWaitTime.rom = mpuCycleUnit;
6103: mpuWaitTime.gvram = (long) (mpuCycleUnit * 1.1);
6104: mpuWaitTime.rtc =
6105: mpuWaitTime.opm =
6106: mpuWaitTime.adpcm =
6107: mpuWaitTime.fdc =
6108: mpuWaitTime.fdd =
6109: mpuWaitTime.hdc =
6110: mpuWaitTime.ppi =
6111: mpuWaitTime.ioi = (long) (mpuCycleUnit * 1.7);
6112: mpuWaitTime.tvram = mpuCycleUnit * 2;
6113: mpuWaitTime.palet = (long) (mpuCycleUnit * 2.6);
6114: mpuWaitTime.mfp = (long) (mpuCycleUnit * 4.3);
6115: mpuWaitTime.scc = mpuCycleUnit * 6;
6116: mpuWaitTime.dmac = mpuCycleUnit * 15;
6117: mpuWaitTime.ramlong = mpuWaitTime.ram << 1;
6118: mpuWaitTime.romlong = mpuWaitTime.rom << 1;
6119: } else if (currentMPU <= Model.MPU_MC68030) {
6120: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6121: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6122: mpuWaitTime.sram = mpuCycleUnit * 2;
6123: mpuWaitTime.prnport =
6124: mpuWaitTime.sysport = mpuCycleUnit * 4;
6125: mpuWaitTime.gvram =
6126: mpuWaitTime.crtc =
6127: mpuWaitTime.vicon =
6128: mpuWaitTime.sprc = mpuCycleUnit * 6;
6129: mpuWaitTime.tvram = mpuCycleUnit * 7;
6130: mpuWaitTime.palet = mpuCycleUnit * 11;
6131: mpuWaitTime.opm =
6132: mpuWaitTime.adpcm =
6133: mpuWaitTime.fdc =
6134: mpuWaitTime.fdd =
6135: mpuWaitTime.hdc =
6136: mpuWaitTime.ppi =
6137: mpuWaitTime.ioi = mpuCycleUnit * 15;
6138: mpuWaitTime.mfp = mpuCycleUnit * 19;
6139: mpuWaitTime.rtc = mpuCycleUnit * 28;
6140: mpuWaitTime.dmac = mpuCycleUnit * 34;
6141: mpuWaitTime.scc = mpuCycleUnit * 38;
6142: mpuWaitTime.ramlong = mpuWaitTime.ram;
6143: mpuWaitTime.romlong = mpuWaitTime.rom;
6144: } else {
6145: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6146: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6147: mpuWaitTime.sram = mpuCycleUnit * 13;
6148: mpuWaitTime.prnport =
6149: mpuWaitTime.sysport = mpuCycleUnit * 17;
6150: mpuWaitTime.gvram =
6151: mpuWaitTime.crtc =
6152: mpuWaitTime.vicon =
6153: mpuWaitTime.sprc = mpuCycleUnit * 21;
6154: mpuWaitTime.tvram = mpuCycleUnit * 22;
6155: mpuWaitTime.palet = mpuCycleUnit * 33;
6156: mpuWaitTime.opm =
6157: mpuWaitTime.adpcm =
6158: mpuWaitTime.fdc =
6159: mpuWaitTime.fdd =
6160: mpuWaitTime.hdc =
6161: mpuWaitTime.ppi =
6162: mpuWaitTime.ioi = mpuCycleUnit * 37;
6163: mpuWaitTime.mfp = mpuCycleUnit * 47;
6164: mpuWaitTime.dmac = mpuCycleUnit * 73;
6165: mpuWaitTime.rtc = mpuCycleUnit * 77;
6166: mpuWaitTime.scc = mpuCycleUnit * 97;
6167: mpuWaitTime.ramlong = mpuWaitTime.ram;
6168: mpuWaitTime.romlong = mpuWaitTime.rom;
6169: }
6170: if (true) {
6171: mpuNoWaitTime.sram = mpuWaitTime.sram;
6172: mpuNoWaitTime.rom = mpuWaitTime.rom;
6173: mpuNoWaitTime.romlong = mpuWaitTime.romlong;
6174: }
6175:
6176: dmaWaitTime.ram = dmaCycleUnit >> 3;
6177: dmaWaitTime.sram = 0;
6178: dmaWaitTime.rom = 0;
6179: dmaWaitTime.gvram =
6180: dmaWaitTime.crtc =
6181: dmaWaitTime.vicon =
6182: dmaWaitTime.prnport =
6183: dmaWaitTime.sysport =
6184: dmaWaitTime.sprc = dmaCycleUnit;
6185: dmaWaitTime.tvram =
6186: dmaWaitTime.rtc =
6187: dmaWaitTime.opm =
6188: dmaWaitTime.adpcm =
6189: dmaWaitTime.fdc =
6190: dmaWaitTime.fdd =
6191: dmaWaitTime.hdc =
6192: dmaWaitTime.ppi =
6193: dmaWaitTime.ioi = dmaCycleUnit * 2;
6194: dmaWaitTime.palet = dmaCycleUnit * 3;
6195: dmaWaitTime.mfp = dmaCycleUnit * 4;
6196: dmaWaitTime.scc = dmaCycleUnit * 6;
6197: dmaWaitTime.dmac = dmaCycleUnit * 15;
6198: dmaWaitTime.ramlong = dmaWaitTime.ram << 1;
6199: dmaWaitTime.romlong = dmaWaitTime.rom << 1;
6200: }
6201:
6202:
6203:
6204:
6205:
6206: public static void mpuReset (int device, int romHandle) {
6207:
6208: mpuBootDevice = device;
6209: mpuROMBootHandle = romHandle;
6210:
6211:
6212:
6213:
6214:
6215:
6216:
6217:
6218:
6219:
6220:
6221:
6222: if (mpuBootDevice == -1) {
6223: if (mpuSavedBootDevice != -1) {
6224: mpuBootDevice = mpuSavedBootDevice;
6225: mpuROMBootHandle = mpuSavedROMBootHandle;
6226: mpuSavedBootDevice = -1;
6227: mpuSavedROMBootHandle = -1;
6228: }
6229: } else {
6230: if (mpuSavedBootDevice == -1) {
6231: mpuSavedBootDevice = MainMemory.mmrRwz (0x00ed0018);
6232: mpuSavedROMBootHandle = MainMemory.mmrRls (0x00ed000c);
6233: }
6234: }
6235:
6236:
6237: if (mpu010) {
6238: if (specifiedFirstMPU == Model.MPU_MC68000) {
6239: specifiedFirstMPU = Model.MPU_MC68010;
6240: }
6241: if (specifiedSecondMPU == Model.MPU_MC68000) {
6242: specifiedSecondMPU = Model.MPU_MC68010;
6243: }
6244: } else {
6245: if (specifiedFirstMPU == Model.MPU_MC68010) {
6246: specifiedFirstMPU = Model.MPU_MC68000;
6247: }
6248: if (specifiedSecondMPU == Model.MPU_MC68010) {
6249: specifiedSecondMPU = Model.MPU_MC68000;
6250: }
6251: }
6252:
6253:
6254: specifiedIsSecond = false;
6255: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
6256: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
6257:
6258: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
6259: MC68EC030.m30DivZeroVFlag = false;
6260: }
6261:
6262: if (mpuTask != null) {
6263: mpuClockLimit = 0L;
6264: System.out.println (Multilingual.mlnJapanese ?
6265: "MPU を停止します" :
6266: "MPU stops");
6267: mpuTask.cancel ();
6268: mpuTask = null;
6269: }
6270:
6271: tmrTimer.schedule (new TimerTask () {
6272: @Override public void run () {
6273:
6274:
6275:
6276: currentModel = specifiedModel;
6277: currentAccelerator = specifiedAccelerator;
6278: frmUpdateTitle ();
6279:
6280: currentIsSecond = specifiedIsSecond;
6281: currentFirstMPU = specifiedFirstMPU;
6282: currentSecondMPU = specifiedSecondMPU;
6283: currentMPU = specifiedMPU;
6284:
6285: mpuSetCurrentClock (specifiedClock);
6286:
6287: currentCopro0 = specifiedCopro0;
6288: currentCopro1 = specifiedCopro1;
6289: currentCopro2 = specifiedCopro2;
6290: currentOnchipFPU = specifiedOnchipFPU;
6291:
6292:
6293: if (currentMPU < Model.MPU_MC68020) {
6294: if (busHimem68000) {
6295: busRequestExMemoryStart = 0x10000000;
6296: busRequestExMemorySize = busLocalMemorySize;
6297: busRequestExMemoryArray = busLocalMemoryArray;
6298: } else {
6299: busRequestExMemoryStart = 0x10000000;
6300: busRequestExMemorySize = 0 << 20;
6301: busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
6302: }
6303: } else if (currentMPU < Model.MPU_MC68LC040) {
6304: if (busHighMemory060turboOn) {
6305: busRequestExMemoryStart = 0x10000000;
6306: busRequestExMemorySize = busLocalMemorySize;
6307: busRequestExMemoryArray = busLocalMemoryArray;
6308: } else {
6309: busRequestExMemoryStart = 0x01000000;
6310: busRequestExMemorySize = busHighMemorySize;
6311: busRequestExMemoryArray = busHighMemoryArray;
6312: }
6313: } else {
6314: busRequestExMemoryStart = 0x10000000;
6315: busRequestExMemorySize = busLocalMemorySize;
6316: busRequestExMemoryArray = busLocalMemoryArray;
6317: }
6318: busUpdateMemoryMap ();
6319:
6320:
6321: ROM.romReset ();
6322:
6323: RegisterList.drpSetMPU ();
6324:
6325: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
6326: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6327: MC68060.mmuReset ();
6328:
6329:
6330: if (Model.MPU_MC68020 <= currentMPU) {
6331: if ((7 & currentCopro0) == 1) {
6332: fpuMotherboardCoprocessor.epbSetMC68881 ();
6333: } else if ((7 & currentCopro0) == 2) {
6334: fpuMotherboardCoprocessor.epbSetMC68882 ();
6335: } else {
6336: fpuMotherboardCoprocessor.epbSetFullSpec ();
6337: }
6338: if ((8 & currentCopro0) == 0) {
6339: fpuMotherboardCoprocessor.epbSetExtended ();
6340: } else {
6341: fpuMotherboardCoprocessor.epbSetTriple ();
6342: }
6343: }
6344:
6345: if ((7 & currentCopro1) == 1) {
6346: fpuCoproboard1.epbSetMC68881 ();
6347: } else if ((7 & currentCopro1) == 2) {
6348: fpuCoproboard1.epbSetMC68882 ();
6349: } else {
6350: fpuCoproboard1.epbSetFullSpec ();
6351: }
6352: if ((8 & currentCopro1) == 0) {
6353: fpuCoproboard1.epbSetExtended ();
6354: } else {
6355: fpuCoproboard1.epbSetTriple ();
6356: }
6357:
6358: if ((7 & currentCopro2) == 1) {
6359: fpuCoproboard2.epbSetMC68881 ();
6360: } else if ((7 & currentCopro2) == 2) {
6361: fpuCoproboard2.epbSetMC68882 ();
6362: } else {
6363: fpuCoproboard2.epbSetFullSpec ();
6364: }
6365: if ((8 & currentCopro2) == 0) {
6366: fpuCoproboard2.epbSetExtended ();
6367: } else {
6368: fpuCoproboard2.epbSetTriple ();
6369: }
6370:
6371: if (Model.MPU_MC68040 <= currentMPU) {
6372: if ((7 & currentOnchipFPU) == 6) {
6373: fpuOnChipFPU.epbSetMC68060 ();
6374: } else {
6375: fpuOnChipFPU.epbSetFullSpec ();
6376: }
6377: if ((8 & currentOnchipFPU) == 0) {
6378: fpuOnChipFPU.epbSetExtended ();
6379: } else {
6380: fpuOnChipFPU.epbSetTriple ();
6381: }
6382: }
6383:
6384: if (!currentModel.isX68030 ()) {
6385: dmaCycleUnit = TMR_FREQ / 10000000L;
6386: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6387: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6388: mpuROMWaitCycles = 1;
6389: mpuRAMWaitCycles = 0;
6390: } else {
6391: dmaCycleUnit = TMR_FREQ / 12500000L;
6392: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6393: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6394: mpuROMWaitCycles = 0;
6395: mpuRAMWaitCycles = 0;
6396: }
6397:
6398: busWaitCycles = busWaitCyclesRequest;
6399: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
6400:
6401: HD63450.dmaReadCycles = (currentModel.isPRO () ? 6 :
6402: currentModel.isCompact () ? 4 :
6403: 5);
6404: HD63450.dmaWriteCycles = (currentModel.isPRO () ? 6 :
6405: 5);
6406:
6407: if (currentMPU < Model.MPU_MC68020) {
6408:
6409: mpuIgnoreAddressError = false;
6410:
6411: mpuCacheOn = false;
6412:
6413: } else if (currentMPU < Model.MPU_MC68040) {
6414:
6415: mpuIgnoreAddressError = true;
6416: fpuBox = fpuMotherboardCoprocessor;
6417: fpuBox.epbReset ();
6418: fpuFPn = fpuBox.epbFPn;
6419:
6420: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
6421:
6422: } else {
6423:
6424: mpuIgnoreAddressError = true;
6425: fpuBox = fpuOnChipFPU;
6426: fpuBox.epbReset ();
6427: fpuFPn = fpuBox.epbFPn;
6428:
6429: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6430: mpuCacheOn = (mpuCACR & 0x80008000) != 0;
6431:
6432: }
6433:
6434: mpuSetWait ();
6435:
6436:
6437: regSRT1 = regSRT0 = 0;
6438: regSRS = REG_SR_S;
6439: regSRM = 0;
6440: regSRI = REG_SR_I;
6441: regCCR = 0;
6442: Arrays.fill (regRn, 0);
6443:
6444: regRn[15] = MainMemory.mmrRls (0x00ff0000);
6445: regPC = MainMemory.mmrRls (0x00ff0004);
6446:
6447: MainMemory.mmrReset ();
6448:
6449: busReset ();
6450: if (InstructionBreakPoint.IBP_ON) {
6451: InstructionBreakPoint.ibpOp1MemoryMap = InstructionBreakPoint.ibpOp1SuperMap;
6452: InstructionBreakPoint.ibpReset ();
6453: }
6454: if (BranchLog.BLG_ON) {
6455: BranchLog.blgReset ();
6456: }
6457:
6458: mpuIMR = 0;
6459: mpuIRR = 0;
6460: if (MC68901.MFP_DELAYED_INTERRUPT) {
6461: mpuDIRR = 0;
6462: }
6463: mpuISR = 0;
6464:
6465:
6466: mpuStart ();
6467: }
6468: }, TMR_DELAY);
6469:
6470: }
6471:
6472:
6473:
6474: public static void mpuStopAndStart () {
6475: if (mpuTask == null) {
6476: mpuStart ();
6477: } else {
6478: if (RootPointerList.RTL_ON) {
6479: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6480: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6481: mpuStop (null);
6482: }
6483: } else {
6484: mpuStop (null);
6485: }
6486: }
6487: }
6488:
6489:
6490:
6491:
6492:
6493: public static void mpuStart () {
6494: if (mpuTask != null) {
6495: mpuClockLimit = 0L;
6496: System.out.println (Multilingual.mlnJapanese ?
6497: "MPU を停止します" :
6498: "MPU stops");
6499: mpuTask.cancel ();
6500: mpuTask = null;
6501: }
6502:
6503: for (AbstractButton button : mpuButtonsStopped) {
6504: button.setEnabled (false);
6505: }
6506: DisassembleList.ddpStoppedBy = null;
6507: System.out.println (Model.mpuNameOf (currentMPU) + (Multilingual.mlnJapanese ? " を起動します" : " starts up"));
6508: mpuTask = new TimerTask () {
6509: @Override public void run () {
6510: mpuContinue = true;
6511: mpuClockLimit = mpuClockTime + TMR_FREQ * TMR_INTERVAL / 1000;
6512: mpuExecuteCore ();
6513: }
6514: };
6515: tmrTimer.scheduleAtFixedRate (mpuTask, TMR_DELAY, TMR_INTERVAL);
6516:
6517: for (AbstractButton button : mpuButtonsRunning) {
6518: button.setEnabled (true);
6519: }
6520: }
6521:
6522:
6523:
6524: public static void mpuExecuteCore () {
6525:
6526: long nanoStart = System.nanoTime ();
6527:
6528: busSuper (RP5C15.rtcFirst, 0x00e8a000, 0x00e8c000);
6529:
6530:
6531: if (currentMPU < Model.MPU_MC68010) {
6532: MC68000.mpuCore ();
6533: } else if (currentMPU < Model.MPU_MC68020) {
6534: MC68010.mpuCore ();
6535: } else if (currentMPU < Model.MPU_MC68LC040) {
6536: MC68EC030.mpuCore ();
6537: } else {
6538: MC68060.mpuCore ();
6539: }
6540:
6541: if (dbgVisibleMask != 0) {
6542: dbgUpdate ();
6543: }
6544:
6545: long nanoEnd = System.nanoTime ();
6546: mpuTotalNano += nanoEnd - nanoStart;
6547: if (--mpuAdjustmentCounter == 0) {
6548:
6549: final double expectedNano = 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
6550:
6551: double coreNano0 = (double) mpuTotalNano;
6552: mpuTotalNano = 0L;
6553: double coreNanoA = (coreNano0 * 2.0 + mpuCoreNano1 + mpuCoreNano2) * 0.25;
6554: mpuCoreNano2 = mpuCoreNano1;
6555: mpuCoreNano1 = coreNano0;
6556:
6557:
6558:
6559: double actualPercent = Math.max (1.0, 100.0 * coreNanoA / expectedNano);
6560:
6561: double maxPercent = SoundSource.sndPlayOn ? 90.0 : 100.0;
6562:
6563:
6564:
6565:
6566: if (mpuUtilOn) {
6567:
6568: double targetPercent = Math.min (maxPercent, (double) mpuUtilRatio);
6569: mpuSetClockMHz ((1.2 - 0.2 * actualPercent / targetPercent) * mpuCurrentMHz);
6570: } else {
6571: mpuSetClockMHz (Math.min (maxPercent / actualPercent,
6572: 1.2 - 0.2 * mpuCurrentMHz / mpuClockMHz) * mpuCurrentMHz);
6573: }
6574: Indicator.indUpdate (actualPercent);
6575: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
6576: }
6577: }
6578:
6579:
6580:
6581:
6582: public static void mpuStop (String message) {
6583:
6584: mpuAdvanceCount = 0;
6585: mpuStepCount = 0;
6586: mpuContinue = false;
6587: mpuStop1 (message);
6588: }
6589: public static void mpuStop1 (String message) {
6590: if (mpuTask == null) {
6591: return;
6592: }
6593: DisassembleList.ddpStoppedBy = message;
6594: mpuClockLimit = 0L;
6595: System.out.println (Multilingual.mlnJapanese ?
6596: "MPU を停止します" :
6597: "MPU stops");
6598: mpuTask.cancel ();
6599: mpuTask = null;
6600:
6601: if (mpuStepCount != 0 && mpuContinue) {
6602: if (mpuStepCount == -1 || --mpuStepCount != 0) {
6603: mpuStep (mpuStepCount);
6604: return;
6605: }
6606: }
6607: mpuAdvanceCount = 0;
6608: mpuStepCount = 0;
6609: mpuContinue = false;
6610:
6611: for (AbstractButton button : mpuButtonsRunning) {
6612: button.setEnabled (false);
6613: }
6614: tmrTimer.schedule (new TimerTask () {
6615: @Override public void run () {
6616: mpuUpdateWindow ();
6617: }
6618: }, TMR_DELAY);
6619: }
6620:
6621:
6622:
6623:
6624:
6625:
6626: public static void mpuAdvance (int n) {
6627: if (mpuTask != null) {
6628: return;
6629: }
6630: mpuAdvanceCount = n;
6631: DisassembleList.ddpStoppedBy = null;
6632: mpuTask = new TimerTask () {
6633: @Override public void run () {
6634: mpuContinue = true;
6635: do {
6636: mpuClockLimit = mpuClockTime + 1L;
6637: mpuExecuteCore ();
6638: } while (mpuContinue && --mpuAdvanceCount != 0);
6639: mpuClockLimit = 0L;
6640: if (mpuTask != null) {
6641: mpuTask.cancel ();
6642: mpuTask = null;
6643: }
6644: if (mpuStepCount != 0 && mpuContinue) {
6645: if (mpuStepCount == -1 || --mpuStepCount != 0) {
6646: mpuStep (mpuStepCount);
6647: return;
6648: }
6649: }
6650: mpuAdvanceCount = 0;
6651: mpuStepCount = 0;
6652: mpuContinue = false;
6653: mpuUpdateWindow ();
6654: }
6655: };
6656: tmrTimer.schedule (mpuTask, TMR_DELAY);
6657: }
6658:
6659:
6660:
6661:
6662:
6663:
6664: public static void mpuStep (int n) {
6665: if (mpuTask != null) {
6666: return;
6667: }
6668: mpuStepCount = n;
6669: Disassembler.disDisassemble (new StringBuilder (), regPC, regSRS);
6670: if ((Disassembler.disStatus & (Disassembler.DIS_ALWAYS_BRANCH | Disassembler.DIS_SOMETIMES_BRANCH)) != 0) {
6671: if (mpuStepCount == -1 &&
6672: (Disassembler.disOC == 0x4e73 ||
6673: Disassembler.disOC == 0x4e74 ||
6674: Disassembler.disOC == 0x4e75 ||
6675: Disassembler.disOC == 0x4e77) &&
6676: mpuUntilReturnSRS == regSRS &&
6677: (currentMPU < Model.MPU_MC68LC040 ||
6678: mpuUntilReturnRP == (regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP)) &&
6679: mpuUntilReturnPC0 != regPC0 &&
6680: Integer.compareUnsigned (mpuUntilReturnSP, regRn[15]) <= 0) {
6681: mpuAdvanceCount = 0;
6682: mpuStepCount = 0;
6683: mpuContinue = false;
6684: mpuUpdateWindow ();
6685: return;
6686: }
6687: mpuAdvance (1);
6688: } else {
6689: if (InstructionBreakPoint.IBP_ON) {
6690: InstructionBreakPoint.ibpInstant (Disassembler.disPC, DisassembleList.ddpSupervisorMode);
6691: mpuStart ();
6692: }
6693: }
6694: }
6695:
6696:
6697:
6698:
6699:
6700:
6701:
6702:
6703:
6704:
6705:
6706: public static void mpuStepUntilReturn () {
6707: if (mpuTask != null) {
6708: return;
6709: }
6710: mpuUntilReturnSRS = regSRS;
6711: mpuUntilReturnRP = regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP;
6712: mpuUntilReturnPC0 = regPC0;
6713: mpuUntilReturnSP = regRn[15];
6714: mpuStep (-1);
6715: }
6716:
6717:
6718:
6719: public static void mpuUpdateWindow () {
6720: if (dbgVisibleMask != 0) {
6721: if ((dbgVisibleMask & DBG_DDP_VISIBLE_MASK) != 0) {
6722: DisassembleList.ddpBacktraceRecord = -1L;
6723: DisassembleList.ddpUpdate (-1, -1, false);
6724: }
6725: if (BranchLog.BLG_ON) {
6726: if ((dbgVisibleMask & DBG_BLG_VISIBLE_MASK) != 0) {
6727: BranchLog.blgUpdate (BranchLog.BLG_SELECT_NEWEST);
6728: }
6729: }
6730: if (ProgramFlowVisualizer.PFV_ON) {
6731: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
6732: ProgramFlowVisualizer.pfvUpdate ();
6733: }
6734: }
6735: if (RasterBreakPoint.RBP_ON) {
6736: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
6737: RasterBreakPoint.rbpUpdateFrame ();
6738: }
6739: }
6740: if (ScreenModeTest.SMT_ON) {
6741: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
6742: ScreenModeTest.smtUpdateFrame ();
6743: }
6744: }
6745: if (RootPointerList.RTL_ON) {
6746: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
6747: RootPointerList.rtlUpdateFrame ();
6748: }
6749: }
6750: if (SpritePatternViewer.SPV_ON) {
6751: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
6752: SpritePatternViewer.spvUpdateFrame ();
6753: }
6754: }
6755: if (ATCMonitor.ACM_ON) {
6756: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
6757: ATCMonitor.acmUpdateFrame ();
6758: }
6759: }
6760: }
6761:
6762: if (DebugConsole.dgtRequestRegs != 0) {
6763: if ((DebugConsole.dgtRequestRegs & 1) != 0) {
6764: ExpressionEvaluator.ElementType.ETY_COMMAND_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
6765: }
6766: if ((DebugConsole.dgtRequestRegs & 2) != 0) {
6767: ExpressionEvaluator.ElementType.ETY_COMMAND_FLOAT_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
6768: }
6769: if ((DebugConsole.dgtRequestRegs & 4) != 0) {
6770: DebugConsole.dgtPrintPrompt ();
6771: }
6772: DebugConsole.dgtRequestRegs = 0;
6773: }
6774:
6775: for (AbstractButton button : mpuButtonsRunning) {
6776: button.setEnabled (false);
6777: }
6778:
6779: for (AbstractButton button : mpuButtonsStopped) {
6780: button.setEnabled (true);
6781: }
6782: }
6783:
6784:
6785:
6786: public static JButton mpuMakeBreakButton () {
6787: return mpuAddButtonRunning (
6788: Multilingual.mlnToolTipText (
6789: ComponentFactory.createImageButton (
6790: LnF.LNF_BREAK_IMAGE,
6791: LnF.LNF_BREAK_DISABLED_IMAGE,
6792: "Stop", mpuDebugActionListener),
6793: "ja", "停止")
6794: );
6795: }
6796:
6797:
6798:
6799: public static JButton mpuMakeTraceButton () {
6800: return mpuAddButtonStopped (
6801: Multilingual.mlnToolTipText (
6802: ComponentFactory.createImageButton (
6803: LnF.LNF_TRACE_IMAGE,
6804: LnF.LNF_TRACE_DISABLED_IMAGE,
6805: "Trace", mpuDebugActionListener),
6806: "ja", "トレース")
6807: );
6808: }
6809:
6810:
6811:
6812: public static JButton mpuMakeTrace10Button () {
6813: return mpuAddButtonStopped (
6814: Multilingual.mlnToolTipText (
6815: ComponentFactory.createImageButton (
6816: LnF.LNF_TRACE_10_IMAGE,
6817: LnF.LNF_TRACE_10_DISABLED_IMAGE,
6818: "Trace 10 times", mpuDebugActionListener),
6819: "ja", "トレース 10 回")
6820: );
6821: }
6822:
6823:
6824:
6825: public static JButton mpuMakeTrace100Button () {
6826: return mpuAddButtonStopped (
6827: Multilingual.mlnToolTipText (
6828: ComponentFactory.createImageButton (
6829: LnF.LNF_TRACE_100_IMAGE,
6830: LnF.LNF_TRACE_100_DISABLED_IMAGE,
6831: "Trace 100 times", mpuDebugActionListener),
6832: "ja", "トレース 100 回")
6833: );
6834: }
6835:
6836:
6837:
6838: public static JButton mpuMakeStepButton () {
6839: return mpuAddButtonStopped (
6840: Multilingual.mlnToolTipText (
6841: ComponentFactory.createImageButton (
6842: LnF.LNF_STEP_IMAGE,
6843: LnF.LNF_STEP_DISABLED_IMAGE,
6844: "Step", mpuDebugActionListener),
6845: "ja", "ステップ")
6846: );
6847: }
6848:
6849:
6850:
6851: public static JButton mpuMakeStep10Button () {
6852: return mpuAddButtonStopped (
6853: Multilingual.mlnToolTipText (
6854: ComponentFactory.createImageButton (
6855: LnF.LNF_STEP_10_IMAGE,
6856: LnF.LNF_STEP_10_DISABLED_IMAGE,
6857: "Step 10 times", mpuDebugActionListener),
6858: "ja", "ステップ 10 回")
6859: );
6860: }
6861:
6862:
6863:
6864: public static JButton mpuMakeStep100Button () {
6865: return mpuAddButtonStopped (
6866: Multilingual.mlnToolTipText (
6867: ComponentFactory.createImageButton (
6868: LnF.LNF_STEP_100_IMAGE,
6869: LnF.LNF_STEP_100_DISABLED_IMAGE,
6870: "Step 100 times", mpuDebugActionListener),
6871: "ja", "ステップ 100 回")
6872: );
6873: }
6874:
6875:
6876:
6877: public static JButton mpuMakeReturnButton () {
6878: return mpuAddButtonStopped (
6879: Multilingual.mlnToolTipText (
6880: ComponentFactory.createImageButton (
6881: LnF.LNF_STEP_UNTIL_RETURN_IMAGE,
6882: LnF.LNF_STEP_UNTIL_RETURN_DISABLED_IMAGE,
6883: "Step until return", mpuDebugActionListener),
6884: "ja", "ステップアンティルリターン")
6885: );
6886: }
6887:
6888:
6889:
6890: public static JButton mpuMakeRunButton () {
6891: return mpuAddButtonStopped (
6892: Multilingual.mlnToolTipText (
6893: ComponentFactory.createImageButton (
6894: LnF.LNF_RUN_IMAGE,
6895: LnF.LNF_RUN_DISABLED_IMAGE,
6896: "Run", mpuDebugActionListener),
6897: "ja", "実行")
6898: );
6899: }
6900:
6901:
6902:
6903: public static <T extends AbstractButton> T mpuAddButtonRunning (T button) {
6904: button.setEnabled (mpuTask != null);
6905: mpuButtonsRunning.add (button);
6906: return button;
6907: }
6908:
6909:
6910:
6911: public static <T extends AbstractButton> T mpuAddButtonStopped (T button) {
6912: button.setEnabled (mpuTask == null);
6913: mpuButtonsStopped.add (button);
6914: return button;
6915: }
6916:
6917:
6918:
6919:
6920:
6921:
6922:
6923:
6924:
6925:
6926:
6927:
6928:
6929:
6930:
6931:
6932: public static final int EMX_OPCODE_BASE = 0x4e00;
6933: public static final int EMX_OPCODE_HFSBOOT = EMX_OPCODE_BASE + 0x00;
6934: public static final int EMX_OPCODE_HFSINST = EMX_OPCODE_BASE + 0x01;
6935: public static final int EMX_OPCODE_HFSSTR = EMX_OPCODE_BASE + 0x02;
6936: public static final int EMX_OPCODE_HFSINT = EMX_OPCODE_BASE + 0x03;
6937: public static final int EMX_OPCODE_EMXNOP = EMX_OPCODE_BASE + 0x04;
6938: public static final int EMX_OPCODE_EMXWAIT = EMX_OPCODE_BASE + 0x05;
6939:
6940: public static final String[] EMX_MNEMONIC_ARRAY = {
6941: "hfsboot",
6942: "hfsinst",
6943: "hfsstr",
6944: "hfsint",
6945: "emxnop",
6946: "emxwait",
6947: };
6948:
6949:
6950:
6951:
6952: public static void emxNop () {
6953: if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x00007140) {
6954: int head = regRn[9];
6955: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
6956:
6957:
6958: emxPatchPCM8A (head, tail);
6959:
6960:
6961: emxCheckRSDRV202 (head, tail);
6962: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000716c) {
6963: int head = regRn[9];
6964: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
6965:
6966:
6967: emxPatch060turbosys (head, tail);
6968:
6969:
6970: if (Z8530.SCC_FSX_MOUSE) {
6971: emxCheckFSX (head, tail);
6972: }
6973:
6974:
6975: if (HFS.HFS_USE_TWENTY_ONE) {
6976: emxCheckTwentyOne (head, tail);
6977: }
6978:
6979:
6980: LabeledAddress.lblClear ();
6981: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000972c) {
6982: int head = regRn[8] + 256;
6983:
6984: int tail = MC68060.mmuPeekLong (head - 208, 1);
6985:
6986:
6987: emxCheckBSIO021 (head, tail);
6988:
6989:
6990: emxPatchPCM8A (head, tail);
6991:
6992:
6993: emxCheckTMSIO031 (head, tail);
6994:
6995:
6996: LabeledAddress.lblClear ();
6997:
6998:
6999: if (dbgStopAtStart) {
7000: InstructionBreakPoint.ibpInstant (regRn[12], 0);
7001: }
7002: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000a090) {
7003: int head = regRn[8] + 256;
7004: int tail = MC68060.mmuPeekLongData (regRn[8] + 8, 1);
7005: String name = MC68060.mmuPeekStringZ (head - 60, 1);
7006: if (name.equalsIgnoreCase ("fsx.x")) {
7007:
7008:
7009: if (Z8530.SCC_FSX_MOUSE) {
7010: emxCheckFSX (head, tail);
7011: }
7012: }
7013: if (name.equalsIgnoreCase ("TwentyOne.x")) {
7014:
7015:
7016: if (HFS.HFS_USE_TWENTY_ONE) {
7017: emxCheckTwentyOne (head, tail);
7018: }
7019: }
7020: }
7021: }
7022:
7023: public static final int[] emxPCM8AFFMap = {
7024: 0x00000138, 0x000001f6, 0x00000394, 0x000011ec, 0x0000120a, 0x00001400, 0x00001814, 0x00001870, 0x00001882, 0x0000188a,
7025: 0x00001892, 0x000018a2, 0x000018a8, 0x000018ca, 0x000018d4, 0x000018e0, 0x000018e8, 0x00001908, 0x000019e4, 0x00001afa,
7026: 0x00001b58, 0x00001b7c, 0x00001bac, 0x00001c38, 0x00001ccc, 0x000021f8, 0x00002250, 0x00002258, 0x00002290, 0x000022a6,
7027: 0x000022b0, 0x000022c0, 0x000022c8, 0x000022de, 0x000022ea, 0x000030c8, 0x000030de, 0x000030e6, 0x000030ea, 0x000030f6,
7028: 0x00003112, 0x00003188, 0x0000334c, 0x0000338a, 0x000033a2, 0x000033c4, 0x000033d0, 0x0000341a, 0x00003428, 0x00003496,
7029: 0x000034a6, 0x000034d6, 0x0000fe0e, 0x0000fec8, 0x0000feec, 0x0000ff46, 0x0000ff4e,
7030: };
7031:
7032:
7033:
7034: public static void emxPatchPCM8A (int head, int tail) {
7035: if (head + 0x0000ff60 <= tail &&
7036: MC68060.mmuPeekLongData (head + 0x10f8, 1) == 0x50434d38 &&
7037: MC68060.mmuPeekLongData (head + 0x10fc, 1) == 0x41313032) {
7038: System.out.println (Multilingual.mlnJapanese ?
7039: "PCM8A.X 1.02 があります" :
7040: "PCM8A.X 1.02 exists");
7041: int patched = 0;
7042: int failed = 0;
7043:
7044: for (int offset : emxPCM8AFFMap) {
7045: if (MC68060.mmuPeekByteZeroData (head + offset, 1) == 0xff) {
7046: MC68060.mmuPokeByteData (head + offset, 0x00, 1);
7047: patched++;
7048: } else {
7049: failed++;
7050: }
7051: }
7052: if (patched != 0) {
7053: System.out.printf (Multilingual.mlnJapanese ?
7054: "PCM8A.X 1.02 にパッチをあてました (%d/%d)\n" :
7055: "PCM8A.X 1.02 was patched (%d/%d)\n",
7056: patched, patched + failed);
7057: }
7058: }
7059: }
7060:
7061:
7062:
7063: public static void emxPatch060turbosys (int head, int tail) {
7064:
7065:
7066:
7067:
7068: if (head + 0x00002000 <= tail &&
7069: MC68060.mmuPeekLongData (head + 0x00000ec0, 1) == 0x203c302e &&
7070: MC68060.mmuPeekLongData (head + 0x00000ec4, 1) == 0x3536227c &&
7071: MC68060.mmuPeekLongData (head + 0x00000ec8, 1) == 0x30363054) {
7072: System.out.println (Multilingual.mlnJapanese ?
7073: "060turbo.sys 0.56 があります" :
7074: "060turbo.sys 0.56 exists");
7075:
7076:
7077:
7078: int patched = 0;
7079: int failed = 0;
7080: if (MC68060.mmuPeekLongData (head + 0x000021e6, 1) == 0x08f90004 &&
7081: MC68060.mmuPeekLongData (head + 0x000021ea, 1) == 0x00ed0070) {
7082: MC68060.mmuPokeWordData (head + 0x000021e6, 0x0839, 1);
7083: patched++;
7084: } else {
7085: failed++;
7086: }
7087: System.out.printf (Multilingual.mlnJapanese ?
7088: "060turbo.sys 0.56 にパッチをあてました (%d/%d)\n" :
7089: "060turbo.sys 0.56 was patched (%d/%d)\n",
7090: patched, patched + failed);
7091: }
7092: }
7093:
7094:
7095:
7096: public static void emxCheckFSX (int head, int tail) {
7097: if (Z8530.SCC_FSX_MOUSE) {
7098: if (head + 0x00063200 <= tail &&
7099: "\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))) {
7100: System.out.println (Multilingual.mlnJapanese ?
7101: "FSX.X 3.10 があります" :
7102: "FSX.X 3.10 exists");
7103: Z8530.sccFSXMouseHook = head + 0x04f82a;
7104: Z8530.sccFSXMouseWork = head + 0x063184;
7105: }
7106: }
7107: }
7108:
7109:
7110:
7111:
7112:
7113:
7114: public static void emxCheckRSDRV202 (int head, int tail) {
7115: if (head + 0x000ea6 <= tail &&
7116: MC68060.mmuPeekEquals (head + 0x000e4e, "RS-232C DRIVER for X68000 version 2.02")) {
7117: if (RS232CTerminal.trmRSDRV202Head != head) {
7118: RS232CTerminal.trmRSDRV202Head = head;
7119: int[] patchData = {
7120:
7121:
7122: 0x05f8, 0x000a, 0x000b,
7123:
7124: 0x0600, 0xd040, 0x2048,
7125:
7126: 0x060e, 0x3030, 0x4e90,
7127: 0x0610, 0x0000, 0x2048,
7128:
7129: 0x074e, 0x0821, 0x2041,
7130: 0x0750, 0x0410, 0x3200,
7131: 0x0752, 0x0207, 0x303c,
7132: 0x0754, 0x0102, 0x0823,
7133: 0x0756, 0x0080, 0xe268,
7134: 0x0758, 0x003f, 0x72fe,
7135: 0x075a, 0x001f, 0xd141,
7136: 0x075c, 0x000e, 0x2208,
7137: 0x075e, 0x0006, 0x4e75,
7138:
7139:
7140: 0x0ab0, 0x0040, 0x0400,
7141: 0x0ad2, 0x0040, 0x0400,
7142: 0x0af4, 0x0040, 0x0400,
7143: 0x0b16, 0x0040, 0x0400,
7144: 0x0b38, 0x0040, 0x0400,
7145:
7146:
7147: 0x0cae, 0x0009, 0x000b,
7148: };
7149: int patched = 0;
7150: int failed = 0;
7151: for (int i = 0; i < patchData.length; i += 3) {
7152: int a = head + patchData[i];
7153: int b = patchData[i + 1];
7154: int c = patchData[i + 2];
7155: int d = MC68060.mmuPeekWordZeroData (a, 1);
7156: if (d == b) {
7157: MC68060.mmuPokeWordData (a, c, 1);
7158: patched++;
7159: } else if (d != c) {
7160: failed++;
7161: }
7162: }
7163: System.out.printf ("RSDRV.SYS 2.02 found at %08X and patched (%d/%d)\n", head, patched, patched + failed);
7164: }
7165: }
7166: }
7167:
7168:
7169:
7170:
7171:
7172: public static void emxCheckTMSIO031 (int head, int tail) {
7173: if (head + 0x000fc4 <= tail &&
7174: MC68060.mmuPeekEquals (head + 0x000d1c, "TMSIO version 0.31 Copyright (C) 1990-93 by Miki Hoshino")) {
7175: if (RS232CTerminal.trmTMSIO031Head != head) {
7176: RS232CTerminal.trmTMSIO031Head = head;
7177: System.out.printf ("TMSIO 0.31 found at %08X\n", head);
7178: }
7179: }
7180: }
7181:
7182:
7183:
7184:
7185:
7186: public static void emxCheckBSIO021 (int head, int tail) {
7187: if (head + 0x001c2c <= tail &&
7188: MC68060.mmuPeekEquals (head + 0x001a66, "BSIO version 0.21 Copyright (C) 1994 By BAZU")) {
7189: if (RS232CTerminal.trmBSIO021Head != head) {
7190: RS232CTerminal.trmBSIO021Head = head;
7191: System.out.printf ("BSIO 0.21 found at %08X\n", head);
7192: }
7193: }
7194: }
7195:
7196:
7197:
7198: public static void emxCheckTwentyOne (int head, int tail) {
7199: if (HFS.HFS_USE_TWENTY_ONE &&
7200: head + 64 <= tail) {
7201: if (MainMemory.mmrTwentyOneOptionAddress != 0 ||
7202: MainMemory.mmrHumanVersion <= 0) {
7203: return;
7204: }
7205: int name1 = MC68060.mmuPeekLongData (head + 14, 1);
7206: if (name1 == ('*' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7207: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7208: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '*')) {
7209: MainMemory.mmrTwentyOneOptionAddress = -1;
7210: }
7211: } else if (name1 == ('?' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7212: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7213: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '?') ||
7214: name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | 'E')) {
7215: System.out.println (Multilingual.mlnJapanese ?
7216: "TwentyOne.x があります" :
7217: "TwentyOne.x exists");
7218: MainMemory.mmrTwentyOneOptionAddress = head + 22;
7219: }
7220: }
7221: }
7222: }
7223:
7224:
7225:
7226:
7227:
7228:
7229:
7230:
7231:
7232:
7233:
7234:
7235:
7236:
7237:
7238:
7239:
7240:
7241:
7242:
7243:
7244:
7245:
7246:
7247:
7248:
7249:
7250:
7251:
7252:
7253:
7254:
7255:
7256:
7257:
7258:
7259:
7260:
7261:
7262:
7263:
7264:
7265:
7266:
7267:
7268:
7269:
7270:
7271:
7272:
7273:
7274: public static final boolean IRP_BITREV_REVERSE = false;
7275: public static final boolean IRP_BITREV_SHIFT = false;
7276: public static final boolean IRP_BITREV_TABLE = true;
7277:
7278: public static final boolean IRP_MOVEM_MAINMEMORY = true;
7279: public static final boolean IRP_MOVEM_EXPAND = false;
7280: public static final boolean IRP_MOVEM_LOOP = false;
7281: public static final boolean IRP_MOVEM_SHIFT_LEFT = false;
7282: public static final boolean IRP_MOVEM_SHIFT_RIGHT = true;
7283: public static final boolean IRP_MOVEM_ZEROS = false;
7284:
7285:
7286: public static void irpReset () {
7287:
7288: CRTC.crtReset ();
7289: VideoController.vcnReset ();
7290: HD63450.dmaReset ();
7291: MC68901.mfpReset ();
7292: Keyboard.kbdReset ();
7293: RP5C15.rtcReset ();
7294: PrinterPort.prnReset ();
7295: SoundSource.sndReset ();
7296: OPM.opmReset ();
7297: ADPCM.pcmReset ();
7298: FDC.fdcReset ();
7299: IOInterrupt.ioiReset ();
7300: eb2Reset ();
7301: SPC.spcReset ();
7302: Z8530.sccReset ();
7303: RS232CTerminal.trmReset ();
7304: PPI.ppiReset ();
7305: HFS.hfsReset ();
7306: SpriteScreen.sprReset ();
7307:
7308: xt3Reset ();
7309: SRAM.smrReset ();
7310: CONDevice.conReset ();
7311: TextCopy.txcReset ();
7312: }
7313:
7314:
7315:
7316:
7317:
7318:
7319:
7320:
7321:
7322:
7323:
7324:
7325:
7326:
7327:
7328:
7329:
7330:
7331:
7332:
7333:
7334:
7335:
7336:
7337:
7338:
7339:
7340:
7341:
7342:
7343:
7344:
7345:
7346:
7347:
7348:
7349:
7350:
7351:
7352:
7353:
7354:
7355:
7356:
7357:
7358:
7359:
7360:
7361:
7362:
7363:
7364:
7365:
7366:
7367:
7368:
7369:
7370:
7371:
7372:
7373:
7374:
7375:
7376:
7377:
7378:
7379:
7380:
7381:
7382:
7383:
7384:
7385:
7386:
7387:
7388:
7389:
7390:
7391:
7392:
7393:
7394:
7395:
7396:
7397:
7398:
7399:
7400:
7401:
7402:
7403:
7404:
7405:
7406:
7407:
7408:
7409:
7410:
7411:
7412:
7413:
7414:
7415:
7416:
7417:
7418:
7419:
7420:
7421:
7422:
7423:
7424:
7425:
7426:
7427:
7428:
7429:
7430:
7431:
7432:
7433:
7434:
7435:
7436:
7437:
7438:
7439:
7440:
7441:
7442:
7443:
7444:
7445:
7446:
7447:
7448:
7449:
7450:
7451:
7452:
7453:
7454:
7455:
7456:
7457:
7458:
7459:
7460:
7461:
7462:
7463:
7464:
7465:
7466:
7467:
7468:
7469:
7470:
7471:
7472:
7473:
7474:
7475:
7476:
7477:
7478:
7479:
7480:
7481:
7482:
7483:
7484:
7485:
7486:
7487:
7488:
7489:
7490:
7491:
7492:
7493:
7494:
7495:
7496:
7497:
7498:
7499:
7500:
7501:
7502:
7503:
7504:
7505:
7506:
7507:
7508:
7509:
7510:
7511:
7512:
7513:
7514:
7515:
7516:
7517:
7518:
7519:
7520:
7521:
7522:
7523:
7524:
7525:
7526:
7527:
7528:
7529:
7530:
7531:
7532:
7533:
7534:
7535:
7536:
7537:
7538:
7539:
7540:
7541:
7542:
7543:
7544:
7545:
7546:
7547:
7548:
7549:
7550:
7551:
7552:
7553:
7554:
7555:
7556:
7557:
7558:
7559:
7560:
7561:
7562:
7563:
7564:
7565:
7566:
7567:
7568:
7569:
7570:
7571:
7572:
7573:
7574:
7575:
7576:
7577:
7578:
7579:
7580:
7581:
7582:
7583:
7584:
7585:
7586:
7587:
7588:
7589:
7590:
7591:
7592:
7593:
7594:
7595:
7596:
7597:
7598:
7599:
7600:
7601:
7602:
7603:
7604:
7605:
7606:
7607:
7608:
7609:
7610:
7611:
7612:
7613:
7614:
7615:
7616:
7617:
7618:
7619:
7620:
7621:
7622:
7623:
7624:
7625:
7626:
7627:
7628:
7629:
7630:
7631:
7632:
7633:
7634:
7635:
7636:
7637:
7638:
7639:
7640:
7641:
7642:
7643:
7644:
7645:
7646:
7647:
7648:
7649:
7650:
7651:
7652:
7653:
7654:
7655:
7656:
7657:
7658:
7659:
7660:
7661:
7662:
7663:
7664:
7665:
7666:
7667:
7668:
7669:
7670:
7671:
7672:
7673:
7674:
7675:
7676:
7677:
7678:
7679:
7680:
7681:
7682:
7683:
7684:
7685:
7686:
7687:
7688:
7689:
7690:
7691:
7692:
7693:
7694:
7695:
7696:
7697:
7698:
7699:
7700:
7701:
7702:
7703:
7704:
7705:
7706:
7707:
7708:
7709:
7710:
7711:
7712:
7713:
7714:
7715:
7716:
7717:
7718:
7719:
7720:
7721:
7722:
7723:
7724:
7725:
7726:
7727:
7728:
7729:
7730:
7731:
7732:
7733:
7734:
7735:
7736:
7737:
7738:
7739:
7740:
7741:
7742:
7743:
7744:
7745:
7746:
7747:
7748:
7749:
7750:
7751:
7752:
7753:
7754:
7755:
7756:
7757:
7758:
7759:
7760:
7761:
7762:
7763:
7764:
7765:
7766:
7767:
7768:
7769:
7770:
7771:
7772:
7773:
7774:
7775:
7776:
7777:
7778:
7779:
7780:
7781:
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:
7824:
7825:
7826:
7827:
7828:
7829:
7830:
7831:
7832:
7833:
7834:
7835:
7836:
7837:
7838:
7839:
7840:
7841:
7842:
7843:
7844:
7845:
7846:
7847:
7848:
7849:
7850:
7851:
7852:
7853:
7854:
7855:
7856:
7857:
7858:
7859:
7860:
7861:
7862:
7863:
7864:
7865:
7866:
7867:
7868:
7869:
7870:
7871:
7872:
7873:
7874:
7875:
7876:
7877:
7878:
7879:
7880:
7881:
7882:
7883:
7884:
7885:
7886:
7887:
7888:
7889:
7890:
7891:
7892:
7893:
7894:
7895:
7896:
7897:
7898:
7899: 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);
7900:
7901: public static final boolean EFA_SEPARATE_AR = false;
7902:
7903:
7904:
7905:
7906:
7907:
7908: public static final boolean BUS_SPLIT_UNALIGNED_LONG = false;
7909:
7910:
7911: public static final int BUS_MOTHER_BITS = 24;
7912: public static final int BUS_MOTHER_SIZE = BUS_MOTHER_BITS < 32 ? 1 << BUS_MOTHER_BITS : 0;
7913: public static final int BUS_MOTHER_MASK = BUS_MOTHER_SIZE - 1;
7914:
7915: public static final int BUS_ARRAY_SIZE = BUS_MOTHER_SIZE;
7916:
7917:
7918: public static final int BUS_PAGE_BITS = 12;
7919: public static final int BUS_PAGE_SIZE = 1 << BUS_PAGE_BITS;
7920: public static final int BUS_PAGE_COUNT = 1 << (32 - BUS_PAGE_BITS);
7921:
7922:
7923: public static final int MPU_SS_BYTE = 0;
7924: public static final int MPU_SS_WORD = 1;
7925: public static final int MPU_SS_LONG = 2;
7926:
7927:
7928: public static final int MPU_WR_WRITE = 0;
7929: public static final int MPU_WR_READ = 1;
7930:
7931:
7932: public static final int MPU_US_USER = 0;
7933: public static final int MPU_US_SUPERVISOR = 1;
7934:
7935:
7936: public static final MemoryMappedDevice[] busUserMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
7937: public static final MemoryMappedDevice[] busSuperMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
7938: public static MemoryMappedDevice[] busMemoryMap;
7939:
7940:
7941: public static boolean busHimem68000;
7942:
7943:
7944: public static final int BUS_HIGH_MEMORY_START = 0x01000000;
7945: public static int busHighMemorySize;
7946: public static byte[] busHighMemoryArray;
7947: public static boolean busHighMemorySaveOn;
7948: public static boolean busHighMemory060turboOn;
7949:
7950:
7951: public static final int BUS_LOCAL_MEMORY_START = 0x10000000;
7952: public static int busLocalMemorySize;
7953: public static byte[] busLocalMemoryArray;
7954: public static boolean busLocalMemorySaveOn;
7955:
7956:
7957: public static final byte[] BUS_DUMMY_MEMORY_ARRAY = new byte[0];
7958: public static int busRequestExMemoryStart;
7959: public static int busRequestExMemorySize;
7960: public static byte[] busRequestExMemoryArray;
7961: public static int busExMemoryStart;
7962: public static int busExMemorySize;
7963: public static byte[] busExMemoryArray;
7964:
7965:
7966: public static boolean busRequestCutFC2Pin;
7967: public static boolean busCutFC2Pin;
7968:
7969:
7970:
7971: public static void busInit () {
7972:
7973:
7974: if (!DataBreakPoint.DBP_ON) {
7975: busMemoryMap = busSuperMap;
7976: }
7977:
7978:
7979: int highMemorySizeMB = Settings.sgsGetInt ("highmemory");
7980: busHighMemorySize = highMemorySizeMB == 16 ? highMemorySizeMB << 20 : 0 << 20;
7981: if (busHighMemorySize == 0) {
7982: System.out.println (Multilingual.mlnJapanese ?
7983: "X68030/Xellent30 のハイメモリはありません" :
7984: "X68030/Xellent30 high memory does not exists");
7985: } else {
7986: System.out.printf (Multilingual.mlnJapanese ?
7987: "X68030/Xellent30 のハイメモリのサイズは %dMB です\n" :
7988: "X68030/Xellent30 high memory size is %dMB\n",
7989: busHighMemorySize >> 20);
7990: }
7991: busHighMemoryArray = new byte[busHighMemorySize];
7992:
7993: busHimem68000 = Settings.sgsGetOnOff ("himem68000");
7994:
7995: busHighMemorySaveOn = Settings.sgsGetOnOff ("highmemorysave");
7996: busHighMemory060turboOn = Settings.sgsGetOnOff ("highmemory060turbo");
7997:
7998: byte[] highMemoryArray = Settings.sgsGetData ("highmemorydata");
7999: if (busHighMemorySize != 0) {
8000: if (highMemoryArray.length != 0) {
8001: System.out.println (Multilingual.mlnJapanese ?
8002: "X68030/Xellent30 のハイメモリのデータを復元します" :
8003: "X68030/Xellent30 high memory data is restored");
8004: System.arraycopy (highMemoryArray, 0, busHighMemoryArray, 0, Math.min (highMemoryArray.length, busHighMemorySize));
8005: } else {
8006: System.out.println (Multilingual.mlnJapanese ?
8007: "X68030/Xellent30 のハイメモリをゼロクリアします" :
8008: "X68030/Xellent30 high memory is zero-cleared");
8009: }
8010: if (highMemoryArray.length < busHighMemorySize) {
8011: Arrays.fill (busHighMemoryArray, highMemoryArray.length, busHighMemorySize, (byte) 0);
8012: }
8013: }
8014:
8015:
8016: int localMemorySizeMB = Settings.sgsGetInt ("localmemory");
8017: busLocalMemorySize = (localMemorySizeMB == 16 ||
8018: localMemorySizeMB == 32 ||
8019: localMemorySizeMB == 64 ||
8020: localMemorySizeMB == 128 ||
8021: localMemorySizeMB == 256 ||
8022: localMemorySizeMB == 384 ||
8023: localMemorySizeMB == 512 ||
8024: localMemorySizeMB == 768 ?
8025: localMemorySizeMB << 20 :
8026: 128 << 20);
8027: if (busLocalMemorySize == 0) {
8028: System.out.println (Multilingual.mlnJapanese ?
8029: "060turbo のハイメモリはありません" :
8030: "060turbo high memory does not exists");
8031: } else {
8032: System.out.printf (Multilingual.mlnJapanese ?
8033: "060turbo のハイメモリのサイズは %dMB です\n" :
8034: "060turbo high memory size is %dMB\n",
8035: busLocalMemorySize >> 20);
8036: }
8037: busLocalMemoryArray = new byte[busLocalMemorySize];
8038:
8039: busLocalMemorySaveOn = Settings.sgsGetOnOff ("localmemorysave");
8040:
8041: byte[] localMemoryArray = Settings.sgsGetData ("localmemorydata");
8042: if (busLocalMemorySize != 0) {
8043: if (localMemoryArray.length != 0) {
8044: System.out.println (Multilingual.mlnJapanese ?
8045: "060turbo のハイメモリのデータを復元します" :
8046: "060turbo high memory data is restored");
8047: System.arraycopy (localMemoryArray, 0, busLocalMemoryArray, 0, Math.min (localMemoryArray.length, busLocalMemorySize));
8048: } else {
8049: System.out.println (Multilingual.mlnJapanese ?
8050: "060turbo のハイメモリをゼロクリアします" :
8051: "060turbo high memory is zero-cleared");
8052: }
8053: if (localMemoryArray.length < busLocalMemorySize) {
8054: Arrays.fill (busLocalMemoryArray, localMemoryArray.length, busLocalMemorySize, (byte) 0);
8055: }
8056: }
8057:
8058:
8059: busExMemoryStart = busRequestExMemoryStart = 0x10000000;
8060: busExMemorySize = busRequestExMemorySize = 0 << 20;
8061: busExMemoryArray = busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
8062:
8063:
8064: busRequestCutFC2Pin = Settings.sgsGetOnOff ("cutfc2pin");
8065: busCutFC2Pin = !busRequestCutFC2Pin;
8066:
8067: busUpdateMemoryMap ();
8068:
8069: }
8070:
8071:
8072:
8073: public static void busTini () {
8074: Settings.sgsPutOnOff ("himem68000", busHimem68000);
8075: Settings.sgsPutInt ("highmemory", busHighMemorySize >>> 20);
8076: Settings.sgsPutOnOff ("highmemorysave", busHighMemorySaveOn);
8077: Settings.sgsPutOnOff ("highmemory060turbo", busHighMemory060turboOn);
8078: Settings.sgsPutData ("highmemorydata", busHighMemorySaveOn ? busHighMemoryArray : new byte[0]);
8079: Settings.sgsPutInt ("localmemory", busLocalMemorySize >>> 20);
8080: Settings.sgsPutOnOff ("localmemorysave", busLocalMemorySaveOn);
8081: Settings.sgsPutData ("localmemorydata", busLocalMemorySaveOn ? busLocalMemoryArray : new byte[0]);
8082: Settings.sgsPutOnOff ("cutfc2pin", busRequestCutFC2Pin);
8083: }
8084:
8085: public static void busUpdateMemoryMap () {
8086: if (busExMemoryStart == busRequestExMemoryStart &&
8087: busExMemorySize == busRequestExMemorySize &&
8088: busExMemoryArray == busRequestExMemoryArray &&
8089: busExMemoryArray.length == busExMemorySize &&
8090: busCutFC2Pin == busRequestCutFC2Pin) {
8091: return;
8092: }
8093:
8094: busExMemoryStart = busRequestExMemoryStart;
8095: busExMemorySize = busRequestExMemorySize;
8096: busExMemoryArray = busRequestExMemoryArray;
8097: if (busExMemoryArray.length != busExMemorySize) {
8098: byte[] newArray = new byte[busExMemorySize];
8099: int copySize = Math.min (busExMemoryArray.length, busExMemorySize);
8100: if (copySize > 0) {
8101: System.arraycopy (busExMemoryArray, 0, newArray, 0, copySize);
8102: }
8103: if (busExMemoryArray == busHighMemoryArray) {
8104: busHighMemoryArray = newArray;
8105: } else if (busExMemoryArray == busLocalMemoryArray) {
8106: busLocalMemoryArray = newArray;
8107: }
8108: busExMemoryArray = newArray;
8109: }
8110:
8111: busCutFC2Pin = busRequestCutFC2Pin;
8112:
8113:
8114:
8115:
8116:
8117:
8118:
8119:
8120:
8121:
8122:
8123:
8124: busSuper (MemoryMappedDevice.MMD_MMR, 0x00000000, 0x00002000);
8125: busUser ( MemoryMappedDevice.MMD_MMR, 0x00002000, 0x00c00000);
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: busSuper (MemoryMappedDevice.MMD_GE0, 0x00c00000, 0x00c80000);
8151: busSuper (MemoryMappedDevice.MMD_GE1, 0x00c80000, 0x00d00000);
8152: busSuper (MemoryMappedDevice.MMD_GE2, 0x00d00000, 0x00d80000);
8153: busSuper (MemoryMappedDevice.MMD_GE3, 0x00d80000, 0x00e00000);
8154:
8155:
8156:
8157:
8158: busSuper (MemoryMappedDevice.MMD_TXT, 0x00e00000, 0x00e80000);
8159:
8160:
8161:
8162:
8163: busSuper (MemoryMappedDevice.MMD_CRT, 0x00e80000, 0x00e82000);
8164:
8165:
8166:
8167:
8168:
8169: busSuper (MemoryMappedDevice.MMD_VCN, 0x00e82000, 0x00e84000);
8170:
8171:
8172:
8173:
8174: busSuper (MemoryMappedDevice.MMD_DMA, 0x00e84000, 0x00e86000);
8175:
8176:
8177:
8178:
8179: busSuper (MemoryMappedDevice.MMD_SVS, 0x00e86000, 0x00e88000);
8180:
8181:
8182:
8183:
8184: busSuper (MemoryMappedDevice.MMD_MFP, 0x00e88000, 0x00e8a000);
8185:
8186:
8187:
8188:
8189: busSuper (MemoryMappedDevice.MMD_RTC_FIRST, 0x00e8a000, 0x00e8c000);
8190:
8191:
8192:
8193:
8194: busSuper (MemoryMappedDevice.MMD_PRN, 0x00e8c000, 0x00e8e000);
8195:
8196:
8197:
8198:
8199: busSuper (MemoryMappedDevice.MMD_SYS, 0x00e8e000, 0x00e90000);
8200:
8201:
8202:
8203:
8204: busSuper (MemoryMappedDevice.MMD_OPM, 0x00e90000, 0x00e92000);
8205:
8206:
8207:
8208:
8209: busSuper (MemoryMappedDevice.MMD_PCM, 0x00e92000, 0x00e94000);
8210:
8211:
8212:
8213:
8214: busSuper (MemoryMappedDevice.MMD_FDC, 0x00e94000, 0x00e96000);
8215:
8216:
8217:
8218:
8219:
8220: busSuper (MemoryMappedDevice.MMD_HDC, 0x00e96000, 0x00e98000);
8221:
8222:
8223:
8224:
8225: busSuper (MemoryMappedDevice.MMD_SCC, 0x00e98000, 0x00e9a000);
8226:
8227:
8228:
8229:
8230: busSuper (MemoryMappedDevice.MMD_PPI, 0x00e9a000, 0x00e9c000);
8231:
8232:
8233:
8234:
8235: busSuper (MemoryMappedDevice.MMD_IOI, 0x00e9c000, 0x00e9e000);
8236:
8237:
8238:
8239:
8240:
8241:
8242:
8243:
8244:
8245: busSuper (MemoryMappedDevice.MMD_XB1, 0x00e9e000, 0x00ea0000);
8246:
8247:
8248:
8249:
8250:
8251: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ea0000, 0x00eae000);
8252:
8253:
8254:
8255:
8256:
8257:
8258:
8259:
8260:
8261:
8262:
8263:
8264:
8265:
8266:
8267: busSuper (MemoryMappedDevice.MMD_XB2, 0x00eae000, 0x00eb0000);
8268:
8269:
8270:
8271:
8272:
8273:
8274:
8275:
8276: busSuper (MemoryMappedDevice.MMD_SPR, 0x00eb0000, 0x00ec0000);
8277:
8278:
8279:
8280:
8281:
8282:
8283:
8284:
8285:
8286:
8287:
8288:
8289:
8290: busSuper (MemoryMappedDevice.MMD_XB3, 0x00ec0000, 0x00ed0000);
8291:
8292:
8293:
8294:
8295:
8296:
8297: busSuper (MemoryMappedDevice.MMD_SMR, 0x00ed0000, 0x00ed0000 + 16384);
8298: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ed0000 + 16384, 0x00ed0000 + 65536);
8299:
8300:
8301:
8302:
8303:
8304:
8305:
8306:
8307: busSuper (MemoryMappedDevice.MMD_XB4, 0x00ee0000, 0x00f00000);
8308:
8309:
8310:
8311:
8312:
8313:
8314:
8315:
8316:
8317:
8318: busSuper (MemoryMappedDevice.MMD_CG1, 0x00f00000, 0x00f40000);
8319:
8320:
8321:
8322:
8323:
8324:
8325:
8326: busSuper (MemoryMappedDevice.MMD_CG2, 0x00f40000, 0x00fc0000);
8327:
8328:
8329:
8330:
8331:
8332:
8333:
8334:
8335:
8336:
8337:
8338:
8339:
8340:
8341: busSuper (MemoryMappedDevice.MMD_ROM, 0x00fc0000, 0x01000000);
8342:
8343: }
8344:
8345: public static void busReset () {
8346: if (regSRS != 0) {
8347: if (DataBreakPoint.DBP_ON) {
8348: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpSuperMap;
8349: } else {
8350: busMemoryMap = busSuperMap;
8351: }
8352: } else {
8353: if (DataBreakPoint.DBP_ON) {
8354: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpUserMap;
8355: } else {
8356: busMemoryMap = busUserMap;
8357: }
8358: }
8359: }
8360:
8361:
8362:
8363:
8364:
8365: public static void busUser (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8366: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8367: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8368: if (false &&
8369: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8370: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8371: System.out.printf ("ERROR: busUser (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8372: }
8373: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8374: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8375: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8376: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8377: int startPage = blockStartPage + motherStartPage;
8378: int endPage = blockStartPage + motherEndPage;
8379: for (int page = startPage; page < endPage; page++) {
8380: MemoryMappedDevice superMmd = exMemoryStartPage <= page && page < exMemoryEndPage ? MemoryMappedDevice.MMD_XMM : mmd;
8381: busUserMap[page] = busSuperMap[page] = superMmd;
8382: if (InstructionBreakPoint.IBP_ON) {
8383: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8384: InstructionBreakPoint.ibpUserMap[page] = superMmd;
8385: }
8386: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8387: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8388: }
8389: }
8390: if (DataBreakPoint.DBP_ON) {
8391: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8392: DataBreakPoint.dbpUserMap[page] = superMmd;
8393: }
8394: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8395: DataBreakPoint.dbpSuperMap[page] = superMmd;
8396: }
8397: }
8398: }
8399: }
8400: }
8401:
8402:
8403:
8404:
8405:
8406: public static void busSuper (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8407: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8408: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8409: if (false &&
8410: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8411: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8412: System.out.printf ("ERROR: busSuper (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8413: }
8414: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8415: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8416: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8417: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8418: int startPage = blockStartPage + motherStartPage;
8419: int endPage = blockStartPage + motherEndPage;
8420: for (int page = startPage; page < endPage; page++) {
8421: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
8422: MemoryMappedDevice userMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : busCutFC2Pin ? mmd : MemoryMappedDevice.MMD_NUL;
8423: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
8424: busUserMap[page] = userMmd;
8425: busSuperMap[page] = superMmd;
8426: if (InstructionBreakPoint.IBP_ON) {
8427: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8428: InstructionBreakPoint.ibpUserMap[page] = userMmd;
8429: }
8430: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8431: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8432: }
8433: }
8434: if (DataBreakPoint.DBP_ON) {
8435: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8436: DataBreakPoint.dbpUserMap[page] = userMmd;
8437: }
8438: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8439: DataBreakPoint.dbpSuperMap[page] = superMmd;
8440: }
8441: }
8442: }
8443: }
8444: }
8445:
8446:
8447:
8448: public static byte busPbs (int a) {
8449: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a);
8450: }
8451:
8452:
8453:
8454: public static int busPbz (int a) {
8455: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a);
8456: }
8457:
8458:
8459:
8460: public static int busPws (int a) {
8461: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8462: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
8463: } else {
8464: int a1 = a + 1;
8465: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
8466: }
8467: }
8468:
8469:
8470:
8471: public static int busPwse (int a) {
8472: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
8473: }
8474:
8475:
8476:
8477: public static int busPwz (int a) {
8478: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8479: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
8480: } else {
8481: int a1 = a + 1;
8482: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
8483: }
8484: }
8485:
8486:
8487:
8488: public static int busPwze (int a) {
8489: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
8490: }
8491:
8492:
8493:
8494: public static int busPls (int a) {
8495: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8496: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
8497: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8498: int a2 = a + 2;
8499: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a) << 16 | busSuperMap[a2 >>> BUS_PAGE_BITS].mmdPwz (a2);
8500: } else {
8501: int a1 = a + 1;
8502: int a3 = a + 3;
8503: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 24 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPwz (a1) << 8 | busSuperMap[a3 >>> BUS_PAGE_BITS].mmdPbz (a3);
8504: }
8505: }
8506:
8507:
8508:
8509: public static int busPlsf (int a) {
8510: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
8511: }
8512:
8513:
8514:
8515: public static long busPqs (int a) {
8516: return (long) busPls (a) << 32 | busPls (a + 4) & 0xffffffffL;
8517: }
8518:
8519:
8520:
8521: public static int busSearchByte (int start, int end, int c) {
8522: for (int a = start; a < end; a++) {
8523: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) == c) {
8524: return a;
8525: }
8526: }
8527: return -1;
8528: }
8529: public static int busSearchWord (int start, int end, int c) {
8530: for (int a = start; a < end; a += 2) {
8531: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) == c) {
8532: return a;
8533: }
8534: }
8535: return -1;
8536: }
8537: public static int busSearchByteArray (int start, int end, int[] array) {
8538: int l = array.length;
8539: end -= l;
8540: int c = array[0];
8541: a:
8542: for (int a = start; a <= end; a++) {
8543: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) != c) {
8544: continue a;
8545: }
8546: for (int i = 1, b = a + 1; i < l; i++, b++) {
8547: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPbz (b) != array[i]) {
8548: continue a;
8549: }
8550: }
8551: return a;
8552: }
8553: return -1;
8554: }
8555: public static int busSearchWordArray (int start, int end, int[] array) {
8556: int l = array.length;
8557: end -= l;
8558: int c = array[0];
8559: a:
8560: for (int a = start; a <= end; a += 2) {
8561: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) != c) {
8562: continue a;
8563: }
8564: for (int i = 1, b = a + 2; i < l; i++, b += 2) {
8565: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPwz (b) != array[i]) {
8566: continue a;
8567: }
8568: }
8569: return a;
8570: }
8571: return -1;
8572: }
8573:
8574:
8575:
8576:
8577: public static byte busRbs (int a) throws M68kException {
8578: if (DataBreakPoint.DBP_ON) {
8579: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
8580: } else {
8581: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
8582: }
8583: }
8584:
8585:
8586:
8587: public static int busRbz (int a) throws M68kException {
8588: if (DataBreakPoint.DBP_ON) {
8589: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
8590: } else {
8591: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
8592: }
8593: }
8594:
8595:
8596:
8597: public static int busRws (int a) throws M68kException {
8598: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8599: if (DataBreakPoint.DBP_ON) {
8600: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8601: } else {
8602: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8603: }
8604: } else if (mpuIgnoreAddressError) {
8605: int a1 = a + 1;
8606: if (DataBreakPoint.DBP_ON) {
8607: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8608: } else {
8609: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8610: }
8611: } else {
8612: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8613: M68kException.m6eAddress = a;
8614: M68kException.m6eDirection = MPU_WR_READ;
8615: M68kException.m6eSize = MPU_SS_WORD;
8616: throw M68kException.m6eSignal;
8617: }
8618: }
8619:
8620:
8621:
8622:
8623: public static int busRwse (int a) throws M68kException {
8624: if (DataBreakPoint.DBP_ON) {
8625: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8626: } else {
8627: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8628: }
8629: }
8630:
8631:
8632:
8633: public static int busRwz (int a) throws M68kException {
8634: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8635: if (DataBreakPoint.DBP_ON) {
8636: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8637: } else {
8638: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8639: }
8640: } else if (mpuIgnoreAddressError) {
8641: int a1 = a + 1;
8642: if (DataBreakPoint.DBP_ON) {
8643: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8644: } else {
8645: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8646: }
8647: } else {
8648: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8649: M68kException.m6eAddress = a;
8650: M68kException.m6eDirection = MPU_WR_READ;
8651: M68kException.m6eSize = MPU_SS_WORD;
8652: throw M68kException.m6eSignal;
8653: }
8654: }
8655:
8656:
8657:
8658:
8659: public static int busRwze (int a) throws M68kException {
8660: if (DataBreakPoint.DBP_ON) {
8661: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8662: } else {
8663: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8664: }
8665: }
8666:
8667:
8668:
8669: public static int busRls (int a) throws M68kException {
8670: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8671: if (DataBreakPoint.DBP_ON) {
8672: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8673: } else {
8674: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8675: }
8676: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8677: int a2 = a + 2;
8678: if (BUS_SPLIT_UNALIGNED_LONG) {
8679: if (DataBreakPoint.DBP_ON) {
8680: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8681: } else {
8682: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8683: }
8684: } else {
8685: MemoryMappedDevice mmd;
8686: MemoryMappedDevice mmd2;
8687: if (DataBreakPoint.DBP_ON) {
8688: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8689: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8690: } else {
8691: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8692: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8693: }
8694: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
8695: }
8696: } else if (mpuIgnoreAddressError) {
8697: int a1 = a + 1;
8698: int a3 = a + 3;
8699: if (DataBreakPoint.DBP_ON) {
8700: 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);
8701: } else {
8702: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 24 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRwz (a1) << 8 | busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdRbz (a3);
8703: }
8704: } else {
8705: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8706: M68kException.m6eAddress = a;
8707: M68kException.m6eDirection = MPU_WR_READ;
8708: M68kException.m6eSize = MPU_SS_LONG;
8709: throw M68kException.m6eSignal;
8710: }
8711: }
8712:
8713:
8714:
8715:
8716: public static int busRlse (int a) throws M68kException {
8717: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8718: if (DataBreakPoint.DBP_ON) {
8719: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8720: } else {
8721: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8722: }
8723: } else {
8724: int a2 = a + 2;
8725: if (BUS_SPLIT_UNALIGNED_LONG) {
8726: if (DataBreakPoint.DBP_ON) {
8727: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8728: } else {
8729: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8730: }
8731: } else {
8732: MemoryMappedDevice mmd;
8733: MemoryMappedDevice mmd2;
8734: if (DataBreakPoint.DBP_ON) {
8735: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8736: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8737: } else {
8738: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8739: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8740: }
8741: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
8742: }
8743: }
8744: }
8745:
8746:
8747:
8748:
8749: public static int busRlsf (int a) throws M68kException {
8750: if (DataBreakPoint.DBP_ON) {
8751: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8752: } else {
8753: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8754: }
8755: }
8756:
8757:
8758:
8759: public static long busRqs (int a) throws M68kException {
8760: return (long) busRls (a) << 32 | busRls (a + 4) & 0xffffffffL;
8761: }
8762:
8763:
8764:
8765: public static void busWb (int a, int d) throws M68kException {
8766: if (DataBreakPoint.DBP_ON) {
8767: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
8768: } else {
8769: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
8770: }
8771: }
8772:
8773:
8774:
8775: public static void busWw (int a, int d) throws M68kException {
8776: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8777: if (DataBreakPoint.DBP_ON) {
8778: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8779: } else {
8780: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8781: }
8782: } else if (mpuIgnoreAddressError) {
8783: int a1 = a + 1;
8784: if (DataBreakPoint.DBP_ON) {
8785: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
8786: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
8787: } else {
8788: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
8789: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
8790: }
8791: } else {
8792: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8793: M68kException.m6eAddress = a;
8794: M68kException.m6eDirection = MPU_WR_WRITE;
8795: M68kException.m6eSize = MPU_SS_WORD;
8796: throw M68kException.m6eSignal;
8797: }
8798: }
8799:
8800:
8801:
8802:
8803: public static void busWwe (int a, int d) throws M68kException {
8804: if (DataBreakPoint.DBP_ON) {
8805: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8806: } else {
8807: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8808: }
8809: }
8810:
8811:
8812:
8813: public static void busWl (int a, int d) throws M68kException {
8814: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8815: if (DataBreakPoint.DBP_ON) {
8816: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8817: } else {
8818: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8819: }
8820: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8821: int a2 = a + 2;
8822: if (BUS_SPLIT_UNALIGNED_LONG) {
8823: if (DataBreakPoint.DBP_ON) {
8824: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8825: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8826: } else {
8827: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8828: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8829: }
8830: } else {
8831: MemoryMappedDevice mmd;
8832: MemoryMappedDevice mmd2;
8833: if (DataBreakPoint.DBP_ON) {
8834: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8835: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8836: } else {
8837: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8838: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8839: }
8840: if (mmd == mmd2) {
8841: mmd.mmdWl (a, d);
8842: } else {
8843: mmd.mmdWw (a, d >> 16);
8844: mmd2.mmdWw (a2, d);
8845: }
8846: }
8847: } else if (mpuIgnoreAddressError) {
8848: int a1 = a + 1;
8849: int a3 = a + 3;
8850: if (DataBreakPoint.DBP_ON) {
8851: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
8852: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
8853: DataBreakPoint.dbpMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
8854: } else {
8855: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
8856: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
8857: busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
8858: }
8859: } else {
8860: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8861: M68kException.m6eAddress = a;
8862: M68kException.m6eDirection = MPU_WR_WRITE;
8863: M68kException.m6eSize = MPU_SS_LONG;
8864: throw M68kException.m6eSignal;
8865: }
8866: }
8867:
8868:
8869:
8870:
8871: public static void busWlf (int a, int d) throws M68kException {
8872: if (DataBreakPoint.DBP_ON) {
8873: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8874: } else {
8875: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8876: }
8877: }
8878:
8879:
8880:
8881:
8882: public static void busWle (int a, int d) throws M68kException {
8883: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8884: if (DataBreakPoint.DBP_ON) {
8885: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8886: } else {
8887: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8888: }
8889: } else {
8890: int a2 = a + 2;
8891: if (BUS_SPLIT_UNALIGNED_LONG) {
8892: if (DataBreakPoint.DBP_ON) {
8893: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8894: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8895: } else {
8896: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8897: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8898: }
8899: } else {
8900: MemoryMappedDevice mmd;
8901: MemoryMappedDevice mmd2;
8902: if (DataBreakPoint.DBP_ON) {
8903: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8904: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8905: } else {
8906: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8907: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8908: }
8909: if (mmd == mmd2) {
8910: mmd.mmdWl (a, d);
8911: } else {
8912: mmd.mmdWw (a, d >> 16);
8913: mmd2.mmdWw (a2, d);
8914: }
8915: }
8916: }
8917: }
8918:
8919:
8920:
8921: public static void busWq (int a, long d) throws M68kException {
8922: busWl (a, (int) (d >>> 32));
8923: busWl (a + 4, (int) d);
8924: }
8925:
8926:
8927:
8928:
8929:
8930: public static void busRbb (int a, byte[] bb, int o, int l) throws M68kException {
8931: if (false) {
8932: for (int i = 0; i < l; i++) {
8933: int ai = a + i;
8934: if (DataBreakPoint.DBP_ON) {
8935: bb[o + i] = DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
8936: } else {
8937: bb[o + i] = busMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
8938: }
8939: }
8940: } else {
8941: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
8942: while (l > 0) {
8943: MemoryMappedDevice mmd;
8944: if (DataBreakPoint.DBP_ON) {
8945: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8946: } else {
8947: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8948: }
8949: int s = l <= r ? l : r;
8950: l -= s;
8951: if (true) {
8952: for (s -= 16; s >= 0; s -= 16) {
8953: bb[o ] = mmd.mmdRbs (a );
8954: bb[o + 1] = mmd.mmdRbs (a + 1);
8955: bb[o + 2] = mmd.mmdRbs (a + 2);
8956: bb[o + 3] = mmd.mmdRbs (a + 3);
8957: bb[o + 4] = mmd.mmdRbs (a + 4);
8958: bb[o + 5] = mmd.mmdRbs (a + 5);
8959: bb[o + 6] = mmd.mmdRbs (a + 6);
8960: bb[o + 7] = mmd.mmdRbs (a + 7);
8961: bb[o + 8] = mmd.mmdRbs (a + 8);
8962: bb[o + 9] = mmd.mmdRbs (a + 9);
8963: bb[o + 10] = mmd.mmdRbs (a + 10);
8964: bb[o + 11] = mmd.mmdRbs (a + 11);
8965: bb[o + 12] = mmd.mmdRbs (a + 12);
8966: bb[o + 13] = mmd.mmdRbs (a + 13);
8967: bb[o + 14] = mmd.mmdRbs (a + 14);
8968: bb[o + 15] = mmd.mmdRbs (a + 15);
8969: a += 16;
8970: o += 16;
8971: }
8972: s += 16;
8973: }
8974: for (int i = 0; i < s; i++) {
8975: bb[o + i] = mmd.mmdRbs (a + i);
8976: }
8977: a += s;
8978: o += s;
8979: r = BUS_PAGE_SIZE;
8980: }
8981: }
8982: }
8983:
8984:
8985:
8986: public static void busWbb (int a, byte[] bb, int o, int l) throws M68kException {
8987: if (false) {
8988: for (int i = 0; i < l; i++) {
8989: int ai = a + i;
8990: if (DataBreakPoint.DBP_ON) {
8991: DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
8992: } else {
8993: busMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
8994: }
8995: }
8996: } else {
8997: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
8998: while (l > 0) {
8999: MemoryMappedDevice mmd;
9000: if (DataBreakPoint.DBP_ON) {
9001: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9002: } else {
9003: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9004: }
9005: int s = l <= r ? l : r;
9006: l -= s;
9007: if (true) {
9008: for (s -= 16; s >= 0; s -= 16) {
9009: mmd.mmdWb (a , bb[o ]);
9010: mmd.mmdWb (a + 1, bb[o + 1]);
9011: mmd.mmdWb (a + 2, bb[o + 2]);
9012: mmd.mmdWb (a + 3, bb[o + 3]);
9013: mmd.mmdWb (a + 4, bb[o + 4]);
9014: mmd.mmdWb (a + 5, bb[o + 5]);
9015: mmd.mmdWb (a + 6, bb[o + 6]);
9016: mmd.mmdWb (a + 7, bb[o + 7]);
9017: mmd.mmdWb (a + 8, bb[o + 8]);
9018: mmd.mmdWb (a + 9, bb[o + 9]);
9019: mmd.mmdWb (a + 10, bb[o + 10]);
9020: mmd.mmdWb (a + 11, bb[o + 11]);
9021: mmd.mmdWb (a + 12, bb[o + 12]);
9022: mmd.mmdWb (a + 13, bb[o + 13]);
9023: mmd.mmdWb (a + 14, bb[o + 14]);
9024: mmd.mmdWb (a + 15, bb[o + 15]);
9025: a += 16;
9026: o += 16;
9027: }
9028: s += 16;
9029: }
9030: for (int i = 0; i < s; i++) {
9031: mmd.mmdWb (a + i, bb[o + i]);
9032: }
9033: a += s;
9034: o += s;
9035: r = BUS_PAGE_SIZE;
9036: }
9037: }
9038: }
9039:
9040:
9041:
9042: public static void busVb (int a, int d) {
9043: try {
9044: if (DataBreakPoint.DBP_ON) {
9045: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9046: } else {
9047: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9048: }
9049: } catch (M68kException e) {
9050: }
9051: }
9052:
9053:
9054:
9055: public static void busVw (int a, int d) {
9056: try {
9057: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9058: if (DataBreakPoint.DBP_ON) {
9059: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9060: } else {
9061: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9062: }
9063: }
9064: } catch (M68kException e) {
9065: }
9066: }
9067:
9068:
9069:
9070: public static void busVl (int a, int d) {
9071: try {
9072: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9073: if (DataBreakPoint.DBP_ON) {
9074: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9075: } else {
9076: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9077: }
9078: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9079: int a2 = a + 2;
9080: MemoryMappedDevice mmd;
9081: MemoryMappedDevice mmd2;
9082: if (DataBreakPoint.DBP_ON) {
9083: mmd = (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS];
9084: mmd2 = (regSRS != 0 ? busSuperMap : busUserMap)[a2 >>> BUS_PAGE_BITS];
9085: } else {
9086: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9087: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9088: }
9089: if (mmd == mmd2) {
9090: mmd.mmdWl (a, d);
9091: } else {
9092: mmd.mmdWw (a, d >> 16);
9093: mmd2.mmdWw (a2, d);
9094: }
9095: }
9096: } catch (M68kException e) {
9097: }
9098: }
9099:
9100:
9101:
9102:
9103:
9104: public static final int SVS_AREASET = 0x00e86001;
9105:
9106:
9107:
9108:
9109:
9110:
9111:
9112:
9113:
9114: public static void svsInit () {
9115: }
9116:
9117:
9118:
9119:
9120:
9121:
9122:
9123:
9124:
9125:
9126:
9127:
9128:
9129:
9130:
9131:
9132:
9133:
9134:
9135:
9136:
9137:
9138:
9139:
9140:
9141:
9142:
9143:
9144:
9145:
9146:
9147:
9148:
9149:
9150:
9151: public static boolean sysNMIFlag;
9152:
9153:
9154:
9155: public static void sysInit () {
9156: sysNMIFlag = false;
9157: }
9158:
9159:
9160:
9161:
9162:
9163:
9164: public static int sysAcknowledge () {
9165: return M68kException.M6E_LEVEL_7_INTERRUPT_AUTOVECTOR;
9166: }
9167:
9168:
9169:
9170:
9171: public static void sysDone () {
9172: if (sysNMIFlag) {
9173: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9174: }
9175: }
9176:
9177:
9178:
9179: public static void sysInterrupt () {
9180: sysNMIFlag = true;
9181: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9182: }
9183:
9184:
9185:
9186: public static void sysResetNMI () {
9187: sysNMIFlag = false;
9188: }
9189:
9190:
9191:
9192:
9193:
9194:
9195: public static final int EB2_SPC_REQUEST = 0x4000;
9196: public static final int EB2_SPC_VECTOR = 0xf6;
9197:
9198:
9199:
9200: public static int eb2Request;
9201:
9202:
9203:
9204: public static void eb2Reset () {
9205: eb2Request = 0;
9206: }
9207:
9208:
9209:
9210:
9211:
9212: public static void eb2Interrupt (int mask) {
9213: eb2Request |= mask;
9214: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9215: }
9216:
9217:
9218:
9219:
9220:
9221:
9222:
9223: public static int eb2Acknowledge () {
9224: if ((eb2Request & EB2_SPC_REQUEST) != 0) {
9225: eb2Request &= ~EB2_SPC_REQUEST;
9226: return EB2_SPC_VECTOR;
9227: }
9228: return 0;
9229: }
9230:
9231:
9232:
9233:
9234:
9235: public static void eb2Done () {
9236: if (eb2Request != 0) {
9237: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9238: }
9239: }
9240:
9241:
9242:
9243:
9244:
9245:
9246:
9247:
9248:
9249:
9250:
9251:
9252:
9253:
9254:
9255:
9256:
9257:
9258:
9259:
9260:
9261:
9262:
9263:
9264:
9265:
9266:
9267:
9268:
9269:
9270:
9271:
9272:
9273:
9274:
9275:
9276:
9277:
9278:
9279:
9280:
9281:
9282:
9283:
9284:
9285:
9286:
9287:
9288:
9289:
9290:
9291:
9292:
9293:
9294:
9295:
9296:
9297:
9298:
9299:
9300:
9301:
9302:
9303:
9304: public static final int BNK_SIZE = 1024 * 1024 * 32;
9305: public static byte[] bnkMemory;
9306: public static int bnkPageStart;
9307: public static boolean bnkOn;
9308:
9309: public static void bnkInit () {
9310: bnkMemory = new byte[BNK_SIZE];
9311: byte[] array = Settings.sgsGetData ("bankdata");
9312: if (array.length != 0) {
9313: System.arraycopy (array, 0, bnkMemory, 0, Math.min (array.length, BNK_SIZE));
9314: }
9315: bnkPageStart = 0;
9316:
9317: bnkOn = false;
9318: }
9319:
9320: public static void bnkTini () {
9321: Settings.sgsPutData ("bankdata", bnkMemory, 0, BNK_SIZE);
9322: }
9323:
9324:
9325:
9326:
9327:
9328:
9329:
9330: public static ExpressionEvaluator fpuMotherboardCoprocessor;
9331: public static ExpressionEvaluator fpuOnChipFPU;
9332: public static ExpressionEvaluator fpuBox;
9333:
9334:
9335: public static EFPBox fpuCoproboard1;
9336: public static EFPBox fpuCoproboard2;
9337:
9338:
9339: public static EFPBox.EFP[] fpuFPn;
9340:
9341:
9342:
9343: public static final int FPU_FPCR_BSUN = 0b00000000_00000000_10000000_00000000;
9344: public static final int FPU_FPCR_SNAN = 0b00000000_00000000_01000000_00000000;
9345: public static final int FPU_FPCR_OPERR = 0b00000000_00000000_00100000_00000000;
9346: public static final int FPU_FPCR_OVFL = 0b00000000_00000000_00010000_00000000;
9347: public static final int FPU_FPCR_UNFL = 0b00000000_00000000_00001000_00000000;
9348: public static final int FPU_FPCR_DZ = 0b00000000_00000000_00000100_00000000;
9349: public static final int FPU_FPCR_INEX2 = 0b00000000_00000000_00000010_00000000;
9350: public static final int FPU_FPCR_INEX1 = 0b00000000_00000000_00000001_00000000;
9351:
9352:
9353: public static final int FPU_FPCR_PE = 0b00000000_00000000_00000000_00000000;
9354: public static final int FPU_FPCR_PS = 0b00000000_00000000_00000000_01000000;
9355: public static final int FPU_FPCR_PD = 0b00000000_00000000_00000000_10000000;
9356:
9357: public static final int FPU_FPCR_RN = 0b00000000_00000000_00000000_00000000;
9358: public static final int FPU_FPCR_RZ = 0b00000000_00000000_00000000_00010000;
9359: public static final int FPU_FPCR_RM = 0b00000000_00000000_00000000_00100000;
9360: public static final int FPU_FPCR_RP = 0b00000000_00000000_00000000_00110000;
9361:
9362:
9363:
9364: public static final int FPU_FPSR_N = 0b00001000_00000000_00000000_00000000;
9365: public static final int FPU_FPSR_Z = 0b00000100_00000000_00000000_00000000;
9366: public static final int FPU_FPSR_I = 0b00000010_00000000_00000000_00000000;
9367: public static final int FPU_FPSR_NAN = 0b00000001_00000000_00000000_00000000;
9368:
9369: public static final int FPU_FPSR_S = 0b00000000_10000000_00000000_00000000;
9370: public static final int FPU_FPSR_QUOTIENT = 0b00000000_01111111_00000000_00000000;
9371:
9372: public static final int FPU_FPSR_EXC_BSUN = 0b00000000_00000000_10000000_00000000;
9373: public static final int FPU_FPSR_EXC_SNAN = 0b00000000_00000000_01000000_00000000;
9374: public static final int FPU_FPSR_EXC_OPERR = 0b00000000_00000000_00100000_00000000;
9375: public static final int FPU_FPSR_EXC_OVFL = 0b00000000_00000000_00010000_00000000;
9376: public static final int FPU_FPSR_EXC_UNFL = 0b00000000_00000000_00001000_00000000;
9377: public static final int FPU_FPSR_EXC_DZ = 0b00000000_00000000_00000100_00000000;
9378: public static final int FPU_FPSR_EXC_INEX2 = 0b00000000_00000000_00000010_00000000;
9379: public static final int FPU_FPSR_EXC_INEX1 = 0b00000000_00000000_00000001_00000000;
9380:
9381: public static final int FPU_FPSR_AEXC_IOP = 0b00000000_00000000_00000000_10000000;
9382: public static final int FPU_FPSR_AEXC_OVFL = 0b00000000_00000000_00000000_01000000;
9383: public static final int FPU_FPSR_AEXC_UNFL = 0b00000000_00000000_00000000_00100000;
9384: public static final int FPU_FPSR_AEXC_DZ = 0b00000000_00000000_00000000_00010000;
9385: public static final int FPU_FPSR_AEXC_INEX = 0b00000000_00000000_00000000_00001000;
9386:
9387:
9388:
9389:
9390:
9391:
9392:
9393: public static final int[] FPU_FPSR_EXC_TO_AEXC = new int[256];
9394:
9395:
9396:
9397:
9398:
9399:
9400:
9401:
9402:
9403:
9404:
9405:
9406:
9407:
9408:
9409:
9410:
9411:
9412:
9413:
9414:
9415:
9416:
9417:
9418: public static final boolean[] FPU_CCMAP_882 = {
9419:
9420:
9421: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9422: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9423: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9424: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9425: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9426: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9427: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9428: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9429: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9430: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9431: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9432: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9433: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9434: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9435: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9436: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9437:
9438:
9439: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9440: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9441: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9442: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9443: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9444: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9445: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9446: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9447: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9448: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9449: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9450: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9451: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9452: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9453: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9454: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9455:
9456: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9457: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9458: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9459: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9460: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9461: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9462: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9463: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9464: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9465: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9466: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9467: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9468: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9469: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9470: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9471: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9472:
9473: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9474: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9475: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9476: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9477: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9478: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9479: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9480: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9481: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9482: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9483: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9484: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9485: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9486: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9487: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9488: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9489: };
9490:
9491:
9492:
9493:
9494:
9495:
9496:
9497: public static final boolean[] FPU_CCMAP_060 = {
9498:
9499:
9500: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9501: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9502: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9503: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9504: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9505: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9506: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9507: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9508: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9509: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9510: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9511: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9512: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9513: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9514: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9515: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9516:
9517:
9518: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9519: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9520: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9521: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9522: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9523: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9524: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9525: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9526: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9527: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9528: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9529: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9530: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9531: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9532: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9533: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9534:
9535: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9536: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9537: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9538: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9539: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9540: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9541: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9542: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9543: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9544: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9545: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9546: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9547: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9548: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9549: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9550: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9551:
9552: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9553: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9554: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9555: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9556: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9557: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9558: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9559: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9560: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9561: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9562: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9563: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9564: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9565: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9566: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9567: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9568: };
9569:
9570:
9571:
9572:
9573: public static void fpuInit () {
9574: for (int i = 0; i < 256; i++) {
9575: 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) |
9576: ((i << 8 & FPU_FPSR_EXC_OVFL) != 0 ? FPU_FPSR_AEXC_OVFL : 0) |
9577: ((i << 8 & (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2)) == (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2) ? FPU_FPSR_AEXC_UNFL : 0) |
9578: ((i << 8 & FPU_FPSR_EXC_DZ) != 0 ? FPU_FPSR_AEXC_DZ : 0) |
9579: ((i << 8 & (FPU_FPSR_EXC_OVFL | FPU_FPSR_EXC_INEX2 | FPU_FPSR_EXC_INEX1)) != 0 ? FPU_FPSR_AEXC_INEX : 0));
9580: }
9581:
9582: fpuMotherboardCoprocessor = new ExpressionEvaluator ();
9583:
9584: fpuOnChipFPU = new ExpressionEvaluator ();
9585:
9586: fpuBox = currentMPU < Model.MPU_MC68LC040 ? fpuMotherboardCoprocessor : fpuOnChipFPU;
9587:
9588: fpuFPn = fpuBox.epbFPn;
9589:
9590: fpuCoproboard1 = new EFPBox ();
9591: fpuCoproboard2 = new EFPBox ();
9592: }
9593:
9594:
9595:
9596:
9597:
9598:
9599: public static final boolean DBG_ORI_BYTE_ZERO_D0 = true;
9600:
9601: public static boolean dbgHexSelected;
9602: public static int dbgHexValue;
9603: public static int dbgSupervisorMode;
9604: public static JPopupMenu dbgPopupMenu;
9605: public static JMenu dbgPopupIBPMenu;
9606: public static SpinnerNumberModel dbgPopupIBPCurrentModel;
9607: public static int dbgPopupIBPCurrentValue;
9608: public static SpinnerNumberModel dbgPopupIBPThresholdModel;
9609: public static int dbgPopupIBPThresholdValue;
9610: public static JMenuItem dbgPopupIBPClearMenuItem;
9611: public static JMenu dbgPopupHexMenu;
9612: public static JMenuItem dbgPopupDisMenuItem;
9613: public static JMenuItem dbgPopupMemMenuItem;
9614: public static JMenuItem dbgPopupCopyMenuItem;
9615: public static JMenuItem dbgPopupSelectAllMenuItem;
9616: public static JTextArea dbgPopupTextArea;
9617: public static int dbgEventMask;
9618: public static boolean dbgStopOnError;
9619: public static boolean dbgOriByteZeroD0;
9620: public static boolean dbgStopAtStart;
9621:
9622:
9623:
9624: public static final char[] DBG_SPACES = (
9625:
9626:
9627: " ").toCharArray ();
9628:
9629: public static final int DBG_DRP_VISIBLE_MASK = 1;
9630: public static final int DBG_DDP_VISIBLE_MASK = 2;
9631: public static final int DBG_DMP_VISIBLE_MASK = 4;
9632: public static final int DBG_BLG_VISIBLE_MASK = 8;
9633: public static final int DBG_PFV_VISIBLE_MASK = 16;
9634: public static final int DBG_RBP_VISIBLE_MASK = 32;
9635: public static final int DBG_DBP_VISIBLE_MASK = 64;
9636: public static final int DBG_SMT_VISIBLE_MASK = 128;
9637: public static final int DBG_ATW_VISIBLE_MASK = 256;
9638: public static final int DBG_PAA_VISIBLE_MASK = 512;
9639: public static final int DBG_RTL_VISIBLE_MASK = 1024;
9640: public static final int DBG_SPV_VISIBLE_MASK = 2048;
9641: public static final int DBG_ACM_VISIBLE_MASK = 4096;
9642: public static int dbgVisibleMask;
9643:
9644:
9645:
9646: public static void dbgInit () {
9647: dbgVisibleMask = 0;
9648: dbgHexSelected = false;
9649: dbgHexValue = 0;
9650: dbgSupervisorMode = 1;
9651: dbgPopupMenu = null;
9652: dbgPopupDisMenuItem = null;
9653: dbgPopupMemMenuItem = null;
9654: dbgPopupCopyMenuItem = null;
9655: dbgPopupSelectAllMenuItem = null;
9656: dbgPopupIBPMenu = null;
9657: dbgPopupIBPCurrentModel = null;
9658: dbgPopupIBPCurrentValue = 0;
9659: dbgPopupIBPThresholdModel = null;
9660: dbgPopupIBPThresholdValue = 0;
9661: dbgPopupHexMenu = null;
9662: dbgPopupTextArea = null;
9663: dbgEventMask = 0;
9664: dbgStopOnError = false;
9665: if (DBG_ORI_BYTE_ZERO_D0) {
9666: dbgOriByteZeroD0 = false;
9667: }
9668: dbgStopAtStart = false;
9669: }
9670:
9671:
9672:
9673: public static void dbgMakePopup () {
9674:
9675:
9676: ActionListener popupActionListener = new ActionListener () {
9677: @Override public void actionPerformed (ActionEvent ae) {
9678: switch (ae.getActionCommand ()) {
9679: case "Disassemble":
9680: DisassembleList.ddpBacktraceRecord = -1L;
9681: DisassembleList.ddpOpen (dbgHexValue, dbgSupervisorMode, false);
9682: break;
9683: case "Memory Dump":
9684: MemoryDumpList.dmpOpen (dbgHexValue, dbgSupervisorMode != 0 ? 5 : 1, false);
9685: break;
9686: case "Run to Here":
9687: if (InstructionBreakPoint.IBP_ON) {
9688: if (mpuTask == null) {
9689: InstructionBreakPoint.ibpInstant (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
9690: mpuStart ();
9691: }
9692: }
9693: break;
9694: case "Set Breakpoint":
9695: if (InstructionBreakPoint.IBP_ON) {
9696: InstructionBreakPoint.ibpPut (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode, dbgPopupIBPCurrentValue, dbgPopupIBPThresholdValue, null);
9697: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
9698: }
9699: break;
9700: case "Clear Breakpoint":
9701: if (InstructionBreakPoint.IBP_ON) {
9702: InstructionBreakPoint.ibpRemove (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
9703: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
9704: }
9705: break;
9706: case "Copy":
9707: dbgCopy ();
9708: break;
9709: case "Select All":
9710: dbgSelectAll ();
9711: break;
9712: }
9713: }
9714: };
9715: dbgPopupMenu = ComponentFactory.createPopupMenu (
9716: dbgPopupIBPMenu =
9717: InstructionBreakPoint.IBP_ON ?
9718: ComponentFactory.createMenu (
9719: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
9720: Multilingual.mlnText (ComponentFactory.createMenuItem ("Run to Here", 'R', popupActionListener), "ja", "ここまで実行"),
9721: ComponentFactory.createHorizontalSeparator (),
9722: Multilingual.mlnText (ComponentFactory.createMenuItem ("Set Breakpoint", 'S', popupActionListener), "ja", "ブレークポイントを設定"),
9723: ComponentFactory.createHorizontalBox (
9724: Box.createHorizontalStrut (7),
9725: Box.createHorizontalGlue (),
9726: ComponentFactory.setPreferredSize (
9727: Multilingual.mlnText (ComponentFactory.createLabel ("current"), "ja", "現在値"),
9728: 60, 16),
9729: ComponentFactory.createNumberSpinner (dbgPopupIBPCurrentModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
9730: @Override public void stateChanged (ChangeEvent ce) {
9731: dbgPopupIBPCurrentValue = dbgPopupIBPCurrentModel.getNumber ().intValue ();
9732: }
9733: }),
9734: Box.createHorizontalGlue ()
9735: ),
9736: ComponentFactory.createHorizontalBox (
9737: Box.createHorizontalStrut (7),
9738: Box.createHorizontalGlue (),
9739: ComponentFactory.setPreferredSize (
9740: Multilingual.mlnText (ComponentFactory.createLabel ("threshold"), "ja", "閾値"),
9741: 60, 16),
9742: ComponentFactory.createNumberSpinner (dbgPopupIBPThresholdModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
9743: @Override public void stateChanged (ChangeEvent ce) {
9744: dbgPopupIBPThresholdValue = dbgPopupIBPThresholdModel.getNumber ().intValue ();
9745: }
9746: }),
9747: Box.createHorizontalGlue ()
9748: ),
9749: dbgPopupIBPClearMenuItem =
9750: Multilingual.mlnText (ComponentFactory.createMenuItem ("Clear Breakpoint", 'C', popupActionListener), "ja", "ブレークポイントを消去")
9751: ) :
9752: null,
9753: dbgPopupHexMenu =
9754: ComponentFactory.createMenu (
9755: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
9756: dbgPopupDisMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble", 'D', popupActionListener), "ja", "逆アセンブル"),
9757: dbgPopupMemMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory Dump", 'M', popupActionListener), "ja", "メモリダンプ")
9758: ),
9759: dbgPopupCopyMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Copy", 'C', popupActionListener), "ja", "コピー"),
9760: dbgPopupSelectAllMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Select All", 'A', popupActionListener), "ja", "すべて選択")
9761: );
9762:
9763: }
9764:
9765:
9766:
9767: public static void dbgShowPopup (MouseEvent me, JTextArea textArea, boolean dis) {
9768: dbgEventMask++;
9769: int x = me.getX ();
9770: int y = me.getY ();
9771:
9772: int p = textArea.viewToModel2D (me.getPoint ());
9773: DisassembleList.ddpPopupAddress = -1;
9774: if (dis) {
9775: int i = Arrays.binarySearch (DisassembleList.ddpSplitArray, 1, DisassembleList.ddpItemCount, p + 1);
9776: i = (i >> 31 ^ i) - 1;
9777: DisassembleList.ddpPopupAddress = DisassembleList.ddpAddressArray[i];
9778: }
9779: int start = textArea.getSelectionStart ();
9780: int end = textArea.getSelectionEnd ();
9781: String text = textArea.getText ();
9782: int length = text.length ();
9783: if ((start == end ||
9784: p < start || end <= p) &&
9785: 0 <= p && p < length && isWord (text.charAt (p))) {
9786:
9787: for (start = p; 0 < start && isWord (text.charAt (start - 1)); start--) {
9788: }
9789: for (end = p + 1; end < length && isWord (text.charAt (end)); end++) {
9790: }
9791: textArea.select (start, end);
9792: }
9793: dbgHexSelected = false;
9794: if (start < end) {
9795: textArea.requestFocusInWindow ();
9796:
9797:
9798:
9799:
9800:
9801: dbgHexValue = 0;
9802: int n = 0;
9803: for (int i = start; i < end; i++) {
9804: int t;
9805: if ((t = Character.digit (text.charAt (i), 16)) >= 0) {
9806: dbgHexValue = dbgHexValue << 4 | t;
9807: if (n >= 8 ||
9808: i + 1 >= end || (t = Character.digit (text.charAt (i + 1), 16)) < 0) {
9809: n = 0;
9810: break;
9811: }
9812: dbgHexValue = dbgHexValue << 4 | t;
9813: n += 2;
9814: i++;
9815: } else if (isWord (text.charAt (i))) {
9816: n = 0;
9817: break;
9818: }
9819: }
9820: dbgHexSelected = n > 0;
9821: try {
9822:
9823: Rectangle r = textArea.modelToView2D (start).getBounds ();
9824:
9825: Rectangle s = textArea.modelToView2D (end - 1).getBounds ();
9826: if (r.y == s.y) {
9827:
9828: y = r.y + r.height;
9829: }
9830: } catch (BadLocationException ble) {
9831: }
9832: }
9833:
9834: if (InstructionBreakPoint.IBP_ON) {
9835: if (dis && mpuTask == null && DisassembleList.ddpPopupAddress != -1) {
9836: ComponentFactory.setText (dbgPopupIBPMenu, fmtHex8 (DisassembleList.ddpPopupAddress));
9837: TreeMap<Integer,InstructionBreakPoint.InstructionBreakRecord> pointTable = InstructionBreakPoint.ibpPointTable;
9838: InstructionBreakPoint.InstructionBreakRecord r = pointTable.get (DisassembleList.ddpPopupAddress);
9839: if (r != null) {
9840: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = r.ibrValue));
9841: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = r.ibrThreshold));
9842: dbgPopupIBPClearMenuItem.setEnabled (true);
9843: } else {
9844: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = 0));
9845: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = 0));
9846: dbgPopupIBPClearMenuItem.setEnabled (false);
9847: }
9848: ComponentFactory.setVisible (dbgPopupIBPMenu, true);
9849: } else {
9850: ComponentFactory.setVisible (dbgPopupIBPMenu, false);
9851: }
9852: }
9853:
9854: if (dbgHexSelected) {
9855: ComponentFactory.setText (dbgPopupHexMenu, fmtHex8 (dbgHexValue));
9856: ComponentFactory.setVisible (dbgPopupHexMenu, true);
9857: } else {
9858: ComponentFactory.setVisible (dbgPopupHexMenu, false);
9859: }
9860:
9861: ComponentFactory.setEnabled (dbgPopupCopyMenuItem, clpClipboard != null && start < end);
9862:
9863: ComponentFactory.setEnabled (dbgPopupSelectAllMenuItem, clpClipboard != null);
9864:
9865: dbgPopupTextArea = textArea;
9866: dbgPopupMenu.show (textArea, x, y);
9867: dbgEventMask--;
9868: }
9869:
9870: public static boolean isWord (char c) {
9871: return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '_';
9872: }
9873:
9874:
9875:
9876: public static void dbgCopy () {
9877: clpCopy (dbgPopupTextArea.getSelectedText ());
9878: }
9879:
9880:
9881:
9882: public static void dbgSelectAll () {
9883: if (clpClipboard != null) {
9884:
9885: dbgEventMask++;
9886: dbgPopupTextArea.selectAll ();
9887: dbgPopupTextArea.requestFocusInWindow ();
9888: dbgEventMask--;
9889: }
9890: }
9891:
9892:
9893:
9894:
9895: public static void dbgUpdate () {
9896: if ((dbgVisibleMask & DBG_DRP_VISIBLE_MASK) != 0) {
9897: RegisterList.drpUpdate ();
9898: }
9899: if (ProgramFlowVisualizer.PFV_ON) {
9900: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
9901: if (ProgramFlowVisualizer.pfvTimer == 0) {
9902: ProgramFlowVisualizer.pfvUpdate ();
9903: } else {
9904: ProgramFlowVisualizer.pfvTimer--;
9905: }
9906: }
9907: }
9908: if (RasterBreakPoint.RBP_ON) {
9909: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
9910: if (RasterBreakPoint.rbpTimer == 0) {
9911: RasterBreakPoint.rbpUpdateFrame ();
9912: } else {
9913: RasterBreakPoint.rbpTimer--;
9914: }
9915: }
9916: }
9917: if (ScreenModeTest.SMT_ON) {
9918: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
9919: if (ScreenModeTest.smtTimer == 0) {
9920: ScreenModeTest.smtUpdateFrame ();
9921: } else {
9922: ScreenModeTest.smtTimer--;
9923: }
9924: }
9925: }
9926: if (RootPointerList.RTL_ON) {
9927: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
9928: if (RootPointerList.rtlTimer == 0) {
9929: RootPointerList.rtlTimer = RootPointerList.RTL_INTERVAL - 1;
9930: RootPointerList.rtlUpdateFrame ();
9931: } else {
9932: RootPointerList.rtlTimer--;
9933: }
9934: }
9935: }
9936: if (SpritePatternViewer.SPV_ON) {
9937: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
9938: if (SpritePatternViewer.spvTimer == 0) {
9939: SpritePatternViewer.spvTimer = SpritePatternViewer.SPV_INTERVAL - 1;
9940: SpritePatternViewer.spvUpdateFrame ();
9941: } else {
9942: SpritePatternViewer.spvTimer--;
9943: }
9944: }
9945: }
9946: if (ATCMonitor.ACM_ON) {
9947: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
9948: if (ATCMonitor.acmTimer == 0) {
9949: ATCMonitor.acmTimer = ATCMonitor.ACM_INTERVAL - 1;
9950: ATCMonitor.acmUpdateFrame ();
9951: } else {
9952: ATCMonitor.acmTimer--;
9953: }
9954: }
9955: }
9956: }
9957:
9958:
9959:
9960:
9961:
9962:
9963:
9964:
9965:
9966:
9967:
9968:
9969:
9970:
9971:
9972:
9973:
9974:
9975:
9976:
9977:
9978:
9979: public static boolean dbgDoStopOnError () {
9980: if (MainMemory.mmrHumanVersion <= 0) {
9981: return true;
9982: }
9983: if ((regOC & 0xff00) == 0xff00 &&
9984: M68kException.m6eNumber == M68kException.M6E_PRIVILEGE_VIOLATION) {
9985: return false;
9986: }
9987: String message = (
9988: M68kException.m6eNumber < 0 ?
9989: fmtHex8 (new StringBuilder ("breaked").append (" at "), regPC0).toString () :
9990: M68kException.m6eNumber <= M68kException.M6E_ADDRESS_ERROR ?
9991: fmtHex8 (fmtHex8 (new StringBuilder ("ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
9992: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
9993: .append (" at "), regPC0).toString () :
9994: fmtHex8 (new StringBuilder (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
9995: .append (" at "), regPC0).toString ()
9996: );
9997: System.out.println (message);
9998: if (!(M68kException.m6eNumber == M68kException.M6E_ACCESS_FAULT &&
9999: 0x0000e100 <= regPC0 && regPC0 < 0x0000e500)) {
10000: mpuStop (message);
10001: return true;
10002: }
10003: return false;
10004: }
10005:
10006:
10007:
10008: public static void dbgDoubleBusFault () {
10009: String message =
10010: fmtHex8 (fmtHex8 (new StringBuilder ("FATAL ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10011: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10012: .append (" at "), regPC0).toString ();
10013: System.out.println (message);
10014: mpuStop (message);
10015: }
10016:
10017:
10018:
10019:
10020:
10021:
10022: public static final HashMap<String,byte[]> rscResourceCache = new HashMap<String,byte[]> ();
10023:
10024:
10025:
10026:
10027:
10028:
10029: public static byte[] rscGetResource (String name, int... sizes) {
10030: byte[] array = rscResourceCache.get (name);
10031: if (array != null) {
10032: return array;
10033: }
10034: array = new byte[1024 * 64];
10035: int size = 0;
10036: try (BufferedInputStream bis = new BufferedInputStream (XEiJ.class.getResourceAsStream ("../data/" + name))) {
10037: for (;;) {
10038: if (size == array.length) {
10039: byte[] newArray = new byte[array.length * 2];
10040: System.arraycopy (array, 0, newArray, 0, size);
10041: array = newArray;
10042: }
10043: int step = bis.read (array, size, array.length - size);
10044: if (step == -1) {
10045: break;
10046: }
10047: size += step;
10048: }
10049: if (size < array.length) {
10050: byte[] newArray = new byte[size];
10051: System.arraycopy (array, 0, newArray, 0, size);
10052: array = newArray;
10053: }
10054: boolean fit = sizes.length == 0;
10055: if (!fit) {
10056: for (int i = 0; i < sizes.length; i++) {
10057: if (size == sizes[i]) {
10058: fit = true;
10059: break;
10060: }
10061: }
10062: }
10063: if (fit) {
10064: System.out.println (Multilingual.mlnJapanese ?
10065: name + " を読み込みました" :
10066: name + " was read");
10067: rscResourceCache.put (name, array);
10068: return array;
10069: }
10070: System.out.println (Multilingual.mlnJapanese ?
10071: name + " のサイズが違います" :
10072: name + " has wrong size");
10073: return null;
10074: } catch (IOException ioe) {
10075: }
10076:
10077: System.out.println (Multilingual.mlnJapanese ?
10078: name + " を読み込めません" :
10079: name + " cannot be read");
10080: return null;
10081: }
10082:
10083:
10084:
10085: public static String rscGetResourceText (String name) {
10086: return rscGetResourceText (name, "UTF-8");
10087: }
10088: public static String rscGetResourceText (String name, String charset) {
10089: byte[] array = rscGetResource (name);
10090: if (name != null) {
10091: try {
10092: return new String (array, charset);
10093: } catch (UnsupportedEncodingException uee) {
10094: }
10095: }
10096: return "";
10097: }
10098:
10099: public static final Pattern RSC_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10100: public static String rscLastFileName = null;
10101:
10102:
10103:
10104:
10105:
10106:
10107: public static byte[] rscGetFile (String names, int... sizes) {
10108: for (String name : names.split (",")) {
10109: name = name.trim ();
10110: if (name.length () == 0 || name.equalsIgnoreCase ("none")) {
10111: continue;
10112: }
10113: String[] zipSplittedName = RSC_ZIP_SEPARATOR.split (name, 2);
10114: InputStream is = null;
10115: if (zipSplittedName.length < 2) {
10116: File file = new File (name);
10117: if (file.isFile ()) {
10118: try {
10119: is = new FileInputStream (file);
10120: } catch (IOException ioe) {
10121: }
10122: } else {
10123: System.out.println (Multilingual.mlnJapanese ?
10124: name + " がありません" :
10125: name + " does not exist");
10126: continue;
10127: }
10128: } else {
10129: String zipName = zipSplittedName[0];
10130: String entryName = zipSplittedName[1];
10131: if (new File (zipName).isFile ()) {
10132: try {
10133: ZipFile zipFile = new ZipFile (zipName);
10134: ZipEntry zipEntry = zipFile.getEntry (entryName);
10135: if (zipEntry != null) {
10136: is = zipFile.getInputStream (zipEntry);
10137: } else {
10138: System.out.println (Multilingual.mlnJapanese ?
10139: zipName + " に " + zipEntry + " がありません" :
10140: zipName + " does not include " + zipEntry);
10141: }
10142: } catch (IOException ioe) {
10143: }
10144: } else {
10145: System.out.println (Multilingual.mlnJapanese ?
10146: zipName + " がありません" :
10147: zipName + " does not exist");
10148: continue;
10149: }
10150: }
10151: if (is != null) {
10152: try {
10153: is = new BufferedInputStream (is);
10154: if (name.toLowerCase ().endsWith (".gz")) {
10155: is = new GZIPInputStream (is);
10156: }
10157: byte[] array = new byte[1024 * 64];
10158: int size = 0;
10159: for (;;) {
10160: if (size == array.length) {
10161: byte[] newArray = new byte[array.length * 2];
10162: System.arraycopy (array, 0, newArray, 0, size);
10163: array = newArray;
10164: }
10165: int step = is.read (array, size, array.length - size);
10166: if (step == -1) {
10167: break;
10168: }
10169: size += step;
10170: }
10171: is.close ();
10172: is = null;
10173: if (size < array.length) {
10174: byte[] newArray = new byte[size];
10175: System.arraycopy (array, 0, newArray, 0, size);
10176: array = newArray;
10177: }
10178: boolean fit = sizes.length == 0;
10179: if (!fit) {
10180: for (int i = 0; i < sizes.length; i++) {
10181: if (size == sizes[i]) {
10182: fit = true;
10183: break;
10184: }
10185: }
10186: }
10187: if (fit) {
10188: System.out.println (Multilingual.mlnJapanese ?
10189: name + " を読み込みました" :
10190: name + " was read");
10191: rscLastFileName = name;
10192: return array;
10193: }
10194: System.out.println (Multilingual.mlnJapanese ?
10195: name + " のサイズが違います" :
10196: name + " has wrong size");
10197: continue;
10198: } catch (IOException ioe) {
10199: }
10200: if (is != null) {
10201: try {
10202: is.close ();
10203: is = null;
10204: } catch (IOException ioe) {
10205: }
10206: }
10207: }
10208: System.out.println (Multilingual.mlnJapanese ?
10209: name + " を読み込めません" :
10210: name + " cannot be read");
10211: }
10212:
10213:
10214:
10215: return null;
10216: }
10217:
10218:
10219:
10220:
10221: public static String rscGetTextFile (String name) {
10222: return rscGetTextFile (name, "UTF-8");
10223: }
10224: public static String rscGetTextFile (String name, String charset) {
10225: byte[] array = rscGetFile (name);
10226: if (array != null) {
10227: try {
10228: return new String (array, charset);
10229: } catch (UnsupportedEncodingException uee) {
10230: }
10231: }
10232: return "";
10233: }
10234:
10235:
10236:
10237: public static final int RSC_A_MASK = 1;
10238: public static final int RSC_R_MASK = 2;
10239: public static final int RSC_I_MASK = 4;
10240: public static final String RSC_A_EN = "Abort";
10241: public static final String RSC_R_EN = "Retry";
10242: public static final String RSC_I_EN = "Ignore";
10243: public static final String RSC_A_JA = "中止";
10244: public static final String RSC_R_JA = "再実行";
10245: public static final String RSC_I_JA = "無視";
10246: public static final String[][] RSC_EN_OPTIONS = {
10247: { RSC_A_EN },
10248: { RSC_A_EN },
10249: { RSC_R_EN },
10250: { RSC_A_EN, RSC_R_EN },
10251: { RSC_I_EN },
10252: { RSC_A_EN, RSC_I_EN },
10253: { RSC_R_EN, RSC_I_EN },
10254: { RSC_A_EN, RSC_R_EN, RSC_I_EN },
10255: };
10256: public static final String[][] RSC_JA_OPTIONS = {
10257: { RSC_A_JA },
10258: { RSC_A_JA },
10259: { RSC_R_JA },
10260: { RSC_A_JA, RSC_R_JA },
10261: { RSC_I_JA },
10262: { RSC_A_JA, RSC_I_JA },
10263: { RSC_R_JA, RSC_I_JA },
10264: { RSC_A_JA, RSC_R_JA, RSC_I_JA },
10265: };
10266: public static int rscShowError (String message, int mask) {
10267: System.out.println (message);
10268: mask &= RSC_A_MASK | RSC_R_MASK | RSC_I_MASK;
10269: if (mask == 0) {
10270: mask = RSC_A_MASK;
10271: }
10272: String[] options = (Multilingual.mlnJapanese ? RSC_JA_OPTIONS : RSC_EN_OPTIONS)[mask];
10273: int def = Integer.numberOfTrailingZeros (mask);
10274: pnlExitFullScreen (true);
10275: int bit = JOptionPane.showOptionDialog (
10276: null,
10277: message,
10278: Multilingual.mlnJapanese ? "ファイル操作エラー" : "File operation error",
10279: JOptionPane.YES_NO_CANCEL_OPTION,
10280: JOptionPane.ERROR_MESSAGE,
10281: null,
10282: options,
10283: options[def]);
10284: if (bit == JOptionPane.CLOSED_OPTION) {
10285: bit = def;
10286: }
10287: return 1 << bit;
10288: }
10289:
10290:
10291:
10292:
10293:
10294:
10295: public static boolean rscPutTextFile (String name, String string) {
10296: return rscPutTextFile (name, string, "UTF-8");
10297: }
10298: public static boolean rscPutTextFile (String name, ArrayList<String> strings) {
10299: return rscPutTextFile (name, strings, "UTF-8");
10300: }
10301: public static boolean rscPutTextFile (String name, String string, String charset) {
10302: ArrayList<String> strings = new ArrayList<String> ();
10303: strings.add (string);
10304: return rscPutTextFile (name, strings, charset);
10305: }
10306: public static boolean rscPutTextFile (String name, ArrayList<String> strings, String charset) {
10307: String nameTmp = name + ".tmp";
10308: String nameBak = name + ".bak";
10309: File file = new File (name);
10310: File fileTmp = new File (nameTmp);
10311: File fileBak = new File (nameBak);
10312:
10313: File parentDirectory = file.getParentFile ();
10314: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10315: if (!parentDirectory.mkdirs ()) {
10316: System.out.println (parentDirectory.getPath () + (Multilingual.mlnJapanese ? " を作れません" : " cannot be created"));
10317: return false;
10318: }
10319: }
10320:
10321: if (fileTmp.exists ()) {
10322: if (!fileTmp.delete ()) {
10323: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10324: return false;
10325: }
10326: }
10327:
10328: try (BufferedWriter bw = new BufferedWriter (new FileWriter (nameTmp, Charset.forName (charset)))) {
10329: for (String string : strings) {
10330: bw.write (string);
10331: }
10332: } catch (IOException ioe) {
10333: ioe.printStackTrace ();
10334: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " に書き出せません" : " cannot be written"));
10335: return false;
10336: }
10337:
10338: boolean fileExists = file.exists ();
10339: if (fileExists) {
10340:
10341: if (fileBak.exists ()) {
10342: if (!fileBak.delete ()) {
10343: System.out.println (nameBak + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10344: return false;
10345: }
10346: }
10347:
10348: if (!file.renameTo (fileBak)) {
10349: System.out.println (name + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + nameBak + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10350: return false;
10351: }
10352: }
10353:
10354: if (!fileTmp.renameTo (file)) {
10355: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + name + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10356: return false;
10357: }
10358: if (fileExists) {
10359: System.out.println (name + (Multilingual.mlnJapanese ? " を更新しました" : " was updated"));
10360: } else {
10361: System.out.println (name + (Multilingual.mlnJapanese ? " を作りました" : " was created"));
10362: }
10363: return true;
10364: }
10365:
10366:
10367:
10368:
10369:
10370:
10371:
10372:
10373:
10374: public static boolean rscPutFile (String name, byte[] array) {
10375: return rscPutFile (name, array, 0, array.length, (long) array.length);
10376: }
10377: public static boolean rscPutFile (String name, byte[] array, int offset, int length) {
10378: return rscPutFile (name, array, offset, length, (long) length);
10379: }
10380: public static boolean rscPutFile (String name, byte[] array, int offset, int length, long longLength2) {
10381: if (RSC_ZIP_SEPARATOR.matcher (name).matches ()) {
10382:
10383: return false;
10384: }
10385: File file = new File (name);
10386: boolean fileExists = file.isFile ();
10387: if (fileExists && file.length () == longLength2) {
10388: comparison:
10389: {
10390: try (BufferedInputStream bis = new BufferedInputStream (new FileInputStream (file))) {
10391: byte[] buffer = new byte[(int) Math.min (Math.max ((long) length, longLength2 - (long) length), (long) (1024 * 1024))];
10392: int position = 0;
10393: while (position < length) {
10394: int step = bis.read (buffer, 0, Math.min (buffer.length, length - position));
10395: if (step == -1) {
10396: break comparison;
10397: }
10398: int offsetPosition = offset + position;
10399: for (int i = 0; i < step; i++) {
10400: if (buffer[i] != array[offsetPosition + i]) {
10401: break comparison;
10402: }
10403: }
10404: position += step;
10405: }
10406: long longPosition2 = (long) length;
10407: while (longPosition2 < longLength2) {
10408: int step = bis.read (buffer, 0, (int) Math.min ((long) buffer.length, longLength2 - longPosition2));
10409: if (step == -1) {
10410: break comparison;
10411: }
10412: for (int i = 0; i < step; i++) {
10413: if (buffer[i] != 0) {
10414: break comparison;
10415: }
10416: }
10417: longPosition2 += (long) step;
10418: }
10419: return true;
10420: } catch (IOException ioe) {
10421: }
10422: }
10423: }
10424: String nameTmp = name + ".tmp";
10425: File fileTmp = new File (nameTmp);
10426: String nameBak = name + ".bak";
10427: File fileBak = new File (nameBak);
10428: retry:
10429: for (;;) {
10430: File parentDirectory = file.getParentFile ();
10431: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10432: String parentName = parentDirectory.getPath ();
10433: if (parentDirectory.mkdirs ()) {
10434: System.out.println (Multilingual.mlnJapanese ?
10435: parentName + " を作りました" :
10436: parentName + " was created");
10437: } else {
10438: switch (rscShowError (Multilingual.mlnJapanese ?
10439: parentName + " を作れません" :
10440: parentName + " cannot be created",
10441: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10442: case RSC_A_MASK:
10443: break retry;
10444: case RSC_R_MASK:
10445: continue retry;
10446: }
10447: }
10448: }
10449: if (fileTmp.isFile ()) {
10450: if (!fileTmp.delete ()) {
10451: switch (rscShowError (Multilingual.mlnJapanese ?
10452: nameTmp + " を削除できません" :
10453: nameTmp + " cannot be deleted",
10454: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10455: case RSC_A_MASK:
10456: break retry;
10457: case RSC_R_MASK:
10458: continue retry;
10459: }
10460: }
10461: }
10462: try (OutputStream os = name.toLowerCase ().endsWith (".gz") ?
10463: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10464: {
10465:
10466: def.setLevel (Deflater.DEFAULT_COMPRESSION);
10467:
10468: }
10469: } :
10470: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10471:
10472: os.write (array, offset, length);
10473:
10474:
10475: if ((long) length < longLength2) {
10476: byte[] buffer = new byte[(int) Math.min (longLength2 - (long) length, (long) (1024 * 1024))];
10477: Arrays.fill (buffer, 0, buffer.length, (byte) 0);
10478: long longPosition2 = (long) length;
10479: while (longPosition2 < longLength2) {
10480: int step = (int) Math.min ((long) buffer.length, longLength2 - longPosition2);
10481: os.write (buffer, 0, step);
10482: longPosition2 += (long) step;
10483: }
10484: }
10485: } catch (IOException ioe) {
10486: switch (rscShowError (Multilingual.mlnJapanese ?
10487: nameTmp + " に書き出せません" :
10488: nameTmp + " cannot be written",
10489: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10490: case RSC_A_MASK:
10491: break retry;
10492: case RSC_R_MASK:
10493: continue retry;
10494: }
10495: }
10496: if (fileExists && file.isFile ()) {
10497: if (fileBak.isFile ()) {
10498: if (!fileBak.delete ()) {
10499: switch (rscShowError (Multilingual.mlnJapanese ?
10500: nameBak + " を削除できません" :
10501: nameBak + " cannot be deleted",
10502: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10503: case RSC_A_MASK:
10504: break retry;
10505: case RSC_R_MASK:
10506: continue retry;
10507: }
10508: }
10509: }
10510: if (!file.renameTo (fileBak)) {
10511: switch (rscShowError (Multilingual.mlnJapanese ?
10512: name + " を " + nameBak + " にリネームできません" :
10513: name + " cannot be renamed to " + nameBak,
10514: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10515: case RSC_A_MASK:
10516: break retry;
10517: case RSC_R_MASK:
10518: continue retry;
10519: }
10520: }
10521: }
10522: if (fileTmp.renameTo (file)) {
10523: if (fileExists) {
10524: System.out.println (Multilingual.mlnJapanese ?
10525: name + " を更新しました" :
10526: name + " was updated");
10527: } else {
10528: System.out.println (Multilingual.mlnJapanese ?
10529: name + " を作りました" :
10530: name + " was created");
10531: }
10532: return true;
10533: } else {
10534: switch (rscShowError (Multilingual.mlnJapanese ?
10535: nameTmp + " を " + name + " にリネームできません" :
10536: nameTmp + " cannot be renamed to " + name,
10537: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10538: case RSC_A_MASK:
10539: break retry;
10540: case RSC_R_MASK:
10541: continue retry;
10542: }
10543: }
10544: break;
10545: }
10546: if (fileExists) {
10547: System.out.println (Multilingual.mlnJapanese ?
10548: name + " を更新できません" :
10549: name + " cannot be updated");
10550: } else {
10551: System.out.println (Multilingual.mlnJapanese ?
10552: name + " を作れません" :
10553: name + " cannot be created");
10554: }
10555: return false;
10556: }
10557:
10558:
10559:
10560:
10561:
10562:
10563: public static final Pattern ISM_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10564:
10565:
10566:
10567:
10568:
10569:
10570:
10571:
10572:
10573:
10574:
10575: public static InputStream ismOpen (String name) {
10576: InputStream in = null;
10577: in = ismOpen (name, false);
10578: if (in == null && name.indexOf ('/') < 0 && name.indexOf ('\\') < 0) {
10579: in = ismOpen (name, true);
10580: }
10581: return in;
10582: }
10583: public static InputStream ismOpen (String name, boolean useGetResource) {
10584: boolean gzipped = name.toLowerCase ().endsWith (".gz");
10585: String[] zipSplittedName = ISM_ZIP_SEPARATOR.split (name, 2);
10586: String fileName = zipSplittedName[0];
10587: String zipEntryName = zipSplittedName.length < 2 ? null : zipSplittedName[1];
10588: InputStream in = null;
10589: try {
10590: if (useGetResource) {
10591: if (false) {
10592: URL url = XEiJ.class.getResource (fileName);
10593: if (url != null) {
10594: in = url.openStream ();
10595: }
10596: } else {
10597: in = XEiJ.class.getResourceAsStream (fileName);
10598: }
10599: } else {
10600: File file = new File (fileName);
10601: if (file.exists ()) {
10602: in = new FileInputStream (file);
10603: }
10604: }
10605: if (in != null && zipEntryName != null) {
10606: ZipInputStream zin = new ZipInputStream (in);
10607: in = null;
10608: ZipEntry entry;
10609: while ((entry = zin.getNextEntry ()) != null) {
10610: if (zipEntryName.equals (entry.getName ())) {
10611: in = zin;
10612: break;
10613: }
10614: }
10615: if (in == null) {
10616: System.out.println (Multilingual.mlnJapanese ? fileName + " の中に " + zipEntryName + " がありません" :
10617: zipEntryName + " does not exist in " + fileName);
10618: }
10619: }
10620: if (in != null && gzipped) {
10621: in = new GZIPInputStream (in);
10622: }
10623: if (in != null) {
10624: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " を読み込みます" :
10625: (useGetResource ? "Reading resource file " : "Reading file ") + name);
10626: return new BufferedInputStream (in);
10627: }
10628: } catch (Exception ioe) {
10629: if (prgVerbose) {
10630: prgPrintStackTraceOf (ioe);
10631: }
10632: }
10633: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " が見つかりません" :
10634: (useGetResource ? "Resource file " : "File ") + name + " is not found");
10635: return null;
10636: }
10637:
10638:
10639:
10640:
10641:
10642:
10643:
10644:
10645: public static int ismRead (InputStream in, byte[] bb, int o, int l) {
10646: try {
10647: int k = 0;
10648: while (k < l) {
10649: int t = in.read (bb, o + k, l - k);
10650: if (t < 0) {
10651: break;
10652: }
10653: k += t;
10654: }
10655: return k;
10656: } catch (IOException ioe) {
10657: if (prgVerbose) {
10658: prgPrintStackTraceOf (ioe);
10659: }
10660: }
10661: return -1;
10662: }
10663:
10664:
10665:
10666:
10667:
10668:
10669:
10670:
10671: public static int ismSkip (InputStream in, int l) {
10672: try {
10673: int k = 0;
10674: while (k < l) {
10675:
10676:
10677: if (in.read () < 0) {
10678: break;
10679: }
10680: k++;
10681: if (k < l) {
10682: int t = (int) in.skip ((long) (l - k));
10683: if (t < 0) {
10684: break;
10685: }
10686: k += t;
10687: }
10688: }
10689: return k;
10690: } catch (IOException ioe) {
10691: if (prgVerbose) {
10692: prgPrintStackTraceOf (ioe);
10693: }
10694: }
10695: return -1;
10696: }
10697:
10698:
10699:
10700:
10701:
10702: public static void ismClose (InputStream in) {
10703: try {
10704: if (in != null) {
10705: in.close ();
10706: }
10707: } catch (IOException ioe) {
10708: if (prgVerbose) {
10709: prgPrintStackTraceOf (ioe);
10710: }
10711: }
10712: }
10713:
10714:
10715:
10716:
10717:
10718:
10719: public static int ismLength (String name, int maxLength) {
10720: int length;
10721: InputStream in = ismOpen (name);
10722: if (in == null) {
10723: length = -1;
10724: } else {
10725: length = ismSkip (in, maxLength);
10726: ismClose (in);
10727: }
10728: return length;
10729: }
10730:
10731:
10732:
10733:
10734:
10735:
10736:
10737:
10738:
10739:
10740:
10741:
10742:
10743:
10744: public static boolean ismLoad (byte[] bb, int o, int l, String names) {
10745: for (String name : names.split (",")) {
10746: if (name.length () != 0) {
10747: InputStream in = ismOpen (name);
10748: if (in != null) {
10749: int k = ismRead (in, bb, o, l);
10750: ismClose (in);
10751: if (k == l) {
10752: return true;
10753: }
10754: }
10755: }
10756: }
10757: return false;
10758: }
10759:
10760:
10761:
10762:
10763:
10764:
10765:
10766:
10767:
10768: public static boolean ismSave (byte[] bb, int offset, long length, String path, boolean verbose) {
10769: if (ISM_ZIP_SEPARATOR.split (path, 2).length != 1) {
10770: if (verbose) {
10771: pnlExitFullScreen (true);
10772: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? path + " に書き出せません" : "Cannot write " + path);
10773: }
10774: return false;
10775: }
10776: long step = 0;
10777: byte[] zz = null;
10778: long pointer = (long) (bb.length - offset);
10779: if (pointer < length) {
10780: step = Math.min (1024L * 512, length - pointer);
10781: zz = new byte[(int) step];
10782: Arrays.fill (zz, (byte) 0);
10783: }
10784:
10785: File file = new File (path);
10786:
10787: if (step == 0 &&
10788: file.exists () && file.length () == length) {
10789:
10790: if (length == 0L) {
10791: return true;
10792: }
10793: InputStream in = ismOpen (path);
10794: if (in != null) {
10795: int l = (int) length;
10796: byte[] tt = new byte[l];
10797: int k = ismRead (in, tt, 0, l);
10798: ismClose (in);
10799: if (k == l &&
10800: Arrays.equals (tt, bb.length == l ? bb : Arrays.copyOfRange (bb, offset, offset + l))) {
10801: return true;
10802: }
10803: }
10804: }
10805:
10806: String pathTmp = path + ".tmp";
10807: String pathBak = path + ".bak";
10808: File fileTmp = new File (pathTmp);
10809: File fileBak = new File (pathBak);
10810:
10811: if (fileTmp.exists ()) {
10812: if (!fileTmp.delete ()) {
10813: if (verbose) {
10814: pnlExitFullScreen (true);
10815: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " を削除できません" : "Cannot delete " + pathTmp);
10816: }
10817: return false;
10818: }
10819: }
10820:
10821: try (OutputStream out = path.toLowerCase ().endsWith (".gz") ?
10822: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10823: {
10824:
10825: def.setLevel (Deflater.DEFAULT_COMPRESSION);
10826:
10827: }
10828: } :
10829: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10830: if (step == 0) {
10831: out.write (bb, offset, (int) length);
10832: } else {
10833: out.write (bb, offset, (int) pointer);
10834: for (; pointer < length; pointer += step) {
10835: out.write (zz, 0, (int) Math.min (step, length - pointer));
10836: }
10837: }
10838: } catch (IOException ioe) {
10839: if (verbose) {
10840: prgPrintStackTraceOf (ioe);
10841: pnlExitFullScreen (true);
10842: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " に書き出せません" : "Cannot write " + pathTmp);
10843: }
10844: return false;
10845: }
10846:
10847:
10848: if (file.exists ()) {
10849: if (fileBak.exists ()) {
10850: if (!fileBak.delete ()) {
10851: if (verbose) {
10852: pnlExitFullScreen (true);
10853: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathBak + " を削除できません" : "Cannot delete " + pathBak);
10854: }
10855: return false;
10856: }
10857: }
10858: if (!file.renameTo (fileBak)) {
10859: if (verbose) {
10860: pnlExitFullScreen (true);
10861: JOptionPane.showMessageDialog (
10862: null, Multilingual.mlnJapanese ? path + " を " + pathBak + " にリネームできません" : "Cannot rename " + path + " to " + pathBak);
10863: }
10864: return false;
10865: }
10866: }
10867:
10868:
10869: if (!fileTmp.renameTo (file)) {
10870: if (verbose) {
10871: pnlExitFullScreen (true);
10872: JOptionPane.showMessageDialog (
10873: null, Multilingual.mlnJapanese ? pathTmp + " を " + path + " にリネームできません" : "Cannot rename " + pathTmp + " to " + path);
10874: }
10875: return false;
10876: }
10877: return true;
10878: }
10879:
10880:
10881:
10882:
10883:
10884:
10885:
10886: public static final char[] FMT_TEMP = new char[32];
10887:
10888:
10889:
10890:
10891:
10892:
10893:
10894:
10895:
10896:
10897:
10898: public static final char[] FMT_AIN4_BASE = ".......*..*...**.*...*.*.**..****...*..**.*.*.****..**.****.****".toCharArray ();
10899: public static final char[] FMT_BIN4_BASE = "0000000100100011010001010110011110001001101010111100110111101111".toCharArray ();
10900:
10901:
10902:
10903:
10904:
10905:
10906:
10907:
10908: public static void fmtAin4 (char[] a, int o, int x) {
10909: a[o ] = (char) (x >> 1 & 4 ^ 46);
10910: a[o + 1] = (char) (x & 4 ^ 46);
10911: a[o + 2] = (char) (x << 1 & 4 ^ 46);
10912: a[o + 3] = (char) (x << 2 & 4 ^ 46);
10913: }
10914: public static void fmtBin4 (char[] a, int o, int x) {
10915: a[o ] = (char) (x >>> 3 & 1 | 48);
10916: a[o + 1] = (char) (x >>> 2 & 1 | 48);
10917: a[o + 2] = (char) (x >>> 1 & 1 | 48);
10918: a[o + 3] = (char) (x & 1 | 48);
10919: }
10920: public static String fmtAin4 (int x) {
10921: return String.valueOf (FMT_AIN4_BASE, (x & 15) << 2, 4);
10922: }
10923: public static String fmtBin4 (int x) {
10924: return String.valueOf (FMT_BIN4_BASE, (x & 15) << 2, 4);
10925: }
10926: public static StringBuilder fmtAin4 (StringBuilder sb, int x) {
10927: return sb.append (FMT_AIN4_BASE, (x & 15) << 2, 6);
10928: }
10929: public static StringBuilder fmtBin4 (StringBuilder sb, int x) {
10930: return sb.append (FMT_BIN4_BASE, (x & 15) << 2, 6);
10931: }
10932:
10933:
10934:
10935:
10936:
10937:
10938:
10939:
10940: public static void fmtAin6 (char[] a, int o, int x) {
10941: a[o ] = (char) (x >> 3 & 4 ^ 46);
10942: a[o + 1] = (char) (x >> 2 & 4 ^ 46);
10943: a[o + 2] = (char) (x >> 1 & 4 ^ 46);
10944: a[o + 3] = (char) (x & 4 ^ 46);
10945: a[o + 4] = (char) (x << 1 & 4 ^ 46);
10946: a[o + 5] = (char) (x << 2 & 4 ^ 46);
10947: }
10948: public static void fmtBin6 (char[] a, int o, int x) {
10949: a[o ] = (char) (x >>> 5 & 1 | 48);
10950: a[o + 1] = (char) (x >>> 4 & 1 | 48);
10951: a[o + 2] = (char) (x >>> 3 & 1 | 48);
10952: a[o + 3] = (char) (x >>> 2 & 1 | 48);
10953: a[o + 4] = (char) (x >>> 1 & 1 | 48);
10954: a[o + 5] = (char) (x & 1 | 48);
10955: }
10956: public static String fmtAin6 (int x) {
10957: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
10958: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
10959: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
10960: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
10961: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
10962: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
10963: return String.valueOf (FMT_TEMP, 0, 6);
10964: }
10965: public static String fmtBin6 (int x) {
10966: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
10967: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
10968: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
10969: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
10970: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
10971: FMT_TEMP[ 5] = (char) (x & 1 | 48);
10972: return String.valueOf (FMT_TEMP, 0, 6);
10973: }
10974: public static StringBuilder fmtAin6 (StringBuilder sb, int x) {
10975: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
10976: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
10977: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
10978: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
10979: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
10980: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
10981: return sb.append (FMT_TEMP, 0, 6);
10982: }
10983: public static StringBuilder fmtBin6 (StringBuilder sb, int x) {
10984: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
10985: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
10986: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
10987: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
10988: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
10989: FMT_TEMP[ 5] = (char) (x & 1 | 48);
10990: return sb.append (FMT_TEMP, 0, 6);
10991: }
10992:
10993:
10994:
10995:
10996:
10997:
10998:
10999:
11000: public static void fmtAin8 (char[] a, int o, int x) {
11001: a[o ] = (char) (x >> 5 & 4 ^ 46);
11002: a[o + 1] = (char) (x >> 4 & 4 ^ 46);
11003: a[o + 2] = (char) (x >> 3 & 4 ^ 46);
11004: a[o + 3] = (char) (x >> 2 & 4 ^ 46);
11005: a[o + 4] = (char) (x >> 1 & 4 ^ 46);
11006: a[o + 5] = (char) (x & 4 ^ 46);
11007: a[o + 6] = (char) (x << 1 & 4 ^ 46);
11008: a[o + 7] = (char) (x << 2 & 4 ^ 46);
11009: }
11010: public static void fmtBin8 (char[] a, int o, int x) {
11011: a[o ] = (char) (x >>> 7 & 1 | 48);
11012: a[o + 1] = (char) (x >>> 6 & 1 | 48);
11013: a[o + 2] = (char) (x >>> 5 & 1 | 48);
11014: a[o + 3] = (char) (x >>> 4 & 1 | 48);
11015: a[o + 4] = (char) (x >>> 3 & 1 | 48);
11016: a[o + 5] = (char) (x >>> 2 & 1 | 48);
11017: a[o + 6] = (char) (x >>> 1 & 1 | 48);
11018: a[o + 7] = (char) (x & 1 | 48);
11019: }
11020: public static String fmtAin8 (int x) {
11021: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11022: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11023: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11024: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11025: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11026: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11027: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11028: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11029: return String.valueOf (FMT_TEMP, 0, 8);
11030: }
11031: public static String fmtBin8 (int x) {
11032: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11033: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11034: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11035: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11036: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11037: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11038: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11039: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11040: return String.valueOf (FMT_TEMP, 0, 8);
11041: }
11042: public static StringBuilder fmtAin8 (StringBuilder sb, int x) {
11043: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11044: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11045: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11046: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11047: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11048: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11049: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11050: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11051: return sb.append (FMT_TEMP, 0, 8);
11052: }
11053: public static StringBuilder fmtBin8 (StringBuilder sb, int x) {
11054: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11055: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11056: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11057: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11058: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11059: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11060: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11061: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11062: return sb.append (FMT_TEMP, 0, 8);
11063: }
11064:
11065:
11066:
11067:
11068:
11069:
11070:
11071:
11072: public static void fmtAin12 (char[] a, int o, int x) {
11073: a[o ] = (char) (x >> 9 & 4 ^ 46);
11074: a[o + 1] = (char) (x >> 8 & 4 ^ 46);
11075: a[o + 2] = (char) (x >> 7 & 4 ^ 46);
11076: a[o + 3] = (char) (x >> 6 & 4 ^ 46);
11077: a[o + 4] = (char) (x >> 5 & 4 ^ 46);
11078: a[o + 5] = (char) (x >> 4 & 4 ^ 46);
11079: a[o + 6] = (char) (x >> 3 & 4 ^ 46);
11080: a[o + 7] = (char) (x >> 2 & 4 ^ 46);
11081: a[o + 8] = (char) (x >> 1 & 4 ^ 46);
11082: a[o + 9] = (char) (x & 4 ^ 46);
11083: a[o + 10] = (char) (x << 1 & 4 ^ 46);
11084: a[o + 11] = (char) (x << 2 & 4 ^ 46);
11085: }
11086: public static void fmtBin12 (char[] a, int o, int x) {
11087: a[o ] = (char) (x >>> 11 & 1 | 48);
11088: a[o + 1] = (char) (x >>> 10 & 1 | 48);
11089: a[o + 2] = (char) (x >>> 9 & 1 | 48);
11090: a[o + 3] = (char) (x >>> 8 & 1 | 48);
11091: a[o + 4] = (char) (x >>> 7 & 1 | 48);
11092: a[o + 5] = (char) (x >>> 6 & 1 | 48);
11093: a[o + 6] = (char) (x >>> 5 & 1 | 48);
11094: a[o + 7] = (char) (x >>> 4 & 1 | 48);
11095: a[o + 8] = (char) (x >>> 3 & 1 | 48);
11096: a[o + 9] = (char) (x >>> 2 & 1 | 48);
11097: a[o + 10] = (char) (x >>> 1 & 1 | 48);
11098: a[o + 11] = (char) (x & 1 | 48);
11099: }
11100: public static String fmtAin12 (int x) {
11101: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11102: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11103: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11104: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11105: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11106: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11107: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11108: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11109: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11110: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11111: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11112: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11113: return String.valueOf (FMT_TEMP, 0, 12);
11114: }
11115: public static String fmtBin12 (int x) {
11116: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11117: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11118: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11119: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11120: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11121: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11122: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11123: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11124: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11125: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11126: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11127: FMT_TEMP[11] = (char) (x & 1 | 48);
11128: return String.valueOf (FMT_TEMP, 0, 12);
11129: }
11130: public static StringBuilder fmtAin12 (StringBuilder sb, int x) {
11131: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11132: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11133: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11134: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11135: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11136: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11137: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11138: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11139: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11140: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11141: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11142: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11143: return sb.append (FMT_TEMP, 0, 12);
11144: }
11145: public static StringBuilder fmtBin12 (StringBuilder sb, int x) {
11146: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11147: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11148: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11149: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11150: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11151: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11152: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11153: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11154: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11155: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11156: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11157: FMT_TEMP[11] = (char) (x & 1 | 48);
11158: return sb.append (FMT_TEMP, 0, 12);
11159: }
11160:
11161:
11162:
11163:
11164:
11165:
11166:
11167:
11168: public static void fmtAin16 (char[] a, int o, int x) {
11169: a[o ] = (char) (x >> 13 & 4 ^ 46);
11170: a[o + 1] = (char) (x >> 12 & 4 ^ 46);
11171: a[o + 2] = (char) (x >> 11 & 4 ^ 46);
11172: a[o + 3] = (char) (x >> 10 & 4 ^ 46);
11173: a[o + 4] = (char) (x >> 9 & 4 ^ 46);
11174: a[o + 5] = (char) (x >> 8 & 4 ^ 46);
11175: a[o + 6] = (char) (x >> 7 & 4 ^ 46);
11176: a[o + 7] = (char) (x >> 6 & 4 ^ 46);
11177: a[o + 8] = (char) (x >> 5 & 4 ^ 46);
11178: a[o + 9] = (char) (x >> 4 & 4 ^ 46);
11179: a[o + 10] = (char) (x >> 3 & 4 ^ 46);
11180: a[o + 11] = (char) (x >> 2 & 4 ^ 46);
11181: a[o + 12] = (char) (x >> 1 & 4 ^ 46);
11182: a[o + 13] = (char) (x & 4 ^ 46);
11183: a[o + 14] = (char) (x << 1 & 4 ^ 46);
11184: a[o + 15] = (char) (x << 2 & 4 ^ 46);
11185: }
11186: public static void fmtBin16 (char[] a, int o, int x) {
11187: a[o ] = (char) (x >>> 15 & 1 | 48);
11188: a[o + 1] = (char) (x >>> 14 & 1 | 48);
11189: a[o + 2] = (char) (x >>> 13 & 1 | 48);
11190: a[o + 3] = (char) (x >>> 12 & 1 | 48);
11191: a[o + 4] = (char) (x >>> 11 & 1 | 48);
11192: a[o + 5] = (char) (x >>> 10 & 1 | 48);
11193: a[o + 6] = (char) (x >>> 9 & 1 | 48);
11194: a[o + 7] = (char) (x >>> 8 & 1 | 48);
11195: a[o + 8] = (char) (x >>> 7 & 1 | 48);
11196: a[o + 9] = (char) (x >>> 6 & 1 | 48);
11197: a[o + 10] = (char) (x >>> 5 & 1 | 48);
11198: a[o + 11] = (char) (x >>> 4 & 1 | 48);
11199: a[o + 12] = (char) (x >>> 3 & 1 | 48);
11200: a[o + 13] = (char) (x >>> 2 & 1 | 48);
11201: a[o + 14] = (char) (x >>> 1 & 1 | 48);
11202: a[o + 15] = (char) (x & 1 | 48);
11203: }
11204: public static String fmtAin16 (int x) {
11205: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11206: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11207: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11208: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11209: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11210: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11211: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11212: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11213: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11214: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11215: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11216: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11217: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11218: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11219: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11220: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11221: return String.valueOf (FMT_TEMP, 0, 16);
11222: }
11223: public static String fmtBin16 (int x) {
11224: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11225: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11226: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11227: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11228: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11229: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11230: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11231: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11232: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11233: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11234: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11235: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11236: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11237: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11238: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11239: FMT_TEMP[15] = (char) (x & 1 | 48);
11240: return String.valueOf (FMT_TEMP, 0, 16);
11241: }
11242: public static StringBuilder fmtAin16 (StringBuilder sb, int x) {
11243: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11244: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11245: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11246: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11247: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11248: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11249: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11250: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11251: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11252: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11253: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11254: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11255: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11256: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11257: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11258: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11259: return sb.append (FMT_TEMP, 0, 16);
11260: }
11261: public static StringBuilder fmtBin16 (StringBuilder sb, int x) {
11262: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11263: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11264: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11265: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11266: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11267: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11268: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11269: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11270: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11271: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11272: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11273: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11274: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11275: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11276: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11277: FMT_TEMP[15] = (char) (x & 1 | 48);
11278: return sb.append (FMT_TEMP, 0, 16);
11279: }
11280:
11281:
11282:
11283:
11284:
11285:
11286:
11287:
11288: public static void fmtAin24 (char[] a, int o, int x) {
11289: a[o ] = (char) (x >> 21 & 4 ^ 46);
11290: a[o + 1] = (char) (x >> 20 & 4 ^ 46);
11291: a[o + 2] = (char) (x >> 19 & 4 ^ 46);
11292: a[o + 3] = (char) (x >> 18 & 4 ^ 46);
11293: a[o + 4] = (char) (x >> 17 & 4 ^ 46);
11294: a[o + 5] = (char) (x >> 16 & 4 ^ 46);
11295: a[o + 6] = (char) (x >> 15 & 4 ^ 46);
11296: a[o + 7] = (char) (x >> 14 & 4 ^ 46);
11297: a[o + 8] = (char) (x >> 13 & 4 ^ 46);
11298: a[o + 9] = (char) (x >> 12 & 4 ^ 46);
11299: a[o + 10] = (char) (x >> 11 & 4 ^ 46);
11300: a[o + 11] = (char) (x >> 10 & 4 ^ 46);
11301: a[o + 12] = (char) (x >> 9 & 4 ^ 46);
11302: a[o + 13] = (char) (x >> 8 & 4 ^ 46);
11303: a[o + 14] = (char) (x >> 7 & 4 ^ 46);
11304: a[o + 15] = (char) (x >> 6 & 4 ^ 46);
11305: a[o + 16] = (char) (x >> 5 & 4 ^ 46);
11306: a[o + 17] = (char) (x >> 4 & 4 ^ 46);
11307: a[o + 18] = (char) (x >> 3 & 4 ^ 46);
11308: a[o + 19] = (char) (x >> 2 & 4 ^ 46);
11309: a[o + 20] = (char) (x >> 1 & 4 ^ 46);
11310: a[o + 21] = (char) (x & 4 ^ 46);
11311: a[o + 22] = (char) (x << 1 & 4 ^ 46);
11312: a[o + 23] = (char) (x << 2 & 4 ^ 46);
11313: }
11314: public static void fmtBin24 (char[] a, int o, int x) {
11315: a[o ] = (char) (x >>> 23 & 1 | 48);
11316: a[o + 1] = (char) (x >>> 22 & 1 | 48);
11317: a[o + 2] = (char) (x >>> 21 & 1 | 48);
11318: a[o + 3] = (char) (x >>> 20 & 1 | 48);
11319: a[o + 4] = (char) (x >>> 19 & 1 | 48);
11320: a[o + 5] = (char) (x >>> 18 & 1 | 48);
11321: a[o + 6] = (char) (x >>> 17 & 1 | 48);
11322: a[o + 7] = (char) (x >>> 16 & 1 | 48);
11323: a[o + 8] = (char) (x >>> 15 & 1 | 48);
11324: a[o + 9] = (char) (x >>> 14 & 1 | 48);
11325: a[o + 10] = (char) (x >>> 13 & 1 | 48);
11326: a[o + 11] = (char) (x >>> 12 & 1 | 48);
11327: a[o + 12] = (char) (x >>> 11 & 1 | 48);
11328: a[o + 13] = (char) (x >>> 10 & 1 | 48);
11329: a[o + 14] = (char) (x >>> 9 & 1 | 48);
11330: a[o + 15] = (char) (x >>> 8 & 1 | 48);
11331: a[o + 16] = (char) (x >>> 7 & 1 | 48);
11332: a[o + 17] = (char) (x >>> 6 & 1 | 48);
11333: a[o + 18] = (char) (x >>> 5 & 1 | 48);
11334: a[o + 19] = (char) (x >>> 4 & 1 | 48);
11335: a[o + 20] = (char) (x >>> 3 & 1 | 48);
11336: a[o + 21] = (char) (x >>> 2 & 1 | 48);
11337: a[o + 22] = (char) (x >>> 1 & 1 | 48);
11338: a[o + 23] = (char) (x & 1 | 48);
11339: }
11340: public static String fmtAin24 (int x) {
11341: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11342: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11343: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11344: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11345: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11346: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11347: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11348: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11349: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11350: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11351: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11352: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11353: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11354: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11355: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11356: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11357: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11358: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11359: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11360: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11361: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11362: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11363: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11364: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11365: return String.valueOf (FMT_TEMP, 0, 24);
11366: }
11367: public static String fmtBin24 (int x) {
11368: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11369: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11370: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11371: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11372: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11373: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11374: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11375: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11376: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11377: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11378: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11379: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11380: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11381: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11382: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11383: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11384: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11385: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11386: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11387: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11388: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11389: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11390: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11391: FMT_TEMP[23] = (char) (x & 1 | 48);
11392: return String.valueOf (FMT_TEMP, 0, 24);
11393: }
11394: public static StringBuilder fmtAin24 (StringBuilder sb, int x) {
11395: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11396: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11397: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11398: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11399: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11400: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11401: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11402: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11403: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11404: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11405: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11406: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11407: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11408: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11409: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11410: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11411: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11412: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11413: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11414: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11415: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11416: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11417: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11418: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11419: return sb.append (FMT_TEMP, 0, 24);
11420: }
11421: public static StringBuilder fmtBin24 (StringBuilder sb, int x) {
11422: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11423: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11424: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11425: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11426: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11427: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11428: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11429: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11430: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11431: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11432: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11433: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11434: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11435: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11436: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11437: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11438: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11439: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11440: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11441: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11442: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11443: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11444: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11445: FMT_TEMP[23] = (char) (x & 1 | 48);
11446: return sb.append (FMT_TEMP, 0, 24);
11447: }
11448:
11449:
11450:
11451:
11452:
11453:
11454:
11455:
11456:
11457:
11458:
11459:
11460:
11461:
11462:
11463:
11464:
11465:
11466:
11467:
11468:
11469:
11470:
11471:
11472:
11473:
11474:
11475:
11476:
11477:
11478:
11479:
11480:
11481: public static char fmtHexc (int x) {
11482: x &= 15;
11483: return (char) ((((9 - x) >> 4) & 7) + 48 + x);
11484: }
11485: public static void fmtHex1 (char[] a, int o, int x) {
11486: x &= 15;
11487: a[o] = (char) ((((9 - x) >> 4) & 7) + 48 + x);
11488: }
11489: public static String fmtHex1 (int x) {
11490: x &= 15;
11491: return Character.toString ((char) ((((9 - x) >> 4) & 7) + 48 + x));
11492: }
11493: public static StringBuilder fmtHex1 (StringBuilder sb, int x) {
11494: x &= 15;
11495: return sb.append ((char) ((((9 - x) >> 4) & 7) + 48 + x));
11496: }
11497:
11498:
11499:
11500:
11501:
11502:
11503: public static void fmtHex2 (char[] a, int o, int x) {
11504: int x0 = x & 15;
11505: int x1 = x >>> 4 & 15;
11506: a[o ] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
11507: a[o + 1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
11508: }
11509: public static String fmtHex2 (int x) {
11510:
11511: int x0 = x & 15;
11512: int x1 = x >>> 4 & 15;
11513: FMT_TEMP[0] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
11514: FMT_TEMP[1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
11515: return String.valueOf (FMT_TEMP, 0, 2);
11516: }
11517: public static StringBuilder fmtHex2 (StringBuilder sb, int x) {
11518: int x0 = x & 15;
11519: int x1 = x >>> 4 & 15;
11520: return (sb.
11521: append ((char) ((((9 - x1) >> 4) & 7) + 48 + x1)).
11522: append ((char) ((((9 - x0) >> 4) & 7) + 48 + x0)));
11523: }
11524:
11525:
11526:
11527:
11528:
11529:
11530: public static void fmtHex4 (char[] a, int o, int x) {
11531: int t;
11532: t = (char) x >>> 12;
11533: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11534: t = x >>> 8 & 15;
11535: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11536: t = x >>> 4 & 15;
11537: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11538: t = x & 15;
11539: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11540: }
11541: public static String fmtHex4 (int x) {
11542:
11543: int t;
11544: t = (char) x >>> 12;
11545: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11546: t = x >>> 8 & 15;
11547: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11548: t = x >>> 4 & 15;
11549: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11550: t = x & 15;
11551: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11552: return String.valueOf (FMT_TEMP, 0, 4);
11553: }
11554: public static StringBuilder fmtHex4 (StringBuilder sb, int x) {
11555:
11556: int t;
11557: t = (char) x >>> 12;
11558: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11559: t = x >>> 8 & 15;
11560: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11561: t = x >>> 4 & 15;
11562: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11563: t = x & 15;
11564: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11565: return sb.append (FMT_TEMP, 0, 4);
11566: }
11567:
11568:
11569:
11570:
11571:
11572:
11573: public static void fmtHex6 (char[] a, int o, int x) {
11574: int t;
11575: t = x >>> 20 & 15;
11576: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11577: t = x >>> 16 & 15;
11578: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11579: t = (char) x >>> 12;
11580: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11581: t = x >>> 8 & 15;
11582: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11583: t = x >>> 4 & 15;
11584: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11585: t = x & 15;
11586: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11587: }
11588: public static String fmtHex6 (int x) {
11589:
11590: int t;
11591: t = x >>> 20 & 15;
11592: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11593: t = x >>> 16 & 15;
11594: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11595: t = (char) x >>> 12;
11596: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11597: t = x >>> 8 & 15;
11598: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11599: t = x >>> 4 & 15;
11600: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11601: t = x & 15;
11602: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11603: return String.valueOf (FMT_TEMP, 0, 6);
11604: }
11605: public static StringBuilder fmtHex6 (StringBuilder sb, int x) {
11606:
11607: int t;
11608: t = x >>> 20 & 15;
11609: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11610: t = x >>> 16 & 15;
11611: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11612: t = (char) x >>> 12;
11613: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11614: t = x >>> 8 & 15;
11615: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11616: t = x >>> 4 & 15;
11617: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11618: t = x & 15;
11619: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11620: return sb.append (FMT_TEMP, 0, 6);
11621: }
11622:
11623:
11624:
11625:
11626:
11627:
11628: public static void fmtHex8 (char[] a, int o, int x) {
11629: int t;
11630: t = x >>> 28;
11631: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11632: t = x >>> 24 & 15;
11633: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11634: t = x >>> 20 & 15;
11635: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11636: t = x >>> 16 & 15;
11637: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11638: t = (char) x >>> 12;
11639: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11640: t = x >>> 8 & 15;
11641: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11642: t = x >>> 4 & 15;
11643: a[o + 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11644: t = x & 15;
11645: a[o + 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11646: }
11647: public static String fmtHex8 (int x) {
11648:
11649: int t;
11650: t = x >>> 28;
11651: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11652: t = x >>> 24 & 15;
11653: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11654: t = x >>> 20 & 15;
11655: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11656: t = x >>> 16 & 15;
11657: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11658: t = (char) x >>> 12;
11659: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11660: t = x >>> 8 & 15;
11661: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11662: t = x >>> 4 & 15;
11663: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11664: t = x & 15;
11665: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11666: return String.valueOf (FMT_TEMP, 0, 8);
11667: }
11668: public static StringBuilder fmtHex8 (StringBuilder sb, int x) {
11669:
11670: int t;
11671: t = x >>> 28;
11672: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11673: t = x >>> 24 & 15;
11674: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11675: t = x >>> 20 & 15;
11676: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11677: t = x >>> 16 & 15;
11678: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11679: t = (char) x >>> 12;
11680: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11681: t = x >>> 8 & 15;
11682: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11683: t = x >>> 4 & 15;
11684: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11685: t = x & 15;
11686: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11687: return sb.append (FMT_TEMP, 0, 8);
11688: }
11689:
11690: public static StringBuilder fmtHex16 (StringBuilder sb, long x) {
11691:
11692: int s, t;
11693: s = (int) (x >>> 32);
11694: t = s >>> 28;
11695: FMT_TEMP[ 0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11696: t = s >>> 24 & 15;
11697: FMT_TEMP[ 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11698: t = s >>> 20 & 15;
11699: FMT_TEMP[ 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11700: t = s >>> 16 & 15;
11701: FMT_TEMP[ 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11702: t = (char) s >>> 12;
11703: FMT_TEMP[ 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11704: t = s >>> 8 & 15;
11705: FMT_TEMP[ 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11706: t = s >>> 4 & 15;
11707: FMT_TEMP[ 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11708: t = s & 15;
11709: FMT_TEMP[ 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11710: s = (int) x;
11711: t = s >>> 28;
11712: FMT_TEMP[ 8] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11713: t = s >>> 24 & 15;
11714: FMT_TEMP[ 9] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11715: t = s >>> 20 & 15;
11716: FMT_TEMP[10] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11717: t = s >>> 16 & 15;
11718: FMT_TEMP[11] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11719: t = (char) s >>> 12;
11720: FMT_TEMP[12] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11721: t = s >>> 8 & 15;
11722: FMT_TEMP[13] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11723: t = s >>> 4 & 15;
11724: FMT_TEMP[14] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11725: t = s & 15;
11726: FMT_TEMP[15] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11727: return sb.append (FMT_TEMP, 0, 16);
11728: }
11729:
11730:
11731:
11732:
11733:
11734:
11735:
11736:
11737:
11738:
11739:
11740:
11741:
11742:
11743:
11744:
11745:
11746:
11747:
11748:
11749:
11750:
11751:
11752:
11753:
11754:
11755:
11756:
11757:
11758:
11759:
11760:
11761:
11762:
11763:
11764:
11765:
11766:
11767:
11768:
11769:
11770:
11771:
11772:
11773:
11774:
11775:
11776:
11777:
11778:
11779:
11780:
11781:
11782:
11783:
11784:
11785:
11786:
11787:
11788:
11789:
11790:
11791:
11792:
11793:
11794:
11795:
11796:
11797: public static final int[] FMT_BCD4 = new int[10000];
11798: public static final int[] FMT_DCB4 = new int[65536];
11799:
11800:
11801:
11802:
11803: public static void fmtInit () {
11804: Arrays.fill (FMT_DCB4, -1);
11805: int i = 0;
11806: int x = 0;
11807: for (int a = 0; a < 10; a++) {
11808: for (int b = 0; b < 10; b++) {
11809: for (int c = 0; c < 10; c++) {
11810: FMT_DCB4[FMT_BCD4[i ] = x ] = i;
11811: FMT_DCB4[FMT_BCD4[i + 1] = x + 1] = i + 1;
11812: FMT_DCB4[FMT_BCD4[i + 2] = x + 2] = i + 2;
11813: FMT_DCB4[FMT_BCD4[i + 3] = x + 3] = i + 3;
11814: FMT_DCB4[FMT_BCD4[i + 4] = x + 4] = i + 4;
11815: FMT_DCB4[FMT_BCD4[i + 5] = x + 5] = i + 5;
11816: FMT_DCB4[FMT_BCD4[i + 6] = x + 6] = i + 6;
11817: FMT_DCB4[FMT_BCD4[i + 7] = x + 7] = i + 7;
11818: FMT_DCB4[FMT_BCD4[i + 8] = x + 8] = i + 8;
11819: FMT_DCB4[FMT_BCD4[i + 9] = x + 9] = i + 9;
11820: i += 10;
11821: x += 1 << 4;
11822: }
11823: x += 6 << 4;
11824: }
11825: x += 6 << 8;
11826: }
11827: }
11828:
11829:
11830:
11831: public static int fmtBcd4 (int x) {
11832:
11833:
11834:
11835:
11836:
11837:
11838:
11839:
11840:
11841: return FMT_BCD4[Math.max (0, Math.min (9999, x))];
11842: }
11843:
11844:
11845:
11846: public static int fmtBcd8 (int x) {
11847: x = Math.max (0, Math.min (99999999, x));
11848:
11849:
11850: int q = (int) ((long) x * 109951163L >>> 40);
11851:
11852: return FMT_BCD4[q] << 16 | FMT_BCD4[x - 10000 * q];
11853: }
11854:
11855:
11856:
11857: public static long fmtBcd12 (long x) {
11858: x = Math.max (0L, Math.min (999999999999L, x));
11859: int q = (int) ((double) x / 100000000.0);
11860: int r = (int) (x - 100000000L * q);
11861:
11862:
11863: int rq = (int) ((long) r * 109951163L >>> 40);
11864:
11865: return (long) FMT_BCD4[q] << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
11866: }
11867:
11868:
11869:
11870: public static long fmtBcd16 (long x) {
11871: x = Math.max (0L, Math.min (9999999999999999L, x));
11872: int q = x <= (1L << 53) ? (int) ((double) x / 100000000.0) : (int) (x / 100000000L);
11873: int r = (int) (x - 100000000L * q);
11874:
11875:
11876: int qq = (int) ((long) q * 109951163L >>> 40);
11877:
11878:
11879:
11880: int rq = (int) ((long) r * 109951163L >>> 40);
11881:
11882: return (long) (FMT_BCD4[qq] << 16 | FMT_BCD4[q - 10000 * qq]) << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
11883: }
11884:
11885:
11886:
11887:
11888:
11889:
11890: public static int fmtCA02u (char[] a, int o, int x) {
11891: if (x < 0 || 99 < x) {
11892: x = 99;
11893: }
11894: x = FMT_BCD4[x];
11895: a[o ] = (char) ('0' | x >>> 4);
11896: a[o + 1] = (char) ('0' | x & 15);
11897: return o + 2;
11898: }
11899: public static StringBuilder fmtSB02u (StringBuilder sb, int x) {
11900: return sb.append (FMT_TEMP, 0, fmtCA02u (FMT_TEMP, 0, x));
11901: }
11902:
11903:
11904:
11905:
11906:
11907: public static int fmtCA2u (char[] a, int o, int x) {
11908: if (x < 0 || 99 < x) {
11909: x = 99;
11910: }
11911: x = FMT_BCD4[x];
11912: if (x <= 0x000f) {
11913: a[o++] = (char) ('0' | x);
11914: } else {
11915: a[o++] = (char) ('0' | x >>> 4);
11916: a[o++] = (char) ('0' | x & 15);
11917: }
11918: return o;
11919: }
11920: public static StringBuilder fmtSB2u (StringBuilder sb, int x) {
11921: return sb.append (FMT_TEMP, 0, fmtCA2u (FMT_TEMP, 0, x));
11922: }
11923:
11924:
11925:
11926:
11927:
11928: public static int fmtCA04u (char[] a, int o, int x) {
11929: if (x < 0 || 9999 < x) {
11930: x = 9999;
11931: }
11932: x = FMT_BCD4[x];
11933: a[o ] = (char) ('0' | x >>> 12);
11934: a[o + 1] = (char) ('0' | x >>> 8 & 15);
11935: a[o + 2] = (char) ('0' | x >>> 4 & 15);
11936: a[o + 3] = (char) ('0' | x & 15);
11937: return o + 4;
11938: }
11939: public static StringBuilder fmtSB04u (StringBuilder sb, int x) {
11940: return sb.append (FMT_TEMP, 0, fmtCA04u (FMT_TEMP, 0, x));
11941: }
11942:
11943:
11944:
11945:
11946:
11947: public static int fmtCA4u (char[] a, int o, int x) {
11948: if (x < 0 || 9999 < x) {
11949: x = 9999;
11950: }
11951: x = FMT_BCD4[x];
11952: if (x <= 0x000f) {
11953: a[o++] = (char) ('0' | x);
11954: } else if (x <= 0x00ff) {
11955: a[o++] = (char) ('0' | x >>> 4);
11956: a[o++] = (char) ('0' | x & 15);
11957: } else if (x <= 0x0fff) {
11958: a[o++] = (char) ('0' | x >>> 8);
11959: a[o++] = (char) ('0' | x >>> 4 & 15);
11960: a[o++] = (char) ('0' | x & 15);
11961: } else {
11962: a[o++] = (char) ('0' | x >>> 12);
11963: a[o++] = (char) ('0' | x >>> 8 & 15);
11964: a[o++] = (char) ('0' | x >>> 4 & 15);
11965: a[o++] = (char) ('0' | x & 15);
11966: }
11967: return o;
11968: }
11969: public static StringBuilder fmtSB4u (StringBuilder sb, int x) {
11970: return sb.append (FMT_TEMP, 0, fmtCA4u (FMT_TEMP, 0, x));
11971: }
11972:
11973:
11974:
11975:
11976:
11977: public static int fmtCA08u (char[] a, int o, int x) {
11978: if (x < 0 || 99999999 < x) {
11979: x = 99999999;
11980: }
11981:
11982:
11983: int h = (int) ((long) x * 109951163L >>> 40);
11984: return fmtCA04u (a, fmtCA04u (a, o, h), x - h * 10000);
11985: }
11986: public static StringBuilder fmtSB08u (StringBuilder sb, int x) {
11987: return sb.append (FMT_TEMP, 0, fmtCA08u (FMT_TEMP, 0, x));
11988: }
11989:
11990:
11991:
11992:
11993:
11994: public static int fmtCA8u (char[] a, int o, int x) {
11995: if (x < 0 || 99999999 < x) {
11996: x = 99999999;
11997: }
11998: if (x <= 9999) {
11999: return fmtCA4u (a, o, x);
12000: } else {
12001:
12002:
12003: int h = (int) ((long) x * 109951163L >>> 40);
12004: return fmtCA04u (a, fmtCA4u (a, o, h), x - h * 10000);
12005: }
12006: }
12007: public static StringBuilder fmtSB8u (StringBuilder sb, int x) {
12008: return sb.append (FMT_TEMP, 0, fmtCA8u (FMT_TEMP, 0, x));
12009: }
12010:
12011:
12012:
12013:
12014:
12015: public static int fmtCAd (char[] a, int o, long x) {
12016: if (x < 0L) {
12017: x = -x;
12018: a[o++] = '-';
12019: }
12020: if (x <= 99999999L) {
12021: return fmtCA8u (a, o, (int) x);
12022: } else if (x <= 9999999999999999L) {
12023: long h = x / 100000000L;
12024: return fmtCA08u (a, fmtCA8u (a, o, (int) h), (int) (x - h * 100000000L));
12025: } else {
12026: long hh = x / 10000000000000000L;
12027: x -= hh * 10000000000000000L;
12028: long h = x / 100000000L;
12029: return fmtCA08u (a, fmtCA08u (a, fmtCA4u (a, o, (int) hh), (int) h), (int) (x - h * 100000000L));
12030: }
12031: }
12032: public static StringBuilder fmtSBd (StringBuilder sb, long x) {
12033: return sb.append (FMT_TEMP, 0, fmtCAd (FMT_TEMP, 0, x));
12034: }
12035:
12036:
12037:
12038:
12039:
12040:
12041: public static int fmtCAnd (char[] a, int o, int n, long x) {
12042: int t = fmtCAd (a, o, x);
12043: n += o;
12044: if (t < n) {
12045: int i = n;
12046: while (o < t) {
12047: a[--i] = a[--t];
12048: }
12049: while (o < i) {
12050: a[--i] = ' ';
12051: }
12052: t = n;
12053: }
12054: return t;
12055: }
12056: public static StringBuilder fmtSBnd (StringBuilder sb, int n, int x) {
12057: return sb.append (FMT_TEMP, 0, fmtCAnd (FMT_TEMP, 0, n, x));
12058: }
12059:
12060:
12061:
12062:
12063:
12064:
12065:
12066:
12067:
12068:
12069:
12070:
12071:
12072: public static int fmtParseInt (String s, int i, int min, int max, int err) {
12073: return fmtParseIntRadix (s, i, min, max, err, 10);
12074: }
12075: public static int fmtParseIntRadix (String s, int i, int min, int max, int err, int radix) {
12076: if (s == null) {
12077: return err;
12078: }
12079: int l = s.length ();
12080: int c = i < l ? s.charAt (i++) : -1;
12081:
12082: while (c == ' ' || c == '\t') {
12083: c = i < l ? s.charAt (i++) : -1;
12084: }
12085:
12086: int n = 0;
12087: if (c == '+') {
12088: c = i < l ? s.charAt (i++) : -1;
12089: } else if (c == '-') {
12090: n = 1;
12091: c = i < l ? s.charAt (i++) : -1;
12092: }
12093:
12094:
12095:
12096:
12097: int o;
12098: int p;
12099: if (c == '$') {
12100: o = 0x07ffffff + n;
12101: p = 15 + n & 15;
12102: radix = 16;
12103: c = i < l ? s.charAt (i++) : -1;
12104: } else if (radix == 16) {
12105: o = 0x07ffffff + n;
12106: p = 15 + n & 15;
12107: } else if (radix == 8) {
12108: o = 0x0fffffff + n;
12109: p = 7 + n & 7;
12110: } else if (radix == 2) {
12111: o = 0x3fffffff + n;
12112: p = 1 + n & 1;
12113: } else {
12114: o = 214748364;
12115: p = 7 + n;
12116: radix = 10;
12117: }
12118:
12119: int x = Character.digit (c, radix);
12120: if (x < 0) {
12121: return err;
12122: }
12123: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12124: while (c >= 0) {
12125: int t = x - o;
12126: if (t > 0 || t == 0 && c > p) {
12127: return err;
12128: }
12129: x = x * radix + c;
12130: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12131: }
12132: if (n != 0) {
12133: x = -x;
12134: }
12135: return min <= x && x <= max ? x : err;
12136: }
12137:
12138:
12139:
12140:
12141:
12142:
12143:
12144:
12145:
12146:
12147: public static long matMax3 (long x1, long x2, long x3) {
12148: return Math.max (Math.max (x1, x2), x3);
12149: }
12150: public static long matMax4 (long x1, long x2, long x3, long x4) {
12151: return Math.max (Math.max (x1, x2), Math.max (x3, x4));
12152: }
12153: public static long matMax5 (long x1, long x2, long x3, long x4, long x5) {
12154: return Math.max (Math.max (Math.max (x1, x2), Math.max (x3, x4)), x5);
12155: }
12156:
12157:
12158:
12159:
12160:
12161: public static long matMin3 (long x1, long x2, long x3) {
12162: return Math.min (Math.min (x1, x2), x3);
12163: }
12164: public static long matMin4 (long x1, long x2, long x3, long x4) {
12165: return Math.min (Math.min (x1, x2), Math.min (x3, x4));
12166: }
12167: public static long matMin5 (long x1, long x2, long x3, long x4, long x5) {
12168: return Math.min (Math.min (Math.min (x1, x2), Math.min (x3, x4)), x5);
12169: }
12170:
12171:
12172:
12173:
12174:
12175:
12176:
12177:
12178:
12179:
12180:
12181:
12182: public static String strEncodeUTF8 (String s) {
12183: StringBuilder sb = new StringBuilder ();
12184: int l = s.length ();
12185: for (int i = 0; i < l; i++) {
12186: int u = s.charAt (i);
12187: if (0xd800 <= u && u <= 0xdbff && i + 1 < l) {
12188: int v = s.charAt (i + 1);
12189: if (0xdc00 <= v && v <= 0xdfff) {
12190: u = 0x10000 + ((u & 0x3ff) << 10) + (v & 0x3ff);
12191: i++;
12192: }
12193: }
12194: if ((u & 0xffffff80) == 0) {
12195: sb.append ((char) u);
12196: } else if ((u & 0xfffff800) == 0) {
12197: u = (0x0000c080 |
12198: (u & 0x000007c0) << 2 |
12199: (u & 0x0000003f));
12200: sb.append ((char) (u >> 8)).append ((char) (u & 0xff));
12201: } else if ((u & 0xffff0000) == 0 && !(0xd800 <= u && u <= 0xdfff)) {
12202: u = (0x00e08080 |
12203: (u & 0x0000f000) << 4 |
12204: (u & 0x00000fc0) << 2 |
12205: (u & 0x0000003f));
12206: sb.append ((char) (u >> 16)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12207: } else if ((u & 0xffe00000) == 0) {
12208: u = (0xf0808080 |
12209: (u & 0x001c0000) << 6 |
12210: (u & 0x0003f000) << 4 |
12211: (u & 0x00000fc0) << 2 |
12212: (u & 0x0000003f));
12213: sb.append ((char) ((u >> 24) & 0xff)).append ((char) ((u >> 16) & 0xff)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12214: } else {
12215: sb.append ((char) 0xef).append ((char) 0xbf).append ((char) 0xbd);
12216: }
12217: }
12218: return sb.toString ();
12219: }
12220:
12221:
12222:
12223:
12224:
12225:
12226:
12227: public static String strDecodeUTF8 (String s) {
12228: StringBuilder sb = new StringBuilder ();
12229: int l = s.length ();
12230: for (int i = 0; i < l; i++) {
12231: int c = s.charAt (i) & 0xff;
12232: for (int k = ((c & 0x80) == 0x00 ? 0 :
12233: (c & 0xe0) == 0xc0 ? 1 :
12234: (c & 0xf0) == 0xe0 ? 2 :
12235: (c & 0xf8) == 0xf0 ? 3 :
12236: -1);
12237: --k >= 0; ) {
12238: c = c << 8 | (i + 1 < l ? s.charAt (++i) & 0xff : 0);
12239: }
12240: int u = ((c & 0xffffff80) == 0x00000000 ? c :
12241: (c & 0xffffe0c0) == 0x0000c080 ? ((c & 0x00001f00) >> 2 |
12242: (c & 0x0000003f)) :
12243: (c & 0xfff0c0c0) == 0x00e08080 ? ((c & 0x000f0000) >> 4 |
12244: (c & 0x00003f00) >> 2 |
12245: (c & 0x0000003f)) :
12246: (c & 0xf8c0c0c0) == 0xf0808080 ? ((c & 0x07000000) >> 6 |
12247: (c & 0x003f0000) >> 4 |
12248: (c & 0x00003f00) >> 2 |
12249: (c & 0x0000003f)) :
12250: 0xfffd);
12251: if (u <= 0x0000ffff) {
12252: sb.append (0xd800 <= u && u <= 0xdfff ? '\ufffd' :
12253: (char) u);
12254: } else if (u <= 0x0010ffff) {
12255: u -= 0x000010000;
12256: sb.append ((char) (0xd800 + ((u >> 10) & 0x3ff))).append ((char) (0xdc00 + (u & 0x3ff)));
12257: }
12258: }
12259: return sb.toString ();
12260: }
12261:
12262:
12263:
12264:
12265:
12266: public static final int[] IsURIChar = {
12267:
12268:
12269: 0b00000000_00000000_00000000_00000000,
12270: 0b00000000_00000110_11111111_11000000,
12271: 0b01111111_11111111_11111111_11100001,
12272: 0b01111111_11111111_11111111_11100010,
12273: };
12274: public static String strEncodeURI (String s) {
12275: s = strEncodeUTF8 (s);
12276: StringBuilder sb = new StringBuilder ();
12277: int l = s.length ();
12278: for (int i = 0; i < l; i++) {
12279: int c = s.charAt (i);
12280: if (c < 0x80 && IsURIChar[c >> 5] << c < 0) {
12281: sb.append ((char) c);
12282: } else {
12283: fmtHex2 (sb.append ('%'), c);
12284: }
12285: }
12286: return sb.toString ();
12287: }
12288:
12289:
12290:
12291:
12292:
12293: public static final byte[] strIsHexChar = {
12294:
12295: -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,
12296: -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,
12297: -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,
12298: -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,
12299: };
12300: public static String strDecodeURI (String s) {
12301: StringBuilder sb = new StringBuilder ();
12302: int l = s.length ();
12303: for (int i = 0; i < l; i++) {
12304: int c = s.charAt (i);
12305: if (c == '%' && i + 2 < l) {
12306: int d = s.charAt (i + 1);
12307: int e = s.charAt (i + 2);
12308: if (d < 0x80 && (d = strIsHexChar[d]) >= 0 &&
12309: e < 0x80 && (e = strIsHexChar[e]) >= 0) {
12310: sb.append ((char) (d << 4 | e));
12311: } else {
12312: sb.append ((char) c);
12313: }
12314: } else {
12315: sb.append ((char) c);
12316: }
12317: }
12318: return sb.toString ();
12319: }
12320:
12321:
12322:
12323:
12324:
12325:
12326:
12327:
12328: public static BufferedImage createImage (int width, int height, String pattern, int... rgbs) {
12329: BufferedImage image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
12330: int[] bitmap = ((DataBufferInt) image.getRaster ().getDataBuffer ()).getData ();
12331: int length = width * height;
12332: for (int i = 0; i < length; i++) {
12333: char c = pattern.charAt (i);
12334: bitmap[i] = rgbs[c < '0' ? 0 : Character.digit (c, 16)];
12335: }
12336: return image;
12337: }
12338:
12339:
12340:
12341: public static ImageIcon createImageIcon (int width, int height, String pattern, int... rgbs) {
12342: return new ImageIcon (createImage (width, height, pattern, rgbs));
12343: }
12344:
12345:
12346:
12347: public static TexturePaint createTexturePaint (int width, int height, String pattern, int... rgbs) {
12348: return new TexturePaint (createImage (width, height, pattern, rgbs), new Rectangle (0, 0, width, height));
12349: }
12350:
12351:
12352:
12353: public static BufferedImage loadImage (String name) {
12354: BufferedImage image = null;
12355: try {
12356: image = ImageIO.read (new File (name));
12357: } catch (Exception e) {
12358: }
12359: return image;
12360: }
12361:
12362:
12363:
12364:
12365: public static boolean saveImage (BufferedImage image, String name) {
12366: return saveImage (image, name, 0.75F);
12367: }
12368: public static boolean saveImage (BufferedImage image, String name, float quality) {
12369: int index = name.lastIndexOf (".");
12370: if (index < 0) {
12371: return false;
12372: }
12373: if (name.substring (index).equalsIgnoreCase (".ico")) {
12374: return saveIcon (name, image);
12375: }
12376: Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix (name.substring (index + 1));
12377: if (!iterator.hasNext ()) {
12378: return false;
12379: }
12380: ImageWriter imageWriter = iterator.next ();
12381: ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam ();
12382: if (imageWriteParam.canWriteCompressed ()) {
12383: imageWriteParam.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);
12384: imageWriteParam.setCompressionQuality (quality);
12385: }
12386: try {
12387: File file = new File (name);
12388: ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream (file);
12389: imageWriter.setOutput (imageOutputStream);
12390: imageWriter.write (null, new IIOImage (image, null, null), imageWriteParam);
12391: imageOutputStream.close ();
12392: } catch (Exception e) {
12393:
12394: return false;
12395: }
12396: return true;
12397: }
12398:
12399:
12400:
12401:
12402:
12403:
12404:
12405:
12406:
12407:
12408:
12409:
12410:
12411:
12412:
12413:
12414:
12415:
12416:
12417:
12418:
12419:
12420:
12421:
12422:
12423:
12424:
12425:
12426:
12427:
12428:
12429:
12430:
12431:
12432:
12433:
12434:
12435:
12436:
12437:
12438:
12439:
12440:
12441:
12442:
12443:
12444:
12445:
12446:
12447:
12448:
12449:
12450:
12451:
12452:
12453:
12454:
12455:
12456:
12457:
12458:
12459:
12460:
12461:
12462:
12463:
12464:
12465:
12466:
12467:
12468:
12469:
12470:
12471: public static boolean saveIcon (String fileName, BufferedImage... arrayImage) {
12472: int iconCount = arrayImage.length;
12473: int[][] arrayPaletTable = new int[iconCount][];
12474: int[] arrayPaletCount = new int[iconCount];
12475: int[] arrayPixelBits = new int[iconCount];
12476: int[] arrayPatternLineSize = new int[iconCount];
12477: int[] arrayMaskLineSize = new int[iconCount];
12478: int[] arrayImageSize = new int[iconCount];
12479: int[] arrayImageOffset = new int[iconCount];
12480: int fileSize = 6 + 16 * iconCount;
12481: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
12482: BufferedImage image = arrayImage[iconNumber];
12483: int width = image.getWidth ();
12484: int height = image.getHeight ();
12485:
12486: int[] paletTable = new int[256];
12487: int paletCount = 0;
12488: countPalet:
12489: for (int y = height - 1; y >= 0; y--) {
12490: for (int x = 0; x < width; x++) {
12491: int rgb = image.getRGB (x, y);
12492: if (rgb >>> 24 != 0xff) {
12493: continue;
12494: }
12495: int l = 0;
12496: int r = paletCount;
12497: while (l < r) {
12498: int m = l + r >> 1;
12499: if (paletTable[m] < rgb) {
12500: l = m + 1;
12501: } else {
12502: r = m;
12503: }
12504: }
12505: if (l == paletCount || paletTable[l] != rgb) {
12506: if (paletCount == 256) {
12507: paletCount = 0;
12508: break countPalet;
12509: }
12510: for (int i = paletCount; i > l; i--) {
12511: paletTable[i] = paletTable[i - 1];
12512: }
12513: paletTable[l] = rgb;
12514: paletCount++;
12515: }
12516: }
12517: }
12518: int pixelBits = (paletCount == 0 ? 24 :
12519: paletCount > 16 ? 8 :
12520: paletCount > 4 ? 4 :
12521: paletCount > 2 ? 2 :
12522: 1);
12523: int patternLineSize = pixelBits * width + 31 >> 5 << 2;
12524: int maskLineSize = width + 31 >> 5 << 2;
12525: int imageSize = 40 + 4 * paletCount + patternLineSize * height + maskLineSize * height;
12526: arrayPaletTable[iconNumber] = paletTable;
12527: arrayPaletCount[iconNumber] = paletCount;
12528: arrayPixelBits[iconNumber] = pixelBits;
12529: arrayPatternLineSize[iconNumber] = patternLineSize;
12530: arrayMaskLineSize[iconNumber] = maskLineSize;
12531: arrayImageSize[iconNumber] = imageSize;
12532: arrayImageOffset[iconNumber] = fileSize;
12533: fileSize += imageSize;
12534: }
12535: byte[] bb = new byte[fileSize];
12536:
12537: ByteArray.byaWiw (bb, 0, 0);
12538: ByteArray.byaWiw (bb, 2, 1);
12539: ByteArray.byaWiw (bb, 4, iconCount);
12540: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
12541: BufferedImage image = arrayImage[iconNumber];
12542: int width = image.getWidth ();
12543: int height = image.getHeight ();
12544: int[] paletTable = arrayPaletTable[iconNumber];
12545: int paletCount = arrayPaletCount[iconNumber];
12546: int pixelBits = arrayPixelBits[iconNumber];
12547: int patternLineSize = arrayPatternLineSize[iconNumber];
12548: int maskLineSize = arrayMaskLineSize[iconNumber];
12549: int imageSize = arrayImageSize[iconNumber];
12550: int imageOffset = arrayImageOffset[iconNumber];
12551:
12552: int o = 6 + 16 * iconNumber;
12553: ByteArray.byaWb (bb, o, width);
12554: ByteArray.byaWb (bb, o + 1, height);
12555: ByteArray.byaWb (bb, o + 2, paletCount);
12556: ByteArray.byaWb (bb, o + 3, 0);
12557: ByteArray.byaWiw (bb, o + 4, 1);
12558: ByteArray.byaWiw (bb, o + 6, pixelBits);
12559: ByteArray.byaWil (bb, o + 8, imageSize);
12560: ByteArray.byaWil (bb, o + 12, imageOffset);
12561:
12562: o = imageOffset;
12563: ByteArray.byaWil (bb, o, 40);
12564: ByteArray.byaWil (bb, o + 4, width);
12565: ByteArray.byaWil (bb, o + 8, height * 2);
12566: ByteArray.byaWiw (bb, o + 12, 1);
12567: ByteArray.byaWiw (bb, o + 14, pixelBits);
12568: ByteArray.byaWil (bb, o + 16, 0);
12569: ByteArray.byaWil (bb, o + 20, 0);
12570: ByteArray.byaWil (bb, o + 24, 0);
12571: ByteArray.byaWil (bb, o + 28, 0);
12572: ByteArray.byaWil (bb, o + 32, paletCount);
12573: ByteArray.byaWil (bb, o + 36, 0);
12574:
12575: o += 40;
12576: for (int i = 0; i < paletCount; i++) {
12577: ByteArray.byaWil (bb, o, paletTable[i] & 0x00ffffff);
12578: o += 4;
12579: }
12580:
12581: for (int y = height - 1; y >= 0; y--) {
12582: for (int x = 0; x < width; x++) {
12583: int rgb = image.getRGB (x, y);
12584: if (rgb >>> 24 != 0xff) {
12585: continue;
12586: }
12587: if (pixelBits == 24) {
12588: bb[o + 3 * x] = (byte) rgb;
12589: bb[o + 3 * x + 1] = (byte) (rgb >> 8);
12590: bb[o + 3 * x + 2] = (byte) (rgb >> 16);
12591: continue;
12592: }
12593: int l = 0;
12594: int r = paletCount;
12595: while (l < r) {
12596: int m = l + r >> 1;
12597: if (paletTable[m] < rgb) {
12598: l = m + 1;
12599: } else {
12600: r = m;
12601: }
12602: }
12603: if (l != 0) {
12604: if (pixelBits == 8) {
12605: bb[o + x] = (byte) l;
12606: } else if (pixelBits == 4) {
12607: bb[o + (x >> 1)] |= (byte) (l << ((~x & 1) << 2));
12608: } else if (pixelBits == 2) {
12609: bb[o + (x >> 2)] |= (byte) (l << ((~x & 3) << 1));
12610: } else {
12611: bb[o + (x >> 3)] |= (byte) (l << (~x & 7));
12612: }
12613: }
12614: }
12615: o += patternLineSize;
12616: }
12617:
12618: for (int y = height - 1; y >= 0; y--) {
12619: for (int x = 0; x < width; x++) {
12620: int rgb = image.getRGB (x, y);
12621: if (rgb >>> 24 != 0xff) {
12622: bb[o + (x >> 3)] |= (byte) (1 << (~x & 7));
12623: }
12624: }
12625: o += maskLineSize;
12626: }
12627: }
12628: return rscPutFile (fileName, bb, 0, fileSize);
12629: }
12630:
12631:
12632:
12633: }
12634:
12635:
12636: