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.29";
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: if (HostCDROM.HCD_ENABLED) {
217: HostCDROM.hcdInit ();
218: }
219: SPC.spcInit ();
220: Z8530.sccInit ();
221: IOInterrupt.ioiInit ();
222: SpriteScreen.sprInit ();
223: bnkInit ();
224: SRAM.smrInit ();
225:
226: PPI.ppiInit ();
227: PrinterPort.prnInit ();
228: Indicator.indInit ();
229:
230: SlowdownTest.sdtInit ();
231: Keyboard.kbdInit ();
232: CONDevice.conInit ();
233: Mouse.musInit ();
234: pnlInit ();
235: frmInit ();
236:
237: dbgInit ();
238: RegisterList.drpInit ();
239: DisassembleList.ddpInit ();
240: MemoryDumpList.dmpInit ();
241: LogicalSpaceMonitor.atwInit ();
242: PhysicalSpaceMonitor.paaInit ();
243: DebugConsole.dgtInit ();
244: if (BranchLog.BLG_ON) {
245: BranchLog.blgInit ();
246: }
247: if (ProgramFlowVisualizer.PFV_ON) {
248: ProgramFlowVisualizer.pfvInit ();
249: }
250: if (RasterBreakPoint.RBP_ON) {
251: RasterBreakPoint.rbpInit ();
252: }
253: if (ScreenModeTest.SMT_ON) {
254: ScreenModeTest.smtInit ();
255: }
256: if (RootPointerList.RTL_ON) {
257: RootPointerList.rtlInit ();
258: }
259: if (SpritePatternViewer.SPV_ON) {
260: SpritePatternViewer.spvInit ();
261: }
262: if (ATCMonitor.ACM_ON) {
263: ATCMonitor.acmInit ();
264: }
265:
266: SoundSource.sndInit ();
267: FEFunction.fpkInit ();
268: mpuInit ();
269: MC68060.mmuInit ();
270: SoundMonitor.smnInit ();
271: HFS.hfsInit ();
272:
273: GIFAnimation.gifInit ();
274: TextCopy.txcInit ();
275: ButtonFunction.bfnInit ();
276:
277:
278:
279: Settings.sgsMakeMenu ();
280: mdlMakeMenu ();
281: FDC.fdcMakeMenu ();
282: HDC.hdcMakeMenu ();
283: SPC.spcMakeMenu ();
284: mpuMakeMenu ();
285: SRAM.smrMakeMenu ();
286: clpMake ();
287: pnlMake ();
288: mnbMakeMenu ();
289: frmMake ();
290: dbgMakePopup ();
291:
292:
293: final String flags = (
294: "" +
295: (EFPBox.CIR_DEBUG_TRACE ? " EFPBox.CIR_DEBUG_TRACE" : "") +
296: (FDC.FDC_DEBUG_TRACE ? " FDC.FDC_DEBUG_TRACE" : "") +
297: (FEFunction.FPK_DEBUG_TRACE ? " FEFunction.FPK_DEBUG_TRACE" : "") +
298: (HD63450.DMA_DEBUG_TRACE != 0 ? " HD63450.DMA_DEBUG_TRACE" : "") +
299: (HDC.HDC_DEBUG_TRACE ? " HDC.HDC_DEBUG_TRACE" : "") +
300: (HDC.HDC_DEBUG_COMMAND ? " HDC.HDC_DEBUG_COMMAND" : "") +
301: (HFS.HFS_DEBUG_TRACE ? " HFS.HFS_DEBUG_TRACE" : "") +
302: (HFS.HFS_DEBUG_FILE_INFO ? " HFS.HFS_DEBUG_FILE_INFO" : "") +
303: (HFS.HFS_COMMAND_TRACE ? " HFS.HFS_COMMAND_TRACE" : "") +
304: (HFS.HFS_BUFFER_TRACE ? " HFS.HFS_BUFFER_TRACE" : "") +
305: (IOInterrupt.IOI_DEBUG_TRACE ? " IOInterrupt.IOI_DEBUG_TRACE" : "") +
306: (Keyboard.KBD_DEBUG_LED ? " Keyboard.KBD_DEBUG_LED" : "") +
307: (MC68060.MMU_DEBUG_COMMAND ? " MC68060.MMU_DEBUG_COMMAND" : "") +
308: (MC68060.MMU_DEBUG_TRANSLATION ? " MC68060.MMU_DEBUG_TRANSLATION" : "") +
309: (MC68060.MMU_NOT_ALLOCATE_CACHE ? " MC68060.MMU_NOT_ALLOCATE_CACHE" : "") +
310: (RP5C15.RTC_DEBUG_TRACE ? " RP5C15.RTC_DEBUG_TRACE" : "") +
311: (SPC.SPC_DEBUG_ON ? " SPC.SPC_DEBUG_ON" : "") +
312: (Z8530.SCC_DEBUG_ON ? " Z8530.SCC_DEBUG_ON" : "")
313: );
314: if (!"".equals (flags)) {
315: pnlExitFullScreen (true);
316: JOptionPane.showMessageDialog (null, "debug flags:" + flags);
317: }
318:
319:
320:
321:
322: tmrStart ();
323:
324: Keyboard.kbdStart ();
325: Mouse.musStart ();
326: pnlStart ();
327: frmStart ();
328: SoundSource.sndStart ();
329:
330: if (DataBreakPoint.DBP_ON) {
331: DataBreakPoint.dbpStart ();
332: }
333: if (RasterBreakPoint.RBP_ON) {
334: RasterBreakPoint.rbpStart ();
335: }
336: if (ScreenModeTest.SMT_ON) {
337: ScreenModeTest.smtStart ();
338: }
339: if (OPMLog.OLG_ON) {
340: OPMLog.olgStart ();
341: }
342: SoundMonitor.smnStart ();
343: RS232CTerminal.trmStart ();
344: PPI.ppiStart ();
345: PrinterPort.prnStart ();
346: if (BranchLog.BLG_ON) {
347: BranchLog.blgStart ();
348: }
349: if (ProgramFlowVisualizer.PFV_ON) {
350: ProgramFlowVisualizer.pfvStart ();
351: }
352: RegisterList.drpStart ();
353: DisassembleList.ddpStart ();
354: MemoryDumpList.dmpStart ();
355: LogicalSpaceMonitor.atwStart ();
356: PhysicalSpaceMonitor.paaStart ();
357: DebugConsole.dgtStart ();
358: if (RootPointerList.RTL_ON) {
359: RootPointerList.rtlStart ();
360: }
361: if (SpritePatternViewer.SPV_ON) {
362: SpritePatternViewer.spvStart ();
363: }
364: if (ATCMonitor.ACM_ON) {
365: ATCMonitor.acmStart ();
366: }
367: ButtonFunction.bfnStart ();
368:
369: if (Settings.sgsSaveiconValue != null) {
370: String[] a = Settings.sgsSaveiconValue.split (",");
371: if (0 < a.length) {
372: saveIcon (a[0], LnF.LNF_ICON_IMAGES);
373: if (1 < a.length) {
374: saveImage (LnF.LNF_ICON_IMAGE_16, a[1]);
375: if (2 < a.length) {
376: saveImage (LnF.LNF_ICON_IMAGE_32, a[2]);
377: if (3 < a.length) {
378: saveImage (LnF.LNF_ICON_IMAGE_48, a[3]);
379: }
380: }
381: }
382: }
383: prgTini ();
384: return;
385: }
386:
387:
388: mpuReset (-1, -1);
389:
390: pnlBoot2 ();
391:
392: }
393:
394:
395:
396:
397:
398: public static void prgTini () {
399: try {
400: if (OPMLog.OLG_ON) {
401: OPMLog.olgTini ();
402: }
403: ButtonFunction.bfnTini ();
404: TextCopy.txcTini ();
405: GIFAnimation.gifTini ();
406: SoundSource.sndTini ();
407: Keyboard.kbdTini ();
408: Mouse.musTini ();
409: CONDevice.conTini ();
410: PPI.ppiTini ();
411: PrinterPort.prnTini ();
412: FDC.fdcTini ();
413: HDC.hdcTini ();
414: if (HostCDROM.HCD_ENABLED) {
415: HostCDROM.hcdTini ();
416: }
417: SPC.spcTini ();
418: HFS.hfsTini ();
419: Z8530.sccTini ();
420: CRTC.crtTini ();
421: SpriteScreen.sprTini ();
422: pnlTini ();
423: bnkTini ();
424: ROM.romTini ();
425: xt3Tini ();
426: mdlTini ();
427: SRAM.smrTini ();
428: tmrTini ();
429: busTini ();
430: RS232CTerminal.trmTini ();
431: LnF.lnfTini ();
432: Settings.sgsTini ();
433: } catch (Exception e) {
434: e.printStackTrace ();
435: }
436: System.exit (0);
437: }
438:
439:
440:
441: public static void prgOpenJavaDialog () {
442: pnlExitFullScreen (true);
443: JOptionPane.showMessageDialog (
444: frmFrame,
445: ComponentFactory.createGridPanel (
446: 3,
447: 6,
448: "paddingLeft=6,paddingRight=6",
449: "italic,right;left;left",
450: "italic,center;colSpan=3,widen",
451: "",
452:
453: null,
454: Multilingual.mlnJapanese ? "実行中" : "Running",
455: Multilingual.mlnJapanese ? "推奨" : "Recommended",
456:
457: ComponentFactory.createHorizontalSeparator (),
458:
459: Multilingual.mlnJapanese ? "Java のベンダー" : "Java Vendor",
460: prgJavaVendor,
461: PRG_JAVA_VENDOR,
462:
463: Multilingual.mlnJapanese ? "Java のバージョン" : "Java Version",
464: prgJavaVersion,
465: PRG_JAVA_VERSION,
466:
467: Multilingual.mlnJapanese ? "OS のアーキテクチャ" : "OS Architecture",
468: prgOsArch,
469: PRG_OS_ARCH,
470:
471: Multilingual.mlnJapanese ? "OS の名前" : "OS Name",
472: prgOsName,
473: PRG_OS_NAME
474: ),
475: Multilingual.mlnJapanese ? "Java 実行環境の情報" : "Java runtime environment information",
476: JOptionPane.PLAIN_MESSAGE);
477: }
478:
479:
480:
481: public static void prgOpenAboutDialog () {
482: pnlExitFullScreen (true);
483: JOptionPane.showMessageDialog (
484: frmFrame,
485: ComponentFactory.createGridPanel (
486: 2, 4, "paddingLeft=6,paddingRight=6", "italic,right;left", "", "",
487: Multilingual.mlnJapanese ? "タイトル" : "Title" ,
488: PRG_TITLE,
489: Multilingual.mlnJapanese ? "バージョン" : "Version",
490: PRG_VERSION,
491: Multilingual.mlnJapanese ? "作者" : "Author" ,
492: PRG_AUTHOR,
493: Multilingual.mlnJapanese ? "ウェブページ" : "Webpage",
494: PRG_WEBPAGE
495: ),
496: Multilingual.mlnJapanese ? "バージョン情報" : "Version information",
497: JOptionPane.PLAIN_MESSAGE);
498: }
499:
500:
501:
502: public static void prgOpenXEiJLicenseDialog () {
503: pnlExitFullScreen (true);
504: JOptionPane.showMessageDialog (
505: frmFrame,
506: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_XEiJ.txt"), 550, 300),
507: Multilingual.mlnJapanese ? "XEiJ 使用許諾条件" : "XEiJ License",
508: JOptionPane.PLAIN_MESSAGE);
509: }
510:
511:
512:
513: public static void prgOpenSHARPLicenseDialog () {
514: pnlExitFullScreen (true);
515: JOptionPane.showMessageDialog (
516: frmFrame,
517: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_FSHARP.txt", "Shift_JIS"), 550, 300),
518: Multilingual.mlnJapanese ? "無償公開された X68000 の基本ソフトウェア製品の許諾条件" : "License of the basic software products for X68000 that were distributed free of charge",
519: JOptionPane.PLAIN_MESSAGE);
520: }
521:
522:
523:
524: public static void prgOpenYmfmLicenseDialog () {
525: pnlExitFullScreen (true);
526: JOptionPane.showMessageDialog (
527: frmFrame,
528: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_ymfm.txt"), 550, 300),
529: "ymfm License",
530: JOptionPane.PLAIN_MESSAGE);
531: }
532:
533:
534:
535: public static void prgOpenJSerialCommLicenseDialog () {
536: pnlExitFullScreen (true);
537: JOptionPane.showMessageDialog (
538: frmFrame,
539: ComponentFactory.createVerticalSplitPane (
540: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-APACHE-2.0"), 550, 300),
541: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-LGPL-3.0"), 550, 300)
542: ),
543: "jSerialComm License",
544: JOptionPane.PLAIN_MESSAGE);
545: }
546:
547:
548:
549: public static void prgPrintClass (Object o) {
550: System.out.println (o.toString ());
551:
552: try {
553: Stack<Class<?>> s = new Stack<Class<?>> ();
554: for (Class<?> c = o.getClass (); c != null; c = c.getSuperclass ()) {
555: s.push (c);
556: }
557: for (int i = 0; !s.empty (); i++) {
558: for (int j = 0; j < i; j++) {
559: System.out.print (" ");
560: }
561: System.out.println (s.pop ().getName ());
562: }
563: } catch (Exception e) {
564: }
565: }
566:
567:
568:
569:
570: public static void prgPrintStackTrace () {
571: Exception e = new Exception ();
572: e.fillInStackTrace ();
573: prgPrintStackTraceOf (e);
574: }
575: public static void prgPrintStackTraceOf (Exception e) {
576:
577: System.out.println ("------------------------------------------------");
578: System.out.println (e.toString ());
579: System.out.println ("\t" + e.getMessage ());
580: for (StackTraceElement ste : e.getStackTrace ()) {
581: System.out.println ("\tat " + ste.toString ());
582: }
583: System.out.println ("------------------------------------------------");
584: }
585:
586:
587:
588:
589: public static boolean prgStopDone = false;
590: public static void prgStopOnce () {
591: if (!prgStopDone) {
592: prgStopDone = true;
593: mpuStop (null);
594: }
595: }
596:
597:
598:
599:
600:
601:
602:
603:
604:
605:
606:
607:
608:
609:
610:
611:
612:
613:
614:
615:
616:
617:
618:
619:
620:
621:
622:
623:
624:
625:
626:
627: public static final long TMR_FREQ = 1000000000000L;
628:
629:
630: public static final long TMR_DELAY = 10L;
631: public static final long TMR_INTERVAL = 10L;
632:
633:
634: public static java.util.Timer tmrTimer;
635:
636:
637:
638: public static void tmrStart () {
639: tmrTimer = new java.util.Timer ();
640: }
641:
642:
643:
644: public static void tmrTini () {
645: if (tmrTimer != null) {
646: tmrTimer.cancel ();
647: }
648: }
649:
650:
651:
652:
653:
654:
655:
656:
657:
658:
659:
660:
661:
662:
663:
664:
665:
666:
667:
668:
669:
670:
671:
672:
673:
674:
675:
676:
677:
678:
679:
680:
681:
682:
683:
684: public static final int PNL_BM_OFFSET_BITS = 10;
685: public static final int PNL_BM_WIDTH = 1 << PNL_BM_OFFSET_BITS;
686: public static final int PNL_BM_HEIGHT = 1024;
687:
688:
689: public static final int PNL_ASPECT_KEYS = 4;
690: public static final int PNL_ASPECT_VALUES = 4;
691: public static final int[] PNL_ASPECT_DEFAULT_VALUE = { 0, 0, 0, 3 };
692: public static final String[] PNL_ASPECT_RESOLUTION_NAME = { "256x256", "384x256", "512x512", "768x512" };
693: public static final String[] PNL_ASPECT_SCREEN_NAME = { "4:3", "7:5", "13:9", "3:2" };
694: public static final String[] PNL_ASPECT_PIXEL_NAME = { "8:9", "14:15", "26:27", "1:1" };
695: public static final float[] PNL_ASPECT_SCREEN_RATIO = { 4.0F / 3.0F, 7.0F / 5.0F, 13.0F / 9.0F, 3.0F / 2.0F };
696: public static final float[] PNL_ASPECT_PIXEL_RATIO = { 8.0F / 9.0F, 14.0F / 15.0F, 26.0F / 27.0F, 1.0F / 1.0F };
697: public static final float[][] PNL_ASPECT_MATRIX = {
698: PNL_ASPECT_SCREEN_RATIO,
699: PNL_ASPECT_PIXEL_RATIO,
700: PNL_ASPECT_SCREEN_RATIO,
701: PNL_ASPECT_PIXEL_RATIO,
702: };
703: public static int[] pnlAspectMap;
704: public static float[] pnlAspectTable;
705:
706:
707: public static final int PNL_MIN_WIDTH = 64;
708: public static final int PNL_MIN_HEIGHT = 64;
709: public static int pnlScreenWidth;
710: public static int pnlScreenHeight;
711: public static float pnlStretchMode;
712: public static int pnlStretchWidth;
713:
714: public static boolean PNL_ROTATION_ON = true;
715: public static int pnlRotationMode;
716: public static AffineTransform pnlRotationTransformLeft;
717: public static AffineTransform pnlRotationTransformRight;
718: public static double pnlMatrixL00, pnlMatrixL10, pnlMatrixL01, pnlMatrixL11, pnlMatrixL02, pnlMatrixL12;
719: public static double pnlMatrixR00, pnlMatrixR10, pnlMatrixR01, pnlMatrixR11, pnlMatrixR02, pnlMatrixR12;
720: public static double pnlInverseL00, pnlInverseL10, pnlInverseL01, pnlInverseL11, pnlInverseL02, pnlInverseL12;
721: public static double pnlInverseR00, pnlInverseR10, pnlInverseR01, pnlInverseR11, pnlInverseR02, pnlInverseR12;
722: public static int pnlRotatedWidth;
723: public static int pnlRotatedHeight;
724:
725: public static int pnlZoomWidth;
726: public static int pnlZoomHeight;
727: public static int pnlZoomRatioOutX;
728: public static int pnlZoomRatioOutY;
729: public static int pnlZoomRatioInX;
730: public static int pnlZoomRatioInY;
731: public static int pnlWidth;
732: public static int pnlHeight;
733: public static Dimension pnlSize;
734: public static int pnlScreenX1;
735: public static int pnlScreenX2;
736: public static int pnlScreenX3;
737: public static int pnlScreenX4;
738: public static int pnlScreenY1;
739: public static int pnlScreenY2;
740: public static int pnlScreenY3;
741: public static int pnlScreenY4;
742: public static int pnlKeyboardX;
743: public static int pnlKeyboardY;
744: public static int pnlMinimumWidth;
745: public static int pnlMinimumHeight;
746: public static int pnlGlobalX;
747: public static int pnlGlobalY;
748:
749:
750: public static final boolean PNL_FILL_BACKGROUND = true;
751: public static boolean pnlFillBackgroundRequest;
752: public static boolean pnlIsFullScreenSupported;
753: public static boolean pnlPrevKeyboardOn;
754: public static boolean pnlHideKeyboard;
755:
756:
757:
758:
759:
760: public static Object pnlInterpolation;
761:
762:
763: public static final double PNL_MIN_RATE = 1.0;
764: public static final double PNL_MAX_RATE = 1000.0;
765: public static final double PNL_DEFAULT_RATE = 59.94;
766: public static double pnlRefreshRate;
767: public static double pnlFixedRate;
768: public static boolean pnlAdjustVsync;
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:
813:
814:
815:
816:
817:
818: public static final boolean PNL_STEREOSCOPIC_ON = true;
819:
820: public static final boolean PNL_USE_THREAD = true;
821:
822: public static BufferedImage[] pnlScreenImageLeftArray;
823: public static BufferedImage[] pnlScreenImageRightArray;
824:
825: public static BufferedImage[] pnlScreenSubImageLeftArray;
826: public static BufferedImage[] pnlScreenSubImageRightArray;
827:
828: public static int[][] pnlBMLeftArray;
829: public static int[][] pnlBMRightArray;
830: public static volatile int pnlBMWrite;
831: public static volatile int pnlBMRead;
832:
833: public static BufferedImage pnlScreenImageLeft;
834: public static BufferedImage pnlScreenImageRight;
835:
836: public static BufferedImage pnlScreenSubImageLeft;
837: public static BufferedImage pnlScreenSubImageRight;
838:
839: public static int[] pnlBMLeft;
840: public static int[] pnlBMRight;
841:
842: public static int[] pnlBM;
843: public static boolean pnlStereoscopicOn;
844: public static final int PNL_NAKED_EYE_CROSSING = 0;
845: public static final int PNL_NAKED_EYE_PARALLEL = 1;
846: public static final int PNL_SIDE_BY_SIDE = 2;
847: public static final int PNL_TOP_AND_BOTTOM = 3;
848: public static int pnlStereoscopicMethod;
849: public static int pnlStereoscopicFactor;
850: public static int pnlStereoscopicShutter;
851:
852:
853: public static JPanel pnlPanel;
854:
855: public static Thread pnlThread;
856: public static long pnlWakeupTime;
857: public static long pnlWakeupTimeMNP;
858: public static final boolean PNL_USE_CANVAS = PNL_USE_THREAD && true;
859:
860: public static boolean pnlUseCanvasRequest;
861: public static boolean pnlUseCanvas;
862: public static Canvas pnlCanvas;
863: public static Component pnlCanvasOrPanel;
864:
865:
866:
867:
868: public static int pnlFixedScale;
869: public static SpinnerNumberModel pnlFixedModel;
870: public static JSpinner pnlFixedSpinner;
871:
872:
873:
874: public static void pnlInit () {
875: pnlInit2 ();
876:
877:
878:
879:
880: pnlFixedScale = Math.max (10, Math.min (1000, Settings.sgsGetInt ("fixedscale")));
881:
882:
883: pnlAspectMap = new int[PNL_ASPECT_KEYS];
884: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
885: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[key];
886: String screenName = Settings.sgsGetString ("aspectratio" + resolutionName);
887: int value = PNL_ASPECT_DEFAULT_VALUE[key];
888: for (int tempValue = 0; tempValue < PNL_ASPECT_VALUES; tempValue++) {
889: if (PNL_ASPECT_SCREEN_NAME[tempValue].equals (screenName)) {
890: value = tempValue;
891: break;
892: }
893: }
894: pnlAspectMap[key] = value;
895: }
896: pnlAspectTable = new float[8];
897: pnlUpdateAspectTable ();
898:
899:
900: switch (Settings.sgsGetString ("interpolation").toLowerCase ()) {
901: case "nearest":
902: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
903: break;
904: case "bilinear":
905: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
906: break;
907: case "bicubic":
908: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
909: break;
910: default:
911: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
912: }
913:
914:
915: pnlRefreshRate = 0.0;
916: {
917: String s = Settings.sgsGetString ("refreshrate");
918: if (!s.equals ("")) {
919: try {
920: double rate = Double.parseDouble (s);
921: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
922: pnlRefreshRate = rate;
923: }
924: } catch (NumberFormatException nfe) {
925: }
926: }
927: }
928: pnlFixedRate = pnlRefreshRate;
929: pnlAdjustVsync = Settings.sgsGetOnOff ("adjustvsync");
930:
931: pnlPrevKeyboardOn = true;
932:
933: pnlHideKeyboard = Settings.sgsGetOnOff ("hidekeyboard");
934:
935:
936: if (PNL_USE_THREAD) {
937: pnlScreenImageLeftArray = new BufferedImage[4];
938: pnlScreenImageRightArray = new BufferedImage[4];
939: if (PNL_ROTATION_ON) {
940: pnlScreenSubImageLeftArray = new BufferedImage[4];
941: pnlScreenSubImageRightArray = new BufferedImage[4];
942: }
943: pnlBMLeftArray = new int[4][];
944: pnlBMRightArray = new int[4][];
945: for (int n = 0; n < 4; n++) {
946: pnlScreenImageLeftArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
947: pnlScreenImageRightArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
948: if (PNL_ROTATION_ON) {
949: pnlScreenSubImageLeftArray[n] = null;
950: pnlScreenSubImageRightArray[n] = null;
951: }
952: pnlBMLeftArray[n] = ((DataBufferInt) pnlScreenImageLeftArray[n].getRaster ().getDataBuffer ()).getData ();
953: pnlBMRightArray[n] = ((DataBufferInt) pnlScreenImageRightArray[n].getRaster ().getDataBuffer ()).getData ();
954: }
955: pnlBMWrite = 0;
956: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
957: pnlBMRead = 0;
958: pnlThread = null;
959: pnlWakeupTime = 0L;
960: pnlWakeupTimeMNP = 0L;
961: if (PNL_USE_CANVAS) {
962: pnlUseCanvasRequest = Settings.sgsGetOnOff ("usecanvas");
963: pnlUseCanvas = pnlUseCanvasRequest;
964: pnlCanvas = null;
965: }
966: } else {
967: pnlScreenImageLeft = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
968: pnlScreenImageRight = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
969: if (PNL_ROTATION_ON) {
970: pnlScreenSubImageLeft = null;
971: pnlScreenSubImageRight = null;
972: }
973: pnlBMLeft = ((DataBufferInt) pnlScreenImageLeft.getRaster ().getDataBuffer ()).getData ();
974: pnlBMRight = ((DataBufferInt) pnlScreenImageRight.getRaster ().getDataBuffer ()).getData ();
975: pnlBM = pnlBMLeft;
976: }
977: pnlStereoscopicOn = Settings.sgsGetOnOff ("stereoscopic");
978: switch (Settings.sgsGetString ("stereoscopicmethod").toLowerCase ()) {
979: case "nakedeyecrossing":
980: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
981: break;
982: case "nakedeyeparallel":
983: pnlStereoscopicMethod = PNL_NAKED_EYE_PARALLEL;
984: break;
985: case "sidebyside":
986: pnlStereoscopicMethod = PNL_SIDE_BY_SIDE;
987: break;
988: case "topandbottom":
989: pnlStereoscopicMethod = PNL_TOP_AND_BOTTOM;
990: break;
991: default:
992: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
993: }
994: pnlStereoscopicFactor = pnlStereoscopicOn && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
995: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
996: pnlStereoscopicShutter = 0;
997:
998:
999: pnlScreenWidth = 768;
1000: pnlScreenHeight = 512;
1001: pnlStretchMode = 1.0F;
1002: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchMode);
1003:
1004: if (PNL_ROTATION_ON) {
1005: pnlRotationMode = Settings.sgsGetInt ("rotation", 0);
1006: if (pnlRotationMode < 0 || 3 < pnlRotationMode) {
1007: pnlRotationMode = 0;
1008: }
1009: pnlRotationTransformLeft = new AffineTransform ();
1010: pnlRotationTransformRight = new AffineTransform ();
1011: }
1012: pnlRotatedWidth = pnlStretchWidth;
1013: pnlRotatedHeight = pnlScreenHeight;
1014: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1015: pnlRotatedWidth = pnlScreenHeight;
1016: pnlRotatedHeight = pnlStretchWidth;
1017: }
1018:
1019: pnlZoomWidth = pnlRotatedWidth;
1020: pnlZoomHeight = pnlRotatedHeight;
1021: pnlWidth = Math.max (pnlZoomWidth * pnlStereoscopicFactor, Keyboard.kbdWidth);
1022: pnlHeight = pnlZoomHeight + Keyboard.kbdHeight;
1023: pnlSize = new Dimension (pnlWidth, pnlHeight);
1024: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1025: pnlScreenY1 = 0;
1026: pnlArrangementCommon ();
1027: pnlMinimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
1028: pnlMinimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
1029: pnlGlobalX = 0;
1030: pnlGlobalY = 0;
1031:
1032:
1033: if (!PNL_FILL_BACKGROUND) {
1034: pnlFillBackgroundRequest = true;
1035: }
1036:
1037:
1038: pnlFixedModel = new SpinnerNumberModel (pnlFixedScale, 10, 1000, 1);
1039: pnlFixedSpinner = ComponentFactory.createNumberSpinner (pnlFixedModel, 4, new ChangeListener () {
1040: @Override public void stateChanged (ChangeEvent ce) {
1041: if (pnlMode != PNL_FIXEDSCALE) {
1042: pnlSetMode (PNL_FIXEDSCALE);
1043: } else {
1044: pnlUpdateArrangement ();
1045: }
1046: }
1047: });
1048:
1049: }
1050:
1051:
1052:
1053: public static double pnlGetRefreshRate () {
1054: double rate = 0.0;
1055: GraphicsConfiguration gc = frmFrame.getGraphicsConfiguration ();
1056: if (gc != null) {
1057: GraphicsDevice gd = gc.getDevice ();
1058: DisplayMode dm = gd.getDisplayMode ();
1059: int i = dm.getRefreshRate ();
1060: if (i != DisplayMode.REFRESH_RATE_UNKNOWN) {
1061: rate = (i == 23 ? 23.98 :
1062: i == 29 ? 29.97 :
1063: i == 59 ? 59.94 :
1064: i == 119 ? 119.88 :
1065: i == 239 ? 239.76 :
1066: (double) i);
1067: if (rate < PNL_MIN_RATE || PNL_MAX_RATE < rate) {
1068: rate = 0.0;
1069: }
1070: }
1071: }
1072: if (rate == 0.0) {
1073: rate = PNL_DEFAULT_RATE;
1074: System.out.printf (Multilingual.mlnJapanese ?
1075: "ホストのリフレッシュレートを取得できません。デフォルトの %.2f Hz を使います\n" :
1076: "Cannot get host refresh rate. Use default %.2f Hz\n", rate);
1077: } else {
1078: System.out.printf (Multilingual.mlnJapanese ?
1079: "ホストのリフレッシュレートは %.2f Hz です\n" :
1080: "Host refresh rate is %.2f Hz\n", rate);
1081: }
1082: return rate;
1083: }
1084:
1085:
1086: public static void pnlSetStereoscopic (boolean on, int method) {
1087: if (pnlStereoscopicOn != on || pnlStereoscopicMethod != method) {
1088: pnlStereoscopicMethod = method;
1089: pnlStereoscopicFactor = on && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1090: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1091: if (!pnlStereoscopicOn && on) {
1092: if (PNL_USE_THREAD) {
1093: for (int n = 0; n < 4; n++) {
1094: System.arraycopy (pnlBMLeftArray[n], 0, pnlBMRightArray[n], 0, 1024 * 1024);
1095: }
1096: } else {
1097: System.arraycopy (pnlBMLeft, 0, pnlBMRight, 0, 1024 * 1024);
1098: }
1099: } else if (pnlStereoscopicOn && !on) {
1100: if (PNL_USE_THREAD) {
1101: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
1102: } else {
1103: pnlBM = pnlBMLeft;
1104: }
1105: }
1106: pnlStereoscopicOn = on;
1107: pnlUpdateArrangement ();
1108: }
1109: }
1110:
1111:
1112: public static void pnlTini () {
1113: pnlTini2 ();
1114: if (PNL_USE_THREAD) {
1115: if (pnlThread != null) {
1116: pnlThread.interrupt ();
1117: try {
1118: pnlThread.join ();
1119: } catch (InterruptedException ie) {
1120: }
1121: pnlThread = null;
1122: }
1123: }
1124:
1125:
1126: Settings.sgsPutInt ("fixedscale", pnlFixedScale);
1127:
1128:
1129: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
1130: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[key];
1131: int value = pnlAspectMap[key];
1132: String screenName = PNL_ASPECT_SCREEN_NAME[value];
1133: Settings.sgsPutString ("aspectratio" + resolutionName, screenName);
1134: }
1135:
1136:
1137: Settings.sgsPutString ("interpolation",
1138: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR ? "nearest" :
1139: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR ? "bilinear" :
1140: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC ? "bicubic" :
1141: "bilinear");
1142:
1143: if (pnlRefreshRate != PNL_DEFAULT_RATE) {
1144: Settings.sgsPutString ("refreshrate",
1145: pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate));
1146: }
1147: Settings.sgsPutOnOff ("adjustvsync", pnlAdjustVsync);
1148:
1149: Settings.sgsPutOnOff ("hidekeyboard", pnlHideKeyboard);
1150:
1151: if (PNL_USE_CANVAS) {
1152: Settings.sgsPutOnOff ("usecanvas", pnlUseCanvasRequest);
1153: }
1154:
1155:
1156: Settings.sgsPutOnOff ("stereoscopic", pnlStereoscopicOn);
1157: Settings.sgsPutString ("stereoscopicmethod",
1158: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ? "nakedeyecrossing" :
1159: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL ? "nakedeyeparallel" :
1160: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ? "sidebyside" :
1161: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM ? "topandbottom" :
1162: "nakedeyecrossing");
1163:
1164:
1165: if (PNL_ROTATION_ON) {
1166: Settings.sgsPutInt ("rotation", pnlRotationMode);
1167: }
1168:
1169: }
1170:
1171:
1172:
1173: public static void pnlUpdateAspectTable () {
1174: float[] ratio = new float[PNL_ASPECT_KEYS];
1175: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
1176: int value = pnlAspectMap[key];
1177: ratio[key] = PNL_ASPECT_MATRIX[key][value];
1178: }
1179: pnlAspectTable[0] = ratio[0] * 2.0F;
1180: pnlAspectTable[1] = ratio[2];
1181: pnlAspectTable[2] = ratio[3];
1182: pnlAspectTable[3] = ratio[3];
1183: pnlAspectTable[4] = ratio[1] * 4.0F;
1184: pnlAspectTable[5] = ratio[1] * 2.0F;
1185: pnlAspectTable[6] = ratio[3];
1186: pnlAspectTable[7] = ratio[3];
1187: }
1188:
1189:
1190:
1191: public static void pnlMake () {
1192: pnlMake2 ();
1193:
1194:
1195: if (PNL_USE_CANVAS && pnlUseCanvas) {
1196: pnlCanvas = new Canvas ();
1197: pnlPanel = new JPanel (new BorderLayout (0, 0));
1198: pnlPanel.add (pnlCanvas, BorderLayout.CENTER);
1199: pnlCanvasOrPanel = pnlCanvas;
1200: } else {
1201: pnlPanel = new JPanel () {
1202: @Override protected void paintComponent (Graphics g) {
1203: pnlPaintCommon (g);
1204: }
1205: @Override protected void paintBorder (Graphics g) {
1206: }
1207: @Override protected void paintChildren (Graphics g) {
1208: }
1209: };
1210: pnlCanvasOrPanel = pnlPanel;
1211: }
1212: pnlPanel.setBackground (Color.black);
1213: pnlPanel.setOpaque (true);
1214: pnlPanel.setPreferredSize (pnlSize);
1215:
1216: if (Mouse.musCursorAvailable) {
1217: pnlPanel.setCursor (Mouse.musCursorArray[1]);
1218: }
1219:
1220: }
1221:
1222:
1223:
1224: public static void pnlPaintCommon (Graphics g) {
1225: Graphics2D g2 = (Graphics2D) g;
1226: if (PNL_FILL_BACKGROUND || pnlFillBackgroundRequest) {
1227: if (!PNL_FILL_BACKGROUND) {
1228: pnlFillBackgroundRequest = false;
1229: }
1230: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1231: g2.setColor (Color.black);
1232: g2.fillRect (0, 0, pnlWidth, pnlHeight);
1233: }
1234: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, pnlInterpolation);
1235: if (PNL_USE_THREAD) {
1236: int d = pnlBMWrite - pnlBMRead;
1237: if (false) {
1238: System.out.print (d);
1239: }
1240: if (d < 1) {
1241: pnlBMRead += d - 1;
1242: } else if (3 < d) {
1243: pnlBMRead += d - 3;
1244: }
1245: int n = pnlBMRead++ & 3;
1246: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1247: BufferedImage leftImage;
1248: BufferedImage rightImage;
1249: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1250: leftImage = pnlScreenImageRightArray[n];
1251: rightImage = pnlScreenImageLeftArray[n];
1252: } else {
1253:
1254:
1255:
1256: leftImage = pnlScreenImageLeftArray[n];
1257: rightImage = pnlScreenImageRightArray[n];
1258: }
1259: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1260: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1261: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1262: } else {
1263: g2.drawImage (leftImage,
1264: pnlScreenX1, pnlScreenY1,
1265: pnlScreenX2, pnlScreenY2,
1266: 0, 0, pnlScreenWidth, pnlScreenHeight,
1267: null);
1268: g2.drawImage (rightImage,
1269: pnlScreenX3, pnlScreenY3,
1270: pnlScreenX4, pnlScreenY4,
1271: 0, 0, pnlScreenWidth, pnlScreenHeight,
1272: null);
1273: }
1274: } else {
1275: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1276: g2.drawImage (pnlScreenSubImageLeftArray[n], pnlRotationTransformLeft, null);
1277: } else {
1278: g2.drawImage (pnlScreenImageLeftArray[n],
1279: pnlScreenX1, pnlScreenY1,
1280: pnlScreenX2, pnlScreenY2,
1281: 0, 0, pnlScreenWidth, pnlScreenHeight,
1282: null);
1283: }
1284: }
1285: } else {
1286: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1287: BufferedImage leftImage;
1288: BufferedImage rightImage;
1289: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1290: leftImage = pnlScreenImageRight;
1291: rightImage = pnlScreenImageLeft;
1292: } else {
1293:
1294:
1295:
1296: leftImage = pnlScreenImageLeft;
1297: rightImage = pnlScreenImageRight;
1298: }
1299: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1300: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1301: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1302: } else {
1303: g2.drawImage (leftImage,
1304: pnlScreenX1, pnlScreenY1,
1305: pnlScreenX2, pnlScreenY2,
1306: 0, 0, pnlScreenWidth, pnlScreenHeight,
1307: null);
1308: g2.drawImage (rightImage,
1309: pnlScreenX3, pnlScreenY3,
1310: pnlScreenX4, pnlScreenY4,
1311: 0, 0, pnlScreenWidth, pnlScreenHeight,
1312: null);
1313: }
1314: } else {
1315: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1316: g2.drawImage (pnlScreenImageLeft, pnlRotationTransformLeft, null);
1317: } else {
1318: g2.drawImage (pnlScreenImageLeft,
1319: pnlScreenX1, pnlScreenY1,
1320: pnlScreenX2, pnlScreenY2,
1321: 0, 0, pnlScreenWidth, pnlScreenHeight,
1322: null);
1323: }
1324: }
1325: }
1326: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1327: g2.drawImage (Keyboard.kbdImage, pnlKeyboardX, pnlKeyboardY, null);
1328:
1329: if (TextCopy.txcEncloseEachTime && 0 <= TextCopy.txcRow1) {
1330: int x = TextCopy.txcCol1 << 3;
1331: int w = (TextCopy.txcCol2 - TextCopy.txcCol1 + 1) << 3;
1332: int y = TextCopy.txcRow1 << 4;
1333: int h = (TextCopy.txcRow2 - TextCopy.txcRow1 + 1) << 4;
1334: x -= CRTC.crtR10TxXCurr;
1335: y -= CRTC.crtR11TxYCurr;
1336: g2.setColor (Color.red);
1337: if (PNL_ROTATION_ON) {
1338: AffineTransform savedTransform = g2.getTransform ();
1339: g2.setTransform (pnlRotationTransformLeft);
1340: g2.drawRect (x, y, w, h);
1341: g2.setTransform (savedTransform);
1342: } else {
1343: g2.drawRect (pnlScreenX1 + ((x * pnlZoomRatioOutX) >> 16),
1344: pnlScreenY1 + ((y * pnlZoomRatioOutY) >> 16),
1345: ((w * pnlZoomRatioOutX) >> 16) - 1,
1346: ((h * pnlZoomRatioOutY) >> 16) - 1);
1347: }
1348: }
1349: if (Bubble.BBL_ON) {
1350: Bubble.bblDraw (g2);
1351: }
1352: }
1353:
1354:
1355:
1356:
1357: public static void pnlStart () {
1358: pnlStart2 ();
1359:
1360:
1361: ComponentFactory.addListener (
1362: pnlPanel,
1363: new ComponentAdapter () {
1364: @Override public void componentResized (ComponentEvent ce) {
1365: pnlUpdateArrangement ();
1366: }
1367: });
1368:
1369: if (PNL_USE_THREAD) {
1370: if (PNL_USE_CANVAS && pnlUseCanvas) {
1371: pnlCanvas.createBufferStrategy (2);
1372: pnlThread = new Thread () {
1373: @Override public void run () {
1374: do {
1375: BufferStrategy bs = pnlCanvas.getBufferStrategy ();
1376: if (bs != null) {
1377: Graphics g = bs.getDrawGraphics ();
1378: pnlPaintCommon (g);
1379: g.dispose ();
1380: bs.show ();
1381: }
1382: } while (!isInterrupted () && pnlWakeupCommon ());
1383: }
1384: };
1385: } else {
1386: pnlThread = new Thread () {
1387: @Override public void run () {
1388: do {
1389: pnlPanel.repaint ();
1390: if (!pnlWakeupCommon ()) {
1391: break;
1392: }
1393: } while (!isInterrupted () && pnlWakeupCommon ());
1394: }
1395: };
1396: }
1397: pnlWakeupTime = System.currentTimeMillis ();
1398: pnlWakeupTimeMNP = 0L;
1399: pnlThread.start ();
1400: }
1401:
1402: }
1403:
1404: public static boolean pnlWakeupCommon () {
1405: long t = System.currentTimeMillis ();
1406: if (CRTC.crtTotalLength == 0L) {
1407: pnlWakeupTime += 40L;
1408: } else {
1409: pnlWakeupTime += CRTC.crtTotalLength;
1410: pnlWakeupTimeMNP += CRTC.crtTotalLengthMNP;
1411: if (1000000000L <= pnlWakeupTimeMNP) {
1412: pnlWakeupTime++;
1413: pnlWakeupTimeMNP -= 1000000000L;
1414: }
1415: }
1416: pnlWakeupTime = Math.max (pnlWakeupTime, t + 4L);
1417: try {
1418: Thread.sleep (pnlWakeupTime - t);
1419: } catch (InterruptedException ie) {
1420: return false;
1421: }
1422: return true;
1423: }
1424:
1425:
1426:
1427:
1428:
1429: public static void pnlExitFullScreen (boolean dialog) {
1430: if (prgIsMac || !dialog) {
1431: pnlSetFullScreenOn (false);
1432: }
1433: }
1434:
1435:
1436:
1437: public static void pnlToggleFullScreen () {
1438: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1439: pnlSetMode (PNL_FULLSCREEN);
1440: } else {
1441: pnlSetMode (pnlPrevMode);
1442: }
1443: }
1444:
1445:
1446:
1447: public static void pnlToggleMaximized () {
1448: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1449: pnlSetMode (PNL_MAXIMIZED);
1450: } else {
1451: pnlSetMode (pnlPrevMode);
1452: }
1453: }
1454:
1455:
1456:
1457: public static void pnlSetFullScreenOn (boolean on) {
1458: if (on) {
1459: pnlSetMode (PNL_FULLSCREEN);
1460: } else if (pnlMode == PNL_FULLSCREEN) {
1461: pnlSetMode (pnlPrevMode);
1462: }
1463: }
1464:
1465:
1466:
1467:
1468: public static void pnlSetFitInWindowOn (boolean on) {
1469: if (!on) {
1470: pnlSetMode (PNL_FIXEDSCALE);
1471: } else if (pnlMode == PNL_FIXEDSCALE) {
1472: pnlSetMode (PNL_FITINWINDOW);
1473: }
1474: }
1475:
1476:
1477:
1478:
1479:
1480:
1481:
1482:
1483:
1484:
1485: public static void pnlUpdateArrangement () {
1486: pnlWidth = pnlPanel.getWidth ();
1487: pnlHeight = pnlPanel.getHeight ();
1488: frmMarginWidth = frmFrame.getWidth () - pnlWidth;
1489: frmMarginHeight = frmFrame.getHeight () - pnlHeight;
1490: pnlStretchMode = pnlAspectTable[CRTC.crtHRLCurr << 2 | CRTC.crtHResoCurr];
1491: pnlScreenWidth = Math.max (PNL_MIN_WIDTH, (CRTC.crtR03HDispEndCurr - CRTC.crtR02HBackEndCurr) << 3);
1492: pnlScreenHeight = Math.max (PNL_MIN_HEIGHT, (CRTC.crtR07VDispEndCurr - CRTC.crtR06VBackEndCurr) << (CRTC.crtInterlace || CRTC.crtSlit ? 1 : 0));
1493: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchMode);
1494: if (RasterBreakPoint.RBP_ON) {
1495:
1496: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
1497: RasterBreakPoint.rbpUpdateFrame ();
1498: }
1499: }
1500:
1501: pnlFixedScale = pnlFixedModel.getNumber ().intValue ();
1502:
1503: pnlRotatedWidth = pnlStretchWidth;
1504: pnlRotatedHeight = pnlScreenHeight;
1505: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1506: pnlRotatedWidth = pnlScreenHeight;
1507: pnlRotatedHeight = pnlStretchWidth;
1508: }
1509: if (pnlMode == PNL_FIXEDSCALE) {
1510:
1511:
1512:
1513:
1514:
1515: pnlZoomWidth = (pnlRotatedWidth * pnlFixedScale + 50) * 5243 >>> 19;
1516: pnlZoomHeight = (pnlRotatedHeight * pnlFixedScale + 50) * 5243 >>> 19;
1517: int width = Math.max (Math.max (PNL_MIN_WIDTH, pnlZoomWidth * pnlStereoscopicFactor), Keyboard.kbdWidth);
1518: int height = Math.max (PNL_MIN_HEIGHT, pnlZoomHeight) + Keyboard.kbdHeight;
1519: pnlScreenX1 = (width - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1520: pnlScreenY1 = (height - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1521: if (pnlWidth != width || pnlHeight != height) {
1522: pnlWidth = width;
1523: pnlHeight = height;
1524: pnlMinimumWidth = width;
1525: pnlMinimumHeight = height;
1526: pnlSize.setSize (width, height);
1527: pnlPanel.setMinimumSize (pnlSize);
1528: pnlPanel.setMaximumSize (pnlSize);
1529: pnlPanel.setPreferredSize (pnlSize);
1530: }
1531: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1532: frmFrame.setMinimumSize (frmMinimumSize);
1533: frmFrame.setMaximumSize (frmMinimumSize);
1534: frmFrame.setPreferredSize (frmMinimumSize);
1535: frmFrame.setResizable (false);
1536: frmFrame.pack ();
1537: } else {
1538:
1539: if (pnlWidth * pnlRotatedHeight >= (pnlHeight - Keyboard.kbdHeight) * (pnlRotatedWidth * pnlStereoscopicFactor)) {
1540:
1541:
1542:
1543:
1544:
1545:
1546:
1547:
1548:
1549:
1550:
1551:
1552: pnlZoomHeight = pnlHeight - Keyboard.kbdHeight;
1553: pnlZoomWidth = (pnlZoomHeight * pnlRotatedWidth + (pnlRotatedHeight >> 1)) / pnlRotatedHeight;
1554: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1555: pnlScreenX1 = ((pnlWidth >> 1) - (pnlZoomWidth >> 1)) >> 1;
1556: } else {
1557: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1558: }
1559: pnlScreenY1 = 0;
1560: } else {
1561:
1562:
1563:
1564:
1565:
1566:
1567:
1568:
1569:
1570:
1571:
1572:
1573:
1574:
1575:
1576:
1577: pnlZoomWidth = pnlWidth / pnlStereoscopicFactor;
1578: pnlZoomHeight = (pnlZoomWidth * pnlStereoscopicFactor * pnlRotatedHeight + (pnlRotatedWidth * pnlStereoscopicFactor >> 1)) / (pnlRotatedWidth * pnlStereoscopicFactor);
1579: pnlScreenX1 = 0;
1580: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM) {
1581: pnlScreenY1 = (((pnlHeight - Keyboard.kbdHeight) >> 1) - (pnlZoomHeight >> 1)) >> 1;
1582: } else {
1583: pnlScreenY1 = (pnlHeight - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1584: }
1585: }
1586:
1587: int minimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
1588: int minimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
1589: if (pnlMinimumWidth != minimumWidth || pnlMinimumHeight != minimumHeight) {
1590: pnlMinimumWidth = minimumWidth;
1591: pnlMinimumHeight = minimumHeight;
1592: }
1593: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1594: frmFrame.setMinimumSize (frmMinimumSize);
1595: frmFrame.setMaximumSize (null);
1596: frmFrame.setResizable (true);
1597: }
1598:
1599: pnlArrangementCommon ();
1600: Mouse.musUpdateSpeedRatio ();
1601: if (!PNL_FILL_BACKGROUND) {
1602: pnlFillBackgroundRequest = true;
1603: }
1604: }
1605:
1606: public static void pnlArrangementCommon () {
1607: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1608: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1609: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) {
1610: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1611: pnlScreenX3 = pnlScreenX2;
1612: pnlScreenX4 = pnlScreenX3 + pnlZoomWidth;
1613: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1614: pnlScreenY3 = pnlScreenY1;
1615: pnlScreenY4 = pnlScreenY2;
1616: } else if (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1617: pnlScreenX2 = pnlScreenX1 + (pnlZoomWidth >> 1);
1618: pnlScreenX3 = pnlScreenX2;
1619: pnlScreenX4 = pnlScreenX3 + (pnlZoomWidth >> 1);
1620: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1621: pnlScreenY3 = pnlScreenY1;
1622: pnlScreenY4 = pnlScreenY2;
1623: } else {
1624: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1625: pnlScreenX3 = pnlScreenX1;
1626: pnlScreenX4 = pnlScreenX2;
1627: pnlScreenY2 = pnlScreenY1 + (pnlZoomHeight >> 1);
1628: pnlScreenY3 = pnlScreenY2;
1629: pnlScreenY4 = pnlScreenY3 + (pnlZoomHeight >> 1);
1630: }
1631: } else {
1632: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1633: pnlScreenX3 = pnlScreenX1;
1634: pnlScreenX4 = pnlScreenX2;
1635: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1636: pnlScreenY3 = pnlScreenY1;
1637: pnlScreenY4 = pnlScreenY2;
1638: }
1639: pnlKeyboardX = (pnlWidth - Keyboard.kbdWidth) >> 1;
1640: pnlKeyboardY = pnlScreenY4;
1641: pnlZoomRatioOutX = ((pnlZoomWidth * pnlStereoscopicFactor) << 16) / pnlScreenWidth;
1642: pnlZoomRatioOutY = (pnlZoomHeight << 16) / pnlScreenHeight;
1643: pnlZoomRatioInX = (pnlScreenWidth << 16) / (pnlZoomWidth * pnlStereoscopicFactor);
1644: pnlZoomRatioInY = (pnlScreenHeight << 16) / pnlZoomHeight;
1645: if (PNL_ROTATION_ON) {
1646:
1647: if (PNL_USE_THREAD) {
1648: for (int n = 0; n < 4; n++) {
1649: pnlScreenSubImageLeftArray[n] = pnlScreenImageLeftArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1650: pnlScreenSubImageRightArray[n] = pnlScreenImageRightArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1651: }
1652: } else {
1653: pnlScreenSubImageLeft = pnlScreenImageLeft.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1654: pnlScreenSubImageRight = pnlScreenImageRight.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1655: }
1656:
1657:
1658:
1659:
1660: double ax = 0.0;
1661: double ay = 0.0;
1662: double bx = (double) pnlScreenWidth;
1663: double by = (double) pnlScreenHeight;
1664: double l00, l10, l01, l11, l02, l12;
1665: double r00, r10, r01, r11, r02, r12;
1666: if (pnlRotationMode == 0) {
1667: double cx = (double) pnlScreenX1;
1668: double cy = (double) pnlScreenY1;
1669: double dx = (double) pnlScreenX2;
1670: double dy = (double) pnlScreenY2;
1671: l00 = (cx - dx) / (ax - bx);
1672: l10 = 0.0;
1673: l01 = 0.0;
1674: l11 = (cy - dy) / (ay - by);
1675: l02 = (ax * dx - bx * cx) / (ax - bx);
1676: l12 = (ay * dy - by * cy) / (ay - by);
1677: cx = (double) pnlScreenX3;
1678: cy = (double) pnlScreenY3;
1679: dx = (double) pnlScreenX4;
1680: dy = (double) pnlScreenY4;
1681: r00 = (cx - dx) / (ax - bx);
1682: r10 = 0.0;
1683: r01 = 0.0;
1684: r11 = (cy - dy) / (ay - by);
1685: r02 = (ax * dx - bx * cx) / (ax - bx);
1686: r12 = (ay * dy - by * cy) / (ay - by);
1687: } else if (pnlRotationMode == 1) {
1688: double cx = (double) pnlScreenX1;
1689: double cy = (double) pnlScreenY1;
1690: double dx = (double) pnlScreenX2;
1691: double dy = (double) pnlScreenY2;
1692: l00 = 0.0;
1693: l10 = (dy - cy) / (ax - bx);
1694: l01 = (cx - dx) / (ay - by);
1695: l11 = 0.0;
1696: l02 = (ay * dx - by * cx) / (ay - by);
1697: l12 = (ax * cy - bx * dy) / (ax - bx);
1698: cx = (double) pnlScreenX3;
1699: cy = (double) pnlScreenY3;
1700: dx = (double) pnlScreenX4;
1701: dy = (double) pnlScreenY4;
1702: r00 = 0.0;
1703: r10 = (dy - cy) / (ax - bx);
1704: r01 = (cx - dx) / (ay - by);
1705: r11 = 0.0;
1706: r02 = (ay * dx - by * cx) / (ay - by);
1707: r12 = (ax * cy - bx * dy) / (ax - bx);
1708: } else if (pnlRotationMode == 2) {
1709: double cx = (double) pnlScreenX1;
1710: double cy = (double) pnlScreenY1;
1711: double dx = (double) pnlScreenX2;
1712: double dy = (double) pnlScreenY2;
1713: l00 = (dx - cx) / (ax - bx);
1714: l10 = 0.0;
1715: l01 = 0.0;
1716: l11 = (dy - cy) / (ay - by);
1717: l02 = (ax * cx - bx * dx) / (ax - bx);
1718: l12 = (ay * cy - by * dy) / (ay - by);
1719: cx = (double) pnlScreenX3;
1720: cy = (double) pnlScreenY3;
1721: dx = (double) pnlScreenX4;
1722: dy = (double) pnlScreenY4;
1723: r00 = (dx - cx) / (ax - bx);
1724: r10 = 0.0;
1725: r01 = 0.0;
1726: r11 = (dy - cy) / (ay - by);
1727: r02 = (ax * cx - bx * dx) / (ax - bx);
1728: r12 = (ay * cy - by * dy) / (ay - by);
1729: } else {
1730: double cx = (double) pnlScreenX1;
1731: double cy = (double) pnlScreenY1;
1732: double dx = (double) pnlScreenX2;
1733: double dy = (double) pnlScreenY2;
1734: l00 = 0.0;
1735: l10 = (cy - dy) / (ax - bx);
1736: l01 = (dx - cx) / (ay - by);
1737: l11 = 0.0;
1738: l02 = (ay * cx - by * dx) / (ay - by);
1739: l12 = (ax * dy - bx * cy) / (ax - bx);
1740: cx = (double) pnlScreenX3;
1741: cy = (double) pnlScreenY3;
1742: dx = (double) pnlScreenX4;
1743: dy = (double) pnlScreenY4;
1744: r00 = 0.0;
1745: r10 = (cy - dy) / (ax - bx);
1746: r01 = (dx - cx) / (ay - by);
1747: r11 = 0.0;
1748: r02 = (ay * cx - by * dx) / (ay - by);
1749: r12 = (ax * dy - bx * cy) / (ax - bx);
1750: }
1751: pnlRotationTransformLeft.setTransform (l00, l10, l01, l11, l02, l12);
1752: pnlRotationTransformRight.setTransform (r00, r10, r01, r11, r02, r12);
1753: pnlMatrixL00 = l00;
1754: pnlMatrixL10 = l10;
1755: pnlMatrixL01 = l01;
1756: pnlMatrixL11 = l11;
1757: pnlMatrixL02 = l02;
1758: pnlMatrixL12 = l12;
1759: pnlMatrixR00 = r00;
1760: pnlMatrixR10 = r10;
1761: pnlMatrixR01 = r01;
1762: pnlMatrixR11 = r11;
1763: pnlMatrixR02 = r02;
1764: pnlMatrixR12 = r12;
1765:
1766:
1767:
1768:
1769:
1770:
1771: double d = l00 * l11 - l01 * l10;
1772: pnlInverseL00 = l11 / d;
1773: pnlInverseL10 = -l10 / d;
1774: pnlInverseL01 = -l01 / d;
1775: pnlInverseL11 = l00 / d;
1776: pnlInverseL02 = (l01 * l12 - l02 * l11) / d;
1777: pnlInverseL12 = (l02 * l10 - l00 * l12) / d;
1778: d = r00 * r11 - r01 * r10;
1779: pnlInverseR00 = r11 / d;
1780: pnlInverseR10 = -r10 / d;
1781: pnlInverseR01 = -r01 / d;
1782: pnlInverseR11 = r00 / d;
1783: pnlInverseR02 = (r01 * r12 - r02 * r11) / d;
1784: pnlInverseR12 = (r02 * r10 - r00 * r12) / d;
1785: }
1786: }
1787:
1788:
1789:
1790:
1791: public static final int PNL_UNDEFINED = 0;
1792: public static final int PNL_FIXEDSCALE = 1;
1793: public static final int PNL_FITINWINDOW = 2;
1794: public static final int PNL_FULLSCREEN = 3;
1795: public static final int PNL_MAXIMIZED = 4;
1796: public static int pnlModeRequest;
1797: public static int pnlMode;
1798: public static int pnlPrevMode;
1799:
1800:
1801: public static JRadioButtonMenuItem mnbFullScreenMenuItem;
1802: public static JRadioButtonMenuItem mnbMaximizedMenuItem;
1803: public static JRadioButtonMenuItem mnbFitInWindowMenuItem;
1804: public static JRadioButtonMenuItem mnbFixedScaleMenuItem;
1805:
1806:
1807: public static int PNL_BOOT_DELAY = 500;
1808: public static javax.swing.Timer pnlBootTimer;
1809:
1810:
1811:
1812: public static void pnlInit2 () {
1813: pnlModeRequest = PNL_UNDEFINED;
1814: pnlMode = PNL_FITINWINDOW;
1815: pnlPrevMode = PNL_FITINWINDOW;
1816: switch (Settings.sgsGetString ("scaling").toLowerCase ()) {
1817: case "fullscreen":
1818: pnlModeRequest = PNL_FULLSCREEN;
1819: break;
1820: case "maximized":
1821: pnlModeRequest = PNL_MAXIMIZED;
1822: break;
1823: case "fitinwindow":
1824: break;
1825: case "fixedscale":
1826: pnlMode = PNL_FIXEDSCALE;
1827: break;
1828: }
1829: }
1830:
1831:
1832:
1833: public static void pnlTini2 () {
1834: Settings.sgsPutString ("scaling",
1835: pnlMode == PNL_FULLSCREEN ? "fullscreen" :
1836: pnlMode == PNL_MAXIMIZED ? "maximized" :
1837: pnlMode == PNL_FITINWINDOW ? "fitinwindow" :
1838: "fixedscale");
1839: }
1840:
1841:
1842:
1843: public static void pnlMake2 () {
1844:
1845: ActionListener listener = new ActionListener () {
1846: @Override public void actionPerformed (ActionEvent ae) {
1847: String command = ae.getActionCommand ();
1848: switch (command) {
1849: case "Full screen":
1850: pnlSetMode (PNL_FULLSCREEN);
1851: break;
1852: case "Maximized":
1853: pnlSetMode (PNL_MAXIMIZED);
1854: break;
1855: case "Fit in window":
1856: pnlSetMode (PNL_FITINWINDOW);
1857: break;
1858: case "Fixed scale":
1859: pnlSetMode (PNL_FIXEDSCALE);
1860: break;
1861: }
1862: }
1863: };
1864: ButtonGroup group = new ButtonGroup ();
1865: mnbFullScreenMenuItem = ComponentFactory.setEnabled (
1866: Multilingual.mlnText (
1867: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FULLSCREEN, "Full screen", listener),
1868: "ja", "全画面表示"),
1869: pnlIsFullScreenSupported);
1870: mnbMaximizedMenuItem = Multilingual.mlnText (
1871: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_MAXIMIZED, "Maximized", listener),
1872: "ja", "最大化");
1873: mnbFitInWindowMenuItem = Multilingual.mlnText (
1874: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FITINWINDOW, "Fit in window", 'W', MNB_MODIFIERS, listener),
1875: "ja", "ウインドウに合わせる");
1876: mnbFixedScaleMenuItem = Multilingual.mlnText (
1877: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FIXEDSCALE, "Fixed scale", 'X', MNB_MODIFIERS, listener),
1878: "ja", "固定倍率");
1879: }
1880:
1881:
1882:
1883: public static void pnlStart2 () {
1884:
1885: frmFrame.addWindowStateListener (new WindowStateListener () {
1886: @Override public void windowStateChanged (WindowEvent we) {
1887: int state = frmFrame.getExtendedState ();
1888: if (pnlMode != PNL_MAXIMIZED &&
1889: (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
1890: pnlSetMode (PNL_MAXIMIZED);
1891: } else if (pnlMode == PNL_MAXIMIZED &&
1892: (state & Frame.MAXIMIZED_BOTH) != Frame.MAXIMIZED_BOTH) {
1893: pnlSetMode (pnlPrevMode);
1894: }
1895: }
1896: });
1897: }
1898:
1899:
1900:
1901: public static void pnlBoot2 () {
1902: if (pnlModeRequest != PNL_UNDEFINED) {
1903: pnlBootTimer = new javax.swing.Timer (PNL_BOOT_DELAY, new ActionListener () {
1904: public void actionPerformed (ActionEvent ae) {
1905: if (pnlModeRequest == PNL_FULLSCREEN) {
1906: mnbFullScreenMenuItem.doClick ();
1907: } else if (pnlModeRequest == PNL_MAXIMIZED) {
1908: mnbMaximizedMenuItem.doClick ();
1909: }
1910: pnlBootTimer.stop ();
1911: pnlBootTimer = null;
1912: }
1913: });
1914: pnlBootTimer.start ();
1915: }
1916: }
1917:
1918:
1919:
1920: public static void pnlSetMode (int mode) {
1921: do {
1922:
1923: if (pnlMode == mode) {
1924: break;
1925: }
1926:
1927: String text = null;
1928: if (mode == PNL_FULLSCREEN) {
1929: if (!pnlIsFullScreenSupported) {
1930: JOptionPane.showMessageDialog (
1931: frmFrame,
1932: Multilingual.mlnJapanese ?
1933: "全画面表示に対応していません" :
1934: "Full screen is not supported");
1935: break;
1936: }
1937: if (Bubble.BBL_ON) {
1938: text = ButtonFunction.bfnFullScreenText ();
1939: if (text == null) {
1940: JOptionPane.showMessageDialog (
1941: frmFrame,
1942: Multilingual.mlnJapanese ?
1943: "全画面表示を終了するキーまたはボタンがありません" :
1944: "No key or button to exit full screen");
1945: break;
1946: }
1947: }
1948: }
1949:
1950: if (pnlMode == PNL_FULLSCREEN) {
1951: pnlMode = pnlPrevMode;
1952: if (Bubble.BBL_ON) {
1953: Bubble.bblEnd ();
1954: }
1955: if (frmScreenDevice.getFullScreenWindow () == frmFrame) {
1956: frmScreenDevice.setFullScreenWindow (null);
1957: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.FRAME);
1958: }
1959: frmFrame.setJMenuBar (mnbMenuBar);
1960: if (pnlHideKeyboard) {
1961: if (pnlPrevKeyboardOn) {
1962: Keyboard.kbdSetOn (true);
1963: }
1964: }
1965: } else if (pnlMode == PNL_MAXIMIZED) {
1966: pnlMode = pnlPrevMode;
1967: if ((frmFrame.getExtendedState () & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
1968: frmFrame.setExtendedState (Frame.NORMAL);
1969: }
1970: }
1971:
1972: if (mode == PNL_FULLSCREEN) {
1973: pnlPrevMode = pnlMode;
1974: if (pnlHideKeyboard) {
1975: pnlPrevKeyboardOn = Keyboard.kbdImage != null;
1976: if (pnlPrevKeyboardOn) {
1977: Keyboard.kbdSetOn (false);
1978: }
1979: }
1980: frmFrame.setJMenuBar (null);
1981: if (frmScreenDevice.getFullScreenWindow () != frmFrame) {
1982: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.NONE);
1983: frmScreenDevice.setFullScreenWindow (frmFrame);
1984: }
1985: if (Bubble.BBL_ON) {
1986: if (text != null) {
1987: Bubble.bblStart (text + (Multilingual.mlnJapanese ? "で全画面表示を終了" : " to exit full screen"), 5000L);
1988: }
1989: }
1990: } else if (mode == PNL_MAXIMIZED) {
1991: pnlPrevMode = pnlMode;
1992: frmFrame.setExtendedState (Frame.MAXIMIZED_BOTH);
1993: }
1994: pnlMode = mode;
1995:
1996:
1997: pnlUpdateArrangement ();
1998: } while (false);
1999:
2000: if (pnlMode == PNL_FIXEDSCALE) {
2001: if (!mnbFixedScaleMenuItem.isSelected ()) {
2002: mnbFixedScaleMenuItem.setSelected (true);
2003: }
2004: } else if (pnlMode == PNL_FITINWINDOW) {
2005: if (!mnbFitInWindowMenuItem.isSelected ()) {
2006: mnbFitInWindowMenuItem.setSelected (true);
2007: }
2008: } else if (pnlMode == PNL_FULLSCREEN) {
2009: if (!mnbFullScreenMenuItem.isSelected ()) {
2010: mnbFullScreenMenuItem.setSelected (true);
2011: }
2012: } else if (pnlMode == PNL_MAXIMIZED) {
2013: if (!mnbMaximizedMenuItem.isSelected ()) {
2014: mnbMaximizedMenuItem.setSelected (true);
2015: }
2016: }
2017: }
2018:
2019:
2020:
2021:
2022:
2023:
2024: public static Robot rbtRobot;
2025:
2026:
2027: public static void rbtInit () {
2028:
2029:
2030: rbtRobot = null;
2031: try {
2032: rbtRobot = new Robot ();
2033: } catch (Exception e) {
2034: }
2035:
2036: }
2037:
2038:
2039:
2040:
2041:
2042:
2043:
2044: public static final int MNB_MODIFIERS = InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK;
2045:
2046:
2047: public static JMenuBar mnbMenuBar;
2048:
2049:
2050: public static JMenu mnbFileMenu;
2051: public static JMenu mnbDisplayMenu;
2052: public static JMenu mnbSoundMenu;
2053: public static JMenu mnbInputMenu;
2054: public static JMenu mnbConfigMenu;
2055: public static JMenu mnbLanguageMenu;
2056:
2057:
2058:
2059:
2060:
2061: public static JMenuItem mnbQuitMenuItem;
2062: public static JCheckBoxMenuItem mnbStereoscopicMenuItem;
2063: public static JCheckBoxMenuItem mnbPlayMenuItem;
2064: public static JMenuItem mnbPasteMenuItem;
2065: public static JRadioButtonMenuItem mnbStandardKeyboardMenuItem;
2066: public static JRadioButtonMenuItem mnbCompactKeyboardMenuItem;
2067: public static JRadioButtonMenuItem mnbNoKeyboardMenuItem;
2068: public static JLabel mnbVolumeLabel;
2069:
2070:
2071:
2072:
2073:
2074:
2075: public static JMenu mnbMakeFontSizeMenu () {
2076:
2077: ActionListener actionListener = new ActionListener () {
2078: @Override public void actionPerformed (ActionEvent ae) {
2079: String command = ae.getActionCommand ();
2080: switch (command) {
2081: case "Very small":
2082: LnF.lnfFontSizeRequest = 10;
2083: break;
2084: case "Small":
2085: LnF.lnfFontSizeRequest = 12;
2086: break;
2087: case "Medium":
2088: LnF.lnfFontSizeRequest = 14;
2089: break;
2090: case "Large":
2091: LnF.lnfFontSizeRequest = 16;
2092: break;
2093: case "Very large":
2094: LnF.lnfFontSizeRequest = 18;
2095: break;
2096: default:
2097: System.out.println ("unknown action command " + command);
2098: }
2099: }
2100: };
2101:
2102: ButtonGroup fontSizeGroup = new ButtonGroup ();
2103:
2104: return Multilingual.mlnText (
2105: ComponentFactory.createMenu (
2106: "Font size",
2107: Multilingual.mlnText (
2108: ComponentFactory.pointSize (
2109: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 10, "Very small", actionListener),
2110: 10),
2111: "ja", "極小"),
2112: Multilingual.mlnText (
2113: ComponentFactory.pointSize (
2114: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 12, "Small", actionListener),
2115: 12),
2116: "ja", "小"),
2117: Multilingual.mlnText (
2118: ComponentFactory.pointSize (
2119: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 14, "Medium", actionListener),
2120: 14),
2121: "ja", "中"),
2122: Multilingual.mlnText (
2123: ComponentFactory.pointSize (
2124: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 16, "Large", actionListener),
2125: 16),
2126: "ja", "大"),
2127: Multilingual.mlnText (
2128: ComponentFactory.pointSize (
2129: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 18, "Very large", actionListener),
2130: 18),
2131: "ja", "極大")),
2132: "ja", "フォントサイズ");
2133: }
2134:
2135:
2136:
2137: public static final DecimalSpinner[] mnbColorSpinners = new DecimalSpinner[9];
2138: public static final int[] mnbColorRGB = new int[15];
2139: public static JPanel mnbColorPanel;
2140:
2141:
2142:
2143: public static void mnbColorHSBToRGB () {
2144: for (int i = 0; i <= 14; i++) {
2145: int[] t = LnF.LNF_HSB_INTERPOLATION_TABLE[i];
2146: float h = (float) (t[0] * LnF.lnfHSB[0] + t[1] * LnF.lnfHSB[1] + t[2] * LnF.lnfHSB[2]) / (49.0F * 360.0F);
2147: float s = (float) (t[0] * LnF.lnfHSB[3] + t[1] * LnF.lnfHSB[4] + t[2] * LnF.lnfHSB[5]) / (49.0F * 100.0F);
2148: float b = (float) (t[0] * LnF.lnfHSB[6] + t[1] * LnF.lnfHSB[7] + t[2] * LnF.lnfHSB[8]) / (49.0F * 100.0F);
2149: mnbColorRGB[i] = Color.HSBtoRGB (h,
2150: Math.max (0.0F, Math.min (1.0F, s)),
2151: Math.max (0.0F, Math.min (1.0F, b)));
2152: }
2153: }
2154:
2155:
2156:
2157: public static JMenu mnbMakeColorMenu () {
2158: mnbColorHSBToRGB ();
2159:
2160: mnbColorPanel = ComponentFactory.setColor (
2161: ComponentFactory.setFixedSize (
2162: new JPanel () {
2163: @Override protected void paintComponent (Graphics g) {
2164: super.paintComponent (g);
2165: for (int i = 0; i <= 14; i++) {
2166: g.setColor (new Color (mnbColorRGB[i]));
2167: g.fillRect (LnF.lnfFontSize * i, 0, LnF.lnfFontSize, LnF.lnfFontSize * 5);
2168: }
2169: }
2170: },
2171: LnF.lnfFontSize * 15, LnF.lnfFontSize * 5),
2172: Color.white, Color.black);
2173:
2174: ChangeListener changeListener = new ChangeListener () {
2175: @Override public void stateChanged (ChangeEvent ce) {
2176: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
2177: LnF.lnfHSB[spinner.getOption ()] = spinner.getIntValue ();
2178: mnbColorHSBToRGB ();
2179: mnbColorPanel.repaint ();
2180: }
2181: };
2182:
2183: ActionListener actionListener = new ActionListener () {
2184: @Override public void actionPerformed (ActionEvent ae) {
2185: String command = ae.getActionCommand ();
2186: switch (command) {
2187: case "Reset to default values":
2188: for (int i = 0; i < 9; i++) {
2189: LnF.lnfHSB[i] = LnF.LNF_DEFAULT_HSB[i];
2190: mnbColorSpinners[i].setIntValue (LnF.lnfHSB[i]);
2191: }
2192: mnbColorHSBToRGB ();
2193: mnbColorPanel.repaint ();
2194: break;
2195: default:
2196: System.out.println ("unknown action command " + command);
2197: }
2198: }
2199: };
2200:
2201: for (int i = 0; i < 9; i++) {
2202: mnbColorSpinners[i] = ComponentFactory.createDecimalSpinner (
2203: LnF.lnfHSB[i], 0, i < 3 ? 720 : 100, 1, i, changeListener);
2204: }
2205:
2206: return Multilingual.mlnText (
2207: ComponentFactory.createMenu (
2208: "Color",
2209: ComponentFactory.createHorizontalBox (
2210: mnbColorSpinners[0],
2211: mnbColorSpinners[1],
2212: mnbColorSpinners[2],
2213: ComponentFactory.createLabel ("H °"),
2214: Box.createHorizontalGlue ()
2215: ),
2216: ComponentFactory.createHorizontalBox (
2217: mnbColorSpinners[3],
2218: mnbColorSpinners[4],
2219: mnbColorSpinners[5],
2220: ComponentFactory.createLabel ("S%"),
2221: Box.createHorizontalGlue ()
2222: ),
2223: ComponentFactory.createHorizontalBox (
2224: mnbColorSpinners[6],
2225: mnbColorSpinners[7],
2226: mnbColorSpinners[8],
2227: ComponentFactory.createLabel ("B%"),
2228: Box.createHorizontalGlue ()
2229: ),
2230: ComponentFactory.createHorizontalBox (
2231: ComponentFactory.setLineBorder (mnbColorPanel),
2232: Box.createHorizontalGlue ()
2233: ),
2234: Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset to default values", actionListener), "ja", "初期値に戻す")
2235: ),
2236: "ja", "色");
2237: }
2238:
2239:
2240:
2241:
2242:
2243: public static JMenu mnbMakeLanguageMenu () {
2244:
2245: ActionListener actionListener = new ActionListener () {
2246: @Override public void actionPerformed (ActionEvent ae) {
2247: String command = ae.getActionCommand ();
2248: switch (command) {
2249: case "English":
2250: Multilingual.mlnChange ("en");
2251: break;
2252: case "日本語":
2253: Multilingual.mlnChange ("ja");
2254: break;
2255: default:
2256: System.out.println ("unknown action command " + command);
2257: }
2258: }
2259: };
2260:
2261: ButtonGroup languageGroup = new ButtonGroup ();
2262:
2263: return mnbLanguageMenu = Multilingual.mlnText (
2264: ComponentFactory.createMenu (
2265: "Language", 'L',
2266: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnEnglish, "English", actionListener),
2267: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnJapanese, "日本語", actionListener),
2268: ComponentFactory.createHorizontalSeparator (),
2269: mnbMakeFontSizeMenu (),
2270: mnbMakeColorMenu ()
2271: ),
2272: "ja", "言語");
2273: }
2274:
2275:
2276:
2277:
2278:
2279: public static void mnbMakeMenu () {
2280:
2281:
2282: ActionListener listener = new ActionListener () {
2283: @Override public void actionPerformed (ActionEvent ae) {
2284: Object source = ae.getSource ();
2285: String command = ae.getActionCommand ();
2286: switch (command) {
2287:
2288:
2289: case "Quit":
2290: prgTini ();
2291: break;
2292:
2293:
2294: case "50%":
2295: case "75%":
2296: case "100%":
2297: case "150%":
2298: case "200%":
2299: pnlFixedModel.setValue (Integer.valueOf (Integer.parseInt (command.substring (0, command.length () - 1))));
2300: break;
2301: case "Nearest neighbor":
2302: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
2303: break;
2304: case "Bilinear":
2305: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
2306: break;
2307: case "Bicubic":
2308: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
2309: break;
2310:
2311: case "Use canvas":
2312: pnlUseCanvasRequest = ((JCheckBoxMenuItem) source).isSelected ();
2313: break;
2314:
2315: case "Draw all changed pictures":
2316: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2317: CRTC.crtIntermittentInterval = 0;
2318: }
2319: break;
2320: case "Draw a changed picture once every two times":
2321: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2322: CRTC.crtIntermittentInterval = 1;
2323: }
2324: break;
2325: case "Draw a changed picture once every three times":
2326: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2327: CRTC.crtIntermittentInterval = 2;
2328: }
2329: break;
2330: case "Draw a changed picture once every four times":
2331: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2332: CRTC.crtIntermittentInterval = 3;
2333: }
2334: break;
2335: case "Draw a changed picture once every five times":
2336: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2337: CRTC.crtIntermittentInterval = 4;
2338: }
2339: break;
2340:
2341: case "Stereoscopic viewing":
2342: pnlSetStereoscopic (((JCheckBoxMenuItem) source).isSelected (), pnlStereoscopicMethod);
2343: break;
2344: case "Naked-eye crossing":
2345: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_CROSSING);
2346: break;
2347: case "Naked-eye parallel":
2348: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_PARALLEL);
2349: break;
2350: case "Side-by-side":
2351: pnlSetStereoscopic (pnlStereoscopicOn, PNL_SIDE_BY_SIDE);
2352: break;
2353: case "Top-and-bottom":
2354: pnlSetStereoscopic (pnlStereoscopicOn, PNL_TOP_AND_BOTTOM);
2355: break;
2356:
2357: case "Sprite pattern viewer":
2358: if (SpritePatternViewer.SPV_ON) {
2359: SpritePatternViewer.spvOpen ();
2360: }
2361: break;
2362: case "Screen mode test":
2363: if (ScreenModeTest.SMT_ON) {
2364: ScreenModeTest.smtOpen ();
2365: }
2366: break;
2367:
2368:
2369: case "Play":
2370: SoundSource.sndSetPlayOn (((JCheckBoxMenuItem) source).isSelected ());
2371: break;
2372: case "OPM output":
2373: OPM.opmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2374: break;
2375: case "OPM log":
2376: OPMLog.olgOpen ();
2377: break;
2378:
2379: case "PCM output":
2380: ADPCM.pcmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2381: break;
2382: case "Sound thinning":
2383: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.THINNING_MONO : SoundSource.SNDRateConverter.THINNING_STEREO;
2384: break;
2385: case "Sound linear interpolation":
2386: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.LINEAR_MONO : SoundSource.SNDRateConverter.LINEAR_STEREO;
2387: break;
2388: case "Sound piecewise-constant area interpolation":
2389: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000;
2390: break;
2391: case "Sound linear area interpolation":
2392: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000;
2393: break;
2394: case "Sound monitor":
2395: SoundMonitor.smnOpen ();
2396: break;
2397: case "PCM piecewise-constant interpolation":
2398: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_CONSTANT);
2399: break;
2400: case "PCM linear interpolation":
2401: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_LINEAR);
2402: break;
2403: case "PCM hermite interpolation":
2404: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_HERMITE);
2405: break;
2406: case "PCM 8MHz/4MHz":
2407: ADPCM.pcmOSCFreqRequest = 0;
2408: break;
2409: case "PCM 8MHz/16MHz":
2410: ADPCM.pcmOSCFreqRequest = 1;
2411: break;
2412:
2413:
2414: case "Paste":
2415: CONDevice.conDoPaste ();
2416: break;
2417: case "No keyboard":
2418: Keyboard.kbdSetOn (false);
2419: pnlUpdateArrangement ();
2420: break;
2421: case "Standard keyboard":
2422: Keyboard.kbdSetType (Keyboard.KBD_STANDARD_TYPE);
2423: Keyboard.kbdSetOn (true);
2424: pnlUpdateArrangement ();
2425: break;
2426: case "Compact keyboard":
2427: Keyboard.kbdSetType (Keyboard.KBD_COMPACT_TYPE);
2428: Keyboard.kbdSetOn (true);
2429: pnlUpdateArrangement ();
2430: break;
2431: case "Hide keyboard in full screen":
2432: pnlHideKeyboard = ((JCheckBoxMenuItem) source).isSelected ();
2433: if (pnlMode == PNL_FULLSCREEN) {
2434: pnlUpdateArrangement ();
2435: }
2436: break;
2437: case "Key assignments":
2438: Keyboard.kbdOpen ();
2439: break;
2440: case "Joystick port settings":
2441: PPI.ppiOpen ();
2442: break;
2443:
2444:
2445: case "RS-232C and terminal":
2446: RS232CTerminal.trmOpen ();
2447: break;
2448:
2449: case "Console":
2450: DebugConsole.dgtOpen ();
2451: break;
2452: case "Register list":
2453: RegisterList.drpOpen ();
2454: break;
2455: case "Disassemble list":
2456: DisassembleList.ddpOpen (-1, -1, true);
2457: break;
2458: case "Memory dump list":
2459: MemoryDumpList.dmpOpen (-1, -1, true);
2460: break;
2461: case "Logical space monitor":
2462: LogicalSpaceMonitor.atwOpen ();
2463: break;
2464: case "Physical space monitor":
2465: PhysicalSpaceMonitor.paaOpen ();
2466: break;
2467: case "Address translation caches monitor":
2468: if (ATCMonitor.ACM_ON) {
2469: ATCMonitor.acmOpen ();
2470: }
2471: break;
2472: case "Branch log":
2473: if (BranchLog.BLG_ON) {
2474: BranchLog.blgOpen (BranchLog.BLG_SELECT_NONE);
2475: }
2476: break;
2477: case "Program flow visualizer":
2478: if (ProgramFlowVisualizer.PFV_ON) {
2479: ProgramFlowVisualizer.pfvOpen ();
2480: }
2481: break;
2482: case "Raster break point":
2483: if (RasterBreakPoint.RBP_ON) {
2484: RasterBreakPoint.rbpOpen ();
2485: }
2486: break;
2487: case "Data break point":
2488: if (DataBreakPoint.DBP_ON) {
2489: DataBreakPoint.dbpOpen ();
2490: }
2491: break;
2492: case "Root pointer list":
2493: if (RootPointerList.RTL_ON) {
2494: RootPointerList.rtlOpen ();
2495: }
2496: break;
2497:
2498:
2499: case "Adjust clock to host":
2500: RP5C15.rtcSetByHost ();
2501: break;
2502:
2503:
2504:
2505: case "Printer":
2506: PrinterPort.prnOpen ();
2507: break;
2508:
2509: case "Mouse button status":
2510: Mouse.musOutputButtonStatus = ((JCheckBoxMenuItem) source).isSelected ();
2511: break;
2512:
2513: case "Java runtime environment information":
2514: prgOpenJavaDialog ();
2515: break;
2516: case "Version information":
2517: prgOpenAboutDialog ();
2518: break;
2519: case "XEiJ License":
2520: prgOpenXEiJLicenseDialog ();
2521: break;
2522: case "FSHARP License":
2523: prgOpenSHARPLicenseDialog ();
2524: break;
2525: case "ymfm License":
2526: prgOpenYmfmLicenseDialog ();
2527: break;
2528: case "jSerialComm License":
2529: prgOpenJSerialCommLicenseDialog ();
2530: break;
2531:
2532: default:
2533: System.out.println ("unknown action command " + command);
2534:
2535: }
2536: }
2537: };
2538:
2539:
2540: ActionListener mainMemoryListener = new ActionListener () {
2541: @Override public void actionPerformed (ActionEvent ae) {
2542: Object source = ae.getSource ();
2543: String command = ae.getActionCommand ();
2544: switch (command) {
2545: case "1MB":
2546: MainMemory.mmrMemorySizeRequest = 0x00100000;
2547: break;
2548: case "2MB":
2549: MainMemory.mmrMemorySizeRequest = 0x00200000;
2550: break;
2551: case "4MB":
2552: MainMemory.mmrMemorySizeRequest = 0x00400000;
2553: break;
2554: case "6MB":
2555: MainMemory.mmrMemorySizeRequest = 0x00600000;
2556: break;
2557: case "8MB":
2558: MainMemory.mmrMemorySizeRequest = 0x00800000;
2559: break;
2560: case "10MB":
2561: MainMemory.mmrMemorySizeRequest = 0x00a00000;
2562: break;
2563: case "12MB":
2564: MainMemory.mmrMemorySizeRequest = 0x00c00000;
2565: break;
2566: case "Save contents on exit":
2567: MainMemory.mmrMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2568: break;
2569: }
2570: }
2571: };
2572: ButtonGroup mainMemoryGroup = new ButtonGroup ();
2573: JMenu mainMemoryMenu = Multilingual.mlnText (
2574: ComponentFactory.createMenu (
2575: "Main memory",
2576: Multilingual.mlnText (
2577: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00100000, "1MB", mainMemoryListener),
2578: "ja", "1MB"),
2579: Multilingual.mlnText (
2580: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00200000, "2MB", mainMemoryListener),
2581: "ja", "2MB"),
2582: Multilingual.mlnText (
2583: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00400000, "4MB", mainMemoryListener),
2584: "ja", "4MB"),
2585: Multilingual.mlnText (
2586: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00600000, "6MB", mainMemoryListener),
2587: "ja", "6MB"),
2588: Multilingual.mlnText (
2589: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00800000, "8MB", mainMemoryListener),
2590: "ja", "8MB"),
2591: Multilingual.mlnText (
2592: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00a00000, "10MB", mainMemoryListener),
2593: "ja", "10MB"),
2594: Multilingual.mlnText (
2595: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00c00000, "12MB", mainMemoryListener),
2596: "ja", "12MB"),
2597: ComponentFactory.createHorizontalSeparator (),
2598: Multilingual.mlnText (
2599: ComponentFactory.createCheckBoxMenuItem (MainMemory.mmrMemorySaveOn, "Save contents on exit", mainMemoryListener),
2600: "ja", "終了時に内容を保存する"),
2601: SRAM.smrModifyMemorySizeMenuItem
2602: ),
2603: "ja", "メインメモリ");
2604:
2605:
2606: ActionListener highMemoryListener = new ActionListener () {
2607: @Override public void actionPerformed (ActionEvent ae) {
2608: Object source = ae.getSource ();
2609: String command = ae.getActionCommand ();
2610: switch (command) {
2611: case "None":
2612: busHighMemorySize = 0 << 20;
2613: break;
2614: case "16MB":
2615: busHighMemorySize = 16 << 20;
2616: break;
2617: case "Save contents on exit":
2618: busHighMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2619: break;
2620: }
2621: }
2622: };
2623: ButtonGroup highMemoryGroup = new ButtonGroup ();
2624: JMenu highMemoryMenu = Multilingual.mlnText (
2625: ComponentFactory.createMenu (
2626: "High memory on X68030/Xellent30",
2627: Multilingual.mlnText (
2628: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 0 << 20, "None", highMemoryListener),
2629: "ja", "なし"),
2630: Multilingual.mlnText (
2631: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 16 << 20, "16MB", highMemoryListener),
2632: "ja", "16MB"),
2633: ComponentFactory.createHorizontalSeparator (),
2634: Multilingual.mlnText (
2635: ComponentFactory.createCheckBoxMenuItem (busHighMemorySaveOn, "Save contents on exit", highMemoryListener),
2636: "ja", "終了時に内容を保存する")
2637: ),
2638: "ja", "X68030/Xellent30 のハイメモリ");
2639:
2640:
2641: ActionListener localMemoryListener = new ActionListener () {
2642: @Override public void actionPerformed (ActionEvent ae) {
2643: Object source = ae.getSource ();
2644: String command = ae.getActionCommand ();
2645: switch (command) {
2646: case "None":
2647: busLocalMemorySize = 0 << 20;
2648: break;
2649: case "16MB":
2650: busLocalMemorySize = 16 << 20;
2651: break;
2652: case "32MB":
2653: busLocalMemorySize = 32 << 20;
2654: break;
2655: case "64MB":
2656: busLocalMemorySize = 64 << 20;
2657: break;
2658: case "128MB":
2659: busLocalMemorySize = 128 << 20;
2660: break;
2661: case "256MB":
2662: busLocalMemorySize = 256 << 20;
2663: break;
2664: case "384MB":
2665: busLocalMemorySize = 384 << 20;
2666: break;
2667: case "512MB":
2668: busLocalMemorySize = 512 << 20;
2669: break;
2670: case "768MB":
2671: busLocalMemorySize = 768 << 20;
2672: break;
2673: case "Save contents on exit":
2674: busLocalMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2675: break;
2676: case "Available on X68000":
2677: busHimem68000 = ((JCheckBoxMenuItem) source).isSelected ();
2678: break;
2679: case "Available on X68030/Xellent30":
2680: busHighMemory060turboOn = ((JCheckBoxMenuItem) source).isSelected ();
2681: break;
2682: }
2683: }
2684: };
2685: ButtonGroup localMenoryGroup = new ButtonGroup ();
2686: JMenu localMemoryMenu = Multilingual.mlnText (
2687: ComponentFactory.createMenu (
2688: "High memory on 060turbo",
2689: Multilingual.mlnText (
2690: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 0 << 20, "None", localMemoryListener),
2691: "ja", "なし"),
2692: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 16 << 20, "16MB", localMemoryListener),
2693: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 32 << 20, "32MB", localMemoryListener),
2694: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 64 << 20, "64MB", localMemoryListener),
2695: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 128 << 20, "128MB", localMemoryListener),
2696: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 256 << 20, "256MB", localMemoryListener),
2697: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 384 << 20, "384MB", localMemoryListener),
2698: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 512 << 20, "512MB", localMemoryListener),
2699: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 768 << 20, "768MB", localMemoryListener),
2700: ComponentFactory.createHorizontalSeparator (),
2701: Multilingual.mlnText (
2702: ComponentFactory.createCheckBoxMenuItem (busLocalMemorySaveOn, "Save contents on exit", localMemoryListener),
2703: "ja", "終了時に内容を保存する"),
2704: ComponentFactory.createHorizontalSeparator (),
2705: Multilingual.mlnText (
2706: ComponentFactory.createCheckBoxMenuItem (busHimem68000, "Available on X68000", localMemoryListener),
2707: "ja", "X68000 でも有効"),
2708: Multilingual.mlnText (
2709: ComponentFactory.createCheckBoxMenuItem (busHighMemory060turboOn, "Available on X68030/Xellent30", localMemoryListener),
2710: "ja", "X68030/Xellent30 でも有効")
2711: ),
2712: "ja", "060turbo のハイメモリ");
2713:
2714:
2715: ActionListener xellent30Listener = new ActionListener () {
2716: @Override public void actionPerformed (ActionEvent ae) {
2717: Object source = ae.getSource ();
2718: String command = ae.getActionCommand ();
2719: switch (command) {
2720: case "$00EC0000-$00EC3FFF":
2721: xt3DIPSW = 0;
2722: break;
2723: case "$00EC4000-$00EC7FFF":
2724: xt3DIPSW = 1;
2725: break;
2726: case "$00EC8000-$00ECBFFF":
2727: xt3DIPSW = 2;
2728: break;
2729: case "$00ECC000-$00ECFFFF":
2730: xt3DIPSW = 3;
2731: break;
2732: case "256KB":
2733: xt3MemorySizeRequest = 1 << 18;
2734: break;
2735: case "1MB":
2736: xt3MemorySizeRequest = 1 << 20;
2737: break;
2738: case "Save contents on exit":
2739: xt3MemorySave = ((JCheckBoxMenuItem) source).isSelected ();
2740: break;
2741: }
2742: }
2743: };
2744: ButtonGroup xellent30PortGroup = new ButtonGroup ();
2745: ButtonGroup xellent30SizeGroup = new ButtonGroup ();
2746: JMenu xellent30Menu = ComponentFactory.createMenu (
2747: "Xellent30",
2748: ComponentFactory.createRadioButtonMenuItem (
2749: xellent30PortGroup,
2750: xt3DIPSW == 0,
2751: "$00EC0000-$00EC3FFF",
2752: xellent30Listener),
2753: ComponentFactory.createRadioButtonMenuItem (
2754: xellent30PortGroup,
2755: xt3DIPSW == 1,
2756: "$00EC4000-$00EC7FFF",
2757: xellent30Listener),
2758: ComponentFactory.createRadioButtonMenuItem (
2759: xellent30PortGroup,
2760: xt3DIPSW == 2,
2761: "$00EC8000-$00ECBFFF",
2762: xellent30Listener),
2763: ComponentFactory.createRadioButtonMenuItem (
2764: xellent30PortGroup,
2765: xt3DIPSW == 3,
2766: "$00ECC000-$00ECFFFF",
2767: xellent30Listener),
2768: ComponentFactory.createHorizontalSeparator (),
2769: ComponentFactory.createRadioButtonMenuItem (
2770: xellent30SizeGroup,
2771: xt3MemorySizeRequest == 1 << 18,
2772: "256KB",
2773: xellent30Listener),
2774: ComponentFactory.createRadioButtonMenuItem (
2775: xellent30SizeGroup,
2776: xt3MemorySizeRequest == 1 << 20,
2777: "1MB",
2778: xellent30Listener),
2779: ComponentFactory.createHorizontalSeparator (),
2780: Multilingual.mlnText (
2781: ComponentFactory.createCheckBoxMenuItem (xt3MemorySave, "Save contents on exit", xellent30Listener),
2782: "ja", "終了時に内容を保存する")
2783: );
2784:
2785:
2786: JMenu rotationMenu = null;
2787: if (PNL_ROTATION_ON) {
2788: ActionListener rotationListener = new ActionListener () {
2789: @Override public void actionPerformed (ActionEvent ae) {
2790: String command = ae.getActionCommand ();
2791: switch (command) {
2792: case "No rotation (landscape)":
2793: pnlRotationMode = 0;
2794: pnlUpdateArrangement ();
2795: break;
2796: case "90-degree rotation (portrait)":
2797: pnlRotationMode = 1;
2798: pnlUpdateArrangement ();
2799: break;
2800: case "180-degree rotation":
2801: pnlRotationMode = 2;
2802: pnlUpdateArrangement ();
2803: break;
2804: case "270-degree rotation":
2805: pnlRotationMode = 3;
2806: pnlUpdateArrangement ();
2807: break;
2808: default:
2809: System.out.println ("unknown action command " + command);
2810: }
2811: }
2812: };
2813: ButtonGroup rotationGroup = new ButtonGroup ();
2814: rotationMenu = Multilingual.mlnText (
2815: ComponentFactory.createMenu (
2816: "Rotation",
2817: Multilingual.mlnText (
2818: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 0, "No rotation (landscape)", rotationListener),
2819: "ja", "回転なし (横画面)"),
2820: Multilingual.mlnText (
2821: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 1, "90-degree rotation (portrait)", rotationListener),
2822: "ja", "90 度回転 (縦画面)"),
2823: Multilingual.mlnText (
2824: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 2, "180-degree rotation", rotationListener),
2825: "ja", "180 度回転"),
2826: Multilingual.mlnText (
2827: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 3, "270-degree rotation", rotationListener),
2828: "ja", "270 度回転")
2829: ),
2830: "ja", "回転");
2831: }
2832:
2833:
2834: ActionListener aspectListener = new ActionListener () {
2835: @Override public void actionPerformed (ActionEvent ae) {
2836: String command = ae.getActionCommand ();
2837: int i = command.indexOf (',');
2838: int key = Integer.parseInt (command.substring (0, i));
2839: int value = Integer.parseInt (command.substring (i + 1));
2840: pnlAspectMap[key] = value;
2841: pnlUpdateAspectTable ();
2842: pnlUpdateArrangement ();
2843: }
2844: };
2845: JMenu aspectMenu = ComponentFactory.createMenu ("Aspect ratio");
2846: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
2847: if (key != 0) {
2848: aspectMenu.add (ComponentFactory.createHorizontalSeparator ());
2849: }
2850: ButtonGroup group = new ButtonGroup ();
2851: for (int value = 0; value < PNL_ASPECT_VALUES; value++) {
2852: aspectMenu.add (
2853: ComponentFactory.setText (
2854: ComponentFactory.createRadioButtonMenuItem (
2855: group,
2856: pnlAspectMap[key] == value,
2857: key + "," + value,
2858: aspectListener
2859: ),
2860: (PNL_ASPECT_MATRIX[key] == PNL_ASPECT_SCREEN_RATIO ?
2861: String.format ("%s %s (%.3f)",
2862: PNL_ASPECT_RESOLUTION_NAME[key],
2863: PNL_ASPECT_SCREEN_NAME[value],
2864: PNL_ASPECT_SCREEN_RATIO[value]) :
2865: String.format ("%s %s (%.3f) @ %s (%.3f)",
2866: PNL_ASPECT_RESOLUTION_NAME[key],
2867: PNL_ASPECT_SCREEN_NAME[value],
2868: PNL_ASPECT_SCREEN_RATIO[value],
2869: PNL_ASPECT_PIXEL_NAME[value],
2870: PNL_ASPECT_PIXEL_RATIO[value]))
2871: )
2872: );
2873: }
2874: }
2875: aspectMenu = Multilingual.mlnText (aspectMenu, "ja", "アスペクト比");
2876:
2877:
2878: ActionListener scanlineListener = new ActionListener () {
2879: @Override public void actionPerformed (ActionEvent ae) {
2880:
2881: String command = ae.getActionCommand ();
2882: switch (command) {
2883: case "Off":
2884: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.OFF;
2885: CRTC.crtAllStamp += 2;
2886: break;
2887: case "Weak":
2888: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.WEAK;
2889: CRTC.crtAllStamp += 2;
2890: break;
2891: case "Medium":
2892: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.MEDIUM;
2893: CRTC.crtAllStamp += 2;
2894: break;
2895: case "Strong":
2896: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.STRONG;
2897: CRTC.crtAllStamp += 2;
2898: break;
2899: case "Black":
2900: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.BLACK;
2901: CRTC.crtAllStamp += 2;
2902: break;
2903: }
2904: }
2905: };
2906: ButtonGroup scanlineGroup = new ButtonGroup ();
2907: JMenu scanlineMenu =
2908: Multilingual.mlnText (
2909: ComponentFactory.createMenu (
2910: "Scanline effect",
2911: Multilingual.mlnText (
2912: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.OFF, "Off", scanlineListener),
2913: "ja", "なし"),
2914: Multilingual.mlnText (
2915: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.WEAK, "Weak", scanlineListener),
2916: "ja", "弱"),
2917: Multilingual.mlnText (
2918: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.MEDIUM, "Medium", scanlineListener),
2919: "ja", "中"),
2920: Multilingual.mlnText (
2921: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.STRONG, "Strong", scanlineListener),
2922: "ja", "強"),
2923: Multilingual.mlnText (
2924: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.BLACK, "Black", scanlineListener),
2925: "ja", "黒")
2926: ),
2927: "ja", "走査線エフェクト");
2928:
2929:
2930: JTextField refreshRateTextField = ComponentFactory.createNumberField (pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate), 8);
2931: refreshRateTextField.addActionListener (
2932: new ActionListener () {
2933: @Override public void actionPerformed (ActionEvent ae) {
2934: JTextField textField = (JTextField) ae.getSource ();
2935: pnlRefreshRate = 0.0;
2936: String s = textField.getText ();
2937: if (!s.equals ("")) {
2938: double rate = 0.0;
2939: try {
2940: rate = Double.parseDouble (s);
2941: } catch (NumberFormatException nfe) {
2942: }
2943: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
2944: pnlRefreshRate = rate;
2945: } else {
2946: textField.setText ("");
2947: }
2948: }
2949: pnlFixedRate = pnlRefreshRate;
2950: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
2951: pnlFixedRate = pnlGetRefreshRate ();
2952: }
2953: CRTC.crtUpdateLength ();
2954: }
2955: });
2956:
2957: ButtonGroup unitGroup = new ButtonGroup ();
2958: ButtonGroup frameGroup = new ButtonGroup ();
2959: ButtonGroup hintGroup = new ButtonGroup ();
2960: ButtonGroup vgaGroup = new ButtonGroup ();
2961: ButtonGroup intermittentGroup = new ButtonGroup ();
2962: ButtonGroup sterescopicGroup = new ButtonGroup ();
2963: ButtonGroup soundInterpolationGroup = new ButtonGroup ();
2964: ButtonGroup adpcmInterpolationGroup = new ButtonGroup ();
2965: ButtonGroup adpcmOSCFreqGroup = new ButtonGroup ();
2966: ButtonGroup keyboardGroup = new ButtonGroup ();
2967: ButtonGroup spritesGroup = new ButtonGroup ();
2968:
2969:
2970: DecimalSpinner[] freqSpinner = new DecimalSpinner[3];
2971: ChangeListener freqListener = new ChangeListener () {
2972: @Override public void stateChanged (ChangeEvent ce) {
2973: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
2974: int i = spinner.getOption ();
2975: CRTC.crtFreqsRequest[i] = spinner.getIntValue ();
2976: }
2977: };
2978: for (int i = 0; i < 3; i++) {
2979: freqSpinner[i] = ComponentFactory.createDecimalSpinner (
2980: CRTC.crtFreqsRequest[i], CRTC.CRT_MIN_FREQ, CRTC.CRT_MAX_FREQ, 1000000, i, freqListener
2981: );
2982: }
2983: DecimalSpinner sprrasSpinner = ComponentFactory.createDecimalSpinner (
2984: SpriteScreen.sprSpritesPerRaster, 0, 1016, 1, 0,
2985: new ChangeListener () {
2986: @Override public void stateChanged (ChangeEvent ce) {
2987: SpriteScreen.sprSpritesPerRaster = ((DecimalSpinner) ce.getSource ()).getIntValue ();
2988: }
2989: });
2990: ActionListener modificationListener = new ActionListener () {
2991: @Override public void actionPerformed (ActionEvent ae) {
2992: Object source = ae.getSource ();
2993: String command = ae.getActionCommand ();
2994: switch (command) {
2995:
2996: case "Adjust to host refresh rate":
2997: pnlAdjustVsync = ((JCheckBoxMenuItem) source).isSelected ();
2998: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
2999: pnlFixedRate = pnlGetRefreshRate ();
3000: }
3001: CRTC.crtUpdateLength ();
3002: break;
3003: case "* Reset to default values":
3004: for (int i = 0; i < 3; i++) {
3005: if (CRTC.crtFreqsRequest[i] != CRTC.CRT_DEFAULT_FREQS[i]) {
3006: CRTC.crtFreqsRequest[i] = CRTC.CRT_DEFAULT_FREQS[i];
3007: freqSpinner[i].setIntValue (CRTC.crtFreqsRequest[i]);
3008: }
3009: }
3010: break;
3011: case "1024-dot non-interlaced":
3012: CRTC.crtEleventhBitRequest = ((JCheckBoxMenuItem) source).isSelected ();
3013: break;
3014: case "Can write 0 to bit 0 of CRTC R00":
3015: CRTC.crtR00Bit0Zero = ((JCheckBoxMenuItem) source).isSelected ();
3016: break;
3017:
3018: case "Extended graphic screen":
3019: CRTC.crtExtendedGraphicRequest = ((JCheckBoxMenuItem) source).isSelected ();
3020: break;
3021:
3022: case "Spherical scrolling of text screen":
3023: CRTC.crtSetSphericalScrolling (((JCheckBoxMenuItem) source).isSelected ());
3024: break;
3025:
3026: case "128 sprites":
3027: SpriteScreen.sprNumberOfSpritesRequest = 128;
3028: break;
3029: case "256 sprites":
3030: SpriteScreen.sprNumberOfSpritesRequest = 256;
3031: break;
3032: case "504 sprites":
3033: SpriteScreen.sprNumberOfSpritesRequest = 512;
3034: break;
3035: case "1016 sprites":
3036: SpriteScreen.sprNumberOfSpritesRequest = 1024;
3037: break;
3038:
3039:
3040:
3041: case "4096 patterns":
3042: SpriteScreen.sprBankOnRequest = ((JCheckBoxMenuItem) source).isSelected ();
3043: break;
3044: case "Sprites displayed in 768x512":
3045: SpriteScreen.spr768x512Request = ((JCheckBoxMenuItem) source).isSelected ();
3046: break;
3047: case "BG1 displayed in 512x512":
3048: SpriteScreen.spr512bg1Request = ((JCheckBoxMenuItem) source).isSelected ();
3049: break;
3050: case "Row and column scroll":
3051: if (SpriteScreen.SPR_RC_SCROLL_ON) {
3052: SpriteScreen.sprRcScrollRequest = ((JCheckBoxMenuItem) source).isSelected ();
3053: }
3054: break;
3055: case "** Reset to default values":
3056: if (SpriteScreen.sprSpritesPerRaster != 32) {
3057: SpriteScreen.sprSpritesPerRaster = 32;
3058: sprrasSpinner.setIntValue (SpriteScreen.sprSpritesPerRaster);
3059: }
3060: break;
3061: }
3062: }
3063: };
3064: JMenu modificationMenu =
3065: Multilingual.mlnText (
3066: ComponentFactory.createMenu (
3067: "Modification",
3068: Multilingual.mlnText (
3069: ComponentFactory.createMenu (
3070: "Dot clock",
3071: Multilingual.mlnText (
3072: ComponentFactory.createCheckBoxMenuItem (pnlAdjustVsync, "Adjust to host refresh rate", modificationListener),
3073: "ja", "ホストのリフレッシュレートに合わせる"),
3074: ComponentFactory.createHorizontalBox (
3075: Box.createHorizontalStrut (20),
3076: refreshRateTextField,
3077: ComponentFactory.createLabel (" Hz"),
3078: Box.createHorizontalGlue ()
3079: ),
3080: ComponentFactory.createHorizontalSeparator (),
3081: ComponentFactory.createHorizontalBox (
3082: Box.createHorizontalStrut (20),
3083: Multilingual.mlnText (ComponentFactory.createLabel ("Dot clock oscillattor"), "ja", "ドットクロックオシレータ"),
3084: Box.createHorizontalGlue ()
3085: ),
3086: ComponentFactory.createHorizontalBox (
3087: Box.createHorizontalStrut (20),
3088: freqSpinner[0],
3089: ComponentFactory.createLabel (" Hz *"),
3090: Box.createHorizontalGlue ()
3091: ),
3092: ComponentFactory.createHorizontalBox (
3093: Box.createHorizontalStrut (20),
3094: freqSpinner[1],
3095: ComponentFactory.createLabel (" Hz *"),
3096: Box.createHorizontalGlue ()
3097: ),
3098: ComponentFactory.createHorizontalBox (
3099: Box.createHorizontalStrut (20),
3100: freqSpinner[2],
3101: ComponentFactory.createLabel (" Hz *"),
3102: Box.createHorizontalGlue ()
3103: ),
3104: Multilingual.mlnText (
3105: ComponentFactory.createMenuItem ("* Reset to default values", modificationListener),
3106: "ja", "* 初期値に戻す"),
3107: ComponentFactory.createHorizontalSeparator (),
3108: Multilingual.mlnText (
3109: ComponentFactory.createCheckBoxMenuItem (CRTC.crtEleventhBitRequest, "1024-dot non-interlaced", modificationListener),
3110: "ja", "1024 ドットノンインターレース"),
3111: Multilingual.mlnText (
3112: ComponentFactory.createCheckBoxMenuItem (CRTC.crtR00Bit0Zero, "Can write 0 to bit 0 of CRTC R00", modificationListener),
3113: "ja", "CRTC R00 のビット 0 に 0 を書き込める")
3114: ),
3115: "ja", "ドットクロック"),
3116: Multilingual.mlnText (
3117: ComponentFactory.createMenu (
3118: "Graphic screen",
3119: !CRTC.CRT_EXTENDED_GRAPHIC ? null : Multilingual.mlnText (
3120: ComponentFactory.createCheckBoxMenuItem (CRTC.crtExtendedGraphicRequest, "Extended graphic screen", modificationListener),
3121: "ja", "拡張グラフィック画面")
3122: ),
3123: "ja", "グラフィック画面"),
3124: Multilingual.mlnText (
3125: ComponentFactory.createMenu (
3126: "Text screen",
3127: Multilingual.mlnText (
3128: ComponentFactory.createCheckBoxMenuItem (CRTC.crtSphericalScrolling, "Spherical scrolling of text screen", modificationListener),
3129: "ja", "テキスト画面の球面スクロール")
3130: ),
3131: "ja", "テキスト画面"),
3132: Multilingual.mlnText (
3133: ComponentFactory.createMenu (
3134: "Sprite screen",
3135: Multilingual.mlnText (
3136: ComponentFactory.createRadioButtonMenuItem (
3137: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 128, "128 sprites", modificationListener),
3138: "ja", "128 枚のスプライト"),
3139: Multilingual.mlnText (
3140: ComponentFactory.createRadioButtonMenuItem (
3141: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 256, "256 sprites", modificationListener),
3142: "ja", "256 枚のスプライト"),
3143: Multilingual.mlnText (
3144: ComponentFactory.createRadioButtonMenuItem (
3145: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 512, "504 sprites", modificationListener),
3146: "ja", "504 枚のスプライト"),
3147: Multilingual.mlnText (
3148: ComponentFactory.createRadioButtonMenuItem (
3149: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 1024, "1016 sprites", modificationListener),
3150: "ja", "1016 枚のスプライト"),
3151:
3152:
3153:
3154:
3155: ComponentFactory.createHorizontalSeparator (),
3156: Multilingual.mlnText (
3157: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprBankOnRequest, "4096 patterns", modificationListener),
3158: "ja", "4096 個のパターン"),
3159: Multilingual.mlnText (
3160: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr768x512Request, "Sprites displayed in 768x512", modificationListener),
3161: "ja", "768x512 でスプライトを表示"),
3162: Multilingual.mlnText (
3163: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr512bg1Request, "BG1 displayed in 512x512", modificationListener),
3164: "ja", "512x512 で BG1 を表示"),
3165: !SpriteScreen.SPR_RC_SCROLL_ON ? null : Multilingual.mlnText (
3166: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprRcScrollRequest, "Row and column scroll", modificationListener),
3167: "ja", "行スクロールと列スクロール"),
3168: ComponentFactory.createHorizontalSeparator (),
3169: ComponentFactory.createHorizontalBox (
3170: Box.createHorizontalStrut (20),
3171: Multilingual.mlnText (ComponentFactory.createLabel ("Number of sprites per raster"), "ja", "ラスタあたりのスプライトの枚数"),
3172: Box.createHorizontalGlue ()
3173: ),
3174: ComponentFactory.createHorizontalBox (
3175: Box.createHorizontalStrut (20),
3176: sprrasSpinner,
3177: ComponentFactory.createLabel (" *"),
3178: Box.createHorizontalGlue ()
3179: ),
3180: Multilingual.mlnText (
3181: ComponentFactory.createMenuItem ("** Reset to default values", modificationListener),
3182: "ja", "** 初期値に戻す")
3183: ),
3184: "ja", "スプライト画面")
3185: ),
3186: "ja", "改造");
3187:
3188:
3189: mnbMenuBar = ComponentFactory.createMenuBar (
3190:
3191:
3192: mnbFileMenu = Multilingual.mlnText (
3193: ComponentFactory.createMenu (
3194: "File", 'F',
3195:
3196: FDC.fdcMenu,
3197:
3198: HDC.hdcMenu,
3199:
3200: SPC.spcMenu,
3201:
3202: HFS.hfsMenu,
3203: ComponentFactory.createHorizontalSeparator (),
3204: mnbQuitMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Quit", 'Q', MNB_MODIFIERS, listener), "ja", "終了")
3205: ),
3206: "ja", "ファイル"),
3207:
3208:
3209: mpuMenu,
3210:
3211:
3212: mnbDisplayMenu = Multilingual.mlnText (
3213: ComponentFactory.createMenu (
3214: "Display", 'D',
3215: mnbFullScreenMenuItem,
3216: mnbMaximizedMenuItem,
3217: mnbFitInWindowMenuItem,
3218: mnbFixedScaleMenuItem,
3219: ComponentFactory.createHorizontalBox (
3220: Box.createHorizontalStrut (20),
3221: pnlFixedSpinner,
3222: ComponentFactory.createLabel ("%"),
3223: Box.createHorizontalGlue ()
3224: ),
3225: ComponentFactory.createMenuItem ("50%", listener),
3226: ComponentFactory.createMenuItem ("75%", listener),
3227: ComponentFactory.createMenuItem ("100%", listener),
3228: ComponentFactory.createMenuItem ("150%", listener),
3229: ComponentFactory.createMenuItem ("200%", listener),
3230:
3231: rotationMenu,
3232:
3233: aspectMenu,
3234:
3235: Multilingual.mlnText (
3236: ComponentFactory.createMenu (
3237: "Interpolation algorithm",
3238: Multilingual.mlnText (
3239: ComponentFactory.createRadioButtonMenuItem (
3240: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
3241: "Nearest neighbor", listener),
3242: "ja", "最近傍補間"),
3243: Multilingual.mlnText (
3244: ComponentFactory.createRadioButtonMenuItem (
3245: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR,
3246: "Bilinear", listener),
3247: "ja", "線形補間"),
3248: Multilingual.mlnText (
3249: ComponentFactory.createRadioButtonMenuItem (
3250: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC,
3251: "Bicubic", listener),
3252: "ja", "三次補間")
3253: ),
3254: "ja", "補間アルゴリズム"),
3255:
3256: scanlineMenu,
3257: !PNL_USE_CANVAS ? null : Multilingual.mlnText (
3258: ComponentFactory.createCheckBoxMenuItem (pnlUseCanvasRequest, "Use canvas", listener),
3259: "ja", "キャンバスを使う"),
3260:
3261: !CRTC.CRT_ENABLE_INTERMITTENT ? null : Multilingual.mlnText (
3262: ComponentFactory.createMenu (
3263: "Intermittent drawing",
3264: Multilingual.mlnText (
3265: ComponentFactory.createRadioButtonMenuItem (
3266: intermittentGroup, CRTC.crtIntermittentInterval == 0, "Draw all changed pictures", listener),
3267: "ja", "変化した画像をすべて描画する"),
3268: Multilingual.mlnText (
3269: ComponentFactory.createRadioButtonMenuItem (
3270: intermittentGroup, CRTC.crtIntermittentInterval == 1, "Draw a changed picture once every two times", listener),
3271: "ja", "変化した画像を 2 回に 1 回描画する"),
3272: Multilingual.mlnText (
3273: ComponentFactory.createRadioButtonMenuItem (
3274: intermittentGroup, CRTC.crtIntermittentInterval == 2, "Draw a changed picture once every three times", listener),
3275: "ja", "変化した画像を 3 回に 1 回描画する"),
3276: Multilingual.mlnText (
3277: ComponentFactory.createRadioButtonMenuItem (
3278: intermittentGroup, CRTC.crtIntermittentInterval == 3, "Draw a changed picture once every four times", listener),
3279: "ja", "変化した画像を 4 回に 1 回描画する"),
3280: Multilingual.mlnText (
3281: ComponentFactory.createRadioButtonMenuItem (
3282: intermittentGroup, CRTC.crtIntermittentInterval == 4, "Draw a changed picture once every five times", listener),
3283: "ja", "変化した画像を 5 回に 1 回描画する")
3284: ),
3285: "ja", "間欠描画"),
3286:
3287: !PNL_STEREOSCOPIC_ON ? null : ComponentFactory.createHorizontalSeparator (),
3288: mnbStereoscopicMenuItem = !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3289: ComponentFactory.createCheckBoxMenuItem (pnlStereoscopicOn, "Stereoscopic viewing", 'T', listener),
3290: "ja", "立体視"),
3291: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3292: ComponentFactory.createMenu (
3293: "Stereoscopic settings",
3294: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3295: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3296: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING,
3297: "Naked-eye crossing", listener),
3298: "ja", "裸眼交差法"),
3299: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3300: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3301: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL,
3302: "Naked-eye parallel", listener),
3303: "ja", "裸眼平行法"),
3304: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3305: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3306: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE,
3307: "Side-by-side", listener),
3308: "ja", "サイドバイサイド"),
3309: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3310: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3311: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM,
3312: "Top-and-bottom", listener),
3313: "ja", "トップアンドボトム")
3314: ),
3315: "ja", "立体視設定"),
3316:
3317: ComponentFactory.createHorizontalSeparator (),
3318: GIFAnimation.gifStartRecordingMenuItem,
3319: GIFAnimation.gifSettingsMenu,
3320:
3321: ComponentFactory.createHorizontalSeparator (),
3322: modificationMenu,
3323:
3324: SpritePatternViewer.SPV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Sprite pattern viewer", listener), "ja", "スプライトパターンビュア") : null,
3325: ScreenModeTest.SMT_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Screen mode test", listener), "ja", "表示モードテスト") : null
3326: ),
3327: "ja", "画面"),
3328:
3329:
3330: mnbSoundMenu = ComponentFactory.setEnabled (
3331: Multilingual.mlnText (
3332: ComponentFactory.createMenu (
3333: "Sound", 'S',
3334: mnbPlayMenuItem = ComponentFactory.setEnabled (
3335: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (SoundSource.sndPlayOn, "Play", 'P', MNB_MODIFIERS, listener), "ja", "音声出力"),
3336: SoundSource.sndLine != null),
3337:
3338:
3339:
3340: ComponentFactory.createHorizontalBox (
3341: Box.createHorizontalGlue (),
3342: Multilingual.mlnText (ComponentFactory.createLabel ("Volume "), "ja", "音量 "),
3343: mnbVolumeLabel = ComponentFactory.createLabel (String.valueOf (SoundSource.sndVolume)),
3344: Box.createHorizontalGlue ()
3345: ),
3346:
3347:
3348: ComponentFactory.setPreferredSize (
3349: ComponentFactory.createHorizontalSlider (
3350: 0,
3351: SoundSource.SND_VOLUME_MAX,
3352: SoundSource.sndVolume,
3353: SoundSource.SND_VOLUME_STEP,
3354: 1,
3355: new ChangeListener () {
3356: @Override public void stateChanged (ChangeEvent ce) {
3357: SoundSource.sndSetVolume (((JSlider) ce.getSource ()).getValue ());
3358: }
3359: }),
3360: LnF.lnfFontSize * 18, LnF.lnfFontSize * 2 + 28),
3361: Multilingual.mlnText (
3362: ComponentFactory.createMenu (
3363: "Sound interpolation",
3364: Multilingual.mlnText (
3365: ComponentFactory.createRadioButtonMenuItem (
3366: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.THINNING_STEREO,
3367: "Sound thinning", listener),
3368: "ja", "音声 間引き"),
3369: Multilingual.mlnText (
3370: ComponentFactory.createRadioButtonMenuItem (
3371: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_STEREO,
3372: "Sound linear interpolation", listener),
3373: "ja", "音声 線形補間"),
3374: ComponentFactory.setEnabled (
3375: Multilingual.mlnText (
3376: ComponentFactory.createRadioButtonMenuItem (
3377: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000,
3378: "Sound piecewise-constant area interpolation", listener),
3379: "ja", "音声 区分定数面積補間"),
3380: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000),
3381: ComponentFactory.setEnabled (
3382: Multilingual.mlnText (
3383: ComponentFactory.createRadioButtonMenuItem (
3384: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000,
3385: "Sound linear area interpolation", listener),
3386: "ja", "音声 線形面積補間"),
3387: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000)
3388: ),
3389: "ja", "音声補間"),
3390: Multilingual.mlnText (ComponentFactory.createMenuItem ("Sound monitor", listener), "ja", "音声モニタ"),
3391:
3392: ComponentFactory.createHorizontalSeparator (),
3393:
3394: ComponentFactory.setEnabled (
3395: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (OPM.opmOutputMask != 0, "OPM output", listener), "ja", "OPM 出力"),
3396: SoundSource.sndLine != null),
3397: !OPMLog.OLG_ON ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("OPM log", listener), "ja", "OPM ログ"),
3398:
3399: ComponentFactory.createHorizontalSeparator (),
3400:
3401: ComponentFactory.setEnabled (
3402: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ADPCM.pcmOutputOn, "PCM output", listener), "ja", "PCM 出力"),
3403: SoundSource.sndLine != null),
3404: Multilingual.mlnText (
3405: ComponentFactory.createMenu (
3406: "PCM interpolation",
3407: Multilingual.mlnText (
3408: ComponentFactory.createRadioButtonMenuItem (
3409: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_CONSTANT,
3410: "PCM piecewise-constant interpolation", listener),
3411: "ja", "PCM 区分定数補間"),
3412: Multilingual.mlnText (
3413: ComponentFactory.createRadioButtonMenuItem (
3414: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_LINEAR,
3415: "PCM linear interpolation", listener),
3416: "ja", "PCM 線形補間"),
3417: Multilingual.mlnText (
3418: ComponentFactory.createRadioButtonMenuItem (
3419: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_HERMITE,
3420: "PCM hermite interpolation", listener),
3421: "ja", "PCM エルミート補間")
3422: ),
3423: "ja", "PCM 補間"),
3424: Multilingual.mlnText (
3425: ComponentFactory.createMenu (
3426: "PCM source oscillator frequency",
3427: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 0, "PCM 8MHz/4MHz", listener),
3428: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 1, "PCM 8MHz/16MHz", listener)
3429: ),
3430: "ja", "PCM 原発振周波数")
3431: ),
3432: "ja", "音声"),
3433: SoundSource.sndLine != null),
3434:
3435:
3436: mnbInputMenu = Multilingual.mlnText (
3437: ComponentFactory.createMenu (
3438: "Input", 'I',
3439: mnbPasteMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Paste", 'V', MNB_MODIFIERS, listener), "ja", "貼り付け"),
3440: CONDevice.conSettingsMenu,
3441: TextCopy.txcMakeMenuItem (),
3442: TextCopy.txcMakeSettingMenu (),
3443: ComponentFactory.createHorizontalSeparator (),
3444: mnbNoKeyboardMenuItem = Multilingual.mlnText (
3445: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, !Keyboard.kbdOn, "No keyboard", 'K', MNB_MODIFIERS, listener),
3446: "ja", "キーボードなし"),
3447: mnbStandardKeyboardMenuItem = Multilingual.mlnText (
3448: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_STANDARD_TYPE, "Standard keyboard", listener),
3449: "ja", "標準キーボード"),
3450: mnbCompactKeyboardMenuItem = Multilingual.mlnText (
3451: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_COMPACT_TYPE, "Compact keyboard", listener),
3452: "ja", "コンパクトキーボード"),
3453: Multilingual.mlnText (
3454: ComponentFactory.createCheckBoxMenuItem (pnlHideKeyboard, "Hide keyboard in full screen", listener),
3455: "ja", "全画面表示のときキーボードを隠す"),
3456: Multilingual.mlnText (ComponentFactory.createMenuItem ("Key assignments", listener), "ja", "キー割り当て"),
3457: ButtonFunction.bfnMakeMenuItem (),
3458: SRAM.smrRepeatDelayMenu,
3459: SRAM.smrRepeatIntervalMenu,
3460: !Keyboard.KBD_ZKEY_ON ? null : Keyboard.kbdZKeyMenu,
3461: ComponentFactory.createHorizontalSeparator (),
3462: Mouse.musSeamlessMouseCheckBox,
3463: Mouse.musFollowScrollCheckBox,
3464: Mouse.musCtrlRightCheckBox,
3465: Mouse.musEdgeAccelerationCheckBox,
3466: Mouse.musMouseCursorSpeedBox,
3467: Mouse.musSpeedSlider,
3468: Mouse.musHostsPixelUnitsCheckBox,
3469: ComponentFactory.createHorizontalSeparator (),
3470: Multilingual.mlnText (ComponentFactory.createMenuItem ("Joystick port settings", listener), "ja", "ジョイスティックポート設定")
3471: ),
3472: "ja", "入力"),
3473:
3474:
3475: mnbConfigMenu = Multilingual.mlnText (
3476: ComponentFactory.createMenu (
3477: "Config", 'G',
3478: Multilingual.mlnText (ComponentFactory.createMenuItem ("RS-232C and terminal", listener), "ja", "RS-232C とターミナル"),
3479: Multilingual.mlnText (
3480: ComponentFactory.createMenu (
3481: "Debug",
3482: Multilingual.mlnText (ComponentFactory.createMenuItem ("Console", listener), "ja", "コンソール"),
3483: Multilingual.mlnText (ComponentFactory.createMenuItem ("Register list", listener), "ja", "レジスタリスト"),
3484: Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble list", listener), "ja", "逆アセンブルリスト"),
3485: Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory dump list", listener), "ja", "メモリダンプリスト"),
3486: Multilingual.mlnText (ComponentFactory.createMenuItem ("Logical space monitor", listener), "ja", "論理空間モニタ"),
3487: Multilingual.mlnText (ComponentFactory.createMenuItem ("Physical space monitor", listener), "ja", "物理空間モニタ"),
3488: ATCMonitor.ACM_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Address translation caches monitor", listener), "ja", "アドレス変換キャッシュモニタ") : null,
3489: BranchLog.BLG_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Branch log", listener), "ja", "分岐ログ") : null,
3490: ProgramFlowVisualizer.PFV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Program flow visualizer", listener), "ja", "プログラムフロービジュアライザ") : null,
3491: RasterBreakPoint.RBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Raster break point", listener), "ja", "ラスタブレークポイント") : null,
3492: DataBreakPoint.DBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Data break point", listener), "ja", "データブレークポイント") : null,
3493: RootPointerList.RTL_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Root pointer list", listener), "ja", "ルートポインタリスト") : null,
3494: ComponentFactory.createHorizontalSeparator (),
3495: SRAM.smrRomdbMenu
3496: ),
3497: "ja", "デバッグ"),
3498: SRAM.smrBootMenu,
3499: mainMemoryMenu,
3500: highMemoryMenu,
3501: localMemoryMenu,
3502: xellent30Menu,
3503: ComponentFactory.createHorizontalSeparator (),
3504: ComponentFactory.createMenu (
3505: "RTC",
3506: Multilingual.mlnText (
3507: ComponentFactory.createMenuItem ("Adjust clock to host", listener),
3508: "ja", "時計をホストに合わせる")
3509: ),
3510: SRAM.smrMenu,
3511: Settings.sgsMenu,
3512: ComponentFactory.createHorizontalSeparator (),
3513: Multilingual.mlnText (ComponentFactory.createMenuItem ("Printer", listener), "ja", "プリンタ"),
3514: ROM.romMenu,
3515: Multilingual.mlnText (
3516: ComponentFactory.createMenu (
3517: "Miscellaneous",
3518: SlowdownTest.sdtCheckBoxMenuItem,
3519: SlowdownTest.sdtBox,
3520: Multilingual.mlnText (
3521: ComponentFactory.createCheckBoxMenuItem (Mouse.musOutputButtonStatus, "Mouse button status", listener),
3522: "ja", "マウスのボタンの状態"),
3523: Z8530.SCC_DEBUG_ON ? Z8530.sccDebugMenu : null
3524: ),
3525: "ja", "その他"),
3526: ComponentFactory.createHorizontalSeparator (),
3527: Multilingual.mlnText (
3528: ComponentFactory.createMenuItem ("Java runtime environment information", listener),
3529: "ja", "Java 実行環境の情報"),
3530: Multilingual.mlnText (
3531: ComponentFactory.createMenuItem ("Version information", listener),
3532: "ja", "バージョン情報"),
3533: Multilingual.mlnText (
3534: ComponentFactory.createMenu (
3535: "License",
3536: Multilingual.mlnText (ComponentFactory.createMenuItem ("XEiJ License", listener), "ja", "XEiJ 使用許諾条件"),
3537: Multilingual.mlnText (ComponentFactory.createMenuItem ("FSHARP License", listener), "ja", "FSHARP 許諾条件"),
3538: Multilingual.mlnText (ComponentFactory.createMenuItem ("ymfm License", listener), "ja", "ymfm License"),
3539: Multilingual.mlnText (ComponentFactory.createMenuItem ("jSerialComm License", listener), "ja", "jSerialComm License")
3540: ),
3541: "ja", "使用許諾条件")
3542: ),
3543: "ja", "設定"),
3544:
3545: mnbMakeLanguageMenu (),
3546:
3547:
3548: Box.createHorizontalGlue (),
3549: ComponentFactory.createVerticalBox (
3550: Box.createVerticalGlue (),
3551: Indicator.indBox,
3552: Box.createVerticalGlue ()
3553: ),
3554: Box.createHorizontalGlue ()
3555:
3556: );
3557: }
3558:
3559:
3560:
3561:
3562:
3563:
3564:
3565: public static boolean frmIsActive;
3566:
3567:
3568: public static JFrame frmFrame;
3569: public static int frmMarginWidth;
3570: public static int frmMarginHeight;
3571: public static Dimension frmMinimumSize;
3572:
3573:
3574: public static GraphicsDevice frmScreenDevice;
3575:
3576:
3577: public static DropTarget frmDropTarget;
3578:
3579:
3580:
3581: public static void frmInit () {
3582: frmIsActive = false;
3583: frmScreenDevice = GraphicsEnvironment.getLocalGraphicsEnvironment ().getDefaultScreenDevice ();
3584: pnlIsFullScreenSupported = frmScreenDevice.isFullScreenSupported ();
3585: }
3586:
3587:
3588:
3589: public static void frmMake () {
3590:
3591:
3592: frmFrame = ComponentFactory.createRestorableFrame (
3593: Settings.SGS_FRM_FRAME_KEY,
3594: PRG_TITLE + " version " + PRG_VERSION,
3595: mnbMenuBar,
3596: pnlPanel);
3597: frmUpdateTitle ();
3598: frmFrame.setIconImage (LnF.LNF_ICON_IMAGE_48);
3599: frmFrame.setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);
3600:
3601:
3602:
3603:
3604: frmMarginWidth = frmFrame.getWidth () - pnlPanel.getWidth ();
3605: frmMarginHeight = frmFrame.getHeight () - pnlPanel.getHeight ();
3606: frmMinimumSize = new Dimension (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
3607: frmFrame.setMinimumSize (frmMinimumSize);
3608:
3609:
3610:
3611: frmDropTarget = new DropTarget (pnlPanel, DnDConstants.ACTION_COPY, new DropTargetAdapter () {
3612: @Override public void dragOver (DropTargetDragEvent dtde) {
3613: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
3614: dtde.acceptDrag (DnDConstants.ACTION_COPY);
3615: return;
3616: }
3617: dtde.rejectDrag ();
3618: }
3619: @Override public void drop (DropTargetDropEvent dtde) {
3620: try {
3621: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
3622: dtde.acceptDrop (DnDConstants.ACTION_COPY);
3623: boolean reset = false;
3624: int fdu0 = -1;
3625: int fdu = 0;
3626: int hdu0 = -1;
3627: int hdu = 0;
3628: int scu0 = -1;
3629: int scu = 0;
3630: int hfu0 = -1;
3631: int hfu = 0;
3632: for (Object o : (java.util.List) dtde.getTransferable ().getTransferData (DataFlavor.javaFileListFlavor)) {
3633: if (o instanceof File) {
3634: File file = (File) o;
3635: if (file.isFile ()) {
3636: if (FDC.fdcFileFilter.accept (file)) {
3637: if (fdu < FDC.FDC_MAX_UNITS &&
3638: FDC.fdcUnitArray[fdu].insert (file.getPath (), false)) {
3639: if (fdu0 < 0) {
3640: fdu0 = fdu;
3641: }
3642: fdu++;
3643: continue;
3644: }
3645: }
3646: if (HDC.hdcFileFilter.accept (file)) {
3647: if (hdu < 16 &&
3648: HDC.hdcUnitArray[hdu].insert (file.getPath (), false)) {
3649: if (hdu0 < 0) {
3650: hdu0 = hdu;
3651: }
3652: hdu++;
3653: continue;
3654: }
3655: }
3656: if (SPC.spcFileFilter.accept (file)) {
3657: if (scu < 16 &&
3658: SPC.spcUnitArray[scu].insert (file.getPath (), false)) {
3659: if (scu0 < 0) {
3660: scu0 = scu;
3661: }
3662: scu++;
3663: continue;
3664: }
3665: }
3666: }
3667: if (HFS.hfsFileFilter.accept (file)) {
3668: if (hfu < HFS.HFS_MAX_UNITS &&
3669: HFS.hfsUnitArray[hfu].insert (file.getPath (), false)) {
3670: if (hfu0 < 0) {
3671: hfu0 = hfu;
3672: }
3673: hfu++;
3674: continue;
3675: }
3676: }
3677: }
3678: reset = false;
3679: }
3680: dtde.dropComplete (true);
3681: if (reset) {
3682: if (fdu0 >= 0) {
3683: mpuReset (0x9070 | fdu0 << 8, -1);
3684: } else if (hdu0 >= 0) {
3685: mpuReset (0x8000 | hdu0 << 8, -1);
3686: } else if (scu0 >= 0) {
3687: mpuReset (0xa000, SPC.SPC_HANDLE_EX + (scu0 << 2));
3688: } else if (hfu0 >= 0) {
3689: HFS.hfsBootUnit = hfu0;
3690: mpuReset (0xa000, HFS.HFS_BOOT_HANDLE);
3691: }
3692: }
3693: return;
3694: }
3695: } catch (UnsupportedFlavorException ufe) {
3696:
3697: } catch (IOException ioe) {
3698:
3699: }
3700: dtde.rejectDrop();
3701: }
3702: });
3703:
3704: }
3705:
3706:
3707:
3708: public static void frmUpdateTitle () {
3709: frmFrame.setTitle ((currentAccelerator == ACCELERATOR_HYBRID ? "X68000 Hybrid" :
3710: currentModel.getName () +
3711: (currentAccelerator == ACCELERATOR_XELLENT30 ? " with Xellent30" :
3712: currentAccelerator == ACCELERATOR_060TURBO ? " with 060turbo" :
3713: currentAccelerator == ACCELERATOR_060TURBOPRO ? " with 060turboPRO" : "")) +
3714: " - " + PRG_TITLE + " version " + PRG_VERSION);
3715: }
3716:
3717:
3718:
3719: public static void frmStart () {
3720:
3721:
3722:
3723:
3724:
3725:
3726:
3727:
3728: ComponentFactory.addListener (
3729: frmFrame,
3730: new WindowAdapter () {
3731: @Override public void windowActivated (WindowEvent we) {
3732: frmIsActive = true;
3733: }
3734: @Override public void windowClosing (WindowEvent we) {
3735: prgTini ();
3736: }
3737: @Override public void windowDeactivated (WindowEvent we) {
3738: frmIsActive = false;
3739:
3740: }
3741: @Override public void windowOpened (WindowEvent we) {
3742: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3743: pnlFixedRate = pnlGetRefreshRate ();
3744: }
3745: }
3746: });
3747:
3748:
3749:
3750:
3751: ComponentFactory.addListener (
3752: frmFrame,
3753: new ComponentAdapter () {
3754: @Override public void componentMoved (ComponentEvent ce) {
3755: Point p = pnlPanel.getLocationOnScreen ();
3756: pnlGlobalX = p.x;
3757: pnlGlobalY = p.y;
3758: }
3759: @Override public void componentResized (ComponentEvent ce) {
3760: Point p = pnlPanel.getLocationOnScreen ();
3761: pnlGlobalX = p.x;
3762: pnlGlobalY = p.y;
3763: }
3764: });
3765:
3766: }
3767:
3768:
3769:
3770:
3771:
3772:
3773: public static BufferedImage clpClipboardImage;
3774: public static String clpClipboardString;
3775: public static Clipboard clpClipboard;
3776: public static Transferable clpImageContents;
3777: public static Transferable clpStringContents;
3778: public static ClipboardOwner clpClipboardOwner;
3779: public static boolean clpIsClipboardOwner;
3780:
3781:
3782:
3783:
3784: public static void clpMake () {
3785: Toolkit toolkit = Toolkit.getDefaultToolkit ();
3786: clpClipboard = null;
3787: try {
3788: clpClipboard = toolkit.getSystemClipboard ();
3789: } catch (Exception e) {
3790: return;
3791: }
3792: clpClipboardImage = null;
3793: clpClipboardString = null;
3794: clpImageContents = new Transferable () {
3795: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
3796: if (flavor == DataFlavor.imageFlavor) {
3797: return clpClipboardImage;
3798: } else {
3799: throw new UnsupportedFlavorException (flavor);
3800: }
3801: }
3802: public DataFlavor[] getTransferDataFlavors () {
3803: return new DataFlavor[] { DataFlavor.imageFlavor };
3804: }
3805: public boolean isDataFlavorSupported (DataFlavor flavor) {
3806: return flavor == DataFlavor.imageFlavor;
3807: }
3808: };
3809: clpStringContents = new Transferable () {
3810: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
3811: if (flavor == DataFlavor.stringFlavor) {
3812: return clpClipboardString;
3813: } else {
3814: throw new UnsupportedFlavorException (flavor);
3815: }
3816: }
3817: public DataFlavor[] getTransferDataFlavors () {
3818: return new DataFlavor[] { DataFlavor.stringFlavor };
3819: }
3820: public boolean isDataFlavorSupported (DataFlavor flavor) {
3821: return flavor == DataFlavor.stringFlavor;
3822: }
3823: };
3824: clpIsClipboardOwner = false;
3825:
3826:
3827: clpClipboardOwner = new ClipboardOwner () {
3828: @Override public void lostOwnership (Clipboard clipboard, Transferable contents) {
3829: clpIsClipboardOwner = false;
3830: }
3831: };
3832:
3833:
3834: clpClipboard.addFlavorListener (new FlavorListener () {
3835: @Override public void flavorsChanged (FlavorEvent fe) {
3836: boolean available = false;
3837: try {
3838: available = clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor);
3839: } catch (IllegalStateException ise) {
3840: }
3841: if (mnbPasteMenuItem != null) {
3842: mnbPasteMenuItem.setEnabled (available);
3843: }
3844: }
3845: });
3846: if (!clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor)) {
3847: if (mnbPasteMenuItem != null) {
3848: mnbPasteMenuItem.setEnabled (false);
3849: }
3850: }
3851: }
3852:
3853:
3854:
3855: public static void clpCopy (String s) {
3856: if (clpClipboard != null && s != null) {
3857: clpClipboardString = s;
3858: try {
3859: clpClipboard.setContents (clpStringContents, clpClipboardOwner);
3860: clpIsClipboardOwner = true;
3861: } catch (Exception e) {
3862: return;
3863: }
3864: }
3865: }
3866:
3867:
3868:
3869:
3870:
3871:
3872:
3873:
3874:
3875:
3876:
3877:
3878:
3879:
3880:
3881:
3882:
3883:
3884:
3885:
3886:
3887:
3888:
3889: public static int xt3DIPSWRequest;
3890: public static int xt3DIPSW;
3891: public static int xt3PortAddress;
3892:
3893:
3894: public static int xt3MemorySizeRequest;
3895: public static int xt3MemorySize;
3896: public static boolean xt3MemoryEnabled;
3897: public static int xt3MemoryPosition;
3898: public static int xt3MemoryStart;
3899: public static final byte[] xt3MemoryArray = new byte[1 << 20];
3900: public static boolean xt3MemorySave;
3901:
3902:
3903: public static int xt3SavedPC;
3904: public static final int[] xt3SavedRn = new int[16];
3905:
3906:
3907: public static void xt3Init () {
3908:
3909:
3910: xt3DIPSWRequest = Math.max (0, Math.min (3, Settings.sgsGetInt ("xt3dipsw")));
3911: xt3DIPSW = xt3DIPSWRequest;
3912:
3913:
3914: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
3915:
3916:
3917: int memoryKB = Settings.sgsGetInt ("xt3memorykb");
3918: if (!(memoryKB == 1 << 8 || memoryKB == 1 << 10)) {
3919: memoryKB = 1 << 8;
3920: }
3921: xt3MemorySizeRequest = memoryKB << 10;
3922: xt3MemorySize = xt3MemorySizeRequest;
3923:
3924:
3925: xt3MemoryEnabled = false;
3926:
3927:
3928: xt3MemoryPosition = 11 << 20;
3929:
3930:
3931: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
3932:
3933:
3934:
3935: byte[] memoryArray = Settings.sgsGetData ("xt3memorydata");
3936: Arrays.fill (xt3MemoryArray,
3937: (byte) 0);
3938: if (memoryArray.length != 0) {
3939: System.arraycopy (memoryArray, 0,
3940: xt3MemoryArray, 0,
3941: Math.min (memoryArray.length, xt3MemoryArray.length));
3942: if (memoryArray.length < xt3MemoryArray.length) {
3943: Arrays.fill (xt3MemoryArray,
3944: memoryArray.length,
3945: xt3MemoryArray.length,
3946: (byte) 0);
3947: }
3948: }
3949:
3950:
3951: xt3MemorySave = Settings.sgsGetOnOff ("xt3memorysave");
3952:
3953:
3954: xt3SavedPC = 0;
3955:
3956: Arrays.fill (xt3SavedRn, 0);
3957:
3958: xt3Reset ();
3959: }
3960:
3961:
3962: public static void xt3Tini () {
3963:
3964:
3965: Settings.sgsPutInt ("xt3dipsw", xt3DIPSW);
3966:
3967:
3968: Settings.sgsPutInt ("xt3memorykb", xt3MemorySizeRequest >> 10);
3969:
3970:
3971: boolean zero = true;
3972: if (xt3MemorySave) {
3973: for (int i = 0; i < 1 << 20; i++) {
3974: if (xt3MemoryArray[i] != 0) {
3975: zero = false;
3976: break;
3977: }
3978: }
3979: }
3980: Settings.sgsCurrentMap.put ("xt3memorydata",
3981: zero ? "" :
3982: ByteArray.byaEncodeBase64 (ByteArray.byaEncodeGzip (xt3MemoryArray, 0, 1 << 20)));
3983:
3984:
3985: Settings.sgsPutOnOff ("xt3memorysave", xt3MemorySave);
3986:
3987: }
3988:
3989:
3990: public static void xt3Reset () {
3991:
3992:
3993: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
3994:
3995:
3996: xt3MemorySize = xt3MemorySizeRequest;
3997:
3998:
3999: xt3MemoryEnabled = false;
4000:
4001:
4002: xt3MemoryPosition = 11 << 20;
4003:
4004:
4005: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4006:
4007:
4008: xt3SavedPC = 0;
4009: Arrays.fill (xt3SavedRn, 0);
4010:
4011: }
4012:
4013:
4014: public static int xt3PortRead () {
4015: return (currentIsSecond ? 4 : 0) | (xt3MemoryEnabled ? 2 : 0) | (xt3MemoryPosition == 11 << 20 ? 0 : 1);
4016: }
4017:
4018:
4019: public static void xt3PortWrite (int d) {
4020: boolean nextIsSecond = (d & 4) != 0;
4021: boolean memoryEnabled = (d & 2) != 0;
4022: int memoryPosition = (d & 1) == 0 ? 11 << 20 : 15 << 20;
4023:
4024: if (xt3MemoryEnabled != memoryEnabled ||
4025: xt3MemoryPosition != memoryPosition) {
4026: if (xt3MemoryEnabled) {
4027: if (xt3MemoryPosition == 11 << 20) {
4028: if (MainMemory.mmrMemorySizeCurrent < 12 << 20) {
4029: busSuper (MemoryMappedDevice.MMD_NUL, (12 << 20) - xt3MemorySize, 12 << 20);
4030: } else {
4031: busUser (MemoryMappedDevice.MMD_MMR, (12 << 20) - xt3MemorySize, 12 << 20);
4032: }
4033: } else {
4034: busSuper (MemoryMappedDevice.MMD_ROM, (16 << 20) - xt3MemorySize, 16 << 20);
4035: }
4036: }
4037: xt3MemoryEnabled = memoryEnabled;
4038: xt3MemoryPosition = memoryPosition;
4039: if (xt3MemoryEnabled) {
4040: if (xt3MemoryPosition == 11 << 20) {
4041: busUser (MemoryMappedDevice.MMD_XTM, (12 << 20) - xt3MemorySize, 12 << 20);
4042: } else {
4043: busUser (MemoryMappedDevice.MMD_XTM, (16 << 20) - xt3MemorySize, 16 << 20);
4044: }
4045: }
4046: }
4047:
4048: if (currentIsSecond != nextIsSecond) {
4049:
4050: if (nextIsSecond) {
4051:
4052:
4053: xt3SavedPC = regPC;
4054: System.arraycopy (regRn, 0, xt3SavedRn, 0, 16);
4055:
4056:
4057: if (mpuTask != null) {
4058: mpuClockLimit = 0L;
4059: System.out.println (Multilingual.mlnJapanese ?
4060: Model.MPU_NAMES[currentFirstMPU] + " を停止します" :
4061: Model.MPU_NAMES[currentFirstMPU] + " stops");
4062: mpuTask.cancel ();
4063: mpuTask = null;
4064: }
4065:
4066:
4067: tmrTimer.schedule (new TimerTask () {
4068: @Override public void run () {
4069:
4070:
4071: currentIsSecond = true;
4072: currentMPU = currentSecondMPU;
4073: mpuSetCurrentClock (specifiedSecondClock);
4074:
4075: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
4076: MC68EC030.m30DivZeroVFlag = false;
4077: }
4078:
4079: RegisterList.drpSetMPU ();
4080: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4081: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4082: MC68060.mmuReset ();
4083:
4084: mpuIgnoreAddressError = true;
4085: fpuBox = fpuMotherboardCoprocessor;
4086: fpuBox.epbReset ();
4087: fpuFPn = fpuBox.epbFPn;
4088: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
4089: mpuSetWait ();
4090:
4091: regSRT1 = regSRT0 = 0;
4092: regSRS = REG_SR_S;
4093: regSRM = 0;
4094: regSRI = REG_SR_I;
4095: regCCR = 0;
4096: Arrays.fill (regRn, 0);
4097:
4098: regRn[15] = MainMemory.mmrRls (0x00000000);
4099: regPC = MainMemory.mmrRls (0x00000004);
4100:
4101: mpuIMR = 0;
4102: mpuIRR = 0;
4103: if (MC68901.MFP_DELAYED_INTERRUPT) {
4104: mpuDIRR = 0;
4105: }
4106: mpuISR = 0;
4107:
4108: mpuStart ();
4109: }
4110: }, TMR_DELAY);
4111:
4112: } else {
4113:
4114:
4115: if (mpuTask != null) {
4116: mpuClockLimit = 0L;
4117: System.out.println (Multilingual.mlnJapanese ? "MC68EC030 を停止します" : "MC68EC030 stops");
4118: mpuTask.cancel ();
4119: mpuTask = null;
4120: }
4121:
4122:
4123: tmrTimer.schedule (new TimerTask () {
4124: @Override public void run () {
4125:
4126:
4127: currentIsSecond = false;
4128: currentMPU = currentFirstMPU;
4129: mpuSetCurrentClock (specifiedFirstClock);
4130:
4131: RegisterList.drpSetMPU ();
4132: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4133: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4134: MC68060.mmuReset ();
4135:
4136: mpuIgnoreAddressError = false;
4137: mpuCacheOn = false;
4138: mpuSetWait ();
4139:
4140: regSRT1 = regSRT0 = 0;
4141: regSRS = REG_SR_S;
4142: regSRM = 0;
4143: regSRI = REG_SR_I;
4144: regCCR = 0;
4145:
4146: regPC = xt3SavedPC;
4147: System.arraycopy (xt3SavedRn, 0, regRn, 0, 16);
4148:
4149: mpuIMR = 0;
4150: mpuIRR = 0;
4151: if (MC68901.MFP_DELAYED_INTERRUPT) {
4152: mpuDIRR = 0;
4153: }
4154: mpuISR = 0;
4155:
4156: mpuStart ();
4157: }
4158: }, TMR_DELAY);
4159:
4160: }
4161: }
4162: }
4163:
4164:
4165:
4166:
4167:
4168:
4169: public static JMenu mdlMenu;
4170:
4171: public static JRadioButtonMenuItem mdlShodaiMenuItem;
4172: public static JRadioButtonMenuItem mdlACEMenuItem;
4173: public static JRadioButtonMenuItem mdlEXPERTMenuItem;
4174: public static JRadioButtonMenuItem mdlPROMenuItem;
4175: public static JRadioButtonMenuItem mdlSUPERMenuItem;
4176: public static JRadioButtonMenuItem mdlXVIMenuItem;
4177: public static JRadioButtonMenuItem mdlXellent30MenuItem;
4178: public static JRadioButtonMenuItem mdlCompactMenuItem;
4179: public static JRadioButtonMenuItem mdlHybridMenuItem;
4180: public static JRadioButtonMenuItem mdl060turboPROMenuItem;
4181: public static JRadioButtonMenuItem mdlX68030MenuItem;
4182: public static JRadioButtonMenuItem mdl030CompactMenuItem;
4183: public static JRadioButtonMenuItem mdl060turboMenuItem;
4184: public static JCheckBoxMenuItem mdlMC68010MenuItem;
4185:
4186: public static JMenu coproFPUMenu;
4187:
4188:
4189: public static final int ACCELERATOR_HYBRID = 1;
4190: public static final int ACCELERATOR_XELLENT30 = 2;
4191: public static final int ACCELERATOR_060TURBO = 3;
4192: public static final int ACCELERATOR_060TURBOPRO = 4;
4193: public static final double MHZ_HYBRID_VALUE = 100.0 / 3.0;
4194: public static final String MHZ_HYBRID_STRING = "33.3";
4195: public static final double MHZ_060TURBO_VALUE = 50.0;
4196: public static final String MHZ_060TURBO_STRING = "50";
4197:
4198:
4199:
4200: public static Model specifiedModel;
4201: public static int specifiedAccelerator;
4202: public static boolean mpu010;
4203:
4204: public static boolean specifiedIsSecond;
4205: public static int specifiedFirstMPU;
4206: public static int specifiedSecondMPU;
4207: public static int specifiedMPU;
4208:
4209: public static double specifiedFirstClock;
4210: public static double specifiedSecondClock;
4211: public static double specifiedClock;
4212:
4213: public static int specifiedCopro0;
4214: public static int specifiedCopro1;
4215: public static int specifiedCopro2;
4216: public static int specifiedOnchipFPU;
4217:
4218:
4219:
4220: public static Model currentModel;
4221: public static int currentAccelerator;
4222:
4223: public static boolean currentIsSecond;
4224: public static int currentFirstMPU;
4225: public static int currentSecondMPU;
4226: public static int currentMPU;
4227:
4228:
4229: public static int currentCopro0;
4230: public static int currentCopro1;
4231: public static int currentCopro2;
4232: public static int currentOnchipFPU;
4233:
4234:
4235:
4236: public static void mdlInit () {
4237:
4238:
4239: specifiedModel = Model.COMPACT;
4240: specifiedAccelerator = ACCELERATOR_HYBRID;
4241: mpu010 = Settings.sgsGetOnOff ("mpu010");
4242: {
4243: String paramModel = Settings.sgsGetString ("model");
4244: switch (paramModel.toLowerCase ()) {
4245: case "":
4246: case "none":
4247: case "hybrid":
4248: specifiedModel = Model.COMPACT;
4249: specifiedAccelerator = ACCELERATOR_HYBRID;
4250: break;
4251: case "xellent30":
4252: specifiedModel = Model.XVI;
4253: specifiedAccelerator = ACCELERATOR_XELLENT30;
4254: break;
4255: case "060turbo":
4256: specifiedModel = Model.X68030;
4257: specifiedAccelerator = ACCELERATOR_060TURBO;
4258: break;
4259: case "060turbopro":
4260: specifiedModel = Model.PRO;
4261: specifiedAccelerator = ACCELERATOR_060TURBOPRO;
4262: break;
4263: default:
4264: Model model = Model.fromTypeOrSynonym (paramModel);
4265: if (model != null) {
4266: specifiedModel = model;
4267: specifiedAccelerator = 0;
4268: } else {
4269: System.out.println (Multilingual.mlnJapanese ?
4270: paramModel + " は不明な機種です" :
4271: paramModel + " is unknown model");
4272: specifiedModel = Model.COMPACT;
4273: specifiedAccelerator = ACCELERATOR_HYBRID;
4274: }
4275: }
4276: }
4277:
4278: specifiedIsSecond = false;
4279: specifiedFirstMPU = specifiedModel.getMPU ();
4280: specifiedSecondMPU = Model.MPU_MC68EC030;
4281: {
4282: String[] paramMPUs = Settings.sgsGetString ("mpu").split (",");
4283: for (int i = 0; i < 2; i++) {
4284: int mpu = 0;
4285: String paramMPU = i < paramMPUs.length ? paramMPUs[i] : "";
4286: switch (paramMPU) {
4287: case "":
4288: case "none":
4289: case "-1":
4290: mpu = (i == 0 ?
4291: (specifiedAccelerator == ACCELERATOR_060TURBO ||
4292: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4293: specifiedModel.getMPU ()) :
4294: Model.MPU_MC68EC030);
4295: break;
4296: case "0":
4297: case "68000":
4298: case "mc68000":
4299: mpu = Model.MPU_MC68000;
4300: break;
4301: case "1":
4302: case "68010":
4303: case "mc68010":
4304: mpu = Model.MPU_MC68010;
4305: break;
4306:
4307:
4308:
4309:
4310:
4311: case "3":
4312: case "68ec030":
4313: case "mc68ec030":
4314: mpu = Model.MPU_MC68EC030;
4315: break;
4316:
4317:
4318:
4319:
4320:
4321:
4322:
4323:
4324:
4325:
4326:
4327:
4328:
4329:
4330:
4331:
4332:
4333: case "6":
4334: case "68060":
4335: case "mc68060":
4336: mpu = Model.MPU_MC68060;
4337: break;
4338: default:
4339: Model model = Model.fromTypeOrSynonym (paramMPU);
4340: if (model != null) {
4341: mpu = model.getMPU ();
4342: } else {
4343: System.out.println (Multilingual.mlnJapanese ?
4344: paramMPU + " は不明な MPU です" :
4345: paramMPU + " is unknown MPU");
4346: mpu = specifiedModel.getMPU ();
4347: }
4348: }
4349: if (i == 0) {
4350: specifiedFirstMPU = mpu;
4351: } else {
4352: specifiedSecondMPU = mpu;
4353: }
4354: }
4355: }
4356: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
4357:
4358: specifiedFirstClock = specifiedModel.getClock ();
4359: specifiedSecondClock = specifiedFirstClock * 2.0;
4360: {
4361: String[] paramClocks = Settings.sgsGetString ("clock").split (",");
4362: for (int i = 0; i < 2; i++) {
4363: double clock = 0.0;
4364: String paramClock = i < paramClocks.length ? paramClocks[i] : "";
4365: switch (paramClock.toLowerCase ()) {
4366: case "":
4367: case "none":
4368: case "-1":
4369: clock = (i == 0 ?
4370: (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4371: specifiedAccelerator == ACCELERATOR_060TURBO ||
4372: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4373: specifiedModel.getClock ()) :
4374: specifiedFirstClock * 2.0);
4375: break;
4376: case "hybrid":
4377: clock = MHZ_HYBRID_VALUE;
4378: break;
4379: case "060turbo":
4380: case "060turbopro":
4381: clock = MHZ_060TURBO_VALUE;
4382: break;
4383: case "16.7":
4384: case "xellent30":
4385: clock = 50.0 / 3.0;
4386: break;
4387: case "33.3":
4388: clock = 100.0 / 3.0;
4389: break;
4390: case "66.7":
4391: clock = 200.0 / 3.0;
4392: break;
4393: default:
4394: if (paramClock.matches ("^(?:" +
4395: "[-+]?" +
4396: "(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)" +
4397: "(?:[Ee][-+]?[0-9]+)?" +
4398: ")$")) {
4399: double d = Double.parseDouble (paramClock);
4400: if (1.0 <= d && d <= 1000.0) {
4401: clock = d;
4402: }
4403: } else {
4404: System.out.println (Multilingual.mlnJapanese ?
4405: paramClock + " は不明な動作周波数です" :
4406: paramClock + " is unknown clock frequency");
4407: clock = specifiedModel.getClock ();
4408: }
4409: }
4410: if (i == 0) {
4411: specifiedFirstClock = clock;
4412: } else {
4413: specifiedSecondClock = clock;
4414: }
4415: }
4416: }
4417: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4418:
4419: specifiedCopro0 = 15 & Settings.sgsGetInt ("copro0", 2);
4420: if (!((7 & specifiedCopro0) == 0 ||
4421: (7 & specifiedCopro0) == 1 ||
4422: (7 & specifiedCopro0) == 2 ||
4423: (7 & specifiedCopro0) == 7)) {
4424: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4425: }
4426: specifiedCopro1 = 15 & Settings.sgsGetInt ("copro1", 2);
4427: if (!((7 & specifiedCopro1) == 0 ||
4428: (7 & specifiedCopro1) == 1 ||
4429: (7 & specifiedCopro1) == 2 ||
4430: (7 & specifiedCopro1) == 7)) {
4431: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4432: }
4433: specifiedCopro2 = 15 & Settings.sgsGetInt ("copro2", 2);
4434: if (!((7 & specifiedCopro2) == 0 ||
4435: (7 & specifiedCopro2) == 1 ||
4436: (7 & specifiedCopro2) == 2 ||
4437: (7 & specifiedCopro2) == 7)) {
4438: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4439: }
4440: specifiedOnchipFPU = 15 & Settings.sgsGetInt ("onchipfpu", 7);
4441: if (!((7 & specifiedOnchipFPU) == 0 ||
4442: (7 & specifiedOnchipFPU) == 6 ||
4443: (7 & specifiedOnchipFPU) == 7)) {
4444: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4445: }
4446:
4447:
4448: currentModel = specifiedModel;
4449: currentAccelerator = specifiedAccelerator;
4450:
4451: currentIsSecond = specifiedIsSecond;
4452: currentFirstMPU = specifiedFirstMPU;
4453: currentSecondMPU = specifiedSecondMPU;
4454: currentMPU = specifiedMPU;
4455:
4456:
4457: currentCopro0 = specifiedCopro0;
4458: currentCopro1 = specifiedCopro1;
4459: currentCopro2 = specifiedCopro2;
4460: currentOnchipFPU = specifiedOnchipFPU;
4461:
4462:
4463: mpuUtilOn = Settings.sgsGetOnOff ("util");
4464: mpuUtilRatio = fmtParseInt (Settings.sgsGetString ("ratio"), 0, 1, 100, 100);
4465:
4466: mpuArbFreqMHz = fmtParseInt (Settings.sgsGetString ("mhz"), 0, 1, 1000, 100);
4467: if (mpuUtilOn) {
4468: mpuArbFreqOn = false;
4469: } else {
4470: mpuArbFreqOn = !(specifiedClock == 10.0 ||
4471: specifiedClock == 50.0 / 3.0 ||
4472: specifiedClock == 25.0 ||
4473: specifiedClock == 100.0 / 3.0 ||
4474: specifiedClock == 50.0 ||
4475: specifiedClock == 200.0 / 3.0 ||
4476: specifiedClock == 75.0 ||
4477: specifiedClock == 100.0);
4478: if (mpuArbFreqOn) {
4479: mpuArbFreqMHz = (int) specifiedClock;
4480: }
4481: }
4482:
4483:
4484: mpuROMWaitCycles = 0;
4485: mpuRAMWaitCycles = 0;
4486: mpuCacheOn = false;
4487:
4488: mpuNoWaitTime.ram = 0;
4489: mpuNoWaitTime.gvram = 0;
4490: mpuNoWaitTime.tvram = 0;
4491: mpuNoWaitTime.crtc = 0;
4492: mpuNoWaitTime.palet = 0;
4493: mpuNoWaitTime.vicon = 0;
4494: mpuNoWaitTime.dmac = 0;
4495: mpuNoWaitTime.mfp = 0;
4496: mpuNoWaitTime.rtc = 0;
4497: mpuNoWaitTime.prnport = 0;
4498: mpuNoWaitTime.sysport = 0;
4499: mpuNoWaitTime.opm = 0;
4500: mpuNoWaitTime.adpcm = 0;
4501: mpuNoWaitTime.fdc = 0;
4502: mpuNoWaitTime.fdd = 0;
4503: mpuNoWaitTime.hdc = 0;
4504: mpuNoWaitTime.scc = 0;
4505: mpuNoWaitTime.ppi = 0;
4506: mpuNoWaitTime.ioi = 0;
4507: mpuNoWaitTime.sprc = 0;
4508: mpuNoWaitTime.sram = 0;
4509: mpuNoWaitTime.rom = 0;
4510: mpuNoWaitTime.ramlong = mpuNoWaitTime.ram << 1;
4511: mpuNoWaitTime.romlong = mpuNoWaitTime.rom << 1;
4512:
4513: dmaNoWaitTime.ram = 0;
4514: dmaNoWaitTime.gvram = 0;
4515: dmaNoWaitTime.tvram = 0;
4516: dmaNoWaitTime.crtc = 0;
4517: dmaNoWaitTime.palet = 0;
4518: dmaNoWaitTime.vicon = 0;
4519: dmaNoWaitTime.dmac = 0;
4520: dmaNoWaitTime.mfp = 0;
4521: dmaNoWaitTime.rtc = 0;
4522: dmaNoWaitTime.prnport = 0;
4523: dmaNoWaitTime.sysport = 0;
4524: dmaNoWaitTime.opm = 0;
4525: dmaNoWaitTime.adpcm = 0;
4526: dmaNoWaitTime.fdc = 0;
4527: dmaNoWaitTime.fdd = 0;
4528: dmaNoWaitTime.hdc = 0;
4529: dmaNoWaitTime.scc = 0;
4530: dmaNoWaitTime.ppi = 0;
4531: dmaNoWaitTime.ioi = 0;
4532: dmaNoWaitTime.sprc = 0;
4533: dmaNoWaitTime.sram = 0;
4534: dmaNoWaitTime.rom = 0;
4535: dmaNoWaitTime.ramlong = dmaNoWaitTime.ram << 1;
4536: dmaNoWaitTime.romlong = dmaNoWaitTime.rom << 1;
4537:
4538:
4539: busWaitCyclesRequest = Settings.sgsGetOnOff ("waitcycles");
4540: busWaitCycles = busWaitCyclesRequest;
4541: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
4542:
4543: }
4544:
4545: public static void mdlTini () {
4546:
4547: Settings.sgsPutString ("model",
4548: specifiedAccelerator == ACCELERATOR_HYBRID ? "Hybrid" :
4549: specifiedAccelerator == ACCELERATOR_XELLENT30 ? "Xellent30" :
4550: specifiedAccelerator == ACCELERATOR_060TURBO ? "060turbo" :
4551: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? "060turboPRO" :
4552: specifiedModel.getSynonym () != null ? specifiedModel.getSynonym () :
4553: specifiedModel.getType ());
4554: Settings.sgsPutOnOff ("mpu010", mpu010);
4555:
4556:
4557: int defaultFirstMPU = (specifiedAccelerator == ACCELERATOR_060TURBO ||
4558: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4559: specifiedModel.getMPU ());
4560: int defaultSecondMPU = Model.MPU_MC68EC030;
4561: Settings.sgsPutString ("mpu",
4562: (specifiedFirstMPU == defaultFirstMPU ? "" :
4563: Model.mpuNameOf (specifiedFirstMPU)) +
4564: (specifiedSecondMPU == defaultSecondMPU ? "" :
4565: "," + Model.mpuNameOf (specifiedSecondMPU)));
4566:
4567:
4568:
4569:
4570: double defaultFirstClock = (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4571: specifiedAccelerator == ACCELERATOR_060TURBO ||
4572: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4573: specifiedModel.getClock ());
4574: double defaultSecondClock = defaultFirstClock * 2.0;
4575: Settings.sgsPutString ("clock",
4576: (specifiedFirstClock == defaultFirstClock ? "" :
4577: specifiedFirstClock == 50.0 / 3.0 ? "16.7" :
4578: specifiedFirstClock == 100.0 / 3.0 ? "33.3" :
4579: specifiedFirstClock == 200.0 / 3.0 ? "66.7" :
4580: String.valueOf ((int) specifiedFirstClock)) +
4581: (specifiedSecondClock == defaultSecondClock ? "" :
4582: "," + (specifiedSecondClock == 50.0 / 3.0 ? "16.7" :
4583: specifiedSecondClock == 100.0 / 3.0 ? "33.3" :
4584: specifiedSecondClock == 200.0 / 3.0 ? "66.7" :
4585: String.valueOf ((int) specifiedSecondClock))));
4586:
4587: Settings.sgsPutInt ("copro0", specifiedCopro0);
4588: Settings.sgsPutInt ("copro1", specifiedCopro1);
4589: Settings.sgsPutInt ("copro2", specifiedCopro2);
4590: Settings.sgsPutInt ("onchipfpu", specifiedOnchipFPU);
4591:
4592: Settings.sgsPutOnOff ("util",
4593: mpuUtilOn);
4594: Settings.sgsPutString ("ratio",
4595: String.valueOf (mpuUtilRatio));
4596:
4597: Settings.sgsPutString ("mhz",
4598: String.valueOf (mpuArbFreqMHz));
4599:
4600: Settings.sgsPutOnOff ("waitcycles", busWaitCyclesRequest);
4601: }
4602:
4603: public static void mdlMakeMenu () {
4604:
4605:
4606: ActionListener listener = new ActionListener () {
4607: @Override public void actionPerformed (ActionEvent ae) {
4608: Object source = ae.getSource ();
4609: switch (ae.getActionCommand ()) {
4610: case "X68000 (10MHz)":
4611: mdlRequestModel (Model.SHODAI, 0);
4612: mpuReset (-1, -1);
4613: break;
4614: case "X68000 ACE (10MHz)":
4615: mdlRequestModel (Model.ACE, 0);
4616: mpuReset (-1, -1);
4617: break;
4618: case "X68000 EXPERT (10MHz)":
4619: mdlRequestModel (Model.EXPERT, 0);
4620: mpuReset (-1, -1);
4621: break;
4622: case "X68000 PRO (10MHz)":
4623: mdlRequestModel (Model.PRO, 0);
4624: mpuReset (-1, -1);
4625: break;
4626: case "X68000 SUPER (10MHz)":
4627: mdlRequestModel (Model.SUPER, 0);
4628: mpuReset (-1, -1);
4629: break;
4630: case "X68000 XVI (16.7MHz)":
4631: mdlRequestModel (Model.XVI, 0);
4632: mpuReset (-1, -1);
4633: break;
4634: case "X68000 Compact (16.7MHz)":
4635: mdlRequestModel (Model.COMPACT, 0);
4636: mpuReset (-1, -1);
4637: break;
4638:
4639: case "X68030 (25MHz)":
4640: mdlRequestModel (Model.X68030, 0);
4641: mpuReset (-1, -1);
4642: break;
4643: case "X68030 Compact (25MHz)":
4644: mdlRequestModel (Model.X68030COMPACT, 0);
4645: mpuReset (-1, -1);
4646: break;
4647:
4648: case "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)":
4649: mdlRequestModel (Model.COMPACT, ACCELERATOR_HYBRID);
4650: mpuReset (-1, -1);
4651: break;
4652: case "Xellent30 (33.3MHz)":
4653: mdlRequestModel (Model.XVI, ACCELERATOR_XELLENT30);
4654: mpuReset (-1, -1);
4655: break;
4656: case "060turbo (" + MHZ_060TURBO_STRING + "MHz)":
4657: mdlRequestModel (Model.X68030, ACCELERATOR_060TURBO);
4658: mpuReset (-1, -1);
4659: break;
4660: case "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)":
4661: mdlRequestModel (Model.PRO, ACCELERATOR_060TURBOPRO);
4662: mpuReset (-1, -1);
4663: break;
4664:
4665: case "MC68010":
4666: mpu010 = ((JCheckBoxMenuItem) source).isSelected ();
4667: break;
4668:
4669: }
4670: }
4671: };
4672:
4673:
4674: ButtonGroup modelGroup = new ButtonGroup ();
4675: mdlMenu = Multilingual.mlnText (
4676: ComponentFactory.createMenu (
4677: "Change the model and reset",
4678: mdlShodaiMenuItem = ComponentFactory.createRadioButtonMenuItem (
4679: modelGroup,
4680: specifiedModel == Model.SHODAI,
4681: "X68000 (10MHz)",
4682: listener),
4683: mdlACEMenuItem = ComponentFactory.createRadioButtonMenuItem (
4684: modelGroup,
4685: specifiedModel == Model.ACE,
4686: "X68000 ACE (10MHz)",
4687: listener),
4688: mdlEXPERTMenuItem = ComponentFactory.createRadioButtonMenuItem (
4689: modelGroup,
4690: specifiedModel == Model.EXPERT,
4691: "X68000 EXPERT (10MHz)",
4692: listener),
4693: mdlPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
4694: modelGroup,
4695: specifiedModel == Model.PRO && specifiedAccelerator == 0,
4696: "X68000 PRO (10MHz)",
4697: listener),
4698: mdlSUPERMenuItem = ComponentFactory.createRadioButtonMenuItem (
4699: modelGroup,
4700: specifiedModel == Model.SUPER,
4701: "X68000 SUPER (10MHz)",
4702: listener),
4703: mdlXVIMenuItem = ComponentFactory.createRadioButtonMenuItem (
4704: modelGroup,
4705: specifiedModel == Model.XVI && specifiedAccelerator == 0,
4706: "X68000 XVI (16.7MHz)",
4707: listener),
4708: mdlCompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
4709: modelGroup,
4710: specifiedModel == Model.COMPACT && specifiedAccelerator == 0,
4711: "X68000 Compact (16.7MHz)",
4712: listener),
4713:
4714: ComponentFactory.createHorizontalSeparator (),
4715:
4716: mdlX68030MenuItem = ComponentFactory.createRadioButtonMenuItem (
4717: modelGroup,
4718: specifiedModel == Model.X68030 && specifiedAccelerator == 0,
4719: "X68030 (25MHz)",
4720: listener),
4721: mdl030CompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
4722: modelGroup,
4723: specifiedModel == Model.X68030COMPACT,
4724: "X68030 Compact (25MHz)",
4725: listener),
4726:
4727: ComponentFactory.createHorizontalSeparator (),
4728:
4729: mdlHybridMenuItem = ComponentFactory.createRadioButtonMenuItem (
4730: modelGroup,
4731: specifiedModel == Model.COMPACT && specifiedAccelerator == ACCELERATOR_HYBRID,
4732: "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)",
4733: listener),
4734: mdlXellent30MenuItem = ComponentFactory.createRadioButtonMenuItem (
4735: modelGroup,
4736: specifiedModel == Model.XVI && specifiedAccelerator == ACCELERATOR_XELLENT30,
4737: "Xellent30 (33.3MHz)",
4738: listener),
4739: mdl060turboMenuItem = ComponentFactory.createRadioButtonMenuItem (
4740: modelGroup,
4741: specifiedModel == Model.X68030 && specifiedAccelerator == ACCELERATOR_060TURBO,
4742: "060turbo (" + MHZ_060TURBO_STRING + "MHz)",
4743: listener),
4744: mdl060turboPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
4745: modelGroup,
4746: specifiedModel == Model.PRO && specifiedAccelerator == ACCELERATOR_060TURBOPRO,
4747: "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)",
4748: listener),
4749:
4750: ComponentFactory.createHorizontalSeparator (),
4751:
4752: mdlMC68010MenuItem = ComponentFactory.createCheckBoxMenuItem (
4753: mpu010,
4754: "MC68010",
4755: listener)
4756: ),
4757: "ja", "機種を変更してリセット");
4758:
4759:
4760: ActionListener copro0Listener = new ActionListener () {
4761: @Override public void actionPerformed (ActionEvent ae) {
4762: String command = ae.getActionCommand ();
4763: switch (command) {
4764: case "Not installed":
4765: specifiedCopro0 = (8 & specifiedCopro0) | 0;
4766: break;
4767: case "MC68881":
4768: specifiedCopro0 = (8 & specifiedCopro0) | 1;
4769: break;
4770: case "MC68882":
4771: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4772: break;
4773: case "Full specification":
4774: specifiedCopro0 = (8 & specifiedCopro0) | 7;
4775: break;
4776: case "Extended precision (19 digits)":
4777: specifiedCopro0 = 0 | (7 & specifiedCopro0);
4778: break;
4779: case "Triple precision (24 digits)":
4780: specifiedCopro0 = 8 | (7 & specifiedCopro0);
4781: break;
4782: default:
4783: System.out.println ("unknown action command " + command);
4784: }
4785: }
4786: };
4787:
4788: ActionListener copro1Listener = new ActionListener () {
4789: @Override public void actionPerformed (ActionEvent ae) {
4790: String command = ae.getActionCommand ();
4791: switch (command) {
4792: case "Not installed":
4793: specifiedCopro1 = (8 & specifiedCopro1) | 0;
4794: break;
4795: case "MC68881":
4796: specifiedCopro1 = (8 & specifiedCopro1) | 1;
4797: break;
4798: case "MC68882":
4799: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4800: break;
4801: case "Full specification":
4802: specifiedCopro1 = (8 & specifiedCopro1) | 7;
4803: break;
4804: case "Extended precision (19 digits)":
4805: specifiedCopro1 = 0 | (7 & specifiedCopro1);
4806: break;
4807: case "Triple precision (24 digits)":
4808: specifiedCopro1 = 8 | (7 & specifiedCopro1);
4809: break;
4810: default:
4811: System.out.println ("unknown action command " + command);
4812: }
4813: }
4814: };
4815:
4816: ActionListener copro2Listener = new ActionListener () {
4817: @Override public void actionPerformed (ActionEvent ae) {
4818: String command = ae.getActionCommand ();
4819: switch (command) {
4820: case "Not installed":
4821: specifiedCopro2 = (8 & specifiedCopro2) | 0;
4822: break;
4823: case "MC68881":
4824: specifiedCopro2 = (8 & specifiedCopro2) | 1;
4825: break;
4826: case "MC68882":
4827: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4828: break;
4829: case "Full specification":
4830: specifiedCopro2 = (8 & specifiedCopro2) | 7;
4831: break;
4832: case "Extended precision (19 digits)":
4833: specifiedCopro2 = 0 | (7 & specifiedCopro2);
4834: break;
4835: case "Triple precision (24 digits)":
4836: specifiedCopro2 = 8 | (7 & specifiedCopro2);
4837: break;
4838: default:
4839: System.out.println ("unknown action command " + command);
4840: }
4841: }
4842: };
4843:
4844: ActionListener onchipFPUListener = new ActionListener () {
4845: @Override public void actionPerformed (ActionEvent ae) {
4846: String command = ae.getActionCommand ();
4847: switch (command) {
4848: case "Not installed":
4849: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 0;
4850: break;
4851: case "MC68060":
4852: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 6;
4853: break;
4854: case "Full specification":
4855: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4856: break;
4857: case "Extended precision (19 digits)":
4858: specifiedOnchipFPU = 0 | (7 & specifiedOnchipFPU);
4859: break;
4860: case "Triple precision (24 digits)":
4861: specifiedOnchipFPU = 8 | (7 & specifiedOnchipFPU);
4862: break;
4863: default:
4864: System.out.println ("unknown action command " + command);
4865: }
4866: }
4867: };
4868:
4869: ButtonGroup copro00Group = new ButtonGroup ();
4870: ButtonGroup copro01Group = new ButtonGroup ();
4871: ButtonGroup copro10Group = new ButtonGroup ();
4872: ButtonGroup copro11Group = new ButtonGroup ();
4873: ButtonGroup copro20Group = new ButtonGroup ();
4874: ButtonGroup copro21Group = new ButtonGroup ();
4875: ButtonGroup onchipFPU0Group = new ButtonGroup ();
4876: ButtonGroup onchipFPU1Group = new ButtonGroup ();
4877:
4878: coproFPUMenu = Multilingual.mlnText (
4879: ComponentFactory.createMenu (
4880: "Coprocessor and on-chip FPU",
4881:
4882: Multilingual.mlnText (
4883: ComponentFactory.createMenu (
4884: "Motherboard coprocessor",
4885: Multilingual.mlnText (
4886: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 0, "Not installed", copro0Listener),
4887: "ja", "なし"),
4888: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 1, "MC68881", copro0Listener),
4889: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 2, "MC68882", copro0Listener),
4890: Multilingual.mlnText (
4891: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 7, "Full specification", copro0Listener),
4892: "ja", "フルスペック"),
4893: ComponentFactory.createHorizontalSeparator (),
4894: Multilingual.mlnText (
4895: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) == 0, "Extended precision (19 digits)", copro0Listener),
4896: "ja", "拡張精度 (19 桁)"),
4897: Multilingual.mlnText (
4898: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) != 0, "Triple precision (24 digits)", copro0Listener),
4899: "ja", "三倍精度 (24 桁)")),
4900: "ja", "マザーボードコプロセッサ"),
4901:
4902: Multilingual.mlnText (
4903: ComponentFactory.createMenu (
4904: "Extension coprocessor #1",
4905: Multilingual.mlnText (
4906: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 0, "Not installed", copro1Listener),
4907: "ja", "なし"),
4908: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 1, "MC68881", copro1Listener),
4909: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 2, "MC68882", copro1Listener),
4910: Multilingual.mlnText (
4911: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 7, "Full specification", copro1Listener),
4912: "ja", "フルスペック"),
4913: ComponentFactory.createHorizontalSeparator (),
4914: Multilingual.mlnText (
4915: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) == 0, "Extended precision (19 digits)", copro1Listener),
4916: "ja", "拡張精度 (19 桁)"),
4917: Multilingual.mlnText (
4918: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) != 0, "Triple precision (24 digits)", copro1Listener),
4919: "ja", "三倍精度 (24 桁)")),
4920: "ja", "拡張コプロセッサ #1"),
4921:
4922: Multilingual.mlnText (
4923: ComponentFactory.createMenu (
4924: "Extension coprocessor #2",
4925: Multilingual.mlnText (
4926: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 0, "Not installed", copro2Listener),
4927: "ja", "なし"),
4928: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 1, "MC68881", copro2Listener),
4929: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 2, "MC68882", copro2Listener),
4930: Multilingual.mlnText (
4931: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 7, "Full specification", copro2Listener),
4932: "ja", "フルスペック"),
4933: ComponentFactory.createHorizontalSeparator (),
4934: Multilingual.mlnText (
4935: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) == 0, "Extended precision (19 digits)", copro2Listener),
4936: "ja", "拡張精度 (19 桁)"),
4937: Multilingual.mlnText (
4938: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) != 0, "Triple precision (24 digits)", copro2Listener),
4939: "ja", "三倍精度 (24 桁)")),
4940: "ja", "拡張コプロセッサ #2"),
4941:
4942: Multilingual.mlnText (
4943: ComponentFactory.createMenu (
4944: "On-chip FPU",
4945: Multilingual.mlnText (
4946: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 0, "Not installed", onchipFPUListener),
4947: "ja", "なし"),
4948: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 6, "MC68060", onchipFPUListener),
4949: Multilingual.mlnText (
4950: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 7, "Full specification", onchipFPUListener),
4951: "ja", "フルスペック"),
4952: ComponentFactory.createHorizontalSeparator (),
4953: Multilingual.mlnText (
4954: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) == 0, "Extended precision (19 digits)", onchipFPUListener),
4955: "ja", "拡張精度 (19 桁)"),
4956: Multilingual.mlnText (
4957: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) != 0, "Triple precision (24 digits)", onchipFPUListener),
4958: "ja", "三倍精度 (24 桁)")),
4959: "ja", "オンチップ FPU")),
4960: "ja", "コプロセッサとオンチップ FPU");
4961:
4962: }
4963:
4964: public static void mdlRequestModel (Model model, int accelerator) {
4965: specifiedModel = model;
4966: specifiedAccelerator = accelerator;
4967:
4968: specifiedIsSecond = false;
4969: specifiedFirstMPU = specifiedModel.getMPU ();
4970: specifiedSecondMPU = Model.MPU_MC68EC030;
4971: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
4972: specifiedFirstClock = specifiedModel.getClock ();
4973: specifiedSecondClock = specifiedFirstClock * 2.0;
4974: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4975:
4976: switch (accelerator) {
4977: case ACCELERATOR_HYBRID:
4978: specifiedFirstClock = MHZ_HYBRID_VALUE;
4979: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4980: break;
4981: case ACCELERATOR_XELLENT30:
4982: break;
4983: case ACCELERATOR_060TURBO:
4984: case ACCELERATOR_060TURBOPRO:
4985: specifiedFirstMPU = Model.MPU_MC68060;
4986: specifiedFirstClock = MHZ_060TURBO_VALUE;
4987: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4988: }
4989:
4990: mpuUtilOn = false;
4991: mpuArbFreqOn = false;
4992: mpuSetCurrentClock (specifiedClock);
4993:
4994: if (accelerator == ACCELERATOR_HYBRID) {
4995: mdlHybridMenuItem.setSelected (true);
4996: } else if (accelerator == ACCELERATOR_XELLENT30) {
4997: mdlXellent30MenuItem.setSelected (true);
4998: } else if (accelerator == ACCELERATOR_060TURBO) {
4999: mdl060turboMenuItem.setSelected (true);
5000: } else if (accelerator == ACCELERATOR_060TURBOPRO) {
5001: mdl060turboPROMenuItem.setSelected (true);
5002: } else if (specifiedModel == Model.SHODAI) {
5003: mdlShodaiMenuItem.setSelected (true);
5004: } else if (specifiedModel == Model.ACE) {
5005: mdlACEMenuItem.setSelected (true);
5006: } else if (specifiedModel == Model.EXPERT) {
5007: mdlEXPERTMenuItem.setSelected (true);
5008: } else if (specifiedModel == Model.PRO) {
5009: mdlPROMenuItem.setSelected (true);
5010: } else if (specifiedModel == Model.SUPER) {
5011: mdlSUPERMenuItem.setSelected (true);
5012: } else if (specifiedModel == Model.XVI) {
5013: mdlXVIMenuItem.setSelected (true);
5014: } else if (specifiedModel == Model.COMPACT) {
5015: mdlCompactMenuItem.setSelected (true);
5016: } else if (specifiedModel == Model.X68030) {
5017: mdlX68030MenuItem.setSelected (true);
5018: } else if (specifiedModel == Model.X68030COMPACT) {
5019: mdl030CompactMenuItem.setSelected (true);
5020: }
5021:
5022:
5023: HDC.hdcSASIMenuItem.setSelected (!currentModel.isSCSI ());
5024: SPC.spcSCSIINMenuItem.setSelected (currentModel.isSCSI ());
5025: }
5026:
5027:
5028:
5029:
5030:
5031:
5032:
5033: public static final boolean MPU_INLINE_EXCEPTION = true;
5034: public static final boolean MPU_COMPOUND_POSTINCREMENT = false;
5035:
5036: public static final boolean MPU_SWITCH_MISC_OPCODE = false;
5037: public static final boolean MPU_SWITCH_BCC_CONDITION = false;
5038: public static final boolean MPU_SWITCH_BCC_OFFSET = false;
5039: public static final boolean MPU_SWITCH_SCC_CONDITION = true;
5040:
5041: public static final boolean MPU_OMIT_EXTRA_READ = false;
5042: public static final boolean MPU_OMIT_OFFSET_READ = false;
5043:
5044:
5045:
5046:
5047: public static final long FAR_FUTURE = 0x7fffffffffffffffL;
5048:
5049:
5050:
5051:
5052:
5053:
5054:
5055:
5056: public static final int REG_SR_T1 = 0b10000000_00000000;
5057: public static final int REG_SR_T0 = 0b01000000_00000000;
5058:
5059:
5060:
5061:
5062:
5063:
5064: public static final int REG_SR_S = 0b00100000_00000000;
5065: public static final int REG_SR_M = 0b00010000_00000000;
5066:
5067: public static final int REG_SR_I = 0b00000111_00000000;
5068:
5069:
5070: public static final int REG_CCR_X = 0b00000000_00010000;
5071: public static final int REG_CCR_N = 0b00000000_00001000;
5072: public static final int REG_CCR_Z = 0b00000000_00000100;
5073: public static final int REG_CCR_V = 0b00000000_00000010;
5074: public static final int REG_CCR_C = 0b00000000_00000001;
5075: public static final int REG_CCR_MASK = REG_CCR_X | REG_CCR_N | REG_CCR_Z | REG_CCR_V | REG_CCR_C;
5076:
5077: public static char[] REG_CCRXMAP = "00000000000000001111111111111111".toCharArray ();
5078: public static char[] REG_CCRNMAP = "00000000111111110000000011111111".toCharArray ();
5079: public static char[] REG_CCRZMAP = "00001111000011110000111100001111".toCharArray ();
5080: public static char[] REG_CCRVMAP = "00110011001100110011001100110011".toCharArray ();
5081: public static char[] REG_CCRCMAP = "01010101010101010101010101010101".toCharArray ();
5082:
5083:
5084:
5085: public static final int MPU_IOI_INTERRUPT_LEVEL = 1;
5086: public static final int MPU_EB2_INTERRUPT_LEVEL = 2;
5087: public static final int MPU_DMA_INTERRUPT_LEVEL = 3;
5088: public static final int MPU_SCC_INTERRUPT_LEVEL = 5;
5089: public static final int MPU_MFP_INTERRUPT_LEVEL = 6;
5090: public static final int MPU_SYS_INTERRUPT_LEVEL = 7;
5091: public static final int MPU_IOI_INTERRUPT_MASK = 0x80 >> MPU_IOI_INTERRUPT_LEVEL;
5092: public static final int MPU_EB2_INTERRUPT_MASK = 0x80 >> MPU_EB2_INTERRUPT_LEVEL;
5093: public static final int MPU_DMA_INTERRUPT_MASK = 0x80 >> MPU_DMA_INTERRUPT_LEVEL;
5094: public static final int MPU_SCC_INTERRUPT_MASK = 0x80 >> MPU_SCC_INTERRUPT_LEVEL;
5095: public static final int MPU_MFP_INTERRUPT_MASK = 0x80 >> MPU_MFP_INTERRUPT_LEVEL;
5096: public static final int MPU_SYS_INTERRUPT_MASK = 0x80 >> MPU_SYS_INTERRUPT_LEVEL;
5097:
5098: public static final boolean MPU_INTERRUPT_SWITCH = true;
5099:
5100:
5101: public static final boolean T = true;
5102: public static final boolean F = false;
5103:
5104: public static final int CCCC_T = 0b0000;
5105: public static final int CCCC_F = 0b0001;
5106: public static final int CCCC_HI = 0b0010;
5107: public static final int CCCC_LS = 0b0011;
5108: public static final int CCCC_CC = 0b0100;
5109: public static final int CCCC_CS = 0b0101;
5110: public static final int CCCC_NE = 0b0110;
5111: public static final int CCCC_EQ = 0b0111;
5112: public static final int CCCC_VC = 0b1000;
5113: public static final int CCCC_VS = 0b1001;
5114: public static final int CCCC_PL = 0b1010;
5115: public static final int CCCC_MI = 0b1011;
5116: public static final int CCCC_GE = 0b1100;
5117: public static final int CCCC_LT = 0b1101;
5118: public static final int CCCC_GT = 0b1110;
5119: public static final int CCCC_LE = 0b1111;
5120:
5121:
5122:
5123:
5124:
5125:
5126: public static final boolean[] BCCMAP = {
5127: 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,
5128: 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,
5129: 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,
5130: 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,
5131: 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,
5132: 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,
5133: 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,
5134: 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,
5135: 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,
5136: 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,
5137: 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,
5138: 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,
5139: 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,
5140: 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,
5141: 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,
5142: 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,
5143: };
5144:
5145:
5146: public static final char[] MPU_CCCMAP = (
5147: "11111111111111111111111111111111" +
5148: "00000000000000000000000000000000" +
5149: "10100000101000001010000010100000" +
5150: "01011111010111110101111101011111" +
5151: "10101010101010101010101010101010" +
5152: "01010101010101010101010101010101" +
5153: "11110000111100001111000011110000" +
5154: "00001111000011110000111100001111" +
5155: "11001100110011001100110011001100" +
5156: "00110011001100110011001100110011" +
5157: "11111111000000001111111100000000" +
5158: "00000000111111110000000011111111" +
5159: "11001100001100111100110000110011" +
5160: "00110011110011000011001111001100" +
5161: "11000000001100001100000000110000" +
5162: "00111111110011110011111111001111").toCharArray ();
5163:
5164:
5165:
5166: public static final int MPU_CC_T = 0b11111111111111111111111111111111;
5167: public static final int MPU_CC_F = 0b00000000000000000000000000000000;
5168: public static final int MPU_CC_HI = 0b10100000101000001010000010100000;
5169: public static final int MPU_CC_LS = 0b01011111010111110101111101011111;
5170: public static final int MPU_CC_HS = 0b10101010101010101010101010101010;
5171: public static final int MPU_CC_LO = 0b01010101010101010101010101010101;
5172: public static final int MPU_CC_NE = 0b11110000111100001111000011110000;
5173: public static final int MPU_CC_EQ = 0b00001111000011110000111100001111;
5174: public static final int MPU_CC_VC = 0b11001100110011001100110011001100;
5175: public static final int MPU_CC_VS = 0b00110011001100110011001100110011;
5176: public static final int MPU_CC_PL = 0b11111111000000001111111100000000;
5177: public static final int MPU_CC_MI = 0b00000000111111110000000011111111;
5178: public static final int MPU_CC_GE = 0b11001100001100111100110000110011;
5179: public static final int MPU_CC_LT = 0b00110011110011000011001111001100;
5180: public static final int MPU_CC_GT = 0b11000000001100001100000000110000;
5181: public static final int MPU_CC_LE = 0b00111111110011110011111111001111;
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:
5226:
5227:
5228:
5229:
5230:
5231: 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);
5232:
5233:
5234:
5235: public static final int[] MPU_BITREV_TABLE_0 = new int[2048];
5236: public static final int[] MPU_BITREV_TABLE_1 = new int[2048];
5237: public static final int[] MPU_BITREV_TABLE_2 = new int[2048];
5238: static {
5239: for (int i = 0; i < 2048; i++) {
5240: MPU_BITREV_TABLE_2[i] = (MPU_BITREV_TABLE_1[i] = (MPU_BITREV_TABLE_0[i] = Integer.reverse (i)) >>> 11) >>> 11;
5241: }
5242: }
5243:
5244:
5245:
5246: public static final int EA_DR = 0b000_000;
5247: public static final int EA_AR = 0b001_000;
5248: public static final int EA_MM = 0b010_000;
5249: public static final int EA_MP = 0b011_000;
5250: public static final int EA_MN = 0b100_000;
5251: public static final int EA_MW = 0b101_000;
5252: public static final int EA_MX = 0b110_000;
5253: public static final int EA_ZW = 0b111_000;
5254: public static final int EA_ZL = 0b111_001;
5255: public static final int EA_PW = 0b111_010;
5256: public static final int EA_PX = 0b111_011;
5257: public static final int EA_IM = 0b111_100;
5258: public static final int MMM_DR = EA_DR >> 3;
5259: public static final int MMM_AR = EA_AR >> 3;
5260: public static final int MMM_MM = EA_MM >> 3;
5261: public static final int MMM_MP = EA_MP >> 3;
5262: public static final int MMM_MN = EA_MN >> 3;
5263: public static final int MMM_MW = EA_MW >> 3;
5264: public static final int MMM_MX = EA_MX >> 3;
5265: public static final long EAM_DR = 0xff00000000000000L >>> EA_DR;
5266: public static final long EAM_AR = 0xff00000000000000L >>> EA_AR;
5267: public static final long EAM_MM = 0xff00000000000000L >>> EA_MM;
5268: public static final long EAM_MP = 0xff00000000000000L >>> EA_MP;
5269: public static final long EAM_MN = 0xff00000000000000L >>> EA_MN;
5270: public static final long EAM_MW = 0xff00000000000000L >>> EA_MW;
5271: public static final long EAM_MX = 0xff00000000000000L >>> EA_MX;
5272: public static final long EAM_ZW = 0x8000000000000000L >>> EA_ZW;
5273: public static final long EAM_ZL = 0x8000000000000000L >>> EA_ZL;
5274: public static final long EAM_PW = 0x8000000000000000L >>> EA_PW;
5275: public static final long EAM_PX = 0x8000000000000000L >>> EA_PX;
5276: public static final long EAM_IM = 0x8000000000000000L >>> EA_IM;
5277: 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;
5278: public static final long EAM_ALT = EAM_DR|EAM_AR|EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5279: 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;
5280: 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 ;
5281: public static final long EAM_DLT = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5282: public static final long EAM_DCN = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5283: public static final long EAM_DCL = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5284: 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;
5285: public static final long EAM_MEM = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5286: public static final long EAM_MLT = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5287: public static final long EAM_RDL = EAM_MM|EAM_MP |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5288: public static final long EAM_WTL = EAM_MM |EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5289: public static final long EAM_CNT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5290: public static final long EAM_CLT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5291:
5292:
5293:
5294:
5295:
5296:
5297:
5298:
5299:
5300:
5301:
5302: public static final int[] regRn = new int[16 + 1];
5303:
5304:
5305: public static int regPC;
5306: public static int regPC0;
5307:
5308:
5309: public static int regOC;
5310:
5311:
5312: public static int regSRT1;
5313: public static int regSRT0;
5314: public static int mpuTraceFlag;
5315: public static int regSRS;
5316: public static int regSRM;
5317: public static int regSRI;
5318:
5319:
5320: public static int regCCR;
5321:
5322:
5323:
5324:
5325:
5326:
5327:
5328:
5329:
5330:
5331:
5332:
5333:
5334:
5335:
5336:
5337:
5338:
5339:
5340:
5341: public static int mpuIMR;
5342:
5343:
5344:
5345:
5346:
5347:
5348: public static int mpuIRR;
5349: public static int mpuDIRR;
5350:
5351:
5352:
5353:
5354:
5355:
5356:
5357:
5358: public static int mpuISR;
5359:
5360:
5361: public static int mpuSFC;
5362: public static int mpuDFC;
5363: public static int mpuCACR;
5364:
5365:
5366:
5367:
5368:
5369: public static int mpuBUSCR;
5370: public static int mpuUSP;
5371: public static int mpuVBR;
5372: public static int mpuCAAR;
5373: public static int mpuMSP;
5374: public static int mpuISP;
5375:
5376:
5377:
5378: public static int mpuPCR;
5379:
5380:
5381:
5382: public static final int MPU_060_REV = 7;
5383:
5384:
5385:
5386: public static long mpuClockTime;
5387: public static long mpuClockLimit;
5388: public static double mpuClockMHz;
5389: public static double mpuCurrentMHz;
5390: public static int mpuCycleCount;
5391: public static long mpuCycleUnit;
5392: public static long mpuModifiedUnit;
5393: public static long dmaCycleUnit;
5394:
5395:
5396:
5397: public static TimerTask mpuTask;
5398:
5399:
5400: public static int mpuBootDevice;
5401: public static int mpuROMBootHandle;
5402: public static int mpuSavedBootDevice;
5403: public static int mpuSavedROMBootHandle;
5404:
5405:
5406: public static boolean mpuIgnoreAddressError;
5407:
5408:
5409: public static int mpuROMWaitCycles;
5410: public static int mpuRAMWaitCycles;
5411: public static boolean mpuCacheOn;
5412: public static final class WaitTime {
5413: public long ram;
5414: public long gvram;
5415: public long tvram;
5416: public long crtc;
5417: public long palet;
5418: public long vicon;
5419: public long dmac;
5420: public long mfp;
5421: public long rtc;
5422: public long prnport;
5423: public long sysport;
5424: public long opm;
5425: public long adpcm;
5426: public long fdc;
5427: public long fdd;
5428: public long hdc;
5429: public long scc;
5430: public long ppi;
5431: public long ioi;
5432: public long sprc;
5433: public long sram;
5434: public long rom;
5435: public long ramlong;
5436: public long romlong;
5437: }
5438: public static final WaitTime mpuNoWaitTime = new WaitTime ();
5439: public static final WaitTime dmaNoWaitTime = new WaitTime ();
5440: public static final WaitTime mpuWaitTime = new WaitTime ();
5441: public static final WaitTime dmaWaitTime = new WaitTime ();
5442: public static boolean busWaitCyclesRequest;
5443: public static boolean busWaitCycles;
5444: public static WaitTime busWaitTime;
5445:
5446:
5447: public static boolean mpuArbFreqOn;
5448: public static int mpuArbFreqMHz;
5449: public static SpinnerNumberModel mpuArbFreqModel;
5450: public static JSpinner mpuArbFreqSpinner;
5451: public static JRadioButtonMenuItem mpuArbFreqRadioButtonMenuItem;
5452:
5453:
5454: public static boolean mpuUtilOn;
5455: public static int mpuUtilRatio;
5456: public static SpinnerNumberModel mpuUtilModel;
5457: public static JSpinner mpuUtilSpinner;
5458: public static JRadioButtonMenuItem mpuUtilRadioButtonMenuItem;
5459:
5460:
5461: public static final int MPU_ADJUSTMENT_INTERVAL = 100;
5462: public static int mpuAdjustmentCounter;
5463: public static long mpuTotalNano;
5464: public static long mpuLastNano;
5465: public static double mpuCoreNano1;
5466: public static double mpuCoreNano2;
5467:
5468:
5469: public static JMenu mpuMenu;
5470: public static JMenuItem mpuResetMenuItem;
5471: public static JMenuItem mpuOpt1ResetMenuItem;
5472: public static JRadioButtonMenuItem mpuClock10MenuItem;
5473: public static JRadioButtonMenuItem mpuClock16MenuItem;
5474: public static JRadioButtonMenuItem mpuClock25MenuItem;
5475: public static JRadioButtonMenuItem mpuClock33MenuItem;
5476: public static JRadioButtonMenuItem mpuClock50MenuItem;
5477: public static JRadioButtonMenuItem mpuClock66MenuItem;
5478: public static JRadioButtonMenuItem mpuClock75MenuItem;
5479: public static JRadioButtonMenuItem mpuClock100MenuItem;
5480:
5481:
5482: public static ActionListener mpuDebugActionListener;
5483: public static ArrayList<AbstractButton> mpuButtonsRunning;
5484: public static ArrayList<AbstractButton> mpuButtonsStopped;
5485: public static ArrayList<JCheckBox> mpuOriIllegalCheckBoxList;
5486: public static ArrayList<JCheckBox> mpuStopOnErrorCheckBoxList;
5487: public static ArrayList<JCheckBox> mpuStopAtStartCheckBoxList;
5488:
5489: public static int mpuAdvanceCount;
5490: public static int mpuStepCount;
5491: public static boolean mpuContinue;
5492: public static int mpuUntilReturnSRS;
5493: public static int mpuUntilReturnRP;
5494: public static int mpuUntilReturnPC0;
5495: public static int mpuUntilReturnSP;
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:
5564:
5565:
5566:
5567:
5568:
5569: public static final boolean MPU_SXMENU = false;
5570:
5571:
5572:
5573: public static void mpuInit () {
5574:
5575: mpuIgnoreAddressError = false;
5576:
5577:
5578:
5579: fpuInit ();
5580:
5581: mpuClockTime = 0L;
5582: mpuClockLimit = 0L;
5583: mpuCycleCount = 0;
5584:
5585: mpuTask = null;
5586:
5587: M68kException.m6eSignal = new M68kException ();
5588: M68kException.m6eNumber = 0;
5589: M68kException.m6eAddress = 0;
5590: M68kException.m6eDirection = MPU_WR_WRITE;
5591: M68kException.m6eSize = MPU_SS_BYTE;
5592:
5593: mpuBootDevice = -1;
5594: mpuROMBootHandle = -1;
5595: mpuSavedBootDevice = -1;
5596: mpuSavedROMBootHandle = -1;
5597:
5598:
5599:
5600:
5601:
5602:
5603:
5604:
5605:
5606:
5607:
5608:
5609:
5610:
5611:
5612: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
5613: mpuTotalNano = 0L;
5614: mpuLastNano = System.nanoTime ();
5615: mpuCoreNano1 = mpuCoreNano2 = 0.5 * 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
5616:
5617: mpuButtonsRunning = new ArrayList<AbstractButton> ();
5618: mpuButtonsStopped = new ArrayList<AbstractButton> ();
5619:
5620: mpuOriIllegalCheckBoxList = new ArrayList<JCheckBox> ();
5621: mpuStopOnErrorCheckBoxList = new ArrayList<JCheckBox> ();
5622: mpuStopAtStartCheckBoxList = new ArrayList<JCheckBox> ();
5623:
5624: mpuAdvanceCount = 0;
5625: mpuStepCount = 0;
5626: mpuContinue = false;
5627: mpuUntilReturnSRS = 0;
5628: mpuUntilReturnRP = 0;
5629: mpuUntilReturnPC0 = 0;
5630: mpuUntilReturnSP = 0;
5631:
5632:
5633: mpuDebugActionListener = new ActionListener () {
5634: @Override public void actionPerformed (ActionEvent ae) {
5635: Object source = ae.getSource ();
5636: switch (ae.getActionCommand ()) {
5637: case "Stop":
5638: if (RootPointerList.RTL_ON) {
5639: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
5640: RootPointerList.rtlCurrentUserTaskIsStoppable) {
5641: mpuStop (null);
5642: }
5643: } else {
5644: mpuStop (null);
5645: }
5646: break;
5647: case "Trace":
5648: mpuAdvance (1);
5649: break;
5650: case "Trace 10 times":
5651: mpuAdvance (10);
5652: break;
5653: case "Trace 100 times":
5654: mpuAdvance (100);
5655: break;
5656: case "Step":
5657: mpuStep (1);
5658: break;
5659: case "Step 10 times":
5660: mpuStep (10);
5661: break;
5662: case "Step 100 times":
5663: mpuStep (100);
5664: break;
5665: case "Step until return":
5666: mpuStepUntilReturn ();
5667: break;
5668: case "Run":
5669: mpuStart ();
5670: break;
5671:
5672: case "Consider ORI.B #$00,D0 as an illegal instruction" :
5673: if (DBG_ORI_BYTE_ZERO_D0) {
5674: dbgOriByteZeroD0 = ((JCheckBox) source).isSelected ();
5675: for (JCheckBox checkBox : mpuOriIllegalCheckBoxList) {
5676: if (checkBox.isSelected () != dbgOriByteZeroD0) {
5677: checkBox.setSelected (dbgOriByteZeroD0);
5678: }
5679: }
5680: }
5681: break;
5682: case "Stop on error":
5683: dbgStopOnError = ((JCheckBox) source).isSelected ();
5684: for (JCheckBox checkBox : mpuStopOnErrorCheckBoxList) {
5685: if (checkBox.isSelected () != dbgStopOnError) {
5686: checkBox.setSelected (dbgStopOnError);
5687: }
5688: }
5689: break;
5690: case "Stop at execution start position":
5691: dbgStopAtStart = ((JCheckBox) source).isSelected ();
5692: for (JCheckBox checkBox : mpuStopAtStartCheckBoxList) {
5693: if (checkBox.isSelected () != dbgStopAtStart) {
5694: checkBox.setSelected (dbgStopAtStart);
5695: }
5696: }
5697: break;
5698: }
5699: }
5700: };
5701:
5702: }
5703:
5704:
5705:
5706: public static JCheckBox mpuMakeOriIllegalCheckBox () {
5707: JCheckBox checkBox = Multilingual.mlnToolTipText (
5708: ComponentFactory.createIconCheckBox (
5709: DBG_ORI_BYTE_ZERO_D0 ? dbgOriByteZeroD0 : null,
5710: LnF.LNF_ORI_BYTE_ZERO_D0_IMAGE,
5711: LnF.LNF_ORI_BYTE_ZERO_D0_SELECTED_IMAGE,
5712: "Consider ORI.B #$00,D0 as an illegal instruction", mpuDebugActionListener),
5713: "ja", "ORI.B #$00,D0 を不当命令とみなす");
5714: mpuOriIllegalCheckBoxList.add (checkBox);
5715: return checkBox;
5716: }
5717:
5718:
5719:
5720: public static JCheckBox mpuMakeStopOnErrorCheckBox () {
5721: JCheckBox checkBox = Multilingual.mlnToolTipText (
5722: ComponentFactory.createIconCheckBox (
5723: dbgStopOnError,
5724: LnF.LNF_STOP_ON_ERROR_IMAGE,
5725: LnF.LNF_STOP_ON_ERROR_SELECTED_IMAGE,
5726: "Stop on error", mpuDebugActionListener),
5727: "ja", "エラーで停止する");
5728: mpuStopOnErrorCheckBoxList.add (checkBox);
5729: return checkBox;
5730: }
5731:
5732:
5733:
5734: public static JCheckBox mpuMakeStopAtStartCheckBox () {
5735: JCheckBox checkBox = Multilingual.mlnToolTipText (
5736: ComponentFactory.createIconCheckBox (
5737: dbgStopAtStart,
5738: LnF.LNF_STOP_AT_START_IMAGE,
5739: LnF.LNF_STOP_AT_START_SELECTED_IMAGE,
5740: "Stop at execution start position", mpuDebugActionListener),
5741: "ja", "実行開始位置で停止する");
5742: mpuStopAtStartCheckBoxList.add (checkBox);
5743: return checkBox;
5744: }
5745:
5746:
5747: public static void mpuMakeMenu () {
5748:
5749: ButtonGroup unitGroup = new ButtonGroup ();
5750: ActionListener listener = new ActionListener () {
5751: @Override public void actionPerformed (ActionEvent ae) {
5752: Object source = ae.getSource ();
5753: switch (ae.getActionCommand ()) {
5754: case "Reset":
5755: mpuReset (-1, -1);
5756: break;
5757: case "Hold down OPT.1 and reset":
5758: mpuReset (0, -1);
5759: break;
5760: case "Interrupt":
5761: sysInterrupt ();
5762: break;
5763: case "10MHz":
5764: mpuArbFreqOn = false;
5765: mpuUtilOn = false;
5766: mpuSetCurrentClock (10.0);
5767: break;
5768: case "16.7MHz":
5769: mpuArbFreqOn = false;
5770: mpuUtilOn = false;
5771: mpuSetCurrentClock (50.0 / 3.0);
5772: break;
5773: case "25MHz":
5774: mpuArbFreqOn = false;
5775: mpuUtilOn = false;
5776: mpuSetCurrentClock (25.0);
5777: break;
5778: case "33.3MHz":
5779: mpuArbFreqOn = false;
5780: mpuUtilOn = false;
5781: mpuSetCurrentClock (100.0 / 3.0);
5782: break;
5783: case "50MHz":
5784: mpuArbFreqOn = false;
5785: mpuUtilOn = false;
5786: mpuSetCurrentClock (50.0);
5787: break;
5788: case "66.7MHz":
5789: mpuArbFreqOn = false;
5790: mpuUtilOn = false;
5791: mpuSetCurrentClock (200.0 / 3.0);
5792: break;
5793: case "75MHz":
5794: mpuArbFreqOn = false;
5795: mpuUtilOn = false;
5796: mpuSetCurrentClock (75.0);
5797: break;
5798: case "100MHz":
5799: mpuArbFreqOn = false;
5800: mpuUtilOn = false;
5801: mpuSetCurrentClock (100.0);
5802: break;
5803: case "Arbitrary frequency":
5804: mpuArbFreqOn = true;
5805: mpuUtilOn = false;
5806: mpuSetCurrentClock ((double) mpuArbFreqMHz);
5807: break;
5808: case "Arbitrary load factor":
5809: mpuArbFreqOn = false;
5810: mpuUtilOn = true;
5811: break;
5812: case "FE function instruction":
5813: FEFunction.fpkOn = ((JCheckBoxMenuItem) source).isSelected ();
5814: break;
5815: case "Reject FLOATn.X":
5816: FEFunction.fpkRejectFloatOn = ((JCheckBoxMenuItem) source).isSelected ();
5817: break;
5818: case "Cut FC2 pin":
5819: busRequestCutFC2Pin = ((JCheckBoxMenuItem) source).isSelected ();
5820: break;
5821: case "Wait cycles":
5822: busWaitCyclesRequest = ((JCheckBoxMenuItem) source).isSelected ();
5823: break;
5824: case "Use IPLROM 1.6":
5825: ROM.romIPLROM16On = ((JCheckBoxMenuItem) source).isSelected ();
5826: break;
5827: case "Increase IPLROM to 256KB":
5828: ROM.romIPLROM256KOn = ((JCheckBoxMenuItem) source).isSelected ();
5829: break;
5830:
5831: case "Run / Stop":
5832: if (((JCheckBox) source).isSelected ()) {
5833: mpuStart ();
5834: } else {
5835: if (RootPointerList.RTL_ON) {
5836: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
5837: RootPointerList.rtlCurrentUserTaskIsStoppable) {
5838: mpuStop (null);
5839: }
5840: } else {
5841: mpuStop (null);
5842: }
5843: }
5844: pnlPanel.requestFocusInWindow ();
5845: break;
5846: }
5847: }
5848: };
5849: mpuMenu = ComponentFactory.createMenu (
5850: "MPU", 'M',
5851: mpuResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset", 'R', MNB_MODIFIERS, listener), "ja", "リセット"),
5852: mpuOpt1ResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Hold down OPT.1 and reset", 'O', MNB_MODIFIERS, listener), "ja", "OPT.1 を押しながらリセット"),
5853: Multilingual.mlnText (ComponentFactory.createMenuItem ("Interrupt", listener), "ja", "インタラプト"),
5854: ComponentFactory.createHorizontalSeparator (),
5855: mdlMenu,
5856: ComponentFactory.createHorizontalSeparator (),
5857: mpuClock10MenuItem = ComponentFactory.createRadioButtonMenuItem (
5858: unitGroup,
5859: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 10.0,
5860: "10MHz",
5861: listener),
5862: mpuClock16MenuItem = ComponentFactory.createRadioButtonMenuItem (
5863: unitGroup,
5864: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0 / 3.0,
5865: "16.7MHz",
5866: listener),
5867: mpuClock25MenuItem = ComponentFactory.createRadioButtonMenuItem (
5868: unitGroup,
5869: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 25.0,
5870: "25MHz",
5871: listener),
5872: mpuClock33MenuItem = ComponentFactory.createRadioButtonMenuItem (
5873: unitGroup,
5874: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0 / 3.0,
5875: "33.3MHz",
5876: listener),
5877: mpuClock50MenuItem = ComponentFactory.createRadioButtonMenuItem (
5878: unitGroup,
5879: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0,
5880: "50MHz",
5881: listener),
5882: mpuClock66MenuItem = ComponentFactory.createRadioButtonMenuItem (
5883: unitGroup,
5884: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 200.0 / 3.0,
5885: "66.7MHz",
5886: listener),
5887: mpuClock75MenuItem = ComponentFactory.createRadioButtonMenuItem (
5888: unitGroup,
5889: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 75.0,
5890: "75MHz",
5891: listener),
5892: mpuClock100MenuItem = ComponentFactory.createRadioButtonMenuItem (
5893: unitGroup,
5894: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0,
5895: "100MHz",
5896: listener),
5897: mpuArbFreqRadioButtonMenuItem = Multilingual.mlnText (
5898: ComponentFactory.createRadioButtonMenuItem (
5899: unitGroup,
5900: mpuArbFreqOn,
5901: "Arbitrary frequency",
5902: listener),
5903: "ja", "任意の周波数"),
5904: ComponentFactory.createHorizontalBox (
5905: Box.createHorizontalStrut (20),
5906: mpuArbFreqSpinner = ComponentFactory.createNumberSpinner (
5907: mpuArbFreqModel = new SpinnerNumberModel (mpuArbFreqMHz, 1, 1000, 1),
5908: 4,
5909: new ChangeListener () {
5910: @Override public void stateChanged (ChangeEvent ce) {
5911:
5912: mpuArbFreqMHz = mpuArbFreqModel.getNumber ().intValue ();
5913: if (mpuArbFreqOn) {
5914: mpuSetCurrentClock ((double) mpuArbFreqMHz);
5915: }
5916: }
5917: }
5918: ),
5919: ComponentFactory.createLabel ("MHz"),
5920: Box.createHorizontalGlue ()
5921: ),
5922: mpuUtilRadioButtonMenuItem = Multilingual.mlnText (
5923: ComponentFactory.createRadioButtonMenuItem (
5924: unitGroup,
5925: mpuUtilOn,
5926: "Arbitrary load factor",
5927: listener),
5928: "ja", "任意の負荷率"),
5929: ComponentFactory.createHorizontalBox (
5930: Box.createHorizontalStrut (20),
5931: mpuUtilSpinner = ComponentFactory.createNumberSpinner (
5932: mpuUtilModel = new SpinnerNumberModel (mpuUtilRatio, 1, 100, 1),
5933: 4,
5934: new ChangeListener () {
5935: @Override public void stateChanged (ChangeEvent ce) {
5936:
5937: mpuUtilRatio = mpuUtilModel.getNumber ().intValue ();
5938: }
5939: }
5940: ),
5941: ComponentFactory.createLabel ("%"),
5942: Box.createHorizontalGlue ()
5943: ),
5944: ComponentFactory.createHorizontalSeparator (),
5945:
5946: coproFPUMenu,
5947:
5948: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkOn, "FE function instruction", listener), "ja", "FE ファンクション命令"),
5949: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkRejectFloatOn, "Reject FLOATn.X", listener), "ja", "FLOATn.X を組み込まない"),
5950: ComponentFactory.createHorizontalSeparator (),
5951: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busRequestCutFC2Pin, "Cut FC2 pin", listener), "ja", "FC2 ピンをカットする"),
5952: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busWaitCyclesRequest, "Wait cycles", listener), "ja", "ウェイトサイクル"),
5953: ComponentFactory.createHorizontalSeparator (),
5954: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM16On, "Use IPLROM 1.6", listener), "ja", "IPLROM 1.6 を使う"),
5955: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM256KOn, "Increase IPLROM to 256KB", listener), "ja", "IPLROM を 256KB に増やす")
5956: );
5957: }
5958:
5959:
5960: public static void mpuSetCurrentClock (double clock) {
5961: specifiedClock = clock;
5962: if (currentIsSecond) {
5963: specifiedSecondClock = clock;
5964: } else {
5965: specifiedFirstClock = clock;
5966: }
5967: if (!mpuArbFreqOn && !mpuUtilOn) {
5968: if (specifiedClock == 10.0) {
5969: mpuClock10MenuItem.setSelected (true);
5970: } else if (specifiedClock == 50.0 / 3.0) {
5971: mpuClock16MenuItem.setSelected (true);
5972: } else if (specifiedClock == 25.0) {
5973: mpuClock25MenuItem.setSelected (true);
5974: } else if (specifiedClock == 100.0 / 3.0) {
5975: mpuClock33MenuItem.setSelected (true);
5976: } else if (specifiedClock == 50.0) {
5977: mpuClock50MenuItem.setSelected (true);
5978: } else if (specifiedClock == 200.0 / 3.0) {
5979: mpuClock66MenuItem.setSelected (true);
5980: } else if (specifiedClock == 75.0) {
5981: mpuClock75MenuItem.setSelected (true);
5982: } else if (specifiedClock == 100.0) {
5983: mpuClock100MenuItem.setSelected (true);
5984: }
5985: }
5986: mpuClockMHz = specifiedClock;
5987: mpuSetClockMHz (mpuClockMHz);
5988: }
5989:
5990:
5991:
5992:
5993:
5994:
5995:
5996:
5997:
5998:
5999:
6000: public static void mpuSetClockMHz (double mhz) {
6001: mhz = Math.max (1.0, Math.min (1000.0, mhz));
6002: double lastMHz = mpuCurrentMHz;
6003: mpuCurrentMHz = mhz;
6004: mpuCycleUnit = (long) (((double) TMR_FREQ / 1000000.0) / mhz + 0.5);
6005:
6006: mpuModifiedUnit = (currentMPU == Model.MPU_MC68EC030 ||
6007: currentMPU == Model.MPU_MC68030 ?
6008: (long) (((double) TMR_FREQ * 3.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6009: currentMPU == Model.MPU_MC68LC040 ||
6010: currentMPU == Model.MPU_MC68040 ?
6011: (long) (((double) TMR_FREQ * 2.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6012: mpuCycleUnit);
6013: if (lastMHz != mhz) {
6014: mpuSetWait ();
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:
6093:
6094:
6095:
6096:
6097:
6098: public static void mpuSetWait () {
6099:
6100: if (currentMPU <= Model.MPU_MC68010) {
6101: mpuWaitTime.ram = mpuCycleUnit >> 3;
6102: mpuWaitTime.vicon = (long) (mpuCycleUnit * 0.6);
6103: mpuWaitTime.crtc =
6104: mpuWaitTime.prnport =
6105: mpuWaitTime.sysport =
6106: mpuWaitTime.sprc =
6107: mpuWaitTime.sram =
6108: mpuWaitTime.rom = mpuCycleUnit;
6109: mpuWaitTime.gvram = (long) (mpuCycleUnit * 1.1);
6110: mpuWaitTime.rtc =
6111: mpuWaitTime.opm =
6112: mpuWaitTime.adpcm =
6113: mpuWaitTime.fdc =
6114: mpuWaitTime.fdd =
6115: mpuWaitTime.hdc =
6116: mpuWaitTime.ppi =
6117: mpuWaitTime.ioi = (long) (mpuCycleUnit * 1.7);
6118: mpuWaitTime.tvram = mpuCycleUnit * 2;
6119: mpuWaitTime.palet = (long) (mpuCycleUnit * 2.6);
6120: mpuWaitTime.mfp = (long) (mpuCycleUnit * 4.3);
6121: mpuWaitTime.scc = mpuCycleUnit * 6;
6122: mpuWaitTime.dmac = mpuCycleUnit * 15;
6123: mpuWaitTime.ramlong = mpuWaitTime.ram << 1;
6124: mpuWaitTime.romlong = mpuWaitTime.rom << 1;
6125: } else if (currentMPU <= Model.MPU_MC68030) {
6126: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6127: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6128: mpuWaitTime.sram = mpuCycleUnit * 2;
6129: mpuWaitTime.prnport =
6130: mpuWaitTime.sysport = mpuCycleUnit * 4;
6131: mpuWaitTime.gvram =
6132: mpuWaitTime.crtc =
6133: mpuWaitTime.vicon =
6134: mpuWaitTime.sprc = mpuCycleUnit * 6;
6135: mpuWaitTime.tvram = mpuCycleUnit * 7;
6136: mpuWaitTime.palet = mpuCycleUnit * 11;
6137: mpuWaitTime.opm =
6138: mpuWaitTime.adpcm =
6139: mpuWaitTime.fdc =
6140: mpuWaitTime.fdd =
6141: mpuWaitTime.hdc =
6142: mpuWaitTime.ppi =
6143: mpuWaitTime.ioi = mpuCycleUnit * 15;
6144: mpuWaitTime.mfp = mpuCycleUnit * 19;
6145: mpuWaitTime.rtc = mpuCycleUnit * 28;
6146: mpuWaitTime.dmac = mpuCycleUnit * 34;
6147: mpuWaitTime.scc = mpuCycleUnit * 38;
6148: mpuWaitTime.ramlong = mpuWaitTime.ram;
6149: mpuWaitTime.romlong = mpuWaitTime.rom;
6150: } else {
6151: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6152: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6153: mpuWaitTime.sram = mpuCycleUnit * 13;
6154: mpuWaitTime.prnport =
6155: mpuWaitTime.sysport = mpuCycleUnit * 17;
6156: mpuWaitTime.gvram =
6157: mpuWaitTime.crtc =
6158: mpuWaitTime.vicon =
6159: mpuWaitTime.sprc = mpuCycleUnit * 21;
6160: mpuWaitTime.tvram = mpuCycleUnit * 22;
6161: mpuWaitTime.palet = mpuCycleUnit * 33;
6162: mpuWaitTime.opm =
6163: mpuWaitTime.adpcm =
6164: mpuWaitTime.fdc =
6165: mpuWaitTime.fdd =
6166: mpuWaitTime.hdc =
6167: mpuWaitTime.ppi =
6168: mpuWaitTime.ioi = mpuCycleUnit * 37;
6169: mpuWaitTime.mfp = mpuCycleUnit * 47;
6170: mpuWaitTime.dmac = mpuCycleUnit * 73;
6171: mpuWaitTime.rtc = mpuCycleUnit * 77;
6172: mpuWaitTime.scc = mpuCycleUnit * 97;
6173: mpuWaitTime.ramlong = mpuWaitTime.ram;
6174: mpuWaitTime.romlong = mpuWaitTime.rom;
6175: }
6176: if (true) {
6177: mpuNoWaitTime.sram = mpuWaitTime.sram;
6178: mpuNoWaitTime.rom = mpuWaitTime.rom;
6179: mpuNoWaitTime.romlong = mpuWaitTime.romlong;
6180: }
6181:
6182: dmaWaitTime.ram = dmaCycleUnit >> 3;
6183: dmaWaitTime.sram = 0;
6184: dmaWaitTime.rom = 0;
6185: dmaWaitTime.gvram =
6186: dmaWaitTime.crtc =
6187: dmaWaitTime.vicon =
6188: dmaWaitTime.prnport =
6189: dmaWaitTime.sysport =
6190: dmaWaitTime.sprc = dmaCycleUnit;
6191: dmaWaitTime.tvram =
6192: dmaWaitTime.rtc =
6193: dmaWaitTime.opm =
6194: dmaWaitTime.adpcm =
6195: dmaWaitTime.fdc =
6196: dmaWaitTime.fdd =
6197: dmaWaitTime.hdc =
6198: dmaWaitTime.ppi =
6199: dmaWaitTime.ioi = dmaCycleUnit * 2;
6200: dmaWaitTime.palet = dmaCycleUnit * 3;
6201: dmaWaitTime.mfp = dmaCycleUnit * 4;
6202: dmaWaitTime.scc = dmaCycleUnit * 6;
6203: dmaWaitTime.dmac = dmaCycleUnit * 15;
6204: dmaWaitTime.ramlong = dmaWaitTime.ram << 1;
6205: dmaWaitTime.romlong = dmaWaitTime.rom << 1;
6206: }
6207:
6208:
6209:
6210:
6211:
6212: public static void mpuReset (int device, int romHandle) {
6213:
6214: mpuBootDevice = device;
6215: mpuROMBootHandle = romHandle;
6216:
6217:
6218:
6219:
6220:
6221:
6222:
6223:
6224:
6225:
6226:
6227:
6228: if (mpuBootDevice == -1) {
6229: if (mpuSavedBootDevice != -1) {
6230: mpuBootDevice = mpuSavedBootDevice;
6231: mpuROMBootHandle = mpuSavedROMBootHandle;
6232: mpuSavedBootDevice = -1;
6233: mpuSavedROMBootHandle = -1;
6234: }
6235: } else {
6236: if (mpuSavedBootDevice == -1) {
6237: mpuSavedBootDevice = MainMemory.mmrRwz (0x00ed0018);
6238: mpuSavedROMBootHandle = MainMemory.mmrRls (0x00ed000c);
6239: }
6240: }
6241:
6242:
6243: if (mpu010) {
6244: if (specifiedFirstMPU == Model.MPU_MC68000) {
6245: specifiedFirstMPU = Model.MPU_MC68010;
6246: }
6247: if (specifiedSecondMPU == Model.MPU_MC68000) {
6248: specifiedSecondMPU = Model.MPU_MC68010;
6249: }
6250: } else {
6251: if (specifiedFirstMPU == Model.MPU_MC68010) {
6252: specifiedFirstMPU = Model.MPU_MC68000;
6253: }
6254: if (specifiedSecondMPU == Model.MPU_MC68010) {
6255: specifiedSecondMPU = Model.MPU_MC68000;
6256: }
6257: }
6258:
6259:
6260: specifiedIsSecond = false;
6261: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
6262: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
6263:
6264: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
6265: MC68EC030.m30DivZeroVFlag = false;
6266: }
6267:
6268: if (mpuTask != null) {
6269: mpuClockLimit = 0L;
6270: System.out.println (Multilingual.mlnJapanese ?
6271: "MPU を停止します" :
6272: "MPU stops");
6273: mpuTask.cancel ();
6274: mpuTask = null;
6275: }
6276:
6277: tmrTimer.schedule (new TimerTask () {
6278: @Override public void run () {
6279:
6280:
6281:
6282: currentModel = specifiedModel;
6283: currentAccelerator = specifiedAccelerator;
6284: frmUpdateTitle ();
6285:
6286: currentIsSecond = specifiedIsSecond;
6287: currentFirstMPU = specifiedFirstMPU;
6288: currentSecondMPU = specifiedSecondMPU;
6289: currentMPU = specifiedMPU;
6290:
6291: mpuSetCurrentClock (specifiedClock);
6292:
6293: currentCopro0 = specifiedCopro0;
6294: currentCopro1 = specifiedCopro1;
6295: currentCopro2 = specifiedCopro2;
6296: currentOnchipFPU = specifiedOnchipFPU;
6297:
6298:
6299: if (currentMPU < Model.MPU_MC68020) {
6300: if (busHimem68000) {
6301: busRequestExMemoryStart = 0x10000000;
6302: busRequestExMemorySize = busLocalMemorySize;
6303: busRequestExMemoryArray = busLocalMemoryArray;
6304: } else {
6305: busRequestExMemoryStart = 0x10000000;
6306: busRequestExMemorySize = 0 << 20;
6307: busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
6308: }
6309: } else if (currentMPU < Model.MPU_MC68LC040) {
6310: if (busHighMemory060turboOn) {
6311: busRequestExMemoryStart = 0x10000000;
6312: busRequestExMemorySize = busLocalMemorySize;
6313: busRequestExMemoryArray = busLocalMemoryArray;
6314: } else {
6315: busRequestExMemoryStart = 0x01000000;
6316: busRequestExMemorySize = busHighMemorySize;
6317: busRequestExMemoryArray = busHighMemoryArray;
6318: }
6319: } else {
6320: busRequestExMemoryStart = 0x10000000;
6321: busRequestExMemorySize = busLocalMemorySize;
6322: busRequestExMemoryArray = busLocalMemoryArray;
6323: }
6324: busUpdateMemoryMap ();
6325:
6326:
6327: ROM.romReset ();
6328:
6329: RegisterList.drpSetMPU ();
6330:
6331: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
6332: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6333: MC68060.mmuReset ();
6334:
6335:
6336: if (Model.MPU_MC68020 <= currentMPU) {
6337: if ((7 & currentCopro0) == 1) {
6338: fpuMotherboardCoprocessor.epbSetMC68881 ();
6339: } else if ((7 & currentCopro0) == 2) {
6340: fpuMotherboardCoprocessor.epbSetMC68882 ();
6341: } else {
6342: fpuMotherboardCoprocessor.epbSetFullSpec ();
6343: }
6344: if ((8 & currentCopro0) == 0) {
6345: fpuMotherboardCoprocessor.epbSetExtended ();
6346: } else {
6347: fpuMotherboardCoprocessor.epbSetTriple ();
6348: }
6349: }
6350:
6351: if ((7 & currentCopro1) == 1) {
6352: fpuCoproboard1.epbSetMC68881 ();
6353: } else if ((7 & currentCopro1) == 2) {
6354: fpuCoproboard1.epbSetMC68882 ();
6355: } else {
6356: fpuCoproboard1.epbSetFullSpec ();
6357: }
6358: if ((8 & currentCopro1) == 0) {
6359: fpuCoproboard1.epbSetExtended ();
6360: } else {
6361: fpuCoproboard1.epbSetTriple ();
6362: }
6363:
6364: if ((7 & currentCopro2) == 1) {
6365: fpuCoproboard2.epbSetMC68881 ();
6366: } else if ((7 & currentCopro2) == 2) {
6367: fpuCoproboard2.epbSetMC68882 ();
6368: } else {
6369: fpuCoproboard2.epbSetFullSpec ();
6370: }
6371: if ((8 & currentCopro2) == 0) {
6372: fpuCoproboard2.epbSetExtended ();
6373: } else {
6374: fpuCoproboard2.epbSetTriple ();
6375: }
6376:
6377: if (Model.MPU_MC68040 <= currentMPU) {
6378: if ((7 & currentOnchipFPU) == 6) {
6379: fpuOnChipFPU.epbSetMC68060 ();
6380: } else {
6381: fpuOnChipFPU.epbSetFullSpec ();
6382: }
6383: if ((8 & currentOnchipFPU) == 0) {
6384: fpuOnChipFPU.epbSetExtended ();
6385: } else {
6386: fpuOnChipFPU.epbSetTriple ();
6387: }
6388: }
6389:
6390: if (!currentModel.isX68030 ()) {
6391: dmaCycleUnit = TMR_FREQ / 10000000L;
6392: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6393: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6394: mpuROMWaitCycles = 1;
6395: mpuRAMWaitCycles = 0;
6396: } else {
6397: dmaCycleUnit = TMR_FREQ / 12500000L;
6398: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6399: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6400: mpuROMWaitCycles = 0;
6401: mpuRAMWaitCycles = 0;
6402: }
6403:
6404: busWaitCycles = busWaitCyclesRequest;
6405: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
6406:
6407: HD63450.dmaReadCycles = (currentModel.isPRO () ? 6 :
6408: currentModel.isCompact () ? 4 :
6409: 5);
6410: HD63450.dmaWriteCycles = (currentModel.isPRO () ? 6 :
6411: 5);
6412:
6413: if (currentMPU < Model.MPU_MC68020) {
6414:
6415: mpuIgnoreAddressError = false;
6416:
6417: mpuCacheOn = false;
6418:
6419: } else if (currentMPU < Model.MPU_MC68040) {
6420:
6421: mpuIgnoreAddressError = true;
6422: fpuBox = fpuMotherboardCoprocessor;
6423: fpuBox.epbReset ();
6424: fpuFPn = fpuBox.epbFPn;
6425:
6426: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
6427:
6428: } else {
6429:
6430: mpuIgnoreAddressError = true;
6431: fpuBox = fpuOnChipFPU;
6432: fpuBox.epbReset ();
6433: fpuFPn = fpuBox.epbFPn;
6434:
6435: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6436: mpuCacheOn = (mpuCACR & 0x80008000) != 0;
6437:
6438: }
6439:
6440: mpuSetWait ();
6441:
6442:
6443: regSRT1 = regSRT0 = 0;
6444: regSRS = REG_SR_S;
6445: regSRM = 0;
6446: regSRI = REG_SR_I;
6447: regCCR = 0;
6448: Arrays.fill (regRn, 0);
6449:
6450: regRn[15] = MainMemory.mmrRls (0x00ff0000);
6451: regPC = MainMemory.mmrRls (0x00ff0004);
6452:
6453: MainMemory.mmrReset ();
6454:
6455: busReset ();
6456: if (InstructionBreakPoint.IBP_ON) {
6457: InstructionBreakPoint.ibpOp1MemoryMap = InstructionBreakPoint.ibpOp1SuperMap;
6458: InstructionBreakPoint.ibpReset ();
6459: }
6460: if (BranchLog.BLG_ON) {
6461: BranchLog.blgReset ();
6462: }
6463:
6464: mpuIMR = 0;
6465: mpuIRR = 0;
6466: if (MC68901.MFP_DELAYED_INTERRUPT) {
6467: mpuDIRR = 0;
6468: }
6469: mpuISR = 0;
6470:
6471:
6472: mpuStart ();
6473: }
6474: }, TMR_DELAY);
6475:
6476: }
6477:
6478:
6479:
6480: public static void mpuStopAndStart () {
6481: if (mpuTask == null) {
6482: mpuStart ();
6483: } else {
6484: if (RootPointerList.RTL_ON) {
6485: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6486: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6487: mpuStop (null);
6488: }
6489: } else {
6490: mpuStop (null);
6491: }
6492: }
6493: }
6494:
6495:
6496:
6497:
6498:
6499: public static void mpuStart () {
6500: if (mpuTask != null) {
6501: mpuClockLimit = 0L;
6502: System.out.println (Multilingual.mlnJapanese ?
6503: "MPU を停止します" :
6504: "MPU stops");
6505: mpuTask.cancel ();
6506: mpuTask = null;
6507: }
6508:
6509: for (AbstractButton button : mpuButtonsStopped) {
6510: button.setEnabled (false);
6511: }
6512: DisassembleList.ddpStoppedBy = null;
6513: System.out.println (Model.mpuNameOf (currentMPU) + (Multilingual.mlnJapanese ? " を起動します" : " starts up"));
6514: mpuTask = new TimerTask () {
6515: @Override public void run () {
6516: mpuContinue = true;
6517: mpuClockLimit = mpuClockTime + TMR_FREQ * TMR_INTERVAL / 1000;
6518: mpuExecuteCore ();
6519: }
6520: };
6521: tmrTimer.scheduleAtFixedRate (mpuTask, TMR_DELAY, TMR_INTERVAL);
6522:
6523: for (AbstractButton button : mpuButtonsRunning) {
6524: button.setEnabled (true);
6525: }
6526: }
6527:
6528:
6529:
6530: public static void mpuExecuteCore () {
6531:
6532: long nanoStart = System.nanoTime ();
6533:
6534: busSuper (RP5C15.rtcFirst, 0x00e8a000, 0x00e8c000);
6535:
6536:
6537: if (currentMPU < Model.MPU_MC68010) {
6538: MC68000.mpuCore ();
6539: } else if (currentMPU < Model.MPU_MC68020) {
6540: MC68010.mpuCore ();
6541: } else if (currentMPU < Model.MPU_MC68LC040) {
6542: MC68EC030.mpuCore ();
6543: } else {
6544: MC68060.mpuCore ();
6545: }
6546:
6547: if (dbgVisibleMask != 0) {
6548: dbgUpdate ();
6549: }
6550:
6551: long nanoEnd = System.nanoTime ();
6552: mpuTotalNano += nanoEnd - nanoStart;
6553: if (--mpuAdjustmentCounter == 0) {
6554:
6555: final double expectedNano = 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
6556:
6557: double coreNano0 = (double) mpuTotalNano;
6558: mpuTotalNano = 0L;
6559: double coreNanoA = (coreNano0 * 2.0 + mpuCoreNano1 + mpuCoreNano2) * 0.25;
6560: mpuCoreNano2 = mpuCoreNano1;
6561: mpuCoreNano1 = coreNano0;
6562:
6563:
6564:
6565: double actualPercent = Math.max (1.0, 100.0 * coreNanoA / expectedNano);
6566:
6567: double maxPercent = SoundSource.sndPlayOn ? 90.0 : 100.0;
6568:
6569:
6570:
6571:
6572: if (mpuUtilOn) {
6573:
6574: double targetPercent = Math.min (maxPercent, (double) mpuUtilRatio);
6575: mpuSetClockMHz ((1.2 - 0.2 * actualPercent / targetPercent) * mpuCurrentMHz);
6576: } else {
6577: mpuSetClockMHz (Math.min (maxPercent / actualPercent,
6578: 1.2 - 0.2 * mpuCurrentMHz / mpuClockMHz) * mpuCurrentMHz);
6579: }
6580: Indicator.indUpdate (actualPercent);
6581: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
6582: }
6583: }
6584:
6585:
6586:
6587:
6588: public static void mpuStop (String message) {
6589:
6590: mpuAdvanceCount = 0;
6591: mpuStepCount = 0;
6592: mpuContinue = false;
6593: mpuStop1 (message);
6594: }
6595: public static void mpuStop1 (String message) {
6596: if (mpuTask == null) {
6597: return;
6598: }
6599: DisassembleList.ddpStoppedBy = message;
6600: mpuClockLimit = 0L;
6601: System.out.println (Multilingual.mlnJapanese ?
6602: "MPU を停止します" :
6603: "MPU stops");
6604: mpuTask.cancel ();
6605: mpuTask = null;
6606:
6607: if (mpuStepCount != 0 && mpuContinue) {
6608: if (mpuStepCount == -1 || --mpuStepCount != 0) {
6609: mpuStep (mpuStepCount);
6610: return;
6611: }
6612: }
6613: mpuAdvanceCount = 0;
6614: mpuStepCount = 0;
6615: mpuContinue = false;
6616:
6617: for (AbstractButton button : mpuButtonsRunning) {
6618: button.setEnabled (false);
6619: }
6620: tmrTimer.schedule (new TimerTask () {
6621: @Override public void run () {
6622: mpuUpdateWindow ();
6623: }
6624: }, TMR_DELAY);
6625: }
6626:
6627:
6628:
6629:
6630:
6631:
6632: public static void mpuAdvance (int n) {
6633: if (mpuTask != null) {
6634: return;
6635: }
6636: mpuAdvanceCount = n;
6637: DisassembleList.ddpStoppedBy = null;
6638: mpuTask = new TimerTask () {
6639: @Override public void run () {
6640: mpuContinue = true;
6641: do {
6642: mpuClockLimit = mpuClockTime + 1L;
6643: mpuExecuteCore ();
6644: } while (mpuContinue && --mpuAdvanceCount != 0);
6645: mpuClockLimit = 0L;
6646: if (mpuTask != null) {
6647: mpuTask.cancel ();
6648: mpuTask = null;
6649: }
6650: if (mpuStepCount != 0 && mpuContinue) {
6651: if (mpuStepCount == -1 || --mpuStepCount != 0) {
6652: mpuStep (mpuStepCount);
6653: return;
6654: }
6655: }
6656: mpuAdvanceCount = 0;
6657: mpuStepCount = 0;
6658: mpuContinue = false;
6659: mpuUpdateWindow ();
6660: }
6661: };
6662: tmrTimer.schedule (mpuTask, TMR_DELAY);
6663: }
6664:
6665:
6666:
6667:
6668:
6669:
6670: public static void mpuStep (int n) {
6671: if (mpuTask != null) {
6672: return;
6673: }
6674: mpuStepCount = n;
6675: Disassembler.disDisassemble (new StringBuilder (), regPC, regSRS);
6676: if ((Disassembler.disStatus & (Disassembler.DIS_ALWAYS_BRANCH | Disassembler.DIS_SOMETIMES_BRANCH)) != 0) {
6677: if (mpuStepCount == -1 &&
6678: (Disassembler.disOC == 0x4e73 ||
6679: Disassembler.disOC == 0x4e74 ||
6680: Disassembler.disOC == 0x4e75 ||
6681: Disassembler.disOC == 0x4e77) &&
6682: mpuUntilReturnSRS == regSRS &&
6683: (currentMPU < Model.MPU_MC68LC040 ||
6684: mpuUntilReturnRP == (regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP)) &&
6685: mpuUntilReturnPC0 != regPC0 &&
6686: Integer.compareUnsigned (mpuUntilReturnSP, regRn[15]) <= 0) {
6687: mpuAdvanceCount = 0;
6688: mpuStepCount = 0;
6689: mpuContinue = false;
6690: mpuUpdateWindow ();
6691: return;
6692: }
6693: mpuAdvance (1);
6694: } else {
6695: if (InstructionBreakPoint.IBP_ON) {
6696: InstructionBreakPoint.ibpInstant (Disassembler.disPC, DisassembleList.ddpSupervisorMode);
6697: mpuStart ();
6698: }
6699: }
6700: }
6701:
6702:
6703:
6704:
6705:
6706:
6707:
6708:
6709:
6710:
6711:
6712: public static void mpuStepUntilReturn () {
6713: if (mpuTask != null) {
6714: return;
6715: }
6716: mpuUntilReturnSRS = regSRS;
6717: mpuUntilReturnRP = regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP;
6718: mpuUntilReturnPC0 = regPC0;
6719: mpuUntilReturnSP = regRn[15];
6720: mpuStep (-1);
6721: }
6722:
6723:
6724:
6725: public static void mpuUpdateWindow () {
6726: if (dbgVisibleMask != 0) {
6727: if ((dbgVisibleMask & DBG_DDP_VISIBLE_MASK) != 0) {
6728: DisassembleList.ddpBacktraceRecord = -1L;
6729: DisassembleList.ddpUpdate (-1, -1, false);
6730: }
6731: if (BranchLog.BLG_ON) {
6732: if ((dbgVisibleMask & DBG_BLG_VISIBLE_MASK) != 0) {
6733: BranchLog.blgUpdate (BranchLog.BLG_SELECT_NEWEST);
6734: }
6735: }
6736: if (ProgramFlowVisualizer.PFV_ON) {
6737: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
6738: ProgramFlowVisualizer.pfvUpdate ();
6739: }
6740: }
6741: if (RasterBreakPoint.RBP_ON) {
6742: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
6743: RasterBreakPoint.rbpUpdateFrame ();
6744: }
6745: }
6746: if (ScreenModeTest.SMT_ON) {
6747: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
6748: ScreenModeTest.smtUpdateFrame ();
6749: }
6750: }
6751: if (RootPointerList.RTL_ON) {
6752: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
6753: RootPointerList.rtlUpdateFrame ();
6754: }
6755: }
6756: if (SpritePatternViewer.SPV_ON) {
6757: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
6758: SpritePatternViewer.spvUpdateFrame ();
6759: }
6760: }
6761: if (ATCMonitor.ACM_ON) {
6762: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
6763: ATCMonitor.acmUpdateFrame ();
6764: }
6765: }
6766: }
6767:
6768: if (DebugConsole.dgtRequestRegs != 0) {
6769: if ((DebugConsole.dgtRequestRegs & 1) != 0) {
6770: ExpressionEvaluator.ElementType.ETY_COMMAND_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
6771: }
6772: if ((DebugConsole.dgtRequestRegs & 2) != 0) {
6773: ExpressionEvaluator.ElementType.ETY_COMMAND_FLOAT_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
6774: }
6775: if ((DebugConsole.dgtRequestRegs & 4) != 0) {
6776: DebugConsole.dgtPrintPrompt ();
6777: }
6778: DebugConsole.dgtRequestRegs = 0;
6779: }
6780:
6781: for (AbstractButton button : mpuButtonsRunning) {
6782: button.setEnabled (false);
6783: }
6784:
6785: for (AbstractButton button : mpuButtonsStopped) {
6786: button.setEnabled (true);
6787: }
6788: }
6789:
6790:
6791:
6792: public static JButton mpuMakeBreakButton () {
6793: return mpuAddButtonRunning (
6794: Multilingual.mlnToolTipText (
6795: ComponentFactory.createImageButton (
6796: LnF.LNF_BREAK_IMAGE,
6797: LnF.LNF_BREAK_DISABLED_IMAGE,
6798: "Stop", mpuDebugActionListener),
6799: "ja", "停止")
6800: );
6801: }
6802:
6803:
6804:
6805: public static JButton mpuMakeTraceButton () {
6806: return mpuAddButtonStopped (
6807: Multilingual.mlnToolTipText (
6808: ComponentFactory.createImageButton (
6809: LnF.LNF_TRACE_IMAGE,
6810: LnF.LNF_TRACE_DISABLED_IMAGE,
6811: "Trace", mpuDebugActionListener),
6812: "ja", "トレース")
6813: );
6814: }
6815:
6816:
6817:
6818: public static JButton mpuMakeTrace10Button () {
6819: return mpuAddButtonStopped (
6820: Multilingual.mlnToolTipText (
6821: ComponentFactory.createImageButton (
6822: LnF.LNF_TRACE_10_IMAGE,
6823: LnF.LNF_TRACE_10_DISABLED_IMAGE,
6824: "Trace 10 times", mpuDebugActionListener),
6825: "ja", "トレース 10 回")
6826: );
6827: }
6828:
6829:
6830:
6831: public static JButton mpuMakeTrace100Button () {
6832: return mpuAddButtonStopped (
6833: Multilingual.mlnToolTipText (
6834: ComponentFactory.createImageButton (
6835: LnF.LNF_TRACE_100_IMAGE,
6836: LnF.LNF_TRACE_100_DISABLED_IMAGE,
6837: "Trace 100 times", mpuDebugActionListener),
6838: "ja", "トレース 100 回")
6839: );
6840: }
6841:
6842:
6843:
6844: public static JButton mpuMakeStepButton () {
6845: return mpuAddButtonStopped (
6846: Multilingual.mlnToolTipText (
6847: ComponentFactory.createImageButton (
6848: LnF.LNF_STEP_IMAGE,
6849: LnF.LNF_STEP_DISABLED_IMAGE,
6850: "Step", mpuDebugActionListener),
6851: "ja", "ステップ")
6852: );
6853: }
6854:
6855:
6856:
6857: public static JButton mpuMakeStep10Button () {
6858: return mpuAddButtonStopped (
6859: Multilingual.mlnToolTipText (
6860: ComponentFactory.createImageButton (
6861: LnF.LNF_STEP_10_IMAGE,
6862: LnF.LNF_STEP_10_DISABLED_IMAGE,
6863: "Step 10 times", mpuDebugActionListener),
6864: "ja", "ステップ 10 回")
6865: );
6866: }
6867:
6868:
6869:
6870: public static JButton mpuMakeStep100Button () {
6871: return mpuAddButtonStopped (
6872: Multilingual.mlnToolTipText (
6873: ComponentFactory.createImageButton (
6874: LnF.LNF_STEP_100_IMAGE,
6875: LnF.LNF_STEP_100_DISABLED_IMAGE,
6876: "Step 100 times", mpuDebugActionListener),
6877: "ja", "ステップ 100 回")
6878: );
6879: }
6880:
6881:
6882:
6883: public static JButton mpuMakeReturnButton () {
6884: return mpuAddButtonStopped (
6885: Multilingual.mlnToolTipText (
6886: ComponentFactory.createImageButton (
6887: LnF.LNF_STEP_UNTIL_RETURN_IMAGE,
6888: LnF.LNF_STEP_UNTIL_RETURN_DISABLED_IMAGE,
6889: "Step until return", mpuDebugActionListener),
6890: "ja", "ステップアンティルリターン")
6891: );
6892: }
6893:
6894:
6895:
6896: public static JButton mpuMakeRunButton () {
6897: return mpuAddButtonStopped (
6898: Multilingual.mlnToolTipText (
6899: ComponentFactory.createImageButton (
6900: LnF.LNF_RUN_IMAGE,
6901: LnF.LNF_RUN_DISABLED_IMAGE,
6902: "Run", mpuDebugActionListener),
6903: "ja", "実行")
6904: );
6905: }
6906:
6907:
6908:
6909: public static <T extends AbstractButton> T mpuAddButtonRunning (T button) {
6910: button.setEnabled (mpuTask != null);
6911: mpuButtonsRunning.add (button);
6912: return button;
6913: }
6914:
6915:
6916:
6917: public static <T extends AbstractButton> T mpuAddButtonStopped (T button) {
6918: button.setEnabled (mpuTask == null);
6919: mpuButtonsStopped.add (button);
6920: return button;
6921: }
6922:
6923:
6924:
6925:
6926:
6927:
6928:
6929:
6930:
6931:
6932:
6933:
6934:
6935:
6936:
6937:
6938: public static final int EMX_OPCODE_BASE = 0x4e00;
6939: public static final int EMX_OPCODE_HFSBOOT = EMX_OPCODE_BASE + 0x00;
6940: public static final int EMX_OPCODE_HFSINST = EMX_OPCODE_BASE + 0x01;
6941: public static final int EMX_OPCODE_HFSSTR = EMX_OPCODE_BASE + 0x02;
6942: public static final int EMX_OPCODE_HFSINT = EMX_OPCODE_BASE + 0x03;
6943: public static final int EMX_OPCODE_EMXNOP = EMX_OPCODE_BASE + 0x04;
6944: public static final int EMX_OPCODE_EMXWAIT = EMX_OPCODE_BASE + 0x05;
6945:
6946: public static final String[] EMX_MNEMONIC_ARRAY = {
6947: "hfsboot",
6948: "hfsinst",
6949: "hfsstr",
6950: "hfsint",
6951: "emxnop",
6952: "emxwait",
6953: };
6954:
6955:
6956:
6957:
6958: public static void emxNop () {
6959: if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x00007140) {
6960: int head = regRn[9];
6961: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
6962:
6963:
6964: emxPatchPCM8A (head, tail);
6965:
6966:
6967: emxCheckRSDRV202 (head, tail);
6968: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000716c) {
6969: int head = regRn[9];
6970: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
6971:
6972:
6973: emxPatch060turbosys (head, tail);
6974:
6975:
6976: if (Z8530.SCC_FSX_MOUSE) {
6977: emxCheckFSX (head, tail);
6978: }
6979:
6980:
6981: if (HFS.HFS_USE_TWENTY_ONE) {
6982: emxCheckTwentyOne (head, tail);
6983: }
6984:
6985:
6986: LabeledAddress.lblClear ();
6987: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000972c) {
6988: int head = regRn[8] + 256;
6989:
6990: int tail = MC68060.mmuPeekLong (head - 208, 1);
6991:
6992:
6993: emxCheckBSIO021 (head, tail);
6994:
6995:
6996: emxPatchPCM8A (head, tail);
6997:
6998:
6999: emxCheckTMSIO031 (head, tail);
7000:
7001:
7002: LabeledAddress.lblClear ();
7003:
7004:
7005: if (dbgStopAtStart) {
7006: InstructionBreakPoint.ibpInstant (regRn[12], 0);
7007: }
7008: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000a090) {
7009: int head = regRn[8] + 256;
7010: int tail = MC68060.mmuPeekLongData (regRn[8] + 8, 1);
7011: String name = MC68060.mmuPeekStringZ (head - 60, 1);
7012: if (name.equalsIgnoreCase ("fsx.x")) {
7013:
7014:
7015: if (Z8530.SCC_FSX_MOUSE) {
7016: emxCheckFSX (head, tail);
7017: }
7018: }
7019: if (name.equalsIgnoreCase ("TwentyOne.x")) {
7020:
7021:
7022: if (HFS.HFS_USE_TWENTY_ONE) {
7023: emxCheckTwentyOne (head, tail);
7024: }
7025: }
7026: }
7027: }
7028:
7029: public static final int[] emxPCM8AFFMap = {
7030: 0x00000138, 0x000001f6, 0x00000394, 0x000011ec, 0x0000120a, 0x00001400, 0x00001814, 0x00001870, 0x00001882, 0x0000188a,
7031: 0x00001892, 0x000018a2, 0x000018a8, 0x000018ca, 0x000018d4, 0x000018e0, 0x000018e8, 0x00001908, 0x000019e4, 0x00001afa,
7032: 0x00001b58, 0x00001b7c, 0x00001bac, 0x00001c38, 0x00001ccc, 0x000021f8, 0x00002250, 0x00002258, 0x00002290, 0x000022a6,
7033: 0x000022b0, 0x000022c0, 0x000022c8, 0x000022de, 0x000022ea, 0x000030c8, 0x000030de, 0x000030e6, 0x000030ea, 0x000030f6,
7034: 0x00003112, 0x00003188, 0x0000334c, 0x0000338a, 0x000033a2, 0x000033c4, 0x000033d0, 0x0000341a, 0x00003428, 0x00003496,
7035: 0x000034a6, 0x000034d6, 0x0000fe0e, 0x0000fec8, 0x0000feec, 0x0000ff46, 0x0000ff4e,
7036: };
7037:
7038:
7039:
7040: public static void emxPatchPCM8A (int head, int tail) {
7041: if (head + 0x0000ff60 <= tail &&
7042: MC68060.mmuPeekLongData (head + 0x10f8, 1) == 0x50434d38 &&
7043: MC68060.mmuPeekLongData (head + 0x10fc, 1) == 0x41313032) {
7044: System.out.println (Multilingual.mlnJapanese ?
7045: "PCM8A.X 1.02 があります" :
7046: "PCM8A.X 1.02 exists");
7047: int patched = 0;
7048: int failed = 0;
7049:
7050: for (int offset : emxPCM8AFFMap) {
7051: if (MC68060.mmuPeekByteZeroData (head + offset, 1) == 0xff) {
7052: MC68060.mmuPokeByteData (head + offset, 0x00, 1);
7053: patched++;
7054: } else {
7055: failed++;
7056: }
7057: }
7058: if (patched != 0) {
7059: System.out.printf (Multilingual.mlnJapanese ?
7060: "PCM8A.X 1.02 にパッチをあてました (%d/%d)\n" :
7061: "PCM8A.X 1.02 was patched (%d/%d)\n",
7062: patched, patched + failed);
7063: }
7064: }
7065: }
7066:
7067:
7068:
7069: public static void emxPatch060turbosys (int head, int tail) {
7070:
7071:
7072:
7073:
7074: if (head + 0x00002000 <= tail &&
7075: MC68060.mmuPeekLongData (head + 0x00000ec0, 1) == 0x203c302e &&
7076: MC68060.mmuPeekLongData (head + 0x00000ec4, 1) == 0x3536227c &&
7077: MC68060.mmuPeekLongData (head + 0x00000ec8, 1) == 0x30363054) {
7078: System.out.println (Multilingual.mlnJapanese ?
7079: "060turbo.sys 0.56 があります" :
7080: "060turbo.sys 0.56 exists");
7081:
7082:
7083:
7084: int patched = 0;
7085: int failed = 0;
7086: if (MC68060.mmuPeekLongData (head + 0x000021e6, 1) == 0x08f90004 &&
7087: MC68060.mmuPeekLongData (head + 0x000021ea, 1) == 0x00ed0070) {
7088: MC68060.mmuPokeWordData (head + 0x000021e6, 0x0839, 1);
7089: patched++;
7090: } else {
7091: failed++;
7092: }
7093: System.out.printf (Multilingual.mlnJapanese ?
7094: "060turbo.sys 0.56 にパッチをあてました (%d/%d)\n" :
7095: "060turbo.sys 0.56 was patched (%d/%d)\n",
7096: patched, patched + failed);
7097: }
7098: }
7099:
7100:
7101:
7102: public static void emxCheckFSX (int head, int tail) {
7103: if (Z8530.SCC_FSX_MOUSE) {
7104: if (head + 0x00063200 <= tail &&
7105: "\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))) {
7106: System.out.println (Multilingual.mlnJapanese ?
7107: "FSX.X 3.10 があります" :
7108: "FSX.X 3.10 exists");
7109: Z8530.sccFSXMouseHook = head + 0x04f82a;
7110: Z8530.sccFSXMouseWork = head + 0x063184;
7111: }
7112: }
7113: }
7114:
7115:
7116:
7117:
7118:
7119:
7120: public static void emxCheckRSDRV202 (int head, int tail) {
7121: if (head + 0x000ea6 <= tail &&
7122: MC68060.mmuPeekEquals (head + 0x000e4e, "RS-232C DRIVER for X68000 version 2.02")) {
7123: if (RS232CTerminal.trmRSDRV202Head != head) {
7124: RS232CTerminal.trmRSDRV202Head = head;
7125: int[] patchData = {
7126:
7127:
7128: 0x05f8, 0x000a, 0x000b,
7129:
7130: 0x0600, 0xd040, 0x2048,
7131:
7132: 0x060e, 0x3030, 0x4e90,
7133: 0x0610, 0x0000, 0x2048,
7134:
7135: 0x074e, 0x0821, 0x2041,
7136: 0x0750, 0x0410, 0x3200,
7137: 0x0752, 0x0207, 0x303c,
7138: 0x0754, 0x0102, 0x0823,
7139: 0x0756, 0x0080, 0xe268,
7140: 0x0758, 0x003f, 0x72fe,
7141: 0x075a, 0x001f, 0xd141,
7142: 0x075c, 0x000e, 0x2208,
7143: 0x075e, 0x0006, 0x4e75,
7144:
7145:
7146: 0x0ab0, 0x0040, 0x0400,
7147: 0x0ad2, 0x0040, 0x0400,
7148: 0x0af4, 0x0040, 0x0400,
7149: 0x0b16, 0x0040, 0x0400,
7150: 0x0b38, 0x0040, 0x0400,
7151:
7152:
7153: 0x0cae, 0x0009, 0x000b,
7154: };
7155: int patched = 0;
7156: int failed = 0;
7157: for (int i = 0; i < patchData.length; i += 3) {
7158: int a = head + patchData[i];
7159: int b = patchData[i + 1];
7160: int c = patchData[i + 2];
7161: int d = MC68060.mmuPeekWordZeroData (a, 1);
7162: if (d == b) {
7163: MC68060.mmuPokeWordData (a, c, 1);
7164: patched++;
7165: } else if (d != c) {
7166: failed++;
7167: }
7168: }
7169: System.out.printf ("RSDRV.SYS 2.02 found at %08X and patched (%d/%d)\n", head, patched, patched + failed);
7170: }
7171: }
7172: }
7173:
7174:
7175:
7176:
7177:
7178: public static void emxCheckTMSIO031 (int head, int tail) {
7179: if (head + 0x000fc4 <= tail &&
7180: MC68060.mmuPeekEquals (head + 0x000d1c, "TMSIO version 0.31 Copyright (C) 1990-93 by Miki Hoshino")) {
7181: if (RS232CTerminal.trmTMSIO031Head != head) {
7182: RS232CTerminal.trmTMSIO031Head = head;
7183: System.out.printf ("TMSIO 0.31 found at %08X\n", head);
7184: }
7185: }
7186: }
7187:
7188:
7189:
7190:
7191:
7192: public static void emxCheckBSIO021 (int head, int tail) {
7193: if (head + 0x001c2c <= tail &&
7194: MC68060.mmuPeekEquals (head + 0x001a66, "BSIO version 0.21 Copyright (C) 1994 By BAZU")) {
7195: if (RS232CTerminal.trmBSIO021Head != head) {
7196: RS232CTerminal.trmBSIO021Head = head;
7197: System.out.printf ("BSIO 0.21 found at %08X\n", head);
7198: }
7199: }
7200: }
7201:
7202:
7203:
7204: public static void emxCheckTwentyOne (int head, int tail) {
7205: if (HFS.HFS_USE_TWENTY_ONE &&
7206: head + 64 <= tail) {
7207: if (MainMemory.mmrTwentyOneOptionAddress != 0 ||
7208: MainMemory.mmrHumanVersion <= 0) {
7209: return;
7210: }
7211: int name1 = MC68060.mmuPeekLongData (head + 14, 1);
7212: if (name1 == ('*' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7213: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7214: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '*')) {
7215: MainMemory.mmrTwentyOneOptionAddress = -1;
7216: }
7217: } else if (name1 == ('?' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7218: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7219: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '?') ||
7220: name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | 'E')) {
7221: System.out.println (Multilingual.mlnJapanese ?
7222: "TwentyOne.x があります" :
7223: "TwentyOne.x exists");
7224: MainMemory.mmrTwentyOneOptionAddress = head + 22;
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:
7275:
7276:
7277:
7278:
7279:
7280: public static final boolean IRP_BITREV_REVERSE = false;
7281: public static final boolean IRP_BITREV_SHIFT = false;
7282: public static final boolean IRP_BITREV_TABLE = true;
7283:
7284: public static final boolean IRP_MOVEM_MAINMEMORY = true;
7285: public static final boolean IRP_MOVEM_EXPAND = false;
7286: public static final boolean IRP_MOVEM_LOOP = false;
7287: public static final boolean IRP_MOVEM_SHIFT_LEFT = false;
7288: public static final boolean IRP_MOVEM_SHIFT_RIGHT = true;
7289: public static final boolean IRP_MOVEM_ZEROS = false;
7290:
7291:
7292: public static void irpReset () {
7293:
7294: CRTC.crtReset ();
7295: VideoController.vcnReset ();
7296: HD63450.dmaReset ();
7297: MC68901.mfpReset ();
7298: Keyboard.kbdReset ();
7299: RP5C15.rtcReset ();
7300: PrinterPort.prnReset ();
7301: SoundSource.sndReset ();
7302: OPM.opmReset ();
7303: ADPCM.pcmReset ();
7304: FDC.fdcReset ();
7305: IOInterrupt.ioiReset ();
7306: eb2Reset ();
7307: if (HostCDROM.HCD_ENABLED) {
7308: HostCDROM.hcdReset ();
7309: }
7310: SPC.spcReset ();
7311: Z8530.sccReset ();
7312: RS232CTerminal.trmReset ();
7313: PPI.ppiReset ();
7314: HFS.hfsReset ();
7315: SpriteScreen.sprReset ();
7316:
7317: xt3Reset ();
7318: SRAM.smrReset ();
7319: CONDevice.conReset ();
7320: TextCopy.txcReset ();
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:
7900:
7901:
7902:
7903:
7904:
7905:
7906:
7907:
7908: 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);
7909:
7910: public static final boolean EFA_SEPARATE_AR = false;
7911:
7912:
7913:
7914:
7915:
7916:
7917: public static final boolean BUS_SPLIT_UNALIGNED_LONG = false;
7918:
7919:
7920: public static final int BUS_MOTHER_BITS = 24;
7921: public static final int BUS_MOTHER_SIZE = BUS_MOTHER_BITS < 32 ? 1 << BUS_MOTHER_BITS : 0;
7922: public static final int BUS_MOTHER_MASK = BUS_MOTHER_SIZE - 1;
7923:
7924: public static final int BUS_ARRAY_SIZE = BUS_MOTHER_SIZE;
7925:
7926:
7927: public static final int BUS_PAGE_BITS = 12;
7928: public static final int BUS_PAGE_SIZE = 1 << BUS_PAGE_BITS;
7929: public static final int BUS_PAGE_COUNT = 1 << (32 - BUS_PAGE_BITS);
7930:
7931:
7932: public static final int MPU_SS_BYTE = 0;
7933: public static final int MPU_SS_WORD = 1;
7934: public static final int MPU_SS_LONG = 2;
7935:
7936:
7937: public static final int MPU_WR_WRITE = 0;
7938: public static final int MPU_WR_READ = 1;
7939:
7940:
7941: public static final int MPU_US_USER = 0;
7942: public static final int MPU_US_SUPERVISOR = 1;
7943:
7944:
7945: public static final MemoryMappedDevice[] busUserMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
7946: public static final MemoryMappedDevice[] busSuperMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
7947: public static MemoryMappedDevice[] busMemoryMap;
7948:
7949:
7950: public static boolean busHimem68000;
7951:
7952:
7953: public static final int BUS_HIGH_MEMORY_START = 0x01000000;
7954: public static int busHighMemorySize;
7955: public static byte[] busHighMemoryArray;
7956: public static boolean busHighMemorySaveOn;
7957: public static boolean busHighMemory060turboOn;
7958:
7959:
7960: public static final int BUS_LOCAL_MEMORY_START = 0x10000000;
7961: public static int busLocalMemorySize;
7962: public static byte[] busLocalMemoryArray;
7963: public static boolean busLocalMemorySaveOn;
7964:
7965:
7966: public static final byte[] BUS_DUMMY_MEMORY_ARRAY = new byte[0];
7967: public static int busRequestExMemoryStart;
7968: public static int busRequestExMemorySize;
7969: public static byte[] busRequestExMemoryArray;
7970: public static int busExMemoryStart;
7971: public static int busExMemorySize;
7972: public static byte[] busExMemoryArray;
7973:
7974:
7975: public static boolean busRequestCutFC2Pin;
7976: public static boolean busCutFC2Pin;
7977:
7978:
7979:
7980: public static void busInit () {
7981:
7982:
7983: if (!DataBreakPoint.DBP_ON) {
7984: busMemoryMap = busSuperMap;
7985: }
7986:
7987:
7988: int highMemorySizeMB = Settings.sgsGetInt ("highmemory");
7989: busHighMemorySize = highMemorySizeMB == 16 ? highMemorySizeMB << 20 : 0 << 20;
7990: if (busHighMemorySize == 0) {
7991: System.out.println (Multilingual.mlnJapanese ?
7992: "X68030/Xellent30 のハイメモリはありません" :
7993: "X68030/Xellent30 high memory does not exists");
7994: } else {
7995: System.out.printf (Multilingual.mlnJapanese ?
7996: "X68030/Xellent30 のハイメモリのサイズは %dMB です\n" :
7997: "X68030/Xellent30 high memory size is %dMB\n",
7998: busHighMemorySize >> 20);
7999: }
8000: busHighMemoryArray = new byte[busHighMemorySize];
8001:
8002: busHimem68000 = Settings.sgsGetOnOff ("himem68000");
8003:
8004: busHighMemorySaveOn = Settings.sgsGetOnOff ("highmemorysave");
8005: busHighMemory060turboOn = Settings.sgsGetOnOff ("highmemory060turbo");
8006:
8007: byte[] highMemoryArray = Settings.sgsGetData ("highmemorydata");
8008: if (busHighMemorySize != 0) {
8009: if (highMemoryArray.length != 0) {
8010: System.out.println (Multilingual.mlnJapanese ?
8011: "X68030/Xellent30 のハイメモリのデータを復元します" :
8012: "X68030/Xellent30 high memory data is restored");
8013: System.arraycopy (highMemoryArray, 0, busHighMemoryArray, 0, Math.min (highMemoryArray.length, busHighMemorySize));
8014: } else {
8015: System.out.println (Multilingual.mlnJapanese ?
8016: "X68030/Xellent30 のハイメモリをゼロクリアします" :
8017: "X68030/Xellent30 high memory is zero-cleared");
8018: }
8019: if (highMemoryArray.length < busHighMemorySize) {
8020: Arrays.fill (busHighMemoryArray, highMemoryArray.length, busHighMemorySize, (byte) 0);
8021: }
8022: }
8023:
8024:
8025: int localMemorySizeMB = Settings.sgsGetInt ("localmemory");
8026: busLocalMemorySize = (localMemorySizeMB == 16 ||
8027: localMemorySizeMB == 32 ||
8028: localMemorySizeMB == 64 ||
8029: localMemorySizeMB == 128 ||
8030: localMemorySizeMB == 256 ||
8031: localMemorySizeMB == 384 ||
8032: localMemorySizeMB == 512 ||
8033: localMemorySizeMB == 768 ?
8034: localMemorySizeMB << 20 :
8035: 128 << 20);
8036: if (busLocalMemorySize == 0) {
8037: System.out.println (Multilingual.mlnJapanese ?
8038: "060turbo のハイメモリはありません" :
8039: "060turbo high memory does not exists");
8040: } else {
8041: System.out.printf (Multilingual.mlnJapanese ?
8042: "060turbo のハイメモリのサイズは %dMB です\n" :
8043: "060turbo high memory size is %dMB\n",
8044: busLocalMemorySize >> 20);
8045: }
8046: busLocalMemoryArray = new byte[busLocalMemorySize];
8047:
8048: busLocalMemorySaveOn = Settings.sgsGetOnOff ("localmemorysave");
8049:
8050: byte[] localMemoryArray = Settings.sgsGetData ("localmemorydata");
8051: if (busLocalMemorySize != 0) {
8052: if (localMemoryArray.length != 0) {
8053: System.out.println (Multilingual.mlnJapanese ?
8054: "060turbo のハイメモリのデータを復元します" :
8055: "060turbo high memory data is restored");
8056: System.arraycopy (localMemoryArray, 0, busLocalMemoryArray, 0, Math.min (localMemoryArray.length, busLocalMemorySize));
8057: } else {
8058: System.out.println (Multilingual.mlnJapanese ?
8059: "060turbo のハイメモリをゼロクリアします" :
8060: "060turbo high memory is zero-cleared");
8061: }
8062: if (localMemoryArray.length < busLocalMemorySize) {
8063: Arrays.fill (busLocalMemoryArray, localMemoryArray.length, busLocalMemorySize, (byte) 0);
8064: }
8065: }
8066:
8067:
8068: busExMemoryStart = busRequestExMemoryStart = 0x10000000;
8069: busExMemorySize = busRequestExMemorySize = 0 << 20;
8070: busExMemoryArray = busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
8071:
8072:
8073: busRequestCutFC2Pin = Settings.sgsGetOnOff ("cutfc2pin");
8074: busCutFC2Pin = !busRequestCutFC2Pin;
8075:
8076: busUpdateMemoryMap ();
8077:
8078: }
8079:
8080:
8081:
8082: public static void busTini () {
8083: Settings.sgsPutOnOff ("himem68000", busHimem68000);
8084: Settings.sgsPutInt ("highmemory", busHighMemorySize >>> 20);
8085: Settings.sgsPutOnOff ("highmemorysave", busHighMemorySaveOn);
8086: Settings.sgsPutOnOff ("highmemory060turbo", busHighMemory060turboOn);
8087: Settings.sgsPutData ("highmemorydata", busHighMemorySaveOn ? busHighMemoryArray : new byte[0]);
8088: Settings.sgsPutInt ("localmemory", busLocalMemorySize >>> 20);
8089: Settings.sgsPutOnOff ("localmemorysave", busLocalMemorySaveOn);
8090: Settings.sgsPutData ("localmemorydata", busLocalMemorySaveOn ? busLocalMemoryArray : new byte[0]);
8091: Settings.sgsPutOnOff ("cutfc2pin", busRequestCutFC2Pin);
8092: }
8093:
8094: public static void busUpdateMemoryMap () {
8095: if (busExMemoryStart == busRequestExMemoryStart &&
8096: busExMemorySize == busRequestExMemorySize &&
8097: busExMemoryArray == busRequestExMemoryArray &&
8098: busExMemoryArray.length == busExMemorySize &&
8099: busCutFC2Pin == busRequestCutFC2Pin) {
8100: return;
8101: }
8102:
8103: busExMemoryStart = busRequestExMemoryStart;
8104: busExMemorySize = busRequestExMemorySize;
8105: busExMemoryArray = busRequestExMemoryArray;
8106: if (busExMemoryArray.length != busExMemorySize) {
8107: byte[] newArray = new byte[busExMemorySize];
8108: int copySize = Math.min (busExMemoryArray.length, busExMemorySize);
8109: if (copySize > 0) {
8110: System.arraycopy (busExMemoryArray, 0, newArray, 0, copySize);
8111: }
8112: if (busExMemoryArray == busHighMemoryArray) {
8113: busHighMemoryArray = newArray;
8114: } else if (busExMemoryArray == busLocalMemoryArray) {
8115: busLocalMemoryArray = newArray;
8116: }
8117: busExMemoryArray = newArray;
8118: }
8119:
8120: busCutFC2Pin = busRequestCutFC2Pin;
8121:
8122:
8123:
8124:
8125:
8126:
8127:
8128:
8129:
8130:
8131:
8132:
8133: busSuper (MemoryMappedDevice.MMD_MMR, 0x00000000, 0x00002000);
8134: busUser ( MemoryMappedDevice.MMD_MMR, 0x00002000, 0x00c00000);
8135:
8136:
8137:
8138:
8139:
8140:
8141:
8142:
8143:
8144:
8145:
8146:
8147:
8148:
8149:
8150:
8151:
8152:
8153:
8154:
8155:
8156:
8157:
8158:
8159: busSuper (MemoryMappedDevice.MMD_GE0, 0x00c00000, 0x00c80000);
8160: busSuper (MemoryMappedDevice.MMD_GE1, 0x00c80000, 0x00d00000);
8161: busSuper (MemoryMappedDevice.MMD_GE2, 0x00d00000, 0x00d80000);
8162: busSuper (MemoryMappedDevice.MMD_GE3, 0x00d80000, 0x00e00000);
8163:
8164:
8165:
8166:
8167: busSuper (MemoryMappedDevice.MMD_TXT, 0x00e00000, 0x00e80000);
8168:
8169:
8170:
8171:
8172: busSuper (MemoryMappedDevice.MMD_CRT, 0x00e80000, 0x00e82000);
8173:
8174:
8175:
8176:
8177:
8178: busSuper (MemoryMappedDevice.MMD_VCN, 0x00e82000, 0x00e84000);
8179:
8180:
8181:
8182:
8183: busSuper (MemoryMappedDevice.MMD_DMA, 0x00e84000, 0x00e86000);
8184:
8185:
8186:
8187:
8188: busSuper (MemoryMappedDevice.MMD_SVS, 0x00e86000, 0x00e88000);
8189:
8190:
8191:
8192:
8193: busSuper (MemoryMappedDevice.MMD_MFP, 0x00e88000, 0x00e8a000);
8194:
8195:
8196:
8197:
8198: busSuper (MemoryMappedDevice.MMD_RTC_FIRST, 0x00e8a000, 0x00e8c000);
8199:
8200:
8201:
8202:
8203: busSuper (MemoryMappedDevice.MMD_PRN, 0x00e8c000, 0x00e8e000);
8204:
8205:
8206:
8207:
8208: busSuper (MemoryMappedDevice.MMD_SYS, 0x00e8e000, 0x00e90000);
8209:
8210:
8211:
8212:
8213: busSuper (MemoryMappedDevice.MMD_OPM, 0x00e90000, 0x00e92000);
8214:
8215:
8216:
8217:
8218: busSuper (MemoryMappedDevice.MMD_PCM, 0x00e92000, 0x00e94000);
8219:
8220:
8221:
8222:
8223: busSuper (MemoryMappedDevice.MMD_FDC, 0x00e94000, 0x00e96000);
8224:
8225:
8226:
8227:
8228:
8229: busSuper (MemoryMappedDevice.MMD_HDC, 0x00e96000, 0x00e98000);
8230:
8231:
8232:
8233:
8234: busSuper (MemoryMappedDevice.MMD_SCC, 0x00e98000, 0x00e9a000);
8235:
8236:
8237:
8238:
8239: busSuper (MemoryMappedDevice.MMD_PPI, 0x00e9a000, 0x00e9c000);
8240:
8241:
8242:
8243:
8244: busSuper (MemoryMappedDevice.MMD_IOI, 0x00e9c000, 0x00e9e000);
8245:
8246:
8247:
8248:
8249:
8250:
8251:
8252:
8253:
8254: busSuper (MemoryMappedDevice.MMD_XB1, 0x00e9e000, 0x00ea0000);
8255:
8256:
8257:
8258:
8259:
8260: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ea0000, 0x00eae000);
8261:
8262:
8263:
8264:
8265:
8266:
8267:
8268:
8269:
8270:
8271:
8272:
8273:
8274:
8275:
8276: busSuper (MemoryMappedDevice.MMD_XB2, 0x00eae000, 0x00eb0000);
8277:
8278:
8279:
8280:
8281:
8282:
8283:
8284:
8285: busSuper (MemoryMappedDevice.MMD_SPR, 0x00eb0000, 0x00ec0000);
8286:
8287:
8288:
8289:
8290:
8291:
8292:
8293:
8294:
8295:
8296:
8297:
8298:
8299: busSuper (MemoryMappedDevice.MMD_XB3, 0x00ec0000, 0x00ed0000);
8300:
8301:
8302:
8303:
8304:
8305:
8306: busSuper (MemoryMappedDevice.MMD_SMR, 0x00ed0000, 0x00ed0000 + 16384);
8307: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ed0000 + 16384, 0x00ed0000 + 65536);
8308:
8309:
8310:
8311:
8312:
8313:
8314:
8315:
8316: busSuper (MemoryMappedDevice.MMD_XB4, 0x00ee0000, 0x00f00000);
8317:
8318:
8319:
8320:
8321:
8322:
8323:
8324:
8325:
8326:
8327: busSuper (MemoryMappedDevice.MMD_CG1, 0x00f00000, 0x00f40000);
8328:
8329:
8330:
8331:
8332:
8333:
8334:
8335: busSuper (MemoryMappedDevice.MMD_CG2, 0x00f40000, 0x00fc0000);
8336:
8337:
8338:
8339:
8340:
8341:
8342:
8343:
8344:
8345:
8346:
8347:
8348:
8349:
8350: busSuper (MemoryMappedDevice.MMD_ROM, 0x00fc0000, 0x01000000);
8351:
8352: }
8353:
8354: public static void busReset () {
8355: if (regSRS != 0) {
8356: if (DataBreakPoint.DBP_ON) {
8357: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpSuperMap;
8358: } else {
8359: busMemoryMap = busSuperMap;
8360: }
8361: } else {
8362: if (DataBreakPoint.DBP_ON) {
8363: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpUserMap;
8364: } else {
8365: busMemoryMap = busUserMap;
8366: }
8367: }
8368: }
8369:
8370:
8371:
8372:
8373:
8374: public static void busUser (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8375: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8376: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8377: if (false &&
8378: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8379: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8380: System.out.printf ("ERROR: busUser (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8381: }
8382: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8383: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8384: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8385: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8386: int startPage = blockStartPage + motherStartPage;
8387: int endPage = blockStartPage + motherEndPage;
8388: for (int page = startPage; page < endPage; page++) {
8389: MemoryMappedDevice superMmd = exMemoryStartPage <= page && page < exMemoryEndPage ? MemoryMappedDevice.MMD_XMM : mmd;
8390: busUserMap[page] = busSuperMap[page] = superMmd;
8391: if (InstructionBreakPoint.IBP_ON) {
8392: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8393: InstructionBreakPoint.ibpUserMap[page] = superMmd;
8394: }
8395: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8396: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8397: }
8398: }
8399: if (DataBreakPoint.DBP_ON) {
8400: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8401: DataBreakPoint.dbpUserMap[page] = superMmd;
8402: }
8403: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8404: DataBreakPoint.dbpSuperMap[page] = superMmd;
8405: }
8406: }
8407: }
8408: }
8409: }
8410:
8411:
8412:
8413:
8414:
8415: public static void busSuper (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8416: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8417: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8418: if (false &&
8419: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8420: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8421: System.out.printf ("ERROR: busSuper (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8422: }
8423: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8424: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8425: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8426: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8427: int startPage = blockStartPage + motherStartPage;
8428: int endPage = blockStartPage + motherEndPage;
8429: for (int page = startPage; page < endPage; page++) {
8430: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
8431: MemoryMappedDevice userMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : busCutFC2Pin ? mmd : MemoryMappedDevice.MMD_NUL;
8432: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
8433: busUserMap[page] = userMmd;
8434: busSuperMap[page] = superMmd;
8435: if (InstructionBreakPoint.IBP_ON) {
8436: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8437: InstructionBreakPoint.ibpUserMap[page] = userMmd;
8438: }
8439: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8440: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8441: }
8442: }
8443: if (DataBreakPoint.DBP_ON) {
8444: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8445: DataBreakPoint.dbpUserMap[page] = userMmd;
8446: }
8447: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8448: DataBreakPoint.dbpSuperMap[page] = superMmd;
8449: }
8450: }
8451: }
8452: }
8453: }
8454:
8455:
8456:
8457: public static byte busPbs (int a) {
8458: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a);
8459: }
8460:
8461:
8462:
8463: public static int busPbz (int a) {
8464: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a);
8465: }
8466:
8467:
8468:
8469: public static int busPws (int a) {
8470: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8471: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
8472: } else {
8473: int a1 = a + 1;
8474: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
8475: }
8476: }
8477:
8478:
8479:
8480: public static int busPwse (int a) {
8481: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
8482: }
8483:
8484:
8485:
8486: public static int busPwz (int a) {
8487: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8488: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
8489: } else {
8490: int a1 = a + 1;
8491: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
8492: }
8493: }
8494:
8495:
8496:
8497: public static int busPwze (int a) {
8498: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
8499: }
8500:
8501:
8502:
8503: public static int busPls (int a) {
8504: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8505: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
8506: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8507: int a2 = a + 2;
8508: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a) << 16 | busSuperMap[a2 >>> BUS_PAGE_BITS].mmdPwz (a2);
8509: } else {
8510: int a1 = a + 1;
8511: int a3 = a + 3;
8512: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 24 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPwz (a1) << 8 | busSuperMap[a3 >>> BUS_PAGE_BITS].mmdPbz (a3);
8513: }
8514: }
8515:
8516:
8517:
8518: public static int busPlsf (int a) {
8519: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
8520: }
8521:
8522:
8523:
8524: public static long busPqs (int a) {
8525: return (long) busPls (a) << 32 | busPls (a + 4) & 0xffffffffL;
8526: }
8527:
8528:
8529:
8530: public static int busSearchByte (int start, int end, int c) {
8531: for (int a = start; a < end; a++) {
8532: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) == c) {
8533: return a;
8534: }
8535: }
8536: return -1;
8537: }
8538: public static int busSearchWord (int start, int end, int c) {
8539: for (int a = start; a < end; a += 2) {
8540: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) == c) {
8541: return a;
8542: }
8543: }
8544: return -1;
8545: }
8546: public static int busSearchByteArray (int start, int end, int[] array) {
8547: int l = array.length;
8548: end -= l;
8549: int c = array[0];
8550: a:
8551: for (int a = start; a <= end; a++) {
8552: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) != c) {
8553: continue a;
8554: }
8555: for (int i = 1, b = a + 1; i < l; i++, b++) {
8556: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPbz (b) != array[i]) {
8557: continue a;
8558: }
8559: }
8560: return a;
8561: }
8562: return -1;
8563: }
8564: public static int busSearchWordArray (int start, int end, int[] array) {
8565: int l = array.length;
8566: end -= l;
8567: int c = array[0];
8568: a:
8569: for (int a = start; a <= end; a += 2) {
8570: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) != c) {
8571: continue a;
8572: }
8573: for (int i = 1, b = a + 2; i < l; i++, b += 2) {
8574: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPwz (b) != array[i]) {
8575: continue a;
8576: }
8577: }
8578: return a;
8579: }
8580: return -1;
8581: }
8582:
8583:
8584:
8585:
8586: public static byte busRbs (int a) throws M68kException {
8587: if (DataBreakPoint.DBP_ON) {
8588: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
8589: } else {
8590: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
8591: }
8592: }
8593:
8594:
8595:
8596: public static int busRbz (int a) throws M68kException {
8597: if (DataBreakPoint.DBP_ON) {
8598: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
8599: } else {
8600: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
8601: }
8602: }
8603:
8604:
8605:
8606: public static int busRws (int a) throws M68kException {
8607: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8608: if (DataBreakPoint.DBP_ON) {
8609: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8610: } else {
8611: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8612: }
8613: } else if (mpuIgnoreAddressError) {
8614: int a1 = a + 1;
8615: if (DataBreakPoint.DBP_ON) {
8616: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8617: } else {
8618: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8619: }
8620: } else {
8621: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8622: M68kException.m6eAddress = a;
8623: M68kException.m6eDirection = MPU_WR_READ;
8624: M68kException.m6eSize = MPU_SS_WORD;
8625: throw M68kException.m6eSignal;
8626: }
8627: }
8628:
8629:
8630:
8631:
8632: public static int busRwse (int a) throws M68kException {
8633: if (DataBreakPoint.DBP_ON) {
8634: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8635: } else {
8636: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8637: }
8638: }
8639:
8640:
8641:
8642: public static int busRwz (int a) throws M68kException {
8643: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8644: if (DataBreakPoint.DBP_ON) {
8645: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8646: } else {
8647: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8648: }
8649: } else if (mpuIgnoreAddressError) {
8650: int a1 = a + 1;
8651: if (DataBreakPoint.DBP_ON) {
8652: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8653: } else {
8654: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8655: }
8656: } else {
8657: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8658: M68kException.m6eAddress = a;
8659: M68kException.m6eDirection = MPU_WR_READ;
8660: M68kException.m6eSize = MPU_SS_WORD;
8661: throw M68kException.m6eSignal;
8662: }
8663: }
8664:
8665:
8666:
8667:
8668: public static int busRwze (int a) throws M68kException {
8669: if (DataBreakPoint.DBP_ON) {
8670: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8671: } else {
8672: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8673: }
8674: }
8675:
8676:
8677:
8678: public static int busRls (int a) throws M68kException {
8679: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8680: if (DataBreakPoint.DBP_ON) {
8681: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8682: } else {
8683: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8684: }
8685: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8686: int a2 = a + 2;
8687: if (BUS_SPLIT_UNALIGNED_LONG) {
8688: if (DataBreakPoint.DBP_ON) {
8689: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8690: } else {
8691: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8692: }
8693: } else {
8694: MemoryMappedDevice mmd;
8695: MemoryMappedDevice mmd2;
8696: if (DataBreakPoint.DBP_ON) {
8697: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8698: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8699: } else {
8700: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8701: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8702: }
8703: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
8704: }
8705: } else if (mpuIgnoreAddressError) {
8706: int a1 = a + 1;
8707: int a3 = a + 3;
8708: if (DataBreakPoint.DBP_ON) {
8709: 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);
8710: } else {
8711: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 24 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRwz (a1) << 8 | busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdRbz (a3);
8712: }
8713: } else {
8714: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8715: M68kException.m6eAddress = a;
8716: M68kException.m6eDirection = MPU_WR_READ;
8717: M68kException.m6eSize = MPU_SS_LONG;
8718: throw M68kException.m6eSignal;
8719: }
8720: }
8721:
8722:
8723:
8724:
8725: public static int busRlse (int a) throws M68kException {
8726: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8727: if (DataBreakPoint.DBP_ON) {
8728: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8729: } else {
8730: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8731: }
8732: } else {
8733: int a2 = a + 2;
8734: if (BUS_SPLIT_UNALIGNED_LONG) {
8735: if (DataBreakPoint.DBP_ON) {
8736: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8737: } else {
8738: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8739: }
8740: } else {
8741: MemoryMappedDevice mmd;
8742: MemoryMappedDevice mmd2;
8743: if (DataBreakPoint.DBP_ON) {
8744: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8745: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8746: } else {
8747: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8748: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8749: }
8750: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
8751: }
8752: }
8753: }
8754:
8755:
8756:
8757:
8758: public static int busRlsf (int a) throws M68kException {
8759: if (DataBreakPoint.DBP_ON) {
8760: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8761: } else {
8762: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8763: }
8764: }
8765:
8766:
8767:
8768: public static long busRqs (int a) throws M68kException {
8769: return (long) busRls (a) << 32 | busRls (a + 4) & 0xffffffffL;
8770: }
8771:
8772:
8773:
8774: public static void busWb (int a, int d) throws M68kException {
8775: if (DataBreakPoint.DBP_ON) {
8776: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
8777: } else {
8778: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
8779: }
8780: }
8781:
8782:
8783:
8784: public static void busWw (int a, int d) throws M68kException {
8785: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8786: if (DataBreakPoint.DBP_ON) {
8787: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8788: } else {
8789: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8790: }
8791: } else if (mpuIgnoreAddressError) {
8792: int a1 = a + 1;
8793: if (DataBreakPoint.DBP_ON) {
8794: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
8795: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
8796: } else {
8797: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
8798: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
8799: }
8800: } else {
8801: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8802: M68kException.m6eAddress = a;
8803: M68kException.m6eDirection = MPU_WR_WRITE;
8804: M68kException.m6eSize = MPU_SS_WORD;
8805: throw M68kException.m6eSignal;
8806: }
8807: }
8808:
8809:
8810:
8811:
8812: public static void busWwe (int a, int d) throws M68kException {
8813: if (DataBreakPoint.DBP_ON) {
8814: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8815: } else {
8816: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8817: }
8818: }
8819:
8820:
8821:
8822: public static void busWl (int a, int d) throws M68kException {
8823: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8824: if (DataBreakPoint.DBP_ON) {
8825: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8826: } else {
8827: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8828: }
8829: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8830: int a2 = a + 2;
8831: if (BUS_SPLIT_UNALIGNED_LONG) {
8832: if (DataBreakPoint.DBP_ON) {
8833: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8834: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8835: } else {
8836: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8837: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8838: }
8839: } else {
8840: MemoryMappedDevice mmd;
8841: MemoryMappedDevice mmd2;
8842: if (DataBreakPoint.DBP_ON) {
8843: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8844: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8845: } else {
8846: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8847: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8848: }
8849: if (mmd == mmd2) {
8850: mmd.mmdWl (a, d);
8851: } else {
8852: mmd.mmdWw (a, d >> 16);
8853: mmd2.mmdWw (a2, d);
8854: }
8855: }
8856: } else if (mpuIgnoreAddressError) {
8857: int a1 = a + 1;
8858: int a3 = a + 3;
8859: if (DataBreakPoint.DBP_ON) {
8860: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
8861: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
8862: DataBreakPoint.dbpMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
8863: } else {
8864: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
8865: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
8866: busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
8867: }
8868: } else {
8869: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8870: M68kException.m6eAddress = a;
8871: M68kException.m6eDirection = MPU_WR_WRITE;
8872: M68kException.m6eSize = MPU_SS_LONG;
8873: throw M68kException.m6eSignal;
8874: }
8875: }
8876:
8877:
8878:
8879:
8880: public static void busWlf (int a, int d) throws M68kException {
8881: if (DataBreakPoint.DBP_ON) {
8882: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8883: } else {
8884: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8885: }
8886: }
8887:
8888:
8889:
8890:
8891: public static void busWle (int a, int d) throws M68kException {
8892: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8893: if (DataBreakPoint.DBP_ON) {
8894: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8895: } else {
8896: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8897: }
8898: } else {
8899: int a2 = a + 2;
8900: if (BUS_SPLIT_UNALIGNED_LONG) {
8901: if (DataBreakPoint.DBP_ON) {
8902: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8903: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8904: } else {
8905: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8906: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8907: }
8908: } else {
8909: MemoryMappedDevice mmd;
8910: MemoryMappedDevice mmd2;
8911: if (DataBreakPoint.DBP_ON) {
8912: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8913: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8914: } else {
8915: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8916: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8917: }
8918: if (mmd == mmd2) {
8919: mmd.mmdWl (a, d);
8920: } else {
8921: mmd.mmdWw (a, d >> 16);
8922: mmd2.mmdWw (a2, d);
8923: }
8924: }
8925: }
8926: }
8927:
8928:
8929:
8930: public static void busWq (int a, long d) throws M68kException {
8931: busWl (a, (int) (d >>> 32));
8932: busWl (a + 4, (int) d);
8933: }
8934:
8935:
8936:
8937:
8938:
8939: public static void busRbb (int a, byte[] bb, int o, int l) throws M68kException {
8940: if (false) {
8941: for (int i = 0; i < l; i++) {
8942: int ai = a + i;
8943: if (DataBreakPoint.DBP_ON) {
8944: bb[o + i] = DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
8945: } else {
8946: bb[o + i] = busMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
8947: }
8948: }
8949: } else {
8950: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
8951: while (l > 0) {
8952: MemoryMappedDevice mmd;
8953: if (DataBreakPoint.DBP_ON) {
8954: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8955: } else {
8956: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8957: }
8958: int s = l <= r ? l : r;
8959: l -= s;
8960: if (true) {
8961: for (s -= 16; s >= 0; s -= 16) {
8962: bb[o ] = mmd.mmdRbs (a );
8963: bb[o + 1] = mmd.mmdRbs (a + 1);
8964: bb[o + 2] = mmd.mmdRbs (a + 2);
8965: bb[o + 3] = mmd.mmdRbs (a + 3);
8966: bb[o + 4] = mmd.mmdRbs (a + 4);
8967: bb[o + 5] = mmd.mmdRbs (a + 5);
8968: bb[o + 6] = mmd.mmdRbs (a + 6);
8969: bb[o + 7] = mmd.mmdRbs (a + 7);
8970: bb[o + 8] = mmd.mmdRbs (a + 8);
8971: bb[o + 9] = mmd.mmdRbs (a + 9);
8972: bb[o + 10] = mmd.mmdRbs (a + 10);
8973: bb[o + 11] = mmd.mmdRbs (a + 11);
8974: bb[o + 12] = mmd.mmdRbs (a + 12);
8975: bb[o + 13] = mmd.mmdRbs (a + 13);
8976: bb[o + 14] = mmd.mmdRbs (a + 14);
8977: bb[o + 15] = mmd.mmdRbs (a + 15);
8978: a += 16;
8979: o += 16;
8980: }
8981: s += 16;
8982: }
8983: for (int i = 0; i < s; i++) {
8984: bb[o + i] = mmd.mmdRbs (a + i);
8985: }
8986: a += s;
8987: o += s;
8988: r = BUS_PAGE_SIZE;
8989: }
8990: }
8991: }
8992:
8993:
8994:
8995: public static void busWbb (int a, byte[] bb, int o, int l) throws M68kException {
8996: if (false) {
8997: for (int i = 0; i < l; i++) {
8998: int ai = a + i;
8999: if (DataBreakPoint.DBP_ON) {
9000: DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9001: } else {
9002: busMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9003: }
9004: }
9005: } else {
9006: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9007: while (l > 0) {
9008: MemoryMappedDevice mmd;
9009: if (DataBreakPoint.DBP_ON) {
9010: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9011: } else {
9012: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9013: }
9014: int s = l <= r ? l : r;
9015: l -= s;
9016: if (true) {
9017: for (s -= 16; s >= 0; s -= 16) {
9018: mmd.mmdWb (a , bb[o ]);
9019: mmd.mmdWb (a + 1, bb[o + 1]);
9020: mmd.mmdWb (a + 2, bb[o + 2]);
9021: mmd.mmdWb (a + 3, bb[o + 3]);
9022: mmd.mmdWb (a + 4, bb[o + 4]);
9023: mmd.mmdWb (a + 5, bb[o + 5]);
9024: mmd.mmdWb (a + 6, bb[o + 6]);
9025: mmd.mmdWb (a + 7, bb[o + 7]);
9026: mmd.mmdWb (a + 8, bb[o + 8]);
9027: mmd.mmdWb (a + 9, bb[o + 9]);
9028: mmd.mmdWb (a + 10, bb[o + 10]);
9029: mmd.mmdWb (a + 11, bb[o + 11]);
9030: mmd.mmdWb (a + 12, bb[o + 12]);
9031: mmd.mmdWb (a + 13, bb[o + 13]);
9032: mmd.mmdWb (a + 14, bb[o + 14]);
9033: mmd.mmdWb (a + 15, bb[o + 15]);
9034: a += 16;
9035: o += 16;
9036: }
9037: s += 16;
9038: }
9039: for (int i = 0; i < s; i++) {
9040: mmd.mmdWb (a + i, bb[o + i]);
9041: }
9042: a += s;
9043: o += s;
9044: r = BUS_PAGE_SIZE;
9045: }
9046: }
9047: }
9048:
9049:
9050:
9051: public static void busVb (int a, int d) {
9052: try {
9053: if (DataBreakPoint.DBP_ON) {
9054: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9055: } else {
9056: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9057: }
9058: } catch (M68kException e) {
9059: }
9060: }
9061:
9062:
9063:
9064: public static void busVw (int a, int d) {
9065: try {
9066: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9067: if (DataBreakPoint.DBP_ON) {
9068: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9069: } else {
9070: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9071: }
9072: }
9073: } catch (M68kException e) {
9074: }
9075: }
9076:
9077:
9078:
9079: public static void busVl (int a, int d) {
9080: try {
9081: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9082: if (DataBreakPoint.DBP_ON) {
9083: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9084: } else {
9085: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9086: }
9087: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9088: int a2 = a + 2;
9089: MemoryMappedDevice mmd;
9090: MemoryMappedDevice mmd2;
9091: if (DataBreakPoint.DBP_ON) {
9092: mmd = (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS];
9093: mmd2 = (regSRS != 0 ? busSuperMap : busUserMap)[a2 >>> BUS_PAGE_BITS];
9094: } else {
9095: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9096: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9097: }
9098: if (mmd == mmd2) {
9099: mmd.mmdWl (a, d);
9100: } else {
9101: mmd.mmdWw (a, d >> 16);
9102: mmd2.mmdWw (a2, d);
9103: }
9104: }
9105: } catch (M68kException e) {
9106: }
9107: }
9108:
9109:
9110:
9111:
9112:
9113: public static final int SVS_AREASET = 0x00e86001;
9114:
9115:
9116:
9117:
9118:
9119:
9120:
9121:
9122:
9123: public static void svsInit () {
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:
9152:
9153:
9154:
9155:
9156:
9157:
9158:
9159:
9160: public static boolean sysNMIFlag;
9161:
9162:
9163:
9164: public static void sysInit () {
9165: sysNMIFlag = false;
9166: }
9167:
9168:
9169:
9170:
9171:
9172:
9173: public static int sysAcknowledge () {
9174: return M68kException.M6E_LEVEL_7_INTERRUPT_AUTOVECTOR;
9175: }
9176:
9177:
9178:
9179:
9180: public static void sysDone () {
9181: if (sysNMIFlag) {
9182: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9183: }
9184: }
9185:
9186:
9187:
9188: public static void sysInterrupt () {
9189: sysNMIFlag = true;
9190: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9191: }
9192:
9193:
9194:
9195: public static void sysResetNMI () {
9196: sysNMIFlag = false;
9197: }
9198:
9199:
9200:
9201:
9202:
9203:
9204: public static final int EB2_SPC_REQUEST = 0x4000;
9205: public static final int EB2_SPC_VECTOR = 0xf6;
9206:
9207:
9208:
9209: public static int eb2Request;
9210:
9211:
9212:
9213: public static void eb2Reset () {
9214: eb2Request = 0;
9215: }
9216:
9217:
9218:
9219:
9220:
9221: public static void eb2Interrupt (int mask) {
9222: eb2Request |= mask;
9223: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9224: }
9225:
9226:
9227:
9228:
9229:
9230:
9231:
9232: public static int eb2Acknowledge () {
9233: if ((eb2Request & EB2_SPC_REQUEST) != 0) {
9234: eb2Request &= ~EB2_SPC_REQUEST;
9235: return EB2_SPC_VECTOR;
9236: }
9237: return 0;
9238: }
9239:
9240:
9241:
9242:
9243:
9244: public static void eb2Done () {
9245: if (eb2Request != 0) {
9246: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
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:
9305:
9306:
9307:
9308:
9309:
9310:
9311:
9312:
9313: public static final int BNK_SIZE = 1024 * 1024 * 32;
9314: public static byte[] bnkMemory;
9315: public static int bnkPageStart;
9316: public static boolean bnkOn;
9317:
9318: public static void bnkInit () {
9319: bnkMemory = new byte[BNK_SIZE];
9320: byte[] array = Settings.sgsGetData ("bankdata");
9321: if (array.length != 0) {
9322: System.arraycopy (array, 0, bnkMemory, 0, Math.min (array.length, BNK_SIZE));
9323: }
9324: bnkPageStart = 0;
9325:
9326: bnkOn = false;
9327: }
9328:
9329: public static void bnkTini () {
9330: Settings.sgsPutData ("bankdata", bnkMemory, 0, BNK_SIZE);
9331: }
9332:
9333:
9334:
9335:
9336:
9337:
9338:
9339: public static ExpressionEvaluator fpuMotherboardCoprocessor;
9340: public static ExpressionEvaluator fpuOnChipFPU;
9341: public static ExpressionEvaluator fpuBox;
9342:
9343:
9344: public static EFPBox fpuCoproboard1;
9345: public static EFPBox fpuCoproboard2;
9346:
9347:
9348: public static EFPBox.EFP[] fpuFPn;
9349:
9350:
9351:
9352: public static final int FPU_FPCR_BSUN = 0b00000000_00000000_10000000_00000000;
9353: public static final int FPU_FPCR_SNAN = 0b00000000_00000000_01000000_00000000;
9354: public static final int FPU_FPCR_OPERR = 0b00000000_00000000_00100000_00000000;
9355: public static final int FPU_FPCR_OVFL = 0b00000000_00000000_00010000_00000000;
9356: public static final int FPU_FPCR_UNFL = 0b00000000_00000000_00001000_00000000;
9357: public static final int FPU_FPCR_DZ = 0b00000000_00000000_00000100_00000000;
9358: public static final int FPU_FPCR_INEX2 = 0b00000000_00000000_00000010_00000000;
9359: public static final int FPU_FPCR_INEX1 = 0b00000000_00000000_00000001_00000000;
9360:
9361:
9362: public static final int FPU_FPCR_PE = 0b00000000_00000000_00000000_00000000;
9363: public static final int FPU_FPCR_PS = 0b00000000_00000000_00000000_01000000;
9364: public static final int FPU_FPCR_PD = 0b00000000_00000000_00000000_10000000;
9365:
9366: public static final int FPU_FPCR_RN = 0b00000000_00000000_00000000_00000000;
9367: public static final int FPU_FPCR_RZ = 0b00000000_00000000_00000000_00010000;
9368: public static final int FPU_FPCR_RM = 0b00000000_00000000_00000000_00100000;
9369: public static final int FPU_FPCR_RP = 0b00000000_00000000_00000000_00110000;
9370:
9371:
9372:
9373: public static final int FPU_FPSR_N = 0b00001000_00000000_00000000_00000000;
9374: public static final int FPU_FPSR_Z = 0b00000100_00000000_00000000_00000000;
9375: public static final int FPU_FPSR_I = 0b00000010_00000000_00000000_00000000;
9376: public static final int FPU_FPSR_NAN = 0b00000001_00000000_00000000_00000000;
9377:
9378: public static final int FPU_FPSR_S = 0b00000000_10000000_00000000_00000000;
9379: public static final int FPU_FPSR_QUOTIENT = 0b00000000_01111111_00000000_00000000;
9380:
9381: public static final int FPU_FPSR_EXC_BSUN = 0b00000000_00000000_10000000_00000000;
9382: public static final int FPU_FPSR_EXC_SNAN = 0b00000000_00000000_01000000_00000000;
9383: public static final int FPU_FPSR_EXC_OPERR = 0b00000000_00000000_00100000_00000000;
9384: public static final int FPU_FPSR_EXC_OVFL = 0b00000000_00000000_00010000_00000000;
9385: public static final int FPU_FPSR_EXC_UNFL = 0b00000000_00000000_00001000_00000000;
9386: public static final int FPU_FPSR_EXC_DZ = 0b00000000_00000000_00000100_00000000;
9387: public static final int FPU_FPSR_EXC_INEX2 = 0b00000000_00000000_00000010_00000000;
9388: public static final int FPU_FPSR_EXC_INEX1 = 0b00000000_00000000_00000001_00000000;
9389:
9390: public static final int FPU_FPSR_AEXC_IOP = 0b00000000_00000000_00000000_10000000;
9391: public static final int FPU_FPSR_AEXC_OVFL = 0b00000000_00000000_00000000_01000000;
9392: public static final int FPU_FPSR_AEXC_UNFL = 0b00000000_00000000_00000000_00100000;
9393: public static final int FPU_FPSR_AEXC_DZ = 0b00000000_00000000_00000000_00010000;
9394: public static final int FPU_FPSR_AEXC_INEX = 0b00000000_00000000_00000000_00001000;
9395:
9396:
9397:
9398:
9399:
9400:
9401:
9402: public static final int[] FPU_FPSR_EXC_TO_AEXC = new int[256];
9403:
9404:
9405:
9406:
9407:
9408:
9409:
9410:
9411:
9412:
9413:
9414:
9415:
9416:
9417:
9418:
9419:
9420:
9421:
9422:
9423:
9424:
9425:
9426:
9427: public static final boolean[] FPU_CCMAP_882 = {
9428:
9429:
9430: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9431: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9432: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9433: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9434: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9435: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9436: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9437: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9438: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9439: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9440: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9441: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9442: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9443: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9444: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9445: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9446:
9447:
9448: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9449: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9450: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9451: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9452: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9453: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9454: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9455: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9456: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9457: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9458: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9459: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9460: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9461: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9462: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9463: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9464:
9465: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9466: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9467: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9468: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9469: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9470: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9471: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9472: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9473: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9474: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9475: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9476: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9477: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9478: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9479: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9480: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9481:
9482: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9483: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9484: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9485: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9486: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9487: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9488: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9489: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9490: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9491: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9492: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9493: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9494: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9495: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9496: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9497: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9498: };
9499:
9500:
9501:
9502:
9503:
9504:
9505:
9506: public static final boolean[] FPU_CCMAP_060 = {
9507:
9508:
9509: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9510: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9511: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9512: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9513: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9514: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9515: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9516: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9517: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9518: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9519: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9520: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9521: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9522: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9523: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9524: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9525:
9526:
9527: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9528: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9529: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9530: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9531: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9532: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9533: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9534: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9535: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9536: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9537: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9538: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9539: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9540: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9541: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9542: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9543:
9544: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9545: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9546: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9547: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9548: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9549: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9550: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9551: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9552: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9553: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9554: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9555: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9556: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9557: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9558: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9559: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9560:
9561: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9562: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9563: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9564: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9565: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9566: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9567: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9568: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9569: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9570: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9571: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9572: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9573: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9574: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9575: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9576: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9577: };
9578:
9579:
9580:
9581:
9582: public static void fpuInit () {
9583: for (int i = 0; i < 256; i++) {
9584: 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) |
9585: ((i << 8 & FPU_FPSR_EXC_OVFL) != 0 ? FPU_FPSR_AEXC_OVFL : 0) |
9586: ((i << 8 & (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2)) == (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2) ? FPU_FPSR_AEXC_UNFL : 0) |
9587: ((i << 8 & FPU_FPSR_EXC_DZ) != 0 ? FPU_FPSR_AEXC_DZ : 0) |
9588: ((i << 8 & (FPU_FPSR_EXC_OVFL | FPU_FPSR_EXC_INEX2 | FPU_FPSR_EXC_INEX1)) != 0 ? FPU_FPSR_AEXC_INEX : 0));
9589: }
9590:
9591: fpuMotherboardCoprocessor = new ExpressionEvaluator ();
9592:
9593: fpuOnChipFPU = new ExpressionEvaluator ();
9594:
9595: fpuBox = currentMPU < Model.MPU_MC68LC040 ? fpuMotherboardCoprocessor : fpuOnChipFPU;
9596:
9597: fpuFPn = fpuBox.epbFPn;
9598:
9599: fpuCoproboard1 = new EFPBox ();
9600: fpuCoproboard2 = new EFPBox ();
9601: }
9602:
9603:
9604:
9605:
9606:
9607:
9608: public static final boolean DBG_ORI_BYTE_ZERO_D0 = true;
9609:
9610: public static boolean dbgHexSelected;
9611: public static int dbgHexValue;
9612: public static int dbgSupervisorMode;
9613: public static JPopupMenu dbgPopupMenu;
9614: public static JMenu dbgPopupIBPMenu;
9615: public static SpinnerNumberModel dbgPopupIBPCurrentModel;
9616: public static int dbgPopupIBPCurrentValue;
9617: public static SpinnerNumberModel dbgPopupIBPThresholdModel;
9618: public static int dbgPopupIBPThresholdValue;
9619: public static JMenuItem dbgPopupIBPClearMenuItem;
9620: public static JMenu dbgPopupHexMenu;
9621: public static JMenuItem dbgPopupDisMenuItem;
9622: public static JMenuItem dbgPopupMemMenuItem;
9623: public static JMenuItem dbgPopupCopyMenuItem;
9624: public static JMenuItem dbgPopupSelectAllMenuItem;
9625: public static JTextArea dbgPopupTextArea;
9626: public static int dbgEventMask;
9627: public static boolean dbgStopOnError;
9628: public static boolean dbgOriByteZeroD0;
9629: public static boolean dbgStopAtStart;
9630:
9631:
9632:
9633: public static final char[] DBG_SPACES = (
9634:
9635:
9636: " ").toCharArray ();
9637:
9638: public static final int DBG_DRP_VISIBLE_MASK = 1;
9639: public static final int DBG_DDP_VISIBLE_MASK = 2;
9640: public static final int DBG_DMP_VISIBLE_MASK = 4;
9641: public static final int DBG_BLG_VISIBLE_MASK = 8;
9642: public static final int DBG_PFV_VISIBLE_MASK = 16;
9643: public static final int DBG_RBP_VISIBLE_MASK = 32;
9644: public static final int DBG_DBP_VISIBLE_MASK = 64;
9645: public static final int DBG_SMT_VISIBLE_MASK = 128;
9646: public static final int DBG_ATW_VISIBLE_MASK = 256;
9647: public static final int DBG_PAA_VISIBLE_MASK = 512;
9648: public static final int DBG_RTL_VISIBLE_MASK = 1024;
9649: public static final int DBG_SPV_VISIBLE_MASK = 2048;
9650: public static final int DBG_ACM_VISIBLE_MASK = 4096;
9651: public static int dbgVisibleMask;
9652:
9653:
9654:
9655: public static void dbgInit () {
9656: dbgVisibleMask = 0;
9657: dbgHexSelected = false;
9658: dbgHexValue = 0;
9659: dbgSupervisorMode = 1;
9660: dbgPopupMenu = null;
9661: dbgPopupDisMenuItem = null;
9662: dbgPopupMemMenuItem = null;
9663: dbgPopupCopyMenuItem = null;
9664: dbgPopupSelectAllMenuItem = null;
9665: dbgPopupIBPMenu = null;
9666: dbgPopupIBPCurrentModel = null;
9667: dbgPopupIBPCurrentValue = 0;
9668: dbgPopupIBPThresholdModel = null;
9669: dbgPopupIBPThresholdValue = 0;
9670: dbgPopupHexMenu = null;
9671: dbgPopupTextArea = null;
9672: dbgEventMask = 0;
9673: dbgStopOnError = false;
9674: if (DBG_ORI_BYTE_ZERO_D0) {
9675: dbgOriByteZeroD0 = false;
9676: }
9677: dbgStopAtStart = false;
9678: }
9679:
9680:
9681:
9682: public static void dbgMakePopup () {
9683:
9684:
9685: ActionListener popupActionListener = new ActionListener () {
9686: @Override public void actionPerformed (ActionEvent ae) {
9687: switch (ae.getActionCommand ()) {
9688: case "Disassemble":
9689: DisassembleList.ddpBacktraceRecord = -1L;
9690: DisassembleList.ddpOpen (dbgHexValue, dbgSupervisorMode, false);
9691: break;
9692: case "Memory Dump":
9693: MemoryDumpList.dmpOpen (dbgHexValue, dbgSupervisorMode != 0 ? 5 : 1, false);
9694: break;
9695: case "Run to Here":
9696: if (InstructionBreakPoint.IBP_ON) {
9697: if (mpuTask == null) {
9698: InstructionBreakPoint.ibpInstant (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
9699: mpuStart ();
9700: }
9701: }
9702: break;
9703: case "Set Breakpoint":
9704: if (InstructionBreakPoint.IBP_ON) {
9705: InstructionBreakPoint.ibpPut (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode, dbgPopupIBPCurrentValue, dbgPopupIBPThresholdValue, null);
9706: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
9707: }
9708: break;
9709: case "Clear Breakpoint":
9710: if (InstructionBreakPoint.IBP_ON) {
9711: InstructionBreakPoint.ibpRemove (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
9712: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
9713: }
9714: break;
9715: case "Copy":
9716: dbgCopy ();
9717: break;
9718: case "Select All":
9719: dbgSelectAll ();
9720: break;
9721: }
9722: }
9723: };
9724: dbgPopupMenu = ComponentFactory.createPopupMenu (
9725: dbgPopupIBPMenu =
9726: InstructionBreakPoint.IBP_ON ?
9727: ComponentFactory.createMenu (
9728: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
9729: Multilingual.mlnText (ComponentFactory.createMenuItem ("Run to Here", 'R', popupActionListener), "ja", "ここまで実行"),
9730: ComponentFactory.createHorizontalSeparator (),
9731: Multilingual.mlnText (ComponentFactory.createMenuItem ("Set Breakpoint", 'S', popupActionListener), "ja", "ブレークポイントを設定"),
9732: ComponentFactory.createHorizontalBox (
9733: Box.createHorizontalStrut (7),
9734: Box.createHorizontalGlue (),
9735: ComponentFactory.setPreferredSize (
9736: Multilingual.mlnText (ComponentFactory.createLabel ("current"), "ja", "現在値"),
9737: 60, 16),
9738: ComponentFactory.createNumberSpinner (dbgPopupIBPCurrentModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
9739: @Override public void stateChanged (ChangeEvent ce) {
9740: dbgPopupIBPCurrentValue = dbgPopupIBPCurrentModel.getNumber ().intValue ();
9741: }
9742: }),
9743: Box.createHorizontalGlue ()
9744: ),
9745: ComponentFactory.createHorizontalBox (
9746: Box.createHorizontalStrut (7),
9747: Box.createHorizontalGlue (),
9748: ComponentFactory.setPreferredSize (
9749: Multilingual.mlnText (ComponentFactory.createLabel ("threshold"), "ja", "閾値"),
9750: 60, 16),
9751: ComponentFactory.createNumberSpinner (dbgPopupIBPThresholdModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
9752: @Override public void stateChanged (ChangeEvent ce) {
9753: dbgPopupIBPThresholdValue = dbgPopupIBPThresholdModel.getNumber ().intValue ();
9754: }
9755: }),
9756: Box.createHorizontalGlue ()
9757: ),
9758: dbgPopupIBPClearMenuItem =
9759: Multilingual.mlnText (ComponentFactory.createMenuItem ("Clear Breakpoint", 'C', popupActionListener), "ja", "ブレークポイントを消去")
9760: ) :
9761: null,
9762: dbgPopupHexMenu =
9763: ComponentFactory.createMenu (
9764: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
9765: dbgPopupDisMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble", 'D', popupActionListener), "ja", "逆アセンブル"),
9766: dbgPopupMemMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory Dump", 'M', popupActionListener), "ja", "メモリダンプ")
9767: ),
9768: dbgPopupCopyMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Copy", 'C', popupActionListener), "ja", "コピー"),
9769: dbgPopupSelectAllMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Select All", 'A', popupActionListener), "ja", "すべて選択")
9770: );
9771:
9772: }
9773:
9774:
9775:
9776: public static void dbgShowPopup (MouseEvent me, JTextArea textArea, boolean dis) {
9777: dbgEventMask++;
9778: int x = me.getX ();
9779: int y = me.getY ();
9780:
9781: int p = textArea.viewToModel2D (me.getPoint ());
9782: DisassembleList.ddpPopupAddress = -1;
9783: if (dis) {
9784: int i = Arrays.binarySearch (DisassembleList.ddpSplitArray, 1, DisassembleList.ddpItemCount, p + 1);
9785: i = (i >> 31 ^ i) - 1;
9786: DisassembleList.ddpPopupAddress = DisassembleList.ddpAddressArray[i];
9787: }
9788: int start = textArea.getSelectionStart ();
9789: int end = textArea.getSelectionEnd ();
9790: String text = textArea.getText ();
9791: int length = text.length ();
9792: if ((start == end ||
9793: p < start || end <= p) &&
9794: 0 <= p && p < length && isWord (text.charAt (p))) {
9795:
9796: for (start = p; 0 < start && isWord (text.charAt (start - 1)); start--) {
9797: }
9798: for (end = p + 1; end < length && isWord (text.charAt (end)); end++) {
9799: }
9800: textArea.select (start, end);
9801: }
9802: dbgHexSelected = false;
9803: if (start < end) {
9804: textArea.requestFocusInWindow ();
9805:
9806:
9807:
9808:
9809:
9810: dbgHexValue = 0;
9811: int n = 0;
9812: for (int i = start; i < end; i++) {
9813: int t;
9814: if ((t = Character.digit (text.charAt (i), 16)) >= 0) {
9815: dbgHexValue = dbgHexValue << 4 | t;
9816: if (n >= 8 ||
9817: i + 1 >= end || (t = Character.digit (text.charAt (i + 1), 16)) < 0) {
9818: n = 0;
9819: break;
9820: }
9821: dbgHexValue = dbgHexValue << 4 | t;
9822: n += 2;
9823: i++;
9824: } else if (isWord (text.charAt (i))) {
9825: n = 0;
9826: break;
9827: }
9828: }
9829: dbgHexSelected = n > 0;
9830: try {
9831:
9832: Rectangle r = textArea.modelToView2D (start).getBounds ();
9833:
9834: Rectangle s = textArea.modelToView2D (end - 1).getBounds ();
9835: if (r.y == s.y) {
9836:
9837: y = r.y + r.height;
9838: }
9839: } catch (BadLocationException ble) {
9840: }
9841: }
9842:
9843: if (InstructionBreakPoint.IBP_ON) {
9844: if (dis && mpuTask == null && DisassembleList.ddpPopupAddress != -1) {
9845: ComponentFactory.setText (dbgPopupIBPMenu, fmtHex8 (DisassembleList.ddpPopupAddress));
9846: TreeMap<Integer,InstructionBreakPoint.InstructionBreakRecord> pointTable = InstructionBreakPoint.ibpPointTable;
9847: InstructionBreakPoint.InstructionBreakRecord r = pointTable.get (DisassembleList.ddpPopupAddress);
9848: if (r != null) {
9849: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = r.ibrValue));
9850: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = r.ibrThreshold));
9851: dbgPopupIBPClearMenuItem.setEnabled (true);
9852: } else {
9853: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = 0));
9854: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = 0));
9855: dbgPopupIBPClearMenuItem.setEnabled (false);
9856: }
9857: ComponentFactory.setVisible (dbgPopupIBPMenu, true);
9858: } else {
9859: ComponentFactory.setVisible (dbgPopupIBPMenu, false);
9860: }
9861: }
9862:
9863: if (dbgHexSelected) {
9864: ComponentFactory.setText (dbgPopupHexMenu, fmtHex8 (dbgHexValue));
9865: ComponentFactory.setVisible (dbgPopupHexMenu, true);
9866: } else {
9867: ComponentFactory.setVisible (dbgPopupHexMenu, false);
9868: }
9869:
9870: ComponentFactory.setEnabled (dbgPopupCopyMenuItem, clpClipboard != null && start < end);
9871:
9872: ComponentFactory.setEnabled (dbgPopupSelectAllMenuItem, clpClipboard != null);
9873:
9874: dbgPopupTextArea = textArea;
9875: dbgPopupMenu.show (textArea, x, y);
9876: dbgEventMask--;
9877: }
9878:
9879: public static boolean isWord (char c) {
9880: return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '_';
9881: }
9882:
9883:
9884:
9885: public static void dbgCopy () {
9886: clpCopy (dbgPopupTextArea.getSelectedText ());
9887: }
9888:
9889:
9890:
9891: public static void dbgSelectAll () {
9892: if (clpClipboard != null) {
9893:
9894: dbgEventMask++;
9895: dbgPopupTextArea.selectAll ();
9896: dbgPopupTextArea.requestFocusInWindow ();
9897: dbgEventMask--;
9898: }
9899: }
9900:
9901:
9902:
9903:
9904: public static void dbgUpdate () {
9905: if ((dbgVisibleMask & DBG_DRP_VISIBLE_MASK) != 0) {
9906: RegisterList.drpUpdate ();
9907: }
9908: if (ProgramFlowVisualizer.PFV_ON) {
9909: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
9910: if (ProgramFlowVisualizer.pfvTimer == 0) {
9911: ProgramFlowVisualizer.pfvUpdate ();
9912: } else {
9913: ProgramFlowVisualizer.pfvTimer--;
9914: }
9915: }
9916: }
9917: if (RasterBreakPoint.RBP_ON) {
9918: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
9919: if (RasterBreakPoint.rbpTimer == 0) {
9920: RasterBreakPoint.rbpUpdateFrame ();
9921: } else {
9922: RasterBreakPoint.rbpTimer--;
9923: }
9924: }
9925: }
9926: if (ScreenModeTest.SMT_ON) {
9927: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
9928: if (ScreenModeTest.smtTimer == 0) {
9929: ScreenModeTest.smtUpdateFrame ();
9930: } else {
9931: ScreenModeTest.smtTimer--;
9932: }
9933: }
9934: }
9935: if (RootPointerList.RTL_ON) {
9936: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
9937: if (RootPointerList.rtlTimer == 0) {
9938: RootPointerList.rtlTimer = RootPointerList.RTL_INTERVAL - 1;
9939: RootPointerList.rtlUpdateFrame ();
9940: } else {
9941: RootPointerList.rtlTimer--;
9942: }
9943: }
9944: }
9945: if (SpritePatternViewer.SPV_ON) {
9946: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
9947: if (SpritePatternViewer.spvTimer == 0) {
9948: SpritePatternViewer.spvTimer = SpritePatternViewer.SPV_INTERVAL - 1;
9949: SpritePatternViewer.spvUpdateFrame ();
9950: } else {
9951: SpritePatternViewer.spvTimer--;
9952: }
9953: }
9954: }
9955: if (ATCMonitor.ACM_ON) {
9956: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
9957: if (ATCMonitor.acmTimer == 0) {
9958: ATCMonitor.acmTimer = ATCMonitor.ACM_INTERVAL - 1;
9959: ATCMonitor.acmUpdateFrame ();
9960: } else {
9961: ATCMonitor.acmTimer--;
9962: }
9963: }
9964: }
9965: }
9966:
9967:
9968:
9969:
9970:
9971:
9972:
9973:
9974:
9975:
9976:
9977:
9978:
9979:
9980:
9981:
9982:
9983:
9984:
9985:
9986:
9987:
9988: public static boolean dbgDoStopOnError () {
9989: if (MainMemory.mmrHumanVersion <= 0) {
9990: return true;
9991: }
9992: if ((regOC & 0xff00) == 0xff00 &&
9993: M68kException.m6eNumber == M68kException.M6E_PRIVILEGE_VIOLATION) {
9994: return false;
9995: }
9996: String message = (
9997: M68kException.m6eNumber < 0 ?
9998: fmtHex8 (new StringBuilder ("breaked").append (" at "), regPC0).toString () :
9999: M68kException.m6eNumber <= M68kException.M6E_ADDRESS_ERROR ?
10000: fmtHex8 (fmtHex8 (new StringBuilder ("ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10001: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10002: .append (" at "), regPC0).toString () :
10003: fmtHex8 (new StringBuilder (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10004: .append (" at "), regPC0).toString ()
10005: );
10006: System.out.println (message);
10007: if (!(M68kException.m6eNumber == M68kException.M6E_ACCESS_FAULT &&
10008: 0x0000e100 <= regPC0 && regPC0 < 0x0000e500)) {
10009: mpuStop (message);
10010: return true;
10011: }
10012: return false;
10013: }
10014:
10015:
10016:
10017: public static void dbgDoubleBusFault () {
10018: String message =
10019: fmtHex8 (fmtHex8 (new StringBuilder ("FATAL ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10020: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10021: .append (" at "), regPC0).toString ();
10022: System.out.println (message);
10023: mpuStop (message);
10024: }
10025:
10026:
10027:
10028:
10029:
10030:
10031: public static final HashMap<String,byte[]> rscResourceCache = new HashMap<String,byte[]> ();
10032:
10033:
10034:
10035:
10036:
10037:
10038: public static byte[] rscGetResource (String name, int... sizes) {
10039: byte[] array = rscResourceCache.get (name);
10040: if (array != null) {
10041: return array;
10042: }
10043: array = new byte[1024 * 64];
10044: int size = 0;
10045: try (BufferedInputStream bis = new BufferedInputStream (XEiJ.class.getResourceAsStream ("../data/" + name))) {
10046: for (;;) {
10047: if (size == array.length) {
10048: byte[] newArray = new byte[array.length * 2];
10049: System.arraycopy (array, 0, newArray, 0, size);
10050: array = newArray;
10051: }
10052: int step = bis.read (array, size, array.length - size);
10053: if (step == -1) {
10054: break;
10055: }
10056: size += step;
10057: }
10058: if (size < array.length) {
10059: byte[] newArray = new byte[size];
10060: System.arraycopy (array, 0, newArray, 0, size);
10061: array = newArray;
10062: }
10063: boolean fit = sizes.length == 0;
10064: if (!fit) {
10065: for (int i = 0; i < sizes.length; i++) {
10066: if (size == sizes[i]) {
10067: fit = true;
10068: break;
10069: }
10070: }
10071: }
10072: if (fit) {
10073: System.out.println (Multilingual.mlnJapanese ?
10074: name + " を読み込みました" :
10075: name + " was read");
10076: rscResourceCache.put (name, array);
10077: return array;
10078: }
10079: System.out.println (Multilingual.mlnJapanese ?
10080: name + " のサイズが違います" :
10081: name + " has wrong size");
10082: return null;
10083: } catch (IOException ioe) {
10084: }
10085:
10086: System.out.println (Multilingual.mlnJapanese ?
10087: name + " を読み込めません" :
10088: name + " cannot be read");
10089: return null;
10090: }
10091:
10092:
10093:
10094: public static String rscGetResourceText (String name) {
10095: return rscGetResourceText (name, "UTF-8");
10096: }
10097: public static String rscGetResourceText (String name, String charset) {
10098: byte[] array = rscGetResource (name);
10099: if (name != null) {
10100: try {
10101: return new String (array, charset);
10102: } catch (UnsupportedEncodingException uee) {
10103: }
10104: }
10105: return "";
10106: }
10107:
10108: public static final Pattern RSC_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10109: public static String rscLastFileName = null;
10110:
10111:
10112:
10113:
10114:
10115:
10116: public static byte[] rscGetFile (String names, int... sizes) {
10117: for (String name : names.split (",")) {
10118: name = name.trim ();
10119: if (name.length () == 0 || name.equalsIgnoreCase ("none")) {
10120: continue;
10121: }
10122: String[] zipSplittedName = RSC_ZIP_SEPARATOR.split (name, 2);
10123: InputStream is = null;
10124: if (zipSplittedName.length < 2) {
10125: File file = new File (name);
10126: if (file.isFile ()) {
10127: try {
10128: is = new FileInputStream (file);
10129: } catch (IOException ioe) {
10130: }
10131: } else {
10132: System.out.println (Multilingual.mlnJapanese ?
10133: name + " がありません" :
10134: name + " does not exist");
10135: continue;
10136: }
10137: } else {
10138: String zipName = zipSplittedName[0];
10139: String entryName = zipSplittedName[1];
10140: if (new File (zipName).isFile ()) {
10141: try {
10142: ZipFile zipFile = new ZipFile (zipName);
10143: ZipEntry zipEntry = zipFile.getEntry (entryName);
10144: if (zipEntry != null) {
10145: is = zipFile.getInputStream (zipEntry);
10146: } else {
10147: System.out.println (Multilingual.mlnJapanese ?
10148: zipName + " に " + zipEntry + " がありません" :
10149: zipName + " does not include " + zipEntry);
10150: }
10151: } catch (IOException ioe) {
10152: }
10153: } else {
10154: System.out.println (Multilingual.mlnJapanese ?
10155: zipName + " がありません" :
10156: zipName + " does not exist");
10157: continue;
10158: }
10159: }
10160: if (is != null) {
10161: try {
10162: is = new BufferedInputStream (is);
10163: if (name.toLowerCase ().endsWith (".gz")) {
10164: is = new GZIPInputStream (is);
10165: }
10166: byte[] array = new byte[1024 * 64];
10167: int size = 0;
10168: for (;;) {
10169: if (size == array.length) {
10170: byte[] newArray = new byte[array.length * 2];
10171: System.arraycopy (array, 0, newArray, 0, size);
10172: array = newArray;
10173: }
10174: int step = is.read (array, size, array.length - size);
10175: if (step == -1) {
10176: break;
10177: }
10178: size += step;
10179: }
10180: is.close ();
10181: is = null;
10182: if (size < array.length) {
10183: byte[] newArray = new byte[size];
10184: System.arraycopy (array, 0, newArray, 0, size);
10185: array = newArray;
10186: }
10187: boolean fit = sizes.length == 0;
10188: if (!fit) {
10189: for (int i = 0; i < sizes.length; i++) {
10190: if (size == sizes[i]) {
10191: fit = true;
10192: break;
10193: }
10194: }
10195: }
10196: if (fit) {
10197: System.out.println (Multilingual.mlnJapanese ?
10198: name + " を読み込みました" :
10199: name + " was read");
10200: rscLastFileName = name;
10201: return array;
10202: }
10203: System.out.println (Multilingual.mlnJapanese ?
10204: name + " のサイズが違います" :
10205: name + " has wrong size");
10206: continue;
10207: } catch (IOException ioe) {
10208: }
10209: if (is != null) {
10210: try {
10211: is.close ();
10212: is = null;
10213: } catch (IOException ioe) {
10214: }
10215: }
10216: }
10217: System.out.println (Multilingual.mlnJapanese ?
10218: name + " を読み込めません" :
10219: name + " cannot be read");
10220: }
10221:
10222:
10223:
10224: return null;
10225: }
10226:
10227:
10228:
10229:
10230: public static String rscGetTextFile (String name) {
10231: return rscGetTextFile (name, "UTF-8");
10232: }
10233: public static String rscGetTextFile (String name, String charset) {
10234: byte[] array = rscGetFile (name);
10235: if (array != null) {
10236: try {
10237: return new String (array, charset);
10238: } catch (UnsupportedEncodingException uee) {
10239: }
10240: }
10241: return "";
10242: }
10243:
10244:
10245:
10246: public static final int RSC_A_MASK = 1;
10247: public static final int RSC_R_MASK = 2;
10248: public static final int RSC_I_MASK = 4;
10249: public static final String RSC_A_EN = "Abort";
10250: public static final String RSC_R_EN = "Retry";
10251: public static final String RSC_I_EN = "Ignore";
10252: public static final String RSC_A_JA = "中止";
10253: public static final String RSC_R_JA = "再実行";
10254: public static final String RSC_I_JA = "無視";
10255: public static final String[][] RSC_EN_OPTIONS = {
10256: { RSC_A_EN },
10257: { RSC_A_EN },
10258: { RSC_R_EN },
10259: { RSC_A_EN, RSC_R_EN },
10260: { RSC_I_EN },
10261: { RSC_A_EN, RSC_I_EN },
10262: { RSC_R_EN, RSC_I_EN },
10263: { RSC_A_EN, RSC_R_EN, RSC_I_EN },
10264: };
10265: public static final String[][] RSC_JA_OPTIONS = {
10266: { RSC_A_JA },
10267: { RSC_A_JA },
10268: { RSC_R_JA },
10269: { RSC_A_JA, RSC_R_JA },
10270: { RSC_I_JA },
10271: { RSC_A_JA, RSC_I_JA },
10272: { RSC_R_JA, RSC_I_JA },
10273: { RSC_A_JA, RSC_R_JA, RSC_I_JA },
10274: };
10275: public static int rscShowError (String message, int mask) {
10276: System.out.println (message);
10277: mask &= RSC_A_MASK | RSC_R_MASK | RSC_I_MASK;
10278: if (mask == 0) {
10279: mask = RSC_A_MASK;
10280: }
10281: String[] options = (Multilingual.mlnJapanese ? RSC_JA_OPTIONS : RSC_EN_OPTIONS)[mask];
10282: int def = Integer.numberOfTrailingZeros (mask);
10283: pnlExitFullScreen (true);
10284: int bit = JOptionPane.showOptionDialog (
10285: null,
10286: message,
10287: Multilingual.mlnJapanese ? "ファイル操作エラー" : "File operation error",
10288: JOptionPane.YES_NO_CANCEL_OPTION,
10289: JOptionPane.ERROR_MESSAGE,
10290: null,
10291: options,
10292: options[def]);
10293: if (bit == JOptionPane.CLOSED_OPTION) {
10294: bit = def;
10295: }
10296: return 1 << bit;
10297: }
10298:
10299:
10300:
10301:
10302:
10303:
10304: public static boolean rscPutTextFile (String name, String string) {
10305: return rscPutTextFile (name, string, "UTF-8");
10306: }
10307: public static boolean rscPutTextFile (String name, ArrayList<String> strings) {
10308: return rscPutTextFile (name, strings, "UTF-8");
10309: }
10310: public static boolean rscPutTextFile (String name, String string, String charset) {
10311: ArrayList<String> strings = new ArrayList<String> ();
10312: strings.add (string);
10313: return rscPutTextFile (name, strings, charset);
10314: }
10315: public static boolean rscPutTextFile (String name, ArrayList<String> strings, String charset) {
10316: String nameTmp = name + ".tmp";
10317: String nameBak = name + ".bak";
10318: File file = new File (name);
10319: File fileTmp = new File (nameTmp);
10320: File fileBak = new File (nameBak);
10321:
10322: File parentDirectory = file.getParentFile ();
10323: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10324: if (!parentDirectory.mkdirs ()) {
10325: System.out.println (parentDirectory.getPath () + (Multilingual.mlnJapanese ? " を作れません" : " cannot be created"));
10326: return false;
10327: }
10328: }
10329:
10330: if (fileTmp.exists ()) {
10331: if (!fileTmp.delete ()) {
10332: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10333: return false;
10334: }
10335: }
10336:
10337: try (BufferedWriter bw = new BufferedWriter (new FileWriter (nameTmp, Charset.forName (charset)))) {
10338: for (String string : strings) {
10339: bw.write (string);
10340: }
10341: } catch (IOException ioe) {
10342: ioe.printStackTrace ();
10343: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " に書き出せません" : " cannot be written"));
10344: return false;
10345: }
10346:
10347: boolean fileExists = file.exists ();
10348: if (fileExists) {
10349:
10350: if (fileBak.exists ()) {
10351: if (!fileBak.delete ()) {
10352: System.out.println (nameBak + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10353: return false;
10354: }
10355: }
10356:
10357: if (!file.renameTo (fileBak)) {
10358: System.out.println (name + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + nameBak + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10359: return false;
10360: }
10361: }
10362:
10363: if (!fileTmp.renameTo (file)) {
10364: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + name + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10365: return false;
10366: }
10367: if (fileExists) {
10368: System.out.println (name + (Multilingual.mlnJapanese ? " を更新しました" : " was updated"));
10369: } else {
10370: System.out.println (name + (Multilingual.mlnJapanese ? " を作りました" : " was created"));
10371: }
10372: return true;
10373: }
10374:
10375:
10376:
10377:
10378:
10379:
10380:
10381:
10382:
10383: public static boolean rscPutFile (String name, byte[] array) {
10384: return rscPutFile (name, array, 0, array.length, (long) array.length);
10385: }
10386: public static boolean rscPutFile (String name, byte[] array, int offset, int length) {
10387: return rscPutFile (name, array, offset, length, (long) length);
10388: }
10389: public static boolean rscPutFile (String name, byte[] array, int offset, int length, long longLength2) {
10390: if (RSC_ZIP_SEPARATOR.matcher (name).matches ()) {
10391:
10392: return false;
10393: }
10394: File file = new File (name);
10395: boolean fileExists = file.isFile ();
10396: if (fileExists && file.length () == longLength2) {
10397: comparison:
10398: {
10399: try (BufferedInputStream bis = new BufferedInputStream (new FileInputStream (file))) {
10400: byte[] buffer = new byte[(int) Math.min (Math.max ((long) length, longLength2 - (long) length), (long) (1024 * 1024))];
10401: int position = 0;
10402: while (position < length) {
10403: int step = bis.read (buffer, 0, Math.min (buffer.length, length - position));
10404: if (step == -1) {
10405: break comparison;
10406: }
10407: int offsetPosition = offset + position;
10408: for (int i = 0; i < step; i++) {
10409: if (buffer[i] != array[offsetPosition + i]) {
10410: break comparison;
10411: }
10412: }
10413: position += step;
10414: }
10415: long longPosition2 = (long) length;
10416: while (longPosition2 < longLength2) {
10417: int step = bis.read (buffer, 0, (int) Math.min ((long) buffer.length, longLength2 - longPosition2));
10418: if (step == -1) {
10419: break comparison;
10420: }
10421: for (int i = 0; i < step; i++) {
10422: if (buffer[i] != 0) {
10423: break comparison;
10424: }
10425: }
10426: longPosition2 += (long) step;
10427: }
10428: return true;
10429: } catch (IOException ioe) {
10430: }
10431: }
10432: }
10433: String nameTmp = name + ".tmp";
10434: File fileTmp = new File (nameTmp);
10435: String nameBak = name + ".bak";
10436: File fileBak = new File (nameBak);
10437: retry:
10438: for (;;) {
10439: File parentDirectory = file.getParentFile ();
10440: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10441: String parentName = parentDirectory.getPath ();
10442: if (parentDirectory.mkdirs ()) {
10443: System.out.println (Multilingual.mlnJapanese ?
10444: parentName + " を作りました" :
10445: parentName + " was created");
10446: } else {
10447: switch (rscShowError (Multilingual.mlnJapanese ?
10448: parentName + " を作れません" :
10449: parentName + " cannot be created",
10450: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10451: case RSC_A_MASK:
10452: break retry;
10453: case RSC_R_MASK:
10454: continue retry;
10455: }
10456: }
10457: }
10458: if (fileTmp.isFile ()) {
10459: if (!fileTmp.delete ()) {
10460: switch (rscShowError (Multilingual.mlnJapanese ?
10461: nameTmp + " を削除できません" :
10462: nameTmp + " cannot be deleted",
10463: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10464: case RSC_A_MASK:
10465: break retry;
10466: case RSC_R_MASK:
10467: continue retry;
10468: }
10469: }
10470: }
10471: try (OutputStream os = name.toLowerCase ().endsWith (".gz") ?
10472: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10473: {
10474:
10475: def.setLevel (Deflater.DEFAULT_COMPRESSION);
10476:
10477: }
10478: } :
10479: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10480:
10481: os.write (array, offset, length);
10482:
10483:
10484: if ((long) length < longLength2) {
10485: byte[] buffer = new byte[(int) Math.min (longLength2 - (long) length, (long) (1024 * 1024))];
10486: Arrays.fill (buffer, 0, buffer.length, (byte) 0);
10487: long longPosition2 = (long) length;
10488: while (longPosition2 < longLength2) {
10489: int step = (int) Math.min ((long) buffer.length, longLength2 - longPosition2);
10490: os.write (buffer, 0, step);
10491: longPosition2 += (long) step;
10492: }
10493: }
10494: } catch (IOException ioe) {
10495: switch (rscShowError (Multilingual.mlnJapanese ?
10496: nameTmp + " に書き出せません" :
10497: nameTmp + " cannot be written",
10498: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10499: case RSC_A_MASK:
10500: break retry;
10501: case RSC_R_MASK:
10502: continue retry;
10503: }
10504: }
10505: if (fileExists && file.isFile ()) {
10506: if (fileBak.isFile ()) {
10507: if (!fileBak.delete ()) {
10508: switch (rscShowError (Multilingual.mlnJapanese ?
10509: nameBak + " を削除できません" :
10510: nameBak + " cannot be deleted",
10511: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10512: case RSC_A_MASK:
10513: break retry;
10514: case RSC_R_MASK:
10515: continue retry;
10516: }
10517: }
10518: }
10519: if (!file.renameTo (fileBak)) {
10520: switch (rscShowError (Multilingual.mlnJapanese ?
10521: name + " を " + nameBak + " にリネームできません" :
10522: name + " cannot be renamed to " + nameBak,
10523: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10524: case RSC_A_MASK:
10525: break retry;
10526: case RSC_R_MASK:
10527: continue retry;
10528: }
10529: }
10530: }
10531: if (fileTmp.renameTo (file)) {
10532: if (fileExists) {
10533: System.out.println (Multilingual.mlnJapanese ?
10534: name + " を更新しました" :
10535: name + " was updated");
10536: } else {
10537: System.out.println (Multilingual.mlnJapanese ?
10538: name + " を作りました" :
10539: name + " was created");
10540: }
10541: return true;
10542: } else {
10543: switch (rscShowError (Multilingual.mlnJapanese ?
10544: nameTmp + " を " + name + " にリネームできません" :
10545: nameTmp + " cannot be renamed to " + name,
10546: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10547: case RSC_A_MASK:
10548: break retry;
10549: case RSC_R_MASK:
10550: continue retry;
10551: }
10552: }
10553: break;
10554: }
10555: if (fileExists) {
10556: System.out.println (Multilingual.mlnJapanese ?
10557: name + " を更新できません" :
10558: name + " cannot be updated");
10559: } else {
10560: System.out.println (Multilingual.mlnJapanese ?
10561: name + " を作れません" :
10562: name + " cannot be created");
10563: }
10564: return false;
10565: }
10566:
10567:
10568:
10569:
10570:
10571:
10572: public static final Pattern ISM_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10573:
10574:
10575:
10576:
10577:
10578:
10579:
10580:
10581:
10582:
10583:
10584: public static InputStream ismOpen (String name) {
10585: InputStream in = null;
10586: in = ismOpen (name, false);
10587: if (in == null && name.indexOf ('/') < 0 && name.indexOf ('\\') < 0) {
10588: in = ismOpen (name, true);
10589: }
10590: return in;
10591: }
10592: public static InputStream ismOpen (String name, boolean useGetResource) {
10593: boolean gzipped = name.toLowerCase ().endsWith (".gz");
10594: String[] zipSplittedName = ISM_ZIP_SEPARATOR.split (name, 2);
10595: String fileName = zipSplittedName[0];
10596: String zipEntryName = zipSplittedName.length < 2 ? null : zipSplittedName[1];
10597: InputStream in = null;
10598: try {
10599: if (useGetResource) {
10600: if (false) {
10601: URL url = XEiJ.class.getResource (fileName);
10602: if (url != null) {
10603: in = url.openStream ();
10604: }
10605: } else {
10606: in = XEiJ.class.getResourceAsStream (fileName);
10607: }
10608: } else {
10609: File file = new File (fileName);
10610: if (file.exists ()) {
10611: in = new FileInputStream (file);
10612: }
10613: }
10614: if (in != null && zipEntryName != null) {
10615: ZipInputStream zin = new ZipInputStream (in);
10616: in = null;
10617: ZipEntry entry;
10618: while ((entry = zin.getNextEntry ()) != null) {
10619: if (zipEntryName.equals (entry.getName ())) {
10620: in = zin;
10621: break;
10622: }
10623: }
10624: if (in == null) {
10625: System.out.println (Multilingual.mlnJapanese ? fileName + " の中に " + zipEntryName + " がありません" :
10626: zipEntryName + " does not exist in " + fileName);
10627: }
10628: }
10629: if (in != null && gzipped) {
10630: in = new GZIPInputStream (in);
10631: }
10632: if (in != null) {
10633: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " を読み込みます" :
10634: (useGetResource ? "Reading resource file " : "Reading file ") + name);
10635: return new BufferedInputStream (in);
10636: }
10637: } catch (Exception ioe) {
10638: if (prgVerbose) {
10639: prgPrintStackTraceOf (ioe);
10640: }
10641: }
10642: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " が見つかりません" :
10643: (useGetResource ? "Resource file " : "File ") + name + " is not found");
10644: return null;
10645: }
10646:
10647:
10648:
10649:
10650:
10651:
10652:
10653:
10654: public static int ismRead (InputStream in, byte[] bb, int o, int l) {
10655: try {
10656: int k = 0;
10657: while (k < l) {
10658: int t = in.read (bb, o + k, l - k);
10659: if (t < 0) {
10660: break;
10661: }
10662: k += t;
10663: }
10664: return k;
10665: } catch (IOException ioe) {
10666: if (prgVerbose) {
10667: prgPrintStackTraceOf (ioe);
10668: }
10669: }
10670: return -1;
10671: }
10672:
10673:
10674:
10675:
10676:
10677:
10678:
10679:
10680: public static int ismSkip (InputStream in, int l) {
10681: try {
10682: int k = 0;
10683: while (k < l) {
10684:
10685:
10686: if (in.read () < 0) {
10687: break;
10688: }
10689: k++;
10690: if (k < l) {
10691: int t = (int) in.skip ((long) (l - k));
10692: if (t < 0) {
10693: break;
10694: }
10695: k += t;
10696: }
10697: }
10698: return k;
10699: } catch (IOException ioe) {
10700: if (prgVerbose) {
10701: prgPrintStackTraceOf (ioe);
10702: }
10703: }
10704: return -1;
10705: }
10706:
10707:
10708:
10709:
10710:
10711: public static void ismClose (InputStream in) {
10712: try {
10713: if (in != null) {
10714: in.close ();
10715: }
10716: } catch (IOException ioe) {
10717: if (prgVerbose) {
10718: prgPrintStackTraceOf (ioe);
10719: }
10720: }
10721: }
10722:
10723:
10724:
10725:
10726:
10727:
10728: public static int ismLength (String name, int maxLength) {
10729: int length;
10730: InputStream in = ismOpen (name);
10731: if (in == null) {
10732: length = -1;
10733: } else {
10734: length = ismSkip (in, maxLength);
10735: ismClose (in);
10736: }
10737: return length;
10738: }
10739:
10740:
10741:
10742:
10743:
10744:
10745:
10746:
10747:
10748:
10749:
10750:
10751:
10752:
10753: public static boolean ismLoad (byte[] bb, int o, int l, String names) {
10754: for (String name : names.split (",")) {
10755: if (name.length () != 0) {
10756: InputStream in = ismOpen (name);
10757: if (in != null) {
10758: int k = ismRead (in, bb, o, l);
10759: ismClose (in);
10760: if (k == l) {
10761: return true;
10762: }
10763: }
10764: }
10765: }
10766: return false;
10767: }
10768:
10769:
10770:
10771:
10772:
10773:
10774:
10775:
10776:
10777: public static boolean ismSave (byte[] bb, int offset, long length, String path, boolean verbose) {
10778: if (ISM_ZIP_SEPARATOR.split (path, 2).length != 1) {
10779: if (verbose) {
10780: pnlExitFullScreen (true);
10781: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? path + " に書き出せません" : "Cannot write " + path);
10782: }
10783: return false;
10784: }
10785: long step = 0;
10786: byte[] zz = null;
10787: long pointer = (long) (bb.length - offset);
10788: if (pointer < length) {
10789: step = Math.min (1024L * 512, length - pointer);
10790: zz = new byte[(int) step];
10791: Arrays.fill (zz, (byte) 0);
10792: }
10793:
10794: File file = new File (path);
10795:
10796: if (step == 0 &&
10797: file.exists () && file.length () == length) {
10798:
10799: if (length == 0L) {
10800: return true;
10801: }
10802: InputStream in = ismOpen (path);
10803: if (in != null) {
10804: int l = (int) length;
10805: byte[] tt = new byte[l];
10806: int k = ismRead (in, tt, 0, l);
10807: ismClose (in);
10808: if (k == l &&
10809: Arrays.equals (tt, bb.length == l ? bb : Arrays.copyOfRange (bb, offset, offset + l))) {
10810: return true;
10811: }
10812: }
10813: }
10814:
10815: String pathTmp = path + ".tmp";
10816: String pathBak = path + ".bak";
10817: File fileTmp = new File (pathTmp);
10818: File fileBak = new File (pathBak);
10819:
10820: if (fileTmp.exists ()) {
10821: if (!fileTmp.delete ()) {
10822: if (verbose) {
10823: pnlExitFullScreen (true);
10824: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " を削除できません" : "Cannot delete " + pathTmp);
10825: }
10826: return false;
10827: }
10828: }
10829:
10830: try (OutputStream out = path.toLowerCase ().endsWith (".gz") ?
10831: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10832: {
10833:
10834: def.setLevel (Deflater.DEFAULT_COMPRESSION);
10835:
10836: }
10837: } :
10838: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10839: if (step == 0) {
10840: out.write (bb, offset, (int) length);
10841: } else {
10842: out.write (bb, offset, (int) pointer);
10843: for (; pointer < length; pointer += step) {
10844: out.write (zz, 0, (int) Math.min (step, length - pointer));
10845: }
10846: }
10847: } catch (IOException ioe) {
10848: if (verbose) {
10849: prgPrintStackTraceOf (ioe);
10850: pnlExitFullScreen (true);
10851: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " に書き出せません" : "Cannot write " + pathTmp);
10852: }
10853: return false;
10854: }
10855:
10856:
10857: if (file.exists ()) {
10858: if (fileBak.exists ()) {
10859: if (!fileBak.delete ()) {
10860: if (verbose) {
10861: pnlExitFullScreen (true);
10862: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathBak + " を削除できません" : "Cannot delete " + pathBak);
10863: }
10864: return false;
10865: }
10866: }
10867: if (!file.renameTo (fileBak)) {
10868: if (verbose) {
10869: pnlExitFullScreen (true);
10870: JOptionPane.showMessageDialog (
10871: null, Multilingual.mlnJapanese ? path + " を " + pathBak + " にリネームできません" : "Cannot rename " + path + " to " + pathBak);
10872: }
10873: return false;
10874: }
10875: }
10876:
10877:
10878: if (!fileTmp.renameTo (file)) {
10879: if (verbose) {
10880: pnlExitFullScreen (true);
10881: JOptionPane.showMessageDialog (
10882: null, Multilingual.mlnJapanese ? pathTmp + " を " + path + " にリネームできません" : "Cannot rename " + pathTmp + " to " + path);
10883: }
10884: return false;
10885: }
10886: return true;
10887: }
10888:
10889:
10890:
10891:
10892:
10893:
10894:
10895: public static final char[] FMT_TEMP = new char[32];
10896:
10897:
10898:
10899:
10900:
10901:
10902:
10903:
10904:
10905:
10906:
10907: public static final char[] FMT_AIN4_BASE = ".......*..*...**.*...*.*.**..****...*..**.*.*.****..**.****.****".toCharArray ();
10908: public static final char[] FMT_BIN4_BASE = "0000000100100011010001010110011110001001101010111100110111101111".toCharArray ();
10909:
10910:
10911:
10912:
10913:
10914:
10915:
10916:
10917: public static void fmtAin4 (char[] a, int o, int x) {
10918: a[o ] = (char) (x >> 1 & 4 ^ 46);
10919: a[o + 1] = (char) (x & 4 ^ 46);
10920: a[o + 2] = (char) (x << 1 & 4 ^ 46);
10921: a[o + 3] = (char) (x << 2 & 4 ^ 46);
10922: }
10923: public static void fmtBin4 (char[] a, int o, int x) {
10924: a[o ] = (char) (x >>> 3 & 1 | 48);
10925: a[o + 1] = (char) (x >>> 2 & 1 | 48);
10926: a[o + 2] = (char) (x >>> 1 & 1 | 48);
10927: a[o + 3] = (char) (x & 1 | 48);
10928: }
10929: public static String fmtAin4 (int x) {
10930: return String.valueOf (FMT_AIN4_BASE, (x & 15) << 2, 4);
10931: }
10932: public static String fmtBin4 (int x) {
10933: return String.valueOf (FMT_BIN4_BASE, (x & 15) << 2, 4);
10934: }
10935: public static StringBuilder fmtAin4 (StringBuilder sb, int x) {
10936: return sb.append (FMT_AIN4_BASE, (x & 15) << 2, 6);
10937: }
10938: public static StringBuilder fmtBin4 (StringBuilder sb, int x) {
10939: return sb.append (FMT_BIN4_BASE, (x & 15) << 2, 6);
10940: }
10941:
10942:
10943:
10944:
10945:
10946:
10947:
10948:
10949: public static void fmtAin6 (char[] a, int o, int x) {
10950: a[o ] = (char) (x >> 3 & 4 ^ 46);
10951: a[o + 1] = (char) (x >> 2 & 4 ^ 46);
10952: a[o + 2] = (char) (x >> 1 & 4 ^ 46);
10953: a[o + 3] = (char) (x & 4 ^ 46);
10954: a[o + 4] = (char) (x << 1 & 4 ^ 46);
10955: a[o + 5] = (char) (x << 2 & 4 ^ 46);
10956: }
10957: public static void fmtBin6 (char[] a, int o, int x) {
10958: a[o ] = (char) (x >>> 5 & 1 | 48);
10959: a[o + 1] = (char) (x >>> 4 & 1 | 48);
10960: a[o + 2] = (char) (x >>> 3 & 1 | 48);
10961: a[o + 3] = (char) (x >>> 2 & 1 | 48);
10962: a[o + 4] = (char) (x >>> 1 & 1 | 48);
10963: a[o + 5] = (char) (x & 1 | 48);
10964: }
10965: public static String fmtAin6 (int x) {
10966: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
10967: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
10968: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
10969: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
10970: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
10971: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
10972: return String.valueOf (FMT_TEMP, 0, 6);
10973: }
10974: public static String fmtBin6 (int x) {
10975: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
10976: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
10977: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
10978: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
10979: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
10980: FMT_TEMP[ 5] = (char) (x & 1 | 48);
10981: return String.valueOf (FMT_TEMP, 0, 6);
10982: }
10983: public static StringBuilder fmtAin6 (StringBuilder sb, int x) {
10984: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
10985: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
10986: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
10987: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
10988: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
10989: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
10990: return sb.append (FMT_TEMP, 0, 6);
10991: }
10992: public static StringBuilder fmtBin6 (StringBuilder sb, int x) {
10993: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
10994: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
10995: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
10996: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
10997: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
10998: FMT_TEMP[ 5] = (char) (x & 1 | 48);
10999: return sb.append (FMT_TEMP, 0, 6);
11000: }
11001:
11002:
11003:
11004:
11005:
11006:
11007:
11008:
11009: public static void fmtAin8 (char[] a, int o, int x) {
11010: a[o ] = (char) (x >> 5 & 4 ^ 46);
11011: a[o + 1] = (char) (x >> 4 & 4 ^ 46);
11012: a[o + 2] = (char) (x >> 3 & 4 ^ 46);
11013: a[o + 3] = (char) (x >> 2 & 4 ^ 46);
11014: a[o + 4] = (char) (x >> 1 & 4 ^ 46);
11015: a[o + 5] = (char) (x & 4 ^ 46);
11016: a[o + 6] = (char) (x << 1 & 4 ^ 46);
11017: a[o + 7] = (char) (x << 2 & 4 ^ 46);
11018: }
11019: public static void fmtBin8 (char[] a, int o, int x) {
11020: a[o ] = (char) (x >>> 7 & 1 | 48);
11021: a[o + 1] = (char) (x >>> 6 & 1 | 48);
11022: a[o + 2] = (char) (x >>> 5 & 1 | 48);
11023: a[o + 3] = (char) (x >>> 4 & 1 | 48);
11024: a[o + 4] = (char) (x >>> 3 & 1 | 48);
11025: a[o + 5] = (char) (x >>> 2 & 1 | 48);
11026: a[o + 6] = (char) (x >>> 1 & 1 | 48);
11027: a[o + 7] = (char) (x & 1 | 48);
11028: }
11029: public static String fmtAin8 (int x) {
11030: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11031: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11032: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11033: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11034: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11035: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11036: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11037: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11038: return String.valueOf (FMT_TEMP, 0, 8);
11039: }
11040: public static String fmtBin8 (int x) {
11041: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11042: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11043: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11044: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11045: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11046: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11047: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11048: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11049: return String.valueOf (FMT_TEMP, 0, 8);
11050: }
11051: public static StringBuilder fmtAin8 (StringBuilder sb, int x) {
11052: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11053: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11054: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11055: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11056: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11057: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11058: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11059: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11060: return sb.append (FMT_TEMP, 0, 8);
11061: }
11062: public static StringBuilder fmtBin8 (StringBuilder sb, int x) {
11063: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11064: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11065: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11066: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11067: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11068: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11069: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11070: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11071: return sb.append (FMT_TEMP, 0, 8);
11072: }
11073:
11074:
11075:
11076:
11077:
11078:
11079:
11080:
11081: public static void fmtAin12 (char[] a, int o, int x) {
11082: a[o ] = (char) (x >> 9 & 4 ^ 46);
11083: a[o + 1] = (char) (x >> 8 & 4 ^ 46);
11084: a[o + 2] = (char) (x >> 7 & 4 ^ 46);
11085: a[o + 3] = (char) (x >> 6 & 4 ^ 46);
11086: a[o + 4] = (char) (x >> 5 & 4 ^ 46);
11087: a[o + 5] = (char) (x >> 4 & 4 ^ 46);
11088: a[o + 6] = (char) (x >> 3 & 4 ^ 46);
11089: a[o + 7] = (char) (x >> 2 & 4 ^ 46);
11090: a[o + 8] = (char) (x >> 1 & 4 ^ 46);
11091: a[o + 9] = (char) (x & 4 ^ 46);
11092: a[o + 10] = (char) (x << 1 & 4 ^ 46);
11093: a[o + 11] = (char) (x << 2 & 4 ^ 46);
11094: }
11095: public static void fmtBin12 (char[] a, int o, int x) {
11096: a[o ] = (char) (x >>> 11 & 1 | 48);
11097: a[o + 1] = (char) (x >>> 10 & 1 | 48);
11098: a[o + 2] = (char) (x >>> 9 & 1 | 48);
11099: a[o + 3] = (char) (x >>> 8 & 1 | 48);
11100: a[o + 4] = (char) (x >>> 7 & 1 | 48);
11101: a[o + 5] = (char) (x >>> 6 & 1 | 48);
11102: a[o + 6] = (char) (x >>> 5 & 1 | 48);
11103: a[o + 7] = (char) (x >>> 4 & 1 | 48);
11104: a[o + 8] = (char) (x >>> 3 & 1 | 48);
11105: a[o + 9] = (char) (x >>> 2 & 1 | 48);
11106: a[o + 10] = (char) (x >>> 1 & 1 | 48);
11107: a[o + 11] = (char) (x & 1 | 48);
11108: }
11109: public static String fmtAin12 (int x) {
11110: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11111: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11112: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11113: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11114: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11115: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11116: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11117: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11118: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11119: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11120: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11121: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11122: return String.valueOf (FMT_TEMP, 0, 12);
11123: }
11124: public static String fmtBin12 (int x) {
11125: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11126: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11127: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11128: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11129: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11130: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11131: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11132: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11133: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11134: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11135: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11136: FMT_TEMP[11] = (char) (x & 1 | 48);
11137: return String.valueOf (FMT_TEMP, 0, 12);
11138: }
11139: public static StringBuilder fmtAin12 (StringBuilder sb, int x) {
11140: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11141: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11142: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11143: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11144: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11145: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11146: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11147: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11148: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11149: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11150: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11151: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11152: return sb.append (FMT_TEMP, 0, 12);
11153: }
11154: public static StringBuilder fmtBin12 (StringBuilder sb, int x) {
11155: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11156: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11157: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11158: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11159: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11160: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11161: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11162: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11163: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11164: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11165: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11166: FMT_TEMP[11] = (char) (x & 1 | 48);
11167: return sb.append (FMT_TEMP, 0, 12);
11168: }
11169:
11170:
11171:
11172:
11173:
11174:
11175:
11176:
11177: public static void fmtAin16 (char[] a, int o, int x) {
11178: a[o ] = (char) (x >> 13 & 4 ^ 46);
11179: a[o + 1] = (char) (x >> 12 & 4 ^ 46);
11180: a[o + 2] = (char) (x >> 11 & 4 ^ 46);
11181: a[o + 3] = (char) (x >> 10 & 4 ^ 46);
11182: a[o + 4] = (char) (x >> 9 & 4 ^ 46);
11183: a[o + 5] = (char) (x >> 8 & 4 ^ 46);
11184: a[o + 6] = (char) (x >> 7 & 4 ^ 46);
11185: a[o + 7] = (char) (x >> 6 & 4 ^ 46);
11186: a[o + 8] = (char) (x >> 5 & 4 ^ 46);
11187: a[o + 9] = (char) (x >> 4 & 4 ^ 46);
11188: a[o + 10] = (char) (x >> 3 & 4 ^ 46);
11189: a[o + 11] = (char) (x >> 2 & 4 ^ 46);
11190: a[o + 12] = (char) (x >> 1 & 4 ^ 46);
11191: a[o + 13] = (char) (x & 4 ^ 46);
11192: a[o + 14] = (char) (x << 1 & 4 ^ 46);
11193: a[o + 15] = (char) (x << 2 & 4 ^ 46);
11194: }
11195: public static void fmtBin16 (char[] a, int o, int x) {
11196: a[o ] = (char) (x >>> 15 & 1 | 48);
11197: a[o + 1] = (char) (x >>> 14 & 1 | 48);
11198: a[o + 2] = (char) (x >>> 13 & 1 | 48);
11199: a[o + 3] = (char) (x >>> 12 & 1 | 48);
11200: a[o + 4] = (char) (x >>> 11 & 1 | 48);
11201: a[o + 5] = (char) (x >>> 10 & 1 | 48);
11202: a[o + 6] = (char) (x >>> 9 & 1 | 48);
11203: a[o + 7] = (char) (x >>> 8 & 1 | 48);
11204: a[o + 8] = (char) (x >>> 7 & 1 | 48);
11205: a[o + 9] = (char) (x >>> 6 & 1 | 48);
11206: a[o + 10] = (char) (x >>> 5 & 1 | 48);
11207: a[o + 11] = (char) (x >>> 4 & 1 | 48);
11208: a[o + 12] = (char) (x >>> 3 & 1 | 48);
11209: a[o + 13] = (char) (x >>> 2 & 1 | 48);
11210: a[o + 14] = (char) (x >>> 1 & 1 | 48);
11211: a[o + 15] = (char) (x & 1 | 48);
11212: }
11213: public static String fmtAin16 (int x) {
11214: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11215: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11216: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11217: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11218: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11219: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11220: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11221: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11222: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11223: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11224: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11225: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11226: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11227: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11228: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11229: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11230: return String.valueOf (FMT_TEMP, 0, 16);
11231: }
11232: public static String fmtBin16 (int x) {
11233: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11234: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11235: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11236: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11237: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11238: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11239: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11240: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11241: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11242: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11243: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11244: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11245: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11246: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11247: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11248: FMT_TEMP[15] = (char) (x & 1 | 48);
11249: return String.valueOf (FMT_TEMP, 0, 16);
11250: }
11251: public static StringBuilder fmtAin16 (StringBuilder sb, int x) {
11252: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11253: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11254: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11255: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11256: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11257: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11258: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11259: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11260: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11261: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11262: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11263: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11264: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11265: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11266: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11267: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11268: return sb.append (FMT_TEMP, 0, 16);
11269: }
11270: public static StringBuilder fmtBin16 (StringBuilder sb, int x) {
11271: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11272: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11273: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11274: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11275: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11276: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11277: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11278: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11279: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11280: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11281: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11282: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11283: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11284: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11285: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11286: FMT_TEMP[15] = (char) (x & 1 | 48);
11287: return sb.append (FMT_TEMP, 0, 16);
11288: }
11289:
11290:
11291:
11292:
11293:
11294:
11295:
11296:
11297: public static void fmtAin24 (char[] a, int o, int x) {
11298: a[o ] = (char) (x >> 21 & 4 ^ 46);
11299: a[o + 1] = (char) (x >> 20 & 4 ^ 46);
11300: a[o + 2] = (char) (x >> 19 & 4 ^ 46);
11301: a[o + 3] = (char) (x >> 18 & 4 ^ 46);
11302: a[o + 4] = (char) (x >> 17 & 4 ^ 46);
11303: a[o + 5] = (char) (x >> 16 & 4 ^ 46);
11304: a[o + 6] = (char) (x >> 15 & 4 ^ 46);
11305: a[o + 7] = (char) (x >> 14 & 4 ^ 46);
11306: a[o + 8] = (char) (x >> 13 & 4 ^ 46);
11307: a[o + 9] = (char) (x >> 12 & 4 ^ 46);
11308: a[o + 10] = (char) (x >> 11 & 4 ^ 46);
11309: a[o + 11] = (char) (x >> 10 & 4 ^ 46);
11310: a[o + 12] = (char) (x >> 9 & 4 ^ 46);
11311: a[o + 13] = (char) (x >> 8 & 4 ^ 46);
11312: a[o + 14] = (char) (x >> 7 & 4 ^ 46);
11313: a[o + 15] = (char) (x >> 6 & 4 ^ 46);
11314: a[o + 16] = (char) (x >> 5 & 4 ^ 46);
11315: a[o + 17] = (char) (x >> 4 & 4 ^ 46);
11316: a[o + 18] = (char) (x >> 3 & 4 ^ 46);
11317: a[o + 19] = (char) (x >> 2 & 4 ^ 46);
11318: a[o + 20] = (char) (x >> 1 & 4 ^ 46);
11319: a[o + 21] = (char) (x & 4 ^ 46);
11320: a[o + 22] = (char) (x << 1 & 4 ^ 46);
11321: a[o + 23] = (char) (x << 2 & 4 ^ 46);
11322: }
11323: public static void fmtBin24 (char[] a, int o, int x) {
11324: a[o ] = (char) (x >>> 23 & 1 | 48);
11325: a[o + 1] = (char) (x >>> 22 & 1 | 48);
11326: a[o + 2] = (char) (x >>> 21 & 1 | 48);
11327: a[o + 3] = (char) (x >>> 20 & 1 | 48);
11328: a[o + 4] = (char) (x >>> 19 & 1 | 48);
11329: a[o + 5] = (char) (x >>> 18 & 1 | 48);
11330: a[o + 6] = (char) (x >>> 17 & 1 | 48);
11331: a[o + 7] = (char) (x >>> 16 & 1 | 48);
11332: a[o + 8] = (char) (x >>> 15 & 1 | 48);
11333: a[o + 9] = (char) (x >>> 14 & 1 | 48);
11334: a[o + 10] = (char) (x >>> 13 & 1 | 48);
11335: a[o + 11] = (char) (x >>> 12 & 1 | 48);
11336: a[o + 12] = (char) (x >>> 11 & 1 | 48);
11337: a[o + 13] = (char) (x >>> 10 & 1 | 48);
11338: a[o + 14] = (char) (x >>> 9 & 1 | 48);
11339: a[o + 15] = (char) (x >>> 8 & 1 | 48);
11340: a[o + 16] = (char) (x >>> 7 & 1 | 48);
11341: a[o + 17] = (char) (x >>> 6 & 1 | 48);
11342: a[o + 18] = (char) (x >>> 5 & 1 | 48);
11343: a[o + 19] = (char) (x >>> 4 & 1 | 48);
11344: a[o + 20] = (char) (x >>> 3 & 1 | 48);
11345: a[o + 21] = (char) (x >>> 2 & 1 | 48);
11346: a[o + 22] = (char) (x >>> 1 & 1 | 48);
11347: a[o + 23] = (char) (x & 1 | 48);
11348: }
11349: public static String fmtAin24 (int x) {
11350: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11351: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11352: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11353: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11354: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11355: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11356: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11357: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11358: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11359: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11360: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11361: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11362: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11363: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11364: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11365: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11366: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11367: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11368: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11369: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11370: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11371: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11372: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11373: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11374: return String.valueOf (FMT_TEMP, 0, 24);
11375: }
11376: public static String fmtBin24 (int x) {
11377: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11378: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11379: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11380: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11381: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11382: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11383: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11384: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11385: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11386: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11387: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11388: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11389: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11390: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11391: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11392: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11393: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11394: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11395: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11396: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11397: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11398: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11399: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11400: FMT_TEMP[23] = (char) (x & 1 | 48);
11401: return String.valueOf (FMT_TEMP, 0, 24);
11402: }
11403: public static StringBuilder fmtAin24 (StringBuilder sb, int x) {
11404: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11405: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11406: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11407: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11408: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11409: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11410: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11411: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11412: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11413: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11414: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11415: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11416: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11417: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11418: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11419: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11420: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11421: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11422: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11423: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11424: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11425: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11426: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11427: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11428: return sb.append (FMT_TEMP, 0, 24);
11429: }
11430: public static StringBuilder fmtBin24 (StringBuilder sb, int x) {
11431: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11432: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11433: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11434: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11435: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11436: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11437: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11438: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11439: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11440: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11441: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11442: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11443: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11444: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11445: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11446: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11447: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11448: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11449: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11450: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11451: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11452: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11453: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11454: FMT_TEMP[23] = (char) (x & 1 | 48);
11455: return sb.append (FMT_TEMP, 0, 24);
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:
11482:
11483:
11484:
11485:
11486:
11487:
11488:
11489:
11490: public static char fmtHexc (int x) {
11491: x &= 15;
11492: return (char) ((((9 - x) >> 4) & 7) + 48 + x);
11493: }
11494: public static void fmtHex1 (char[] a, int o, int x) {
11495: x &= 15;
11496: a[o] = (char) ((((9 - x) >> 4) & 7) + 48 + x);
11497: }
11498: public static String fmtHex1 (int x) {
11499: x &= 15;
11500: return Character.toString ((char) ((((9 - x) >> 4) & 7) + 48 + x));
11501: }
11502: public static StringBuilder fmtHex1 (StringBuilder sb, int x) {
11503: x &= 15;
11504: return sb.append ((char) ((((9 - x) >> 4) & 7) + 48 + x));
11505: }
11506:
11507:
11508:
11509:
11510:
11511:
11512: public static void fmtHex2 (char[] a, int o, int x) {
11513: int x0 = x & 15;
11514: int x1 = x >>> 4 & 15;
11515: a[o ] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
11516: a[o + 1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
11517: }
11518: public static String fmtHex2 (int x) {
11519:
11520: int x0 = x & 15;
11521: int x1 = x >>> 4 & 15;
11522: FMT_TEMP[0] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
11523: FMT_TEMP[1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
11524: return String.valueOf (FMT_TEMP, 0, 2);
11525: }
11526: public static StringBuilder fmtHex2 (StringBuilder sb, int x) {
11527: int x0 = x & 15;
11528: int x1 = x >>> 4 & 15;
11529: return (sb.
11530: append ((char) ((((9 - x1) >> 4) & 7) + 48 + x1)).
11531: append ((char) ((((9 - x0) >> 4) & 7) + 48 + x0)));
11532: }
11533:
11534:
11535:
11536:
11537:
11538:
11539: public static void fmtHex4 (char[] a, int o, int x) {
11540: int t;
11541: t = (char) x >>> 12;
11542: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11543: t = x >>> 8 & 15;
11544: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11545: t = x >>> 4 & 15;
11546: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11547: t = x & 15;
11548: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11549: }
11550: public static String fmtHex4 (int x) {
11551:
11552: int t;
11553: t = (char) x >>> 12;
11554: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11555: t = x >>> 8 & 15;
11556: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11557: t = x >>> 4 & 15;
11558: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11559: t = x & 15;
11560: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11561: return String.valueOf (FMT_TEMP, 0, 4);
11562: }
11563: public static StringBuilder fmtHex4 (StringBuilder sb, int x) {
11564:
11565: int t;
11566: t = (char) x >>> 12;
11567: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11568: t = x >>> 8 & 15;
11569: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11570: t = x >>> 4 & 15;
11571: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11572: t = x & 15;
11573: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11574: return sb.append (FMT_TEMP, 0, 4);
11575: }
11576:
11577:
11578:
11579:
11580:
11581:
11582: public static void fmtHex6 (char[] a, int o, int x) {
11583: int t;
11584: t = x >>> 20 & 15;
11585: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11586: t = x >>> 16 & 15;
11587: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11588: t = (char) x >>> 12;
11589: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11590: t = x >>> 8 & 15;
11591: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11592: t = x >>> 4 & 15;
11593: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11594: t = x & 15;
11595: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11596: }
11597: public static String fmtHex6 (int x) {
11598:
11599: int t;
11600: t = x >>> 20 & 15;
11601: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11602: t = x >>> 16 & 15;
11603: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11604: t = (char) x >>> 12;
11605: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11606: t = x >>> 8 & 15;
11607: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11608: t = x >>> 4 & 15;
11609: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11610: t = x & 15;
11611: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11612: return String.valueOf (FMT_TEMP, 0, 6);
11613: }
11614: public static StringBuilder fmtHex6 (StringBuilder sb, int x) {
11615:
11616: int t;
11617: t = x >>> 20 & 15;
11618: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11619: t = x >>> 16 & 15;
11620: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11621: t = (char) x >>> 12;
11622: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11623: t = x >>> 8 & 15;
11624: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11625: t = x >>> 4 & 15;
11626: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11627: t = x & 15;
11628: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11629: return sb.append (FMT_TEMP, 0, 6);
11630: }
11631:
11632:
11633:
11634:
11635:
11636:
11637: public static void fmtHex8 (char[] a, int o, int x) {
11638: int t;
11639: t = x >>> 28;
11640: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11641: t = x >>> 24 & 15;
11642: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11643: t = x >>> 20 & 15;
11644: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11645: t = x >>> 16 & 15;
11646: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11647: t = (char) x >>> 12;
11648: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11649: t = x >>> 8 & 15;
11650: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11651: t = x >>> 4 & 15;
11652: a[o + 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11653: t = x & 15;
11654: a[o + 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11655: }
11656: public static String fmtHex8 (int x) {
11657:
11658: int t;
11659: t = x >>> 28;
11660: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11661: t = x >>> 24 & 15;
11662: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11663: t = x >>> 20 & 15;
11664: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11665: t = x >>> 16 & 15;
11666: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11667: t = (char) x >>> 12;
11668: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11669: t = x >>> 8 & 15;
11670: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11671: t = x >>> 4 & 15;
11672: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11673: t = x & 15;
11674: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11675: return String.valueOf (FMT_TEMP, 0, 8);
11676: }
11677: public static StringBuilder fmtHex8 (StringBuilder sb, int x) {
11678:
11679: int t;
11680: t = x >>> 28;
11681: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11682: t = x >>> 24 & 15;
11683: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11684: t = x >>> 20 & 15;
11685: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11686: t = x >>> 16 & 15;
11687: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11688: t = (char) x >>> 12;
11689: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11690: t = x >>> 8 & 15;
11691: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11692: t = x >>> 4 & 15;
11693: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11694: t = x & 15;
11695: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11696: return sb.append (FMT_TEMP, 0, 8);
11697: }
11698:
11699: public static StringBuilder fmtHex16 (StringBuilder sb, long x) {
11700:
11701: int s, t;
11702: s = (int) (x >>> 32);
11703: t = s >>> 28;
11704: FMT_TEMP[ 0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11705: t = s >>> 24 & 15;
11706: FMT_TEMP[ 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11707: t = s >>> 20 & 15;
11708: FMT_TEMP[ 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11709: t = s >>> 16 & 15;
11710: FMT_TEMP[ 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11711: t = (char) s >>> 12;
11712: FMT_TEMP[ 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11713: t = s >>> 8 & 15;
11714: FMT_TEMP[ 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11715: t = s >>> 4 & 15;
11716: FMT_TEMP[ 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11717: t = s & 15;
11718: FMT_TEMP[ 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11719: s = (int) x;
11720: t = s >>> 28;
11721: FMT_TEMP[ 8] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11722: t = s >>> 24 & 15;
11723: FMT_TEMP[ 9] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11724: t = s >>> 20 & 15;
11725: FMT_TEMP[10] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11726: t = s >>> 16 & 15;
11727: FMT_TEMP[11] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11728: t = (char) s >>> 12;
11729: FMT_TEMP[12] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11730: t = s >>> 8 & 15;
11731: FMT_TEMP[13] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11732: t = s >>> 4 & 15;
11733: FMT_TEMP[14] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11734: t = s & 15;
11735: FMT_TEMP[15] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11736: return sb.append (FMT_TEMP, 0, 16);
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:
11798:
11799:
11800:
11801:
11802:
11803:
11804:
11805:
11806: public static final int[] FMT_BCD4 = new int[10000];
11807: public static final int[] FMT_DCB4 = new int[65536];
11808:
11809:
11810:
11811:
11812: public static void fmtInit () {
11813: Arrays.fill (FMT_DCB4, -1);
11814: int i = 0;
11815: int x = 0;
11816: for (int a = 0; a < 10; a++) {
11817: for (int b = 0; b < 10; b++) {
11818: for (int c = 0; c < 10; c++) {
11819: FMT_DCB4[FMT_BCD4[i ] = x ] = i;
11820: FMT_DCB4[FMT_BCD4[i + 1] = x + 1] = i + 1;
11821: FMT_DCB4[FMT_BCD4[i + 2] = x + 2] = i + 2;
11822: FMT_DCB4[FMT_BCD4[i + 3] = x + 3] = i + 3;
11823: FMT_DCB4[FMT_BCD4[i + 4] = x + 4] = i + 4;
11824: FMT_DCB4[FMT_BCD4[i + 5] = x + 5] = i + 5;
11825: FMT_DCB4[FMT_BCD4[i + 6] = x + 6] = i + 6;
11826: FMT_DCB4[FMT_BCD4[i + 7] = x + 7] = i + 7;
11827: FMT_DCB4[FMT_BCD4[i + 8] = x + 8] = i + 8;
11828: FMT_DCB4[FMT_BCD4[i + 9] = x + 9] = i + 9;
11829: i += 10;
11830: x += 1 << 4;
11831: }
11832: x += 6 << 4;
11833: }
11834: x += 6 << 8;
11835: }
11836: }
11837:
11838:
11839:
11840: public static int fmtBcd4 (int x) {
11841:
11842:
11843:
11844:
11845:
11846:
11847:
11848:
11849:
11850: return FMT_BCD4[Math.max (0, Math.min (9999, x))];
11851: }
11852:
11853:
11854:
11855: public static int fmtBcd8 (int x) {
11856: x = Math.max (0, Math.min (99999999, x));
11857:
11858:
11859: int q = (int) ((long) x * 109951163L >>> 40);
11860:
11861: return FMT_BCD4[q] << 16 | FMT_BCD4[x - 10000 * q];
11862: }
11863:
11864:
11865:
11866: public static long fmtBcd12 (long x) {
11867: x = Math.max (0L, Math.min (999999999999L, x));
11868: int q = (int) ((double) x / 100000000.0);
11869: int r = (int) (x - 100000000L * q);
11870:
11871:
11872: int rq = (int) ((long) r * 109951163L >>> 40);
11873:
11874: return (long) FMT_BCD4[q] << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
11875: }
11876:
11877:
11878:
11879: public static long fmtBcd16 (long x) {
11880: x = Math.max (0L, Math.min (9999999999999999L, x));
11881: int q = x <= (1L << 53) ? (int) ((double) x / 100000000.0) : (int) (x / 100000000L);
11882: int r = (int) (x - 100000000L * q);
11883:
11884:
11885: int qq = (int) ((long) q * 109951163L >>> 40);
11886:
11887:
11888:
11889: int rq = (int) ((long) r * 109951163L >>> 40);
11890:
11891: return (long) (FMT_BCD4[qq] << 16 | FMT_BCD4[q - 10000 * qq]) << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
11892: }
11893:
11894:
11895:
11896:
11897:
11898:
11899: public static int fmtCA02u (char[] a, int o, int x) {
11900: if (x < 0 || 99 < x) {
11901: x = 99;
11902: }
11903: x = FMT_BCD4[x];
11904: a[o ] = (char) ('0' | x >>> 4);
11905: a[o + 1] = (char) ('0' | x & 15);
11906: return o + 2;
11907: }
11908: public static StringBuilder fmtSB02u (StringBuilder sb, int x) {
11909: return sb.append (FMT_TEMP, 0, fmtCA02u (FMT_TEMP, 0, x));
11910: }
11911:
11912:
11913:
11914:
11915:
11916: public static int fmtCA2u (char[] a, int o, int x) {
11917: if (x < 0 || 99 < x) {
11918: x = 99;
11919: }
11920: x = FMT_BCD4[x];
11921: if (x <= 0x000f) {
11922: a[o++] = (char) ('0' | x);
11923: } else {
11924: a[o++] = (char) ('0' | x >>> 4);
11925: a[o++] = (char) ('0' | x & 15);
11926: }
11927: return o;
11928: }
11929: public static StringBuilder fmtSB2u (StringBuilder sb, int x) {
11930: return sb.append (FMT_TEMP, 0, fmtCA2u (FMT_TEMP, 0, x));
11931: }
11932:
11933:
11934:
11935:
11936:
11937: public static int fmtCA04u (char[] a, int o, int x) {
11938: if (x < 0 || 9999 < x) {
11939: x = 9999;
11940: }
11941: x = FMT_BCD4[x];
11942: a[o ] = (char) ('0' | x >>> 12);
11943: a[o + 1] = (char) ('0' | x >>> 8 & 15);
11944: a[o + 2] = (char) ('0' | x >>> 4 & 15);
11945: a[o + 3] = (char) ('0' | x & 15);
11946: return o + 4;
11947: }
11948: public static StringBuilder fmtSB04u (StringBuilder sb, int x) {
11949: return sb.append (FMT_TEMP, 0, fmtCA04u (FMT_TEMP, 0, x));
11950: }
11951:
11952:
11953:
11954:
11955:
11956: public static int fmtCA4u (char[] a, int o, int x) {
11957: if (x < 0 || 9999 < x) {
11958: x = 9999;
11959: }
11960: x = FMT_BCD4[x];
11961: if (x <= 0x000f) {
11962: a[o++] = (char) ('0' | x);
11963: } else if (x <= 0x00ff) {
11964: a[o++] = (char) ('0' | x >>> 4);
11965: a[o++] = (char) ('0' | x & 15);
11966: } else if (x <= 0x0fff) {
11967: a[o++] = (char) ('0' | x >>> 8);
11968: a[o++] = (char) ('0' | x >>> 4 & 15);
11969: a[o++] = (char) ('0' | x & 15);
11970: } else {
11971: a[o++] = (char) ('0' | x >>> 12);
11972: a[o++] = (char) ('0' | x >>> 8 & 15);
11973: a[o++] = (char) ('0' | x >>> 4 & 15);
11974: a[o++] = (char) ('0' | x & 15);
11975: }
11976: return o;
11977: }
11978: public static StringBuilder fmtSB4u (StringBuilder sb, int x) {
11979: return sb.append (FMT_TEMP, 0, fmtCA4u (FMT_TEMP, 0, x));
11980: }
11981:
11982:
11983:
11984:
11985:
11986: public static int fmtCA08u (char[] a, int o, int x) {
11987: if (x < 0 || 99999999 < x) {
11988: x = 99999999;
11989: }
11990:
11991:
11992: int h = (int) ((long) x * 109951163L >>> 40);
11993: return fmtCA04u (a, fmtCA04u (a, o, h), x - h * 10000);
11994: }
11995: public static StringBuilder fmtSB08u (StringBuilder sb, int x) {
11996: return sb.append (FMT_TEMP, 0, fmtCA08u (FMT_TEMP, 0, x));
11997: }
11998:
11999:
12000:
12001:
12002:
12003: public static int fmtCA8u (char[] a, int o, int x) {
12004: if (x < 0 || 99999999 < x) {
12005: x = 99999999;
12006: }
12007: if (x <= 9999) {
12008: return fmtCA4u (a, o, x);
12009: } else {
12010:
12011:
12012: int h = (int) ((long) x * 109951163L >>> 40);
12013: return fmtCA04u (a, fmtCA4u (a, o, h), x - h * 10000);
12014: }
12015: }
12016: public static StringBuilder fmtSB8u (StringBuilder sb, int x) {
12017: return sb.append (FMT_TEMP, 0, fmtCA8u (FMT_TEMP, 0, x));
12018: }
12019:
12020:
12021:
12022:
12023:
12024: public static int fmtCAd (char[] a, int o, long x) {
12025: if (x < 0L) {
12026: x = -x;
12027: a[o++] = '-';
12028: }
12029: if (x <= 99999999L) {
12030: return fmtCA8u (a, o, (int) x);
12031: } else if (x <= 9999999999999999L) {
12032: long h = x / 100000000L;
12033: return fmtCA08u (a, fmtCA8u (a, o, (int) h), (int) (x - h * 100000000L));
12034: } else {
12035: long hh = x / 10000000000000000L;
12036: x -= hh * 10000000000000000L;
12037: long h = x / 100000000L;
12038: return fmtCA08u (a, fmtCA08u (a, fmtCA4u (a, o, (int) hh), (int) h), (int) (x - h * 100000000L));
12039: }
12040: }
12041: public static StringBuilder fmtSBd (StringBuilder sb, long x) {
12042: return sb.append (FMT_TEMP, 0, fmtCAd (FMT_TEMP, 0, x));
12043: }
12044:
12045:
12046:
12047:
12048:
12049:
12050: public static int fmtCAnd (char[] a, int o, int n, long x) {
12051: int t = fmtCAd (a, o, x);
12052: n += o;
12053: if (t < n) {
12054: int i = n;
12055: while (o < t) {
12056: a[--i] = a[--t];
12057: }
12058: while (o < i) {
12059: a[--i] = ' ';
12060: }
12061: t = n;
12062: }
12063: return t;
12064: }
12065: public static StringBuilder fmtSBnd (StringBuilder sb, int n, int x) {
12066: return sb.append (FMT_TEMP, 0, fmtCAnd (FMT_TEMP, 0, n, x));
12067: }
12068:
12069:
12070:
12071:
12072:
12073:
12074:
12075:
12076:
12077:
12078:
12079:
12080:
12081: public static int fmtParseInt (String s, int i, int min, int max, int err) {
12082: return fmtParseIntRadix (s, i, min, max, err, 10);
12083: }
12084: public static int fmtParseIntRadix (String s, int i, int min, int max, int err, int radix) {
12085: if (s == null) {
12086: return err;
12087: }
12088: int l = s.length ();
12089: int c = i < l ? s.charAt (i++) : -1;
12090:
12091: while (c == ' ' || c == '\t') {
12092: c = i < l ? s.charAt (i++) : -1;
12093: }
12094:
12095: int n = 0;
12096: if (c == '+') {
12097: c = i < l ? s.charAt (i++) : -1;
12098: } else if (c == '-') {
12099: n = 1;
12100: c = i < l ? s.charAt (i++) : -1;
12101: }
12102:
12103:
12104:
12105:
12106: int o;
12107: int p;
12108: if (c == '$') {
12109: o = 0x07ffffff + n;
12110: p = 15 + n & 15;
12111: radix = 16;
12112: c = i < l ? s.charAt (i++) : -1;
12113: } else if (radix == 16) {
12114: o = 0x07ffffff + n;
12115: p = 15 + n & 15;
12116: } else if (radix == 8) {
12117: o = 0x0fffffff + n;
12118: p = 7 + n & 7;
12119: } else if (radix == 2) {
12120: o = 0x3fffffff + n;
12121: p = 1 + n & 1;
12122: } else {
12123: o = 214748364;
12124: p = 7 + n;
12125: radix = 10;
12126: }
12127:
12128: int x = Character.digit (c, radix);
12129: if (x < 0) {
12130: return err;
12131: }
12132: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12133: while (c >= 0) {
12134: int t = x - o;
12135: if (t > 0 || t == 0 && c > p) {
12136: return err;
12137: }
12138: x = x * radix + c;
12139: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12140: }
12141: if (n != 0) {
12142: x = -x;
12143: }
12144: return min <= x && x <= max ? x : err;
12145: }
12146:
12147:
12148:
12149:
12150:
12151:
12152:
12153:
12154:
12155:
12156: public static long matMax3 (long x1, long x2, long x3) {
12157: return Math.max (Math.max (x1, x2), x3);
12158: }
12159: public static long matMax4 (long x1, long x2, long x3, long x4) {
12160: return Math.max (Math.max (x1, x2), Math.max (x3, x4));
12161: }
12162: public static long matMax5 (long x1, long x2, long x3, long x4, long x5) {
12163: return Math.max (Math.max (Math.max (x1, x2), Math.max (x3, x4)), x5);
12164: }
12165:
12166:
12167:
12168:
12169:
12170: public static long matMin3 (long x1, long x2, long x3) {
12171: return Math.min (Math.min (x1, x2), x3);
12172: }
12173: public static long matMin4 (long x1, long x2, long x3, long x4) {
12174: return Math.min (Math.min (x1, x2), Math.min (x3, x4));
12175: }
12176: public static long matMin5 (long x1, long x2, long x3, long x4, long x5) {
12177: return Math.min (Math.min (Math.min (x1, x2), Math.min (x3, x4)), x5);
12178: }
12179:
12180:
12181:
12182:
12183:
12184:
12185:
12186:
12187:
12188:
12189:
12190:
12191: public static String strEncodeUTF8 (String s) {
12192: StringBuilder sb = new StringBuilder ();
12193: int l = s.length ();
12194: for (int i = 0; i < l; i++) {
12195: int u = s.charAt (i);
12196: if (0xd800 <= u && u <= 0xdbff && i + 1 < l) {
12197: int v = s.charAt (i + 1);
12198: if (0xdc00 <= v && v <= 0xdfff) {
12199: u = 0x10000 + ((u & 0x3ff) << 10) + (v & 0x3ff);
12200: i++;
12201: }
12202: }
12203: if ((u & 0xffffff80) == 0) {
12204: sb.append ((char) u);
12205: } else if ((u & 0xfffff800) == 0) {
12206: u = (0x0000c080 |
12207: (u & 0x000007c0) << 2 |
12208: (u & 0x0000003f));
12209: sb.append ((char) (u >> 8)).append ((char) (u & 0xff));
12210: } else if ((u & 0xffff0000) == 0 && !(0xd800 <= u && u <= 0xdfff)) {
12211: u = (0x00e08080 |
12212: (u & 0x0000f000) << 4 |
12213: (u & 0x00000fc0) << 2 |
12214: (u & 0x0000003f));
12215: sb.append ((char) (u >> 16)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12216: } else if ((u & 0xffe00000) == 0) {
12217: u = (0xf0808080 |
12218: (u & 0x001c0000) << 6 |
12219: (u & 0x0003f000) << 4 |
12220: (u & 0x00000fc0) << 2 |
12221: (u & 0x0000003f));
12222: sb.append ((char) ((u >> 24) & 0xff)).append ((char) ((u >> 16) & 0xff)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12223: } else {
12224: sb.append ((char) 0xef).append ((char) 0xbf).append ((char) 0xbd);
12225: }
12226: }
12227: return sb.toString ();
12228: }
12229:
12230:
12231:
12232:
12233:
12234:
12235:
12236: public static String strDecodeUTF8 (String s) {
12237: StringBuilder sb = new StringBuilder ();
12238: int l = s.length ();
12239: for (int i = 0; i < l; i++) {
12240: int c = s.charAt (i) & 0xff;
12241: for (int k = ((c & 0x80) == 0x00 ? 0 :
12242: (c & 0xe0) == 0xc0 ? 1 :
12243: (c & 0xf0) == 0xe0 ? 2 :
12244: (c & 0xf8) == 0xf0 ? 3 :
12245: -1);
12246: --k >= 0; ) {
12247: c = c << 8 | (i + 1 < l ? s.charAt (++i) & 0xff : 0);
12248: }
12249: int u = ((c & 0xffffff80) == 0x00000000 ? c :
12250: (c & 0xffffe0c0) == 0x0000c080 ? ((c & 0x00001f00) >> 2 |
12251: (c & 0x0000003f)) :
12252: (c & 0xfff0c0c0) == 0x00e08080 ? ((c & 0x000f0000) >> 4 |
12253: (c & 0x00003f00) >> 2 |
12254: (c & 0x0000003f)) :
12255: (c & 0xf8c0c0c0) == 0xf0808080 ? ((c & 0x07000000) >> 6 |
12256: (c & 0x003f0000) >> 4 |
12257: (c & 0x00003f00) >> 2 |
12258: (c & 0x0000003f)) :
12259: 0xfffd);
12260: if (u <= 0x0000ffff) {
12261: sb.append (0xd800 <= u && u <= 0xdfff ? '\ufffd' :
12262: (char) u);
12263: } else if (u <= 0x0010ffff) {
12264: u -= 0x000010000;
12265: sb.append ((char) (0xd800 + ((u >> 10) & 0x3ff))).append ((char) (0xdc00 + (u & 0x3ff)));
12266: }
12267: }
12268: return sb.toString ();
12269: }
12270:
12271:
12272:
12273:
12274:
12275: public static final int[] IsURIChar = {
12276:
12277:
12278: 0b00000000_00000000_00000000_00000000,
12279: 0b00000000_00000110_11111111_11000000,
12280: 0b01111111_11111111_11111111_11100001,
12281: 0b01111111_11111111_11111111_11100010,
12282: };
12283: public static String strEncodeURI (String s) {
12284: s = strEncodeUTF8 (s);
12285: StringBuilder sb = new StringBuilder ();
12286: int l = s.length ();
12287: for (int i = 0; i < l; i++) {
12288: int c = s.charAt (i);
12289: if (c < 0x80 && IsURIChar[c >> 5] << c < 0) {
12290: sb.append ((char) c);
12291: } else {
12292: fmtHex2 (sb.append ('%'), c);
12293: }
12294: }
12295: return sb.toString ();
12296: }
12297:
12298:
12299:
12300:
12301:
12302: public static final byte[] strIsHexChar = {
12303:
12304: -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,
12305: -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,
12306: -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,
12307: -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,
12308: };
12309: public static String strDecodeURI (String s) {
12310: StringBuilder sb = new StringBuilder ();
12311: int l = s.length ();
12312: for (int i = 0; i < l; i++) {
12313: int c = s.charAt (i);
12314: if (c == '%' && i + 2 < l) {
12315: int d = s.charAt (i + 1);
12316: int e = s.charAt (i + 2);
12317: if (d < 0x80 && (d = strIsHexChar[d]) >= 0 &&
12318: e < 0x80 && (e = strIsHexChar[e]) >= 0) {
12319: sb.append ((char) (d << 4 | e));
12320: } else {
12321: sb.append ((char) c);
12322: }
12323: } else {
12324: sb.append ((char) c);
12325: }
12326: }
12327: return sb.toString ();
12328: }
12329:
12330:
12331:
12332:
12333:
12334:
12335:
12336:
12337: public static BufferedImage createImage (int width, int height, String pattern, int... rgbs) {
12338: BufferedImage image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
12339: int[] bitmap = ((DataBufferInt) image.getRaster ().getDataBuffer ()).getData ();
12340: int length = width * height;
12341: for (int i = 0; i < length; i++) {
12342: char c = pattern.charAt (i);
12343: bitmap[i] = rgbs[c < '0' ? 0 : Character.digit (c, 16)];
12344: }
12345: return image;
12346: }
12347:
12348:
12349:
12350: public static ImageIcon createImageIcon (int width, int height, String pattern, int... rgbs) {
12351: return new ImageIcon (createImage (width, height, pattern, rgbs));
12352: }
12353:
12354:
12355:
12356: public static TexturePaint createTexturePaint (int width, int height, String pattern, int... rgbs) {
12357: return new TexturePaint (createImage (width, height, pattern, rgbs), new Rectangle (0, 0, width, height));
12358: }
12359:
12360:
12361:
12362: public static BufferedImage loadImage (String name) {
12363: BufferedImage image = null;
12364: try {
12365: image = ImageIO.read (new File (name));
12366: } catch (Exception e) {
12367: }
12368: return image;
12369: }
12370:
12371:
12372:
12373:
12374: public static boolean saveImage (BufferedImage image, String name) {
12375: return saveImage (image, name, 0.75F);
12376: }
12377: public static boolean saveImage (BufferedImage image, String name, float quality) {
12378: int index = name.lastIndexOf (".");
12379: if (index < 0) {
12380: return false;
12381: }
12382: if (name.substring (index).equalsIgnoreCase (".ico")) {
12383: return saveIcon (name, image);
12384: }
12385: Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix (name.substring (index + 1));
12386: if (!iterator.hasNext ()) {
12387: return false;
12388: }
12389: ImageWriter imageWriter = iterator.next ();
12390: ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam ();
12391: if (imageWriteParam.canWriteCompressed ()) {
12392: imageWriteParam.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);
12393: imageWriteParam.setCompressionQuality (quality);
12394: }
12395: try {
12396: File file = new File (name);
12397: ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream (file);
12398: imageWriter.setOutput (imageOutputStream);
12399: imageWriter.write (null, new IIOImage (image, null, null), imageWriteParam);
12400: imageOutputStream.close ();
12401: } catch (Exception e) {
12402:
12403: return false;
12404: }
12405: return true;
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:
12472:
12473:
12474:
12475:
12476:
12477:
12478:
12479:
12480: public static boolean saveIcon (String fileName, BufferedImage... arrayImage) {
12481: int iconCount = arrayImage.length;
12482: int[][] arrayPaletTable = new int[iconCount][];
12483: int[] arrayPaletCount = new int[iconCount];
12484: int[] arrayPixelBits = new int[iconCount];
12485: int[] arrayPatternLineSize = new int[iconCount];
12486: int[] arrayMaskLineSize = new int[iconCount];
12487: int[] arrayImageSize = new int[iconCount];
12488: int[] arrayImageOffset = new int[iconCount];
12489: int fileSize = 6 + 16 * iconCount;
12490: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
12491: BufferedImage image = arrayImage[iconNumber];
12492: int width = image.getWidth ();
12493: int height = image.getHeight ();
12494:
12495: int[] paletTable = new int[256];
12496: int paletCount = 0;
12497: countPalet:
12498: for (int y = height - 1; y >= 0; y--) {
12499: for (int x = 0; x < width; x++) {
12500: int rgb = image.getRGB (x, y);
12501: if (rgb >>> 24 != 0xff) {
12502: continue;
12503: }
12504: int l = 0;
12505: int r = paletCount;
12506: while (l < r) {
12507: int m = l + r >> 1;
12508: if (paletTable[m] < rgb) {
12509: l = m + 1;
12510: } else {
12511: r = m;
12512: }
12513: }
12514: if (l == paletCount || paletTable[l] != rgb) {
12515: if (paletCount == 256) {
12516: paletCount = 0;
12517: break countPalet;
12518: }
12519: for (int i = paletCount; i > l; i--) {
12520: paletTable[i] = paletTable[i - 1];
12521: }
12522: paletTable[l] = rgb;
12523: paletCount++;
12524: }
12525: }
12526: }
12527: int pixelBits = (paletCount == 0 ? 24 :
12528: paletCount > 16 ? 8 :
12529: paletCount > 4 ? 4 :
12530: paletCount > 2 ? 2 :
12531: 1);
12532: int patternLineSize = pixelBits * width + 31 >> 5 << 2;
12533: int maskLineSize = width + 31 >> 5 << 2;
12534: int imageSize = 40 + 4 * paletCount + patternLineSize * height + maskLineSize * height;
12535: arrayPaletTable[iconNumber] = paletTable;
12536: arrayPaletCount[iconNumber] = paletCount;
12537: arrayPixelBits[iconNumber] = pixelBits;
12538: arrayPatternLineSize[iconNumber] = patternLineSize;
12539: arrayMaskLineSize[iconNumber] = maskLineSize;
12540: arrayImageSize[iconNumber] = imageSize;
12541: arrayImageOffset[iconNumber] = fileSize;
12542: fileSize += imageSize;
12543: }
12544: byte[] bb = new byte[fileSize];
12545:
12546: ByteArray.byaWiw (bb, 0, 0);
12547: ByteArray.byaWiw (bb, 2, 1);
12548: ByteArray.byaWiw (bb, 4, iconCount);
12549: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
12550: BufferedImage image = arrayImage[iconNumber];
12551: int width = image.getWidth ();
12552: int height = image.getHeight ();
12553: int[] paletTable = arrayPaletTable[iconNumber];
12554: int paletCount = arrayPaletCount[iconNumber];
12555: int pixelBits = arrayPixelBits[iconNumber];
12556: int patternLineSize = arrayPatternLineSize[iconNumber];
12557: int maskLineSize = arrayMaskLineSize[iconNumber];
12558: int imageSize = arrayImageSize[iconNumber];
12559: int imageOffset = arrayImageOffset[iconNumber];
12560:
12561: int o = 6 + 16 * iconNumber;
12562: ByteArray.byaWb (bb, o, width);
12563: ByteArray.byaWb (bb, o + 1, height);
12564: ByteArray.byaWb (bb, o + 2, paletCount);
12565: ByteArray.byaWb (bb, o + 3, 0);
12566: ByteArray.byaWiw (bb, o + 4, 1);
12567: ByteArray.byaWiw (bb, o + 6, pixelBits);
12568: ByteArray.byaWil (bb, o + 8, imageSize);
12569: ByteArray.byaWil (bb, o + 12, imageOffset);
12570:
12571: o = imageOffset;
12572: ByteArray.byaWil (bb, o, 40);
12573: ByteArray.byaWil (bb, o + 4, width);
12574: ByteArray.byaWil (bb, o + 8, height * 2);
12575: ByteArray.byaWiw (bb, o + 12, 1);
12576: ByteArray.byaWiw (bb, o + 14, pixelBits);
12577: ByteArray.byaWil (bb, o + 16, 0);
12578: ByteArray.byaWil (bb, o + 20, 0);
12579: ByteArray.byaWil (bb, o + 24, 0);
12580: ByteArray.byaWil (bb, o + 28, 0);
12581: ByteArray.byaWil (bb, o + 32, paletCount);
12582: ByteArray.byaWil (bb, o + 36, 0);
12583:
12584: o += 40;
12585: for (int i = 0; i < paletCount; i++) {
12586: ByteArray.byaWil (bb, o, paletTable[i] & 0x00ffffff);
12587: o += 4;
12588: }
12589:
12590: for (int y = height - 1; y >= 0; y--) {
12591: for (int x = 0; x < width; x++) {
12592: int rgb = image.getRGB (x, y);
12593: if (rgb >>> 24 != 0xff) {
12594: continue;
12595: }
12596: if (pixelBits == 24) {
12597: bb[o + 3 * x] = (byte) rgb;
12598: bb[o + 3 * x + 1] = (byte) (rgb >> 8);
12599: bb[o + 3 * x + 2] = (byte) (rgb >> 16);
12600: continue;
12601: }
12602: int l = 0;
12603: int r = paletCount;
12604: while (l < r) {
12605: int m = l + r >> 1;
12606: if (paletTable[m] < rgb) {
12607: l = m + 1;
12608: } else {
12609: r = m;
12610: }
12611: }
12612: if (l != 0) {
12613: if (pixelBits == 8) {
12614: bb[o + x] = (byte) l;
12615: } else if (pixelBits == 4) {
12616: bb[o + (x >> 1)] |= (byte) (l << ((~x & 1) << 2));
12617: } else if (pixelBits == 2) {
12618: bb[o + (x >> 2)] |= (byte) (l << ((~x & 3) << 1));
12619: } else {
12620: bb[o + (x >> 3)] |= (byte) (l << (~x & 7));
12621: }
12622: }
12623: }
12624: o += patternLineSize;
12625: }
12626:
12627: for (int y = height - 1; y >= 0; y--) {
12628: for (int x = 0; x < width; x++) {
12629: int rgb = image.getRGB (x, y);
12630: if (rgb >>> 24 != 0xff) {
12631: bb[o + (x >> 3)] |= (byte) (1 << (~x & 7));
12632: }
12633: }
12634: o += maskLineSize;
12635: }
12636: }
12637: return rscPutFile (fileName, bb, 0, fileSize);
12638: }
12639:
12640:
12641:
12642: }
12643:
12644:
12645: