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.24.04.08";
43: public static final String PRG_AUTHOR = "Makoto Kamada";
44: public static final String PRG_WEBPAGE = "https://stdkmd.net/xeij/";
45:
46: public static final String PRG_JAVA_VENDOR = "Oracle Corporation";
47: public static final String PRG_JAVA_VERSION = "21.0.2";
48: public static final String PRG_OS_ARCH = "amd64";
49: public static final String PRG_OS_NAME = "Windows 10";
50:
51: public static final String PRG_WINDLL_NAME = "xeijwin";
52: public static final int PRG_WINDLL_VERSION = 20231008;
53:
54:
55:
56:
57:
58:
59:
60: public static final boolean TEST_BIT_0_SHIFT = false;
61: public static final boolean TEST_BIT_1_SHIFT = false;
62: public static final boolean TEST_BIT_2_SHIFT = true;
63: public static final boolean TEST_BIT_3_SHIFT = true;
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81: public static final boolean SHORT_SATURATION_CAST = false;
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93: public static final Charset ISO_8859_1 = Charset.forName ("ISO-8859-1");
94: static {
95: if (false) {
96:
97: StringBuilder sb = new StringBuilder ();
98: for (int i = 0; i < 256; i++) {
99: sb.append ((char) i);
100: }
101: byte[] bb = sb.toString ().getBytes (ISO_8859_1);
102: for (int i = 0; i < 256; i++) {
103: System.out.printf ("%02x %02x %s\n", i, bb[i] & 255, i == (bb[i] & 255) ? "OK" : "ERROR");
104: }
105: }
106: }
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119: public static String prgJavaVendor;
120: public static String prgJavaVersion;
121: public static String prgOsArch;
122: public static String prgOsName;
123: public static boolean prgIsLinux;
124: public static boolean prgIsMac;
125: public static boolean prgIsWindows;
126: public static boolean prgWindllLoaded;
127:
128: public static boolean prgCaseIgnored;
129:
130: public static boolean prgVerbose;
131:
132: public static String[] prgArgs;
133:
134:
135:
136: public static void main (String[] args) {
137:
138: prgArgs = args;
139:
140:
141: SwingUtilities.invokeLater (new Runnable () {
142: @Override public void run () {
143: new XEiJ ();
144: }
145: });
146:
147: }
148:
149:
150:
151: public XEiJ () {
152:
153: prgJavaVendor = System.getProperty ("java.vendor");
154: prgJavaVersion = System.getProperty ("java.version");
155: prgOsArch = System.getProperty ("os.arch");
156: prgOsName = System.getProperty ("os.name");
157: prgIsLinux = 0 <= prgOsName.indexOf ("Linux");
158: prgIsMac = 0 <= prgOsName.indexOf ("Mac");
159: prgIsWindows = 0 <= prgOsName.indexOf ("Windows");
160:
161: System.out.print ("\n" +
162: "-------------------------------------------------\n" +
163: PRG_TITLE + " version " + PRG_VERSION + "\n" +
164: "-------------------------------------------------\n");
165:
166:
167:
168:
169: prgCaseIgnored = new File ("A").equals (new File ("a"));
170: fmtInit ();
171: Multilingual.mlnInit ();
172:
173: System.out.println (Multilingual.mlnJapanese ? "java.vendor は " + prgJavaVendor + " です" :
174: "java.vendor is " + prgJavaVendor);
175: System.out.println (Multilingual.mlnJapanese ? "java.version は " + prgJavaVersion + " です" :
176: "java.version is " + prgJavaVersion);
177: System.out.println (Multilingual.mlnJapanese ? "os.arch は " + prgOsArch + " です" :
178: "os.arch is " + prgOsArch);
179: System.out.println (Multilingual.mlnJapanese ? "os.name は " + prgOsName + " です" :
180: "os.name is " + prgOsName);
181:
182:
183: prgWindllLoaded = false;
184: if (prgIsWindows) {
185: try {
186: System.loadLibrary (PRG_WINDLL_NAME);
187: if (PRG_WINDLL_VERSION <= WinDLL.version ()) {
188: prgWindllLoaded = true;
189: System.out.println (Multilingual.mlnJapanese ?
190: PRG_WINDLL_NAME + ".dll を読み込みました" :
191: PRG_WINDLL_NAME + ".dll was read");
192: } else {
193: System.out.println (Multilingual.mlnJapanese ?
194: PRG_WINDLL_NAME + ".dll のバージョンが違います" :
195: PRG_WINDLL_NAME + ".dll version mismatch");
196: }
197: } catch (UnsatisfiedLinkError ule) {
198: System.out.println (Multilingual.mlnJapanese ?
199: PRG_WINDLL_NAME + ".dll を読み込めません" :
200: PRG_WINDLL_NAME + ".dll cannot be read");
201: }
202: }
203:
204: rbtInit ();
205:
206: Settings.sgsInit ();
207: LnF.lnfInit ();
208:
209: CharacterCode.chrInit ();
210:
211: TickerQueue.tkqInit ();
212:
213: RS232CTerminal.trmInit ();
214:
215: xt3Init ();
216: mdlInit ();
217:
218: if (InstructionBreakPoint.IBP_ON) {
219: InstructionBreakPoint.ibpInit ();
220: }
221: if (DataBreakPoint.DBP_ON) {
222: DataBreakPoint.dbpInit ();
223: }
224: busInit ();
225: MainMemory.mmrInit ();
226: ROM.romInit ();
227: graInit ();
228: txtInit ();
229: CRTC.crtInit ();
230: VideoController.vcnInit ();
231: HD63450.dmaInit ();
232: svsInit ();
233: MC68901.mfpInit ();
234: RP5C15.rtcInit ();
235: sysInit ();
236: if (OPMLog.OLG_ON) {
237: OPMLog.olgInit ();
238: }
239: OPM.opmInit ();
240: ADPCM.pcmInit ();
241: FDC.fdcInit ();
242: HDC.hdcInit ();
243: SPC.spcInit ();
244: Z8530.sccInit ();
245: IOInterrupt.ioiInit ();
246: SpriteScreen.sprInit ();
247: bnkInit ();
248: SRAM.smrInit ();
249:
250: PPI.ppiInit ();
251: PrinterPort.prnInit ();
252: Indicator.indInit ();
253:
254: SlowdownTest.sdtInit ();
255: Keyboard.kbdInit ();
256: CONDevice.conInit ();
257: Mouse.musInit ();
258: pnlInit ();
259: frmInit ();
260:
261: dbgInit ();
262: RegisterList.drpInit ();
263: DisassembleList.ddpInit ();
264: MemoryDumpList.dmpInit ();
265: LogicalSpaceMonitor.atwInit ();
266: PhysicalSpaceMonitor.paaInit ();
267: DebugConsole.dgtInit ();
268: if (BranchLog.BLG_ON) {
269: BranchLog.blgInit ();
270: }
271: if (ProgramFlowVisualizer.PFV_ON) {
272: ProgramFlowVisualizer.pfvInit ();
273: }
274: if (RasterBreakPoint.RBP_ON) {
275: RasterBreakPoint.rbpInit ();
276: }
277: if (ScreenModeTest.SMT_ON) {
278: ScreenModeTest.smtInit ();
279: }
280: if (RootPointerList.RTL_ON) {
281: RootPointerList.rtlInit ();
282: }
283: if (SpritePatternViewer.SPV_ON) {
284: SpritePatternViewer.spvInit ();
285: }
286: if (ATCMonitor.ACM_ON) {
287: ATCMonitor.acmInit ();
288: }
289:
290: SoundSource.sndInit ();
291: FEFunction.fpkInit ();
292: mpuInit ();
293: MC68060.mmuInit ();
294: SoundMonitor.smnInit ();
295: HFS.hfsInit ();
296:
297: GIFAnimation.gifInit ();
298:
299:
300:
301: Settings.sgsMakeMenu ();
302: mdlMakeMenu ();
303: FDC.fdcMakeMenu ();
304: HDC.hdcMakeMenu ();
305: SPC.spcMakeMenu ();
306: mpuMakeMenu ();
307: SRAM.smrMakeMenu ();
308: mnbMakeMenu ();
309: pnlMake ();
310: frmMake ();
311: clpMake ();
312: dbgMakePopup ();
313:
314:
315: final String flags = (
316: "" +
317: (EFPBox.CIR_DEBUG_TRACE ? " EFPBox.CIR_DEBUG_TRACE" : "") +
318: (FDC.FDC_DEBUG_TRACE ? " FDC.FDC_DEBUG_TRACE" : "") +
319: (FEFunction.FPK_DEBUG_TRACE ? " FEFunction.FPK_DEBUG_TRACE" : "") +
320: (HD63450.DMA_DEBUG_TRACE != 0 ? " HD63450.DMA_DEBUG_TRACE" : "") +
321: (HDC.HDC_DEBUG_TRACE ? " HDC.HDC_DEBUG_TRACE" : "") +
322: (HDC.HDC_DEBUG_COMMAND ? " HDC.HDC_DEBUG_COMMAND" : "") +
323: (HFS.HFS_DEBUG_TRACE ? " HFS.HFS_DEBUG_TRACE" : "") +
324: (HFS.HFS_DEBUG_FILE_INFO ? " HFS.HFS_DEBUG_FILE_INFO" : "") +
325: (HFS.HFS_COMMAND_TRACE ? " HFS.HFS_COMMAND_TRACE" : "") +
326: (HFS.HFS_BUFFER_TRACE ? " HFS.HFS_BUFFER_TRACE" : "") +
327: (IOInterrupt.IOI_DEBUG_TRACE ? " IOInterrupt.IOI_DEBUG_TRACE" : "") +
328: (Keyboard.KBD_DEBUG_LED ? " Keyboard.KBD_DEBUG_LED" : "") +
329: (M68kException.M6E_DEBUG_ERROR ? " M68kException.M6E_DEBUG_ERROR" : "") +
330: (MC68060.MMU_DEBUG_COMMAND ? " MC68060.MMU_DEBUG_COMMAND" : "") +
331: (MC68060.MMU_DEBUG_TRANSLATION ? " MC68060.MMU_DEBUG_TRANSLATION" : "") +
332: (MC68060.MMU_NOT_ALLOCATE_CACHE ? " MC68060.MMU_NOT_ALLOCATE_CACHE" : "") +
333: (RP5C15.RTC_DEBUG_TRACE ? " RP5C15.RTC_DEBUG_TRACE" : "") +
334: (SPC.SPC_DEBUG_ON ? " SPC.SPC_DEBUG_ON" : "") +
335: (Z8530.SCC_DEBUG_ON ? " Z8530.SCC_DEBUG_ON" : "")
336: );
337: if (!"".equals (flags)) {
338: JOptionPane.showMessageDialog (null, "debug flags:" + flags);
339: }
340:
341:
342:
343:
344: tmrStart ();
345:
346: Keyboard.kbdStart ();
347: Mouse.musStart ();
348: pnlStart ();
349: frmStart ();
350: SoundSource.sndStart ();
351:
352: if (DataBreakPoint.DBP_ON) {
353: DataBreakPoint.dbpStart ();
354: }
355: if (RasterBreakPoint.RBP_ON) {
356: RasterBreakPoint.rbpStart ();
357: }
358: if (ScreenModeTest.SMT_ON) {
359: ScreenModeTest.smtStart ();
360: }
361: if (OPMLog.OLG_ON) {
362: OPMLog.olgStart ();
363: }
364: SoundMonitor.smnStart ();
365: RS232CTerminal.trmStart ();
366: PPI.ppiStart ();
367: PrinterPort.prnStart ();
368: if (BranchLog.BLG_ON) {
369: BranchLog.blgStart ();
370: }
371: if (ProgramFlowVisualizer.PFV_ON) {
372: ProgramFlowVisualizer.pfvStart ();
373: }
374: RegisterList.drpStart ();
375: DisassembleList.ddpStart ();
376: MemoryDumpList.dmpStart ();
377: LogicalSpaceMonitor.atwStart ();
378: PhysicalSpaceMonitor.paaStart ();
379: DebugConsole.dgtStart ();
380: if (RootPointerList.RTL_ON) {
381: RootPointerList.rtlStart ();
382: }
383: if (SpritePatternViewer.SPV_ON) {
384: SpritePatternViewer.spvStart ();
385: }
386: if (ATCMonitor.ACM_ON) {
387: ATCMonitor.acmStart ();
388: }
389:
390: if (Settings.sgsSaveiconValue != null) {
391: String[] a = Settings.sgsSaveiconValue.split (",");
392: if (0 < a.length) {
393: saveIcon (a[0], LnF.LNF_ICON_IMAGES);
394: if (1 < a.length) {
395: saveImage (LnF.LNF_ICON_IMAGE_16, a[1]);
396: if (2 < a.length) {
397: saveImage (LnF.LNF_ICON_IMAGE_32, a[2]);
398: if (3 < a.length) {
399: saveImage (LnF.LNF_ICON_IMAGE_48, a[3]);
400: }
401: }
402: }
403: }
404: prgTini ();
405: return;
406: }
407:
408:
409: mpuReset (-1, -1);
410:
411: }
412:
413:
414:
415:
416:
417: public static void prgTini () {
418: try {
419: if (OPMLog.OLG_ON) {
420: OPMLog.olgTini ();
421: }
422: GIFAnimation.gifTini ();
423: SoundSource.sndTini ();
424: Keyboard.kbdTini ();
425: Mouse.musTini ();
426: CONDevice.conTini ();
427: PPI.ppiTini ();
428: PrinterPort.prnTini ();
429: FDC.fdcTini ();
430: HDC.hdcTini ();
431: SPC.spcTini ();
432: HFS.hfsTini ();
433: Z8530.sccTini ();
434: CRTC.crtTini ();
435: SpriteScreen.sprTini ();
436: pnlTini ();
437: bnkTini ();
438: ROM.romTini ();
439: xt3Tini ();
440: mdlTini ();
441: SRAM.smrTini ();
442: tmrTini ();
443: busTini ();
444: RS232CTerminal.trmTini ();
445: LnF.lnfTini ();
446: Settings.sgsTini ();
447: } catch (Exception e) {
448: e.printStackTrace ();
449: }
450: System.exit (0);
451: }
452:
453:
454:
455: public static void prgOpenJavaDialog () {
456: JOptionPane.showMessageDialog (
457: frmFrame,
458: ComponentFactory.createGridPanel (
459: 3,
460: 6,
461: "paddingLeft=6,paddingRight=6",
462: "italic,right;left;left",
463: "italic,center;colSpan=3,widen",
464: "",
465:
466: null,
467: Multilingual.mlnJapanese ? "実行中" : "Running",
468: Multilingual.mlnJapanese ? "推奨" : "Recommended",
469:
470: ComponentFactory.createHorizontalSeparator (),
471:
472: Multilingual.mlnJapanese ? "Java のベンダー" : "Java Vendor",
473: prgJavaVendor,
474: PRG_JAVA_VENDOR,
475:
476: Multilingual.mlnJapanese ? "Java のバージョン" : "Java Version",
477: prgJavaVersion,
478: PRG_JAVA_VERSION,
479:
480: Multilingual.mlnJapanese ? "OS のアーキテクチャ" : "OS Architecture",
481: prgOsArch,
482: PRG_OS_ARCH,
483:
484: Multilingual.mlnJapanese ? "OS の名前" : "OS Name",
485: prgOsName,
486: PRG_OS_NAME
487: ),
488: Multilingual.mlnJapanese ? "Java 実行環境の情報" : "Java runtime environment information",
489: JOptionPane.PLAIN_MESSAGE);
490: }
491:
492:
493:
494: public static void prgOpenAboutDialog () {
495: JOptionPane.showMessageDialog (
496: frmFrame,
497: ComponentFactory.createGridPanel (
498: 2, 4, "paddingLeft=6,paddingRight=6", "italic,right;left", "", "",
499: Multilingual.mlnJapanese ? "タイトル" : "Title" ,
500: PRG_TITLE,
501: Multilingual.mlnJapanese ? "バージョン" : "Version",
502: PRG_VERSION,
503: Multilingual.mlnJapanese ? "作者" : "Author" ,
504: PRG_AUTHOR,
505: Multilingual.mlnJapanese ? "ウェブページ" : "Webpage",
506: PRG_WEBPAGE
507: ),
508: Multilingual.mlnJapanese ? "バージョン情報" : "Version information",
509: JOptionPane.PLAIN_MESSAGE);
510: }
511:
512:
513:
514: public static void prgOpenXEiJLicenseDialog () {
515: JOptionPane.showMessageDialog (
516: frmFrame,
517: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_XEiJ.txt"), 550, 300),
518: Multilingual.mlnJapanese ? "XEiJ 使用許諾条件" : "XEiJ License",
519: JOptionPane.PLAIN_MESSAGE);
520: }
521:
522:
523:
524: public static void prgOpenSHARPLicenseDialog () {
525: JOptionPane.showMessageDialog (
526: frmFrame,
527: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_FSHARP.txt", "Shift_JIS"), 550, 300),
528: Multilingual.mlnJapanese ? "無償公開された X68000 の基本ソフトウェア製品の許諾条件" : "License of the basic software products for X68000 that were distributed free of charge",
529: JOptionPane.PLAIN_MESSAGE);
530: }
531:
532:
533:
534: public static void prgOpenYmfmLicenseDialog () {
535: JOptionPane.showMessageDialog (
536: frmFrame,
537: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_ymfm.txt"), 550, 300),
538: "ymfm License",
539: JOptionPane.PLAIN_MESSAGE);
540: }
541:
542:
543:
544: public static void prgOpenJSerialCommLicenseDialog () {
545: JOptionPane.showMessageDialog (
546: frmFrame,
547: ComponentFactory.createVerticalSplitPane (
548: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-APACHE-2.0"), 550, 300),
549: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-LGPL-3.0"), 550, 300)
550: ),
551: "jSerialComm License",
552: JOptionPane.PLAIN_MESSAGE);
553: }
554:
555:
556:
557: public static void prgPrintClass (Object o) {
558: System.out.println (o.toString ());
559:
560: try {
561: Stack<Class<?>> s = new Stack<Class<?>> ();
562: for (Class<?> c = o.getClass (); c != null; c = c.getSuperclass ()) {
563: s.push (c);
564: }
565: for (int i = 0; !s.empty (); i++) {
566: for (int j = 0; j < i; j++) {
567: System.out.print (" ");
568: }
569: System.out.println (s.pop ().getName ());
570: }
571: } catch (Exception e) {
572: }
573: }
574:
575:
576:
577:
578: public static void prgPrintStackTrace () {
579: Exception e = new Exception ();
580: e.fillInStackTrace ();
581: prgPrintStackTraceOf (e);
582: }
583: public static void prgPrintStackTraceOf (Exception e) {
584:
585: System.out.println ("------------------------------------------------");
586: System.out.println (e.toString ());
587: System.out.println ("\t" + e.getMessage ());
588: for (StackTraceElement ste : e.getStackTrace ()) {
589: System.out.println ("\tat " + ste.toString ());
590: }
591: System.out.println ("------------------------------------------------");
592: }
593:
594:
595:
596:
597: public static boolean prgStopDone = false;
598: public static void prgStopOnce () {
599: if (!prgStopDone) {
600: prgStopDone = true;
601: mpuStop (null);
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:
628:
629:
630:
631:
632:
633:
634:
635: public static final long TMR_FREQ = 1000000000000L;
636:
637:
638: public static final long TMR_DELAY = 10L;
639: public static final long TMR_INTERVAL = 10L;
640:
641:
642: public static java.util.Timer tmrTimer;
643:
644:
645:
646: public static void tmrStart () {
647: tmrTimer = new java.util.Timer ();
648: }
649:
650:
651:
652: public static void tmrTini () {
653: if (tmrTimer != null) {
654: tmrTimer.cancel ();
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:
685:
686:
687:
688:
689:
690:
691:
692: public static final int PNL_BM_OFFSET_BITS = 10;
693: public static final int PNL_BM_WIDTH = 1 << PNL_BM_OFFSET_BITS;
694: public static final int PNL_BM_HEIGHT = 1024;
695:
696:
697: public static final int PNL_ASPECT_KEYS = 4;
698: public static final int PNL_ASPECT_VALUES = 4;
699: public static final int[] PNL_ASPECT_DEFAULT_VALUE = { 0, 0, 0, 3 };
700: public static final String[] PNL_ASPECT_RESOLUTION_NAME = { "256x256", "384x256", "512x512", "768x512" };
701: public static final String[] PNL_ASPECT_SCREEN_NAME = { "4:3", "7:5", "13:9", "3:2" };
702: public static final String[] PNL_ASPECT_PIXEL_NAME = { "8:9", "14:15", "26:27", "1:1" };
703: public static final float[] PNL_ASPECT_SCREEN_RATIO = { 4.0F / 3.0F, 7.0F / 5.0F, 13.0F / 9.0F, 3.0F / 2.0F };
704: public static final float[] PNL_ASPECT_PIXEL_RATIO = { 8.0F / 9.0F, 14.0F / 15.0F, 26.0F / 27.0F, 1.0F / 1.0F };
705: public static final float[][] PNL_ASPECT_MATRIX = {
706: PNL_ASPECT_SCREEN_RATIO,
707: PNL_ASPECT_PIXEL_RATIO,
708: PNL_ASPECT_SCREEN_RATIO,
709: PNL_ASPECT_PIXEL_RATIO,
710: };
711: public static int[] pnlAspectMap;
712: public static float[] pnlAspectTable;
713:
714:
715: public static int pnlScreenWidth;
716: public static int pnlScreenHeight;
717: public static float pnlStretchMode;
718: public static int pnlStretchWidth;
719: public static int pnlZoomWidth;
720: public static int pnlZoomHeight;
721: public static int pnlZoomRatioOut;
722: public static int pnlZoomRatioInX;
723: public static int pnlZoomRatioInY;
724: public static int pnlWidth;
725: public static int pnlHeight;
726: public static Dimension pnlSize;
727: public static int pnlScreenX1;
728: public static int pnlScreenX2;
729: public static int pnlScreenX3;
730: public static int pnlScreenX4;
731: public static int pnlScreenY1;
732: public static int pnlScreenY2;
733: public static int pnlScreenY3;
734: public static int pnlScreenY4;
735: public static int pnlKeyboardX;
736: public static int pnlKeyboardY;
737: public static int pnlMinimumWidth;
738: public static int pnlMinimumHeight;
739: public static int pnlGlobalX;
740: public static int pnlGlobalY;
741:
742:
743: public static final boolean PNL_FILL_BACKGROUND = true;
744: public static boolean pnlFillBackgroundRequest;
745: public static boolean pnlIsFullscreenSupported;
746: public static boolean pnlFullscreenOn;
747: public static boolean pnlIsFitInWindowSupported;
748: public static boolean pnlFitInWindowOn;
749: public static boolean pnlPrevFitInWindowOn;
750: public static boolean pnlPrevKeyboardOn;
751:
752:
753:
754:
755:
756: public static Object pnlInterpolation;
757:
758:
759:
760:
761:
762:
763:
764:
765:
766:
767:
768:
769:
770:
771:
772:
773:
774:
775:
776:
777:
778:
779:
780:
781:
782:
783:
784:
785:
786:
787:
788:
789:
790:
791:
792:
793:
794:
795:
796:
797:
798:
799:
800:
801:
802:
803:
804:
805:
806: public static final boolean PNL_STEREOSCOPIC_ON = true;
807: public static BufferedImage pnlScreenImageLeft;
808: public static BufferedImage pnlScreenImageRight;
809: public static int[] pnlBMLeft;
810: public static int[] pnlBMRight;
811: public static int[] pnlBM;
812: public static boolean pnlStereoscopicOn;
813: public static final int PNL_NAKED_EYE_CROSSING = 0;
814: public static final int PNL_NAKED_EYE_PARALLEL = 1;
815: public static final int PNL_SIDE_BY_SIDE = 2;
816: public static final int PNL_TOP_AND_BOTTOM = 3;
817: public static int pnlStereoscopicMethod;
818: public static int pnlStereoscopicFactor;
819: public static int pnlStereoscopicShutter;
820:
821:
822: public static JPanel pnlPanel;
823:
824:
825: public static int pnlFixedScale;
826: public static SpinnerNumberModel pnlFixedModel;
827: public static JSpinner pnlFixedSpinner;
828:
829:
830:
831: public static void pnlInit () {
832:
833:
834:
835: switch (Settings.sgsGetString ("scaling").toLowerCase ()) {
836: case "fullscreen":
837: pnlFullscreenOn = true;
838: pnlFitInWindowOn = false;
839: break;
840: case "fitinwindow":
841: pnlFullscreenOn = false;
842: pnlFitInWindowOn = true;
843: break;
844: case "fixedscale":
845: pnlFullscreenOn = false;
846: pnlFitInWindowOn = false;
847: break;
848: default:
849: pnlFullscreenOn = false;
850: pnlFitInWindowOn = true;
851: }
852:
853: pnlFixedScale = Math.max (10, Math.min (1000, Settings.sgsGetInt ("fixedscale")));
854:
855:
856: pnlAspectMap = new int[PNL_ASPECT_KEYS];
857: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
858: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[key];
859: String screenName = Settings.sgsGetString ("aspectratio" + resolutionName);
860: int value = PNL_ASPECT_DEFAULT_VALUE[key];
861: for (int tempValue = 0; tempValue < PNL_ASPECT_VALUES; tempValue++) {
862: if (PNL_ASPECT_SCREEN_NAME[tempValue].equals (screenName)) {
863: value = tempValue;
864: break;
865: }
866: }
867: pnlAspectMap[key] = value;
868: }
869: pnlAspectTable = new float[8];
870: pnlUpdateAspectTable ();
871:
872:
873: switch (Settings.sgsGetString ("interpolation").toLowerCase ()) {
874: case "nearest":
875: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
876: break;
877: case "bilinear":
878: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
879: break;
880: case "bicubic":
881: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
882: break;
883: default:
884: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
885: }
886:
887: pnlPrevFitInWindowOn = pnlFitInWindowOn;
888: pnlPrevKeyboardOn = true;
889:
890:
891: pnlScreenImageLeft = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_RGB);
892: pnlScreenImageRight = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_RGB);
893: pnlBMLeft = ((DataBufferInt) pnlScreenImageLeft.getRaster ().getDataBuffer ()).getData ();
894: pnlBMRight = ((DataBufferInt) pnlScreenImageRight.getRaster ().getDataBuffer ()).getData ();
895: pnlBM = pnlBMLeft;
896: pnlStereoscopicOn = Settings.sgsGetOnOff ("stereoscopic");
897: switch (Settings.sgsGetString ("stereoscopicmethod").toLowerCase ()) {
898: case "nakedeyecrossing":
899: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
900: break;
901: case "nakedeyeparallel":
902: pnlStereoscopicMethod = PNL_NAKED_EYE_PARALLEL;
903: break;
904: case "sidebyside":
905: pnlStereoscopicMethod = PNL_SIDE_BY_SIDE;
906: break;
907: case "topandbottom":
908: pnlStereoscopicMethod = PNL_TOP_AND_BOTTOM;
909: break;
910: default:
911: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
912: }
913: pnlStereoscopicFactor = pnlStereoscopicOn && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
914: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
915: pnlStereoscopicShutter = 0;
916:
917:
918: pnlScreenWidth = 768;
919: pnlScreenHeight = 512;
920: pnlStretchMode = 1.0F;
921: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchMode);
922: pnlZoomWidth = pnlStretchWidth;
923: pnlZoomHeight = pnlScreenHeight;
924: pnlWidth = Math.max (pnlZoomWidth * pnlStereoscopicFactor, Keyboard.kbdWidth);
925: pnlHeight = pnlZoomHeight + Keyboard.kbdHeight;
926: pnlSize = new Dimension (pnlWidth, pnlHeight);
927: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
928: pnlScreenY1 = 0;
929: pnlArrangementCommon ();
930: pnlMinimumWidth = Math.max (256, Keyboard.kbdWidth);
931: pnlMinimumHeight = 64 + Keyboard.kbdHeight;
932: pnlGlobalX = 0;
933: pnlGlobalY = 0;
934:
935:
936: if (!PNL_FILL_BACKGROUND) {
937: pnlFillBackgroundRequest = true;
938: }
939:
940:
941: pnlFixedModel = new SpinnerNumberModel (pnlFixedScale, 10, 1000, 1);
942: pnlFixedSpinner = ComponentFactory.createNumberSpinner (pnlFixedModel, 4, new ChangeListener () {
943: @Override public void stateChanged (ChangeEvent ce) {
944: mnbFixedScaleMenuItem.setSelected (true);
945: pnlSetFitInWindowOn (false);
946: pnlSetFullscreenOn (false);
947: pnlUpdateArrangement ();
948: }
949: });
950:
951: }
952:
953:
954: public static void pnlSetStereoscopic (boolean on, int method) {
955: if (pnlStereoscopicOn != on || pnlStereoscopicMethod != method) {
956: pnlStereoscopicMethod = method;
957: pnlStereoscopicFactor = on && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
958: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
959: if (!pnlStereoscopicOn && on) {
960: System.arraycopy (pnlBMLeft, 0, pnlBMRight, 0, 1024 * 1024);
961: } else if (pnlStereoscopicOn && !on) {
962: pnlBM = pnlBMLeft;
963: }
964: pnlStereoscopicOn = on;
965: if (pnlFullscreenOn &&
966: pnlStereoscopicOn && (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ||
967: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM)) {
968: frmFrame.setJMenuBar (null);
969: Keyboard.kbdSetOn (false);
970: }
971: pnlUpdateArrangement ();
972: }
973: }
974:
975:
976: public static void pnlTini () {
977:
978:
979: Settings.sgsPutString ("scaling",
980: pnlFullscreenOn ? "fullscreen" :
981: pnlFitInWindowOn ? "fitinwindow" :
982: "fixedscale");
983:
984: Settings.sgsPutInt ("fixedscale", pnlFixedScale);
985:
986:
987: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
988: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[key];
989: int value = pnlAspectMap[key];
990: String screenName = PNL_ASPECT_SCREEN_NAME[value];
991: Settings.sgsPutString ("aspectratio" + resolutionName, screenName);
992: }
993:
994:
995: Settings.sgsPutString ("interpolation",
996: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR ? "nearest" :
997: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR ? "bilinear" :
998: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC ? "bicubic" :
999: "bilinear");
1000:
1001: Settings.sgsPutOnOff ("stereoscopic", pnlStereoscopicOn);
1002: Settings.sgsPutString ("stereoscopicmethod",
1003: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ? "nakedeyecrossing" :
1004: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL ? "nakedeyeparallel" :
1005: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ? "sidebyside" :
1006: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM ? "topandbottom" :
1007: "nakedeyecrossing");
1008: }
1009:
1010:
1011:
1012: public static void pnlUpdateAspectTable () {
1013: float[] ratio = new float[PNL_ASPECT_KEYS];
1014: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
1015: int value = pnlAspectMap[key];
1016: ratio[key] = PNL_ASPECT_MATRIX[key][value];
1017: }
1018: pnlAspectTable[0] = ratio[0] * 2.0F;
1019: pnlAspectTable[1] = ratio[2];
1020: pnlAspectTable[2] = ratio[3];
1021: pnlAspectTable[3] = ratio[3];
1022: pnlAspectTable[4] = ratio[1] * 4.0F;
1023: pnlAspectTable[5] = ratio[1] * 2.0F;
1024: pnlAspectTable[6] = ratio[3];
1025: pnlAspectTable[7] = ratio[3];
1026: }
1027:
1028:
1029:
1030: public static void pnlMake () {
1031:
1032:
1033: pnlPanel = new JPanel () {
1034: @Override protected void paintComponent (Graphics g) {
1035: Graphics2D g2 = (Graphics2D) g;
1036: if (PNL_FILL_BACKGROUND || pnlFillBackgroundRequest) {
1037: if (!PNL_FILL_BACKGROUND) {
1038: pnlFillBackgroundRequest = false;
1039: }
1040: g2.setColor (Color.black);
1041: g2.fillRect (0, 0, pnlWidth, pnlHeight);
1042: }
1043: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, pnlInterpolation);
1044: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1045: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1046: g2.drawImage (pnlScreenImageRight,
1047: pnlScreenX1, pnlScreenY1,
1048: pnlScreenX2, pnlScreenY2,
1049: 0, 0, pnlScreenWidth, pnlScreenHeight,
1050: null);
1051: g2.drawImage (pnlScreenImageLeft,
1052: pnlScreenX3, pnlScreenY3,
1053: pnlScreenX4, pnlScreenY4,
1054: 0, 0, pnlScreenWidth, pnlScreenHeight,
1055: null);
1056: } else {
1057:
1058:
1059:
1060: g2.drawImage (pnlScreenImageLeft,
1061: pnlScreenX1, pnlScreenY1,
1062: pnlScreenX2, pnlScreenY2,
1063: 0, 0, pnlScreenWidth, pnlScreenHeight,
1064: null);
1065: g2.drawImage (pnlScreenImageRight,
1066: pnlScreenX3, pnlScreenY3,
1067: pnlScreenX4, pnlScreenY4,
1068: 0, 0, pnlScreenWidth, pnlScreenHeight,
1069: null);
1070: }
1071: } else {
1072: g2.drawImage (pnlScreenImageLeft,
1073: pnlScreenX1, pnlScreenY1,
1074: pnlScreenX2, pnlScreenY2,
1075: 0, 0, pnlScreenWidth, pnlScreenHeight,
1076: null);
1077: }
1078: g2.drawImage (Keyboard.kbdImage, pnlKeyboardX, pnlKeyboardY, null);
1079: }
1080: @Override protected void paintBorder (Graphics g) {
1081: }
1082: @Override protected void paintChildren (Graphics g) {
1083: }
1084: };
1085: pnlPanel.setBackground (Color.black);
1086: pnlPanel.setOpaque (true);
1087: pnlPanel.setPreferredSize (pnlSize);
1088:
1089: if (Mouse.musCursorAvailable) {
1090: pnlPanel.setCursor (Mouse.musCursorArray[1]);
1091: }
1092:
1093: }
1094:
1095:
1096:
1097:
1098: public static void pnlStart () {
1099:
1100:
1101: ComponentFactory.addListener (
1102: pnlPanel,
1103: new ComponentAdapter () {
1104: @Override public void componentResized (ComponentEvent ce) {
1105: pnlWidth = pnlPanel.getWidth ();
1106: pnlHeight = pnlPanel.getHeight ();
1107: pnlUpdateArrangement ();
1108: }
1109: });
1110:
1111: }
1112:
1113:
1114:
1115: public static void pnlSetFullscreenOn (boolean on) {
1116: if (pnlIsFullscreenSupported && pnlFullscreenOn != on) {
1117: if (on) {
1118: pnlFullscreenOn = true;
1119: pnlPrevKeyboardOn = Keyboard.kbdImage != null;
1120: pnlPrevFitInWindowOn = pnlFitInWindowOn;
1121: mnbFullscreenMenuItem.setSelected (true);
1122: frmSetFullscreenOn (true);
1123: pnlSetFitInWindowOn (true);
1124: if (pnlStereoscopicOn && (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ||
1125: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM)) {
1126: frmFrame.setJMenuBar (null);
1127: Keyboard.kbdSetOn (false);
1128: }
1129: } else {
1130: pnlFullscreenOn = false;
1131: if (pnlPrevKeyboardOn) {
1132: Keyboard.kbdSetOn (true);
1133: }
1134: frmFrame.setJMenuBar (mnbMenuBar);
1135: if (!pnlPrevFitInWindowOn) {
1136: pnlSetFitInWindowOn (false);
1137: }
1138: frmSetFullscreenOn (false);
1139: }
1140: }
1141: }
1142:
1143:
1144:
1145:
1146: public static void pnlSetFitInWindowOn (boolean on) {
1147: if (pnlIsFitInWindowSupported && pnlFitInWindowOn != on) {
1148: pnlFitInWindowOn = on;
1149: pnlUpdateArrangement ();
1150: if (!pnlFullscreenOn) {
1151: if (on) {
1152: mnbFitInWindowMenuItem.setSelected (true);
1153: } else {
1154: mnbFixedScaleMenuItem.setSelected (true);
1155: }
1156: }
1157: }
1158: }
1159:
1160:
1161:
1162:
1163:
1164:
1165:
1166:
1167:
1168:
1169: public static void pnlUpdateArrangement () {
1170: pnlStretchMode = pnlAspectTable[CRTC.crtHRLCurr << 2 | CRTC.crtHResoCurr];
1171: pnlScreenWidth = Math.max (256, (CRTC.crtR03HDispEndCurr - CRTC.crtR02HBackEndCurr) << 3);
1172: pnlScreenHeight = Math.max (64, (CRTC.crtR07VDispEndCurr - CRTC.crtR06VBackEndCurr) << (CRTC.crtInterlace || CRTC.crtSlit ? 1 : 0));
1173: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchMode);
1174: if (RasterBreakPoint.RBP_ON) {
1175:
1176: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
1177: RasterBreakPoint.rbpUpdateFrame ();
1178: }
1179: }
1180:
1181: pnlFixedScale = pnlFixedModel.getNumber ().intValue ();
1182:
1183: if (!pnlFitInWindowOn) {
1184:
1185:
1186:
1187:
1188:
1189: pnlZoomWidth = (pnlStretchWidth * pnlFixedScale + 50) * 5243 >>> 19;
1190: pnlZoomHeight = (pnlScreenHeight * pnlFixedScale + 50) * 5243 >>> 19;
1191: int width = Math.max (Math.max (256, pnlZoomWidth * pnlStereoscopicFactor), Keyboard.kbdWidth);
1192: int height = Math.max (64, pnlZoomHeight) + Keyboard.kbdHeight;
1193: pnlScreenX1 = (width - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1194: pnlScreenY1 = (height - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1195: if (pnlWidth != width || pnlHeight != height) {
1196: pnlWidth = width;
1197: pnlHeight = height;
1198: pnlMinimumWidth = width;
1199: pnlMinimumHeight = height;
1200: pnlSize.setSize (width, height);
1201:
1202: frmMinimumSize.setSize (width + frmMarginWidth, height + frmMarginHeight);
1203: frmFrame.setMinimumSize (frmMinimumSize);
1204: frmFrame.setMaximumSize (frmMinimumSize);
1205: frmFrame.setPreferredSize (frmMinimumSize);
1206: frmFrame.setResizable (false);
1207: pnlPanel.setMinimumSize (pnlSize);
1208: pnlPanel.setMaximumSize (pnlSize);
1209: pnlPanel.setPreferredSize (pnlSize);
1210: frmFrame.pack ();
1211: }
1212: } else {
1213:
1214: if (pnlWidth * pnlScreenHeight >= (pnlHeight - Keyboard.kbdHeight) * (pnlStretchWidth * pnlStereoscopicFactor)) {
1215:
1216:
1217:
1218:
1219:
1220:
1221:
1222:
1223:
1224:
1225:
1226:
1227: pnlZoomHeight = pnlHeight - Keyboard.kbdHeight;
1228: pnlZoomWidth = (pnlZoomHeight * pnlStretchWidth + (pnlScreenHeight >> 1)) / pnlScreenHeight;
1229: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1230: pnlScreenX1 = ((pnlWidth >> 1) - (pnlZoomWidth >> 1)) >> 1;
1231: } else {
1232: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1233: }
1234: pnlScreenY1 = 0;
1235: } else {
1236:
1237:
1238:
1239:
1240:
1241:
1242:
1243:
1244:
1245:
1246:
1247:
1248:
1249:
1250:
1251:
1252: pnlZoomWidth = pnlWidth / pnlStereoscopicFactor;
1253: pnlZoomHeight = (pnlZoomWidth * pnlStereoscopicFactor * pnlScreenHeight + (pnlStretchWidth * pnlStereoscopicFactor >> 1)) / (pnlStretchWidth * pnlStereoscopicFactor);
1254: pnlScreenX1 = 0;
1255: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM) {
1256: pnlScreenY1 = (((pnlHeight - Keyboard.kbdHeight) >> 1) - (pnlZoomHeight >> 1)) >> 1;
1257: } else {
1258: pnlScreenY1 = (pnlHeight - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1259: }
1260: }
1261:
1262: int minimumWidth = Math.max (256, Keyboard.kbdWidth);
1263: int minimumHeight = 64 + Keyboard.kbdHeight;
1264: if (pnlMinimumWidth != minimumWidth || pnlMinimumHeight != minimumHeight) {
1265: pnlMinimumWidth = minimumWidth;
1266: pnlMinimumHeight = minimumHeight;
1267: frmMinimumSize.setSize (minimumWidth + frmMarginWidth, minimumHeight + frmMarginHeight);
1268: frmFrame.setMinimumSize (frmMinimumSize);
1269: frmFrame.setMaximumSize (null);
1270: frmFrame.setResizable (true);
1271: }
1272: }
1273: pnlArrangementCommon ();
1274: Mouse.musUpdateSpeedRatio ();
1275: if (!PNL_FILL_BACKGROUND) {
1276: pnlFillBackgroundRequest = true;
1277: }
1278: pnlPanel.repaint ();
1279: }
1280:
1281: public static void pnlArrangementCommon () {
1282: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1283: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1284: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) {
1285: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1286: pnlScreenX3 = pnlScreenX2;
1287: pnlScreenX4 = pnlScreenX3 + pnlZoomWidth;
1288: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1289: pnlScreenY3 = pnlScreenY1;
1290: pnlScreenY4 = pnlScreenY2;
1291: } else if (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1292: pnlScreenX2 = pnlScreenX1 + (pnlZoomWidth >> 1);
1293: pnlScreenX3 = pnlScreenX1 + (pnlWidth >> 1);
1294: pnlScreenX4 = pnlScreenX3 + (pnlZoomWidth >> 1);
1295: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1296: pnlScreenY3 = pnlScreenY1;
1297: pnlScreenY4 = pnlScreenY2;
1298: } else {
1299: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1300: pnlScreenX3 = pnlScreenX1;
1301: pnlScreenX4 = pnlScreenX2;
1302: pnlScreenY2 = pnlScreenY1 + (pnlZoomHeight >> 1);
1303: pnlScreenY3 = pnlScreenY1 + ((pnlHeight - Keyboard.kbdHeight) >> 1);
1304: pnlScreenY4 = pnlScreenY3 + (pnlZoomHeight >> 1);
1305: }
1306: } else {
1307: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1308: pnlScreenX3 = pnlScreenX1;
1309: pnlScreenX4 = pnlScreenX2;
1310: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1311: pnlScreenY3 = pnlScreenY1;
1312: pnlScreenY4 = pnlScreenY2;
1313: }
1314: pnlKeyboardX = (pnlWidth - Keyboard.kbdWidth) >> 1;
1315: pnlKeyboardY = pnlScreenY4;
1316: pnlZoomRatioOut = (pnlZoomHeight << 16) / pnlScreenHeight;
1317: pnlZoomRatioInX = (pnlScreenWidth << 16) / (pnlZoomWidth * pnlStereoscopicFactor);
1318: pnlZoomRatioInY = (pnlScreenHeight << 16) / pnlZoomHeight;
1319: }
1320:
1321:
1322:
1323:
1324:
1325:
1326: public static Robot rbtRobot;
1327:
1328:
1329: public static void rbtInit () {
1330:
1331:
1332: rbtRobot = null;
1333: try {
1334: rbtRobot = new Robot ();
1335: } catch (Exception e) {
1336: }
1337:
1338: }
1339:
1340:
1341:
1342:
1343:
1344:
1345:
1346: public static final int MNB_MODIFIERS = InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK;
1347:
1348:
1349: public static JMenuBar mnbMenuBar;
1350:
1351:
1352: public static JMenu mnbFileMenu;
1353: public static JMenu mnbDisplayMenu;
1354: public static JMenu mnbSoundMenu;
1355: public static JMenu mnbInputMenu;
1356: public static JMenu mnbConfigMenu;
1357: public static JMenu mnbLanguageMenu;
1358:
1359:
1360:
1361:
1362:
1363: public static JMenuItem mnbQuitMenuItem;
1364: public static JRadioButtonMenuItem mnbFullscreenMenuItem;
1365: public static JRadioButtonMenuItem mnbFitInWindowMenuItem;
1366: public static JRadioButtonMenuItem mnbFixedScaleMenuItem;
1367: public static JCheckBoxMenuItem mnbStereoscopicMenuItem;
1368: public static JCheckBoxMenuItem mnbPlayMenuItem;
1369: public static JMenuItem mnbPasteMenuItem;
1370: public static JRadioButtonMenuItem mnbStandardKeyboardMenuItem;
1371: public static JRadioButtonMenuItem mnbCompactKeyboardMenuItem;
1372: public static JRadioButtonMenuItem mnbNoKeyboardMenuItem;
1373: public static JLabel mnbVolumeLabel;
1374:
1375:
1376:
1377:
1378:
1379:
1380: public static JMenu mnbMakeFontSizeMenu () {
1381:
1382: ActionListener actionListener = new ActionListener () {
1383: @Override public void actionPerformed (ActionEvent ae) {
1384: String command = ae.getActionCommand ();
1385: switch (command) {
1386: case "Very small":
1387: LnF.lnfFontSizeRequest = 10;
1388: break;
1389: case "Small":
1390: LnF.lnfFontSizeRequest = 12;
1391: break;
1392: case "Medium":
1393: LnF.lnfFontSizeRequest = 14;
1394: break;
1395: case "Large":
1396: LnF.lnfFontSizeRequest = 16;
1397: break;
1398: case "Very large":
1399: LnF.lnfFontSizeRequest = 18;
1400: break;
1401: default:
1402: System.out.println ("unknown action command " + command);
1403: }
1404: }
1405: };
1406:
1407: ButtonGroup fontSizeGroup = new ButtonGroup ();
1408:
1409: return Multilingual.mlnText (
1410: ComponentFactory.createMenu (
1411: "Font size",
1412: Multilingual.mlnText (
1413: ComponentFactory.pointSize (
1414: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 10, "Very small", actionListener),
1415: 10),
1416: "ja", "極小"),
1417: Multilingual.mlnText (
1418: ComponentFactory.pointSize (
1419: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 12, "Small", actionListener),
1420: 12),
1421: "ja", "小"),
1422: Multilingual.mlnText (
1423: ComponentFactory.pointSize (
1424: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 14, "Medium", actionListener),
1425: 14),
1426: "ja", "中"),
1427: Multilingual.mlnText (
1428: ComponentFactory.pointSize (
1429: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 16, "Large", actionListener),
1430: 16),
1431: "ja", "大"),
1432: Multilingual.mlnText (
1433: ComponentFactory.pointSize (
1434: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 18, "Very large", actionListener),
1435: 18),
1436: "ja", "極大")),
1437: "ja", "フォントサイズ");
1438: }
1439:
1440:
1441:
1442: public static final DecimalSpinner[] mnbColorSpinners = new DecimalSpinner[9];
1443: public static final int[] mnbColorRGB = new int[15];
1444: public static JPanel mnbColorPanel;
1445:
1446:
1447:
1448: public static void mnbColorHSBToRGB () {
1449: for (int i = 0; i <= 14; i++) {
1450: int[] t = LnF.LNF_HSB_INTERPOLATION_TABLE[i];
1451: float h = (float) (t[0] * LnF.lnfHSB[0] + t[1] * LnF.lnfHSB[1] + t[2] * LnF.lnfHSB[2]) / (49.0F * 360.0F);
1452: float s = (float) (t[0] * LnF.lnfHSB[3] + t[1] * LnF.lnfHSB[4] + t[2] * LnF.lnfHSB[5]) / (49.0F * 100.0F);
1453: float b = (float) (t[0] * LnF.lnfHSB[6] + t[1] * LnF.lnfHSB[7] + t[2] * LnF.lnfHSB[8]) / (49.0F * 100.0F);
1454: mnbColorRGB[i] = Color.HSBtoRGB (h,
1455: Math.max (0.0F, Math.min (1.0F, s)),
1456: Math.max (0.0F, Math.min (1.0F, b)));
1457: }
1458: }
1459:
1460:
1461:
1462: public static JMenu mnbMakeColorMenu () {
1463: mnbColorHSBToRGB ();
1464:
1465: mnbColorPanel = ComponentFactory.setColor (
1466: ComponentFactory.setFixedSize (
1467: new JPanel () {
1468: @Override protected void paintComponent (Graphics g) {
1469: super.paintComponent (g);
1470: for (int i = 0; i <= 14; i++) {
1471: g.setColor (new Color (mnbColorRGB[i]));
1472: g.fillRect (LnF.lnfFontSize * i, 0, LnF.lnfFontSize, LnF.lnfFontSize * 5);
1473: }
1474: }
1475: },
1476: LnF.lnfFontSize * 15, LnF.lnfFontSize * 5),
1477: Color.white, Color.black);
1478:
1479: ChangeListener changeListener = new ChangeListener () {
1480: @Override public void stateChanged (ChangeEvent ce) {
1481: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
1482: LnF.lnfHSB[spinner.getOption ()] = spinner.getIntValue ();
1483: mnbColorHSBToRGB ();
1484: mnbColorPanel.repaint ();
1485: }
1486: };
1487:
1488: ActionListener actionListener = new ActionListener () {
1489: @Override public void actionPerformed (ActionEvent ae) {
1490: String command = ae.getActionCommand ();
1491: switch (command) {
1492: case "Reset to default values":
1493: for (int i = 0; i < 9; i++) {
1494: LnF.lnfHSB[i] = LnF.LNF_DEFAULT_HSB[i];
1495: mnbColorSpinners[i].setIntValue (LnF.lnfHSB[i]);
1496: }
1497: mnbColorHSBToRGB ();
1498: mnbColorPanel.repaint ();
1499: break;
1500: default:
1501: System.out.println ("unknown action command " + command);
1502: }
1503: }
1504: };
1505:
1506: for (int i = 0; i < 9; i++) {
1507: mnbColorSpinners[i] = ComponentFactory.createDecimalSpinner (
1508: LnF.lnfHSB[i], 0, i < 3 ? 720 : 100, 1, i, changeListener);
1509: }
1510:
1511: return Multilingual.mlnText (
1512: ComponentFactory.createMenu (
1513: "Color",
1514: ComponentFactory.createHorizontalBox (
1515: mnbColorSpinners[0],
1516: mnbColorSpinners[1],
1517: mnbColorSpinners[2],
1518: ComponentFactory.createLabel ("H °"),
1519: Box.createHorizontalGlue ()
1520: ),
1521: ComponentFactory.createHorizontalBox (
1522: mnbColorSpinners[3],
1523: mnbColorSpinners[4],
1524: mnbColorSpinners[5],
1525: ComponentFactory.createLabel ("S%"),
1526: Box.createHorizontalGlue ()
1527: ),
1528: ComponentFactory.createHorizontalBox (
1529: mnbColorSpinners[6],
1530: mnbColorSpinners[7],
1531: mnbColorSpinners[8],
1532: ComponentFactory.createLabel ("B%"),
1533: Box.createHorizontalGlue ()
1534: ),
1535: ComponentFactory.createHorizontalBox (
1536: ComponentFactory.setLineBorder (mnbColorPanel),
1537: Box.createHorizontalGlue ()
1538: ),
1539: Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset to default values", actionListener), "ja", "初期値に戻す")
1540: ),
1541: "ja", "色");
1542: }
1543:
1544:
1545:
1546:
1547:
1548: public static JMenu mnbMakeLanguageMenu () {
1549:
1550: ActionListener actionListener = new ActionListener () {
1551: @Override public void actionPerformed (ActionEvent ae) {
1552: String command = ae.getActionCommand ();
1553: switch (command) {
1554: case "English":
1555: Multilingual.mlnChange ("en");
1556: break;
1557: case "日本語":
1558: Multilingual.mlnChange ("ja");
1559: break;
1560: default:
1561: System.out.println ("unknown action command " + command);
1562: }
1563: }
1564: };
1565:
1566: ButtonGroup languageGroup = new ButtonGroup ();
1567:
1568: return mnbLanguageMenu = Multilingual.mlnText (
1569: ComponentFactory.createMenu (
1570: "Language", 'L',
1571: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnEnglish, "English", actionListener),
1572: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnJapanese, "日本語", actionListener),
1573: ComponentFactory.createHorizontalSeparator (),
1574: mnbMakeFontSizeMenu (),
1575: mnbMakeColorMenu ()
1576: ),
1577: "ja", "言語");
1578: }
1579:
1580:
1581:
1582:
1583:
1584: public static void mnbMakeMenu () {
1585:
1586:
1587: ActionListener listener = new ActionListener () {
1588: @Override public void actionPerformed (ActionEvent ae) {
1589: Object source = ae.getSource ();
1590: String command = ae.getActionCommand ();
1591: switch (command) {
1592:
1593:
1594: case "Quit":
1595: prgTini ();
1596: break;
1597:
1598:
1599: case "Full screen":
1600: pnlSetFullscreenOn (true);
1601: break;
1602: case "Fit in window":
1603: if (pnlFullscreenOn) {
1604: pnlPrevFitInWindowOn = true;
1605: pnlSetFullscreenOn (false);
1606: } else {
1607: pnlSetFitInWindowOn (true);
1608: }
1609: break;
1610: case "Fixed scale":
1611: if (pnlFullscreenOn) {
1612: pnlPrevFitInWindowOn = false;
1613: pnlSetFullscreenOn (false);
1614: } else {
1615: pnlSetFitInWindowOn (false);
1616: }
1617: break;
1618: case "50%":
1619: case "75%":
1620: case "100%":
1621: case "150%":
1622: case "200%":
1623: pnlFixedModel.setValue (Integer.valueOf (Integer.parseInt (command.substring (0, command.length () - 1))));
1624: break;
1625: case "Nearest neighbor":
1626: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
1627: pnlPanel.repaint ();
1628: break;
1629: case "Bilinear":
1630: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
1631: pnlPanel.repaint ();
1632: break;
1633: case "Bicubic":
1634: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
1635: pnlPanel.repaint ();
1636: break;
1637:
1638: case "Draw all changed pictures":
1639: if (CRTC.CRT_ENABLE_INTERMITTENT) {
1640: CRTC.crtIntermittentInterval = 0;
1641: }
1642: break;
1643: case "Draw a changed picture once every two times":
1644: if (CRTC.CRT_ENABLE_INTERMITTENT) {
1645: CRTC.crtIntermittentInterval = 1;
1646: }
1647: break;
1648: case "Draw a changed picture once every three times":
1649: if (CRTC.CRT_ENABLE_INTERMITTENT) {
1650: CRTC.crtIntermittentInterval = 2;
1651: }
1652: break;
1653: case "Draw a changed picture once every four times":
1654: if (CRTC.CRT_ENABLE_INTERMITTENT) {
1655: CRTC.crtIntermittentInterval = 3;
1656: }
1657: break;
1658: case "Draw a changed picture once every five times":
1659: if (CRTC.CRT_ENABLE_INTERMITTENT) {
1660: CRTC.crtIntermittentInterval = 4;
1661: }
1662: break;
1663:
1664: case "Stereoscopic viewing":
1665: pnlSetStereoscopic (((JCheckBoxMenuItem) source).isSelected (), pnlStereoscopicMethod);
1666: break;
1667: case "Naked-eye crossing":
1668: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_CROSSING);
1669: break;
1670: case "Naked-eye parallel":
1671: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_PARALLEL);
1672: break;
1673: case "Side-by-side":
1674: pnlSetStereoscopic (pnlStereoscopicOn, PNL_SIDE_BY_SIDE);
1675: break;
1676: case "Top-and-bottom":
1677: pnlSetStereoscopic (pnlStereoscopicOn, PNL_TOP_AND_BOTTOM);
1678: break;
1679:
1680: case "Sprite pattern viewer":
1681: if (SpritePatternViewer.SPV_ON) {
1682: SpritePatternViewer.spvOpen ();
1683: }
1684: break;
1685: case "Screen mode test":
1686: if (ScreenModeTest.SMT_ON) {
1687: ScreenModeTest.smtOpen ();
1688: }
1689: break;
1690:
1691:
1692: case "Play":
1693: SoundSource.sndSetPlayOn (((JCheckBoxMenuItem) source).isSelected ());
1694: break;
1695: case "OPM output":
1696: OPM.opmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
1697: break;
1698: case "OPM log":
1699: OPMLog.olgOpen ();
1700: break;
1701:
1702: case "PCM output":
1703: ADPCM.pcmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
1704: break;
1705: case "Sound thinning":
1706: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.THINNING_MONO : SoundSource.SNDRateConverter.THINNING_STEREO;
1707: break;
1708: case "Sound linear interpolation":
1709: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.LINEAR_MONO : SoundSource.SNDRateConverter.LINEAR_STEREO;
1710: break;
1711: case "Sound piecewise-constant area interpolation":
1712: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000;
1713: break;
1714: case "Sound linear area interpolation":
1715: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000;
1716: break;
1717: case "Sound monitor":
1718: SoundMonitor.smnOpen ();
1719: break;
1720: case "PCM piecewise-constant interpolation":
1721: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_CONSTANT);
1722: break;
1723: case "PCM linear interpolation":
1724: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_LINEAR);
1725: break;
1726: case "PCM hermite interpolation":
1727: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_HERMITE);
1728: break;
1729: case "PCM 8MHz/4MHz":
1730: ADPCM.pcmOSCFreqRequest = 0;
1731: break;
1732: case "PCM 8MHz/16MHz":
1733: ADPCM.pcmOSCFreqRequest = 1;
1734: break;
1735:
1736:
1737: case "Paste":
1738: CONDevice.conDoPaste ();
1739: break;
1740: case "No keyboard":
1741: Keyboard.kbdSetOn (false);
1742: break;
1743: case "Standard keyboard":
1744: Keyboard.kbdSetType (Keyboard.KBD_STANDARD_TYPE);
1745: Keyboard.kbdSetOn (true);
1746: break;
1747: case "Compact keyboard":
1748: Keyboard.kbdSetType (Keyboard.KBD_COMPACT_TYPE);
1749: Keyboard.kbdSetOn (true);
1750: break;
1751: case "Key assignments":
1752: Keyboard.kbdOpen ();
1753: break;
1754: case "Joystick port settings":
1755: PPI.ppiOpen ();
1756: break;
1757:
1758:
1759: case "RS-232C and terminal":
1760: RS232CTerminal.trmOpen ();
1761: break;
1762:
1763: case "Console":
1764: DebugConsole.dgtOpen ();
1765: break;
1766: case "Register list":
1767: RegisterList.drpOpen ();
1768: break;
1769: case "Disassemble list":
1770: DisassembleList.ddpOpen (-1, -1, true);
1771: break;
1772: case "Memory dump list":
1773: MemoryDumpList.dmpOpen (-1, -1, true);
1774: break;
1775: case "Logical space monitor":
1776: LogicalSpaceMonitor.atwOpen ();
1777: break;
1778: case "Physical space monitor":
1779: PhysicalSpaceMonitor.paaOpen ();
1780: break;
1781: case "Address translation caches monitor":
1782: if (ATCMonitor.ACM_ON) {
1783: ATCMonitor.acmOpen ();
1784: }
1785: break;
1786: case "Branch log":
1787: if (BranchLog.BLG_ON) {
1788: BranchLog.blgOpen (BranchLog.BLG_SELECT_NONE);
1789: }
1790: break;
1791: case "Program flow visualizer":
1792: if (ProgramFlowVisualizer.PFV_ON) {
1793: ProgramFlowVisualizer.pfvOpen ();
1794: }
1795: break;
1796: case "Raster break point":
1797: if (RasterBreakPoint.RBP_ON) {
1798: RasterBreakPoint.rbpOpen ();
1799: }
1800: break;
1801: case "Data break point":
1802: if (DataBreakPoint.DBP_ON) {
1803: DataBreakPoint.dbpOpen ();
1804: }
1805: break;
1806: case "Root pointer list":
1807: if (RootPointerList.RTL_ON) {
1808: RootPointerList.rtlOpen ();
1809: }
1810: break;
1811:
1812:
1813: case "Adjust clock to host":
1814: RP5C15.rtcSetByHost ();
1815: break;
1816:
1817:
1818:
1819: case "Printer":
1820: PrinterPort.prnOpen ();
1821: break;
1822:
1823: case "Mouse button status":
1824: Mouse.musOutputButtonStatus = ((JCheckBoxMenuItem) source).isSelected ();
1825: break;
1826:
1827: case "Java runtime environment information":
1828: prgOpenJavaDialog ();
1829: break;
1830: case "Version information":
1831: prgOpenAboutDialog ();
1832: break;
1833: case "XEiJ License":
1834: prgOpenXEiJLicenseDialog ();
1835: break;
1836: case "FSHARP License":
1837: prgOpenSHARPLicenseDialog ();
1838: break;
1839: case "ymfm License":
1840: prgOpenYmfmLicenseDialog ();
1841: break;
1842: case "jSerialComm License":
1843: prgOpenJSerialCommLicenseDialog ();
1844: break;
1845:
1846: default:
1847: System.out.println ("unknown action command " + command);
1848:
1849: }
1850: }
1851: };
1852:
1853:
1854: ActionListener mainMemoryListener = new ActionListener () {
1855: @Override public void actionPerformed (ActionEvent ae) {
1856: Object source = ae.getSource ();
1857: String command = ae.getActionCommand ();
1858: switch (command) {
1859: case "1MB":
1860: MainMemory.mmrMemorySizeRequest = 0x00100000;
1861: break;
1862: case "2MB":
1863: MainMemory.mmrMemorySizeRequest = 0x00200000;
1864: break;
1865: case "4MB":
1866: MainMemory.mmrMemorySizeRequest = 0x00400000;
1867: break;
1868: case "6MB":
1869: MainMemory.mmrMemorySizeRequest = 0x00600000;
1870: break;
1871: case "8MB":
1872: MainMemory.mmrMemorySizeRequest = 0x00800000;
1873: break;
1874: case "10MB":
1875: MainMemory.mmrMemorySizeRequest = 0x00a00000;
1876: break;
1877: case "12MB":
1878: MainMemory.mmrMemorySizeRequest = 0x00c00000;
1879: break;
1880: case "Save contents on exit":
1881: MainMemory.mmrMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
1882: break;
1883: }
1884: }
1885: };
1886: ButtonGroup mainMemoryGroup = new ButtonGroup ();
1887: JMenu mainMemoryMenu = Multilingual.mlnText (
1888: ComponentFactory.createMenu (
1889: "Main memory",
1890: Multilingual.mlnText (
1891: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00100000, "1MB", mainMemoryListener),
1892: "ja", "1MB"),
1893: Multilingual.mlnText (
1894: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00200000, "2MB", mainMemoryListener),
1895: "ja", "2MB"),
1896: Multilingual.mlnText (
1897: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00400000, "4MB", mainMemoryListener),
1898: "ja", "4MB"),
1899: Multilingual.mlnText (
1900: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00600000, "6MB", mainMemoryListener),
1901: "ja", "6MB"),
1902: Multilingual.mlnText (
1903: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00800000, "8MB", mainMemoryListener),
1904: "ja", "8MB"),
1905: Multilingual.mlnText (
1906: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00a00000, "10MB", mainMemoryListener),
1907: "ja", "10MB"),
1908: Multilingual.mlnText (
1909: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00c00000, "12MB", mainMemoryListener),
1910: "ja", "12MB"),
1911: ComponentFactory.createHorizontalSeparator (),
1912: Multilingual.mlnText (
1913: ComponentFactory.createCheckBoxMenuItem (MainMemory.mmrMemorySaveOn, "Save contents on exit", mainMemoryListener),
1914: "ja", "終了時に内容を保存する"),
1915: SRAM.smrModifyMemorySizeMenuItem
1916: ),
1917: "ja", "メインメモリ");
1918:
1919:
1920: ActionListener highMemoryListener = new ActionListener () {
1921: @Override public void actionPerformed (ActionEvent ae) {
1922: Object source = ae.getSource ();
1923: String command = ae.getActionCommand ();
1924: switch (command) {
1925: case "None":
1926: busHighMemorySize = 0 << 20;
1927: break;
1928: case "16MB":
1929: busHighMemorySize = 16 << 20;
1930: break;
1931: case "Save contents on exit":
1932: busHighMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
1933: break;
1934: case "Use high memory on 060turbo":
1935: busHighMemory060turboOn = ((JCheckBoxMenuItem) source).isSelected ();
1936: }
1937: }
1938: };
1939: ButtonGroup highMemoryGroup = new ButtonGroup ();
1940: JMenu highMemoryMenu = Multilingual.mlnText (
1941: ComponentFactory.createMenu (
1942: "High memory on X68030/Xellent30",
1943: Multilingual.mlnText (
1944: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 0 << 20, "None", highMemoryListener),
1945: "ja", "なし"),
1946: Multilingual.mlnText (
1947: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 16 << 20, "16MB", highMemoryListener),
1948: "ja", "16MB"),
1949: ComponentFactory.createHorizontalSeparator (),
1950: Multilingual.mlnText (
1951: ComponentFactory.createCheckBoxMenuItem (busHighMemorySaveOn, "Save contents on exit", highMemoryListener),
1952: "ja", "終了時に内容を保存する"),
1953: ComponentFactory.createHorizontalSeparator (),
1954: Multilingual.mlnText (
1955: ComponentFactory.createCheckBoxMenuItem (busHighMemory060turboOn, "Use high memory on 060turbo", highMemoryListener),
1956: "ja", "060turbo のハイメモリを使う")
1957: ),
1958: "ja", "X68030/Xellent30 のハイメモリ");
1959:
1960:
1961: ActionListener localMemoryListener = new ActionListener () {
1962: @Override public void actionPerformed (ActionEvent ae) {
1963: Object source = ae.getSource ();
1964: String command = ae.getActionCommand ();
1965: switch (command) {
1966: case "None":
1967: busLocalMemorySize = 0 << 20;
1968: break;
1969: case "16MB":
1970: busLocalMemorySize = 16 << 20;
1971: break;
1972: case "32MB":
1973: busLocalMemorySize = 32 << 20;
1974: break;
1975: case "64MB":
1976: busLocalMemorySize = 64 << 20;
1977: break;
1978: case "128MB":
1979: busLocalMemorySize = 128 << 20;
1980: break;
1981: case "256MB":
1982: busLocalMemorySize = 256 << 20;
1983: break;
1984: case "384MB":
1985: busLocalMemorySize = 384 << 20;
1986: break;
1987: case "512MB":
1988: busLocalMemorySize = 512 << 20;
1989: break;
1990: case "768MB":
1991: busLocalMemorySize = 768 << 20;
1992: break;
1993: case "Save contents on exit":
1994: busLocalMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
1995: break;
1996: }
1997: }
1998: };
1999: ButtonGroup localMenoryGroup = new ButtonGroup ();
2000: JMenu localMemoryMenu = Multilingual.mlnText (
2001: ComponentFactory.createMenu (
2002: "High memory on 060turbo",
2003: Multilingual.mlnText (
2004: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 0 << 20, "None", localMemoryListener),
2005: "ja", "なし"),
2006: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 16 << 20, "16MB", localMemoryListener),
2007: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 32 << 20, "32MB", localMemoryListener),
2008: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 64 << 20, "64MB", localMemoryListener),
2009: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 128 << 20, "128MB", localMemoryListener),
2010: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 256 << 20, "256MB", localMemoryListener),
2011: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 384 << 20, "384MB", localMemoryListener),
2012: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 512 << 20, "512MB", localMemoryListener),
2013: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 768 << 20, "768MB", localMemoryListener),
2014: ComponentFactory.createHorizontalSeparator (),
2015: Multilingual.mlnText (
2016: ComponentFactory.createCheckBoxMenuItem (busLocalMemorySaveOn, "Save contents on exit", localMemoryListener),
2017: "ja", "終了時に内容を保存する")
2018: ),
2019: "ja", "060turbo のハイメモリ");
2020:
2021:
2022: ActionListener xellent30Listener = new ActionListener () {
2023: @Override public void actionPerformed (ActionEvent ae) {
2024: Object source = ae.getSource ();
2025: String command = ae.getActionCommand ();
2026: switch (command) {
2027: case "$00EC0000-$00EC3FFF":
2028: xt3DIPSW = 0;
2029: break;
2030: case "$00EC4000-$00EC7FFF":
2031: xt3DIPSW = 1;
2032: break;
2033: case "$00EC8000-$00ECBFFF":
2034: xt3DIPSW = 2;
2035: break;
2036: case "$00ECC000-$00ECFFFF":
2037: xt3DIPSW = 3;
2038: break;
2039: case "256KB":
2040: xt3MemorySizeRequest = 1 << 18;
2041: break;
2042: case "1MB":
2043: xt3MemorySizeRequest = 1 << 20;
2044: break;
2045: case "Save contents on exit":
2046: xt3MemorySave = ((JCheckBoxMenuItem) source).isSelected ();
2047: break;
2048: }
2049: }
2050: };
2051: ButtonGroup xellent30PortGroup = new ButtonGroup ();
2052: ButtonGroup xellent30SizeGroup = new ButtonGroup ();
2053: JMenu xellent30Menu = ComponentFactory.createMenu (
2054: "Xellent30",
2055: ComponentFactory.createRadioButtonMenuItem (
2056: xellent30PortGroup,
2057: xt3DIPSW == 0,
2058: "$00EC0000-$00EC3FFF",
2059: xellent30Listener),
2060: ComponentFactory.createRadioButtonMenuItem (
2061: xellent30PortGroup,
2062: xt3DIPSW == 1,
2063: "$00EC4000-$00EC7FFF",
2064: xellent30Listener),
2065: ComponentFactory.createRadioButtonMenuItem (
2066: xellent30PortGroup,
2067: xt3DIPSW == 2,
2068: "$00EC8000-$00ECBFFF",
2069: xellent30Listener),
2070: ComponentFactory.createRadioButtonMenuItem (
2071: xellent30PortGroup,
2072: xt3DIPSW == 3,
2073: "$00ECC000-$00ECFFFF",
2074: xellent30Listener),
2075: ComponentFactory.createHorizontalSeparator (),
2076: ComponentFactory.createRadioButtonMenuItem (
2077: xellent30SizeGroup,
2078: xt3MemorySizeRequest == 1 << 18,
2079: "256KB",
2080: xellent30Listener),
2081: ComponentFactory.createRadioButtonMenuItem (
2082: xellent30SizeGroup,
2083: xt3MemorySizeRequest == 1 << 20,
2084: "1MB",
2085: xellent30Listener),
2086: ComponentFactory.createHorizontalSeparator (),
2087: Multilingual.mlnText (
2088: ComponentFactory.createCheckBoxMenuItem (xt3MemorySave, "Save contents on exit", xellent30Listener),
2089: "ja", "終了時に内容を保存する")
2090: );
2091:
2092:
2093: ActionListener aspectListener = new ActionListener () {
2094: @Override public void actionPerformed (ActionEvent ae) {
2095: String command = ae.getActionCommand ();
2096: int i = command.indexOf (',');
2097: int key = Integer.parseInt (command.substring (0, i));
2098: int value = Integer.parseInt (command.substring (i + 1));
2099: pnlAspectMap[key] = value;
2100: pnlUpdateAspectTable ();
2101: pnlUpdateArrangement ();
2102: }
2103: };
2104: JMenu aspectMenu = ComponentFactory.createMenu ("Aspect ratio");
2105: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
2106: if (key != 0) {
2107: aspectMenu.add (ComponentFactory.createHorizontalSeparator ());
2108: }
2109: ButtonGroup group = new ButtonGroup ();
2110: for (int value = 0; value < PNL_ASPECT_VALUES; value++) {
2111: aspectMenu.add (
2112: ComponentFactory.setText (
2113: ComponentFactory.createRadioButtonMenuItem (
2114: group,
2115: pnlAspectMap[key] == value,
2116: key + "," + value,
2117: aspectListener
2118: ),
2119: (PNL_ASPECT_MATRIX[key] == PNL_ASPECT_SCREEN_RATIO ?
2120: String.format ("%s %s (%.3f)",
2121: PNL_ASPECT_RESOLUTION_NAME[key],
2122: PNL_ASPECT_SCREEN_NAME[value],
2123: PNL_ASPECT_SCREEN_RATIO[value]) :
2124: String.format ("%s %s (%.3f) @ %s (%.3f)",
2125: PNL_ASPECT_RESOLUTION_NAME[key],
2126: PNL_ASPECT_SCREEN_NAME[value],
2127: PNL_ASPECT_SCREEN_RATIO[value],
2128: PNL_ASPECT_PIXEL_NAME[value],
2129: PNL_ASPECT_PIXEL_RATIO[value]))
2130: )
2131: );
2132: }
2133: }
2134: aspectMenu = Multilingual.mlnText (aspectMenu, "ja", "アスペクト比");
2135:
2136:
2137: ActionListener scanlineListener = new ActionListener () {
2138: @Override public void actionPerformed (ActionEvent ae) {
2139:
2140: String command = ae.getActionCommand ();
2141: switch (command) {
2142: case "Off":
2143: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.OFF;
2144: CRTC.crtAllStamp += 2;
2145: break;
2146: case "Weak":
2147: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.WEAK;
2148: CRTC.crtAllStamp += 2;
2149: break;
2150: case "Medium":
2151: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.MEDIUM;
2152: CRTC.crtAllStamp += 2;
2153: break;
2154: case "Strong":
2155: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.STRONG;
2156: CRTC.crtAllStamp += 2;
2157: break;
2158: case "Black":
2159: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.BLACK;
2160: CRTC.crtAllStamp += 2;
2161: break;
2162: }
2163: }
2164: };
2165: ButtonGroup scanlineGroup = new ButtonGroup ();
2166: JMenu scanlineMenu =
2167: Multilingual.mlnText (
2168: ComponentFactory.createMenu (
2169: "Scanline effect",
2170: Multilingual.mlnText (
2171: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.OFF, "Off", scanlineListener),
2172: "ja", "なし"),
2173: Multilingual.mlnText (
2174: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.WEAK, "Weak", scanlineListener),
2175: "ja", "弱"),
2176: Multilingual.mlnText (
2177: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.MEDIUM, "Medium", scanlineListener),
2178: "ja", "中"),
2179: Multilingual.mlnText (
2180: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.STRONG, "Strong", scanlineListener),
2181: "ja", "強"),
2182: Multilingual.mlnText (
2183: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.BLACK, "Black", scanlineListener),
2184: "ja", "黒")
2185: ),
2186: "ja", "走査線エフェクト");
2187:
2188: ButtonGroup unitGroup = new ButtonGroup ();
2189: ButtonGroup frameGroup = new ButtonGroup ();
2190: ButtonGroup fullGroup = new ButtonGroup ();
2191: ButtonGroup hintGroup = new ButtonGroup ();
2192: ButtonGroup vgaGroup = new ButtonGroup ();
2193: ButtonGroup intermittentGroup = new ButtonGroup ();
2194: ButtonGroup sterescopicGroup = new ButtonGroup ();
2195: ButtonGroup soundInterpolationGroup = new ButtonGroup ();
2196: ButtonGroup adpcmInterpolationGroup = new ButtonGroup ();
2197: ButtonGroup adpcmOSCFreqGroup = new ButtonGroup ();
2198: ButtonGroup keyboardGroup = new ButtonGroup ();
2199:
2200:
2201: DecimalSpinner[] freqSpinner = new DecimalSpinner[3];
2202: ChangeListener freqListener = new ChangeListener () {
2203: @Override public void stateChanged (ChangeEvent ce) {
2204: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
2205: int i = spinner.getOption ();
2206: CRTC.crtFreqsRequest[i] = spinner.getIntValue ();
2207: }
2208: };
2209: for (int i = 0; i < 3; i++) {
2210: freqSpinner[i] = ComponentFactory.createDecimalSpinner (
2211: CRTC.crtFreqsRequest[i], CRTC.CRT_MIN_FREQ, CRTC.CRT_MAX_FREQ, 1000000, i, freqListener
2212: );
2213: }
2214: DecimalSpinner sprrasSpinner = ComponentFactory.createDecimalSpinner (
2215: SpriteScreen.sprSpritesPerRaster, 0, 256, 1, 0,
2216: new ChangeListener () {
2217: @Override public void stateChanged (ChangeEvent ce) {
2218: SpriteScreen.sprSpritesPerRaster = ((DecimalSpinner) ce.getSource ()).getIntValue ();
2219: }
2220: });
2221: ActionListener modificationListener = new ActionListener () {
2222: @Override public void actionPerformed (ActionEvent ae) {
2223: Object source = ae.getSource ();
2224: String command = ae.getActionCommand ();
2225: switch (command) {
2226: case "Extended graphic screen":
2227: CRTC.crtExtendedGraphicRequest = ((JCheckBoxMenuItem) source).isSelected ();
2228: break;
2229: case "1024-dot non-interlaced":
2230: CRTC.crtEleventhBitRequest = ((JCheckBoxMenuItem) source).isSelected ();
2231: break;
2232: case "Spherical scrolling of text screen":
2233: CRTC.crtSetSphericalScrolling (((JCheckBoxMenuItem) source).isSelected ());
2234: break;
2235: case "* Reset to default values":
2236: for (int i = 0; i < 3; i++) {
2237: if (CRTC.crtFreqsRequest[i] != CRTC.CRT_DEFAULT_FREQS[i]) {
2238: CRTC.crtFreqsRequest[i] = CRTC.CRT_DEFAULT_FREQS[i];
2239: freqSpinner[i].setIntValue (CRTC.crtFreqsRequest[i]);
2240: }
2241: }
2242: break;
2243: case "256 sprites":
2244: SpriteScreen.sprDoubleSpritesRequest = ((JCheckBoxMenuItem) source).isSelected ();
2245: break;
2246: case "** Reset to default values":
2247: if (SpriteScreen.sprSpritesPerRaster != 32) {
2248: SpriteScreen.sprSpritesPerRaster = 32;
2249: sprrasSpinner.setIntValue (SpriteScreen.sprSpritesPerRaster);
2250: }
2251: break;
2252: case "Can write 0 to bit 0 of CRTC R00":
2253: CRTC.crtR00Bit0Zero = ((JCheckBoxMenuItem) source).isSelected ();
2254: break;
2255: }
2256: }
2257: };
2258: JMenu modificationMenu =
2259: Multilingual.mlnText (
2260: ComponentFactory.createMenu (
2261: "Modification",
2262: !CRTC.CRT_EXTENDED_GRAPHIC ? null : Multilingual.mlnText (
2263: ComponentFactory.createCheckBoxMenuItem (CRTC.crtExtendedGraphicRequest, "Extended graphic screen", modificationListener),
2264: "ja", "拡張グラフィック画面"),
2265: Multilingual.mlnText (
2266: ComponentFactory.createCheckBoxMenuItem (CRTC.crtEleventhBitRequest, "1024-dot non-interlaced", modificationListener),
2267: "ja", "1024 ドットノンインターレース"),
2268: Multilingual.mlnText (
2269: ComponentFactory.createCheckBoxMenuItem (CRTC.crtSphericalScrolling, "Spherical scrolling of text screen", modificationListener),
2270: "ja", "テキスト画面の球面スクロール"),
2271: ComponentFactory.createHorizontalSeparator (),
2272: ComponentFactory.createHorizontalBox (
2273: Box.createHorizontalStrut (20),
2274: Multilingual.mlnText (ComponentFactory.createLabel ("Dot clock oscillattor"), "ja", "ドットクロックオシレータ"),
2275: Box.createHorizontalGlue ()
2276: ),
2277: ComponentFactory.createHorizontalBox (
2278: Box.createHorizontalStrut (20),
2279: freqSpinner[0],
2280: ComponentFactory.createLabel (" Hz *"),
2281: Box.createHorizontalGlue ()
2282: ),
2283: ComponentFactory.createHorizontalBox (
2284: Box.createHorizontalStrut (20),
2285: freqSpinner[1],
2286: ComponentFactory.createLabel (" Hz *"),
2287: Box.createHorizontalGlue ()
2288: ),
2289: ComponentFactory.createHorizontalBox (
2290: Box.createHorizontalStrut (20),
2291: freqSpinner[2],
2292: ComponentFactory.createLabel (" Hz *"),
2293: Box.createHorizontalGlue ()
2294: ),
2295: Multilingual.mlnText (
2296: ComponentFactory.createMenuItem ("* Reset to default values", modificationListener),
2297: "ja", "* 初期値に戻す"),
2298: ComponentFactory.createHorizontalSeparator (),
2299: Multilingual.mlnText (
2300: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprDoubleSpritesRequest, "256 sprites", modificationListener),
2301: "ja", "スプライト 256 枚"),
2302: ComponentFactory.createHorizontalSeparator (),
2303: ComponentFactory.createHorizontalBox (
2304: Box.createHorizontalStrut (20),
2305: Multilingual.mlnText (ComponentFactory.createLabel ("Number of sprites per raster"), "ja", "ラスタあたりのスプライトの枚数")
2306: ),
2307: ComponentFactory.createHorizontalBox (
2308: Box.createHorizontalStrut (20),
2309: sprrasSpinner,
2310: ComponentFactory.createLabel (" **"),
2311: Box.createHorizontalGlue ()
2312: ),
2313: Multilingual.mlnText (
2314: ComponentFactory.createMenuItem ("** Reset to default values", modificationListener),
2315: "ja", "** 初期値に戻す"),
2316: ComponentFactory.createHorizontalSeparator (),
2317: Multilingual.mlnText (
2318: ComponentFactory.createCheckBoxMenuItem (CRTC.crtR00Bit0Zero, "Can write 0 to bit 0 of CRTC R00", modificationListener),
2319: "ja", "CRTC R00 のビット 0 に 0 を書き込める")
2320: ),
2321: "ja", "改造");
2322:
2323:
2324: mnbMenuBar = ComponentFactory.createMenuBar (
2325:
2326:
2327: mnbFileMenu = Multilingual.mlnText (
2328: ComponentFactory.createMenu (
2329: "File", 'F',
2330:
2331: FDC.fdcMenu,
2332:
2333: HDC.hdcMenu,
2334:
2335: SPC.spcMenu,
2336:
2337: HFS.hfsMenu,
2338: ComponentFactory.createHorizontalSeparator (),
2339: mnbQuitMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Quit", 'Q', MNB_MODIFIERS, listener), "ja", "終了")
2340: ),
2341: "ja", "ファイル"),
2342:
2343:
2344: mpuMenu,
2345:
2346:
2347: mnbDisplayMenu = Multilingual.mlnText (
2348: ComponentFactory.createMenu (
2349: "Display", 'D',
2350: mnbFullscreenMenuItem = ComponentFactory.setEnabled (
2351: Multilingual.mlnText (
2352: ComponentFactory.createRadioButtonMenuItem (
2353: fullGroup, pnlFullscreenOn,
2354: "Full screen", KeyEvent.VK_F11, listener), "ja", "全画面表示"),
2355: pnlIsFullscreenSupported),
2356: mnbFitInWindowMenuItem = ComponentFactory.setEnabled (
2357: Multilingual.mlnText (
2358: ComponentFactory.createRadioButtonMenuItem (
2359: fullGroup, !pnlFullscreenOn && pnlFitInWindowOn,
2360: "Fit in window", 'W', MNB_MODIFIERS, listener), "ja", "ウインドウに合わせる"),
2361: pnlIsFitInWindowSupported),
2362: mnbFixedScaleMenuItem = Multilingual.mlnText (
2363: ComponentFactory.createRadioButtonMenuItem (
2364: fullGroup, !pnlFullscreenOn && !pnlFitInWindowOn,
2365: "Fixed scale", 'X', MNB_MODIFIERS, listener), "ja", "固定倍率"),
2366: ComponentFactory.createHorizontalBox (
2367: Box.createHorizontalStrut (20),
2368: pnlFixedSpinner,
2369: ComponentFactory.createLabel ("%"),
2370: Box.createHorizontalGlue ()
2371: ),
2372: ComponentFactory.createMenuItem ("50%", listener),
2373: ComponentFactory.createMenuItem ("75%", listener),
2374: ComponentFactory.createMenuItem ("100%", listener),
2375: ComponentFactory.createMenuItem ("150%", listener),
2376: ComponentFactory.createMenuItem ("200%", listener),
2377:
2378: aspectMenu,
2379:
2380: Multilingual.mlnText (
2381: ComponentFactory.createMenu (
2382: "Interpolation algorithm",
2383: Multilingual.mlnText (
2384: ComponentFactory.createRadioButtonMenuItem (
2385: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
2386: "Nearest neighbor", listener),
2387: "ja", "最近傍補間"),
2388: Multilingual.mlnText (
2389: ComponentFactory.createRadioButtonMenuItem (
2390: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR,
2391: "Bilinear", listener),
2392: "ja", "線形補間"),
2393: Multilingual.mlnText (
2394: ComponentFactory.createRadioButtonMenuItem (
2395: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC,
2396: "Bicubic", listener),
2397: "ja", "三次補間")
2398: ),
2399: "ja", "補間アルゴリズム"),
2400:
2401: scanlineMenu,
2402:
2403: !CRTC.CRT_ENABLE_INTERMITTENT ? null : Multilingual.mlnText (
2404: ComponentFactory.createMenu (
2405: "Intermittent drawing",
2406: Multilingual.mlnText (
2407: ComponentFactory.createRadioButtonMenuItem (
2408: intermittentGroup, CRTC.crtIntermittentInterval == 0, "Draw all changed pictures", listener),
2409: "ja", "変化した画像をすべて描画する"),
2410: Multilingual.mlnText (
2411: ComponentFactory.createRadioButtonMenuItem (
2412: intermittentGroup, CRTC.crtIntermittentInterval == 1, "Draw a changed picture once every two times", listener),
2413: "ja", "変化した画像を 2 回に 1 回描画する"),
2414: Multilingual.mlnText (
2415: ComponentFactory.createRadioButtonMenuItem (
2416: intermittentGroup, CRTC.crtIntermittentInterval == 2, "Draw a changed picture once every three times", listener),
2417: "ja", "変化した画像を 3 回に 1 回描画する"),
2418: Multilingual.mlnText (
2419: ComponentFactory.createRadioButtonMenuItem (
2420: intermittentGroup, CRTC.crtIntermittentInterval == 3, "Draw a changed picture once every four times", listener),
2421: "ja", "変化した画像を 4 回に 1 回描画する"),
2422: Multilingual.mlnText (
2423: ComponentFactory.createRadioButtonMenuItem (
2424: intermittentGroup, CRTC.crtIntermittentInterval == 4, "Draw a changed picture once every five times", listener),
2425: "ja", "変化した画像を 5 回に 1 回描画する")
2426: ),
2427: "ja", "間欠描画"),
2428:
2429: !PNL_STEREOSCOPIC_ON ? null : ComponentFactory.createHorizontalSeparator (),
2430: mnbStereoscopicMenuItem = !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
2431: ComponentFactory.createCheckBoxMenuItem (pnlStereoscopicOn, "Stereoscopic viewing", 'T', listener),
2432: "ja", "立体視"),
2433: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
2434: ComponentFactory.createMenu (
2435: "Stereoscopic settings",
2436: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
2437: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
2438: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING,
2439: "Naked-eye crossing", listener),
2440: "ja", "裸眼交差法"),
2441: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
2442: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
2443: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL,
2444: "Naked-eye parallel", listener),
2445: "ja", "裸眼平行法"),
2446: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
2447: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
2448: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE,
2449: "Side-by-side", listener),
2450: "ja", "サイドバイサイド"),
2451: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
2452: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
2453: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM,
2454: "Top-and-bottom", listener),
2455: "ja", "トップアンドボトム")
2456: ),
2457: "ja", "立体視設定"),
2458:
2459: ComponentFactory.createHorizontalSeparator (),
2460: GIFAnimation.gifStartRecordingMenuItem,
2461: GIFAnimation.gifSettingsMenu,
2462:
2463: ComponentFactory.createHorizontalSeparator (),
2464: modificationMenu,
2465:
2466: SpritePatternViewer.SPV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Sprite pattern viewer", listener), "ja", "スプライトパターンビュア") : null,
2467: ScreenModeTest.SMT_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Screen mode test", listener), "ja", "表示モードテスト") : null
2468: ),
2469: "ja", "画面"),
2470:
2471:
2472: mnbSoundMenu = ComponentFactory.setEnabled (
2473: Multilingual.mlnText (
2474: ComponentFactory.createMenu (
2475: "Sound", 'S',
2476: mnbPlayMenuItem = ComponentFactory.setEnabled (
2477: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (SoundSource.sndPlayOn, "Play", 'P', MNB_MODIFIERS, listener), "ja", "音声出力"),
2478: SoundSource.sndLine != null),
2479:
2480:
2481:
2482: ComponentFactory.createHorizontalBox (
2483: Box.createHorizontalGlue (),
2484: Multilingual.mlnText (ComponentFactory.createLabel ("Volume "), "ja", "音量 "),
2485: mnbVolumeLabel = ComponentFactory.createLabel (String.valueOf (SoundSource.sndVolume)),
2486: Box.createHorizontalGlue ()
2487: ),
2488:
2489:
2490: ComponentFactory.setPreferredSize (
2491: ComponentFactory.createHorizontalSlider (
2492: 0,
2493: SoundSource.SND_VOLUME_MAX,
2494: SoundSource.sndVolume,
2495: SoundSource.SND_VOLUME_STEP,
2496: 1,
2497: new ChangeListener () {
2498: @Override public void stateChanged (ChangeEvent ce) {
2499: SoundSource.sndSetVolume (((JSlider) ce.getSource ()).getValue ());
2500: }
2501: }),
2502: LnF.lnfFontSize * 18, LnF.lnfFontSize * 2 + 28),
2503: Multilingual.mlnText (
2504: ComponentFactory.createMenu (
2505: "Sound interpolation",
2506: Multilingual.mlnText (
2507: ComponentFactory.createRadioButtonMenuItem (
2508: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.THINNING_STEREO,
2509: "Sound thinning", listener),
2510: "ja", "音声 間引き"),
2511: Multilingual.mlnText (
2512: ComponentFactory.createRadioButtonMenuItem (
2513: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_STEREO,
2514: "Sound linear interpolation", listener),
2515: "ja", "音声 線形補間"),
2516: ComponentFactory.setEnabled (
2517: Multilingual.mlnText (
2518: ComponentFactory.createRadioButtonMenuItem (
2519: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000,
2520: "Sound piecewise-constant area interpolation", listener),
2521: "ja", "音声 区分定数面積補間"),
2522: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000),
2523: ComponentFactory.setEnabled (
2524: Multilingual.mlnText (
2525: ComponentFactory.createRadioButtonMenuItem (
2526: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000,
2527: "Sound linear area interpolation", listener),
2528: "ja", "音声 線形面積補間"),
2529: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000)
2530: ),
2531: "ja", "音声補間"),
2532: Multilingual.mlnText (ComponentFactory.createMenuItem ("Sound monitor", listener), "ja", "音声モニタ"),
2533:
2534: ComponentFactory.createHorizontalSeparator (),
2535:
2536: ComponentFactory.setEnabled (
2537: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (OPM.opmOutputMask != 0, "OPM output", listener), "ja", "OPM 出力"),
2538: SoundSource.sndLine != null),
2539: !OPMLog.OLG_ON ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("OPM log", listener), "ja", "OPM ログ"),
2540:
2541: ComponentFactory.createHorizontalSeparator (),
2542:
2543: ComponentFactory.setEnabled (
2544: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ADPCM.pcmOutputOn, "PCM output", listener), "ja", "PCM 出力"),
2545: SoundSource.sndLine != null),
2546: Multilingual.mlnText (
2547: ComponentFactory.createMenu (
2548: "PCM interpolation",
2549: Multilingual.mlnText (
2550: ComponentFactory.createRadioButtonMenuItem (
2551: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_CONSTANT,
2552: "PCM piecewise-constant interpolation", listener),
2553: "ja", "PCM 区分定数補間"),
2554: Multilingual.mlnText (
2555: ComponentFactory.createRadioButtonMenuItem (
2556: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_LINEAR,
2557: "PCM linear interpolation", listener),
2558: "ja", "PCM 線形補間"),
2559: Multilingual.mlnText (
2560: ComponentFactory.createRadioButtonMenuItem (
2561: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_HERMITE,
2562: "PCM hermite interpolation", listener),
2563: "ja", "PCM エルミート補間")
2564: ),
2565: "ja", "PCM 補間"),
2566: Multilingual.mlnText (
2567: ComponentFactory.createMenu (
2568: "PCM source oscillator frequency",
2569: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 0, "PCM 8MHz/4MHz", listener),
2570: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 1, "PCM 8MHz/16MHz", listener)
2571: ),
2572: "ja", "PCM 原発振周波数")
2573: ),
2574: "ja", "音声"),
2575: SoundSource.sndLine != null),
2576:
2577:
2578: mnbInputMenu = Multilingual.mlnText (
2579: ComponentFactory.createMenu (
2580: "Input", 'I',
2581: mnbPasteMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Paste", 'V', MNB_MODIFIERS, listener), "ja", "貼り付け"),
2582: CONDevice.conSettingsMenu,
2583: ComponentFactory.createHorizontalSeparator (),
2584: mnbNoKeyboardMenuItem = Multilingual.mlnText (
2585: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, !Keyboard.kbdOn, "No keyboard", 'K', MNB_MODIFIERS, listener),
2586: "ja", "キーボードなし"),
2587: mnbStandardKeyboardMenuItem = Multilingual.mlnText (
2588: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_STANDARD_TYPE, "Standard keyboard", listener),
2589: "ja", "標準キーボード"),
2590: mnbCompactKeyboardMenuItem = Multilingual.mlnText (
2591: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_COMPACT_TYPE, "Compact keyboard", listener),
2592: "ja", "コンパクトキーボード"),
2593: Multilingual.mlnText (ComponentFactory.createMenuItem ("Key assignments", listener), "ja", "キー割り当て"),
2594: Keyboard.kbdF11KeyMenu,
2595: SRAM.smrRepeatDelayMenu,
2596: SRAM.smrRepeatIntervalMenu,
2597: !Keyboard.KBD_ZKEY_ON ? null : Keyboard.kbdZKeyMenu,
2598: ComponentFactory.createHorizontalSeparator (),
2599: Mouse.musSeamlessMouseCheckBox,
2600: Mouse.musWheelMenu,
2601: Mouse.musCtrlRightCheckBox,
2602: Mouse.musEdgeAccelerationCheckBox,
2603: Mouse.musMouseCursorSpeedBox,
2604: Mouse.musSpeedSlider,
2605: Mouse.musHostsPixelUnitsCheckBox,
2606: ComponentFactory.createHorizontalSeparator (),
2607: Multilingual.mlnText (ComponentFactory.createMenuItem ("Joystick port settings", listener), "ja", "ジョイスティックポート設定")
2608: ),
2609: "ja", "入力"),
2610:
2611:
2612: mnbConfigMenu = Multilingual.mlnText (
2613: ComponentFactory.createMenu (
2614: "Config", 'C',
2615: Multilingual.mlnText (ComponentFactory.createMenuItem ("RS-232C and terminal", listener), "ja", "RS-232C とターミナル"),
2616: Multilingual.mlnText (
2617: ComponentFactory.createMenu (
2618: "Debug",
2619: Multilingual.mlnText (ComponentFactory.createMenuItem ("Console", listener), "ja", "コンソール"),
2620: Multilingual.mlnText (ComponentFactory.createMenuItem ("Register list", listener), "ja", "レジスタリスト"),
2621: Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble list", listener), "ja", "逆アセンブルリスト"),
2622: Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory dump list", listener), "ja", "メモリダンプリスト"),
2623: Multilingual.mlnText (ComponentFactory.createMenuItem ("Logical space monitor", listener), "ja", "論理空間モニタ"),
2624: Multilingual.mlnText (ComponentFactory.createMenuItem ("Physical space monitor", listener), "ja", "物理空間モニタ"),
2625: ATCMonitor.ACM_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Address translation caches monitor", listener), "ja", "アドレス変換キャッシュモニタ") : null,
2626: BranchLog.BLG_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Branch log", listener), "ja", "分岐ログ") : null,
2627: ProgramFlowVisualizer.PFV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Program flow visualizer", listener), "ja", "プログラムフロービジュアライザ") : null,
2628: RasterBreakPoint.RBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Raster break point", listener), "ja", "ラスタブレークポイント") : null,
2629: DataBreakPoint.DBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Data break point", listener), "ja", "データブレークポイント") : null,
2630: RootPointerList.RTL_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Root pointer list", listener), "ja", "ルートポインタリスト") : null,
2631: ComponentFactory.createHorizontalSeparator (),
2632: SRAM.smrROMDBMenuItem
2633: ),
2634: "ja", "デバッグ"),
2635: SRAM.smrBootMenu,
2636: mainMemoryMenu,
2637: highMemoryMenu,
2638: localMemoryMenu,
2639: xellent30Menu,
2640: ComponentFactory.createHorizontalSeparator (),
2641: ComponentFactory.createMenu (
2642: "RTC",
2643: Multilingual.mlnText (
2644: ComponentFactory.createMenuItem ("Adjust clock to host", listener),
2645: "ja", "時計をホストに合わせる")
2646: ),
2647: SRAM.smrMenu,
2648: Settings.sgsMenu,
2649: ComponentFactory.createHorizontalSeparator (),
2650: Multilingual.mlnText (ComponentFactory.createMenuItem ("Printer", listener), "ja", "プリンタ"),
2651: ROM.romMenu,
2652: Multilingual.mlnText (
2653: ComponentFactory.createMenu (
2654: "Miscellaneous",
2655: SlowdownTest.sdtCheckBoxMenuItem,
2656: SlowdownTest.sdtBox,
2657: Multilingual.mlnText (
2658: ComponentFactory.createCheckBoxMenuItem (Mouse.musOutputButtonStatus, "Mouse button status", listener),
2659: "ja", "マウスのボタンの状態"),
2660: Z8530.SCC_DEBUG_ON ? Z8530.sccDebugMenu : null
2661: ),
2662: "ja", "その他"),
2663: ComponentFactory.createHorizontalSeparator (),
2664: Multilingual.mlnText (
2665: ComponentFactory.createMenuItem ("Java runtime environment information", listener),
2666: "ja", "Java 実行環境の情報"),
2667: Multilingual.mlnText (
2668: ComponentFactory.createMenuItem ("Version information", listener),
2669: "ja", "バージョン情報"),
2670: Multilingual.mlnText (
2671: ComponentFactory.createMenu (
2672: "License",
2673: Multilingual.mlnText (ComponentFactory.createMenuItem ("XEiJ License", listener), "ja", "XEiJ 使用許諾条件"),
2674: Multilingual.mlnText (ComponentFactory.createMenuItem ("FSHARP License", listener), "ja", "FSHARP 許諾条件"),
2675: Multilingual.mlnText (ComponentFactory.createMenuItem ("ymfm License", listener), "ja", "ymfm License"),
2676: Multilingual.mlnText (ComponentFactory.createMenuItem ("jSerialComm License", listener), "ja", "jSerialComm License")
2677: ),
2678: "ja", "使用許諾条件")
2679: ),
2680: "ja", "設定"),
2681:
2682: mnbMakeLanguageMenu (),
2683:
2684:
2685: Box.createHorizontalGlue (),
2686: ComponentFactory.createVerticalBox (
2687: Box.createVerticalGlue (),
2688: Indicator.indBox,
2689: Box.createVerticalGlue ()
2690: ),
2691: Box.createHorizontalGlue ()
2692:
2693: );
2694: }
2695:
2696:
2697:
2698:
2699:
2700:
2701:
2702: public static boolean frmIsActive;
2703:
2704:
2705: public static JFrame frmFrame;
2706: public static int frmMarginWidth;
2707: public static int frmMarginHeight;
2708: public static Dimension frmMinimumSize;
2709:
2710:
2711: public static GraphicsDevice frmScreenDevice;
2712:
2713:
2714: public static DropTarget frmDropTarget;
2715:
2716:
2717:
2718: public static void frmInit () {
2719: frmIsActive = false;
2720: frmScreenDevice = GraphicsEnvironment.getLocalGraphicsEnvironment ().getDefaultScreenDevice ();
2721: pnlIsFullscreenSupported = frmScreenDevice.isFullScreenSupported ();
2722: pnlIsFitInWindowSupported = true;
2723: }
2724:
2725:
2726:
2727: public static void frmMake () {
2728:
2729:
2730: frmFrame = ComponentFactory.createRestorableFrame (
2731: Settings.SGS_FRM_FRAME_KEY,
2732: PRG_TITLE + " version " + PRG_VERSION,
2733: mnbMenuBar,
2734: pnlPanel);
2735: frmUpdateTitle ();
2736: frmFrame.setIconImage (LnF.LNF_ICON_IMAGE_16);
2737: frmFrame.setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);
2738:
2739:
2740:
2741: frmMarginWidth = frmFrame.getWidth () - pnlWidth;
2742: frmMarginHeight = frmFrame.getHeight () - pnlHeight;
2743: frmMinimumSize = new Dimension (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
2744: frmFrame.setMinimumSize (frmMinimumSize);
2745:
2746:
2747:
2748: frmDropTarget = new DropTarget (pnlPanel, DnDConstants.ACTION_COPY, new DropTargetAdapter () {
2749: @Override public void dragOver (DropTargetDragEvent dtde) {
2750: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
2751: dtde.acceptDrag (DnDConstants.ACTION_COPY);
2752: return;
2753: }
2754: dtde.rejectDrag ();
2755: }
2756: @Override public void drop (DropTargetDropEvent dtde) {
2757: try {
2758: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
2759: dtde.acceptDrop (DnDConstants.ACTION_COPY);
2760: boolean reset = false;
2761: int fdu0 = -1;
2762: int fdu = 0;
2763: int hdu0 = -1;
2764: int hdu = 0;
2765: int scu0 = -1;
2766: int scu = 0;
2767: int hfu0 = -1;
2768: int hfu = 0;
2769: for (Object o : (java.util.List) dtde.getTransferable ().getTransferData (DataFlavor.javaFileListFlavor)) {
2770: if (o instanceof File) {
2771: File file = (File) o;
2772: if (file.isFile ()) {
2773: if (FDC.fdcFileFilter.accept (file)) {
2774: if (fdu < FDC.FDC_MAX_UNITS &&
2775: FDC.fdcUnitArray[fdu].insert (file.getPath (), false)) {
2776: if (fdu0 < 0) {
2777: fdu0 = fdu;
2778: }
2779: fdu++;
2780: continue;
2781: }
2782: }
2783: if (HDC.hdcFileFilter.accept (file)) {
2784: if (hdu < 16 &&
2785: HDC.hdcUnitArray[hdu].insert (file.getPath (), false)) {
2786: if (hdu0 < 0) {
2787: hdu0 = hdu;
2788: }
2789: hdu++;
2790: continue;
2791: }
2792: }
2793: if (SPC.spcFileFilter.accept (file)) {
2794: if (scu < 16 &&
2795: SPC.spcUnitArray[scu].insert (file.getPath (), false)) {
2796: if (scu0 < 0) {
2797: scu0 = scu;
2798: }
2799: scu++;
2800: continue;
2801: }
2802: }
2803: }
2804: if (HFS.hfsFileFilter.accept (file)) {
2805: if (hfu < HFS.HFS_MAX_UNITS &&
2806: HFS.hfsUnitArray[hfu].insert (file.getPath (), false)) {
2807: if (hfu0 < 0) {
2808: hfu0 = hfu;
2809: }
2810: hfu++;
2811: continue;
2812: }
2813: }
2814: }
2815: reset = false;
2816: }
2817: dtde.dropComplete (true);
2818: if (reset) {
2819: if (fdu0 >= 0) {
2820: mpuReset (0x9070 | fdu0 << 8, -1);
2821: } else if (hdu0 >= 0) {
2822: mpuReset (0x8000 | hdu0 << 8, -1);
2823: } else if (scu0 >= 0) {
2824: mpuReset (0xa000, SPC.SPC_HANDLE_EX + (scu0 << 2));
2825: } else if (hfu0 >= 0) {
2826: HFS.hfsBootUnit = hfu0;
2827: mpuReset (0xa000, HFS.HFS_BOOT_HANDLE);
2828: }
2829: }
2830: return;
2831: }
2832: } catch (UnsupportedFlavorException ufe) {
2833:
2834: } catch (IOException ioe) {
2835:
2836: }
2837: dtde.rejectDrop();
2838: }
2839: });
2840:
2841: }
2842:
2843:
2844:
2845: public static void frmUpdateTitle () {
2846: frmFrame.setTitle ((currentAccelerator == ACCELERATOR_HYBRID ? "X68000 Hybrid" :
2847: currentModel.getName () +
2848: (currentAccelerator == ACCELERATOR_XELLENT30 ? " with Xellent30" :
2849: currentAccelerator == ACCELERATOR_060TURBO ? " with 060turbo" :
2850: currentAccelerator == ACCELERATOR_060TURBOPRO ? " with 060turboPRO" : "")) +
2851: " - " + PRG_TITLE + " version " + PRG_VERSION);
2852: }
2853:
2854:
2855:
2856: public static void frmStart () {
2857:
2858:
2859:
2860:
2861:
2862:
2863:
2864:
2865: ComponentFactory.addListener (
2866: frmFrame,
2867: new WindowAdapter () {
2868: @Override public void windowActivated (WindowEvent we) {
2869: frmIsActive = true;
2870: }
2871: @Override public void windowClosing (WindowEvent we) {
2872: prgTini ();
2873: }
2874: @Override public void windowDeactivated (WindowEvent we) {
2875: frmIsActive = false;
2876:
2877: }
2878: });
2879:
2880:
2881:
2882:
2883: ComponentFactory.addListener (
2884: frmFrame,
2885: new ComponentAdapter () {
2886: @Override public void componentMoved (ComponentEvent ce) {
2887: Point p = pnlPanel.getLocationOnScreen ();
2888: pnlGlobalX = p.x;
2889: pnlGlobalY = p.y;
2890: }
2891: @Override public void componentResized (ComponentEvent ce) {
2892: Point p = pnlPanel.getLocationOnScreen ();
2893: pnlGlobalX = p.x;
2894: pnlGlobalY = p.y;
2895: }
2896: });
2897:
2898: }
2899:
2900:
2901:
2902:
2903: public static void frmSetFullscreenOn (boolean on) {
2904: pnlFullscreenOn = on;
2905:
2906: if (on) {
2907: if (frmScreenDevice.getFullScreenWindow () != frmFrame) {
2908: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.NONE);
2909: frmScreenDevice.setFullScreenWindow (frmFrame);
2910: }
2911: } else {
2912: if (frmScreenDevice.getFullScreenWindow () == frmFrame) {
2913: frmScreenDevice.setFullScreenWindow (null);
2914: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.FRAME);
2915: }
2916: }
2917:
2918:
2919: }
2920:
2921:
2922:
2923:
2924:
2925:
2926: public static BufferedImage clpClipboardImage;
2927: public static String clpClipboardString;
2928: public static Clipboard clpClipboard;
2929: public static Transferable clpImageContents;
2930: public static Transferable clpStringContents;
2931: public static ClipboardOwner clpClipboardOwner;
2932: public static boolean clpIsClipboardOwner;
2933:
2934:
2935:
2936: public static void clpMake () {
2937: Toolkit toolkit = Toolkit.getDefaultToolkit ();
2938: clpClipboard = null;
2939: try {
2940: clpClipboard = toolkit.getSystemClipboard ();
2941: } catch (Exception e) {
2942: return;
2943: }
2944: clpClipboardImage = null;
2945: clpClipboardString = null;
2946: clpImageContents = new Transferable () {
2947: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
2948: if (flavor == DataFlavor.imageFlavor) {
2949: return clpClipboardImage;
2950: } else {
2951: throw new UnsupportedFlavorException (flavor);
2952: }
2953: }
2954: public DataFlavor[] getTransferDataFlavors () {
2955: return new DataFlavor[] { DataFlavor.imageFlavor };
2956: }
2957: public boolean isDataFlavorSupported (DataFlavor flavor) {
2958: return flavor == DataFlavor.imageFlavor;
2959: }
2960: };
2961: clpStringContents = new Transferable () {
2962: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
2963: if (flavor == DataFlavor.stringFlavor) {
2964: return clpClipboardString;
2965: } else {
2966: throw new UnsupportedFlavorException (flavor);
2967: }
2968: }
2969: public DataFlavor[] getTransferDataFlavors () {
2970: return new DataFlavor[] { DataFlavor.stringFlavor };
2971: }
2972: public boolean isDataFlavorSupported (DataFlavor flavor) {
2973: return flavor == DataFlavor.stringFlavor;
2974: }
2975: };
2976: clpIsClipboardOwner = false;
2977:
2978:
2979: clpClipboardOwner = new ClipboardOwner () {
2980: @Override public void lostOwnership (Clipboard clipboard, Transferable contents) {
2981: clpIsClipboardOwner = false;
2982: }
2983: };
2984:
2985:
2986: clpClipboard.addFlavorListener (new FlavorListener () {
2987: @Override public void flavorsChanged (FlavorEvent fe) {
2988: boolean available = false;
2989: try {
2990: available = clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor);
2991: } catch (IllegalStateException ise) {
2992: }
2993: mnbPasteMenuItem.setEnabled (available);
2994: }
2995: });
2996: if (!clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor)) {
2997: mnbPasteMenuItem.setEnabled (false);
2998: }
2999: }
3000:
3001:
3002:
3003:
3004:
3005:
3006:
3007:
3008:
3009:
3010:
3011:
3012:
3013:
3014:
3015:
3016:
3017:
3018:
3019:
3020:
3021:
3022:
3023: public static int xt3DIPSWRequest;
3024: public static int xt3DIPSW;
3025: public static int xt3PortAddress;
3026:
3027:
3028: public static int xt3MemorySizeRequest;
3029: public static int xt3MemorySize;
3030: public static boolean xt3MemoryEnabled;
3031: public static int xt3MemoryPosition;
3032: public static int xt3MemoryStart;
3033: public static final byte[] xt3MemoryArray = new byte[1 << 20];
3034: public static boolean xt3MemorySave;
3035:
3036:
3037: public static int xt3SavedPC;
3038: public static final int[] xt3SavedRn = new int[16];
3039:
3040:
3041: public static void xt3Init () {
3042:
3043:
3044: xt3DIPSWRequest = Math.max (0, Math.min (3, Settings.sgsGetInt ("xt3dipsw")));
3045: xt3DIPSW = xt3DIPSWRequest;
3046:
3047:
3048: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
3049:
3050:
3051: int memoryKB = Settings.sgsGetInt ("xt3memorykb");
3052: if (!(memoryKB == 1 << 8 || memoryKB == 1 << 10)) {
3053: memoryKB = 1 << 8;
3054: }
3055: xt3MemorySizeRequest = memoryKB << 10;
3056: xt3MemorySize = xt3MemorySizeRequest;
3057:
3058:
3059: xt3MemoryEnabled = false;
3060:
3061:
3062: xt3MemoryPosition = 11 << 20;
3063:
3064:
3065: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
3066:
3067:
3068:
3069: byte[] memoryArray = Settings.sgsGetData ("xt3memorydata");
3070: Arrays.fill (xt3MemoryArray,
3071: (byte) 0);
3072: if (memoryArray.length != 0) {
3073: System.arraycopy (memoryArray, 0,
3074: xt3MemoryArray, 0,
3075: Math.min (memoryArray.length, xt3MemoryArray.length));
3076: if (memoryArray.length < xt3MemoryArray.length) {
3077: Arrays.fill (xt3MemoryArray,
3078: memoryArray.length,
3079: xt3MemoryArray.length,
3080: (byte) 0);
3081: }
3082: }
3083:
3084:
3085: xt3MemorySave = Settings.sgsGetOnOff ("xt3memorysave");
3086:
3087:
3088: xt3SavedPC = 0;
3089:
3090: Arrays.fill (xt3SavedRn, 0);
3091:
3092: xt3Reset ();
3093: }
3094:
3095:
3096: public static void xt3Tini () {
3097:
3098:
3099: Settings.sgsPutInt ("xt3dipsw", xt3DIPSW);
3100:
3101:
3102: Settings.sgsPutInt ("xt3memorykb", xt3MemorySizeRequest >> 10);
3103:
3104:
3105: boolean zero = true;
3106: if (xt3MemorySave) {
3107: for (int i = 0; i < 1 << 20; i++) {
3108: if (xt3MemoryArray[i] != 0) {
3109: zero = false;
3110: break;
3111: }
3112: }
3113: }
3114: Settings.sgsCurrentMap.put ("xt3memorydata",
3115: zero ? "" :
3116: ByteArray.byaEncodeBase64 (ByteArray.byaEncodeGzip (xt3MemoryArray, 0, 1 << 20)));
3117:
3118:
3119: Settings.sgsPutOnOff ("xt3memorysave", xt3MemorySave);
3120:
3121: }
3122:
3123:
3124: public static void xt3Reset () {
3125:
3126:
3127: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
3128:
3129:
3130: xt3MemorySize = xt3MemorySizeRequest;
3131:
3132:
3133: xt3MemoryEnabled = false;
3134:
3135:
3136: xt3MemoryPosition = 11 << 20;
3137:
3138:
3139: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
3140:
3141:
3142: xt3SavedPC = 0;
3143: Arrays.fill (xt3SavedRn, 0);
3144:
3145: }
3146:
3147:
3148: public static int xt3PortRead () {
3149: return (currentIsSecond ? 4 : 0) | (xt3MemoryEnabled ? 2 : 0) | (xt3MemoryPosition == 11 << 20 ? 0 : 1);
3150: }
3151:
3152:
3153: public static void xt3PortWrite (int d) {
3154: boolean nextIsSecond = (d & 4) != 0;
3155: boolean memoryEnabled = (d & 2) != 0;
3156: int memoryPosition = (d & 1) == 0 ? 11 << 20 : 15 << 20;
3157:
3158: if (xt3MemoryEnabled != memoryEnabled ||
3159: xt3MemoryPosition != memoryPosition) {
3160: if (xt3MemoryEnabled) {
3161: if (xt3MemoryPosition == 11 << 20) {
3162: if (MainMemory.mmrMemorySizeCurrent < 12 << 20) {
3163: busSuper (MemoryMappedDevice.MMD_NUL, (12 << 20) - xt3MemorySize, 12 << 20);
3164: } else {
3165: busUser (MemoryMappedDevice.MMD_MMR, (12 << 20) - xt3MemorySize, 12 << 20);
3166: }
3167: } else {
3168: busSuper (MemoryMappedDevice.MMD_ROM, (16 << 20) - xt3MemorySize, 16 << 20);
3169: }
3170: }
3171: xt3MemoryEnabled = memoryEnabled;
3172: xt3MemoryPosition = memoryPosition;
3173: if (xt3MemoryEnabled) {
3174: if (xt3MemoryPosition == 11 << 20) {
3175: busUser (MemoryMappedDevice.MMD_XTM, (12 << 20) - xt3MemorySize, 12 << 20);
3176: } else {
3177: busUser (MemoryMappedDevice.MMD_XTM, (16 << 20) - xt3MemorySize, 16 << 20);
3178: }
3179: }
3180: }
3181:
3182: if (currentIsSecond != nextIsSecond) {
3183:
3184: if (nextIsSecond) {
3185:
3186:
3187: xt3SavedPC = regPC;
3188: System.arraycopy (regRn, 0, xt3SavedRn, 0, 16);
3189:
3190:
3191: if (mpuTask != null) {
3192: mpuClockLimit = 0L;
3193: System.out.println (Multilingual.mlnJapanese ?
3194: Model.MPU_NAMES[currentFirstMPU] + " を停止します" :
3195: Model.MPU_NAMES[currentFirstMPU] + " stops");
3196: mpuTask.cancel ();
3197: mpuTask = null;
3198: }
3199:
3200:
3201: tmrTimer.schedule (new TimerTask () {
3202: @Override public void run () {
3203:
3204:
3205: currentIsSecond = true;
3206: currentMPU = currentSecondMPU;
3207: mpuSetCurrentClock (specifiedSecondClock);
3208:
3209: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
3210: MC68EC030.m30DivZeroVFlag = false;
3211: }
3212:
3213: RegisterList.drpSetMPU ();
3214: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
3215: mpuPCR = 0x04300500 | MPU_060_REV << 8;
3216: MC68060.mmuReset ();
3217:
3218: mpuIgnoreAddressError = true;
3219: fpuBox = fpuMotherboardCoprocessor;
3220: if (currentFPU == 2) {
3221: fpuBox.epbSetMC68882 ();
3222: } else {
3223: fpuBox.epbSetMC68881 ();
3224: }
3225: if (currentTriplePrecision) {
3226: fpuBox.epbSetTriple ();
3227: } else {
3228: fpuBox.epbSetExtended ();
3229: }
3230: fpuBox.epbReset ();
3231: fpuFPn = fpuBox.epbFPn;
3232: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
3233: mpuSetWait ();
3234:
3235: regSRT1 = regSRT0 = 0;
3236: regSRS = REG_SR_S;
3237: regSRM = 0;
3238: regSRI = REG_SR_I;
3239: regCCR = 0;
3240: Arrays.fill (regRn, 0);
3241:
3242: regRn[15] = MainMemory.mmrRls (0x00000000);
3243: regPC = MainMemory.mmrRls (0x00000004);
3244:
3245: mpuIMR = 0;
3246: mpuIRR = 0;
3247: if (MC68901.MFP_DELAYED_INTERRUPT) {
3248: mpuDIRR = 0;
3249: }
3250: mpuISR = 0;
3251:
3252: mpuStart ();
3253: }
3254: }, TMR_DELAY);
3255:
3256: } else {
3257:
3258:
3259: if (mpuTask != null) {
3260: mpuClockLimit = 0L;
3261: System.out.println (Multilingual.mlnJapanese ? "MC68EC030 を停止します" : "MC68EC030 stops");
3262: mpuTask.cancel ();
3263: mpuTask = null;
3264: }
3265:
3266:
3267: tmrTimer.schedule (new TimerTask () {
3268: @Override public void run () {
3269:
3270:
3271: currentIsSecond = false;
3272: currentMPU = currentFirstMPU;
3273: mpuSetCurrentClock (specifiedFirstClock);
3274:
3275: RegisterList.drpSetMPU ();
3276: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
3277: mpuPCR = 0x04300500 | MPU_060_REV << 8;
3278: MC68060.mmuReset ();
3279:
3280: mpuIgnoreAddressError = false;
3281: mpuCacheOn = false;
3282: mpuSetWait ();
3283:
3284: regSRT1 = regSRT0 = 0;
3285: regSRS = REG_SR_S;
3286: regSRM = 0;
3287: regSRI = REG_SR_I;
3288: regCCR = 0;
3289:
3290: regPC = xt3SavedPC;
3291: System.arraycopy (xt3SavedRn, 0, regRn, 0, 16);
3292:
3293: mpuIMR = 0;
3294: mpuIRR = 0;
3295: if (MC68901.MFP_DELAYED_INTERRUPT) {
3296: mpuDIRR = 0;
3297: }
3298: mpuISR = 0;
3299:
3300: mpuStart ();
3301: }
3302: }, TMR_DELAY);
3303:
3304: }
3305: }
3306: }
3307:
3308:
3309:
3310:
3311:
3312:
3313: public static JMenu mdlMenu;
3314:
3315: public static JRadioButtonMenuItem mdlShodaiMenuItem;
3316: public static JRadioButtonMenuItem mdlACEMenuItem;
3317: public static JRadioButtonMenuItem mdlEXPERTMenuItem;
3318: public static JRadioButtonMenuItem mdlPROMenuItem;
3319: public static JRadioButtonMenuItem mdlSUPERMenuItem;
3320: public static JRadioButtonMenuItem mdlXVIMenuItem;
3321: public static JRadioButtonMenuItem mdlXellent30MenuItem;
3322: public static JRadioButtonMenuItem mdlCompactMenuItem;
3323: public static JRadioButtonMenuItem mdlHybridMenuItem;
3324: public static JRadioButtonMenuItem mdl060turboPROMenuItem;
3325: public static JRadioButtonMenuItem mdlX68030MenuItem;
3326: public static JRadioButtonMenuItem mdl030CompactMenuItem;
3327: public static JRadioButtonMenuItem mdl060turboMenuItem;
3328: public static JCheckBoxMenuItem mdlMC68010MenuItem;
3329:
3330: public static JRadioButtonMenuItem fpuMenuItem0;
3331: public static JRadioButtonMenuItem fpuMenuItem1;
3332: public static JRadioButtonMenuItem fpuMenuItem2;
3333: public static JCheckBoxMenuItem fpuMenuItem3;
3334:
3335:
3336: public static final int ACCELERATOR_HYBRID = 1;
3337: public static final int ACCELERATOR_XELLENT30 = 2;
3338: public static final int ACCELERATOR_060TURBO = 3;
3339: public static final int ACCELERATOR_060TURBOPRO = 4;
3340: public static final double MHZ_HYBRID_VALUE = 100.0 / 3.0;
3341: public static final String MHZ_HYBRID_STRING = "33.3";
3342: public static final double MHZ_060TURBO_VALUE = 50.0;
3343: public static final String MHZ_060TURBO_STRING = "50";
3344:
3345:
3346:
3347: public static Model specifiedModel;
3348: public static int specifiedAccelerator;
3349:
3350: public static boolean specifiedIsSecond;
3351: public static int specifiedFirstMPU;
3352: public static int specifiedSecondMPU;
3353: public static int specifiedMPU;
3354:
3355: public static double specifiedFirstClock;
3356: public static double specifiedSecondClock;
3357: public static double specifiedClock;
3358:
3359: public static int specifiedFPU;
3360: public static boolean specifiedTriplePrecision;
3361: public static boolean specifiedFullSpecification;
3362:
3363:
3364:
3365: public static Model currentModel;
3366: public static int currentAccelerator;
3367:
3368: public static boolean currentIsSecond;
3369: public static int currentFirstMPU;
3370: public static int currentSecondMPU;
3371: public static int currentMPU;
3372:
3373:
3374: public static int currentFPU;
3375: public static boolean currentTriplePrecision;
3376: public static boolean currentFullSpecification;
3377:
3378:
3379:
3380: public static void mdlInit () {
3381:
3382:
3383: specifiedModel = Model.COMPACT;
3384: specifiedAccelerator = ACCELERATOR_HYBRID;
3385: {
3386: String paramModel = Settings.sgsGetString ("model");
3387: switch (paramModel.toLowerCase ()) {
3388: case "":
3389: case "none":
3390: case "hybrid":
3391: specifiedModel = Model.COMPACT;
3392: specifiedAccelerator = ACCELERATOR_HYBRID;
3393: break;
3394: case "xellent30":
3395: specifiedModel = Model.XVI;
3396: specifiedAccelerator = ACCELERATOR_XELLENT30;
3397: break;
3398: case "060turbo":
3399: specifiedModel = Model.X68030;
3400: specifiedAccelerator = ACCELERATOR_060TURBO;
3401: break;
3402: case "060turbopro":
3403: specifiedModel = Model.PRO;
3404: specifiedAccelerator = ACCELERATOR_060TURBOPRO;
3405: break;
3406: default:
3407: Model model = Model.fromTypeOrSynonym (paramModel);
3408: if (model != null) {
3409: specifiedModel = model;
3410: specifiedAccelerator = 0;
3411: } else {
3412: System.out.println (Multilingual.mlnJapanese ?
3413: paramModel + " は不明な機種です" :
3414: paramModel + " is unknown model");
3415: specifiedModel = Model.COMPACT;
3416: specifiedAccelerator = ACCELERATOR_HYBRID;
3417: }
3418: }
3419: }
3420:
3421: specifiedIsSecond = false;
3422: specifiedFirstMPU = specifiedModel.getMPU ();
3423: specifiedSecondMPU = Model.MPU_MC68EC030;
3424: {
3425: String[] paramMPUs = Settings.sgsGetString ("mpu").split (",");
3426: for (int i = 0; i < 2; i++) {
3427: int mpu = 0;
3428: String paramMPU = i < paramMPUs.length ? paramMPUs[i] : "";
3429: switch (paramMPU) {
3430: case "":
3431: case "none":
3432: case "-1":
3433: mpu = (i == 0 ?
3434: (specifiedAccelerator == ACCELERATOR_060TURBO ||
3435: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
3436: specifiedModel.getMPU ()) :
3437: Model.MPU_MC68EC030);
3438: break;
3439: case "0":
3440: case "68000":
3441: case "mc68000":
3442: mpu = Model.MPU_MC68000;
3443: break;
3444: case "1":
3445: case "68010":
3446: case "mc68010":
3447: mpu = Model.MPU_MC68010;
3448: break;
3449:
3450:
3451:
3452:
3453:
3454: case "3":
3455: case "68ec030":
3456: case "mc68ec030":
3457: mpu = Model.MPU_MC68EC030;
3458: break;
3459:
3460:
3461:
3462:
3463:
3464:
3465:
3466:
3467:
3468:
3469:
3470:
3471:
3472:
3473:
3474:
3475:
3476: case "6":
3477: case "68060":
3478: case "mc68060":
3479: mpu = Model.MPU_MC68060;
3480: break;
3481: default:
3482: Model model = Model.fromTypeOrSynonym (paramMPU);
3483: if (model != null) {
3484: mpu = model.getMPU ();
3485: } else {
3486: System.out.println (Multilingual.mlnJapanese ?
3487: paramMPU + " は不明な MPU です" :
3488: paramMPU + " is unknown MPU");
3489: mpu = specifiedModel.getMPU ();
3490: }
3491: }
3492: if (i == 0) {
3493: specifiedFirstMPU = mpu;
3494: } else {
3495: specifiedSecondMPU = mpu;
3496: }
3497: }
3498: }
3499: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
3500:
3501: specifiedFirstClock = specifiedModel.getClock ();
3502: specifiedSecondClock = specifiedFirstClock * 2.0;
3503: {
3504: String[] paramClocks = Settings.sgsGetString ("clock").split (",");
3505: for (int i = 0; i < 2; i++) {
3506: double clock = 0.0;
3507: String paramClock = i < paramClocks.length ? paramClocks[i] : "";
3508: switch (paramClock.toLowerCase ()) {
3509: case "":
3510: case "none":
3511: case "-1":
3512: clock = (i == 0 ?
3513: (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
3514: specifiedAccelerator == ACCELERATOR_060TURBO ||
3515: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
3516: specifiedModel.getClock ()) :
3517: specifiedFirstClock * 2.0);
3518: break;
3519: case "hybrid":
3520: clock = MHZ_HYBRID_VALUE;
3521: break;
3522: case "060turbo":
3523: case "060turbopro":
3524: clock = MHZ_060TURBO_VALUE;
3525: break;
3526: case "16.7":
3527: case "xellent30":
3528: clock = 50.0 / 3.0;
3529: break;
3530: case "33.3":
3531: clock = 100.0 / 3.0;
3532: break;
3533: case "66.7":
3534: clock = 200.0 / 3.0;
3535: break;
3536: default:
3537: if (paramClock.matches ("^(?:" +
3538: "[-+]?" +
3539: "(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)" +
3540: "(?:[Ee][-+]?[0-9]+)?" +
3541: ")$")) {
3542: double d = Double.parseDouble (paramClock);
3543: if (1.0 <= d && d <= 1000.0) {
3544: clock = d;
3545: }
3546: } else {
3547: System.out.println (Multilingual.mlnJapanese ?
3548: paramClock + " は不明な動作周波数です" :
3549: paramClock + " is unknown clock frequency");
3550: clock = specifiedModel.getClock ();
3551: }
3552: }
3553: if (i == 0) {
3554: specifiedFirstClock = clock;
3555: } else {
3556: specifiedSecondClock = clock;
3557: }
3558: }
3559: }
3560: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
3561:
3562: specifiedFPU = 0;
3563: specifiedTriplePrecision = false;
3564: specifiedFullSpecification = false;
3565: {
3566: int paramFPUMode = fmtParseInt (Settings.sgsGetString ("fpumode"), 0, 0, 2, 0);
3567: if (paramFPUMode == 0) {
3568: specifiedFPU = 0;
3569: specifiedTriplePrecision = false;
3570: } else if (paramFPUMode == 1) {
3571: specifiedFPU = Model.FPU_MC68882;
3572: specifiedTriplePrecision = false;
3573: } else if (paramFPUMode == 2) {
3574: specifiedFPU = Model.FPU_MC68882;
3575: specifiedTriplePrecision = true;
3576: }
3577: specifiedFullSpecification = Settings.sgsGetOnOff ("fullspecfpu");
3578: }
3579:
3580:
3581:
3582: currentModel = specifiedModel;
3583: currentAccelerator = specifiedAccelerator;
3584:
3585: currentIsSecond = specifiedIsSecond;
3586: currentFirstMPU = specifiedFirstMPU;
3587: currentSecondMPU = specifiedSecondMPU;
3588: currentMPU = specifiedMPU;
3589:
3590:
3591: currentFPU = specifiedFPU;
3592: currentTriplePrecision = specifiedTriplePrecision;
3593: currentFullSpecification = specifiedFullSpecification;
3594:
3595:
3596: mpuUtilOn = Settings.sgsGetOnOff ("util");
3597: mpuUtilRatio = fmtParseInt (Settings.sgsGetString ("ratio"), 0, 1, 100, 100);
3598:
3599: mpuArbFreqMHz = fmtParseInt (Settings.sgsGetString ("mhz"), 0, 1, 1000, 100);
3600: if (mpuUtilOn) {
3601: mpuArbFreqOn = false;
3602: } else {
3603: mpuArbFreqOn = !(specifiedClock == 10.0 ||
3604: specifiedClock == 50.0 / 3.0 ||
3605: specifiedClock == 25.0 ||
3606: specifiedClock == 100.0 / 3.0 ||
3607: specifiedClock == 50.0 ||
3608: specifiedClock == 200.0 / 3.0 ||
3609: specifiedClock == 75.0 ||
3610: specifiedClock == 100.0);
3611: if (mpuArbFreqOn) {
3612: mpuArbFreqMHz = (int) specifiedClock;
3613: }
3614: }
3615:
3616:
3617: mpuROMWaitCycles = 0;
3618: mpuRAMWaitCycles = 0;
3619: mpuCacheOn = false;
3620:
3621: mpuNoWaitTime.ram = 0;
3622: mpuNoWaitTime.gvram = 0;
3623: mpuNoWaitTime.tvram = 0;
3624: mpuNoWaitTime.crtc = 0;
3625: mpuNoWaitTime.palet = 0;
3626: mpuNoWaitTime.vicon = 0;
3627: mpuNoWaitTime.dmac = 0;
3628: mpuNoWaitTime.mfp = 0;
3629: mpuNoWaitTime.rtc = 0;
3630: mpuNoWaitTime.prnport = 0;
3631: mpuNoWaitTime.sysport = 0;
3632: mpuNoWaitTime.opm = 0;
3633: mpuNoWaitTime.adpcm = 0;
3634: mpuNoWaitTime.fdc = 0;
3635: mpuNoWaitTime.fdd = 0;
3636: mpuNoWaitTime.hdc = 0;
3637: mpuNoWaitTime.scc = 0;
3638: mpuNoWaitTime.ppi = 0;
3639: mpuNoWaitTime.ioi = 0;
3640: mpuNoWaitTime.sprc = 0;
3641: mpuNoWaitTime.sram = 0;
3642: mpuNoWaitTime.rom = 0;
3643: mpuNoWaitTime.ramlong = mpuNoWaitTime.ram << 1;
3644: mpuNoWaitTime.romlong = mpuNoWaitTime.rom << 1;
3645:
3646: dmaNoWaitTime.ram = 0;
3647: dmaNoWaitTime.gvram = 0;
3648: dmaNoWaitTime.tvram = 0;
3649: dmaNoWaitTime.crtc = 0;
3650: dmaNoWaitTime.palet = 0;
3651: dmaNoWaitTime.vicon = 0;
3652: dmaNoWaitTime.dmac = 0;
3653: dmaNoWaitTime.mfp = 0;
3654: dmaNoWaitTime.rtc = 0;
3655: dmaNoWaitTime.prnport = 0;
3656: dmaNoWaitTime.sysport = 0;
3657: dmaNoWaitTime.opm = 0;
3658: dmaNoWaitTime.adpcm = 0;
3659: dmaNoWaitTime.fdc = 0;
3660: dmaNoWaitTime.fdd = 0;
3661: dmaNoWaitTime.hdc = 0;
3662: dmaNoWaitTime.scc = 0;
3663: dmaNoWaitTime.ppi = 0;
3664: dmaNoWaitTime.ioi = 0;
3665: dmaNoWaitTime.sprc = 0;
3666: dmaNoWaitTime.sram = 0;
3667: dmaNoWaitTime.rom = 0;
3668: dmaNoWaitTime.ramlong = dmaNoWaitTime.ram << 1;
3669: dmaNoWaitTime.romlong = dmaNoWaitTime.rom << 1;
3670:
3671:
3672: busWaitCyclesRequest = Settings.sgsGetOnOff ("waitcycles");
3673: busWaitCycles = busWaitCyclesRequest;
3674: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
3675:
3676: }
3677:
3678: public static void mdlTini () {
3679:
3680: Settings.sgsPutString ("model",
3681: specifiedAccelerator == ACCELERATOR_HYBRID ? "Hybrid" :
3682: specifiedAccelerator == ACCELERATOR_XELLENT30 ? "Xellent30" :
3683: specifiedAccelerator == ACCELERATOR_060TURBO ? "060turbo" :
3684: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? "060turboPRO" :
3685: specifiedModel.getSynonym () != null ? specifiedModel.getSynonym () :
3686: specifiedModel.getType ());
3687:
3688:
3689: int defaultFirstMPU = (specifiedAccelerator == ACCELERATOR_060TURBO ||
3690: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
3691: specifiedModel.getMPU ());
3692: int defaultSecondMPU = Model.MPU_MC68EC030;
3693: Settings.sgsPutString ("mpu",
3694: (specifiedFirstMPU == defaultFirstMPU ? "" :
3695: Model.mpuNameOf (specifiedFirstMPU)) +
3696: (specifiedSecondMPU == defaultSecondMPU ? "" :
3697: "," + Model.mpuNameOf (specifiedSecondMPU)));
3698:
3699:
3700:
3701:
3702: double defaultFirstClock = (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
3703: specifiedAccelerator == ACCELERATOR_060TURBO ||
3704: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
3705: specifiedModel.getClock ());
3706: double defaultSecondClock = defaultFirstClock * 2.0;
3707: Settings.sgsPutString ("clock",
3708: (specifiedFirstClock == defaultFirstClock ? "" :
3709: specifiedFirstClock == 50.0 / 3.0 ? "16.7" :
3710: specifiedFirstClock == 100.0 / 3.0 ? "33.3" :
3711: specifiedFirstClock == 200.0 / 3.0 ? "66.7" :
3712: String.valueOf ((int) specifiedFirstClock)) +
3713: (specifiedSecondClock == defaultSecondClock ? "" :
3714: "," + (specifiedSecondClock == 50.0 / 3.0 ? "16.7" :
3715: specifiedSecondClock == 100.0 / 3.0 ? "33.3" :
3716: specifiedSecondClock == 200.0 / 3.0 ? "66.7" :
3717: String.valueOf ((int) specifiedSecondClock))));
3718:
3719: Settings.sgsPutInt ("fpumode",
3720: specifiedFPU == 0 ? 0 :
3721: !specifiedTriplePrecision ? 1 :
3722: 2);
3723: Settings.sgsPutOnOff ("fullspecfpu",
3724: specifiedFullSpecification);
3725:
3726: Settings.sgsPutOnOff ("util",
3727: mpuUtilOn);
3728: Settings.sgsPutString ("ratio",
3729: String.valueOf (mpuUtilRatio));
3730:
3731: Settings.sgsPutString ("mhz",
3732: String.valueOf (mpuArbFreqMHz));
3733:
3734: Settings.sgsPutOnOff ("waitcycles", busWaitCyclesRequest);
3735: }
3736:
3737: public static void mdlMakeMenu () {
3738:
3739:
3740: ActionListener listener = new ActionListener () {
3741: @Override public void actionPerformed (ActionEvent ae) {
3742: Object source = ae.getSource ();
3743: switch (ae.getActionCommand ()) {
3744: case "X68000 (10MHz)":
3745: mdlRequestModel (Model.SHODAI, 0);
3746: mpuReset (-1, -1);
3747: break;
3748: case "X68000 ACE (10MHz)":
3749: mdlRequestModel (Model.ACE, 0);
3750: mpuReset (-1, -1);
3751: break;
3752: case "X68000 EXPERT (10MHz)":
3753: mdlRequestModel (Model.EXPERT, 0);
3754: mpuReset (-1, -1);
3755: break;
3756: case "X68000 PRO (10MHz)":
3757: mdlRequestModel (Model.PRO, 0);
3758: mpuReset (-1, -1);
3759: break;
3760: case "X68000 SUPER (10MHz)":
3761: mdlRequestModel (Model.SUPER, 0);
3762: mpuReset (-1, -1);
3763: break;
3764: case "X68000 XVI (16.7MHz)":
3765: mdlRequestModel (Model.XVI, 0);
3766: mpuReset (-1, -1);
3767: break;
3768: case "X68000 Compact (16.7MHz)":
3769: mdlRequestModel (Model.COMPACT, 0);
3770: mpuReset (-1, -1);
3771: break;
3772:
3773: case "X68030 (25MHz)":
3774: mdlRequestModel (Model.X68030, 0);
3775: mpuReset (-1, -1);
3776: break;
3777: case "X68030 Compact (25MHz)":
3778: mdlRequestModel (Model.X68030COMPACT, 0);
3779: mpuReset (-1, -1);
3780: break;
3781:
3782: case "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)":
3783: mdlRequestModel (Model.COMPACT, ACCELERATOR_HYBRID);
3784: mpuReset (-1, -1);
3785: break;
3786: case "Xellent30 (33.3MHz)":
3787: mdlRequestModel (Model.XVI, ACCELERATOR_XELLENT30);
3788: mpuReset (-1, -1);
3789: break;
3790: case "060turbo (" + MHZ_060TURBO_STRING + "MHz)":
3791: mdlRequestModel (Model.X68030, ACCELERATOR_060TURBO);
3792: mpuReset (-1, -1);
3793: break;
3794: case "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)":
3795: mdlRequestModel (Model.PRO, ACCELERATOR_060TURBOPRO);
3796: mpuReset (-1, -1);
3797: break;
3798:
3799: case "MC68010":
3800:
3801: break;
3802:
3803: case "No FPU":
3804: specifiedFPU = 0;
3805: specifiedTriplePrecision = false;
3806: break;
3807: case "Extended precision (19 digit)":
3808: specifiedFPU = Model.FPU_MC68882;
3809: specifiedTriplePrecision = false;
3810: break;
3811: case "Triple precision (24 digit)":
3812: specifiedFPU = Model.FPU_MC68882;
3813: specifiedTriplePrecision = true;
3814: break;
3815: case "Full specification FPU":
3816: specifiedFullSpecification = ((JCheckBoxMenuItem) source).isSelected ();
3817: break;
3818:
3819: }
3820: }
3821: };
3822:
3823:
3824: ButtonGroup modelGroup = new ButtonGroup ();
3825: mdlMenu = Multilingual.mlnText (
3826: ComponentFactory.createMenu (
3827: "Change the model and reset",
3828: mdlShodaiMenuItem = ComponentFactory.createRadioButtonMenuItem (
3829: modelGroup,
3830: specifiedModel == Model.SHODAI,
3831: "X68000 (10MHz)",
3832: listener),
3833: mdlACEMenuItem = ComponentFactory.createRadioButtonMenuItem (
3834: modelGroup,
3835: specifiedModel == Model.ACE,
3836: "X68000 ACE (10MHz)",
3837: listener),
3838: mdlEXPERTMenuItem = ComponentFactory.createRadioButtonMenuItem (
3839: modelGroup,
3840: specifiedModel == Model.EXPERT,
3841: "X68000 EXPERT (10MHz)",
3842: listener),
3843: mdlPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
3844: modelGroup,
3845: specifiedModel == Model.PRO && specifiedAccelerator == 0,
3846: "X68000 PRO (10MHz)",
3847: listener),
3848: mdlSUPERMenuItem = ComponentFactory.createRadioButtonMenuItem (
3849: modelGroup,
3850: specifiedModel == Model.SUPER,
3851: "X68000 SUPER (10MHz)",
3852: listener),
3853: mdlXVIMenuItem = ComponentFactory.createRadioButtonMenuItem (
3854: modelGroup,
3855: specifiedModel == Model.XVI && specifiedAccelerator == 0,
3856: "X68000 XVI (16.7MHz)",
3857: listener),
3858: mdlCompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
3859: modelGroup,
3860: specifiedModel == Model.COMPACT && specifiedAccelerator == 0,
3861: "X68000 Compact (16.7MHz)",
3862: listener),
3863:
3864: ComponentFactory.createHorizontalSeparator (),
3865:
3866: mdlX68030MenuItem = ComponentFactory.createRadioButtonMenuItem (
3867: modelGroup,
3868: specifiedModel == Model.X68030 && specifiedAccelerator == 0,
3869: "X68030 (25MHz)",
3870: listener),
3871: mdl030CompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
3872: modelGroup,
3873: specifiedModel == Model.X68030COMPACT,
3874: "X68030 Compact (25MHz)",
3875: listener),
3876:
3877: ComponentFactory.createHorizontalSeparator (),
3878:
3879: mdlHybridMenuItem = ComponentFactory.createRadioButtonMenuItem (
3880: modelGroup,
3881: specifiedModel == Model.COMPACT && specifiedAccelerator == ACCELERATOR_HYBRID,
3882: "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)",
3883: listener),
3884: mdlXellent30MenuItem = ComponentFactory.createRadioButtonMenuItem (
3885: modelGroup,
3886: specifiedModel == Model.XVI && specifiedAccelerator == ACCELERATOR_XELLENT30,
3887: "Xellent30 (33.3MHz)",
3888: listener),
3889: mdl060turboMenuItem = ComponentFactory.createRadioButtonMenuItem (
3890: modelGroup,
3891: specifiedModel == Model.X68030 && specifiedAccelerator == ACCELERATOR_060TURBO,
3892: "060turbo (" + MHZ_060TURBO_STRING + "MHz)",
3893: listener),
3894: mdl060turboPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
3895: modelGroup,
3896: specifiedModel == Model.PRO && specifiedAccelerator == ACCELERATOR_060TURBOPRO,
3897: "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)",
3898: listener),
3899:
3900: ComponentFactory.createHorizontalSeparator (),
3901:
3902: mdlMC68010MenuItem = ComponentFactory.createCheckBoxMenuItem (
3903: specifiedMPU == Model.MPU_MC68010,
3904: "MC68010",
3905: listener)
3906: ),
3907: "ja", "機種を変更してリセット");
3908:
3909: ButtonGroup fpuGroup = new ButtonGroup ();
3910: fpuMenuItem0 = ComponentFactory.setEnabled (
3911: Multilingual.mlnText (
3912: ComponentFactory.createRadioButtonMenuItem (
3913: fpuGroup,
3914: specifiedFPU == 0,
3915: "No FPU",
3916: listener),
3917: "ja", "FPU なし"),
3918: Model.MPU_MC68020 <= specifiedFirstMPU ||
3919: Model.MPU_MC68020 <= specifiedSecondMPU);
3920: fpuMenuItem1 = ComponentFactory.setEnabled (
3921: Multilingual.mlnText (
3922: ComponentFactory.createRadioButtonMenuItem (
3923: fpuGroup,
3924: specifiedFPU != 0 && !specifiedTriplePrecision,
3925: "Extended precision (19 digit)",
3926: listener),
3927: "ja", "拡張精度 (19 桁)"),
3928: Model.MPU_MC68020 <= specifiedFirstMPU ||
3929: Model.MPU_MC68020 <= specifiedSecondMPU);
3930: fpuMenuItem2 = ComponentFactory.setEnabled (
3931: Multilingual.mlnText (
3932: ComponentFactory.createRadioButtonMenuItem (
3933: fpuGroup,
3934: specifiedFPU != 0 && specifiedTriplePrecision,
3935: "Triple precision (24 digit)",
3936: listener),
3937: "ja", "三倍精度 (24 桁)"),
3938: Model.MPU_MC68020 <= specifiedFirstMPU ||
3939: Model.MPU_MC68020 <= specifiedSecondMPU);
3940: fpuMenuItem3 = ComponentFactory.setEnabled (
3941: Multilingual.mlnText (
3942: ComponentFactory.createCheckBoxMenuItem (
3943: specifiedFullSpecification,
3944: "Full specification FPU",
3945: listener),
3946: "ja", "フルスペック FPU"),
3947: Model.MPU_MC68040 <= specifiedFirstMPU ||
3948: Model.MPU_MC68040 <= specifiedSecondMPU);
3949:
3950: }
3951:
3952: public static void mdlRequestModel (Model model, int accelerator) {
3953: specifiedModel = model;
3954: specifiedAccelerator = accelerator;
3955:
3956: specifiedIsSecond = false;
3957: specifiedFirstMPU = specifiedModel.getMPU ();
3958: specifiedSecondMPU = Model.MPU_MC68EC030;
3959: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
3960: specifiedFirstClock = specifiedModel.getClock ();
3961: specifiedSecondClock = specifiedFirstClock * 2.0;
3962: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
3963:
3964: if (specifiedFirstMPU == Model.MPU_MC68000 &&
3965: mdlMC68010MenuItem.isSelected ()) {
3966: specifiedFirstMPU = Model.MPU_MC68010;
3967: }
3968:
3969: switch (accelerator) {
3970: case ACCELERATOR_HYBRID:
3971: specifiedFirstClock = MHZ_HYBRID_VALUE;
3972: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
3973: break;
3974: case ACCELERATOR_XELLENT30:
3975: break;
3976: case ACCELERATOR_060TURBO:
3977: case ACCELERATOR_060TURBOPRO:
3978: specifiedFirstMPU = Model.MPU_MC68060;
3979: specifiedFirstClock = MHZ_060TURBO_VALUE;
3980: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
3981: }
3982:
3983: mpuUtilOn = false;
3984: mpuArbFreqOn = false;
3985: mpuSetCurrentClock (specifiedClock);
3986:
3987: if (accelerator == ACCELERATOR_HYBRID) {
3988: mdlHybridMenuItem.setSelected (true);
3989: } else if (accelerator == ACCELERATOR_XELLENT30) {
3990: mdlXellent30MenuItem.setSelected (true);
3991: } else if (accelerator == ACCELERATOR_060TURBO) {
3992: mdl060turboMenuItem.setSelected (true);
3993: } else if (accelerator == ACCELERATOR_060TURBOPRO) {
3994: mdl060turboPROMenuItem.setSelected (true);
3995: } else if (specifiedModel == Model.SHODAI) {
3996: mdlShodaiMenuItem.setSelected (true);
3997: } else if (specifiedModel == Model.ACE) {
3998: mdlACEMenuItem.setSelected (true);
3999: } else if (specifiedModel == Model.EXPERT) {
4000: mdlEXPERTMenuItem.setSelected (true);
4001: } else if (specifiedModel == Model.PRO) {
4002: mdlPROMenuItem.setSelected (true);
4003: } else if (specifiedModel == Model.SUPER) {
4004: mdlSUPERMenuItem.setSelected (true);
4005: } else if (specifiedModel == Model.XVI) {
4006: mdlXVIMenuItem.setSelected (true);
4007: } else if (specifiedModel == Model.COMPACT) {
4008: mdlCompactMenuItem.setSelected (true);
4009: } else if (specifiedModel == Model.X68030) {
4010: mdlX68030MenuItem.setSelected (true);
4011: } else if (specifiedModel == Model.X68030COMPACT) {
4012: mdl030CompactMenuItem.setSelected (true);
4013: }
4014:
4015: fpuMenuItem0.setEnabled (Model.MPU_MC68020 <= specifiedFirstMPU ||
4016: Model.MPU_MC68020 <= specifiedSecondMPU);
4017: fpuMenuItem1.setEnabled (Model.MPU_MC68020 <= specifiedFirstMPU ||
4018: Model.MPU_MC68020 <= specifiedSecondMPU);
4019: fpuMenuItem2.setEnabled (Model.MPU_MC68020 <= specifiedFirstMPU ||
4020: Model.MPU_MC68020 <= specifiedSecondMPU);
4021: fpuMenuItem3.setEnabled (Model.MPU_MC68040 <= specifiedFirstMPU ||
4022: Model.MPU_MC68040 <= specifiedSecondMPU);
4023:
4024: HDC.hdcSASIMenuItem.setSelected (!currentModel.isSCSI ());
4025: SPC.spcSCSIINMenuItem.setSelected (currentModel.isSCSI ());
4026: }
4027:
4028:
4029:
4030:
4031:
4032:
4033:
4034: public static final boolean MPU_INLINE_EXCEPTION = true;
4035: public static final boolean MPU_COMPOUND_POSTINCREMENT = false;
4036:
4037: public static final boolean MPU_SWITCH_MISC_OPCODE = false;
4038: public static final boolean MPU_SWITCH_BCC_CONDITION = false;
4039: public static final boolean MPU_SWITCH_BCC_OFFSET = false;
4040: public static final boolean MPU_SWITCH_SCC_CONDITION = true;
4041:
4042: public static final boolean MPU_OMIT_EXTRA_READ = false;
4043: public static final boolean MPU_OMIT_OFFSET_READ = false;
4044:
4045:
4046:
4047:
4048: public static final long FAR_FUTURE = 0x7fffffffffffffffL;
4049:
4050:
4051:
4052:
4053:
4054:
4055:
4056:
4057: public static final int REG_SR_T1 = 0b10000000_00000000;
4058: public static final int REG_SR_T0 = 0b01000000_00000000;
4059:
4060:
4061:
4062:
4063:
4064:
4065: public static final int REG_SR_S = 0b00100000_00000000;
4066: public static final int REG_SR_M = 0b00010000_00000000;
4067:
4068: public static final int REG_SR_I = 0b00000111_00000000;
4069:
4070:
4071: public static final int REG_CCR_X = 0b00000000_00010000;
4072: public static final int REG_CCR_N = 0b00000000_00001000;
4073: public static final int REG_CCR_Z = 0b00000000_00000100;
4074: public static final int REG_CCR_V = 0b00000000_00000010;
4075: public static final int REG_CCR_C = 0b00000000_00000001;
4076: public static final int REG_CCR_MASK = REG_CCR_X | REG_CCR_N | REG_CCR_Z | REG_CCR_V | REG_CCR_C;
4077:
4078: public static char[] REG_CCRXMAP = "00000000000000001111111111111111".toCharArray ();
4079: public static char[] REG_CCRNMAP = "00000000111111110000000011111111".toCharArray ();
4080: public static char[] REG_CCRZMAP = "00001111000011110000111100001111".toCharArray ();
4081: public static char[] REG_CCRVMAP = "00110011001100110011001100110011".toCharArray ();
4082: public static char[] REG_CCRCMAP = "01010101010101010101010101010101".toCharArray ();
4083:
4084:
4085:
4086: public static final int MPU_IOI_INTERRUPT_LEVEL = 1;
4087: public static final int MPU_EB2_INTERRUPT_LEVEL = 2;
4088: public static final int MPU_DMA_INTERRUPT_LEVEL = 3;
4089: public static final int MPU_SCC_INTERRUPT_LEVEL = 5;
4090: public static final int MPU_MFP_INTERRUPT_LEVEL = 6;
4091: public static final int MPU_SYS_INTERRUPT_LEVEL = 7;
4092: public static final int MPU_IOI_INTERRUPT_MASK = 0x80 >> MPU_IOI_INTERRUPT_LEVEL;
4093: public static final int MPU_EB2_INTERRUPT_MASK = 0x80 >> MPU_EB2_INTERRUPT_LEVEL;
4094: public static final int MPU_DMA_INTERRUPT_MASK = 0x80 >> MPU_DMA_INTERRUPT_LEVEL;
4095: public static final int MPU_SCC_INTERRUPT_MASK = 0x80 >> MPU_SCC_INTERRUPT_LEVEL;
4096: public static final int MPU_MFP_INTERRUPT_MASK = 0x80 >> MPU_MFP_INTERRUPT_LEVEL;
4097: public static final int MPU_SYS_INTERRUPT_MASK = 0x80 >> MPU_SYS_INTERRUPT_LEVEL;
4098:
4099: public static final boolean MPU_INTERRUPT_SWITCH = true;
4100:
4101:
4102: public static final boolean T = true;
4103: public static final boolean F = false;
4104:
4105: public static final int CCCC_T = 0b0000;
4106: public static final int CCCC_F = 0b0001;
4107: public static final int CCCC_HI = 0b0010;
4108: public static final int CCCC_LS = 0b0011;
4109: public static final int CCCC_CC = 0b0100;
4110: public static final int CCCC_CS = 0b0101;
4111: public static final int CCCC_NE = 0b0110;
4112: public static final int CCCC_EQ = 0b0111;
4113: public static final int CCCC_VC = 0b1000;
4114: public static final int CCCC_VS = 0b1001;
4115: public static final int CCCC_PL = 0b1010;
4116: public static final int CCCC_MI = 0b1011;
4117: public static final int CCCC_GE = 0b1100;
4118: public static final int CCCC_LT = 0b1101;
4119: public static final int CCCC_GT = 0b1110;
4120: public static final int CCCC_LE = 0b1111;
4121:
4122:
4123:
4124:
4125:
4126:
4127: public static final boolean[] BCCMAP = {
4128: 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,
4129: 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,
4130: 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,
4131: 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,
4132: 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,
4133: 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,
4134: 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,
4135: 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,
4136: 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,
4137: 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,
4138: 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,
4139: 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,
4140: 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,
4141: 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,
4142: 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,
4143: 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,
4144: };
4145:
4146:
4147: public static final char[] MPU_CCCMAP = (
4148: "11111111111111111111111111111111" +
4149: "00000000000000000000000000000000" +
4150: "10100000101000001010000010100000" +
4151: "01011111010111110101111101011111" +
4152: "10101010101010101010101010101010" +
4153: "01010101010101010101010101010101" +
4154: "11110000111100001111000011110000" +
4155: "00001111000011110000111100001111" +
4156: "11001100110011001100110011001100" +
4157: "00110011001100110011001100110011" +
4158: "11111111000000001111111100000000" +
4159: "00000000111111110000000011111111" +
4160: "11001100001100111100110000110011" +
4161: "00110011110011000011001111001100" +
4162: "11000000001100001100000000110000" +
4163: "00111111110011110011111111001111").toCharArray ();
4164:
4165:
4166:
4167: public static final int MPU_CC_T = 0b11111111111111111111111111111111;
4168: public static final int MPU_CC_F = 0b00000000000000000000000000000000;
4169: public static final int MPU_CC_HI = 0b10100000101000001010000010100000;
4170: public static final int MPU_CC_LS = 0b01011111010111110101111101011111;
4171: public static final int MPU_CC_HS = 0b10101010101010101010101010101010;
4172: public static final int MPU_CC_LO = 0b01010101010101010101010101010101;
4173: public static final int MPU_CC_NE = 0b11110000111100001111000011110000;
4174: public static final int MPU_CC_EQ = 0b00001111000011110000111100001111;
4175: public static final int MPU_CC_VC = 0b11001100110011001100110011001100;
4176: public static final int MPU_CC_VS = 0b00110011001100110011001100110011;
4177: public static final int MPU_CC_PL = 0b11111111000000001111111100000000;
4178: public static final int MPU_CC_MI = 0b00000000111111110000000011111111;
4179: public static final int MPU_CC_GE = 0b11001100001100111100110000110011;
4180: public static final int MPU_CC_LT = 0b00110011110011000011001111001100;
4181: public static final int MPU_CC_GT = 0b11000000001100001100000000110000;
4182: public static final int MPU_CC_LE = 0b00111111110011110011111111001111;
4183:
4184:
4185:
4186:
4187:
4188:
4189:
4190:
4191:
4192:
4193:
4194:
4195:
4196:
4197:
4198:
4199:
4200:
4201:
4202:
4203:
4204:
4205:
4206:
4207:
4208:
4209:
4210:
4211:
4212:
4213:
4214:
4215:
4216:
4217:
4218:
4219:
4220:
4221:
4222:
4223:
4224:
4225:
4226:
4227:
4228:
4229:
4230:
4231:
4232: 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);
4233:
4234:
4235:
4236: public static final int[] MPU_BITREV_TABLE_0 = new int[2048];
4237: public static final int[] MPU_BITREV_TABLE_1 = new int[2048];
4238: public static final int[] MPU_BITREV_TABLE_2 = new int[2048];
4239: static {
4240: for (int i = 0; i < 2048; i++) {
4241: MPU_BITREV_TABLE_2[i] = (MPU_BITREV_TABLE_1[i] = (MPU_BITREV_TABLE_0[i] = Integer.reverse (i)) >>> 11) >>> 11;
4242: }
4243: }
4244:
4245:
4246:
4247: public static final int EA_DR = 0b000_000;
4248: public static final int EA_AR = 0b001_000;
4249: public static final int EA_MM = 0b010_000;
4250: public static final int EA_MP = 0b011_000;
4251: public static final int EA_MN = 0b100_000;
4252: public static final int EA_MW = 0b101_000;
4253: public static final int EA_MX = 0b110_000;
4254: public static final int EA_ZW = 0b111_000;
4255: public static final int EA_ZL = 0b111_001;
4256: public static final int EA_PW = 0b111_010;
4257: public static final int EA_PX = 0b111_011;
4258: public static final int EA_IM = 0b111_100;
4259: public static final int MMM_DR = EA_DR >> 3;
4260: public static final int MMM_AR = EA_AR >> 3;
4261: public static final int MMM_MM = EA_MM >> 3;
4262: public static final int MMM_MP = EA_MP >> 3;
4263: public static final int MMM_MN = EA_MN >> 3;
4264: public static final int MMM_MW = EA_MW >> 3;
4265: public static final int MMM_MX = EA_MX >> 3;
4266: public static final long EAM_DR = 0xff00000000000000L >>> EA_DR;
4267: public static final long EAM_AR = 0xff00000000000000L >>> EA_AR;
4268: public static final long EAM_MM = 0xff00000000000000L >>> EA_MM;
4269: public static final long EAM_MP = 0xff00000000000000L >>> EA_MP;
4270: public static final long EAM_MN = 0xff00000000000000L >>> EA_MN;
4271: public static final long EAM_MW = 0xff00000000000000L >>> EA_MW;
4272: public static final long EAM_MX = 0xff00000000000000L >>> EA_MX;
4273: public static final long EAM_ZW = 0x8000000000000000L >>> EA_ZW;
4274: public static final long EAM_ZL = 0x8000000000000000L >>> EA_ZL;
4275: public static final long EAM_PW = 0x8000000000000000L >>> EA_PW;
4276: public static final long EAM_PX = 0x8000000000000000L >>> EA_PX;
4277: public static final long EAM_IM = 0x8000000000000000L >>> EA_IM;
4278: 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;
4279: public static final long EAM_ALT = EAM_DR|EAM_AR|EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
4280: 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;
4281: 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 ;
4282: public static final long EAM_DLT = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
4283: public static final long EAM_DCN = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
4284: public static final long EAM_DCL = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
4285: 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;
4286: public static final long EAM_MEM = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
4287: public static final long EAM_MLT = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
4288: public static final long EAM_RDL = EAM_MM|EAM_MP |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
4289: public static final long EAM_WTL = EAM_MM |EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
4290: public static final long EAM_CNT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
4291: public static final long EAM_CLT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
4292:
4293:
4294:
4295:
4296:
4297:
4298:
4299:
4300:
4301:
4302:
4303: public static final int[] regRn = new int[16 + 1];
4304:
4305:
4306: public static int regPC;
4307: public static int regPC0;
4308:
4309:
4310: public static int regOC;
4311:
4312:
4313: public static int regSRT1;
4314: public static int regSRT0;
4315: public static int mpuTraceFlag;
4316: public static int regSRS;
4317: public static int regSRM;
4318: public static int regSRI;
4319:
4320:
4321: public static int regCCR;
4322:
4323:
4324:
4325:
4326:
4327:
4328:
4329:
4330:
4331:
4332:
4333:
4334:
4335:
4336:
4337:
4338:
4339:
4340:
4341:
4342: public static int mpuIMR;
4343:
4344:
4345:
4346:
4347:
4348:
4349: public static int mpuIRR;
4350: public static int mpuDIRR;
4351:
4352:
4353:
4354:
4355:
4356:
4357:
4358:
4359: public static int mpuISR;
4360:
4361:
4362: public static int mpuSFC;
4363: public static int mpuDFC;
4364: public static int mpuCACR;
4365:
4366:
4367:
4368:
4369:
4370: public static int mpuBUSCR;
4371: public static int mpuUSP;
4372: public static int mpuVBR;
4373: public static int mpuCAAR;
4374: public static int mpuMSP;
4375: public static int mpuISP;
4376:
4377:
4378:
4379: public static int mpuPCR;
4380:
4381:
4382:
4383: public static final int MPU_060_REV = 7;
4384:
4385:
4386:
4387: public static long mpuClockTime;
4388: public static long mpuClockLimit;
4389: public static double mpuClockMHz;
4390: public static double mpuCurrentMHz;
4391: public static int mpuCycleCount;
4392: public static long mpuCycleUnit;
4393: public static long mpuModifiedUnit;
4394: public static long dmaCycleUnit;
4395:
4396:
4397:
4398: public static TimerTask mpuTask;
4399:
4400:
4401: public static int mpuBootDevice;
4402: public static int mpuROMBootHandle;
4403: public static int mpuSavedBootDevice;
4404: public static int mpuSavedROMBootHandle;
4405:
4406:
4407: public static boolean mpuIgnoreAddressError;
4408:
4409:
4410: public static int mpuROMWaitCycles;
4411: public static int mpuRAMWaitCycles;
4412: public static boolean mpuCacheOn;
4413: public static final class WaitTime {
4414: public long ram;
4415: public long gvram;
4416: public long tvram;
4417: public long crtc;
4418: public long palet;
4419: public long vicon;
4420: public long dmac;
4421: public long mfp;
4422: public long rtc;
4423: public long prnport;
4424: public long sysport;
4425: public long opm;
4426: public long adpcm;
4427: public long fdc;
4428: public long fdd;
4429: public long hdc;
4430: public long scc;
4431: public long ppi;
4432: public long ioi;
4433: public long sprc;
4434: public long sram;
4435: public long rom;
4436: public long ramlong;
4437: public long romlong;
4438: }
4439: public static final WaitTime mpuNoWaitTime = new WaitTime ();
4440: public static final WaitTime dmaNoWaitTime = new WaitTime ();
4441: public static final WaitTime mpuWaitTime = new WaitTime ();
4442: public static final WaitTime dmaWaitTime = new WaitTime ();
4443: public static boolean busWaitCyclesRequest;
4444: public static boolean busWaitCycles;
4445: public static WaitTime busWaitTime;
4446:
4447:
4448: public static boolean mpuArbFreqOn;
4449: public static int mpuArbFreqMHz;
4450: public static SpinnerNumberModel mpuArbFreqModel;
4451: public static JSpinner mpuArbFreqSpinner;
4452: public static JRadioButtonMenuItem mpuArbFreqRadioButtonMenuItem;
4453:
4454:
4455: public static boolean mpuUtilOn;
4456: public static int mpuUtilRatio;
4457: public static SpinnerNumberModel mpuUtilModel;
4458: public static JSpinner mpuUtilSpinner;
4459: public static JRadioButtonMenuItem mpuUtilRadioButtonMenuItem;
4460:
4461:
4462: public static final int MPU_ADJUSTMENT_INTERVAL = 100;
4463: public static int mpuAdjustmentCounter;
4464: public static long mpuTotalNano;
4465: public static long mpuLastNano;
4466: public static double mpuCoreNano1;
4467: public static double mpuCoreNano2;
4468:
4469:
4470: public static JMenu mpuMenu;
4471: public static JMenuItem mpuResetMenuItem;
4472: public static JMenuItem mpuOpt1ResetMenuItem;
4473: public static JRadioButtonMenuItem mpuClock10MenuItem;
4474: public static JRadioButtonMenuItem mpuClock16MenuItem;
4475: public static JRadioButtonMenuItem mpuClock25MenuItem;
4476: public static JRadioButtonMenuItem mpuClock33MenuItem;
4477: public static JRadioButtonMenuItem mpuClock50MenuItem;
4478: public static JRadioButtonMenuItem mpuClock66MenuItem;
4479: public static JRadioButtonMenuItem mpuClock75MenuItem;
4480: public static JRadioButtonMenuItem mpuClock100MenuItem;
4481:
4482:
4483: public static ActionListener mpuDebugActionListener;
4484: public static ArrayList<AbstractButton> mpuButtonsRunning;
4485: public static ArrayList<AbstractButton> mpuButtonsStopped;
4486: public static ArrayList<JCheckBox> mpuOriIllegalCheckBoxList;
4487: public static ArrayList<JCheckBox> mpuStopOnErrorCheckBoxList;
4488: public static ArrayList<JCheckBox> mpuStopAtStartCheckBoxList;
4489:
4490: public static int mpuAdvanceCount;
4491: public static int mpuStepCount;
4492: public static boolean mpuContinue;
4493: public static int mpuUntilReturnSRS;
4494: public static int mpuUntilReturnRP;
4495: public static int mpuUntilReturnPC0;
4496: public static int mpuUntilReturnSP;
4497:
4498:
4499:
4500:
4501:
4502:
4503:
4504:
4505:
4506:
4507:
4508:
4509:
4510:
4511:
4512:
4513:
4514:
4515:
4516:
4517:
4518:
4519:
4520:
4521:
4522:
4523:
4524:
4525:
4526:
4527:
4528:
4529:
4530:
4531:
4532:
4533:
4534:
4535:
4536:
4537:
4538:
4539:
4540:
4541:
4542:
4543:
4544:
4545:
4546:
4547:
4548:
4549:
4550:
4551:
4552:
4553:
4554:
4555:
4556:
4557:
4558:
4559:
4560:
4561:
4562:
4563:
4564:
4565:
4566:
4567:
4568:
4569:
4570: public static final boolean MPU_SXMENU = false;
4571:
4572:
4573:
4574: public static void mpuInit () {
4575:
4576: mpuIgnoreAddressError = false;
4577:
4578:
4579:
4580: fpuInit ();
4581:
4582: mpuClockTime = 0L;
4583: mpuClockLimit = 0L;
4584: mpuCycleCount = 0;
4585:
4586: mpuTask = null;
4587:
4588: M68kException.m6eSignal = new M68kException ();
4589: M68kException.m6eNumber = 0;
4590: M68kException.m6eAddress = 0;
4591: M68kException.m6eDirection = MPU_WR_WRITE;
4592: M68kException.m6eSize = MPU_SS_BYTE;
4593:
4594: mpuBootDevice = -1;
4595: mpuROMBootHandle = -1;
4596: mpuSavedBootDevice = -1;
4597: mpuSavedROMBootHandle = -1;
4598:
4599:
4600:
4601:
4602:
4603:
4604:
4605:
4606:
4607:
4608:
4609:
4610:
4611:
4612:
4613: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
4614: mpuTotalNano = 0L;
4615: mpuLastNano = System.nanoTime ();
4616: mpuCoreNano1 = mpuCoreNano2 = 0.5 * 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
4617:
4618: mpuButtonsRunning = new ArrayList<AbstractButton> ();
4619: mpuButtonsStopped = new ArrayList<AbstractButton> ();
4620:
4621: mpuOriIllegalCheckBoxList = new ArrayList<JCheckBox> ();
4622: mpuStopOnErrorCheckBoxList = new ArrayList<JCheckBox> ();
4623: mpuStopAtStartCheckBoxList = new ArrayList<JCheckBox> ();
4624:
4625: mpuAdvanceCount = 0;
4626: mpuStepCount = 0;
4627: mpuContinue = false;
4628: mpuUntilReturnSRS = 0;
4629: mpuUntilReturnRP = 0;
4630: mpuUntilReturnPC0 = 0;
4631: mpuUntilReturnSP = 0;
4632:
4633:
4634: mpuDebugActionListener = new ActionListener () {
4635: @Override public void actionPerformed (ActionEvent ae) {
4636: Object source = ae.getSource ();
4637: switch (ae.getActionCommand ()) {
4638: case "Stop":
4639: if (RootPointerList.RTL_ON) {
4640: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
4641: RootPointerList.rtlCurrentUserTaskIsStoppable) {
4642: mpuStop (null);
4643: }
4644: } else {
4645: mpuStop (null);
4646: }
4647: break;
4648: case "Trace":
4649: mpuAdvance (1);
4650: break;
4651: case "Trace 10 times":
4652: mpuAdvance (10);
4653: break;
4654: case "Trace 100 times":
4655: mpuAdvance (100);
4656: break;
4657: case "Step":
4658: mpuStep (1);
4659: break;
4660: case "Step 10 times":
4661: mpuStep (10);
4662: break;
4663: case "Step 100 times":
4664: mpuStep (100);
4665: break;
4666: case "Step until return":
4667: mpuStepUntilReturn ();
4668: break;
4669: case "Run":
4670: mpuStart ();
4671: break;
4672:
4673: case "Consider ORI.B #$00,D0 as an illegal instruction" :
4674: if (XEiJ.DBG_ORI_BYTE_ZERO_D0) {
4675: dbgOriByteZeroD0 = ((JCheckBox) source).isSelected ();
4676: for (JCheckBox checkBox : mpuOriIllegalCheckBoxList) {
4677: if (checkBox.isSelected () != dbgOriByteZeroD0) {
4678: checkBox.setSelected (dbgOriByteZeroD0);
4679: }
4680: }
4681: }
4682: break;
4683: case "Stop on error":
4684: dbgStopOnError = ((JCheckBox) source).isSelected ();
4685: for (JCheckBox checkBox : mpuStopOnErrorCheckBoxList) {
4686: if (checkBox.isSelected () != dbgStopOnError) {
4687: checkBox.setSelected (dbgStopOnError);
4688: }
4689: }
4690: break;
4691: case "Stop at execution start position":
4692: dbgStopAtStart = ((JCheckBox) source).isSelected ();
4693: for (JCheckBox checkBox : mpuStopAtStartCheckBoxList) {
4694: if (checkBox.isSelected () != dbgStopAtStart) {
4695: checkBox.setSelected (dbgStopAtStart);
4696: }
4697: }
4698: break;
4699: }
4700: }
4701: };
4702:
4703: }
4704:
4705:
4706:
4707: public static JCheckBox mpuMakeOriIllegalCheckBox () {
4708: JCheckBox checkBox = Multilingual.mlnToolTipText (
4709: ComponentFactory.createIconCheckBox (
4710: DBG_ORI_BYTE_ZERO_D0 ? dbgOriByteZeroD0 : null,
4711: LnF.LNF_ORI_BYTE_ZERO_D0_IMAGE,
4712: LnF.LNF_ORI_BYTE_ZERO_D0_SELECTED_IMAGE,
4713: "Consider ORI.B #$00,D0 as an illegal instruction", mpuDebugActionListener),
4714: "ja", "ORI.B #$00,D0 を不当命令とみなす");
4715: mpuOriIllegalCheckBoxList.add (checkBox);
4716: return checkBox;
4717: }
4718:
4719:
4720:
4721: public static JCheckBox mpuMakeStopOnErrorCheckBox () {
4722: JCheckBox checkBox = Multilingual.mlnToolTipText (
4723: ComponentFactory.createIconCheckBox (
4724: dbgStopOnError,
4725: LnF.LNF_STOP_ON_ERROR_IMAGE,
4726: LnF.LNF_STOP_ON_ERROR_SELECTED_IMAGE,
4727: "Stop on error", mpuDebugActionListener),
4728: "ja", "エラーで停止する");
4729: mpuStopOnErrorCheckBoxList.add (checkBox);
4730: return checkBox;
4731: }
4732:
4733:
4734:
4735: public static JCheckBox mpuMakeStopAtStartCheckBox () {
4736: JCheckBox checkBox = Multilingual.mlnToolTipText (
4737: ComponentFactory.createIconCheckBox (
4738: dbgStopAtStart,
4739: LnF.LNF_STOP_AT_START_IMAGE,
4740: LnF.LNF_STOP_AT_START_SELECTED_IMAGE,
4741: "Stop at execution start position", mpuDebugActionListener),
4742: "ja", "実行開始位置で停止する");
4743: mpuStopAtStartCheckBoxList.add (checkBox);
4744: return checkBox;
4745: }
4746:
4747:
4748: public static void mpuMakeMenu () {
4749:
4750: ButtonGroup unitGroup = new ButtonGroup ();
4751: ActionListener listener = new ActionListener () {
4752: @Override public void actionPerformed (ActionEvent ae) {
4753: Object source = ae.getSource ();
4754: switch (ae.getActionCommand ()) {
4755: case "Reset":
4756: mpuReset (-1, -1);
4757: break;
4758: case "Hold down OPT.1 and reset":
4759: mpuReset (0, -1);
4760: break;
4761: case "Interrupt":
4762: sysInterrupt ();
4763: break;
4764: case "10MHz":
4765: mpuArbFreqOn = false;
4766: mpuUtilOn = false;
4767: mpuSetCurrentClock (10.0);
4768: break;
4769: case "16.7MHz":
4770: mpuArbFreqOn = false;
4771: mpuUtilOn = false;
4772: mpuSetCurrentClock (50.0 / 3.0);
4773: break;
4774: case "25MHz":
4775: mpuArbFreqOn = false;
4776: mpuUtilOn = false;
4777: mpuSetCurrentClock (25.0);
4778: break;
4779: case "33.3MHz":
4780: mpuArbFreqOn = false;
4781: mpuUtilOn = false;
4782: mpuSetCurrentClock (100.0 / 3.0);
4783: break;
4784: case "50MHz":
4785: mpuArbFreqOn = false;
4786: mpuUtilOn = false;
4787: mpuSetCurrentClock (50.0);
4788: break;
4789: case "66.7MHz":
4790: mpuArbFreqOn = false;
4791: mpuUtilOn = false;
4792: mpuSetCurrentClock (200.0 / 3.0);
4793: break;
4794: case "75MHz":
4795: mpuArbFreqOn = false;
4796: mpuUtilOn = false;
4797: mpuSetCurrentClock (75.0);
4798: break;
4799: case "100MHz":
4800: mpuArbFreqOn = false;
4801: mpuUtilOn = false;
4802: mpuSetCurrentClock (100.0);
4803: break;
4804: case "Arbitrary frequency":
4805: mpuArbFreqOn = true;
4806: mpuUtilOn = false;
4807: mpuSetCurrentClock ((double) mpuArbFreqMHz);
4808: break;
4809: case "Arbitrary load factor":
4810: mpuArbFreqOn = false;
4811: mpuUtilOn = true;
4812: break;
4813: case "FE function instruction":
4814: FEFunction.fpkOn = ((JCheckBoxMenuItem) source).isSelected ();
4815: break;
4816: case "Reject FLOATn.X":
4817: FEFunction.fpkRejectFloatOn = ((JCheckBoxMenuItem) source).isSelected ();
4818: break;
4819: case "Cut FC2 pin":
4820: busRequestCutFC2Pin = ((JCheckBoxMenuItem) source).isSelected ();
4821: break;
4822: case "Wait cycles":
4823: busWaitCyclesRequest = ((JCheckBoxMenuItem) source).isSelected ();
4824: break;
4825: case "Use IPLROM 1.6":
4826: ROM.romIPLROM16On = ((JCheckBoxMenuItem) source).isSelected ();
4827: break;
4828: case "Increase IPLROM to 256KB":
4829: ROM.romIPLROM256KOn = ((JCheckBoxMenuItem) source).isSelected ();
4830: break;
4831:
4832: case "Run / Stop":
4833: if (((JCheckBox) source).isSelected ()) {
4834: mpuStart ();
4835: } else {
4836: if (RootPointerList.RTL_ON) {
4837: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
4838: RootPointerList.rtlCurrentUserTaskIsStoppable) {
4839: mpuStop (null);
4840: }
4841: } else {
4842: mpuStop (null);
4843: }
4844: }
4845: pnlPanel.requestFocusInWindow ();
4846: break;
4847: }
4848: }
4849: };
4850: mpuMenu = ComponentFactory.createMenu (
4851: "MPU", 'M',
4852: mpuResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset", 'R', MNB_MODIFIERS, listener), "ja", "リセット"),
4853: mpuOpt1ResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Hold down OPT.1 and reset", 'O', MNB_MODIFIERS, listener), "ja", "OPT.1 を押しながらリセット"),
4854: Multilingual.mlnText (ComponentFactory.createMenuItem ("Interrupt", listener), "ja", "インタラプト"),
4855: ComponentFactory.createHorizontalSeparator (),
4856: mdlMenu,
4857: ComponentFactory.createHorizontalSeparator (),
4858: mpuClock10MenuItem = ComponentFactory.createRadioButtonMenuItem (
4859: unitGroup,
4860: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 10.0,
4861: "10MHz",
4862: listener),
4863: mpuClock16MenuItem = ComponentFactory.createRadioButtonMenuItem (
4864: unitGroup,
4865: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0 / 3.0,
4866: "16.7MHz",
4867: listener),
4868: mpuClock25MenuItem = ComponentFactory.createRadioButtonMenuItem (
4869: unitGroup,
4870: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 25.0,
4871: "25MHz",
4872: listener),
4873: mpuClock33MenuItem = ComponentFactory.createRadioButtonMenuItem (
4874: unitGroup,
4875: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0 / 3.0,
4876: "33.3MHz",
4877: listener),
4878: mpuClock50MenuItem = ComponentFactory.createRadioButtonMenuItem (
4879: unitGroup,
4880: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0,
4881: "50MHz",
4882: listener),
4883: mpuClock66MenuItem = ComponentFactory.createRadioButtonMenuItem (
4884: unitGroup,
4885: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 200.0 / 3.0,
4886: "66.7MHz",
4887: listener),
4888: mpuClock75MenuItem = ComponentFactory.createRadioButtonMenuItem (
4889: unitGroup,
4890: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 75.0,
4891: "75MHz",
4892: listener),
4893: mpuClock100MenuItem = ComponentFactory.createRadioButtonMenuItem (
4894: unitGroup,
4895: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0,
4896: "100MHz",
4897: listener),
4898: mpuArbFreqRadioButtonMenuItem = Multilingual.mlnText (
4899: ComponentFactory.createRadioButtonMenuItem (
4900: unitGroup,
4901: mpuArbFreqOn,
4902: "Arbitrary frequency",
4903: listener),
4904: "ja", "任意の周波数"),
4905: ComponentFactory.createHorizontalBox (
4906: Box.createHorizontalStrut (20),
4907: mpuArbFreqSpinner = ComponentFactory.createNumberSpinner (
4908: mpuArbFreqModel = new SpinnerNumberModel (mpuArbFreqMHz, 1, 1000, 1),
4909: 4,
4910: new ChangeListener () {
4911: @Override public void stateChanged (ChangeEvent ce) {
4912:
4913: mpuArbFreqMHz = mpuArbFreqModel.getNumber ().intValue ();
4914: if (mpuArbFreqOn) {
4915: mpuSetCurrentClock ((double) mpuArbFreqMHz);
4916: }
4917: }
4918: }
4919: ),
4920: ComponentFactory.createLabel ("MHz"),
4921: Box.createHorizontalGlue ()
4922: ),
4923: mpuUtilRadioButtonMenuItem = Multilingual.mlnText (
4924: ComponentFactory.createRadioButtonMenuItem (
4925: unitGroup,
4926: mpuUtilOn,
4927: "Arbitrary load factor",
4928: listener),
4929: "ja", "任意の負荷率"),
4930: ComponentFactory.createHorizontalBox (
4931: Box.createHorizontalStrut (20),
4932: mpuUtilSpinner = ComponentFactory.createNumberSpinner (
4933: mpuUtilModel = new SpinnerNumberModel (mpuUtilRatio, 1, 100, 1),
4934: 4,
4935: new ChangeListener () {
4936: @Override public void stateChanged (ChangeEvent ce) {
4937:
4938: mpuUtilRatio = mpuUtilModel.getNumber ().intValue ();
4939: }
4940: }
4941: ),
4942: ComponentFactory.createLabel ("%"),
4943: Box.createHorizontalGlue ()
4944: ),
4945: ComponentFactory.createHorizontalSeparator (),
4946: fpuMenuItem0,
4947: fpuMenuItem1,
4948: fpuMenuItem2,
4949: fpuMenuItem3,
4950: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkOn, "FE function instruction", listener), "ja", "FE ファンクション命令"),
4951: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkRejectFloatOn, "Reject FLOATn.X", listener), "ja", "FLOATn.X を組み込まない"),
4952: ComponentFactory.createHorizontalSeparator (),
4953: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busRequestCutFC2Pin, "Cut FC2 pin", listener), "ja", "FC2 ピンをカットする"),
4954: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busWaitCyclesRequest, "Wait cycles", listener), "ja", "ウェイトサイクル"),
4955: ComponentFactory.createHorizontalSeparator (),
4956: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM16On, "Use IPLROM 1.6", listener), "ja", "IPLROM 1.6 を使う"),
4957: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM256KOn, "Increase IPLROM to 256KB", listener), "ja", "IPLROM を 256KB に増やす")
4958: );
4959: }
4960:
4961:
4962: public static void mpuSetCurrentClock (double clock) {
4963: specifiedClock = clock;
4964: if (currentIsSecond) {
4965: specifiedSecondClock = clock;
4966: } else {
4967: specifiedFirstClock = clock;
4968: }
4969: if (!mpuArbFreqOn && !mpuUtilOn) {
4970: if (specifiedClock == 10.0) {
4971: mpuClock10MenuItem.setSelected (true);
4972: } else if (specifiedClock == 50.0 / 3.0) {
4973: mpuClock16MenuItem.setSelected (true);
4974: } else if (specifiedClock == 25.0) {
4975: mpuClock25MenuItem.setSelected (true);
4976: } else if (specifiedClock == 100.0 / 3.0) {
4977: mpuClock33MenuItem.setSelected (true);
4978: } else if (specifiedClock == 50.0) {
4979: mpuClock50MenuItem.setSelected (true);
4980: } else if (specifiedClock == 200.0 / 3.0) {
4981: mpuClock66MenuItem.setSelected (true);
4982: } else if (specifiedClock == 75.0) {
4983: mpuClock75MenuItem.setSelected (true);
4984: } else if (specifiedClock == 100.0) {
4985: mpuClock100MenuItem.setSelected (true);
4986: }
4987: }
4988: mpuClockMHz = specifiedClock;
4989: mpuSetClockMHz (mpuClockMHz);
4990: }
4991:
4992:
4993:
4994:
4995:
4996:
4997:
4998:
4999:
5000:
5001:
5002: public static void mpuSetClockMHz (double mhz) {
5003: mhz = Math.max (1.0, Math.min (1000.0, mhz));
5004: mpuCurrentMHz = mhz;
5005: mpuCycleUnit = (long) (((double) TMR_FREQ / 1000000.0) / mhz + 0.5);
5006:
5007: mpuModifiedUnit = (currentMPU == Model.MPU_MC68EC030 ||
5008: currentMPU == Model.MPU_MC68030 ?
5009: (long) (((double) TMR_FREQ * 3.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
5010: currentMPU == Model.MPU_MC68LC040 ||
5011: currentMPU == Model.MPU_MC68040 ?
5012: (long) (((double) TMR_FREQ * 2.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
5013: mpuCycleUnit);
5014: }
5015:
5016:
5017:
5018:
5019:
5020:
5021:
5022:
5023:
5024:
5025:
5026:
5027:
5028:
5029:
5030:
5031:
5032:
5033:
5034:
5035:
5036:
5037:
5038:
5039:
5040:
5041:
5042:
5043:
5044:
5045:
5046:
5047:
5048:
5049:
5050:
5051:
5052:
5053:
5054:
5055:
5056:
5057:
5058:
5059:
5060:
5061:
5062:
5063:
5064:
5065:
5066:
5067:
5068:
5069:
5070:
5071:
5072:
5073:
5074:
5075:
5076:
5077:
5078:
5079:
5080:
5081:
5082:
5083:
5084:
5085:
5086:
5087:
5088:
5089:
5090:
5091:
5092:
5093:
5094:
5095:
5096: public static void mpuSetWait () {
5097:
5098: if (currentMPU <= Model.MPU_MC68010) {
5099: mpuWaitTime.ram = mpuCycleUnit >> 3;
5100: mpuWaitTime.vicon = (long) (mpuCycleUnit * 0.6);
5101: mpuWaitTime.crtc =
5102: mpuWaitTime.prnport =
5103: mpuWaitTime.sysport =
5104: mpuWaitTime.sprc =
5105: mpuWaitTime.sram =
5106: mpuWaitTime.rom = mpuCycleUnit;
5107: mpuWaitTime.gvram = (long) (mpuCycleUnit * 1.1);
5108: mpuWaitTime.rtc =
5109: mpuWaitTime.opm =
5110: mpuWaitTime.adpcm =
5111: mpuWaitTime.fdc =
5112: mpuWaitTime.fdd =
5113: mpuWaitTime.hdc =
5114: mpuWaitTime.ppi =
5115: mpuWaitTime.ioi = (long) (mpuCycleUnit * 1.7);
5116: mpuWaitTime.tvram = mpuCycleUnit * 2;
5117: mpuWaitTime.palet = (long) (mpuCycleUnit * 2.6);
5118: mpuWaitTime.mfp = (long) (mpuCycleUnit * 4.3);
5119: mpuWaitTime.scc = mpuCycleUnit * 6;
5120: mpuWaitTime.dmac = mpuCycleUnit * 15;
5121: mpuWaitTime.ramlong = mpuWaitTime.ram << 1;
5122: mpuWaitTime.romlong = mpuWaitTime.rom << 1;
5123: } else if (currentMPU <= Model.MPU_MC68030) {
5124: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
5125: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
5126: mpuWaitTime.sram = mpuCycleUnit * 2;
5127: mpuWaitTime.prnport =
5128: mpuWaitTime.sysport = mpuCycleUnit * 4;
5129: mpuWaitTime.gvram =
5130: mpuWaitTime.crtc =
5131: mpuWaitTime.vicon =
5132: mpuWaitTime.sprc = mpuCycleUnit * 6;
5133: mpuWaitTime.tvram = mpuCycleUnit * 7;
5134: mpuWaitTime.palet = mpuCycleUnit * 11;
5135: mpuWaitTime.opm =
5136: mpuWaitTime.adpcm =
5137: mpuWaitTime.fdc =
5138: mpuWaitTime.fdd =
5139: mpuWaitTime.hdc =
5140: mpuWaitTime.ppi =
5141: mpuWaitTime.ioi = mpuCycleUnit * 15;
5142: mpuWaitTime.mfp = mpuCycleUnit * 19;
5143: mpuWaitTime.rtc = mpuCycleUnit * 28;
5144: mpuWaitTime.dmac = mpuCycleUnit * 34;
5145: mpuWaitTime.scc = mpuCycleUnit * 38;
5146: mpuWaitTime.ramlong = mpuWaitTime.ram;
5147: mpuWaitTime.romlong = mpuWaitTime.rom;
5148: } else {
5149: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
5150: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
5151: mpuWaitTime.sram = mpuCycleUnit * 13;
5152: mpuWaitTime.prnport =
5153: mpuWaitTime.sysport = mpuCycleUnit * 17;
5154: mpuWaitTime.gvram =
5155: mpuWaitTime.crtc =
5156: mpuWaitTime.vicon =
5157: mpuWaitTime.sprc = mpuCycleUnit * 21;
5158: mpuWaitTime.tvram = mpuCycleUnit * 22;
5159: mpuWaitTime.palet = mpuCycleUnit * 33;
5160: mpuWaitTime.opm =
5161: mpuWaitTime.adpcm =
5162: mpuWaitTime.fdc =
5163: mpuWaitTime.fdd =
5164: mpuWaitTime.hdc =
5165: mpuWaitTime.ppi =
5166: mpuWaitTime.ioi = mpuCycleUnit * 37;
5167: mpuWaitTime.mfp = mpuCycleUnit * 47;
5168: mpuWaitTime.dmac = mpuCycleUnit * 73;
5169: mpuWaitTime.rtc = mpuCycleUnit * 77;
5170: mpuWaitTime.scc = mpuCycleUnit * 97;
5171: mpuWaitTime.ramlong = mpuWaitTime.ram;
5172: mpuWaitTime.romlong = mpuWaitTime.rom;
5173: }
5174: if (true) {
5175: mpuNoWaitTime.sram = mpuWaitTime.sram;
5176: mpuNoWaitTime.rom = mpuWaitTime.rom;
5177: mpuNoWaitTime.romlong = mpuWaitTime.romlong;
5178: }
5179:
5180: dmaWaitTime.ram = dmaCycleUnit >> 3;
5181: dmaWaitTime.sram = 0;
5182: dmaWaitTime.rom = 0;
5183: dmaWaitTime.gvram =
5184: dmaWaitTime.crtc =
5185: dmaWaitTime.vicon =
5186: dmaWaitTime.prnport =
5187: dmaWaitTime.sysport =
5188: dmaWaitTime.sprc = dmaCycleUnit;
5189: dmaWaitTime.tvram =
5190: dmaWaitTime.rtc =
5191: dmaWaitTime.opm =
5192: dmaWaitTime.adpcm =
5193: dmaWaitTime.fdc =
5194: dmaWaitTime.fdd =
5195: dmaWaitTime.hdc =
5196: dmaWaitTime.ppi =
5197: dmaWaitTime.ioi = dmaCycleUnit * 2;
5198: dmaWaitTime.palet = dmaCycleUnit * 3;
5199: dmaWaitTime.mfp = dmaCycleUnit * 4;
5200: dmaWaitTime.scc = dmaCycleUnit * 6;
5201: dmaWaitTime.dmac = dmaCycleUnit * 15;
5202: dmaWaitTime.ramlong = dmaWaitTime.ram << 1;
5203: dmaWaitTime.romlong = dmaWaitTime.rom << 1;
5204: }
5205:
5206:
5207:
5208:
5209:
5210: public static void mpuReset (int device, int romHandle) {
5211:
5212: mpuBootDevice = device;
5213: mpuROMBootHandle = romHandle;
5214:
5215:
5216:
5217:
5218:
5219:
5220:
5221:
5222:
5223:
5224:
5225:
5226: if (mpuBootDevice == -1) {
5227: if (mpuSavedBootDevice != -1) {
5228: mpuBootDevice = mpuSavedBootDevice;
5229: mpuROMBootHandle = mpuSavedROMBootHandle;
5230: mpuSavedBootDevice = -1;
5231: mpuSavedROMBootHandle = -1;
5232: }
5233: } else {
5234: if (mpuSavedBootDevice == -1) {
5235: mpuSavedBootDevice = MainMemory.mmrRwz (0x00ed0018);
5236: mpuSavedROMBootHandle = MainMemory.mmrRls (0x00ed000c);
5237: }
5238: }
5239:
5240:
5241: specifiedIsSecond = false;
5242: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
5243: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5244:
5245: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
5246: MC68EC030.m30DivZeroVFlag = false;
5247: }
5248:
5249: if (mpuTask != null) {
5250: mpuClockLimit = 0L;
5251: System.out.println (Multilingual.mlnJapanese ?
5252: "MPU を停止します" :
5253: "MPU stops");
5254: mpuTask.cancel ();
5255: mpuTask = null;
5256: }
5257:
5258: tmrTimer.schedule (new TimerTask () {
5259: @Override public void run () {
5260:
5261:
5262:
5263: currentModel = specifiedModel;
5264: currentAccelerator = specifiedAccelerator;
5265: frmUpdateTitle ();
5266:
5267: currentIsSecond = specifiedIsSecond;
5268: currentFirstMPU = specifiedFirstMPU;
5269: currentSecondMPU = specifiedSecondMPU;
5270: currentMPU = specifiedMPU;
5271:
5272: mpuSetCurrentClock (specifiedClock);
5273:
5274: currentFPU = specifiedFPU;
5275: currentTriplePrecision = specifiedTriplePrecision;
5276: currentFullSpecification = specifiedFullSpecification;
5277:
5278:
5279: if (currentMPU < Model.MPU_MC68020) {
5280: busRequestExMemoryStart = 0x10000000;
5281: busRequestExMemorySize = 0 << 20;
5282: busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
5283: } else if (currentMPU < Model.MPU_MC68LC040 &&
5284: !busHighMemory060turboOn) {
5285: busRequestExMemoryStart = 0x01000000;
5286: busRequestExMemorySize = busHighMemorySize;
5287: busRequestExMemoryArray = busHighMemoryArray;
5288: } else {
5289: busRequestExMemoryStart = 0x10000000;
5290: busRequestExMemorySize = busLocalMemorySize;
5291: busRequestExMemoryArray = busLocalMemoryArray;
5292: }
5293: busUpdateMemoryMap ();
5294:
5295:
5296: ROM.romReset ();
5297:
5298: RegisterList.drpSetMPU ();
5299:
5300: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
5301: mpuPCR = 0x04300500 | MPU_060_REV << 8;
5302: MC68060.mmuReset ();
5303:
5304: if (!currentModel.isX68030 ()) {
5305: dmaCycleUnit = TMR_FREQ / 10000000L;
5306: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
5307: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
5308: mpuROMWaitCycles = 1;
5309: mpuRAMWaitCycles = 0;
5310: } else {
5311: dmaCycleUnit = TMR_FREQ / 12500000L;
5312: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
5313: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
5314: mpuROMWaitCycles = 0;
5315: mpuRAMWaitCycles = 0;
5316: }
5317:
5318: busWaitCycles = busWaitCyclesRequest;
5319: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
5320:
5321: HD63450.dmaReadCycles = (currentModel.isPRO () ? 6 :
5322: currentModel.isCompact () ? 4 :
5323: 5);
5324: HD63450.dmaWriteCycles = (currentModel.isPRO () ? 6 :
5325: 5);
5326:
5327: if (currentMPU < Model.MPU_MC68020) {
5328:
5329: mpuIgnoreAddressError = false;
5330:
5331: mpuCacheOn = false;
5332:
5333: } else if (currentMPU < Model.MPU_MC68040) {
5334:
5335: mpuIgnoreAddressError = true;
5336: fpuBox = fpuMotherboardCoprocessor;
5337: if (currentFPU == 2) {
5338: fpuBox.epbSetMC68882 ();
5339: } else {
5340: fpuBox.epbSetMC68881 ();
5341: }
5342: if (currentTriplePrecision) {
5343: fpuBox.epbSetTriple ();
5344: } else {
5345: fpuBox.epbSetExtended ();
5346: }
5347: fpuBox.epbReset ();
5348: fpuFPn = fpuBox.epbFPn;
5349:
5350: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
5351:
5352: } else {
5353:
5354: mpuIgnoreAddressError = true;
5355: fpuBox = fpuOnChipFPU;
5356: if (currentFullSpecification) {
5357: fpuBox.epbSetFullSpec ();
5358:
5359:
5360: } else {
5361: fpuBox.epbSetMC68060 ();
5362: }
5363: if (currentTriplePrecision) {
5364: fpuBox.epbSetTriple ();
5365: } else {
5366: fpuBox.epbSetExtended ();
5367: }
5368: fpuBox.epbReset ();
5369: fpuFPn = fpuBox.epbFPn;
5370:
5371: mpuPCR = 0x04300500 | MPU_060_REV << 8;
5372: mpuCacheOn = (mpuCACR & 0x80008000) != 0;
5373:
5374: }
5375:
5376: mpuSetWait ();
5377:
5378:
5379: regSRT1 = regSRT0 = 0;
5380: regSRS = REG_SR_S;
5381: regSRM = 0;
5382: regSRI = REG_SR_I;
5383: regCCR = 0;
5384: Arrays.fill (regRn, 0);
5385:
5386: regRn[15] = MainMemory.mmrRls (0x00ff0000);
5387: regPC = MainMemory.mmrRls (0x00ff0004);
5388:
5389: MainMemory.mmrReset ();
5390:
5391: busReset ();
5392: if (InstructionBreakPoint.IBP_ON) {
5393: InstructionBreakPoint.ibpOp1MemoryMap = InstructionBreakPoint.ibpOp1SuperMap;
5394: InstructionBreakPoint.ibpReset ();
5395: }
5396: if (BranchLog.BLG_ON) {
5397: BranchLog.blgReset ();
5398: }
5399:
5400: mpuIMR = 0;
5401: mpuIRR = 0;
5402: if (MC68901.MFP_DELAYED_INTERRUPT) {
5403: mpuDIRR = 0;
5404: }
5405: mpuISR = 0;
5406:
5407:
5408: mpuStart ();
5409: }
5410: }, TMR_DELAY);
5411:
5412: }
5413:
5414:
5415:
5416:
5417:
5418: public static void mpuStart () {
5419: if (mpuTask != null) {
5420: mpuClockLimit = 0L;
5421: System.out.println (Multilingual.mlnJapanese ?
5422: "MPU を停止します" :
5423: "MPU stops");
5424: mpuTask.cancel ();
5425: mpuTask = null;
5426: }
5427:
5428: for (AbstractButton button : mpuButtonsStopped) {
5429: button.setEnabled (false);
5430: }
5431: DisassembleList.ddpStoppedBy = null;
5432: System.out.println (Model.mpuNameOf (currentMPU) + (Multilingual.mlnJapanese ? " を起動します" : " starts up"));
5433: mpuTask = new TimerTask () {
5434: @Override public void run () {
5435: mpuContinue = true;
5436: mpuClockLimit = mpuClockTime + TMR_FREQ * TMR_INTERVAL / 1000;
5437: mpuExecuteCore ();
5438: }
5439: };
5440: tmrTimer.scheduleAtFixedRate (mpuTask, TMR_DELAY, TMR_INTERVAL);
5441:
5442: for (AbstractButton button : mpuButtonsRunning) {
5443: button.setEnabled (true);
5444: }
5445: }
5446:
5447:
5448:
5449: public static void mpuExecuteCore () {
5450:
5451: long nanoStart = System.nanoTime ();
5452:
5453: busSuper (RP5C15.rtcFirst, 0x00e8a000, 0x00e8c000);
5454:
5455:
5456: if (currentMPU < Model.MPU_MC68010) {
5457: MC68000.mpuCore ();
5458: } else if (currentMPU < Model.MPU_MC68020) {
5459: MC68010.mpuCore ();
5460: } else if (currentMPU < Model.MPU_MC68LC040) {
5461: MC68EC030.mpuCore ();
5462: } else {
5463: MC68060.mpuCore ();
5464: }
5465:
5466: if (dbgVisibleMask != 0) {
5467: dbgUpdate ();
5468: }
5469:
5470: long nanoEnd = System.nanoTime ();
5471: mpuTotalNano += nanoEnd - nanoStart;
5472: if (--mpuAdjustmentCounter == 0) {
5473:
5474: final double expectedNano = 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
5475:
5476: double coreNano0 = (double) mpuTotalNano;
5477: mpuTotalNano = 0L;
5478: double coreNanoA = (coreNano0 * 2.0 + mpuCoreNano1 + mpuCoreNano2) * 0.25;
5479: mpuCoreNano2 = mpuCoreNano1;
5480: mpuCoreNano1 = coreNano0;
5481:
5482:
5483:
5484: double actualPercent = Math.max (1.0, 100.0 * coreNanoA / expectedNano);
5485:
5486: double maxPercent = SoundSource.sndPlayOn ? 90.0 : 100.0;
5487:
5488:
5489:
5490:
5491: if (mpuUtilOn) {
5492:
5493: double targetPercent = Math.min (maxPercent, (double) mpuUtilRatio);
5494: mpuSetClockMHz ((1.2 - 0.2 * actualPercent / targetPercent) * mpuCurrentMHz);
5495: } else {
5496: mpuSetClockMHz (Math.min (maxPercent / actualPercent,
5497: 1.2 - 0.2 * mpuCurrentMHz / mpuClockMHz) * mpuCurrentMHz);
5498: }
5499: Indicator.indUpdate (actualPercent);
5500: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
5501: }
5502: }
5503:
5504:
5505:
5506:
5507: public static void mpuStop (String message) {
5508:
5509: mpuAdvanceCount = 0;
5510: mpuStepCount = 0;
5511: mpuContinue = false;
5512: mpuStop1 (message);
5513: }
5514: public static void mpuStop1 (String message) {
5515: if (mpuTask == null) {
5516: return;
5517: }
5518: DisassembleList.ddpStoppedBy = message;
5519: mpuClockLimit = 0L;
5520: System.out.println (Multilingual.mlnJapanese ?
5521: "MPU を停止します" :
5522: "MPU stops");
5523: mpuTask.cancel ();
5524: mpuTask = null;
5525:
5526: if (mpuStepCount != 0 && mpuContinue) {
5527: if (mpuStepCount == -1 || --mpuStepCount != 0) {
5528: mpuStep (mpuStepCount);
5529: return;
5530: }
5531: }
5532: mpuAdvanceCount = 0;
5533: mpuStepCount = 0;
5534: mpuContinue = false;
5535:
5536: for (AbstractButton button : mpuButtonsRunning) {
5537: button.setEnabled (false);
5538: }
5539: tmrTimer.schedule (new TimerTask () {
5540: @Override public void run () {
5541: mpuUpdateWindow ();
5542: }
5543: }, TMR_DELAY);
5544: }
5545:
5546:
5547:
5548:
5549:
5550:
5551: public static void mpuAdvance (int n) {
5552: if (mpuTask != null) {
5553: return;
5554: }
5555: mpuAdvanceCount = n;
5556: DisassembleList.ddpStoppedBy = null;
5557: mpuTask = new TimerTask () {
5558: @Override public void run () {
5559: mpuContinue = true;
5560: do {
5561: mpuClockLimit = mpuClockTime + 1L;
5562: mpuExecuteCore ();
5563: } while (mpuContinue && --mpuAdvanceCount != 0);
5564: mpuClockLimit = 0L;
5565: if (mpuTask != null) {
5566: mpuTask.cancel ();
5567: mpuTask = null;
5568: }
5569: if (mpuStepCount != 0 && mpuContinue) {
5570: if (mpuStepCount == -1 || --mpuStepCount != 0) {
5571: mpuStep (mpuStepCount);
5572: return;
5573: }
5574: }
5575: mpuAdvanceCount = 0;
5576: mpuStepCount = 0;
5577: mpuContinue = false;
5578: mpuUpdateWindow ();
5579: }
5580: };
5581: tmrTimer.schedule (mpuTask, TMR_DELAY);
5582: }
5583:
5584:
5585:
5586:
5587:
5588:
5589: public static void mpuStep (int n) {
5590: if (mpuTask != null) {
5591: return;
5592: }
5593: mpuStepCount = n;
5594: Disassembler.disDisassemble (new StringBuilder (), regPC, regSRS);
5595: if ((Disassembler.disStatus & (Disassembler.DIS_ALWAYS_BRANCH | Disassembler.DIS_SOMETIMES_BRANCH)) != 0) {
5596: if (mpuStepCount == -1 &&
5597: (Disassembler.disOC == 0x4e73 ||
5598: Disassembler.disOC == 0x4e74 ||
5599: Disassembler.disOC == 0x4e75 ||
5600: Disassembler.disOC == 0x4e77) &&
5601: mpuUntilReturnSRS == regSRS &&
5602: (currentMPU < Model.MPU_MC68LC040 ||
5603: mpuUntilReturnRP == (regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP)) &&
5604: mpuUntilReturnPC0 != regPC0 &&
5605: Integer.compareUnsigned (mpuUntilReturnSP, regRn[15]) <= 0) {
5606: mpuAdvanceCount = 0;
5607: mpuStepCount = 0;
5608: mpuContinue = false;
5609: mpuUpdateWindow ();
5610: return;
5611: }
5612: mpuAdvance (1);
5613: } else {
5614: if (InstructionBreakPoint.IBP_ON) {
5615: InstructionBreakPoint.ibpInstant (Disassembler.disPC, DisassembleList.ddpSupervisorMode);
5616: mpuStart ();
5617: }
5618: }
5619: }
5620:
5621:
5622:
5623:
5624:
5625:
5626:
5627:
5628:
5629:
5630:
5631: public static void mpuStepUntilReturn () {
5632: if (mpuTask != null) {
5633: return;
5634: }
5635: mpuUntilReturnSRS = regSRS;
5636: mpuUntilReturnRP = regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP;
5637: mpuUntilReturnPC0 = regPC0;
5638: mpuUntilReturnSP = regRn[15];
5639: mpuStep (-1);
5640: }
5641:
5642:
5643:
5644: public static void mpuUpdateWindow () {
5645: if (dbgVisibleMask != 0) {
5646: if ((dbgVisibleMask & DBG_DDP_VISIBLE_MASK) != 0) {
5647: DisassembleList.ddpBacktraceRecord = -1L;
5648: DisassembleList.ddpUpdate (-1, -1, false);
5649: }
5650: if (BranchLog.BLG_ON) {
5651: if ((dbgVisibleMask & DBG_BLG_VISIBLE_MASK) != 0) {
5652: BranchLog.blgUpdate (BranchLog.BLG_SELECT_NEWEST);
5653: }
5654: }
5655: if (ProgramFlowVisualizer.PFV_ON) {
5656: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
5657: ProgramFlowVisualizer.pfvUpdate ();
5658: }
5659: }
5660: if (RasterBreakPoint.RBP_ON) {
5661: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
5662: RasterBreakPoint.rbpUpdateFrame ();
5663: }
5664: }
5665: if (ScreenModeTest.SMT_ON) {
5666: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
5667: ScreenModeTest.smtUpdateFrame ();
5668: }
5669: }
5670: if (RootPointerList.RTL_ON) {
5671: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
5672: RootPointerList.rtlUpdateFrame ();
5673: }
5674: }
5675: if (SpritePatternViewer.SPV_ON) {
5676: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
5677: SpritePatternViewer.spvUpdateFrame ();
5678: }
5679: }
5680: if (ATCMonitor.ACM_ON) {
5681: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
5682: ATCMonitor.acmUpdateFrame ();
5683: }
5684: }
5685: }
5686:
5687: if (DebugConsole.dgtRequestRegs) {
5688: ExpressionEvaluator.ElementType.ETY_COMMAND_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
5689: DebugConsole.dgtRequestRegs = false;
5690: DebugConsole.dgtPrintPrompt ();
5691: }
5692:
5693: for (AbstractButton button : mpuButtonsRunning) {
5694: button.setEnabled (false);
5695: }
5696:
5697: for (AbstractButton button : mpuButtonsStopped) {
5698: button.setEnabled (true);
5699: }
5700: }
5701:
5702:
5703:
5704: public static JButton mpuMakeBreakButton () {
5705: return mpuAddButtonRunning (
5706: Multilingual.mlnToolTipText (
5707: ComponentFactory.createImageButton (
5708: LnF.LNF_BREAK_IMAGE,
5709: LnF.LNF_BREAK_DISABLED_IMAGE,
5710: "Stop", mpuDebugActionListener),
5711: "ja", "停止")
5712: );
5713: }
5714:
5715:
5716:
5717: public static JButton mpuMakeTraceButton () {
5718: return mpuAddButtonStopped (
5719: Multilingual.mlnToolTipText (
5720: ComponentFactory.createImageButton (
5721: LnF.LNF_TRACE_IMAGE,
5722: LnF.LNF_TRACE_DISABLED_IMAGE,
5723: "Trace", mpuDebugActionListener),
5724: "ja", "トレース")
5725: );
5726: }
5727:
5728:
5729:
5730: public static JButton mpuMakeTrace10Button () {
5731: return mpuAddButtonStopped (
5732: Multilingual.mlnToolTipText (
5733: ComponentFactory.createImageButton (
5734: LnF.LNF_TRACE_10_IMAGE,
5735: LnF.LNF_TRACE_10_DISABLED_IMAGE,
5736: "Trace 10 times", mpuDebugActionListener),
5737: "ja", "トレース 10 回")
5738: );
5739: }
5740:
5741:
5742:
5743: public static JButton mpuMakeTrace100Button () {
5744: return mpuAddButtonStopped (
5745: Multilingual.mlnToolTipText (
5746: ComponentFactory.createImageButton (
5747: LnF.LNF_TRACE_100_IMAGE,
5748: LnF.LNF_TRACE_100_DISABLED_IMAGE,
5749: "Trace 100 times", mpuDebugActionListener),
5750: "ja", "トレース 100 回")
5751: );
5752: }
5753:
5754:
5755:
5756: public static JButton mpuMakeStepButton () {
5757: return mpuAddButtonStopped (
5758: Multilingual.mlnToolTipText (
5759: ComponentFactory.createImageButton (
5760: LnF.LNF_STEP_IMAGE,
5761: LnF.LNF_STEP_DISABLED_IMAGE,
5762: "Step", mpuDebugActionListener),
5763: "ja", "ステップ")
5764: );
5765: }
5766:
5767:
5768:
5769: public static JButton mpuMakeStep10Button () {
5770: return mpuAddButtonStopped (
5771: Multilingual.mlnToolTipText (
5772: ComponentFactory.createImageButton (
5773: LnF.LNF_STEP_10_IMAGE,
5774: LnF.LNF_STEP_10_DISABLED_IMAGE,
5775: "Step 10 times", mpuDebugActionListener),
5776: "ja", "ステップ 10 回")
5777: );
5778: }
5779:
5780:
5781:
5782: public static JButton mpuMakeStep100Button () {
5783: return mpuAddButtonStopped (
5784: Multilingual.mlnToolTipText (
5785: ComponentFactory.createImageButton (
5786: LnF.LNF_STEP_100_IMAGE,
5787: LnF.LNF_STEP_100_DISABLED_IMAGE,
5788: "Step 100 times", mpuDebugActionListener),
5789: "ja", "ステップ 100 回")
5790: );
5791: }
5792:
5793:
5794:
5795: public static JButton mpuMakeReturnButton () {
5796: return mpuAddButtonStopped (
5797: Multilingual.mlnToolTipText (
5798: ComponentFactory.createImageButton (
5799: LnF.LNF_STEP_UNTIL_RETURN_IMAGE,
5800: LnF.LNF_STEP_UNTIL_RETURN_DISABLED_IMAGE,
5801: "Step until return", mpuDebugActionListener),
5802: "ja", "ステップアンティルリターン")
5803: );
5804: }
5805:
5806:
5807:
5808: public static JButton mpuMakeRunButton () {
5809: return mpuAddButtonStopped (
5810: Multilingual.mlnToolTipText (
5811: ComponentFactory.createImageButton (
5812: LnF.LNF_RUN_IMAGE,
5813: LnF.LNF_RUN_DISABLED_IMAGE,
5814: "Run", mpuDebugActionListener),
5815: "ja", "実行")
5816: );
5817: }
5818:
5819:
5820:
5821: public static <T extends AbstractButton> T mpuAddButtonRunning (T button) {
5822: button.setEnabled (mpuTask != null);
5823: mpuButtonsRunning.add (button);
5824: return button;
5825: }
5826:
5827:
5828:
5829: public static <T extends AbstractButton> T mpuAddButtonStopped (T button) {
5830: button.setEnabled (mpuTask == null);
5831: mpuButtonsStopped.add (button);
5832: return button;
5833: }
5834:
5835:
5836:
5837:
5838:
5839:
5840:
5841:
5842:
5843:
5844:
5845:
5846:
5847:
5848:
5849:
5850: public static final int EMX_OPCODE_BASE = 0x4e00;
5851: public static final int EMX_OPCODE_HFSBOOT = EMX_OPCODE_BASE + 0x00;
5852: public static final int EMX_OPCODE_HFSINST = EMX_OPCODE_BASE + 0x01;
5853: public static final int EMX_OPCODE_HFSSTR = EMX_OPCODE_BASE + 0x02;
5854: public static final int EMX_OPCODE_HFSINT = EMX_OPCODE_BASE + 0x03;
5855: public static final int EMX_OPCODE_EMXNOP = EMX_OPCODE_BASE + 0x04;
5856:
5857: public static final String[] EMX_MNEMONIC_ARRAY = {
5858: "hfsboot",
5859: "hfsinst",
5860: "hfsstr",
5861: "hfsint",
5862: "emxnop",
5863: };
5864:
5865:
5866:
5867:
5868: public static void emxNop () {
5869: if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x00007140) {
5870: int head = regRn[9];
5871: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
5872:
5873:
5874: emxPatchPCM8A (head, tail);
5875:
5876:
5877: emxCheckRSDRV202 (head, tail);
5878: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000716c) {
5879: int head = regRn[9];
5880: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
5881:
5882:
5883: emxPatch060turbosys (head, tail);
5884:
5885:
5886: if (Z8530.SCC_FSX_MOUSE) {
5887: emxCheckFSX (head, tail);
5888: }
5889:
5890:
5891: if (HFS.HFS_USE_TWENTY_ONE) {
5892: emxCheckTwentyOne (head, tail);
5893: }
5894:
5895:
5896: LabeledAddress.lblClear ();
5897: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000972c) {
5898: int head = regRn[8] + 256;
5899:
5900: int tail = MC68060.mmuPeekLong (head - 208, 1);
5901:
5902:
5903: emxCheckBSIO021 (head, tail);
5904:
5905:
5906: emxPatchPCM8A (head, tail);
5907:
5908:
5909: emxCheckTMSIO031 (head, tail);
5910:
5911:
5912: LabeledAddress.lblClear ();
5913:
5914:
5915: if (dbgStopAtStart) {
5916: InstructionBreakPoint.ibpInstant (regRn[12], 0);
5917: }
5918: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000a090) {
5919: int head = regRn[8] + 256;
5920: int tail = MC68060.mmuPeekLongData (regRn[8] + 8, 1);
5921: String name = MC68060.mmuPeekStringZ (head - 60, 1);
5922: if (name.equalsIgnoreCase ("fsx.x")) {
5923:
5924:
5925: if (Z8530.SCC_FSX_MOUSE) {
5926: emxCheckFSX (head, tail);
5927: }
5928: }
5929: if (name.equalsIgnoreCase ("TwentyOne.x")) {
5930:
5931:
5932: if (HFS.HFS_USE_TWENTY_ONE) {
5933: emxCheckTwentyOne (head, tail);
5934: }
5935: }
5936: }
5937: }
5938:
5939: public static final int[] emxPCM8AFFMap = {
5940: 0x00000138, 0x000001f6, 0x00000394, 0x000011ec, 0x0000120a, 0x00001400, 0x00001814, 0x00001870, 0x00001882, 0x0000188a,
5941: 0x00001892, 0x000018a2, 0x000018a8, 0x000018ca, 0x000018d4, 0x000018e0, 0x000018e8, 0x00001908, 0x000019e4, 0x00001afa,
5942: 0x00001b58, 0x00001b7c, 0x00001bac, 0x00001c38, 0x00001ccc, 0x000021f8, 0x00002250, 0x00002258, 0x00002290, 0x000022a6,
5943: 0x000022b0, 0x000022c0, 0x000022c8, 0x000022de, 0x000022ea, 0x000030c8, 0x000030de, 0x000030e6, 0x000030ea, 0x000030f6,
5944: 0x00003112, 0x00003188, 0x0000334c, 0x0000338a, 0x000033a2, 0x000033c4, 0x000033d0, 0x0000341a, 0x00003428, 0x00003496,
5945: 0x000034a6, 0x000034d6, 0x0000fe0e, 0x0000fec8, 0x0000feec, 0x0000ff46, 0x0000ff4e,
5946: };
5947:
5948:
5949:
5950: public static void emxPatchPCM8A (int head, int tail) {
5951: if (head + 0x0000ff60 <= tail &&
5952: MC68060.mmuPeekLongData (head + 0x10f8, 1) == 0x50434d38 &&
5953: MC68060.mmuPeekLongData (head + 0x10fc, 1) == 0x41313032) {
5954: System.out.println (Multilingual.mlnJapanese ?
5955: "PCM8A.X 1.02 があります" :
5956: "PCM8A.X 1.02 exists");
5957: int patched = 0;
5958: int failed = 0;
5959:
5960: for (int offset : emxPCM8AFFMap) {
5961: if (MC68060.mmuPeekByteZeroData (head + offset, 1) == 0xff) {
5962: MC68060.mmuPokeByteData (head + offset, 0x00, 1);
5963: patched++;
5964: } else {
5965: failed++;
5966: }
5967: }
5968: if (patched != 0) {
5969: System.out.printf (Multilingual.mlnJapanese ?
5970: "PCM8A.X 1.02 にパッチをあてました (%d/%d)\n" :
5971: "PCM8A.X 1.02 was patched (%d/%d)\n",
5972: patched, patched + failed);
5973: }
5974: }
5975: }
5976:
5977:
5978:
5979: public static void emxPatch060turbosys (int head, int tail) {
5980:
5981:
5982:
5983:
5984: if (head + 0x00002000 <= tail &&
5985: MC68060.mmuPeekLongData (head + 0x00000ec0, 1) == 0x203c302e &&
5986: MC68060.mmuPeekLongData (head + 0x00000ec4, 1) == 0x3536227c &&
5987: MC68060.mmuPeekLongData (head + 0x00000ec8, 1) == 0x30363054) {
5988: System.out.println (Multilingual.mlnJapanese ?
5989: "060turbo.sys 0.56 があります" :
5990: "060turbo.sys 0.56 exists");
5991:
5992:
5993:
5994: int patched = 0;
5995: int failed = 0;
5996: if (MC68060.mmuPeekLongData (head + 0x000021e6, 1) == 0x08f90004 &&
5997: MC68060.mmuPeekLongData (head + 0x000021ea, 1) == 0x00ed0070) {
5998: MC68060.mmuPokeWordData (head + 0x000021e6, 0x0839, 1);
5999: patched++;
6000: } else {
6001: failed++;
6002: }
6003: System.out.printf (Multilingual.mlnJapanese ?
6004: "060turbo.sys 0.56 にパッチをあてました (%d/%d)\n" :
6005: "060turbo.sys 0.56 was patched (%d/%d)\n",
6006: patched, patched + failed);
6007: }
6008: }
6009:
6010:
6011:
6012: public static void emxCheckFSX (int head, int tail) {
6013: if (Z8530.SCC_FSX_MOUSE) {
6014: if (head + 0x00063200 <= tail &&
6015: "\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))) {
6016: System.out.println (Multilingual.mlnJapanese ?
6017: "FSX.X 3.10 があります" :
6018: "FSX.X 3.10 exists");
6019: Z8530.sccFSXMouseHook = head + 0x04f82a;
6020: Z8530.sccFSXMouseWork = head + 0x063184;
6021: }
6022: }
6023: }
6024:
6025:
6026:
6027:
6028:
6029:
6030: public static void emxCheckRSDRV202 (int head, int tail) {
6031: if (head + 0x000ea6 <= tail &&
6032: MC68060.mmuPeekEquals (head + 0x000e4e, "RS-232C DRIVER for X68000 version 2.02")) {
6033: if (RS232CTerminal.trmRSDRV202Head != head) {
6034: RS232CTerminal.trmRSDRV202Head = head;
6035: int[] patchData = {
6036:
6037:
6038: 0x05f8, 0x000a, 0x000b,
6039:
6040: 0x0600, 0xd040, 0x2048,
6041:
6042: 0x060e, 0x3030, 0x4e90,
6043: 0x0610, 0x0000, 0x2048,
6044:
6045: 0x074e, 0x0821, 0x2041,
6046: 0x0750, 0x0410, 0x3200,
6047: 0x0752, 0x0207, 0x303c,
6048: 0x0754, 0x0102, 0x0823,
6049: 0x0756, 0x0080, 0xe268,
6050: 0x0758, 0x003f, 0x72fe,
6051: 0x075a, 0x001f, 0xd141,
6052: 0x075c, 0x000e, 0x2208,
6053: 0x075e, 0x0006, 0x4e75,
6054:
6055:
6056: 0x0ab0, 0x0040, 0x0400,
6057: 0x0ad2, 0x0040, 0x0400,
6058: 0x0af4, 0x0040, 0x0400,
6059: 0x0b16, 0x0040, 0x0400,
6060: 0x0b38, 0x0040, 0x0400,
6061:
6062:
6063: 0x0cae, 0x0009, 0x000b,
6064: };
6065: int patched = 0;
6066: int failed = 0;
6067: for (int i = 0; i < patchData.length; i += 3) {
6068: int a = head + patchData[i];
6069: int b = patchData[i + 1];
6070: int c = patchData[i + 2];
6071: int d = MC68060.mmuPeekWordZeroData (a, 1);
6072: if (d == b) {
6073: MC68060.mmuPokeWordData (a, c, 1);
6074: patched++;
6075: } else if (d != c) {
6076: failed++;
6077: }
6078: }
6079: System.out.printf ("RSDRV.SYS 2.02 found at %08X and patched (%d/%d)\n", head, patched, patched + failed);
6080: }
6081: }
6082: }
6083:
6084:
6085:
6086:
6087:
6088: public static void emxCheckTMSIO031 (int head, int tail) {
6089: if (head + 0x000fc4 <= tail &&
6090: MC68060.mmuPeekEquals (head + 0x000d1c, "TMSIO version 0.31 Copyright (C) 1990-93 by Miki Hoshino")) {
6091: if (RS232CTerminal.trmTMSIO031Head != head) {
6092: RS232CTerminal.trmTMSIO031Head = head;
6093: System.out.printf ("TMSIO 0.31 found at %08X\n", head);
6094: }
6095: }
6096: }
6097:
6098:
6099:
6100:
6101:
6102: public static void emxCheckBSIO021 (int head, int tail) {
6103: if (head + 0x001c2c <= tail &&
6104: MC68060.mmuPeekEquals (head + 0x001a66, "BSIO version 0.21 Copyright (C) 1994 By BAZU")) {
6105: if (RS232CTerminal.trmBSIO021Head != head) {
6106: RS232CTerminal.trmBSIO021Head = head;
6107: System.out.printf ("BSIO 0.21 found at %08X\n", head);
6108: }
6109: }
6110: }
6111:
6112:
6113:
6114: public static void emxCheckTwentyOne (int head, int tail) {
6115: if (HFS.HFS_USE_TWENTY_ONE &&
6116: head + 64 <= tail) {
6117: if (MainMemory.mmrTwentyOneOptionAddress != 0 ||
6118: MainMemory.mmrHumanVersion <= 0) {
6119: return;
6120: }
6121: int name1 = MC68060.mmuPeekLongData (head + 14, 1);
6122: if (name1 == ('*' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
6123: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
6124: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '*')) {
6125: MainMemory.mmrTwentyOneOptionAddress = -1;
6126: }
6127: } else if (name1 == ('?' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
6128: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
6129: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '?') ||
6130: name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | 'E')) {
6131: System.out.println (Multilingual.mlnJapanese ?
6132: "TwentyOne.x があります" :
6133: "TwentyOne.x exists");
6134: MainMemory.mmrTwentyOneOptionAddress = head + 22;
6135: }
6136: }
6137: }
6138: }
6139:
6140:
6141:
6142:
6143:
6144:
6145:
6146:
6147:
6148:
6149:
6150:
6151:
6152:
6153:
6154:
6155:
6156:
6157:
6158:
6159:
6160:
6161:
6162:
6163:
6164:
6165:
6166:
6167:
6168:
6169:
6170:
6171:
6172:
6173:
6174:
6175:
6176:
6177:
6178:
6179:
6180:
6181:
6182:
6183:
6184:
6185:
6186:
6187:
6188:
6189:
6190: public static final boolean IRP_BITREV_REVERSE = false;
6191: public static final boolean IRP_BITREV_SHIFT = false;
6192: public static final boolean IRP_BITREV_TABLE = true;
6193:
6194: public static final boolean IRP_MOVEM_MAINMEMORY = true;
6195: public static final boolean IRP_MOVEM_EXPAND = false;
6196: public static final boolean IRP_MOVEM_LOOP = false;
6197: public static final boolean IRP_MOVEM_SHIFT_LEFT = false;
6198: public static final boolean IRP_MOVEM_SHIFT_RIGHT = true;
6199: public static final boolean IRP_MOVEM_ZEROS = false;
6200:
6201:
6202: public static void irpReset () {
6203:
6204: CRTC.crtReset ();
6205: VideoController.vcnReset ();
6206: HD63450.dmaReset ();
6207: MC68901.mfpReset ();
6208: Keyboard.kbdReset ();
6209: RP5C15.rtcReset ();
6210: PrinterPort.prnReset ();
6211: SoundSource.sndReset ();
6212: OPM.opmReset ();
6213: ADPCM.pcmReset ();
6214: FDC.fdcReset ();
6215: IOInterrupt.ioiReset ();
6216: eb2Reset ();
6217: SPC.spcReset ();
6218: Z8530.sccReset ();
6219: RS232CTerminal.trmReset ();
6220: PPI.ppiReset ();
6221: HFS.hfsReset ();
6222: SpriteScreen.sprReset ();
6223:
6224: xt3Reset ();
6225: SRAM.smrReset ();
6226: CONDevice.conReset ();
6227: }
6228:
6229:
6230:
6231:
6232:
6233:
6234:
6235:
6236:
6237:
6238:
6239:
6240:
6241:
6242:
6243:
6244:
6245:
6246:
6247:
6248:
6249:
6250:
6251:
6252:
6253:
6254:
6255:
6256:
6257:
6258:
6259:
6260:
6261:
6262:
6263:
6264:
6265:
6266:
6267:
6268:
6269:
6270:
6271:
6272:
6273:
6274:
6275:
6276:
6277:
6278:
6279:
6280:
6281:
6282:
6283:
6284:
6285:
6286:
6287:
6288:
6289:
6290:
6291:
6292:
6293:
6294:
6295:
6296:
6297:
6298:
6299:
6300:
6301:
6302:
6303:
6304:
6305:
6306:
6307:
6308:
6309:
6310:
6311:
6312:
6313:
6314:
6315:
6316:
6317:
6318:
6319:
6320:
6321:
6322:
6323:
6324:
6325:
6326:
6327:
6328:
6329:
6330:
6331:
6332:
6333:
6334:
6335:
6336:
6337:
6338:
6339:
6340:
6341:
6342:
6343:
6344:
6345:
6346:
6347:
6348:
6349:
6350:
6351:
6352:
6353:
6354:
6355:
6356:
6357:
6358:
6359:
6360:
6361:
6362:
6363:
6364:
6365:
6366:
6367:
6368:
6369:
6370:
6371:
6372:
6373:
6374:
6375:
6376:
6377:
6378:
6379:
6380:
6381:
6382:
6383:
6384:
6385:
6386:
6387:
6388:
6389:
6390:
6391:
6392:
6393:
6394:
6395:
6396:
6397:
6398:
6399:
6400:
6401:
6402:
6403:
6404:
6405:
6406:
6407:
6408:
6409:
6410:
6411:
6412:
6413:
6414:
6415:
6416:
6417:
6418:
6419:
6420:
6421:
6422:
6423:
6424:
6425:
6426:
6427:
6428:
6429:
6430:
6431:
6432:
6433:
6434:
6435:
6436:
6437:
6438:
6439:
6440:
6441:
6442:
6443:
6444:
6445:
6446:
6447:
6448:
6449:
6450:
6451:
6452:
6453:
6454:
6455:
6456:
6457:
6458:
6459:
6460:
6461:
6462:
6463:
6464:
6465:
6466:
6467:
6468:
6469:
6470:
6471:
6472:
6473:
6474:
6475:
6476:
6477:
6478:
6479:
6480:
6481:
6482:
6483:
6484:
6485:
6486:
6487:
6488:
6489:
6490:
6491:
6492:
6493:
6494:
6495:
6496:
6497:
6498:
6499:
6500:
6501:
6502:
6503:
6504:
6505:
6506:
6507:
6508:
6509:
6510:
6511:
6512:
6513:
6514:
6515:
6516:
6517:
6518:
6519:
6520:
6521:
6522:
6523:
6524:
6525:
6526:
6527:
6528:
6529:
6530:
6531:
6532:
6533:
6534:
6535:
6536:
6537:
6538:
6539:
6540:
6541:
6542:
6543:
6544:
6545:
6546:
6547:
6548:
6549:
6550:
6551:
6552:
6553:
6554:
6555:
6556:
6557:
6558:
6559:
6560:
6561:
6562:
6563:
6564:
6565:
6566:
6567:
6568:
6569:
6570:
6571:
6572:
6573:
6574:
6575:
6576:
6577:
6578:
6579:
6580:
6581:
6582:
6583:
6584:
6585:
6586:
6587:
6588:
6589:
6590:
6591:
6592:
6593:
6594:
6595:
6596:
6597:
6598:
6599:
6600:
6601:
6602:
6603:
6604:
6605:
6606:
6607:
6608:
6609:
6610:
6611:
6612:
6613:
6614:
6615:
6616:
6617:
6618:
6619:
6620:
6621:
6622:
6623:
6624:
6625:
6626:
6627:
6628:
6629:
6630:
6631:
6632:
6633:
6634:
6635:
6636:
6637:
6638:
6639:
6640:
6641:
6642:
6643:
6644:
6645:
6646:
6647:
6648:
6649:
6650:
6651:
6652:
6653:
6654:
6655:
6656:
6657:
6658:
6659:
6660:
6661:
6662:
6663:
6664:
6665:
6666:
6667:
6668:
6669:
6670:
6671:
6672:
6673:
6674:
6675:
6676:
6677:
6678:
6679:
6680:
6681:
6682:
6683:
6684:
6685:
6686:
6687:
6688:
6689:
6690:
6691:
6692:
6693:
6694:
6695:
6696:
6697:
6698:
6699:
6700:
6701:
6702:
6703:
6704:
6705:
6706:
6707:
6708:
6709:
6710:
6711:
6712:
6713:
6714:
6715:
6716:
6717:
6718:
6719:
6720:
6721:
6722:
6723:
6724:
6725:
6726:
6727:
6728:
6729:
6730:
6731:
6732:
6733:
6734:
6735:
6736:
6737:
6738:
6739:
6740:
6741:
6742:
6743:
6744:
6745:
6746:
6747:
6748:
6749:
6750:
6751:
6752:
6753:
6754:
6755:
6756:
6757:
6758:
6759:
6760:
6761:
6762:
6763:
6764:
6765:
6766:
6767:
6768:
6769:
6770:
6771:
6772:
6773:
6774:
6775:
6776:
6777:
6778:
6779:
6780:
6781:
6782:
6783:
6784:
6785:
6786:
6787:
6788:
6789:
6790:
6791:
6792:
6793:
6794:
6795:
6796:
6797:
6798:
6799:
6800:
6801:
6802:
6803:
6804:
6805:
6806:
6807:
6808:
6809:
6810:
6811:
6812:
6813:
6814: 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);
6815:
6816: public static final boolean EFA_SEPARATE_AR = false;
6817:
6818:
6819:
6820:
6821:
6822:
6823: public static final boolean BUS_SPLIT_UNALIGNED_LONG = false;
6824:
6825:
6826: public static final int BUS_MOTHER_BITS = 24;
6827: public static final int BUS_MOTHER_SIZE = BUS_MOTHER_BITS < 32 ? 1 << BUS_MOTHER_BITS : 0;
6828: public static final int BUS_MOTHER_MASK = BUS_MOTHER_SIZE - 1;
6829:
6830: public static final int BUS_DUMMY_4BIT_PAGE = BUS_MOTHER_SIZE;
6831: public static final int BUS_DUMMY_4BIT_SIZE = 2 * 512 * 512;
6832:
6833: public static final int BUS_MODIFIED_256_PAGE = BUS_DUMMY_4BIT_PAGE + BUS_DUMMY_4BIT_SIZE;
6834: public static final int BUS_MODIFIED_256_SIZE = 2 * 1024 * 1024;
6835:
6836: public static final int BUS_MODIFIED_65536_PAGE = BUS_MODIFIED_256_PAGE + BUS_MODIFIED_256_SIZE;
6837: public static final int BUS_MODIFIED_65536_SIZE = 2 * 1024 * 1024;
6838:
6839: public static final int BUS_ARRAY_SIZE = BUS_MODIFIED_65536_PAGE + BUS_MODIFIED_65536_SIZE;
6840:
6841:
6842: public static final int BUS_PAGE_BITS = 12;
6843: public static final int BUS_PAGE_SIZE = 1 << BUS_PAGE_BITS;
6844: public static final int BUS_PAGE_COUNT = 1 << (32 - BUS_PAGE_BITS);
6845:
6846:
6847: public static final int MPU_SS_BYTE = 0;
6848: public static final int MPU_SS_WORD = 1;
6849: public static final int MPU_SS_LONG = 2;
6850:
6851:
6852: public static final int MPU_WR_WRITE = 0;
6853: public static final int MPU_WR_READ = 1;
6854:
6855:
6856: public static final int MPU_US_USER = 0;
6857: public static final int MPU_US_SUPERVISOR = 1;
6858:
6859:
6860: public static final MemoryMappedDevice[] busUserMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
6861: public static final MemoryMappedDevice[] busSuperMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
6862: public static MemoryMappedDevice[] busMemoryMap;
6863:
6864:
6865: public static final int BUS_HIGH_MEMORY_START = 0x01000000;
6866: public static int busHighMemorySize;
6867: public static byte[] busHighMemoryArray;
6868: public static boolean busHighMemorySaveOn;
6869: public static boolean busHighMemory060turboOn;
6870:
6871:
6872: public static final int BUS_LOCAL_MEMORY_START = 0x10000000;
6873: public static int busLocalMemorySize;
6874: public static byte[] busLocalMemoryArray;
6875: public static boolean busLocalMemorySaveOn;
6876:
6877:
6878: public static final byte[] BUS_DUMMY_MEMORY_ARRAY = new byte[0];
6879: public static int busRequestExMemoryStart;
6880: public static int busRequestExMemorySize;
6881: public static byte[] busRequestExMemoryArray;
6882: public static int busExMemoryStart;
6883: public static int busExMemorySize;
6884: public static byte[] busExMemoryArray;
6885:
6886:
6887: public static boolean busRequestCutFC2Pin;
6888: public static boolean busCutFC2Pin;
6889:
6890:
6891:
6892: public static void busInit () {
6893:
6894:
6895: if (!DataBreakPoint.DBP_ON) {
6896: busMemoryMap = busSuperMap;
6897: }
6898:
6899:
6900: int highMemorySizeMB = Settings.sgsGetInt ("highmemory");
6901: busHighMemorySize = highMemorySizeMB == 16 ? highMemorySizeMB << 20 : 0 << 20;
6902: if (busHighMemorySize == 0) {
6903: System.out.println (Multilingual.mlnJapanese ?
6904: "X68030/Xellent30 のハイメモリはありません" :
6905: "X68030/Xellent30 high memory does not exists");
6906: } else {
6907: System.out.printf (Multilingual.mlnJapanese ?
6908: "X68030/Xellent30 のハイメモリのサイズは %dMB です\n" :
6909: "X68030/Xellent30 high memory size is %dMB\n",
6910: busHighMemorySize >> 20);
6911: }
6912: busHighMemoryArray = new byte[busHighMemorySize];
6913:
6914: busHighMemorySaveOn = Settings.sgsGetOnOff ("highmemorysave");
6915: busHighMemory060turboOn = Settings.sgsGetOnOff ("highmemory060turbo");
6916:
6917: byte[] highMemoryArray = Settings.sgsGetData ("highmemorydata");
6918: if (busHighMemorySize != 0) {
6919: if (highMemoryArray.length != 0) {
6920: System.out.println (Multilingual.mlnJapanese ?
6921: "X68030/Xellent30 のハイメモリのデータを復元します" :
6922: "X68030/Xellent30 high memory data is restored");
6923: System.arraycopy (highMemoryArray, 0, busHighMemoryArray, 0, Math.min (highMemoryArray.length, busHighMemorySize));
6924: } else {
6925: System.out.println (Multilingual.mlnJapanese ?
6926: "X68030/Xellent30 のハイメモリをゼロクリアします" :
6927: "X68030/Xellent30 high memory is zero-cleared");
6928: }
6929: if (highMemoryArray.length < busHighMemorySize) {
6930: Arrays.fill (busHighMemoryArray, highMemoryArray.length, busHighMemorySize, (byte) 0);
6931: }
6932: }
6933:
6934:
6935: int localMemorySizeMB = Settings.sgsGetInt ("localmemory");
6936: busLocalMemorySize = (localMemorySizeMB == 16 ||
6937: localMemorySizeMB == 32 ||
6938: localMemorySizeMB == 64 ||
6939: localMemorySizeMB == 128 ||
6940: localMemorySizeMB == 256 ||
6941: localMemorySizeMB == 384 ||
6942: localMemorySizeMB == 512 ||
6943: localMemorySizeMB == 768 ?
6944: localMemorySizeMB << 20 :
6945: 128 << 20);
6946: if (busLocalMemorySize == 0) {
6947: System.out.println (Multilingual.mlnJapanese ?
6948: "060turbo のハイメモリはありません" :
6949: "060turbo high memory does not exists");
6950: } else {
6951: System.out.printf (Multilingual.mlnJapanese ?
6952: "060turbo のハイメモリのサイズは %dMB です\n" :
6953: "060turbo high memory size is %dMB\n",
6954: busLocalMemorySize >> 20);
6955: }
6956: busLocalMemoryArray = new byte[busLocalMemorySize];
6957:
6958: busLocalMemorySaveOn = Settings.sgsGetOnOff ("localmemorysave");
6959:
6960: byte[] localMemoryArray = Settings.sgsGetData ("localmemorydata");
6961: if (busLocalMemorySize != 0) {
6962: if (localMemoryArray.length != 0) {
6963: System.out.println (Multilingual.mlnJapanese ?
6964: "060turbo のハイメモリのデータを復元します" :
6965: "060turbo high memory data is restored");
6966: System.arraycopy (localMemoryArray, 0, busLocalMemoryArray, 0, Math.min (localMemoryArray.length, busLocalMemorySize));
6967: } else {
6968: System.out.println (Multilingual.mlnJapanese ?
6969: "060turbo のハイメモリをゼロクリアします" :
6970: "060turbo high memory is zero-cleared");
6971: }
6972: if (localMemoryArray.length < busLocalMemorySize) {
6973: Arrays.fill (busLocalMemoryArray, localMemoryArray.length, busLocalMemorySize, (byte) 0);
6974: }
6975: }
6976:
6977:
6978: busExMemoryStart = busRequestExMemoryStart = 0x10000000;
6979: busExMemorySize = busRequestExMemorySize = 0 << 20;
6980: busExMemoryArray = busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
6981:
6982:
6983: busRequestCutFC2Pin = Settings.sgsGetOnOff ("cutfc2pin");
6984: busCutFC2Pin = !busRequestCutFC2Pin;
6985:
6986: busUpdateMemoryMap ();
6987:
6988: }
6989:
6990:
6991:
6992: public static void busTini () {
6993: Settings.sgsPutInt ("highmemory", busHighMemorySize >>> 20);
6994: Settings.sgsPutOnOff ("highmemorysave", busHighMemorySaveOn);
6995: Settings.sgsPutOnOff ("highmemory060turbo", busHighMemory060turboOn);
6996: Settings.sgsPutData ("highmemorydata", busHighMemorySaveOn ? busHighMemoryArray : new byte[0]);
6997: Settings.sgsPutInt ("localmemory", busLocalMemorySize >>> 20);
6998: Settings.sgsPutOnOff ("localmemorysave", busLocalMemorySaveOn);
6999: Settings.sgsPutData ("localmemorydata", busLocalMemorySaveOn ? busLocalMemoryArray : new byte[0]);
7000: Settings.sgsPutOnOff ("cutfc2pin", busRequestCutFC2Pin);
7001: }
7002:
7003: public static void busUpdateMemoryMap () {
7004: if (busExMemoryStart == busRequestExMemoryStart &&
7005: busExMemorySize == busRequestExMemorySize &&
7006: busExMemoryArray == busRequestExMemoryArray &&
7007: busExMemoryArray.length == busExMemorySize &&
7008: busCutFC2Pin == busRequestCutFC2Pin) {
7009: return;
7010: }
7011:
7012: busExMemoryStart = busRequestExMemoryStart;
7013: busExMemorySize = busRequestExMemorySize;
7014: busExMemoryArray = busRequestExMemoryArray;
7015: if (busExMemoryArray.length != busExMemorySize) {
7016: byte[] newArray = new byte[busExMemorySize];
7017: int copySize = Math.min (busExMemoryArray.length, busExMemorySize);
7018: if (copySize > 0) {
7019: System.arraycopy (busExMemoryArray, 0, newArray, 0, copySize);
7020: }
7021: if (busExMemoryArray == busHighMemoryArray) {
7022: busHighMemoryArray = newArray;
7023: } else if (busExMemoryArray == busLocalMemoryArray) {
7024: busLocalMemoryArray = newArray;
7025: }
7026: busExMemoryArray = newArray;
7027: }
7028:
7029: busCutFC2Pin = busRequestCutFC2Pin;
7030:
7031:
7032:
7033:
7034:
7035:
7036:
7037:
7038:
7039:
7040:
7041:
7042: busSuper (MemoryMappedDevice.MMD_MMR, 0x00000000, 0x00002000);
7043: busUser ( MemoryMappedDevice.MMD_MMR, 0x00002000, 0x00c00000);
7044:
7045:
7046:
7047:
7048:
7049:
7050:
7051:
7052:
7053:
7054:
7055:
7056:
7057:
7058:
7059:
7060:
7061:
7062:
7063:
7064:
7065:
7066:
7067:
7068: busSuper (MemoryMappedDevice.MMD_GE0, 0x00c00000, 0x00c80000);
7069: busSuper (MemoryMappedDevice.MMD_GE1, 0x00c80000, 0x00d00000);
7070: busSuper (MemoryMappedDevice.MMD_GE2, 0x00d00000, 0x00d80000);
7071: busSuper (MemoryMappedDevice.MMD_GE3, 0x00d80000, 0x00e00000);
7072:
7073:
7074:
7075:
7076: busSuper (MemoryMappedDevice.MMD_TXT, 0x00e00000, 0x00e80000);
7077:
7078:
7079:
7080:
7081: busSuper (MemoryMappedDevice.MMD_CRT, 0x00e80000, 0x00e82000);
7082:
7083:
7084:
7085:
7086:
7087: busSuper (MemoryMappedDevice.MMD_VCN, 0x00e82000, 0x00e84000);
7088:
7089:
7090:
7091:
7092: busSuper (MemoryMappedDevice.MMD_DMA, 0x00e84000, 0x00e86000);
7093:
7094:
7095:
7096:
7097: busSuper (MemoryMappedDevice.MMD_SVS, 0x00e86000, 0x00e88000);
7098:
7099:
7100:
7101:
7102: busSuper (MemoryMappedDevice.MMD_MFP, 0x00e88000, 0x00e8a000);
7103:
7104:
7105:
7106:
7107: busSuper (MemoryMappedDevice.MMD_RTC_FIRST, 0x00e8a000, 0x00e8c000);
7108:
7109:
7110:
7111:
7112: busSuper (MemoryMappedDevice.MMD_PRN, 0x00e8c000, 0x00e8e000);
7113:
7114:
7115:
7116:
7117: busSuper (MemoryMappedDevice.MMD_SYS, 0x00e8e000, 0x00e90000);
7118:
7119:
7120:
7121:
7122: busSuper (MemoryMappedDevice.MMD_OPM, 0x00e90000, 0x00e92000);
7123:
7124:
7125:
7126:
7127: busSuper (MemoryMappedDevice.MMD_PCM, 0x00e92000, 0x00e94000);
7128:
7129:
7130:
7131:
7132: busSuper (MemoryMappedDevice.MMD_FDC, 0x00e94000, 0x00e96000);
7133:
7134:
7135:
7136:
7137:
7138: busSuper (MemoryMappedDevice.MMD_HDC, 0x00e96000, 0x00e98000);
7139:
7140:
7141:
7142:
7143: busSuper (MemoryMappedDevice.MMD_SCC, 0x00e98000, 0x00e9a000);
7144:
7145:
7146:
7147:
7148: busSuper (MemoryMappedDevice.MMD_PPI, 0x00e9a000, 0x00e9c000);
7149:
7150:
7151:
7152:
7153: busSuper (MemoryMappedDevice.MMD_IOI, 0x00e9c000, 0x00e9e000);
7154:
7155:
7156:
7157:
7158:
7159:
7160:
7161:
7162:
7163: busSuper (MemoryMappedDevice.MMD_XB1, 0x00e9e000, 0x00ea0000);
7164:
7165:
7166:
7167:
7168:
7169: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ea0000, 0x00eae000);
7170:
7171:
7172:
7173:
7174:
7175:
7176:
7177:
7178:
7179:
7180:
7181:
7182:
7183: busSuper (MemoryMappedDevice.MMD_XB2, 0x00eae000, 0x00eb0000);
7184:
7185:
7186:
7187:
7188:
7189:
7190:
7191:
7192: busSuper (MemoryMappedDevice.MMD_SPR, 0x00eb0000, 0x00ec0000);
7193:
7194:
7195:
7196:
7197:
7198:
7199:
7200:
7201:
7202: busSuper (MemoryMappedDevice.MMD_XB3, 0x00ec0000, 0x00ed0000);
7203:
7204:
7205:
7206:
7207:
7208:
7209: busSuper (MemoryMappedDevice.MMD_SMR, 0x00ed0000, 0x00ed0000 + 16384);
7210: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ed0000 + 16384, 0x00ed0000 + 65536);
7211:
7212:
7213:
7214:
7215:
7216:
7217:
7218:
7219: busSuper (MemoryMappedDevice.MMD_XB4, 0x00ee0000, 0x00f00000);
7220:
7221:
7222:
7223:
7224:
7225:
7226:
7227:
7228:
7229:
7230: busSuper (MemoryMappedDevice.MMD_CG1, 0x00f00000, 0x00f40000);
7231:
7232:
7233:
7234:
7235:
7236:
7237:
7238: busSuper (MemoryMappedDevice.MMD_CG2, 0x00f40000, 0x00fc0000);
7239:
7240:
7241:
7242:
7243:
7244:
7245:
7246:
7247:
7248:
7249:
7250:
7251:
7252:
7253: busSuper (MemoryMappedDevice.MMD_ROM, 0x00fc0000, 0x01000000);
7254:
7255: }
7256:
7257: public static void busReset () {
7258: if (regSRS != 0) {
7259: if (DataBreakPoint.DBP_ON) {
7260: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpSuperMap;
7261: } else {
7262: busMemoryMap = busSuperMap;
7263: }
7264: } else {
7265: if (DataBreakPoint.DBP_ON) {
7266: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpUserMap;
7267: } else {
7268: busMemoryMap = busUserMap;
7269: }
7270: }
7271: }
7272:
7273:
7274:
7275:
7276:
7277: public static void busUser (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
7278: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
7279: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
7280: if (false &&
7281: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
7282: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
7283: System.out.printf ("ERROR: busUser (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
7284: }
7285: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
7286: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
7287: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
7288: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
7289: int startPage = blockStartPage + motherStartPage;
7290: int endPage = blockStartPage + motherEndPage;
7291: for (int page = startPage; page < endPage; page++) {
7292: MemoryMappedDevice superMmd = exMemoryStartPage <= page && page < exMemoryEndPage ? MemoryMappedDevice.MMD_XMM : mmd;
7293: busUserMap[page] = busSuperMap[page] = superMmd;
7294: if (InstructionBreakPoint.IBP_ON) {
7295: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
7296: InstructionBreakPoint.ibpUserMap[page] = superMmd;
7297: }
7298: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
7299: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
7300: }
7301: }
7302: if (DataBreakPoint.DBP_ON) {
7303: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
7304: DataBreakPoint.dbpUserMap[page] = superMmd;
7305: }
7306: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
7307: DataBreakPoint.dbpSuperMap[page] = superMmd;
7308: }
7309: }
7310: }
7311: }
7312: }
7313:
7314:
7315:
7316:
7317:
7318: public static void busSuper (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
7319: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
7320: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
7321: if (false &&
7322: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
7323: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
7324: System.out.printf ("ERROR: busSuper (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
7325: }
7326: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
7327: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
7328: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
7329: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
7330: int startPage = blockStartPage + motherStartPage;
7331: int endPage = blockStartPage + motherEndPage;
7332: for (int page = startPage; page < endPage; page++) {
7333: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
7334: MemoryMappedDevice userMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : busCutFC2Pin ? mmd : MemoryMappedDevice.MMD_NUL;
7335: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
7336: busUserMap[page] = userMmd;
7337: busSuperMap[page] = superMmd;
7338: if (InstructionBreakPoint.IBP_ON) {
7339: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
7340: InstructionBreakPoint.ibpUserMap[page] = userMmd;
7341: }
7342: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
7343: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
7344: }
7345: }
7346: if (DataBreakPoint.DBP_ON) {
7347: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
7348: DataBreakPoint.dbpUserMap[page] = userMmd;
7349: }
7350: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
7351: DataBreakPoint.dbpSuperMap[page] = superMmd;
7352: }
7353: }
7354: }
7355: }
7356: }
7357:
7358:
7359:
7360: public static byte busPbs (int a) {
7361: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a);
7362: }
7363:
7364:
7365:
7366: public static int busPbz (int a) {
7367: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a);
7368: }
7369:
7370:
7371:
7372: public static int busPws (int a) {
7373: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7374: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
7375: } else {
7376: int a1 = a + 1;
7377: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
7378: }
7379: }
7380:
7381:
7382:
7383: public static int busPwse (int a) {
7384: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
7385: }
7386:
7387:
7388:
7389: public static int busPwz (int a) {
7390: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7391: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
7392: } else {
7393: int a1 = a + 1;
7394: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
7395: }
7396: }
7397:
7398:
7399:
7400: public static int busPwze (int a) {
7401: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
7402: }
7403:
7404:
7405:
7406: public static int busPls (int a) {
7407: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
7408: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
7409: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7410: int a2 = a + 2;
7411: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a) << 16 | busSuperMap[a2 >>> BUS_PAGE_BITS].mmdPwz (a2);
7412: } else {
7413: int a1 = a + 1;
7414: int a3 = a + 3;
7415: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 24 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPwz (a1) << 8 | busSuperMap[a3 >>> BUS_PAGE_BITS].mmdPbz (a3);
7416: }
7417: }
7418:
7419:
7420:
7421: public static int busPlsf (int a) {
7422: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
7423: }
7424:
7425:
7426:
7427: public static long busPqs (int a) {
7428: return (long) busPls (a) << 32 | busPls (a + 4) & 0xffffffffL;
7429: }
7430:
7431:
7432:
7433: public static int busSearchByte (int start, int end, int c) {
7434: for (int a = start; a < end; a++) {
7435: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) == c) {
7436: return a;
7437: }
7438: }
7439: return -1;
7440: }
7441: public static int busSearchWord (int start, int end, int c) {
7442: for (int a = start; a < end; a += 2) {
7443: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) == c) {
7444: return a;
7445: }
7446: }
7447: return -1;
7448: }
7449: public static int busSearchByteArray (int start, int end, int[] array) {
7450: int l = array.length;
7451: end -= l;
7452: int c = array[0];
7453: a:
7454: for (int a = start; a <= end; a++) {
7455: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) != c) {
7456: continue a;
7457: }
7458: for (int i = 1, b = a + 1; i < l; i++, b++) {
7459: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPbz (b) != array[i]) {
7460: continue a;
7461: }
7462: }
7463: return a;
7464: }
7465: return -1;
7466: }
7467: public static int busSearchWordArray (int start, int end, int[] array) {
7468: int l = array.length;
7469: end -= l;
7470: int c = array[0];
7471: a:
7472: for (int a = start; a <= end; a += 2) {
7473: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) != c) {
7474: continue a;
7475: }
7476: for (int i = 1, b = a + 2; i < l; i++, b += 2) {
7477: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPwz (b) != array[i]) {
7478: continue a;
7479: }
7480: }
7481: return a;
7482: }
7483: return -1;
7484: }
7485:
7486:
7487:
7488:
7489: public static byte busRbs (int a) throws M68kException {
7490: if (DataBreakPoint.DBP_ON) {
7491: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
7492: } else {
7493: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
7494: }
7495: }
7496:
7497:
7498:
7499: public static int busRbz (int a) throws M68kException {
7500: if (DataBreakPoint.DBP_ON) {
7501: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
7502: } else {
7503: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
7504: }
7505: }
7506:
7507:
7508:
7509: public static int busRws (int a) throws M68kException {
7510: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7511: if (DataBreakPoint.DBP_ON) {
7512: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
7513: } else {
7514: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
7515: }
7516: } else if (mpuIgnoreAddressError) {
7517: int a1 = a + 1;
7518: if (DataBreakPoint.DBP_ON) {
7519: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
7520: } else {
7521: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
7522: }
7523: } else {
7524: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
7525: M68kException.m6eAddress = a;
7526: M68kException.m6eDirection = MPU_WR_READ;
7527: M68kException.m6eSize = MPU_SS_WORD;
7528: throw M68kException.m6eSignal;
7529: }
7530: }
7531:
7532:
7533:
7534:
7535: public static int busRwse (int a) throws M68kException {
7536: if (DataBreakPoint.DBP_ON) {
7537: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
7538: } else {
7539: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
7540: }
7541: }
7542:
7543:
7544:
7545: public static int busRwz (int a) throws M68kException {
7546: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7547: if (DataBreakPoint.DBP_ON) {
7548: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
7549: } else {
7550: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
7551: }
7552: } else if (mpuIgnoreAddressError) {
7553: int a1 = a + 1;
7554: if (DataBreakPoint.DBP_ON) {
7555: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
7556: } else {
7557: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
7558: }
7559: } else {
7560: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
7561: M68kException.m6eAddress = a;
7562: M68kException.m6eDirection = MPU_WR_READ;
7563: M68kException.m6eSize = MPU_SS_WORD;
7564: throw M68kException.m6eSignal;
7565: }
7566: }
7567:
7568:
7569:
7570:
7571: public static int busRwze (int a) throws M68kException {
7572: if (DataBreakPoint.DBP_ON) {
7573: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
7574: } else {
7575: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
7576: }
7577: }
7578:
7579:
7580:
7581: public static int busRls (int a) throws M68kException {
7582: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
7583: if (DataBreakPoint.DBP_ON) {
7584: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
7585: } else {
7586: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
7587: }
7588: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7589: int a2 = a + 2;
7590: if (BUS_SPLIT_UNALIGNED_LONG) {
7591: if (DataBreakPoint.DBP_ON) {
7592: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
7593: } else {
7594: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
7595: }
7596: } else {
7597: MemoryMappedDevice mmd;
7598: MemoryMappedDevice mmd2;
7599: if (DataBreakPoint.DBP_ON) {
7600: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
7601: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
7602: } else {
7603: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
7604: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
7605: }
7606: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
7607: }
7608: } else if (mpuIgnoreAddressError) {
7609: int a1 = a + 1;
7610: int a3 = a + 3;
7611: if (DataBreakPoint.DBP_ON) {
7612: 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);
7613: } else {
7614: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 24 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRwz (a1) << 8 | busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdRbz (a3);
7615: }
7616: } else {
7617: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
7618: M68kException.m6eAddress = a;
7619: M68kException.m6eDirection = MPU_WR_READ;
7620: M68kException.m6eSize = MPU_SS_LONG;
7621: throw M68kException.m6eSignal;
7622: }
7623: }
7624:
7625:
7626:
7627:
7628: public static int busRlse (int a) throws M68kException {
7629: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
7630: if (DataBreakPoint.DBP_ON) {
7631: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
7632: } else {
7633: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
7634: }
7635: } else {
7636: int a2 = a + 2;
7637: if (BUS_SPLIT_UNALIGNED_LONG) {
7638: if (DataBreakPoint.DBP_ON) {
7639: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
7640: } else {
7641: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
7642: }
7643: } else {
7644: MemoryMappedDevice mmd;
7645: MemoryMappedDevice mmd2;
7646: if (DataBreakPoint.DBP_ON) {
7647: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
7648: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
7649: } else {
7650: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
7651: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
7652: }
7653: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
7654: }
7655: }
7656: }
7657:
7658:
7659:
7660:
7661: public static int busRlsf (int a) throws M68kException {
7662: if (DataBreakPoint.DBP_ON) {
7663: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
7664: } else {
7665: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
7666: }
7667: }
7668:
7669:
7670:
7671: public static long busRqs (int a) throws M68kException {
7672: return (long) busRls (a) << 32 | busRls (a + 4) & 0xffffffffL;
7673: }
7674:
7675:
7676:
7677: public static void busWb (int a, int d) throws M68kException {
7678: if (DataBreakPoint.DBP_ON) {
7679: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
7680: } else {
7681: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
7682: }
7683: }
7684:
7685:
7686:
7687: public static void busWw (int a, int d) throws M68kException {
7688: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7689: if (DataBreakPoint.DBP_ON) {
7690: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
7691: } else {
7692: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
7693: }
7694: } else if (mpuIgnoreAddressError) {
7695: int a1 = a + 1;
7696: if (DataBreakPoint.DBP_ON) {
7697: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
7698: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
7699: } else {
7700: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
7701: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
7702: }
7703: } else {
7704: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
7705: M68kException.m6eAddress = a;
7706: M68kException.m6eDirection = MPU_WR_WRITE;
7707: M68kException.m6eSize = MPU_SS_WORD;
7708: throw M68kException.m6eSignal;
7709: }
7710: }
7711:
7712:
7713:
7714:
7715: public static void busWwe (int a, int d) throws M68kException {
7716: if (DataBreakPoint.DBP_ON) {
7717: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
7718: } else {
7719: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
7720: }
7721: }
7722:
7723:
7724:
7725: public static void busWl (int a, int d) throws M68kException {
7726: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
7727: if (DataBreakPoint.DBP_ON) {
7728: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
7729: } else {
7730: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
7731: }
7732: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7733: int a2 = a + 2;
7734: if (BUS_SPLIT_UNALIGNED_LONG) {
7735: if (DataBreakPoint.DBP_ON) {
7736: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
7737: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
7738: } else {
7739: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
7740: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
7741: }
7742: } else {
7743: MemoryMappedDevice mmd;
7744: MemoryMappedDevice mmd2;
7745: if (DataBreakPoint.DBP_ON) {
7746: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
7747: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
7748: } else {
7749: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
7750: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
7751: }
7752: if (mmd == mmd2) {
7753: mmd.mmdWl (a, d);
7754: } else {
7755: mmd.mmdWw (a, d >> 16);
7756: mmd2.mmdWw (a2, d);
7757: }
7758: }
7759: } else if (mpuIgnoreAddressError) {
7760: int a1 = a + 1;
7761: int a3 = a + 3;
7762: if (DataBreakPoint.DBP_ON) {
7763: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
7764: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
7765: DataBreakPoint.dbpMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
7766: } else {
7767: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
7768: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
7769: busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
7770: }
7771: } else {
7772: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
7773: M68kException.m6eAddress = a;
7774: M68kException.m6eDirection = MPU_WR_WRITE;
7775: M68kException.m6eSize = MPU_SS_LONG;
7776: throw M68kException.m6eSignal;
7777: }
7778: }
7779:
7780:
7781:
7782:
7783: public static void busWlf (int a, int d) throws M68kException {
7784: if (DataBreakPoint.DBP_ON) {
7785: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
7786: } else {
7787: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
7788: }
7789: }
7790:
7791:
7792:
7793:
7794: public static void busWle (int a, int d) throws M68kException {
7795: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
7796: if (DataBreakPoint.DBP_ON) {
7797: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
7798: } else {
7799: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
7800: }
7801: } else {
7802: int a2 = a + 2;
7803: if (BUS_SPLIT_UNALIGNED_LONG) {
7804: if (DataBreakPoint.DBP_ON) {
7805: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
7806: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
7807: } else {
7808: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
7809: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
7810: }
7811: } else {
7812: MemoryMappedDevice mmd;
7813: MemoryMappedDevice mmd2;
7814: if (DataBreakPoint.DBP_ON) {
7815: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
7816: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
7817: } else {
7818: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
7819: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
7820: }
7821: if (mmd == mmd2) {
7822: mmd.mmdWl (a, d);
7823: } else {
7824: mmd.mmdWw (a, d >> 16);
7825: mmd2.mmdWw (a2, d);
7826: }
7827: }
7828: }
7829: }
7830:
7831:
7832:
7833: public static void busWq (int a, long d) throws M68kException {
7834: busWl (a, (int) (d >>> 32));
7835: busWl (a + 4, (int) d);
7836: }
7837:
7838:
7839:
7840:
7841:
7842: public static void busRbb (int a, byte[] bb, int o, int l) throws M68kException {
7843: if (false) {
7844: for (int i = 0; i < l; i++) {
7845: int ai = a + i;
7846: if (DataBreakPoint.DBP_ON) {
7847: bb[o + i] = DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
7848: } else {
7849: bb[o + i] = busMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
7850: }
7851: }
7852: } else {
7853: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
7854: while (l > 0) {
7855: MemoryMappedDevice mmd;
7856: if (DataBreakPoint.DBP_ON) {
7857: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
7858: } else {
7859: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
7860: }
7861: int s = l <= r ? l : r;
7862: l -= s;
7863: if (true) {
7864: for (s -= 16; s >= 0; s -= 16) {
7865: bb[o ] = mmd.mmdRbs (a );
7866: bb[o + 1] = mmd.mmdRbs (a + 1);
7867: bb[o + 2] = mmd.mmdRbs (a + 2);
7868: bb[o + 3] = mmd.mmdRbs (a + 3);
7869: bb[o + 4] = mmd.mmdRbs (a + 4);
7870: bb[o + 5] = mmd.mmdRbs (a + 5);
7871: bb[o + 6] = mmd.mmdRbs (a + 6);
7872: bb[o + 7] = mmd.mmdRbs (a + 7);
7873: bb[o + 8] = mmd.mmdRbs (a + 8);
7874: bb[o + 9] = mmd.mmdRbs (a + 9);
7875: bb[o + 10] = mmd.mmdRbs (a + 10);
7876: bb[o + 11] = mmd.mmdRbs (a + 11);
7877: bb[o + 12] = mmd.mmdRbs (a + 12);
7878: bb[o + 13] = mmd.mmdRbs (a + 13);
7879: bb[o + 14] = mmd.mmdRbs (a + 14);
7880: bb[o + 15] = mmd.mmdRbs (a + 15);
7881: a += 16;
7882: o += 16;
7883: }
7884: s += 16;
7885: }
7886: for (int i = 0; i < s; i++) {
7887: bb[o + i] = mmd.mmdRbs (a + i);
7888: }
7889: a += s;
7890: o += s;
7891: r = BUS_PAGE_SIZE;
7892: }
7893: }
7894: }
7895:
7896:
7897:
7898: public static void busWbb (int a, byte[] bb, int o, int l) throws M68kException {
7899: if (false) {
7900: for (int i = 0; i < l; i++) {
7901: int ai = a + i;
7902: if (DataBreakPoint.DBP_ON) {
7903: DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
7904: } else {
7905: busMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
7906: }
7907: }
7908: } else {
7909: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
7910: while (l > 0) {
7911: MemoryMappedDevice mmd;
7912: if (DataBreakPoint.DBP_ON) {
7913: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
7914: } else {
7915: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
7916: }
7917: int s = l <= r ? l : r;
7918: l -= s;
7919: if (true) {
7920: for (s -= 16; s >= 0; s -= 16) {
7921: mmd.mmdWb (a , bb[o ]);
7922: mmd.mmdWb (a + 1, bb[o + 1]);
7923: mmd.mmdWb (a + 2, bb[o + 2]);
7924: mmd.mmdWb (a + 3, bb[o + 3]);
7925: mmd.mmdWb (a + 4, bb[o + 4]);
7926: mmd.mmdWb (a + 5, bb[o + 5]);
7927: mmd.mmdWb (a + 6, bb[o + 6]);
7928: mmd.mmdWb (a + 7, bb[o + 7]);
7929: mmd.mmdWb (a + 8, bb[o + 8]);
7930: mmd.mmdWb (a + 9, bb[o + 9]);
7931: mmd.mmdWb (a + 10, bb[o + 10]);
7932: mmd.mmdWb (a + 11, bb[o + 11]);
7933: mmd.mmdWb (a + 12, bb[o + 12]);
7934: mmd.mmdWb (a + 13, bb[o + 13]);
7935: mmd.mmdWb (a + 14, bb[o + 14]);
7936: mmd.mmdWb (a + 15, bb[o + 15]);
7937: a += 16;
7938: o += 16;
7939: }
7940: s += 16;
7941: }
7942: for (int i = 0; i < s; i++) {
7943: mmd.mmdWb (a + i, bb[o + i]);
7944: }
7945: a += s;
7946: o += s;
7947: r = BUS_PAGE_SIZE;
7948: }
7949: }
7950: }
7951:
7952:
7953:
7954: public static void busVb (int a, int d) {
7955: try {
7956: if (DataBreakPoint.DBP_ON) {
7957: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWb (a, d);
7958: } else {
7959: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
7960: }
7961: } catch (M68kException e) {
7962: }
7963: }
7964:
7965:
7966:
7967: public static void busVw (int a, int d) {
7968: try {
7969: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7970: if (DataBreakPoint.DBP_ON) {
7971: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWw (a, d);
7972: } else {
7973: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
7974: }
7975: }
7976: } catch (M68kException e) {
7977: }
7978: }
7979:
7980:
7981:
7982: public static void busVl (int a, int d) {
7983: try {
7984: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
7985: if (DataBreakPoint.DBP_ON) {
7986: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWl (a, d);
7987: } else {
7988: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
7989: }
7990: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7991: int a2 = a + 2;
7992: MemoryMappedDevice mmd;
7993: MemoryMappedDevice mmd2;
7994: if (DataBreakPoint.DBP_ON) {
7995: mmd = (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS];
7996: mmd2 = (regSRS != 0 ? busSuperMap : busUserMap)[a2 >>> BUS_PAGE_BITS];
7997: } else {
7998: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
7999: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8000: }
8001: if (mmd == mmd2) {
8002: mmd.mmdWl (a, d);
8003: } else {
8004: mmd.mmdWw (a, d >> 16);
8005: mmd2.mmdWw (a2, d);
8006: }
8007: }
8008: } catch (M68kException e) {
8009: }
8010: }
8011:
8012:
8013:
8014:
8015:
8016:
8017:
8018:
8019:
8020:
8021:
8022:
8023:
8024:
8025:
8026:
8027:
8028:
8029:
8030:
8031:
8032:
8033:
8034:
8035:
8036:
8037:
8038:
8039:
8040:
8041:
8042:
8043:
8044:
8045:
8046:
8047:
8048: public static void graInit () {
8049: }
8050:
8051:
8052:
8053:
8054:
8055:
8056:
8057:
8058: public static void txtInit () {
8059: }
8060:
8061:
8062:
8063:
8064:
8065: public static final int SVS_AREASET = 0x00e86001;
8066:
8067:
8068:
8069:
8070:
8071:
8072:
8073:
8074:
8075: public static void svsInit () {
8076: }
8077:
8078:
8079:
8080:
8081:
8082:
8083:
8084:
8085:
8086:
8087:
8088:
8089:
8090:
8091:
8092:
8093:
8094:
8095:
8096:
8097:
8098:
8099:
8100:
8101:
8102:
8103:
8104:
8105:
8106:
8107:
8108:
8109:
8110:
8111:
8112: public static boolean sysNMIFlag;
8113:
8114:
8115:
8116: public static void sysInit () {
8117: sysNMIFlag = false;
8118: }
8119:
8120:
8121:
8122:
8123:
8124:
8125: public static int sysAcknowledge () {
8126: return M68kException.M6E_LEVEL_7_INTERRUPT_AUTOVECTOR;
8127: }
8128:
8129:
8130:
8131:
8132: public static void sysDone () {
8133: if (sysNMIFlag) {
8134: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
8135: }
8136: }
8137:
8138:
8139:
8140: public static void sysInterrupt () {
8141: sysNMIFlag = true;
8142: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
8143: }
8144:
8145:
8146:
8147: public static void sysResetNMI () {
8148: sysNMIFlag = false;
8149: }
8150:
8151:
8152:
8153:
8154:
8155:
8156: public static final int EB2_SPC_REQUEST = 0x4000;
8157: public static final int EB2_SPC_VECTOR = 0xf6;
8158:
8159:
8160:
8161: public static int eb2Request;
8162:
8163:
8164:
8165: public static void eb2Reset () {
8166: eb2Request = 0;
8167: }
8168:
8169:
8170:
8171:
8172:
8173: public static void eb2Interrupt (int mask) {
8174: eb2Request |= mask;
8175: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
8176: }
8177:
8178:
8179:
8180:
8181:
8182:
8183:
8184: public static int eb2Acknowledge () {
8185: if ((eb2Request & EB2_SPC_REQUEST) != 0) {
8186: eb2Request &= ~EB2_SPC_REQUEST;
8187: return EB2_SPC_VECTOR;
8188: }
8189: return 0;
8190: }
8191:
8192:
8193:
8194:
8195:
8196: public static void eb2Done () {
8197: if (eb2Request != 0) {
8198: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
8199: }
8200: }
8201:
8202:
8203:
8204:
8205:
8206:
8207:
8208:
8209:
8210:
8211:
8212:
8213:
8214:
8215:
8216:
8217:
8218:
8219:
8220:
8221:
8222:
8223:
8224:
8225:
8226:
8227:
8228:
8229:
8230:
8231:
8232:
8233:
8234:
8235:
8236:
8237:
8238:
8239:
8240:
8241:
8242:
8243:
8244:
8245:
8246:
8247:
8248:
8249:
8250:
8251:
8252:
8253:
8254:
8255:
8256:
8257:
8258:
8259:
8260:
8261:
8262:
8263:
8264:
8265:
8266:
8267:
8268:
8269:
8270:
8271:
8272:
8273:
8274:
8275:
8276:
8277:
8278:
8279:
8280:
8281:
8282:
8283:
8284:
8285:
8286: public static final int BNK_SIZE = 1024 * 1024 * 32;
8287: public static byte[] bnkMemory;
8288: public static int bnkPageStart;
8289: public static boolean bnkOn;
8290:
8291: public static void bnkInit () {
8292: bnkMemory = new byte[BNK_SIZE];
8293: byte[] array = Settings.sgsGetData ("bankdata");
8294: if (array.length != 0) {
8295: System.arraycopy (array, 0, bnkMemory, 0, Math.min (array.length, BNK_SIZE));
8296: }
8297: bnkPageStart = 0;
8298:
8299: bnkOn = false;
8300: }
8301:
8302: public static void bnkTini () {
8303: Settings.sgsPutData ("bankdata", bnkMemory, 0, BNK_SIZE);
8304: }
8305:
8306:
8307:
8308:
8309:
8310:
8311:
8312: public static ExpressionEvaluator fpuMotherboardCoprocessor;
8313: public static ExpressionEvaluator fpuOnChipFPU;
8314: public static ExpressionEvaluator fpuBox;
8315:
8316:
8317: public static EFPBox fpuCoproboard1;
8318: public static EFPBox fpuCoproboard2;
8319:
8320:
8321: public static EFPBox.EFP[] fpuFPn;
8322:
8323:
8324:
8325: public static final int FPU_FPCR_BSUN = 0b00000000_00000000_10000000_00000000;
8326: public static final int FPU_FPCR_SNAN = 0b00000000_00000000_01000000_00000000;
8327: public static final int FPU_FPCR_OPERR = 0b00000000_00000000_00100000_00000000;
8328: public static final int FPU_FPCR_OVFL = 0b00000000_00000000_00010000_00000000;
8329: public static final int FPU_FPCR_UNFL = 0b00000000_00000000_00001000_00000000;
8330: public static final int FPU_FPCR_DZ = 0b00000000_00000000_00000100_00000000;
8331: public static final int FPU_FPCR_INEX2 = 0b00000000_00000000_00000010_00000000;
8332: public static final int FPU_FPCR_INEX1 = 0b00000000_00000000_00000001_00000000;
8333:
8334:
8335: public static final int FPU_FPCR_PE = 0b00000000_00000000_00000000_00000000;
8336: public static final int FPU_FPCR_PS = 0b00000000_00000000_00000000_01000000;
8337: public static final int FPU_FPCR_PD = 0b00000000_00000000_00000000_10000000;
8338:
8339: public static final int FPU_FPCR_RN = 0b00000000_00000000_00000000_00000000;
8340: public static final int FPU_FPCR_RZ = 0b00000000_00000000_00000000_00010000;
8341: public static final int FPU_FPCR_RM = 0b00000000_00000000_00000000_00100000;
8342: public static final int FPU_FPCR_RP = 0b00000000_00000000_00000000_00110000;
8343:
8344:
8345:
8346: public static final int FPU_FPSR_N = 0b00001000_00000000_00000000_00000000;
8347: public static final int FPU_FPSR_Z = 0b00000100_00000000_00000000_00000000;
8348: public static final int FPU_FPSR_I = 0b00000010_00000000_00000000_00000000;
8349: public static final int FPU_FPSR_NAN = 0b00000001_00000000_00000000_00000000;
8350:
8351: public static final int FPU_FPSR_S = 0b00000000_10000000_00000000_00000000;
8352: public static final int FPU_FPSR_QUOTIENT = 0b00000000_01111111_00000000_00000000;
8353:
8354: public static final int FPU_FPSR_EXC_BSUN = 0b00000000_00000000_10000000_00000000;
8355: public static final int FPU_FPSR_EXC_SNAN = 0b00000000_00000000_01000000_00000000;
8356: public static final int FPU_FPSR_EXC_OPERR = 0b00000000_00000000_00100000_00000000;
8357: public static final int FPU_FPSR_EXC_OVFL = 0b00000000_00000000_00010000_00000000;
8358: public static final int FPU_FPSR_EXC_UNFL = 0b00000000_00000000_00001000_00000000;
8359: public static final int FPU_FPSR_EXC_DZ = 0b00000000_00000000_00000100_00000000;
8360: public static final int FPU_FPSR_EXC_INEX2 = 0b00000000_00000000_00000010_00000000;
8361: public static final int FPU_FPSR_EXC_INEX1 = 0b00000000_00000000_00000001_00000000;
8362:
8363: public static final int FPU_FPSR_AEXC_IOP = 0b00000000_00000000_00000000_10000000;
8364: public static final int FPU_FPSR_AEXC_OVFL = 0b00000000_00000000_00000000_01000000;
8365: public static final int FPU_FPSR_AEXC_UNFL = 0b00000000_00000000_00000000_00100000;
8366: public static final int FPU_FPSR_AEXC_DZ = 0b00000000_00000000_00000000_00010000;
8367: public static final int FPU_FPSR_AEXC_INEX = 0b00000000_00000000_00000000_00001000;
8368:
8369:
8370:
8371:
8372:
8373:
8374:
8375: public static final int[] FPU_FPSR_EXC_TO_AEXC = new int[256];
8376:
8377:
8378:
8379:
8380:
8381:
8382:
8383:
8384:
8385:
8386:
8387:
8388:
8389:
8390:
8391:
8392:
8393:
8394:
8395:
8396:
8397:
8398:
8399:
8400: public static final boolean[] FPU_CCMAP_882 = {
8401:
8402:
8403: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
8404: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
8405: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
8406: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
8407: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
8408: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
8409: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
8410: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
8411: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
8412: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
8413: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
8414: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
8415: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
8416: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
8417: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
8418: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
8419:
8420:
8421: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
8422: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
8423: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
8424: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
8425: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
8426: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
8427: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
8428: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
8429: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
8430: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
8431: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
8432: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
8433: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
8434: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
8435: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
8436: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
8437:
8438: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
8439: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
8440: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
8441: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
8442: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
8443: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
8444: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
8445: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
8446: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
8447: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
8448: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
8449: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
8450: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
8451: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
8452: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
8453: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
8454:
8455: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
8456: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
8457: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
8458: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
8459: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
8460: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
8461: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
8462: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
8463: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
8464: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
8465: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
8466: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
8467: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
8468: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
8469: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
8470: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
8471: };
8472:
8473:
8474:
8475:
8476:
8477:
8478:
8479: public static final boolean[] FPU_CCMAP_060 = {
8480:
8481:
8482: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
8483: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
8484: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
8485: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
8486: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
8487: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
8488: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
8489: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
8490: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
8491: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
8492: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
8493: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
8494: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
8495: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
8496: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
8497: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
8498:
8499:
8500: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
8501: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
8502: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
8503: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
8504: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
8505: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
8506: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
8507: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
8508: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
8509: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
8510: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
8511: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
8512: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
8513: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
8514: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
8515: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
8516:
8517: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
8518: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
8519: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
8520: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
8521: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
8522: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
8523: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
8524: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
8525: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
8526: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
8527: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
8528: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
8529: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
8530: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
8531: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
8532: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
8533:
8534: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
8535: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
8536: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
8537: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
8538: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
8539: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
8540: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
8541: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
8542: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
8543: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
8544: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
8545: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
8546: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
8547: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
8548: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
8549: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
8550: };
8551:
8552:
8553:
8554:
8555: public static void fpuInit () {
8556: for (int i = 0; i < 256; i++) {
8557: 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) |
8558: ((i << 8 & FPU_FPSR_EXC_OVFL) != 0 ? FPU_FPSR_AEXC_OVFL : 0) |
8559: ((i << 8 & (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2)) == (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2) ? FPU_FPSR_AEXC_UNFL : 0) |
8560: ((i << 8 & FPU_FPSR_EXC_DZ) != 0 ? FPU_FPSR_AEXC_DZ : 0) |
8561: ((i << 8 & (FPU_FPSR_EXC_OVFL | FPU_FPSR_EXC_INEX2 | FPU_FPSR_EXC_INEX1)) != 0 ? FPU_FPSR_AEXC_INEX : 0));
8562: }
8563:
8564: fpuMotherboardCoprocessor = new ExpressionEvaluator ();
8565:
8566: fpuOnChipFPU = new ExpressionEvaluator ();
8567:
8568: fpuBox = currentMPU < Model.MPU_MC68LC040 ? fpuMotherboardCoprocessor : fpuOnChipFPU;
8569:
8570: fpuFPn = fpuBox.epbFPn;
8571:
8572: fpuCoproboard1 = new EFPBox ();
8573: fpuCoproboard1.epbSetMC68881 ();
8574: fpuCoproboard2 = new EFPBox ();
8575: fpuCoproboard2.epbSetMC68881 ();
8576: }
8577:
8578:
8579:
8580:
8581:
8582:
8583: public static final boolean DBG_ORI_BYTE_ZERO_D0 = true;
8584:
8585: public static boolean dbgHexSelected;
8586: public static int dbgHexValue;
8587: public static int dbgSupervisorMode;
8588: public static JPopupMenu dbgPopupMenu;
8589: public static JMenu dbgPopupIBPMenu;
8590: public static SpinnerNumberModel dbgPopupIBPCurrentModel;
8591: public static int dbgPopupIBPCurrentValue;
8592: public static SpinnerNumberModel dbgPopupIBPThresholdModel;
8593: public static int dbgPopupIBPThresholdValue;
8594: public static JMenuItem dbgPopupIBPClearMenuItem;
8595: public static JMenu dbgPopupHexMenu;
8596: public static JMenuItem dbgPopupDisMenuItem;
8597: public static JMenuItem dbgPopupMemMenuItem;
8598: public static JMenuItem dbgPopupCopyMenuItem;
8599: public static JMenuItem dbgPopupSelectAllMenuItem;
8600: public static JTextArea dbgPopupTextArea;
8601: public static int dbgEventMask;
8602: public static boolean dbgStopOnError;
8603: public static boolean dbgOriByteZeroD0;
8604: public static boolean dbgStopAtStart;
8605:
8606:
8607:
8608: public static final char[] DBG_SPACES = (
8609:
8610:
8611: " ").toCharArray ();
8612:
8613: public static final int DBG_DRP_VISIBLE_MASK = 1;
8614: public static final int DBG_DDP_VISIBLE_MASK = 2;
8615: public static final int DBG_DMP_VISIBLE_MASK = 4;
8616: public static final int DBG_BLG_VISIBLE_MASK = 8;
8617: public static final int DBG_PFV_VISIBLE_MASK = 16;
8618: public static final int DBG_RBP_VISIBLE_MASK = 32;
8619: public static final int DBG_DBP_VISIBLE_MASK = 64;
8620: public static final int DBG_SMT_VISIBLE_MASK = 128;
8621: public static final int DBG_ATW_VISIBLE_MASK = 256;
8622: public static final int DBG_PAA_VISIBLE_MASK = 512;
8623: public static final int DBG_RTL_VISIBLE_MASK = 1024;
8624: public static final int DBG_SPV_VISIBLE_MASK = 2048;
8625: public static final int DBG_ACM_VISIBLE_MASK = 4096;
8626: public static int dbgVisibleMask;
8627:
8628:
8629:
8630: public static void dbgInit () {
8631: dbgVisibleMask = 0;
8632: dbgHexSelected = false;
8633: dbgHexValue = 0;
8634: dbgSupervisorMode = 1;
8635: dbgPopupMenu = null;
8636: dbgPopupDisMenuItem = null;
8637: dbgPopupMemMenuItem = null;
8638: dbgPopupCopyMenuItem = null;
8639: dbgPopupSelectAllMenuItem = null;
8640: dbgPopupIBPMenu = null;
8641: dbgPopupIBPCurrentModel = null;
8642: dbgPopupIBPCurrentValue = 0;
8643: dbgPopupIBPThresholdModel = null;
8644: dbgPopupIBPThresholdValue = 0;
8645: dbgPopupHexMenu = null;
8646: dbgPopupTextArea = null;
8647: dbgEventMask = 0;
8648: dbgStopOnError = false;
8649: if (DBG_ORI_BYTE_ZERO_D0) {
8650: dbgOriByteZeroD0 = false;
8651: }
8652: dbgStopAtStart = false;
8653: }
8654:
8655:
8656:
8657: public static void dbgMakePopup () {
8658:
8659:
8660: ActionListener popupActionListener = new ActionListener () {
8661: @Override public void actionPerformed (ActionEvent ae) {
8662: switch (ae.getActionCommand ()) {
8663: case "Disassemble":
8664: DisassembleList.ddpBacktraceRecord = -1L;
8665: DisassembleList.ddpOpen (dbgHexValue, dbgSupervisorMode, false);
8666: break;
8667: case "Memory Dump":
8668: MemoryDumpList.dmpOpen (dbgHexValue, dbgSupervisorMode, false);
8669: break;
8670: case "Run to Here":
8671: if (InstructionBreakPoint.IBP_ON) {
8672: if (mpuTask == null) {
8673: InstructionBreakPoint.ibpInstant (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
8674: mpuStart ();
8675: }
8676: }
8677: break;
8678: case "Set Breakpoint":
8679: if (InstructionBreakPoint.IBP_ON) {
8680: InstructionBreakPoint.ibpPut (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode, dbgPopupIBPCurrentValue, dbgPopupIBPThresholdValue, null);
8681: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
8682: }
8683: break;
8684: case "Clear Breakpoint":
8685: if (InstructionBreakPoint.IBP_ON) {
8686: InstructionBreakPoint.ibpRemove (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
8687: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
8688: }
8689: break;
8690: case "Copy":
8691: dbgCopy ();
8692: break;
8693: case "Select All":
8694: dbgSelectAll ();
8695: break;
8696: }
8697: }
8698: };
8699: dbgPopupMenu = ComponentFactory.createPopupMenu (
8700: dbgPopupIBPMenu =
8701: InstructionBreakPoint.IBP_ON ?
8702: ComponentFactory.createMenu (
8703: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
8704: Multilingual.mlnText (ComponentFactory.createMenuItem ("Run to Here", 'R', popupActionListener), "ja", "ここまで実行"),
8705: ComponentFactory.createHorizontalSeparator (),
8706: Multilingual.mlnText (ComponentFactory.createMenuItem ("Set Breakpoint", 'S', popupActionListener), "ja", "ブレークポイントを設定"),
8707: ComponentFactory.createHorizontalBox (
8708: Box.createHorizontalStrut (7),
8709: Box.createHorizontalGlue (),
8710: ComponentFactory.setPreferredSize (
8711: Multilingual.mlnText (ComponentFactory.createLabel ("current"), "ja", "現在値"),
8712: 60, 16),
8713: ComponentFactory.createNumberSpinner (dbgPopupIBPCurrentModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
8714: @Override public void stateChanged (ChangeEvent ce) {
8715: dbgPopupIBPCurrentValue = dbgPopupIBPCurrentModel.getNumber ().intValue ();
8716: }
8717: }),
8718: Box.createHorizontalGlue ()
8719: ),
8720: ComponentFactory.createHorizontalBox (
8721: Box.createHorizontalStrut (7),
8722: Box.createHorizontalGlue (),
8723: ComponentFactory.setPreferredSize (
8724: Multilingual.mlnText (ComponentFactory.createLabel ("threshold"), "ja", "閾値"),
8725: 60, 16),
8726: ComponentFactory.createNumberSpinner (dbgPopupIBPThresholdModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
8727: @Override public void stateChanged (ChangeEvent ce) {
8728: dbgPopupIBPThresholdValue = dbgPopupIBPThresholdModel.getNumber ().intValue ();
8729: }
8730: }),
8731: Box.createHorizontalGlue ()
8732: ),
8733: dbgPopupIBPClearMenuItem =
8734: Multilingual.mlnText (ComponentFactory.createMenuItem ("Clear Breakpoint", 'C', popupActionListener), "ja", "ブレークポイントを消去")
8735: ) :
8736: null,
8737: dbgPopupHexMenu =
8738: ComponentFactory.createMenu (
8739: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
8740: dbgPopupDisMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble", 'D', popupActionListener), "ja", "逆アセンブル"),
8741: dbgPopupMemMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory Dump", 'M', popupActionListener), "ja", "メモリダンプ")
8742: ),
8743: dbgPopupCopyMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Copy", 'C', popupActionListener), "ja", "コピー"),
8744: dbgPopupSelectAllMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Select All", 'A', popupActionListener), "ja", "すべて選択")
8745: );
8746:
8747: }
8748:
8749:
8750:
8751: public static void dbgShowPopup (MouseEvent me, JTextArea textArea, boolean dis) {
8752: dbgEventMask++;
8753: int x = me.getX ();
8754: int y = me.getY ();
8755:
8756: int p = textArea.viewToModel2D (me.getPoint ());
8757: DisassembleList.ddpPopupAddress = -1;
8758: if (dis) {
8759: int i = Arrays.binarySearch (DisassembleList.ddpSplitArray, 1, DisassembleList.ddpItemCount, p + 1);
8760: i = (i >> 31 ^ i) - 1;
8761: DisassembleList.ddpPopupAddress = DisassembleList.ddpAddressArray[i];
8762: }
8763: int start = textArea.getSelectionStart ();
8764: int end = textArea.getSelectionEnd ();
8765: String text = textArea.getText ();
8766: int length = text.length ();
8767: if ((start == end ||
8768: p < start || end <= p) &&
8769: 0 <= p && p < length && isWord (text.charAt (p))) {
8770:
8771: for (start = p; 0 < start && isWord (text.charAt (start - 1)); start--) {
8772: }
8773: for (end = p + 1; end < length && isWord (text.charAt (end)); end++) {
8774: }
8775: textArea.select (start, end);
8776: }
8777: dbgHexSelected = false;
8778: if (start < end) {
8779: textArea.requestFocusInWindow ();
8780:
8781:
8782:
8783:
8784:
8785: dbgHexValue = 0;
8786: int n = 0;
8787: for (int i = start; i < end; i++) {
8788: int t;
8789: if ((t = Character.digit (text.charAt (i), 16)) >= 0) {
8790: dbgHexValue = dbgHexValue << 4 | t;
8791: if (n >= 8 ||
8792: i + 1 >= end || (t = Character.digit (text.charAt (i + 1), 16)) < 0) {
8793: n = 0;
8794: break;
8795: }
8796: dbgHexValue = dbgHexValue << 4 | t;
8797: n += 2;
8798: i++;
8799: } else if (isWord (text.charAt (i))) {
8800: n = 0;
8801: break;
8802: }
8803: }
8804: dbgHexSelected = n > 0;
8805: try {
8806:
8807: Rectangle r = textArea.modelToView2D (start).getBounds ();
8808:
8809: Rectangle s = textArea.modelToView2D (end - 1).getBounds ();
8810: if (r.y == s.y) {
8811:
8812: y = r.y + r.height;
8813: }
8814: } catch (BadLocationException ble) {
8815: }
8816: }
8817:
8818: if (InstructionBreakPoint.IBP_ON) {
8819: if (dis && mpuTask == null && DisassembleList.ddpPopupAddress != -1) {
8820: ComponentFactory.setText (dbgPopupIBPMenu, fmtHex8 (DisassembleList.ddpPopupAddress));
8821: TreeMap<Integer,InstructionBreakPoint.InstructionBreakRecord> pointTable = DisassembleList.ddpSupervisorMode != 0 ? InstructionBreakPoint.ibpSuperPointTable : InstructionBreakPoint.ibpUserPointTable;
8822: InstructionBreakPoint.InstructionBreakRecord r = pointTable.get (DisassembleList.ddpPopupAddress);
8823: if (r != null) {
8824: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = r.ibrValue));
8825: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = r.ibrThreshold));
8826: dbgPopupIBPClearMenuItem.setEnabled (true);
8827: } else {
8828: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = 0));
8829: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = 0));
8830: dbgPopupIBPClearMenuItem.setEnabled (false);
8831: }
8832: ComponentFactory.setVisible (dbgPopupIBPMenu, true);
8833: } else {
8834: ComponentFactory.setVisible (dbgPopupIBPMenu, false);
8835: }
8836: }
8837:
8838: if (dbgHexSelected) {
8839: ComponentFactory.setText (dbgPopupHexMenu, fmtHex8 (dbgHexValue));
8840: ComponentFactory.setVisible (dbgPopupHexMenu, true);
8841: } else {
8842: ComponentFactory.setVisible (dbgPopupHexMenu, false);
8843: }
8844:
8845: ComponentFactory.setEnabled (dbgPopupCopyMenuItem, clpClipboard != null && start < end);
8846:
8847: ComponentFactory.setEnabled (dbgPopupSelectAllMenuItem, clpClipboard != null);
8848:
8849: dbgPopupTextArea = textArea;
8850: dbgPopupMenu.show (textArea, x, y);
8851: dbgEventMask--;
8852: }
8853:
8854: public static boolean isWord (char c) {
8855: return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '_';
8856: }
8857:
8858:
8859:
8860: public static void dbgCopy () {
8861: if (clpClipboard != null) {
8862:
8863: String selectedText = dbgPopupTextArea.getSelectedText ();
8864: if (selectedText != null) {
8865: clpClipboardString = selectedText;
8866: try {
8867: clpClipboard.setContents (clpStringContents, clpClipboardOwner);
8868: clpIsClipboardOwner = true;
8869: } catch (Exception e) {
8870: return;
8871: }
8872: }
8873: }
8874: }
8875:
8876:
8877:
8878: public static void dbgSelectAll () {
8879: if (clpClipboard != null) {
8880:
8881: dbgEventMask++;
8882: dbgPopupTextArea.selectAll ();
8883: dbgPopupTextArea.requestFocusInWindow ();
8884: dbgEventMask--;
8885: }
8886: }
8887:
8888:
8889:
8890:
8891: public static void dbgUpdate () {
8892: if ((dbgVisibleMask & DBG_DRP_VISIBLE_MASK) != 0) {
8893: RegisterList.drpUpdate ();
8894: }
8895: if (ProgramFlowVisualizer.PFV_ON) {
8896: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
8897: if (ProgramFlowVisualizer.pfvTimer == 0) {
8898: ProgramFlowVisualizer.pfvUpdate ();
8899: } else {
8900: ProgramFlowVisualizer.pfvTimer--;
8901: }
8902: }
8903: }
8904: if (RasterBreakPoint.RBP_ON) {
8905: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
8906: if (RasterBreakPoint.rbpTimer == 0) {
8907: RasterBreakPoint.rbpUpdateFrame ();
8908: } else {
8909: RasterBreakPoint.rbpTimer--;
8910: }
8911: }
8912: }
8913: if (ScreenModeTest.SMT_ON) {
8914: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
8915: if (ScreenModeTest.smtTimer == 0) {
8916: ScreenModeTest.smtUpdateFrame ();
8917: } else {
8918: ScreenModeTest.smtTimer--;
8919: }
8920: }
8921: }
8922: if (RootPointerList.RTL_ON) {
8923: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
8924: if (RootPointerList.rtlTimer == 0) {
8925: RootPointerList.rtlTimer = RootPointerList.RTL_INTERVAL - 1;
8926: RootPointerList.rtlUpdateFrame ();
8927: } else {
8928: RootPointerList.rtlTimer--;
8929: }
8930: }
8931: }
8932: if (SpritePatternViewer.SPV_ON) {
8933: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
8934: if (SpritePatternViewer.spvTimer == 0) {
8935: SpritePatternViewer.spvTimer = SpritePatternViewer.SPV_INTERVAL - 1;
8936: SpritePatternViewer.spvUpdateFrame ();
8937: } else {
8938: SpritePatternViewer.spvTimer--;
8939: }
8940: }
8941: }
8942: if (ATCMonitor.ACM_ON) {
8943: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
8944: if (ATCMonitor.acmTimer == 0) {
8945: ATCMonitor.acmTimer = ATCMonitor.ACM_INTERVAL - 1;
8946: ATCMonitor.acmUpdateFrame ();
8947: } else {
8948: ATCMonitor.acmTimer--;
8949: }
8950: }
8951: }
8952: }
8953:
8954:
8955:
8956:
8957:
8958:
8959:
8960:
8961:
8962:
8963:
8964:
8965:
8966:
8967:
8968:
8969:
8970:
8971:
8972: public static boolean dbgDoStopOnError () {
8973: String message = (
8974: M68kException.m6eNumber < 0 ?
8975: fmtHex8 (new StringBuilder ("breaked").append (" at "), regPC0).toString () :
8976: M68kException.m6eNumber <= M68kException.M6E_ADDRESS_ERROR ?
8977: fmtHex8 (fmtHex8 (new StringBuilder ("ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
8978: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
8979: .append (" at "), regPC0).toString () :
8980: fmtHex8 (new StringBuilder (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
8981: .append (" at "), regPC0).toString ()
8982: );
8983: System.out.println (message);
8984: if (!(M68kException.m6eNumber == M68kException.M6E_ACCESS_FAULT &&
8985: 0x0000e100 <= regPC0 && regPC0 < 0x0000e500)) {
8986: mpuStop (message);
8987: return true;
8988: }
8989: return false;
8990: }
8991:
8992:
8993:
8994: public static void dbgDoubleBusFault () {
8995: String message =
8996: fmtHex8 (fmtHex8 (new StringBuilder ("FATAL ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
8997: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
8998: .append (" at "), regPC0).toString ();
8999: System.out.println (message);
9000: mpuStop (message);
9001: }
9002:
9003:
9004:
9005:
9006:
9007:
9008: public static final HashMap<String,byte[]> rscResourceCache = new HashMap<String,byte[]> ();
9009:
9010:
9011:
9012:
9013:
9014:
9015: public static byte[] rscGetResource (String name, int... sizes) {
9016: byte[] array = rscResourceCache.get (name);
9017: if (array != null) {
9018: return array;
9019: }
9020: array = new byte[1024 * 64];
9021: int size = 0;
9022: try (BufferedInputStream bis = new BufferedInputStream (XEiJ.class.getResourceAsStream ("../data/" + name))) {
9023: for (;;) {
9024: if (size == array.length) {
9025: byte[] newArray = new byte[array.length * 2];
9026: System.arraycopy (array, 0, newArray, 0, size);
9027: array = newArray;
9028: }
9029: int step = bis.read (array, size, array.length - size);
9030: if (step == -1) {
9031: break;
9032: }
9033: size += step;
9034: }
9035: if (size < array.length) {
9036: byte[] newArray = new byte[size];
9037: System.arraycopy (array, 0, newArray, 0, size);
9038: array = newArray;
9039: }
9040: boolean fit = sizes.length == 0;
9041: if (!fit) {
9042: for (int i = 0; i < sizes.length; i++) {
9043: if (size == sizes[i]) {
9044: fit = true;
9045: break;
9046: }
9047: }
9048: }
9049: if (fit) {
9050: System.out.println (Multilingual.mlnJapanese ?
9051: name + " を読み込みました" :
9052: name + " was read");
9053: rscResourceCache.put (name, array);
9054: return array;
9055: }
9056: System.out.println (Multilingual.mlnJapanese ?
9057: name + " のサイズが違います" :
9058: name + " has wrong size");
9059: return null;
9060: } catch (IOException ioe) {
9061: }
9062:
9063: System.out.println (Multilingual.mlnJapanese ?
9064: name + " を読み込めません" :
9065: name + " cannot be read");
9066: return null;
9067: }
9068:
9069:
9070:
9071: public static String rscGetResourceText (String name) {
9072: return rscGetResourceText (name, "UTF-8");
9073: }
9074: public static String rscGetResourceText (String name, String charset) {
9075: byte[] array = rscGetResource (name);
9076: if (name != null) {
9077: try {
9078: return new String (array, charset);
9079: } catch (UnsupportedEncodingException uee) {
9080: }
9081: }
9082: return "";
9083: }
9084:
9085: public static final Pattern RSC_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
9086: public static String rscLastFileName = null;
9087:
9088:
9089:
9090:
9091:
9092:
9093: public static byte[] rscGetFile (String names, int... sizes) {
9094: for (String name : names.split (",")) {
9095: name = name.trim ();
9096: if (name.length () == 0 || name.equalsIgnoreCase ("none")) {
9097: continue;
9098: }
9099: String[] zipSplittedName = RSC_ZIP_SEPARATOR.split (name, 2);
9100: InputStream is = null;
9101: if (zipSplittedName.length < 2) {
9102: File file = new File (name);
9103: if (file.isFile ()) {
9104: try {
9105: is = new FileInputStream (file);
9106: } catch (IOException ioe) {
9107: }
9108: } else {
9109: System.out.println (Multilingual.mlnJapanese ?
9110: name + " がありません" :
9111: name + " does not exist");
9112: continue;
9113: }
9114: } else {
9115: String zipName = zipSplittedName[0];
9116: String entryName = zipSplittedName[1];
9117: if (new File (zipName).isFile ()) {
9118: try {
9119: ZipFile zipFile = new ZipFile (zipName);
9120: ZipEntry zipEntry = zipFile.getEntry (entryName);
9121: if (zipEntry != null) {
9122: is = zipFile.getInputStream (zipEntry);
9123: } else {
9124: System.out.println (Multilingual.mlnJapanese ?
9125: zipName + " に " + zipEntry + " がありません" :
9126: zipName + " does not include " + zipEntry);
9127: }
9128: } catch (IOException ioe) {
9129: }
9130: } else {
9131: System.out.println (Multilingual.mlnJapanese ?
9132: zipName + " がありません" :
9133: zipName + " does not exist");
9134: continue;
9135: }
9136: }
9137: if (is != null) {
9138: try {
9139: is = new BufferedInputStream (is);
9140: if (name.toLowerCase ().endsWith (".gz")) {
9141: is = new GZIPInputStream (is);
9142: }
9143: byte[] array = new byte[1024 * 64];
9144: int size = 0;
9145: for (;;) {
9146: if (size == array.length) {
9147: byte[] newArray = new byte[array.length * 2];
9148: System.arraycopy (array, 0, newArray, 0, size);
9149: array = newArray;
9150: }
9151: int step = is.read (array, size, array.length - size);
9152: if (step == -1) {
9153: break;
9154: }
9155: size += step;
9156: }
9157: is.close ();
9158: is = null;
9159: if (size < array.length) {
9160: byte[] newArray = new byte[size];
9161: System.arraycopy (array, 0, newArray, 0, size);
9162: array = newArray;
9163: }
9164: boolean fit = sizes.length == 0;
9165: if (!fit) {
9166: for (int i = 0; i < sizes.length; i++) {
9167: if (size == sizes[i]) {
9168: fit = true;
9169: break;
9170: }
9171: }
9172: }
9173: if (fit) {
9174: System.out.println (Multilingual.mlnJapanese ?
9175: name + " を読み込みました" :
9176: name + " was read");
9177: rscLastFileName = name;
9178: return array;
9179: }
9180: System.out.println (Multilingual.mlnJapanese ?
9181: name + " のサイズが違います" :
9182: name + " has wrong size");
9183: continue;
9184: } catch (IOException ioe) {
9185: }
9186: if (is != null) {
9187: try {
9188: is.close ();
9189: is = null;
9190: } catch (IOException ioe) {
9191: }
9192: }
9193: }
9194: System.out.println (Multilingual.mlnJapanese ?
9195: name + " を読み込めません" :
9196: name + " cannot be read");
9197: }
9198:
9199:
9200:
9201: return null;
9202: }
9203:
9204:
9205:
9206:
9207: public static String rscGetTextFile (String name) {
9208: return rscGetTextFile (name, "UTF-8");
9209: }
9210: public static String rscGetTextFile (String name, String charset) {
9211: byte[] array = rscGetFile (name);
9212: if (array != null) {
9213: try {
9214: return new String (array, charset);
9215: } catch (UnsupportedEncodingException uee) {
9216: }
9217: }
9218: return "";
9219: }
9220:
9221:
9222:
9223: public static final int RSC_A_MASK = 1;
9224: public static final int RSC_R_MASK = 2;
9225: public static final int RSC_I_MASK = 4;
9226: public static final String RSC_A_EN = "Abort";
9227: public static final String RSC_R_EN = "Retry";
9228: public static final String RSC_I_EN = "Ignore";
9229: public static final String RSC_A_JA = "中止";
9230: public static final String RSC_R_JA = "再実行";
9231: public static final String RSC_I_JA = "無視";
9232: public static final String[][] RSC_EN_OPTIONS = {
9233: { RSC_A_EN },
9234: { RSC_A_EN },
9235: { RSC_R_EN },
9236: { RSC_A_EN, RSC_R_EN },
9237: { RSC_I_EN },
9238: { RSC_A_EN, RSC_I_EN },
9239: { RSC_R_EN, RSC_I_EN },
9240: { RSC_A_EN, RSC_R_EN, RSC_I_EN },
9241: };
9242: public static final String[][] RSC_JA_OPTIONS = {
9243: { RSC_A_JA },
9244: { RSC_A_JA },
9245: { RSC_R_JA },
9246: { RSC_A_JA, RSC_R_JA },
9247: { RSC_I_JA },
9248: { RSC_A_JA, RSC_I_JA },
9249: { RSC_R_JA, RSC_I_JA },
9250: { RSC_A_JA, RSC_R_JA, RSC_I_JA },
9251: };
9252: public static int rscShowError (String message, int mask) {
9253: System.out.println (message);
9254: mask &= RSC_A_MASK | RSC_R_MASK | RSC_I_MASK;
9255: if (mask == 0) {
9256: mask = RSC_A_MASK;
9257: }
9258: String[] options = (Multilingual.mlnJapanese ? RSC_JA_OPTIONS : RSC_EN_OPTIONS)[mask];
9259: int def = Integer.numberOfTrailingZeros (mask);
9260: int bit = JOptionPane.showOptionDialog (
9261: null,
9262: message,
9263: Multilingual.mlnJapanese ? "ファイル操作エラー" : "File operation error",
9264: JOptionPane.YES_NO_CANCEL_OPTION,
9265: JOptionPane.ERROR_MESSAGE,
9266: null,
9267: options,
9268: options[def]);
9269: if (bit == JOptionPane.CLOSED_OPTION) {
9270: bit = def;
9271: }
9272: return 1 << bit;
9273: }
9274:
9275:
9276:
9277:
9278:
9279:
9280: public static boolean rscPutTextFile (String name, String string) {
9281: return rscPutTextFile (name, string, "UTF-8");
9282: }
9283: public static boolean rscPutTextFile (String name, ArrayList<String> strings) {
9284: return rscPutTextFile (name, strings, "UTF-8");
9285: }
9286: public static boolean rscPutTextFile (String name, String string, String charset) {
9287: ArrayList<String> strings = new ArrayList<String> ();
9288: strings.add (string);
9289: return rscPutTextFile (name, strings, charset);
9290: }
9291: public static boolean rscPutTextFile (String name, ArrayList<String> strings, String charset) {
9292: String nameTmp = name + ".tmp";
9293: String nameBak = name + ".bak";
9294: File file = new File (name);
9295: File fileTmp = new File (nameTmp);
9296: File fileBak = new File (nameBak);
9297:
9298: File parentDirectory = file.getParentFile ();
9299: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
9300: if (!parentDirectory.mkdirs ()) {
9301: System.out.println (parentDirectory.getPath () + (Multilingual.mlnJapanese ? " を作れません" : " cannot be created"));
9302: return false;
9303: }
9304: }
9305:
9306: if (fileTmp.exists ()) {
9307: if (!fileTmp.delete ()) {
9308: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
9309: return false;
9310: }
9311: }
9312:
9313: try (BufferedWriter bw = new BufferedWriter (new FileWriter (nameTmp, Charset.forName (charset)))) {
9314: for (String string : strings) {
9315: bw.write (string);
9316: }
9317: } catch (IOException ioe) {
9318: ioe.printStackTrace ();
9319: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " に書き出せません" : " cannot be written"));
9320: return false;
9321: }
9322:
9323: boolean fileExists = file.exists ();
9324: if (fileExists) {
9325:
9326: if (fileBak.exists ()) {
9327: if (!fileBak.delete ()) {
9328: System.out.println (nameBak + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
9329: return false;
9330: }
9331: }
9332:
9333: if (!file.renameTo (fileBak)) {
9334: System.out.println (name + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + nameBak + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
9335: return false;
9336: }
9337: }
9338:
9339: if (!fileTmp.renameTo (file)) {
9340: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + name + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
9341: return false;
9342: }
9343: if (fileExists) {
9344: System.out.println (name + (Multilingual.mlnJapanese ? " を更新しました" : " was updated"));
9345: } else {
9346: System.out.println (name + (Multilingual.mlnJapanese ? " を作りました" : " was created"));
9347: }
9348: return true;
9349: }
9350:
9351:
9352:
9353:
9354:
9355:
9356:
9357:
9358:
9359: public static boolean rscPutFile (String name, byte[] array) {
9360: return rscPutFile (name, array, 0, array.length, (long) array.length);
9361: }
9362: public static boolean rscPutFile (String name, byte[] array, int offset, int length) {
9363: return rscPutFile (name, array, offset, length, (long) length);
9364: }
9365: public static boolean rscPutFile (String name, byte[] array, int offset, int length, long longLength2) {
9366: if (RSC_ZIP_SEPARATOR.matcher (name).matches ()) {
9367:
9368: return false;
9369: }
9370: File file = new File (name);
9371: boolean fileExists = file.isFile ();
9372: if (fileExists && file.length () == longLength2) {
9373: comparison:
9374: {
9375: try (BufferedInputStream bis = new BufferedInputStream (new FileInputStream (file))) {
9376: byte[] buffer = new byte[(int) Math.min (Math.max ((long) length, longLength2 - (long) length), (long) (1024 * 1024))];
9377: int position = 0;
9378: while (position < length) {
9379: int step = bis.read (buffer, 0, Math.min (buffer.length, length - position));
9380: if (step == -1) {
9381: break comparison;
9382: }
9383: int offsetPosition = offset + position;
9384: for (int i = 0; i < step; i++) {
9385: if (buffer[i] != array[offsetPosition + i]) {
9386: break comparison;
9387: }
9388: }
9389: position += step;
9390: }
9391: long longPosition2 = (long) length;
9392: while (longPosition2 < longLength2) {
9393: int step = bis.read (buffer, 0, (int) Math.min ((long) buffer.length, longLength2 - longPosition2));
9394: if (step == -1) {
9395: break comparison;
9396: }
9397: for (int i = 0; i < step; i++) {
9398: if (buffer[i] != 0) {
9399: break comparison;
9400: }
9401: }
9402: longPosition2 += (long) step;
9403: }
9404: return true;
9405: } catch (IOException ioe) {
9406: }
9407: }
9408: }
9409: String nameTmp = name + ".tmp";
9410: File fileTmp = new File (nameTmp);
9411: String nameBak = name + ".bak";
9412: File fileBak = new File (nameBak);
9413: retry:
9414: for (;;) {
9415: File parentDirectory = file.getParentFile ();
9416: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
9417: String parentName = parentDirectory.getPath ();
9418: if (parentDirectory.mkdirs ()) {
9419: System.out.println (Multilingual.mlnJapanese ?
9420: parentName + " を作りました" :
9421: parentName + " was created");
9422: } else {
9423: switch (rscShowError (Multilingual.mlnJapanese ?
9424: parentName + " を作れません" :
9425: parentName + " cannot be created",
9426: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
9427: case RSC_A_MASK:
9428: break retry;
9429: case RSC_R_MASK:
9430: continue retry;
9431: }
9432: }
9433: }
9434: if (fileTmp.isFile ()) {
9435: if (!fileTmp.delete ()) {
9436: switch (rscShowError (Multilingual.mlnJapanese ?
9437: nameTmp + " を削除できません" :
9438: nameTmp + " cannot be deleted",
9439: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
9440: case RSC_A_MASK:
9441: break retry;
9442: case RSC_R_MASK:
9443: continue retry;
9444: }
9445: }
9446: }
9447: try (OutputStream os = name.toLowerCase ().endsWith (".gz") ?
9448: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
9449: {
9450:
9451: def.setLevel (Deflater.DEFAULT_COMPRESSION);
9452:
9453: }
9454: } :
9455: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
9456:
9457: os.write (array, offset, length);
9458:
9459:
9460: if ((long) length < longLength2) {
9461: byte[] buffer = new byte[(int) Math.min (longLength2 - (long) length, (long) (1024 * 1024))];
9462: Arrays.fill (buffer, 0, buffer.length, (byte) 0);
9463: long longPosition2 = (long) length;
9464: while (longPosition2 < longLength2) {
9465: int step = (int) Math.min ((long) buffer.length, longLength2 - longPosition2);
9466: os.write (buffer, 0, step);
9467: longPosition2 += (long) step;
9468: }
9469: }
9470: } catch (IOException ioe) {
9471: switch (rscShowError (Multilingual.mlnJapanese ?
9472: nameTmp + " に書き出せません" :
9473: nameTmp + " cannot be written",
9474: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
9475: case RSC_A_MASK:
9476: break retry;
9477: case RSC_R_MASK:
9478: continue retry;
9479: }
9480: }
9481: if (fileExists && file.isFile ()) {
9482: if (fileBak.isFile ()) {
9483: if (!fileBak.delete ()) {
9484: switch (rscShowError (Multilingual.mlnJapanese ?
9485: nameBak + " を削除できません" :
9486: nameBak + " cannot be deleted",
9487: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
9488: case RSC_A_MASK:
9489: break retry;
9490: case RSC_R_MASK:
9491: continue retry;
9492: }
9493: }
9494: }
9495: if (!file.renameTo (fileBak)) {
9496: switch (rscShowError (Multilingual.mlnJapanese ?
9497: name + " を " + nameBak + " にリネームできません" :
9498: name + " cannot be renamed to " + nameBak,
9499: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
9500: case RSC_A_MASK:
9501: break retry;
9502: case RSC_R_MASK:
9503: continue retry;
9504: }
9505: }
9506: }
9507: if (fileTmp.renameTo (file)) {
9508: if (fileExists) {
9509: System.out.println (Multilingual.mlnJapanese ?
9510: name + " を更新しました" :
9511: name + " was updated");
9512: } else {
9513: System.out.println (Multilingual.mlnJapanese ?
9514: name + " を作りました" :
9515: name + " was created");
9516: }
9517: return true;
9518: } else {
9519: switch (rscShowError (Multilingual.mlnJapanese ?
9520: nameTmp + " を " + name + " にリネームできません" :
9521: nameTmp + " cannot be renamed to " + name,
9522: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
9523: case RSC_A_MASK:
9524: break retry;
9525: case RSC_R_MASK:
9526: continue retry;
9527: }
9528: }
9529: break;
9530: }
9531: if (fileExists) {
9532: System.out.println (Multilingual.mlnJapanese ?
9533: name + " を更新できません" :
9534: name + " cannot be updated");
9535: } else {
9536: System.out.println (Multilingual.mlnJapanese ?
9537: name + " を作れません" :
9538: name + " cannot be created");
9539: }
9540: return false;
9541: }
9542:
9543:
9544:
9545:
9546:
9547:
9548: public static final Pattern ISM_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
9549:
9550:
9551:
9552:
9553:
9554:
9555:
9556:
9557:
9558:
9559:
9560: public static InputStream ismOpen (String name) {
9561: InputStream in = null;
9562: in = ismOpen (name, false);
9563: if (in == null && name.indexOf ('/') < 0 && name.indexOf ('\\') < 0) {
9564: in = ismOpen (name, true);
9565: }
9566: return in;
9567: }
9568: public static InputStream ismOpen (String name, boolean useGetResource) {
9569: boolean gzipped = name.toLowerCase ().endsWith (".gz");
9570: String[] zipSplittedName = ISM_ZIP_SEPARATOR.split (name, 2);
9571: String fileName = zipSplittedName[0];
9572: String zipEntryName = zipSplittedName.length < 2 ? null : zipSplittedName[1];
9573: InputStream in = null;
9574: try {
9575: if (useGetResource) {
9576: if (false) {
9577: URL url = XEiJ.class.getResource (fileName);
9578: if (url != null) {
9579: in = url.openStream ();
9580: }
9581: } else {
9582: in = XEiJ.class.getResourceAsStream (fileName);
9583: }
9584: } else {
9585: File file = new File (fileName);
9586: if (file.exists ()) {
9587: in = new FileInputStream (file);
9588: }
9589: }
9590: if (in != null && zipEntryName != null) {
9591: ZipInputStream zin = new ZipInputStream (in);
9592: in = null;
9593: ZipEntry entry;
9594: while ((entry = zin.getNextEntry ()) != null) {
9595: if (zipEntryName.equals (entry.getName ())) {
9596: in = zin;
9597: break;
9598: }
9599: }
9600: if (in == null) {
9601: System.out.println (Multilingual.mlnJapanese ? fileName + " の中に " + zipEntryName + " がありません" :
9602: zipEntryName + " does not exist in " + fileName);
9603: }
9604: }
9605: if (in != null && gzipped) {
9606: in = new GZIPInputStream (in);
9607: }
9608: if (in != null) {
9609: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " を読み込みます" :
9610: (useGetResource ? "Reading resource file " : "Reading file ") + name);
9611: return new BufferedInputStream (in);
9612: }
9613: } catch (Exception ioe) {
9614: if (prgVerbose) {
9615: prgPrintStackTraceOf (ioe);
9616: }
9617: }
9618: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " が見つかりません" :
9619: (useGetResource ? "Resource file " : "File ") + name + " is not found");
9620: return null;
9621: }
9622:
9623:
9624:
9625:
9626:
9627:
9628:
9629:
9630: public static int ismRead (InputStream in, byte[] bb, int o, int l) {
9631: try {
9632: int k = 0;
9633: while (k < l) {
9634: int t = in.read (bb, o + k, l - k);
9635: if (t < 0) {
9636: break;
9637: }
9638: k += t;
9639: }
9640: return k;
9641: } catch (IOException ioe) {
9642: if (prgVerbose) {
9643: prgPrintStackTraceOf (ioe);
9644: }
9645: }
9646: return -1;
9647: }
9648:
9649:
9650:
9651:
9652:
9653:
9654:
9655:
9656: public static int ismSkip (InputStream in, int l) {
9657: try {
9658: int k = 0;
9659: while (k < l) {
9660:
9661:
9662: if (in.read () < 0) {
9663: break;
9664: }
9665: k++;
9666: if (k < l) {
9667: int t = (int) in.skip ((long) (l - k));
9668: if (t < 0) {
9669: break;
9670: }
9671: k += t;
9672: }
9673: }
9674: return k;
9675: } catch (IOException ioe) {
9676: if (prgVerbose) {
9677: prgPrintStackTraceOf (ioe);
9678: }
9679: }
9680: return -1;
9681: }
9682:
9683:
9684:
9685:
9686:
9687: public static void ismClose (InputStream in) {
9688: try {
9689: if (in != null) {
9690: in.close ();
9691: }
9692: } catch (IOException ioe) {
9693: if (prgVerbose) {
9694: prgPrintStackTraceOf (ioe);
9695: }
9696: }
9697: }
9698:
9699:
9700:
9701:
9702:
9703:
9704: public static int ismLength (String name, int maxLength) {
9705: int length;
9706: InputStream in = ismOpen (name);
9707: if (in == null) {
9708: length = -1;
9709: } else {
9710: length = ismSkip (in, maxLength);
9711: ismClose (in);
9712: }
9713: return length;
9714: }
9715:
9716:
9717:
9718:
9719:
9720:
9721:
9722:
9723:
9724:
9725:
9726:
9727:
9728:
9729: public static boolean ismLoad (byte[] bb, int o, int l, String names) {
9730: for (String name : names.split (",")) {
9731: if (name.length () != 0) {
9732: InputStream in = ismOpen (name);
9733: if (in != null) {
9734: int k = ismRead (in, bb, o, l);
9735: ismClose (in);
9736: if (k == l) {
9737: return true;
9738: }
9739: }
9740: }
9741: }
9742: return false;
9743: }
9744:
9745:
9746:
9747:
9748:
9749:
9750:
9751:
9752:
9753: public static boolean ismSave (byte[] bb, int offset, long length, String path, boolean verbose) {
9754: if (ISM_ZIP_SEPARATOR.split (path, 2).length != 1) {
9755: if (verbose) {
9756: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? path + " に書き出せません" : "Cannot write " + path);
9757: }
9758: return false;
9759: }
9760: long step = 0;
9761: byte[] zz = null;
9762: long pointer = (long) (bb.length - offset);
9763: if (pointer < length) {
9764: step = Math.min (1024L * 512, length - pointer);
9765: zz = new byte[(int) step];
9766: Arrays.fill (zz, (byte) 0);
9767: }
9768:
9769: File file = new File (path);
9770:
9771: if (step == 0 &&
9772: file.exists () && file.length () == length) {
9773:
9774: if (length == 0L) {
9775: return true;
9776: }
9777: InputStream in = ismOpen (path);
9778: if (in != null) {
9779: int l = (int) length;
9780: byte[] tt = new byte[l];
9781: int k = ismRead (in, tt, 0, l);
9782: ismClose (in);
9783: if (k == l &&
9784: Arrays.equals (tt, bb.length == l ? bb : Arrays.copyOfRange (bb, offset, offset + l))) {
9785: return true;
9786: }
9787: }
9788: }
9789:
9790: String pathTmp = path + ".tmp";
9791: String pathBak = path + ".bak";
9792: File fileTmp = new File (pathTmp);
9793: File fileBak = new File (pathBak);
9794:
9795: if (fileTmp.exists ()) {
9796: if (!fileTmp.delete ()) {
9797: if (verbose) {
9798: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " を削除できません" : "Cannot delete " + pathTmp);
9799: }
9800: return false;
9801: }
9802: }
9803:
9804: try (OutputStream out = path.toLowerCase ().endsWith (".gz") ?
9805: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
9806: {
9807:
9808: def.setLevel (Deflater.DEFAULT_COMPRESSION);
9809:
9810: }
9811: } :
9812: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
9813: if (step == 0) {
9814: out.write (bb, offset, (int) length);
9815: } else {
9816: out.write (bb, offset, (int) pointer);
9817: for (; pointer < length; pointer += step) {
9818: out.write (zz, 0, (int) Math.min (step, length - pointer));
9819: }
9820: }
9821: } catch (IOException ioe) {
9822: if (verbose) {
9823: prgPrintStackTraceOf (ioe);
9824: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " に書き出せません" : "Cannot write " + pathTmp);
9825: }
9826: return false;
9827: }
9828:
9829:
9830: if (file.exists ()) {
9831: if (fileBak.exists ()) {
9832: if (!fileBak.delete ()) {
9833: if (verbose) {
9834: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathBak + " を削除できません" : "Cannot delete " + pathBak);
9835: }
9836: return false;
9837: }
9838: }
9839: if (!file.renameTo (fileBak)) {
9840: if (verbose) {
9841: JOptionPane.showMessageDialog (
9842: null, Multilingual.mlnJapanese ? path + " を " + pathBak + " にリネームできません" : "Cannot rename " + path + " to " + pathBak);
9843: }
9844: return false;
9845: }
9846: }
9847:
9848:
9849: if (!fileTmp.renameTo (file)) {
9850: if (verbose) {
9851: JOptionPane.showMessageDialog (
9852: null, Multilingual.mlnJapanese ? pathTmp + " を " + path + " にリネームできません" : "Cannot rename " + pathTmp + " to " + path);
9853: }
9854: return false;
9855: }
9856: return true;
9857: }
9858:
9859:
9860:
9861:
9862:
9863:
9864:
9865: public static final char[] FMT_TEMP = new char[32];
9866:
9867:
9868:
9869:
9870:
9871:
9872:
9873:
9874:
9875:
9876:
9877: public static final char[] FMT_AIN4_BASE = ".......*..*...**.*...*.*.**..****...*..**.*.*.****..**.****.****".toCharArray ();
9878: public static final char[] FMT_BIN4_BASE = "0000000100100011010001010110011110001001101010111100110111101111".toCharArray ();
9879:
9880:
9881:
9882:
9883:
9884:
9885:
9886:
9887: public static void fmtAin4 (char[] a, int o, int x) {
9888: a[o ] = (char) (x >> 1 & 4 ^ 46);
9889: a[o + 1] = (char) (x & 4 ^ 46);
9890: a[o + 2] = (char) (x << 1 & 4 ^ 46);
9891: a[o + 3] = (char) (x << 2 & 4 ^ 46);
9892: }
9893: public static void fmtBin4 (char[] a, int o, int x) {
9894: a[o ] = (char) (x >>> 3 & 1 | 48);
9895: a[o + 1] = (char) (x >>> 2 & 1 | 48);
9896: a[o + 2] = (char) (x >>> 1 & 1 | 48);
9897: a[o + 3] = (char) (x & 1 | 48);
9898: }
9899: public static String fmtAin4 (int x) {
9900: return String.valueOf (FMT_AIN4_BASE, (x & 15) << 2, 4);
9901: }
9902: public static String fmtBin4 (int x) {
9903: return String.valueOf (FMT_BIN4_BASE, (x & 15) << 2, 4);
9904: }
9905: public static StringBuilder fmtAin4 (StringBuilder sb, int x) {
9906: return sb.append (FMT_AIN4_BASE, (x & 15) << 2, 6);
9907: }
9908: public static StringBuilder fmtBin4 (StringBuilder sb, int x) {
9909: return sb.append (FMT_BIN4_BASE, (x & 15) << 2, 6);
9910: }
9911:
9912:
9913:
9914:
9915:
9916:
9917:
9918:
9919: public static void fmtAin6 (char[] a, int o, int x) {
9920: a[o ] = (char) (x >> 3 & 4 ^ 46);
9921: a[o + 1] = (char) (x >> 2 & 4 ^ 46);
9922: a[o + 2] = (char) (x >> 1 & 4 ^ 46);
9923: a[o + 3] = (char) (x & 4 ^ 46);
9924: a[o + 4] = (char) (x << 1 & 4 ^ 46);
9925: a[o + 5] = (char) (x << 2 & 4 ^ 46);
9926: }
9927: public static void fmtBin6 (char[] a, int o, int x) {
9928: a[o ] = (char) (x >>> 5 & 1 | 48);
9929: a[o + 1] = (char) (x >>> 4 & 1 | 48);
9930: a[o + 2] = (char) (x >>> 3 & 1 | 48);
9931: a[o + 3] = (char) (x >>> 2 & 1 | 48);
9932: a[o + 4] = (char) (x >>> 1 & 1 | 48);
9933: a[o + 5] = (char) (x & 1 | 48);
9934: }
9935: public static String fmtAin6 (int x) {
9936: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
9937: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
9938: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
9939: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
9940: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
9941: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
9942: return String.valueOf (FMT_TEMP, 0, 6);
9943: }
9944: public static String fmtBin6 (int x) {
9945: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
9946: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
9947: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
9948: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
9949: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
9950: FMT_TEMP[ 5] = (char) (x & 1 | 48);
9951: return String.valueOf (FMT_TEMP, 0, 6);
9952: }
9953: public static StringBuilder fmtAin6 (StringBuilder sb, int x) {
9954: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
9955: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
9956: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
9957: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
9958: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
9959: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
9960: return sb.append (FMT_TEMP, 0, 6);
9961: }
9962: public static StringBuilder fmtBin6 (StringBuilder sb, int x) {
9963: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
9964: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
9965: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
9966: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
9967: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
9968: FMT_TEMP[ 5] = (char) (x & 1 | 48);
9969: return sb.append (FMT_TEMP, 0, 6);
9970: }
9971:
9972:
9973:
9974:
9975:
9976:
9977:
9978:
9979: public static void fmtAin8 (char[] a, int o, int x) {
9980: a[o ] = (char) (x >> 5 & 4 ^ 46);
9981: a[o + 1] = (char) (x >> 4 & 4 ^ 46);
9982: a[o + 2] = (char) (x >> 3 & 4 ^ 46);
9983: a[o + 3] = (char) (x >> 2 & 4 ^ 46);
9984: a[o + 4] = (char) (x >> 1 & 4 ^ 46);
9985: a[o + 5] = (char) (x & 4 ^ 46);
9986: a[o + 6] = (char) (x << 1 & 4 ^ 46);
9987: a[o + 7] = (char) (x << 2 & 4 ^ 46);
9988: }
9989: public static void fmtBin8 (char[] a, int o, int x) {
9990: a[o ] = (char) (x >>> 7 & 1 | 48);
9991: a[o + 1] = (char) (x >>> 6 & 1 | 48);
9992: a[o + 2] = (char) (x >>> 5 & 1 | 48);
9993: a[o + 3] = (char) (x >>> 4 & 1 | 48);
9994: a[o + 4] = (char) (x >>> 3 & 1 | 48);
9995: a[o + 5] = (char) (x >>> 2 & 1 | 48);
9996: a[o + 6] = (char) (x >>> 1 & 1 | 48);
9997: a[o + 7] = (char) (x & 1 | 48);
9998: }
9999: public static String fmtAin8 (int x) {
10000: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
10001: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
10002: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
10003: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
10004: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
10005: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
10006: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
10007: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
10008: return String.valueOf (FMT_TEMP, 0, 8);
10009: }
10010: public static String fmtBin8 (int x) {
10011: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
10012: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
10013: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
10014: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
10015: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
10016: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
10017: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
10018: FMT_TEMP[ 7] = (char) (x & 1 | 48);
10019: return String.valueOf (FMT_TEMP, 0, 8);
10020: }
10021: public static StringBuilder fmtAin8 (StringBuilder sb, int x) {
10022: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
10023: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
10024: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
10025: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
10026: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
10027: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
10028: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
10029: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
10030: return sb.append (FMT_TEMP, 0, 8);
10031: }
10032: public static StringBuilder fmtBin8 (StringBuilder sb, int x) {
10033: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
10034: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
10035: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
10036: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
10037: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
10038: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
10039: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
10040: FMT_TEMP[ 7] = (char) (x & 1 | 48);
10041: return sb.append (FMT_TEMP, 0, 8);
10042: }
10043:
10044:
10045:
10046:
10047:
10048:
10049:
10050:
10051: public static void fmtAin12 (char[] a, int o, int x) {
10052: a[o ] = (char) (x >> 9 & 4 ^ 46);
10053: a[o + 1] = (char) (x >> 8 & 4 ^ 46);
10054: a[o + 2] = (char) (x >> 7 & 4 ^ 46);
10055: a[o + 3] = (char) (x >> 6 & 4 ^ 46);
10056: a[o + 4] = (char) (x >> 5 & 4 ^ 46);
10057: a[o + 5] = (char) (x >> 4 & 4 ^ 46);
10058: a[o + 6] = (char) (x >> 3 & 4 ^ 46);
10059: a[o + 7] = (char) (x >> 2 & 4 ^ 46);
10060: a[o + 8] = (char) (x >> 1 & 4 ^ 46);
10061: a[o + 9] = (char) (x & 4 ^ 46);
10062: a[o + 10] = (char) (x << 1 & 4 ^ 46);
10063: a[o + 11] = (char) (x << 2 & 4 ^ 46);
10064: }
10065: public static void fmtBin12 (char[] a, int o, int x) {
10066: a[o ] = (char) (x >>> 11 & 1 | 48);
10067: a[o + 1] = (char) (x >>> 10 & 1 | 48);
10068: a[o + 2] = (char) (x >>> 9 & 1 | 48);
10069: a[o + 3] = (char) (x >>> 8 & 1 | 48);
10070: a[o + 4] = (char) (x >>> 7 & 1 | 48);
10071: a[o + 5] = (char) (x >>> 6 & 1 | 48);
10072: a[o + 6] = (char) (x >>> 5 & 1 | 48);
10073: a[o + 7] = (char) (x >>> 4 & 1 | 48);
10074: a[o + 8] = (char) (x >>> 3 & 1 | 48);
10075: a[o + 9] = (char) (x >>> 2 & 1 | 48);
10076: a[o + 10] = (char) (x >>> 1 & 1 | 48);
10077: a[o + 11] = (char) (x & 1 | 48);
10078: }
10079: public static String fmtAin12 (int x) {
10080: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
10081: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
10082: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
10083: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
10084: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
10085: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
10086: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
10087: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
10088: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
10089: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
10090: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
10091: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
10092: return String.valueOf (FMT_TEMP, 0, 12);
10093: }
10094: public static String fmtBin12 (int x) {
10095: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
10096: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
10097: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
10098: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
10099: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
10100: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
10101: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
10102: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
10103: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
10104: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
10105: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
10106: FMT_TEMP[11] = (char) (x & 1 | 48);
10107: return String.valueOf (FMT_TEMP, 0, 12);
10108: }
10109: public static StringBuilder fmtAin12 (StringBuilder sb, int x) {
10110: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
10111: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
10112: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
10113: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
10114: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
10115: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
10116: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
10117: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
10118: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
10119: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
10120: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
10121: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
10122: return sb.append (FMT_TEMP, 0, 12);
10123: }
10124: public static StringBuilder fmtBin12 (StringBuilder sb, int x) {
10125: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
10126: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
10127: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
10128: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
10129: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
10130: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
10131: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
10132: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
10133: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
10134: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
10135: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
10136: FMT_TEMP[11] = (char) (x & 1 | 48);
10137: return sb.append (FMT_TEMP, 0, 12);
10138: }
10139:
10140:
10141:
10142:
10143:
10144:
10145:
10146:
10147: public static void fmtAin16 (char[] a, int o, int x) {
10148: a[o ] = (char) (x >> 13 & 4 ^ 46);
10149: a[o + 1] = (char) (x >> 12 & 4 ^ 46);
10150: a[o + 2] = (char) (x >> 11 & 4 ^ 46);
10151: a[o + 3] = (char) (x >> 10 & 4 ^ 46);
10152: a[o + 4] = (char) (x >> 9 & 4 ^ 46);
10153: a[o + 5] = (char) (x >> 8 & 4 ^ 46);
10154: a[o + 6] = (char) (x >> 7 & 4 ^ 46);
10155: a[o + 7] = (char) (x >> 6 & 4 ^ 46);
10156: a[o + 8] = (char) (x >> 5 & 4 ^ 46);
10157: a[o + 9] = (char) (x >> 4 & 4 ^ 46);
10158: a[o + 10] = (char) (x >> 3 & 4 ^ 46);
10159: a[o + 11] = (char) (x >> 2 & 4 ^ 46);
10160: a[o + 12] = (char) (x >> 1 & 4 ^ 46);
10161: a[o + 13] = (char) (x & 4 ^ 46);
10162: a[o + 14] = (char) (x << 1 & 4 ^ 46);
10163: a[o + 15] = (char) (x << 2 & 4 ^ 46);
10164: }
10165: public static void fmtBin16 (char[] a, int o, int x) {
10166: a[o ] = (char) (x >>> 15 & 1 | 48);
10167: a[o + 1] = (char) (x >>> 14 & 1 | 48);
10168: a[o + 2] = (char) (x >>> 13 & 1 | 48);
10169: a[o + 3] = (char) (x >>> 12 & 1 | 48);
10170: a[o + 4] = (char) (x >>> 11 & 1 | 48);
10171: a[o + 5] = (char) (x >>> 10 & 1 | 48);
10172: a[o + 6] = (char) (x >>> 9 & 1 | 48);
10173: a[o + 7] = (char) (x >>> 8 & 1 | 48);
10174: a[o + 8] = (char) (x >>> 7 & 1 | 48);
10175: a[o + 9] = (char) (x >>> 6 & 1 | 48);
10176: a[o + 10] = (char) (x >>> 5 & 1 | 48);
10177: a[o + 11] = (char) (x >>> 4 & 1 | 48);
10178: a[o + 12] = (char) (x >>> 3 & 1 | 48);
10179: a[o + 13] = (char) (x >>> 2 & 1 | 48);
10180: a[o + 14] = (char) (x >>> 1 & 1 | 48);
10181: a[o + 15] = (char) (x & 1 | 48);
10182: }
10183: public static String fmtAin16 (int x) {
10184: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
10185: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
10186: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
10187: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
10188: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
10189: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
10190: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
10191: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
10192: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
10193: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
10194: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
10195: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
10196: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
10197: FMT_TEMP[13] = (char) (x & 4 ^ 46);
10198: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
10199: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
10200: return String.valueOf (FMT_TEMP, 0, 16);
10201: }
10202: public static String fmtBin16 (int x) {
10203: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
10204: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
10205: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
10206: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
10207: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
10208: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
10209: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
10210: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
10211: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
10212: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
10213: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
10214: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
10215: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
10216: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
10217: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
10218: FMT_TEMP[15] = (char) (x & 1 | 48);
10219: return String.valueOf (FMT_TEMP, 0, 16);
10220: }
10221: public static StringBuilder fmtAin16 (StringBuilder sb, int x) {
10222: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
10223: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
10224: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
10225: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
10226: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
10227: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
10228: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
10229: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
10230: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
10231: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
10232: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
10233: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
10234: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
10235: FMT_TEMP[13] = (char) (x & 4 ^ 46);
10236: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
10237: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
10238: return sb.append (FMT_TEMP, 0, 16);
10239: }
10240: public static StringBuilder fmtBin16 (StringBuilder sb, int x) {
10241: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
10242: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
10243: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
10244: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
10245: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
10246: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
10247: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
10248: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
10249: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
10250: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
10251: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
10252: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
10253: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
10254: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
10255: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
10256: FMT_TEMP[15] = (char) (x & 1 | 48);
10257: return sb.append (FMT_TEMP, 0, 16);
10258: }
10259:
10260:
10261:
10262:
10263:
10264:
10265:
10266:
10267: public static void fmtAin24 (char[] a, int o, int x) {
10268: a[o ] = (char) (x >> 21 & 4 ^ 46);
10269: a[o + 1] = (char) (x >> 20 & 4 ^ 46);
10270: a[o + 2] = (char) (x >> 19 & 4 ^ 46);
10271: a[o + 3] = (char) (x >> 18 & 4 ^ 46);
10272: a[o + 4] = (char) (x >> 17 & 4 ^ 46);
10273: a[o + 5] = (char) (x >> 16 & 4 ^ 46);
10274: a[o + 6] = (char) (x >> 15 & 4 ^ 46);
10275: a[o + 7] = (char) (x >> 14 & 4 ^ 46);
10276: a[o + 8] = (char) (x >> 13 & 4 ^ 46);
10277: a[o + 9] = (char) (x >> 12 & 4 ^ 46);
10278: a[o + 10] = (char) (x >> 11 & 4 ^ 46);
10279: a[o + 11] = (char) (x >> 10 & 4 ^ 46);
10280: a[o + 12] = (char) (x >> 9 & 4 ^ 46);
10281: a[o + 13] = (char) (x >> 8 & 4 ^ 46);
10282: a[o + 14] = (char) (x >> 7 & 4 ^ 46);
10283: a[o + 15] = (char) (x >> 6 & 4 ^ 46);
10284: a[o + 16] = (char) (x >> 5 & 4 ^ 46);
10285: a[o + 17] = (char) (x >> 4 & 4 ^ 46);
10286: a[o + 18] = (char) (x >> 3 & 4 ^ 46);
10287: a[o + 19] = (char) (x >> 2 & 4 ^ 46);
10288: a[o + 20] = (char) (x >> 1 & 4 ^ 46);
10289: a[o + 21] = (char) (x & 4 ^ 46);
10290: a[o + 22] = (char) (x << 1 & 4 ^ 46);
10291: a[o + 23] = (char) (x << 2 & 4 ^ 46);
10292: }
10293: public static void fmtBin24 (char[] a, int o, int x) {
10294: a[o ] = (char) (x >>> 23 & 1 | 48);
10295: a[o + 1] = (char) (x >>> 22 & 1 | 48);
10296: a[o + 2] = (char) (x >>> 21 & 1 | 48);
10297: a[o + 3] = (char) (x >>> 20 & 1 | 48);
10298: a[o + 4] = (char) (x >>> 19 & 1 | 48);
10299: a[o + 5] = (char) (x >>> 18 & 1 | 48);
10300: a[o + 6] = (char) (x >>> 17 & 1 | 48);
10301: a[o + 7] = (char) (x >>> 16 & 1 | 48);
10302: a[o + 8] = (char) (x >>> 15 & 1 | 48);
10303: a[o + 9] = (char) (x >>> 14 & 1 | 48);
10304: a[o + 10] = (char) (x >>> 13 & 1 | 48);
10305: a[o + 11] = (char) (x >>> 12 & 1 | 48);
10306: a[o + 12] = (char) (x >>> 11 & 1 | 48);
10307: a[o + 13] = (char) (x >>> 10 & 1 | 48);
10308: a[o + 14] = (char) (x >>> 9 & 1 | 48);
10309: a[o + 15] = (char) (x >>> 8 & 1 | 48);
10310: a[o + 16] = (char) (x >>> 7 & 1 | 48);
10311: a[o + 17] = (char) (x >>> 6 & 1 | 48);
10312: a[o + 18] = (char) (x >>> 5 & 1 | 48);
10313: a[o + 19] = (char) (x >>> 4 & 1 | 48);
10314: a[o + 20] = (char) (x >>> 3 & 1 | 48);
10315: a[o + 21] = (char) (x >>> 2 & 1 | 48);
10316: a[o + 22] = (char) (x >>> 1 & 1 | 48);
10317: a[o + 23] = (char) (x & 1 | 48);
10318: }
10319: public static String fmtAin24 (int x) {
10320: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
10321: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
10322: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
10323: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
10324: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
10325: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
10326: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
10327: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
10328: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
10329: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
10330: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
10331: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
10332: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
10333: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
10334: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
10335: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
10336: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
10337: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
10338: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
10339: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
10340: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
10341: FMT_TEMP[21] = (char) (x & 4 ^ 46);
10342: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
10343: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
10344: return String.valueOf (FMT_TEMP, 0, 24);
10345: }
10346: public static String fmtBin24 (int x) {
10347: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
10348: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
10349: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
10350: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
10351: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
10352: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
10353: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
10354: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
10355: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
10356: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
10357: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
10358: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
10359: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
10360: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
10361: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
10362: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
10363: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
10364: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
10365: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
10366: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
10367: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
10368: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
10369: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
10370: FMT_TEMP[23] = (char) (x & 1 | 48);
10371: return String.valueOf (FMT_TEMP, 0, 24);
10372: }
10373: public static StringBuilder fmtAin24 (StringBuilder sb, int x) {
10374: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
10375: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
10376: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
10377: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
10378: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
10379: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
10380: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
10381: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
10382: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
10383: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
10384: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
10385: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
10386: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
10387: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
10388: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
10389: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
10390: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
10391: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
10392: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
10393: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
10394: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
10395: FMT_TEMP[21] = (char) (x & 4 ^ 46);
10396: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
10397: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
10398: return sb.append (FMT_TEMP, 0, 24);
10399: }
10400: public static StringBuilder fmtBin24 (StringBuilder sb, int x) {
10401: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
10402: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
10403: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
10404: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
10405: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
10406: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
10407: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
10408: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
10409: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
10410: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
10411: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
10412: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
10413: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
10414: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
10415: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
10416: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
10417: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
10418: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
10419: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
10420: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
10421: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
10422: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
10423: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
10424: FMT_TEMP[23] = (char) (x & 1 | 48);
10425: return sb.append (FMT_TEMP, 0, 24);
10426: }
10427:
10428:
10429:
10430:
10431:
10432:
10433:
10434:
10435:
10436:
10437:
10438:
10439:
10440:
10441:
10442:
10443:
10444:
10445:
10446:
10447:
10448:
10449:
10450:
10451:
10452:
10453:
10454:
10455:
10456:
10457:
10458:
10459:
10460: public static char fmtHexc (int x) {
10461: x &= 15;
10462: return (char) ((((9 - x) >> 4) & 7) + 48 + x);
10463: }
10464: public static void fmtHex1 (char[] a, int o, int x) {
10465: x &= 15;
10466: a[o] = (char) ((((9 - x) >> 4) & 7) + 48 + x);
10467: }
10468: public static String fmtHex1 (int x) {
10469: x &= 15;
10470: return Character.toString ((char) ((((9 - x) >> 4) & 7) + 48 + x));
10471: }
10472: public static StringBuilder fmtHex1 (StringBuilder sb, int x) {
10473: x &= 15;
10474: return sb.append ((char) ((((9 - x) >> 4) & 7) + 48 + x));
10475: }
10476:
10477:
10478:
10479:
10480:
10481:
10482: public static void fmtHex2 (char[] a, int o, int x) {
10483: int x0 = x & 15;
10484: int x1 = x >>> 4 & 15;
10485: a[o ] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
10486: a[o + 1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
10487: }
10488: public static String fmtHex2 (int x) {
10489:
10490: int x0 = x & 15;
10491: int x1 = x >>> 4 & 15;
10492: FMT_TEMP[0] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
10493: FMT_TEMP[1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
10494: return String.valueOf (FMT_TEMP, 0, 2);
10495: }
10496: public static StringBuilder fmtHex2 (StringBuilder sb, int x) {
10497: int x0 = x & 15;
10498: int x1 = x >>> 4 & 15;
10499: return (sb.
10500: append ((char) ((((9 - x1) >> 4) & 7) + 48 + x1)).
10501: append ((char) ((((9 - x0) >> 4) & 7) + 48 + x0)));
10502: }
10503:
10504:
10505:
10506:
10507:
10508:
10509: public static void fmtHex4 (char[] a, int o, int x) {
10510: int t;
10511: t = (char) x >>> 12;
10512: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10513: t = x >>> 8 & 15;
10514: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10515: t = x >>> 4 & 15;
10516: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10517: t = x & 15;
10518: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10519: }
10520: public static String fmtHex4 (int x) {
10521:
10522: int t;
10523: t = (char) x >>> 12;
10524: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10525: t = x >>> 8 & 15;
10526: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10527: t = x >>> 4 & 15;
10528: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10529: t = x & 15;
10530: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10531: return String.valueOf (FMT_TEMP, 0, 4);
10532: }
10533: public static StringBuilder fmtHex4 (StringBuilder sb, int x) {
10534:
10535: int t;
10536: t = (char) x >>> 12;
10537: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10538: t = x >>> 8 & 15;
10539: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10540: t = x >>> 4 & 15;
10541: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10542: t = x & 15;
10543: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10544: return sb.append (FMT_TEMP, 0, 4);
10545: }
10546:
10547:
10548:
10549:
10550:
10551:
10552: public static void fmtHex6 (char[] a, int o, int x) {
10553: int t;
10554: t = x >>> 20 & 15;
10555: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10556: t = x >>> 16 & 15;
10557: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10558: t = (char) x >>> 12;
10559: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10560: t = x >>> 8 & 15;
10561: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10562: t = x >>> 4 & 15;
10563: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10564: t = x & 15;
10565: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10566: }
10567: public static String fmtHex6 (int x) {
10568:
10569: int t;
10570: t = x >>> 20 & 15;
10571: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10572: t = x >>> 16 & 15;
10573: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10574: t = (char) x >>> 12;
10575: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10576: t = x >>> 8 & 15;
10577: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10578: t = x >>> 4 & 15;
10579: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10580: t = x & 15;
10581: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10582: return String.valueOf (FMT_TEMP, 0, 6);
10583: }
10584: public static StringBuilder fmtHex6 (StringBuilder sb, int x) {
10585:
10586: int t;
10587: t = x >>> 20 & 15;
10588: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10589: t = x >>> 16 & 15;
10590: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10591: t = (char) x >>> 12;
10592: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10593: t = x >>> 8 & 15;
10594: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10595: t = x >>> 4 & 15;
10596: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10597: t = x & 15;
10598: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10599: return sb.append (FMT_TEMP, 0, 6);
10600: }
10601:
10602:
10603:
10604:
10605:
10606:
10607: public static void fmtHex8 (char[] a, int o, int x) {
10608: int t;
10609: t = x >>> 28;
10610: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10611: t = x >>> 24 & 15;
10612: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10613: t = x >>> 20 & 15;
10614: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10615: t = x >>> 16 & 15;
10616: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10617: t = (char) x >>> 12;
10618: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10619: t = x >>> 8 & 15;
10620: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10621: t = x >>> 4 & 15;
10622: a[o + 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10623: t = x & 15;
10624: a[o + 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10625: }
10626: public static String fmtHex8 (int x) {
10627:
10628: int t;
10629: t = x >>> 28;
10630: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10631: t = x >>> 24 & 15;
10632: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10633: t = x >>> 20 & 15;
10634: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10635: t = x >>> 16 & 15;
10636: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10637: t = (char) x >>> 12;
10638: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10639: t = x >>> 8 & 15;
10640: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10641: t = x >>> 4 & 15;
10642: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10643: t = x & 15;
10644: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10645: return String.valueOf (FMT_TEMP, 0, 8);
10646: }
10647: public static StringBuilder fmtHex8 (StringBuilder sb, int x) {
10648:
10649: int t;
10650: t = x >>> 28;
10651: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10652: t = x >>> 24 & 15;
10653: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10654: t = x >>> 20 & 15;
10655: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10656: t = x >>> 16 & 15;
10657: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10658: t = (char) x >>> 12;
10659: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10660: t = x >>> 8 & 15;
10661: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10662: t = x >>> 4 & 15;
10663: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10664: t = x & 15;
10665: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10666: return sb.append (FMT_TEMP, 0, 8);
10667: }
10668:
10669: public static StringBuilder fmtHex16 (StringBuilder sb, long x) {
10670:
10671: int s, t;
10672: s = (int) (x >>> 32);
10673: t = s >>> 28;
10674: FMT_TEMP[ 0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10675: t = s >>> 24 & 15;
10676: FMT_TEMP[ 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10677: t = s >>> 20 & 15;
10678: FMT_TEMP[ 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10679: t = s >>> 16 & 15;
10680: FMT_TEMP[ 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10681: t = (char) s >>> 12;
10682: FMT_TEMP[ 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10683: t = s >>> 8 & 15;
10684: FMT_TEMP[ 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10685: t = s >>> 4 & 15;
10686: FMT_TEMP[ 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10687: t = s & 15;
10688: FMT_TEMP[ 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10689: s = (int) x;
10690: t = s >>> 28;
10691: FMT_TEMP[ 8] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10692: t = s >>> 24 & 15;
10693: FMT_TEMP[ 9] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10694: t = s >>> 20 & 15;
10695: FMT_TEMP[10] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10696: t = s >>> 16 & 15;
10697: FMT_TEMP[11] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10698: t = (char) s >>> 12;
10699: FMT_TEMP[12] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10700: t = s >>> 8 & 15;
10701: FMT_TEMP[13] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10702: t = s >>> 4 & 15;
10703: FMT_TEMP[14] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10704: t = s & 15;
10705: FMT_TEMP[15] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10706: return sb.append (FMT_TEMP, 0, 16);
10707: }
10708:
10709:
10710:
10711:
10712:
10713:
10714:
10715:
10716:
10717:
10718:
10719:
10720:
10721:
10722:
10723:
10724:
10725:
10726:
10727:
10728:
10729:
10730:
10731:
10732:
10733:
10734:
10735:
10736:
10737:
10738:
10739:
10740:
10741:
10742:
10743:
10744:
10745:
10746:
10747:
10748:
10749:
10750:
10751:
10752:
10753:
10754:
10755:
10756:
10757:
10758:
10759:
10760:
10761:
10762:
10763:
10764:
10765:
10766:
10767:
10768:
10769:
10770:
10771:
10772:
10773:
10774:
10775:
10776: public static final int[] FMT_BCD4 = new int[10000];
10777: public static final int[] FMT_DCB4 = new int[65536];
10778:
10779:
10780:
10781:
10782: public static void fmtInit () {
10783: Arrays.fill (FMT_DCB4, -1);
10784: int i = 0;
10785: int x = 0;
10786: for (int a = 0; a < 10; a++) {
10787: for (int b = 0; b < 10; b++) {
10788: for (int c = 0; c < 10; c++) {
10789: FMT_DCB4[FMT_BCD4[i ] = x ] = i;
10790: FMT_DCB4[FMT_BCD4[i + 1] = x + 1] = i + 1;
10791: FMT_DCB4[FMT_BCD4[i + 2] = x + 2] = i + 2;
10792: FMT_DCB4[FMT_BCD4[i + 3] = x + 3] = i + 3;
10793: FMT_DCB4[FMT_BCD4[i + 4] = x + 4] = i + 4;
10794: FMT_DCB4[FMT_BCD4[i + 5] = x + 5] = i + 5;
10795: FMT_DCB4[FMT_BCD4[i + 6] = x + 6] = i + 6;
10796: FMT_DCB4[FMT_BCD4[i + 7] = x + 7] = i + 7;
10797: FMT_DCB4[FMT_BCD4[i + 8] = x + 8] = i + 8;
10798: FMT_DCB4[FMT_BCD4[i + 9] = x + 9] = i + 9;
10799: i += 10;
10800: x += 1 << 4;
10801: }
10802: x += 6 << 4;
10803: }
10804: x += 6 << 8;
10805: }
10806: }
10807:
10808:
10809:
10810: public static int fmtBcd4 (int x) {
10811:
10812:
10813:
10814:
10815:
10816:
10817:
10818:
10819:
10820: return FMT_BCD4[Math.max (0, Math.min (9999, x))];
10821: }
10822:
10823:
10824:
10825: public static int fmtBcd8 (int x) {
10826: x = Math.max (0, Math.min (99999999, x));
10827:
10828:
10829: int q = (int) ((long) x * 109951163L >>> 40);
10830:
10831: return FMT_BCD4[q] << 16 | FMT_BCD4[x - 10000 * q];
10832: }
10833:
10834:
10835:
10836: public static long fmtBcd12 (long x) {
10837: x = Math.max (0L, Math.min (999999999999L, x));
10838: int q = (int) ((double) x / 100000000.0);
10839: int r = (int) (x - 100000000L * q);
10840:
10841:
10842: int rq = (int) ((long) r * 109951163L >>> 40);
10843:
10844: return (long) FMT_BCD4[q] << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
10845: }
10846:
10847:
10848:
10849: public static long fmtBcd16 (long x) {
10850: x = Math.max (0L, Math.min (9999999999999999L, x));
10851: int q = x <= (1L << 53) ? (int) ((double) x / 100000000.0) : (int) (x / 100000000L);
10852: int r = (int) (x - 100000000L * q);
10853:
10854:
10855: int qq = (int) ((long) q * 109951163L >>> 40);
10856:
10857:
10858:
10859: int rq = (int) ((long) r * 109951163L >>> 40);
10860:
10861: return (long) (FMT_BCD4[qq] << 16 | FMT_BCD4[q - 10000 * qq]) << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
10862: }
10863:
10864:
10865:
10866:
10867:
10868:
10869: public static int fmtCA02u (char[] a, int o, int x) {
10870: if (x < 0 || 99 < x) {
10871: x = 99;
10872: }
10873: x = FMT_BCD4[x];
10874: a[o ] = (char) ('0' | x >>> 4);
10875: a[o + 1] = (char) ('0' | x & 15);
10876: return o + 2;
10877: }
10878: public static StringBuilder fmtSB02u (StringBuilder sb, int x) {
10879: return sb.append (FMT_TEMP, 0, fmtCA02u (FMT_TEMP, 0, x));
10880: }
10881:
10882:
10883:
10884:
10885:
10886: public static int fmtCA2u (char[] a, int o, int x) {
10887: if (x < 0 || 99 < x) {
10888: x = 99;
10889: }
10890: x = FMT_BCD4[x];
10891: if (x <= 0x000f) {
10892: a[o++] = (char) ('0' | x);
10893: } else {
10894: a[o++] = (char) ('0' | x >>> 4);
10895: a[o++] = (char) ('0' | x & 15);
10896: }
10897: return o;
10898: }
10899: public static StringBuilder fmtSB2u (StringBuilder sb, int x) {
10900: return sb.append (FMT_TEMP, 0, fmtCA2u (FMT_TEMP, 0, x));
10901: }
10902:
10903:
10904:
10905:
10906:
10907: public static int fmtCA04u (char[] a, int o, int x) {
10908: if (x < 0 || 9999 < x) {
10909: x = 9999;
10910: }
10911: x = FMT_BCD4[x];
10912: a[o ] = (char) ('0' | x >>> 12);
10913: a[o + 1] = (char) ('0' | x >>> 8 & 15);
10914: a[o + 2] = (char) ('0' | x >>> 4 & 15);
10915: a[o + 3] = (char) ('0' | x & 15);
10916: return o + 4;
10917: }
10918: public static StringBuilder fmtSB04u (StringBuilder sb, int x) {
10919: return sb.append (FMT_TEMP, 0, fmtCA04u (FMT_TEMP, 0, x));
10920: }
10921:
10922:
10923:
10924:
10925:
10926: public static int fmtCA4u (char[] a, int o, int x) {
10927: if (x < 0 || 9999 < x) {
10928: x = 9999;
10929: }
10930: x = FMT_BCD4[x];
10931: if (x <= 0x000f) {
10932: a[o++] = (char) ('0' | x);
10933: } else if (x <= 0x00ff) {
10934: a[o++] = (char) ('0' | x >>> 4);
10935: a[o++] = (char) ('0' | x & 15);
10936: } else if (x <= 0x0fff) {
10937: a[o++] = (char) ('0' | x >>> 8);
10938: a[o++] = (char) ('0' | x >>> 4 & 15);
10939: a[o++] = (char) ('0' | x & 15);
10940: } else {
10941: a[o++] = (char) ('0' | x >>> 12);
10942: a[o++] = (char) ('0' | x >>> 8 & 15);
10943: a[o++] = (char) ('0' | x >>> 4 & 15);
10944: a[o++] = (char) ('0' | x & 15);
10945: }
10946: return o;
10947: }
10948: public static StringBuilder fmtSB4u (StringBuilder sb, int x) {
10949: return sb.append (FMT_TEMP, 0, fmtCA4u (FMT_TEMP, 0, x));
10950: }
10951:
10952:
10953:
10954:
10955:
10956: public static int fmtCA08u (char[] a, int o, int x) {
10957: if (x < 0 || 99999999 < x) {
10958: x = 99999999;
10959: }
10960:
10961:
10962: int h = (int) ((long) x * 109951163L >>> 40);
10963: return fmtCA04u (a, fmtCA04u (a, o, h), x - h * 10000);
10964: }
10965: public static StringBuilder fmtSB08u (StringBuilder sb, int x) {
10966: return sb.append (FMT_TEMP, 0, fmtCA08u (FMT_TEMP, 0, x));
10967: }
10968:
10969:
10970:
10971:
10972:
10973: public static int fmtCA8u (char[] a, int o, int x) {
10974: if (x < 0 || 99999999 < x) {
10975: x = 99999999;
10976: }
10977: if (x <= 9999) {
10978: return fmtCA4u (a, o, x);
10979: } else {
10980:
10981:
10982: int h = (int) ((long) x * 109951163L >>> 40);
10983: return fmtCA04u (a, fmtCA4u (a, o, h), x - h * 10000);
10984: }
10985: }
10986: public static StringBuilder fmtSB8u (StringBuilder sb, int x) {
10987: return sb.append (FMT_TEMP, 0, fmtCA8u (FMT_TEMP, 0, x));
10988: }
10989:
10990:
10991:
10992:
10993:
10994: public static int fmtCAd (char[] a, int o, long x) {
10995: if (x < 0L) {
10996: x = -x;
10997: a[o++] = '-';
10998: }
10999: if (x <= 99999999L) {
11000: return fmtCA8u (a, o, (int) x);
11001: } else if (x <= 9999999999999999L) {
11002: long h = x / 100000000L;
11003: return fmtCA08u (a, fmtCA8u (a, o, (int) h), (int) (x - h * 100000000L));
11004: } else {
11005: long hh = x / 10000000000000000L;
11006: x -= hh * 10000000000000000L;
11007: long h = x / 100000000L;
11008: return fmtCA08u (a, fmtCA08u (a, fmtCA4u (a, o, (int) hh), (int) h), (int) (x - h * 100000000L));
11009: }
11010: }
11011: public static StringBuilder fmtSBd (StringBuilder sb, long x) {
11012: return sb.append (FMT_TEMP, 0, fmtCAd (FMT_TEMP, 0, x));
11013: }
11014:
11015:
11016:
11017:
11018:
11019:
11020: public static int fmtCAnd (char[] a, int o, int n, long x) {
11021: int t = fmtCAd (a, o, x);
11022: n += o;
11023: if (t < n) {
11024: int i = n;
11025: while (o < t) {
11026: a[--i] = a[--t];
11027: }
11028: while (o < i) {
11029: a[--i] = ' ';
11030: }
11031: t = n;
11032: }
11033: return t;
11034: }
11035: public static StringBuilder fmtSBnd (StringBuilder sb, int n, int x) {
11036: return sb.append (FMT_TEMP, 0, fmtCAnd (FMT_TEMP, 0, n, x));
11037: }
11038:
11039:
11040:
11041:
11042:
11043:
11044:
11045:
11046:
11047:
11048:
11049:
11050:
11051: public static int fmtParseInt (String s, int i, int min, int max, int err) {
11052: return fmtParseIntRadix (s, i, min, max, err, 10);
11053: }
11054: public static int fmtParseIntRadix (String s, int i, int min, int max, int err, int radix) {
11055: if (s == null) {
11056: return err;
11057: }
11058: int l = s.length ();
11059: int c = i < l ? s.charAt (i++) : -1;
11060:
11061: while (c == ' ' || c == '\t') {
11062: c = i < l ? s.charAt (i++) : -1;
11063: }
11064:
11065: int n = 0;
11066: if (c == '+') {
11067: c = i < l ? s.charAt (i++) : -1;
11068: } else if (c == '-') {
11069: n = 1;
11070: c = i < l ? s.charAt (i++) : -1;
11071: }
11072:
11073:
11074:
11075:
11076: int o;
11077: int p;
11078: if (c == '$') {
11079: o = 0x07ffffff + n;
11080: p = 15 + n & 15;
11081: radix = 16;
11082: c = i < l ? s.charAt (i++) : -1;
11083: } else if (radix == 16) {
11084: o = 0x07ffffff + n;
11085: p = 15 + n & 15;
11086: } else if (radix == 8) {
11087: o = 0x0fffffff + n;
11088: p = 7 + n & 7;
11089: } else if (radix == 2) {
11090: o = 0x3fffffff + n;
11091: p = 1 + n & 1;
11092: } else {
11093: o = 214748364;
11094: p = 7 + n;
11095: radix = 10;
11096: }
11097:
11098: int x = Character.digit (c, radix);
11099: if (x < 0) {
11100: return err;
11101: }
11102: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
11103: while (c >= 0) {
11104: int t = x - o;
11105: if (t > 0 || t == 0 && c > p) {
11106: return err;
11107: }
11108: x = x * radix + c;
11109: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
11110: }
11111: if (n != 0) {
11112: x = -x;
11113: }
11114: return min <= x && x <= max ? x : err;
11115: }
11116:
11117:
11118:
11119:
11120:
11121:
11122:
11123:
11124:
11125:
11126: public static long matMax3 (long x1, long x2, long x3) {
11127: return Math.max (Math.max (x1, x2), x3);
11128: }
11129: public static long matMax4 (long x1, long x2, long x3, long x4) {
11130: return Math.max (Math.max (x1, x2), Math.max (x3, x4));
11131: }
11132: public static long matMax5 (long x1, long x2, long x3, long x4, long x5) {
11133: return Math.max (Math.max (Math.max (x1, x2), Math.max (x3, x4)), x5);
11134: }
11135:
11136:
11137:
11138:
11139:
11140: public static long matMin3 (long x1, long x2, long x3) {
11141: return Math.min (Math.min (x1, x2), x3);
11142: }
11143: public static long matMin4 (long x1, long x2, long x3, long x4) {
11144: return Math.min (Math.min (x1, x2), Math.min (x3, x4));
11145: }
11146: public static long matMin5 (long x1, long x2, long x3, long x4, long x5) {
11147: return Math.min (Math.min (Math.min (x1, x2), Math.min (x3, x4)), x5);
11148: }
11149:
11150:
11151:
11152:
11153:
11154:
11155:
11156:
11157:
11158:
11159:
11160:
11161: public static String strEncodeUTF8 (String s) {
11162: StringBuilder sb = new StringBuilder ();
11163: int l = s.length ();
11164: for (int i = 0; i < l; i++) {
11165: int u = s.charAt (i);
11166: if (0xd800 <= u && u <= 0xdbff && i + 1 < l) {
11167: int v = s.charAt (i + 1);
11168: if (0xdc00 <= v && v <= 0xdfff) {
11169: u = 0x10000 + ((u & 0x3ff) << 10) + (v & 0x3ff);
11170: i++;
11171: }
11172: }
11173: if ((u & 0xffffff80) == 0) {
11174: sb.append ((char) u);
11175: } else if ((u & 0xfffff800) == 0) {
11176: u = (0x0000c080 |
11177: (u & 0x000007c0) << 2 |
11178: (u & 0x0000003f));
11179: sb.append ((char) (u >> 8)).append ((char) (u & 0xff));
11180: } else if ((u & 0xffff0000) == 0 && !(0xd800 <= u && u <= 0xdfff)) {
11181: u = (0x00e08080 |
11182: (u & 0x0000f000) << 4 |
11183: (u & 0x00000fc0) << 2 |
11184: (u & 0x0000003f));
11185: sb.append ((char) (u >> 16)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
11186: } else if ((u & 0xffe00000) == 0) {
11187: u = (0xf0808080 |
11188: (u & 0x001c0000) << 6 |
11189: (u & 0x0003f000) << 4 |
11190: (u & 0x00000fc0) << 2 |
11191: (u & 0x0000003f));
11192: sb.append ((char) ((u >> 24) & 0xff)).append ((char) ((u >> 16) & 0xff)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
11193: } else {
11194: sb.append ((char) 0xef).append ((char) 0xbf).append ((char) 0xbd);
11195: }
11196: }
11197: return sb.toString ();
11198: }
11199:
11200:
11201:
11202:
11203:
11204:
11205:
11206: public static String strDecodeUTF8 (String s) {
11207: StringBuilder sb = new StringBuilder ();
11208: int l = s.length ();
11209: for (int i = 0; i < l; i++) {
11210: int c = s.charAt (i) & 0xff;
11211: for (int k = ((c & 0x80) == 0x00 ? 0 :
11212: (c & 0xe0) == 0xc0 ? 1 :
11213: (c & 0xf0) == 0xe0 ? 2 :
11214: (c & 0xf8) == 0xf0 ? 3 :
11215: -1);
11216: --k >= 0; ) {
11217: c = c << 8 | (i + 1 < l ? s.charAt (++i) & 0xff : 0);
11218: }
11219: int u = ((c & 0xffffff80) == 0x00000000 ? c :
11220: (c & 0xffffe0c0) == 0x0000c080 ? ((c & 0x00001f00) >> 2 |
11221: (c & 0x0000003f)) :
11222: (c & 0xfff0c0c0) == 0x00e08080 ? ((c & 0x000f0000) >> 4 |
11223: (c & 0x00003f00) >> 2 |
11224: (c & 0x0000003f)) :
11225: (c & 0xf8c0c0c0) == 0xf0808080 ? ((c & 0x07000000) >> 6 |
11226: (c & 0x003f0000) >> 4 |
11227: (c & 0x00003f00) >> 2 |
11228: (c & 0x0000003f)) :
11229: 0xfffd);
11230: if (u <= 0x0000ffff) {
11231: sb.append (0xd800 <= u && u <= 0xdfff ? '\ufffd' :
11232: (char) u);
11233: } else if (u <= 0x0010ffff) {
11234: u -= 0x000010000;
11235: sb.append ((char) (0xd800 + ((u >> 10) & 0x3ff))).append ((char) (0xdc00 + (u & 0x3ff)));
11236: }
11237: }
11238: return sb.toString ();
11239: }
11240:
11241:
11242:
11243:
11244:
11245: public static final int[] IsURIChar = {
11246:
11247:
11248: 0b00000000_00000000_00000000_00000000,
11249: 0b00000000_00000110_11111111_11000000,
11250: 0b01111111_11111111_11111111_11100001,
11251: 0b01111111_11111111_11111111_11100010,
11252: };
11253: public static String strEncodeURI (String s) {
11254: s = strEncodeUTF8 (s);
11255: StringBuilder sb = new StringBuilder ();
11256: int l = s.length ();
11257: for (int i = 0; i < l; i++) {
11258: int c = s.charAt (i);
11259: if (c < 0x80 && IsURIChar[c >> 5] << c < 0) {
11260: sb.append ((char) c);
11261: } else {
11262: fmtHex2 (sb.append ('%'), c);
11263: }
11264: }
11265: return sb.toString ();
11266: }
11267:
11268:
11269:
11270:
11271:
11272: public static final byte[] strIsHexChar = {
11273:
11274: -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,
11275: -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,
11276: -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,
11277: -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,
11278: };
11279: public static String strDecodeURI (String s) {
11280: StringBuilder sb = new StringBuilder ();
11281: int l = s.length ();
11282: for (int i = 0; i < l; i++) {
11283: int c = s.charAt (i);
11284: if (c == '%' && i + 2 < l) {
11285: int d = s.charAt (i + 1);
11286: int e = s.charAt (i + 2);
11287: if (d < 0x80 && (d = strIsHexChar[d]) >= 0 &&
11288: e < 0x80 && (e = strIsHexChar[e]) >= 0) {
11289: sb.append ((char) (d << 4 | e));
11290: } else {
11291: sb.append ((char) c);
11292: }
11293: } else {
11294: sb.append ((char) c);
11295: }
11296: }
11297: return sb.toString ();
11298: }
11299:
11300:
11301:
11302:
11303:
11304:
11305:
11306:
11307: public static BufferedImage createImage (int width, int height, String pattern, int... rgbs) {
11308: BufferedImage image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
11309: int[] bitmap = ((DataBufferInt) image.getRaster ().getDataBuffer ()).getData ();
11310: int length = width * height;
11311: for (int i = 0; i < length; i++) {
11312: char c = pattern.charAt (i);
11313: bitmap[i] = rgbs[c < '0' ? 0 : Character.digit (c, 16)];
11314: }
11315: return image;
11316: }
11317:
11318:
11319:
11320: public static ImageIcon createImageIcon (int width, int height, String pattern, int... rgbs) {
11321: return new ImageIcon (createImage (width, height, pattern, rgbs));
11322: }
11323:
11324:
11325:
11326: public static TexturePaint createTexturePaint (int width, int height, String pattern, int... rgbs) {
11327: return new TexturePaint (createImage (width, height, pattern, rgbs), new Rectangle (0, 0, width, height));
11328: }
11329:
11330:
11331:
11332: public static BufferedImage loadImage (String name) {
11333: BufferedImage image = null;
11334: try {
11335: image = ImageIO.read (new File (name));
11336: } catch (Exception e) {
11337: }
11338: return image;
11339: }
11340:
11341:
11342:
11343:
11344: public static boolean saveImage (BufferedImage image, String name) {
11345: return saveImage (image, name, 0.75F);
11346: }
11347: public static boolean saveImage (BufferedImage image, String name, float quality) {
11348: int index = name.lastIndexOf (".");
11349: if (index < 0) {
11350: return false;
11351: }
11352: if (name.substring (index).equalsIgnoreCase (".ico")) {
11353: return saveIcon (name, image);
11354: }
11355: Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix (name.substring (index + 1));
11356: if (!iterator.hasNext ()) {
11357: return false;
11358: }
11359: ImageWriter imageWriter = iterator.next ();
11360: ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam ();
11361: if (imageWriteParam.canWriteCompressed ()) {
11362: imageWriteParam.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);
11363: imageWriteParam.setCompressionQuality (quality);
11364: }
11365: try {
11366: File file = new File (name);
11367: ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream (file);
11368: imageWriter.setOutput (imageOutputStream);
11369: imageWriter.write (null, new IIOImage (image, null, null), imageWriteParam);
11370: imageOutputStream.close ();
11371: } catch (Exception e) {
11372:
11373: return false;
11374: }
11375: return true;
11376: }
11377:
11378:
11379:
11380:
11381:
11382:
11383:
11384:
11385:
11386:
11387:
11388:
11389:
11390:
11391:
11392:
11393:
11394:
11395:
11396:
11397:
11398:
11399:
11400:
11401:
11402:
11403:
11404:
11405:
11406:
11407:
11408:
11409:
11410:
11411:
11412:
11413:
11414:
11415:
11416:
11417:
11418:
11419:
11420:
11421:
11422:
11423:
11424:
11425:
11426:
11427:
11428:
11429:
11430:
11431:
11432:
11433:
11434:
11435:
11436:
11437:
11438:
11439:
11440:
11441:
11442:
11443:
11444:
11445:
11446:
11447:
11448:
11449:
11450: public static boolean saveIcon (String fileName, BufferedImage... arrayImage) {
11451: int iconCount = arrayImage.length;
11452: int[][] arrayPaletTable = new int[iconCount][];
11453: int[] arrayPaletCount = new int[iconCount];
11454: int[] arrayPixelBits = new int[iconCount];
11455: int[] arrayPatternLineSize = new int[iconCount];
11456: int[] arrayMaskLineSize = new int[iconCount];
11457: int[] arrayImageSize = new int[iconCount];
11458: int[] arrayImageOffset = new int[iconCount];
11459: int fileSize = 6 + 16 * iconCount;
11460: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
11461: BufferedImage image = arrayImage[iconNumber];
11462: int width = image.getWidth ();
11463: int height = image.getHeight ();
11464:
11465: int[] paletTable = new int[256];
11466: int paletCount = 0;
11467: countPalet:
11468: for (int y = height - 1; y >= 0; y--) {
11469: for (int x = 0; x < width; x++) {
11470: int rgb = image.getRGB (x, y);
11471: if (rgb >>> 24 != 0xff) {
11472: continue;
11473: }
11474: int l = 0;
11475: int r = paletCount;
11476: while (l < r) {
11477: int m = l + r >> 1;
11478: if (paletTable[m] < rgb) {
11479: l = m + 1;
11480: } else {
11481: r = m;
11482: }
11483: }
11484: if (l == paletCount || paletTable[l] != rgb) {
11485: if (paletCount == 256) {
11486: paletCount = 0;
11487: break countPalet;
11488: }
11489: for (int i = paletCount; i > l; i--) {
11490: paletTable[i] = paletTable[i - 1];
11491: }
11492: paletTable[l] = rgb;
11493: paletCount++;
11494: }
11495: }
11496: }
11497: int pixelBits = (paletCount == 0 ? 24 :
11498: paletCount > 16 ? 8 :
11499: paletCount > 4 ? 4 :
11500: paletCount > 2 ? 2 :
11501: 1);
11502: int patternLineSize = pixelBits * width + 31 >> 5 << 2;
11503: int maskLineSize = width + 31 >> 5 << 2;
11504: int imageSize = 40 + 4 * paletCount + patternLineSize * height + maskLineSize * height;
11505: arrayPaletTable[iconNumber] = paletTable;
11506: arrayPaletCount[iconNumber] = paletCount;
11507: arrayPixelBits[iconNumber] = pixelBits;
11508: arrayPatternLineSize[iconNumber] = patternLineSize;
11509: arrayMaskLineSize[iconNumber] = maskLineSize;
11510: arrayImageSize[iconNumber] = imageSize;
11511: arrayImageOffset[iconNumber] = fileSize;
11512: fileSize += imageSize;
11513: }
11514: byte[] bb = new byte[fileSize];
11515:
11516: ByteArray.byaWiw (bb, 0, 0);
11517: ByteArray.byaWiw (bb, 2, 1);
11518: ByteArray.byaWiw (bb, 4, iconCount);
11519: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
11520: BufferedImage image = arrayImage[iconNumber];
11521: int width = image.getWidth ();
11522: int height = image.getHeight ();
11523: int[] paletTable = arrayPaletTable[iconNumber];
11524: int paletCount = arrayPaletCount[iconNumber];
11525: int pixelBits = arrayPixelBits[iconNumber];
11526: int patternLineSize = arrayPatternLineSize[iconNumber];
11527: int maskLineSize = arrayMaskLineSize[iconNumber];
11528: int imageSize = arrayImageSize[iconNumber];
11529: int imageOffset = arrayImageOffset[iconNumber];
11530:
11531: int o = 6 + 16 * iconNumber;
11532: ByteArray.byaWb (bb, o, width);
11533: ByteArray.byaWb (bb, o + 1, height);
11534: ByteArray.byaWb (bb, o + 2, paletCount);
11535: ByteArray.byaWb (bb, o + 3, 0);
11536: ByteArray.byaWiw (bb, o + 4, 1);
11537: ByteArray.byaWiw (bb, o + 6, pixelBits);
11538: ByteArray.byaWil (bb, o + 8, imageSize);
11539: ByteArray.byaWil (bb, o + 12, imageOffset);
11540:
11541: o = imageOffset;
11542: ByteArray.byaWil (bb, o, 40);
11543: ByteArray.byaWil (bb, o + 4, width);
11544: ByteArray.byaWil (bb, o + 8, height * 2);
11545: ByteArray.byaWiw (bb, o + 12, 1);
11546: ByteArray.byaWiw (bb, o + 14, pixelBits);
11547: ByteArray.byaWil (bb, o + 16, 0);
11548: ByteArray.byaWil (bb, o + 20, 0);
11549: ByteArray.byaWil (bb, o + 24, 0);
11550: ByteArray.byaWil (bb, o + 28, 0);
11551: ByteArray.byaWil (bb, o + 32, paletCount);
11552: ByteArray.byaWil (bb, o + 36, 0);
11553:
11554: o += 40;
11555: for (int i = 0; i < paletCount; i++) {
11556: ByteArray.byaWil (bb, o, paletTable[i] & 0x00ffffff);
11557: o += 4;
11558: }
11559:
11560: for (int y = height - 1; y >= 0; y--) {
11561: for (int x = 0; x < width; x++) {
11562: int rgb = image.getRGB (x, y);
11563: if (rgb >>> 24 != 0xff) {
11564: continue;
11565: }
11566: if (pixelBits == 24) {
11567: bb[o + 3 * x] = (byte) rgb;
11568: bb[o + 3 * x + 1] = (byte) (rgb >> 8);
11569: bb[o + 3 * x + 2] = (byte) (rgb >> 16);
11570: continue;
11571: }
11572: int l = 0;
11573: int r = paletCount;
11574: while (l < r) {
11575: int m = l + r >> 1;
11576: if (paletTable[m] < rgb) {
11577: l = m + 1;
11578: } else {
11579: r = m;
11580: }
11581: }
11582: if (l != 0) {
11583: if (pixelBits == 8) {
11584: bb[o + x] = (byte) l;
11585: } else if (pixelBits == 4) {
11586: bb[o + (x >> 1)] |= (byte) (l << ((~x & 1) << 2));
11587: } else if (pixelBits == 2) {
11588: bb[o + (x >> 2)] |= (byte) (l << ((~x & 3) << 1));
11589: } else {
11590: bb[o + (x >> 3)] |= (byte) (l << (~x & 7));
11591: }
11592: }
11593: }
11594: o += patternLineSize;
11595: }
11596:
11597: for (int y = height - 1; y >= 0; y--) {
11598: for (int x = 0; x < width; x++) {
11599: int rgb = image.getRGB (x, y);
11600: if (rgb >>> 24 != 0xff) {
11601: bb[o + (x >> 3)] |= (byte) (1 << (~x & 7));
11602: }
11603: }
11604: o += maskLineSize;
11605: }
11606: }
11607: return rscPutFile (fileName, bb, 0, fileSize);
11608: }
11609:
11610:
11611:
11612: }
11613:
11614:
11615: