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.28";
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: if (PNL_ROUNDED_CORNER_ON) {
1115: pnlRoundedCornerModel = new SpinnerNumberModel (pnlRoundedCornerRatio, 0, 50, 1);
1116: pnlRoundedCornerSpinner = ComponentFactory.createNumberSpinner (pnlRoundedCornerModel, 2, new ChangeListener () {
1117: @Override public void stateChanged (ChangeEvent ce) {
1118: pnlRoundedCornerRatio = pnlRoundedCornerModel.getNumber ().intValue ();
1119: if (PNL_ROUNDED_CORNER_TEST || pnlMode == PNL_FULLSCREEN) {
1120: pnlUpdateArrangement ();
1121: }
1122: }
1123: });
1124: }
1125:
1126: }
1127:
1128:
1129:
1130: public static double pnlGetRefreshRate () {
1131: double rate = 0.0;
1132: GraphicsConfiguration gc = frmFrame.getGraphicsConfiguration ();
1133: if (gc != null) {
1134: GraphicsDevice gd = gc.getDevice ();
1135: DisplayMode dm = gd.getDisplayMode ();
1136: int i = dm.getRefreshRate ();
1137: if (i != DisplayMode.REFRESH_RATE_UNKNOWN) {
1138: rate = (i == 23 ? 23.98 :
1139: i == 29 ? 29.97 :
1140: i == 59 ? 59.94 :
1141: i == 119 ? 119.88 :
1142: i == 239 ? 239.76 :
1143: (double) i);
1144: if (rate < PNL_MIN_RATE || PNL_MAX_RATE < rate) {
1145: rate = 0.0;
1146: }
1147: }
1148: }
1149: if (rate == 0.0) {
1150: rate = PNL_DEFAULT_RATE;
1151: System.out.printf (Multilingual.mlnJapanese ?
1152: "ホストのリフレッシュレートを取得できません。デフォルトの %.2f Hz を使います\n" :
1153: "Cannot get host refresh rate. Use default %.2f Hz\n", rate);
1154: } else {
1155: System.out.printf (Multilingual.mlnJapanese ?
1156: "ホストのリフレッシュレートは %.2f Hz です\n" :
1157: "Host refresh rate is %.2f Hz\n", rate);
1158: }
1159: return rate;
1160: }
1161:
1162:
1163: public static void pnlSetStereoscopic (boolean on, int method) {
1164: if (pnlStereoscopicOn != on || pnlStereoscopicMethod != method) {
1165: pnlStereoscopicMethod = method;
1166: pnlStereoscopicFactor = on && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1167: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1168: if (!pnlStereoscopicOn && on) {
1169: if (PNL_USE_THREAD) {
1170: for (int n = 0; n < 4; n++) {
1171: System.arraycopy (pnlBMLeftArray[n], 0, pnlBMRightArray[n], 0, 1024 * 1024);
1172: }
1173: } else {
1174: System.arraycopy (pnlBMLeft, 0, pnlBMRight, 0, 1024 * 1024);
1175: }
1176: } else if (pnlStereoscopicOn && !on) {
1177: if (PNL_USE_THREAD) {
1178: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
1179: } else {
1180: pnlBM = pnlBMLeft;
1181: }
1182: }
1183: pnlStereoscopicOn = on;
1184: pnlUpdateArrangement ();
1185: }
1186: }
1187:
1188:
1189: public static void pnlTini () {
1190: pnlTini2 ();
1191: if (PNL_USE_THREAD) {
1192: if (pnlThread != null) {
1193: pnlThread.interrupt ();
1194: try {
1195: pnlThread.join ();
1196: } catch (InterruptedException ie) {
1197: }
1198: pnlThread = null;
1199: }
1200: }
1201:
1202:
1203: Settings.sgsPutInt ("fixedscale", pnlFixedScale);
1204:
1205:
1206: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
1207: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[key];
1208: int value = pnlAspectMap[key];
1209: String screenName = PNL_ASPECT_SCREEN_NAME[value];
1210: Settings.sgsPutString ("aspectratio" + resolutionName, screenName);
1211: }
1212:
1213:
1214: Settings.sgsPutString ("interpolation",
1215: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR ? "nearest" :
1216: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR ? "bilinear" :
1217: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC ? "bicubic" :
1218: "bilinear");
1219:
1220: if (pnlRefreshRate != PNL_DEFAULT_RATE) {
1221: Settings.sgsPutString ("refreshrate",
1222: pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate));
1223: }
1224: Settings.sgsPutOnOff ("adjustvsync", pnlAdjustVsync);
1225:
1226: Settings.sgsPutOnOff ("hidekeyboard", pnlHideKeyboard);
1227:
1228: if (PNL_USE_CANVAS) {
1229: Settings.sgsPutOnOff ("usecanvas", pnlUseCanvasRequest);
1230: }
1231:
1232:
1233: Settings.sgsPutOnOff ("stereoscopic", pnlStereoscopicOn);
1234: Settings.sgsPutString ("stereoscopicmethod",
1235: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ? "nakedeyecrossing" :
1236: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL ? "nakedeyeparallel" :
1237: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ? "sidebyside" :
1238: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM ? "topandbottom" :
1239: "nakedeyecrossing");
1240:
1241:
1242: if (PNL_ROTATION_ON) {
1243: Settings.sgsPutInt ("rotation", pnlRotationMode);
1244: }
1245:
1246: }
1247:
1248:
1249:
1250: public static void pnlUpdateAspectTable () {
1251: float[] ratio = new float[PNL_ASPECT_KEYS];
1252: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
1253: int value = pnlAspectMap[key];
1254: ratio[key] = PNL_ASPECT_MATRIX[key][value];
1255: }
1256: pnlAspectTable[0] = ratio[0] * 2.0F;
1257: pnlAspectTable[1] = ratio[2];
1258: pnlAspectTable[2] = ratio[3];
1259: pnlAspectTable[3] = ratio[3];
1260: pnlAspectTable[4] = ratio[1] * 4.0F;
1261: pnlAspectTable[5] = ratio[1] * 2.0F;
1262: pnlAspectTable[6] = ratio[3];
1263: pnlAspectTable[7] = ratio[3];
1264: }
1265:
1266:
1267:
1268: public static void pnlMake () {
1269: pnlMake2 ();
1270:
1271:
1272: if (PNL_USE_CANVAS && pnlUseCanvas) {
1273: pnlCanvas = new Canvas ();
1274: pnlPanel = new JPanel (new BorderLayout (0, 0));
1275: pnlPanel.add (pnlCanvas, BorderLayout.CENTER);
1276: pnlCanvasOrPanel = pnlCanvas;
1277: } else {
1278: pnlPanel = new JPanel () {
1279: @Override protected void paintComponent (Graphics g) {
1280: pnlPaintCommon (g);
1281: }
1282: @Override protected void paintBorder (Graphics g) {
1283: }
1284: @Override protected void paintChildren (Graphics g) {
1285: }
1286: };
1287: pnlCanvasOrPanel = pnlPanel;
1288: }
1289: pnlPanel.setBackground (Color.black);
1290: pnlPanel.setOpaque (true);
1291: pnlPanel.setPreferredSize (pnlSize);
1292:
1293: if (Mouse.musCursorAvailable) {
1294: pnlPanel.setCursor (Mouse.musCursorArray[1]);
1295: }
1296:
1297: }
1298:
1299:
1300:
1301: public static void pnlPaintCommon (Graphics g) {
1302: Graphics2D g2 = (Graphics2D) g;
1303: if (PNL_FILL_BACKGROUND || pnlFillBackgroundRequest) {
1304: if (!PNL_FILL_BACKGROUND) {
1305: pnlFillBackgroundRequest = false;
1306: }
1307: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1308: g2.setColor (Color.black);
1309: g2.fillRect (0, 0, pnlWidth, pnlHeight);
1310: }
1311: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, pnlInterpolation);
1312: if (PNL_USE_THREAD) {
1313: int d = pnlBMWrite - pnlBMRead;
1314: if (false) {
1315: System.out.print (d);
1316: }
1317: if (d < 1) {
1318: pnlBMRead += d - 1;
1319: } else if (3 < d) {
1320: pnlBMRead += d - 3;
1321: }
1322: int n = pnlBMRead++ & 3;
1323: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1324: BufferedImage leftImage;
1325: BufferedImage rightImage;
1326: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1327: leftImage = pnlScreenImageRightArray[n];
1328: rightImage = pnlScreenImageLeftArray[n];
1329: } else {
1330:
1331:
1332:
1333: leftImage = pnlScreenImageLeftArray[n];
1334: rightImage = pnlScreenImageRightArray[n];
1335: }
1336: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1337: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1338: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1339: } else {
1340: g2.drawImage (leftImage,
1341: pnlScreenX1, pnlScreenY1,
1342: pnlScreenX2, pnlScreenY2,
1343: 0, 0, pnlScreenWidth, pnlScreenHeight,
1344: null);
1345: g2.drawImage (rightImage,
1346: pnlScreenX3, pnlScreenY3,
1347: pnlScreenX4, pnlScreenY4,
1348: 0, 0, pnlScreenWidth, pnlScreenHeight,
1349: null);
1350: }
1351: } else {
1352: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1353: g2.drawImage (pnlScreenSubImageLeftArray[n], pnlRotationTransformLeft, null);
1354: } else {
1355: g2.drawImage (pnlScreenImageLeftArray[n],
1356: pnlScreenX1, pnlScreenY1,
1357: pnlScreenX2, pnlScreenY2,
1358: 0, 0, pnlScreenWidth, pnlScreenHeight,
1359: null);
1360: }
1361: }
1362: } else {
1363: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1364: BufferedImage leftImage;
1365: BufferedImage rightImage;
1366: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1367: leftImage = pnlScreenImageRight;
1368: rightImage = pnlScreenImageLeft;
1369: } else {
1370:
1371:
1372:
1373: leftImage = pnlScreenImageLeft;
1374: rightImage = pnlScreenImageRight;
1375: }
1376: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1377: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1378: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1379: } else {
1380: g2.drawImage (leftImage,
1381: pnlScreenX1, pnlScreenY1,
1382: pnlScreenX2, pnlScreenY2,
1383: 0, 0, pnlScreenWidth, pnlScreenHeight,
1384: null);
1385: g2.drawImage (rightImage,
1386: pnlScreenX3, pnlScreenY3,
1387: pnlScreenX4, pnlScreenY4,
1388: 0, 0, pnlScreenWidth, pnlScreenHeight,
1389: null);
1390: }
1391: } else {
1392: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1393: g2.drawImage (pnlScreenImageLeft, pnlRotationTransformLeft, null);
1394: } else {
1395: g2.drawImage (pnlScreenImageLeft,
1396: pnlScreenX1, pnlScreenY1,
1397: pnlScreenX2, pnlScreenY2,
1398: 0, 0, pnlScreenWidth, pnlScreenHeight,
1399: null);
1400: }
1401: }
1402: }
1403: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1404: g2.drawImage (Keyboard.kbdImage, pnlKeyboardX, pnlKeyboardY, null);
1405:
1406: if (TextCopy.txcEncloseEachTime && 0 <= TextCopy.txcRow1) {
1407: int x = TextCopy.txcCol1 << 3;
1408: int w = (TextCopy.txcCol2 - TextCopy.txcCol1 + 1) << 3;
1409: int y = TextCopy.txcRow1 << 4;
1410: int h = (TextCopy.txcRow2 - TextCopy.txcRow1 + 1) << 4;
1411: x -= CRTC.crtR10TxXCurr;
1412: y -= CRTC.crtR11TxYCurr;
1413: g2.setColor (Color.red);
1414: if (PNL_ROTATION_ON) {
1415: AffineTransform savedTransform = g2.getTransform ();
1416: g2.setTransform (pnlRotationTransformLeft);
1417: g2.drawRect (x, y, w, h);
1418: g2.setTransform (savedTransform);
1419: } else {
1420: g2.drawRect (pnlScreenX1 + ((x * pnlZoomRatioOutX) >> 16),
1421: pnlScreenY1 + ((y * pnlZoomRatioOutY) >> 16),
1422: ((w * pnlZoomRatioOutX) >> 16) - 1,
1423: ((h * pnlZoomRatioOutY) >> 16) - 1);
1424: }
1425: }
1426: if (Bubble.BBL_ON) {
1427: Bubble.bblDraw (g2);
1428: }
1429: }
1430:
1431:
1432:
1433:
1434: public static void pnlStart () {
1435: pnlStart2 ();
1436:
1437:
1438: ComponentFactory.addListener (
1439: pnlPanel,
1440: new ComponentAdapter () {
1441: @Override public void componentResized (ComponentEvent ce) {
1442: pnlUpdateArrangement ();
1443: }
1444: });
1445:
1446: if (PNL_USE_THREAD) {
1447: if (PNL_USE_CANVAS && pnlUseCanvas) {
1448: pnlCanvas.createBufferStrategy (2);
1449: pnlThread = new Thread () {
1450: @Override public void run () {
1451: do {
1452: BufferStrategy bs = pnlCanvas.getBufferStrategy ();
1453: if (bs != null) {
1454: Graphics g = bs.getDrawGraphics ();
1455: pnlPaintCommon (g);
1456: g.dispose ();
1457: bs.show ();
1458: }
1459: } while (!isInterrupted () && pnlWakeupCommon ());
1460: }
1461: };
1462: } else {
1463: pnlThread = new Thread () {
1464: @Override public void run () {
1465: do {
1466: pnlPanel.repaint ();
1467: if (!pnlWakeupCommon ()) {
1468: break;
1469: }
1470: } while (!isInterrupted () && pnlWakeupCommon ());
1471: }
1472: };
1473: }
1474: pnlWakeupTime = System.currentTimeMillis ();
1475: pnlWakeupTimeMNP = 0L;
1476: pnlThread.start ();
1477: }
1478:
1479: }
1480:
1481: public static boolean pnlWakeupCommon () {
1482: long t = System.currentTimeMillis ();
1483: if (CRTC.crtTotalLength == 0L) {
1484: pnlWakeupTime += 40L;
1485: } else {
1486: pnlWakeupTime += CRTC.crtTotalLength;
1487: pnlWakeupTimeMNP += CRTC.crtTotalLengthMNP;
1488: if (1000000000L <= pnlWakeupTimeMNP) {
1489: pnlWakeupTime++;
1490: pnlWakeupTimeMNP -= 1000000000L;
1491: }
1492: }
1493: pnlWakeupTime = Math.max (pnlWakeupTime, t + 4L);
1494: try {
1495: Thread.sleep (pnlWakeupTime - t);
1496: } catch (InterruptedException ie) {
1497: return false;
1498: }
1499: return true;
1500: }
1501:
1502:
1503:
1504:
1505:
1506: public static void pnlExitFullScreen (boolean dialog) {
1507: if (prgIsMac || !dialog) {
1508: pnlSetFullScreenOn (false);
1509: }
1510: }
1511:
1512:
1513:
1514: public static void pnlToggleFullScreen () {
1515: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1516: pnlSetMode (PNL_FULLSCREEN);
1517: } else {
1518: pnlSetMode (pnlPrevMode);
1519: }
1520: }
1521:
1522:
1523:
1524: public static void pnlToggleMaximized () {
1525: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1526: pnlSetMode (PNL_MAXIMIZED);
1527: } else {
1528: pnlSetMode (pnlPrevMode);
1529: }
1530: }
1531:
1532:
1533:
1534: public static void pnlSetFullScreenOn (boolean on) {
1535: if (on) {
1536: pnlSetMode (PNL_FULLSCREEN);
1537: } else if (pnlMode == PNL_FULLSCREEN) {
1538: pnlSetMode (pnlPrevMode);
1539: }
1540: }
1541:
1542:
1543:
1544:
1545: public static void pnlSetFitInWindowOn (boolean on) {
1546: if (!on) {
1547: pnlSetMode (PNL_FIXEDSCALE);
1548: } else if (pnlMode == PNL_FIXEDSCALE) {
1549: pnlSetMode (PNL_FITINWINDOW);
1550: }
1551: }
1552:
1553:
1554:
1555:
1556:
1557:
1558:
1559:
1560:
1561:
1562: public static void pnlUpdateArrangement () {
1563: pnlWidth = pnlPanel.getWidth ();
1564: pnlHeight = pnlPanel.getHeight ();
1565: frmMarginWidth = frmFrame.getWidth () - pnlWidth;
1566: frmMarginHeight = frmFrame.getHeight () - pnlHeight;
1567: pnlStretchMode = pnlAspectTable[CRTC.crtHRLCurr << 2 | CRTC.crtHResoCurr];
1568: pnlScreenWidth = Math.max (PNL_MIN_WIDTH, (CRTC.crtR03HDispEndCurr - CRTC.crtR02HBackEndCurr) << 3);
1569: pnlScreenHeight = Math.max (PNL_MIN_HEIGHT, (CRTC.crtR07VDispEndCurr - CRTC.crtR06VBackEndCurr) << (CRTC.crtInterlace || CRTC.crtSlit ? 1 : 0));
1570: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchMode);
1571: if (RasterBreakPoint.RBP_ON) {
1572:
1573: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
1574: RasterBreakPoint.rbpUpdateFrame ();
1575: }
1576: }
1577:
1578: pnlFixedScale = pnlFixedModel.getNumber ().intValue ();
1579:
1580: pnlRotatedWidth = pnlStretchWidth;
1581: pnlRotatedHeight = pnlScreenHeight;
1582: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1583: pnlRotatedWidth = pnlScreenHeight;
1584: pnlRotatedHeight = pnlStretchWidth;
1585: }
1586: if (pnlMode == PNL_FIXEDSCALE) {
1587:
1588:
1589:
1590:
1591:
1592: pnlZoomWidth = (pnlRotatedWidth * pnlFixedScale + 50) * 5243 >>> 19;
1593: pnlZoomHeight = (pnlRotatedHeight * pnlFixedScale + 50) * 5243 >>> 19;
1594: int width = Math.max (Math.max (PNL_MIN_WIDTH, pnlZoomWidth * pnlStereoscopicFactor), Keyboard.kbdWidth);
1595: int height = Math.max (PNL_MIN_HEIGHT, pnlZoomHeight) + Keyboard.kbdHeight;
1596: pnlScreenX1 = (width - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1597: pnlScreenY1 = (height - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1598: if (pnlWidth != width || pnlHeight != height) {
1599: pnlWidth = width;
1600: pnlHeight = height;
1601: pnlMinimumWidth = width;
1602: pnlMinimumHeight = height;
1603: pnlSize.setSize (width, height);
1604: pnlPanel.setMinimumSize (pnlSize);
1605: pnlPanel.setMaximumSize (pnlSize);
1606: pnlPanel.setPreferredSize (pnlSize);
1607: }
1608: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1609: frmFrame.setMinimumSize (frmMinimumSize);
1610: frmFrame.setMaximumSize (frmMinimumSize);
1611: frmFrame.setPreferredSize (frmMinimumSize);
1612: frmFrame.setResizable (false);
1613: frmFrame.pack ();
1614: } else {
1615:
1616: if (PNL_ROUNDED_CORNER_ON) {
1617:
1618: int screenWidth = pnlRotatedWidth * pnlStereoscopicFactor;
1619:
1620: int screenHeight = pnlRotatedHeight;
1621:
1622: int maximumWidth = pnlWidth;
1623:
1624: int maximumHeight = pnlHeight - Keyboard.kbdHeight;
1625:
1626:
1627:
1628: double cornerRadius = (!(PNL_ROUNDED_CORNER_TEST || pnlMode == PNL_FULLSCREEN) ||
1629: (pnlStereoscopicOn &&
1630: (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ||
1631: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM)) ? 0 :
1632: Math.min (pnlWidth, pnlHeight) * (double) pnlRoundedCornerRatio / 100.0);
1633:
1634: double cornerWidth = cornerRadius * 2.0;
1635:
1636: double cornerHeight = cornerRadius * (Keyboard.kbdHeight != 0 ? 1.0 : 2.0);
1637:
1638: double straightWidth = maximumWidth - cornerWidth;
1639:
1640: double straightHeight = maximumHeight - cornerHeight;
1641: if (maximumHeight * screenWidth <= straightWidth * screenHeight) {
1642:
1643:
1644:
1645: pnlZoomHeight = maximumHeight;
1646:
1647: pnlZoomWidth = (pnlZoomHeight * screenWidth + (screenHeight >> 1)) / screenHeight;
1648:
1649: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1650:
1651: pnlScreenX1 = ((maximumWidth >> 1) - (pnlZoomWidth >> 1)) >> 1;
1652: } else {
1653: pnlScreenX1 = (maximumWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1654: }
1655: pnlScreenY1 = 0;
1656: } else if (maximumWidth * screenHeight <= straightHeight * screenWidth) {
1657:
1658:
1659:
1660: pnlZoomWidth = maximumWidth;
1661:
1662: pnlZoomHeight = (pnlZoomWidth * screenHeight + (screenWidth >> 1)) / screenWidth;
1663:
1664: pnlScreenX1 = 0;
1665: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM) {
1666:
1667: pnlScreenY1 = ((maximumHeight >> 1) - (pnlZoomHeight >> 1)) >> 1;
1668: } else {
1669: pnlScreenY1 = (maximumHeight - pnlZoomHeight) >> 1;
1670: }
1671: } else {
1672:
1673:
1674:
1675:
1676:
1677:
1678:
1679:
1680:
1681:
1682:
1683:
1684:
1685:
1686:
1687:
1688:
1689:
1690:
1691:
1692:
1693:
1694:
1695: double ax = 1.0;
1696: double ay = 0.0;
1697: double bx = 0.0;
1698: double by = 1.0;
1699: for (int i = 0; i < 4; i++) {
1700: double mx;
1701: double my;
1702: if (false) {
1703: double t = (ax * bx - ay * by) * 0.5;
1704: mx = Math.sqrt (0.5 + t);
1705: my = Math.sqrt (0.5 - t);
1706: } else {
1707: double sx = ax + bx;
1708: double sy = ay + by;
1709: double t = Math.cbrt (2.0 + 3.0 * (ax * bx * sx + ay * by * sy));
1710: mx = sx / t;
1711: my = sy / t;
1712: }
1713:
1714: double temporaryWidth = straightWidth + mx * cornerWidth;
1715:
1716: double temporaryHeight = straightHeight + my * cornerHeight;
1717: if (temporaryHeight * screenWidth <= temporaryWidth * screenHeight) {
1718:
1719:
1720: ax = mx;
1721: ay = my;
1722: } else {
1723:
1724: bx = mx;
1725: by = my;
1726: }
1727: }
1728:
1729:
1730:
1731:
1732:
1733:
1734:
1735:
1736:
1737:
1738:
1739:
1740: double t = (((straightHeight + ay * cornerHeight) * screenWidth
1741: - (straightWidth + ax * cornerWidth) * screenHeight)
1742: / ((bx - ax) * cornerWidth * screenHeight
1743: - (by - ay) * cornerHeight * screenWidth));
1744:
1745: pnlZoomWidth = (int) Math.round (straightWidth + (ax + (bx - ax) * t) * cornerWidth);
1746: if (false) {
1747:
1748: pnlZoomHeight = (int) Math.round (straightHeight + (ay + (by - ay) * t) * cornerHeight);
1749: } else {
1750:
1751: pnlZoomHeight = (pnlZoomWidth * screenHeight + (screenWidth >> 1)) / screenWidth;
1752: }
1753:
1754: pnlScreenX1 = (maximumWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1755: pnlScreenY1 = (maximumHeight - pnlZoomHeight) >> 1;
1756: }
1757: } else {
1758: if (pnlWidth * pnlRotatedHeight >= (pnlHeight - Keyboard.kbdHeight) * (pnlRotatedWidth * pnlStereoscopicFactor)) {
1759:
1760:
1761:
1762:
1763:
1764:
1765:
1766:
1767:
1768:
1769:
1770:
1771: pnlZoomHeight = pnlHeight - Keyboard.kbdHeight;
1772: pnlZoomWidth = (pnlZoomHeight * pnlRotatedWidth + (pnlRotatedHeight >> 1)) / pnlRotatedHeight;
1773: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1774: pnlScreenX1 = ((pnlWidth >> 1) - (pnlZoomWidth >> 1)) >> 1;
1775: } else {
1776: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1777: }
1778: pnlScreenY1 = 0;
1779: } else {
1780:
1781:
1782:
1783:
1784:
1785:
1786:
1787:
1788:
1789:
1790:
1791:
1792:
1793:
1794:
1795:
1796: pnlZoomWidth = pnlWidth / pnlStereoscopicFactor;
1797: pnlZoomHeight = (pnlZoomWidth * pnlStereoscopicFactor * pnlRotatedHeight + (pnlRotatedWidth * pnlStereoscopicFactor >> 1)) / (pnlRotatedWidth * pnlStereoscopicFactor);
1798: pnlScreenX1 = 0;
1799: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM) {
1800: pnlScreenY1 = (((pnlHeight - Keyboard.kbdHeight) >> 1) - (pnlZoomHeight >> 1)) >> 1;
1801: } else {
1802: pnlScreenY1 = (pnlHeight - (pnlZoomHeight + Keyboard.kbdHeight)) >> 1;
1803: }
1804: }
1805: }
1806:
1807: int minimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
1808: int minimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
1809: if (pnlMinimumWidth != minimumWidth || pnlMinimumHeight != minimumHeight) {
1810: pnlMinimumWidth = minimumWidth;
1811: pnlMinimumHeight = minimumHeight;
1812: }
1813: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1814: frmFrame.setMinimumSize (frmMinimumSize);
1815: frmFrame.setMaximumSize (null);
1816: frmFrame.setResizable (true);
1817: }
1818:
1819: pnlArrangementCommon ();
1820: Mouse.musUpdateSpeedRatio ();
1821: if (!PNL_FILL_BACKGROUND) {
1822: pnlFillBackgroundRequest = true;
1823: }
1824: }
1825:
1826: public static void pnlArrangementCommon () {
1827: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1828: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1829: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) {
1830: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1831: pnlScreenX3 = pnlScreenX2;
1832: pnlScreenX4 = pnlScreenX3 + pnlZoomWidth;
1833: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1834: pnlScreenY3 = pnlScreenY1;
1835: pnlScreenY4 = pnlScreenY2;
1836: } else if (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1837: pnlScreenX2 = pnlScreenX1 + (pnlZoomWidth >> 1);
1838: pnlScreenX3 = pnlScreenX2;
1839: pnlScreenX4 = pnlScreenX3 + (pnlZoomWidth >> 1);
1840: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1841: pnlScreenY3 = pnlScreenY1;
1842: pnlScreenY4 = pnlScreenY2;
1843: } else {
1844: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1845: pnlScreenX3 = pnlScreenX1;
1846: pnlScreenX4 = pnlScreenX2;
1847: pnlScreenY2 = pnlScreenY1 + (pnlZoomHeight >> 1);
1848: pnlScreenY3 = pnlScreenY2;
1849: pnlScreenY4 = pnlScreenY3 + (pnlZoomHeight >> 1);
1850: }
1851: } else {
1852: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1853: pnlScreenX3 = pnlScreenX1;
1854: pnlScreenX4 = pnlScreenX2;
1855: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1856: pnlScreenY3 = pnlScreenY1;
1857: pnlScreenY4 = pnlScreenY2;
1858: }
1859: pnlKeyboardX = (pnlWidth - Keyboard.kbdWidth) >> 1;
1860: pnlKeyboardY = pnlScreenY4;
1861: pnlZoomRatioOutX = ((pnlZoomWidth * pnlStereoscopicFactor) << 16) / pnlScreenWidth;
1862: pnlZoomRatioOutY = (pnlZoomHeight << 16) / pnlScreenHeight;
1863: pnlZoomRatioInX = (pnlScreenWidth << 16) / (pnlZoomWidth * pnlStereoscopicFactor);
1864: pnlZoomRatioInY = (pnlScreenHeight << 16) / pnlZoomHeight;
1865: if (PNL_ROTATION_ON) {
1866:
1867: if (PNL_USE_THREAD) {
1868: for (int n = 0; n < 4; n++) {
1869: pnlScreenSubImageLeftArray[n] = pnlScreenImageLeftArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1870: pnlScreenSubImageRightArray[n] = pnlScreenImageRightArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1871: }
1872: } else {
1873: pnlScreenSubImageLeft = pnlScreenImageLeft.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1874: pnlScreenSubImageRight = pnlScreenImageRight.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1875: }
1876:
1877:
1878:
1879:
1880: double ax = 0.0;
1881: double ay = 0.0;
1882: double bx = (double) pnlScreenWidth;
1883: double by = (double) pnlScreenHeight;
1884: double l00, l10, l01, l11, l02, l12;
1885: double r00, r10, r01, r11, r02, r12;
1886: if (pnlRotationMode == 0) {
1887: double cx = (double) pnlScreenX1;
1888: double cy = (double) pnlScreenY1;
1889: double dx = (double) pnlScreenX2;
1890: double dy = (double) pnlScreenY2;
1891: l00 = (cx - dx) / (ax - bx);
1892: l10 = 0.0;
1893: l01 = 0.0;
1894: l11 = (cy - dy) / (ay - by);
1895: l02 = (ax * dx - bx * cx) / (ax - bx);
1896: l12 = (ay * dy - by * cy) / (ay - by);
1897: cx = (double) pnlScreenX3;
1898: cy = (double) pnlScreenY3;
1899: dx = (double) pnlScreenX4;
1900: dy = (double) pnlScreenY4;
1901: r00 = (cx - dx) / (ax - bx);
1902: r10 = 0.0;
1903: r01 = 0.0;
1904: r11 = (cy - dy) / (ay - by);
1905: r02 = (ax * dx - bx * cx) / (ax - bx);
1906: r12 = (ay * dy - by * cy) / (ay - by);
1907: } else if (pnlRotationMode == 1) {
1908: double cx = (double) pnlScreenX1;
1909: double cy = (double) pnlScreenY1;
1910: double dx = (double) pnlScreenX2;
1911: double dy = (double) pnlScreenY2;
1912: l00 = 0.0;
1913: l10 = (dy - cy) / (ax - bx);
1914: l01 = (cx - dx) / (ay - by);
1915: l11 = 0.0;
1916: l02 = (ay * dx - by * cx) / (ay - by);
1917: l12 = (ax * cy - bx * dy) / (ax - bx);
1918: cx = (double) pnlScreenX3;
1919: cy = (double) pnlScreenY3;
1920: dx = (double) pnlScreenX4;
1921: dy = (double) pnlScreenY4;
1922: r00 = 0.0;
1923: r10 = (dy - cy) / (ax - bx);
1924: r01 = (cx - dx) / (ay - by);
1925: r11 = 0.0;
1926: r02 = (ay * dx - by * cx) / (ay - by);
1927: r12 = (ax * cy - bx * dy) / (ax - bx);
1928: } else if (pnlRotationMode == 2) {
1929: double cx = (double) pnlScreenX1;
1930: double cy = (double) pnlScreenY1;
1931: double dx = (double) pnlScreenX2;
1932: double dy = (double) pnlScreenY2;
1933: l00 = (dx - cx) / (ax - bx);
1934: l10 = 0.0;
1935: l01 = 0.0;
1936: l11 = (dy - cy) / (ay - by);
1937: l02 = (ax * cx - bx * dx) / (ax - bx);
1938: l12 = (ay * cy - by * dy) / (ay - by);
1939: cx = (double) pnlScreenX3;
1940: cy = (double) pnlScreenY3;
1941: dx = (double) pnlScreenX4;
1942: dy = (double) pnlScreenY4;
1943: r00 = (dx - cx) / (ax - bx);
1944: r10 = 0.0;
1945: r01 = 0.0;
1946: r11 = (dy - cy) / (ay - by);
1947: r02 = (ax * cx - bx * dx) / (ax - bx);
1948: r12 = (ay * cy - by * dy) / (ay - by);
1949: } else {
1950: double cx = (double) pnlScreenX1;
1951: double cy = (double) pnlScreenY1;
1952: double dx = (double) pnlScreenX2;
1953: double dy = (double) pnlScreenY2;
1954: l00 = 0.0;
1955: l10 = (cy - dy) / (ax - bx);
1956: l01 = (dx - cx) / (ay - by);
1957: l11 = 0.0;
1958: l02 = (ay * cx - by * dx) / (ay - by);
1959: l12 = (ax * dy - bx * cy) / (ax - bx);
1960: cx = (double) pnlScreenX3;
1961: cy = (double) pnlScreenY3;
1962: dx = (double) pnlScreenX4;
1963: dy = (double) pnlScreenY4;
1964: r00 = 0.0;
1965: r10 = (cy - dy) / (ax - bx);
1966: r01 = (dx - cx) / (ay - by);
1967: r11 = 0.0;
1968: r02 = (ay * cx - by * dx) / (ay - by);
1969: r12 = (ax * dy - bx * cy) / (ax - bx);
1970: }
1971: pnlRotationTransformLeft.setTransform (l00, l10, l01, l11, l02, l12);
1972: pnlRotationTransformRight.setTransform (r00, r10, r01, r11, r02, r12);
1973: pnlMatrixL00 = l00;
1974: pnlMatrixL10 = l10;
1975: pnlMatrixL01 = l01;
1976: pnlMatrixL11 = l11;
1977: pnlMatrixL02 = l02;
1978: pnlMatrixL12 = l12;
1979: pnlMatrixR00 = r00;
1980: pnlMatrixR10 = r10;
1981: pnlMatrixR01 = r01;
1982: pnlMatrixR11 = r11;
1983: pnlMatrixR02 = r02;
1984: pnlMatrixR12 = r12;
1985:
1986:
1987:
1988:
1989:
1990:
1991: double d = l00 * l11 - l01 * l10;
1992: pnlInverseL00 = l11 / d;
1993: pnlInverseL10 = -l10 / d;
1994: pnlInverseL01 = -l01 / d;
1995: pnlInverseL11 = l00 / d;
1996: pnlInverseL02 = (l01 * l12 - l02 * l11) / d;
1997: pnlInverseL12 = (l02 * l10 - l00 * l12) / d;
1998: d = r00 * r11 - r01 * r10;
1999: pnlInverseR00 = r11 / d;
2000: pnlInverseR10 = -r10 / d;
2001: pnlInverseR01 = -r01 / d;
2002: pnlInverseR11 = r00 / d;
2003: pnlInverseR02 = (r01 * r12 - r02 * r11) / d;
2004: pnlInverseR12 = (r02 * r10 - r00 * r12) / d;
2005: }
2006: }
2007:
2008:
2009:
2010:
2011: public static final int PNL_UNDEFINED = 0;
2012: public static final int PNL_FIXEDSCALE = 1;
2013: public static final int PNL_FITINWINDOW = 2;
2014: public static final int PNL_FULLSCREEN = 3;
2015: public static final int PNL_MAXIMIZED = 4;
2016: public static int pnlModeRequest;
2017: public static int pnlMode;
2018: public static int pnlPrevMode;
2019:
2020:
2021: public static JRadioButtonMenuItem mnbFullScreenMenuItem;
2022: public static JRadioButtonMenuItem mnbMaximizedMenuItem;
2023: public static JRadioButtonMenuItem mnbFitInWindowMenuItem;
2024: public static JRadioButtonMenuItem mnbFixedScaleMenuItem;
2025:
2026:
2027:
2028:
2029:
2030: public static boolean PNL_ROUNDED_CORNER_ON = true;
2031: public static boolean PNL_ROUNDED_CORNER_TEST = false;
2032: public static int pnlRoundedCornerRatio;
2033: public static SpinnerNumberModel pnlRoundedCornerModel;
2034: public static JSpinner pnlRoundedCornerSpinner;
2035:
2036:
2037: public static int PNL_BOOT_DELAY = 500;
2038: public static javax.swing.Timer pnlBootTimer;
2039:
2040:
2041:
2042: public static void pnlInit2 () {
2043: pnlModeRequest = PNL_UNDEFINED;
2044: pnlMode = PNL_FITINWINDOW;
2045: pnlPrevMode = PNL_FITINWINDOW;
2046: switch (Settings.sgsGetString ("scaling").toLowerCase ()) {
2047: case "fullscreen":
2048: pnlModeRequest = PNL_FULLSCREEN;
2049: break;
2050: case "maximized":
2051: pnlModeRequest = PNL_MAXIMIZED;
2052: break;
2053: case "fitinwindow":
2054: break;
2055: case "fixedscale":
2056: pnlMode = PNL_FIXEDSCALE;
2057: break;
2058: }
2059: if (PNL_ROUNDED_CORNER_ON) {
2060: pnlRoundedCornerRatio = Settings.sgsGetInt ("roundedcornerratio", 0, 0, 50);
2061: }
2062: }
2063:
2064:
2065:
2066: public static void pnlTini2 () {
2067: Settings.sgsPutString ("scaling",
2068: pnlMode == PNL_FULLSCREEN ? "fullscreen" :
2069: pnlMode == PNL_MAXIMIZED ? "maximized" :
2070: pnlMode == PNL_FITINWINDOW ? "fitinwindow" :
2071: "fixedscale");
2072: if (PNL_ROUNDED_CORNER_ON) {
2073: Settings.sgsPutInt ("roundedcornerratio", pnlRoundedCornerRatio);
2074: }
2075: }
2076:
2077:
2078:
2079: public static void pnlMake2 () {
2080:
2081: ActionListener listener = new ActionListener () {
2082: @Override public void actionPerformed (ActionEvent ae) {
2083: String command = ae.getActionCommand ();
2084: switch (command) {
2085: case "Full screen":
2086: pnlSetMode (PNL_FULLSCREEN);
2087: break;
2088: case "Maximized":
2089: pnlSetMode (PNL_MAXIMIZED);
2090: break;
2091: case "Fit in window":
2092: pnlSetMode (PNL_FITINWINDOW);
2093: break;
2094: case "Fixed scale":
2095: pnlSetMode (PNL_FIXEDSCALE);
2096: break;
2097: }
2098: }
2099: };
2100: ButtonGroup group = new ButtonGroup ();
2101: mnbFullScreenMenuItem = ComponentFactory.setEnabled (
2102: Multilingual.mlnText (
2103: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FULLSCREEN, "Full screen", listener),
2104: "ja", "全画面表示"),
2105: pnlIsFullScreenSupported);
2106: mnbMaximizedMenuItem = Multilingual.mlnText (
2107: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_MAXIMIZED, "Maximized", listener),
2108: "ja", "最大化");
2109: mnbFitInWindowMenuItem = Multilingual.mlnText (
2110: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FITINWINDOW, "Fit in window", 'W', MNB_MODIFIERS, listener),
2111: "ja", "ウインドウに合わせる");
2112: mnbFixedScaleMenuItem = Multilingual.mlnText (
2113: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FIXEDSCALE, "Fixed scale", 'X', MNB_MODIFIERS, listener),
2114: "ja", "固定倍率");
2115: }
2116:
2117:
2118:
2119: public static void pnlStart2 () {
2120:
2121: frmFrame.addWindowStateListener (new WindowStateListener () {
2122: @Override public void windowStateChanged (WindowEvent we) {
2123: int state = frmFrame.getExtendedState ();
2124: if (pnlMode != PNL_MAXIMIZED &&
2125: (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
2126: pnlSetMode (PNL_MAXIMIZED);
2127: } else if (pnlMode == PNL_MAXIMIZED &&
2128: (state & Frame.MAXIMIZED_BOTH) != Frame.MAXIMIZED_BOTH) {
2129: pnlSetMode (pnlPrevMode);
2130: }
2131: }
2132: });
2133: }
2134:
2135:
2136:
2137: public static void pnlBoot2 () {
2138: if (pnlModeRequest != PNL_UNDEFINED) {
2139: pnlBootTimer = new javax.swing.Timer (PNL_BOOT_DELAY, new ActionListener () {
2140: public void actionPerformed (ActionEvent ae) {
2141: if (pnlModeRequest == PNL_FULLSCREEN) {
2142: mnbFullScreenMenuItem.doClick ();
2143: } else if (pnlModeRequest == PNL_MAXIMIZED) {
2144: mnbMaximizedMenuItem.doClick ();
2145: }
2146: pnlBootTimer.stop ();
2147: pnlBootTimer = null;
2148: }
2149: });
2150: pnlBootTimer.start ();
2151: }
2152: }
2153:
2154:
2155:
2156: public static void pnlSetMode (int mode) {
2157: do {
2158:
2159: if (pnlMode == mode) {
2160: break;
2161: }
2162:
2163: String text = null;
2164: if (mode == PNL_FULLSCREEN) {
2165: if (!pnlIsFullScreenSupported) {
2166: JOptionPane.showMessageDialog (
2167: frmFrame,
2168: Multilingual.mlnJapanese ?
2169: "全画面表示に対応していません" :
2170: "Full screen is not supported");
2171: break;
2172: }
2173: if (Bubble.BBL_ON) {
2174: text = ButtonFunction.bfnFullScreenText ();
2175: if (text == null) {
2176: JOptionPane.showMessageDialog (
2177: frmFrame,
2178: Multilingual.mlnJapanese ?
2179: "全画面表示を終了するキーまたはボタンがありません" :
2180: "No key or button to exit full screen");
2181: break;
2182: }
2183: }
2184: }
2185:
2186: if (pnlMode == PNL_FULLSCREEN) {
2187: pnlMode = pnlPrevMode;
2188: if (Bubble.BBL_ON) {
2189: Bubble.bblEnd ();
2190: }
2191: if (frmScreenDevice.getFullScreenWindow () == frmFrame) {
2192: frmScreenDevice.setFullScreenWindow (null);
2193: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.FRAME);
2194: }
2195: frmFrame.setJMenuBar (mnbMenuBar);
2196: if (pnlHideKeyboard) {
2197: if (pnlPrevKeyboardOn) {
2198: Keyboard.kbdSetOn (true);
2199: }
2200: }
2201: } else if (pnlMode == PNL_MAXIMIZED) {
2202: pnlMode = pnlPrevMode;
2203: if ((frmFrame.getExtendedState () & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
2204: frmFrame.setExtendedState (Frame.NORMAL);
2205: }
2206: }
2207:
2208: if (mode == PNL_FULLSCREEN) {
2209: pnlPrevMode = pnlMode;
2210: if (pnlHideKeyboard) {
2211: pnlPrevKeyboardOn = Keyboard.kbdImage != null;
2212: if (pnlPrevKeyboardOn) {
2213: Keyboard.kbdSetOn (false);
2214: }
2215: }
2216: frmFrame.setJMenuBar (null);
2217: if (frmScreenDevice.getFullScreenWindow () != frmFrame) {
2218: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.NONE);
2219: frmScreenDevice.setFullScreenWindow (frmFrame);
2220: }
2221: if (Bubble.BBL_ON) {
2222: if (text != null) {
2223: Bubble.bblStart (text + (Multilingual.mlnJapanese ? "で全画面表示を終了" : " to exit full screen"), 5000L);
2224: }
2225: }
2226: } else if (mode == PNL_MAXIMIZED) {
2227: pnlPrevMode = pnlMode;
2228: frmFrame.setExtendedState (Frame.MAXIMIZED_BOTH);
2229: }
2230: pnlMode = mode;
2231:
2232:
2233: pnlUpdateArrangement ();
2234: } while (false);
2235:
2236: if (pnlMode == PNL_FIXEDSCALE) {
2237: if (!mnbFixedScaleMenuItem.isSelected ()) {
2238: mnbFixedScaleMenuItem.setSelected (true);
2239: }
2240: } else if (pnlMode == PNL_FITINWINDOW) {
2241: if (!mnbFitInWindowMenuItem.isSelected ()) {
2242: mnbFitInWindowMenuItem.setSelected (true);
2243: }
2244: } else if (pnlMode == PNL_FULLSCREEN) {
2245: if (!mnbFullScreenMenuItem.isSelected ()) {
2246: mnbFullScreenMenuItem.setSelected (true);
2247: }
2248: } else if (pnlMode == PNL_MAXIMIZED) {
2249: if (!mnbMaximizedMenuItem.isSelected ()) {
2250: mnbMaximizedMenuItem.setSelected (true);
2251: }
2252: }
2253: }
2254:
2255:
2256:
2257:
2258:
2259:
2260: public static Robot rbtRobot;
2261:
2262:
2263: public static void rbtInit () {
2264:
2265:
2266: rbtRobot = null;
2267: try {
2268: rbtRobot = new Robot ();
2269: } catch (Exception e) {
2270: }
2271:
2272: }
2273:
2274:
2275:
2276:
2277:
2278:
2279:
2280: public static final int MNB_MODIFIERS = InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK;
2281:
2282:
2283: public static JMenuBar mnbMenuBar;
2284:
2285:
2286: public static JMenu mnbFileMenu;
2287: public static JMenu mnbDisplayMenu;
2288: public static JMenu mnbSoundMenu;
2289: public static JMenu mnbInputMenu;
2290: public static JMenu mnbConfigMenu;
2291: public static JMenu mnbLanguageMenu;
2292:
2293:
2294:
2295:
2296:
2297: public static JMenuItem mnbQuitMenuItem;
2298: public static JCheckBoxMenuItem mnbStereoscopicMenuItem;
2299: public static JCheckBoxMenuItem mnbPlayMenuItem;
2300: public static JMenuItem mnbPasteMenuItem;
2301: public static JRadioButtonMenuItem mnbStandardKeyboardMenuItem;
2302: public static JRadioButtonMenuItem mnbCompactKeyboardMenuItem;
2303: public static JRadioButtonMenuItem mnbNoKeyboardMenuItem;
2304: public static JLabel mnbVolumeLabel;
2305:
2306:
2307:
2308:
2309:
2310:
2311: public static JMenu mnbMakeFontSizeMenu () {
2312:
2313: ActionListener actionListener = new ActionListener () {
2314: @Override public void actionPerformed (ActionEvent ae) {
2315: String command = ae.getActionCommand ();
2316: switch (command) {
2317: case "Very small":
2318: LnF.lnfFontSizeRequest = 10;
2319: break;
2320: case "Small":
2321: LnF.lnfFontSizeRequest = 12;
2322: break;
2323: case "Medium":
2324: LnF.lnfFontSizeRequest = 14;
2325: break;
2326: case "Large":
2327: LnF.lnfFontSizeRequest = 16;
2328: break;
2329: case "Very large":
2330: LnF.lnfFontSizeRequest = 18;
2331: break;
2332: default:
2333: System.out.println ("unknown action command " + command);
2334: }
2335: }
2336: };
2337:
2338: ButtonGroup fontSizeGroup = new ButtonGroup ();
2339:
2340: return Multilingual.mlnText (
2341: ComponentFactory.createMenu (
2342: "Font size",
2343: Multilingual.mlnText (
2344: ComponentFactory.pointSize (
2345: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 10, "Very small", actionListener),
2346: 10),
2347: "ja", "極小"),
2348: Multilingual.mlnText (
2349: ComponentFactory.pointSize (
2350: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 12, "Small", actionListener),
2351: 12),
2352: "ja", "小"),
2353: Multilingual.mlnText (
2354: ComponentFactory.pointSize (
2355: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 14, "Medium", actionListener),
2356: 14),
2357: "ja", "中"),
2358: Multilingual.mlnText (
2359: ComponentFactory.pointSize (
2360: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 16, "Large", actionListener),
2361: 16),
2362: "ja", "大"),
2363: Multilingual.mlnText (
2364: ComponentFactory.pointSize (
2365: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 18, "Very large", actionListener),
2366: 18),
2367: "ja", "極大")),
2368: "ja", "フォントサイズ");
2369: }
2370:
2371:
2372:
2373: public static final DecimalSpinner[] mnbColorSpinners = new DecimalSpinner[9];
2374: public static final int[] mnbColorRGB = new int[15];
2375: public static JPanel mnbColorPanel;
2376:
2377:
2378:
2379: public static void mnbColorHSBToRGB () {
2380: for (int i = 0; i <= 14; i++) {
2381: int[] t = LnF.LNF_HSB_INTERPOLATION_TABLE[i];
2382: float h = (float) (t[0] * LnF.lnfHSB[0] + t[1] * LnF.lnfHSB[1] + t[2] * LnF.lnfHSB[2]) / (49.0F * 360.0F);
2383: float s = (float) (t[0] * LnF.lnfHSB[3] + t[1] * LnF.lnfHSB[4] + t[2] * LnF.lnfHSB[5]) / (49.0F * 100.0F);
2384: float b = (float) (t[0] * LnF.lnfHSB[6] + t[1] * LnF.lnfHSB[7] + t[2] * LnF.lnfHSB[8]) / (49.0F * 100.0F);
2385: mnbColorRGB[i] = Color.HSBtoRGB (h,
2386: Math.max (0.0F, Math.min (1.0F, s)),
2387: Math.max (0.0F, Math.min (1.0F, b)));
2388: }
2389: }
2390:
2391:
2392:
2393: public static JMenu mnbMakeColorMenu () {
2394: mnbColorHSBToRGB ();
2395:
2396: mnbColorPanel = ComponentFactory.setColor (
2397: ComponentFactory.setFixedSize (
2398: new JPanel () {
2399: @Override protected void paintComponent (Graphics g) {
2400: super.paintComponent (g);
2401: for (int i = 0; i <= 14; i++) {
2402: g.setColor (new Color (mnbColorRGB[i]));
2403: g.fillRect (LnF.lnfFontSize * i, 0, LnF.lnfFontSize, LnF.lnfFontSize * 5);
2404: }
2405: }
2406: },
2407: LnF.lnfFontSize * 15, LnF.lnfFontSize * 5),
2408: Color.white, Color.black);
2409:
2410: ChangeListener changeListener = new ChangeListener () {
2411: @Override public void stateChanged (ChangeEvent ce) {
2412: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
2413: LnF.lnfHSB[spinner.getOption ()] = spinner.getIntValue ();
2414: mnbColorHSBToRGB ();
2415: mnbColorPanel.repaint ();
2416: }
2417: };
2418:
2419: ActionListener actionListener = new ActionListener () {
2420: @Override public void actionPerformed (ActionEvent ae) {
2421: String command = ae.getActionCommand ();
2422: switch (command) {
2423: case "Reset to default values":
2424: for (int i = 0; i < 9; i++) {
2425: LnF.lnfHSB[i] = LnF.LNF_DEFAULT_HSB[i];
2426: mnbColorSpinners[i].setIntValue (LnF.lnfHSB[i]);
2427: }
2428: mnbColorHSBToRGB ();
2429: mnbColorPanel.repaint ();
2430: break;
2431: default:
2432: System.out.println ("unknown action command " + command);
2433: }
2434: }
2435: };
2436:
2437: for (int i = 0; i < 9; i++) {
2438: mnbColorSpinners[i] = ComponentFactory.createDecimalSpinner (
2439: LnF.lnfHSB[i], 0, i < 3 ? 720 : 100, 1, i, changeListener);
2440: }
2441:
2442: return Multilingual.mlnText (
2443: ComponentFactory.createMenu (
2444: "Color",
2445: ComponentFactory.createHorizontalBox (
2446: mnbColorSpinners[0],
2447: mnbColorSpinners[1],
2448: mnbColorSpinners[2],
2449: ComponentFactory.createLabel ("H °"),
2450: Box.createHorizontalGlue ()
2451: ),
2452: ComponentFactory.createHorizontalBox (
2453: mnbColorSpinners[3],
2454: mnbColorSpinners[4],
2455: mnbColorSpinners[5],
2456: ComponentFactory.createLabel ("S%"),
2457: Box.createHorizontalGlue ()
2458: ),
2459: ComponentFactory.createHorizontalBox (
2460: mnbColorSpinners[6],
2461: mnbColorSpinners[7],
2462: mnbColorSpinners[8],
2463: ComponentFactory.createLabel ("B%"),
2464: Box.createHorizontalGlue ()
2465: ),
2466: ComponentFactory.createHorizontalBox (
2467: ComponentFactory.setLineBorder (mnbColorPanel),
2468: Box.createHorizontalGlue ()
2469: ),
2470: Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset to default values", actionListener), "ja", "初期値に戻す")
2471: ),
2472: "ja", "色");
2473: }
2474:
2475:
2476:
2477:
2478:
2479: public static JMenu mnbMakeLanguageMenu () {
2480:
2481: ActionListener actionListener = new ActionListener () {
2482: @Override public void actionPerformed (ActionEvent ae) {
2483: String command = ae.getActionCommand ();
2484: switch (command) {
2485: case "English":
2486: Multilingual.mlnChange ("en");
2487: break;
2488: case "日本語":
2489: Multilingual.mlnChange ("ja");
2490: break;
2491: default:
2492: System.out.println ("unknown action command " + command);
2493: }
2494: }
2495: };
2496:
2497: ButtonGroup languageGroup = new ButtonGroup ();
2498:
2499: return mnbLanguageMenu = Multilingual.mlnText (
2500: ComponentFactory.createMenu (
2501: "Language", 'L',
2502: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnEnglish, "English", actionListener),
2503: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnJapanese, "日本語", actionListener),
2504: ComponentFactory.createHorizontalSeparator (),
2505: mnbMakeFontSizeMenu (),
2506: mnbMakeColorMenu ()
2507: ),
2508: "ja", "言語");
2509: }
2510:
2511:
2512:
2513:
2514:
2515: public static void mnbMakeMenu () {
2516:
2517:
2518: ActionListener listener = new ActionListener () {
2519: @Override public void actionPerformed (ActionEvent ae) {
2520: Object source = ae.getSource ();
2521: String command = ae.getActionCommand ();
2522: switch (command) {
2523:
2524:
2525: case "Quit":
2526: prgTini ();
2527: break;
2528:
2529:
2530: case "50%":
2531: case "75%":
2532: case "100%":
2533: case "150%":
2534: case "200%":
2535: pnlFixedModel.setValue (Integer.valueOf (Integer.parseInt (command.substring (0, command.length () - 1))));
2536: break;
2537: case "Nearest neighbor":
2538: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
2539: break;
2540: case "Bilinear":
2541: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
2542: break;
2543: case "Bicubic":
2544: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
2545: break;
2546:
2547: case "Use canvas":
2548: pnlUseCanvasRequest = ((JCheckBoxMenuItem) source).isSelected ();
2549: break;
2550:
2551: case "Draw all changed pictures":
2552: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2553: CRTC.crtIntermittentInterval = 0;
2554: }
2555: break;
2556: case "Draw a changed picture once every two times":
2557: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2558: CRTC.crtIntermittentInterval = 1;
2559: }
2560: break;
2561: case "Draw a changed picture once every three times":
2562: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2563: CRTC.crtIntermittentInterval = 2;
2564: }
2565: break;
2566: case "Draw a changed picture once every four times":
2567: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2568: CRTC.crtIntermittentInterval = 3;
2569: }
2570: break;
2571: case "Draw a changed picture once every five times":
2572: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2573: CRTC.crtIntermittentInterval = 4;
2574: }
2575: break;
2576:
2577: case "Stereoscopic viewing":
2578: pnlSetStereoscopic (((JCheckBoxMenuItem) source).isSelected (), pnlStereoscopicMethod);
2579: break;
2580: case "Naked-eye crossing":
2581: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_CROSSING);
2582: break;
2583: case "Naked-eye parallel":
2584: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_PARALLEL);
2585: break;
2586: case "Side-by-side":
2587: pnlSetStereoscopic (pnlStereoscopicOn, PNL_SIDE_BY_SIDE);
2588: break;
2589: case "Top-and-bottom":
2590: pnlSetStereoscopic (pnlStereoscopicOn, PNL_TOP_AND_BOTTOM);
2591: break;
2592:
2593: case "Sprite pattern viewer":
2594: if (SpritePatternViewer.SPV_ON) {
2595: SpritePatternViewer.spvOpen ();
2596: }
2597: break;
2598: case "Palette viewer":
2599: if (PaletteViewer.PLV_ON) {
2600: PaletteViewer.plvOpen ();
2601: }
2602: break;
2603: case "Screen mode test":
2604: if (ScreenModeTest.SMT_ON) {
2605: ScreenModeTest.smtOpen ();
2606: }
2607: break;
2608:
2609:
2610: case "Play":
2611: SoundSource.sndSetPlayOn (((JCheckBoxMenuItem) source).isSelected ());
2612: break;
2613: case "OPM output":
2614: OPM.opmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2615: break;
2616: case "OPM log":
2617: OPMLog.olgOpen ();
2618: break;
2619:
2620: case "PCM output":
2621: ADPCM.pcmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2622: break;
2623: case "Sound thinning":
2624: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.THINNING_MONO : SoundSource.SNDRateConverter.THINNING_STEREO;
2625: break;
2626: case "Sound linear interpolation":
2627: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.LINEAR_MONO : SoundSource.SNDRateConverter.LINEAR_STEREO;
2628: break;
2629: case "Sound piecewise-constant area interpolation":
2630: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000;
2631: break;
2632: case "Sound linear area interpolation":
2633: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000;
2634: break;
2635: case "Sound monitor":
2636: SoundMonitor.smnOpen ();
2637: break;
2638: case "PCM piecewise-constant interpolation":
2639: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_CONSTANT);
2640: break;
2641: case "PCM linear interpolation":
2642: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_LINEAR);
2643: break;
2644: case "PCM hermite interpolation":
2645: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_HERMITE);
2646: break;
2647: case "PCM 8MHz/4MHz":
2648: ADPCM.pcmOSCFreqRequest = 0;
2649: break;
2650: case "PCM 8MHz/16MHz":
2651: ADPCM.pcmOSCFreqRequest = 1;
2652: break;
2653: case "Mercury-Unit V4 (MK-MU1)":
2654: MercuryUnit.mu4OnRequest = ((JCheckBoxMenuItem) source).isSelected ();
2655: break;
2656: case "MU4 output":
2657: MercuryUnit.mu4OutputEnable = ((JCheckBoxMenuItem) source).isSelected ();
2658: break;
2659:
2660:
2661: case "Paste":
2662: CONDevice.conDoPaste ();
2663: break;
2664: case "No keyboard":
2665: Keyboard.kbdSetOn (false);
2666: pnlUpdateArrangement ();
2667: break;
2668: case "Standard keyboard":
2669: Keyboard.kbdSetType (Keyboard.KBD_STANDARD_TYPE);
2670: Keyboard.kbdSetOn (true);
2671: pnlUpdateArrangement ();
2672: break;
2673: case "Compact keyboard":
2674: Keyboard.kbdSetType (Keyboard.KBD_COMPACT_TYPE);
2675: Keyboard.kbdSetOn (true);
2676: pnlUpdateArrangement ();
2677: break;
2678: case "Hide keyboard in full screen":
2679: pnlHideKeyboard = ((JCheckBoxMenuItem) source).isSelected ();
2680: if (pnlMode == PNL_FULLSCREEN) {
2681: pnlUpdateArrangement ();
2682: }
2683: break;
2684: case "Key assignments":
2685: Keyboard.kbdOpen ();
2686: break;
2687: case "Joystick port settings":
2688: PPI.ppiOpen ();
2689: break;
2690:
2691:
2692: case "RS-232C and terminal":
2693: RS232CTerminal.trmOpen ();
2694: break;
2695:
2696: case "Console":
2697: DebugConsole.dgtOpen ();
2698: break;
2699: case "Register list":
2700: RegisterList.drpOpen ();
2701: break;
2702: case "Disassemble list":
2703: DisassembleList.ddpOpen (-1, -1, true);
2704: break;
2705: case "Memory dump list":
2706: MemoryDumpList.dmpOpen (-1, -1, true);
2707: break;
2708: case "Logical space monitor":
2709: LogicalSpaceMonitor.atwOpen ();
2710: break;
2711: case "Physical space monitor":
2712: PhysicalSpaceMonitor.paaOpen ();
2713: break;
2714: case "Address translation caches monitor":
2715: if (ATCMonitor.ACM_ON) {
2716: ATCMonitor.acmOpen ();
2717: }
2718: break;
2719: case "Branch log":
2720: if (BranchLog.BLG_ON) {
2721: BranchLog.blgOpen (BranchLog.BLG_SELECT_NONE);
2722: }
2723: break;
2724: case "Program flow visualizer":
2725: if (ProgramFlowVisualizer.PFV_ON) {
2726: ProgramFlowVisualizer.pfvOpen ();
2727: }
2728: break;
2729: case "Raster break point":
2730: if (RasterBreakPoint.RBP_ON) {
2731: RasterBreakPoint.rbpOpen ();
2732: }
2733: break;
2734: case "Data break point":
2735: if (DataBreakPoint.DBP_ON) {
2736: DataBreakPoint.dbpOpen ();
2737: }
2738: break;
2739: case "Root pointer list":
2740: if (RootPointerList.RTL_ON) {
2741: RootPointerList.rtlOpen ();
2742: }
2743: break;
2744:
2745:
2746: case "Adjust clock to host":
2747: RP5C15.rtcSetByHost ();
2748: break;
2749:
2750:
2751:
2752: case "Printer":
2753: PrinterPort.prnOpen ();
2754: break;
2755:
2756: case "Print key and mouse button events":
2757: Mouse.musOutputButtonStatus = ((JCheckBoxMenuItem) source).isSelected ();
2758: break;
2759:
2760: case "Java runtime environment information":
2761: prgOpenJavaDialog ();
2762: break;
2763: case "Version information":
2764: prgOpenAboutDialog ();
2765: break;
2766: case "XEiJ License":
2767: prgOpenXEiJLicenseDialog ();
2768: break;
2769: case "FSHARP License":
2770: prgOpenSHARPLicenseDialog ();
2771: break;
2772: case "ymfm License":
2773: prgOpenYmfmLicenseDialog ();
2774: break;
2775: case "jSerialComm License":
2776: prgOpenJSerialCommLicenseDialog ();
2777: break;
2778:
2779: default:
2780: System.out.println ("unknown action command " + command);
2781:
2782: }
2783: }
2784: };
2785:
2786:
2787: ActionListener mainMemoryListener = new ActionListener () {
2788: @Override public void actionPerformed (ActionEvent ae) {
2789: Object source = ae.getSource ();
2790: String command = ae.getActionCommand ();
2791: switch (command) {
2792: case "1MB":
2793: MainMemory.mmrMemorySizeRequest = 0x00100000;
2794: break;
2795: case "2MB":
2796: MainMemory.mmrMemorySizeRequest = 0x00200000;
2797: break;
2798: case "4MB":
2799: MainMemory.mmrMemorySizeRequest = 0x00400000;
2800: break;
2801: case "6MB":
2802: MainMemory.mmrMemorySizeRequest = 0x00600000;
2803: break;
2804: case "8MB":
2805: MainMemory.mmrMemorySizeRequest = 0x00800000;
2806: break;
2807: case "10MB":
2808: MainMemory.mmrMemorySizeRequest = 0x00a00000;
2809: break;
2810: case "12MB":
2811: MainMemory.mmrMemorySizeRequest = 0x00c00000;
2812: break;
2813: case "Save contents on exit":
2814: MainMemory.mmrMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2815: break;
2816: }
2817: }
2818: };
2819: ButtonGroup mainMemoryGroup = new ButtonGroup ();
2820: JMenu mainMemoryMenu = Multilingual.mlnText (
2821: ComponentFactory.createMenu (
2822: "Main memory",
2823: Multilingual.mlnText (
2824: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00100000, "1MB", mainMemoryListener),
2825: "ja", "1MB"),
2826: Multilingual.mlnText (
2827: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00200000, "2MB", mainMemoryListener),
2828: "ja", "2MB"),
2829: Multilingual.mlnText (
2830: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00400000, "4MB", mainMemoryListener),
2831: "ja", "4MB"),
2832: Multilingual.mlnText (
2833: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00600000, "6MB", mainMemoryListener),
2834: "ja", "6MB"),
2835: Multilingual.mlnText (
2836: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00800000, "8MB", mainMemoryListener),
2837: "ja", "8MB"),
2838: Multilingual.mlnText (
2839: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00a00000, "10MB", mainMemoryListener),
2840: "ja", "10MB"),
2841: Multilingual.mlnText (
2842: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00c00000, "12MB", mainMemoryListener),
2843: "ja", "12MB"),
2844: ComponentFactory.createHorizontalSeparator (),
2845: Multilingual.mlnText (
2846: ComponentFactory.createCheckBoxMenuItem (MainMemory.mmrMemorySaveOn, "Save contents on exit", mainMemoryListener),
2847: "ja", "終了時に内容を保存する"),
2848: SRAM.smrModifyMemorySizeMenuItem
2849: ),
2850: "ja", "メインメモリ");
2851:
2852:
2853: ActionListener highMemoryListener = new ActionListener () {
2854: @Override public void actionPerformed (ActionEvent ae) {
2855: Object source = ae.getSource ();
2856: String command = ae.getActionCommand ();
2857: switch (command) {
2858: case "None":
2859: busHighMemorySize = 0 << 20;
2860: break;
2861: case "16MB":
2862: busHighMemorySize = 16 << 20;
2863: break;
2864: case "Save contents on exit":
2865: busHighMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2866: break;
2867: }
2868: }
2869: };
2870: ButtonGroup highMemoryGroup = new ButtonGroup ();
2871: JMenu highMemoryMenu = Multilingual.mlnText (
2872: ComponentFactory.createMenu (
2873: "High memory on X68030/Xellent30",
2874: Multilingual.mlnText (
2875: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 0 << 20, "None", highMemoryListener),
2876: "ja", "なし"),
2877: Multilingual.mlnText (
2878: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 16 << 20, "16MB", highMemoryListener),
2879: "ja", "16MB"),
2880: ComponentFactory.createHorizontalSeparator (),
2881: Multilingual.mlnText (
2882: ComponentFactory.createCheckBoxMenuItem (busHighMemorySaveOn, "Save contents on exit", highMemoryListener),
2883: "ja", "終了時に内容を保存する")
2884: ),
2885: "ja", "X68030/Xellent30 のハイメモリ");
2886:
2887:
2888: ActionListener localMemoryListener = new ActionListener () {
2889: @Override public void actionPerformed (ActionEvent ae) {
2890: Object source = ae.getSource ();
2891: String command = ae.getActionCommand ();
2892: switch (command) {
2893: case "None":
2894: busLocalMemorySize = 0 << 20;
2895: break;
2896: case "16MB":
2897: busLocalMemorySize = 16 << 20;
2898: break;
2899: case "32MB":
2900: busLocalMemorySize = 32 << 20;
2901: break;
2902: case "64MB":
2903: busLocalMemorySize = 64 << 20;
2904: break;
2905: case "128MB":
2906: busLocalMemorySize = 128 << 20;
2907: break;
2908: case "256MB":
2909: busLocalMemorySize = 256 << 20;
2910: break;
2911: case "384MB":
2912: busLocalMemorySize = 384 << 20;
2913: break;
2914: case "512MB":
2915: busLocalMemorySize = 512 << 20;
2916: break;
2917: case "768MB":
2918: busLocalMemorySize = 768 << 20;
2919: break;
2920: case "Save contents on exit":
2921: busLocalMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2922: break;
2923: case "Available on X68000":
2924: busHimem68000 = ((JCheckBoxMenuItem) source).isSelected ();
2925: break;
2926: case "Available on X68030/Xellent30":
2927: busHighMemory060turboOn = ((JCheckBoxMenuItem) source).isSelected ();
2928: break;
2929: }
2930: }
2931: };
2932: ButtonGroup localMenoryGroup = new ButtonGroup ();
2933: JMenu localMemoryMenu = Multilingual.mlnText (
2934: ComponentFactory.createMenu (
2935: "High memory on 060turbo",
2936: Multilingual.mlnText (
2937: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 0 << 20, "None", localMemoryListener),
2938: "ja", "なし"),
2939: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 16 << 20, "16MB", localMemoryListener),
2940: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 32 << 20, "32MB", localMemoryListener),
2941: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 64 << 20, "64MB", localMemoryListener),
2942: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 128 << 20, "128MB", localMemoryListener),
2943: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 256 << 20, "256MB", localMemoryListener),
2944: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 384 << 20, "384MB", localMemoryListener),
2945: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 512 << 20, "512MB", localMemoryListener),
2946: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 768 << 20, "768MB", localMemoryListener),
2947: ComponentFactory.createHorizontalSeparator (),
2948: Multilingual.mlnText (
2949: ComponentFactory.createCheckBoxMenuItem (busLocalMemorySaveOn, "Save contents on exit", localMemoryListener),
2950: "ja", "終了時に内容を保存する"),
2951: ComponentFactory.createHorizontalSeparator (),
2952: Multilingual.mlnText (
2953: ComponentFactory.createCheckBoxMenuItem (busHimem68000, "Available on X68000", localMemoryListener),
2954: "ja", "X68000 でも有効"),
2955: Multilingual.mlnText (
2956: ComponentFactory.createCheckBoxMenuItem (busHighMemory060turboOn, "Available on X68030/Xellent30", localMemoryListener),
2957: "ja", "X68030/Xellent30 でも有効")
2958: ),
2959: "ja", "060turbo のハイメモリ");
2960:
2961:
2962: ActionListener xellent30Listener = new ActionListener () {
2963: @Override public void actionPerformed (ActionEvent ae) {
2964: Object source = ae.getSource ();
2965: String command = ae.getActionCommand ();
2966: switch (command) {
2967: case "$00EC0000-$00EC3FFF":
2968: xt3DIPSW = 0;
2969: break;
2970: case "$00EC4000-$00EC7FFF":
2971: xt3DIPSW = 1;
2972: break;
2973: case "$00EC8000-$00ECBFFF":
2974: xt3DIPSW = 2;
2975: break;
2976: case "$00ECC000-$00ECFFFF":
2977: xt3DIPSW = 3;
2978: break;
2979: case "256KB":
2980: xt3MemorySizeRequest = 1 << 18;
2981: break;
2982: case "1MB":
2983: xt3MemorySizeRequest = 1 << 20;
2984: break;
2985: case "Save contents on exit":
2986: xt3MemorySave = ((JCheckBoxMenuItem) source).isSelected ();
2987: break;
2988: }
2989: }
2990: };
2991: ButtonGroup xellent30PortGroup = new ButtonGroup ();
2992: ButtonGroup xellent30SizeGroup = new ButtonGroup ();
2993: JMenu xellent30Menu = ComponentFactory.createMenu (
2994: "Xellent30",
2995: ComponentFactory.createRadioButtonMenuItem (
2996: xellent30PortGroup,
2997: xt3DIPSW == 0,
2998: "$00EC0000-$00EC3FFF",
2999: xellent30Listener),
3000: ComponentFactory.createRadioButtonMenuItem (
3001: xellent30PortGroup,
3002: xt3DIPSW == 1,
3003: "$00EC4000-$00EC7FFF",
3004: xellent30Listener),
3005: ComponentFactory.createRadioButtonMenuItem (
3006: xellent30PortGroup,
3007: xt3DIPSW == 2,
3008: "$00EC8000-$00ECBFFF",
3009: xellent30Listener),
3010: ComponentFactory.createRadioButtonMenuItem (
3011: xellent30PortGroup,
3012: xt3DIPSW == 3,
3013: "$00ECC000-$00ECFFFF",
3014: xellent30Listener),
3015: ComponentFactory.createHorizontalSeparator (),
3016: ComponentFactory.createRadioButtonMenuItem (
3017: xellent30SizeGroup,
3018: xt3MemorySizeRequest == 1 << 18,
3019: "256KB",
3020: xellent30Listener),
3021: ComponentFactory.createRadioButtonMenuItem (
3022: xellent30SizeGroup,
3023: xt3MemorySizeRequest == 1 << 20,
3024: "1MB",
3025: xellent30Listener),
3026: ComponentFactory.createHorizontalSeparator (),
3027: Multilingual.mlnText (
3028: ComponentFactory.createCheckBoxMenuItem (xt3MemorySave, "Save contents on exit", xellent30Listener),
3029: "ja", "終了時に内容を保存する")
3030: );
3031:
3032:
3033: JMenu rotationMenu = null;
3034: if (PNL_ROTATION_ON) {
3035: ActionListener rotationListener = new ActionListener () {
3036: @Override public void actionPerformed (ActionEvent ae) {
3037: String command = ae.getActionCommand ();
3038: switch (command) {
3039: case "No rotation (landscape)":
3040: pnlRotationMode = 0;
3041: pnlUpdateArrangement ();
3042: break;
3043: case "90-degree rotation (portrait)":
3044: pnlRotationMode = 1;
3045: pnlUpdateArrangement ();
3046: break;
3047: case "180-degree rotation":
3048: pnlRotationMode = 2;
3049: pnlUpdateArrangement ();
3050: break;
3051: case "270-degree rotation":
3052: pnlRotationMode = 3;
3053: pnlUpdateArrangement ();
3054: break;
3055: default:
3056: System.out.println ("unknown action command " + command);
3057: }
3058: }
3059: };
3060: ButtonGroup rotationGroup = new ButtonGroup ();
3061: rotationMenu = Multilingual.mlnText (
3062: ComponentFactory.createMenu (
3063: "Rotation",
3064: Multilingual.mlnText (
3065: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 0, "No rotation (landscape)", rotationListener),
3066: "ja", "回転なし (横画面)"),
3067: Multilingual.mlnText (
3068: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 1, "90-degree rotation (portrait)", rotationListener),
3069: "ja", "90 度回転 (縦画面)"),
3070: Multilingual.mlnText (
3071: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 2, "180-degree rotation", rotationListener),
3072: "ja", "180 度回転"),
3073: Multilingual.mlnText (
3074: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 3, "270-degree rotation", rotationListener),
3075: "ja", "270 度回転")
3076: ),
3077: "ja", "回転");
3078: }
3079:
3080:
3081: ActionListener aspectListener = new ActionListener () {
3082: @Override public void actionPerformed (ActionEvent ae) {
3083: String command = ae.getActionCommand ();
3084: int i = command.indexOf (',');
3085: int key = Integer.parseInt (command.substring (0, i));
3086: int value = Integer.parseInt (command.substring (i + 1));
3087: pnlAspectMap[key] = value;
3088: pnlUpdateAspectTable ();
3089: pnlUpdateArrangement ();
3090: }
3091: };
3092: JMenu aspectMenu = ComponentFactory.createMenu ("Aspect ratio");
3093: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
3094: if (key != 0) {
3095: aspectMenu.add (ComponentFactory.createHorizontalSeparator ());
3096: }
3097: ButtonGroup group = new ButtonGroup ();
3098: for (int value = 0; value < PNL_ASPECT_VALUES; value++) {
3099: if (PNL_ASPECT_MATRIX[key][value] == 0.0F) {
3100: continue;
3101: }
3102: aspectMenu.add (
3103: ComponentFactory.setText (
3104: ComponentFactory.createRadioButtonMenuItem (
3105: group,
3106: pnlAspectMap[key] == value,
3107: key + "," + value,
3108: aspectListener
3109: ),
3110: (PNL_ASPECT_MATRIX[key] == PNL_ASPECT_SCREEN_RATIO ?
3111: String.format ("%s %s (%.3f)",
3112: PNL_ASPECT_RESOLUTION_NAME[key],
3113: PNL_ASPECT_SCREEN_NAME[value],
3114: PNL_ASPECT_SCREEN_RATIO[value]) :
3115: String.format ("%s %s (%.3f) @ %s (%.3f)",
3116: PNL_ASPECT_RESOLUTION_NAME[key],
3117: PNL_ASPECT_SCREEN_NAME[value],
3118: PNL_ASPECT_SCREEN_RATIO[value],
3119: PNL_ASPECT_PIXEL_NAME[value],
3120: PNL_ASPECT_PIXEL_RATIO[value]))
3121: )
3122: );
3123: }
3124: }
3125: aspectMenu = Multilingual.mlnText (aspectMenu, "ja", "アスペクト比");
3126:
3127:
3128: ActionListener scanlineListener = new ActionListener () {
3129: @Override public void actionPerformed (ActionEvent ae) {
3130:
3131: String command = ae.getActionCommand ();
3132: switch (command) {
3133: case "Off":
3134: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.OFF;
3135: CRTC.crtAllStamp += 2;
3136: break;
3137: case "Weak":
3138: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.WEAK;
3139: CRTC.crtAllStamp += 2;
3140: break;
3141: case "Medium":
3142: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.MEDIUM;
3143: CRTC.crtAllStamp += 2;
3144: break;
3145: case "Strong":
3146: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.STRONG;
3147: CRTC.crtAllStamp += 2;
3148: break;
3149: case "Black":
3150: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.BLACK;
3151: CRTC.crtAllStamp += 2;
3152: break;
3153: }
3154: }
3155: };
3156: ButtonGroup scanlineGroup = new ButtonGroup ();
3157: JMenu scanlineMenu =
3158: Multilingual.mlnText (
3159: ComponentFactory.createMenu (
3160: "Scanline effect",
3161: Multilingual.mlnText (
3162: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.OFF, "Off", scanlineListener),
3163: "ja", "なし"),
3164: Multilingual.mlnText (
3165: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.WEAK, "Weak", scanlineListener),
3166: "ja", "弱"),
3167: Multilingual.mlnText (
3168: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.MEDIUM, "Medium", scanlineListener),
3169: "ja", "中"),
3170: Multilingual.mlnText (
3171: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.STRONG, "Strong", scanlineListener),
3172: "ja", "強"),
3173: Multilingual.mlnText (
3174: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.BLACK, "Black", scanlineListener),
3175: "ja", "黒")
3176: ),
3177: "ja", "走査線エフェクト");
3178:
3179:
3180: JTextField refreshRateTextField = ComponentFactory.createNumberField (pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate), 8);
3181: refreshRateTextField.addActionListener (
3182: new ActionListener () {
3183: @Override public void actionPerformed (ActionEvent ae) {
3184: JTextField textField = (JTextField) ae.getSource ();
3185: pnlRefreshRate = 0.0;
3186: String s = textField.getText ();
3187: if (!s.equals ("")) {
3188: double rate = 0.0;
3189: try {
3190: rate = Double.parseDouble (s);
3191: } catch (NumberFormatException nfe) {
3192: }
3193: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
3194: pnlRefreshRate = rate;
3195: } else {
3196: textField.setText ("");
3197: }
3198: }
3199: pnlFixedRate = pnlRefreshRate;
3200: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3201: pnlFixedRate = pnlGetRefreshRate ();
3202: }
3203: CRTC.crtUpdateLength ();
3204: }
3205: });
3206:
3207: ButtonGroup unitGroup = new ButtonGroup ();
3208: ButtonGroup frameGroup = new ButtonGroup ();
3209: ButtonGroup hintGroup = new ButtonGroup ();
3210: ButtonGroup vgaGroup = new ButtonGroup ();
3211: ButtonGroup intermittentGroup = new ButtonGroup ();
3212: ButtonGroup sterescopicGroup = new ButtonGroup ();
3213: ButtonGroup soundInterpolationGroup = new ButtonGroup ();
3214: ButtonGroup adpcmInterpolationGroup = new ButtonGroup ();
3215: ButtonGroup adpcmOSCFreqGroup = new ButtonGroup ();
3216: ButtonGroup keyboardGroup = new ButtonGroup ();
3217: ButtonGroup spritesGroup = new ButtonGroup ();
3218:
3219:
3220: DecimalSpinner[] freqSpinner = new DecimalSpinner[3];
3221: ChangeListener freqListener = new ChangeListener () {
3222: @Override public void stateChanged (ChangeEvent ce) {
3223: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
3224: int i = spinner.getOption ();
3225: CRTC.crtFreqsRequest[i] = spinner.getIntValue ();
3226: }
3227: };
3228: for (int i = 0; i < 3; i++) {
3229: freqSpinner[i] = ComponentFactory.createDecimalSpinner (
3230: CRTC.crtFreqsRequest[i], CRTC.CRT_MIN_FREQ, CRTC.CRT_MAX_FREQ, 1000000, i, freqListener
3231: );
3232: }
3233: DecimalSpinner sprrasSpinner = ComponentFactory.createDecimalSpinner (
3234: SpriteScreen.sprSpritesPerRaster, 0, 1016, 1, 0,
3235: new ChangeListener () {
3236: @Override public void stateChanged (ChangeEvent ce) {
3237: SpriteScreen.sprSpritesPerRaster = ((DecimalSpinner) ce.getSource ()).getIntValue ();
3238: }
3239: });
3240: ActionListener modificationListener = new ActionListener () {
3241: @Override public void actionPerformed (ActionEvent ae) {
3242: Object source = ae.getSource ();
3243: String command = ae.getActionCommand ();
3244: switch (command) {
3245:
3246: case "Adjust to host refresh rate":
3247: pnlAdjustVsync = ((JCheckBoxMenuItem) source).isSelected ();
3248: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3249: pnlFixedRate = pnlGetRefreshRate ();
3250: }
3251: CRTC.crtUpdateLength ();
3252: break;
3253: case "* Reset to default values":
3254: for (int i = 0; i < 3; i++) {
3255: if (CRTC.crtFreqsRequest[i] != CRTC.CRT_DEFAULT_FREQS[i]) {
3256: CRTC.crtFreqsRequest[i] = CRTC.CRT_DEFAULT_FREQS[i];
3257: freqSpinner[i].setIntValue (CRTC.crtFreqsRequest[i]);
3258: }
3259: }
3260: break;
3261: case "1024-dot non-interlaced":
3262: CRTC.crtEleventhBitRequest = ((JCheckBoxMenuItem) source).isSelected ();
3263: break;
3264: case "Can write 0 to bit 0 of CRTC R00":
3265: CRTC.crtR00Bit0Zero = ((JCheckBoxMenuItem) source).isSelected ();
3266: break;
3267:
3268: case "Extended graphic screen":
3269: CRTC.crtExtendedGraphicRequest = ((JCheckBoxMenuItem) source).isSelected ();
3270: break;
3271:
3272: case "Spherical scrolling of text screen":
3273: CRTC.crtSetSphericalScrolling (((JCheckBoxMenuItem) source).isSelected ());
3274: break;
3275:
3276: case "128 sprites":
3277: SpriteScreen.sprNumberOfSpritesRequest = 128;
3278: break;
3279: case "256 sprites":
3280: SpriteScreen.sprNumberOfSpritesRequest = 256;
3281: break;
3282: case "504 sprites":
3283: SpriteScreen.sprNumberOfSpritesRequest = 512;
3284: break;
3285: case "1016 sprites":
3286: SpriteScreen.sprNumberOfSpritesRequest = 1024;
3287: break;
3288:
3289:
3290:
3291: case "Full pattern memory":
3292: SpriteScreen.sprFPMRequest = ((JCheckBoxMenuItem) source).isSelected ();
3293: break;
3294: case "4096 patterns":
3295: SpriteScreen.sprBankOnRequest = ((JCheckBoxMenuItem) source).isSelected ();
3296: break;
3297: case "Sprites displayed in 768x512":
3298: SpriteScreen.spr768x512Request = ((JCheckBoxMenuItem) source).isSelected ();
3299: break;
3300: case "BG1 displayed in 512x512":
3301: SpriteScreen.spr512bg1Request = ((JCheckBoxMenuItem) source).isSelected ();
3302: break;
3303: case "Row and column scroll":
3304: if (SpriteScreen.SPR_RC_SCROLL_ON) {
3305: SpriteScreen.sprRcScrollRequest = ((JCheckBoxMenuItem) source).isSelected ();
3306: }
3307: break;
3308: case "** Reset to default values":
3309: if (SpriteScreen.sprSpritesPerRaster != 32) {
3310: SpriteScreen.sprSpritesPerRaster = 32;
3311: sprrasSpinner.setIntValue (SpriteScreen.sprSpritesPerRaster);
3312: }
3313: break;
3314: }
3315: }
3316: };
3317: JMenu modificationMenu =
3318: Multilingual.mlnText (
3319: ComponentFactory.createMenu (
3320: "Modification",
3321: Multilingual.mlnText (
3322: ComponentFactory.createMenu (
3323: "Dot clock",
3324: Multilingual.mlnText (
3325: ComponentFactory.createCheckBoxMenuItem (pnlAdjustVsync, "Adjust to host refresh rate", modificationListener),
3326: "ja", "ホストのリフレッシュレートに合わせる"),
3327: ComponentFactory.createHorizontalBox (
3328: Box.createHorizontalStrut (20),
3329: refreshRateTextField,
3330: ComponentFactory.createLabel (" Hz"),
3331: Box.createHorizontalGlue ()
3332: ),
3333: ComponentFactory.createHorizontalSeparator (),
3334: ComponentFactory.createHorizontalBox (
3335: Box.createHorizontalStrut (20),
3336: Multilingual.mlnText (ComponentFactory.createLabel ("Dot clock oscillattor"), "ja", "ドットクロックオシレータ"),
3337: Box.createHorizontalGlue ()
3338: ),
3339: ComponentFactory.createHorizontalBox (
3340: Box.createHorizontalStrut (20),
3341: freqSpinner[0],
3342: ComponentFactory.createLabel (" Hz *"),
3343: Box.createHorizontalGlue ()
3344: ),
3345: ComponentFactory.createHorizontalBox (
3346: Box.createHorizontalStrut (20),
3347: freqSpinner[1],
3348: ComponentFactory.createLabel (" Hz *"),
3349: Box.createHorizontalGlue ()
3350: ),
3351: ComponentFactory.createHorizontalBox (
3352: Box.createHorizontalStrut (20),
3353: freqSpinner[2],
3354: ComponentFactory.createLabel (" Hz *"),
3355: Box.createHorizontalGlue ()
3356: ),
3357: Multilingual.mlnText (
3358: ComponentFactory.createMenuItem ("* Reset to default values", modificationListener),
3359: "ja", "* 初期値に戻す"),
3360: ComponentFactory.createHorizontalSeparator (),
3361: Multilingual.mlnText (
3362: ComponentFactory.createCheckBoxMenuItem (CRTC.crtEleventhBitRequest, "1024-dot non-interlaced", modificationListener),
3363: "ja", "1024 ドットノンインターレース"),
3364: Multilingual.mlnText (
3365: ComponentFactory.createCheckBoxMenuItem (CRTC.crtR00Bit0Zero, "Can write 0 to bit 0 of CRTC R00", modificationListener),
3366: "ja", "CRTC R00 のビット 0 に 0 を書き込める")
3367: ),
3368: "ja", "ドットクロック"),
3369: Multilingual.mlnText (
3370: ComponentFactory.createMenu (
3371: "Graphic screen",
3372: !CRTC.CRT_EXTENDED_GRAPHIC ? null : Multilingual.mlnText (
3373: ComponentFactory.createCheckBoxMenuItem (CRTC.crtExtendedGraphicRequest, "Extended graphic screen", modificationListener),
3374: "ja", "拡張グラフィック画面")
3375: ),
3376: "ja", "グラフィック画面"),
3377: Multilingual.mlnText (
3378: ComponentFactory.createMenu (
3379: "Text screen",
3380: Multilingual.mlnText (
3381: ComponentFactory.createCheckBoxMenuItem (CRTC.crtSphericalScrolling, "Spherical scrolling of text screen", modificationListener),
3382: "ja", "テキスト画面の球面スクロール")
3383: ),
3384: "ja", "テキスト画面"),
3385: Multilingual.mlnText (
3386: ComponentFactory.createMenu (
3387: "Sprite screen",
3388: Multilingual.mlnText (
3389: ComponentFactory.createRadioButtonMenuItem (
3390: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 128, "128 sprites", modificationListener),
3391: "ja", "128 枚のスプライト"),
3392: Multilingual.mlnText (
3393: ComponentFactory.createRadioButtonMenuItem (
3394: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 256, "256 sprites", modificationListener),
3395: "ja", "256 枚のスプライト"),
3396: Multilingual.mlnText (
3397: ComponentFactory.createRadioButtonMenuItem (
3398: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 512, "504 sprites", modificationListener),
3399: "ja", "504 枚のスプライト"),
3400: Multilingual.mlnText (
3401: ComponentFactory.createRadioButtonMenuItem (
3402: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 1024, "1016 sprites", modificationListener),
3403: "ja", "1016 枚のスプライト"),
3404:
3405:
3406:
3407:
3408: ComponentFactory.createHorizontalSeparator (),
3409: Multilingual.mlnText (
3410: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprFPMRequest, "Full pattern memory", modificationListener),
3411: "ja", "フルパターンメモリ"),
3412: ComponentFactory.createHorizontalSeparator (),
3413: Multilingual.mlnText (
3414: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprBankOnRequest, "4096 patterns", modificationListener),
3415: "ja", "4096 個のパターン"),
3416: Multilingual.mlnText (
3417: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr768x512Request, "Sprites displayed in 768x512", modificationListener),
3418: "ja", "768x512 でスプライトを表示"),
3419: Multilingual.mlnText (
3420: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr512bg1Request, "BG1 displayed in 512x512", modificationListener),
3421: "ja", "512x512 で BG1 を表示"),
3422: !SpriteScreen.SPR_RC_SCROLL_ON ? null : Multilingual.mlnText (
3423: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprRcScrollRequest, "Row and column scroll", modificationListener),
3424: "ja", "行スクロールと列スクロール"),
3425: ComponentFactory.createHorizontalSeparator (),
3426: ComponentFactory.createHorizontalBox (
3427: Box.createHorizontalStrut (20),
3428: Multilingual.mlnText (ComponentFactory.createLabel ("Number of sprites per raster"), "ja", "ラスタあたりのスプライトの枚数"),
3429: Box.createHorizontalGlue ()
3430: ),
3431: ComponentFactory.createHorizontalBox (
3432: Box.createHorizontalStrut (20),
3433: sprrasSpinner,
3434: ComponentFactory.createLabel (" **"),
3435: Box.createHorizontalGlue ()
3436: ),
3437: Multilingual.mlnText (
3438: ComponentFactory.createMenuItem ("** Reset to default values", modificationListener),
3439: "ja", "** 初期値に戻す")
3440: ),
3441: "ja", "スプライト画面")
3442: ),
3443: "ja", "改造");
3444:
3445:
3446: mnbMenuBar = ComponentFactory.createMenuBar (
3447:
3448:
3449: mnbFileMenu = Multilingual.mlnText (
3450: ComponentFactory.createMenu (
3451: "File", 'F',
3452:
3453: FDC.fdcMenu,
3454:
3455: HDC.hdcMenu,
3456:
3457: SPC.spcMenu,
3458:
3459: HFS.hfsMenu,
3460: ComponentFactory.createHorizontalSeparator (),
3461: mnbQuitMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Quit", 'Q', MNB_MODIFIERS, listener), "ja", "終了")
3462: ),
3463: "ja", "ファイル"),
3464:
3465:
3466: mpuMenu,
3467:
3468:
3469: mnbDisplayMenu = Multilingual.mlnText (
3470: ComponentFactory.createMenu (
3471: "Display", 'D',
3472: mnbFullScreenMenuItem,
3473: !PNL_ROUNDED_CORNER_ON ? null : ComponentFactory.createHorizontalBox (
3474: Box.createHorizontalStrut (20),
3475: Multilingual.mlnText (
3476: ComponentFactory.createLabel ("Rounded corner ratio "),
3477: "ja", "角丸率 "),
3478: pnlRoundedCornerSpinner,
3479: ComponentFactory.createLabel ("%"),
3480: Box.createHorizontalGlue ()
3481: ),
3482: mnbMaximizedMenuItem,
3483: mnbFitInWindowMenuItem,
3484: mnbFixedScaleMenuItem,
3485: ComponentFactory.createHorizontalBox (
3486: Box.createHorizontalStrut (20),
3487: pnlFixedSpinner,
3488: ComponentFactory.createLabel ("%"),
3489: Box.createHorizontalGlue ()
3490: ),
3491: ComponentFactory.createMenuItem ("50%", listener),
3492: ComponentFactory.createMenuItem ("75%", listener),
3493: ComponentFactory.createMenuItem ("100%", listener),
3494: ComponentFactory.createMenuItem ("150%", listener),
3495: ComponentFactory.createMenuItem ("200%", listener),
3496:
3497: rotationMenu,
3498:
3499: aspectMenu,
3500:
3501: Multilingual.mlnText (
3502: ComponentFactory.createMenu (
3503: "Interpolation algorithm",
3504: Multilingual.mlnText (
3505: ComponentFactory.createRadioButtonMenuItem (
3506: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
3507: "Nearest neighbor", listener),
3508: "ja", "最近傍補間"),
3509: Multilingual.mlnText (
3510: ComponentFactory.createRadioButtonMenuItem (
3511: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR,
3512: "Bilinear", listener),
3513: "ja", "線形補間"),
3514: Multilingual.mlnText (
3515: ComponentFactory.createRadioButtonMenuItem (
3516: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC,
3517: "Bicubic", listener),
3518: "ja", "三次補間")
3519: ),
3520: "ja", "補間アルゴリズム"),
3521:
3522: scanlineMenu,
3523: !PNL_USE_CANVAS ? null : Multilingual.mlnText (
3524: ComponentFactory.createCheckBoxMenuItem (pnlUseCanvasRequest, "Use canvas", listener),
3525: "ja", "キャンバスを使う"),
3526:
3527: !CRTC.CRT_ENABLE_INTERMITTENT ? null : Multilingual.mlnText (
3528: ComponentFactory.createMenu (
3529: "Intermittent drawing",
3530: Multilingual.mlnText (
3531: ComponentFactory.createRadioButtonMenuItem (
3532: intermittentGroup, CRTC.crtIntermittentInterval == 0, "Draw all changed pictures", listener),
3533: "ja", "変化した画像をすべて描画する"),
3534: Multilingual.mlnText (
3535: ComponentFactory.createRadioButtonMenuItem (
3536: intermittentGroup, CRTC.crtIntermittentInterval == 1, "Draw a changed picture once every two times", listener),
3537: "ja", "変化した画像を 2 回に 1 回描画する"),
3538: Multilingual.mlnText (
3539: ComponentFactory.createRadioButtonMenuItem (
3540: intermittentGroup, CRTC.crtIntermittentInterval == 2, "Draw a changed picture once every three times", listener),
3541: "ja", "変化した画像を 3 回に 1 回描画する"),
3542: Multilingual.mlnText (
3543: ComponentFactory.createRadioButtonMenuItem (
3544: intermittentGroup, CRTC.crtIntermittentInterval == 3, "Draw a changed picture once every four times", listener),
3545: "ja", "変化した画像を 4 回に 1 回描画する"),
3546: Multilingual.mlnText (
3547: ComponentFactory.createRadioButtonMenuItem (
3548: intermittentGroup, CRTC.crtIntermittentInterval == 4, "Draw a changed picture once every five times", listener),
3549: "ja", "変化した画像を 5 回に 1 回描画する")
3550: ),
3551: "ja", "間欠描画"),
3552:
3553: !PNL_STEREOSCOPIC_ON ? null : ComponentFactory.createHorizontalSeparator (),
3554: mnbStereoscopicMenuItem = !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3555: ComponentFactory.createCheckBoxMenuItem (pnlStereoscopicOn, "Stereoscopic viewing", 'T', listener),
3556: "ja", "立体視"),
3557: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3558: ComponentFactory.createMenu (
3559: "Stereoscopic settings",
3560: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3561: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3562: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING,
3563: "Naked-eye crossing", listener),
3564: "ja", "裸眼交差法"),
3565: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3566: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3567: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL,
3568: "Naked-eye parallel", listener),
3569: "ja", "裸眼平行法"),
3570: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3571: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3572: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE,
3573: "Side-by-side", listener),
3574: "ja", "サイドバイサイド"),
3575: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3576: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3577: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM,
3578: "Top-and-bottom", listener),
3579: "ja", "トップアンドボトム")
3580: ),
3581: "ja", "立体視設定"),
3582:
3583: ComponentFactory.createHorizontalSeparator (),
3584: GIFAnimation.gifStartRecordingMenuItem,
3585: GIFAnimation.gifSettingsMenu,
3586:
3587: ComponentFactory.createHorizontalSeparator (),
3588: modificationMenu,
3589:
3590: SpritePatternViewer.SPV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Sprite pattern viewer", listener), "ja", "スプライトパターンビュア") : null,
3591: PaletteViewer.PLV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Palette viewer", listener), "ja", "パレットビュア") : null,
3592: ScreenModeTest.SMT_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Screen mode test", listener), "ja", "表示モードテスト") : null
3593: ),
3594: "ja", "画面"),
3595:
3596:
3597: mnbSoundMenu = ComponentFactory.setEnabled (
3598: Multilingual.mlnText (
3599: ComponentFactory.createMenu (
3600: "Sound", 'S',
3601: mnbPlayMenuItem = ComponentFactory.setEnabled (
3602: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (SoundSource.sndPlayOn, "Play", 'P', MNB_MODIFIERS, listener), "ja", "音声出力"),
3603: SoundSource.sndLine != null),
3604:
3605:
3606:
3607: ComponentFactory.createHorizontalBox (
3608: Box.createHorizontalGlue (),
3609: Multilingual.mlnText (ComponentFactory.createLabel ("Volume "), "ja", "音量 "),
3610: mnbVolumeLabel = ComponentFactory.createLabel (String.valueOf (SoundSource.sndVolume)),
3611: Box.createHorizontalGlue ()
3612: ),
3613:
3614:
3615: ComponentFactory.setPreferredSize (
3616: ComponentFactory.createHorizontalSlider (
3617: 0,
3618: SoundSource.SND_VOLUME_MAX,
3619: SoundSource.sndVolume,
3620: SoundSource.SND_VOLUME_STEP,
3621: 1,
3622: new ChangeListener () {
3623: @Override public void stateChanged (ChangeEvent ce) {
3624: SoundSource.sndSetVolume (((JSlider) ce.getSource ()).getValue ());
3625: }
3626: }),
3627: LnF.lnfFontSize * 18, LnF.lnfFontSize * 2 + 28),
3628: Multilingual.mlnText (
3629: ComponentFactory.createMenu (
3630: "Sound interpolation",
3631: Multilingual.mlnText (
3632: ComponentFactory.createRadioButtonMenuItem (
3633: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.THINNING_STEREO,
3634: "Sound thinning", listener),
3635: "ja", "音声 間引き"),
3636: Multilingual.mlnText (
3637: ComponentFactory.createRadioButtonMenuItem (
3638: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_STEREO,
3639: "Sound linear interpolation", listener),
3640: "ja", "音声 線形補間"),
3641: ComponentFactory.setEnabled (
3642: Multilingual.mlnText (
3643: ComponentFactory.createRadioButtonMenuItem (
3644: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000,
3645: "Sound piecewise-constant area interpolation", listener),
3646: "ja", "音声 区分定数面積補間"),
3647: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000),
3648: ComponentFactory.setEnabled (
3649: Multilingual.mlnText (
3650: ComponentFactory.createRadioButtonMenuItem (
3651: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000,
3652: "Sound linear area interpolation", listener),
3653: "ja", "音声 線形面積補間"),
3654: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000)
3655: ),
3656: "ja", "音声補間"),
3657: Multilingual.mlnText (ComponentFactory.createMenuItem ("Sound monitor", listener), "ja", "音声モニタ"),
3658:
3659: ComponentFactory.createHorizontalSeparator (),
3660:
3661: ComponentFactory.setEnabled (
3662: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (OPM.opmOutputMask != 0, "OPM output", listener), "ja", "OPM 出力"),
3663: SoundSource.sndLine != null),
3664: !OPMLog.OLG_ON ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("OPM log", listener), "ja", "OPM ログ"),
3665:
3666: ComponentFactory.createHorizontalSeparator (),
3667:
3668: ComponentFactory.setEnabled (
3669: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ADPCM.pcmOutputOn, "PCM output", listener), "ja", "PCM 出力"),
3670: SoundSource.sndLine != null),
3671: Multilingual.mlnText (
3672: ComponentFactory.createMenu (
3673: "PCM interpolation",
3674: Multilingual.mlnText (
3675: ComponentFactory.createRadioButtonMenuItem (
3676: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_CONSTANT,
3677: "PCM piecewise-constant interpolation", listener),
3678: "ja", "PCM 区分定数補間"),
3679: Multilingual.mlnText (
3680: ComponentFactory.createRadioButtonMenuItem (
3681: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_LINEAR,
3682: "PCM linear interpolation", listener),
3683: "ja", "PCM 線形補間"),
3684: Multilingual.mlnText (
3685: ComponentFactory.createRadioButtonMenuItem (
3686: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_HERMITE,
3687: "PCM hermite interpolation", listener),
3688: "ja", "PCM エルミート補間")
3689: ),
3690: "ja", "PCM 補間"),
3691: Multilingual.mlnText (
3692: ComponentFactory.createMenu (
3693: "PCM source oscillator frequency",
3694: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 0, "PCM 8MHz/4MHz", listener),
3695: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 1, "PCM 8MHz/16MHz", listener)
3696: ),
3697: "ja", "PCM 原発振周波数"),
3698:
3699: !MercuryUnit.MU4_ON ? null :
3700: ComponentFactory.createHorizontalSeparator (),
3701: !MercuryUnit.MU4_ON ? null :
3702: ComponentFactory.createCheckBoxMenuItem (
3703: MercuryUnit.mu4OnRequest,
3704: "Mercury-Unit V4 (MK-MU1)",
3705: listener),
3706: !MercuryUnit.MU4_ON ? null :
3707: Multilingual.mlnText (
3708: ComponentFactory.createCheckBoxMenuItem (
3709: MercuryUnit.mu4OutputEnable,
3710: "MU4 output",
3711: listener),
3712: "ja", "MU4 出力")
3713: ),
3714: "ja", "音声"),
3715: SoundSource.sndLine != null),
3716:
3717:
3718: mnbInputMenu = Multilingual.mlnText (
3719: ComponentFactory.createMenu (
3720: "Input", 'I',
3721: mnbPasteMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Paste", 'V', MNB_MODIFIERS, listener), "ja", "貼り付け"),
3722: CONDevice.conSettingsMenu,
3723: TextCopy.txcMakeMenuItem (),
3724: TextCopy.txcMakeSettingMenu (),
3725: ComponentFactory.createHorizontalSeparator (),
3726: mnbNoKeyboardMenuItem = Multilingual.mlnText (
3727: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, !Keyboard.kbdOn, "No keyboard", 'K', MNB_MODIFIERS, listener),
3728: "ja", "キーボードなし"),
3729: mnbStandardKeyboardMenuItem = Multilingual.mlnText (
3730: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_STANDARD_TYPE, "Standard keyboard", listener),
3731: "ja", "標準キーボード"),
3732: mnbCompactKeyboardMenuItem = Multilingual.mlnText (
3733: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_COMPACT_TYPE, "Compact keyboard", listener),
3734: "ja", "コンパクトキーボード"),
3735: Multilingual.mlnText (
3736: ComponentFactory.createCheckBoxMenuItem (pnlHideKeyboard, "Hide keyboard in full screen", listener),
3737: "ja", "全画面表示のときキーボードを隠す"),
3738: Multilingual.mlnText (ComponentFactory.createMenuItem ("Key assignments", listener), "ja", "キー割り当て"),
3739: ButtonFunction.bfnMakeMenuItem (),
3740: SRAM.smrRepeatDelayMenu,
3741: SRAM.smrRepeatIntervalMenu,
3742: !Keyboard.KBD_ZKEY_ON ? null : Keyboard.kbdZKeyMenu,
3743: ComponentFactory.createHorizontalSeparator (),
3744: Mouse.musSeamlessMouseCheckBox,
3745: Mouse.musFollowScrollCheckBox,
3746: Mouse.musCtrlRightCheckBox,
3747: Mouse.musEdgeAccelerationCheckBox,
3748: Mouse.musMouseCursorSpeedBox,
3749: Mouse.musSpeedSlider,
3750: Mouse.musHostsPixelUnitsCheckBox,
3751: ComponentFactory.createHorizontalSeparator (),
3752: Multilingual.mlnText (ComponentFactory.createMenuItem ("Joystick port settings", listener), "ja", "ジョイスティックポート設定")
3753: ),
3754: "ja", "入力"),
3755:
3756:
3757: mnbConfigMenu = Multilingual.mlnText (
3758: ComponentFactory.createMenu (
3759: "Config", 'G',
3760: Multilingual.mlnText (ComponentFactory.createMenuItem ("RS-232C and terminal", listener), "ja", "RS-232C とターミナル"),
3761: Multilingual.mlnText (
3762: ComponentFactory.createMenu (
3763: "Debug",
3764: Multilingual.mlnText (ComponentFactory.createMenuItem ("Console", listener), "ja", "コンソール"),
3765: Multilingual.mlnText (ComponentFactory.createMenuItem ("Register list", listener), "ja", "レジスタリスト"),
3766: Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble list", listener), "ja", "逆アセンブルリスト"),
3767: Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory dump list", listener), "ja", "メモリダンプリスト"),
3768: Multilingual.mlnText (ComponentFactory.createMenuItem ("Logical space monitor", listener), "ja", "論理空間モニタ"),
3769: Multilingual.mlnText (ComponentFactory.createMenuItem ("Physical space monitor", listener), "ja", "物理空間モニタ"),
3770: ATCMonitor.ACM_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Address translation caches monitor", listener), "ja", "アドレス変換キャッシュモニタ") : null,
3771: BranchLog.BLG_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Branch log", listener), "ja", "分岐ログ") : null,
3772: ProgramFlowVisualizer.PFV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Program flow visualizer", listener), "ja", "プログラムフロービジュアライザ") : null,
3773: RasterBreakPoint.RBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Raster break point", listener), "ja", "ラスタブレークポイント") : null,
3774: DataBreakPoint.DBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Data break point", listener), "ja", "データブレークポイント") : null,
3775: RootPointerList.RTL_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Root pointer list", listener), "ja", "ルートポインタリスト") : null,
3776: ComponentFactory.createHorizontalSeparator (),
3777: SRAM.smrRomdbMenu
3778: ),
3779: "ja", "デバッグ"),
3780: SRAM.smrBootMenu,
3781: mainMemoryMenu,
3782: highMemoryMenu,
3783: localMemoryMenu,
3784: xellent30Menu,
3785: ComponentFactory.createHorizontalSeparator (),
3786: ComponentFactory.createMenu (
3787: "RTC",
3788: Multilingual.mlnText (
3789: ComponentFactory.createMenuItem ("Adjust clock to host", listener),
3790: "ja", "時計をホストに合わせる")
3791: ),
3792: SRAM.smrMenu,
3793: Settings.sgsMenu,
3794: ComponentFactory.createHorizontalSeparator (),
3795: Multilingual.mlnText (ComponentFactory.createMenuItem ("Printer", listener), "ja", "プリンタ"),
3796: ROM.romMenu,
3797: Multilingual.mlnText (
3798: ComponentFactory.createMenu (
3799: "Miscellaneous",
3800: SlowdownTest.sdtCheckBoxMenuItem,
3801: SlowdownTest.sdtBox,
3802: Multilingual.mlnText (
3803: ComponentFactory.createCheckBoxMenuItem (Mouse.musOutputButtonStatus, "Print key and mouse button events", listener),
3804: "ja", "キーとマウスのボタンのイベントを表示"),
3805: Z8530.SCC_DEBUG_ON ? Z8530.sccDebugMenu : null
3806: ),
3807: "ja", "その他"),
3808: ComponentFactory.createHorizontalSeparator (),
3809: Multilingual.mlnText (
3810: ComponentFactory.createMenuItem ("Java runtime environment information", listener),
3811: "ja", "Java 実行環境の情報"),
3812: Multilingual.mlnText (
3813: ComponentFactory.createMenuItem ("Version information", listener),
3814: "ja", "バージョン情報"),
3815: Multilingual.mlnText (
3816: ComponentFactory.createMenu (
3817: "License",
3818: Multilingual.mlnText (ComponentFactory.createMenuItem ("XEiJ License", listener), "ja", "XEiJ 使用許諾条件"),
3819: Multilingual.mlnText (ComponentFactory.createMenuItem ("FSHARP License", listener), "ja", "FSHARP 許諾条件"),
3820: Multilingual.mlnText (ComponentFactory.createMenuItem ("ymfm License", listener), "ja", "ymfm License"),
3821: Multilingual.mlnText (ComponentFactory.createMenuItem ("jSerialComm License", listener), "ja", "jSerialComm License")
3822: ),
3823: "ja", "使用許諾条件")
3824: ),
3825: "ja", "設定"),
3826:
3827: mnbMakeLanguageMenu (),
3828:
3829:
3830: Box.createHorizontalGlue (),
3831: ComponentFactory.createVerticalBox (
3832: Box.createVerticalGlue (),
3833: Indicator.indBox,
3834: Box.createVerticalGlue ()
3835: ),
3836: Box.createHorizontalGlue ()
3837:
3838: );
3839: }
3840:
3841:
3842:
3843:
3844:
3845:
3846:
3847: public static boolean frmIsActive;
3848:
3849:
3850: public static JFrame frmFrame;
3851: public static int frmMarginWidth;
3852: public static int frmMarginHeight;
3853: public static Dimension frmMinimumSize;
3854:
3855:
3856: public static GraphicsDevice frmScreenDevice;
3857:
3858:
3859: public static DropTarget frmDropTarget;
3860:
3861:
3862:
3863: public static void frmInit () {
3864: frmIsActive = false;
3865: frmScreenDevice = GraphicsEnvironment.getLocalGraphicsEnvironment ().getDefaultScreenDevice ();
3866: pnlIsFullScreenSupported = frmScreenDevice.isFullScreenSupported ();
3867: }
3868:
3869:
3870:
3871: public static void frmMake () {
3872:
3873:
3874: frmFrame = ComponentFactory.createRestorableFrame (
3875: Settings.SGS_FRM_FRAME_KEY,
3876: PRG_TITLE + " version " + PRG_VERSION,
3877: mnbMenuBar,
3878: pnlPanel);
3879: frmUpdateTitle ();
3880: frmFrame.setIconImage (LnF.LNF_ICON_IMAGE_48);
3881: frmFrame.setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);
3882:
3883:
3884:
3885:
3886: frmMarginWidth = frmFrame.getWidth () - pnlPanel.getWidth ();
3887: frmMarginHeight = frmFrame.getHeight () - pnlPanel.getHeight ();
3888: frmMinimumSize = new Dimension (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
3889: frmFrame.setMinimumSize (frmMinimumSize);
3890:
3891:
3892:
3893: frmDropTarget = new DropTarget (pnlPanel, DnDConstants.ACTION_COPY, new DropTargetAdapter () {
3894: @Override public void dragOver (DropTargetDragEvent dtde) {
3895: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
3896: dtde.acceptDrag (DnDConstants.ACTION_COPY);
3897: return;
3898: }
3899: dtde.rejectDrag ();
3900: }
3901: @Override public void drop (DropTargetDropEvent dtde) {
3902: try {
3903: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
3904: dtde.acceptDrop (DnDConstants.ACTION_COPY);
3905: boolean reset = false;
3906: int fdu0 = -1;
3907: int fdu = 0;
3908: int hdu0 = -1;
3909: int hdu = 0;
3910: int scu0 = -1;
3911: int scu = 0;
3912: int hfu0 = -1;
3913: int hfu = 0;
3914: for (Object o : (java.util.List) dtde.getTransferable ().getTransferData (DataFlavor.javaFileListFlavor)) {
3915: if (o instanceof File) {
3916: File file = (File) o;
3917: if (file.isFile ()) {
3918: if (FDC.fdcFileFilter.accept (file)) {
3919: if (fdu < FDC.FDC_MAX_UNITS &&
3920: FDC.fdcUnitArray[fdu].insert (file.getPath (), false)) {
3921: if (fdu0 < 0) {
3922: fdu0 = fdu;
3923: }
3924: fdu++;
3925: continue;
3926: }
3927: }
3928: if (HDC.hdcFileFilter.accept (file)) {
3929: if (hdu < 16 &&
3930: HDC.hdcUnitArray[hdu].insert (file.getPath (), false)) {
3931: if (hdu0 < 0) {
3932: hdu0 = hdu;
3933: }
3934: hdu++;
3935: continue;
3936: }
3937: }
3938: if (SPC.spcFileFilter.accept (file)) {
3939: if (scu < 16 &&
3940: SPC.spcUnitArray[scu].insert (file.getPath (), false)) {
3941: if (scu0 < 0) {
3942: scu0 = scu;
3943: }
3944: scu++;
3945: continue;
3946: }
3947: }
3948: }
3949: if (HFS.hfsFileFilter.accept (file)) {
3950: if (hfu < HFS.HFS_MAX_UNITS &&
3951: HFS.hfsUnitArray[hfu].insert (file.getPath (), false)) {
3952: if (hfu0 < 0) {
3953: hfu0 = hfu;
3954: }
3955: hfu++;
3956: continue;
3957: }
3958: }
3959: }
3960: reset = false;
3961: }
3962: dtde.dropComplete (true);
3963: if (reset) {
3964: if (fdu0 >= 0) {
3965: mpuReset (0x9070 | fdu0 << 8, -1);
3966: } else if (hdu0 >= 0) {
3967: mpuReset (0x8000 | hdu0 << 8, -1);
3968: } else if (scu0 >= 0) {
3969: mpuReset (0xa000, SPC.SPC_HANDLE_EX + (scu0 << 2));
3970: } else if (hfu0 >= 0) {
3971: HFS.hfsBootUnit = hfu0;
3972: mpuReset (0xa000, HFS.HFS_BOOT_HANDLE);
3973: }
3974: }
3975: return;
3976: }
3977: } catch (UnsupportedFlavorException ufe) {
3978:
3979: } catch (IOException ioe) {
3980:
3981: }
3982: dtde.rejectDrop();
3983: }
3984: });
3985:
3986: }
3987:
3988:
3989:
3990: public static void frmUpdateTitle () {
3991: frmFrame.setTitle ((currentAccelerator == ACCELERATOR_HYBRID ? "X68000 Hybrid" :
3992: currentModel.getName () +
3993: (currentAccelerator == ACCELERATOR_XELLENT30 ? " with Xellent30" :
3994: currentAccelerator == ACCELERATOR_060TURBO ? " with 060turbo" :
3995: currentAccelerator == ACCELERATOR_060TURBOPRO ? " with 060turboPRO" : "")) +
3996: " - " + PRG_TITLE + " version " + PRG_VERSION);
3997: }
3998:
3999:
4000:
4001: public static void frmStart () {
4002:
4003:
4004:
4005:
4006:
4007:
4008:
4009:
4010: ComponentFactory.addListener (
4011: frmFrame,
4012: new WindowAdapter () {
4013: @Override public void windowActivated (WindowEvent we) {
4014: frmIsActive = true;
4015: }
4016: @Override public void windowClosing (WindowEvent we) {
4017: prgTini ();
4018: }
4019: @Override public void windowDeactivated (WindowEvent we) {
4020: frmIsActive = false;
4021:
4022: }
4023: @Override public void windowOpened (WindowEvent we) {
4024: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
4025: pnlFixedRate = pnlGetRefreshRate ();
4026: }
4027: }
4028: });
4029:
4030:
4031:
4032:
4033: ComponentFactory.addListener (
4034: frmFrame,
4035: new ComponentAdapter () {
4036: @Override public void componentMoved (ComponentEvent ce) {
4037: Point p = pnlPanel.getLocationOnScreen ();
4038: pnlGlobalX = p.x;
4039: pnlGlobalY = p.y;
4040: }
4041: @Override public void componentResized (ComponentEvent ce) {
4042: Point p = pnlPanel.getLocationOnScreen ();
4043: pnlGlobalX = p.x;
4044: pnlGlobalY = p.y;
4045: }
4046: });
4047:
4048: }
4049:
4050:
4051:
4052:
4053:
4054:
4055: public static BufferedImage clpClipboardImage;
4056: public static String clpClipboardString;
4057: public static Clipboard clpClipboard;
4058: public static Transferable clpImageContents;
4059: public static Transferable clpStringContents;
4060: public static ClipboardOwner clpClipboardOwner;
4061: public static boolean clpIsClipboardOwner;
4062:
4063:
4064:
4065:
4066: public static void clpMake () {
4067: Toolkit toolkit = Toolkit.getDefaultToolkit ();
4068: clpClipboard = null;
4069: try {
4070: clpClipboard = toolkit.getSystemClipboard ();
4071: } catch (Exception e) {
4072: return;
4073: }
4074: clpClipboardImage = null;
4075: clpClipboardString = null;
4076: clpImageContents = new Transferable () {
4077: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
4078: if (flavor == DataFlavor.imageFlavor) {
4079: return clpClipboardImage;
4080: } else {
4081: throw new UnsupportedFlavorException (flavor);
4082: }
4083: }
4084: public DataFlavor[] getTransferDataFlavors () {
4085: return new DataFlavor[] { DataFlavor.imageFlavor };
4086: }
4087: public boolean isDataFlavorSupported (DataFlavor flavor) {
4088: return flavor == DataFlavor.imageFlavor;
4089: }
4090: };
4091: clpStringContents = new Transferable () {
4092: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
4093: if (flavor == DataFlavor.stringFlavor) {
4094: return clpClipboardString;
4095: } else {
4096: throw new UnsupportedFlavorException (flavor);
4097: }
4098: }
4099: public DataFlavor[] getTransferDataFlavors () {
4100: return new DataFlavor[] { DataFlavor.stringFlavor };
4101: }
4102: public boolean isDataFlavorSupported (DataFlavor flavor) {
4103: return flavor == DataFlavor.stringFlavor;
4104: }
4105: };
4106: clpIsClipboardOwner = false;
4107:
4108:
4109: clpClipboardOwner = new ClipboardOwner () {
4110: @Override public void lostOwnership (Clipboard clipboard, Transferable contents) {
4111: clpIsClipboardOwner = false;
4112: }
4113: };
4114:
4115:
4116: clpClipboard.addFlavorListener (new FlavorListener () {
4117: @Override public void flavorsChanged (FlavorEvent fe) {
4118: boolean available = false;
4119: try {
4120: available = clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor);
4121: } catch (IllegalStateException ise) {
4122: }
4123: if (mnbPasteMenuItem != null) {
4124: mnbPasteMenuItem.setEnabled (available);
4125: }
4126: }
4127: });
4128: if (!clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor)) {
4129: if (mnbPasteMenuItem != null) {
4130: mnbPasteMenuItem.setEnabled (false);
4131: }
4132: }
4133: }
4134:
4135:
4136:
4137: public static void clpCopy (String s) {
4138: if (clpClipboard != null && s != null) {
4139: clpClipboardString = s;
4140: try {
4141: clpClipboard.setContents (clpStringContents, clpClipboardOwner);
4142: clpIsClipboardOwner = true;
4143: } catch (Exception e) {
4144: return;
4145: }
4146: }
4147: }
4148:
4149:
4150:
4151:
4152:
4153:
4154:
4155:
4156:
4157:
4158:
4159:
4160:
4161:
4162:
4163:
4164:
4165:
4166:
4167:
4168:
4169:
4170:
4171: public static int xt3DIPSWRequest;
4172: public static int xt3DIPSW;
4173: public static int xt3PortAddress;
4174:
4175:
4176: public static int xt3MemorySizeRequest;
4177: public static int xt3MemorySize;
4178: public static boolean xt3MemoryEnabled;
4179: public static int xt3MemoryPosition;
4180: public static int xt3MemoryStart;
4181: public static final byte[] xt3MemoryArray = new byte[1 << 20];
4182: public static boolean xt3MemorySave;
4183:
4184:
4185: public static int xt3SavedPC;
4186: public static final int[] xt3SavedRn = new int[16];
4187:
4188:
4189: public static void xt3Init () {
4190:
4191:
4192: xt3DIPSWRequest = Math.max (0, Math.min (3, Settings.sgsGetInt ("xt3dipsw")));
4193: xt3DIPSW = xt3DIPSWRequest;
4194:
4195:
4196: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4197:
4198:
4199: int memoryKB = Settings.sgsGetInt ("xt3memorykb");
4200: if (!(memoryKB == 1 << 8 || memoryKB == 1 << 10)) {
4201: memoryKB = 1 << 8;
4202: }
4203: xt3MemorySizeRequest = memoryKB << 10;
4204: xt3MemorySize = xt3MemorySizeRequest;
4205:
4206:
4207: xt3MemoryEnabled = false;
4208:
4209:
4210: xt3MemoryPosition = 11 << 20;
4211:
4212:
4213: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4214:
4215:
4216:
4217: byte[] memoryArray = Settings.sgsGetData ("xt3memorydata");
4218: Arrays.fill (xt3MemoryArray,
4219: (byte) 0);
4220: if (memoryArray.length != 0) {
4221: System.arraycopy (memoryArray, 0,
4222: xt3MemoryArray, 0,
4223: Math.min (memoryArray.length, xt3MemoryArray.length));
4224: if (memoryArray.length < xt3MemoryArray.length) {
4225: Arrays.fill (xt3MemoryArray,
4226: memoryArray.length,
4227: xt3MemoryArray.length,
4228: (byte) 0);
4229: }
4230: }
4231:
4232:
4233: xt3MemorySave = Settings.sgsGetOnOff ("xt3memorysave");
4234:
4235:
4236: xt3SavedPC = 0;
4237:
4238: Arrays.fill (xt3SavedRn, 0);
4239:
4240: xt3Reset ();
4241: }
4242:
4243:
4244: public static void xt3Tini () {
4245:
4246:
4247: Settings.sgsPutInt ("xt3dipsw", xt3DIPSW);
4248:
4249:
4250: Settings.sgsPutInt ("xt3memorykb", xt3MemorySizeRequest >> 10);
4251:
4252:
4253: boolean zero = true;
4254: if (xt3MemorySave) {
4255: for (int i = 0; i < 1 << 20; i++) {
4256: if (xt3MemoryArray[i] != 0) {
4257: zero = false;
4258: break;
4259: }
4260: }
4261: }
4262: Settings.sgsCurrentMap.put ("xt3memorydata",
4263: zero ? "" :
4264: ByteArray.byaEncodeBase64 (ByteArray.byaEncodeGzip (xt3MemoryArray, 0, 1 << 20)));
4265:
4266:
4267: Settings.sgsPutOnOff ("xt3memorysave", xt3MemorySave);
4268:
4269: }
4270:
4271:
4272: public static void xt3Reset () {
4273:
4274:
4275: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4276:
4277:
4278: xt3MemorySize = xt3MemorySizeRequest;
4279:
4280:
4281: xt3MemoryEnabled = false;
4282:
4283:
4284: xt3MemoryPosition = 11 << 20;
4285:
4286:
4287: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4288:
4289:
4290: xt3SavedPC = 0;
4291: Arrays.fill (xt3SavedRn, 0);
4292:
4293: }
4294:
4295:
4296: public static int xt3PortRead () {
4297: return (currentIsSecond ? 4 : 0) | (xt3MemoryEnabled ? 2 : 0) | (xt3MemoryPosition == 11 << 20 ? 0 : 1);
4298: }
4299:
4300:
4301: public static void xt3PortWrite (int d) {
4302: boolean nextIsSecond = (d & 4) != 0;
4303: boolean memoryEnabled = (d & 2) != 0;
4304: int memoryPosition = (d & 1) == 0 ? 11 << 20 : 15 << 20;
4305:
4306: if (xt3MemoryEnabled != memoryEnabled ||
4307: xt3MemoryPosition != memoryPosition) {
4308: if (xt3MemoryEnabled) {
4309: if (xt3MemoryPosition == 11 << 20) {
4310: if (MainMemory.mmrMemorySizeCurrent < 12 << 20) {
4311: busSuper (MemoryMappedDevice.MMD_NUL, (12 << 20) - xt3MemorySize, 12 << 20);
4312: } else {
4313: busUser (MemoryMappedDevice.MMD_MMR, (12 << 20) - xt3MemorySize, 12 << 20);
4314: }
4315: } else {
4316: busSuper (MemoryMappedDevice.MMD_ROM, (16 << 20) - xt3MemorySize, 16 << 20);
4317: }
4318: }
4319: xt3MemoryEnabled = memoryEnabled;
4320: xt3MemoryPosition = memoryPosition;
4321: if (xt3MemoryEnabled) {
4322: if (xt3MemoryPosition == 11 << 20) {
4323: busUser (MemoryMappedDevice.MMD_XTM, (12 << 20) - xt3MemorySize, 12 << 20);
4324: } else {
4325: busUser (MemoryMappedDevice.MMD_XTM, (16 << 20) - xt3MemorySize, 16 << 20);
4326: }
4327: }
4328: }
4329:
4330: if (currentIsSecond != nextIsSecond) {
4331:
4332: if (nextIsSecond) {
4333:
4334:
4335: xt3SavedPC = regPC;
4336: System.arraycopy (regRn, 0, xt3SavedRn, 0, 16);
4337:
4338:
4339: if (mpuTask != null) {
4340: mpuClockLimit = 0L;
4341: System.out.println (Multilingual.mlnJapanese ?
4342: Model.MPU_NAMES[currentFirstMPU] + " を停止します" :
4343: Model.MPU_NAMES[currentFirstMPU] + " stops");
4344: mpuTask.cancel ();
4345: mpuTask = null;
4346: }
4347:
4348:
4349: tmrTimer.schedule (new TimerTask () {
4350: @Override public void run () {
4351:
4352:
4353: currentIsSecond = true;
4354: currentMPU = currentSecondMPU;
4355: mpuSetCurrentClock (specifiedSecondClock);
4356:
4357: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
4358: MC68EC030.m30DivZeroVFlag = false;
4359: }
4360:
4361: RegisterList.drpSetMPU ();
4362: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4363: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4364: MC68060.mmuReset ();
4365:
4366: mpuIgnoreAddressError = true;
4367: fpuBox = fpuMotherboardCoprocessor;
4368: fpuBox.epbReset ();
4369: fpuFPn = fpuBox.epbFPn;
4370: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
4371: mpuSetWait ();
4372:
4373: regSRT1 = regSRT0 = 0;
4374: regSRS = REG_SR_S;
4375: regSRM = 0;
4376: regSRI = REG_SR_I;
4377: regCCR = 0;
4378: Arrays.fill (regRn, 0);
4379:
4380: regRn[15] = MainMemory.mmrRls (0x00000000);
4381: regPC = MainMemory.mmrRls (0x00000004);
4382:
4383: mpuIMR = 0;
4384: mpuIRR = 0;
4385: if (MC68901.MFP_DELAYED_INTERRUPT) {
4386: mpuDIRR = 0;
4387: }
4388: mpuISR = 0;
4389:
4390: mpuStart ();
4391: }
4392: }, TMR_DELAY);
4393:
4394: } else {
4395:
4396:
4397: if (mpuTask != null) {
4398: mpuClockLimit = 0L;
4399: System.out.println (Multilingual.mlnJapanese ? "MC68EC030 を停止します" : "MC68EC030 stops");
4400: mpuTask.cancel ();
4401: mpuTask = null;
4402: }
4403:
4404:
4405: tmrTimer.schedule (new TimerTask () {
4406: @Override public void run () {
4407:
4408:
4409: currentIsSecond = false;
4410: currentMPU = currentFirstMPU;
4411: mpuSetCurrentClock (specifiedFirstClock);
4412:
4413: RegisterList.drpSetMPU ();
4414: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4415: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4416: MC68060.mmuReset ();
4417:
4418: mpuIgnoreAddressError = false;
4419: mpuCacheOn = false;
4420: mpuSetWait ();
4421:
4422: regSRT1 = regSRT0 = 0;
4423: regSRS = REG_SR_S;
4424: regSRM = 0;
4425: regSRI = REG_SR_I;
4426: regCCR = 0;
4427:
4428: regPC = xt3SavedPC;
4429: System.arraycopy (xt3SavedRn, 0, regRn, 0, 16);
4430:
4431: mpuIMR = 0;
4432: mpuIRR = 0;
4433: if (MC68901.MFP_DELAYED_INTERRUPT) {
4434: mpuDIRR = 0;
4435: }
4436: mpuISR = 0;
4437:
4438: mpuStart ();
4439: }
4440: }, TMR_DELAY);
4441:
4442: }
4443: }
4444: }
4445:
4446:
4447:
4448:
4449:
4450:
4451: public static JMenu mdlMenu;
4452:
4453: public static JRadioButtonMenuItem mdlShodaiMenuItem;
4454: public static JRadioButtonMenuItem mdlACEMenuItem;
4455: public static JRadioButtonMenuItem mdlEXPERTMenuItem;
4456: public static JRadioButtonMenuItem mdlPROMenuItem;
4457: public static JRadioButtonMenuItem mdlSUPERMenuItem;
4458: public static JRadioButtonMenuItem mdlXVIMenuItem;
4459: public static JRadioButtonMenuItem mdlXellent30MenuItem;
4460: public static JRadioButtonMenuItem mdlCompactMenuItem;
4461: public static JRadioButtonMenuItem mdlHybridMenuItem;
4462: public static JRadioButtonMenuItem mdl060turboPROMenuItem;
4463: public static JRadioButtonMenuItem mdlX68030MenuItem;
4464: public static JRadioButtonMenuItem mdl030CompactMenuItem;
4465: public static JRadioButtonMenuItem mdl060turboMenuItem;
4466: public static JCheckBoxMenuItem mdlMC68010MenuItem;
4467:
4468: public static JMenu coproFPUMenu;
4469:
4470:
4471: public static final int ACCELERATOR_HYBRID = 1;
4472: public static final int ACCELERATOR_XELLENT30 = 2;
4473: public static final int ACCELERATOR_060TURBO = 3;
4474: public static final int ACCELERATOR_060TURBOPRO = 4;
4475: public static final double MHZ_HYBRID_VALUE = 100.0 / 3.0;
4476: public static final String MHZ_HYBRID_STRING = "33.3";
4477: public static final double MHZ_060TURBO_VALUE = 50.0;
4478: public static final String MHZ_060TURBO_STRING = "50";
4479:
4480:
4481:
4482: public static Model specifiedModel;
4483: public static int specifiedAccelerator;
4484: public static boolean mpu010;
4485:
4486: public static boolean specifiedIsSecond;
4487: public static int specifiedFirstMPU;
4488: public static int specifiedSecondMPU;
4489: public static int specifiedMPU;
4490:
4491: public static double specifiedFirstClock;
4492: public static double specifiedSecondClock;
4493: public static double specifiedClock;
4494:
4495: public static int specifiedCopro0;
4496: public static int specifiedCopro1;
4497: public static int specifiedCopro2;
4498: public static int specifiedOnchipFPU;
4499:
4500:
4501:
4502: public static Model currentModel;
4503: public static int currentAccelerator;
4504:
4505: public static boolean currentIsSecond;
4506: public static int currentFirstMPU;
4507: public static int currentSecondMPU;
4508: public static int currentMPU;
4509:
4510:
4511: public static int currentCopro0;
4512: public static int currentCopro1;
4513: public static int currentCopro2;
4514: public static int currentOnchipFPU;
4515:
4516:
4517:
4518: public static void mdlInit () {
4519:
4520:
4521: specifiedModel = Model.COMPACT;
4522: specifiedAccelerator = ACCELERATOR_HYBRID;
4523: mpu010 = Settings.sgsGetOnOff ("mpu010");
4524: {
4525: String paramModel = Settings.sgsGetString ("model");
4526: switch (paramModel.toLowerCase ()) {
4527: case "":
4528: case "none":
4529: case "hybrid":
4530: specifiedModel = Model.COMPACT;
4531: specifiedAccelerator = ACCELERATOR_HYBRID;
4532: break;
4533: case "xellent30":
4534: specifiedModel = Model.XVI;
4535: specifiedAccelerator = ACCELERATOR_XELLENT30;
4536: break;
4537: case "060turbo":
4538: specifiedModel = Model.X68030;
4539: specifiedAccelerator = ACCELERATOR_060TURBO;
4540: break;
4541: case "060turbopro":
4542: specifiedModel = Model.PRO;
4543: specifiedAccelerator = ACCELERATOR_060TURBOPRO;
4544: break;
4545: default:
4546: Model model = Model.fromTypeOrSynonym (paramModel);
4547: if (model != null) {
4548: specifiedModel = model;
4549: specifiedAccelerator = 0;
4550: } else {
4551: System.out.println (Multilingual.mlnJapanese ?
4552: paramModel + " は不明な機種です" :
4553: paramModel + " is unknown model");
4554: specifiedModel = Model.COMPACT;
4555: specifiedAccelerator = ACCELERATOR_HYBRID;
4556: }
4557: }
4558: }
4559:
4560: specifiedIsSecond = false;
4561: specifiedFirstMPU = specifiedModel.getMPU ();
4562: specifiedSecondMPU = Model.MPU_MC68EC030;
4563: {
4564: String[] paramMPUs = Settings.sgsGetString ("mpu").split (",");
4565: for (int i = 0; i < 2; i++) {
4566: int mpu = 0;
4567: String paramMPU = i < paramMPUs.length ? paramMPUs[i] : "";
4568: switch (paramMPU) {
4569: case "":
4570: case "none":
4571: case "-1":
4572: mpu = (i == 0 ?
4573: (specifiedAccelerator == ACCELERATOR_060TURBO ||
4574: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4575: specifiedModel.getMPU ()) :
4576: Model.MPU_MC68EC030);
4577: break;
4578: case "0":
4579: case "68000":
4580: case "mc68000":
4581: mpu = Model.MPU_MC68000;
4582: break;
4583: case "1":
4584: case "68010":
4585: case "mc68010":
4586: mpu = Model.MPU_MC68010;
4587: break;
4588:
4589:
4590:
4591:
4592:
4593: case "3":
4594: case "68ec030":
4595: case "mc68ec030":
4596: mpu = Model.MPU_MC68EC030;
4597: break;
4598:
4599:
4600:
4601:
4602:
4603:
4604:
4605:
4606:
4607:
4608:
4609:
4610:
4611:
4612:
4613:
4614:
4615: case "6":
4616: case "68060":
4617: case "mc68060":
4618: mpu = Model.MPU_MC68060;
4619: break;
4620: default:
4621: Model model = Model.fromTypeOrSynonym (paramMPU);
4622: if (model != null) {
4623: mpu = model.getMPU ();
4624: } else {
4625: System.out.println (Multilingual.mlnJapanese ?
4626: paramMPU + " は不明な MPU です" :
4627: paramMPU + " is unknown MPU");
4628: mpu = specifiedModel.getMPU ();
4629: }
4630: }
4631: if (i == 0) {
4632: specifiedFirstMPU = mpu;
4633: } else {
4634: specifiedSecondMPU = mpu;
4635: }
4636: }
4637: }
4638: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
4639:
4640: specifiedFirstClock = specifiedModel.getClock ();
4641: specifiedSecondClock = specifiedFirstClock * 2.0;
4642: {
4643: String[] paramClocks = Settings.sgsGetString ("clock").split (",");
4644: for (int i = 0; i < 2; i++) {
4645: double clock = 0.0;
4646: String paramClock = i < paramClocks.length ? paramClocks[i] : "";
4647: switch (paramClock.toLowerCase ()) {
4648: case "":
4649: case "none":
4650: case "-1":
4651: clock = (i == 0 ?
4652: (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4653: specifiedAccelerator == ACCELERATOR_060TURBO ||
4654: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4655: specifiedModel.getClock ()) :
4656: specifiedFirstClock * 2.0);
4657: break;
4658: case "hybrid":
4659: clock = MHZ_HYBRID_VALUE;
4660: break;
4661: case "060turbo":
4662: case "060turbopro":
4663: clock = MHZ_060TURBO_VALUE;
4664: break;
4665: case "16.7":
4666: case "xellent30":
4667: clock = 50.0 / 3.0;
4668: break;
4669: case "33.3":
4670: clock = 100.0 / 3.0;
4671: break;
4672: case "66.7":
4673: clock = 200.0 / 3.0;
4674: break;
4675: default:
4676: if (paramClock.matches ("^(?:" +
4677: "[-+]?" +
4678: "(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)" +
4679: "(?:[Ee][-+]?[0-9]+)?" +
4680: ")$")) {
4681: double d = Double.parseDouble (paramClock);
4682: if (1.0 <= d && d <= 1000.0) {
4683: clock = d;
4684: }
4685: } else {
4686: System.out.println (Multilingual.mlnJapanese ?
4687: paramClock + " は不明な動作周波数です" :
4688: paramClock + " is unknown clock frequency");
4689: clock = specifiedModel.getClock ();
4690: }
4691: }
4692: if (i == 0) {
4693: specifiedFirstClock = clock;
4694: } else {
4695: specifiedSecondClock = clock;
4696: }
4697: }
4698: }
4699: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4700:
4701: specifiedCopro0 = 15 & Settings.sgsGetInt ("copro0", 2);
4702: if (!((7 & specifiedCopro0) == 0 ||
4703: (7 & specifiedCopro0) == 1 ||
4704: (7 & specifiedCopro0) == 2 ||
4705: (7 & specifiedCopro0) == 7)) {
4706: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4707: }
4708: specifiedCopro1 = 15 & Settings.sgsGetInt ("copro1", 2);
4709: if (!((7 & specifiedCopro1) == 0 ||
4710: (7 & specifiedCopro1) == 1 ||
4711: (7 & specifiedCopro1) == 2 ||
4712: (7 & specifiedCopro1) == 7)) {
4713: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4714: }
4715: specifiedCopro2 = 15 & Settings.sgsGetInt ("copro2", 2);
4716: if (!((7 & specifiedCopro2) == 0 ||
4717: (7 & specifiedCopro2) == 1 ||
4718: (7 & specifiedCopro2) == 2 ||
4719: (7 & specifiedCopro2) == 7)) {
4720: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4721: }
4722: specifiedOnchipFPU = 15 & Settings.sgsGetInt ("onchipfpu", 7);
4723: if (!((7 & specifiedOnchipFPU) == 0 ||
4724: (7 & specifiedOnchipFPU) == 6 ||
4725: (7 & specifiedOnchipFPU) == 7)) {
4726: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4727: }
4728:
4729:
4730: currentModel = specifiedModel;
4731: currentAccelerator = specifiedAccelerator;
4732:
4733: currentIsSecond = specifiedIsSecond;
4734: currentFirstMPU = specifiedFirstMPU;
4735: currentSecondMPU = specifiedSecondMPU;
4736: currentMPU = specifiedMPU;
4737:
4738:
4739: currentCopro0 = specifiedCopro0;
4740: currentCopro1 = specifiedCopro1;
4741: currentCopro2 = specifiedCopro2;
4742: currentOnchipFPU = specifiedOnchipFPU;
4743:
4744:
4745: mpuUtilOn = Settings.sgsGetOnOff ("util");
4746: mpuUtilRatio = fmtParseInt (Settings.sgsGetString ("ratio"), 0, 1, 100, 100);
4747:
4748: mpuArbFreqMHz = fmtParseInt (Settings.sgsGetString ("mhz"), 0, 1, 1000, 100);
4749: if (mpuUtilOn) {
4750: mpuArbFreqOn = false;
4751: } else {
4752: mpuArbFreqOn = !(specifiedClock == 10.0 ||
4753: specifiedClock == 50.0 / 3.0 ||
4754: specifiedClock == 25.0 ||
4755: specifiedClock == 100.0 / 3.0 ||
4756: specifiedClock == 50.0 ||
4757: specifiedClock == 200.0 / 3.0 ||
4758: specifiedClock == 75.0 ||
4759: specifiedClock == 100.0);
4760: if (mpuArbFreqOn) {
4761: mpuArbFreqMHz = (int) specifiedClock;
4762: }
4763: }
4764:
4765:
4766: mpuROMWaitCycles = 0;
4767: mpuRAMWaitCycles = 0;
4768: mpuCacheOn = false;
4769:
4770: mpuNoWaitTime.ram = 0;
4771: mpuNoWaitTime.gvram = 0;
4772: mpuNoWaitTime.tvram = 0;
4773: mpuNoWaitTime.crtc = 0;
4774: mpuNoWaitTime.palet = 0;
4775: mpuNoWaitTime.vicon = 0;
4776: mpuNoWaitTime.dmac = 0;
4777: mpuNoWaitTime.mfp = 0;
4778: mpuNoWaitTime.rtc = 0;
4779: mpuNoWaitTime.prnport = 0;
4780: mpuNoWaitTime.sysport = 0;
4781: mpuNoWaitTime.opm = 0;
4782: mpuNoWaitTime.adpcm = 0;
4783: mpuNoWaitTime.fdc = 0;
4784: mpuNoWaitTime.fdd = 0;
4785: mpuNoWaitTime.hdc = 0;
4786: mpuNoWaitTime.scc = 0;
4787: mpuNoWaitTime.ppi = 0;
4788: mpuNoWaitTime.ioi = 0;
4789: mpuNoWaitTime.sprc = 0;
4790: mpuNoWaitTime.sram = 0;
4791: mpuNoWaitTime.rom = 0;
4792: mpuNoWaitTime.ramlong = mpuNoWaitTime.ram << 1;
4793: mpuNoWaitTime.romlong = mpuNoWaitTime.rom << 1;
4794:
4795: dmaNoWaitTime.ram = 0;
4796: dmaNoWaitTime.gvram = 0;
4797: dmaNoWaitTime.tvram = 0;
4798: dmaNoWaitTime.crtc = 0;
4799: dmaNoWaitTime.palet = 0;
4800: dmaNoWaitTime.vicon = 0;
4801: dmaNoWaitTime.dmac = 0;
4802: dmaNoWaitTime.mfp = 0;
4803: dmaNoWaitTime.rtc = 0;
4804: dmaNoWaitTime.prnport = 0;
4805: dmaNoWaitTime.sysport = 0;
4806: dmaNoWaitTime.opm = 0;
4807: dmaNoWaitTime.adpcm = 0;
4808: dmaNoWaitTime.fdc = 0;
4809: dmaNoWaitTime.fdd = 0;
4810: dmaNoWaitTime.hdc = 0;
4811: dmaNoWaitTime.scc = 0;
4812: dmaNoWaitTime.ppi = 0;
4813: dmaNoWaitTime.ioi = 0;
4814: dmaNoWaitTime.sprc = 0;
4815: dmaNoWaitTime.sram = 0;
4816: dmaNoWaitTime.rom = 0;
4817: dmaNoWaitTime.ramlong = dmaNoWaitTime.ram << 1;
4818: dmaNoWaitTime.romlong = dmaNoWaitTime.rom << 1;
4819:
4820:
4821: busWaitCyclesRequest = Settings.sgsGetOnOff ("waitcycles");
4822: busWaitCycles = busWaitCyclesRequest;
4823: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
4824:
4825: }
4826:
4827: public static void mdlTini () {
4828:
4829: Settings.sgsPutString ("model",
4830: specifiedAccelerator == ACCELERATOR_HYBRID ? "Hybrid" :
4831: specifiedAccelerator == ACCELERATOR_XELLENT30 ? "Xellent30" :
4832: specifiedAccelerator == ACCELERATOR_060TURBO ? "060turbo" :
4833: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? "060turboPRO" :
4834: specifiedModel.getSynonym () != null ? specifiedModel.getSynonym () :
4835: specifiedModel.getType ());
4836: Settings.sgsPutOnOff ("mpu010", mpu010);
4837:
4838:
4839: int defaultFirstMPU = (specifiedAccelerator == ACCELERATOR_060TURBO ||
4840: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4841: specifiedModel.getMPU ());
4842: int defaultSecondMPU = Model.MPU_MC68EC030;
4843: Settings.sgsPutString ("mpu",
4844: (specifiedFirstMPU == defaultFirstMPU ? "" :
4845: Model.mpuNameOf (specifiedFirstMPU)) +
4846: (specifiedSecondMPU == defaultSecondMPU ? "" :
4847: "," + Model.mpuNameOf (specifiedSecondMPU)));
4848:
4849:
4850:
4851:
4852: double defaultFirstClock = (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4853: specifiedAccelerator == ACCELERATOR_060TURBO ||
4854: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4855: specifiedModel.getClock ());
4856: double defaultSecondClock = defaultFirstClock * 2.0;
4857: Settings.sgsPutString ("clock",
4858: (specifiedFirstClock == defaultFirstClock ? "" :
4859: specifiedFirstClock == 50.0 / 3.0 ? "16.7" :
4860: specifiedFirstClock == 100.0 / 3.0 ? "33.3" :
4861: specifiedFirstClock == 200.0 / 3.0 ? "66.7" :
4862: String.valueOf ((int) specifiedFirstClock)) +
4863: (specifiedSecondClock == defaultSecondClock ? "" :
4864: "," + (specifiedSecondClock == 50.0 / 3.0 ? "16.7" :
4865: specifiedSecondClock == 100.0 / 3.0 ? "33.3" :
4866: specifiedSecondClock == 200.0 / 3.0 ? "66.7" :
4867: String.valueOf ((int) specifiedSecondClock))));
4868:
4869: Settings.sgsPutInt ("copro0", specifiedCopro0);
4870: Settings.sgsPutInt ("copro1", specifiedCopro1);
4871: Settings.sgsPutInt ("copro2", specifiedCopro2);
4872: Settings.sgsPutInt ("onchipfpu", specifiedOnchipFPU);
4873:
4874: Settings.sgsPutOnOff ("util",
4875: mpuUtilOn);
4876: Settings.sgsPutString ("ratio",
4877: String.valueOf (mpuUtilRatio));
4878:
4879: Settings.sgsPutString ("mhz",
4880: String.valueOf (mpuArbFreqMHz));
4881:
4882: Settings.sgsPutOnOff ("waitcycles", busWaitCyclesRequest);
4883: }
4884:
4885: public static void mdlMakeMenu () {
4886:
4887:
4888: ActionListener listener = new ActionListener () {
4889: @Override public void actionPerformed (ActionEvent ae) {
4890: Object source = ae.getSource ();
4891: switch (ae.getActionCommand ()) {
4892: case "X68000 (10MHz)":
4893: mdlRequestModel (Model.SHODAI, 0);
4894: mpuReset (-1, -1);
4895: break;
4896: case "X68000 ACE (10MHz)":
4897: mdlRequestModel (Model.ACE, 0);
4898: mpuReset (-1, -1);
4899: break;
4900: case "X68000 EXPERT (10MHz)":
4901: mdlRequestModel (Model.EXPERT, 0);
4902: mpuReset (-1, -1);
4903: break;
4904: case "X68000 PRO (10MHz)":
4905: mdlRequestModel (Model.PRO, 0);
4906: mpuReset (-1, -1);
4907: break;
4908: case "X68000 SUPER (10MHz)":
4909: mdlRequestModel (Model.SUPER, 0);
4910: mpuReset (-1, -1);
4911: break;
4912: case "X68000 XVI (16.7MHz)":
4913: mdlRequestModel (Model.XVI, 0);
4914: mpuReset (-1, -1);
4915: break;
4916: case "X68000 Compact (16.7MHz)":
4917: mdlRequestModel (Model.COMPACT, 0);
4918: mpuReset (-1, -1);
4919: break;
4920:
4921: case "X68030 (25MHz)":
4922: mdlRequestModel (Model.X68030, 0);
4923: mpuReset (-1, -1);
4924: break;
4925: case "X68030 Compact (25MHz)":
4926: mdlRequestModel (Model.X68030COMPACT, 0);
4927: mpuReset (-1, -1);
4928: break;
4929:
4930: case "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)":
4931: mdlRequestModel (Model.COMPACT, ACCELERATOR_HYBRID);
4932: mpuReset (-1, -1);
4933: break;
4934: case "Xellent30 (33.3MHz)":
4935: mdlRequestModel (Model.XVI, ACCELERATOR_XELLENT30);
4936: mpuReset (-1, -1);
4937: break;
4938: case "060turbo (" + MHZ_060TURBO_STRING + "MHz)":
4939: mdlRequestModel (Model.X68030, ACCELERATOR_060TURBO);
4940: mpuReset (-1, -1);
4941: break;
4942: case "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)":
4943: mdlRequestModel (Model.PRO, ACCELERATOR_060TURBOPRO);
4944: mpuReset (-1, -1);
4945: break;
4946:
4947: case "MC68010":
4948: mpu010 = ((JCheckBoxMenuItem) source).isSelected ();
4949: break;
4950:
4951: }
4952: }
4953: };
4954:
4955:
4956: ButtonGroup modelGroup = new ButtonGroup ();
4957: mdlMenu = Multilingual.mlnText (
4958: ComponentFactory.createMenu (
4959: "Change the model and reset",
4960: mdlShodaiMenuItem = ComponentFactory.createRadioButtonMenuItem (
4961: modelGroup,
4962: specifiedModel == Model.SHODAI,
4963: "X68000 (10MHz)",
4964: listener),
4965: mdlACEMenuItem = ComponentFactory.createRadioButtonMenuItem (
4966: modelGroup,
4967: specifiedModel == Model.ACE,
4968: "X68000 ACE (10MHz)",
4969: listener),
4970: mdlEXPERTMenuItem = ComponentFactory.createRadioButtonMenuItem (
4971: modelGroup,
4972: specifiedModel == Model.EXPERT,
4973: "X68000 EXPERT (10MHz)",
4974: listener),
4975: mdlPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
4976: modelGroup,
4977: specifiedModel == Model.PRO && specifiedAccelerator == 0,
4978: "X68000 PRO (10MHz)",
4979: listener),
4980: mdlSUPERMenuItem = ComponentFactory.createRadioButtonMenuItem (
4981: modelGroup,
4982: specifiedModel == Model.SUPER,
4983: "X68000 SUPER (10MHz)",
4984: listener),
4985: mdlXVIMenuItem = ComponentFactory.createRadioButtonMenuItem (
4986: modelGroup,
4987: specifiedModel == Model.XVI && specifiedAccelerator == 0,
4988: "X68000 XVI (16.7MHz)",
4989: listener),
4990: mdlCompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
4991: modelGroup,
4992: specifiedModel == Model.COMPACT && specifiedAccelerator == 0,
4993: "X68000 Compact (16.7MHz)",
4994: listener),
4995:
4996: ComponentFactory.createHorizontalSeparator (),
4997:
4998: mdlX68030MenuItem = ComponentFactory.createRadioButtonMenuItem (
4999: modelGroup,
5000: specifiedModel == Model.X68030 && specifiedAccelerator == 0,
5001: "X68030 (25MHz)",
5002: listener),
5003: mdl030CompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
5004: modelGroup,
5005: specifiedModel == Model.X68030COMPACT,
5006: "X68030 Compact (25MHz)",
5007: listener),
5008:
5009: ComponentFactory.createHorizontalSeparator (),
5010:
5011: mdlHybridMenuItem = ComponentFactory.createRadioButtonMenuItem (
5012: modelGroup,
5013: specifiedModel == Model.COMPACT && specifiedAccelerator == ACCELERATOR_HYBRID,
5014: "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)",
5015: listener),
5016: mdlXellent30MenuItem = ComponentFactory.createRadioButtonMenuItem (
5017: modelGroup,
5018: specifiedModel == Model.XVI && specifiedAccelerator == ACCELERATOR_XELLENT30,
5019: "Xellent30 (33.3MHz)",
5020: listener),
5021: mdl060turboMenuItem = ComponentFactory.createRadioButtonMenuItem (
5022: modelGroup,
5023: specifiedModel == Model.X68030 && specifiedAccelerator == ACCELERATOR_060TURBO,
5024: "060turbo (" + MHZ_060TURBO_STRING + "MHz)",
5025: listener),
5026: mdl060turboPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
5027: modelGroup,
5028: specifiedModel == Model.PRO && specifiedAccelerator == ACCELERATOR_060TURBOPRO,
5029: "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)",
5030: listener),
5031:
5032: ComponentFactory.createHorizontalSeparator (),
5033:
5034: mdlMC68010MenuItem = ComponentFactory.createCheckBoxMenuItem (
5035: mpu010,
5036: "MC68010",
5037: listener)
5038: ),
5039: "ja", "機種を変更してリセット");
5040:
5041:
5042: ActionListener copro0Listener = new ActionListener () {
5043: @Override public void actionPerformed (ActionEvent ae) {
5044: String command = ae.getActionCommand ();
5045: switch (command) {
5046: case "Not installed":
5047: specifiedCopro0 = (8 & specifiedCopro0) | 0;
5048: break;
5049: case "MC68881":
5050: specifiedCopro0 = (8 & specifiedCopro0) | 1;
5051: break;
5052: case "MC68882":
5053: specifiedCopro0 = (8 & specifiedCopro0) | 2;
5054: break;
5055: case "Full specification":
5056: specifiedCopro0 = (8 & specifiedCopro0) | 7;
5057: break;
5058: case "Extended precision (19 digits)":
5059: specifiedCopro0 = 0 | (7 & specifiedCopro0);
5060: break;
5061: case "Triple precision (24 digits)":
5062: specifiedCopro0 = 8 | (7 & specifiedCopro0);
5063: break;
5064: default:
5065: System.out.println ("unknown action command " + command);
5066: }
5067: }
5068: };
5069:
5070: ActionListener copro1Listener = new ActionListener () {
5071: @Override public void actionPerformed (ActionEvent ae) {
5072: String command = ae.getActionCommand ();
5073: switch (command) {
5074: case "Not installed":
5075: specifiedCopro1 = (8 & specifiedCopro1) | 0;
5076: break;
5077: case "MC68881":
5078: specifiedCopro1 = (8 & specifiedCopro1) | 1;
5079: break;
5080: case "MC68882":
5081: specifiedCopro1 = (8 & specifiedCopro1) | 2;
5082: break;
5083: case "Full specification":
5084: specifiedCopro1 = (8 & specifiedCopro1) | 7;
5085: break;
5086: case "Extended precision (19 digits)":
5087: specifiedCopro1 = 0 | (7 & specifiedCopro1);
5088: break;
5089: case "Triple precision (24 digits)":
5090: specifiedCopro1 = 8 | (7 & specifiedCopro1);
5091: break;
5092: default:
5093: System.out.println ("unknown action command " + command);
5094: }
5095: }
5096: };
5097:
5098: ActionListener copro2Listener = new ActionListener () {
5099: @Override public void actionPerformed (ActionEvent ae) {
5100: String command = ae.getActionCommand ();
5101: switch (command) {
5102: case "Not installed":
5103: specifiedCopro2 = (8 & specifiedCopro2) | 0;
5104: break;
5105: case "MC68881":
5106: specifiedCopro2 = (8 & specifiedCopro2) | 1;
5107: break;
5108: case "MC68882":
5109: specifiedCopro2 = (8 & specifiedCopro2) | 2;
5110: break;
5111: case "Full specification":
5112: specifiedCopro2 = (8 & specifiedCopro2) | 7;
5113: break;
5114: case "Extended precision (19 digits)":
5115: specifiedCopro2 = 0 | (7 & specifiedCopro2);
5116: break;
5117: case "Triple precision (24 digits)":
5118: specifiedCopro2 = 8 | (7 & specifiedCopro2);
5119: break;
5120: default:
5121: System.out.println ("unknown action command " + command);
5122: }
5123: }
5124: };
5125:
5126: ActionListener onchipFPUListener = new ActionListener () {
5127: @Override public void actionPerformed (ActionEvent ae) {
5128: String command = ae.getActionCommand ();
5129: switch (command) {
5130: case "Not installed":
5131: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 0;
5132: break;
5133: case "MC68060":
5134: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 6;
5135: break;
5136: case "Full specification":
5137: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
5138: break;
5139: case "Extended precision (19 digits)":
5140: specifiedOnchipFPU = 0 | (7 & specifiedOnchipFPU);
5141: break;
5142: case "Triple precision (24 digits)":
5143: specifiedOnchipFPU = 8 | (7 & specifiedOnchipFPU);
5144: break;
5145: default:
5146: System.out.println ("unknown action command " + command);
5147: }
5148: }
5149: };
5150:
5151: ButtonGroup copro00Group = new ButtonGroup ();
5152: ButtonGroup copro01Group = new ButtonGroup ();
5153: ButtonGroup copro10Group = new ButtonGroup ();
5154: ButtonGroup copro11Group = new ButtonGroup ();
5155: ButtonGroup copro20Group = new ButtonGroup ();
5156: ButtonGroup copro21Group = new ButtonGroup ();
5157: ButtonGroup onchipFPU0Group = new ButtonGroup ();
5158: ButtonGroup onchipFPU1Group = new ButtonGroup ();
5159:
5160: coproFPUMenu = Multilingual.mlnText (
5161: ComponentFactory.createMenu (
5162: "Coprocessor and on-chip FPU",
5163:
5164: Multilingual.mlnText (
5165: ComponentFactory.createMenu (
5166: "Motherboard coprocessor",
5167: Multilingual.mlnText (
5168: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 0, "Not installed", copro0Listener),
5169: "ja", "なし"),
5170: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 1, "MC68881", copro0Listener),
5171: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 2, "MC68882", copro0Listener),
5172: Multilingual.mlnText (
5173: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 7, "Full specification", copro0Listener),
5174: "ja", "フルスペック"),
5175: ComponentFactory.createHorizontalSeparator (),
5176: Multilingual.mlnText (
5177: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) == 0, "Extended precision (19 digits)", copro0Listener),
5178: "ja", "拡張精度 (19 桁)"),
5179: Multilingual.mlnText (
5180: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) != 0, "Triple precision (24 digits)", copro0Listener),
5181: "ja", "三倍精度 (24 桁)")),
5182: "ja", "マザーボードコプロセッサ"),
5183:
5184: Multilingual.mlnText (
5185: ComponentFactory.createMenu (
5186: "Extension coprocessor #1",
5187: Multilingual.mlnText (
5188: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 0, "Not installed", copro1Listener),
5189: "ja", "なし"),
5190: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 1, "MC68881", copro1Listener),
5191: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 2, "MC68882", copro1Listener),
5192: Multilingual.mlnText (
5193: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 7, "Full specification", copro1Listener),
5194: "ja", "フルスペック"),
5195: ComponentFactory.createHorizontalSeparator (),
5196: Multilingual.mlnText (
5197: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) == 0, "Extended precision (19 digits)", copro1Listener),
5198: "ja", "拡張精度 (19 桁)"),
5199: Multilingual.mlnText (
5200: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) != 0, "Triple precision (24 digits)", copro1Listener),
5201: "ja", "三倍精度 (24 桁)")),
5202: "ja", "拡張コプロセッサ #1"),
5203:
5204: Multilingual.mlnText (
5205: ComponentFactory.createMenu (
5206: "Extension coprocessor #2",
5207: Multilingual.mlnText (
5208: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 0, "Not installed", copro2Listener),
5209: "ja", "なし"),
5210: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 1, "MC68881", copro2Listener),
5211: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 2, "MC68882", copro2Listener),
5212: Multilingual.mlnText (
5213: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 7, "Full specification", copro2Listener),
5214: "ja", "フルスペック"),
5215: ComponentFactory.createHorizontalSeparator (),
5216: Multilingual.mlnText (
5217: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) == 0, "Extended precision (19 digits)", copro2Listener),
5218: "ja", "拡張精度 (19 桁)"),
5219: Multilingual.mlnText (
5220: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) != 0, "Triple precision (24 digits)", copro2Listener),
5221: "ja", "三倍精度 (24 桁)")),
5222: "ja", "拡張コプロセッサ #2"),
5223:
5224: Multilingual.mlnText (
5225: ComponentFactory.createMenu (
5226: "On-chip FPU",
5227: Multilingual.mlnText (
5228: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 0, "Not installed", onchipFPUListener),
5229: "ja", "なし"),
5230: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 6, "MC68060", onchipFPUListener),
5231: Multilingual.mlnText (
5232: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 7, "Full specification", onchipFPUListener),
5233: "ja", "フルスペック"),
5234: ComponentFactory.createHorizontalSeparator (),
5235: Multilingual.mlnText (
5236: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) == 0, "Extended precision (19 digits)", onchipFPUListener),
5237: "ja", "拡張精度 (19 桁)"),
5238: Multilingual.mlnText (
5239: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) != 0, "Triple precision (24 digits)", onchipFPUListener),
5240: "ja", "三倍精度 (24 桁)")),
5241: "ja", "オンチップ FPU")),
5242: "ja", "コプロセッサとオンチップ FPU");
5243:
5244: }
5245:
5246: public static void mdlRequestModel (Model model, int accelerator) {
5247: specifiedModel = model;
5248: specifiedAccelerator = accelerator;
5249:
5250: specifiedIsSecond = false;
5251: specifiedFirstMPU = specifiedModel.getMPU ();
5252: specifiedSecondMPU = Model.MPU_MC68EC030;
5253: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
5254: specifiedFirstClock = specifiedModel.getClock ();
5255: specifiedSecondClock = specifiedFirstClock * 2.0;
5256: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5257:
5258: switch (accelerator) {
5259: case ACCELERATOR_HYBRID:
5260: specifiedFirstClock = MHZ_HYBRID_VALUE;
5261: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5262: break;
5263: case ACCELERATOR_XELLENT30:
5264: break;
5265: case ACCELERATOR_060TURBO:
5266: case ACCELERATOR_060TURBOPRO:
5267: specifiedFirstMPU = Model.MPU_MC68060;
5268: specifiedFirstClock = MHZ_060TURBO_VALUE;
5269: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5270: }
5271:
5272: mpuUtilOn = false;
5273: mpuArbFreqOn = false;
5274: mpuSetCurrentClock (specifiedClock);
5275:
5276: if (accelerator == ACCELERATOR_HYBRID) {
5277: mdlHybridMenuItem.setSelected (true);
5278: } else if (accelerator == ACCELERATOR_XELLENT30) {
5279: mdlXellent30MenuItem.setSelected (true);
5280: } else if (accelerator == ACCELERATOR_060TURBO) {
5281: mdl060turboMenuItem.setSelected (true);
5282: } else if (accelerator == ACCELERATOR_060TURBOPRO) {
5283: mdl060turboPROMenuItem.setSelected (true);
5284: } else if (specifiedModel == Model.SHODAI) {
5285: mdlShodaiMenuItem.setSelected (true);
5286: } else if (specifiedModel == Model.ACE) {
5287: mdlACEMenuItem.setSelected (true);
5288: } else if (specifiedModel == Model.EXPERT) {
5289: mdlEXPERTMenuItem.setSelected (true);
5290: } else if (specifiedModel == Model.PRO) {
5291: mdlPROMenuItem.setSelected (true);
5292: } else if (specifiedModel == Model.SUPER) {
5293: mdlSUPERMenuItem.setSelected (true);
5294: } else if (specifiedModel == Model.XVI) {
5295: mdlXVIMenuItem.setSelected (true);
5296: } else if (specifiedModel == Model.COMPACT) {
5297: mdlCompactMenuItem.setSelected (true);
5298: } else if (specifiedModel == Model.X68030) {
5299: mdlX68030MenuItem.setSelected (true);
5300: } else if (specifiedModel == Model.X68030COMPACT) {
5301: mdl030CompactMenuItem.setSelected (true);
5302: }
5303:
5304:
5305: HDC.hdcSASIMenuItem.setSelected (!currentModel.isSCSI ());
5306: SPC.spcSCSIINMenuItem.setSelected (currentModel.isSCSI ());
5307: }
5308:
5309:
5310:
5311:
5312:
5313:
5314:
5315: public static final boolean MPU_INLINE_EXCEPTION = true;
5316: public static final boolean MPU_COMPOUND_POSTINCREMENT = false;
5317:
5318: public static final boolean MPU_SWITCH_MISC_OPCODE = false;
5319: public static final boolean MPU_SWITCH_BCC_CONDITION = false;
5320: public static final boolean MPU_SWITCH_BCC_OFFSET = false;
5321: public static final boolean MPU_SWITCH_SCC_CONDITION = true;
5322:
5323: public static final boolean MPU_OMIT_EXTRA_READ = false;
5324: public static final boolean MPU_OMIT_OFFSET_READ = false;
5325:
5326:
5327:
5328:
5329: public static final long FAR_FUTURE = 0x7fffffffffffffffL;
5330:
5331:
5332:
5333:
5334:
5335:
5336:
5337:
5338: public static final int REG_SR_T1 = 0b10000000_00000000;
5339: public static final int REG_SR_T0 = 0b01000000_00000000;
5340:
5341:
5342:
5343:
5344:
5345:
5346: public static final int REG_SR_S = 0b00100000_00000000;
5347: public static final int REG_SR_M = 0b00010000_00000000;
5348:
5349: public static final int REG_SR_I = 0b00000111_00000000;
5350:
5351:
5352: public static final int REG_CCR_X = 0b00000000_00010000;
5353: public static final int REG_CCR_N = 0b00000000_00001000;
5354: public static final int REG_CCR_Z = 0b00000000_00000100;
5355: public static final int REG_CCR_V = 0b00000000_00000010;
5356: public static final int REG_CCR_C = 0b00000000_00000001;
5357: public static final int REG_CCR_MASK = REG_CCR_X | REG_CCR_N | REG_CCR_Z | REG_CCR_V | REG_CCR_C;
5358:
5359: public static char[] REG_CCRXMAP = "00000000000000001111111111111111".toCharArray ();
5360: public static char[] REG_CCRNMAP = "00000000111111110000000011111111".toCharArray ();
5361: public static char[] REG_CCRZMAP = "00001111000011110000111100001111".toCharArray ();
5362: public static char[] REG_CCRVMAP = "00110011001100110011001100110011".toCharArray ();
5363: public static char[] REG_CCRCMAP = "01010101010101010101010101010101".toCharArray ();
5364:
5365:
5366:
5367: public static final int MPU_IOI_INTERRUPT_LEVEL = 1;
5368: public static final int MPU_EB2_INTERRUPT_LEVEL = 2;
5369: public static final int MPU_DMA_INTERRUPT_LEVEL = 3;
5370: public static final int MPU_SCC_INTERRUPT_LEVEL = 5;
5371: public static final int MPU_MFP_INTERRUPT_LEVEL = 6;
5372: public static final int MPU_SYS_INTERRUPT_LEVEL = 7;
5373: public static final int MPU_IOI_INTERRUPT_MASK = 0x80 >> MPU_IOI_INTERRUPT_LEVEL;
5374: public static final int MPU_EB2_INTERRUPT_MASK = 0x80 >> MPU_EB2_INTERRUPT_LEVEL;
5375: public static final int MPU_DMA_INTERRUPT_MASK = 0x80 >> MPU_DMA_INTERRUPT_LEVEL;
5376: public static final int MPU_SCC_INTERRUPT_MASK = 0x80 >> MPU_SCC_INTERRUPT_LEVEL;
5377: public static final int MPU_MFP_INTERRUPT_MASK = 0x80 >> MPU_MFP_INTERRUPT_LEVEL;
5378: public static final int MPU_SYS_INTERRUPT_MASK = 0x80 >> MPU_SYS_INTERRUPT_LEVEL;
5379:
5380: public static final boolean MPU_INTERRUPT_SWITCH = true;
5381:
5382:
5383: public static final boolean T = true;
5384: public static final boolean F = false;
5385:
5386: public static final int CCCC_T = 0b0000;
5387: public static final int CCCC_F = 0b0001;
5388: public static final int CCCC_HI = 0b0010;
5389: public static final int CCCC_LS = 0b0011;
5390: public static final int CCCC_CC = 0b0100;
5391: public static final int CCCC_CS = 0b0101;
5392: public static final int CCCC_NE = 0b0110;
5393: public static final int CCCC_EQ = 0b0111;
5394: public static final int CCCC_VC = 0b1000;
5395: public static final int CCCC_VS = 0b1001;
5396: public static final int CCCC_PL = 0b1010;
5397: public static final int CCCC_MI = 0b1011;
5398: public static final int CCCC_GE = 0b1100;
5399: public static final int CCCC_LT = 0b1101;
5400: public static final int CCCC_GT = 0b1110;
5401: public static final int CCCC_LE = 0b1111;
5402:
5403:
5404:
5405:
5406:
5407:
5408: public static final boolean[] BCCMAP = {
5409: 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,
5410: 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,
5411: 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,
5412: 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,
5413: 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,
5414: 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,
5415: 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,
5416: 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,
5417: 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,
5418: 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,
5419: 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,
5420: 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,
5421: 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,
5422: 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,
5423: 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,
5424: 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,
5425: };
5426:
5427:
5428: public static final char[] MPU_CCCMAP = (
5429: "11111111111111111111111111111111" +
5430: "00000000000000000000000000000000" +
5431: "10100000101000001010000010100000" +
5432: "01011111010111110101111101011111" +
5433: "10101010101010101010101010101010" +
5434: "01010101010101010101010101010101" +
5435: "11110000111100001111000011110000" +
5436: "00001111000011110000111100001111" +
5437: "11001100110011001100110011001100" +
5438: "00110011001100110011001100110011" +
5439: "11111111000000001111111100000000" +
5440: "00000000111111110000000011111111" +
5441: "11001100001100111100110000110011" +
5442: "00110011110011000011001111001100" +
5443: "11000000001100001100000000110000" +
5444: "00111111110011110011111111001111").toCharArray ();
5445:
5446:
5447:
5448: public static final int MPU_CC_T = 0b11111111111111111111111111111111;
5449: public static final int MPU_CC_F = 0b00000000000000000000000000000000;
5450: public static final int MPU_CC_HI = 0b10100000101000001010000010100000;
5451: public static final int MPU_CC_LS = 0b01011111010111110101111101011111;
5452: public static final int MPU_CC_HS = 0b10101010101010101010101010101010;
5453: public static final int MPU_CC_LO = 0b01010101010101010101010101010101;
5454: public static final int MPU_CC_NE = 0b11110000111100001111000011110000;
5455: public static final int MPU_CC_EQ = 0b00001111000011110000111100001111;
5456: public static final int MPU_CC_VC = 0b11001100110011001100110011001100;
5457: public static final int MPU_CC_VS = 0b00110011001100110011001100110011;
5458: public static final int MPU_CC_PL = 0b11111111000000001111111100000000;
5459: public static final int MPU_CC_MI = 0b00000000111111110000000011111111;
5460: public static final int MPU_CC_GE = 0b11001100001100111100110000110011;
5461: public static final int MPU_CC_LT = 0b00110011110011000011001111001100;
5462: public static final int MPU_CC_GT = 0b11000000001100001100000000110000;
5463: public static final int MPU_CC_LE = 0b00111111110011110011111111001111;
5464:
5465:
5466:
5467:
5468:
5469:
5470:
5471:
5472:
5473:
5474:
5475:
5476:
5477:
5478:
5479:
5480:
5481:
5482:
5483:
5484:
5485:
5486:
5487:
5488:
5489:
5490:
5491:
5492:
5493:
5494:
5495:
5496:
5497:
5498:
5499:
5500:
5501:
5502:
5503:
5504:
5505:
5506:
5507:
5508:
5509:
5510:
5511:
5512:
5513: 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);
5514:
5515:
5516:
5517: public static final int[] MPU_BITREV_TABLE_0 = new int[2048];
5518: public static final int[] MPU_BITREV_TABLE_1 = new int[2048];
5519: public static final int[] MPU_BITREV_TABLE_2 = new int[2048];
5520: static {
5521: for (int i = 0; i < 2048; i++) {
5522: MPU_BITREV_TABLE_2[i] = (MPU_BITREV_TABLE_1[i] = (MPU_BITREV_TABLE_0[i] = Integer.reverse (i)) >>> 11) >>> 11;
5523: }
5524: }
5525:
5526:
5527:
5528: public static final int EA_DR = 0b000_000;
5529: public static final int EA_AR = 0b001_000;
5530: public static final int EA_MM = 0b010_000;
5531: public static final int EA_MP = 0b011_000;
5532: public static final int EA_MN = 0b100_000;
5533: public static final int EA_MW = 0b101_000;
5534: public static final int EA_MX = 0b110_000;
5535: public static final int EA_ZW = 0b111_000;
5536: public static final int EA_ZL = 0b111_001;
5537: public static final int EA_PW = 0b111_010;
5538: public static final int EA_PX = 0b111_011;
5539: public static final int EA_IM = 0b111_100;
5540: public static final int MMM_DR = EA_DR >> 3;
5541: public static final int MMM_AR = EA_AR >> 3;
5542: public static final int MMM_MM = EA_MM >> 3;
5543: public static final int MMM_MP = EA_MP >> 3;
5544: public static final int MMM_MN = EA_MN >> 3;
5545: public static final int MMM_MW = EA_MW >> 3;
5546: public static final int MMM_MX = EA_MX >> 3;
5547: public static final long EAM_DR = 0xff00000000000000L >>> EA_DR;
5548: public static final long EAM_AR = 0xff00000000000000L >>> EA_AR;
5549: public static final long EAM_MM = 0xff00000000000000L >>> EA_MM;
5550: public static final long EAM_MP = 0xff00000000000000L >>> EA_MP;
5551: public static final long EAM_MN = 0xff00000000000000L >>> EA_MN;
5552: public static final long EAM_MW = 0xff00000000000000L >>> EA_MW;
5553: public static final long EAM_MX = 0xff00000000000000L >>> EA_MX;
5554: public static final long EAM_ZW = 0x8000000000000000L >>> EA_ZW;
5555: public static final long EAM_ZL = 0x8000000000000000L >>> EA_ZL;
5556: public static final long EAM_PW = 0x8000000000000000L >>> EA_PW;
5557: public static final long EAM_PX = 0x8000000000000000L >>> EA_PX;
5558: public static final long EAM_IM = 0x8000000000000000L >>> EA_IM;
5559: 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;
5560: public static final long EAM_ALT = EAM_DR|EAM_AR|EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5561: 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;
5562: 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 ;
5563: public static final long EAM_DLT = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5564: public static final long EAM_DCN = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5565: public static final long EAM_DCL = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5566: 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;
5567: public static final long EAM_MEM = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5568: public static final long EAM_MLT = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5569: public static final long EAM_RDL = EAM_MM|EAM_MP |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5570: public static final long EAM_WTL = EAM_MM |EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5571: public static final long EAM_CNT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5572: public static final long EAM_CLT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5573:
5574:
5575:
5576:
5577:
5578:
5579:
5580:
5581:
5582:
5583:
5584: public static final int[] regRn = new int[16 + 1];
5585:
5586:
5587: public static int regPC;
5588: public static int regPC0;
5589:
5590:
5591: public static int regOC;
5592:
5593:
5594: public static int regSRT1;
5595: public static int regSRT0;
5596: public static int mpuTraceFlag;
5597: public static int regSRS;
5598: public static int regSRM;
5599: public static int regSRI;
5600:
5601:
5602: public static int regCCR;
5603:
5604:
5605:
5606:
5607:
5608:
5609:
5610:
5611:
5612:
5613:
5614:
5615:
5616:
5617:
5618:
5619:
5620:
5621:
5622:
5623: public static int mpuIMR;
5624:
5625:
5626:
5627:
5628:
5629:
5630: public static int mpuIRR;
5631: public static int mpuDIRR;
5632:
5633:
5634:
5635:
5636:
5637:
5638:
5639:
5640: public static int mpuISR;
5641:
5642:
5643: public static int mpuSFC;
5644: public static int mpuDFC;
5645: public static int mpuCACR;
5646:
5647:
5648:
5649:
5650:
5651: public static int mpuBUSCR;
5652: public static int mpuUSP;
5653: public static int mpuVBR;
5654: public static int mpuCAAR;
5655: public static int mpuMSP;
5656: public static int mpuISP;
5657:
5658:
5659:
5660: public static int mpuPCR;
5661:
5662:
5663:
5664: public static final int MPU_060_REV = 7;
5665:
5666:
5667:
5668: public static long mpuClockTime;
5669: public static long mpuClockLimit;
5670: public static double mpuClockMHz;
5671: public static double mpuCurrentMHz;
5672: public static int mpuCycleCount;
5673: public static long mpuCycleUnit;
5674: public static long mpuModifiedUnit;
5675: public static long dmaCycleUnit;
5676:
5677:
5678:
5679: public static TimerTask mpuTask;
5680:
5681:
5682: public static int mpuBootDevice;
5683: public static int mpuROMBootHandle;
5684: public static int mpuSavedBootDevice;
5685: public static int mpuSavedROMBootHandle;
5686:
5687:
5688: public static boolean mpuIgnoreAddressError;
5689:
5690:
5691: public static int mpuROMWaitCycles;
5692: public static int mpuRAMWaitCycles;
5693: public static boolean mpuCacheOn;
5694: public static final class WaitTime {
5695: public long ram;
5696: public long gvram;
5697: public long tvram;
5698: public long crtc;
5699: public long palet;
5700: public long vicon;
5701: public long dmac;
5702: public long mfp;
5703: public long rtc;
5704: public long prnport;
5705: public long sysport;
5706: public long opm;
5707: public long adpcm;
5708: public long fdc;
5709: public long fdd;
5710: public long hdc;
5711: public long scc;
5712: public long ppi;
5713: public long ioi;
5714: public long sprc;
5715: public long sram;
5716: public long rom;
5717: public long ramlong;
5718: public long romlong;
5719: public boolean isDma;
5720: public WaitTime (boolean isDma) {
5721: this.isDma = isDma;
5722: }
5723: }
5724: public static final WaitTime mpuNoWaitTime = new WaitTime (false);
5725: public static final WaitTime dmaNoWaitTime = new WaitTime (true);
5726: public static final WaitTime mpuWaitTime = new WaitTime (false);
5727: public static final WaitTime dmaWaitTime = new WaitTime (true);
5728: public static boolean busWaitCyclesRequest;
5729: public static boolean busWaitCycles;
5730: public static WaitTime busWaitTime;
5731:
5732:
5733: public static boolean mpuArbFreqOn;
5734: public static int mpuArbFreqMHz;
5735: public static SpinnerNumberModel mpuArbFreqModel;
5736: public static JSpinner mpuArbFreqSpinner;
5737: public static JRadioButtonMenuItem mpuArbFreqRadioButtonMenuItem;
5738:
5739:
5740: public static boolean mpuUtilOn;
5741: public static int mpuUtilRatio;
5742: public static SpinnerNumberModel mpuUtilModel;
5743: public static JSpinner mpuUtilSpinner;
5744: public static JRadioButtonMenuItem mpuUtilRadioButtonMenuItem;
5745:
5746:
5747: public static final int MPU_ADJUSTMENT_INTERVAL = 100;
5748: public static int mpuAdjustmentCounter;
5749: public static long mpuTotalNano;
5750: public static long mpuLastNano;
5751: public static double mpuCoreNano1;
5752: public static double mpuCoreNano2;
5753:
5754:
5755: public static JMenu mpuMenu;
5756: public static JMenuItem mpuResetMenuItem;
5757: public static JMenuItem mpuOpt1ResetMenuItem;
5758: public static JRadioButtonMenuItem mpuClock10MenuItem;
5759: public static JRadioButtonMenuItem mpuClock16MenuItem;
5760: public static JRadioButtonMenuItem mpuClock25MenuItem;
5761: public static JRadioButtonMenuItem mpuClock33MenuItem;
5762: public static JRadioButtonMenuItem mpuClock50MenuItem;
5763: public static JRadioButtonMenuItem mpuClock66MenuItem;
5764: public static JRadioButtonMenuItem mpuClock75MenuItem;
5765: public static JRadioButtonMenuItem mpuClock100MenuItem;
5766:
5767:
5768: public static ActionListener mpuDebugActionListener;
5769: public static ArrayList<AbstractButton> mpuButtonsRunning;
5770: public static ArrayList<AbstractButton> mpuButtonsStopped;
5771: public static ArrayList<JCheckBox> mpuOriIllegalCheckBoxList;
5772: public static ArrayList<JCheckBox> mpuStopOnErrorCheckBoxList;
5773: public static ArrayList<JCheckBox> mpuStopAtStartCheckBoxList;
5774:
5775: public static int mpuAdvanceCount;
5776: public static int mpuStepCount;
5777: public static boolean mpuContinue;
5778: public static int mpuUntilReturnSRS;
5779: public static int mpuUntilReturnRP;
5780: public static int mpuUntilReturnPC0;
5781: public static int mpuUntilReturnSP;
5782:
5783:
5784:
5785:
5786:
5787:
5788:
5789:
5790:
5791:
5792:
5793:
5794:
5795:
5796:
5797:
5798:
5799:
5800:
5801:
5802:
5803:
5804:
5805:
5806:
5807:
5808:
5809:
5810:
5811:
5812:
5813:
5814:
5815:
5816:
5817:
5818:
5819:
5820:
5821:
5822:
5823:
5824:
5825:
5826:
5827:
5828:
5829:
5830:
5831:
5832:
5833:
5834:
5835:
5836:
5837:
5838:
5839:
5840:
5841:
5842:
5843:
5844:
5845:
5846:
5847:
5848:
5849:
5850:
5851:
5852:
5853:
5854:
5855: public static final boolean MPU_SXMENU = false;
5856:
5857:
5858:
5859: public static void mpuInit () {
5860:
5861: mpuIgnoreAddressError = false;
5862:
5863:
5864:
5865: fpuInit ();
5866:
5867: mpuClockTime = 0L;
5868: mpuClockLimit = 0L;
5869: mpuCycleCount = 0;
5870:
5871: mpuTask = null;
5872:
5873: M68kException.m6eSignal = new M68kException ();
5874: M68kException.m6eNumber = 0;
5875: M68kException.m6eAddress = 0;
5876: M68kException.m6eDirection = MPU_WR_WRITE;
5877: M68kException.m6eSize = MPU_SS_BYTE;
5878:
5879: mpuBootDevice = -1;
5880: mpuROMBootHandle = -1;
5881: mpuSavedBootDevice = -1;
5882: mpuSavedROMBootHandle = -1;
5883:
5884:
5885:
5886:
5887:
5888:
5889:
5890:
5891:
5892:
5893:
5894:
5895:
5896:
5897:
5898: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
5899: mpuTotalNano = 0L;
5900: mpuLastNano = System.nanoTime ();
5901: mpuCoreNano1 = mpuCoreNano2 = 0.5 * 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
5902:
5903: mpuButtonsRunning = new ArrayList<AbstractButton> ();
5904: mpuButtonsStopped = new ArrayList<AbstractButton> ();
5905:
5906: mpuOriIllegalCheckBoxList = new ArrayList<JCheckBox> ();
5907: mpuStopOnErrorCheckBoxList = new ArrayList<JCheckBox> ();
5908: mpuStopAtStartCheckBoxList = new ArrayList<JCheckBox> ();
5909:
5910: mpuAdvanceCount = 0;
5911: mpuStepCount = 0;
5912: mpuContinue = false;
5913: mpuUntilReturnSRS = 0;
5914: mpuUntilReturnRP = 0;
5915: mpuUntilReturnPC0 = 0;
5916: mpuUntilReturnSP = 0;
5917:
5918:
5919: mpuDebugActionListener = new ActionListener () {
5920: @Override public void actionPerformed (ActionEvent ae) {
5921: Object source = ae.getSource ();
5922: switch (ae.getActionCommand ()) {
5923: case "Stop":
5924: if (RootPointerList.RTL_ON) {
5925: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
5926: RootPointerList.rtlCurrentUserTaskIsStoppable) {
5927: mpuStop (null);
5928: }
5929: } else {
5930: mpuStop (null);
5931: }
5932: break;
5933: case "Trace":
5934: mpuAdvance (1);
5935: break;
5936: case "Trace 10 times":
5937: mpuAdvance (10);
5938: break;
5939: case "Trace 100 times":
5940: mpuAdvance (100);
5941: break;
5942: case "Step":
5943: mpuStep (1);
5944: break;
5945: case "Step 10 times":
5946: mpuStep (10);
5947: break;
5948: case "Step 100 times":
5949: mpuStep (100);
5950: break;
5951: case "Step until return":
5952: mpuStepUntilReturn ();
5953: break;
5954: case "Run":
5955: mpuStart ();
5956: break;
5957:
5958: case "Consider ORI.B #$00,D0 as an illegal instruction" :
5959: if (DBG_ORI_BYTE_ZERO_D0) {
5960: dbgOriByteZeroD0 = ((JCheckBox) source).isSelected ();
5961: for (JCheckBox checkBox : mpuOriIllegalCheckBoxList) {
5962: if (checkBox.isSelected () != dbgOriByteZeroD0) {
5963: checkBox.setSelected (dbgOriByteZeroD0);
5964: }
5965: }
5966: }
5967: break;
5968: case "Stop on error":
5969: dbgStopOnError = ((JCheckBox) source).isSelected ();
5970: for (JCheckBox checkBox : mpuStopOnErrorCheckBoxList) {
5971: if (checkBox.isSelected () != dbgStopOnError) {
5972: checkBox.setSelected (dbgStopOnError);
5973: }
5974: }
5975: break;
5976: case "Stop at execution start position":
5977: dbgStopAtStart = ((JCheckBox) source).isSelected ();
5978: for (JCheckBox checkBox : mpuStopAtStartCheckBoxList) {
5979: if (checkBox.isSelected () != dbgStopAtStart) {
5980: checkBox.setSelected (dbgStopAtStart);
5981: }
5982: }
5983: break;
5984: }
5985: }
5986: };
5987:
5988: }
5989:
5990:
5991:
5992: public static JCheckBox mpuMakeOriIllegalCheckBox () {
5993: JCheckBox checkBox = Multilingual.mlnToolTipText (
5994: ComponentFactory.createIconCheckBox (
5995: DBG_ORI_BYTE_ZERO_D0 ? dbgOriByteZeroD0 : null,
5996: LnF.LNF_ORI_BYTE_ZERO_D0_IMAGE,
5997: LnF.LNF_ORI_BYTE_ZERO_D0_SELECTED_IMAGE,
5998: "Consider ORI.B #$00,D0 as an illegal instruction", mpuDebugActionListener),
5999: "ja", "ORI.B #$00,D0 を不当命令とみなす");
6000: mpuOriIllegalCheckBoxList.add (checkBox);
6001: return checkBox;
6002: }
6003:
6004:
6005:
6006: public static JCheckBox mpuMakeStopOnErrorCheckBox () {
6007: JCheckBox checkBox = Multilingual.mlnToolTipText (
6008: ComponentFactory.createIconCheckBox (
6009: dbgStopOnError,
6010: LnF.LNF_STOP_ON_ERROR_IMAGE,
6011: LnF.LNF_STOP_ON_ERROR_SELECTED_IMAGE,
6012: "Stop on error", mpuDebugActionListener),
6013: "ja", "エラーで停止する");
6014: mpuStopOnErrorCheckBoxList.add (checkBox);
6015: return checkBox;
6016: }
6017:
6018:
6019:
6020: public static JCheckBox mpuMakeStopAtStartCheckBox () {
6021: JCheckBox checkBox = Multilingual.mlnToolTipText (
6022: ComponentFactory.createIconCheckBox (
6023: dbgStopAtStart,
6024: LnF.LNF_STOP_AT_START_IMAGE,
6025: LnF.LNF_STOP_AT_START_SELECTED_IMAGE,
6026: "Stop at execution start position", mpuDebugActionListener),
6027: "ja", "実行開始位置で停止する");
6028: mpuStopAtStartCheckBoxList.add (checkBox);
6029: return checkBox;
6030: }
6031:
6032:
6033: public static void mpuMakeMenu () {
6034:
6035: ButtonGroup unitGroup = new ButtonGroup ();
6036: ActionListener listener = new ActionListener () {
6037: @Override public void actionPerformed (ActionEvent ae) {
6038: Object source = ae.getSource ();
6039: switch (ae.getActionCommand ()) {
6040: case "Reset":
6041: mpuReset (-1, -1);
6042: break;
6043: case "Hold down OPT.1 and reset":
6044: mpuReset (0, -1);
6045: break;
6046: case "Interrupt":
6047: sysInterrupt ();
6048: break;
6049: case "10MHz":
6050: mpuArbFreqOn = false;
6051: mpuUtilOn = false;
6052: mpuSetCurrentClock (10.0);
6053: break;
6054: case "16.7MHz":
6055: mpuArbFreqOn = false;
6056: mpuUtilOn = false;
6057: mpuSetCurrentClock (50.0 / 3.0);
6058: break;
6059: case "25MHz":
6060: mpuArbFreqOn = false;
6061: mpuUtilOn = false;
6062: mpuSetCurrentClock (25.0);
6063: break;
6064: case "33.3MHz":
6065: mpuArbFreqOn = false;
6066: mpuUtilOn = false;
6067: mpuSetCurrentClock (100.0 / 3.0);
6068: break;
6069: case "50MHz":
6070: mpuArbFreqOn = false;
6071: mpuUtilOn = false;
6072: mpuSetCurrentClock (50.0);
6073: break;
6074: case "66.7MHz":
6075: mpuArbFreqOn = false;
6076: mpuUtilOn = false;
6077: mpuSetCurrentClock (200.0 / 3.0);
6078: break;
6079: case "75MHz":
6080: mpuArbFreqOn = false;
6081: mpuUtilOn = false;
6082: mpuSetCurrentClock (75.0);
6083: break;
6084: case "100MHz":
6085: mpuArbFreqOn = false;
6086: mpuUtilOn = false;
6087: mpuSetCurrentClock (100.0);
6088: break;
6089: case "Arbitrary frequency":
6090: mpuArbFreqOn = true;
6091: mpuUtilOn = false;
6092: mpuSetCurrentClock ((double) mpuArbFreqMHz);
6093: break;
6094: case "Arbitrary load factor":
6095: mpuArbFreqOn = false;
6096: mpuUtilOn = true;
6097: break;
6098: case "FE function instruction":
6099: FEFunction.fpkOn = ((JCheckBoxMenuItem) source).isSelected ();
6100: break;
6101: case "Reject FLOATn.X":
6102: FEFunction.fpkRejectFloatOn = ((JCheckBoxMenuItem) source).isSelected ();
6103: break;
6104: case "Cut FC2 pin":
6105: busRequestCutFC2Pin = ((JCheckBoxMenuItem) source).isSelected ();
6106: break;
6107: case "Wait cycles":
6108: busWaitCyclesRequest = ((JCheckBoxMenuItem) source).isSelected ();
6109: break;
6110: case "Use IPLROM 1.6":
6111: ROM.romIPLROM16On = ((JCheckBoxMenuItem) source).isSelected ();
6112: break;
6113: case "Increase IPLROM to 256KB":
6114: ROM.romIPLROM256KOn = ((JCheckBoxMenuItem) source).isSelected ();
6115: break;
6116:
6117: case "Run / Stop":
6118: if (((JCheckBox) source).isSelected ()) {
6119: mpuStart ();
6120: } else {
6121: if (RootPointerList.RTL_ON) {
6122: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6123: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6124: mpuStop (null);
6125: }
6126: } else {
6127: mpuStop (null);
6128: }
6129: }
6130: pnlPanel.requestFocusInWindow ();
6131: break;
6132: }
6133: }
6134: };
6135: mpuMenu = ComponentFactory.createMenu (
6136: "MPU", 'M',
6137: mpuResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset", 'R', MNB_MODIFIERS, listener), "ja", "リセット"),
6138: mpuOpt1ResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Hold down OPT.1 and reset", 'O', MNB_MODIFIERS, listener), "ja", "OPT.1 を押しながらリセット"),
6139: Multilingual.mlnText (ComponentFactory.createMenuItem ("Interrupt", listener), "ja", "インタラプト"),
6140: ComponentFactory.createHorizontalSeparator (),
6141: mdlMenu,
6142: ComponentFactory.createHorizontalSeparator (),
6143: mpuClock10MenuItem = ComponentFactory.createRadioButtonMenuItem (
6144: unitGroup,
6145: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 10.0,
6146: "10MHz",
6147: listener),
6148: mpuClock16MenuItem = ComponentFactory.createRadioButtonMenuItem (
6149: unitGroup,
6150: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0 / 3.0,
6151: "16.7MHz",
6152: listener),
6153: mpuClock25MenuItem = ComponentFactory.createRadioButtonMenuItem (
6154: unitGroup,
6155: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 25.0,
6156: "25MHz",
6157: listener),
6158: mpuClock33MenuItem = ComponentFactory.createRadioButtonMenuItem (
6159: unitGroup,
6160: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0 / 3.0,
6161: "33.3MHz",
6162: listener),
6163: mpuClock50MenuItem = ComponentFactory.createRadioButtonMenuItem (
6164: unitGroup,
6165: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0,
6166: "50MHz",
6167: listener),
6168: mpuClock66MenuItem = ComponentFactory.createRadioButtonMenuItem (
6169: unitGroup,
6170: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 200.0 / 3.0,
6171: "66.7MHz",
6172: listener),
6173: mpuClock75MenuItem = ComponentFactory.createRadioButtonMenuItem (
6174: unitGroup,
6175: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 75.0,
6176: "75MHz",
6177: listener),
6178: mpuClock100MenuItem = ComponentFactory.createRadioButtonMenuItem (
6179: unitGroup,
6180: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0,
6181: "100MHz",
6182: listener),
6183: mpuArbFreqRadioButtonMenuItem = Multilingual.mlnText (
6184: ComponentFactory.createRadioButtonMenuItem (
6185: unitGroup,
6186: mpuArbFreqOn,
6187: "Arbitrary frequency",
6188: listener),
6189: "ja", "任意の周波数"),
6190: ComponentFactory.createHorizontalBox (
6191: Box.createHorizontalStrut (20),
6192: mpuArbFreqSpinner = ComponentFactory.createNumberSpinner (
6193: mpuArbFreqModel = new SpinnerNumberModel (mpuArbFreqMHz, 1, 1000, 1),
6194: 4,
6195: new ChangeListener () {
6196: @Override public void stateChanged (ChangeEvent ce) {
6197:
6198: mpuArbFreqMHz = mpuArbFreqModel.getNumber ().intValue ();
6199: if (mpuArbFreqOn) {
6200: mpuSetCurrentClock ((double) mpuArbFreqMHz);
6201: }
6202: }
6203: }
6204: ),
6205: ComponentFactory.createLabel ("MHz"),
6206: Box.createHorizontalGlue ()
6207: ),
6208: mpuUtilRadioButtonMenuItem = Multilingual.mlnText (
6209: ComponentFactory.createRadioButtonMenuItem (
6210: unitGroup,
6211: mpuUtilOn,
6212: "Arbitrary load factor",
6213: listener),
6214: "ja", "任意の負荷率"),
6215: ComponentFactory.createHorizontalBox (
6216: Box.createHorizontalStrut (20),
6217: mpuUtilSpinner = ComponentFactory.createNumberSpinner (
6218: mpuUtilModel = new SpinnerNumberModel (mpuUtilRatio, 1, 100, 1),
6219: 4,
6220: new ChangeListener () {
6221: @Override public void stateChanged (ChangeEvent ce) {
6222:
6223: mpuUtilRatio = mpuUtilModel.getNumber ().intValue ();
6224: }
6225: }
6226: ),
6227: ComponentFactory.createLabel ("%"),
6228: Box.createHorizontalGlue ()
6229: ),
6230: ComponentFactory.createHorizontalSeparator (),
6231:
6232: coproFPUMenu,
6233:
6234: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkOn, "FE function instruction", listener), "ja", "FE ファンクション命令"),
6235: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkRejectFloatOn, "Reject FLOATn.X", listener), "ja", "FLOATn.X を組み込まない"),
6236: ComponentFactory.createHorizontalSeparator (),
6237: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busRequestCutFC2Pin, "Cut FC2 pin", listener), "ja", "FC2 ピンをカットする"),
6238: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busWaitCyclesRequest, "Wait cycles", listener), "ja", "ウェイトサイクル"),
6239: ComponentFactory.createHorizontalSeparator (),
6240: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM16On, "Use IPLROM 1.6", listener), "ja", "IPLROM 1.6 を使う"),
6241: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM256KOn, "Increase IPLROM to 256KB", listener), "ja", "IPLROM を 256KB に増やす")
6242: );
6243: }
6244:
6245:
6246: public static void mpuSetCurrentClock (double clock) {
6247: specifiedClock = clock;
6248: if (currentIsSecond) {
6249: specifiedSecondClock = clock;
6250: } else {
6251: specifiedFirstClock = clock;
6252: }
6253: if (!mpuArbFreqOn && !mpuUtilOn) {
6254: if (specifiedClock == 10.0) {
6255: mpuClock10MenuItem.setSelected (true);
6256: } else if (specifiedClock == 50.0 / 3.0) {
6257: mpuClock16MenuItem.setSelected (true);
6258: } else if (specifiedClock == 25.0) {
6259: mpuClock25MenuItem.setSelected (true);
6260: } else if (specifiedClock == 100.0 / 3.0) {
6261: mpuClock33MenuItem.setSelected (true);
6262: } else if (specifiedClock == 50.0) {
6263: mpuClock50MenuItem.setSelected (true);
6264: } else if (specifiedClock == 200.0 / 3.0) {
6265: mpuClock66MenuItem.setSelected (true);
6266: } else if (specifiedClock == 75.0) {
6267: mpuClock75MenuItem.setSelected (true);
6268: } else if (specifiedClock == 100.0) {
6269: mpuClock100MenuItem.setSelected (true);
6270: }
6271: }
6272: mpuClockMHz = specifiedClock;
6273: mpuSetClockMHz (mpuClockMHz);
6274: }
6275:
6276:
6277:
6278:
6279:
6280:
6281:
6282:
6283:
6284:
6285:
6286: public static void mpuSetClockMHz (double mhz) {
6287: mhz = Math.max (1.0, Math.min (1000.0, mhz));
6288: double lastMHz = mpuCurrentMHz;
6289: mpuCurrentMHz = mhz;
6290: mpuCycleUnit = (long) (((double) TMR_FREQ / 1000000.0) / mhz + 0.5);
6291:
6292: mpuModifiedUnit = (currentMPU == Model.MPU_MC68EC030 ||
6293: currentMPU == Model.MPU_MC68030 ?
6294: (long) (((double) TMR_FREQ * 3.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6295: currentMPU == Model.MPU_MC68LC040 ||
6296: currentMPU == Model.MPU_MC68040 ?
6297: (long) (((double) TMR_FREQ * 2.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6298: mpuCycleUnit);
6299: if (lastMHz != mhz) {
6300: mpuSetWait ();
6301: }
6302: }
6303:
6304:
6305:
6306:
6307:
6308:
6309:
6310:
6311:
6312:
6313:
6314:
6315:
6316:
6317:
6318:
6319:
6320:
6321:
6322:
6323:
6324:
6325:
6326:
6327:
6328:
6329:
6330:
6331:
6332:
6333:
6334:
6335:
6336:
6337:
6338:
6339:
6340:
6341:
6342:
6343:
6344:
6345:
6346:
6347:
6348:
6349:
6350:
6351:
6352:
6353:
6354:
6355:
6356:
6357:
6358:
6359:
6360:
6361:
6362:
6363:
6364:
6365:
6366:
6367:
6368:
6369:
6370:
6371:
6372:
6373:
6374:
6375:
6376:
6377:
6378:
6379:
6380:
6381:
6382:
6383:
6384: public static void mpuSetWait () {
6385:
6386: if (currentMPU <= Model.MPU_MC68010) {
6387: mpuWaitTime.ram = mpuCycleUnit >> 3;
6388: mpuWaitTime.vicon = (long) (mpuCycleUnit * 0.6);
6389: mpuWaitTime.crtc =
6390: mpuWaitTime.prnport =
6391: mpuWaitTime.sysport =
6392: mpuWaitTime.sprc =
6393: mpuWaitTime.sram =
6394: mpuWaitTime.rom = mpuCycleUnit;
6395: mpuWaitTime.gvram = (long) (mpuCycleUnit * 1.1);
6396: mpuWaitTime.rtc =
6397: mpuWaitTime.opm =
6398: mpuWaitTime.adpcm =
6399: mpuWaitTime.fdc =
6400: mpuWaitTime.fdd =
6401: mpuWaitTime.hdc =
6402: mpuWaitTime.ppi =
6403: mpuWaitTime.ioi = (long) (mpuCycleUnit * 1.7);
6404: mpuWaitTime.tvram = mpuCycleUnit * 2;
6405: mpuWaitTime.palet = (long) (mpuCycleUnit * 2.6);
6406: mpuWaitTime.mfp = (long) (mpuCycleUnit * 4.3);
6407: mpuWaitTime.scc = mpuCycleUnit * 6;
6408: mpuWaitTime.dmac = mpuCycleUnit * 15;
6409: mpuWaitTime.ramlong = mpuWaitTime.ram << 1;
6410: mpuWaitTime.romlong = mpuWaitTime.rom << 1;
6411: } else if (currentMPU <= Model.MPU_MC68030) {
6412: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6413: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6414: mpuWaitTime.sram = mpuCycleUnit * 2;
6415: mpuWaitTime.prnport =
6416: mpuWaitTime.sysport = mpuCycleUnit * 4;
6417: mpuWaitTime.gvram =
6418: mpuWaitTime.crtc =
6419: mpuWaitTime.vicon =
6420: mpuWaitTime.sprc = mpuCycleUnit * 6;
6421: mpuWaitTime.tvram = mpuCycleUnit * 7;
6422: mpuWaitTime.palet = mpuCycleUnit * 11;
6423: mpuWaitTime.opm =
6424: mpuWaitTime.adpcm =
6425: mpuWaitTime.fdc =
6426: mpuWaitTime.fdd =
6427: mpuWaitTime.hdc =
6428: mpuWaitTime.ppi =
6429: mpuWaitTime.ioi = mpuCycleUnit * 15;
6430: mpuWaitTime.mfp = mpuCycleUnit * 19;
6431: mpuWaitTime.rtc = mpuCycleUnit * 28;
6432: mpuWaitTime.dmac = mpuCycleUnit * 34;
6433: mpuWaitTime.scc = mpuCycleUnit * 38;
6434: mpuWaitTime.ramlong = mpuWaitTime.ram;
6435: mpuWaitTime.romlong = mpuWaitTime.rom;
6436: } else {
6437: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6438: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6439: mpuWaitTime.sram = mpuCycleUnit * 13;
6440: mpuWaitTime.prnport =
6441: mpuWaitTime.sysport = mpuCycleUnit * 17;
6442: mpuWaitTime.gvram =
6443: mpuWaitTime.crtc =
6444: mpuWaitTime.vicon =
6445: mpuWaitTime.sprc = mpuCycleUnit * 21;
6446: mpuWaitTime.tvram = mpuCycleUnit * 22;
6447: mpuWaitTime.palet = mpuCycleUnit * 33;
6448: mpuWaitTime.opm =
6449: mpuWaitTime.adpcm =
6450: mpuWaitTime.fdc =
6451: mpuWaitTime.fdd =
6452: mpuWaitTime.hdc =
6453: mpuWaitTime.ppi =
6454: mpuWaitTime.ioi = mpuCycleUnit * 37;
6455: mpuWaitTime.mfp = mpuCycleUnit * 47;
6456: mpuWaitTime.dmac = mpuCycleUnit * 73;
6457: mpuWaitTime.rtc = mpuCycleUnit * 77;
6458: mpuWaitTime.scc = mpuCycleUnit * 97;
6459: mpuWaitTime.ramlong = mpuWaitTime.ram;
6460: mpuWaitTime.romlong = mpuWaitTime.rom;
6461: }
6462: if (true) {
6463:
6464: mpuNoWaitTime.sram = mpuWaitTime.sram;
6465: mpuNoWaitTime.rom = mpuWaitTime.rom;
6466: mpuNoWaitTime.romlong = mpuWaitTime.romlong;
6467: }
6468:
6469: dmaWaitTime.ram = dmaCycleUnit >> 3;
6470: dmaWaitTime.sram = 0;
6471: dmaWaitTime.rom = 0;
6472: dmaWaitTime.gvram =
6473: dmaWaitTime.crtc =
6474: dmaWaitTime.vicon =
6475: dmaWaitTime.prnport =
6476: dmaWaitTime.sysport =
6477: dmaWaitTime.sprc = dmaCycleUnit;
6478: dmaWaitTime.tvram =
6479: dmaWaitTime.rtc =
6480: dmaWaitTime.opm =
6481: dmaWaitTime.adpcm =
6482: dmaWaitTime.fdc =
6483: dmaWaitTime.fdd =
6484: dmaWaitTime.hdc =
6485: dmaWaitTime.ppi =
6486: dmaWaitTime.ioi = dmaCycleUnit * 2;
6487: dmaWaitTime.palet = dmaCycleUnit * 3;
6488: dmaWaitTime.mfp = dmaCycleUnit * 4;
6489: dmaWaitTime.scc = dmaCycleUnit * 6;
6490: dmaWaitTime.dmac = dmaCycleUnit * 15;
6491: dmaWaitTime.ramlong = dmaWaitTime.ram << 1;
6492: dmaWaitTime.romlong = dmaWaitTime.rom << 1;
6493: if (MC68060.CAT_ON) {
6494: if (Model.MPU_MC68LC060 <= currentMPU) {
6495: MC68060.catMainLongTime = mpuCycleUnit * 13;
6496: MC68060.catMainLineTime = mpuCycleUnit * 45;
6497: MC68060.catHighLongTime = mpuCycleUnit * 9;
6498: MC68060.catHighLineTime = mpuCycleUnit * 15;
6499: }
6500: }
6501: }
6502:
6503:
6504:
6505:
6506:
6507: public static void mpuReset (int device, int romHandle) {
6508:
6509: mpuBootDevice = device;
6510: mpuROMBootHandle = romHandle;
6511:
6512:
6513:
6514:
6515:
6516:
6517:
6518:
6519:
6520:
6521:
6522:
6523: if (mpuBootDevice == -1) {
6524: if (mpuSavedBootDevice != -1) {
6525: mpuBootDevice = mpuSavedBootDevice;
6526: mpuROMBootHandle = mpuSavedROMBootHandle;
6527: mpuSavedBootDevice = -1;
6528: mpuSavedROMBootHandle = -1;
6529: }
6530: } else {
6531: if (mpuSavedBootDevice == -1) {
6532: mpuSavedBootDevice = MainMemory.mmrRwz (0x00ed0018);
6533: mpuSavedROMBootHandle = MainMemory.mmrRls (0x00ed000c);
6534: }
6535: }
6536:
6537:
6538: if (mpu010) {
6539: if (specifiedFirstMPU == Model.MPU_MC68000) {
6540: specifiedFirstMPU = Model.MPU_MC68010;
6541: }
6542: if (specifiedSecondMPU == Model.MPU_MC68000) {
6543: specifiedSecondMPU = Model.MPU_MC68010;
6544: }
6545: } else {
6546: if (specifiedFirstMPU == Model.MPU_MC68010) {
6547: specifiedFirstMPU = Model.MPU_MC68000;
6548: }
6549: if (specifiedSecondMPU == Model.MPU_MC68010) {
6550: specifiedSecondMPU = Model.MPU_MC68000;
6551: }
6552: }
6553:
6554:
6555: specifiedIsSecond = false;
6556: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
6557: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
6558:
6559: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
6560: MC68EC030.m30DivZeroVFlag = false;
6561: }
6562:
6563: if (mpuTask != null) {
6564: mpuClockLimit = 0L;
6565: System.out.println (Multilingual.mlnJapanese ?
6566: "MPU を停止します" :
6567: "MPU stops");
6568: mpuTask.cancel ();
6569: mpuTask = null;
6570: }
6571:
6572: tmrTimer.schedule (new TimerTask () {
6573: @Override public void run () {
6574:
6575:
6576:
6577: currentModel = specifiedModel;
6578: currentAccelerator = specifiedAccelerator;
6579: frmUpdateTitle ();
6580:
6581: currentIsSecond = specifiedIsSecond;
6582: currentFirstMPU = specifiedFirstMPU;
6583: currentSecondMPU = specifiedSecondMPU;
6584: currentMPU = specifiedMPU;
6585:
6586: mpuSetCurrentClock (specifiedClock);
6587:
6588: currentCopro0 = specifiedCopro0;
6589: currentCopro1 = specifiedCopro1;
6590: currentCopro2 = specifiedCopro2;
6591: currentOnchipFPU = specifiedOnchipFPU;
6592:
6593:
6594: if (currentMPU < Model.MPU_MC68020) {
6595: if (busHimem68000) {
6596: busRequestExMemoryStart = 0x10000000;
6597: busRequestExMemorySize = busLocalMemorySize;
6598: busRequestExMemoryArray = busLocalMemoryArray;
6599: } else {
6600: busRequestExMemoryStart = 0x10000000;
6601: busRequestExMemorySize = 0 << 20;
6602: busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
6603: }
6604: } else if (currentMPU < Model.MPU_MC68LC040) {
6605: if (busHighMemory060turboOn) {
6606: busRequestExMemoryStart = 0x10000000;
6607: busRequestExMemorySize = busLocalMemorySize;
6608: busRequestExMemoryArray = busLocalMemoryArray;
6609: } else {
6610: busRequestExMemoryStart = 0x01000000;
6611: busRequestExMemorySize = busHighMemorySize;
6612: busRequestExMemoryArray = busHighMemoryArray;
6613: }
6614: } else {
6615: busRequestExMemoryStart = 0x10000000;
6616: busRequestExMemorySize = busLocalMemorySize;
6617: busRequestExMemoryArray = busLocalMemoryArray;
6618: }
6619: busUpdateMemoryMap ();
6620:
6621:
6622: ROM.romReset ();
6623:
6624: RegisterList.drpSetMPU ();
6625:
6626: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
6627: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6628: MC68060.mmuReset ();
6629:
6630:
6631: if (Model.MPU_MC68020 <= currentMPU) {
6632: if ((7 & currentCopro0) == 1) {
6633: fpuMotherboardCoprocessor.epbSetMC68881 ();
6634: } else if ((7 & currentCopro0) == 2) {
6635: fpuMotherboardCoprocessor.epbSetMC68882 ();
6636: } else {
6637: fpuMotherboardCoprocessor.epbSetFullSpec ();
6638: }
6639: if ((8 & currentCopro0) == 0) {
6640: fpuMotherboardCoprocessor.epbSetExtended ();
6641: } else {
6642: fpuMotherboardCoprocessor.epbSetTriple ();
6643: }
6644: }
6645:
6646: if ((7 & currentCopro1) == 1) {
6647: fpuCoproboard1.epbSetMC68881 ();
6648: } else if ((7 & currentCopro1) == 2) {
6649: fpuCoproboard1.epbSetMC68882 ();
6650: } else {
6651: fpuCoproboard1.epbSetFullSpec ();
6652: }
6653: if ((8 & currentCopro1) == 0) {
6654: fpuCoproboard1.epbSetExtended ();
6655: } else {
6656: fpuCoproboard1.epbSetTriple ();
6657: }
6658:
6659: if ((7 & currentCopro2) == 1) {
6660: fpuCoproboard2.epbSetMC68881 ();
6661: } else if ((7 & currentCopro2) == 2) {
6662: fpuCoproboard2.epbSetMC68882 ();
6663: } else {
6664: fpuCoproboard2.epbSetFullSpec ();
6665: }
6666: if ((8 & currentCopro2) == 0) {
6667: fpuCoproboard2.epbSetExtended ();
6668: } else {
6669: fpuCoproboard2.epbSetTriple ();
6670: }
6671:
6672: if (Model.MPU_MC68040 <= currentMPU) {
6673: if ((7 & currentOnchipFPU) == 6) {
6674: fpuOnChipFPU.epbSetMC68060 ();
6675: } else {
6676: fpuOnChipFPU.epbSetFullSpec ();
6677: }
6678: if ((8 & currentOnchipFPU) == 0) {
6679: fpuOnChipFPU.epbSetExtended ();
6680: } else {
6681: fpuOnChipFPU.epbSetTriple ();
6682: }
6683: }
6684:
6685: if (!currentModel.isX68030 ()) {
6686: dmaCycleUnit = TMR_FREQ / 10000000L;
6687: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6688: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6689: mpuROMWaitCycles = 1;
6690: mpuRAMWaitCycles = 0;
6691: } else {
6692: dmaCycleUnit = TMR_FREQ / 12500000L;
6693: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6694: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6695: mpuROMWaitCycles = 0;
6696: mpuRAMWaitCycles = 0;
6697: }
6698:
6699: busWaitCycles = busWaitCyclesRequest;
6700: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
6701:
6702: HD63450.dmaReadCycles = (currentModel.isPRO () ? 6 :
6703: currentModel.isCompact () ? 4 :
6704: 5);
6705: HD63450.dmaWriteCycles = (currentModel.isPRO () ? 6 :
6706: 5);
6707:
6708: if (currentMPU < Model.MPU_MC68020) {
6709:
6710: mpuIgnoreAddressError = false;
6711:
6712: mpuCacheOn = false;
6713:
6714: } else if (currentMPU < Model.MPU_MC68040) {
6715:
6716: mpuIgnoreAddressError = true;
6717: fpuBox = fpuMotherboardCoprocessor;
6718: fpuBox.epbReset ();
6719: fpuFPn = fpuBox.epbFPn;
6720:
6721: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
6722:
6723: } else {
6724:
6725: mpuIgnoreAddressError = true;
6726: fpuBox = fpuOnChipFPU;
6727: fpuBox.epbReset ();
6728: fpuFPn = fpuBox.epbFPn;
6729:
6730: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6731: mpuCacheOn = (mpuCACR & 0x80008000) != 0;
6732: if (MC68060.CAT_ON) {
6733: if (Model.MPU_MC68LC060 <= currentMPU) {
6734: MC68060.catReset ();
6735: }
6736: }
6737:
6738: }
6739:
6740: mpuSetWait ();
6741:
6742:
6743: regSRT1 = regSRT0 = 0;
6744: regSRS = REG_SR_S;
6745: regSRM = 0;
6746: regSRI = REG_SR_I;
6747: regCCR = 0;
6748: Arrays.fill (regRn, 0);
6749:
6750: regRn[15] = MainMemory.mmrRls (0x00ff0000);
6751: regPC = MainMemory.mmrRls (0x00ff0004);
6752:
6753: MainMemory.mmrReset ();
6754:
6755: busReset ();
6756: if (InstructionBreakPoint.IBP_ON) {
6757: InstructionBreakPoint.ibpOp1MemoryMap = InstructionBreakPoint.ibpOp1SuperMap;
6758: InstructionBreakPoint.ibpReset ();
6759: }
6760: if (BranchLog.BLG_ON) {
6761: BranchLog.blgReset ();
6762: }
6763:
6764: mpuIMR = 0;
6765: mpuIRR = 0;
6766: if (MC68901.MFP_DELAYED_INTERRUPT) {
6767: mpuDIRR = 0;
6768: }
6769: mpuISR = 0;
6770:
6771:
6772: mpuStart ();
6773: }
6774: }, TMR_DELAY);
6775:
6776: }
6777:
6778:
6779:
6780: public static void mpuStopAndStart () {
6781: if (mpuTask == null) {
6782: mpuStart ();
6783: } else {
6784: if (RootPointerList.RTL_ON) {
6785: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6786: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6787: mpuStop (null);
6788: }
6789: } else {
6790: mpuStop (null);
6791: }
6792: }
6793: }
6794:
6795:
6796:
6797:
6798:
6799: public static void mpuStart () {
6800: if (mpuTask != null) {
6801: mpuClockLimit = 0L;
6802: System.out.println (Multilingual.mlnJapanese ?
6803: "MPU を停止します" :
6804: "MPU stops");
6805: mpuTask.cancel ();
6806: mpuTask = null;
6807: }
6808:
6809: for (AbstractButton button : mpuButtonsStopped) {
6810: button.setEnabled (false);
6811: }
6812: DisassembleList.ddpStoppedBy = null;
6813: System.out.println (Model.mpuNameOf (currentMPU) + (Multilingual.mlnJapanese ? " を起動します" : " starts up"));
6814: mpuTask = new TimerTask () {
6815: @Override public void run () {
6816: mpuContinue = true;
6817: mpuClockLimit = mpuClockTime + TMR_FREQ * TMR_INTERVAL / 1000;
6818: mpuExecuteCore ();
6819: }
6820: };
6821: tmrTimer.scheduleAtFixedRate (mpuTask, TMR_DELAY, TMR_INTERVAL);
6822:
6823: for (AbstractButton button : mpuButtonsRunning) {
6824: button.setEnabled (true);
6825: }
6826: }
6827:
6828:
6829:
6830: public static void mpuExecuteCore () {
6831:
6832: long nanoStart = System.nanoTime ();
6833:
6834: busSuper (RP5C15.rtcFirst, 0x00e8a000, 0x00e8c000);
6835:
6836:
6837: if (currentMPU < Model.MPU_MC68010) {
6838: MC68000.mpuCore ();
6839: } else if (currentMPU < Model.MPU_MC68020) {
6840: MC68010.mpuCore ();
6841: } else if (currentMPU < Model.MPU_MC68LC040) {
6842: MC68EC030.mpuCore ();
6843: } else {
6844: MC68060.mpuCore ();
6845: }
6846:
6847: if (dbgVisibleMask != 0) {
6848: dbgUpdate ();
6849: }
6850:
6851: long nanoEnd = System.nanoTime ();
6852: mpuTotalNano += nanoEnd - nanoStart;
6853: if (--mpuAdjustmentCounter == 0) {
6854:
6855: final double expectedNano = 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
6856:
6857: double coreNano0 = (double) mpuTotalNano;
6858: mpuTotalNano = 0L;
6859: double coreNanoA = (coreNano0 * 2.0 + mpuCoreNano1 + mpuCoreNano2) * 0.25;
6860: mpuCoreNano2 = mpuCoreNano1;
6861: mpuCoreNano1 = coreNano0;
6862:
6863:
6864:
6865: double actualPercent = Math.max (1.0, 100.0 * coreNanoA / expectedNano);
6866:
6867: double maxPercent = SoundSource.sndPlayOn ? 90.0 : 100.0;
6868:
6869:
6870:
6871:
6872: if (mpuUtilOn) {
6873:
6874: double targetPercent = Math.min (maxPercent, (double) mpuUtilRatio);
6875: mpuSetClockMHz ((1.2 - 0.2 * actualPercent / targetPercent) * mpuCurrentMHz);
6876: } else {
6877: mpuSetClockMHz (Math.min (maxPercent / actualPercent,
6878: 1.2 - 0.2 * mpuCurrentMHz / mpuClockMHz) * mpuCurrentMHz);
6879: }
6880: Indicator.indUpdate (actualPercent);
6881: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
6882: }
6883: }
6884:
6885:
6886:
6887:
6888: public static void mpuStop (String message) {
6889:
6890: mpuAdvanceCount = 0;
6891: mpuStepCount = 0;
6892: mpuContinue = false;
6893: mpuStop1 (message);
6894: }
6895: public static void mpuStop1 (String message) {
6896: if (mpuTask == null) {
6897: return;
6898: }
6899: DisassembleList.ddpStoppedBy = message;
6900: mpuClockLimit = 0L;
6901: System.out.println (Multilingual.mlnJapanese ?
6902: "MPU を停止します" :
6903: "MPU stops");
6904: mpuTask.cancel ();
6905: mpuTask = null;
6906:
6907: if (mpuStepCount != 0 && mpuContinue) {
6908: if (mpuStepCount == -1 || --mpuStepCount != 0) {
6909: mpuStep (mpuStepCount);
6910: return;
6911: }
6912: }
6913: mpuAdvanceCount = 0;
6914: mpuStepCount = 0;
6915: mpuContinue = false;
6916:
6917: for (AbstractButton button : mpuButtonsRunning) {
6918: button.setEnabled (false);
6919: }
6920: tmrTimer.schedule (new TimerTask () {
6921: @Override public void run () {
6922: mpuUpdateWindow ();
6923: }
6924: }, TMR_DELAY);
6925: }
6926:
6927:
6928:
6929:
6930:
6931:
6932: public static void mpuAdvance (int n) {
6933: if (mpuTask != null) {
6934: return;
6935: }
6936: mpuAdvanceCount = n;
6937: DisassembleList.ddpStoppedBy = null;
6938: mpuTask = new TimerTask () {
6939: @Override public void run () {
6940: mpuContinue = true;
6941: do {
6942: mpuClockLimit = mpuClockTime + 1L;
6943: mpuExecuteCore ();
6944: } while (mpuContinue && --mpuAdvanceCount != 0);
6945: mpuClockLimit = 0L;
6946: if (mpuTask != null) {
6947: mpuTask.cancel ();
6948: mpuTask = null;
6949: }
6950: if (mpuStepCount != 0 && mpuContinue) {
6951: if (mpuStepCount == -1 || --mpuStepCount != 0) {
6952: mpuStep (mpuStepCount);
6953: return;
6954: }
6955: }
6956: mpuAdvanceCount = 0;
6957: mpuStepCount = 0;
6958: mpuContinue = false;
6959: mpuUpdateWindow ();
6960: }
6961: };
6962: tmrTimer.schedule (mpuTask, TMR_DELAY);
6963: }
6964:
6965:
6966:
6967:
6968:
6969:
6970: public static void mpuStep (int n) {
6971: if (mpuTask != null) {
6972: return;
6973: }
6974: mpuStepCount = n;
6975: Disassembler.disDisassemble (new StringBuilder (), regPC, regSRS);
6976: if ((Disassembler.disStatus & (Disassembler.DIS_ALWAYS_BRANCH | Disassembler.DIS_SOMETIMES_BRANCH)) != 0) {
6977: if (mpuStepCount == -1 &&
6978: (Disassembler.disOC == 0x4e73 ||
6979: Disassembler.disOC == 0x4e74 ||
6980: Disassembler.disOC == 0x4e75 ||
6981: Disassembler.disOC == 0x4e77) &&
6982: mpuUntilReturnSRS == regSRS &&
6983: (currentMPU < Model.MPU_MC68LC040 ||
6984: mpuUntilReturnRP == (regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP)) &&
6985: mpuUntilReturnPC0 != regPC0 &&
6986: Integer.compareUnsigned (mpuUntilReturnSP, regRn[15]) <= 0) {
6987: mpuAdvanceCount = 0;
6988: mpuStepCount = 0;
6989: mpuContinue = false;
6990: mpuUpdateWindow ();
6991: return;
6992: }
6993: mpuAdvance (1);
6994: } else {
6995: if (InstructionBreakPoint.IBP_ON) {
6996: InstructionBreakPoint.ibpInstant (Disassembler.disPC, DisassembleList.ddpSupervisorMode);
6997: mpuStart ();
6998: }
6999: }
7000: }
7001:
7002:
7003:
7004:
7005:
7006:
7007:
7008:
7009:
7010:
7011:
7012: public static void mpuStepUntilReturn () {
7013: if (mpuTask != null) {
7014: return;
7015: }
7016: mpuUntilReturnSRS = regSRS;
7017: mpuUntilReturnRP = regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP;
7018: mpuUntilReturnPC0 = regPC0;
7019: mpuUntilReturnSP = regRn[15];
7020: mpuStep (-1);
7021: }
7022:
7023:
7024:
7025: public static void mpuUpdateWindow () {
7026: if (dbgVisibleMask != 0) {
7027: if ((dbgVisibleMask & DBG_DDP_VISIBLE_MASK) != 0) {
7028: DisassembleList.ddpBacktraceRecord = -1L;
7029: DisassembleList.ddpUpdate (-1, -1, false);
7030: }
7031: if (BranchLog.BLG_ON) {
7032: if ((dbgVisibleMask & DBG_BLG_VISIBLE_MASK) != 0) {
7033: BranchLog.blgUpdate (BranchLog.BLG_SELECT_NEWEST);
7034: }
7035: }
7036: if (ProgramFlowVisualizer.PFV_ON) {
7037: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
7038: ProgramFlowVisualizer.pfvUpdate ();
7039: }
7040: }
7041: if (RasterBreakPoint.RBP_ON) {
7042: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
7043: RasterBreakPoint.rbpUpdateFrame ();
7044: }
7045: }
7046: if (ScreenModeTest.SMT_ON) {
7047: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
7048: ScreenModeTest.smtUpdateFrame ();
7049: }
7050: }
7051: if (RootPointerList.RTL_ON) {
7052: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
7053: RootPointerList.rtlUpdateFrame ();
7054: }
7055: }
7056: if (SpritePatternViewer.SPV_ON) {
7057: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
7058: SpritePatternViewer.spvUpdateFrame ();
7059: }
7060: }
7061: if (PaletteViewer.PLV_ON) {
7062: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
7063: PaletteViewer.plvUpdateFrame ();
7064: }
7065: }
7066: if (ATCMonitor.ACM_ON) {
7067: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
7068: ATCMonitor.acmUpdateFrame ();
7069: }
7070: }
7071: }
7072:
7073: if (DebugConsole.dgtRequestRegs != 0) {
7074: if ((DebugConsole.dgtRequestRegs & 1) != 0) {
7075: ExpressionEvaluator.ElementType.ETY_COMMAND_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
7076: }
7077: if ((DebugConsole.dgtRequestRegs & 2) != 0) {
7078: ExpressionEvaluator.ElementType.ETY_COMMAND_FLOAT_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
7079: }
7080: if ((DebugConsole.dgtRequestRegs & 4) != 0) {
7081: DebugConsole.dgtPrintPrompt ();
7082: }
7083: DebugConsole.dgtRequestRegs = 0;
7084: }
7085:
7086: for (AbstractButton button : mpuButtonsRunning) {
7087: button.setEnabled (false);
7088: }
7089:
7090: for (AbstractButton button : mpuButtonsStopped) {
7091: button.setEnabled (true);
7092: }
7093: }
7094:
7095:
7096:
7097: public static JButton mpuMakeBreakButton () {
7098: return mpuAddButtonRunning (
7099: Multilingual.mlnToolTipText (
7100: ComponentFactory.createImageButton (
7101: LnF.LNF_BREAK_IMAGE,
7102: LnF.LNF_BREAK_DISABLED_IMAGE,
7103: "Stop", mpuDebugActionListener),
7104: "ja", "停止")
7105: );
7106: }
7107:
7108:
7109:
7110: public static JButton mpuMakeTraceButton () {
7111: return mpuAddButtonStopped (
7112: Multilingual.mlnToolTipText (
7113: ComponentFactory.createImageButton (
7114: LnF.LNF_TRACE_IMAGE,
7115: LnF.LNF_TRACE_DISABLED_IMAGE,
7116: "Trace", mpuDebugActionListener),
7117: "ja", "トレース")
7118: );
7119: }
7120:
7121:
7122:
7123: public static JButton mpuMakeTrace10Button () {
7124: return mpuAddButtonStopped (
7125: Multilingual.mlnToolTipText (
7126: ComponentFactory.createImageButton (
7127: LnF.LNF_TRACE_10_IMAGE,
7128: LnF.LNF_TRACE_10_DISABLED_IMAGE,
7129: "Trace 10 times", mpuDebugActionListener),
7130: "ja", "トレース 10 回")
7131: );
7132: }
7133:
7134:
7135:
7136: public static JButton mpuMakeTrace100Button () {
7137: return mpuAddButtonStopped (
7138: Multilingual.mlnToolTipText (
7139: ComponentFactory.createImageButton (
7140: LnF.LNF_TRACE_100_IMAGE,
7141: LnF.LNF_TRACE_100_DISABLED_IMAGE,
7142: "Trace 100 times", mpuDebugActionListener),
7143: "ja", "トレース 100 回")
7144: );
7145: }
7146:
7147:
7148:
7149: public static JButton mpuMakeStepButton () {
7150: return mpuAddButtonStopped (
7151: Multilingual.mlnToolTipText (
7152: ComponentFactory.createImageButton (
7153: LnF.LNF_STEP_IMAGE,
7154: LnF.LNF_STEP_DISABLED_IMAGE,
7155: "Step", mpuDebugActionListener),
7156: "ja", "ステップ")
7157: );
7158: }
7159:
7160:
7161:
7162: public static JButton mpuMakeStep10Button () {
7163: return mpuAddButtonStopped (
7164: Multilingual.mlnToolTipText (
7165: ComponentFactory.createImageButton (
7166: LnF.LNF_STEP_10_IMAGE,
7167: LnF.LNF_STEP_10_DISABLED_IMAGE,
7168: "Step 10 times", mpuDebugActionListener),
7169: "ja", "ステップ 10 回")
7170: );
7171: }
7172:
7173:
7174:
7175: public static JButton mpuMakeStep100Button () {
7176: return mpuAddButtonStopped (
7177: Multilingual.mlnToolTipText (
7178: ComponentFactory.createImageButton (
7179: LnF.LNF_STEP_100_IMAGE,
7180: LnF.LNF_STEP_100_DISABLED_IMAGE,
7181: "Step 100 times", mpuDebugActionListener),
7182: "ja", "ステップ 100 回")
7183: );
7184: }
7185:
7186:
7187:
7188: public static JButton mpuMakeReturnButton () {
7189: return mpuAddButtonStopped (
7190: Multilingual.mlnToolTipText (
7191: ComponentFactory.createImageButton (
7192: LnF.LNF_STEP_UNTIL_RETURN_IMAGE,
7193: LnF.LNF_STEP_UNTIL_RETURN_DISABLED_IMAGE,
7194: "Step until return", mpuDebugActionListener),
7195: "ja", "ステップアンティルリターン")
7196: );
7197: }
7198:
7199:
7200:
7201: public static JButton mpuMakeRunButton () {
7202: return mpuAddButtonStopped (
7203: Multilingual.mlnToolTipText (
7204: ComponentFactory.createImageButton (
7205: LnF.LNF_RUN_IMAGE,
7206: LnF.LNF_RUN_DISABLED_IMAGE,
7207: "Run", mpuDebugActionListener),
7208: "ja", "実行")
7209: );
7210: }
7211:
7212:
7213:
7214: public static <T extends AbstractButton> T mpuAddButtonRunning (T button) {
7215: button.setEnabled (mpuTask != null);
7216: mpuButtonsRunning.add (button);
7217: return button;
7218: }
7219:
7220:
7221:
7222: public static <T extends AbstractButton> T mpuAddButtonStopped (T button) {
7223: button.setEnabled (mpuTask == null);
7224: mpuButtonsStopped.add (button);
7225: return button;
7226: }
7227:
7228:
7229:
7230:
7231:
7232:
7233:
7234:
7235:
7236:
7237:
7238:
7239:
7240:
7241:
7242:
7243: public static final int EMX_OPCODE_BASE = 0x4e00;
7244: public static final int EMX_OPCODE_HFSBOOT = EMX_OPCODE_BASE + 0x00;
7245: public static final int EMX_OPCODE_HFSINST = EMX_OPCODE_BASE + 0x01;
7246: public static final int EMX_OPCODE_HFSSTR = EMX_OPCODE_BASE + 0x02;
7247: public static final int EMX_OPCODE_HFSINT = EMX_OPCODE_BASE + 0x03;
7248: public static final int EMX_OPCODE_EMXNOP = EMX_OPCODE_BASE + 0x04;
7249: public static final int EMX_OPCODE_EMXWAIT = EMX_OPCODE_BASE + 0x05;
7250:
7251: public static final String[] EMX_MNEMONIC_ARRAY = {
7252: "hfsboot",
7253: "hfsinst",
7254: "hfsstr",
7255: "hfsint",
7256: "emxnop",
7257: "emxwait",
7258: };
7259:
7260:
7261:
7262:
7263: public static void emxNop () {
7264: if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x00007140) {
7265: int head = regRn[9];
7266: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7267:
7268:
7269: emxPatchPCM8A (head, tail);
7270:
7271:
7272: emxCheckRSDRV202 (head, tail);
7273: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000716c) {
7274: int head = regRn[9];
7275: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7276:
7277:
7278: emxPatch060turbosys (head, tail);
7279:
7280:
7281: if (Z8530.SCC_FSX_MOUSE) {
7282: emxCheckFSX (head, tail);
7283: }
7284:
7285:
7286: if (HFS.HFS_USE_TWENTY_ONE) {
7287: emxCheckTwentyOne (head, tail);
7288: }
7289:
7290:
7291: LabeledAddress.lblClear ();
7292: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000972c) {
7293: int head = regRn[8] + 256;
7294:
7295: int tail = MC68060.mmuPeekLong (head - 208, 1);
7296:
7297:
7298: emxCheckBSIO021 (head, tail);
7299:
7300:
7301: emxPatchPCM8A (head, tail);
7302:
7303:
7304: emxCheckTMSIO031 (head, tail);
7305:
7306:
7307: LabeledAddress.lblClear ();
7308:
7309:
7310: if (dbgStopAtStart) {
7311: InstructionBreakPoint.ibpInstant (regRn[12], 0);
7312: }
7313: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000a090) {
7314: int head = regRn[8] + 256;
7315: int tail = MC68060.mmuPeekLongData (regRn[8] + 8, 1);
7316: String name = MC68060.mmuPeekStringZ (head - 60, 1);
7317: if (name.equalsIgnoreCase ("fsx.x")) {
7318:
7319:
7320: if (Z8530.SCC_FSX_MOUSE) {
7321: emxCheckFSX (head, tail);
7322: }
7323: }
7324: if (name.equalsIgnoreCase ("TwentyOne.x")) {
7325:
7326:
7327: if (HFS.HFS_USE_TWENTY_ONE) {
7328: emxCheckTwentyOne (head, tail);
7329: }
7330: }
7331: }
7332: }
7333:
7334: public static final int[] emxPCM8AFFMap = {
7335: 0x00000138, 0x000001f6, 0x00000394, 0x000011ec, 0x0000120a, 0x00001400, 0x00001814, 0x00001870, 0x00001882, 0x0000188a,
7336: 0x00001892, 0x000018a2, 0x000018a8, 0x000018ca, 0x000018d4, 0x000018e0, 0x000018e8, 0x00001908, 0x000019e4, 0x00001afa,
7337: 0x00001b58, 0x00001b7c, 0x00001bac, 0x00001c38, 0x00001ccc, 0x000021f8, 0x00002250, 0x00002258, 0x00002290, 0x000022a6,
7338: 0x000022b0, 0x000022c0, 0x000022c8, 0x000022de, 0x000022ea, 0x000030c8, 0x000030de, 0x000030e6, 0x000030ea, 0x000030f6,
7339: 0x00003112, 0x00003188, 0x0000334c, 0x0000338a, 0x000033a2, 0x000033c4, 0x000033d0, 0x0000341a, 0x00003428, 0x00003496,
7340: 0x000034a6, 0x000034d6, 0x0000fe0e, 0x0000fec8, 0x0000feec, 0x0000ff46, 0x0000ff4e,
7341: };
7342:
7343:
7344:
7345: public static void emxPatchPCM8A (int head, int tail) {
7346: if (head + 0x0000ff60 <= tail &&
7347: MC68060.mmuPeekLongData (head + 0x10f8, 1) == 0x50434d38 &&
7348: MC68060.mmuPeekLongData (head + 0x10fc, 1) == 0x41313032) {
7349: System.out.println (Multilingual.mlnJapanese ?
7350: "PCM8A.X 1.02 があります" :
7351: "PCM8A.X 1.02 exists");
7352: int patched = 0;
7353: int failed = 0;
7354:
7355: for (int offset : emxPCM8AFFMap) {
7356: if (MC68060.mmuPeekByteZeroData (head + offset, 1) == 0xff) {
7357: MC68060.mmuPokeByteData (head + offset, 0x00, 1);
7358: patched++;
7359: } else {
7360: failed++;
7361: }
7362: }
7363: if (patched != 0) {
7364: System.out.printf (Multilingual.mlnJapanese ?
7365: "PCM8A.X 1.02 にパッチをあてました (%d/%d)\n" :
7366: "PCM8A.X 1.02 was patched (%d/%d)\n",
7367: patched, patched + failed);
7368: }
7369: }
7370: }
7371:
7372:
7373:
7374: public static void emxPatch060turbosys (int head, int tail) {
7375:
7376:
7377:
7378:
7379: if (head + 0x00002000 <= tail &&
7380: MC68060.mmuPeekLongData (head + 0x00000ec0, 1) == 0x203c302e &&
7381: MC68060.mmuPeekLongData (head + 0x00000ec4, 1) == 0x3536227c &&
7382: MC68060.mmuPeekLongData (head + 0x00000ec8, 1) == 0x30363054) {
7383: System.out.println (Multilingual.mlnJapanese ?
7384: "060turbo.sys 0.56 があります" :
7385: "060turbo.sys 0.56 exists");
7386:
7387:
7388:
7389: int patched = 0;
7390: int failed = 0;
7391: if (MC68060.mmuPeekLongData (head + 0x000021e6, 1) == 0x08f90004 &&
7392: MC68060.mmuPeekLongData (head + 0x000021ea, 1) == 0x00ed0070) {
7393: MC68060.mmuPokeWordData (head + 0x000021e6, 0x0839, 1);
7394: patched++;
7395: } else {
7396: failed++;
7397: }
7398: System.out.printf (Multilingual.mlnJapanese ?
7399: "060turbo.sys 0.56 にパッチをあてました (%d/%d)\n" :
7400: "060turbo.sys 0.56 was patched (%d/%d)\n",
7401: patched, patched + failed);
7402: }
7403: }
7404:
7405:
7406:
7407: public static void emxCheckFSX (int head, int tail) {
7408: if (Z8530.SCC_FSX_MOUSE) {
7409: if (head + 0x00063200 <= tail &&
7410: "\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))) {
7411: System.out.println (Multilingual.mlnJapanese ?
7412: "FSX.X 3.10 があります" :
7413: "FSX.X 3.10 exists");
7414: Z8530.sccFSXMouseHook = head + 0x04f82a;
7415: Z8530.sccFSXMouseWork = head + 0x063184;
7416: }
7417: }
7418: }
7419:
7420:
7421:
7422:
7423:
7424:
7425: public static void emxCheckRSDRV202 (int head, int tail) {
7426: if (head + 0x000ea6 <= tail &&
7427: MC68060.mmuPeekEquals (head + 0x000e4e, "RS-232C DRIVER for X68000 version 2.02")) {
7428: if (RS232CTerminal.trmRSDRV202Head != head) {
7429: RS232CTerminal.trmRSDRV202Head = head;
7430: int[] patchData = {
7431:
7432:
7433: 0x05f8, 0x000a, 0x000b,
7434:
7435: 0x0600, 0xd040, 0x2048,
7436:
7437: 0x060e, 0x3030, 0x4e90,
7438: 0x0610, 0x0000, 0x2048,
7439:
7440: 0x074e, 0x0821, 0x2041,
7441: 0x0750, 0x0410, 0x3200,
7442: 0x0752, 0x0207, 0x303c,
7443: 0x0754, 0x0102, 0x0823,
7444: 0x0756, 0x0080, 0xe268,
7445: 0x0758, 0x003f, 0x72fe,
7446: 0x075a, 0x001f, 0xd141,
7447: 0x075c, 0x000e, 0x2208,
7448: 0x075e, 0x0006, 0x4e75,
7449:
7450:
7451: 0x0ab0, 0x0040, 0x0400,
7452: 0x0ad2, 0x0040, 0x0400,
7453: 0x0af4, 0x0040, 0x0400,
7454: 0x0b16, 0x0040, 0x0400,
7455: 0x0b38, 0x0040, 0x0400,
7456:
7457:
7458: 0x0cae, 0x0009, 0x000b,
7459: };
7460: int patched = 0;
7461: int failed = 0;
7462: for (int i = 0; i < patchData.length; i += 3) {
7463: int a = head + patchData[i];
7464: int b = patchData[i + 1];
7465: int c = patchData[i + 2];
7466: int d = MC68060.mmuPeekWordZeroData (a, 1);
7467: if (d == b) {
7468: MC68060.mmuPokeWordData (a, c, 1);
7469: patched++;
7470: } else if (d != c) {
7471: failed++;
7472: }
7473: }
7474: System.out.printf ("RSDRV.SYS 2.02 found at %08X and patched (%d/%d)\n", head, patched, patched + failed);
7475: }
7476: }
7477: }
7478:
7479:
7480:
7481:
7482:
7483: public static void emxCheckTMSIO031 (int head, int tail) {
7484: if (head + 0x000fc4 <= tail &&
7485: MC68060.mmuPeekEquals (head + 0x000d1c, "TMSIO version 0.31 Copyright (C) 1990-93 by Miki Hoshino")) {
7486: if (RS232CTerminal.trmTMSIO031Head != head) {
7487: RS232CTerminal.trmTMSIO031Head = head;
7488: System.out.printf ("TMSIO 0.31 found at %08X\n", head);
7489: }
7490: }
7491: }
7492:
7493:
7494:
7495:
7496:
7497: public static void emxCheckBSIO021 (int head, int tail) {
7498: if (head + 0x001c2c <= tail &&
7499: MC68060.mmuPeekEquals (head + 0x001a66, "BSIO version 0.21 Copyright (C) 1994 By BAZU")) {
7500: if (RS232CTerminal.trmBSIO021Head != head) {
7501: RS232CTerminal.trmBSIO021Head = head;
7502: System.out.printf ("BSIO 0.21 found at %08X\n", head);
7503: }
7504: }
7505: }
7506:
7507:
7508:
7509: public static void emxCheckTwentyOne (int head, int tail) {
7510: if (HFS.HFS_USE_TWENTY_ONE &&
7511: head + 64 <= tail) {
7512: if (MainMemory.mmrTwentyOneOptionAddress != 0 ||
7513: MainMemory.mmrHumanVersion <= 0) {
7514: return;
7515: }
7516: int name1 = MC68060.mmuPeekLongData (head + 14, 1);
7517: if (name1 == ('*' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7518: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7519: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '*')) {
7520: MainMemory.mmrTwentyOneOptionAddress = -1;
7521: }
7522: } else if (name1 == ('?' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7523: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7524: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '?') ||
7525: name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | 'E')) {
7526: System.out.println (Multilingual.mlnJapanese ?
7527: "TwentyOne.x があります" :
7528: "TwentyOne.x exists");
7529: MainMemory.mmrTwentyOneOptionAddress = head + 22;
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: public static final boolean IRP_BITREV_REVERSE = false;
7586: public static final boolean IRP_BITREV_SHIFT = false;
7587: public static final boolean IRP_BITREV_TABLE = true;
7588:
7589: public static final boolean IRP_MOVEM_MAINMEMORY = true;
7590: public static final boolean IRP_MOVEM_EXPAND = false;
7591: public static final boolean IRP_MOVEM_LOOP = false;
7592: public static final boolean IRP_MOVEM_SHIFT_LEFT = false;
7593: public static final boolean IRP_MOVEM_SHIFT_RIGHT = true;
7594: public static final boolean IRP_MOVEM_ZEROS = false;
7595:
7596:
7597: public static void irpReset () {
7598:
7599: CRTC.crtReset ();
7600: VideoController.vcnReset ();
7601: HD63450.dmaReset ();
7602: MC68901.mfpReset ();
7603: Keyboard.kbdReset ();
7604: RP5C15.rtcReset ();
7605: PrinterPort.prnReset ();
7606: SoundSource.sndReset ();
7607: OPM.opmReset ();
7608: ADPCM.pcmReset ();
7609: FDC.fdcReset ();
7610: IOInterrupt.ioiReset ();
7611: eb2Reset ();
7612: if (HostCDROM.HCD_ENABLED) {
7613: HostCDROM.hcdReset ();
7614: }
7615: SPC.spcReset ();
7616: Z8530.sccReset ();
7617: RS232CTerminal.trmReset ();
7618: PPI.ppiReset ();
7619: HFS.hfsReset ();
7620: SpriteScreen.sprReset ();
7621:
7622: if (MercuryUnit.MU4_ON) {
7623: MercuryUnit.mu4Reset ();
7624: }
7625: xt3Reset ();
7626: SRAM.smrReset ();
7627: CONDevice.conReset ();
7628: TextCopy.txcReset ();
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:
8036:
8037:
8038:
8039:
8040:
8041:
8042:
8043:
8044:
8045:
8046:
8047:
8048:
8049:
8050:
8051:
8052:
8053:
8054:
8055:
8056:
8057:
8058:
8059:
8060:
8061:
8062:
8063:
8064:
8065:
8066:
8067:
8068:
8069:
8070:
8071:
8072:
8073:
8074:
8075:
8076:
8077:
8078:
8079:
8080:
8081:
8082:
8083:
8084:
8085:
8086:
8087:
8088:
8089:
8090:
8091:
8092:
8093:
8094:
8095:
8096:
8097:
8098:
8099:
8100:
8101:
8102:
8103:
8104:
8105:
8106:
8107:
8108:
8109:
8110:
8111:
8112:
8113:
8114:
8115:
8116:
8117:
8118:
8119:
8120:
8121:
8122:
8123:
8124:
8125:
8126:
8127:
8128:
8129:
8130:
8131:
8132:
8133:
8134:
8135:
8136:
8137:
8138:
8139:
8140:
8141:
8142:
8143:
8144:
8145:
8146:
8147:
8148:
8149:
8150:
8151:
8152:
8153:
8154:
8155:
8156:
8157:
8158:
8159:
8160:
8161:
8162:
8163:
8164:
8165:
8166:
8167:
8168:
8169:
8170:
8171:
8172:
8173:
8174:
8175:
8176:
8177:
8178:
8179:
8180:
8181:
8182:
8183:
8184:
8185:
8186:
8187:
8188:
8189:
8190:
8191:
8192:
8193:
8194:
8195:
8196:
8197:
8198:
8199:
8200:
8201:
8202:
8203:
8204:
8205:
8206:
8207:
8208:
8209:
8210:
8211:
8212:
8213:
8214:
8215:
8216: 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);
8217:
8218: public static final boolean EFA_SEPARATE_AR = false;
8219:
8220:
8221:
8222:
8223:
8224:
8225: public static final boolean BUS_SPLIT_UNALIGNED_LONG = false;
8226:
8227:
8228: public static final int BUS_MOTHER_BITS = 24;
8229: public static final int BUS_MOTHER_SIZE = BUS_MOTHER_BITS < 32 ? 1 << BUS_MOTHER_BITS : 0;
8230: public static final int BUS_MOTHER_MASK = BUS_MOTHER_SIZE - 1;
8231:
8232: public static final int BUS_ARRAY_SIZE = BUS_MOTHER_SIZE;
8233:
8234:
8235: public static final int BUS_PAGE_BITS = 12;
8236: public static final int BUS_PAGE_SIZE = 1 << BUS_PAGE_BITS;
8237: public static final int BUS_PAGE_COUNT = 1 << (32 - BUS_PAGE_BITS);
8238:
8239:
8240: public static final int MPU_SS_BYTE = 0;
8241: public static final int MPU_SS_WORD = 1;
8242: public static final int MPU_SS_LONG = 2;
8243:
8244:
8245: public static final int MPU_WR_WRITE = 0;
8246: public static final int MPU_WR_READ = 1;
8247:
8248:
8249: public static final int MPU_US_USER = 0;
8250: public static final int MPU_US_SUPERVISOR = 1;
8251:
8252:
8253: public static final MemoryMappedDevice[] busUserMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8254: public static final MemoryMappedDevice[] busSuperMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8255: public static MemoryMappedDevice[] busMemoryMap;
8256:
8257:
8258: public static boolean busHimem68000;
8259:
8260:
8261: public static final int BUS_HIGH_MEMORY_START = 0x01000000;
8262: public static int busHighMemorySize;
8263: public static byte[] busHighMemoryArray;
8264: public static boolean busHighMemorySaveOn;
8265: public static boolean busHighMemory060turboOn;
8266:
8267:
8268: public static final int BUS_LOCAL_MEMORY_START = 0x10000000;
8269: public static int busLocalMemorySize;
8270: public static byte[] busLocalMemoryArray;
8271: public static boolean busLocalMemorySaveOn;
8272:
8273:
8274: public static final byte[] BUS_DUMMY_MEMORY_ARRAY = new byte[0];
8275: public static int busRequestExMemoryStart;
8276: public static int busRequestExMemorySize;
8277: public static byte[] busRequestExMemoryArray;
8278: public static int busExMemoryStart;
8279: public static int busExMemorySize;
8280: public static byte[] busExMemoryArray;
8281:
8282:
8283: public static boolean busRequestCutFC2Pin;
8284: public static boolean busCutFC2Pin;
8285:
8286:
8287:
8288: public static void busInit () {
8289:
8290:
8291: if (!DataBreakPoint.DBP_ON) {
8292: busMemoryMap = busSuperMap;
8293: }
8294:
8295:
8296: int highMemorySizeMB = Settings.sgsGetInt ("highmemory");
8297: busHighMemorySize = highMemorySizeMB == 16 ? highMemorySizeMB << 20 : 0 << 20;
8298: if (busHighMemorySize == 0) {
8299: System.out.println (Multilingual.mlnJapanese ?
8300: "X68030/Xellent30 のハイメモリはありません" :
8301: "X68030/Xellent30 high memory does not exists");
8302: } else {
8303: System.out.printf (Multilingual.mlnJapanese ?
8304: "X68030/Xellent30 のハイメモリのサイズは %dMB です\n" :
8305: "X68030/Xellent30 high memory size is %dMB\n",
8306: busHighMemorySize >> 20);
8307: }
8308: busHighMemoryArray = new byte[busHighMemorySize];
8309:
8310: busHimem68000 = Settings.sgsGetOnOff ("himem68000");
8311:
8312: busHighMemorySaveOn = Settings.sgsGetOnOff ("highmemorysave");
8313: busHighMemory060turboOn = Settings.sgsGetOnOff ("highmemory060turbo");
8314:
8315: byte[] highMemoryArray = Settings.sgsGetData ("highmemorydata");
8316: if (busHighMemorySize != 0) {
8317: if (highMemoryArray.length != 0) {
8318: System.out.println (Multilingual.mlnJapanese ?
8319: "X68030/Xellent30 のハイメモリのデータを復元します" :
8320: "X68030/Xellent30 high memory data is restored");
8321: System.arraycopy (highMemoryArray, 0, busHighMemoryArray, 0, Math.min (highMemoryArray.length, busHighMemorySize));
8322: } else {
8323: System.out.println (Multilingual.mlnJapanese ?
8324: "X68030/Xellent30 のハイメモリをゼロクリアします" :
8325: "X68030/Xellent30 high memory is zero-cleared");
8326: }
8327: if (highMemoryArray.length < busHighMemorySize) {
8328: Arrays.fill (busHighMemoryArray, highMemoryArray.length, busHighMemorySize, (byte) 0);
8329: }
8330: }
8331:
8332:
8333: int localMemorySizeMB = Settings.sgsGetInt ("localmemory");
8334: busLocalMemorySize = (localMemorySizeMB == 16 ||
8335: localMemorySizeMB == 32 ||
8336: localMemorySizeMB == 64 ||
8337: localMemorySizeMB == 128 ||
8338: localMemorySizeMB == 256 ||
8339: localMemorySizeMB == 384 ||
8340: localMemorySizeMB == 512 ||
8341: localMemorySizeMB == 768 ?
8342: localMemorySizeMB << 20 :
8343: 128 << 20);
8344: if (busLocalMemorySize == 0) {
8345: System.out.println (Multilingual.mlnJapanese ?
8346: "060turbo のハイメモリはありません" :
8347: "060turbo high memory does not exists");
8348: } else {
8349: System.out.printf (Multilingual.mlnJapanese ?
8350: "060turbo のハイメモリのサイズは %dMB です\n" :
8351: "060turbo high memory size is %dMB\n",
8352: busLocalMemorySize >> 20);
8353: }
8354: busLocalMemoryArray = new byte[busLocalMemorySize];
8355:
8356: busLocalMemorySaveOn = Settings.sgsGetOnOff ("localmemorysave");
8357:
8358: byte[] localMemoryArray = Settings.sgsGetData ("localmemorydata");
8359: if (busLocalMemorySize != 0) {
8360: if (localMemoryArray.length != 0) {
8361: System.out.println (Multilingual.mlnJapanese ?
8362: "060turbo のハイメモリのデータを復元します" :
8363: "060turbo high memory data is restored");
8364: System.arraycopy (localMemoryArray, 0, busLocalMemoryArray, 0, Math.min (localMemoryArray.length, busLocalMemorySize));
8365: } else {
8366: System.out.println (Multilingual.mlnJapanese ?
8367: "060turbo のハイメモリをゼロクリアします" :
8368: "060turbo high memory is zero-cleared");
8369: }
8370: if (localMemoryArray.length < busLocalMemorySize) {
8371: Arrays.fill (busLocalMemoryArray, localMemoryArray.length, busLocalMemorySize, (byte) 0);
8372: }
8373: }
8374:
8375:
8376: busExMemoryStart = busRequestExMemoryStart = 0x10000000;
8377: busExMemorySize = busRequestExMemorySize = 0 << 20;
8378: busExMemoryArray = busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
8379:
8380:
8381: busRequestCutFC2Pin = Settings.sgsGetOnOff ("cutfc2pin");
8382: busCutFC2Pin = !busRequestCutFC2Pin;
8383:
8384: busUpdateMemoryMap ();
8385:
8386: }
8387:
8388:
8389:
8390: public static void busTini () {
8391: Settings.sgsPutOnOff ("himem68000", busHimem68000);
8392: Settings.sgsPutInt ("highmemory", busHighMemorySize >>> 20);
8393: Settings.sgsPutOnOff ("highmemorysave", busHighMemorySaveOn);
8394: Settings.sgsPutOnOff ("highmemory060turbo", busHighMemory060turboOn);
8395: Settings.sgsPutData ("highmemorydata", busHighMemorySaveOn ? busHighMemoryArray : new byte[0]);
8396: Settings.sgsPutInt ("localmemory", busLocalMemorySize >>> 20);
8397: Settings.sgsPutOnOff ("localmemorysave", busLocalMemorySaveOn);
8398: Settings.sgsPutData ("localmemorydata", busLocalMemorySaveOn ? busLocalMemoryArray : new byte[0]);
8399: Settings.sgsPutOnOff ("cutfc2pin", busRequestCutFC2Pin);
8400: }
8401:
8402: public static void busUpdateMemoryMap () {
8403: if (busExMemoryStart == busRequestExMemoryStart &&
8404: busExMemorySize == busRequestExMemorySize &&
8405: busExMemoryArray == busRequestExMemoryArray &&
8406: busExMemoryArray.length == busExMemorySize &&
8407: busCutFC2Pin == busRequestCutFC2Pin) {
8408: return;
8409: }
8410:
8411: busExMemoryStart = busRequestExMemoryStart;
8412: busExMemorySize = busRequestExMemorySize;
8413: busExMemoryArray = busRequestExMemoryArray;
8414: if (busExMemoryArray.length != busExMemorySize) {
8415: byte[] newArray = new byte[busExMemorySize];
8416: int copySize = Math.min (busExMemoryArray.length, busExMemorySize);
8417: if (copySize > 0) {
8418: System.arraycopy (busExMemoryArray, 0, newArray, 0, copySize);
8419: }
8420: if (busExMemoryArray == busHighMemoryArray) {
8421: busHighMemoryArray = newArray;
8422: } else if (busExMemoryArray == busLocalMemoryArray) {
8423: busLocalMemoryArray = newArray;
8424: }
8425: busExMemoryArray = newArray;
8426: }
8427:
8428: busCutFC2Pin = busRequestCutFC2Pin;
8429:
8430:
8431:
8432:
8433:
8434:
8435:
8436:
8437:
8438:
8439:
8440:
8441: busSuper (MemoryMappedDevice.MMD_MMR, 0x00000000, 0x00002000);
8442: busUser ( MemoryMappedDevice.MMD_MMR, 0x00002000, 0x00c00000);
8443:
8444:
8445:
8446:
8447:
8448:
8449:
8450:
8451:
8452:
8453:
8454:
8455:
8456:
8457:
8458:
8459:
8460:
8461:
8462:
8463:
8464:
8465:
8466:
8467: busSuper (MemoryMappedDevice.MMD_GE0, 0x00c00000, 0x00c80000);
8468: busSuper (MemoryMappedDevice.MMD_GE1, 0x00c80000, 0x00d00000);
8469: busSuper (MemoryMappedDevice.MMD_GE2, 0x00d00000, 0x00d80000);
8470: busSuper (MemoryMappedDevice.MMD_GE3, 0x00d80000, 0x00e00000);
8471:
8472:
8473:
8474:
8475: busSuper (MemoryMappedDevice.MMD_TXT, 0x00e00000, 0x00e80000);
8476:
8477:
8478:
8479:
8480: busSuper (MemoryMappedDevice.MMD_CRT, 0x00e80000, 0x00e82000);
8481:
8482:
8483:
8484:
8485:
8486: busSuper (MemoryMappedDevice.MMD_VCN, 0x00e82000, 0x00e84000);
8487:
8488:
8489:
8490:
8491: busSuper (MemoryMappedDevice.MMD_DMA, 0x00e84000, 0x00e86000);
8492:
8493:
8494:
8495:
8496: busSuper (MemoryMappedDevice.MMD_SVS, 0x00e86000, 0x00e88000);
8497:
8498:
8499:
8500:
8501: busSuper (MemoryMappedDevice.MMD_MFP, 0x00e88000, 0x00e8a000);
8502:
8503:
8504:
8505:
8506: busSuper (MemoryMappedDevice.MMD_RTC_FIRST, 0x00e8a000, 0x00e8c000);
8507:
8508:
8509:
8510:
8511: busSuper (MemoryMappedDevice.MMD_PRN, 0x00e8c000, 0x00e8e000);
8512:
8513:
8514:
8515:
8516: busSuper (MemoryMappedDevice.MMD_SYS, 0x00e8e000, 0x00e90000);
8517:
8518:
8519:
8520:
8521: busSuper (MemoryMappedDevice.MMD_OPM, 0x00e90000, 0x00e92000);
8522:
8523:
8524:
8525:
8526: busSuper (MemoryMappedDevice.MMD_PCM, 0x00e92000, 0x00e94000);
8527:
8528:
8529:
8530:
8531: busSuper (MemoryMappedDevice.MMD_FDC, 0x00e94000, 0x00e96000);
8532:
8533:
8534:
8535:
8536:
8537: busSuper (MemoryMappedDevice.MMD_HDC, 0x00e96000, 0x00e98000);
8538:
8539:
8540:
8541:
8542: busSuper (MemoryMappedDevice.MMD_SCC, 0x00e98000, 0x00e9a000);
8543:
8544:
8545:
8546:
8547: busSuper (MemoryMappedDevice.MMD_PPI, 0x00e9a000, 0x00e9c000);
8548:
8549:
8550:
8551:
8552: busSuper (MemoryMappedDevice.MMD_IOI, 0x00e9c000, 0x00e9e000);
8553:
8554:
8555:
8556:
8557:
8558:
8559:
8560:
8561:
8562: busSuper (MemoryMappedDevice.MMD_XB1, 0x00e9e000, 0x00ea0000);
8563:
8564:
8565:
8566:
8567:
8568: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ea0000, 0x00eae000);
8569:
8570:
8571:
8572:
8573:
8574:
8575:
8576:
8577:
8578:
8579:
8580:
8581:
8582:
8583:
8584: busSuper (MemoryMappedDevice.MMD_XB2, 0x00eae000, 0x00eb0000);
8585:
8586:
8587:
8588:
8589:
8590:
8591:
8592:
8593: busSuper (MemoryMappedDevice.MMD_SPR, 0x00eb0000, 0x00ec0000);
8594:
8595:
8596:
8597:
8598:
8599:
8600:
8601:
8602:
8603:
8604:
8605:
8606:
8607: busSuper (MemoryMappedDevice.MMD_XB3, 0x00ec0000, 0x00ed0000);
8608:
8609:
8610:
8611:
8612:
8613:
8614: busSuper (MemoryMappedDevice.MMD_SMR, 0x00ed0000, 0x00ed0000 + 16384);
8615: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ed0000 + 16384, 0x00ed0000 + 65536);
8616:
8617:
8618:
8619:
8620:
8621:
8622:
8623:
8624: busSuper (MemoryMappedDevice.MMD_XB4, 0x00ee0000, 0x00f00000);
8625:
8626:
8627:
8628:
8629:
8630:
8631:
8632:
8633:
8634:
8635: busSuper (MemoryMappedDevice.MMD_ROM, 0x00f00000, 0x00f40000);
8636:
8637:
8638:
8639:
8640:
8641:
8642:
8643: busSuper (MemoryMappedDevice.MMD_ROM, 0x00f40000, 0x00fc0000);
8644:
8645:
8646:
8647:
8648:
8649:
8650:
8651:
8652:
8653:
8654:
8655:
8656:
8657:
8658: busSuper (MemoryMappedDevice.MMD_ROM, 0x00fc0000, 0x01000000);
8659:
8660: }
8661:
8662: public static void busReset () {
8663: if (regSRS != 0) {
8664: if (DataBreakPoint.DBP_ON) {
8665: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpSuperMap;
8666: } else {
8667: busMemoryMap = busSuperMap;
8668: }
8669: } else {
8670: if (DataBreakPoint.DBP_ON) {
8671: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpUserMap;
8672: } else {
8673: busMemoryMap = busUserMap;
8674: }
8675: }
8676: }
8677:
8678:
8679:
8680:
8681:
8682: public static void busUser (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8683: if (MC68060.CAT_ON) {
8684: if (Model.MPU_MC68LC060 <= currentMPU) {
8685: mmd = (mmd == MemoryMappedDevice.MMD_MMR ? MemoryMappedDevice.MMD_MM6 :
8686: mmd == MemoryMappedDevice.MMD_ROM ? MemoryMappedDevice.MMD_RO6 :
8687: mmd);
8688: }
8689: }
8690: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8691: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8692: if (false &&
8693: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8694: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8695: System.out.printf ("ERROR: busUser (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8696: }
8697: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8698: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8699: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8700: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8701: int startPage = blockStartPage + motherStartPage;
8702: int endPage = blockStartPage + motherEndPage;
8703: for (int page = startPage; page < endPage; page++) {
8704: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
8705: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
8706: if (MC68060.CAT_ON) {
8707: if (Model.MPU_MC68LC060 <= currentMPU &&
8708: isExMemory) {
8709: superMmd = MemoryMappedDevice.MMD_XM6;
8710: }
8711: }
8712: busUserMap[page] = busSuperMap[page] = superMmd;
8713: if (InstructionBreakPoint.IBP_ON) {
8714: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8715: InstructionBreakPoint.ibpUserMap[page] = superMmd;
8716: }
8717: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8718: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8719: }
8720: }
8721: if (DataBreakPoint.DBP_ON) {
8722: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8723: DataBreakPoint.dbpUserMap[page] = superMmd;
8724: }
8725: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8726: DataBreakPoint.dbpSuperMap[page] = superMmd;
8727: }
8728: }
8729: }
8730: }
8731: }
8732:
8733:
8734:
8735:
8736:
8737: public static void busSuper (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8738: if (MC68060.CAT_ON) {
8739: if (Model.MPU_MC68LC060 <= currentMPU) {
8740: mmd = (mmd == MemoryMappedDevice.MMD_MMR ? MemoryMappedDevice.MMD_MM6 :
8741: mmd == MemoryMappedDevice.MMD_ROM ? MemoryMappedDevice.MMD_RO6 :
8742: mmd);
8743: }
8744: }
8745: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8746: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8747: if (false &&
8748: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8749: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8750: System.out.printf ("ERROR: busSuper (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8751: }
8752: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8753: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8754: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8755: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8756: int startPage = blockStartPage + motherStartPage;
8757: int endPage = blockStartPage + motherEndPage;
8758: for (int page = startPage; page < endPage; page++) {
8759: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
8760: MemoryMappedDevice userMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : busCutFC2Pin ? mmd : MemoryMappedDevice.MMD_NUL;
8761: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
8762: if (MC68060.CAT_ON) {
8763: if (Model.MPU_MC68LC060 <= currentMPU &&
8764: isExMemory) {
8765: userMmd = MemoryMappedDevice.MMD_XM6;
8766: superMmd = MemoryMappedDevice.MMD_XM6;
8767: }
8768: }
8769: busUserMap[page] = userMmd;
8770: busSuperMap[page] = superMmd;
8771: if (InstructionBreakPoint.IBP_ON) {
8772: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8773: InstructionBreakPoint.ibpUserMap[page] = userMmd;
8774: }
8775: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8776: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8777: }
8778: }
8779: if (DataBreakPoint.DBP_ON) {
8780: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8781: DataBreakPoint.dbpUserMap[page] = userMmd;
8782: }
8783: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8784: DataBreakPoint.dbpSuperMap[page] = superMmd;
8785: }
8786: }
8787: }
8788: }
8789: }
8790:
8791:
8792:
8793: public static byte busPbs (int a) {
8794: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a);
8795: }
8796:
8797:
8798:
8799: public static int busPbz (int a) {
8800: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a);
8801: }
8802:
8803:
8804:
8805: public static int busPws (int a) {
8806: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8807: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
8808: } else {
8809: int a1 = a + 1;
8810: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
8811: }
8812: }
8813:
8814:
8815:
8816: public static int busPwse (int a) {
8817: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
8818: }
8819:
8820:
8821:
8822: public static int busPwz (int a) {
8823: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8824: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
8825: } else {
8826: int a1 = a + 1;
8827: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
8828: }
8829: }
8830:
8831:
8832:
8833: public static int busPwze (int a) {
8834: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
8835: }
8836:
8837:
8838:
8839: public static int busPls (int a) {
8840: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8841: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
8842: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8843: int a2 = a + 2;
8844: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a) << 16 | busSuperMap[a2 >>> BUS_PAGE_BITS].mmdPwz (a2);
8845: } else {
8846: int a1 = a + 1;
8847: int a3 = a + 3;
8848: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 24 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPwz (a1) << 8 | busSuperMap[a3 >>> BUS_PAGE_BITS].mmdPbz (a3);
8849: }
8850: }
8851:
8852:
8853:
8854: public static int busPlsf (int a) {
8855: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
8856: }
8857:
8858:
8859:
8860: public static long busPqs (int a) {
8861: return (long) busPls (a) << 32 | busPls (a + 4) & 0xffffffffL;
8862: }
8863:
8864:
8865:
8866: public static int busSearchByte (int start, int end, int c) {
8867: for (int a = start; a < end; a++) {
8868: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) == c) {
8869: return a;
8870: }
8871: }
8872: return -1;
8873: }
8874: public static int busSearchWord (int start, int end, int c) {
8875: for (int a = start; a < end; a += 2) {
8876: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) == c) {
8877: return a;
8878: }
8879: }
8880: return -1;
8881: }
8882: public static int busSearchByteArray (int start, int end, int[] array) {
8883: int l = array.length;
8884: end -= l;
8885: int c = array[0];
8886: a:
8887: for (int a = start; a <= end; a++) {
8888: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) != c) {
8889: continue a;
8890: }
8891: for (int i = 1, b = a + 1; i < l; i++, b++) {
8892: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPbz (b) != array[i]) {
8893: continue a;
8894: }
8895: }
8896: return a;
8897: }
8898: return -1;
8899: }
8900: public static int busSearchWordArray (int start, int end, int[] array) {
8901: int l = array.length;
8902: end -= l;
8903: int c = array[0];
8904: a:
8905: for (int a = start; a <= end; a += 2) {
8906: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) != c) {
8907: continue a;
8908: }
8909: for (int i = 1, b = a + 2; i < l; i++, b += 2) {
8910: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPwz (b) != array[i]) {
8911: continue a;
8912: }
8913: }
8914: return a;
8915: }
8916: return -1;
8917: }
8918:
8919:
8920:
8921:
8922: public static byte busRbs (int a) throws M68kException {
8923: if (DataBreakPoint.DBP_ON) {
8924: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
8925: } else {
8926: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
8927: }
8928: }
8929:
8930:
8931:
8932: public static int busRbz (int a) throws M68kException {
8933: if (DataBreakPoint.DBP_ON) {
8934: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
8935: } else {
8936: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
8937: }
8938: }
8939:
8940:
8941:
8942: public static int busRws (int a) throws M68kException {
8943: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8944: if (DataBreakPoint.DBP_ON) {
8945: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8946: } else {
8947: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8948: }
8949: } else if (mpuIgnoreAddressError) {
8950: int a1 = a + 1;
8951: if (DataBreakPoint.DBP_ON) {
8952: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8953: } else {
8954: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8955: }
8956: } else {
8957: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8958: M68kException.m6eAddress = a;
8959: M68kException.m6eDirection = MPU_WR_READ;
8960: M68kException.m6eSize = MPU_SS_WORD;
8961: throw M68kException.m6eSignal;
8962: }
8963: }
8964:
8965:
8966:
8967:
8968: public static int busRwse (int a) throws M68kException {
8969: if (DataBreakPoint.DBP_ON) {
8970: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8971: } else {
8972: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8973: }
8974: }
8975:
8976:
8977:
8978: public static int busRwz (int a) throws M68kException {
8979: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8980: if (DataBreakPoint.DBP_ON) {
8981: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8982: } else {
8983: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8984: }
8985: } else if (mpuIgnoreAddressError) {
8986: int a1 = a + 1;
8987: if (DataBreakPoint.DBP_ON) {
8988: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8989: } else {
8990: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8991: }
8992: } else {
8993: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8994: M68kException.m6eAddress = a;
8995: M68kException.m6eDirection = MPU_WR_READ;
8996: M68kException.m6eSize = MPU_SS_WORD;
8997: throw M68kException.m6eSignal;
8998: }
8999: }
9000:
9001:
9002:
9003:
9004: public static int busRwze (int a) throws M68kException {
9005: if (DataBreakPoint.DBP_ON) {
9006: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9007: } else {
9008: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9009: }
9010: }
9011:
9012:
9013:
9014: public static int busRls (int a) throws M68kException {
9015: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9016: if (DataBreakPoint.DBP_ON) {
9017: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9018: } else {
9019: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9020: }
9021: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9022: int a2 = a + 2;
9023: if (BUS_SPLIT_UNALIGNED_LONG) {
9024: if (DataBreakPoint.DBP_ON) {
9025: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9026: } else {
9027: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9028: }
9029: } else {
9030: MemoryMappedDevice mmd;
9031: MemoryMappedDevice mmd2;
9032: if (DataBreakPoint.DBP_ON) {
9033: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9034: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9035: } else {
9036: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9037: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9038: }
9039: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
9040: }
9041: } else if (mpuIgnoreAddressError) {
9042: int a1 = a + 1;
9043: int a3 = a + 3;
9044: if (DataBreakPoint.DBP_ON) {
9045: 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);
9046: } else {
9047: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 24 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRwz (a1) << 8 | busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdRbz (a3);
9048: }
9049: } else {
9050: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9051: M68kException.m6eAddress = a;
9052: M68kException.m6eDirection = MPU_WR_READ;
9053: M68kException.m6eSize = MPU_SS_LONG;
9054: throw M68kException.m6eSignal;
9055: }
9056: }
9057:
9058:
9059:
9060:
9061: public static int busRlse (int a) throws M68kException {
9062: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9063: if (DataBreakPoint.DBP_ON) {
9064: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9065: } else {
9066: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9067: }
9068: } else {
9069: int a2 = a + 2;
9070: if (BUS_SPLIT_UNALIGNED_LONG) {
9071: if (DataBreakPoint.DBP_ON) {
9072: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9073: } else {
9074: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9075: }
9076: } else {
9077: MemoryMappedDevice mmd;
9078: MemoryMappedDevice mmd2;
9079: if (DataBreakPoint.DBP_ON) {
9080: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9081: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9082: } else {
9083: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9084: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9085: }
9086: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
9087: }
9088: }
9089: }
9090:
9091:
9092:
9093:
9094: public static int busRlsf (int a) throws M68kException {
9095: if (DataBreakPoint.DBP_ON) {
9096: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9097: } else {
9098: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9099: }
9100: }
9101:
9102:
9103:
9104: public static long busRqs (int a) throws M68kException {
9105: return (long) busRls (a) << 32 | busRls (a + 4) & 0xffffffffL;
9106: }
9107:
9108:
9109:
9110: public static void busWb (int a, int d) throws M68kException {
9111: if (DataBreakPoint.DBP_ON) {
9112: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9113: } else {
9114: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9115: }
9116: }
9117:
9118:
9119:
9120: public static void busWw (int a, int d) throws M68kException {
9121: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9122: if (DataBreakPoint.DBP_ON) {
9123: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9124: } else {
9125: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9126: }
9127: } else if (mpuIgnoreAddressError) {
9128: int a1 = a + 1;
9129: if (DataBreakPoint.DBP_ON) {
9130: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
9131: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
9132: } else {
9133: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
9134: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
9135: }
9136: } else {
9137: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9138: M68kException.m6eAddress = a;
9139: M68kException.m6eDirection = MPU_WR_WRITE;
9140: M68kException.m6eSize = MPU_SS_WORD;
9141: throw M68kException.m6eSignal;
9142: }
9143: }
9144:
9145:
9146:
9147:
9148: public static void busWwe (int a, int d) throws M68kException {
9149: if (DataBreakPoint.DBP_ON) {
9150: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9151: } else {
9152: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9153: }
9154: }
9155:
9156:
9157:
9158: public static void busWl (int a, int d) throws M68kException {
9159: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9160: if (DataBreakPoint.DBP_ON) {
9161: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9162: } else {
9163: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9164: }
9165: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9166: int a2 = a + 2;
9167: if (BUS_SPLIT_UNALIGNED_LONG) {
9168: if (DataBreakPoint.DBP_ON) {
9169: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9170: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9171: } else {
9172: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9173: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9174: }
9175: } else {
9176: MemoryMappedDevice mmd;
9177: MemoryMappedDevice mmd2;
9178: if (DataBreakPoint.DBP_ON) {
9179: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9180: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9181: } else {
9182: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9183: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9184: }
9185: if (mmd == mmd2) {
9186: mmd.mmdWl (a, d);
9187: } else {
9188: mmd.mmdWw (a, d >> 16);
9189: mmd2.mmdWw (a2, d);
9190: }
9191: }
9192: } else if (mpuIgnoreAddressError) {
9193: int a1 = a + 1;
9194: int a3 = a + 3;
9195: if (DataBreakPoint.DBP_ON) {
9196: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
9197: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
9198: DataBreakPoint.dbpMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
9199: } else {
9200: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
9201: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
9202: busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
9203: }
9204: } else {
9205: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9206: M68kException.m6eAddress = a;
9207: M68kException.m6eDirection = MPU_WR_WRITE;
9208: M68kException.m6eSize = MPU_SS_LONG;
9209: throw M68kException.m6eSignal;
9210: }
9211: }
9212:
9213:
9214:
9215:
9216: public static void busWlf (int a, int d) throws M68kException {
9217: if (DataBreakPoint.DBP_ON) {
9218: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9219: } else {
9220: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9221: }
9222: }
9223:
9224:
9225:
9226:
9227: public static void busWle (int a, int d) throws M68kException {
9228: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9229: if (DataBreakPoint.DBP_ON) {
9230: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9231: } else {
9232: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9233: }
9234: } else {
9235: int a2 = a + 2;
9236: if (BUS_SPLIT_UNALIGNED_LONG) {
9237: if (DataBreakPoint.DBP_ON) {
9238: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9239: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9240: } else {
9241: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9242: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9243: }
9244: } else {
9245: MemoryMappedDevice mmd;
9246: MemoryMappedDevice mmd2;
9247: if (DataBreakPoint.DBP_ON) {
9248: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9249: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9250: } else {
9251: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9252: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9253: }
9254: if (mmd == mmd2) {
9255: mmd.mmdWl (a, d);
9256: } else {
9257: mmd.mmdWw (a, d >> 16);
9258: mmd2.mmdWw (a2, d);
9259: }
9260: }
9261: }
9262: }
9263:
9264:
9265:
9266: public static void busWq (int a, long d) throws M68kException {
9267: busWl (a, (int) (d >>> 32));
9268: busWl (a + 4, (int) d);
9269: }
9270:
9271:
9272:
9273:
9274:
9275: public static void busRbb (int a, byte[] bb, int o, int l) throws M68kException {
9276: if (false) {
9277: for (int i = 0; i < l; i++) {
9278: int ai = a + i;
9279: if (DataBreakPoint.DBP_ON) {
9280: bb[o + i] = DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9281: } else {
9282: bb[o + i] = busMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9283: }
9284: }
9285: } else {
9286: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9287: while (l > 0) {
9288: MemoryMappedDevice mmd;
9289: if (DataBreakPoint.DBP_ON) {
9290: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9291: } else {
9292: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9293: }
9294: int s = l <= r ? l : r;
9295: l -= s;
9296: if (true) {
9297: for (s -= 16; s >= 0; s -= 16) {
9298: bb[o ] = mmd.mmdRbs (a );
9299: bb[o + 1] = mmd.mmdRbs (a + 1);
9300: bb[o + 2] = mmd.mmdRbs (a + 2);
9301: bb[o + 3] = mmd.mmdRbs (a + 3);
9302: bb[o + 4] = mmd.mmdRbs (a + 4);
9303: bb[o + 5] = mmd.mmdRbs (a + 5);
9304: bb[o + 6] = mmd.mmdRbs (a + 6);
9305: bb[o + 7] = mmd.mmdRbs (a + 7);
9306: bb[o + 8] = mmd.mmdRbs (a + 8);
9307: bb[o + 9] = mmd.mmdRbs (a + 9);
9308: bb[o + 10] = mmd.mmdRbs (a + 10);
9309: bb[o + 11] = mmd.mmdRbs (a + 11);
9310: bb[o + 12] = mmd.mmdRbs (a + 12);
9311: bb[o + 13] = mmd.mmdRbs (a + 13);
9312: bb[o + 14] = mmd.mmdRbs (a + 14);
9313: bb[o + 15] = mmd.mmdRbs (a + 15);
9314: a += 16;
9315: o += 16;
9316: }
9317: s += 16;
9318: }
9319: for (int i = 0; i < s; i++) {
9320: bb[o + i] = mmd.mmdRbs (a + i);
9321: }
9322: a += s;
9323: o += s;
9324: r = BUS_PAGE_SIZE;
9325: }
9326: }
9327: }
9328:
9329:
9330:
9331: public static void busWbb (int a, byte[] bb, int o, int l) throws M68kException {
9332: if (false) {
9333: for (int i = 0; i < l; i++) {
9334: int ai = a + i;
9335: if (DataBreakPoint.DBP_ON) {
9336: DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9337: } else {
9338: busMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9339: }
9340: }
9341: } else {
9342: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9343: while (l > 0) {
9344: MemoryMappedDevice mmd;
9345: if (DataBreakPoint.DBP_ON) {
9346: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9347: } else {
9348: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9349: }
9350: int s = l <= r ? l : r;
9351: l -= s;
9352: if (true) {
9353: for (s -= 16; s >= 0; s -= 16) {
9354: mmd.mmdWb (a , bb[o ]);
9355: mmd.mmdWb (a + 1, bb[o + 1]);
9356: mmd.mmdWb (a + 2, bb[o + 2]);
9357: mmd.mmdWb (a + 3, bb[o + 3]);
9358: mmd.mmdWb (a + 4, bb[o + 4]);
9359: mmd.mmdWb (a + 5, bb[o + 5]);
9360: mmd.mmdWb (a + 6, bb[o + 6]);
9361: mmd.mmdWb (a + 7, bb[o + 7]);
9362: mmd.mmdWb (a + 8, bb[o + 8]);
9363: mmd.mmdWb (a + 9, bb[o + 9]);
9364: mmd.mmdWb (a + 10, bb[o + 10]);
9365: mmd.mmdWb (a + 11, bb[o + 11]);
9366: mmd.mmdWb (a + 12, bb[o + 12]);
9367: mmd.mmdWb (a + 13, bb[o + 13]);
9368: mmd.mmdWb (a + 14, bb[o + 14]);
9369: mmd.mmdWb (a + 15, bb[o + 15]);
9370: a += 16;
9371: o += 16;
9372: }
9373: s += 16;
9374: }
9375: for (int i = 0; i < s; i++) {
9376: mmd.mmdWb (a + i, bb[o + i]);
9377: }
9378: a += s;
9379: o += s;
9380: r = BUS_PAGE_SIZE;
9381: }
9382: }
9383: }
9384:
9385:
9386:
9387: public static void busVb (int a, int d) {
9388: try {
9389: if (DataBreakPoint.DBP_ON) {
9390: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9391: } else {
9392: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9393: }
9394: } catch (M68kException e) {
9395: }
9396: }
9397:
9398:
9399:
9400: public static void busVw (int a, int d) {
9401: try {
9402: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9403: if (DataBreakPoint.DBP_ON) {
9404: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9405: } else {
9406: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9407: }
9408: }
9409: } catch (M68kException e) {
9410: }
9411: }
9412:
9413:
9414:
9415: public static void busVl (int a, int d) {
9416: try {
9417: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9418: if (DataBreakPoint.DBP_ON) {
9419: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9420: } else {
9421: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9422: }
9423: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9424: int a2 = a + 2;
9425: MemoryMappedDevice mmd;
9426: MemoryMappedDevice mmd2;
9427: if (DataBreakPoint.DBP_ON) {
9428: mmd = (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS];
9429: mmd2 = (regSRS != 0 ? busSuperMap : busUserMap)[a2 >>> BUS_PAGE_BITS];
9430: } else {
9431: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9432: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9433: }
9434: if (mmd == mmd2) {
9435: mmd.mmdWl (a, d);
9436: } else {
9437: mmd.mmdWw (a, d >> 16);
9438: mmd2.mmdWw (a2, d);
9439: }
9440: }
9441: } catch (M68kException e) {
9442: }
9443: }
9444:
9445:
9446:
9447:
9448:
9449: public static final int SVS_AREASET = 0x00e86001;
9450:
9451:
9452:
9453:
9454:
9455:
9456:
9457:
9458:
9459: public static void svsInit () {
9460: }
9461:
9462:
9463:
9464:
9465:
9466:
9467:
9468:
9469:
9470:
9471:
9472:
9473:
9474:
9475:
9476:
9477:
9478:
9479:
9480:
9481:
9482:
9483:
9484:
9485:
9486:
9487:
9488:
9489:
9490:
9491:
9492:
9493:
9494:
9495:
9496: public static boolean sysNMIFlag;
9497:
9498:
9499:
9500: public static void sysInit () {
9501: sysNMIFlag = false;
9502: }
9503:
9504:
9505:
9506:
9507:
9508:
9509: public static int sysAcknowledge () {
9510: return M68kException.M6E_LEVEL_7_INTERRUPT_AUTOVECTOR;
9511: }
9512:
9513:
9514:
9515:
9516: public static void sysDone () {
9517: if (sysNMIFlag) {
9518: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9519: }
9520: }
9521:
9522:
9523:
9524: public static void sysInterrupt () {
9525: sysNMIFlag = true;
9526: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9527: }
9528:
9529:
9530:
9531: public static void sysResetNMI () {
9532: sysNMIFlag = false;
9533: }
9534:
9535:
9536:
9537:
9538:
9539:
9540: public static final int EB2_SPC_REQUEST = 0x4000;
9541: public static final int EB2_SPC_VECTOR = 0xf6;
9542:
9543:
9544:
9545: public static int eb2Request;
9546:
9547:
9548:
9549: public static void eb2Reset () {
9550: eb2Request = 0;
9551: }
9552:
9553:
9554:
9555:
9556:
9557: public static void eb2Interrupt (int mask) {
9558: eb2Request |= mask;
9559: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9560: }
9561:
9562:
9563:
9564:
9565:
9566:
9567:
9568: public static int eb2Acknowledge () {
9569: if ((eb2Request & EB2_SPC_REQUEST) != 0) {
9570: eb2Request &= ~EB2_SPC_REQUEST;
9571: return EB2_SPC_VECTOR;
9572: }
9573: return 0;
9574: }
9575:
9576:
9577:
9578:
9579:
9580: public static void eb2Done () {
9581: if (eb2Request != 0) {
9582: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9583: }
9584: }
9585:
9586:
9587:
9588:
9589:
9590:
9591:
9592:
9593:
9594:
9595:
9596:
9597:
9598:
9599:
9600:
9601:
9602:
9603:
9604:
9605:
9606:
9607:
9608:
9609:
9610:
9611:
9612:
9613:
9614:
9615:
9616:
9617:
9618:
9619:
9620:
9621:
9622:
9623:
9624:
9625:
9626:
9627:
9628:
9629:
9630:
9631:
9632:
9633:
9634:
9635:
9636:
9637:
9638:
9639:
9640:
9641:
9642:
9643:
9644:
9645:
9646:
9647:
9648:
9649: public static final int BNK_SIZE = 1024 * 1024 * 32;
9650: public static byte[] bnkMemory;
9651: public static int bnkPageStart;
9652: public static boolean bnkOn;
9653:
9654: public static void bnkInit () {
9655: bnkMemory = new byte[BNK_SIZE];
9656: byte[] array = Settings.sgsGetData ("bankdata");
9657: if (array.length != 0) {
9658: System.arraycopy (array, 0, bnkMemory, 0, Math.min (array.length, BNK_SIZE));
9659: }
9660: bnkPageStart = 0;
9661:
9662: bnkOn = false;
9663: }
9664:
9665: public static void bnkTini () {
9666: Settings.sgsPutData ("bankdata", bnkMemory, 0, BNK_SIZE);
9667: }
9668:
9669:
9670:
9671:
9672:
9673:
9674:
9675: public static ExpressionEvaluator fpuMotherboardCoprocessor;
9676: public static ExpressionEvaluator fpuOnChipFPU;
9677: public static ExpressionEvaluator fpuBox;
9678:
9679:
9680: public static EFPBox fpuCoproboard1;
9681: public static EFPBox fpuCoproboard2;
9682:
9683:
9684: public static EFPBox.EFP[] fpuFPn;
9685:
9686:
9687:
9688: public static final int FPU_FPCR_BSUN = 0b00000000_00000000_10000000_00000000;
9689: public static final int FPU_FPCR_SNAN = 0b00000000_00000000_01000000_00000000;
9690: public static final int FPU_FPCR_OPERR = 0b00000000_00000000_00100000_00000000;
9691: public static final int FPU_FPCR_OVFL = 0b00000000_00000000_00010000_00000000;
9692: public static final int FPU_FPCR_UNFL = 0b00000000_00000000_00001000_00000000;
9693: public static final int FPU_FPCR_DZ = 0b00000000_00000000_00000100_00000000;
9694: public static final int FPU_FPCR_INEX2 = 0b00000000_00000000_00000010_00000000;
9695: public static final int FPU_FPCR_INEX1 = 0b00000000_00000000_00000001_00000000;
9696:
9697:
9698: public static final int FPU_FPCR_PE = 0b00000000_00000000_00000000_00000000;
9699: public static final int FPU_FPCR_PS = 0b00000000_00000000_00000000_01000000;
9700: public static final int FPU_FPCR_PD = 0b00000000_00000000_00000000_10000000;
9701:
9702: public static final int FPU_FPCR_RN = 0b00000000_00000000_00000000_00000000;
9703: public static final int FPU_FPCR_RZ = 0b00000000_00000000_00000000_00010000;
9704: public static final int FPU_FPCR_RM = 0b00000000_00000000_00000000_00100000;
9705: public static final int FPU_FPCR_RP = 0b00000000_00000000_00000000_00110000;
9706:
9707:
9708:
9709: public static final int FPU_FPSR_N = 0b00001000_00000000_00000000_00000000;
9710: public static final int FPU_FPSR_Z = 0b00000100_00000000_00000000_00000000;
9711: public static final int FPU_FPSR_I = 0b00000010_00000000_00000000_00000000;
9712: public static final int FPU_FPSR_NAN = 0b00000001_00000000_00000000_00000000;
9713:
9714: public static final int FPU_FPSR_S = 0b00000000_10000000_00000000_00000000;
9715: public static final int FPU_FPSR_QUOTIENT = 0b00000000_01111111_00000000_00000000;
9716:
9717: public static final int FPU_FPSR_EXC_BSUN = 0b00000000_00000000_10000000_00000000;
9718: public static final int FPU_FPSR_EXC_SNAN = 0b00000000_00000000_01000000_00000000;
9719: public static final int FPU_FPSR_EXC_OPERR = 0b00000000_00000000_00100000_00000000;
9720: public static final int FPU_FPSR_EXC_OVFL = 0b00000000_00000000_00010000_00000000;
9721: public static final int FPU_FPSR_EXC_UNFL = 0b00000000_00000000_00001000_00000000;
9722: public static final int FPU_FPSR_EXC_DZ = 0b00000000_00000000_00000100_00000000;
9723: public static final int FPU_FPSR_EXC_INEX2 = 0b00000000_00000000_00000010_00000000;
9724: public static final int FPU_FPSR_EXC_INEX1 = 0b00000000_00000000_00000001_00000000;
9725:
9726: public static final int FPU_FPSR_AEXC_IOP = 0b00000000_00000000_00000000_10000000;
9727: public static final int FPU_FPSR_AEXC_OVFL = 0b00000000_00000000_00000000_01000000;
9728: public static final int FPU_FPSR_AEXC_UNFL = 0b00000000_00000000_00000000_00100000;
9729: public static final int FPU_FPSR_AEXC_DZ = 0b00000000_00000000_00000000_00010000;
9730: public static final int FPU_FPSR_AEXC_INEX = 0b00000000_00000000_00000000_00001000;
9731:
9732:
9733:
9734:
9735:
9736:
9737:
9738: public static final int[] FPU_FPSR_EXC_TO_AEXC = new int[256];
9739:
9740:
9741:
9742:
9743:
9744:
9745:
9746:
9747:
9748:
9749:
9750:
9751:
9752:
9753:
9754:
9755:
9756:
9757:
9758:
9759:
9760:
9761:
9762:
9763: public static final boolean[] FPU_CCMAP_882 = {
9764:
9765:
9766: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9767: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9768: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9769: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9770: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9771: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9772: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9773: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9774: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9775: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9776: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9777: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9778: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9779: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9780: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9781: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9782:
9783:
9784: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9785: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9786: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9787: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9788: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9789: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9790: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9791: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9792: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9793: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9794: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9795: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9796: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9797: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9798: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9799: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9800:
9801: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9802: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9803: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9804: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9805: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9806: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9807: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9808: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9809: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9810: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9811: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9812: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9813: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9814: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9815: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9816: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9817:
9818: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9819: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9820: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9821: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9822: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9823: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9824: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9825: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9826: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9827: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9828: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9829: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9830: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9831: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9832: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9833: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9834: };
9835:
9836:
9837:
9838:
9839:
9840:
9841:
9842: public static final boolean[] FPU_CCMAP_060 = {
9843:
9844:
9845: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9846: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9847: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9848: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9849: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9850: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9851: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9852: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9853: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9854: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9855: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9856: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9857: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9858: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9859: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9860: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9861:
9862:
9863: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9864: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9865: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9866: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9867: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9868: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9869: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9870: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9871: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9872: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9873: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9874: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9875: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9876: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9877: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9878: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9879:
9880: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9881: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9882: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9883: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9884: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9885: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9886: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9887: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9888: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9889: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9890: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9891: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9892: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9893: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9894: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9895: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9896:
9897: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9898: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9899: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9900: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9901: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9902: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9903: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9904: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9905: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9906: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9907: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9908: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9909: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9910: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9911: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9912: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9913: };
9914:
9915:
9916:
9917:
9918: public static void fpuInit () {
9919: for (int i = 0; i < 256; i++) {
9920: 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) |
9921: ((i << 8 & FPU_FPSR_EXC_OVFL) != 0 ? FPU_FPSR_AEXC_OVFL : 0) |
9922: ((i << 8 & (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2)) == (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2) ? FPU_FPSR_AEXC_UNFL : 0) |
9923: ((i << 8 & FPU_FPSR_EXC_DZ) != 0 ? FPU_FPSR_AEXC_DZ : 0) |
9924: ((i << 8 & (FPU_FPSR_EXC_OVFL | FPU_FPSR_EXC_INEX2 | FPU_FPSR_EXC_INEX1)) != 0 ? FPU_FPSR_AEXC_INEX : 0));
9925: }
9926:
9927: fpuMotherboardCoprocessor = new ExpressionEvaluator ();
9928:
9929: fpuOnChipFPU = new ExpressionEvaluator ();
9930:
9931: fpuBox = currentMPU < Model.MPU_MC68LC040 ? fpuMotherboardCoprocessor : fpuOnChipFPU;
9932:
9933: fpuFPn = fpuBox.epbFPn;
9934:
9935: fpuCoproboard1 = new EFPBox ();
9936: fpuCoproboard2 = new EFPBox ();
9937: }
9938:
9939:
9940:
9941:
9942:
9943:
9944: public static final boolean DBG_ORI_BYTE_ZERO_D0 = true;
9945:
9946: public static boolean dbgHexSelected;
9947: public static int dbgHexValue;
9948: public static int dbgSupervisorMode;
9949: public static JPopupMenu dbgPopupMenu;
9950: public static JMenu dbgPopupIBPMenu;
9951: public static SpinnerNumberModel dbgPopupIBPCurrentModel;
9952: public static int dbgPopupIBPCurrentValue;
9953: public static SpinnerNumberModel dbgPopupIBPThresholdModel;
9954: public static int dbgPopupIBPThresholdValue;
9955: public static JMenuItem dbgPopupIBPClearMenuItem;
9956: public static JMenu dbgPopupHexMenu;
9957: public static JMenuItem dbgPopupDisMenuItem;
9958: public static JMenuItem dbgPopupMemMenuItem;
9959: public static JMenuItem dbgPopupCopyMenuItem;
9960: public static JMenuItem dbgPopupSelectAllMenuItem;
9961: public static JTextArea dbgPopupTextArea;
9962: public static int dbgEventMask;
9963: public static boolean dbgStopOnError;
9964: public static boolean dbgOriByteZeroD0;
9965: public static boolean dbgStopAtStart;
9966:
9967:
9968:
9969: public static final char[] DBG_SPACES = (
9970:
9971:
9972: " ").toCharArray ();
9973:
9974: public static final int DBG_DRP_VISIBLE_MASK = 1;
9975: public static final int DBG_DDP_VISIBLE_MASK = 2;
9976: public static final int DBG_DMP_VISIBLE_MASK = 4;
9977: public static final int DBG_BLG_VISIBLE_MASK = 8;
9978: public static final int DBG_PFV_VISIBLE_MASK = 16;
9979: public static final int DBG_RBP_VISIBLE_MASK = 32;
9980: public static final int DBG_DBP_VISIBLE_MASK = 64;
9981: public static final int DBG_SMT_VISIBLE_MASK = 128;
9982: public static final int DBG_ATW_VISIBLE_MASK = 256;
9983: public static final int DBG_PAA_VISIBLE_MASK = 512;
9984: public static final int DBG_RTL_VISIBLE_MASK = 1024;
9985: public static final int DBG_SPV_VISIBLE_MASK = 2048;
9986: public static final int DBG_PLV_VISIBLE_MASK = 4096;
9987: public static final int DBG_ACM_VISIBLE_MASK = 8192;
9988: public static int dbgVisibleMask;
9989:
9990:
9991:
9992: public static void dbgInit () {
9993: dbgVisibleMask = 0;
9994: dbgHexSelected = false;
9995: dbgHexValue = 0;
9996: dbgSupervisorMode = 1;
9997: dbgPopupMenu = null;
9998: dbgPopupDisMenuItem = null;
9999: dbgPopupMemMenuItem = null;
10000: dbgPopupCopyMenuItem = null;
10001: dbgPopupSelectAllMenuItem = null;
10002: dbgPopupIBPMenu = null;
10003: dbgPopupIBPCurrentModel = null;
10004: dbgPopupIBPCurrentValue = 0;
10005: dbgPopupIBPThresholdModel = null;
10006: dbgPopupIBPThresholdValue = 0;
10007: dbgPopupHexMenu = null;
10008: dbgPopupTextArea = null;
10009: dbgEventMask = 0;
10010: dbgStopOnError = false;
10011: if (DBG_ORI_BYTE_ZERO_D0) {
10012: dbgOriByteZeroD0 = false;
10013: }
10014: dbgStopAtStart = false;
10015: }
10016:
10017:
10018:
10019: public static void dbgMakePopup () {
10020:
10021:
10022: ActionListener popupActionListener = new ActionListener () {
10023: @Override public void actionPerformed (ActionEvent ae) {
10024: switch (ae.getActionCommand ()) {
10025: case "Disassemble":
10026: DisassembleList.ddpBacktraceRecord = -1L;
10027: DisassembleList.ddpOpen (dbgHexValue, dbgSupervisorMode, false);
10028: break;
10029: case "Memory Dump":
10030: MemoryDumpList.dmpOpen (dbgHexValue, dbgSupervisorMode != 0 ? 5 : 1, false);
10031: break;
10032: case "Run to Here":
10033: if (InstructionBreakPoint.IBP_ON) {
10034: if (mpuTask == null) {
10035: InstructionBreakPoint.ibpInstant (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
10036: mpuStart ();
10037: }
10038: }
10039: break;
10040: case "Set Breakpoint":
10041: if (InstructionBreakPoint.IBP_ON) {
10042: InstructionBreakPoint.ibpPut (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode, dbgPopupIBPCurrentValue, dbgPopupIBPThresholdValue, null);
10043: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
10044: }
10045: break;
10046: case "Clear Breakpoint":
10047: if (InstructionBreakPoint.IBP_ON) {
10048: InstructionBreakPoint.ibpRemove (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
10049: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
10050: }
10051: break;
10052: case "Copy":
10053: dbgCopy ();
10054: break;
10055: case "Select All":
10056: dbgSelectAll ();
10057: break;
10058: }
10059: }
10060: };
10061: dbgPopupMenu = ComponentFactory.createPopupMenu (
10062: dbgPopupIBPMenu =
10063: InstructionBreakPoint.IBP_ON ?
10064: ComponentFactory.createMenu (
10065: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
10066: Multilingual.mlnText (ComponentFactory.createMenuItem ("Run to Here", 'R', popupActionListener), "ja", "ここまで実行"),
10067: ComponentFactory.createHorizontalSeparator (),
10068: Multilingual.mlnText (ComponentFactory.createMenuItem ("Set Breakpoint", 'S', popupActionListener), "ja", "ブレークポイントを設定"),
10069: ComponentFactory.createHorizontalBox (
10070: Box.createHorizontalStrut (7),
10071: Box.createHorizontalGlue (),
10072: ComponentFactory.setPreferredSize (
10073: Multilingual.mlnText (ComponentFactory.createLabel ("current"), "ja", "現在値"),
10074: 60, 16),
10075: ComponentFactory.createNumberSpinner (dbgPopupIBPCurrentModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
10076: @Override public void stateChanged (ChangeEvent ce) {
10077: dbgPopupIBPCurrentValue = dbgPopupIBPCurrentModel.getNumber ().intValue ();
10078: }
10079: }),
10080: Box.createHorizontalGlue ()
10081: ),
10082: ComponentFactory.createHorizontalBox (
10083: Box.createHorizontalStrut (7),
10084: Box.createHorizontalGlue (),
10085: ComponentFactory.setPreferredSize (
10086: Multilingual.mlnText (ComponentFactory.createLabel ("threshold"), "ja", "閾値"),
10087: 60, 16),
10088: ComponentFactory.createNumberSpinner (dbgPopupIBPThresholdModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
10089: @Override public void stateChanged (ChangeEvent ce) {
10090: dbgPopupIBPThresholdValue = dbgPopupIBPThresholdModel.getNumber ().intValue ();
10091: }
10092: }),
10093: Box.createHorizontalGlue ()
10094: ),
10095: dbgPopupIBPClearMenuItem =
10096: Multilingual.mlnText (ComponentFactory.createMenuItem ("Clear Breakpoint", 'C', popupActionListener), "ja", "ブレークポイントを消去")
10097: ) :
10098: null,
10099: dbgPopupHexMenu =
10100: ComponentFactory.createMenu (
10101: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
10102: dbgPopupDisMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble", 'D', popupActionListener), "ja", "逆アセンブル"),
10103: dbgPopupMemMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory Dump", 'M', popupActionListener), "ja", "メモリダンプ")
10104: ),
10105: dbgPopupCopyMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Copy", 'C', popupActionListener), "ja", "コピー"),
10106: dbgPopupSelectAllMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Select All", 'A', popupActionListener), "ja", "すべて選択")
10107: );
10108:
10109: }
10110:
10111:
10112:
10113: public static void dbgShowPopup (MouseEvent me, JTextArea textArea, boolean dis) {
10114: dbgEventMask++;
10115: int x = me.getX ();
10116: int y = me.getY ();
10117:
10118: int p = textArea.viewToModel2D (me.getPoint ());
10119: DisassembleList.ddpPopupAddress = -1;
10120: if (dis) {
10121: int i = Arrays.binarySearch (DisassembleList.ddpSplitArray, 1, DisassembleList.ddpItemCount, p + 1);
10122: i = (i >> 31 ^ i) - 1;
10123: DisassembleList.ddpPopupAddress = DisassembleList.ddpAddressArray[i];
10124: }
10125: int start = textArea.getSelectionStart ();
10126: int end = textArea.getSelectionEnd ();
10127: String text = textArea.getText ();
10128: int length = text.length ();
10129: if ((start == end ||
10130: p < start || end <= p) &&
10131: 0 <= p && p < length && isWord (text.charAt (p))) {
10132:
10133: for (start = p; 0 < start && isWord (text.charAt (start - 1)); start--) {
10134: }
10135: for (end = p + 1; end < length && isWord (text.charAt (end)); end++) {
10136: }
10137: textArea.select (start, end);
10138: }
10139: dbgHexSelected = false;
10140: if (start < end) {
10141: textArea.requestFocusInWindow ();
10142:
10143:
10144:
10145:
10146:
10147: dbgHexValue = 0;
10148: int n = 0;
10149: for (int i = start; i < end; i++) {
10150: int t;
10151: if ((t = Character.digit (text.charAt (i), 16)) >= 0) {
10152: dbgHexValue = dbgHexValue << 4 | t;
10153: if (n >= 8 ||
10154: i + 1 >= end || (t = Character.digit (text.charAt (i + 1), 16)) < 0) {
10155: n = 0;
10156: break;
10157: }
10158: dbgHexValue = dbgHexValue << 4 | t;
10159: n += 2;
10160: i++;
10161: } else if (isWord (text.charAt (i))) {
10162: n = 0;
10163: break;
10164: }
10165: }
10166: dbgHexSelected = n > 0;
10167: try {
10168:
10169: Rectangle r = textArea.modelToView2D (start).getBounds ();
10170:
10171: Rectangle s = textArea.modelToView2D (end - 1).getBounds ();
10172: if (r.y == s.y) {
10173:
10174: y = r.y + r.height;
10175: }
10176: } catch (BadLocationException ble) {
10177: }
10178: }
10179:
10180: if (InstructionBreakPoint.IBP_ON) {
10181: if (dis && mpuTask == null && DisassembleList.ddpPopupAddress != -1) {
10182: ComponentFactory.setText (dbgPopupIBPMenu, fmtHex8 (DisassembleList.ddpPopupAddress));
10183: TreeMap<Integer,InstructionBreakPoint.InstructionBreakRecord> pointTable = InstructionBreakPoint.ibpPointTable;
10184: InstructionBreakPoint.InstructionBreakRecord r = pointTable.get (DisassembleList.ddpPopupAddress);
10185: if (r != null) {
10186: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = r.ibrValue));
10187: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = r.ibrThreshold));
10188: dbgPopupIBPClearMenuItem.setEnabled (true);
10189: } else {
10190: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = 0));
10191: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = 0));
10192: dbgPopupIBPClearMenuItem.setEnabled (false);
10193: }
10194: ComponentFactory.setVisible (dbgPopupIBPMenu, true);
10195: } else {
10196: ComponentFactory.setVisible (dbgPopupIBPMenu, false);
10197: }
10198: }
10199:
10200: if (dbgHexSelected) {
10201: ComponentFactory.setText (dbgPopupHexMenu, fmtHex8 (dbgHexValue));
10202: ComponentFactory.setVisible (dbgPopupHexMenu, true);
10203: } else {
10204: ComponentFactory.setVisible (dbgPopupHexMenu, false);
10205: }
10206:
10207: ComponentFactory.setEnabled (dbgPopupCopyMenuItem, clpClipboard != null && start < end);
10208:
10209: ComponentFactory.setEnabled (dbgPopupSelectAllMenuItem, clpClipboard != null);
10210:
10211: dbgPopupTextArea = textArea;
10212: dbgPopupMenu.show (textArea, x, y);
10213: dbgEventMask--;
10214: }
10215:
10216: public static boolean isWord (char c) {
10217: return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '_';
10218: }
10219:
10220:
10221:
10222: public static void dbgCopy () {
10223: clpCopy (dbgPopupTextArea.getSelectedText ());
10224: }
10225:
10226:
10227:
10228: public static void dbgSelectAll () {
10229: if (clpClipboard != null) {
10230:
10231: dbgEventMask++;
10232: dbgPopupTextArea.selectAll ();
10233: dbgPopupTextArea.requestFocusInWindow ();
10234: dbgEventMask--;
10235: }
10236: }
10237:
10238:
10239:
10240:
10241: public static void dbgUpdate () {
10242: if ((dbgVisibleMask & DBG_DRP_VISIBLE_MASK) != 0) {
10243: RegisterList.drpUpdate ();
10244: }
10245: if (ProgramFlowVisualizer.PFV_ON) {
10246: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
10247: if (ProgramFlowVisualizer.pfvTimer == 0) {
10248: ProgramFlowVisualizer.pfvUpdate ();
10249: } else {
10250: ProgramFlowVisualizer.pfvTimer--;
10251: }
10252: }
10253: }
10254: if (RasterBreakPoint.RBP_ON) {
10255: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
10256: if (RasterBreakPoint.rbpTimer == 0) {
10257: RasterBreakPoint.rbpUpdateFrame ();
10258: } else {
10259: RasterBreakPoint.rbpTimer--;
10260: }
10261: }
10262: }
10263: if (ScreenModeTest.SMT_ON) {
10264: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
10265: if (ScreenModeTest.smtTimer == 0) {
10266: ScreenModeTest.smtUpdateFrame ();
10267: } else {
10268: ScreenModeTest.smtTimer--;
10269: }
10270: }
10271: }
10272: if (RootPointerList.RTL_ON) {
10273: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
10274: if (RootPointerList.rtlTimer == 0) {
10275: RootPointerList.rtlTimer = RootPointerList.RTL_INTERVAL - 1;
10276: RootPointerList.rtlUpdateFrame ();
10277: } else {
10278: RootPointerList.rtlTimer--;
10279: }
10280: }
10281: }
10282: if (SpritePatternViewer.SPV_ON) {
10283: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
10284: if (SpritePatternViewer.spvTimer == 0) {
10285: SpritePatternViewer.spvTimer = SpritePatternViewer.SPV_INTERVAL - 1;
10286: SpritePatternViewer.spvUpdateFrame ();
10287: } else {
10288: SpritePatternViewer.spvTimer--;
10289: }
10290: }
10291: }
10292: if (PaletteViewer.PLV_ON) {
10293: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
10294: if (PaletteViewer.plvTimer == 0) {
10295: PaletteViewer.plvTimer = PaletteViewer.PLV_INTERVAL - 1;
10296: PaletteViewer.plvUpdateFrame ();
10297: } else {
10298: PaletteViewer.plvTimer--;
10299: }
10300: }
10301: }
10302: if (ATCMonitor.ACM_ON) {
10303: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
10304: if (ATCMonitor.acmTimer == 0) {
10305: ATCMonitor.acmTimer = ATCMonitor.ACM_INTERVAL - 1;
10306: ATCMonitor.acmUpdateFrame ();
10307: } else {
10308: ATCMonitor.acmTimer--;
10309: }
10310: }
10311: }
10312: }
10313:
10314:
10315:
10316:
10317:
10318:
10319:
10320:
10321:
10322:
10323:
10324:
10325:
10326:
10327:
10328:
10329:
10330:
10331:
10332:
10333:
10334:
10335: public static boolean dbgDoStopOnError () {
10336: if (MainMemory.mmrHumanVersion <= 0) {
10337: return true;
10338: }
10339: if ((regOC & 0xff00) == 0xff00 &&
10340: M68kException.m6eNumber == M68kException.M6E_PRIVILEGE_VIOLATION) {
10341: return false;
10342: }
10343: String message = (
10344: M68kException.m6eNumber < 0 ?
10345: fmtHex8 (new StringBuilder ("breaked").append (" at "), regPC0).toString () :
10346: M68kException.m6eNumber <= M68kException.M6E_ADDRESS_ERROR ?
10347: fmtHex8 (fmtHex8 (new StringBuilder ("ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10348: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10349: .append (" at "), regPC0).toString () :
10350: fmtHex8 (new StringBuilder (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10351: .append (" at "), regPC0).toString ()
10352: );
10353: System.out.println (message);
10354: if (!(M68kException.m6eNumber == M68kException.M6E_ACCESS_FAULT &&
10355: 0x0000e100 <= regPC0 && regPC0 < 0x0000e500)) {
10356: mpuStop (message);
10357: return true;
10358: }
10359: return false;
10360: }
10361:
10362:
10363:
10364: public static void dbgDoubleBusFault () {
10365: String message =
10366: fmtHex8 (fmtHex8 (new StringBuilder ("FATAL ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10367: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10368: .append (" at "), regPC0).toString ();
10369: System.out.println (message);
10370: mpuStop (message);
10371: }
10372:
10373:
10374:
10375:
10376:
10377:
10378: public static final HashMap<String,byte[]> rscResourceCache = new HashMap<String,byte[]> ();
10379:
10380:
10381:
10382:
10383:
10384:
10385: public static byte[] rscGetResource (String name, int... sizes) {
10386: byte[] array = rscResourceCache.get (name);
10387: if (array != null) {
10388: return array;
10389: }
10390: array = new byte[1024 * 64];
10391: int size = 0;
10392: try (BufferedInputStream bis = new BufferedInputStream (XEiJ.class.getResourceAsStream ("../data/" + name))) {
10393: for (;;) {
10394: if (size == array.length) {
10395: byte[] newArray = new byte[array.length * 2];
10396: System.arraycopy (array, 0, newArray, 0, size);
10397: array = newArray;
10398: }
10399: int step = bis.read (array, size, array.length - size);
10400: if (step == -1) {
10401: break;
10402: }
10403: size += step;
10404: }
10405: if (size < array.length) {
10406: byte[] newArray = new byte[size];
10407: System.arraycopy (array, 0, newArray, 0, size);
10408: array = newArray;
10409: }
10410: boolean fit = sizes.length == 0;
10411: if (!fit) {
10412: for (int i = 0; i < sizes.length; i++) {
10413: if (size == sizes[i]) {
10414: fit = true;
10415: break;
10416: }
10417: }
10418: }
10419: if (fit) {
10420: System.out.println (Multilingual.mlnJapanese ?
10421: name + " を読み込みました" :
10422: name + " was read");
10423: rscResourceCache.put (name, array);
10424: return array;
10425: }
10426: System.out.println (Multilingual.mlnJapanese ?
10427: name + " のサイズが違います" :
10428: name + " has wrong size");
10429: return null;
10430: } catch (IOException ioe) {
10431: }
10432:
10433: System.out.println (Multilingual.mlnJapanese ?
10434: name + " を読み込めません" :
10435: name + " cannot be read");
10436: return null;
10437: }
10438:
10439:
10440:
10441: public static String rscGetResourceText (String name) {
10442: return rscGetResourceText (name, "UTF-8");
10443: }
10444: public static String rscGetResourceText (String name, String charset) {
10445: byte[] array = rscGetResource (name);
10446: if (name != null) {
10447: try {
10448: return new String (array, charset);
10449: } catch (UnsupportedEncodingException uee) {
10450: }
10451: }
10452: return "";
10453: }
10454:
10455: public static final Pattern RSC_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10456: public static String rscLastFileName = null;
10457:
10458:
10459:
10460:
10461:
10462:
10463: public static byte[] rscGetFile (String names, int... sizes) {
10464: for (String name : names.split (",")) {
10465: name = name.trim ();
10466: if (name.length () == 0 || name.equalsIgnoreCase ("none")) {
10467: continue;
10468: }
10469: String[] zipSplittedName = RSC_ZIP_SEPARATOR.split (name, 2);
10470: InputStream is = null;
10471: if (zipSplittedName.length < 2) {
10472: File file = new File (name);
10473: if (file.isFile ()) {
10474: try {
10475: is = new FileInputStream (file);
10476: } catch (IOException ioe) {
10477: }
10478: } else {
10479: System.out.println (Multilingual.mlnJapanese ?
10480: name + " がありません" :
10481: name + " does not exist");
10482: continue;
10483: }
10484: } else {
10485: String zipName = zipSplittedName[0];
10486: String entryName = zipSplittedName[1];
10487: if (new File (zipName).isFile ()) {
10488: try {
10489: ZipFile zipFile = new ZipFile (zipName);
10490: ZipEntry zipEntry = zipFile.getEntry (entryName);
10491: if (zipEntry != null) {
10492: is = zipFile.getInputStream (zipEntry);
10493: } else {
10494: System.out.println (Multilingual.mlnJapanese ?
10495: zipName + " に " + zipEntry + " がありません" :
10496: zipName + " does not include " + zipEntry);
10497: }
10498: } catch (IOException ioe) {
10499: }
10500: } else {
10501: System.out.println (Multilingual.mlnJapanese ?
10502: zipName + " がありません" :
10503: zipName + " does not exist");
10504: continue;
10505: }
10506: }
10507: if (is != null) {
10508: try {
10509: is = new BufferedInputStream (is);
10510: if (name.toLowerCase ().endsWith (".gz")) {
10511: is = new GZIPInputStream (is);
10512: }
10513: byte[] array = new byte[1024 * 64];
10514: int size = 0;
10515: for (;;) {
10516: if (size == array.length) {
10517: byte[] newArray = new byte[array.length * 2];
10518: System.arraycopy (array, 0, newArray, 0, size);
10519: array = newArray;
10520: }
10521: int step = is.read (array, size, array.length - size);
10522: if (step == -1) {
10523: break;
10524: }
10525: size += step;
10526: }
10527: is.close ();
10528: is = null;
10529: if (size < array.length) {
10530: byte[] newArray = new byte[size];
10531: System.arraycopy (array, 0, newArray, 0, size);
10532: array = newArray;
10533: }
10534: boolean fit = sizes.length == 0;
10535: if (!fit) {
10536: for (int i = 0; i < sizes.length; i++) {
10537: if (size == sizes[i]) {
10538: fit = true;
10539: break;
10540: }
10541: }
10542: }
10543: if (fit) {
10544: System.out.println (Multilingual.mlnJapanese ?
10545: name + " を読み込みました" :
10546: name + " was read");
10547: rscLastFileName = name;
10548: return array;
10549: }
10550: System.out.println (Multilingual.mlnJapanese ?
10551: name + " のサイズが違います" :
10552: name + " has wrong size");
10553: continue;
10554: } catch (IOException ioe) {
10555: }
10556: if (is != null) {
10557: try {
10558: is.close ();
10559: is = null;
10560: } catch (IOException ioe) {
10561: }
10562: }
10563: }
10564: System.out.println (Multilingual.mlnJapanese ?
10565: name + " を読み込めません" :
10566: name + " cannot be read");
10567: }
10568:
10569:
10570:
10571: return null;
10572: }
10573:
10574:
10575:
10576:
10577: public static String rscGetTextFile (String name) {
10578: return rscGetTextFile (name, "UTF-8");
10579: }
10580: public static String rscGetTextFile (String name, String charset) {
10581: byte[] array = rscGetFile (name);
10582: if (array != null) {
10583: try {
10584: return new String (array, charset);
10585: } catch (UnsupportedEncodingException uee) {
10586: }
10587: }
10588: return "";
10589: }
10590:
10591:
10592:
10593: public static final int RSC_A_MASK = 1;
10594: public static final int RSC_R_MASK = 2;
10595: public static final int RSC_I_MASK = 4;
10596: public static final String RSC_A_EN = "Abort";
10597: public static final String RSC_R_EN = "Retry";
10598: public static final String RSC_I_EN = "Ignore";
10599: public static final String RSC_A_JA = "中止";
10600: public static final String RSC_R_JA = "再実行";
10601: public static final String RSC_I_JA = "無視";
10602: public static final String[][] RSC_EN_OPTIONS = {
10603: { RSC_A_EN },
10604: { RSC_A_EN },
10605: { RSC_R_EN },
10606: { RSC_A_EN, RSC_R_EN },
10607: { RSC_I_EN },
10608: { RSC_A_EN, RSC_I_EN },
10609: { RSC_R_EN, RSC_I_EN },
10610: { RSC_A_EN, RSC_R_EN, RSC_I_EN },
10611: };
10612: public static final String[][] RSC_JA_OPTIONS = {
10613: { RSC_A_JA },
10614: { RSC_A_JA },
10615: { RSC_R_JA },
10616: { RSC_A_JA, RSC_R_JA },
10617: { RSC_I_JA },
10618: { RSC_A_JA, RSC_I_JA },
10619: { RSC_R_JA, RSC_I_JA },
10620: { RSC_A_JA, RSC_R_JA, RSC_I_JA },
10621: };
10622: public static int rscShowError (String message, int mask) {
10623: System.out.println (message);
10624: mask &= RSC_A_MASK | RSC_R_MASK | RSC_I_MASK;
10625: if (mask == 0) {
10626: mask = RSC_A_MASK;
10627: }
10628: String[] options = (Multilingual.mlnJapanese ? RSC_JA_OPTIONS : RSC_EN_OPTIONS)[mask];
10629: int def = Integer.numberOfTrailingZeros (mask);
10630: pnlExitFullScreen (true);
10631: int bit = JOptionPane.showOptionDialog (
10632: null,
10633: message,
10634: Multilingual.mlnJapanese ? "ファイル操作エラー" : "File operation error",
10635: JOptionPane.YES_NO_CANCEL_OPTION,
10636: JOptionPane.ERROR_MESSAGE,
10637: null,
10638: options,
10639: options[def]);
10640: if (bit == JOptionPane.CLOSED_OPTION) {
10641: bit = def;
10642: }
10643: return 1 << bit;
10644: }
10645:
10646:
10647:
10648:
10649:
10650:
10651: public static boolean rscPutTextFile (String name, String string) {
10652: return rscPutTextFile (name, string, "UTF-8");
10653: }
10654: public static boolean rscPutTextFile (String name, ArrayList<String> strings) {
10655: return rscPutTextFile (name, strings, "UTF-8");
10656: }
10657: public static boolean rscPutTextFile (String name, String string, String charset) {
10658: ArrayList<String> strings = new ArrayList<String> ();
10659: strings.add (string);
10660: return rscPutTextFile (name, strings, charset);
10661: }
10662: public static boolean rscPutTextFile (String name, ArrayList<String> strings, String charset) {
10663: String nameTmp = name + ".tmp";
10664: String nameBak = name + ".bak";
10665: File file = new File (name);
10666: File fileTmp = new File (nameTmp);
10667: File fileBak = new File (nameBak);
10668:
10669: File parentDirectory = file.getParentFile ();
10670: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10671: if (!parentDirectory.mkdirs ()) {
10672: System.out.println (parentDirectory.getPath () + (Multilingual.mlnJapanese ? " を作れません" : " cannot be created"));
10673: return false;
10674: }
10675: }
10676:
10677: if (fileTmp.exists ()) {
10678: if (!fileTmp.delete ()) {
10679: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10680: return false;
10681: }
10682: }
10683:
10684: try (BufferedWriter bw = new BufferedWriter (new FileWriter (nameTmp, Charset.forName (charset)))) {
10685: for (String string : strings) {
10686: bw.write (string);
10687: }
10688: } catch (IOException ioe) {
10689: ioe.printStackTrace ();
10690: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " に書き出せません" : " cannot be written"));
10691: return false;
10692: }
10693:
10694: boolean fileExists = file.exists ();
10695: if (fileExists) {
10696:
10697: if (fileBak.exists ()) {
10698: if (!fileBak.delete ()) {
10699: System.out.println (nameBak + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10700: return false;
10701: }
10702: }
10703:
10704: if (!file.renameTo (fileBak)) {
10705: System.out.println (name + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + nameBak + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10706: return false;
10707: }
10708: }
10709:
10710: if (!fileTmp.renameTo (file)) {
10711: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + name + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10712: return false;
10713: }
10714: if (fileExists) {
10715: System.out.println (name + (Multilingual.mlnJapanese ? " を更新しました" : " was updated"));
10716: } else {
10717: System.out.println (name + (Multilingual.mlnJapanese ? " を作りました" : " was created"));
10718: }
10719: return true;
10720: }
10721:
10722:
10723:
10724:
10725:
10726:
10727:
10728:
10729:
10730: public static boolean rscPutFile (String name, byte[] array) {
10731: return rscPutFile (name, array, 0, array.length, (long) array.length);
10732: }
10733: public static boolean rscPutFile (String name, byte[] array, int offset, int length) {
10734: return rscPutFile (name, array, offset, length, (long) length);
10735: }
10736: public static boolean rscPutFile (String name, byte[] array, int offset, int length, long longLength2) {
10737: if (RSC_ZIP_SEPARATOR.matcher (name).matches ()) {
10738:
10739: return false;
10740: }
10741: File file = new File (name);
10742: boolean fileExists = file.isFile ();
10743: if (fileExists && file.length () == longLength2) {
10744: comparison:
10745: {
10746: try (BufferedInputStream bis = new BufferedInputStream (new FileInputStream (file))) {
10747: byte[] buffer = new byte[(int) Math.min (Math.max ((long) length, longLength2 - (long) length), (long) (1024 * 1024))];
10748: int position = 0;
10749: while (position < length) {
10750: int step = bis.read (buffer, 0, Math.min (buffer.length, length - position));
10751: if (step == -1) {
10752: break comparison;
10753: }
10754: int offsetPosition = offset + position;
10755: for (int i = 0; i < step; i++) {
10756: if (buffer[i] != array[offsetPosition + i]) {
10757: break comparison;
10758: }
10759: }
10760: position += step;
10761: }
10762: long longPosition2 = (long) length;
10763: while (longPosition2 < longLength2) {
10764: int step = bis.read (buffer, 0, (int) Math.min ((long) buffer.length, longLength2 - longPosition2));
10765: if (step == -1) {
10766: break comparison;
10767: }
10768: for (int i = 0; i < step; i++) {
10769: if (buffer[i] != 0) {
10770: break comparison;
10771: }
10772: }
10773: longPosition2 += (long) step;
10774: }
10775: return true;
10776: } catch (IOException ioe) {
10777: }
10778: }
10779: }
10780: String nameTmp = name + ".tmp";
10781: File fileTmp = new File (nameTmp);
10782: String nameBak = name + ".bak";
10783: File fileBak = new File (nameBak);
10784: retry:
10785: for (;;) {
10786: File parentDirectory = file.getParentFile ();
10787: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10788: String parentName = parentDirectory.getPath ();
10789: if (parentDirectory.mkdirs ()) {
10790: System.out.println (Multilingual.mlnJapanese ?
10791: parentName + " を作りました" :
10792: parentName + " was created");
10793: } else {
10794: switch (rscShowError (Multilingual.mlnJapanese ?
10795: parentName + " を作れません" :
10796: parentName + " cannot be created",
10797: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10798: case RSC_A_MASK:
10799: break retry;
10800: case RSC_R_MASK:
10801: continue retry;
10802: }
10803: }
10804: }
10805: if (fileTmp.isFile ()) {
10806: if (!fileTmp.delete ()) {
10807: switch (rscShowError (Multilingual.mlnJapanese ?
10808: nameTmp + " を削除できません" :
10809: nameTmp + " cannot be deleted",
10810: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10811: case RSC_A_MASK:
10812: break retry;
10813: case RSC_R_MASK:
10814: continue retry;
10815: }
10816: }
10817: }
10818: try (OutputStream os = name.toLowerCase ().endsWith (".gz") ?
10819: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10820: {
10821:
10822: def.setLevel (Deflater.DEFAULT_COMPRESSION);
10823:
10824: }
10825: } :
10826: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10827:
10828: os.write (array, offset, length);
10829:
10830:
10831: if ((long) length < longLength2) {
10832: byte[] buffer = new byte[(int) Math.min (longLength2 - (long) length, (long) (1024 * 1024))];
10833: Arrays.fill (buffer, 0, buffer.length, (byte) 0);
10834: long longPosition2 = (long) length;
10835: while (longPosition2 < longLength2) {
10836: int step = (int) Math.min ((long) buffer.length, longLength2 - longPosition2);
10837: os.write (buffer, 0, step);
10838: longPosition2 += (long) step;
10839: }
10840: }
10841: } catch (IOException ioe) {
10842: switch (rscShowError (Multilingual.mlnJapanese ?
10843: nameTmp + " に書き出せません" :
10844: nameTmp + " cannot be written",
10845: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10846: case RSC_A_MASK:
10847: break retry;
10848: case RSC_R_MASK:
10849: continue retry;
10850: }
10851: }
10852: if (fileExists && file.isFile ()) {
10853: if (fileBak.isFile ()) {
10854: if (!fileBak.delete ()) {
10855: switch (rscShowError (Multilingual.mlnJapanese ?
10856: nameBak + " を削除できません" :
10857: nameBak + " cannot be deleted",
10858: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10859: case RSC_A_MASK:
10860: break retry;
10861: case RSC_R_MASK:
10862: continue retry;
10863: }
10864: }
10865: }
10866: if (!file.renameTo (fileBak)) {
10867: switch (rscShowError (Multilingual.mlnJapanese ?
10868: name + " を " + nameBak + " にリネームできません" :
10869: name + " cannot be renamed to " + nameBak,
10870: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10871: case RSC_A_MASK:
10872: break retry;
10873: case RSC_R_MASK:
10874: continue retry;
10875: }
10876: }
10877: }
10878: if (fileTmp.renameTo (file)) {
10879: if (fileExists) {
10880: System.out.println (Multilingual.mlnJapanese ?
10881: name + " を更新しました" :
10882: name + " was updated");
10883: } else {
10884: System.out.println (Multilingual.mlnJapanese ?
10885: name + " を作りました" :
10886: name + " was created");
10887: }
10888: return true;
10889: } else {
10890: switch (rscShowError (Multilingual.mlnJapanese ?
10891: nameTmp + " を " + name + " にリネームできません" :
10892: nameTmp + " cannot be renamed to " + name,
10893: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10894: case RSC_A_MASK:
10895: break retry;
10896: case RSC_R_MASK:
10897: continue retry;
10898: }
10899: }
10900: break;
10901: }
10902: if (fileExists) {
10903: System.out.println (Multilingual.mlnJapanese ?
10904: name + " を更新できません" :
10905: name + " cannot be updated");
10906: } else {
10907: System.out.println (Multilingual.mlnJapanese ?
10908: name + " を作れません" :
10909: name + " cannot be created");
10910: }
10911: return false;
10912: }
10913:
10914:
10915:
10916:
10917:
10918:
10919: public static final Pattern ISM_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10920:
10921:
10922:
10923:
10924:
10925:
10926:
10927:
10928:
10929:
10930:
10931: public static InputStream ismOpen (String name) {
10932: InputStream in = null;
10933: in = ismOpen (name, false);
10934: if (in == null && name.indexOf ('/') < 0 && name.indexOf ('\\') < 0) {
10935: in = ismOpen (name, true);
10936: }
10937: return in;
10938: }
10939: public static InputStream ismOpen (String name, boolean useGetResource) {
10940: boolean gzipped = name.toLowerCase ().endsWith (".gz");
10941: String[] zipSplittedName = ISM_ZIP_SEPARATOR.split (name, 2);
10942: String fileName = zipSplittedName[0];
10943: String zipEntryName = zipSplittedName.length < 2 ? null : zipSplittedName[1];
10944: InputStream in = null;
10945: try {
10946: if (useGetResource) {
10947: if (false) {
10948: URL url = XEiJ.class.getResource (fileName);
10949: if (url != null) {
10950: in = url.openStream ();
10951: }
10952: } else {
10953: in = XEiJ.class.getResourceAsStream (fileName);
10954: }
10955: } else {
10956: File file = new File (fileName);
10957: if (file.exists ()) {
10958: in = new FileInputStream (file);
10959: }
10960: }
10961: if (in != null && zipEntryName != null) {
10962: ZipInputStream zin = new ZipInputStream (in);
10963: in = null;
10964: ZipEntry entry;
10965: while ((entry = zin.getNextEntry ()) != null) {
10966: if (zipEntryName.equals (entry.getName ())) {
10967: in = zin;
10968: break;
10969: }
10970: }
10971: if (in == null) {
10972: System.out.println (Multilingual.mlnJapanese ? fileName + " の中に " + zipEntryName + " がありません" :
10973: zipEntryName + " does not exist in " + fileName);
10974: }
10975: }
10976: if (in != null && gzipped) {
10977: in = new GZIPInputStream (in);
10978: }
10979: if (in != null) {
10980: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " を読み込みます" :
10981: (useGetResource ? "Reading resource file " : "Reading file ") + name);
10982: return new BufferedInputStream (in);
10983: }
10984: } catch (Exception ioe) {
10985: if (prgVerbose) {
10986: prgPrintStackTraceOf (ioe);
10987: }
10988: }
10989: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " が見つかりません" :
10990: (useGetResource ? "Resource file " : "File ") + name + " is not found");
10991: return null;
10992: }
10993:
10994:
10995:
10996:
10997:
10998:
10999:
11000:
11001: public static int ismRead (InputStream in, byte[] bb, int o, int l) {
11002: try {
11003: int k = 0;
11004: while (k < l) {
11005: int t = in.read (bb, o + k, l - k);
11006: if (t < 0) {
11007: break;
11008: }
11009: k += t;
11010: }
11011: return k;
11012: } catch (IOException ioe) {
11013: if (prgVerbose) {
11014: prgPrintStackTraceOf (ioe);
11015: }
11016: }
11017: return -1;
11018: }
11019:
11020:
11021:
11022:
11023:
11024:
11025:
11026:
11027: public static int ismSkip (InputStream in, int l) {
11028: try {
11029: int k = 0;
11030: while (k < l) {
11031:
11032:
11033: if (in.read () < 0) {
11034: break;
11035: }
11036: k++;
11037: if (k < l) {
11038: int t = (int) in.skip ((long) (l - k));
11039: if (t < 0) {
11040: break;
11041: }
11042: k += t;
11043: }
11044: }
11045: return k;
11046: } catch (IOException ioe) {
11047: if (prgVerbose) {
11048: prgPrintStackTraceOf (ioe);
11049: }
11050: }
11051: return -1;
11052: }
11053:
11054:
11055:
11056:
11057:
11058: public static void ismClose (InputStream in) {
11059: try {
11060: if (in != null) {
11061: in.close ();
11062: }
11063: } catch (IOException ioe) {
11064: if (prgVerbose) {
11065: prgPrintStackTraceOf (ioe);
11066: }
11067: }
11068: }
11069:
11070:
11071:
11072:
11073:
11074:
11075: public static int ismLength (String name, int maxLength) {
11076: int length;
11077: InputStream in = ismOpen (name);
11078: if (in == null) {
11079: length = -1;
11080: } else {
11081: length = ismSkip (in, maxLength);
11082: ismClose (in);
11083: }
11084: return length;
11085: }
11086:
11087:
11088:
11089:
11090:
11091:
11092:
11093:
11094:
11095:
11096:
11097:
11098:
11099:
11100: public static boolean ismLoad (byte[] bb, int o, int l, String names) {
11101: for (String name : names.split (",")) {
11102: if (name.length () != 0) {
11103: InputStream in = ismOpen (name);
11104: if (in != null) {
11105: int k = ismRead (in, bb, o, l);
11106: ismClose (in);
11107: if (k == l) {
11108: return true;
11109: }
11110: }
11111: }
11112: }
11113: return false;
11114: }
11115:
11116:
11117:
11118:
11119:
11120:
11121:
11122:
11123:
11124: public static boolean ismSave (byte[] bb, int offset, long length, String path, boolean verbose) {
11125: if (ISM_ZIP_SEPARATOR.split (path, 2).length != 1) {
11126: if (verbose) {
11127: pnlExitFullScreen (true);
11128: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? path + " に書き出せません" : "Cannot write " + path);
11129: }
11130: return false;
11131: }
11132: long step = 0;
11133: byte[] zz = null;
11134: long pointer = (long) (bb.length - offset);
11135: if (pointer < length) {
11136: step = Math.min (1024L * 512, length - pointer);
11137: zz = new byte[(int) step];
11138: Arrays.fill (zz, (byte) 0);
11139: }
11140:
11141: File file = new File (path);
11142:
11143: if (step == 0 &&
11144: file.exists () && file.length () == length) {
11145:
11146: if (length == 0L) {
11147: return true;
11148: }
11149: InputStream in = ismOpen (path);
11150: if (in != null) {
11151: int l = (int) length;
11152: byte[] tt = new byte[l];
11153: int k = ismRead (in, tt, 0, l);
11154: ismClose (in);
11155: if (k == l &&
11156: Arrays.equals (tt, bb.length == l ? bb : Arrays.copyOfRange (bb, offset, offset + l))) {
11157: return true;
11158: }
11159: }
11160: }
11161:
11162: String pathTmp = path + ".tmp";
11163: String pathBak = path + ".bak";
11164: File fileTmp = new File (pathTmp);
11165: File fileBak = new File (pathBak);
11166:
11167: if (fileTmp.exists ()) {
11168: if (!fileTmp.delete ()) {
11169: if (verbose) {
11170: pnlExitFullScreen (true);
11171: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " を削除できません" : "Cannot delete " + pathTmp);
11172: }
11173: return false;
11174: }
11175: }
11176:
11177: try (OutputStream out = path.toLowerCase ().endsWith (".gz") ?
11178: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11179: {
11180:
11181: def.setLevel (Deflater.DEFAULT_COMPRESSION);
11182:
11183: }
11184: } :
11185: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11186: if (step == 0) {
11187: out.write (bb, offset, (int) length);
11188: } else {
11189: out.write (bb, offset, (int) pointer);
11190: for (; pointer < length; pointer += step) {
11191: out.write (zz, 0, (int) Math.min (step, length - pointer));
11192: }
11193: }
11194: } catch (IOException ioe) {
11195: if (verbose) {
11196: prgPrintStackTraceOf (ioe);
11197: pnlExitFullScreen (true);
11198: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " に書き出せません" : "Cannot write " + pathTmp);
11199: }
11200: return false;
11201: }
11202:
11203:
11204: if (file.exists ()) {
11205: if (fileBak.exists ()) {
11206: if (!fileBak.delete ()) {
11207: if (verbose) {
11208: pnlExitFullScreen (true);
11209: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathBak + " を削除できません" : "Cannot delete " + pathBak);
11210: }
11211: return false;
11212: }
11213: }
11214: if (!file.renameTo (fileBak)) {
11215: if (verbose) {
11216: pnlExitFullScreen (true);
11217: JOptionPane.showMessageDialog (
11218: null, Multilingual.mlnJapanese ? path + " を " + pathBak + " にリネームできません" : "Cannot rename " + path + " to " + pathBak);
11219: }
11220: return false;
11221: }
11222: }
11223:
11224:
11225: if (!fileTmp.renameTo (file)) {
11226: if (verbose) {
11227: pnlExitFullScreen (true);
11228: JOptionPane.showMessageDialog (
11229: null, Multilingual.mlnJapanese ? pathTmp + " を " + path + " にリネームできません" : "Cannot rename " + pathTmp + " to " + path);
11230: }
11231: return false;
11232: }
11233: return true;
11234: }
11235:
11236:
11237:
11238:
11239:
11240:
11241:
11242: public static final char[] FMT_TEMP = new char[32];
11243:
11244:
11245:
11246:
11247:
11248:
11249:
11250:
11251:
11252:
11253:
11254: public static final char[] FMT_AIN4_BASE = ".......*..*...**.*...*.*.**..****...*..**.*.*.****..**.****.****".toCharArray ();
11255: public static final char[] FMT_BIN4_BASE = "0000000100100011010001010110011110001001101010111100110111101111".toCharArray ();
11256:
11257:
11258:
11259:
11260:
11261:
11262:
11263:
11264: public static void fmtAin4 (char[] a, int o, int x) {
11265: a[o ] = (char) (x >> 1 & 4 ^ 46);
11266: a[o + 1] = (char) (x & 4 ^ 46);
11267: a[o + 2] = (char) (x << 1 & 4 ^ 46);
11268: a[o + 3] = (char) (x << 2 & 4 ^ 46);
11269: }
11270: public static void fmtBin4 (char[] a, int o, int x) {
11271: a[o ] = (char) (x >>> 3 & 1 | 48);
11272: a[o + 1] = (char) (x >>> 2 & 1 | 48);
11273: a[o + 2] = (char) (x >>> 1 & 1 | 48);
11274: a[o + 3] = (char) (x & 1 | 48);
11275: }
11276: public static String fmtAin4 (int x) {
11277: return String.valueOf (FMT_AIN4_BASE, (x & 15) << 2, 4);
11278: }
11279: public static String fmtBin4 (int x) {
11280: return String.valueOf (FMT_BIN4_BASE, (x & 15) << 2, 4);
11281: }
11282: public static StringBuilder fmtAin4 (StringBuilder sb, int x) {
11283: return sb.append (FMT_AIN4_BASE, (x & 15) << 2, 6);
11284: }
11285: public static StringBuilder fmtBin4 (StringBuilder sb, int x) {
11286: return sb.append (FMT_BIN4_BASE, (x & 15) << 2, 6);
11287: }
11288:
11289:
11290:
11291:
11292:
11293:
11294:
11295:
11296: public static void fmtAin6 (char[] a, int o, int x) {
11297: a[o ] = (char) (x >> 3 & 4 ^ 46);
11298: a[o + 1] = (char) (x >> 2 & 4 ^ 46);
11299: a[o + 2] = (char) (x >> 1 & 4 ^ 46);
11300: a[o + 3] = (char) (x & 4 ^ 46);
11301: a[o + 4] = (char) (x << 1 & 4 ^ 46);
11302: a[o + 5] = (char) (x << 2 & 4 ^ 46);
11303: }
11304: public static void fmtBin6 (char[] a, int o, int x) {
11305: a[o ] = (char) (x >>> 5 & 1 | 48);
11306: a[o + 1] = (char) (x >>> 4 & 1 | 48);
11307: a[o + 2] = (char) (x >>> 3 & 1 | 48);
11308: a[o + 3] = (char) (x >>> 2 & 1 | 48);
11309: a[o + 4] = (char) (x >>> 1 & 1 | 48);
11310: a[o + 5] = (char) (x & 1 | 48);
11311: }
11312: public static String fmtAin6 (int x) {
11313: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11314: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11315: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11316: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11317: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11318: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11319: return String.valueOf (FMT_TEMP, 0, 6);
11320: }
11321: public static String fmtBin6 (int x) {
11322: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11323: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11324: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11325: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11326: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11327: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11328: return String.valueOf (FMT_TEMP, 0, 6);
11329: }
11330: public static StringBuilder fmtAin6 (StringBuilder sb, int x) {
11331: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11332: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11333: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11334: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11335: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11336: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11337: return sb.append (FMT_TEMP, 0, 6);
11338: }
11339: public static StringBuilder fmtBin6 (StringBuilder sb, int x) {
11340: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11341: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11342: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11343: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11344: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11345: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11346: return sb.append (FMT_TEMP, 0, 6);
11347: }
11348:
11349:
11350:
11351:
11352:
11353:
11354:
11355:
11356: public static void fmtAin8 (char[] a, int o, int x) {
11357: a[o ] = (char) (x >> 5 & 4 ^ 46);
11358: a[o + 1] = (char) (x >> 4 & 4 ^ 46);
11359: a[o + 2] = (char) (x >> 3 & 4 ^ 46);
11360: a[o + 3] = (char) (x >> 2 & 4 ^ 46);
11361: a[o + 4] = (char) (x >> 1 & 4 ^ 46);
11362: a[o + 5] = (char) (x & 4 ^ 46);
11363: a[o + 6] = (char) (x << 1 & 4 ^ 46);
11364: a[o + 7] = (char) (x << 2 & 4 ^ 46);
11365: }
11366: public static void fmtBin8 (char[] a, int o, int x) {
11367: a[o ] = (char) (x >>> 7 & 1 | 48);
11368: a[o + 1] = (char) (x >>> 6 & 1 | 48);
11369: a[o + 2] = (char) (x >>> 5 & 1 | 48);
11370: a[o + 3] = (char) (x >>> 4 & 1 | 48);
11371: a[o + 4] = (char) (x >>> 3 & 1 | 48);
11372: a[o + 5] = (char) (x >>> 2 & 1 | 48);
11373: a[o + 6] = (char) (x >>> 1 & 1 | 48);
11374: a[o + 7] = (char) (x & 1 | 48);
11375: }
11376: public static String fmtAin8 (int x) {
11377: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11378: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11379: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11380: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11381: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11382: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11383: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11384: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11385: return String.valueOf (FMT_TEMP, 0, 8);
11386: }
11387: public static String fmtBin8 (int x) {
11388: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11389: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11390: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11391: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11392: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11393: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11394: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11395: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11396: return String.valueOf (FMT_TEMP, 0, 8);
11397: }
11398: public static StringBuilder fmtAin8 (StringBuilder sb, int x) {
11399: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11400: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11401: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11402: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11403: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11404: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11405: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11406: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11407: return sb.append (FMT_TEMP, 0, 8);
11408: }
11409: public static StringBuilder fmtBin8 (StringBuilder sb, int x) {
11410: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11411: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11412: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11413: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11414: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11415: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11416: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11417: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11418: return sb.append (FMT_TEMP, 0, 8);
11419: }
11420:
11421:
11422:
11423:
11424:
11425:
11426:
11427:
11428: public static void fmtAin12 (char[] a, int o, int x) {
11429: a[o ] = (char) (x >> 9 & 4 ^ 46);
11430: a[o + 1] = (char) (x >> 8 & 4 ^ 46);
11431: a[o + 2] = (char) (x >> 7 & 4 ^ 46);
11432: a[o + 3] = (char) (x >> 6 & 4 ^ 46);
11433: a[o + 4] = (char) (x >> 5 & 4 ^ 46);
11434: a[o + 5] = (char) (x >> 4 & 4 ^ 46);
11435: a[o + 6] = (char) (x >> 3 & 4 ^ 46);
11436: a[o + 7] = (char) (x >> 2 & 4 ^ 46);
11437: a[o + 8] = (char) (x >> 1 & 4 ^ 46);
11438: a[o + 9] = (char) (x & 4 ^ 46);
11439: a[o + 10] = (char) (x << 1 & 4 ^ 46);
11440: a[o + 11] = (char) (x << 2 & 4 ^ 46);
11441: }
11442: public static void fmtBin12 (char[] a, int o, int x) {
11443: a[o ] = (char) (x >>> 11 & 1 | 48);
11444: a[o + 1] = (char) (x >>> 10 & 1 | 48);
11445: a[o + 2] = (char) (x >>> 9 & 1 | 48);
11446: a[o + 3] = (char) (x >>> 8 & 1 | 48);
11447: a[o + 4] = (char) (x >>> 7 & 1 | 48);
11448: a[o + 5] = (char) (x >>> 6 & 1 | 48);
11449: a[o + 6] = (char) (x >>> 5 & 1 | 48);
11450: a[o + 7] = (char) (x >>> 4 & 1 | 48);
11451: a[o + 8] = (char) (x >>> 3 & 1 | 48);
11452: a[o + 9] = (char) (x >>> 2 & 1 | 48);
11453: a[o + 10] = (char) (x >>> 1 & 1 | 48);
11454: a[o + 11] = (char) (x & 1 | 48);
11455: }
11456: public static String fmtAin12 (int x) {
11457: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11458: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11459: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11460: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11461: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11462: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11463: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11464: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11465: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11466: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11467: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11468: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11469: return String.valueOf (FMT_TEMP, 0, 12);
11470: }
11471: public static String fmtBin12 (int x) {
11472: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11473: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11474: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11475: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11476: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11477: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11478: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11479: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11480: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11481: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11482: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11483: FMT_TEMP[11] = (char) (x & 1 | 48);
11484: return String.valueOf (FMT_TEMP, 0, 12);
11485: }
11486: public static StringBuilder fmtAin12 (StringBuilder sb, int x) {
11487: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11488: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11489: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11490: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11491: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11492: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11493: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11494: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11495: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11496: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11497: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11498: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11499: return sb.append (FMT_TEMP, 0, 12);
11500: }
11501: public static StringBuilder fmtBin12 (StringBuilder sb, int x) {
11502: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11503: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11504: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11505: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11506: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11507: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11508: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11509: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11510: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11511: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11512: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11513: FMT_TEMP[11] = (char) (x & 1 | 48);
11514: return sb.append (FMT_TEMP, 0, 12);
11515: }
11516:
11517:
11518:
11519:
11520:
11521:
11522:
11523:
11524: public static void fmtAin16 (char[] a, int o, int x) {
11525: a[o ] = (char) (x >> 13 & 4 ^ 46);
11526: a[o + 1] = (char) (x >> 12 & 4 ^ 46);
11527: a[o + 2] = (char) (x >> 11 & 4 ^ 46);
11528: a[o + 3] = (char) (x >> 10 & 4 ^ 46);
11529: a[o + 4] = (char) (x >> 9 & 4 ^ 46);
11530: a[o + 5] = (char) (x >> 8 & 4 ^ 46);
11531: a[o + 6] = (char) (x >> 7 & 4 ^ 46);
11532: a[o + 7] = (char) (x >> 6 & 4 ^ 46);
11533: a[o + 8] = (char) (x >> 5 & 4 ^ 46);
11534: a[o + 9] = (char) (x >> 4 & 4 ^ 46);
11535: a[o + 10] = (char) (x >> 3 & 4 ^ 46);
11536: a[o + 11] = (char) (x >> 2 & 4 ^ 46);
11537: a[o + 12] = (char) (x >> 1 & 4 ^ 46);
11538: a[o + 13] = (char) (x & 4 ^ 46);
11539: a[o + 14] = (char) (x << 1 & 4 ^ 46);
11540: a[o + 15] = (char) (x << 2 & 4 ^ 46);
11541: }
11542: public static void fmtBin16 (char[] a, int o, int x) {
11543: a[o ] = (char) (x >>> 15 & 1 | 48);
11544: a[o + 1] = (char) (x >>> 14 & 1 | 48);
11545: a[o + 2] = (char) (x >>> 13 & 1 | 48);
11546: a[o + 3] = (char) (x >>> 12 & 1 | 48);
11547: a[o + 4] = (char) (x >>> 11 & 1 | 48);
11548: a[o + 5] = (char) (x >>> 10 & 1 | 48);
11549: a[o + 6] = (char) (x >>> 9 & 1 | 48);
11550: a[o + 7] = (char) (x >>> 8 & 1 | 48);
11551: a[o + 8] = (char) (x >>> 7 & 1 | 48);
11552: a[o + 9] = (char) (x >>> 6 & 1 | 48);
11553: a[o + 10] = (char) (x >>> 5 & 1 | 48);
11554: a[o + 11] = (char) (x >>> 4 & 1 | 48);
11555: a[o + 12] = (char) (x >>> 3 & 1 | 48);
11556: a[o + 13] = (char) (x >>> 2 & 1 | 48);
11557: a[o + 14] = (char) (x >>> 1 & 1 | 48);
11558: a[o + 15] = (char) (x & 1 | 48);
11559: }
11560: public static String fmtAin16 (int x) {
11561: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11562: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11563: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11564: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11565: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11566: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11567: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11568: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11569: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11570: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11571: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11572: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11573: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11574: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11575: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11576: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11577: return String.valueOf (FMT_TEMP, 0, 16);
11578: }
11579: public static String fmtBin16 (int x) {
11580: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11581: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11582: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11583: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11584: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11585: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11586: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11587: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11588: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11589: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11590: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11591: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11592: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11593: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11594: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11595: FMT_TEMP[15] = (char) (x & 1 | 48);
11596: return String.valueOf (FMT_TEMP, 0, 16);
11597: }
11598: public static StringBuilder fmtAin16 (StringBuilder sb, int x) {
11599: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11600: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11601: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11602: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11603: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11604: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11605: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11606: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11607: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11608: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11609: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11610: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11611: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11612: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11613: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11614: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11615: return sb.append (FMT_TEMP, 0, 16);
11616: }
11617: public static StringBuilder fmtBin16 (StringBuilder sb, int x) {
11618: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11619: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11620: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11621: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11622: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11623: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11624: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11625: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11626: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11627: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11628: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11629: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11630: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11631: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11632: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11633: FMT_TEMP[15] = (char) (x & 1 | 48);
11634: return sb.append (FMT_TEMP, 0, 16);
11635: }
11636:
11637:
11638:
11639:
11640:
11641:
11642:
11643:
11644: public static void fmtAin24 (char[] a, int o, int x) {
11645: a[o ] = (char) (x >> 21 & 4 ^ 46);
11646: a[o + 1] = (char) (x >> 20 & 4 ^ 46);
11647: a[o + 2] = (char) (x >> 19 & 4 ^ 46);
11648: a[o + 3] = (char) (x >> 18 & 4 ^ 46);
11649: a[o + 4] = (char) (x >> 17 & 4 ^ 46);
11650: a[o + 5] = (char) (x >> 16 & 4 ^ 46);
11651: a[o + 6] = (char) (x >> 15 & 4 ^ 46);
11652: a[o + 7] = (char) (x >> 14 & 4 ^ 46);
11653: a[o + 8] = (char) (x >> 13 & 4 ^ 46);
11654: a[o + 9] = (char) (x >> 12 & 4 ^ 46);
11655: a[o + 10] = (char) (x >> 11 & 4 ^ 46);
11656: a[o + 11] = (char) (x >> 10 & 4 ^ 46);
11657: a[o + 12] = (char) (x >> 9 & 4 ^ 46);
11658: a[o + 13] = (char) (x >> 8 & 4 ^ 46);
11659: a[o + 14] = (char) (x >> 7 & 4 ^ 46);
11660: a[o + 15] = (char) (x >> 6 & 4 ^ 46);
11661: a[o + 16] = (char) (x >> 5 & 4 ^ 46);
11662: a[o + 17] = (char) (x >> 4 & 4 ^ 46);
11663: a[o + 18] = (char) (x >> 3 & 4 ^ 46);
11664: a[o + 19] = (char) (x >> 2 & 4 ^ 46);
11665: a[o + 20] = (char) (x >> 1 & 4 ^ 46);
11666: a[o + 21] = (char) (x & 4 ^ 46);
11667: a[o + 22] = (char) (x << 1 & 4 ^ 46);
11668: a[o + 23] = (char) (x << 2 & 4 ^ 46);
11669: }
11670: public static void fmtBin24 (char[] a, int o, int x) {
11671: a[o ] = (char) (x >>> 23 & 1 | 48);
11672: a[o + 1] = (char) (x >>> 22 & 1 | 48);
11673: a[o + 2] = (char) (x >>> 21 & 1 | 48);
11674: a[o + 3] = (char) (x >>> 20 & 1 | 48);
11675: a[o + 4] = (char) (x >>> 19 & 1 | 48);
11676: a[o + 5] = (char) (x >>> 18 & 1 | 48);
11677: a[o + 6] = (char) (x >>> 17 & 1 | 48);
11678: a[o + 7] = (char) (x >>> 16 & 1 | 48);
11679: a[o + 8] = (char) (x >>> 15 & 1 | 48);
11680: a[o + 9] = (char) (x >>> 14 & 1 | 48);
11681: a[o + 10] = (char) (x >>> 13 & 1 | 48);
11682: a[o + 11] = (char) (x >>> 12 & 1 | 48);
11683: a[o + 12] = (char) (x >>> 11 & 1 | 48);
11684: a[o + 13] = (char) (x >>> 10 & 1 | 48);
11685: a[o + 14] = (char) (x >>> 9 & 1 | 48);
11686: a[o + 15] = (char) (x >>> 8 & 1 | 48);
11687: a[o + 16] = (char) (x >>> 7 & 1 | 48);
11688: a[o + 17] = (char) (x >>> 6 & 1 | 48);
11689: a[o + 18] = (char) (x >>> 5 & 1 | 48);
11690: a[o + 19] = (char) (x >>> 4 & 1 | 48);
11691: a[o + 20] = (char) (x >>> 3 & 1 | 48);
11692: a[o + 21] = (char) (x >>> 2 & 1 | 48);
11693: a[o + 22] = (char) (x >>> 1 & 1 | 48);
11694: a[o + 23] = (char) (x & 1 | 48);
11695: }
11696: public static String fmtAin24 (int x) {
11697: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11698: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11699: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11700: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11701: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11702: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11703: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11704: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11705: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11706: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11707: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11708: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11709: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11710: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11711: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11712: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11713: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11714: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11715: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11716: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11717: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11718: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11719: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11720: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11721: return String.valueOf (FMT_TEMP, 0, 24);
11722: }
11723: public static String fmtBin24 (int x) {
11724: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11725: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11726: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11727: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11728: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11729: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11730: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11731: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11732: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11733: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11734: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11735: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11736: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11737: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11738: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11739: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11740: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11741: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11742: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11743: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11744: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11745: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11746: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11747: FMT_TEMP[23] = (char) (x & 1 | 48);
11748: return String.valueOf (FMT_TEMP, 0, 24);
11749: }
11750: public static StringBuilder fmtAin24 (StringBuilder sb, int x) {
11751: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11752: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11753: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11754: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11755: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11756: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11757: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11758: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11759: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11760: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11761: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11762: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11763: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11764: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11765: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11766: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11767: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11768: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11769: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11770: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11771: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11772: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11773: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11774: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11775: return sb.append (FMT_TEMP, 0, 24);
11776: }
11777: public static StringBuilder fmtBin24 (StringBuilder sb, int x) {
11778: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11779: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11780: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11781: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11782: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11783: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11784: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11785: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11786: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11787: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11788: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11789: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11790: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11791: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11792: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11793: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11794: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11795: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11796: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11797: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11798: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11799: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11800: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11801: FMT_TEMP[23] = (char) (x & 1 | 48);
11802: return sb.append (FMT_TEMP, 0, 24);
11803: }
11804:
11805:
11806:
11807:
11808:
11809:
11810:
11811:
11812:
11813:
11814:
11815:
11816:
11817:
11818:
11819:
11820:
11821:
11822:
11823:
11824:
11825:
11826:
11827:
11828:
11829:
11830:
11831:
11832:
11833:
11834:
11835:
11836:
11837: public static char fmtHexc (int x) {
11838: x &= 15;
11839: return (char) ((((9 - x) >> 4) & 7) + 48 + x);
11840: }
11841: public static void fmtHex1 (char[] a, int o, int x) {
11842: x &= 15;
11843: a[o] = (char) ((((9 - x) >> 4) & 7) + 48 + x);
11844: }
11845: public static String fmtHex1 (int x) {
11846: x &= 15;
11847: return Character.toString ((char) ((((9 - x) >> 4) & 7) + 48 + x));
11848: }
11849: public static StringBuilder fmtHex1 (StringBuilder sb, int x) {
11850: x &= 15;
11851: return sb.append ((char) ((((9 - x) >> 4) & 7) + 48 + x));
11852: }
11853:
11854:
11855:
11856:
11857:
11858:
11859: public static void fmtHex2 (char[] a, int o, int x) {
11860: int x0 = x & 15;
11861: int x1 = x >>> 4 & 15;
11862: a[o ] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
11863: a[o + 1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
11864: }
11865: public static String fmtHex2 (int x) {
11866:
11867: int x0 = x & 15;
11868: int x1 = x >>> 4 & 15;
11869: FMT_TEMP[0] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
11870: FMT_TEMP[1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
11871: return String.valueOf (FMT_TEMP, 0, 2);
11872: }
11873: public static StringBuilder fmtHex2 (StringBuilder sb, int x) {
11874: int x0 = x & 15;
11875: int x1 = x >>> 4 & 15;
11876: return (sb.
11877: append ((char) ((((9 - x1) >> 4) & 7) + 48 + x1)).
11878: append ((char) ((((9 - x0) >> 4) & 7) + 48 + x0)));
11879: }
11880:
11881:
11882:
11883:
11884:
11885:
11886: public static void fmtHex4 (char[] a, int o, int x) {
11887: int t;
11888: t = (char) x >>> 12;
11889: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11890: t = x >>> 8 & 15;
11891: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11892: t = x >>> 4 & 15;
11893: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11894: t = x & 15;
11895: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11896: }
11897: public static String fmtHex4 (int x) {
11898:
11899: int t;
11900: t = (char) x >>> 12;
11901: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11902: t = x >>> 8 & 15;
11903: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11904: t = x >>> 4 & 15;
11905: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11906: t = x & 15;
11907: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11908: return String.valueOf (FMT_TEMP, 0, 4);
11909: }
11910: public static StringBuilder fmtHex4 (StringBuilder sb, int x) {
11911:
11912: int t;
11913: t = (char) x >>> 12;
11914: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11915: t = x >>> 8 & 15;
11916: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11917: t = x >>> 4 & 15;
11918: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11919: t = x & 15;
11920: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11921: return sb.append (FMT_TEMP, 0, 4);
11922: }
11923:
11924:
11925:
11926:
11927:
11928:
11929: public static void fmtHex6 (char[] a, int o, int x) {
11930: int t;
11931: t = x >>> 20 & 15;
11932: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11933: t = x >>> 16 & 15;
11934: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11935: t = (char) x >>> 12;
11936: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11937: t = x >>> 8 & 15;
11938: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11939: t = x >>> 4 & 15;
11940: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11941: t = x & 15;
11942: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11943: }
11944: public static String fmtHex6 (int x) {
11945:
11946: int t;
11947: t = x >>> 20 & 15;
11948: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11949: t = x >>> 16 & 15;
11950: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11951: t = (char) x >>> 12;
11952: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11953: t = x >>> 8 & 15;
11954: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11955: t = x >>> 4 & 15;
11956: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11957: t = x & 15;
11958: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11959: return String.valueOf (FMT_TEMP, 0, 6);
11960: }
11961: public static StringBuilder fmtHex6 (StringBuilder sb, int x) {
11962:
11963: int t;
11964: t = x >>> 20 & 15;
11965: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11966: t = x >>> 16 & 15;
11967: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11968: t = (char) x >>> 12;
11969: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11970: t = x >>> 8 & 15;
11971: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11972: t = x >>> 4 & 15;
11973: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11974: t = x & 15;
11975: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11976: return sb.append (FMT_TEMP, 0, 6);
11977: }
11978:
11979:
11980:
11981:
11982:
11983:
11984: public static void fmtHex8 (char[] a, int o, int x) {
11985: int t;
11986: t = x >>> 28;
11987: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11988: t = x >>> 24 & 15;
11989: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11990: t = x >>> 20 & 15;
11991: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11992: t = x >>> 16 & 15;
11993: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11994: t = (char) x >>> 12;
11995: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11996: t = x >>> 8 & 15;
11997: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11998: t = x >>> 4 & 15;
11999: a[o + 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12000: t = x & 15;
12001: a[o + 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12002: }
12003: public static String fmtHex8 (int x) {
12004:
12005: int t;
12006: t = x >>> 28;
12007: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12008: t = x >>> 24 & 15;
12009: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12010: t = x >>> 20 & 15;
12011: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12012: t = x >>> 16 & 15;
12013: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12014: t = (char) x >>> 12;
12015: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12016: t = x >>> 8 & 15;
12017: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12018: t = x >>> 4 & 15;
12019: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12020: t = x & 15;
12021: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12022: return String.valueOf (FMT_TEMP, 0, 8);
12023: }
12024: public static StringBuilder fmtHex8 (StringBuilder sb, int x) {
12025:
12026: int t;
12027: t = x >>> 28;
12028: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12029: t = x >>> 24 & 15;
12030: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12031: t = x >>> 20 & 15;
12032: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12033: t = x >>> 16 & 15;
12034: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12035: t = (char) x >>> 12;
12036: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12037: t = x >>> 8 & 15;
12038: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12039: t = x >>> 4 & 15;
12040: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12041: t = x & 15;
12042: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12043: return sb.append (FMT_TEMP, 0, 8);
12044: }
12045:
12046: public static StringBuilder fmtHex16 (StringBuilder sb, long x) {
12047:
12048: int s, t;
12049: s = (int) (x >>> 32);
12050: t = s >>> 28;
12051: FMT_TEMP[ 0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12052: t = s >>> 24 & 15;
12053: FMT_TEMP[ 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12054: t = s >>> 20 & 15;
12055: FMT_TEMP[ 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12056: t = s >>> 16 & 15;
12057: FMT_TEMP[ 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12058: t = (char) s >>> 12;
12059: FMT_TEMP[ 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12060: t = s >>> 8 & 15;
12061: FMT_TEMP[ 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12062: t = s >>> 4 & 15;
12063: FMT_TEMP[ 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12064: t = s & 15;
12065: FMT_TEMP[ 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12066: s = (int) x;
12067: t = s >>> 28;
12068: FMT_TEMP[ 8] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12069: t = s >>> 24 & 15;
12070: FMT_TEMP[ 9] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12071: t = s >>> 20 & 15;
12072: FMT_TEMP[10] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12073: t = s >>> 16 & 15;
12074: FMT_TEMP[11] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12075: t = (char) s >>> 12;
12076: FMT_TEMP[12] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12077: t = s >>> 8 & 15;
12078: FMT_TEMP[13] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12079: t = s >>> 4 & 15;
12080: FMT_TEMP[14] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12081: t = s & 15;
12082: FMT_TEMP[15] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12083: return sb.append (FMT_TEMP, 0, 16);
12084: }
12085:
12086:
12087:
12088:
12089:
12090:
12091:
12092:
12093:
12094:
12095:
12096:
12097:
12098:
12099:
12100:
12101:
12102:
12103:
12104:
12105:
12106:
12107:
12108:
12109:
12110:
12111:
12112:
12113:
12114:
12115:
12116:
12117:
12118:
12119:
12120:
12121:
12122:
12123:
12124:
12125:
12126:
12127:
12128:
12129:
12130:
12131:
12132:
12133:
12134:
12135:
12136:
12137:
12138:
12139:
12140:
12141:
12142:
12143:
12144:
12145:
12146:
12147:
12148:
12149:
12150:
12151:
12152:
12153: public static final int[] FMT_BCD4 = new int[10000];
12154: public static final int[] FMT_DCB4 = new int[65536];
12155:
12156:
12157:
12158:
12159: public static void fmtInit () {
12160: Arrays.fill (FMT_DCB4, -1);
12161: int i = 0;
12162: int x = 0;
12163: for (int a = 0; a < 10; a++) {
12164: for (int b = 0; b < 10; b++) {
12165: for (int c = 0; c < 10; c++) {
12166: FMT_DCB4[FMT_BCD4[i ] = x ] = i;
12167: FMT_DCB4[FMT_BCD4[i + 1] = x + 1] = i + 1;
12168: FMT_DCB4[FMT_BCD4[i + 2] = x + 2] = i + 2;
12169: FMT_DCB4[FMT_BCD4[i + 3] = x + 3] = i + 3;
12170: FMT_DCB4[FMT_BCD4[i + 4] = x + 4] = i + 4;
12171: FMT_DCB4[FMT_BCD4[i + 5] = x + 5] = i + 5;
12172: FMT_DCB4[FMT_BCD4[i + 6] = x + 6] = i + 6;
12173: FMT_DCB4[FMT_BCD4[i + 7] = x + 7] = i + 7;
12174: FMT_DCB4[FMT_BCD4[i + 8] = x + 8] = i + 8;
12175: FMT_DCB4[FMT_BCD4[i + 9] = x + 9] = i + 9;
12176: i += 10;
12177: x += 1 << 4;
12178: }
12179: x += 6 << 4;
12180: }
12181: x += 6 << 8;
12182: }
12183: }
12184:
12185:
12186:
12187: public static int fmtBcd4 (int x) {
12188:
12189:
12190:
12191:
12192:
12193:
12194:
12195:
12196:
12197: return FMT_BCD4[Math.max (0, Math.min (9999, x))];
12198: }
12199:
12200:
12201:
12202: public static int fmtBcd8 (int x) {
12203: x = Math.max (0, Math.min (99999999, x));
12204:
12205:
12206: int q = (int) ((long) x * 109951163L >>> 40);
12207:
12208: return FMT_BCD4[q] << 16 | FMT_BCD4[x - 10000 * q];
12209: }
12210:
12211:
12212:
12213: public static long fmtBcd12 (long x) {
12214: x = Math.max (0L, Math.min (999999999999L, x));
12215: int q = (int) ((double) x / 100000000.0);
12216: int r = (int) (x - 100000000L * q);
12217:
12218:
12219: int rq = (int) ((long) r * 109951163L >>> 40);
12220:
12221: return (long) FMT_BCD4[q] << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
12222: }
12223:
12224:
12225:
12226: public static long fmtBcd16 (long x) {
12227: x = Math.max (0L, Math.min (9999999999999999L, x));
12228: int q = x <= (1L << 53) ? (int) ((double) x / 100000000.0) : (int) (x / 100000000L);
12229: int r = (int) (x - 100000000L * q);
12230:
12231:
12232: int qq = (int) ((long) q * 109951163L >>> 40);
12233:
12234:
12235:
12236: int rq = (int) ((long) r * 109951163L >>> 40);
12237:
12238: return (long) (FMT_BCD4[qq] << 16 | FMT_BCD4[q - 10000 * qq]) << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
12239: }
12240:
12241:
12242:
12243:
12244:
12245:
12246: public static int fmtCA02u (char[] a, int o, int x) {
12247: if (x < 0 || 99 < x) {
12248: x = 99;
12249: }
12250: x = FMT_BCD4[x];
12251: a[o ] = (char) ('0' | x >>> 4);
12252: a[o + 1] = (char) ('0' | x & 15);
12253: return o + 2;
12254: }
12255: public static StringBuilder fmtSB02u (StringBuilder sb, int x) {
12256: return sb.append (FMT_TEMP, 0, fmtCA02u (FMT_TEMP, 0, x));
12257: }
12258:
12259:
12260:
12261:
12262:
12263: public static int fmtCA2u (char[] a, int o, int x) {
12264: if (x < 0 || 99 < x) {
12265: x = 99;
12266: }
12267: x = FMT_BCD4[x];
12268: if (x <= 0x000f) {
12269: a[o++] = (char) ('0' | x);
12270: } else {
12271: a[o++] = (char) ('0' | x >>> 4);
12272: a[o++] = (char) ('0' | x & 15);
12273: }
12274: return o;
12275: }
12276: public static StringBuilder fmtSB2u (StringBuilder sb, int x) {
12277: return sb.append (FMT_TEMP, 0, fmtCA2u (FMT_TEMP, 0, x));
12278: }
12279:
12280:
12281:
12282:
12283:
12284: public static int fmtCA04u (char[] a, int o, int x) {
12285: if (x < 0 || 9999 < x) {
12286: x = 9999;
12287: }
12288: x = FMT_BCD4[x];
12289: a[o ] = (char) ('0' | x >>> 12);
12290: a[o + 1] = (char) ('0' | x >>> 8 & 15);
12291: a[o + 2] = (char) ('0' | x >>> 4 & 15);
12292: a[o + 3] = (char) ('0' | x & 15);
12293: return o + 4;
12294: }
12295: public static StringBuilder fmtSB04u (StringBuilder sb, int x) {
12296: return sb.append (FMT_TEMP, 0, fmtCA04u (FMT_TEMP, 0, x));
12297: }
12298:
12299:
12300:
12301:
12302:
12303: public static int fmtCA4u (char[] a, int o, int x) {
12304: if (x < 0 || 9999 < x) {
12305: x = 9999;
12306: }
12307: x = FMT_BCD4[x];
12308: if (x <= 0x000f) {
12309: a[o++] = (char) ('0' | x);
12310: } else if (x <= 0x00ff) {
12311: a[o++] = (char) ('0' | x >>> 4);
12312: a[o++] = (char) ('0' | x & 15);
12313: } else if (x <= 0x0fff) {
12314: a[o++] = (char) ('0' | x >>> 8);
12315: a[o++] = (char) ('0' | x >>> 4 & 15);
12316: a[o++] = (char) ('0' | x & 15);
12317: } else {
12318: a[o++] = (char) ('0' | x >>> 12);
12319: a[o++] = (char) ('0' | x >>> 8 & 15);
12320: a[o++] = (char) ('0' | x >>> 4 & 15);
12321: a[o++] = (char) ('0' | x & 15);
12322: }
12323: return o;
12324: }
12325: public static StringBuilder fmtSB4u (StringBuilder sb, int x) {
12326: return sb.append (FMT_TEMP, 0, fmtCA4u (FMT_TEMP, 0, x));
12327: }
12328:
12329:
12330:
12331:
12332:
12333: public static int fmtCA08u (char[] a, int o, int x) {
12334: if (x < 0 || 99999999 < x) {
12335: x = 99999999;
12336: }
12337:
12338:
12339: int h = (int) ((long) x * 109951163L >>> 40);
12340: return fmtCA04u (a, fmtCA04u (a, o, h), x - h * 10000);
12341: }
12342: public static StringBuilder fmtSB08u (StringBuilder sb, int x) {
12343: return sb.append (FMT_TEMP, 0, fmtCA08u (FMT_TEMP, 0, x));
12344: }
12345:
12346:
12347:
12348:
12349:
12350: public static int fmtCA8u (char[] a, int o, int x) {
12351: if (x < 0 || 99999999 < x) {
12352: x = 99999999;
12353: }
12354: if (x <= 9999) {
12355: return fmtCA4u (a, o, x);
12356: } else {
12357:
12358:
12359: int h = (int) ((long) x * 109951163L >>> 40);
12360: return fmtCA04u (a, fmtCA4u (a, o, h), x - h * 10000);
12361: }
12362: }
12363: public static StringBuilder fmtSB8u (StringBuilder sb, int x) {
12364: return sb.append (FMT_TEMP, 0, fmtCA8u (FMT_TEMP, 0, x));
12365: }
12366:
12367:
12368:
12369:
12370:
12371: public static int fmtCAd (char[] a, int o, long x) {
12372: if (x < 0L) {
12373: x = -x;
12374: a[o++] = '-';
12375: }
12376: if (x <= 99999999L) {
12377: return fmtCA8u (a, o, (int) x);
12378: } else if (x <= 9999999999999999L) {
12379: long h = x / 100000000L;
12380: return fmtCA08u (a, fmtCA8u (a, o, (int) h), (int) (x - h * 100000000L));
12381: } else {
12382: long hh = x / 10000000000000000L;
12383: x -= hh * 10000000000000000L;
12384: long h = x / 100000000L;
12385: return fmtCA08u (a, fmtCA08u (a, fmtCA4u (a, o, (int) hh), (int) h), (int) (x - h * 100000000L));
12386: }
12387: }
12388: public static StringBuilder fmtSBd (StringBuilder sb, long x) {
12389: return sb.append (FMT_TEMP, 0, fmtCAd (FMT_TEMP, 0, x));
12390: }
12391:
12392:
12393:
12394:
12395:
12396:
12397: public static int fmtCAnd (char[] a, int o, int n, long x) {
12398: int t = fmtCAd (a, o, x);
12399: n += o;
12400: if (t < n) {
12401: int i = n;
12402: while (o < t) {
12403: a[--i] = a[--t];
12404: }
12405: while (o < i) {
12406: a[--i] = ' ';
12407: }
12408: t = n;
12409: }
12410: return t;
12411: }
12412: public static StringBuilder fmtSBnd (StringBuilder sb, int n, int x) {
12413: return sb.append (FMT_TEMP, 0, fmtCAnd (FMT_TEMP, 0, n, x));
12414: }
12415:
12416:
12417:
12418:
12419:
12420:
12421:
12422:
12423:
12424:
12425:
12426:
12427:
12428: public static int fmtParseInt (String s, int i, int min, int max, int err) {
12429: return fmtParseIntRadix (s, i, min, max, err, 10);
12430: }
12431: public static int fmtParseIntRadix (String s, int i, int min, int max, int err, int radix) {
12432: if (s == null) {
12433: return err;
12434: }
12435: int l = s.length ();
12436: int c = i < l ? s.charAt (i++) : -1;
12437:
12438: while (c == ' ' || c == '\t') {
12439: c = i < l ? s.charAt (i++) : -1;
12440: }
12441:
12442: int n = 0;
12443: if (c == '+') {
12444: c = i < l ? s.charAt (i++) : -1;
12445: } else if (c == '-') {
12446: n = 1;
12447: c = i < l ? s.charAt (i++) : -1;
12448: }
12449:
12450:
12451:
12452:
12453: int o;
12454: int p;
12455: if (c == '$') {
12456: o = 0x07ffffff + n;
12457: p = 15 + n & 15;
12458: radix = 16;
12459: c = i < l ? s.charAt (i++) : -1;
12460: } else if (radix == 16) {
12461: o = 0x07ffffff + n;
12462: p = 15 + n & 15;
12463: } else if (radix == 8) {
12464: o = 0x0fffffff + n;
12465: p = 7 + n & 7;
12466: } else if (radix == 2) {
12467: o = 0x3fffffff + n;
12468: p = 1 + n & 1;
12469: } else {
12470: o = 214748364;
12471: p = 7 + n;
12472: radix = 10;
12473: }
12474:
12475: int x = Character.digit (c, radix);
12476: if (x < 0) {
12477: return err;
12478: }
12479: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12480: while (c >= 0) {
12481: int t = x - o;
12482: if (t > 0 || t == 0 && c > p) {
12483: return err;
12484: }
12485: x = x * radix + c;
12486: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12487: }
12488: if (n != 0) {
12489: x = -x;
12490: }
12491: return min <= x && x <= max ? x : err;
12492: }
12493:
12494:
12495:
12496:
12497:
12498:
12499:
12500:
12501:
12502:
12503: public static long matMax3 (long x1, long x2, long x3) {
12504: return Math.max (Math.max (x1, x2), x3);
12505: }
12506: public static long matMax4 (long x1, long x2, long x3, long x4) {
12507: return Math.max (Math.max (x1, x2), Math.max (x3, x4));
12508: }
12509: public static long matMax5 (long x1, long x2, long x3, long x4, long x5) {
12510: return Math.max (Math.max (Math.max (x1, x2), Math.max (x3, x4)), x5);
12511: }
12512:
12513:
12514:
12515:
12516:
12517: public static long matMin3 (long x1, long x2, long x3) {
12518: return Math.min (Math.min (x1, x2), x3);
12519: }
12520: public static long matMin4 (long x1, long x2, long x3, long x4) {
12521: return Math.min (Math.min (x1, x2), Math.min (x3, x4));
12522: }
12523: public static long matMin5 (long x1, long x2, long x3, long x4, long x5) {
12524: return Math.min (Math.min (Math.min (x1, x2), Math.min (x3, x4)), x5);
12525: }
12526:
12527:
12528:
12529:
12530:
12531:
12532:
12533:
12534:
12535:
12536:
12537:
12538: public static String strEncodeUTF8 (String s) {
12539: StringBuilder sb = new StringBuilder ();
12540: int l = s.length ();
12541: for (int i = 0; i < l; i++) {
12542: int u = s.charAt (i);
12543: if (0xd800 <= u && u <= 0xdbff && i + 1 < l) {
12544: int v = s.charAt (i + 1);
12545: if (0xdc00 <= v && v <= 0xdfff) {
12546: u = 0x10000 + ((u & 0x3ff) << 10) + (v & 0x3ff);
12547: i++;
12548: }
12549: }
12550: if ((u & 0xffffff80) == 0) {
12551: sb.append ((char) u);
12552: } else if ((u & 0xfffff800) == 0) {
12553: u = (0x0000c080 |
12554: (u & 0x000007c0) << 2 |
12555: (u & 0x0000003f));
12556: sb.append ((char) (u >> 8)).append ((char) (u & 0xff));
12557: } else if ((u & 0xffff0000) == 0 && !(0xd800 <= u && u <= 0xdfff)) {
12558: u = (0x00e08080 |
12559: (u & 0x0000f000) << 4 |
12560: (u & 0x00000fc0) << 2 |
12561: (u & 0x0000003f));
12562: sb.append ((char) (u >> 16)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12563: } else if ((u & 0xffe00000) == 0) {
12564: u = (0xf0808080 |
12565: (u & 0x001c0000) << 6 |
12566: (u & 0x0003f000) << 4 |
12567: (u & 0x00000fc0) << 2 |
12568: (u & 0x0000003f));
12569: sb.append ((char) ((u >> 24) & 0xff)).append ((char) ((u >> 16) & 0xff)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12570: } else {
12571: sb.append ((char) 0xef).append ((char) 0xbf).append ((char) 0xbd);
12572: }
12573: }
12574: return sb.toString ();
12575: }
12576:
12577:
12578:
12579:
12580:
12581:
12582:
12583: public static String strDecodeUTF8 (String s) {
12584: StringBuilder sb = new StringBuilder ();
12585: int l = s.length ();
12586: for (int i = 0; i < l; i++) {
12587: int c = s.charAt (i) & 0xff;
12588: for (int k = ((c & 0x80) == 0x00 ? 0 :
12589: (c & 0xe0) == 0xc0 ? 1 :
12590: (c & 0xf0) == 0xe0 ? 2 :
12591: (c & 0xf8) == 0xf0 ? 3 :
12592: -1);
12593: --k >= 0; ) {
12594: c = c << 8 | (i + 1 < l ? s.charAt (++i) & 0xff : 0);
12595: }
12596: int u = ((c & 0xffffff80) == 0x00000000 ? c :
12597: (c & 0xffffe0c0) == 0x0000c080 ? ((c & 0x00001f00) >> 2 |
12598: (c & 0x0000003f)) :
12599: (c & 0xfff0c0c0) == 0x00e08080 ? ((c & 0x000f0000) >> 4 |
12600: (c & 0x00003f00) >> 2 |
12601: (c & 0x0000003f)) :
12602: (c & 0xf8c0c0c0) == 0xf0808080 ? ((c & 0x07000000) >> 6 |
12603: (c & 0x003f0000) >> 4 |
12604: (c & 0x00003f00) >> 2 |
12605: (c & 0x0000003f)) :
12606: 0xfffd);
12607: if (u <= 0x0000ffff) {
12608: sb.append (0xd800 <= u && u <= 0xdfff ? '\ufffd' :
12609: (char) u);
12610: } else if (u <= 0x0010ffff) {
12611: u -= 0x000010000;
12612: sb.append ((char) (0xd800 + ((u >> 10) & 0x3ff))).append ((char) (0xdc00 + (u & 0x3ff)));
12613: }
12614: }
12615: return sb.toString ();
12616: }
12617:
12618:
12619:
12620:
12621:
12622: public static final int[] IsURIChar = {
12623:
12624:
12625: 0b00000000_00000000_00000000_00000000,
12626: 0b00000000_00000110_11111111_11000000,
12627: 0b01111111_11111111_11111111_11100001,
12628: 0b01111111_11111111_11111111_11100010,
12629: };
12630: public static String strEncodeURI (String s) {
12631: s = strEncodeUTF8 (s);
12632: StringBuilder sb = new StringBuilder ();
12633: int l = s.length ();
12634: for (int i = 0; i < l; i++) {
12635: int c = s.charAt (i);
12636: if (c < 0x80 && IsURIChar[c >> 5] << c < 0) {
12637: sb.append ((char) c);
12638: } else {
12639: fmtHex2 (sb.append ('%'), c);
12640: }
12641: }
12642: return sb.toString ();
12643: }
12644:
12645:
12646:
12647:
12648:
12649: public static final byte[] strIsHexChar = {
12650:
12651: -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,
12652: -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,
12653: -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,
12654: -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,
12655: };
12656: public static String strDecodeURI (String s) {
12657: StringBuilder sb = new StringBuilder ();
12658: int l = s.length ();
12659: for (int i = 0; i < l; i++) {
12660: int c = s.charAt (i);
12661: if (c == '%' && i + 2 < l) {
12662: int d = s.charAt (i + 1);
12663: int e = s.charAt (i + 2);
12664: if (d < 0x80 && (d = strIsHexChar[d]) >= 0 &&
12665: e < 0x80 && (e = strIsHexChar[e]) >= 0) {
12666: sb.append ((char) (d << 4 | e));
12667: } else {
12668: sb.append ((char) c);
12669: }
12670: } else {
12671: sb.append ((char) c);
12672: }
12673: }
12674: return sb.toString ();
12675: }
12676:
12677:
12678:
12679:
12680:
12681:
12682:
12683:
12684: public static BufferedImage createImage (int width, int height, String pattern, int... rgbs) {
12685: BufferedImage image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
12686: int[] bitmap = ((DataBufferInt) image.getRaster ().getDataBuffer ()).getData ();
12687: int length = width * height;
12688: for (int i = 0; i < length; i++) {
12689: char c = pattern.charAt (i);
12690: bitmap[i] = rgbs[c < '0' ? 0 : Character.digit (c, 16)];
12691: }
12692: return image;
12693: }
12694:
12695:
12696:
12697: public static ImageIcon createImageIcon (int width, int height, String pattern, int... rgbs) {
12698: return new ImageIcon (createImage (width, height, pattern, rgbs));
12699: }
12700:
12701:
12702:
12703: public static TexturePaint createTexturePaint (int width, int height, String pattern, int... rgbs) {
12704: return new TexturePaint (createImage (width, height, pattern, rgbs), new Rectangle (0, 0, width, height));
12705: }
12706:
12707:
12708:
12709: public static BufferedImage loadImage (String name) {
12710: BufferedImage image = null;
12711: try {
12712: image = ImageIO.read (new File (name));
12713: } catch (Exception e) {
12714: }
12715: return image;
12716: }
12717:
12718:
12719:
12720:
12721: public static boolean saveImage (BufferedImage image, String name) {
12722: return saveImage (image, name, 0.75F);
12723: }
12724: public static boolean saveImage (BufferedImage image, String name, float quality) {
12725: int index = name.lastIndexOf (".");
12726: if (index < 0) {
12727: return false;
12728: }
12729: if (name.substring (index).equalsIgnoreCase (".ico")) {
12730: return saveIcon (name, image);
12731: }
12732: Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix (name.substring (index + 1));
12733: if (!iterator.hasNext ()) {
12734: return false;
12735: }
12736: ImageWriter imageWriter = iterator.next ();
12737: ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam ();
12738: if (imageWriteParam.canWriteCompressed ()) {
12739: imageWriteParam.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);
12740: imageWriteParam.setCompressionQuality (quality);
12741: }
12742: try {
12743: File file = new File (name);
12744: ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream (file);
12745: imageWriter.setOutput (imageOutputStream);
12746: imageWriter.write (null, new IIOImage (image, null, null), imageWriteParam);
12747: imageOutputStream.close ();
12748: } catch (Exception e) {
12749:
12750: return false;
12751: }
12752: return true;
12753: }
12754:
12755:
12756:
12757:
12758:
12759:
12760:
12761:
12762:
12763:
12764:
12765:
12766:
12767:
12768:
12769:
12770:
12771:
12772:
12773:
12774:
12775:
12776:
12777:
12778:
12779:
12780:
12781:
12782:
12783:
12784:
12785:
12786:
12787:
12788:
12789:
12790:
12791:
12792:
12793:
12794:
12795:
12796:
12797:
12798:
12799:
12800:
12801:
12802:
12803:
12804:
12805:
12806:
12807:
12808:
12809:
12810:
12811:
12812:
12813:
12814:
12815:
12816:
12817:
12818:
12819:
12820:
12821:
12822:
12823:
12824:
12825:
12826:
12827: public static boolean saveIcon (String fileName, BufferedImage... arrayImage) {
12828: int iconCount = arrayImage.length;
12829: int[][] arrayPaletTable = new int[iconCount][];
12830: int[] arrayPaletCount = new int[iconCount];
12831: int[] arrayPixelBits = new int[iconCount];
12832: int[] arrayPatternLineSize = new int[iconCount];
12833: int[] arrayMaskLineSize = new int[iconCount];
12834: int[] arrayImageSize = new int[iconCount];
12835: int[] arrayImageOffset = new int[iconCount];
12836: int fileSize = 6 + 16 * iconCount;
12837: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
12838: BufferedImage image = arrayImage[iconNumber];
12839: int width = image.getWidth ();
12840: int height = image.getHeight ();
12841:
12842: int[] paletTable = new int[256];
12843: int paletCount = 0;
12844: countPalet:
12845: for (int y = height - 1; y >= 0; y--) {
12846: for (int x = 0; x < width; x++) {
12847: int rgb = image.getRGB (x, y);
12848: if (rgb >>> 24 != 0xff) {
12849: continue;
12850: }
12851: int l = 0;
12852: int r = paletCount;
12853: while (l < r) {
12854: int m = l + r >> 1;
12855: if (paletTable[m] < rgb) {
12856: l = m + 1;
12857: } else {
12858: r = m;
12859: }
12860: }
12861: if (l == paletCount || paletTable[l] != rgb) {
12862: if (paletCount == 256) {
12863: paletCount = 0;
12864: break countPalet;
12865: }
12866: for (int i = paletCount; i > l; i--) {
12867: paletTable[i] = paletTable[i - 1];
12868: }
12869: paletTable[l] = rgb;
12870: paletCount++;
12871: }
12872: }
12873: }
12874: int pixelBits = (paletCount == 0 ? 24 :
12875: paletCount > 16 ? 8 :
12876: paletCount > 4 ? 4 :
12877: paletCount > 2 ? 2 :
12878: 1);
12879: int patternLineSize = pixelBits * width + 31 >> 5 << 2;
12880: int maskLineSize = width + 31 >> 5 << 2;
12881: int imageSize = 40 + 4 * paletCount + patternLineSize * height + maskLineSize * height;
12882: arrayPaletTable[iconNumber] = paletTable;
12883: arrayPaletCount[iconNumber] = paletCount;
12884: arrayPixelBits[iconNumber] = pixelBits;
12885: arrayPatternLineSize[iconNumber] = patternLineSize;
12886: arrayMaskLineSize[iconNumber] = maskLineSize;
12887: arrayImageSize[iconNumber] = imageSize;
12888: arrayImageOffset[iconNumber] = fileSize;
12889: fileSize += imageSize;
12890: }
12891: byte[] bb = new byte[fileSize];
12892:
12893: ByteArray.byaWiw (bb, 0, 0);
12894: ByteArray.byaWiw (bb, 2, 1);
12895: ByteArray.byaWiw (bb, 4, iconCount);
12896: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
12897: BufferedImage image = arrayImage[iconNumber];
12898: int width = image.getWidth ();
12899: int height = image.getHeight ();
12900: int[] paletTable = arrayPaletTable[iconNumber];
12901: int paletCount = arrayPaletCount[iconNumber];
12902: int pixelBits = arrayPixelBits[iconNumber];
12903: int patternLineSize = arrayPatternLineSize[iconNumber];
12904: int maskLineSize = arrayMaskLineSize[iconNumber];
12905: int imageSize = arrayImageSize[iconNumber];
12906: int imageOffset = arrayImageOffset[iconNumber];
12907:
12908: int o = 6 + 16 * iconNumber;
12909: ByteArray.byaWb (bb, o, width);
12910: ByteArray.byaWb (bb, o + 1, height);
12911: ByteArray.byaWb (bb, o + 2, paletCount);
12912: ByteArray.byaWb (bb, o + 3, 0);
12913: ByteArray.byaWiw (bb, o + 4, 1);
12914: ByteArray.byaWiw (bb, o + 6, pixelBits);
12915: ByteArray.byaWil (bb, o + 8, imageSize);
12916: ByteArray.byaWil (bb, o + 12, imageOffset);
12917:
12918: o = imageOffset;
12919: ByteArray.byaWil (bb, o, 40);
12920: ByteArray.byaWil (bb, o + 4, width);
12921: ByteArray.byaWil (bb, o + 8, height * 2);
12922: ByteArray.byaWiw (bb, o + 12, 1);
12923: ByteArray.byaWiw (bb, o + 14, pixelBits);
12924: ByteArray.byaWil (bb, o + 16, 0);
12925: ByteArray.byaWil (bb, o + 20, 0);
12926: ByteArray.byaWil (bb, o + 24, 0);
12927: ByteArray.byaWil (bb, o + 28, 0);
12928: ByteArray.byaWil (bb, o + 32, paletCount);
12929: ByteArray.byaWil (bb, o + 36, 0);
12930:
12931: o += 40;
12932: for (int i = 0; i < paletCount; i++) {
12933: ByteArray.byaWil (bb, o, paletTable[i] & 0x00ffffff);
12934: o += 4;
12935: }
12936:
12937: for (int y = height - 1; y >= 0; y--) {
12938: for (int x = 0; x < width; x++) {
12939: int rgb = image.getRGB (x, y);
12940: if (rgb >>> 24 != 0xff) {
12941: continue;
12942: }
12943: if (pixelBits == 24) {
12944: bb[o + 3 * x] = (byte) rgb;
12945: bb[o + 3 * x + 1] = (byte) (rgb >> 8);
12946: bb[o + 3 * x + 2] = (byte) (rgb >> 16);
12947: continue;
12948: }
12949: int l = 0;
12950: int r = paletCount;
12951: while (l < r) {
12952: int m = l + r >> 1;
12953: if (paletTable[m] < rgb) {
12954: l = m + 1;
12955: } else {
12956: r = m;
12957: }
12958: }
12959: if (l != 0) {
12960: if (pixelBits == 8) {
12961: bb[o + x] = (byte) l;
12962: } else if (pixelBits == 4) {
12963: bb[o + (x >> 1)] |= (byte) (l << ((~x & 1) << 2));
12964: } else if (pixelBits == 2) {
12965: bb[o + (x >> 2)] |= (byte) (l << ((~x & 3) << 1));
12966: } else {
12967: bb[o + (x >> 3)] |= (byte) (l << (~x & 7));
12968: }
12969: }
12970: }
12971: o += patternLineSize;
12972: }
12973:
12974: for (int y = height - 1; y >= 0; y--) {
12975: for (int x = 0; x < width; x++) {
12976: int rgb = image.getRGB (x, y);
12977: if (rgb >>> 24 != 0xff) {
12978: bb[o + (x >> 3)] |= (byte) (1 << (~x & 7));
12979: }
12980: }
12981: o += maskLineSize;
12982: }
12983: }
12984: return rscPutFile (fileName, bb, 0, fileSize);
12985: }
12986:
12987:
12988:
12989: }
12990:
12991:
12992: