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.02.08";
54: public static final String PRG_AUTHOR = "Makoto Kamada";
55: public static final String PRG_WEBPAGE = "https://stdkmd.net/xeij/";
56:
57: public static final String PRG_JAVA_VENDOR = "Oracle Corporation";
58: public static final String PRG_JAVA_VERSION = "25.0.1";
59: public static final String PRG_OS_ARCH = "amd64";
60: public static final String PRG_OS_NAME = "Windows 11";
61:
62:
63:
64:
65:
66:
67:
68: public static final boolean TEST_BIT_0_SHIFT = false;
69: public static final boolean TEST_BIT_1_SHIFT = false;
70: public static final boolean TEST_BIT_2_SHIFT = true;
71: public static final boolean TEST_BIT_3_SHIFT = true;
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89: public static final boolean SHORT_SATURATION_CAST = false;
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101: public static final Charset ISO_8859_1 = Charset.forName ("ISO-8859-1");
102: static {
103: if (false) {
104:
105: StringBuilder sb = new StringBuilder ();
106: for (int i = 0; i < 256; i++) {
107: sb.append ((char) i);
108: }
109: byte[] bb = sb.toString ().getBytes (ISO_8859_1);
110: for (int i = 0; i < 256; i++) {
111: System.out.printf ("%02x %02x %s\n", i, bb[i] & 255, i == (bb[i] & 255) ? "OK" : "ERROR");
112: }
113: }
114: }
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127: public static String prgJavaVendor;
128: public static String prgJavaVersion;
129: public static String prgOsArch;
130: public static String prgOsName;
131: public static boolean prgIsLinux;
132: public static boolean prgIsMac;
133: public static boolean prgIsWindows;
134:
135: public static boolean prgCaseIgnored;
136:
137: public static boolean prgVerbose;
138:
139: public static String[] prgArgs;
140:
141:
142:
143: public static void main (String[] args) {
144:
145:
146:
147:
148: if (true) {
149: try {
150: String def = System.getProperty ("os.name").toLowerCase ().contains ("win") ? "C:\\Temp" : "/tmp";
151: Stream.of (new File (System.getProperty ("java.io.tmpdir", def),
152: "jSerialComm").getCanonicalFile ().toPath (),
153: new File (System.getProperty ("user.home", def),
154: ".jSerialComm").getCanonicalFile ().toPath ())
155: .filter (Files::exists)
156: .forEach (dir -> {
157: try {
158: Files.walk (dir)
159: .sorted (Comparator.reverseOrder ())
160: .forEach (path -> {
161: if (Files.exists (path)) {
162: try {
163: Files.delete (path);
164:
165: } catch (IOException ioe) {
166: System.err.println ("Failed to delete: " + path + " (" + ioe.getMessage () + ")");
167: }
168: }
169: });
170: } catch (IOException ioe) {
171: System.err.println ("Failed to walk: " + dir + " (" + ioe.getMessage () + ")");
172: }
173: });
174: } catch (IOException ioe) {
175: }
176: }
177:
178: prgArgs = args;
179:
180:
181: SwingUtilities.invokeLater (new Runnable () {
182: @Override public void run () {
183: new XEiJ ();
184: }
185: });
186:
187: }
188:
189:
190:
191: public XEiJ () {
192:
193: prgJavaVendor = System.getProperty ("java.vendor");
194: prgJavaVersion = System.getProperty ("java.version");
195: prgOsArch = System.getProperty ("os.arch");
196: prgOsName = System.getProperty ("os.name");
197: prgIsLinux = 0 <= prgOsName.indexOf ("Linux");
198: prgIsMac = 0 <= prgOsName.indexOf ("Mac");
199: prgIsWindows = 0 <= prgOsName.indexOf ("Windows");
200:
201: System.out.print ("\n" +
202: "-------------------------------------------------\n" +
203: PRG_TITLE + " version " + PRG_VERSION + "\n" +
204: "-------------------------------------------------\n");
205:
206:
207:
208:
209: prgCaseIgnored = new File ("A").equals (new File ("a"));
210: fmtInit ();
211: Multilingual.mlnInit ();
212:
213: System.out.println (Multilingual.mlnJapanese ? "java.vendor は " + prgJavaVendor + " です" :
214: "java.vendor is " + prgJavaVendor);
215: System.out.println (Multilingual.mlnJapanese ? "java.version は " + prgJavaVersion + " です" :
216: "java.version is " + prgJavaVersion);
217: System.out.println (Multilingual.mlnJapanese ? "os.arch は " + prgOsArch + " です" :
218: "os.arch is " + prgOsArch);
219: System.out.println (Multilingual.mlnJapanese ? "os.name は " + prgOsName + " です" :
220: "os.name is " + prgOsName);
221:
222: rbtInit ();
223:
224: Settings.sgsInit ();
225: LnF.lnfInit ();
226: Bubble.bblInit ();
227:
228: CharacterCode.chrInit ();
229:
230: TickerQueue.tkqInit ();
231:
232: RS232CTerminal.trmInit ();
233:
234: if (MercuryUnit.MU4_ON) {
235: MercuryUnit.mu4Init ();
236: }
237: xt3Init ();
238: mdlInit ();
239:
240: if (InstructionBreakPoint.IBP_ON) {
241: InstructionBreakPoint.ibpInit ();
242: }
243: if (DataBreakPoint.DBP_ON) {
244: DataBreakPoint.dbpInit ();
245: }
246: busInit ();
247: MainMemory.mmrInit ();
248: ROM.romInit ();
249: CRTC.crtInit ();
250: VideoController.vcnInit ();
251: HD63450.dmaInit ();
252: svsInit ();
253: MC68901.mfpInit ();
254: RP5C15.rtcInit ();
255: sysInit ();
256: if (OPMLog.OLG_ON) {
257: OPMLog.olgInit ();
258: }
259: OPM.opmInit ();
260: ADPCM.pcmInit ();
261: FDC.fdcInit ();
262: HDC.hdcInit ();
263: if (HostCDROM.HCD_ENABLED) {
264: HostCDROM.hcdInit ();
265: }
266: SPC.spcInit ();
267: Z8530.sccInit ();
268: IOInterrupt.ioiInit ();
269: SpriteScreen.sprInit ();
270: bnkInit ();
271: SRAM.smrInit ();
272:
273: PPI.ppiInit ();
274: PrinterPort.prnInit ();
275: Indicator.indInit ();
276:
277: SlowdownTest.sdtInit ();
278: Keyboard.kbdInit ();
279: CONDevice.conInit ();
280: Mouse.musInit ();
281: pnlInit ();
282: frmInit ();
283:
284: dbgInit ();
285: RegisterList.drpInit ();
286: DisassembleList.ddpInit ();
287: MemoryDumpList.dmpInit ();
288: LogicalSpaceMonitor.atwInit ();
289: PhysicalSpaceMonitor.paaInit ();
290: DebugConsole.dgtInit ();
291: if (BranchLog.BLG_ON) {
292: BranchLog.blgInit ();
293: }
294: if (ProgramFlowVisualizer.PFV_ON) {
295: ProgramFlowVisualizer.pfvInit ();
296: }
297: if (RasterBreakPoint.RBP_ON) {
298: RasterBreakPoint.rbpInit ();
299: }
300: if (ScreenModeTest.SMT_ON) {
301: ScreenModeTest.smtInit ();
302: }
303: if (RootPointerList.RTL_ON) {
304: RootPointerList.rtlInit ();
305: }
306: if (SpritePatternViewer.SPV_ON) {
307: SpritePatternViewer.spvInit ();
308: }
309: if (PaletteViewer.PLV_ON) {
310: PaletteViewer.plvInit ();
311: }
312: if (ATCMonitor.ACM_ON) {
313: ATCMonitor.acmInit ();
314: }
315:
316: SoundSource.sndInit ();
317: FEFunction.fpkInit ();
318: mpuInit ();
319: MC68060.mmuInit ();
320: SoundMonitor.smnInit ();
321: HFS.hfsInit ();
322:
323: GIFAnimation.gifInit ();
324: TextCopy.txcInit ();
325: ButtonFunction.bfnInit ();
326:
327:
328:
329: Settings.sgsMakeMenu ();
330: mdlMakeMenu ();
331: FDC.fdcMakeMenu ();
332: HDC.hdcMakeMenu ();
333: SPC.spcMakeMenu ();
334: mpuMakeMenu ();
335: SRAM.smrMakeMenu ();
336: clpMake ();
337: pnlMake ();
338: mnbMakeMenu ();
339: frmMake ();
340: dbgMakePopup ();
341:
342:
343: final String flags = (
344: "" +
345: (EFPBox.CIR_DEBUG_TRACE ? " EFPBox.CIR_DEBUG_TRACE" : "") +
346: (FDC.FDC_DEBUG_TRACE ? " FDC.FDC_DEBUG_TRACE" : "") +
347: (FEFunction.FPK_DEBUG_TRACE ? " FEFunction.FPK_DEBUG_TRACE" : "") +
348: (HD63450.DMA_DEBUG_TRACE != 0 ? " HD63450.DMA_DEBUG_TRACE" : "") +
349: (HDC.HDC_DEBUG_TRACE ? " HDC.HDC_DEBUG_TRACE" : "") +
350: (HDC.HDC_DEBUG_COMMAND ? " HDC.HDC_DEBUG_COMMAND" : "") +
351: (HFS.HFS_DEBUG_TRACE ? " HFS.HFS_DEBUG_TRACE" : "") +
352: (HFS.HFS_DEBUG_FILE_INFO ? " HFS.HFS_DEBUG_FILE_INFO" : "") +
353: (HFS.HFS_COMMAND_TRACE ? " HFS.HFS_COMMAND_TRACE" : "") +
354: (HFS.HFS_BUFFER_TRACE ? " HFS.HFS_BUFFER_TRACE" : "") +
355: (IOInterrupt.IOI_DEBUG_TRACE ? " IOInterrupt.IOI_DEBUG_TRACE" : "") +
356: (Keyboard.KBD_DEBUG_LED ? " Keyboard.KBD_DEBUG_LED" : "") +
357: (MC68060.MMU_DEBUG_COMMAND ? " MC68060.MMU_DEBUG_COMMAND" : "") +
358: (MC68060.MMU_DEBUG_TRANSLATION ? " MC68060.MMU_DEBUG_TRANSLATION" : "") +
359: (MC68060.MMU_NOT_ALLOCATE_CACHE ? " MC68060.MMU_NOT_ALLOCATE_CACHE" : "") +
360: (RP5C15.RTC_DEBUG_TRACE ? " RP5C15.RTC_DEBUG_TRACE" : "") +
361: (SPC.SPC_DEBUG_ON ? " SPC.SPC_DEBUG_ON" : "") +
362: (Z8530.SCC_DEBUG_ON ? " Z8530.SCC_DEBUG_ON" : "")
363: );
364: if (!"".equals (flags)) {
365: pnlExitFullScreen (true);
366: JOptionPane.showMessageDialog (null, "debug flags:" + flags);
367: }
368:
369:
370:
371:
372: tmrStart ();
373:
374: Keyboard.kbdStart ();
375: Mouse.musStart ();
376: pnlStart ();
377: frmStart ();
378: SoundSource.sndStart ();
379:
380: if (DataBreakPoint.DBP_ON) {
381: DataBreakPoint.dbpStart ();
382: }
383: if (RasterBreakPoint.RBP_ON) {
384: RasterBreakPoint.rbpStart ();
385: }
386: if (ScreenModeTest.SMT_ON) {
387: ScreenModeTest.smtStart ();
388: }
389: if (OPMLog.OLG_ON) {
390: OPMLog.olgStart ();
391: }
392: SoundMonitor.smnStart ();
393: RS232CTerminal.trmStart ();
394: PPI.ppiStart ();
395: PrinterPort.prnStart ();
396: if (BranchLog.BLG_ON) {
397: BranchLog.blgStart ();
398: }
399: if (ProgramFlowVisualizer.PFV_ON) {
400: ProgramFlowVisualizer.pfvStart ();
401: }
402: RegisterList.drpStart ();
403: DisassembleList.ddpStart ();
404: MemoryDumpList.dmpStart ();
405: LogicalSpaceMonitor.atwStart ();
406: PhysicalSpaceMonitor.paaStart ();
407: DebugConsole.dgtStart ();
408: if (RootPointerList.RTL_ON) {
409: RootPointerList.rtlStart ();
410: }
411: if (SpritePatternViewer.SPV_ON) {
412: SpritePatternViewer.spvStart ();
413: }
414: if (PaletteViewer.PLV_ON) {
415: PaletteViewer.plvStart ();
416: }
417: if (ATCMonitor.ACM_ON) {
418: ATCMonitor.acmStart ();
419: }
420: ButtonFunction.bfnStart ();
421:
422: if (Settings.sgsSaveiconValue != null) {
423: String[] a = Settings.sgsSaveiconValue.split (",");
424: if (0 < a.length) {
425: saveIcon (a[0], LnF.LNF_ICON_IMAGES);
426: if (1 < a.length) {
427: saveImage (LnF.LNF_ICON_IMAGE_16, a[1]);
428: if (2 < a.length) {
429: saveImage (LnF.LNF_ICON_IMAGE_32, a[2]);
430: if (3 < a.length) {
431: saveImage (LnF.LNF_ICON_IMAGE_48, a[3]);
432: }
433: }
434: }
435: }
436: prgTini ();
437: return;
438: }
439:
440:
441: mpuReset (-1, -1);
442:
443: pnlBoot2 ();
444:
445: }
446:
447:
448:
449:
450:
451: public static void prgTini () {
452: try {
453: if (OPMLog.OLG_ON) {
454: OPMLog.olgTini ();
455: }
456: ButtonFunction.bfnTini ();
457: TextCopy.txcTini ();
458: GIFAnimation.gifTini ();
459: SoundSource.sndTini ();
460: Keyboard.kbdTini ();
461: Mouse.musTini ();
462: CONDevice.conTini ();
463: PPI.ppiTini ();
464: PrinterPort.prnTini ();
465: FDC.fdcTini ();
466: HDC.hdcTini ();
467: if (HostCDROM.HCD_ENABLED) {
468: HostCDROM.hcdTini ();
469: }
470: SPC.spcTini ();
471: HFS.hfsTini ();
472: Z8530.sccTini ();
473: CRTC.crtTini ();
474: SpriteScreen.sprTini ();
475: pnlTini ();
476: bnkTini ();
477: ROM.romTini ();
478: if (MercuryUnit.MU4_ON) {
479: MercuryUnit.mu4Tini ();
480: }
481: xt3Tini ();
482: mdlTini ();
483: SRAM.smrTini ();
484: tmrTini ();
485: busTini ();
486: if (SpritePatternViewer.SPV_ON) {
487: SpritePatternViewer.spvTini ();
488: }
489: if (PaletteViewer.PLV_ON) {
490: PaletteViewer.plvTini ();
491: }
492: RS232CTerminal.trmTini ();
493: LnF.lnfTini ();
494: Settings.sgsTini ();
495: } catch (Exception e) {
496: e.printStackTrace ();
497: }
498: System.exit (0);
499: }
500:
501:
502:
503: public static void prgOpenJavaDialog () {
504: pnlExitFullScreen (true);
505: JOptionPane.showMessageDialog (
506: frmFrame,
507: ComponentFactory.createGridPanel (
508: 3,
509: 6,
510: "paddingLeft=6,paddingRight=6",
511: "italic,right;left;left",
512: "italic,center;colSpan=3,widen",
513: "",
514:
515: null,
516: Multilingual.mlnJapanese ? "実行中" : "Running",
517: Multilingual.mlnJapanese ? "推奨" : "Recommended",
518:
519: ComponentFactory.createHorizontalSeparator (),
520:
521: Multilingual.mlnJapanese ? "Java のベンダー" : "Java Vendor",
522: prgJavaVendor,
523: PRG_JAVA_VENDOR,
524:
525: Multilingual.mlnJapanese ? "Java のバージョン" : "Java Version",
526: prgJavaVersion,
527: PRG_JAVA_VERSION,
528:
529: Multilingual.mlnJapanese ? "OS のアーキテクチャ" : "OS Architecture",
530: prgOsArch,
531: PRG_OS_ARCH,
532:
533: Multilingual.mlnJapanese ? "OS の名前" : "OS Name",
534: prgOsName,
535: PRG_OS_NAME
536: ),
537: Multilingual.mlnJapanese ? "Java 実行環境の情報" : "Java runtime environment information",
538: JOptionPane.PLAIN_MESSAGE);
539: }
540:
541:
542:
543: public static void prgOpenAboutDialog () {
544: pnlExitFullScreen (true);
545: JOptionPane.showMessageDialog (
546: frmFrame,
547: ComponentFactory.createGridPanel (
548: 2, 4, "paddingLeft=6,paddingRight=6", "italic,right;left", "", "",
549: Multilingual.mlnJapanese ? "タイトル" : "Title" ,
550: PRG_TITLE,
551: Multilingual.mlnJapanese ? "バージョン" : "Version",
552: PRG_VERSION,
553: Multilingual.mlnJapanese ? "作者" : "Author" ,
554: PRG_AUTHOR,
555: Multilingual.mlnJapanese ? "ウェブページ" : "Webpage",
556: PRG_WEBPAGE
557: ),
558: Multilingual.mlnJapanese ? "バージョン情報" : "Version information",
559: JOptionPane.PLAIN_MESSAGE);
560: }
561:
562:
563:
564: public static void prgOpenXEiJLicenseDialog () {
565: pnlExitFullScreen (true);
566: JOptionPane.showMessageDialog (
567: frmFrame,
568: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_XEiJ.txt"), 550, 300),
569: Multilingual.mlnJapanese ? "XEiJ 使用許諾条件" : "XEiJ License",
570: JOptionPane.PLAIN_MESSAGE);
571: }
572:
573:
574:
575: public static void prgOpenSHARPLicenseDialog () {
576: pnlExitFullScreen (true);
577: JOptionPane.showMessageDialog (
578: frmFrame,
579: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_FSHARP.txt", "Shift_JIS"), 550, 300),
580: Multilingual.mlnJapanese ? "無償公開された X68000 の基本ソフトウェア製品の許諾条件" : "License of the basic software products for X68000 that were distributed free of charge",
581: JOptionPane.PLAIN_MESSAGE);
582: }
583:
584:
585:
586: public static void prgOpenYmfmLicenseDialog () {
587: pnlExitFullScreen (true);
588: JOptionPane.showMessageDialog (
589: frmFrame,
590: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_ymfm.txt"), 550, 300),
591: "ymfm License",
592: JOptionPane.PLAIN_MESSAGE);
593: }
594:
595:
596:
597: public static void prgOpenJSerialCommLicenseDialog () {
598: pnlExitFullScreen (true);
599: JOptionPane.showMessageDialog (
600: frmFrame,
601: ComponentFactory.createVerticalSplitPane (
602: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-APACHE-2.0"), 550, 300),
603: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-LGPL-3.0"), 550, 300)
604: ),
605: "jSerialComm License",
606: JOptionPane.PLAIN_MESSAGE);
607: }
608:
609:
610:
611: public static void prgPrintClass (Object o) {
612: System.out.println (o.toString ());
613:
614: try {
615: Stack<Class<?>> s = new Stack<Class<?>> ();
616: for (Class<?> c = o.getClass (); c != null; c = c.getSuperclass ()) {
617: s.push (c);
618: }
619: for (int i = 0; !s.empty (); i++) {
620: for (int j = 0; j < i; j++) {
621: System.out.print (" ");
622: }
623: System.out.println (s.pop ().getName ());
624: }
625: } catch (Exception e) {
626: }
627: }
628:
629:
630:
631:
632: public static void prgPrintStackTrace () {
633: Exception e = new Exception ();
634: e.fillInStackTrace ();
635: prgPrintStackTraceOf (e);
636: }
637: public static void prgPrintStackTraceOf (Exception e) {
638:
639: System.out.println ("------------------------------------------------");
640: System.out.println (e.toString ());
641: System.out.println ("\t" + e.getMessage ());
642: for (StackTraceElement ste : e.getStackTrace ()) {
643: System.out.println ("\tat " + ste.toString ());
644: }
645: System.out.println ("------------------------------------------------");
646: }
647:
648:
649:
650:
651: public static boolean prgStopDone = false;
652: public static void prgStopOnce () {
653: if (!prgStopDone) {
654: prgStopDone = true;
655: mpuStop (null);
656: }
657: }
658:
659:
660:
661:
662:
663:
664:
665:
666:
667:
668:
669:
670:
671:
672:
673:
674:
675:
676:
677:
678:
679:
680:
681:
682:
683:
684:
685:
686:
687:
688:
689: public static final long TMR_FREQ = 1000000000000L;
690:
691:
692: public static final long TMR_DELAY = 10L;
693: public static final long TMR_INTERVAL = 10L;
694:
695:
696: public static java.util.Timer tmrTimer;
697:
698:
699:
700: public static void tmrStart () {
701: tmrTimer = new java.util.Timer ();
702: }
703:
704:
705:
706: public static void tmrTini () {
707: if (tmrTimer != null) {
708: tmrTimer.cancel ();
709: }
710: }
711:
712:
713:
714:
715:
716:
717:
718:
719:
720:
721:
722:
723:
724:
725:
726:
727:
728:
729:
730:
731:
732:
733:
734:
735:
736:
737:
738:
739:
740:
741:
742:
743:
744:
745:
746: public static final int PNL_BM_OFFSET_BITS = 10;
747: public static final int PNL_BM_WIDTH = 1 << PNL_BM_OFFSET_BITS;
748: public static final int PNL_BM_HEIGHT = 1024;
749:
750:
751: public static final int PNL_ASPECT_KEYS = 4;
752: public static final int PNL_ASPECT_VALUES = 5;
753: public static final int[] PNL_ASPECT_DEFAULT_VALUE = { 1, 1, 1, 4 };
754: public static final String[] PNL_ASPECT_RESOLUTION_NAME = { "256x256", "384x256", "512x512", "768x512" };
755: public static final String[] PNL_ASPECT_SCREEN_NAME = { "1:1", "4:3", "7:5", "13:9", "3:2" };
756: public static final String[] PNL_ASPECT_PIXEL_NAME = { null, "8:9", "14:15", "26:27", "1:1" };
757: public static final float[] PNL_ASPECT_SCREEN_RATIO = { 1.0F / 1.0F, 4.0F / 3.0F, 7.0F / 5.0F, 13.0F / 9.0F, 3.0F / 2.0F };
758: public static final float[] PNL_ASPECT_PIXEL_RATIO = { 0.0F, 8.0F / 9.0F, 14.0F / 15.0F, 26.0F / 27.0F, 1.0F / 1.0F };
759: public static final float[][] PNL_ASPECT_MATRIX = {
760: PNL_ASPECT_SCREEN_RATIO,
761: PNL_ASPECT_PIXEL_RATIO,
762: PNL_ASPECT_SCREEN_RATIO,
763: PNL_ASPECT_PIXEL_RATIO,
764: };
765: public static int[] pnlAspectMap;
766: public static float[] pnlAspectTable;
767:
768:
769: public static final int PNL_MIN_WIDTH = 64;
770: public static final int PNL_MIN_HEIGHT = 64;
771: public static int pnlScreenWidth;
772: public static int pnlScreenHeight;
773: public static float pnlStretchMode;
774: public static int pnlStretchWidth;
775:
776: public static boolean PNL_ROTATION_ON = true;
777: public static int pnlRotationMode;
778: public static AffineTransform pnlRotationTransformLeft;
779: public static AffineTransform pnlRotationTransformRight;
780: public static double pnlMatrixL00, pnlMatrixL10, pnlMatrixL01, pnlMatrixL11, pnlMatrixL02, pnlMatrixL12;
781: public static double pnlMatrixR00, pnlMatrixR10, pnlMatrixR01, pnlMatrixR11, pnlMatrixR02, pnlMatrixR12;
782: public static double pnlInverseL00, pnlInverseL10, pnlInverseL01, pnlInverseL11, pnlInverseL02, pnlInverseL12;
783: public static double pnlInverseR00, pnlInverseR10, pnlInverseR01, pnlInverseR11, pnlInverseR02, pnlInverseR12;
784: public static int pnlRotatedWidth;
785: public static int pnlRotatedHeight;
786:
787: public static int pnlZoomWidth;
788: public static int pnlZoomHeight;
789: public static int pnlZoomRatioOutX;
790: public static int pnlZoomRatioOutY;
791: public static int pnlZoomRatioInX;
792: public static int pnlZoomRatioInY;
793: public static int pnlWidth;
794: public static int pnlHeight;
795: public static Dimension pnlSize;
796: public static int pnlScreenX1;
797: public static int pnlScreenX2;
798: public static int pnlScreenX3;
799: public static int pnlScreenX4;
800: public static int pnlScreenY1;
801: public static int pnlScreenY2;
802: public static int pnlScreenY3;
803: public static int pnlScreenY4;
804: public static int pnlKeyboardX;
805: public static int pnlKeyboardY;
806: public static int pnlMinimumWidth;
807: public static int pnlMinimumHeight;
808: public static int pnlGlobalX;
809: public static int pnlGlobalY;
810:
811:
812: public static final boolean PNL_FILL_BACKGROUND = true;
813: public static boolean pnlFillBackgroundRequest;
814: public static boolean pnlIsFullScreenSupported;
815: public static boolean pnlPrevKeyboardOn;
816: public static boolean pnlHideKeyboard;
817:
818:
819:
820:
821:
822: public static Object pnlInterpolation;
823:
824:
825: public static final double PNL_MIN_RATE = 1.0;
826: public static final double PNL_MAX_RATE = 1000.0;
827: public static final double PNL_DEFAULT_RATE = 59.94;
828: public static double pnlRefreshRate;
829: public static double pnlFixedRate;
830: public static boolean pnlAdjustVsync;
831:
832:
833:
834:
835:
836:
837:
838:
839:
840:
841:
842:
843:
844:
845:
846:
847:
848:
849:
850:
851:
852:
853:
854:
855:
856:
857:
858:
859:
860:
861:
862:
863:
864:
865:
866:
867:
868:
869:
870:
871:
872:
873:
874:
875:
876:
877:
878:
879:
880: public static final boolean PNL_STEREOSCOPIC_ON = true;
881:
882: public static final boolean PNL_USE_THREAD = true;
883:
884: public static BufferedImage[] pnlScreenImageLeftArray;
885: public static BufferedImage[] pnlScreenImageRightArray;
886:
887: public static BufferedImage[] pnlScreenSubImageLeftArray;
888: public static BufferedImage[] pnlScreenSubImageRightArray;
889:
890: public static int[][] pnlBMLeftArray;
891: public static int[][] pnlBMRightArray;
892: public static volatile int pnlBMWrite;
893: public static volatile int pnlBMRead;
894:
895: public static BufferedImage pnlScreenImageLeft;
896: public static BufferedImage pnlScreenImageRight;
897:
898: public static BufferedImage pnlScreenSubImageLeft;
899: public static BufferedImage pnlScreenSubImageRight;
900:
901: public static int[] pnlBMLeft;
902: public static int[] pnlBMRight;
903:
904: public static int[] pnlBM;
905: public static boolean pnlStereoscopicOn;
906: public static final int PNL_NAKED_EYE_CROSSING = 0;
907: public static final int PNL_NAKED_EYE_PARALLEL = 1;
908: public static final int PNL_SIDE_BY_SIDE = 2;
909: public static final int PNL_TOP_AND_BOTTOM = 3;
910: public static int pnlStereoscopicMethod;
911: public static int pnlStereoscopicFactor;
912: public static int pnlStereoscopicShutter;
913:
914:
915: public static JPanel pnlPanel;
916:
917: public static Thread pnlThread;
918: public static long pnlWakeupTime;
919: public static long pnlWakeupTimeMNP;
920: public static final boolean PNL_USE_CANVAS = PNL_USE_THREAD && true;
921:
922: public static boolean pnlUseCanvasRequest;
923: public static boolean pnlUseCanvas;
924: public static Canvas pnlCanvas;
925: public static Component pnlCanvasOrPanel;
926:
927:
928:
929:
930: public static int pnlFixedScale;
931: public static SpinnerNumberModel pnlFixedModel;
932: public static JSpinner pnlFixedSpinner;
933:
934:
935:
936: public static void pnlInit () {
937: pnlInit2 ();
938:
939:
940:
941:
942: pnlFixedScale = Math.max (10, Math.min (1000, Settings.sgsGetInt ("fixedscale")));
943:
944:
945: pnlAspectMap = new int[PNL_ASPECT_KEYS];
946: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
947: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[key];
948: String screenName = Settings.sgsGetString ("aspectratio" + resolutionName);
949: int value = PNL_ASPECT_DEFAULT_VALUE[key];
950: for (int tempValue = 0; tempValue < PNL_ASPECT_VALUES; tempValue++) {
951: if (PNL_ASPECT_MATRIX[key][tempValue] == 0.0F) {
952: continue;
953: }
954: if (PNL_ASPECT_SCREEN_NAME[tempValue].equals (screenName)) {
955: value = tempValue;
956: break;
957: }
958: }
959: pnlAspectMap[key] = value;
960: }
961: pnlAspectTable = new float[8];
962: pnlUpdateAspectTable ();
963:
964:
965: switch (Settings.sgsGetString ("interpolation").toLowerCase ()) {
966: case "nearest":
967: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
968: break;
969: case "bilinear":
970: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
971: break;
972: case "bicubic":
973: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
974: break;
975: default:
976: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
977: }
978:
979:
980: pnlRefreshRate = 0.0;
981: {
982: String s = Settings.sgsGetString ("refreshrate");
983: if (!s.equals ("")) {
984: try {
985: double rate = Double.parseDouble (s);
986: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
987: pnlRefreshRate = rate;
988: }
989: } catch (NumberFormatException nfe) {
990: }
991: }
992: }
993: pnlFixedRate = pnlRefreshRate;
994: pnlAdjustVsync = Settings.sgsGetOnOff ("adjustvsync");
995:
996: pnlPrevKeyboardOn = true;
997:
998: pnlHideKeyboard = Settings.sgsGetOnOff ("hidekeyboard");
999:
1000:
1001: if (PNL_USE_THREAD) {
1002: pnlScreenImageLeftArray = new BufferedImage[4];
1003: pnlScreenImageRightArray = new BufferedImage[4];
1004: if (PNL_ROTATION_ON) {
1005: pnlScreenSubImageLeftArray = new BufferedImage[4];
1006: pnlScreenSubImageRightArray = new BufferedImage[4];
1007: }
1008: pnlBMLeftArray = new int[4][];
1009: pnlBMRightArray = new int[4][];
1010: for (int n = 0; n < 4; n++) {
1011: pnlScreenImageLeftArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1012: pnlScreenImageRightArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1013: if (PNL_ROTATION_ON) {
1014: pnlScreenSubImageLeftArray[n] = null;
1015: pnlScreenSubImageRightArray[n] = null;
1016: }
1017: pnlBMLeftArray[n] = ((DataBufferInt) pnlScreenImageLeftArray[n].getRaster ().getDataBuffer ()).getData ();
1018: pnlBMRightArray[n] = ((DataBufferInt) pnlScreenImageRightArray[n].getRaster ().getDataBuffer ()).getData ();
1019: }
1020: pnlBMWrite = 0;
1021: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
1022: pnlBMRead = 0;
1023: pnlThread = null;
1024: pnlWakeupTime = 0L;
1025: pnlWakeupTimeMNP = 0L;
1026: if (PNL_USE_CANVAS) {
1027: pnlUseCanvasRequest = Settings.sgsGetOnOff ("usecanvas");
1028: pnlUseCanvas = pnlUseCanvasRequest;
1029: pnlCanvas = null;
1030: }
1031: } else {
1032: pnlScreenImageLeft = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1033: pnlScreenImageRight = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1034: if (PNL_ROTATION_ON) {
1035: pnlScreenSubImageLeft = null;
1036: pnlScreenSubImageRight = null;
1037: }
1038: pnlBMLeft = ((DataBufferInt) pnlScreenImageLeft.getRaster ().getDataBuffer ()).getData ();
1039: pnlBMRight = ((DataBufferInt) pnlScreenImageRight.getRaster ().getDataBuffer ()).getData ();
1040: pnlBM = pnlBMLeft;
1041: }
1042: pnlStereoscopicOn = Settings.sgsGetOnOff ("stereoscopic");
1043: switch (Settings.sgsGetString ("stereoscopicmethod").toLowerCase ()) {
1044: case "nakedeyecrossing":
1045: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
1046: break;
1047: case "nakedeyeparallel":
1048: pnlStereoscopicMethod = PNL_NAKED_EYE_PARALLEL;
1049: break;
1050: case "sidebyside":
1051: pnlStereoscopicMethod = PNL_SIDE_BY_SIDE;
1052: break;
1053: case "topandbottom":
1054: pnlStereoscopicMethod = PNL_TOP_AND_BOTTOM;
1055: break;
1056: default:
1057: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
1058: }
1059: pnlStereoscopicFactor = pnlStereoscopicOn && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1060: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1061: pnlStereoscopicShutter = 0;
1062:
1063:
1064: pnlScreenWidth = 768;
1065: pnlScreenHeight = 512;
1066: pnlStretchMode = 1.0F;
1067: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchMode);
1068:
1069: if (PNL_ROTATION_ON) {
1070: pnlRotationMode = Settings.sgsGetInt ("rotation", 0);
1071: if (pnlRotationMode < 0 || 3 < pnlRotationMode) {
1072: pnlRotationMode = 0;
1073: }
1074: pnlRotationTransformLeft = new AffineTransform ();
1075: pnlRotationTransformRight = new AffineTransform ();
1076: }
1077: pnlRotatedWidth = pnlStretchWidth;
1078: pnlRotatedHeight = pnlScreenHeight;
1079: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1080: pnlRotatedWidth = pnlScreenHeight;
1081: pnlRotatedHeight = pnlStretchWidth;
1082: }
1083:
1084: pnlZoomWidth = pnlRotatedWidth;
1085: pnlZoomHeight = pnlRotatedHeight;
1086: pnlWidth = Math.max (pnlZoomWidth * pnlStereoscopicFactor, Keyboard.kbdWidth);
1087: pnlHeight = pnlZoomHeight + Keyboard.kbdHeight;
1088: pnlSize = new Dimension (pnlWidth, pnlHeight);
1089: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1090: pnlScreenY1 = 0;
1091: pnlArrangementCommon ();
1092: pnlMinimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
1093: pnlMinimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
1094: pnlGlobalX = 0;
1095: pnlGlobalY = 0;
1096:
1097:
1098: if (!PNL_FILL_BACKGROUND) {
1099: pnlFillBackgroundRequest = true;
1100: }
1101:
1102:
1103: pnlFixedModel = new SpinnerNumberModel (pnlFixedScale, 10, 1000, 1);
1104: pnlFixedSpinner = ComponentFactory.createNumberSpinner (pnlFixedModel, 4, new ChangeListener () {
1105: @Override public void stateChanged (ChangeEvent ce) {
1106: if (pnlMode != PNL_FIXEDSCALE) {
1107: pnlSetMode (PNL_FIXEDSCALE);
1108: } else {
1109: pnlUpdateArrangement ();
1110: }
1111: }
1112: });
1113:
1114: }
1115:
1116:
1117:
1118: public static double pnlGetRefreshRate () {
1119: double rate = 0.0;
1120: GraphicsConfiguration gc = frmFrame.getGraphicsConfiguration ();
1121: if (gc != null) {
1122: GraphicsDevice gd = gc.getDevice ();
1123: DisplayMode dm = gd.getDisplayMode ();
1124: int i = dm.getRefreshRate ();
1125: if (i != DisplayMode.REFRESH_RATE_UNKNOWN) {
1126: rate = (i == 23 ? 23.98 :
1127: i == 29 ? 29.97 :
1128: i == 59 ? 59.94 :
1129: i == 119 ? 119.88 :
1130: i == 239 ? 239.76 :
1131: (double) i);
1132: if (rate < PNL_MIN_RATE || PNL_MAX_RATE < rate) {
1133: rate = 0.0;
1134: }
1135: }
1136: }
1137: if (rate == 0.0) {
1138: rate = PNL_DEFAULT_RATE;
1139: System.out.printf (Multilingual.mlnJapanese ?
1140: "ホストのリフレッシュレートを取得できません。デフォルトの %.2f Hz を使います\n" :
1141: "Cannot get host refresh rate. Use default %.2f Hz\n", rate);
1142: } else {
1143: System.out.printf (Multilingual.mlnJapanese ?
1144: "ホストのリフレッシュレートは %.2f Hz です\n" :
1145: "Host refresh rate is %.2f Hz\n", rate);
1146: }
1147: return rate;
1148: }
1149:
1150:
1151: public static void pnlSetStereoscopic (boolean on, int method) {
1152: if (pnlStereoscopicOn != on || pnlStereoscopicMethod != method) {
1153: pnlStereoscopicMethod = method;
1154: pnlStereoscopicFactor = on && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1155: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1156: if (!pnlStereoscopicOn && on) {
1157: if (PNL_USE_THREAD) {
1158: for (int n = 0; n < 4; n++) {
1159: System.arraycopy (pnlBMLeftArray[n], 0, pnlBMRightArray[n], 0, 1024 * 1024);
1160: }
1161: } else {
1162: System.arraycopy (pnlBMLeft, 0, pnlBMRight, 0, 1024 * 1024);
1163: }
1164: } else if (pnlStereoscopicOn && !on) {
1165: if (PNL_USE_THREAD) {
1166: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
1167: } else {
1168: pnlBM = pnlBMLeft;
1169: }
1170: }
1171: pnlStereoscopicOn = on;
1172: pnlUpdateArrangement ();
1173: }
1174: }
1175:
1176:
1177: public static void pnlTini () {
1178: pnlTini2 ();
1179: if (PNL_USE_THREAD) {
1180: if (pnlThread != null) {
1181: pnlThread.interrupt ();
1182: try {
1183: pnlThread.join ();
1184: } catch (InterruptedException ie) {
1185: }
1186: pnlThread = null;
1187: }
1188: }
1189:
1190:
1191: Settings.sgsPutInt ("fixedscale", pnlFixedScale);
1192:
1193:
1194: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
1195: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[key];
1196: int value = pnlAspectMap[key];
1197: String screenName = PNL_ASPECT_SCREEN_NAME[value];
1198: Settings.sgsPutString ("aspectratio" + resolutionName, screenName);
1199: }
1200:
1201:
1202: Settings.sgsPutString ("interpolation",
1203: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR ? "nearest" :
1204: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR ? "bilinear" :
1205: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC ? "bicubic" :
1206: "bilinear");
1207:
1208: if (pnlRefreshRate != PNL_DEFAULT_RATE) {
1209: Settings.sgsPutString ("refreshrate",
1210: pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate));
1211: }
1212: Settings.sgsPutOnOff ("adjustvsync", pnlAdjustVsync);
1213:
1214: Settings.sgsPutOnOff ("hidekeyboard", pnlHideKeyboard);
1215:
1216: if (PNL_USE_CANVAS) {
1217: Settings.sgsPutOnOff ("usecanvas", pnlUseCanvasRequest);
1218: }
1219:
1220:
1221: Settings.sgsPutOnOff ("stereoscopic", pnlStereoscopicOn);
1222: Settings.sgsPutString ("stereoscopicmethod",
1223: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ? "nakedeyecrossing" :
1224: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL ? "nakedeyeparallel" :
1225: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ? "sidebyside" :
1226: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM ? "topandbottom" :
1227: "nakedeyecrossing");
1228:
1229:
1230: if (PNL_ROTATION_ON) {
1231: Settings.sgsPutInt ("rotation", pnlRotationMode);
1232: }
1233:
1234: }
1235:
1236:
1237:
1238: public static void pnlUpdateAspectTable () {
1239: float[] ratio = new float[PNL_ASPECT_KEYS];
1240: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
1241: int value = pnlAspectMap[key];
1242: ratio[key] = PNL_ASPECT_MATRIX[key][value];
1243: }
1244: pnlAspectTable[0] = ratio[0] * 2.0F;
1245: pnlAspectTable[1] = ratio[2];
1246: pnlAspectTable[2] = ratio[3];
1247: pnlAspectTable[3] = ratio[3];
1248: pnlAspectTable[4] = ratio[1] * 4.0F;
1249: pnlAspectTable[5] = ratio[1] * 2.0F;
1250: pnlAspectTable[6] = ratio[3];
1251: pnlAspectTable[7] = ratio[3];
1252: }
1253:
1254:
1255:
1256: public static void pnlMake () {
1257: pnlMake2 ();
1258:
1259:
1260: if (PNL_USE_CANVAS && pnlUseCanvas) {
1261: pnlCanvas = new Canvas ();
1262: pnlPanel = new JPanel (new BorderLayout (0, 0));
1263: pnlPanel.add (pnlCanvas, BorderLayout.CENTER);
1264: pnlCanvasOrPanel = pnlCanvas;
1265: } else {
1266: pnlPanel = new JPanel () {
1267: @Override protected void paintComponent (Graphics g) {
1268: pnlPaintCommon (g);
1269: }
1270: @Override protected void paintBorder (Graphics g) {
1271: }
1272: @Override protected void paintChildren (Graphics g) {
1273: }
1274: };
1275: pnlCanvasOrPanel = pnlPanel;
1276: }
1277: pnlPanel.setBackground (Color.black);
1278: pnlPanel.setOpaque (true);
1279: pnlPanel.setPreferredSize (pnlSize);
1280:
1281: if (Mouse.musCursorAvailable) {
1282: pnlPanel.setCursor (Mouse.musCursorArray[1]);
1283: }
1284:
1285: }
1286:
1287:
1288:
1289: public static void pnlPaintCommon (Graphics g) {
1290: Graphics2D g2 = (Graphics2D) g;
1291: if (PNL_FILL_BACKGROUND || pnlFillBackgroundRequest) {
1292: if (!PNL_FILL_BACKGROUND) {
1293: pnlFillBackgroundRequest = false;
1294: }
1295: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1296: g2.setColor (Color.black);
1297: g2.fillRect (0, 0, pnlWidth, pnlHeight);
1298: }
1299: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, pnlInterpolation);
1300: if (PNL_USE_THREAD) {
1301: int d = pnlBMWrite - pnlBMRead;
1302: if (false) {
1303: System.out.print (d);
1304: }
1305: if (d < 1) {
1306: pnlBMRead += d - 1;
1307: } else if (3 < d) {
1308: pnlBMRead += d - 3;
1309: }
1310: int n = pnlBMRead++ & 3;
1311: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1312: BufferedImage leftImage;
1313: BufferedImage rightImage;
1314: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1315: leftImage = pnlScreenImageRightArray[n];
1316: rightImage = pnlScreenImageLeftArray[n];
1317: } else {
1318:
1319:
1320:
1321: leftImage = pnlScreenImageLeftArray[n];
1322: rightImage = pnlScreenImageRightArray[n];
1323: }
1324: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1325: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1326: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1327: } else {
1328: g2.drawImage (leftImage,
1329: pnlScreenX1, pnlScreenY1,
1330: pnlScreenX2, pnlScreenY2,
1331: 0, 0, pnlScreenWidth, pnlScreenHeight,
1332: null);
1333: g2.drawImage (rightImage,
1334: pnlScreenX3, pnlScreenY3,
1335: pnlScreenX4, pnlScreenY4,
1336: 0, 0, pnlScreenWidth, pnlScreenHeight,
1337: null);
1338: }
1339: } else {
1340: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1341: g2.drawImage (pnlScreenSubImageLeftArray[n], pnlRotationTransformLeft, null);
1342: } else {
1343: g2.drawImage (pnlScreenImageLeftArray[n],
1344: pnlScreenX1, pnlScreenY1,
1345: pnlScreenX2, pnlScreenY2,
1346: 0, 0, pnlScreenWidth, pnlScreenHeight,
1347: null);
1348: }
1349: }
1350: } else {
1351: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1352: BufferedImage leftImage;
1353: BufferedImage rightImage;
1354: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1355: leftImage = pnlScreenImageRight;
1356: rightImage = pnlScreenImageLeft;
1357: } else {
1358:
1359:
1360:
1361: leftImage = pnlScreenImageLeft;
1362: rightImage = pnlScreenImageRight;
1363: }
1364: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1365: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1366: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1367: } else {
1368: g2.drawImage (leftImage,
1369: pnlScreenX1, pnlScreenY1,
1370: pnlScreenX2, pnlScreenY2,
1371: 0, 0, pnlScreenWidth, pnlScreenHeight,
1372: null);
1373: g2.drawImage (rightImage,
1374: pnlScreenX3, pnlScreenY3,
1375: pnlScreenX4, pnlScreenY4,
1376: 0, 0, pnlScreenWidth, pnlScreenHeight,
1377: null);
1378: }
1379: } else {
1380: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1381: g2.drawImage (pnlScreenImageLeft, pnlRotationTransformLeft, null);
1382: } else {
1383: g2.drawImage (pnlScreenImageLeft,
1384: pnlScreenX1, pnlScreenY1,
1385: pnlScreenX2, pnlScreenY2,
1386: 0, 0, pnlScreenWidth, pnlScreenHeight,
1387: null);
1388: }
1389: }
1390: }
1391: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1392: g2.drawImage (Keyboard.kbdImage, pnlKeyboardX, pnlKeyboardY, null);
1393:
1394: if (TextCopy.txcEncloseEachTime && 0 <= TextCopy.txcRow1) {
1395: int x = TextCopy.txcCol1 << 3;
1396: int w = (TextCopy.txcCol2 - TextCopy.txcCol1 + 1) << 3;
1397: int y = TextCopy.txcRow1 << 4;
1398: int h = (TextCopy.txcRow2 - TextCopy.txcRow1 + 1) << 4;
1399: x -= CRTC.crtR10TxXCurr;
1400: y -= CRTC.crtR11TxYCurr;
1401: g2.setColor (Color.red);
1402: if (PNL_ROTATION_ON) {
1403: AffineTransform savedTransform = g2.getTransform ();
1404: g2.setTransform (pnlRotationTransformLeft);
1405: g2.drawRect (x, y, w, h);
1406: g2.setTransform (savedTransform);
1407: } else {
1408: g2.drawRect (pnlScreenX1 + ((x * pnlZoomRatioOutX) >> 16),
1409: pnlScreenY1 + ((y * pnlZoomRatioOutY) >> 16),
1410: ((w * pnlZoomRatioOutX) >> 16) - 1,
1411: ((h * pnlZoomRatioOutY) >> 16) - 1);
1412: }
1413: }
1414: if (Bubble.BBL_ON) {
1415: Bubble.bblDraw (g2);
1416: }
1417: }
1418:
1419:
1420:
1421:
1422: public static void pnlStart () {
1423: pnlStart2 ();
1424:
1425:
1426: ComponentFactory.addListener (
1427: pnlPanel,
1428: new ComponentAdapter () {
1429: @Override public void componentResized (ComponentEvent ce) {
1430: pnlUpdateArrangement ();
1431: }
1432: });
1433:
1434: if (PNL_USE_THREAD) {
1435: if (PNL_USE_CANVAS && pnlUseCanvas) {
1436: pnlCanvas.createBufferStrategy (2);
1437: pnlThread = new Thread () {
1438: @Override public void run () {
1439: do {
1440: BufferStrategy bs = pnlCanvas.getBufferStrategy ();
1441: if (bs != null) {
1442: Graphics g = bs.getDrawGraphics ();
1443: pnlPaintCommon (g);
1444: g.dispose ();
1445: bs.show ();
1446: }
1447: } while (!isInterrupted () && pnlWakeupCommon ());
1448: }
1449: };
1450: } else {
1451: pnlThread = new Thread () {
1452: @Override public void run () {
1453: do {
1454: pnlPanel.repaint ();
1455: if (!pnlWakeupCommon ()) {
1456: break;
1457: }
1458: } while (!isInterrupted () && pnlWakeupCommon ());
1459: }
1460: };
1461: }
1462: pnlWakeupTime = System.currentTimeMillis ();
1463: pnlWakeupTimeMNP = 0L;
1464: pnlThread.start ();
1465: }
1466:
1467: }
1468:
1469: public static boolean pnlWakeupCommon () {
1470: long t = System.currentTimeMillis ();
1471: if (CRTC.crtTotalLength == 0L) {
1472: pnlWakeupTime += 40L;
1473: } else {
1474: pnlWakeupTime += CRTC.crtTotalLength;
1475: pnlWakeupTimeMNP += CRTC.crtTotalLengthMNP;
1476: if (1000000000L <= pnlWakeupTimeMNP) {
1477: pnlWakeupTime++;
1478: pnlWakeupTimeMNP -= 1000000000L;
1479: }
1480: }
1481: pnlWakeupTime = Math.max (pnlWakeupTime, t + 4L);
1482: try {
1483: Thread.sleep (pnlWakeupTime - t);
1484: } catch (InterruptedException ie) {
1485: return false;
1486: }
1487: return true;
1488: }
1489:
1490:
1491:
1492:
1493:
1494: public static void pnlExitFullScreen (boolean dialog) {
1495: if (prgIsMac || !dialog) {
1496: pnlSetFullScreenOn (false);
1497: }
1498: }
1499:
1500:
1501:
1502: public static void pnlToggleFullScreen () {
1503: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1504: pnlSetMode (PNL_FULLSCREEN);
1505: } else {
1506: pnlSetMode (pnlPrevMode);
1507: }
1508: }
1509:
1510:
1511:
1512: public static void pnlToggleMaximized () {
1513: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1514: pnlSetMode (PNL_MAXIMIZED);
1515: } else {
1516: pnlSetMode (pnlPrevMode);
1517: }
1518: }
1519:
1520:
1521:
1522: public static void pnlSetFullScreenOn (boolean on) {
1523: if (on) {
1524: pnlSetMode (PNL_FULLSCREEN);
1525: } else if (pnlMode == PNL_FULLSCREEN) {
1526: pnlSetMode (pnlPrevMode);
1527: }
1528: }
1529:
1530:
1531:
1532:
1533: public static void pnlSetFitInWindowOn (boolean on) {
1534: if (!on) {
1535: pnlSetMode (PNL_FIXEDSCALE);
1536: } else if (pnlMode == PNL_FIXEDSCALE) {
1537: pnlSetMode (PNL_FITINWINDOW);
1538: }
1539: }
1540:
1541:
1542:
1543:
1544:
1545:
1546:
1547:
1548:
1549:
1550: public static void pnlUpdateArrangement () {
1551: pnlWidth = pnlPanel.getWidth ();
1552: pnlHeight = pnlPanel.getHeight ();
1553: frmMarginWidth = frmFrame.getWidth () - pnlWidth;
1554: frmMarginHeight = frmFrame.getHeight () - pnlHeight;
1555: pnlStretchMode = pnlAspectTable[CRTC.crtHRLCurr << 2 | CRTC.crtHResoCurr];
1556: pnlScreenWidth = Math.max (PNL_MIN_WIDTH, (CRTC.crtR03HDispEndCurr - CRTC.crtR02HBackEndCurr) << 3);
1557: pnlScreenHeight = Math.max (PNL_MIN_HEIGHT, (CRTC.crtR07VDispEndCurr - CRTC.crtR06VBackEndCurr) << (CRTC.crtInterlace || CRTC.crtSlit ? 1 : 0));
1558: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchMode);
1559: if (RasterBreakPoint.RBP_ON) {
1560:
1561: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
1562: RasterBreakPoint.rbpUpdateFrame ();
1563: }
1564: }
1565:
1566: pnlFixedScale = pnlFixedModel.getNumber ().intValue ();
1567:
1568: pnlRotatedWidth = pnlStretchWidth;
1569: pnlRotatedHeight = pnlScreenHeight;
1570: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1571: pnlRotatedWidth = pnlScreenHeight;
1572: pnlRotatedHeight = pnlStretchWidth;
1573: }
1574: if (pnlMode == PNL_FIXEDSCALE) {
1575:
1576:
1577:
1578:
1579:
1580: pnlZoomWidth = (pnlRotatedWidth * pnlFixedScale + 50) * 5243 >>> 19;
1581: pnlZoomHeight = (pnlRotatedHeight * pnlFixedScale + 50) * 5243 >>> 19;
1582: int width = Math.max (Math.max (PNL_MIN_WIDTH, pnlZoomWidth * pnlStereoscopicFactor), Keyboard.kbdWidth);
1583: int height = Math.max (PNL_MIN_HEIGHT, pnlZoomHeight) + Keyboard.kbdHeight;
1584: pnlScreenX1 = (width - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1585: pnlScreenY1 = (height - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1586: if (pnlWidth != width || pnlHeight != height) {
1587: pnlWidth = width;
1588: pnlHeight = height;
1589: pnlMinimumWidth = width;
1590: pnlMinimumHeight = height;
1591: pnlSize.setSize (width, height);
1592: pnlPanel.setMinimumSize (pnlSize);
1593: pnlPanel.setMaximumSize (pnlSize);
1594: pnlPanel.setPreferredSize (pnlSize);
1595: }
1596: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1597: frmFrame.setMinimumSize (frmMinimumSize);
1598: frmFrame.setMaximumSize (frmMinimumSize);
1599: frmFrame.setPreferredSize (frmMinimumSize);
1600: frmFrame.setResizable (false);
1601: frmFrame.pack ();
1602: } else {
1603:
1604: if (pnlWidth * pnlRotatedHeight >= (pnlHeight - Keyboard.kbdHeight) * (pnlRotatedWidth * pnlStereoscopicFactor)) {
1605:
1606:
1607:
1608:
1609:
1610:
1611:
1612:
1613:
1614:
1615:
1616:
1617: pnlZoomHeight = pnlHeight - Keyboard.kbdHeight;
1618: pnlZoomWidth = (pnlZoomHeight * pnlRotatedWidth + (pnlRotatedHeight >> 1)) / pnlRotatedHeight;
1619: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1620: pnlScreenX1 = ((pnlWidth >> 1) - (pnlZoomWidth >> 1)) >> 1;
1621: } else {
1622: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1623: }
1624: pnlScreenY1 = 0;
1625: } else {
1626:
1627:
1628:
1629:
1630:
1631:
1632:
1633:
1634:
1635:
1636:
1637:
1638:
1639:
1640:
1641:
1642: pnlZoomWidth = pnlWidth / pnlStereoscopicFactor;
1643: pnlZoomHeight = (pnlZoomWidth * pnlStereoscopicFactor * pnlRotatedHeight + (pnlRotatedWidth * pnlStereoscopicFactor >> 1)) / (pnlRotatedWidth * pnlStereoscopicFactor);
1644: pnlScreenX1 = 0;
1645: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM) {
1646: pnlScreenY1 = (((pnlHeight - Keyboard.kbdHeight) >> 1) - (pnlZoomHeight >> 1)) >> 1;
1647: } else {
1648: pnlScreenY1 = (pnlHeight - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1649: }
1650: }
1651:
1652: int minimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
1653: int minimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
1654: if (pnlMinimumWidth != minimumWidth || pnlMinimumHeight != minimumHeight) {
1655: pnlMinimumWidth = minimumWidth;
1656: pnlMinimumHeight = minimumHeight;
1657: }
1658: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1659: frmFrame.setMinimumSize (frmMinimumSize);
1660: frmFrame.setMaximumSize (null);
1661: frmFrame.setResizable (true);
1662: }
1663:
1664: pnlArrangementCommon ();
1665: Mouse.musUpdateSpeedRatio ();
1666: if (!PNL_FILL_BACKGROUND) {
1667: pnlFillBackgroundRequest = true;
1668: }
1669: }
1670:
1671: public static void pnlArrangementCommon () {
1672: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1673: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1674: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) {
1675: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1676: pnlScreenX3 = pnlScreenX2;
1677: pnlScreenX4 = pnlScreenX3 + pnlZoomWidth;
1678: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1679: pnlScreenY3 = pnlScreenY1;
1680: pnlScreenY4 = pnlScreenY2;
1681: } else if (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1682: pnlScreenX2 = pnlScreenX1 + (pnlZoomWidth >> 1);
1683: pnlScreenX3 = pnlScreenX2;
1684: pnlScreenX4 = pnlScreenX3 + (pnlZoomWidth >> 1);
1685: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1686: pnlScreenY3 = pnlScreenY1;
1687: pnlScreenY4 = pnlScreenY2;
1688: } else {
1689: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1690: pnlScreenX3 = pnlScreenX1;
1691: pnlScreenX4 = pnlScreenX2;
1692: pnlScreenY2 = pnlScreenY1 + (pnlZoomHeight >> 1);
1693: pnlScreenY3 = pnlScreenY2;
1694: pnlScreenY4 = pnlScreenY3 + (pnlZoomHeight >> 1);
1695: }
1696: } else {
1697: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1698: pnlScreenX3 = pnlScreenX1;
1699: pnlScreenX4 = pnlScreenX2;
1700: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1701: pnlScreenY3 = pnlScreenY1;
1702: pnlScreenY4 = pnlScreenY2;
1703: }
1704: pnlKeyboardX = (pnlWidth - Keyboard.kbdWidth) >> 1;
1705: pnlKeyboardY = pnlScreenY4;
1706: pnlZoomRatioOutX = ((pnlZoomWidth * pnlStereoscopicFactor) << 16) / pnlScreenWidth;
1707: pnlZoomRatioOutY = (pnlZoomHeight << 16) / pnlScreenHeight;
1708: pnlZoomRatioInX = (pnlScreenWidth << 16) / (pnlZoomWidth * pnlStereoscopicFactor);
1709: pnlZoomRatioInY = (pnlScreenHeight << 16) / pnlZoomHeight;
1710: if (PNL_ROTATION_ON) {
1711:
1712: if (PNL_USE_THREAD) {
1713: for (int n = 0; n < 4; n++) {
1714: pnlScreenSubImageLeftArray[n] = pnlScreenImageLeftArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1715: pnlScreenSubImageRightArray[n] = pnlScreenImageRightArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1716: }
1717: } else {
1718: pnlScreenSubImageLeft = pnlScreenImageLeft.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1719: pnlScreenSubImageRight = pnlScreenImageRight.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1720: }
1721:
1722:
1723:
1724:
1725: double ax = 0.0;
1726: double ay = 0.0;
1727: double bx = (double) pnlScreenWidth;
1728: double by = (double) pnlScreenHeight;
1729: double l00, l10, l01, l11, l02, l12;
1730: double r00, r10, r01, r11, r02, r12;
1731: if (pnlRotationMode == 0) {
1732: double cx = (double) pnlScreenX1;
1733: double cy = (double) pnlScreenY1;
1734: double dx = (double) pnlScreenX2;
1735: double dy = (double) pnlScreenY2;
1736: l00 = (cx - dx) / (ax - bx);
1737: l10 = 0.0;
1738: l01 = 0.0;
1739: l11 = (cy - dy) / (ay - by);
1740: l02 = (ax * dx - bx * cx) / (ax - bx);
1741: l12 = (ay * dy - by * cy) / (ay - by);
1742: cx = (double) pnlScreenX3;
1743: cy = (double) pnlScreenY3;
1744: dx = (double) pnlScreenX4;
1745: dy = (double) pnlScreenY4;
1746: r00 = (cx - dx) / (ax - bx);
1747: r10 = 0.0;
1748: r01 = 0.0;
1749: r11 = (cy - dy) / (ay - by);
1750: r02 = (ax * dx - bx * cx) / (ax - bx);
1751: r12 = (ay * dy - by * cy) / (ay - by);
1752: } else if (pnlRotationMode == 1) {
1753: double cx = (double) pnlScreenX1;
1754: double cy = (double) pnlScreenY1;
1755: double dx = (double) pnlScreenX2;
1756: double dy = (double) pnlScreenY2;
1757: l00 = 0.0;
1758: l10 = (dy - cy) / (ax - bx);
1759: l01 = (cx - dx) / (ay - by);
1760: l11 = 0.0;
1761: l02 = (ay * dx - by * cx) / (ay - by);
1762: l12 = (ax * cy - bx * dy) / (ax - bx);
1763: cx = (double) pnlScreenX3;
1764: cy = (double) pnlScreenY3;
1765: dx = (double) pnlScreenX4;
1766: dy = (double) pnlScreenY4;
1767: r00 = 0.0;
1768: r10 = (dy - cy) / (ax - bx);
1769: r01 = (cx - dx) / (ay - by);
1770: r11 = 0.0;
1771: r02 = (ay * dx - by * cx) / (ay - by);
1772: r12 = (ax * cy - bx * dy) / (ax - bx);
1773: } else if (pnlRotationMode == 2) {
1774: double cx = (double) pnlScreenX1;
1775: double cy = (double) pnlScreenY1;
1776: double dx = (double) pnlScreenX2;
1777: double dy = (double) pnlScreenY2;
1778: l00 = (dx - cx) / (ax - bx);
1779: l10 = 0.0;
1780: l01 = 0.0;
1781: l11 = (dy - cy) / (ay - by);
1782: l02 = (ax * cx - bx * dx) / (ax - bx);
1783: l12 = (ay * cy - by * dy) / (ay - by);
1784: cx = (double) pnlScreenX3;
1785: cy = (double) pnlScreenY3;
1786: dx = (double) pnlScreenX4;
1787: dy = (double) pnlScreenY4;
1788: r00 = (dx - cx) / (ax - bx);
1789: r10 = 0.0;
1790: r01 = 0.0;
1791: r11 = (dy - cy) / (ay - by);
1792: r02 = (ax * cx - bx * dx) / (ax - bx);
1793: r12 = (ay * cy - by * dy) / (ay - by);
1794: } else {
1795: double cx = (double) pnlScreenX1;
1796: double cy = (double) pnlScreenY1;
1797: double dx = (double) pnlScreenX2;
1798: double dy = (double) pnlScreenY2;
1799: l00 = 0.0;
1800: l10 = (cy - dy) / (ax - bx);
1801: l01 = (dx - cx) / (ay - by);
1802: l11 = 0.0;
1803: l02 = (ay * cx - by * dx) / (ay - by);
1804: l12 = (ax * dy - bx * cy) / (ax - bx);
1805: cx = (double) pnlScreenX3;
1806: cy = (double) pnlScreenY3;
1807: dx = (double) pnlScreenX4;
1808: dy = (double) pnlScreenY4;
1809: r00 = 0.0;
1810: r10 = (cy - dy) / (ax - bx);
1811: r01 = (dx - cx) / (ay - by);
1812: r11 = 0.0;
1813: r02 = (ay * cx - by * dx) / (ay - by);
1814: r12 = (ax * dy - bx * cy) / (ax - bx);
1815: }
1816: pnlRotationTransformLeft.setTransform (l00, l10, l01, l11, l02, l12);
1817: pnlRotationTransformRight.setTransform (r00, r10, r01, r11, r02, r12);
1818: pnlMatrixL00 = l00;
1819: pnlMatrixL10 = l10;
1820: pnlMatrixL01 = l01;
1821: pnlMatrixL11 = l11;
1822: pnlMatrixL02 = l02;
1823: pnlMatrixL12 = l12;
1824: pnlMatrixR00 = r00;
1825: pnlMatrixR10 = r10;
1826: pnlMatrixR01 = r01;
1827: pnlMatrixR11 = r11;
1828: pnlMatrixR02 = r02;
1829: pnlMatrixR12 = r12;
1830:
1831:
1832:
1833:
1834:
1835:
1836: double d = l00 * l11 - l01 * l10;
1837: pnlInverseL00 = l11 / d;
1838: pnlInverseL10 = -l10 / d;
1839: pnlInverseL01 = -l01 / d;
1840: pnlInverseL11 = l00 / d;
1841: pnlInverseL02 = (l01 * l12 - l02 * l11) / d;
1842: pnlInverseL12 = (l02 * l10 - l00 * l12) / d;
1843: d = r00 * r11 - r01 * r10;
1844: pnlInverseR00 = r11 / d;
1845: pnlInverseR10 = -r10 / d;
1846: pnlInverseR01 = -r01 / d;
1847: pnlInverseR11 = r00 / d;
1848: pnlInverseR02 = (r01 * r12 - r02 * r11) / d;
1849: pnlInverseR12 = (r02 * r10 - r00 * r12) / d;
1850: }
1851: }
1852:
1853:
1854:
1855:
1856: public static final int PNL_UNDEFINED = 0;
1857: public static final int PNL_FIXEDSCALE = 1;
1858: public static final int PNL_FITINWINDOW = 2;
1859: public static final int PNL_FULLSCREEN = 3;
1860: public static final int PNL_MAXIMIZED = 4;
1861: public static int pnlModeRequest;
1862: public static int pnlMode;
1863: public static int pnlPrevMode;
1864:
1865:
1866: public static JRadioButtonMenuItem mnbFullScreenMenuItem;
1867: public static JRadioButtonMenuItem mnbMaximizedMenuItem;
1868: public static JRadioButtonMenuItem mnbFitInWindowMenuItem;
1869: public static JRadioButtonMenuItem mnbFixedScaleMenuItem;
1870:
1871:
1872: public static int PNL_BOOT_DELAY = 500;
1873: public static javax.swing.Timer pnlBootTimer;
1874:
1875:
1876:
1877: public static void pnlInit2 () {
1878: pnlModeRequest = PNL_UNDEFINED;
1879: pnlMode = PNL_FITINWINDOW;
1880: pnlPrevMode = PNL_FITINWINDOW;
1881: switch (Settings.sgsGetString ("scaling").toLowerCase ()) {
1882: case "fullscreen":
1883: pnlModeRequest = PNL_FULLSCREEN;
1884: break;
1885: case "maximized":
1886: pnlModeRequest = PNL_MAXIMIZED;
1887: break;
1888: case "fitinwindow":
1889: break;
1890: case "fixedscale":
1891: pnlMode = PNL_FIXEDSCALE;
1892: break;
1893: }
1894: }
1895:
1896:
1897:
1898: public static void pnlTini2 () {
1899: Settings.sgsPutString ("scaling",
1900: pnlMode == PNL_FULLSCREEN ? "fullscreen" :
1901: pnlMode == PNL_MAXIMIZED ? "maximized" :
1902: pnlMode == PNL_FITINWINDOW ? "fitinwindow" :
1903: "fixedscale");
1904: }
1905:
1906:
1907:
1908: public static void pnlMake2 () {
1909:
1910: ActionListener listener = new ActionListener () {
1911: @Override public void actionPerformed (ActionEvent ae) {
1912: String command = ae.getActionCommand ();
1913: switch (command) {
1914: case "Full screen":
1915: pnlSetMode (PNL_FULLSCREEN);
1916: break;
1917: case "Maximized":
1918: pnlSetMode (PNL_MAXIMIZED);
1919: break;
1920: case "Fit in window":
1921: pnlSetMode (PNL_FITINWINDOW);
1922: break;
1923: case "Fixed scale":
1924: pnlSetMode (PNL_FIXEDSCALE);
1925: break;
1926: }
1927: }
1928: };
1929: ButtonGroup group = new ButtonGroup ();
1930: mnbFullScreenMenuItem = ComponentFactory.setEnabled (
1931: Multilingual.mlnText (
1932: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FULLSCREEN, "Full screen", listener),
1933: "ja", "全画面表示"),
1934: pnlIsFullScreenSupported);
1935: mnbMaximizedMenuItem = Multilingual.mlnText (
1936: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_MAXIMIZED, "Maximized", listener),
1937: "ja", "最大化");
1938: mnbFitInWindowMenuItem = Multilingual.mlnText (
1939: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FITINWINDOW, "Fit in window", 'W', MNB_MODIFIERS, listener),
1940: "ja", "ウインドウに合わせる");
1941: mnbFixedScaleMenuItem = Multilingual.mlnText (
1942: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FIXEDSCALE, "Fixed scale", 'X', MNB_MODIFIERS, listener),
1943: "ja", "固定倍率");
1944: }
1945:
1946:
1947:
1948: public static void pnlStart2 () {
1949:
1950: frmFrame.addWindowStateListener (new WindowStateListener () {
1951: @Override public void windowStateChanged (WindowEvent we) {
1952: int state = frmFrame.getExtendedState ();
1953: if (pnlMode != PNL_MAXIMIZED &&
1954: (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
1955: pnlSetMode (PNL_MAXIMIZED);
1956: } else if (pnlMode == PNL_MAXIMIZED &&
1957: (state & Frame.MAXIMIZED_BOTH) != Frame.MAXIMIZED_BOTH) {
1958: pnlSetMode (pnlPrevMode);
1959: }
1960: }
1961: });
1962: }
1963:
1964:
1965:
1966: public static void pnlBoot2 () {
1967: if (pnlModeRequest != PNL_UNDEFINED) {
1968: pnlBootTimer = new javax.swing.Timer (PNL_BOOT_DELAY, new ActionListener () {
1969: public void actionPerformed (ActionEvent ae) {
1970: if (pnlModeRequest == PNL_FULLSCREEN) {
1971: mnbFullScreenMenuItem.doClick ();
1972: } else if (pnlModeRequest == PNL_MAXIMIZED) {
1973: mnbMaximizedMenuItem.doClick ();
1974: }
1975: pnlBootTimer.stop ();
1976: pnlBootTimer = null;
1977: }
1978: });
1979: pnlBootTimer.start ();
1980: }
1981: }
1982:
1983:
1984:
1985: public static void pnlSetMode (int mode) {
1986: do {
1987:
1988: if (pnlMode == mode) {
1989: break;
1990: }
1991:
1992: String text = null;
1993: if (mode == PNL_FULLSCREEN) {
1994: if (!pnlIsFullScreenSupported) {
1995: JOptionPane.showMessageDialog (
1996: frmFrame,
1997: Multilingual.mlnJapanese ?
1998: "全画面表示に対応していません" :
1999: "Full screen is not supported");
2000: break;
2001: }
2002: if (Bubble.BBL_ON) {
2003: text = ButtonFunction.bfnFullScreenText ();
2004: if (text == null) {
2005: JOptionPane.showMessageDialog (
2006: frmFrame,
2007: Multilingual.mlnJapanese ?
2008: "全画面表示を終了するキーまたはボタンがありません" :
2009: "No key or button to exit full screen");
2010: break;
2011: }
2012: }
2013: }
2014:
2015: if (pnlMode == PNL_FULLSCREEN) {
2016: pnlMode = pnlPrevMode;
2017: if (Bubble.BBL_ON) {
2018: Bubble.bblEnd ();
2019: }
2020: if (frmScreenDevice.getFullScreenWindow () == frmFrame) {
2021: frmScreenDevice.setFullScreenWindow (null);
2022: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.FRAME);
2023: }
2024: frmFrame.setJMenuBar (mnbMenuBar);
2025: if (pnlHideKeyboard) {
2026: if (pnlPrevKeyboardOn) {
2027: Keyboard.kbdSetOn (true);
2028: }
2029: }
2030: } else if (pnlMode == PNL_MAXIMIZED) {
2031: pnlMode = pnlPrevMode;
2032: if ((frmFrame.getExtendedState () & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
2033: frmFrame.setExtendedState (Frame.NORMAL);
2034: }
2035: }
2036:
2037: if (mode == PNL_FULLSCREEN) {
2038: pnlPrevMode = pnlMode;
2039: if (pnlHideKeyboard) {
2040: pnlPrevKeyboardOn = Keyboard.kbdImage != null;
2041: if (pnlPrevKeyboardOn) {
2042: Keyboard.kbdSetOn (false);
2043: }
2044: }
2045: frmFrame.setJMenuBar (null);
2046: if (frmScreenDevice.getFullScreenWindow () != frmFrame) {
2047: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.NONE);
2048: frmScreenDevice.setFullScreenWindow (frmFrame);
2049: }
2050: if (Bubble.BBL_ON) {
2051: if (text != null) {
2052: Bubble.bblStart (text + (Multilingual.mlnJapanese ? "で全画面表示を終了" : " to exit full screen"), 5000L);
2053: }
2054: }
2055: } else if (mode == PNL_MAXIMIZED) {
2056: pnlPrevMode = pnlMode;
2057: frmFrame.setExtendedState (Frame.MAXIMIZED_BOTH);
2058: }
2059: pnlMode = mode;
2060:
2061:
2062: pnlUpdateArrangement ();
2063: } while (false);
2064:
2065: if (pnlMode == PNL_FIXEDSCALE) {
2066: if (!mnbFixedScaleMenuItem.isSelected ()) {
2067: mnbFixedScaleMenuItem.setSelected (true);
2068: }
2069: } else if (pnlMode == PNL_FITINWINDOW) {
2070: if (!mnbFitInWindowMenuItem.isSelected ()) {
2071: mnbFitInWindowMenuItem.setSelected (true);
2072: }
2073: } else if (pnlMode == PNL_FULLSCREEN) {
2074: if (!mnbFullScreenMenuItem.isSelected ()) {
2075: mnbFullScreenMenuItem.setSelected (true);
2076: }
2077: } else if (pnlMode == PNL_MAXIMIZED) {
2078: if (!mnbMaximizedMenuItem.isSelected ()) {
2079: mnbMaximizedMenuItem.setSelected (true);
2080: }
2081: }
2082: }
2083:
2084:
2085:
2086:
2087:
2088:
2089: public static Robot rbtRobot;
2090:
2091:
2092: public static void rbtInit () {
2093:
2094:
2095: rbtRobot = null;
2096: try {
2097: rbtRobot = new Robot ();
2098: } catch (Exception e) {
2099: }
2100:
2101: }
2102:
2103:
2104:
2105:
2106:
2107:
2108:
2109: public static final int MNB_MODIFIERS = InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK;
2110:
2111:
2112: public static JMenuBar mnbMenuBar;
2113:
2114:
2115: public static JMenu mnbFileMenu;
2116: public static JMenu mnbDisplayMenu;
2117: public static JMenu mnbSoundMenu;
2118: public static JMenu mnbInputMenu;
2119: public static JMenu mnbConfigMenu;
2120: public static JMenu mnbLanguageMenu;
2121:
2122:
2123:
2124:
2125:
2126: public static JMenuItem mnbQuitMenuItem;
2127: public static JCheckBoxMenuItem mnbStereoscopicMenuItem;
2128: public static JCheckBoxMenuItem mnbPlayMenuItem;
2129: public static JMenuItem mnbPasteMenuItem;
2130: public static JRadioButtonMenuItem mnbStandardKeyboardMenuItem;
2131: public static JRadioButtonMenuItem mnbCompactKeyboardMenuItem;
2132: public static JRadioButtonMenuItem mnbNoKeyboardMenuItem;
2133: public static JLabel mnbVolumeLabel;
2134:
2135:
2136:
2137:
2138:
2139:
2140: public static JMenu mnbMakeFontSizeMenu () {
2141:
2142: ActionListener actionListener = new ActionListener () {
2143: @Override public void actionPerformed (ActionEvent ae) {
2144: String command = ae.getActionCommand ();
2145: switch (command) {
2146: case "Very small":
2147: LnF.lnfFontSizeRequest = 10;
2148: break;
2149: case "Small":
2150: LnF.lnfFontSizeRequest = 12;
2151: break;
2152: case "Medium":
2153: LnF.lnfFontSizeRequest = 14;
2154: break;
2155: case "Large":
2156: LnF.lnfFontSizeRequest = 16;
2157: break;
2158: case "Very large":
2159: LnF.lnfFontSizeRequest = 18;
2160: break;
2161: default:
2162: System.out.println ("unknown action command " + command);
2163: }
2164: }
2165: };
2166:
2167: ButtonGroup fontSizeGroup = new ButtonGroup ();
2168:
2169: return Multilingual.mlnText (
2170: ComponentFactory.createMenu (
2171: "Font size",
2172: Multilingual.mlnText (
2173: ComponentFactory.pointSize (
2174: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 10, "Very small", actionListener),
2175: 10),
2176: "ja", "極小"),
2177: Multilingual.mlnText (
2178: ComponentFactory.pointSize (
2179: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 12, "Small", actionListener),
2180: 12),
2181: "ja", "小"),
2182: Multilingual.mlnText (
2183: ComponentFactory.pointSize (
2184: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 14, "Medium", actionListener),
2185: 14),
2186: "ja", "中"),
2187: Multilingual.mlnText (
2188: ComponentFactory.pointSize (
2189: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 16, "Large", actionListener),
2190: 16),
2191: "ja", "大"),
2192: Multilingual.mlnText (
2193: ComponentFactory.pointSize (
2194: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 18, "Very large", actionListener),
2195: 18),
2196: "ja", "極大")),
2197: "ja", "フォントサイズ");
2198: }
2199:
2200:
2201:
2202: public static final DecimalSpinner[] mnbColorSpinners = new DecimalSpinner[9];
2203: public static final int[] mnbColorRGB = new int[15];
2204: public static JPanel mnbColorPanel;
2205:
2206:
2207:
2208: public static void mnbColorHSBToRGB () {
2209: for (int i = 0; i <= 14; i++) {
2210: int[] t = LnF.LNF_HSB_INTERPOLATION_TABLE[i];
2211: float h = (float) (t[0] * LnF.lnfHSB[0] + t[1] * LnF.lnfHSB[1] + t[2] * LnF.lnfHSB[2]) / (49.0F * 360.0F);
2212: float s = (float) (t[0] * LnF.lnfHSB[3] + t[1] * LnF.lnfHSB[4] + t[2] * LnF.lnfHSB[5]) / (49.0F * 100.0F);
2213: float b = (float) (t[0] * LnF.lnfHSB[6] + t[1] * LnF.lnfHSB[7] + t[2] * LnF.lnfHSB[8]) / (49.0F * 100.0F);
2214: mnbColorRGB[i] = Color.HSBtoRGB (h,
2215: Math.max (0.0F, Math.min (1.0F, s)),
2216: Math.max (0.0F, Math.min (1.0F, b)));
2217: }
2218: }
2219:
2220:
2221:
2222: public static JMenu mnbMakeColorMenu () {
2223: mnbColorHSBToRGB ();
2224:
2225: mnbColorPanel = ComponentFactory.setColor (
2226: ComponentFactory.setFixedSize (
2227: new JPanel () {
2228: @Override protected void paintComponent (Graphics g) {
2229: super.paintComponent (g);
2230: for (int i = 0; i <= 14; i++) {
2231: g.setColor (new Color (mnbColorRGB[i]));
2232: g.fillRect (LnF.lnfFontSize * i, 0, LnF.lnfFontSize, LnF.lnfFontSize * 5);
2233: }
2234: }
2235: },
2236: LnF.lnfFontSize * 15, LnF.lnfFontSize * 5),
2237: Color.white, Color.black);
2238:
2239: ChangeListener changeListener = new ChangeListener () {
2240: @Override public void stateChanged (ChangeEvent ce) {
2241: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
2242: LnF.lnfHSB[spinner.getOption ()] = spinner.getIntValue ();
2243: mnbColorHSBToRGB ();
2244: mnbColorPanel.repaint ();
2245: }
2246: };
2247:
2248: ActionListener actionListener = new ActionListener () {
2249: @Override public void actionPerformed (ActionEvent ae) {
2250: String command = ae.getActionCommand ();
2251: switch (command) {
2252: case "Reset to default values":
2253: for (int i = 0; i < 9; i++) {
2254: LnF.lnfHSB[i] = LnF.LNF_DEFAULT_HSB[i];
2255: mnbColorSpinners[i].setIntValue (LnF.lnfHSB[i]);
2256: }
2257: mnbColorHSBToRGB ();
2258: mnbColorPanel.repaint ();
2259: break;
2260: default:
2261: System.out.println ("unknown action command " + command);
2262: }
2263: }
2264: };
2265:
2266: for (int i = 0; i < 9; i++) {
2267: mnbColorSpinners[i] = ComponentFactory.createDecimalSpinner (
2268: LnF.lnfHSB[i], 0, i < 3 ? 720 : 100, 1, i, changeListener);
2269: }
2270:
2271: return Multilingual.mlnText (
2272: ComponentFactory.createMenu (
2273: "Color",
2274: ComponentFactory.createHorizontalBox (
2275: mnbColorSpinners[0],
2276: mnbColorSpinners[1],
2277: mnbColorSpinners[2],
2278: ComponentFactory.createLabel ("H °"),
2279: Box.createHorizontalGlue ()
2280: ),
2281: ComponentFactory.createHorizontalBox (
2282: mnbColorSpinners[3],
2283: mnbColorSpinners[4],
2284: mnbColorSpinners[5],
2285: ComponentFactory.createLabel ("S%"),
2286: Box.createHorizontalGlue ()
2287: ),
2288: ComponentFactory.createHorizontalBox (
2289: mnbColorSpinners[6],
2290: mnbColorSpinners[7],
2291: mnbColorSpinners[8],
2292: ComponentFactory.createLabel ("B%"),
2293: Box.createHorizontalGlue ()
2294: ),
2295: ComponentFactory.createHorizontalBox (
2296: ComponentFactory.setLineBorder (mnbColorPanel),
2297: Box.createHorizontalGlue ()
2298: ),
2299: Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset to default values", actionListener), "ja", "初期値に戻す")
2300: ),
2301: "ja", "色");
2302: }
2303:
2304:
2305:
2306:
2307:
2308: public static JMenu mnbMakeLanguageMenu () {
2309:
2310: ActionListener actionListener = new ActionListener () {
2311: @Override public void actionPerformed (ActionEvent ae) {
2312: String command = ae.getActionCommand ();
2313: switch (command) {
2314: case "English":
2315: Multilingual.mlnChange ("en");
2316: break;
2317: case "日本語":
2318: Multilingual.mlnChange ("ja");
2319: break;
2320: default:
2321: System.out.println ("unknown action command " + command);
2322: }
2323: }
2324: };
2325:
2326: ButtonGroup languageGroup = new ButtonGroup ();
2327:
2328: return mnbLanguageMenu = Multilingual.mlnText (
2329: ComponentFactory.createMenu (
2330: "Language", 'L',
2331: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnEnglish, "English", actionListener),
2332: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnJapanese, "日本語", actionListener),
2333: ComponentFactory.createHorizontalSeparator (),
2334: mnbMakeFontSizeMenu (),
2335: mnbMakeColorMenu ()
2336: ),
2337: "ja", "言語");
2338: }
2339:
2340:
2341:
2342:
2343:
2344: public static void mnbMakeMenu () {
2345:
2346:
2347: ActionListener listener = new ActionListener () {
2348: @Override public void actionPerformed (ActionEvent ae) {
2349: Object source = ae.getSource ();
2350: String command = ae.getActionCommand ();
2351: switch (command) {
2352:
2353:
2354: case "Quit":
2355: prgTini ();
2356: break;
2357:
2358:
2359: case "50%":
2360: case "75%":
2361: case "100%":
2362: case "150%":
2363: case "200%":
2364: pnlFixedModel.setValue (Integer.valueOf (Integer.parseInt (command.substring (0, command.length () - 1))));
2365: break;
2366: case "Nearest neighbor":
2367: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
2368: break;
2369: case "Bilinear":
2370: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
2371: break;
2372: case "Bicubic":
2373: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
2374: break;
2375:
2376: case "Use canvas":
2377: pnlUseCanvasRequest = ((JCheckBoxMenuItem) source).isSelected ();
2378: break;
2379:
2380: case "Draw all changed pictures":
2381: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2382: CRTC.crtIntermittentInterval = 0;
2383: }
2384: break;
2385: case "Draw a changed picture once every two times":
2386: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2387: CRTC.crtIntermittentInterval = 1;
2388: }
2389: break;
2390: case "Draw a changed picture once every three times":
2391: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2392: CRTC.crtIntermittentInterval = 2;
2393: }
2394: break;
2395: case "Draw a changed picture once every four times":
2396: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2397: CRTC.crtIntermittentInterval = 3;
2398: }
2399: break;
2400: case "Draw a changed picture once every five times":
2401: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2402: CRTC.crtIntermittentInterval = 4;
2403: }
2404: break;
2405:
2406: case "Stereoscopic viewing":
2407: pnlSetStereoscopic (((JCheckBoxMenuItem) source).isSelected (), pnlStereoscopicMethod);
2408: break;
2409: case "Naked-eye crossing":
2410: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_CROSSING);
2411: break;
2412: case "Naked-eye parallel":
2413: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_PARALLEL);
2414: break;
2415: case "Side-by-side":
2416: pnlSetStereoscopic (pnlStereoscopicOn, PNL_SIDE_BY_SIDE);
2417: break;
2418: case "Top-and-bottom":
2419: pnlSetStereoscopic (pnlStereoscopicOn, PNL_TOP_AND_BOTTOM);
2420: break;
2421:
2422: case "Sprite pattern viewer":
2423: if (SpritePatternViewer.SPV_ON) {
2424: SpritePatternViewer.spvOpen ();
2425: }
2426: break;
2427: case "Palette viewer":
2428: if (PaletteViewer.PLV_ON) {
2429: PaletteViewer.plvOpen ();
2430: }
2431: break;
2432: case "Screen mode test":
2433: if (ScreenModeTest.SMT_ON) {
2434: ScreenModeTest.smtOpen ();
2435: }
2436: break;
2437:
2438:
2439: case "Play":
2440: SoundSource.sndSetPlayOn (((JCheckBoxMenuItem) source).isSelected ());
2441: break;
2442: case "OPM output":
2443: OPM.opmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2444: break;
2445: case "OPM log":
2446: OPMLog.olgOpen ();
2447: break;
2448:
2449: case "PCM output":
2450: ADPCM.pcmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2451: break;
2452: case "Sound thinning":
2453: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.THINNING_MONO : SoundSource.SNDRateConverter.THINNING_STEREO;
2454: break;
2455: case "Sound linear interpolation":
2456: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.LINEAR_MONO : SoundSource.SNDRateConverter.LINEAR_STEREO;
2457: break;
2458: case "Sound piecewise-constant area interpolation":
2459: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000;
2460: break;
2461: case "Sound linear area interpolation":
2462: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000;
2463: break;
2464: case "Sound monitor":
2465: SoundMonitor.smnOpen ();
2466: break;
2467: case "PCM piecewise-constant interpolation":
2468: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_CONSTANT);
2469: break;
2470: case "PCM linear interpolation":
2471: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_LINEAR);
2472: break;
2473: case "PCM hermite interpolation":
2474: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_HERMITE);
2475: break;
2476: case "PCM 8MHz/4MHz":
2477: ADPCM.pcmOSCFreqRequest = 0;
2478: break;
2479: case "PCM 8MHz/16MHz":
2480: ADPCM.pcmOSCFreqRequest = 1;
2481: break;
2482: case "Mercury-Unit V4 (MK-MU1)":
2483: MercuryUnit.mu4OnRequest = ((JCheckBoxMenuItem) source).isSelected ();
2484: break;
2485: case "MU4 output":
2486: MercuryUnit.mu4OutputEnable = ((JCheckBoxMenuItem) source).isSelected ();
2487: break;
2488:
2489:
2490: case "Paste":
2491: CONDevice.conDoPaste ();
2492: break;
2493: case "No keyboard":
2494: Keyboard.kbdSetOn (false);
2495: pnlUpdateArrangement ();
2496: break;
2497: case "Standard keyboard":
2498: Keyboard.kbdSetType (Keyboard.KBD_STANDARD_TYPE);
2499: Keyboard.kbdSetOn (true);
2500: pnlUpdateArrangement ();
2501: break;
2502: case "Compact keyboard":
2503: Keyboard.kbdSetType (Keyboard.KBD_COMPACT_TYPE);
2504: Keyboard.kbdSetOn (true);
2505: pnlUpdateArrangement ();
2506: break;
2507: case "Hide keyboard in full screen":
2508: pnlHideKeyboard = ((JCheckBoxMenuItem) source).isSelected ();
2509: if (pnlMode == PNL_FULLSCREEN) {
2510: pnlUpdateArrangement ();
2511: }
2512: break;
2513: case "Key assignments":
2514: Keyboard.kbdOpen ();
2515: break;
2516: case "Joystick port settings":
2517: PPI.ppiOpen ();
2518: break;
2519:
2520:
2521: case "RS-232C and terminal":
2522: RS232CTerminal.trmOpen ();
2523: break;
2524:
2525: case "Console":
2526: DebugConsole.dgtOpen ();
2527: break;
2528: case "Register list":
2529: RegisterList.drpOpen ();
2530: break;
2531: case "Disassemble list":
2532: DisassembleList.ddpOpen (-1, -1, true);
2533: break;
2534: case "Memory dump list":
2535: MemoryDumpList.dmpOpen (-1, -1, true);
2536: break;
2537: case "Logical space monitor":
2538: LogicalSpaceMonitor.atwOpen ();
2539: break;
2540: case "Physical space monitor":
2541: PhysicalSpaceMonitor.paaOpen ();
2542: break;
2543: case "Address translation caches monitor":
2544: if (ATCMonitor.ACM_ON) {
2545: ATCMonitor.acmOpen ();
2546: }
2547: break;
2548: case "Branch log":
2549: if (BranchLog.BLG_ON) {
2550: BranchLog.blgOpen (BranchLog.BLG_SELECT_NONE);
2551: }
2552: break;
2553: case "Program flow visualizer":
2554: if (ProgramFlowVisualizer.PFV_ON) {
2555: ProgramFlowVisualizer.pfvOpen ();
2556: }
2557: break;
2558: case "Raster break point":
2559: if (RasterBreakPoint.RBP_ON) {
2560: RasterBreakPoint.rbpOpen ();
2561: }
2562: break;
2563: case "Data break point":
2564: if (DataBreakPoint.DBP_ON) {
2565: DataBreakPoint.dbpOpen ();
2566: }
2567: break;
2568: case "Root pointer list":
2569: if (RootPointerList.RTL_ON) {
2570: RootPointerList.rtlOpen ();
2571: }
2572: break;
2573:
2574:
2575: case "Adjust clock to host":
2576: RP5C15.rtcSetByHost ();
2577: break;
2578:
2579:
2580:
2581: case "Printer":
2582: PrinterPort.prnOpen ();
2583: break;
2584:
2585: case "Print key and mouse button events":
2586: Mouse.musOutputButtonStatus = ((JCheckBoxMenuItem) source).isSelected ();
2587: break;
2588:
2589: case "Java runtime environment information":
2590: prgOpenJavaDialog ();
2591: break;
2592: case "Version information":
2593: prgOpenAboutDialog ();
2594: break;
2595: case "XEiJ License":
2596: prgOpenXEiJLicenseDialog ();
2597: break;
2598: case "FSHARP License":
2599: prgOpenSHARPLicenseDialog ();
2600: break;
2601: case "ymfm License":
2602: prgOpenYmfmLicenseDialog ();
2603: break;
2604: case "jSerialComm License":
2605: prgOpenJSerialCommLicenseDialog ();
2606: break;
2607:
2608: default:
2609: System.out.println ("unknown action command " + command);
2610:
2611: }
2612: }
2613: };
2614:
2615:
2616: ActionListener mainMemoryListener = new ActionListener () {
2617: @Override public void actionPerformed (ActionEvent ae) {
2618: Object source = ae.getSource ();
2619: String command = ae.getActionCommand ();
2620: switch (command) {
2621: case "1MB":
2622: MainMemory.mmrMemorySizeRequest = 0x00100000;
2623: break;
2624: case "2MB":
2625: MainMemory.mmrMemorySizeRequest = 0x00200000;
2626: break;
2627: case "4MB":
2628: MainMemory.mmrMemorySizeRequest = 0x00400000;
2629: break;
2630: case "6MB":
2631: MainMemory.mmrMemorySizeRequest = 0x00600000;
2632: break;
2633: case "8MB":
2634: MainMemory.mmrMemorySizeRequest = 0x00800000;
2635: break;
2636: case "10MB":
2637: MainMemory.mmrMemorySizeRequest = 0x00a00000;
2638: break;
2639: case "12MB":
2640: MainMemory.mmrMemorySizeRequest = 0x00c00000;
2641: break;
2642: case "Save contents on exit":
2643: MainMemory.mmrMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2644: break;
2645: }
2646: }
2647: };
2648: ButtonGroup mainMemoryGroup = new ButtonGroup ();
2649: JMenu mainMemoryMenu = Multilingual.mlnText (
2650: ComponentFactory.createMenu (
2651: "Main memory",
2652: Multilingual.mlnText (
2653: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00100000, "1MB", mainMemoryListener),
2654: "ja", "1MB"),
2655: Multilingual.mlnText (
2656: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00200000, "2MB", mainMemoryListener),
2657: "ja", "2MB"),
2658: Multilingual.mlnText (
2659: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00400000, "4MB", mainMemoryListener),
2660: "ja", "4MB"),
2661: Multilingual.mlnText (
2662: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00600000, "6MB", mainMemoryListener),
2663: "ja", "6MB"),
2664: Multilingual.mlnText (
2665: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00800000, "8MB", mainMemoryListener),
2666: "ja", "8MB"),
2667: Multilingual.mlnText (
2668: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00a00000, "10MB", mainMemoryListener),
2669: "ja", "10MB"),
2670: Multilingual.mlnText (
2671: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00c00000, "12MB", mainMemoryListener),
2672: "ja", "12MB"),
2673: ComponentFactory.createHorizontalSeparator (),
2674: Multilingual.mlnText (
2675: ComponentFactory.createCheckBoxMenuItem (MainMemory.mmrMemorySaveOn, "Save contents on exit", mainMemoryListener),
2676: "ja", "終了時に内容を保存する"),
2677: SRAM.smrModifyMemorySizeMenuItem
2678: ),
2679: "ja", "メインメモリ");
2680:
2681:
2682: ActionListener highMemoryListener = new ActionListener () {
2683: @Override public void actionPerformed (ActionEvent ae) {
2684: Object source = ae.getSource ();
2685: String command = ae.getActionCommand ();
2686: switch (command) {
2687: case "None":
2688: busHighMemorySize = 0 << 20;
2689: break;
2690: case "16MB":
2691: busHighMemorySize = 16 << 20;
2692: break;
2693: case "Save contents on exit":
2694: busHighMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2695: break;
2696: }
2697: }
2698: };
2699: ButtonGroup highMemoryGroup = new ButtonGroup ();
2700: JMenu highMemoryMenu = Multilingual.mlnText (
2701: ComponentFactory.createMenu (
2702: "High memory on X68030/Xellent30",
2703: Multilingual.mlnText (
2704: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 0 << 20, "None", highMemoryListener),
2705: "ja", "なし"),
2706: Multilingual.mlnText (
2707: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 16 << 20, "16MB", highMemoryListener),
2708: "ja", "16MB"),
2709: ComponentFactory.createHorizontalSeparator (),
2710: Multilingual.mlnText (
2711: ComponentFactory.createCheckBoxMenuItem (busHighMemorySaveOn, "Save contents on exit", highMemoryListener),
2712: "ja", "終了時に内容を保存する")
2713: ),
2714: "ja", "X68030/Xellent30 のハイメモリ");
2715:
2716:
2717: ActionListener localMemoryListener = new ActionListener () {
2718: @Override public void actionPerformed (ActionEvent ae) {
2719: Object source = ae.getSource ();
2720: String command = ae.getActionCommand ();
2721: switch (command) {
2722: case "None":
2723: busLocalMemorySize = 0 << 20;
2724: break;
2725: case "16MB":
2726: busLocalMemorySize = 16 << 20;
2727: break;
2728: case "32MB":
2729: busLocalMemorySize = 32 << 20;
2730: break;
2731: case "64MB":
2732: busLocalMemorySize = 64 << 20;
2733: break;
2734: case "128MB":
2735: busLocalMemorySize = 128 << 20;
2736: break;
2737: case "256MB":
2738: busLocalMemorySize = 256 << 20;
2739: break;
2740: case "384MB":
2741: busLocalMemorySize = 384 << 20;
2742: break;
2743: case "512MB":
2744: busLocalMemorySize = 512 << 20;
2745: break;
2746: case "768MB":
2747: busLocalMemorySize = 768 << 20;
2748: break;
2749: case "Save contents on exit":
2750: busLocalMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2751: break;
2752: case "Available on X68000":
2753: busHimem68000 = ((JCheckBoxMenuItem) source).isSelected ();
2754: break;
2755: case "Available on X68030/Xellent30":
2756: busHighMemory060turboOn = ((JCheckBoxMenuItem) source).isSelected ();
2757: break;
2758: }
2759: }
2760: };
2761: ButtonGroup localMenoryGroup = new ButtonGroup ();
2762: JMenu localMemoryMenu = Multilingual.mlnText (
2763: ComponentFactory.createMenu (
2764: "High memory on 060turbo",
2765: Multilingual.mlnText (
2766: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 0 << 20, "None", localMemoryListener),
2767: "ja", "なし"),
2768: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 16 << 20, "16MB", localMemoryListener),
2769: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 32 << 20, "32MB", localMemoryListener),
2770: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 64 << 20, "64MB", localMemoryListener),
2771: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 128 << 20, "128MB", localMemoryListener),
2772: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 256 << 20, "256MB", localMemoryListener),
2773: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 384 << 20, "384MB", localMemoryListener),
2774: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 512 << 20, "512MB", localMemoryListener),
2775: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 768 << 20, "768MB", localMemoryListener),
2776: ComponentFactory.createHorizontalSeparator (),
2777: Multilingual.mlnText (
2778: ComponentFactory.createCheckBoxMenuItem (busLocalMemorySaveOn, "Save contents on exit", localMemoryListener),
2779: "ja", "終了時に内容を保存する"),
2780: ComponentFactory.createHorizontalSeparator (),
2781: Multilingual.mlnText (
2782: ComponentFactory.createCheckBoxMenuItem (busHimem68000, "Available on X68000", localMemoryListener),
2783: "ja", "X68000 でも有効"),
2784: Multilingual.mlnText (
2785: ComponentFactory.createCheckBoxMenuItem (busHighMemory060turboOn, "Available on X68030/Xellent30", localMemoryListener),
2786: "ja", "X68030/Xellent30 でも有効")
2787: ),
2788: "ja", "060turbo のハイメモリ");
2789:
2790:
2791: ActionListener xellent30Listener = new ActionListener () {
2792: @Override public void actionPerformed (ActionEvent ae) {
2793: Object source = ae.getSource ();
2794: String command = ae.getActionCommand ();
2795: switch (command) {
2796: case "$00EC0000-$00EC3FFF":
2797: xt3DIPSW = 0;
2798: break;
2799: case "$00EC4000-$00EC7FFF":
2800: xt3DIPSW = 1;
2801: break;
2802: case "$00EC8000-$00ECBFFF":
2803: xt3DIPSW = 2;
2804: break;
2805: case "$00ECC000-$00ECFFFF":
2806: xt3DIPSW = 3;
2807: break;
2808: case "256KB":
2809: xt3MemorySizeRequest = 1 << 18;
2810: break;
2811: case "1MB":
2812: xt3MemorySizeRequest = 1 << 20;
2813: break;
2814: case "Save contents on exit":
2815: xt3MemorySave = ((JCheckBoxMenuItem) source).isSelected ();
2816: break;
2817: }
2818: }
2819: };
2820: ButtonGroup xellent30PortGroup = new ButtonGroup ();
2821: ButtonGroup xellent30SizeGroup = new ButtonGroup ();
2822: JMenu xellent30Menu = ComponentFactory.createMenu (
2823: "Xellent30",
2824: ComponentFactory.createRadioButtonMenuItem (
2825: xellent30PortGroup,
2826: xt3DIPSW == 0,
2827: "$00EC0000-$00EC3FFF",
2828: xellent30Listener),
2829: ComponentFactory.createRadioButtonMenuItem (
2830: xellent30PortGroup,
2831: xt3DIPSW == 1,
2832: "$00EC4000-$00EC7FFF",
2833: xellent30Listener),
2834: ComponentFactory.createRadioButtonMenuItem (
2835: xellent30PortGroup,
2836: xt3DIPSW == 2,
2837: "$00EC8000-$00ECBFFF",
2838: xellent30Listener),
2839: ComponentFactory.createRadioButtonMenuItem (
2840: xellent30PortGroup,
2841: xt3DIPSW == 3,
2842: "$00ECC000-$00ECFFFF",
2843: xellent30Listener),
2844: ComponentFactory.createHorizontalSeparator (),
2845: ComponentFactory.createRadioButtonMenuItem (
2846: xellent30SizeGroup,
2847: xt3MemorySizeRequest == 1 << 18,
2848: "256KB",
2849: xellent30Listener),
2850: ComponentFactory.createRadioButtonMenuItem (
2851: xellent30SizeGroup,
2852: xt3MemorySizeRequest == 1 << 20,
2853: "1MB",
2854: xellent30Listener),
2855: ComponentFactory.createHorizontalSeparator (),
2856: Multilingual.mlnText (
2857: ComponentFactory.createCheckBoxMenuItem (xt3MemorySave, "Save contents on exit", xellent30Listener),
2858: "ja", "終了時に内容を保存する")
2859: );
2860:
2861:
2862: JMenu rotationMenu = null;
2863: if (PNL_ROTATION_ON) {
2864: ActionListener rotationListener = new ActionListener () {
2865: @Override public void actionPerformed (ActionEvent ae) {
2866: String command = ae.getActionCommand ();
2867: switch (command) {
2868: case "No rotation (landscape)":
2869: pnlRotationMode = 0;
2870: pnlUpdateArrangement ();
2871: break;
2872: case "90-degree rotation (portrait)":
2873: pnlRotationMode = 1;
2874: pnlUpdateArrangement ();
2875: break;
2876: case "180-degree rotation":
2877: pnlRotationMode = 2;
2878: pnlUpdateArrangement ();
2879: break;
2880: case "270-degree rotation":
2881: pnlRotationMode = 3;
2882: pnlUpdateArrangement ();
2883: break;
2884: default:
2885: System.out.println ("unknown action command " + command);
2886: }
2887: }
2888: };
2889: ButtonGroup rotationGroup = new ButtonGroup ();
2890: rotationMenu = Multilingual.mlnText (
2891: ComponentFactory.createMenu (
2892: "Rotation",
2893: Multilingual.mlnText (
2894: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 0, "No rotation (landscape)", rotationListener),
2895: "ja", "回転なし (横画面)"),
2896: Multilingual.mlnText (
2897: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 1, "90-degree rotation (portrait)", rotationListener),
2898: "ja", "90 度回転 (縦画面)"),
2899: Multilingual.mlnText (
2900: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 2, "180-degree rotation", rotationListener),
2901: "ja", "180 度回転"),
2902: Multilingual.mlnText (
2903: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 3, "270-degree rotation", rotationListener),
2904: "ja", "270 度回転")
2905: ),
2906: "ja", "回転");
2907: }
2908:
2909:
2910: ActionListener aspectListener = new ActionListener () {
2911: @Override public void actionPerformed (ActionEvent ae) {
2912: String command = ae.getActionCommand ();
2913: int i = command.indexOf (',');
2914: int key = Integer.parseInt (command.substring (0, i));
2915: int value = Integer.parseInt (command.substring (i + 1));
2916: pnlAspectMap[key] = value;
2917: pnlUpdateAspectTable ();
2918: pnlUpdateArrangement ();
2919: }
2920: };
2921: JMenu aspectMenu = ComponentFactory.createMenu ("Aspect ratio");
2922: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
2923: if (key != 0) {
2924: aspectMenu.add (ComponentFactory.createHorizontalSeparator ());
2925: }
2926: ButtonGroup group = new ButtonGroup ();
2927: for (int value = 0; value < PNL_ASPECT_VALUES; value++) {
2928: if (PNL_ASPECT_MATRIX[key][value] == 0.0F) {
2929: continue;
2930: }
2931: aspectMenu.add (
2932: ComponentFactory.setText (
2933: ComponentFactory.createRadioButtonMenuItem (
2934: group,
2935: pnlAspectMap[key] == value,
2936: key + "," + value,
2937: aspectListener
2938: ),
2939: (PNL_ASPECT_MATRIX[key] == PNL_ASPECT_SCREEN_RATIO ?
2940: String.format ("%s %s (%.3f)",
2941: PNL_ASPECT_RESOLUTION_NAME[key],
2942: PNL_ASPECT_SCREEN_NAME[value],
2943: PNL_ASPECT_SCREEN_RATIO[value]) :
2944: String.format ("%s %s (%.3f) @ %s (%.3f)",
2945: PNL_ASPECT_RESOLUTION_NAME[key],
2946: PNL_ASPECT_SCREEN_NAME[value],
2947: PNL_ASPECT_SCREEN_RATIO[value],
2948: PNL_ASPECT_PIXEL_NAME[value],
2949: PNL_ASPECT_PIXEL_RATIO[value]))
2950: )
2951: );
2952: }
2953: }
2954: aspectMenu = Multilingual.mlnText (aspectMenu, "ja", "アスペクト比");
2955:
2956:
2957: ActionListener scanlineListener = new ActionListener () {
2958: @Override public void actionPerformed (ActionEvent ae) {
2959:
2960: String command = ae.getActionCommand ();
2961: switch (command) {
2962: case "Off":
2963: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.OFF;
2964: CRTC.crtAllStamp += 2;
2965: break;
2966: case "Weak":
2967: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.WEAK;
2968: CRTC.crtAllStamp += 2;
2969: break;
2970: case "Medium":
2971: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.MEDIUM;
2972: CRTC.crtAllStamp += 2;
2973: break;
2974: case "Strong":
2975: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.STRONG;
2976: CRTC.crtAllStamp += 2;
2977: break;
2978: case "Black":
2979: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.BLACK;
2980: CRTC.crtAllStamp += 2;
2981: break;
2982: }
2983: }
2984: };
2985: ButtonGroup scanlineGroup = new ButtonGroup ();
2986: JMenu scanlineMenu =
2987: Multilingual.mlnText (
2988: ComponentFactory.createMenu (
2989: "Scanline effect",
2990: Multilingual.mlnText (
2991: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.OFF, "Off", scanlineListener),
2992: "ja", "なし"),
2993: Multilingual.mlnText (
2994: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.WEAK, "Weak", scanlineListener),
2995: "ja", "弱"),
2996: Multilingual.mlnText (
2997: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.MEDIUM, "Medium", scanlineListener),
2998: "ja", "中"),
2999: Multilingual.mlnText (
3000: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.STRONG, "Strong", scanlineListener),
3001: "ja", "強"),
3002: Multilingual.mlnText (
3003: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.BLACK, "Black", scanlineListener),
3004: "ja", "黒")
3005: ),
3006: "ja", "走査線エフェクト");
3007:
3008:
3009: JTextField refreshRateTextField = ComponentFactory.createNumberField (pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate), 8);
3010: refreshRateTextField.addActionListener (
3011: new ActionListener () {
3012: @Override public void actionPerformed (ActionEvent ae) {
3013: JTextField textField = (JTextField) ae.getSource ();
3014: pnlRefreshRate = 0.0;
3015: String s = textField.getText ();
3016: if (!s.equals ("")) {
3017: double rate = 0.0;
3018: try {
3019: rate = Double.parseDouble (s);
3020: } catch (NumberFormatException nfe) {
3021: }
3022: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
3023: pnlRefreshRate = rate;
3024: } else {
3025: textField.setText ("");
3026: }
3027: }
3028: pnlFixedRate = pnlRefreshRate;
3029: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3030: pnlFixedRate = pnlGetRefreshRate ();
3031: }
3032: CRTC.crtUpdateLength ();
3033: }
3034: });
3035:
3036: ButtonGroup unitGroup = new ButtonGroup ();
3037: ButtonGroup frameGroup = new ButtonGroup ();
3038: ButtonGroup hintGroup = new ButtonGroup ();
3039: ButtonGroup vgaGroup = new ButtonGroup ();
3040: ButtonGroup intermittentGroup = new ButtonGroup ();
3041: ButtonGroup sterescopicGroup = new ButtonGroup ();
3042: ButtonGroup soundInterpolationGroup = new ButtonGroup ();
3043: ButtonGroup adpcmInterpolationGroup = new ButtonGroup ();
3044: ButtonGroup adpcmOSCFreqGroup = new ButtonGroup ();
3045: ButtonGroup keyboardGroup = new ButtonGroup ();
3046: ButtonGroup spritesGroup = new ButtonGroup ();
3047:
3048:
3049: DecimalSpinner[] freqSpinner = new DecimalSpinner[3];
3050: ChangeListener freqListener = new ChangeListener () {
3051: @Override public void stateChanged (ChangeEvent ce) {
3052: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
3053: int i = spinner.getOption ();
3054: CRTC.crtFreqsRequest[i] = spinner.getIntValue ();
3055: }
3056: };
3057: for (int i = 0; i < 3; i++) {
3058: freqSpinner[i] = ComponentFactory.createDecimalSpinner (
3059: CRTC.crtFreqsRequest[i], CRTC.CRT_MIN_FREQ, CRTC.CRT_MAX_FREQ, 1000000, i, freqListener
3060: );
3061: }
3062: DecimalSpinner sprrasSpinner = ComponentFactory.createDecimalSpinner (
3063: SpriteScreen.sprSpritesPerRaster, 0, 1016, 1, 0,
3064: new ChangeListener () {
3065: @Override public void stateChanged (ChangeEvent ce) {
3066: SpriteScreen.sprSpritesPerRaster = ((DecimalSpinner) ce.getSource ()).getIntValue ();
3067: }
3068: });
3069: ActionListener modificationListener = new ActionListener () {
3070: @Override public void actionPerformed (ActionEvent ae) {
3071: Object source = ae.getSource ();
3072: String command = ae.getActionCommand ();
3073: switch (command) {
3074:
3075: case "Adjust to host refresh rate":
3076: pnlAdjustVsync = ((JCheckBoxMenuItem) source).isSelected ();
3077: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3078: pnlFixedRate = pnlGetRefreshRate ();
3079: }
3080: CRTC.crtUpdateLength ();
3081: break;
3082: case "* Reset to default values":
3083: for (int i = 0; i < 3; i++) {
3084: if (CRTC.crtFreqsRequest[i] != CRTC.CRT_DEFAULT_FREQS[i]) {
3085: CRTC.crtFreqsRequest[i] = CRTC.CRT_DEFAULT_FREQS[i];
3086: freqSpinner[i].setIntValue (CRTC.crtFreqsRequest[i]);
3087: }
3088: }
3089: break;
3090: case "1024-dot non-interlaced":
3091: CRTC.crtEleventhBitRequest = ((JCheckBoxMenuItem) source).isSelected ();
3092: break;
3093: case "Can write 0 to bit 0 of CRTC R00":
3094: CRTC.crtR00Bit0Zero = ((JCheckBoxMenuItem) source).isSelected ();
3095: break;
3096:
3097: case "Extended graphic screen":
3098: CRTC.crtExtendedGraphicRequest = ((JCheckBoxMenuItem) source).isSelected ();
3099: break;
3100:
3101: case "Spherical scrolling of text screen":
3102: CRTC.crtSetSphericalScrolling (((JCheckBoxMenuItem) source).isSelected ());
3103: break;
3104:
3105: case "128 sprites":
3106: SpriteScreen.sprNumberOfSpritesRequest = 128;
3107: break;
3108: case "256 sprites":
3109: SpriteScreen.sprNumberOfSpritesRequest = 256;
3110: break;
3111: case "504 sprites":
3112: SpriteScreen.sprNumberOfSpritesRequest = 512;
3113: break;
3114: case "1016 sprites":
3115: SpriteScreen.sprNumberOfSpritesRequest = 1024;
3116: break;
3117:
3118:
3119:
3120: case "Full pattern memory":
3121: SpriteScreen.sprFPMRequest = ((JCheckBoxMenuItem) source).isSelected ();
3122: break;
3123: case "4096 patterns":
3124: SpriteScreen.sprBankOnRequest = ((JCheckBoxMenuItem) source).isSelected ();
3125: break;
3126: case "Sprites displayed in 768x512":
3127: SpriteScreen.spr768x512Request = ((JCheckBoxMenuItem) source).isSelected ();
3128: break;
3129: case "BG1 displayed in 512x512":
3130: SpriteScreen.spr512bg1Request = ((JCheckBoxMenuItem) source).isSelected ();
3131: break;
3132: case "Row and column scroll":
3133: if (SpriteScreen.SPR_RC_SCROLL_ON) {
3134: SpriteScreen.sprRcScrollRequest = ((JCheckBoxMenuItem) source).isSelected ();
3135: }
3136: break;
3137: case "** Reset to default values":
3138: if (SpriteScreen.sprSpritesPerRaster != 32) {
3139: SpriteScreen.sprSpritesPerRaster = 32;
3140: sprrasSpinner.setIntValue (SpriteScreen.sprSpritesPerRaster);
3141: }
3142: break;
3143: }
3144: }
3145: };
3146: JMenu modificationMenu =
3147: Multilingual.mlnText (
3148: ComponentFactory.createMenu (
3149: "Modification",
3150: Multilingual.mlnText (
3151: ComponentFactory.createMenu (
3152: "Dot clock",
3153: Multilingual.mlnText (
3154: ComponentFactory.createCheckBoxMenuItem (pnlAdjustVsync, "Adjust to host refresh rate", modificationListener),
3155: "ja", "ホストのリフレッシュレートに合わせる"),
3156: ComponentFactory.createHorizontalBox (
3157: Box.createHorizontalStrut (20),
3158: refreshRateTextField,
3159: ComponentFactory.createLabel (" Hz"),
3160: Box.createHorizontalGlue ()
3161: ),
3162: ComponentFactory.createHorizontalSeparator (),
3163: ComponentFactory.createHorizontalBox (
3164: Box.createHorizontalStrut (20),
3165: Multilingual.mlnText (ComponentFactory.createLabel ("Dot clock oscillattor"), "ja", "ドットクロックオシレータ"),
3166: Box.createHorizontalGlue ()
3167: ),
3168: ComponentFactory.createHorizontalBox (
3169: Box.createHorizontalStrut (20),
3170: freqSpinner[0],
3171: ComponentFactory.createLabel (" Hz *"),
3172: Box.createHorizontalGlue ()
3173: ),
3174: ComponentFactory.createHorizontalBox (
3175: Box.createHorizontalStrut (20),
3176: freqSpinner[1],
3177: ComponentFactory.createLabel (" Hz *"),
3178: Box.createHorizontalGlue ()
3179: ),
3180: ComponentFactory.createHorizontalBox (
3181: Box.createHorizontalStrut (20),
3182: freqSpinner[2],
3183: ComponentFactory.createLabel (" Hz *"),
3184: Box.createHorizontalGlue ()
3185: ),
3186: Multilingual.mlnText (
3187: ComponentFactory.createMenuItem ("* Reset to default values", modificationListener),
3188: "ja", "* 初期値に戻す"),
3189: ComponentFactory.createHorizontalSeparator (),
3190: Multilingual.mlnText (
3191: ComponentFactory.createCheckBoxMenuItem (CRTC.crtEleventhBitRequest, "1024-dot non-interlaced", modificationListener),
3192: "ja", "1024 ドットノンインターレース"),
3193: Multilingual.mlnText (
3194: ComponentFactory.createCheckBoxMenuItem (CRTC.crtR00Bit0Zero, "Can write 0 to bit 0 of CRTC R00", modificationListener),
3195: "ja", "CRTC R00 のビット 0 に 0 を書き込める")
3196: ),
3197: "ja", "ドットクロック"),
3198: Multilingual.mlnText (
3199: ComponentFactory.createMenu (
3200: "Graphic screen",
3201: !CRTC.CRT_EXTENDED_GRAPHIC ? null : Multilingual.mlnText (
3202: ComponentFactory.createCheckBoxMenuItem (CRTC.crtExtendedGraphicRequest, "Extended graphic screen", modificationListener),
3203: "ja", "拡張グラフィック画面")
3204: ),
3205: "ja", "グラフィック画面"),
3206: Multilingual.mlnText (
3207: ComponentFactory.createMenu (
3208: "Text screen",
3209: Multilingual.mlnText (
3210: ComponentFactory.createCheckBoxMenuItem (CRTC.crtSphericalScrolling, "Spherical scrolling of text screen", modificationListener),
3211: "ja", "テキスト画面の球面スクロール")
3212: ),
3213: "ja", "テキスト画面"),
3214: Multilingual.mlnText (
3215: ComponentFactory.createMenu (
3216: "Sprite screen",
3217: Multilingual.mlnText (
3218: ComponentFactory.createRadioButtonMenuItem (
3219: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 128, "128 sprites", modificationListener),
3220: "ja", "128 枚のスプライト"),
3221: Multilingual.mlnText (
3222: ComponentFactory.createRadioButtonMenuItem (
3223: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 256, "256 sprites", modificationListener),
3224: "ja", "256 枚のスプライト"),
3225: Multilingual.mlnText (
3226: ComponentFactory.createRadioButtonMenuItem (
3227: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 512, "504 sprites", modificationListener),
3228: "ja", "504 枚のスプライト"),
3229: Multilingual.mlnText (
3230: ComponentFactory.createRadioButtonMenuItem (
3231: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 1024, "1016 sprites", modificationListener),
3232: "ja", "1016 枚のスプライト"),
3233:
3234:
3235:
3236:
3237: ComponentFactory.createHorizontalSeparator (),
3238: Multilingual.mlnText (
3239: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprFPMRequest, "Full pattern memory", modificationListener),
3240: "ja", "フルパターンメモリ"),
3241: Multilingual.mlnText (
3242: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprBankOnRequest, "4096 patterns", modificationListener),
3243: "ja", "4096 個のパターン"),
3244: Multilingual.mlnText (
3245: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr768x512Request, "Sprites displayed in 768x512", modificationListener),
3246: "ja", "768x512 でスプライトを表示"),
3247: Multilingual.mlnText (
3248: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr512bg1Request, "BG1 displayed in 512x512", modificationListener),
3249: "ja", "512x512 で BG1 を表示"),
3250: !SpriteScreen.SPR_RC_SCROLL_ON ? null : Multilingual.mlnText (
3251: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprRcScrollRequest, "Row and column scroll", modificationListener),
3252: "ja", "行スクロールと列スクロール"),
3253: ComponentFactory.createHorizontalSeparator (),
3254: ComponentFactory.createHorizontalBox (
3255: Box.createHorizontalStrut (20),
3256: Multilingual.mlnText (ComponentFactory.createLabel ("Number of sprites per raster"), "ja", "ラスタあたりのスプライトの枚数"),
3257: Box.createHorizontalGlue ()
3258: ),
3259: ComponentFactory.createHorizontalBox (
3260: Box.createHorizontalStrut (20),
3261: sprrasSpinner,
3262: ComponentFactory.createLabel (" **"),
3263: Box.createHorizontalGlue ()
3264: ),
3265: Multilingual.mlnText (
3266: ComponentFactory.createMenuItem ("** Reset to default values", modificationListener),
3267: "ja", "** 初期値に戻す")
3268: ),
3269: "ja", "スプライト画面")
3270: ),
3271: "ja", "改造");
3272:
3273:
3274: mnbMenuBar = ComponentFactory.createMenuBar (
3275:
3276:
3277: mnbFileMenu = Multilingual.mlnText (
3278: ComponentFactory.createMenu (
3279: "File", 'F',
3280:
3281: FDC.fdcMenu,
3282:
3283: HDC.hdcMenu,
3284:
3285: SPC.spcMenu,
3286:
3287: HFS.hfsMenu,
3288: ComponentFactory.createHorizontalSeparator (),
3289: mnbQuitMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Quit", 'Q', MNB_MODIFIERS, listener), "ja", "終了")
3290: ),
3291: "ja", "ファイル"),
3292:
3293:
3294: mpuMenu,
3295:
3296:
3297: mnbDisplayMenu = Multilingual.mlnText (
3298: ComponentFactory.createMenu (
3299: "Display", 'D',
3300: mnbFullScreenMenuItem,
3301: mnbMaximizedMenuItem,
3302: mnbFitInWindowMenuItem,
3303: mnbFixedScaleMenuItem,
3304: ComponentFactory.createHorizontalBox (
3305: Box.createHorizontalStrut (20),
3306: pnlFixedSpinner,
3307: ComponentFactory.createLabel ("%"),
3308: Box.createHorizontalGlue ()
3309: ),
3310: ComponentFactory.createMenuItem ("50%", listener),
3311: ComponentFactory.createMenuItem ("75%", listener),
3312: ComponentFactory.createMenuItem ("100%", listener),
3313: ComponentFactory.createMenuItem ("150%", listener),
3314: ComponentFactory.createMenuItem ("200%", listener),
3315:
3316: rotationMenu,
3317:
3318: aspectMenu,
3319:
3320: Multilingual.mlnText (
3321: ComponentFactory.createMenu (
3322: "Interpolation algorithm",
3323: Multilingual.mlnText (
3324: ComponentFactory.createRadioButtonMenuItem (
3325: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
3326: "Nearest neighbor", listener),
3327: "ja", "最近傍補間"),
3328: Multilingual.mlnText (
3329: ComponentFactory.createRadioButtonMenuItem (
3330: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR,
3331: "Bilinear", listener),
3332: "ja", "線形補間"),
3333: Multilingual.mlnText (
3334: ComponentFactory.createRadioButtonMenuItem (
3335: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC,
3336: "Bicubic", listener),
3337: "ja", "三次補間")
3338: ),
3339: "ja", "補間アルゴリズム"),
3340:
3341: scanlineMenu,
3342: !PNL_USE_CANVAS ? null : Multilingual.mlnText (
3343: ComponentFactory.createCheckBoxMenuItem (pnlUseCanvasRequest, "Use canvas", listener),
3344: "ja", "キャンバスを使う"),
3345:
3346: !CRTC.CRT_ENABLE_INTERMITTENT ? null : Multilingual.mlnText (
3347: ComponentFactory.createMenu (
3348: "Intermittent drawing",
3349: Multilingual.mlnText (
3350: ComponentFactory.createRadioButtonMenuItem (
3351: intermittentGroup, CRTC.crtIntermittentInterval == 0, "Draw all changed pictures", listener),
3352: "ja", "変化した画像をすべて描画する"),
3353: Multilingual.mlnText (
3354: ComponentFactory.createRadioButtonMenuItem (
3355: intermittentGroup, CRTC.crtIntermittentInterval == 1, "Draw a changed picture once every two times", listener),
3356: "ja", "変化した画像を 2 回に 1 回描画する"),
3357: Multilingual.mlnText (
3358: ComponentFactory.createRadioButtonMenuItem (
3359: intermittentGroup, CRTC.crtIntermittentInterval == 2, "Draw a changed picture once every three times", listener),
3360: "ja", "変化した画像を 3 回に 1 回描画する"),
3361: Multilingual.mlnText (
3362: ComponentFactory.createRadioButtonMenuItem (
3363: intermittentGroup, CRTC.crtIntermittentInterval == 3, "Draw a changed picture once every four times", listener),
3364: "ja", "変化した画像を 4 回に 1 回描画する"),
3365: Multilingual.mlnText (
3366: ComponentFactory.createRadioButtonMenuItem (
3367: intermittentGroup, CRTC.crtIntermittentInterval == 4, "Draw a changed picture once every five times", listener),
3368: "ja", "変化した画像を 5 回に 1 回描画する")
3369: ),
3370: "ja", "間欠描画"),
3371:
3372: !PNL_STEREOSCOPIC_ON ? null : ComponentFactory.createHorizontalSeparator (),
3373: mnbStereoscopicMenuItem = !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3374: ComponentFactory.createCheckBoxMenuItem (pnlStereoscopicOn, "Stereoscopic viewing", 'T', listener),
3375: "ja", "立体視"),
3376: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3377: ComponentFactory.createMenu (
3378: "Stereoscopic settings",
3379: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3380: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3381: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING,
3382: "Naked-eye crossing", listener),
3383: "ja", "裸眼交差法"),
3384: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3385: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3386: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL,
3387: "Naked-eye parallel", listener),
3388: "ja", "裸眼平行法"),
3389: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3390: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3391: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE,
3392: "Side-by-side", listener),
3393: "ja", "サイドバイサイド"),
3394: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3395: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3396: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM,
3397: "Top-and-bottom", listener),
3398: "ja", "トップアンドボトム")
3399: ),
3400: "ja", "立体視設定"),
3401:
3402: ComponentFactory.createHorizontalSeparator (),
3403: GIFAnimation.gifStartRecordingMenuItem,
3404: GIFAnimation.gifSettingsMenu,
3405:
3406: ComponentFactory.createHorizontalSeparator (),
3407: modificationMenu,
3408:
3409: SpritePatternViewer.SPV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Sprite pattern viewer", listener), "ja", "スプライトパターンビュア") : null,
3410: PaletteViewer.PLV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Palette viewer", listener), "ja", "パレットビュア") : null,
3411: ScreenModeTest.SMT_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Screen mode test", listener), "ja", "表示モードテスト") : null
3412: ),
3413: "ja", "画面"),
3414:
3415:
3416: mnbSoundMenu = ComponentFactory.setEnabled (
3417: Multilingual.mlnText (
3418: ComponentFactory.createMenu (
3419: "Sound", 'S',
3420: mnbPlayMenuItem = ComponentFactory.setEnabled (
3421: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (SoundSource.sndPlayOn, "Play", 'P', MNB_MODIFIERS, listener), "ja", "音声出力"),
3422: SoundSource.sndLine != null),
3423:
3424:
3425:
3426: ComponentFactory.createHorizontalBox (
3427: Box.createHorizontalGlue (),
3428: Multilingual.mlnText (ComponentFactory.createLabel ("Volume "), "ja", "音量 "),
3429: mnbVolumeLabel = ComponentFactory.createLabel (String.valueOf (SoundSource.sndVolume)),
3430: Box.createHorizontalGlue ()
3431: ),
3432:
3433:
3434: ComponentFactory.setPreferredSize (
3435: ComponentFactory.createHorizontalSlider (
3436: 0,
3437: SoundSource.SND_VOLUME_MAX,
3438: SoundSource.sndVolume,
3439: SoundSource.SND_VOLUME_STEP,
3440: 1,
3441: new ChangeListener () {
3442: @Override public void stateChanged (ChangeEvent ce) {
3443: SoundSource.sndSetVolume (((JSlider) ce.getSource ()).getValue ());
3444: }
3445: }),
3446: LnF.lnfFontSize * 18, LnF.lnfFontSize * 2 + 28),
3447: Multilingual.mlnText (
3448: ComponentFactory.createMenu (
3449: "Sound interpolation",
3450: Multilingual.mlnText (
3451: ComponentFactory.createRadioButtonMenuItem (
3452: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.THINNING_STEREO,
3453: "Sound thinning", listener),
3454: "ja", "音声 間引き"),
3455: Multilingual.mlnText (
3456: ComponentFactory.createRadioButtonMenuItem (
3457: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_STEREO,
3458: "Sound linear interpolation", listener),
3459: "ja", "音声 線形補間"),
3460: ComponentFactory.setEnabled (
3461: Multilingual.mlnText (
3462: ComponentFactory.createRadioButtonMenuItem (
3463: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000,
3464: "Sound piecewise-constant area interpolation", listener),
3465: "ja", "音声 区分定数面積補間"),
3466: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000),
3467: ComponentFactory.setEnabled (
3468: Multilingual.mlnText (
3469: ComponentFactory.createRadioButtonMenuItem (
3470: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000,
3471: "Sound linear area interpolation", listener),
3472: "ja", "音声 線形面積補間"),
3473: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000)
3474: ),
3475: "ja", "音声補間"),
3476: Multilingual.mlnText (ComponentFactory.createMenuItem ("Sound monitor", listener), "ja", "音声モニタ"),
3477:
3478: ComponentFactory.createHorizontalSeparator (),
3479:
3480: ComponentFactory.setEnabled (
3481: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (OPM.opmOutputMask != 0, "OPM output", listener), "ja", "OPM 出力"),
3482: SoundSource.sndLine != null),
3483: !OPMLog.OLG_ON ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("OPM log", listener), "ja", "OPM ログ"),
3484:
3485: ComponentFactory.createHorizontalSeparator (),
3486:
3487: ComponentFactory.setEnabled (
3488: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ADPCM.pcmOutputOn, "PCM output", listener), "ja", "PCM 出力"),
3489: SoundSource.sndLine != null),
3490: Multilingual.mlnText (
3491: ComponentFactory.createMenu (
3492: "PCM interpolation",
3493: Multilingual.mlnText (
3494: ComponentFactory.createRadioButtonMenuItem (
3495: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_CONSTANT,
3496: "PCM piecewise-constant interpolation", listener),
3497: "ja", "PCM 区分定数補間"),
3498: Multilingual.mlnText (
3499: ComponentFactory.createRadioButtonMenuItem (
3500: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_LINEAR,
3501: "PCM linear interpolation", listener),
3502: "ja", "PCM 線形補間"),
3503: Multilingual.mlnText (
3504: ComponentFactory.createRadioButtonMenuItem (
3505: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_HERMITE,
3506: "PCM hermite interpolation", listener),
3507: "ja", "PCM エルミート補間")
3508: ),
3509: "ja", "PCM 補間"),
3510: Multilingual.mlnText (
3511: ComponentFactory.createMenu (
3512: "PCM source oscillator frequency",
3513: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 0, "PCM 8MHz/4MHz", listener),
3514: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 1, "PCM 8MHz/16MHz", listener)
3515: ),
3516: "ja", "PCM 原発振周波数"),
3517:
3518: !MercuryUnit.MU4_ON ? null :
3519: ComponentFactory.createHorizontalSeparator (),
3520: !MercuryUnit.MU4_ON ? null :
3521: ComponentFactory.createCheckBoxMenuItem (
3522: MercuryUnit.mu4OnRequest,
3523: "Mercury-Unit V4 (MK-MU1)",
3524: listener),
3525: !MercuryUnit.MU4_ON ? null :
3526: Multilingual.mlnText (
3527: ComponentFactory.createCheckBoxMenuItem (
3528: MercuryUnit.mu4OutputEnable,
3529: "MU4 output",
3530: listener),
3531: "ja", "MU4 出力")
3532: ),
3533: "ja", "音声"),
3534: SoundSource.sndLine != null),
3535:
3536:
3537: mnbInputMenu = Multilingual.mlnText (
3538: ComponentFactory.createMenu (
3539: "Input", 'I',
3540: mnbPasteMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Paste", 'V', MNB_MODIFIERS, listener), "ja", "貼り付け"),
3541: CONDevice.conSettingsMenu,
3542: TextCopy.txcMakeMenuItem (),
3543: TextCopy.txcMakeSettingMenu (),
3544: ComponentFactory.createHorizontalSeparator (),
3545: mnbNoKeyboardMenuItem = Multilingual.mlnText (
3546: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, !Keyboard.kbdOn, "No keyboard", 'K', MNB_MODIFIERS, listener),
3547: "ja", "キーボードなし"),
3548: mnbStandardKeyboardMenuItem = Multilingual.mlnText (
3549: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_STANDARD_TYPE, "Standard keyboard", listener),
3550: "ja", "標準キーボード"),
3551: mnbCompactKeyboardMenuItem = Multilingual.mlnText (
3552: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_COMPACT_TYPE, "Compact keyboard", listener),
3553: "ja", "コンパクトキーボード"),
3554: Multilingual.mlnText (
3555: ComponentFactory.createCheckBoxMenuItem (pnlHideKeyboard, "Hide keyboard in full screen", listener),
3556: "ja", "全画面表示のときキーボードを隠す"),
3557: Multilingual.mlnText (ComponentFactory.createMenuItem ("Key assignments", listener), "ja", "キー割り当て"),
3558: ButtonFunction.bfnMakeMenuItem (),
3559: SRAM.smrRepeatDelayMenu,
3560: SRAM.smrRepeatIntervalMenu,
3561: !Keyboard.KBD_ZKEY_ON ? null : Keyboard.kbdZKeyMenu,
3562: ComponentFactory.createHorizontalSeparator (),
3563: Mouse.musSeamlessMouseCheckBox,
3564: Mouse.musFollowScrollCheckBox,
3565: Mouse.musCtrlRightCheckBox,
3566: Mouse.musEdgeAccelerationCheckBox,
3567: Mouse.musMouseCursorSpeedBox,
3568: Mouse.musSpeedSlider,
3569: Mouse.musHostsPixelUnitsCheckBox,
3570: ComponentFactory.createHorizontalSeparator (),
3571: Multilingual.mlnText (ComponentFactory.createMenuItem ("Joystick port settings", listener), "ja", "ジョイスティックポート設定")
3572: ),
3573: "ja", "入力"),
3574:
3575:
3576: mnbConfigMenu = Multilingual.mlnText (
3577: ComponentFactory.createMenu (
3578: "Config", 'G',
3579: Multilingual.mlnText (ComponentFactory.createMenuItem ("RS-232C and terminal", listener), "ja", "RS-232C とターミナル"),
3580: Multilingual.mlnText (
3581: ComponentFactory.createMenu (
3582: "Debug",
3583: Multilingual.mlnText (ComponentFactory.createMenuItem ("Console", listener), "ja", "コンソール"),
3584: Multilingual.mlnText (ComponentFactory.createMenuItem ("Register list", listener), "ja", "レジスタリスト"),
3585: Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble list", listener), "ja", "逆アセンブルリスト"),
3586: Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory dump list", listener), "ja", "メモリダンプリスト"),
3587: Multilingual.mlnText (ComponentFactory.createMenuItem ("Logical space monitor", listener), "ja", "論理空間モニタ"),
3588: Multilingual.mlnText (ComponentFactory.createMenuItem ("Physical space monitor", listener), "ja", "物理空間モニタ"),
3589: ATCMonitor.ACM_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Address translation caches monitor", listener), "ja", "アドレス変換キャッシュモニタ") : null,
3590: BranchLog.BLG_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Branch log", listener), "ja", "分岐ログ") : null,
3591: ProgramFlowVisualizer.PFV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Program flow visualizer", listener), "ja", "プログラムフロービジュアライザ") : null,
3592: RasterBreakPoint.RBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Raster break point", listener), "ja", "ラスタブレークポイント") : null,
3593: DataBreakPoint.DBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Data break point", listener), "ja", "データブレークポイント") : null,
3594: RootPointerList.RTL_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Root pointer list", listener), "ja", "ルートポインタリスト") : null,
3595: ComponentFactory.createHorizontalSeparator (),
3596: SRAM.smrRomdbMenu
3597: ),
3598: "ja", "デバッグ"),
3599: SRAM.smrBootMenu,
3600: mainMemoryMenu,
3601: highMemoryMenu,
3602: localMemoryMenu,
3603: xellent30Menu,
3604: ComponentFactory.createHorizontalSeparator (),
3605: ComponentFactory.createMenu (
3606: "RTC",
3607: Multilingual.mlnText (
3608: ComponentFactory.createMenuItem ("Adjust clock to host", listener),
3609: "ja", "時計をホストに合わせる")
3610: ),
3611: SRAM.smrMenu,
3612: Settings.sgsMenu,
3613: ComponentFactory.createHorizontalSeparator (),
3614: Multilingual.mlnText (ComponentFactory.createMenuItem ("Printer", listener), "ja", "プリンタ"),
3615: ROM.romMenu,
3616: Multilingual.mlnText (
3617: ComponentFactory.createMenu (
3618: "Miscellaneous",
3619: SlowdownTest.sdtCheckBoxMenuItem,
3620: SlowdownTest.sdtBox,
3621: Multilingual.mlnText (
3622: ComponentFactory.createCheckBoxMenuItem (Mouse.musOutputButtonStatus, "Print key and mouse button events", listener),
3623: "ja", "キーとマウスのボタンのイベントを表示"),
3624: Z8530.SCC_DEBUG_ON ? Z8530.sccDebugMenu : null
3625: ),
3626: "ja", "その他"),
3627: ComponentFactory.createHorizontalSeparator (),
3628: Multilingual.mlnText (
3629: ComponentFactory.createMenuItem ("Java runtime environment information", listener),
3630: "ja", "Java 実行環境の情報"),
3631: Multilingual.mlnText (
3632: ComponentFactory.createMenuItem ("Version information", listener),
3633: "ja", "バージョン情報"),
3634: Multilingual.mlnText (
3635: ComponentFactory.createMenu (
3636: "License",
3637: Multilingual.mlnText (ComponentFactory.createMenuItem ("XEiJ License", listener), "ja", "XEiJ 使用許諾条件"),
3638: Multilingual.mlnText (ComponentFactory.createMenuItem ("FSHARP License", listener), "ja", "FSHARP 許諾条件"),
3639: Multilingual.mlnText (ComponentFactory.createMenuItem ("ymfm License", listener), "ja", "ymfm License"),
3640: Multilingual.mlnText (ComponentFactory.createMenuItem ("jSerialComm License", listener), "ja", "jSerialComm License")
3641: ),
3642: "ja", "使用許諾条件")
3643: ),
3644: "ja", "設定"),
3645:
3646: mnbMakeLanguageMenu (),
3647:
3648:
3649: Box.createHorizontalGlue (),
3650: ComponentFactory.createVerticalBox (
3651: Box.createVerticalGlue (),
3652: Indicator.indBox,
3653: Box.createVerticalGlue ()
3654: ),
3655: Box.createHorizontalGlue ()
3656:
3657: );
3658: }
3659:
3660:
3661:
3662:
3663:
3664:
3665:
3666: public static boolean frmIsActive;
3667:
3668:
3669: public static JFrame frmFrame;
3670: public static int frmMarginWidth;
3671: public static int frmMarginHeight;
3672: public static Dimension frmMinimumSize;
3673:
3674:
3675: public static GraphicsDevice frmScreenDevice;
3676:
3677:
3678: public static DropTarget frmDropTarget;
3679:
3680:
3681:
3682: public static void frmInit () {
3683: frmIsActive = false;
3684: frmScreenDevice = GraphicsEnvironment.getLocalGraphicsEnvironment ().getDefaultScreenDevice ();
3685: pnlIsFullScreenSupported = frmScreenDevice.isFullScreenSupported ();
3686: }
3687:
3688:
3689:
3690: public static void frmMake () {
3691:
3692:
3693: frmFrame = ComponentFactory.createRestorableFrame (
3694: Settings.SGS_FRM_FRAME_KEY,
3695: PRG_TITLE + " version " + PRG_VERSION,
3696: mnbMenuBar,
3697: pnlPanel);
3698: frmUpdateTitle ();
3699: frmFrame.setIconImage (LnF.LNF_ICON_IMAGE_48);
3700: frmFrame.setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);
3701:
3702:
3703:
3704:
3705: frmMarginWidth = frmFrame.getWidth () - pnlPanel.getWidth ();
3706: frmMarginHeight = frmFrame.getHeight () - pnlPanel.getHeight ();
3707: frmMinimumSize = new Dimension (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
3708: frmFrame.setMinimumSize (frmMinimumSize);
3709:
3710:
3711:
3712: frmDropTarget = new DropTarget (pnlPanel, DnDConstants.ACTION_COPY, new DropTargetAdapter () {
3713: @Override public void dragOver (DropTargetDragEvent dtde) {
3714: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
3715: dtde.acceptDrag (DnDConstants.ACTION_COPY);
3716: return;
3717: }
3718: dtde.rejectDrag ();
3719: }
3720: @Override public void drop (DropTargetDropEvent dtde) {
3721: try {
3722: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
3723: dtde.acceptDrop (DnDConstants.ACTION_COPY);
3724: boolean reset = false;
3725: int fdu0 = -1;
3726: int fdu = 0;
3727: int hdu0 = -1;
3728: int hdu = 0;
3729: int scu0 = -1;
3730: int scu = 0;
3731: int hfu0 = -1;
3732: int hfu = 0;
3733: for (Object o : (java.util.List) dtde.getTransferable ().getTransferData (DataFlavor.javaFileListFlavor)) {
3734: if (o instanceof File) {
3735: File file = (File) o;
3736: if (file.isFile ()) {
3737: if (FDC.fdcFileFilter.accept (file)) {
3738: if (fdu < FDC.FDC_MAX_UNITS &&
3739: FDC.fdcUnitArray[fdu].insert (file.getPath (), false)) {
3740: if (fdu0 < 0) {
3741: fdu0 = fdu;
3742: }
3743: fdu++;
3744: continue;
3745: }
3746: }
3747: if (HDC.hdcFileFilter.accept (file)) {
3748: if (hdu < 16 &&
3749: HDC.hdcUnitArray[hdu].insert (file.getPath (), false)) {
3750: if (hdu0 < 0) {
3751: hdu0 = hdu;
3752: }
3753: hdu++;
3754: continue;
3755: }
3756: }
3757: if (SPC.spcFileFilter.accept (file)) {
3758: if (scu < 16 &&
3759: SPC.spcUnitArray[scu].insert (file.getPath (), false)) {
3760: if (scu0 < 0) {
3761: scu0 = scu;
3762: }
3763: scu++;
3764: continue;
3765: }
3766: }
3767: }
3768: if (HFS.hfsFileFilter.accept (file)) {
3769: if (hfu < HFS.HFS_MAX_UNITS &&
3770: HFS.hfsUnitArray[hfu].insert (file.getPath (), false)) {
3771: if (hfu0 < 0) {
3772: hfu0 = hfu;
3773: }
3774: hfu++;
3775: continue;
3776: }
3777: }
3778: }
3779: reset = false;
3780: }
3781: dtde.dropComplete (true);
3782: if (reset) {
3783: if (fdu0 >= 0) {
3784: mpuReset (0x9070 | fdu0 << 8, -1);
3785: } else if (hdu0 >= 0) {
3786: mpuReset (0x8000 | hdu0 << 8, -1);
3787: } else if (scu0 >= 0) {
3788: mpuReset (0xa000, SPC.SPC_HANDLE_EX + (scu0 << 2));
3789: } else if (hfu0 >= 0) {
3790: HFS.hfsBootUnit = hfu0;
3791: mpuReset (0xa000, HFS.HFS_BOOT_HANDLE);
3792: }
3793: }
3794: return;
3795: }
3796: } catch (UnsupportedFlavorException ufe) {
3797:
3798: } catch (IOException ioe) {
3799:
3800: }
3801: dtde.rejectDrop();
3802: }
3803: });
3804:
3805: }
3806:
3807:
3808:
3809: public static void frmUpdateTitle () {
3810: frmFrame.setTitle ((currentAccelerator == ACCELERATOR_HYBRID ? "X68000 Hybrid" :
3811: currentModel.getName () +
3812: (currentAccelerator == ACCELERATOR_XELLENT30 ? " with Xellent30" :
3813: currentAccelerator == ACCELERATOR_060TURBO ? " with 060turbo" :
3814: currentAccelerator == ACCELERATOR_060TURBOPRO ? " with 060turboPRO" : "")) +
3815: " - " + PRG_TITLE + " version " + PRG_VERSION);
3816: }
3817:
3818:
3819:
3820: public static void frmStart () {
3821:
3822:
3823:
3824:
3825:
3826:
3827:
3828:
3829: ComponentFactory.addListener (
3830: frmFrame,
3831: new WindowAdapter () {
3832: @Override public void windowActivated (WindowEvent we) {
3833: frmIsActive = true;
3834: }
3835: @Override public void windowClosing (WindowEvent we) {
3836: prgTini ();
3837: }
3838: @Override public void windowDeactivated (WindowEvent we) {
3839: frmIsActive = false;
3840:
3841: }
3842: @Override public void windowOpened (WindowEvent we) {
3843: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3844: pnlFixedRate = pnlGetRefreshRate ();
3845: }
3846: }
3847: });
3848:
3849:
3850:
3851:
3852: ComponentFactory.addListener (
3853: frmFrame,
3854: new ComponentAdapter () {
3855: @Override public void componentMoved (ComponentEvent ce) {
3856: Point p = pnlPanel.getLocationOnScreen ();
3857: pnlGlobalX = p.x;
3858: pnlGlobalY = p.y;
3859: }
3860: @Override public void componentResized (ComponentEvent ce) {
3861: Point p = pnlPanel.getLocationOnScreen ();
3862: pnlGlobalX = p.x;
3863: pnlGlobalY = p.y;
3864: }
3865: });
3866:
3867: }
3868:
3869:
3870:
3871:
3872:
3873:
3874: public static BufferedImage clpClipboardImage;
3875: public static String clpClipboardString;
3876: public static Clipboard clpClipboard;
3877: public static Transferable clpImageContents;
3878: public static Transferable clpStringContents;
3879: public static ClipboardOwner clpClipboardOwner;
3880: public static boolean clpIsClipboardOwner;
3881:
3882:
3883:
3884:
3885: public static void clpMake () {
3886: Toolkit toolkit = Toolkit.getDefaultToolkit ();
3887: clpClipboard = null;
3888: try {
3889: clpClipboard = toolkit.getSystemClipboard ();
3890: } catch (Exception e) {
3891: return;
3892: }
3893: clpClipboardImage = null;
3894: clpClipboardString = null;
3895: clpImageContents = new Transferable () {
3896: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
3897: if (flavor == DataFlavor.imageFlavor) {
3898: return clpClipboardImage;
3899: } else {
3900: throw new UnsupportedFlavorException (flavor);
3901: }
3902: }
3903: public DataFlavor[] getTransferDataFlavors () {
3904: return new DataFlavor[] { DataFlavor.imageFlavor };
3905: }
3906: public boolean isDataFlavorSupported (DataFlavor flavor) {
3907: return flavor == DataFlavor.imageFlavor;
3908: }
3909: };
3910: clpStringContents = new Transferable () {
3911: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
3912: if (flavor == DataFlavor.stringFlavor) {
3913: return clpClipboardString;
3914: } else {
3915: throw new UnsupportedFlavorException (flavor);
3916: }
3917: }
3918: public DataFlavor[] getTransferDataFlavors () {
3919: return new DataFlavor[] { DataFlavor.stringFlavor };
3920: }
3921: public boolean isDataFlavorSupported (DataFlavor flavor) {
3922: return flavor == DataFlavor.stringFlavor;
3923: }
3924: };
3925: clpIsClipboardOwner = false;
3926:
3927:
3928: clpClipboardOwner = new ClipboardOwner () {
3929: @Override public void lostOwnership (Clipboard clipboard, Transferable contents) {
3930: clpIsClipboardOwner = false;
3931: }
3932: };
3933:
3934:
3935: clpClipboard.addFlavorListener (new FlavorListener () {
3936: @Override public void flavorsChanged (FlavorEvent fe) {
3937: boolean available = false;
3938: try {
3939: available = clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor);
3940: } catch (IllegalStateException ise) {
3941: }
3942: if (mnbPasteMenuItem != null) {
3943: mnbPasteMenuItem.setEnabled (available);
3944: }
3945: }
3946: });
3947: if (!clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor)) {
3948: if (mnbPasteMenuItem != null) {
3949: mnbPasteMenuItem.setEnabled (false);
3950: }
3951: }
3952: }
3953:
3954:
3955:
3956: public static void clpCopy (String s) {
3957: if (clpClipboard != null && s != null) {
3958: clpClipboardString = s;
3959: try {
3960: clpClipboard.setContents (clpStringContents, clpClipboardOwner);
3961: clpIsClipboardOwner = true;
3962: } catch (Exception e) {
3963: return;
3964: }
3965: }
3966: }
3967:
3968:
3969:
3970:
3971:
3972:
3973:
3974:
3975:
3976:
3977:
3978:
3979:
3980:
3981:
3982:
3983:
3984:
3985:
3986:
3987:
3988:
3989:
3990: public static int xt3DIPSWRequest;
3991: public static int xt3DIPSW;
3992: public static int xt3PortAddress;
3993:
3994:
3995: public static int xt3MemorySizeRequest;
3996: public static int xt3MemorySize;
3997: public static boolean xt3MemoryEnabled;
3998: public static int xt3MemoryPosition;
3999: public static int xt3MemoryStart;
4000: public static final byte[] xt3MemoryArray = new byte[1 << 20];
4001: public static boolean xt3MemorySave;
4002:
4003:
4004: public static int xt3SavedPC;
4005: public static final int[] xt3SavedRn = new int[16];
4006:
4007:
4008: public static void xt3Init () {
4009:
4010:
4011: xt3DIPSWRequest = Math.max (0, Math.min (3, Settings.sgsGetInt ("xt3dipsw")));
4012: xt3DIPSW = xt3DIPSWRequest;
4013:
4014:
4015: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4016:
4017:
4018: int memoryKB = Settings.sgsGetInt ("xt3memorykb");
4019: if (!(memoryKB == 1 << 8 || memoryKB == 1 << 10)) {
4020: memoryKB = 1 << 8;
4021: }
4022: xt3MemorySizeRequest = memoryKB << 10;
4023: xt3MemorySize = xt3MemorySizeRequest;
4024:
4025:
4026: xt3MemoryEnabled = false;
4027:
4028:
4029: xt3MemoryPosition = 11 << 20;
4030:
4031:
4032: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4033:
4034:
4035:
4036: byte[] memoryArray = Settings.sgsGetData ("xt3memorydata");
4037: Arrays.fill (xt3MemoryArray,
4038: (byte) 0);
4039: if (memoryArray.length != 0) {
4040: System.arraycopy (memoryArray, 0,
4041: xt3MemoryArray, 0,
4042: Math.min (memoryArray.length, xt3MemoryArray.length));
4043: if (memoryArray.length < xt3MemoryArray.length) {
4044: Arrays.fill (xt3MemoryArray,
4045: memoryArray.length,
4046: xt3MemoryArray.length,
4047: (byte) 0);
4048: }
4049: }
4050:
4051:
4052: xt3MemorySave = Settings.sgsGetOnOff ("xt3memorysave");
4053:
4054:
4055: xt3SavedPC = 0;
4056:
4057: Arrays.fill (xt3SavedRn, 0);
4058:
4059: xt3Reset ();
4060: }
4061:
4062:
4063: public static void xt3Tini () {
4064:
4065:
4066: Settings.sgsPutInt ("xt3dipsw", xt3DIPSW);
4067:
4068:
4069: Settings.sgsPutInt ("xt3memorykb", xt3MemorySizeRequest >> 10);
4070:
4071:
4072: boolean zero = true;
4073: if (xt3MemorySave) {
4074: for (int i = 0; i < 1 << 20; i++) {
4075: if (xt3MemoryArray[i] != 0) {
4076: zero = false;
4077: break;
4078: }
4079: }
4080: }
4081: Settings.sgsCurrentMap.put ("xt3memorydata",
4082: zero ? "" :
4083: ByteArray.byaEncodeBase64 (ByteArray.byaEncodeGzip (xt3MemoryArray, 0, 1 << 20)));
4084:
4085:
4086: Settings.sgsPutOnOff ("xt3memorysave", xt3MemorySave);
4087:
4088: }
4089:
4090:
4091: public static void xt3Reset () {
4092:
4093:
4094: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4095:
4096:
4097: xt3MemorySize = xt3MemorySizeRequest;
4098:
4099:
4100: xt3MemoryEnabled = false;
4101:
4102:
4103: xt3MemoryPosition = 11 << 20;
4104:
4105:
4106: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4107:
4108:
4109: xt3SavedPC = 0;
4110: Arrays.fill (xt3SavedRn, 0);
4111:
4112: }
4113:
4114:
4115: public static int xt3PortRead () {
4116: return (currentIsSecond ? 4 : 0) | (xt3MemoryEnabled ? 2 : 0) | (xt3MemoryPosition == 11 << 20 ? 0 : 1);
4117: }
4118:
4119:
4120: public static void xt3PortWrite (int d) {
4121: boolean nextIsSecond = (d & 4) != 0;
4122: boolean memoryEnabled = (d & 2) != 0;
4123: int memoryPosition = (d & 1) == 0 ? 11 << 20 : 15 << 20;
4124:
4125: if (xt3MemoryEnabled != memoryEnabled ||
4126: xt3MemoryPosition != memoryPosition) {
4127: if (xt3MemoryEnabled) {
4128: if (xt3MemoryPosition == 11 << 20) {
4129: if (MainMemory.mmrMemorySizeCurrent < 12 << 20) {
4130: busSuper (MemoryMappedDevice.MMD_NUL, (12 << 20) - xt3MemorySize, 12 << 20);
4131: } else {
4132: busUser (MemoryMappedDevice.MMD_MMR, (12 << 20) - xt3MemorySize, 12 << 20);
4133: }
4134: } else {
4135: busSuper (MemoryMappedDevice.MMD_ROM, (16 << 20) - xt3MemorySize, 16 << 20);
4136: }
4137: }
4138: xt3MemoryEnabled = memoryEnabled;
4139: xt3MemoryPosition = memoryPosition;
4140: if (xt3MemoryEnabled) {
4141: if (xt3MemoryPosition == 11 << 20) {
4142: busUser (MemoryMappedDevice.MMD_XTM, (12 << 20) - xt3MemorySize, 12 << 20);
4143: } else {
4144: busUser (MemoryMappedDevice.MMD_XTM, (16 << 20) - xt3MemorySize, 16 << 20);
4145: }
4146: }
4147: }
4148:
4149: if (currentIsSecond != nextIsSecond) {
4150:
4151: if (nextIsSecond) {
4152:
4153:
4154: xt3SavedPC = regPC;
4155: System.arraycopy (regRn, 0, xt3SavedRn, 0, 16);
4156:
4157:
4158: if (mpuTask != null) {
4159: mpuClockLimit = 0L;
4160: System.out.println (Multilingual.mlnJapanese ?
4161: Model.MPU_NAMES[currentFirstMPU] + " を停止します" :
4162: Model.MPU_NAMES[currentFirstMPU] + " stops");
4163: mpuTask.cancel ();
4164: mpuTask = null;
4165: }
4166:
4167:
4168: tmrTimer.schedule (new TimerTask () {
4169: @Override public void run () {
4170:
4171:
4172: currentIsSecond = true;
4173: currentMPU = currentSecondMPU;
4174: mpuSetCurrentClock (specifiedSecondClock);
4175:
4176: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
4177: MC68EC030.m30DivZeroVFlag = false;
4178: }
4179:
4180: RegisterList.drpSetMPU ();
4181: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4182: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4183: MC68060.mmuReset ();
4184:
4185: mpuIgnoreAddressError = true;
4186: fpuBox = fpuMotherboardCoprocessor;
4187: fpuBox.epbReset ();
4188: fpuFPn = fpuBox.epbFPn;
4189: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
4190: mpuSetWait ();
4191:
4192: regSRT1 = regSRT0 = 0;
4193: regSRS = REG_SR_S;
4194: regSRM = 0;
4195: regSRI = REG_SR_I;
4196: regCCR = 0;
4197: Arrays.fill (regRn, 0);
4198:
4199: regRn[15] = MainMemory.mmrRls (0x00000000);
4200: regPC = MainMemory.mmrRls (0x00000004);
4201:
4202: mpuIMR = 0;
4203: mpuIRR = 0;
4204: if (MC68901.MFP_DELAYED_INTERRUPT) {
4205: mpuDIRR = 0;
4206: }
4207: mpuISR = 0;
4208:
4209: mpuStart ();
4210: }
4211: }, TMR_DELAY);
4212:
4213: } else {
4214:
4215:
4216: if (mpuTask != null) {
4217: mpuClockLimit = 0L;
4218: System.out.println (Multilingual.mlnJapanese ? "MC68EC030 を停止します" : "MC68EC030 stops");
4219: mpuTask.cancel ();
4220: mpuTask = null;
4221: }
4222:
4223:
4224: tmrTimer.schedule (new TimerTask () {
4225: @Override public void run () {
4226:
4227:
4228: currentIsSecond = false;
4229: currentMPU = currentFirstMPU;
4230: mpuSetCurrentClock (specifiedFirstClock);
4231:
4232: RegisterList.drpSetMPU ();
4233: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4234: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4235: MC68060.mmuReset ();
4236:
4237: mpuIgnoreAddressError = false;
4238: mpuCacheOn = false;
4239: mpuSetWait ();
4240:
4241: regSRT1 = regSRT0 = 0;
4242: regSRS = REG_SR_S;
4243: regSRM = 0;
4244: regSRI = REG_SR_I;
4245: regCCR = 0;
4246:
4247: regPC = xt3SavedPC;
4248: System.arraycopy (xt3SavedRn, 0, regRn, 0, 16);
4249:
4250: mpuIMR = 0;
4251: mpuIRR = 0;
4252: if (MC68901.MFP_DELAYED_INTERRUPT) {
4253: mpuDIRR = 0;
4254: }
4255: mpuISR = 0;
4256:
4257: mpuStart ();
4258: }
4259: }, TMR_DELAY);
4260:
4261: }
4262: }
4263: }
4264:
4265:
4266:
4267:
4268:
4269:
4270: public static JMenu mdlMenu;
4271:
4272: public static JRadioButtonMenuItem mdlShodaiMenuItem;
4273: public static JRadioButtonMenuItem mdlACEMenuItem;
4274: public static JRadioButtonMenuItem mdlEXPERTMenuItem;
4275: public static JRadioButtonMenuItem mdlPROMenuItem;
4276: public static JRadioButtonMenuItem mdlSUPERMenuItem;
4277: public static JRadioButtonMenuItem mdlXVIMenuItem;
4278: public static JRadioButtonMenuItem mdlXellent30MenuItem;
4279: public static JRadioButtonMenuItem mdlCompactMenuItem;
4280: public static JRadioButtonMenuItem mdlHybridMenuItem;
4281: public static JRadioButtonMenuItem mdl060turboPROMenuItem;
4282: public static JRadioButtonMenuItem mdlX68030MenuItem;
4283: public static JRadioButtonMenuItem mdl030CompactMenuItem;
4284: public static JRadioButtonMenuItem mdl060turboMenuItem;
4285: public static JCheckBoxMenuItem mdlMC68010MenuItem;
4286:
4287: public static JMenu coproFPUMenu;
4288:
4289:
4290: public static final int ACCELERATOR_HYBRID = 1;
4291: public static final int ACCELERATOR_XELLENT30 = 2;
4292: public static final int ACCELERATOR_060TURBO = 3;
4293: public static final int ACCELERATOR_060TURBOPRO = 4;
4294: public static final double MHZ_HYBRID_VALUE = 100.0 / 3.0;
4295: public static final String MHZ_HYBRID_STRING = "33.3";
4296: public static final double MHZ_060TURBO_VALUE = 50.0;
4297: public static final String MHZ_060TURBO_STRING = "50";
4298:
4299:
4300:
4301: public static Model specifiedModel;
4302: public static int specifiedAccelerator;
4303: public static boolean mpu010;
4304:
4305: public static boolean specifiedIsSecond;
4306: public static int specifiedFirstMPU;
4307: public static int specifiedSecondMPU;
4308: public static int specifiedMPU;
4309:
4310: public static double specifiedFirstClock;
4311: public static double specifiedSecondClock;
4312: public static double specifiedClock;
4313:
4314: public static int specifiedCopro0;
4315: public static int specifiedCopro1;
4316: public static int specifiedCopro2;
4317: public static int specifiedOnchipFPU;
4318:
4319:
4320:
4321: public static Model currentModel;
4322: public static int currentAccelerator;
4323:
4324: public static boolean currentIsSecond;
4325: public static int currentFirstMPU;
4326: public static int currentSecondMPU;
4327: public static int currentMPU;
4328:
4329:
4330: public static int currentCopro0;
4331: public static int currentCopro1;
4332: public static int currentCopro2;
4333: public static int currentOnchipFPU;
4334:
4335:
4336:
4337: public static void mdlInit () {
4338:
4339:
4340: specifiedModel = Model.COMPACT;
4341: specifiedAccelerator = ACCELERATOR_HYBRID;
4342: mpu010 = Settings.sgsGetOnOff ("mpu010");
4343: {
4344: String paramModel = Settings.sgsGetString ("model");
4345: switch (paramModel.toLowerCase ()) {
4346: case "":
4347: case "none":
4348: case "hybrid":
4349: specifiedModel = Model.COMPACT;
4350: specifiedAccelerator = ACCELERATOR_HYBRID;
4351: break;
4352: case "xellent30":
4353: specifiedModel = Model.XVI;
4354: specifiedAccelerator = ACCELERATOR_XELLENT30;
4355: break;
4356: case "060turbo":
4357: specifiedModel = Model.X68030;
4358: specifiedAccelerator = ACCELERATOR_060TURBO;
4359: break;
4360: case "060turbopro":
4361: specifiedModel = Model.PRO;
4362: specifiedAccelerator = ACCELERATOR_060TURBOPRO;
4363: break;
4364: default:
4365: Model model = Model.fromTypeOrSynonym (paramModel);
4366: if (model != null) {
4367: specifiedModel = model;
4368: specifiedAccelerator = 0;
4369: } else {
4370: System.out.println (Multilingual.mlnJapanese ?
4371: paramModel + " は不明な機種です" :
4372: paramModel + " is unknown model");
4373: specifiedModel = Model.COMPACT;
4374: specifiedAccelerator = ACCELERATOR_HYBRID;
4375: }
4376: }
4377: }
4378:
4379: specifiedIsSecond = false;
4380: specifiedFirstMPU = specifiedModel.getMPU ();
4381: specifiedSecondMPU = Model.MPU_MC68EC030;
4382: {
4383: String[] paramMPUs = Settings.sgsGetString ("mpu").split (",");
4384: for (int i = 0; i < 2; i++) {
4385: int mpu = 0;
4386: String paramMPU = i < paramMPUs.length ? paramMPUs[i] : "";
4387: switch (paramMPU) {
4388: case "":
4389: case "none":
4390: case "-1":
4391: mpu = (i == 0 ?
4392: (specifiedAccelerator == ACCELERATOR_060TURBO ||
4393: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4394: specifiedModel.getMPU ()) :
4395: Model.MPU_MC68EC030);
4396: break;
4397: case "0":
4398: case "68000":
4399: case "mc68000":
4400: mpu = Model.MPU_MC68000;
4401: break;
4402: case "1":
4403: case "68010":
4404: case "mc68010":
4405: mpu = Model.MPU_MC68010;
4406: break;
4407:
4408:
4409:
4410:
4411:
4412: case "3":
4413: case "68ec030":
4414: case "mc68ec030":
4415: mpu = Model.MPU_MC68EC030;
4416: break;
4417:
4418:
4419:
4420:
4421:
4422:
4423:
4424:
4425:
4426:
4427:
4428:
4429:
4430:
4431:
4432:
4433:
4434: case "6":
4435: case "68060":
4436: case "mc68060":
4437: mpu = Model.MPU_MC68060;
4438: break;
4439: default:
4440: Model model = Model.fromTypeOrSynonym (paramMPU);
4441: if (model != null) {
4442: mpu = model.getMPU ();
4443: } else {
4444: System.out.println (Multilingual.mlnJapanese ?
4445: paramMPU + " は不明な MPU です" :
4446: paramMPU + " is unknown MPU");
4447: mpu = specifiedModel.getMPU ();
4448: }
4449: }
4450: if (i == 0) {
4451: specifiedFirstMPU = mpu;
4452: } else {
4453: specifiedSecondMPU = mpu;
4454: }
4455: }
4456: }
4457: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
4458:
4459: specifiedFirstClock = specifiedModel.getClock ();
4460: specifiedSecondClock = specifiedFirstClock * 2.0;
4461: {
4462: String[] paramClocks = Settings.sgsGetString ("clock").split (",");
4463: for (int i = 0; i < 2; i++) {
4464: double clock = 0.0;
4465: String paramClock = i < paramClocks.length ? paramClocks[i] : "";
4466: switch (paramClock.toLowerCase ()) {
4467: case "":
4468: case "none":
4469: case "-1":
4470: clock = (i == 0 ?
4471: (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4472: specifiedAccelerator == ACCELERATOR_060TURBO ||
4473: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4474: specifiedModel.getClock ()) :
4475: specifiedFirstClock * 2.0);
4476: break;
4477: case "hybrid":
4478: clock = MHZ_HYBRID_VALUE;
4479: break;
4480: case "060turbo":
4481: case "060turbopro":
4482: clock = MHZ_060TURBO_VALUE;
4483: break;
4484: case "16.7":
4485: case "xellent30":
4486: clock = 50.0 / 3.0;
4487: break;
4488: case "33.3":
4489: clock = 100.0 / 3.0;
4490: break;
4491: case "66.7":
4492: clock = 200.0 / 3.0;
4493: break;
4494: default:
4495: if (paramClock.matches ("^(?:" +
4496: "[-+]?" +
4497: "(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)" +
4498: "(?:[Ee][-+]?[0-9]+)?" +
4499: ")$")) {
4500: double d = Double.parseDouble (paramClock);
4501: if (1.0 <= d && d <= 1000.0) {
4502: clock = d;
4503: }
4504: } else {
4505: System.out.println (Multilingual.mlnJapanese ?
4506: paramClock + " は不明な動作周波数です" :
4507: paramClock + " is unknown clock frequency");
4508: clock = specifiedModel.getClock ();
4509: }
4510: }
4511: if (i == 0) {
4512: specifiedFirstClock = clock;
4513: } else {
4514: specifiedSecondClock = clock;
4515: }
4516: }
4517: }
4518: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4519:
4520: specifiedCopro0 = 15 & Settings.sgsGetInt ("copro0", 2);
4521: if (!((7 & specifiedCopro0) == 0 ||
4522: (7 & specifiedCopro0) == 1 ||
4523: (7 & specifiedCopro0) == 2 ||
4524: (7 & specifiedCopro0) == 7)) {
4525: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4526: }
4527: specifiedCopro1 = 15 & Settings.sgsGetInt ("copro1", 2);
4528: if (!((7 & specifiedCopro1) == 0 ||
4529: (7 & specifiedCopro1) == 1 ||
4530: (7 & specifiedCopro1) == 2 ||
4531: (7 & specifiedCopro1) == 7)) {
4532: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4533: }
4534: specifiedCopro2 = 15 & Settings.sgsGetInt ("copro2", 2);
4535: if (!((7 & specifiedCopro2) == 0 ||
4536: (7 & specifiedCopro2) == 1 ||
4537: (7 & specifiedCopro2) == 2 ||
4538: (7 & specifiedCopro2) == 7)) {
4539: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4540: }
4541: specifiedOnchipFPU = 15 & Settings.sgsGetInt ("onchipfpu", 7);
4542: if (!((7 & specifiedOnchipFPU) == 0 ||
4543: (7 & specifiedOnchipFPU) == 6 ||
4544: (7 & specifiedOnchipFPU) == 7)) {
4545: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4546: }
4547:
4548:
4549: currentModel = specifiedModel;
4550: currentAccelerator = specifiedAccelerator;
4551:
4552: currentIsSecond = specifiedIsSecond;
4553: currentFirstMPU = specifiedFirstMPU;
4554: currentSecondMPU = specifiedSecondMPU;
4555: currentMPU = specifiedMPU;
4556:
4557:
4558: currentCopro0 = specifiedCopro0;
4559: currentCopro1 = specifiedCopro1;
4560: currentCopro2 = specifiedCopro2;
4561: currentOnchipFPU = specifiedOnchipFPU;
4562:
4563:
4564: mpuUtilOn = Settings.sgsGetOnOff ("util");
4565: mpuUtilRatio = fmtParseInt (Settings.sgsGetString ("ratio"), 0, 1, 100, 100);
4566:
4567: mpuArbFreqMHz = fmtParseInt (Settings.sgsGetString ("mhz"), 0, 1, 1000, 100);
4568: if (mpuUtilOn) {
4569: mpuArbFreqOn = false;
4570: } else {
4571: mpuArbFreqOn = !(specifiedClock == 10.0 ||
4572: specifiedClock == 50.0 / 3.0 ||
4573: specifiedClock == 25.0 ||
4574: specifiedClock == 100.0 / 3.0 ||
4575: specifiedClock == 50.0 ||
4576: specifiedClock == 200.0 / 3.0 ||
4577: specifiedClock == 75.0 ||
4578: specifiedClock == 100.0);
4579: if (mpuArbFreqOn) {
4580: mpuArbFreqMHz = (int) specifiedClock;
4581: }
4582: }
4583:
4584:
4585: mpuROMWaitCycles = 0;
4586: mpuRAMWaitCycles = 0;
4587: mpuCacheOn = false;
4588:
4589: mpuNoWaitTime.ram = 0;
4590: mpuNoWaitTime.gvram = 0;
4591: mpuNoWaitTime.tvram = 0;
4592: mpuNoWaitTime.crtc = 0;
4593: mpuNoWaitTime.palet = 0;
4594: mpuNoWaitTime.vicon = 0;
4595: mpuNoWaitTime.dmac = 0;
4596: mpuNoWaitTime.mfp = 0;
4597: mpuNoWaitTime.rtc = 0;
4598: mpuNoWaitTime.prnport = 0;
4599: mpuNoWaitTime.sysport = 0;
4600: mpuNoWaitTime.opm = 0;
4601: mpuNoWaitTime.adpcm = 0;
4602: mpuNoWaitTime.fdc = 0;
4603: mpuNoWaitTime.fdd = 0;
4604: mpuNoWaitTime.hdc = 0;
4605: mpuNoWaitTime.scc = 0;
4606: mpuNoWaitTime.ppi = 0;
4607: mpuNoWaitTime.ioi = 0;
4608: mpuNoWaitTime.sprc = 0;
4609: mpuNoWaitTime.sram = 0;
4610: mpuNoWaitTime.rom = 0;
4611: mpuNoWaitTime.ramlong = mpuNoWaitTime.ram << 1;
4612: mpuNoWaitTime.romlong = mpuNoWaitTime.rom << 1;
4613:
4614: dmaNoWaitTime.ram = 0;
4615: dmaNoWaitTime.gvram = 0;
4616: dmaNoWaitTime.tvram = 0;
4617: dmaNoWaitTime.crtc = 0;
4618: dmaNoWaitTime.palet = 0;
4619: dmaNoWaitTime.vicon = 0;
4620: dmaNoWaitTime.dmac = 0;
4621: dmaNoWaitTime.mfp = 0;
4622: dmaNoWaitTime.rtc = 0;
4623: dmaNoWaitTime.prnport = 0;
4624: dmaNoWaitTime.sysport = 0;
4625: dmaNoWaitTime.opm = 0;
4626: dmaNoWaitTime.adpcm = 0;
4627: dmaNoWaitTime.fdc = 0;
4628: dmaNoWaitTime.fdd = 0;
4629: dmaNoWaitTime.hdc = 0;
4630: dmaNoWaitTime.scc = 0;
4631: dmaNoWaitTime.ppi = 0;
4632: dmaNoWaitTime.ioi = 0;
4633: dmaNoWaitTime.sprc = 0;
4634: dmaNoWaitTime.sram = 0;
4635: dmaNoWaitTime.rom = 0;
4636: dmaNoWaitTime.ramlong = dmaNoWaitTime.ram << 1;
4637: dmaNoWaitTime.romlong = dmaNoWaitTime.rom << 1;
4638:
4639:
4640: busWaitCyclesRequest = Settings.sgsGetOnOff ("waitcycles");
4641: busWaitCycles = busWaitCyclesRequest;
4642: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
4643:
4644: }
4645:
4646: public static void mdlTini () {
4647:
4648: Settings.sgsPutString ("model",
4649: specifiedAccelerator == ACCELERATOR_HYBRID ? "Hybrid" :
4650: specifiedAccelerator == ACCELERATOR_XELLENT30 ? "Xellent30" :
4651: specifiedAccelerator == ACCELERATOR_060TURBO ? "060turbo" :
4652: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? "060turboPRO" :
4653: specifiedModel.getSynonym () != null ? specifiedModel.getSynonym () :
4654: specifiedModel.getType ());
4655: Settings.sgsPutOnOff ("mpu010", mpu010);
4656:
4657:
4658: int defaultFirstMPU = (specifiedAccelerator == ACCELERATOR_060TURBO ||
4659: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4660: specifiedModel.getMPU ());
4661: int defaultSecondMPU = Model.MPU_MC68EC030;
4662: Settings.sgsPutString ("mpu",
4663: (specifiedFirstMPU == defaultFirstMPU ? "" :
4664: Model.mpuNameOf (specifiedFirstMPU)) +
4665: (specifiedSecondMPU == defaultSecondMPU ? "" :
4666: "," + Model.mpuNameOf (specifiedSecondMPU)));
4667:
4668:
4669:
4670:
4671: double defaultFirstClock = (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4672: specifiedAccelerator == ACCELERATOR_060TURBO ||
4673: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4674: specifiedModel.getClock ());
4675: double defaultSecondClock = defaultFirstClock * 2.0;
4676: Settings.sgsPutString ("clock",
4677: (specifiedFirstClock == defaultFirstClock ? "" :
4678: specifiedFirstClock == 50.0 / 3.0 ? "16.7" :
4679: specifiedFirstClock == 100.0 / 3.0 ? "33.3" :
4680: specifiedFirstClock == 200.0 / 3.0 ? "66.7" :
4681: String.valueOf ((int) specifiedFirstClock)) +
4682: (specifiedSecondClock == defaultSecondClock ? "" :
4683: "," + (specifiedSecondClock == 50.0 / 3.0 ? "16.7" :
4684: specifiedSecondClock == 100.0 / 3.0 ? "33.3" :
4685: specifiedSecondClock == 200.0 / 3.0 ? "66.7" :
4686: String.valueOf ((int) specifiedSecondClock))));
4687:
4688: Settings.sgsPutInt ("copro0", specifiedCopro0);
4689: Settings.sgsPutInt ("copro1", specifiedCopro1);
4690: Settings.sgsPutInt ("copro2", specifiedCopro2);
4691: Settings.sgsPutInt ("onchipfpu", specifiedOnchipFPU);
4692:
4693: Settings.sgsPutOnOff ("util",
4694: mpuUtilOn);
4695: Settings.sgsPutString ("ratio",
4696: String.valueOf (mpuUtilRatio));
4697:
4698: Settings.sgsPutString ("mhz",
4699: String.valueOf (mpuArbFreqMHz));
4700:
4701: Settings.sgsPutOnOff ("waitcycles", busWaitCyclesRequest);
4702: }
4703:
4704: public static void mdlMakeMenu () {
4705:
4706:
4707: ActionListener listener = new ActionListener () {
4708: @Override public void actionPerformed (ActionEvent ae) {
4709: Object source = ae.getSource ();
4710: switch (ae.getActionCommand ()) {
4711: case "X68000 (10MHz)":
4712: mdlRequestModel (Model.SHODAI, 0);
4713: mpuReset (-1, -1);
4714: break;
4715: case "X68000 ACE (10MHz)":
4716: mdlRequestModel (Model.ACE, 0);
4717: mpuReset (-1, -1);
4718: break;
4719: case "X68000 EXPERT (10MHz)":
4720: mdlRequestModel (Model.EXPERT, 0);
4721: mpuReset (-1, -1);
4722: break;
4723: case "X68000 PRO (10MHz)":
4724: mdlRequestModel (Model.PRO, 0);
4725: mpuReset (-1, -1);
4726: break;
4727: case "X68000 SUPER (10MHz)":
4728: mdlRequestModel (Model.SUPER, 0);
4729: mpuReset (-1, -1);
4730: break;
4731: case "X68000 XVI (16.7MHz)":
4732: mdlRequestModel (Model.XVI, 0);
4733: mpuReset (-1, -1);
4734: break;
4735: case "X68000 Compact (16.7MHz)":
4736: mdlRequestModel (Model.COMPACT, 0);
4737: mpuReset (-1, -1);
4738: break;
4739:
4740: case "X68030 (25MHz)":
4741: mdlRequestModel (Model.X68030, 0);
4742: mpuReset (-1, -1);
4743: break;
4744: case "X68030 Compact (25MHz)":
4745: mdlRequestModel (Model.X68030COMPACT, 0);
4746: mpuReset (-1, -1);
4747: break;
4748:
4749: case "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)":
4750: mdlRequestModel (Model.COMPACT, ACCELERATOR_HYBRID);
4751: mpuReset (-1, -1);
4752: break;
4753: case "Xellent30 (33.3MHz)":
4754: mdlRequestModel (Model.XVI, ACCELERATOR_XELLENT30);
4755: mpuReset (-1, -1);
4756: break;
4757: case "060turbo (" + MHZ_060TURBO_STRING + "MHz)":
4758: mdlRequestModel (Model.X68030, ACCELERATOR_060TURBO);
4759: mpuReset (-1, -1);
4760: break;
4761: case "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)":
4762: mdlRequestModel (Model.PRO, ACCELERATOR_060TURBOPRO);
4763: mpuReset (-1, -1);
4764: break;
4765:
4766: case "MC68010":
4767: mpu010 = ((JCheckBoxMenuItem) source).isSelected ();
4768: break;
4769:
4770: }
4771: }
4772: };
4773:
4774:
4775: ButtonGroup modelGroup = new ButtonGroup ();
4776: mdlMenu = Multilingual.mlnText (
4777: ComponentFactory.createMenu (
4778: "Change the model and reset",
4779: mdlShodaiMenuItem = ComponentFactory.createRadioButtonMenuItem (
4780: modelGroup,
4781: specifiedModel == Model.SHODAI,
4782: "X68000 (10MHz)",
4783: listener),
4784: mdlACEMenuItem = ComponentFactory.createRadioButtonMenuItem (
4785: modelGroup,
4786: specifiedModel == Model.ACE,
4787: "X68000 ACE (10MHz)",
4788: listener),
4789: mdlEXPERTMenuItem = ComponentFactory.createRadioButtonMenuItem (
4790: modelGroup,
4791: specifiedModel == Model.EXPERT,
4792: "X68000 EXPERT (10MHz)",
4793: listener),
4794: mdlPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
4795: modelGroup,
4796: specifiedModel == Model.PRO && specifiedAccelerator == 0,
4797: "X68000 PRO (10MHz)",
4798: listener),
4799: mdlSUPERMenuItem = ComponentFactory.createRadioButtonMenuItem (
4800: modelGroup,
4801: specifiedModel == Model.SUPER,
4802: "X68000 SUPER (10MHz)",
4803: listener),
4804: mdlXVIMenuItem = ComponentFactory.createRadioButtonMenuItem (
4805: modelGroup,
4806: specifiedModel == Model.XVI && specifiedAccelerator == 0,
4807: "X68000 XVI (16.7MHz)",
4808: listener),
4809: mdlCompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
4810: modelGroup,
4811: specifiedModel == Model.COMPACT && specifiedAccelerator == 0,
4812: "X68000 Compact (16.7MHz)",
4813: listener),
4814:
4815: ComponentFactory.createHorizontalSeparator (),
4816:
4817: mdlX68030MenuItem = ComponentFactory.createRadioButtonMenuItem (
4818: modelGroup,
4819: specifiedModel == Model.X68030 && specifiedAccelerator == 0,
4820: "X68030 (25MHz)",
4821: listener),
4822: mdl030CompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
4823: modelGroup,
4824: specifiedModel == Model.X68030COMPACT,
4825: "X68030 Compact (25MHz)",
4826: listener),
4827:
4828: ComponentFactory.createHorizontalSeparator (),
4829:
4830: mdlHybridMenuItem = ComponentFactory.createRadioButtonMenuItem (
4831: modelGroup,
4832: specifiedModel == Model.COMPACT && specifiedAccelerator == ACCELERATOR_HYBRID,
4833: "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)",
4834: listener),
4835: mdlXellent30MenuItem = ComponentFactory.createRadioButtonMenuItem (
4836: modelGroup,
4837: specifiedModel == Model.XVI && specifiedAccelerator == ACCELERATOR_XELLENT30,
4838: "Xellent30 (33.3MHz)",
4839: listener),
4840: mdl060turboMenuItem = ComponentFactory.createRadioButtonMenuItem (
4841: modelGroup,
4842: specifiedModel == Model.X68030 && specifiedAccelerator == ACCELERATOR_060TURBO,
4843: "060turbo (" + MHZ_060TURBO_STRING + "MHz)",
4844: listener),
4845: mdl060turboPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
4846: modelGroup,
4847: specifiedModel == Model.PRO && specifiedAccelerator == ACCELERATOR_060TURBOPRO,
4848: "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)",
4849: listener),
4850:
4851: ComponentFactory.createHorizontalSeparator (),
4852:
4853: mdlMC68010MenuItem = ComponentFactory.createCheckBoxMenuItem (
4854: mpu010,
4855: "MC68010",
4856: listener)
4857: ),
4858: "ja", "機種を変更してリセット");
4859:
4860:
4861: ActionListener copro0Listener = new ActionListener () {
4862: @Override public void actionPerformed (ActionEvent ae) {
4863: String command = ae.getActionCommand ();
4864: switch (command) {
4865: case "Not installed":
4866: specifiedCopro0 = (8 & specifiedCopro0) | 0;
4867: break;
4868: case "MC68881":
4869: specifiedCopro0 = (8 & specifiedCopro0) | 1;
4870: break;
4871: case "MC68882":
4872: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4873: break;
4874: case "Full specification":
4875: specifiedCopro0 = (8 & specifiedCopro0) | 7;
4876: break;
4877: case "Extended precision (19 digits)":
4878: specifiedCopro0 = 0 | (7 & specifiedCopro0);
4879: break;
4880: case "Triple precision (24 digits)":
4881: specifiedCopro0 = 8 | (7 & specifiedCopro0);
4882: break;
4883: default:
4884: System.out.println ("unknown action command " + command);
4885: }
4886: }
4887: };
4888:
4889: ActionListener copro1Listener = new ActionListener () {
4890: @Override public void actionPerformed (ActionEvent ae) {
4891: String command = ae.getActionCommand ();
4892: switch (command) {
4893: case "Not installed":
4894: specifiedCopro1 = (8 & specifiedCopro1) | 0;
4895: break;
4896: case "MC68881":
4897: specifiedCopro1 = (8 & specifiedCopro1) | 1;
4898: break;
4899: case "MC68882":
4900: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4901: break;
4902: case "Full specification":
4903: specifiedCopro1 = (8 & specifiedCopro1) | 7;
4904: break;
4905: case "Extended precision (19 digits)":
4906: specifiedCopro1 = 0 | (7 & specifiedCopro1);
4907: break;
4908: case "Triple precision (24 digits)":
4909: specifiedCopro1 = 8 | (7 & specifiedCopro1);
4910: break;
4911: default:
4912: System.out.println ("unknown action command " + command);
4913: }
4914: }
4915: };
4916:
4917: ActionListener copro2Listener = new ActionListener () {
4918: @Override public void actionPerformed (ActionEvent ae) {
4919: String command = ae.getActionCommand ();
4920: switch (command) {
4921: case "Not installed":
4922: specifiedCopro2 = (8 & specifiedCopro2) | 0;
4923: break;
4924: case "MC68881":
4925: specifiedCopro2 = (8 & specifiedCopro2) | 1;
4926: break;
4927: case "MC68882":
4928: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4929: break;
4930: case "Full specification":
4931: specifiedCopro2 = (8 & specifiedCopro2) | 7;
4932: break;
4933: case "Extended precision (19 digits)":
4934: specifiedCopro2 = 0 | (7 & specifiedCopro2);
4935: break;
4936: case "Triple precision (24 digits)":
4937: specifiedCopro2 = 8 | (7 & specifiedCopro2);
4938: break;
4939: default:
4940: System.out.println ("unknown action command " + command);
4941: }
4942: }
4943: };
4944:
4945: ActionListener onchipFPUListener = new ActionListener () {
4946: @Override public void actionPerformed (ActionEvent ae) {
4947: String command = ae.getActionCommand ();
4948: switch (command) {
4949: case "Not installed":
4950: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 0;
4951: break;
4952: case "MC68060":
4953: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 6;
4954: break;
4955: case "Full specification":
4956: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4957: break;
4958: case "Extended precision (19 digits)":
4959: specifiedOnchipFPU = 0 | (7 & specifiedOnchipFPU);
4960: break;
4961: case "Triple precision (24 digits)":
4962: specifiedOnchipFPU = 8 | (7 & specifiedOnchipFPU);
4963: break;
4964: default:
4965: System.out.println ("unknown action command " + command);
4966: }
4967: }
4968: };
4969:
4970: ButtonGroup copro00Group = new ButtonGroup ();
4971: ButtonGroup copro01Group = new ButtonGroup ();
4972: ButtonGroup copro10Group = new ButtonGroup ();
4973: ButtonGroup copro11Group = new ButtonGroup ();
4974: ButtonGroup copro20Group = new ButtonGroup ();
4975: ButtonGroup copro21Group = new ButtonGroup ();
4976: ButtonGroup onchipFPU0Group = new ButtonGroup ();
4977: ButtonGroup onchipFPU1Group = new ButtonGroup ();
4978:
4979: coproFPUMenu = Multilingual.mlnText (
4980: ComponentFactory.createMenu (
4981: "Coprocessor and on-chip FPU",
4982:
4983: Multilingual.mlnText (
4984: ComponentFactory.createMenu (
4985: "Motherboard coprocessor",
4986: Multilingual.mlnText (
4987: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 0, "Not installed", copro0Listener),
4988: "ja", "なし"),
4989: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 1, "MC68881", copro0Listener),
4990: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 2, "MC68882", copro0Listener),
4991: Multilingual.mlnText (
4992: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 7, "Full specification", copro0Listener),
4993: "ja", "フルスペック"),
4994: ComponentFactory.createHorizontalSeparator (),
4995: Multilingual.mlnText (
4996: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) == 0, "Extended precision (19 digits)", copro0Listener),
4997: "ja", "拡張精度 (19 桁)"),
4998: Multilingual.mlnText (
4999: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) != 0, "Triple precision (24 digits)", copro0Listener),
5000: "ja", "三倍精度 (24 桁)")),
5001: "ja", "マザーボードコプロセッサ"),
5002:
5003: Multilingual.mlnText (
5004: ComponentFactory.createMenu (
5005: "Extension coprocessor #1",
5006: Multilingual.mlnText (
5007: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 0, "Not installed", copro1Listener),
5008: "ja", "なし"),
5009: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 1, "MC68881", copro1Listener),
5010: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 2, "MC68882", copro1Listener),
5011: Multilingual.mlnText (
5012: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 7, "Full specification", copro1Listener),
5013: "ja", "フルスペック"),
5014: ComponentFactory.createHorizontalSeparator (),
5015: Multilingual.mlnText (
5016: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) == 0, "Extended precision (19 digits)", copro1Listener),
5017: "ja", "拡張精度 (19 桁)"),
5018: Multilingual.mlnText (
5019: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) != 0, "Triple precision (24 digits)", copro1Listener),
5020: "ja", "三倍精度 (24 桁)")),
5021: "ja", "拡張コプロセッサ #1"),
5022:
5023: Multilingual.mlnText (
5024: ComponentFactory.createMenu (
5025: "Extension coprocessor #2",
5026: Multilingual.mlnText (
5027: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 0, "Not installed", copro2Listener),
5028: "ja", "なし"),
5029: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 1, "MC68881", copro2Listener),
5030: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 2, "MC68882", copro2Listener),
5031: Multilingual.mlnText (
5032: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 7, "Full specification", copro2Listener),
5033: "ja", "フルスペック"),
5034: ComponentFactory.createHorizontalSeparator (),
5035: Multilingual.mlnText (
5036: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) == 0, "Extended precision (19 digits)", copro2Listener),
5037: "ja", "拡張精度 (19 桁)"),
5038: Multilingual.mlnText (
5039: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) != 0, "Triple precision (24 digits)", copro2Listener),
5040: "ja", "三倍精度 (24 桁)")),
5041: "ja", "拡張コプロセッサ #2"),
5042:
5043: Multilingual.mlnText (
5044: ComponentFactory.createMenu (
5045: "On-chip FPU",
5046: Multilingual.mlnText (
5047: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 0, "Not installed", onchipFPUListener),
5048: "ja", "なし"),
5049: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 6, "MC68060", onchipFPUListener),
5050: Multilingual.mlnText (
5051: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 7, "Full specification", onchipFPUListener),
5052: "ja", "フルスペック"),
5053: ComponentFactory.createHorizontalSeparator (),
5054: Multilingual.mlnText (
5055: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) == 0, "Extended precision (19 digits)", onchipFPUListener),
5056: "ja", "拡張精度 (19 桁)"),
5057: Multilingual.mlnText (
5058: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) != 0, "Triple precision (24 digits)", onchipFPUListener),
5059: "ja", "三倍精度 (24 桁)")),
5060: "ja", "オンチップ FPU")),
5061: "ja", "コプロセッサとオンチップ FPU");
5062:
5063: }
5064:
5065: public static void mdlRequestModel (Model model, int accelerator) {
5066: specifiedModel = model;
5067: specifiedAccelerator = accelerator;
5068:
5069: specifiedIsSecond = false;
5070: specifiedFirstMPU = specifiedModel.getMPU ();
5071: specifiedSecondMPU = Model.MPU_MC68EC030;
5072: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
5073: specifiedFirstClock = specifiedModel.getClock ();
5074: specifiedSecondClock = specifiedFirstClock * 2.0;
5075: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5076:
5077: switch (accelerator) {
5078: case ACCELERATOR_HYBRID:
5079: specifiedFirstClock = MHZ_HYBRID_VALUE;
5080: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5081: break;
5082: case ACCELERATOR_XELLENT30:
5083: break;
5084: case ACCELERATOR_060TURBO:
5085: case ACCELERATOR_060TURBOPRO:
5086: specifiedFirstMPU = Model.MPU_MC68060;
5087: specifiedFirstClock = MHZ_060TURBO_VALUE;
5088: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5089: }
5090:
5091: mpuUtilOn = false;
5092: mpuArbFreqOn = false;
5093: mpuSetCurrentClock (specifiedClock);
5094:
5095: if (accelerator == ACCELERATOR_HYBRID) {
5096: mdlHybridMenuItem.setSelected (true);
5097: } else if (accelerator == ACCELERATOR_XELLENT30) {
5098: mdlXellent30MenuItem.setSelected (true);
5099: } else if (accelerator == ACCELERATOR_060TURBO) {
5100: mdl060turboMenuItem.setSelected (true);
5101: } else if (accelerator == ACCELERATOR_060TURBOPRO) {
5102: mdl060turboPROMenuItem.setSelected (true);
5103: } else if (specifiedModel == Model.SHODAI) {
5104: mdlShodaiMenuItem.setSelected (true);
5105: } else if (specifiedModel == Model.ACE) {
5106: mdlACEMenuItem.setSelected (true);
5107: } else if (specifiedModel == Model.EXPERT) {
5108: mdlEXPERTMenuItem.setSelected (true);
5109: } else if (specifiedModel == Model.PRO) {
5110: mdlPROMenuItem.setSelected (true);
5111: } else if (specifiedModel == Model.SUPER) {
5112: mdlSUPERMenuItem.setSelected (true);
5113: } else if (specifiedModel == Model.XVI) {
5114: mdlXVIMenuItem.setSelected (true);
5115: } else if (specifiedModel == Model.COMPACT) {
5116: mdlCompactMenuItem.setSelected (true);
5117: } else if (specifiedModel == Model.X68030) {
5118: mdlX68030MenuItem.setSelected (true);
5119: } else if (specifiedModel == Model.X68030COMPACT) {
5120: mdl030CompactMenuItem.setSelected (true);
5121: }
5122:
5123:
5124: HDC.hdcSASIMenuItem.setSelected (!currentModel.isSCSI ());
5125: SPC.spcSCSIINMenuItem.setSelected (currentModel.isSCSI ());
5126: }
5127:
5128:
5129:
5130:
5131:
5132:
5133:
5134: public static final boolean MPU_INLINE_EXCEPTION = true;
5135: public static final boolean MPU_COMPOUND_POSTINCREMENT = false;
5136:
5137: public static final boolean MPU_SWITCH_MISC_OPCODE = false;
5138: public static final boolean MPU_SWITCH_BCC_CONDITION = false;
5139: public static final boolean MPU_SWITCH_BCC_OFFSET = false;
5140: public static final boolean MPU_SWITCH_SCC_CONDITION = true;
5141:
5142: public static final boolean MPU_OMIT_EXTRA_READ = false;
5143: public static final boolean MPU_OMIT_OFFSET_READ = false;
5144:
5145:
5146:
5147:
5148: public static final long FAR_FUTURE = 0x7fffffffffffffffL;
5149:
5150:
5151:
5152:
5153:
5154:
5155:
5156:
5157: public static final int REG_SR_T1 = 0b10000000_00000000;
5158: public static final int REG_SR_T0 = 0b01000000_00000000;
5159:
5160:
5161:
5162:
5163:
5164:
5165: public static final int REG_SR_S = 0b00100000_00000000;
5166: public static final int REG_SR_M = 0b00010000_00000000;
5167:
5168: public static final int REG_SR_I = 0b00000111_00000000;
5169:
5170:
5171: public static final int REG_CCR_X = 0b00000000_00010000;
5172: public static final int REG_CCR_N = 0b00000000_00001000;
5173: public static final int REG_CCR_Z = 0b00000000_00000100;
5174: public static final int REG_CCR_V = 0b00000000_00000010;
5175: public static final int REG_CCR_C = 0b00000000_00000001;
5176: public static final int REG_CCR_MASK = REG_CCR_X | REG_CCR_N | REG_CCR_Z | REG_CCR_V | REG_CCR_C;
5177:
5178: public static char[] REG_CCRXMAP = "00000000000000001111111111111111".toCharArray ();
5179: public static char[] REG_CCRNMAP = "00000000111111110000000011111111".toCharArray ();
5180: public static char[] REG_CCRZMAP = "00001111000011110000111100001111".toCharArray ();
5181: public static char[] REG_CCRVMAP = "00110011001100110011001100110011".toCharArray ();
5182: public static char[] REG_CCRCMAP = "01010101010101010101010101010101".toCharArray ();
5183:
5184:
5185:
5186: public static final int MPU_IOI_INTERRUPT_LEVEL = 1;
5187: public static final int MPU_EB2_INTERRUPT_LEVEL = 2;
5188: public static final int MPU_DMA_INTERRUPT_LEVEL = 3;
5189: public static final int MPU_SCC_INTERRUPT_LEVEL = 5;
5190: public static final int MPU_MFP_INTERRUPT_LEVEL = 6;
5191: public static final int MPU_SYS_INTERRUPT_LEVEL = 7;
5192: public static final int MPU_IOI_INTERRUPT_MASK = 0x80 >> MPU_IOI_INTERRUPT_LEVEL;
5193: public static final int MPU_EB2_INTERRUPT_MASK = 0x80 >> MPU_EB2_INTERRUPT_LEVEL;
5194: public static final int MPU_DMA_INTERRUPT_MASK = 0x80 >> MPU_DMA_INTERRUPT_LEVEL;
5195: public static final int MPU_SCC_INTERRUPT_MASK = 0x80 >> MPU_SCC_INTERRUPT_LEVEL;
5196: public static final int MPU_MFP_INTERRUPT_MASK = 0x80 >> MPU_MFP_INTERRUPT_LEVEL;
5197: public static final int MPU_SYS_INTERRUPT_MASK = 0x80 >> MPU_SYS_INTERRUPT_LEVEL;
5198:
5199: public static final boolean MPU_INTERRUPT_SWITCH = true;
5200:
5201:
5202: public static final boolean T = true;
5203: public static final boolean F = false;
5204:
5205: public static final int CCCC_T = 0b0000;
5206: public static final int CCCC_F = 0b0001;
5207: public static final int CCCC_HI = 0b0010;
5208: public static final int CCCC_LS = 0b0011;
5209: public static final int CCCC_CC = 0b0100;
5210: public static final int CCCC_CS = 0b0101;
5211: public static final int CCCC_NE = 0b0110;
5212: public static final int CCCC_EQ = 0b0111;
5213: public static final int CCCC_VC = 0b1000;
5214: public static final int CCCC_VS = 0b1001;
5215: public static final int CCCC_PL = 0b1010;
5216: public static final int CCCC_MI = 0b1011;
5217: public static final int CCCC_GE = 0b1100;
5218: public static final int CCCC_LT = 0b1101;
5219: public static final int CCCC_GT = 0b1110;
5220: public static final int CCCC_LE = 0b1111;
5221:
5222:
5223:
5224:
5225:
5226:
5227: public static final boolean[] BCCMAP = {
5228: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
5229: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
5230: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
5231: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
5232: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
5233: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
5234: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
5235: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
5236: T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,
5237: F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,F,F,T,T,
5238: T,T,T,T,T,T,T,T,F,F,F,F,F,F,F,F,T,T,T,T,T,T,T,T,F,F,F,F,F,F,F,F,
5239: F,F,F,F,F,F,F,F,T,T,T,T,T,T,T,T,F,F,F,F,F,F,F,F,T,T,T,T,T,T,T,T,
5240: T,T,F,F,T,T,F,F,F,F,T,T,F,F,T,T,T,T,F,F,T,T,F,F,F,F,T,T,F,F,T,T,
5241: F,F,T,T,F,F,T,T,T,T,F,F,T,T,F,F,F,F,T,T,F,F,T,T,T,T,F,F,T,T,F,F,
5242: T,T,F,F,F,F,F,F,F,F,T,T,F,F,F,F,T,T,F,F,F,F,F,F,F,F,T,T,F,F,F,F,
5243: F,F,T,T,T,T,T,T,T,T,F,F,T,T,T,T,F,F,T,T,T,T,T,T,T,T,F,F,T,T,T,T,
5244: };
5245:
5246:
5247: public static final char[] MPU_CCCMAP = (
5248: "11111111111111111111111111111111" +
5249: "00000000000000000000000000000000" +
5250: "10100000101000001010000010100000" +
5251: "01011111010111110101111101011111" +
5252: "10101010101010101010101010101010" +
5253: "01010101010101010101010101010101" +
5254: "11110000111100001111000011110000" +
5255: "00001111000011110000111100001111" +
5256: "11001100110011001100110011001100" +
5257: "00110011001100110011001100110011" +
5258: "11111111000000001111111100000000" +
5259: "00000000111111110000000011111111" +
5260: "11001100001100111100110000110011" +
5261: "00110011110011000011001111001100" +
5262: "11000000001100001100000000110000" +
5263: "00111111110011110011111111001111").toCharArray ();
5264:
5265:
5266:
5267: public static final int MPU_CC_T = 0b11111111111111111111111111111111;
5268: public static final int MPU_CC_F = 0b00000000000000000000000000000000;
5269: public static final int MPU_CC_HI = 0b10100000101000001010000010100000;
5270: public static final int MPU_CC_LS = 0b01011111010111110101111101011111;
5271: public static final int MPU_CC_HS = 0b10101010101010101010101010101010;
5272: public static final int MPU_CC_LO = 0b01010101010101010101010101010101;
5273: public static final int MPU_CC_NE = 0b11110000111100001111000011110000;
5274: public static final int MPU_CC_EQ = 0b00001111000011110000111100001111;
5275: public static final int MPU_CC_VC = 0b11001100110011001100110011001100;
5276: public static final int MPU_CC_VS = 0b00110011001100110011001100110011;
5277: public static final int MPU_CC_PL = 0b11111111000000001111111100000000;
5278: public static final int MPU_CC_MI = 0b00000000111111110000000011111111;
5279: public static final int MPU_CC_GE = 0b11001100001100111100110000110011;
5280: public static final int MPU_CC_LT = 0b00110011110011000011001111001100;
5281: public static final int MPU_CC_GT = 0b11000000001100001100000000110000;
5282: public static final int MPU_CC_LE = 0b00111111110011110011111111001111;
5283:
5284:
5285:
5286:
5287:
5288:
5289:
5290:
5291:
5292:
5293:
5294:
5295:
5296:
5297:
5298:
5299:
5300:
5301:
5302:
5303:
5304:
5305:
5306:
5307:
5308:
5309:
5310:
5311:
5312:
5313:
5314:
5315:
5316:
5317:
5318:
5319:
5320:
5321:
5322:
5323:
5324:
5325:
5326:
5327:
5328:
5329:
5330:
5331:
5332: public static final byte[] MPU_TSTB_TABLE = "\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b".getBytes (XEiJ.ISO_8859_1);
5333:
5334:
5335:
5336: public static final int[] MPU_BITREV_TABLE_0 = new int[2048];
5337: public static final int[] MPU_BITREV_TABLE_1 = new int[2048];
5338: public static final int[] MPU_BITREV_TABLE_2 = new int[2048];
5339: static {
5340: for (int i = 0; i < 2048; i++) {
5341: MPU_BITREV_TABLE_2[i] = (MPU_BITREV_TABLE_1[i] = (MPU_BITREV_TABLE_0[i] = Integer.reverse (i)) >>> 11) >>> 11;
5342: }
5343: }
5344:
5345:
5346:
5347: public static final int EA_DR = 0b000_000;
5348: public static final int EA_AR = 0b001_000;
5349: public static final int EA_MM = 0b010_000;
5350: public static final int EA_MP = 0b011_000;
5351: public static final int EA_MN = 0b100_000;
5352: public static final int EA_MW = 0b101_000;
5353: public static final int EA_MX = 0b110_000;
5354: public static final int EA_ZW = 0b111_000;
5355: public static final int EA_ZL = 0b111_001;
5356: public static final int EA_PW = 0b111_010;
5357: public static final int EA_PX = 0b111_011;
5358: public static final int EA_IM = 0b111_100;
5359: public static final int MMM_DR = EA_DR >> 3;
5360: public static final int MMM_AR = EA_AR >> 3;
5361: public static final int MMM_MM = EA_MM >> 3;
5362: public static final int MMM_MP = EA_MP >> 3;
5363: public static final int MMM_MN = EA_MN >> 3;
5364: public static final int MMM_MW = EA_MW >> 3;
5365: public static final int MMM_MX = EA_MX >> 3;
5366: public static final long EAM_DR = 0xff00000000000000L >>> EA_DR;
5367: public static final long EAM_AR = 0xff00000000000000L >>> EA_AR;
5368: public static final long EAM_MM = 0xff00000000000000L >>> EA_MM;
5369: public static final long EAM_MP = 0xff00000000000000L >>> EA_MP;
5370: public static final long EAM_MN = 0xff00000000000000L >>> EA_MN;
5371: public static final long EAM_MW = 0xff00000000000000L >>> EA_MW;
5372: public static final long EAM_MX = 0xff00000000000000L >>> EA_MX;
5373: public static final long EAM_ZW = 0x8000000000000000L >>> EA_ZW;
5374: public static final long EAM_ZL = 0x8000000000000000L >>> EA_ZL;
5375: public static final long EAM_PW = 0x8000000000000000L >>> EA_PW;
5376: public static final long EAM_PX = 0x8000000000000000L >>> EA_PX;
5377: public static final long EAM_IM = 0x8000000000000000L >>> EA_IM;
5378: public static final long EAM_ALL = EAM_DR|EAM_AR|EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX|EAM_IM;
5379: public static final long EAM_ALT = EAM_DR|EAM_AR|EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5380: public static final long EAM_DAT = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX|EAM_IM;
5381: public static final long EAM_DME = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5382: public static final long EAM_DLT = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5383: public static final long EAM_DCN = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5384: public static final long EAM_DCL = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5385: public static final long EAM_ANY = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX|EAM_IM;
5386: public static final long EAM_MEM = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5387: public static final long EAM_MLT = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5388: public static final long EAM_RDL = EAM_MM|EAM_MP |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5389: public static final long EAM_WTL = EAM_MM |EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5390: public static final long EAM_CNT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5391: public static final long EAM_CLT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5392:
5393:
5394:
5395:
5396:
5397:
5398:
5399:
5400:
5401:
5402:
5403: public static final int[] regRn = new int[16 + 1];
5404:
5405:
5406: public static int regPC;
5407: public static int regPC0;
5408:
5409:
5410: public static int regOC;
5411:
5412:
5413: public static int regSRT1;
5414: public static int regSRT0;
5415: public static int mpuTraceFlag;
5416: public static int regSRS;
5417: public static int regSRM;
5418: public static int regSRI;
5419:
5420:
5421: public static int regCCR;
5422:
5423:
5424:
5425:
5426:
5427:
5428:
5429:
5430:
5431:
5432:
5433:
5434:
5435:
5436:
5437:
5438:
5439:
5440:
5441:
5442: public static int mpuIMR;
5443:
5444:
5445:
5446:
5447:
5448:
5449: public static int mpuIRR;
5450: public static int mpuDIRR;
5451:
5452:
5453:
5454:
5455:
5456:
5457:
5458:
5459: public static int mpuISR;
5460:
5461:
5462: public static int mpuSFC;
5463: public static int mpuDFC;
5464: public static int mpuCACR;
5465:
5466:
5467:
5468:
5469:
5470: public static int mpuBUSCR;
5471: public static int mpuUSP;
5472: public static int mpuVBR;
5473: public static int mpuCAAR;
5474: public static int mpuMSP;
5475: public static int mpuISP;
5476:
5477:
5478:
5479: public static int mpuPCR;
5480:
5481:
5482:
5483: public static final int MPU_060_REV = 7;
5484:
5485:
5486:
5487: public static long mpuClockTime;
5488: public static long mpuClockLimit;
5489: public static double mpuClockMHz;
5490: public static double mpuCurrentMHz;
5491: public static int mpuCycleCount;
5492: public static long mpuCycleUnit;
5493: public static long mpuModifiedUnit;
5494: public static long dmaCycleUnit;
5495:
5496:
5497:
5498: public static TimerTask mpuTask;
5499:
5500:
5501: public static int mpuBootDevice;
5502: public static int mpuROMBootHandle;
5503: public static int mpuSavedBootDevice;
5504: public static int mpuSavedROMBootHandle;
5505:
5506:
5507: public static boolean mpuIgnoreAddressError;
5508:
5509:
5510: public static int mpuROMWaitCycles;
5511: public static int mpuRAMWaitCycles;
5512: public static boolean mpuCacheOn;
5513: public static final class WaitTime {
5514: public long ram;
5515: public long gvram;
5516: public long tvram;
5517: public long crtc;
5518: public long palet;
5519: public long vicon;
5520: public long dmac;
5521: public long mfp;
5522: public long rtc;
5523: public long prnport;
5524: public long sysport;
5525: public long opm;
5526: public long adpcm;
5527: public long fdc;
5528: public long fdd;
5529: public long hdc;
5530: public long scc;
5531: public long ppi;
5532: public long ioi;
5533: public long sprc;
5534: public long sram;
5535: public long rom;
5536: public long ramlong;
5537: public long romlong;
5538: }
5539: public static final WaitTime mpuNoWaitTime = new WaitTime ();
5540: public static final WaitTime dmaNoWaitTime = new WaitTime ();
5541: public static final WaitTime mpuWaitTime = new WaitTime ();
5542: public static final WaitTime dmaWaitTime = new WaitTime ();
5543: public static boolean busWaitCyclesRequest;
5544: public static boolean busWaitCycles;
5545: public static WaitTime busWaitTime;
5546:
5547:
5548: public static boolean mpuArbFreqOn;
5549: public static int mpuArbFreqMHz;
5550: public static SpinnerNumberModel mpuArbFreqModel;
5551: public static JSpinner mpuArbFreqSpinner;
5552: public static JRadioButtonMenuItem mpuArbFreqRadioButtonMenuItem;
5553:
5554:
5555: public static boolean mpuUtilOn;
5556: public static int mpuUtilRatio;
5557: public static SpinnerNumberModel mpuUtilModel;
5558: public static JSpinner mpuUtilSpinner;
5559: public static JRadioButtonMenuItem mpuUtilRadioButtonMenuItem;
5560:
5561:
5562: public static final int MPU_ADJUSTMENT_INTERVAL = 100;
5563: public static int mpuAdjustmentCounter;
5564: public static long mpuTotalNano;
5565: public static long mpuLastNano;
5566: public static double mpuCoreNano1;
5567: public static double mpuCoreNano2;
5568:
5569:
5570: public static JMenu mpuMenu;
5571: public static JMenuItem mpuResetMenuItem;
5572: public static JMenuItem mpuOpt1ResetMenuItem;
5573: public static JRadioButtonMenuItem mpuClock10MenuItem;
5574: public static JRadioButtonMenuItem mpuClock16MenuItem;
5575: public static JRadioButtonMenuItem mpuClock25MenuItem;
5576: public static JRadioButtonMenuItem mpuClock33MenuItem;
5577: public static JRadioButtonMenuItem mpuClock50MenuItem;
5578: public static JRadioButtonMenuItem mpuClock66MenuItem;
5579: public static JRadioButtonMenuItem mpuClock75MenuItem;
5580: public static JRadioButtonMenuItem mpuClock100MenuItem;
5581:
5582:
5583: public static ActionListener mpuDebugActionListener;
5584: public static ArrayList<AbstractButton> mpuButtonsRunning;
5585: public static ArrayList<AbstractButton> mpuButtonsStopped;
5586: public static ArrayList<JCheckBox> mpuOriIllegalCheckBoxList;
5587: public static ArrayList<JCheckBox> mpuStopOnErrorCheckBoxList;
5588: public static ArrayList<JCheckBox> mpuStopAtStartCheckBoxList;
5589:
5590: public static int mpuAdvanceCount;
5591: public static int mpuStepCount;
5592: public static boolean mpuContinue;
5593: public static int mpuUntilReturnSRS;
5594: public static int mpuUntilReturnRP;
5595: public static int mpuUntilReturnPC0;
5596: public static int mpuUntilReturnSP;
5597:
5598:
5599:
5600:
5601:
5602:
5603:
5604:
5605:
5606:
5607:
5608:
5609:
5610:
5611:
5612:
5613:
5614:
5615:
5616:
5617:
5618:
5619:
5620:
5621:
5622:
5623:
5624:
5625:
5626:
5627:
5628:
5629:
5630:
5631:
5632:
5633:
5634:
5635:
5636:
5637:
5638:
5639:
5640:
5641:
5642:
5643:
5644:
5645:
5646:
5647:
5648:
5649:
5650:
5651:
5652:
5653:
5654:
5655:
5656:
5657:
5658:
5659:
5660:
5661:
5662:
5663:
5664:
5665:
5666:
5667:
5668:
5669:
5670: public static final boolean MPU_SXMENU = false;
5671:
5672:
5673:
5674: public static void mpuInit () {
5675:
5676: mpuIgnoreAddressError = false;
5677:
5678:
5679:
5680: fpuInit ();
5681:
5682: mpuClockTime = 0L;
5683: mpuClockLimit = 0L;
5684: mpuCycleCount = 0;
5685:
5686: mpuTask = null;
5687:
5688: M68kException.m6eSignal = new M68kException ();
5689: M68kException.m6eNumber = 0;
5690: M68kException.m6eAddress = 0;
5691: M68kException.m6eDirection = MPU_WR_WRITE;
5692: M68kException.m6eSize = MPU_SS_BYTE;
5693:
5694: mpuBootDevice = -1;
5695: mpuROMBootHandle = -1;
5696: mpuSavedBootDevice = -1;
5697: mpuSavedROMBootHandle = -1;
5698:
5699:
5700:
5701:
5702:
5703:
5704:
5705:
5706:
5707:
5708:
5709:
5710:
5711:
5712:
5713: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
5714: mpuTotalNano = 0L;
5715: mpuLastNano = System.nanoTime ();
5716: mpuCoreNano1 = mpuCoreNano2 = 0.5 * 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
5717:
5718: mpuButtonsRunning = new ArrayList<AbstractButton> ();
5719: mpuButtonsStopped = new ArrayList<AbstractButton> ();
5720:
5721: mpuOriIllegalCheckBoxList = new ArrayList<JCheckBox> ();
5722: mpuStopOnErrorCheckBoxList = new ArrayList<JCheckBox> ();
5723: mpuStopAtStartCheckBoxList = new ArrayList<JCheckBox> ();
5724:
5725: mpuAdvanceCount = 0;
5726: mpuStepCount = 0;
5727: mpuContinue = false;
5728: mpuUntilReturnSRS = 0;
5729: mpuUntilReturnRP = 0;
5730: mpuUntilReturnPC0 = 0;
5731: mpuUntilReturnSP = 0;
5732:
5733:
5734: mpuDebugActionListener = new ActionListener () {
5735: @Override public void actionPerformed (ActionEvent ae) {
5736: Object source = ae.getSource ();
5737: switch (ae.getActionCommand ()) {
5738: case "Stop":
5739: if (RootPointerList.RTL_ON) {
5740: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
5741: RootPointerList.rtlCurrentUserTaskIsStoppable) {
5742: mpuStop (null);
5743: }
5744: } else {
5745: mpuStop (null);
5746: }
5747: break;
5748: case "Trace":
5749: mpuAdvance (1);
5750: break;
5751: case "Trace 10 times":
5752: mpuAdvance (10);
5753: break;
5754: case "Trace 100 times":
5755: mpuAdvance (100);
5756: break;
5757: case "Step":
5758: mpuStep (1);
5759: break;
5760: case "Step 10 times":
5761: mpuStep (10);
5762: break;
5763: case "Step 100 times":
5764: mpuStep (100);
5765: break;
5766: case "Step until return":
5767: mpuStepUntilReturn ();
5768: break;
5769: case "Run":
5770: mpuStart ();
5771: break;
5772:
5773: case "Consider ORI.B #$00,D0 as an illegal instruction" :
5774: if (DBG_ORI_BYTE_ZERO_D0) {
5775: dbgOriByteZeroD0 = ((JCheckBox) source).isSelected ();
5776: for (JCheckBox checkBox : mpuOriIllegalCheckBoxList) {
5777: if (checkBox.isSelected () != dbgOriByteZeroD0) {
5778: checkBox.setSelected (dbgOriByteZeroD0);
5779: }
5780: }
5781: }
5782: break;
5783: case "Stop on error":
5784: dbgStopOnError = ((JCheckBox) source).isSelected ();
5785: for (JCheckBox checkBox : mpuStopOnErrorCheckBoxList) {
5786: if (checkBox.isSelected () != dbgStopOnError) {
5787: checkBox.setSelected (dbgStopOnError);
5788: }
5789: }
5790: break;
5791: case "Stop at execution start position":
5792: dbgStopAtStart = ((JCheckBox) source).isSelected ();
5793: for (JCheckBox checkBox : mpuStopAtStartCheckBoxList) {
5794: if (checkBox.isSelected () != dbgStopAtStart) {
5795: checkBox.setSelected (dbgStopAtStart);
5796: }
5797: }
5798: break;
5799: }
5800: }
5801: };
5802:
5803: }
5804:
5805:
5806:
5807: public static JCheckBox mpuMakeOriIllegalCheckBox () {
5808: JCheckBox checkBox = Multilingual.mlnToolTipText (
5809: ComponentFactory.createIconCheckBox (
5810: DBG_ORI_BYTE_ZERO_D0 ? dbgOriByteZeroD0 : null,
5811: LnF.LNF_ORI_BYTE_ZERO_D0_IMAGE,
5812: LnF.LNF_ORI_BYTE_ZERO_D0_SELECTED_IMAGE,
5813: "Consider ORI.B #$00,D0 as an illegal instruction", mpuDebugActionListener),
5814: "ja", "ORI.B #$00,D0 を不当命令とみなす");
5815: mpuOriIllegalCheckBoxList.add (checkBox);
5816: return checkBox;
5817: }
5818:
5819:
5820:
5821: public static JCheckBox mpuMakeStopOnErrorCheckBox () {
5822: JCheckBox checkBox = Multilingual.mlnToolTipText (
5823: ComponentFactory.createIconCheckBox (
5824: dbgStopOnError,
5825: LnF.LNF_STOP_ON_ERROR_IMAGE,
5826: LnF.LNF_STOP_ON_ERROR_SELECTED_IMAGE,
5827: "Stop on error", mpuDebugActionListener),
5828: "ja", "エラーで停止する");
5829: mpuStopOnErrorCheckBoxList.add (checkBox);
5830: return checkBox;
5831: }
5832:
5833:
5834:
5835: public static JCheckBox mpuMakeStopAtStartCheckBox () {
5836: JCheckBox checkBox = Multilingual.mlnToolTipText (
5837: ComponentFactory.createIconCheckBox (
5838: dbgStopAtStart,
5839: LnF.LNF_STOP_AT_START_IMAGE,
5840: LnF.LNF_STOP_AT_START_SELECTED_IMAGE,
5841: "Stop at execution start position", mpuDebugActionListener),
5842: "ja", "実行開始位置で停止する");
5843: mpuStopAtStartCheckBoxList.add (checkBox);
5844: return checkBox;
5845: }
5846:
5847:
5848: public static void mpuMakeMenu () {
5849:
5850: ButtonGroup unitGroup = new ButtonGroup ();
5851: ActionListener listener = new ActionListener () {
5852: @Override public void actionPerformed (ActionEvent ae) {
5853: Object source = ae.getSource ();
5854: switch (ae.getActionCommand ()) {
5855: case "Reset":
5856: mpuReset (-1, -1);
5857: break;
5858: case "Hold down OPT.1 and reset":
5859: mpuReset (0, -1);
5860: break;
5861: case "Interrupt":
5862: sysInterrupt ();
5863: break;
5864: case "10MHz":
5865: mpuArbFreqOn = false;
5866: mpuUtilOn = false;
5867: mpuSetCurrentClock (10.0);
5868: break;
5869: case "16.7MHz":
5870: mpuArbFreqOn = false;
5871: mpuUtilOn = false;
5872: mpuSetCurrentClock (50.0 / 3.0);
5873: break;
5874: case "25MHz":
5875: mpuArbFreqOn = false;
5876: mpuUtilOn = false;
5877: mpuSetCurrentClock (25.0);
5878: break;
5879: case "33.3MHz":
5880: mpuArbFreqOn = false;
5881: mpuUtilOn = false;
5882: mpuSetCurrentClock (100.0 / 3.0);
5883: break;
5884: case "50MHz":
5885: mpuArbFreqOn = false;
5886: mpuUtilOn = false;
5887: mpuSetCurrentClock (50.0);
5888: break;
5889: case "66.7MHz":
5890: mpuArbFreqOn = false;
5891: mpuUtilOn = false;
5892: mpuSetCurrentClock (200.0 / 3.0);
5893: break;
5894: case "75MHz":
5895: mpuArbFreqOn = false;
5896: mpuUtilOn = false;
5897: mpuSetCurrentClock (75.0);
5898: break;
5899: case "100MHz":
5900: mpuArbFreqOn = false;
5901: mpuUtilOn = false;
5902: mpuSetCurrentClock (100.0);
5903: break;
5904: case "Arbitrary frequency":
5905: mpuArbFreqOn = true;
5906: mpuUtilOn = false;
5907: mpuSetCurrentClock ((double) mpuArbFreqMHz);
5908: break;
5909: case "Arbitrary load factor":
5910: mpuArbFreqOn = false;
5911: mpuUtilOn = true;
5912: break;
5913: case "FE function instruction":
5914: FEFunction.fpkOn = ((JCheckBoxMenuItem) source).isSelected ();
5915: break;
5916: case "Reject FLOATn.X":
5917: FEFunction.fpkRejectFloatOn = ((JCheckBoxMenuItem) source).isSelected ();
5918: break;
5919: case "Cut FC2 pin":
5920: busRequestCutFC2Pin = ((JCheckBoxMenuItem) source).isSelected ();
5921: break;
5922: case "Wait cycles":
5923: busWaitCyclesRequest = ((JCheckBoxMenuItem) source).isSelected ();
5924: break;
5925: case "Use IPLROM 1.6":
5926: ROM.romIPLROM16On = ((JCheckBoxMenuItem) source).isSelected ();
5927: break;
5928: case "Increase IPLROM to 256KB":
5929: ROM.romIPLROM256KOn = ((JCheckBoxMenuItem) source).isSelected ();
5930: break;
5931:
5932: case "Run / Stop":
5933: if (((JCheckBox) source).isSelected ()) {
5934: mpuStart ();
5935: } else {
5936: if (RootPointerList.RTL_ON) {
5937: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
5938: RootPointerList.rtlCurrentUserTaskIsStoppable) {
5939: mpuStop (null);
5940: }
5941: } else {
5942: mpuStop (null);
5943: }
5944: }
5945: pnlPanel.requestFocusInWindow ();
5946: break;
5947: }
5948: }
5949: };
5950: mpuMenu = ComponentFactory.createMenu (
5951: "MPU", 'M',
5952: mpuResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset", 'R', MNB_MODIFIERS, listener), "ja", "リセット"),
5953: mpuOpt1ResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Hold down OPT.1 and reset", 'O', MNB_MODIFIERS, listener), "ja", "OPT.1 を押しながらリセット"),
5954: Multilingual.mlnText (ComponentFactory.createMenuItem ("Interrupt", listener), "ja", "インタラプト"),
5955: ComponentFactory.createHorizontalSeparator (),
5956: mdlMenu,
5957: ComponentFactory.createHorizontalSeparator (),
5958: mpuClock10MenuItem = ComponentFactory.createRadioButtonMenuItem (
5959: unitGroup,
5960: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 10.0,
5961: "10MHz",
5962: listener),
5963: mpuClock16MenuItem = ComponentFactory.createRadioButtonMenuItem (
5964: unitGroup,
5965: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0 / 3.0,
5966: "16.7MHz",
5967: listener),
5968: mpuClock25MenuItem = ComponentFactory.createRadioButtonMenuItem (
5969: unitGroup,
5970: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 25.0,
5971: "25MHz",
5972: listener),
5973: mpuClock33MenuItem = ComponentFactory.createRadioButtonMenuItem (
5974: unitGroup,
5975: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0 / 3.0,
5976: "33.3MHz",
5977: listener),
5978: mpuClock50MenuItem = ComponentFactory.createRadioButtonMenuItem (
5979: unitGroup,
5980: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0,
5981: "50MHz",
5982: listener),
5983: mpuClock66MenuItem = ComponentFactory.createRadioButtonMenuItem (
5984: unitGroup,
5985: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 200.0 / 3.0,
5986: "66.7MHz",
5987: listener),
5988: mpuClock75MenuItem = ComponentFactory.createRadioButtonMenuItem (
5989: unitGroup,
5990: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 75.0,
5991: "75MHz",
5992: listener),
5993: mpuClock100MenuItem = ComponentFactory.createRadioButtonMenuItem (
5994: unitGroup,
5995: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0,
5996: "100MHz",
5997: listener),
5998: mpuArbFreqRadioButtonMenuItem = Multilingual.mlnText (
5999: ComponentFactory.createRadioButtonMenuItem (
6000: unitGroup,
6001: mpuArbFreqOn,
6002: "Arbitrary frequency",
6003: listener),
6004: "ja", "任意の周波数"),
6005: ComponentFactory.createHorizontalBox (
6006: Box.createHorizontalStrut (20),
6007: mpuArbFreqSpinner = ComponentFactory.createNumberSpinner (
6008: mpuArbFreqModel = new SpinnerNumberModel (mpuArbFreqMHz, 1, 1000, 1),
6009: 4,
6010: new ChangeListener () {
6011: @Override public void stateChanged (ChangeEvent ce) {
6012:
6013: mpuArbFreqMHz = mpuArbFreqModel.getNumber ().intValue ();
6014: if (mpuArbFreqOn) {
6015: mpuSetCurrentClock ((double) mpuArbFreqMHz);
6016: }
6017: }
6018: }
6019: ),
6020: ComponentFactory.createLabel ("MHz"),
6021: Box.createHorizontalGlue ()
6022: ),
6023: mpuUtilRadioButtonMenuItem = Multilingual.mlnText (
6024: ComponentFactory.createRadioButtonMenuItem (
6025: unitGroup,
6026: mpuUtilOn,
6027: "Arbitrary load factor",
6028: listener),
6029: "ja", "任意の負荷率"),
6030: ComponentFactory.createHorizontalBox (
6031: Box.createHorizontalStrut (20),
6032: mpuUtilSpinner = ComponentFactory.createNumberSpinner (
6033: mpuUtilModel = new SpinnerNumberModel (mpuUtilRatio, 1, 100, 1),
6034: 4,
6035: new ChangeListener () {
6036: @Override public void stateChanged (ChangeEvent ce) {
6037:
6038: mpuUtilRatio = mpuUtilModel.getNumber ().intValue ();
6039: }
6040: }
6041: ),
6042: ComponentFactory.createLabel ("%"),
6043: Box.createHorizontalGlue ()
6044: ),
6045: ComponentFactory.createHorizontalSeparator (),
6046:
6047: coproFPUMenu,
6048:
6049: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkOn, "FE function instruction", listener), "ja", "FE ファンクション命令"),
6050: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkRejectFloatOn, "Reject FLOATn.X", listener), "ja", "FLOATn.X を組み込まない"),
6051: ComponentFactory.createHorizontalSeparator (),
6052: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busRequestCutFC2Pin, "Cut FC2 pin", listener), "ja", "FC2 ピンをカットする"),
6053: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busWaitCyclesRequest, "Wait cycles", listener), "ja", "ウェイトサイクル"),
6054: ComponentFactory.createHorizontalSeparator (),
6055: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM16On, "Use IPLROM 1.6", listener), "ja", "IPLROM 1.6 を使う"),
6056: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM256KOn, "Increase IPLROM to 256KB", listener), "ja", "IPLROM を 256KB に増やす")
6057: );
6058: }
6059:
6060:
6061: public static void mpuSetCurrentClock (double clock) {
6062: specifiedClock = clock;
6063: if (currentIsSecond) {
6064: specifiedSecondClock = clock;
6065: } else {
6066: specifiedFirstClock = clock;
6067: }
6068: if (!mpuArbFreqOn && !mpuUtilOn) {
6069: if (specifiedClock == 10.0) {
6070: mpuClock10MenuItem.setSelected (true);
6071: } else if (specifiedClock == 50.0 / 3.0) {
6072: mpuClock16MenuItem.setSelected (true);
6073: } else if (specifiedClock == 25.0) {
6074: mpuClock25MenuItem.setSelected (true);
6075: } else if (specifiedClock == 100.0 / 3.0) {
6076: mpuClock33MenuItem.setSelected (true);
6077: } else if (specifiedClock == 50.0) {
6078: mpuClock50MenuItem.setSelected (true);
6079: } else if (specifiedClock == 200.0 / 3.0) {
6080: mpuClock66MenuItem.setSelected (true);
6081: } else if (specifiedClock == 75.0) {
6082: mpuClock75MenuItem.setSelected (true);
6083: } else if (specifiedClock == 100.0) {
6084: mpuClock100MenuItem.setSelected (true);
6085: }
6086: }
6087: mpuClockMHz = specifiedClock;
6088: mpuSetClockMHz (mpuClockMHz);
6089: }
6090:
6091:
6092:
6093:
6094:
6095:
6096:
6097:
6098:
6099:
6100:
6101: public static void mpuSetClockMHz (double mhz) {
6102: mhz = Math.max (1.0, Math.min (1000.0, mhz));
6103: double lastMHz = mpuCurrentMHz;
6104: mpuCurrentMHz = mhz;
6105: mpuCycleUnit = (long) (((double) TMR_FREQ / 1000000.0) / mhz + 0.5);
6106:
6107: mpuModifiedUnit = (currentMPU == Model.MPU_MC68EC030 ||
6108: currentMPU == Model.MPU_MC68030 ?
6109: (long) (((double) TMR_FREQ * 3.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6110: currentMPU == Model.MPU_MC68LC040 ||
6111: currentMPU == Model.MPU_MC68040 ?
6112: (long) (((double) TMR_FREQ * 2.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6113: mpuCycleUnit);
6114: if (lastMHz != mhz) {
6115: mpuSetWait ();
6116: }
6117: }
6118:
6119:
6120:
6121:
6122:
6123:
6124:
6125:
6126:
6127:
6128:
6129:
6130:
6131:
6132:
6133:
6134:
6135:
6136:
6137:
6138:
6139:
6140:
6141:
6142:
6143:
6144:
6145:
6146:
6147:
6148:
6149:
6150:
6151:
6152:
6153:
6154:
6155:
6156:
6157:
6158:
6159:
6160:
6161:
6162:
6163:
6164:
6165:
6166:
6167:
6168:
6169:
6170:
6171:
6172:
6173:
6174:
6175:
6176:
6177:
6178:
6179:
6180:
6181:
6182:
6183:
6184:
6185:
6186:
6187:
6188:
6189:
6190:
6191:
6192:
6193:
6194:
6195:
6196:
6197:
6198:
6199: public static void mpuSetWait () {
6200:
6201: if (currentMPU <= Model.MPU_MC68010) {
6202: mpuWaitTime.ram = mpuCycleUnit >> 3;
6203: mpuWaitTime.vicon = (long) (mpuCycleUnit * 0.6);
6204: mpuWaitTime.crtc =
6205: mpuWaitTime.prnport =
6206: mpuWaitTime.sysport =
6207: mpuWaitTime.sprc =
6208: mpuWaitTime.sram =
6209: mpuWaitTime.rom = mpuCycleUnit;
6210: mpuWaitTime.gvram = (long) (mpuCycleUnit * 1.1);
6211: mpuWaitTime.rtc =
6212: mpuWaitTime.opm =
6213: mpuWaitTime.adpcm =
6214: mpuWaitTime.fdc =
6215: mpuWaitTime.fdd =
6216: mpuWaitTime.hdc =
6217: mpuWaitTime.ppi =
6218: mpuWaitTime.ioi = (long) (mpuCycleUnit * 1.7);
6219: mpuWaitTime.tvram = mpuCycleUnit * 2;
6220: mpuWaitTime.palet = (long) (mpuCycleUnit * 2.6);
6221: mpuWaitTime.mfp = (long) (mpuCycleUnit * 4.3);
6222: mpuWaitTime.scc = mpuCycleUnit * 6;
6223: mpuWaitTime.dmac = mpuCycleUnit * 15;
6224: mpuWaitTime.ramlong = mpuWaitTime.ram << 1;
6225: mpuWaitTime.romlong = mpuWaitTime.rom << 1;
6226: } else if (currentMPU <= Model.MPU_MC68030) {
6227: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6228: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6229: mpuWaitTime.sram = mpuCycleUnit * 2;
6230: mpuWaitTime.prnport =
6231: mpuWaitTime.sysport = mpuCycleUnit * 4;
6232: mpuWaitTime.gvram =
6233: mpuWaitTime.crtc =
6234: mpuWaitTime.vicon =
6235: mpuWaitTime.sprc = mpuCycleUnit * 6;
6236: mpuWaitTime.tvram = mpuCycleUnit * 7;
6237: mpuWaitTime.palet = mpuCycleUnit * 11;
6238: mpuWaitTime.opm =
6239: mpuWaitTime.adpcm =
6240: mpuWaitTime.fdc =
6241: mpuWaitTime.fdd =
6242: mpuWaitTime.hdc =
6243: mpuWaitTime.ppi =
6244: mpuWaitTime.ioi = mpuCycleUnit * 15;
6245: mpuWaitTime.mfp = mpuCycleUnit * 19;
6246: mpuWaitTime.rtc = mpuCycleUnit * 28;
6247: mpuWaitTime.dmac = mpuCycleUnit * 34;
6248: mpuWaitTime.scc = mpuCycleUnit * 38;
6249: mpuWaitTime.ramlong = mpuWaitTime.ram;
6250: mpuWaitTime.romlong = mpuWaitTime.rom;
6251: } else {
6252: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6253: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6254: mpuWaitTime.sram = mpuCycleUnit * 13;
6255: mpuWaitTime.prnport =
6256: mpuWaitTime.sysport = mpuCycleUnit * 17;
6257: mpuWaitTime.gvram =
6258: mpuWaitTime.crtc =
6259: mpuWaitTime.vicon =
6260: mpuWaitTime.sprc = mpuCycleUnit * 21;
6261: mpuWaitTime.tvram = mpuCycleUnit * 22;
6262: mpuWaitTime.palet = mpuCycleUnit * 33;
6263: mpuWaitTime.opm =
6264: mpuWaitTime.adpcm =
6265: mpuWaitTime.fdc =
6266: mpuWaitTime.fdd =
6267: mpuWaitTime.hdc =
6268: mpuWaitTime.ppi =
6269: mpuWaitTime.ioi = mpuCycleUnit * 37;
6270: mpuWaitTime.mfp = mpuCycleUnit * 47;
6271: mpuWaitTime.dmac = mpuCycleUnit * 73;
6272: mpuWaitTime.rtc = mpuCycleUnit * 77;
6273: mpuWaitTime.scc = mpuCycleUnit * 97;
6274: mpuWaitTime.ramlong = mpuWaitTime.ram;
6275: mpuWaitTime.romlong = mpuWaitTime.rom;
6276: }
6277: if (true) {
6278: mpuNoWaitTime.sram = mpuWaitTime.sram;
6279: mpuNoWaitTime.rom = mpuWaitTime.rom;
6280: mpuNoWaitTime.romlong = mpuWaitTime.romlong;
6281: }
6282:
6283: dmaWaitTime.ram = dmaCycleUnit >> 3;
6284: dmaWaitTime.sram = 0;
6285: dmaWaitTime.rom = 0;
6286: dmaWaitTime.gvram =
6287: dmaWaitTime.crtc =
6288: dmaWaitTime.vicon =
6289: dmaWaitTime.prnport =
6290: dmaWaitTime.sysport =
6291: dmaWaitTime.sprc = dmaCycleUnit;
6292: dmaWaitTime.tvram =
6293: dmaWaitTime.rtc =
6294: dmaWaitTime.opm =
6295: dmaWaitTime.adpcm =
6296: dmaWaitTime.fdc =
6297: dmaWaitTime.fdd =
6298: dmaWaitTime.hdc =
6299: dmaWaitTime.ppi =
6300: dmaWaitTime.ioi = dmaCycleUnit * 2;
6301: dmaWaitTime.palet = dmaCycleUnit * 3;
6302: dmaWaitTime.mfp = dmaCycleUnit * 4;
6303: dmaWaitTime.scc = dmaCycleUnit * 6;
6304: dmaWaitTime.dmac = dmaCycleUnit * 15;
6305: dmaWaitTime.ramlong = dmaWaitTime.ram << 1;
6306: dmaWaitTime.romlong = dmaWaitTime.rom << 1;
6307: }
6308:
6309:
6310:
6311:
6312:
6313: public static void mpuReset (int device, int romHandle) {
6314:
6315: mpuBootDevice = device;
6316: mpuROMBootHandle = romHandle;
6317:
6318:
6319:
6320:
6321:
6322:
6323:
6324:
6325:
6326:
6327:
6328:
6329: if (mpuBootDevice == -1) {
6330: if (mpuSavedBootDevice != -1) {
6331: mpuBootDevice = mpuSavedBootDevice;
6332: mpuROMBootHandle = mpuSavedROMBootHandle;
6333: mpuSavedBootDevice = -1;
6334: mpuSavedROMBootHandle = -1;
6335: }
6336: } else {
6337: if (mpuSavedBootDevice == -1) {
6338: mpuSavedBootDevice = MainMemory.mmrRwz (0x00ed0018);
6339: mpuSavedROMBootHandle = MainMemory.mmrRls (0x00ed000c);
6340: }
6341: }
6342:
6343:
6344: if (mpu010) {
6345: if (specifiedFirstMPU == Model.MPU_MC68000) {
6346: specifiedFirstMPU = Model.MPU_MC68010;
6347: }
6348: if (specifiedSecondMPU == Model.MPU_MC68000) {
6349: specifiedSecondMPU = Model.MPU_MC68010;
6350: }
6351: } else {
6352: if (specifiedFirstMPU == Model.MPU_MC68010) {
6353: specifiedFirstMPU = Model.MPU_MC68000;
6354: }
6355: if (specifiedSecondMPU == Model.MPU_MC68010) {
6356: specifiedSecondMPU = Model.MPU_MC68000;
6357: }
6358: }
6359:
6360:
6361: specifiedIsSecond = false;
6362: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
6363: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
6364:
6365: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
6366: MC68EC030.m30DivZeroVFlag = false;
6367: }
6368:
6369: if (mpuTask != null) {
6370: mpuClockLimit = 0L;
6371: System.out.println (Multilingual.mlnJapanese ?
6372: "MPU を停止します" :
6373: "MPU stops");
6374: mpuTask.cancel ();
6375: mpuTask = null;
6376: }
6377:
6378: tmrTimer.schedule (new TimerTask () {
6379: @Override public void run () {
6380:
6381:
6382:
6383: currentModel = specifiedModel;
6384: currentAccelerator = specifiedAccelerator;
6385: frmUpdateTitle ();
6386:
6387: currentIsSecond = specifiedIsSecond;
6388: currentFirstMPU = specifiedFirstMPU;
6389: currentSecondMPU = specifiedSecondMPU;
6390: currentMPU = specifiedMPU;
6391:
6392: mpuSetCurrentClock (specifiedClock);
6393:
6394: currentCopro0 = specifiedCopro0;
6395: currentCopro1 = specifiedCopro1;
6396: currentCopro2 = specifiedCopro2;
6397: currentOnchipFPU = specifiedOnchipFPU;
6398:
6399:
6400: if (currentMPU < Model.MPU_MC68020) {
6401: if (busHimem68000) {
6402: busRequestExMemoryStart = 0x10000000;
6403: busRequestExMemorySize = busLocalMemorySize;
6404: busRequestExMemoryArray = busLocalMemoryArray;
6405: } else {
6406: busRequestExMemoryStart = 0x10000000;
6407: busRequestExMemorySize = 0 << 20;
6408: busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
6409: }
6410: } else if (currentMPU < Model.MPU_MC68LC040) {
6411: if (busHighMemory060turboOn) {
6412: busRequestExMemoryStart = 0x10000000;
6413: busRequestExMemorySize = busLocalMemorySize;
6414: busRequestExMemoryArray = busLocalMemoryArray;
6415: } else {
6416: busRequestExMemoryStart = 0x01000000;
6417: busRequestExMemorySize = busHighMemorySize;
6418: busRequestExMemoryArray = busHighMemoryArray;
6419: }
6420: } else {
6421: busRequestExMemoryStart = 0x10000000;
6422: busRequestExMemorySize = busLocalMemorySize;
6423: busRequestExMemoryArray = busLocalMemoryArray;
6424: }
6425: busUpdateMemoryMap ();
6426:
6427:
6428: ROM.romReset ();
6429:
6430: RegisterList.drpSetMPU ();
6431:
6432: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
6433: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6434: MC68060.mmuReset ();
6435:
6436:
6437: if (Model.MPU_MC68020 <= currentMPU) {
6438: if ((7 & currentCopro0) == 1) {
6439: fpuMotherboardCoprocessor.epbSetMC68881 ();
6440: } else if ((7 & currentCopro0) == 2) {
6441: fpuMotherboardCoprocessor.epbSetMC68882 ();
6442: } else {
6443: fpuMotherboardCoprocessor.epbSetFullSpec ();
6444: }
6445: if ((8 & currentCopro0) == 0) {
6446: fpuMotherboardCoprocessor.epbSetExtended ();
6447: } else {
6448: fpuMotherboardCoprocessor.epbSetTriple ();
6449: }
6450: }
6451:
6452: if ((7 & currentCopro1) == 1) {
6453: fpuCoproboard1.epbSetMC68881 ();
6454: } else if ((7 & currentCopro1) == 2) {
6455: fpuCoproboard1.epbSetMC68882 ();
6456: } else {
6457: fpuCoproboard1.epbSetFullSpec ();
6458: }
6459: if ((8 & currentCopro1) == 0) {
6460: fpuCoproboard1.epbSetExtended ();
6461: } else {
6462: fpuCoproboard1.epbSetTriple ();
6463: }
6464:
6465: if ((7 & currentCopro2) == 1) {
6466: fpuCoproboard2.epbSetMC68881 ();
6467: } else if ((7 & currentCopro2) == 2) {
6468: fpuCoproboard2.epbSetMC68882 ();
6469: } else {
6470: fpuCoproboard2.epbSetFullSpec ();
6471: }
6472: if ((8 & currentCopro2) == 0) {
6473: fpuCoproboard2.epbSetExtended ();
6474: } else {
6475: fpuCoproboard2.epbSetTriple ();
6476: }
6477:
6478: if (Model.MPU_MC68040 <= currentMPU) {
6479: if ((7 & currentOnchipFPU) == 6) {
6480: fpuOnChipFPU.epbSetMC68060 ();
6481: } else {
6482: fpuOnChipFPU.epbSetFullSpec ();
6483: }
6484: if ((8 & currentOnchipFPU) == 0) {
6485: fpuOnChipFPU.epbSetExtended ();
6486: } else {
6487: fpuOnChipFPU.epbSetTriple ();
6488: }
6489: }
6490:
6491: if (!currentModel.isX68030 ()) {
6492: dmaCycleUnit = TMR_FREQ / 10000000L;
6493: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6494: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6495: mpuROMWaitCycles = 1;
6496: mpuRAMWaitCycles = 0;
6497: } else {
6498: dmaCycleUnit = TMR_FREQ / 12500000L;
6499: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6500: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6501: mpuROMWaitCycles = 0;
6502: mpuRAMWaitCycles = 0;
6503: }
6504:
6505: busWaitCycles = busWaitCyclesRequest;
6506: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
6507:
6508: HD63450.dmaReadCycles = (currentModel.isPRO () ? 6 :
6509: currentModel.isCompact () ? 4 :
6510: 5);
6511: HD63450.dmaWriteCycles = (currentModel.isPRO () ? 6 :
6512: 5);
6513:
6514: if (currentMPU < Model.MPU_MC68020) {
6515:
6516: mpuIgnoreAddressError = false;
6517:
6518: mpuCacheOn = false;
6519:
6520: } else if (currentMPU < Model.MPU_MC68040) {
6521:
6522: mpuIgnoreAddressError = true;
6523: fpuBox = fpuMotherboardCoprocessor;
6524: fpuBox.epbReset ();
6525: fpuFPn = fpuBox.epbFPn;
6526:
6527: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
6528:
6529: } else {
6530:
6531: mpuIgnoreAddressError = true;
6532: fpuBox = fpuOnChipFPU;
6533: fpuBox.epbReset ();
6534: fpuFPn = fpuBox.epbFPn;
6535:
6536: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6537: mpuCacheOn = (mpuCACR & 0x80008000) != 0;
6538:
6539: }
6540:
6541: mpuSetWait ();
6542:
6543:
6544: regSRT1 = regSRT0 = 0;
6545: regSRS = REG_SR_S;
6546: regSRM = 0;
6547: regSRI = REG_SR_I;
6548: regCCR = 0;
6549: Arrays.fill (regRn, 0);
6550:
6551: regRn[15] = MainMemory.mmrRls (0x00ff0000);
6552: regPC = MainMemory.mmrRls (0x00ff0004);
6553:
6554: MainMemory.mmrReset ();
6555:
6556: busReset ();
6557: if (InstructionBreakPoint.IBP_ON) {
6558: InstructionBreakPoint.ibpOp1MemoryMap = InstructionBreakPoint.ibpOp1SuperMap;
6559: InstructionBreakPoint.ibpReset ();
6560: }
6561: if (BranchLog.BLG_ON) {
6562: BranchLog.blgReset ();
6563: }
6564:
6565: mpuIMR = 0;
6566: mpuIRR = 0;
6567: if (MC68901.MFP_DELAYED_INTERRUPT) {
6568: mpuDIRR = 0;
6569: }
6570: mpuISR = 0;
6571:
6572:
6573: mpuStart ();
6574: }
6575: }, TMR_DELAY);
6576:
6577: }
6578:
6579:
6580:
6581: public static void mpuStopAndStart () {
6582: if (mpuTask == null) {
6583: mpuStart ();
6584: } else {
6585: if (RootPointerList.RTL_ON) {
6586: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6587: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6588: mpuStop (null);
6589: }
6590: } else {
6591: mpuStop (null);
6592: }
6593: }
6594: }
6595:
6596:
6597:
6598:
6599:
6600: public static void mpuStart () {
6601: if (mpuTask != null) {
6602: mpuClockLimit = 0L;
6603: System.out.println (Multilingual.mlnJapanese ?
6604: "MPU を停止します" :
6605: "MPU stops");
6606: mpuTask.cancel ();
6607: mpuTask = null;
6608: }
6609:
6610: for (AbstractButton button : mpuButtonsStopped) {
6611: button.setEnabled (false);
6612: }
6613: DisassembleList.ddpStoppedBy = null;
6614: System.out.println (Model.mpuNameOf (currentMPU) + (Multilingual.mlnJapanese ? " を起動します" : " starts up"));
6615: mpuTask = new TimerTask () {
6616: @Override public void run () {
6617: mpuContinue = true;
6618: mpuClockLimit = mpuClockTime + TMR_FREQ * TMR_INTERVAL / 1000;
6619: mpuExecuteCore ();
6620: }
6621: };
6622: tmrTimer.scheduleAtFixedRate (mpuTask, TMR_DELAY, TMR_INTERVAL);
6623:
6624: for (AbstractButton button : mpuButtonsRunning) {
6625: button.setEnabled (true);
6626: }
6627: }
6628:
6629:
6630:
6631: public static void mpuExecuteCore () {
6632:
6633: long nanoStart = System.nanoTime ();
6634:
6635: busSuper (RP5C15.rtcFirst, 0x00e8a000, 0x00e8c000);
6636:
6637:
6638: if (currentMPU < Model.MPU_MC68010) {
6639: MC68000.mpuCore ();
6640: } else if (currentMPU < Model.MPU_MC68020) {
6641: MC68010.mpuCore ();
6642: } else if (currentMPU < Model.MPU_MC68LC040) {
6643: MC68EC030.mpuCore ();
6644: } else {
6645: MC68060.mpuCore ();
6646: }
6647:
6648: if (dbgVisibleMask != 0) {
6649: dbgUpdate ();
6650: }
6651:
6652: long nanoEnd = System.nanoTime ();
6653: mpuTotalNano += nanoEnd - nanoStart;
6654: if (--mpuAdjustmentCounter == 0) {
6655:
6656: final double expectedNano = 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
6657:
6658: double coreNano0 = (double) mpuTotalNano;
6659: mpuTotalNano = 0L;
6660: double coreNanoA = (coreNano0 * 2.0 + mpuCoreNano1 + mpuCoreNano2) * 0.25;
6661: mpuCoreNano2 = mpuCoreNano1;
6662: mpuCoreNano1 = coreNano0;
6663:
6664:
6665:
6666: double actualPercent = Math.max (1.0, 100.0 * coreNanoA / expectedNano);
6667:
6668: double maxPercent = SoundSource.sndPlayOn ? 90.0 : 100.0;
6669:
6670:
6671:
6672:
6673: if (mpuUtilOn) {
6674:
6675: double targetPercent = Math.min (maxPercent, (double) mpuUtilRatio);
6676: mpuSetClockMHz ((1.2 - 0.2 * actualPercent / targetPercent) * mpuCurrentMHz);
6677: } else {
6678: mpuSetClockMHz (Math.min (maxPercent / actualPercent,
6679: 1.2 - 0.2 * mpuCurrentMHz / mpuClockMHz) * mpuCurrentMHz);
6680: }
6681: Indicator.indUpdate (actualPercent);
6682: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
6683: }
6684: }
6685:
6686:
6687:
6688:
6689: public static void mpuStop (String message) {
6690:
6691: mpuAdvanceCount = 0;
6692: mpuStepCount = 0;
6693: mpuContinue = false;
6694: mpuStop1 (message);
6695: }
6696: public static void mpuStop1 (String message) {
6697: if (mpuTask == null) {
6698: return;
6699: }
6700: DisassembleList.ddpStoppedBy = message;
6701: mpuClockLimit = 0L;
6702: System.out.println (Multilingual.mlnJapanese ?
6703: "MPU を停止します" :
6704: "MPU stops");
6705: mpuTask.cancel ();
6706: mpuTask = null;
6707:
6708: if (mpuStepCount != 0 && mpuContinue) {
6709: if (mpuStepCount == -1 || --mpuStepCount != 0) {
6710: mpuStep (mpuStepCount);
6711: return;
6712: }
6713: }
6714: mpuAdvanceCount = 0;
6715: mpuStepCount = 0;
6716: mpuContinue = false;
6717:
6718: for (AbstractButton button : mpuButtonsRunning) {
6719: button.setEnabled (false);
6720: }
6721: tmrTimer.schedule (new TimerTask () {
6722: @Override public void run () {
6723: mpuUpdateWindow ();
6724: }
6725: }, TMR_DELAY);
6726: }
6727:
6728:
6729:
6730:
6731:
6732:
6733: public static void mpuAdvance (int n) {
6734: if (mpuTask != null) {
6735: return;
6736: }
6737: mpuAdvanceCount = n;
6738: DisassembleList.ddpStoppedBy = null;
6739: mpuTask = new TimerTask () {
6740: @Override public void run () {
6741: mpuContinue = true;
6742: do {
6743: mpuClockLimit = mpuClockTime + 1L;
6744: mpuExecuteCore ();
6745: } while (mpuContinue && --mpuAdvanceCount != 0);
6746: mpuClockLimit = 0L;
6747: if (mpuTask != null) {
6748: mpuTask.cancel ();
6749: mpuTask = null;
6750: }
6751: if (mpuStepCount != 0 && mpuContinue) {
6752: if (mpuStepCount == -1 || --mpuStepCount != 0) {
6753: mpuStep (mpuStepCount);
6754: return;
6755: }
6756: }
6757: mpuAdvanceCount = 0;
6758: mpuStepCount = 0;
6759: mpuContinue = false;
6760: mpuUpdateWindow ();
6761: }
6762: };
6763: tmrTimer.schedule (mpuTask, TMR_DELAY);
6764: }
6765:
6766:
6767:
6768:
6769:
6770:
6771: public static void mpuStep (int n) {
6772: if (mpuTask != null) {
6773: return;
6774: }
6775: mpuStepCount = n;
6776: Disassembler.disDisassemble (new StringBuilder (), regPC, regSRS);
6777: if ((Disassembler.disStatus & (Disassembler.DIS_ALWAYS_BRANCH | Disassembler.DIS_SOMETIMES_BRANCH)) != 0) {
6778: if (mpuStepCount == -1 &&
6779: (Disassembler.disOC == 0x4e73 ||
6780: Disassembler.disOC == 0x4e74 ||
6781: Disassembler.disOC == 0x4e75 ||
6782: Disassembler.disOC == 0x4e77) &&
6783: mpuUntilReturnSRS == regSRS &&
6784: (currentMPU < Model.MPU_MC68LC040 ||
6785: mpuUntilReturnRP == (regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP)) &&
6786: mpuUntilReturnPC0 != regPC0 &&
6787: Integer.compareUnsigned (mpuUntilReturnSP, regRn[15]) <= 0) {
6788: mpuAdvanceCount = 0;
6789: mpuStepCount = 0;
6790: mpuContinue = false;
6791: mpuUpdateWindow ();
6792: return;
6793: }
6794: mpuAdvance (1);
6795: } else {
6796: if (InstructionBreakPoint.IBP_ON) {
6797: InstructionBreakPoint.ibpInstant (Disassembler.disPC, DisassembleList.ddpSupervisorMode);
6798: mpuStart ();
6799: }
6800: }
6801: }
6802:
6803:
6804:
6805:
6806:
6807:
6808:
6809:
6810:
6811:
6812:
6813: public static void mpuStepUntilReturn () {
6814: if (mpuTask != null) {
6815: return;
6816: }
6817: mpuUntilReturnSRS = regSRS;
6818: mpuUntilReturnRP = regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP;
6819: mpuUntilReturnPC0 = regPC0;
6820: mpuUntilReturnSP = regRn[15];
6821: mpuStep (-1);
6822: }
6823:
6824:
6825:
6826: public static void mpuUpdateWindow () {
6827: if (dbgVisibleMask != 0) {
6828: if ((dbgVisibleMask & DBG_DDP_VISIBLE_MASK) != 0) {
6829: DisassembleList.ddpBacktraceRecord = -1L;
6830: DisassembleList.ddpUpdate (-1, -1, false);
6831: }
6832: if (BranchLog.BLG_ON) {
6833: if ((dbgVisibleMask & DBG_BLG_VISIBLE_MASK) != 0) {
6834: BranchLog.blgUpdate (BranchLog.BLG_SELECT_NEWEST);
6835: }
6836: }
6837: if (ProgramFlowVisualizer.PFV_ON) {
6838: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
6839: ProgramFlowVisualizer.pfvUpdate ();
6840: }
6841: }
6842: if (RasterBreakPoint.RBP_ON) {
6843: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
6844: RasterBreakPoint.rbpUpdateFrame ();
6845: }
6846: }
6847: if (ScreenModeTest.SMT_ON) {
6848: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
6849: ScreenModeTest.smtUpdateFrame ();
6850: }
6851: }
6852: if (RootPointerList.RTL_ON) {
6853: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
6854: RootPointerList.rtlUpdateFrame ();
6855: }
6856: }
6857: if (SpritePatternViewer.SPV_ON) {
6858: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
6859: SpritePatternViewer.spvUpdateFrame ();
6860: }
6861: }
6862: if (PaletteViewer.PLV_ON) {
6863: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
6864: PaletteViewer.plvUpdateFrame ();
6865: }
6866: }
6867: if (ATCMonitor.ACM_ON) {
6868: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
6869: ATCMonitor.acmUpdateFrame ();
6870: }
6871: }
6872: }
6873:
6874: if (DebugConsole.dgtRequestRegs != 0) {
6875: if ((DebugConsole.dgtRequestRegs & 1) != 0) {
6876: ExpressionEvaluator.ElementType.ETY_COMMAND_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
6877: }
6878: if ((DebugConsole.dgtRequestRegs & 2) != 0) {
6879: ExpressionEvaluator.ElementType.ETY_COMMAND_FLOAT_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
6880: }
6881: if ((DebugConsole.dgtRequestRegs & 4) != 0) {
6882: DebugConsole.dgtPrintPrompt ();
6883: }
6884: DebugConsole.dgtRequestRegs = 0;
6885: }
6886:
6887: for (AbstractButton button : mpuButtonsRunning) {
6888: button.setEnabled (false);
6889: }
6890:
6891: for (AbstractButton button : mpuButtonsStopped) {
6892: button.setEnabled (true);
6893: }
6894: }
6895:
6896:
6897:
6898: public static JButton mpuMakeBreakButton () {
6899: return mpuAddButtonRunning (
6900: Multilingual.mlnToolTipText (
6901: ComponentFactory.createImageButton (
6902: LnF.LNF_BREAK_IMAGE,
6903: LnF.LNF_BREAK_DISABLED_IMAGE,
6904: "Stop", mpuDebugActionListener),
6905: "ja", "停止")
6906: );
6907: }
6908:
6909:
6910:
6911: public static JButton mpuMakeTraceButton () {
6912: return mpuAddButtonStopped (
6913: Multilingual.mlnToolTipText (
6914: ComponentFactory.createImageButton (
6915: LnF.LNF_TRACE_IMAGE,
6916: LnF.LNF_TRACE_DISABLED_IMAGE,
6917: "Trace", mpuDebugActionListener),
6918: "ja", "トレース")
6919: );
6920: }
6921:
6922:
6923:
6924: public static JButton mpuMakeTrace10Button () {
6925: return mpuAddButtonStopped (
6926: Multilingual.mlnToolTipText (
6927: ComponentFactory.createImageButton (
6928: LnF.LNF_TRACE_10_IMAGE,
6929: LnF.LNF_TRACE_10_DISABLED_IMAGE,
6930: "Trace 10 times", mpuDebugActionListener),
6931: "ja", "トレース 10 回")
6932: );
6933: }
6934:
6935:
6936:
6937: public static JButton mpuMakeTrace100Button () {
6938: return mpuAddButtonStopped (
6939: Multilingual.mlnToolTipText (
6940: ComponentFactory.createImageButton (
6941: LnF.LNF_TRACE_100_IMAGE,
6942: LnF.LNF_TRACE_100_DISABLED_IMAGE,
6943: "Trace 100 times", mpuDebugActionListener),
6944: "ja", "トレース 100 回")
6945: );
6946: }
6947:
6948:
6949:
6950: public static JButton mpuMakeStepButton () {
6951: return mpuAddButtonStopped (
6952: Multilingual.mlnToolTipText (
6953: ComponentFactory.createImageButton (
6954: LnF.LNF_STEP_IMAGE,
6955: LnF.LNF_STEP_DISABLED_IMAGE,
6956: "Step", mpuDebugActionListener),
6957: "ja", "ステップ")
6958: );
6959: }
6960:
6961:
6962:
6963: public static JButton mpuMakeStep10Button () {
6964: return mpuAddButtonStopped (
6965: Multilingual.mlnToolTipText (
6966: ComponentFactory.createImageButton (
6967: LnF.LNF_STEP_10_IMAGE,
6968: LnF.LNF_STEP_10_DISABLED_IMAGE,
6969: "Step 10 times", mpuDebugActionListener),
6970: "ja", "ステップ 10 回")
6971: );
6972: }
6973:
6974:
6975:
6976: public static JButton mpuMakeStep100Button () {
6977: return mpuAddButtonStopped (
6978: Multilingual.mlnToolTipText (
6979: ComponentFactory.createImageButton (
6980: LnF.LNF_STEP_100_IMAGE,
6981: LnF.LNF_STEP_100_DISABLED_IMAGE,
6982: "Step 100 times", mpuDebugActionListener),
6983: "ja", "ステップ 100 回")
6984: );
6985: }
6986:
6987:
6988:
6989: public static JButton mpuMakeReturnButton () {
6990: return mpuAddButtonStopped (
6991: Multilingual.mlnToolTipText (
6992: ComponentFactory.createImageButton (
6993: LnF.LNF_STEP_UNTIL_RETURN_IMAGE,
6994: LnF.LNF_STEP_UNTIL_RETURN_DISABLED_IMAGE,
6995: "Step until return", mpuDebugActionListener),
6996: "ja", "ステップアンティルリターン")
6997: );
6998: }
6999:
7000:
7001:
7002: public static JButton mpuMakeRunButton () {
7003: return mpuAddButtonStopped (
7004: Multilingual.mlnToolTipText (
7005: ComponentFactory.createImageButton (
7006: LnF.LNF_RUN_IMAGE,
7007: LnF.LNF_RUN_DISABLED_IMAGE,
7008: "Run", mpuDebugActionListener),
7009: "ja", "実行")
7010: );
7011: }
7012:
7013:
7014:
7015: public static <T extends AbstractButton> T mpuAddButtonRunning (T button) {
7016: button.setEnabled (mpuTask != null);
7017: mpuButtonsRunning.add (button);
7018: return button;
7019: }
7020:
7021:
7022:
7023: public static <T extends AbstractButton> T mpuAddButtonStopped (T button) {
7024: button.setEnabled (mpuTask == null);
7025: mpuButtonsStopped.add (button);
7026: return button;
7027: }
7028:
7029:
7030:
7031:
7032:
7033:
7034:
7035:
7036:
7037:
7038:
7039:
7040:
7041:
7042:
7043:
7044: public static final int EMX_OPCODE_BASE = 0x4e00;
7045: public static final int EMX_OPCODE_HFSBOOT = EMX_OPCODE_BASE + 0x00;
7046: public static final int EMX_OPCODE_HFSINST = EMX_OPCODE_BASE + 0x01;
7047: public static final int EMX_OPCODE_HFSSTR = EMX_OPCODE_BASE + 0x02;
7048: public static final int EMX_OPCODE_HFSINT = EMX_OPCODE_BASE + 0x03;
7049: public static final int EMX_OPCODE_EMXNOP = EMX_OPCODE_BASE + 0x04;
7050: public static final int EMX_OPCODE_EMXWAIT = EMX_OPCODE_BASE + 0x05;
7051:
7052: public static final String[] EMX_MNEMONIC_ARRAY = {
7053: "hfsboot",
7054: "hfsinst",
7055: "hfsstr",
7056: "hfsint",
7057: "emxnop",
7058: "emxwait",
7059: };
7060:
7061:
7062:
7063:
7064: public static void emxNop () {
7065: if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x00007140) {
7066: int head = regRn[9];
7067: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7068:
7069:
7070: emxPatchPCM8A (head, tail);
7071:
7072:
7073: emxCheckRSDRV202 (head, tail);
7074: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000716c) {
7075: int head = regRn[9];
7076: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7077:
7078:
7079: emxPatch060turbosys (head, tail);
7080:
7081:
7082: if (Z8530.SCC_FSX_MOUSE) {
7083: emxCheckFSX (head, tail);
7084: }
7085:
7086:
7087: if (HFS.HFS_USE_TWENTY_ONE) {
7088: emxCheckTwentyOne (head, tail);
7089: }
7090:
7091:
7092: LabeledAddress.lblClear ();
7093: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000972c) {
7094: int head = regRn[8] + 256;
7095:
7096: int tail = MC68060.mmuPeekLong (head - 208, 1);
7097:
7098:
7099: emxCheckBSIO021 (head, tail);
7100:
7101:
7102: emxPatchPCM8A (head, tail);
7103:
7104:
7105: emxCheckTMSIO031 (head, tail);
7106:
7107:
7108: LabeledAddress.lblClear ();
7109:
7110:
7111: if (dbgStopAtStart) {
7112: InstructionBreakPoint.ibpInstant (regRn[12], 0);
7113: }
7114: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000a090) {
7115: int head = regRn[8] + 256;
7116: int tail = MC68060.mmuPeekLongData (regRn[8] + 8, 1);
7117: String name = MC68060.mmuPeekStringZ (head - 60, 1);
7118: if (name.equalsIgnoreCase ("fsx.x")) {
7119:
7120:
7121: if (Z8530.SCC_FSX_MOUSE) {
7122: emxCheckFSX (head, tail);
7123: }
7124: }
7125: if (name.equalsIgnoreCase ("TwentyOne.x")) {
7126:
7127:
7128: if (HFS.HFS_USE_TWENTY_ONE) {
7129: emxCheckTwentyOne (head, tail);
7130: }
7131: }
7132: }
7133: }
7134:
7135: public static final int[] emxPCM8AFFMap = {
7136: 0x00000138, 0x000001f6, 0x00000394, 0x000011ec, 0x0000120a, 0x00001400, 0x00001814, 0x00001870, 0x00001882, 0x0000188a,
7137: 0x00001892, 0x000018a2, 0x000018a8, 0x000018ca, 0x000018d4, 0x000018e0, 0x000018e8, 0x00001908, 0x000019e4, 0x00001afa,
7138: 0x00001b58, 0x00001b7c, 0x00001bac, 0x00001c38, 0x00001ccc, 0x000021f8, 0x00002250, 0x00002258, 0x00002290, 0x000022a6,
7139: 0x000022b0, 0x000022c0, 0x000022c8, 0x000022de, 0x000022ea, 0x000030c8, 0x000030de, 0x000030e6, 0x000030ea, 0x000030f6,
7140: 0x00003112, 0x00003188, 0x0000334c, 0x0000338a, 0x000033a2, 0x000033c4, 0x000033d0, 0x0000341a, 0x00003428, 0x00003496,
7141: 0x000034a6, 0x000034d6, 0x0000fe0e, 0x0000fec8, 0x0000feec, 0x0000ff46, 0x0000ff4e,
7142: };
7143:
7144:
7145:
7146: public static void emxPatchPCM8A (int head, int tail) {
7147: if (head + 0x0000ff60 <= tail &&
7148: MC68060.mmuPeekLongData (head + 0x10f8, 1) == 0x50434d38 &&
7149: MC68060.mmuPeekLongData (head + 0x10fc, 1) == 0x41313032) {
7150: System.out.println (Multilingual.mlnJapanese ?
7151: "PCM8A.X 1.02 があります" :
7152: "PCM8A.X 1.02 exists");
7153: int patched = 0;
7154: int failed = 0;
7155:
7156: for (int offset : emxPCM8AFFMap) {
7157: if (MC68060.mmuPeekByteZeroData (head + offset, 1) == 0xff) {
7158: MC68060.mmuPokeByteData (head + offset, 0x00, 1);
7159: patched++;
7160: } else {
7161: failed++;
7162: }
7163: }
7164: if (patched != 0) {
7165: System.out.printf (Multilingual.mlnJapanese ?
7166: "PCM8A.X 1.02 にパッチをあてました (%d/%d)\n" :
7167: "PCM8A.X 1.02 was patched (%d/%d)\n",
7168: patched, patched + failed);
7169: }
7170: }
7171: }
7172:
7173:
7174:
7175: public static void emxPatch060turbosys (int head, int tail) {
7176:
7177:
7178:
7179:
7180: if (head + 0x00002000 <= tail &&
7181: MC68060.mmuPeekLongData (head + 0x00000ec0, 1) == 0x203c302e &&
7182: MC68060.mmuPeekLongData (head + 0x00000ec4, 1) == 0x3536227c &&
7183: MC68060.mmuPeekLongData (head + 0x00000ec8, 1) == 0x30363054) {
7184: System.out.println (Multilingual.mlnJapanese ?
7185: "060turbo.sys 0.56 があります" :
7186: "060turbo.sys 0.56 exists");
7187:
7188:
7189:
7190: int patched = 0;
7191: int failed = 0;
7192: if (MC68060.mmuPeekLongData (head + 0x000021e6, 1) == 0x08f90004 &&
7193: MC68060.mmuPeekLongData (head + 0x000021ea, 1) == 0x00ed0070) {
7194: MC68060.mmuPokeWordData (head + 0x000021e6, 0x0839, 1);
7195: patched++;
7196: } else {
7197: failed++;
7198: }
7199: System.out.printf (Multilingual.mlnJapanese ?
7200: "060turbo.sys 0.56 にパッチをあてました (%d/%d)\n" :
7201: "060turbo.sys 0.56 was patched (%d/%d)\n",
7202: patched, patched + failed);
7203: }
7204: }
7205:
7206:
7207:
7208: public static void emxCheckFSX (int head, int tail) {
7209: if (Z8530.SCC_FSX_MOUSE) {
7210: if (head + 0x00063200 <= tail &&
7211: "\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))) {
7212: System.out.println (Multilingual.mlnJapanese ?
7213: "FSX.X 3.10 があります" :
7214: "FSX.X 3.10 exists");
7215: Z8530.sccFSXMouseHook = head + 0x04f82a;
7216: Z8530.sccFSXMouseWork = head + 0x063184;
7217: }
7218: }
7219: }
7220:
7221:
7222:
7223:
7224:
7225:
7226: public static void emxCheckRSDRV202 (int head, int tail) {
7227: if (head + 0x000ea6 <= tail &&
7228: MC68060.mmuPeekEquals (head + 0x000e4e, "RS-232C DRIVER for X68000 version 2.02")) {
7229: if (RS232CTerminal.trmRSDRV202Head != head) {
7230: RS232CTerminal.trmRSDRV202Head = head;
7231: int[] patchData = {
7232:
7233:
7234: 0x05f8, 0x000a, 0x000b,
7235:
7236: 0x0600, 0xd040, 0x2048,
7237:
7238: 0x060e, 0x3030, 0x4e90,
7239: 0x0610, 0x0000, 0x2048,
7240:
7241: 0x074e, 0x0821, 0x2041,
7242: 0x0750, 0x0410, 0x3200,
7243: 0x0752, 0x0207, 0x303c,
7244: 0x0754, 0x0102, 0x0823,
7245: 0x0756, 0x0080, 0xe268,
7246: 0x0758, 0x003f, 0x72fe,
7247: 0x075a, 0x001f, 0xd141,
7248: 0x075c, 0x000e, 0x2208,
7249: 0x075e, 0x0006, 0x4e75,
7250:
7251:
7252: 0x0ab0, 0x0040, 0x0400,
7253: 0x0ad2, 0x0040, 0x0400,
7254: 0x0af4, 0x0040, 0x0400,
7255: 0x0b16, 0x0040, 0x0400,
7256: 0x0b38, 0x0040, 0x0400,
7257:
7258:
7259: 0x0cae, 0x0009, 0x000b,
7260: };
7261: int patched = 0;
7262: int failed = 0;
7263: for (int i = 0; i < patchData.length; i += 3) {
7264: int a = head + patchData[i];
7265: int b = patchData[i + 1];
7266: int c = patchData[i + 2];
7267: int d = MC68060.mmuPeekWordZeroData (a, 1);
7268: if (d == b) {
7269: MC68060.mmuPokeWordData (a, c, 1);
7270: patched++;
7271: } else if (d != c) {
7272: failed++;
7273: }
7274: }
7275: System.out.printf ("RSDRV.SYS 2.02 found at %08X and patched (%d/%d)\n", head, patched, patched + failed);
7276: }
7277: }
7278: }
7279:
7280:
7281:
7282:
7283:
7284: public static void emxCheckTMSIO031 (int head, int tail) {
7285: if (head + 0x000fc4 <= tail &&
7286: MC68060.mmuPeekEquals (head + 0x000d1c, "TMSIO version 0.31 Copyright (C) 1990-93 by Miki Hoshino")) {
7287: if (RS232CTerminal.trmTMSIO031Head != head) {
7288: RS232CTerminal.trmTMSIO031Head = head;
7289: System.out.printf ("TMSIO 0.31 found at %08X\n", head);
7290: }
7291: }
7292: }
7293:
7294:
7295:
7296:
7297:
7298: public static void emxCheckBSIO021 (int head, int tail) {
7299: if (head + 0x001c2c <= tail &&
7300: MC68060.mmuPeekEquals (head + 0x001a66, "BSIO version 0.21 Copyright (C) 1994 By BAZU")) {
7301: if (RS232CTerminal.trmBSIO021Head != head) {
7302: RS232CTerminal.trmBSIO021Head = head;
7303: System.out.printf ("BSIO 0.21 found at %08X\n", head);
7304: }
7305: }
7306: }
7307:
7308:
7309:
7310: public static void emxCheckTwentyOne (int head, int tail) {
7311: if (HFS.HFS_USE_TWENTY_ONE &&
7312: head + 64 <= tail) {
7313: if (MainMemory.mmrTwentyOneOptionAddress != 0 ||
7314: MainMemory.mmrHumanVersion <= 0) {
7315: return;
7316: }
7317: int name1 = MC68060.mmuPeekLongData (head + 14, 1);
7318: if (name1 == ('*' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7319: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7320: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '*')) {
7321: MainMemory.mmrTwentyOneOptionAddress = -1;
7322: }
7323: } else if (name1 == ('?' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7324: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7325: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '?') ||
7326: name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | 'E')) {
7327: System.out.println (Multilingual.mlnJapanese ?
7328: "TwentyOne.x があります" :
7329: "TwentyOne.x exists");
7330: MainMemory.mmrTwentyOneOptionAddress = head + 22;
7331: }
7332: }
7333: }
7334: }
7335:
7336:
7337:
7338:
7339:
7340:
7341:
7342:
7343:
7344:
7345:
7346:
7347:
7348:
7349:
7350:
7351:
7352:
7353:
7354:
7355:
7356:
7357:
7358:
7359:
7360:
7361:
7362:
7363:
7364:
7365:
7366:
7367:
7368:
7369:
7370:
7371:
7372:
7373:
7374:
7375:
7376:
7377:
7378:
7379:
7380:
7381:
7382:
7383:
7384:
7385:
7386: public static final boolean IRP_BITREV_REVERSE = false;
7387: public static final boolean IRP_BITREV_SHIFT = false;
7388: public static final boolean IRP_BITREV_TABLE = true;
7389:
7390: public static final boolean IRP_MOVEM_MAINMEMORY = true;
7391: public static final boolean IRP_MOVEM_EXPAND = false;
7392: public static final boolean IRP_MOVEM_LOOP = false;
7393: public static final boolean IRP_MOVEM_SHIFT_LEFT = false;
7394: public static final boolean IRP_MOVEM_SHIFT_RIGHT = true;
7395: public static final boolean IRP_MOVEM_ZEROS = false;
7396:
7397:
7398: public static void irpReset () {
7399:
7400: CRTC.crtReset ();
7401: VideoController.vcnReset ();
7402: HD63450.dmaReset ();
7403: MC68901.mfpReset ();
7404: Keyboard.kbdReset ();
7405: RP5C15.rtcReset ();
7406: PrinterPort.prnReset ();
7407: SoundSource.sndReset ();
7408: OPM.opmReset ();
7409: ADPCM.pcmReset ();
7410: FDC.fdcReset ();
7411: IOInterrupt.ioiReset ();
7412: eb2Reset ();
7413: if (HostCDROM.HCD_ENABLED) {
7414: HostCDROM.hcdReset ();
7415: }
7416: SPC.spcReset ();
7417: Z8530.sccReset ();
7418: RS232CTerminal.trmReset ();
7419: PPI.ppiReset ();
7420: HFS.hfsReset ();
7421: SpriteScreen.sprReset ();
7422:
7423: if (MercuryUnit.MU4_ON) {
7424: MercuryUnit.mu4Reset ();
7425: }
7426: xt3Reset ();
7427: SRAM.smrReset ();
7428: CONDevice.conReset ();
7429: TextCopy.txcReset ();
7430: }
7431:
7432:
7433:
7434:
7435:
7436:
7437:
7438:
7439:
7440:
7441:
7442:
7443:
7444:
7445:
7446:
7447:
7448:
7449:
7450:
7451:
7452:
7453:
7454:
7455:
7456:
7457:
7458:
7459:
7460:
7461:
7462:
7463:
7464:
7465:
7466:
7467:
7468:
7469:
7470:
7471:
7472:
7473:
7474:
7475:
7476:
7477:
7478:
7479:
7480:
7481:
7482:
7483:
7484:
7485:
7486:
7487:
7488:
7489:
7490:
7491:
7492:
7493:
7494:
7495:
7496:
7497:
7498:
7499:
7500:
7501:
7502:
7503:
7504:
7505:
7506:
7507:
7508:
7509:
7510:
7511:
7512:
7513:
7514:
7515:
7516:
7517:
7518:
7519:
7520:
7521:
7522:
7523:
7524:
7525:
7526:
7527:
7528:
7529:
7530:
7531:
7532:
7533:
7534:
7535:
7536:
7537:
7538:
7539:
7540:
7541:
7542:
7543:
7544:
7545:
7546:
7547:
7548:
7549:
7550:
7551:
7552:
7553:
7554:
7555:
7556:
7557:
7558:
7559:
7560:
7561:
7562:
7563:
7564:
7565:
7566:
7567:
7568:
7569:
7570:
7571:
7572:
7573:
7574:
7575:
7576:
7577:
7578:
7579:
7580:
7581:
7582:
7583:
7584:
7585:
7586:
7587:
7588:
7589:
7590:
7591:
7592:
7593:
7594:
7595:
7596:
7597:
7598:
7599:
7600:
7601:
7602:
7603:
7604:
7605:
7606:
7607:
7608:
7609:
7610:
7611:
7612:
7613:
7614:
7615:
7616:
7617:
7618:
7619:
7620:
7621:
7622:
7623:
7624:
7625:
7626:
7627:
7628:
7629:
7630:
7631:
7632:
7633:
7634:
7635:
7636:
7637:
7638:
7639:
7640:
7641:
7642:
7643:
7644:
7645:
7646:
7647:
7648:
7649:
7650:
7651:
7652:
7653:
7654:
7655:
7656:
7657:
7658:
7659:
7660:
7661:
7662:
7663:
7664:
7665:
7666:
7667:
7668:
7669:
7670:
7671:
7672:
7673:
7674:
7675:
7676:
7677:
7678:
7679:
7680:
7681:
7682:
7683:
7684:
7685:
7686:
7687:
7688:
7689:
7690:
7691:
7692:
7693:
7694:
7695:
7696:
7697:
7698:
7699:
7700:
7701:
7702:
7703:
7704:
7705:
7706:
7707:
7708:
7709:
7710:
7711:
7712:
7713:
7714:
7715:
7716:
7717:
7718:
7719:
7720:
7721:
7722:
7723:
7724:
7725:
7726:
7727:
7728:
7729:
7730:
7731:
7732:
7733:
7734:
7735:
7736:
7737:
7738:
7739:
7740:
7741:
7742:
7743:
7744:
7745:
7746:
7747:
7748:
7749:
7750:
7751:
7752:
7753:
7754:
7755:
7756:
7757:
7758:
7759:
7760:
7761:
7762:
7763:
7764:
7765:
7766:
7767:
7768:
7769:
7770:
7771:
7772:
7773:
7774:
7775:
7776:
7777:
7778:
7779:
7780:
7781:
7782:
7783:
7784:
7785:
7786:
7787:
7788:
7789:
7790:
7791:
7792:
7793:
7794:
7795:
7796:
7797:
7798:
7799:
7800:
7801:
7802:
7803:
7804:
7805:
7806:
7807:
7808:
7809:
7810:
7811:
7812:
7813:
7814:
7815:
7816:
7817:
7818:
7819:
7820:
7821:
7822:
7823:
7824:
7825:
7826:
7827:
7828:
7829:
7830:
7831:
7832:
7833:
7834:
7835:
7836:
7837:
7838:
7839:
7840:
7841:
7842:
7843:
7844:
7845:
7846:
7847:
7848:
7849:
7850:
7851:
7852:
7853:
7854:
7855:
7856:
7857:
7858:
7859:
7860:
7861:
7862:
7863:
7864:
7865:
7866:
7867:
7868:
7869:
7870:
7871:
7872:
7873:
7874:
7875:
7876:
7877:
7878:
7879:
7880:
7881:
7882:
7883:
7884:
7885:
7886:
7887:
7888:
7889:
7890:
7891:
7892:
7893:
7894:
7895:
7896:
7897:
7898:
7899:
7900:
7901:
7902:
7903:
7904:
7905:
7906:
7907:
7908:
7909:
7910:
7911:
7912:
7913:
7914:
7915:
7916:
7917:
7918:
7919:
7920:
7921:
7922:
7923:
7924:
7925:
7926:
7927:
7928:
7929:
7930:
7931:
7932:
7933:
7934:
7935:
7936:
7937:
7938:
7939:
7940:
7941:
7942:
7943:
7944:
7945:
7946:
7947:
7948:
7949:
7950:
7951:
7952:
7953:
7954:
7955:
7956:
7957:
7958:
7959:
7960:
7961:
7962:
7963:
7964:
7965:
7966:
7967:
7968:
7969:
7970:
7971:
7972:
7973:
7974:
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: 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);
8018:
8019: public static final boolean EFA_SEPARATE_AR = false;
8020:
8021:
8022:
8023:
8024:
8025:
8026: public static final boolean BUS_SPLIT_UNALIGNED_LONG = false;
8027:
8028:
8029: public static final int BUS_MOTHER_BITS = 24;
8030: public static final int BUS_MOTHER_SIZE = BUS_MOTHER_BITS < 32 ? 1 << BUS_MOTHER_BITS : 0;
8031: public static final int BUS_MOTHER_MASK = BUS_MOTHER_SIZE - 1;
8032:
8033: public static final int BUS_ARRAY_SIZE = BUS_MOTHER_SIZE;
8034:
8035:
8036: public static final int BUS_PAGE_BITS = 12;
8037: public static final int BUS_PAGE_SIZE = 1 << BUS_PAGE_BITS;
8038: public static final int BUS_PAGE_COUNT = 1 << (32 - BUS_PAGE_BITS);
8039:
8040:
8041: public static final int MPU_SS_BYTE = 0;
8042: public static final int MPU_SS_WORD = 1;
8043: public static final int MPU_SS_LONG = 2;
8044:
8045:
8046: public static final int MPU_WR_WRITE = 0;
8047: public static final int MPU_WR_READ = 1;
8048:
8049:
8050: public static final int MPU_US_USER = 0;
8051: public static final int MPU_US_SUPERVISOR = 1;
8052:
8053:
8054: public static final MemoryMappedDevice[] busUserMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8055: public static final MemoryMappedDevice[] busSuperMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8056: public static MemoryMappedDevice[] busMemoryMap;
8057:
8058:
8059: public static boolean busHimem68000;
8060:
8061:
8062: public static final int BUS_HIGH_MEMORY_START = 0x01000000;
8063: public static int busHighMemorySize;
8064: public static byte[] busHighMemoryArray;
8065: public static boolean busHighMemorySaveOn;
8066: public static boolean busHighMemory060turboOn;
8067:
8068:
8069: public static final int BUS_LOCAL_MEMORY_START = 0x10000000;
8070: public static int busLocalMemorySize;
8071: public static byte[] busLocalMemoryArray;
8072: public static boolean busLocalMemorySaveOn;
8073:
8074:
8075: public static final byte[] BUS_DUMMY_MEMORY_ARRAY = new byte[0];
8076: public static int busRequestExMemoryStart;
8077: public static int busRequestExMemorySize;
8078: public static byte[] busRequestExMemoryArray;
8079: public static int busExMemoryStart;
8080: public static int busExMemorySize;
8081: public static byte[] busExMemoryArray;
8082:
8083:
8084: public static boolean busRequestCutFC2Pin;
8085: public static boolean busCutFC2Pin;
8086:
8087:
8088:
8089: public static void busInit () {
8090:
8091:
8092: if (!DataBreakPoint.DBP_ON) {
8093: busMemoryMap = busSuperMap;
8094: }
8095:
8096:
8097: int highMemorySizeMB = Settings.sgsGetInt ("highmemory");
8098: busHighMemorySize = highMemorySizeMB == 16 ? highMemorySizeMB << 20 : 0 << 20;
8099: if (busHighMemorySize == 0) {
8100: System.out.println (Multilingual.mlnJapanese ?
8101: "X68030/Xellent30 のハイメモリはありません" :
8102: "X68030/Xellent30 high memory does not exists");
8103: } else {
8104: System.out.printf (Multilingual.mlnJapanese ?
8105: "X68030/Xellent30 のハイメモリのサイズは %dMB です\n" :
8106: "X68030/Xellent30 high memory size is %dMB\n",
8107: busHighMemorySize >> 20);
8108: }
8109: busHighMemoryArray = new byte[busHighMemorySize];
8110:
8111: busHimem68000 = Settings.sgsGetOnOff ("himem68000");
8112:
8113: busHighMemorySaveOn = Settings.sgsGetOnOff ("highmemorysave");
8114: busHighMemory060turboOn = Settings.sgsGetOnOff ("highmemory060turbo");
8115:
8116: byte[] highMemoryArray = Settings.sgsGetData ("highmemorydata");
8117: if (busHighMemorySize != 0) {
8118: if (highMemoryArray.length != 0) {
8119: System.out.println (Multilingual.mlnJapanese ?
8120: "X68030/Xellent30 のハイメモリのデータを復元します" :
8121: "X68030/Xellent30 high memory data is restored");
8122: System.arraycopy (highMemoryArray, 0, busHighMemoryArray, 0, Math.min (highMemoryArray.length, busHighMemorySize));
8123: } else {
8124: System.out.println (Multilingual.mlnJapanese ?
8125: "X68030/Xellent30 のハイメモリをゼロクリアします" :
8126: "X68030/Xellent30 high memory is zero-cleared");
8127: }
8128: if (highMemoryArray.length < busHighMemorySize) {
8129: Arrays.fill (busHighMemoryArray, highMemoryArray.length, busHighMemorySize, (byte) 0);
8130: }
8131: }
8132:
8133:
8134: int localMemorySizeMB = Settings.sgsGetInt ("localmemory");
8135: busLocalMemorySize = (localMemorySizeMB == 16 ||
8136: localMemorySizeMB == 32 ||
8137: localMemorySizeMB == 64 ||
8138: localMemorySizeMB == 128 ||
8139: localMemorySizeMB == 256 ||
8140: localMemorySizeMB == 384 ||
8141: localMemorySizeMB == 512 ||
8142: localMemorySizeMB == 768 ?
8143: localMemorySizeMB << 20 :
8144: 128 << 20);
8145: if (busLocalMemorySize == 0) {
8146: System.out.println (Multilingual.mlnJapanese ?
8147: "060turbo のハイメモリはありません" :
8148: "060turbo high memory does not exists");
8149: } else {
8150: System.out.printf (Multilingual.mlnJapanese ?
8151: "060turbo のハイメモリのサイズは %dMB です\n" :
8152: "060turbo high memory size is %dMB\n",
8153: busLocalMemorySize >> 20);
8154: }
8155: busLocalMemoryArray = new byte[busLocalMemorySize];
8156:
8157: busLocalMemorySaveOn = Settings.sgsGetOnOff ("localmemorysave");
8158:
8159: byte[] localMemoryArray = Settings.sgsGetData ("localmemorydata");
8160: if (busLocalMemorySize != 0) {
8161: if (localMemoryArray.length != 0) {
8162: System.out.println (Multilingual.mlnJapanese ?
8163: "060turbo のハイメモリのデータを復元します" :
8164: "060turbo high memory data is restored");
8165: System.arraycopy (localMemoryArray, 0, busLocalMemoryArray, 0, Math.min (localMemoryArray.length, busLocalMemorySize));
8166: } else {
8167: System.out.println (Multilingual.mlnJapanese ?
8168: "060turbo のハイメモリをゼロクリアします" :
8169: "060turbo high memory is zero-cleared");
8170: }
8171: if (localMemoryArray.length < busLocalMemorySize) {
8172: Arrays.fill (busLocalMemoryArray, localMemoryArray.length, busLocalMemorySize, (byte) 0);
8173: }
8174: }
8175:
8176:
8177: busExMemoryStart = busRequestExMemoryStart = 0x10000000;
8178: busExMemorySize = busRequestExMemorySize = 0 << 20;
8179: busExMemoryArray = busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
8180:
8181:
8182: busRequestCutFC2Pin = Settings.sgsGetOnOff ("cutfc2pin");
8183: busCutFC2Pin = !busRequestCutFC2Pin;
8184:
8185: busUpdateMemoryMap ();
8186:
8187: }
8188:
8189:
8190:
8191: public static void busTini () {
8192: Settings.sgsPutOnOff ("himem68000", busHimem68000);
8193: Settings.sgsPutInt ("highmemory", busHighMemorySize >>> 20);
8194: Settings.sgsPutOnOff ("highmemorysave", busHighMemorySaveOn);
8195: Settings.sgsPutOnOff ("highmemory060turbo", busHighMemory060turboOn);
8196: Settings.sgsPutData ("highmemorydata", busHighMemorySaveOn ? busHighMemoryArray : new byte[0]);
8197: Settings.sgsPutInt ("localmemory", busLocalMemorySize >>> 20);
8198: Settings.sgsPutOnOff ("localmemorysave", busLocalMemorySaveOn);
8199: Settings.sgsPutData ("localmemorydata", busLocalMemorySaveOn ? busLocalMemoryArray : new byte[0]);
8200: Settings.sgsPutOnOff ("cutfc2pin", busRequestCutFC2Pin);
8201: }
8202:
8203: public static void busUpdateMemoryMap () {
8204: if (busExMemoryStart == busRequestExMemoryStart &&
8205: busExMemorySize == busRequestExMemorySize &&
8206: busExMemoryArray == busRequestExMemoryArray &&
8207: busExMemoryArray.length == busExMemorySize &&
8208: busCutFC2Pin == busRequestCutFC2Pin) {
8209: return;
8210: }
8211:
8212: busExMemoryStart = busRequestExMemoryStart;
8213: busExMemorySize = busRequestExMemorySize;
8214: busExMemoryArray = busRequestExMemoryArray;
8215: if (busExMemoryArray.length != busExMemorySize) {
8216: byte[] newArray = new byte[busExMemorySize];
8217: int copySize = Math.min (busExMemoryArray.length, busExMemorySize);
8218: if (copySize > 0) {
8219: System.arraycopy (busExMemoryArray, 0, newArray, 0, copySize);
8220: }
8221: if (busExMemoryArray == busHighMemoryArray) {
8222: busHighMemoryArray = newArray;
8223: } else if (busExMemoryArray == busLocalMemoryArray) {
8224: busLocalMemoryArray = newArray;
8225: }
8226: busExMemoryArray = newArray;
8227: }
8228:
8229: busCutFC2Pin = busRequestCutFC2Pin;
8230:
8231:
8232:
8233:
8234:
8235:
8236:
8237:
8238:
8239:
8240:
8241:
8242: busSuper (MemoryMappedDevice.MMD_MMR, 0x00000000, 0x00002000);
8243: busUser ( MemoryMappedDevice.MMD_MMR, 0x00002000, 0x00c00000);
8244:
8245:
8246:
8247:
8248:
8249:
8250:
8251:
8252:
8253:
8254:
8255:
8256:
8257:
8258:
8259:
8260:
8261:
8262:
8263:
8264:
8265:
8266:
8267:
8268: busSuper (MemoryMappedDevice.MMD_GE0, 0x00c00000, 0x00c80000);
8269: busSuper (MemoryMappedDevice.MMD_GE1, 0x00c80000, 0x00d00000);
8270: busSuper (MemoryMappedDevice.MMD_GE2, 0x00d00000, 0x00d80000);
8271: busSuper (MemoryMappedDevice.MMD_GE3, 0x00d80000, 0x00e00000);
8272:
8273:
8274:
8275:
8276: busSuper (MemoryMappedDevice.MMD_TXT, 0x00e00000, 0x00e80000);
8277:
8278:
8279:
8280:
8281: busSuper (MemoryMappedDevice.MMD_CRT, 0x00e80000, 0x00e82000);
8282:
8283:
8284:
8285:
8286:
8287: busSuper (MemoryMappedDevice.MMD_VCN, 0x00e82000, 0x00e84000);
8288:
8289:
8290:
8291:
8292: busSuper (MemoryMappedDevice.MMD_DMA, 0x00e84000, 0x00e86000);
8293:
8294:
8295:
8296:
8297: busSuper (MemoryMappedDevice.MMD_SVS, 0x00e86000, 0x00e88000);
8298:
8299:
8300:
8301:
8302: busSuper (MemoryMappedDevice.MMD_MFP, 0x00e88000, 0x00e8a000);
8303:
8304:
8305:
8306:
8307: busSuper (MemoryMappedDevice.MMD_RTC_FIRST, 0x00e8a000, 0x00e8c000);
8308:
8309:
8310:
8311:
8312: busSuper (MemoryMappedDevice.MMD_PRN, 0x00e8c000, 0x00e8e000);
8313:
8314:
8315:
8316:
8317: busSuper (MemoryMappedDevice.MMD_SYS, 0x00e8e000, 0x00e90000);
8318:
8319:
8320:
8321:
8322: busSuper (MemoryMappedDevice.MMD_OPM, 0x00e90000, 0x00e92000);
8323:
8324:
8325:
8326:
8327: busSuper (MemoryMappedDevice.MMD_PCM, 0x00e92000, 0x00e94000);
8328:
8329:
8330:
8331:
8332: busSuper (MemoryMappedDevice.MMD_FDC, 0x00e94000, 0x00e96000);
8333:
8334:
8335:
8336:
8337:
8338: busSuper (MemoryMappedDevice.MMD_HDC, 0x00e96000, 0x00e98000);
8339:
8340:
8341:
8342:
8343: busSuper (MemoryMappedDevice.MMD_SCC, 0x00e98000, 0x00e9a000);
8344:
8345:
8346:
8347:
8348: busSuper (MemoryMappedDevice.MMD_PPI, 0x00e9a000, 0x00e9c000);
8349:
8350:
8351:
8352:
8353: busSuper (MemoryMappedDevice.MMD_IOI, 0x00e9c000, 0x00e9e000);
8354:
8355:
8356:
8357:
8358:
8359:
8360:
8361:
8362:
8363: busSuper (MemoryMappedDevice.MMD_XB1, 0x00e9e000, 0x00ea0000);
8364:
8365:
8366:
8367:
8368:
8369: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ea0000, 0x00eae000);
8370:
8371:
8372:
8373:
8374:
8375:
8376:
8377:
8378:
8379:
8380:
8381:
8382:
8383:
8384:
8385: busSuper (MemoryMappedDevice.MMD_XB2, 0x00eae000, 0x00eb0000);
8386:
8387:
8388:
8389:
8390:
8391:
8392:
8393:
8394: busSuper (MemoryMappedDevice.MMD_SPR, 0x00eb0000, 0x00ec0000);
8395:
8396:
8397:
8398:
8399:
8400:
8401:
8402:
8403:
8404:
8405:
8406:
8407:
8408: busSuper (MemoryMappedDevice.MMD_XB3, 0x00ec0000, 0x00ed0000);
8409:
8410:
8411:
8412:
8413:
8414:
8415: busSuper (MemoryMappedDevice.MMD_SMR, 0x00ed0000, 0x00ed0000 + 16384);
8416: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ed0000 + 16384, 0x00ed0000 + 65536);
8417:
8418:
8419:
8420:
8421:
8422:
8423:
8424:
8425: busSuper (MemoryMappedDevice.MMD_XB4, 0x00ee0000, 0x00f00000);
8426:
8427:
8428:
8429:
8430:
8431:
8432:
8433:
8434:
8435:
8436: busSuper (MemoryMappedDevice.MMD_CG1, 0x00f00000, 0x00f40000);
8437:
8438:
8439:
8440:
8441:
8442:
8443:
8444: busSuper (MemoryMappedDevice.MMD_CG2, 0x00f40000, 0x00fc0000);
8445:
8446:
8447:
8448:
8449:
8450:
8451:
8452:
8453:
8454:
8455:
8456:
8457:
8458:
8459: busSuper (MemoryMappedDevice.MMD_ROM, 0x00fc0000, 0x01000000);
8460:
8461: }
8462:
8463: public static void busReset () {
8464: if (regSRS != 0) {
8465: if (DataBreakPoint.DBP_ON) {
8466: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpSuperMap;
8467: } else {
8468: busMemoryMap = busSuperMap;
8469: }
8470: } else {
8471: if (DataBreakPoint.DBP_ON) {
8472: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpUserMap;
8473: } else {
8474: busMemoryMap = busUserMap;
8475: }
8476: }
8477: }
8478:
8479:
8480:
8481:
8482:
8483: public static void busUser (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8484: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8485: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8486: if (false &&
8487: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8488: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8489: System.out.printf ("ERROR: busUser (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8490: }
8491: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8492: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8493: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8494: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8495: int startPage = blockStartPage + motherStartPage;
8496: int endPage = blockStartPage + motherEndPage;
8497: for (int page = startPage; page < endPage; page++) {
8498: MemoryMappedDevice superMmd = exMemoryStartPage <= page && page < exMemoryEndPage ? MemoryMappedDevice.MMD_XMM : mmd;
8499: busUserMap[page] = busSuperMap[page] = superMmd;
8500: if (InstructionBreakPoint.IBP_ON) {
8501: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8502: InstructionBreakPoint.ibpUserMap[page] = superMmd;
8503: }
8504: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8505: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8506: }
8507: }
8508: if (DataBreakPoint.DBP_ON) {
8509: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8510: DataBreakPoint.dbpUserMap[page] = superMmd;
8511: }
8512: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8513: DataBreakPoint.dbpSuperMap[page] = superMmd;
8514: }
8515: }
8516: }
8517: }
8518: }
8519:
8520:
8521:
8522:
8523:
8524: public static void busSuper (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8525: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8526: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8527: if (false &&
8528: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8529: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8530: System.out.printf ("ERROR: busSuper (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8531: }
8532: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8533: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8534: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8535: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8536: int startPage = blockStartPage + motherStartPage;
8537: int endPage = blockStartPage + motherEndPage;
8538: for (int page = startPage; page < endPage; page++) {
8539: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
8540: MemoryMappedDevice userMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : busCutFC2Pin ? mmd : MemoryMappedDevice.MMD_NUL;
8541: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
8542: busUserMap[page] = userMmd;
8543: busSuperMap[page] = superMmd;
8544: if (InstructionBreakPoint.IBP_ON) {
8545: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8546: InstructionBreakPoint.ibpUserMap[page] = userMmd;
8547: }
8548: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8549: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8550: }
8551: }
8552: if (DataBreakPoint.DBP_ON) {
8553: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8554: DataBreakPoint.dbpUserMap[page] = userMmd;
8555: }
8556: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8557: DataBreakPoint.dbpSuperMap[page] = superMmd;
8558: }
8559: }
8560: }
8561: }
8562: }
8563:
8564:
8565:
8566: public static byte busPbs (int a) {
8567: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a);
8568: }
8569:
8570:
8571:
8572: public static int busPbz (int a) {
8573: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a);
8574: }
8575:
8576:
8577:
8578: public static int busPws (int a) {
8579: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8580: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
8581: } else {
8582: int a1 = a + 1;
8583: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
8584: }
8585: }
8586:
8587:
8588:
8589: public static int busPwse (int a) {
8590: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
8591: }
8592:
8593:
8594:
8595: public static int busPwz (int a) {
8596: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8597: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
8598: } else {
8599: int a1 = a + 1;
8600: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
8601: }
8602: }
8603:
8604:
8605:
8606: public static int busPwze (int a) {
8607: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
8608: }
8609:
8610:
8611:
8612: public static int busPls (int a) {
8613: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8614: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
8615: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8616: int a2 = a + 2;
8617: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a) << 16 | busSuperMap[a2 >>> BUS_PAGE_BITS].mmdPwz (a2);
8618: } else {
8619: int a1 = a + 1;
8620: int a3 = a + 3;
8621: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 24 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPwz (a1) << 8 | busSuperMap[a3 >>> BUS_PAGE_BITS].mmdPbz (a3);
8622: }
8623: }
8624:
8625:
8626:
8627: public static int busPlsf (int a) {
8628: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
8629: }
8630:
8631:
8632:
8633: public static long busPqs (int a) {
8634: return (long) busPls (a) << 32 | busPls (a + 4) & 0xffffffffL;
8635: }
8636:
8637:
8638:
8639: public static int busSearchByte (int start, int end, int c) {
8640: for (int a = start; a < end; a++) {
8641: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) == c) {
8642: return a;
8643: }
8644: }
8645: return -1;
8646: }
8647: public static int busSearchWord (int start, int end, int c) {
8648: for (int a = start; a < end; a += 2) {
8649: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) == c) {
8650: return a;
8651: }
8652: }
8653: return -1;
8654: }
8655: public static int busSearchByteArray (int start, int end, int[] array) {
8656: int l = array.length;
8657: end -= l;
8658: int c = array[0];
8659: a:
8660: for (int a = start; a <= end; a++) {
8661: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) != c) {
8662: continue a;
8663: }
8664: for (int i = 1, b = a + 1; i < l; i++, b++) {
8665: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPbz (b) != array[i]) {
8666: continue a;
8667: }
8668: }
8669: return a;
8670: }
8671: return -1;
8672: }
8673: public static int busSearchWordArray (int start, int end, int[] array) {
8674: int l = array.length;
8675: end -= l;
8676: int c = array[0];
8677: a:
8678: for (int a = start; a <= end; a += 2) {
8679: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) != c) {
8680: continue a;
8681: }
8682: for (int i = 1, b = a + 2; i < l; i++, b += 2) {
8683: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPwz (b) != array[i]) {
8684: continue a;
8685: }
8686: }
8687: return a;
8688: }
8689: return -1;
8690: }
8691:
8692:
8693:
8694:
8695: public static byte busRbs (int a) throws M68kException {
8696: if (DataBreakPoint.DBP_ON) {
8697: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
8698: } else {
8699: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
8700: }
8701: }
8702:
8703:
8704:
8705: public static int busRbz (int a) throws M68kException {
8706: if (DataBreakPoint.DBP_ON) {
8707: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
8708: } else {
8709: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
8710: }
8711: }
8712:
8713:
8714:
8715: public static int busRws (int a) throws M68kException {
8716: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8717: if (DataBreakPoint.DBP_ON) {
8718: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8719: } else {
8720: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8721: }
8722: } else if (mpuIgnoreAddressError) {
8723: int a1 = a + 1;
8724: if (DataBreakPoint.DBP_ON) {
8725: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8726: } else {
8727: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8728: }
8729: } else {
8730: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8731: M68kException.m6eAddress = a;
8732: M68kException.m6eDirection = MPU_WR_READ;
8733: M68kException.m6eSize = MPU_SS_WORD;
8734: throw M68kException.m6eSignal;
8735: }
8736: }
8737:
8738:
8739:
8740:
8741: public static int busRwse (int a) throws M68kException {
8742: if (DataBreakPoint.DBP_ON) {
8743: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8744: } else {
8745: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8746: }
8747: }
8748:
8749:
8750:
8751: public static int busRwz (int a) throws M68kException {
8752: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8753: if (DataBreakPoint.DBP_ON) {
8754: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8755: } else {
8756: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8757: }
8758: } else if (mpuIgnoreAddressError) {
8759: int a1 = a + 1;
8760: if (DataBreakPoint.DBP_ON) {
8761: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8762: } else {
8763: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8764: }
8765: } else {
8766: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8767: M68kException.m6eAddress = a;
8768: M68kException.m6eDirection = MPU_WR_READ;
8769: M68kException.m6eSize = MPU_SS_WORD;
8770: throw M68kException.m6eSignal;
8771: }
8772: }
8773:
8774:
8775:
8776:
8777: public static int busRwze (int a) throws M68kException {
8778: if (DataBreakPoint.DBP_ON) {
8779: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8780: } else {
8781: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8782: }
8783: }
8784:
8785:
8786:
8787: public static int busRls (int a) throws M68kException {
8788: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8789: if (DataBreakPoint.DBP_ON) {
8790: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8791: } else {
8792: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8793: }
8794: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8795: int a2 = a + 2;
8796: if (BUS_SPLIT_UNALIGNED_LONG) {
8797: if (DataBreakPoint.DBP_ON) {
8798: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8799: } else {
8800: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8801: }
8802: } else {
8803: MemoryMappedDevice mmd;
8804: MemoryMappedDevice mmd2;
8805: if (DataBreakPoint.DBP_ON) {
8806: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8807: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8808: } else {
8809: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8810: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8811: }
8812: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
8813: }
8814: } else if (mpuIgnoreAddressError) {
8815: int a1 = a + 1;
8816: int a3 = a + 3;
8817: if (DataBreakPoint.DBP_ON) {
8818: 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);
8819: } else {
8820: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 24 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRwz (a1) << 8 | busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdRbz (a3);
8821: }
8822: } else {
8823: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8824: M68kException.m6eAddress = a;
8825: M68kException.m6eDirection = MPU_WR_READ;
8826: M68kException.m6eSize = MPU_SS_LONG;
8827: throw M68kException.m6eSignal;
8828: }
8829: }
8830:
8831:
8832:
8833:
8834: public static int busRlse (int a) throws M68kException {
8835: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8836: if (DataBreakPoint.DBP_ON) {
8837: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8838: } else {
8839: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8840: }
8841: } else {
8842: int a2 = a + 2;
8843: if (BUS_SPLIT_UNALIGNED_LONG) {
8844: if (DataBreakPoint.DBP_ON) {
8845: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8846: } else {
8847: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8848: }
8849: } else {
8850: MemoryMappedDevice mmd;
8851: MemoryMappedDevice mmd2;
8852: if (DataBreakPoint.DBP_ON) {
8853: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8854: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8855: } else {
8856: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8857: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8858: }
8859: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
8860: }
8861: }
8862: }
8863:
8864:
8865:
8866:
8867: public static int busRlsf (int a) throws M68kException {
8868: if (DataBreakPoint.DBP_ON) {
8869: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8870: } else {
8871: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8872: }
8873: }
8874:
8875:
8876:
8877: public static long busRqs (int a) throws M68kException {
8878: return (long) busRls (a) << 32 | busRls (a + 4) & 0xffffffffL;
8879: }
8880:
8881:
8882:
8883: public static void busWb (int a, int d) throws M68kException {
8884: if (DataBreakPoint.DBP_ON) {
8885: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
8886: } else {
8887: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
8888: }
8889: }
8890:
8891:
8892:
8893: public static void busWw (int a, int d) throws M68kException {
8894: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8895: if (DataBreakPoint.DBP_ON) {
8896: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8897: } else {
8898: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8899: }
8900: } else if (mpuIgnoreAddressError) {
8901: int a1 = a + 1;
8902: if (DataBreakPoint.DBP_ON) {
8903: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
8904: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
8905: } else {
8906: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
8907: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
8908: }
8909: } else {
8910: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8911: M68kException.m6eAddress = a;
8912: M68kException.m6eDirection = MPU_WR_WRITE;
8913: M68kException.m6eSize = MPU_SS_WORD;
8914: throw M68kException.m6eSignal;
8915: }
8916: }
8917:
8918:
8919:
8920:
8921: public static void busWwe (int a, int d) throws M68kException {
8922: if (DataBreakPoint.DBP_ON) {
8923: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8924: } else {
8925: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8926: }
8927: }
8928:
8929:
8930:
8931: public static void busWl (int a, int d) throws M68kException {
8932: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8933: if (DataBreakPoint.DBP_ON) {
8934: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8935: } else {
8936: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8937: }
8938: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8939: int a2 = a + 2;
8940: if (BUS_SPLIT_UNALIGNED_LONG) {
8941: if (DataBreakPoint.DBP_ON) {
8942: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8943: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8944: } else {
8945: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8946: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8947: }
8948: } else {
8949: MemoryMappedDevice mmd;
8950: MemoryMappedDevice mmd2;
8951: if (DataBreakPoint.DBP_ON) {
8952: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8953: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8954: } else {
8955: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8956: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8957: }
8958: if (mmd == mmd2) {
8959: mmd.mmdWl (a, d);
8960: } else {
8961: mmd.mmdWw (a, d >> 16);
8962: mmd2.mmdWw (a2, d);
8963: }
8964: }
8965: } else if (mpuIgnoreAddressError) {
8966: int a1 = a + 1;
8967: int a3 = a + 3;
8968: if (DataBreakPoint.DBP_ON) {
8969: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
8970: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
8971: DataBreakPoint.dbpMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
8972: } else {
8973: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
8974: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
8975: busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
8976: }
8977: } else {
8978: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8979: M68kException.m6eAddress = a;
8980: M68kException.m6eDirection = MPU_WR_WRITE;
8981: M68kException.m6eSize = MPU_SS_LONG;
8982: throw M68kException.m6eSignal;
8983: }
8984: }
8985:
8986:
8987:
8988:
8989: public static void busWlf (int a, int d) throws M68kException {
8990: if (DataBreakPoint.DBP_ON) {
8991: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8992: } else {
8993: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8994: }
8995: }
8996:
8997:
8998:
8999:
9000: public static void busWle (int a, int d) throws M68kException {
9001: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9002: if (DataBreakPoint.DBP_ON) {
9003: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9004: } else {
9005: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9006: }
9007: } else {
9008: int a2 = a + 2;
9009: if (BUS_SPLIT_UNALIGNED_LONG) {
9010: if (DataBreakPoint.DBP_ON) {
9011: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9012: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9013: } else {
9014: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9015: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9016: }
9017: } else {
9018: MemoryMappedDevice mmd;
9019: MemoryMappedDevice mmd2;
9020: if (DataBreakPoint.DBP_ON) {
9021: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9022: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9023: } else {
9024: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9025: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9026: }
9027: if (mmd == mmd2) {
9028: mmd.mmdWl (a, d);
9029: } else {
9030: mmd.mmdWw (a, d >> 16);
9031: mmd2.mmdWw (a2, d);
9032: }
9033: }
9034: }
9035: }
9036:
9037:
9038:
9039: public static void busWq (int a, long d) throws M68kException {
9040: busWl (a, (int) (d >>> 32));
9041: busWl (a + 4, (int) d);
9042: }
9043:
9044:
9045:
9046:
9047:
9048: public static void busRbb (int a, byte[] bb, int o, int l) throws M68kException {
9049: if (false) {
9050: for (int i = 0; i < l; i++) {
9051: int ai = a + i;
9052: if (DataBreakPoint.DBP_ON) {
9053: bb[o + i] = DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9054: } else {
9055: bb[o + i] = busMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9056: }
9057: }
9058: } else {
9059: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9060: while (l > 0) {
9061: MemoryMappedDevice mmd;
9062: if (DataBreakPoint.DBP_ON) {
9063: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9064: } else {
9065: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9066: }
9067: int s = l <= r ? l : r;
9068: l -= s;
9069: if (true) {
9070: for (s -= 16; s >= 0; s -= 16) {
9071: bb[o ] = mmd.mmdRbs (a );
9072: bb[o + 1] = mmd.mmdRbs (a + 1);
9073: bb[o + 2] = mmd.mmdRbs (a + 2);
9074: bb[o + 3] = mmd.mmdRbs (a + 3);
9075: bb[o + 4] = mmd.mmdRbs (a + 4);
9076: bb[o + 5] = mmd.mmdRbs (a + 5);
9077: bb[o + 6] = mmd.mmdRbs (a + 6);
9078: bb[o + 7] = mmd.mmdRbs (a + 7);
9079: bb[o + 8] = mmd.mmdRbs (a + 8);
9080: bb[o + 9] = mmd.mmdRbs (a + 9);
9081: bb[o + 10] = mmd.mmdRbs (a + 10);
9082: bb[o + 11] = mmd.mmdRbs (a + 11);
9083: bb[o + 12] = mmd.mmdRbs (a + 12);
9084: bb[o + 13] = mmd.mmdRbs (a + 13);
9085: bb[o + 14] = mmd.mmdRbs (a + 14);
9086: bb[o + 15] = mmd.mmdRbs (a + 15);
9087: a += 16;
9088: o += 16;
9089: }
9090: s += 16;
9091: }
9092: for (int i = 0; i < s; i++) {
9093: bb[o + i] = mmd.mmdRbs (a + i);
9094: }
9095: a += s;
9096: o += s;
9097: r = BUS_PAGE_SIZE;
9098: }
9099: }
9100: }
9101:
9102:
9103:
9104: public static void busWbb (int a, byte[] bb, int o, int l) throws M68kException {
9105: if (false) {
9106: for (int i = 0; i < l; i++) {
9107: int ai = a + i;
9108: if (DataBreakPoint.DBP_ON) {
9109: DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9110: } else {
9111: busMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9112: }
9113: }
9114: } else {
9115: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9116: while (l > 0) {
9117: MemoryMappedDevice mmd;
9118: if (DataBreakPoint.DBP_ON) {
9119: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9120: } else {
9121: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9122: }
9123: int s = l <= r ? l : r;
9124: l -= s;
9125: if (true) {
9126: for (s -= 16; s >= 0; s -= 16) {
9127: mmd.mmdWb (a , bb[o ]);
9128: mmd.mmdWb (a + 1, bb[o + 1]);
9129: mmd.mmdWb (a + 2, bb[o + 2]);
9130: mmd.mmdWb (a + 3, bb[o + 3]);
9131: mmd.mmdWb (a + 4, bb[o + 4]);
9132: mmd.mmdWb (a + 5, bb[o + 5]);
9133: mmd.mmdWb (a + 6, bb[o + 6]);
9134: mmd.mmdWb (a + 7, bb[o + 7]);
9135: mmd.mmdWb (a + 8, bb[o + 8]);
9136: mmd.mmdWb (a + 9, bb[o + 9]);
9137: mmd.mmdWb (a + 10, bb[o + 10]);
9138: mmd.mmdWb (a + 11, bb[o + 11]);
9139: mmd.mmdWb (a + 12, bb[o + 12]);
9140: mmd.mmdWb (a + 13, bb[o + 13]);
9141: mmd.mmdWb (a + 14, bb[o + 14]);
9142: mmd.mmdWb (a + 15, bb[o + 15]);
9143: a += 16;
9144: o += 16;
9145: }
9146: s += 16;
9147: }
9148: for (int i = 0; i < s; i++) {
9149: mmd.mmdWb (a + i, bb[o + i]);
9150: }
9151: a += s;
9152: o += s;
9153: r = BUS_PAGE_SIZE;
9154: }
9155: }
9156: }
9157:
9158:
9159:
9160: public static void busVb (int a, int d) {
9161: try {
9162: if (DataBreakPoint.DBP_ON) {
9163: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9164: } else {
9165: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9166: }
9167: } catch (M68kException e) {
9168: }
9169: }
9170:
9171:
9172:
9173: public static void busVw (int a, int d) {
9174: try {
9175: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9176: if (DataBreakPoint.DBP_ON) {
9177: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9178: } else {
9179: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9180: }
9181: }
9182: } catch (M68kException e) {
9183: }
9184: }
9185:
9186:
9187:
9188: public static void busVl (int a, int d) {
9189: try {
9190: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9191: if (DataBreakPoint.DBP_ON) {
9192: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9193: } else {
9194: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9195: }
9196: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9197: int a2 = a + 2;
9198: MemoryMappedDevice mmd;
9199: MemoryMappedDevice mmd2;
9200: if (DataBreakPoint.DBP_ON) {
9201: mmd = (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS];
9202: mmd2 = (regSRS != 0 ? busSuperMap : busUserMap)[a2 >>> BUS_PAGE_BITS];
9203: } else {
9204: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9205: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9206: }
9207: if (mmd == mmd2) {
9208: mmd.mmdWl (a, d);
9209: } else {
9210: mmd.mmdWw (a, d >> 16);
9211: mmd2.mmdWw (a2, d);
9212: }
9213: }
9214: } catch (M68kException e) {
9215: }
9216: }
9217:
9218:
9219:
9220:
9221:
9222: public static final int SVS_AREASET = 0x00e86001;
9223:
9224:
9225:
9226:
9227:
9228:
9229:
9230:
9231:
9232: public static void svsInit () {
9233: }
9234:
9235:
9236:
9237:
9238:
9239:
9240:
9241:
9242:
9243:
9244:
9245:
9246:
9247:
9248:
9249:
9250:
9251:
9252:
9253:
9254:
9255:
9256:
9257:
9258:
9259:
9260:
9261:
9262:
9263:
9264:
9265:
9266:
9267:
9268:
9269: public static boolean sysNMIFlag;
9270:
9271:
9272:
9273: public static void sysInit () {
9274: sysNMIFlag = false;
9275: }
9276:
9277:
9278:
9279:
9280:
9281:
9282: public static int sysAcknowledge () {
9283: return M68kException.M6E_LEVEL_7_INTERRUPT_AUTOVECTOR;
9284: }
9285:
9286:
9287:
9288:
9289: public static void sysDone () {
9290: if (sysNMIFlag) {
9291: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9292: }
9293: }
9294:
9295:
9296:
9297: public static void sysInterrupt () {
9298: sysNMIFlag = true;
9299: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9300: }
9301:
9302:
9303:
9304: public static void sysResetNMI () {
9305: sysNMIFlag = false;
9306: }
9307:
9308:
9309:
9310:
9311:
9312:
9313: public static final int EB2_SPC_REQUEST = 0x4000;
9314: public static final int EB2_SPC_VECTOR = 0xf6;
9315:
9316:
9317:
9318: public static int eb2Request;
9319:
9320:
9321:
9322: public static void eb2Reset () {
9323: eb2Request = 0;
9324: }
9325:
9326:
9327:
9328:
9329:
9330: public static void eb2Interrupt (int mask) {
9331: eb2Request |= mask;
9332: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9333: }
9334:
9335:
9336:
9337:
9338:
9339:
9340:
9341: public static int eb2Acknowledge () {
9342: if ((eb2Request & EB2_SPC_REQUEST) != 0) {
9343: eb2Request &= ~EB2_SPC_REQUEST;
9344: return EB2_SPC_VECTOR;
9345: }
9346: return 0;
9347: }
9348:
9349:
9350:
9351:
9352:
9353: public static void eb2Done () {
9354: if (eb2Request != 0) {
9355: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9356: }
9357: }
9358:
9359:
9360:
9361:
9362:
9363:
9364:
9365:
9366:
9367:
9368:
9369:
9370:
9371:
9372:
9373:
9374:
9375:
9376:
9377:
9378:
9379:
9380:
9381:
9382:
9383:
9384:
9385:
9386:
9387:
9388:
9389:
9390:
9391:
9392:
9393:
9394:
9395:
9396:
9397:
9398:
9399:
9400:
9401:
9402:
9403:
9404:
9405:
9406:
9407:
9408:
9409:
9410:
9411:
9412:
9413:
9414:
9415:
9416:
9417:
9418:
9419:
9420:
9421:
9422: public static final int BNK_SIZE = 1024 * 1024 * 32;
9423: public static byte[] bnkMemory;
9424: public static int bnkPageStart;
9425: public static boolean bnkOn;
9426:
9427: public static void bnkInit () {
9428: bnkMemory = new byte[BNK_SIZE];
9429: byte[] array = Settings.sgsGetData ("bankdata");
9430: if (array.length != 0) {
9431: System.arraycopy (array, 0, bnkMemory, 0, Math.min (array.length, BNK_SIZE));
9432: }
9433: bnkPageStart = 0;
9434:
9435: bnkOn = false;
9436: }
9437:
9438: public static void bnkTini () {
9439: Settings.sgsPutData ("bankdata", bnkMemory, 0, BNK_SIZE);
9440: }
9441:
9442:
9443:
9444:
9445:
9446:
9447:
9448: public static ExpressionEvaluator fpuMotherboardCoprocessor;
9449: public static ExpressionEvaluator fpuOnChipFPU;
9450: public static ExpressionEvaluator fpuBox;
9451:
9452:
9453: public static EFPBox fpuCoproboard1;
9454: public static EFPBox fpuCoproboard2;
9455:
9456:
9457: public static EFPBox.EFP[] fpuFPn;
9458:
9459:
9460:
9461: public static final int FPU_FPCR_BSUN = 0b00000000_00000000_10000000_00000000;
9462: public static final int FPU_FPCR_SNAN = 0b00000000_00000000_01000000_00000000;
9463: public static final int FPU_FPCR_OPERR = 0b00000000_00000000_00100000_00000000;
9464: public static final int FPU_FPCR_OVFL = 0b00000000_00000000_00010000_00000000;
9465: public static final int FPU_FPCR_UNFL = 0b00000000_00000000_00001000_00000000;
9466: public static final int FPU_FPCR_DZ = 0b00000000_00000000_00000100_00000000;
9467: public static final int FPU_FPCR_INEX2 = 0b00000000_00000000_00000010_00000000;
9468: public static final int FPU_FPCR_INEX1 = 0b00000000_00000000_00000001_00000000;
9469:
9470:
9471: public static final int FPU_FPCR_PE = 0b00000000_00000000_00000000_00000000;
9472: public static final int FPU_FPCR_PS = 0b00000000_00000000_00000000_01000000;
9473: public static final int FPU_FPCR_PD = 0b00000000_00000000_00000000_10000000;
9474:
9475: public static final int FPU_FPCR_RN = 0b00000000_00000000_00000000_00000000;
9476: public static final int FPU_FPCR_RZ = 0b00000000_00000000_00000000_00010000;
9477: public static final int FPU_FPCR_RM = 0b00000000_00000000_00000000_00100000;
9478: public static final int FPU_FPCR_RP = 0b00000000_00000000_00000000_00110000;
9479:
9480:
9481:
9482: public static final int FPU_FPSR_N = 0b00001000_00000000_00000000_00000000;
9483: public static final int FPU_FPSR_Z = 0b00000100_00000000_00000000_00000000;
9484: public static final int FPU_FPSR_I = 0b00000010_00000000_00000000_00000000;
9485: public static final int FPU_FPSR_NAN = 0b00000001_00000000_00000000_00000000;
9486:
9487: public static final int FPU_FPSR_S = 0b00000000_10000000_00000000_00000000;
9488: public static final int FPU_FPSR_QUOTIENT = 0b00000000_01111111_00000000_00000000;
9489:
9490: public static final int FPU_FPSR_EXC_BSUN = 0b00000000_00000000_10000000_00000000;
9491: public static final int FPU_FPSR_EXC_SNAN = 0b00000000_00000000_01000000_00000000;
9492: public static final int FPU_FPSR_EXC_OPERR = 0b00000000_00000000_00100000_00000000;
9493: public static final int FPU_FPSR_EXC_OVFL = 0b00000000_00000000_00010000_00000000;
9494: public static final int FPU_FPSR_EXC_UNFL = 0b00000000_00000000_00001000_00000000;
9495: public static final int FPU_FPSR_EXC_DZ = 0b00000000_00000000_00000100_00000000;
9496: public static final int FPU_FPSR_EXC_INEX2 = 0b00000000_00000000_00000010_00000000;
9497: public static final int FPU_FPSR_EXC_INEX1 = 0b00000000_00000000_00000001_00000000;
9498:
9499: public static final int FPU_FPSR_AEXC_IOP = 0b00000000_00000000_00000000_10000000;
9500: public static final int FPU_FPSR_AEXC_OVFL = 0b00000000_00000000_00000000_01000000;
9501: public static final int FPU_FPSR_AEXC_UNFL = 0b00000000_00000000_00000000_00100000;
9502: public static final int FPU_FPSR_AEXC_DZ = 0b00000000_00000000_00000000_00010000;
9503: public static final int FPU_FPSR_AEXC_INEX = 0b00000000_00000000_00000000_00001000;
9504:
9505:
9506:
9507:
9508:
9509:
9510:
9511: public static final int[] FPU_FPSR_EXC_TO_AEXC = new int[256];
9512:
9513:
9514:
9515:
9516:
9517:
9518:
9519:
9520:
9521:
9522:
9523:
9524:
9525:
9526:
9527:
9528:
9529:
9530:
9531:
9532:
9533:
9534:
9535:
9536: public static final boolean[] FPU_CCMAP_882 = {
9537:
9538:
9539: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9540: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9541: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9542: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9543: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9544: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9545: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9546: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9547: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9548: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9549: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9550: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9551: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9552: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9553: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9554: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9555:
9556:
9557: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9558: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9559: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9560: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9561: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9562: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9563: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9564: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9565: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9566: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9567: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9568: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9569: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9570: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9571: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9572: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9573:
9574: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9575: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9576: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9577: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9578: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9579: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9580: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9581: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9582: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9583: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9584: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9585: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9586: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9587: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9588: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9589: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9590:
9591: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9592: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9593: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9594: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9595: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9596: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9597: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9598: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9599: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9600: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9601: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9602: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9603: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9604: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9605: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9606: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9607: };
9608:
9609:
9610:
9611:
9612:
9613:
9614:
9615: public static final boolean[] FPU_CCMAP_060 = {
9616:
9617:
9618: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9619: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9620: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9621: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9622: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9623: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9624: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9625: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9626: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9627: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9628: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9629: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9630: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9631: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9632: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9633: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9634:
9635:
9636: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9637: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9638: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9639: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9640: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9641: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9642: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9643: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9644: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9645: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9646: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9647: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9648: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9649: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9650: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9651: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9652:
9653: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9654: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9655: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9656: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9657: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9658: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9659: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9660: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9661: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9662: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9663: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9664: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9665: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9666: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9667: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9668: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9669:
9670: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9671: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9672: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9673: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9674: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9675: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9676: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9677: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9678: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9679: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9680: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9681: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9682: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9683: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9684: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9685: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9686: };
9687:
9688:
9689:
9690:
9691: public static void fpuInit () {
9692: for (int i = 0; i < 256; i++) {
9693: 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) |
9694: ((i << 8 & FPU_FPSR_EXC_OVFL) != 0 ? FPU_FPSR_AEXC_OVFL : 0) |
9695: ((i << 8 & (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2)) == (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2) ? FPU_FPSR_AEXC_UNFL : 0) |
9696: ((i << 8 & FPU_FPSR_EXC_DZ) != 0 ? FPU_FPSR_AEXC_DZ : 0) |
9697: ((i << 8 & (FPU_FPSR_EXC_OVFL | FPU_FPSR_EXC_INEX2 | FPU_FPSR_EXC_INEX1)) != 0 ? FPU_FPSR_AEXC_INEX : 0));
9698: }
9699:
9700: fpuMotherboardCoprocessor = new ExpressionEvaluator ();
9701:
9702: fpuOnChipFPU = new ExpressionEvaluator ();
9703:
9704: fpuBox = currentMPU < Model.MPU_MC68LC040 ? fpuMotherboardCoprocessor : fpuOnChipFPU;
9705:
9706: fpuFPn = fpuBox.epbFPn;
9707:
9708: fpuCoproboard1 = new EFPBox ();
9709: fpuCoproboard2 = new EFPBox ();
9710: }
9711:
9712:
9713:
9714:
9715:
9716:
9717: public static final boolean DBG_ORI_BYTE_ZERO_D0 = true;
9718:
9719: public static boolean dbgHexSelected;
9720: public static int dbgHexValue;
9721: public static int dbgSupervisorMode;
9722: public static JPopupMenu dbgPopupMenu;
9723: public static JMenu dbgPopupIBPMenu;
9724: public static SpinnerNumberModel dbgPopupIBPCurrentModel;
9725: public static int dbgPopupIBPCurrentValue;
9726: public static SpinnerNumberModel dbgPopupIBPThresholdModel;
9727: public static int dbgPopupIBPThresholdValue;
9728: public static JMenuItem dbgPopupIBPClearMenuItem;
9729: public static JMenu dbgPopupHexMenu;
9730: public static JMenuItem dbgPopupDisMenuItem;
9731: public static JMenuItem dbgPopupMemMenuItem;
9732: public static JMenuItem dbgPopupCopyMenuItem;
9733: public static JMenuItem dbgPopupSelectAllMenuItem;
9734: public static JTextArea dbgPopupTextArea;
9735: public static int dbgEventMask;
9736: public static boolean dbgStopOnError;
9737: public static boolean dbgOriByteZeroD0;
9738: public static boolean dbgStopAtStart;
9739:
9740:
9741:
9742: public static final char[] DBG_SPACES = (
9743:
9744:
9745: " ").toCharArray ();
9746:
9747: public static final int DBG_DRP_VISIBLE_MASK = 1;
9748: public static final int DBG_DDP_VISIBLE_MASK = 2;
9749: public static final int DBG_DMP_VISIBLE_MASK = 4;
9750: public static final int DBG_BLG_VISIBLE_MASK = 8;
9751: public static final int DBG_PFV_VISIBLE_MASK = 16;
9752: public static final int DBG_RBP_VISIBLE_MASK = 32;
9753: public static final int DBG_DBP_VISIBLE_MASK = 64;
9754: public static final int DBG_SMT_VISIBLE_MASK = 128;
9755: public static final int DBG_ATW_VISIBLE_MASK = 256;
9756: public static final int DBG_PAA_VISIBLE_MASK = 512;
9757: public static final int DBG_RTL_VISIBLE_MASK = 1024;
9758: public static final int DBG_SPV_VISIBLE_MASK = 2048;
9759: public static final int DBG_PLV_VISIBLE_MASK = 4096;
9760: public static final int DBG_ACM_VISIBLE_MASK = 8192;
9761: public static int dbgVisibleMask;
9762:
9763:
9764:
9765: public static void dbgInit () {
9766: dbgVisibleMask = 0;
9767: dbgHexSelected = false;
9768: dbgHexValue = 0;
9769: dbgSupervisorMode = 1;
9770: dbgPopupMenu = null;
9771: dbgPopupDisMenuItem = null;
9772: dbgPopupMemMenuItem = null;
9773: dbgPopupCopyMenuItem = null;
9774: dbgPopupSelectAllMenuItem = null;
9775: dbgPopupIBPMenu = null;
9776: dbgPopupIBPCurrentModel = null;
9777: dbgPopupIBPCurrentValue = 0;
9778: dbgPopupIBPThresholdModel = null;
9779: dbgPopupIBPThresholdValue = 0;
9780: dbgPopupHexMenu = null;
9781: dbgPopupTextArea = null;
9782: dbgEventMask = 0;
9783: dbgStopOnError = false;
9784: if (DBG_ORI_BYTE_ZERO_D0) {
9785: dbgOriByteZeroD0 = false;
9786: }
9787: dbgStopAtStart = false;
9788: }
9789:
9790:
9791:
9792: public static void dbgMakePopup () {
9793:
9794:
9795: ActionListener popupActionListener = new ActionListener () {
9796: @Override public void actionPerformed (ActionEvent ae) {
9797: switch (ae.getActionCommand ()) {
9798: case "Disassemble":
9799: DisassembleList.ddpBacktraceRecord = -1L;
9800: DisassembleList.ddpOpen (dbgHexValue, dbgSupervisorMode, false);
9801: break;
9802: case "Memory Dump":
9803: MemoryDumpList.dmpOpen (dbgHexValue, dbgSupervisorMode != 0 ? 5 : 1, false);
9804: break;
9805: case "Run to Here":
9806: if (InstructionBreakPoint.IBP_ON) {
9807: if (mpuTask == null) {
9808: InstructionBreakPoint.ibpInstant (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
9809: mpuStart ();
9810: }
9811: }
9812: break;
9813: case "Set Breakpoint":
9814: if (InstructionBreakPoint.IBP_ON) {
9815: InstructionBreakPoint.ibpPut (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode, dbgPopupIBPCurrentValue, dbgPopupIBPThresholdValue, null);
9816: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
9817: }
9818: break;
9819: case "Clear Breakpoint":
9820: if (InstructionBreakPoint.IBP_ON) {
9821: InstructionBreakPoint.ibpRemove (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
9822: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
9823: }
9824: break;
9825: case "Copy":
9826: dbgCopy ();
9827: break;
9828: case "Select All":
9829: dbgSelectAll ();
9830: break;
9831: }
9832: }
9833: };
9834: dbgPopupMenu = ComponentFactory.createPopupMenu (
9835: dbgPopupIBPMenu =
9836: InstructionBreakPoint.IBP_ON ?
9837: ComponentFactory.createMenu (
9838: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
9839: Multilingual.mlnText (ComponentFactory.createMenuItem ("Run to Here", 'R', popupActionListener), "ja", "ここまで実行"),
9840: ComponentFactory.createHorizontalSeparator (),
9841: Multilingual.mlnText (ComponentFactory.createMenuItem ("Set Breakpoint", 'S', popupActionListener), "ja", "ブレークポイントを設定"),
9842: ComponentFactory.createHorizontalBox (
9843: Box.createHorizontalStrut (7),
9844: Box.createHorizontalGlue (),
9845: ComponentFactory.setPreferredSize (
9846: Multilingual.mlnText (ComponentFactory.createLabel ("current"), "ja", "現在値"),
9847: 60, 16),
9848: ComponentFactory.createNumberSpinner (dbgPopupIBPCurrentModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
9849: @Override public void stateChanged (ChangeEvent ce) {
9850: dbgPopupIBPCurrentValue = dbgPopupIBPCurrentModel.getNumber ().intValue ();
9851: }
9852: }),
9853: Box.createHorizontalGlue ()
9854: ),
9855: ComponentFactory.createHorizontalBox (
9856: Box.createHorizontalStrut (7),
9857: Box.createHorizontalGlue (),
9858: ComponentFactory.setPreferredSize (
9859: Multilingual.mlnText (ComponentFactory.createLabel ("threshold"), "ja", "閾値"),
9860: 60, 16),
9861: ComponentFactory.createNumberSpinner (dbgPopupIBPThresholdModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
9862: @Override public void stateChanged (ChangeEvent ce) {
9863: dbgPopupIBPThresholdValue = dbgPopupIBPThresholdModel.getNumber ().intValue ();
9864: }
9865: }),
9866: Box.createHorizontalGlue ()
9867: ),
9868: dbgPopupIBPClearMenuItem =
9869: Multilingual.mlnText (ComponentFactory.createMenuItem ("Clear Breakpoint", 'C', popupActionListener), "ja", "ブレークポイントを消去")
9870: ) :
9871: null,
9872: dbgPopupHexMenu =
9873: ComponentFactory.createMenu (
9874: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
9875: dbgPopupDisMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble", 'D', popupActionListener), "ja", "逆アセンブル"),
9876: dbgPopupMemMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory Dump", 'M', popupActionListener), "ja", "メモリダンプ")
9877: ),
9878: dbgPopupCopyMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Copy", 'C', popupActionListener), "ja", "コピー"),
9879: dbgPopupSelectAllMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Select All", 'A', popupActionListener), "ja", "すべて選択")
9880: );
9881:
9882: }
9883:
9884:
9885:
9886: public static void dbgShowPopup (MouseEvent me, JTextArea textArea, boolean dis) {
9887: dbgEventMask++;
9888: int x = me.getX ();
9889: int y = me.getY ();
9890:
9891: int p = textArea.viewToModel2D (me.getPoint ());
9892: DisassembleList.ddpPopupAddress = -1;
9893: if (dis) {
9894: int i = Arrays.binarySearch (DisassembleList.ddpSplitArray, 1, DisassembleList.ddpItemCount, p + 1);
9895: i = (i >> 31 ^ i) - 1;
9896: DisassembleList.ddpPopupAddress = DisassembleList.ddpAddressArray[i];
9897: }
9898: int start = textArea.getSelectionStart ();
9899: int end = textArea.getSelectionEnd ();
9900: String text = textArea.getText ();
9901: int length = text.length ();
9902: if ((start == end ||
9903: p < start || end <= p) &&
9904: 0 <= p && p < length && isWord (text.charAt (p))) {
9905:
9906: for (start = p; 0 < start && isWord (text.charAt (start - 1)); start--) {
9907: }
9908: for (end = p + 1; end < length && isWord (text.charAt (end)); end++) {
9909: }
9910: textArea.select (start, end);
9911: }
9912: dbgHexSelected = false;
9913: if (start < end) {
9914: textArea.requestFocusInWindow ();
9915:
9916:
9917:
9918:
9919:
9920: dbgHexValue = 0;
9921: int n = 0;
9922: for (int i = start; i < end; i++) {
9923: int t;
9924: if ((t = Character.digit (text.charAt (i), 16)) >= 0) {
9925: dbgHexValue = dbgHexValue << 4 | t;
9926: if (n >= 8 ||
9927: i + 1 >= end || (t = Character.digit (text.charAt (i + 1), 16)) < 0) {
9928: n = 0;
9929: break;
9930: }
9931: dbgHexValue = dbgHexValue << 4 | t;
9932: n += 2;
9933: i++;
9934: } else if (isWord (text.charAt (i))) {
9935: n = 0;
9936: break;
9937: }
9938: }
9939: dbgHexSelected = n > 0;
9940: try {
9941:
9942: Rectangle r = textArea.modelToView2D (start).getBounds ();
9943:
9944: Rectangle s = textArea.modelToView2D (end - 1).getBounds ();
9945: if (r.y == s.y) {
9946:
9947: y = r.y + r.height;
9948: }
9949: } catch (BadLocationException ble) {
9950: }
9951: }
9952:
9953: if (InstructionBreakPoint.IBP_ON) {
9954: if (dis && mpuTask == null && DisassembleList.ddpPopupAddress != -1) {
9955: ComponentFactory.setText (dbgPopupIBPMenu, fmtHex8 (DisassembleList.ddpPopupAddress));
9956: TreeMap<Integer,InstructionBreakPoint.InstructionBreakRecord> pointTable = InstructionBreakPoint.ibpPointTable;
9957: InstructionBreakPoint.InstructionBreakRecord r = pointTable.get (DisassembleList.ddpPopupAddress);
9958: if (r != null) {
9959: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = r.ibrValue));
9960: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = r.ibrThreshold));
9961: dbgPopupIBPClearMenuItem.setEnabled (true);
9962: } else {
9963: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = 0));
9964: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = 0));
9965: dbgPopupIBPClearMenuItem.setEnabled (false);
9966: }
9967: ComponentFactory.setVisible (dbgPopupIBPMenu, true);
9968: } else {
9969: ComponentFactory.setVisible (dbgPopupIBPMenu, false);
9970: }
9971: }
9972:
9973: if (dbgHexSelected) {
9974: ComponentFactory.setText (dbgPopupHexMenu, fmtHex8 (dbgHexValue));
9975: ComponentFactory.setVisible (dbgPopupHexMenu, true);
9976: } else {
9977: ComponentFactory.setVisible (dbgPopupHexMenu, false);
9978: }
9979:
9980: ComponentFactory.setEnabled (dbgPopupCopyMenuItem, clpClipboard != null && start < end);
9981:
9982: ComponentFactory.setEnabled (dbgPopupSelectAllMenuItem, clpClipboard != null);
9983:
9984: dbgPopupTextArea = textArea;
9985: dbgPopupMenu.show (textArea, x, y);
9986: dbgEventMask--;
9987: }
9988:
9989: public static boolean isWord (char c) {
9990: return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '_';
9991: }
9992:
9993:
9994:
9995: public static void dbgCopy () {
9996: clpCopy (dbgPopupTextArea.getSelectedText ());
9997: }
9998:
9999:
10000:
10001: public static void dbgSelectAll () {
10002: if (clpClipboard != null) {
10003:
10004: dbgEventMask++;
10005: dbgPopupTextArea.selectAll ();
10006: dbgPopupTextArea.requestFocusInWindow ();
10007: dbgEventMask--;
10008: }
10009: }
10010:
10011:
10012:
10013:
10014: public static void dbgUpdate () {
10015: if ((dbgVisibleMask & DBG_DRP_VISIBLE_MASK) != 0) {
10016: RegisterList.drpUpdate ();
10017: }
10018: if (ProgramFlowVisualizer.PFV_ON) {
10019: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
10020: if (ProgramFlowVisualizer.pfvTimer == 0) {
10021: ProgramFlowVisualizer.pfvUpdate ();
10022: } else {
10023: ProgramFlowVisualizer.pfvTimer--;
10024: }
10025: }
10026: }
10027: if (RasterBreakPoint.RBP_ON) {
10028: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
10029: if (RasterBreakPoint.rbpTimer == 0) {
10030: RasterBreakPoint.rbpUpdateFrame ();
10031: } else {
10032: RasterBreakPoint.rbpTimer--;
10033: }
10034: }
10035: }
10036: if (ScreenModeTest.SMT_ON) {
10037: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
10038: if (ScreenModeTest.smtTimer == 0) {
10039: ScreenModeTest.smtUpdateFrame ();
10040: } else {
10041: ScreenModeTest.smtTimer--;
10042: }
10043: }
10044: }
10045: if (RootPointerList.RTL_ON) {
10046: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
10047: if (RootPointerList.rtlTimer == 0) {
10048: RootPointerList.rtlTimer = RootPointerList.RTL_INTERVAL - 1;
10049: RootPointerList.rtlUpdateFrame ();
10050: } else {
10051: RootPointerList.rtlTimer--;
10052: }
10053: }
10054: }
10055: if (SpritePatternViewer.SPV_ON) {
10056: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
10057: if (SpritePatternViewer.spvTimer == 0) {
10058: SpritePatternViewer.spvTimer = SpritePatternViewer.SPV_INTERVAL - 1;
10059: SpritePatternViewer.spvUpdateFrame ();
10060: } else {
10061: SpritePatternViewer.spvTimer--;
10062: }
10063: }
10064: }
10065: if (PaletteViewer.PLV_ON) {
10066: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
10067: if (PaletteViewer.plvTimer == 0) {
10068: PaletteViewer.plvTimer = PaletteViewer.PLV_INTERVAL - 1;
10069: PaletteViewer.plvUpdateFrame ();
10070: } else {
10071: PaletteViewer.plvTimer--;
10072: }
10073: }
10074: }
10075: if (ATCMonitor.ACM_ON) {
10076: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
10077: if (ATCMonitor.acmTimer == 0) {
10078: ATCMonitor.acmTimer = ATCMonitor.ACM_INTERVAL - 1;
10079: ATCMonitor.acmUpdateFrame ();
10080: } else {
10081: ATCMonitor.acmTimer--;
10082: }
10083: }
10084: }
10085: }
10086:
10087:
10088:
10089:
10090:
10091:
10092:
10093:
10094:
10095:
10096:
10097:
10098:
10099:
10100:
10101:
10102:
10103:
10104:
10105:
10106:
10107:
10108: public static boolean dbgDoStopOnError () {
10109: if (MainMemory.mmrHumanVersion <= 0) {
10110: return true;
10111: }
10112: if ((regOC & 0xff00) == 0xff00 &&
10113: M68kException.m6eNumber == M68kException.M6E_PRIVILEGE_VIOLATION) {
10114: return false;
10115: }
10116: String message = (
10117: M68kException.m6eNumber < 0 ?
10118: fmtHex8 (new StringBuilder ("breaked").append (" at "), regPC0).toString () :
10119: M68kException.m6eNumber <= M68kException.M6E_ADDRESS_ERROR ?
10120: fmtHex8 (fmtHex8 (new StringBuilder ("ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10121: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10122: .append (" at "), regPC0).toString () :
10123: fmtHex8 (new StringBuilder (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10124: .append (" at "), regPC0).toString ()
10125: );
10126: System.out.println (message);
10127: if (!(M68kException.m6eNumber == M68kException.M6E_ACCESS_FAULT &&
10128: 0x0000e100 <= regPC0 && regPC0 < 0x0000e500)) {
10129: mpuStop (message);
10130: return true;
10131: }
10132: return false;
10133: }
10134:
10135:
10136:
10137: public static void dbgDoubleBusFault () {
10138: String message =
10139: fmtHex8 (fmtHex8 (new StringBuilder ("FATAL ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10140: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10141: .append (" at "), regPC0).toString ();
10142: System.out.println (message);
10143: mpuStop (message);
10144: }
10145:
10146:
10147:
10148:
10149:
10150:
10151: public static final HashMap<String,byte[]> rscResourceCache = new HashMap<String,byte[]> ();
10152:
10153:
10154:
10155:
10156:
10157:
10158: public static byte[] rscGetResource (String name, int... sizes) {
10159: byte[] array = rscResourceCache.get (name);
10160: if (array != null) {
10161: return array;
10162: }
10163: array = new byte[1024 * 64];
10164: int size = 0;
10165: try (BufferedInputStream bis = new BufferedInputStream (XEiJ.class.getResourceAsStream ("../data/" + name))) {
10166: for (;;) {
10167: if (size == array.length) {
10168: byte[] newArray = new byte[array.length * 2];
10169: System.arraycopy (array, 0, newArray, 0, size);
10170: array = newArray;
10171: }
10172: int step = bis.read (array, size, array.length - size);
10173: if (step == -1) {
10174: break;
10175: }
10176: size += step;
10177: }
10178: if (size < array.length) {
10179: byte[] newArray = new byte[size];
10180: System.arraycopy (array, 0, newArray, 0, size);
10181: array = newArray;
10182: }
10183: boolean fit = sizes.length == 0;
10184: if (!fit) {
10185: for (int i = 0; i < sizes.length; i++) {
10186: if (size == sizes[i]) {
10187: fit = true;
10188: break;
10189: }
10190: }
10191: }
10192: if (fit) {
10193: System.out.println (Multilingual.mlnJapanese ?
10194: name + " を読み込みました" :
10195: name + " was read");
10196: rscResourceCache.put (name, array);
10197: return array;
10198: }
10199: System.out.println (Multilingual.mlnJapanese ?
10200: name + " のサイズが違います" :
10201: name + " has wrong size");
10202: return null;
10203: } catch (IOException ioe) {
10204: }
10205:
10206: System.out.println (Multilingual.mlnJapanese ?
10207: name + " を読み込めません" :
10208: name + " cannot be read");
10209: return null;
10210: }
10211:
10212:
10213:
10214: public static String rscGetResourceText (String name) {
10215: return rscGetResourceText (name, "UTF-8");
10216: }
10217: public static String rscGetResourceText (String name, String charset) {
10218: byte[] array = rscGetResource (name);
10219: if (name != null) {
10220: try {
10221: return new String (array, charset);
10222: } catch (UnsupportedEncodingException uee) {
10223: }
10224: }
10225: return "";
10226: }
10227:
10228: public static final Pattern RSC_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10229: public static String rscLastFileName = null;
10230:
10231:
10232:
10233:
10234:
10235:
10236: public static byte[] rscGetFile (String names, int... sizes) {
10237: for (String name : names.split (",")) {
10238: name = name.trim ();
10239: if (name.length () == 0 || name.equalsIgnoreCase ("none")) {
10240: continue;
10241: }
10242: String[] zipSplittedName = RSC_ZIP_SEPARATOR.split (name, 2);
10243: InputStream is = null;
10244: if (zipSplittedName.length < 2) {
10245: File file = new File (name);
10246: if (file.isFile ()) {
10247: try {
10248: is = new FileInputStream (file);
10249: } catch (IOException ioe) {
10250: }
10251: } else {
10252: System.out.println (Multilingual.mlnJapanese ?
10253: name + " がありません" :
10254: name + " does not exist");
10255: continue;
10256: }
10257: } else {
10258: String zipName = zipSplittedName[0];
10259: String entryName = zipSplittedName[1];
10260: if (new File (zipName).isFile ()) {
10261: try {
10262: ZipFile zipFile = new ZipFile (zipName);
10263: ZipEntry zipEntry = zipFile.getEntry (entryName);
10264: if (zipEntry != null) {
10265: is = zipFile.getInputStream (zipEntry);
10266: } else {
10267: System.out.println (Multilingual.mlnJapanese ?
10268: zipName + " に " + zipEntry + " がありません" :
10269: zipName + " does not include " + zipEntry);
10270: }
10271: } catch (IOException ioe) {
10272: }
10273: } else {
10274: System.out.println (Multilingual.mlnJapanese ?
10275: zipName + " がありません" :
10276: zipName + " does not exist");
10277: continue;
10278: }
10279: }
10280: if (is != null) {
10281: try {
10282: is = new BufferedInputStream (is);
10283: if (name.toLowerCase ().endsWith (".gz")) {
10284: is = new GZIPInputStream (is);
10285: }
10286: byte[] array = new byte[1024 * 64];
10287: int size = 0;
10288: for (;;) {
10289: if (size == array.length) {
10290: byte[] newArray = new byte[array.length * 2];
10291: System.arraycopy (array, 0, newArray, 0, size);
10292: array = newArray;
10293: }
10294: int step = is.read (array, size, array.length - size);
10295: if (step == -1) {
10296: break;
10297: }
10298: size += step;
10299: }
10300: is.close ();
10301: is = null;
10302: if (size < array.length) {
10303: byte[] newArray = new byte[size];
10304: System.arraycopy (array, 0, newArray, 0, size);
10305: array = newArray;
10306: }
10307: boolean fit = sizes.length == 0;
10308: if (!fit) {
10309: for (int i = 0; i < sizes.length; i++) {
10310: if (size == sizes[i]) {
10311: fit = true;
10312: break;
10313: }
10314: }
10315: }
10316: if (fit) {
10317: System.out.println (Multilingual.mlnJapanese ?
10318: name + " を読み込みました" :
10319: name + " was read");
10320: rscLastFileName = name;
10321: return array;
10322: }
10323: System.out.println (Multilingual.mlnJapanese ?
10324: name + " のサイズが違います" :
10325: name + " has wrong size");
10326: continue;
10327: } catch (IOException ioe) {
10328: }
10329: if (is != null) {
10330: try {
10331: is.close ();
10332: is = null;
10333: } catch (IOException ioe) {
10334: }
10335: }
10336: }
10337: System.out.println (Multilingual.mlnJapanese ?
10338: name + " を読み込めません" :
10339: name + " cannot be read");
10340: }
10341:
10342:
10343:
10344: return null;
10345: }
10346:
10347:
10348:
10349:
10350: public static String rscGetTextFile (String name) {
10351: return rscGetTextFile (name, "UTF-8");
10352: }
10353: public static String rscGetTextFile (String name, String charset) {
10354: byte[] array = rscGetFile (name);
10355: if (array != null) {
10356: try {
10357: return new String (array, charset);
10358: } catch (UnsupportedEncodingException uee) {
10359: }
10360: }
10361: return "";
10362: }
10363:
10364:
10365:
10366: public static final int RSC_A_MASK = 1;
10367: public static final int RSC_R_MASK = 2;
10368: public static final int RSC_I_MASK = 4;
10369: public static final String RSC_A_EN = "Abort";
10370: public static final String RSC_R_EN = "Retry";
10371: public static final String RSC_I_EN = "Ignore";
10372: public static final String RSC_A_JA = "中止";
10373: public static final String RSC_R_JA = "再実行";
10374: public static final String RSC_I_JA = "無視";
10375: public static final String[][] RSC_EN_OPTIONS = {
10376: { RSC_A_EN },
10377: { RSC_A_EN },
10378: { RSC_R_EN },
10379: { RSC_A_EN, RSC_R_EN },
10380: { RSC_I_EN },
10381: { RSC_A_EN, RSC_I_EN },
10382: { RSC_R_EN, RSC_I_EN },
10383: { RSC_A_EN, RSC_R_EN, RSC_I_EN },
10384: };
10385: public static final String[][] RSC_JA_OPTIONS = {
10386: { RSC_A_JA },
10387: { RSC_A_JA },
10388: { RSC_R_JA },
10389: { RSC_A_JA, RSC_R_JA },
10390: { RSC_I_JA },
10391: { RSC_A_JA, RSC_I_JA },
10392: { RSC_R_JA, RSC_I_JA },
10393: { RSC_A_JA, RSC_R_JA, RSC_I_JA },
10394: };
10395: public static int rscShowError (String message, int mask) {
10396: System.out.println (message);
10397: mask &= RSC_A_MASK | RSC_R_MASK | RSC_I_MASK;
10398: if (mask == 0) {
10399: mask = RSC_A_MASK;
10400: }
10401: String[] options = (Multilingual.mlnJapanese ? RSC_JA_OPTIONS : RSC_EN_OPTIONS)[mask];
10402: int def = Integer.numberOfTrailingZeros (mask);
10403: pnlExitFullScreen (true);
10404: int bit = JOptionPane.showOptionDialog (
10405: null,
10406: message,
10407: Multilingual.mlnJapanese ? "ファイル操作エラー" : "File operation error",
10408: JOptionPane.YES_NO_CANCEL_OPTION,
10409: JOptionPane.ERROR_MESSAGE,
10410: null,
10411: options,
10412: options[def]);
10413: if (bit == JOptionPane.CLOSED_OPTION) {
10414: bit = def;
10415: }
10416: return 1 << bit;
10417: }
10418:
10419:
10420:
10421:
10422:
10423:
10424: public static boolean rscPutTextFile (String name, String string) {
10425: return rscPutTextFile (name, string, "UTF-8");
10426: }
10427: public static boolean rscPutTextFile (String name, ArrayList<String> strings) {
10428: return rscPutTextFile (name, strings, "UTF-8");
10429: }
10430: public static boolean rscPutTextFile (String name, String string, String charset) {
10431: ArrayList<String> strings = new ArrayList<String> ();
10432: strings.add (string);
10433: return rscPutTextFile (name, strings, charset);
10434: }
10435: public static boolean rscPutTextFile (String name, ArrayList<String> strings, String charset) {
10436: String nameTmp = name + ".tmp";
10437: String nameBak = name + ".bak";
10438: File file = new File (name);
10439: File fileTmp = new File (nameTmp);
10440: File fileBak = new File (nameBak);
10441:
10442: File parentDirectory = file.getParentFile ();
10443: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10444: if (!parentDirectory.mkdirs ()) {
10445: System.out.println (parentDirectory.getPath () + (Multilingual.mlnJapanese ? " を作れません" : " cannot be created"));
10446: return false;
10447: }
10448: }
10449:
10450: if (fileTmp.exists ()) {
10451: if (!fileTmp.delete ()) {
10452: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10453: return false;
10454: }
10455: }
10456:
10457: try (BufferedWriter bw = new BufferedWriter (new FileWriter (nameTmp, Charset.forName (charset)))) {
10458: for (String string : strings) {
10459: bw.write (string);
10460: }
10461: } catch (IOException ioe) {
10462: ioe.printStackTrace ();
10463: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " に書き出せません" : " cannot be written"));
10464: return false;
10465: }
10466:
10467: boolean fileExists = file.exists ();
10468: if (fileExists) {
10469:
10470: if (fileBak.exists ()) {
10471: if (!fileBak.delete ()) {
10472: System.out.println (nameBak + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10473: return false;
10474: }
10475: }
10476:
10477: if (!file.renameTo (fileBak)) {
10478: System.out.println (name + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + nameBak + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10479: return false;
10480: }
10481: }
10482:
10483: if (!fileTmp.renameTo (file)) {
10484: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + name + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10485: return false;
10486: }
10487: if (fileExists) {
10488: System.out.println (name + (Multilingual.mlnJapanese ? " を更新しました" : " was updated"));
10489: } else {
10490: System.out.println (name + (Multilingual.mlnJapanese ? " を作りました" : " was created"));
10491: }
10492: return true;
10493: }
10494:
10495:
10496:
10497:
10498:
10499:
10500:
10501:
10502:
10503: public static boolean rscPutFile (String name, byte[] array) {
10504: return rscPutFile (name, array, 0, array.length, (long) array.length);
10505: }
10506: public static boolean rscPutFile (String name, byte[] array, int offset, int length) {
10507: return rscPutFile (name, array, offset, length, (long) length);
10508: }
10509: public static boolean rscPutFile (String name, byte[] array, int offset, int length, long longLength2) {
10510: if (RSC_ZIP_SEPARATOR.matcher (name).matches ()) {
10511:
10512: return false;
10513: }
10514: File file = new File (name);
10515: boolean fileExists = file.isFile ();
10516: if (fileExists && file.length () == longLength2) {
10517: comparison:
10518: {
10519: try (BufferedInputStream bis = new BufferedInputStream (new FileInputStream (file))) {
10520: byte[] buffer = new byte[(int) Math.min (Math.max ((long) length, longLength2 - (long) length), (long) (1024 * 1024))];
10521: int position = 0;
10522: while (position < length) {
10523: int step = bis.read (buffer, 0, Math.min (buffer.length, length - position));
10524: if (step == -1) {
10525: break comparison;
10526: }
10527: int offsetPosition = offset + position;
10528: for (int i = 0; i < step; i++) {
10529: if (buffer[i] != array[offsetPosition + i]) {
10530: break comparison;
10531: }
10532: }
10533: position += step;
10534: }
10535: long longPosition2 = (long) length;
10536: while (longPosition2 < longLength2) {
10537: int step = bis.read (buffer, 0, (int) Math.min ((long) buffer.length, longLength2 - longPosition2));
10538: if (step == -1) {
10539: break comparison;
10540: }
10541: for (int i = 0; i < step; i++) {
10542: if (buffer[i] != 0) {
10543: break comparison;
10544: }
10545: }
10546: longPosition2 += (long) step;
10547: }
10548: return true;
10549: } catch (IOException ioe) {
10550: }
10551: }
10552: }
10553: String nameTmp = name + ".tmp";
10554: File fileTmp = new File (nameTmp);
10555: String nameBak = name + ".bak";
10556: File fileBak = new File (nameBak);
10557: retry:
10558: for (;;) {
10559: File parentDirectory = file.getParentFile ();
10560: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10561: String parentName = parentDirectory.getPath ();
10562: if (parentDirectory.mkdirs ()) {
10563: System.out.println (Multilingual.mlnJapanese ?
10564: parentName + " を作りました" :
10565: parentName + " was created");
10566: } else {
10567: switch (rscShowError (Multilingual.mlnJapanese ?
10568: parentName + " を作れません" :
10569: parentName + " cannot be created",
10570: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10571: case RSC_A_MASK:
10572: break retry;
10573: case RSC_R_MASK:
10574: continue retry;
10575: }
10576: }
10577: }
10578: if (fileTmp.isFile ()) {
10579: if (!fileTmp.delete ()) {
10580: switch (rscShowError (Multilingual.mlnJapanese ?
10581: nameTmp + " を削除できません" :
10582: nameTmp + " cannot be deleted",
10583: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10584: case RSC_A_MASK:
10585: break retry;
10586: case RSC_R_MASK:
10587: continue retry;
10588: }
10589: }
10590: }
10591: try (OutputStream os = name.toLowerCase ().endsWith (".gz") ?
10592: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10593: {
10594:
10595: def.setLevel (Deflater.DEFAULT_COMPRESSION);
10596:
10597: }
10598: } :
10599: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10600:
10601: os.write (array, offset, length);
10602:
10603:
10604: if ((long) length < longLength2) {
10605: byte[] buffer = new byte[(int) Math.min (longLength2 - (long) length, (long) (1024 * 1024))];
10606: Arrays.fill (buffer, 0, buffer.length, (byte) 0);
10607: long longPosition2 = (long) length;
10608: while (longPosition2 < longLength2) {
10609: int step = (int) Math.min ((long) buffer.length, longLength2 - longPosition2);
10610: os.write (buffer, 0, step);
10611: longPosition2 += (long) step;
10612: }
10613: }
10614: } catch (IOException ioe) {
10615: switch (rscShowError (Multilingual.mlnJapanese ?
10616: nameTmp + " に書き出せません" :
10617: nameTmp + " cannot be written",
10618: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10619: case RSC_A_MASK:
10620: break retry;
10621: case RSC_R_MASK:
10622: continue retry;
10623: }
10624: }
10625: if (fileExists && file.isFile ()) {
10626: if (fileBak.isFile ()) {
10627: if (!fileBak.delete ()) {
10628: switch (rscShowError (Multilingual.mlnJapanese ?
10629: nameBak + " を削除できません" :
10630: nameBak + " cannot be deleted",
10631: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10632: case RSC_A_MASK:
10633: break retry;
10634: case RSC_R_MASK:
10635: continue retry;
10636: }
10637: }
10638: }
10639: if (!file.renameTo (fileBak)) {
10640: switch (rscShowError (Multilingual.mlnJapanese ?
10641: name + " を " + nameBak + " にリネームできません" :
10642: name + " cannot be renamed to " + nameBak,
10643: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10644: case RSC_A_MASK:
10645: break retry;
10646: case RSC_R_MASK:
10647: continue retry;
10648: }
10649: }
10650: }
10651: if (fileTmp.renameTo (file)) {
10652: if (fileExists) {
10653: System.out.println (Multilingual.mlnJapanese ?
10654: name + " を更新しました" :
10655: name + " was updated");
10656: } else {
10657: System.out.println (Multilingual.mlnJapanese ?
10658: name + " を作りました" :
10659: name + " was created");
10660: }
10661: return true;
10662: } else {
10663: switch (rscShowError (Multilingual.mlnJapanese ?
10664: nameTmp + " を " + name + " にリネームできません" :
10665: nameTmp + " cannot be renamed to " + name,
10666: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10667: case RSC_A_MASK:
10668: break retry;
10669: case RSC_R_MASK:
10670: continue retry;
10671: }
10672: }
10673: break;
10674: }
10675: if (fileExists) {
10676: System.out.println (Multilingual.mlnJapanese ?
10677: name + " を更新できません" :
10678: name + " cannot be updated");
10679: } else {
10680: System.out.println (Multilingual.mlnJapanese ?
10681: name + " を作れません" :
10682: name + " cannot be created");
10683: }
10684: return false;
10685: }
10686:
10687:
10688:
10689:
10690:
10691:
10692: public static final Pattern ISM_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10693:
10694:
10695:
10696:
10697:
10698:
10699:
10700:
10701:
10702:
10703:
10704: public static InputStream ismOpen (String name) {
10705: InputStream in = null;
10706: in = ismOpen (name, false);
10707: if (in == null && name.indexOf ('/') < 0 && name.indexOf ('\\') < 0) {
10708: in = ismOpen (name, true);
10709: }
10710: return in;
10711: }
10712: public static InputStream ismOpen (String name, boolean useGetResource) {
10713: boolean gzipped = name.toLowerCase ().endsWith (".gz");
10714: String[] zipSplittedName = ISM_ZIP_SEPARATOR.split (name, 2);
10715: String fileName = zipSplittedName[0];
10716: String zipEntryName = zipSplittedName.length < 2 ? null : zipSplittedName[1];
10717: InputStream in = null;
10718: try {
10719: if (useGetResource) {
10720: if (false) {
10721: URL url = XEiJ.class.getResource (fileName);
10722: if (url != null) {
10723: in = url.openStream ();
10724: }
10725: } else {
10726: in = XEiJ.class.getResourceAsStream (fileName);
10727: }
10728: } else {
10729: File file = new File (fileName);
10730: if (file.exists ()) {
10731: in = new FileInputStream (file);
10732: }
10733: }
10734: if (in != null && zipEntryName != null) {
10735: ZipInputStream zin = new ZipInputStream (in);
10736: in = null;
10737: ZipEntry entry;
10738: while ((entry = zin.getNextEntry ()) != null) {
10739: if (zipEntryName.equals (entry.getName ())) {
10740: in = zin;
10741: break;
10742: }
10743: }
10744: if (in == null) {
10745: System.out.println (Multilingual.mlnJapanese ? fileName + " の中に " + zipEntryName + " がありません" :
10746: zipEntryName + " does not exist in " + fileName);
10747: }
10748: }
10749: if (in != null && gzipped) {
10750: in = new GZIPInputStream (in);
10751: }
10752: if (in != null) {
10753: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " を読み込みます" :
10754: (useGetResource ? "Reading resource file " : "Reading file ") + name);
10755: return new BufferedInputStream (in);
10756: }
10757: } catch (Exception ioe) {
10758: if (prgVerbose) {
10759: prgPrintStackTraceOf (ioe);
10760: }
10761: }
10762: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " が見つかりません" :
10763: (useGetResource ? "Resource file " : "File ") + name + " is not found");
10764: return null;
10765: }
10766:
10767:
10768:
10769:
10770:
10771:
10772:
10773:
10774: public static int ismRead (InputStream in, byte[] bb, int o, int l) {
10775: try {
10776: int k = 0;
10777: while (k < l) {
10778: int t = in.read (bb, o + k, l - k);
10779: if (t < 0) {
10780: break;
10781: }
10782: k += t;
10783: }
10784: return k;
10785: } catch (IOException ioe) {
10786: if (prgVerbose) {
10787: prgPrintStackTraceOf (ioe);
10788: }
10789: }
10790: return -1;
10791: }
10792:
10793:
10794:
10795:
10796:
10797:
10798:
10799:
10800: public static int ismSkip (InputStream in, int l) {
10801: try {
10802: int k = 0;
10803: while (k < l) {
10804:
10805:
10806: if (in.read () < 0) {
10807: break;
10808: }
10809: k++;
10810: if (k < l) {
10811: int t = (int) in.skip ((long) (l - k));
10812: if (t < 0) {
10813: break;
10814: }
10815: k += t;
10816: }
10817: }
10818: return k;
10819: } catch (IOException ioe) {
10820: if (prgVerbose) {
10821: prgPrintStackTraceOf (ioe);
10822: }
10823: }
10824: return -1;
10825: }
10826:
10827:
10828:
10829:
10830:
10831: public static void ismClose (InputStream in) {
10832: try {
10833: if (in != null) {
10834: in.close ();
10835: }
10836: } catch (IOException ioe) {
10837: if (prgVerbose) {
10838: prgPrintStackTraceOf (ioe);
10839: }
10840: }
10841: }
10842:
10843:
10844:
10845:
10846:
10847:
10848: public static int ismLength (String name, int maxLength) {
10849: int length;
10850: InputStream in = ismOpen (name);
10851: if (in == null) {
10852: length = -1;
10853: } else {
10854: length = ismSkip (in, maxLength);
10855: ismClose (in);
10856: }
10857: return length;
10858: }
10859:
10860:
10861:
10862:
10863:
10864:
10865:
10866:
10867:
10868:
10869:
10870:
10871:
10872:
10873: public static boolean ismLoad (byte[] bb, int o, int l, String names) {
10874: for (String name : names.split (",")) {
10875: if (name.length () != 0) {
10876: InputStream in = ismOpen (name);
10877: if (in != null) {
10878: int k = ismRead (in, bb, o, l);
10879: ismClose (in);
10880: if (k == l) {
10881: return true;
10882: }
10883: }
10884: }
10885: }
10886: return false;
10887: }
10888:
10889:
10890:
10891:
10892:
10893:
10894:
10895:
10896:
10897: public static boolean ismSave (byte[] bb, int offset, long length, String path, boolean verbose) {
10898: if (ISM_ZIP_SEPARATOR.split (path, 2).length != 1) {
10899: if (verbose) {
10900: pnlExitFullScreen (true);
10901: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? path + " に書き出せません" : "Cannot write " + path);
10902: }
10903: return false;
10904: }
10905: long step = 0;
10906: byte[] zz = null;
10907: long pointer = (long) (bb.length - offset);
10908: if (pointer < length) {
10909: step = Math.min (1024L * 512, length - pointer);
10910: zz = new byte[(int) step];
10911: Arrays.fill (zz, (byte) 0);
10912: }
10913:
10914: File file = new File (path);
10915:
10916: if (step == 0 &&
10917: file.exists () && file.length () == length) {
10918:
10919: if (length == 0L) {
10920: return true;
10921: }
10922: InputStream in = ismOpen (path);
10923: if (in != null) {
10924: int l = (int) length;
10925: byte[] tt = new byte[l];
10926: int k = ismRead (in, tt, 0, l);
10927: ismClose (in);
10928: if (k == l &&
10929: Arrays.equals (tt, bb.length == l ? bb : Arrays.copyOfRange (bb, offset, offset + l))) {
10930: return true;
10931: }
10932: }
10933: }
10934:
10935: String pathTmp = path + ".tmp";
10936: String pathBak = path + ".bak";
10937: File fileTmp = new File (pathTmp);
10938: File fileBak = new File (pathBak);
10939:
10940: if (fileTmp.exists ()) {
10941: if (!fileTmp.delete ()) {
10942: if (verbose) {
10943: pnlExitFullScreen (true);
10944: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " を削除できません" : "Cannot delete " + pathTmp);
10945: }
10946: return false;
10947: }
10948: }
10949:
10950: try (OutputStream out = path.toLowerCase ().endsWith (".gz") ?
10951: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10952: {
10953:
10954: def.setLevel (Deflater.DEFAULT_COMPRESSION);
10955:
10956: }
10957: } :
10958: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10959: if (step == 0) {
10960: out.write (bb, offset, (int) length);
10961: } else {
10962: out.write (bb, offset, (int) pointer);
10963: for (; pointer < length; pointer += step) {
10964: out.write (zz, 0, (int) Math.min (step, length - pointer));
10965: }
10966: }
10967: } catch (IOException ioe) {
10968: if (verbose) {
10969: prgPrintStackTraceOf (ioe);
10970: pnlExitFullScreen (true);
10971: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " に書き出せません" : "Cannot write " + pathTmp);
10972: }
10973: return false;
10974: }
10975:
10976:
10977: if (file.exists ()) {
10978: if (fileBak.exists ()) {
10979: if (!fileBak.delete ()) {
10980: if (verbose) {
10981: pnlExitFullScreen (true);
10982: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathBak + " を削除できません" : "Cannot delete " + pathBak);
10983: }
10984: return false;
10985: }
10986: }
10987: if (!file.renameTo (fileBak)) {
10988: if (verbose) {
10989: pnlExitFullScreen (true);
10990: JOptionPane.showMessageDialog (
10991: null, Multilingual.mlnJapanese ? path + " を " + pathBak + " にリネームできません" : "Cannot rename " + path + " to " + pathBak);
10992: }
10993: return false;
10994: }
10995: }
10996:
10997:
10998: if (!fileTmp.renameTo (file)) {
10999: if (verbose) {
11000: pnlExitFullScreen (true);
11001: JOptionPane.showMessageDialog (
11002: null, Multilingual.mlnJapanese ? pathTmp + " を " + path + " にリネームできません" : "Cannot rename " + pathTmp + " to " + path);
11003: }
11004: return false;
11005: }
11006: return true;
11007: }
11008:
11009:
11010:
11011:
11012:
11013:
11014:
11015: public static final char[] FMT_TEMP = new char[32];
11016:
11017:
11018:
11019:
11020:
11021:
11022:
11023:
11024:
11025:
11026:
11027: public static final char[] FMT_AIN4_BASE = ".......*..*...**.*...*.*.**..****...*..**.*.*.****..**.****.****".toCharArray ();
11028: public static final char[] FMT_BIN4_BASE = "0000000100100011010001010110011110001001101010111100110111101111".toCharArray ();
11029:
11030:
11031:
11032:
11033:
11034:
11035:
11036:
11037: public static void fmtAin4 (char[] a, int o, int x) {
11038: a[o ] = (char) (x >> 1 & 4 ^ 46);
11039: a[o + 1] = (char) (x & 4 ^ 46);
11040: a[o + 2] = (char) (x << 1 & 4 ^ 46);
11041: a[o + 3] = (char) (x << 2 & 4 ^ 46);
11042: }
11043: public static void fmtBin4 (char[] a, int o, int x) {
11044: a[o ] = (char) (x >>> 3 & 1 | 48);
11045: a[o + 1] = (char) (x >>> 2 & 1 | 48);
11046: a[o + 2] = (char) (x >>> 1 & 1 | 48);
11047: a[o + 3] = (char) (x & 1 | 48);
11048: }
11049: public static String fmtAin4 (int x) {
11050: return String.valueOf (FMT_AIN4_BASE, (x & 15) << 2, 4);
11051: }
11052: public static String fmtBin4 (int x) {
11053: return String.valueOf (FMT_BIN4_BASE, (x & 15) << 2, 4);
11054: }
11055: public static StringBuilder fmtAin4 (StringBuilder sb, int x) {
11056: return sb.append (FMT_AIN4_BASE, (x & 15) << 2, 6);
11057: }
11058: public static StringBuilder fmtBin4 (StringBuilder sb, int x) {
11059: return sb.append (FMT_BIN4_BASE, (x & 15) << 2, 6);
11060: }
11061:
11062:
11063:
11064:
11065:
11066:
11067:
11068:
11069: public static void fmtAin6 (char[] a, int o, int x) {
11070: a[o ] = (char) (x >> 3 & 4 ^ 46);
11071: a[o + 1] = (char) (x >> 2 & 4 ^ 46);
11072: a[o + 2] = (char) (x >> 1 & 4 ^ 46);
11073: a[o + 3] = (char) (x & 4 ^ 46);
11074: a[o + 4] = (char) (x << 1 & 4 ^ 46);
11075: a[o + 5] = (char) (x << 2 & 4 ^ 46);
11076: }
11077: public static void fmtBin6 (char[] a, int o, int x) {
11078: a[o ] = (char) (x >>> 5 & 1 | 48);
11079: a[o + 1] = (char) (x >>> 4 & 1 | 48);
11080: a[o + 2] = (char) (x >>> 3 & 1 | 48);
11081: a[o + 3] = (char) (x >>> 2 & 1 | 48);
11082: a[o + 4] = (char) (x >>> 1 & 1 | 48);
11083: a[o + 5] = (char) (x & 1 | 48);
11084: }
11085: public static String fmtAin6 (int x) {
11086: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11087: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11088: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11089: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11090: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11091: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11092: return String.valueOf (FMT_TEMP, 0, 6);
11093: }
11094: public static String fmtBin6 (int x) {
11095: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11096: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11097: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11098: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11099: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11100: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11101: return String.valueOf (FMT_TEMP, 0, 6);
11102: }
11103: public static StringBuilder fmtAin6 (StringBuilder sb, int x) {
11104: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11105: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11106: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11107: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11108: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11109: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11110: return sb.append (FMT_TEMP, 0, 6);
11111: }
11112: public static StringBuilder fmtBin6 (StringBuilder sb, int x) {
11113: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11114: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11115: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11116: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11117: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11118: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11119: return sb.append (FMT_TEMP, 0, 6);
11120: }
11121:
11122:
11123:
11124:
11125:
11126:
11127:
11128:
11129: public static void fmtAin8 (char[] a, int o, int x) {
11130: a[o ] = (char) (x >> 5 & 4 ^ 46);
11131: a[o + 1] = (char) (x >> 4 & 4 ^ 46);
11132: a[o + 2] = (char) (x >> 3 & 4 ^ 46);
11133: a[o + 3] = (char) (x >> 2 & 4 ^ 46);
11134: a[o + 4] = (char) (x >> 1 & 4 ^ 46);
11135: a[o + 5] = (char) (x & 4 ^ 46);
11136: a[o + 6] = (char) (x << 1 & 4 ^ 46);
11137: a[o + 7] = (char) (x << 2 & 4 ^ 46);
11138: }
11139: public static void fmtBin8 (char[] a, int o, int x) {
11140: a[o ] = (char) (x >>> 7 & 1 | 48);
11141: a[o + 1] = (char) (x >>> 6 & 1 | 48);
11142: a[o + 2] = (char) (x >>> 5 & 1 | 48);
11143: a[o + 3] = (char) (x >>> 4 & 1 | 48);
11144: a[o + 4] = (char) (x >>> 3 & 1 | 48);
11145: a[o + 5] = (char) (x >>> 2 & 1 | 48);
11146: a[o + 6] = (char) (x >>> 1 & 1 | 48);
11147: a[o + 7] = (char) (x & 1 | 48);
11148: }
11149: public static String fmtAin8 (int x) {
11150: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11151: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11152: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11153: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11154: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11155: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11156: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11157: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11158: return String.valueOf (FMT_TEMP, 0, 8);
11159: }
11160: public static String fmtBin8 (int x) {
11161: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11162: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11163: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11164: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11165: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11166: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11167: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11168: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11169: return String.valueOf (FMT_TEMP, 0, 8);
11170: }
11171: public static StringBuilder fmtAin8 (StringBuilder sb, int x) {
11172: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11173: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11174: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11175: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11176: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11177: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11178: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11179: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11180: return sb.append (FMT_TEMP, 0, 8);
11181: }
11182: public static StringBuilder fmtBin8 (StringBuilder sb, int x) {
11183: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11184: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11185: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11186: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11187: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11188: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11189: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11190: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11191: return sb.append (FMT_TEMP, 0, 8);
11192: }
11193:
11194:
11195:
11196:
11197:
11198:
11199:
11200:
11201: public static void fmtAin12 (char[] a, int o, int x) {
11202: a[o ] = (char) (x >> 9 & 4 ^ 46);
11203: a[o + 1] = (char) (x >> 8 & 4 ^ 46);
11204: a[o + 2] = (char) (x >> 7 & 4 ^ 46);
11205: a[o + 3] = (char) (x >> 6 & 4 ^ 46);
11206: a[o + 4] = (char) (x >> 5 & 4 ^ 46);
11207: a[o + 5] = (char) (x >> 4 & 4 ^ 46);
11208: a[o + 6] = (char) (x >> 3 & 4 ^ 46);
11209: a[o + 7] = (char) (x >> 2 & 4 ^ 46);
11210: a[o + 8] = (char) (x >> 1 & 4 ^ 46);
11211: a[o + 9] = (char) (x & 4 ^ 46);
11212: a[o + 10] = (char) (x << 1 & 4 ^ 46);
11213: a[o + 11] = (char) (x << 2 & 4 ^ 46);
11214: }
11215: public static void fmtBin12 (char[] a, int o, int x) {
11216: a[o ] = (char) (x >>> 11 & 1 | 48);
11217: a[o + 1] = (char) (x >>> 10 & 1 | 48);
11218: a[o + 2] = (char) (x >>> 9 & 1 | 48);
11219: a[o + 3] = (char) (x >>> 8 & 1 | 48);
11220: a[o + 4] = (char) (x >>> 7 & 1 | 48);
11221: a[o + 5] = (char) (x >>> 6 & 1 | 48);
11222: a[o + 6] = (char) (x >>> 5 & 1 | 48);
11223: a[o + 7] = (char) (x >>> 4 & 1 | 48);
11224: a[o + 8] = (char) (x >>> 3 & 1 | 48);
11225: a[o + 9] = (char) (x >>> 2 & 1 | 48);
11226: a[o + 10] = (char) (x >>> 1 & 1 | 48);
11227: a[o + 11] = (char) (x & 1 | 48);
11228: }
11229: public static String fmtAin12 (int x) {
11230: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11231: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11232: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11233: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11234: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11235: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11236: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11237: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11238: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11239: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11240: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11241: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11242: return String.valueOf (FMT_TEMP, 0, 12);
11243: }
11244: public static String fmtBin12 (int x) {
11245: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11246: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11247: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11248: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11249: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11250: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11251: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11252: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11253: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11254: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11255: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11256: FMT_TEMP[11] = (char) (x & 1 | 48);
11257: return String.valueOf (FMT_TEMP, 0, 12);
11258: }
11259: public static StringBuilder fmtAin12 (StringBuilder sb, int x) {
11260: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11261: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11262: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11263: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11264: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11265: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11266: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11267: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11268: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11269: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11270: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11271: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11272: return sb.append (FMT_TEMP, 0, 12);
11273: }
11274: public static StringBuilder fmtBin12 (StringBuilder sb, int x) {
11275: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11276: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11277: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11278: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11279: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11280: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11281: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11282: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11283: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11284: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11285: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11286: FMT_TEMP[11] = (char) (x & 1 | 48);
11287: return sb.append (FMT_TEMP, 0, 12);
11288: }
11289:
11290:
11291:
11292:
11293:
11294:
11295:
11296:
11297: public static void fmtAin16 (char[] a, int o, int x) {
11298: a[o ] = (char) (x >> 13 & 4 ^ 46);
11299: a[o + 1] = (char) (x >> 12 & 4 ^ 46);
11300: a[o + 2] = (char) (x >> 11 & 4 ^ 46);
11301: a[o + 3] = (char) (x >> 10 & 4 ^ 46);
11302: a[o + 4] = (char) (x >> 9 & 4 ^ 46);
11303: a[o + 5] = (char) (x >> 8 & 4 ^ 46);
11304: a[o + 6] = (char) (x >> 7 & 4 ^ 46);
11305: a[o + 7] = (char) (x >> 6 & 4 ^ 46);
11306: a[o + 8] = (char) (x >> 5 & 4 ^ 46);
11307: a[o + 9] = (char) (x >> 4 & 4 ^ 46);
11308: a[o + 10] = (char) (x >> 3 & 4 ^ 46);
11309: a[o + 11] = (char) (x >> 2 & 4 ^ 46);
11310: a[o + 12] = (char) (x >> 1 & 4 ^ 46);
11311: a[o + 13] = (char) (x & 4 ^ 46);
11312: a[o + 14] = (char) (x << 1 & 4 ^ 46);
11313: a[o + 15] = (char) (x << 2 & 4 ^ 46);
11314: }
11315: public static void fmtBin16 (char[] a, int o, int x) {
11316: a[o ] = (char) (x >>> 15 & 1 | 48);
11317: a[o + 1] = (char) (x >>> 14 & 1 | 48);
11318: a[o + 2] = (char) (x >>> 13 & 1 | 48);
11319: a[o + 3] = (char) (x >>> 12 & 1 | 48);
11320: a[o + 4] = (char) (x >>> 11 & 1 | 48);
11321: a[o + 5] = (char) (x >>> 10 & 1 | 48);
11322: a[o + 6] = (char) (x >>> 9 & 1 | 48);
11323: a[o + 7] = (char) (x >>> 8 & 1 | 48);
11324: a[o + 8] = (char) (x >>> 7 & 1 | 48);
11325: a[o + 9] = (char) (x >>> 6 & 1 | 48);
11326: a[o + 10] = (char) (x >>> 5 & 1 | 48);
11327: a[o + 11] = (char) (x >>> 4 & 1 | 48);
11328: a[o + 12] = (char) (x >>> 3 & 1 | 48);
11329: a[o + 13] = (char) (x >>> 2 & 1 | 48);
11330: a[o + 14] = (char) (x >>> 1 & 1 | 48);
11331: a[o + 15] = (char) (x & 1 | 48);
11332: }
11333: public static String fmtAin16 (int x) {
11334: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11335: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11336: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11337: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11338: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11339: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11340: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11341: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11342: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11343: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11344: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11345: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11346: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11347: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11348: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11349: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11350: return String.valueOf (FMT_TEMP, 0, 16);
11351: }
11352: public static String fmtBin16 (int x) {
11353: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11354: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11355: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11356: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11357: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11358: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11359: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11360: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11361: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11362: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11363: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11364: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11365: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11366: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11367: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11368: FMT_TEMP[15] = (char) (x & 1 | 48);
11369: return String.valueOf (FMT_TEMP, 0, 16);
11370: }
11371: public static StringBuilder fmtAin16 (StringBuilder sb, int x) {
11372: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11373: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11374: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11375: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11376: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11377: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11378: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11379: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11380: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11381: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11382: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11383: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11384: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11385: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11386: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11387: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11388: return sb.append (FMT_TEMP, 0, 16);
11389: }
11390: public static StringBuilder fmtBin16 (StringBuilder sb, int x) {
11391: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11392: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11393: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11394: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11395: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11396: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11397: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11398: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11399: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11400: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11401: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11402: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11403: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11404: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11405: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11406: FMT_TEMP[15] = (char) (x & 1 | 48);
11407: return sb.append (FMT_TEMP, 0, 16);
11408: }
11409:
11410:
11411:
11412:
11413:
11414:
11415:
11416:
11417: public static void fmtAin24 (char[] a, int o, int x) {
11418: a[o ] = (char) (x >> 21 & 4 ^ 46);
11419: a[o + 1] = (char) (x >> 20 & 4 ^ 46);
11420: a[o + 2] = (char) (x >> 19 & 4 ^ 46);
11421: a[o + 3] = (char) (x >> 18 & 4 ^ 46);
11422: a[o + 4] = (char) (x >> 17 & 4 ^ 46);
11423: a[o + 5] = (char) (x >> 16 & 4 ^ 46);
11424: a[o + 6] = (char) (x >> 15 & 4 ^ 46);
11425: a[o + 7] = (char) (x >> 14 & 4 ^ 46);
11426: a[o + 8] = (char) (x >> 13 & 4 ^ 46);
11427: a[o + 9] = (char) (x >> 12 & 4 ^ 46);
11428: a[o + 10] = (char) (x >> 11 & 4 ^ 46);
11429: a[o + 11] = (char) (x >> 10 & 4 ^ 46);
11430: a[o + 12] = (char) (x >> 9 & 4 ^ 46);
11431: a[o + 13] = (char) (x >> 8 & 4 ^ 46);
11432: a[o + 14] = (char) (x >> 7 & 4 ^ 46);
11433: a[o + 15] = (char) (x >> 6 & 4 ^ 46);
11434: a[o + 16] = (char) (x >> 5 & 4 ^ 46);
11435: a[o + 17] = (char) (x >> 4 & 4 ^ 46);
11436: a[o + 18] = (char) (x >> 3 & 4 ^ 46);
11437: a[o + 19] = (char) (x >> 2 & 4 ^ 46);
11438: a[o + 20] = (char) (x >> 1 & 4 ^ 46);
11439: a[o + 21] = (char) (x & 4 ^ 46);
11440: a[o + 22] = (char) (x << 1 & 4 ^ 46);
11441: a[o + 23] = (char) (x << 2 & 4 ^ 46);
11442: }
11443: public static void fmtBin24 (char[] a, int o, int x) {
11444: a[o ] = (char) (x >>> 23 & 1 | 48);
11445: a[o + 1] = (char) (x >>> 22 & 1 | 48);
11446: a[o + 2] = (char) (x >>> 21 & 1 | 48);
11447: a[o + 3] = (char) (x >>> 20 & 1 | 48);
11448: a[o + 4] = (char) (x >>> 19 & 1 | 48);
11449: a[o + 5] = (char) (x >>> 18 & 1 | 48);
11450: a[o + 6] = (char) (x >>> 17 & 1 | 48);
11451: a[o + 7] = (char) (x >>> 16 & 1 | 48);
11452: a[o + 8] = (char) (x >>> 15 & 1 | 48);
11453: a[o + 9] = (char) (x >>> 14 & 1 | 48);
11454: a[o + 10] = (char) (x >>> 13 & 1 | 48);
11455: a[o + 11] = (char) (x >>> 12 & 1 | 48);
11456: a[o + 12] = (char) (x >>> 11 & 1 | 48);
11457: a[o + 13] = (char) (x >>> 10 & 1 | 48);
11458: a[o + 14] = (char) (x >>> 9 & 1 | 48);
11459: a[o + 15] = (char) (x >>> 8 & 1 | 48);
11460: a[o + 16] = (char) (x >>> 7 & 1 | 48);
11461: a[o + 17] = (char) (x >>> 6 & 1 | 48);
11462: a[o + 18] = (char) (x >>> 5 & 1 | 48);
11463: a[o + 19] = (char) (x >>> 4 & 1 | 48);
11464: a[o + 20] = (char) (x >>> 3 & 1 | 48);
11465: a[o + 21] = (char) (x >>> 2 & 1 | 48);
11466: a[o + 22] = (char) (x >>> 1 & 1 | 48);
11467: a[o + 23] = (char) (x & 1 | 48);
11468: }
11469: public static String fmtAin24 (int x) {
11470: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11471: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11472: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11473: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11474: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11475: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11476: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11477: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11478: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11479: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11480: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11481: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11482: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11483: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11484: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11485: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11486: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11487: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11488: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11489: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11490: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11491: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11492: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11493: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11494: return String.valueOf (FMT_TEMP, 0, 24);
11495: }
11496: public static String fmtBin24 (int x) {
11497: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11498: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11499: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11500: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11501: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11502: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11503: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11504: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11505: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11506: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11507: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11508: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11509: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11510: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11511: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11512: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11513: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11514: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11515: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11516: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11517: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11518: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11519: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11520: FMT_TEMP[23] = (char) (x & 1 | 48);
11521: return String.valueOf (FMT_TEMP, 0, 24);
11522: }
11523: public static StringBuilder fmtAin24 (StringBuilder sb, int x) {
11524: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11525: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11526: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11527: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11528: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11529: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11530: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11531: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11532: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11533: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11534: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11535: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11536: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11537: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11538: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11539: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11540: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11541: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11542: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11543: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11544: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11545: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11546: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11547: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11548: return sb.append (FMT_TEMP, 0, 24);
11549: }
11550: public static StringBuilder fmtBin24 (StringBuilder sb, int x) {
11551: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11552: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11553: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11554: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11555: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11556: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11557: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11558: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11559: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11560: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11561: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11562: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11563: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11564: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11565: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11566: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11567: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11568: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11569: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11570: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11571: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11572: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11573: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11574: FMT_TEMP[23] = (char) (x & 1 | 48);
11575: return sb.append (FMT_TEMP, 0, 24);
11576: }
11577:
11578:
11579:
11580:
11581:
11582:
11583:
11584:
11585:
11586:
11587:
11588:
11589:
11590:
11591:
11592:
11593:
11594:
11595:
11596:
11597:
11598:
11599:
11600:
11601:
11602:
11603:
11604:
11605:
11606:
11607:
11608:
11609:
11610: public static char fmtHexc (int x) {
11611: x &= 15;
11612: return (char) ((((9 - x) >> 4) & 7) + 48 + x);
11613: }
11614: public static void fmtHex1 (char[] a, int o, int x) {
11615: x &= 15;
11616: a[o] = (char) ((((9 - x) >> 4) & 7) + 48 + x);
11617: }
11618: public static String fmtHex1 (int x) {
11619: x &= 15;
11620: return Character.toString ((char) ((((9 - x) >> 4) & 7) + 48 + x));
11621: }
11622: public static StringBuilder fmtHex1 (StringBuilder sb, int x) {
11623: x &= 15;
11624: return sb.append ((char) ((((9 - x) >> 4) & 7) + 48 + x));
11625: }
11626:
11627:
11628:
11629:
11630:
11631:
11632: public static void fmtHex2 (char[] a, int o, int x) {
11633: int x0 = x & 15;
11634: int x1 = x >>> 4 & 15;
11635: a[o ] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
11636: a[o + 1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
11637: }
11638: public static String fmtHex2 (int x) {
11639:
11640: int x0 = x & 15;
11641: int x1 = x >>> 4 & 15;
11642: FMT_TEMP[0] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
11643: FMT_TEMP[1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
11644: return String.valueOf (FMT_TEMP, 0, 2);
11645: }
11646: public static StringBuilder fmtHex2 (StringBuilder sb, int x) {
11647: int x0 = x & 15;
11648: int x1 = x >>> 4 & 15;
11649: return (sb.
11650: append ((char) ((((9 - x1) >> 4) & 7) + 48 + x1)).
11651: append ((char) ((((9 - x0) >> 4) & 7) + 48 + x0)));
11652: }
11653:
11654:
11655:
11656:
11657:
11658:
11659: public static void fmtHex4 (char[] a, int o, int x) {
11660: int t;
11661: t = (char) x >>> 12;
11662: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11663: t = x >>> 8 & 15;
11664: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11665: t = x >>> 4 & 15;
11666: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11667: t = x & 15;
11668: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11669: }
11670: public static String fmtHex4 (int x) {
11671:
11672: int t;
11673: t = (char) x >>> 12;
11674: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11675: t = x >>> 8 & 15;
11676: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11677: t = x >>> 4 & 15;
11678: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11679: t = x & 15;
11680: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11681: return String.valueOf (FMT_TEMP, 0, 4);
11682: }
11683: public static StringBuilder fmtHex4 (StringBuilder sb, int x) {
11684:
11685: int t;
11686: t = (char) x >>> 12;
11687: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11688: t = x >>> 8 & 15;
11689: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11690: t = x >>> 4 & 15;
11691: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11692: t = x & 15;
11693: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11694: return sb.append (FMT_TEMP, 0, 4);
11695: }
11696:
11697:
11698:
11699:
11700:
11701:
11702: public static void fmtHex6 (char[] a, int o, int x) {
11703: int t;
11704: t = x >>> 20 & 15;
11705: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11706: t = x >>> 16 & 15;
11707: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11708: t = (char) x >>> 12;
11709: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11710: t = x >>> 8 & 15;
11711: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11712: t = x >>> 4 & 15;
11713: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11714: t = x & 15;
11715: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11716: }
11717: public static String fmtHex6 (int x) {
11718:
11719: int t;
11720: t = x >>> 20 & 15;
11721: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11722: t = x >>> 16 & 15;
11723: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11724: t = (char) x >>> 12;
11725: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11726: t = x >>> 8 & 15;
11727: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11728: t = x >>> 4 & 15;
11729: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11730: t = x & 15;
11731: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11732: return String.valueOf (FMT_TEMP, 0, 6);
11733: }
11734: public static StringBuilder fmtHex6 (StringBuilder sb, int x) {
11735:
11736: int t;
11737: t = x >>> 20 & 15;
11738: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11739: t = x >>> 16 & 15;
11740: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11741: t = (char) x >>> 12;
11742: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11743: t = x >>> 8 & 15;
11744: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11745: t = x >>> 4 & 15;
11746: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11747: t = x & 15;
11748: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11749: return sb.append (FMT_TEMP, 0, 6);
11750: }
11751:
11752:
11753:
11754:
11755:
11756:
11757: public static void fmtHex8 (char[] a, int o, int x) {
11758: int t;
11759: t = x >>> 28;
11760: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11761: t = x >>> 24 & 15;
11762: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11763: t = x >>> 20 & 15;
11764: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11765: t = x >>> 16 & 15;
11766: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11767: t = (char) x >>> 12;
11768: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11769: t = x >>> 8 & 15;
11770: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11771: t = x >>> 4 & 15;
11772: a[o + 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11773: t = x & 15;
11774: a[o + 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11775: }
11776: public static String fmtHex8 (int x) {
11777:
11778: int t;
11779: t = x >>> 28;
11780: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11781: t = x >>> 24 & 15;
11782: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11783: t = x >>> 20 & 15;
11784: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11785: t = x >>> 16 & 15;
11786: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11787: t = (char) x >>> 12;
11788: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11789: t = x >>> 8 & 15;
11790: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11791: t = x >>> 4 & 15;
11792: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11793: t = x & 15;
11794: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11795: return String.valueOf (FMT_TEMP, 0, 8);
11796: }
11797: public static StringBuilder fmtHex8 (StringBuilder sb, int x) {
11798:
11799: int t;
11800: t = x >>> 28;
11801: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11802: t = x >>> 24 & 15;
11803: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11804: t = x >>> 20 & 15;
11805: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11806: t = x >>> 16 & 15;
11807: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11808: t = (char) x >>> 12;
11809: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11810: t = x >>> 8 & 15;
11811: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11812: t = x >>> 4 & 15;
11813: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11814: t = x & 15;
11815: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11816: return sb.append (FMT_TEMP, 0, 8);
11817: }
11818:
11819: public static StringBuilder fmtHex16 (StringBuilder sb, long x) {
11820:
11821: int s, t;
11822: s = (int) (x >>> 32);
11823: t = s >>> 28;
11824: FMT_TEMP[ 0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11825: t = s >>> 24 & 15;
11826: FMT_TEMP[ 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11827: t = s >>> 20 & 15;
11828: FMT_TEMP[ 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11829: t = s >>> 16 & 15;
11830: FMT_TEMP[ 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11831: t = (char) s >>> 12;
11832: FMT_TEMP[ 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11833: t = s >>> 8 & 15;
11834: FMT_TEMP[ 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11835: t = s >>> 4 & 15;
11836: FMT_TEMP[ 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11837: t = s & 15;
11838: FMT_TEMP[ 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11839: s = (int) x;
11840: t = s >>> 28;
11841: FMT_TEMP[ 8] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11842: t = s >>> 24 & 15;
11843: FMT_TEMP[ 9] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11844: t = s >>> 20 & 15;
11845: FMT_TEMP[10] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11846: t = s >>> 16 & 15;
11847: FMT_TEMP[11] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11848: t = (char) s >>> 12;
11849: FMT_TEMP[12] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11850: t = s >>> 8 & 15;
11851: FMT_TEMP[13] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11852: t = s >>> 4 & 15;
11853: FMT_TEMP[14] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11854: t = s & 15;
11855: FMT_TEMP[15] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11856: return sb.append (FMT_TEMP, 0, 16);
11857: }
11858:
11859:
11860:
11861:
11862:
11863:
11864:
11865:
11866:
11867:
11868:
11869:
11870:
11871:
11872:
11873:
11874:
11875:
11876:
11877:
11878:
11879:
11880:
11881:
11882:
11883:
11884:
11885:
11886:
11887:
11888:
11889:
11890:
11891:
11892:
11893:
11894:
11895:
11896:
11897:
11898:
11899:
11900:
11901:
11902:
11903:
11904:
11905:
11906:
11907:
11908:
11909:
11910:
11911:
11912:
11913:
11914:
11915:
11916:
11917:
11918:
11919:
11920:
11921:
11922:
11923:
11924:
11925:
11926: public static final int[] FMT_BCD4 = new int[10000];
11927: public static final int[] FMT_DCB4 = new int[65536];
11928:
11929:
11930:
11931:
11932: public static void fmtInit () {
11933: Arrays.fill (FMT_DCB4, -1);
11934: int i = 0;
11935: int x = 0;
11936: for (int a = 0; a < 10; a++) {
11937: for (int b = 0; b < 10; b++) {
11938: for (int c = 0; c < 10; c++) {
11939: FMT_DCB4[FMT_BCD4[i ] = x ] = i;
11940: FMT_DCB4[FMT_BCD4[i + 1] = x + 1] = i + 1;
11941: FMT_DCB4[FMT_BCD4[i + 2] = x + 2] = i + 2;
11942: FMT_DCB4[FMT_BCD4[i + 3] = x + 3] = i + 3;
11943: FMT_DCB4[FMT_BCD4[i + 4] = x + 4] = i + 4;
11944: FMT_DCB4[FMT_BCD4[i + 5] = x + 5] = i + 5;
11945: FMT_DCB4[FMT_BCD4[i + 6] = x + 6] = i + 6;
11946: FMT_DCB4[FMT_BCD4[i + 7] = x + 7] = i + 7;
11947: FMT_DCB4[FMT_BCD4[i + 8] = x + 8] = i + 8;
11948: FMT_DCB4[FMT_BCD4[i + 9] = x + 9] = i + 9;
11949: i += 10;
11950: x += 1 << 4;
11951: }
11952: x += 6 << 4;
11953: }
11954: x += 6 << 8;
11955: }
11956: }
11957:
11958:
11959:
11960: public static int fmtBcd4 (int x) {
11961:
11962:
11963:
11964:
11965:
11966:
11967:
11968:
11969:
11970: return FMT_BCD4[Math.max (0, Math.min (9999, x))];
11971: }
11972:
11973:
11974:
11975: public static int fmtBcd8 (int x) {
11976: x = Math.max (0, Math.min (99999999, x));
11977:
11978:
11979: int q = (int) ((long) x * 109951163L >>> 40);
11980:
11981: return FMT_BCD4[q] << 16 | FMT_BCD4[x - 10000 * q];
11982: }
11983:
11984:
11985:
11986: public static long fmtBcd12 (long x) {
11987: x = Math.max (0L, Math.min (999999999999L, x));
11988: int q = (int) ((double) x / 100000000.0);
11989: int r = (int) (x - 100000000L * q);
11990:
11991:
11992: int rq = (int) ((long) r * 109951163L >>> 40);
11993:
11994: return (long) FMT_BCD4[q] << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
11995: }
11996:
11997:
11998:
11999: public static long fmtBcd16 (long x) {
12000: x = Math.max (0L, Math.min (9999999999999999L, x));
12001: int q = x <= (1L << 53) ? (int) ((double) x / 100000000.0) : (int) (x / 100000000L);
12002: int r = (int) (x - 100000000L * q);
12003:
12004:
12005: int qq = (int) ((long) q * 109951163L >>> 40);
12006:
12007:
12008:
12009: int rq = (int) ((long) r * 109951163L >>> 40);
12010:
12011: return (long) (FMT_BCD4[qq] << 16 | FMT_BCD4[q - 10000 * qq]) << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
12012: }
12013:
12014:
12015:
12016:
12017:
12018:
12019: public static int fmtCA02u (char[] a, int o, int x) {
12020: if (x < 0 || 99 < x) {
12021: x = 99;
12022: }
12023: x = FMT_BCD4[x];
12024: a[o ] = (char) ('0' | x >>> 4);
12025: a[o + 1] = (char) ('0' | x & 15);
12026: return o + 2;
12027: }
12028: public static StringBuilder fmtSB02u (StringBuilder sb, int x) {
12029: return sb.append (FMT_TEMP, 0, fmtCA02u (FMT_TEMP, 0, x));
12030: }
12031:
12032:
12033:
12034:
12035:
12036: public static int fmtCA2u (char[] a, int o, int x) {
12037: if (x < 0 || 99 < x) {
12038: x = 99;
12039: }
12040: x = FMT_BCD4[x];
12041: if (x <= 0x000f) {
12042: a[o++] = (char) ('0' | x);
12043: } else {
12044: a[o++] = (char) ('0' | x >>> 4);
12045: a[o++] = (char) ('0' | x & 15);
12046: }
12047: return o;
12048: }
12049: public static StringBuilder fmtSB2u (StringBuilder sb, int x) {
12050: return sb.append (FMT_TEMP, 0, fmtCA2u (FMT_TEMP, 0, x));
12051: }
12052:
12053:
12054:
12055:
12056:
12057: public static int fmtCA04u (char[] a, int o, int x) {
12058: if (x < 0 || 9999 < x) {
12059: x = 9999;
12060: }
12061: x = FMT_BCD4[x];
12062: a[o ] = (char) ('0' | x >>> 12);
12063: a[o + 1] = (char) ('0' | x >>> 8 & 15);
12064: a[o + 2] = (char) ('0' | x >>> 4 & 15);
12065: a[o + 3] = (char) ('0' | x & 15);
12066: return o + 4;
12067: }
12068: public static StringBuilder fmtSB04u (StringBuilder sb, int x) {
12069: return sb.append (FMT_TEMP, 0, fmtCA04u (FMT_TEMP, 0, x));
12070: }
12071:
12072:
12073:
12074:
12075:
12076: public static int fmtCA4u (char[] a, int o, int x) {
12077: if (x < 0 || 9999 < x) {
12078: x = 9999;
12079: }
12080: x = FMT_BCD4[x];
12081: if (x <= 0x000f) {
12082: a[o++] = (char) ('0' | x);
12083: } else if (x <= 0x00ff) {
12084: a[o++] = (char) ('0' | x >>> 4);
12085: a[o++] = (char) ('0' | x & 15);
12086: } else if (x <= 0x0fff) {
12087: a[o++] = (char) ('0' | x >>> 8);
12088: a[o++] = (char) ('0' | x >>> 4 & 15);
12089: a[o++] = (char) ('0' | x & 15);
12090: } else {
12091: a[o++] = (char) ('0' | x >>> 12);
12092: a[o++] = (char) ('0' | x >>> 8 & 15);
12093: a[o++] = (char) ('0' | x >>> 4 & 15);
12094: a[o++] = (char) ('0' | x & 15);
12095: }
12096: return o;
12097: }
12098: public static StringBuilder fmtSB4u (StringBuilder sb, int x) {
12099: return sb.append (FMT_TEMP, 0, fmtCA4u (FMT_TEMP, 0, x));
12100: }
12101:
12102:
12103:
12104:
12105:
12106: public static int fmtCA08u (char[] a, int o, int x) {
12107: if (x < 0 || 99999999 < x) {
12108: x = 99999999;
12109: }
12110:
12111:
12112: int h = (int) ((long) x * 109951163L >>> 40);
12113: return fmtCA04u (a, fmtCA04u (a, o, h), x - h * 10000);
12114: }
12115: public static StringBuilder fmtSB08u (StringBuilder sb, int x) {
12116: return sb.append (FMT_TEMP, 0, fmtCA08u (FMT_TEMP, 0, x));
12117: }
12118:
12119:
12120:
12121:
12122:
12123: public static int fmtCA8u (char[] a, int o, int x) {
12124: if (x < 0 || 99999999 < x) {
12125: x = 99999999;
12126: }
12127: if (x <= 9999) {
12128: return fmtCA4u (a, o, x);
12129: } else {
12130:
12131:
12132: int h = (int) ((long) x * 109951163L >>> 40);
12133: return fmtCA04u (a, fmtCA4u (a, o, h), x - h * 10000);
12134: }
12135: }
12136: public static StringBuilder fmtSB8u (StringBuilder sb, int x) {
12137: return sb.append (FMT_TEMP, 0, fmtCA8u (FMT_TEMP, 0, x));
12138: }
12139:
12140:
12141:
12142:
12143:
12144: public static int fmtCAd (char[] a, int o, long x) {
12145: if (x < 0L) {
12146: x = -x;
12147: a[o++] = '-';
12148: }
12149: if (x <= 99999999L) {
12150: return fmtCA8u (a, o, (int) x);
12151: } else if (x <= 9999999999999999L) {
12152: long h = x / 100000000L;
12153: return fmtCA08u (a, fmtCA8u (a, o, (int) h), (int) (x - h * 100000000L));
12154: } else {
12155: long hh = x / 10000000000000000L;
12156: x -= hh * 10000000000000000L;
12157: long h = x / 100000000L;
12158: return fmtCA08u (a, fmtCA08u (a, fmtCA4u (a, o, (int) hh), (int) h), (int) (x - h * 100000000L));
12159: }
12160: }
12161: public static StringBuilder fmtSBd (StringBuilder sb, long x) {
12162: return sb.append (FMT_TEMP, 0, fmtCAd (FMT_TEMP, 0, x));
12163: }
12164:
12165:
12166:
12167:
12168:
12169:
12170: public static int fmtCAnd (char[] a, int o, int n, long x) {
12171: int t = fmtCAd (a, o, x);
12172: n += o;
12173: if (t < n) {
12174: int i = n;
12175: while (o < t) {
12176: a[--i] = a[--t];
12177: }
12178: while (o < i) {
12179: a[--i] = ' ';
12180: }
12181: t = n;
12182: }
12183: return t;
12184: }
12185: public static StringBuilder fmtSBnd (StringBuilder sb, int n, int x) {
12186: return sb.append (FMT_TEMP, 0, fmtCAnd (FMT_TEMP, 0, n, x));
12187: }
12188:
12189:
12190:
12191:
12192:
12193:
12194:
12195:
12196:
12197:
12198:
12199:
12200:
12201: public static int fmtParseInt (String s, int i, int min, int max, int err) {
12202: return fmtParseIntRadix (s, i, min, max, err, 10);
12203: }
12204: public static int fmtParseIntRadix (String s, int i, int min, int max, int err, int radix) {
12205: if (s == null) {
12206: return err;
12207: }
12208: int l = s.length ();
12209: int c = i < l ? s.charAt (i++) : -1;
12210:
12211: while (c == ' ' || c == '\t') {
12212: c = i < l ? s.charAt (i++) : -1;
12213: }
12214:
12215: int n = 0;
12216: if (c == '+') {
12217: c = i < l ? s.charAt (i++) : -1;
12218: } else if (c == '-') {
12219: n = 1;
12220: c = i < l ? s.charAt (i++) : -1;
12221: }
12222:
12223:
12224:
12225:
12226: int o;
12227: int p;
12228: if (c == '$') {
12229: o = 0x07ffffff + n;
12230: p = 15 + n & 15;
12231: radix = 16;
12232: c = i < l ? s.charAt (i++) : -1;
12233: } else if (radix == 16) {
12234: o = 0x07ffffff + n;
12235: p = 15 + n & 15;
12236: } else if (radix == 8) {
12237: o = 0x0fffffff + n;
12238: p = 7 + n & 7;
12239: } else if (radix == 2) {
12240: o = 0x3fffffff + n;
12241: p = 1 + n & 1;
12242: } else {
12243: o = 214748364;
12244: p = 7 + n;
12245: radix = 10;
12246: }
12247:
12248: int x = Character.digit (c, radix);
12249: if (x < 0) {
12250: return err;
12251: }
12252: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12253: while (c >= 0) {
12254: int t = x - o;
12255: if (t > 0 || t == 0 && c > p) {
12256: return err;
12257: }
12258: x = x * radix + c;
12259: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12260: }
12261: if (n != 0) {
12262: x = -x;
12263: }
12264: return min <= x && x <= max ? x : err;
12265: }
12266:
12267:
12268:
12269:
12270:
12271:
12272:
12273:
12274:
12275:
12276: public static long matMax3 (long x1, long x2, long x3) {
12277: return Math.max (Math.max (x1, x2), x3);
12278: }
12279: public static long matMax4 (long x1, long x2, long x3, long x4) {
12280: return Math.max (Math.max (x1, x2), Math.max (x3, x4));
12281: }
12282: public static long matMax5 (long x1, long x2, long x3, long x4, long x5) {
12283: return Math.max (Math.max (Math.max (x1, x2), Math.max (x3, x4)), x5);
12284: }
12285:
12286:
12287:
12288:
12289:
12290: public static long matMin3 (long x1, long x2, long x3) {
12291: return Math.min (Math.min (x1, x2), x3);
12292: }
12293: public static long matMin4 (long x1, long x2, long x3, long x4) {
12294: return Math.min (Math.min (x1, x2), Math.min (x3, x4));
12295: }
12296: public static long matMin5 (long x1, long x2, long x3, long x4, long x5) {
12297: return Math.min (Math.min (Math.min (x1, x2), Math.min (x3, x4)), x5);
12298: }
12299:
12300:
12301:
12302:
12303:
12304:
12305:
12306:
12307:
12308:
12309:
12310:
12311: public static String strEncodeUTF8 (String s) {
12312: StringBuilder sb = new StringBuilder ();
12313: int l = s.length ();
12314: for (int i = 0; i < l; i++) {
12315: int u = s.charAt (i);
12316: if (0xd800 <= u && u <= 0xdbff && i + 1 < l) {
12317: int v = s.charAt (i + 1);
12318: if (0xdc00 <= v && v <= 0xdfff) {
12319: u = 0x10000 + ((u & 0x3ff) << 10) + (v & 0x3ff);
12320: i++;
12321: }
12322: }
12323: if ((u & 0xffffff80) == 0) {
12324: sb.append ((char) u);
12325: } else if ((u & 0xfffff800) == 0) {
12326: u = (0x0000c080 |
12327: (u & 0x000007c0) << 2 |
12328: (u & 0x0000003f));
12329: sb.append ((char) (u >> 8)).append ((char) (u & 0xff));
12330: } else if ((u & 0xffff0000) == 0 && !(0xd800 <= u && u <= 0xdfff)) {
12331: u = (0x00e08080 |
12332: (u & 0x0000f000) << 4 |
12333: (u & 0x00000fc0) << 2 |
12334: (u & 0x0000003f));
12335: sb.append ((char) (u >> 16)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12336: } else if ((u & 0xffe00000) == 0) {
12337: u = (0xf0808080 |
12338: (u & 0x001c0000) << 6 |
12339: (u & 0x0003f000) << 4 |
12340: (u & 0x00000fc0) << 2 |
12341: (u & 0x0000003f));
12342: sb.append ((char) ((u >> 24) & 0xff)).append ((char) ((u >> 16) & 0xff)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12343: } else {
12344: sb.append ((char) 0xef).append ((char) 0xbf).append ((char) 0xbd);
12345: }
12346: }
12347: return sb.toString ();
12348: }
12349:
12350:
12351:
12352:
12353:
12354:
12355:
12356: public static String strDecodeUTF8 (String s) {
12357: StringBuilder sb = new StringBuilder ();
12358: int l = s.length ();
12359: for (int i = 0; i < l; i++) {
12360: int c = s.charAt (i) & 0xff;
12361: for (int k = ((c & 0x80) == 0x00 ? 0 :
12362: (c & 0xe0) == 0xc0 ? 1 :
12363: (c & 0xf0) == 0xe0 ? 2 :
12364: (c & 0xf8) == 0xf0 ? 3 :
12365: -1);
12366: --k >= 0; ) {
12367: c = c << 8 | (i + 1 < l ? s.charAt (++i) & 0xff : 0);
12368: }
12369: int u = ((c & 0xffffff80) == 0x00000000 ? c :
12370: (c & 0xffffe0c0) == 0x0000c080 ? ((c & 0x00001f00) >> 2 |
12371: (c & 0x0000003f)) :
12372: (c & 0xfff0c0c0) == 0x00e08080 ? ((c & 0x000f0000) >> 4 |
12373: (c & 0x00003f00) >> 2 |
12374: (c & 0x0000003f)) :
12375: (c & 0xf8c0c0c0) == 0xf0808080 ? ((c & 0x07000000) >> 6 |
12376: (c & 0x003f0000) >> 4 |
12377: (c & 0x00003f00) >> 2 |
12378: (c & 0x0000003f)) :
12379: 0xfffd);
12380: if (u <= 0x0000ffff) {
12381: sb.append (0xd800 <= u && u <= 0xdfff ? '\ufffd' :
12382: (char) u);
12383: } else if (u <= 0x0010ffff) {
12384: u -= 0x000010000;
12385: sb.append ((char) (0xd800 + ((u >> 10) & 0x3ff))).append ((char) (0xdc00 + (u & 0x3ff)));
12386: }
12387: }
12388: return sb.toString ();
12389: }
12390:
12391:
12392:
12393:
12394:
12395: public static final int[] IsURIChar = {
12396:
12397:
12398: 0b00000000_00000000_00000000_00000000,
12399: 0b00000000_00000110_11111111_11000000,
12400: 0b01111111_11111111_11111111_11100001,
12401: 0b01111111_11111111_11111111_11100010,
12402: };
12403: public static String strEncodeURI (String s) {
12404: s = strEncodeUTF8 (s);
12405: StringBuilder sb = new StringBuilder ();
12406: int l = s.length ();
12407: for (int i = 0; i < l; i++) {
12408: int c = s.charAt (i);
12409: if (c < 0x80 && IsURIChar[c >> 5] << c < 0) {
12410: sb.append ((char) c);
12411: } else {
12412: fmtHex2 (sb.append ('%'), c);
12413: }
12414: }
12415: return sb.toString ();
12416: }
12417:
12418:
12419:
12420:
12421:
12422: public static final byte[] strIsHexChar = {
12423:
12424: -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,
12425: -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,
12426: -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,
12427: -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,
12428: };
12429: public static String strDecodeURI (String s) {
12430: StringBuilder sb = new StringBuilder ();
12431: int l = s.length ();
12432: for (int i = 0; i < l; i++) {
12433: int c = s.charAt (i);
12434: if (c == '%' && i + 2 < l) {
12435: int d = s.charAt (i + 1);
12436: int e = s.charAt (i + 2);
12437: if (d < 0x80 && (d = strIsHexChar[d]) >= 0 &&
12438: e < 0x80 && (e = strIsHexChar[e]) >= 0) {
12439: sb.append ((char) (d << 4 | e));
12440: } else {
12441: sb.append ((char) c);
12442: }
12443: } else {
12444: sb.append ((char) c);
12445: }
12446: }
12447: return sb.toString ();
12448: }
12449:
12450:
12451:
12452:
12453:
12454:
12455:
12456:
12457: public static BufferedImage createImage (int width, int height, String pattern, int... rgbs) {
12458: BufferedImage image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
12459: int[] bitmap = ((DataBufferInt) image.getRaster ().getDataBuffer ()).getData ();
12460: int length = width * height;
12461: for (int i = 0; i < length; i++) {
12462: char c = pattern.charAt (i);
12463: bitmap[i] = rgbs[c < '0' ? 0 : Character.digit (c, 16)];
12464: }
12465: return image;
12466: }
12467:
12468:
12469:
12470: public static ImageIcon createImageIcon (int width, int height, String pattern, int... rgbs) {
12471: return new ImageIcon (createImage (width, height, pattern, rgbs));
12472: }
12473:
12474:
12475:
12476: public static TexturePaint createTexturePaint (int width, int height, String pattern, int... rgbs) {
12477: return new TexturePaint (createImage (width, height, pattern, rgbs), new Rectangle (0, 0, width, height));
12478: }
12479:
12480:
12481:
12482: public static BufferedImage loadImage (String name) {
12483: BufferedImage image = null;
12484: try {
12485: image = ImageIO.read (new File (name));
12486: } catch (Exception e) {
12487: }
12488: return image;
12489: }
12490:
12491:
12492:
12493:
12494: public static boolean saveImage (BufferedImage image, String name) {
12495: return saveImage (image, name, 0.75F);
12496: }
12497: public static boolean saveImage (BufferedImage image, String name, float quality) {
12498: int index = name.lastIndexOf (".");
12499: if (index < 0) {
12500: return false;
12501: }
12502: if (name.substring (index).equalsIgnoreCase (".ico")) {
12503: return saveIcon (name, image);
12504: }
12505: Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix (name.substring (index + 1));
12506: if (!iterator.hasNext ()) {
12507: return false;
12508: }
12509: ImageWriter imageWriter = iterator.next ();
12510: ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam ();
12511: if (imageWriteParam.canWriteCompressed ()) {
12512: imageWriteParam.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);
12513: imageWriteParam.setCompressionQuality (quality);
12514: }
12515: try {
12516: File file = new File (name);
12517: ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream (file);
12518: imageWriter.setOutput (imageOutputStream);
12519: imageWriter.write (null, new IIOImage (image, null, null), imageWriteParam);
12520: imageOutputStream.close ();
12521: } catch (Exception e) {
12522:
12523: return false;
12524: }
12525: return true;
12526: }
12527:
12528:
12529:
12530:
12531:
12532:
12533:
12534:
12535:
12536:
12537:
12538:
12539:
12540:
12541:
12542:
12543:
12544:
12545:
12546:
12547:
12548:
12549:
12550:
12551:
12552:
12553:
12554:
12555:
12556:
12557:
12558:
12559:
12560:
12561:
12562:
12563:
12564:
12565:
12566:
12567:
12568:
12569:
12570:
12571:
12572:
12573:
12574:
12575:
12576:
12577:
12578:
12579:
12580:
12581:
12582:
12583:
12584:
12585:
12586:
12587:
12588:
12589:
12590:
12591:
12592:
12593:
12594:
12595:
12596:
12597:
12598:
12599:
12600: public static boolean saveIcon (String fileName, BufferedImage... arrayImage) {
12601: int iconCount = arrayImage.length;
12602: int[][] arrayPaletTable = new int[iconCount][];
12603: int[] arrayPaletCount = new int[iconCount];
12604: int[] arrayPixelBits = new int[iconCount];
12605: int[] arrayPatternLineSize = new int[iconCount];
12606: int[] arrayMaskLineSize = new int[iconCount];
12607: int[] arrayImageSize = new int[iconCount];
12608: int[] arrayImageOffset = new int[iconCount];
12609: int fileSize = 6 + 16 * iconCount;
12610: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
12611: BufferedImage image = arrayImage[iconNumber];
12612: int width = image.getWidth ();
12613: int height = image.getHeight ();
12614:
12615: int[] paletTable = new int[256];
12616: int paletCount = 0;
12617: countPalet:
12618: for (int y = height - 1; y >= 0; y--) {
12619: for (int x = 0; x < width; x++) {
12620: int rgb = image.getRGB (x, y);
12621: if (rgb >>> 24 != 0xff) {
12622: continue;
12623: }
12624: int l = 0;
12625: int r = paletCount;
12626: while (l < r) {
12627: int m = l + r >> 1;
12628: if (paletTable[m] < rgb) {
12629: l = m + 1;
12630: } else {
12631: r = m;
12632: }
12633: }
12634: if (l == paletCount || paletTable[l] != rgb) {
12635: if (paletCount == 256) {
12636: paletCount = 0;
12637: break countPalet;
12638: }
12639: for (int i = paletCount; i > l; i--) {
12640: paletTable[i] = paletTable[i - 1];
12641: }
12642: paletTable[l] = rgb;
12643: paletCount++;
12644: }
12645: }
12646: }
12647: int pixelBits = (paletCount == 0 ? 24 :
12648: paletCount > 16 ? 8 :
12649: paletCount > 4 ? 4 :
12650: paletCount > 2 ? 2 :
12651: 1);
12652: int patternLineSize = pixelBits * width + 31 >> 5 << 2;
12653: int maskLineSize = width + 31 >> 5 << 2;
12654: int imageSize = 40 + 4 * paletCount + patternLineSize * height + maskLineSize * height;
12655: arrayPaletTable[iconNumber] = paletTable;
12656: arrayPaletCount[iconNumber] = paletCount;
12657: arrayPixelBits[iconNumber] = pixelBits;
12658: arrayPatternLineSize[iconNumber] = patternLineSize;
12659: arrayMaskLineSize[iconNumber] = maskLineSize;
12660: arrayImageSize[iconNumber] = imageSize;
12661: arrayImageOffset[iconNumber] = fileSize;
12662: fileSize += imageSize;
12663: }
12664: byte[] bb = new byte[fileSize];
12665:
12666: ByteArray.byaWiw (bb, 0, 0);
12667: ByteArray.byaWiw (bb, 2, 1);
12668: ByteArray.byaWiw (bb, 4, iconCount);
12669: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
12670: BufferedImage image = arrayImage[iconNumber];
12671: int width = image.getWidth ();
12672: int height = image.getHeight ();
12673: int[] paletTable = arrayPaletTable[iconNumber];
12674: int paletCount = arrayPaletCount[iconNumber];
12675: int pixelBits = arrayPixelBits[iconNumber];
12676: int patternLineSize = arrayPatternLineSize[iconNumber];
12677: int maskLineSize = arrayMaskLineSize[iconNumber];
12678: int imageSize = arrayImageSize[iconNumber];
12679: int imageOffset = arrayImageOffset[iconNumber];
12680:
12681: int o = 6 + 16 * iconNumber;
12682: ByteArray.byaWb (bb, o, width);
12683: ByteArray.byaWb (bb, o + 1, height);
12684: ByteArray.byaWb (bb, o + 2, paletCount);
12685: ByteArray.byaWb (bb, o + 3, 0);
12686: ByteArray.byaWiw (bb, o + 4, 1);
12687: ByteArray.byaWiw (bb, o + 6, pixelBits);
12688: ByteArray.byaWil (bb, o + 8, imageSize);
12689: ByteArray.byaWil (bb, o + 12, imageOffset);
12690:
12691: o = imageOffset;
12692: ByteArray.byaWil (bb, o, 40);
12693: ByteArray.byaWil (bb, o + 4, width);
12694: ByteArray.byaWil (bb, o + 8, height * 2);
12695: ByteArray.byaWiw (bb, o + 12, 1);
12696: ByteArray.byaWiw (bb, o + 14, pixelBits);
12697: ByteArray.byaWil (bb, o + 16, 0);
12698: ByteArray.byaWil (bb, o + 20, 0);
12699: ByteArray.byaWil (bb, o + 24, 0);
12700: ByteArray.byaWil (bb, o + 28, 0);
12701: ByteArray.byaWil (bb, o + 32, paletCount);
12702: ByteArray.byaWil (bb, o + 36, 0);
12703:
12704: o += 40;
12705: for (int i = 0; i < paletCount; i++) {
12706: ByteArray.byaWil (bb, o, paletTable[i] & 0x00ffffff);
12707: o += 4;
12708: }
12709:
12710: for (int y = height - 1; y >= 0; y--) {
12711: for (int x = 0; x < width; x++) {
12712: int rgb = image.getRGB (x, y);
12713: if (rgb >>> 24 != 0xff) {
12714: continue;
12715: }
12716: if (pixelBits == 24) {
12717: bb[o + 3 * x] = (byte) rgb;
12718: bb[o + 3 * x + 1] = (byte) (rgb >> 8);
12719: bb[o + 3 * x + 2] = (byte) (rgb >> 16);
12720: continue;
12721: }
12722: int l = 0;
12723: int r = paletCount;
12724: while (l < r) {
12725: int m = l + r >> 1;
12726: if (paletTable[m] < rgb) {
12727: l = m + 1;
12728: } else {
12729: r = m;
12730: }
12731: }
12732: if (l != 0) {
12733: if (pixelBits == 8) {
12734: bb[o + x] = (byte) l;
12735: } else if (pixelBits == 4) {
12736: bb[o + (x >> 1)] |= (byte) (l << ((~x & 1) << 2));
12737: } else if (pixelBits == 2) {
12738: bb[o + (x >> 2)] |= (byte) (l << ((~x & 3) << 1));
12739: } else {
12740: bb[o + (x >> 3)] |= (byte) (l << (~x & 7));
12741: }
12742: }
12743: }
12744: o += patternLineSize;
12745: }
12746:
12747: for (int y = height - 1; y >= 0; y--) {
12748: for (int x = 0; x < width; x++) {
12749: int rgb = image.getRGB (x, y);
12750: if (rgb >>> 24 != 0xff) {
12751: bb[o + (x >> 3)] |= (byte) (1 << (~x & 7));
12752: }
12753: }
12754: o += maskLineSize;
12755: }
12756: }
12757: return rscPutFile (fileName, bb, 0, fileSize);
12758: }
12759:
12760:
12761:
12762: }
12763:
12764:
12765: