XEiJ.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13: package xeij;
14:
15: import java.awt.*;
16: import java.awt.datatransfer.*;
17: import java.awt.dnd.*;
18: import java.awt.event.*;
19: import java.awt.font.*;
20: import java.awt.geom.*;
21: import java.awt.image.*;
22: import java.io.*;
23: import java.lang.*;
24: import java.math.*;
25: import java.net.*;
26: import java.nio.*;
27: import java.nio.charset.*;
28: import java.nio.file.*;
29: import java.util.*;
30: import java.util.function.*;
31: import java.util.regex.*;
32: import java.util.stream.*;
33: import java.util.zip.*;
34: import javax.imageio.*;
35: import javax.imageio.stream.*;
36: import javax.swing.*;
37: import javax.swing.event.*;
38: import javax.swing.text.*;
39:
40: public class XEiJ {
41:
42:
43:
44:
45:
46: static {
47: System.setProperty ("sun.java2d.d3d", "false");
48: System.setProperty ("sun.java2d.xrender", "false");
49: }
50:
51:
52: public static final String PRG_TITLE = "XEiJ (X68000 Emulator in Java)";
53: public static final String PRG_VERSION = "0.26.03.08";
54: public static final String PRG_AUTHOR = "Makoto Kamada";
55: public static final String PRG_WEBPAGE = "https://stdkmd.net/xeij/";
56:
57: public static final String PRG_JAVA_VENDOR = "Oracle Corporation";
58: public static final String PRG_JAVA_VERSION = "25.0.2";
59: public static final String PRG_OS_ARCH = "amd64";
60: public static final String PRG_OS_NAME = "Windows 11";
61:
62:
63:
64:
65:
66:
67:
68: public static final boolean TEST_BIT_0_SHIFT = false;
69: public static final boolean TEST_BIT_1_SHIFT = false;
70: public static final boolean TEST_BIT_2_SHIFT = true;
71: public static final boolean TEST_BIT_3_SHIFT = true;
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89: public static final boolean SHORT_SATURATION_CAST = false;
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101: public static final Charset ISO_8859_1 = Charset.forName ("ISO-8859-1");
102: static {
103: if (false) {
104:
105: StringBuilder sb = new StringBuilder ();
106: for (int i = 0; i < 256; i++) {
107: sb.append ((char) i);
108: }
109: byte[] bb = sb.toString ().getBytes (ISO_8859_1);
110: for (int i = 0; i < 256; i++) {
111: System.out.printf ("%02x %02x %s\n", i, bb[i] & 255, i == (bb[i] & 255) ? "OK" : "ERROR");
112: }
113: }
114: }
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127: public static String prgJavaVendor;
128: public static String prgJavaVersion;
129: public static String prgOsArch;
130: public static String prgOsName;
131: public static boolean prgIsLinux;
132: public static boolean prgIsMac;
133: public static boolean prgIsWindows;
134:
135: public static boolean prgCaseIgnored;
136:
137: public static boolean prgVerbose;
138:
139: public static String[] prgArgs;
140:
141:
142:
143: public static void main (String[] args) {
144:
145:
146:
147:
148: if (true) {
149: try {
150: String def = System.getProperty ("os.name").toLowerCase ().contains ("win") ? "C:\\Temp" : "/tmp";
151: Stream.of (new File (System.getProperty ("java.io.tmpdir", def),
152: "jSerialComm").getCanonicalFile ().toPath (),
153: new File (System.getProperty ("user.home", def),
154: ".jSerialComm").getCanonicalFile ().toPath ())
155: .filter (Files::exists)
156: .forEach (dir -> {
157: try {
158: Files.walk (dir)
159: .sorted (Comparator.reverseOrder ())
160: .forEach (path -> {
161: if (Files.exists (path)) {
162: try {
163: Files.delete (path);
164:
165: } catch (IOException ioe) {
166: System.err.println ("Failed to delete: " + path + " (" + ioe.getMessage () + ")");
167: }
168: }
169: });
170: } catch (IOException ioe) {
171: System.err.println ("Failed to walk: " + dir + " (" + ioe.getMessage () + ")");
172: }
173: });
174: } catch (IOException ioe) {
175: }
176: }
177:
178: prgArgs = args;
179:
180:
181: SwingUtilities.invokeLater (new Runnable () {
182: @Override public void run () {
183: new XEiJ ();
184: }
185: });
186:
187: }
188:
189:
190:
191: public XEiJ () {
192:
193: prgJavaVendor = System.getProperty ("java.vendor");
194: prgJavaVersion = System.getProperty ("java.version");
195: prgOsArch = System.getProperty ("os.arch");
196: prgOsName = System.getProperty ("os.name");
197: prgIsLinux = 0 <= prgOsName.indexOf ("Linux");
198: prgIsMac = 0 <= prgOsName.indexOf ("Mac");
199: prgIsWindows = 0 <= prgOsName.indexOf ("Windows");
200:
201: System.out.print ("\n" +
202: "-------------------------------------------------\n" +
203: PRG_TITLE + " version " + PRG_VERSION + "\n" +
204: "-------------------------------------------------\n");
205:
206:
207:
208:
209: prgCaseIgnored = new File ("A").equals (new File ("a"));
210: fmtInit ();
211: Multilingual.mlnInit ();
212:
213: System.out.println (Multilingual.mlnJapanese ? "java.vendor は " + prgJavaVendor + " です" :
214: "java.vendor is " + prgJavaVendor);
215: System.out.println (Multilingual.mlnJapanese ? "java.version は " + prgJavaVersion + " です" :
216: "java.version is " + prgJavaVersion);
217: System.out.println (Multilingual.mlnJapanese ? "os.arch は " + prgOsArch + " です" :
218: "os.arch is " + prgOsArch);
219: System.out.println (Multilingual.mlnJapanese ? "os.name は " + prgOsName + " です" :
220: "os.name is " + prgOsName);
221:
222: rbtInit ();
223:
224: Settings.sgsInit ();
225: LnF.lnfInit ();
226: Bubble.bblInit ();
227:
228: CharacterCode.chrInit ();
229:
230: TickerQueue.tkqInit ();
231:
232: RS232CTerminal.trmInit ();
233:
234: if (MercuryUnit.MU4_ON) {
235: MercuryUnit.mu4Init ();
236: }
237: xt3Init ();
238: mdlInit ();
239:
240: if (InstructionBreakPoint.IBP_ON) {
241: InstructionBreakPoint.ibpInit ();
242: }
243: if (DataBreakPoint.DBP_ON) {
244: DataBreakPoint.dbpInit ();
245: }
246: busInit ();
247: MainMemory.mmrInit ();
248: ROM.romInit ();
249: CRTC.crtInit ();
250: VideoController.vcnInit ();
251: HD63450.dmaInit ();
252: svsInit ();
253: MC68901.mfpInit ();
254: RP5C15.rtcInit ();
255: sysInit ();
256: if (OPMLog.OLG_ON) {
257: OPMLog.olgInit ();
258: }
259: OPM.opmInit ();
260: ADPCM.pcmInit ();
261: FDC.fdcInit ();
262: HDC.hdcInit ();
263: if (HostCDROM.HCD_ENABLED) {
264: HostCDROM.hcdInit ();
265: }
266: SPC.spcInit ();
267: Z8530.sccInit ();
268: IOInterrupt.ioiInit ();
269: SpriteScreen.sprInit ();
270: bnkInit ();
271: SRAM.smrInit ();
272:
273: PPI.ppiInit ();
274: PrinterPort.prnInit ();
275: Indicator.indInit ();
276:
277: SlowdownTest.sdtInit ();
278: Keyboard.kbdInit ();
279: CONDevice.conInit ();
280: Mouse.musInit ();
281: pnlInit ();
282: frmInit ();
283:
284: dbgInit ();
285: RegisterList.drpInit ();
286: DisassembleList.ddpInit ();
287: MemoryDumpList.dmpInit ();
288: LogicalSpaceMonitor.atwInit ();
289: PhysicalSpaceMonitor.paaInit ();
290: DebugConsole.dgtInit ();
291: if (BranchLog.BLG_ON) {
292: BranchLog.blgInit ();
293: }
294: if (ProgramFlowVisualizer.PFV_ON) {
295: ProgramFlowVisualizer.pfvInit ();
296: }
297: if (RasterBreakPoint.RBP_ON) {
298: RasterBreakPoint.rbpInit ();
299: }
300: if (ScreenModeTest.SMT_ON) {
301: ScreenModeTest.smtInit ();
302: }
303: if (RootPointerList.RTL_ON) {
304: RootPointerList.rtlInit ();
305: }
306: if (SpritePatternViewer.SPV_ON) {
307: SpritePatternViewer.spvInit ();
308: }
309: if (PaletteViewer.PLV_ON) {
310: PaletteViewer.plvInit ();
311: }
312: if (ATCMonitor.ACM_ON) {
313: ATCMonitor.acmInit ();
314: }
315:
316: SoundSource.sndInit ();
317: FEFunction.fpkInit ();
318: mpuInit ();
319: MC68060.mmuInit ();
320: SoundMonitor.smnInit ();
321: HFS.hfsInit ();
322:
323: GIFAnimation.gifInit ();
324: TextCopy.txcInit ();
325: ButtonFunction.bfnInit ();
326:
327:
328:
329: Settings.sgsMakeMenu ();
330: mdlMakeMenu ();
331: FDC.fdcMakeMenu ();
332: HDC.hdcMakeMenu ();
333: SPC.spcMakeMenu ();
334: mpuMakeMenu ();
335: SRAM.smrMakeMenu ();
336: clpMake ();
337: pnlMake ();
338: mnbMakeMenu ();
339: frmMake ();
340: dbgMakePopup ();
341:
342:
343: final String flags = (
344: "" +
345: (EFPBox.CIR_DEBUG_TRACE ? " EFPBox.CIR_DEBUG_TRACE" : "") +
346: (FDC.FDC_DEBUG_TRACE ? " FDC.FDC_DEBUG_TRACE" : "") +
347: (FEFunction.FPK_DEBUG_TRACE ? " FEFunction.FPK_DEBUG_TRACE" : "") +
348: (HD63450.DMA_DEBUG_TRACE != 0 ? " HD63450.DMA_DEBUG_TRACE" : "") +
349: (HDC.HDC_DEBUG_TRACE ? " HDC.HDC_DEBUG_TRACE" : "") +
350: (HDC.HDC_DEBUG_COMMAND ? " HDC.HDC_DEBUG_COMMAND" : "") +
351: (HFS.HFS_DEBUG_TRACE ? " HFS.HFS_DEBUG_TRACE" : "") +
352: (HFS.HFS_DEBUG_FILE_INFO ? " HFS.HFS_DEBUG_FILE_INFO" : "") +
353: (HFS.HFS_COMMAND_TRACE ? " HFS.HFS_COMMAND_TRACE" : "") +
354: (HFS.HFS_BUFFER_TRACE ? " HFS.HFS_BUFFER_TRACE" : "") +
355: (IOInterrupt.IOI_DEBUG_TRACE ? " IOInterrupt.IOI_DEBUG_TRACE" : "") +
356: (Keyboard.KBD_DEBUG_LED ? " Keyboard.KBD_DEBUG_LED" : "") +
357: (MC68060.MMU_DEBUG_COMMAND ? " MC68060.MMU_DEBUG_COMMAND" : "") +
358: (MC68060.MMU_DEBUG_TRANSLATION ? " MC68060.MMU_DEBUG_TRANSLATION" : "") +
359: (MC68060.MMU_NOT_ALLOCATE_CACHE ? " MC68060.MMU_NOT_ALLOCATE_CACHE" : "") +
360: (RP5C15.RTC_DEBUG_TRACE ? " RP5C15.RTC_DEBUG_TRACE" : "") +
361: (SPC.SPC_DEBUG_ON ? " SPC.SPC_DEBUG_ON" : "") +
362: (Z8530.SCC_DEBUG_ON ? " Z8530.SCC_DEBUG_ON" : "")
363: );
364: if (!"".equals (flags)) {
365: pnlExitFullScreen (true);
366: JOptionPane.showMessageDialog (null, "debug flags:" + flags);
367: }
368:
369:
370:
371:
372: tmrStart ();
373:
374: Keyboard.kbdStart ();
375: Mouse.musStart ();
376: pnlStart ();
377: frmStart ();
378: SoundSource.sndStart ();
379:
380: if (DataBreakPoint.DBP_ON) {
381: DataBreakPoint.dbpStart ();
382: }
383: if (RasterBreakPoint.RBP_ON) {
384: RasterBreakPoint.rbpStart ();
385: }
386: if (ScreenModeTest.SMT_ON) {
387: ScreenModeTest.smtStart ();
388: }
389: if (OPMLog.OLG_ON) {
390: OPMLog.olgStart ();
391: }
392: SoundMonitor.smnStart ();
393: RS232CTerminal.trmStart ();
394: PPI.ppiStart ();
395: PrinterPort.prnStart ();
396: if (BranchLog.BLG_ON) {
397: BranchLog.blgStart ();
398: }
399: if (ProgramFlowVisualizer.PFV_ON) {
400: ProgramFlowVisualizer.pfvStart ();
401: }
402: RegisterList.drpStart ();
403: DisassembleList.ddpStart ();
404: MemoryDumpList.dmpStart ();
405: LogicalSpaceMonitor.atwStart ();
406: PhysicalSpaceMonitor.paaStart ();
407: DebugConsole.dgtStart ();
408: if (RootPointerList.RTL_ON) {
409: RootPointerList.rtlStart ();
410: }
411: if (SpritePatternViewer.SPV_ON) {
412: SpritePatternViewer.spvStart ();
413: }
414: if (PaletteViewer.PLV_ON) {
415: PaletteViewer.plvStart ();
416: }
417: if (ATCMonitor.ACM_ON) {
418: ATCMonitor.acmStart ();
419: }
420: ButtonFunction.bfnStart ();
421:
422: if (Settings.sgsSaveiconValue != null) {
423: String[] a = Settings.sgsSaveiconValue.split (",");
424: if (0 < a.length) {
425: saveIcon (a[0], LnF.LNF_ICON_IMAGES);
426: if (1 < a.length) {
427: saveImage (LnF.LNF_ICON_IMAGE_16, a[1]);
428: if (2 < a.length) {
429: saveImage (LnF.LNF_ICON_IMAGE_32, a[2]);
430: if (3 < a.length) {
431: saveImage (LnF.LNF_ICON_IMAGE_48, a[3]);
432: }
433: }
434: }
435: }
436: prgTini ();
437: return;
438: }
439:
440:
441: mpuReset (-1, -1);
442:
443: pnlBoot2 ();
444:
445: }
446:
447:
448:
449:
450:
451: public static void prgTini () {
452: try {
453: if (OPMLog.OLG_ON) {
454: OPMLog.olgTini ();
455: }
456: ButtonFunction.bfnTini ();
457: TextCopy.txcTini ();
458: GIFAnimation.gifTini ();
459: SoundSource.sndTini ();
460: Keyboard.kbdTini ();
461: Mouse.musTini ();
462: CONDevice.conTini ();
463: PPI.ppiTini ();
464: PrinterPort.prnTini ();
465: FDC.fdcTini ();
466: HDC.hdcTini ();
467: if (HostCDROM.HCD_ENABLED) {
468: HostCDROM.hcdTini ();
469: }
470: SPC.spcTini ();
471: HFS.hfsTini ();
472: Z8530.sccTini ();
473: CRTC.crtTini ();
474: SpriteScreen.sprTini ();
475: pnlTini ();
476: bnkTini ();
477: ROM.romTini ();
478: if (MercuryUnit.MU4_ON) {
479: MercuryUnit.mu4Tini ();
480: }
481: xt3Tini ();
482: mdlTini ();
483: SRAM.smrTini ();
484: tmrTini ();
485: busTini ();
486: if (SpritePatternViewer.SPV_ON) {
487: SpritePatternViewer.spvTini ();
488: }
489: if (PaletteViewer.PLV_ON) {
490: PaletteViewer.plvTini ();
491: }
492: RS232CTerminal.trmTini ();
493: LnF.lnfTini ();
494: Settings.sgsTini ();
495: } catch (Exception e) {
496: e.printStackTrace ();
497: }
498: System.exit (0);
499: }
500:
501:
502:
503: public static void prgOpenJavaDialog () {
504: pnlExitFullScreen (true);
505: JOptionPane.showMessageDialog (
506: frmFrame,
507: ComponentFactory.createGridPanel (
508: 3,
509: 6,
510: "paddingLeft=6,paddingRight=6",
511: "italic,right;left;left",
512: "italic,center;colSpan=3,widen",
513: "",
514:
515: null,
516: Multilingual.mlnJapanese ? "実行中" : "Running",
517: Multilingual.mlnJapanese ? "推奨" : "Recommended",
518:
519: ComponentFactory.createHorizontalSeparator (),
520:
521: Multilingual.mlnJapanese ? "Java のベンダー" : "Java Vendor",
522: prgJavaVendor,
523: PRG_JAVA_VENDOR,
524:
525: Multilingual.mlnJapanese ? "Java のバージョン" : "Java Version",
526: prgJavaVersion,
527: PRG_JAVA_VERSION,
528:
529: Multilingual.mlnJapanese ? "OS のアーキテクチャ" : "OS Architecture",
530: prgOsArch,
531: PRG_OS_ARCH,
532:
533: Multilingual.mlnJapanese ? "OS の名前" : "OS Name",
534: prgOsName,
535: PRG_OS_NAME
536: ),
537: Multilingual.mlnJapanese ? "Java 実行環境の情報" : "Java runtime environment information",
538: JOptionPane.PLAIN_MESSAGE);
539: }
540:
541:
542:
543: public static void prgOpenAboutDialog () {
544: pnlExitFullScreen (true);
545: JOptionPane.showMessageDialog (
546: frmFrame,
547: ComponentFactory.createGridPanel (
548: 2, 4, "paddingLeft=6,paddingRight=6", "italic,right;left", "", "",
549: Multilingual.mlnJapanese ? "タイトル" : "Title" ,
550: PRG_TITLE,
551: Multilingual.mlnJapanese ? "バージョン" : "Version",
552: PRG_VERSION,
553: Multilingual.mlnJapanese ? "作者" : "Author" ,
554: PRG_AUTHOR,
555: Multilingual.mlnJapanese ? "ウェブページ" : "Webpage",
556: PRG_WEBPAGE
557: ),
558: Multilingual.mlnJapanese ? "バージョン情報" : "Version information",
559: JOptionPane.PLAIN_MESSAGE);
560: }
561:
562:
563:
564: public static void prgOpenXEiJLicenseDialog () {
565: pnlExitFullScreen (true);
566: JOptionPane.showMessageDialog (
567: frmFrame,
568: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_XEiJ.txt"), 550, 300),
569: Multilingual.mlnJapanese ? "XEiJ 使用許諾条件" : "XEiJ License",
570: JOptionPane.PLAIN_MESSAGE);
571: }
572:
573:
574:
575: public static void prgOpenSHARPLicenseDialog () {
576: pnlExitFullScreen (true);
577: JOptionPane.showMessageDialog (
578: frmFrame,
579: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_FSHARP.txt", "Shift_JIS"), 550, 300),
580: Multilingual.mlnJapanese ? "無償公開された X68000 の基本ソフトウェア製品の許諾条件" : "License of the basic software products for X68000 that were distributed free of charge",
581: JOptionPane.PLAIN_MESSAGE);
582: }
583:
584:
585:
586: public static void prgOpenYmfmLicenseDialog () {
587: pnlExitFullScreen (true);
588: JOptionPane.showMessageDialog (
589: frmFrame,
590: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_ymfm.txt"), 550, 300),
591: "ymfm License",
592: JOptionPane.PLAIN_MESSAGE);
593: }
594:
595:
596:
597: public static void prgOpenJSerialCommLicenseDialog () {
598: pnlExitFullScreen (true);
599: JOptionPane.showMessageDialog (
600: frmFrame,
601: ComponentFactory.createVerticalSplitPane (
602: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-APACHE-2.0"), 550, 300),
603: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-LGPL-3.0"), 550, 300)
604: ),
605: "jSerialComm License",
606: JOptionPane.PLAIN_MESSAGE);
607: }
608:
609:
610:
611: public static void prgPrintClass (Object o) {
612: System.out.println (o.toString ());
613:
614: try {
615: Stack<Class<?>> s = new Stack<Class<?>> ();
616: for (Class<?> c = o.getClass (); c != null; c = c.getSuperclass ()) {
617: s.push (c);
618: }
619: for (int i = 0; !s.empty (); i++) {
620: for (int j = 0; j < i; j++) {
621: System.out.print (" ");
622: }
623: System.out.println (s.pop ().getName ());
624: }
625: } catch (Exception e) {
626: }
627: }
628:
629:
630:
631:
632: public static void prgPrintStackTrace () {
633: Exception e = new Exception ();
634: e.fillInStackTrace ();
635: prgPrintStackTraceOf (e);
636: }
637: public static void prgPrintStackTraceOf (Exception e) {
638:
639: System.out.println ("------------------------------------------------");
640: System.out.println (e.toString ());
641: System.out.println ("\t" + e.getMessage ());
642: for (StackTraceElement ste : e.getStackTrace ()) {
643: System.out.println ("\tat " + ste.toString ());
644: }
645: System.out.println ("------------------------------------------------");
646: }
647:
648:
649:
650:
651: public static boolean prgStopDone = false;
652: public static void prgStopOnce () {
653: if (!prgStopDone) {
654: prgStopDone = true;
655: mpuStop (null);
656: }
657: }
658:
659:
660:
661:
662:
663:
664:
665:
666:
667:
668:
669:
670:
671:
672:
673:
674:
675:
676:
677:
678:
679:
680:
681:
682:
683:
684:
685:
686:
687:
688:
689: public static final long TMR_FREQ = 1000000000000L;
690:
691:
692: public static final long TMR_DELAY = 10L;
693: public static final long TMR_INTERVAL = 10L;
694:
695:
696: public static java.util.Timer tmrTimer;
697:
698:
699:
700: public static void tmrStart () {
701: tmrTimer = new java.util.Timer ();
702: }
703:
704:
705:
706: public static void tmrTini () {
707: if (tmrTimer != null) {
708: tmrTimer.cancel ();
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:
740:
741:
742:
743:
744:
745:
746: public static final int PNL_BM_OFFSET_BITS = 10;
747: public static final int PNL_BM_WIDTH = 1 << PNL_BM_OFFSET_BITS;
748: public static final int PNL_BM_HEIGHT = 1024;
749:
750:
751: public static final int PNL_ASPECT_KEYS = 4;
752: public static final int PNL_ASPECT_VALUES = 5;
753: public static final int[] PNL_ASPECT_DEFAULT_VALUE = { 1, 1, 1, 4 };
754: public static final String[] PNL_ASPECT_RESOLUTION_NAME = { "256x256", "384x256", "512x512", "768x512" };
755: public static final String[] PNL_ASPECT_SCREEN_NAME = { "1:1", "4:3", "7:5", "13:9", "3:2" };
756: public static final String[] PNL_ASPECT_PIXEL_NAME = { null, "8:9", "14:15", "26:27", "1:1" };
757: public static final float[] PNL_ASPECT_SCREEN_RATIO = { 1.0F / 1.0F, 4.0F / 3.0F, 7.0F / 5.0F, 13.0F / 9.0F, 3.0F / 2.0F };
758: public static final float[] PNL_ASPECT_PIXEL_RATIO = { 0.0F, 8.0F / 9.0F, 14.0F / 15.0F, 26.0F / 27.0F, 1.0F / 1.0F };
759: public static final float[][] PNL_ASPECT_MATRIX = {
760: PNL_ASPECT_SCREEN_RATIO,
761: PNL_ASPECT_PIXEL_RATIO,
762: PNL_ASPECT_SCREEN_RATIO,
763: PNL_ASPECT_PIXEL_RATIO,
764: };
765: public static int[] pnlAspectMap;
766: public static float[] pnlAspectTable;
767:
768:
769: public static final int PNL_MIN_WIDTH = 64;
770: public static final int PNL_MIN_HEIGHT = 64;
771: public static int pnlScreenWidth;
772: public static int pnlScreenHeight;
773: public static float pnlStretchMode;
774: public static int pnlStretchWidth;
775:
776: public static boolean PNL_ROTATION_ON = true;
777: public static int pnlRotationMode;
778: public static AffineTransform pnlRotationTransformLeft;
779: public static AffineTransform pnlRotationTransformRight;
780: public static double pnlMatrixL00, pnlMatrixL10, pnlMatrixL01, pnlMatrixL11, pnlMatrixL02, pnlMatrixL12;
781: public static double pnlMatrixR00, pnlMatrixR10, pnlMatrixR01, pnlMatrixR11, pnlMatrixR02, pnlMatrixR12;
782: public static double pnlInverseL00, pnlInverseL10, pnlInverseL01, pnlInverseL11, pnlInverseL02, pnlInverseL12;
783: public static double pnlInverseR00, pnlInverseR10, pnlInverseR01, pnlInverseR11, pnlInverseR02, pnlInverseR12;
784: public static int pnlRotatedWidth;
785: public static int pnlRotatedHeight;
786:
787: public static int pnlZoomWidth;
788: public static int pnlZoomHeight;
789: public static int pnlZoomRatioOutX;
790: public static int pnlZoomRatioOutY;
791: public static int pnlZoomRatioInX;
792: public static int pnlZoomRatioInY;
793: public static int pnlWidth;
794: public static int pnlHeight;
795: public static Dimension pnlSize;
796: public static int pnlScreenX1;
797: public static int pnlScreenX2;
798: public static int pnlScreenX3;
799: public static int pnlScreenX4;
800: public static int pnlScreenY1;
801: public static int pnlScreenY2;
802: public static int pnlScreenY3;
803: public static int pnlScreenY4;
804: public static int pnlKeyboardX;
805: public static int pnlKeyboardY;
806: public static int pnlMinimumWidth;
807: public static int pnlMinimumHeight;
808: public static int pnlGlobalX;
809: public static int pnlGlobalY;
810:
811:
812: public static final boolean PNL_FILL_BACKGROUND = true;
813: public static boolean pnlFillBackgroundRequest;
814: public static boolean pnlIsFullScreenSupported;
815: public static boolean pnlPrevKeyboardOn;
816: public static boolean pnlHideKeyboard;
817:
818:
819:
820:
821:
822: public static Object pnlInterpolation;
823:
824:
825: public static final double PNL_MIN_RATE = 1.0;
826: public static final double PNL_MAX_RATE = 1000.0;
827: public static final double PNL_DEFAULT_RATE = 59.94;
828: public static double pnlRefreshRate;
829: public static double pnlFixedRate;
830: public static boolean pnlAdjustVsync;
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:
874:
875:
876:
877:
878:
879:
880: public static final boolean PNL_STEREOSCOPIC_ON = true;
881:
882: public static final boolean PNL_USE_THREAD = true;
883:
884: public static BufferedImage[] pnlScreenImageLeftArray;
885: public static BufferedImage[] pnlScreenImageRightArray;
886:
887: public static BufferedImage[] pnlScreenSubImageLeftArray;
888: public static BufferedImage[] pnlScreenSubImageRightArray;
889:
890: public static int[][] pnlBMLeftArray;
891: public static int[][] pnlBMRightArray;
892: public static volatile int pnlBMWrite;
893: public static volatile int pnlBMRead;
894:
895: public static BufferedImage pnlScreenImageLeft;
896: public static BufferedImage pnlScreenImageRight;
897:
898: public static BufferedImage pnlScreenSubImageLeft;
899: public static BufferedImage pnlScreenSubImageRight;
900:
901: public static int[] pnlBMLeft;
902: public static int[] pnlBMRight;
903:
904: public static int[] pnlBM;
905: public static boolean pnlStereoscopicOn;
906: public static final int PNL_NAKED_EYE_CROSSING = 0;
907: public static final int PNL_NAKED_EYE_PARALLEL = 1;
908: public static final int PNL_SIDE_BY_SIDE = 2;
909: public static final int PNL_TOP_AND_BOTTOM = 3;
910: public static int pnlStereoscopicMethod;
911: public static int pnlStereoscopicFactor;
912: public static int pnlStereoscopicShutter;
913:
914:
915: public static JPanel pnlPanel;
916:
917: public static Thread pnlThread;
918: public static long pnlWakeupTime;
919: public static long pnlWakeupTimeMNP;
920: public static final boolean PNL_USE_CANVAS = PNL_USE_THREAD && true;
921:
922: public static boolean pnlUseCanvasRequest;
923: public static boolean pnlUseCanvas;
924: public static Canvas pnlCanvas;
925: public static Component pnlCanvasOrPanel;
926:
927:
928:
929:
930: public static int pnlFixedScale;
931: public static SpinnerNumberModel pnlFixedModel;
932: public static JSpinner pnlFixedSpinner;
933:
934:
935:
936: public static void pnlInit () {
937: pnlInit2 ();
938:
939:
940:
941:
942: pnlFixedScale = Math.max (10, Math.min (1000, Settings.sgsGetInt ("fixedscale")));
943:
944:
945: pnlAspectMap = new int[PNL_ASPECT_KEYS];
946: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
947: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[key];
948: String screenName = Settings.sgsGetString ("aspectratio" + resolutionName);
949: int value = PNL_ASPECT_DEFAULT_VALUE[key];
950: for (int tempValue = 0; tempValue < PNL_ASPECT_VALUES; tempValue++) {
951: if (PNL_ASPECT_MATRIX[key][tempValue] == 0.0F) {
952: continue;
953: }
954: if (PNL_ASPECT_SCREEN_NAME[tempValue].equals (screenName)) {
955: value = tempValue;
956: break;
957: }
958: }
959: pnlAspectMap[key] = value;
960: }
961: pnlAspectTable = new float[8];
962: pnlUpdateAspectTable ();
963:
964:
965: switch (Settings.sgsGetString ("interpolation").toLowerCase ()) {
966: case "nearest":
967: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
968: break;
969: case "bilinear":
970: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
971: break;
972: case "bicubic":
973: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
974: break;
975: default:
976: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
977: }
978:
979:
980: pnlRefreshRate = 0.0;
981: {
982: String s = Settings.sgsGetString ("refreshrate");
983: if (!s.equals ("")) {
984: try {
985: double rate = Double.parseDouble (s);
986: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
987: pnlRefreshRate = rate;
988: }
989: } catch (NumberFormatException nfe) {
990: }
991: }
992: }
993: pnlFixedRate = pnlRefreshRate;
994: pnlAdjustVsync = Settings.sgsGetOnOff ("adjustvsync");
995:
996: pnlPrevKeyboardOn = true;
997:
998: pnlHideKeyboard = Settings.sgsGetOnOff ("hidekeyboard");
999:
1000:
1001: if (PNL_USE_THREAD) {
1002: pnlScreenImageLeftArray = new BufferedImage[4];
1003: pnlScreenImageRightArray = new BufferedImage[4];
1004: if (PNL_ROTATION_ON) {
1005: pnlScreenSubImageLeftArray = new BufferedImage[4];
1006: pnlScreenSubImageRightArray = new BufferedImage[4];
1007: }
1008: pnlBMLeftArray = new int[4][];
1009: pnlBMRightArray = new int[4][];
1010: for (int n = 0; n < 4; n++) {
1011: pnlScreenImageLeftArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1012: pnlScreenImageRightArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1013: if (PNL_ROTATION_ON) {
1014: pnlScreenSubImageLeftArray[n] = null;
1015: pnlScreenSubImageRightArray[n] = null;
1016: }
1017: pnlBMLeftArray[n] = ((DataBufferInt) pnlScreenImageLeftArray[n].getRaster ().getDataBuffer ()).getData ();
1018: pnlBMRightArray[n] = ((DataBufferInt) pnlScreenImageRightArray[n].getRaster ().getDataBuffer ()).getData ();
1019: }
1020: pnlBMWrite = 0;
1021: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
1022: pnlBMRead = 0;
1023: pnlThread = null;
1024: pnlWakeupTime = 0L;
1025: pnlWakeupTimeMNP = 0L;
1026: if (PNL_USE_CANVAS) {
1027: pnlUseCanvasRequest = Settings.sgsGetOnOff ("usecanvas");
1028: pnlUseCanvas = pnlUseCanvasRequest;
1029: pnlCanvas = null;
1030: }
1031: } else {
1032: pnlScreenImageLeft = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1033: pnlScreenImageRight = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1034: if (PNL_ROTATION_ON) {
1035: pnlScreenSubImageLeft = null;
1036: pnlScreenSubImageRight = null;
1037: }
1038: pnlBMLeft = ((DataBufferInt) pnlScreenImageLeft.getRaster ().getDataBuffer ()).getData ();
1039: pnlBMRight = ((DataBufferInt) pnlScreenImageRight.getRaster ().getDataBuffer ()).getData ();
1040: pnlBM = pnlBMLeft;
1041: }
1042: pnlStereoscopicOn = Settings.sgsGetOnOff ("stereoscopic");
1043: switch (Settings.sgsGetString ("stereoscopicmethod").toLowerCase ()) {
1044: case "nakedeyecrossing":
1045: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
1046: break;
1047: case "nakedeyeparallel":
1048: pnlStereoscopicMethod = PNL_NAKED_EYE_PARALLEL;
1049: break;
1050: case "sidebyside":
1051: pnlStereoscopicMethod = PNL_SIDE_BY_SIDE;
1052: break;
1053: case "topandbottom":
1054: pnlStereoscopicMethod = PNL_TOP_AND_BOTTOM;
1055: break;
1056: default:
1057: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
1058: }
1059: pnlStereoscopicFactor = pnlStereoscopicOn && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1060: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1061: pnlStereoscopicShutter = 0;
1062:
1063:
1064: pnlScreenWidth = 768;
1065: pnlScreenHeight = 512;
1066: pnlStretchMode = 1.0F;
1067: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchMode);
1068:
1069: if (PNL_ROTATION_ON) {
1070: pnlRotationMode = Settings.sgsGetInt ("rotation", 0);
1071: if (pnlRotationMode < 0 || 3 < pnlRotationMode) {
1072: pnlRotationMode = 0;
1073: }
1074: pnlRotationTransformLeft = new AffineTransform ();
1075: pnlRotationTransformRight = new AffineTransform ();
1076: }
1077: pnlRotatedWidth = pnlStretchWidth;
1078: pnlRotatedHeight = pnlScreenHeight;
1079: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1080: pnlRotatedWidth = pnlScreenHeight;
1081: pnlRotatedHeight = pnlStretchWidth;
1082: }
1083:
1084: pnlZoomWidth = pnlRotatedWidth;
1085: pnlZoomHeight = pnlRotatedHeight;
1086: pnlWidth = Math.max (pnlZoomWidth * pnlStereoscopicFactor, Keyboard.kbdWidth);
1087: pnlHeight = pnlZoomHeight + Keyboard.kbdHeight;
1088: pnlSize = new Dimension (pnlWidth, pnlHeight);
1089: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1090: pnlScreenY1 = 0;
1091: pnlArrangementCommon ();
1092: pnlMinimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
1093: pnlMinimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
1094: pnlGlobalX = 0;
1095: pnlGlobalY = 0;
1096:
1097:
1098: if (!PNL_FILL_BACKGROUND) {
1099: pnlFillBackgroundRequest = true;
1100: }
1101:
1102:
1103: pnlFixedModel = new SpinnerNumberModel (pnlFixedScale, 10, 1000, 1);
1104: pnlFixedSpinner = ComponentFactory.createNumberSpinner (pnlFixedModel, 4, new ChangeListener () {
1105: @Override public void stateChanged (ChangeEvent ce) {
1106: if (pnlMode != PNL_FIXEDSCALE) {
1107: pnlSetMode (PNL_FIXEDSCALE);
1108: } else {
1109: pnlUpdateArrangement ();
1110: }
1111: }
1112: });
1113:
1114: }
1115:
1116:
1117:
1118: public static double pnlGetRefreshRate () {
1119: double rate = 0.0;
1120: GraphicsConfiguration gc = frmFrame.getGraphicsConfiguration ();
1121: if (gc != null) {
1122: GraphicsDevice gd = gc.getDevice ();
1123: DisplayMode dm = gd.getDisplayMode ();
1124: int i = dm.getRefreshRate ();
1125: if (i != DisplayMode.REFRESH_RATE_UNKNOWN) {
1126: rate = (i == 23 ? 23.98 :
1127: i == 29 ? 29.97 :
1128: i == 59 ? 59.94 :
1129: i == 119 ? 119.88 :
1130: i == 239 ? 239.76 :
1131: (double) i);
1132: if (rate < PNL_MIN_RATE || PNL_MAX_RATE < rate) {
1133: rate = 0.0;
1134: }
1135: }
1136: }
1137: if (rate == 0.0) {
1138: rate = PNL_DEFAULT_RATE;
1139: System.out.printf (Multilingual.mlnJapanese ?
1140: "ホストのリフレッシュレートを取得できません。デフォルトの %.2f Hz を使います\n" :
1141: "Cannot get host refresh rate. Use default %.2f Hz\n", rate);
1142: } else {
1143: System.out.printf (Multilingual.mlnJapanese ?
1144: "ホストのリフレッシュレートは %.2f Hz です\n" :
1145: "Host refresh rate is %.2f Hz\n", rate);
1146: }
1147: return rate;
1148: }
1149:
1150:
1151: public static void pnlSetStereoscopic (boolean on, int method) {
1152: if (pnlStereoscopicOn != on || pnlStereoscopicMethod != method) {
1153: pnlStereoscopicMethod = method;
1154: pnlStereoscopicFactor = on && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1155: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1156: if (!pnlStereoscopicOn && on) {
1157: if (PNL_USE_THREAD) {
1158: for (int n = 0; n < 4; n++) {
1159: System.arraycopy (pnlBMLeftArray[n], 0, pnlBMRightArray[n], 0, 1024 * 1024);
1160: }
1161: } else {
1162: System.arraycopy (pnlBMLeft, 0, pnlBMRight, 0, 1024 * 1024);
1163: }
1164: } else if (pnlStereoscopicOn && !on) {
1165: if (PNL_USE_THREAD) {
1166: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
1167: } else {
1168: pnlBM = pnlBMLeft;
1169: }
1170: }
1171: pnlStereoscopicOn = on;
1172: pnlUpdateArrangement ();
1173: }
1174: }
1175:
1176:
1177: public static void pnlTini () {
1178: pnlTini2 ();
1179: if (PNL_USE_THREAD) {
1180: if (pnlThread != null) {
1181: pnlThread.interrupt ();
1182: try {
1183: pnlThread.join ();
1184: } catch (InterruptedException ie) {
1185: }
1186: pnlThread = null;
1187: }
1188: }
1189:
1190:
1191: Settings.sgsPutInt ("fixedscale", pnlFixedScale);
1192:
1193:
1194: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
1195: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[key];
1196: int value = pnlAspectMap[key];
1197: String screenName = PNL_ASPECT_SCREEN_NAME[value];
1198: Settings.sgsPutString ("aspectratio" + resolutionName, screenName);
1199: }
1200:
1201:
1202: Settings.sgsPutString ("interpolation",
1203: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR ? "nearest" :
1204: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR ? "bilinear" :
1205: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC ? "bicubic" :
1206: "bilinear");
1207:
1208: if (pnlRefreshRate != PNL_DEFAULT_RATE) {
1209: Settings.sgsPutString ("refreshrate",
1210: pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate));
1211: }
1212: Settings.sgsPutOnOff ("adjustvsync", pnlAdjustVsync);
1213:
1214: Settings.sgsPutOnOff ("hidekeyboard", pnlHideKeyboard);
1215:
1216: if (PNL_USE_CANVAS) {
1217: Settings.sgsPutOnOff ("usecanvas", pnlUseCanvasRequest);
1218: }
1219:
1220:
1221: Settings.sgsPutOnOff ("stereoscopic", pnlStereoscopicOn);
1222: Settings.sgsPutString ("stereoscopicmethod",
1223: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ? "nakedeyecrossing" :
1224: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL ? "nakedeyeparallel" :
1225: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ? "sidebyside" :
1226: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM ? "topandbottom" :
1227: "nakedeyecrossing");
1228:
1229:
1230: if (PNL_ROTATION_ON) {
1231: Settings.sgsPutInt ("rotation", pnlRotationMode);
1232: }
1233:
1234: }
1235:
1236:
1237:
1238: public static void pnlUpdateAspectTable () {
1239: float[] ratio = new float[PNL_ASPECT_KEYS];
1240: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
1241: int value = pnlAspectMap[key];
1242: ratio[key] = PNL_ASPECT_MATRIX[key][value];
1243: }
1244: pnlAspectTable[0] = ratio[0] * 2.0F;
1245: pnlAspectTable[1] = ratio[2];
1246: pnlAspectTable[2] = ratio[3];
1247: pnlAspectTable[3] = ratio[3];
1248: pnlAspectTable[4] = ratio[1] * 4.0F;
1249: pnlAspectTable[5] = ratio[1] * 2.0F;
1250: pnlAspectTable[6] = ratio[3];
1251: pnlAspectTable[7] = ratio[3];
1252: }
1253:
1254:
1255:
1256: public static void pnlMake () {
1257: pnlMake2 ();
1258:
1259:
1260: if (PNL_USE_CANVAS && pnlUseCanvas) {
1261: pnlCanvas = new Canvas ();
1262: pnlPanel = new JPanel (new BorderLayout (0, 0));
1263: pnlPanel.add (pnlCanvas, BorderLayout.CENTER);
1264: pnlCanvasOrPanel = pnlCanvas;
1265: } else {
1266: pnlPanel = new JPanel () {
1267: @Override protected void paintComponent (Graphics g) {
1268: pnlPaintCommon (g);
1269: }
1270: @Override protected void paintBorder (Graphics g) {
1271: }
1272: @Override protected void paintChildren (Graphics g) {
1273: }
1274: };
1275: pnlCanvasOrPanel = pnlPanel;
1276: }
1277: pnlPanel.setBackground (Color.black);
1278: pnlPanel.setOpaque (true);
1279: pnlPanel.setPreferredSize (pnlSize);
1280:
1281: if (Mouse.musCursorAvailable) {
1282: pnlPanel.setCursor (Mouse.musCursorArray[1]);
1283: }
1284:
1285: }
1286:
1287:
1288:
1289: public static void pnlPaintCommon (Graphics g) {
1290: Graphics2D g2 = (Graphics2D) g;
1291: if (PNL_FILL_BACKGROUND || pnlFillBackgroundRequest) {
1292: if (!PNL_FILL_BACKGROUND) {
1293: pnlFillBackgroundRequest = false;
1294: }
1295: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1296: g2.setColor (Color.black);
1297: g2.fillRect (0, 0, pnlWidth, pnlHeight);
1298: }
1299: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, pnlInterpolation);
1300: if (PNL_USE_THREAD) {
1301: int d = pnlBMWrite - pnlBMRead;
1302: if (false) {
1303: System.out.print (d);
1304: }
1305: if (d < 1) {
1306: pnlBMRead += d - 1;
1307: } else if (3 < d) {
1308: pnlBMRead += d - 3;
1309: }
1310: int n = pnlBMRead++ & 3;
1311: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1312: BufferedImage leftImage;
1313: BufferedImage rightImage;
1314: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1315: leftImage = pnlScreenImageRightArray[n];
1316: rightImage = pnlScreenImageLeftArray[n];
1317: } else {
1318:
1319:
1320:
1321: leftImage = pnlScreenImageLeftArray[n];
1322: rightImage = pnlScreenImageRightArray[n];
1323: }
1324: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1325: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1326: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1327: } else {
1328: g2.drawImage (leftImage,
1329: pnlScreenX1, pnlScreenY1,
1330: pnlScreenX2, pnlScreenY2,
1331: 0, 0, pnlScreenWidth, pnlScreenHeight,
1332: null);
1333: g2.drawImage (rightImage,
1334: pnlScreenX3, pnlScreenY3,
1335: pnlScreenX4, pnlScreenY4,
1336: 0, 0, pnlScreenWidth, pnlScreenHeight,
1337: null);
1338: }
1339: } else {
1340: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1341: g2.drawImage (pnlScreenSubImageLeftArray[n], pnlRotationTransformLeft, null);
1342: } else {
1343: g2.drawImage (pnlScreenImageLeftArray[n],
1344: pnlScreenX1, pnlScreenY1,
1345: pnlScreenX2, pnlScreenY2,
1346: 0, 0, pnlScreenWidth, pnlScreenHeight,
1347: null);
1348: }
1349: }
1350: } else {
1351: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1352: BufferedImage leftImage;
1353: BufferedImage rightImage;
1354: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1355: leftImage = pnlScreenImageRight;
1356: rightImage = pnlScreenImageLeft;
1357: } else {
1358:
1359:
1360:
1361: leftImage = pnlScreenImageLeft;
1362: rightImage = pnlScreenImageRight;
1363: }
1364: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1365: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1366: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1367: } else {
1368: g2.drawImage (leftImage,
1369: pnlScreenX1, pnlScreenY1,
1370: pnlScreenX2, pnlScreenY2,
1371: 0, 0, pnlScreenWidth, pnlScreenHeight,
1372: null);
1373: g2.drawImage (rightImage,
1374: pnlScreenX3, pnlScreenY3,
1375: pnlScreenX4, pnlScreenY4,
1376: 0, 0, pnlScreenWidth, pnlScreenHeight,
1377: null);
1378: }
1379: } else {
1380: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1381: g2.drawImage (pnlScreenImageLeft, pnlRotationTransformLeft, null);
1382: } else {
1383: g2.drawImage (pnlScreenImageLeft,
1384: pnlScreenX1, pnlScreenY1,
1385: pnlScreenX2, pnlScreenY2,
1386: 0, 0, pnlScreenWidth, pnlScreenHeight,
1387: null);
1388: }
1389: }
1390: }
1391: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1392: g2.drawImage (Keyboard.kbdImage, pnlKeyboardX, pnlKeyboardY, null);
1393:
1394: if (TextCopy.txcEncloseEachTime && 0 <= TextCopy.txcRow1) {
1395: int x = TextCopy.txcCol1 << 3;
1396: int w = (TextCopy.txcCol2 - TextCopy.txcCol1 + 1) << 3;
1397: int y = TextCopy.txcRow1 << 4;
1398: int h = (TextCopy.txcRow2 - TextCopy.txcRow1 + 1) << 4;
1399: x -= CRTC.crtR10TxXCurr;
1400: y -= CRTC.crtR11TxYCurr;
1401: g2.setColor (Color.red);
1402: if (PNL_ROTATION_ON) {
1403: AffineTransform savedTransform = g2.getTransform ();
1404: g2.setTransform (pnlRotationTransformLeft);
1405: g2.drawRect (x, y, w, h);
1406: g2.setTransform (savedTransform);
1407: } else {
1408: g2.drawRect (pnlScreenX1 + ((x * pnlZoomRatioOutX) >> 16),
1409: pnlScreenY1 + ((y * pnlZoomRatioOutY) >> 16),
1410: ((w * pnlZoomRatioOutX) >> 16) - 1,
1411: ((h * pnlZoomRatioOutY) >> 16) - 1);
1412: }
1413: }
1414: if (Bubble.BBL_ON) {
1415: Bubble.bblDraw (g2);
1416: }
1417: }
1418:
1419:
1420:
1421:
1422: public static void pnlStart () {
1423: pnlStart2 ();
1424:
1425:
1426: ComponentFactory.addListener (
1427: pnlPanel,
1428: new ComponentAdapter () {
1429: @Override public void componentResized (ComponentEvent ce) {
1430: pnlUpdateArrangement ();
1431: }
1432: });
1433:
1434: if (PNL_USE_THREAD) {
1435: if (PNL_USE_CANVAS && pnlUseCanvas) {
1436: pnlCanvas.createBufferStrategy (2);
1437: pnlThread = new Thread () {
1438: @Override public void run () {
1439: do {
1440: BufferStrategy bs = pnlCanvas.getBufferStrategy ();
1441: if (bs != null) {
1442: Graphics g = bs.getDrawGraphics ();
1443: pnlPaintCommon (g);
1444: g.dispose ();
1445: bs.show ();
1446: }
1447: } while (!isInterrupted () && pnlWakeupCommon ());
1448: }
1449: };
1450: } else {
1451: pnlThread = new Thread () {
1452: @Override public void run () {
1453: do {
1454: pnlPanel.repaint ();
1455: if (!pnlWakeupCommon ()) {
1456: break;
1457: }
1458: } while (!isInterrupted () && pnlWakeupCommon ());
1459: }
1460: };
1461: }
1462: pnlWakeupTime = System.currentTimeMillis ();
1463: pnlWakeupTimeMNP = 0L;
1464: pnlThread.start ();
1465: }
1466:
1467: }
1468:
1469: public static boolean pnlWakeupCommon () {
1470: long t = System.currentTimeMillis ();
1471: if (CRTC.crtTotalLength == 0L) {
1472: pnlWakeupTime += 40L;
1473: } else {
1474: pnlWakeupTime += CRTC.crtTotalLength;
1475: pnlWakeupTimeMNP += CRTC.crtTotalLengthMNP;
1476: if (1000000000L <= pnlWakeupTimeMNP) {
1477: pnlWakeupTime++;
1478: pnlWakeupTimeMNP -= 1000000000L;
1479: }
1480: }
1481: pnlWakeupTime = Math.max (pnlWakeupTime, t + 4L);
1482: try {
1483: Thread.sleep (pnlWakeupTime - t);
1484: } catch (InterruptedException ie) {
1485: return false;
1486: }
1487: return true;
1488: }
1489:
1490:
1491:
1492:
1493:
1494: public static void pnlExitFullScreen (boolean dialog) {
1495: if (prgIsMac || !dialog) {
1496: pnlSetFullScreenOn (false);
1497: }
1498: }
1499:
1500:
1501:
1502: public static void pnlToggleFullScreen () {
1503: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1504: pnlSetMode (PNL_FULLSCREEN);
1505: } else {
1506: pnlSetMode (pnlPrevMode);
1507: }
1508: }
1509:
1510:
1511:
1512: public static void pnlToggleMaximized () {
1513: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1514: pnlSetMode (PNL_MAXIMIZED);
1515: } else {
1516: pnlSetMode (pnlPrevMode);
1517: }
1518: }
1519:
1520:
1521:
1522: public static void pnlSetFullScreenOn (boolean on) {
1523: if (on) {
1524: pnlSetMode (PNL_FULLSCREEN);
1525: } else if (pnlMode == PNL_FULLSCREEN) {
1526: pnlSetMode (pnlPrevMode);
1527: }
1528: }
1529:
1530:
1531:
1532:
1533: public static void pnlSetFitInWindowOn (boolean on) {
1534: if (!on) {
1535: pnlSetMode (PNL_FIXEDSCALE);
1536: } else if (pnlMode == PNL_FIXEDSCALE) {
1537: pnlSetMode (PNL_FITINWINDOW);
1538: }
1539: }
1540:
1541:
1542:
1543:
1544:
1545:
1546:
1547:
1548:
1549:
1550: public static void pnlUpdateArrangement () {
1551: pnlWidth = pnlPanel.getWidth ();
1552: pnlHeight = pnlPanel.getHeight ();
1553: frmMarginWidth = frmFrame.getWidth () - pnlWidth;
1554: frmMarginHeight = frmFrame.getHeight () - pnlHeight;
1555: pnlStretchMode = pnlAspectTable[CRTC.crtHRLCurr << 2 | CRTC.crtHResoCurr];
1556: pnlScreenWidth = Math.max (PNL_MIN_WIDTH, (CRTC.crtR03HDispEndCurr - CRTC.crtR02HBackEndCurr) << 3);
1557: pnlScreenHeight = Math.max (PNL_MIN_HEIGHT, (CRTC.crtR07VDispEndCurr - CRTC.crtR06VBackEndCurr) << (CRTC.crtInterlace || CRTC.crtSlit ? 1 : 0));
1558: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchMode);
1559: if (RasterBreakPoint.RBP_ON) {
1560:
1561: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
1562: RasterBreakPoint.rbpUpdateFrame ();
1563: }
1564: }
1565:
1566: pnlFixedScale = pnlFixedModel.getNumber ().intValue ();
1567:
1568: pnlRotatedWidth = pnlStretchWidth;
1569: pnlRotatedHeight = pnlScreenHeight;
1570: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1571: pnlRotatedWidth = pnlScreenHeight;
1572: pnlRotatedHeight = pnlStretchWidth;
1573: }
1574: if (pnlMode == PNL_FIXEDSCALE) {
1575:
1576:
1577:
1578:
1579:
1580: pnlZoomWidth = (pnlRotatedWidth * pnlFixedScale + 50) * 5243 >>> 19;
1581: pnlZoomHeight = (pnlRotatedHeight * pnlFixedScale + 50) * 5243 >>> 19;
1582: int width = Math.max (Math.max (PNL_MIN_WIDTH, pnlZoomWidth * pnlStereoscopicFactor), Keyboard.kbdWidth);
1583: int height = Math.max (PNL_MIN_HEIGHT, pnlZoomHeight) + Keyboard.kbdHeight;
1584: pnlScreenX1 = (width - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1585: pnlScreenY1 = (height - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1586: if (pnlWidth != width || pnlHeight != height) {
1587: pnlWidth = width;
1588: pnlHeight = height;
1589: pnlMinimumWidth = width;
1590: pnlMinimumHeight = height;
1591: pnlSize.setSize (width, height);
1592: pnlPanel.setMinimumSize (pnlSize);
1593: pnlPanel.setMaximumSize (pnlSize);
1594: pnlPanel.setPreferredSize (pnlSize);
1595: }
1596: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1597: frmFrame.setMinimumSize (frmMinimumSize);
1598: frmFrame.setMaximumSize (frmMinimumSize);
1599: frmFrame.setPreferredSize (frmMinimumSize);
1600: frmFrame.setResizable (false);
1601: frmFrame.pack ();
1602: } else {
1603:
1604: if (pnlWidth * pnlRotatedHeight >= (pnlHeight - Keyboard.kbdHeight) * (pnlRotatedWidth * pnlStereoscopicFactor)) {
1605:
1606:
1607:
1608:
1609:
1610:
1611:
1612:
1613:
1614:
1615:
1616:
1617: pnlZoomHeight = pnlHeight - Keyboard.kbdHeight;
1618: pnlZoomWidth = (pnlZoomHeight * pnlRotatedWidth + (pnlRotatedHeight >> 1)) / pnlRotatedHeight;
1619: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1620: pnlScreenX1 = ((pnlWidth >> 1) - (pnlZoomWidth >> 1)) >> 1;
1621: } else {
1622: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1623: }
1624: pnlScreenY1 = 0;
1625: } else {
1626:
1627:
1628:
1629:
1630:
1631:
1632:
1633:
1634:
1635:
1636:
1637:
1638:
1639:
1640:
1641:
1642: pnlZoomWidth = pnlWidth / pnlStereoscopicFactor;
1643: pnlZoomHeight = (pnlZoomWidth * pnlStereoscopicFactor * pnlRotatedHeight + (pnlRotatedWidth * pnlStereoscopicFactor >> 1)) / (pnlRotatedWidth * pnlStereoscopicFactor);
1644: pnlScreenX1 = 0;
1645: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM) {
1646: pnlScreenY1 = (((pnlHeight - Keyboard.kbdHeight) >> 1) - (pnlZoomHeight >> 1)) >> 1;
1647: } else {
1648: pnlScreenY1 = (pnlHeight - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1649: }
1650: }
1651:
1652: int minimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
1653: int minimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
1654: if (pnlMinimumWidth != minimumWidth || pnlMinimumHeight != minimumHeight) {
1655: pnlMinimumWidth = minimumWidth;
1656: pnlMinimumHeight = minimumHeight;
1657: }
1658: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1659: frmFrame.setMinimumSize (frmMinimumSize);
1660: frmFrame.setMaximumSize (null);
1661: frmFrame.setResizable (true);
1662: }
1663:
1664: pnlArrangementCommon ();
1665: Mouse.musUpdateSpeedRatio ();
1666: if (!PNL_FILL_BACKGROUND) {
1667: pnlFillBackgroundRequest = true;
1668: }
1669: }
1670:
1671: public static void pnlArrangementCommon () {
1672: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1673: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1674: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) {
1675: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1676: pnlScreenX3 = pnlScreenX2;
1677: pnlScreenX4 = pnlScreenX3 + pnlZoomWidth;
1678: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1679: pnlScreenY3 = pnlScreenY1;
1680: pnlScreenY4 = pnlScreenY2;
1681: } else if (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1682: pnlScreenX2 = pnlScreenX1 + (pnlZoomWidth >> 1);
1683: pnlScreenX3 = pnlScreenX2;
1684: pnlScreenX4 = pnlScreenX3 + (pnlZoomWidth >> 1);
1685: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1686: pnlScreenY3 = pnlScreenY1;
1687: pnlScreenY4 = pnlScreenY2;
1688: } else {
1689: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1690: pnlScreenX3 = pnlScreenX1;
1691: pnlScreenX4 = pnlScreenX2;
1692: pnlScreenY2 = pnlScreenY1 + (pnlZoomHeight >> 1);
1693: pnlScreenY3 = pnlScreenY2;
1694: pnlScreenY4 = pnlScreenY3 + (pnlZoomHeight >> 1);
1695: }
1696: } else {
1697: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1698: pnlScreenX3 = pnlScreenX1;
1699: pnlScreenX4 = pnlScreenX2;
1700: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1701: pnlScreenY3 = pnlScreenY1;
1702: pnlScreenY4 = pnlScreenY2;
1703: }
1704: pnlKeyboardX = (pnlWidth - Keyboard.kbdWidth) >> 1;
1705: pnlKeyboardY = pnlScreenY4;
1706: pnlZoomRatioOutX = ((pnlZoomWidth * pnlStereoscopicFactor) << 16) / pnlScreenWidth;
1707: pnlZoomRatioOutY = (pnlZoomHeight << 16) / pnlScreenHeight;
1708: pnlZoomRatioInX = (pnlScreenWidth << 16) / (pnlZoomWidth * pnlStereoscopicFactor);
1709: pnlZoomRatioInY = (pnlScreenHeight << 16) / pnlZoomHeight;
1710: if (PNL_ROTATION_ON) {
1711:
1712: if (PNL_USE_THREAD) {
1713: for (int n = 0; n < 4; n++) {
1714: pnlScreenSubImageLeftArray[n] = pnlScreenImageLeftArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1715: pnlScreenSubImageRightArray[n] = pnlScreenImageRightArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1716: }
1717: } else {
1718: pnlScreenSubImageLeft = pnlScreenImageLeft.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1719: pnlScreenSubImageRight = pnlScreenImageRight.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1720: }
1721:
1722:
1723:
1724:
1725: double ax = 0.0;
1726: double ay = 0.0;
1727: double bx = (double) pnlScreenWidth;
1728: double by = (double) pnlScreenHeight;
1729: double l00, l10, l01, l11, l02, l12;
1730: double r00, r10, r01, r11, r02, r12;
1731: if (pnlRotationMode == 0) {
1732: double cx = (double) pnlScreenX1;
1733: double cy = (double) pnlScreenY1;
1734: double dx = (double) pnlScreenX2;
1735: double dy = (double) pnlScreenY2;
1736: l00 = (cx - dx) / (ax - bx);
1737: l10 = 0.0;
1738: l01 = 0.0;
1739: l11 = (cy - dy) / (ay - by);
1740: l02 = (ax * dx - bx * cx) / (ax - bx);
1741: l12 = (ay * dy - by * cy) / (ay - by);
1742: cx = (double) pnlScreenX3;
1743: cy = (double) pnlScreenY3;
1744: dx = (double) pnlScreenX4;
1745: dy = (double) pnlScreenY4;
1746: r00 = (cx - dx) / (ax - bx);
1747: r10 = 0.0;
1748: r01 = 0.0;
1749: r11 = (cy - dy) / (ay - by);
1750: r02 = (ax * dx - bx * cx) / (ax - bx);
1751: r12 = (ay * dy - by * cy) / (ay - by);
1752: } else if (pnlRotationMode == 1) {
1753: double cx = (double) pnlScreenX1;
1754: double cy = (double) pnlScreenY1;
1755: double dx = (double) pnlScreenX2;
1756: double dy = (double) pnlScreenY2;
1757: l00 = 0.0;
1758: l10 = (dy - cy) / (ax - bx);
1759: l01 = (cx - dx) / (ay - by);
1760: l11 = 0.0;
1761: l02 = (ay * dx - by * cx) / (ay - by);
1762: l12 = (ax * cy - bx * dy) / (ax - bx);
1763: cx = (double) pnlScreenX3;
1764: cy = (double) pnlScreenY3;
1765: dx = (double) pnlScreenX4;
1766: dy = (double) pnlScreenY4;
1767: r00 = 0.0;
1768: r10 = (dy - cy) / (ax - bx);
1769: r01 = (cx - dx) / (ay - by);
1770: r11 = 0.0;
1771: r02 = (ay * dx - by * cx) / (ay - by);
1772: r12 = (ax * cy - bx * dy) / (ax - bx);
1773: } else if (pnlRotationMode == 2) {
1774: double cx = (double) pnlScreenX1;
1775: double cy = (double) pnlScreenY1;
1776: double dx = (double) pnlScreenX2;
1777: double dy = (double) pnlScreenY2;
1778: l00 = (dx - cx) / (ax - bx);
1779: l10 = 0.0;
1780: l01 = 0.0;
1781: l11 = (dy - cy) / (ay - by);
1782: l02 = (ax * cx - bx * dx) / (ax - bx);
1783: l12 = (ay * cy - by * dy) / (ay - by);
1784: cx = (double) pnlScreenX3;
1785: cy = (double) pnlScreenY3;
1786: dx = (double) pnlScreenX4;
1787: dy = (double) pnlScreenY4;
1788: r00 = (dx - cx) / (ax - bx);
1789: r10 = 0.0;
1790: r01 = 0.0;
1791: r11 = (dy - cy) / (ay - by);
1792: r02 = (ax * cx - bx * dx) / (ax - bx);
1793: r12 = (ay * cy - by * dy) / (ay - by);
1794: } else {
1795: double cx = (double) pnlScreenX1;
1796: double cy = (double) pnlScreenY1;
1797: double dx = (double) pnlScreenX2;
1798: double dy = (double) pnlScreenY2;
1799: l00 = 0.0;
1800: l10 = (cy - dy) / (ax - bx);
1801: l01 = (dx - cx) / (ay - by);
1802: l11 = 0.0;
1803: l02 = (ay * cx - by * dx) / (ay - by);
1804: l12 = (ax * dy - bx * cy) / (ax - bx);
1805: cx = (double) pnlScreenX3;
1806: cy = (double) pnlScreenY3;
1807: dx = (double) pnlScreenX4;
1808: dy = (double) pnlScreenY4;
1809: r00 = 0.0;
1810: r10 = (cy - dy) / (ax - bx);
1811: r01 = (dx - cx) / (ay - by);
1812: r11 = 0.0;
1813: r02 = (ay * cx - by * dx) / (ay - by);
1814: r12 = (ax * dy - bx * cy) / (ax - bx);
1815: }
1816: pnlRotationTransformLeft.setTransform (l00, l10, l01, l11, l02, l12);
1817: pnlRotationTransformRight.setTransform (r00, r10, r01, r11, r02, r12);
1818: pnlMatrixL00 = l00;
1819: pnlMatrixL10 = l10;
1820: pnlMatrixL01 = l01;
1821: pnlMatrixL11 = l11;
1822: pnlMatrixL02 = l02;
1823: pnlMatrixL12 = l12;
1824: pnlMatrixR00 = r00;
1825: pnlMatrixR10 = r10;
1826: pnlMatrixR01 = r01;
1827: pnlMatrixR11 = r11;
1828: pnlMatrixR02 = r02;
1829: pnlMatrixR12 = r12;
1830:
1831:
1832:
1833:
1834:
1835:
1836: double d = l00 * l11 - l01 * l10;
1837: pnlInverseL00 = l11 / d;
1838: pnlInverseL10 = -l10 / d;
1839: pnlInverseL01 = -l01 / d;
1840: pnlInverseL11 = l00 / d;
1841: pnlInverseL02 = (l01 * l12 - l02 * l11) / d;
1842: pnlInverseL12 = (l02 * l10 - l00 * l12) / d;
1843: d = r00 * r11 - r01 * r10;
1844: pnlInverseR00 = r11 / d;
1845: pnlInverseR10 = -r10 / d;
1846: pnlInverseR01 = -r01 / d;
1847: pnlInverseR11 = r00 / d;
1848: pnlInverseR02 = (r01 * r12 - r02 * r11) / d;
1849: pnlInverseR12 = (r02 * r10 - r00 * r12) / d;
1850: }
1851: }
1852:
1853:
1854:
1855:
1856: public static final int PNL_UNDEFINED = 0;
1857: public static final int PNL_FIXEDSCALE = 1;
1858: public static final int PNL_FITINWINDOW = 2;
1859: public static final int PNL_FULLSCREEN = 3;
1860: public static final int PNL_MAXIMIZED = 4;
1861: public static int pnlModeRequest;
1862: public static int pnlMode;
1863: public static int pnlPrevMode;
1864:
1865:
1866: public static JRadioButtonMenuItem mnbFullScreenMenuItem;
1867: public static JRadioButtonMenuItem mnbMaximizedMenuItem;
1868: public static JRadioButtonMenuItem mnbFitInWindowMenuItem;
1869: public static JRadioButtonMenuItem mnbFixedScaleMenuItem;
1870:
1871:
1872: public static int PNL_BOOT_DELAY = 500;
1873: public static javax.swing.Timer pnlBootTimer;
1874:
1875:
1876:
1877: public static void pnlInit2 () {
1878: pnlModeRequest = PNL_UNDEFINED;
1879: pnlMode = PNL_FITINWINDOW;
1880: pnlPrevMode = PNL_FITINWINDOW;
1881: switch (Settings.sgsGetString ("scaling").toLowerCase ()) {
1882: case "fullscreen":
1883: pnlModeRequest = PNL_FULLSCREEN;
1884: break;
1885: case "maximized":
1886: pnlModeRequest = PNL_MAXIMIZED;
1887: break;
1888: case "fitinwindow":
1889: break;
1890: case "fixedscale":
1891: pnlMode = PNL_FIXEDSCALE;
1892: break;
1893: }
1894: }
1895:
1896:
1897:
1898: public static void pnlTini2 () {
1899: Settings.sgsPutString ("scaling",
1900: pnlMode == PNL_FULLSCREEN ? "fullscreen" :
1901: pnlMode == PNL_MAXIMIZED ? "maximized" :
1902: pnlMode == PNL_FITINWINDOW ? "fitinwindow" :
1903: "fixedscale");
1904: }
1905:
1906:
1907:
1908: public static void pnlMake2 () {
1909:
1910: ActionListener listener = new ActionListener () {
1911: @Override public void actionPerformed (ActionEvent ae) {
1912: String command = ae.getActionCommand ();
1913: switch (command) {
1914: case "Full screen":
1915: pnlSetMode (PNL_FULLSCREEN);
1916: break;
1917: case "Maximized":
1918: pnlSetMode (PNL_MAXIMIZED);
1919: break;
1920: case "Fit in window":
1921: pnlSetMode (PNL_FITINWINDOW);
1922: break;
1923: case "Fixed scale":
1924: pnlSetMode (PNL_FIXEDSCALE);
1925: break;
1926: }
1927: }
1928: };
1929: ButtonGroup group = new ButtonGroup ();
1930: mnbFullScreenMenuItem = ComponentFactory.setEnabled (
1931: Multilingual.mlnText (
1932: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FULLSCREEN, "Full screen", listener),
1933: "ja", "全画面表示"),
1934: pnlIsFullScreenSupported);
1935: mnbMaximizedMenuItem = Multilingual.mlnText (
1936: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_MAXIMIZED, "Maximized", listener),
1937: "ja", "最大化");
1938: mnbFitInWindowMenuItem = Multilingual.mlnText (
1939: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FITINWINDOW, "Fit in window", 'W', MNB_MODIFIERS, listener),
1940: "ja", "ウインドウに合わせる");
1941: mnbFixedScaleMenuItem = Multilingual.mlnText (
1942: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FIXEDSCALE, "Fixed scale", 'X', MNB_MODIFIERS, listener),
1943: "ja", "固定倍率");
1944: }
1945:
1946:
1947:
1948: public static void pnlStart2 () {
1949:
1950: frmFrame.addWindowStateListener (new WindowStateListener () {
1951: @Override public void windowStateChanged (WindowEvent we) {
1952: int state = frmFrame.getExtendedState ();
1953: if (pnlMode != PNL_MAXIMIZED &&
1954: (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
1955: pnlSetMode (PNL_MAXIMIZED);
1956: } else if (pnlMode == PNL_MAXIMIZED &&
1957: (state & Frame.MAXIMIZED_BOTH) != Frame.MAXIMIZED_BOTH) {
1958: pnlSetMode (pnlPrevMode);
1959: }
1960: }
1961: });
1962: }
1963:
1964:
1965:
1966: public static void pnlBoot2 () {
1967: if (pnlModeRequest != PNL_UNDEFINED) {
1968: pnlBootTimer = new javax.swing.Timer (PNL_BOOT_DELAY, new ActionListener () {
1969: public void actionPerformed (ActionEvent ae) {
1970: if (pnlModeRequest == PNL_FULLSCREEN) {
1971: mnbFullScreenMenuItem.doClick ();
1972: } else if (pnlModeRequest == PNL_MAXIMIZED) {
1973: mnbMaximizedMenuItem.doClick ();
1974: }
1975: pnlBootTimer.stop ();
1976: pnlBootTimer = null;
1977: }
1978: });
1979: pnlBootTimer.start ();
1980: }
1981: }
1982:
1983:
1984:
1985: public static void pnlSetMode (int mode) {
1986: do {
1987:
1988: if (pnlMode == mode) {
1989: break;
1990: }
1991:
1992: String text = null;
1993: if (mode == PNL_FULLSCREEN) {
1994: if (!pnlIsFullScreenSupported) {
1995: JOptionPane.showMessageDialog (
1996: frmFrame,
1997: Multilingual.mlnJapanese ?
1998: "全画面表示に対応していません" :
1999: "Full screen is not supported");
2000: break;
2001: }
2002: if (Bubble.BBL_ON) {
2003: text = ButtonFunction.bfnFullScreenText ();
2004: if (text == null) {
2005: JOptionPane.showMessageDialog (
2006: frmFrame,
2007: Multilingual.mlnJapanese ?
2008: "全画面表示を終了するキーまたはボタンがありません" :
2009: "No key or button to exit full screen");
2010: break;
2011: }
2012: }
2013: }
2014:
2015: if (pnlMode == PNL_FULLSCREEN) {
2016: pnlMode = pnlPrevMode;
2017: if (Bubble.BBL_ON) {
2018: Bubble.bblEnd ();
2019: }
2020: if (frmScreenDevice.getFullScreenWindow () == frmFrame) {
2021: frmScreenDevice.setFullScreenWindow (null);
2022: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.FRAME);
2023: }
2024: frmFrame.setJMenuBar (mnbMenuBar);
2025: if (pnlHideKeyboard) {
2026: if (pnlPrevKeyboardOn) {
2027: Keyboard.kbdSetOn (true);
2028: }
2029: }
2030: } else if (pnlMode == PNL_MAXIMIZED) {
2031: pnlMode = pnlPrevMode;
2032: if ((frmFrame.getExtendedState () & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
2033: frmFrame.setExtendedState (Frame.NORMAL);
2034: }
2035: }
2036:
2037: if (mode == PNL_FULLSCREEN) {
2038: pnlPrevMode = pnlMode;
2039: if (pnlHideKeyboard) {
2040: pnlPrevKeyboardOn = Keyboard.kbdImage != null;
2041: if (pnlPrevKeyboardOn) {
2042: Keyboard.kbdSetOn (false);
2043: }
2044: }
2045: frmFrame.setJMenuBar (null);
2046: if (frmScreenDevice.getFullScreenWindow () != frmFrame) {
2047: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.NONE);
2048: frmScreenDevice.setFullScreenWindow (frmFrame);
2049: }
2050: if (Bubble.BBL_ON) {
2051: if (text != null) {
2052: Bubble.bblStart (text + (Multilingual.mlnJapanese ? "で全画面表示を終了" : " to exit full screen"), 5000L);
2053: }
2054: }
2055: } else if (mode == PNL_MAXIMIZED) {
2056: pnlPrevMode = pnlMode;
2057: frmFrame.setExtendedState (Frame.MAXIMIZED_BOTH);
2058: }
2059: pnlMode = mode;
2060:
2061:
2062: pnlUpdateArrangement ();
2063: } while (false);
2064:
2065: if (pnlMode == PNL_FIXEDSCALE) {
2066: if (!mnbFixedScaleMenuItem.isSelected ()) {
2067: mnbFixedScaleMenuItem.setSelected (true);
2068: }
2069: } else if (pnlMode == PNL_FITINWINDOW) {
2070: if (!mnbFitInWindowMenuItem.isSelected ()) {
2071: mnbFitInWindowMenuItem.setSelected (true);
2072: }
2073: } else if (pnlMode == PNL_FULLSCREEN) {
2074: if (!mnbFullScreenMenuItem.isSelected ()) {
2075: mnbFullScreenMenuItem.setSelected (true);
2076: }
2077: } else if (pnlMode == PNL_MAXIMIZED) {
2078: if (!mnbMaximizedMenuItem.isSelected ()) {
2079: mnbMaximizedMenuItem.setSelected (true);
2080: }
2081: }
2082: }
2083:
2084:
2085:
2086:
2087:
2088:
2089: public static Robot rbtRobot;
2090:
2091:
2092: public static void rbtInit () {
2093:
2094:
2095: rbtRobot = null;
2096: try {
2097: rbtRobot = new Robot ();
2098: } catch (Exception e) {
2099: }
2100:
2101: }
2102:
2103:
2104:
2105:
2106:
2107:
2108:
2109: public static final int MNB_MODIFIERS = InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK;
2110:
2111:
2112: public static JMenuBar mnbMenuBar;
2113:
2114:
2115: public static JMenu mnbFileMenu;
2116: public static JMenu mnbDisplayMenu;
2117: public static JMenu mnbSoundMenu;
2118: public static JMenu mnbInputMenu;
2119: public static JMenu mnbConfigMenu;
2120: public static JMenu mnbLanguageMenu;
2121:
2122:
2123:
2124:
2125:
2126: public static JMenuItem mnbQuitMenuItem;
2127: public static JCheckBoxMenuItem mnbStereoscopicMenuItem;
2128: public static JCheckBoxMenuItem mnbPlayMenuItem;
2129: public static JMenuItem mnbPasteMenuItem;
2130: public static JRadioButtonMenuItem mnbStandardKeyboardMenuItem;
2131: public static JRadioButtonMenuItem mnbCompactKeyboardMenuItem;
2132: public static JRadioButtonMenuItem mnbNoKeyboardMenuItem;
2133: public static JLabel mnbVolumeLabel;
2134:
2135:
2136:
2137:
2138:
2139:
2140: public static JMenu mnbMakeFontSizeMenu () {
2141:
2142: ActionListener actionListener = new ActionListener () {
2143: @Override public void actionPerformed (ActionEvent ae) {
2144: String command = ae.getActionCommand ();
2145: switch (command) {
2146: case "Very small":
2147: LnF.lnfFontSizeRequest = 10;
2148: break;
2149: case "Small":
2150: LnF.lnfFontSizeRequest = 12;
2151: break;
2152: case "Medium":
2153: LnF.lnfFontSizeRequest = 14;
2154: break;
2155: case "Large":
2156: LnF.lnfFontSizeRequest = 16;
2157: break;
2158: case "Very large":
2159: LnF.lnfFontSizeRequest = 18;
2160: break;
2161: default:
2162: System.out.println ("unknown action command " + command);
2163: }
2164: }
2165: };
2166:
2167: ButtonGroup fontSizeGroup = new ButtonGroup ();
2168:
2169: return Multilingual.mlnText (
2170: ComponentFactory.createMenu (
2171: "Font size",
2172: Multilingual.mlnText (
2173: ComponentFactory.pointSize (
2174: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 10, "Very small", actionListener),
2175: 10),
2176: "ja", "極小"),
2177: Multilingual.mlnText (
2178: ComponentFactory.pointSize (
2179: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 12, "Small", actionListener),
2180: 12),
2181: "ja", "小"),
2182: Multilingual.mlnText (
2183: ComponentFactory.pointSize (
2184: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 14, "Medium", actionListener),
2185: 14),
2186: "ja", "中"),
2187: Multilingual.mlnText (
2188: ComponentFactory.pointSize (
2189: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 16, "Large", actionListener),
2190: 16),
2191: "ja", "大"),
2192: Multilingual.mlnText (
2193: ComponentFactory.pointSize (
2194: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 18, "Very large", actionListener),
2195: 18),
2196: "ja", "極大")),
2197: "ja", "フォントサイズ");
2198: }
2199:
2200:
2201:
2202: public static final DecimalSpinner[] mnbColorSpinners = new DecimalSpinner[9];
2203: public static final int[] mnbColorRGB = new int[15];
2204: public static JPanel mnbColorPanel;
2205:
2206:
2207:
2208: public static void mnbColorHSBToRGB () {
2209: for (int i = 0; i <= 14; i++) {
2210: int[] t = LnF.LNF_HSB_INTERPOLATION_TABLE[i];
2211: float h = (float) (t[0] * LnF.lnfHSB[0] + t[1] * LnF.lnfHSB[1] + t[2] * LnF.lnfHSB[2]) / (49.0F * 360.0F);
2212: float s = (float) (t[0] * LnF.lnfHSB[3] + t[1] * LnF.lnfHSB[4] + t[2] * LnF.lnfHSB[5]) / (49.0F * 100.0F);
2213: float b = (float) (t[0] * LnF.lnfHSB[6] + t[1] * LnF.lnfHSB[7] + t[2] * LnF.lnfHSB[8]) / (49.0F * 100.0F);
2214: mnbColorRGB[i] = Color.HSBtoRGB (h,
2215: Math.max (0.0F, Math.min (1.0F, s)),
2216: Math.max (0.0F, Math.min (1.0F, b)));
2217: }
2218: }
2219:
2220:
2221:
2222: public static JMenu mnbMakeColorMenu () {
2223: mnbColorHSBToRGB ();
2224:
2225: mnbColorPanel = ComponentFactory.setColor (
2226: ComponentFactory.setFixedSize (
2227: new JPanel () {
2228: @Override protected void paintComponent (Graphics g) {
2229: super.paintComponent (g);
2230: for (int i = 0; i <= 14; i++) {
2231: g.setColor (new Color (mnbColorRGB[i]));
2232: g.fillRect (LnF.lnfFontSize * i, 0, LnF.lnfFontSize, LnF.lnfFontSize * 5);
2233: }
2234: }
2235: },
2236: LnF.lnfFontSize * 15, LnF.lnfFontSize * 5),
2237: Color.white, Color.black);
2238:
2239: ChangeListener changeListener = new ChangeListener () {
2240: @Override public void stateChanged (ChangeEvent ce) {
2241: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
2242: LnF.lnfHSB[spinner.getOption ()] = spinner.getIntValue ();
2243: mnbColorHSBToRGB ();
2244: mnbColorPanel.repaint ();
2245: }
2246: };
2247:
2248: ActionListener actionListener = new ActionListener () {
2249: @Override public void actionPerformed (ActionEvent ae) {
2250: String command = ae.getActionCommand ();
2251: switch (command) {
2252: case "Reset to default values":
2253: for (int i = 0; i < 9; i++) {
2254: LnF.lnfHSB[i] = LnF.LNF_DEFAULT_HSB[i];
2255: mnbColorSpinners[i].setIntValue (LnF.lnfHSB[i]);
2256: }
2257: mnbColorHSBToRGB ();
2258: mnbColorPanel.repaint ();
2259: break;
2260: default:
2261: System.out.println ("unknown action command " + command);
2262: }
2263: }
2264: };
2265:
2266: for (int i = 0; i < 9; i++) {
2267: mnbColorSpinners[i] = ComponentFactory.createDecimalSpinner (
2268: LnF.lnfHSB[i], 0, i < 3 ? 720 : 100, 1, i, changeListener);
2269: }
2270:
2271: return Multilingual.mlnText (
2272: ComponentFactory.createMenu (
2273: "Color",
2274: ComponentFactory.createHorizontalBox (
2275: mnbColorSpinners[0],
2276: mnbColorSpinners[1],
2277: mnbColorSpinners[2],
2278: ComponentFactory.createLabel ("H °"),
2279: Box.createHorizontalGlue ()
2280: ),
2281: ComponentFactory.createHorizontalBox (
2282: mnbColorSpinners[3],
2283: mnbColorSpinners[4],
2284: mnbColorSpinners[5],
2285: ComponentFactory.createLabel ("S%"),
2286: Box.createHorizontalGlue ()
2287: ),
2288: ComponentFactory.createHorizontalBox (
2289: mnbColorSpinners[6],
2290: mnbColorSpinners[7],
2291: mnbColorSpinners[8],
2292: ComponentFactory.createLabel ("B%"),
2293: Box.createHorizontalGlue ()
2294: ),
2295: ComponentFactory.createHorizontalBox (
2296: ComponentFactory.setLineBorder (mnbColorPanel),
2297: Box.createHorizontalGlue ()
2298: ),
2299: Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset to default values", actionListener), "ja", "初期値に戻す")
2300: ),
2301: "ja", "色");
2302: }
2303:
2304:
2305:
2306:
2307:
2308: public static JMenu mnbMakeLanguageMenu () {
2309:
2310: ActionListener actionListener = new ActionListener () {
2311: @Override public void actionPerformed (ActionEvent ae) {
2312: String command = ae.getActionCommand ();
2313: switch (command) {
2314: case "English":
2315: Multilingual.mlnChange ("en");
2316: break;
2317: case "日本語":
2318: Multilingual.mlnChange ("ja");
2319: break;
2320: default:
2321: System.out.println ("unknown action command " + command);
2322: }
2323: }
2324: };
2325:
2326: ButtonGroup languageGroup = new ButtonGroup ();
2327:
2328: return mnbLanguageMenu = Multilingual.mlnText (
2329: ComponentFactory.createMenu (
2330: "Language", 'L',
2331: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnEnglish, "English", actionListener),
2332: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnJapanese, "日本語", actionListener),
2333: ComponentFactory.createHorizontalSeparator (),
2334: mnbMakeFontSizeMenu (),
2335: mnbMakeColorMenu ()
2336: ),
2337: "ja", "言語");
2338: }
2339:
2340:
2341:
2342:
2343:
2344: public static void mnbMakeMenu () {
2345:
2346:
2347: ActionListener listener = new ActionListener () {
2348: @Override public void actionPerformed (ActionEvent ae) {
2349: Object source = ae.getSource ();
2350: String command = ae.getActionCommand ();
2351: switch (command) {
2352:
2353:
2354: case "Quit":
2355: prgTini ();
2356: break;
2357:
2358:
2359: case "50%":
2360: case "75%":
2361: case "100%":
2362: case "150%":
2363: case "200%":
2364: pnlFixedModel.setValue (Integer.valueOf (Integer.parseInt (command.substring (0, command.length () - 1))));
2365: break;
2366: case "Nearest neighbor":
2367: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
2368: break;
2369: case "Bilinear":
2370: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
2371: break;
2372: case "Bicubic":
2373: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
2374: break;
2375:
2376: case "Use canvas":
2377: pnlUseCanvasRequest = ((JCheckBoxMenuItem) source).isSelected ();
2378: break;
2379:
2380: case "Draw all changed pictures":
2381: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2382: CRTC.crtIntermittentInterval = 0;
2383: }
2384: break;
2385: case "Draw a changed picture once every two times":
2386: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2387: CRTC.crtIntermittentInterval = 1;
2388: }
2389: break;
2390: case "Draw a changed picture once every three times":
2391: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2392: CRTC.crtIntermittentInterval = 2;
2393: }
2394: break;
2395: case "Draw a changed picture once every four times":
2396: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2397: CRTC.crtIntermittentInterval = 3;
2398: }
2399: break;
2400: case "Draw a changed picture once every five times":
2401: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2402: CRTC.crtIntermittentInterval = 4;
2403: }
2404: break;
2405:
2406: case "Stereoscopic viewing":
2407: pnlSetStereoscopic (((JCheckBoxMenuItem) source).isSelected (), pnlStereoscopicMethod);
2408: break;
2409: case "Naked-eye crossing":
2410: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_CROSSING);
2411: break;
2412: case "Naked-eye parallel":
2413: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_PARALLEL);
2414: break;
2415: case "Side-by-side":
2416: pnlSetStereoscopic (pnlStereoscopicOn, PNL_SIDE_BY_SIDE);
2417: break;
2418: case "Top-and-bottom":
2419: pnlSetStereoscopic (pnlStereoscopicOn, PNL_TOP_AND_BOTTOM);
2420: break;
2421:
2422: case "Sprite pattern viewer":
2423: if (SpritePatternViewer.SPV_ON) {
2424: SpritePatternViewer.spvOpen ();
2425: }
2426: break;
2427: case "Palette viewer":
2428: if (PaletteViewer.PLV_ON) {
2429: PaletteViewer.plvOpen ();
2430: }
2431: break;
2432: case "Screen mode test":
2433: if (ScreenModeTest.SMT_ON) {
2434: ScreenModeTest.smtOpen ();
2435: }
2436: break;
2437:
2438:
2439: case "Play":
2440: SoundSource.sndSetPlayOn (((JCheckBoxMenuItem) source).isSelected ());
2441: break;
2442: case "OPM output":
2443: OPM.opmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2444: break;
2445: case "OPM log":
2446: OPMLog.olgOpen ();
2447: break;
2448:
2449: case "PCM output":
2450: ADPCM.pcmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2451: break;
2452: case "Sound thinning":
2453: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.THINNING_MONO : SoundSource.SNDRateConverter.THINNING_STEREO;
2454: break;
2455: case "Sound linear interpolation":
2456: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.LINEAR_MONO : SoundSource.SNDRateConverter.LINEAR_STEREO;
2457: break;
2458: case "Sound piecewise-constant area interpolation":
2459: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000;
2460: break;
2461: case "Sound linear area interpolation":
2462: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000;
2463: break;
2464: case "Sound monitor":
2465: SoundMonitor.smnOpen ();
2466: break;
2467: case "PCM piecewise-constant interpolation":
2468: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_CONSTANT);
2469: break;
2470: case "PCM linear interpolation":
2471: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_LINEAR);
2472: break;
2473: case "PCM hermite interpolation":
2474: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_HERMITE);
2475: break;
2476: case "PCM 8MHz/4MHz":
2477: ADPCM.pcmOSCFreqRequest = 0;
2478: break;
2479: case "PCM 8MHz/16MHz":
2480: ADPCM.pcmOSCFreqRequest = 1;
2481: break;
2482: case "Mercury-Unit V4 (MK-MU1)":
2483: MercuryUnit.mu4OnRequest = ((JCheckBoxMenuItem) source).isSelected ();
2484: break;
2485: case "MU4 output":
2486: MercuryUnit.mu4OutputEnable = ((JCheckBoxMenuItem) source).isSelected ();
2487: break;
2488:
2489:
2490: case "Paste":
2491: CONDevice.conDoPaste ();
2492: break;
2493: case "No keyboard":
2494: Keyboard.kbdSetOn (false);
2495: pnlUpdateArrangement ();
2496: break;
2497: case "Standard keyboard":
2498: Keyboard.kbdSetType (Keyboard.KBD_STANDARD_TYPE);
2499: Keyboard.kbdSetOn (true);
2500: pnlUpdateArrangement ();
2501: break;
2502: case "Compact keyboard":
2503: Keyboard.kbdSetType (Keyboard.KBD_COMPACT_TYPE);
2504: Keyboard.kbdSetOn (true);
2505: pnlUpdateArrangement ();
2506: break;
2507: case "Hide keyboard in full screen":
2508: pnlHideKeyboard = ((JCheckBoxMenuItem) source).isSelected ();
2509: if (pnlMode == PNL_FULLSCREEN) {
2510: pnlUpdateArrangement ();
2511: }
2512: break;
2513: case "Key assignments":
2514: Keyboard.kbdOpen ();
2515: break;
2516: case "Joystick port settings":
2517: PPI.ppiOpen ();
2518: break;
2519:
2520:
2521: case "RS-232C and terminal":
2522: RS232CTerminal.trmOpen ();
2523: break;
2524:
2525: case "Console":
2526: DebugConsole.dgtOpen ();
2527: break;
2528: case "Register list":
2529: RegisterList.drpOpen ();
2530: break;
2531: case "Disassemble list":
2532: DisassembleList.ddpOpen (-1, -1, true);
2533: break;
2534: case "Memory dump list":
2535: MemoryDumpList.dmpOpen (-1, -1, true);
2536: break;
2537: case "Logical space monitor":
2538: LogicalSpaceMonitor.atwOpen ();
2539: break;
2540: case "Physical space monitor":
2541: PhysicalSpaceMonitor.paaOpen ();
2542: break;
2543: case "Address translation caches monitor":
2544: if (ATCMonitor.ACM_ON) {
2545: ATCMonitor.acmOpen ();
2546: }
2547: break;
2548: case "Branch log":
2549: if (BranchLog.BLG_ON) {
2550: BranchLog.blgOpen (BranchLog.BLG_SELECT_NONE);
2551: }
2552: break;
2553: case "Program flow visualizer":
2554: if (ProgramFlowVisualizer.PFV_ON) {
2555: ProgramFlowVisualizer.pfvOpen ();
2556: }
2557: break;
2558: case "Raster break point":
2559: if (RasterBreakPoint.RBP_ON) {
2560: RasterBreakPoint.rbpOpen ();
2561: }
2562: break;
2563: case "Data break point":
2564: if (DataBreakPoint.DBP_ON) {
2565: DataBreakPoint.dbpOpen ();
2566: }
2567: break;
2568: case "Root pointer list":
2569: if (RootPointerList.RTL_ON) {
2570: RootPointerList.rtlOpen ();
2571: }
2572: break;
2573:
2574:
2575: case "Adjust clock to host":
2576: RP5C15.rtcSetByHost ();
2577: break;
2578:
2579:
2580:
2581: case "Printer":
2582: PrinterPort.prnOpen ();
2583: break;
2584:
2585: case "Print key and mouse button events":
2586: Mouse.musOutputButtonStatus = ((JCheckBoxMenuItem) source).isSelected ();
2587: break;
2588:
2589: case "Java runtime environment information":
2590: prgOpenJavaDialog ();
2591: break;
2592: case "Version information":
2593: prgOpenAboutDialog ();
2594: break;
2595: case "XEiJ License":
2596: prgOpenXEiJLicenseDialog ();
2597: break;
2598: case "FSHARP License":
2599: prgOpenSHARPLicenseDialog ();
2600: break;
2601: case "ymfm License":
2602: prgOpenYmfmLicenseDialog ();
2603: break;
2604: case "jSerialComm License":
2605: prgOpenJSerialCommLicenseDialog ();
2606: break;
2607:
2608: default:
2609: System.out.println ("unknown action command " + command);
2610:
2611: }
2612: }
2613: };
2614:
2615:
2616: ActionListener mainMemoryListener = new ActionListener () {
2617: @Override public void actionPerformed (ActionEvent ae) {
2618: Object source = ae.getSource ();
2619: String command = ae.getActionCommand ();
2620: switch (command) {
2621: case "1MB":
2622: MainMemory.mmrMemorySizeRequest = 0x00100000;
2623: break;
2624: case "2MB":
2625: MainMemory.mmrMemorySizeRequest = 0x00200000;
2626: break;
2627: case "4MB":
2628: MainMemory.mmrMemorySizeRequest = 0x00400000;
2629: break;
2630: case "6MB":
2631: MainMemory.mmrMemorySizeRequest = 0x00600000;
2632: break;
2633: case "8MB":
2634: MainMemory.mmrMemorySizeRequest = 0x00800000;
2635: break;
2636: case "10MB":
2637: MainMemory.mmrMemorySizeRequest = 0x00a00000;
2638: break;
2639: case "12MB":
2640: MainMemory.mmrMemorySizeRequest = 0x00c00000;
2641: break;
2642: case "Save contents on exit":
2643: MainMemory.mmrMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2644: break;
2645: }
2646: }
2647: };
2648: ButtonGroup mainMemoryGroup = new ButtonGroup ();
2649: JMenu mainMemoryMenu = Multilingual.mlnText (
2650: ComponentFactory.createMenu (
2651: "Main memory",
2652: Multilingual.mlnText (
2653: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00100000, "1MB", mainMemoryListener),
2654: "ja", "1MB"),
2655: Multilingual.mlnText (
2656: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00200000, "2MB", mainMemoryListener),
2657: "ja", "2MB"),
2658: Multilingual.mlnText (
2659: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00400000, "4MB", mainMemoryListener),
2660: "ja", "4MB"),
2661: Multilingual.mlnText (
2662: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00600000, "6MB", mainMemoryListener),
2663: "ja", "6MB"),
2664: Multilingual.mlnText (
2665: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00800000, "8MB", mainMemoryListener),
2666: "ja", "8MB"),
2667: Multilingual.mlnText (
2668: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00a00000, "10MB", mainMemoryListener),
2669: "ja", "10MB"),
2670: Multilingual.mlnText (
2671: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00c00000, "12MB", mainMemoryListener),
2672: "ja", "12MB"),
2673: ComponentFactory.createHorizontalSeparator (),
2674: Multilingual.mlnText (
2675: ComponentFactory.createCheckBoxMenuItem (MainMemory.mmrMemorySaveOn, "Save contents on exit", mainMemoryListener),
2676: "ja", "終了時に内容を保存する"),
2677: SRAM.smrModifyMemorySizeMenuItem
2678: ),
2679: "ja", "メインメモリ");
2680:
2681:
2682: ActionListener highMemoryListener = new ActionListener () {
2683: @Override public void actionPerformed (ActionEvent ae) {
2684: Object source = ae.getSource ();
2685: String command = ae.getActionCommand ();
2686: switch (command) {
2687: case "None":
2688: busHighMemorySize = 0 << 20;
2689: break;
2690: case "16MB":
2691: busHighMemorySize = 16 << 20;
2692: break;
2693: case "Save contents on exit":
2694: busHighMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2695: break;
2696: }
2697: }
2698: };
2699: ButtonGroup highMemoryGroup = new ButtonGroup ();
2700: JMenu highMemoryMenu = Multilingual.mlnText (
2701: ComponentFactory.createMenu (
2702: "High memory on X68030/Xellent30",
2703: Multilingual.mlnText (
2704: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 0 << 20, "None", highMemoryListener),
2705: "ja", "なし"),
2706: Multilingual.mlnText (
2707: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 16 << 20, "16MB", highMemoryListener),
2708: "ja", "16MB"),
2709: ComponentFactory.createHorizontalSeparator (),
2710: Multilingual.mlnText (
2711: ComponentFactory.createCheckBoxMenuItem (busHighMemorySaveOn, "Save contents on exit", highMemoryListener),
2712: "ja", "終了時に内容を保存する")
2713: ),
2714: "ja", "X68030/Xellent30 のハイメモリ");
2715:
2716:
2717: ActionListener localMemoryListener = new ActionListener () {
2718: @Override public void actionPerformed (ActionEvent ae) {
2719: Object source = ae.getSource ();
2720: String command = ae.getActionCommand ();
2721: switch (command) {
2722: case "None":
2723: busLocalMemorySize = 0 << 20;
2724: break;
2725: case "16MB":
2726: busLocalMemorySize = 16 << 20;
2727: break;
2728: case "32MB":
2729: busLocalMemorySize = 32 << 20;
2730: break;
2731: case "64MB":
2732: busLocalMemorySize = 64 << 20;
2733: break;
2734: case "128MB":
2735: busLocalMemorySize = 128 << 20;
2736: break;
2737: case "256MB":
2738: busLocalMemorySize = 256 << 20;
2739: break;
2740: case "384MB":
2741: busLocalMemorySize = 384 << 20;
2742: break;
2743: case "512MB":
2744: busLocalMemorySize = 512 << 20;
2745: break;
2746: case "768MB":
2747: busLocalMemorySize = 768 << 20;
2748: break;
2749: case "Save contents on exit":
2750: busLocalMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2751: break;
2752: case "Available on X68000":
2753: busHimem68000 = ((JCheckBoxMenuItem) source).isSelected ();
2754: break;
2755: case "Available on X68030/Xellent30":
2756: busHighMemory060turboOn = ((JCheckBoxMenuItem) source).isSelected ();
2757: break;
2758: }
2759: }
2760: };
2761: ButtonGroup localMenoryGroup = new ButtonGroup ();
2762: JMenu localMemoryMenu = Multilingual.mlnText (
2763: ComponentFactory.createMenu (
2764: "High memory on 060turbo",
2765: Multilingual.mlnText (
2766: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 0 << 20, "None", localMemoryListener),
2767: "ja", "なし"),
2768: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 16 << 20, "16MB", localMemoryListener),
2769: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 32 << 20, "32MB", localMemoryListener),
2770: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 64 << 20, "64MB", localMemoryListener),
2771: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 128 << 20, "128MB", localMemoryListener),
2772: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 256 << 20, "256MB", localMemoryListener),
2773: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 384 << 20, "384MB", localMemoryListener),
2774: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 512 << 20, "512MB", localMemoryListener),
2775: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 768 << 20, "768MB", localMemoryListener),
2776: ComponentFactory.createHorizontalSeparator (),
2777: Multilingual.mlnText (
2778: ComponentFactory.createCheckBoxMenuItem (busLocalMemorySaveOn, "Save contents on exit", localMemoryListener),
2779: "ja", "終了時に内容を保存する"),
2780: ComponentFactory.createHorizontalSeparator (),
2781: Multilingual.mlnText (
2782: ComponentFactory.createCheckBoxMenuItem (busHimem68000, "Available on X68000", localMemoryListener),
2783: "ja", "X68000 でも有効"),
2784: Multilingual.mlnText (
2785: ComponentFactory.createCheckBoxMenuItem (busHighMemory060turboOn, "Available on X68030/Xellent30", localMemoryListener),
2786: "ja", "X68030/Xellent30 でも有効")
2787: ),
2788: "ja", "060turbo のハイメモリ");
2789:
2790:
2791: ActionListener xellent30Listener = new ActionListener () {
2792: @Override public void actionPerformed (ActionEvent ae) {
2793: Object source = ae.getSource ();
2794: String command = ae.getActionCommand ();
2795: switch (command) {
2796: case "$00EC0000-$00EC3FFF":
2797: xt3DIPSW = 0;
2798: break;
2799: case "$00EC4000-$00EC7FFF":
2800: xt3DIPSW = 1;
2801: break;
2802: case "$00EC8000-$00ECBFFF":
2803: xt3DIPSW = 2;
2804: break;
2805: case "$00ECC000-$00ECFFFF":
2806: xt3DIPSW = 3;
2807: break;
2808: case "256KB":
2809: xt3MemorySizeRequest = 1 << 18;
2810: break;
2811: case "1MB":
2812: xt3MemorySizeRequest = 1 << 20;
2813: break;
2814: case "Save contents on exit":
2815: xt3MemorySave = ((JCheckBoxMenuItem) source).isSelected ();
2816: break;
2817: }
2818: }
2819: };
2820: ButtonGroup xellent30PortGroup = new ButtonGroup ();
2821: ButtonGroup xellent30SizeGroup = new ButtonGroup ();
2822: JMenu xellent30Menu = ComponentFactory.createMenu (
2823: "Xellent30",
2824: ComponentFactory.createRadioButtonMenuItem (
2825: xellent30PortGroup,
2826: xt3DIPSW == 0,
2827: "$00EC0000-$00EC3FFF",
2828: xellent30Listener),
2829: ComponentFactory.createRadioButtonMenuItem (
2830: xellent30PortGroup,
2831: xt3DIPSW == 1,
2832: "$00EC4000-$00EC7FFF",
2833: xellent30Listener),
2834: ComponentFactory.createRadioButtonMenuItem (
2835: xellent30PortGroup,
2836: xt3DIPSW == 2,
2837: "$00EC8000-$00ECBFFF",
2838: xellent30Listener),
2839: ComponentFactory.createRadioButtonMenuItem (
2840: xellent30PortGroup,
2841: xt3DIPSW == 3,
2842: "$00ECC000-$00ECFFFF",
2843: xellent30Listener),
2844: ComponentFactory.createHorizontalSeparator (),
2845: ComponentFactory.createRadioButtonMenuItem (
2846: xellent30SizeGroup,
2847: xt3MemorySizeRequest == 1 << 18,
2848: "256KB",
2849: xellent30Listener),
2850: ComponentFactory.createRadioButtonMenuItem (
2851: xellent30SizeGroup,
2852: xt3MemorySizeRequest == 1 << 20,
2853: "1MB",
2854: xellent30Listener),
2855: ComponentFactory.createHorizontalSeparator (),
2856: Multilingual.mlnText (
2857: ComponentFactory.createCheckBoxMenuItem (xt3MemorySave, "Save contents on exit", xellent30Listener),
2858: "ja", "終了時に内容を保存する")
2859: );
2860:
2861:
2862: JMenu rotationMenu = null;
2863: if (PNL_ROTATION_ON) {
2864: ActionListener rotationListener = new ActionListener () {
2865: @Override public void actionPerformed (ActionEvent ae) {
2866: String command = ae.getActionCommand ();
2867: switch (command) {
2868: case "No rotation (landscape)":
2869: pnlRotationMode = 0;
2870: pnlUpdateArrangement ();
2871: break;
2872: case "90-degree rotation (portrait)":
2873: pnlRotationMode = 1;
2874: pnlUpdateArrangement ();
2875: break;
2876: case "180-degree rotation":
2877: pnlRotationMode = 2;
2878: pnlUpdateArrangement ();
2879: break;
2880: case "270-degree rotation":
2881: pnlRotationMode = 3;
2882: pnlUpdateArrangement ();
2883: break;
2884: default:
2885: System.out.println ("unknown action command " + command);
2886: }
2887: }
2888: };
2889: ButtonGroup rotationGroup = new ButtonGroup ();
2890: rotationMenu = Multilingual.mlnText (
2891: ComponentFactory.createMenu (
2892: "Rotation",
2893: Multilingual.mlnText (
2894: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 0, "No rotation (landscape)", rotationListener),
2895: "ja", "回転なし (横画面)"),
2896: Multilingual.mlnText (
2897: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 1, "90-degree rotation (portrait)", rotationListener),
2898: "ja", "90 度回転 (縦画面)"),
2899: Multilingual.mlnText (
2900: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 2, "180-degree rotation", rotationListener),
2901: "ja", "180 度回転"),
2902: Multilingual.mlnText (
2903: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 3, "270-degree rotation", rotationListener),
2904: "ja", "270 度回転")
2905: ),
2906: "ja", "回転");
2907: }
2908:
2909:
2910: ActionListener aspectListener = new ActionListener () {
2911: @Override public void actionPerformed (ActionEvent ae) {
2912: String command = ae.getActionCommand ();
2913: int i = command.indexOf (',');
2914: int key = Integer.parseInt (command.substring (0, i));
2915: int value = Integer.parseInt (command.substring (i + 1));
2916: pnlAspectMap[key] = value;
2917: pnlUpdateAspectTable ();
2918: pnlUpdateArrangement ();
2919: }
2920: };
2921: JMenu aspectMenu = ComponentFactory.createMenu ("Aspect ratio");
2922: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
2923: if (key != 0) {
2924: aspectMenu.add (ComponentFactory.createHorizontalSeparator ());
2925: }
2926: ButtonGroup group = new ButtonGroup ();
2927: for (int value = 0; value < PNL_ASPECT_VALUES; value++) {
2928: if (PNL_ASPECT_MATRIX[key][value] == 0.0F) {
2929: continue;
2930: }
2931: aspectMenu.add (
2932: ComponentFactory.setText (
2933: ComponentFactory.createRadioButtonMenuItem (
2934: group,
2935: pnlAspectMap[key] == value,
2936: key + "," + value,
2937: aspectListener
2938: ),
2939: (PNL_ASPECT_MATRIX[key] == PNL_ASPECT_SCREEN_RATIO ?
2940: String.format ("%s %s (%.3f)",
2941: PNL_ASPECT_RESOLUTION_NAME[key],
2942: PNL_ASPECT_SCREEN_NAME[value],
2943: PNL_ASPECT_SCREEN_RATIO[value]) :
2944: String.format ("%s %s (%.3f) @ %s (%.3f)",
2945: PNL_ASPECT_RESOLUTION_NAME[key],
2946: PNL_ASPECT_SCREEN_NAME[value],
2947: PNL_ASPECT_SCREEN_RATIO[value],
2948: PNL_ASPECT_PIXEL_NAME[value],
2949: PNL_ASPECT_PIXEL_RATIO[value]))
2950: )
2951: );
2952: }
2953: }
2954: aspectMenu = Multilingual.mlnText (aspectMenu, "ja", "アスペクト比");
2955:
2956:
2957: ActionListener scanlineListener = new ActionListener () {
2958: @Override public void actionPerformed (ActionEvent ae) {
2959:
2960: String command = ae.getActionCommand ();
2961: switch (command) {
2962: case "Off":
2963: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.OFF;
2964: CRTC.crtAllStamp += 2;
2965: break;
2966: case "Weak":
2967: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.WEAK;
2968: CRTC.crtAllStamp += 2;
2969: break;
2970: case "Medium":
2971: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.MEDIUM;
2972: CRTC.crtAllStamp += 2;
2973: break;
2974: case "Strong":
2975: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.STRONG;
2976: CRTC.crtAllStamp += 2;
2977: break;
2978: case "Black":
2979: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.BLACK;
2980: CRTC.crtAllStamp += 2;
2981: break;
2982: }
2983: }
2984: };
2985: ButtonGroup scanlineGroup = new ButtonGroup ();
2986: JMenu scanlineMenu =
2987: Multilingual.mlnText (
2988: ComponentFactory.createMenu (
2989: "Scanline effect",
2990: Multilingual.mlnText (
2991: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.OFF, "Off", scanlineListener),
2992: "ja", "なし"),
2993: Multilingual.mlnText (
2994: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.WEAK, "Weak", scanlineListener),
2995: "ja", "弱"),
2996: Multilingual.mlnText (
2997: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.MEDIUM, "Medium", scanlineListener),
2998: "ja", "中"),
2999: Multilingual.mlnText (
3000: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.STRONG, "Strong", scanlineListener),
3001: "ja", "強"),
3002: Multilingual.mlnText (
3003: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.BLACK, "Black", scanlineListener),
3004: "ja", "黒")
3005: ),
3006: "ja", "走査線エフェクト");
3007:
3008:
3009: JTextField refreshRateTextField = ComponentFactory.createNumberField (pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate), 8);
3010: refreshRateTextField.addActionListener (
3011: new ActionListener () {
3012: @Override public void actionPerformed (ActionEvent ae) {
3013: JTextField textField = (JTextField) ae.getSource ();
3014: pnlRefreshRate = 0.0;
3015: String s = textField.getText ();
3016: if (!s.equals ("")) {
3017: double rate = 0.0;
3018: try {
3019: rate = Double.parseDouble (s);
3020: } catch (NumberFormatException nfe) {
3021: }
3022: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
3023: pnlRefreshRate = rate;
3024: } else {
3025: textField.setText ("");
3026: }
3027: }
3028: pnlFixedRate = pnlRefreshRate;
3029: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3030: pnlFixedRate = pnlGetRefreshRate ();
3031: }
3032: CRTC.crtUpdateLength ();
3033: }
3034: });
3035:
3036: ButtonGroup unitGroup = new ButtonGroup ();
3037: ButtonGroup frameGroup = new ButtonGroup ();
3038: ButtonGroup hintGroup = new ButtonGroup ();
3039: ButtonGroup vgaGroup = new ButtonGroup ();
3040: ButtonGroup intermittentGroup = new ButtonGroup ();
3041: ButtonGroup sterescopicGroup = new ButtonGroup ();
3042: ButtonGroup soundInterpolationGroup = new ButtonGroup ();
3043: ButtonGroup adpcmInterpolationGroup = new ButtonGroup ();
3044: ButtonGroup adpcmOSCFreqGroup = new ButtonGroup ();
3045: ButtonGroup keyboardGroup = new ButtonGroup ();
3046: ButtonGroup spritesGroup = new ButtonGroup ();
3047:
3048:
3049: DecimalSpinner[] freqSpinner = new DecimalSpinner[3];
3050: ChangeListener freqListener = new ChangeListener () {
3051: @Override public void stateChanged (ChangeEvent ce) {
3052: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
3053: int i = spinner.getOption ();
3054: CRTC.crtFreqsRequest[i] = spinner.getIntValue ();
3055: }
3056: };
3057: for (int i = 0; i < 3; i++) {
3058: freqSpinner[i] = ComponentFactory.createDecimalSpinner (
3059: CRTC.crtFreqsRequest[i], CRTC.CRT_MIN_FREQ, CRTC.CRT_MAX_FREQ, 1000000, i, freqListener
3060: );
3061: }
3062: DecimalSpinner sprrasSpinner = ComponentFactory.createDecimalSpinner (
3063: SpriteScreen.sprSpritesPerRaster, 0, 1016, 1, 0,
3064: new ChangeListener () {
3065: @Override public void stateChanged (ChangeEvent ce) {
3066: SpriteScreen.sprSpritesPerRaster = ((DecimalSpinner) ce.getSource ()).getIntValue ();
3067: }
3068: });
3069: ActionListener modificationListener = new ActionListener () {
3070: @Override public void actionPerformed (ActionEvent ae) {
3071: Object source = ae.getSource ();
3072: String command = ae.getActionCommand ();
3073: switch (command) {
3074:
3075: case "Adjust to host refresh rate":
3076: pnlAdjustVsync = ((JCheckBoxMenuItem) source).isSelected ();
3077: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3078: pnlFixedRate = pnlGetRefreshRate ();
3079: }
3080: CRTC.crtUpdateLength ();
3081: break;
3082: case "* Reset to default values":
3083: for (int i = 0; i < 3; i++) {
3084: if (CRTC.crtFreqsRequest[i] != CRTC.CRT_DEFAULT_FREQS[i]) {
3085: CRTC.crtFreqsRequest[i] = CRTC.CRT_DEFAULT_FREQS[i];
3086: freqSpinner[i].setIntValue (CRTC.crtFreqsRequest[i]);
3087: }
3088: }
3089: break;
3090: case "1024-dot non-interlaced":
3091: CRTC.crtEleventhBitRequest = ((JCheckBoxMenuItem) source).isSelected ();
3092: break;
3093: case "Can write 0 to bit 0 of CRTC R00":
3094: CRTC.crtR00Bit0Zero = ((JCheckBoxMenuItem) source).isSelected ();
3095: break;
3096:
3097: case "Extended graphic screen":
3098: CRTC.crtExtendedGraphicRequest = ((JCheckBoxMenuItem) source).isSelected ();
3099: break;
3100:
3101: case "Spherical scrolling of text screen":
3102: CRTC.crtSetSphericalScrolling (((JCheckBoxMenuItem) source).isSelected ());
3103: break;
3104:
3105: case "128 sprites":
3106: SpriteScreen.sprNumberOfSpritesRequest = 128;
3107: break;
3108: case "256 sprites":
3109: SpriteScreen.sprNumberOfSpritesRequest = 256;
3110: break;
3111: case "504 sprites":
3112: SpriteScreen.sprNumberOfSpritesRequest = 512;
3113: break;
3114: case "1016 sprites":
3115: SpriteScreen.sprNumberOfSpritesRequest = 1024;
3116: break;
3117:
3118:
3119:
3120: case "Full pattern memory":
3121: SpriteScreen.sprFPMRequest = ((JCheckBoxMenuItem) source).isSelected ();
3122: break;
3123: case "4096 patterns":
3124: SpriteScreen.sprBankOnRequest = ((JCheckBoxMenuItem) source).isSelected ();
3125: break;
3126: case "Sprites displayed in 768x512":
3127: SpriteScreen.spr768x512Request = ((JCheckBoxMenuItem) source).isSelected ();
3128: break;
3129: case "BG1 displayed in 512x512":
3130: SpriteScreen.spr512bg1Request = ((JCheckBoxMenuItem) source).isSelected ();
3131: break;
3132: case "Row and column scroll":
3133: if (SpriteScreen.SPR_RC_SCROLL_ON) {
3134: SpriteScreen.sprRcScrollRequest = ((JCheckBoxMenuItem) source).isSelected ();
3135: }
3136: break;
3137: case "** Reset to default values":
3138: if (SpriteScreen.sprSpritesPerRaster != 32) {
3139: SpriteScreen.sprSpritesPerRaster = 32;
3140: sprrasSpinner.setIntValue (SpriteScreen.sprSpritesPerRaster);
3141: }
3142: break;
3143: }
3144: }
3145: };
3146: JMenu modificationMenu =
3147: Multilingual.mlnText (
3148: ComponentFactory.createMenu (
3149: "Modification",
3150: Multilingual.mlnText (
3151: ComponentFactory.createMenu (
3152: "Dot clock",
3153: Multilingual.mlnText (
3154: ComponentFactory.createCheckBoxMenuItem (pnlAdjustVsync, "Adjust to host refresh rate", modificationListener),
3155: "ja", "ホストのリフレッシュレートに合わせる"),
3156: ComponentFactory.createHorizontalBox (
3157: Box.createHorizontalStrut (20),
3158: refreshRateTextField,
3159: ComponentFactory.createLabel (" Hz"),
3160: Box.createHorizontalGlue ()
3161: ),
3162: ComponentFactory.createHorizontalSeparator (),
3163: ComponentFactory.createHorizontalBox (
3164: Box.createHorizontalStrut (20),
3165: Multilingual.mlnText (ComponentFactory.createLabel ("Dot clock oscillattor"), "ja", "ドットクロックオシレータ"),
3166: Box.createHorizontalGlue ()
3167: ),
3168: ComponentFactory.createHorizontalBox (
3169: Box.createHorizontalStrut (20),
3170: freqSpinner[0],
3171: ComponentFactory.createLabel (" Hz *"),
3172: Box.createHorizontalGlue ()
3173: ),
3174: ComponentFactory.createHorizontalBox (
3175: Box.createHorizontalStrut (20),
3176: freqSpinner[1],
3177: ComponentFactory.createLabel (" Hz *"),
3178: Box.createHorizontalGlue ()
3179: ),
3180: ComponentFactory.createHorizontalBox (
3181: Box.createHorizontalStrut (20),
3182: freqSpinner[2],
3183: ComponentFactory.createLabel (" Hz *"),
3184: Box.createHorizontalGlue ()
3185: ),
3186: Multilingual.mlnText (
3187: ComponentFactory.createMenuItem ("* Reset to default values", modificationListener),
3188: "ja", "* 初期値に戻す"),
3189: ComponentFactory.createHorizontalSeparator (),
3190: Multilingual.mlnText (
3191: ComponentFactory.createCheckBoxMenuItem (CRTC.crtEleventhBitRequest, "1024-dot non-interlaced", modificationListener),
3192: "ja", "1024 ドットノンインターレース"),
3193: Multilingual.mlnText (
3194: ComponentFactory.createCheckBoxMenuItem (CRTC.crtR00Bit0Zero, "Can write 0 to bit 0 of CRTC R00", modificationListener),
3195: "ja", "CRTC R00 のビット 0 に 0 を書き込める")
3196: ),
3197: "ja", "ドットクロック"),
3198: Multilingual.mlnText (
3199: ComponentFactory.createMenu (
3200: "Graphic screen",
3201: !CRTC.CRT_EXTENDED_GRAPHIC ? null : Multilingual.mlnText (
3202: ComponentFactory.createCheckBoxMenuItem (CRTC.crtExtendedGraphicRequest, "Extended graphic screen", modificationListener),
3203: "ja", "拡張グラフィック画面")
3204: ),
3205: "ja", "グラフィック画面"),
3206: Multilingual.mlnText (
3207: ComponentFactory.createMenu (
3208: "Text screen",
3209: Multilingual.mlnText (
3210: ComponentFactory.createCheckBoxMenuItem (CRTC.crtSphericalScrolling, "Spherical scrolling of text screen", modificationListener),
3211: "ja", "テキスト画面の球面スクロール")
3212: ),
3213: "ja", "テキスト画面"),
3214: Multilingual.mlnText (
3215: ComponentFactory.createMenu (
3216: "Sprite screen",
3217: Multilingual.mlnText (
3218: ComponentFactory.createRadioButtonMenuItem (
3219: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 128, "128 sprites", modificationListener),
3220: "ja", "128 枚のスプライト"),
3221: Multilingual.mlnText (
3222: ComponentFactory.createRadioButtonMenuItem (
3223: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 256, "256 sprites", modificationListener),
3224: "ja", "256 枚のスプライト"),
3225: Multilingual.mlnText (
3226: ComponentFactory.createRadioButtonMenuItem (
3227: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 512, "504 sprites", modificationListener),
3228: "ja", "504 枚のスプライト"),
3229: Multilingual.mlnText (
3230: ComponentFactory.createRadioButtonMenuItem (
3231: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 1024, "1016 sprites", modificationListener),
3232: "ja", "1016 枚のスプライト"),
3233:
3234:
3235:
3236:
3237: ComponentFactory.createHorizontalSeparator (),
3238: Multilingual.mlnText (
3239: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprFPMRequest, "Full pattern memory", modificationListener),
3240: "ja", "フルパターンメモリ"),
3241: Multilingual.mlnText (
3242: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprBankOnRequest, "4096 patterns", modificationListener),
3243: "ja", "4096 個のパターン"),
3244: Multilingual.mlnText (
3245: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr768x512Request, "Sprites displayed in 768x512", modificationListener),
3246: "ja", "768x512 でスプライトを表示"),
3247: Multilingual.mlnText (
3248: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr512bg1Request, "BG1 displayed in 512x512", modificationListener),
3249: "ja", "512x512 で BG1 を表示"),
3250: !SpriteScreen.SPR_RC_SCROLL_ON ? null : Multilingual.mlnText (
3251: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprRcScrollRequest, "Row and column scroll", modificationListener),
3252: "ja", "行スクロールと列スクロール"),
3253: ComponentFactory.createHorizontalSeparator (),
3254: ComponentFactory.createHorizontalBox (
3255: Box.createHorizontalStrut (20),
3256: Multilingual.mlnText (ComponentFactory.createLabel ("Number of sprites per raster"), "ja", "ラスタあたりのスプライトの枚数"),
3257: Box.createHorizontalGlue ()
3258: ),
3259: ComponentFactory.createHorizontalBox (
3260: Box.createHorizontalStrut (20),
3261: sprrasSpinner,
3262: ComponentFactory.createLabel (" **"),
3263: Box.createHorizontalGlue ()
3264: ),
3265: Multilingual.mlnText (
3266: ComponentFactory.createMenuItem ("** Reset to default values", modificationListener),
3267: "ja", "** 初期値に戻す")
3268: ),
3269: "ja", "スプライト画面")
3270: ),
3271: "ja", "改造");
3272:
3273:
3274: mnbMenuBar = ComponentFactory.createMenuBar (
3275:
3276:
3277: mnbFileMenu = Multilingual.mlnText (
3278: ComponentFactory.createMenu (
3279: "File", 'F',
3280:
3281: FDC.fdcMenu,
3282:
3283: HDC.hdcMenu,
3284:
3285: SPC.spcMenu,
3286:
3287: HFS.hfsMenu,
3288: ComponentFactory.createHorizontalSeparator (),
3289: mnbQuitMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Quit", 'Q', MNB_MODIFIERS, listener), "ja", "終了")
3290: ),
3291: "ja", "ファイル"),
3292:
3293:
3294: mpuMenu,
3295:
3296:
3297: mnbDisplayMenu = Multilingual.mlnText (
3298: ComponentFactory.createMenu (
3299: "Display", 'D',
3300: mnbFullScreenMenuItem,
3301: mnbMaximizedMenuItem,
3302: mnbFitInWindowMenuItem,
3303: mnbFixedScaleMenuItem,
3304: ComponentFactory.createHorizontalBox (
3305: Box.createHorizontalStrut (20),
3306: pnlFixedSpinner,
3307: ComponentFactory.createLabel ("%"),
3308: Box.createHorizontalGlue ()
3309: ),
3310: ComponentFactory.createMenuItem ("50%", listener),
3311: ComponentFactory.createMenuItem ("75%", listener),
3312: ComponentFactory.createMenuItem ("100%", listener),
3313: ComponentFactory.createMenuItem ("150%", listener),
3314: ComponentFactory.createMenuItem ("200%", listener),
3315:
3316: rotationMenu,
3317:
3318: aspectMenu,
3319:
3320: Multilingual.mlnText (
3321: ComponentFactory.createMenu (
3322: "Interpolation algorithm",
3323: Multilingual.mlnText (
3324: ComponentFactory.createRadioButtonMenuItem (
3325: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
3326: "Nearest neighbor", listener),
3327: "ja", "最近傍補間"),
3328: Multilingual.mlnText (
3329: ComponentFactory.createRadioButtonMenuItem (
3330: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR,
3331: "Bilinear", listener),
3332: "ja", "線形補間"),
3333: Multilingual.mlnText (
3334: ComponentFactory.createRadioButtonMenuItem (
3335: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC,
3336: "Bicubic", listener),
3337: "ja", "三次補間")
3338: ),
3339: "ja", "補間アルゴリズム"),
3340:
3341: scanlineMenu,
3342: !PNL_USE_CANVAS ? null : Multilingual.mlnText (
3343: ComponentFactory.createCheckBoxMenuItem (pnlUseCanvasRequest, "Use canvas", listener),
3344: "ja", "キャンバスを使う"),
3345:
3346: !CRTC.CRT_ENABLE_INTERMITTENT ? null : Multilingual.mlnText (
3347: ComponentFactory.createMenu (
3348: "Intermittent drawing",
3349: Multilingual.mlnText (
3350: ComponentFactory.createRadioButtonMenuItem (
3351: intermittentGroup, CRTC.crtIntermittentInterval == 0, "Draw all changed pictures", listener),
3352: "ja", "変化した画像をすべて描画する"),
3353: Multilingual.mlnText (
3354: ComponentFactory.createRadioButtonMenuItem (
3355: intermittentGroup, CRTC.crtIntermittentInterval == 1, "Draw a changed picture once every two times", listener),
3356: "ja", "変化した画像を 2 回に 1 回描画する"),
3357: Multilingual.mlnText (
3358: ComponentFactory.createRadioButtonMenuItem (
3359: intermittentGroup, CRTC.crtIntermittentInterval == 2, "Draw a changed picture once every three times", listener),
3360: "ja", "変化した画像を 3 回に 1 回描画する"),
3361: Multilingual.mlnText (
3362: ComponentFactory.createRadioButtonMenuItem (
3363: intermittentGroup, CRTC.crtIntermittentInterval == 3, "Draw a changed picture once every four times", listener),
3364: "ja", "変化した画像を 4 回に 1 回描画する"),
3365: Multilingual.mlnText (
3366: ComponentFactory.createRadioButtonMenuItem (
3367: intermittentGroup, CRTC.crtIntermittentInterval == 4, "Draw a changed picture once every five times", listener),
3368: "ja", "変化した画像を 5 回に 1 回描画する")
3369: ),
3370: "ja", "間欠描画"),
3371:
3372: !PNL_STEREOSCOPIC_ON ? null : ComponentFactory.createHorizontalSeparator (),
3373: mnbStereoscopicMenuItem = !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3374: ComponentFactory.createCheckBoxMenuItem (pnlStereoscopicOn, "Stereoscopic viewing", 'T', listener),
3375: "ja", "立体視"),
3376: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3377: ComponentFactory.createMenu (
3378: "Stereoscopic settings",
3379: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3380: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3381: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING,
3382: "Naked-eye crossing", listener),
3383: "ja", "裸眼交差法"),
3384: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3385: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3386: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL,
3387: "Naked-eye parallel", listener),
3388: "ja", "裸眼平行法"),
3389: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3390: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3391: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE,
3392: "Side-by-side", listener),
3393: "ja", "サイドバイサイド"),
3394: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3395: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3396: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM,
3397: "Top-and-bottom", listener),
3398: "ja", "トップアンドボトム")
3399: ),
3400: "ja", "立体視設定"),
3401:
3402: ComponentFactory.createHorizontalSeparator (),
3403: GIFAnimation.gifStartRecordingMenuItem,
3404: GIFAnimation.gifSettingsMenu,
3405:
3406: ComponentFactory.createHorizontalSeparator (),
3407: modificationMenu,
3408:
3409: SpritePatternViewer.SPV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Sprite pattern viewer", listener), "ja", "スプライトパターンビュア") : null,
3410: PaletteViewer.PLV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Palette viewer", listener), "ja", "パレットビュア") : null,
3411: ScreenModeTest.SMT_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Screen mode test", listener), "ja", "表示モードテスト") : null
3412: ),
3413: "ja", "画面"),
3414:
3415:
3416: mnbSoundMenu = ComponentFactory.setEnabled (
3417: Multilingual.mlnText (
3418: ComponentFactory.createMenu (
3419: "Sound", 'S',
3420: mnbPlayMenuItem = ComponentFactory.setEnabled (
3421: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (SoundSource.sndPlayOn, "Play", 'P', MNB_MODIFIERS, listener), "ja", "音声出力"),
3422: SoundSource.sndLine != null),
3423:
3424:
3425:
3426: ComponentFactory.createHorizontalBox (
3427: Box.createHorizontalGlue (),
3428: Multilingual.mlnText (ComponentFactory.createLabel ("Volume "), "ja", "音量 "),
3429: mnbVolumeLabel = ComponentFactory.createLabel (String.valueOf (SoundSource.sndVolume)),
3430: Box.createHorizontalGlue ()
3431: ),
3432:
3433:
3434: ComponentFactory.setPreferredSize (
3435: ComponentFactory.createHorizontalSlider (
3436: 0,
3437: SoundSource.SND_VOLUME_MAX,
3438: SoundSource.sndVolume,
3439: SoundSource.SND_VOLUME_STEP,
3440: 1,
3441: new ChangeListener () {
3442: @Override public void stateChanged (ChangeEvent ce) {
3443: SoundSource.sndSetVolume (((JSlider) ce.getSource ()).getValue ());
3444: }
3445: }),
3446: LnF.lnfFontSize * 18, LnF.lnfFontSize * 2 + 28),
3447: Multilingual.mlnText (
3448: ComponentFactory.createMenu (
3449: "Sound interpolation",
3450: Multilingual.mlnText (
3451: ComponentFactory.createRadioButtonMenuItem (
3452: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.THINNING_STEREO,
3453: "Sound thinning", listener),
3454: "ja", "音声 間引き"),
3455: Multilingual.mlnText (
3456: ComponentFactory.createRadioButtonMenuItem (
3457: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_STEREO,
3458: "Sound linear interpolation", listener),
3459: "ja", "音声 線形補間"),
3460: ComponentFactory.setEnabled (
3461: Multilingual.mlnText (
3462: ComponentFactory.createRadioButtonMenuItem (
3463: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000,
3464: "Sound piecewise-constant area interpolation", listener),
3465: "ja", "音声 区分定数面積補間"),
3466: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000),
3467: ComponentFactory.setEnabled (
3468: Multilingual.mlnText (
3469: ComponentFactory.createRadioButtonMenuItem (
3470: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000,
3471: "Sound linear area interpolation", listener),
3472: "ja", "音声 線形面積補間"),
3473: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000)
3474: ),
3475: "ja", "音声補間"),
3476: Multilingual.mlnText (ComponentFactory.createMenuItem ("Sound monitor", listener), "ja", "音声モニタ"),
3477:
3478: ComponentFactory.createHorizontalSeparator (),
3479:
3480: ComponentFactory.setEnabled (
3481: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (OPM.opmOutputMask != 0, "OPM output", listener), "ja", "OPM 出力"),
3482: SoundSource.sndLine != null),
3483: !OPMLog.OLG_ON ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("OPM log", listener), "ja", "OPM ログ"),
3484:
3485: ComponentFactory.createHorizontalSeparator (),
3486:
3487: ComponentFactory.setEnabled (
3488: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ADPCM.pcmOutputOn, "PCM output", listener), "ja", "PCM 出力"),
3489: SoundSource.sndLine != null),
3490: Multilingual.mlnText (
3491: ComponentFactory.createMenu (
3492: "PCM interpolation",
3493: Multilingual.mlnText (
3494: ComponentFactory.createRadioButtonMenuItem (
3495: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_CONSTANT,
3496: "PCM piecewise-constant interpolation", listener),
3497: "ja", "PCM 区分定数補間"),
3498: Multilingual.mlnText (
3499: ComponentFactory.createRadioButtonMenuItem (
3500: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_LINEAR,
3501: "PCM linear interpolation", listener),
3502: "ja", "PCM 線形補間"),
3503: Multilingual.mlnText (
3504: ComponentFactory.createRadioButtonMenuItem (
3505: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_HERMITE,
3506: "PCM hermite interpolation", listener),
3507: "ja", "PCM エルミート補間")
3508: ),
3509: "ja", "PCM 補間"),
3510: Multilingual.mlnText (
3511: ComponentFactory.createMenu (
3512: "PCM source oscillator frequency",
3513: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 0, "PCM 8MHz/4MHz", listener),
3514: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 1, "PCM 8MHz/16MHz", listener)
3515: ),
3516: "ja", "PCM 原発振周波数"),
3517:
3518: !MercuryUnit.MU4_ON ? null :
3519: ComponentFactory.createHorizontalSeparator (),
3520: !MercuryUnit.MU4_ON ? null :
3521: ComponentFactory.createCheckBoxMenuItem (
3522: MercuryUnit.mu4OnRequest,
3523: "Mercury-Unit V4 (MK-MU1)",
3524: listener),
3525: !MercuryUnit.MU4_ON ? null :
3526: Multilingual.mlnText (
3527: ComponentFactory.createCheckBoxMenuItem (
3528: MercuryUnit.mu4OutputEnable,
3529: "MU4 output",
3530: listener),
3531: "ja", "MU4 出力")
3532: ),
3533: "ja", "音声"),
3534: SoundSource.sndLine != null),
3535:
3536:
3537: mnbInputMenu = Multilingual.mlnText (
3538: ComponentFactory.createMenu (
3539: "Input", 'I',
3540: mnbPasteMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Paste", 'V', MNB_MODIFIERS, listener), "ja", "貼り付け"),
3541: CONDevice.conSettingsMenu,
3542: TextCopy.txcMakeMenuItem (),
3543: TextCopy.txcMakeSettingMenu (),
3544: ComponentFactory.createHorizontalSeparator (),
3545: mnbNoKeyboardMenuItem = Multilingual.mlnText (
3546: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, !Keyboard.kbdOn, "No keyboard", 'K', MNB_MODIFIERS, listener),
3547: "ja", "キーボードなし"),
3548: mnbStandardKeyboardMenuItem = Multilingual.mlnText (
3549: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_STANDARD_TYPE, "Standard keyboard", listener),
3550: "ja", "標準キーボード"),
3551: mnbCompactKeyboardMenuItem = Multilingual.mlnText (
3552: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_COMPACT_TYPE, "Compact keyboard", listener),
3553: "ja", "コンパクトキーボード"),
3554: Multilingual.mlnText (
3555: ComponentFactory.createCheckBoxMenuItem (pnlHideKeyboard, "Hide keyboard in full screen", listener),
3556: "ja", "全画面表示のときキーボードを隠す"),
3557: Multilingual.mlnText (ComponentFactory.createMenuItem ("Key assignments", listener), "ja", "キー割り当て"),
3558: ButtonFunction.bfnMakeMenuItem (),
3559: SRAM.smrRepeatDelayMenu,
3560: SRAM.smrRepeatIntervalMenu,
3561: !Keyboard.KBD_ZKEY_ON ? null : Keyboard.kbdZKeyMenu,
3562: ComponentFactory.createHorizontalSeparator (),
3563: Mouse.musSeamlessMouseCheckBox,
3564: Mouse.musFollowScrollCheckBox,
3565: Mouse.musCtrlRightCheckBox,
3566: Mouse.musEdgeAccelerationCheckBox,
3567: Mouse.musMouseCursorSpeedBox,
3568: Mouse.musSpeedSlider,
3569: Mouse.musHostsPixelUnitsCheckBox,
3570: ComponentFactory.createHorizontalSeparator (),
3571: Multilingual.mlnText (ComponentFactory.createMenuItem ("Joystick port settings", listener), "ja", "ジョイスティックポート設定")
3572: ),
3573: "ja", "入力"),
3574:
3575:
3576: mnbConfigMenu = Multilingual.mlnText (
3577: ComponentFactory.createMenu (
3578: "Config", 'G',
3579: Multilingual.mlnText (ComponentFactory.createMenuItem ("RS-232C and terminal", listener), "ja", "RS-232C とターミナル"),
3580: Multilingual.mlnText (
3581: ComponentFactory.createMenu (
3582: "Debug",
3583: Multilingual.mlnText (ComponentFactory.createMenuItem ("Console", listener), "ja", "コンソール"),
3584: Multilingual.mlnText (ComponentFactory.createMenuItem ("Register list", listener), "ja", "レジスタリスト"),
3585: Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble list", listener), "ja", "逆アセンブルリスト"),
3586: Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory dump list", listener), "ja", "メモリダンプリスト"),
3587: Multilingual.mlnText (ComponentFactory.createMenuItem ("Logical space monitor", listener), "ja", "論理空間モニタ"),
3588: Multilingual.mlnText (ComponentFactory.createMenuItem ("Physical space monitor", listener), "ja", "物理空間モニタ"),
3589: ATCMonitor.ACM_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Address translation caches monitor", listener), "ja", "アドレス変換キャッシュモニタ") : null,
3590: BranchLog.BLG_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Branch log", listener), "ja", "分岐ログ") : null,
3591: ProgramFlowVisualizer.PFV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Program flow visualizer", listener), "ja", "プログラムフロービジュアライザ") : null,
3592: RasterBreakPoint.RBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Raster break point", listener), "ja", "ラスタブレークポイント") : null,
3593: DataBreakPoint.DBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Data break point", listener), "ja", "データブレークポイント") : null,
3594: RootPointerList.RTL_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Root pointer list", listener), "ja", "ルートポインタリスト") : null,
3595: ComponentFactory.createHorizontalSeparator (),
3596: SRAM.smrRomdbMenu
3597: ),
3598: "ja", "デバッグ"),
3599: SRAM.smrBootMenu,
3600: mainMemoryMenu,
3601: highMemoryMenu,
3602: localMemoryMenu,
3603: xellent30Menu,
3604: ComponentFactory.createHorizontalSeparator (),
3605: ComponentFactory.createMenu (
3606: "RTC",
3607: Multilingual.mlnText (
3608: ComponentFactory.createMenuItem ("Adjust clock to host", listener),
3609: "ja", "時計をホストに合わせる")
3610: ),
3611: SRAM.smrMenu,
3612: Settings.sgsMenu,
3613: ComponentFactory.createHorizontalSeparator (),
3614: Multilingual.mlnText (ComponentFactory.createMenuItem ("Printer", listener), "ja", "プリンタ"),
3615: ROM.romMenu,
3616: Multilingual.mlnText (
3617: ComponentFactory.createMenu (
3618: "Miscellaneous",
3619: SlowdownTest.sdtCheckBoxMenuItem,
3620: SlowdownTest.sdtBox,
3621: Multilingual.mlnText (
3622: ComponentFactory.createCheckBoxMenuItem (Mouse.musOutputButtonStatus, "Print key and mouse button events", listener),
3623: "ja", "キーとマウスのボタンのイベントを表示"),
3624: Z8530.SCC_DEBUG_ON ? Z8530.sccDebugMenu : null
3625: ),
3626: "ja", "その他"),
3627: ComponentFactory.createHorizontalSeparator (),
3628: Multilingual.mlnText (
3629: ComponentFactory.createMenuItem ("Java runtime environment information", listener),
3630: "ja", "Java 実行環境の情報"),
3631: Multilingual.mlnText (
3632: ComponentFactory.createMenuItem ("Version information", listener),
3633: "ja", "バージョン情報"),
3634: Multilingual.mlnText (
3635: ComponentFactory.createMenu (
3636: "License",
3637: Multilingual.mlnText (ComponentFactory.createMenuItem ("XEiJ License", listener), "ja", "XEiJ 使用許諾条件"),
3638: Multilingual.mlnText (ComponentFactory.createMenuItem ("FSHARP License", listener), "ja", "FSHARP 許諾条件"),
3639: Multilingual.mlnText (ComponentFactory.createMenuItem ("ymfm License", listener), "ja", "ymfm License"),
3640: Multilingual.mlnText (ComponentFactory.createMenuItem ("jSerialComm License", listener), "ja", "jSerialComm License")
3641: ),
3642: "ja", "使用許諾条件")
3643: ),
3644: "ja", "設定"),
3645:
3646: mnbMakeLanguageMenu (),
3647:
3648:
3649: Box.createHorizontalGlue (),
3650: ComponentFactory.createVerticalBox (
3651: Box.createVerticalGlue (),
3652: Indicator.indBox,
3653: Box.createVerticalGlue ()
3654: ),
3655: Box.createHorizontalGlue ()
3656:
3657: );
3658: }
3659:
3660:
3661:
3662:
3663:
3664:
3665:
3666: public static boolean frmIsActive;
3667:
3668:
3669: public static JFrame frmFrame;
3670: public static int frmMarginWidth;
3671: public static int frmMarginHeight;
3672: public static Dimension frmMinimumSize;
3673:
3674:
3675: public static GraphicsDevice frmScreenDevice;
3676:
3677:
3678: public static DropTarget frmDropTarget;
3679:
3680:
3681:
3682: public static void frmInit () {
3683: frmIsActive = false;
3684: frmScreenDevice = GraphicsEnvironment.getLocalGraphicsEnvironment ().getDefaultScreenDevice ();
3685: pnlIsFullScreenSupported = frmScreenDevice.isFullScreenSupported ();
3686: }
3687:
3688:
3689:
3690: public static void frmMake () {
3691:
3692:
3693: frmFrame = ComponentFactory.createRestorableFrame (
3694: Settings.SGS_FRM_FRAME_KEY,
3695: PRG_TITLE + " version " + PRG_VERSION,
3696: mnbMenuBar,
3697: pnlPanel);
3698: frmUpdateTitle ();
3699: frmFrame.setIconImage (LnF.LNF_ICON_IMAGE_48);
3700: frmFrame.setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);
3701:
3702:
3703:
3704:
3705: frmMarginWidth = frmFrame.getWidth () - pnlPanel.getWidth ();
3706: frmMarginHeight = frmFrame.getHeight () - pnlPanel.getHeight ();
3707: frmMinimumSize = new Dimension (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
3708: frmFrame.setMinimumSize (frmMinimumSize);
3709:
3710:
3711:
3712: frmDropTarget = new DropTarget (pnlPanel, DnDConstants.ACTION_COPY, new DropTargetAdapter () {
3713: @Override public void dragOver (DropTargetDragEvent dtde) {
3714: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
3715: dtde.acceptDrag (DnDConstants.ACTION_COPY);
3716: return;
3717: }
3718: dtde.rejectDrag ();
3719: }
3720: @Override public void drop (DropTargetDropEvent dtde) {
3721: try {
3722: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
3723: dtde.acceptDrop (DnDConstants.ACTION_COPY);
3724: boolean reset = false;
3725: int fdu0 = -1;
3726: int fdu = 0;
3727: int hdu0 = -1;
3728: int hdu = 0;
3729: int scu0 = -1;
3730: int scu = 0;
3731: int hfu0 = -1;
3732: int hfu = 0;
3733: for (Object o : (java.util.List) dtde.getTransferable ().getTransferData (DataFlavor.javaFileListFlavor)) {
3734: if (o instanceof File) {
3735: File file = (File) o;
3736: if (file.isFile ()) {
3737: if (FDC.fdcFileFilter.accept (file)) {
3738: if (fdu < FDC.FDC_MAX_UNITS &&
3739: FDC.fdcUnitArray[fdu].insert (file.getPath (), false)) {
3740: if (fdu0 < 0) {
3741: fdu0 = fdu;
3742: }
3743: fdu++;
3744: continue;
3745: }
3746: }
3747: if (HDC.hdcFileFilter.accept (file)) {
3748: if (hdu < 16 &&
3749: HDC.hdcUnitArray[hdu].insert (file.getPath (), false)) {
3750: if (hdu0 < 0) {
3751: hdu0 = hdu;
3752: }
3753: hdu++;
3754: continue;
3755: }
3756: }
3757: if (SPC.spcFileFilter.accept (file)) {
3758: if (scu < 16 &&
3759: SPC.spcUnitArray[scu].insert (file.getPath (), false)) {
3760: if (scu0 < 0) {
3761: scu0 = scu;
3762: }
3763: scu++;
3764: continue;
3765: }
3766: }
3767: }
3768: if (HFS.hfsFileFilter.accept (file)) {
3769: if (hfu < HFS.HFS_MAX_UNITS &&
3770: HFS.hfsUnitArray[hfu].insert (file.getPath (), false)) {
3771: if (hfu0 < 0) {
3772: hfu0 = hfu;
3773: }
3774: hfu++;
3775: continue;
3776: }
3777: }
3778: }
3779: reset = false;
3780: }
3781: dtde.dropComplete (true);
3782: if (reset) {
3783: if (fdu0 >= 0) {
3784: mpuReset (0x9070 | fdu0 << 8, -1);
3785: } else if (hdu0 >= 0) {
3786: mpuReset (0x8000 | hdu0 << 8, -1);
3787: } else if (scu0 >= 0) {
3788: mpuReset (0xa000, SPC.SPC_HANDLE_EX + (scu0 << 2));
3789: } else if (hfu0 >= 0) {
3790: HFS.hfsBootUnit = hfu0;
3791: mpuReset (0xa000, HFS.HFS_BOOT_HANDLE);
3792: }
3793: }
3794: return;
3795: }
3796: } catch (UnsupportedFlavorException ufe) {
3797:
3798: } catch (IOException ioe) {
3799:
3800: }
3801: dtde.rejectDrop();
3802: }
3803: });
3804:
3805: }
3806:
3807:
3808:
3809: public static void frmUpdateTitle () {
3810: frmFrame.setTitle ((currentAccelerator == ACCELERATOR_HYBRID ? "X68000 Hybrid" :
3811: currentModel.getName () +
3812: (currentAccelerator == ACCELERATOR_XELLENT30 ? " with Xellent30" :
3813: currentAccelerator == ACCELERATOR_060TURBO ? " with 060turbo" :
3814: currentAccelerator == ACCELERATOR_060TURBOPRO ? " with 060turboPRO" : "")) +
3815: " - " + PRG_TITLE + " version " + PRG_VERSION);
3816: }
3817:
3818:
3819:
3820: public static void frmStart () {
3821:
3822:
3823:
3824:
3825:
3826:
3827:
3828:
3829: ComponentFactory.addListener (
3830: frmFrame,
3831: new WindowAdapter () {
3832: @Override public void windowActivated (WindowEvent we) {
3833: frmIsActive = true;
3834: }
3835: @Override public void windowClosing (WindowEvent we) {
3836: prgTini ();
3837: }
3838: @Override public void windowDeactivated (WindowEvent we) {
3839: frmIsActive = false;
3840:
3841: }
3842: @Override public void windowOpened (WindowEvent we) {
3843: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3844: pnlFixedRate = pnlGetRefreshRate ();
3845: }
3846: }
3847: });
3848:
3849:
3850:
3851:
3852: ComponentFactory.addListener (
3853: frmFrame,
3854: new ComponentAdapter () {
3855: @Override public void componentMoved (ComponentEvent ce) {
3856: Point p = pnlPanel.getLocationOnScreen ();
3857: pnlGlobalX = p.x;
3858: pnlGlobalY = p.y;
3859: }
3860: @Override public void componentResized (ComponentEvent ce) {
3861: Point p = pnlPanel.getLocationOnScreen ();
3862: pnlGlobalX = p.x;
3863: pnlGlobalY = p.y;
3864: }
3865: });
3866:
3867: }
3868:
3869:
3870:
3871:
3872:
3873:
3874: public static BufferedImage clpClipboardImage;
3875: public static String clpClipboardString;
3876: public static Clipboard clpClipboard;
3877: public static Transferable clpImageContents;
3878: public static Transferable clpStringContents;
3879: public static ClipboardOwner clpClipboardOwner;
3880: public static boolean clpIsClipboardOwner;
3881:
3882:
3883:
3884:
3885: public static void clpMake () {
3886: Toolkit toolkit = Toolkit.getDefaultToolkit ();
3887: clpClipboard = null;
3888: try {
3889: clpClipboard = toolkit.getSystemClipboard ();
3890: } catch (Exception e) {
3891: return;
3892: }
3893: clpClipboardImage = null;
3894: clpClipboardString = null;
3895: clpImageContents = new Transferable () {
3896: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
3897: if (flavor == DataFlavor.imageFlavor) {
3898: return clpClipboardImage;
3899: } else {
3900: throw new UnsupportedFlavorException (flavor);
3901: }
3902: }
3903: public DataFlavor[] getTransferDataFlavors () {
3904: return new DataFlavor[] { DataFlavor.imageFlavor };
3905: }
3906: public boolean isDataFlavorSupported (DataFlavor flavor) {
3907: return flavor == DataFlavor.imageFlavor;
3908: }
3909: };
3910: clpStringContents = new Transferable () {
3911: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
3912: if (flavor == DataFlavor.stringFlavor) {
3913: return clpClipboardString;
3914: } else {
3915: throw new UnsupportedFlavorException (flavor);
3916: }
3917: }
3918: public DataFlavor[] getTransferDataFlavors () {
3919: return new DataFlavor[] { DataFlavor.stringFlavor };
3920: }
3921: public boolean isDataFlavorSupported (DataFlavor flavor) {
3922: return flavor == DataFlavor.stringFlavor;
3923: }
3924: };
3925: clpIsClipboardOwner = false;
3926:
3927:
3928: clpClipboardOwner = new ClipboardOwner () {
3929: @Override public void lostOwnership (Clipboard clipboard, Transferable contents) {
3930: clpIsClipboardOwner = false;
3931: }
3932: };
3933:
3934:
3935: clpClipboard.addFlavorListener (new FlavorListener () {
3936: @Override public void flavorsChanged (FlavorEvent fe) {
3937: boolean available = false;
3938: try {
3939: available = clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor);
3940: } catch (IllegalStateException ise) {
3941: }
3942: if (mnbPasteMenuItem != null) {
3943: mnbPasteMenuItem.setEnabled (available);
3944: }
3945: }
3946: });
3947: if (!clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor)) {
3948: if (mnbPasteMenuItem != null) {
3949: mnbPasteMenuItem.setEnabled (false);
3950: }
3951: }
3952: }
3953:
3954:
3955:
3956: public static void clpCopy (String s) {
3957: if (clpClipboard != null && s != null) {
3958: clpClipboardString = s;
3959: try {
3960: clpClipboard.setContents (clpStringContents, clpClipboardOwner);
3961: clpIsClipboardOwner = true;
3962: } catch (Exception e) {
3963: return;
3964: }
3965: }
3966: }
3967:
3968:
3969:
3970:
3971:
3972:
3973:
3974:
3975:
3976:
3977:
3978:
3979:
3980:
3981:
3982:
3983:
3984:
3985:
3986:
3987:
3988:
3989:
3990: public static int xt3DIPSWRequest;
3991: public static int xt3DIPSW;
3992: public static int xt3PortAddress;
3993:
3994:
3995: public static int xt3MemorySizeRequest;
3996: public static int xt3MemorySize;
3997: public static boolean xt3MemoryEnabled;
3998: public static int xt3MemoryPosition;
3999: public static int xt3MemoryStart;
4000: public static final byte[] xt3MemoryArray = new byte[1 << 20];
4001: public static boolean xt3MemorySave;
4002:
4003:
4004: public static int xt3SavedPC;
4005: public static final int[] xt3SavedRn = new int[16];
4006:
4007:
4008: public static void xt3Init () {
4009:
4010:
4011: xt3DIPSWRequest = Math.max (0, Math.min (3, Settings.sgsGetInt ("xt3dipsw")));
4012: xt3DIPSW = xt3DIPSWRequest;
4013:
4014:
4015: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4016:
4017:
4018: int memoryKB = Settings.sgsGetInt ("xt3memorykb");
4019: if (!(memoryKB == 1 << 8 || memoryKB == 1 << 10)) {
4020: memoryKB = 1 << 8;
4021: }
4022: xt3MemorySizeRequest = memoryKB << 10;
4023: xt3MemorySize = xt3MemorySizeRequest;
4024:
4025:
4026: xt3MemoryEnabled = false;
4027:
4028:
4029: xt3MemoryPosition = 11 << 20;
4030:
4031:
4032: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4033:
4034:
4035:
4036: byte[] memoryArray = Settings.sgsGetData ("xt3memorydata");
4037: Arrays.fill (xt3MemoryArray,
4038: (byte) 0);
4039: if (memoryArray.length != 0) {
4040: System.arraycopy (memoryArray, 0,
4041: xt3MemoryArray, 0,
4042: Math.min (memoryArray.length, xt3MemoryArray.length));
4043: if (memoryArray.length < xt3MemoryArray.length) {
4044: Arrays.fill (xt3MemoryArray,
4045: memoryArray.length,
4046: xt3MemoryArray.length,
4047: (byte) 0);
4048: }
4049: }
4050:
4051:
4052: xt3MemorySave = Settings.sgsGetOnOff ("xt3memorysave");
4053:
4054:
4055: xt3SavedPC = 0;
4056:
4057: Arrays.fill (xt3SavedRn, 0);
4058:
4059: xt3Reset ();
4060: }
4061:
4062:
4063: public static void xt3Tini () {
4064:
4065:
4066: Settings.sgsPutInt ("xt3dipsw", xt3DIPSW);
4067:
4068:
4069: Settings.sgsPutInt ("xt3memorykb", xt3MemorySizeRequest >> 10);
4070:
4071:
4072: boolean zero = true;
4073: if (xt3MemorySave) {
4074: for (int i = 0; i < 1 << 20; i++) {
4075: if (xt3MemoryArray[i] != 0) {
4076: zero = false;
4077: break;
4078: }
4079: }
4080: }
4081: Settings.sgsCurrentMap.put ("xt3memorydata",
4082: zero ? "" :
4083: ByteArray.byaEncodeBase64 (ByteArray.byaEncodeGzip (xt3MemoryArray, 0, 1 << 20)));
4084:
4085:
4086: Settings.sgsPutOnOff ("xt3memorysave", xt3MemorySave);
4087:
4088: }
4089:
4090:
4091: public static void xt3Reset () {
4092:
4093:
4094: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4095:
4096:
4097: xt3MemorySize = xt3MemorySizeRequest;
4098:
4099:
4100: xt3MemoryEnabled = false;
4101:
4102:
4103: xt3MemoryPosition = 11 << 20;
4104:
4105:
4106: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4107:
4108:
4109: xt3SavedPC = 0;
4110: Arrays.fill (xt3SavedRn, 0);
4111:
4112: }
4113:
4114:
4115: public static int xt3PortRead () {
4116: return (currentIsSecond ? 4 : 0) | (xt3MemoryEnabled ? 2 : 0) | (xt3MemoryPosition == 11 << 20 ? 0 : 1);
4117: }
4118:
4119:
4120: public static void xt3PortWrite (int d) {
4121: boolean nextIsSecond = (d & 4) != 0;
4122: boolean memoryEnabled = (d & 2) != 0;
4123: int memoryPosition = (d & 1) == 0 ? 11 << 20 : 15 << 20;
4124:
4125: if (xt3MemoryEnabled != memoryEnabled ||
4126: xt3MemoryPosition != memoryPosition) {
4127: if (xt3MemoryEnabled) {
4128: if (xt3MemoryPosition == 11 << 20) {
4129: if (MainMemory.mmrMemorySizeCurrent < 12 << 20) {
4130: busSuper (MemoryMappedDevice.MMD_NUL, (12 << 20) - xt3MemorySize, 12 << 20);
4131: } else {
4132: busUser (MemoryMappedDevice.MMD_MMR, (12 << 20) - xt3MemorySize, 12 << 20);
4133: }
4134: } else {
4135: busSuper (MemoryMappedDevice.MMD_ROM, (16 << 20) - xt3MemorySize, 16 << 20);
4136: }
4137: }
4138: xt3MemoryEnabled = memoryEnabled;
4139: xt3MemoryPosition = memoryPosition;
4140: if (xt3MemoryEnabled) {
4141: if (xt3MemoryPosition == 11 << 20) {
4142: busUser (MemoryMappedDevice.MMD_XTM, (12 << 20) - xt3MemorySize, 12 << 20);
4143: } else {
4144: busUser (MemoryMappedDevice.MMD_XTM, (16 << 20) - xt3MemorySize, 16 << 20);
4145: }
4146: }
4147: }
4148:
4149: if (currentIsSecond != nextIsSecond) {
4150:
4151: if (nextIsSecond) {
4152:
4153:
4154: xt3SavedPC = regPC;
4155: System.arraycopy (regRn, 0, xt3SavedRn, 0, 16);
4156:
4157:
4158: if (mpuTask != null) {
4159: mpuClockLimit = 0L;
4160: System.out.println (Multilingual.mlnJapanese ?
4161: Model.MPU_NAMES[currentFirstMPU] + " を停止します" :
4162: Model.MPU_NAMES[currentFirstMPU] + " stops");
4163: mpuTask.cancel ();
4164: mpuTask = null;
4165: }
4166:
4167:
4168: tmrTimer.schedule (new TimerTask () {
4169: @Override public void run () {
4170:
4171:
4172: currentIsSecond = true;
4173: currentMPU = currentSecondMPU;
4174: mpuSetCurrentClock (specifiedSecondClock);
4175:
4176: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
4177: MC68EC030.m30DivZeroVFlag = false;
4178: }
4179:
4180: RegisterList.drpSetMPU ();
4181: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4182: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4183: MC68060.mmuReset ();
4184:
4185: mpuIgnoreAddressError = true;
4186: fpuBox = fpuMotherboardCoprocessor;
4187: fpuBox.epbReset ();
4188: fpuFPn = fpuBox.epbFPn;
4189: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
4190: mpuSetWait ();
4191:
4192: regSRT1 = regSRT0 = 0;
4193: regSRS = REG_SR_S;
4194: regSRM = 0;
4195: regSRI = REG_SR_I;
4196: regCCR = 0;
4197: Arrays.fill (regRn, 0);
4198:
4199: regRn[15] = MainMemory.mmrRls (0x00000000);
4200: regPC = MainMemory.mmrRls (0x00000004);
4201:
4202: mpuIMR = 0;
4203: mpuIRR = 0;
4204: if (MC68901.MFP_DELAYED_INTERRUPT) {
4205: mpuDIRR = 0;
4206: }
4207: mpuISR = 0;
4208:
4209: mpuStart ();
4210: }
4211: }, TMR_DELAY);
4212:
4213: } else {
4214:
4215:
4216: if (mpuTask != null) {
4217: mpuClockLimit = 0L;
4218: System.out.println (Multilingual.mlnJapanese ? "MC68EC030 を停止します" : "MC68EC030 stops");
4219: mpuTask.cancel ();
4220: mpuTask = null;
4221: }
4222:
4223:
4224: tmrTimer.schedule (new TimerTask () {
4225: @Override public void run () {
4226:
4227:
4228: currentIsSecond = false;
4229: currentMPU = currentFirstMPU;
4230: mpuSetCurrentClock (specifiedFirstClock);
4231:
4232: RegisterList.drpSetMPU ();
4233: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4234: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4235: MC68060.mmuReset ();
4236:
4237: mpuIgnoreAddressError = false;
4238: mpuCacheOn = false;
4239: mpuSetWait ();
4240:
4241: regSRT1 = regSRT0 = 0;
4242: regSRS = REG_SR_S;
4243: regSRM = 0;
4244: regSRI = REG_SR_I;
4245: regCCR = 0;
4246:
4247: regPC = xt3SavedPC;
4248: System.arraycopy (xt3SavedRn, 0, regRn, 0, 16);
4249:
4250: mpuIMR = 0;
4251: mpuIRR = 0;
4252: if (MC68901.MFP_DELAYED_INTERRUPT) {
4253: mpuDIRR = 0;
4254: }
4255: mpuISR = 0;
4256:
4257: mpuStart ();
4258: }
4259: }, TMR_DELAY);
4260:
4261: }
4262: }
4263: }
4264:
4265:
4266:
4267:
4268:
4269:
4270: public static JMenu mdlMenu;
4271:
4272: public static JRadioButtonMenuItem mdlShodaiMenuItem;
4273: public static JRadioButtonMenuItem mdlACEMenuItem;
4274: public static JRadioButtonMenuItem mdlEXPERTMenuItem;
4275: public static JRadioButtonMenuItem mdlPROMenuItem;
4276: public static JRadioButtonMenuItem mdlSUPERMenuItem;
4277: public static JRadioButtonMenuItem mdlXVIMenuItem;
4278: public static JRadioButtonMenuItem mdlXellent30MenuItem;
4279: public static JRadioButtonMenuItem mdlCompactMenuItem;
4280: public static JRadioButtonMenuItem mdlHybridMenuItem;
4281: public static JRadioButtonMenuItem mdl060turboPROMenuItem;
4282: public static JRadioButtonMenuItem mdlX68030MenuItem;
4283: public static JRadioButtonMenuItem mdl030CompactMenuItem;
4284: public static JRadioButtonMenuItem mdl060turboMenuItem;
4285: public static JCheckBoxMenuItem mdlMC68010MenuItem;
4286:
4287: public static JMenu coproFPUMenu;
4288:
4289:
4290: public static final int ACCELERATOR_HYBRID = 1;
4291: public static final int ACCELERATOR_XELLENT30 = 2;
4292: public static final int ACCELERATOR_060TURBO = 3;
4293: public static final int ACCELERATOR_060TURBOPRO = 4;
4294: public static final double MHZ_HYBRID_VALUE = 100.0 / 3.0;
4295: public static final String MHZ_HYBRID_STRING = "33.3";
4296: public static final double MHZ_060TURBO_VALUE = 50.0;
4297: public static final String MHZ_060TURBO_STRING = "50";
4298:
4299:
4300:
4301: public static Model specifiedModel;
4302: public static int specifiedAccelerator;
4303: public static boolean mpu010;
4304:
4305: public static boolean specifiedIsSecond;
4306: public static int specifiedFirstMPU;
4307: public static int specifiedSecondMPU;
4308: public static int specifiedMPU;
4309:
4310: public static double specifiedFirstClock;
4311: public static double specifiedSecondClock;
4312: public static double specifiedClock;
4313:
4314: public static int specifiedCopro0;
4315: public static int specifiedCopro1;
4316: public static int specifiedCopro2;
4317: public static int specifiedOnchipFPU;
4318:
4319:
4320:
4321: public static Model currentModel;
4322: public static int currentAccelerator;
4323:
4324: public static boolean currentIsSecond;
4325: public static int currentFirstMPU;
4326: public static int currentSecondMPU;
4327: public static int currentMPU;
4328:
4329:
4330: public static int currentCopro0;
4331: public static int currentCopro1;
4332: public static int currentCopro2;
4333: public static int currentOnchipFPU;
4334:
4335:
4336:
4337: public static void mdlInit () {
4338:
4339:
4340: specifiedModel = Model.COMPACT;
4341: specifiedAccelerator = ACCELERATOR_HYBRID;
4342: mpu010 = Settings.sgsGetOnOff ("mpu010");
4343: {
4344: String paramModel = Settings.sgsGetString ("model");
4345: switch (paramModel.toLowerCase ()) {
4346: case "":
4347: case "none":
4348: case "hybrid":
4349: specifiedModel = Model.COMPACT;
4350: specifiedAccelerator = ACCELERATOR_HYBRID;
4351: break;
4352: case "xellent30":
4353: specifiedModel = Model.XVI;
4354: specifiedAccelerator = ACCELERATOR_XELLENT30;
4355: break;
4356: case "060turbo":
4357: specifiedModel = Model.X68030;
4358: specifiedAccelerator = ACCELERATOR_060TURBO;
4359: break;
4360: case "060turbopro":
4361: specifiedModel = Model.PRO;
4362: specifiedAccelerator = ACCELERATOR_060TURBOPRO;
4363: break;
4364: default:
4365: Model model = Model.fromTypeOrSynonym (paramModel);
4366: if (model != null) {
4367: specifiedModel = model;
4368: specifiedAccelerator = 0;
4369: } else {
4370: System.out.println (Multilingual.mlnJapanese ?
4371: paramModel + " は不明な機種です" :
4372: paramModel + " is unknown model");
4373: specifiedModel = Model.COMPACT;
4374: specifiedAccelerator = ACCELERATOR_HYBRID;
4375: }
4376: }
4377: }
4378:
4379: specifiedIsSecond = false;
4380: specifiedFirstMPU = specifiedModel.getMPU ();
4381: specifiedSecondMPU = Model.MPU_MC68EC030;
4382: {
4383: String[] paramMPUs = Settings.sgsGetString ("mpu").split (",");
4384: for (int i = 0; i < 2; i++) {
4385: int mpu = 0;
4386: String paramMPU = i < paramMPUs.length ? paramMPUs[i] : "";
4387: switch (paramMPU) {
4388: case "":
4389: case "none":
4390: case "-1":
4391: mpu = (i == 0 ?
4392: (specifiedAccelerator == ACCELERATOR_060TURBO ||
4393: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4394: specifiedModel.getMPU ()) :
4395: Model.MPU_MC68EC030);
4396: break;
4397: case "0":
4398: case "68000":
4399: case "mc68000":
4400: mpu = Model.MPU_MC68000;
4401: break;
4402: case "1":
4403: case "68010":
4404: case "mc68010":
4405: mpu = Model.MPU_MC68010;
4406: break;
4407:
4408:
4409:
4410:
4411:
4412: case "3":
4413: case "68ec030":
4414: case "mc68ec030":
4415: mpu = Model.MPU_MC68EC030;
4416: break;
4417:
4418:
4419:
4420:
4421:
4422:
4423:
4424:
4425:
4426:
4427:
4428:
4429:
4430:
4431:
4432:
4433:
4434: case "6":
4435: case "68060":
4436: case "mc68060":
4437: mpu = Model.MPU_MC68060;
4438: break;
4439: default:
4440: Model model = Model.fromTypeOrSynonym (paramMPU);
4441: if (model != null) {
4442: mpu = model.getMPU ();
4443: } else {
4444: System.out.println (Multilingual.mlnJapanese ?
4445: paramMPU + " は不明な MPU です" :
4446: paramMPU + " is unknown MPU");
4447: mpu = specifiedModel.getMPU ();
4448: }
4449: }
4450: if (i == 0) {
4451: specifiedFirstMPU = mpu;
4452: } else {
4453: specifiedSecondMPU = mpu;
4454: }
4455: }
4456: }
4457: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
4458:
4459: specifiedFirstClock = specifiedModel.getClock ();
4460: specifiedSecondClock = specifiedFirstClock * 2.0;
4461: {
4462: String[] paramClocks = Settings.sgsGetString ("clock").split (",");
4463: for (int i = 0; i < 2; i++) {
4464: double clock = 0.0;
4465: String paramClock = i < paramClocks.length ? paramClocks[i] : "";
4466: switch (paramClock.toLowerCase ()) {
4467: case "":
4468: case "none":
4469: case "-1":
4470: clock = (i == 0 ?
4471: (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4472: specifiedAccelerator == ACCELERATOR_060TURBO ||
4473: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4474: specifiedModel.getClock ()) :
4475: specifiedFirstClock * 2.0);
4476: break;
4477: case "hybrid":
4478: clock = MHZ_HYBRID_VALUE;
4479: break;
4480: case "060turbo":
4481: case "060turbopro":
4482: clock = MHZ_060TURBO_VALUE;
4483: break;
4484: case "16.7":
4485: case "xellent30":
4486: clock = 50.0 / 3.0;
4487: break;
4488: case "33.3":
4489: clock = 100.0 / 3.0;
4490: break;
4491: case "66.7":
4492: clock = 200.0 / 3.0;
4493: break;
4494: default:
4495: if (paramClock.matches ("^(?:" +
4496: "[-+]?" +
4497: "(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)" +
4498: "(?:[Ee][-+]?[0-9]+)?" +
4499: ")$")) {
4500: double d = Double.parseDouble (paramClock);
4501: if (1.0 <= d && d <= 1000.0) {
4502: clock = d;
4503: }
4504: } else {
4505: System.out.println (Multilingual.mlnJapanese ?
4506: paramClock + " は不明な動作周波数です" :
4507: paramClock + " is unknown clock frequency");
4508: clock = specifiedModel.getClock ();
4509: }
4510: }
4511: if (i == 0) {
4512: specifiedFirstClock = clock;
4513: } else {
4514: specifiedSecondClock = clock;
4515: }
4516: }
4517: }
4518: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4519:
4520: specifiedCopro0 = 15 & Settings.sgsGetInt ("copro0", 2);
4521: if (!((7 & specifiedCopro0) == 0 ||
4522: (7 & specifiedCopro0) == 1 ||
4523: (7 & specifiedCopro0) == 2 ||
4524: (7 & specifiedCopro0) == 7)) {
4525: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4526: }
4527: specifiedCopro1 = 15 & Settings.sgsGetInt ("copro1", 2);
4528: if (!((7 & specifiedCopro1) == 0 ||
4529: (7 & specifiedCopro1) == 1 ||
4530: (7 & specifiedCopro1) == 2 ||
4531: (7 & specifiedCopro1) == 7)) {
4532: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4533: }
4534: specifiedCopro2 = 15 & Settings.sgsGetInt ("copro2", 2);
4535: if (!((7 & specifiedCopro2) == 0 ||
4536: (7 & specifiedCopro2) == 1 ||
4537: (7 & specifiedCopro2) == 2 ||
4538: (7 & specifiedCopro2) == 7)) {
4539: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4540: }
4541: specifiedOnchipFPU = 15 & Settings.sgsGetInt ("onchipfpu", 7);
4542: if (!((7 & specifiedOnchipFPU) == 0 ||
4543: (7 & specifiedOnchipFPU) == 6 ||
4544: (7 & specifiedOnchipFPU) == 7)) {
4545: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4546: }
4547:
4548:
4549: currentModel = specifiedModel;
4550: currentAccelerator = specifiedAccelerator;
4551:
4552: currentIsSecond = specifiedIsSecond;
4553: currentFirstMPU = specifiedFirstMPU;
4554: currentSecondMPU = specifiedSecondMPU;
4555: currentMPU = specifiedMPU;
4556:
4557:
4558: currentCopro0 = specifiedCopro0;
4559: currentCopro1 = specifiedCopro1;
4560: currentCopro2 = specifiedCopro2;
4561: currentOnchipFPU = specifiedOnchipFPU;
4562:
4563:
4564: mpuUtilOn = Settings.sgsGetOnOff ("util");
4565: mpuUtilRatio = fmtParseInt (Settings.sgsGetString ("ratio"), 0, 1, 100, 100);
4566:
4567: mpuArbFreqMHz = fmtParseInt (Settings.sgsGetString ("mhz"), 0, 1, 1000, 100);
4568: if (mpuUtilOn) {
4569: mpuArbFreqOn = false;
4570: } else {
4571: mpuArbFreqOn = !(specifiedClock == 10.0 ||
4572: specifiedClock == 50.0 / 3.0 ||
4573: specifiedClock == 25.0 ||
4574: specifiedClock == 100.0 / 3.0 ||
4575: specifiedClock == 50.0 ||
4576: specifiedClock == 200.0 / 3.0 ||
4577: specifiedClock == 75.0 ||
4578: specifiedClock == 100.0);
4579: if (mpuArbFreqOn) {
4580: mpuArbFreqMHz = (int) specifiedClock;
4581: }
4582: }
4583:
4584:
4585: mpuROMWaitCycles = 0;
4586: mpuRAMWaitCycles = 0;
4587: mpuCacheOn = false;
4588:
4589: mpuNoWaitTime.ram = 0;
4590: mpuNoWaitTime.gvram = 0;
4591: mpuNoWaitTime.tvram = 0;
4592: mpuNoWaitTime.crtc = 0;
4593: mpuNoWaitTime.palet = 0;
4594: mpuNoWaitTime.vicon = 0;
4595: mpuNoWaitTime.dmac = 0;
4596: mpuNoWaitTime.mfp = 0;
4597: mpuNoWaitTime.rtc = 0;
4598: mpuNoWaitTime.prnport = 0;
4599: mpuNoWaitTime.sysport = 0;
4600: mpuNoWaitTime.opm = 0;
4601: mpuNoWaitTime.adpcm = 0;
4602: mpuNoWaitTime.fdc = 0;
4603: mpuNoWaitTime.fdd = 0;
4604: mpuNoWaitTime.hdc = 0;
4605: mpuNoWaitTime.scc = 0;
4606: mpuNoWaitTime.ppi = 0;
4607: mpuNoWaitTime.ioi = 0;
4608: mpuNoWaitTime.sprc = 0;
4609: mpuNoWaitTime.sram = 0;
4610: mpuNoWaitTime.rom = 0;
4611: mpuNoWaitTime.ramlong = mpuNoWaitTime.ram << 1;
4612: mpuNoWaitTime.romlong = mpuNoWaitTime.rom << 1;
4613:
4614: dmaNoWaitTime.ram = 0;
4615: dmaNoWaitTime.gvram = 0;
4616: dmaNoWaitTime.tvram = 0;
4617: dmaNoWaitTime.crtc = 0;
4618: dmaNoWaitTime.palet = 0;
4619: dmaNoWaitTime.vicon = 0;
4620: dmaNoWaitTime.dmac = 0;
4621: dmaNoWaitTime.mfp = 0;
4622: dmaNoWaitTime.rtc = 0;
4623: dmaNoWaitTime.prnport = 0;
4624: dmaNoWaitTime.sysport = 0;
4625: dmaNoWaitTime.opm = 0;
4626: dmaNoWaitTime.adpcm = 0;
4627: dmaNoWaitTime.fdc = 0;
4628: dmaNoWaitTime.fdd = 0;
4629: dmaNoWaitTime.hdc = 0;
4630: dmaNoWaitTime.scc = 0;
4631: dmaNoWaitTime.ppi = 0;
4632: dmaNoWaitTime.ioi = 0;
4633: dmaNoWaitTime.sprc = 0;
4634: dmaNoWaitTime.sram = 0;
4635: dmaNoWaitTime.rom = 0;
4636: dmaNoWaitTime.ramlong = dmaNoWaitTime.ram << 1;
4637: dmaNoWaitTime.romlong = dmaNoWaitTime.rom << 1;
4638:
4639:
4640: busWaitCyclesRequest = Settings.sgsGetOnOff ("waitcycles");
4641: busWaitCycles = busWaitCyclesRequest;
4642: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
4643:
4644: }
4645:
4646: public static void mdlTini () {
4647:
4648: Settings.sgsPutString ("model",
4649: specifiedAccelerator == ACCELERATOR_HYBRID ? "Hybrid" :
4650: specifiedAccelerator == ACCELERATOR_XELLENT30 ? "Xellent30" :
4651: specifiedAccelerator == ACCELERATOR_060TURBO ? "060turbo" :
4652: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? "060turboPRO" :
4653: specifiedModel.getSynonym () != null ? specifiedModel.getSynonym () :
4654: specifiedModel.getType ());
4655: Settings.sgsPutOnOff ("mpu010", mpu010);
4656:
4657:
4658: int defaultFirstMPU = (specifiedAccelerator == ACCELERATOR_060TURBO ||
4659: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4660: specifiedModel.getMPU ());
4661: int defaultSecondMPU = Model.MPU_MC68EC030;
4662: Settings.sgsPutString ("mpu",
4663: (specifiedFirstMPU == defaultFirstMPU ? "" :
4664: Model.mpuNameOf (specifiedFirstMPU)) +
4665: (specifiedSecondMPU == defaultSecondMPU ? "" :
4666: "," + Model.mpuNameOf (specifiedSecondMPU)));
4667:
4668:
4669:
4670:
4671: double defaultFirstClock = (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4672: specifiedAccelerator == ACCELERATOR_060TURBO ||
4673: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4674: specifiedModel.getClock ());
4675: double defaultSecondClock = defaultFirstClock * 2.0;
4676: Settings.sgsPutString ("clock",
4677: (specifiedFirstClock == defaultFirstClock ? "" :
4678: specifiedFirstClock == 50.0 / 3.0 ? "16.7" :
4679: specifiedFirstClock == 100.0 / 3.0 ? "33.3" :
4680: specifiedFirstClock == 200.0 / 3.0 ? "66.7" :
4681: String.valueOf ((int) specifiedFirstClock)) +
4682: (specifiedSecondClock == defaultSecondClock ? "" :
4683: "," + (specifiedSecondClock == 50.0 / 3.0 ? "16.7" :
4684: specifiedSecondClock == 100.0 / 3.0 ? "33.3" :
4685: specifiedSecondClock == 200.0 / 3.0 ? "66.7" :
4686: String.valueOf ((int) specifiedSecondClock))));
4687:
4688: Settings.sgsPutInt ("copro0", specifiedCopro0);
4689: Settings.sgsPutInt ("copro1", specifiedCopro1);
4690: Settings.sgsPutInt ("copro2", specifiedCopro2);
4691: Settings.sgsPutInt ("onchipfpu", specifiedOnchipFPU);
4692:
4693: Settings.sgsPutOnOff ("util",
4694: mpuUtilOn);
4695: Settings.sgsPutString ("ratio",
4696: String.valueOf (mpuUtilRatio));
4697:
4698: Settings.sgsPutString ("mhz",
4699: String.valueOf (mpuArbFreqMHz));
4700:
4701: Settings.sgsPutOnOff ("waitcycles", busWaitCyclesRequest);
4702: }
4703:
4704: public static void mdlMakeMenu () {
4705:
4706:
4707: ActionListener listener = new ActionListener () {
4708: @Override public void actionPerformed (ActionEvent ae) {
4709: Object source = ae.getSource ();
4710: switch (ae.getActionCommand ()) {
4711: case "X68000 (10MHz)":
4712: mdlRequestModel (Model.SHODAI, 0);
4713: mpuReset (-1, -1);
4714: break;
4715: case "X68000 ACE (10MHz)":
4716: mdlRequestModel (Model.ACE, 0);
4717: mpuReset (-1, -1);
4718: break;
4719: case "X68000 EXPERT (10MHz)":
4720: mdlRequestModel (Model.EXPERT, 0);
4721: mpuReset (-1, -1);
4722: break;
4723: case "X68000 PRO (10MHz)":
4724: mdlRequestModel (Model.PRO, 0);
4725: mpuReset (-1, -1);
4726: break;
4727: case "X68000 SUPER (10MHz)":
4728: mdlRequestModel (Model.SUPER, 0);
4729: mpuReset (-1, -1);
4730: break;
4731: case "X68000 XVI (16.7MHz)":
4732: mdlRequestModel (Model.XVI, 0);
4733: mpuReset (-1, -1);
4734: break;
4735: case "X68000 Compact (16.7MHz)":
4736: mdlRequestModel (Model.COMPACT, 0);
4737: mpuReset (-1, -1);
4738: break;
4739:
4740: case "X68030 (25MHz)":
4741: mdlRequestModel (Model.X68030, 0);
4742: mpuReset (-1, -1);
4743: break;
4744: case "X68030 Compact (25MHz)":
4745: mdlRequestModel (Model.X68030COMPACT, 0);
4746: mpuReset (-1, -1);
4747: break;
4748:
4749: case "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)":
4750: mdlRequestModel (Model.COMPACT, ACCELERATOR_HYBRID);
4751: mpuReset (-1, -1);
4752: break;
4753: case "Xellent30 (33.3MHz)":
4754: mdlRequestModel (Model.XVI, ACCELERATOR_XELLENT30);
4755: mpuReset (-1, -1);
4756: break;
4757: case "060turbo (" + MHZ_060TURBO_STRING + "MHz)":
4758: mdlRequestModel (Model.X68030, ACCELERATOR_060TURBO);
4759: mpuReset (-1, -1);
4760: break;
4761: case "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)":
4762: mdlRequestModel (Model.PRO, ACCELERATOR_060TURBOPRO);
4763: mpuReset (-1, -1);
4764: break;
4765:
4766: case "MC68010":
4767: mpu010 = ((JCheckBoxMenuItem) source).isSelected ();
4768: break;
4769:
4770: }
4771: }
4772: };
4773:
4774:
4775: ButtonGroup modelGroup = new ButtonGroup ();
4776: mdlMenu = Multilingual.mlnText (
4777: ComponentFactory.createMenu (
4778: "Change the model and reset",
4779: mdlShodaiMenuItem = ComponentFactory.createRadioButtonMenuItem (
4780: modelGroup,
4781: specifiedModel == Model.SHODAI,
4782: "X68000 (10MHz)",
4783: listener),
4784: mdlACEMenuItem = ComponentFactory.createRadioButtonMenuItem (
4785: modelGroup,
4786: specifiedModel == Model.ACE,
4787: "X68000 ACE (10MHz)",
4788: listener),
4789: mdlEXPERTMenuItem = ComponentFactory.createRadioButtonMenuItem (
4790: modelGroup,
4791: specifiedModel == Model.EXPERT,
4792: "X68000 EXPERT (10MHz)",
4793: listener),
4794: mdlPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
4795: modelGroup,
4796: specifiedModel == Model.PRO && specifiedAccelerator == 0,
4797: "X68000 PRO (10MHz)",
4798: listener),
4799: mdlSUPERMenuItem = ComponentFactory.createRadioButtonMenuItem (
4800: modelGroup,
4801: specifiedModel == Model.SUPER,
4802: "X68000 SUPER (10MHz)",
4803: listener),
4804: mdlXVIMenuItem = ComponentFactory.createRadioButtonMenuItem (
4805: modelGroup,
4806: specifiedModel == Model.XVI && specifiedAccelerator == 0,
4807: "X68000 XVI (16.7MHz)",
4808: listener),
4809: mdlCompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
4810: modelGroup,
4811: specifiedModel == Model.COMPACT && specifiedAccelerator == 0,
4812: "X68000 Compact (16.7MHz)",
4813: listener),
4814:
4815: ComponentFactory.createHorizontalSeparator (),
4816:
4817: mdlX68030MenuItem = ComponentFactory.createRadioButtonMenuItem (
4818: modelGroup,
4819: specifiedModel == Model.X68030 && specifiedAccelerator == 0,
4820: "X68030 (25MHz)",
4821: listener),
4822: mdl030CompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
4823: modelGroup,
4824: specifiedModel == Model.X68030COMPACT,
4825: "X68030 Compact (25MHz)",
4826: listener),
4827:
4828: ComponentFactory.createHorizontalSeparator (),
4829:
4830: mdlHybridMenuItem = ComponentFactory.createRadioButtonMenuItem (
4831: modelGroup,
4832: specifiedModel == Model.COMPACT && specifiedAccelerator == ACCELERATOR_HYBRID,
4833: "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)",
4834: listener),
4835: mdlXellent30MenuItem = ComponentFactory.createRadioButtonMenuItem (
4836: modelGroup,
4837: specifiedModel == Model.XVI && specifiedAccelerator == ACCELERATOR_XELLENT30,
4838: "Xellent30 (33.3MHz)",
4839: listener),
4840: mdl060turboMenuItem = ComponentFactory.createRadioButtonMenuItem (
4841: modelGroup,
4842: specifiedModel == Model.X68030 && specifiedAccelerator == ACCELERATOR_060TURBO,
4843: "060turbo (" + MHZ_060TURBO_STRING + "MHz)",
4844: listener),
4845: mdl060turboPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
4846: modelGroup,
4847: specifiedModel == Model.PRO && specifiedAccelerator == ACCELERATOR_060TURBOPRO,
4848: "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)",
4849: listener),
4850:
4851: ComponentFactory.createHorizontalSeparator (),
4852:
4853: mdlMC68010MenuItem = ComponentFactory.createCheckBoxMenuItem (
4854: mpu010,
4855: "MC68010",
4856: listener)
4857: ),
4858: "ja", "機種を変更してリセット");
4859:
4860:
4861: ActionListener copro0Listener = new ActionListener () {
4862: @Override public void actionPerformed (ActionEvent ae) {
4863: String command = ae.getActionCommand ();
4864: switch (command) {
4865: case "Not installed":
4866: specifiedCopro0 = (8 & specifiedCopro0) | 0;
4867: break;
4868: case "MC68881":
4869: specifiedCopro0 = (8 & specifiedCopro0) | 1;
4870: break;
4871: case "MC68882":
4872: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4873: break;
4874: case "Full specification":
4875: specifiedCopro0 = (8 & specifiedCopro0) | 7;
4876: break;
4877: case "Extended precision (19 digits)":
4878: specifiedCopro0 = 0 | (7 & specifiedCopro0);
4879: break;
4880: case "Triple precision (24 digits)":
4881: specifiedCopro0 = 8 | (7 & specifiedCopro0);
4882: break;
4883: default:
4884: System.out.println ("unknown action command " + command);
4885: }
4886: }
4887: };
4888:
4889: ActionListener copro1Listener = new ActionListener () {
4890: @Override public void actionPerformed (ActionEvent ae) {
4891: String command = ae.getActionCommand ();
4892: switch (command) {
4893: case "Not installed":
4894: specifiedCopro1 = (8 & specifiedCopro1) | 0;
4895: break;
4896: case "MC68881":
4897: specifiedCopro1 = (8 & specifiedCopro1) | 1;
4898: break;
4899: case "MC68882":
4900: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4901: break;
4902: case "Full specification":
4903: specifiedCopro1 = (8 & specifiedCopro1) | 7;
4904: break;
4905: case "Extended precision (19 digits)":
4906: specifiedCopro1 = 0 | (7 & specifiedCopro1);
4907: break;
4908: case "Triple precision (24 digits)":
4909: specifiedCopro1 = 8 | (7 & specifiedCopro1);
4910: break;
4911: default:
4912: System.out.println ("unknown action command " + command);
4913: }
4914: }
4915: };
4916:
4917: ActionListener copro2Listener = new ActionListener () {
4918: @Override public void actionPerformed (ActionEvent ae) {
4919: String command = ae.getActionCommand ();
4920: switch (command) {
4921: case "Not installed":
4922: specifiedCopro2 = (8 & specifiedCopro2) | 0;
4923: break;
4924: case "MC68881":
4925: specifiedCopro2 = (8 & specifiedCopro2) | 1;
4926: break;
4927: case "MC68882":
4928: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4929: break;
4930: case "Full specification":
4931: specifiedCopro2 = (8 & specifiedCopro2) | 7;
4932: break;
4933: case "Extended precision (19 digits)":
4934: specifiedCopro2 = 0 | (7 & specifiedCopro2);
4935: break;
4936: case "Triple precision (24 digits)":
4937: specifiedCopro2 = 8 | (7 & specifiedCopro2);
4938: break;
4939: default:
4940: System.out.println ("unknown action command " + command);
4941: }
4942: }
4943: };
4944:
4945: ActionListener onchipFPUListener = new ActionListener () {
4946: @Override public void actionPerformed (ActionEvent ae) {
4947: String command = ae.getActionCommand ();
4948: switch (command) {
4949: case "Not installed":
4950: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 0;
4951: break;
4952: case "MC68060":
4953: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 6;
4954: break;
4955: case "Full specification":
4956: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4957: break;
4958: case "Extended precision (19 digits)":
4959: specifiedOnchipFPU = 0 | (7 & specifiedOnchipFPU);
4960: break;
4961: case "Triple precision (24 digits)":
4962: specifiedOnchipFPU = 8 | (7 & specifiedOnchipFPU);
4963: break;
4964: default:
4965: System.out.println ("unknown action command " + command);
4966: }
4967: }
4968: };
4969:
4970: ButtonGroup copro00Group = new ButtonGroup ();
4971: ButtonGroup copro01Group = new ButtonGroup ();
4972: ButtonGroup copro10Group = new ButtonGroup ();
4973: ButtonGroup copro11Group = new ButtonGroup ();
4974: ButtonGroup copro20Group = new ButtonGroup ();
4975: ButtonGroup copro21Group = new ButtonGroup ();
4976: ButtonGroup onchipFPU0Group = new ButtonGroup ();
4977: ButtonGroup onchipFPU1Group = new ButtonGroup ();
4978:
4979: coproFPUMenu = Multilingual.mlnText (
4980: ComponentFactory.createMenu (
4981: "Coprocessor and on-chip FPU",
4982:
4983: Multilingual.mlnText (
4984: ComponentFactory.createMenu (
4985: "Motherboard coprocessor",
4986: Multilingual.mlnText (
4987: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 0, "Not installed", copro0Listener),
4988: "ja", "なし"),
4989: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 1, "MC68881", copro0Listener),
4990: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 2, "MC68882", copro0Listener),
4991: Multilingual.mlnText (
4992: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 7, "Full specification", copro0Listener),
4993: "ja", "フルスペック"),
4994: ComponentFactory.createHorizontalSeparator (),
4995: Multilingual.mlnText (
4996: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) == 0, "Extended precision (19 digits)", copro0Listener),
4997: "ja", "拡張精度 (19 桁)"),
4998: Multilingual.mlnText (
4999: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) != 0, "Triple precision (24 digits)", copro0Listener),
5000: "ja", "三倍精度 (24 桁)")),
5001: "ja", "マザーボードコプロセッサ"),
5002:
5003: Multilingual.mlnText (
5004: ComponentFactory.createMenu (
5005: "Extension coprocessor #1",
5006: Multilingual.mlnText (
5007: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 0, "Not installed", copro1Listener),
5008: "ja", "なし"),
5009: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 1, "MC68881", copro1Listener),
5010: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 2, "MC68882", copro1Listener),
5011: Multilingual.mlnText (
5012: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 7, "Full specification", copro1Listener),
5013: "ja", "フルスペック"),
5014: ComponentFactory.createHorizontalSeparator (),
5015: Multilingual.mlnText (
5016: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) == 0, "Extended precision (19 digits)", copro1Listener),
5017: "ja", "拡張精度 (19 桁)"),
5018: Multilingual.mlnText (
5019: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) != 0, "Triple precision (24 digits)", copro1Listener),
5020: "ja", "三倍精度 (24 桁)")),
5021: "ja", "拡張コプロセッサ #1"),
5022:
5023: Multilingual.mlnText (
5024: ComponentFactory.createMenu (
5025: "Extension coprocessor #2",
5026: Multilingual.mlnText (
5027: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 0, "Not installed", copro2Listener),
5028: "ja", "なし"),
5029: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 1, "MC68881", copro2Listener),
5030: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 2, "MC68882", copro2Listener),
5031: Multilingual.mlnText (
5032: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 7, "Full specification", copro2Listener),
5033: "ja", "フルスペック"),
5034: ComponentFactory.createHorizontalSeparator (),
5035: Multilingual.mlnText (
5036: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) == 0, "Extended precision (19 digits)", copro2Listener),
5037: "ja", "拡張精度 (19 桁)"),
5038: Multilingual.mlnText (
5039: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) != 0, "Triple precision (24 digits)", copro2Listener),
5040: "ja", "三倍精度 (24 桁)")),
5041: "ja", "拡張コプロセッサ #2"),
5042:
5043: Multilingual.mlnText (
5044: ComponentFactory.createMenu (
5045: "On-chip FPU",
5046: Multilingual.mlnText (
5047: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 0, "Not installed", onchipFPUListener),
5048: "ja", "なし"),
5049: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 6, "MC68060", onchipFPUListener),
5050: Multilingual.mlnText (
5051: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 7, "Full specification", onchipFPUListener),
5052: "ja", "フルスペック"),
5053: ComponentFactory.createHorizontalSeparator (),
5054: Multilingual.mlnText (
5055: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) == 0, "Extended precision (19 digits)", onchipFPUListener),
5056: "ja", "拡張精度 (19 桁)"),
5057: Multilingual.mlnText (
5058: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) != 0, "Triple precision (24 digits)", onchipFPUListener),
5059: "ja", "三倍精度 (24 桁)")),
5060: "ja", "オンチップ FPU")),
5061: "ja", "コプロセッサとオンチップ FPU");
5062:
5063: }
5064:
5065: public static void mdlRequestModel (Model model, int accelerator) {
5066: specifiedModel = model;
5067: specifiedAccelerator = accelerator;
5068:
5069: specifiedIsSecond = false;
5070: specifiedFirstMPU = specifiedModel.getMPU ();
5071: specifiedSecondMPU = Model.MPU_MC68EC030;
5072: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
5073: specifiedFirstClock = specifiedModel.getClock ();
5074: specifiedSecondClock = specifiedFirstClock * 2.0;
5075: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5076:
5077: switch (accelerator) {
5078: case ACCELERATOR_HYBRID:
5079: specifiedFirstClock = MHZ_HYBRID_VALUE;
5080: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5081: break;
5082: case ACCELERATOR_XELLENT30:
5083: break;
5084: case ACCELERATOR_060TURBO:
5085: case ACCELERATOR_060TURBOPRO:
5086: specifiedFirstMPU = Model.MPU_MC68060;
5087: specifiedFirstClock = MHZ_060TURBO_VALUE;
5088: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5089: }
5090:
5091: mpuUtilOn = false;
5092: mpuArbFreqOn = false;
5093: mpuSetCurrentClock (specifiedClock);
5094:
5095: if (accelerator == ACCELERATOR_HYBRID) {
5096: mdlHybridMenuItem.setSelected (true);
5097: } else if (accelerator == ACCELERATOR_XELLENT30) {
5098: mdlXellent30MenuItem.setSelected (true);
5099: } else if (accelerator == ACCELERATOR_060TURBO) {
5100: mdl060turboMenuItem.setSelected (true);
5101: } else if (accelerator == ACCELERATOR_060TURBOPRO) {
5102: mdl060turboPROMenuItem.setSelected (true);
5103: } else if (specifiedModel == Model.SHODAI) {
5104: mdlShodaiMenuItem.setSelected (true);
5105: } else if (specifiedModel == Model.ACE) {
5106: mdlACEMenuItem.setSelected (true);
5107: } else if (specifiedModel == Model.EXPERT) {
5108: mdlEXPERTMenuItem.setSelected (true);
5109: } else if (specifiedModel == Model.PRO) {
5110: mdlPROMenuItem.setSelected (true);
5111: } else if (specifiedModel == Model.SUPER) {
5112: mdlSUPERMenuItem.setSelected (true);
5113: } else if (specifiedModel == Model.XVI) {
5114: mdlXVIMenuItem.setSelected (true);
5115: } else if (specifiedModel == Model.COMPACT) {
5116: mdlCompactMenuItem.setSelected (true);
5117: } else if (specifiedModel == Model.X68030) {
5118: mdlX68030MenuItem.setSelected (true);
5119: } else if (specifiedModel == Model.X68030COMPACT) {
5120: mdl030CompactMenuItem.setSelected (true);
5121: }
5122:
5123:
5124: HDC.hdcSASIMenuItem.setSelected (!currentModel.isSCSI ());
5125: SPC.spcSCSIINMenuItem.setSelected (currentModel.isSCSI ());
5126: }
5127:
5128:
5129:
5130:
5131:
5132:
5133:
5134: public static final boolean MPU_INLINE_EXCEPTION = true;
5135: public static final boolean MPU_COMPOUND_POSTINCREMENT = false;
5136:
5137: public static final boolean MPU_SWITCH_MISC_OPCODE = false;
5138: public static final boolean MPU_SWITCH_BCC_CONDITION = false;
5139: public static final boolean MPU_SWITCH_BCC_OFFSET = false;
5140: public static final boolean MPU_SWITCH_SCC_CONDITION = true;
5141:
5142: public static final boolean MPU_OMIT_EXTRA_READ = false;
5143: public static final boolean MPU_OMIT_OFFSET_READ = false;
5144:
5145:
5146:
5147:
5148: public static final long FAR_FUTURE = 0x7fffffffffffffffL;
5149:
5150:
5151:
5152:
5153:
5154:
5155:
5156:
5157: public static final int REG_SR_T1 = 0b10000000_00000000;
5158: public static final int REG_SR_T0 = 0b01000000_00000000;
5159:
5160:
5161:
5162:
5163:
5164:
5165: public static final int REG_SR_S = 0b00100000_00000000;
5166: public static final int REG_SR_M = 0b00010000_00000000;
5167:
5168: public static final int REG_SR_I = 0b00000111_00000000;
5169:
5170:
5171: public static final int REG_CCR_X = 0b00000000_00010000;
5172: public static final int REG_CCR_N = 0b00000000_00001000;
5173: public static final int REG_CCR_Z = 0b00000000_00000100;
5174: public static final int REG_CCR_V = 0b00000000_00000010;
5175: public static final int REG_CCR_C = 0b00000000_00000001;
5176: public static final int REG_CCR_MASK = REG_CCR_X | REG_CCR_N | REG_CCR_Z | REG_CCR_V | REG_CCR_C;
5177:
5178: public static char[] REG_CCRXMAP = "00000000000000001111111111111111".toCharArray ();
5179: public static char[] REG_CCRNMAP = "00000000111111110000000011111111".toCharArray ();
5180: public static char[] REG_CCRZMAP = "00001111000011110000111100001111".toCharArray ();
5181: public static char[] REG_CCRVMAP = "00110011001100110011001100110011".toCharArray ();
5182: public static char[] REG_CCRCMAP = "01010101010101010101010101010101".toCharArray ();
5183:
5184:
5185:
5186: public static final int MPU_IOI_INTERRUPT_LEVEL = 1;
5187: public static final int MPU_EB2_INTERRUPT_LEVEL = 2;
5188: public static final int MPU_DMA_INTERRUPT_LEVEL = 3;
5189: public static final int MPU_SCC_INTERRUPT_LEVEL = 5;
5190: public static final int MPU_MFP_INTERRUPT_LEVEL = 6;
5191: public static final int MPU_SYS_INTERRUPT_LEVEL = 7;
5192: public static final int MPU_IOI_INTERRUPT_MASK = 0x80 >> MPU_IOI_INTERRUPT_LEVEL;
5193: public static final int MPU_EB2_INTERRUPT_MASK = 0x80 >> MPU_EB2_INTERRUPT_LEVEL;
5194: public static final int MPU_DMA_INTERRUPT_MASK = 0x80 >> MPU_DMA_INTERRUPT_LEVEL;
5195: public static final int MPU_SCC_INTERRUPT_MASK = 0x80 >> MPU_SCC_INTERRUPT_LEVEL;
5196: public static final int MPU_MFP_INTERRUPT_MASK = 0x80 >> MPU_MFP_INTERRUPT_LEVEL;
5197: public static final int MPU_SYS_INTERRUPT_MASK = 0x80 >> MPU_SYS_INTERRUPT_LEVEL;
5198:
5199: public static final boolean MPU_INTERRUPT_SWITCH = true;
5200:
5201:
5202: public static final boolean T = true;
5203: public static final boolean F = false;
5204:
5205: public static final int CCCC_T = 0b0000;
5206: public static final int CCCC_F = 0b0001;
5207: public static final int CCCC_HI = 0b0010;
5208: public static final int CCCC_LS = 0b0011;
5209: public static final int CCCC_CC = 0b0100;
5210: public static final int CCCC_CS = 0b0101;
5211: public static final int CCCC_NE = 0b0110;
5212: public static final int CCCC_EQ = 0b0111;
5213: public static final int CCCC_VC = 0b1000;
5214: public static final int CCCC_VS = 0b1001;
5215: public static final int CCCC_PL = 0b1010;
5216: public static final int CCCC_MI = 0b1011;
5217: public static final int CCCC_GE = 0b1100;
5218: public static final int CCCC_LT = 0b1101;
5219: public static final int CCCC_GT = 0b1110;
5220: public static final int CCCC_LE = 0b1111;
5221:
5222:
5223:
5224:
5225:
5226:
5227: public static final boolean[] BCCMAP = {
5228: 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,
5229: 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,
5230: 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,
5231: 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,
5232: 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,
5233: 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,
5234: 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,
5235: 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,
5236: 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,
5237: 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,
5238: 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,
5239: 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,
5240: 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,
5241: 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,
5242: 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,
5243: 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,
5244: };
5245:
5246:
5247: public static final char[] MPU_CCCMAP = (
5248: "11111111111111111111111111111111" +
5249: "00000000000000000000000000000000" +
5250: "10100000101000001010000010100000" +
5251: "01011111010111110101111101011111" +
5252: "10101010101010101010101010101010" +
5253: "01010101010101010101010101010101" +
5254: "11110000111100001111000011110000" +
5255: "00001111000011110000111100001111" +
5256: "11001100110011001100110011001100" +
5257: "00110011001100110011001100110011" +
5258: "11111111000000001111111100000000" +
5259: "00000000111111110000000011111111" +
5260: "11001100001100111100110000110011" +
5261: "00110011110011000011001111001100" +
5262: "11000000001100001100000000110000" +
5263: "00111111110011110011111111001111").toCharArray ();
5264:
5265:
5266:
5267: public static final int MPU_CC_T = 0b11111111111111111111111111111111;
5268: public static final int MPU_CC_F = 0b00000000000000000000000000000000;
5269: public static final int MPU_CC_HI = 0b10100000101000001010000010100000;
5270: public static final int MPU_CC_LS = 0b01011111010111110101111101011111;
5271: public static final int MPU_CC_HS = 0b10101010101010101010101010101010;
5272: public static final int MPU_CC_LO = 0b01010101010101010101010101010101;
5273: public static final int MPU_CC_NE = 0b11110000111100001111000011110000;
5274: public static final int MPU_CC_EQ = 0b00001111000011110000111100001111;
5275: public static final int MPU_CC_VC = 0b11001100110011001100110011001100;
5276: public static final int MPU_CC_VS = 0b00110011001100110011001100110011;
5277: public static final int MPU_CC_PL = 0b11111111000000001111111100000000;
5278: public static final int MPU_CC_MI = 0b00000000111111110000000011111111;
5279: public static final int MPU_CC_GE = 0b11001100001100111100110000110011;
5280: public static final int MPU_CC_LT = 0b00110011110011000011001111001100;
5281: public static final int MPU_CC_GT = 0b11000000001100001100000000110000;
5282: public static final int MPU_CC_LE = 0b00111111110011110011111111001111;
5283:
5284:
5285:
5286:
5287:
5288:
5289:
5290:
5291:
5292:
5293:
5294:
5295:
5296:
5297:
5298:
5299:
5300:
5301:
5302:
5303:
5304:
5305:
5306:
5307:
5308:
5309:
5310:
5311:
5312:
5313:
5314:
5315:
5316:
5317:
5318:
5319:
5320:
5321:
5322:
5323:
5324:
5325:
5326:
5327:
5328:
5329:
5330:
5331:
5332: 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);
5333:
5334:
5335:
5336: public static final int[] MPU_BITREV_TABLE_0 = new int[2048];
5337: public static final int[] MPU_BITREV_TABLE_1 = new int[2048];
5338: public static final int[] MPU_BITREV_TABLE_2 = new int[2048];
5339: static {
5340: for (int i = 0; i < 2048; i++) {
5341: MPU_BITREV_TABLE_2[i] = (MPU_BITREV_TABLE_1[i] = (MPU_BITREV_TABLE_0[i] = Integer.reverse (i)) >>> 11) >>> 11;
5342: }
5343: }
5344:
5345:
5346:
5347: public static final int EA_DR = 0b000_000;
5348: public static final int EA_AR = 0b001_000;
5349: public static final int EA_MM = 0b010_000;
5350: public static final int EA_MP = 0b011_000;
5351: public static final int EA_MN = 0b100_000;
5352: public static final int EA_MW = 0b101_000;
5353: public static final int EA_MX = 0b110_000;
5354: public static final int EA_ZW = 0b111_000;
5355: public static final int EA_ZL = 0b111_001;
5356: public static final int EA_PW = 0b111_010;
5357: public static final int EA_PX = 0b111_011;
5358: public static final int EA_IM = 0b111_100;
5359: public static final int MMM_DR = EA_DR >> 3;
5360: public static final int MMM_AR = EA_AR >> 3;
5361: public static final int MMM_MM = EA_MM >> 3;
5362: public static final int MMM_MP = EA_MP >> 3;
5363: public static final int MMM_MN = EA_MN >> 3;
5364: public static final int MMM_MW = EA_MW >> 3;
5365: public static final int MMM_MX = EA_MX >> 3;
5366: public static final long EAM_DR = 0xff00000000000000L >>> EA_DR;
5367: public static final long EAM_AR = 0xff00000000000000L >>> EA_AR;
5368: public static final long EAM_MM = 0xff00000000000000L >>> EA_MM;
5369: public static final long EAM_MP = 0xff00000000000000L >>> EA_MP;
5370: public static final long EAM_MN = 0xff00000000000000L >>> EA_MN;
5371: public static final long EAM_MW = 0xff00000000000000L >>> EA_MW;
5372: public static final long EAM_MX = 0xff00000000000000L >>> EA_MX;
5373: public static final long EAM_ZW = 0x8000000000000000L >>> EA_ZW;
5374: public static final long EAM_ZL = 0x8000000000000000L >>> EA_ZL;
5375: public static final long EAM_PW = 0x8000000000000000L >>> EA_PW;
5376: public static final long EAM_PX = 0x8000000000000000L >>> EA_PX;
5377: public static final long EAM_IM = 0x8000000000000000L >>> EA_IM;
5378: 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;
5379: public static final long EAM_ALT = EAM_DR|EAM_AR|EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5380: 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;
5381: 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 ;
5382: public static final long EAM_DLT = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5383: public static final long EAM_DCN = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5384: public static final long EAM_DCL = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5385: 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;
5386: public static final long EAM_MEM = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5387: public static final long EAM_MLT = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5388: public static final long EAM_RDL = EAM_MM|EAM_MP |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5389: public static final long EAM_WTL = EAM_MM |EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5390: public static final long EAM_CNT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5391: public static final long EAM_CLT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5392:
5393:
5394:
5395:
5396:
5397:
5398:
5399:
5400:
5401:
5402:
5403: public static final int[] regRn = new int[16 + 1];
5404:
5405:
5406: public static int regPC;
5407: public static int regPC0;
5408:
5409:
5410: public static int regOC;
5411:
5412:
5413: public static int regSRT1;
5414: public static int regSRT0;
5415: public static int mpuTraceFlag;
5416: public static int regSRS;
5417: public static int regSRM;
5418: public static int regSRI;
5419:
5420:
5421: public static int regCCR;
5422:
5423:
5424:
5425:
5426:
5427:
5428:
5429:
5430:
5431:
5432:
5433:
5434:
5435:
5436:
5437:
5438:
5439:
5440:
5441:
5442: public static int mpuIMR;
5443:
5444:
5445:
5446:
5447:
5448:
5449: public static int mpuIRR;
5450: public static int mpuDIRR;
5451:
5452:
5453:
5454:
5455:
5456:
5457:
5458:
5459: public static int mpuISR;
5460:
5461:
5462: public static int mpuSFC;
5463: public static int mpuDFC;
5464: public static int mpuCACR;
5465:
5466:
5467:
5468:
5469:
5470: public static int mpuBUSCR;
5471: public static int mpuUSP;
5472: public static int mpuVBR;
5473: public static int mpuCAAR;
5474: public static int mpuMSP;
5475: public static int mpuISP;
5476:
5477:
5478:
5479: public static int mpuPCR;
5480:
5481:
5482:
5483: public static final int MPU_060_REV = 7;
5484:
5485:
5486:
5487: public static long mpuClockTime;
5488: public static long mpuClockLimit;
5489: public static double mpuClockMHz;
5490: public static double mpuCurrentMHz;
5491: public static int mpuCycleCount;
5492: public static long mpuCycleUnit;
5493: public static long mpuModifiedUnit;
5494: public static long dmaCycleUnit;
5495:
5496:
5497:
5498: public static TimerTask mpuTask;
5499:
5500:
5501: public static int mpuBootDevice;
5502: public static int mpuROMBootHandle;
5503: public static int mpuSavedBootDevice;
5504: public static int mpuSavedROMBootHandle;
5505:
5506:
5507: public static boolean mpuIgnoreAddressError;
5508:
5509:
5510: public static int mpuROMWaitCycles;
5511: public static int mpuRAMWaitCycles;
5512: public static boolean mpuCacheOn;
5513: public static final class WaitTime {
5514: public long ram;
5515: public long gvram;
5516: public long tvram;
5517: public long crtc;
5518: public long palet;
5519: public long vicon;
5520: public long dmac;
5521: public long mfp;
5522: public long rtc;
5523: public long prnport;
5524: public long sysport;
5525: public long opm;
5526: public long adpcm;
5527: public long fdc;
5528: public long fdd;
5529: public long hdc;
5530: public long scc;
5531: public long ppi;
5532: public long ioi;
5533: public long sprc;
5534: public long sram;
5535: public long rom;
5536: public long ramlong;
5537: public long romlong;
5538: public boolean isDma;
5539: public WaitTime (boolean isDma) {
5540: this.isDma = isDma;
5541: }
5542: }
5543: public static final WaitTime mpuNoWaitTime = new WaitTime (false);
5544: public static final WaitTime dmaNoWaitTime = new WaitTime (true);
5545: public static final WaitTime mpuWaitTime = new WaitTime (false);
5546: public static final WaitTime dmaWaitTime = new WaitTime (true);
5547: public static boolean busWaitCyclesRequest;
5548: public static boolean busWaitCycles;
5549: public static WaitTime busWaitTime;
5550:
5551:
5552: public static boolean mpuArbFreqOn;
5553: public static int mpuArbFreqMHz;
5554: public static SpinnerNumberModel mpuArbFreqModel;
5555: public static JSpinner mpuArbFreqSpinner;
5556: public static JRadioButtonMenuItem mpuArbFreqRadioButtonMenuItem;
5557:
5558:
5559: public static boolean mpuUtilOn;
5560: public static int mpuUtilRatio;
5561: public static SpinnerNumberModel mpuUtilModel;
5562: public static JSpinner mpuUtilSpinner;
5563: public static JRadioButtonMenuItem mpuUtilRadioButtonMenuItem;
5564:
5565:
5566: public static final int MPU_ADJUSTMENT_INTERVAL = 100;
5567: public static int mpuAdjustmentCounter;
5568: public static long mpuTotalNano;
5569: public static long mpuLastNano;
5570: public static double mpuCoreNano1;
5571: public static double mpuCoreNano2;
5572:
5573:
5574: public static JMenu mpuMenu;
5575: public static JMenuItem mpuResetMenuItem;
5576: public static JMenuItem mpuOpt1ResetMenuItem;
5577: public static JRadioButtonMenuItem mpuClock10MenuItem;
5578: public static JRadioButtonMenuItem mpuClock16MenuItem;
5579: public static JRadioButtonMenuItem mpuClock25MenuItem;
5580: public static JRadioButtonMenuItem mpuClock33MenuItem;
5581: public static JRadioButtonMenuItem mpuClock50MenuItem;
5582: public static JRadioButtonMenuItem mpuClock66MenuItem;
5583: public static JRadioButtonMenuItem mpuClock75MenuItem;
5584: public static JRadioButtonMenuItem mpuClock100MenuItem;
5585:
5586:
5587: public static ActionListener mpuDebugActionListener;
5588: public static ArrayList<AbstractButton> mpuButtonsRunning;
5589: public static ArrayList<AbstractButton> mpuButtonsStopped;
5590: public static ArrayList<JCheckBox> mpuOriIllegalCheckBoxList;
5591: public static ArrayList<JCheckBox> mpuStopOnErrorCheckBoxList;
5592: public static ArrayList<JCheckBox> mpuStopAtStartCheckBoxList;
5593:
5594: public static int mpuAdvanceCount;
5595: public static int mpuStepCount;
5596: public static boolean mpuContinue;
5597: public static int mpuUntilReturnSRS;
5598: public static int mpuUntilReturnRP;
5599: public static int mpuUntilReturnPC0;
5600: public static int mpuUntilReturnSP;
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:
5631:
5632:
5633:
5634:
5635:
5636:
5637:
5638:
5639:
5640:
5641:
5642:
5643:
5644:
5645:
5646:
5647:
5648:
5649:
5650:
5651:
5652:
5653:
5654:
5655:
5656:
5657:
5658:
5659:
5660:
5661:
5662:
5663:
5664:
5665:
5666:
5667:
5668:
5669:
5670:
5671:
5672:
5673:
5674: public static final boolean MPU_SXMENU = false;
5675:
5676:
5677:
5678: public static void mpuInit () {
5679:
5680: mpuIgnoreAddressError = false;
5681:
5682:
5683:
5684: fpuInit ();
5685:
5686: mpuClockTime = 0L;
5687: mpuClockLimit = 0L;
5688: mpuCycleCount = 0;
5689:
5690: mpuTask = null;
5691:
5692: M68kException.m6eSignal = new M68kException ();
5693: M68kException.m6eNumber = 0;
5694: M68kException.m6eAddress = 0;
5695: M68kException.m6eDirection = MPU_WR_WRITE;
5696: M68kException.m6eSize = MPU_SS_BYTE;
5697:
5698: mpuBootDevice = -1;
5699: mpuROMBootHandle = -1;
5700: mpuSavedBootDevice = -1;
5701: mpuSavedROMBootHandle = -1;
5702:
5703:
5704:
5705:
5706:
5707:
5708:
5709:
5710:
5711:
5712:
5713:
5714:
5715:
5716:
5717: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
5718: mpuTotalNano = 0L;
5719: mpuLastNano = System.nanoTime ();
5720: mpuCoreNano1 = mpuCoreNano2 = 0.5 * 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
5721:
5722: mpuButtonsRunning = new ArrayList<AbstractButton> ();
5723: mpuButtonsStopped = new ArrayList<AbstractButton> ();
5724:
5725: mpuOriIllegalCheckBoxList = new ArrayList<JCheckBox> ();
5726: mpuStopOnErrorCheckBoxList = new ArrayList<JCheckBox> ();
5727: mpuStopAtStartCheckBoxList = new ArrayList<JCheckBox> ();
5728:
5729: mpuAdvanceCount = 0;
5730: mpuStepCount = 0;
5731: mpuContinue = false;
5732: mpuUntilReturnSRS = 0;
5733: mpuUntilReturnRP = 0;
5734: mpuUntilReturnPC0 = 0;
5735: mpuUntilReturnSP = 0;
5736:
5737:
5738: mpuDebugActionListener = new ActionListener () {
5739: @Override public void actionPerformed (ActionEvent ae) {
5740: Object source = ae.getSource ();
5741: switch (ae.getActionCommand ()) {
5742: case "Stop":
5743: if (RootPointerList.RTL_ON) {
5744: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
5745: RootPointerList.rtlCurrentUserTaskIsStoppable) {
5746: mpuStop (null);
5747: }
5748: } else {
5749: mpuStop (null);
5750: }
5751: break;
5752: case "Trace":
5753: mpuAdvance (1);
5754: break;
5755: case "Trace 10 times":
5756: mpuAdvance (10);
5757: break;
5758: case "Trace 100 times":
5759: mpuAdvance (100);
5760: break;
5761: case "Step":
5762: mpuStep (1);
5763: break;
5764: case "Step 10 times":
5765: mpuStep (10);
5766: break;
5767: case "Step 100 times":
5768: mpuStep (100);
5769: break;
5770: case "Step until return":
5771: mpuStepUntilReturn ();
5772: break;
5773: case "Run":
5774: mpuStart ();
5775: break;
5776:
5777: case "Consider ORI.B #$00,D0 as an illegal instruction" :
5778: if (DBG_ORI_BYTE_ZERO_D0) {
5779: dbgOriByteZeroD0 = ((JCheckBox) source).isSelected ();
5780: for (JCheckBox checkBox : mpuOriIllegalCheckBoxList) {
5781: if (checkBox.isSelected () != dbgOriByteZeroD0) {
5782: checkBox.setSelected (dbgOriByteZeroD0);
5783: }
5784: }
5785: }
5786: break;
5787: case "Stop on error":
5788: dbgStopOnError = ((JCheckBox) source).isSelected ();
5789: for (JCheckBox checkBox : mpuStopOnErrorCheckBoxList) {
5790: if (checkBox.isSelected () != dbgStopOnError) {
5791: checkBox.setSelected (dbgStopOnError);
5792: }
5793: }
5794: break;
5795: case "Stop at execution start position":
5796: dbgStopAtStart = ((JCheckBox) source).isSelected ();
5797: for (JCheckBox checkBox : mpuStopAtStartCheckBoxList) {
5798: if (checkBox.isSelected () != dbgStopAtStart) {
5799: checkBox.setSelected (dbgStopAtStart);
5800: }
5801: }
5802: break;
5803: }
5804: }
5805: };
5806:
5807: }
5808:
5809:
5810:
5811: public static JCheckBox mpuMakeOriIllegalCheckBox () {
5812: JCheckBox checkBox = Multilingual.mlnToolTipText (
5813: ComponentFactory.createIconCheckBox (
5814: DBG_ORI_BYTE_ZERO_D0 ? dbgOriByteZeroD0 : null,
5815: LnF.LNF_ORI_BYTE_ZERO_D0_IMAGE,
5816: LnF.LNF_ORI_BYTE_ZERO_D0_SELECTED_IMAGE,
5817: "Consider ORI.B #$00,D0 as an illegal instruction", mpuDebugActionListener),
5818: "ja", "ORI.B #$00,D0 を不当命令とみなす");
5819: mpuOriIllegalCheckBoxList.add (checkBox);
5820: return checkBox;
5821: }
5822:
5823:
5824:
5825: public static JCheckBox mpuMakeStopOnErrorCheckBox () {
5826: JCheckBox checkBox = Multilingual.mlnToolTipText (
5827: ComponentFactory.createIconCheckBox (
5828: dbgStopOnError,
5829: LnF.LNF_STOP_ON_ERROR_IMAGE,
5830: LnF.LNF_STOP_ON_ERROR_SELECTED_IMAGE,
5831: "Stop on error", mpuDebugActionListener),
5832: "ja", "エラーで停止する");
5833: mpuStopOnErrorCheckBoxList.add (checkBox);
5834: return checkBox;
5835: }
5836:
5837:
5838:
5839: public static JCheckBox mpuMakeStopAtStartCheckBox () {
5840: JCheckBox checkBox = Multilingual.mlnToolTipText (
5841: ComponentFactory.createIconCheckBox (
5842: dbgStopAtStart,
5843: LnF.LNF_STOP_AT_START_IMAGE,
5844: LnF.LNF_STOP_AT_START_SELECTED_IMAGE,
5845: "Stop at execution start position", mpuDebugActionListener),
5846: "ja", "実行開始位置で停止する");
5847: mpuStopAtStartCheckBoxList.add (checkBox);
5848: return checkBox;
5849: }
5850:
5851:
5852: public static void mpuMakeMenu () {
5853:
5854: ButtonGroup unitGroup = new ButtonGroup ();
5855: ActionListener listener = new ActionListener () {
5856: @Override public void actionPerformed (ActionEvent ae) {
5857: Object source = ae.getSource ();
5858: switch (ae.getActionCommand ()) {
5859: case "Reset":
5860: mpuReset (-1, -1);
5861: break;
5862: case "Hold down OPT.1 and reset":
5863: mpuReset (0, -1);
5864: break;
5865: case "Interrupt":
5866: sysInterrupt ();
5867: break;
5868: case "10MHz":
5869: mpuArbFreqOn = false;
5870: mpuUtilOn = false;
5871: mpuSetCurrentClock (10.0);
5872: break;
5873: case "16.7MHz":
5874: mpuArbFreqOn = false;
5875: mpuUtilOn = false;
5876: mpuSetCurrentClock (50.0 / 3.0);
5877: break;
5878: case "25MHz":
5879: mpuArbFreqOn = false;
5880: mpuUtilOn = false;
5881: mpuSetCurrentClock (25.0);
5882: break;
5883: case "33.3MHz":
5884: mpuArbFreqOn = false;
5885: mpuUtilOn = false;
5886: mpuSetCurrentClock (100.0 / 3.0);
5887: break;
5888: case "50MHz":
5889: mpuArbFreqOn = false;
5890: mpuUtilOn = false;
5891: mpuSetCurrentClock (50.0);
5892: break;
5893: case "66.7MHz":
5894: mpuArbFreqOn = false;
5895: mpuUtilOn = false;
5896: mpuSetCurrentClock (200.0 / 3.0);
5897: break;
5898: case "75MHz":
5899: mpuArbFreqOn = false;
5900: mpuUtilOn = false;
5901: mpuSetCurrentClock (75.0);
5902: break;
5903: case "100MHz":
5904: mpuArbFreqOn = false;
5905: mpuUtilOn = false;
5906: mpuSetCurrentClock (100.0);
5907: break;
5908: case "Arbitrary frequency":
5909: mpuArbFreqOn = true;
5910: mpuUtilOn = false;
5911: mpuSetCurrentClock ((double) mpuArbFreqMHz);
5912: break;
5913: case "Arbitrary load factor":
5914: mpuArbFreqOn = false;
5915: mpuUtilOn = true;
5916: break;
5917: case "FE function instruction":
5918: FEFunction.fpkOn = ((JCheckBoxMenuItem) source).isSelected ();
5919: break;
5920: case "Reject FLOATn.X":
5921: FEFunction.fpkRejectFloatOn = ((JCheckBoxMenuItem) source).isSelected ();
5922: break;
5923: case "Cut FC2 pin":
5924: busRequestCutFC2Pin = ((JCheckBoxMenuItem) source).isSelected ();
5925: break;
5926: case "Wait cycles":
5927: busWaitCyclesRequest = ((JCheckBoxMenuItem) source).isSelected ();
5928: break;
5929: case "Use IPLROM 1.6":
5930: ROM.romIPLROM16On = ((JCheckBoxMenuItem) source).isSelected ();
5931: break;
5932: case "Increase IPLROM to 256KB":
5933: ROM.romIPLROM256KOn = ((JCheckBoxMenuItem) source).isSelected ();
5934: break;
5935:
5936: case "Run / Stop":
5937: if (((JCheckBox) source).isSelected ()) {
5938: mpuStart ();
5939: } else {
5940: if (RootPointerList.RTL_ON) {
5941: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
5942: RootPointerList.rtlCurrentUserTaskIsStoppable) {
5943: mpuStop (null);
5944: }
5945: } else {
5946: mpuStop (null);
5947: }
5948: }
5949: pnlPanel.requestFocusInWindow ();
5950: break;
5951: }
5952: }
5953: };
5954: mpuMenu = ComponentFactory.createMenu (
5955: "MPU", 'M',
5956: mpuResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset", 'R', MNB_MODIFIERS, listener), "ja", "リセット"),
5957: mpuOpt1ResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Hold down OPT.1 and reset", 'O', MNB_MODIFIERS, listener), "ja", "OPT.1 を押しながらリセット"),
5958: Multilingual.mlnText (ComponentFactory.createMenuItem ("Interrupt", listener), "ja", "インタラプト"),
5959: ComponentFactory.createHorizontalSeparator (),
5960: mdlMenu,
5961: ComponentFactory.createHorizontalSeparator (),
5962: mpuClock10MenuItem = ComponentFactory.createRadioButtonMenuItem (
5963: unitGroup,
5964: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 10.0,
5965: "10MHz",
5966: listener),
5967: mpuClock16MenuItem = ComponentFactory.createRadioButtonMenuItem (
5968: unitGroup,
5969: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0 / 3.0,
5970: "16.7MHz",
5971: listener),
5972: mpuClock25MenuItem = ComponentFactory.createRadioButtonMenuItem (
5973: unitGroup,
5974: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 25.0,
5975: "25MHz",
5976: listener),
5977: mpuClock33MenuItem = ComponentFactory.createRadioButtonMenuItem (
5978: unitGroup,
5979: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0 / 3.0,
5980: "33.3MHz",
5981: listener),
5982: mpuClock50MenuItem = ComponentFactory.createRadioButtonMenuItem (
5983: unitGroup,
5984: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0,
5985: "50MHz",
5986: listener),
5987: mpuClock66MenuItem = ComponentFactory.createRadioButtonMenuItem (
5988: unitGroup,
5989: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 200.0 / 3.0,
5990: "66.7MHz",
5991: listener),
5992: mpuClock75MenuItem = ComponentFactory.createRadioButtonMenuItem (
5993: unitGroup,
5994: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 75.0,
5995: "75MHz",
5996: listener),
5997: mpuClock100MenuItem = ComponentFactory.createRadioButtonMenuItem (
5998: unitGroup,
5999: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0,
6000: "100MHz",
6001: listener),
6002: mpuArbFreqRadioButtonMenuItem = Multilingual.mlnText (
6003: ComponentFactory.createRadioButtonMenuItem (
6004: unitGroup,
6005: mpuArbFreqOn,
6006: "Arbitrary frequency",
6007: listener),
6008: "ja", "任意の周波数"),
6009: ComponentFactory.createHorizontalBox (
6010: Box.createHorizontalStrut (20),
6011: mpuArbFreqSpinner = ComponentFactory.createNumberSpinner (
6012: mpuArbFreqModel = new SpinnerNumberModel (mpuArbFreqMHz, 1, 1000, 1),
6013: 4,
6014: new ChangeListener () {
6015: @Override public void stateChanged (ChangeEvent ce) {
6016:
6017: mpuArbFreqMHz = mpuArbFreqModel.getNumber ().intValue ();
6018: if (mpuArbFreqOn) {
6019: mpuSetCurrentClock ((double) mpuArbFreqMHz);
6020: }
6021: }
6022: }
6023: ),
6024: ComponentFactory.createLabel ("MHz"),
6025: Box.createHorizontalGlue ()
6026: ),
6027: mpuUtilRadioButtonMenuItem = Multilingual.mlnText (
6028: ComponentFactory.createRadioButtonMenuItem (
6029: unitGroup,
6030: mpuUtilOn,
6031: "Arbitrary load factor",
6032: listener),
6033: "ja", "任意の負荷率"),
6034: ComponentFactory.createHorizontalBox (
6035: Box.createHorizontalStrut (20),
6036: mpuUtilSpinner = ComponentFactory.createNumberSpinner (
6037: mpuUtilModel = new SpinnerNumberModel (mpuUtilRatio, 1, 100, 1),
6038: 4,
6039: new ChangeListener () {
6040: @Override public void stateChanged (ChangeEvent ce) {
6041:
6042: mpuUtilRatio = mpuUtilModel.getNumber ().intValue ();
6043: }
6044: }
6045: ),
6046: ComponentFactory.createLabel ("%"),
6047: Box.createHorizontalGlue ()
6048: ),
6049: ComponentFactory.createHorizontalSeparator (),
6050:
6051: coproFPUMenu,
6052:
6053: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkOn, "FE function instruction", listener), "ja", "FE ファンクション命令"),
6054: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkRejectFloatOn, "Reject FLOATn.X", listener), "ja", "FLOATn.X を組み込まない"),
6055: ComponentFactory.createHorizontalSeparator (),
6056: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busRequestCutFC2Pin, "Cut FC2 pin", listener), "ja", "FC2 ピンをカットする"),
6057: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busWaitCyclesRequest, "Wait cycles", listener), "ja", "ウェイトサイクル"),
6058: ComponentFactory.createHorizontalSeparator (),
6059: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM16On, "Use IPLROM 1.6", listener), "ja", "IPLROM 1.6 を使う"),
6060: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM256KOn, "Increase IPLROM to 256KB", listener), "ja", "IPLROM を 256KB に増やす")
6061: );
6062: }
6063:
6064:
6065: public static void mpuSetCurrentClock (double clock) {
6066: specifiedClock = clock;
6067: if (currentIsSecond) {
6068: specifiedSecondClock = clock;
6069: } else {
6070: specifiedFirstClock = clock;
6071: }
6072: if (!mpuArbFreqOn && !mpuUtilOn) {
6073: if (specifiedClock == 10.0) {
6074: mpuClock10MenuItem.setSelected (true);
6075: } else if (specifiedClock == 50.0 / 3.0) {
6076: mpuClock16MenuItem.setSelected (true);
6077: } else if (specifiedClock == 25.0) {
6078: mpuClock25MenuItem.setSelected (true);
6079: } else if (specifiedClock == 100.0 / 3.0) {
6080: mpuClock33MenuItem.setSelected (true);
6081: } else if (specifiedClock == 50.0) {
6082: mpuClock50MenuItem.setSelected (true);
6083: } else if (specifiedClock == 200.0 / 3.0) {
6084: mpuClock66MenuItem.setSelected (true);
6085: } else if (specifiedClock == 75.0) {
6086: mpuClock75MenuItem.setSelected (true);
6087: } else if (specifiedClock == 100.0) {
6088: mpuClock100MenuItem.setSelected (true);
6089: }
6090: }
6091: mpuClockMHz = specifiedClock;
6092: mpuSetClockMHz (mpuClockMHz);
6093: }
6094:
6095:
6096:
6097:
6098:
6099:
6100:
6101:
6102:
6103:
6104:
6105: public static void mpuSetClockMHz (double mhz) {
6106: mhz = Math.max (1.0, Math.min (1000.0, mhz));
6107: double lastMHz = mpuCurrentMHz;
6108: mpuCurrentMHz = mhz;
6109: mpuCycleUnit = (long) (((double) TMR_FREQ / 1000000.0) / mhz + 0.5);
6110:
6111: mpuModifiedUnit = (currentMPU == Model.MPU_MC68EC030 ||
6112: currentMPU == Model.MPU_MC68030 ?
6113: (long) (((double) TMR_FREQ * 3.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6114: currentMPU == Model.MPU_MC68LC040 ||
6115: currentMPU == Model.MPU_MC68040 ?
6116: (long) (((double) TMR_FREQ * 2.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6117: mpuCycleUnit);
6118: if (lastMHz != mhz) {
6119: mpuSetWait ();
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:
6160:
6161:
6162:
6163:
6164:
6165:
6166:
6167:
6168:
6169:
6170:
6171:
6172:
6173:
6174:
6175:
6176:
6177:
6178:
6179:
6180:
6181:
6182:
6183:
6184:
6185:
6186:
6187:
6188:
6189:
6190:
6191:
6192:
6193:
6194:
6195:
6196:
6197:
6198:
6199:
6200:
6201:
6202:
6203: public static void mpuSetWait () {
6204:
6205: if (currentMPU <= Model.MPU_MC68010) {
6206: mpuWaitTime.ram = mpuCycleUnit >> 3;
6207: mpuWaitTime.vicon = (long) (mpuCycleUnit * 0.6);
6208: mpuWaitTime.crtc =
6209: mpuWaitTime.prnport =
6210: mpuWaitTime.sysport =
6211: mpuWaitTime.sprc =
6212: mpuWaitTime.sram =
6213: mpuWaitTime.rom = mpuCycleUnit;
6214: mpuWaitTime.gvram = (long) (mpuCycleUnit * 1.1);
6215: mpuWaitTime.rtc =
6216: mpuWaitTime.opm =
6217: mpuWaitTime.adpcm =
6218: mpuWaitTime.fdc =
6219: mpuWaitTime.fdd =
6220: mpuWaitTime.hdc =
6221: mpuWaitTime.ppi =
6222: mpuWaitTime.ioi = (long) (mpuCycleUnit * 1.7);
6223: mpuWaitTime.tvram = mpuCycleUnit * 2;
6224: mpuWaitTime.palet = (long) (mpuCycleUnit * 2.6);
6225: mpuWaitTime.mfp = (long) (mpuCycleUnit * 4.3);
6226: mpuWaitTime.scc = mpuCycleUnit * 6;
6227: mpuWaitTime.dmac = mpuCycleUnit * 15;
6228: mpuWaitTime.ramlong = mpuWaitTime.ram << 1;
6229: mpuWaitTime.romlong = mpuWaitTime.rom << 1;
6230: } else if (currentMPU <= Model.MPU_MC68030) {
6231: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6232: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6233: mpuWaitTime.sram = mpuCycleUnit * 2;
6234: mpuWaitTime.prnport =
6235: mpuWaitTime.sysport = mpuCycleUnit * 4;
6236: mpuWaitTime.gvram =
6237: mpuWaitTime.crtc =
6238: mpuWaitTime.vicon =
6239: mpuWaitTime.sprc = mpuCycleUnit * 6;
6240: mpuWaitTime.tvram = mpuCycleUnit * 7;
6241: mpuWaitTime.palet = mpuCycleUnit * 11;
6242: mpuWaitTime.opm =
6243: mpuWaitTime.adpcm =
6244: mpuWaitTime.fdc =
6245: mpuWaitTime.fdd =
6246: mpuWaitTime.hdc =
6247: mpuWaitTime.ppi =
6248: mpuWaitTime.ioi = mpuCycleUnit * 15;
6249: mpuWaitTime.mfp = mpuCycleUnit * 19;
6250: mpuWaitTime.rtc = mpuCycleUnit * 28;
6251: mpuWaitTime.dmac = mpuCycleUnit * 34;
6252: mpuWaitTime.scc = mpuCycleUnit * 38;
6253: mpuWaitTime.ramlong = mpuWaitTime.ram;
6254: mpuWaitTime.romlong = mpuWaitTime.rom;
6255: } else {
6256: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6257: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6258: mpuWaitTime.sram = mpuCycleUnit * 13;
6259: mpuWaitTime.prnport =
6260: mpuWaitTime.sysport = mpuCycleUnit * 17;
6261: mpuWaitTime.gvram =
6262: mpuWaitTime.crtc =
6263: mpuWaitTime.vicon =
6264: mpuWaitTime.sprc = mpuCycleUnit * 21;
6265: mpuWaitTime.tvram = mpuCycleUnit * 22;
6266: mpuWaitTime.palet = mpuCycleUnit * 33;
6267: mpuWaitTime.opm =
6268: mpuWaitTime.adpcm =
6269: mpuWaitTime.fdc =
6270: mpuWaitTime.fdd =
6271: mpuWaitTime.hdc =
6272: mpuWaitTime.ppi =
6273: mpuWaitTime.ioi = mpuCycleUnit * 37;
6274: mpuWaitTime.mfp = mpuCycleUnit * 47;
6275: mpuWaitTime.dmac = mpuCycleUnit * 73;
6276: mpuWaitTime.rtc = mpuCycleUnit * 77;
6277: mpuWaitTime.scc = mpuCycleUnit * 97;
6278: mpuWaitTime.ramlong = mpuWaitTime.ram;
6279: mpuWaitTime.romlong = mpuWaitTime.rom;
6280: }
6281: if (true) {
6282:
6283: mpuNoWaitTime.sram = mpuWaitTime.sram;
6284: mpuNoWaitTime.rom = mpuWaitTime.rom;
6285: mpuNoWaitTime.romlong = mpuWaitTime.romlong;
6286: }
6287:
6288: dmaWaitTime.ram = dmaCycleUnit >> 3;
6289: dmaWaitTime.sram = 0;
6290: dmaWaitTime.rom = 0;
6291: dmaWaitTime.gvram =
6292: dmaWaitTime.crtc =
6293: dmaWaitTime.vicon =
6294: dmaWaitTime.prnport =
6295: dmaWaitTime.sysport =
6296: dmaWaitTime.sprc = dmaCycleUnit;
6297: dmaWaitTime.tvram =
6298: dmaWaitTime.rtc =
6299: dmaWaitTime.opm =
6300: dmaWaitTime.adpcm =
6301: dmaWaitTime.fdc =
6302: dmaWaitTime.fdd =
6303: dmaWaitTime.hdc =
6304: dmaWaitTime.ppi =
6305: dmaWaitTime.ioi = dmaCycleUnit * 2;
6306: dmaWaitTime.palet = dmaCycleUnit * 3;
6307: dmaWaitTime.mfp = dmaCycleUnit * 4;
6308: dmaWaitTime.scc = dmaCycleUnit * 6;
6309: dmaWaitTime.dmac = dmaCycleUnit * 15;
6310: dmaWaitTime.ramlong = dmaWaitTime.ram << 1;
6311: dmaWaitTime.romlong = dmaWaitTime.rom << 1;
6312: if (MC68060.CAT_ON) {
6313: if (Model.MPU_MC68LC060 <= currentMPU) {
6314: MC68060.catMainLongTime = mpuCycleUnit * 13;
6315: MC68060.catMainLineTime = mpuCycleUnit * 45;
6316: MC68060.catHighLongTime = mpuCycleUnit * 9;
6317: MC68060.catHighLineTime = mpuCycleUnit * 15;
6318: }
6319: }
6320: }
6321:
6322:
6323:
6324:
6325:
6326: public static void mpuReset (int device, int romHandle) {
6327:
6328: mpuBootDevice = device;
6329: mpuROMBootHandle = romHandle;
6330:
6331:
6332:
6333:
6334:
6335:
6336:
6337:
6338:
6339:
6340:
6341:
6342: if (mpuBootDevice == -1) {
6343: if (mpuSavedBootDevice != -1) {
6344: mpuBootDevice = mpuSavedBootDevice;
6345: mpuROMBootHandle = mpuSavedROMBootHandle;
6346: mpuSavedBootDevice = -1;
6347: mpuSavedROMBootHandle = -1;
6348: }
6349: } else {
6350: if (mpuSavedBootDevice == -1) {
6351: mpuSavedBootDevice = MainMemory.mmrRwz (0x00ed0018);
6352: mpuSavedROMBootHandle = MainMemory.mmrRls (0x00ed000c);
6353: }
6354: }
6355:
6356:
6357: if (mpu010) {
6358: if (specifiedFirstMPU == Model.MPU_MC68000) {
6359: specifiedFirstMPU = Model.MPU_MC68010;
6360: }
6361: if (specifiedSecondMPU == Model.MPU_MC68000) {
6362: specifiedSecondMPU = Model.MPU_MC68010;
6363: }
6364: } else {
6365: if (specifiedFirstMPU == Model.MPU_MC68010) {
6366: specifiedFirstMPU = Model.MPU_MC68000;
6367: }
6368: if (specifiedSecondMPU == Model.MPU_MC68010) {
6369: specifiedSecondMPU = Model.MPU_MC68000;
6370: }
6371: }
6372:
6373:
6374: specifiedIsSecond = false;
6375: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
6376: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
6377:
6378: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
6379: MC68EC030.m30DivZeroVFlag = false;
6380: }
6381:
6382: if (mpuTask != null) {
6383: mpuClockLimit = 0L;
6384: System.out.println (Multilingual.mlnJapanese ?
6385: "MPU を停止します" :
6386: "MPU stops");
6387: mpuTask.cancel ();
6388: mpuTask = null;
6389: }
6390:
6391: tmrTimer.schedule (new TimerTask () {
6392: @Override public void run () {
6393:
6394:
6395:
6396: currentModel = specifiedModel;
6397: currentAccelerator = specifiedAccelerator;
6398: frmUpdateTitle ();
6399:
6400: currentIsSecond = specifiedIsSecond;
6401: currentFirstMPU = specifiedFirstMPU;
6402: currentSecondMPU = specifiedSecondMPU;
6403: currentMPU = specifiedMPU;
6404:
6405: mpuSetCurrentClock (specifiedClock);
6406:
6407: currentCopro0 = specifiedCopro0;
6408: currentCopro1 = specifiedCopro1;
6409: currentCopro2 = specifiedCopro2;
6410: currentOnchipFPU = specifiedOnchipFPU;
6411:
6412:
6413: if (currentMPU < Model.MPU_MC68020) {
6414: if (busHimem68000) {
6415: busRequestExMemoryStart = 0x10000000;
6416: busRequestExMemorySize = busLocalMemorySize;
6417: busRequestExMemoryArray = busLocalMemoryArray;
6418: } else {
6419: busRequestExMemoryStart = 0x10000000;
6420: busRequestExMemorySize = 0 << 20;
6421: busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
6422: }
6423: } else if (currentMPU < Model.MPU_MC68LC040) {
6424: if (busHighMemory060turboOn) {
6425: busRequestExMemoryStart = 0x10000000;
6426: busRequestExMemorySize = busLocalMemorySize;
6427: busRequestExMemoryArray = busLocalMemoryArray;
6428: } else {
6429: busRequestExMemoryStart = 0x01000000;
6430: busRequestExMemorySize = busHighMemorySize;
6431: busRequestExMemoryArray = busHighMemoryArray;
6432: }
6433: } else {
6434: busRequestExMemoryStart = 0x10000000;
6435: busRequestExMemorySize = busLocalMemorySize;
6436: busRequestExMemoryArray = busLocalMemoryArray;
6437: }
6438: busUpdateMemoryMap ();
6439:
6440:
6441: ROM.romReset ();
6442:
6443: RegisterList.drpSetMPU ();
6444:
6445: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
6446: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6447: MC68060.mmuReset ();
6448:
6449:
6450: if (Model.MPU_MC68020 <= currentMPU) {
6451: if ((7 & currentCopro0) == 1) {
6452: fpuMotherboardCoprocessor.epbSetMC68881 ();
6453: } else if ((7 & currentCopro0) == 2) {
6454: fpuMotherboardCoprocessor.epbSetMC68882 ();
6455: } else {
6456: fpuMotherboardCoprocessor.epbSetFullSpec ();
6457: }
6458: if ((8 & currentCopro0) == 0) {
6459: fpuMotherboardCoprocessor.epbSetExtended ();
6460: } else {
6461: fpuMotherboardCoprocessor.epbSetTriple ();
6462: }
6463: }
6464:
6465: if ((7 & currentCopro1) == 1) {
6466: fpuCoproboard1.epbSetMC68881 ();
6467: } else if ((7 & currentCopro1) == 2) {
6468: fpuCoproboard1.epbSetMC68882 ();
6469: } else {
6470: fpuCoproboard1.epbSetFullSpec ();
6471: }
6472: if ((8 & currentCopro1) == 0) {
6473: fpuCoproboard1.epbSetExtended ();
6474: } else {
6475: fpuCoproboard1.epbSetTriple ();
6476: }
6477:
6478: if ((7 & currentCopro2) == 1) {
6479: fpuCoproboard2.epbSetMC68881 ();
6480: } else if ((7 & currentCopro2) == 2) {
6481: fpuCoproboard2.epbSetMC68882 ();
6482: } else {
6483: fpuCoproboard2.epbSetFullSpec ();
6484: }
6485: if ((8 & currentCopro2) == 0) {
6486: fpuCoproboard2.epbSetExtended ();
6487: } else {
6488: fpuCoproboard2.epbSetTriple ();
6489: }
6490:
6491: if (Model.MPU_MC68040 <= currentMPU) {
6492: if ((7 & currentOnchipFPU) == 6) {
6493: fpuOnChipFPU.epbSetMC68060 ();
6494: } else {
6495: fpuOnChipFPU.epbSetFullSpec ();
6496: }
6497: if ((8 & currentOnchipFPU) == 0) {
6498: fpuOnChipFPU.epbSetExtended ();
6499: } else {
6500: fpuOnChipFPU.epbSetTriple ();
6501: }
6502: }
6503:
6504: if (!currentModel.isX68030 ()) {
6505: dmaCycleUnit = TMR_FREQ / 10000000L;
6506: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6507: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6508: mpuROMWaitCycles = 1;
6509: mpuRAMWaitCycles = 0;
6510: } else {
6511: dmaCycleUnit = TMR_FREQ / 12500000L;
6512: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6513: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6514: mpuROMWaitCycles = 0;
6515: mpuRAMWaitCycles = 0;
6516: }
6517:
6518: busWaitCycles = busWaitCyclesRequest;
6519: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
6520:
6521: HD63450.dmaReadCycles = (currentModel.isPRO () ? 6 :
6522: currentModel.isCompact () ? 4 :
6523: 5);
6524: HD63450.dmaWriteCycles = (currentModel.isPRO () ? 6 :
6525: 5);
6526:
6527: if (currentMPU < Model.MPU_MC68020) {
6528:
6529: mpuIgnoreAddressError = false;
6530:
6531: mpuCacheOn = false;
6532:
6533: } else if (currentMPU < Model.MPU_MC68040) {
6534:
6535: mpuIgnoreAddressError = true;
6536: fpuBox = fpuMotherboardCoprocessor;
6537: fpuBox.epbReset ();
6538: fpuFPn = fpuBox.epbFPn;
6539:
6540: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
6541:
6542: } else {
6543:
6544: mpuIgnoreAddressError = true;
6545: fpuBox = fpuOnChipFPU;
6546: fpuBox.epbReset ();
6547: fpuFPn = fpuBox.epbFPn;
6548:
6549: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6550: mpuCacheOn = (mpuCACR & 0x80008000) != 0;
6551: if (MC68060.CAT_ON) {
6552: if (Model.MPU_MC68LC060 <= currentMPU) {
6553: MC68060.catReset ();
6554: }
6555: }
6556:
6557: }
6558:
6559: mpuSetWait ();
6560:
6561:
6562: regSRT1 = regSRT0 = 0;
6563: regSRS = REG_SR_S;
6564: regSRM = 0;
6565: regSRI = REG_SR_I;
6566: regCCR = 0;
6567: Arrays.fill (regRn, 0);
6568:
6569: regRn[15] = MainMemory.mmrRls (0x00ff0000);
6570: regPC = MainMemory.mmrRls (0x00ff0004);
6571:
6572: MainMemory.mmrReset ();
6573:
6574: busReset ();
6575: if (InstructionBreakPoint.IBP_ON) {
6576: InstructionBreakPoint.ibpOp1MemoryMap = InstructionBreakPoint.ibpOp1SuperMap;
6577: InstructionBreakPoint.ibpReset ();
6578: }
6579: if (BranchLog.BLG_ON) {
6580: BranchLog.blgReset ();
6581: }
6582:
6583: mpuIMR = 0;
6584: mpuIRR = 0;
6585: if (MC68901.MFP_DELAYED_INTERRUPT) {
6586: mpuDIRR = 0;
6587: }
6588: mpuISR = 0;
6589:
6590:
6591: mpuStart ();
6592: }
6593: }, TMR_DELAY);
6594:
6595: }
6596:
6597:
6598:
6599: public static void mpuStopAndStart () {
6600: if (mpuTask == null) {
6601: mpuStart ();
6602: } else {
6603: if (RootPointerList.RTL_ON) {
6604: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6605: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6606: mpuStop (null);
6607: }
6608: } else {
6609: mpuStop (null);
6610: }
6611: }
6612: }
6613:
6614:
6615:
6616:
6617:
6618: public static void mpuStart () {
6619: if (mpuTask != null) {
6620: mpuClockLimit = 0L;
6621: System.out.println (Multilingual.mlnJapanese ?
6622: "MPU を停止します" :
6623: "MPU stops");
6624: mpuTask.cancel ();
6625: mpuTask = null;
6626: }
6627:
6628: for (AbstractButton button : mpuButtonsStopped) {
6629: button.setEnabled (false);
6630: }
6631: DisassembleList.ddpStoppedBy = null;
6632: System.out.println (Model.mpuNameOf (currentMPU) + (Multilingual.mlnJapanese ? " を起動します" : " starts up"));
6633: mpuTask = new TimerTask () {
6634: @Override public void run () {
6635: mpuContinue = true;
6636: mpuClockLimit = mpuClockTime + TMR_FREQ * TMR_INTERVAL / 1000;
6637: mpuExecuteCore ();
6638: }
6639: };
6640: tmrTimer.scheduleAtFixedRate (mpuTask, TMR_DELAY, TMR_INTERVAL);
6641:
6642: for (AbstractButton button : mpuButtonsRunning) {
6643: button.setEnabled (true);
6644: }
6645: }
6646:
6647:
6648:
6649: public static void mpuExecuteCore () {
6650:
6651: long nanoStart = System.nanoTime ();
6652:
6653: busSuper (RP5C15.rtcFirst, 0x00e8a000, 0x00e8c000);
6654:
6655:
6656: if (currentMPU < Model.MPU_MC68010) {
6657: MC68000.mpuCore ();
6658: } else if (currentMPU < Model.MPU_MC68020) {
6659: MC68010.mpuCore ();
6660: } else if (currentMPU < Model.MPU_MC68LC040) {
6661: MC68EC030.mpuCore ();
6662: } else {
6663: MC68060.mpuCore ();
6664: }
6665:
6666: if (dbgVisibleMask != 0) {
6667: dbgUpdate ();
6668: }
6669:
6670: long nanoEnd = System.nanoTime ();
6671: mpuTotalNano += nanoEnd - nanoStart;
6672: if (--mpuAdjustmentCounter == 0) {
6673:
6674: final double expectedNano = 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
6675:
6676: double coreNano0 = (double) mpuTotalNano;
6677: mpuTotalNano = 0L;
6678: double coreNanoA = (coreNano0 * 2.0 + mpuCoreNano1 + mpuCoreNano2) * 0.25;
6679: mpuCoreNano2 = mpuCoreNano1;
6680: mpuCoreNano1 = coreNano0;
6681:
6682:
6683:
6684: double actualPercent = Math.max (1.0, 100.0 * coreNanoA / expectedNano);
6685:
6686: double maxPercent = SoundSource.sndPlayOn ? 90.0 : 100.0;
6687:
6688:
6689:
6690:
6691: if (mpuUtilOn) {
6692:
6693: double targetPercent = Math.min (maxPercent, (double) mpuUtilRatio);
6694: mpuSetClockMHz ((1.2 - 0.2 * actualPercent / targetPercent) * mpuCurrentMHz);
6695: } else {
6696: mpuSetClockMHz (Math.min (maxPercent / actualPercent,
6697: 1.2 - 0.2 * mpuCurrentMHz / mpuClockMHz) * mpuCurrentMHz);
6698: }
6699: Indicator.indUpdate (actualPercent);
6700: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
6701: }
6702: }
6703:
6704:
6705:
6706:
6707: public static void mpuStop (String message) {
6708:
6709: mpuAdvanceCount = 0;
6710: mpuStepCount = 0;
6711: mpuContinue = false;
6712: mpuStop1 (message);
6713: }
6714: public static void mpuStop1 (String message) {
6715: if (mpuTask == null) {
6716: return;
6717: }
6718: DisassembleList.ddpStoppedBy = message;
6719: mpuClockLimit = 0L;
6720: System.out.println (Multilingual.mlnJapanese ?
6721: "MPU を停止します" :
6722: "MPU stops");
6723: mpuTask.cancel ();
6724: mpuTask = null;
6725:
6726: if (mpuStepCount != 0 && mpuContinue) {
6727: if (mpuStepCount == -1 || --mpuStepCount != 0) {
6728: mpuStep (mpuStepCount);
6729: return;
6730: }
6731: }
6732: mpuAdvanceCount = 0;
6733: mpuStepCount = 0;
6734: mpuContinue = false;
6735:
6736: for (AbstractButton button : mpuButtonsRunning) {
6737: button.setEnabled (false);
6738: }
6739: tmrTimer.schedule (new TimerTask () {
6740: @Override public void run () {
6741: mpuUpdateWindow ();
6742: }
6743: }, TMR_DELAY);
6744: }
6745:
6746:
6747:
6748:
6749:
6750:
6751: public static void mpuAdvance (int n) {
6752: if (mpuTask != null) {
6753: return;
6754: }
6755: mpuAdvanceCount = n;
6756: DisassembleList.ddpStoppedBy = null;
6757: mpuTask = new TimerTask () {
6758: @Override public void run () {
6759: mpuContinue = true;
6760: do {
6761: mpuClockLimit = mpuClockTime + 1L;
6762: mpuExecuteCore ();
6763: } while (mpuContinue && --mpuAdvanceCount != 0);
6764: mpuClockLimit = 0L;
6765: if (mpuTask != null) {
6766: mpuTask.cancel ();
6767: mpuTask = null;
6768: }
6769: if (mpuStepCount != 0 && mpuContinue) {
6770: if (mpuStepCount == -1 || --mpuStepCount != 0) {
6771: mpuStep (mpuStepCount);
6772: return;
6773: }
6774: }
6775: mpuAdvanceCount = 0;
6776: mpuStepCount = 0;
6777: mpuContinue = false;
6778: mpuUpdateWindow ();
6779: }
6780: };
6781: tmrTimer.schedule (mpuTask, TMR_DELAY);
6782: }
6783:
6784:
6785:
6786:
6787:
6788:
6789: public static void mpuStep (int n) {
6790: if (mpuTask != null) {
6791: return;
6792: }
6793: mpuStepCount = n;
6794: Disassembler.disDisassemble (new StringBuilder (), regPC, regSRS);
6795: if ((Disassembler.disStatus & (Disassembler.DIS_ALWAYS_BRANCH | Disassembler.DIS_SOMETIMES_BRANCH)) != 0) {
6796: if (mpuStepCount == -1 &&
6797: (Disassembler.disOC == 0x4e73 ||
6798: Disassembler.disOC == 0x4e74 ||
6799: Disassembler.disOC == 0x4e75 ||
6800: Disassembler.disOC == 0x4e77) &&
6801: mpuUntilReturnSRS == regSRS &&
6802: (currentMPU < Model.MPU_MC68LC040 ||
6803: mpuUntilReturnRP == (regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP)) &&
6804: mpuUntilReturnPC0 != regPC0 &&
6805: Integer.compareUnsigned (mpuUntilReturnSP, regRn[15]) <= 0) {
6806: mpuAdvanceCount = 0;
6807: mpuStepCount = 0;
6808: mpuContinue = false;
6809: mpuUpdateWindow ();
6810: return;
6811: }
6812: mpuAdvance (1);
6813: } else {
6814: if (InstructionBreakPoint.IBP_ON) {
6815: InstructionBreakPoint.ibpInstant (Disassembler.disPC, DisassembleList.ddpSupervisorMode);
6816: mpuStart ();
6817: }
6818: }
6819: }
6820:
6821:
6822:
6823:
6824:
6825:
6826:
6827:
6828:
6829:
6830:
6831: public static void mpuStepUntilReturn () {
6832: if (mpuTask != null) {
6833: return;
6834: }
6835: mpuUntilReturnSRS = regSRS;
6836: mpuUntilReturnRP = regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP;
6837: mpuUntilReturnPC0 = regPC0;
6838: mpuUntilReturnSP = regRn[15];
6839: mpuStep (-1);
6840: }
6841:
6842:
6843:
6844: public static void mpuUpdateWindow () {
6845: if (dbgVisibleMask != 0) {
6846: if ((dbgVisibleMask & DBG_DDP_VISIBLE_MASK) != 0) {
6847: DisassembleList.ddpBacktraceRecord = -1L;
6848: DisassembleList.ddpUpdate (-1, -1, false);
6849: }
6850: if (BranchLog.BLG_ON) {
6851: if ((dbgVisibleMask & DBG_BLG_VISIBLE_MASK) != 0) {
6852: BranchLog.blgUpdate (BranchLog.BLG_SELECT_NEWEST);
6853: }
6854: }
6855: if (ProgramFlowVisualizer.PFV_ON) {
6856: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
6857: ProgramFlowVisualizer.pfvUpdate ();
6858: }
6859: }
6860: if (RasterBreakPoint.RBP_ON) {
6861: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
6862: RasterBreakPoint.rbpUpdateFrame ();
6863: }
6864: }
6865: if (ScreenModeTest.SMT_ON) {
6866: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
6867: ScreenModeTest.smtUpdateFrame ();
6868: }
6869: }
6870: if (RootPointerList.RTL_ON) {
6871: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
6872: RootPointerList.rtlUpdateFrame ();
6873: }
6874: }
6875: if (SpritePatternViewer.SPV_ON) {
6876: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
6877: SpritePatternViewer.spvUpdateFrame ();
6878: }
6879: }
6880: if (PaletteViewer.PLV_ON) {
6881: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
6882: PaletteViewer.plvUpdateFrame ();
6883: }
6884: }
6885: if (ATCMonitor.ACM_ON) {
6886: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
6887: ATCMonitor.acmUpdateFrame ();
6888: }
6889: }
6890: }
6891:
6892: if (DebugConsole.dgtRequestRegs != 0) {
6893: if ((DebugConsole.dgtRequestRegs & 1) != 0) {
6894: ExpressionEvaluator.ElementType.ETY_COMMAND_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
6895: }
6896: if ((DebugConsole.dgtRequestRegs & 2) != 0) {
6897: ExpressionEvaluator.ElementType.ETY_COMMAND_FLOAT_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
6898: }
6899: if ((DebugConsole.dgtRequestRegs & 4) != 0) {
6900: DebugConsole.dgtPrintPrompt ();
6901: }
6902: DebugConsole.dgtRequestRegs = 0;
6903: }
6904:
6905: for (AbstractButton button : mpuButtonsRunning) {
6906: button.setEnabled (false);
6907: }
6908:
6909: for (AbstractButton button : mpuButtonsStopped) {
6910: button.setEnabled (true);
6911: }
6912: }
6913:
6914:
6915:
6916: public static JButton mpuMakeBreakButton () {
6917: return mpuAddButtonRunning (
6918: Multilingual.mlnToolTipText (
6919: ComponentFactory.createImageButton (
6920: LnF.LNF_BREAK_IMAGE,
6921: LnF.LNF_BREAK_DISABLED_IMAGE,
6922: "Stop", mpuDebugActionListener),
6923: "ja", "停止")
6924: );
6925: }
6926:
6927:
6928:
6929: public static JButton mpuMakeTraceButton () {
6930: return mpuAddButtonStopped (
6931: Multilingual.mlnToolTipText (
6932: ComponentFactory.createImageButton (
6933: LnF.LNF_TRACE_IMAGE,
6934: LnF.LNF_TRACE_DISABLED_IMAGE,
6935: "Trace", mpuDebugActionListener),
6936: "ja", "トレース")
6937: );
6938: }
6939:
6940:
6941:
6942: public static JButton mpuMakeTrace10Button () {
6943: return mpuAddButtonStopped (
6944: Multilingual.mlnToolTipText (
6945: ComponentFactory.createImageButton (
6946: LnF.LNF_TRACE_10_IMAGE,
6947: LnF.LNF_TRACE_10_DISABLED_IMAGE,
6948: "Trace 10 times", mpuDebugActionListener),
6949: "ja", "トレース 10 回")
6950: );
6951: }
6952:
6953:
6954:
6955: public static JButton mpuMakeTrace100Button () {
6956: return mpuAddButtonStopped (
6957: Multilingual.mlnToolTipText (
6958: ComponentFactory.createImageButton (
6959: LnF.LNF_TRACE_100_IMAGE,
6960: LnF.LNF_TRACE_100_DISABLED_IMAGE,
6961: "Trace 100 times", mpuDebugActionListener),
6962: "ja", "トレース 100 回")
6963: );
6964: }
6965:
6966:
6967:
6968: public static JButton mpuMakeStepButton () {
6969: return mpuAddButtonStopped (
6970: Multilingual.mlnToolTipText (
6971: ComponentFactory.createImageButton (
6972: LnF.LNF_STEP_IMAGE,
6973: LnF.LNF_STEP_DISABLED_IMAGE,
6974: "Step", mpuDebugActionListener),
6975: "ja", "ステップ")
6976: );
6977: }
6978:
6979:
6980:
6981: public static JButton mpuMakeStep10Button () {
6982: return mpuAddButtonStopped (
6983: Multilingual.mlnToolTipText (
6984: ComponentFactory.createImageButton (
6985: LnF.LNF_STEP_10_IMAGE,
6986: LnF.LNF_STEP_10_DISABLED_IMAGE,
6987: "Step 10 times", mpuDebugActionListener),
6988: "ja", "ステップ 10 回")
6989: );
6990: }
6991:
6992:
6993:
6994: public static JButton mpuMakeStep100Button () {
6995: return mpuAddButtonStopped (
6996: Multilingual.mlnToolTipText (
6997: ComponentFactory.createImageButton (
6998: LnF.LNF_STEP_100_IMAGE,
6999: LnF.LNF_STEP_100_DISABLED_IMAGE,
7000: "Step 100 times", mpuDebugActionListener),
7001: "ja", "ステップ 100 回")
7002: );
7003: }
7004:
7005:
7006:
7007: public static JButton mpuMakeReturnButton () {
7008: return mpuAddButtonStopped (
7009: Multilingual.mlnToolTipText (
7010: ComponentFactory.createImageButton (
7011: LnF.LNF_STEP_UNTIL_RETURN_IMAGE,
7012: LnF.LNF_STEP_UNTIL_RETURN_DISABLED_IMAGE,
7013: "Step until return", mpuDebugActionListener),
7014: "ja", "ステップアンティルリターン")
7015: );
7016: }
7017:
7018:
7019:
7020: public static JButton mpuMakeRunButton () {
7021: return mpuAddButtonStopped (
7022: Multilingual.mlnToolTipText (
7023: ComponentFactory.createImageButton (
7024: LnF.LNF_RUN_IMAGE,
7025: LnF.LNF_RUN_DISABLED_IMAGE,
7026: "Run", mpuDebugActionListener),
7027: "ja", "実行")
7028: );
7029: }
7030:
7031:
7032:
7033: public static <T extends AbstractButton> T mpuAddButtonRunning (T button) {
7034: button.setEnabled (mpuTask != null);
7035: mpuButtonsRunning.add (button);
7036: return button;
7037: }
7038:
7039:
7040:
7041: public static <T extends AbstractButton> T mpuAddButtonStopped (T button) {
7042: button.setEnabled (mpuTask == null);
7043: mpuButtonsStopped.add (button);
7044: return button;
7045: }
7046:
7047:
7048:
7049:
7050:
7051:
7052:
7053:
7054:
7055:
7056:
7057:
7058:
7059:
7060:
7061:
7062: public static final int EMX_OPCODE_BASE = 0x4e00;
7063: public static final int EMX_OPCODE_HFSBOOT = EMX_OPCODE_BASE + 0x00;
7064: public static final int EMX_OPCODE_HFSINST = EMX_OPCODE_BASE + 0x01;
7065: public static final int EMX_OPCODE_HFSSTR = EMX_OPCODE_BASE + 0x02;
7066: public static final int EMX_OPCODE_HFSINT = EMX_OPCODE_BASE + 0x03;
7067: public static final int EMX_OPCODE_EMXNOP = EMX_OPCODE_BASE + 0x04;
7068: public static final int EMX_OPCODE_EMXWAIT = EMX_OPCODE_BASE + 0x05;
7069:
7070: public static final String[] EMX_MNEMONIC_ARRAY = {
7071: "hfsboot",
7072: "hfsinst",
7073: "hfsstr",
7074: "hfsint",
7075: "emxnop",
7076: "emxwait",
7077: };
7078:
7079:
7080:
7081:
7082: public static void emxNop () {
7083: if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x00007140) {
7084: int head = regRn[9];
7085: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7086:
7087:
7088: emxPatchPCM8A (head, tail);
7089:
7090:
7091: emxCheckRSDRV202 (head, tail);
7092: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000716c) {
7093: int head = regRn[9];
7094: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7095:
7096:
7097: emxPatch060turbosys (head, tail);
7098:
7099:
7100: if (Z8530.SCC_FSX_MOUSE) {
7101: emxCheckFSX (head, tail);
7102: }
7103:
7104:
7105: if (HFS.HFS_USE_TWENTY_ONE) {
7106: emxCheckTwentyOne (head, tail);
7107: }
7108:
7109:
7110: LabeledAddress.lblClear ();
7111: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000972c) {
7112: int head = regRn[8] + 256;
7113:
7114: int tail = MC68060.mmuPeekLong (head - 208, 1);
7115:
7116:
7117: emxCheckBSIO021 (head, tail);
7118:
7119:
7120: emxPatchPCM8A (head, tail);
7121:
7122:
7123: emxCheckTMSIO031 (head, tail);
7124:
7125:
7126: LabeledAddress.lblClear ();
7127:
7128:
7129: if (dbgStopAtStart) {
7130: InstructionBreakPoint.ibpInstant (regRn[12], 0);
7131: }
7132: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000a090) {
7133: int head = regRn[8] + 256;
7134: int tail = MC68060.mmuPeekLongData (regRn[8] + 8, 1);
7135: String name = MC68060.mmuPeekStringZ (head - 60, 1);
7136: if (name.equalsIgnoreCase ("fsx.x")) {
7137:
7138:
7139: if (Z8530.SCC_FSX_MOUSE) {
7140: emxCheckFSX (head, tail);
7141: }
7142: }
7143: if (name.equalsIgnoreCase ("TwentyOne.x")) {
7144:
7145:
7146: if (HFS.HFS_USE_TWENTY_ONE) {
7147: emxCheckTwentyOne (head, tail);
7148: }
7149: }
7150: }
7151: }
7152:
7153: public static final int[] emxPCM8AFFMap = {
7154: 0x00000138, 0x000001f6, 0x00000394, 0x000011ec, 0x0000120a, 0x00001400, 0x00001814, 0x00001870, 0x00001882, 0x0000188a,
7155: 0x00001892, 0x000018a2, 0x000018a8, 0x000018ca, 0x000018d4, 0x000018e0, 0x000018e8, 0x00001908, 0x000019e4, 0x00001afa,
7156: 0x00001b58, 0x00001b7c, 0x00001bac, 0x00001c38, 0x00001ccc, 0x000021f8, 0x00002250, 0x00002258, 0x00002290, 0x000022a6,
7157: 0x000022b0, 0x000022c0, 0x000022c8, 0x000022de, 0x000022ea, 0x000030c8, 0x000030de, 0x000030e6, 0x000030ea, 0x000030f6,
7158: 0x00003112, 0x00003188, 0x0000334c, 0x0000338a, 0x000033a2, 0x000033c4, 0x000033d0, 0x0000341a, 0x00003428, 0x00003496,
7159: 0x000034a6, 0x000034d6, 0x0000fe0e, 0x0000fec8, 0x0000feec, 0x0000ff46, 0x0000ff4e,
7160: };
7161:
7162:
7163:
7164: public static void emxPatchPCM8A (int head, int tail) {
7165: if (head + 0x0000ff60 <= tail &&
7166: MC68060.mmuPeekLongData (head + 0x10f8, 1) == 0x50434d38 &&
7167: MC68060.mmuPeekLongData (head + 0x10fc, 1) == 0x41313032) {
7168: System.out.println (Multilingual.mlnJapanese ?
7169: "PCM8A.X 1.02 があります" :
7170: "PCM8A.X 1.02 exists");
7171: int patched = 0;
7172: int failed = 0;
7173:
7174: for (int offset : emxPCM8AFFMap) {
7175: if (MC68060.mmuPeekByteZeroData (head + offset, 1) == 0xff) {
7176: MC68060.mmuPokeByteData (head + offset, 0x00, 1);
7177: patched++;
7178: } else {
7179: failed++;
7180: }
7181: }
7182: if (patched != 0) {
7183: System.out.printf (Multilingual.mlnJapanese ?
7184: "PCM8A.X 1.02 にパッチをあてました (%d/%d)\n" :
7185: "PCM8A.X 1.02 was patched (%d/%d)\n",
7186: patched, patched + failed);
7187: }
7188: }
7189: }
7190:
7191:
7192:
7193: public static void emxPatch060turbosys (int head, int tail) {
7194:
7195:
7196:
7197:
7198: if (head + 0x00002000 <= tail &&
7199: MC68060.mmuPeekLongData (head + 0x00000ec0, 1) == 0x203c302e &&
7200: MC68060.mmuPeekLongData (head + 0x00000ec4, 1) == 0x3536227c &&
7201: MC68060.mmuPeekLongData (head + 0x00000ec8, 1) == 0x30363054) {
7202: System.out.println (Multilingual.mlnJapanese ?
7203: "060turbo.sys 0.56 があります" :
7204: "060turbo.sys 0.56 exists");
7205:
7206:
7207:
7208: int patched = 0;
7209: int failed = 0;
7210: if (MC68060.mmuPeekLongData (head + 0x000021e6, 1) == 0x08f90004 &&
7211: MC68060.mmuPeekLongData (head + 0x000021ea, 1) == 0x00ed0070) {
7212: MC68060.mmuPokeWordData (head + 0x000021e6, 0x0839, 1);
7213: patched++;
7214: } else {
7215: failed++;
7216: }
7217: System.out.printf (Multilingual.mlnJapanese ?
7218: "060turbo.sys 0.56 にパッチをあてました (%d/%d)\n" :
7219: "060turbo.sys 0.56 was patched (%d/%d)\n",
7220: patched, patched + failed);
7221: }
7222: }
7223:
7224:
7225:
7226: public static void emxCheckFSX (int head, int tail) {
7227: if (Z8530.SCC_FSX_MOUSE) {
7228: if (head + 0x00063200 <= tail &&
7229: "\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))) {
7230: System.out.println (Multilingual.mlnJapanese ?
7231: "FSX.X 3.10 があります" :
7232: "FSX.X 3.10 exists");
7233: Z8530.sccFSXMouseHook = head + 0x04f82a;
7234: Z8530.sccFSXMouseWork = head + 0x063184;
7235: }
7236: }
7237: }
7238:
7239:
7240:
7241:
7242:
7243:
7244: public static void emxCheckRSDRV202 (int head, int tail) {
7245: if (head + 0x000ea6 <= tail &&
7246: MC68060.mmuPeekEquals (head + 0x000e4e, "RS-232C DRIVER for X68000 version 2.02")) {
7247: if (RS232CTerminal.trmRSDRV202Head != head) {
7248: RS232CTerminal.trmRSDRV202Head = head;
7249: int[] patchData = {
7250:
7251:
7252: 0x05f8, 0x000a, 0x000b,
7253:
7254: 0x0600, 0xd040, 0x2048,
7255:
7256: 0x060e, 0x3030, 0x4e90,
7257: 0x0610, 0x0000, 0x2048,
7258:
7259: 0x074e, 0x0821, 0x2041,
7260: 0x0750, 0x0410, 0x3200,
7261: 0x0752, 0x0207, 0x303c,
7262: 0x0754, 0x0102, 0x0823,
7263: 0x0756, 0x0080, 0xe268,
7264: 0x0758, 0x003f, 0x72fe,
7265: 0x075a, 0x001f, 0xd141,
7266: 0x075c, 0x000e, 0x2208,
7267: 0x075e, 0x0006, 0x4e75,
7268:
7269:
7270: 0x0ab0, 0x0040, 0x0400,
7271: 0x0ad2, 0x0040, 0x0400,
7272: 0x0af4, 0x0040, 0x0400,
7273: 0x0b16, 0x0040, 0x0400,
7274: 0x0b38, 0x0040, 0x0400,
7275:
7276:
7277: 0x0cae, 0x0009, 0x000b,
7278: };
7279: int patched = 0;
7280: int failed = 0;
7281: for (int i = 0; i < patchData.length; i += 3) {
7282: int a = head + patchData[i];
7283: int b = patchData[i + 1];
7284: int c = patchData[i + 2];
7285: int d = MC68060.mmuPeekWordZeroData (a, 1);
7286: if (d == b) {
7287: MC68060.mmuPokeWordData (a, c, 1);
7288: patched++;
7289: } else if (d != c) {
7290: failed++;
7291: }
7292: }
7293: System.out.printf ("RSDRV.SYS 2.02 found at %08X and patched (%d/%d)\n", head, patched, patched + failed);
7294: }
7295: }
7296: }
7297:
7298:
7299:
7300:
7301:
7302: public static void emxCheckTMSIO031 (int head, int tail) {
7303: if (head + 0x000fc4 <= tail &&
7304: MC68060.mmuPeekEquals (head + 0x000d1c, "TMSIO version 0.31 Copyright (C) 1990-93 by Miki Hoshino")) {
7305: if (RS232CTerminal.trmTMSIO031Head != head) {
7306: RS232CTerminal.trmTMSIO031Head = head;
7307: System.out.printf ("TMSIO 0.31 found at %08X\n", head);
7308: }
7309: }
7310: }
7311:
7312:
7313:
7314:
7315:
7316: public static void emxCheckBSIO021 (int head, int tail) {
7317: if (head + 0x001c2c <= tail &&
7318: MC68060.mmuPeekEquals (head + 0x001a66, "BSIO version 0.21 Copyright (C) 1994 By BAZU")) {
7319: if (RS232CTerminal.trmBSIO021Head != head) {
7320: RS232CTerminal.trmBSIO021Head = head;
7321: System.out.printf ("BSIO 0.21 found at %08X\n", head);
7322: }
7323: }
7324: }
7325:
7326:
7327:
7328: public static void emxCheckTwentyOne (int head, int tail) {
7329: if (HFS.HFS_USE_TWENTY_ONE &&
7330: head + 64 <= tail) {
7331: if (MainMemory.mmrTwentyOneOptionAddress != 0 ||
7332: MainMemory.mmrHumanVersion <= 0) {
7333: return;
7334: }
7335: int name1 = MC68060.mmuPeekLongData (head + 14, 1);
7336: if (name1 == ('*' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7337: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7338: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '*')) {
7339: MainMemory.mmrTwentyOneOptionAddress = -1;
7340: }
7341: } else if (name1 == ('?' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7342: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7343: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '?') ||
7344: name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | 'E')) {
7345: System.out.println (Multilingual.mlnJapanese ?
7346: "TwentyOne.x があります" :
7347: "TwentyOne.x exists");
7348: MainMemory.mmrTwentyOneOptionAddress = head + 22;
7349: }
7350: }
7351: }
7352: }
7353:
7354:
7355:
7356:
7357:
7358:
7359:
7360:
7361:
7362:
7363:
7364:
7365:
7366:
7367:
7368:
7369:
7370:
7371:
7372:
7373:
7374:
7375:
7376:
7377:
7378:
7379:
7380:
7381:
7382:
7383:
7384:
7385:
7386:
7387:
7388:
7389:
7390:
7391:
7392:
7393:
7394:
7395:
7396:
7397:
7398:
7399:
7400:
7401:
7402:
7403:
7404: public static final boolean IRP_BITREV_REVERSE = false;
7405: public static final boolean IRP_BITREV_SHIFT = false;
7406: public static final boolean IRP_BITREV_TABLE = true;
7407:
7408: public static final boolean IRP_MOVEM_MAINMEMORY = true;
7409: public static final boolean IRP_MOVEM_EXPAND = false;
7410: public static final boolean IRP_MOVEM_LOOP = false;
7411: public static final boolean IRP_MOVEM_SHIFT_LEFT = false;
7412: public static final boolean IRP_MOVEM_SHIFT_RIGHT = true;
7413: public static final boolean IRP_MOVEM_ZEROS = false;
7414:
7415:
7416: public static void irpReset () {
7417:
7418: CRTC.crtReset ();
7419: VideoController.vcnReset ();
7420: HD63450.dmaReset ();
7421: MC68901.mfpReset ();
7422: Keyboard.kbdReset ();
7423: RP5C15.rtcReset ();
7424: PrinterPort.prnReset ();
7425: SoundSource.sndReset ();
7426: OPM.opmReset ();
7427: ADPCM.pcmReset ();
7428: FDC.fdcReset ();
7429: IOInterrupt.ioiReset ();
7430: eb2Reset ();
7431: if (HostCDROM.HCD_ENABLED) {
7432: HostCDROM.hcdReset ();
7433: }
7434: SPC.spcReset ();
7435: Z8530.sccReset ();
7436: RS232CTerminal.trmReset ();
7437: PPI.ppiReset ();
7438: HFS.hfsReset ();
7439: SpriteScreen.sprReset ();
7440:
7441: if (MercuryUnit.MU4_ON) {
7442: MercuryUnit.mu4Reset ();
7443: }
7444: xt3Reset ();
7445: SRAM.smrReset ();
7446: CONDevice.conReset ();
7447: TextCopy.txcReset ();
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:
7975:
7976:
7977:
7978:
7979:
7980:
7981:
7982:
7983:
7984:
7985:
7986:
7987:
7988:
7989:
7990:
7991:
7992:
7993:
7994:
7995:
7996:
7997:
7998:
7999:
8000:
8001:
8002:
8003:
8004:
8005:
8006:
8007:
8008:
8009:
8010:
8011:
8012:
8013:
8014:
8015:
8016:
8017:
8018:
8019:
8020:
8021:
8022:
8023:
8024:
8025:
8026:
8027:
8028:
8029:
8030:
8031:
8032:
8033:
8034:
8035: 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);
8036:
8037: public static final boolean EFA_SEPARATE_AR = false;
8038:
8039:
8040:
8041:
8042:
8043:
8044: public static final boolean BUS_SPLIT_UNALIGNED_LONG = false;
8045:
8046:
8047: public static final int BUS_MOTHER_BITS = 24;
8048: public static final int BUS_MOTHER_SIZE = BUS_MOTHER_BITS < 32 ? 1 << BUS_MOTHER_BITS : 0;
8049: public static final int BUS_MOTHER_MASK = BUS_MOTHER_SIZE - 1;
8050:
8051: public static final int BUS_ARRAY_SIZE = BUS_MOTHER_SIZE;
8052:
8053:
8054: public static final int BUS_PAGE_BITS = 12;
8055: public static final int BUS_PAGE_SIZE = 1 << BUS_PAGE_BITS;
8056: public static final int BUS_PAGE_COUNT = 1 << (32 - BUS_PAGE_BITS);
8057:
8058:
8059: public static final int MPU_SS_BYTE = 0;
8060: public static final int MPU_SS_WORD = 1;
8061: public static final int MPU_SS_LONG = 2;
8062:
8063:
8064: public static final int MPU_WR_WRITE = 0;
8065: public static final int MPU_WR_READ = 1;
8066:
8067:
8068: public static final int MPU_US_USER = 0;
8069: public static final int MPU_US_SUPERVISOR = 1;
8070:
8071:
8072: public static final MemoryMappedDevice[] busUserMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8073: public static final MemoryMappedDevice[] busSuperMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8074: public static MemoryMappedDevice[] busMemoryMap;
8075:
8076:
8077: public static boolean busHimem68000;
8078:
8079:
8080: public static final int BUS_HIGH_MEMORY_START = 0x01000000;
8081: public static int busHighMemorySize;
8082: public static byte[] busHighMemoryArray;
8083: public static boolean busHighMemorySaveOn;
8084: public static boolean busHighMemory060turboOn;
8085:
8086:
8087: public static final int BUS_LOCAL_MEMORY_START = 0x10000000;
8088: public static int busLocalMemorySize;
8089: public static byte[] busLocalMemoryArray;
8090: public static boolean busLocalMemorySaveOn;
8091:
8092:
8093: public static final byte[] BUS_DUMMY_MEMORY_ARRAY = new byte[0];
8094: public static int busRequestExMemoryStart;
8095: public static int busRequestExMemorySize;
8096: public static byte[] busRequestExMemoryArray;
8097: public static int busExMemoryStart;
8098: public static int busExMemorySize;
8099: public static byte[] busExMemoryArray;
8100:
8101:
8102: public static boolean busRequestCutFC2Pin;
8103: public static boolean busCutFC2Pin;
8104:
8105:
8106:
8107: public static void busInit () {
8108:
8109:
8110: if (!DataBreakPoint.DBP_ON) {
8111: busMemoryMap = busSuperMap;
8112: }
8113:
8114:
8115: int highMemorySizeMB = Settings.sgsGetInt ("highmemory");
8116: busHighMemorySize = highMemorySizeMB == 16 ? highMemorySizeMB << 20 : 0 << 20;
8117: if (busHighMemorySize == 0) {
8118: System.out.println (Multilingual.mlnJapanese ?
8119: "X68030/Xellent30 のハイメモリはありません" :
8120: "X68030/Xellent30 high memory does not exists");
8121: } else {
8122: System.out.printf (Multilingual.mlnJapanese ?
8123: "X68030/Xellent30 のハイメモリのサイズは %dMB です\n" :
8124: "X68030/Xellent30 high memory size is %dMB\n",
8125: busHighMemorySize >> 20);
8126: }
8127: busHighMemoryArray = new byte[busHighMemorySize];
8128:
8129: busHimem68000 = Settings.sgsGetOnOff ("himem68000");
8130:
8131: busHighMemorySaveOn = Settings.sgsGetOnOff ("highmemorysave");
8132: busHighMemory060turboOn = Settings.sgsGetOnOff ("highmemory060turbo");
8133:
8134: byte[] highMemoryArray = Settings.sgsGetData ("highmemorydata");
8135: if (busHighMemorySize != 0) {
8136: if (highMemoryArray.length != 0) {
8137: System.out.println (Multilingual.mlnJapanese ?
8138: "X68030/Xellent30 のハイメモリのデータを復元します" :
8139: "X68030/Xellent30 high memory data is restored");
8140: System.arraycopy (highMemoryArray, 0, busHighMemoryArray, 0, Math.min (highMemoryArray.length, busHighMemorySize));
8141: } else {
8142: System.out.println (Multilingual.mlnJapanese ?
8143: "X68030/Xellent30 のハイメモリをゼロクリアします" :
8144: "X68030/Xellent30 high memory is zero-cleared");
8145: }
8146: if (highMemoryArray.length < busHighMemorySize) {
8147: Arrays.fill (busHighMemoryArray, highMemoryArray.length, busHighMemorySize, (byte) 0);
8148: }
8149: }
8150:
8151:
8152: int localMemorySizeMB = Settings.sgsGetInt ("localmemory");
8153: busLocalMemorySize = (localMemorySizeMB == 16 ||
8154: localMemorySizeMB == 32 ||
8155: localMemorySizeMB == 64 ||
8156: localMemorySizeMB == 128 ||
8157: localMemorySizeMB == 256 ||
8158: localMemorySizeMB == 384 ||
8159: localMemorySizeMB == 512 ||
8160: localMemorySizeMB == 768 ?
8161: localMemorySizeMB << 20 :
8162: 128 << 20);
8163: if (busLocalMemorySize == 0) {
8164: System.out.println (Multilingual.mlnJapanese ?
8165: "060turbo のハイメモリはありません" :
8166: "060turbo high memory does not exists");
8167: } else {
8168: System.out.printf (Multilingual.mlnJapanese ?
8169: "060turbo のハイメモリのサイズは %dMB です\n" :
8170: "060turbo high memory size is %dMB\n",
8171: busLocalMemorySize >> 20);
8172: }
8173: busLocalMemoryArray = new byte[busLocalMemorySize];
8174:
8175: busLocalMemorySaveOn = Settings.sgsGetOnOff ("localmemorysave");
8176:
8177: byte[] localMemoryArray = Settings.sgsGetData ("localmemorydata");
8178: if (busLocalMemorySize != 0) {
8179: if (localMemoryArray.length != 0) {
8180: System.out.println (Multilingual.mlnJapanese ?
8181: "060turbo のハイメモリのデータを復元します" :
8182: "060turbo high memory data is restored");
8183: System.arraycopy (localMemoryArray, 0, busLocalMemoryArray, 0, Math.min (localMemoryArray.length, busLocalMemorySize));
8184: } else {
8185: System.out.println (Multilingual.mlnJapanese ?
8186: "060turbo のハイメモリをゼロクリアします" :
8187: "060turbo high memory is zero-cleared");
8188: }
8189: if (localMemoryArray.length < busLocalMemorySize) {
8190: Arrays.fill (busLocalMemoryArray, localMemoryArray.length, busLocalMemorySize, (byte) 0);
8191: }
8192: }
8193:
8194:
8195: busExMemoryStart = busRequestExMemoryStart = 0x10000000;
8196: busExMemorySize = busRequestExMemorySize = 0 << 20;
8197: busExMemoryArray = busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
8198:
8199:
8200: busRequestCutFC2Pin = Settings.sgsGetOnOff ("cutfc2pin");
8201: busCutFC2Pin = !busRequestCutFC2Pin;
8202:
8203: busUpdateMemoryMap ();
8204:
8205: }
8206:
8207:
8208:
8209: public static void busTini () {
8210: Settings.sgsPutOnOff ("himem68000", busHimem68000);
8211: Settings.sgsPutInt ("highmemory", busHighMemorySize >>> 20);
8212: Settings.sgsPutOnOff ("highmemorysave", busHighMemorySaveOn);
8213: Settings.sgsPutOnOff ("highmemory060turbo", busHighMemory060turboOn);
8214: Settings.sgsPutData ("highmemorydata", busHighMemorySaveOn ? busHighMemoryArray : new byte[0]);
8215: Settings.sgsPutInt ("localmemory", busLocalMemorySize >>> 20);
8216: Settings.sgsPutOnOff ("localmemorysave", busLocalMemorySaveOn);
8217: Settings.sgsPutData ("localmemorydata", busLocalMemorySaveOn ? busLocalMemoryArray : new byte[0]);
8218: Settings.sgsPutOnOff ("cutfc2pin", busRequestCutFC2Pin);
8219: }
8220:
8221: public static void busUpdateMemoryMap () {
8222: if (busExMemoryStart == busRequestExMemoryStart &&
8223: busExMemorySize == busRequestExMemorySize &&
8224: busExMemoryArray == busRequestExMemoryArray &&
8225: busExMemoryArray.length == busExMemorySize &&
8226: busCutFC2Pin == busRequestCutFC2Pin) {
8227: return;
8228: }
8229:
8230: busExMemoryStart = busRequestExMemoryStart;
8231: busExMemorySize = busRequestExMemorySize;
8232: busExMemoryArray = busRequestExMemoryArray;
8233: if (busExMemoryArray.length != busExMemorySize) {
8234: byte[] newArray = new byte[busExMemorySize];
8235: int copySize = Math.min (busExMemoryArray.length, busExMemorySize);
8236: if (copySize > 0) {
8237: System.arraycopy (busExMemoryArray, 0, newArray, 0, copySize);
8238: }
8239: if (busExMemoryArray == busHighMemoryArray) {
8240: busHighMemoryArray = newArray;
8241: } else if (busExMemoryArray == busLocalMemoryArray) {
8242: busLocalMemoryArray = newArray;
8243: }
8244: busExMemoryArray = newArray;
8245: }
8246:
8247: busCutFC2Pin = busRequestCutFC2Pin;
8248:
8249:
8250:
8251:
8252:
8253:
8254:
8255:
8256:
8257:
8258:
8259:
8260: busSuper (MemoryMappedDevice.MMD_MMR, 0x00000000, 0x00002000);
8261: busUser ( MemoryMappedDevice.MMD_MMR, 0x00002000, 0x00c00000);
8262:
8263:
8264:
8265:
8266:
8267:
8268:
8269:
8270:
8271:
8272:
8273:
8274:
8275:
8276:
8277:
8278:
8279:
8280:
8281:
8282:
8283:
8284:
8285:
8286: busSuper (MemoryMappedDevice.MMD_GE0, 0x00c00000, 0x00c80000);
8287: busSuper (MemoryMappedDevice.MMD_GE1, 0x00c80000, 0x00d00000);
8288: busSuper (MemoryMappedDevice.MMD_GE2, 0x00d00000, 0x00d80000);
8289: busSuper (MemoryMappedDevice.MMD_GE3, 0x00d80000, 0x00e00000);
8290:
8291:
8292:
8293:
8294: busSuper (MemoryMappedDevice.MMD_TXT, 0x00e00000, 0x00e80000);
8295:
8296:
8297:
8298:
8299: busSuper (MemoryMappedDevice.MMD_CRT, 0x00e80000, 0x00e82000);
8300:
8301:
8302:
8303:
8304:
8305: busSuper (MemoryMappedDevice.MMD_VCN, 0x00e82000, 0x00e84000);
8306:
8307:
8308:
8309:
8310: busSuper (MemoryMappedDevice.MMD_DMA, 0x00e84000, 0x00e86000);
8311:
8312:
8313:
8314:
8315: busSuper (MemoryMappedDevice.MMD_SVS, 0x00e86000, 0x00e88000);
8316:
8317:
8318:
8319:
8320: busSuper (MemoryMappedDevice.MMD_MFP, 0x00e88000, 0x00e8a000);
8321:
8322:
8323:
8324:
8325: busSuper (MemoryMappedDevice.MMD_RTC_FIRST, 0x00e8a000, 0x00e8c000);
8326:
8327:
8328:
8329:
8330: busSuper (MemoryMappedDevice.MMD_PRN, 0x00e8c000, 0x00e8e000);
8331:
8332:
8333:
8334:
8335: busSuper (MemoryMappedDevice.MMD_SYS, 0x00e8e000, 0x00e90000);
8336:
8337:
8338:
8339:
8340: busSuper (MemoryMappedDevice.MMD_OPM, 0x00e90000, 0x00e92000);
8341:
8342:
8343:
8344:
8345: busSuper (MemoryMappedDevice.MMD_PCM, 0x00e92000, 0x00e94000);
8346:
8347:
8348:
8349:
8350: busSuper (MemoryMappedDevice.MMD_FDC, 0x00e94000, 0x00e96000);
8351:
8352:
8353:
8354:
8355:
8356: busSuper (MemoryMappedDevice.MMD_HDC, 0x00e96000, 0x00e98000);
8357:
8358:
8359:
8360:
8361: busSuper (MemoryMappedDevice.MMD_SCC, 0x00e98000, 0x00e9a000);
8362:
8363:
8364:
8365:
8366: busSuper (MemoryMappedDevice.MMD_PPI, 0x00e9a000, 0x00e9c000);
8367:
8368:
8369:
8370:
8371: busSuper (MemoryMappedDevice.MMD_IOI, 0x00e9c000, 0x00e9e000);
8372:
8373:
8374:
8375:
8376:
8377:
8378:
8379:
8380:
8381: busSuper (MemoryMappedDevice.MMD_XB1, 0x00e9e000, 0x00ea0000);
8382:
8383:
8384:
8385:
8386:
8387: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ea0000, 0x00eae000);
8388:
8389:
8390:
8391:
8392:
8393:
8394:
8395:
8396:
8397:
8398:
8399:
8400:
8401:
8402:
8403: busSuper (MemoryMappedDevice.MMD_XB2, 0x00eae000, 0x00eb0000);
8404:
8405:
8406:
8407:
8408:
8409:
8410:
8411:
8412: busSuper (MemoryMappedDevice.MMD_SPR, 0x00eb0000, 0x00ec0000);
8413:
8414:
8415:
8416:
8417:
8418:
8419:
8420:
8421:
8422:
8423:
8424:
8425:
8426: busSuper (MemoryMappedDevice.MMD_XB3, 0x00ec0000, 0x00ed0000);
8427:
8428:
8429:
8430:
8431:
8432:
8433: busSuper (MemoryMappedDevice.MMD_SMR, 0x00ed0000, 0x00ed0000 + 16384);
8434: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ed0000 + 16384, 0x00ed0000 + 65536);
8435:
8436:
8437:
8438:
8439:
8440:
8441:
8442:
8443: busSuper (MemoryMappedDevice.MMD_XB4, 0x00ee0000, 0x00f00000);
8444:
8445:
8446:
8447:
8448:
8449:
8450:
8451:
8452:
8453:
8454: busSuper (MemoryMappedDevice.MMD_ROM, 0x00f00000, 0x00f40000);
8455:
8456:
8457:
8458:
8459:
8460:
8461:
8462: busSuper (MemoryMappedDevice.MMD_ROM, 0x00f40000, 0x00fc0000);
8463:
8464:
8465:
8466:
8467:
8468:
8469:
8470:
8471:
8472:
8473:
8474:
8475:
8476:
8477: busSuper (MemoryMappedDevice.MMD_ROM, 0x00fc0000, 0x01000000);
8478:
8479: }
8480:
8481: public static void busReset () {
8482: if (regSRS != 0) {
8483: if (DataBreakPoint.DBP_ON) {
8484: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpSuperMap;
8485: } else {
8486: busMemoryMap = busSuperMap;
8487: }
8488: } else {
8489: if (DataBreakPoint.DBP_ON) {
8490: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpUserMap;
8491: } else {
8492: busMemoryMap = busUserMap;
8493: }
8494: }
8495: }
8496:
8497:
8498:
8499:
8500:
8501: public static void busUser (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8502: if (MC68060.CAT_ON) {
8503: if (Model.MPU_MC68LC060 <= currentMPU) {
8504: mmd = (mmd == MemoryMappedDevice.MMD_MMR ? MemoryMappedDevice.MMD_MM6 :
8505: mmd == MemoryMappedDevice.MMD_ROM ? MemoryMappedDevice.MMD_RO6 :
8506: mmd);
8507: }
8508: }
8509: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8510: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8511: if (false &&
8512: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8513: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8514: System.out.printf ("ERROR: busUser (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8515: }
8516: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8517: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8518: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8519: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8520: int startPage = blockStartPage + motherStartPage;
8521: int endPage = blockStartPage + motherEndPage;
8522: for (int page = startPage; page < endPage; page++) {
8523: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
8524: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
8525: if (MC68060.CAT_ON) {
8526: if (Model.MPU_MC68LC060 <= currentMPU &&
8527: isExMemory) {
8528: superMmd = MemoryMappedDevice.MMD_XM6;
8529: }
8530: }
8531: busUserMap[page] = busSuperMap[page] = superMmd;
8532: if (InstructionBreakPoint.IBP_ON) {
8533: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8534: InstructionBreakPoint.ibpUserMap[page] = superMmd;
8535: }
8536: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8537: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8538: }
8539: }
8540: if (DataBreakPoint.DBP_ON) {
8541: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8542: DataBreakPoint.dbpUserMap[page] = superMmd;
8543: }
8544: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8545: DataBreakPoint.dbpSuperMap[page] = superMmd;
8546: }
8547: }
8548: }
8549: }
8550: }
8551:
8552:
8553:
8554:
8555:
8556: public static void busSuper (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8557: if (MC68060.CAT_ON) {
8558: if (Model.MPU_MC68LC060 <= currentMPU) {
8559: mmd = (mmd == MemoryMappedDevice.MMD_MMR ? MemoryMappedDevice.MMD_MM6 :
8560: mmd == MemoryMappedDevice.MMD_ROM ? MemoryMappedDevice.MMD_RO6 :
8561: mmd);
8562: }
8563: }
8564: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8565: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8566: if (false &&
8567: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8568: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8569: System.out.printf ("ERROR: busSuper (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8570: }
8571: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8572: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8573: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8574: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8575: int startPage = blockStartPage + motherStartPage;
8576: int endPage = blockStartPage + motherEndPage;
8577: for (int page = startPage; page < endPage; page++) {
8578: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
8579: MemoryMappedDevice userMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : busCutFC2Pin ? mmd : MemoryMappedDevice.MMD_NUL;
8580: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
8581: if (MC68060.CAT_ON) {
8582: if (Model.MPU_MC68LC060 <= currentMPU &&
8583: isExMemory) {
8584: userMmd = MemoryMappedDevice.MMD_XM6;
8585: superMmd = MemoryMappedDevice.MMD_XM6;
8586: }
8587: }
8588: busUserMap[page] = userMmd;
8589: busSuperMap[page] = superMmd;
8590: if (InstructionBreakPoint.IBP_ON) {
8591: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8592: InstructionBreakPoint.ibpUserMap[page] = userMmd;
8593: }
8594: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8595: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8596: }
8597: }
8598: if (DataBreakPoint.DBP_ON) {
8599: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8600: DataBreakPoint.dbpUserMap[page] = userMmd;
8601: }
8602: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8603: DataBreakPoint.dbpSuperMap[page] = superMmd;
8604: }
8605: }
8606: }
8607: }
8608: }
8609:
8610:
8611:
8612: public static byte busPbs (int a) {
8613: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a);
8614: }
8615:
8616:
8617:
8618: public static int busPbz (int a) {
8619: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a);
8620: }
8621:
8622:
8623:
8624: public static int busPws (int a) {
8625: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8626: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
8627: } else {
8628: int a1 = a + 1;
8629: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
8630: }
8631: }
8632:
8633:
8634:
8635: public static int busPwse (int a) {
8636: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
8637: }
8638:
8639:
8640:
8641: public static int busPwz (int a) {
8642: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8643: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
8644: } else {
8645: int a1 = a + 1;
8646: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
8647: }
8648: }
8649:
8650:
8651:
8652: public static int busPwze (int a) {
8653: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
8654: }
8655:
8656:
8657:
8658: public static int busPls (int a) {
8659: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8660: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
8661: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8662: int a2 = a + 2;
8663: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a) << 16 | busSuperMap[a2 >>> BUS_PAGE_BITS].mmdPwz (a2);
8664: } else {
8665: int a1 = a + 1;
8666: int a3 = a + 3;
8667: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 24 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPwz (a1) << 8 | busSuperMap[a3 >>> BUS_PAGE_BITS].mmdPbz (a3);
8668: }
8669: }
8670:
8671:
8672:
8673: public static int busPlsf (int a) {
8674: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
8675: }
8676:
8677:
8678:
8679: public static long busPqs (int a) {
8680: return (long) busPls (a) << 32 | busPls (a + 4) & 0xffffffffL;
8681: }
8682:
8683:
8684:
8685: public static int busSearchByte (int start, int end, int c) {
8686: for (int a = start; a < end; a++) {
8687: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) == c) {
8688: return a;
8689: }
8690: }
8691: return -1;
8692: }
8693: public static int busSearchWord (int start, int end, int c) {
8694: for (int a = start; a < end; a += 2) {
8695: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) == c) {
8696: return a;
8697: }
8698: }
8699: return -1;
8700: }
8701: public static int busSearchByteArray (int start, int end, int[] array) {
8702: int l = array.length;
8703: end -= l;
8704: int c = array[0];
8705: a:
8706: for (int a = start; a <= end; a++) {
8707: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) != c) {
8708: continue a;
8709: }
8710: for (int i = 1, b = a + 1; i < l; i++, b++) {
8711: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPbz (b) != array[i]) {
8712: continue a;
8713: }
8714: }
8715: return a;
8716: }
8717: return -1;
8718: }
8719: public static int busSearchWordArray (int start, int end, int[] array) {
8720: int l = array.length;
8721: end -= l;
8722: int c = array[0];
8723: a:
8724: for (int a = start; a <= end; a += 2) {
8725: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) != c) {
8726: continue a;
8727: }
8728: for (int i = 1, b = a + 2; i < l; i++, b += 2) {
8729: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPwz (b) != array[i]) {
8730: continue a;
8731: }
8732: }
8733: return a;
8734: }
8735: return -1;
8736: }
8737:
8738:
8739:
8740:
8741: public static byte busRbs (int a) throws M68kException {
8742: if (DataBreakPoint.DBP_ON) {
8743: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
8744: } else {
8745: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
8746: }
8747: }
8748:
8749:
8750:
8751: public static int busRbz (int a) throws M68kException {
8752: if (DataBreakPoint.DBP_ON) {
8753: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
8754: } else {
8755: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
8756: }
8757: }
8758:
8759:
8760:
8761: public static int busRws (int a) throws M68kException {
8762: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8763: if (DataBreakPoint.DBP_ON) {
8764: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8765: } else {
8766: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8767: }
8768: } else if (mpuIgnoreAddressError) {
8769: int a1 = a + 1;
8770: if (DataBreakPoint.DBP_ON) {
8771: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8772: } else {
8773: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8774: }
8775: } else {
8776: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8777: M68kException.m6eAddress = a;
8778: M68kException.m6eDirection = MPU_WR_READ;
8779: M68kException.m6eSize = MPU_SS_WORD;
8780: throw M68kException.m6eSignal;
8781: }
8782: }
8783:
8784:
8785:
8786:
8787: public static int busRwse (int a) throws M68kException {
8788: if (DataBreakPoint.DBP_ON) {
8789: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8790: } else {
8791: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8792: }
8793: }
8794:
8795:
8796:
8797: public static int busRwz (int a) throws M68kException {
8798: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8799: if (DataBreakPoint.DBP_ON) {
8800: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8801: } else {
8802: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8803: }
8804: } else if (mpuIgnoreAddressError) {
8805: int a1 = a + 1;
8806: if (DataBreakPoint.DBP_ON) {
8807: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8808: } else {
8809: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8810: }
8811: } else {
8812: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8813: M68kException.m6eAddress = a;
8814: M68kException.m6eDirection = MPU_WR_READ;
8815: M68kException.m6eSize = MPU_SS_WORD;
8816: throw M68kException.m6eSignal;
8817: }
8818: }
8819:
8820:
8821:
8822:
8823: public static int busRwze (int a) throws M68kException {
8824: if (DataBreakPoint.DBP_ON) {
8825: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8826: } else {
8827: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8828: }
8829: }
8830:
8831:
8832:
8833: public static int busRls (int a) throws M68kException {
8834: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8835: if (DataBreakPoint.DBP_ON) {
8836: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8837: } else {
8838: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8839: }
8840: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8841: int a2 = a + 2;
8842: if (BUS_SPLIT_UNALIGNED_LONG) {
8843: if (DataBreakPoint.DBP_ON) {
8844: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8845: } else {
8846: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8847: }
8848: } else {
8849: MemoryMappedDevice mmd;
8850: MemoryMappedDevice mmd2;
8851: if (DataBreakPoint.DBP_ON) {
8852: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8853: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8854: } else {
8855: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8856: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8857: }
8858: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
8859: }
8860: } else if (mpuIgnoreAddressError) {
8861: int a1 = a + 1;
8862: int a3 = a + 3;
8863: if (DataBreakPoint.DBP_ON) {
8864: 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);
8865: } else {
8866: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 24 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRwz (a1) << 8 | busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdRbz (a3);
8867: }
8868: } else {
8869: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8870: M68kException.m6eAddress = a;
8871: M68kException.m6eDirection = MPU_WR_READ;
8872: M68kException.m6eSize = MPU_SS_LONG;
8873: throw M68kException.m6eSignal;
8874: }
8875: }
8876:
8877:
8878:
8879:
8880: public static int busRlse (int a) throws M68kException {
8881: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8882: if (DataBreakPoint.DBP_ON) {
8883: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8884: } else {
8885: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8886: }
8887: } else {
8888: int a2 = a + 2;
8889: if (BUS_SPLIT_UNALIGNED_LONG) {
8890: if (DataBreakPoint.DBP_ON) {
8891: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8892: } else {
8893: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8894: }
8895: } else {
8896: MemoryMappedDevice mmd;
8897: MemoryMappedDevice mmd2;
8898: if (DataBreakPoint.DBP_ON) {
8899: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8900: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8901: } else {
8902: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8903: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8904: }
8905: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
8906: }
8907: }
8908: }
8909:
8910:
8911:
8912:
8913: public static int busRlsf (int a) throws M68kException {
8914: if (DataBreakPoint.DBP_ON) {
8915: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8916: } else {
8917: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8918: }
8919: }
8920:
8921:
8922:
8923: public static long busRqs (int a) throws M68kException {
8924: return (long) busRls (a) << 32 | busRls (a + 4) & 0xffffffffL;
8925: }
8926:
8927:
8928:
8929: public static void busWb (int a, int d) throws M68kException {
8930: if (DataBreakPoint.DBP_ON) {
8931: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
8932: } else {
8933: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
8934: }
8935: }
8936:
8937:
8938:
8939: public static void busWw (int a, int d) throws M68kException {
8940: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8941: if (DataBreakPoint.DBP_ON) {
8942: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8943: } else {
8944: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8945: }
8946: } else if (mpuIgnoreAddressError) {
8947: int a1 = a + 1;
8948: if (DataBreakPoint.DBP_ON) {
8949: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
8950: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
8951: } else {
8952: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
8953: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
8954: }
8955: } else {
8956: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8957: M68kException.m6eAddress = a;
8958: M68kException.m6eDirection = MPU_WR_WRITE;
8959: M68kException.m6eSize = MPU_SS_WORD;
8960: throw M68kException.m6eSignal;
8961: }
8962: }
8963:
8964:
8965:
8966:
8967: public static void busWwe (int a, int d) throws M68kException {
8968: if (DataBreakPoint.DBP_ON) {
8969: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8970: } else {
8971: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8972: }
8973: }
8974:
8975:
8976:
8977: public static void busWl (int a, int d) throws M68kException {
8978: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8979: if (DataBreakPoint.DBP_ON) {
8980: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8981: } else {
8982: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8983: }
8984: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8985: int a2 = a + 2;
8986: if (BUS_SPLIT_UNALIGNED_LONG) {
8987: if (DataBreakPoint.DBP_ON) {
8988: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8989: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8990: } else {
8991: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8992: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8993: }
8994: } else {
8995: MemoryMappedDevice mmd;
8996: MemoryMappedDevice mmd2;
8997: if (DataBreakPoint.DBP_ON) {
8998: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8999: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9000: } else {
9001: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9002: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9003: }
9004: if (mmd == mmd2) {
9005: mmd.mmdWl (a, d);
9006: } else {
9007: mmd.mmdWw (a, d >> 16);
9008: mmd2.mmdWw (a2, d);
9009: }
9010: }
9011: } else if (mpuIgnoreAddressError) {
9012: int a1 = a + 1;
9013: int a3 = a + 3;
9014: if (DataBreakPoint.DBP_ON) {
9015: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
9016: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
9017: DataBreakPoint.dbpMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
9018: } else {
9019: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
9020: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
9021: busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
9022: }
9023: } else {
9024: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9025: M68kException.m6eAddress = a;
9026: M68kException.m6eDirection = MPU_WR_WRITE;
9027: M68kException.m6eSize = MPU_SS_LONG;
9028: throw M68kException.m6eSignal;
9029: }
9030: }
9031:
9032:
9033:
9034:
9035: public static void busWlf (int a, int d) throws M68kException {
9036: if (DataBreakPoint.DBP_ON) {
9037: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9038: } else {
9039: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9040: }
9041: }
9042:
9043:
9044:
9045:
9046: public static void busWle (int a, int d) throws M68kException {
9047: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9048: if (DataBreakPoint.DBP_ON) {
9049: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9050: } else {
9051: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9052: }
9053: } else {
9054: int a2 = a + 2;
9055: if (BUS_SPLIT_UNALIGNED_LONG) {
9056: if (DataBreakPoint.DBP_ON) {
9057: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9058: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9059: } else {
9060: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9061: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9062: }
9063: } else {
9064: MemoryMappedDevice mmd;
9065: MemoryMappedDevice mmd2;
9066: if (DataBreakPoint.DBP_ON) {
9067: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9068: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9069: } else {
9070: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9071: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9072: }
9073: if (mmd == mmd2) {
9074: mmd.mmdWl (a, d);
9075: } else {
9076: mmd.mmdWw (a, d >> 16);
9077: mmd2.mmdWw (a2, d);
9078: }
9079: }
9080: }
9081: }
9082:
9083:
9084:
9085: public static void busWq (int a, long d) throws M68kException {
9086: busWl (a, (int) (d >>> 32));
9087: busWl (a + 4, (int) d);
9088: }
9089:
9090:
9091:
9092:
9093:
9094: public static void busRbb (int a, byte[] bb, int o, int l) throws M68kException {
9095: if (false) {
9096: for (int i = 0; i < l; i++) {
9097: int ai = a + i;
9098: if (DataBreakPoint.DBP_ON) {
9099: bb[o + i] = DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9100: } else {
9101: bb[o + i] = busMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9102: }
9103: }
9104: } else {
9105: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9106: while (l > 0) {
9107: MemoryMappedDevice mmd;
9108: if (DataBreakPoint.DBP_ON) {
9109: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9110: } else {
9111: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9112: }
9113: int s = l <= r ? l : r;
9114: l -= s;
9115: if (true) {
9116: for (s -= 16; s >= 0; s -= 16) {
9117: bb[o ] = mmd.mmdRbs (a );
9118: bb[o + 1] = mmd.mmdRbs (a + 1);
9119: bb[o + 2] = mmd.mmdRbs (a + 2);
9120: bb[o + 3] = mmd.mmdRbs (a + 3);
9121: bb[o + 4] = mmd.mmdRbs (a + 4);
9122: bb[o + 5] = mmd.mmdRbs (a + 5);
9123: bb[o + 6] = mmd.mmdRbs (a + 6);
9124: bb[o + 7] = mmd.mmdRbs (a + 7);
9125: bb[o + 8] = mmd.mmdRbs (a + 8);
9126: bb[o + 9] = mmd.mmdRbs (a + 9);
9127: bb[o + 10] = mmd.mmdRbs (a + 10);
9128: bb[o + 11] = mmd.mmdRbs (a + 11);
9129: bb[o + 12] = mmd.mmdRbs (a + 12);
9130: bb[o + 13] = mmd.mmdRbs (a + 13);
9131: bb[o + 14] = mmd.mmdRbs (a + 14);
9132: bb[o + 15] = mmd.mmdRbs (a + 15);
9133: a += 16;
9134: o += 16;
9135: }
9136: s += 16;
9137: }
9138: for (int i = 0; i < s; i++) {
9139: bb[o + i] = mmd.mmdRbs (a + i);
9140: }
9141: a += s;
9142: o += s;
9143: r = BUS_PAGE_SIZE;
9144: }
9145: }
9146: }
9147:
9148:
9149:
9150: public static void busWbb (int a, byte[] bb, int o, int l) throws M68kException {
9151: if (false) {
9152: for (int i = 0; i < l; i++) {
9153: int ai = a + i;
9154: if (DataBreakPoint.DBP_ON) {
9155: DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9156: } else {
9157: busMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9158: }
9159: }
9160: } else {
9161: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9162: while (l > 0) {
9163: MemoryMappedDevice mmd;
9164: if (DataBreakPoint.DBP_ON) {
9165: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9166: } else {
9167: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9168: }
9169: int s = l <= r ? l : r;
9170: l -= s;
9171: if (true) {
9172: for (s -= 16; s >= 0; s -= 16) {
9173: mmd.mmdWb (a , bb[o ]);
9174: mmd.mmdWb (a + 1, bb[o + 1]);
9175: mmd.mmdWb (a + 2, bb[o + 2]);
9176: mmd.mmdWb (a + 3, bb[o + 3]);
9177: mmd.mmdWb (a + 4, bb[o + 4]);
9178: mmd.mmdWb (a + 5, bb[o + 5]);
9179: mmd.mmdWb (a + 6, bb[o + 6]);
9180: mmd.mmdWb (a + 7, bb[o + 7]);
9181: mmd.mmdWb (a + 8, bb[o + 8]);
9182: mmd.mmdWb (a + 9, bb[o + 9]);
9183: mmd.mmdWb (a + 10, bb[o + 10]);
9184: mmd.mmdWb (a + 11, bb[o + 11]);
9185: mmd.mmdWb (a + 12, bb[o + 12]);
9186: mmd.mmdWb (a + 13, bb[o + 13]);
9187: mmd.mmdWb (a + 14, bb[o + 14]);
9188: mmd.mmdWb (a + 15, bb[o + 15]);
9189: a += 16;
9190: o += 16;
9191: }
9192: s += 16;
9193: }
9194: for (int i = 0; i < s; i++) {
9195: mmd.mmdWb (a + i, bb[o + i]);
9196: }
9197: a += s;
9198: o += s;
9199: r = BUS_PAGE_SIZE;
9200: }
9201: }
9202: }
9203:
9204:
9205:
9206: public static void busVb (int a, int d) {
9207: try {
9208: if (DataBreakPoint.DBP_ON) {
9209: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9210: } else {
9211: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9212: }
9213: } catch (M68kException e) {
9214: }
9215: }
9216:
9217:
9218:
9219: public static void busVw (int a, int d) {
9220: try {
9221: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9222: if (DataBreakPoint.DBP_ON) {
9223: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9224: } else {
9225: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9226: }
9227: }
9228: } catch (M68kException e) {
9229: }
9230: }
9231:
9232:
9233:
9234: public static void busVl (int a, int d) {
9235: try {
9236: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9237: if (DataBreakPoint.DBP_ON) {
9238: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9239: } else {
9240: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9241: }
9242: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9243: int a2 = a + 2;
9244: MemoryMappedDevice mmd;
9245: MemoryMappedDevice mmd2;
9246: if (DataBreakPoint.DBP_ON) {
9247: mmd = (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS];
9248: mmd2 = (regSRS != 0 ? busSuperMap : busUserMap)[a2 >>> BUS_PAGE_BITS];
9249: } else {
9250: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9251: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9252: }
9253: if (mmd == mmd2) {
9254: mmd.mmdWl (a, d);
9255: } else {
9256: mmd.mmdWw (a, d >> 16);
9257: mmd2.mmdWw (a2, d);
9258: }
9259: }
9260: } catch (M68kException e) {
9261: }
9262: }
9263:
9264:
9265:
9266:
9267:
9268: public static final int SVS_AREASET = 0x00e86001;
9269:
9270:
9271:
9272:
9273:
9274:
9275:
9276:
9277:
9278: public static void svsInit () {
9279: }
9280:
9281:
9282:
9283:
9284:
9285:
9286:
9287:
9288:
9289:
9290:
9291:
9292:
9293:
9294:
9295:
9296:
9297:
9298:
9299:
9300:
9301:
9302:
9303:
9304:
9305:
9306:
9307:
9308:
9309:
9310:
9311:
9312:
9313:
9314:
9315: public static boolean sysNMIFlag;
9316:
9317:
9318:
9319: public static void sysInit () {
9320: sysNMIFlag = false;
9321: }
9322:
9323:
9324:
9325:
9326:
9327:
9328: public static int sysAcknowledge () {
9329: return M68kException.M6E_LEVEL_7_INTERRUPT_AUTOVECTOR;
9330: }
9331:
9332:
9333:
9334:
9335: public static void sysDone () {
9336: if (sysNMIFlag) {
9337: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9338: }
9339: }
9340:
9341:
9342:
9343: public static void sysInterrupt () {
9344: sysNMIFlag = true;
9345: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9346: }
9347:
9348:
9349:
9350: public static void sysResetNMI () {
9351: sysNMIFlag = false;
9352: }
9353:
9354:
9355:
9356:
9357:
9358:
9359: public static final int EB2_SPC_REQUEST = 0x4000;
9360: public static final int EB2_SPC_VECTOR = 0xf6;
9361:
9362:
9363:
9364: public static int eb2Request;
9365:
9366:
9367:
9368: public static void eb2Reset () {
9369: eb2Request = 0;
9370: }
9371:
9372:
9373:
9374:
9375:
9376: public static void eb2Interrupt (int mask) {
9377: eb2Request |= mask;
9378: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9379: }
9380:
9381:
9382:
9383:
9384:
9385:
9386:
9387: public static int eb2Acknowledge () {
9388: if ((eb2Request & EB2_SPC_REQUEST) != 0) {
9389: eb2Request &= ~EB2_SPC_REQUEST;
9390: return EB2_SPC_VECTOR;
9391: }
9392: return 0;
9393: }
9394:
9395:
9396:
9397:
9398:
9399: public static void eb2Done () {
9400: if (eb2Request != 0) {
9401: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9402: }
9403: }
9404:
9405:
9406:
9407:
9408:
9409:
9410:
9411:
9412:
9413:
9414:
9415:
9416:
9417:
9418:
9419:
9420:
9421:
9422:
9423:
9424:
9425:
9426:
9427:
9428:
9429:
9430:
9431:
9432:
9433:
9434:
9435:
9436:
9437:
9438:
9439:
9440:
9441:
9442:
9443:
9444:
9445:
9446:
9447:
9448:
9449:
9450:
9451:
9452:
9453:
9454:
9455:
9456:
9457:
9458:
9459:
9460:
9461:
9462:
9463:
9464:
9465:
9466:
9467:
9468: public static final int BNK_SIZE = 1024 * 1024 * 32;
9469: public static byte[] bnkMemory;
9470: public static int bnkPageStart;
9471: public static boolean bnkOn;
9472:
9473: public static void bnkInit () {
9474: bnkMemory = new byte[BNK_SIZE];
9475: byte[] array = Settings.sgsGetData ("bankdata");
9476: if (array.length != 0) {
9477: System.arraycopy (array, 0, bnkMemory, 0, Math.min (array.length, BNK_SIZE));
9478: }
9479: bnkPageStart = 0;
9480:
9481: bnkOn = false;
9482: }
9483:
9484: public static void bnkTini () {
9485: Settings.sgsPutData ("bankdata", bnkMemory, 0, BNK_SIZE);
9486: }
9487:
9488:
9489:
9490:
9491:
9492:
9493:
9494: public static ExpressionEvaluator fpuMotherboardCoprocessor;
9495: public static ExpressionEvaluator fpuOnChipFPU;
9496: public static ExpressionEvaluator fpuBox;
9497:
9498:
9499: public static EFPBox fpuCoproboard1;
9500: public static EFPBox fpuCoproboard2;
9501:
9502:
9503: public static EFPBox.EFP[] fpuFPn;
9504:
9505:
9506:
9507: public static final int FPU_FPCR_BSUN = 0b00000000_00000000_10000000_00000000;
9508: public static final int FPU_FPCR_SNAN = 0b00000000_00000000_01000000_00000000;
9509: public static final int FPU_FPCR_OPERR = 0b00000000_00000000_00100000_00000000;
9510: public static final int FPU_FPCR_OVFL = 0b00000000_00000000_00010000_00000000;
9511: public static final int FPU_FPCR_UNFL = 0b00000000_00000000_00001000_00000000;
9512: public static final int FPU_FPCR_DZ = 0b00000000_00000000_00000100_00000000;
9513: public static final int FPU_FPCR_INEX2 = 0b00000000_00000000_00000010_00000000;
9514: public static final int FPU_FPCR_INEX1 = 0b00000000_00000000_00000001_00000000;
9515:
9516:
9517: public static final int FPU_FPCR_PE = 0b00000000_00000000_00000000_00000000;
9518: public static final int FPU_FPCR_PS = 0b00000000_00000000_00000000_01000000;
9519: public static final int FPU_FPCR_PD = 0b00000000_00000000_00000000_10000000;
9520:
9521: public static final int FPU_FPCR_RN = 0b00000000_00000000_00000000_00000000;
9522: public static final int FPU_FPCR_RZ = 0b00000000_00000000_00000000_00010000;
9523: public static final int FPU_FPCR_RM = 0b00000000_00000000_00000000_00100000;
9524: public static final int FPU_FPCR_RP = 0b00000000_00000000_00000000_00110000;
9525:
9526:
9527:
9528: public static final int FPU_FPSR_N = 0b00001000_00000000_00000000_00000000;
9529: public static final int FPU_FPSR_Z = 0b00000100_00000000_00000000_00000000;
9530: public static final int FPU_FPSR_I = 0b00000010_00000000_00000000_00000000;
9531: public static final int FPU_FPSR_NAN = 0b00000001_00000000_00000000_00000000;
9532:
9533: public static final int FPU_FPSR_S = 0b00000000_10000000_00000000_00000000;
9534: public static final int FPU_FPSR_QUOTIENT = 0b00000000_01111111_00000000_00000000;
9535:
9536: public static final int FPU_FPSR_EXC_BSUN = 0b00000000_00000000_10000000_00000000;
9537: public static final int FPU_FPSR_EXC_SNAN = 0b00000000_00000000_01000000_00000000;
9538: public static final int FPU_FPSR_EXC_OPERR = 0b00000000_00000000_00100000_00000000;
9539: public static final int FPU_FPSR_EXC_OVFL = 0b00000000_00000000_00010000_00000000;
9540: public static final int FPU_FPSR_EXC_UNFL = 0b00000000_00000000_00001000_00000000;
9541: public static final int FPU_FPSR_EXC_DZ = 0b00000000_00000000_00000100_00000000;
9542: public static final int FPU_FPSR_EXC_INEX2 = 0b00000000_00000000_00000010_00000000;
9543: public static final int FPU_FPSR_EXC_INEX1 = 0b00000000_00000000_00000001_00000000;
9544:
9545: public static final int FPU_FPSR_AEXC_IOP = 0b00000000_00000000_00000000_10000000;
9546: public static final int FPU_FPSR_AEXC_OVFL = 0b00000000_00000000_00000000_01000000;
9547: public static final int FPU_FPSR_AEXC_UNFL = 0b00000000_00000000_00000000_00100000;
9548: public static final int FPU_FPSR_AEXC_DZ = 0b00000000_00000000_00000000_00010000;
9549: public static final int FPU_FPSR_AEXC_INEX = 0b00000000_00000000_00000000_00001000;
9550:
9551:
9552:
9553:
9554:
9555:
9556:
9557: public static final int[] FPU_FPSR_EXC_TO_AEXC = new int[256];
9558:
9559:
9560:
9561:
9562:
9563:
9564:
9565:
9566:
9567:
9568:
9569:
9570:
9571:
9572:
9573:
9574:
9575:
9576:
9577:
9578:
9579:
9580:
9581:
9582: public static final boolean[] FPU_CCMAP_882 = {
9583:
9584:
9585: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9586: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9587: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9588: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9589: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9590: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9591: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9592: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9593: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9594: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9595: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9596: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9597: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9598: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9599: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9600: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9601:
9602:
9603: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9604: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9605: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9606: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9607: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9608: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9609: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9610: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9611: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9612: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9613: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9614: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9615: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9616: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9617: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9618: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9619:
9620: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9621: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9622: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9623: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9624: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9625: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9626: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9627: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9628: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9629: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9630: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9631: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9632: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9633: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9634: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9635: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9636:
9637: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9638: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9639: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9640: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9641: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9642: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9643: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9644: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9645: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9646: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9647: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9648: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9649: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9650: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9651: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9652: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9653: };
9654:
9655:
9656:
9657:
9658:
9659:
9660:
9661: public static final boolean[] FPU_CCMAP_060 = {
9662:
9663:
9664: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9665: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9666: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9667: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9668: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9669: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9670: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9671: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9672: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9673: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9674: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9675: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9676: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9677: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9678: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9679: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9680:
9681:
9682: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9683: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9684: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9685: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9686: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9687: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9688: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9689: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9690: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9691: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9692: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9693: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9694: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9695: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9696: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9697: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9698:
9699: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9700: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9701: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9702: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9703: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9704: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9705: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9706: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9707: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9708: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9709: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9710: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9711: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9712: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9713: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9714: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9715:
9716: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9717: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9718: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9719: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9720: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9721: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9722: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9723: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9724: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9725: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9726: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9727: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9728: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9729: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9730: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9731: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9732: };
9733:
9734:
9735:
9736:
9737: public static void fpuInit () {
9738: for (int i = 0; i < 256; i++) {
9739: 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) |
9740: ((i << 8 & FPU_FPSR_EXC_OVFL) != 0 ? FPU_FPSR_AEXC_OVFL : 0) |
9741: ((i << 8 & (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2)) == (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2) ? FPU_FPSR_AEXC_UNFL : 0) |
9742: ((i << 8 & FPU_FPSR_EXC_DZ) != 0 ? FPU_FPSR_AEXC_DZ : 0) |
9743: ((i << 8 & (FPU_FPSR_EXC_OVFL | FPU_FPSR_EXC_INEX2 | FPU_FPSR_EXC_INEX1)) != 0 ? FPU_FPSR_AEXC_INEX : 0));
9744: }
9745:
9746: fpuMotherboardCoprocessor = new ExpressionEvaluator ();
9747:
9748: fpuOnChipFPU = new ExpressionEvaluator ();
9749:
9750: fpuBox = currentMPU < Model.MPU_MC68LC040 ? fpuMotherboardCoprocessor : fpuOnChipFPU;
9751:
9752: fpuFPn = fpuBox.epbFPn;
9753:
9754: fpuCoproboard1 = new EFPBox ();
9755: fpuCoproboard2 = new EFPBox ();
9756: }
9757:
9758:
9759:
9760:
9761:
9762:
9763: public static final boolean DBG_ORI_BYTE_ZERO_D0 = true;
9764:
9765: public static boolean dbgHexSelected;
9766: public static int dbgHexValue;
9767: public static int dbgSupervisorMode;
9768: public static JPopupMenu dbgPopupMenu;
9769: public static JMenu dbgPopupIBPMenu;
9770: public static SpinnerNumberModel dbgPopupIBPCurrentModel;
9771: public static int dbgPopupIBPCurrentValue;
9772: public static SpinnerNumberModel dbgPopupIBPThresholdModel;
9773: public static int dbgPopupIBPThresholdValue;
9774: public static JMenuItem dbgPopupIBPClearMenuItem;
9775: public static JMenu dbgPopupHexMenu;
9776: public static JMenuItem dbgPopupDisMenuItem;
9777: public static JMenuItem dbgPopupMemMenuItem;
9778: public static JMenuItem dbgPopupCopyMenuItem;
9779: public static JMenuItem dbgPopupSelectAllMenuItem;
9780: public static JTextArea dbgPopupTextArea;
9781: public static int dbgEventMask;
9782: public static boolean dbgStopOnError;
9783: public static boolean dbgOriByteZeroD0;
9784: public static boolean dbgStopAtStart;
9785:
9786:
9787:
9788: public static final char[] DBG_SPACES = (
9789:
9790:
9791: " ").toCharArray ();
9792:
9793: public static final int DBG_DRP_VISIBLE_MASK = 1;
9794: public static final int DBG_DDP_VISIBLE_MASK = 2;
9795: public static final int DBG_DMP_VISIBLE_MASK = 4;
9796: public static final int DBG_BLG_VISIBLE_MASK = 8;
9797: public static final int DBG_PFV_VISIBLE_MASK = 16;
9798: public static final int DBG_RBP_VISIBLE_MASK = 32;
9799: public static final int DBG_DBP_VISIBLE_MASK = 64;
9800: public static final int DBG_SMT_VISIBLE_MASK = 128;
9801: public static final int DBG_ATW_VISIBLE_MASK = 256;
9802: public static final int DBG_PAA_VISIBLE_MASK = 512;
9803: public static final int DBG_RTL_VISIBLE_MASK = 1024;
9804: public static final int DBG_SPV_VISIBLE_MASK = 2048;
9805: public static final int DBG_PLV_VISIBLE_MASK = 4096;
9806: public static final int DBG_ACM_VISIBLE_MASK = 8192;
9807: public static int dbgVisibleMask;
9808:
9809:
9810:
9811: public static void dbgInit () {
9812: dbgVisibleMask = 0;
9813: dbgHexSelected = false;
9814: dbgHexValue = 0;
9815: dbgSupervisorMode = 1;
9816: dbgPopupMenu = null;
9817: dbgPopupDisMenuItem = null;
9818: dbgPopupMemMenuItem = null;
9819: dbgPopupCopyMenuItem = null;
9820: dbgPopupSelectAllMenuItem = null;
9821: dbgPopupIBPMenu = null;
9822: dbgPopupIBPCurrentModel = null;
9823: dbgPopupIBPCurrentValue = 0;
9824: dbgPopupIBPThresholdModel = null;
9825: dbgPopupIBPThresholdValue = 0;
9826: dbgPopupHexMenu = null;
9827: dbgPopupTextArea = null;
9828: dbgEventMask = 0;
9829: dbgStopOnError = false;
9830: if (DBG_ORI_BYTE_ZERO_D0) {
9831: dbgOriByteZeroD0 = false;
9832: }
9833: dbgStopAtStart = false;
9834: }
9835:
9836:
9837:
9838: public static void dbgMakePopup () {
9839:
9840:
9841: ActionListener popupActionListener = new ActionListener () {
9842: @Override public void actionPerformed (ActionEvent ae) {
9843: switch (ae.getActionCommand ()) {
9844: case "Disassemble":
9845: DisassembleList.ddpBacktraceRecord = -1L;
9846: DisassembleList.ddpOpen (dbgHexValue, dbgSupervisorMode, false);
9847: break;
9848: case "Memory Dump":
9849: MemoryDumpList.dmpOpen (dbgHexValue, dbgSupervisorMode != 0 ? 5 : 1, false);
9850: break;
9851: case "Run to Here":
9852: if (InstructionBreakPoint.IBP_ON) {
9853: if (mpuTask == null) {
9854: InstructionBreakPoint.ibpInstant (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
9855: mpuStart ();
9856: }
9857: }
9858: break;
9859: case "Set Breakpoint":
9860: if (InstructionBreakPoint.IBP_ON) {
9861: InstructionBreakPoint.ibpPut (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode, dbgPopupIBPCurrentValue, dbgPopupIBPThresholdValue, null);
9862: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
9863: }
9864: break;
9865: case "Clear Breakpoint":
9866: if (InstructionBreakPoint.IBP_ON) {
9867: InstructionBreakPoint.ibpRemove (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
9868: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
9869: }
9870: break;
9871: case "Copy":
9872: dbgCopy ();
9873: break;
9874: case "Select All":
9875: dbgSelectAll ();
9876: break;
9877: }
9878: }
9879: };
9880: dbgPopupMenu = ComponentFactory.createPopupMenu (
9881: dbgPopupIBPMenu =
9882: InstructionBreakPoint.IBP_ON ?
9883: ComponentFactory.createMenu (
9884: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
9885: Multilingual.mlnText (ComponentFactory.createMenuItem ("Run to Here", 'R', popupActionListener), "ja", "ここまで実行"),
9886: ComponentFactory.createHorizontalSeparator (),
9887: Multilingual.mlnText (ComponentFactory.createMenuItem ("Set Breakpoint", 'S', popupActionListener), "ja", "ブレークポイントを設定"),
9888: ComponentFactory.createHorizontalBox (
9889: Box.createHorizontalStrut (7),
9890: Box.createHorizontalGlue (),
9891: ComponentFactory.setPreferredSize (
9892: Multilingual.mlnText (ComponentFactory.createLabel ("current"), "ja", "現在値"),
9893: 60, 16),
9894: ComponentFactory.createNumberSpinner (dbgPopupIBPCurrentModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
9895: @Override public void stateChanged (ChangeEvent ce) {
9896: dbgPopupIBPCurrentValue = dbgPopupIBPCurrentModel.getNumber ().intValue ();
9897: }
9898: }),
9899: Box.createHorizontalGlue ()
9900: ),
9901: ComponentFactory.createHorizontalBox (
9902: Box.createHorizontalStrut (7),
9903: Box.createHorizontalGlue (),
9904: ComponentFactory.setPreferredSize (
9905: Multilingual.mlnText (ComponentFactory.createLabel ("threshold"), "ja", "閾値"),
9906: 60, 16),
9907: ComponentFactory.createNumberSpinner (dbgPopupIBPThresholdModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
9908: @Override public void stateChanged (ChangeEvent ce) {
9909: dbgPopupIBPThresholdValue = dbgPopupIBPThresholdModel.getNumber ().intValue ();
9910: }
9911: }),
9912: Box.createHorizontalGlue ()
9913: ),
9914: dbgPopupIBPClearMenuItem =
9915: Multilingual.mlnText (ComponentFactory.createMenuItem ("Clear Breakpoint", 'C', popupActionListener), "ja", "ブレークポイントを消去")
9916: ) :
9917: null,
9918: dbgPopupHexMenu =
9919: ComponentFactory.createMenu (
9920: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
9921: dbgPopupDisMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble", 'D', popupActionListener), "ja", "逆アセンブル"),
9922: dbgPopupMemMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory Dump", 'M', popupActionListener), "ja", "メモリダンプ")
9923: ),
9924: dbgPopupCopyMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Copy", 'C', popupActionListener), "ja", "コピー"),
9925: dbgPopupSelectAllMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Select All", 'A', popupActionListener), "ja", "すべて選択")
9926: );
9927:
9928: }
9929:
9930:
9931:
9932: public static void dbgShowPopup (MouseEvent me, JTextArea textArea, boolean dis) {
9933: dbgEventMask++;
9934: int x = me.getX ();
9935: int y = me.getY ();
9936:
9937: int p = textArea.viewToModel2D (me.getPoint ());
9938: DisassembleList.ddpPopupAddress = -1;
9939: if (dis) {
9940: int i = Arrays.binarySearch (DisassembleList.ddpSplitArray, 1, DisassembleList.ddpItemCount, p + 1);
9941: i = (i >> 31 ^ i) - 1;
9942: DisassembleList.ddpPopupAddress = DisassembleList.ddpAddressArray[i];
9943: }
9944: int start = textArea.getSelectionStart ();
9945: int end = textArea.getSelectionEnd ();
9946: String text = textArea.getText ();
9947: int length = text.length ();
9948: if ((start == end ||
9949: p < start || end <= p) &&
9950: 0 <= p && p < length && isWord (text.charAt (p))) {
9951:
9952: for (start = p; 0 < start && isWord (text.charAt (start - 1)); start--) {
9953: }
9954: for (end = p + 1; end < length && isWord (text.charAt (end)); end++) {
9955: }
9956: textArea.select (start, end);
9957: }
9958: dbgHexSelected = false;
9959: if (start < end) {
9960: textArea.requestFocusInWindow ();
9961:
9962:
9963:
9964:
9965:
9966: dbgHexValue = 0;
9967: int n = 0;
9968: for (int i = start; i < end; i++) {
9969: int t;
9970: if ((t = Character.digit (text.charAt (i), 16)) >= 0) {
9971: dbgHexValue = dbgHexValue << 4 | t;
9972: if (n >= 8 ||
9973: i + 1 >= end || (t = Character.digit (text.charAt (i + 1), 16)) < 0) {
9974: n = 0;
9975: break;
9976: }
9977: dbgHexValue = dbgHexValue << 4 | t;
9978: n += 2;
9979: i++;
9980: } else if (isWord (text.charAt (i))) {
9981: n = 0;
9982: break;
9983: }
9984: }
9985: dbgHexSelected = n > 0;
9986: try {
9987:
9988: Rectangle r = textArea.modelToView2D (start).getBounds ();
9989:
9990: Rectangle s = textArea.modelToView2D (end - 1).getBounds ();
9991: if (r.y == s.y) {
9992:
9993: y = r.y + r.height;
9994: }
9995: } catch (BadLocationException ble) {
9996: }
9997: }
9998:
9999: if (InstructionBreakPoint.IBP_ON) {
10000: if (dis && mpuTask == null && DisassembleList.ddpPopupAddress != -1) {
10001: ComponentFactory.setText (dbgPopupIBPMenu, fmtHex8 (DisassembleList.ddpPopupAddress));
10002: TreeMap<Integer,InstructionBreakPoint.InstructionBreakRecord> pointTable = InstructionBreakPoint.ibpPointTable;
10003: InstructionBreakPoint.InstructionBreakRecord r = pointTable.get (DisassembleList.ddpPopupAddress);
10004: if (r != null) {
10005: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = r.ibrValue));
10006: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = r.ibrThreshold));
10007: dbgPopupIBPClearMenuItem.setEnabled (true);
10008: } else {
10009: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = 0));
10010: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = 0));
10011: dbgPopupIBPClearMenuItem.setEnabled (false);
10012: }
10013: ComponentFactory.setVisible (dbgPopupIBPMenu, true);
10014: } else {
10015: ComponentFactory.setVisible (dbgPopupIBPMenu, false);
10016: }
10017: }
10018:
10019: if (dbgHexSelected) {
10020: ComponentFactory.setText (dbgPopupHexMenu, fmtHex8 (dbgHexValue));
10021: ComponentFactory.setVisible (dbgPopupHexMenu, true);
10022: } else {
10023: ComponentFactory.setVisible (dbgPopupHexMenu, false);
10024: }
10025:
10026: ComponentFactory.setEnabled (dbgPopupCopyMenuItem, clpClipboard != null && start < end);
10027:
10028: ComponentFactory.setEnabled (dbgPopupSelectAllMenuItem, clpClipboard != null);
10029:
10030: dbgPopupTextArea = textArea;
10031: dbgPopupMenu.show (textArea, x, y);
10032: dbgEventMask--;
10033: }
10034:
10035: public static boolean isWord (char c) {
10036: return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '_';
10037: }
10038:
10039:
10040:
10041: public static void dbgCopy () {
10042: clpCopy (dbgPopupTextArea.getSelectedText ());
10043: }
10044:
10045:
10046:
10047: public static void dbgSelectAll () {
10048: if (clpClipboard != null) {
10049:
10050: dbgEventMask++;
10051: dbgPopupTextArea.selectAll ();
10052: dbgPopupTextArea.requestFocusInWindow ();
10053: dbgEventMask--;
10054: }
10055: }
10056:
10057:
10058:
10059:
10060: public static void dbgUpdate () {
10061: if ((dbgVisibleMask & DBG_DRP_VISIBLE_MASK) != 0) {
10062: RegisterList.drpUpdate ();
10063: }
10064: if (ProgramFlowVisualizer.PFV_ON) {
10065: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
10066: if (ProgramFlowVisualizer.pfvTimer == 0) {
10067: ProgramFlowVisualizer.pfvUpdate ();
10068: } else {
10069: ProgramFlowVisualizer.pfvTimer--;
10070: }
10071: }
10072: }
10073: if (RasterBreakPoint.RBP_ON) {
10074: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
10075: if (RasterBreakPoint.rbpTimer == 0) {
10076: RasterBreakPoint.rbpUpdateFrame ();
10077: } else {
10078: RasterBreakPoint.rbpTimer--;
10079: }
10080: }
10081: }
10082: if (ScreenModeTest.SMT_ON) {
10083: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
10084: if (ScreenModeTest.smtTimer == 0) {
10085: ScreenModeTest.smtUpdateFrame ();
10086: } else {
10087: ScreenModeTest.smtTimer--;
10088: }
10089: }
10090: }
10091: if (RootPointerList.RTL_ON) {
10092: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
10093: if (RootPointerList.rtlTimer == 0) {
10094: RootPointerList.rtlTimer = RootPointerList.RTL_INTERVAL - 1;
10095: RootPointerList.rtlUpdateFrame ();
10096: } else {
10097: RootPointerList.rtlTimer--;
10098: }
10099: }
10100: }
10101: if (SpritePatternViewer.SPV_ON) {
10102: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
10103: if (SpritePatternViewer.spvTimer == 0) {
10104: SpritePatternViewer.spvTimer = SpritePatternViewer.SPV_INTERVAL - 1;
10105: SpritePatternViewer.spvUpdateFrame ();
10106: } else {
10107: SpritePatternViewer.spvTimer--;
10108: }
10109: }
10110: }
10111: if (PaletteViewer.PLV_ON) {
10112: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
10113: if (PaletteViewer.plvTimer == 0) {
10114: PaletteViewer.plvTimer = PaletteViewer.PLV_INTERVAL - 1;
10115: PaletteViewer.plvUpdateFrame ();
10116: } else {
10117: PaletteViewer.plvTimer--;
10118: }
10119: }
10120: }
10121: if (ATCMonitor.ACM_ON) {
10122: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
10123: if (ATCMonitor.acmTimer == 0) {
10124: ATCMonitor.acmTimer = ATCMonitor.ACM_INTERVAL - 1;
10125: ATCMonitor.acmUpdateFrame ();
10126: } else {
10127: ATCMonitor.acmTimer--;
10128: }
10129: }
10130: }
10131: }
10132:
10133:
10134:
10135:
10136:
10137:
10138:
10139:
10140:
10141:
10142:
10143:
10144:
10145:
10146:
10147:
10148:
10149:
10150:
10151:
10152:
10153:
10154: public static boolean dbgDoStopOnError () {
10155: if (MainMemory.mmrHumanVersion <= 0) {
10156: return true;
10157: }
10158: if ((regOC & 0xff00) == 0xff00 &&
10159: M68kException.m6eNumber == M68kException.M6E_PRIVILEGE_VIOLATION) {
10160: return false;
10161: }
10162: String message = (
10163: M68kException.m6eNumber < 0 ?
10164: fmtHex8 (new StringBuilder ("breaked").append (" at "), regPC0).toString () :
10165: M68kException.m6eNumber <= M68kException.M6E_ADDRESS_ERROR ?
10166: fmtHex8 (fmtHex8 (new StringBuilder ("ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10167: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10168: .append (" at "), regPC0).toString () :
10169: fmtHex8 (new StringBuilder (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10170: .append (" at "), regPC0).toString ()
10171: );
10172: System.out.println (message);
10173: if (!(M68kException.m6eNumber == M68kException.M6E_ACCESS_FAULT &&
10174: 0x0000e100 <= regPC0 && regPC0 < 0x0000e500)) {
10175: mpuStop (message);
10176: return true;
10177: }
10178: return false;
10179: }
10180:
10181:
10182:
10183: public static void dbgDoubleBusFault () {
10184: String message =
10185: fmtHex8 (fmtHex8 (new StringBuilder ("FATAL ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10186: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10187: .append (" at "), regPC0).toString ();
10188: System.out.println (message);
10189: mpuStop (message);
10190: }
10191:
10192:
10193:
10194:
10195:
10196:
10197: public static final HashMap<String,byte[]> rscResourceCache = new HashMap<String,byte[]> ();
10198:
10199:
10200:
10201:
10202:
10203:
10204: public static byte[] rscGetResource (String name, int... sizes) {
10205: byte[] array = rscResourceCache.get (name);
10206: if (array != null) {
10207: return array;
10208: }
10209: array = new byte[1024 * 64];
10210: int size = 0;
10211: try (BufferedInputStream bis = new BufferedInputStream (XEiJ.class.getResourceAsStream ("../data/" + name))) {
10212: for (;;) {
10213: if (size == array.length) {
10214: byte[] newArray = new byte[array.length * 2];
10215: System.arraycopy (array, 0, newArray, 0, size);
10216: array = newArray;
10217: }
10218: int step = bis.read (array, size, array.length - size);
10219: if (step == -1) {
10220: break;
10221: }
10222: size += step;
10223: }
10224: if (size < array.length) {
10225: byte[] newArray = new byte[size];
10226: System.arraycopy (array, 0, newArray, 0, size);
10227: array = newArray;
10228: }
10229: boolean fit = sizes.length == 0;
10230: if (!fit) {
10231: for (int i = 0; i < sizes.length; i++) {
10232: if (size == sizes[i]) {
10233: fit = true;
10234: break;
10235: }
10236: }
10237: }
10238: if (fit) {
10239: System.out.println (Multilingual.mlnJapanese ?
10240: name + " を読み込みました" :
10241: name + " was read");
10242: rscResourceCache.put (name, array);
10243: return array;
10244: }
10245: System.out.println (Multilingual.mlnJapanese ?
10246: name + " のサイズが違います" :
10247: name + " has wrong size");
10248: return null;
10249: } catch (IOException ioe) {
10250: }
10251:
10252: System.out.println (Multilingual.mlnJapanese ?
10253: name + " を読み込めません" :
10254: name + " cannot be read");
10255: return null;
10256: }
10257:
10258:
10259:
10260: public static String rscGetResourceText (String name) {
10261: return rscGetResourceText (name, "UTF-8");
10262: }
10263: public static String rscGetResourceText (String name, String charset) {
10264: byte[] array = rscGetResource (name);
10265: if (name != null) {
10266: try {
10267: return new String (array, charset);
10268: } catch (UnsupportedEncodingException uee) {
10269: }
10270: }
10271: return "";
10272: }
10273:
10274: public static final Pattern RSC_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10275: public static String rscLastFileName = null;
10276:
10277:
10278:
10279:
10280:
10281:
10282: public static byte[] rscGetFile (String names, int... sizes) {
10283: for (String name : names.split (",")) {
10284: name = name.trim ();
10285: if (name.length () == 0 || name.equalsIgnoreCase ("none")) {
10286: continue;
10287: }
10288: String[] zipSplittedName = RSC_ZIP_SEPARATOR.split (name, 2);
10289: InputStream is = null;
10290: if (zipSplittedName.length < 2) {
10291: File file = new File (name);
10292: if (file.isFile ()) {
10293: try {
10294: is = new FileInputStream (file);
10295: } catch (IOException ioe) {
10296: }
10297: } else {
10298: System.out.println (Multilingual.mlnJapanese ?
10299: name + " がありません" :
10300: name + " does not exist");
10301: continue;
10302: }
10303: } else {
10304: String zipName = zipSplittedName[0];
10305: String entryName = zipSplittedName[1];
10306: if (new File (zipName).isFile ()) {
10307: try {
10308: ZipFile zipFile = new ZipFile (zipName);
10309: ZipEntry zipEntry = zipFile.getEntry (entryName);
10310: if (zipEntry != null) {
10311: is = zipFile.getInputStream (zipEntry);
10312: } else {
10313: System.out.println (Multilingual.mlnJapanese ?
10314: zipName + " に " + zipEntry + " がありません" :
10315: zipName + " does not include " + zipEntry);
10316: }
10317: } catch (IOException ioe) {
10318: }
10319: } else {
10320: System.out.println (Multilingual.mlnJapanese ?
10321: zipName + " がありません" :
10322: zipName + " does not exist");
10323: continue;
10324: }
10325: }
10326: if (is != null) {
10327: try {
10328: is = new BufferedInputStream (is);
10329: if (name.toLowerCase ().endsWith (".gz")) {
10330: is = new GZIPInputStream (is);
10331: }
10332: byte[] array = new byte[1024 * 64];
10333: int size = 0;
10334: for (;;) {
10335: if (size == array.length) {
10336: byte[] newArray = new byte[array.length * 2];
10337: System.arraycopy (array, 0, newArray, 0, size);
10338: array = newArray;
10339: }
10340: int step = is.read (array, size, array.length - size);
10341: if (step == -1) {
10342: break;
10343: }
10344: size += step;
10345: }
10346: is.close ();
10347: is = null;
10348: if (size < array.length) {
10349: byte[] newArray = new byte[size];
10350: System.arraycopy (array, 0, newArray, 0, size);
10351: array = newArray;
10352: }
10353: boolean fit = sizes.length == 0;
10354: if (!fit) {
10355: for (int i = 0; i < sizes.length; i++) {
10356: if (size == sizes[i]) {
10357: fit = true;
10358: break;
10359: }
10360: }
10361: }
10362: if (fit) {
10363: System.out.println (Multilingual.mlnJapanese ?
10364: name + " を読み込みました" :
10365: name + " was read");
10366: rscLastFileName = name;
10367: return array;
10368: }
10369: System.out.println (Multilingual.mlnJapanese ?
10370: name + " のサイズが違います" :
10371: name + " has wrong size");
10372: continue;
10373: } catch (IOException ioe) {
10374: }
10375: if (is != null) {
10376: try {
10377: is.close ();
10378: is = null;
10379: } catch (IOException ioe) {
10380: }
10381: }
10382: }
10383: System.out.println (Multilingual.mlnJapanese ?
10384: name + " を読み込めません" :
10385: name + " cannot be read");
10386: }
10387:
10388:
10389:
10390: return null;
10391: }
10392:
10393:
10394:
10395:
10396: public static String rscGetTextFile (String name) {
10397: return rscGetTextFile (name, "UTF-8");
10398: }
10399: public static String rscGetTextFile (String name, String charset) {
10400: byte[] array = rscGetFile (name);
10401: if (array != null) {
10402: try {
10403: return new String (array, charset);
10404: } catch (UnsupportedEncodingException uee) {
10405: }
10406: }
10407: return "";
10408: }
10409:
10410:
10411:
10412: public static final int RSC_A_MASK = 1;
10413: public static final int RSC_R_MASK = 2;
10414: public static final int RSC_I_MASK = 4;
10415: public static final String RSC_A_EN = "Abort";
10416: public static final String RSC_R_EN = "Retry";
10417: public static final String RSC_I_EN = "Ignore";
10418: public static final String RSC_A_JA = "中止";
10419: public static final String RSC_R_JA = "再実行";
10420: public static final String RSC_I_JA = "無視";
10421: public static final String[][] RSC_EN_OPTIONS = {
10422: { RSC_A_EN },
10423: { RSC_A_EN },
10424: { RSC_R_EN },
10425: { RSC_A_EN, RSC_R_EN },
10426: { RSC_I_EN },
10427: { RSC_A_EN, RSC_I_EN },
10428: { RSC_R_EN, RSC_I_EN },
10429: { RSC_A_EN, RSC_R_EN, RSC_I_EN },
10430: };
10431: public static final String[][] RSC_JA_OPTIONS = {
10432: { RSC_A_JA },
10433: { RSC_A_JA },
10434: { RSC_R_JA },
10435: { RSC_A_JA, RSC_R_JA },
10436: { RSC_I_JA },
10437: { RSC_A_JA, RSC_I_JA },
10438: { RSC_R_JA, RSC_I_JA },
10439: { RSC_A_JA, RSC_R_JA, RSC_I_JA },
10440: };
10441: public static int rscShowError (String message, int mask) {
10442: System.out.println (message);
10443: mask &= RSC_A_MASK | RSC_R_MASK | RSC_I_MASK;
10444: if (mask == 0) {
10445: mask = RSC_A_MASK;
10446: }
10447: String[] options = (Multilingual.mlnJapanese ? RSC_JA_OPTIONS : RSC_EN_OPTIONS)[mask];
10448: int def = Integer.numberOfTrailingZeros (mask);
10449: pnlExitFullScreen (true);
10450: int bit = JOptionPane.showOptionDialog (
10451: null,
10452: message,
10453: Multilingual.mlnJapanese ? "ファイル操作エラー" : "File operation error",
10454: JOptionPane.YES_NO_CANCEL_OPTION,
10455: JOptionPane.ERROR_MESSAGE,
10456: null,
10457: options,
10458: options[def]);
10459: if (bit == JOptionPane.CLOSED_OPTION) {
10460: bit = def;
10461: }
10462: return 1 << bit;
10463: }
10464:
10465:
10466:
10467:
10468:
10469:
10470: public static boolean rscPutTextFile (String name, String string) {
10471: return rscPutTextFile (name, string, "UTF-8");
10472: }
10473: public static boolean rscPutTextFile (String name, ArrayList<String> strings) {
10474: return rscPutTextFile (name, strings, "UTF-8");
10475: }
10476: public static boolean rscPutTextFile (String name, String string, String charset) {
10477: ArrayList<String> strings = new ArrayList<String> ();
10478: strings.add (string);
10479: return rscPutTextFile (name, strings, charset);
10480: }
10481: public static boolean rscPutTextFile (String name, ArrayList<String> strings, String charset) {
10482: String nameTmp = name + ".tmp";
10483: String nameBak = name + ".bak";
10484: File file = new File (name);
10485: File fileTmp = new File (nameTmp);
10486: File fileBak = new File (nameBak);
10487:
10488: File parentDirectory = file.getParentFile ();
10489: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10490: if (!parentDirectory.mkdirs ()) {
10491: System.out.println (parentDirectory.getPath () + (Multilingual.mlnJapanese ? " を作れません" : " cannot be created"));
10492: return false;
10493: }
10494: }
10495:
10496: if (fileTmp.exists ()) {
10497: if (!fileTmp.delete ()) {
10498: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10499: return false;
10500: }
10501: }
10502:
10503: try (BufferedWriter bw = new BufferedWriter (new FileWriter (nameTmp, Charset.forName (charset)))) {
10504: for (String string : strings) {
10505: bw.write (string);
10506: }
10507: } catch (IOException ioe) {
10508: ioe.printStackTrace ();
10509: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " に書き出せません" : " cannot be written"));
10510: return false;
10511: }
10512:
10513: boolean fileExists = file.exists ();
10514: if (fileExists) {
10515:
10516: if (fileBak.exists ()) {
10517: if (!fileBak.delete ()) {
10518: System.out.println (nameBak + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10519: return false;
10520: }
10521: }
10522:
10523: if (!file.renameTo (fileBak)) {
10524: System.out.println (name + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + nameBak + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10525: return false;
10526: }
10527: }
10528:
10529: if (!fileTmp.renameTo (file)) {
10530: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + name + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10531: return false;
10532: }
10533: if (fileExists) {
10534: System.out.println (name + (Multilingual.mlnJapanese ? " を更新しました" : " was updated"));
10535: } else {
10536: System.out.println (name + (Multilingual.mlnJapanese ? " を作りました" : " was created"));
10537: }
10538: return true;
10539: }
10540:
10541:
10542:
10543:
10544:
10545:
10546:
10547:
10548:
10549: public static boolean rscPutFile (String name, byte[] array) {
10550: return rscPutFile (name, array, 0, array.length, (long) array.length);
10551: }
10552: public static boolean rscPutFile (String name, byte[] array, int offset, int length) {
10553: return rscPutFile (name, array, offset, length, (long) length);
10554: }
10555: public static boolean rscPutFile (String name, byte[] array, int offset, int length, long longLength2) {
10556: if (RSC_ZIP_SEPARATOR.matcher (name).matches ()) {
10557:
10558: return false;
10559: }
10560: File file = new File (name);
10561: boolean fileExists = file.isFile ();
10562: if (fileExists && file.length () == longLength2) {
10563: comparison:
10564: {
10565: try (BufferedInputStream bis = new BufferedInputStream (new FileInputStream (file))) {
10566: byte[] buffer = new byte[(int) Math.min (Math.max ((long) length, longLength2 - (long) length), (long) (1024 * 1024))];
10567: int position = 0;
10568: while (position < length) {
10569: int step = bis.read (buffer, 0, Math.min (buffer.length, length - position));
10570: if (step == -1) {
10571: break comparison;
10572: }
10573: int offsetPosition = offset + position;
10574: for (int i = 0; i < step; i++) {
10575: if (buffer[i] != array[offsetPosition + i]) {
10576: break comparison;
10577: }
10578: }
10579: position += step;
10580: }
10581: long longPosition2 = (long) length;
10582: while (longPosition2 < longLength2) {
10583: int step = bis.read (buffer, 0, (int) Math.min ((long) buffer.length, longLength2 - longPosition2));
10584: if (step == -1) {
10585: break comparison;
10586: }
10587: for (int i = 0; i < step; i++) {
10588: if (buffer[i] != 0) {
10589: break comparison;
10590: }
10591: }
10592: longPosition2 += (long) step;
10593: }
10594: return true;
10595: } catch (IOException ioe) {
10596: }
10597: }
10598: }
10599: String nameTmp = name + ".tmp";
10600: File fileTmp = new File (nameTmp);
10601: String nameBak = name + ".bak";
10602: File fileBak = new File (nameBak);
10603: retry:
10604: for (;;) {
10605: File parentDirectory = file.getParentFile ();
10606: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10607: String parentName = parentDirectory.getPath ();
10608: if (parentDirectory.mkdirs ()) {
10609: System.out.println (Multilingual.mlnJapanese ?
10610: parentName + " を作りました" :
10611: parentName + " was created");
10612: } else {
10613: switch (rscShowError (Multilingual.mlnJapanese ?
10614: parentName + " を作れません" :
10615: parentName + " cannot be created",
10616: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10617: case RSC_A_MASK:
10618: break retry;
10619: case RSC_R_MASK:
10620: continue retry;
10621: }
10622: }
10623: }
10624: if (fileTmp.isFile ()) {
10625: if (!fileTmp.delete ()) {
10626: switch (rscShowError (Multilingual.mlnJapanese ?
10627: nameTmp + " を削除できません" :
10628: nameTmp + " cannot be deleted",
10629: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10630: case RSC_A_MASK:
10631: break retry;
10632: case RSC_R_MASK:
10633: continue retry;
10634: }
10635: }
10636: }
10637: try (OutputStream os = name.toLowerCase ().endsWith (".gz") ?
10638: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10639: {
10640:
10641: def.setLevel (Deflater.DEFAULT_COMPRESSION);
10642:
10643: }
10644: } :
10645: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10646:
10647: os.write (array, offset, length);
10648:
10649:
10650: if ((long) length < longLength2) {
10651: byte[] buffer = new byte[(int) Math.min (longLength2 - (long) length, (long) (1024 * 1024))];
10652: Arrays.fill (buffer, 0, buffer.length, (byte) 0);
10653: long longPosition2 = (long) length;
10654: while (longPosition2 < longLength2) {
10655: int step = (int) Math.min ((long) buffer.length, longLength2 - longPosition2);
10656: os.write (buffer, 0, step);
10657: longPosition2 += (long) step;
10658: }
10659: }
10660: } catch (IOException ioe) {
10661: switch (rscShowError (Multilingual.mlnJapanese ?
10662: nameTmp + " に書き出せません" :
10663: nameTmp + " cannot be written",
10664: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10665: case RSC_A_MASK:
10666: break retry;
10667: case RSC_R_MASK:
10668: continue retry;
10669: }
10670: }
10671: if (fileExists && file.isFile ()) {
10672: if (fileBak.isFile ()) {
10673: if (!fileBak.delete ()) {
10674: switch (rscShowError (Multilingual.mlnJapanese ?
10675: nameBak + " を削除できません" :
10676: nameBak + " cannot be deleted",
10677: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10678: case RSC_A_MASK:
10679: break retry;
10680: case RSC_R_MASK:
10681: continue retry;
10682: }
10683: }
10684: }
10685: if (!file.renameTo (fileBak)) {
10686: switch (rscShowError (Multilingual.mlnJapanese ?
10687: name + " を " + nameBak + " にリネームできません" :
10688: name + " cannot be renamed to " + nameBak,
10689: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10690: case RSC_A_MASK:
10691: break retry;
10692: case RSC_R_MASK:
10693: continue retry;
10694: }
10695: }
10696: }
10697: if (fileTmp.renameTo (file)) {
10698: if (fileExists) {
10699: System.out.println (Multilingual.mlnJapanese ?
10700: name + " を更新しました" :
10701: name + " was updated");
10702: } else {
10703: System.out.println (Multilingual.mlnJapanese ?
10704: name + " を作りました" :
10705: name + " was created");
10706: }
10707: return true;
10708: } else {
10709: switch (rscShowError (Multilingual.mlnJapanese ?
10710: nameTmp + " を " + name + " にリネームできません" :
10711: nameTmp + " cannot be renamed to " + name,
10712: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10713: case RSC_A_MASK:
10714: break retry;
10715: case RSC_R_MASK:
10716: continue retry;
10717: }
10718: }
10719: break;
10720: }
10721: if (fileExists) {
10722: System.out.println (Multilingual.mlnJapanese ?
10723: name + " を更新できません" :
10724: name + " cannot be updated");
10725: } else {
10726: System.out.println (Multilingual.mlnJapanese ?
10727: name + " を作れません" :
10728: name + " cannot be created");
10729: }
10730: return false;
10731: }
10732:
10733:
10734:
10735:
10736:
10737:
10738: public static final Pattern ISM_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10739:
10740:
10741:
10742:
10743:
10744:
10745:
10746:
10747:
10748:
10749:
10750: public static InputStream ismOpen (String name) {
10751: InputStream in = null;
10752: in = ismOpen (name, false);
10753: if (in == null && name.indexOf ('/') < 0 && name.indexOf ('\\') < 0) {
10754: in = ismOpen (name, true);
10755: }
10756: return in;
10757: }
10758: public static InputStream ismOpen (String name, boolean useGetResource) {
10759: boolean gzipped = name.toLowerCase ().endsWith (".gz");
10760: String[] zipSplittedName = ISM_ZIP_SEPARATOR.split (name, 2);
10761: String fileName = zipSplittedName[0];
10762: String zipEntryName = zipSplittedName.length < 2 ? null : zipSplittedName[1];
10763: InputStream in = null;
10764: try {
10765: if (useGetResource) {
10766: if (false) {
10767: URL url = XEiJ.class.getResource (fileName);
10768: if (url != null) {
10769: in = url.openStream ();
10770: }
10771: } else {
10772: in = XEiJ.class.getResourceAsStream (fileName);
10773: }
10774: } else {
10775: File file = new File (fileName);
10776: if (file.exists ()) {
10777: in = new FileInputStream (file);
10778: }
10779: }
10780: if (in != null && zipEntryName != null) {
10781: ZipInputStream zin = new ZipInputStream (in);
10782: in = null;
10783: ZipEntry entry;
10784: while ((entry = zin.getNextEntry ()) != null) {
10785: if (zipEntryName.equals (entry.getName ())) {
10786: in = zin;
10787: break;
10788: }
10789: }
10790: if (in == null) {
10791: System.out.println (Multilingual.mlnJapanese ? fileName + " の中に " + zipEntryName + " がありません" :
10792: zipEntryName + " does not exist in " + fileName);
10793: }
10794: }
10795: if (in != null && gzipped) {
10796: in = new GZIPInputStream (in);
10797: }
10798: if (in != null) {
10799: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " を読み込みます" :
10800: (useGetResource ? "Reading resource file " : "Reading file ") + name);
10801: return new BufferedInputStream (in);
10802: }
10803: } catch (Exception ioe) {
10804: if (prgVerbose) {
10805: prgPrintStackTraceOf (ioe);
10806: }
10807: }
10808: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " が見つかりません" :
10809: (useGetResource ? "Resource file " : "File ") + name + " is not found");
10810: return null;
10811: }
10812:
10813:
10814:
10815:
10816:
10817:
10818:
10819:
10820: public static int ismRead (InputStream in, byte[] bb, int o, int l) {
10821: try {
10822: int k = 0;
10823: while (k < l) {
10824: int t = in.read (bb, o + k, l - k);
10825: if (t < 0) {
10826: break;
10827: }
10828: k += t;
10829: }
10830: return k;
10831: } catch (IOException ioe) {
10832: if (prgVerbose) {
10833: prgPrintStackTraceOf (ioe);
10834: }
10835: }
10836: return -1;
10837: }
10838:
10839:
10840:
10841:
10842:
10843:
10844:
10845:
10846: public static int ismSkip (InputStream in, int l) {
10847: try {
10848: int k = 0;
10849: while (k < l) {
10850:
10851:
10852: if (in.read () < 0) {
10853: break;
10854: }
10855: k++;
10856: if (k < l) {
10857: int t = (int) in.skip ((long) (l - k));
10858: if (t < 0) {
10859: break;
10860: }
10861: k += t;
10862: }
10863: }
10864: return k;
10865: } catch (IOException ioe) {
10866: if (prgVerbose) {
10867: prgPrintStackTraceOf (ioe);
10868: }
10869: }
10870: return -1;
10871: }
10872:
10873:
10874:
10875:
10876:
10877: public static void ismClose (InputStream in) {
10878: try {
10879: if (in != null) {
10880: in.close ();
10881: }
10882: } catch (IOException ioe) {
10883: if (prgVerbose) {
10884: prgPrintStackTraceOf (ioe);
10885: }
10886: }
10887: }
10888:
10889:
10890:
10891:
10892:
10893:
10894: public static int ismLength (String name, int maxLength) {
10895: int length;
10896: InputStream in = ismOpen (name);
10897: if (in == null) {
10898: length = -1;
10899: } else {
10900: length = ismSkip (in, maxLength);
10901: ismClose (in);
10902: }
10903: return length;
10904: }
10905:
10906:
10907:
10908:
10909:
10910:
10911:
10912:
10913:
10914:
10915:
10916:
10917:
10918:
10919: public static boolean ismLoad (byte[] bb, int o, int l, String names) {
10920: for (String name : names.split (",")) {
10921: if (name.length () != 0) {
10922: InputStream in = ismOpen (name);
10923: if (in != null) {
10924: int k = ismRead (in, bb, o, l);
10925: ismClose (in);
10926: if (k == l) {
10927: return true;
10928: }
10929: }
10930: }
10931: }
10932: return false;
10933: }
10934:
10935:
10936:
10937:
10938:
10939:
10940:
10941:
10942:
10943: public static boolean ismSave (byte[] bb, int offset, long length, String path, boolean verbose) {
10944: if (ISM_ZIP_SEPARATOR.split (path, 2).length != 1) {
10945: if (verbose) {
10946: pnlExitFullScreen (true);
10947: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? path + " に書き出せません" : "Cannot write " + path);
10948: }
10949: return false;
10950: }
10951: long step = 0;
10952: byte[] zz = null;
10953: long pointer = (long) (bb.length - offset);
10954: if (pointer < length) {
10955: step = Math.min (1024L * 512, length - pointer);
10956: zz = new byte[(int) step];
10957: Arrays.fill (zz, (byte) 0);
10958: }
10959:
10960: File file = new File (path);
10961:
10962: if (step == 0 &&
10963: file.exists () && file.length () == length) {
10964:
10965: if (length == 0L) {
10966: return true;
10967: }
10968: InputStream in = ismOpen (path);
10969: if (in != null) {
10970: int l = (int) length;
10971: byte[] tt = new byte[l];
10972: int k = ismRead (in, tt, 0, l);
10973: ismClose (in);
10974: if (k == l &&
10975: Arrays.equals (tt, bb.length == l ? bb : Arrays.copyOfRange (bb, offset, offset + l))) {
10976: return true;
10977: }
10978: }
10979: }
10980:
10981: String pathTmp = path + ".tmp";
10982: String pathBak = path + ".bak";
10983: File fileTmp = new File (pathTmp);
10984: File fileBak = new File (pathBak);
10985:
10986: if (fileTmp.exists ()) {
10987: if (!fileTmp.delete ()) {
10988: if (verbose) {
10989: pnlExitFullScreen (true);
10990: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " を削除できません" : "Cannot delete " + pathTmp);
10991: }
10992: return false;
10993: }
10994: }
10995:
10996: try (OutputStream out = path.toLowerCase ().endsWith (".gz") ?
10997: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10998: {
10999:
11000: def.setLevel (Deflater.DEFAULT_COMPRESSION);
11001:
11002: }
11003: } :
11004: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11005: if (step == 0) {
11006: out.write (bb, offset, (int) length);
11007: } else {
11008: out.write (bb, offset, (int) pointer);
11009: for (; pointer < length; pointer += step) {
11010: out.write (zz, 0, (int) Math.min (step, length - pointer));
11011: }
11012: }
11013: } catch (IOException ioe) {
11014: if (verbose) {
11015: prgPrintStackTraceOf (ioe);
11016: pnlExitFullScreen (true);
11017: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " に書き出せません" : "Cannot write " + pathTmp);
11018: }
11019: return false;
11020: }
11021:
11022:
11023: if (file.exists ()) {
11024: if (fileBak.exists ()) {
11025: if (!fileBak.delete ()) {
11026: if (verbose) {
11027: pnlExitFullScreen (true);
11028: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathBak + " を削除できません" : "Cannot delete " + pathBak);
11029: }
11030: return false;
11031: }
11032: }
11033: if (!file.renameTo (fileBak)) {
11034: if (verbose) {
11035: pnlExitFullScreen (true);
11036: JOptionPane.showMessageDialog (
11037: null, Multilingual.mlnJapanese ? path + " を " + pathBak + " にリネームできません" : "Cannot rename " + path + " to " + pathBak);
11038: }
11039: return false;
11040: }
11041: }
11042:
11043:
11044: if (!fileTmp.renameTo (file)) {
11045: if (verbose) {
11046: pnlExitFullScreen (true);
11047: JOptionPane.showMessageDialog (
11048: null, Multilingual.mlnJapanese ? pathTmp + " を " + path + " にリネームできません" : "Cannot rename " + pathTmp + " to " + path);
11049: }
11050: return false;
11051: }
11052: return true;
11053: }
11054:
11055:
11056:
11057:
11058:
11059:
11060:
11061: public static final char[] FMT_TEMP = new char[32];
11062:
11063:
11064:
11065:
11066:
11067:
11068:
11069:
11070:
11071:
11072:
11073: public static final char[] FMT_AIN4_BASE = ".......*..*...**.*...*.*.**..****...*..**.*.*.****..**.****.****".toCharArray ();
11074: public static final char[] FMT_BIN4_BASE = "0000000100100011010001010110011110001001101010111100110111101111".toCharArray ();
11075:
11076:
11077:
11078:
11079:
11080:
11081:
11082:
11083: public static void fmtAin4 (char[] a, int o, int x) {
11084: a[o ] = (char) (x >> 1 & 4 ^ 46);
11085: a[o + 1] = (char) (x & 4 ^ 46);
11086: a[o + 2] = (char) (x << 1 & 4 ^ 46);
11087: a[o + 3] = (char) (x << 2 & 4 ^ 46);
11088: }
11089: public static void fmtBin4 (char[] a, int o, int x) {
11090: a[o ] = (char) (x >>> 3 & 1 | 48);
11091: a[o + 1] = (char) (x >>> 2 & 1 | 48);
11092: a[o + 2] = (char) (x >>> 1 & 1 | 48);
11093: a[o + 3] = (char) (x & 1 | 48);
11094: }
11095: public static String fmtAin4 (int x) {
11096: return String.valueOf (FMT_AIN4_BASE, (x & 15) << 2, 4);
11097: }
11098: public static String fmtBin4 (int x) {
11099: return String.valueOf (FMT_BIN4_BASE, (x & 15) << 2, 4);
11100: }
11101: public static StringBuilder fmtAin4 (StringBuilder sb, int x) {
11102: return sb.append (FMT_AIN4_BASE, (x & 15) << 2, 6);
11103: }
11104: public static StringBuilder fmtBin4 (StringBuilder sb, int x) {
11105: return sb.append (FMT_BIN4_BASE, (x & 15) << 2, 6);
11106: }
11107:
11108:
11109:
11110:
11111:
11112:
11113:
11114:
11115: public static void fmtAin6 (char[] a, int o, int x) {
11116: a[o ] = (char) (x >> 3 & 4 ^ 46);
11117: a[o + 1] = (char) (x >> 2 & 4 ^ 46);
11118: a[o + 2] = (char) (x >> 1 & 4 ^ 46);
11119: a[o + 3] = (char) (x & 4 ^ 46);
11120: a[o + 4] = (char) (x << 1 & 4 ^ 46);
11121: a[o + 5] = (char) (x << 2 & 4 ^ 46);
11122: }
11123: public static void fmtBin6 (char[] a, int o, int x) {
11124: a[o ] = (char) (x >>> 5 & 1 | 48);
11125: a[o + 1] = (char) (x >>> 4 & 1 | 48);
11126: a[o + 2] = (char) (x >>> 3 & 1 | 48);
11127: a[o + 3] = (char) (x >>> 2 & 1 | 48);
11128: a[o + 4] = (char) (x >>> 1 & 1 | 48);
11129: a[o + 5] = (char) (x & 1 | 48);
11130: }
11131: public static String fmtAin6 (int x) {
11132: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11133: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11134: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11135: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11136: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11137: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11138: return String.valueOf (FMT_TEMP, 0, 6);
11139: }
11140: public static String fmtBin6 (int x) {
11141: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11142: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11143: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11144: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11145: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11146: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11147: return String.valueOf (FMT_TEMP, 0, 6);
11148: }
11149: public static StringBuilder fmtAin6 (StringBuilder sb, int x) {
11150: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11151: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11152: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11153: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11154: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11155: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11156: return sb.append (FMT_TEMP, 0, 6);
11157: }
11158: public static StringBuilder fmtBin6 (StringBuilder sb, int x) {
11159: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11160: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11161: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11162: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11163: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11164: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11165: return sb.append (FMT_TEMP, 0, 6);
11166: }
11167:
11168:
11169:
11170:
11171:
11172:
11173:
11174:
11175: public static void fmtAin8 (char[] a, int o, int x) {
11176: a[o ] = (char) (x >> 5 & 4 ^ 46);
11177: a[o + 1] = (char) (x >> 4 & 4 ^ 46);
11178: a[o + 2] = (char) (x >> 3 & 4 ^ 46);
11179: a[o + 3] = (char) (x >> 2 & 4 ^ 46);
11180: a[o + 4] = (char) (x >> 1 & 4 ^ 46);
11181: a[o + 5] = (char) (x & 4 ^ 46);
11182: a[o + 6] = (char) (x << 1 & 4 ^ 46);
11183: a[o + 7] = (char) (x << 2 & 4 ^ 46);
11184: }
11185: public static void fmtBin8 (char[] a, int o, int x) {
11186: a[o ] = (char) (x >>> 7 & 1 | 48);
11187: a[o + 1] = (char) (x >>> 6 & 1 | 48);
11188: a[o + 2] = (char) (x >>> 5 & 1 | 48);
11189: a[o + 3] = (char) (x >>> 4 & 1 | 48);
11190: a[o + 4] = (char) (x >>> 3 & 1 | 48);
11191: a[o + 5] = (char) (x >>> 2 & 1 | 48);
11192: a[o + 6] = (char) (x >>> 1 & 1 | 48);
11193: a[o + 7] = (char) (x & 1 | 48);
11194: }
11195: public static String fmtAin8 (int x) {
11196: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11197: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11198: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11199: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11200: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11201: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11202: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11203: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11204: return String.valueOf (FMT_TEMP, 0, 8);
11205: }
11206: public static String fmtBin8 (int x) {
11207: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11208: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11209: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11210: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11211: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11212: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11213: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11214: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11215: return String.valueOf (FMT_TEMP, 0, 8);
11216: }
11217: public static StringBuilder fmtAin8 (StringBuilder sb, int x) {
11218: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11219: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11220: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11221: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11222: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11223: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11224: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11225: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11226: return sb.append (FMT_TEMP, 0, 8);
11227: }
11228: public static StringBuilder fmtBin8 (StringBuilder sb, int x) {
11229: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11230: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11231: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11232: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11233: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11234: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11235: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11236: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11237: return sb.append (FMT_TEMP, 0, 8);
11238: }
11239:
11240:
11241:
11242:
11243:
11244:
11245:
11246:
11247: public static void fmtAin12 (char[] a, int o, int x) {
11248: a[o ] = (char) (x >> 9 & 4 ^ 46);
11249: a[o + 1] = (char) (x >> 8 & 4 ^ 46);
11250: a[o + 2] = (char) (x >> 7 & 4 ^ 46);
11251: a[o + 3] = (char) (x >> 6 & 4 ^ 46);
11252: a[o + 4] = (char) (x >> 5 & 4 ^ 46);
11253: a[o + 5] = (char) (x >> 4 & 4 ^ 46);
11254: a[o + 6] = (char) (x >> 3 & 4 ^ 46);
11255: a[o + 7] = (char) (x >> 2 & 4 ^ 46);
11256: a[o + 8] = (char) (x >> 1 & 4 ^ 46);
11257: a[o + 9] = (char) (x & 4 ^ 46);
11258: a[o + 10] = (char) (x << 1 & 4 ^ 46);
11259: a[o + 11] = (char) (x << 2 & 4 ^ 46);
11260: }
11261: public static void fmtBin12 (char[] a, int o, int x) {
11262: a[o ] = (char) (x >>> 11 & 1 | 48);
11263: a[o + 1] = (char) (x >>> 10 & 1 | 48);
11264: a[o + 2] = (char) (x >>> 9 & 1 | 48);
11265: a[o + 3] = (char) (x >>> 8 & 1 | 48);
11266: a[o + 4] = (char) (x >>> 7 & 1 | 48);
11267: a[o + 5] = (char) (x >>> 6 & 1 | 48);
11268: a[o + 6] = (char) (x >>> 5 & 1 | 48);
11269: a[o + 7] = (char) (x >>> 4 & 1 | 48);
11270: a[o + 8] = (char) (x >>> 3 & 1 | 48);
11271: a[o + 9] = (char) (x >>> 2 & 1 | 48);
11272: a[o + 10] = (char) (x >>> 1 & 1 | 48);
11273: a[o + 11] = (char) (x & 1 | 48);
11274: }
11275: public static String fmtAin12 (int x) {
11276: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11277: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11278: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11279: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11280: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11281: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11282: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11283: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11284: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11285: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11286: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11287: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11288: return String.valueOf (FMT_TEMP, 0, 12);
11289: }
11290: public static String fmtBin12 (int x) {
11291: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11292: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11293: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11294: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11295: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11296: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11297: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11298: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11299: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11300: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11301: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11302: FMT_TEMP[11] = (char) (x & 1 | 48);
11303: return String.valueOf (FMT_TEMP, 0, 12);
11304: }
11305: public static StringBuilder fmtAin12 (StringBuilder sb, int x) {
11306: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11307: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11308: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11309: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11310: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11311: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11312: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11313: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11314: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11315: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11316: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11317: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11318: return sb.append (FMT_TEMP, 0, 12);
11319: }
11320: public static StringBuilder fmtBin12 (StringBuilder sb, int x) {
11321: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11322: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11323: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11324: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11325: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11326: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11327: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11328: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11329: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11330: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11331: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11332: FMT_TEMP[11] = (char) (x & 1 | 48);
11333: return sb.append (FMT_TEMP, 0, 12);
11334: }
11335:
11336:
11337:
11338:
11339:
11340:
11341:
11342:
11343: public static void fmtAin16 (char[] a, int o, int x) {
11344: a[o ] = (char) (x >> 13 & 4 ^ 46);
11345: a[o + 1] = (char) (x >> 12 & 4 ^ 46);
11346: a[o + 2] = (char) (x >> 11 & 4 ^ 46);
11347: a[o + 3] = (char) (x >> 10 & 4 ^ 46);
11348: a[o + 4] = (char) (x >> 9 & 4 ^ 46);
11349: a[o + 5] = (char) (x >> 8 & 4 ^ 46);
11350: a[o + 6] = (char) (x >> 7 & 4 ^ 46);
11351: a[o + 7] = (char) (x >> 6 & 4 ^ 46);
11352: a[o + 8] = (char) (x >> 5 & 4 ^ 46);
11353: a[o + 9] = (char) (x >> 4 & 4 ^ 46);
11354: a[o + 10] = (char) (x >> 3 & 4 ^ 46);
11355: a[o + 11] = (char) (x >> 2 & 4 ^ 46);
11356: a[o + 12] = (char) (x >> 1 & 4 ^ 46);
11357: a[o + 13] = (char) (x & 4 ^ 46);
11358: a[o + 14] = (char) (x << 1 & 4 ^ 46);
11359: a[o + 15] = (char) (x << 2 & 4 ^ 46);
11360: }
11361: public static void fmtBin16 (char[] a, int o, int x) {
11362: a[o ] = (char) (x >>> 15 & 1 | 48);
11363: a[o + 1] = (char) (x >>> 14 & 1 | 48);
11364: a[o + 2] = (char) (x >>> 13 & 1 | 48);
11365: a[o + 3] = (char) (x >>> 12 & 1 | 48);
11366: a[o + 4] = (char) (x >>> 11 & 1 | 48);
11367: a[o + 5] = (char) (x >>> 10 & 1 | 48);
11368: a[o + 6] = (char) (x >>> 9 & 1 | 48);
11369: a[o + 7] = (char) (x >>> 8 & 1 | 48);
11370: a[o + 8] = (char) (x >>> 7 & 1 | 48);
11371: a[o + 9] = (char) (x >>> 6 & 1 | 48);
11372: a[o + 10] = (char) (x >>> 5 & 1 | 48);
11373: a[o + 11] = (char) (x >>> 4 & 1 | 48);
11374: a[o + 12] = (char) (x >>> 3 & 1 | 48);
11375: a[o + 13] = (char) (x >>> 2 & 1 | 48);
11376: a[o + 14] = (char) (x >>> 1 & 1 | 48);
11377: a[o + 15] = (char) (x & 1 | 48);
11378: }
11379: public static String fmtAin16 (int x) {
11380: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11381: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11382: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11383: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11384: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11385: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11386: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11387: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11388: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11389: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11390: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11391: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11392: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11393: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11394: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11395: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11396: return String.valueOf (FMT_TEMP, 0, 16);
11397: }
11398: public static String fmtBin16 (int x) {
11399: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11400: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11401: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11402: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11403: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11404: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11405: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11406: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11407: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11408: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11409: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11410: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11411: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11412: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11413: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11414: FMT_TEMP[15] = (char) (x & 1 | 48);
11415: return String.valueOf (FMT_TEMP, 0, 16);
11416: }
11417: public static StringBuilder fmtAin16 (StringBuilder sb, int x) {
11418: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11419: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11420: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11421: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11422: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11423: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11424: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11425: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11426: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11427: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11428: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11429: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11430: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11431: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11432: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11433: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11434: return sb.append (FMT_TEMP, 0, 16);
11435: }
11436: public static StringBuilder fmtBin16 (StringBuilder sb, int x) {
11437: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11438: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11439: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11440: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11441: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11442: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11443: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11444: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11445: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11446: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11447: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11448: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11449: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11450: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11451: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11452: FMT_TEMP[15] = (char) (x & 1 | 48);
11453: return sb.append (FMT_TEMP, 0, 16);
11454: }
11455:
11456:
11457:
11458:
11459:
11460:
11461:
11462:
11463: public static void fmtAin24 (char[] a, int o, int x) {
11464: a[o ] = (char) (x >> 21 & 4 ^ 46);
11465: a[o + 1] = (char) (x >> 20 & 4 ^ 46);
11466: a[o + 2] = (char) (x >> 19 & 4 ^ 46);
11467: a[o + 3] = (char) (x >> 18 & 4 ^ 46);
11468: a[o + 4] = (char) (x >> 17 & 4 ^ 46);
11469: a[o + 5] = (char) (x >> 16 & 4 ^ 46);
11470: a[o + 6] = (char) (x >> 15 & 4 ^ 46);
11471: a[o + 7] = (char) (x >> 14 & 4 ^ 46);
11472: a[o + 8] = (char) (x >> 13 & 4 ^ 46);
11473: a[o + 9] = (char) (x >> 12 & 4 ^ 46);
11474: a[o + 10] = (char) (x >> 11 & 4 ^ 46);
11475: a[o + 11] = (char) (x >> 10 & 4 ^ 46);
11476: a[o + 12] = (char) (x >> 9 & 4 ^ 46);
11477: a[o + 13] = (char) (x >> 8 & 4 ^ 46);
11478: a[o + 14] = (char) (x >> 7 & 4 ^ 46);
11479: a[o + 15] = (char) (x >> 6 & 4 ^ 46);
11480: a[o + 16] = (char) (x >> 5 & 4 ^ 46);
11481: a[o + 17] = (char) (x >> 4 & 4 ^ 46);
11482: a[o + 18] = (char) (x >> 3 & 4 ^ 46);
11483: a[o + 19] = (char) (x >> 2 & 4 ^ 46);
11484: a[o + 20] = (char) (x >> 1 & 4 ^ 46);
11485: a[o + 21] = (char) (x & 4 ^ 46);
11486: a[o + 22] = (char) (x << 1 & 4 ^ 46);
11487: a[o + 23] = (char) (x << 2 & 4 ^ 46);
11488: }
11489: public static void fmtBin24 (char[] a, int o, int x) {
11490: a[o ] = (char) (x >>> 23 & 1 | 48);
11491: a[o + 1] = (char) (x >>> 22 & 1 | 48);
11492: a[o + 2] = (char) (x >>> 21 & 1 | 48);
11493: a[o + 3] = (char) (x >>> 20 & 1 | 48);
11494: a[o + 4] = (char) (x >>> 19 & 1 | 48);
11495: a[o + 5] = (char) (x >>> 18 & 1 | 48);
11496: a[o + 6] = (char) (x >>> 17 & 1 | 48);
11497: a[o + 7] = (char) (x >>> 16 & 1 | 48);
11498: a[o + 8] = (char) (x >>> 15 & 1 | 48);
11499: a[o + 9] = (char) (x >>> 14 & 1 | 48);
11500: a[o + 10] = (char) (x >>> 13 & 1 | 48);
11501: a[o + 11] = (char) (x >>> 12 & 1 | 48);
11502: a[o + 12] = (char) (x >>> 11 & 1 | 48);
11503: a[o + 13] = (char) (x >>> 10 & 1 | 48);
11504: a[o + 14] = (char) (x >>> 9 & 1 | 48);
11505: a[o + 15] = (char) (x >>> 8 & 1 | 48);
11506: a[o + 16] = (char) (x >>> 7 & 1 | 48);
11507: a[o + 17] = (char) (x >>> 6 & 1 | 48);
11508: a[o + 18] = (char) (x >>> 5 & 1 | 48);
11509: a[o + 19] = (char) (x >>> 4 & 1 | 48);
11510: a[o + 20] = (char) (x >>> 3 & 1 | 48);
11511: a[o + 21] = (char) (x >>> 2 & 1 | 48);
11512: a[o + 22] = (char) (x >>> 1 & 1 | 48);
11513: a[o + 23] = (char) (x & 1 | 48);
11514: }
11515: public static String fmtAin24 (int x) {
11516: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11517: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11518: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11519: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11520: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11521: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11522: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11523: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11524: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11525: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11526: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11527: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11528: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11529: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11530: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11531: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11532: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11533: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11534: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11535: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11536: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11537: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11538: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11539: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11540: return String.valueOf (FMT_TEMP, 0, 24);
11541: }
11542: public static String fmtBin24 (int x) {
11543: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11544: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11545: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11546: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11547: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11548: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11549: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11550: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11551: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11552: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11553: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11554: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11555: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11556: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11557: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11558: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11559: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11560: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11561: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11562: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11563: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11564: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11565: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11566: FMT_TEMP[23] = (char) (x & 1 | 48);
11567: return String.valueOf (FMT_TEMP, 0, 24);
11568: }
11569: public static StringBuilder fmtAin24 (StringBuilder sb, int x) {
11570: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11571: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11572: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11573: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11574: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11575: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11576: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11577: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11578: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11579: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11580: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11581: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11582: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11583: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11584: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11585: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11586: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11587: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11588: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11589: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11590: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11591: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11592: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11593: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11594: return sb.append (FMT_TEMP, 0, 24);
11595: }
11596: public static StringBuilder fmtBin24 (StringBuilder sb, int x) {
11597: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11598: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11599: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11600: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11601: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11602: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11603: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11604: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11605: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11606: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11607: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11608: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11609: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11610: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11611: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11612: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11613: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11614: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11615: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11616: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11617: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11618: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11619: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11620: FMT_TEMP[23] = (char) (x & 1 | 48);
11621: return sb.append (FMT_TEMP, 0, 24);
11622: }
11623:
11624:
11625:
11626:
11627:
11628:
11629:
11630:
11631:
11632:
11633:
11634:
11635:
11636:
11637:
11638:
11639:
11640:
11641:
11642:
11643:
11644:
11645:
11646:
11647:
11648:
11649:
11650:
11651:
11652:
11653:
11654:
11655:
11656: public static char fmtHexc (int x) {
11657: x &= 15;
11658: return (char) ((((9 - x) >> 4) & 7) + 48 + x);
11659: }
11660: public static void fmtHex1 (char[] a, int o, int x) {
11661: x &= 15;
11662: a[o] = (char) ((((9 - x) >> 4) & 7) + 48 + x);
11663: }
11664: public static String fmtHex1 (int x) {
11665: x &= 15;
11666: return Character.toString ((char) ((((9 - x) >> 4) & 7) + 48 + x));
11667: }
11668: public static StringBuilder fmtHex1 (StringBuilder sb, int x) {
11669: x &= 15;
11670: return sb.append ((char) ((((9 - x) >> 4) & 7) + 48 + x));
11671: }
11672:
11673:
11674:
11675:
11676:
11677:
11678: public static void fmtHex2 (char[] a, int o, int x) {
11679: int x0 = x & 15;
11680: int x1 = x >>> 4 & 15;
11681: a[o ] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
11682: a[o + 1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
11683: }
11684: public static String fmtHex2 (int x) {
11685:
11686: int x0 = x & 15;
11687: int x1 = x >>> 4 & 15;
11688: FMT_TEMP[0] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
11689: FMT_TEMP[1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
11690: return String.valueOf (FMT_TEMP, 0, 2);
11691: }
11692: public static StringBuilder fmtHex2 (StringBuilder sb, int x) {
11693: int x0 = x & 15;
11694: int x1 = x >>> 4 & 15;
11695: return (sb.
11696: append ((char) ((((9 - x1) >> 4) & 7) + 48 + x1)).
11697: append ((char) ((((9 - x0) >> 4) & 7) + 48 + x0)));
11698: }
11699:
11700:
11701:
11702:
11703:
11704:
11705: public static void fmtHex4 (char[] a, int o, int x) {
11706: int t;
11707: t = (char) x >>> 12;
11708: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11709: t = x >>> 8 & 15;
11710: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11711: t = x >>> 4 & 15;
11712: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11713: t = x & 15;
11714: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11715: }
11716: public static String fmtHex4 (int x) {
11717:
11718: int t;
11719: t = (char) x >>> 12;
11720: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11721: t = x >>> 8 & 15;
11722: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11723: t = x >>> 4 & 15;
11724: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11725: t = x & 15;
11726: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11727: return String.valueOf (FMT_TEMP, 0, 4);
11728: }
11729: public static StringBuilder fmtHex4 (StringBuilder sb, int x) {
11730:
11731: int t;
11732: t = (char) x >>> 12;
11733: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11734: t = x >>> 8 & 15;
11735: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11736: t = x >>> 4 & 15;
11737: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11738: t = x & 15;
11739: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11740: return sb.append (FMT_TEMP, 0, 4);
11741: }
11742:
11743:
11744:
11745:
11746:
11747:
11748: public static void fmtHex6 (char[] a, int o, int x) {
11749: int t;
11750: t = x >>> 20 & 15;
11751: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11752: t = x >>> 16 & 15;
11753: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11754: t = (char) x >>> 12;
11755: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11756: t = x >>> 8 & 15;
11757: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11758: t = x >>> 4 & 15;
11759: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11760: t = x & 15;
11761: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11762: }
11763: public static String fmtHex6 (int x) {
11764:
11765: int t;
11766: t = x >>> 20 & 15;
11767: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11768: t = x >>> 16 & 15;
11769: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11770: t = (char) x >>> 12;
11771: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11772: t = x >>> 8 & 15;
11773: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11774: t = x >>> 4 & 15;
11775: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11776: t = x & 15;
11777: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11778: return String.valueOf (FMT_TEMP, 0, 6);
11779: }
11780: public static StringBuilder fmtHex6 (StringBuilder sb, int x) {
11781:
11782: int t;
11783: t = x >>> 20 & 15;
11784: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11785: t = x >>> 16 & 15;
11786: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11787: t = (char) x >>> 12;
11788: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11789: t = x >>> 8 & 15;
11790: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11791: t = x >>> 4 & 15;
11792: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11793: t = x & 15;
11794: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11795: return sb.append (FMT_TEMP, 0, 6);
11796: }
11797:
11798:
11799:
11800:
11801:
11802:
11803: public static void fmtHex8 (char[] a, int o, int x) {
11804: int t;
11805: t = x >>> 28;
11806: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11807: t = x >>> 24 & 15;
11808: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11809: t = x >>> 20 & 15;
11810: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11811: t = x >>> 16 & 15;
11812: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11813: t = (char) x >>> 12;
11814: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11815: t = x >>> 8 & 15;
11816: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11817: t = x >>> 4 & 15;
11818: a[o + 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11819: t = x & 15;
11820: a[o + 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11821: }
11822: public static String fmtHex8 (int x) {
11823:
11824: int t;
11825: t = x >>> 28;
11826: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11827: t = x >>> 24 & 15;
11828: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11829: t = x >>> 20 & 15;
11830: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11831: t = x >>> 16 & 15;
11832: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11833: t = (char) x >>> 12;
11834: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11835: t = x >>> 8 & 15;
11836: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11837: t = x >>> 4 & 15;
11838: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11839: t = x & 15;
11840: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11841: return String.valueOf (FMT_TEMP, 0, 8);
11842: }
11843: public static StringBuilder fmtHex8 (StringBuilder sb, int x) {
11844:
11845: int t;
11846: t = x >>> 28;
11847: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11848: t = x >>> 24 & 15;
11849: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11850: t = x >>> 20 & 15;
11851: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11852: t = x >>> 16 & 15;
11853: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11854: t = (char) x >>> 12;
11855: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11856: t = x >>> 8 & 15;
11857: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11858: t = x >>> 4 & 15;
11859: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11860: t = x & 15;
11861: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11862: return sb.append (FMT_TEMP, 0, 8);
11863: }
11864:
11865: public static StringBuilder fmtHex16 (StringBuilder sb, long x) {
11866:
11867: int s, t;
11868: s = (int) (x >>> 32);
11869: t = s >>> 28;
11870: FMT_TEMP[ 0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11871: t = s >>> 24 & 15;
11872: FMT_TEMP[ 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11873: t = s >>> 20 & 15;
11874: FMT_TEMP[ 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11875: t = s >>> 16 & 15;
11876: FMT_TEMP[ 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11877: t = (char) s >>> 12;
11878: FMT_TEMP[ 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11879: t = s >>> 8 & 15;
11880: FMT_TEMP[ 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11881: t = s >>> 4 & 15;
11882: FMT_TEMP[ 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11883: t = s & 15;
11884: FMT_TEMP[ 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11885: s = (int) x;
11886: t = s >>> 28;
11887: FMT_TEMP[ 8] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11888: t = s >>> 24 & 15;
11889: FMT_TEMP[ 9] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11890: t = s >>> 20 & 15;
11891: FMT_TEMP[10] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11892: t = s >>> 16 & 15;
11893: FMT_TEMP[11] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11894: t = (char) s >>> 12;
11895: FMT_TEMP[12] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11896: t = s >>> 8 & 15;
11897: FMT_TEMP[13] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11898: t = s >>> 4 & 15;
11899: FMT_TEMP[14] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11900: t = s & 15;
11901: FMT_TEMP[15] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11902: return sb.append (FMT_TEMP, 0, 16);
11903: }
11904:
11905:
11906:
11907:
11908:
11909:
11910:
11911:
11912:
11913:
11914:
11915:
11916:
11917:
11918:
11919:
11920:
11921:
11922:
11923:
11924:
11925:
11926:
11927:
11928:
11929:
11930:
11931:
11932:
11933:
11934:
11935:
11936:
11937:
11938:
11939:
11940:
11941:
11942:
11943:
11944:
11945:
11946:
11947:
11948:
11949:
11950:
11951:
11952:
11953:
11954:
11955:
11956:
11957:
11958:
11959:
11960:
11961:
11962:
11963:
11964:
11965:
11966:
11967:
11968:
11969:
11970:
11971:
11972: public static final int[] FMT_BCD4 = new int[10000];
11973: public static final int[] FMT_DCB4 = new int[65536];
11974:
11975:
11976:
11977:
11978: public static void fmtInit () {
11979: Arrays.fill (FMT_DCB4, -1);
11980: int i = 0;
11981: int x = 0;
11982: for (int a = 0; a < 10; a++) {
11983: for (int b = 0; b < 10; b++) {
11984: for (int c = 0; c < 10; c++) {
11985: FMT_DCB4[FMT_BCD4[i ] = x ] = i;
11986: FMT_DCB4[FMT_BCD4[i + 1] = x + 1] = i + 1;
11987: FMT_DCB4[FMT_BCD4[i + 2] = x + 2] = i + 2;
11988: FMT_DCB4[FMT_BCD4[i + 3] = x + 3] = i + 3;
11989: FMT_DCB4[FMT_BCD4[i + 4] = x + 4] = i + 4;
11990: FMT_DCB4[FMT_BCD4[i + 5] = x + 5] = i + 5;
11991: FMT_DCB4[FMT_BCD4[i + 6] = x + 6] = i + 6;
11992: FMT_DCB4[FMT_BCD4[i + 7] = x + 7] = i + 7;
11993: FMT_DCB4[FMT_BCD4[i + 8] = x + 8] = i + 8;
11994: FMT_DCB4[FMT_BCD4[i + 9] = x + 9] = i + 9;
11995: i += 10;
11996: x += 1 << 4;
11997: }
11998: x += 6 << 4;
11999: }
12000: x += 6 << 8;
12001: }
12002: }
12003:
12004:
12005:
12006: public static int fmtBcd4 (int x) {
12007:
12008:
12009:
12010:
12011:
12012:
12013:
12014:
12015:
12016: return FMT_BCD4[Math.max (0, Math.min (9999, x))];
12017: }
12018:
12019:
12020:
12021: public static int fmtBcd8 (int x) {
12022: x = Math.max (0, Math.min (99999999, x));
12023:
12024:
12025: int q = (int) ((long) x * 109951163L >>> 40);
12026:
12027: return FMT_BCD4[q] << 16 | FMT_BCD4[x - 10000 * q];
12028: }
12029:
12030:
12031:
12032: public static long fmtBcd12 (long x) {
12033: x = Math.max (0L, Math.min (999999999999L, x));
12034: int q = (int) ((double) x / 100000000.0);
12035: int r = (int) (x - 100000000L * q);
12036:
12037:
12038: int rq = (int) ((long) r * 109951163L >>> 40);
12039:
12040: return (long) FMT_BCD4[q] << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
12041: }
12042:
12043:
12044:
12045: public static long fmtBcd16 (long x) {
12046: x = Math.max (0L, Math.min (9999999999999999L, x));
12047: int q = x <= (1L << 53) ? (int) ((double) x / 100000000.0) : (int) (x / 100000000L);
12048: int r = (int) (x - 100000000L * q);
12049:
12050:
12051: int qq = (int) ((long) q * 109951163L >>> 40);
12052:
12053:
12054:
12055: int rq = (int) ((long) r * 109951163L >>> 40);
12056:
12057: return (long) (FMT_BCD4[qq] << 16 | FMT_BCD4[q - 10000 * qq]) << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
12058: }
12059:
12060:
12061:
12062:
12063:
12064:
12065: public static int fmtCA02u (char[] a, int o, int x) {
12066: if (x < 0 || 99 < x) {
12067: x = 99;
12068: }
12069: x = FMT_BCD4[x];
12070: a[o ] = (char) ('0' | x >>> 4);
12071: a[o + 1] = (char) ('0' | x & 15);
12072: return o + 2;
12073: }
12074: public static StringBuilder fmtSB02u (StringBuilder sb, int x) {
12075: return sb.append (FMT_TEMP, 0, fmtCA02u (FMT_TEMP, 0, x));
12076: }
12077:
12078:
12079:
12080:
12081:
12082: public static int fmtCA2u (char[] a, int o, int x) {
12083: if (x < 0 || 99 < x) {
12084: x = 99;
12085: }
12086: x = FMT_BCD4[x];
12087: if (x <= 0x000f) {
12088: a[o++] = (char) ('0' | x);
12089: } else {
12090: a[o++] = (char) ('0' | x >>> 4);
12091: a[o++] = (char) ('0' | x & 15);
12092: }
12093: return o;
12094: }
12095: public static StringBuilder fmtSB2u (StringBuilder sb, int x) {
12096: return sb.append (FMT_TEMP, 0, fmtCA2u (FMT_TEMP, 0, x));
12097: }
12098:
12099:
12100:
12101:
12102:
12103: public static int fmtCA04u (char[] a, int o, int x) {
12104: if (x < 0 || 9999 < x) {
12105: x = 9999;
12106: }
12107: x = FMT_BCD4[x];
12108: a[o ] = (char) ('0' | x >>> 12);
12109: a[o + 1] = (char) ('0' | x >>> 8 & 15);
12110: a[o + 2] = (char) ('0' | x >>> 4 & 15);
12111: a[o + 3] = (char) ('0' | x & 15);
12112: return o + 4;
12113: }
12114: public static StringBuilder fmtSB04u (StringBuilder sb, int x) {
12115: return sb.append (FMT_TEMP, 0, fmtCA04u (FMT_TEMP, 0, x));
12116: }
12117:
12118:
12119:
12120:
12121:
12122: public static int fmtCA4u (char[] a, int o, int x) {
12123: if (x < 0 || 9999 < x) {
12124: x = 9999;
12125: }
12126: x = FMT_BCD4[x];
12127: if (x <= 0x000f) {
12128: a[o++] = (char) ('0' | x);
12129: } else if (x <= 0x00ff) {
12130: a[o++] = (char) ('0' | x >>> 4);
12131: a[o++] = (char) ('0' | x & 15);
12132: } else if (x <= 0x0fff) {
12133: a[o++] = (char) ('0' | x >>> 8);
12134: a[o++] = (char) ('0' | x >>> 4 & 15);
12135: a[o++] = (char) ('0' | x & 15);
12136: } else {
12137: a[o++] = (char) ('0' | x >>> 12);
12138: a[o++] = (char) ('0' | x >>> 8 & 15);
12139: a[o++] = (char) ('0' | x >>> 4 & 15);
12140: a[o++] = (char) ('0' | x & 15);
12141: }
12142: return o;
12143: }
12144: public static StringBuilder fmtSB4u (StringBuilder sb, int x) {
12145: return sb.append (FMT_TEMP, 0, fmtCA4u (FMT_TEMP, 0, x));
12146: }
12147:
12148:
12149:
12150:
12151:
12152: public static int fmtCA08u (char[] a, int o, int x) {
12153: if (x < 0 || 99999999 < x) {
12154: x = 99999999;
12155: }
12156:
12157:
12158: int h = (int) ((long) x * 109951163L >>> 40);
12159: return fmtCA04u (a, fmtCA04u (a, o, h), x - h * 10000);
12160: }
12161: public static StringBuilder fmtSB08u (StringBuilder sb, int x) {
12162: return sb.append (FMT_TEMP, 0, fmtCA08u (FMT_TEMP, 0, x));
12163: }
12164:
12165:
12166:
12167:
12168:
12169: public static int fmtCA8u (char[] a, int o, int x) {
12170: if (x < 0 || 99999999 < x) {
12171: x = 99999999;
12172: }
12173: if (x <= 9999) {
12174: return fmtCA4u (a, o, x);
12175: } else {
12176:
12177:
12178: int h = (int) ((long) x * 109951163L >>> 40);
12179: return fmtCA04u (a, fmtCA4u (a, o, h), x - h * 10000);
12180: }
12181: }
12182: public static StringBuilder fmtSB8u (StringBuilder sb, int x) {
12183: return sb.append (FMT_TEMP, 0, fmtCA8u (FMT_TEMP, 0, x));
12184: }
12185:
12186:
12187:
12188:
12189:
12190: public static int fmtCAd (char[] a, int o, long x) {
12191: if (x < 0L) {
12192: x = -x;
12193: a[o++] = '-';
12194: }
12195: if (x <= 99999999L) {
12196: return fmtCA8u (a, o, (int) x);
12197: } else if (x <= 9999999999999999L) {
12198: long h = x / 100000000L;
12199: return fmtCA08u (a, fmtCA8u (a, o, (int) h), (int) (x - h * 100000000L));
12200: } else {
12201: long hh = x / 10000000000000000L;
12202: x -= hh * 10000000000000000L;
12203: long h = x / 100000000L;
12204: return fmtCA08u (a, fmtCA08u (a, fmtCA4u (a, o, (int) hh), (int) h), (int) (x - h * 100000000L));
12205: }
12206: }
12207: public static StringBuilder fmtSBd (StringBuilder sb, long x) {
12208: return sb.append (FMT_TEMP, 0, fmtCAd (FMT_TEMP, 0, x));
12209: }
12210:
12211:
12212:
12213:
12214:
12215:
12216: public static int fmtCAnd (char[] a, int o, int n, long x) {
12217: int t = fmtCAd (a, o, x);
12218: n += o;
12219: if (t < n) {
12220: int i = n;
12221: while (o < t) {
12222: a[--i] = a[--t];
12223: }
12224: while (o < i) {
12225: a[--i] = ' ';
12226: }
12227: t = n;
12228: }
12229: return t;
12230: }
12231: public static StringBuilder fmtSBnd (StringBuilder sb, int n, int x) {
12232: return sb.append (FMT_TEMP, 0, fmtCAnd (FMT_TEMP, 0, n, x));
12233: }
12234:
12235:
12236:
12237:
12238:
12239:
12240:
12241:
12242:
12243:
12244:
12245:
12246:
12247: public static int fmtParseInt (String s, int i, int min, int max, int err) {
12248: return fmtParseIntRadix (s, i, min, max, err, 10);
12249: }
12250: public static int fmtParseIntRadix (String s, int i, int min, int max, int err, int radix) {
12251: if (s == null) {
12252: return err;
12253: }
12254: int l = s.length ();
12255: int c = i < l ? s.charAt (i++) : -1;
12256:
12257: while (c == ' ' || c == '\t') {
12258: c = i < l ? s.charAt (i++) : -1;
12259: }
12260:
12261: int n = 0;
12262: if (c == '+') {
12263: c = i < l ? s.charAt (i++) : -1;
12264: } else if (c == '-') {
12265: n = 1;
12266: c = i < l ? s.charAt (i++) : -1;
12267: }
12268:
12269:
12270:
12271:
12272: int o;
12273: int p;
12274: if (c == '$') {
12275: o = 0x07ffffff + n;
12276: p = 15 + n & 15;
12277: radix = 16;
12278: c = i < l ? s.charAt (i++) : -1;
12279: } else if (radix == 16) {
12280: o = 0x07ffffff + n;
12281: p = 15 + n & 15;
12282: } else if (radix == 8) {
12283: o = 0x0fffffff + n;
12284: p = 7 + n & 7;
12285: } else if (radix == 2) {
12286: o = 0x3fffffff + n;
12287: p = 1 + n & 1;
12288: } else {
12289: o = 214748364;
12290: p = 7 + n;
12291: radix = 10;
12292: }
12293:
12294: int x = Character.digit (c, radix);
12295: if (x < 0) {
12296: return err;
12297: }
12298: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12299: while (c >= 0) {
12300: int t = x - o;
12301: if (t > 0 || t == 0 && c > p) {
12302: return err;
12303: }
12304: x = x * radix + c;
12305: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12306: }
12307: if (n != 0) {
12308: x = -x;
12309: }
12310: return min <= x && x <= max ? x : err;
12311: }
12312:
12313:
12314:
12315:
12316:
12317:
12318:
12319:
12320:
12321:
12322: public static long matMax3 (long x1, long x2, long x3) {
12323: return Math.max (Math.max (x1, x2), x3);
12324: }
12325: public static long matMax4 (long x1, long x2, long x3, long x4) {
12326: return Math.max (Math.max (x1, x2), Math.max (x3, x4));
12327: }
12328: public static long matMax5 (long x1, long x2, long x3, long x4, long x5) {
12329: return Math.max (Math.max (Math.max (x1, x2), Math.max (x3, x4)), x5);
12330: }
12331:
12332:
12333:
12334:
12335:
12336: public static long matMin3 (long x1, long x2, long x3) {
12337: return Math.min (Math.min (x1, x2), x3);
12338: }
12339: public static long matMin4 (long x1, long x2, long x3, long x4) {
12340: return Math.min (Math.min (x1, x2), Math.min (x3, x4));
12341: }
12342: public static long matMin5 (long x1, long x2, long x3, long x4, long x5) {
12343: return Math.min (Math.min (Math.min (x1, x2), Math.min (x3, x4)), x5);
12344: }
12345:
12346:
12347:
12348:
12349:
12350:
12351:
12352:
12353:
12354:
12355:
12356:
12357: public static String strEncodeUTF8 (String s) {
12358: StringBuilder sb = new StringBuilder ();
12359: int l = s.length ();
12360: for (int i = 0; i < l; i++) {
12361: int u = s.charAt (i);
12362: if (0xd800 <= u && u <= 0xdbff && i + 1 < l) {
12363: int v = s.charAt (i + 1);
12364: if (0xdc00 <= v && v <= 0xdfff) {
12365: u = 0x10000 + ((u & 0x3ff) << 10) + (v & 0x3ff);
12366: i++;
12367: }
12368: }
12369: if ((u & 0xffffff80) == 0) {
12370: sb.append ((char) u);
12371: } else if ((u & 0xfffff800) == 0) {
12372: u = (0x0000c080 |
12373: (u & 0x000007c0) << 2 |
12374: (u & 0x0000003f));
12375: sb.append ((char) (u >> 8)).append ((char) (u & 0xff));
12376: } else if ((u & 0xffff0000) == 0 && !(0xd800 <= u && u <= 0xdfff)) {
12377: u = (0x00e08080 |
12378: (u & 0x0000f000) << 4 |
12379: (u & 0x00000fc0) << 2 |
12380: (u & 0x0000003f));
12381: sb.append ((char) (u >> 16)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12382: } else if ((u & 0xffe00000) == 0) {
12383: u = (0xf0808080 |
12384: (u & 0x001c0000) << 6 |
12385: (u & 0x0003f000) << 4 |
12386: (u & 0x00000fc0) << 2 |
12387: (u & 0x0000003f));
12388: sb.append ((char) ((u >> 24) & 0xff)).append ((char) ((u >> 16) & 0xff)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12389: } else {
12390: sb.append ((char) 0xef).append ((char) 0xbf).append ((char) 0xbd);
12391: }
12392: }
12393: return sb.toString ();
12394: }
12395:
12396:
12397:
12398:
12399:
12400:
12401:
12402: public static String strDecodeUTF8 (String s) {
12403: StringBuilder sb = new StringBuilder ();
12404: int l = s.length ();
12405: for (int i = 0; i < l; i++) {
12406: int c = s.charAt (i) & 0xff;
12407: for (int k = ((c & 0x80) == 0x00 ? 0 :
12408: (c & 0xe0) == 0xc0 ? 1 :
12409: (c & 0xf0) == 0xe0 ? 2 :
12410: (c & 0xf8) == 0xf0 ? 3 :
12411: -1);
12412: --k >= 0; ) {
12413: c = c << 8 | (i + 1 < l ? s.charAt (++i) & 0xff : 0);
12414: }
12415: int u = ((c & 0xffffff80) == 0x00000000 ? c :
12416: (c & 0xffffe0c0) == 0x0000c080 ? ((c & 0x00001f00) >> 2 |
12417: (c & 0x0000003f)) :
12418: (c & 0xfff0c0c0) == 0x00e08080 ? ((c & 0x000f0000) >> 4 |
12419: (c & 0x00003f00) >> 2 |
12420: (c & 0x0000003f)) :
12421: (c & 0xf8c0c0c0) == 0xf0808080 ? ((c & 0x07000000) >> 6 |
12422: (c & 0x003f0000) >> 4 |
12423: (c & 0x00003f00) >> 2 |
12424: (c & 0x0000003f)) :
12425: 0xfffd);
12426: if (u <= 0x0000ffff) {
12427: sb.append (0xd800 <= u && u <= 0xdfff ? '\ufffd' :
12428: (char) u);
12429: } else if (u <= 0x0010ffff) {
12430: u -= 0x000010000;
12431: sb.append ((char) (0xd800 + ((u >> 10) & 0x3ff))).append ((char) (0xdc00 + (u & 0x3ff)));
12432: }
12433: }
12434: return sb.toString ();
12435: }
12436:
12437:
12438:
12439:
12440:
12441: public static final int[] IsURIChar = {
12442:
12443:
12444: 0b00000000_00000000_00000000_00000000,
12445: 0b00000000_00000110_11111111_11000000,
12446: 0b01111111_11111111_11111111_11100001,
12447: 0b01111111_11111111_11111111_11100010,
12448: };
12449: public static String strEncodeURI (String s) {
12450: s = strEncodeUTF8 (s);
12451: StringBuilder sb = new StringBuilder ();
12452: int l = s.length ();
12453: for (int i = 0; i < l; i++) {
12454: int c = s.charAt (i);
12455: if (c < 0x80 && IsURIChar[c >> 5] << c < 0) {
12456: sb.append ((char) c);
12457: } else {
12458: fmtHex2 (sb.append ('%'), c);
12459: }
12460: }
12461: return sb.toString ();
12462: }
12463:
12464:
12465:
12466:
12467:
12468: public static final byte[] strIsHexChar = {
12469:
12470: -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,
12471: -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,
12472: -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,
12473: -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,
12474: };
12475: public static String strDecodeURI (String s) {
12476: StringBuilder sb = new StringBuilder ();
12477: int l = s.length ();
12478: for (int i = 0; i < l; i++) {
12479: int c = s.charAt (i);
12480: if (c == '%' && i + 2 < l) {
12481: int d = s.charAt (i + 1);
12482: int e = s.charAt (i + 2);
12483: if (d < 0x80 && (d = strIsHexChar[d]) >= 0 &&
12484: e < 0x80 && (e = strIsHexChar[e]) >= 0) {
12485: sb.append ((char) (d << 4 | e));
12486: } else {
12487: sb.append ((char) c);
12488: }
12489: } else {
12490: sb.append ((char) c);
12491: }
12492: }
12493: return sb.toString ();
12494: }
12495:
12496:
12497:
12498:
12499:
12500:
12501:
12502:
12503: public static BufferedImage createImage (int width, int height, String pattern, int... rgbs) {
12504: BufferedImage image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
12505: int[] bitmap = ((DataBufferInt) image.getRaster ().getDataBuffer ()).getData ();
12506: int length = width * height;
12507: for (int i = 0; i < length; i++) {
12508: char c = pattern.charAt (i);
12509: bitmap[i] = rgbs[c < '0' ? 0 : Character.digit (c, 16)];
12510: }
12511: return image;
12512: }
12513:
12514:
12515:
12516: public static ImageIcon createImageIcon (int width, int height, String pattern, int... rgbs) {
12517: return new ImageIcon (createImage (width, height, pattern, rgbs));
12518: }
12519:
12520:
12521:
12522: public static TexturePaint createTexturePaint (int width, int height, String pattern, int... rgbs) {
12523: return new TexturePaint (createImage (width, height, pattern, rgbs), new Rectangle (0, 0, width, height));
12524: }
12525:
12526:
12527:
12528: public static BufferedImage loadImage (String name) {
12529: BufferedImage image = null;
12530: try {
12531: image = ImageIO.read (new File (name));
12532: } catch (Exception e) {
12533: }
12534: return image;
12535: }
12536:
12537:
12538:
12539:
12540: public static boolean saveImage (BufferedImage image, String name) {
12541: return saveImage (image, name, 0.75F);
12542: }
12543: public static boolean saveImage (BufferedImage image, String name, float quality) {
12544: int index = name.lastIndexOf (".");
12545: if (index < 0) {
12546: return false;
12547: }
12548: if (name.substring (index).equalsIgnoreCase (".ico")) {
12549: return saveIcon (name, image);
12550: }
12551: Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix (name.substring (index + 1));
12552: if (!iterator.hasNext ()) {
12553: return false;
12554: }
12555: ImageWriter imageWriter = iterator.next ();
12556: ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam ();
12557: if (imageWriteParam.canWriteCompressed ()) {
12558: imageWriteParam.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);
12559: imageWriteParam.setCompressionQuality (quality);
12560: }
12561: try {
12562: File file = new File (name);
12563: ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream (file);
12564: imageWriter.setOutput (imageOutputStream);
12565: imageWriter.write (null, new IIOImage (image, null, null), imageWriteParam);
12566: imageOutputStream.close ();
12567: } catch (Exception e) {
12568:
12569: return false;
12570: }
12571: return true;
12572: }
12573:
12574:
12575:
12576:
12577:
12578:
12579:
12580:
12581:
12582:
12583:
12584:
12585:
12586:
12587:
12588:
12589:
12590:
12591:
12592:
12593:
12594:
12595:
12596:
12597:
12598:
12599:
12600:
12601:
12602:
12603:
12604:
12605:
12606:
12607:
12608:
12609:
12610:
12611:
12612:
12613:
12614:
12615:
12616:
12617:
12618:
12619:
12620:
12621:
12622:
12623:
12624:
12625:
12626:
12627:
12628:
12629:
12630:
12631:
12632:
12633:
12634:
12635:
12636:
12637:
12638:
12639:
12640:
12641:
12642:
12643:
12644:
12645:
12646: public static boolean saveIcon (String fileName, BufferedImage... arrayImage) {
12647: int iconCount = arrayImage.length;
12648: int[][] arrayPaletTable = new int[iconCount][];
12649: int[] arrayPaletCount = new int[iconCount];
12650: int[] arrayPixelBits = new int[iconCount];
12651: int[] arrayPatternLineSize = new int[iconCount];
12652: int[] arrayMaskLineSize = new int[iconCount];
12653: int[] arrayImageSize = new int[iconCount];
12654: int[] arrayImageOffset = new int[iconCount];
12655: int fileSize = 6 + 16 * iconCount;
12656: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
12657: BufferedImage image = arrayImage[iconNumber];
12658: int width = image.getWidth ();
12659: int height = image.getHeight ();
12660:
12661: int[] paletTable = new int[256];
12662: int paletCount = 0;
12663: countPalet:
12664: for (int y = height - 1; y >= 0; y--) {
12665: for (int x = 0; x < width; x++) {
12666: int rgb = image.getRGB (x, y);
12667: if (rgb >>> 24 != 0xff) {
12668: continue;
12669: }
12670: int l = 0;
12671: int r = paletCount;
12672: while (l < r) {
12673: int m = l + r >> 1;
12674: if (paletTable[m] < rgb) {
12675: l = m + 1;
12676: } else {
12677: r = m;
12678: }
12679: }
12680: if (l == paletCount || paletTable[l] != rgb) {
12681: if (paletCount == 256) {
12682: paletCount = 0;
12683: break countPalet;
12684: }
12685: for (int i = paletCount; i > l; i--) {
12686: paletTable[i] = paletTable[i - 1];
12687: }
12688: paletTable[l] = rgb;
12689: paletCount++;
12690: }
12691: }
12692: }
12693: int pixelBits = (paletCount == 0 ? 24 :
12694: paletCount > 16 ? 8 :
12695: paletCount > 4 ? 4 :
12696: paletCount > 2 ? 2 :
12697: 1);
12698: int patternLineSize = pixelBits * width + 31 >> 5 << 2;
12699: int maskLineSize = width + 31 >> 5 << 2;
12700: int imageSize = 40 + 4 * paletCount + patternLineSize * height + maskLineSize * height;
12701: arrayPaletTable[iconNumber] = paletTable;
12702: arrayPaletCount[iconNumber] = paletCount;
12703: arrayPixelBits[iconNumber] = pixelBits;
12704: arrayPatternLineSize[iconNumber] = patternLineSize;
12705: arrayMaskLineSize[iconNumber] = maskLineSize;
12706: arrayImageSize[iconNumber] = imageSize;
12707: arrayImageOffset[iconNumber] = fileSize;
12708: fileSize += imageSize;
12709: }
12710: byte[] bb = new byte[fileSize];
12711:
12712: ByteArray.byaWiw (bb, 0, 0);
12713: ByteArray.byaWiw (bb, 2, 1);
12714: ByteArray.byaWiw (bb, 4, iconCount);
12715: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
12716: BufferedImage image = arrayImage[iconNumber];
12717: int width = image.getWidth ();
12718: int height = image.getHeight ();
12719: int[] paletTable = arrayPaletTable[iconNumber];
12720: int paletCount = arrayPaletCount[iconNumber];
12721: int pixelBits = arrayPixelBits[iconNumber];
12722: int patternLineSize = arrayPatternLineSize[iconNumber];
12723: int maskLineSize = arrayMaskLineSize[iconNumber];
12724: int imageSize = arrayImageSize[iconNumber];
12725: int imageOffset = arrayImageOffset[iconNumber];
12726:
12727: int o = 6 + 16 * iconNumber;
12728: ByteArray.byaWb (bb, o, width);
12729: ByteArray.byaWb (bb, o + 1, height);
12730: ByteArray.byaWb (bb, o + 2, paletCount);
12731: ByteArray.byaWb (bb, o + 3, 0);
12732: ByteArray.byaWiw (bb, o + 4, 1);
12733: ByteArray.byaWiw (bb, o + 6, pixelBits);
12734: ByteArray.byaWil (bb, o + 8, imageSize);
12735: ByteArray.byaWil (bb, o + 12, imageOffset);
12736:
12737: o = imageOffset;
12738: ByteArray.byaWil (bb, o, 40);
12739: ByteArray.byaWil (bb, o + 4, width);
12740: ByteArray.byaWil (bb, o + 8, height * 2);
12741: ByteArray.byaWiw (bb, o + 12, 1);
12742: ByteArray.byaWiw (bb, o + 14, pixelBits);
12743: ByteArray.byaWil (bb, o + 16, 0);
12744: ByteArray.byaWil (bb, o + 20, 0);
12745: ByteArray.byaWil (bb, o + 24, 0);
12746: ByteArray.byaWil (bb, o + 28, 0);
12747: ByteArray.byaWil (bb, o + 32, paletCount);
12748: ByteArray.byaWil (bb, o + 36, 0);
12749:
12750: o += 40;
12751: for (int i = 0; i < paletCount; i++) {
12752: ByteArray.byaWil (bb, o, paletTable[i] & 0x00ffffff);
12753: o += 4;
12754: }
12755:
12756: for (int y = height - 1; y >= 0; y--) {
12757: for (int x = 0; x < width; x++) {
12758: int rgb = image.getRGB (x, y);
12759: if (rgb >>> 24 != 0xff) {
12760: continue;
12761: }
12762: if (pixelBits == 24) {
12763: bb[o + 3 * x] = (byte) rgb;
12764: bb[o + 3 * x + 1] = (byte) (rgb >> 8);
12765: bb[o + 3 * x + 2] = (byte) (rgb >> 16);
12766: continue;
12767: }
12768: int l = 0;
12769: int r = paletCount;
12770: while (l < r) {
12771: int m = l + r >> 1;
12772: if (paletTable[m] < rgb) {
12773: l = m + 1;
12774: } else {
12775: r = m;
12776: }
12777: }
12778: if (l != 0) {
12779: if (pixelBits == 8) {
12780: bb[o + x] = (byte) l;
12781: } else if (pixelBits == 4) {
12782: bb[o + (x >> 1)] |= (byte) (l << ((~x & 1) << 2));
12783: } else if (pixelBits == 2) {
12784: bb[o + (x >> 2)] |= (byte) (l << ((~x & 3) << 1));
12785: } else {
12786: bb[o + (x >> 3)] |= (byte) (l << (~x & 7));
12787: }
12788: }
12789: }
12790: o += patternLineSize;
12791: }
12792:
12793: for (int y = height - 1; y >= 0; y--) {
12794: for (int x = 0; x < width; x++) {
12795: int rgb = image.getRGB (x, y);
12796: if (rgb >>> 24 != 0xff) {
12797: bb[o + (x >> 3)] |= (byte) (1 << (~x & 7));
12798: }
12799: }
12800: o += maskLineSize;
12801: }
12802: }
12803: return rscPutFile (fileName, bb, 0, fileSize);
12804: }
12805:
12806:
12807:
12808: }
12809:
12810:
12811: