XEiJ.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13: package xeij;
14:
15: import java.awt.*;
16: import java.awt.datatransfer.*;
17: import java.awt.dnd.*;
18: import java.awt.event.*;
19: import java.awt.font.*;
20: import java.awt.geom.*;
21: import java.awt.image.*;
22: import java.io.*;
23: import java.lang.*;
24: import java.math.*;
25: import java.net.*;
26: import java.nio.*;
27: import java.nio.charset.*;
28: import java.nio.file.*;
29: import java.util.*;
30: import java.util.function.*;
31: import java.util.regex.*;
32: import java.util.stream.*;
33: import java.util.zip.*;
34: import javax.imageio.*;
35: import javax.imageio.stream.*;
36: import javax.swing.*;
37: import javax.swing.event.*;
38: import javax.swing.text.*;
39:
40: public class XEiJ {
41:
42:
43:
44:
45:
46: static {
47: System.setProperty ("sun.java2d.xrender", "false");
48: }
49:
50:
51: public static final String PRG_TITLE = "XEiJ (X68000 Emulator in Java)";
52: public static final String PRG_VERSION = "0.25.11.22";
53: public static final String PRG_AUTHOR = "Makoto Kamada";
54: public static final String PRG_WEBPAGE = "https://stdkmd.net/xeij/";
55:
56: public static final String PRG_JAVA_VENDOR = "Oracle Corporation";
57: public static final String PRG_JAVA_VERSION = "25.0.1";
58: public static final String PRG_OS_ARCH = "amd64";
59: public static final String PRG_OS_NAME = "Windows 11";
60:
61:
62:
63:
64:
65:
66:
67: public static final boolean TEST_BIT_0_SHIFT = false;
68: public static final boolean TEST_BIT_1_SHIFT = false;
69: public static final boolean TEST_BIT_2_SHIFT = true;
70: public static final boolean TEST_BIT_3_SHIFT = true;
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88: public static final boolean SHORT_SATURATION_CAST = false;
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100: public static final Charset ISO_8859_1 = Charset.forName ("ISO-8859-1");
101: static {
102: if (false) {
103:
104: StringBuilder sb = new StringBuilder ();
105: for (int i = 0; i < 256; i++) {
106: sb.append ((char) i);
107: }
108: byte[] bb = sb.toString ().getBytes (ISO_8859_1);
109: for (int i = 0; i < 256; i++) {
110: System.out.printf ("%02x %02x %s\n", i, bb[i] & 255, i == (bb[i] & 255) ? "OK" : "ERROR");
111: }
112: }
113: }
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126: public static String prgJavaVendor;
127: public static String prgJavaVersion;
128: public static String prgOsArch;
129: public static String prgOsName;
130: public static boolean prgIsLinux;
131: public static boolean prgIsMac;
132: public static boolean prgIsWindows;
133:
134: public static boolean prgCaseIgnored;
135:
136: public static boolean prgVerbose;
137:
138: public static String[] prgArgs;
139:
140:
141:
142: public static void main (String[] args) {
143:
144:
145:
146:
147: if (true) {
148: try {
149: String def = System.getProperty ("os.name").toLowerCase ().contains ("win") ? "C:\\Temp" : "/tmp";
150: Stream.of (new File (System.getProperty ("java.io.tmpdir", def),
151: "jSerialComm").getCanonicalFile ().toPath (),
152: new File (System.getProperty ("user.home", def),
153: ".jSerialComm").getCanonicalFile ().toPath ())
154: .filter (Files::exists)
155: .forEach (dir -> {
156: try {
157: Files.walk (dir)
158: .sorted (Comparator.reverseOrder ())
159: .forEach (path -> {
160: if (Files.exists (path)) {
161: try {
162: Files.delete (path);
163:
164: } catch (IOException ioe) {
165: System.err.println ("Failed to delete: " + path + " (" + ioe.getMessage () + ")");
166: }
167: }
168: });
169: } catch (IOException ioe) {
170: System.err.println ("Failed to walk: " + dir + " (" + ioe.getMessage () + ")");
171: }
172: });
173: } catch (IOException ioe) {
174: }
175: }
176:
177: prgArgs = args;
178:
179:
180: SwingUtilities.invokeLater (new Runnable () {
181: @Override public void run () {
182: new XEiJ ();
183: }
184: });
185:
186: }
187:
188:
189:
190: public XEiJ () {
191:
192: prgJavaVendor = System.getProperty ("java.vendor");
193: prgJavaVersion = System.getProperty ("java.version");
194: prgOsArch = System.getProperty ("os.arch");
195: prgOsName = System.getProperty ("os.name");
196: prgIsLinux = 0 <= prgOsName.indexOf ("Linux");
197: prgIsMac = 0 <= prgOsName.indexOf ("Mac");
198: prgIsWindows = 0 <= prgOsName.indexOf ("Windows");
199:
200: System.out.print ("\n" +
201: "-------------------------------------------------\n" +
202: PRG_TITLE + " version " + PRG_VERSION + "\n" +
203: "-------------------------------------------------\n");
204:
205:
206:
207:
208: prgCaseIgnored = new File ("A").equals (new File ("a"));
209: fmtInit ();
210: Multilingual.mlnInit ();
211:
212: System.out.println (Multilingual.mlnJapanese ? "java.vendor は " + prgJavaVendor + " です" :
213: "java.vendor is " + prgJavaVendor);
214: System.out.println (Multilingual.mlnJapanese ? "java.version は " + prgJavaVersion + " です" :
215: "java.version is " + prgJavaVersion);
216: System.out.println (Multilingual.mlnJapanese ? "os.arch は " + prgOsArch + " です" :
217: "os.arch is " + prgOsArch);
218: System.out.println (Multilingual.mlnJapanese ? "os.name は " + prgOsName + " です" :
219: "os.name is " + prgOsName);
220:
221: rbtInit ();
222:
223: Settings.sgsInit ();
224: LnF.lnfInit ();
225: Bubble.bblInit ();
226:
227: CharacterCode.chrInit ();
228:
229: TickerQueue.tkqInit ();
230:
231: RS232CTerminal.trmInit ();
232:
233: xt3Init ();
234: mdlInit ();
235:
236: if (InstructionBreakPoint.IBP_ON) {
237: InstructionBreakPoint.ibpInit ();
238: }
239: if (DataBreakPoint.DBP_ON) {
240: DataBreakPoint.dbpInit ();
241: }
242: busInit ();
243: MainMemory.mmrInit ();
244: ROM.romInit ();
245: CRTC.crtInit ();
246: VideoController.vcnInit ();
247: HD63450.dmaInit ();
248: svsInit ();
249: MC68901.mfpInit ();
250: RP5C15.rtcInit ();
251: sysInit ();
252: if (OPMLog.OLG_ON) {
253: OPMLog.olgInit ();
254: }
255: OPM.opmInit ();
256: ADPCM.pcmInit ();
257: FDC.fdcInit ();
258: HDC.hdcInit ();
259: if (HostCDROM.HCD_ENABLED) {
260: HostCDROM.hcdInit ();
261: }
262: SPC.spcInit ();
263: Z8530.sccInit ();
264: IOInterrupt.ioiInit ();
265: SpriteScreen.sprInit ();
266: bnkInit ();
267: SRAM.smrInit ();
268:
269: PPI.ppiInit ();
270: PrinterPort.prnInit ();
271: Indicator.indInit ();
272:
273: SlowdownTest.sdtInit ();
274: Keyboard.kbdInit ();
275: CONDevice.conInit ();
276: Mouse.musInit ();
277: pnlInit ();
278: frmInit ();
279:
280: dbgInit ();
281: RegisterList.drpInit ();
282: DisassembleList.ddpInit ();
283: MemoryDumpList.dmpInit ();
284: LogicalSpaceMonitor.atwInit ();
285: PhysicalSpaceMonitor.paaInit ();
286: DebugConsole.dgtInit ();
287: if (BranchLog.BLG_ON) {
288: BranchLog.blgInit ();
289: }
290: if (ProgramFlowVisualizer.PFV_ON) {
291: ProgramFlowVisualizer.pfvInit ();
292: }
293: if (RasterBreakPoint.RBP_ON) {
294: RasterBreakPoint.rbpInit ();
295: }
296: if (ScreenModeTest.SMT_ON) {
297: ScreenModeTest.smtInit ();
298: }
299: if (RootPointerList.RTL_ON) {
300: RootPointerList.rtlInit ();
301: }
302: if (SpritePatternViewer.SPV_ON) {
303: SpritePatternViewer.spvInit ();
304: }
305: if (PaletteViewer.PLV_ON) {
306: PaletteViewer.plvInit ();
307: }
308: if (ATCMonitor.ACM_ON) {
309: ATCMonitor.acmInit ();
310: }
311:
312: SoundSource.sndInit ();
313: FEFunction.fpkInit ();
314: mpuInit ();
315: MC68060.mmuInit ();
316: SoundMonitor.smnInit ();
317: HFS.hfsInit ();
318:
319: GIFAnimation.gifInit ();
320: TextCopy.txcInit ();
321: ButtonFunction.bfnInit ();
322:
323:
324:
325: Settings.sgsMakeMenu ();
326: mdlMakeMenu ();
327: FDC.fdcMakeMenu ();
328: HDC.hdcMakeMenu ();
329: SPC.spcMakeMenu ();
330: mpuMakeMenu ();
331: SRAM.smrMakeMenu ();
332: clpMake ();
333: pnlMake ();
334: mnbMakeMenu ();
335: frmMake ();
336: dbgMakePopup ();
337:
338:
339: final String flags = (
340: "" +
341: (EFPBox.CIR_DEBUG_TRACE ? " EFPBox.CIR_DEBUG_TRACE" : "") +
342: (FDC.FDC_DEBUG_TRACE ? " FDC.FDC_DEBUG_TRACE" : "") +
343: (FEFunction.FPK_DEBUG_TRACE ? " FEFunction.FPK_DEBUG_TRACE" : "") +
344: (HD63450.DMA_DEBUG_TRACE != 0 ? " HD63450.DMA_DEBUG_TRACE" : "") +
345: (HDC.HDC_DEBUG_TRACE ? " HDC.HDC_DEBUG_TRACE" : "") +
346: (HDC.HDC_DEBUG_COMMAND ? " HDC.HDC_DEBUG_COMMAND" : "") +
347: (HFS.HFS_DEBUG_TRACE ? " HFS.HFS_DEBUG_TRACE" : "") +
348: (HFS.HFS_DEBUG_FILE_INFO ? " HFS.HFS_DEBUG_FILE_INFO" : "") +
349: (HFS.HFS_COMMAND_TRACE ? " HFS.HFS_COMMAND_TRACE" : "") +
350: (HFS.HFS_BUFFER_TRACE ? " HFS.HFS_BUFFER_TRACE" : "") +
351: (IOInterrupt.IOI_DEBUG_TRACE ? " IOInterrupt.IOI_DEBUG_TRACE" : "") +
352: (Keyboard.KBD_DEBUG_LED ? " Keyboard.KBD_DEBUG_LED" : "") +
353: (MC68060.MMU_DEBUG_COMMAND ? " MC68060.MMU_DEBUG_COMMAND" : "") +
354: (MC68060.MMU_DEBUG_TRANSLATION ? " MC68060.MMU_DEBUG_TRANSLATION" : "") +
355: (MC68060.MMU_NOT_ALLOCATE_CACHE ? " MC68060.MMU_NOT_ALLOCATE_CACHE" : "") +
356: (RP5C15.RTC_DEBUG_TRACE ? " RP5C15.RTC_DEBUG_TRACE" : "") +
357: (SPC.SPC_DEBUG_ON ? " SPC.SPC_DEBUG_ON" : "") +
358: (Z8530.SCC_DEBUG_ON ? " Z8530.SCC_DEBUG_ON" : "")
359: );
360: if (!"".equals (flags)) {
361: pnlExitFullScreen (true);
362: JOptionPane.showMessageDialog (null, "debug flags:" + flags);
363: }
364:
365:
366:
367:
368: tmrStart ();
369:
370: Keyboard.kbdStart ();
371: Mouse.musStart ();
372: pnlStart ();
373: frmStart ();
374: SoundSource.sndStart ();
375:
376: if (DataBreakPoint.DBP_ON) {
377: DataBreakPoint.dbpStart ();
378: }
379: if (RasterBreakPoint.RBP_ON) {
380: RasterBreakPoint.rbpStart ();
381: }
382: if (ScreenModeTest.SMT_ON) {
383: ScreenModeTest.smtStart ();
384: }
385: if (OPMLog.OLG_ON) {
386: OPMLog.olgStart ();
387: }
388: SoundMonitor.smnStart ();
389: RS232CTerminal.trmStart ();
390: PPI.ppiStart ();
391: PrinterPort.prnStart ();
392: if (BranchLog.BLG_ON) {
393: BranchLog.blgStart ();
394: }
395: if (ProgramFlowVisualizer.PFV_ON) {
396: ProgramFlowVisualizer.pfvStart ();
397: }
398: RegisterList.drpStart ();
399: DisassembleList.ddpStart ();
400: MemoryDumpList.dmpStart ();
401: LogicalSpaceMonitor.atwStart ();
402: PhysicalSpaceMonitor.paaStart ();
403: DebugConsole.dgtStart ();
404: if (RootPointerList.RTL_ON) {
405: RootPointerList.rtlStart ();
406: }
407: if (SpritePatternViewer.SPV_ON) {
408: SpritePatternViewer.spvStart ();
409: }
410: if (PaletteViewer.PLV_ON) {
411: PaletteViewer.plvStart ();
412: }
413: if (ATCMonitor.ACM_ON) {
414: ATCMonitor.acmStart ();
415: }
416: ButtonFunction.bfnStart ();
417:
418: if (Settings.sgsSaveiconValue != null) {
419: String[] a = Settings.sgsSaveiconValue.split (",");
420: if (0 < a.length) {
421: saveIcon (a[0], LnF.LNF_ICON_IMAGES);
422: if (1 < a.length) {
423: saveImage (LnF.LNF_ICON_IMAGE_16, a[1]);
424: if (2 < a.length) {
425: saveImage (LnF.LNF_ICON_IMAGE_32, a[2]);
426: if (3 < a.length) {
427: saveImage (LnF.LNF_ICON_IMAGE_48, a[3]);
428: }
429: }
430: }
431: }
432: prgTini ();
433: return;
434: }
435:
436:
437: mpuReset (-1, -1);
438:
439: pnlBoot2 ();
440:
441: }
442:
443:
444:
445:
446:
447: public static void prgTini () {
448: try {
449: if (OPMLog.OLG_ON) {
450: OPMLog.olgTini ();
451: }
452: ButtonFunction.bfnTini ();
453: TextCopy.txcTini ();
454: GIFAnimation.gifTini ();
455: SoundSource.sndTini ();
456: Keyboard.kbdTini ();
457: Mouse.musTini ();
458: CONDevice.conTini ();
459: PPI.ppiTini ();
460: PrinterPort.prnTini ();
461: FDC.fdcTini ();
462: HDC.hdcTini ();
463: if (HostCDROM.HCD_ENABLED) {
464: HostCDROM.hcdTini ();
465: }
466: SPC.spcTini ();
467: HFS.hfsTini ();
468: Z8530.sccTini ();
469: CRTC.crtTini ();
470: SpriteScreen.sprTini ();
471: pnlTini ();
472: bnkTini ();
473: ROM.romTini ();
474: xt3Tini ();
475: mdlTini ();
476: SRAM.smrTini ();
477: tmrTini ();
478: busTini ();
479: if (SpritePatternViewer.SPV_ON) {
480: SpritePatternViewer.spvTini ();
481: }
482: if (PaletteViewer.PLV_ON) {
483: PaletteViewer.plvTini ();
484: }
485: RS232CTerminal.trmTini ();
486: LnF.lnfTini ();
487: Settings.sgsTini ();
488: } catch (Exception e) {
489: e.printStackTrace ();
490: }
491: System.exit (0);
492: }
493:
494:
495:
496: public static void prgOpenJavaDialog () {
497: pnlExitFullScreen (true);
498: JOptionPane.showMessageDialog (
499: frmFrame,
500: ComponentFactory.createGridPanel (
501: 3,
502: 6,
503: "paddingLeft=6,paddingRight=6",
504: "italic,right;left;left",
505: "italic,center;colSpan=3,widen",
506: "",
507:
508: null,
509: Multilingual.mlnJapanese ? "実行中" : "Running",
510: Multilingual.mlnJapanese ? "推奨" : "Recommended",
511:
512: ComponentFactory.createHorizontalSeparator (),
513:
514: Multilingual.mlnJapanese ? "Java のベンダー" : "Java Vendor",
515: prgJavaVendor,
516: PRG_JAVA_VENDOR,
517:
518: Multilingual.mlnJapanese ? "Java のバージョン" : "Java Version",
519: prgJavaVersion,
520: PRG_JAVA_VERSION,
521:
522: Multilingual.mlnJapanese ? "OS のアーキテクチャ" : "OS Architecture",
523: prgOsArch,
524: PRG_OS_ARCH,
525:
526: Multilingual.mlnJapanese ? "OS の名前" : "OS Name",
527: prgOsName,
528: PRG_OS_NAME
529: ),
530: Multilingual.mlnJapanese ? "Java 実行環境の情報" : "Java runtime environment information",
531: JOptionPane.PLAIN_MESSAGE);
532: }
533:
534:
535:
536: public static void prgOpenAboutDialog () {
537: pnlExitFullScreen (true);
538: JOptionPane.showMessageDialog (
539: frmFrame,
540: ComponentFactory.createGridPanel (
541: 2, 4, "paddingLeft=6,paddingRight=6", "italic,right;left", "", "",
542: Multilingual.mlnJapanese ? "タイトル" : "Title" ,
543: PRG_TITLE,
544: Multilingual.mlnJapanese ? "バージョン" : "Version",
545: PRG_VERSION,
546: Multilingual.mlnJapanese ? "作者" : "Author" ,
547: PRG_AUTHOR,
548: Multilingual.mlnJapanese ? "ウェブページ" : "Webpage",
549: PRG_WEBPAGE
550: ),
551: Multilingual.mlnJapanese ? "バージョン情報" : "Version information",
552: JOptionPane.PLAIN_MESSAGE);
553: }
554:
555:
556:
557: public static void prgOpenXEiJLicenseDialog () {
558: pnlExitFullScreen (true);
559: JOptionPane.showMessageDialog (
560: frmFrame,
561: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_XEiJ.txt"), 550, 300),
562: Multilingual.mlnJapanese ? "XEiJ 使用許諾条件" : "XEiJ License",
563: JOptionPane.PLAIN_MESSAGE);
564: }
565:
566:
567:
568: public static void prgOpenSHARPLicenseDialog () {
569: pnlExitFullScreen (true);
570: JOptionPane.showMessageDialog (
571: frmFrame,
572: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_FSHARP.txt", "Shift_JIS"), 550, 300),
573: Multilingual.mlnJapanese ? "無償公開された X68000 の基本ソフトウェア製品の許諾条件" : "License of the basic software products for X68000 that were distributed free of charge",
574: JOptionPane.PLAIN_MESSAGE);
575: }
576:
577:
578:
579: public static void prgOpenYmfmLicenseDialog () {
580: pnlExitFullScreen (true);
581: JOptionPane.showMessageDialog (
582: frmFrame,
583: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_ymfm.txt"), 550, 300),
584: "ymfm License",
585: JOptionPane.PLAIN_MESSAGE);
586: }
587:
588:
589:
590: public static void prgOpenJSerialCommLicenseDialog () {
591: pnlExitFullScreen (true);
592: JOptionPane.showMessageDialog (
593: frmFrame,
594: ComponentFactory.createVerticalSplitPane (
595: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-APACHE-2.0"), 550, 300),
596: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-LGPL-3.0"), 550, 300)
597: ),
598: "jSerialComm License",
599: JOptionPane.PLAIN_MESSAGE);
600: }
601:
602:
603:
604: public static void prgPrintClass (Object o) {
605: System.out.println (o.toString ());
606:
607: try {
608: Stack<Class<?>> s = new Stack<Class<?>> ();
609: for (Class<?> c = o.getClass (); c != null; c = c.getSuperclass ()) {
610: s.push (c);
611: }
612: for (int i = 0; !s.empty (); i++) {
613: for (int j = 0; j < i; j++) {
614: System.out.print (" ");
615: }
616: System.out.println (s.pop ().getName ());
617: }
618: } catch (Exception e) {
619: }
620: }
621:
622:
623:
624:
625: public static void prgPrintStackTrace () {
626: Exception e = new Exception ();
627: e.fillInStackTrace ();
628: prgPrintStackTraceOf (e);
629: }
630: public static void prgPrintStackTraceOf (Exception e) {
631:
632: System.out.println ("------------------------------------------------");
633: System.out.println (e.toString ());
634: System.out.println ("\t" + e.getMessage ());
635: for (StackTraceElement ste : e.getStackTrace ()) {
636: System.out.println ("\tat " + ste.toString ());
637: }
638: System.out.println ("------------------------------------------------");
639: }
640:
641:
642:
643:
644: public static boolean prgStopDone = false;
645: public static void prgStopOnce () {
646: if (!prgStopDone) {
647: prgStopDone = true;
648: mpuStop (null);
649: }
650: }
651:
652:
653:
654:
655:
656:
657:
658:
659:
660:
661:
662:
663:
664:
665:
666:
667:
668:
669:
670:
671:
672:
673:
674:
675:
676:
677:
678:
679:
680:
681:
682: public static final long TMR_FREQ = 1000000000000L;
683:
684:
685: public static final long TMR_DELAY = 10L;
686: public static final long TMR_INTERVAL = 10L;
687:
688:
689: public static java.util.Timer tmrTimer;
690:
691:
692:
693: public static void tmrStart () {
694: tmrTimer = new java.util.Timer ();
695: }
696:
697:
698:
699: public static void tmrTini () {
700: if (tmrTimer != null) {
701: tmrTimer.cancel ();
702: }
703: }
704:
705:
706:
707:
708:
709:
710:
711:
712:
713:
714:
715:
716:
717:
718:
719:
720:
721:
722:
723:
724:
725:
726:
727:
728:
729:
730:
731:
732:
733:
734:
735:
736:
737:
738:
739: public static final int PNL_BM_OFFSET_BITS = 10;
740: public static final int PNL_BM_WIDTH = 1 << PNL_BM_OFFSET_BITS;
741: public static final int PNL_BM_HEIGHT = 1024;
742:
743:
744: public static final int PNL_ASPECT_KEYS = 4;
745: public static final int PNL_ASPECT_VALUES = 4;
746: public static final int[] PNL_ASPECT_DEFAULT_VALUE = { 0, 0, 0, 3 };
747: public static final String[] PNL_ASPECT_RESOLUTION_NAME = { "256x256", "384x256", "512x512", "768x512" };
748: public static final String[] PNL_ASPECT_SCREEN_NAME = { "4:3", "7:5", "13:9", "3:2" };
749: public static final String[] PNL_ASPECT_PIXEL_NAME = { "8:9", "14:15", "26:27", "1:1" };
750: public static final float[] PNL_ASPECT_SCREEN_RATIO = { 4.0F / 3.0F, 7.0F / 5.0F, 13.0F / 9.0F, 3.0F / 2.0F };
751: public static final float[] PNL_ASPECT_PIXEL_RATIO = { 8.0F / 9.0F, 14.0F / 15.0F, 26.0F / 27.0F, 1.0F / 1.0F };
752: public static final float[][] PNL_ASPECT_MATRIX = {
753: PNL_ASPECT_SCREEN_RATIO,
754: PNL_ASPECT_PIXEL_RATIO,
755: PNL_ASPECT_SCREEN_RATIO,
756: PNL_ASPECT_PIXEL_RATIO,
757: };
758: public static int[] pnlAspectMap;
759: public static float[] pnlAspectTable;
760:
761:
762: public static final int PNL_MIN_WIDTH = 64;
763: public static final int PNL_MIN_HEIGHT = 64;
764: public static int pnlScreenWidth;
765: public static int pnlScreenHeight;
766: public static float pnlStretchMode;
767: public static int pnlStretchWidth;
768:
769: public static boolean PNL_ROTATION_ON = true;
770: public static int pnlRotationMode;
771: public static AffineTransform pnlRotationTransformLeft;
772: public static AffineTransform pnlRotationTransformRight;
773: public static double pnlMatrixL00, pnlMatrixL10, pnlMatrixL01, pnlMatrixL11, pnlMatrixL02, pnlMatrixL12;
774: public static double pnlMatrixR00, pnlMatrixR10, pnlMatrixR01, pnlMatrixR11, pnlMatrixR02, pnlMatrixR12;
775: public static double pnlInverseL00, pnlInverseL10, pnlInverseL01, pnlInverseL11, pnlInverseL02, pnlInverseL12;
776: public static double pnlInverseR00, pnlInverseR10, pnlInverseR01, pnlInverseR11, pnlInverseR02, pnlInverseR12;
777: public static int pnlRotatedWidth;
778: public static int pnlRotatedHeight;
779:
780: public static int pnlZoomWidth;
781: public static int pnlZoomHeight;
782: public static int pnlZoomRatioOutX;
783: public static int pnlZoomRatioOutY;
784: public static int pnlZoomRatioInX;
785: public static int pnlZoomRatioInY;
786: public static int pnlWidth;
787: public static int pnlHeight;
788: public static Dimension pnlSize;
789: public static int pnlScreenX1;
790: public static int pnlScreenX2;
791: public static int pnlScreenX3;
792: public static int pnlScreenX4;
793: public static int pnlScreenY1;
794: public static int pnlScreenY2;
795: public static int pnlScreenY3;
796: public static int pnlScreenY4;
797: public static int pnlKeyboardX;
798: public static int pnlKeyboardY;
799: public static int pnlMinimumWidth;
800: public static int pnlMinimumHeight;
801: public static int pnlGlobalX;
802: public static int pnlGlobalY;
803:
804:
805: public static final boolean PNL_FILL_BACKGROUND = true;
806: public static boolean pnlFillBackgroundRequest;
807: public static boolean pnlIsFullScreenSupported;
808: public static boolean pnlPrevKeyboardOn;
809: public static boolean pnlHideKeyboard;
810:
811:
812:
813:
814:
815: public static Object pnlInterpolation;
816:
817:
818: public static final double PNL_MIN_RATE = 1.0;
819: public static final double PNL_MAX_RATE = 1000.0;
820: public static final double PNL_DEFAULT_RATE = 59.94;
821: public static double pnlRefreshRate;
822: public static double pnlFixedRate;
823: public static boolean pnlAdjustVsync;
824:
825:
826:
827:
828:
829:
830:
831:
832:
833:
834:
835:
836:
837:
838:
839:
840:
841:
842:
843:
844:
845:
846:
847:
848:
849:
850:
851:
852:
853:
854:
855:
856:
857:
858:
859:
860:
861:
862:
863:
864:
865:
866:
867:
868:
869:
870:
871:
872:
873: public static final boolean PNL_STEREOSCOPIC_ON = true;
874:
875: public static final boolean PNL_USE_THREAD = true;
876:
877: public static BufferedImage[] pnlScreenImageLeftArray;
878: public static BufferedImage[] pnlScreenImageRightArray;
879:
880: public static BufferedImage[] pnlScreenSubImageLeftArray;
881: public static BufferedImage[] pnlScreenSubImageRightArray;
882:
883: public static int[][] pnlBMLeftArray;
884: public static int[][] pnlBMRightArray;
885: public static volatile int pnlBMWrite;
886: public static volatile int pnlBMRead;
887:
888: public static BufferedImage pnlScreenImageLeft;
889: public static BufferedImage pnlScreenImageRight;
890:
891: public static BufferedImage pnlScreenSubImageLeft;
892: public static BufferedImage pnlScreenSubImageRight;
893:
894: public static int[] pnlBMLeft;
895: public static int[] pnlBMRight;
896:
897: public static int[] pnlBM;
898: public static boolean pnlStereoscopicOn;
899: public static final int PNL_NAKED_EYE_CROSSING = 0;
900: public static final int PNL_NAKED_EYE_PARALLEL = 1;
901: public static final int PNL_SIDE_BY_SIDE = 2;
902: public static final int PNL_TOP_AND_BOTTOM = 3;
903: public static int pnlStereoscopicMethod;
904: public static int pnlStereoscopicFactor;
905: public static int pnlStereoscopicShutter;
906:
907:
908: public static JPanel pnlPanel;
909:
910: public static Thread pnlThread;
911: public static long pnlWakeupTime;
912: public static long pnlWakeupTimeMNP;
913: public static final boolean PNL_USE_CANVAS = PNL_USE_THREAD && true;
914:
915: public static boolean pnlUseCanvasRequest;
916: public static boolean pnlUseCanvas;
917: public static Canvas pnlCanvas;
918: public static Component pnlCanvasOrPanel;
919:
920:
921:
922:
923: public static int pnlFixedScale;
924: public static SpinnerNumberModel pnlFixedModel;
925: public static JSpinner pnlFixedSpinner;
926:
927:
928:
929: public static void pnlInit () {
930: pnlInit2 ();
931:
932:
933:
934:
935: pnlFixedScale = Math.max (10, Math.min (1000, Settings.sgsGetInt ("fixedscale")));
936:
937:
938: pnlAspectMap = new int[PNL_ASPECT_KEYS];
939: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
940: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[key];
941: String screenName = Settings.sgsGetString ("aspectratio" + resolutionName);
942: int value = PNL_ASPECT_DEFAULT_VALUE[key];
943: for (int tempValue = 0; tempValue < PNL_ASPECT_VALUES; tempValue++) {
944: if (PNL_ASPECT_SCREEN_NAME[tempValue].equals (screenName)) {
945: value = tempValue;
946: break;
947: }
948: }
949: pnlAspectMap[key] = value;
950: }
951: pnlAspectTable = new float[8];
952: pnlUpdateAspectTable ();
953:
954:
955: switch (Settings.sgsGetString ("interpolation").toLowerCase ()) {
956: case "nearest":
957: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
958: break;
959: case "bilinear":
960: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
961: break;
962: case "bicubic":
963: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
964: break;
965: default:
966: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
967: }
968:
969:
970: pnlRefreshRate = 0.0;
971: {
972: String s = Settings.sgsGetString ("refreshrate");
973: if (!s.equals ("")) {
974: try {
975: double rate = Double.parseDouble (s);
976: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
977: pnlRefreshRate = rate;
978: }
979: } catch (NumberFormatException nfe) {
980: }
981: }
982: }
983: pnlFixedRate = pnlRefreshRate;
984: pnlAdjustVsync = Settings.sgsGetOnOff ("adjustvsync");
985:
986: pnlPrevKeyboardOn = true;
987:
988: pnlHideKeyboard = Settings.sgsGetOnOff ("hidekeyboard");
989:
990:
991: if (PNL_USE_THREAD) {
992: pnlScreenImageLeftArray = new BufferedImage[4];
993: pnlScreenImageRightArray = new BufferedImage[4];
994: if (PNL_ROTATION_ON) {
995: pnlScreenSubImageLeftArray = new BufferedImage[4];
996: pnlScreenSubImageRightArray = new BufferedImage[4];
997: }
998: pnlBMLeftArray = new int[4][];
999: pnlBMRightArray = new int[4][];
1000: for (int n = 0; n < 4; n++) {
1001: pnlScreenImageLeftArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1002: pnlScreenImageRightArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1003: if (PNL_ROTATION_ON) {
1004: pnlScreenSubImageLeftArray[n] = null;
1005: pnlScreenSubImageRightArray[n] = null;
1006: }
1007: pnlBMLeftArray[n] = ((DataBufferInt) pnlScreenImageLeftArray[n].getRaster ().getDataBuffer ()).getData ();
1008: pnlBMRightArray[n] = ((DataBufferInt) pnlScreenImageRightArray[n].getRaster ().getDataBuffer ()).getData ();
1009: }
1010: pnlBMWrite = 0;
1011: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
1012: pnlBMRead = 0;
1013: pnlThread = null;
1014: pnlWakeupTime = 0L;
1015: pnlWakeupTimeMNP = 0L;
1016: if (PNL_USE_CANVAS) {
1017: pnlUseCanvasRequest = Settings.sgsGetOnOff ("usecanvas");
1018: pnlUseCanvas = pnlUseCanvasRequest;
1019: pnlCanvas = null;
1020: }
1021: } else {
1022: pnlScreenImageLeft = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1023: pnlScreenImageRight = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1024: if (PNL_ROTATION_ON) {
1025: pnlScreenSubImageLeft = null;
1026: pnlScreenSubImageRight = null;
1027: }
1028: pnlBMLeft = ((DataBufferInt) pnlScreenImageLeft.getRaster ().getDataBuffer ()).getData ();
1029: pnlBMRight = ((DataBufferInt) pnlScreenImageRight.getRaster ().getDataBuffer ()).getData ();
1030: pnlBM = pnlBMLeft;
1031: }
1032: pnlStereoscopicOn = Settings.sgsGetOnOff ("stereoscopic");
1033: switch (Settings.sgsGetString ("stereoscopicmethod").toLowerCase ()) {
1034: case "nakedeyecrossing":
1035: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
1036: break;
1037: case "nakedeyeparallel":
1038: pnlStereoscopicMethod = PNL_NAKED_EYE_PARALLEL;
1039: break;
1040: case "sidebyside":
1041: pnlStereoscopicMethod = PNL_SIDE_BY_SIDE;
1042: break;
1043: case "topandbottom":
1044: pnlStereoscopicMethod = PNL_TOP_AND_BOTTOM;
1045: break;
1046: default:
1047: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
1048: }
1049: pnlStereoscopicFactor = pnlStereoscopicOn && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1050: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1051: pnlStereoscopicShutter = 0;
1052:
1053:
1054: pnlScreenWidth = 768;
1055: pnlScreenHeight = 512;
1056: pnlStretchMode = 1.0F;
1057: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchMode);
1058:
1059: if (PNL_ROTATION_ON) {
1060: pnlRotationMode = Settings.sgsGetInt ("rotation", 0);
1061: if (pnlRotationMode < 0 || 3 < pnlRotationMode) {
1062: pnlRotationMode = 0;
1063: }
1064: pnlRotationTransformLeft = new AffineTransform ();
1065: pnlRotationTransformRight = new AffineTransform ();
1066: }
1067: pnlRotatedWidth = pnlStretchWidth;
1068: pnlRotatedHeight = pnlScreenHeight;
1069: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1070: pnlRotatedWidth = pnlScreenHeight;
1071: pnlRotatedHeight = pnlStretchWidth;
1072: }
1073:
1074: pnlZoomWidth = pnlRotatedWidth;
1075: pnlZoomHeight = pnlRotatedHeight;
1076: pnlWidth = Math.max (pnlZoomWidth * pnlStereoscopicFactor, Keyboard.kbdWidth);
1077: pnlHeight = pnlZoomHeight + Keyboard.kbdHeight;
1078: pnlSize = new Dimension (pnlWidth, pnlHeight);
1079: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1080: pnlScreenY1 = 0;
1081: pnlArrangementCommon ();
1082: pnlMinimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
1083: pnlMinimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
1084: pnlGlobalX = 0;
1085: pnlGlobalY = 0;
1086:
1087:
1088: if (!PNL_FILL_BACKGROUND) {
1089: pnlFillBackgroundRequest = true;
1090: }
1091:
1092:
1093: pnlFixedModel = new SpinnerNumberModel (pnlFixedScale, 10, 1000, 1);
1094: pnlFixedSpinner = ComponentFactory.createNumberSpinner (pnlFixedModel, 4, new ChangeListener () {
1095: @Override public void stateChanged (ChangeEvent ce) {
1096: if (pnlMode != PNL_FIXEDSCALE) {
1097: pnlSetMode (PNL_FIXEDSCALE);
1098: } else {
1099: pnlUpdateArrangement ();
1100: }
1101: }
1102: });
1103:
1104: }
1105:
1106:
1107:
1108: public static double pnlGetRefreshRate () {
1109: double rate = 0.0;
1110: GraphicsConfiguration gc = frmFrame.getGraphicsConfiguration ();
1111: if (gc != null) {
1112: GraphicsDevice gd = gc.getDevice ();
1113: DisplayMode dm = gd.getDisplayMode ();
1114: int i = dm.getRefreshRate ();
1115: if (i != DisplayMode.REFRESH_RATE_UNKNOWN) {
1116: rate = (i == 23 ? 23.98 :
1117: i == 29 ? 29.97 :
1118: i == 59 ? 59.94 :
1119: i == 119 ? 119.88 :
1120: i == 239 ? 239.76 :
1121: (double) i);
1122: if (rate < PNL_MIN_RATE || PNL_MAX_RATE < rate) {
1123: rate = 0.0;
1124: }
1125: }
1126: }
1127: if (rate == 0.0) {
1128: rate = PNL_DEFAULT_RATE;
1129: System.out.printf (Multilingual.mlnJapanese ?
1130: "ホストのリフレッシュレートを取得できません。デフォルトの %.2f Hz を使います\n" :
1131: "Cannot get host refresh rate. Use default %.2f Hz\n", rate);
1132: } else {
1133: System.out.printf (Multilingual.mlnJapanese ?
1134: "ホストのリフレッシュレートは %.2f Hz です\n" :
1135: "Host refresh rate is %.2f Hz\n", rate);
1136: }
1137: return rate;
1138: }
1139:
1140:
1141: public static void pnlSetStereoscopic (boolean on, int method) {
1142: if (pnlStereoscopicOn != on || pnlStereoscopicMethod != method) {
1143: pnlStereoscopicMethod = method;
1144: pnlStereoscopicFactor = on && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1145: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1146: if (!pnlStereoscopicOn && on) {
1147: if (PNL_USE_THREAD) {
1148: for (int n = 0; n < 4; n++) {
1149: System.arraycopy (pnlBMLeftArray[n], 0, pnlBMRightArray[n], 0, 1024 * 1024);
1150: }
1151: } else {
1152: System.arraycopy (pnlBMLeft, 0, pnlBMRight, 0, 1024 * 1024);
1153: }
1154: } else if (pnlStereoscopicOn && !on) {
1155: if (PNL_USE_THREAD) {
1156: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
1157: } else {
1158: pnlBM = pnlBMLeft;
1159: }
1160: }
1161: pnlStereoscopicOn = on;
1162: pnlUpdateArrangement ();
1163: }
1164: }
1165:
1166:
1167: public static void pnlTini () {
1168: pnlTini2 ();
1169: if (PNL_USE_THREAD) {
1170: if (pnlThread != null) {
1171: pnlThread.interrupt ();
1172: try {
1173: pnlThread.join ();
1174: } catch (InterruptedException ie) {
1175: }
1176: pnlThread = null;
1177: }
1178: }
1179:
1180:
1181: Settings.sgsPutInt ("fixedscale", pnlFixedScale);
1182:
1183:
1184: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
1185: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[key];
1186: int value = pnlAspectMap[key];
1187: String screenName = PNL_ASPECT_SCREEN_NAME[value];
1188: Settings.sgsPutString ("aspectratio" + resolutionName, screenName);
1189: }
1190:
1191:
1192: Settings.sgsPutString ("interpolation",
1193: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR ? "nearest" :
1194: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR ? "bilinear" :
1195: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC ? "bicubic" :
1196: "bilinear");
1197:
1198: if (pnlRefreshRate != PNL_DEFAULT_RATE) {
1199: Settings.sgsPutString ("refreshrate",
1200: pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate));
1201: }
1202: Settings.sgsPutOnOff ("adjustvsync", pnlAdjustVsync);
1203:
1204: Settings.sgsPutOnOff ("hidekeyboard", pnlHideKeyboard);
1205:
1206: if (PNL_USE_CANVAS) {
1207: Settings.sgsPutOnOff ("usecanvas", pnlUseCanvasRequest);
1208: }
1209:
1210:
1211: Settings.sgsPutOnOff ("stereoscopic", pnlStereoscopicOn);
1212: Settings.sgsPutString ("stereoscopicmethod",
1213: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ? "nakedeyecrossing" :
1214: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL ? "nakedeyeparallel" :
1215: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ? "sidebyside" :
1216: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM ? "topandbottom" :
1217: "nakedeyecrossing");
1218:
1219:
1220: if (PNL_ROTATION_ON) {
1221: Settings.sgsPutInt ("rotation", pnlRotationMode);
1222: }
1223:
1224: }
1225:
1226:
1227:
1228: public static void pnlUpdateAspectTable () {
1229: float[] ratio = new float[PNL_ASPECT_KEYS];
1230: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
1231: int value = pnlAspectMap[key];
1232: ratio[key] = PNL_ASPECT_MATRIX[key][value];
1233: }
1234: pnlAspectTable[0] = ratio[0] * 2.0F;
1235: pnlAspectTable[1] = ratio[2];
1236: pnlAspectTable[2] = ratio[3];
1237: pnlAspectTable[3] = ratio[3];
1238: pnlAspectTable[4] = ratio[1] * 4.0F;
1239: pnlAspectTable[5] = ratio[1] * 2.0F;
1240: pnlAspectTable[6] = ratio[3];
1241: pnlAspectTable[7] = ratio[3];
1242: }
1243:
1244:
1245:
1246: public static void pnlMake () {
1247: pnlMake2 ();
1248:
1249:
1250: if (PNL_USE_CANVAS && pnlUseCanvas) {
1251: pnlCanvas = new Canvas ();
1252: pnlPanel = new JPanel (new BorderLayout (0, 0));
1253: pnlPanel.add (pnlCanvas, BorderLayout.CENTER);
1254: pnlCanvasOrPanel = pnlCanvas;
1255: } else {
1256: pnlPanel = new JPanel () {
1257: @Override protected void paintComponent (Graphics g) {
1258: pnlPaintCommon (g);
1259: }
1260: @Override protected void paintBorder (Graphics g) {
1261: }
1262: @Override protected void paintChildren (Graphics g) {
1263: }
1264: };
1265: pnlCanvasOrPanel = pnlPanel;
1266: }
1267: pnlPanel.setBackground (Color.black);
1268: pnlPanel.setOpaque (true);
1269: pnlPanel.setPreferredSize (pnlSize);
1270:
1271: if (Mouse.musCursorAvailable) {
1272: pnlPanel.setCursor (Mouse.musCursorArray[1]);
1273: }
1274:
1275: }
1276:
1277:
1278:
1279: public static void pnlPaintCommon (Graphics g) {
1280: Graphics2D g2 = (Graphics2D) g;
1281: if (PNL_FILL_BACKGROUND || pnlFillBackgroundRequest) {
1282: if (!PNL_FILL_BACKGROUND) {
1283: pnlFillBackgroundRequest = false;
1284: }
1285: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1286: g2.setColor (Color.black);
1287: g2.fillRect (0, 0, pnlWidth, pnlHeight);
1288: }
1289: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, pnlInterpolation);
1290: if (PNL_USE_THREAD) {
1291: int d = pnlBMWrite - pnlBMRead;
1292: if (false) {
1293: System.out.print (d);
1294: }
1295: if (d < 1) {
1296: pnlBMRead += d - 1;
1297: } else if (3 < d) {
1298: pnlBMRead += d - 3;
1299: }
1300: int n = pnlBMRead++ & 3;
1301: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1302: BufferedImage leftImage;
1303: BufferedImage rightImage;
1304: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1305: leftImage = pnlScreenImageRightArray[n];
1306: rightImage = pnlScreenImageLeftArray[n];
1307: } else {
1308:
1309:
1310:
1311: leftImage = pnlScreenImageLeftArray[n];
1312: rightImage = pnlScreenImageRightArray[n];
1313: }
1314: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1315: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1316: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1317: } else {
1318: g2.drawImage (leftImage,
1319: pnlScreenX1, pnlScreenY1,
1320: pnlScreenX2, pnlScreenY2,
1321: 0, 0, pnlScreenWidth, pnlScreenHeight,
1322: null);
1323: g2.drawImage (rightImage,
1324: pnlScreenX3, pnlScreenY3,
1325: pnlScreenX4, pnlScreenY4,
1326: 0, 0, pnlScreenWidth, pnlScreenHeight,
1327: null);
1328: }
1329: } else {
1330: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1331: g2.drawImage (pnlScreenSubImageLeftArray[n], pnlRotationTransformLeft, null);
1332: } else {
1333: g2.drawImage (pnlScreenImageLeftArray[n],
1334: pnlScreenX1, pnlScreenY1,
1335: pnlScreenX2, pnlScreenY2,
1336: 0, 0, pnlScreenWidth, pnlScreenHeight,
1337: null);
1338: }
1339: }
1340: } else {
1341: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1342: BufferedImage leftImage;
1343: BufferedImage rightImage;
1344: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1345: leftImage = pnlScreenImageRight;
1346: rightImage = pnlScreenImageLeft;
1347: } else {
1348:
1349:
1350:
1351: leftImage = pnlScreenImageLeft;
1352: rightImage = pnlScreenImageRight;
1353: }
1354: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1355: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1356: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1357: } else {
1358: g2.drawImage (leftImage,
1359: pnlScreenX1, pnlScreenY1,
1360: pnlScreenX2, pnlScreenY2,
1361: 0, 0, pnlScreenWidth, pnlScreenHeight,
1362: null);
1363: g2.drawImage (rightImage,
1364: pnlScreenX3, pnlScreenY3,
1365: pnlScreenX4, pnlScreenY4,
1366: 0, 0, pnlScreenWidth, pnlScreenHeight,
1367: null);
1368: }
1369: } else {
1370: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1371: g2.drawImage (pnlScreenImageLeft, pnlRotationTransformLeft, null);
1372: } else {
1373: g2.drawImage (pnlScreenImageLeft,
1374: pnlScreenX1, pnlScreenY1,
1375: pnlScreenX2, pnlScreenY2,
1376: 0, 0, pnlScreenWidth, pnlScreenHeight,
1377: null);
1378: }
1379: }
1380: }
1381: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1382: g2.drawImage (Keyboard.kbdImage, pnlKeyboardX, pnlKeyboardY, null);
1383:
1384: if (TextCopy.txcEncloseEachTime && 0 <= TextCopy.txcRow1) {
1385: int x = TextCopy.txcCol1 << 3;
1386: int w = (TextCopy.txcCol2 - TextCopy.txcCol1 + 1) << 3;
1387: int y = TextCopy.txcRow1 << 4;
1388: int h = (TextCopy.txcRow2 - TextCopy.txcRow1 + 1) << 4;
1389: x -= CRTC.crtR10TxXCurr;
1390: y -= CRTC.crtR11TxYCurr;
1391: g2.setColor (Color.red);
1392: if (PNL_ROTATION_ON) {
1393: AffineTransform savedTransform = g2.getTransform ();
1394: g2.setTransform (pnlRotationTransformLeft);
1395: g2.drawRect (x, y, w, h);
1396: g2.setTransform (savedTransform);
1397: } else {
1398: g2.drawRect (pnlScreenX1 + ((x * pnlZoomRatioOutX) >> 16),
1399: pnlScreenY1 + ((y * pnlZoomRatioOutY) >> 16),
1400: ((w * pnlZoomRatioOutX) >> 16) - 1,
1401: ((h * pnlZoomRatioOutY) >> 16) - 1);
1402: }
1403: }
1404: if (Bubble.BBL_ON) {
1405: Bubble.bblDraw (g2);
1406: }
1407: }
1408:
1409:
1410:
1411:
1412: public static void pnlStart () {
1413: pnlStart2 ();
1414:
1415:
1416: ComponentFactory.addListener (
1417: pnlPanel,
1418: new ComponentAdapter () {
1419: @Override public void componentResized (ComponentEvent ce) {
1420: pnlUpdateArrangement ();
1421: }
1422: });
1423:
1424: if (PNL_USE_THREAD) {
1425: if (PNL_USE_CANVAS && pnlUseCanvas) {
1426: pnlCanvas.createBufferStrategy (2);
1427: pnlThread = new Thread () {
1428: @Override public void run () {
1429: do {
1430: BufferStrategy bs = pnlCanvas.getBufferStrategy ();
1431: if (bs != null) {
1432: Graphics g = bs.getDrawGraphics ();
1433: pnlPaintCommon (g);
1434: g.dispose ();
1435: bs.show ();
1436: }
1437: } while (!isInterrupted () && pnlWakeupCommon ());
1438: }
1439: };
1440: } else {
1441: pnlThread = new Thread () {
1442: @Override public void run () {
1443: do {
1444: pnlPanel.repaint ();
1445: if (!pnlWakeupCommon ()) {
1446: break;
1447: }
1448: } while (!isInterrupted () && pnlWakeupCommon ());
1449: }
1450: };
1451: }
1452: pnlWakeupTime = System.currentTimeMillis ();
1453: pnlWakeupTimeMNP = 0L;
1454: pnlThread.start ();
1455: }
1456:
1457: }
1458:
1459: public static boolean pnlWakeupCommon () {
1460: long t = System.currentTimeMillis ();
1461: if (CRTC.crtTotalLength == 0L) {
1462: pnlWakeupTime += 40L;
1463: } else {
1464: pnlWakeupTime += CRTC.crtTotalLength;
1465: pnlWakeupTimeMNP += CRTC.crtTotalLengthMNP;
1466: if (1000000000L <= pnlWakeupTimeMNP) {
1467: pnlWakeupTime++;
1468: pnlWakeupTimeMNP -= 1000000000L;
1469: }
1470: }
1471: pnlWakeupTime = Math.max (pnlWakeupTime, t + 4L);
1472: try {
1473: Thread.sleep (pnlWakeupTime - t);
1474: } catch (InterruptedException ie) {
1475: return false;
1476: }
1477: return true;
1478: }
1479:
1480:
1481:
1482:
1483:
1484: public static void pnlExitFullScreen (boolean dialog) {
1485: if (prgIsMac || !dialog) {
1486: pnlSetFullScreenOn (false);
1487: }
1488: }
1489:
1490:
1491:
1492: public static void pnlToggleFullScreen () {
1493: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1494: pnlSetMode (PNL_FULLSCREEN);
1495: } else {
1496: pnlSetMode (pnlPrevMode);
1497: }
1498: }
1499:
1500:
1501:
1502: public static void pnlToggleMaximized () {
1503: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1504: pnlSetMode (PNL_MAXIMIZED);
1505: } else {
1506: pnlSetMode (pnlPrevMode);
1507: }
1508: }
1509:
1510:
1511:
1512: public static void pnlSetFullScreenOn (boolean on) {
1513: if (on) {
1514: pnlSetMode (PNL_FULLSCREEN);
1515: } else if (pnlMode == PNL_FULLSCREEN) {
1516: pnlSetMode (pnlPrevMode);
1517: }
1518: }
1519:
1520:
1521:
1522:
1523: public static void pnlSetFitInWindowOn (boolean on) {
1524: if (!on) {
1525: pnlSetMode (PNL_FIXEDSCALE);
1526: } else if (pnlMode == PNL_FIXEDSCALE) {
1527: pnlSetMode (PNL_FITINWINDOW);
1528: }
1529: }
1530:
1531:
1532:
1533:
1534:
1535:
1536:
1537:
1538:
1539:
1540: public static void pnlUpdateArrangement () {
1541: pnlWidth = pnlPanel.getWidth ();
1542: pnlHeight = pnlPanel.getHeight ();
1543: frmMarginWidth = frmFrame.getWidth () - pnlWidth;
1544: frmMarginHeight = frmFrame.getHeight () - pnlHeight;
1545: pnlStretchMode = pnlAspectTable[CRTC.crtHRLCurr << 2 | CRTC.crtHResoCurr];
1546: pnlScreenWidth = Math.max (PNL_MIN_WIDTH, (CRTC.crtR03HDispEndCurr - CRTC.crtR02HBackEndCurr) << 3);
1547: pnlScreenHeight = Math.max (PNL_MIN_HEIGHT, (CRTC.crtR07VDispEndCurr - CRTC.crtR06VBackEndCurr) << (CRTC.crtInterlace || CRTC.crtSlit ? 1 : 0));
1548: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchMode);
1549: if (RasterBreakPoint.RBP_ON) {
1550:
1551: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
1552: RasterBreakPoint.rbpUpdateFrame ();
1553: }
1554: }
1555:
1556: pnlFixedScale = pnlFixedModel.getNumber ().intValue ();
1557:
1558: pnlRotatedWidth = pnlStretchWidth;
1559: pnlRotatedHeight = pnlScreenHeight;
1560: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1561: pnlRotatedWidth = pnlScreenHeight;
1562: pnlRotatedHeight = pnlStretchWidth;
1563: }
1564: if (pnlMode == PNL_FIXEDSCALE) {
1565:
1566:
1567:
1568:
1569:
1570: pnlZoomWidth = (pnlRotatedWidth * pnlFixedScale + 50) * 5243 >>> 19;
1571: pnlZoomHeight = (pnlRotatedHeight * pnlFixedScale + 50) * 5243 >>> 19;
1572: int width = Math.max (Math.max (PNL_MIN_WIDTH, pnlZoomWidth * pnlStereoscopicFactor), Keyboard.kbdWidth);
1573: int height = Math.max (PNL_MIN_HEIGHT, pnlZoomHeight) + Keyboard.kbdHeight;
1574: pnlScreenX1 = (width - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1575: pnlScreenY1 = (height - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1576: if (pnlWidth != width || pnlHeight != height) {
1577: pnlWidth = width;
1578: pnlHeight = height;
1579: pnlMinimumWidth = width;
1580: pnlMinimumHeight = height;
1581: pnlSize.setSize (width, height);
1582: pnlPanel.setMinimumSize (pnlSize);
1583: pnlPanel.setMaximumSize (pnlSize);
1584: pnlPanel.setPreferredSize (pnlSize);
1585: }
1586: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1587: frmFrame.setMinimumSize (frmMinimumSize);
1588: frmFrame.setMaximumSize (frmMinimumSize);
1589: frmFrame.setPreferredSize (frmMinimumSize);
1590: frmFrame.setResizable (false);
1591: frmFrame.pack ();
1592: } else {
1593:
1594: if (pnlWidth * pnlRotatedHeight >= (pnlHeight - Keyboard.kbdHeight) * (pnlRotatedWidth * pnlStereoscopicFactor)) {
1595:
1596:
1597:
1598:
1599:
1600:
1601:
1602:
1603:
1604:
1605:
1606:
1607: pnlZoomHeight = pnlHeight - Keyboard.kbdHeight;
1608: pnlZoomWidth = (pnlZoomHeight * pnlRotatedWidth + (pnlRotatedHeight >> 1)) / pnlRotatedHeight;
1609: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1610: pnlScreenX1 = ((pnlWidth >> 1) - (pnlZoomWidth >> 1)) >> 1;
1611: } else {
1612: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1613: }
1614: pnlScreenY1 = 0;
1615: } else {
1616:
1617:
1618:
1619:
1620:
1621:
1622:
1623:
1624:
1625:
1626:
1627:
1628:
1629:
1630:
1631:
1632: pnlZoomWidth = pnlWidth / pnlStereoscopicFactor;
1633: pnlZoomHeight = (pnlZoomWidth * pnlStereoscopicFactor * pnlRotatedHeight + (pnlRotatedWidth * pnlStereoscopicFactor >> 1)) / (pnlRotatedWidth * pnlStereoscopicFactor);
1634: pnlScreenX1 = 0;
1635: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM) {
1636: pnlScreenY1 = (((pnlHeight - Keyboard.kbdHeight) >> 1) - (pnlZoomHeight >> 1)) >> 1;
1637: } else {
1638: pnlScreenY1 = (pnlHeight - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1639: }
1640: }
1641:
1642: int minimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
1643: int minimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
1644: if (pnlMinimumWidth != minimumWidth || pnlMinimumHeight != minimumHeight) {
1645: pnlMinimumWidth = minimumWidth;
1646: pnlMinimumHeight = minimumHeight;
1647: }
1648: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1649: frmFrame.setMinimumSize (frmMinimumSize);
1650: frmFrame.setMaximumSize (null);
1651: frmFrame.setResizable (true);
1652: }
1653:
1654: pnlArrangementCommon ();
1655: Mouse.musUpdateSpeedRatio ();
1656: if (!PNL_FILL_BACKGROUND) {
1657: pnlFillBackgroundRequest = true;
1658: }
1659: }
1660:
1661: public static void pnlArrangementCommon () {
1662: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1663: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1664: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) {
1665: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1666: pnlScreenX3 = pnlScreenX2;
1667: pnlScreenX4 = pnlScreenX3 + pnlZoomWidth;
1668: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1669: pnlScreenY3 = pnlScreenY1;
1670: pnlScreenY4 = pnlScreenY2;
1671: } else if (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1672: pnlScreenX2 = pnlScreenX1 + (pnlZoomWidth >> 1);
1673: pnlScreenX3 = pnlScreenX2;
1674: pnlScreenX4 = pnlScreenX3 + (pnlZoomWidth >> 1);
1675: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1676: pnlScreenY3 = pnlScreenY1;
1677: pnlScreenY4 = pnlScreenY2;
1678: } else {
1679: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1680: pnlScreenX3 = pnlScreenX1;
1681: pnlScreenX4 = pnlScreenX2;
1682: pnlScreenY2 = pnlScreenY1 + (pnlZoomHeight >> 1);
1683: pnlScreenY3 = pnlScreenY2;
1684: pnlScreenY4 = pnlScreenY3 + (pnlZoomHeight >> 1);
1685: }
1686: } else {
1687: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1688: pnlScreenX3 = pnlScreenX1;
1689: pnlScreenX4 = pnlScreenX2;
1690: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1691: pnlScreenY3 = pnlScreenY1;
1692: pnlScreenY4 = pnlScreenY2;
1693: }
1694: pnlKeyboardX = (pnlWidth - Keyboard.kbdWidth) >> 1;
1695: pnlKeyboardY = pnlScreenY4;
1696: pnlZoomRatioOutX = ((pnlZoomWidth * pnlStereoscopicFactor) << 16) / pnlScreenWidth;
1697: pnlZoomRatioOutY = (pnlZoomHeight << 16) / pnlScreenHeight;
1698: pnlZoomRatioInX = (pnlScreenWidth << 16) / (pnlZoomWidth * pnlStereoscopicFactor);
1699: pnlZoomRatioInY = (pnlScreenHeight << 16) / pnlZoomHeight;
1700: if (PNL_ROTATION_ON) {
1701:
1702: if (PNL_USE_THREAD) {
1703: for (int n = 0; n < 4; n++) {
1704: pnlScreenSubImageLeftArray[n] = pnlScreenImageLeftArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1705: pnlScreenSubImageRightArray[n] = pnlScreenImageRightArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1706: }
1707: } else {
1708: pnlScreenSubImageLeft = pnlScreenImageLeft.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1709: pnlScreenSubImageRight = pnlScreenImageRight.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1710: }
1711:
1712:
1713:
1714:
1715: double ax = 0.0;
1716: double ay = 0.0;
1717: double bx = (double) pnlScreenWidth;
1718: double by = (double) pnlScreenHeight;
1719: double l00, l10, l01, l11, l02, l12;
1720: double r00, r10, r01, r11, r02, r12;
1721: if (pnlRotationMode == 0) {
1722: double cx = (double) pnlScreenX1;
1723: double cy = (double) pnlScreenY1;
1724: double dx = (double) pnlScreenX2;
1725: double dy = (double) pnlScreenY2;
1726: l00 = (cx - dx) / (ax - bx);
1727: l10 = 0.0;
1728: l01 = 0.0;
1729: l11 = (cy - dy) / (ay - by);
1730: l02 = (ax * dx - bx * cx) / (ax - bx);
1731: l12 = (ay * dy - by * cy) / (ay - by);
1732: cx = (double) pnlScreenX3;
1733: cy = (double) pnlScreenY3;
1734: dx = (double) pnlScreenX4;
1735: dy = (double) pnlScreenY4;
1736: r00 = (cx - dx) / (ax - bx);
1737: r10 = 0.0;
1738: r01 = 0.0;
1739: r11 = (cy - dy) / (ay - by);
1740: r02 = (ax * dx - bx * cx) / (ax - bx);
1741: r12 = (ay * dy - by * cy) / (ay - by);
1742: } else if (pnlRotationMode == 1) {
1743: double cx = (double) pnlScreenX1;
1744: double cy = (double) pnlScreenY1;
1745: double dx = (double) pnlScreenX2;
1746: double dy = (double) pnlScreenY2;
1747: l00 = 0.0;
1748: l10 = (dy - cy) / (ax - bx);
1749: l01 = (cx - dx) / (ay - by);
1750: l11 = 0.0;
1751: l02 = (ay * dx - by * cx) / (ay - by);
1752: l12 = (ax * cy - bx * dy) / (ax - bx);
1753: cx = (double) pnlScreenX3;
1754: cy = (double) pnlScreenY3;
1755: dx = (double) pnlScreenX4;
1756: dy = (double) pnlScreenY4;
1757: r00 = 0.0;
1758: r10 = (dy - cy) / (ax - bx);
1759: r01 = (cx - dx) / (ay - by);
1760: r11 = 0.0;
1761: r02 = (ay * dx - by * cx) / (ay - by);
1762: r12 = (ax * cy - bx * dy) / (ax - bx);
1763: } else if (pnlRotationMode == 2) {
1764: double cx = (double) pnlScreenX1;
1765: double cy = (double) pnlScreenY1;
1766: double dx = (double) pnlScreenX2;
1767: double dy = (double) pnlScreenY2;
1768: l00 = (dx - cx) / (ax - bx);
1769: l10 = 0.0;
1770: l01 = 0.0;
1771: l11 = (dy - cy) / (ay - by);
1772: l02 = (ax * cx - bx * dx) / (ax - bx);
1773: l12 = (ay * cy - by * dy) / (ay - by);
1774: cx = (double) pnlScreenX3;
1775: cy = (double) pnlScreenY3;
1776: dx = (double) pnlScreenX4;
1777: dy = (double) pnlScreenY4;
1778: r00 = (dx - cx) / (ax - bx);
1779: r10 = 0.0;
1780: r01 = 0.0;
1781: r11 = (dy - cy) / (ay - by);
1782: r02 = (ax * cx - bx * dx) / (ax - bx);
1783: r12 = (ay * cy - by * dy) / (ay - by);
1784: } else {
1785: double cx = (double) pnlScreenX1;
1786: double cy = (double) pnlScreenY1;
1787: double dx = (double) pnlScreenX2;
1788: double dy = (double) pnlScreenY2;
1789: l00 = 0.0;
1790: l10 = (cy - dy) / (ax - bx);
1791: l01 = (dx - cx) / (ay - by);
1792: l11 = 0.0;
1793: l02 = (ay * cx - by * dx) / (ay - by);
1794: l12 = (ax * dy - bx * cy) / (ax - bx);
1795: cx = (double) pnlScreenX3;
1796: cy = (double) pnlScreenY3;
1797: dx = (double) pnlScreenX4;
1798: dy = (double) pnlScreenY4;
1799: r00 = 0.0;
1800: r10 = (cy - dy) / (ax - bx);
1801: r01 = (dx - cx) / (ay - by);
1802: r11 = 0.0;
1803: r02 = (ay * cx - by * dx) / (ay - by);
1804: r12 = (ax * dy - bx * cy) / (ax - bx);
1805: }
1806: pnlRotationTransformLeft.setTransform (l00, l10, l01, l11, l02, l12);
1807: pnlRotationTransformRight.setTransform (r00, r10, r01, r11, r02, r12);
1808: pnlMatrixL00 = l00;
1809: pnlMatrixL10 = l10;
1810: pnlMatrixL01 = l01;
1811: pnlMatrixL11 = l11;
1812: pnlMatrixL02 = l02;
1813: pnlMatrixL12 = l12;
1814: pnlMatrixR00 = r00;
1815: pnlMatrixR10 = r10;
1816: pnlMatrixR01 = r01;
1817: pnlMatrixR11 = r11;
1818: pnlMatrixR02 = r02;
1819: pnlMatrixR12 = r12;
1820:
1821:
1822:
1823:
1824:
1825:
1826: double d = l00 * l11 - l01 * l10;
1827: pnlInverseL00 = l11 / d;
1828: pnlInverseL10 = -l10 / d;
1829: pnlInverseL01 = -l01 / d;
1830: pnlInverseL11 = l00 / d;
1831: pnlInverseL02 = (l01 * l12 - l02 * l11) / d;
1832: pnlInverseL12 = (l02 * l10 - l00 * l12) / d;
1833: d = r00 * r11 - r01 * r10;
1834: pnlInverseR00 = r11 / d;
1835: pnlInverseR10 = -r10 / d;
1836: pnlInverseR01 = -r01 / d;
1837: pnlInverseR11 = r00 / d;
1838: pnlInverseR02 = (r01 * r12 - r02 * r11) / d;
1839: pnlInverseR12 = (r02 * r10 - r00 * r12) / d;
1840: }
1841: }
1842:
1843:
1844:
1845:
1846: public static final int PNL_UNDEFINED = 0;
1847: public static final int PNL_FIXEDSCALE = 1;
1848: public static final int PNL_FITINWINDOW = 2;
1849: public static final int PNL_FULLSCREEN = 3;
1850: public static final int PNL_MAXIMIZED = 4;
1851: public static int pnlModeRequest;
1852: public static int pnlMode;
1853: public static int pnlPrevMode;
1854:
1855:
1856: public static JRadioButtonMenuItem mnbFullScreenMenuItem;
1857: public static JRadioButtonMenuItem mnbMaximizedMenuItem;
1858: public static JRadioButtonMenuItem mnbFitInWindowMenuItem;
1859: public static JRadioButtonMenuItem mnbFixedScaleMenuItem;
1860:
1861:
1862: public static int PNL_BOOT_DELAY = 500;
1863: public static javax.swing.Timer pnlBootTimer;
1864:
1865:
1866:
1867: public static void pnlInit2 () {
1868: pnlModeRequest = PNL_UNDEFINED;
1869: pnlMode = PNL_FITINWINDOW;
1870: pnlPrevMode = PNL_FITINWINDOW;
1871: switch (Settings.sgsGetString ("scaling").toLowerCase ()) {
1872: case "fullscreen":
1873: pnlModeRequest = PNL_FULLSCREEN;
1874: break;
1875: case "maximized":
1876: pnlModeRequest = PNL_MAXIMIZED;
1877: break;
1878: case "fitinwindow":
1879: break;
1880: case "fixedscale":
1881: pnlMode = PNL_FIXEDSCALE;
1882: break;
1883: }
1884: }
1885:
1886:
1887:
1888: public static void pnlTini2 () {
1889: Settings.sgsPutString ("scaling",
1890: pnlMode == PNL_FULLSCREEN ? "fullscreen" :
1891: pnlMode == PNL_MAXIMIZED ? "maximized" :
1892: pnlMode == PNL_FITINWINDOW ? "fitinwindow" :
1893: "fixedscale");
1894: }
1895:
1896:
1897:
1898: public static void pnlMake2 () {
1899:
1900: ActionListener listener = new ActionListener () {
1901: @Override public void actionPerformed (ActionEvent ae) {
1902: String command = ae.getActionCommand ();
1903: switch (command) {
1904: case "Full screen":
1905: pnlSetMode (PNL_FULLSCREEN);
1906: break;
1907: case "Maximized":
1908: pnlSetMode (PNL_MAXIMIZED);
1909: break;
1910: case "Fit in window":
1911: pnlSetMode (PNL_FITINWINDOW);
1912: break;
1913: case "Fixed scale":
1914: pnlSetMode (PNL_FIXEDSCALE);
1915: break;
1916: }
1917: }
1918: };
1919: ButtonGroup group = new ButtonGroup ();
1920: mnbFullScreenMenuItem = ComponentFactory.setEnabled (
1921: Multilingual.mlnText (
1922: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FULLSCREEN, "Full screen", listener),
1923: "ja", "全画面表示"),
1924: pnlIsFullScreenSupported);
1925: mnbMaximizedMenuItem = Multilingual.mlnText (
1926: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_MAXIMIZED, "Maximized", listener),
1927: "ja", "最大化");
1928: mnbFitInWindowMenuItem = Multilingual.mlnText (
1929: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FITINWINDOW, "Fit in window", 'W', MNB_MODIFIERS, listener),
1930: "ja", "ウインドウに合わせる");
1931: mnbFixedScaleMenuItem = Multilingual.mlnText (
1932: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FIXEDSCALE, "Fixed scale", 'X', MNB_MODIFIERS, listener),
1933: "ja", "固定倍率");
1934: }
1935:
1936:
1937:
1938: public static void pnlStart2 () {
1939:
1940: frmFrame.addWindowStateListener (new WindowStateListener () {
1941: @Override public void windowStateChanged (WindowEvent we) {
1942: int state = frmFrame.getExtendedState ();
1943: if (pnlMode != PNL_MAXIMIZED &&
1944: (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
1945: pnlSetMode (PNL_MAXIMIZED);
1946: } else if (pnlMode == PNL_MAXIMIZED &&
1947: (state & Frame.MAXIMIZED_BOTH) != Frame.MAXIMIZED_BOTH) {
1948: pnlSetMode (pnlPrevMode);
1949: }
1950: }
1951: });
1952: }
1953:
1954:
1955:
1956: public static void pnlBoot2 () {
1957: if (pnlModeRequest != PNL_UNDEFINED) {
1958: pnlBootTimer = new javax.swing.Timer (PNL_BOOT_DELAY, new ActionListener () {
1959: public void actionPerformed (ActionEvent ae) {
1960: if (pnlModeRequest == PNL_FULLSCREEN) {
1961: mnbFullScreenMenuItem.doClick ();
1962: } else if (pnlModeRequest == PNL_MAXIMIZED) {
1963: mnbMaximizedMenuItem.doClick ();
1964: }
1965: pnlBootTimer.stop ();
1966: pnlBootTimer = null;
1967: }
1968: });
1969: pnlBootTimer.start ();
1970: }
1971: }
1972:
1973:
1974:
1975: public static void pnlSetMode (int mode) {
1976: do {
1977:
1978: if (pnlMode == mode) {
1979: break;
1980: }
1981:
1982: String text = null;
1983: if (mode == PNL_FULLSCREEN) {
1984: if (!pnlIsFullScreenSupported) {
1985: JOptionPane.showMessageDialog (
1986: frmFrame,
1987: Multilingual.mlnJapanese ?
1988: "全画面表示に対応していません" :
1989: "Full screen is not supported");
1990: break;
1991: }
1992: if (Bubble.BBL_ON) {
1993: text = ButtonFunction.bfnFullScreenText ();
1994: if (text == null) {
1995: JOptionPane.showMessageDialog (
1996: frmFrame,
1997: Multilingual.mlnJapanese ?
1998: "全画面表示を終了するキーまたはボタンがありません" :
1999: "No key or button to exit full screen");
2000: break;
2001: }
2002: }
2003: }
2004:
2005: if (pnlMode == PNL_FULLSCREEN) {
2006: pnlMode = pnlPrevMode;
2007: if (Bubble.BBL_ON) {
2008: Bubble.bblEnd ();
2009: }
2010: if (frmScreenDevice.getFullScreenWindow () == frmFrame) {
2011: frmScreenDevice.setFullScreenWindow (null);
2012: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.FRAME);
2013: }
2014: frmFrame.setJMenuBar (mnbMenuBar);
2015: if (pnlHideKeyboard) {
2016: if (pnlPrevKeyboardOn) {
2017: Keyboard.kbdSetOn (true);
2018: }
2019: }
2020: } else if (pnlMode == PNL_MAXIMIZED) {
2021: pnlMode = pnlPrevMode;
2022: if ((frmFrame.getExtendedState () & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
2023: frmFrame.setExtendedState (Frame.NORMAL);
2024: }
2025: }
2026:
2027: if (mode == PNL_FULLSCREEN) {
2028: pnlPrevMode = pnlMode;
2029: if (pnlHideKeyboard) {
2030: pnlPrevKeyboardOn = Keyboard.kbdImage != null;
2031: if (pnlPrevKeyboardOn) {
2032: Keyboard.kbdSetOn (false);
2033: }
2034: }
2035: frmFrame.setJMenuBar (null);
2036: if (frmScreenDevice.getFullScreenWindow () != frmFrame) {
2037: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.NONE);
2038: frmScreenDevice.setFullScreenWindow (frmFrame);
2039: }
2040: if (Bubble.BBL_ON) {
2041: if (text != null) {
2042: Bubble.bblStart (text + (Multilingual.mlnJapanese ? "で全画面表示を終了" : " to exit full screen"), 5000L);
2043: }
2044: }
2045: } else if (mode == PNL_MAXIMIZED) {
2046: pnlPrevMode = pnlMode;
2047: frmFrame.setExtendedState (Frame.MAXIMIZED_BOTH);
2048: }
2049: pnlMode = mode;
2050:
2051:
2052: pnlUpdateArrangement ();
2053: } while (false);
2054:
2055: if (pnlMode == PNL_FIXEDSCALE) {
2056: if (!mnbFixedScaleMenuItem.isSelected ()) {
2057: mnbFixedScaleMenuItem.setSelected (true);
2058: }
2059: } else if (pnlMode == PNL_FITINWINDOW) {
2060: if (!mnbFitInWindowMenuItem.isSelected ()) {
2061: mnbFitInWindowMenuItem.setSelected (true);
2062: }
2063: } else if (pnlMode == PNL_FULLSCREEN) {
2064: if (!mnbFullScreenMenuItem.isSelected ()) {
2065: mnbFullScreenMenuItem.setSelected (true);
2066: }
2067: } else if (pnlMode == PNL_MAXIMIZED) {
2068: if (!mnbMaximizedMenuItem.isSelected ()) {
2069: mnbMaximizedMenuItem.setSelected (true);
2070: }
2071: }
2072: }
2073:
2074:
2075:
2076:
2077:
2078:
2079: public static Robot rbtRobot;
2080:
2081:
2082: public static void rbtInit () {
2083:
2084:
2085: rbtRobot = null;
2086: try {
2087: rbtRobot = new Robot ();
2088: } catch (Exception e) {
2089: }
2090:
2091: }
2092:
2093:
2094:
2095:
2096:
2097:
2098:
2099: public static final int MNB_MODIFIERS = InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK;
2100:
2101:
2102: public static JMenuBar mnbMenuBar;
2103:
2104:
2105: public static JMenu mnbFileMenu;
2106: public static JMenu mnbDisplayMenu;
2107: public static JMenu mnbSoundMenu;
2108: public static JMenu mnbInputMenu;
2109: public static JMenu mnbConfigMenu;
2110: public static JMenu mnbLanguageMenu;
2111:
2112:
2113:
2114:
2115:
2116: public static JMenuItem mnbQuitMenuItem;
2117: public static JCheckBoxMenuItem mnbStereoscopicMenuItem;
2118: public static JCheckBoxMenuItem mnbPlayMenuItem;
2119: public static JMenuItem mnbPasteMenuItem;
2120: public static JRadioButtonMenuItem mnbStandardKeyboardMenuItem;
2121: public static JRadioButtonMenuItem mnbCompactKeyboardMenuItem;
2122: public static JRadioButtonMenuItem mnbNoKeyboardMenuItem;
2123: public static JLabel mnbVolumeLabel;
2124:
2125:
2126:
2127:
2128:
2129:
2130: public static JMenu mnbMakeFontSizeMenu () {
2131:
2132: ActionListener actionListener = new ActionListener () {
2133: @Override public void actionPerformed (ActionEvent ae) {
2134: String command = ae.getActionCommand ();
2135: switch (command) {
2136: case "Very small":
2137: LnF.lnfFontSizeRequest = 10;
2138: break;
2139: case "Small":
2140: LnF.lnfFontSizeRequest = 12;
2141: break;
2142: case "Medium":
2143: LnF.lnfFontSizeRequest = 14;
2144: break;
2145: case "Large":
2146: LnF.lnfFontSizeRequest = 16;
2147: break;
2148: case "Very large":
2149: LnF.lnfFontSizeRequest = 18;
2150: break;
2151: default:
2152: System.out.println ("unknown action command " + command);
2153: }
2154: }
2155: };
2156:
2157: ButtonGroup fontSizeGroup = new ButtonGroup ();
2158:
2159: return Multilingual.mlnText (
2160: ComponentFactory.createMenu (
2161: "Font size",
2162: Multilingual.mlnText (
2163: ComponentFactory.pointSize (
2164: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 10, "Very small", actionListener),
2165: 10),
2166: "ja", "極小"),
2167: Multilingual.mlnText (
2168: ComponentFactory.pointSize (
2169: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 12, "Small", actionListener),
2170: 12),
2171: "ja", "小"),
2172: Multilingual.mlnText (
2173: ComponentFactory.pointSize (
2174: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 14, "Medium", actionListener),
2175: 14),
2176: "ja", "中"),
2177: Multilingual.mlnText (
2178: ComponentFactory.pointSize (
2179: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 16, "Large", actionListener),
2180: 16),
2181: "ja", "大"),
2182: Multilingual.mlnText (
2183: ComponentFactory.pointSize (
2184: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 18, "Very large", actionListener),
2185: 18),
2186: "ja", "極大")),
2187: "ja", "フォントサイズ");
2188: }
2189:
2190:
2191:
2192: public static final DecimalSpinner[] mnbColorSpinners = new DecimalSpinner[9];
2193: public static final int[] mnbColorRGB = new int[15];
2194: public static JPanel mnbColorPanel;
2195:
2196:
2197:
2198: public static void mnbColorHSBToRGB () {
2199: for (int i = 0; i <= 14; i++) {
2200: int[] t = LnF.LNF_HSB_INTERPOLATION_TABLE[i];
2201: float h = (float) (t[0] * LnF.lnfHSB[0] + t[1] * LnF.lnfHSB[1] + t[2] * LnF.lnfHSB[2]) / (49.0F * 360.0F);
2202: float s = (float) (t[0] * LnF.lnfHSB[3] + t[1] * LnF.lnfHSB[4] + t[2] * LnF.lnfHSB[5]) / (49.0F * 100.0F);
2203: float b = (float) (t[0] * LnF.lnfHSB[6] + t[1] * LnF.lnfHSB[7] + t[2] * LnF.lnfHSB[8]) / (49.0F * 100.0F);
2204: mnbColorRGB[i] = Color.HSBtoRGB (h,
2205: Math.max (0.0F, Math.min (1.0F, s)),
2206: Math.max (0.0F, Math.min (1.0F, b)));
2207: }
2208: }
2209:
2210:
2211:
2212: public static JMenu mnbMakeColorMenu () {
2213: mnbColorHSBToRGB ();
2214:
2215: mnbColorPanel = ComponentFactory.setColor (
2216: ComponentFactory.setFixedSize (
2217: new JPanel () {
2218: @Override protected void paintComponent (Graphics g) {
2219: super.paintComponent (g);
2220: for (int i = 0; i <= 14; i++) {
2221: g.setColor (new Color (mnbColorRGB[i]));
2222: g.fillRect (LnF.lnfFontSize * i, 0, LnF.lnfFontSize, LnF.lnfFontSize * 5);
2223: }
2224: }
2225: },
2226: LnF.lnfFontSize * 15, LnF.lnfFontSize * 5),
2227: Color.white, Color.black);
2228:
2229: ChangeListener changeListener = new ChangeListener () {
2230: @Override public void stateChanged (ChangeEvent ce) {
2231: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
2232: LnF.lnfHSB[spinner.getOption ()] = spinner.getIntValue ();
2233: mnbColorHSBToRGB ();
2234: mnbColorPanel.repaint ();
2235: }
2236: };
2237:
2238: ActionListener actionListener = new ActionListener () {
2239: @Override public void actionPerformed (ActionEvent ae) {
2240: String command = ae.getActionCommand ();
2241: switch (command) {
2242: case "Reset to default values":
2243: for (int i = 0; i < 9; i++) {
2244: LnF.lnfHSB[i] = LnF.LNF_DEFAULT_HSB[i];
2245: mnbColorSpinners[i].setIntValue (LnF.lnfHSB[i]);
2246: }
2247: mnbColorHSBToRGB ();
2248: mnbColorPanel.repaint ();
2249: break;
2250: default:
2251: System.out.println ("unknown action command " + command);
2252: }
2253: }
2254: };
2255:
2256: for (int i = 0; i < 9; i++) {
2257: mnbColorSpinners[i] = ComponentFactory.createDecimalSpinner (
2258: LnF.lnfHSB[i], 0, i < 3 ? 720 : 100, 1, i, changeListener);
2259: }
2260:
2261: return Multilingual.mlnText (
2262: ComponentFactory.createMenu (
2263: "Color",
2264: ComponentFactory.createHorizontalBox (
2265: mnbColorSpinners[0],
2266: mnbColorSpinners[1],
2267: mnbColorSpinners[2],
2268: ComponentFactory.createLabel ("H °"),
2269: Box.createHorizontalGlue ()
2270: ),
2271: ComponentFactory.createHorizontalBox (
2272: mnbColorSpinners[3],
2273: mnbColorSpinners[4],
2274: mnbColorSpinners[5],
2275: ComponentFactory.createLabel ("S%"),
2276: Box.createHorizontalGlue ()
2277: ),
2278: ComponentFactory.createHorizontalBox (
2279: mnbColorSpinners[6],
2280: mnbColorSpinners[7],
2281: mnbColorSpinners[8],
2282: ComponentFactory.createLabel ("B%"),
2283: Box.createHorizontalGlue ()
2284: ),
2285: ComponentFactory.createHorizontalBox (
2286: ComponentFactory.setLineBorder (mnbColorPanel),
2287: Box.createHorizontalGlue ()
2288: ),
2289: Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset to default values", actionListener), "ja", "初期値に戻す")
2290: ),
2291: "ja", "色");
2292: }
2293:
2294:
2295:
2296:
2297:
2298: public static JMenu mnbMakeLanguageMenu () {
2299:
2300: ActionListener actionListener = new ActionListener () {
2301: @Override public void actionPerformed (ActionEvent ae) {
2302: String command = ae.getActionCommand ();
2303: switch (command) {
2304: case "English":
2305: Multilingual.mlnChange ("en");
2306: break;
2307: case "日本語":
2308: Multilingual.mlnChange ("ja");
2309: break;
2310: default:
2311: System.out.println ("unknown action command " + command);
2312: }
2313: }
2314: };
2315:
2316: ButtonGroup languageGroup = new ButtonGroup ();
2317:
2318: return mnbLanguageMenu = Multilingual.mlnText (
2319: ComponentFactory.createMenu (
2320: "Language", 'L',
2321: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnEnglish, "English", actionListener),
2322: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnJapanese, "日本語", actionListener),
2323: ComponentFactory.createHorizontalSeparator (),
2324: mnbMakeFontSizeMenu (),
2325: mnbMakeColorMenu ()
2326: ),
2327: "ja", "言語");
2328: }
2329:
2330:
2331:
2332:
2333:
2334: public static void mnbMakeMenu () {
2335:
2336:
2337: ActionListener listener = new ActionListener () {
2338: @Override public void actionPerformed (ActionEvent ae) {
2339: Object source = ae.getSource ();
2340: String command = ae.getActionCommand ();
2341: switch (command) {
2342:
2343:
2344: case "Quit":
2345: prgTini ();
2346: break;
2347:
2348:
2349: case "50%":
2350: case "75%":
2351: case "100%":
2352: case "150%":
2353: case "200%":
2354: pnlFixedModel.setValue (Integer.valueOf (Integer.parseInt (command.substring (0, command.length () - 1))));
2355: break;
2356: case "Nearest neighbor":
2357: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
2358: break;
2359: case "Bilinear":
2360: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
2361: break;
2362: case "Bicubic":
2363: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
2364: break;
2365:
2366: case "Use canvas":
2367: pnlUseCanvasRequest = ((JCheckBoxMenuItem) source).isSelected ();
2368: break;
2369:
2370: case "Draw all changed pictures":
2371: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2372: CRTC.crtIntermittentInterval = 0;
2373: }
2374: break;
2375: case "Draw a changed picture once every two times":
2376: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2377: CRTC.crtIntermittentInterval = 1;
2378: }
2379: break;
2380: case "Draw a changed picture once every three times":
2381: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2382: CRTC.crtIntermittentInterval = 2;
2383: }
2384: break;
2385: case "Draw a changed picture once every four times":
2386: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2387: CRTC.crtIntermittentInterval = 3;
2388: }
2389: break;
2390: case "Draw a changed picture once every five times":
2391: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2392: CRTC.crtIntermittentInterval = 4;
2393: }
2394: break;
2395:
2396: case "Stereoscopic viewing":
2397: pnlSetStereoscopic (((JCheckBoxMenuItem) source).isSelected (), pnlStereoscopicMethod);
2398: break;
2399: case "Naked-eye crossing":
2400: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_CROSSING);
2401: break;
2402: case "Naked-eye parallel":
2403: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_PARALLEL);
2404: break;
2405: case "Side-by-side":
2406: pnlSetStereoscopic (pnlStereoscopicOn, PNL_SIDE_BY_SIDE);
2407: break;
2408: case "Top-and-bottom":
2409: pnlSetStereoscopic (pnlStereoscopicOn, PNL_TOP_AND_BOTTOM);
2410: break;
2411:
2412: case "Sprite pattern viewer":
2413: if (SpritePatternViewer.SPV_ON) {
2414: SpritePatternViewer.spvOpen ();
2415: }
2416: break;
2417: case "Palette viewer":
2418: if (PaletteViewer.PLV_ON) {
2419: PaletteViewer.plvOpen ();
2420: }
2421: break;
2422: case "Screen mode test":
2423: if (ScreenModeTest.SMT_ON) {
2424: ScreenModeTest.smtOpen ();
2425: }
2426: break;
2427:
2428:
2429: case "Play":
2430: SoundSource.sndSetPlayOn (((JCheckBoxMenuItem) source).isSelected ());
2431: break;
2432: case "OPM output":
2433: OPM.opmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2434: break;
2435: case "OPM log":
2436: OPMLog.olgOpen ();
2437: break;
2438:
2439: case "PCM output":
2440: ADPCM.pcmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2441: break;
2442: case "Sound thinning":
2443: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.THINNING_MONO : SoundSource.SNDRateConverter.THINNING_STEREO;
2444: break;
2445: case "Sound linear interpolation":
2446: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.LINEAR_MONO : SoundSource.SNDRateConverter.LINEAR_STEREO;
2447: break;
2448: case "Sound piecewise-constant area interpolation":
2449: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000;
2450: break;
2451: case "Sound linear area interpolation":
2452: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000;
2453: break;
2454: case "Sound monitor":
2455: SoundMonitor.smnOpen ();
2456: break;
2457: case "PCM piecewise-constant interpolation":
2458: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_CONSTANT);
2459: break;
2460: case "PCM linear interpolation":
2461: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_LINEAR);
2462: break;
2463: case "PCM hermite interpolation":
2464: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_HERMITE);
2465: break;
2466: case "PCM 8MHz/4MHz":
2467: ADPCM.pcmOSCFreqRequest = 0;
2468: break;
2469: case "PCM 8MHz/16MHz":
2470: ADPCM.pcmOSCFreqRequest = 1;
2471: break;
2472:
2473:
2474: case "Paste":
2475: CONDevice.conDoPaste ();
2476: break;
2477: case "No keyboard":
2478: Keyboard.kbdSetOn (false);
2479: pnlUpdateArrangement ();
2480: break;
2481: case "Standard keyboard":
2482: Keyboard.kbdSetType (Keyboard.KBD_STANDARD_TYPE);
2483: Keyboard.kbdSetOn (true);
2484: pnlUpdateArrangement ();
2485: break;
2486: case "Compact keyboard":
2487: Keyboard.kbdSetType (Keyboard.KBD_COMPACT_TYPE);
2488: Keyboard.kbdSetOn (true);
2489: pnlUpdateArrangement ();
2490: break;
2491: case "Hide keyboard in full screen":
2492: pnlHideKeyboard = ((JCheckBoxMenuItem) source).isSelected ();
2493: if (pnlMode == PNL_FULLSCREEN) {
2494: pnlUpdateArrangement ();
2495: }
2496: break;
2497: case "Key assignments":
2498: Keyboard.kbdOpen ();
2499: break;
2500: case "Joystick port settings":
2501: PPI.ppiOpen ();
2502: break;
2503:
2504:
2505: case "RS-232C and terminal":
2506: RS232CTerminal.trmOpen ();
2507: break;
2508:
2509: case "Console":
2510: DebugConsole.dgtOpen ();
2511: break;
2512: case "Register list":
2513: RegisterList.drpOpen ();
2514: break;
2515: case "Disassemble list":
2516: DisassembleList.ddpOpen (-1, -1, true);
2517: break;
2518: case "Memory dump list":
2519: MemoryDumpList.dmpOpen (-1, -1, true);
2520: break;
2521: case "Logical space monitor":
2522: LogicalSpaceMonitor.atwOpen ();
2523: break;
2524: case "Physical space monitor":
2525: PhysicalSpaceMonitor.paaOpen ();
2526: break;
2527: case "Address translation caches monitor":
2528: if (ATCMonitor.ACM_ON) {
2529: ATCMonitor.acmOpen ();
2530: }
2531: break;
2532: case "Branch log":
2533: if (BranchLog.BLG_ON) {
2534: BranchLog.blgOpen (BranchLog.BLG_SELECT_NONE);
2535: }
2536: break;
2537: case "Program flow visualizer":
2538: if (ProgramFlowVisualizer.PFV_ON) {
2539: ProgramFlowVisualizer.pfvOpen ();
2540: }
2541: break;
2542: case "Raster break point":
2543: if (RasterBreakPoint.RBP_ON) {
2544: RasterBreakPoint.rbpOpen ();
2545: }
2546: break;
2547: case "Data break point":
2548: if (DataBreakPoint.DBP_ON) {
2549: DataBreakPoint.dbpOpen ();
2550: }
2551: break;
2552: case "Root pointer list":
2553: if (RootPointerList.RTL_ON) {
2554: RootPointerList.rtlOpen ();
2555: }
2556: break;
2557:
2558:
2559: case "Adjust clock to host":
2560: RP5C15.rtcSetByHost ();
2561: break;
2562:
2563:
2564:
2565: case "Printer":
2566: PrinterPort.prnOpen ();
2567: break;
2568:
2569: case "Print key and mouse button events":
2570: Mouse.musOutputButtonStatus = ((JCheckBoxMenuItem) source).isSelected ();
2571: break;
2572:
2573: case "Java runtime environment information":
2574: prgOpenJavaDialog ();
2575: break;
2576: case "Version information":
2577: prgOpenAboutDialog ();
2578: break;
2579: case "XEiJ License":
2580: prgOpenXEiJLicenseDialog ();
2581: break;
2582: case "FSHARP License":
2583: prgOpenSHARPLicenseDialog ();
2584: break;
2585: case "ymfm License":
2586: prgOpenYmfmLicenseDialog ();
2587: break;
2588: case "jSerialComm License":
2589: prgOpenJSerialCommLicenseDialog ();
2590: break;
2591:
2592: default:
2593: System.out.println ("unknown action command " + command);
2594:
2595: }
2596: }
2597: };
2598:
2599:
2600: ActionListener mainMemoryListener = new ActionListener () {
2601: @Override public void actionPerformed (ActionEvent ae) {
2602: Object source = ae.getSource ();
2603: String command = ae.getActionCommand ();
2604: switch (command) {
2605: case "1MB":
2606: MainMemory.mmrMemorySizeRequest = 0x00100000;
2607: break;
2608: case "2MB":
2609: MainMemory.mmrMemorySizeRequest = 0x00200000;
2610: break;
2611: case "4MB":
2612: MainMemory.mmrMemorySizeRequest = 0x00400000;
2613: break;
2614: case "6MB":
2615: MainMemory.mmrMemorySizeRequest = 0x00600000;
2616: break;
2617: case "8MB":
2618: MainMemory.mmrMemorySizeRequest = 0x00800000;
2619: break;
2620: case "10MB":
2621: MainMemory.mmrMemorySizeRequest = 0x00a00000;
2622: break;
2623: case "12MB":
2624: MainMemory.mmrMemorySizeRequest = 0x00c00000;
2625: break;
2626: case "Save contents on exit":
2627: MainMemory.mmrMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2628: break;
2629: }
2630: }
2631: };
2632: ButtonGroup mainMemoryGroup = new ButtonGroup ();
2633: JMenu mainMemoryMenu = Multilingual.mlnText (
2634: ComponentFactory.createMenu (
2635: "Main memory",
2636: Multilingual.mlnText (
2637: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00100000, "1MB", mainMemoryListener),
2638: "ja", "1MB"),
2639: Multilingual.mlnText (
2640: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00200000, "2MB", mainMemoryListener),
2641: "ja", "2MB"),
2642: Multilingual.mlnText (
2643: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00400000, "4MB", mainMemoryListener),
2644: "ja", "4MB"),
2645: Multilingual.mlnText (
2646: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00600000, "6MB", mainMemoryListener),
2647: "ja", "6MB"),
2648: Multilingual.mlnText (
2649: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00800000, "8MB", mainMemoryListener),
2650: "ja", "8MB"),
2651: Multilingual.mlnText (
2652: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00a00000, "10MB", mainMemoryListener),
2653: "ja", "10MB"),
2654: Multilingual.mlnText (
2655: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00c00000, "12MB", mainMemoryListener),
2656: "ja", "12MB"),
2657: ComponentFactory.createHorizontalSeparator (),
2658: Multilingual.mlnText (
2659: ComponentFactory.createCheckBoxMenuItem (MainMemory.mmrMemorySaveOn, "Save contents on exit", mainMemoryListener),
2660: "ja", "終了時に内容を保存する"),
2661: SRAM.smrModifyMemorySizeMenuItem
2662: ),
2663: "ja", "メインメモリ");
2664:
2665:
2666: ActionListener highMemoryListener = new ActionListener () {
2667: @Override public void actionPerformed (ActionEvent ae) {
2668: Object source = ae.getSource ();
2669: String command = ae.getActionCommand ();
2670: switch (command) {
2671: case "None":
2672: busHighMemorySize = 0 << 20;
2673: break;
2674: case "16MB":
2675: busHighMemorySize = 16 << 20;
2676: break;
2677: case "Save contents on exit":
2678: busHighMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2679: break;
2680: }
2681: }
2682: };
2683: ButtonGroup highMemoryGroup = new ButtonGroup ();
2684: JMenu highMemoryMenu = Multilingual.mlnText (
2685: ComponentFactory.createMenu (
2686: "High memory on X68030/Xellent30",
2687: Multilingual.mlnText (
2688: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 0 << 20, "None", highMemoryListener),
2689: "ja", "なし"),
2690: Multilingual.mlnText (
2691: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 16 << 20, "16MB", highMemoryListener),
2692: "ja", "16MB"),
2693: ComponentFactory.createHorizontalSeparator (),
2694: Multilingual.mlnText (
2695: ComponentFactory.createCheckBoxMenuItem (busHighMemorySaveOn, "Save contents on exit", highMemoryListener),
2696: "ja", "終了時に内容を保存する")
2697: ),
2698: "ja", "X68030/Xellent30 のハイメモリ");
2699:
2700:
2701: ActionListener localMemoryListener = new ActionListener () {
2702: @Override public void actionPerformed (ActionEvent ae) {
2703: Object source = ae.getSource ();
2704: String command = ae.getActionCommand ();
2705: switch (command) {
2706: case "None":
2707: busLocalMemorySize = 0 << 20;
2708: break;
2709: case "16MB":
2710: busLocalMemorySize = 16 << 20;
2711: break;
2712: case "32MB":
2713: busLocalMemorySize = 32 << 20;
2714: break;
2715: case "64MB":
2716: busLocalMemorySize = 64 << 20;
2717: break;
2718: case "128MB":
2719: busLocalMemorySize = 128 << 20;
2720: break;
2721: case "256MB":
2722: busLocalMemorySize = 256 << 20;
2723: break;
2724: case "384MB":
2725: busLocalMemorySize = 384 << 20;
2726: break;
2727: case "512MB":
2728: busLocalMemorySize = 512 << 20;
2729: break;
2730: case "768MB":
2731: busLocalMemorySize = 768 << 20;
2732: break;
2733: case "Save contents on exit":
2734: busLocalMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2735: break;
2736: case "Available on X68000":
2737: busHimem68000 = ((JCheckBoxMenuItem) source).isSelected ();
2738: break;
2739: case "Available on X68030/Xellent30":
2740: busHighMemory060turboOn = ((JCheckBoxMenuItem) source).isSelected ();
2741: break;
2742: }
2743: }
2744: };
2745: ButtonGroup localMenoryGroup = new ButtonGroup ();
2746: JMenu localMemoryMenu = Multilingual.mlnText (
2747: ComponentFactory.createMenu (
2748: "High memory on 060turbo",
2749: Multilingual.mlnText (
2750: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 0 << 20, "None", localMemoryListener),
2751: "ja", "なし"),
2752: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 16 << 20, "16MB", localMemoryListener),
2753: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 32 << 20, "32MB", localMemoryListener),
2754: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 64 << 20, "64MB", localMemoryListener),
2755: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 128 << 20, "128MB", localMemoryListener),
2756: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 256 << 20, "256MB", localMemoryListener),
2757: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 384 << 20, "384MB", localMemoryListener),
2758: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 512 << 20, "512MB", localMemoryListener),
2759: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 768 << 20, "768MB", localMemoryListener),
2760: ComponentFactory.createHorizontalSeparator (),
2761: Multilingual.mlnText (
2762: ComponentFactory.createCheckBoxMenuItem (busLocalMemorySaveOn, "Save contents on exit", localMemoryListener),
2763: "ja", "終了時に内容を保存する"),
2764: ComponentFactory.createHorizontalSeparator (),
2765: Multilingual.mlnText (
2766: ComponentFactory.createCheckBoxMenuItem (busHimem68000, "Available on X68000", localMemoryListener),
2767: "ja", "X68000 でも有効"),
2768: Multilingual.mlnText (
2769: ComponentFactory.createCheckBoxMenuItem (busHighMemory060turboOn, "Available on X68030/Xellent30", localMemoryListener),
2770: "ja", "X68030/Xellent30 でも有効")
2771: ),
2772: "ja", "060turbo のハイメモリ");
2773:
2774:
2775: ActionListener xellent30Listener = new ActionListener () {
2776: @Override public void actionPerformed (ActionEvent ae) {
2777: Object source = ae.getSource ();
2778: String command = ae.getActionCommand ();
2779: switch (command) {
2780: case "$00EC0000-$00EC3FFF":
2781: xt3DIPSW = 0;
2782: break;
2783: case "$00EC4000-$00EC7FFF":
2784: xt3DIPSW = 1;
2785: break;
2786: case "$00EC8000-$00ECBFFF":
2787: xt3DIPSW = 2;
2788: break;
2789: case "$00ECC000-$00ECFFFF":
2790: xt3DIPSW = 3;
2791: break;
2792: case "256KB":
2793: xt3MemorySizeRequest = 1 << 18;
2794: break;
2795: case "1MB":
2796: xt3MemorySizeRequest = 1 << 20;
2797: break;
2798: case "Save contents on exit":
2799: xt3MemorySave = ((JCheckBoxMenuItem) source).isSelected ();
2800: break;
2801: }
2802: }
2803: };
2804: ButtonGroup xellent30PortGroup = new ButtonGroup ();
2805: ButtonGroup xellent30SizeGroup = new ButtonGroup ();
2806: JMenu xellent30Menu = ComponentFactory.createMenu (
2807: "Xellent30",
2808: ComponentFactory.createRadioButtonMenuItem (
2809: xellent30PortGroup,
2810: xt3DIPSW == 0,
2811: "$00EC0000-$00EC3FFF",
2812: xellent30Listener),
2813: ComponentFactory.createRadioButtonMenuItem (
2814: xellent30PortGroup,
2815: xt3DIPSW == 1,
2816: "$00EC4000-$00EC7FFF",
2817: xellent30Listener),
2818: ComponentFactory.createRadioButtonMenuItem (
2819: xellent30PortGroup,
2820: xt3DIPSW == 2,
2821: "$00EC8000-$00ECBFFF",
2822: xellent30Listener),
2823: ComponentFactory.createRadioButtonMenuItem (
2824: xellent30PortGroup,
2825: xt3DIPSW == 3,
2826: "$00ECC000-$00ECFFFF",
2827: xellent30Listener),
2828: ComponentFactory.createHorizontalSeparator (),
2829: ComponentFactory.createRadioButtonMenuItem (
2830: xellent30SizeGroup,
2831: xt3MemorySizeRequest == 1 << 18,
2832: "256KB",
2833: xellent30Listener),
2834: ComponentFactory.createRadioButtonMenuItem (
2835: xellent30SizeGroup,
2836: xt3MemorySizeRequest == 1 << 20,
2837: "1MB",
2838: xellent30Listener),
2839: ComponentFactory.createHorizontalSeparator (),
2840: Multilingual.mlnText (
2841: ComponentFactory.createCheckBoxMenuItem (xt3MemorySave, "Save contents on exit", xellent30Listener),
2842: "ja", "終了時に内容を保存する")
2843: );
2844:
2845:
2846: JMenu rotationMenu = null;
2847: if (PNL_ROTATION_ON) {
2848: ActionListener rotationListener = new ActionListener () {
2849: @Override public void actionPerformed (ActionEvent ae) {
2850: String command = ae.getActionCommand ();
2851: switch (command) {
2852: case "No rotation (landscape)":
2853: pnlRotationMode = 0;
2854: pnlUpdateArrangement ();
2855: break;
2856: case "90-degree rotation (portrait)":
2857: pnlRotationMode = 1;
2858: pnlUpdateArrangement ();
2859: break;
2860: case "180-degree rotation":
2861: pnlRotationMode = 2;
2862: pnlUpdateArrangement ();
2863: break;
2864: case "270-degree rotation":
2865: pnlRotationMode = 3;
2866: pnlUpdateArrangement ();
2867: break;
2868: default:
2869: System.out.println ("unknown action command " + command);
2870: }
2871: }
2872: };
2873: ButtonGroup rotationGroup = new ButtonGroup ();
2874: rotationMenu = Multilingual.mlnText (
2875: ComponentFactory.createMenu (
2876: "Rotation",
2877: Multilingual.mlnText (
2878: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 0, "No rotation (landscape)", rotationListener),
2879: "ja", "回転なし (横画面)"),
2880: Multilingual.mlnText (
2881: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 1, "90-degree rotation (portrait)", rotationListener),
2882: "ja", "90 度回転 (縦画面)"),
2883: Multilingual.mlnText (
2884: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 2, "180-degree rotation", rotationListener),
2885: "ja", "180 度回転"),
2886: Multilingual.mlnText (
2887: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 3, "270-degree rotation", rotationListener),
2888: "ja", "270 度回転")
2889: ),
2890: "ja", "回転");
2891: }
2892:
2893:
2894: ActionListener aspectListener = new ActionListener () {
2895: @Override public void actionPerformed (ActionEvent ae) {
2896: String command = ae.getActionCommand ();
2897: int i = command.indexOf (',');
2898: int key = Integer.parseInt (command.substring (0, i));
2899: int value = Integer.parseInt (command.substring (i + 1));
2900: pnlAspectMap[key] = value;
2901: pnlUpdateAspectTable ();
2902: pnlUpdateArrangement ();
2903: }
2904: };
2905: JMenu aspectMenu = ComponentFactory.createMenu ("Aspect ratio");
2906: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
2907: if (key != 0) {
2908: aspectMenu.add (ComponentFactory.createHorizontalSeparator ());
2909: }
2910: ButtonGroup group = new ButtonGroup ();
2911: for (int value = 0; value < PNL_ASPECT_VALUES; value++) {
2912: aspectMenu.add (
2913: ComponentFactory.setText (
2914: ComponentFactory.createRadioButtonMenuItem (
2915: group,
2916: pnlAspectMap[key] == value,
2917: key + "," + value,
2918: aspectListener
2919: ),
2920: (PNL_ASPECT_MATRIX[key] == PNL_ASPECT_SCREEN_RATIO ?
2921: String.format ("%s %s (%.3f)",
2922: PNL_ASPECT_RESOLUTION_NAME[key],
2923: PNL_ASPECT_SCREEN_NAME[value],
2924: PNL_ASPECT_SCREEN_RATIO[value]) :
2925: String.format ("%s %s (%.3f) @ %s (%.3f)",
2926: PNL_ASPECT_RESOLUTION_NAME[key],
2927: PNL_ASPECT_SCREEN_NAME[value],
2928: PNL_ASPECT_SCREEN_RATIO[value],
2929: PNL_ASPECT_PIXEL_NAME[value],
2930: PNL_ASPECT_PIXEL_RATIO[value]))
2931: )
2932: );
2933: }
2934: }
2935: aspectMenu = Multilingual.mlnText (aspectMenu, "ja", "アスペクト比");
2936:
2937:
2938: ActionListener scanlineListener = new ActionListener () {
2939: @Override public void actionPerformed (ActionEvent ae) {
2940:
2941: String command = ae.getActionCommand ();
2942: switch (command) {
2943: case "Off":
2944: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.OFF;
2945: CRTC.crtAllStamp += 2;
2946: break;
2947: case "Weak":
2948: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.WEAK;
2949: CRTC.crtAllStamp += 2;
2950: break;
2951: case "Medium":
2952: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.MEDIUM;
2953: CRTC.crtAllStamp += 2;
2954: break;
2955: case "Strong":
2956: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.STRONG;
2957: CRTC.crtAllStamp += 2;
2958: break;
2959: case "Black":
2960: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.BLACK;
2961: CRTC.crtAllStamp += 2;
2962: break;
2963: }
2964: }
2965: };
2966: ButtonGroup scanlineGroup = new ButtonGroup ();
2967: JMenu scanlineMenu =
2968: Multilingual.mlnText (
2969: ComponentFactory.createMenu (
2970: "Scanline effect",
2971: Multilingual.mlnText (
2972: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.OFF, "Off", scanlineListener),
2973: "ja", "なし"),
2974: Multilingual.mlnText (
2975: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.WEAK, "Weak", scanlineListener),
2976: "ja", "弱"),
2977: Multilingual.mlnText (
2978: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.MEDIUM, "Medium", scanlineListener),
2979: "ja", "中"),
2980: Multilingual.mlnText (
2981: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.STRONG, "Strong", scanlineListener),
2982: "ja", "強"),
2983: Multilingual.mlnText (
2984: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.BLACK, "Black", scanlineListener),
2985: "ja", "黒")
2986: ),
2987: "ja", "走査線エフェクト");
2988:
2989:
2990: JTextField refreshRateTextField = ComponentFactory.createNumberField (pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate), 8);
2991: refreshRateTextField.addActionListener (
2992: new ActionListener () {
2993: @Override public void actionPerformed (ActionEvent ae) {
2994: JTextField textField = (JTextField) ae.getSource ();
2995: pnlRefreshRate = 0.0;
2996: String s = textField.getText ();
2997: if (!s.equals ("")) {
2998: double rate = 0.0;
2999: try {
3000: rate = Double.parseDouble (s);
3001: } catch (NumberFormatException nfe) {
3002: }
3003: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
3004: pnlRefreshRate = rate;
3005: } else {
3006: textField.setText ("");
3007: }
3008: }
3009: pnlFixedRate = pnlRefreshRate;
3010: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3011: pnlFixedRate = pnlGetRefreshRate ();
3012: }
3013: CRTC.crtUpdateLength ();
3014: }
3015: });
3016:
3017: ButtonGroup unitGroup = new ButtonGroup ();
3018: ButtonGroup frameGroup = new ButtonGroup ();
3019: ButtonGroup hintGroup = new ButtonGroup ();
3020: ButtonGroup vgaGroup = new ButtonGroup ();
3021: ButtonGroup intermittentGroup = new ButtonGroup ();
3022: ButtonGroup sterescopicGroup = new ButtonGroup ();
3023: ButtonGroup soundInterpolationGroup = new ButtonGroup ();
3024: ButtonGroup adpcmInterpolationGroup = new ButtonGroup ();
3025: ButtonGroup adpcmOSCFreqGroup = new ButtonGroup ();
3026: ButtonGroup keyboardGroup = new ButtonGroup ();
3027: ButtonGroup spritesGroup = new ButtonGroup ();
3028:
3029:
3030: DecimalSpinner[] freqSpinner = new DecimalSpinner[3];
3031: ChangeListener freqListener = new ChangeListener () {
3032: @Override public void stateChanged (ChangeEvent ce) {
3033: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
3034: int i = spinner.getOption ();
3035: CRTC.crtFreqsRequest[i] = spinner.getIntValue ();
3036: }
3037: };
3038: for (int i = 0; i < 3; i++) {
3039: freqSpinner[i] = ComponentFactory.createDecimalSpinner (
3040: CRTC.crtFreqsRequest[i], CRTC.CRT_MIN_FREQ, CRTC.CRT_MAX_FREQ, 1000000, i, freqListener
3041: );
3042: }
3043: DecimalSpinner sprrasSpinner = ComponentFactory.createDecimalSpinner (
3044: SpriteScreen.sprSpritesPerRaster, 0, 1016, 1, 0,
3045: new ChangeListener () {
3046: @Override public void stateChanged (ChangeEvent ce) {
3047: SpriteScreen.sprSpritesPerRaster = ((DecimalSpinner) ce.getSource ()).getIntValue ();
3048: }
3049: });
3050: ActionListener modificationListener = new ActionListener () {
3051: @Override public void actionPerformed (ActionEvent ae) {
3052: Object source = ae.getSource ();
3053: String command = ae.getActionCommand ();
3054: switch (command) {
3055:
3056: case "Adjust to host refresh rate":
3057: pnlAdjustVsync = ((JCheckBoxMenuItem) source).isSelected ();
3058: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3059: pnlFixedRate = pnlGetRefreshRate ();
3060: }
3061: CRTC.crtUpdateLength ();
3062: break;
3063: case "* Reset to default values":
3064: for (int i = 0; i < 3; i++) {
3065: if (CRTC.crtFreqsRequest[i] != CRTC.CRT_DEFAULT_FREQS[i]) {
3066: CRTC.crtFreqsRequest[i] = CRTC.CRT_DEFAULT_FREQS[i];
3067: freqSpinner[i].setIntValue (CRTC.crtFreqsRequest[i]);
3068: }
3069: }
3070: break;
3071: case "1024-dot non-interlaced":
3072: CRTC.crtEleventhBitRequest = ((JCheckBoxMenuItem) source).isSelected ();
3073: break;
3074: case "Can write 0 to bit 0 of CRTC R00":
3075: CRTC.crtR00Bit0Zero = ((JCheckBoxMenuItem) source).isSelected ();
3076: break;
3077:
3078: case "Extended graphic screen":
3079: CRTC.crtExtendedGraphicRequest = ((JCheckBoxMenuItem) source).isSelected ();
3080: break;
3081:
3082: case "Spherical scrolling of text screen":
3083: CRTC.crtSetSphericalScrolling (((JCheckBoxMenuItem) source).isSelected ());
3084: break;
3085:
3086: case "128 sprites":
3087: SpriteScreen.sprNumberOfSpritesRequest = 128;
3088: break;
3089: case "256 sprites":
3090: SpriteScreen.sprNumberOfSpritesRequest = 256;
3091: break;
3092: case "504 sprites":
3093: SpriteScreen.sprNumberOfSpritesRequest = 512;
3094: break;
3095: case "1016 sprites":
3096: SpriteScreen.sprNumberOfSpritesRequest = 1024;
3097: break;
3098:
3099:
3100:
3101: case "4096 patterns":
3102: SpriteScreen.sprBankOnRequest = ((JCheckBoxMenuItem) source).isSelected ();
3103: break;
3104: case "Sprites displayed in 768x512":
3105: SpriteScreen.spr768x512Request = ((JCheckBoxMenuItem) source).isSelected ();
3106: break;
3107: case "BG1 displayed in 512x512":
3108: SpriteScreen.spr512bg1Request = ((JCheckBoxMenuItem) source).isSelected ();
3109: break;
3110: case "Row and column scroll":
3111: if (SpriteScreen.SPR_RC_SCROLL_ON) {
3112: SpriteScreen.sprRcScrollRequest = ((JCheckBoxMenuItem) source).isSelected ();
3113: }
3114: break;
3115: case "** Reset to default values":
3116: if (SpriteScreen.sprSpritesPerRaster != 32) {
3117: SpriteScreen.sprSpritesPerRaster = 32;
3118: sprrasSpinner.setIntValue (SpriteScreen.sprSpritesPerRaster);
3119: }
3120: break;
3121: }
3122: }
3123: };
3124: JMenu modificationMenu =
3125: Multilingual.mlnText (
3126: ComponentFactory.createMenu (
3127: "Modification",
3128: Multilingual.mlnText (
3129: ComponentFactory.createMenu (
3130: "Dot clock",
3131: Multilingual.mlnText (
3132: ComponentFactory.createCheckBoxMenuItem (pnlAdjustVsync, "Adjust to host refresh rate", modificationListener),
3133: "ja", "ホストのリフレッシュレートに合わせる"),
3134: ComponentFactory.createHorizontalBox (
3135: Box.createHorizontalStrut (20),
3136: refreshRateTextField,
3137: ComponentFactory.createLabel (" Hz"),
3138: Box.createHorizontalGlue ()
3139: ),
3140: ComponentFactory.createHorizontalSeparator (),
3141: ComponentFactory.createHorizontalBox (
3142: Box.createHorizontalStrut (20),
3143: Multilingual.mlnText (ComponentFactory.createLabel ("Dot clock oscillattor"), "ja", "ドットクロックオシレータ"),
3144: Box.createHorizontalGlue ()
3145: ),
3146: ComponentFactory.createHorizontalBox (
3147: Box.createHorizontalStrut (20),
3148: freqSpinner[0],
3149: ComponentFactory.createLabel (" Hz *"),
3150: Box.createHorizontalGlue ()
3151: ),
3152: ComponentFactory.createHorizontalBox (
3153: Box.createHorizontalStrut (20),
3154: freqSpinner[1],
3155: ComponentFactory.createLabel (" Hz *"),
3156: Box.createHorizontalGlue ()
3157: ),
3158: ComponentFactory.createHorizontalBox (
3159: Box.createHorizontalStrut (20),
3160: freqSpinner[2],
3161: ComponentFactory.createLabel (" Hz *"),
3162: Box.createHorizontalGlue ()
3163: ),
3164: Multilingual.mlnText (
3165: ComponentFactory.createMenuItem ("* Reset to default values", modificationListener),
3166: "ja", "* 初期値に戻す"),
3167: ComponentFactory.createHorizontalSeparator (),
3168: Multilingual.mlnText (
3169: ComponentFactory.createCheckBoxMenuItem (CRTC.crtEleventhBitRequest, "1024-dot non-interlaced", modificationListener),
3170: "ja", "1024 ドットノンインターレース"),
3171: Multilingual.mlnText (
3172: ComponentFactory.createCheckBoxMenuItem (CRTC.crtR00Bit0Zero, "Can write 0 to bit 0 of CRTC R00", modificationListener),
3173: "ja", "CRTC R00 のビット 0 に 0 を書き込める")
3174: ),
3175: "ja", "ドットクロック"),
3176: Multilingual.mlnText (
3177: ComponentFactory.createMenu (
3178: "Graphic screen",
3179: !CRTC.CRT_EXTENDED_GRAPHIC ? null : Multilingual.mlnText (
3180: ComponentFactory.createCheckBoxMenuItem (CRTC.crtExtendedGraphicRequest, "Extended graphic screen", modificationListener),
3181: "ja", "拡張グラフィック画面")
3182: ),
3183: "ja", "グラフィック画面"),
3184: Multilingual.mlnText (
3185: ComponentFactory.createMenu (
3186: "Text screen",
3187: Multilingual.mlnText (
3188: ComponentFactory.createCheckBoxMenuItem (CRTC.crtSphericalScrolling, "Spherical scrolling of text screen", modificationListener),
3189: "ja", "テキスト画面の球面スクロール")
3190: ),
3191: "ja", "テキスト画面"),
3192: Multilingual.mlnText (
3193: ComponentFactory.createMenu (
3194: "Sprite screen",
3195: Multilingual.mlnText (
3196: ComponentFactory.createRadioButtonMenuItem (
3197: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 128, "128 sprites", modificationListener),
3198: "ja", "128 枚のスプライト"),
3199: Multilingual.mlnText (
3200: ComponentFactory.createRadioButtonMenuItem (
3201: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 256, "256 sprites", modificationListener),
3202: "ja", "256 枚のスプライト"),
3203: Multilingual.mlnText (
3204: ComponentFactory.createRadioButtonMenuItem (
3205: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 512, "504 sprites", modificationListener),
3206: "ja", "504 枚のスプライト"),
3207: Multilingual.mlnText (
3208: ComponentFactory.createRadioButtonMenuItem (
3209: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 1024, "1016 sprites", modificationListener),
3210: "ja", "1016 枚のスプライト"),
3211:
3212:
3213:
3214:
3215: ComponentFactory.createHorizontalSeparator (),
3216: Multilingual.mlnText (
3217: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprBankOnRequest, "4096 patterns", modificationListener),
3218: "ja", "4096 個のパターン"),
3219: Multilingual.mlnText (
3220: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr768x512Request, "Sprites displayed in 768x512", modificationListener),
3221: "ja", "768x512 でスプライトを表示"),
3222: Multilingual.mlnText (
3223: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr512bg1Request, "BG1 displayed in 512x512", modificationListener),
3224: "ja", "512x512 で BG1 を表示"),
3225: !SpriteScreen.SPR_RC_SCROLL_ON ? null : Multilingual.mlnText (
3226: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprRcScrollRequest, "Row and column scroll", modificationListener),
3227: "ja", "行スクロールと列スクロール"),
3228: ComponentFactory.createHorizontalSeparator (),
3229: ComponentFactory.createHorizontalBox (
3230: Box.createHorizontalStrut (20),
3231: Multilingual.mlnText (ComponentFactory.createLabel ("Number of sprites per raster"), "ja", "ラスタあたりのスプライトの枚数"),
3232: Box.createHorizontalGlue ()
3233: ),
3234: ComponentFactory.createHorizontalBox (
3235: Box.createHorizontalStrut (20),
3236: sprrasSpinner,
3237: ComponentFactory.createLabel (" *"),
3238: Box.createHorizontalGlue ()
3239: ),
3240: Multilingual.mlnText (
3241: ComponentFactory.createMenuItem ("** Reset to default values", modificationListener),
3242: "ja", "** 初期値に戻す")
3243: ),
3244: "ja", "スプライト画面")
3245: ),
3246: "ja", "改造");
3247:
3248:
3249: mnbMenuBar = ComponentFactory.createMenuBar (
3250:
3251:
3252: mnbFileMenu = Multilingual.mlnText (
3253: ComponentFactory.createMenu (
3254: "File", 'F',
3255:
3256: FDC.fdcMenu,
3257:
3258: HDC.hdcMenu,
3259:
3260: SPC.spcMenu,
3261:
3262: HFS.hfsMenu,
3263: ComponentFactory.createHorizontalSeparator (),
3264: mnbQuitMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Quit", 'Q', MNB_MODIFIERS, listener), "ja", "終了")
3265: ),
3266: "ja", "ファイル"),
3267:
3268:
3269: mpuMenu,
3270:
3271:
3272: mnbDisplayMenu = Multilingual.mlnText (
3273: ComponentFactory.createMenu (
3274: "Display", 'D',
3275: mnbFullScreenMenuItem,
3276: mnbMaximizedMenuItem,
3277: mnbFitInWindowMenuItem,
3278: mnbFixedScaleMenuItem,
3279: ComponentFactory.createHorizontalBox (
3280: Box.createHorizontalStrut (20),
3281: pnlFixedSpinner,
3282: ComponentFactory.createLabel ("%"),
3283: Box.createHorizontalGlue ()
3284: ),
3285: ComponentFactory.createMenuItem ("50%", listener),
3286: ComponentFactory.createMenuItem ("75%", listener),
3287: ComponentFactory.createMenuItem ("100%", listener),
3288: ComponentFactory.createMenuItem ("150%", listener),
3289: ComponentFactory.createMenuItem ("200%", listener),
3290:
3291: rotationMenu,
3292:
3293: aspectMenu,
3294:
3295: Multilingual.mlnText (
3296: ComponentFactory.createMenu (
3297: "Interpolation algorithm",
3298: Multilingual.mlnText (
3299: ComponentFactory.createRadioButtonMenuItem (
3300: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
3301: "Nearest neighbor", listener),
3302: "ja", "最近傍補間"),
3303: Multilingual.mlnText (
3304: ComponentFactory.createRadioButtonMenuItem (
3305: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR,
3306: "Bilinear", listener),
3307: "ja", "線形補間"),
3308: Multilingual.mlnText (
3309: ComponentFactory.createRadioButtonMenuItem (
3310: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC,
3311: "Bicubic", listener),
3312: "ja", "三次補間")
3313: ),
3314: "ja", "補間アルゴリズム"),
3315:
3316: scanlineMenu,
3317: !PNL_USE_CANVAS ? null : Multilingual.mlnText (
3318: ComponentFactory.createCheckBoxMenuItem (pnlUseCanvasRequest, "Use canvas", listener),
3319: "ja", "キャンバスを使う"),
3320:
3321: !CRTC.CRT_ENABLE_INTERMITTENT ? null : Multilingual.mlnText (
3322: ComponentFactory.createMenu (
3323: "Intermittent drawing",
3324: Multilingual.mlnText (
3325: ComponentFactory.createRadioButtonMenuItem (
3326: intermittentGroup, CRTC.crtIntermittentInterval == 0, "Draw all changed pictures", listener),
3327: "ja", "変化した画像をすべて描画する"),
3328: Multilingual.mlnText (
3329: ComponentFactory.createRadioButtonMenuItem (
3330: intermittentGroup, CRTC.crtIntermittentInterval == 1, "Draw a changed picture once every two times", listener),
3331: "ja", "変化した画像を 2 回に 1 回描画する"),
3332: Multilingual.mlnText (
3333: ComponentFactory.createRadioButtonMenuItem (
3334: intermittentGroup, CRTC.crtIntermittentInterval == 2, "Draw a changed picture once every three times", listener),
3335: "ja", "変化した画像を 3 回に 1 回描画する"),
3336: Multilingual.mlnText (
3337: ComponentFactory.createRadioButtonMenuItem (
3338: intermittentGroup, CRTC.crtIntermittentInterval == 3, "Draw a changed picture once every four times", listener),
3339: "ja", "変化した画像を 4 回に 1 回描画する"),
3340: Multilingual.mlnText (
3341: ComponentFactory.createRadioButtonMenuItem (
3342: intermittentGroup, CRTC.crtIntermittentInterval == 4, "Draw a changed picture once every five times", listener),
3343: "ja", "変化した画像を 5 回に 1 回描画する")
3344: ),
3345: "ja", "間欠描画"),
3346:
3347: !PNL_STEREOSCOPIC_ON ? null : ComponentFactory.createHorizontalSeparator (),
3348: mnbStereoscopicMenuItem = !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3349: ComponentFactory.createCheckBoxMenuItem (pnlStereoscopicOn, "Stereoscopic viewing", 'T', listener),
3350: "ja", "立体視"),
3351: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3352: ComponentFactory.createMenu (
3353: "Stereoscopic settings",
3354: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3355: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3356: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING,
3357: "Naked-eye crossing", listener),
3358: "ja", "裸眼交差法"),
3359: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3360: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3361: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL,
3362: "Naked-eye parallel", listener),
3363: "ja", "裸眼平行法"),
3364: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3365: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3366: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE,
3367: "Side-by-side", listener),
3368: "ja", "サイドバイサイド"),
3369: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3370: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3371: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM,
3372: "Top-and-bottom", listener),
3373: "ja", "トップアンドボトム")
3374: ),
3375: "ja", "立体視設定"),
3376:
3377: ComponentFactory.createHorizontalSeparator (),
3378: GIFAnimation.gifStartRecordingMenuItem,
3379: GIFAnimation.gifSettingsMenu,
3380:
3381: ComponentFactory.createHorizontalSeparator (),
3382: modificationMenu,
3383:
3384: SpritePatternViewer.SPV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Sprite pattern viewer", listener), "ja", "スプライトパターンビュア") : null,
3385: PaletteViewer.PLV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Palette viewer", listener), "ja", "パレットビュア") : null,
3386: ScreenModeTest.SMT_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Screen mode test", listener), "ja", "表示モードテスト") : null
3387: ),
3388: "ja", "画面"),
3389:
3390:
3391: mnbSoundMenu = ComponentFactory.setEnabled (
3392: Multilingual.mlnText (
3393: ComponentFactory.createMenu (
3394: "Sound", 'S',
3395: mnbPlayMenuItem = ComponentFactory.setEnabled (
3396: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (SoundSource.sndPlayOn, "Play", 'P', MNB_MODIFIERS, listener), "ja", "音声出力"),
3397: SoundSource.sndLine != null),
3398:
3399:
3400:
3401: ComponentFactory.createHorizontalBox (
3402: Box.createHorizontalGlue (),
3403: Multilingual.mlnText (ComponentFactory.createLabel ("Volume "), "ja", "音量 "),
3404: mnbVolumeLabel = ComponentFactory.createLabel (String.valueOf (SoundSource.sndVolume)),
3405: Box.createHorizontalGlue ()
3406: ),
3407:
3408:
3409: ComponentFactory.setPreferredSize (
3410: ComponentFactory.createHorizontalSlider (
3411: 0,
3412: SoundSource.SND_VOLUME_MAX,
3413: SoundSource.sndVolume,
3414: SoundSource.SND_VOLUME_STEP,
3415: 1,
3416: new ChangeListener () {
3417: @Override public void stateChanged (ChangeEvent ce) {
3418: SoundSource.sndSetVolume (((JSlider) ce.getSource ()).getValue ());
3419: }
3420: }),
3421: LnF.lnfFontSize * 18, LnF.lnfFontSize * 2 + 28),
3422: Multilingual.mlnText (
3423: ComponentFactory.createMenu (
3424: "Sound interpolation",
3425: Multilingual.mlnText (
3426: ComponentFactory.createRadioButtonMenuItem (
3427: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.THINNING_STEREO,
3428: "Sound thinning", listener),
3429: "ja", "音声 間引き"),
3430: Multilingual.mlnText (
3431: ComponentFactory.createRadioButtonMenuItem (
3432: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_STEREO,
3433: "Sound linear interpolation", listener),
3434: "ja", "音声 線形補間"),
3435: ComponentFactory.setEnabled (
3436: Multilingual.mlnText (
3437: ComponentFactory.createRadioButtonMenuItem (
3438: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000,
3439: "Sound piecewise-constant area interpolation", listener),
3440: "ja", "音声 区分定数面積補間"),
3441: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000),
3442: ComponentFactory.setEnabled (
3443: Multilingual.mlnText (
3444: ComponentFactory.createRadioButtonMenuItem (
3445: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000,
3446: "Sound linear area interpolation", listener),
3447: "ja", "音声 線形面積補間"),
3448: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000)
3449: ),
3450: "ja", "音声補間"),
3451: Multilingual.mlnText (ComponentFactory.createMenuItem ("Sound monitor", listener), "ja", "音声モニタ"),
3452:
3453: ComponentFactory.createHorizontalSeparator (),
3454:
3455: ComponentFactory.setEnabled (
3456: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (OPM.opmOutputMask != 0, "OPM output", listener), "ja", "OPM 出力"),
3457: SoundSource.sndLine != null),
3458: !OPMLog.OLG_ON ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("OPM log", listener), "ja", "OPM ログ"),
3459:
3460: ComponentFactory.createHorizontalSeparator (),
3461:
3462: ComponentFactory.setEnabled (
3463: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ADPCM.pcmOutputOn, "PCM output", listener), "ja", "PCM 出力"),
3464: SoundSource.sndLine != null),
3465: Multilingual.mlnText (
3466: ComponentFactory.createMenu (
3467: "PCM interpolation",
3468: Multilingual.mlnText (
3469: ComponentFactory.createRadioButtonMenuItem (
3470: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_CONSTANT,
3471: "PCM piecewise-constant interpolation", listener),
3472: "ja", "PCM 区分定数補間"),
3473: Multilingual.mlnText (
3474: ComponentFactory.createRadioButtonMenuItem (
3475: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_LINEAR,
3476: "PCM linear interpolation", listener),
3477: "ja", "PCM 線形補間"),
3478: Multilingual.mlnText (
3479: ComponentFactory.createRadioButtonMenuItem (
3480: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_HERMITE,
3481: "PCM hermite interpolation", listener),
3482: "ja", "PCM エルミート補間")
3483: ),
3484: "ja", "PCM 補間"),
3485: Multilingual.mlnText (
3486: ComponentFactory.createMenu (
3487: "PCM source oscillator frequency",
3488: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 0, "PCM 8MHz/4MHz", listener),
3489: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 1, "PCM 8MHz/16MHz", listener)
3490: ),
3491: "ja", "PCM 原発振周波数")
3492: ),
3493: "ja", "音声"),
3494: SoundSource.sndLine != null),
3495:
3496:
3497: mnbInputMenu = Multilingual.mlnText (
3498: ComponentFactory.createMenu (
3499: "Input", 'I',
3500: mnbPasteMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Paste", 'V', MNB_MODIFIERS, listener), "ja", "貼り付け"),
3501: CONDevice.conSettingsMenu,
3502: TextCopy.txcMakeMenuItem (),
3503: TextCopy.txcMakeSettingMenu (),
3504: ComponentFactory.createHorizontalSeparator (),
3505: mnbNoKeyboardMenuItem = Multilingual.mlnText (
3506: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, !Keyboard.kbdOn, "No keyboard", 'K', MNB_MODIFIERS, listener),
3507: "ja", "キーボードなし"),
3508: mnbStandardKeyboardMenuItem = Multilingual.mlnText (
3509: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_STANDARD_TYPE, "Standard keyboard", listener),
3510: "ja", "標準キーボード"),
3511: mnbCompactKeyboardMenuItem = Multilingual.mlnText (
3512: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_COMPACT_TYPE, "Compact keyboard", listener),
3513: "ja", "コンパクトキーボード"),
3514: Multilingual.mlnText (
3515: ComponentFactory.createCheckBoxMenuItem (pnlHideKeyboard, "Hide keyboard in full screen", listener),
3516: "ja", "全画面表示のときキーボードを隠す"),
3517: Multilingual.mlnText (ComponentFactory.createMenuItem ("Key assignments", listener), "ja", "キー割り当て"),
3518: ButtonFunction.bfnMakeMenuItem (),
3519: SRAM.smrRepeatDelayMenu,
3520: SRAM.smrRepeatIntervalMenu,
3521: !Keyboard.KBD_ZKEY_ON ? null : Keyboard.kbdZKeyMenu,
3522: ComponentFactory.createHorizontalSeparator (),
3523: Mouse.musSeamlessMouseCheckBox,
3524: Mouse.musFollowScrollCheckBox,
3525: Mouse.musCtrlRightCheckBox,
3526: Mouse.musEdgeAccelerationCheckBox,
3527: Mouse.musMouseCursorSpeedBox,
3528: Mouse.musSpeedSlider,
3529: Mouse.musHostsPixelUnitsCheckBox,
3530: ComponentFactory.createHorizontalSeparator (),
3531: Multilingual.mlnText (ComponentFactory.createMenuItem ("Joystick port settings", listener), "ja", "ジョイスティックポート設定")
3532: ),
3533: "ja", "入力"),
3534:
3535:
3536: mnbConfigMenu = Multilingual.mlnText (
3537: ComponentFactory.createMenu (
3538: "Config", 'G',
3539: Multilingual.mlnText (ComponentFactory.createMenuItem ("RS-232C and terminal", listener), "ja", "RS-232C とターミナル"),
3540: Multilingual.mlnText (
3541: ComponentFactory.createMenu (
3542: "Debug",
3543: Multilingual.mlnText (ComponentFactory.createMenuItem ("Console", listener), "ja", "コンソール"),
3544: Multilingual.mlnText (ComponentFactory.createMenuItem ("Register list", listener), "ja", "レジスタリスト"),
3545: Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble list", listener), "ja", "逆アセンブルリスト"),
3546: Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory dump list", listener), "ja", "メモリダンプリスト"),
3547: Multilingual.mlnText (ComponentFactory.createMenuItem ("Logical space monitor", listener), "ja", "論理空間モニタ"),
3548: Multilingual.mlnText (ComponentFactory.createMenuItem ("Physical space monitor", listener), "ja", "物理空間モニタ"),
3549: ATCMonitor.ACM_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Address translation caches monitor", listener), "ja", "アドレス変換キャッシュモニタ") : null,
3550: BranchLog.BLG_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Branch log", listener), "ja", "分岐ログ") : null,
3551: ProgramFlowVisualizer.PFV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Program flow visualizer", listener), "ja", "プログラムフロービジュアライザ") : null,
3552: RasterBreakPoint.RBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Raster break point", listener), "ja", "ラスタブレークポイント") : null,
3553: DataBreakPoint.DBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Data break point", listener), "ja", "データブレークポイント") : null,
3554: RootPointerList.RTL_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Root pointer list", listener), "ja", "ルートポインタリスト") : null,
3555: ComponentFactory.createHorizontalSeparator (),
3556: SRAM.smrRomdbMenu
3557: ),
3558: "ja", "デバッグ"),
3559: SRAM.smrBootMenu,
3560: mainMemoryMenu,
3561: highMemoryMenu,
3562: localMemoryMenu,
3563: xellent30Menu,
3564: ComponentFactory.createHorizontalSeparator (),
3565: ComponentFactory.createMenu (
3566: "RTC",
3567: Multilingual.mlnText (
3568: ComponentFactory.createMenuItem ("Adjust clock to host", listener),
3569: "ja", "時計をホストに合わせる")
3570: ),
3571: SRAM.smrMenu,
3572: Settings.sgsMenu,
3573: ComponentFactory.createHorizontalSeparator (),
3574: Multilingual.mlnText (ComponentFactory.createMenuItem ("Printer", listener), "ja", "プリンタ"),
3575: ROM.romMenu,
3576: Multilingual.mlnText (
3577: ComponentFactory.createMenu (
3578: "Miscellaneous",
3579: SlowdownTest.sdtCheckBoxMenuItem,
3580: SlowdownTest.sdtBox,
3581: Multilingual.mlnText (
3582: ComponentFactory.createCheckBoxMenuItem (Mouse.musOutputButtonStatus, "Print key and mouse button events", listener),
3583: "ja", "キーとマウスのボタンのイベントを表示"),
3584: Z8530.SCC_DEBUG_ON ? Z8530.sccDebugMenu : null
3585: ),
3586: "ja", "その他"),
3587: ComponentFactory.createHorizontalSeparator (),
3588: Multilingual.mlnText (
3589: ComponentFactory.createMenuItem ("Java runtime environment information", listener),
3590: "ja", "Java 実行環境の情報"),
3591: Multilingual.mlnText (
3592: ComponentFactory.createMenuItem ("Version information", listener),
3593: "ja", "バージョン情報"),
3594: Multilingual.mlnText (
3595: ComponentFactory.createMenu (
3596: "License",
3597: Multilingual.mlnText (ComponentFactory.createMenuItem ("XEiJ License", listener), "ja", "XEiJ 使用許諾条件"),
3598: Multilingual.mlnText (ComponentFactory.createMenuItem ("FSHARP License", listener), "ja", "FSHARP 許諾条件"),
3599: Multilingual.mlnText (ComponentFactory.createMenuItem ("ymfm License", listener), "ja", "ymfm License"),
3600: Multilingual.mlnText (ComponentFactory.createMenuItem ("jSerialComm License", listener), "ja", "jSerialComm License")
3601: ),
3602: "ja", "使用許諾条件")
3603: ),
3604: "ja", "設定"),
3605:
3606: mnbMakeLanguageMenu (),
3607:
3608:
3609: Box.createHorizontalGlue (),
3610: ComponentFactory.createVerticalBox (
3611: Box.createVerticalGlue (),
3612: Indicator.indBox,
3613: Box.createVerticalGlue ()
3614: ),
3615: Box.createHorizontalGlue ()
3616:
3617: );
3618: }
3619:
3620:
3621:
3622:
3623:
3624:
3625:
3626: public static boolean frmIsActive;
3627:
3628:
3629: public static JFrame frmFrame;
3630: public static int frmMarginWidth;
3631: public static int frmMarginHeight;
3632: public static Dimension frmMinimumSize;
3633:
3634:
3635: public static GraphicsDevice frmScreenDevice;
3636:
3637:
3638: public static DropTarget frmDropTarget;
3639:
3640:
3641:
3642: public static void frmInit () {
3643: frmIsActive = false;
3644: frmScreenDevice = GraphicsEnvironment.getLocalGraphicsEnvironment ().getDefaultScreenDevice ();
3645: pnlIsFullScreenSupported = frmScreenDevice.isFullScreenSupported ();
3646: }
3647:
3648:
3649:
3650: public static void frmMake () {
3651:
3652:
3653: frmFrame = ComponentFactory.createRestorableFrame (
3654: Settings.SGS_FRM_FRAME_KEY,
3655: PRG_TITLE + " version " + PRG_VERSION,
3656: mnbMenuBar,
3657: pnlPanel);
3658: frmUpdateTitle ();
3659: frmFrame.setIconImage (LnF.LNF_ICON_IMAGE_48);
3660: frmFrame.setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);
3661:
3662:
3663:
3664:
3665: frmMarginWidth = frmFrame.getWidth () - pnlPanel.getWidth ();
3666: frmMarginHeight = frmFrame.getHeight () - pnlPanel.getHeight ();
3667: frmMinimumSize = new Dimension (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
3668: frmFrame.setMinimumSize (frmMinimumSize);
3669:
3670:
3671:
3672: frmDropTarget = new DropTarget (pnlPanel, DnDConstants.ACTION_COPY, new DropTargetAdapter () {
3673: @Override public void dragOver (DropTargetDragEvent dtde) {
3674: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
3675: dtde.acceptDrag (DnDConstants.ACTION_COPY);
3676: return;
3677: }
3678: dtde.rejectDrag ();
3679: }
3680: @Override public void drop (DropTargetDropEvent dtde) {
3681: try {
3682: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
3683: dtde.acceptDrop (DnDConstants.ACTION_COPY);
3684: boolean reset = false;
3685: int fdu0 = -1;
3686: int fdu = 0;
3687: int hdu0 = -1;
3688: int hdu = 0;
3689: int scu0 = -1;
3690: int scu = 0;
3691: int hfu0 = -1;
3692: int hfu = 0;
3693: for (Object o : (java.util.List) dtde.getTransferable ().getTransferData (DataFlavor.javaFileListFlavor)) {
3694: if (o instanceof File) {
3695: File file = (File) o;
3696: if (file.isFile ()) {
3697: if (FDC.fdcFileFilter.accept (file)) {
3698: if (fdu < FDC.FDC_MAX_UNITS &&
3699: FDC.fdcUnitArray[fdu].insert (file.getPath (), false)) {
3700: if (fdu0 < 0) {
3701: fdu0 = fdu;
3702: }
3703: fdu++;
3704: continue;
3705: }
3706: }
3707: if (HDC.hdcFileFilter.accept (file)) {
3708: if (hdu < 16 &&
3709: HDC.hdcUnitArray[hdu].insert (file.getPath (), false)) {
3710: if (hdu0 < 0) {
3711: hdu0 = hdu;
3712: }
3713: hdu++;
3714: continue;
3715: }
3716: }
3717: if (SPC.spcFileFilter.accept (file)) {
3718: if (scu < 16 &&
3719: SPC.spcUnitArray[scu].insert (file.getPath (), false)) {
3720: if (scu0 < 0) {
3721: scu0 = scu;
3722: }
3723: scu++;
3724: continue;
3725: }
3726: }
3727: }
3728: if (HFS.hfsFileFilter.accept (file)) {
3729: if (hfu < HFS.HFS_MAX_UNITS &&
3730: HFS.hfsUnitArray[hfu].insert (file.getPath (), false)) {
3731: if (hfu0 < 0) {
3732: hfu0 = hfu;
3733: }
3734: hfu++;
3735: continue;
3736: }
3737: }
3738: }
3739: reset = false;
3740: }
3741: dtde.dropComplete (true);
3742: if (reset) {
3743: if (fdu0 >= 0) {
3744: mpuReset (0x9070 | fdu0 << 8, -1);
3745: } else if (hdu0 >= 0) {
3746: mpuReset (0x8000 | hdu0 << 8, -1);
3747: } else if (scu0 >= 0) {
3748: mpuReset (0xa000, SPC.SPC_HANDLE_EX + (scu0 << 2));
3749: } else if (hfu0 >= 0) {
3750: HFS.hfsBootUnit = hfu0;
3751: mpuReset (0xa000, HFS.HFS_BOOT_HANDLE);
3752: }
3753: }
3754: return;
3755: }
3756: } catch (UnsupportedFlavorException ufe) {
3757:
3758: } catch (IOException ioe) {
3759:
3760: }
3761: dtde.rejectDrop();
3762: }
3763: });
3764:
3765: }
3766:
3767:
3768:
3769: public static void frmUpdateTitle () {
3770: frmFrame.setTitle ((currentAccelerator == ACCELERATOR_HYBRID ? "X68000 Hybrid" :
3771: currentModel.getName () +
3772: (currentAccelerator == ACCELERATOR_XELLENT30 ? " with Xellent30" :
3773: currentAccelerator == ACCELERATOR_060TURBO ? " with 060turbo" :
3774: currentAccelerator == ACCELERATOR_060TURBOPRO ? " with 060turboPRO" : "")) +
3775: " - " + PRG_TITLE + " version " + PRG_VERSION);
3776: }
3777:
3778:
3779:
3780: public static void frmStart () {
3781:
3782:
3783:
3784:
3785:
3786:
3787:
3788:
3789: ComponentFactory.addListener (
3790: frmFrame,
3791: new WindowAdapter () {
3792: @Override public void windowActivated (WindowEvent we) {
3793: frmIsActive = true;
3794: }
3795: @Override public void windowClosing (WindowEvent we) {
3796: prgTini ();
3797: }
3798: @Override public void windowDeactivated (WindowEvent we) {
3799: frmIsActive = false;
3800:
3801: }
3802: @Override public void windowOpened (WindowEvent we) {
3803: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3804: pnlFixedRate = pnlGetRefreshRate ();
3805: }
3806: }
3807: });
3808:
3809:
3810:
3811:
3812: ComponentFactory.addListener (
3813: frmFrame,
3814: new ComponentAdapter () {
3815: @Override public void componentMoved (ComponentEvent ce) {
3816: Point p = pnlPanel.getLocationOnScreen ();
3817: pnlGlobalX = p.x;
3818: pnlGlobalY = p.y;
3819: }
3820: @Override public void componentResized (ComponentEvent ce) {
3821: Point p = pnlPanel.getLocationOnScreen ();
3822: pnlGlobalX = p.x;
3823: pnlGlobalY = p.y;
3824: }
3825: });
3826:
3827: }
3828:
3829:
3830:
3831:
3832:
3833:
3834: public static BufferedImage clpClipboardImage;
3835: public static String clpClipboardString;
3836: public static Clipboard clpClipboard;
3837: public static Transferable clpImageContents;
3838: public static Transferable clpStringContents;
3839: public static ClipboardOwner clpClipboardOwner;
3840: public static boolean clpIsClipboardOwner;
3841:
3842:
3843:
3844:
3845: public static void clpMake () {
3846: Toolkit toolkit = Toolkit.getDefaultToolkit ();
3847: clpClipboard = null;
3848: try {
3849: clpClipboard = toolkit.getSystemClipboard ();
3850: } catch (Exception e) {
3851: return;
3852: }
3853: clpClipboardImage = null;
3854: clpClipboardString = null;
3855: clpImageContents = new Transferable () {
3856: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
3857: if (flavor == DataFlavor.imageFlavor) {
3858: return clpClipboardImage;
3859: } else {
3860: throw new UnsupportedFlavorException (flavor);
3861: }
3862: }
3863: public DataFlavor[] getTransferDataFlavors () {
3864: return new DataFlavor[] { DataFlavor.imageFlavor };
3865: }
3866: public boolean isDataFlavorSupported (DataFlavor flavor) {
3867: return flavor == DataFlavor.imageFlavor;
3868: }
3869: };
3870: clpStringContents = new Transferable () {
3871: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
3872: if (flavor == DataFlavor.stringFlavor) {
3873: return clpClipboardString;
3874: } else {
3875: throw new UnsupportedFlavorException (flavor);
3876: }
3877: }
3878: public DataFlavor[] getTransferDataFlavors () {
3879: return new DataFlavor[] { DataFlavor.stringFlavor };
3880: }
3881: public boolean isDataFlavorSupported (DataFlavor flavor) {
3882: return flavor == DataFlavor.stringFlavor;
3883: }
3884: };
3885: clpIsClipboardOwner = false;
3886:
3887:
3888: clpClipboardOwner = new ClipboardOwner () {
3889: @Override public void lostOwnership (Clipboard clipboard, Transferable contents) {
3890: clpIsClipboardOwner = false;
3891: }
3892: };
3893:
3894:
3895: clpClipboard.addFlavorListener (new FlavorListener () {
3896: @Override public void flavorsChanged (FlavorEvent fe) {
3897: boolean available = false;
3898: try {
3899: available = clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor);
3900: } catch (IllegalStateException ise) {
3901: }
3902: if (mnbPasteMenuItem != null) {
3903: mnbPasteMenuItem.setEnabled (available);
3904: }
3905: }
3906: });
3907: if (!clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor)) {
3908: if (mnbPasteMenuItem != null) {
3909: mnbPasteMenuItem.setEnabled (false);
3910: }
3911: }
3912: }
3913:
3914:
3915:
3916: public static void clpCopy (String s) {
3917: if (clpClipboard != null && s != null) {
3918: clpClipboardString = s;
3919: try {
3920: clpClipboard.setContents (clpStringContents, clpClipboardOwner);
3921: clpIsClipboardOwner = true;
3922: } catch (Exception e) {
3923: return;
3924: }
3925: }
3926: }
3927:
3928:
3929:
3930:
3931:
3932:
3933:
3934:
3935:
3936:
3937:
3938:
3939:
3940:
3941:
3942:
3943:
3944:
3945:
3946:
3947:
3948:
3949:
3950: public static int xt3DIPSWRequest;
3951: public static int xt3DIPSW;
3952: public static int xt3PortAddress;
3953:
3954:
3955: public static int xt3MemorySizeRequest;
3956: public static int xt3MemorySize;
3957: public static boolean xt3MemoryEnabled;
3958: public static int xt3MemoryPosition;
3959: public static int xt3MemoryStart;
3960: public static final byte[] xt3MemoryArray = new byte[1 << 20];
3961: public static boolean xt3MemorySave;
3962:
3963:
3964: public static int xt3SavedPC;
3965: public static final int[] xt3SavedRn = new int[16];
3966:
3967:
3968: public static void xt3Init () {
3969:
3970:
3971: xt3DIPSWRequest = Math.max (0, Math.min (3, Settings.sgsGetInt ("xt3dipsw")));
3972: xt3DIPSW = xt3DIPSWRequest;
3973:
3974:
3975: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
3976:
3977:
3978: int memoryKB = Settings.sgsGetInt ("xt3memorykb");
3979: if (!(memoryKB == 1 << 8 || memoryKB == 1 << 10)) {
3980: memoryKB = 1 << 8;
3981: }
3982: xt3MemorySizeRequest = memoryKB << 10;
3983: xt3MemorySize = xt3MemorySizeRequest;
3984:
3985:
3986: xt3MemoryEnabled = false;
3987:
3988:
3989: xt3MemoryPosition = 11 << 20;
3990:
3991:
3992: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
3993:
3994:
3995:
3996: byte[] memoryArray = Settings.sgsGetData ("xt3memorydata");
3997: Arrays.fill (xt3MemoryArray,
3998: (byte) 0);
3999: if (memoryArray.length != 0) {
4000: System.arraycopy (memoryArray, 0,
4001: xt3MemoryArray, 0,
4002: Math.min (memoryArray.length, xt3MemoryArray.length));
4003: if (memoryArray.length < xt3MemoryArray.length) {
4004: Arrays.fill (xt3MemoryArray,
4005: memoryArray.length,
4006: xt3MemoryArray.length,
4007: (byte) 0);
4008: }
4009: }
4010:
4011:
4012: xt3MemorySave = Settings.sgsGetOnOff ("xt3memorysave");
4013:
4014:
4015: xt3SavedPC = 0;
4016:
4017: Arrays.fill (xt3SavedRn, 0);
4018:
4019: xt3Reset ();
4020: }
4021:
4022:
4023: public static void xt3Tini () {
4024:
4025:
4026: Settings.sgsPutInt ("xt3dipsw", xt3DIPSW);
4027:
4028:
4029: Settings.sgsPutInt ("xt3memorykb", xt3MemorySizeRequest >> 10);
4030:
4031:
4032: boolean zero = true;
4033: if (xt3MemorySave) {
4034: for (int i = 0; i < 1 << 20; i++) {
4035: if (xt3MemoryArray[i] != 0) {
4036: zero = false;
4037: break;
4038: }
4039: }
4040: }
4041: Settings.sgsCurrentMap.put ("xt3memorydata",
4042: zero ? "" :
4043: ByteArray.byaEncodeBase64 (ByteArray.byaEncodeGzip (xt3MemoryArray, 0, 1 << 20)));
4044:
4045:
4046: Settings.sgsPutOnOff ("xt3memorysave", xt3MemorySave);
4047:
4048: }
4049:
4050:
4051: public static void xt3Reset () {
4052:
4053:
4054: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4055:
4056:
4057: xt3MemorySize = xt3MemorySizeRequest;
4058:
4059:
4060: xt3MemoryEnabled = false;
4061:
4062:
4063: xt3MemoryPosition = 11 << 20;
4064:
4065:
4066: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4067:
4068:
4069: xt3SavedPC = 0;
4070: Arrays.fill (xt3SavedRn, 0);
4071:
4072: }
4073:
4074:
4075: public static int xt3PortRead () {
4076: return (currentIsSecond ? 4 : 0) | (xt3MemoryEnabled ? 2 : 0) | (xt3MemoryPosition == 11 << 20 ? 0 : 1);
4077: }
4078:
4079:
4080: public static void xt3PortWrite (int d) {
4081: boolean nextIsSecond = (d & 4) != 0;
4082: boolean memoryEnabled = (d & 2) != 0;
4083: int memoryPosition = (d & 1) == 0 ? 11 << 20 : 15 << 20;
4084:
4085: if (xt3MemoryEnabled != memoryEnabled ||
4086: xt3MemoryPosition != memoryPosition) {
4087: if (xt3MemoryEnabled) {
4088: if (xt3MemoryPosition == 11 << 20) {
4089: if (MainMemory.mmrMemorySizeCurrent < 12 << 20) {
4090: busSuper (MemoryMappedDevice.MMD_NUL, (12 << 20) - xt3MemorySize, 12 << 20);
4091: } else {
4092: busUser (MemoryMappedDevice.MMD_MMR, (12 << 20) - xt3MemorySize, 12 << 20);
4093: }
4094: } else {
4095: busSuper (MemoryMappedDevice.MMD_ROM, (16 << 20) - xt3MemorySize, 16 << 20);
4096: }
4097: }
4098: xt3MemoryEnabled = memoryEnabled;
4099: xt3MemoryPosition = memoryPosition;
4100: if (xt3MemoryEnabled) {
4101: if (xt3MemoryPosition == 11 << 20) {
4102: busUser (MemoryMappedDevice.MMD_XTM, (12 << 20) - xt3MemorySize, 12 << 20);
4103: } else {
4104: busUser (MemoryMappedDevice.MMD_XTM, (16 << 20) - xt3MemorySize, 16 << 20);
4105: }
4106: }
4107: }
4108:
4109: if (currentIsSecond != nextIsSecond) {
4110:
4111: if (nextIsSecond) {
4112:
4113:
4114: xt3SavedPC = regPC;
4115: System.arraycopy (regRn, 0, xt3SavedRn, 0, 16);
4116:
4117:
4118: if (mpuTask != null) {
4119: mpuClockLimit = 0L;
4120: System.out.println (Multilingual.mlnJapanese ?
4121: Model.MPU_NAMES[currentFirstMPU] + " を停止します" :
4122: Model.MPU_NAMES[currentFirstMPU] + " stops");
4123: mpuTask.cancel ();
4124: mpuTask = null;
4125: }
4126:
4127:
4128: tmrTimer.schedule (new TimerTask () {
4129: @Override public void run () {
4130:
4131:
4132: currentIsSecond = true;
4133: currentMPU = currentSecondMPU;
4134: mpuSetCurrentClock (specifiedSecondClock);
4135:
4136: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
4137: MC68EC030.m30DivZeroVFlag = false;
4138: }
4139:
4140: RegisterList.drpSetMPU ();
4141: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4142: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4143: MC68060.mmuReset ();
4144:
4145: mpuIgnoreAddressError = true;
4146: fpuBox = fpuMotherboardCoprocessor;
4147: fpuBox.epbReset ();
4148: fpuFPn = fpuBox.epbFPn;
4149: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
4150: mpuSetWait ();
4151:
4152: regSRT1 = regSRT0 = 0;
4153: regSRS = REG_SR_S;
4154: regSRM = 0;
4155: regSRI = REG_SR_I;
4156: regCCR = 0;
4157: Arrays.fill (regRn, 0);
4158:
4159: regRn[15] = MainMemory.mmrRls (0x00000000);
4160: regPC = MainMemory.mmrRls (0x00000004);
4161:
4162: mpuIMR = 0;
4163: mpuIRR = 0;
4164: if (MC68901.MFP_DELAYED_INTERRUPT) {
4165: mpuDIRR = 0;
4166: }
4167: mpuISR = 0;
4168:
4169: mpuStart ();
4170: }
4171: }, TMR_DELAY);
4172:
4173: } else {
4174:
4175:
4176: if (mpuTask != null) {
4177: mpuClockLimit = 0L;
4178: System.out.println (Multilingual.mlnJapanese ? "MC68EC030 を停止します" : "MC68EC030 stops");
4179: mpuTask.cancel ();
4180: mpuTask = null;
4181: }
4182:
4183:
4184: tmrTimer.schedule (new TimerTask () {
4185: @Override public void run () {
4186:
4187:
4188: currentIsSecond = false;
4189: currentMPU = currentFirstMPU;
4190: mpuSetCurrentClock (specifiedFirstClock);
4191:
4192: RegisterList.drpSetMPU ();
4193: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4194: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4195: MC68060.mmuReset ();
4196:
4197: mpuIgnoreAddressError = false;
4198: mpuCacheOn = false;
4199: mpuSetWait ();
4200:
4201: regSRT1 = regSRT0 = 0;
4202: regSRS = REG_SR_S;
4203: regSRM = 0;
4204: regSRI = REG_SR_I;
4205: regCCR = 0;
4206:
4207: regPC = xt3SavedPC;
4208: System.arraycopy (xt3SavedRn, 0, regRn, 0, 16);
4209:
4210: mpuIMR = 0;
4211: mpuIRR = 0;
4212: if (MC68901.MFP_DELAYED_INTERRUPT) {
4213: mpuDIRR = 0;
4214: }
4215: mpuISR = 0;
4216:
4217: mpuStart ();
4218: }
4219: }, TMR_DELAY);
4220:
4221: }
4222: }
4223: }
4224:
4225:
4226:
4227:
4228:
4229:
4230: public static JMenu mdlMenu;
4231:
4232: public static JRadioButtonMenuItem mdlShodaiMenuItem;
4233: public static JRadioButtonMenuItem mdlACEMenuItem;
4234: public static JRadioButtonMenuItem mdlEXPERTMenuItem;
4235: public static JRadioButtonMenuItem mdlPROMenuItem;
4236: public static JRadioButtonMenuItem mdlSUPERMenuItem;
4237: public static JRadioButtonMenuItem mdlXVIMenuItem;
4238: public static JRadioButtonMenuItem mdlXellent30MenuItem;
4239: public static JRadioButtonMenuItem mdlCompactMenuItem;
4240: public static JRadioButtonMenuItem mdlHybridMenuItem;
4241: public static JRadioButtonMenuItem mdl060turboPROMenuItem;
4242: public static JRadioButtonMenuItem mdlX68030MenuItem;
4243: public static JRadioButtonMenuItem mdl030CompactMenuItem;
4244: public static JRadioButtonMenuItem mdl060turboMenuItem;
4245: public static JCheckBoxMenuItem mdlMC68010MenuItem;
4246:
4247: public static JMenu coproFPUMenu;
4248:
4249:
4250: public static final int ACCELERATOR_HYBRID = 1;
4251: public static final int ACCELERATOR_XELLENT30 = 2;
4252: public static final int ACCELERATOR_060TURBO = 3;
4253: public static final int ACCELERATOR_060TURBOPRO = 4;
4254: public static final double MHZ_HYBRID_VALUE = 100.0 / 3.0;
4255: public static final String MHZ_HYBRID_STRING = "33.3";
4256: public static final double MHZ_060TURBO_VALUE = 50.0;
4257: public static final String MHZ_060TURBO_STRING = "50";
4258:
4259:
4260:
4261: public static Model specifiedModel;
4262: public static int specifiedAccelerator;
4263: public static boolean mpu010;
4264:
4265: public static boolean specifiedIsSecond;
4266: public static int specifiedFirstMPU;
4267: public static int specifiedSecondMPU;
4268: public static int specifiedMPU;
4269:
4270: public static double specifiedFirstClock;
4271: public static double specifiedSecondClock;
4272: public static double specifiedClock;
4273:
4274: public static int specifiedCopro0;
4275: public static int specifiedCopro1;
4276: public static int specifiedCopro2;
4277: public static int specifiedOnchipFPU;
4278:
4279:
4280:
4281: public static Model currentModel;
4282: public static int currentAccelerator;
4283:
4284: public static boolean currentIsSecond;
4285: public static int currentFirstMPU;
4286: public static int currentSecondMPU;
4287: public static int currentMPU;
4288:
4289:
4290: public static int currentCopro0;
4291: public static int currentCopro1;
4292: public static int currentCopro2;
4293: public static int currentOnchipFPU;
4294:
4295:
4296:
4297: public static void mdlInit () {
4298:
4299:
4300: specifiedModel = Model.COMPACT;
4301: specifiedAccelerator = ACCELERATOR_HYBRID;
4302: mpu010 = Settings.sgsGetOnOff ("mpu010");
4303: {
4304: String paramModel = Settings.sgsGetString ("model");
4305: switch (paramModel.toLowerCase ()) {
4306: case "":
4307: case "none":
4308: case "hybrid":
4309: specifiedModel = Model.COMPACT;
4310: specifiedAccelerator = ACCELERATOR_HYBRID;
4311: break;
4312: case "xellent30":
4313: specifiedModel = Model.XVI;
4314: specifiedAccelerator = ACCELERATOR_XELLENT30;
4315: break;
4316: case "060turbo":
4317: specifiedModel = Model.X68030;
4318: specifiedAccelerator = ACCELERATOR_060TURBO;
4319: break;
4320: case "060turbopro":
4321: specifiedModel = Model.PRO;
4322: specifiedAccelerator = ACCELERATOR_060TURBOPRO;
4323: break;
4324: default:
4325: Model model = Model.fromTypeOrSynonym (paramModel);
4326: if (model != null) {
4327: specifiedModel = model;
4328: specifiedAccelerator = 0;
4329: } else {
4330: System.out.println (Multilingual.mlnJapanese ?
4331: paramModel + " は不明な機種です" :
4332: paramModel + " is unknown model");
4333: specifiedModel = Model.COMPACT;
4334: specifiedAccelerator = ACCELERATOR_HYBRID;
4335: }
4336: }
4337: }
4338:
4339: specifiedIsSecond = false;
4340: specifiedFirstMPU = specifiedModel.getMPU ();
4341: specifiedSecondMPU = Model.MPU_MC68EC030;
4342: {
4343: String[] paramMPUs = Settings.sgsGetString ("mpu").split (",");
4344: for (int i = 0; i < 2; i++) {
4345: int mpu = 0;
4346: String paramMPU = i < paramMPUs.length ? paramMPUs[i] : "";
4347: switch (paramMPU) {
4348: case "":
4349: case "none":
4350: case "-1":
4351: mpu = (i == 0 ?
4352: (specifiedAccelerator == ACCELERATOR_060TURBO ||
4353: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4354: specifiedModel.getMPU ()) :
4355: Model.MPU_MC68EC030);
4356: break;
4357: case "0":
4358: case "68000":
4359: case "mc68000":
4360: mpu = Model.MPU_MC68000;
4361: break;
4362: case "1":
4363: case "68010":
4364: case "mc68010":
4365: mpu = Model.MPU_MC68010;
4366: break;
4367:
4368:
4369:
4370:
4371:
4372: case "3":
4373: case "68ec030":
4374: case "mc68ec030":
4375: mpu = Model.MPU_MC68EC030;
4376: break;
4377:
4378:
4379:
4380:
4381:
4382:
4383:
4384:
4385:
4386:
4387:
4388:
4389:
4390:
4391:
4392:
4393:
4394: case "6":
4395: case "68060":
4396: case "mc68060":
4397: mpu = Model.MPU_MC68060;
4398: break;
4399: default:
4400: Model model = Model.fromTypeOrSynonym (paramMPU);
4401: if (model != null) {
4402: mpu = model.getMPU ();
4403: } else {
4404: System.out.println (Multilingual.mlnJapanese ?
4405: paramMPU + " は不明な MPU です" :
4406: paramMPU + " is unknown MPU");
4407: mpu = specifiedModel.getMPU ();
4408: }
4409: }
4410: if (i == 0) {
4411: specifiedFirstMPU = mpu;
4412: } else {
4413: specifiedSecondMPU = mpu;
4414: }
4415: }
4416: }
4417: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
4418:
4419: specifiedFirstClock = specifiedModel.getClock ();
4420: specifiedSecondClock = specifiedFirstClock * 2.0;
4421: {
4422: String[] paramClocks = Settings.sgsGetString ("clock").split (",");
4423: for (int i = 0; i < 2; i++) {
4424: double clock = 0.0;
4425: String paramClock = i < paramClocks.length ? paramClocks[i] : "";
4426: switch (paramClock.toLowerCase ()) {
4427: case "":
4428: case "none":
4429: case "-1":
4430: clock = (i == 0 ?
4431: (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4432: specifiedAccelerator == ACCELERATOR_060TURBO ||
4433: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4434: specifiedModel.getClock ()) :
4435: specifiedFirstClock * 2.0);
4436: break;
4437: case "hybrid":
4438: clock = MHZ_HYBRID_VALUE;
4439: break;
4440: case "060turbo":
4441: case "060turbopro":
4442: clock = MHZ_060TURBO_VALUE;
4443: break;
4444: case "16.7":
4445: case "xellent30":
4446: clock = 50.0 / 3.0;
4447: break;
4448: case "33.3":
4449: clock = 100.0 / 3.0;
4450: break;
4451: case "66.7":
4452: clock = 200.0 / 3.0;
4453: break;
4454: default:
4455: if (paramClock.matches ("^(?:" +
4456: "[-+]?" +
4457: "(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)" +
4458: "(?:[Ee][-+]?[0-9]+)?" +
4459: ")$")) {
4460: double d = Double.parseDouble (paramClock);
4461: if (1.0 <= d && d <= 1000.0) {
4462: clock = d;
4463: }
4464: } else {
4465: System.out.println (Multilingual.mlnJapanese ?
4466: paramClock + " は不明な動作周波数です" :
4467: paramClock + " is unknown clock frequency");
4468: clock = specifiedModel.getClock ();
4469: }
4470: }
4471: if (i == 0) {
4472: specifiedFirstClock = clock;
4473: } else {
4474: specifiedSecondClock = clock;
4475: }
4476: }
4477: }
4478: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4479:
4480: specifiedCopro0 = 15 & Settings.sgsGetInt ("copro0", 2);
4481: if (!((7 & specifiedCopro0) == 0 ||
4482: (7 & specifiedCopro0) == 1 ||
4483: (7 & specifiedCopro0) == 2 ||
4484: (7 & specifiedCopro0) == 7)) {
4485: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4486: }
4487: specifiedCopro1 = 15 & Settings.sgsGetInt ("copro1", 2);
4488: if (!((7 & specifiedCopro1) == 0 ||
4489: (7 & specifiedCopro1) == 1 ||
4490: (7 & specifiedCopro1) == 2 ||
4491: (7 & specifiedCopro1) == 7)) {
4492: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4493: }
4494: specifiedCopro2 = 15 & Settings.sgsGetInt ("copro2", 2);
4495: if (!((7 & specifiedCopro2) == 0 ||
4496: (7 & specifiedCopro2) == 1 ||
4497: (7 & specifiedCopro2) == 2 ||
4498: (7 & specifiedCopro2) == 7)) {
4499: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4500: }
4501: specifiedOnchipFPU = 15 & Settings.sgsGetInt ("onchipfpu", 7);
4502: if (!((7 & specifiedOnchipFPU) == 0 ||
4503: (7 & specifiedOnchipFPU) == 6 ||
4504: (7 & specifiedOnchipFPU) == 7)) {
4505: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4506: }
4507:
4508:
4509: currentModel = specifiedModel;
4510: currentAccelerator = specifiedAccelerator;
4511:
4512: currentIsSecond = specifiedIsSecond;
4513: currentFirstMPU = specifiedFirstMPU;
4514: currentSecondMPU = specifiedSecondMPU;
4515: currentMPU = specifiedMPU;
4516:
4517:
4518: currentCopro0 = specifiedCopro0;
4519: currentCopro1 = specifiedCopro1;
4520: currentCopro2 = specifiedCopro2;
4521: currentOnchipFPU = specifiedOnchipFPU;
4522:
4523:
4524: mpuUtilOn = Settings.sgsGetOnOff ("util");
4525: mpuUtilRatio = fmtParseInt (Settings.sgsGetString ("ratio"), 0, 1, 100, 100);
4526:
4527: mpuArbFreqMHz = fmtParseInt (Settings.sgsGetString ("mhz"), 0, 1, 1000, 100);
4528: if (mpuUtilOn) {
4529: mpuArbFreqOn = false;
4530: } else {
4531: mpuArbFreqOn = !(specifiedClock == 10.0 ||
4532: specifiedClock == 50.0 / 3.0 ||
4533: specifiedClock == 25.0 ||
4534: specifiedClock == 100.0 / 3.0 ||
4535: specifiedClock == 50.0 ||
4536: specifiedClock == 200.0 / 3.0 ||
4537: specifiedClock == 75.0 ||
4538: specifiedClock == 100.0);
4539: if (mpuArbFreqOn) {
4540: mpuArbFreqMHz = (int) specifiedClock;
4541: }
4542: }
4543:
4544:
4545: mpuROMWaitCycles = 0;
4546: mpuRAMWaitCycles = 0;
4547: mpuCacheOn = false;
4548:
4549: mpuNoWaitTime.ram = 0;
4550: mpuNoWaitTime.gvram = 0;
4551: mpuNoWaitTime.tvram = 0;
4552: mpuNoWaitTime.crtc = 0;
4553: mpuNoWaitTime.palet = 0;
4554: mpuNoWaitTime.vicon = 0;
4555: mpuNoWaitTime.dmac = 0;
4556: mpuNoWaitTime.mfp = 0;
4557: mpuNoWaitTime.rtc = 0;
4558: mpuNoWaitTime.prnport = 0;
4559: mpuNoWaitTime.sysport = 0;
4560: mpuNoWaitTime.opm = 0;
4561: mpuNoWaitTime.adpcm = 0;
4562: mpuNoWaitTime.fdc = 0;
4563: mpuNoWaitTime.fdd = 0;
4564: mpuNoWaitTime.hdc = 0;
4565: mpuNoWaitTime.scc = 0;
4566: mpuNoWaitTime.ppi = 0;
4567: mpuNoWaitTime.ioi = 0;
4568: mpuNoWaitTime.sprc = 0;
4569: mpuNoWaitTime.sram = 0;
4570: mpuNoWaitTime.rom = 0;
4571: mpuNoWaitTime.ramlong = mpuNoWaitTime.ram << 1;
4572: mpuNoWaitTime.romlong = mpuNoWaitTime.rom << 1;
4573:
4574: dmaNoWaitTime.ram = 0;
4575: dmaNoWaitTime.gvram = 0;
4576: dmaNoWaitTime.tvram = 0;
4577: dmaNoWaitTime.crtc = 0;
4578: dmaNoWaitTime.palet = 0;
4579: dmaNoWaitTime.vicon = 0;
4580: dmaNoWaitTime.dmac = 0;
4581: dmaNoWaitTime.mfp = 0;
4582: dmaNoWaitTime.rtc = 0;
4583: dmaNoWaitTime.prnport = 0;
4584: dmaNoWaitTime.sysport = 0;
4585: dmaNoWaitTime.opm = 0;
4586: dmaNoWaitTime.adpcm = 0;
4587: dmaNoWaitTime.fdc = 0;
4588: dmaNoWaitTime.fdd = 0;
4589: dmaNoWaitTime.hdc = 0;
4590: dmaNoWaitTime.scc = 0;
4591: dmaNoWaitTime.ppi = 0;
4592: dmaNoWaitTime.ioi = 0;
4593: dmaNoWaitTime.sprc = 0;
4594: dmaNoWaitTime.sram = 0;
4595: dmaNoWaitTime.rom = 0;
4596: dmaNoWaitTime.ramlong = dmaNoWaitTime.ram << 1;
4597: dmaNoWaitTime.romlong = dmaNoWaitTime.rom << 1;
4598:
4599:
4600: busWaitCyclesRequest = Settings.sgsGetOnOff ("waitcycles");
4601: busWaitCycles = busWaitCyclesRequest;
4602: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
4603:
4604: }
4605:
4606: public static void mdlTini () {
4607:
4608: Settings.sgsPutString ("model",
4609: specifiedAccelerator == ACCELERATOR_HYBRID ? "Hybrid" :
4610: specifiedAccelerator == ACCELERATOR_XELLENT30 ? "Xellent30" :
4611: specifiedAccelerator == ACCELERATOR_060TURBO ? "060turbo" :
4612: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? "060turboPRO" :
4613: specifiedModel.getSynonym () != null ? specifiedModel.getSynonym () :
4614: specifiedModel.getType ());
4615: Settings.sgsPutOnOff ("mpu010", mpu010);
4616:
4617:
4618: int defaultFirstMPU = (specifiedAccelerator == ACCELERATOR_060TURBO ||
4619: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4620: specifiedModel.getMPU ());
4621: int defaultSecondMPU = Model.MPU_MC68EC030;
4622: Settings.sgsPutString ("mpu",
4623: (specifiedFirstMPU == defaultFirstMPU ? "" :
4624: Model.mpuNameOf (specifiedFirstMPU)) +
4625: (specifiedSecondMPU == defaultSecondMPU ? "" :
4626: "," + Model.mpuNameOf (specifiedSecondMPU)));
4627:
4628:
4629:
4630:
4631: double defaultFirstClock = (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4632: specifiedAccelerator == ACCELERATOR_060TURBO ||
4633: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4634: specifiedModel.getClock ());
4635: double defaultSecondClock = defaultFirstClock * 2.0;
4636: Settings.sgsPutString ("clock",
4637: (specifiedFirstClock == defaultFirstClock ? "" :
4638: specifiedFirstClock == 50.0 / 3.0 ? "16.7" :
4639: specifiedFirstClock == 100.0 / 3.0 ? "33.3" :
4640: specifiedFirstClock == 200.0 / 3.0 ? "66.7" :
4641: String.valueOf ((int) specifiedFirstClock)) +
4642: (specifiedSecondClock == defaultSecondClock ? "" :
4643: "," + (specifiedSecondClock == 50.0 / 3.0 ? "16.7" :
4644: specifiedSecondClock == 100.0 / 3.0 ? "33.3" :
4645: specifiedSecondClock == 200.0 / 3.0 ? "66.7" :
4646: String.valueOf ((int) specifiedSecondClock))));
4647:
4648: Settings.sgsPutInt ("copro0", specifiedCopro0);
4649: Settings.sgsPutInt ("copro1", specifiedCopro1);
4650: Settings.sgsPutInt ("copro2", specifiedCopro2);
4651: Settings.sgsPutInt ("onchipfpu", specifiedOnchipFPU);
4652:
4653: Settings.sgsPutOnOff ("util",
4654: mpuUtilOn);
4655: Settings.sgsPutString ("ratio",
4656: String.valueOf (mpuUtilRatio));
4657:
4658: Settings.sgsPutString ("mhz",
4659: String.valueOf (mpuArbFreqMHz));
4660:
4661: Settings.sgsPutOnOff ("waitcycles", busWaitCyclesRequest);
4662: }
4663:
4664: public static void mdlMakeMenu () {
4665:
4666:
4667: ActionListener listener = new ActionListener () {
4668: @Override public void actionPerformed (ActionEvent ae) {
4669: Object source = ae.getSource ();
4670: switch (ae.getActionCommand ()) {
4671: case "X68000 (10MHz)":
4672: mdlRequestModel (Model.SHODAI, 0);
4673: mpuReset (-1, -1);
4674: break;
4675: case "X68000 ACE (10MHz)":
4676: mdlRequestModel (Model.ACE, 0);
4677: mpuReset (-1, -1);
4678: break;
4679: case "X68000 EXPERT (10MHz)":
4680: mdlRequestModel (Model.EXPERT, 0);
4681: mpuReset (-1, -1);
4682: break;
4683: case "X68000 PRO (10MHz)":
4684: mdlRequestModel (Model.PRO, 0);
4685: mpuReset (-1, -1);
4686: break;
4687: case "X68000 SUPER (10MHz)":
4688: mdlRequestModel (Model.SUPER, 0);
4689: mpuReset (-1, -1);
4690: break;
4691: case "X68000 XVI (16.7MHz)":
4692: mdlRequestModel (Model.XVI, 0);
4693: mpuReset (-1, -1);
4694: break;
4695: case "X68000 Compact (16.7MHz)":
4696: mdlRequestModel (Model.COMPACT, 0);
4697: mpuReset (-1, -1);
4698: break;
4699:
4700: case "X68030 (25MHz)":
4701: mdlRequestModel (Model.X68030, 0);
4702: mpuReset (-1, -1);
4703: break;
4704: case "X68030 Compact (25MHz)":
4705: mdlRequestModel (Model.X68030COMPACT, 0);
4706: mpuReset (-1, -1);
4707: break;
4708:
4709: case "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)":
4710: mdlRequestModel (Model.COMPACT, ACCELERATOR_HYBRID);
4711: mpuReset (-1, -1);
4712: break;
4713: case "Xellent30 (33.3MHz)":
4714: mdlRequestModel (Model.XVI, ACCELERATOR_XELLENT30);
4715: mpuReset (-1, -1);
4716: break;
4717: case "060turbo (" + MHZ_060TURBO_STRING + "MHz)":
4718: mdlRequestModel (Model.X68030, ACCELERATOR_060TURBO);
4719: mpuReset (-1, -1);
4720: break;
4721: case "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)":
4722: mdlRequestModel (Model.PRO, ACCELERATOR_060TURBOPRO);
4723: mpuReset (-1, -1);
4724: break;
4725:
4726: case "MC68010":
4727: mpu010 = ((JCheckBoxMenuItem) source).isSelected ();
4728: break;
4729:
4730: }
4731: }
4732: };
4733:
4734:
4735: ButtonGroup modelGroup = new ButtonGroup ();
4736: mdlMenu = Multilingual.mlnText (
4737: ComponentFactory.createMenu (
4738: "Change the model and reset",
4739: mdlShodaiMenuItem = ComponentFactory.createRadioButtonMenuItem (
4740: modelGroup,
4741: specifiedModel == Model.SHODAI,
4742: "X68000 (10MHz)",
4743: listener),
4744: mdlACEMenuItem = ComponentFactory.createRadioButtonMenuItem (
4745: modelGroup,
4746: specifiedModel == Model.ACE,
4747: "X68000 ACE (10MHz)",
4748: listener),
4749: mdlEXPERTMenuItem = ComponentFactory.createRadioButtonMenuItem (
4750: modelGroup,
4751: specifiedModel == Model.EXPERT,
4752: "X68000 EXPERT (10MHz)",
4753: listener),
4754: mdlPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
4755: modelGroup,
4756: specifiedModel == Model.PRO && specifiedAccelerator == 0,
4757: "X68000 PRO (10MHz)",
4758: listener),
4759: mdlSUPERMenuItem = ComponentFactory.createRadioButtonMenuItem (
4760: modelGroup,
4761: specifiedModel == Model.SUPER,
4762: "X68000 SUPER (10MHz)",
4763: listener),
4764: mdlXVIMenuItem = ComponentFactory.createRadioButtonMenuItem (
4765: modelGroup,
4766: specifiedModel == Model.XVI && specifiedAccelerator == 0,
4767: "X68000 XVI (16.7MHz)",
4768: listener),
4769: mdlCompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
4770: modelGroup,
4771: specifiedModel == Model.COMPACT && specifiedAccelerator == 0,
4772: "X68000 Compact (16.7MHz)",
4773: listener),
4774:
4775: ComponentFactory.createHorizontalSeparator (),
4776:
4777: mdlX68030MenuItem = ComponentFactory.createRadioButtonMenuItem (
4778: modelGroup,
4779: specifiedModel == Model.X68030 && specifiedAccelerator == 0,
4780: "X68030 (25MHz)",
4781: listener),
4782: mdl030CompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
4783: modelGroup,
4784: specifiedModel == Model.X68030COMPACT,
4785: "X68030 Compact (25MHz)",
4786: listener),
4787:
4788: ComponentFactory.createHorizontalSeparator (),
4789:
4790: mdlHybridMenuItem = ComponentFactory.createRadioButtonMenuItem (
4791: modelGroup,
4792: specifiedModel == Model.COMPACT && specifiedAccelerator == ACCELERATOR_HYBRID,
4793: "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)",
4794: listener),
4795: mdlXellent30MenuItem = ComponentFactory.createRadioButtonMenuItem (
4796: modelGroup,
4797: specifiedModel == Model.XVI && specifiedAccelerator == ACCELERATOR_XELLENT30,
4798: "Xellent30 (33.3MHz)",
4799: listener),
4800: mdl060turboMenuItem = ComponentFactory.createRadioButtonMenuItem (
4801: modelGroup,
4802: specifiedModel == Model.X68030 && specifiedAccelerator == ACCELERATOR_060TURBO,
4803: "060turbo (" + MHZ_060TURBO_STRING + "MHz)",
4804: listener),
4805: mdl060turboPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
4806: modelGroup,
4807: specifiedModel == Model.PRO && specifiedAccelerator == ACCELERATOR_060TURBOPRO,
4808: "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)",
4809: listener),
4810:
4811: ComponentFactory.createHorizontalSeparator (),
4812:
4813: mdlMC68010MenuItem = ComponentFactory.createCheckBoxMenuItem (
4814: mpu010,
4815: "MC68010",
4816: listener)
4817: ),
4818: "ja", "機種を変更してリセット");
4819:
4820:
4821: ActionListener copro0Listener = new ActionListener () {
4822: @Override public void actionPerformed (ActionEvent ae) {
4823: String command = ae.getActionCommand ();
4824: switch (command) {
4825: case "Not installed":
4826: specifiedCopro0 = (8 & specifiedCopro0) | 0;
4827: break;
4828: case "MC68881":
4829: specifiedCopro0 = (8 & specifiedCopro0) | 1;
4830: break;
4831: case "MC68882":
4832: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4833: break;
4834: case "Full specification":
4835: specifiedCopro0 = (8 & specifiedCopro0) | 7;
4836: break;
4837: case "Extended precision (19 digits)":
4838: specifiedCopro0 = 0 | (7 & specifiedCopro0);
4839: break;
4840: case "Triple precision (24 digits)":
4841: specifiedCopro0 = 8 | (7 & specifiedCopro0);
4842: break;
4843: default:
4844: System.out.println ("unknown action command " + command);
4845: }
4846: }
4847: };
4848:
4849: ActionListener copro1Listener = new ActionListener () {
4850: @Override public void actionPerformed (ActionEvent ae) {
4851: String command = ae.getActionCommand ();
4852: switch (command) {
4853: case "Not installed":
4854: specifiedCopro1 = (8 & specifiedCopro1) | 0;
4855: break;
4856: case "MC68881":
4857: specifiedCopro1 = (8 & specifiedCopro1) | 1;
4858: break;
4859: case "MC68882":
4860: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4861: break;
4862: case "Full specification":
4863: specifiedCopro1 = (8 & specifiedCopro1) | 7;
4864: break;
4865: case "Extended precision (19 digits)":
4866: specifiedCopro1 = 0 | (7 & specifiedCopro1);
4867: break;
4868: case "Triple precision (24 digits)":
4869: specifiedCopro1 = 8 | (7 & specifiedCopro1);
4870: break;
4871: default:
4872: System.out.println ("unknown action command " + command);
4873: }
4874: }
4875: };
4876:
4877: ActionListener copro2Listener = new ActionListener () {
4878: @Override public void actionPerformed (ActionEvent ae) {
4879: String command = ae.getActionCommand ();
4880: switch (command) {
4881: case "Not installed":
4882: specifiedCopro2 = (8 & specifiedCopro2) | 0;
4883: break;
4884: case "MC68881":
4885: specifiedCopro2 = (8 & specifiedCopro2) | 1;
4886: break;
4887: case "MC68882":
4888: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4889: break;
4890: case "Full specification":
4891: specifiedCopro2 = (8 & specifiedCopro2) | 7;
4892: break;
4893: case "Extended precision (19 digits)":
4894: specifiedCopro2 = 0 | (7 & specifiedCopro2);
4895: break;
4896: case "Triple precision (24 digits)":
4897: specifiedCopro2 = 8 | (7 & specifiedCopro2);
4898: break;
4899: default:
4900: System.out.println ("unknown action command " + command);
4901: }
4902: }
4903: };
4904:
4905: ActionListener onchipFPUListener = new ActionListener () {
4906: @Override public void actionPerformed (ActionEvent ae) {
4907: String command = ae.getActionCommand ();
4908: switch (command) {
4909: case "Not installed":
4910: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 0;
4911: break;
4912: case "MC68060":
4913: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 6;
4914: break;
4915: case "Full specification":
4916: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4917: break;
4918: case "Extended precision (19 digits)":
4919: specifiedOnchipFPU = 0 | (7 & specifiedOnchipFPU);
4920: break;
4921: case "Triple precision (24 digits)":
4922: specifiedOnchipFPU = 8 | (7 & specifiedOnchipFPU);
4923: break;
4924: default:
4925: System.out.println ("unknown action command " + command);
4926: }
4927: }
4928: };
4929:
4930: ButtonGroup copro00Group = new ButtonGroup ();
4931: ButtonGroup copro01Group = new ButtonGroup ();
4932: ButtonGroup copro10Group = new ButtonGroup ();
4933: ButtonGroup copro11Group = new ButtonGroup ();
4934: ButtonGroup copro20Group = new ButtonGroup ();
4935: ButtonGroup copro21Group = new ButtonGroup ();
4936: ButtonGroup onchipFPU0Group = new ButtonGroup ();
4937: ButtonGroup onchipFPU1Group = new ButtonGroup ();
4938:
4939: coproFPUMenu = Multilingual.mlnText (
4940: ComponentFactory.createMenu (
4941: "Coprocessor and on-chip FPU",
4942:
4943: Multilingual.mlnText (
4944: ComponentFactory.createMenu (
4945: "Motherboard coprocessor",
4946: Multilingual.mlnText (
4947: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 0, "Not installed", copro0Listener),
4948: "ja", "なし"),
4949: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 1, "MC68881", copro0Listener),
4950: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 2, "MC68882", copro0Listener),
4951: Multilingual.mlnText (
4952: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 7, "Full specification", copro0Listener),
4953: "ja", "フルスペック"),
4954: ComponentFactory.createHorizontalSeparator (),
4955: Multilingual.mlnText (
4956: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) == 0, "Extended precision (19 digits)", copro0Listener),
4957: "ja", "拡張精度 (19 桁)"),
4958: Multilingual.mlnText (
4959: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) != 0, "Triple precision (24 digits)", copro0Listener),
4960: "ja", "三倍精度 (24 桁)")),
4961: "ja", "マザーボードコプロセッサ"),
4962:
4963: Multilingual.mlnText (
4964: ComponentFactory.createMenu (
4965: "Extension coprocessor #1",
4966: Multilingual.mlnText (
4967: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 0, "Not installed", copro1Listener),
4968: "ja", "なし"),
4969: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 1, "MC68881", copro1Listener),
4970: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 2, "MC68882", copro1Listener),
4971: Multilingual.mlnText (
4972: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 7, "Full specification", copro1Listener),
4973: "ja", "フルスペック"),
4974: ComponentFactory.createHorizontalSeparator (),
4975: Multilingual.mlnText (
4976: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) == 0, "Extended precision (19 digits)", copro1Listener),
4977: "ja", "拡張精度 (19 桁)"),
4978: Multilingual.mlnText (
4979: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) != 0, "Triple precision (24 digits)", copro1Listener),
4980: "ja", "三倍精度 (24 桁)")),
4981: "ja", "拡張コプロセッサ #1"),
4982:
4983: Multilingual.mlnText (
4984: ComponentFactory.createMenu (
4985: "Extension coprocessor #2",
4986: Multilingual.mlnText (
4987: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 0, "Not installed", copro2Listener),
4988: "ja", "なし"),
4989: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 1, "MC68881", copro2Listener),
4990: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 2, "MC68882", copro2Listener),
4991: Multilingual.mlnText (
4992: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 7, "Full specification", copro2Listener),
4993: "ja", "フルスペック"),
4994: ComponentFactory.createHorizontalSeparator (),
4995: Multilingual.mlnText (
4996: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) == 0, "Extended precision (19 digits)", copro2Listener),
4997: "ja", "拡張精度 (19 桁)"),
4998: Multilingual.mlnText (
4999: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) != 0, "Triple precision (24 digits)", copro2Listener),
5000: "ja", "三倍精度 (24 桁)")),
5001: "ja", "拡張コプロセッサ #2"),
5002:
5003: Multilingual.mlnText (
5004: ComponentFactory.createMenu (
5005: "On-chip FPU",
5006: Multilingual.mlnText (
5007: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 0, "Not installed", onchipFPUListener),
5008: "ja", "なし"),
5009: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 6, "MC68060", onchipFPUListener),
5010: Multilingual.mlnText (
5011: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 7, "Full specification", onchipFPUListener),
5012: "ja", "フルスペック"),
5013: ComponentFactory.createHorizontalSeparator (),
5014: Multilingual.mlnText (
5015: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) == 0, "Extended precision (19 digits)", onchipFPUListener),
5016: "ja", "拡張精度 (19 桁)"),
5017: Multilingual.mlnText (
5018: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) != 0, "Triple precision (24 digits)", onchipFPUListener),
5019: "ja", "三倍精度 (24 桁)")),
5020: "ja", "オンチップ FPU")),
5021: "ja", "コプロセッサとオンチップ FPU");
5022:
5023: }
5024:
5025: public static void mdlRequestModel (Model model, int accelerator) {
5026: specifiedModel = model;
5027: specifiedAccelerator = accelerator;
5028:
5029: specifiedIsSecond = false;
5030: specifiedFirstMPU = specifiedModel.getMPU ();
5031: specifiedSecondMPU = Model.MPU_MC68EC030;
5032: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
5033: specifiedFirstClock = specifiedModel.getClock ();
5034: specifiedSecondClock = specifiedFirstClock * 2.0;
5035: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5036:
5037: switch (accelerator) {
5038: case ACCELERATOR_HYBRID:
5039: specifiedFirstClock = MHZ_HYBRID_VALUE;
5040: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5041: break;
5042: case ACCELERATOR_XELLENT30:
5043: break;
5044: case ACCELERATOR_060TURBO:
5045: case ACCELERATOR_060TURBOPRO:
5046: specifiedFirstMPU = Model.MPU_MC68060;
5047: specifiedFirstClock = MHZ_060TURBO_VALUE;
5048: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5049: }
5050:
5051: mpuUtilOn = false;
5052: mpuArbFreqOn = false;
5053: mpuSetCurrentClock (specifiedClock);
5054:
5055: if (accelerator == ACCELERATOR_HYBRID) {
5056: mdlHybridMenuItem.setSelected (true);
5057: } else if (accelerator == ACCELERATOR_XELLENT30) {
5058: mdlXellent30MenuItem.setSelected (true);
5059: } else if (accelerator == ACCELERATOR_060TURBO) {
5060: mdl060turboMenuItem.setSelected (true);
5061: } else if (accelerator == ACCELERATOR_060TURBOPRO) {
5062: mdl060turboPROMenuItem.setSelected (true);
5063: } else if (specifiedModel == Model.SHODAI) {
5064: mdlShodaiMenuItem.setSelected (true);
5065: } else if (specifiedModel == Model.ACE) {
5066: mdlACEMenuItem.setSelected (true);
5067: } else if (specifiedModel == Model.EXPERT) {
5068: mdlEXPERTMenuItem.setSelected (true);
5069: } else if (specifiedModel == Model.PRO) {
5070: mdlPROMenuItem.setSelected (true);
5071: } else if (specifiedModel == Model.SUPER) {
5072: mdlSUPERMenuItem.setSelected (true);
5073: } else if (specifiedModel == Model.XVI) {
5074: mdlXVIMenuItem.setSelected (true);
5075: } else if (specifiedModel == Model.COMPACT) {
5076: mdlCompactMenuItem.setSelected (true);
5077: } else if (specifiedModel == Model.X68030) {
5078: mdlX68030MenuItem.setSelected (true);
5079: } else if (specifiedModel == Model.X68030COMPACT) {
5080: mdl030CompactMenuItem.setSelected (true);
5081: }
5082:
5083:
5084: HDC.hdcSASIMenuItem.setSelected (!currentModel.isSCSI ());
5085: SPC.spcSCSIINMenuItem.setSelected (currentModel.isSCSI ());
5086: }
5087:
5088:
5089:
5090:
5091:
5092:
5093:
5094: public static final boolean MPU_INLINE_EXCEPTION = true;
5095: public static final boolean MPU_COMPOUND_POSTINCREMENT = false;
5096:
5097: public static final boolean MPU_SWITCH_MISC_OPCODE = false;
5098: public static final boolean MPU_SWITCH_BCC_CONDITION = false;
5099: public static final boolean MPU_SWITCH_BCC_OFFSET = false;
5100: public static final boolean MPU_SWITCH_SCC_CONDITION = true;
5101:
5102: public static final boolean MPU_OMIT_EXTRA_READ = false;
5103: public static final boolean MPU_OMIT_OFFSET_READ = false;
5104:
5105:
5106:
5107:
5108: public static final long FAR_FUTURE = 0x7fffffffffffffffL;
5109:
5110:
5111:
5112:
5113:
5114:
5115:
5116:
5117: public static final int REG_SR_T1 = 0b10000000_00000000;
5118: public static final int REG_SR_T0 = 0b01000000_00000000;
5119:
5120:
5121:
5122:
5123:
5124:
5125: public static final int REG_SR_S = 0b00100000_00000000;
5126: public static final int REG_SR_M = 0b00010000_00000000;
5127:
5128: public static final int REG_SR_I = 0b00000111_00000000;
5129:
5130:
5131: public static final int REG_CCR_X = 0b00000000_00010000;
5132: public static final int REG_CCR_N = 0b00000000_00001000;
5133: public static final int REG_CCR_Z = 0b00000000_00000100;
5134: public static final int REG_CCR_V = 0b00000000_00000010;
5135: public static final int REG_CCR_C = 0b00000000_00000001;
5136: public static final int REG_CCR_MASK = REG_CCR_X | REG_CCR_N | REG_CCR_Z | REG_CCR_V | REG_CCR_C;
5137:
5138: public static char[] REG_CCRXMAP = "00000000000000001111111111111111".toCharArray ();
5139: public static char[] REG_CCRNMAP = "00000000111111110000000011111111".toCharArray ();
5140: public static char[] REG_CCRZMAP = "00001111000011110000111100001111".toCharArray ();
5141: public static char[] REG_CCRVMAP = "00110011001100110011001100110011".toCharArray ();
5142: public static char[] REG_CCRCMAP = "01010101010101010101010101010101".toCharArray ();
5143:
5144:
5145:
5146: public static final int MPU_IOI_INTERRUPT_LEVEL = 1;
5147: public static final int MPU_EB2_INTERRUPT_LEVEL = 2;
5148: public static final int MPU_DMA_INTERRUPT_LEVEL = 3;
5149: public static final int MPU_SCC_INTERRUPT_LEVEL = 5;
5150: public static final int MPU_MFP_INTERRUPT_LEVEL = 6;
5151: public static final int MPU_SYS_INTERRUPT_LEVEL = 7;
5152: public static final int MPU_IOI_INTERRUPT_MASK = 0x80 >> MPU_IOI_INTERRUPT_LEVEL;
5153: public static final int MPU_EB2_INTERRUPT_MASK = 0x80 >> MPU_EB2_INTERRUPT_LEVEL;
5154: public static final int MPU_DMA_INTERRUPT_MASK = 0x80 >> MPU_DMA_INTERRUPT_LEVEL;
5155: public static final int MPU_SCC_INTERRUPT_MASK = 0x80 >> MPU_SCC_INTERRUPT_LEVEL;
5156: public static final int MPU_MFP_INTERRUPT_MASK = 0x80 >> MPU_MFP_INTERRUPT_LEVEL;
5157: public static final int MPU_SYS_INTERRUPT_MASK = 0x80 >> MPU_SYS_INTERRUPT_LEVEL;
5158:
5159: public static final boolean MPU_INTERRUPT_SWITCH = true;
5160:
5161:
5162: public static final boolean T = true;
5163: public static final boolean F = false;
5164:
5165: public static final int CCCC_T = 0b0000;
5166: public static final int CCCC_F = 0b0001;
5167: public static final int CCCC_HI = 0b0010;
5168: public static final int CCCC_LS = 0b0011;
5169: public static final int CCCC_CC = 0b0100;
5170: public static final int CCCC_CS = 0b0101;
5171: public static final int CCCC_NE = 0b0110;
5172: public static final int CCCC_EQ = 0b0111;
5173: public static final int CCCC_VC = 0b1000;
5174: public static final int CCCC_VS = 0b1001;
5175: public static final int CCCC_PL = 0b1010;
5176: public static final int CCCC_MI = 0b1011;
5177: public static final int CCCC_GE = 0b1100;
5178: public static final int CCCC_LT = 0b1101;
5179: public static final int CCCC_GT = 0b1110;
5180: public static final int CCCC_LE = 0b1111;
5181:
5182:
5183:
5184:
5185:
5186:
5187: public static final boolean[] BCCMAP = {
5188: 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,
5189: 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,
5190: 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,
5191: 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,
5192: 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,
5193: 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,
5194: 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,
5195: 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,
5196: 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,
5197: 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,
5198: 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,
5199: 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,
5200: 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,
5201: 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,
5202: 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,
5203: 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,
5204: };
5205:
5206:
5207: public static final char[] MPU_CCCMAP = (
5208: "11111111111111111111111111111111" +
5209: "00000000000000000000000000000000" +
5210: "10100000101000001010000010100000" +
5211: "01011111010111110101111101011111" +
5212: "10101010101010101010101010101010" +
5213: "01010101010101010101010101010101" +
5214: "11110000111100001111000011110000" +
5215: "00001111000011110000111100001111" +
5216: "11001100110011001100110011001100" +
5217: "00110011001100110011001100110011" +
5218: "11111111000000001111111100000000" +
5219: "00000000111111110000000011111111" +
5220: "11001100001100111100110000110011" +
5221: "00110011110011000011001111001100" +
5222: "11000000001100001100000000110000" +
5223: "00111111110011110011111111001111").toCharArray ();
5224:
5225:
5226:
5227: public static final int MPU_CC_T = 0b11111111111111111111111111111111;
5228: public static final int MPU_CC_F = 0b00000000000000000000000000000000;
5229: public static final int MPU_CC_HI = 0b10100000101000001010000010100000;
5230: public static final int MPU_CC_LS = 0b01011111010111110101111101011111;
5231: public static final int MPU_CC_HS = 0b10101010101010101010101010101010;
5232: public static final int MPU_CC_LO = 0b01010101010101010101010101010101;
5233: public static final int MPU_CC_NE = 0b11110000111100001111000011110000;
5234: public static final int MPU_CC_EQ = 0b00001111000011110000111100001111;
5235: public static final int MPU_CC_VC = 0b11001100110011001100110011001100;
5236: public static final int MPU_CC_VS = 0b00110011001100110011001100110011;
5237: public static final int MPU_CC_PL = 0b11111111000000001111111100000000;
5238: public static final int MPU_CC_MI = 0b00000000111111110000000011111111;
5239: public static final int MPU_CC_GE = 0b11001100001100111100110000110011;
5240: public static final int MPU_CC_LT = 0b00110011110011000011001111001100;
5241: public static final int MPU_CC_GT = 0b11000000001100001100000000110000;
5242: public static final int MPU_CC_LE = 0b00111111110011110011111111001111;
5243:
5244:
5245:
5246:
5247:
5248:
5249:
5250:
5251:
5252:
5253:
5254:
5255:
5256:
5257:
5258:
5259:
5260:
5261:
5262:
5263:
5264:
5265:
5266:
5267:
5268:
5269:
5270:
5271:
5272:
5273:
5274:
5275:
5276:
5277:
5278:
5279:
5280:
5281:
5282:
5283:
5284:
5285:
5286:
5287:
5288:
5289:
5290:
5291:
5292: 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);
5293:
5294:
5295:
5296: public static final int[] MPU_BITREV_TABLE_0 = new int[2048];
5297: public static final int[] MPU_BITREV_TABLE_1 = new int[2048];
5298: public static final int[] MPU_BITREV_TABLE_2 = new int[2048];
5299: static {
5300: for (int i = 0; i < 2048; i++) {
5301: MPU_BITREV_TABLE_2[i] = (MPU_BITREV_TABLE_1[i] = (MPU_BITREV_TABLE_0[i] = Integer.reverse (i)) >>> 11) >>> 11;
5302: }
5303: }
5304:
5305:
5306:
5307: public static final int EA_DR = 0b000_000;
5308: public static final int EA_AR = 0b001_000;
5309: public static final int EA_MM = 0b010_000;
5310: public static final int EA_MP = 0b011_000;
5311: public static final int EA_MN = 0b100_000;
5312: public static final int EA_MW = 0b101_000;
5313: public static final int EA_MX = 0b110_000;
5314: public static final int EA_ZW = 0b111_000;
5315: public static final int EA_ZL = 0b111_001;
5316: public static final int EA_PW = 0b111_010;
5317: public static final int EA_PX = 0b111_011;
5318: public static final int EA_IM = 0b111_100;
5319: public static final int MMM_DR = EA_DR >> 3;
5320: public static final int MMM_AR = EA_AR >> 3;
5321: public static final int MMM_MM = EA_MM >> 3;
5322: public static final int MMM_MP = EA_MP >> 3;
5323: public static final int MMM_MN = EA_MN >> 3;
5324: public static final int MMM_MW = EA_MW >> 3;
5325: public static final int MMM_MX = EA_MX >> 3;
5326: public static final long EAM_DR = 0xff00000000000000L >>> EA_DR;
5327: public static final long EAM_AR = 0xff00000000000000L >>> EA_AR;
5328: public static final long EAM_MM = 0xff00000000000000L >>> EA_MM;
5329: public static final long EAM_MP = 0xff00000000000000L >>> EA_MP;
5330: public static final long EAM_MN = 0xff00000000000000L >>> EA_MN;
5331: public static final long EAM_MW = 0xff00000000000000L >>> EA_MW;
5332: public static final long EAM_MX = 0xff00000000000000L >>> EA_MX;
5333: public static final long EAM_ZW = 0x8000000000000000L >>> EA_ZW;
5334: public static final long EAM_ZL = 0x8000000000000000L >>> EA_ZL;
5335: public static final long EAM_PW = 0x8000000000000000L >>> EA_PW;
5336: public static final long EAM_PX = 0x8000000000000000L >>> EA_PX;
5337: public static final long EAM_IM = 0x8000000000000000L >>> EA_IM;
5338: 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;
5339: public static final long EAM_ALT = EAM_DR|EAM_AR|EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5340: 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;
5341: 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 ;
5342: public static final long EAM_DLT = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5343: public static final long EAM_DCN = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5344: public static final long EAM_DCL = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5345: 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;
5346: public static final long EAM_MEM = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5347: public static final long EAM_MLT = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5348: public static final long EAM_RDL = EAM_MM|EAM_MP |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5349: public static final long EAM_WTL = EAM_MM |EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5350: public static final long EAM_CNT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5351: public static final long EAM_CLT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5352:
5353:
5354:
5355:
5356:
5357:
5358:
5359:
5360:
5361:
5362:
5363: public static final int[] regRn = new int[16 + 1];
5364:
5365:
5366: public static int regPC;
5367: public static int regPC0;
5368:
5369:
5370: public static int regOC;
5371:
5372:
5373: public static int regSRT1;
5374: public static int regSRT0;
5375: public static int mpuTraceFlag;
5376: public static int regSRS;
5377: public static int regSRM;
5378: public static int regSRI;
5379:
5380:
5381: public static int regCCR;
5382:
5383:
5384:
5385:
5386:
5387:
5388:
5389:
5390:
5391:
5392:
5393:
5394:
5395:
5396:
5397:
5398:
5399:
5400:
5401:
5402: public static int mpuIMR;
5403:
5404:
5405:
5406:
5407:
5408:
5409: public static int mpuIRR;
5410: public static int mpuDIRR;
5411:
5412:
5413:
5414:
5415:
5416:
5417:
5418:
5419: public static int mpuISR;
5420:
5421:
5422: public static int mpuSFC;
5423: public static int mpuDFC;
5424: public static int mpuCACR;
5425:
5426:
5427:
5428:
5429:
5430: public static int mpuBUSCR;
5431: public static int mpuUSP;
5432: public static int mpuVBR;
5433: public static int mpuCAAR;
5434: public static int mpuMSP;
5435: public static int mpuISP;
5436:
5437:
5438:
5439: public static int mpuPCR;
5440:
5441:
5442:
5443: public static final int MPU_060_REV = 7;
5444:
5445:
5446:
5447: public static long mpuClockTime;
5448: public static long mpuClockLimit;
5449: public static double mpuClockMHz;
5450: public static double mpuCurrentMHz;
5451: public static int mpuCycleCount;
5452: public static long mpuCycleUnit;
5453: public static long mpuModifiedUnit;
5454: public static long dmaCycleUnit;
5455:
5456:
5457:
5458: public static TimerTask mpuTask;
5459:
5460:
5461: public static int mpuBootDevice;
5462: public static int mpuROMBootHandle;
5463: public static int mpuSavedBootDevice;
5464: public static int mpuSavedROMBootHandle;
5465:
5466:
5467: public static boolean mpuIgnoreAddressError;
5468:
5469:
5470: public static int mpuROMWaitCycles;
5471: public static int mpuRAMWaitCycles;
5472: public static boolean mpuCacheOn;
5473: public static final class WaitTime {
5474: public long ram;
5475: public long gvram;
5476: public long tvram;
5477: public long crtc;
5478: public long palet;
5479: public long vicon;
5480: public long dmac;
5481: public long mfp;
5482: public long rtc;
5483: public long prnport;
5484: public long sysport;
5485: public long opm;
5486: public long adpcm;
5487: public long fdc;
5488: public long fdd;
5489: public long hdc;
5490: public long scc;
5491: public long ppi;
5492: public long ioi;
5493: public long sprc;
5494: public long sram;
5495: public long rom;
5496: public long ramlong;
5497: public long romlong;
5498: }
5499: public static final WaitTime mpuNoWaitTime = new WaitTime ();
5500: public static final WaitTime dmaNoWaitTime = new WaitTime ();
5501: public static final WaitTime mpuWaitTime = new WaitTime ();
5502: public static final WaitTime dmaWaitTime = new WaitTime ();
5503: public static boolean busWaitCyclesRequest;
5504: public static boolean busWaitCycles;
5505: public static WaitTime busWaitTime;
5506:
5507:
5508: public static boolean mpuArbFreqOn;
5509: public static int mpuArbFreqMHz;
5510: public static SpinnerNumberModel mpuArbFreqModel;
5511: public static JSpinner mpuArbFreqSpinner;
5512: public static JRadioButtonMenuItem mpuArbFreqRadioButtonMenuItem;
5513:
5514:
5515: public static boolean mpuUtilOn;
5516: public static int mpuUtilRatio;
5517: public static SpinnerNumberModel mpuUtilModel;
5518: public static JSpinner mpuUtilSpinner;
5519: public static JRadioButtonMenuItem mpuUtilRadioButtonMenuItem;
5520:
5521:
5522: public static final int MPU_ADJUSTMENT_INTERVAL = 100;
5523: public static int mpuAdjustmentCounter;
5524: public static long mpuTotalNano;
5525: public static long mpuLastNano;
5526: public static double mpuCoreNano1;
5527: public static double mpuCoreNano2;
5528:
5529:
5530: public static JMenu mpuMenu;
5531: public static JMenuItem mpuResetMenuItem;
5532: public static JMenuItem mpuOpt1ResetMenuItem;
5533: public static JRadioButtonMenuItem mpuClock10MenuItem;
5534: public static JRadioButtonMenuItem mpuClock16MenuItem;
5535: public static JRadioButtonMenuItem mpuClock25MenuItem;
5536: public static JRadioButtonMenuItem mpuClock33MenuItem;
5537: public static JRadioButtonMenuItem mpuClock50MenuItem;
5538: public static JRadioButtonMenuItem mpuClock66MenuItem;
5539: public static JRadioButtonMenuItem mpuClock75MenuItem;
5540: public static JRadioButtonMenuItem mpuClock100MenuItem;
5541:
5542:
5543: public static ActionListener mpuDebugActionListener;
5544: public static ArrayList<AbstractButton> mpuButtonsRunning;
5545: public static ArrayList<AbstractButton> mpuButtonsStopped;
5546: public static ArrayList<JCheckBox> mpuOriIllegalCheckBoxList;
5547: public static ArrayList<JCheckBox> mpuStopOnErrorCheckBoxList;
5548: public static ArrayList<JCheckBox> mpuStopAtStartCheckBoxList;
5549:
5550: public static int mpuAdvanceCount;
5551: public static int mpuStepCount;
5552: public static boolean mpuContinue;
5553: public static int mpuUntilReturnSRS;
5554: public static int mpuUntilReturnRP;
5555: public static int mpuUntilReturnPC0;
5556: public static int mpuUntilReturnSP;
5557:
5558:
5559:
5560:
5561:
5562:
5563:
5564:
5565:
5566:
5567:
5568:
5569:
5570:
5571:
5572:
5573:
5574:
5575:
5576:
5577:
5578:
5579:
5580:
5581:
5582:
5583:
5584:
5585:
5586:
5587:
5588:
5589:
5590:
5591:
5592:
5593:
5594:
5595:
5596:
5597:
5598:
5599:
5600:
5601:
5602:
5603:
5604:
5605:
5606:
5607:
5608:
5609:
5610:
5611:
5612:
5613:
5614:
5615:
5616:
5617:
5618:
5619:
5620:
5621:
5622:
5623:
5624:
5625:
5626:
5627:
5628:
5629:
5630: public static final boolean MPU_SXMENU = false;
5631:
5632:
5633:
5634: public static void mpuInit () {
5635:
5636: mpuIgnoreAddressError = false;
5637:
5638:
5639:
5640: fpuInit ();
5641:
5642: mpuClockTime = 0L;
5643: mpuClockLimit = 0L;
5644: mpuCycleCount = 0;
5645:
5646: mpuTask = null;
5647:
5648: M68kException.m6eSignal = new M68kException ();
5649: M68kException.m6eNumber = 0;
5650: M68kException.m6eAddress = 0;
5651: M68kException.m6eDirection = MPU_WR_WRITE;
5652: M68kException.m6eSize = MPU_SS_BYTE;
5653:
5654: mpuBootDevice = -1;
5655: mpuROMBootHandle = -1;
5656: mpuSavedBootDevice = -1;
5657: mpuSavedROMBootHandle = -1;
5658:
5659:
5660:
5661:
5662:
5663:
5664:
5665:
5666:
5667:
5668:
5669:
5670:
5671:
5672:
5673: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
5674: mpuTotalNano = 0L;
5675: mpuLastNano = System.nanoTime ();
5676: mpuCoreNano1 = mpuCoreNano2 = 0.5 * 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
5677:
5678: mpuButtonsRunning = new ArrayList<AbstractButton> ();
5679: mpuButtonsStopped = new ArrayList<AbstractButton> ();
5680:
5681: mpuOriIllegalCheckBoxList = new ArrayList<JCheckBox> ();
5682: mpuStopOnErrorCheckBoxList = new ArrayList<JCheckBox> ();
5683: mpuStopAtStartCheckBoxList = new ArrayList<JCheckBox> ();
5684:
5685: mpuAdvanceCount = 0;
5686: mpuStepCount = 0;
5687: mpuContinue = false;
5688: mpuUntilReturnSRS = 0;
5689: mpuUntilReturnRP = 0;
5690: mpuUntilReturnPC0 = 0;
5691: mpuUntilReturnSP = 0;
5692:
5693:
5694: mpuDebugActionListener = new ActionListener () {
5695: @Override public void actionPerformed (ActionEvent ae) {
5696: Object source = ae.getSource ();
5697: switch (ae.getActionCommand ()) {
5698: case "Stop":
5699: if (RootPointerList.RTL_ON) {
5700: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
5701: RootPointerList.rtlCurrentUserTaskIsStoppable) {
5702: mpuStop (null);
5703: }
5704: } else {
5705: mpuStop (null);
5706: }
5707: break;
5708: case "Trace":
5709: mpuAdvance (1);
5710: break;
5711: case "Trace 10 times":
5712: mpuAdvance (10);
5713: break;
5714: case "Trace 100 times":
5715: mpuAdvance (100);
5716: break;
5717: case "Step":
5718: mpuStep (1);
5719: break;
5720: case "Step 10 times":
5721: mpuStep (10);
5722: break;
5723: case "Step 100 times":
5724: mpuStep (100);
5725: break;
5726: case "Step until return":
5727: mpuStepUntilReturn ();
5728: break;
5729: case "Run":
5730: mpuStart ();
5731: break;
5732:
5733: case "Consider ORI.B #$00,D0 as an illegal instruction" :
5734: if (DBG_ORI_BYTE_ZERO_D0) {
5735: dbgOriByteZeroD0 = ((JCheckBox) source).isSelected ();
5736: for (JCheckBox checkBox : mpuOriIllegalCheckBoxList) {
5737: if (checkBox.isSelected () != dbgOriByteZeroD0) {
5738: checkBox.setSelected (dbgOriByteZeroD0);
5739: }
5740: }
5741: }
5742: break;
5743: case "Stop on error":
5744: dbgStopOnError = ((JCheckBox) source).isSelected ();
5745: for (JCheckBox checkBox : mpuStopOnErrorCheckBoxList) {
5746: if (checkBox.isSelected () != dbgStopOnError) {
5747: checkBox.setSelected (dbgStopOnError);
5748: }
5749: }
5750: break;
5751: case "Stop at execution start position":
5752: dbgStopAtStart = ((JCheckBox) source).isSelected ();
5753: for (JCheckBox checkBox : mpuStopAtStartCheckBoxList) {
5754: if (checkBox.isSelected () != dbgStopAtStart) {
5755: checkBox.setSelected (dbgStopAtStart);
5756: }
5757: }
5758: break;
5759: }
5760: }
5761: };
5762:
5763: }
5764:
5765:
5766:
5767: public static JCheckBox mpuMakeOriIllegalCheckBox () {
5768: JCheckBox checkBox = Multilingual.mlnToolTipText (
5769: ComponentFactory.createIconCheckBox (
5770: DBG_ORI_BYTE_ZERO_D0 ? dbgOriByteZeroD0 : null,
5771: LnF.LNF_ORI_BYTE_ZERO_D0_IMAGE,
5772: LnF.LNF_ORI_BYTE_ZERO_D0_SELECTED_IMAGE,
5773: "Consider ORI.B #$00,D0 as an illegal instruction", mpuDebugActionListener),
5774: "ja", "ORI.B #$00,D0 を不当命令とみなす");
5775: mpuOriIllegalCheckBoxList.add (checkBox);
5776: return checkBox;
5777: }
5778:
5779:
5780:
5781: public static JCheckBox mpuMakeStopOnErrorCheckBox () {
5782: JCheckBox checkBox = Multilingual.mlnToolTipText (
5783: ComponentFactory.createIconCheckBox (
5784: dbgStopOnError,
5785: LnF.LNF_STOP_ON_ERROR_IMAGE,
5786: LnF.LNF_STOP_ON_ERROR_SELECTED_IMAGE,
5787: "Stop on error", mpuDebugActionListener),
5788: "ja", "エラーで停止する");
5789: mpuStopOnErrorCheckBoxList.add (checkBox);
5790: return checkBox;
5791: }
5792:
5793:
5794:
5795: public static JCheckBox mpuMakeStopAtStartCheckBox () {
5796: JCheckBox checkBox = Multilingual.mlnToolTipText (
5797: ComponentFactory.createIconCheckBox (
5798: dbgStopAtStart,
5799: LnF.LNF_STOP_AT_START_IMAGE,
5800: LnF.LNF_STOP_AT_START_SELECTED_IMAGE,
5801: "Stop at execution start position", mpuDebugActionListener),
5802: "ja", "実行開始位置で停止する");
5803: mpuStopAtStartCheckBoxList.add (checkBox);
5804: return checkBox;
5805: }
5806:
5807:
5808: public static void mpuMakeMenu () {
5809:
5810: ButtonGroup unitGroup = new ButtonGroup ();
5811: ActionListener listener = new ActionListener () {
5812: @Override public void actionPerformed (ActionEvent ae) {
5813: Object source = ae.getSource ();
5814: switch (ae.getActionCommand ()) {
5815: case "Reset":
5816: mpuReset (-1, -1);
5817: break;
5818: case "Hold down OPT.1 and reset":
5819: mpuReset (0, -1);
5820: break;
5821: case "Interrupt":
5822: sysInterrupt ();
5823: break;
5824: case "10MHz":
5825: mpuArbFreqOn = false;
5826: mpuUtilOn = false;
5827: mpuSetCurrentClock (10.0);
5828: break;
5829: case "16.7MHz":
5830: mpuArbFreqOn = false;
5831: mpuUtilOn = false;
5832: mpuSetCurrentClock (50.0 / 3.0);
5833: break;
5834: case "25MHz":
5835: mpuArbFreqOn = false;
5836: mpuUtilOn = false;
5837: mpuSetCurrentClock (25.0);
5838: break;
5839: case "33.3MHz":
5840: mpuArbFreqOn = false;
5841: mpuUtilOn = false;
5842: mpuSetCurrentClock (100.0 / 3.0);
5843: break;
5844: case "50MHz":
5845: mpuArbFreqOn = false;
5846: mpuUtilOn = false;
5847: mpuSetCurrentClock (50.0);
5848: break;
5849: case "66.7MHz":
5850: mpuArbFreqOn = false;
5851: mpuUtilOn = false;
5852: mpuSetCurrentClock (200.0 / 3.0);
5853: break;
5854: case "75MHz":
5855: mpuArbFreqOn = false;
5856: mpuUtilOn = false;
5857: mpuSetCurrentClock (75.0);
5858: break;
5859: case "100MHz":
5860: mpuArbFreqOn = false;
5861: mpuUtilOn = false;
5862: mpuSetCurrentClock (100.0);
5863: break;
5864: case "Arbitrary frequency":
5865: mpuArbFreqOn = true;
5866: mpuUtilOn = false;
5867: mpuSetCurrentClock ((double) mpuArbFreqMHz);
5868: break;
5869: case "Arbitrary load factor":
5870: mpuArbFreqOn = false;
5871: mpuUtilOn = true;
5872: break;
5873: case "FE function instruction":
5874: FEFunction.fpkOn = ((JCheckBoxMenuItem) source).isSelected ();
5875: break;
5876: case "Reject FLOATn.X":
5877: FEFunction.fpkRejectFloatOn = ((JCheckBoxMenuItem) source).isSelected ();
5878: break;
5879: case "Cut FC2 pin":
5880: busRequestCutFC2Pin = ((JCheckBoxMenuItem) source).isSelected ();
5881: break;
5882: case "Wait cycles":
5883: busWaitCyclesRequest = ((JCheckBoxMenuItem) source).isSelected ();
5884: break;
5885: case "Use IPLROM 1.6":
5886: ROM.romIPLROM16On = ((JCheckBoxMenuItem) source).isSelected ();
5887: break;
5888: case "Increase IPLROM to 256KB":
5889: ROM.romIPLROM256KOn = ((JCheckBoxMenuItem) source).isSelected ();
5890: break;
5891:
5892: case "Run / Stop":
5893: if (((JCheckBox) source).isSelected ()) {
5894: mpuStart ();
5895: } else {
5896: if (RootPointerList.RTL_ON) {
5897: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
5898: RootPointerList.rtlCurrentUserTaskIsStoppable) {
5899: mpuStop (null);
5900: }
5901: } else {
5902: mpuStop (null);
5903: }
5904: }
5905: pnlPanel.requestFocusInWindow ();
5906: break;
5907: }
5908: }
5909: };
5910: mpuMenu = ComponentFactory.createMenu (
5911: "MPU", 'M',
5912: mpuResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset", 'R', MNB_MODIFIERS, listener), "ja", "リセット"),
5913: mpuOpt1ResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Hold down OPT.1 and reset", 'O', MNB_MODIFIERS, listener), "ja", "OPT.1 を押しながらリセット"),
5914: Multilingual.mlnText (ComponentFactory.createMenuItem ("Interrupt", listener), "ja", "インタラプト"),
5915: ComponentFactory.createHorizontalSeparator (),
5916: mdlMenu,
5917: ComponentFactory.createHorizontalSeparator (),
5918: mpuClock10MenuItem = ComponentFactory.createRadioButtonMenuItem (
5919: unitGroup,
5920: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 10.0,
5921: "10MHz",
5922: listener),
5923: mpuClock16MenuItem = ComponentFactory.createRadioButtonMenuItem (
5924: unitGroup,
5925: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0 / 3.0,
5926: "16.7MHz",
5927: listener),
5928: mpuClock25MenuItem = ComponentFactory.createRadioButtonMenuItem (
5929: unitGroup,
5930: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 25.0,
5931: "25MHz",
5932: listener),
5933: mpuClock33MenuItem = ComponentFactory.createRadioButtonMenuItem (
5934: unitGroup,
5935: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0 / 3.0,
5936: "33.3MHz",
5937: listener),
5938: mpuClock50MenuItem = ComponentFactory.createRadioButtonMenuItem (
5939: unitGroup,
5940: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0,
5941: "50MHz",
5942: listener),
5943: mpuClock66MenuItem = ComponentFactory.createRadioButtonMenuItem (
5944: unitGroup,
5945: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 200.0 / 3.0,
5946: "66.7MHz",
5947: listener),
5948: mpuClock75MenuItem = ComponentFactory.createRadioButtonMenuItem (
5949: unitGroup,
5950: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 75.0,
5951: "75MHz",
5952: listener),
5953: mpuClock100MenuItem = ComponentFactory.createRadioButtonMenuItem (
5954: unitGroup,
5955: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0,
5956: "100MHz",
5957: listener),
5958: mpuArbFreqRadioButtonMenuItem = Multilingual.mlnText (
5959: ComponentFactory.createRadioButtonMenuItem (
5960: unitGroup,
5961: mpuArbFreqOn,
5962: "Arbitrary frequency",
5963: listener),
5964: "ja", "任意の周波数"),
5965: ComponentFactory.createHorizontalBox (
5966: Box.createHorizontalStrut (20),
5967: mpuArbFreqSpinner = ComponentFactory.createNumberSpinner (
5968: mpuArbFreqModel = new SpinnerNumberModel (mpuArbFreqMHz, 1, 1000, 1),
5969: 4,
5970: new ChangeListener () {
5971: @Override public void stateChanged (ChangeEvent ce) {
5972:
5973: mpuArbFreqMHz = mpuArbFreqModel.getNumber ().intValue ();
5974: if (mpuArbFreqOn) {
5975: mpuSetCurrentClock ((double) mpuArbFreqMHz);
5976: }
5977: }
5978: }
5979: ),
5980: ComponentFactory.createLabel ("MHz"),
5981: Box.createHorizontalGlue ()
5982: ),
5983: mpuUtilRadioButtonMenuItem = Multilingual.mlnText (
5984: ComponentFactory.createRadioButtonMenuItem (
5985: unitGroup,
5986: mpuUtilOn,
5987: "Arbitrary load factor",
5988: listener),
5989: "ja", "任意の負荷率"),
5990: ComponentFactory.createHorizontalBox (
5991: Box.createHorizontalStrut (20),
5992: mpuUtilSpinner = ComponentFactory.createNumberSpinner (
5993: mpuUtilModel = new SpinnerNumberModel (mpuUtilRatio, 1, 100, 1),
5994: 4,
5995: new ChangeListener () {
5996: @Override public void stateChanged (ChangeEvent ce) {
5997:
5998: mpuUtilRatio = mpuUtilModel.getNumber ().intValue ();
5999: }
6000: }
6001: ),
6002: ComponentFactory.createLabel ("%"),
6003: Box.createHorizontalGlue ()
6004: ),
6005: ComponentFactory.createHorizontalSeparator (),
6006:
6007: coproFPUMenu,
6008:
6009: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkOn, "FE function instruction", listener), "ja", "FE ファンクション命令"),
6010: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkRejectFloatOn, "Reject FLOATn.X", listener), "ja", "FLOATn.X を組み込まない"),
6011: ComponentFactory.createHorizontalSeparator (),
6012: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busRequestCutFC2Pin, "Cut FC2 pin", listener), "ja", "FC2 ピンをカットする"),
6013: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busWaitCyclesRequest, "Wait cycles", listener), "ja", "ウェイトサイクル"),
6014: ComponentFactory.createHorizontalSeparator (),
6015: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM16On, "Use IPLROM 1.6", listener), "ja", "IPLROM 1.6 を使う"),
6016: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM256KOn, "Increase IPLROM to 256KB", listener), "ja", "IPLROM を 256KB に増やす")
6017: );
6018: }
6019:
6020:
6021: public static void mpuSetCurrentClock (double clock) {
6022: specifiedClock = clock;
6023: if (currentIsSecond) {
6024: specifiedSecondClock = clock;
6025: } else {
6026: specifiedFirstClock = clock;
6027: }
6028: if (!mpuArbFreqOn && !mpuUtilOn) {
6029: if (specifiedClock == 10.0) {
6030: mpuClock10MenuItem.setSelected (true);
6031: } else if (specifiedClock == 50.0 / 3.0) {
6032: mpuClock16MenuItem.setSelected (true);
6033: } else if (specifiedClock == 25.0) {
6034: mpuClock25MenuItem.setSelected (true);
6035: } else if (specifiedClock == 100.0 / 3.0) {
6036: mpuClock33MenuItem.setSelected (true);
6037: } else if (specifiedClock == 50.0) {
6038: mpuClock50MenuItem.setSelected (true);
6039: } else if (specifiedClock == 200.0 / 3.0) {
6040: mpuClock66MenuItem.setSelected (true);
6041: } else if (specifiedClock == 75.0) {
6042: mpuClock75MenuItem.setSelected (true);
6043: } else if (specifiedClock == 100.0) {
6044: mpuClock100MenuItem.setSelected (true);
6045: }
6046: }
6047: mpuClockMHz = specifiedClock;
6048: mpuSetClockMHz (mpuClockMHz);
6049: }
6050:
6051:
6052:
6053:
6054:
6055:
6056:
6057:
6058:
6059:
6060:
6061: public static void mpuSetClockMHz (double mhz) {
6062: mhz = Math.max (1.0, Math.min (1000.0, mhz));
6063: double lastMHz = mpuCurrentMHz;
6064: mpuCurrentMHz = mhz;
6065: mpuCycleUnit = (long) (((double) TMR_FREQ / 1000000.0) / mhz + 0.5);
6066:
6067: mpuModifiedUnit = (currentMPU == Model.MPU_MC68EC030 ||
6068: currentMPU == Model.MPU_MC68030 ?
6069: (long) (((double) TMR_FREQ * 3.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6070: currentMPU == Model.MPU_MC68LC040 ||
6071: currentMPU == Model.MPU_MC68040 ?
6072: (long) (((double) TMR_FREQ * 2.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6073: mpuCycleUnit);
6074: if (lastMHz != mhz) {
6075: mpuSetWait ();
6076: }
6077: }
6078:
6079:
6080:
6081:
6082:
6083:
6084:
6085:
6086:
6087:
6088:
6089:
6090:
6091:
6092:
6093:
6094:
6095:
6096:
6097:
6098:
6099:
6100:
6101:
6102:
6103:
6104:
6105:
6106:
6107:
6108:
6109:
6110:
6111:
6112:
6113:
6114:
6115:
6116:
6117:
6118:
6119:
6120:
6121:
6122:
6123:
6124:
6125:
6126:
6127:
6128:
6129:
6130:
6131:
6132:
6133:
6134:
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: public static void mpuSetWait () {
6160:
6161: if (currentMPU <= Model.MPU_MC68010) {
6162: mpuWaitTime.ram = mpuCycleUnit >> 3;
6163: mpuWaitTime.vicon = (long) (mpuCycleUnit * 0.6);
6164: mpuWaitTime.crtc =
6165: mpuWaitTime.prnport =
6166: mpuWaitTime.sysport =
6167: mpuWaitTime.sprc =
6168: mpuWaitTime.sram =
6169: mpuWaitTime.rom = mpuCycleUnit;
6170: mpuWaitTime.gvram = (long) (mpuCycleUnit * 1.1);
6171: mpuWaitTime.rtc =
6172: mpuWaitTime.opm =
6173: mpuWaitTime.adpcm =
6174: mpuWaitTime.fdc =
6175: mpuWaitTime.fdd =
6176: mpuWaitTime.hdc =
6177: mpuWaitTime.ppi =
6178: mpuWaitTime.ioi = (long) (mpuCycleUnit * 1.7);
6179: mpuWaitTime.tvram = mpuCycleUnit * 2;
6180: mpuWaitTime.palet = (long) (mpuCycleUnit * 2.6);
6181: mpuWaitTime.mfp = (long) (mpuCycleUnit * 4.3);
6182: mpuWaitTime.scc = mpuCycleUnit * 6;
6183: mpuWaitTime.dmac = mpuCycleUnit * 15;
6184: mpuWaitTime.ramlong = mpuWaitTime.ram << 1;
6185: mpuWaitTime.romlong = mpuWaitTime.rom << 1;
6186: } else if (currentMPU <= Model.MPU_MC68030) {
6187: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6188: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6189: mpuWaitTime.sram = mpuCycleUnit * 2;
6190: mpuWaitTime.prnport =
6191: mpuWaitTime.sysport = mpuCycleUnit * 4;
6192: mpuWaitTime.gvram =
6193: mpuWaitTime.crtc =
6194: mpuWaitTime.vicon =
6195: mpuWaitTime.sprc = mpuCycleUnit * 6;
6196: mpuWaitTime.tvram = mpuCycleUnit * 7;
6197: mpuWaitTime.palet = mpuCycleUnit * 11;
6198: mpuWaitTime.opm =
6199: mpuWaitTime.adpcm =
6200: mpuWaitTime.fdc =
6201: mpuWaitTime.fdd =
6202: mpuWaitTime.hdc =
6203: mpuWaitTime.ppi =
6204: mpuWaitTime.ioi = mpuCycleUnit * 15;
6205: mpuWaitTime.mfp = mpuCycleUnit * 19;
6206: mpuWaitTime.rtc = mpuCycleUnit * 28;
6207: mpuWaitTime.dmac = mpuCycleUnit * 34;
6208: mpuWaitTime.scc = mpuCycleUnit * 38;
6209: mpuWaitTime.ramlong = mpuWaitTime.ram;
6210: mpuWaitTime.romlong = mpuWaitTime.rom;
6211: } else {
6212: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6213: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6214: mpuWaitTime.sram = mpuCycleUnit * 13;
6215: mpuWaitTime.prnport =
6216: mpuWaitTime.sysport = mpuCycleUnit * 17;
6217: mpuWaitTime.gvram =
6218: mpuWaitTime.crtc =
6219: mpuWaitTime.vicon =
6220: mpuWaitTime.sprc = mpuCycleUnit * 21;
6221: mpuWaitTime.tvram = mpuCycleUnit * 22;
6222: mpuWaitTime.palet = mpuCycleUnit * 33;
6223: mpuWaitTime.opm =
6224: mpuWaitTime.adpcm =
6225: mpuWaitTime.fdc =
6226: mpuWaitTime.fdd =
6227: mpuWaitTime.hdc =
6228: mpuWaitTime.ppi =
6229: mpuWaitTime.ioi = mpuCycleUnit * 37;
6230: mpuWaitTime.mfp = mpuCycleUnit * 47;
6231: mpuWaitTime.dmac = mpuCycleUnit * 73;
6232: mpuWaitTime.rtc = mpuCycleUnit * 77;
6233: mpuWaitTime.scc = mpuCycleUnit * 97;
6234: mpuWaitTime.ramlong = mpuWaitTime.ram;
6235: mpuWaitTime.romlong = mpuWaitTime.rom;
6236: }
6237: if (true) {
6238: mpuNoWaitTime.sram = mpuWaitTime.sram;
6239: mpuNoWaitTime.rom = mpuWaitTime.rom;
6240: mpuNoWaitTime.romlong = mpuWaitTime.romlong;
6241: }
6242:
6243: dmaWaitTime.ram = dmaCycleUnit >> 3;
6244: dmaWaitTime.sram = 0;
6245: dmaWaitTime.rom = 0;
6246: dmaWaitTime.gvram =
6247: dmaWaitTime.crtc =
6248: dmaWaitTime.vicon =
6249: dmaWaitTime.prnport =
6250: dmaWaitTime.sysport =
6251: dmaWaitTime.sprc = dmaCycleUnit;
6252: dmaWaitTime.tvram =
6253: dmaWaitTime.rtc =
6254: dmaWaitTime.opm =
6255: dmaWaitTime.adpcm =
6256: dmaWaitTime.fdc =
6257: dmaWaitTime.fdd =
6258: dmaWaitTime.hdc =
6259: dmaWaitTime.ppi =
6260: dmaWaitTime.ioi = dmaCycleUnit * 2;
6261: dmaWaitTime.palet = dmaCycleUnit * 3;
6262: dmaWaitTime.mfp = dmaCycleUnit * 4;
6263: dmaWaitTime.scc = dmaCycleUnit * 6;
6264: dmaWaitTime.dmac = dmaCycleUnit * 15;
6265: dmaWaitTime.ramlong = dmaWaitTime.ram << 1;
6266: dmaWaitTime.romlong = dmaWaitTime.rom << 1;
6267: }
6268:
6269:
6270:
6271:
6272:
6273: public static void mpuReset (int device, int romHandle) {
6274:
6275: mpuBootDevice = device;
6276: mpuROMBootHandle = romHandle;
6277:
6278:
6279:
6280:
6281:
6282:
6283:
6284:
6285:
6286:
6287:
6288:
6289: if (mpuBootDevice == -1) {
6290: if (mpuSavedBootDevice != -1) {
6291: mpuBootDevice = mpuSavedBootDevice;
6292: mpuROMBootHandle = mpuSavedROMBootHandle;
6293: mpuSavedBootDevice = -1;
6294: mpuSavedROMBootHandle = -1;
6295: }
6296: } else {
6297: if (mpuSavedBootDevice == -1) {
6298: mpuSavedBootDevice = MainMemory.mmrRwz (0x00ed0018);
6299: mpuSavedROMBootHandle = MainMemory.mmrRls (0x00ed000c);
6300: }
6301: }
6302:
6303:
6304: if (mpu010) {
6305: if (specifiedFirstMPU == Model.MPU_MC68000) {
6306: specifiedFirstMPU = Model.MPU_MC68010;
6307: }
6308: if (specifiedSecondMPU == Model.MPU_MC68000) {
6309: specifiedSecondMPU = Model.MPU_MC68010;
6310: }
6311: } else {
6312: if (specifiedFirstMPU == Model.MPU_MC68010) {
6313: specifiedFirstMPU = Model.MPU_MC68000;
6314: }
6315: if (specifiedSecondMPU == Model.MPU_MC68010) {
6316: specifiedSecondMPU = Model.MPU_MC68000;
6317: }
6318: }
6319:
6320:
6321: specifiedIsSecond = false;
6322: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
6323: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
6324:
6325: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
6326: MC68EC030.m30DivZeroVFlag = false;
6327: }
6328:
6329: if (mpuTask != null) {
6330: mpuClockLimit = 0L;
6331: System.out.println (Multilingual.mlnJapanese ?
6332: "MPU を停止します" :
6333: "MPU stops");
6334: mpuTask.cancel ();
6335: mpuTask = null;
6336: }
6337:
6338: tmrTimer.schedule (new TimerTask () {
6339: @Override public void run () {
6340:
6341:
6342:
6343: currentModel = specifiedModel;
6344: currentAccelerator = specifiedAccelerator;
6345: frmUpdateTitle ();
6346:
6347: currentIsSecond = specifiedIsSecond;
6348: currentFirstMPU = specifiedFirstMPU;
6349: currentSecondMPU = specifiedSecondMPU;
6350: currentMPU = specifiedMPU;
6351:
6352: mpuSetCurrentClock (specifiedClock);
6353:
6354: currentCopro0 = specifiedCopro0;
6355: currentCopro1 = specifiedCopro1;
6356: currentCopro2 = specifiedCopro2;
6357: currentOnchipFPU = specifiedOnchipFPU;
6358:
6359:
6360: if (currentMPU < Model.MPU_MC68020) {
6361: if (busHimem68000) {
6362: busRequestExMemoryStart = 0x10000000;
6363: busRequestExMemorySize = busLocalMemorySize;
6364: busRequestExMemoryArray = busLocalMemoryArray;
6365: } else {
6366: busRequestExMemoryStart = 0x10000000;
6367: busRequestExMemorySize = 0 << 20;
6368: busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
6369: }
6370: } else if (currentMPU < Model.MPU_MC68LC040) {
6371: if (busHighMemory060turboOn) {
6372: busRequestExMemoryStart = 0x10000000;
6373: busRequestExMemorySize = busLocalMemorySize;
6374: busRequestExMemoryArray = busLocalMemoryArray;
6375: } else {
6376: busRequestExMemoryStart = 0x01000000;
6377: busRequestExMemorySize = busHighMemorySize;
6378: busRequestExMemoryArray = busHighMemoryArray;
6379: }
6380: } else {
6381: busRequestExMemoryStart = 0x10000000;
6382: busRequestExMemorySize = busLocalMemorySize;
6383: busRequestExMemoryArray = busLocalMemoryArray;
6384: }
6385: busUpdateMemoryMap ();
6386:
6387:
6388: ROM.romReset ();
6389:
6390: RegisterList.drpSetMPU ();
6391:
6392: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
6393: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6394: MC68060.mmuReset ();
6395:
6396:
6397: if (Model.MPU_MC68020 <= currentMPU) {
6398: if ((7 & currentCopro0) == 1) {
6399: fpuMotherboardCoprocessor.epbSetMC68881 ();
6400: } else if ((7 & currentCopro0) == 2) {
6401: fpuMotherboardCoprocessor.epbSetMC68882 ();
6402: } else {
6403: fpuMotherboardCoprocessor.epbSetFullSpec ();
6404: }
6405: if ((8 & currentCopro0) == 0) {
6406: fpuMotherboardCoprocessor.epbSetExtended ();
6407: } else {
6408: fpuMotherboardCoprocessor.epbSetTriple ();
6409: }
6410: }
6411:
6412: if ((7 & currentCopro1) == 1) {
6413: fpuCoproboard1.epbSetMC68881 ();
6414: } else if ((7 & currentCopro1) == 2) {
6415: fpuCoproboard1.epbSetMC68882 ();
6416: } else {
6417: fpuCoproboard1.epbSetFullSpec ();
6418: }
6419: if ((8 & currentCopro1) == 0) {
6420: fpuCoproboard1.epbSetExtended ();
6421: } else {
6422: fpuCoproboard1.epbSetTriple ();
6423: }
6424:
6425: if ((7 & currentCopro2) == 1) {
6426: fpuCoproboard2.epbSetMC68881 ();
6427: } else if ((7 & currentCopro2) == 2) {
6428: fpuCoproboard2.epbSetMC68882 ();
6429: } else {
6430: fpuCoproboard2.epbSetFullSpec ();
6431: }
6432: if ((8 & currentCopro2) == 0) {
6433: fpuCoproboard2.epbSetExtended ();
6434: } else {
6435: fpuCoproboard2.epbSetTriple ();
6436: }
6437:
6438: if (Model.MPU_MC68040 <= currentMPU) {
6439: if ((7 & currentOnchipFPU) == 6) {
6440: fpuOnChipFPU.epbSetMC68060 ();
6441: } else {
6442: fpuOnChipFPU.epbSetFullSpec ();
6443: }
6444: if ((8 & currentOnchipFPU) == 0) {
6445: fpuOnChipFPU.epbSetExtended ();
6446: } else {
6447: fpuOnChipFPU.epbSetTriple ();
6448: }
6449: }
6450:
6451: if (!currentModel.isX68030 ()) {
6452: dmaCycleUnit = TMR_FREQ / 10000000L;
6453: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6454: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6455: mpuROMWaitCycles = 1;
6456: mpuRAMWaitCycles = 0;
6457: } else {
6458: dmaCycleUnit = TMR_FREQ / 12500000L;
6459: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6460: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6461: mpuROMWaitCycles = 0;
6462: mpuRAMWaitCycles = 0;
6463: }
6464:
6465: busWaitCycles = busWaitCyclesRequest;
6466: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
6467:
6468: HD63450.dmaReadCycles = (currentModel.isPRO () ? 6 :
6469: currentModel.isCompact () ? 4 :
6470: 5);
6471: HD63450.dmaWriteCycles = (currentModel.isPRO () ? 6 :
6472: 5);
6473:
6474: if (currentMPU < Model.MPU_MC68020) {
6475:
6476: mpuIgnoreAddressError = false;
6477:
6478: mpuCacheOn = false;
6479:
6480: } else if (currentMPU < Model.MPU_MC68040) {
6481:
6482: mpuIgnoreAddressError = true;
6483: fpuBox = fpuMotherboardCoprocessor;
6484: fpuBox.epbReset ();
6485: fpuFPn = fpuBox.epbFPn;
6486:
6487: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
6488:
6489: } else {
6490:
6491: mpuIgnoreAddressError = true;
6492: fpuBox = fpuOnChipFPU;
6493: fpuBox.epbReset ();
6494: fpuFPn = fpuBox.epbFPn;
6495:
6496: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6497: mpuCacheOn = (mpuCACR & 0x80008000) != 0;
6498:
6499: }
6500:
6501: mpuSetWait ();
6502:
6503:
6504: regSRT1 = regSRT0 = 0;
6505: regSRS = REG_SR_S;
6506: regSRM = 0;
6507: regSRI = REG_SR_I;
6508: regCCR = 0;
6509: Arrays.fill (regRn, 0);
6510:
6511: regRn[15] = MainMemory.mmrRls (0x00ff0000);
6512: regPC = MainMemory.mmrRls (0x00ff0004);
6513:
6514: MainMemory.mmrReset ();
6515:
6516: busReset ();
6517: if (InstructionBreakPoint.IBP_ON) {
6518: InstructionBreakPoint.ibpOp1MemoryMap = InstructionBreakPoint.ibpOp1SuperMap;
6519: InstructionBreakPoint.ibpReset ();
6520: }
6521: if (BranchLog.BLG_ON) {
6522: BranchLog.blgReset ();
6523: }
6524:
6525: mpuIMR = 0;
6526: mpuIRR = 0;
6527: if (MC68901.MFP_DELAYED_INTERRUPT) {
6528: mpuDIRR = 0;
6529: }
6530: mpuISR = 0;
6531:
6532:
6533: mpuStart ();
6534: }
6535: }, TMR_DELAY);
6536:
6537: }
6538:
6539:
6540:
6541: public static void mpuStopAndStart () {
6542: if (mpuTask == null) {
6543: mpuStart ();
6544: } else {
6545: if (RootPointerList.RTL_ON) {
6546: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6547: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6548: mpuStop (null);
6549: }
6550: } else {
6551: mpuStop (null);
6552: }
6553: }
6554: }
6555:
6556:
6557:
6558:
6559:
6560: public static void mpuStart () {
6561: if (mpuTask != null) {
6562: mpuClockLimit = 0L;
6563: System.out.println (Multilingual.mlnJapanese ?
6564: "MPU を停止します" :
6565: "MPU stops");
6566: mpuTask.cancel ();
6567: mpuTask = null;
6568: }
6569:
6570: for (AbstractButton button : mpuButtonsStopped) {
6571: button.setEnabled (false);
6572: }
6573: DisassembleList.ddpStoppedBy = null;
6574: System.out.println (Model.mpuNameOf (currentMPU) + (Multilingual.mlnJapanese ? " を起動します" : " starts up"));
6575: mpuTask = new TimerTask () {
6576: @Override public void run () {
6577: mpuContinue = true;
6578: mpuClockLimit = mpuClockTime + TMR_FREQ * TMR_INTERVAL / 1000;
6579: mpuExecuteCore ();
6580: }
6581: };
6582: tmrTimer.scheduleAtFixedRate (mpuTask, TMR_DELAY, TMR_INTERVAL);
6583:
6584: for (AbstractButton button : mpuButtonsRunning) {
6585: button.setEnabled (true);
6586: }
6587: }
6588:
6589:
6590:
6591: public static void mpuExecuteCore () {
6592:
6593: long nanoStart = System.nanoTime ();
6594:
6595: busSuper (RP5C15.rtcFirst, 0x00e8a000, 0x00e8c000);
6596:
6597:
6598: if (currentMPU < Model.MPU_MC68010) {
6599: MC68000.mpuCore ();
6600: } else if (currentMPU < Model.MPU_MC68020) {
6601: MC68010.mpuCore ();
6602: } else if (currentMPU < Model.MPU_MC68LC040) {
6603: MC68EC030.mpuCore ();
6604: } else {
6605: MC68060.mpuCore ();
6606: }
6607:
6608: if (dbgVisibleMask != 0) {
6609: dbgUpdate ();
6610: }
6611:
6612: long nanoEnd = System.nanoTime ();
6613: mpuTotalNano += nanoEnd - nanoStart;
6614: if (--mpuAdjustmentCounter == 0) {
6615:
6616: final double expectedNano = 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
6617:
6618: double coreNano0 = (double) mpuTotalNano;
6619: mpuTotalNano = 0L;
6620: double coreNanoA = (coreNano0 * 2.0 + mpuCoreNano1 + mpuCoreNano2) * 0.25;
6621: mpuCoreNano2 = mpuCoreNano1;
6622: mpuCoreNano1 = coreNano0;
6623:
6624:
6625:
6626: double actualPercent = Math.max (1.0, 100.0 * coreNanoA / expectedNano);
6627:
6628: double maxPercent = SoundSource.sndPlayOn ? 90.0 : 100.0;
6629:
6630:
6631:
6632:
6633: if (mpuUtilOn) {
6634:
6635: double targetPercent = Math.min (maxPercent, (double) mpuUtilRatio);
6636: mpuSetClockMHz ((1.2 - 0.2 * actualPercent / targetPercent) * mpuCurrentMHz);
6637: } else {
6638: mpuSetClockMHz (Math.min (maxPercent / actualPercent,
6639: 1.2 - 0.2 * mpuCurrentMHz / mpuClockMHz) * mpuCurrentMHz);
6640: }
6641: Indicator.indUpdate (actualPercent);
6642: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
6643: }
6644: }
6645:
6646:
6647:
6648:
6649: public static void mpuStop (String message) {
6650:
6651: mpuAdvanceCount = 0;
6652: mpuStepCount = 0;
6653: mpuContinue = false;
6654: mpuStop1 (message);
6655: }
6656: public static void mpuStop1 (String message) {
6657: if (mpuTask == null) {
6658: return;
6659: }
6660: DisassembleList.ddpStoppedBy = message;
6661: mpuClockLimit = 0L;
6662: System.out.println (Multilingual.mlnJapanese ?
6663: "MPU を停止します" :
6664: "MPU stops");
6665: mpuTask.cancel ();
6666: mpuTask = null;
6667:
6668: if (mpuStepCount != 0 && mpuContinue) {
6669: if (mpuStepCount == -1 || --mpuStepCount != 0) {
6670: mpuStep (mpuStepCount);
6671: return;
6672: }
6673: }
6674: mpuAdvanceCount = 0;
6675: mpuStepCount = 0;
6676: mpuContinue = false;
6677:
6678: for (AbstractButton button : mpuButtonsRunning) {
6679: button.setEnabled (false);
6680: }
6681: tmrTimer.schedule (new TimerTask () {
6682: @Override public void run () {
6683: mpuUpdateWindow ();
6684: }
6685: }, TMR_DELAY);
6686: }
6687:
6688:
6689:
6690:
6691:
6692:
6693: public static void mpuAdvance (int n) {
6694: if (mpuTask != null) {
6695: return;
6696: }
6697: mpuAdvanceCount = n;
6698: DisassembleList.ddpStoppedBy = null;
6699: mpuTask = new TimerTask () {
6700: @Override public void run () {
6701: mpuContinue = true;
6702: do {
6703: mpuClockLimit = mpuClockTime + 1L;
6704: mpuExecuteCore ();
6705: } while (mpuContinue && --mpuAdvanceCount != 0);
6706: mpuClockLimit = 0L;
6707: if (mpuTask != null) {
6708: mpuTask.cancel ();
6709: mpuTask = null;
6710: }
6711: if (mpuStepCount != 0 && mpuContinue) {
6712: if (mpuStepCount == -1 || --mpuStepCount != 0) {
6713: mpuStep (mpuStepCount);
6714: return;
6715: }
6716: }
6717: mpuAdvanceCount = 0;
6718: mpuStepCount = 0;
6719: mpuContinue = false;
6720: mpuUpdateWindow ();
6721: }
6722: };
6723: tmrTimer.schedule (mpuTask, TMR_DELAY);
6724: }
6725:
6726:
6727:
6728:
6729:
6730:
6731: public static void mpuStep (int n) {
6732: if (mpuTask != null) {
6733: return;
6734: }
6735: mpuStepCount = n;
6736: Disassembler.disDisassemble (new StringBuilder (), regPC, regSRS);
6737: if ((Disassembler.disStatus & (Disassembler.DIS_ALWAYS_BRANCH | Disassembler.DIS_SOMETIMES_BRANCH)) != 0) {
6738: if (mpuStepCount == -1 &&
6739: (Disassembler.disOC == 0x4e73 ||
6740: Disassembler.disOC == 0x4e74 ||
6741: Disassembler.disOC == 0x4e75 ||
6742: Disassembler.disOC == 0x4e77) &&
6743: mpuUntilReturnSRS == regSRS &&
6744: (currentMPU < Model.MPU_MC68LC040 ||
6745: mpuUntilReturnRP == (regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP)) &&
6746: mpuUntilReturnPC0 != regPC0 &&
6747: Integer.compareUnsigned (mpuUntilReturnSP, regRn[15]) <= 0) {
6748: mpuAdvanceCount = 0;
6749: mpuStepCount = 0;
6750: mpuContinue = false;
6751: mpuUpdateWindow ();
6752: return;
6753: }
6754: mpuAdvance (1);
6755: } else {
6756: if (InstructionBreakPoint.IBP_ON) {
6757: InstructionBreakPoint.ibpInstant (Disassembler.disPC, DisassembleList.ddpSupervisorMode);
6758: mpuStart ();
6759: }
6760: }
6761: }
6762:
6763:
6764:
6765:
6766:
6767:
6768:
6769:
6770:
6771:
6772:
6773: public static void mpuStepUntilReturn () {
6774: if (mpuTask != null) {
6775: return;
6776: }
6777: mpuUntilReturnSRS = regSRS;
6778: mpuUntilReturnRP = regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP;
6779: mpuUntilReturnPC0 = regPC0;
6780: mpuUntilReturnSP = regRn[15];
6781: mpuStep (-1);
6782: }
6783:
6784:
6785:
6786: public static void mpuUpdateWindow () {
6787: if (dbgVisibleMask != 0) {
6788: if ((dbgVisibleMask & DBG_DDP_VISIBLE_MASK) != 0) {
6789: DisassembleList.ddpBacktraceRecord = -1L;
6790: DisassembleList.ddpUpdate (-1, -1, false);
6791: }
6792: if (BranchLog.BLG_ON) {
6793: if ((dbgVisibleMask & DBG_BLG_VISIBLE_MASK) != 0) {
6794: BranchLog.blgUpdate (BranchLog.BLG_SELECT_NEWEST);
6795: }
6796: }
6797: if (ProgramFlowVisualizer.PFV_ON) {
6798: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
6799: ProgramFlowVisualizer.pfvUpdate ();
6800: }
6801: }
6802: if (RasterBreakPoint.RBP_ON) {
6803: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
6804: RasterBreakPoint.rbpUpdateFrame ();
6805: }
6806: }
6807: if (ScreenModeTest.SMT_ON) {
6808: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
6809: ScreenModeTest.smtUpdateFrame ();
6810: }
6811: }
6812: if (RootPointerList.RTL_ON) {
6813: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
6814: RootPointerList.rtlUpdateFrame ();
6815: }
6816: }
6817: if (SpritePatternViewer.SPV_ON) {
6818: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
6819: SpritePatternViewer.spvUpdateFrame ();
6820: }
6821: }
6822: if (PaletteViewer.PLV_ON) {
6823: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
6824: PaletteViewer.plvUpdateFrame ();
6825: }
6826: }
6827: if (ATCMonitor.ACM_ON) {
6828: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
6829: ATCMonitor.acmUpdateFrame ();
6830: }
6831: }
6832: }
6833:
6834: if (DebugConsole.dgtRequestRegs != 0) {
6835: if ((DebugConsole.dgtRequestRegs & 1) != 0) {
6836: ExpressionEvaluator.ElementType.ETY_COMMAND_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
6837: }
6838: if ((DebugConsole.dgtRequestRegs & 2) != 0) {
6839: ExpressionEvaluator.ElementType.ETY_COMMAND_FLOAT_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
6840: }
6841: if ((DebugConsole.dgtRequestRegs & 4) != 0) {
6842: DebugConsole.dgtPrintPrompt ();
6843: }
6844: DebugConsole.dgtRequestRegs = 0;
6845: }
6846:
6847: for (AbstractButton button : mpuButtonsRunning) {
6848: button.setEnabled (false);
6849: }
6850:
6851: for (AbstractButton button : mpuButtonsStopped) {
6852: button.setEnabled (true);
6853: }
6854: }
6855:
6856:
6857:
6858: public static JButton mpuMakeBreakButton () {
6859: return mpuAddButtonRunning (
6860: Multilingual.mlnToolTipText (
6861: ComponentFactory.createImageButton (
6862: LnF.LNF_BREAK_IMAGE,
6863: LnF.LNF_BREAK_DISABLED_IMAGE,
6864: "Stop", mpuDebugActionListener),
6865: "ja", "停止")
6866: );
6867: }
6868:
6869:
6870:
6871: public static JButton mpuMakeTraceButton () {
6872: return mpuAddButtonStopped (
6873: Multilingual.mlnToolTipText (
6874: ComponentFactory.createImageButton (
6875: LnF.LNF_TRACE_IMAGE,
6876: LnF.LNF_TRACE_DISABLED_IMAGE,
6877: "Trace", mpuDebugActionListener),
6878: "ja", "トレース")
6879: );
6880: }
6881:
6882:
6883:
6884: public static JButton mpuMakeTrace10Button () {
6885: return mpuAddButtonStopped (
6886: Multilingual.mlnToolTipText (
6887: ComponentFactory.createImageButton (
6888: LnF.LNF_TRACE_10_IMAGE,
6889: LnF.LNF_TRACE_10_DISABLED_IMAGE,
6890: "Trace 10 times", mpuDebugActionListener),
6891: "ja", "トレース 10 回")
6892: );
6893: }
6894:
6895:
6896:
6897: public static JButton mpuMakeTrace100Button () {
6898: return mpuAddButtonStopped (
6899: Multilingual.mlnToolTipText (
6900: ComponentFactory.createImageButton (
6901: LnF.LNF_TRACE_100_IMAGE,
6902: LnF.LNF_TRACE_100_DISABLED_IMAGE,
6903: "Trace 100 times", mpuDebugActionListener),
6904: "ja", "トレース 100 回")
6905: );
6906: }
6907:
6908:
6909:
6910: public static JButton mpuMakeStepButton () {
6911: return mpuAddButtonStopped (
6912: Multilingual.mlnToolTipText (
6913: ComponentFactory.createImageButton (
6914: LnF.LNF_STEP_IMAGE,
6915: LnF.LNF_STEP_DISABLED_IMAGE,
6916: "Step", mpuDebugActionListener),
6917: "ja", "ステップ")
6918: );
6919: }
6920:
6921:
6922:
6923: public static JButton mpuMakeStep10Button () {
6924: return mpuAddButtonStopped (
6925: Multilingual.mlnToolTipText (
6926: ComponentFactory.createImageButton (
6927: LnF.LNF_STEP_10_IMAGE,
6928: LnF.LNF_STEP_10_DISABLED_IMAGE,
6929: "Step 10 times", mpuDebugActionListener),
6930: "ja", "ステップ 10 回")
6931: );
6932: }
6933:
6934:
6935:
6936: public static JButton mpuMakeStep100Button () {
6937: return mpuAddButtonStopped (
6938: Multilingual.mlnToolTipText (
6939: ComponentFactory.createImageButton (
6940: LnF.LNF_STEP_100_IMAGE,
6941: LnF.LNF_STEP_100_DISABLED_IMAGE,
6942: "Step 100 times", mpuDebugActionListener),
6943: "ja", "ステップ 100 回")
6944: );
6945: }
6946:
6947:
6948:
6949: public static JButton mpuMakeReturnButton () {
6950: return mpuAddButtonStopped (
6951: Multilingual.mlnToolTipText (
6952: ComponentFactory.createImageButton (
6953: LnF.LNF_STEP_UNTIL_RETURN_IMAGE,
6954: LnF.LNF_STEP_UNTIL_RETURN_DISABLED_IMAGE,
6955: "Step until return", mpuDebugActionListener),
6956: "ja", "ステップアンティルリターン")
6957: );
6958: }
6959:
6960:
6961:
6962: public static JButton mpuMakeRunButton () {
6963: return mpuAddButtonStopped (
6964: Multilingual.mlnToolTipText (
6965: ComponentFactory.createImageButton (
6966: LnF.LNF_RUN_IMAGE,
6967: LnF.LNF_RUN_DISABLED_IMAGE,
6968: "Run", mpuDebugActionListener),
6969: "ja", "実行")
6970: );
6971: }
6972:
6973:
6974:
6975: public static <T extends AbstractButton> T mpuAddButtonRunning (T button) {
6976: button.setEnabled (mpuTask != null);
6977: mpuButtonsRunning.add (button);
6978: return button;
6979: }
6980:
6981:
6982:
6983: public static <T extends AbstractButton> T mpuAddButtonStopped (T button) {
6984: button.setEnabled (mpuTask == null);
6985: mpuButtonsStopped.add (button);
6986: return button;
6987: }
6988:
6989:
6990:
6991:
6992:
6993:
6994:
6995:
6996:
6997:
6998:
6999:
7000:
7001:
7002:
7003:
7004: public static final int EMX_OPCODE_BASE = 0x4e00;
7005: public static final int EMX_OPCODE_HFSBOOT = EMX_OPCODE_BASE + 0x00;
7006: public static final int EMX_OPCODE_HFSINST = EMX_OPCODE_BASE + 0x01;
7007: public static final int EMX_OPCODE_HFSSTR = EMX_OPCODE_BASE + 0x02;
7008: public static final int EMX_OPCODE_HFSINT = EMX_OPCODE_BASE + 0x03;
7009: public static final int EMX_OPCODE_EMXNOP = EMX_OPCODE_BASE + 0x04;
7010: public static final int EMX_OPCODE_EMXWAIT = EMX_OPCODE_BASE + 0x05;
7011:
7012: public static final String[] EMX_MNEMONIC_ARRAY = {
7013: "hfsboot",
7014: "hfsinst",
7015: "hfsstr",
7016: "hfsint",
7017: "emxnop",
7018: "emxwait",
7019: };
7020:
7021:
7022:
7023:
7024: public static void emxNop () {
7025: if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x00007140) {
7026: int head = regRn[9];
7027: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7028:
7029:
7030: emxPatchPCM8A (head, tail);
7031:
7032:
7033: emxCheckRSDRV202 (head, tail);
7034: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000716c) {
7035: int head = regRn[9];
7036: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7037:
7038:
7039: emxPatch060turbosys (head, tail);
7040:
7041:
7042: if (Z8530.SCC_FSX_MOUSE) {
7043: emxCheckFSX (head, tail);
7044: }
7045:
7046:
7047: if (HFS.HFS_USE_TWENTY_ONE) {
7048: emxCheckTwentyOne (head, tail);
7049: }
7050:
7051:
7052: LabeledAddress.lblClear ();
7053: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000972c) {
7054: int head = regRn[8] + 256;
7055:
7056: int tail = MC68060.mmuPeekLong (head - 208, 1);
7057:
7058:
7059: emxCheckBSIO021 (head, tail);
7060:
7061:
7062: emxPatchPCM8A (head, tail);
7063:
7064:
7065: emxCheckTMSIO031 (head, tail);
7066:
7067:
7068: LabeledAddress.lblClear ();
7069:
7070:
7071: if (dbgStopAtStart) {
7072: InstructionBreakPoint.ibpInstant (regRn[12], 0);
7073: }
7074: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000a090) {
7075: int head = regRn[8] + 256;
7076: int tail = MC68060.mmuPeekLongData (regRn[8] + 8, 1);
7077: String name = MC68060.mmuPeekStringZ (head - 60, 1);
7078: if (name.equalsIgnoreCase ("fsx.x")) {
7079:
7080:
7081: if (Z8530.SCC_FSX_MOUSE) {
7082: emxCheckFSX (head, tail);
7083: }
7084: }
7085: if (name.equalsIgnoreCase ("TwentyOne.x")) {
7086:
7087:
7088: if (HFS.HFS_USE_TWENTY_ONE) {
7089: emxCheckTwentyOne (head, tail);
7090: }
7091: }
7092: }
7093: }
7094:
7095: public static final int[] emxPCM8AFFMap = {
7096: 0x00000138, 0x000001f6, 0x00000394, 0x000011ec, 0x0000120a, 0x00001400, 0x00001814, 0x00001870, 0x00001882, 0x0000188a,
7097: 0x00001892, 0x000018a2, 0x000018a8, 0x000018ca, 0x000018d4, 0x000018e0, 0x000018e8, 0x00001908, 0x000019e4, 0x00001afa,
7098: 0x00001b58, 0x00001b7c, 0x00001bac, 0x00001c38, 0x00001ccc, 0x000021f8, 0x00002250, 0x00002258, 0x00002290, 0x000022a6,
7099: 0x000022b0, 0x000022c0, 0x000022c8, 0x000022de, 0x000022ea, 0x000030c8, 0x000030de, 0x000030e6, 0x000030ea, 0x000030f6,
7100: 0x00003112, 0x00003188, 0x0000334c, 0x0000338a, 0x000033a2, 0x000033c4, 0x000033d0, 0x0000341a, 0x00003428, 0x00003496,
7101: 0x000034a6, 0x000034d6, 0x0000fe0e, 0x0000fec8, 0x0000feec, 0x0000ff46, 0x0000ff4e,
7102: };
7103:
7104:
7105:
7106: public static void emxPatchPCM8A (int head, int tail) {
7107: if (head + 0x0000ff60 <= tail &&
7108: MC68060.mmuPeekLongData (head + 0x10f8, 1) == 0x50434d38 &&
7109: MC68060.mmuPeekLongData (head + 0x10fc, 1) == 0x41313032) {
7110: System.out.println (Multilingual.mlnJapanese ?
7111: "PCM8A.X 1.02 があります" :
7112: "PCM8A.X 1.02 exists");
7113: int patched = 0;
7114: int failed = 0;
7115:
7116: for (int offset : emxPCM8AFFMap) {
7117: if (MC68060.mmuPeekByteZeroData (head + offset, 1) == 0xff) {
7118: MC68060.mmuPokeByteData (head + offset, 0x00, 1);
7119: patched++;
7120: } else {
7121: failed++;
7122: }
7123: }
7124: if (patched != 0) {
7125: System.out.printf (Multilingual.mlnJapanese ?
7126: "PCM8A.X 1.02 にパッチをあてました (%d/%d)\n" :
7127: "PCM8A.X 1.02 was patched (%d/%d)\n",
7128: patched, patched + failed);
7129: }
7130: }
7131: }
7132:
7133:
7134:
7135: public static void emxPatch060turbosys (int head, int tail) {
7136:
7137:
7138:
7139:
7140: if (head + 0x00002000 <= tail &&
7141: MC68060.mmuPeekLongData (head + 0x00000ec0, 1) == 0x203c302e &&
7142: MC68060.mmuPeekLongData (head + 0x00000ec4, 1) == 0x3536227c &&
7143: MC68060.mmuPeekLongData (head + 0x00000ec8, 1) == 0x30363054) {
7144: System.out.println (Multilingual.mlnJapanese ?
7145: "060turbo.sys 0.56 があります" :
7146: "060turbo.sys 0.56 exists");
7147:
7148:
7149:
7150: int patched = 0;
7151: int failed = 0;
7152: if (MC68060.mmuPeekLongData (head + 0x000021e6, 1) == 0x08f90004 &&
7153: MC68060.mmuPeekLongData (head + 0x000021ea, 1) == 0x00ed0070) {
7154: MC68060.mmuPokeWordData (head + 0x000021e6, 0x0839, 1);
7155: patched++;
7156: } else {
7157: failed++;
7158: }
7159: System.out.printf (Multilingual.mlnJapanese ?
7160: "060turbo.sys 0.56 にパッチをあてました (%d/%d)\n" :
7161: "060turbo.sys 0.56 was patched (%d/%d)\n",
7162: patched, patched + failed);
7163: }
7164: }
7165:
7166:
7167:
7168: public static void emxCheckFSX (int head, int tail) {
7169: if (Z8530.SCC_FSX_MOUSE) {
7170: if (head + 0x00063200 <= tail &&
7171: "\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))) {
7172: System.out.println (Multilingual.mlnJapanese ?
7173: "FSX.X 3.10 があります" :
7174: "FSX.X 3.10 exists");
7175: Z8530.sccFSXMouseHook = head + 0x04f82a;
7176: Z8530.sccFSXMouseWork = head + 0x063184;
7177: }
7178: }
7179: }
7180:
7181:
7182:
7183:
7184:
7185:
7186: public static void emxCheckRSDRV202 (int head, int tail) {
7187: if (head + 0x000ea6 <= tail &&
7188: MC68060.mmuPeekEquals (head + 0x000e4e, "RS-232C DRIVER for X68000 version 2.02")) {
7189: if (RS232CTerminal.trmRSDRV202Head != head) {
7190: RS232CTerminal.trmRSDRV202Head = head;
7191: int[] patchData = {
7192:
7193:
7194: 0x05f8, 0x000a, 0x000b,
7195:
7196: 0x0600, 0xd040, 0x2048,
7197:
7198: 0x060e, 0x3030, 0x4e90,
7199: 0x0610, 0x0000, 0x2048,
7200:
7201: 0x074e, 0x0821, 0x2041,
7202: 0x0750, 0x0410, 0x3200,
7203: 0x0752, 0x0207, 0x303c,
7204: 0x0754, 0x0102, 0x0823,
7205: 0x0756, 0x0080, 0xe268,
7206: 0x0758, 0x003f, 0x72fe,
7207: 0x075a, 0x001f, 0xd141,
7208: 0x075c, 0x000e, 0x2208,
7209: 0x075e, 0x0006, 0x4e75,
7210:
7211:
7212: 0x0ab0, 0x0040, 0x0400,
7213: 0x0ad2, 0x0040, 0x0400,
7214: 0x0af4, 0x0040, 0x0400,
7215: 0x0b16, 0x0040, 0x0400,
7216: 0x0b38, 0x0040, 0x0400,
7217:
7218:
7219: 0x0cae, 0x0009, 0x000b,
7220: };
7221: int patched = 0;
7222: int failed = 0;
7223: for (int i = 0; i < patchData.length; i += 3) {
7224: int a = head + patchData[i];
7225: int b = patchData[i + 1];
7226: int c = patchData[i + 2];
7227: int d = MC68060.mmuPeekWordZeroData (a, 1);
7228: if (d == b) {
7229: MC68060.mmuPokeWordData (a, c, 1);
7230: patched++;
7231: } else if (d != c) {
7232: failed++;
7233: }
7234: }
7235: System.out.printf ("RSDRV.SYS 2.02 found at %08X and patched (%d/%d)\n", head, patched, patched + failed);
7236: }
7237: }
7238: }
7239:
7240:
7241:
7242:
7243:
7244: public static void emxCheckTMSIO031 (int head, int tail) {
7245: if (head + 0x000fc4 <= tail &&
7246: MC68060.mmuPeekEquals (head + 0x000d1c, "TMSIO version 0.31 Copyright (C) 1990-93 by Miki Hoshino")) {
7247: if (RS232CTerminal.trmTMSIO031Head != head) {
7248: RS232CTerminal.trmTMSIO031Head = head;
7249: System.out.printf ("TMSIO 0.31 found at %08X\n", head);
7250: }
7251: }
7252: }
7253:
7254:
7255:
7256:
7257:
7258: public static void emxCheckBSIO021 (int head, int tail) {
7259: if (head + 0x001c2c <= tail &&
7260: MC68060.mmuPeekEquals (head + 0x001a66, "BSIO version 0.21 Copyright (C) 1994 By BAZU")) {
7261: if (RS232CTerminal.trmBSIO021Head != head) {
7262: RS232CTerminal.trmBSIO021Head = head;
7263: System.out.printf ("BSIO 0.21 found at %08X\n", head);
7264: }
7265: }
7266: }
7267:
7268:
7269:
7270: public static void emxCheckTwentyOne (int head, int tail) {
7271: if (HFS.HFS_USE_TWENTY_ONE &&
7272: head + 64 <= tail) {
7273: if (MainMemory.mmrTwentyOneOptionAddress != 0 ||
7274: MainMemory.mmrHumanVersion <= 0) {
7275: return;
7276: }
7277: int name1 = MC68060.mmuPeekLongData (head + 14, 1);
7278: if (name1 == ('*' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7279: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7280: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '*')) {
7281: MainMemory.mmrTwentyOneOptionAddress = -1;
7282: }
7283: } else if (name1 == ('?' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7284: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7285: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '?') ||
7286: name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | 'E')) {
7287: System.out.println (Multilingual.mlnJapanese ?
7288: "TwentyOne.x があります" :
7289: "TwentyOne.x exists");
7290: MainMemory.mmrTwentyOneOptionAddress = head + 22;
7291: }
7292: }
7293: }
7294: }
7295:
7296:
7297:
7298:
7299:
7300:
7301:
7302:
7303:
7304:
7305:
7306:
7307:
7308:
7309:
7310:
7311:
7312:
7313:
7314:
7315:
7316:
7317:
7318:
7319:
7320:
7321:
7322:
7323:
7324:
7325:
7326:
7327:
7328:
7329:
7330:
7331:
7332:
7333:
7334:
7335:
7336:
7337:
7338:
7339:
7340:
7341:
7342:
7343:
7344:
7345:
7346: public static final boolean IRP_BITREV_REVERSE = false;
7347: public static final boolean IRP_BITREV_SHIFT = false;
7348: public static final boolean IRP_BITREV_TABLE = true;
7349:
7350: public static final boolean IRP_MOVEM_MAINMEMORY = true;
7351: public static final boolean IRP_MOVEM_EXPAND = false;
7352: public static final boolean IRP_MOVEM_LOOP = false;
7353: public static final boolean IRP_MOVEM_SHIFT_LEFT = false;
7354: public static final boolean IRP_MOVEM_SHIFT_RIGHT = true;
7355: public static final boolean IRP_MOVEM_ZEROS = false;
7356:
7357:
7358: public static void irpReset () {
7359:
7360: CRTC.crtReset ();
7361: VideoController.vcnReset ();
7362: HD63450.dmaReset ();
7363: MC68901.mfpReset ();
7364: Keyboard.kbdReset ();
7365: RP5C15.rtcReset ();
7366: PrinterPort.prnReset ();
7367: SoundSource.sndReset ();
7368: OPM.opmReset ();
7369: ADPCM.pcmReset ();
7370: FDC.fdcReset ();
7371: IOInterrupt.ioiReset ();
7372: eb2Reset ();
7373: if (HostCDROM.HCD_ENABLED) {
7374: HostCDROM.hcdReset ();
7375: }
7376: SPC.spcReset ();
7377: Z8530.sccReset ();
7378: RS232CTerminal.trmReset ();
7379: PPI.ppiReset ();
7380: HFS.hfsReset ();
7381: SpriteScreen.sprReset ();
7382:
7383: xt3Reset ();
7384: SRAM.smrReset ();
7385: CONDevice.conReset ();
7386: TextCopy.txcReset ();
7387: }
7388:
7389:
7390:
7391:
7392:
7393:
7394:
7395:
7396:
7397:
7398:
7399:
7400:
7401:
7402:
7403:
7404:
7405:
7406:
7407:
7408:
7409:
7410:
7411:
7412:
7413:
7414:
7415:
7416:
7417:
7418:
7419:
7420:
7421:
7422:
7423:
7424:
7425:
7426:
7427:
7428:
7429:
7430:
7431:
7432:
7433:
7434:
7435:
7436:
7437:
7438:
7439:
7440:
7441:
7442:
7443:
7444:
7445:
7446:
7447:
7448:
7449:
7450:
7451:
7452:
7453:
7454:
7455:
7456:
7457:
7458:
7459:
7460:
7461:
7462:
7463:
7464:
7465:
7466:
7467:
7468:
7469:
7470:
7471:
7472:
7473:
7474:
7475:
7476:
7477:
7478:
7479:
7480:
7481:
7482:
7483:
7484:
7485:
7486:
7487:
7488:
7489:
7490:
7491:
7492:
7493:
7494:
7495:
7496:
7497:
7498:
7499:
7500:
7501:
7502:
7503:
7504:
7505:
7506:
7507:
7508:
7509:
7510:
7511:
7512:
7513:
7514:
7515:
7516:
7517:
7518:
7519:
7520:
7521:
7522:
7523:
7524:
7525:
7526:
7527:
7528:
7529:
7530:
7531:
7532:
7533:
7534:
7535:
7536:
7537:
7538:
7539:
7540:
7541:
7542:
7543:
7544:
7545:
7546:
7547:
7548:
7549:
7550:
7551:
7552:
7553:
7554:
7555:
7556:
7557:
7558:
7559:
7560:
7561:
7562:
7563:
7564:
7565:
7566:
7567:
7568:
7569:
7570:
7571:
7572:
7573:
7574:
7575:
7576:
7577:
7578:
7579:
7580:
7581:
7582:
7583:
7584:
7585:
7586:
7587:
7588:
7589:
7590:
7591:
7592:
7593:
7594:
7595:
7596:
7597:
7598:
7599:
7600:
7601:
7602:
7603:
7604:
7605:
7606:
7607:
7608:
7609:
7610:
7611:
7612:
7613:
7614:
7615:
7616:
7617:
7618:
7619:
7620:
7621:
7622:
7623:
7624:
7625:
7626:
7627:
7628:
7629:
7630:
7631:
7632:
7633:
7634:
7635:
7636:
7637:
7638:
7639:
7640:
7641:
7642:
7643:
7644:
7645:
7646:
7647:
7648:
7649:
7650:
7651:
7652:
7653:
7654:
7655:
7656:
7657:
7658:
7659:
7660:
7661:
7662:
7663:
7664:
7665:
7666:
7667:
7668:
7669:
7670:
7671:
7672:
7673:
7674:
7675:
7676:
7677:
7678:
7679:
7680:
7681:
7682:
7683:
7684:
7685:
7686:
7687:
7688:
7689:
7690:
7691:
7692:
7693:
7694:
7695:
7696:
7697:
7698:
7699:
7700:
7701:
7702:
7703:
7704:
7705:
7706:
7707:
7708:
7709:
7710:
7711:
7712:
7713:
7714:
7715:
7716:
7717:
7718:
7719:
7720:
7721:
7722:
7723:
7724:
7725:
7726:
7727:
7728:
7729:
7730:
7731:
7732:
7733:
7734:
7735:
7736:
7737:
7738:
7739:
7740:
7741:
7742:
7743:
7744:
7745:
7746:
7747:
7748:
7749:
7750:
7751:
7752:
7753:
7754:
7755:
7756:
7757:
7758:
7759:
7760:
7761:
7762:
7763:
7764:
7765:
7766:
7767:
7768:
7769:
7770:
7771:
7772:
7773:
7774:
7775:
7776:
7777:
7778:
7779:
7780:
7781:
7782:
7783:
7784:
7785:
7786:
7787:
7788:
7789:
7790:
7791:
7792:
7793:
7794:
7795:
7796:
7797:
7798:
7799:
7800:
7801:
7802:
7803:
7804:
7805:
7806:
7807:
7808:
7809:
7810:
7811:
7812:
7813:
7814:
7815:
7816:
7817:
7818:
7819:
7820:
7821:
7822:
7823:
7824:
7825:
7826:
7827:
7828:
7829:
7830:
7831:
7832:
7833:
7834:
7835:
7836:
7837:
7838:
7839:
7840:
7841:
7842:
7843:
7844:
7845:
7846:
7847:
7848:
7849:
7850:
7851:
7852:
7853:
7854:
7855:
7856:
7857:
7858:
7859:
7860:
7861:
7862:
7863:
7864:
7865:
7866:
7867:
7868:
7869:
7870:
7871:
7872:
7873:
7874:
7875:
7876:
7877:
7878:
7879:
7880:
7881:
7882:
7883:
7884:
7885:
7886:
7887:
7888:
7889:
7890:
7891:
7892:
7893:
7894:
7895:
7896:
7897:
7898:
7899:
7900:
7901:
7902:
7903:
7904:
7905:
7906:
7907:
7908:
7909:
7910:
7911:
7912:
7913:
7914:
7915:
7916:
7917:
7918:
7919:
7920:
7921:
7922:
7923:
7924:
7925:
7926:
7927:
7928:
7929:
7930:
7931:
7932:
7933:
7934:
7935:
7936:
7937:
7938:
7939:
7940:
7941:
7942:
7943:
7944:
7945:
7946:
7947:
7948:
7949:
7950:
7951:
7952:
7953:
7954:
7955:
7956:
7957:
7958:
7959:
7960:
7961:
7962:
7963:
7964:
7965:
7966:
7967:
7968:
7969:
7970:
7971:
7972:
7973:
7974: 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);
7975:
7976: public static final boolean EFA_SEPARATE_AR = false;
7977:
7978:
7979:
7980:
7981:
7982:
7983: public static final boolean BUS_SPLIT_UNALIGNED_LONG = false;
7984:
7985:
7986: public static final int BUS_MOTHER_BITS = 24;
7987: public static final int BUS_MOTHER_SIZE = BUS_MOTHER_BITS < 32 ? 1 << BUS_MOTHER_BITS : 0;
7988: public static final int BUS_MOTHER_MASK = BUS_MOTHER_SIZE - 1;
7989:
7990: public static final int BUS_ARRAY_SIZE = BUS_MOTHER_SIZE;
7991:
7992:
7993: public static final int BUS_PAGE_BITS = 12;
7994: public static final int BUS_PAGE_SIZE = 1 << BUS_PAGE_BITS;
7995: public static final int BUS_PAGE_COUNT = 1 << (32 - BUS_PAGE_BITS);
7996:
7997:
7998: public static final int MPU_SS_BYTE = 0;
7999: public static final int MPU_SS_WORD = 1;
8000: public static final int MPU_SS_LONG = 2;
8001:
8002:
8003: public static final int MPU_WR_WRITE = 0;
8004: public static final int MPU_WR_READ = 1;
8005:
8006:
8007: public static final int MPU_US_USER = 0;
8008: public static final int MPU_US_SUPERVISOR = 1;
8009:
8010:
8011: public static final MemoryMappedDevice[] busUserMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8012: public static final MemoryMappedDevice[] busSuperMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8013: public static MemoryMappedDevice[] busMemoryMap;
8014:
8015:
8016: public static boolean busHimem68000;
8017:
8018:
8019: public static final int BUS_HIGH_MEMORY_START = 0x01000000;
8020: public static int busHighMemorySize;
8021: public static byte[] busHighMemoryArray;
8022: public static boolean busHighMemorySaveOn;
8023: public static boolean busHighMemory060turboOn;
8024:
8025:
8026: public static final int BUS_LOCAL_MEMORY_START = 0x10000000;
8027: public static int busLocalMemorySize;
8028: public static byte[] busLocalMemoryArray;
8029: public static boolean busLocalMemorySaveOn;
8030:
8031:
8032: public static final byte[] BUS_DUMMY_MEMORY_ARRAY = new byte[0];
8033: public static int busRequestExMemoryStart;
8034: public static int busRequestExMemorySize;
8035: public static byte[] busRequestExMemoryArray;
8036: public static int busExMemoryStart;
8037: public static int busExMemorySize;
8038: public static byte[] busExMemoryArray;
8039:
8040:
8041: public static boolean busRequestCutFC2Pin;
8042: public static boolean busCutFC2Pin;
8043:
8044:
8045:
8046: public static void busInit () {
8047:
8048:
8049: if (!DataBreakPoint.DBP_ON) {
8050: busMemoryMap = busSuperMap;
8051: }
8052:
8053:
8054: int highMemorySizeMB = Settings.sgsGetInt ("highmemory");
8055: busHighMemorySize = highMemorySizeMB == 16 ? highMemorySizeMB << 20 : 0 << 20;
8056: if (busHighMemorySize == 0) {
8057: System.out.println (Multilingual.mlnJapanese ?
8058: "X68030/Xellent30 のハイメモリはありません" :
8059: "X68030/Xellent30 high memory does not exists");
8060: } else {
8061: System.out.printf (Multilingual.mlnJapanese ?
8062: "X68030/Xellent30 のハイメモリのサイズは %dMB です\n" :
8063: "X68030/Xellent30 high memory size is %dMB\n",
8064: busHighMemorySize >> 20);
8065: }
8066: busHighMemoryArray = new byte[busHighMemorySize];
8067:
8068: busHimem68000 = Settings.sgsGetOnOff ("himem68000");
8069:
8070: busHighMemorySaveOn = Settings.sgsGetOnOff ("highmemorysave");
8071: busHighMemory060turboOn = Settings.sgsGetOnOff ("highmemory060turbo");
8072:
8073: byte[] highMemoryArray = Settings.sgsGetData ("highmemorydata");
8074: if (busHighMemorySize != 0) {
8075: if (highMemoryArray.length != 0) {
8076: System.out.println (Multilingual.mlnJapanese ?
8077: "X68030/Xellent30 のハイメモリのデータを復元します" :
8078: "X68030/Xellent30 high memory data is restored");
8079: System.arraycopy (highMemoryArray, 0, busHighMemoryArray, 0, Math.min (highMemoryArray.length, busHighMemorySize));
8080: } else {
8081: System.out.println (Multilingual.mlnJapanese ?
8082: "X68030/Xellent30 のハイメモリをゼロクリアします" :
8083: "X68030/Xellent30 high memory is zero-cleared");
8084: }
8085: if (highMemoryArray.length < busHighMemorySize) {
8086: Arrays.fill (busHighMemoryArray, highMemoryArray.length, busHighMemorySize, (byte) 0);
8087: }
8088: }
8089:
8090:
8091: int localMemorySizeMB = Settings.sgsGetInt ("localmemory");
8092: busLocalMemorySize = (localMemorySizeMB == 16 ||
8093: localMemorySizeMB == 32 ||
8094: localMemorySizeMB == 64 ||
8095: localMemorySizeMB == 128 ||
8096: localMemorySizeMB == 256 ||
8097: localMemorySizeMB == 384 ||
8098: localMemorySizeMB == 512 ||
8099: localMemorySizeMB == 768 ?
8100: localMemorySizeMB << 20 :
8101: 128 << 20);
8102: if (busLocalMemorySize == 0) {
8103: System.out.println (Multilingual.mlnJapanese ?
8104: "060turbo のハイメモリはありません" :
8105: "060turbo high memory does not exists");
8106: } else {
8107: System.out.printf (Multilingual.mlnJapanese ?
8108: "060turbo のハイメモリのサイズは %dMB です\n" :
8109: "060turbo high memory size is %dMB\n",
8110: busLocalMemorySize >> 20);
8111: }
8112: busLocalMemoryArray = new byte[busLocalMemorySize];
8113:
8114: busLocalMemorySaveOn = Settings.sgsGetOnOff ("localmemorysave");
8115:
8116: byte[] localMemoryArray = Settings.sgsGetData ("localmemorydata");
8117: if (busLocalMemorySize != 0) {
8118: if (localMemoryArray.length != 0) {
8119: System.out.println (Multilingual.mlnJapanese ?
8120: "060turbo のハイメモリのデータを復元します" :
8121: "060turbo high memory data is restored");
8122: System.arraycopy (localMemoryArray, 0, busLocalMemoryArray, 0, Math.min (localMemoryArray.length, busLocalMemorySize));
8123: } else {
8124: System.out.println (Multilingual.mlnJapanese ?
8125: "060turbo のハイメモリをゼロクリアします" :
8126: "060turbo high memory is zero-cleared");
8127: }
8128: if (localMemoryArray.length < busLocalMemorySize) {
8129: Arrays.fill (busLocalMemoryArray, localMemoryArray.length, busLocalMemorySize, (byte) 0);
8130: }
8131: }
8132:
8133:
8134: busExMemoryStart = busRequestExMemoryStart = 0x10000000;
8135: busExMemorySize = busRequestExMemorySize = 0 << 20;
8136: busExMemoryArray = busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
8137:
8138:
8139: busRequestCutFC2Pin = Settings.sgsGetOnOff ("cutfc2pin");
8140: busCutFC2Pin = !busRequestCutFC2Pin;
8141:
8142: busUpdateMemoryMap ();
8143:
8144: }
8145:
8146:
8147:
8148: public static void busTini () {
8149: Settings.sgsPutOnOff ("himem68000", busHimem68000);
8150: Settings.sgsPutInt ("highmemory", busHighMemorySize >>> 20);
8151: Settings.sgsPutOnOff ("highmemorysave", busHighMemorySaveOn);
8152: Settings.sgsPutOnOff ("highmemory060turbo", busHighMemory060turboOn);
8153: Settings.sgsPutData ("highmemorydata", busHighMemorySaveOn ? busHighMemoryArray : new byte[0]);
8154: Settings.sgsPutInt ("localmemory", busLocalMemorySize >>> 20);
8155: Settings.sgsPutOnOff ("localmemorysave", busLocalMemorySaveOn);
8156: Settings.sgsPutData ("localmemorydata", busLocalMemorySaveOn ? busLocalMemoryArray : new byte[0]);
8157: Settings.sgsPutOnOff ("cutfc2pin", busRequestCutFC2Pin);
8158: }
8159:
8160: public static void busUpdateMemoryMap () {
8161: if (busExMemoryStart == busRequestExMemoryStart &&
8162: busExMemorySize == busRequestExMemorySize &&
8163: busExMemoryArray == busRequestExMemoryArray &&
8164: busExMemoryArray.length == busExMemorySize &&
8165: busCutFC2Pin == busRequestCutFC2Pin) {
8166: return;
8167: }
8168:
8169: busExMemoryStart = busRequestExMemoryStart;
8170: busExMemorySize = busRequestExMemorySize;
8171: busExMemoryArray = busRequestExMemoryArray;
8172: if (busExMemoryArray.length != busExMemorySize) {
8173: byte[] newArray = new byte[busExMemorySize];
8174: int copySize = Math.min (busExMemoryArray.length, busExMemorySize);
8175: if (copySize > 0) {
8176: System.arraycopy (busExMemoryArray, 0, newArray, 0, copySize);
8177: }
8178: if (busExMemoryArray == busHighMemoryArray) {
8179: busHighMemoryArray = newArray;
8180: } else if (busExMemoryArray == busLocalMemoryArray) {
8181: busLocalMemoryArray = newArray;
8182: }
8183: busExMemoryArray = newArray;
8184: }
8185:
8186: busCutFC2Pin = busRequestCutFC2Pin;
8187:
8188:
8189:
8190:
8191:
8192:
8193:
8194:
8195:
8196:
8197:
8198:
8199: busSuper (MemoryMappedDevice.MMD_MMR, 0x00000000, 0x00002000);
8200: busUser ( MemoryMappedDevice.MMD_MMR, 0x00002000, 0x00c00000);
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: busSuper (MemoryMappedDevice.MMD_GE0, 0x00c00000, 0x00c80000);
8226: busSuper (MemoryMappedDevice.MMD_GE1, 0x00c80000, 0x00d00000);
8227: busSuper (MemoryMappedDevice.MMD_GE2, 0x00d00000, 0x00d80000);
8228: busSuper (MemoryMappedDevice.MMD_GE3, 0x00d80000, 0x00e00000);
8229:
8230:
8231:
8232:
8233: busSuper (MemoryMappedDevice.MMD_TXT, 0x00e00000, 0x00e80000);
8234:
8235:
8236:
8237:
8238: busSuper (MemoryMappedDevice.MMD_CRT, 0x00e80000, 0x00e82000);
8239:
8240:
8241:
8242:
8243:
8244: busSuper (MemoryMappedDevice.MMD_VCN, 0x00e82000, 0x00e84000);
8245:
8246:
8247:
8248:
8249: busSuper (MemoryMappedDevice.MMD_DMA, 0x00e84000, 0x00e86000);
8250:
8251:
8252:
8253:
8254: busSuper (MemoryMappedDevice.MMD_SVS, 0x00e86000, 0x00e88000);
8255:
8256:
8257:
8258:
8259: busSuper (MemoryMappedDevice.MMD_MFP, 0x00e88000, 0x00e8a000);
8260:
8261:
8262:
8263:
8264: busSuper (MemoryMappedDevice.MMD_RTC_FIRST, 0x00e8a000, 0x00e8c000);
8265:
8266:
8267:
8268:
8269: busSuper (MemoryMappedDevice.MMD_PRN, 0x00e8c000, 0x00e8e000);
8270:
8271:
8272:
8273:
8274: busSuper (MemoryMappedDevice.MMD_SYS, 0x00e8e000, 0x00e90000);
8275:
8276:
8277:
8278:
8279: busSuper (MemoryMappedDevice.MMD_OPM, 0x00e90000, 0x00e92000);
8280:
8281:
8282:
8283:
8284: busSuper (MemoryMappedDevice.MMD_PCM, 0x00e92000, 0x00e94000);
8285:
8286:
8287:
8288:
8289: busSuper (MemoryMappedDevice.MMD_FDC, 0x00e94000, 0x00e96000);
8290:
8291:
8292:
8293:
8294:
8295: busSuper (MemoryMappedDevice.MMD_HDC, 0x00e96000, 0x00e98000);
8296:
8297:
8298:
8299:
8300: busSuper (MemoryMappedDevice.MMD_SCC, 0x00e98000, 0x00e9a000);
8301:
8302:
8303:
8304:
8305: busSuper (MemoryMappedDevice.MMD_PPI, 0x00e9a000, 0x00e9c000);
8306:
8307:
8308:
8309:
8310: busSuper (MemoryMappedDevice.MMD_IOI, 0x00e9c000, 0x00e9e000);
8311:
8312:
8313:
8314:
8315:
8316:
8317:
8318:
8319:
8320: busSuper (MemoryMappedDevice.MMD_XB1, 0x00e9e000, 0x00ea0000);
8321:
8322:
8323:
8324:
8325:
8326: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ea0000, 0x00eae000);
8327:
8328:
8329:
8330:
8331:
8332:
8333:
8334:
8335:
8336:
8337:
8338:
8339:
8340:
8341:
8342: busSuper (MemoryMappedDevice.MMD_XB2, 0x00eae000, 0x00eb0000);
8343:
8344:
8345:
8346:
8347:
8348:
8349:
8350:
8351: busSuper (MemoryMappedDevice.MMD_SPR, 0x00eb0000, 0x00ec0000);
8352:
8353:
8354:
8355:
8356:
8357:
8358:
8359:
8360:
8361:
8362:
8363:
8364:
8365: busSuper (MemoryMappedDevice.MMD_XB3, 0x00ec0000, 0x00ed0000);
8366:
8367:
8368:
8369:
8370:
8371:
8372: busSuper (MemoryMappedDevice.MMD_SMR, 0x00ed0000, 0x00ed0000 + 16384);
8373: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ed0000 + 16384, 0x00ed0000 + 65536);
8374:
8375:
8376:
8377:
8378:
8379:
8380:
8381:
8382: busSuper (MemoryMappedDevice.MMD_XB4, 0x00ee0000, 0x00f00000);
8383:
8384:
8385:
8386:
8387:
8388:
8389:
8390:
8391:
8392:
8393: busSuper (MemoryMappedDevice.MMD_CG1, 0x00f00000, 0x00f40000);
8394:
8395:
8396:
8397:
8398:
8399:
8400:
8401: busSuper (MemoryMappedDevice.MMD_CG2, 0x00f40000, 0x00fc0000);
8402:
8403:
8404:
8405:
8406:
8407:
8408:
8409:
8410:
8411:
8412:
8413:
8414:
8415:
8416: busSuper (MemoryMappedDevice.MMD_ROM, 0x00fc0000, 0x01000000);
8417:
8418: }
8419:
8420: public static void busReset () {
8421: if (regSRS != 0) {
8422: if (DataBreakPoint.DBP_ON) {
8423: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpSuperMap;
8424: } else {
8425: busMemoryMap = busSuperMap;
8426: }
8427: } else {
8428: if (DataBreakPoint.DBP_ON) {
8429: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpUserMap;
8430: } else {
8431: busMemoryMap = busUserMap;
8432: }
8433: }
8434: }
8435:
8436:
8437:
8438:
8439:
8440: public static void busUser (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8441: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8442: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8443: if (false &&
8444: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8445: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8446: System.out.printf ("ERROR: busUser (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8447: }
8448: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8449: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8450: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8451: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8452: int startPage = blockStartPage + motherStartPage;
8453: int endPage = blockStartPage + motherEndPage;
8454: for (int page = startPage; page < endPage; page++) {
8455: MemoryMappedDevice superMmd = exMemoryStartPage <= page && page < exMemoryEndPage ? MemoryMappedDevice.MMD_XMM : mmd;
8456: busUserMap[page] = busSuperMap[page] = superMmd;
8457: if (InstructionBreakPoint.IBP_ON) {
8458: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8459: InstructionBreakPoint.ibpUserMap[page] = superMmd;
8460: }
8461: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8462: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8463: }
8464: }
8465: if (DataBreakPoint.DBP_ON) {
8466: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8467: DataBreakPoint.dbpUserMap[page] = superMmd;
8468: }
8469: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8470: DataBreakPoint.dbpSuperMap[page] = superMmd;
8471: }
8472: }
8473: }
8474: }
8475: }
8476:
8477:
8478:
8479:
8480:
8481: public static void busSuper (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8482: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8483: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8484: if (false &&
8485: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8486: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8487: System.out.printf ("ERROR: busSuper (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8488: }
8489: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8490: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8491: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8492: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8493: int startPage = blockStartPage + motherStartPage;
8494: int endPage = blockStartPage + motherEndPage;
8495: for (int page = startPage; page < endPage; page++) {
8496: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
8497: MemoryMappedDevice userMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : busCutFC2Pin ? mmd : MemoryMappedDevice.MMD_NUL;
8498: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
8499: busUserMap[page] = userMmd;
8500: busSuperMap[page] = superMmd;
8501: if (InstructionBreakPoint.IBP_ON) {
8502: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8503: InstructionBreakPoint.ibpUserMap[page] = userMmd;
8504: }
8505: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8506: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8507: }
8508: }
8509: if (DataBreakPoint.DBP_ON) {
8510: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8511: DataBreakPoint.dbpUserMap[page] = userMmd;
8512: }
8513: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8514: DataBreakPoint.dbpSuperMap[page] = superMmd;
8515: }
8516: }
8517: }
8518: }
8519: }
8520:
8521:
8522:
8523: public static byte busPbs (int a) {
8524: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a);
8525: }
8526:
8527:
8528:
8529: public static int busPbz (int a) {
8530: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a);
8531: }
8532:
8533:
8534:
8535: public static int busPws (int a) {
8536: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8537: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
8538: } else {
8539: int a1 = a + 1;
8540: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
8541: }
8542: }
8543:
8544:
8545:
8546: public static int busPwse (int a) {
8547: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
8548: }
8549:
8550:
8551:
8552: public static int busPwz (int a) {
8553: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8554: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
8555: } else {
8556: int a1 = a + 1;
8557: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
8558: }
8559: }
8560:
8561:
8562:
8563: public static int busPwze (int a) {
8564: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
8565: }
8566:
8567:
8568:
8569: public static int busPls (int a) {
8570: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8571: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
8572: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8573: int a2 = a + 2;
8574: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a) << 16 | busSuperMap[a2 >>> BUS_PAGE_BITS].mmdPwz (a2);
8575: } else {
8576: int a1 = a + 1;
8577: int a3 = a + 3;
8578: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 24 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPwz (a1) << 8 | busSuperMap[a3 >>> BUS_PAGE_BITS].mmdPbz (a3);
8579: }
8580: }
8581:
8582:
8583:
8584: public static int busPlsf (int a) {
8585: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
8586: }
8587:
8588:
8589:
8590: public static long busPqs (int a) {
8591: return (long) busPls (a) << 32 | busPls (a + 4) & 0xffffffffL;
8592: }
8593:
8594:
8595:
8596: public static int busSearchByte (int start, int end, int c) {
8597: for (int a = start; a < end; a++) {
8598: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) == c) {
8599: return a;
8600: }
8601: }
8602: return -1;
8603: }
8604: public static int busSearchWord (int start, int end, int c) {
8605: for (int a = start; a < end; a += 2) {
8606: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) == c) {
8607: return a;
8608: }
8609: }
8610: return -1;
8611: }
8612: public static int busSearchByteArray (int start, int end, int[] array) {
8613: int l = array.length;
8614: end -= l;
8615: int c = array[0];
8616: a:
8617: for (int a = start; a <= end; a++) {
8618: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) != c) {
8619: continue a;
8620: }
8621: for (int i = 1, b = a + 1; i < l; i++, b++) {
8622: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPbz (b) != array[i]) {
8623: continue a;
8624: }
8625: }
8626: return a;
8627: }
8628: return -1;
8629: }
8630: public static int busSearchWordArray (int start, int end, int[] array) {
8631: int l = array.length;
8632: end -= l;
8633: int c = array[0];
8634: a:
8635: for (int a = start; a <= end; a += 2) {
8636: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) != c) {
8637: continue a;
8638: }
8639: for (int i = 1, b = a + 2; i < l; i++, b += 2) {
8640: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPwz (b) != array[i]) {
8641: continue a;
8642: }
8643: }
8644: return a;
8645: }
8646: return -1;
8647: }
8648:
8649:
8650:
8651:
8652: public static byte busRbs (int a) throws M68kException {
8653: if (DataBreakPoint.DBP_ON) {
8654: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
8655: } else {
8656: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
8657: }
8658: }
8659:
8660:
8661:
8662: public static int busRbz (int a) throws M68kException {
8663: if (DataBreakPoint.DBP_ON) {
8664: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
8665: } else {
8666: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
8667: }
8668: }
8669:
8670:
8671:
8672: public static int busRws (int a) throws M68kException {
8673: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8674: if (DataBreakPoint.DBP_ON) {
8675: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8676: } else {
8677: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8678: }
8679: } else if (mpuIgnoreAddressError) {
8680: int a1 = a + 1;
8681: if (DataBreakPoint.DBP_ON) {
8682: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8683: } else {
8684: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8685: }
8686: } else {
8687: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8688: M68kException.m6eAddress = a;
8689: M68kException.m6eDirection = MPU_WR_READ;
8690: M68kException.m6eSize = MPU_SS_WORD;
8691: throw M68kException.m6eSignal;
8692: }
8693: }
8694:
8695:
8696:
8697:
8698: public static int busRwse (int a) throws M68kException {
8699: if (DataBreakPoint.DBP_ON) {
8700: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8701: } else {
8702: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8703: }
8704: }
8705:
8706:
8707:
8708: public static int busRwz (int a) throws M68kException {
8709: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8710: if (DataBreakPoint.DBP_ON) {
8711: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8712: } else {
8713: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8714: }
8715: } else if (mpuIgnoreAddressError) {
8716: int a1 = a + 1;
8717: if (DataBreakPoint.DBP_ON) {
8718: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8719: } else {
8720: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8721: }
8722: } else {
8723: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8724: M68kException.m6eAddress = a;
8725: M68kException.m6eDirection = MPU_WR_READ;
8726: M68kException.m6eSize = MPU_SS_WORD;
8727: throw M68kException.m6eSignal;
8728: }
8729: }
8730:
8731:
8732:
8733:
8734: public static int busRwze (int a) throws M68kException {
8735: if (DataBreakPoint.DBP_ON) {
8736: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8737: } else {
8738: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8739: }
8740: }
8741:
8742:
8743:
8744: public static int busRls (int a) throws M68kException {
8745: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8746: if (DataBreakPoint.DBP_ON) {
8747: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8748: } else {
8749: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8750: }
8751: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8752: int a2 = a + 2;
8753: if (BUS_SPLIT_UNALIGNED_LONG) {
8754: if (DataBreakPoint.DBP_ON) {
8755: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8756: } else {
8757: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8758: }
8759: } else {
8760: MemoryMappedDevice mmd;
8761: MemoryMappedDevice mmd2;
8762: if (DataBreakPoint.DBP_ON) {
8763: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8764: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8765: } else {
8766: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8767: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8768: }
8769: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
8770: }
8771: } else if (mpuIgnoreAddressError) {
8772: int a1 = a + 1;
8773: int a3 = a + 3;
8774: if (DataBreakPoint.DBP_ON) {
8775: 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);
8776: } else {
8777: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 24 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRwz (a1) << 8 | busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdRbz (a3);
8778: }
8779: } else {
8780: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8781: M68kException.m6eAddress = a;
8782: M68kException.m6eDirection = MPU_WR_READ;
8783: M68kException.m6eSize = MPU_SS_LONG;
8784: throw M68kException.m6eSignal;
8785: }
8786: }
8787:
8788:
8789:
8790:
8791: public static int busRlse (int a) throws M68kException {
8792: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8793: if (DataBreakPoint.DBP_ON) {
8794: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8795: } else {
8796: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8797: }
8798: } else {
8799: int a2 = a + 2;
8800: if (BUS_SPLIT_UNALIGNED_LONG) {
8801: if (DataBreakPoint.DBP_ON) {
8802: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8803: } else {
8804: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8805: }
8806: } else {
8807: MemoryMappedDevice mmd;
8808: MemoryMappedDevice mmd2;
8809: if (DataBreakPoint.DBP_ON) {
8810: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8811: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8812: } else {
8813: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8814: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8815: }
8816: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
8817: }
8818: }
8819: }
8820:
8821:
8822:
8823:
8824: public static int busRlsf (int a) throws M68kException {
8825: if (DataBreakPoint.DBP_ON) {
8826: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8827: } else {
8828: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8829: }
8830: }
8831:
8832:
8833:
8834: public static long busRqs (int a) throws M68kException {
8835: return (long) busRls (a) << 32 | busRls (a + 4) & 0xffffffffL;
8836: }
8837:
8838:
8839:
8840: public static void busWb (int a, int d) throws M68kException {
8841: if (DataBreakPoint.DBP_ON) {
8842: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
8843: } else {
8844: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
8845: }
8846: }
8847:
8848:
8849:
8850: public static void busWw (int a, int d) throws M68kException {
8851: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8852: if (DataBreakPoint.DBP_ON) {
8853: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8854: } else {
8855: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8856: }
8857: } else if (mpuIgnoreAddressError) {
8858: int a1 = a + 1;
8859: if (DataBreakPoint.DBP_ON) {
8860: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
8861: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
8862: } else {
8863: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
8864: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
8865: }
8866: } else {
8867: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8868: M68kException.m6eAddress = a;
8869: M68kException.m6eDirection = MPU_WR_WRITE;
8870: M68kException.m6eSize = MPU_SS_WORD;
8871: throw M68kException.m6eSignal;
8872: }
8873: }
8874:
8875:
8876:
8877:
8878: public static void busWwe (int a, int d) throws M68kException {
8879: if (DataBreakPoint.DBP_ON) {
8880: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8881: } else {
8882: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8883: }
8884: }
8885:
8886:
8887:
8888: public static void busWl (int a, int d) throws M68kException {
8889: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8890: if (DataBreakPoint.DBP_ON) {
8891: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8892: } else {
8893: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8894: }
8895: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8896: int a2 = a + 2;
8897: if (BUS_SPLIT_UNALIGNED_LONG) {
8898: if (DataBreakPoint.DBP_ON) {
8899: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8900: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8901: } else {
8902: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8903: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8904: }
8905: } else {
8906: MemoryMappedDevice mmd;
8907: MemoryMappedDevice mmd2;
8908: if (DataBreakPoint.DBP_ON) {
8909: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8910: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8911: } else {
8912: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8913: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8914: }
8915: if (mmd == mmd2) {
8916: mmd.mmdWl (a, d);
8917: } else {
8918: mmd.mmdWw (a, d >> 16);
8919: mmd2.mmdWw (a2, d);
8920: }
8921: }
8922: } else if (mpuIgnoreAddressError) {
8923: int a1 = a + 1;
8924: int a3 = a + 3;
8925: if (DataBreakPoint.DBP_ON) {
8926: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
8927: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
8928: DataBreakPoint.dbpMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
8929: } else {
8930: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
8931: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
8932: busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
8933: }
8934: } else {
8935: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8936: M68kException.m6eAddress = a;
8937: M68kException.m6eDirection = MPU_WR_WRITE;
8938: M68kException.m6eSize = MPU_SS_LONG;
8939: throw M68kException.m6eSignal;
8940: }
8941: }
8942:
8943:
8944:
8945:
8946: public static void busWlf (int a, int d) throws M68kException {
8947: if (DataBreakPoint.DBP_ON) {
8948: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8949: } else {
8950: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8951: }
8952: }
8953:
8954:
8955:
8956:
8957: public static void busWle (int a, int d) throws M68kException {
8958: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8959: if (DataBreakPoint.DBP_ON) {
8960: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8961: } else {
8962: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8963: }
8964: } else {
8965: int a2 = a + 2;
8966: if (BUS_SPLIT_UNALIGNED_LONG) {
8967: if (DataBreakPoint.DBP_ON) {
8968: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8969: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8970: } else {
8971: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8972: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8973: }
8974: } else {
8975: MemoryMappedDevice mmd;
8976: MemoryMappedDevice mmd2;
8977: if (DataBreakPoint.DBP_ON) {
8978: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8979: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8980: } else {
8981: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8982: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8983: }
8984: if (mmd == mmd2) {
8985: mmd.mmdWl (a, d);
8986: } else {
8987: mmd.mmdWw (a, d >> 16);
8988: mmd2.mmdWw (a2, d);
8989: }
8990: }
8991: }
8992: }
8993:
8994:
8995:
8996: public static void busWq (int a, long d) throws M68kException {
8997: busWl (a, (int) (d >>> 32));
8998: busWl (a + 4, (int) d);
8999: }
9000:
9001:
9002:
9003:
9004:
9005: public static void busRbb (int a, byte[] bb, int o, int l) throws M68kException {
9006: if (false) {
9007: for (int i = 0; i < l; i++) {
9008: int ai = a + i;
9009: if (DataBreakPoint.DBP_ON) {
9010: bb[o + i] = DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9011: } else {
9012: bb[o + i] = busMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9013: }
9014: }
9015: } else {
9016: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9017: while (l > 0) {
9018: MemoryMappedDevice mmd;
9019: if (DataBreakPoint.DBP_ON) {
9020: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9021: } else {
9022: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9023: }
9024: int s = l <= r ? l : r;
9025: l -= s;
9026: if (true) {
9027: for (s -= 16; s >= 0; s -= 16) {
9028: bb[o ] = mmd.mmdRbs (a );
9029: bb[o + 1] = mmd.mmdRbs (a + 1);
9030: bb[o + 2] = mmd.mmdRbs (a + 2);
9031: bb[o + 3] = mmd.mmdRbs (a + 3);
9032: bb[o + 4] = mmd.mmdRbs (a + 4);
9033: bb[o + 5] = mmd.mmdRbs (a + 5);
9034: bb[o + 6] = mmd.mmdRbs (a + 6);
9035: bb[o + 7] = mmd.mmdRbs (a + 7);
9036: bb[o + 8] = mmd.mmdRbs (a + 8);
9037: bb[o + 9] = mmd.mmdRbs (a + 9);
9038: bb[o + 10] = mmd.mmdRbs (a + 10);
9039: bb[o + 11] = mmd.mmdRbs (a + 11);
9040: bb[o + 12] = mmd.mmdRbs (a + 12);
9041: bb[o + 13] = mmd.mmdRbs (a + 13);
9042: bb[o + 14] = mmd.mmdRbs (a + 14);
9043: bb[o + 15] = mmd.mmdRbs (a + 15);
9044: a += 16;
9045: o += 16;
9046: }
9047: s += 16;
9048: }
9049: for (int i = 0; i < s; i++) {
9050: bb[o + i] = mmd.mmdRbs (a + i);
9051: }
9052: a += s;
9053: o += s;
9054: r = BUS_PAGE_SIZE;
9055: }
9056: }
9057: }
9058:
9059:
9060:
9061: public static void busWbb (int a, byte[] bb, int o, int l) throws M68kException {
9062: if (false) {
9063: for (int i = 0; i < l; i++) {
9064: int ai = a + i;
9065: if (DataBreakPoint.DBP_ON) {
9066: DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9067: } else {
9068: busMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9069: }
9070: }
9071: } else {
9072: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9073: while (l > 0) {
9074: MemoryMappedDevice mmd;
9075: if (DataBreakPoint.DBP_ON) {
9076: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9077: } else {
9078: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9079: }
9080: int s = l <= r ? l : r;
9081: l -= s;
9082: if (true) {
9083: for (s -= 16; s >= 0; s -= 16) {
9084: mmd.mmdWb (a , bb[o ]);
9085: mmd.mmdWb (a + 1, bb[o + 1]);
9086: mmd.mmdWb (a + 2, bb[o + 2]);
9087: mmd.mmdWb (a + 3, bb[o + 3]);
9088: mmd.mmdWb (a + 4, bb[o + 4]);
9089: mmd.mmdWb (a + 5, bb[o + 5]);
9090: mmd.mmdWb (a + 6, bb[o + 6]);
9091: mmd.mmdWb (a + 7, bb[o + 7]);
9092: mmd.mmdWb (a + 8, bb[o + 8]);
9093: mmd.mmdWb (a + 9, bb[o + 9]);
9094: mmd.mmdWb (a + 10, bb[o + 10]);
9095: mmd.mmdWb (a + 11, bb[o + 11]);
9096: mmd.mmdWb (a + 12, bb[o + 12]);
9097: mmd.mmdWb (a + 13, bb[o + 13]);
9098: mmd.mmdWb (a + 14, bb[o + 14]);
9099: mmd.mmdWb (a + 15, bb[o + 15]);
9100: a += 16;
9101: o += 16;
9102: }
9103: s += 16;
9104: }
9105: for (int i = 0; i < s; i++) {
9106: mmd.mmdWb (a + i, bb[o + i]);
9107: }
9108: a += s;
9109: o += s;
9110: r = BUS_PAGE_SIZE;
9111: }
9112: }
9113: }
9114:
9115:
9116:
9117: public static void busVb (int a, int d) {
9118: try {
9119: if (DataBreakPoint.DBP_ON) {
9120: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9121: } else {
9122: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9123: }
9124: } catch (M68kException e) {
9125: }
9126: }
9127:
9128:
9129:
9130: public static void busVw (int a, int d) {
9131: try {
9132: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9133: if (DataBreakPoint.DBP_ON) {
9134: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9135: } else {
9136: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9137: }
9138: }
9139: } catch (M68kException e) {
9140: }
9141: }
9142:
9143:
9144:
9145: public static void busVl (int a, int d) {
9146: try {
9147: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9148: if (DataBreakPoint.DBP_ON) {
9149: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9150: } else {
9151: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9152: }
9153: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9154: int a2 = a + 2;
9155: MemoryMappedDevice mmd;
9156: MemoryMappedDevice mmd2;
9157: if (DataBreakPoint.DBP_ON) {
9158: mmd = (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS];
9159: mmd2 = (regSRS != 0 ? busSuperMap : busUserMap)[a2 >>> BUS_PAGE_BITS];
9160: } else {
9161: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9162: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9163: }
9164: if (mmd == mmd2) {
9165: mmd.mmdWl (a, d);
9166: } else {
9167: mmd.mmdWw (a, d >> 16);
9168: mmd2.mmdWw (a2, d);
9169: }
9170: }
9171: } catch (M68kException e) {
9172: }
9173: }
9174:
9175:
9176:
9177:
9178:
9179: public static final int SVS_AREASET = 0x00e86001;
9180:
9181:
9182:
9183:
9184:
9185:
9186:
9187:
9188:
9189: public static void svsInit () {
9190: }
9191:
9192:
9193:
9194:
9195:
9196:
9197:
9198:
9199:
9200:
9201:
9202:
9203:
9204:
9205:
9206:
9207:
9208:
9209:
9210:
9211:
9212:
9213:
9214:
9215:
9216:
9217:
9218:
9219:
9220:
9221:
9222:
9223:
9224:
9225:
9226: public static boolean sysNMIFlag;
9227:
9228:
9229:
9230: public static void sysInit () {
9231: sysNMIFlag = false;
9232: }
9233:
9234:
9235:
9236:
9237:
9238:
9239: public static int sysAcknowledge () {
9240: return M68kException.M6E_LEVEL_7_INTERRUPT_AUTOVECTOR;
9241: }
9242:
9243:
9244:
9245:
9246: public static void sysDone () {
9247: if (sysNMIFlag) {
9248: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9249: }
9250: }
9251:
9252:
9253:
9254: public static void sysInterrupt () {
9255: sysNMIFlag = true;
9256: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9257: }
9258:
9259:
9260:
9261: public static void sysResetNMI () {
9262: sysNMIFlag = false;
9263: }
9264:
9265:
9266:
9267:
9268:
9269:
9270: public static final int EB2_SPC_REQUEST = 0x4000;
9271: public static final int EB2_SPC_VECTOR = 0xf6;
9272:
9273:
9274:
9275: public static int eb2Request;
9276:
9277:
9278:
9279: public static void eb2Reset () {
9280: eb2Request = 0;
9281: }
9282:
9283:
9284:
9285:
9286:
9287: public static void eb2Interrupt (int mask) {
9288: eb2Request |= mask;
9289: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9290: }
9291:
9292:
9293:
9294:
9295:
9296:
9297:
9298: public static int eb2Acknowledge () {
9299: if ((eb2Request & EB2_SPC_REQUEST) != 0) {
9300: eb2Request &= ~EB2_SPC_REQUEST;
9301: return EB2_SPC_VECTOR;
9302: }
9303: return 0;
9304: }
9305:
9306:
9307:
9308:
9309:
9310: public static void eb2Done () {
9311: if (eb2Request != 0) {
9312: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9313: }
9314: }
9315:
9316:
9317:
9318:
9319:
9320:
9321:
9322:
9323:
9324:
9325:
9326:
9327:
9328:
9329:
9330:
9331:
9332:
9333:
9334:
9335:
9336:
9337:
9338:
9339:
9340:
9341:
9342:
9343:
9344:
9345:
9346:
9347:
9348:
9349:
9350:
9351:
9352:
9353:
9354:
9355:
9356:
9357:
9358:
9359:
9360:
9361:
9362:
9363:
9364:
9365:
9366:
9367:
9368:
9369:
9370:
9371:
9372:
9373:
9374:
9375:
9376:
9377:
9378:
9379: public static final int BNK_SIZE = 1024 * 1024 * 32;
9380: public static byte[] bnkMemory;
9381: public static int bnkPageStart;
9382: public static boolean bnkOn;
9383:
9384: public static void bnkInit () {
9385: bnkMemory = new byte[BNK_SIZE];
9386: byte[] array = Settings.sgsGetData ("bankdata");
9387: if (array.length != 0) {
9388: System.arraycopy (array, 0, bnkMemory, 0, Math.min (array.length, BNK_SIZE));
9389: }
9390: bnkPageStart = 0;
9391:
9392: bnkOn = false;
9393: }
9394:
9395: public static void bnkTini () {
9396: Settings.sgsPutData ("bankdata", bnkMemory, 0, BNK_SIZE);
9397: }
9398:
9399:
9400:
9401:
9402:
9403:
9404:
9405: public static ExpressionEvaluator fpuMotherboardCoprocessor;
9406: public static ExpressionEvaluator fpuOnChipFPU;
9407: public static ExpressionEvaluator fpuBox;
9408:
9409:
9410: public static EFPBox fpuCoproboard1;
9411: public static EFPBox fpuCoproboard2;
9412:
9413:
9414: public static EFPBox.EFP[] fpuFPn;
9415:
9416:
9417:
9418: public static final int FPU_FPCR_BSUN = 0b00000000_00000000_10000000_00000000;
9419: public static final int FPU_FPCR_SNAN = 0b00000000_00000000_01000000_00000000;
9420: public static final int FPU_FPCR_OPERR = 0b00000000_00000000_00100000_00000000;
9421: public static final int FPU_FPCR_OVFL = 0b00000000_00000000_00010000_00000000;
9422: public static final int FPU_FPCR_UNFL = 0b00000000_00000000_00001000_00000000;
9423: public static final int FPU_FPCR_DZ = 0b00000000_00000000_00000100_00000000;
9424: public static final int FPU_FPCR_INEX2 = 0b00000000_00000000_00000010_00000000;
9425: public static final int FPU_FPCR_INEX1 = 0b00000000_00000000_00000001_00000000;
9426:
9427:
9428: public static final int FPU_FPCR_PE = 0b00000000_00000000_00000000_00000000;
9429: public static final int FPU_FPCR_PS = 0b00000000_00000000_00000000_01000000;
9430: public static final int FPU_FPCR_PD = 0b00000000_00000000_00000000_10000000;
9431:
9432: public static final int FPU_FPCR_RN = 0b00000000_00000000_00000000_00000000;
9433: public static final int FPU_FPCR_RZ = 0b00000000_00000000_00000000_00010000;
9434: public static final int FPU_FPCR_RM = 0b00000000_00000000_00000000_00100000;
9435: public static final int FPU_FPCR_RP = 0b00000000_00000000_00000000_00110000;
9436:
9437:
9438:
9439: public static final int FPU_FPSR_N = 0b00001000_00000000_00000000_00000000;
9440: public static final int FPU_FPSR_Z = 0b00000100_00000000_00000000_00000000;
9441: public static final int FPU_FPSR_I = 0b00000010_00000000_00000000_00000000;
9442: public static final int FPU_FPSR_NAN = 0b00000001_00000000_00000000_00000000;
9443:
9444: public static final int FPU_FPSR_S = 0b00000000_10000000_00000000_00000000;
9445: public static final int FPU_FPSR_QUOTIENT = 0b00000000_01111111_00000000_00000000;
9446:
9447: public static final int FPU_FPSR_EXC_BSUN = 0b00000000_00000000_10000000_00000000;
9448: public static final int FPU_FPSR_EXC_SNAN = 0b00000000_00000000_01000000_00000000;
9449: public static final int FPU_FPSR_EXC_OPERR = 0b00000000_00000000_00100000_00000000;
9450: public static final int FPU_FPSR_EXC_OVFL = 0b00000000_00000000_00010000_00000000;
9451: public static final int FPU_FPSR_EXC_UNFL = 0b00000000_00000000_00001000_00000000;
9452: public static final int FPU_FPSR_EXC_DZ = 0b00000000_00000000_00000100_00000000;
9453: public static final int FPU_FPSR_EXC_INEX2 = 0b00000000_00000000_00000010_00000000;
9454: public static final int FPU_FPSR_EXC_INEX1 = 0b00000000_00000000_00000001_00000000;
9455:
9456: public static final int FPU_FPSR_AEXC_IOP = 0b00000000_00000000_00000000_10000000;
9457: public static final int FPU_FPSR_AEXC_OVFL = 0b00000000_00000000_00000000_01000000;
9458: public static final int FPU_FPSR_AEXC_UNFL = 0b00000000_00000000_00000000_00100000;
9459: public static final int FPU_FPSR_AEXC_DZ = 0b00000000_00000000_00000000_00010000;
9460: public static final int FPU_FPSR_AEXC_INEX = 0b00000000_00000000_00000000_00001000;
9461:
9462:
9463:
9464:
9465:
9466:
9467:
9468: public static final int[] FPU_FPSR_EXC_TO_AEXC = new int[256];
9469:
9470:
9471:
9472:
9473:
9474:
9475:
9476:
9477:
9478:
9479:
9480:
9481:
9482:
9483:
9484:
9485:
9486:
9487:
9488:
9489:
9490:
9491:
9492:
9493: public static final boolean[] FPU_CCMAP_882 = {
9494:
9495:
9496: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9497: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9498: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9499: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9500: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9501: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9502: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9503: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9504: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9505: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9506: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9507: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9508: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9509: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9510: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9511: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9512:
9513:
9514: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9515: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9516: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9517: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9518: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9519: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9520: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9521: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9522: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9523: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9524: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9525: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9526: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9527: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9528: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9529: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9530:
9531: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9532: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9533: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9534: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9535: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9536: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9537: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9538: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9539: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9540: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9541: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9542: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9543: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9544: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9545: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9546: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9547:
9548: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9549: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9550: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9551: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9552: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9553: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9554: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9555: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9556: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9557: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9558: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9559: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9560: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9561: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9562: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9563: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9564: };
9565:
9566:
9567:
9568:
9569:
9570:
9571:
9572: public static final boolean[] FPU_CCMAP_060 = {
9573:
9574:
9575: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9576: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9577: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9578: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9579: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9580: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9581: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9582: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9583: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9584: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9585: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9586: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9587: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9588: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9589: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9590: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9591:
9592:
9593: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9594: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9595: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9596: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9597: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9598: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9599: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9600: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9601: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9602: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9603: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9604: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9605: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9606: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9607: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9608: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9609:
9610: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9611: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9612: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9613: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9614: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9615: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9616: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9617: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9618: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9619: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9620: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9621: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9622: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9623: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9624: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9625: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9626:
9627: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9628: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9629: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9630: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9631: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9632: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9633: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9634: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9635: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9636: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9637: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9638: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9639: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9640: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9641: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9642: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9643: };
9644:
9645:
9646:
9647:
9648: public static void fpuInit () {
9649: for (int i = 0; i < 256; i++) {
9650: 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) |
9651: ((i << 8 & FPU_FPSR_EXC_OVFL) != 0 ? FPU_FPSR_AEXC_OVFL : 0) |
9652: ((i << 8 & (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2)) == (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2) ? FPU_FPSR_AEXC_UNFL : 0) |
9653: ((i << 8 & FPU_FPSR_EXC_DZ) != 0 ? FPU_FPSR_AEXC_DZ : 0) |
9654: ((i << 8 & (FPU_FPSR_EXC_OVFL | FPU_FPSR_EXC_INEX2 | FPU_FPSR_EXC_INEX1)) != 0 ? FPU_FPSR_AEXC_INEX : 0));
9655: }
9656:
9657: fpuMotherboardCoprocessor = new ExpressionEvaluator ();
9658:
9659: fpuOnChipFPU = new ExpressionEvaluator ();
9660:
9661: fpuBox = currentMPU < Model.MPU_MC68LC040 ? fpuMotherboardCoprocessor : fpuOnChipFPU;
9662:
9663: fpuFPn = fpuBox.epbFPn;
9664:
9665: fpuCoproboard1 = new EFPBox ();
9666: fpuCoproboard2 = new EFPBox ();
9667: }
9668:
9669:
9670:
9671:
9672:
9673:
9674: public static final boolean DBG_ORI_BYTE_ZERO_D0 = true;
9675:
9676: public static boolean dbgHexSelected;
9677: public static int dbgHexValue;
9678: public static int dbgSupervisorMode;
9679: public static JPopupMenu dbgPopupMenu;
9680: public static JMenu dbgPopupIBPMenu;
9681: public static SpinnerNumberModel dbgPopupIBPCurrentModel;
9682: public static int dbgPopupIBPCurrentValue;
9683: public static SpinnerNumberModel dbgPopupIBPThresholdModel;
9684: public static int dbgPopupIBPThresholdValue;
9685: public static JMenuItem dbgPopupIBPClearMenuItem;
9686: public static JMenu dbgPopupHexMenu;
9687: public static JMenuItem dbgPopupDisMenuItem;
9688: public static JMenuItem dbgPopupMemMenuItem;
9689: public static JMenuItem dbgPopupCopyMenuItem;
9690: public static JMenuItem dbgPopupSelectAllMenuItem;
9691: public static JTextArea dbgPopupTextArea;
9692: public static int dbgEventMask;
9693: public static boolean dbgStopOnError;
9694: public static boolean dbgOriByteZeroD0;
9695: public static boolean dbgStopAtStart;
9696:
9697:
9698:
9699: public static final char[] DBG_SPACES = (
9700:
9701:
9702: " ").toCharArray ();
9703:
9704: public static final int DBG_DRP_VISIBLE_MASK = 1;
9705: public static final int DBG_DDP_VISIBLE_MASK = 2;
9706: public static final int DBG_DMP_VISIBLE_MASK = 4;
9707: public static final int DBG_BLG_VISIBLE_MASK = 8;
9708: public static final int DBG_PFV_VISIBLE_MASK = 16;
9709: public static final int DBG_RBP_VISIBLE_MASK = 32;
9710: public static final int DBG_DBP_VISIBLE_MASK = 64;
9711: public static final int DBG_SMT_VISIBLE_MASK = 128;
9712: public static final int DBG_ATW_VISIBLE_MASK = 256;
9713: public static final int DBG_PAA_VISIBLE_MASK = 512;
9714: public static final int DBG_RTL_VISIBLE_MASK = 1024;
9715: public static final int DBG_SPV_VISIBLE_MASK = 2048;
9716: public static final int DBG_PLV_VISIBLE_MASK = 4096;
9717: public static final int DBG_ACM_VISIBLE_MASK = 8192;
9718: public static int dbgVisibleMask;
9719:
9720:
9721:
9722: public static void dbgInit () {
9723: dbgVisibleMask = 0;
9724: dbgHexSelected = false;
9725: dbgHexValue = 0;
9726: dbgSupervisorMode = 1;
9727: dbgPopupMenu = null;
9728: dbgPopupDisMenuItem = null;
9729: dbgPopupMemMenuItem = null;
9730: dbgPopupCopyMenuItem = null;
9731: dbgPopupSelectAllMenuItem = null;
9732: dbgPopupIBPMenu = null;
9733: dbgPopupIBPCurrentModel = null;
9734: dbgPopupIBPCurrentValue = 0;
9735: dbgPopupIBPThresholdModel = null;
9736: dbgPopupIBPThresholdValue = 0;
9737: dbgPopupHexMenu = null;
9738: dbgPopupTextArea = null;
9739: dbgEventMask = 0;
9740: dbgStopOnError = false;
9741: if (DBG_ORI_BYTE_ZERO_D0) {
9742: dbgOriByteZeroD0 = false;
9743: }
9744: dbgStopAtStart = false;
9745: }
9746:
9747:
9748:
9749: public static void dbgMakePopup () {
9750:
9751:
9752: ActionListener popupActionListener = new ActionListener () {
9753: @Override public void actionPerformed (ActionEvent ae) {
9754: switch (ae.getActionCommand ()) {
9755: case "Disassemble":
9756: DisassembleList.ddpBacktraceRecord = -1L;
9757: DisassembleList.ddpOpen (dbgHexValue, dbgSupervisorMode, false);
9758: break;
9759: case "Memory Dump":
9760: MemoryDumpList.dmpOpen (dbgHexValue, dbgSupervisorMode != 0 ? 5 : 1, false);
9761: break;
9762: case "Run to Here":
9763: if (InstructionBreakPoint.IBP_ON) {
9764: if (mpuTask == null) {
9765: InstructionBreakPoint.ibpInstant (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
9766: mpuStart ();
9767: }
9768: }
9769: break;
9770: case "Set Breakpoint":
9771: if (InstructionBreakPoint.IBP_ON) {
9772: InstructionBreakPoint.ibpPut (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode, dbgPopupIBPCurrentValue, dbgPopupIBPThresholdValue, null);
9773: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
9774: }
9775: break;
9776: case "Clear Breakpoint":
9777: if (InstructionBreakPoint.IBP_ON) {
9778: InstructionBreakPoint.ibpRemove (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
9779: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
9780: }
9781: break;
9782: case "Copy":
9783: dbgCopy ();
9784: break;
9785: case "Select All":
9786: dbgSelectAll ();
9787: break;
9788: }
9789: }
9790: };
9791: dbgPopupMenu = ComponentFactory.createPopupMenu (
9792: dbgPopupIBPMenu =
9793: InstructionBreakPoint.IBP_ON ?
9794: ComponentFactory.createMenu (
9795: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
9796: Multilingual.mlnText (ComponentFactory.createMenuItem ("Run to Here", 'R', popupActionListener), "ja", "ここまで実行"),
9797: ComponentFactory.createHorizontalSeparator (),
9798: Multilingual.mlnText (ComponentFactory.createMenuItem ("Set Breakpoint", 'S', popupActionListener), "ja", "ブレークポイントを設定"),
9799: ComponentFactory.createHorizontalBox (
9800: Box.createHorizontalStrut (7),
9801: Box.createHorizontalGlue (),
9802: ComponentFactory.setPreferredSize (
9803: Multilingual.mlnText (ComponentFactory.createLabel ("current"), "ja", "現在値"),
9804: 60, 16),
9805: ComponentFactory.createNumberSpinner (dbgPopupIBPCurrentModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
9806: @Override public void stateChanged (ChangeEvent ce) {
9807: dbgPopupIBPCurrentValue = dbgPopupIBPCurrentModel.getNumber ().intValue ();
9808: }
9809: }),
9810: Box.createHorizontalGlue ()
9811: ),
9812: ComponentFactory.createHorizontalBox (
9813: Box.createHorizontalStrut (7),
9814: Box.createHorizontalGlue (),
9815: ComponentFactory.setPreferredSize (
9816: Multilingual.mlnText (ComponentFactory.createLabel ("threshold"), "ja", "閾値"),
9817: 60, 16),
9818: ComponentFactory.createNumberSpinner (dbgPopupIBPThresholdModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
9819: @Override public void stateChanged (ChangeEvent ce) {
9820: dbgPopupIBPThresholdValue = dbgPopupIBPThresholdModel.getNumber ().intValue ();
9821: }
9822: }),
9823: Box.createHorizontalGlue ()
9824: ),
9825: dbgPopupIBPClearMenuItem =
9826: Multilingual.mlnText (ComponentFactory.createMenuItem ("Clear Breakpoint", 'C', popupActionListener), "ja", "ブレークポイントを消去")
9827: ) :
9828: null,
9829: dbgPopupHexMenu =
9830: ComponentFactory.createMenu (
9831: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
9832: dbgPopupDisMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble", 'D', popupActionListener), "ja", "逆アセンブル"),
9833: dbgPopupMemMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory Dump", 'M', popupActionListener), "ja", "メモリダンプ")
9834: ),
9835: dbgPopupCopyMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Copy", 'C', popupActionListener), "ja", "コピー"),
9836: dbgPopupSelectAllMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Select All", 'A', popupActionListener), "ja", "すべて選択")
9837: );
9838:
9839: }
9840:
9841:
9842:
9843: public static void dbgShowPopup (MouseEvent me, JTextArea textArea, boolean dis) {
9844: dbgEventMask++;
9845: int x = me.getX ();
9846: int y = me.getY ();
9847:
9848: int p = textArea.viewToModel2D (me.getPoint ());
9849: DisassembleList.ddpPopupAddress = -1;
9850: if (dis) {
9851: int i = Arrays.binarySearch (DisassembleList.ddpSplitArray, 1, DisassembleList.ddpItemCount, p + 1);
9852: i = (i >> 31 ^ i) - 1;
9853: DisassembleList.ddpPopupAddress = DisassembleList.ddpAddressArray[i];
9854: }
9855: int start = textArea.getSelectionStart ();
9856: int end = textArea.getSelectionEnd ();
9857: String text = textArea.getText ();
9858: int length = text.length ();
9859: if ((start == end ||
9860: p < start || end <= p) &&
9861: 0 <= p && p < length && isWord (text.charAt (p))) {
9862:
9863: for (start = p; 0 < start && isWord (text.charAt (start - 1)); start--) {
9864: }
9865: for (end = p + 1; end < length && isWord (text.charAt (end)); end++) {
9866: }
9867: textArea.select (start, end);
9868: }
9869: dbgHexSelected = false;
9870: if (start < end) {
9871: textArea.requestFocusInWindow ();
9872:
9873:
9874:
9875:
9876:
9877: dbgHexValue = 0;
9878: int n = 0;
9879: for (int i = start; i < end; i++) {
9880: int t;
9881: if ((t = Character.digit (text.charAt (i), 16)) >= 0) {
9882: dbgHexValue = dbgHexValue << 4 | t;
9883: if (n >= 8 ||
9884: i + 1 >= end || (t = Character.digit (text.charAt (i + 1), 16)) < 0) {
9885: n = 0;
9886: break;
9887: }
9888: dbgHexValue = dbgHexValue << 4 | t;
9889: n += 2;
9890: i++;
9891: } else if (isWord (text.charAt (i))) {
9892: n = 0;
9893: break;
9894: }
9895: }
9896: dbgHexSelected = n > 0;
9897: try {
9898:
9899: Rectangle r = textArea.modelToView2D (start).getBounds ();
9900:
9901: Rectangle s = textArea.modelToView2D (end - 1).getBounds ();
9902: if (r.y == s.y) {
9903:
9904: y = r.y + r.height;
9905: }
9906: } catch (BadLocationException ble) {
9907: }
9908: }
9909:
9910: if (InstructionBreakPoint.IBP_ON) {
9911: if (dis && mpuTask == null && DisassembleList.ddpPopupAddress != -1) {
9912: ComponentFactory.setText (dbgPopupIBPMenu, fmtHex8 (DisassembleList.ddpPopupAddress));
9913: TreeMap<Integer,InstructionBreakPoint.InstructionBreakRecord> pointTable = InstructionBreakPoint.ibpPointTable;
9914: InstructionBreakPoint.InstructionBreakRecord r = pointTable.get (DisassembleList.ddpPopupAddress);
9915: if (r != null) {
9916: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = r.ibrValue));
9917: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = r.ibrThreshold));
9918: dbgPopupIBPClearMenuItem.setEnabled (true);
9919: } else {
9920: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = 0));
9921: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = 0));
9922: dbgPopupIBPClearMenuItem.setEnabled (false);
9923: }
9924: ComponentFactory.setVisible (dbgPopupIBPMenu, true);
9925: } else {
9926: ComponentFactory.setVisible (dbgPopupIBPMenu, false);
9927: }
9928: }
9929:
9930: if (dbgHexSelected) {
9931: ComponentFactory.setText (dbgPopupHexMenu, fmtHex8 (dbgHexValue));
9932: ComponentFactory.setVisible (dbgPopupHexMenu, true);
9933: } else {
9934: ComponentFactory.setVisible (dbgPopupHexMenu, false);
9935: }
9936:
9937: ComponentFactory.setEnabled (dbgPopupCopyMenuItem, clpClipboard != null && start < end);
9938:
9939: ComponentFactory.setEnabled (dbgPopupSelectAllMenuItem, clpClipboard != null);
9940:
9941: dbgPopupTextArea = textArea;
9942: dbgPopupMenu.show (textArea, x, y);
9943: dbgEventMask--;
9944: }
9945:
9946: public static boolean isWord (char c) {
9947: return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '_';
9948: }
9949:
9950:
9951:
9952: public static void dbgCopy () {
9953: clpCopy (dbgPopupTextArea.getSelectedText ());
9954: }
9955:
9956:
9957:
9958: public static void dbgSelectAll () {
9959: if (clpClipboard != null) {
9960:
9961: dbgEventMask++;
9962: dbgPopupTextArea.selectAll ();
9963: dbgPopupTextArea.requestFocusInWindow ();
9964: dbgEventMask--;
9965: }
9966: }
9967:
9968:
9969:
9970:
9971: public static void dbgUpdate () {
9972: if ((dbgVisibleMask & DBG_DRP_VISIBLE_MASK) != 0) {
9973: RegisterList.drpUpdate ();
9974: }
9975: if (ProgramFlowVisualizer.PFV_ON) {
9976: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
9977: if (ProgramFlowVisualizer.pfvTimer == 0) {
9978: ProgramFlowVisualizer.pfvUpdate ();
9979: } else {
9980: ProgramFlowVisualizer.pfvTimer--;
9981: }
9982: }
9983: }
9984: if (RasterBreakPoint.RBP_ON) {
9985: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
9986: if (RasterBreakPoint.rbpTimer == 0) {
9987: RasterBreakPoint.rbpUpdateFrame ();
9988: } else {
9989: RasterBreakPoint.rbpTimer--;
9990: }
9991: }
9992: }
9993: if (ScreenModeTest.SMT_ON) {
9994: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
9995: if (ScreenModeTest.smtTimer == 0) {
9996: ScreenModeTest.smtUpdateFrame ();
9997: } else {
9998: ScreenModeTest.smtTimer--;
9999: }
10000: }
10001: }
10002: if (RootPointerList.RTL_ON) {
10003: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
10004: if (RootPointerList.rtlTimer == 0) {
10005: RootPointerList.rtlTimer = RootPointerList.RTL_INTERVAL - 1;
10006: RootPointerList.rtlUpdateFrame ();
10007: } else {
10008: RootPointerList.rtlTimer--;
10009: }
10010: }
10011: }
10012: if (SpritePatternViewer.SPV_ON) {
10013: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
10014: if (SpritePatternViewer.spvTimer == 0) {
10015: SpritePatternViewer.spvTimer = SpritePatternViewer.SPV_INTERVAL - 1;
10016: SpritePatternViewer.spvUpdateFrame ();
10017: } else {
10018: SpritePatternViewer.spvTimer--;
10019: }
10020: }
10021: }
10022: if (PaletteViewer.PLV_ON) {
10023: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
10024: if (PaletteViewer.plvTimer == 0) {
10025: PaletteViewer.plvTimer = PaletteViewer.PLV_INTERVAL - 1;
10026: PaletteViewer.plvUpdateFrame ();
10027: } else {
10028: PaletteViewer.plvTimer--;
10029: }
10030: }
10031: }
10032: if (ATCMonitor.ACM_ON) {
10033: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
10034: if (ATCMonitor.acmTimer == 0) {
10035: ATCMonitor.acmTimer = ATCMonitor.ACM_INTERVAL - 1;
10036: ATCMonitor.acmUpdateFrame ();
10037: } else {
10038: ATCMonitor.acmTimer--;
10039: }
10040: }
10041: }
10042: }
10043:
10044:
10045:
10046:
10047:
10048:
10049:
10050:
10051:
10052:
10053:
10054:
10055:
10056:
10057:
10058:
10059:
10060:
10061:
10062:
10063:
10064:
10065: public static boolean dbgDoStopOnError () {
10066: if (MainMemory.mmrHumanVersion <= 0) {
10067: return true;
10068: }
10069: if ((regOC & 0xff00) == 0xff00 &&
10070: M68kException.m6eNumber == M68kException.M6E_PRIVILEGE_VIOLATION) {
10071: return false;
10072: }
10073: String message = (
10074: M68kException.m6eNumber < 0 ?
10075: fmtHex8 (new StringBuilder ("breaked").append (" at "), regPC0).toString () :
10076: M68kException.m6eNumber <= M68kException.M6E_ADDRESS_ERROR ?
10077: fmtHex8 (fmtHex8 (new StringBuilder ("ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10078: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10079: .append (" at "), regPC0).toString () :
10080: fmtHex8 (new StringBuilder (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10081: .append (" at "), regPC0).toString ()
10082: );
10083: System.out.println (message);
10084: if (!(M68kException.m6eNumber == M68kException.M6E_ACCESS_FAULT &&
10085: 0x0000e100 <= regPC0 && regPC0 < 0x0000e500)) {
10086: mpuStop (message);
10087: return true;
10088: }
10089: return false;
10090: }
10091:
10092:
10093:
10094: public static void dbgDoubleBusFault () {
10095: String message =
10096: fmtHex8 (fmtHex8 (new StringBuilder ("FATAL ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10097: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10098: .append (" at "), regPC0).toString ();
10099: System.out.println (message);
10100: mpuStop (message);
10101: }
10102:
10103:
10104:
10105:
10106:
10107:
10108: public static final HashMap<String,byte[]> rscResourceCache = new HashMap<String,byte[]> ();
10109:
10110:
10111:
10112:
10113:
10114:
10115: public static byte[] rscGetResource (String name, int... sizes) {
10116: byte[] array = rscResourceCache.get (name);
10117: if (array != null) {
10118: return array;
10119: }
10120: array = new byte[1024 * 64];
10121: int size = 0;
10122: try (BufferedInputStream bis = new BufferedInputStream (XEiJ.class.getResourceAsStream ("../data/" + name))) {
10123: for (;;) {
10124: if (size == array.length) {
10125: byte[] newArray = new byte[array.length * 2];
10126: System.arraycopy (array, 0, newArray, 0, size);
10127: array = newArray;
10128: }
10129: int step = bis.read (array, size, array.length - size);
10130: if (step == -1) {
10131: break;
10132: }
10133: size += step;
10134: }
10135: if (size < array.length) {
10136: byte[] newArray = new byte[size];
10137: System.arraycopy (array, 0, newArray, 0, size);
10138: array = newArray;
10139: }
10140: boolean fit = sizes.length == 0;
10141: if (!fit) {
10142: for (int i = 0; i < sizes.length; i++) {
10143: if (size == sizes[i]) {
10144: fit = true;
10145: break;
10146: }
10147: }
10148: }
10149: if (fit) {
10150: System.out.println (Multilingual.mlnJapanese ?
10151: name + " を読み込みました" :
10152: name + " was read");
10153: rscResourceCache.put (name, array);
10154: return array;
10155: }
10156: System.out.println (Multilingual.mlnJapanese ?
10157: name + " のサイズが違います" :
10158: name + " has wrong size");
10159: return null;
10160: } catch (IOException ioe) {
10161: }
10162:
10163: System.out.println (Multilingual.mlnJapanese ?
10164: name + " を読み込めません" :
10165: name + " cannot be read");
10166: return null;
10167: }
10168:
10169:
10170:
10171: public static String rscGetResourceText (String name) {
10172: return rscGetResourceText (name, "UTF-8");
10173: }
10174: public static String rscGetResourceText (String name, String charset) {
10175: byte[] array = rscGetResource (name);
10176: if (name != null) {
10177: try {
10178: return new String (array, charset);
10179: } catch (UnsupportedEncodingException uee) {
10180: }
10181: }
10182: return "";
10183: }
10184:
10185: public static final Pattern RSC_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10186: public static String rscLastFileName = null;
10187:
10188:
10189:
10190:
10191:
10192:
10193: public static byte[] rscGetFile (String names, int... sizes) {
10194: for (String name : names.split (",")) {
10195: name = name.trim ();
10196: if (name.length () == 0 || name.equalsIgnoreCase ("none")) {
10197: continue;
10198: }
10199: String[] zipSplittedName = RSC_ZIP_SEPARATOR.split (name, 2);
10200: InputStream is = null;
10201: if (zipSplittedName.length < 2) {
10202: File file = new File (name);
10203: if (file.isFile ()) {
10204: try {
10205: is = new FileInputStream (file);
10206: } catch (IOException ioe) {
10207: }
10208: } else {
10209: System.out.println (Multilingual.mlnJapanese ?
10210: name + " がありません" :
10211: name + " does not exist");
10212: continue;
10213: }
10214: } else {
10215: String zipName = zipSplittedName[0];
10216: String entryName = zipSplittedName[1];
10217: if (new File (zipName).isFile ()) {
10218: try {
10219: ZipFile zipFile = new ZipFile (zipName);
10220: ZipEntry zipEntry = zipFile.getEntry (entryName);
10221: if (zipEntry != null) {
10222: is = zipFile.getInputStream (zipEntry);
10223: } else {
10224: System.out.println (Multilingual.mlnJapanese ?
10225: zipName + " に " + zipEntry + " がありません" :
10226: zipName + " does not include " + zipEntry);
10227: }
10228: } catch (IOException ioe) {
10229: }
10230: } else {
10231: System.out.println (Multilingual.mlnJapanese ?
10232: zipName + " がありません" :
10233: zipName + " does not exist");
10234: continue;
10235: }
10236: }
10237: if (is != null) {
10238: try {
10239: is = new BufferedInputStream (is);
10240: if (name.toLowerCase ().endsWith (".gz")) {
10241: is = new GZIPInputStream (is);
10242: }
10243: byte[] array = new byte[1024 * 64];
10244: int size = 0;
10245: for (;;) {
10246: if (size == array.length) {
10247: byte[] newArray = new byte[array.length * 2];
10248: System.arraycopy (array, 0, newArray, 0, size);
10249: array = newArray;
10250: }
10251: int step = is.read (array, size, array.length - size);
10252: if (step == -1) {
10253: break;
10254: }
10255: size += step;
10256: }
10257: is.close ();
10258: is = null;
10259: if (size < array.length) {
10260: byte[] newArray = new byte[size];
10261: System.arraycopy (array, 0, newArray, 0, size);
10262: array = newArray;
10263: }
10264: boolean fit = sizes.length == 0;
10265: if (!fit) {
10266: for (int i = 0; i < sizes.length; i++) {
10267: if (size == sizes[i]) {
10268: fit = true;
10269: break;
10270: }
10271: }
10272: }
10273: if (fit) {
10274: System.out.println (Multilingual.mlnJapanese ?
10275: name + " を読み込みました" :
10276: name + " was read");
10277: rscLastFileName = name;
10278: return array;
10279: }
10280: System.out.println (Multilingual.mlnJapanese ?
10281: name + " のサイズが違います" :
10282: name + " has wrong size");
10283: continue;
10284: } catch (IOException ioe) {
10285: }
10286: if (is != null) {
10287: try {
10288: is.close ();
10289: is = null;
10290: } catch (IOException ioe) {
10291: }
10292: }
10293: }
10294: System.out.println (Multilingual.mlnJapanese ?
10295: name + " を読み込めません" :
10296: name + " cannot be read");
10297: }
10298:
10299:
10300:
10301: return null;
10302: }
10303:
10304:
10305:
10306:
10307: public static String rscGetTextFile (String name) {
10308: return rscGetTextFile (name, "UTF-8");
10309: }
10310: public static String rscGetTextFile (String name, String charset) {
10311: byte[] array = rscGetFile (name);
10312: if (array != null) {
10313: try {
10314: return new String (array, charset);
10315: } catch (UnsupportedEncodingException uee) {
10316: }
10317: }
10318: return "";
10319: }
10320:
10321:
10322:
10323: public static final int RSC_A_MASK = 1;
10324: public static final int RSC_R_MASK = 2;
10325: public static final int RSC_I_MASK = 4;
10326: public static final String RSC_A_EN = "Abort";
10327: public static final String RSC_R_EN = "Retry";
10328: public static final String RSC_I_EN = "Ignore";
10329: public static final String RSC_A_JA = "中止";
10330: public static final String RSC_R_JA = "再実行";
10331: public static final String RSC_I_JA = "無視";
10332: public static final String[][] RSC_EN_OPTIONS = {
10333: { RSC_A_EN },
10334: { RSC_A_EN },
10335: { RSC_R_EN },
10336: { RSC_A_EN, RSC_R_EN },
10337: { RSC_I_EN },
10338: { RSC_A_EN, RSC_I_EN },
10339: { RSC_R_EN, RSC_I_EN },
10340: { RSC_A_EN, RSC_R_EN, RSC_I_EN },
10341: };
10342: public static final String[][] RSC_JA_OPTIONS = {
10343: { RSC_A_JA },
10344: { RSC_A_JA },
10345: { RSC_R_JA },
10346: { RSC_A_JA, RSC_R_JA },
10347: { RSC_I_JA },
10348: { RSC_A_JA, RSC_I_JA },
10349: { RSC_R_JA, RSC_I_JA },
10350: { RSC_A_JA, RSC_R_JA, RSC_I_JA },
10351: };
10352: public static int rscShowError (String message, int mask) {
10353: System.out.println (message);
10354: mask &= RSC_A_MASK | RSC_R_MASK | RSC_I_MASK;
10355: if (mask == 0) {
10356: mask = RSC_A_MASK;
10357: }
10358: String[] options = (Multilingual.mlnJapanese ? RSC_JA_OPTIONS : RSC_EN_OPTIONS)[mask];
10359: int def = Integer.numberOfTrailingZeros (mask);
10360: pnlExitFullScreen (true);
10361: int bit = JOptionPane.showOptionDialog (
10362: null,
10363: message,
10364: Multilingual.mlnJapanese ? "ファイル操作エラー" : "File operation error",
10365: JOptionPane.YES_NO_CANCEL_OPTION,
10366: JOptionPane.ERROR_MESSAGE,
10367: null,
10368: options,
10369: options[def]);
10370: if (bit == JOptionPane.CLOSED_OPTION) {
10371: bit = def;
10372: }
10373: return 1 << bit;
10374: }
10375:
10376:
10377:
10378:
10379:
10380:
10381: public static boolean rscPutTextFile (String name, String string) {
10382: return rscPutTextFile (name, string, "UTF-8");
10383: }
10384: public static boolean rscPutTextFile (String name, ArrayList<String> strings) {
10385: return rscPutTextFile (name, strings, "UTF-8");
10386: }
10387: public static boolean rscPutTextFile (String name, String string, String charset) {
10388: ArrayList<String> strings = new ArrayList<String> ();
10389: strings.add (string);
10390: return rscPutTextFile (name, strings, charset);
10391: }
10392: public static boolean rscPutTextFile (String name, ArrayList<String> strings, String charset) {
10393: String nameTmp = name + ".tmp";
10394: String nameBak = name + ".bak";
10395: File file = new File (name);
10396: File fileTmp = new File (nameTmp);
10397: File fileBak = new File (nameBak);
10398:
10399: File parentDirectory = file.getParentFile ();
10400: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10401: if (!parentDirectory.mkdirs ()) {
10402: System.out.println (parentDirectory.getPath () + (Multilingual.mlnJapanese ? " を作れません" : " cannot be created"));
10403: return false;
10404: }
10405: }
10406:
10407: if (fileTmp.exists ()) {
10408: if (!fileTmp.delete ()) {
10409: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10410: return false;
10411: }
10412: }
10413:
10414: try (BufferedWriter bw = new BufferedWriter (new FileWriter (nameTmp, Charset.forName (charset)))) {
10415: for (String string : strings) {
10416: bw.write (string);
10417: }
10418: } catch (IOException ioe) {
10419: ioe.printStackTrace ();
10420: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " に書き出せません" : " cannot be written"));
10421: return false;
10422: }
10423:
10424: boolean fileExists = file.exists ();
10425: if (fileExists) {
10426:
10427: if (fileBak.exists ()) {
10428: if (!fileBak.delete ()) {
10429: System.out.println (nameBak + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10430: return false;
10431: }
10432: }
10433:
10434: if (!file.renameTo (fileBak)) {
10435: System.out.println (name + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + nameBak + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10436: return false;
10437: }
10438: }
10439:
10440: if (!fileTmp.renameTo (file)) {
10441: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + name + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10442: return false;
10443: }
10444: if (fileExists) {
10445: System.out.println (name + (Multilingual.mlnJapanese ? " を更新しました" : " was updated"));
10446: } else {
10447: System.out.println (name + (Multilingual.mlnJapanese ? " を作りました" : " was created"));
10448: }
10449: return true;
10450: }
10451:
10452:
10453:
10454:
10455:
10456:
10457:
10458:
10459:
10460: public static boolean rscPutFile (String name, byte[] array) {
10461: return rscPutFile (name, array, 0, array.length, (long) array.length);
10462: }
10463: public static boolean rscPutFile (String name, byte[] array, int offset, int length) {
10464: return rscPutFile (name, array, offset, length, (long) length);
10465: }
10466: public static boolean rscPutFile (String name, byte[] array, int offset, int length, long longLength2) {
10467: if (RSC_ZIP_SEPARATOR.matcher (name).matches ()) {
10468:
10469: return false;
10470: }
10471: File file = new File (name);
10472: boolean fileExists = file.isFile ();
10473: if (fileExists && file.length () == longLength2) {
10474: comparison:
10475: {
10476: try (BufferedInputStream bis = new BufferedInputStream (new FileInputStream (file))) {
10477: byte[] buffer = new byte[(int) Math.min (Math.max ((long) length, longLength2 - (long) length), (long) (1024 * 1024))];
10478: int position = 0;
10479: while (position < length) {
10480: int step = bis.read (buffer, 0, Math.min (buffer.length, length - position));
10481: if (step == -1) {
10482: break comparison;
10483: }
10484: int offsetPosition = offset + position;
10485: for (int i = 0; i < step; i++) {
10486: if (buffer[i] != array[offsetPosition + i]) {
10487: break comparison;
10488: }
10489: }
10490: position += step;
10491: }
10492: long longPosition2 = (long) length;
10493: while (longPosition2 < longLength2) {
10494: int step = bis.read (buffer, 0, (int) Math.min ((long) buffer.length, longLength2 - longPosition2));
10495: if (step == -1) {
10496: break comparison;
10497: }
10498: for (int i = 0; i < step; i++) {
10499: if (buffer[i] != 0) {
10500: break comparison;
10501: }
10502: }
10503: longPosition2 += (long) step;
10504: }
10505: return true;
10506: } catch (IOException ioe) {
10507: }
10508: }
10509: }
10510: String nameTmp = name + ".tmp";
10511: File fileTmp = new File (nameTmp);
10512: String nameBak = name + ".bak";
10513: File fileBak = new File (nameBak);
10514: retry:
10515: for (;;) {
10516: File parentDirectory = file.getParentFile ();
10517: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10518: String parentName = parentDirectory.getPath ();
10519: if (parentDirectory.mkdirs ()) {
10520: System.out.println (Multilingual.mlnJapanese ?
10521: parentName + " を作りました" :
10522: parentName + " was created");
10523: } else {
10524: switch (rscShowError (Multilingual.mlnJapanese ?
10525: parentName + " を作れません" :
10526: parentName + " cannot be created",
10527: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10528: case RSC_A_MASK:
10529: break retry;
10530: case RSC_R_MASK:
10531: continue retry;
10532: }
10533: }
10534: }
10535: if (fileTmp.isFile ()) {
10536: if (!fileTmp.delete ()) {
10537: switch (rscShowError (Multilingual.mlnJapanese ?
10538: nameTmp + " を削除できません" :
10539: nameTmp + " cannot be deleted",
10540: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10541: case RSC_A_MASK:
10542: break retry;
10543: case RSC_R_MASK:
10544: continue retry;
10545: }
10546: }
10547: }
10548: try (OutputStream os = name.toLowerCase ().endsWith (".gz") ?
10549: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10550: {
10551:
10552: def.setLevel (Deflater.DEFAULT_COMPRESSION);
10553:
10554: }
10555: } :
10556: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10557:
10558: os.write (array, offset, length);
10559:
10560:
10561: if ((long) length < longLength2) {
10562: byte[] buffer = new byte[(int) Math.min (longLength2 - (long) length, (long) (1024 * 1024))];
10563: Arrays.fill (buffer, 0, buffer.length, (byte) 0);
10564: long longPosition2 = (long) length;
10565: while (longPosition2 < longLength2) {
10566: int step = (int) Math.min ((long) buffer.length, longLength2 - longPosition2);
10567: os.write (buffer, 0, step);
10568: longPosition2 += (long) step;
10569: }
10570: }
10571: } catch (IOException ioe) {
10572: switch (rscShowError (Multilingual.mlnJapanese ?
10573: nameTmp + " に書き出せません" :
10574: nameTmp + " cannot be written",
10575: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10576: case RSC_A_MASK:
10577: break retry;
10578: case RSC_R_MASK:
10579: continue retry;
10580: }
10581: }
10582: if (fileExists && file.isFile ()) {
10583: if (fileBak.isFile ()) {
10584: if (!fileBak.delete ()) {
10585: switch (rscShowError (Multilingual.mlnJapanese ?
10586: nameBak + " を削除できません" :
10587: nameBak + " cannot be deleted",
10588: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10589: case RSC_A_MASK:
10590: break retry;
10591: case RSC_R_MASK:
10592: continue retry;
10593: }
10594: }
10595: }
10596: if (!file.renameTo (fileBak)) {
10597: switch (rscShowError (Multilingual.mlnJapanese ?
10598: name + " を " + nameBak + " にリネームできません" :
10599: name + " cannot be renamed to " + nameBak,
10600: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10601: case RSC_A_MASK:
10602: break retry;
10603: case RSC_R_MASK:
10604: continue retry;
10605: }
10606: }
10607: }
10608: if (fileTmp.renameTo (file)) {
10609: if (fileExists) {
10610: System.out.println (Multilingual.mlnJapanese ?
10611: name + " を更新しました" :
10612: name + " was updated");
10613: } else {
10614: System.out.println (Multilingual.mlnJapanese ?
10615: name + " を作りました" :
10616: name + " was created");
10617: }
10618: return true;
10619: } else {
10620: switch (rscShowError (Multilingual.mlnJapanese ?
10621: nameTmp + " を " + name + " にリネームできません" :
10622: nameTmp + " cannot be renamed to " + name,
10623: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10624: case RSC_A_MASK:
10625: break retry;
10626: case RSC_R_MASK:
10627: continue retry;
10628: }
10629: }
10630: break;
10631: }
10632: if (fileExists) {
10633: System.out.println (Multilingual.mlnJapanese ?
10634: name + " を更新できません" :
10635: name + " cannot be updated");
10636: } else {
10637: System.out.println (Multilingual.mlnJapanese ?
10638: name + " を作れません" :
10639: name + " cannot be created");
10640: }
10641: return false;
10642: }
10643:
10644:
10645:
10646:
10647:
10648:
10649: public static final Pattern ISM_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10650:
10651:
10652:
10653:
10654:
10655:
10656:
10657:
10658:
10659:
10660:
10661: public static InputStream ismOpen (String name) {
10662: InputStream in = null;
10663: in = ismOpen (name, false);
10664: if (in == null && name.indexOf ('/') < 0 && name.indexOf ('\\') < 0) {
10665: in = ismOpen (name, true);
10666: }
10667: return in;
10668: }
10669: public static InputStream ismOpen (String name, boolean useGetResource) {
10670: boolean gzipped = name.toLowerCase ().endsWith (".gz");
10671: String[] zipSplittedName = ISM_ZIP_SEPARATOR.split (name, 2);
10672: String fileName = zipSplittedName[0];
10673: String zipEntryName = zipSplittedName.length < 2 ? null : zipSplittedName[1];
10674: InputStream in = null;
10675: try {
10676: if (useGetResource) {
10677: if (false) {
10678: URL url = XEiJ.class.getResource (fileName);
10679: if (url != null) {
10680: in = url.openStream ();
10681: }
10682: } else {
10683: in = XEiJ.class.getResourceAsStream (fileName);
10684: }
10685: } else {
10686: File file = new File (fileName);
10687: if (file.exists ()) {
10688: in = new FileInputStream (file);
10689: }
10690: }
10691: if (in != null && zipEntryName != null) {
10692: ZipInputStream zin = new ZipInputStream (in);
10693: in = null;
10694: ZipEntry entry;
10695: while ((entry = zin.getNextEntry ()) != null) {
10696: if (zipEntryName.equals (entry.getName ())) {
10697: in = zin;
10698: break;
10699: }
10700: }
10701: if (in == null) {
10702: System.out.println (Multilingual.mlnJapanese ? fileName + " の中に " + zipEntryName + " がありません" :
10703: zipEntryName + " does not exist in " + fileName);
10704: }
10705: }
10706: if (in != null && gzipped) {
10707: in = new GZIPInputStream (in);
10708: }
10709: if (in != null) {
10710: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " を読み込みます" :
10711: (useGetResource ? "Reading resource file " : "Reading file ") + name);
10712: return new BufferedInputStream (in);
10713: }
10714: } catch (Exception ioe) {
10715: if (prgVerbose) {
10716: prgPrintStackTraceOf (ioe);
10717: }
10718: }
10719: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " が見つかりません" :
10720: (useGetResource ? "Resource file " : "File ") + name + " is not found");
10721: return null;
10722: }
10723:
10724:
10725:
10726:
10727:
10728:
10729:
10730:
10731: public static int ismRead (InputStream in, byte[] bb, int o, int l) {
10732: try {
10733: int k = 0;
10734: while (k < l) {
10735: int t = in.read (bb, o + k, l - k);
10736: if (t < 0) {
10737: break;
10738: }
10739: k += t;
10740: }
10741: return k;
10742: } catch (IOException ioe) {
10743: if (prgVerbose) {
10744: prgPrintStackTraceOf (ioe);
10745: }
10746: }
10747: return -1;
10748: }
10749:
10750:
10751:
10752:
10753:
10754:
10755:
10756:
10757: public static int ismSkip (InputStream in, int l) {
10758: try {
10759: int k = 0;
10760: while (k < l) {
10761:
10762:
10763: if (in.read () < 0) {
10764: break;
10765: }
10766: k++;
10767: if (k < l) {
10768: int t = (int) in.skip ((long) (l - k));
10769: if (t < 0) {
10770: break;
10771: }
10772: k += t;
10773: }
10774: }
10775: return k;
10776: } catch (IOException ioe) {
10777: if (prgVerbose) {
10778: prgPrintStackTraceOf (ioe);
10779: }
10780: }
10781: return -1;
10782: }
10783:
10784:
10785:
10786:
10787:
10788: public static void ismClose (InputStream in) {
10789: try {
10790: if (in != null) {
10791: in.close ();
10792: }
10793: } catch (IOException ioe) {
10794: if (prgVerbose) {
10795: prgPrintStackTraceOf (ioe);
10796: }
10797: }
10798: }
10799:
10800:
10801:
10802:
10803:
10804:
10805: public static int ismLength (String name, int maxLength) {
10806: int length;
10807: InputStream in = ismOpen (name);
10808: if (in == null) {
10809: length = -1;
10810: } else {
10811: length = ismSkip (in, maxLength);
10812: ismClose (in);
10813: }
10814: return length;
10815: }
10816:
10817:
10818:
10819:
10820:
10821:
10822:
10823:
10824:
10825:
10826:
10827:
10828:
10829:
10830: public static boolean ismLoad (byte[] bb, int o, int l, String names) {
10831: for (String name : names.split (",")) {
10832: if (name.length () != 0) {
10833: InputStream in = ismOpen (name);
10834: if (in != null) {
10835: int k = ismRead (in, bb, o, l);
10836: ismClose (in);
10837: if (k == l) {
10838: return true;
10839: }
10840: }
10841: }
10842: }
10843: return false;
10844: }
10845:
10846:
10847:
10848:
10849:
10850:
10851:
10852:
10853:
10854: public static boolean ismSave (byte[] bb, int offset, long length, String path, boolean verbose) {
10855: if (ISM_ZIP_SEPARATOR.split (path, 2).length != 1) {
10856: if (verbose) {
10857: pnlExitFullScreen (true);
10858: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? path + " に書き出せません" : "Cannot write " + path);
10859: }
10860: return false;
10861: }
10862: long step = 0;
10863: byte[] zz = null;
10864: long pointer = (long) (bb.length - offset);
10865: if (pointer < length) {
10866: step = Math.min (1024L * 512, length - pointer);
10867: zz = new byte[(int) step];
10868: Arrays.fill (zz, (byte) 0);
10869: }
10870:
10871: File file = new File (path);
10872:
10873: if (step == 0 &&
10874: file.exists () && file.length () == length) {
10875:
10876: if (length == 0L) {
10877: return true;
10878: }
10879: InputStream in = ismOpen (path);
10880: if (in != null) {
10881: int l = (int) length;
10882: byte[] tt = new byte[l];
10883: int k = ismRead (in, tt, 0, l);
10884: ismClose (in);
10885: if (k == l &&
10886: Arrays.equals (tt, bb.length == l ? bb : Arrays.copyOfRange (bb, offset, offset + l))) {
10887: return true;
10888: }
10889: }
10890: }
10891:
10892: String pathTmp = path + ".tmp";
10893: String pathBak = path + ".bak";
10894: File fileTmp = new File (pathTmp);
10895: File fileBak = new File (pathBak);
10896:
10897: if (fileTmp.exists ()) {
10898: if (!fileTmp.delete ()) {
10899: if (verbose) {
10900: pnlExitFullScreen (true);
10901: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " を削除できません" : "Cannot delete " + pathTmp);
10902: }
10903: return false;
10904: }
10905: }
10906:
10907: try (OutputStream out = path.toLowerCase ().endsWith (".gz") ?
10908: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10909: {
10910:
10911: def.setLevel (Deflater.DEFAULT_COMPRESSION);
10912:
10913: }
10914: } :
10915: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10916: if (step == 0) {
10917: out.write (bb, offset, (int) length);
10918: } else {
10919: out.write (bb, offset, (int) pointer);
10920: for (; pointer < length; pointer += step) {
10921: out.write (zz, 0, (int) Math.min (step, length - pointer));
10922: }
10923: }
10924: } catch (IOException ioe) {
10925: if (verbose) {
10926: prgPrintStackTraceOf (ioe);
10927: pnlExitFullScreen (true);
10928: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " に書き出せません" : "Cannot write " + pathTmp);
10929: }
10930: return false;
10931: }
10932:
10933:
10934: if (file.exists ()) {
10935: if (fileBak.exists ()) {
10936: if (!fileBak.delete ()) {
10937: if (verbose) {
10938: pnlExitFullScreen (true);
10939: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathBak + " を削除できません" : "Cannot delete " + pathBak);
10940: }
10941: return false;
10942: }
10943: }
10944: if (!file.renameTo (fileBak)) {
10945: if (verbose) {
10946: pnlExitFullScreen (true);
10947: JOptionPane.showMessageDialog (
10948: null, Multilingual.mlnJapanese ? path + " を " + pathBak + " にリネームできません" : "Cannot rename " + path + " to " + pathBak);
10949: }
10950: return false;
10951: }
10952: }
10953:
10954:
10955: if (!fileTmp.renameTo (file)) {
10956: if (verbose) {
10957: pnlExitFullScreen (true);
10958: JOptionPane.showMessageDialog (
10959: null, Multilingual.mlnJapanese ? pathTmp + " を " + path + " にリネームできません" : "Cannot rename " + pathTmp + " to " + path);
10960: }
10961: return false;
10962: }
10963: return true;
10964: }
10965:
10966:
10967:
10968:
10969:
10970:
10971:
10972: public static final char[] FMT_TEMP = new char[32];
10973:
10974:
10975:
10976:
10977:
10978:
10979:
10980:
10981:
10982:
10983:
10984: public static final char[] FMT_AIN4_BASE = ".......*..*...**.*...*.*.**..****...*..**.*.*.****..**.****.****".toCharArray ();
10985: public static final char[] FMT_BIN4_BASE = "0000000100100011010001010110011110001001101010111100110111101111".toCharArray ();
10986:
10987:
10988:
10989:
10990:
10991:
10992:
10993:
10994: public static void fmtAin4 (char[] a, int o, int x) {
10995: a[o ] = (char) (x >> 1 & 4 ^ 46);
10996: a[o + 1] = (char) (x & 4 ^ 46);
10997: a[o + 2] = (char) (x << 1 & 4 ^ 46);
10998: a[o + 3] = (char) (x << 2 & 4 ^ 46);
10999: }
11000: public static void fmtBin4 (char[] a, int o, int x) {
11001: a[o ] = (char) (x >>> 3 & 1 | 48);
11002: a[o + 1] = (char) (x >>> 2 & 1 | 48);
11003: a[o + 2] = (char) (x >>> 1 & 1 | 48);
11004: a[o + 3] = (char) (x & 1 | 48);
11005: }
11006: public static String fmtAin4 (int x) {
11007: return String.valueOf (FMT_AIN4_BASE, (x & 15) << 2, 4);
11008: }
11009: public static String fmtBin4 (int x) {
11010: return String.valueOf (FMT_BIN4_BASE, (x & 15) << 2, 4);
11011: }
11012: public static StringBuilder fmtAin4 (StringBuilder sb, int x) {
11013: return sb.append (FMT_AIN4_BASE, (x & 15) << 2, 6);
11014: }
11015: public static StringBuilder fmtBin4 (StringBuilder sb, int x) {
11016: return sb.append (FMT_BIN4_BASE, (x & 15) << 2, 6);
11017: }
11018:
11019:
11020:
11021:
11022:
11023:
11024:
11025:
11026: public static void fmtAin6 (char[] a, int o, int x) {
11027: a[o ] = (char) (x >> 3 & 4 ^ 46);
11028: a[o + 1] = (char) (x >> 2 & 4 ^ 46);
11029: a[o + 2] = (char) (x >> 1 & 4 ^ 46);
11030: a[o + 3] = (char) (x & 4 ^ 46);
11031: a[o + 4] = (char) (x << 1 & 4 ^ 46);
11032: a[o + 5] = (char) (x << 2 & 4 ^ 46);
11033: }
11034: public static void fmtBin6 (char[] a, int o, int x) {
11035: a[o ] = (char) (x >>> 5 & 1 | 48);
11036: a[o + 1] = (char) (x >>> 4 & 1 | 48);
11037: a[o + 2] = (char) (x >>> 3 & 1 | 48);
11038: a[o + 3] = (char) (x >>> 2 & 1 | 48);
11039: a[o + 4] = (char) (x >>> 1 & 1 | 48);
11040: a[o + 5] = (char) (x & 1 | 48);
11041: }
11042: public static String fmtAin6 (int x) {
11043: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11044: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11045: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11046: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11047: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11048: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11049: return String.valueOf (FMT_TEMP, 0, 6);
11050: }
11051: public static String fmtBin6 (int x) {
11052: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11053: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11054: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11055: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11056: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11057: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11058: return String.valueOf (FMT_TEMP, 0, 6);
11059: }
11060: public static StringBuilder fmtAin6 (StringBuilder sb, int x) {
11061: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11062: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11063: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11064: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11065: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11066: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11067: return sb.append (FMT_TEMP, 0, 6);
11068: }
11069: public static StringBuilder fmtBin6 (StringBuilder sb, int x) {
11070: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11071: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11072: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11073: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11074: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11075: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11076: return sb.append (FMT_TEMP, 0, 6);
11077: }
11078:
11079:
11080:
11081:
11082:
11083:
11084:
11085:
11086: public static void fmtAin8 (char[] a, int o, int x) {
11087: a[o ] = (char) (x >> 5 & 4 ^ 46);
11088: a[o + 1] = (char) (x >> 4 & 4 ^ 46);
11089: a[o + 2] = (char) (x >> 3 & 4 ^ 46);
11090: a[o + 3] = (char) (x >> 2 & 4 ^ 46);
11091: a[o + 4] = (char) (x >> 1 & 4 ^ 46);
11092: a[o + 5] = (char) (x & 4 ^ 46);
11093: a[o + 6] = (char) (x << 1 & 4 ^ 46);
11094: a[o + 7] = (char) (x << 2 & 4 ^ 46);
11095: }
11096: public static void fmtBin8 (char[] a, int o, int x) {
11097: a[o ] = (char) (x >>> 7 & 1 | 48);
11098: a[o + 1] = (char) (x >>> 6 & 1 | 48);
11099: a[o + 2] = (char) (x >>> 5 & 1 | 48);
11100: a[o + 3] = (char) (x >>> 4 & 1 | 48);
11101: a[o + 4] = (char) (x >>> 3 & 1 | 48);
11102: a[o + 5] = (char) (x >>> 2 & 1 | 48);
11103: a[o + 6] = (char) (x >>> 1 & 1 | 48);
11104: a[o + 7] = (char) (x & 1 | 48);
11105: }
11106: public static String fmtAin8 (int x) {
11107: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11108: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11109: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11110: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11111: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11112: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11113: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11114: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11115: return String.valueOf (FMT_TEMP, 0, 8);
11116: }
11117: public static String fmtBin8 (int x) {
11118: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11119: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11120: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11121: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11122: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11123: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11124: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11125: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11126: return String.valueOf (FMT_TEMP, 0, 8);
11127: }
11128: public static StringBuilder fmtAin8 (StringBuilder sb, int x) {
11129: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11130: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11131: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11132: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11133: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11134: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11135: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11136: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11137: return sb.append (FMT_TEMP, 0, 8);
11138: }
11139: public static StringBuilder fmtBin8 (StringBuilder sb, int x) {
11140: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11141: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11142: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11143: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11144: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11145: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11146: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11147: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11148: return sb.append (FMT_TEMP, 0, 8);
11149: }
11150:
11151:
11152:
11153:
11154:
11155:
11156:
11157:
11158: public static void fmtAin12 (char[] a, int o, int x) {
11159: a[o ] = (char) (x >> 9 & 4 ^ 46);
11160: a[o + 1] = (char) (x >> 8 & 4 ^ 46);
11161: a[o + 2] = (char) (x >> 7 & 4 ^ 46);
11162: a[o + 3] = (char) (x >> 6 & 4 ^ 46);
11163: a[o + 4] = (char) (x >> 5 & 4 ^ 46);
11164: a[o + 5] = (char) (x >> 4 & 4 ^ 46);
11165: a[o + 6] = (char) (x >> 3 & 4 ^ 46);
11166: a[o + 7] = (char) (x >> 2 & 4 ^ 46);
11167: a[o + 8] = (char) (x >> 1 & 4 ^ 46);
11168: a[o + 9] = (char) (x & 4 ^ 46);
11169: a[o + 10] = (char) (x << 1 & 4 ^ 46);
11170: a[o + 11] = (char) (x << 2 & 4 ^ 46);
11171: }
11172: public static void fmtBin12 (char[] a, int o, int x) {
11173: a[o ] = (char) (x >>> 11 & 1 | 48);
11174: a[o + 1] = (char) (x >>> 10 & 1 | 48);
11175: a[o + 2] = (char) (x >>> 9 & 1 | 48);
11176: a[o + 3] = (char) (x >>> 8 & 1 | 48);
11177: a[o + 4] = (char) (x >>> 7 & 1 | 48);
11178: a[o + 5] = (char) (x >>> 6 & 1 | 48);
11179: a[o + 6] = (char) (x >>> 5 & 1 | 48);
11180: a[o + 7] = (char) (x >>> 4 & 1 | 48);
11181: a[o + 8] = (char) (x >>> 3 & 1 | 48);
11182: a[o + 9] = (char) (x >>> 2 & 1 | 48);
11183: a[o + 10] = (char) (x >>> 1 & 1 | 48);
11184: a[o + 11] = (char) (x & 1 | 48);
11185: }
11186: public static String fmtAin12 (int x) {
11187: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11188: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11189: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11190: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11191: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11192: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11193: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11194: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11195: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11196: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11197: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11198: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11199: return String.valueOf (FMT_TEMP, 0, 12);
11200: }
11201: public static String fmtBin12 (int x) {
11202: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11203: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11204: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11205: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11206: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11207: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11208: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11209: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11210: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11211: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11212: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11213: FMT_TEMP[11] = (char) (x & 1 | 48);
11214: return String.valueOf (FMT_TEMP, 0, 12);
11215: }
11216: public static StringBuilder fmtAin12 (StringBuilder sb, int x) {
11217: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11218: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11219: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11220: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11221: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11222: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11223: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11224: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11225: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11226: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11227: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11228: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11229: return sb.append (FMT_TEMP, 0, 12);
11230: }
11231: public static StringBuilder fmtBin12 (StringBuilder sb, int x) {
11232: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11233: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11234: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11235: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11236: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11237: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11238: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11239: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11240: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11241: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11242: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11243: FMT_TEMP[11] = (char) (x & 1 | 48);
11244: return sb.append (FMT_TEMP, 0, 12);
11245: }
11246:
11247:
11248:
11249:
11250:
11251:
11252:
11253:
11254: public static void fmtAin16 (char[] a, int o, int x) {
11255: a[o ] = (char) (x >> 13 & 4 ^ 46);
11256: a[o + 1] = (char) (x >> 12 & 4 ^ 46);
11257: a[o + 2] = (char) (x >> 11 & 4 ^ 46);
11258: a[o + 3] = (char) (x >> 10 & 4 ^ 46);
11259: a[o + 4] = (char) (x >> 9 & 4 ^ 46);
11260: a[o + 5] = (char) (x >> 8 & 4 ^ 46);
11261: a[o + 6] = (char) (x >> 7 & 4 ^ 46);
11262: a[o + 7] = (char) (x >> 6 & 4 ^ 46);
11263: a[o + 8] = (char) (x >> 5 & 4 ^ 46);
11264: a[o + 9] = (char) (x >> 4 & 4 ^ 46);
11265: a[o + 10] = (char) (x >> 3 & 4 ^ 46);
11266: a[o + 11] = (char) (x >> 2 & 4 ^ 46);
11267: a[o + 12] = (char) (x >> 1 & 4 ^ 46);
11268: a[o + 13] = (char) (x & 4 ^ 46);
11269: a[o + 14] = (char) (x << 1 & 4 ^ 46);
11270: a[o + 15] = (char) (x << 2 & 4 ^ 46);
11271: }
11272: public static void fmtBin16 (char[] a, int o, int x) {
11273: a[o ] = (char) (x >>> 15 & 1 | 48);
11274: a[o + 1] = (char) (x >>> 14 & 1 | 48);
11275: a[o + 2] = (char) (x >>> 13 & 1 | 48);
11276: a[o + 3] = (char) (x >>> 12 & 1 | 48);
11277: a[o + 4] = (char) (x >>> 11 & 1 | 48);
11278: a[o + 5] = (char) (x >>> 10 & 1 | 48);
11279: a[o + 6] = (char) (x >>> 9 & 1 | 48);
11280: a[o + 7] = (char) (x >>> 8 & 1 | 48);
11281: a[o + 8] = (char) (x >>> 7 & 1 | 48);
11282: a[o + 9] = (char) (x >>> 6 & 1 | 48);
11283: a[o + 10] = (char) (x >>> 5 & 1 | 48);
11284: a[o + 11] = (char) (x >>> 4 & 1 | 48);
11285: a[o + 12] = (char) (x >>> 3 & 1 | 48);
11286: a[o + 13] = (char) (x >>> 2 & 1 | 48);
11287: a[o + 14] = (char) (x >>> 1 & 1 | 48);
11288: a[o + 15] = (char) (x & 1 | 48);
11289: }
11290: public static String fmtAin16 (int x) {
11291: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11292: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11293: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11294: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11295: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11296: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11297: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11298: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11299: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11300: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11301: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11302: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11303: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11304: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11305: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11306: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11307: return String.valueOf (FMT_TEMP, 0, 16);
11308: }
11309: public static String fmtBin16 (int x) {
11310: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11311: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11312: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11313: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11314: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11315: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11316: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11317: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11318: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11319: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11320: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11321: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11322: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11323: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11324: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11325: FMT_TEMP[15] = (char) (x & 1 | 48);
11326: return String.valueOf (FMT_TEMP, 0, 16);
11327: }
11328: public static StringBuilder fmtAin16 (StringBuilder sb, int x) {
11329: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11330: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11331: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11332: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11333: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11334: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11335: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11336: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11337: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11338: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11339: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11340: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11341: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11342: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11343: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11344: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11345: return sb.append (FMT_TEMP, 0, 16);
11346: }
11347: public static StringBuilder fmtBin16 (StringBuilder sb, int x) {
11348: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11349: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11350: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11351: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11352: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11353: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11354: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11355: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11356: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11357: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11358: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11359: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11360: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11361: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11362: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11363: FMT_TEMP[15] = (char) (x & 1 | 48);
11364: return sb.append (FMT_TEMP, 0, 16);
11365: }
11366:
11367:
11368:
11369:
11370:
11371:
11372:
11373:
11374: public static void fmtAin24 (char[] a, int o, int x) {
11375: a[o ] = (char) (x >> 21 & 4 ^ 46);
11376: a[o + 1] = (char) (x >> 20 & 4 ^ 46);
11377: a[o + 2] = (char) (x >> 19 & 4 ^ 46);
11378: a[o + 3] = (char) (x >> 18 & 4 ^ 46);
11379: a[o + 4] = (char) (x >> 17 & 4 ^ 46);
11380: a[o + 5] = (char) (x >> 16 & 4 ^ 46);
11381: a[o + 6] = (char) (x >> 15 & 4 ^ 46);
11382: a[o + 7] = (char) (x >> 14 & 4 ^ 46);
11383: a[o + 8] = (char) (x >> 13 & 4 ^ 46);
11384: a[o + 9] = (char) (x >> 12 & 4 ^ 46);
11385: a[o + 10] = (char) (x >> 11 & 4 ^ 46);
11386: a[o + 11] = (char) (x >> 10 & 4 ^ 46);
11387: a[o + 12] = (char) (x >> 9 & 4 ^ 46);
11388: a[o + 13] = (char) (x >> 8 & 4 ^ 46);
11389: a[o + 14] = (char) (x >> 7 & 4 ^ 46);
11390: a[o + 15] = (char) (x >> 6 & 4 ^ 46);
11391: a[o + 16] = (char) (x >> 5 & 4 ^ 46);
11392: a[o + 17] = (char) (x >> 4 & 4 ^ 46);
11393: a[o + 18] = (char) (x >> 3 & 4 ^ 46);
11394: a[o + 19] = (char) (x >> 2 & 4 ^ 46);
11395: a[o + 20] = (char) (x >> 1 & 4 ^ 46);
11396: a[o + 21] = (char) (x & 4 ^ 46);
11397: a[o + 22] = (char) (x << 1 & 4 ^ 46);
11398: a[o + 23] = (char) (x << 2 & 4 ^ 46);
11399: }
11400: public static void fmtBin24 (char[] a, int o, int x) {
11401: a[o ] = (char) (x >>> 23 & 1 | 48);
11402: a[o + 1] = (char) (x >>> 22 & 1 | 48);
11403: a[o + 2] = (char) (x >>> 21 & 1 | 48);
11404: a[o + 3] = (char) (x >>> 20 & 1 | 48);
11405: a[o + 4] = (char) (x >>> 19 & 1 | 48);
11406: a[o + 5] = (char) (x >>> 18 & 1 | 48);
11407: a[o + 6] = (char) (x >>> 17 & 1 | 48);
11408: a[o + 7] = (char) (x >>> 16 & 1 | 48);
11409: a[o + 8] = (char) (x >>> 15 & 1 | 48);
11410: a[o + 9] = (char) (x >>> 14 & 1 | 48);
11411: a[o + 10] = (char) (x >>> 13 & 1 | 48);
11412: a[o + 11] = (char) (x >>> 12 & 1 | 48);
11413: a[o + 12] = (char) (x >>> 11 & 1 | 48);
11414: a[o + 13] = (char) (x >>> 10 & 1 | 48);
11415: a[o + 14] = (char) (x >>> 9 & 1 | 48);
11416: a[o + 15] = (char) (x >>> 8 & 1 | 48);
11417: a[o + 16] = (char) (x >>> 7 & 1 | 48);
11418: a[o + 17] = (char) (x >>> 6 & 1 | 48);
11419: a[o + 18] = (char) (x >>> 5 & 1 | 48);
11420: a[o + 19] = (char) (x >>> 4 & 1 | 48);
11421: a[o + 20] = (char) (x >>> 3 & 1 | 48);
11422: a[o + 21] = (char) (x >>> 2 & 1 | 48);
11423: a[o + 22] = (char) (x >>> 1 & 1 | 48);
11424: a[o + 23] = (char) (x & 1 | 48);
11425: }
11426: public static String fmtAin24 (int x) {
11427: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11428: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11429: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11430: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11431: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11432: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11433: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11434: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11435: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11436: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11437: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11438: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11439: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11440: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11441: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11442: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11443: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11444: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11445: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11446: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11447: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11448: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11449: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11450: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11451: return String.valueOf (FMT_TEMP, 0, 24);
11452: }
11453: public static String fmtBin24 (int x) {
11454: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11455: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11456: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11457: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11458: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11459: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11460: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11461: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11462: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11463: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11464: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11465: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11466: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11467: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11468: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11469: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11470: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11471: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11472: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11473: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11474: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11475: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11476: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11477: FMT_TEMP[23] = (char) (x & 1 | 48);
11478: return String.valueOf (FMT_TEMP, 0, 24);
11479: }
11480: public static StringBuilder fmtAin24 (StringBuilder sb, int x) {
11481: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11482: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11483: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11484: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11485: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11486: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11487: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11488: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11489: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11490: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11491: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11492: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11493: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11494: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11495: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11496: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11497: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11498: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11499: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11500: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11501: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11502: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11503: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11504: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11505: return sb.append (FMT_TEMP, 0, 24);
11506: }
11507: public static StringBuilder fmtBin24 (StringBuilder sb, int x) {
11508: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11509: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11510: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11511: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11512: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11513: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11514: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11515: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11516: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11517: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11518: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11519: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11520: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11521: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11522: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11523: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11524: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11525: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11526: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11527: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11528: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11529: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11530: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11531: FMT_TEMP[23] = (char) (x & 1 | 48);
11532: return sb.append (FMT_TEMP, 0, 24);
11533: }
11534:
11535:
11536:
11537:
11538:
11539:
11540:
11541:
11542:
11543:
11544:
11545:
11546:
11547:
11548:
11549:
11550:
11551:
11552:
11553:
11554:
11555:
11556:
11557:
11558:
11559:
11560:
11561:
11562:
11563:
11564:
11565:
11566:
11567: public static char fmtHexc (int x) {
11568: x &= 15;
11569: return (char) ((((9 - x) >> 4) & 7) + 48 + x);
11570: }
11571: public static void fmtHex1 (char[] a, int o, int x) {
11572: x &= 15;
11573: a[o] = (char) ((((9 - x) >> 4) & 7) + 48 + x);
11574: }
11575: public static String fmtHex1 (int x) {
11576: x &= 15;
11577: return Character.toString ((char) ((((9 - x) >> 4) & 7) + 48 + x));
11578: }
11579: public static StringBuilder fmtHex1 (StringBuilder sb, int x) {
11580: x &= 15;
11581: return sb.append ((char) ((((9 - x) >> 4) & 7) + 48 + x));
11582: }
11583:
11584:
11585:
11586:
11587:
11588:
11589: public static void fmtHex2 (char[] a, int o, int x) {
11590: int x0 = x & 15;
11591: int x1 = x >>> 4 & 15;
11592: a[o ] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
11593: a[o + 1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
11594: }
11595: public static String fmtHex2 (int x) {
11596:
11597: int x0 = x & 15;
11598: int x1 = x >>> 4 & 15;
11599: FMT_TEMP[0] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
11600: FMT_TEMP[1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
11601: return String.valueOf (FMT_TEMP, 0, 2);
11602: }
11603: public static StringBuilder fmtHex2 (StringBuilder sb, int x) {
11604: int x0 = x & 15;
11605: int x1 = x >>> 4 & 15;
11606: return (sb.
11607: append ((char) ((((9 - x1) >> 4) & 7) + 48 + x1)).
11608: append ((char) ((((9 - x0) >> 4) & 7) + 48 + x0)));
11609: }
11610:
11611:
11612:
11613:
11614:
11615:
11616: public static void fmtHex4 (char[] a, int o, int x) {
11617: int t;
11618: t = (char) x >>> 12;
11619: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11620: t = x >>> 8 & 15;
11621: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11622: t = x >>> 4 & 15;
11623: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11624: t = x & 15;
11625: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11626: }
11627: public static String fmtHex4 (int x) {
11628:
11629: int t;
11630: t = (char) x >>> 12;
11631: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11632: t = x >>> 8 & 15;
11633: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11634: t = x >>> 4 & 15;
11635: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11636: t = x & 15;
11637: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11638: return String.valueOf (FMT_TEMP, 0, 4);
11639: }
11640: public static StringBuilder fmtHex4 (StringBuilder sb, int x) {
11641:
11642: int t;
11643: t = (char) x >>> 12;
11644: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11645: t = x >>> 8 & 15;
11646: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11647: t = x >>> 4 & 15;
11648: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11649: t = x & 15;
11650: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11651: return sb.append (FMT_TEMP, 0, 4);
11652: }
11653:
11654:
11655:
11656:
11657:
11658:
11659: public static void fmtHex6 (char[] a, int o, int x) {
11660: int t;
11661: t = x >>> 20 & 15;
11662: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11663: t = x >>> 16 & 15;
11664: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11665: t = (char) x >>> 12;
11666: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11667: t = x >>> 8 & 15;
11668: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11669: t = x >>> 4 & 15;
11670: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11671: t = x & 15;
11672: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11673: }
11674: public static String fmtHex6 (int x) {
11675:
11676: int t;
11677: t = x >>> 20 & 15;
11678: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11679: t = x >>> 16 & 15;
11680: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11681: t = (char) x >>> 12;
11682: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11683: t = x >>> 8 & 15;
11684: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11685: t = x >>> 4 & 15;
11686: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11687: t = x & 15;
11688: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11689: return String.valueOf (FMT_TEMP, 0, 6);
11690: }
11691: public static StringBuilder fmtHex6 (StringBuilder sb, int x) {
11692:
11693: int t;
11694: t = x >>> 20 & 15;
11695: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11696: t = x >>> 16 & 15;
11697: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11698: t = (char) x >>> 12;
11699: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11700: t = x >>> 8 & 15;
11701: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11702: t = x >>> 4 & 15;
11703: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11704: t = x & 15;
11705: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11706: return sb.append (FMT_TEMP, 0, 6);
11707: }
11708:
11709:
11710:
11711:
11712:
11713:
11714: public static void fmtHex8 (char[] a, int o, int x) {
11715: int t;
11716: t = x >>> 28;
11717: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11718: t = x >>> 24 & 15;
11719: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11720: t = x >>> 20 & 15;
11721: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11722: t = x >>> 16 & 15;
11723: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11724: t = (char) x >>> 12;
11725: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11726: t = x >>> 8 & 15;
11727: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11728: t = x >>> 4 & 15;
11729: a[o + 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11730: t = x & 15;
11731: a[o + 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11732: }
11733: public static String fmtHex8 (int x) {
11734:
11735: int t;
11736: t = x >>> 28;
11737: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11738: t = x >>> 24 & 15;
11739: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11740: t = x >>> 20 & 15;
11741: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11742: t = x >>> 16 & 15;
11743: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11744: t = (char) x >>> 12;
11745: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11746: t = x >>> 8 & 15;
11747: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11748: t = x >>> 4 & 15;
11749: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11750: t = x & 15;
11751: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11752: return String.valueOf (FMT_TEMP, 0, 8);
11753: }
11754: public static StringBuilder fmtHex8 (StringBuilder sb, int x) {
11755:
11756: int t;
11757: t = x >>> 28;
11758: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11759: t = x >>> 24 & 15;
11760: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11761: t = x >>> 20 & 15;
11762: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11763: t = x >>> 16 & 15;
11764: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11765: t = (char) x >>> 12;
11766: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11767: t = x >>> 8 & 15;
11768: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11769: t = x >>> 4 & 15;
11770: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11771: t = x & 15;
11772: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11773: return sb.append (FMT_TEMP, 0, 8);
11774: }
11775:
11776: public static StringBuilder fmtHex16 (StringBuilder sb, long x) {
11777:
11778: int s, t;
11779: s = (int) (x >>> 32);
11780: t = s >>> 28;
11781: FMT_TEMP[ 0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11782: t = s >>> 24 & 15;
11783: FMT_TEMP[ 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11784: t = s >>> 20 & 15;
11785: FMT_TEMP[ 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11786: t = s >>> 16 & 15;
11787: FMT_TEMP[ 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11788: t = (char) s >>> 12;
11789: FMT_TEMP[ 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11790: t = s >>> 8 & 15;
11791: FMT_TEMP[ 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11792: t = s >>> 4 & 15;
11793: FMT_TEMP[ 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11794: t = s & 15;
11795: FMT_TEMP[ 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11796: s = (int) x;
11797: t = s >>> 28;
11798: FMT_TEMP[ 8] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11799: t = s >>> 24 & 15;
11800: FMT_TEMP[ 9] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11801: t = s >>> 20 & 15;
11802: FMT_TEMP[10] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11803: t = s >>> 16 & 15;
11804: FMT_TEMP[11] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11805: t = (char) s >>> 12;
11806: FMT_TEMP[12] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11807: t = s >>> 8 & 15;
11808: FMT_TEMP[13] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11809: t = s >>> 4 & 15;
11810: FMT_TEMP[14] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11811: t = s & 15;
11812: FMT_TEMP[15] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11813: return sb.append (FMT_TEMP, 0, 16);
11814: }
11815:
11816:
11817:
11818:
11819:
11820:
11821:
11822:
11823:
11824:
11825:
11826:
11827:
11828:
11829:
11830:
11831:
11832:
11833:
11834:
11835:
11836:
11837:
11838:
11839:
11840:
11841:
11842:
11843:
11844:
11845:
11846:
11847:
11848:
11849:
11850:
11851:
11852:
11853:
11854:
11855:
11856:
11857:
11858:
11859:
11860:
11861:
11862:
11863:
11864:
11865:
11866:
11867:
11868:
11869:
11870:
11871:
11872:
11873:
11874:
11875:
11876:
11877:
11878:
11879:
11880:
11881:
11882:
11883: public static final int[] FMT_BCD4 = new int[10000];
11884: public static final int[] FMT_DCB4 = new int[65536];
11885:
11886:
11887:
11888:
11889: public static void fmtInit () {
11890: Arrays.fill (FMT_DCB4, -1);
11891: int i = 0;
11892: int x = 0;
11893: for (int a = 0; a < 10; a++) {
11894: for (int b = 0; b < 10; b++) {
11895: for (int c = 0; c < 10; c++) {
11896: FMT_DCB4[FMT_BCD4[i ] = x ] = i;
11897: FMT_DCB4[FMT_BCD4[i + 1] = x + 1] = i + 1;
11898: FMT_DCB4[FMT_BCD4[i + 2] = x + 2] = i + 2;
11899: FMT_DCB4[FMT_BCD4[i + 3] = x + 3] = i + 3;
11900: FMT_DCB4[FMT_BCD4[i + 4] = x + 4] = i + 4;
11901: FMT_DCB4[FMT_BCD4[i + 5] = x + 5] = i + 5;
11902: FMT_DCB4[FMT_BCD4[i + 6] = x + 6] = i + 6;
11903: FMT_DCB4[FMT_BCD4[i + 7] = x + 7] = i + 7;
11904: FMT_DCB4[FMT_BCD4[i + 8] = x + 8] = i + 8;
11905: FMT_DCB4[FMT_BCD4[i + 9] = x + 9] = i + 9;
11906: i += 10;
11907: x += 1 << 4;
11908: }
11909: x += 6 << 4;
11910: }
11911: x += 6 << 8;
11912: }
11913: }
11914:
11915:
11916:
11917: public static int fmtBcd4 (int x) {
11918:
11919:
11920:
11921:
11922:
11923:
11924:
11925:
11926:
11927: return FMT_BCD4[Math.max (0, Math.min (9999, x))];
11928: }
11929:
11930:
11931:
11932: public static int fmtBcd8 (int x) {
11933: x = Math.max (0, Math.min (99999999, x));
11934:
11935:
11936: int q = (int) ((long) x * 109951163L >>> 40);
11937:
11938: return FMT_BCD4[q] << 16 | FMT_BCD4[x - 10000 * q];
11939: }
11940:
11941:
11942:
11943: public static long fmtBcd12 (long x) {
11944: x = Math.max (0L, Math.min (999999999999L, x));
11945: int q = (int) ((double) x / 100000000.0);
11946: int r = (int) (x - 100000000L * q);
11947:
11948:
11949: int rq = (int) ((long) r * 109951163L >>> 40);
11950:
11951: return (long) FMT_BCD4[q] << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
11952: }
11953:
11954:
11955:
11956: public static long fmtBcd16 (long x) {
11957: x = Math.max (0L, Math.min (9999999999999999L, x));
11958: int q = x <= (1L << 53) ? (int) ((double) x / 100000000.0) : (int) (x / 100000000L);
11959: int r = (int) (x - 100000000L * q);
11960:
11961:
11962: int qq = (int) ((long) q * 109951163L >>> 40);
11963:
11964:
11965:
11966: int rq = (int) ((long) r * 109951163L >>> 40);
11967:
11968: return (long) (FMT_BCD4[qq] << 16 | FMT_BCD4[q - 10000 * qq]) << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
11969: }
11970:
11971:
11972:
11973:
11974:
11975:
11976: public static int fmtCA02u (char[] a, int o, int x) {
11977: if (x < 0 || 99 < x) {
11978: x = 99;
11979: }
11980: x = FMT_BCD4[x];
11981: a[o ] = (char) ('0' | x >>> 4);
11982: a[o + 1] = (char) ('0' | x & 15);
11983: return o + 2;
11984: }
11985: public static StringBuilder fmtSB02u (StringBuilder sb, int x) {
11986: return sb.append (FMT_TEMP, 0, fmtCA02u (FMT_TEMP, 0, x));
11987: }
11988:
11989:
11990:
11991:
11992:
11993: public static int fmtCA2u (char[] a, int o, int x) {
11994: if (x < 0 || 99 < x) {
11995: x = 99;
11996: }
11997: x = FMT_BCD4[x];
11998: if (x <= 0x000f) {
11999: a[o++] = (char) ('0' | x);
12000: } else {
12001: a[o++] = (char) ('0' | x >>> 4);
12002: a[o++] = (char) ('0' | x & 15);
12003: }
12004: return o;
12005: }
12006: public static StringBuilder fmtSB2u (StringBuilder sb, int x) {
12007: return sb.append (FMT_TEMP, 0, fmtCA2u (FMT_TEMP, 0, x));
12008: }
12009:
12010:
12011:
12012:
12013:
12014: public static int fmtCA04u (char[] a, int o, int x) {
12015: if (x < 0 || 9999 < x) {
12016: x = 9999;
12017: }
12018: x = FMT_BCD4[x];
12019: a[o ] = (char) ('0' | x >>> 12);
12020: a[o + 1] = (char) ('0' | x >>> 8 & 15);
12021: a[o + 2] = (char) ('0' | x >>> 4 & 15);
12022: a[o + 3] = (char) ('0' | x & 15);
12023: return o + 4;
12024: }
12025: public static StringBuilder fmtSB04u (StringBuilder sb, int x) {
12026: return sb.append (FMT_TEMP, 0, fmtCA04u (FMT_TEMP, 0, x));
12027: }
12028:
12029:
12030:
12031:
12032:
12033: public static int fmtCA4u (char[] a, int o, int x) {
12034: if (x < 0 || 9999 < x) {
12035: x = 9999;
12036: }
12037: x = FMT_BCD4[x];
12038: if (x <= 0x000f) {
12039: a[o++] = (char) ('0' | x);
12040: } else if (x <= 0x00ff) {
12041: a[o++] = (char) ('0' | x >>> 4);
12042: a[o++] = (char) ('0' | x & 15);
12043: } else if (x <= 0x0fff) {
12044: a[o++] = (char) ('0' | x >>> 8);
12045: a[o++] = (char) ('0' | x >>> 4 & 15);
12046: a[o++] = (char) ('0' | x & 15);
12047: } else {
12048: a[o++] = (char) ('0' | x >>> 12);
12049: a[o++] = (char) ('0' | x >>> 8 & 15);
12050: a[o++] = (char) ('0' | x >>> 4 & 15);
12051: a[o++] = (char) ('0' | x & 15);
12052: }
12053: return o;
12054: }
12055: public static StringBuilder fmtSB4u (StringBuilder sb, int x) {
12056: return sb.append (FMT_TEMP, 0, fmtCA4u (FMT_TEMP, 0, x));
12057: }
12058:
12059:
12060:
12061:
12062:
12063: public static int fmtCA08u (char[] a, int o, int x) {
12064: if (x < 0 || 99999999 < x) {
12065: x = 99999999;
12066: }
12067:
12068:
12069: int h = (int) ((long) x * 109951163L >>> 40);
12070: return fmtCA04u (a, fmtCA04u (a, o, h), x - h * 10000);
12071: }
12072: public static StringBuilder fmtSB08u (StringBuilder sb, int x) {
12073: return sb.append (FMT_TEMP, 0, fmtCA08u (FMT_TEMP, 0, x));
12074: }
12075:
12076:
12077:
12078:
12079:
12080: public static int fmtCA8u (char[] a, int o, int x) {
12081: if (x < 0 || 99999999 < x) {
12082: x = 99999999;
12083: }
12084: if (x <= 9999) {
12085: return fmtCA4u (a, o, x);
12086: } else {
12087:
12088:
12089: int h = (int) ((long) x * 109951163L >>> 40);
12090: return fmtCA04u (a, fmtCA4u (a, o, h), x - h * 10000);
12091: }
12092: }
12093: public static StringBuilder fmtSB8u (StringBuilder sb, int x) {
12094: return sb.append (FMT_TEMP, 0, fmtCA8u (FMT_TEMP, 0, x));
12095: }
12096:
12097:
12098:
12099:
12100:
12101: public static int fmtCAd (char[] a, int o, long x) {
12102: if (x < 0L) {
12103: x = -x;
12104: a[o++] = '-';
12105: }
12106: if (x <= 99999999L) {
12107: return fmtCA8u (a, o, (int) x);
12108: } else if (x <= 9999999999999999L) {
12109: long h = x / 100000000L;
12110: return fmtCA08u (a, fmtCA8u (a, o, (int) h), (int) (x - h * 100000000L));
12111: } else {
12112: long hh = x / 10000000000000000L;
12113: x -= hh * 10000000000000000L;
12114: long h = x / 100000000L;
12115: return fmtCA08u (a, fmtCA08u (a, fmtCA4u (a, o, (int) hh), (int) h), (int) (x - h * 100000000L));
12116: }
12117: }
12118: public static StringBuilder fmtSBd (StringBuilder sb, long x) {
12119: return sb.append (FMT_TEMP, 0, fmtCAd (FMT_TEMP, 0, x));
12120: }
12121:
12122:
12123:
12124:
12125:
12126:
12127: public static int fmtCAnd (char[] a, int o, int n, long x) {
12128: int t = fmtCAd (a, o, x);
12129: n += o;
12130: if (t < n) {
12131: int i = n;
12132: while (o < t) {
12133: a[--i] = a[--t];
12134: }
12135: while (o < i) {
12136: a[--i] = ' ';
12137: }
12138: t = n;
12139: }
12140: return t;
12141: }
12142: public static StringBuilder fmtSBnd (StringBuilder sb, int n, int x) {
12143: return sb.append (FMT_TEMP, 0, fmtCAnd (FMT_TEMP, 0, n, x));
12144: }
12145:
12146:
12147:
12148:
12149:
12150:
12151:
12152:
12153:
12154:
12155:
12156:
12157:
12158: public static int fmtParseInt (String s, int i, int min, int max, int err) {
12159: return fmtParseIntRadix (s, i, min, max, err, 10);
12160: }
12161: public static int fmtParseIntRadix (String s, int i, int min, int max, int err, int radix) {
12162: if (s == null) {
12163: return err;
12164: }
12165: int l = s.length ();
12166: int c = i < l ? s.charAt (i++) : -1;
12167:
12168: while (c == ' ' || c == '\t') {
12169: c = i < l ? s.charAt (i++) : -1;
12170: }
12171:
12172: int n = 0;
12173: if (c == '+') {
12174: c = i < l ? s.charAt (i++) : -1;
12175: } else if (c == '-') {
12176: n = 1;
12177: c = i < l ? s.charAt (i++) : -1;
12178: }
12179:
12180:
12181:
12182:
12183: int o;
12184: int p;
12185: if (c == '$') {
12186: o = 0x07ffffff + n;
12187: p = 15 + n & 15;
12188: radix = 16;
12189: c = i < l ? s.charAt (i++) : -1;
12190: } else if (radix == 16) {
12191: o = 0x07ffffff + n;
12192: p = 15 + n & 15;
12193: } else if (radix == 8) {
12194: o = 0x0fffffff + n;
12195: p = 7 + n & 7;
12196: } else if (radix == 2) {
12197: o = 0x3fffffff + n;
12198: p = 1 + n & 1;
12199: } else {
12200: o = 214748364;
12201: p = 7 + n;
12202: radix = 10;
12203: }
12204:
12205: int x = Character.digit (c, radix);
12206: if (x < 0) {
12207: return err;
12208: }
12209: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12210: while (c >= 0) {
12211: int t = x - o;
12212: if (t > 0 || t == 0 && c > p) {
12213: return err;
12214: }
12215: x = x * radix + c;
12216: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12217: }
12218: if (n != 0) {
12219: x = -x;
12220: }
12221: return min <= x && x <= max ? x : err;
12222: }
12223:
12224:
12225:
12226:
12227:
12228:
12229:
12230:
12231:
12232:
12233: public static long matMax3 (long x1, long x2, long x3) {
12234: return Math.max (Math.max (x1, x2), x3);
12235: }
12236: public static long matMax4 (long x1, long x2, long x3, long x4) {
12237: return Math.max (Math.max (x1, x2), Math.max (x3, x4));
12238: }
12239: public static long matMax5 (long x1, long x2, long x3, long x4, long x5) {
12240: return Math.max (Math.max (Math.max (x1, x2), Math.max (x3, x4)), x5);
12241: }
12242:
12243:
12244:
12245:
12246:
12247: public static long matMin3 (long x1, long x2, long x3) {
12248: return Math.min (Math.min (x1, x2), x3);
12249: }
12250: public static long matMin4 (long x1, long x2, long x3, long x4) {
12251: return Math.min (Math.min (x1, x2), Math.min (x3, x4));
12252: }
12253: public static long matMin5 (long x1, long x2, long x3, long x4, long x5) {
12254: return Math.min (Math.min (Math.min (x1, x2), Math.min (x3, x4)), x5);
12255: }
12256:
12257:
12258:
12259:
12260:
12261:
12262:
12263:
12264:
12265:
12266:
12267:
12268: public static String strEncodeUTF8 (String s) {
12269: StringBuilder sb = new StringBuilder ();
12270: int l = s.length ();
12271: for (int i = 0; i < l; i++) {
12272: int u = s.charAt (i);
12273: if (0xd800 <= u && u <= 0xdbff && i + 1 < l) {
12274: int v = s.charAt (i + 1);
12275: if (0xdc00 <= v && v <= 0xdfff) {
12276: u = 0x10000 + ((u & 0x3ff) << 10) + (v & 0x3ff);
12277: i++;
12278: }
12279: }
12280: if ((u & 0xffffff80) == 0) {
12281: sb.append ((char) u);
12282: } else if ((u & 0xfffff800) == 0) {
12283: u = (0x0000c080 |
12284: (u & 0x000007c0) << 2 |
12285: (u & 0x0000003f));
12286: sb.append ((char) (u >> 8)).append ((char) (u & 0xff));
12287: } else if ((u & 0xffff0000) == 0 && !(0xd800 <= u && u <= 0xdfff)) {
12288: u = (0x00e08080 |
12289: (u & 0x0000f000) << 4 |
12290: (u & 0x00000fc0) << 2 |
12291: (u & 0x0000003f));
12292: sb.append ((char) (u >> 16)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12293: } else if ((u & 0xffe00000) == 0) {
12294: u = (0xf0808080 |
12295: (u & 0x001c0000) << 6 |
12296: (u & 0x0003f000) << 4 |
12297: (u & 0x00000fc0) << 2 |
12298: (u & 0x0000003f));
12299: sb.append ((char) ((u >> 24) & 0xff)).append ((char) ((u >> 16) & 0xff)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12300: } else {
12301: sb.append ((char) 0xef).append ((char) 0xbf).append ((char) 0xbd);
12302: }
12303: }
12304: return sb.toString ();
12305: }
12306:
12307:
12308:
12309:
12310:
12311:
12312:
12313: public static String strDecodeUTF8 (String s) {
12314: StringBuilder sb = new StringBuilder ();
12315: int l = s.length ();
12316: for (int i = 0; i < l; i++) {
12317: int c = s.charAt (i) & 0xff;
12318: for (int k = ((c & 0x80) == 0x00 ? 0 :
12319: (c & 0xe0) == 0xc0 ? 1 :
12320: (c & 0xf0) == 0xe0 ? 2 :
12321: (c & 0xf8) == 0xf0 ? 3 :
12322: -1);
12323: --k >= 0; ) {
12324: c = c << 8 | (i + 1 < l ? s.charAt (++i) & 0xff : 0);
12325: }
12326: int u = ((c & 0xffffff80) == 0x00000000 ? c :
12327: (c & 0xffffe0c0) == 0x0000c080 ? ((c & 0x00001f00) >> 2 |
12328: (c & 0x0000003f)) :
12329: (c & 0xfff0c0c0) == 0x00e08080 ? ((c & 0x000f0000) >> 4 |
12330: (c & 0x00003f00) >> 2 |
12331: (c & 0x0000003f)) :
12332: (c & 0xf8c0c0c0) == 0xf0808080 ? ((c & 0x07000000) >> 6 |
12333: (c & 0x003f0000) >> 4 |
12334: (c & 0x00003f00) >> 2 |
12335: (c & 0x0000003f)) :
12336: 0xfffd);
12337: if (u <= 0x0000ffff) {
12338: sb.append (0xd800 <= u && u <= 0xdfff ? '\ufffd' :
12339: (char) u);
12340: } else if (u <= 0x0010ffff) {
12341: u -= 0x000010000;
12342: sb.append ((char) (0xd800 + ((u >> 10) & 0x3ff))).append ((char) (0xdc00 + (u & 0x3ff)));
12343: }
12344: }
12345: return sb.toString ();
12346: }
12347:
12348:
12349:
12350:
12351:
12352: public static final int[] IsURIChar = {
12353:
12354:
12355: 0b00000000_00000000_00000000_00000000,
12356: 0b00000000_00000110_11111111_11000000,
12357: 0b01111111_11111111_11111111_11100001,
12358: 0b01111111_11111111_11111111_11100010,
12359: };
12360: public static String strEncodeURI (String s) {
12361: s = strEncodeUTF8 (s);
12362: StringBuilder sb = new StringBuilder ();
12363: int l = s.length ();
12364: for (int i = 0; i < l; i++) {
12365: int c = s.charAt (i);
12366: if (c < 0x80 && IsURIChar[c >> 5] << c < 0) {
12367: sb.append ((char) c);
12368: } else {
12369: fmtHex2 (sb.append ('%'), c);
12370: }
12371: }
12372: return sb.toString ();
12373: }
12374:
12375:
12376:
12377:
12378:
12379: public static final byte[] strIsHexChar = {
12380:
12381: -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,
12382: -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,
12383: -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,
12384: -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,
12385: };
12386: public static String strDecodeURI (String s) {
12387: StringBuilder sb = new StringBuilder ();
12388: int l = s.length ();
12389: for (int i = 0; i < l; i++) {
12390: int c = s.charAt (i);
12391: if (c == '%' && i + 2 < l) {
12392: int d = s.charAt (i + 1);
12393: int e = s.charAt (i + 2);
12394: if (d < 0x80 && (d = strIsHexChar[d]) >= 0 &&
12395: e < 0x80 && (e = strIsHexChar[e]) >= 0) {
12396: sb.append ((char) (d << 4 | e));
12397: } else {
12398: sb.append ((char) c);
12399: }
12400: } else {
12401: sb.append ((char) c);
12402: }
12403: }
12404: return sb.toString ();
12405: }
12406:
12407:
12408:
12409:
12410:
12411:
12412:
12413:
12414: public static BufferedImage createImage (int width, int height, String pattern, int... rgbs) {
12415: BufferedImage image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
12416: int[] bitmap = ((DataBufferInt) image.getRaster ().getDataBuffer ()).getData ();
12417: int length = width * height;
12418: for (int i = 0; i < length; i++) {
12419: char c = pattern.charAt (i);
12420: bitmap[i] = rgbs[c < '0' ? 0 : Character.digit (c, 16)];
12421: }
12422: return image;
12423: }
12424:
12425:
12426:
12427: public static ImageIcon createImageIcon (int width, int height, String pattern, int... rgbs) {
12428: return new ImageIcon (createImage (width, height, pattern, rgbs));
12429: }
12430:
12431:
12432:
12433: public static TexturePaint createTexturePaint (int width, int height, String pattern, int... rgbs) {
12434: return new TexturePaint (createImage (width, height, pattern, rgbs), new Rectangle (0, 0, width, height));
12435: }
12436:
12437:
12438:
12439: public static BufferedImage loadImage (String name) {
12440: BufferedImage image = null;
12441: try {
12442: image = ImageIO.read (new File (name));
12443: } catch (Exception e) {
12444: }
12445: return image;
12446: }
12447:
12448:
12449:
12450:
12451: public static boolean saveImage (BufferedImage image, String name) {
12452: return saveImage (image, name, 0.75F);
12453: }
12454: public static boolean saveImage (BufferedImage image, String name, float quality) {
12455: int index = name.lastIndexOf (".");
12456: if (index < 0) {
12457: return false;
12458: }
12459: if (name.substring (index).equalsIgnoreCase (".ico")) {
12460: return saveIcon (name, image);
12461: }
12462: Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix (name.substring (index + 1));
12463: if (!iterator.hasNext ()) {
12464: return false;
12465: }
12466: ImageWriter imageWriter = iterator.next ();
12467: ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam ();
12468: if (imageWriteParam.canWriteCompressed ()) {
12469: imageWriteParam.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);
12470: imageWriteParam.setCompressionQuality (quality);
12471: }
12472: try {
12473: File file = new File (name);
12474: ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream (file);
12475: imageWriter.setOutput (imageOutputStream);
12476: imageWriter.write (null, new IIOImage (image, null, null), imageWriteParam);
12477: imageOutputStream.close ();
12478: } catch (Exception e) {
12479:
12480: return false;
12481: }
12482: return true;
12483: }
12484:
12485:
12486:
12487:
12488:
12489:
12490:
12491:
12492:
12493:
12494:
12495:
12496:
12497:
12498:
12499:
12500:
12501:
12502:
12503:
12504:
12505:
12506:
12507:
12508:
12509:
12510:
12511:
12512:
12513:
12514:
12515:
12516:
12517:
12518:
12519:
12520:
12521:
12522:
12523:
12524:
12525:
12526:
12527:
12528:
12529:
12530:
12531:
12532:
12533:
12534:
12535:
12536:
12537:
12538:
12539:
12540:
12541:
12542:
12543:
12544:
12545:
12546:
12547:
12548:
12549:
12550:
12551:
12552:
12553:
12554:
12555:
12556:
12557: public static boolean saveIcon (String fileName, BufferedImage... arrayImage) {
12558: int iconCount = arrayImage.length;
12559: int[][] arrayPaletTable = new int[iconCount][];
12560: int[] arrayPaletCount = new int[iconCount];
12561: int[] arrayPixelBits = new int[iconCount];
12562: int[] arrayPatternLineSize = new int[iconCount];
12563: int[] arrayMaskLineSize = new int[iconCount];
12564: int[] arrayImageSize = new int[iconCount];
12565: int[] arrayImageOffset = new int[iconCount];
12566: int fileSize = 6 + 16 * iconCount;
12567: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
12568: BufferedImage image = arrayImage[iconNumber];
12569: int width = image.getWidth ();
12570: int height = image.getHeight ();
12571:
12572: int[] paletTable = new int[256];
12573: int paletCount = 0;
12574: countPalet:
12575: for (int y = height - 1; y >= 0; y--) {
12576: for (int x = 0; x < width; x++) {
12577: int rgb = image.getRGB (x, y);
12578: if (rgb >>> 24 != 0xff) {
12579: continue;
12580: }
12581: int l = 0;
12582: int r = paletCount;
12583: while (l < r) {
12584: int m = l + r >> 1;
12585: if (paletTable[m] < rgb) {
12586: l = m + 1;
12587: } else {
12588: r = m;
12589: }
12590: }
12591: if (l == paletCount || paletTable[l] != rgb) {
12592: if (paletCount == 256) {
12593: paletCount = 0;
12594: break countPalet;
12595: }
12596: for (int i = paletCount; i > l; i--) {
12597: paletTable[i] = paletTable[i - 1];
12598: }
12599: paletTable[l] = rgb;
12600: paletCount++;
12601: }
12602: }
12603: }
12604: int pixelBits = (paletCount == 0 ? 24 :
12605: paletCount > 16 ? 8 :
12606: paletCount > 4 ? 4 :
12607: paletCount > 2 ? 2 :
12608: 1);
12609: int patternLineSize = pixelBits * width + 31 >> 5 << 2;
12610: int maskLineSize = width + 31 >> 5 << 2;
12611: int imageSize = 40 + 4 * paletCount + patternLineSize * height + maskLineSize * height;
12612: arrayPaletTable[iconNumber] = paletTable;
12613: arrayPaletCount[iconNumber] = paletCount;
12614: arrayPixelBits[iconNumber] = pixelBits;
12615: arrayPatternLineSize[iconNumber] = patternLineSize;
12616: arrayMaskLineSize[iconNumber] = maskLineSize;
12617: arrayImageSize[iconNumber] = imageSize;
12618: arrayImageOffset[iconNumber] = fileSize;
12619: fileSize += imageSize;
12620: }
12621: byte[] bb = new byte[fileSize];
12622:
12623: ByteArray.byaWiw (bb, 0, 0);
12624: ByteArray.byaWiw (bb, 2, 1);
12625: ByteArray.byaWiw (bb, 4, iconCount);
12626: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
12627: BufferedImage image = arrayImage[iconNumber];
12628: int width = image.getWidth ();
12629: int height = image.getHeight ();
12630: int[] paletTable = arrayPaletTable[iconNumber];
12631: int paletCount = arrayPaletCount[iconNumber];
12632: int pixelBits = arrayPixelBits[iconNumber];
12633: int patternLineSize = arrayPatternLineSize[iconNumber];
12634: int maskLineSize = arrayMaskLineSize[iconNumber];
12635: int imageSize = arrayImageSize[iconNumber];
12636: int imageOffset = arrayImageOffset[iconNumber];
12637:
12638: int o = 6 + 16 * iconNumber;
12639: ByteArray.byaWb (bb, o, width);
12640: ByteArray.byaWb (bb, o + 1, height);
12641: ByteArray.byaWb (bb, o + 2, paletCount);
12642: ByteArray.byaWb (bb, o + 3, 0);
12643: ByteArray.byaWiw (bb, o + 4, 1);
12644: ByteArray.byaWiw (bb, o + 6, pixelBits);
12645: ByteArray.byaWil (bb, o + 8, imageSize);
12646: ByteArray.byaWil (bb, o + 12, imageOffset);
12647:
12648: o = imageOffset;
12649: ByteArray.byaWil (bb, o, 40);
12650: ByteArray.byaWil (bb, o + 4, width);
12651: ByteArray.byaWil (bb, o + 8, height * 2);
12652: ByteArray.byaWiw (bb, o + 12, 1);
12653: ByteArray.byaWiw (bb, o + 14, pixelBits);
12654: ByteArray.byaWil (bb, o + 16, 0);
12655: ByteArray.byaWil (bb, o + 20, 0);
12656: ByteArray.byaWil (bb, o + 24, 0);
12657: ByteArray.byaWil (bb, o + 28, 0);
12658: ByteArray.byaWil (bb, o + 32, paletCount);
12659: ByteArray.byaWil (bb, o + 36, 0);
12660:
12661: o += 40;
12662: for (int i = 0; i < paletCount; i++) {
12663: ByteArray.byaWil (bb, o, paletTable[i] & 0x00ffffff);
12664: o += 4;
12665: }
12666:
12667: for (int y = height - 1; y >= 0; y--) {
12668: for (int x = 0; x < width; x++) {
12669: int rgb = image.getRGB (x, y);
12670: if (rgb >>> 24 != 0xff) {
12671: continue;
12672: }
12673: if (pixelBits == 24) {
12674: bb[o + 3 * x] = (byte) rgb;
12675: bb[o + 3 * x + 1] = (byte) (rgb >> 8);
12676: bb[o + 3 * x + 2] = (byte) (rgb >> 16);
12677: continue;
12678: }
12679: int l = 0;
12680: int r = paletCount;
12681: while (l < r) {
12682: int m = l + r >> 1;
12683: if (paletTable[m] < rgb) {
12684: l = m + 1;
12685: } else {
12686: r = m;
12687: }
12688: }
12689: if (l != 0) {
12690: if (pixelBits == 8) {
12691: bb[o + x] = (byte) l;
12692: } else if (pixelBits == 4) {
12693: bb[o + (x >> 1)] |= (byte) (l << ((~x & 1) << 2));
12694: } else if (pixelBits == 2) {
12695: bb[o + (x >> 2)] |= (byte) (l << ((~x & 3) << 1));
12696: } else {
12697: bb[o + (x >> 3)] |= (byte) (l << (~x & 7));
12698: }
12699: }
12700: }
12701: o += patternLineSize;
12702: }
12703:
12704: for (int y = height - 1; y >= 0; y--) {
12705: for (int x = 0; x < width; x++) {
12706: int rgb = image.getRGB (x, y);
12707: if (rgb >>> 24 != 0xff) {
12708: bb[o + (x >> 3)] |= (byte) (1 << (~x & 7));
12709: }
12710: }
12711: o += maskLineSize;
12712: }
12713: }
12714: return rscPutFile (fileName, bb, 0, fileSize);
12715: }
12716:
12717:
12718:
12719: }
12720:
12721:
12722: