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.01.12";
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 "4096 patterns":
3121: SpriteScreen.sprBankOnRequest = ((JCheckBoxMenuItem) source).isSelected ();
3122: break;
3123: case "Sprites displayed in 768x512":
3124: SpriteScreen.spr768x512Request = ((JCheckBoxMenuItem) source).isSelected ();
3125: break;
3126: case "BG1 displayed in 512x512":
3127: SpriteScreen.spr512bg1Request = ((JCheckBoxMenuItem) source).isSelected ();
3128: break;
3129: case "Row and column scroll":
3130: if (SpriteScreen.SPR_RC_SCROLL_ON) {
3131: SpriteScreen.sprRcScrollRequest = ((JCheckBoxMenuItem) source).isSelected ();
3132: }
3133: break;
3134: case "** Reset to default values":
3135: if (SpriteScreen.sprSpritesPerRaster != 32) {
3136: SpriteScreen.sprSpritesPerRaster = 32;
3137: sprrasSpinner.setIntValue (SpriteScreen.sprSpritesPerRaster);
3138: }
3139: break;
3140: }
3141: }
3142: };
3143: JMenu modificationMenu =
3144: Multilingual.mlnText (
3145: ComponentFactory.createMenu (
3146: "Modification",
3147: Multilingual.mlnText (
3148: ComponentFactory.createMenu (
3149: "Dot clock",
3150: Multilingual.mlnText (
3151: ComponentFactory.createCheckBoxMenuItem (pnlAdjustVsync, "Adjust to host refresh rate", modificationListener),
3152: "ja", "ホストのリフレッシュレートに合わせる"),
3153: ComponentFactory.createHorizontalBox (
3154: Box.createHorizontalStrut (20),
3155: refreshRateTextField,
3156: ComponentFactory.createLabel (" Hz"),
3157: Box.createHorizontalGlue ()
3158: ),
3159: ComponentFactory.createHorizontalSeparator (),
3160: ComponentFactory.createHorizontalBox (
3161: Box.createHorizontalStrut (20),
3162: Multilingual.mlnText (ComponentFactory.createLabel ("Dot clock oscillattor"), "ja", "ドットクロックオシレータ"),
3163: Box.createHorizontalGlue ()
3164: ),
3165: ComponentFactory.createHorizontalBox (
3166: Box.createHorizontalStrut (20),
3167: freqSpinner[0],
3168: ComponentFactory.createLabel (" Hz *"),
3169: Box.createHorizontalGlue ()
3170: ),
3171: ComponentFactory.createHorizontalBox (
3172: Box.createHorizontalStrut (20),
3173: freqSpinner[1],
3174: ComponentFactory.createLabel (" Hz *"),
3175: Box.createHorizontalGlue ()
3176: ),
3177: ComponentFactory.createHorizontalBox (
3178: Box.createHorizontalStrut (20),
3179: freqSpinner[2],
3180: ComponentFactory.createLabel (" Hz *"),
3181: Box.createHorizontalGlue ()
3182: ),
3183: Multilingual.mlnText (
3184: ComponentFactory.createMenuItem ("* Reset to default values", modificationListener),
3185: "ja", "* 初期値に戻す"),
3186: ComponentFactory.createHorizontalSeparator (),
3187: Multilingual.mlnText (
3188: ComponentFactory.createCheckBoxMenuItem (CRTC.crtEleventhBitRequest, "1024-dot non-interlaced", modificationListener),
3189: "ja", "1024 ドットノンインターレース"),
3190: Multilingual.mlnText (
3191: ComponentFactory.createCheckBoxMenuItem (CRTC.crtR00Bit0Zero, "Can write 0 to bit 0 of CRTC R00", modificationListener),
3192: "ja", "CRTC R00 のビット 0 に 0 を書き込める")
3193: ),
3194: "ja", "ドットクロック"),
3195: Multilingual.mlnText (
3196: ComponentFactory.createMenu (
3197: "Graphic screen",
3198: !CRTC.CRT_EXTENDED_GRAPHIC ? null : Multilingual.mlnText (
3199: ComponentFactory.createCheckBoxMenuItem (CRTC.crtExtendedGraphicRequest, "Extended graphic screen", modificationListener),
3200: "ja", "拡張グラフィック画面")
3201: ),
3202: "ja", "グラフィック画面"),
3203: Multilingual.mlnText (
3204: ComponentFactory.createMenu (
3205: "Text screen",
3206: Multilingual.mlnText (
3207: ComponentFactory.createCheckBoxMenuItem (CRTC.crtSphericalScrolling, "Spherical scrolling of text screen", modificationListener),
3208: "ja", "テキスト画面の球面スクロール")
3209: ),
3210: "ja", "テキスト画面"),
3211: Multilingual.mlnText (
3212: ComponentFactory.createMenu (
3213: "Sprite screen",
3214: Multilingual.mlnText (
3215: ComponentFactory.createRadioButtonMenuItem (
3216: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 128, "128 sprites", modificationListener),
3217: "ja", "128 枚のスプライト"),
3218: Multilingual.mlnText (
3219: ComponentFactory.createRadioButtonMenuItem (
3220: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 256, "256 sprites", modificationListener),
3221: "ja", "256 枚のスプライト"),
3222: Multilingual.mlnText (
3223: ComponentFactory.createRadioButtonMenuItem (
3224: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 512, "504 sprites", modificationListener),
3225: "ja", "504 枚のスプライト"),
3226: Multilingual.mlnText (
3227: ComponentFactory.createRadioButtonMenuItem (
3228: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 1024, "1016 sprites", modificationListener),
3229: "ja", "1016 枚のスプライト"),
3230:
3231:
3232:
3233:
3234: ComponentFactory.createHorizontalSeparator (),
3235: Multilingual.mlnText (
3236: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprBankOnRequest, "4096 patterns", modificationListener),
3237: "ja", "4096 個のパターン"),
3238: Multilingual.mlnText (
3239: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr768x512Request, "Sprites displayed in 768x512", modificationListener),
3240: "ja", "768x512 でスプライトを表示"),
3241: Multilingual.mlnText (
3242: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr512bg1Request, "BG1 displayed in 512x512", modificationListener),
3243: "ja", "512x512 で BG1 を表示"),
3244: !SpriteScreen.SPR_RC_SCROLL_ON ? null : Multilingual.mlnText (
3245: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprRcScrollRequest, "Row and column scroll", modificationListener),
3246: "ja", "行スクロールと列スクロール"),
3247: ComponentFactory.createHorizontalSeparator (),
3248: ComponentFactory.createHorizontalBox (
3249: Box.createHorizontalStrut (20),
3250: Multilingual.mlnText (ComponentFactory.createLabel ("Number of sprites per raster"), "ja", "ラスタあたりのスプライトの枚数"),
3251: Box.createHorizontalGlue ()
3252: ),
3253: ComponentFactory.createHorizontalBox (
3254: Box.createHorizontalStrut (20),
3255: sprrasSpinner,
3256: ComponentFactory.createLabel (" *"),
3257: Box.createHorizontalGlue ()
3258: ),
3259: Multilingual.mlnText (
3260: ComponentFactory.createMenuItem ("** Reset to default values", modificationListener),
3261: "ja", "** 初期値に戻す")
3262: ),
3263: "ja", "スプライト画面")
3264: ),
3265: "ja", "改造");
3266:
3267:
3268: mnbMenuBar = ComponentFactory.createMenuBar (
3269:
3270:
3271: mnbFileMenu = Multilingual.mlnText (
3272: ComponentFactory.createMenu (
3273: "File", 'F',
3274:
3275: FDC.fdcMenu,
3276:
3277: HDC.hdcMenu,
3278:
3279: SPC.spcMenu,
3280:
3281: HFS.hfsMenu,
3282: ComponentFactory.createHorizontalSeparator (),
3283: mnbQuitMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Quit", 'Q', MNB_MODIFIERS, listener), "ja", "終了")
3284: ),
3285: "ja", "ファイル"),
3286:
3287:
3288: mpuMenu,
3289:
3290:
3291: mnbDisplayMenu = Multilingual.mlnText (
3292: ComponentFactory.createMenu (
3293: "Display", 'D',
3294: mnbFullScreenMenuItem,
3295: mnbMaximizedMenuItem,
3296: mnbFitInWindowMenuItem,
3297: mnbFixedScaleMenuItem,
3298: ComponentFactory.createHorizontalBox (
3299: Box.createHorizontalStrut (20),
3300: pnlFixedSpinner,
3301: ComponentFactory.createLabel ("%"),
3302: Box.createHorizontalGlue ()
3303: ),
3304: ComponentFactory.createMenuItem ("50%", listener),
3305: ComponentFactory.createMenuItem ("75%", listener),
3306: ComponentFactory.createMenuItem ("100%", listener),
3307: ComponentFactory.createMenuItem ("150%", listener),
3308: ComponentFactory.createMenuItem ("200%", listener),
3309:
3310: rotationMenu,
3311:
3312: aspectMenu,
3313:
3314: Multilingual.mlnText (
3315: ComponentFactory.createMenu (
3316: "Interpolation algorithm",
3317: Multilingual.mlnText (
3318: ComponentFactory.createRadioButtonMenuItem (
3319: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
3320: "Nearest neighbor", listener),
3321: "ja", "最近傍補間"),
3322: Multilingual.mlnText (
3323: ComponentFactory.createRadioButtonMenuItem (
3324: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR,
3325: "Bilinear", listener),
3326: "ja", "線形補間"),
3327: Multilingual.mlnText (
3328: ComponentFactory.createRadioButtonMenuItem (
3329: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC,
3330: "Bicubic", listener),
3331: "ja", "三次補間")
3332: ),
3333: "ja", "補間アルゴリズム"),
3334:
3335: scanlineMenu,
3336: !PNL_USE_CANVAS ? null : Multilingual.mlnText (
3337: ComponentFactory.createCheckBoxMenuItem (pnlUseCanvasRequest, "Use canvas", listener),
3338: "ja", "キャンバスを使う"),
3339:
3340: !CRTC.CRT_ENABLE_INTERMITTENT ? null : Multilingual.mlnText (
3341: ComponentFactory.createMenu (
3342: "Intermittent drawing",
3343: Multilingual.mlnText (
3344: ComponentFactory.createRadioButtonMenuItem (
3345: intermittentGroup, CRTC.crtIntermittentInterval == 0, "Draw all changed pictures", listener),
3346: "ja", "変化した画像をすべて描画する"),
3347: Multilingual.mlnText (
3348: ComponentFactory.createRadioButtonMenuItem (
3349: intermittentGroup, CRTC.crtIntermittentInterval == 1, "Draw a changed picture once every two times", listener),
3350: "ja", "変化した画像を 2 回に 1 回描画する"),
3351: Multilingual.mlnText (
3352: ComponentFactory.createRadioButtonMenuItem (
3353: intermittentGroup, CRTC.crtIntermittentInterval == 2, "Draw a changed picture once every three times", listener),
3354: "ja", "変化した画像を 3 回に 1 回描画する"),
3355: Multilingual.mlnText (
3356: ComponentFactory.createRadioButtonMenuItem (
3357: intermittentGroup, CRTC.crtIntermittentInterval == 3, "Draw a changed picture once every four times", listener),
3358: "ja", "変化した画像を 4 回に 1 回描画する"),
3359: Multilingual.mlnText (
3360: ComponentFactory.createRadioButtonMenuItem (
3361: intermittentGroup, CRTC.crtIntermittentInterval == 4, "Draw a changed picture once every five times", listener),
3362: "ja", "変化した画像を 5 回に 1 回描画する")
3363: ),
3364: "ja", "間欠描画"),
3365:
3366: !PNL_STEREOSCOPIC_ON ? null : ComponentFactory.createHorizontalSeparator (),
3367: mnbStereoscopicMenuItem = !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3368: ComponentFactory.createCheckBoxMenuItem (pnlStereoscopicOn, "Stereoscopic viewing", 'T', listener),
3369: "ja", "立体視"),
3370: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3371: ComponentFactory.createMenu (
3372: "Stereoscopic settings",
3373: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3374: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3375: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING,
3376: "Naked-eye crossing", listener),
3377: "ja", "裸眼交差法"),
3378: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3379: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3380: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL,
3381: "Naked-eye parallel", listener),
3382: "ja", "裸眼平行法"),
3383: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3384: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3385: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE,
3386: "Side-by-side", listener),
3387: "ja", "サイドバイサイド"),
3388: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3389: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3390: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM,
3391: "Top-and-bottom", listener),
3392: "ja", "トップアンドボトム")
3393: ),
3394: "ja", "立体視設定"),
3395:
3396: ComponentFactory.createHorizontalSeparator (),
3397: GIFAnimation.gifStartRecordingMenuItem,
3398: GIFAnimation.gifSettingsMenu,
3399:
3400: ComponentFactory.createHorizontalSeparator (),
3401: modificationMenu,
3402:
3403: SpritePatternViewer.SPV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Sprite pattern viewer", listener), "ja", "スプライトパターンビュア") : null,
3404: PaletteViewer.PLV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Palette viewer", listener), "ja", "パレットビュア") : null,
3405: ScreenModeTest.SMT_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Screen mode test", listener), "ja", "表示モードテスト") : null
3406: ),
3407: "ja", "画面"),
3408:
3409:
3410: mnbSoundMenu = ComponentFactory.setEnabled (
3411: Multilingual.mlnText (
3412: ComponentFactory.createMenu (
3413: "Sound", 'S',
3414: mnbPlayMenuItem = ComponentFactory.setEnabled (
3415: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (SoundSource.sndPlayOn, "Play", 'P', MNB_MODIFIERS, listener), "ja", "音声出力"),
3416: SoundSource.sndLine != null),
3417:
3418:
3419:
3420: ComponentFactory.createHorizontalBox (
3421: Box.createHorizontalGlue (),
3422: Multilingual.mlnText (ComponentFactory.createLabel ("Volume "), "ja", "音量 "),
3423: mnbVolumeLabel = ComponentFactory.createLabel (String.valueOf (SoundSource.sndVolume)),
3424: Box.createHorizontalGlue ()
3425: ),
3426:
3427:
3428: ComponentFactory.setPreferredSize (
3429: ComponentFactory.createHorizontalSlider (
3430: 0,
3431: SoundSource.SND_VOLUME_MAX,
3432: SoundSource.sndVolume,
3433: SoundSource.SND_VOLUME_STEP,
3434: 1,
3435: new ChangeListener () {
3436: @Override public void stateChanged (ChangeEvent ce) {
3437: SoundSource.sndSetVolume (((JSlider) ce.getSource ()).getValue ());
3438: }
3439: }),
3440: LnF.lnfFontSize * 18, LnF.lnfFontSize * 2 + 28),
3441: Multilingual.mlnText (
3442: ComponentFactory.createMenu (
3443: "Sound interpolation",
3444: Multilingual.mlnText (
3445: ComponentFactory.createRadioButtonMenuItem (
3446: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.THINNING_STEREO,
3447: "Sound thinning", listener),
3448: "ja", "音声 間引き"),
3449: Multilingual.mlnText (
3450: ComponentFactory.createRadioButtonMenuItem (
3451: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_STEREO,
3452: "Sound linear interpolation", listener),
3453: "ja", "音声 線形補間"),
3454: ComponentFactory.setEnabled (
3455: Multilingual.mlnText (
3456: ComponentFactory.createRadioButtonMenuItem (
3457: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000,
3458: "Sound piecewise-constant area interpolation", listener),
3459: "ja", "音声 区分定数面積補間"),
3460: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000),
3461: ComponentFactory.setEnabled (
3462: Multilingual.mlnText (
3463: ComponentFactory.createRadioButtonMenuItem (
3464: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000,
3465: "Sound linear area interpolation", listener),
3466: "ja", "音声 線形面積補間"),
3467: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000)
3468: ),
3469: "ja", "音声補間"),
3470: Multilingual.mlnText (ComponentFactory.createMenuItem ("Sound monitor", listener), "ja", "音声モニタ"),
3471:
3472: ComponentFactory.createHorizontalSeparator (),
3473:
3474: ComponentFactory.setEnabled (
3475: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (OPM.opmOutputMask != 0, "OPM output", listener), "ja", "OPM 出力"),
3476: SoundSource.sndLine != null),
3477: !OPMLog.OLG_ON ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("OPM log", listener), "ja", "OPM ログ"),
3478:
3479: ComponentFactory.createHorizontalSeparator (),
3480:
3481: ComponentFactory.setEnabled (
3482: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ADPCM.pcmOutputOn, "PCM output", listener), "ja", "PCM 出力"),
3483: SoundSource.sndLine != null),
3484: Multilingual.mlnText (
3485: ComponentFactory.createMenu (
3486: "PCM interpolation",
3487: Multilingual.mlnText (
3488: ComponentFactory.createRadioButtonMenuItem (
3489: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_CONSTANT,
3490: "PCM piecewise-constant interpolation", listener),
3491: "ja", "PCM 区分定数補間"),
3492: Multilingual.mlnText (
3493: ComponentFactory.createRadioButtonMenuItem (
3494: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_LINEAR,
3495: "PCM linear interpolation", listener),
3496: "ja", "PCM 線形補間"),
3497: Multilingual.mlnText (
3498: ComponentFactory.createRadioButtonMenuItem (
3499: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_HERMITE,
3500: "PCM hermite interpolation", listener),
3501: "ja", "PCM エルミート補間")
3502: ),
3503: "ja", "PCM 補間"),
3504: Multilingual.mlnText (
3505: ComponentFactory.createMenu (
3506: "PCM source oscillator frequency",
3507: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 0, "PCM 8MHz/4MHz", listener),
3508: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 1, "PCM 8MHz/16MHz", listener)
3509: ),
3510: "ja", "PCM 原発振周波数"),
3511:
3512: !MercuryUnit.MU4_ON ? null :
3513: ComponentFactory.createHorizontalSeparator (),
3514: !MercuryUnit.MU4_ON ? null :
3515: ComponentFactory.createCheckBoxMenuItem (
3516: MercuryUnit.mu4OnRequest,
3517: "Mercury-Unit V4 (MK-MU1)",
3518: listener),
3519: !MercuryUnit.MU4_ON ? null :
3520: Multilingual.mlnText (
3521: ComponentFactory.createCheckBoxMenuItem (
3522: MercuryUnit.mu4OutputEnable,
3523: "MU4 output",
3524: listener),
3525: "ja", "MU4 出力")
3526: ),
3527: "ja", "音声"),
3528: SoundSource.sndLine != null),
3529:
3530:
3531: mnbInputMenu = Multilingual.mlnText (
3532: ComponentFactory.createMenu (
3533: "Input", 'I',
3534: mnbPasteMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Paste", 'V', MNB_MODIFIERS, listener), "ja", "貼り付け"),
3535: CONDevice.conSettingsMenu,
3536: TextCopy.txcMakeMenuItem (),
3537: TextCopy.txcMakeSettingMenu (),
3538: ComponentFactory.createHorizontalSeparator (),
3539: mnbNoKeyboardMenuItem = Multilingual.mlnText (
3540: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, !Keyboard.kbdOn, "No keyboard", 'K', MNB_MODIFIERS, listener),
3541: "ja", "キーボードなし"),
3542: mnbStandardKeyboardMenuItem = Multilingual.mlnText (
3543: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_STANDARD_TYPE, "Standard keyboard", listener),
3544: "ja", "標準キーボード"),
3545: mnbCompactKeyboardMenuItem = Multilingual.mlnText (
3546: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_COMPACT_TYPE, "Compact keyboard", listener),
3547: "ja", "コンパクトキーボード"),
3548: Multilingual.mlnText (
3549: ComponentFactory.createCheckBoxMenuItem (pnlHideKeyboard, "Hide keyboard in full screen", listener),
3550: "ja", "全画面表示のときキーボードを隠す"),
3551: Multilingual.mlnText (ComponentFactory.createMenuItem ("Key assignments", listener), "ja", "キー割り当て"),
3552: ButtonFunction.bfnMakeMenuItem (),
3553: SRAM.smrRepeatDelayMenu,
3554: SRAM.smrRepeatIntervalMenu,
3555: !Keyboard.KBD_ZKEY_ON ? null : Keyboard.kbdZKeyMenu,
3556: ComponentFactory.createHorizontalSeparator (),
3557: Mouse.musSeamlessMouseCheckBox,
3558: Mouse.musFollowScrollCheckBox,
3559: Mouse.musCtrlRightCheckBox,
3560: Mouse.musEdgeAccelerationCheckBox,
3561: Mouse.musMouseCursorSpeedBox,
3562: Mouse.musSpeedSlider,
3563: Mouse.musHostsPixelUnitsCheckBox,
3564: ComponentFactory.createHorizontalSeparator (),
3565: Multilingual.mlnText (ComponentFactory.createMenuItem ("Joystick port settings", listener), "ja", "ジョイスティックポート設定")
3566: ),
3567: "ja", "入力"),
3568:
3569:
3570: mnbConfigMenu = Multilingual.mlnText (
3571: ComponentFactory.createMenu (
3572: "Config", 'G',
3573: Multilingual.mlnText (ComponentFactory.createMenuItem ("RS-232C and terminal", listener), "ja", "RS-232C とターミナル"),
3574: Multilingual.mlnText (
3575: ComponentFactory.createMenu (
3576: "Debug",
3577: Multilingual.mlnText (ComponentFactory.createMenuItem ("Console", listener), "ja", "コンソール"),
3578: Multilingual.mlnText (ComponentFactory.createMenuItem ("Register list", listener), "ja", "レジスタリスト"),
3579: Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble list", listener), "ja", "逆アセンブルリスト"),
3580: Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory dump list", listener), "ja", "メモリダンプリスト"),
3581: Multilingual.mlnText (ComponentFactory.createMenuItem ("Logical space monitor", listener), "ja", "論理空間モニタ"),
3582: Multilingual.mlnText (ComponentFactory.createMenuItem ("Physical space monitor", listener), "ja", "物理空間モニタ"),
3583: ATCMonitor.ACM_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Address translation caches monitor", listener), "ja", "アドレス変換キャッシュモニタ") : null,
3584: BranchLog.BLG_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Branch log", listener), "ja", "分岐ログ") : null,
3585: ProgramFlowVisualizer.PFV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Program flow visualizer", listener), "ja", "プログラムフロービジュアライザ") : null,
3586: RasterBreakPoint.RBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Raster break point", listener), "ja", "ラスタブレークポイント") : null,
3587: DataBreakPoint.DBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Data break point", listener), "ja", "データブレークポイント") : null,
3588: RootPointerList.RTL_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Root pointer list", listener), "ja", "ルートポインタリスト") : null,
3589: ComponentFactory.createHorizontalSeparator (),
3590: SRAM.smrRomdbMenu
3591: ),
3592: "ja", "デバッグ"),
3593: SRAM.smrBootMenu,
3594: mainMemoryMenu,
3595: highMemoryMenu,
3596: localMemoryMenu,
3597: xellent30Menu,
3598: ComponentFactory.createHorizontalSeparator (),
3599: ComponentFactory.createMenu (
3600: "RTC",
3601: Multilingual.mlnText (
3602: ComponentFactory.createMenuItem ("Adjust clock to host", listener),
3603: "ja", "時計をホストに合わせる")
3604: ),
3605: SRAM.smrMenu,
3606: Settings.sgsMenu,
3607: ComponentFactory.createHorizontalSeparator (),
3608: Multilingual.mlnText (ComponentFactory.createMenuItem ("Printer", listener), "ja", "プリンタ"),
3609: ROM.romMenu,
3610: Multilingual.mlnText (
3611: ComponentFactory.createMenu (
3612: "Miscellaneous",
3613: SlowdownTest.sdtCheckBoxMenuItem,
3614: SlowdownTest.sdtBox,
3615: Multilingual.mlnText (
3616: ComponentFactory.createCheckBoxMenuItem (Mouse.musOutputButtonStatus, "Print key and mouse button events", listener),
3617: "ja", "キーとマウスのボタンのイベントを表示"),
3618: Z8530.SCC_DEBUG_ON ? Z8530.sccDebugMenu : null
3619: ),
3620: "ja", "その他"),
3621: ComponentFactory.createHorizontalSeparator (),
3622: Multilingual.mlnText (
3623: ComponentFactory.createMenuItem ("Java runtime environment information", listener),
3624: "ja", "Java 実行環境の情報"),
3625: Multilingual.mlnText (
3626: ComponentFactory.createMenuItem ("Version information", listener),
3627: "ja", "バージョン情報"),
3628: Multilingual.mlnText (
3629: ComponentFactory.createMenu (
3630: "License",
3631: Multilingual.mlnText (ComponentFactory.createMenuItem ("XEiJ License", listener), "ja", "XEiJ 使用許諾条件"),
3632: Multilingual.mlnText (ComponentFactory.createMenuItem ("FSHARP License", listener), "ja", "FSHARP 許諾条件"),
3633: Multilingual.mlnText (ComponentFactory.createMenuItem ("ymfm License", listener), "ja", "ymfm License"),
3634: Multilingual.mlnText (ComponentFactory.createMenuItem ("jSerialComm License", listener), "ja", "jSerialComm License")
3635: ),
3636: "ja", "使用許諾条件")
3637: ),
3638: "ja", "設定"),
3639:
3640: mnbMakeLanguageMenu (),
3641:
3642:
3643: Box.createHorizontalGlue (),
3644: ComponentFactory.createVerticalBox (
3645: Box.createVerticalGlue (),
3646: Indicator.indBox,
3647: Box.createVerticalGlue ()
3648: ),
3649: Box.createHorizontalGlue ()
3650:
3651: );
3652: }
3653:
3654:
3655:
3656:
3657:
3658:
3659:
3660: public static boolean frmIsActive;
3661:
3662:
3663: public static JFrame frmFrame;
3664: public static int frmMarginWidth;
3665: public static int frmMarginHeight;
3666: public static Dimension frmMinimumSize;
3667:
3668:
3669: public static GraphicsDevice frmScreenDevice;
3670:
3671:
3672: public static DropTarget frmDropTarget;
3673:
3674:
3675:
3676: public static void frmInit () {
3677: frmIsActive = false;
3678: frmScreenDevice = GraphicsEnvironment.getLocalGraphicsEnvironment ().getDefaultScreenDevice ();
3679: pnlIsFullScreenSupported = frmScreenDevice.isFullScreenSupported ();
3680: }
3681:
3682:
3683:
3684: public static void frmMake () {
3685:
3686:
3687: frmFrame = ComponentFactory.createRestorableFrame (
3688: Settings.SGS_FRM_FRAME_KEY,
3689: PRG_TITLE + " version " + PRG_VERSION,
3690: mnbMenuBar,
3691: pnlPanel);
3692: frmUpdateTitle ();
3693: frmFrame.setIconImage (LnF.LNF_ICON_IMAGE_48);
3694: frmFrame.setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);
3695:
3696:
3697:
3698:
3699: frmMarginWidth = frmFrame.getWidth () - pnlPanel.getWidth ();
3700: frmMarginHeight = frmFrame.getHeight () - pnlPanel.getHeight ();
3701: frmMinimumSize = new Dimension (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
3702: frmFrame.setMinimumSize (frmMinimumSize);
3703:
3704:
3705:
3706: frmDropTarget = new DropTarget (pnlPanel, DnDConstants.ACTION_COPY, new DropTargetAdapter () {
3707: @Override public void dragOver (DropTargetDragEvent dtde) {
3708: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
3709: dtde.acceptDrag (DnDConstants.ACTION_COPY);
3710: return;
3711: }
3712: dtde.rejectDrag ();
3713: }
3714: @Override public void drop (DropTargetDropEvent dtde) {
3715: try {
3716: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
3717: dtde.acceptDrop (DnDConstants.ACTION_COPY);
3718: boolean reset = false;
3719: int fdu0 = -1;
3720: int fdu = 0;
3721: int hdu0 = -1;
3722: int hdu = 0;
3723: int scu0 = -1;
3724: int scu = 0;
3725: int hfu0 = -1;
3726: int hfu = 0;
3727: for (Object o : (java.util.List) dtde.getTransferable ().getTransferData (DataFlavor.javaFileListFlavor)) {
3728: if (o instanceof File) {
3729: File file = (File) o;
3730: if (file.isFile ()) {
3731: if (FDC.fdcFileFilter.accept (file)) {
3732: if (fdu < FDC.FDC_MAX_UNITS &&
3733: FDC.fdcUnitArray[fdu].insert (file.getPath (), false)) {
3734: if (fdu0 < 0) {
3735: fdu0 = fdu;
3736: }
3737: fdu++;
3738: continue;
3739: }
3740: }
3741: if (HDC.hdcFileFilter.accept (file)) {
3742: if (hdu < 16 &&
3743: HDC.hdcUnitArray[hdu].insert (file.getPath (), false)) {
3744: if (hdu0 < 0) {
3745: hdu0 = hdu;
3746: }
3747: hdu++;
3748: continue;
3749: }
3750: }
3751: if (SPC.spcFileFilter.accept (file)) {
3752: if (scu < 16 &&
3753: SPC.spcUnitArray[scu].insert (file.getPath (), false)) {
3754: if (scu0 < 0) {
3755: scu0 = scu;
3756: }
3757: scu++;
3758: continue;
3759: }
3760: }
3761: }
3762: if (HFS.hfsFileFilter.accept (file)) {
3763: if (hfu < HFS.HFS_MAX_UNITS &&
3764: HFS.hfsUnitArray[hfu].insert (file.getPath (), false)) {
3765: if (hfu0 < 0) {
3766: hfu0 = hfu;
3767: }
3768: hfu++;
3769: continue;
3770: }
3771: }
3772: }
3773: reset = false;
3774: }
3775: dtde.dropComplete (true);
3776: if (reset) {
3777: if (fdu0 >= 0) {
3778: mpuReset (0x9070 | fdu0 << 8, -1);
3779: } else if (hdu0 >= 0) {
3780: mpuReset (0x8000 | hdu0 << 8, -1);
3781: } else if (scu0 >= 0) {
3782: mpuReset (0xa000, SPC.SPC_HANDLE_EX + (scu0 << 2));
3783: } else if (hfu0 >= 0) {
3784: HFS.hfsBootUnit = hfu0;
3785: mpuReset (0xa000, HFS.HFS_BOOT_HANDLE);
3786: }
3787: }
3788: return;
3789: }
3790: } catch (UnsupportedFlavorException ufe) {
3791:
3792: } catch (IOException ioe) {
3793:
3794: }
3795: dtde.rejectDrop();
3796: }
3797: });
3798:
3799: }
3800:
3801:
3802:
3803: public static void frmUpdateTitle () {
3804: frmFrame.setTitle ((currentAccelerator == ACCELERATOR_HYBRID ? "X68000 Hybrid" :
3805: currentModel.getName () +
3806: (currentAccelerator == ACCELERATOR_XELLENT30 ? " with Xellent30" :
3807: currentAccelerator == ACCELERATOR_060TURBO ? " with 060turbo" :
3808: currentAccelerator == ACCELERATOR_060TURBOPRO ? " with 060turboPRO" : "")) +
3809: " - " + PRG_TITLE + " version " + PRG_VERSION);
3810: }
3811:
3812:
3813:
3814: public static void frmStart () {
3815:
3816:
3817:
3818:
3819:
3820:
3821:
3822:
3823: ComponentFactory.addListener (
3824: frmFrame,
3825: new WindowAdapter () {
3826: @Override public void windowActivated (WindowEvent we) {
3827: frmIsActive = true;
3828: }
3829: @Override public void windowClosing (WindowEvent we) {
3830: prgTini ();
3831: }
3832: @Override public void windowDeactivated (WindowEvent we) {
3833: frmIsActive = false;
3834:
3835: }
3836: @Override public void windowOpened (WindowEvent we) {
3837: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3838: pnlFixedRate = pnlGetRefreshRate ();
3839: }
3840: }
3841: });
3842:
3843:
3844:
3845:
3846: ComponentFactory.addListener (
3847: frmFrame,
3848: new ComponentAdapter () {
3849: @Override public void componentMoved (ComponentEvent ce) {
3850: Point p = pnlPanel.getLocationOnScreen ();
3851: pnlGlobalX = p.x;
3852: pnlGlobalY = p.y;
3853: }
3854: @Override public void componentResized (ComponentEvent ce) {
3855: Point p = pnlPanel.getLocationOnScreen ();
3856: pnlGlobalX = p.x;
3857: pnlGlobalY = p.y;
3858: }
3859: });
3860:
3861: }
3862:
3863:
3864:
3865:
3866:
3867:
3868: public static BufferedImage clpClipboardImage;
3869: public static String clpClipboardString;
3870: public static Clipboard clpClipboard;
3871: public static Transferable clpImageContents;
3872: public static Transferable clpStringContents;
3873: public static ClipboardOwner clpClipboardOwner;
3874: public static boolean clpIsClipboardOwner;
3875:
3876:
3877:
3878:
3879: public static void clpMake () {
3880: Toolkit toolkit = Toolkit.getDefaultToolkit ();
3881: clpClipboard = null;
3882: try {
3883: clpClipboard = toolkit.getSystemClipboard ();
3884: } catch (Exception e) {
3885: return;
3886: }
3887: clpClipboardImage = null;
3888: clpClipboardString = null;
3889: clpImageContents = new Transferable () {
3890: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
3891: if (flavor == DataFlavor.imageFlavor) {
3892: return clpClipboardImage;
3893: } else {
3894: throw new UnsupportedFlavorException (flavor);
3895: }
3896: }
3897: public DataFlavor[] getTransferDataFlavors () {
3898: return new DataFlavor[] { DataFlavor.imageFlavor };
3899: }
3900: public boolean isDataFlavorSupported (DataFlavor flavor) {
3901: return flavor == DataFlavor.imageFlavor;
3902: }
3903: };
3904: clpStringContents = new Transferable () {
3905: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
3906: if (flavor == DataFlavor.stringFlavor) {
3907: return clpClipboardString;
3908: } else {
3909: throw new UnsupportedFlavorException (flavor);
3910: }
3911: }
3912: public DataFlavor[] getTransferDataFlavors () {
3913: return new DataFlavor[] { DataFlavor.stringFlavor };
3914: }
3915: public boolean isDataFlavorSupported (DataFlavor flavor) {
3916: return flavor == DataFlavor.stringFlavor;
3917: }
3918: };
3919: clpIsClipboardOwner = false;
3920:
3921:
3922: clpClipboardOwner = new ClipboardOwner () {
3923: @Override public void lostOwnership (Clipboard clipboard, Transferable contents) {
3924: clpIsClipboardOwner = false;
3925: }
3926: };
3927:
3928:
3929: clpClipboard.addFlavorListener (new FlavorListener () {
3930: @Override public void flavorsChanged (FlavorEvent fe) {
3931: boolean available = false;
3932: try {
3933: available = clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor);
3934: } catch (IllegalStateException ise) {
3935: }
3936: if (mnbPasteMenuItem != null) {
3937: mnbPasteMenuItem.setEnabled (available);
3938: }
3939: }
3940: });
3941: if (!clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor)) {
3942: if (mnbPasteMenuItem != null) {
3943: mnbPasteMenuItem.setEnabled (false);
3944: }
3945: }
3946: }
3947:
3948:
3949:
3950: public static void clpCopy (String s) {
3951: if (clpClipboard != null && s != null) {
3952: clpClipboardString = s;
3953: try {
3954: clpClipboard.setContents (clpStringContents, clpClipboardOwner);
3955: clpIsClipboardOwner = true;
3956: } catch (Exception e) {
3957: return;
3958: }
3959: }
3960: }
3961:
3962:
3963:
3964:
3965:
3966:
3967:
3968:
3969:
3970:
3971:
3972:
3973:
3974:
3975:
3976:
3977:
3978:
3979:
3980:
3981:
3982:
3983:
3984: public static int xt3DIPSWRequest;
3985: public static int xt3DIPSW;
3986: public static int xt3PortAddress;
3987:
3988:
3989: public static int xt3MemorySizeRequest;
3990: public static int xt3MemorySize;
3991: public static boolean xt3MemoryEnabled;
3992: public static int xt3MemoryPosition;
3993: public static int xt3MemoryStart;
3994: public static final byte[] xt3MemoryArray = new byte[1 << 20];
3995: public static boolean xt3MemorySave;
3996:
3997:
3998: public static int xt3SavedPC;
3999: public static final int[] xt3SavedRn = new int[16];
4000:
4001:
4002: public static void xt3Init () {
4003:
4004:
4005: xt3DIPSWRequest = Math.max (0, Math.min (3, Settings.sgsGetInt ("xt3dipsw")));
4006: xt3DIPSW = xt3DIPSWRequest;
4007:
4008:
4009: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4010:
4011:
4012: int memoryKB = Settings.sgsGetInt ("xt3memorykb");
4013: if (!(memoryKB == 1 << 8 || memoryKB == 1 << 10)) {
4014: memoryKB = 1 << 8;
4015: }
4016: xt3MemorySizeRequest = memoryKB << 10;
4017: xt3MemorySize = xt3MemorySizeRequest;
4018:
4019:
4020: xt3MemoryEnabled = false;
4021:
4022:
4023: xt3MemoryPosition = 11 << 20;
4024:
4025:
4026: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4027:
4028:
4029:
4030: byte[] memoryArray = Settings.sgsGetData ("xt3memorydata");
4031: Arrays.fill (xt3MemoryArray,
4032: (byte) 0);
4033: if (memoryArray.length != 0) {
4034: System.arraycopy (memoryArray, 0,
4035: xt3MemoryArray, 0,
4036: Math.min (memoryArray.length, xt3MemoryArray.length));
4037: if (memoryArray.length < xt3MemoryArray.length) {
4038: Arrays.fill (xt3MemoryArray,
4039: memoryArray.length,
4040: xt3MemoryArray.length,
4041: (byte) 0);
4042: }
4043: }
4044:
4045:
4046: xt3MemorySave = Settings.sgsGetOnOff ("xt3memorysave");
4047:
4048:
4049: xt3SavedPC = 0;
4050:
4051: Arrays.fill (xt3SavedRn, 0);
4052:
4053: xt3Reset ();
4054: }
4055:
4056:
4057: public static void xt3Tini () {
4058:
4059:
4060: Settings.sgsPutInt ("xt3dipsw", xt3DIPSW);
4061:
4062:
4063: Settings.sgsPutInt ("xt3memorykb", xt3MemorySizeRequest >> 10);
4064:
4065:
4066: boolean zero = true;
4067: if (xt3MemorySave) {
4068: for (int i = 0; i < 1 << 20; i++) {
4069: if (xt3MemoryArray[i] != 0) {
4070: zero = false;
4071: break;
4072: }
4073: }
4074: }
4075: Settings.sgsCurrentMap.put ("xt3memorydata",
4076: zero ? "" :
4077: ByteArray.byaEncodeBase64 (ByteArray.byaEncodeGzip (xt3MemoryArray, 0, 1 << 20)));
4078:
4079:
4080: Settings.sgsPutOnOff ("xt3memorysave", xt3MemorySave);
4081:
4082: }
4083:
4084:
4085: public static void xt3Reset () {
4086:
4087:
4088: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4089:
4090:
4091: xt3MemorySize = xt3MemorySizeRequest;
4092:
4093:
4094: xt3MemoryEnabled = false;
4095:
4096:
4097: xt3MemoryPosition = 11 << 20;
4098:
4099:
4100: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4101:
4102:
4103: xt3SavedPC = 0;
4104: Arrays.fill (xt3SavedRn, 0);
4105:
4106: }
4107:
4108:
4109: public static int xt3PortRead () {
4110: return (currentIsSecond ? 4 : 0) | (xt3MemoryEnabled ? 2 : 0) | (xt3MemoryPosition == 11 << 20 ? 0 : 1);
4111: }
4112:
4113:
4114: public static void xt3PortWrite (int d) {
4115: boolean nextIsSecond = (d & 4) != 0;
4116: boolean memoryEnabled = (d & 2) != 0;
4117: int memoryPosition = (d & 1) == 0 ? 11 << 20 : 15 << 20;
4118:
4119: if (xt3MemoryEnabled != memoryEnabled ||
4120: xt3MemoryPosition != memoryPosition) {
4121: if (xt3MemoryEnabled) {
4122: if (xt3MemoryPosition == 11 << 20) {
4123: if (MainMemory.mmrMemorySizeCurrent < 12 << 20) {
4124: busSuper (MemoryMappedDevice.MMD_NUL, (12 << 20) - xt3MemorySize, 12 << 20);
4125: } else {
4126: busUser (MemoryMappedDevice.MMD_MMR, (12 << 20) - xt3MemorySize, 12 << 20);
4127: }
4128: } else {
4129: busSuper (MemoryMappedDevice.MMD_ROM, (16 << 20) - xt3MemorySize, 16 << 20);
4130: }
4131: }
4132: xt3MemoryEnabled = memoryEnabled;
4133: xt3MemoryPosition = memoryPosition;
4134: if (xt3MemoryEnabled) {
4135: if (xt3MemoryPosition == 11 << 20) {
4136: busUser (MemoryMappedDevice.MMD_XTM, (12 << 20) - xt3MemorySize, 12 << 20);
4137: } else {
4138: busUser (MemoryMappedDevice.MMD_XTM, (16 << 20) - xt3MemorySize, 16 << 20);
4139: }
4140: }
4141: }
4142:
4143: if (currentIsSecond != nextIsSecond) {
4144:
4145: if (nextIsSecond) {
4146:
4147:
4148: xt3SavedPC = regPC;
4149: System.arraycopy (regRn, 0, xt3SavedRn, 0, 16);
4150:
4151:
4152: if (mpuTask != null) {
4153: mpuClockLimit = 0L;
4154: System.out.println (Multilingual.mlnJapanese ?
4155: Model.MPU_NAMES[currentFirstMPU] + " を停止します" :
4156: Model.MPU_NAMES[currentFirstMPU] + " stops");
4157: mpuTask.cancel ();
4158: mpuTask = null;
4159: }
4160:
4161:
4162: tmrTimer.schedule (new TimerTask () {
4163: @Override public void run () {
4164:
4165:
4166: currentIsSecond = true;
4167: currentMPU = currentSecondMPU;
4168: mpuSetCurrentClock (specifiedSecondClock);
4169:
4170: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
4171: MC68EC030.m30DivZeroVFlag = false;
4172: }
4173:
4174: RegisterList.drpSetMPU ();
4175: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4176: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4177: MC68060.mmuReset ();
4178:
4179: mpuIgnoreAddressError = true;
4180: fpuBox = fpuMotherboardCoprocessor;
4181: fpuBox.epbReset ();
4182: fpuFPn = fpuBox.epbFPn;
4183: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
4184: mpuSetWait ();
4185:
4186: regSRT1 = regSRT0 = 0;
4187: regSRS = REG_SR_S;
4188: regSRM = 0;
4189: regSRI = REG_SR_I;
4190: regCCR = 0;
4191: Arrays.fill (regRn, 0);
4192:
4193: regRn[15] = MainMemory.mmrRls (0x00000000);
4194: regPC = MainMemory.mmrRls (0x00000004);
4195:
4196: mpuIMR = 0;
4197: mpuIRR = 0;
4198: if (MC68901.MFP_DELAYED_INTERRUPT) {
4199: mpuDIRR = 0;
4200: }
4201: mpuISR = 0;
4202:
4203: mpuStart ();
4204: }
4205: }, TMR_DELAY);
4206:
4207: } else {
4208:
4209:
4210: if (mpuTask != null) {
4211: mpuClockLimit = 0L;
4212: System.out.println (Multilingual.mlnJapanese ? "MC68EC030 を停止します" : "MC68EC030 stops");
4213: mpuTask.cancel ();
4214: mpuTask = null;
4215: }
4216:
4217:
4218: tmrTimer.schedule (new TimerTask () {
4219: @Override public void run () {
4220:
4221:
4222: currentIsSecond = false;
4223: currentMPU = currentFirstMPU;
4224: mpuSetCurrentClock (specifiedFirstClock);
4225:
4226: RegisterList.drpSetMPU ();
4227: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4228: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4229: MC68060.mmuReset ();
4230:
4231: mpuIgnoreAddressError = false;
4232: mpuCacheOn = false;
4233: mpuSetWait ();
4234:
4235: regSRT1 = regSRT0 = 0;
4236: regSRS = REG_SR_S;
4237: regSRM = 0;
4238: regSRI = REG_SR_I;
4239: regCCR = 0;
4240:
4241: regPC = xt3SavedPC;
4242: System.arraycopy (xt3SavedRn, 0, regRn, 0, 16);
4243:
4244: mpuIMR = 0;
4245: mpuIRR = 0;
4246: if (MC68901.MFP_DELAYED_INTERRUPT) {
4247: mpuDIRR = 0;
4248: }
4249: mpuISR = 0;
4250:
4251: mpuStart ();
4252: }
4253: }, TMR_DELAY);
4254:
4255: }
4256: }
4257: }
4258:
4259:
4260:
4261:
4262:
4263:
4264: public static JMenu mdlMenu;
4265:
4266: public static JRadioButtonMenuItem mdlShodaiMenuItem;
4267: public static JRadioButtonMenuItem mdlACEMenuItem;
4268: public static JRadioButtonMenuItem mdlEXPERTMenuItem;
4269: public static JRadioButtonMenuItem mdlPROMenuItem;
4270: public static JRadioButtonMenuItem mdlSUPERMenuItem;
4271: public static JRadioButtonMenuItem mdlXVIMenuItem;
4272: public static JRadioButtonMenuItem mdlXellent30MenuItem;
4273: public static JRadioButtonMenuItem mdlCompactMenuItem;
4274: public static JRadioButtonMenuItem mdlHybridMenuItem;
4275: public static JRadioButtonMenuItem mdl060turboPROMenuItem;
4276: public static JRadioButtonMenuItem mdlX68030MenuItem;
4277: public static JRadioButtonMenuItem mdl030CompactMenuItem;
4278: public static JRadioButtonMenuItem mdl060turboMenuItem;
4279: public static JCheckBoxMenuItem mdlMC68010MenuItem;
4280:
4281: public static JMenu coproFPUMenu;
4282:
4283:
4284: public static final int ACCELERATOR_HYBRID = 1;
4285: public static final int ACCELERATOR_XELLENT30 = 2;
4286: public static final int ACCELERATOR_060TURBO = 3;
4287: public static final int ACCELERATOR_060TURBOPRO = 4;
4288: public static final double MHZ_HYBRID_VALUE = 100.0 / 3.0;
4289: public static final String MHZ_HYBRID_STRING = "33.3";
4290: public static final double MHZ_060TURBO_VALUE = 50.0;
4291: public static final String MHZ_060TURBO_STRING = "50";
4292:
4293:
4294:
4295: public static Model specifiedModel;
4296: public static int specifiedAccelerator;
4297: public static boolean mpu010;
4298:
4299: public static boolean specifiedIsSecond;
4300: public static int specifiedFirstMPU;
4301: public static int specifiedSecondMPU;
4302: public static int specifiedMPU;
4303:
4304: public static double specifiedFirstClock;
4305: public static double specifiedSecondClock;
4306: public static double specifiedClock;
4307:
4308: public static int specifiedCopro0;
4309: public static int specifiedCopro1;
4310: public static int specifiedCopro2;
4311: public static int specifiedOnchipFPU;
4312:
4313:
4314:
4315: public static Model currentModel;
4316: public static int currentAccelerator;
4317:
4318: public static boolean currentIsSecond;
4319: public static int currentFirstMPU;
4320: public static int currentSecondMPU;
4321: public static int currentMPU;
4322:
4323:
4324: public static int currentCopro0;
4325: public static int currentCopro1;
4326: public static int currentCopro2;
4327: public static int currentOnchipFPU;
4328:
4329:
4330:
4331: public static void mdlInit () {
4332:
4333:
4334: specifiedModel = Model.COMPACT;
4335: specifiedAccelerator = ACCELERATOR_HYBRID;
4336: mpu010 = Settings.sgsGetOnOff ("mpu010");
4337: {
4338: String paramModel = Settings.sgsGetString ("model");
4339: switch (paramModel.toLowerCase ()) {
4340: case "":
4341: case "none":
4342: case "hybrid":
4343: specifiedModel = Model.COMPACT;
4344: specifiedAccelerator = ACCELERATOR_HYBRID;
4345: break;
4346: case "xellent30":
4347: specifiedModel = Model.XVI;
4348: specifiedAccelerator = ACCELERATOR_XELLENT30;
4349: break;
4350: case "060turbo":
4351: specifiedModel = Model.X68030;
4352: specifiedAccelerator = ACCELERATOR_060TURBO;
4353: break;
4354: case "060turbopro":
4355: specifiedModel = Model.PRO;
4356: specifiedAccelerator = ACCELERATOR_060TURBOPRO;
4357: break;
4358: default:
4359: Model model = Model.fromTypeOrSynonym (paramModel);
4360: if (model != null) {
4361: specifiedModel = model;
4362: specifiedAccelerator = 0;
4363: } else {
4364: System.out.println (Multilingual.mlnJapanese ?
4365: paramModel + " は不明な機種です" :
4366: paramModel + " is unknown model");
4367: specifiedModel = Model.COMPACT;
4368: specifiedAccelerator = ACCELERATOR_HYBRID;
4369: }
4370: }
4371: }
4372:
4373: specifiedIsSecond = false;
4374: specifiedFirstMPU = specifiedModel.getMPU ();
4375: specifiedSecondMPU = Model.MPU_MC68EC030;
4376: {
4377: String[] paramMPUs = Settings.sgsGetString ("mpu").split (",");
4378: for (int i = 0; i < 2; i++) {
4379: int mpu = 0;
4380: String paramMPU = i < paramMPUs.length ? paramMPUs[i] : "";
4381: switch (paramMPU) {
4382: case "":
4383: case "none":
4384: case "-1":
4385: mpu = (i == 0 ?
4386: (specifiedAccelerator == ACCELERATOR_060TURBO ||
4387: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4388: specifiedModel.getMPU ()) :
4389: Model.MPU_MC68EC030);
4390: break;
4391: case "0":
4392: case "68000":
4393: case "mc68000":
4394: mpu = Model.MPU_MC68000;
4395: break;
4396: case "1":
4397: case "68010":
4398: case "mc68010":
4399: mpu = Model.MPU_MC68010;
4400: break;
4401:
4402:
4403:
4404:
4405:
4406: case "3":
4407: case "68ec030":
4408: case "mc68ec030":
4409: mpu = Model.MPU_MC68EC030;
4410: break;
4411:
4412:
4413:
4414:
4415:
4416:
4417:
4418:
4419:
4420:
4421:
4422:
4423:
4424:
4425:
4426:
4427:
4428: case "6":
4429: case "68060":
4430: case "mc68060":
4431: mpu = Model.MPU_MC68060;
4432: break;
4433: default:
4434: Model model = Model.fromTypeOrSynonym (paramMPU);
4435: if (model != null) {
4436: mpu = model.getMPU ();
4437: } else {
4438: System.out.println (Multilingual.mlnJapanese ?
4439: paramMPU + " は不明な MPU です" :
4440: paramMPU + " is unknown MPU");
4441: mpu = specifiedModel.getMPU ();
4442: }
4443: }
4444: if (i == 0) {
4445: specifiedFirstMPU = mpu;
4446: } else {
4447: specifiedSecondMPU = mpu;
4448: }
4449: }
4450: }
4451: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
4452:
4453: specifiedFirstClock = specifiedModel.getClock ();
4454: specifiedSecondClock = specifiedFirstClock * 2.0;
4455: {
4456: String[] paramClocks = Settings.sgsGetString ("clock").split (",");
4457: for (int i = 0; i < 2; i++) {
4458: double clock = 0.0;
4459: String paramClock = i < paramClocks.length ? paramClocks[i] : "";
4460: switch (paramClock.toLowerCase ()) {
4461: case "":
4462: case "none":
4463: case "-1":
4464: clock = (i == 0 ?
4465: (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4466: specifiedAccelerator == ACCELERATOR_060TURBO ||
4467: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4468: specifiedModel.getClock ()) :
4469: specifiedFirstClock * 2.0);
4470: break;
4471: case "hybrid":
4472: clock = MHZ_HYBRID_VALUE;
4473: break;
4474: case "060turbo":
4475: case "060turbopro":
4476: clock = MHZ_060TURBO_VALUE;
4477: break;
4478: case "16.7":
4479: case "xellent30":
4480: clock = 50.0 / 3.0;
4481: break;
4482: case "33.3":
4483: clock = 100.0 / 3.0;
4484: break;
4485: case "66.7":
4486: clock = 200.0 / 3.0;
4487: break;
4488: default:
4489: if (paramClock.matches ("^(?:" +
4490: "[-+]?" +
4491: "(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)" +
4492: "(?:[Ee][-+]?[0-9]+)?" +
4493: ")$")) {
4494: double d = Double.parseDouble (paramClock);
4495: if (1.0 <= d && d <= 1000.0) {
4496: clock = d;
4497: }
4498: } else {
4499: System.out.println (Multilingual.mlnJapanese ?
4500: paramClock + " は不明な動作周波数です" :
4501: paramClock + " is unknown clock frequency");
4502: clock = specifiedModel.getClock ();
4503: }
4504: }
4505: if (i == 0) {
4506: specifiedFirstClock = clock;
4507: } else {
4508: specifiedSecondClock = clock;
4509: }
4510: }
4511: }
4512: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4513:
4514: specifiedCopro0 = 15 & Settings.sgsGetInt ("copro0", 2);
4515: if (!((7 & specifiedCopro0) == 0 ||
4516: (7 & specifiedCopro0) == 1 ||
4517: (7 & specifiedCopro0) == 2 ||
4518: (7 & specifiedCopro0) == 7)) {
4519: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4520: }
4521: specifiedCopro1 = 15 & Settings.sgsGetInt ("copro1", 2);
4522: if (!((7 & specifiedCopro1) == 0 ||
4523: (7 & specifiedCopro1) == 1 ||
4524: (7 & specifiedCopro1) == 2 ||
4525: (7 & specifiedCopro1) == 7)) {
4526: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4527: }
4528: specifiedCopro2 = 15 & Settings.sgsGetInt ("copro2", 2);
4529: if (!((7 & specifiedCopro2) == 0 ||
4530: (7 & specifiedCopro2) == 1 ||
4531: (7 & specifiedCopro2) == 2 ||
4532: (7 & specifiedCopro2) == 7)) {
4533: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4534: }
4535: specifiedOnchipFPU = 15 & Settings.sgsGetInt ("onchipfpu", 7);
4536: if (!((7 & specifiedOnchipFPU) == 0 ||
4537: (7 & specifiedOnchipFPU) == 6 ||
4538: (7 & specifiedOnchipFPU) == 7)) {
4539: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4540: }
4541:
4542:
4543: currentModel = specifiedModel;
4544: currentAccelerator = specifiedAccelerator;
4545:
4546: currentIsSecond = specifiedIsSecond;
4547: currentFirstMPU = specifiedFirstMPU;
4548: currentSecondMPU = specifiedSecondMPU;
4549: currentMPU = specifiedMPU;
4550:
4551:
4552: currentCopro0 = specifiedCopro0;
4553: currentCopro1 = specifiedCopro1;
4554: currentCopro2 = specifiedCopro2;
4555: currentOnchipFPU = specifiedOnchipFPU;
4556:
4557:
4558: mpuUtilOn = Settings.sgsGetOnOff ("util");
4559: mpuUtilRatio = fmtParseInt (Settings.sgsGetString ("ratio"), 0, 1, 100, 100);
4560:
4561: mpuArbFreqMHz = fmtParseInt (Settings.sgsGetString ("mhz"), 0, 1, 1000, 100);
4562: if (mpuUtilOn) {
4563: mpuArbFreqOn = false;
4564: } else {
4565: mpuArbFreqOn = !(specifiedClock == 10.0 ||
4566: specifiedClock == 50.0 / 3.0 ||
4567: specifiedClock == 25.0 ||
4568: specifiedClock == 100.0 / 3.0 ||
4569: specifiedClock == 50.0 ||
4570: specifiedClock == 200.0 / 3.0 ||
4571: specifiedClock == 75.0 ||
4572: specifiedClock == 100.0);
4573: if (mpuArbFreqOn) {
4574: mpuArbFreqMHz = (int) specifiedClock;
4575: }
4576: }
4577:
4578:
4579: mpuROMWaitCycles = 0;
4580: mpuRAMWaitCycles = 0;
4581: mpuCacheOn = false;
4582:
4583: mpuNoWaitTime.ram = 0;
4584: mpuNoWaitTime.gvram = 0;
4585: mpuNoWaitTime.tvram = 0;
4586: mpuNoWaitTime.crtc = 0;
4587: mpuNoWaitTime.palet = 0;
4588: mpuNoWaitTime.vicon = 0;
4589: mpuNoWaitTime.dmac = 0;
4590: mpuNoWaitTime.mfp = 0;
4591: mpuNoWaitTime.rtc = 0;
4592: mpuNoWaitTime.prnport = 0;
4593: mpuNoWaitTime.sysport = 0;
4594: mpuNoWaitTime.opm = 0;
4595: mpuNoWaitTime.adpcm = 0;
4596: mpuNoWaitTime.fdc = 0;
4597: mpuNoWaitTime.fdd = 0;
4598: mpuNoWaitTime.hdc = 0;
4599: mpuNoWaitTime.scc = 0;
4600: mpuNoWaitTime.ppi = 0;
4601: mpuNoWaitTime.ioi = 0;
4602: mpuNoWaitTime.sprc = 0;
4603: mpuNoWaitTime.sram = 0;
4604: mpuNoWaitTime.rom = 0;
4605: mpuNoWaitTime.ramlong = mpuNoWaitTime.ram << 1;
4606: mpuNoWaitTime.romlong = mpuNoWaitTime.rom << 1;
4607:
4608: dmaNoWaitTime.ram = 0;
4609: dmaNoWaitTime.gvram = 0;
4610: dmaNoWaitTime.tvram = 0;
4611: dmaNoWaitTime.crtc = 0;
4612: dmaNoWaitTime.palet = 0;
4613: dmaNoWaitTime.vicon = 0;
4614: dmaNoWaitTime.dmac = 0;
4615: dmaNoWaitTime.mfp = 0;
4616: dmaNoWaitTime.rtc = 0;
4617: dmaNoWaitTime.prnport = 0;
4618: dmaNoWaitTime.sysport = 0;
4619: dmaNoWaitTime.opm = 0;
4620: dmaNoWaitTime.adpcm = 0;
4621: dmaNoWaitTime.fdc = 0;
4622: dmaNoWaitTime.fdd = 0;
4623: dmaNoWaitTime.hdc = 0;
4624: dmaNoWaitTime.scc = 0;
4625: dmaNoWaitTime.ppi = 0;
4626: dmaNoWaitTime.ioi = 0;
4627: dmaNoWaitTime.sprc = 0;
4628: dmaNoWaitTime.sram = 0;
4629: dmaNoWaitTime.rom = 0;
4630: dmaNoWaitTime.ramlong = dmaNoWaitTime.ram << 1;
4631: dmaNoWaitTime.romlong = dmaNoWaitTime.rom << 1;
4632:
4633:
4634: busWaitCyclesRequest = Settings.sgsGetOnOff ("waitcycles");
4635: busWaitCycles = busWaitCyclesRequest;
4636: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
4637:
4638: }
4639:
4640: public static void mdlTini () {
4641:
4642: Settings.sgsPutString ("model",
4643: specifiedAccelerator == ACCELERATOR_HYBRID ? "Hybrid" :
4644: specifiedAccelerator == ACCELERATOR_XELLENT30 ? "Xellent30" :
4645: specifiedAccelerator == ACCELERATOR_060TURBO ? "060turbo" :
4646: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? "060turboPRO" :
4647: specifiedModel.getSynonym () != null ? specifiedModel.getSynonym () :
4648: specifiedModel.getType ());
4649: Settings.sgsPutOnOff ("mpu010", mpu010);
4650:
4651:
4652: int defaultFirstMPU = (specifiedAccelerator == ACCELERATOR_060TURBO ||
4653: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4654: specifiedModel.getMPU ());
4655: int defaultSecondMPU = Model.MPU_MC68EC030;
4656: Settings.sgsPutString ("mpu",
4657: (specifiedFirstMPU == defaultFirstMPU ? "" :
4658: Model.mpuNameOf (specifiedFirstMPU)) +
4659: (specifiedSecondMPU == defaultSecondMPU ? "" :
4660: "," + Model.mpuNameOf (specifiedSecondMPU)));
4661:
4662:
4663:
4664:
4665: double defaultFirstClock = (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4666: specifiedAccelerator == ACCELERATOR_060TURBO ||
4667: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4668: specifiedModel.getClock ());
4669: double defaultSecondClock = defaultFirstClock * 2.0;
4670: Settings.sgsPutString ("clock",
4671: (specifiedFirstClock == defaultFirstClock ? "" :
4672: specifiedFirstClock == 50.0 / 3.0 ? "16.7" :
4673: specifiedFirstClock == 100.0 / 3.0 ? "33.3" :
4674: specifiedFirstClock == 200.0 / 3.0 ? "66.7" :
4675: String.valueOf ((int) specifiedFirstClock)) +
4676: (specifiedSecondClock == defaultSecondClock ? "" :
4677: "," + (specifiedSecondClock == 50.0 / 3.0 ? "16.7" :
4678: specifiedSecondClock == 100.0 / 3.0 ? "33.3" :
4679: specifiedSecondClock == 200.0 / 3.0 ? "66.7" :
4680: String.valueOf ((int) specifiedSecondClock))));
4681:
4682: Settings.sgsPutInt ("copro0", specifiedCopro0);
4683: Settings.sgsPutInt ("copro1", specifiedCopro1);
4684: Settings.sgsPutInt ("copro2", specifiedCopro2);
4685: Settings.sgsPutInt ("onchipfpu", specifiedOnchipFPU);
4686:
4687: Settings.sgsPutOnOff ("util",
4688: mpuUtilOn);
4689: Settings.sgsPutString ("ratio",
4690: String.valueOf (mpuUtilRatio));
4691:
4692: Settings.sgsPutString ("mhz",
4693: String.valueOf (mpuArbFreqMHz));
4694:
4695: Settings.sgsPutOnOff ("waitcycles", busWaitCyclesRequest);
4696: }
4697:
4698: public static void mdlMakeMenu () {
4699:
4700:
4701: ActionListener listener = new ActionListener () {
4702: @Override public void actionPerformed (ActionEvent ae) {
4703: Object source = ae.getSource ();
4704: switch (ae.getActionCommand ()) {
4705: case "X68000 (10MHz)":
4706: mdlRequestModel (Model.SHODAI, 0);
4707: mpuReset (-1, -1);
4708: break;
4709: case "X68000 ACE (10MHz)":
4710: mdlRequestModel (Model.ACE, 0);
4711: mpuReset (-1, -1);
4712: break;
4713: case "X68000 EXPERT (10MHz)":
4714: mdlRequestModel (Model.EXPERT, 0);
4715: mpuReset (-1, -1);
4716: break;
4717: case "X68000 PRO (10MHz)":
4718: mdlRequestModel (Model.PRO, 0);
4719: mpuReset (-1, -1);
4720: break;
4721: case "X68000 SUPER (10MHz)":
4722: mdlRequestModel (Model.SUPER, 0);
4723: mpuReset (-1, -1);
4724: break;
4725: case "X68000 XVI (16.7MHz)":
4726: mdlRequestModel (Model.XVI, 0);
4727: mpuReset (-1, -1);
4728: break;
4729: case "X68000 Compact (16.7MHz)":
4730: mdlRequestModel (Model.COMPACT, 0);
4731: mpuReset (-1, -1);
4732: break;
4733:
4734: case "X68030 (25MHz)":
4735: mdlRequestModel (Model.X68030, 0);
4736: mpuReset (-1, -1);
4737: break;
4738: case "X68030 Compact (25MHz)":
4739: mdlRequestModel (Model.X68030COMPACT, 0);
4740: mpuReset (-1, -1);
4741: break;
4742:
4743: case "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)":
4744: mdlRequestModel (Model.COMPACT, ACCELERATOR_HYBRID);
4745: mpuReset (-1, -1);
4746: break;
4747: case "Xellent30 (33.3MHz)":
4748: mdlRequestModel (Model.XVI, ACCELERATOR_XELLENT30);
4749: mpuReset (-1, -1);
4750: break;
4751: case "060turbo (" + MHZ_060TURBO_STRING + "MHz)":
4752: mdlRequestModel (Model.X68030, ACCELERATOR_060TURBO);
4753: mpuReset (-1, -1);
4754: break;
4755: case "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)":
4756: mdlRequestModel (Model.PRO, ACCELERATOR_060TURBOPRO);
4757: mpuReset (-1, -1);
4758: break;
4759:
4760: case "MC68010":
4761: mpu010 = ((JCheckBoxMenuItem) source).isSelected ();
4762: break;
4763:
4764: }
4765: }
4766: };
4767:
4768:
4769: ButtonGroup modelGroup = new ButtonGroup ();
4770: mdlMenu = Multilingual.mlnText (
4771: ComponentFactory.createMenu (
4772: "Change the model and reset",
4773: mdlShodaiMenuItem = ComponentFactory.createRadioButtonMenuItem (
4774: modelGroup,
4775: specifiedModel == Model.SHODAI,
4776: "X68000 (10MHz)",
4777: listener),
4778: mdlACEMenuItem = ComponentFactory.createRadioButtonMenuItem (
4779: modelGroup,
4780: specifiedModel == Model.ACE,
4781: "X68000 ACE (10MHz)",
4782: listener),
4783: mdlEXPERTMenuItem = ComponentFactory.createRadioButtonMenuItem (
4784: modelGroup,
4785: specifiedModel == Model.EXPERT,
4786: "X68000 EXPERT (10MHz)",
4787: listener),
4788: mdlPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
4789: modelGroup,
4790: specifiedModel == Model.PRO && specifiedAccelerator == 0,
4791: "X68000 PRO (10MHz)",
4792: listener),
4793: mdlSUPERMenuItem = ComponentFactory.createRadioButtonMenuItem (
4794: modelGroup,
4795: specifiedModel == Model.SUPER,
4796: "X68000 SUPER (10MHz)",
4797: listener),
4798: mdlXVIMenuItem = ComponentFactory.createRadioButtonMenuItem (
4799: modelGroup,
4800: specifiedModel == Model.XVI && specifiedAccelerator == 0,
4801: "X68000 XVI (16.7MHz)",
4802: listener),
4803: mdlCompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
4804: modelGroup,
4805: specifiedModel == Model.COMPACT && specifiedAccelerator == 0,
4806: "X68000 Compact (16.7MHz)",
4807: listener),
4808:
4809: ComponentFactory.createHorizontalSeparator (),
4810:
4811: mdlX68030MenuItem = ComponentFactory.createRadioButtonMenuItem (
4812: modelGroup,
4813: specifiedModel == Model.X68030 && specifiedAccelerator == 0,
4814: "X68030 (25MHz)",
4815: listener),
4816: mdl030CompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
4817: modelGroup,
4818: specifiedModel == Model.X68030COMPACT,
4819: "X68030 Compact (25MHz)",
4820: listener),
4821:
4822: ComponentFactory.createHorizontalSeparator (),
4823:
4824: mdlHybridMenuItem = ComponentFactory.createRadioButtonMenuItem (
4825: modelGroup,
4826: specifiedModel == Model.COMPACT && specifiedAccelerator == ACCELERATOR_HYBRID,
4827: "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)",
4828: listener),
4829: mdlXellent30MenuItem = ComponentFactory.createRadioButtonMenuItem (
4830: modelGroup,
4831: specifiedModel == Model.XVI && specifiedAccelerator == ACCELERATOR_XELLENT30,
4832: "Xellent30 (33.3MHz)",
4833: listener),
4834: mdl060turboMenuItem = ComponentFactory.createRadioButtonMenuItem (
4835: modelGroup,
4836: specifiedModel == Model.X68030 && specifiedAccelerator == ACCELERATOR_060TURBO,
4837: "060turbo (" + MHZ_060TURBO_STRING + "MHz)",
4838: listener),
4839: mdl060turboPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
4840: modelGroup,
4841: specifiedModel == Model.PRO && specifiedAccelerator == ACCELERATOR_060TURBOPRO,
4842: "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)",
4843: listener),
4844:
4845: ComponentFactory.createHorizontalSeparator (),
4846:
4847: mdlMC68010MenuItem = ComponentFactory.createCheckBoxMenuItem (
4848: mpu010,
4849: "MC68010",
4850: listener)
4851: ),
4852: "ja", "機種を変更してリセット");
4853:
4854:
4855: ActionListener copro0Listener = new ActionListener () {
4856: @Override public void actionPerformed (ActionEvent ae) {
4857: String command = ae.getActionCommand ();
4858: switch (command) {
4859: case "Not installed":
4860: specifiedCopro0 = (8 & specifiedCopro0) | 0;
4861: break;
4862: case "MC68881":
4863: specifiedCopro0 = (8 & specifiedCopro0) | 1;
4864: break;
4865: case "MC68882":
4866: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4867: break;
4868: case "Full specification":
4869: specifiedCopro0 = (8 & specifiedCopro0) | 7;
4870: break;
4871: case "Extended precision (19 digits)":
4872: specifiedCopro0 = 0 | (7 & specifiedCopro0);
4873: break;
4874: case "Triple precision (24 digits)":
4875: specifiedCopro0 = 8 | (7 & specifiedCopro0);
4876: break;
4877: default:
4878: System.out.println ("unknown action command " + command);
4879: }
4880: }
4881: };
4882:
4883: ActionListener copro1Listener = new ActionListener () {
4884: @Override public void actionPerformed (ActionEvent ae) {
4885: String command = ae.getActionCommand ();
4886: switch (command) {
4887: case "Not installed":
4888: specifiedCopro1 = (8 & specifiedCopro1) | 0;
4889: break;
4890: case "MC68881":
4891: specifiedCopro1 = (8 & specifiedCopro1) | 1;
4892: break;
4893: case "MC68882":
4894: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4895: break;
4896: case "Full specification":
4897: specifiedCopro1 = (8 & specifiedCopro1) | 7;
4898: break;
4899: case "Extended precision (19 digits)":
4900: specifiedCopro1 = 0 | (7 & specifiedCopro1);
4901: break;
4902: case "Triple precision (24 digits)":
4903: specifiedCopro1 = 8 | (7 & specifiedCopro1);
4904: break;
4905: default:
4906: System.out.println ("unknown action command " + command);
4907: }
4908: }
4909: };
4910:
4911: ActionListener copro2Listener = new ActionListener () {
4912: @Override public void actionPerformed (ActionEvent ae) {
4913: String command = ae.getActionCommand ();
4914: switch (command) {
4915: case "Not installed":
4916: specifiedCopro2 = (8 & specifiedCopro2) | 0;
4917: break;
4918: case "MC68881":
4919: specifiedCopro2 = (8 & specifiedCopro2) | 1;
4920: break;
4921: case "MC68882":
4922: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4923: break;
4924: case "Full specification":
4925: specifiedCopro2 = (8 & specifiedCopro2) | 7;
4926: break;
4927: case "Extended precision (19 digits)":
4928: specifiedCopro2 = 0 | (7 & specifiedCopro2);
4929: break;
4930: case "Triple precision (24 digits)":
4931: specifiedCopro2 = 8 | (7 & specifiedCopro2);
4932: break;
4933: default:
4934: System.out.println ("unknown action command " + command);
4935: }
4936: }
4937: };
4938:
4939: ActionListener onchipFPUListener = new ActionListener () {
4940: @Override public void actionPerformed (ActionEvent ae) {
4941: String command = ae.getActionCommand ();
4942: switch (command) {
4943: case "Not installed":
4944: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 0;
4945: break;
4946: case "MC68060":
4947: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 6;
4948: break;
4949: case "Full specification":
4950: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4951: break;
4952: case "Extended precision (19 digits)":
4953: specifiedOnchipFPU = 0 | (7 & specifiedOnchipFPU);
4954: break;
4955: case "Triple precision (24 digits)":
4956: specifiedOnchipFPU = 8 | (7 & specifiedOnchipFPU);
4957: break;
4958: default:
4959: System.out.println ("unknown action command " + command);
4960: }
4961: }
4962: };
4963:
4964: ButtonGroup copro00Group = new ButtonGroup ();
4965: ButtonGroup copro01Group = new ButtonGroup ();
4966: ButtonGroup copro10Group = new ButtonGroup ();
4967: ButtonGroup copro11Group = new ButtonGroup ();
4968: ButtonGroup copro20Group = new ButtonGroup ();
4969: ButtonGroup copro21Group = new ButtonGroup ();
4970: ButtonGroup onchipFPU0Group = new ButtonGroup ();
4971: ButtonGroup onchipFPU1Group = new ButtonGroup ();
4972:
4973: coproFPUMenu = Multilingual.mlnText (
4974: ComponentFactory.createMenu (
4975: "Coprocessor and on-chip FPU",
4976:
4977: Multilingual.mlnText (
4978: ComponentFactory.createMenu (
4979: "Motherboard coprocessor",
4980: Multilingual.mlnText (
4981: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 0, "Not installed", copro0Listener),
4982: "ja", "なし"),
4983: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 1, "MC68881", copro0Listener),
4984: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 2, "MC68882", copro0Listener),
4985: Multilingual.mlnText (
4986: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 7, "Full specification", copro0Listener),
4987: "ja", "フルスペック"),
4988: ComponentFactory.createHorizontalSeparator (),
4989: Multilingual.mlnText (
4990: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) == 0, "Extended precision (19 digits)", copro0Listener),
4991: "ja", "拡張精度 (19 桁)"),
4992: Multilingual.mlnText (
4993: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) != 0, "Triple precision (24 digits)", copro0Listener),
4994: "ja", "三倍精度 (24 桁)")),
4995: "ja", "マザーボードコプロセッサ"),
4996:
4997: Multilingual.mlnText (
4998: ComponentFactory.createMenu (
4999: "Extension coprocessor #1",
5000: Multilingual.mlnText (
5001: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 0, "Not installed", copro1Listener),
5002: "ja", "なし"),
5003: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 1, "MC68881", copro1Listener),
5004: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 2, "MC68882", copro1Listener),
5005: Multilingual.mlnText (
5006: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 7, "Full specification", copro1Listener),
5007: "ja", "フルスペック"),
5008: ComponentFactory.createHorizontalSeparator (),
5009: Multilingual.mlnText (
5010: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) == 0, "Extended precision (19 digits)", copro1Listener),
5011: "ja", "拡張精度 (19 桁)"),
5012: Multilingual.mlnText (
5013: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) != 0, "Triple precision (24 digits)", copro1Listener),
5014: "ja", "三倍精度 (24 桁)")),
5015: "ja", "拡張コプロセッサ #1"),
5016:
5017: Multilingual.mlnText (
5018: ComponentFactory.createMenu (
5019: "Extension coprocessor #2",
5020: Multilingual.mlnText (
5021: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 0, "Not installed", copro2Listener),
5022: "ja", "なし"),
5023: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 1, "MC68881", copro2Listener),
5024: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 2, "MC68882", copro2Listener),
5025: Multilingual.mlnText (
5026: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 7, "Full specification", copro2Listener),
5027: "ja", "フルスペック"),
5028: ComponentFactory.createHorizontalSeparator (),
5029: Multilingual.mlnText (
5030: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) == 0, "Extended precision (19 digits)", copro2Listener),
5031: "ja", "拡張精度 (19 桁)"),
5032: Multilingual.mlnText (
5033: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) != 0, "Triple precision (24 digits)", copro2Listener),
5034: "ja", "三倍精度 (24 桁)")),
5035: "ja", "拡張コプロセッサ #2"),
5036:
5037: Multilingual.mlnText (
5038: ComponentFactory.createMenu (
5039: "On-chip FPU",
5040: Multilingual.mlnText (
5041: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 0, "Not installed", onchipFPUListener),
5042: "ja", "なし"),
5043: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 6, "MC68060", onchipFPUListener),
5044: Multilingual.mlnText (
5045: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 7, "Full specification", onchipFPUListener),
5046: "ja", "フルスペック"),
5047: ComponentFactory.createHorizontalSeparator (),
5048: Multilingual.mlnText (
5049: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) == 0, "Extended precision (19 digits)", onchipFPUListener),
5050: "ja", "拡張精度 (19 桁)"),
5051: Multilingual.mlnText (
5052: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) != 0, "Triple precision (24 digits)", onchipFPUListener),
5053: "ja", "三倍精度 (24 桁)")),
5054: "ja", "オンチップ FPU")),
5055: "ja", "コプロセッサとオンチップ FPU");
5056:
5057: }
5058:
5059: public static void mdlRequestModel (Model model, int accelerator) {
5060: specifiedModel = model;
5061: specifiedAccelerator = accelerator;
5062:
5063: specifiedIsSecond = false;
5064: specifiedFirstMPU = specifiedModel.getMPU ();
5065: specifiedSecondMPU = Model.MPU_MC68EC030;
5066: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
5067: specifiedFirstClock = specifiedModel.getClock ();
5068: specifiedSecondClock = specifiedFirstClock * 2.0;
5069: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5070:
5071: switch (accelerator) {
5072: case ACCELERATOR_HYBRID:
5073: specifiedFirstClock = MHZ_HYBRID_VALUE;
5074: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5075: break;
5076: case ACCELERATOR_XELLENT30:
5077: break;
5078: case ACCELERATOR_060TURBO:
5079: case ACCELERATOR_060TURBOPRO:
5080: specifiedFirstMPU = Model.MPU_MC68060;
5081: specifiedFirstClock = MHZ_060TURBO_VALUE;
5082: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5083: }
5084:
5085: mpuUtilOn = false;
5086: mpuArbFreqOn = false;
5087: mpuSetCurrentClock (specifiedClock);
5088:
5089: if (accelerator == ACCELERATOR_HYBRID) {
5090: mdlHybridMenuItem.setSelected (true);
5091: } else if (accelerator == ACCELERATOR_XELLENT30) {
5092: mdlXellent30MenuItem.setSelected (true);
5093: } else if (accelerator == ACCELERATOR_060TURBO) {
5094: mdl060turboMenuItem.setSelected (true);
5095: } else if (accelerator == ACCELERATOR_060TURBOPRO) {
5096: mdl060turboPROMenuItem.setSelected (true);
5097: } else if (specifiedModel == Model.SHODAI) {
5098: mdlShodaiMenuItem.setSelected (true);
5099: } else if (specifiedModel == Model.ACE) {
5100: mdlACEMenuItem.setSelected (true);
5101: } else if (specifiedModel == Model.EXPERT) {
5102: mdlEXPERTMenuItem.setSelected (true);
5103: } else if (specifiedModel == Model.PRO) {
5104: mdlPROMenuItem.setSelected (true);
5105: } else if (specifiedModel == Model.SUPER) {
5106: mdlSUPERMenuItem.setSelected (true);
5107: } else if (specifiedModel == Model.XVI) {
5108: mdlXVIMenuItem.setSelected (true);
5109: } else if (specifiedModel == Model.COMPACT) {
5110: mdlCompactMenuItem.setSelected (true);
5111: } else if (specifiedModel == Model.X68030) {
5112: mdlX68030MenuItem.setSelected (true);
5113: } else if (specifiedModel == Model.X68030COMPACT) {
5114: mdl030CompactMenuItem.setSelected (true);
5115: }
5116:
5117:
5118: HDC.hdcSASIMenuItem.setSelected (!currentModel.isSCSI ());
5119: SPC.spcSCSIINMenuItem.setSelected (currentModel.isSCSI ());
5120: }
5121:
5122:
5123:
5124:
5125:
5126:
5127:
5128: public static final boolean MPU_INLINE_EXCEPTION = true;
5129: public static final boolean MPU_COMPOUND_POSTINCREMENT = false;
5130:
5131: public static final boolean MPU_SWITCH_MISC_OPCODE = false;
5132: public static final boolean MPU_SWITCH_BCC_CONDITION = false;
5133: public static final boolean MPU_SWITCH_BCC_OFFSET = false;
5134: public static final boolean MPU_SWITCH_SCC_CONDITION = true;
5135:
5136: public static final boolean MPU_OMIT_EXTRA_READ = false;
5137: public static final boolean MPU_OMIT_OFFSET_READ = false;
5138:
5139:
5140:
5141:
5142: public static final long FAR_FUTURE = 0x7fffffffffffffffL;
5143:
5144:
5145:
5146:
5147:
5148:
5149:
5150:
5151: public static final int REG_SR_T1 = 0b10000000_00000000;
5152: public static final int REG_SR_T0 = 0b01000000_00000000;
5153:
5154:
5155:
5156:
5157:
5158:
5159: public static final int REG_SR_S = 0b00100000_00000000;
5160: public static final int REG_SR_M = 0b00010000_00000000;
5161:
5162: public static final int REG_SR_I = 0b00000111_00000000;
5163:
5164:
5165: public static final int REG_CCR_X = 0b00000000_00010000;
5166: public static final int REG_CCR_N = 0b00000000_00001000;
5167: public static final int REG_CCR_Z = 0b00000000_00000100;
5168: public static final int REG_CCR_V = 0b00000000_00000010;
5169: public static final int REG_CCR_C = 0b00000000_00000001;
5170: public static final int REG_CCR_MASK = REG_CCR_X | REG_CCR_N | REG_CCR_Z | REG_CCR_V | REG_CCR_C;
5171:
5172: public static char[] REG_CCRXMAP = "00000000000000001111111111111111".toCharArray ();
5173: public static char[] REG_CCRNMAP = "00000000111111110000000011111111".toCharArray ();
5174: public static char[] REG_CCRZMAP = "00001111000011110000111100001111".toCharArray ();
5175: public static char[] REG_CCRVMAP = "00110011001100110011001100110011".toCharArray ();
5176: public static char[] REG_CCRCMAP = "01010101010101010101010101010101".toCharArray ();
5177:
5178:
5179:
5180: public static final int MPU_IOI_INTERRUPT_LEVEL = 1;
5181: public static final int MPU_EB2_INTERRUPT_LEVEL = 2;
5182: public static final int MPU_DMA_INTERRUPT_LEVEL = 3;
5183: public static final int MPU_SCC_INTERRUPT_LEVEL = 5;
5184: public static final int MPU_MFP_INTERRUPT_LEVEL = 6;
5185: public static final int MPU_SYS_INTERRUPT_LEVEL = 7;
5186: public static final int MPU_IOI_INTERRUPT_MASK = 0x80 >> MPU_IOI_INTERRUPT_LEVEL;
5187: public static final int MPU_EB2_INTERRUPT_MASK = 0x80 >> MPU_EB2_INTERRUPT_LEVEL;
5188: public static final int MPU_DMA_INTERRUPT_MASK = 0x80 >> MPU_DMA_INTERRUPT_LEVEL;
5189: public static final int MPU_SCC_INTERRUPT_MASK = 0x80 >> MPU_SCC_INTERRUPT_LEVEL;
5190: public static final int MPU_MFP_INTERRUPT_MASK = 0x80 >> MPU_MFP_INTERRUPT_LEVEL;
5191: public static final int MPU_SYS_INTERRUPT_MASK = 0x80 >> MPU_SYS_INTERRUPT_LEVEL;
5192:
5193: public static final boolean MPU_INTERRUPT_SWITCH = true;
5194:
5195:
5196: public static final boolean T = true;
5197: public static final boolean F = false;
5198:
5199: public static final int CCCC_T = 0b0000;
5200: public static final int CCCC_F = 0b0001;
5201: public static final int CCCC_HI = 0b0010;
5202: public static final int CCCC_LS = 0b0011;
5203: public static final int CCCC_CC = 0b0100;
5204: public static final int CCCC_CS = 0b0101;
5205: public static final int CCCC_NE = 0b0110;
5206: public static final int CCCC_EQ = 0b0111;
5207: public static final int CCCC_VC = 0b1000;
5208: public static final int CCCC_VS = 0b1001;
5209: public static final int CCCC_PL = 0b1010;
5210: public static final int CCCC_MI = 0b1011;
5211: public static final int CCCC_GE = 0b1100;
5212: public static final int CCCC_LT = 0b1101;
5213: public static final int CCCC_GT = 0b1110;
5214: public static final int CCCC_LE = 0b1111;
5215:
5216:
5217:
5218:
5219:
5220:
5221: public static final boolean[] BCCMAP = {
5222: 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,
5223: 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,
5224: 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,
5225: 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,
5226: 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,
5227: 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,
5228: 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,
5229: 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,
5230: 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,
5231: 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,
5232: 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,
5233: 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,
5234: 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,
5235: 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,
5236: 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,
5237: 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,
5238: };
5239:
5240:
5241: public static final char[] MPU_CCCMAP = (
5242: "11111111111111111111111111111111" +
5243: "00000000000000000000000000000000" +
5244: "10100000101000001010000010100000" +
5245: "01011111010111110101111101011111" +
5246: "10101010101010101010101010101010" +
5247: "01010101010101010101010101010101" +
5248: "11110000111100001111000011110000" +
5249: "00001111000011110000111100001111" +
5250: "11001100110011001100110011001100" +
5251: "00110011001100110011001100110011" +
5252: "11111111000000001111111100000000" +
5253: "00000000111111110000000011111111" +
5254: "11001100001100111100110000110011" +
5255: "00110011110011000011001111001100" +
5256: "11000000001100001100000000110000" +
5257: "00111111110011110011111111001111").toCharArray ();
5258:
5259:
5260:
5261: public static final int MPU_CC_T = 0b11111111111111111111111111111111;
5262: public static final int MPU_CC_F = 0b00000000000000000000000000000000;
5263: public static final int MPU_CC_HI = 0b10100000101000001010000010100000;
5264: public static final int MPU_CC_LS = 0b01011111010111110101111101011111;
5265: public static final int MPU_CC_HS = 0b10101010101010101010101010101010;
5266: public static final int MPU_CC_LO = 0b01010101010101010101010101010101;
5267: public static final int MPU_CC_NE = 0b11110000111100001111000011110000;
5268: public static final int MPU_CC_EQ = 0b00001111000011110000111100001111;
5269: public static final int MPU_CC_VC = 0b11001100110011001100110011001100;
5270: public static final int MPU_CC_VS = 0b00110011001100110011001100110011;
5271: public static final int MPU_CC_PL = 0b11111111000000001111111100000000;
5272: public static final int MPU_CC_MI = 0b00000000111111110000000011111111;
5273: public static final int MPU_CC_GE = 0b11001100001100111100110000110011;
5274: public static final int MPU_CC_LT = 0b00110011110011000011001111001100;
5275: public static final int MPU_CC_GT = 0b11000000001100001100000000110000;
5276: public static final int MPU_CC_LE = 0b00111111110011110011111111001111;
5277:
5278:
5279:
5280:
5281:
5282:
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: 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);
5327:
5328:
5329:
5330: public static final int[] MPU_BITREV_TABLE_0 = new int[2048];
5331: public static final int[] MPU_BITREV_TABLE_1 = new int[2048];
5332: public static final int[] MPU_BITREV_TABLE_2 = new int[2048];
5333: static {
5334: for (int i = 0; i < 2048; i++) {
5335: MPU_BITREV_TABLE_2[i] = (MPU_BITREV_TABLE_1[i] = (MPU_BITREV_TABLE_0[i] = Integer.reverse (i)) >>> 11) >>> 11;
5336: }
5337: }
5338:
5339:
5340:
5341: public static final int EA_DR = 0b000_000;
5342: public static final int EA_AR = 0b001_000;
5343: public static final int EA_MM = 0b010_000;
5344: public static final int EA_MP = 0b011_000;
5345: public static final int EA_MN = 0b100_000;
5346: public static final int EA_MW = 0b101_000;
5347: public static final int EA_MX = 0b110_000;
5348: public static final int EA_ZW = 0b111_000;
5349: public static final int EA_ZL = 0b111_001;
5350: public static final int EA_PW = 0b111_010;
5351: public static final int EA_PX = 0b111_011;
5352: public static final int EA_IM = 0b111_100;
5353: public static final int MMM_DR = EA_DR >> 3;
5354: public static final int MMM_AR = EA_AR >> 3;
5355: public static final int MMM_MM = EA_MM >> 3;
5356: public static final int MMM_MP = EA_MP >> 3;
5357: public static final int MMM_MN = EA_MN >> 3;
5358: public static final int MMM_MW = EA_MW >> 3;
5359: public static final int MMM_MX = EA_MX >> 3;
5360: public static final long EAM_DR = 0xff00000000000000L >>> EA_DR;
5361: public static final long EAM_AR = 0xff00000000000000L >>> EA_AR;
5362: public static final long EAM_MM = 0xff00000000000000L >>> EA_MM;
5363: public static final long EAM_MP = 0xff00000000000000L >>> EA_MP;
5364: public static final long EAM_MN = 0xff00000000000000L >>> EA_MN;
5365: public static final long EAM_MW = 0xff00000000000000L >>> EA_MW;
5366: public static final long EAM_MX = 0xff00000000000000L >>> EA_MX;
5367: public static final long EAM_ZW = 0x8000000000000000L >>> EA_ZW;
5368: public static final long EAM_ZL = 0x8000000000000000L >>> EA_ZL;
5369: public static final long EAM_PW = 0x8000000000000000L >>> EA_PW;
5370: public static final long EAM_PX = 0x8000000000000000L >>> EA_PX;
5371: public static final long EAM_IM = 0x8000000000000000L >>> EA_IM;
5372: 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;
5373: public static final long EAM_ALT = EAM_DR|EAM_AR|EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5374: 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;
5375: 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 ;
5376: public static final long EAM_DLT = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5377: public static final long EAM_DCN = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5378: public static final long EAM_DCL = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5379: 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;
5380: public static final long EAM_MEM = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5381: public static final long EAM_MLT = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5382: public static final long EAM_RDL = EAM_MM|EAM_MP |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5383: public static final long EAM_WTL = EAM_MM |EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5384: public static final long EAM_CNT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5385: public static final long EAM_CLT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5386:
5387:
5388:
5389:
5390:
5391:
5392:
5393:
5394:
5395:
5396:
5397: public static final int[] regRn = new int[16 + 1];
5398:
5399:
5400: public static int regPC;
5401: public static int regPC0;
5402:
5403:
5404: public static int regOC;
5405:
5406:
5407: public static int regSRT1;
5408: public static int regSRT0;
5409: public static int mpuTraceFlag;
5410: public static int regSRS;
5411: public static int regSRM;
5412: public static int regSRI;
5413:
5414:
5415: public static int regCCR;
5416:
5417:
5418:
5419:
5420:
5421:
5422:
5423:
5424:
5425:
5426:
5427:
5428:
5429:
5430:
5431:
5432:
5433:
5434:
5435:
5436: public static int mpuIMR;
5437:
5438:
5439:
5440:
5441:
5442:
5443: public static int mpuIRR;
5444: public static int mpuDIRR;
5445:
5446:
5447:
5448:
5449:
5450:
5451:
5452:
5453: public static int mpuISR;
5454:
5455:
5456: public static int mpuSFC;
5457: public static int mpuDFC;
5458: public static int mpuCACR;
5459:
5460:
5461:
5462:
5463:
5464: public static int mpuBUSCR;
5465: public static int mpuUSP;
5466: public static int mpuVBR;
5467: public static int mpuCAAR;
5468: public static int mpuMSP;
5469: public static int mpuISP;
5470:
5471:
5472:
5473: public static int mpuPCR;
5474:
5475:
5476:
5477: public static final int MPU_060_REV = 7;
5478:
5479:
5480:
5481: public static long mpuClockTime;
5482: public static long mpuClockLimit;
5483: public static double mpuClockMHz;
5484: public static double mpuCurrentMHz;
5485: public static int mpuCycleCount;
5486: public static long mpuCycleUnit;
5487: public static long mpuModifiedUnit;
5488: public static long dmaCycleUnit;
5489:
5490:
5491:
5492: public static TimerTask mpuTask;
5493:
5494:
5495: public static int mpuBootDevice;
5496: public static int mpuROMBootHandle;
5497: public static int mpuSavedBootDevice;
5498: public static int mpuSavedROMBootHandle;
5499:
5500:
5501: public static boolean mpuIgnoreAddressError;
5502:
5503:
5504: public static int mpuROMWaitCycles;
5505: public static int mpuRAMWaitCycles;
5506: public static boolean mpuCacheOn;
5507: public static final class WaitTime {
5508: public long ram;
5509: public long gvram;
5510: public long tvram;
5511: public long crtc;
5512: public long palet;
5513: public long vicon;
5514: public long dmac;
5515: public long mfp;
5516: public long rtc;
5517: public long prnport;
5518: public long sysport;
5519: public long opm;
5520: public long adpcm;
5521: public long fdc;
5522: public long fdd;
5523: public long hdc;
5524: public long scc;
5525: public long ppi;
5526: public long ioi;
5527: public long sprc;
5528: public long sram;
5529: public long rom;
5530: public long ramlong;
5531: public long romlong;
5532: }
5533: public static final WaitTime mpuNoWaitTime = new WaitTime ();
5534: public static final WaitTime dmaNoWaitTime = new WaitTime ();
5535: public static final WaitTime mpuWaitTime = new WaitTime ();
5536: public static final WaitTime dmaWaitTime = new WaitTime ();
5537: public static boolean busWaitCyclesRequest;
5538: public static boolean busWaitCycles;
5539: public static WaitTime busWaitTime;
5540:
5541:
5542: public static boolean mpuArbFreqOn;
5543: public static int mpuArbFreqMHz;
5544: public static SpinnerNumberModel mpuArbFreqModel;
5545: public static JSpinner mpuArbFreqSpinner;
5546: public static JRadioButtonMenuItem mpuArbFreqRadioButtonMenuItem;
5547:
5548:
5549: public static boolean mpuUtilOn;
5550: public static int mpuUtilRatio;
5551: public static SpinnerNumberModel mpuUtilModel;
5552: public static JSpinner mpuUtilSpinner;
5553: public static JRadioButtonMenuItem mpuUtilRadioButtonMenuItem;
5554:
5555:
5556: public static final int MPU_ADJUSTMENT_INTERVAL = 100;
5557: public static int mpuAdjustmentCounter;
5558: public static long mpuTotalNano;
5559: public static long mpuLastNano;
5560: public static double mpuCoreNano1;
5561: public static double mpuCoreNano2;
5562:
5563:
5564: public static JMenu mpuMenu;
5565: public static JMenuItem mpuResetMenuItem;
5566: public static JMenuItem mpuOpt1ResetMenuItem;
5567: public static JRadioButtonMenuItem mpuClock10MenuItem;
5568: public static JRadioButtonMenuItem mpuClock16MenuItem;
5569: public static JRadioButtonMenuItem mpuClock25MenuItem;
5570: public static JRadioButtonMenuItem mpuClock33MenuItem;
5571: public static JRadioButtonMenuItem mpuClock50MenuItem;
5572: public static JRadioButtonMenuItem mpuClock66MenuItem;
5573: public static JRadioButtonMenuItem mpuClock75MenuItem;
5574: public static JRadioButtonMenuItem mpuClock100MenuItem;
5575:
5576:
5577: public static ActionListener mpuDebugActionListener;
5578: public static ArrayList<AbstractButton> mpuButtonsRunning;
5579: public static ArrayList<AbstractButton> mpuButtonsStopped;
5580: public static ArrayList<JCheckBox> mpuOriIllegalCheckBoxList;
5581: public static ArrayList<JCheckBox> mpuStopOnErrorCheckBoxList;
5582: public static ArrayList<JCheckBox> mpuStopAtStartCheckBoxList;
5583:
5584: public static int mpuAdvanceCount;
5585: public static int mpuStepCount;
5586: public static boolean mpuContinue;
5587: public static int mpuUntilReturnSRS;
5588: public static int mpuUntilReturnRP;
5589: public static int mpuUntilReturnPC0;
5590: public static int mpuUntilReturnSP;
5591:
5592:
5593:
5594:
5595:
5596:
5597:
5598:
5599:
5600:
5601:
5602:
5603:
5604:
5605:
5606:
5607:
5608:
5609:
5610:
5611:
5612:
5613:
5614:
5615:
5616:
5617:
5618:
5619:
5620:
5621:
5622:
5623:
5624:
5625:
5626:
5627:
5628:
5629:
5630:
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: public static final boolean MPU_SXMENU = false;
5665:
5666:
5667:
5668: public static void mpuInit () {
5669:
5670: mpuIgnoreAddressError = false;
5671:
5672:
5673:
5674: fpuInit ();
5675:
5676: mpuClockTime = 0L;
5677: mpuClockLimit = 0L;
5678: mpuCycleCount = 0;
5679:
5680: mpuTask = null;
5681:
5682: M68kException.m6eSignal = new M68kException ();
5683: M68kException.m6eNumber = 0;
5684: M68kException.m6eAddress = 0;
5685: M68kException.m6eDirection = MPU_WR_WRITE;
5686: M68kException.m6eSize = MPU_SS_BYTE;
5687:
5688: mpuBootDevice = -1;
5689: mpuROMBootHandle = -1;
5690: mpuSavedBootDevice = -1;
5691: mpuSavedROMBootHandle = -1;
5692:
5693:
5694:
5695:
5696:
5697:
5698:
5699:
5700:
5701:
5702:
5703:
5704:
5705:
5706:
5707: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
5708: mpuTotalNano = 0L;
5709: mpuLastNano = System.nanoTime ();
5710: mpuCoreNano1 = mpuCoreNano2 = 0.5 * 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
5711:
5712: mpuButtonsRunning = new ArrayList<AbstractButton> ();
5713: mpuButtonsStopped = new ArrayList<AbstractButton> ();
5714:
5715: mpuOriIllegalCheckBoxList = new ArrayList<JCheckBox> ();
5716: mpuStopOnErrorCheckBoxList = new ArrayList<JCheckBox> ();
5717: mpuStopAtStartCheckBoxList = new ArrayList<JCheckBox> ();
5718:
5719: mpuAdvanceCount = 0;
5720: mpuStepCount = 0;
5721: mpuContinue = false;
5722: mpuUntilReturnSRS = 0;
5723: mpuUntilReturnRP = 0;
5724: mpuUntilReturnPC0 = 0;
5725: mpuUntilReturnSP = 0;
5726:
5727:
5728: mpuDebugActionListener = new ActionListener () {
5729: @Override public void actionPerformed (ActionEvent ae) {
5730: Object source = ae.getSource ();
5731: switch (ae.getActionCommand ()) {
5732: case "Stop":
5733: if (RootPointerList.RTL_ON) {
5734: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
5735: RootPointerList.rtlCurrentUserTaskIsStoppable) {
5736: mpuStop (null);
5737: }
5738: } else {
5739: mpuStop (null);
5740: }
5741: break;
5742: case "Trace":
5743: mpuAdvance (1);
5744: break;
5745: case "Trace 10 times":
5746: mpuAdvance (10);
5747: break;
5748: case "Trace 100 times":
5749: mpuAdvance (100);
5750: break;
5751: case "Step":
5752: mpuStep (1);
5753: break;
5754: case "Step 10 times":
5755: mpuStep (10);
5756: break;
5757: case "Step 100 times":
5758: mpuStep (100);
5759: break;
5760: case "Step until return":
5761: mpuStepUntilReturn ();
5762: break;
5763: case "Run":
5764: mpuStart ();
5765: break;
5766:
5767: case "Consider ORI.B #$00,D0 as an illegal instruction" :
5768: if (DBG_ORI_BYTE_ZERO_D0) {
5769: dbgOriByteZeroD0 = ((JCheckBox) source).isSelected ();
5770: for (JCheckBox checkBox : mpuOriIllegalCheckBoxList) {
5771: if (checkBox.isSelected () != dbgOriByteZeroD0) {
5772: checkBox.setSelected (dbgOriByteZeroD0);
5773: }
5774: }
5775: }
5776: break;
5777: case "Stop on error":
5778: dbgStopOnError = ((JCheckBox) source).isSelected ();
5779: for (JCheckBox checkBox : mpuStopOnErrorCheckBoxList) {
5780: if (checkBox.isSelected () != dbgStopOnError) {
5781: checkBox.setSelected (dbgStopOnError);
5782: }
5783: }
5784: break;
5785: case "Stop at execution start position":
5786: dbgStopAtStart = ((JCheckBox) source).isSelected ();
5787: for (JCheckBox checkBox : mpuStopAtStartCheckBoxList) {
5788: if (checkBox.isSelected () != dbgStopAtStart) {
5789: checkBox.setSelected (dbgStopAtStart);
5790: }
5791: }
5792: break;
5793: }
5794: }
5795: };
5796:
5797: }
5798:
5799:
5800:
5801: public static JCheckBox mpuMakeOriIllegalCheckBox () {
5802: JCheckBox checkBox = Multilingual.mlnToolTipText (
5803: ComponentFactory.createIconCheckBox (
5804: DBG_ORI_BYTE_ZERO_D0 ? dbgOriByteZeroD0 : null,
5805: LnF.LNF_ORI_BYTE_ZERO_D0_IMAGE,
5806: LnF.LNF_ORI_BYTE_ZERO_D0_SELECTED_IMAGE,
5807: "Consider ORI.B #$00,D0 as an illegal instruction", mpuDebugActionListener),
5808: "ja", "ORI.B #$00,D0 を不当命令とみなす");
5809: mpuOriIllegalCheckBoxList.add (checkBox);
5810: return checkBox;
5811: }
5812:
5813:
5814:
5815: public static JCheckBox mpuMakeStopOnErrorCheckBox () {
5816: JCheckBox checkBox = Multilingual.mlnToolTipText (
5817: ComponentFactory.createIconCheckBox (
5818: dbgStopOnError,
5819: LnF.LNF_STOP_ON_ERROR_IMAGE,
5820: LnF.LNF_STOP_ON_ERROR_SELECTED_IMAGE,
5821: "Stop on error", mpuDebugActionListener),
5822: "ja", "エラーで停止する");
5823: mpuStopOnErrorCheckBoxList.add (checkBox);
5824: return checkBox;
5825: }
5826:
5827:
5828:
5829: public static JCheckBox mpuMakeStopAtStartCheckBox () {
5830: JCheckBox checkBox = Multilingual.mlnToolTipText (
5831: ComponentFactory.createIconCheckBox (
5832: dbgStopAtStart,
5833: LnF.LNF_STOP_AT_START_IMAGE,
5834: LnF.LNF_STOP_AT_START_SELECTED_IMAGE,
5835: "Stop at execution start position", mpuDebugActionListener),
5836: "ja", "実行開始位置で停止する");
5837: mpuStopAtStartCheckBoxList.add (checkBox);
5838: return checkBox;
5839: }
5840:
5841:
5842: public static void mpuMakeMenu () {
5843:
5844: ButtonGroup unitGroup = new ButtonGroup ();
5845: ActionListener listener = new ActionListener () {
5846: @Override public void actionPerformed (ActionEvent ae) {
5847: Object source = ae.getSource ();
5848: switch (ae.getActionCommand ()) {
5849: case "Reset":
5850: mpuReset (-1, -1);
5851: break;
5852: case "Hold down OPT.1 and reset":
5853: mpuReset (0, -1);
5854: break;
5855: case "Interrupt":
5856: sysInterrupt ();
5857: break;
5858: case "10MHz":
5859: mpuArbFreqOn = false;
5860: mpuUtilOn = false;
5861: mpuSetCurrentClock (10.0);
5862: break;
5863: case "16.7MHz":
5864: mpuArbFreqOn = false;
5865: mpuUtilOn = false;
5866: mpuSetCurrentClock (50.0 / 3.0);
5867: break;
5868: case "25MHz":
5869: mpuArbFreqOn = false;
5870: mpuUtilOn = false;
5871: mpuSetCurrentClock (25.0);
5872: break;
5873: case "33.3MHz":
5874: mpuArbFreqOn = false;
5875: mpuUtilOn = false;
5876: mpuSetCurrentClock (100.0 / 3.0);
5877: break;
5878: case "50MHz":
5879: mpuArbFreqOn = false;
5880: mpuUtilOn = false;
5881: mpuSetCurrentClock (50.0);
5882: break;
5883: case "66.7MHz":
5884: mpuArbFreqOn = false;
5885: mpuUtilOn = false;
5886: mpuSetCurrentClock (200.0 / 3.0);
5887: break;
5888: case "75MHz":
5889: mpuArbFreqOn = false;
5890: mpuUtilOn = false;
5891: mpuSetCurrentClock (75.0);
5892: break;
5893: case "100MHz":
5894: mpuArbFreqOn = false;
5895: mpuUtilOn = false;
5896: mpuSetCurrentClock (100.0);
5897: break;
5898: case "Arbitrary frequency":
5899: mpuArbFreqOn = true;
5900: mpuUtilOn = false;
5901: mpuSetCurrentClock ((double) mpuArbFreqMHz);
5902: break;
5903: case "Arbitrary load factor":
5904: mpuArbFreqOn = false;
5905: mpuUtilOn = true;
5906: break;
5907: case "FE function instruction":
5908: FEFunction.fpkOn = ((JCheckBoxMenuItem) source).isSelected ();
5909: break;
5910: case "Reject FLOATn.X":
5911: FEFunction.fpkRejectFloatOn = ((JCheckBoxMenuItem) source).isSelected ();
5912: break;
5913: case "Cut FC2 pin":
5914: busRequestCutFC2Pin = ((JCheckBoxMenuItem) source).isSelected ();
5915: break;
5916: case "Wait cycles":
5917: busWaitCyclesRequest = ((JCheckBoxMenuItem) source).isSelected ();
5918: break;
5919: case "Use IPLROM 1.6":
5920: ROM.romIPLROM16On = ((JCheckBoxMenuItem) source).isSelected ();
5921: break;
5922: case "Increase IPLROM to 256KB":
5923: ROM.romIPLROM256KOn = ((JCheckBoxMenuItem) source).isSelected ();
5924: break;
5925:
5926: case "Run / Stop":
5927: if (((JCheckBox) source).isSelected ()) {
5928: mpuStart ();
5929: } else {
5930: if (RootPointerList.RTL_ON) {
5931: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
5932: RootPointerList.rtlCurrentUserTaskIsStoppable) {
5933: mpuStop (null);
5934: }
5935: } else {
5936: mpuStop (null);
5937: }
5938: }
5939: pnlPanel.requestFocusInWindow ();
5940: break;
5941: }
5942: }
5943: };
5944: mpuMenu = ComponentFactory.createMenu (
5945: "MPU", 'M',
5946: mpuResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset", 'R', MNB_MODIFIERS, listener), "ja", "リセット"),
5947: mpuOpt1ResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Hold down OPT.1 and reset", 'O', MNB_MODIFIERS, listener), "ja", "OPT.1 を押しながらリセット"),
5948: Multilingual.mlnText (ComponentFactory.createMenuItem ("Interrupt", listener), "ja", "インタラプト"),
5949: ComponentFactory.createHorizontalSeparator (),
5950: mdlMenu,
5951: ComponentFactory.createHorizontalSeparator (),
5952: mpuClock10MenuItem = ComponentFactory.createRadioButtonMenuItem (
5953: unitGroup,
5954: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 10.0,
5955: "10MHz",
5956: listener),
5957: mpuClock16MenuItem = ComponentFactory.createRadioButtonMenuItem (
5958: unitGroup,
5959: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0 / 3.0,
5960: "16.7MHz",
5961: listener),
5962: mpuClock25MenuItem = ComponentFactory.createRadioButtonMenuItem (
5963: unitGroup,
5964: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 25.0,
5965: "25MHz",
5966: listener),
5967: mpuClock33MenuItem = ComponentFactory.createRadioButtonMenuItem (
5968: unitGroup,
5969: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0 / 3.0,
5970: "33.3MHz",
5971: listener),
5972: mpuClock50MenuItem = ComponentFactory.createRadioButtonMenuItem (
5973: unitGroup,
5974: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0,
5975: "50MHz",
5976: listener),
5977: mpuClock66MenuItem = ComponentFactory.createRadioButtonMenuItem (
5978: unitGroup,
5979: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 200.0 / 3.0,
5980: "66.7MHz",
5981: listener),
5982: mpuClock75MenuItem = ComponentFactory.createRadioButtonMenuItem (
5983: unitGroup,
5984: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 75.0,
5985: "75MHz",
5986: listener),
5987: mpuClock100MenuItem = ComponentFactory.createRadioButtonMenuItem (
5988: unitGroup,
5989: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0,
5990: "100MHz",
5991: listener),
5992: mpuArbFreqRadioButtonMenuItem = Multilingual.mlnText (
5993: ComponentFactory.createRadioButtonMenuItem (
5994: unitGroup,
5995: mpuArbFreqOn,
5996: "Arbitrary frequency",
5997: listener),
5998: "ja", "任意の周波数"),
5999: ComponentFactory.createHorizontalBox (
6000: Box.createHorizontalStrut (20),
6001: mpuArbFreqSpinner = ComponentFactory.createNumberSpinner (
6002: mpuArbFreqModel = new SpinnerNumberModel (mpuArbFreqMHz, 1, 1000, 1),
6003: 4,
6004: new ChangeListener () {
6005: @Override public void stateChanged (ChangeEvent ce) {
6006:
6007: mpuArbFreqMHz = mpuArbFreqModel.getNumber ().intValue ();
6008: if (mpuArbFreqOn) {
6009: mpuSetCurrentClock ((double) mpuArbFreqMHz);
6010: }
6011: }
6012: }
6013: ),
6014: ComponentFactory.createLabel ("MHz"),
6015: Box.createHorizontalGlue ()
6016: ),
6017: mpuUtilRadioButtonMenuItem = Multilingual.mlnText (
6018: ComponentFactory.createRadioButtonMenuItem (
6019: unitGroup,
6020: mpuUtilOn,
6021: "Arbitrary load factor",
6022: listener),
6023: "ja", "任意の負荷率"),
6024: ComponentFactory.createHorizontalBox (
6025: Box.createHorizontalStrut (20),
6026: mpuUtilSpinner = ComponentFactory.createNumberSpinner (
6027: mpuUtilModel = new SpinnerNumberModel (mpuUtilRatio, 1, 100, 1),
6028: 4,
6029: new ChangeListener () {
6030: @Override public void stateChanged (ChangeEvent ce) {
6031:
6032: mpuUtilRatio = mpuUtilModel.getNumber ().intValue ();
6033: }
6034: }
6035: ),
6036: ComponentFactory.createLabel ("%"),
6037: Box.createHorizontalGlue ()
6038: ),
6039: ComponentFactory.createHorizontalSeparator (),
6040:
6041: coproFPUMenu,
6042:
6043: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkOn, "FE function instruction", listener), "ja", "FE ファンクション命令"),
6044: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkRejectFloatOn, "Reject FLOATn.X", listener), "ja", "FLOATn.X を組み込まない"),
6045: ComponentFactory.createHorizontalSeparator (),
6046: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busRequestCutFC2Pin, "Cut FC2 pin", listener), "ja", "FC2 ピンをカットする"),
6047: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busWaitCyclesRequest, "Wait cycles", listener), "ja", "ウェイトサイクル"),
6048: ComponentFactory.createHorizontalSeparator (),
6049: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM16On, "Use IPLROM 1.6", listener), "ja", "IPLROM 1.6 を使う"),
6050: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM256KOn, "Increase IPLROM to 256KB", listener), "ja", "IPLROM を 256KB に増やす")
6051: );
6052: }
6053:
6054:
6055: public static void mpuSetCurrentClock (double clock) {
6056: specifiedClock = clock;
6057: if (currentIsSecond) {
6058: specifiedSecondClock = clock;
6059: } else {
6060: specifiedFirstClock = clock;
6061: }
6062: if (!mpuArbFreqOn && !mpuUtilOn) {
6063: if (specifiedClock == 10.0) {
6064: mpuClock10MenuItem.setSelected (true);
6065: } else if (specifiedClock == 50.0 / 3.0) {
6066: mpuClock16MenuItem.setSelected (true);
6067: } else if (specifiedClock == 25.0) {
6068: mpuClock25MenuItem.setSelected (true);
6069: } else if (specifiedClock == 100.0 / 3.0) {
6070: mpuClock33MenuItem.setSelected (true);
6071: } else if (specifiedClock == 50.0) {
6072: mpuClock50MenuItem.setSelected (true);
6073: } else if (specifiedClock == 200.0 / 3.0) {
6074: mpuClock66MenuItem.setSelected (true);
6075: } else if (specifiedClock == 75.0) {
6076: mpuClock75MenuItem.setSelected (true);
6077: } else if (specifiedClock == 100.0) {
6078: mpuClock100MenuItem.setSelected (true);
6079: }
6080: }
6081: mpuClockMHz = specifiedClock;
6082: mpuSetClockMHz (mpuClockMHz);
6083: }
6084:
6085:
6086:
6087:
6088:
6089:
6090:
6091:
6092:
6093:
6094:
6095: public static void mpuSetClockMHz (double mhz) {
6096: mhz = Math.max (1.0, Math.min (1000.0, mhz));
6097: double lastMHz = mpuCurrentMHz;
6098: mpuCurrentMHz = mhz;
6099: mpuCycleUnit = (long) (((double) TMR_FREQ / 1000000.0) / mhz + 0.5);
6100:
6101: mpuModifiedUnit = (currentMPU == Model.MPU_MC68EC030 ||
6102: currentMPU == Model.MPU_MC68030 ?
6103: (long) (((double) TMR_FREQ * 3.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6104: currentMPU == Model.MPU_MC68LC040 ||
6105: currentMPU == Model.MPU_MC68040 ?
6106: (long) (((double) TMR_FREQ * 2.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6107: mpuCycleUnit);
6108: if (lastMHz != mhz) {
6109: mpuSetWait ();
6110: }
6111: }
6112:
6113:
6114:
6115:
6116:
6117:
6118:
6119:
6120:
6121:
6122:
6123:
6124:
6125:
6126:
6127:
6128:
6129:
6130:
6131:
6132:
6133:
6134:
6135:
6136:
6137:
6138:
6139:
6140:
6141:
6142:
6143:
6144:
6145:
6146:
6147:
6148:
6149:
6150:
6151:
6152:
6153:
6154:
6155:
6156:
6157:
6158:
6159:
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: public static void mpuSetWait () {
6194:
6195: if (currentMPU <= Model.MPU_MC68010) {
6196: mpuWaitTime.ram = mpuCycleUnit >> 3;
6197: mpuWaitTime.vicon = (long) (mpuCycleUnit * 0.6);
6198: mpuWaitTime.crtc =
6199: mpuWaitTime.prnport =
6200: mpuWaitTime.sysport =
6201: mpuWaitTime.sprc =
6202: mpuWaitTime.sram =
6203: mpuWaitTime.rom = mpuCycleUnit;
6204: mpuWaitTime.gvram = (long) (mpuCycleUnit * 1.1);
6205: mpuWaitTime.rtc =
6206: mpuWaitTime.opm =
6207: mpuWaitTime.adpcm =
6208: mpuWaitTime.fdc =
6209: mpuWaitTime.fdd =
6210: mpuWaitTime.hdc =
6211: mpuWaitTime.ppi =
6212: mpuWaitTime.ioi = (long) (mpuCycleUnit * 1.7);
6213: mpuWaitTime.tvram = mpuCycleUnit * 2;
6214: mpuWaitTime.palet = (long) (mpuCycleUnit * 2.6);
6215: mpuWaitTime.mfp = (long) (mpuCycleUnit * 4.3);
6216: mpuWaitTime.scc = mpuCycleUnit * 6;
6217: mpuWaitTime.dmac = mpuCycleUnit * 15;
6218: mpuWaitTime.ramlong = mpuWaitTime.ram << 1;
6219: mpuWaitTime.romlong = mpuWaitTime.rom << 1;
6220: } else if (currentMPU <= Model.MPU_MC68030) {
6221: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6222: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6223: mpuWaitTime.sram = mpuCycleUnit * 2;
6224: mpuWaitTime.prnport =
6225: mpuWaitTime.sysport = mpuCycleUnit * 4;
6226: mpuWaitTime.gvram =
6227: mpuWaitTime.crtc =
6228: mpuWaitTime.vicon =
6229: mpuWaitTime.sprc = mpuCycleUnit * 6;
6230: mpuWaitTime.tvram = mpuCycleUnit * 7;
6231: mpuWaitTime.palet = mpuCycleUnit * 11;
6232: mpuWaitTime.opm =
6233: mpuWaitTime.adpcm =
6234: mpuWaitTime.fdc =
6235: mpuWaitTime.fdd =
6236: mpuWaitTime.hdc =
6237: mpuWaitTime.ppi =
6238: mpuWaitTime.ioi = mpuCycleUnit * 15;
6239: mpuWaitTime.mfp = mpuCycleUnit * 19;
6240: mpuWaitTime.rtc = mpuCycleUnit * 28;
6241: mpuWaitTime.dmac = mpuCycleUnit * 34;
6242: mpuWaitTime.scc = mpuCycleUnit * 38;
6243: mpuWaitTime.ramlong = mpuWaitTime.ram;
6244: mpuWaitTime.romlong = mpuWaitTime.rom;
6245: } else {
6246: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6247: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6248: mpuWaitTime.sram = mpuCycleUnit * 13;
6249: mpuWaitTime.prnport =
6250: mpuWaitTime.sysport = mpuCycleUnit * 17;
6251: mpuWaitTime.gvram =
6252: mpuWaitTime.crtc =
6253: mpuWaitTime.vicon =
6254: mpuWaitTime.sprc = mpuCycleUnit * 21;
6255: mpuWaitTime.tvram = mpuCycleUnit * 22;
6256: mpuWaitTime.palet = mpuCycleUnit * 33;
6257: mpuWaitTime.opm =
6258: mpuWaitTime.adpcm =
6259: mpuWaitTime.fdc =
6260: mpuWaitTime.fdd =
6261: mpuWaitTime.hdc =
6262: mpuWaitTime.ppi =
6263: mpuWaitTime.ioi = mpuCycleUnit * 37;
6264: mpuWaitTime.mfp = mpuCycleUnit * 47;
6265: mpuWaitTime.dmac = mpuCycleUnit * 73;
6266: mpuWaitTime.rtc = mpuCycleUnit * 77;
6267: mpuWaitTime.scc = mpuCycleUnit * 97;
6268: mpuWaitTime.ramlong = mpuWaitTime.ram;
6269: mpuWaitTime.romlong = mpuWaitTime.rom;
6270: }
6271: if (true) {
6272: mpuNoWaitTime.sram = mpuWaitTime.sram;
6273: mpuNoWaitTime.rom = mpuWaitTime.rom;
6274: mpuNoWaitTime.romlong = mpuWaitTime.romlong;
6275: }
6276:
6277: dmaWaitTime.ram = dmaCycleUnit >> 3;
6278: dmaWaitTime.sram = 0;
6279: dmaWaitTime.rom = 0;
6280: dmaWaitTime.gvram =
6281: dmaWaitTime.crtc =
6282: dmaWaitTime.vicon =
6283: dmaWaitTime.prnport =
6284: dmaWaitTime.sysport =
6285: dmaWaitTime.sprc = dmaCycleUnit;
6286: dmaWaitTime.tvram =
6287: dmaWaitTime.rtc =
6288: dmaWaitTime.opm =
6289: dmaWaitTime.adpcm =
6290: dmaWaitTime.fdc =
6291: dmaWaitTime.fdd =
6292: dmaWaitTime.hdc =
6293: dmaWaitTime.ppi =
6294: dmaWaitTime.ioi = dmaCycleUnit * 2;
6295: dmaWaitTime.palet = dmaCycleUnit * 3;
6296: dmaWaitTime.mfp = dmaCycleUnit * 4;
6297: dmaWaitTime.scc = dmaCycleUnit * 6;
6298: dmaWaitTime.dmac = dmaCycleUnit * 15;
6299: dmaWaitTime.ramlong = dmaWaitTime.ram << 1;
6300: dmaWaitTime.romlong = dmaWaitTime.rom << 1;
6301: }
6302:
6303:
6304:
6305:
6306:
6307: public static void mpuReset (int device, int romHandle) {
6308:
6309: mpuBootDevice = device;
6310: mpuROMBootHandle = romHandle;
6311:
6312:
6313:
6314:
6315:
6316:
6317:
6318:
6319:
6320:
6321:
6322:
6323: if (mpuBootDevice == -1) {
6324: if (mpuSavedBootDevice != -1) {
6325: mpuBootDevice = mpuSavedBootDevice;
6326: mpuROMBootHandle = mpuSavedROMBootHandle;
6327: mpuSavedBootDevice = -1;
6328: mpuSavedROMBootHandle = -1;
6329: }
6330: } else {
6331: if (mpuSavedBootDevice == -1) {
6332: mpuSavedBootDevice = MainMemory.mmrRwz (0x00ed0018);
6333: mpuSavedROMBootHandle = MainMemory.mmrRls (0x00ed000c);
6334: }
6335: }
6336:
6337:
6338: if (mpu010) {
6339: if (specifiedFirstMPU == Model.MPU_MC68000) {
6340: specifiedFirstMPU = Model.MPU_MC68010;
6341: }
6342: if (specifiedSecondMPU == Model.MPU_MC68000) {
6343: specifiedSecondMPU = Model.MPU_MC68010;
6344: }
6345: } else {
6346: if (specifiedFirstMPU == Model.MPU_MC68010) {
6347: specifiedFirstMPU = Model.MPU_MC68000;
6348: }
6349: if (specifiedSecondMPU == Model.MPU_MC68010) {
6350: specifiedSecondMPU = Model.MPU_MC68000;
6351: }
6352: }
6353:
6354:
6355: specifiedIsSecond = false;
6356: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
6357: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
6358:
6359: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
6360: MC68EC030.m30DivZeroVFlag = false;
6361: }
6362:
6363: if (mpuTask != null) {
6364: mpuClockLimit = 0L;
6365: System.out.println (Multilingual.mlnJapanese ?
6366: "MPU を停止します" :
6367: "MPU stops");
6368: mpuTask.cancel ();
6369: mpuTask = null;
6370: }
6371:
6372: tmrTimer.schedule (new TimerTask () {
6373: @Override public void run () {
6374:
6375:
6376:
6377: currentModel = specifiedModel;
6378: currentAccelerator = specifiedAccelerator;
6379: frmUpdateTitle ();
6380:
6381: currentIsSecond = specifiedIsSecond;
6382: currentFirstMPU = specifiedFirstMPU;
6383: currentSecondMPU = specifiedSecondMPU;
6384: currentMPU = specifiedMPU;
6385:
6386: mpuSetCurrentClock (specifiedClock);
6387:
6388: currentCopro0 = specifiedCopro0;
6389: currentCopro1 = specifiedCopro1;
6390: currentCopro2 = specifiedCopro2;
6391: currentOnchipFPU = specifiedOnchipFPU;
6392:
6393:
6394: if (currentMPU < Model.MPU_MC68020) {
6395: if (busHimem68000) {
6396: busRequestExMemoryStart = 0x10000000;
6397: busRequestExMemorySize = busLocalMemorySize;
6398: busRequestExMemoryArray = busLocalMemoryArray;
6399: } else {
6400: busRequestExMemoryStart = 0x10000000;
6401: busRequestExMemorySize = 0 << 20;
6402: busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
6403: }
6404: } else if (currentMPU < Model.MPU_MC68LC040) {
6405: if (busHighMemory060turboOn) {
6406: busRequestExMemoryStart = 0x10000000;
6407: busRequestExMemorySize = busLocalMemorySize;
6408: busRequestExMemoryArray = busLocalMemoryArray;
6409: } else {
6410: busRequestExMemoryStart = 0x01000000;
6411: busRequestExMemorySize = busHighMemorySize;
6412: busRequestExMemoryArray = busHighMemoryArray;
6413: }
6414: } else {
6415: busRequestExMemoryStart = 0x10000000;
6416: busRequestExMemorySize = busLocalMemorySize;
6417: busRequestExMemoryArray = busLocalMemoryArray;
6418: }
6419: busUpdateMemoryMap ();
6420:
6421:
6422: ROM.romReset ();
6423:
6424: RegisterList.drpSetMPU ();
6425:
6426: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
6427: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6428: MC68060.mmuReset ();
6429:
6430:
6431: if (Model.MPU_MC68020 <= currentMPU) {
6432: if ((7 & currentCopro0) == 1) {
6433: fpuMotherboardCoprocessor.epbSetMC68881 ();
6434: } else if ((7 & currentCopro0) == 2) {
6435: fpuMotherboardCoprocessor.epbSetMC68882 ();
6436: } else {
6437: fpuMotherboardCoprocessor.epbSetFullSpec ();
6438: }
6439: if ((8 & currentCopro0) == 0) {
6440: fpuMotherboardCoprocessor.epbSetExtended ();
6441: } else {
6442: fpuMotherboardCoprocessor.epbSetTriple ();
6443: }
6444: }
6445:
6446: if ((7 & currentCopro1) == 1) {
6447: fpuCoproboard1.epbSetMC68881 ();
6448: } else if ((7 & currentCopro1) == 2) {
6449: fpuCoproboard1.epbSetMC68882 ();
6450: } else {
6451: fpuCoproboard1.epbSetFullSpec ();
6452: }
6453: if ((8 & currentCopro1) == 0) {
6454: fpuCoproboard1.epbSetExtended ();
6455: } else {
6456: fpuCoproboard1.epbSetTriple ();
6457: }
6458:
6459: if ((7 & currentCopro2) == 1) {
6460: fpuCoproboard2.epbSetMC68881 ();
6461: } else if ((7 & currentCopro2) == 2) {
6462: fpuCoproboard2.epbSetMC68882 ();
6463: } else {
6464: fpuCoproboard2.epbSetFullSpec ();
6465: }
6466: if ((8 & currentCopro2) == 0) {
6467: fpuCoproboard2.epbSetExtended ();
6468: } else {
6469: fpuCoproboard2.epbSetTriple ();
6470: }
6471:
6472: if (Model.MPU_MC68040 <= currentMPU) {
6473: if ((7 & currentOnchipFPU) == 6) {
6474: fpuOnChipFPU.epbSetMC68060 ();
6475: } else {
6476: fpuOnChipFPU.epbSetFullSpec ();
6477: }
6478: if ((8 & currentOnchipFPU) == 0) {
6479: fpuOnChipFPU.epbSetExtended ();
6480: } else {
6481: fpuOnChipFPU.epbSetTriple ();
6482: }
6483: }
6484:
6485: if (!currentModel.isX68030 ()) {
6486: dmaCycleUnit = TMR_FREQ / 10000000L;
6487: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6488: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6489: mpuROMWaitCycles = 1;
6490: mpuRAMWaitCycles = 0;
6491: } else {
6492: dmaCycleUnit = TMR_FREQ / 12500000L;
6493: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6494: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6495: mpuROMWaitCycles = 0;
6496: mpuRAMWaitCycles = 0;
6497: }
6498:
6499: busWaitCycles = busWaitCyclesRequest;
6500: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
6501:
6502: HD63450.dmaReadCycles = (currentModel.isPRO () ? 6 :
6503: currentModel.isCompact () ? 4 :
6504: 5);
6505: HD63450.dmaWriteCycles = (currentModel.isPRO () ? 6 :
6506: 5);
6507:
6508: if (currentMPU < Model.MPU_MC68020) {
6509:
6510: mpuIgnoreAddressError = false;
6511:
6512: mpuCacheOn = false;
6513:
6514: } else if (currentMPU < Model.MPU_MC68040) {
6515:
6516: mpuIgnoreAddressError = true;
6517: fpuBox = fpuMotherboardCoprocessor;
6518: fpuBox.epbReset ();
6519: fpuFPn = fpuBox.epbFPn;
6520:
6521: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
6522:
6523: } else {
6524:
6525: mpuIgnoreAddressError = true;
6526: fpuBox = fpuOnChipFPU;
6527: fpuBox.epbReset ();
6528: fpuFPn = fpuBox.epbFPn;
6529:
6530: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6531: mpuCacheOn = (mpuCACR & 0x80008000) != 0;
6532:
6533: }
6534:
6535: mpuSetWait ();
6536:
6537:
6538: regSRT1 = regSRT0 = 0;
6539: regSRS = REG_SR_S;
6540: regSRM = 0;
6541: regSRI = REG_SR_I;
6542: regCCR = 0;
6543: Arrays.fill (regRn, 0);
6544:
6545: regRn[15] = MainMemory.mmrRls (0x00ff0000);
6546: regPC = MainMemory.mmrRls (0x00ff0004);
6547:
6548: MainMemory.mmrReset ();
6549:
6550: busReset ();
6551: if (InstructionBreakPoint.IBP_ON) {
6552: InstructionBreakPoint.ibpOp1MemoryMap = InstructionBreakPoint.ibpOp1SuperMap;
6553: InstructionBreakPoint.ibpReset ();
6554: }
6555: if (BranchLog.BLG_ON) {
6556: BranchLog.blgReset ();
6557: }
6558:
6559: mpuIMR = 0;
6560: mpuIRR = 0;
6561: if (MC68901.MFP_DELAYED_INTERRUPT) {
6562: mpuDIRR = 0;
6563: }
6564: mpuISR = 0;
6565:
6566:
6567: mpuStart ();
6568: }
6569: }, TMR_DELAY);
6570:
6571: }
6572:
6573:
6574:
6575: public static void mpuStopAndStart () {
6576: if (mpuTask == null) {
6577: mpuStart ();
6578: } else {
6579: if (RootPointerList.RTL_ON) {
6580: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6581: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6582: mpuStop (null);
6583: }
6584: } else {
6585: mpuStop (null);
6586: }
6587: }
6588: }
6589:
6590:
6591:
6592:
6593:
6594: public static void mpuStart () {
6595: if (mpuTask != null) {
6596: mpuClockLimit = 0L;
6597: System.out.println (Multilingual.mlnJapanese ?
6598: "MPU を停止します" :
6599: "MPU stops");
6600: mpuTask.cancel ();
6601: mpuTask = null;
6602: }
6603:
6604: for (AbstractButton button : mpuButtonsStopped) {
6605: button.setEnabled (false);
6606: }
6607: DisassembleList.ddpStoppedBy = null;
6608: System.out.println (Model.mpuNameOf (currentMPU) + (Multilingual.mlnJapanese ? " を起動します" : " starts up"));
6609: mpuTask = new TimerTask () {
6610: @Override public void run () {
6611: mpuContinue = true;
6612: mpuClockLimit = mpuClockTime + TMR_FREQ * TMR_INTERVAL / 1000;
6613: mpuExecuteCore ();
6614: }
6615: };
6616: tmrTimer.scheduleAtFixedRate (mpuTask, TMR_DELAY, TMR_INTERVAL);
6617:
6618: for (AbstractButton button : mpuButtonsRunning) {
6619: button.setEnabled (true);
6620: }
6621: }
6622:
6623:
6624:
6625: public static void mpuExecuteCore () {
6626:
6627: long nanoStart = System.nanoTime ();
6628:
6629: busSuper (RP5C15.rtcFirst, 0x00e8a000, 0x00e8c000);
6630:
6631:
6632: if (currentMPU < Model.MPU_MC68010) {
6633: MC68000.mpuCore ();
6634: } else if (currentMPU < Model.MPU_MC68020) {
6635: MC68010.mpuCore ();
6636: } else if (currentMPU < Model.MPU_MC68LC040) {
6637: MC68EC030.mpuCore ();
6638: } else {
6639: MC68060.mpuCore ();
6640: }
6641:
6642: if (dbgVisibleMask != 0) {
6643: dbgUpdate ();
6644: }
6645:
6646: long nanoEnd = System.nanoTime ();
6647: mpuTotalNano += nanoEnd - nanoStart;
6648: if (--mpuAdjustmentCounter == 0) {
6649:
6650: final double expectedNano = 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
6651:
6652: double coreNano0 = (double) mpuTotalNano;
6653: mpuTotalNano = 0L;
6654: double coreNanoA = (coreNano0 * 2.0 + mpuCoreNano1 + mpuCoreNano2) * 0.25;
6655: mpuCoreNano2 = mpuCoreNano1;
6656: mpuCoreNano1 = coreNano0;
6657:
6658:
6659:
6660: double actualPercent = Math.max (1.0, 100.0 * coreNanoA / expectedNano);
6661:
6662: double maxPercent = SoundSource.sndPlayOn ? 90.0 : 100.0;
6663:
6664:
6665:
6666:
6667: if (mpuUtilOn) {
6668:
6669: double targetPercent = Math.min (maxPercent, (double) mpuUtilRatio);
6670: mpuSetClockMHz ((1.2 - 0.2 * actualPercent / targetPercent) * mpuCurrentMHz);
6671: } else {
6672: mpuSetClockMHz (Math.min (maxPercent / actualPercent,
6673: 1.2 - 0.2 * mpuCurrentMHz / mpuClockMHz) * mpuCurrentMHz);
6674: }
6675: Indicator.indUpdate (actualPercent);
6676: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
6677: }
6678: }
6679:
6680:
6681:
6682:
6683: public static void mpuStop (String message) {
6684:
6685: mpuAdvanceCount = 0;
6686: mpuStepCount = 0;
6687: mpuContinue = false;
6688: mpuStop1 (message);
6689: }
6690: public static void mpuStop1 (String message) {
6691: if (mpuTask == null) {
6692: return;
6693: }
6694: DisassembleList.ddpStoppedBy = message;
6695: mpuClockLimit = 0L;
6696: System.out.println (Multilingual.mlnJapanese ?
6697: "MPU を停止します" :
6698: "MPU stops");
6699: mpuTask.cancel ();
6700: mpuTask = null;
6701:
6702: if (mpuStepCount != 0 && mpuContinue) {
6703: if (mpuStepCount == -1 || --mpuStepCount != 0) {
6704: mpuStep (mpuStepCount);
6705: return;
6706: }
6707: }
6708: mpuAdvanceCount = 0;
6709: mpuStepCount = 0;
6710: mpuContinue = false;
6711:
6712: for (AbstractButton button : mpuButtonsRunning) {
6713: button.setEnabled (false);
6714: }
6715: tmrTimer.schedule (new TimerTask () {
6716: @Override public void run () {
6717: mpuUpdateWindow ();
6718: }
6719: }, TMR_DELAY);
6720: }
6721:
6722:
6723:
6724:
6725:
6726:
6727: public static void mpuAdvance (int n) {
6728: if (mpuTask != null) {
6729: return;
6730: }
6731: mpuAdvanceCount = n;
6732: DisassembleList.ddpStoppedBy = null;
6733: mpuTask = new TimerTask () {
6734: @Override public void run () {
6735: mpuContinue = true;
6736: do {
6737: mpuClockLimit = mpuClockTime + 1L;
6738: mpuExecuteCore ();
6739: } while (mpuContinue && --mpuAdvanceCount != 0);
6740: mpuClockLimit = 0L;
6741: if (mpuTask != null) {
6742: mpuTask.cancel ();
6743: mpuTask = null;
6744: }
6745: if (mpuStepCount != 0 && mpuContinue) {
6746: if (mpuStepCount == -1 || --mpuStepCount != 0) {
6747: mpuStep (mpuStepCount);
6748: return;
6749: }
6750: }
6751: mpuAdvanceCount = 0;
6752: mpuStepCount = 0;
6753: mpuContinue = false;
6754: mpuUpdateWindow ();
6755: }
6756: };
6757: tmrTimer.schedule (mpuTask, TMR_DELAY);
6758: }
6759:
6760:
6761:
6762:
6763:
6764:
6765: public static void mpuStep (int n) {
6766: if (mpuTask != null) {
6767: return;
6768: }
6769: mpuStepCount = n;
6770: Disassembler.disDisassemble (new StringBuilder (), regPC, regSRS);
6771: if ((Disassembler.disStatus & (Disassembler.DIS_ALWAYS_BRANCH | Disassembler.DIS_SOMETIMES_BRANCH)) != 0) {
6772: if (mpuStepCount == -1 &&
6773: (Disassembler.disOC == 0x4e73 ||
6774: Disassembler.disOC == 0x4e74 ||
6775: Disassembler.disOC == 0x4e75 ||
6776: Disassembler.disOC == 0x4e77) &&
6777: mpuUntilReturnSRS == regSRS &&
6778: (currentMPU < Model.MPU_MC68LC040 ||
6779: mpuUntilReturnRP == (regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP)) &&
6780: mpuUntilReturnPC0 != regPC0 &&
6781: Integer.compareUnsigned (mpuUntilReturnSP, regRn[15]) <= 0) {
6782: mpuAdvanceCount = 0;
6783: mpuStepCount = 0;
6784: mpuContinue = false;
6785: mpuUpdateWindow ();
6786: return;
6787: }
6788: mpuAdvance (1);
6789: } else {
6790: if (InstructionBreakPoint.IBP_ON) {
6791: InstructionBreakPoint.ibpInstant (Disassembler.disPC, DisassembleList.ddpSupervisorMode);
6792: mpuStart ();
6793: }
6794: }
6795: }
6796:
6797:
6798:
6799:
6800:
6801:
6802:
6803:
6804:
6805:
6806:
6807: public static void mpuStepUntilReturn () {
6808: if (mpuTask != null) {
6809: return;
6810: }
6811: mpuUntilReturnSRS = regSRS;
6812: mpuUntilReturnRP = regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP;
6813: mpuUntilReturnPC0 = regPC0;
6814: mpuUntilReturnSP = regRn[15];
6815: mpuStep (-1);
6816: }
6817:
6818:
6819:
6820: public static void mpuUpdateWindow () {
6821: if (dbgVisibleMask != 0) {
6822: if ((dbgVisibleMask & DBG_DDP_VISIBLE_MASK) != 0) {
6823: DisassembleList.ddpBacktraceRecord = -1L;
6824: DisassembleList.ddpUpdate (-1, -1, false);
6825: }
6826: if (BranchLog.BLG_ON) {
6827: if ((dbgVisibleMask & DBG_BLG_VISIBLE_MASK) != 0) {
6828: BranchLog.blgUpdate (BranchLog.BLG_SELECT_NEWEST);
6829: }
6830: }
6831: if (ProgramFlowVisualizer.PFV_ON) {
6832: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
6833: ProgramFlowVisualizer.pfvUpdate ();
6834: }
6835: }
6836: if (RasterBreakPoint.RBP_ON) {
6837: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
6838: RasterBreakPoint.rbpUpdateFrame ();
6839: }
6840: }
6841: if (ScreenModeTest.SMT_ON) {
6842: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
6843: ScreenModeTest.smtUpdateFrame ();
6844: }
6845: }
6846: if (RootPointerList.RTL_ON) {
6847: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
6848: RootPointerList.rtlUpdateFrame ();
6849: }
6850: }
6851: if (SpritePatternViewer.SPV_ON) {
6852: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
6853: SpritePatternViewer.spvUpdateFrame ();
6854: }
6855: }
6856: if (PaletteViewer.PLV_ON) {
6857: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
6858: PaletteViewer.plvUpdateFrame ();
6859: }
6860: }
6861: if (ATCMonitor.ACM_ON) {
6862: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
6863: ATCMonitor.acmUpdateFrame ();
6864: }
6865: }
6866: }
6867:
6868: if (DebugConsole.dgtRequestRegs != 0) {
6869: if ((DebugConsole.dgtRequestRegs & 1) != 0) {
6870: ExpressionEvaluator.ElementType.ETY_COMMAND_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
6871: }
6872: if ((DebugConsole.dgtRequestRegs & 2) != 0) {
6873: ExpressionEvaluator.ElementType.ETY_COMMAND_FLOAT_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
6874: }
6875: if ((DebugConsole.dgtRequestRegs & 4) != 0) {
6876: DebugConsole.dgtPrintPrompt ();
6877: }
6878: DebugConsole.dgtRequestRegs = 0;
6879: }
6880:
6881: for (AbstractButton button : mpuButtonsRunning) {
6882: button.setEnabled (false);
6883: }
6884:
6885: for (AbstractButton button : mpuButtonsStopped) {
6886: button.setEnabled (true);
6887: }
6888: }
6889:
6890:
6891:
6892: public static JButton mpuMakeBreakButton () {
6893: return mpuAddButtonRunning (
6894: Multilingual.mlnToolTipText (
6895: ComponentFactory.createImageButton (
6896: LnF.LNF_BREAK_IMAGE,
6897: LnF.LNF_BREAK_DISABLED_IMAGE,
6898: "Stop", mpuDebugActionListener),
6899: "ja", "停止")
6900: );
6901: }
6902:
6903:
6904:
6905: public static JButton mpuMakeTraceButton () {
6906: return mpuAddButtonStopped (
6907: Multilingual.mlnToolTipText (
6908: ComponentFactory.createImageButton (
6909: LnF.LNF_TRACE_IMAGE,
6910: LnF.LNF_TRACE_DISABLED_IMAGE,
6911: "Trace", mpuDebugActionListener),
6912: "ja", "トレース")
6913: );
6914: }
6915:
6916:
6917:
6918: public static JButton mpuMakeTrace10Button () {
6919: return mpuAddButtonStopped (
6920: Multilingual.mlnToolTipText (
6921: ComponentFactory.createImageButton (
6922: LnF.LNF_TRACE_10_IMAGE,
6923: LnF.LNF_TRACE_10_DISABLED_IMAGE,
6924: "Trace 10 times", mpuDebugActionListener),
6925: "ja", "トレース 10 回")
6926: );
6927: }
6928:
6929:
6930:
6931: public static JButton mpuMakeTrace100Button () {
6932: return mpuAddButtonStopped (
6933: Multilingual.mlnToolTipText (
6934: ComponentFactory.createImageButton (
6935: LnF.LNF_TRACE_100_IMAGE,
6936: LnF.LNF_TRACE_100_DISABLED_IMAGE,
6937: "Trace 100 times", mpuDebugActionListener),
6938: "ja", "トレース 100 回")
6939: );
6940: }
6941:
6942:
6943:
6944: public static JButton mpuMakeStepButton () {
6945: return mpuAddButtonStopped (
6946: Multilingual.mlnToolTipText (
6947: ComponentFactory.createImageButton (
6948: LnF.LNF_STEP_IMAGE,
6949: LnF.LNF_STEP_DISABLED_IMAGE,
6950: "Step", mpuDebugActionListener),
6951: "ja", "ステップ")
6952: );
6953: }
6954:
6955:
6956:
6957: public static JButton mpuMakeStep10Button () {
6958: return mpuAddButtonStopped (
6959: Multilingual.mlnToolTipText (
6960: ComponentFactory.createImageButton (
6961: LnF.LNF_STEP_10_IMAGE,
6962: LnF.LNF_STEP_10_DISABLED_IMAGE,
6963: "Step 10 times", mpuDebugActionListener),
6964: "ja", "ステップ 10 回")
6965: );
6966: }
6967:
6968:
6969:
6970: public static JButton mpuMakeStep100Button () {
6971: return mpuAddButtonStopped (
6972: Multilingual.mlnToolTipText (
6973: ComponentFactory.createImageButton (
6974: LnF.LNF_STEP_100_IMAGE,
6975: LnF.LNF_STEP_100_DISABLED_IMAGE,
6976: "Step 100 times", mpuDebugActionListener),
6977: "ja", "ステップ 100 回")
6978: );
6979: }
6980:
6981:
6982:
6983: public static JButton mpuMakeReturnButton () {
6984: return mpuAddButtonStopped (
6985: Multilingual.mlnToolTipText (
6986: ComponentFactory.createImageButton (
6987: LnF.LNF_STEP_UNTIL_RETURN_IMAGE,
6988: LnF.LNF_STEP_UNTIL_RETURN_DISABLED_IMAGE,
6989: "Step until return", mpuDebugActionListener),
6990: "ja", "ステップアンティルリターン")
6991: );
6992: }
6993:
6994:
6995:
6996: public static JButton mpuMakeRunButton () {
6997: return mpuAddButtonStopped (
6998: Multilingual.mlnToolTipText (
6999: ComponentFactory.createImageButton (
7000: LnF.LNF_RUN_IMAGE,
7001: LnF.LNF_RUN_DISABLED_IMAGE,
7002: "Run", mpuDebugActionListener),
7003: "ja", "実行")
7004: );
7005: }
7006:
7007:
7008:
7009: public static <T extends AbstractButton> T mpuAddButtonRunning (T button) {
7010: button.setEnabled (mpuTask != null);
7011: mpuButtonsRunning.add (button);
7012: return button;
7013: }
7014:
7015:
7016:
7017: public static <T extends AbstractButton> T mpuAddButtonStopped (T button) {
7018: button.setEnabled (mpuTask == null);
7019: mpuButtonsStopped.add (button);
7020: return button;
7021: }
7022:
7023:
7024:
7025:
7026:
7027:
7028:
7029:
7030:
7031:
7032:
7033:
7034:
7035:
7036:
7037:
7038: public static final int EMX_OPCODE_BASE = 0x4e00;
7039: public static final int EMX_OPCODE_HFSBOOT = EMX_OPCODE_BASE + 0x00;
7040: public static final int EMX_OPCODE_HFSINST = EMX_OPCODE_BASE + 0x01;
7041: public static final int EMX_OPCODE_HFSSTR = EMX_OPCODE_BASE + 0x02;
7042: public static final int EMX_OPCODE_HFSINT = EMX_OPCODE_BASE + 0x03;
7043: public static final int EMX_OPCODE_EMXNOP = EMX_OPCODE_BASE + 0x04;
7044: public static final int EMX_OPCODE_EMXWAIT = EMX_OPCODE_BASE + 0x05;
7045:
7046: public static final String[] EMX_MNEMONIC_ARRAY = {
7047: "hfsboot",
7048: "hfsinst",
7049: "hfsstr",
7050: "hfsint",
7051: "emxnop",
7052: "emxwait",
7053: };
7054:
7055:
7056:
7057:
7058: public static void emxNop () {
7059: if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x00007140) {
7060: int head = regRn[9];
7061: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7062:
7063:
7064: emxPatchPCM8A (head, tail);
7065:
7066:
7067: emxCheckRSDRV202 (head, tail);
7068: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000716c) {
7069: int head = regRn[9];
7070: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7071:
7072:
7073: emxPatch060turbosys (head, tail);
7074:
7075:
7076: if (Z8530.SCC_FSX_MOUSE) {
7077: emxCheckFSX (head, tail);
7078: }
7079:
7080:
7081: if (HFS.HFS_USE_TWENTY_ONE) {
7082: emxCheckTwentyOne (head, tail);
7083: }
7084:
7085:
7086: LabeledAddress.lblClear ();
7087: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000972c) {
7088: int head = regRn[8] + 256;
7089:
7090: int tail = MC68060.mmuPeekLong (head - 208, 1);
7091:
7092:
7093: emxCheckBSIO021 (head, tail);
7094:
7095:
7096: emxPatchPCM8A (head, tail);
7097:
7098:
7099: emxCheckTMSIO031 (head, tail);
7100:
7101:
7102: LabeledAddress.lblClear ();
7103:
7104:
7105: if (dbgStopAtStart) {
7106: InstructionBreakPoint.ibpInstant (regRn[12], 0);
7107: }
7108: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000a090) {
7109: int head = regRn[8] + 256;
7110: int tail = MC68060.mmuPeekLongData (regRn[8] + 8, 1);
7111: String name = MC68060.mmuPeekStringZ (head - 60, 1);
7112: if (name.equalsIgnoreCase ("fsx.x")) {
7113:
7114:
7115: if (Z8530.SCC_FSX_MOUSE) {
7116: emxCheckFSX (head, tail);
7117: }
7118: }
7119: if (name.equalsIgnoreCase ("TwentyOne.x")) {
7120:
7121:
7122: if (HFS.HFS_USE_TWENTY_ONE) {
7123: emxCheckTwentyOne (head, tail);
7124: }
7125: }
7126: }
7127: }
7128:
7129: public static final int[] emxPCM8AFFMap = {
7130: 0x00000138, 0x000001f6, 0x00000394, 0x000011ec, 0x0000120a, 0x00001400, 0x00001814, 0x00001870, 0x00001882, 0x0000188a,
7131: 0x00001892, 0x000018a2, 0x000018a8, 0x000018ca, 0x000018d4, 0x000018e0, 0x000018e8, 0x00001908, 0x000019e4, 0x00001afa,
7132: 0x00001b58, 0x00001b7c, 0x00001bac, 0x00001c38, 0x00001ccc, 0x000021f8, 0x00002250, 0x00002258, 0x00002290, 0x000022a6,
7133: 0x000022b0, 0x000022c0, 0x000022c8, 0x000022de, 0x000022ea, 0x000030c8, 0x000030de, 0x000030e6, 0x000030ea, 0x000030f6,
7134: 0x00003112, 0x00003188, 0x0000334c, 0x0000338a, 0x000033a2, 0x000033c4, 0x000033d0, 0x0000341a, 0x00003428, 0x00003496,
7135: 0x000034a6, 0x000034d6, 0x0000fe0e, 0x0000fec8, 0x0000feec, 0x0000ff46, 0x0000ff4e,
7136: };
7137:
7138:
7139:
7140: public static void emxPatchPCM8A (int head, int tail) {
7141: if (head + 0x0000ff60 <= tail &&
7142: MC68060.mmuPeekLongData (head + 0x10f8, 1) == 0x50434d38 &&
7143: MC68060.mmuPeekLongData (head + 0x10fc, 1) == 0x41313032) {
7144: System.out.println (Multilingual.mlnJapanese ?
7145: "PCM8A.X 1.02 があります" :
7146: "PCM8A.X 1.02 exists");
7147: int patched = 0;
7148: int failed = 0;
7149:
7150: for (int offset : emxPCM8AFFMap) {
7151: if (MC68060.mmuPeekByteZeroData (head + offset, 1) == 0xff) {
7152: MC68060.mmuPokeByteData (head + offset, 0x00, 1);
7153: patched++;
7154: } else {
7155: failed++;
7156: }
7157: }
7158: if (patched != 0) {
7159: System.out.printf (Multilingual.mlnJapanese ?
7160: "PCM8A.X 1.02 にパッチをあてました (%d/%d)\n" :
7161: "PCM8A.X 1.02 was patched (%d/%d)\n",
7162: patched, patched + failed);
7163: }
7164: }
7165: }
7166:
7167:
7168:
7169: public static void emxPatch060turbosys (int head, int tail) {
7170:
7171:
7172:
7173:
7174: if (head + 0x00002000 <= tail &&
7175: MC68060.mmuPeekLongData (head + 0x00000ec0, 1) == 0x203c302e &&
7176: MC68060.mmuPeekLongData (head + 0x00000ec4, 1) == 0x3536227c &&
7177: MC68060.mmuPeekLongData (head + 0x00000ec8, 1) == 0x30363054) {
7178: System.out.println (Multilingual.mlnJapanese ?
7179: "060turbo.sys 0.56 があります" :
7180: "060turbo.sys 0.56 exists");
7181:
7182:
7183:
7184: int patched = 0;
7185: int failed = 0;
7186: if (MC68060.mmuPeekLongData (head + 0x000021e6, 1) == 0x08f90004 &&
7187: MC68060.mmuPeekLongData (head + 0x000021ea, 1) == 0x00ed0070) {
7188: MC68060.mmuPokeWordData (head + 0x000021e6, 0x0839, 1);
7189: patched++;
7190: } else {
7191: failed++;
7192: }
7193: System.out.printf (Multilingual.mlnJapanese ?
7194: "060turbo.sys 0.56 にパッチをあてました (%d/%d)\n" :
7195: "060turbo.sys 0.56 was patched (%d/%d)\n",
7196: patched, patched + failed);
7197: }
7198: }
7199:
7200:
7201:
7202: public static void emxCheckFSX (int head, int tail) {
7203: if (Z8530.SCC_FSX_MOUSE) {
7204: if (head + 0x00063200 <= tail &&
7205: "\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))) {
7206: System.out.println (Multilingual.mlnJapanese ?
7207: "FSX.X 3.10 があります" :
7208: "FSX.X 3.10 exists");
7209: Z8530.sccFSXMouseHook = head + 0x04f82a;
7210: Z8530.sccFSXMouseWork = head + 0x063184;
7211: }
7212: }
7213: }
7214:
7215:
7216:
7217:
7218:
7219:
7220: public static void emxCheckRSDRV202 (int head, int tail) {
7221: if (head + 0x000ea6 <= tail &&
7222: MC68060.mmuPeekEquals (head + 0x000e4e, "RS-232C DRIVER for X68000 version 2.02")) {
7223: if (RS232CTerminal.trmRSDRV202Head != head) {
7224: RS232CTerminal.trmRSDRV202Head = head;
7225: int[] patchData = {
7226:
7227:
7228: 0x05f8, 0x000a, 0x000b,
7229:
7230: 0x0600, 0xd040, 0x2048,
7231:
7232: 0x060e, 0x3030, 0x4e90,
7233: 0x0610, 0x0000, 0x2048,
7234:
7235: 0x074e, 0x0821, 0x2041,
7236: 0x0750, 0x0410, 0x3200,
7237: 0x0752, 0x0207, 0x303c,
7238: 0x0754, 0x0102, 0x0823,
7239: 0x0756, 0x0080, 0xe268,
7240: 0x0758, 0x003f, 0x72fe,
7241: 0x075a, 0x001f, 0xd141,
7242: 0x075c, 0x000e, 0x2208,
7243: 0x075e, 0x0006, 0x4e75,
7244:
7245:
7246: 0x0ab0, 0x0040, 0x0400,
7247: 0x0ad2, 0x0040, 0x0400,
7248: 0x0af4, 0x0040, 0x0400,
7249: 0x0b16, 0x0040, 0x0400,
7250: 0x0b38, 0x0040, 0x0400,
7251:
7252:
7253: 0x0cae, 0x0009, 0x000b,
7254: };
7255: int patched = 0;
7256: int failed = 0;
7257: for (int i = 0; i < patchData.length; i += 3) {
7258: int a = head + patchData[i];
7259: int b = patchData[i + 1];
7260: int c = patchData[i + 2];
7261: int d = MC68060.mmuPeekWordZeroData (a, 1);
7262: if (d == b) {
7263: MC68060.mmuPokeWordData (a, c, 1);
7264: patched++;
7265: } else if (d != c) {
7266: failed++;
7267: }
7268: }
7269: System.out.printf ("RSDRV.SYS 2.02 found at %08X and patched (%d/%d)\n", head, patched, patched + failed);
7270: }
7271: }
7272: }
7273:
7274:
7275:
7276:
7277:
7278: public static void emxCheckTMSIO031 (int head, int tail) {
7279: if (head + 0x000fc4 <= tail &&
7280: MC68060.mmuPeekEquals (head + 0x000d1c, "TMSIO version 0.31 Copyright (C) 1990-93 by Miki Hoshino")) {
7281: if (RS232CTerminal.trmTMSIO031Head != head) {
7282: RS232CTerminal.trmTMSIO031Head = head;
7283: System.out.printf ("TMSIO 0.31 found at %08X\n", head);
7284: }
7285: }
7286: }
7287:
7288:
7289:
7290:
7291:
7292: public static void emxCheckBSIO021 (int head, int tail) {
7293: if (head + 0x001c2c <= tail &&
7294: MC68060.mmuPeekEquals (head + 0x001a66, "BSIO version 0.21 Copyright (C) 1994 By BAZU")) {
7295: if (RS232CTerminal.trmBSIO021Head != head) {
7296: RS232CTerminal.trmBSIO021Head = head;
7297: System.out.printf ("BSIO 0.21 found at %08X\n", head);
7298: }
7299: }
7300: }
7301:
7302:
7303:
7304: public static void emxCheckTwentyOne (int head, int tail) {
7305: if (HFS.HFS_USE_TWENTY_ONE &&
7306: head + 64 <= tail) {
7307: if (MainMemory.mmrTwentyOneOptionAddress != 0 ||
7308: MainMemory.mmrHumanVersion <= 0) {
7309: return;
7310: }
7311: int name1 = MC68060.mmuPeekLongData (head + 14, 1);
7312: if (name1 == ('*' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7313: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7314: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '*')) {
7315: MainMemory.mmrTwentyOneOptionAddress = -1;
7316: }
7317: } else if (name1 == ('?' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7318: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7319: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '?') ||
7320: name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | 'E')) {
7321: System.out.println (Multilingual.mlnJapanese ?
7322: "TwentyOne.x があります" :
7323: "TwentyOne.x exists");
7324: MainMemory.mmrTwentyOneOptionAddress = head + 22;
7325: }
7326: }
7327: }
7328: }
7329:
7330:
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: public static final boolean IRP_BITREV_REVERSE = false;
7381: public static final boolean IRP_BITREV_SHIFT = false;
7382: public static final boolean IRP_BITREV_TABLE = true;
7383:
7384: public static final boolean IRP_MOVEM_MAINMEMORY = true;
7385: public static final boolean IRP_MOVEM_EXPAND = false;
7386: public static final boolean IRP_MOVEM_LOOP = false;
7387: public static final boolean IRP_MOVEM_SHIFT_LEFT = false;
7388: public static final boolean IRP_MOVEM_SHIFT_RIGHT = true;
7389: public static final boolean IRP_MOVEM_ZEROS = false;
7390:
7391:
7392: public static void irpReset () {
7393:
7394: CRTC.crtReset ();
7395: VideoController.vcnReset ();
7396: HD63450.dmaReset ();
7397: MC68901.mfpReset ();
7398: Keyboard.kbdReset ();
7399: RP5C15.rtcReset ();
7400: PrinterPort.prnReset ();
7401: SoundSource.sndReset ();
7402: OPM.opmReset ();
7403: ADPCM.pcmReset ();
7404: FDC.fdcReset ();
7405: IOInterrupt.ioiReset ();
7406: eb2Reset ();
7407: if (HostCDROM.HCD_ENABLED) {
7408: HostCDROM.hcdReset ();
7409: }
7410: SPC.spcReset ();
7411: Z8530.sccReset ();
7412: RS232CTerminal.trmReset ();
7413: PPI.ppiReset ();
7414: HFS.hfsReset ();
7415: SpriteScreen.sprReset ();
7416:
7417: if (MercuryUnit.MU4_ON) {
7418: MercuryUnit.mu4Reset ();
7419: }
7420: xt3Reset ();
7421: SRAM.smrReset ();
7422: CONDevice.conReset ();
7423: TextCopy.txcReset ();
7424: }
7425:
7426:
7427:
7428:
7429:
7430:
7431:
7432:
7433:
7434:
7435:
7436:
7437:
7438:
7439:
7440:
7441:
7442:
7443:
7444:
7445:
7446:
7447:
7448:
7449:
7450:
7451:
7452:
7453:
7454:
7455:
7456:
7457:
7458:
7459:
7460:
7461:
7462:
7463:
7464:
7465:
7466:
7467:
7468:
7469:
7470:
7471:
7472:
7473:
7474:
7475:
7476:
7477:
7478:
7479:
7480:
7481:
7482:
7483:
7484:
7485:
7486:
7487:
7488:
7489:
7490:
7491:
7492:
7493:
7494:
7495:
7496:
7497:
7498:
7499:
7500:
7501:
7502:
7503:
7504:
7505:
7506:
7507:
7508:
7509:
7510:
7511:
7512:
7513:
7514:
7515:
7516:
7517:
7518:
7519:
7520:
7521:
7522:
7523:
7524:
7525:
7526:
7527:
7528:
7529:
7530:
7531:
7532:
7533:
7534:
7535:
7536:
7537:
7538:
7539:
7540:
7541:
7542:
7543:
7544:
7545:
7546:
7547:
7548:
7549:
7550:
7551:
7552:
7553:
7554:
7555:
7556:
7557:
7558:
7559:
7560:
7561:
7562:
7563:
7564:
7565:
7566:
7567:
7568:
7569:
7570:
7571:
7572:
7573:
7574:
7575:
7576:
7577:
7578:
7579:
7580:
7581:
7582:
7583:
7584:
7585:
7586:
7587:
7588:
7589:
7590:
7591:
7592:
7593:
7594:
7595:
7596:
7597:
7598:
7599:
7600:
7601:
7602:
7603:
7604:
7605:
7606:
7607:
7608:
7609:
7610:
7611:
7612:
7613:
7614:
7615:
7616:
7617:
7618:
7619:
7620:
7621:
7622:
7623:
7624:
7625:
7626:
7627:
7628:
7629:
7630:
7631:
7632:
7633:
7634:
7635:
7636:
7637:
7638:
7639:
7640:
7641:
7642:
7643:
7644:
7645:
7646:
7647:
7648:
7649:
7650:
7651:
7652:
7653:
7654:
7655:
7656:
7657:
7658:
7659:
7660:
7661:
7662:
7663:
7664:
7665:
7666:
7667:
7668:
7669:
7670:
7671:
7672:
7673:
7674:
7675:
7676:
7677:
7678:
7679:
7680:
7681:
7682:
7683:
7684:
7685:
7686:
7687:
7688:
7689:
7690:
7691:
7692:
7693:
7694:
7695:
7696:
7697:
7698:
7699:
7700:
7701:
7702:
7703:
7704:
7705:
7706:
7707:
7708:
7709:
7710:
7711:
7712:
7713:
7714:
7715:
7716:
7717:
7718:
7719:
7720:
7721:
7722:
7723:
7724:
7725:
7726:
7727:
7728:
7729:
7730:
7731:
7732:
7733:
7734:
7735:
7736:
7737:
7738:
7739:
7740:
7741:
7742:
7743:
7744:
7745:
7746:
7747:
7748:
7749:
7750:
7751:
7752:
7753:
7754:
7755:
7756:
7757:
7758:
7759:
7760:
7761:
7762:
7763:
7764:
7765:
7766:
7767:
7768:
7769:
7770:
7771:
7772:
7773:
7774:
7775:
7776:
7777:
7778:
7779:
7780:
7781:
7782:
7783:
7784:
7785:
7786:
7787:
7788:
7789:
7790:
7791:
7792:
7793:
7794:
7795:
7796:
7797:
7798:
7799:
7800:
7801:
7802:
7803:
7804:
7805:
7806:
7807:
7808:
7809:
7810:
7811:
7812:
7813:
7814:
7815:
7816:
7817:
7818:
7819:
7820:
7821:
7822:
7823:
7824:
7825:
7826:
7827:
7828:
7829:
7830:
7831:
7832:
7833:
7834:
7835:
7836:
7837:
7838:
7839:
7840:
7841:
7842:
7843:
7844:
7845:
7846:
7847:
7848:
7849:
7850:
7851:
7852:
7853:
7854:
7855:
7856:
7857:
7858:
7859:
7860:
7861:
7862:
7863:
7864:
7865:
7866:
7867:
7868:
7869:
7870:
7871:
7872:
7873:
7874:
7875:
7876:
7877:
7878:
7879:
7880:
7881:
7882:
7883:
7884:
7885:
7886:
7887:
7888:
7889:
7890:
7891:
7892:
7893:
7894:
7895:
7896:
7897:
7898:
7899:
7900:
7901:
7902:
7903:
7904:
7905:
7906:
7907:
7908:
7909:
7910:
7911:
7912:
7913:
7914:
7915:
7916:
7917:
7918:
7919:
7920:
7921:
7922:
7923:
7924:
7925:
7926:
7927:
7928:
7929:
7930:
7931:
7932:
7933:
7934:
7935:
7936:
7937:
7938:
7939:
7940:
7941:
7942:
7943:
7944:
7945:
7946:
7947:
7948:
7949:
7950:
7951:
7952:
7953:
7954:
7955:
7956:
7957:
7958:
7959:
7960:
7961:
7962:
7963:
7964:
7965:
7966:
7967:
7968:
7969:
7970:
7971:
7972:
7973:
7974:
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: 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);
8012:
8013: public static final boolean EFA_SEPARATE_AR = false;
8014:
8015:
8016:
8017:
8018:
8019:
8020: public static final boolean BUS_SPLIT_UNALIGNED_LONG = false;
8021:
8022:
8023: public static final int BUS_MOTHER_BITS = 24;
8024: public static final int BUS_MOTHER_SIZE = BUS_MOTHER_BITS < 32 ? 1 << BUS_MOTHER_BITS : 0;
8025: public static final int BUS_MOTHER_MASK = BUS_MOTHER_SIZE - 1;
8026:
8027: public static final int BUS_ARRAY_SIZE = BUS_MOTHER_SIZE;
8028:
8029:
8030: public static final int BUS_PAGE_BITS = 12;
8031: public static final int BUS_PAGE_SIZE = 1 << BUS_PAGE_BITS;
8032: public static final int BUS_PAGE_COUNT = 1 << (32 - BUS_PAGE_BITS);
8033:
8034:
8035: public static final int MPU_SS_BYTE = 0;
8036: public static final int MPU_SS_WORD = 1;
8037: public static final int MPU_SS_LONG = 2;
8038:
8039:
8040: public static final int MPU_WR_WRITE = 0;
8041: public static final int MPU_WR_READ = 1;
8042:
8043:
8044: public static final int MPU_US_USER = 0;
8045: public static final int MPU_US_SUPERVISOR = 1;
8046:
8047:
8048: public static final MemoryMappedDevice[] busUserMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8049: public static final MemoryMappedDevice[] busSuperMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8050: public static MemoryMappedDevice[] busMemoryMap;
8051:
8052:
8053: public static boolean busHimem68000;
8054:
8055:
8056: public static final int BUS_HIGH_MEMORY_START = 0x01000000;
8057: public static int busHighMemorySize;
8058: public static byte[] busHighMemoryArray;
8059: public static boolean busHighMemorySaveOn;
8060: public static boolean busHighMemory060turboOn;
8061:
8062:
8063: public static final int BUS_LOCAL_MEMORY_START = 0x10000000;
8064: public static int busLocalMemorySize;
8065: public static byte[] busLocalMemoryArray;
8066: public static boolean busLocalMemorySaveOn;
8067:
8068:
8069: public static final byte[] BUS_DUMMY_MEMORY_ARRAY = new byte[0];
8070: public static int busRequestExMemoryStart;
8071: public static int busRequestExMemorySize;
8072: public static byte[] busRequestExMemoryArray;
8073: public static int busExMemoryStart;
8074: public static int busExMemorySize;
8075: public static byte[] busExMemoryArray;
8076:
8077:
8078: public static boolean busRequestCutFC2Pin;
8079: public static boolean busCutFC2Pin;
8080:
8081:
8082:
8083: public static void busInit () {
8084:
8085:
8086: if (!DataBreakPoint.DBP_ON) {
8087: busMemoryMap = busSuperMap;
8088: }
8089:
8090:
8091: int highMemorySizeMB = Settings.sgsGetInt ("highmemory");
8092: busHighMemorySize = highMemorySizeMB == 16 ? highMemorySizeMB << 20 : 0 << 20;
8093: if (busHighMemorySize == 0) {
8094: System.out.println (Multilingual.mlnJapanese ?
8095: "X68030/Xellent30 のハイメモリはありません" :
8096: "X68030/Xellent30 high memory does not exists");
8097: } else {
8098: System.out.printf (Multilingual.mlnJapanese ?
8099: "X68030/Xellent30 のハイメモリのサイズは %dMB です\n" :
8100: "X68030/Xellent30 high memory size is %dMB\n",
8101: busHighMemorySize >> 20);
8102: }
8103: busHighMemoryArray = new byte[busHighMemorySize];
8104:
8105: busHimem68000 = Settings.sgsGetOnOff ("himem68000");
8106:
8107: busHighMemorySaveOn = Settings.sgsGetOnOff ("highmemorysave");
8108: busHighMemory060turboOn = Settings.sgsGetOnOff ("highmemory060turbo");
8109:
8110: byte[] highMemoryArray = Settings.sgsGetData ("highmemorydata");
8111: if (busHighMemorySize != 0) {
8112: if (highMemoryArray.length != 0) {
8113: System.out.println (Multilingual.mlnJapanese ?
8114: "X68030/Xellent30 のハイメモリのデータを復元します" :
8115: "X68030/Xellent30 high memory data is restored");
8116: System.arraycopy (highMemoryArray, 0, busHighMemoryArray, 0, Math.min (highMemoryArray.length, busHighMemorySize));
8117: } else {
8118: System.out.println (Multilingual.mlnJapanese ?
8119: "X68030/Xellent30 のハイメモリをゼロクリアします" :
8120: "X68030/Xellent30 high memory is zero-cleared");
8121: }
8122: if (highMemoryArray.length < busHighMemorySize) {
8123: Arrays.fill (busHighMemoryArray, highMemoryArray.length, busHighMemorySize, (byte) 0);
8124: }
8125: }
8126:
8127:
8128: int localMemorySizeMB = Settings.sgsGetInt ("localmemory");
8129: busLocalMemorySize = (localMemorySizeMB == 16 ||
8130: localMemorySizeMB == 32 ||
8131: localMemorySizeMB == 64 ||
8132: localMemorySizeMB == 128 ||
8133: localMemorySizeMB == 256 ||
8134: localMemorySizeMB == 384 ||
8135: localMemorySizeMB == 512 ||
8136: localMemorySizeMB == 768 ?
8137: localMemorySizeMB << 20 :
8138: 128 << 20);
8139: if (busLocalMemorySize == 0) {
8140: System.out.println (Multilingual.mlnJapanese ?
8141: "060turbo のハイメモリはありません" :
8142: "060turbo high memory does not exists");
8143: } else {
8144: System.out.printf (Multilingual.mlnJapanese ?
8145: "060turbo のハイメモリのサイズは %dMB です\n" :
8146: "060turbo high memory size is %dMB\n",
8147: busLocalMemorySize >> 20);
8148: }
8149: busLocalMemoryArray = new byte[busLocalMemorySize];
8150:
8151: busLocalMemorySaveOn = Settings.sgsGetOnOff ("localmemorysave");
8152:
8153: byte[] localMemoryArray = Settings.sgsGetData ("localmemorydata");
8154: if (busLocalMemorySize != 0) {
8155: if (localMemoryArray.length != 0) {
8156: System.out.println (Multilingual.mlnJapanese ?
8157: "060turbo のハイメモリのデータを復元します" :
8158: "060turbo high memory data is restored");
8159: System.arraycopy (localMemoryArray, 0, busLocalMemoryArray, 0, Math.min (localMemoryArray.length, busLocalMemorySize));
8160: } else {
8161: System.out.println (Multilingual.mlnJapanese ?
8162: "060turbo のハイメモリをゼロクリアします" :
8163: "060turbo high memory is zero-cleared");
8164: }
8165: if (localMemoryArray.length < busLocalMemorySize) {
8166: Arrays.fill (busLocalMemoryArray, localMemoryArray.length, busLocalMemorySize, (byte) 0);
8167: }
8168: }
8169:
8170:
8171: busExMemoryStart = busRequestExMemoryStart = 0x10000000;
8172: busExMemorySize = busRequestExMemorySize = 0 << 20;
8173: busExMemoryArray = busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
8174:
8175:
8176: busRequestCutFC2Pin = Settings.sgsGetOnOff ("cutfc2pin");
8177: busCutFC2Pin = !busRequestCutFC2Pin;
8178:
8179: busUpdateMemoryMap ();
8180:
8181: }
8182:
8183:
8184:
8185: public static void busTini () {
8186: Settings.sgsPutOnOff ("himem68000", busHimem68000);
8187: Settings.sgsPutInt ("highmemory", busHighMemorySize >>> 20);
8188: Settings.sgsPutOnOff ("highmemorysave", busHighMemorySaveOn);
8189: Settings.sgsPutOnOff ("highmemory060turbo", busHighMemory060turboOn);
8190: Settings.sgsPutData ("highmemorydata", busHighMemorySaveOn ? busHighMemoryArray : new byte[0]);
8191: Settings.sgsPutInt ("localmemory", busLocalMemorySize >>> 20);
8192: Settings.sgsPutOnOff ("localmemorysave", busLocalMemorySaveOn);
8193: Settings.sgsPutData ("localmemorydata", busLocalMemorySaveOn ? busLocalMemoryArray : new byte[0]);
8194: Settings.sgsPutOnOff ("cutfc2pin", busRequestCutFC2Pin);
8195: }
8196:
8197: public static void busUpdateMemoryMap () {
8198: if (busExMemoryStart == busRequestExMemoryStart &&
8199: busExMemorySize == busRequestExMemorySize &&
8200: busExMemoryArray == busRequestExMemoryArray &&
8201: busExMemoryArray.length == busExMemorySize &&
8202: busCutFC2Pin == busRequestCutFC2Pin) {
8203: return;
8204: }
8205:
8206: busExMemoryStart = busRequestExMemoryStart;
8207: busExMemorySize = busRequestExMemorySize;
8208: busExMemoryArray = busRequestExMemoryArray;
8209: if (busExMemoryArray.length != busExMemorySize) {
8210: byte[] newArray = new byte[busExMemorySize];
8211: int copySize = Math.min (busExMemoryArray.length, busExMemorySize);
8212: if (copySize > 0) {
8213: System.arraycopy (busExMemoryArray, 0, newArray, 0, copySize);
8214: }
8215: if (busExMemoryArray == busHighMemoryArray) {
8216: busHighMemoryArray = newArray;
8217: } else if (busExMemoryArray == busLocalMemoryArray) {
8218: busLocalMemoryArray = newArray;
8219: }
8220: busExMemoryArray = newArray;
8221: }
8222:
8223: busCutFC2Pin = busRequestCutFC2Pin;
8224:
8225:
8226:
8227:
8228:
8229:
8230:
8231:
8232:
8233:
8234:
8235:
8236: busSuper (MemoryMappedDevice.MMD_MMR, 0x00000000, 0x00002000);
8237: busUser ( MemoryMappedDevice.MMD_MMR, 0x00002000, 0x00c00000);
8238:
8239:
8240:
8241:
8242:
8243:
8244:
8245:
8246:
8247:
8248:
8249:
8250:
8251:
8252:
8253:
8254:
8255:
8256:
8257:
8258:
8259:
8260:
8261:
8262: busSuper (MemoryMappedDevice.MMD_GE0, 0x00c00000, 0x00c80000);
8263: busSuper (MemoryMappedDevice.MMD_GE1, 0x00c80000, 0x00d00000);
8264: busSuper (MemoryMappedDevice.MMD_GE2, 0x00d00000, 0x00d80000);
8265: busSuper (MemoryMappedDevice.MMD_GE3, 0x00d80000, 0x00e00000);
8266:
8267:
8268:
8269:
8270: busSuper (MemoryMappedDevice.MMD_TXT, 0x00e00000, 0x00e80000);
8271:
8272:
8273:
8274:
8275: busSuper (MemoryMappedDevice.MMD_CRT, 0x00e80000, 0x00e82000);
8276:
8277:
8278:
8279:
8280:
8281: busSuper (MemoryMappedDevice.MMD_VCN, 0x00e82000, 0x00e84000);
8282:
8283:
8284:
8285:
8286: busSuper (MemoryMappedDevice.MMD_DMA, 0x00e84000, 0x00e86000);
8287:
8288:
8289:
8290:
8291: busSuper (MemoryMappedDevice.MMD_SVS, 0x00e86000, 0x00e88000);
8292:
8293:
8294:
8295:
8296: busSuper (MemoryMappedDevice.MMD_MFP, 0x00e88000, 0x00e8a000);
8297:
8298:
8299:
8300:
8301: busSuper (MemoryMappedDevice.MMD_RTC_FIRST, 0x00e8a000, 0x00e8c000);
8302:
8303:
8304:
8305:
8306: busSuper (MemoryMappedDevice.MMD_PRN, 0x00e8c000, 0x00e8e000);
8307:
8308:
8309:
8310:
8311: busSuper (MemoryMappedDevice.MMD_SYS, 0x00e8e000, 0x00e90000);
8312:
8313:
8314:
8315:
8316: busSuper (MemoryMappedDevice.MMD_OPM, 0x00e90000, 0x00e92000);
8317:
8318:
8319:
8320:
8321: busSuper (MemoryMappedDevice.MMD_PCM, 0x00e92000, 0x00e94000);
8322:
8323:
8324:
8325:
8326: busSuper (MemoryMappedDevice.MMD_FDC, 0x00e94000, 0x00e96000);
8327:
8328:
8329:
8330:
8331:
8332: busSuper (MemoryMappedDevice.MMD_HDC, 0x00e96000, 0x00e98000);
8333:
8334:
8335:
8336:
8337: busSuper (MemoryMappedDevice.MMD_SCC, 0x00e98000, 0x00e9a000);
8338:
8339:
8340:
8341:
8342: busSuper (MemoryMappedDevice.MMD_PPI, 0x00e9a000, 0x00e9c000);
8343:
8344:
8345:
8346:
8347: busSuper (MemoryMappedDevice.MMD_IOI, 0x00e9c000, 0x00e9e000);
8348:
8349:
8350:
8351:
8352:
8353:
8354:
8355:
8356:
8357: busSuper (MemoryMappedDevice.MMD_XB1, 0x00e9e000, 0x00ea0000);
8358:
8359:
8360:
8361:
8362:
8363: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ea0000, 0x00eae000);
8364:
8365:
8366:
8367:
8368:
8369:
8370:
8371:
8372:
8373:
8374:
8375:
8376:
8377:
8378:
8379: busSuper (MemoryMappedDevice.MMD_XB2, 0x00eae000, 0x00eb0000);
8380:
8381:
8382:
8383:
8384:
8385:
8386:
8387:
8388: busSuper (MemoryMappedDevice.MMD_SPR, 0x00eb0000, 0x00ec0000);
8389:
8390:
8391:
8392:
8393:
8394:
8395:
8396:
8397:
8398:
8399:
8400:
8401:
8402: busSuper (MemoryMappedDevice.MMD_XB3, 0x00ec0000, 0x00ed0000);
8403:
8404:
8405:
8406:
8407:
8408:
8409: busSuper (MemoryMappedDevice.MMD_SMR, 0x00ed0000, 0x00ed0000 + 16384);
8410: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ed0000 + 16384, 0x00ed0000 + 65536);
8411:
8412:
8413:
8414:
8415:
8416:
8417:
8418:
8419: busSuper (MemoryMappedDevice.MMD_XB4, 0x00ee0000, 0x00f00000);
8420:
8421:
8422:
8423:
8424:
8425:
8426:
8427:
8428:
8429:
8430: busSuper (MemoryMappedDevice.MMD_CG1, 0x00f00000, 0x00f40000);
8431:
8432:
8433:
8434:
8435:
8436:
8437:
8438: busSuper (MemoryMappedDevice.MMD_CG2, 0x00f40000, 0x00fc0000);
8439:
8440:
8441:
8442:
8443:
8444:
8445:
8446:
8447:
8448:
8449:
8450:
8451:
8452:
8453: busSuper (MemoryMappedDevice.MMD_ROM, 0x00fc0000, 0x01000000);
8454:
8455: }
8456:
8457: public static void busReset () {
8458: if (regSRS != 0) {
8459: if (DataBreakPoint.DBP_ON) {
8460: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpSuperMap;
8461: } else {
8462: busMemoryMap = busSuperMap;
8463: }
8464: } else {
8465: if (DataBreakPoint.DBP_ON) {
8466: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpUserMap;
8467: } else {
8468: busMemoryMap = busUserMap;
8469: }
8470: }
8471: }
8472:
8473:
8474:
8475:
8476:
8477: public static void busUser (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8478: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8479: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8480: if (false &&
8481: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8482: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8483: System.out.printf ("ERROR: busUser (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8484: }
8485: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8486: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8487: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8488: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8489: int startPage = blockStartPage + motherStartPage;
8490: int endPage = blockStartPage + motherEndPage;
8491: for (int page = startPage; page < endPage; page++) {
8492: MemoryMappedDevice superMmd = exMemoryStartPage <= page && page < exMemoryEndPage ? MemoryMappedDevice.MMD_XMM : mmd;
8493: busUserMap[page] = busSuperMap[page] = superMmd;
8494: if (InstructionBreakPoint.IBP_ON) {
8495: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8496: InstructionBreakPoint.ibpUserMap[page] = superMmd;
8497: }
8498: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8499: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8500: }
8501: }
8502: if (DataBreakPoint.DBP_ON) {
8503: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8504: DataBreakPoint.dbpUserMap[page] = superMmd;
8505: }
8506: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8507: DataBreakPoint.dbpSuperMap[page] = superMmd;
8508: }
8509: }
8510: }
8511: }
8512: }
8513:
8514:
8515:
8516:
8517:
8518: public static void busSuper (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8519: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8520: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8521: if (false &&
8522: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8523: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8524: System.out.printf ("ERROR: busSuper (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8525: }
8526: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8527: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8528: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8529: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8530: int startPage = blockStartPage + motherStartPage;
8531: int endPage = blockStartPage + motherEndPage;
8532: for (int page = startPage; page < endPage; page++) {
8533: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
8534: MemoryMappedDevice userMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : busCutFC2Pin ? mmd : MemoryMappedDevice.MMD_NUL;
8535: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
8536: busUserMap[page] = userMmd;
8537: busSuperMap[page] = superMmd;
8538: if (InstructionBreakPoint.IBP_ON) {
8539: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8540: InstructionBreakPoint.ibpUserMap[page] = userMmd;
8541: }
8542: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8543: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8544: }
8545: }
8546: if (DataBreakPoint.DBP_ON) {
8547: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8548: DataBreakPoint.dbpUserMap[page] = userMmd;
8549: }
8550: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8551: DataBreakPoint.dbpSuperMap[page] = superMmd;
8552: }
8553: }
8554: }
8555: }
8556: }
8557:
8558:
8559:
8560: public static byte busPbs (int a) {
8561: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a);
8562: }
8563:
8564:
8565:
8566: public static int busPbz (int a) {
8567: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a);
8568: }
8569:
8570:
8571:
8572: public static int busPws (int a) {
8573: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8574: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
8575: } else {
8576: int a1 = a + 1;
8577: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
8578: }
8579: }
8580:
8581:
8582:
8583: public static int busPwse (int a) {
8584: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
8585: }
8586:
8587:
8588:
8589: public static int busPwz (int a) {
8590: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8591: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
8592: } else {
8593: int a1 = a + 1;
8594: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
8595: }
8596: }
8597:
8598:
8599:
8600: public static int busPwze (int a) {
8601: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
8602: }
8603:
8604:
8605:
8606: public static int busPls (int a) {
8607: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8608: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
8609: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8610: int a2 = a + 2;
8611: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a) << 16 | busSuperMap[a2 >>> BUS_PAGE_BITS].mmdPwz (a2);
8612: } else {
8613: int a1 = a + 1;
8614: int a3 = a + 3;
8615: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 24 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPwz (a1) << 8 | busSuperMap[a3 >>> BUS_PAGE_BITS].mmdPbz (a3);
8616: }
8617: }
8618:
8619:
8620:
8621: public static int busPlsf (int a) {
8622: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
8623: }
8624:
8625:
8626:
8627: public static long busPqs (int a) {
8628: return (long) busPls (a) << 32 | busPls (a + 4) & 0xffffffffL;
8629: }
8630:
8631:
8632:
8633: public static int busSearchByte (int start, int end, int c) {
8634: for (int a = start; a < end; a++) {
8635: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) == c) {
8636: return a;
8637: }
8638: }
8639: return -1;
8640: }
8641: public static int busSearchWord (int start, int end, int c) {
8642: for (int a = start; a < end; a += 2) {
8643: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) == c) {
8644: return a;
8645: }
8646: }
8647: return -1;
8648: }
8649: public static int busSearchByteArray (int start, int end, int[] array) {
8650: int l = array.length;
8651: end -= l;
8652: int c = array[0];
8653: a:
8654: for (int a = start; a <= end; a++) {
8655: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) != c) {
8656: continue a;
8657: }
8658: for (int i = 1, b = a + 1; i < l; i++, b++) {
8659: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPbz (b) != array[i]) {
8660: continue a;
8661: }
8662: }
8663: return a;
8664: }
8665: return -1;
8666: }
8667: public static int busSearchWordArray (int start, int end, int[] array) {
8668: int l = array.length;
8669: end -= l;
8670: int c = array[0];
8671: a:
8672: for (int a = start; a <= end; a += 2) {
8673: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) != c) {
8674: continue a;
8675: }
8676: for (int i = 1, b = a + 2; i < l; i++, b += 2) {
8677: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPwz (b) != array[i]) {
8678: continue a;
8679: }
8680: }
8681: return a;
8682: }
8683: return -1;
8684: }
8685:
8686:
8687:
8688:
8689: public static byte busRbs (int a) throws M68kException {
8690: if (DataBreakPoint.DBP_ON) {
8691: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
8692: } else {
8693: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
8694: }
8695: }
8696:
8697:
8698:
8699: public static int busRbz (int a) throws M68kException {
8700: if (DataBreakPoint.DBP_ON) {
8701: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
8702: } else {
8703: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
8704: }
8705: }
8706:
8707:
8708:
8709: public static int busRws (int a) throws M68kException {
8710: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8711: if (DataBreakPoint.DBP_ON) {
8712: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8713: } else {
8714: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8715: }
8716: } else if (mpuIgnoreAddressError) {
8717: int a1 = a + 1;
8718: if (DataBreakPoint.DBP_ON) {
8719: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8720: } else {
8721: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8722: }
8723: } else {
8724: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8725: M68kException.m6eAddress = a;
8726: M68kException.m6eDirection = MPU_WR_READ;
8727: M68kException.m6eSize = MPU_SS_WORD;
8728: throw M68kException.m6eSignal;
8729: }
8730: }
8731:
8732:
8733:
8734:
8735: public static int busRwse (int a) throws M68kException {
8736: if (DataBreakPoint.DBP_ON) {
8737: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8738: } else {
8739: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8740: }
8741: }
8742:
8743:
8744:
8745: public static int busRwz (int a) throws M68kException {
8746: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8747: if (DataBreakPoint.DBP_ON) {
8748: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8749: } else {
8750: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8751: }
8752: } else if (mpuIgnoreAddressError) {
8753: int a1 = a + 1;
8754: if (DataBreakPoint.DBP_ON) {
8755: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8756: } else {
8757: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8758: }
8759: } else {
8760: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8761: M68kException.m6eAddress = a;
8762: M68kException.m6eDirection = MPU_WR_READ;
8763: M68kException.m6eSize = MPU_SS_WORD;
8764: throw M68kException.m6eSignal;
8765: }
8766: }
8767:
8768:
8769:
8770:
8771: public static int busRwze (int a) throws M68kException {
8772: if (DataBreakPoint.DBP_ON) {
8773: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8774: } else {
8775: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8776: }
8777: }
8778:
8779:
8780:
8781: public static int busRls (int a) throws M68kException {
8782: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8783: if (DataBreakPoint.DBP_ON) {
8784: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8785: } else {
8786: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8787: }
8788: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8789: int a2 = a + 2;
8790: if (BUS_SPLIT_UNALIGNED_LONG) {
8791: if (DataBreakPoint.DBP_ON) {
8792: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8793: } else {
8794: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8795: }
8796: } else {
8797: MemoryMappedDevice mmd;
8798: MemoryMappedDevice mmd2;
8799: if (DataBreakPoint.DBP_ON) {
8800: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8801: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8802: } else {
8803: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8804: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8805: }
8806: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
8807: }
8808: } else if (mpuIgnoreAddressError) {
8809: int a1 = a + 1;
8810: int a3 = a + 3;
8811: if (DataBreakPoint.DBP_ON) {
8812: 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);
8813: } else {
8814: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 24 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRwz (a1) << 8 | busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdRbz (a3);
8815: }
8816: } else {
8817: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8818: M68kException.m6eAddress = a;
8819: M68kException.m6eDirection = MPU_WR_READ;
8820: M68kException.m6eSize = MPU_SS_LONG;
8821: throw M68kException.m6eSignal;
8822: }
8823: }
8824:
8825:
8826:
8827:
8828: public static int busRlse (int a) throws M68kException {
8829: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8830: if (DataBreakPoint.DBP_ON) {
8831: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8832: } else {
8833: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8834: }
8835: } else {
8836: int a2 = a + 2;
8837: if (BUS_SPLIT_UNALIGNED_LONG) {
8838: if (DataBreakPoint.DBP_ON) {
8839: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8840: } else {
8841: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8842: }
8843: } else {
8844: MemoryMappedDevice mmd;
8845: MemoryMappedDevice mmd2;
8846: if (DataBreakPoint.DBP_ON) {
8847: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8848: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8849: } else {
8850: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8851: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8852: }
8853: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
8854: }
8855: }
8856: }
8857:
8858:
8859:
8860:
8861: public static int busRlsf (int a) throws M68kException {
8862: if (DataBreakPoint.DBP_ON) {
8863: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8864: } else {
8865: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8866: }
8867: }
8868:
8869:
8870:
8871: public static long busRqs (int a) throws M68kException {
8872: return (long) busRls (a) << 32 | busRls (a + 4) & 0xffffffffL;
8873: }
8874:
8875:
8876:
8877: public static void busWb (int a, int d) throws M68kException {
8878: if (DataBreakPoint.DBP_ON) {
8879: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
8880: } else {
8881: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
8882: }
8883: }
8884:
8885:
8886:
8887: public static void busWw (int a, int d) throws M68kException {
8888: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8889: if (DataBreakPoint.DBP_ON) {
8890: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8891: } else {
8892: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8893: }
8894: } else if (mpuIgnoreAddressError) {
8895: int a1 = a + 1;
8896: if (DataBreakPoint.DBP_ON) {
8897: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
8898: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
8899: } else {
8900: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
8901: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
8902: }
8903: } else {
8904: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8905: M68kException.m6eAddress = a;
8906: M68kException.m6eDirection = MPU_WR_WRITE;
8907: M68kException.m6eSize = MPU_SS_WORD;
8908: throw M68kException.m6eSignal;
8909: }
8910: }
8911:
8912:
8913:
8914:
8915: public static void busWwe (int a, int d) throws M68kException {
8916: if (DataBreakPoint.DBP_ON) {
8917: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8918: } else {
8919: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8920: }
8921: }
8922:
8923:
8924:
8925: public static void busWl (int a, int d) throws M68kException {
8926: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8927: if (DataBreakPoint.DBP_ON) {
8928: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8929: } else {
8930: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8931: }
8932: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8933: int a2 = a + 2;
8934: if (BUS_SPLIT_UNALIGNED_LONG) {
8935: if (DataBreakPoint.DBP_ON) {
8936: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8937: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8938: } else {
8939: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8940: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8941: }
8942: } else {
8943: MemoryMappedDevice mmd;
8944: MemoryMappedDevice mmd2;
8945: if (DataBreakPoint.DBP_ON) {
8946: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8947: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8948: } else {
8949: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8950: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8951: }
8952: if (mmd == mmd2) {
8953: mmd.mmdWl (a, d);
8954: } else {
8955: mmd.mmdWw (a, d >> 16);
8956: mmd2.mmdWw (a2, d);
8957: }
8958: }
8959: } else if (mpuIgnoreAddressError) {
8960: int a1 = a + 1;
8961: int a3 = a + 3;
8962: if (DataBreakPoint.DBP_ON) {
8963: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
8964: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
8965: DataBreakPoint.dbpMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
8966: } else {
8967: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
8968: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
8969: busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
8970: }
8971: } else {
8972: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8973: M68kException.m6eAddress = a;
8974: M68kException.m6eDirection = MPU_WR_WRITE;
8975: M68kException.m6eSize = MPU_SS_LONG;
8976: throw M68kException.m6eSignal;
8977: }
8978: }
8979:
8980:
8981:
8982:
8983: public static void busWlf (int a, int d) throws M68kException {
8984: if (DataBreakPoint.DBP_ON) {
8985: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8986: } else {
8987: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8988: }
8989: }
8990:
8991:
8992:
8993:
8994: public static void busWle (int a, int d) throws M68kException {
8995: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8996: if (DataBreakPoint.DBP_ON) {
8997: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8998: } else {
8999: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9000: }
9001: } else {
9002: int a2 = a + 2;
9003: if (BUS_SPLIT_UNALIGNED_LONG) {
9004: if (DataBreakPoint.DBP_ON) {
9005: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9006: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9007: } else {
9008: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9009: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9010: }
9011: } else {
9012: MemoryMappedDevice mmd;
9013: MemoryMappedDevice mmd2;
9014: if (DataBreakPoint.DBP_ON) {
9015: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9016: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9017: } else {
9018: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9019: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9020: }
9021: if (mmd == mmd2) {
9022: mmd.mmdWl (a, d);
9023: } else {
9024: mmd.mmdWw (a, d >> 16);
9025: mmd2.mmdWw (a2, d);
9026: }
9027: }
9028: }
9029: }
9030:
9031:
9032:
9033: public static void busWq (int a, long d) throws M68kException {
9034: busWl (a, (int) (d >>> 32));
9035: busWl (a + 4, (int) d);
9036: }
9037:
9038:
9039:
9040:
9041:
9042: public static void busRbb (int a, byte[] bb, int o, int l) throws M68kException {
9043: if (false) {
9044: for (int i = 0; i < l; i++) {
9045: int ai = a + i;
9046: if (DataBreakPoint.DBP_ON) {
9047: bb[o + i] = DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9048: } else {
9049: bb[o + i] = busMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9050: }
9051: }
9052: } else {
9053: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9054: while (l > 0) {
9055: MemoryMappedDevice mmd;
9056: if (DataBreakPoint.DBP_ON) {
9057: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9058: } else {
9059: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9060: }
9061: int s = l <= r ? l : r;
9062: l -= s;
9063: if (true) {
9064: for (s -= 16; s >= 0; s -= 16) {
9065: bb[o ] = mmd.mmdRbs (a );
9066: bb[o + 1] = mmd.mmdRbs (a + 1);
9067: bb[o + 2] = mmd.mmdRbs (a + 2);
9068: bb[o + 3] = mmd.mmdRbs (a + 3);
9069: bb[o + 4] = mmd.mmdRbs (a + 4);
9070: bb[o + 5] = mmd.mmdRbs (a + 5);
9071: bb[o + 6] = mmd.mmdRbs (a + 6);
9072: bb[o + 7] = mmd.mmdRbs (a + 7);
9073: bb[o + 8] = mmd.mmdRbs (a + 8);
9074: bb[o + 9] = mmd.mmdRbs (a + 9);
9075: bb[o + 10] = mmd.mmdRbs (a + 10);
9076: bb[o + 11] = mmd.mmdRbs (a + 11);
9077: bb[o + 12] = mmd.mmdRbs (a + 12);
9078: bb[o + 13] = mmd.mmdRbs (a + 13);
9079: bb[o + 14] = mmd.mmdRbs (a + 14);
9080: bb[o + 15] = mmd.mmdRbs (a + 15);
9081: a += 16;
9082: o += 16;
9083: }
9084: s += 16;
9085: }
9086: for (int i = 0; i < s; i++) {
9087: bb[o + i] = mmd.mmdRbs (a + i);
9088: }
9089: a += s;
9090: o += s;
9091: r = BUS_PAGE_SIZE;
9092: }
9093: }
9094: }
9095:
9096:
9097:
9098: public static void busWbb (int a, byte[] bb, int o, int l) throws M68kException {
9099: if (false) {
9100: for (int i = 0; i < l; i++) {
9101: int ai = a + i;
9102: if (DataBreakPoint.DBP_ON) {
9103: DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9104: } else {
9105: busMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9106: }
9107: }
9108: } else {
9109: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9110: while (l > 0) {
9111: MemoryMappedDevice mmd;
9112: if (DataBreakPoint.DBP_ON) {
9113: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9114: } else {
9115: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9116: }
9117: int s = l <= r ? l : r;
9118: l -= s;
9119: if (true) {
9120: for (s -= 16; s >= 0; s -= 16) {
9121: mmd.mmdWb (a , bb[o ]);
9122: mmd.mmdWb (a + 1, bb[o + 1]);
9123: mmd.mmdWb (a + 2, bb[o + 2]);
9124: mmd.mmdWb (a + 3, bb[o + 3]);
9125: mmd.mmdWb (a + 4, bb[o + 4]);
9126: mmd.mmdWb (a + 5, bb[o + 5]);
9127: mmd.mmdWb (a + 6, bb[o + 6]);
9128: mmd.mmdWb (a + 7, bb[o + 7]);
9129: mmd.mmdWb (a + 8, bb[o + 8]);
9130: mmd.mmdWb (a + 9, bb[o + 9]);
9131: mmd.mmdWb (a + 10, bb[o + 10]);
9132: mmd.mmdWb (a + 11, bb[o + 11]);
9133: mmd.mmdWb (a + 12, bb[o + 12]);
9134: mmd.mmdWb (a + 13, bb[o + 13]);
9135: mmd.mmdWb (a + 14, bb[o + 14]);
9136: mmd.mmdWb (a + 15, bb[o + 15]);
9137: a += 16;
9138: o += 16;
9139: }
9140: s += 16;
9141: }
9142: for (int i = 0; i < s; i++) {
9143: mmd.mmdWb (a + i, bb[o + i]);
9144: }
9145: a += s;
9146: o += s;
9147: r = BUS_PAGE_SIZE;
9148: }
9149: }
9150: }
9151:
9152:
9153:
9154: public static void busVb (int a, int d) {
9155: try {
9156: if (DataBreakPoint.DBP_ON) {
9157: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9158: } else {
9159: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9160: }
9161: } catch (M68kException e) {
9162: }
9163: }
9164:
9165:
9166:
9167: public static void busVw (int a, int d) {
9168: try {
9169: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9170: if (DataBreakPoint.DBP_ON) {
9171: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9172: } else {
9173: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9174: }
9175: }
9176: } catch (M68kException e) {
9177: }
9178: }
9179:
9180:
9181:
9182: public static void busVl (int a, int d) {
9183: try {
9184: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9185: if (DataBreakPoint.DBP_ON) {
9186: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9187: } else {
9188: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9189: }
9190: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9191: int a2 = a + 2;
9192: MemoryMappedDevice mmd;
9193: MemoryMappedDevice mmd2;
9194: if (DataBreakPoint.DBP_ON) {
9195: mmd = (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS];
9196: mmd2 = (regSRS != 0 ? busSuperMap : busUserMap)[a2 >>> BUS_PAGE_BITS];
9197: } else {
9198: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9199: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9200: }
9201: if (mmd == mmd2) {
9202: mmd.mmdWl (a, d);
9203: } else {
9204: mmd.mmdWw (a, d >> 16);
9205: mmd2.mmdWw (a2, d);
9206: }
9207: }
9208: } catch (M68kException e) {
9209: }
9210: }
9211:
9212:
9213:
9214:
9215:
9216: public static final int SVS_AREASET = 0x00e86001;
9217:
9218:
9219:
9220:
9221:
9222:
9223:
9224:
9225:
9226: public static void svsInit () {
9227: }
9228:
9229:
9230:
9231:
9232:
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: public static boolean sysNMIFlag;
9264:
9265:
9266:
9267: public static void sysInit () {
9268: sysNMIFlag = false;
9269: }
9270:
9271:
9272:
9273:
9274:
9275:
9276: public static int sysAcknowledge () {
9277: return M68kException.M6E_LEVEL_7_INTERRUPT_AUTOVECTOR;
9278: }
9279:
9280:
9281:
9282:
9283: public static void sysDone () {
9284: if (sysNMIFlag) {
9285: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9286: }
9287: }
9288:
9289:
9290:
9291: public static void sysInterrupt () {
9292: sysNMIFlag = true;
9293: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9294: }
9295:
9296:
9297:
9298: public static void sysResetNMI () {
9299: sysNMIFlag = false;
9300: }
9301:
9302:
9303:
9304:
9305:
9306:
9307: public static final int EB2_SPC_REQUEST = 0x4000;
9308: public static final int EB2_SPC_VECTOR = 0xf6;
9309:
9310:
9311:
9312: public static int eb2Request;
9313:
9314:
9315:
9316: public static void eb2Reset () {
9317: eb2Request = 0;
9318: }
9319:
9320:
9321:
9322:
9323:
9324: public static void eb2Interrupt (int mask) {
9325: eb2Request |= mask;
9326: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9327: }
9328:
9329:
9330:
9331:
9332:
9333:
9334:
9335: public static int eb2Acknowledge () {
9336: if ((eb2Request & EB2_SPC_REQUEST) != 0) {
9337: eb2Request &= ~EB2_SPC_REQUEST;
9338: return EB2_SPC_VECTOR;
9339: }
9340: return 0;
9341: }
9342:
9343:
9344:
9345:
9346:
9347: public static void eb2Done () {
9348: if (eb2Request != 0) {
9349: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9350: }
9351: }
9352:
9353:
9354:
9355:
9356:
9357:
9358:
9359:
9360:
9361:
9362:
9363:
9364:
9365:
9366:
9367:
9368:
9369:
9370:
9371:
9372:
9373:
9374:
9375:
9376:
9377:
9378:
9379:
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: public static final int BNK_SIZE = 1024 * 1024 * 32;
9417: public static byte[] bnkMemory;
9418: public static int bnkPageStart;
9419: public static boolean bnkOn;
9420:
9421: public static void bnkInit () {
9422: bnkMemory = new byte[BNK_SIZE];
9423: byte[] array = Settings.sgsGetData ("bankdata");
9424: if (array.length != 0) {
9425: System.arraycopy (array, 0, bnkMemory, 0, Math.min (array.length, BNK_SIZE));
9426: }
9427: bnkPageStart = 0;
9428:
9429: bnkOn = false;
9430: }
9431:
9432: public static void bnkTini () {
9433: Settings.sgsPutData ("bankdata", bnkMemory, 0, BNK_SIZE);
9434: }
9435:
9436:
9437:
9438:
9439:
9440:
9441:
9442: public static ExpressionEvaluator fpuMotherboardCoprocessor;
9443: public static ExpressionEvaluator fpuOnChipFPU;
9444: public static ExpressionEvaluator fpuBox;
9445:
9446:
9447: public static EFPBox fpuCoproboard1;
9448: public static EFPBox fpuCoproboard2;
9449:
9450:
9451: public static EFPBox.EFP[] fpuFPn;
9452:
9453:
9454:
9455: public static final int FPU_FPCR_BSUN = 0b00000000_00000000_10000000_00000000;
9456: public static final int FPU_FPCR_SNAN = 0b00000000_00000000_01000000_00000000;
9457: public static final int FPU_FPCR_OPERR = 0b00000000_00000000_00100000_00000000;
9458: public static final int FPU_FPCR_OVFL = 0b00000000_00000000_00010000_00000000;
9459: public static final int FPU_FPCR_UNFL = 0b00000000_00000000_00001000_00000000;
9460: public static final int FPU_FPCR_DZ = 0b00000000_00000000_00000100_00000000;
9461: public static final int FPU_FPCR_INEX2 = 0b00000000_00000000_00000010_00000000;
9462: public static final int FPU_FPCR_INEX1 = 0b00000000_00000000_00000001_00000000;
9463:
9464:
9465: public static final int FPU_FPCR_PE = 0b00000000_00000000_00000000_00000000;
9466: public static final int FPU_FPCR_PS = 0b00000000_00000000_00000000_01000000;
9467: public static final int FPU_FPCR_PD = 0b00000000_00000000_00000000_10000000;
9468:
9469: public static final int FPU_FPCR_RN = 0b00000000_00000000_00000000_00000000;
9470: public static final int FPU_FPCR_RZ = 0b00000000_00000000_00000000_00010000;
9471: public static final int FPU_FPCR_RM = 0b00000000_00000000_00000000_00100000;
9472: public static final int FPU_FPCR_RP = 0b00000000_00000000_00000000_00110000;
9473:
9474:
9475:
9476: public static final int FPU_FPSR_N = 0b00001000_00000000_00000000_00000000;
9477: public static final int FPU_FPSR_Z = 0b00000100_00000000_00000000_00000000;
9478: public static final int FPU_FPSR_I = 0b00000010_00000000_00000000_00000000;
9479: public static final int FPU_FPSR_NAN = 0b00000001_00000000_00000000_00000000;
9480:
9481: public static final int FPU_FPSR_S = 0b00000000_10000000_00000000_00000000;
9482: public static final int FPU_FPSR_QUOTIENT = 0b00000000_01111111_00000000_00000000;
9483:
9484: public static final int FPU_FPSR_EXC_BSUN = 0b00000000_00000000_10000000_00000000;
9485: public static final int FPU_FPSR_EXC_SNAN = 0b00000000_00000000_01000000_00000000;
9486: public static final int FPU_FPSR_EXC_OPERR = 0b00000000_00000000_00100000_00000000;
9487: public static final int FPU_FPSR_EXC_OVFL = 0b00000000_00000000_00010000_00000000;
9488: public static final int FPU_FPSR_EXC_UNFL = 0b00000000_00000000_00001000_00000000;
9489: public static final int FPU_FPSR_EXC_DZ = 0b00000000_00000000_00000100_00000000;
9490: public static final int FPU_FPSR_EXC_INEX2 = 0b00000000_00000000_00000010_00000000;
9491: public static final int FPU_FPSR_EXC_INEX1 = 0b00000000_00000000_00000001_00000000;
9492:
9493: public static final int FPU_FPSR_AEXC_IOP = 0b00000000_00000000_00000000_10000000;
9494: public static final int FPU_FPSR_AEXC_OVFL = 0b00000000_00000000_00000000_01000000;
9495: public static final int FPU_FPSR_AEXC_UNFL = 0b00000000_00000000_00000000_00100000;
9496: public static final int FPU_FPSR_AEXC_DZ = 0b00000000_00000000_00000000_00010000;
9497: public static final int FPU_FPSR_AEXC_INEX = 0b00000000_00000000_00000000_00001000;
9498:
9499:
9500:
9501:
9502:
9503:
9504:
9505: public static final int[] FPU_FPSR_EXC_TO_AEXC = new int[256];
9506:
9507:
9508:
9509:
9510:
9511:
9512:
9513:
9514:
9515:
9516:
9517:
9518:
9519:
9520:
9521:
9522:
9523:
9524:
9525:
9526:
9527:
9528:
9529:
9530: public static final boolean[] FPU_CCMAP_882 = {
9531:
9532:
9533: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9534: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9535: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9536: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9537: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9538: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9539: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9540: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9541: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9542: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9543: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9544: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9545: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9546: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9547: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9548: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9549:
9550:
9551: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9552: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9553: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9554: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9555: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9556: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9557: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9558: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9559: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9560: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9561: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9562: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9563: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9564: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9565: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9566: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9567:
9568: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9569: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9570: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9571: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9572: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9573: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9574: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9575: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9576: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9577: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9578: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9579: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9580: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9581: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9582: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9583: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9584:
9585: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9586: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9587: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9588: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9589: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9590: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9591: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9592: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9593: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9594: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9595: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9596: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9597: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9598: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9599: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9600: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9601: };
9602:
9603:
9604:
9605:
9606:
9607:
9608:
9609: public static final boolean[] FPU_CCMAP_060 = {
9610:
9611:
9612: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9613: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9614: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9615: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9616: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9617: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9618: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9619: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9620: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9621: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9622: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9623: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9624: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9625: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9626: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9627: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9628:
9629:
9630: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9631: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9632: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9633: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9634: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9635: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9636: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9637: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9638: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9639: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9640: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9641: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9642: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9643: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9644: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9645: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9646:
9647: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9648: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9649: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9650: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9651: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9652: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9653: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9654: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9655: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9656: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9657: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9658: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9659: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9660: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9661: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9662: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9663:
9664: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9665: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9666: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9667: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9668: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9669: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9670: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9671: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9672: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9673: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9674: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9675: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9676: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9677: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9678: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9679: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9680: };
9681:
9682:
9683:
9684:
9685: public static void fpuInit () {
9686: for (int i = 0; i < 256; i++) {
9687: 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) |
9688: ((i << 8 & FPU_FPSR_EXC_OVFL) != 0 ? FPU_FPSR_AEXC_OVFL : 0) |
9689: ((i << 8 & (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2)) == (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2) ? FPU_FPSR_AEXC_UNFL : 0) |
9690: ((i << 8 & FPU_FPSR_EXC_DZ) != 0 ? FPU_FPSR_AEXC_DZ : 0) |
9691: ((i << 8 & (FPU_FPSR_EXC_OVFL | FPU_FPSR_EXC_INEX2 | FPU_FPSR_EXC_INEX1)) != 0 ? FPU_FPSR_AEXC_INEX : 0));
9692: }
9693:
9694: fpuMotherboardCoprocessor = new ExpressionEvaluator ();
9695:
9696: fpuOnChipFPU = new ExpressionEvaluator ();
9697:
9698: fpuBox = currentMPU < Model.MPU_MC68LC040 ? fpuMotherboardCoprocessor : fpuOnChipFPU;
9699:
9700: fpuFPn = fpuBox.epbFPn;
9701:
9702: fpuCoproboard1 = new EFPBox ();
9703: fpuCoproboard2 = new EFPBox ();
9704: }
9705:
9706:
9707:
9708:
9709:
9710:
9711: public static final boolean DBG_ORI_BYTE_ZERO_D0 = true;
9712:
9713: public static boolean dbgHexSelected;
9714: public static int dbgHexValue;
9715: public static int dbgSupervisorMode;
9716: public static JPopupMenu dbgPopupMenu;
9717: public static JMenu dbgPopupIBPMenu;
9718: public static SpinnerNumberModel dbgPopupIBPCurrentModel;
9719: public static int dbgPopupIBPCurrentValue;
9720: public static SpinnerNumberModel dbgPopupIBPThresholdModel;
9721: public static int dbgPopupIBPThresholdValue;
9722: public static JMenuItem dbgPopupIBPClearMenuItem;
9723: public static JMenu dbgPopupHexMenu;
9724: public static JMenuItem dbgPopupDisMenuItem;
9725: public static JMenuItem dbgPopupMemMenuItem;
9726: public static JMenuItem dbgPopupCopyMenuItem;
9727: public static JMenuItem dbgPopupSelectAllMenuItem;
9728: public static JTextArea dbgPopupTextArea;
9729: public static int dbgEventMask;
9730: public static boolean dbgStopOnError;
9731: public static boolean dbgOriByteZeroD0;
9732: public static boolean dbgStopAtStart;
9733:
9734:
9735:
9736: public static final char[] DBG_SPACES = (
9737:
9738:
9739: " ").toCharArray ();
9740:
9741: public static final int DBG_DRP_VISIBLE_MASK = 1;
9742: public static final int DBG_DDP_VISIBLE_MASK = 2;
9743: public static final int DBG_DMP_VISIBLE_MASK = 4;
9744: public static final int DBG_BLG_VISIBLE_MASK = 8;
9745: public static final int DBG_PFV_VISIBLE_MASK = 16;
9746: public static final int DBG_RBP_VISIBLE_MASK = 32;
9747: public static final int DBG_DBP_VISIBLE_MASK = 64;
9748: public static final int DBG_SMT_VISIBLE_MASK = 128;
9749: public static final int DBG_ATW_VISIBLE_MASK = 256;
9750: public static final int DBG_PAA_VISIBLE_MASK = 512;
9751: public static final int DBG_RTL_VISIBLE_MASK = 1024;
9752: public static final int DBG_SPV_VISIBLE_MASK = 2048;
9753: public static final int DBG_PLV_VISIBLE_MASK = 4096;
9754: public static final int DBG_ACM_VISIBLE_MASK = 8192;
9755: public static int dbgVisibleMask;
9756:
9757:
9758:
9759: public static void dbgInit () {
9760: dbgVisibleMask = 0;
9761: dbgHexSelected = false;
9762: dbgHexValue = 0;
9763: dbgSupervisorMode = 1;
9764: dbgPopupMenu = null;
9765: dbgPopupDisMenuItem = null;
9766: dbgPopupMemMenuItem = null;
9767: dbgPopupCopyMenuItem = null;
9768: dbgPopupSelectAllMenuItem = null;
9769: dbgPopupIBPMenu = null;
9770: dbgPopupIBPCurrentModel = null;
9771: dbgPopupIBPCurrentValue = 0;
9772: dbgPopupIBPThresholdModel = null;
9773: dbgPopupIBPThresholdValue = 0;
9774: dbgPopupHexMenu = null;
9775: dbgPopupTextArea = null;
9776: dbgEventMask = 0;
9777: dbgStopOnError = false;
9778: if (DBG_ORI_BYTE_ZERO_D0) {
9779: dbgOriByteZeroD0 = false;
9780: }
9781: dbgStopAtStart = false;
9782: }
9783:
9784:
9785:
9786: public static void dbgMakePopup () {
9787:
9788:
9789: ActionListener popupActionListener = new ActionListener () {
9790: @Override public void actionPerformed (ActionEvent ae) {
9791: switch (ae.getActionCommand ()) {
9792: case "Disassemble":
9793: DisassembleList.ddpBacktraceRecord = -1L;
9794: DisassembleList.ddpOpen (dbgHexValue, dbgSupervisorMode, false);
9795: break;
9796: case "Memory Dump":
9797: MemoryDumpList.dmpOpen (dbgHexValue, dbgSupervisorMode != 0 ? 5 : 1, false);
9798: break;
9799: case "Run to Here":
9800: if (InstructionBreakPoint.IBP_ON) {
9801: if (mpuTask == null) {
9802: InstructionBreakPoint.ibpInstant (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
9803: mpuStart ();
9804: }
9805: }
9806: break;
9807: case "Set Breakpoint":
9808: if (InstructionBreakPoint.IBP_ON) {
9809: InstructionBreakPoint.ibpPut (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode, dbgPopupIBPCurrentValue, dbgPopupIBPThresholdValue, null);
9810: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
9811: }
9812: break;
9813: case "Clear Breakpoint":
9814: if (InstructionBreakPoint.IBP_ON) {
9815: InstructionBreakPoint.ibpRemove (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
9816: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
9817: }
9818: break;
9819: case "Copy":
9820: dbgCopy ();
9821: break;
9822: case "Select All":
9823: dbgSelectAll ();
9824: break;
9825: }
9826: }
9827: };
9828: dbgPopupMenu = ComponentFactory.createPopupMenu (
9829: dbgPopupIBPMenu =
9830: InstructionBreakPoint.IBP_ON ?
9831: ComponentFactory.createMenu (
9832: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
9833: Multilingual.mlnText (ComponentFactory.createMenuItem ("Run to Here", 'R', popupActionListener), "ja", "ここまで実行"),
9834: ComponentFactory.createHorizontalSeparator (),
9835: Multilingual.mlnText (ComponentFactory.createMenuItem ("Set Breakpoint", 'S', popupActionListener), "ja", "ブレークポイントを設定"),
9836: ComponentFactory.createHorizontalBox (
9837: Box.createHorizontalStrut (7),
9838: Box.createHorizontalGlue (),
9839: ComponentFactory.setPreferredSize (
9840: Multilingual.mlnText (ComponentFactory.createLabel ("current"), "ja", "現在値"),
9841: 60, 16),
9842: ComponentFactory.createNumberSpinner (dbgPopupIBPCurrentModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
9843: @Override public void stateChanged (ChangeEvent ce) {
9844: dbgPopupIBPCurrentValue = dbgPopupIBPCurrentModel.getNumber ().intValue ();
9845: }
9846: }),
9847: Box.createHorizontalGlue ()
9848: ),
9849: ComponentFactory.createHorizontalBox (
9850: Box.createHorizontalStrut (7),
9851: Box.createHorizontalGlue (),
9852: ComponentFactory.setPreferredSize (
9853: Multilingual.mlnText (ComponentFactory.createLabel ("threshold"), "ja", "閾値"),
9854: 60, 16),
9855: ComponentFactory.createNumberSpinner (dbgPopupIBPThresholdModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
9856: @Override public void stateChanged (ChangeEvent ce) {
9857: dbgPopupIBPThresholdValue = dbgPopupIBPThresholdModel.getNumber ().intValue ();
9858: }
9859: }),
9860: Box.createHorizontalGlue ()
9861: ),
9862: dbgPopupIBPClearMenuItem =
9863: Multilingual.mlnText (ComponentFactory.createMenuItem ("Clear Breakpoint", 'C', popupActionListener), "ja", "ブレークポイントを消去")
9864: ) :
9865: null,
9866: dbgPopupHexMenu =
9867: ComponentFactory.createMenu (
9868: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
9869: dbgPopupDisMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble", 'D', popupActionListener), "ja", "逆アセンブル"),
9870: dbgPopupMemMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory Dump", 'M', popupActionListener), "ja", "メモリダンプ")
9871: ),
9872: dbgPopupCopyMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Copy", 'C', popupActionListener), "ja", "コピー"),
9873: dbgPopupSelectAllMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Select All", 'A', popupActionListener), "ja", "すべて選択")
9874: );
9875:
9876: }
9877:
9878:
9879:
9880: public static void dbgShowPopup (MouseEvent me, JTextArea textArea, boolean dis) {
9881: dbgEventMask++;
9882: int x = me.getX ();
9883: int y = me.getY ();
9884:
9885: int p = textArea.viewToModel2D (me.getPoint ());
9886: DisassembleList.ddpPopupAddress = -1;
9887: if (dis) {
9888: int i = Arrays.binarySearch (DisassembleList.ddpSplitArray, 1, DisassembleList.ddpItemCount, p + 1);
9889: i = (i >> 31 ^ i) - 1;
9890: DisassembleList.ddpPopupAddress = DisassembleList.ddpAddressArray[i];
9891: }
9892: int start = textArea.getSelectionStart ();
9893: int end = textArea.getSelectionEnd ();
9894: String text = textArea.getText ();
9895: int length = text.length ();
9896: if ((start == end ||
9897: p < start || end <= p) &&
9898: 0 <= p && p < length && isWord (text.charAt (p))) {
9899:
9900: for (start = p; 0 < start && isWord (text.charAt (start - 1)); start--) {
9901: }
9902: for (end = p + 1; end < length && isWord (text.charAt (end)); end++) {
9903: }
9904: textArea.select (start, end);
9905: }
9906: dbgHexSelected = false;
9907: if (start < end) {
9908: textArea.requestFocusInWindow ();
9909:
9910:
9911:
9912:
9913:
9914: dbgHexValue = 0;
9915: int n = 0;
9916: for (int i = start; i < end; i++) {
9917: int t;
9918: if ((t = Character.digit (text.charAt (i), 16)) >= 0) {
9919: dbgHexValue = dbgHexValue << 4 | t;
9920: if (n >= 8 ||
9921: i + 1 >= end || (t = Character.digit (text.charAt (i + 1), 16)) < 0) {
9922: n = 0;
9923: break;
9924: }
9925: dbgHexValue = dbgHexValue << 4 | t;
9926: n += 2;
9927: i++;
9928: } else if (isWord (text.charAt (i))) {
9929: n = 0;
9930: break;
9931: }
9932: }
9933: dbgHexSelected = n > 0;
9934: try {
9935:
9936: Rectangle r = textArea.modelToView2D (start).getBounds ();
9937:
9938: Rectangle s = textArea.modelToView2D (end - 1).getBounds ();
9939: if (r.y == s.y) {
9940:
9941: y = r.y + r.height;
9942: }
9943: } catch (BadLocationException ble) {
9944: }
9945: }
9946:
9947: if (InstructionBreakPoint.IBP_ON) {
9948: if (dis && mpuTask == null && DisassembleList.ddpPopupAddress != -1) {
9949: ComponentFactory.setText (dbgPopupIBPMenu, fmtHex8 (DisassembleList.ddpPopupAddress));
9950: TreeMap<Integer,InstructionBreakPoint.InstructionBreakRecord> pointTable = InstructionBreakPoint.ibpPointTable;
9951: InstructionBreakPoint.InstructionBreakRecord r = pointTable.get (DisassembleList.ddpPopupAddress);
9952: if (r != null) {
9953: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = r.ibrValue));
9954: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = r.ibrThreshold));
9955: dbgPopupIBPClearMenuItem.setEnabled (true);
9956: } else {
9957: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = 0));
9958: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = 0));
9959: dbgPopupIBPClearMenuItem.setEnabled (false);
9960: }
9961: ComponentFactory.setVisible (dbgPopupIBPMenu, true);
9962: } else {
9963: ComponentFactory.setVisible (dbgPopupIBPMenu, false);
9964: }
9965: }
9966:
9967: if (dbgHexSelected) {
9968: ComponentFactory.setText (dbgPopupHexMenu, fmtHex8 (dbgHexValue));
9969: ComponentFactory.setVisible (dbgPopupHexMenu, true);
9970: } else {
9971: ComponentFactory.setVisible (dbgPopupHexMenu, false);
9972: }
9973:
9974: ComponentFactory.setEnabled (dbgPopupCopyMenuItem, clpClipboard != null && start < end);
9975:
9976: ComponentFactory.setEnabled (dbgPopupSelectAllMenuItem, clpClipboard != null);
9977:
9978: dbgPopupTextArea = textArea;
9979: dbgPopupMenu.show (textArea, x, y);
9980: dbgEventMask--;
9981: }
9982:
9983: public static boolean isWord (char c) {
9984: return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '_';
9985: }
9986:
9987:
9988:
9989: public static void dbgCopy () {
9990: clpCopy (dbgPopupTextArea.getSelectedText ());
9991: }
9992:
9993:
9994:
9995: public static void dbgSelectAll () {
9996: if (clpClipboard != null) {
9997:
9998: dbgEventMask++;
9999: dbgPopupTextArea.selectAll ();
10000: dbgPopupTextArea.requestFocusInWindow ();
10001: dbgEventMask--;
10002: }
10003: }
10004:
10005:
10006:
10007:
10008: public static void dbgUpdate () {
10009: if ((dbgVisibleMask & DBG_DRP_VISIBLE_MASK) != 0) {
10010: RegisterList.drpUpdate ();
10011: }
10012: if (ProgramFlowVisualizer.PFV_ON) {
10013: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
10014: if (ProgramFlowVisualizer.pfvTimer == 0) {
10015: ProgramFlowVisualizer.pfvUpdate ();
10016: } else {
10017: ProgramFlowVisualizer.pfvTimer--;
10018: }
10019: }
10020: }
10021: if (RasterBreakPoint.RBP_ON) {
10022: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
10023: if (RasterBreakPoint.rbpTimer == 0) {
10024: RasterBreakPoint.rbpUpdateFrame ();
10025: } else {
10026: RasterBreakPoint.rbpTimer--;
10027: }
10028: }
10029: }
10030: if (ScreenModeTest.SMT_ON) {
10031: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
10032: if (ScreenModeTest.smtTimer == 0) {
10033: ScreenModeTest.smtUpdateFrame ();
10034: } else {
10035: ScreenModeTest.smtTimer--;
10036: }
10037: }
10038: }
10039: if (RootPointerList.RTL_ON) {
10040: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
10041: if (RootPointerList.rtlTimer == 0) {
10042: RootPointerList.rtlTimer = RootPointerList.RTL_INTERVAL - 1;
10043: RootPointerList.rtlUpdateFrame ();
10044: } else {
10045: RootPointerList.rtlTimer--;
10046: }
10047: }
10048: }
10049: if (SpritePatternViewer.SPV_ON) {
10050: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
10051: if (SpritePatternViewer.spvTimer == 0) {
10052: SpritePatternViewer.spvTimer = SpritePatternViewer.SPV_INTERVAL - 1;
10053: SpritePatternViewer.spvUpdateFrame ();
10054: } else {
10055: SpritePatternViewer.spvTimer--;
10056: }
10057: }
10058: }
10059: if (PaletteViewer.PLV_ON) {
10060: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
10061: if (PaletteViewer.plvTimer == 0) {
10062: PaletteViewer.plvTimer = PaletteViewer.PLV_INTERVAL - 1;
10063: PaletteViewer.plvUpdateFrame ();
10064: } else {
10065: PaletteViewer.plvTimer--;
10066: }
10067: }
10068: }
10069: if (ATCMonitor.ACM_ON) {
10070: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
10071: if (ATCMonitor.acmTimer == 0) {
10072: ATCMonitor.acmTimer = ATCMonitor.ACM_INTERVAL - 1;
10073: ATCMonitor.acmUpdateFrame ();
10074: } else {
10075: ATCMonitor.acmTimer--;
10076: }
10077: }
10078: }
10079: }
10080:
10081:
10082:
10083:
10084:
10085:
10086:
10087:
10088:
10089:
10090:
10091:
10092:
10093:
10094:
10095:
10096:
10097:
10098:
10099:
10100:
10101:
10102: public static boolean dbgDoStopOnError () {
10103: if (MainMemory.mmrHumanVersion <= 0) {
10104: return true;
10105: }
10106: if ((regOC & 0xff00) == 0xff00 &&
10107: M68kException.m6eNumber == M68kException.M6E_PRIVILEGE_VIOLATION) {
10108: return false;
10109: }
10110: String message = (
10111: M68kException.m6eNumber < 0 ?
10112: fmtHex8 (new StringBuilder ("breaked").append (" at "), regPC0).toString () :
10113: M68kException.m6eNumber <= M68kException.M6E_ADDRESS_ERROR ?
10114: fmtHex8 (fmtHex8 (new StringBuilder ("ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10115: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10116: .append (" at "), regPC0).toString () :
10117: fmtHex8 (new StringBuilder (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10118: .append (" at "), regPC0).toString ()
10119: );
10120: System.out.println (message);
10121: if (!(M68kException.m6eNumber == M68kException.M6E_ACCESS_FAULT &&
10122: 0x0000e100 <= regPC0 && regPC0 < 0x0000e500)) {
10123: mpuStop (message);
10124: return true;
10125: }
10126: return false;
10127: }
10128:
10129:
10130:
10131: public static void dbgDoubleBusFault () {
10132: String message =
10133: fmtHex8 (fmtHex8 (new StringBuilder ("FATAL ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10134: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10135: .append (" at "), regPC0).toString ();
10136: System.out.println (message);
10137: mpuStop (message);
10138: }
10139:
10140:
10141:
10142:
10143:
10144:
10145: public static final HashMap<String,byte[]> rscResourceCache = new HashMap<String,byte[]> ();
10146:
10147:
10148:
10149:
10150:
10151:
10152: public static byte[] rscGetResource (String name, int... sizes) {
10153: byte[] array = rscResourceCache.get (name);
10154: if (array != null) {
10155: return array;
10156: }
10157: array = new byte[1024 * 64];
10158: int size = 0;
10159: try (BufferedInputStream bis = new BufferedInputStream (XEiJ.class.getResourceAsStream ("../data/" + name))) {
10160: for (;;) {
10161: if (size == array.length) {
10162: byte[] newArray = new byte[array.length * 2];
10163: System.arraycopy (array, 0, newArray, 0, size);
10164: array = newArray;
10165: }
10166: int step = bis.read (array, size, array.length - size);
10167: if (step == -1) {
10168: break;
10169: }
10170: size += step;
10171: }
10172: if (size < array.length) {
10173: byte[] newArray = new byte[size];
10174: System.arraycopy (array, 0, newArray, 0, size);
10175: array = newArray;
10176: }
10177: boolean fit = sizes.length == 0;
10178: if (!fit) {
10179: for (int i = 0; i < sizes.length; i++) {
10180: if (size == sizes[i]) {
10181: fit = true;
10182: break;
10183: }
10184: }
10185: }
10186: if (fit) {
10187: System.out.println (Multilingual.mlnJapanese ?
10188: name + " を読み込みました" :
10189: name + " was read");
10190: rscResourceCache.put (name, array);
10191: return array;
10192: }
10193: System.out.println (Multilingual.mlnJapanese ?
10194: name + " のサイズが違います" :
10195: name + " has wrong size");
10196: return null;
10197: } catch (IOException ioe) {
10198: }
10199:
10200: System.out.println (Multilingual.mlnJapanese ?
10201: name + " を読み込めません" :
10202: name + " cannot be read");
10203: return null;
10204: }
10205:
10206:
10207:
10208: public static String rscGetResourceText (String name) {
10209: return rscGetResourceText (name, "UTF-8");
10210: }
10211: public static String rscGetResourceText (String name, String charset) {
10212: byte[] array = rscGetResource (name);
10213: if (name != null) {
10214: try {
10215: return new String (array, charset);
10216: } catch (UnsupportedEncodingException uee) {
10217: }
10218: }
10219: return "";
10220: }
10221:
10222: public static final Pattern RSC_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10223: public static String rscLastFileName = null;
10224:
10225:
10226:
10227:
10228:
10229:
10230: public static byte[] rscGetFile (String names, int... sizes) {
10231: for (String name : names.split (",")) {
10232: name = name.trim ();
10233: if (name.length () == 0 || name.equalsIgnoreCase ("none")) {
10234: continue;
10235: }
10236: String[] zipSplittedName = RSC_ZIP_SEPARATOR.split (name, 2);
10237: InputStream is = null;
10238: if (zipSplittedName.length < 2) {
10239: File file = new File (name);
10240: if (file.isFile ()) {
10241: try {
10242: is = new FileInputStream (file);
10243: } catch (IOException ioe) {
10244: }
10245: } else {
10246: System.out.println (Multilingual.mlnJapanese ?
10247: name + " がありません" :
10248: name + " does not exist");
10249: continue;
10250: }
10251: } else {
10252: String zipName = zipSplittedName[0];
10253: String entryName = zipSplittedName[1];
10254: if (new File (zipName).isFile ()) {
10255: try {
10256: ZipFile zipFile = new ZipFile (zipName);
10257: ZipEntry zipEntry = zipFile.getEntry (entryName);
10258: if (zipEntry != null) {
10259: is = zipFile.getInputStream (zipEntry);
10260: } else {
10261: System.out.println (Multilingual.mlnJapanese ?
10262: zipName + " に " + zipEntry + " がありません" :
10263: zipName + " does not include " + zipEntry);
10264: }
10265: } catch (IOException ioe) {
10266: }
10267: } else {
10268: System.out.println (Multilingual.mlnJapanese ?
10269: zipName + " がありません" :
10270: zipName + " does not exist");
10271: continue;
10272: }
10273: }
10274: if (is != null) {
10275: try {
10276: is = new BufferedInputStream (is);
10277: if (name.toLowerCase ().endsWith (".gz")) {
10278: is = new GZIPInputStream (is);
10279: }
10280: byte[] array = new byte[1024 * 64];
10281: int size = 0;
10282: for (;;) {
10283: if (size == array.length) {
10284: byte[] newArray = new byte[array.length * 2];
10285: System.arraycopy (array, 0, newArray, 0, size);
10286: array = newArray;
10287: }
10288: int step = is.read (array, size, array.length - size);
10289: if (step == -1) {
10290: break;
10291: }
10292: size += step;
10293: }
10294: is.close ();
10295: is = null;
10296: if (size < array.length) {
10297: byte[] newArray = new byte[size];
10298: System.arraycopy (array, 0, newArray, 0, size);
10299: array = newArray;
10300: }
10301: boolean fit = sizes.length == 0;
10302: if (!fit) {
10303: for (int i = 0; i < sizes.length; i++) {
10304: if (size == sizes[i]) {
10305: fit = true;
10306: break;
10307: }
10308: }
10309: }
10310: if (fit) {
10311: System.out.println (Multilingual.mlnJapanese ?
10312: name + " を読み込みました" :
10313: name + " was read");
10314: rscLastFileName = name;
10315: return array;
10316: }
10317: System.out.println (Multilingual.mlnJapanese ?
10318: name + " のサイズが違います" :
10319: name + " has wrong size");
10320: continue;
10321: } catch (IOException ioe) {
10322: }
10323: if (is != null) {
10324: try {
10325: is.close ();
10326: is = null;
10327: } catch (IOException ioe) {
10328: }
10329: }
10330: }
10331: System.out.println (Multilingual.mlnJapanese ?
10332: name + " を読み込めません" :
10333: name + " cannot be read");
10334: }
10335:
10336:
10337:
10338: return null;
10339: }
10340:
10341:
10342:
10343:
10344: public static String rscGetTextFile (String name) {
10345: return rscGetTextFile (name, "UTF-8");
10346: }
10347: public static String rscGetTextFile (String name, String charset) {
10348: byte[] array = rscGetFile (name);
10349: if (array != null) {
10350: try {
10351: return new String (array, charset);
10352: } catch (UnsupportedEncodingException uee) {
10353: }
10354: }
10355: return "";
10356: }
10357:
10358:
10359:
10360: public static final int RSC_A_MASK = 1;
10361: public static final int RSC_R_MASK = 2;
10362: public static final int RSC_I_MASK = 4;
10363: public static final String RSC_A_EN = "Abort";
10364: public static final String RSC_R_EN = "Retry";
10365: public static final String RSC_I_EN = "Ignore";
10366: public static final String RSC_A_JA = "中止";
10367: public static final String RSC_R_JA = "再実行";
10368: public static final String RSC_I_JA = "無視";
10369: public static final String[][] RSC_EN_OPTIONS = {
10370: { RSC_A_EN },
10371: { RSC_A_EN },
10372: { RSC_R_EN },
10373: { RSC_A_EN, RSC_R_EN },
10374: { RSC_I_EN },
10375: { RSC_A_EN, RSC_I_EN },
10376: { RSC_R_EN, RSC_I_EN },
10377: { RSC_A_EN, RSC_R_EN, RSC_I_EN },
10378: };
10379: public static final String[][] RSC_JA_OPTIONS = {
10380: { RSC_A_JA },
10381: { RSC_A_JA },
10382: { RSC_R_JA },
10383: { RSC_A_JA, RSC_R_JA },
10384: { RSC_I_JA },
10385: { RSC_A_JA, RSC_I_JA },
10386: { RSC_R_JA, RSC_I_JA },
10387: { RSC_A_JA, RSC_R_JA, RSC_I_JA },
10388: };
10389: public static int rscShowError (String message, int mask) {
10390: System.out.println (message);
10391: mask &= RSC_A_MASK | RSC_R_MASK | RSC_I_MASK;
10392: if (mask == 0) {
10393: mask = RSC_A_MASK;
10394: }
10395: String[] options = (Multilingual.mlnJapanese ? RSC_JA_OPTIONS : RSC_EN_OPTIONS)[mask];
10396: int def = Integer.numberOfTrailingZeros (mask);
10397: pnlExitFullScreen (true);
10398: int bit = JOptionPane.showOptionDialog (
10399: null,
10400: message,
10401: Multilingual.mlnJapanese ? "ファイル操作エラー" : "File operation error",
10402: JOptionPane.YES_NO_CANCEL_OPTION,
10403: JOptionPane.ERROR_MESSAGE,
10404: null,
10405: options,
10406: options[def]);
10407: if (bit == JOptionPane.CLOSED_OPTION) {
10408: bit = def;
10409: }
10410: return 1 << bit;
10411: }
10412:
10413:
10414:
10415:
10416:
10417:
10418: public static boolean rscPutTextFile (String name, String string) {
10419: return rscPutTextFile (name, string, "UTF-8");
10420: }
10421: public static boolean rscPutTextFile (String name, ArrayList<String> strings) {
10422: return rscPutTextFile (name, strings, "UTF-8");
10423: }
10424: public static boolean rscPutTextFile (String name, String string, String charset) {
10425: ArrayList<String> strings = new ArrayList<String> ();
10426: strings.add (string);
10427: return rscPutTextFile (name, strings, charset);
10428: }
10429: public static boolean rscPutTextFile (String name, ArrayList<String> strings, String charset) {
10430: String nameTmp = name + ".tmp";
10431: String nameBak = name + ".bak";
10432: File file = new File (name);
10433: File fileTmp = new File (nameTmp);
10434: File fileBak = new File (nameBak);
10435:
10436: File parentDirectory = file.getParentFile ();
10437: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10438: if (!parentDirectory.mkdirs ()) {
10439: System.out.println (parentDirectory.getPath () + (Multilingual.mlnJapanese ? " を作れません" : " cannot be created"));
10440: return false;
10441: }
10442: }
10443:
10444: if (fileTmp.exists ()) {
10445: if (!fileTmp.delete ()) {
10446: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10447: return false;
10448: }
10449: }
10450:
10451: try (BufferedWriter bw = new BufferedWriter (new FileWriter (nameTmp, Charset.forName (charset)))) {
10452: for (String string : strings) {
10453: bw.write (string);
10454: }
10455: } catch (IOException ioe) {
10456: ioe.printStackTrace ();
10457: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " に書き出せません" : " cannot be written"));
10458: return false;
10459: }
10460:
10461: boolean fileExists = file.exists ();
10462: if (fileExists) {
10463:
10464: if (fileBak.exists ()) {
10465: if (!fileBak.delete ()) {
10466: System.out.println (nameBak + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10467: return false;
10468: }
10469: }
10470:
10471: if (!file.renameTo (fileBak)) {
10472: System.out.println (name + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + nameBak + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10473: return false;
10474: }
10475: }
10476:
10477: if (!fileTmp.renameTo (file)) {
10478: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + name + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10479: return false;
10480: }
10481: if (fileExists) {
10482: System.out.println (name + (Multilingual.mlnJapanese ? " を更新しました" : " was updated"));
10483: } else {
10484: System.out.println (name + (Multilingual.mlnJapanese ? " を作りました" : " was created"));
10485: }
10486: return true;
10487: }
10488:
10489:
10490:
10491:
10492:
10493:
10494:
10495:
10496:
10497: public static boolean rscPutFile (String name, byte[] array) {
10498: return rscPutFile (name, array, 0, array.length, (long) array.length);
10499: }
10500: public static boolean rscPutFile (String name, byte[] array, int offset, int length) {
10501: return rscPutFile (name, array, offset, length, (long) length);
10502: }
10503: public static boolean rscPutFile (String name, byte[] array, int offset, int length, long longLength2) {
10504: if (RSC_ZIP_SEPARATOR.matcher (name).matches ()) {
10505:
10506: return false;
10507: }
10508: File file = new File (name);
10509: boolean fileExists = file.isFile ();
10510: if (fileExists && file.length () == longLength2) {
10511: comparison:
10512: {
10513: try (BufferedInputStream bis = new BufferedInputStream (new FileInputStream (file))) {
10514: byte[] buffer = new byte[(int) Math.min (Math.max ((long) length, longLength2 - (long) length), (long) (1024 * 1024))];
10515: int position = 0;
10516: while (position < length) {
10517: int step = bis.read (buffer, 0, Math.min (buffer.length, length - position));
10518: if (step == -1) {
10519: break comparison;
10520: }
10521: int offsetPosition = offset + position;
10522: for (int i = 0; i < step; i++) {
10523: if (buffer[i] != array[offsetPosition + i]) {
10524: break comparison;
10525: }
10526: }
10527: position += step;
10528: }
10529: long longPosition2 = (long) length;
10530: while (longPosition2 < longLength2) {
10531: int step = bis.read (buffer, 0, (int) Math.min ((long) buffer.length, longLength2 - longPosition2));
10532: if (step == -1) {
10533: break comparison;
10534: }
10535: for (int i = 0; i < step; i++) {
10536: if (buffer[i] != 0) {
10537: break comparison;
10538: }
10539: }
10540: longPosition2 += (long) step;
10541: }
10542: return true;
10543: } catch (IOException ioe) {
10544: }
10545: }
10546: }
10547: String nameTmp = name + ".tmp";
10548: File fileTmp = new File (nameTmp);
10549: String nameBak = name + ".bak";
10550: File fileBak = new File (nameBak);
10551: retry:
10552: for (;;) {
10553: File parentDirectory = file.getParentFile ();
10554: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10555: String parentName = parentDirectory.getPath ();
10556: if (parentDirectory.mkdirs ()) {
10557: System.out.println (Multilingual.mlnJapanese ?
10558: parentName + " を作りました" :
10559: parentName + " was created");
10560: } else {
10561: switch (rscShowError (Multilingual.mlnJapanese ?
10562: parentName + " を作れません" :
10563: parentName + " cannot be created",
10564: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10565: case RSC_A_MASK:
10566: break retry;
10567: case RSC_R_MASK:
10568: continue retry;
10569: }
10570: }
10571: }
10572: if (fileTmp.isFile ()) {
10573: if (!fileTmp.delete ()) {
10574: switch (rscShowError (Multilingual.mlnJapanese ?
10575: nameTmp + " を削除できません" :
10576: nameTmp + " cannot be deleted",
10577: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10578: case RSC_A_MASK:
10579: break retry;
10580: case RSC_R_MASK:
10581: continue retry;
10582: }
10583: }
10584: }
10585: try (OutputStream os = name.toLowerCase ().endsWith (".gz") ?
10586: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10587: {
10588:
10589: def.setLevel (Deflater.DEFAULT_COMPRESSION);
10590:
10591: }
10592: } :
10593: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10594:
10595: os.write (array, offset, length);
10596:
10597:
10598: if ((long) length < longLength2) {
10599: byte[] buffer = new byte[(int) Math.min (longLength2 - (long) length, (long) (1024 * 1024))];
10600: Arrays.fill (buffer, 0, buffer.length, (byte) 0);
10601: long longPosition2 = (long) length;
10602: while (longPosition2 < longLength2) {
10603: int step = (int) Math.min ((long) buffer.length, longLength2 - longPosition2);
10604: os.write (buffer, 0, step);
10605: longPosition2 += (long) step;
10606: }
10607: }
10608: } catch (IOException ioe) {
10609: switch (rscShowError (Multilingual.mlnJapanese ?
10610: nameTmp + " に書き出せません" :
10611: nameTmp + " cannot be written",
10612: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10613: case RSC_A_MASK:
10614: break retry;
10615: case RSC_R_MASK:
10616: continue retry;
10617: }
10618: }
10619: if (fileExists && file.isFile ()) {
10620: if (fileBak.isFile ()) {
10621: if (!fileBak.delete ()) {
10622: switch (rscShowError (Multilingual.mlnJapanese ?
10623: nameBak + " を削除できません" :
10624: nameBak + " cannot be deleted",
10625: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10626: case RSC_A_MASK:
10627: break retry;
10628: case RSC_R_MASK:
10629: continue retry;
10630: }
10631: }
10632: }
10633: if (!file.renameTo (fileBak)) {
10634: switch (rscShowError (Multilingual.mlnJapanese ?
10635: name + " を " + nameBak + " にリネームできません" :
10636: name + " cannot be renamed to " + nameBak,
10637: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10638: case RSC_A_MASK:
10639: break retry;
10640: case RSC_R_MASK:
10641: continue retry;
10642: }
10643: }
10644: }
10645: if (fileTmp.renameTo (file)) {
10646: if (fileExists) {
10647: System.out.println (Multilingual.mlnJapanese ?
10648: name + " を更新しました" :
10649: name + " was updated");
10650: } else {
10651: System.out.println (Multilingual.mlnJapanese ?
10652: name + " を作りました" :
10653: name + " was created");
10654: }
10655: return true;
10656: } else {
10657: switch (rscShowError (Multilingual.mlnJapanese ?
10658: nameTmp + " を " + name + " にリネームできません" :
10659: nameTmp + " cannot be renamed to " + name,
10660: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10661: case RSC_A_MASK:
10662: break retry;
10663: case RSC_R_MASK:
10664: continue retry;
10665: }
10666: }
10667: break;
10668: }
10669: if (fileExists) {
10670: System.out.println (Multilingual.mlnJapanese ?
10671: name + " を更新できません" :
10672: name + " cannot be updated");
10673: } else {
10674: System.out.println (Multilingual.mlnJapanese ?
10675: name + " を作れません" :
10676: name + " cannot be created");
10677: }
10678: return false;
10679: }
10680:
10681:
10682:
10683:
10684:
10685:
10686: public static final Pattern ISM_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10687:
10688:
10689:
10690:
10691:
10692:
10693:
10694:
10695:
10696:
10697:
10698: public static InputStream ismOpen (String name) {
10699: InputStream in = null;
10700: in = ismOpen (name, false);
10701: if (in == null && name.indexOf ('/') < 0 && name.indexOf ('\\') < 0) {
10702: in = ismOpen (name, true);
10703: }
10704: return in;
10705: }
10706: public static InputStream ismOpen (String name, boolean useGetResource) {
10707: boolean gzipped = name.toLowerCase ().endsWith (".gz");
10708: String[] zipSplittedName = ISM_ZIP_SEPARATOR.split (name, 2);
10709: String fileName = zipSplittedName[0];
10710: String zipEntryName = zipSplittedName.length < 2 ? null : zipSplittedName[1];
10711: InputStream in = null;
10712: try {
10713: if (useGetResource) {
10714: if (false) {
10715: URL url = XEiJ.class.getResource (fileName);
10716: if (url != null) {
10717: in = url.openStream ();
10718: }
10719: } else {
10720: in = XEiJ.class.getResourceAsStream (fileName);
10721: }
10722: } else {
10723: File file = new File (fileName);
10724: if (file.exists ()) {
10725: in = new FileInputStream (file);
10726: }
10727: }
10728: if (in != null && zipEntryName != null) {
10729: ZipInputStream zin = new ZipInputStream (in);
10730: in = null;
10731: ZipEntry entry;
10732: while ((entry = zin.getNextEntry ()) != null) {
10733: if (zipEntryName.equals (entry.getName ())) {
10734: in = zin;
10735: break;
10736: }
10737: }
10738: if (in == null) {
10739: System.out.println (Multilingual.mlnJapanese ? fileName + " の中に " + zipEntryName + " がありません" :
10740: zipEntryName + " does not exist in " + fileName);
10741: }
10742: }
10743: if (in != null && gzipped) {
10744: in = new GZIPInputStream (in);
10745: }
10746: if (in != null) {
10747: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " を読み込みます" :
10748: (useGetResource ? "Reading resource file " : "Reading file ") + name);
10749: return new BufferedInputStream (in);
10750: }
10751: } catch (Exception ioe) {
10752: if (prgVerbose) {
10753: prgPrintStackTraceOf (ioe);
10754: }
10755: }
10756: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " が見つかりません" :
10757: (useGetResource ? "Resource file " : "File ") + name + " is not found");
10758: return null;
10759: }
10760:
10761:
10762:
10763:
10764:
10765:
10766:
10767:
10768: public static int ismRead (InputStream in, byte[] bb, int o, int l) {
10769: try {
10770: int k = 0;
10771: while (k < l) {
10772: int t = in.read (bb, o + k, l - k);
10773: if (t < 0) {
10774: break;
10775: }
10776: k += t;
10777: }
10778: return k;
10779: } catch (IOException ioe) {
10780: if (prgVerbose) {
10781: prgPrintStackTraceOf (ioe);
10782: }
10783: }
10784: return -1;
10785: }
10786:
10787:
10788:
10789:
10790:
10791:
10792:
10793:
10794: public static int ismSkip (InputStream in, int l) {
10795: try {
10796: int k = 0;
10797: while (k < l) {
10798:
10799:
10800: if (in.read () < 0) {
10801: break;
10802: }
10803: k++;
10804: if (k < l) {
10805: int t = (int) in.skip ((long) (l - k));
10806: if (t < 0) {
10807: break;
10808: }
10809: k += t;
10810: }
10811: }
10812: return k;
10813: } catch (IOException ioe) {
10814: if (prgVerbose) {
10815: prgPrintStackTraceOf (ioe);
10816: }
10817: }
10818: return -1;
10819: }
10820:
10821:
10822:
10823:
10824:
10825: public static void ismClose (InputStream in) {
10826: try {
10827: if (in != null) {
10828: in.close ();
10829: }
10830: } catch (IOException ioe) {
10831: if (prgVerbose) {
10832: prgPrintStackTraceOf (ioe);
10833: }
10834: }
10835: }
10836:
10837:
10838:
10839:
10840:
10841:
10842: public static int ismLength (String name, int maxLength) {
10843: int length;
10844: InputStream in = ismOpen (name);
10845: if (in == null) {
10846: length = -1;
10847: } else {
10848: length = ismSkip (in, maxLength);
10849: ismClose (in);
10850: }
10851: return length;
10852: }
10853:
10854:
10855:
10856:
10857:
10858:
10859:
10860:
10861:
10862:
10863:
10864:
10865:
10866:
10867: public static boolean ismLoad (byte[] bb, int o, int l, String names) {
10868: for (String name : names.split (",")) {
10869: if (name.length () != 0) {
10870: InputStream in = ismOpen (name);
10871: if (in != null) {
10872: int k = ismRead (in, bb, o, l);
10873: ismClose (in);
10874: if (k == l) {
10875: return true;
10876: }
10877: }
10878: }
10879: }
10880: return false;
10881: }
10882:
10883:
10884:
10885:
10886:
10887:
10888:
10889:
10890:
10891: public static boolean ismSave (byte[] bb, int offset, long length, String path, boolean verbose) {
10892: if (ISM_ZIP_SEPARATOR.split (path, 2).length != 1) {
10893: if (verbose) {
10894: pnlExitFullScreen (true);
10895: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? path + " に書き出せません" : "Cannot write " + path);
10896: }
10897: return false;
10898: }
10899: long step = 0;
10900: byte[] zz = null;
10901: long pointer = (long) (bb.length - offset);
10902: if (pointer < length) {
10903: step = Math.min (1024L * 512, length - pointer);
10904: zz = new byte[(int) step];
10905: Arrays.fill (zz, (byte) 0);
10906: }
10907:
10908: File file = new File (path);
10909:
10910: if (step == 0 &&
10911: file.exists () && file.length () == length) {
10912:
10913: if (length == 0L) {
10914: return true;
10915: }
10916: InputStream in = ismOpen (path);
10917: if (in != null) {
10918: int l = (int) length;
10919: byte[] tt = new byte[l];
10920: int k = ismRead (in, tt, 0, l);
10921: ismClose (in);
10922: if (k == l &&
10923: Arrays.equals (tt, bb.length == l ? bb : Arrays.copyOfRange (bb, offset, offset + l))) {
10924: return true;
10925: }
10926: }
10927: }
10928:
10929: String pathTmp = path + ".tmp";
10930: String pathBak = path + ".bak";
10931: File fileTmp = new File (pathTmp);
10932: File fileBak = new File (pathBak);
10933:
10934: if (fileTmp.exists ()) {
10935: if (!fileTmp.delete ()) {
10936: if (verbose) {
10937: pnlExitFullScreen (true);
10938: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " を削除できません" : "Cannot delete " + pathTmp);
10939: }
10940: return false;
10941: }
10942: }
10943:
10944: try (OutputStream out = path.toLowerCase ().endsWith (".gz") ?
10945: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10946: {
10947:
10948: def.setLevel (Deflater.DEFAULT_COMPRESSION);
10949:
10950: }
10951: } :
10952: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10953: if (step == 0) {
10954: out.write (bb, offset, (int) length);
10955: } else {
10956: out.write (bb, offset, (int) pointer);
10957: for (; pointer < length; pointer += step) {
10958: out.write (zz, 0, (int) Math.min (step, length - pointer));
10959: }
10960: }
10961: } catch (IOException ioe) {
10962: if (verbose) {
10963: prgPrintStackTraceOf (ioe);
10964: pnlExitFullScreen (true);
10965: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " に書き出せません" : "Cannot write " + pathTmp);
10966: }
10967: return false;
10968: }
10969:
10970:
10971: if (file.exists ()) {
10972: if (fileBak.exists ()) {
10973: if (!fileBak.delete ()) {
10974: if (verbose) {
10975: pnlExitFullScreen (true);
10976: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathBak + " を削除できません" : "Cannot delete " + pathBak);
10977: }
10978: return false;
10979: }
10980: }
10981: if (!file.renameTo (fileBak)) {
10982: if (verbose) {
10983: pnlExitFullScreen (true);
10984: JOptionPane.showMessageDialog (
10985: null, Multilingual.mlnJapanese ? path + " を " + pathBak + " にリネームできません" : "Cannot rename " + path + " to " + pathBak);
10986: }
10987: return false;
10988: }
10989: }
10990:
10991:
10992: if (!fileTmp.renameTo (file)) {
10993: if (verbose) {
10994: pnlExitFullScreen (true);
10995: JOptionPane.showMessageDialog (
10996: null, Multilingual.mlnJapanese ? pathTmp + " を " + path + " にリネームできません" : "Cannot rename " + pathTmp + " to " + path);
10997: }
10998: return false;
10999: }
11000: return true;
11001: }
11002:
11003:
11004:
11005:
11006:
11007:
11008:
11009: public static final char[] FMT_TEMP = new char[32];
11010:
11011:
11012:
11013:
11014:
11015:
11016:
11017:
11018:
11019:
11020:
11021: public static final char[] FMT_AIN4_BASE = ".......*..*...**.*...*.*.**..****...*..**.*.*.****..**.****.****".toCharArray ();
11022: public static final char[] FMT_BIN4_BASE = "0000000100100011010001010110011110001001101010111100110111101111".toCharArray ();
11023:
11024:
11025:
11026:
11027:
11028:
11029:
11030:
11031: public static void fmtAin4 (char[] a, int o, int x) {
11032: a[o ] = (char) (x >> 1 & 4 ^ 46);
11033: a[o + 1] = (char) (x & 4 ^ 46);
11034: a[o + 2] = (char) (x << 1 & 4 ^ 46);
11035: a[o + 3] = (char) (x << 2 & 4 ^ 46);
11036: }
11037: public static void fmtBin4 (char[] a, int o, int x) {
11038: a[o ] = (char) (x >>> 3 & 1 | 48);
11039: a[o + 1] = (char) (x >>> 2 & 1 | 48);
11040: a[o + 2] = (char) (x >>> 1 & 1 | 48);
11041: a[o + 3] = (char) (x & 1 | 48);
11042: }
11043: public static String fmtAin4 (int x) {
11044: return String.valueOf (FMT_AIN4_BASE, (x & 15) << 2, 4);
11045: }
11046: public static String fmtBin4 (int x) {
11047: return String.valueOf (FMT_BIN4_BASE, (x & 15) << 2, 4);
11048: }
11049: public static StringBuilder fmtAin4 (StringBuilder sb, int x) {
11050: return sb.append (FMT_AIN4_BASE, (x & 15) << 2, 6);
11051: }
11052: public static StringBuilder fmtBin4 (StringBuilder sb, int x) {
11053: return sb.append (FMT_BIN4_BASE, (x & 15) << 2, 6);
11054: }
11055:
11056:
11057:
11058:
11059:
11060:
11061:
11062:
11063: public static void fmtAin6 (char[] a, int o, int x) {
11064: a[o ] = (char) (x >> 3 & 4 ^ 46);
11065: a[o + 1] = (char) (x >> 2 & 4 ^ 46);
11066: a[o + 2] = (char) (x >> 1 & 4 ^ 46);
11067: a[o + 3] = (char) (x & 4 ^ 46);
11068: a[o + 4] = (char) (x << 1 & 4 ^ 46);
11069: a[o + 5] = (char) (x << 2 & 4 ^ 46);
11070: }
11071: public static void fmtBin6 (char[] a, int o, int x) {
11072: a[o ] = (char) (x >>> 5 & 1 | 48);
11073: a[o + 1] = (char) (x >>> 4 & 1 | 48);
11074: a[o + 2] = (char) (x >>> 3 & 1 | 48);
11075: a[o + 3] = (char) (x >>> 2 & 1 | 48);
11076: a[o + 4] = (char) (x >>> 1 & 1 | 48);
11077: a[o + 5] = (char) (x & 1 | 48);
11078: }
11079: public static String fmtAin6 (int x) {
11080: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11081: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11082: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11083: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11084: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11085: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11086: return String.valueOf (FMT_TEMP, 0, 6);
11087: }
11088: public static String fmtBin6 (int x) {
11089: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11090: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11091: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11092: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11093: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11094: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11095: return String.valueOf (FMT_TEMP, 0, 6);
11096: }
11097: public static StringBuilder fmtAin6 (StringBuilder sb, int x) {
11098: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11099: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11100: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11101: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11102: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11103: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11104: return sb.append (FMT_TEMP, 0, 6);
11105: }
11106: public static StringBuilder fmtBin6 (StringBuilder sb, int x) {
11107: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11108: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11109: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11110: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11111: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11112: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11113: return sb.append (FMT_TEMP, 0, 6);
11114: }
11115:
11116:
11117:
11118:
11119:
11120:
11121:
11122:
11123: public static void fmtAin8 (char[] a, int o, int x) {
11124: a[o ] = (char) (x >> 5 & 4 ^ 46);
11125: a[o + 1] = (char) (x >> 4 & 4 ^ 46);
11126: a[o + 2] = (char) (x >> 3 & 4 ^ 46);
11127: a[o + 3] = (char) (x >> 2 & 4 ^ 46);
11128: a[o + 4] = (char) (x >> 1 & 4 ^ 46);
11129: a[o + 5] = (char) (x & 4 ^ 46);
11130: a[o + 6] = (char) (x << 1 & 4 ^ 46);
11131: a[o + 7] = (char) (x << 2 & 4 ^ 46);
11132: }
11133: public static void fmtBin8 (char[] a, int o, int x) {
11134: a[o ] = (char) (x >>> 7 & 1 | 48);
11135: a[o + 1] = (char) (x >>> 6 & 1 | 48);
11136: a[o + 2] = (char) (x >>> 5 & 1 | 48);
11137: a[o + 3] = (char) (x >>> 4 & 1 | 48);
11138: a[o + 4] = (char) (x >>> 3 & 1 | 48);
11139: a[o + 5] = (char) (x >>> 2 & 1 | 48);
11140: a[o + 6] = (char) (x >>> 1 & 1 | 48);
11141: a[o + 7] = (char) (x & 1 | 48);
11142: }
11143: public static String fmtAin8 (int x) {
11144: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11145: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11146: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11147: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11148: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11149: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11150: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11151: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11152: return String.valueOf (FMT_TEMP, 0, 8);
11153: }
11154: public static String fmtBin8 (int x) {
11155: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11156: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11157: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11158: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11159: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11160: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11161: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11162: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11163: return String.valueOf (FMT_TEMP, 0, 8);
11164: }
11165: public static StringBuilder fmtAin8 (StringBuilder sb, int x) {
11166: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11167: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11168: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11169: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11170: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11171: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11172: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11173: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11174: return sb.append (FMT_TEMP, 0, 8);
11175: }
11176: public static StringBuilder fmtBin8 (StringBuilder sb, int x) {
11177: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11178: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11179: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11180: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11181: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11182: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11183: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11184: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11185: return sb.append (FMT_TEMP, 0, 8);
11186: }
11187:
11188:
11189:
11190:
11191:
11192:
11193:
11194:
11195: public static void fmtAin12 (char[] a, int o, int x) {
11196: a[o ] = (char) (x >> 9 & 4 ^ 46);
11197: a[o + 1] = (char) (x >> 8 & 4 ^ 46);
11198: a[o + 2] = (char) (x >> 7 & 4 ^ 46);
11199: a[o + 3] = (char) (x >> 6 & 4 ^ 46);
11200: a[o + 4] = (char) (x >> 5 & 4 ^ 46);
11201: a[o + 5] = (char) (x >> 4 & 4 ^ 46);
11202: a[o + 6] = (char) (x >> 3 & 4 ^ 46);
11203: a[o + 7] = (char) (x >> 2 & 4 ^ 46);
11204: a[o + 8] = (char) (x >> 1 & 4 ^ 46);
11205: a[o + 9] = (char) (x & 4 ^ 46);
11206: a[o + 10] = (char) (x << 1 & 4 ^ 46);
11207: a[o + 11] = (char) (x << 2 & 4 ^ 46);
11208: }
11209: public static void fmtBin12 (char[] a, int o, int x) {
11210: a[o ] = (char) (x >>> 11 & 1 | 48);
11211: a[o + 1] = (char) (x >>> 10 & 1 | 48);
11212: a[o + 2] = (char) (x >>> 9 & 1 | 48);
11213: a[o + 3] = (char) (x >>> 8 & 1 | 48);
11214: a[o + 4] = (char) (x >>> 7 & 1 | 48);
11215: a[o + 5] = (char) (x >>> 6 & 1 | 48);
11216: a[o + 6] = (char) (x >>> 5 & 1 | 48);
11217: a[o + 7] = (char) (x >>> 4 & 1 | 48);
11218: a[o + 8] = (char) (x >>> 3 & 1 | 48);
11219: a[o + 9] = (char) (x >>> 2 & 1 | 48);
11220: a[o + 10] = (char) (x >>> 1 & 1 | 48);
11221: a[o + 11] = (char) (x & 1 | 48);
11222: }
11223: public static String fmtAin12 (int x) {
11224: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11225: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11226: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11227: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11228: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11229: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11230: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11231: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11232: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11233: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11234: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11235: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11236: return String.valueOf (FMT_TEMP, 0, 12);
11237: }
11238: public static String fmtBin12 (int x) {
11239: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11240: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11241: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11242: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11243: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11244: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11245: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11246: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11247: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11248: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11249: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11250: FMT_TEMP[11] = (char) (x & 1 | 48);
11251: return String.valueOf (FMT_TEMP, 0, 12);
11252: }
11253: public static StringBuilder fmtAin12 (StringBuilder sb, int x) {
11254: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11255: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11256: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11257: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11258: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11259: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11260: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11261: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11262: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11263: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11264: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11265: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11266: return sb.append (FMT_TEMP, 0, 12);
11267: }
11268: public static StringBuilder fmtBin12 (StringBuilder sb, int x) {
11269: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11270: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11271: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11272: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11273: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11274: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11275: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11276: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11277: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11278: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11279: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11280: FMT_TEMP[11] = (char) (x & 1 | 48);
11281: return sb.append (FMT_TEMP, 0, 12);
11282: }
11283:
11284:
11285:
11286:
11287:
11288:
11289:
11290:
11291: public static void fmtAin16 (char[] a, int o, int x) {
11292: a[o ] = (char) (x >> 13 & 4 ^ 46);
11293: a[o + 1] = (char) (x >> 12 & 4 ^ 46);
11294: a[o + 2] = (char) (x >> 11 & 4 ^ 46);
11295: a[o + 3] = (char) (x >> 10 & 4 ^ 46);
11296: a[o + 4] = (char) (x >> 9 & 4 ^ 46);
11297: a[o + 5] = (char) (x >> 8 & 4 ^ 46);
11298: a[o + 6] = (char) (x >> 7 & 4 ^ 46);
11299: a[o + 7] = (char) (x >> 6 & 4 ^ 46);
11300: a[o + 8] = (char) (x >> 5 & 4 ^ 46);
11301: a[o + 9] = (char) (x >> 4 & 4 ^ 46);
11302: a[o + 10] = (char) (x >> 3 & 4 ^ 46);
11303: a[o + 11] = (char) (x >> 2 & 4 ^ 46);
11304: a[o + 12] = (char) (x >> 1 & 4 ^ 46);
11305: a[o + 13] = (char) (x & 4 ^ 46);
11306: a[o + 14] = (char) (x << 1 & 4 ^ 46);
11307: a[o + 15] = (char) (x << 2 & 4 ^ 46);
11308: }
11309: public static void fmtBin16 (char[] a, int o, int x) {
11310: a[o ] = (char) (x >>> 15 & 1 | 48);
11311: a[o + 1] = (char) (x >>> 14 & 1 | 48);
11312: a[o + 2] = (char) (x >>> 13 & 1 | 48);
11313: a[o + 3] = (char) (x >>> 12 & 1 | 48);
11314: a[o + 4] = (char) (x >>> 11 & 1 | 48);
11315: a[o + 5] = (char) (x >>> 10 & 1 | 48);
11316: a[o + 6] = (char) (x >>> 9 & 1 | 48);
11317: a[o + 7] = (char) (x >>> 8 & 1 | 48);
11318: a[o + 8] = (char) (x >>> 7 & 1 | 48);
11319: a[o + 9] = (char) (x >>> 6 & 1 | 48);
11320: a[o + 10] = (char) (x >>> 5 & 1 | 48);
11321: a[o + 11] = (char) (x >>> 4 & 1 | 48);
11322: a[o + 12] = (char) (x >>> 3 & 1 | 48);
11323: a[o + 13] = (char) (x >>> 2 & 1 | 48);
11324: a[o + 14] = (char) (x >>> 1 & 1 | 48);
11325: a[o + 15] = (char) (x & 1 | 48);
11326: }
11327: public static String fmtAin16 (int x) {
11328: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11329: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11330: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11331: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11332: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11333: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11334: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11335: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11336: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11337: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11338: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11339: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11340: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11341: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11342: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11343: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11344: return String.valueOf (FMT_TEMP, 0, 16);
11345: }
11346: public static String fmtBin16 (int x) {
11347: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11348: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11349: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11350: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11351: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11352: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11353: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11354: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11355: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11356: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11357: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11358: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11359: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11360: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11361: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11362: FMT_TEMP[15] = (char) (x & 1 | 48);
11363: return String.valueOf (FMT_TEMP, 0, 16);
11364: }
11365: public static StringBuilder fmtAin16 (StringBuilder sb, int x) {
11366: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11367: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11368: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11369: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11370: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11371: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11372: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11373: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11374: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11375: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11376: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11377: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11378: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11379: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11380: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11381: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11382: return sb.append (FMT_TEMP, 0, 16);
11383: }
11384: public static StringBuilder fmtBin16 (StringBuilder sb, int x) {
11385: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11386: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11387: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11388: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11389: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11390: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11391: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11392: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11393: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11394: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11395: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11396: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11397: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11398: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11399: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11400: FMT_TEMP[15] = (char) (x & 1 | 48);
11401: return sb.append (FMT_TEMP, 0, 16);
11402: }
11403:
11404:
11405:
11406:
11407:
11408:
11409:
11410:
11411: public static void fmtAin24 (char[] a, int o, int x) {
11412: a[o ] = (char) (x >> 21 & 4 ^ 46);
11413: a[o + 1] = (char) (x >> 20 & 4 ^ 46);
11414: a[o + 2] = (char) (x >> 19 & 4 ^ 46);
11415: a[o + 3] = (char) (x >> 18 & 4 ^ 46);
11416: a[o + 4] = (char) (x >> 17 & 4 ^ 46);
11417: a[o + 5] = (char) (x >> 16 & 4 ^ 46);
11418: a[o + 6] = (char) (x >> 15 & 4 ^ 46);
11419: a[o + 7] = (char) (x >> 14 & 4 ^ 46);
11420: a[o + 8] = (char) (x >> 13 & 4 ^ 46);
11421: a[o + 9] = (char) (x >> 12 & 4 ^ 46);
11422: a[o + 10] = (char) (x >> 11 & 4 ^ 46);
11423: a[o + 11] = (char) (x >> 10 & 4 ^ 46);
11424: a[o + 12] = (char) (x >> 9 & 4 ^ 46);
11425: a[o + 13] = (char) (x >> 8 & 4 ^ 46);
11426: a[o + 14] = (char) (x >> 7 & 4 ^ 46);
11427: a[o + 15] = (char) (x >> 6 & 4 ^ 46);
11428: a[o + 16] = (char) (x >> 5 & 4 ^ 46);
11429: a[o + 17] = (char) (x >> 4 & 4 ^ 46);
11430: a[o + 18] = (char) (x >> 3 & 4 ^ 46);
11431: a[o + 19] = (char) (x >> 2 & 4 ^ 46);
11432: a[o + 20] = (char) (x >> 1 & 4 ^ 46);
11433: a[o + 21] = (char) (x & 4 ^ 46);
11434: a[o + 22] = (char) (x << 1 & 4 ^ 46);
11435: a[o + 23] = (char) (x << 2 & 4 ^ 46);
11436: }
11437: public static void fmtBin24 (char[] a, int o, int x) {
11438: a[o ] = (char) (x >>> 23 & 1 | 48);
11439: a[o + 1] = (char) (x >>> 22 & 1 | 48);
11440: a[o + 2] = (char) (x >>> 21 & 1 | 48);
11441: a[o + 3] = (char) (x >>> 20 & 1 | 48);
11442: a[o + 4] = (char) (x >>> 19 & 1 | 48);
11443: a[o + 5] = (char) (x >>> 18 & 1 | 48);
11444: a[o + 6] = (char) (x >>> 17 & 1 | 48);
11445: a[o + 7] = (char) (x >>> 16 & 1 | 48);
11446: a[o + 8] = (char) (x >>> 15 & 1 | 48);
11447: a[o + 9] = (char) (x >>> 14 & 1 | 48);
11448: a[o + 10] = (char) (x >>> 13 & 1 | 48);
11449: a[o + 11] = (char) (x >>> 12 & 1 | 48);
11450: a[o + 12] = (char) (x >>> 11 & 1 | 48);
11451: a[o + 13] = (char) (x >>> 10 & 1 | 48);
11452: a[o + 14] = (char) (x >>> 9 & 1 | 48);
11453: a[o + 15] = (char) (x >>> 8 & 1 | 48);
11454: a[o + 16] = (char) (x >>> 7 & 1 | 48);
11455: a[o + 17] = (char) (x >>> 6 & 1 | 48);
11456: a[o + 18] = (char) (x >>> 5 & 1 | 48);
11457: a[o + 19] = (char) (x >>> 4 & 1 | 48);
11458: a[o + 20] = (char) (x >>> 3 & 1 | 48);
11459: a[o + 21] = (char) (x >>> 2 & 1 | 48);
11460: a[o + 22] = (char) (x >>> 1 & 1 | 48);
11461: a[o + 23] = (char) (x & 1 | 48);
11462: }
11463: public static String fmtAin24 (int x) {
11464: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11465: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11466: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11467: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11468: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11469: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11470: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11471: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11472: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11473: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11474: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11475: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11476: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11477: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11478: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11479: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11480: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11481: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11482: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11483: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11484: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11485: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11486: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11487: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11488: return String.valueOf (FMT_TEMP, 0, 24);
11489: }
11490: public static String fmtBin24 (int x) {
11491: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11492: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11493: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11494: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11495: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11496: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11497: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11498: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11499: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11500: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11501: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11502: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11503: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11504: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11505: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11506: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11507: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11508: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11509: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11510: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11511: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11512: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11513: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11514: FMT_TEMP[23] = (char) (x & 1 | 48);
11515: return String.valueOf (FMT_TEMP, 0, 24);
11516: }
11517: public static StringBuilder fmtAin24 (StringBuilder sb, int x) {
11518: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11519: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11520: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11521: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11522: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11523: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11524: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11525: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11526: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11527: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11528: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11529: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11530: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11531: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11532: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11533: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11534: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11535: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11536: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11537: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11538: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11539: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11540: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11541: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11542: return sb.append (FMT_TEMP, 0, 24);
11543: }
11544: public static StringBuilder fmtBin24 (StringBuilder sb, int x) {
11545: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11546: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11547: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11548: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11549: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11550: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11551: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11552: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11553: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11554: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11555: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11556: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11557: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11558: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11559: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11560: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11561: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11562: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11563: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11564: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11565: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11566: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11567: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11568: FMT_TEMP[23] = (char) (x & 1 | 48);
11569: return sb.append (FMT_TEMP, 0, 24);
11570: }
11571:
11572:
11573:
11574:
11575:
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: public static char fmtHexc (int x) {
11605: x &= 15;
11606: return (char) ((((9 - x) >> 4) & 7) + 48 + x);
11607: }
11608: public static void fmtHex1 (char[] a, int o, int x) {
11609: x &= 15;
11610: a[o] = (char) ((((9 - x) >> 4) & 7) + 48 + x);
11611: }
11612: public static String fmtHex1 (int x) {
11613: x &= 15;
11614: return Character.toString ((char) ((((9 - x) >> 4) & 7) + 48 + x));
11615: }
11616: public static StringBuilder fmtHex1 (StringBuilder sb, int x) {
11617: x &= 15;
11618: return sb.append ((char) ((((9 - x) >> 4) & 7) + 48 + x));
11619: }
11620:
11621:
11622:
11623:
11624:
11625:
11626: public static void fmtHex2 (char[] a, int o, int x) {
11627: int x0 = x & 15;
11628: int x1 = x >>> 4 & 15;
11629: a[o ] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
11630: a[o + 1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
11631: }
11632: public static String fmtHex2 (int x) {
11633:
11634: int x0 = x & 15;
11635: int x1 = x >>> 4 & 15;
11636: FMT_TEMP[0] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
11637: FMT_TEMP[1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
11638: return String.valueOf (FMT_TEMP, 0, 2);
11639: }
11640: public static StringBuilder fmtHex2 (StringBuilder sb, int x) {
11641: int x0 = x & 15;
11642: int x1 = x >>> 4 & 15;
11643: return (sb.
11644: append ((char) ((((9 - x1) >> 4) & 7) + 48 + x1)).
11645: append ((char) ((((9 - x0) >> 4) & 7) + 48 + x0)));
11646: }
11647:
11648:
11649:
11650:
11651:
11652:
11653: public static void fmtHex4 (char[] a, int o, int x) {
11654: int t;
11655: t = (char) x >>> 12;
11656: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11657: t = x >>> 8 & 15;
11658: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11659: t = x >>> 4 & 15;
11660: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11661: t = x & 15;
11662: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11663: }
11664: public static String fmtHex4 (int x) {
11665:
11666: int t;
11667: t = (char) x >>> 12;
11668: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11669: t = x >>> 8 & 15;
11670: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11671: t = x >>> 4 & 15;
11672: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11673: t = x & 15;
11674: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11675: return String.valueOf (FMT_TEMP, 0, 4);
11676: }
11677: public static StringBuilder fmtHex4 (StringBuilder sb, int x) {
11678:
11679: int t;
11680: t = (char) x >>> 12;
11681: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11682: t = x >>> 8 & 15;
11683: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11684: t = x >>> 4 & 15;
11685: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11686: t = x & 15;
11687: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11688: return sb.append (FMT_TEMP, 0, 4);
11689: }
11690:
11691:
11692:
11693:
11694:
11695:
11696: public static void fmtHex6 (char[] a, int o, int x) {
11697: int t;
11698: t = x >>> 20 & 15;
11699: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11700: t = x >>> 16 & 15;
11701: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11702: t = (char) x >>> 12;
11703: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11704: t = x >>> 8 & 15;
11705: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11706: t = x >>> 4 & 15;
11707: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11708: t = x & 15;
11709: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11710: }
11711: public static String fmtHex6 (int x) {
11712:
11713: int t;
11714: t = x >>> 20 & 15;
11715: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11716: t = x >>> 16 & 15;
11717: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11718: t = (char) x >>> 12;
11719: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11720: t = x >>> 8 & 15;
11721: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11722: t = x >>> 4 & 15;
11723: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11724: t = x & 15;
11725: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11726: return String.valueOf (FMT_TEMP, 0, 6);
11727: }
11728: public static StringBuilder fmtHex6 (StringBuilder sb, int x) {
11729:
11730: int t;
11731: t = x >>> 20 & 15;
11732: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11733: t = x >>> 16 & 15;
11734: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11735: t = (char) x >>> 12;
11736: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11737: t = x >>> 8 & 15;
11738: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11739: t = x >>> 4 & 15;
11740: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11741: t = x & 15;
11742: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11743: return sb.append (FMT_TEMP, 0, 6);
11744: }
11745:
11746:
11747:
11748:
11749:
11750:
11751: public static void fmtHex8 (char[] a, int o, int x) {
11752: int t;
11753: t = x >>> 28;
11754: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11755: t = x >>> 24 & 15;
11756: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11757: t = x >>> 20 & 15;
11758: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11759: t = x >>> 16 & 15;
11760: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11761: t = (char) x >>> 12;
11762: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11763: t = x >>> 8 & 15;
11764: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11765: t = x >>> 4 & 15;
11766: a[o + 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11767: t = x & 15;
11768: a[o + 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11769: }
11770: public static String fmtHex8 (int x) {
11771:
11772: int t;
11773: t = x >>> 28;
11774: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11775: t = x >>> 24 & 15;
11776: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11777: t = x >>> 20 & 15;
11778: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11779: t = x >>> 16 & 15;
11780: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11781: t = (char) x >>> 12;
11782: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11783: t = x >>> 8 & 15;
11784: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11785: t = x >>> 4 & 15;
11786: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11787: t = x & 15;
11788: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11789: return String.valueOf (FMT_TEMP, 0, 8);
11790: }
11791: public static StringBuilder fmtHex8 (StringBuilder sb, int x) {
11792:
11793: int t;
11794: t = x >>> 28;
11795: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11796: t = x >>> 24 & 15;
11797: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11798: t = x >>> 20 & 15;
11799: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11800: t = x >>> 16 & 15;
11801: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11802: t = (char) x >>> 12;
11803: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11804: t = x >>> 8 & 15;
11805: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11806: t = x >>> 4 & 15;
11807: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11808: t = x & 15;
11809: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11810: return sb.append (FMT_TEMP, 0, 8);
11811: }
11812:
11813: public static StringBuilder fmtHex16 (StringBuilder sb, long x) {
11814:
11815: int s, t;
11816: s = (int) (x >>> 32);
11817: t = s >>> 28;
11818: FMT_TEMP[ 0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11819: t = s >>> 24 & 15;
11820: FMT_TEMP[ 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11821: t = s >>> 20 & 15;
11822: FMT_TEMP[ 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11823: t = s >>> 16 & 15;
11824: FMT_TEMP[ 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11825: t = (char) s >>> 12;
11826: FMT_TEMP[ 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11827: t = s >>> 8 & 15;
11828: FMT_TEMP[ 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11829: t = s >>> 4 & 15;
11830: FMT_TEMP[ 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11831: t = s & 15;
11832: FMT_TEMP[ 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11833: s = (int) x;
11834: t = s >>> 28;
11835: FMT_TEMP[ 8] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11836: t = s >>> 24 & 15;
11837: FMT_TEMP[ 9] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11838: t = s >>> 20 & 15;
11839: FMT_TEMP[10] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11840: t = s >>> 16 & 15;
11841: FMT_TEMP[11] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11842: t = (char) s >>> 12;
11843: FMT_TEMP[12] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11844: t = s >>> 8 & 15;
11845: FMT_TEMP[13] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11846: t = s >>> 4 & 15;
11847: FMT_TEMP[14] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11848: t = s & 15;
11849: FMT_TEMP[15] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11850: return sb.append (FMT_TEMP, 0, 16);
11851: }
11852:
11853:
11854:
11855:
11856:
11857:
11858:
11859:
11860:
11861:
11862:
11863:
11864:
11865:
11866:
11867:
11868:
11869:
11870:
11871:
11872:
11873:
11874:
11875:
11876:
11877:
11878:
11879:
11880:
11881:
11882:
11883:
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: public static final int[] FMT_BCD4 = new int[10000];
11921: public static final int[] FMT_DCB4 = new int[65536];
11922:
11923:
11924:
11925:
11926: public static void fmtInit () {
11927: Arrays.fill (FMT_DCB4, -1);
11928: int i = 0;
11929: int x = 0;
11930: for (int a = 0; a < 10; a++) {
11931: for (int b = 0; b < 10; b++) {
11932: for (int c = 0; c < 10; c++) {
11933: FMT_DCB4[FMT_BCD4[i ] = x ] = i;
11934: FMT_DCB4[FMT_BCD4[i + 1] = x + 1] = i + 1;
11935: FMT_DCB4[FMT_BCD4[i + 2] = x + 2] = i + 2;
11936: FMT_DCB4[FMT_BCD4[i + 3] = x + 3] = i + 3;
11937: FMT_DCB4[FMT_BCD4[i + 4] = x + 4] = i + 4;
11938: FMT_DCB4[FMT_BCD4[i + 5] = x + 5] = i + 5;
11939: FMT_DCB4[FMT_BCD4[i + 6] = x + 6] = i + 6;
11940: FMT_DCB4[FMT_BCD4[i + 7] = x + 7] = i + 7;
11941: FMT_DCB4[FMT_BCD4[i + 8] = x + 8] = i + 8;
11942: FMT_DCB4[FMT_BCD4[i + 9] = x + 9] = i + 9;
11943: i += 10;
11944: x += 1 << 4;
11945: }
11946: x += 6 << 4;
11947: }
11948: x += 6 << 8;
11949: }
11950: }
11951:
11952:
11953:
11954: public static int fmtBcd4 (int x) {
11955:
11956:
11957:
11958:
11959:
11960:
11961:
11962:
11963:
11964: return FMT_BCD4[Math.max (0, Math.min (9999, x))];
11965: }
11966:
11967:
11968:
11969: public static int fmtBcd8 (int x) {
11970: x = Math.max (0, Math.min (99999999, x));
11971:
11972:
11973: int q = (int) ((long) x * 109951163L >>> 40);
11974:
11975: return FMT_BCD4[q] << 16 | FMT_BCD4[x - 10000 * q];
11976: }
11977:
11978:
11979:
11980: public static long fmtBcd12 (long x) {
11981: x = Math.max (0L, Math.min (999999999999L, x));
11982: int q = (int) ((double) x / 100000000.0);
11983: int r = (int) (x - 100000000L * q);
11984:
11985:
11986: int rq = (int) ((long) r * 109951163L >>> 40);
11987:
11988: return (long) FMT_BCD4[q] << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
11989: }
11990:
11991:
11992:
11993: public static long fmtBcd16 (long x) {
11994: x = Math.max (0L, Math.min (9999999999999999L, x));
11995: int q = x <= (1L << 53) ? (int) ((double) x / 100000000.0) : (int) (x / 100000000L);
11996: int r = (int) (x - 100000000L * q);
11997:
11998:
11999: int qq = (int) ((long) q * 109951163L >>> 40);
12000:
12001:
12002:
12003: int rq = (int) ((long) r * 109951163L >>> 40);
12004:
12005: return (long) (FMT_BCD4[qq] << 16 | FMT_BCD4[q - 10000 * qq]) << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
12006: }
12007:
12008:
12009:
12010:
12011:
12012:
12013: public static int fmtCA02u (char[] a, int o, int x) {
12014: if (x < 0 || 99 < x) {
12015: x = 99;
12016: }
12017: x = FMT_BCD4[x];
12018: a[o ] = (char) ('0' | x >>> 4);
12019: a[o + 1] = (char) ('0' | x & 15);
12020: return o + 2;
12021: }
12022: public static StringBuilder fmtSB02u (StringBuilder sb, int x) {
12023: return sb.append (FMT_TEMP, 0, fmtCA02u (FMT_TEMP, 0, x));
12024: }
12025:
12026:
12027:
12028:
12029:
12030: public static int fmtCA2u (char[] a, int o, int x) {
12031: if (x < 0 || 99 < x) {
12032: x = 99;
12033: }
12034: x = FMT_BCD4[x];
12035: if (x <= 0x000f) {
12036: a[o++] = (char) ('0' | x);
12037: } else {
12038: a[o++] = (char) ('0' | x >>> 4);
12039: a[o++] = (char) ('0' | x & 15);
12040: }
12041: return o;
12042: }
12043: public static StringBuilder fmtSB2u (StringBuilder sb, int x) {
12044: return sb.append (FMT_TEMP, 0, fmtCA2u (FMT_TEMP, 0, x));
12045: }
12046:
12047:
12048:
12049:
12050:
12051: public static int fmtCA04u (char[] a, int o, int x) {
12052: if (x < 0 || 9999 < x) {
12053: x = 9999;
12054: }
12055: x = FMT_BCD4[x];
12056: a[o ] = (char) ('0' | x >>> 12);
12057: a[o + 1] = (char) ('0' | x >>> 8 & 15);
12058: a[o + 2] = (char) ('0' | x >>> 4 & 15);
12059: a[o + 3] = (char) ('0' | x & 15);
12060: return o + 4;
12061: }
12062: public static StringBuilder fmtSB04u (StringBuilder sb, int x) {
12063: return sb.append (FMT_TEMP, 0, fmtCA04u (FMT_TEMP, 0, x));
12064: }
12065:
12066:
12067:
12068:
12069:
12070: public static int fmtCA4u (char[] a, int o, int x) {
12071: if (x < 0 || 9999 < x) {
12072: x = 9999;
12073: }
12074: x = FMT_BCD4[x];
12075: if (x <= 0x000f) {
12076: a[o++] = (char) ('0' | x);
12077: } else if (x <= 0x00ff) {
12078: a[o++] = (char) ('0' | x >>> 4);
12079: a[o++] = (char) ('0' | x & 15);
12080: } else if (x <= 0x0fff) {
12081: a[o++] = (char) ('0' | x >>> 8);
12082: a[o++] = (char) ('0' | x >>> 4 & 15);
12083: a[o++] = (char) ('0' | x & 15);
12084: } else {
12085: a[o++] = (char) ('0' | x >>> 12);
12086: a[o++] = (char) ('0' | x >>> 8 & 15);
12087: a[o++] = (char) ('0' | x >>> 4 & 15);
12088: a[o++] = (char) ('0' | x & 15);
12089: }
12090: return o;
12091: }
12092: public static StringBuilder fmtSB4u (StringBuilder sb, int x) {
12093: return sb.append (FMT_TEMP, 0, fmtCA4u (FMT_TEMP, 0, x));
12094: }
12095:
12096:
12097:
12098:
12099:
12100: public static int fmtCA08u (char[] a, int o, int x) {
12101: if (x < 0 || 99999999 < x) {
12102: x = 99999999;
12103: }
12104:
12105:
12106: int h = (int) ((long) x * 109951163L >>> 40);
12107: return fmtCA04u (a, fmtCA04u (a, o, h), x - h * 10000);
12108: }
12109: public static StringBuilder fmtSB08u (StringBuilder sb, int x) {
12110: return sb.append (FMT_TEMP, 0, fmtCA08u (FMT_TEMP, 0, x));
12111: }
12112:
12113:
12114:
12115:
12116:
12117: public static int fmtCA8u (char[] a, int o, int x) {
12118: if (x < 0 || 99999999 < x) {
12119: x = 99999999;
12120: }
12121: if (x <= 9999) {
12122: return fmtCA4u (a, o, x);
12123: } else {
12124:
12125:
12126: int h = (int) ((long) x * 109951163L >>> 40);
12127: return fmtCA04u (a, fmtCA4u (a, o, h), x - h * 10000);
12128: }
12129: }
12130: public static StringBuilder fmtSB8u (StringBuilder sb, int x) {
12131: return sb.append (FMT_TEMP, 0, fmtCA8u (FMT_TEMP, 0, x));
12132: }
12133:
12134:
12135:
12136:
12137:
12138: public static int fmtCAd (char[] a, int o, long x) {
12139: if (x < 0L) {
12140: x = -x;
12141: a[o++] = '-';
12142: }
12143: if (x <= 99999999L) {
12144: return fmtCA8u (a, o, (int) x);
12145: } else if (x <= 9999999999999999L) {
12146: long h = x / 100000000L;
12147: return fmtCA08u (a, fmtCA8u (a, o, (int) h), (int) (x - h * 100000000L));
12148: } else {
12149: long hh = x / 10000000000000000L;
12150: x -= hh * 10000000000000000L;
12151: long h = x / 100000000L;
12152: return fmtCA08u (a, fmtCA08u (a, fmtCA4u (a, o, (int) hh), (int) h), (int) (x - h * 100000000L));
12153: }
12154: }
12155: public static StringBuilder fmtSBd (StringBuilder sb, long x) {
12156: return sb.append (FMT_TEMP, 0, fmtCAd (FMT_TEMP, 0, x));
12157: }
12158:
12159:
12160:
12161:
12162:
12163:
12164: public static int fmtCAnd (char[] a, int o, int n, long x) {
12165: int t = fmtCAd (a, o, x);
12166: n += o;
12167: if (t < n) {
12168: int i = n;
12169: while (o < t) {
12170: a[--i] = a[--t];
12171: }
12172: while (o < i) {
12173: a[--i] = ' ';
12174: }
12175: t = n;
12176: }
12177: return t;
12178: }
12179: public static StringBuilder fmtSBnd (StringBuilder sb, int n, int x) {
12180: return sb.append (FMT_TEMP, 0, fmtCAnd (FMT_TEMP, 0, n, x));
12181: }
12182:
12183:
12184:
12185:
12186:
12187:
12188:
12189:
12190:
12191:
12192:
12193:
12194:
12195: public static int fmtParseInt (String s, int i, int min, int max, int err) {
12196: return fmtParseIntRadix (s, i, min, max, err, 10);
12197: }
12198: public static int fmtParseIntRadix (String s, int i, int min, int max, int err, int radix) {
12199: if (s == null) {
12200: return err;
12201: }
12202: int l = s.length ();
12203: int c = i < l ? s.charAt (i++) : -1;
12204:
12205: while (c == ' ' || c == '\t') {
12206: c = i < l ? s.charAt (i++) : -1;
12207: }
12208:
12209: int n = 0;
12210: if (c == '+') {
12211: c = i < l ? s.charAt (i++) : -1;
12212: } else if (c == '-') {
12213: n = 1;
12214: c = i < l ? s.charAt (i++) : -1;
12215: }
12216:
12217:
12218:
12219:
12220: int o;
12221: int p;
12222: if (c == '$') {
12223: o = 0x07ffffff + n;
12224: p = 15 + n & 15;
12225: radix = 16;
12226: c = i < l ? s.charAt (i++) : -1;
12227: } else if (radix == 16) {
12228: o = 0x07ffffff + n;
12229: p = 15 + n & 15;
12230: } else if (radix == 8) {
12231: o = 0x0fffffff + n;
12232: p = 7 + n & 7;
12233: } else if (radix == 2) {
12234: o = 0x3fffffff + n;
12235: p = 1 + n & 1;
12236: } else {
12237: o = 214748364;
12238: p = 7 + n;
12239: radix = 10;
12240: }
12241:
12242: int x = Character.digit (c, radix);
12243: if (x < 0) {
12244: return err;
12245: }
12246: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12247: while (c >= 0) {
12248: int t = x - o;
12249: if (t > 0 || t == 0 && c > p) {
12250: return err;
12251: }
12252: x = x * radix + c;
12253: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12254: }
12255: if (n != 0) {
12256: x = -x;
12257: }
12258: return min <= x && x <= max ? x : err;
12259: }
12260:
12261:
12262:
12263:
12264:
12265:
12266:
12267:
12268:
12269:
12270: public static long matMax3 (long x1, long x2, long x3) {
12271: return Math.max (Math.max (x1, x2), x3);
12272: }
12273: public static long matMax4 (long x1, long x2, long x3, long x4) {
12274: return Math.max (Math.max (x1, x2), Math.max (x3, x4));
12275: }
12276: public static long matMax5 (long x1, long x2, long x3, long x4, long x5) {
12277: return Math.max (Math.max (Math.max (x1, x2), Math.max (x3, x4)), x5);
12278: }
12279:
12280:
12281:
12282:
12283:
12284: public static long matMin3 (long x1, long x2, long x3) {
12285: return Math.min (Math.min (x1, x2), x3);
12286: }
12287: public static long matMin4 (long x1, long x2, long x3, long x4) {
12288: return Math.min (Math.min (x1, x2), Math.min (x3, x4));
12289: }
12290: public static long matMin5 (long x1, long x2, long x3, long x4, long x5) {
12291: return Math.min (Math.min (Math.min (x1, x2), Math.min (x3, x4)), x5);
12292: }
12293:
12294:
12295:
12296:
12297:
12298:
12299:
12300:
12301:
12302:
12303:
12304:
12305: public static String strEncodeUTF8 (String s) {
12306: StringBuilder sb = new StringBuilder ();
12307: int l = s.length ();
12308: for (int i = 0; i < l; i++) {
12309: int u = s.charAt (i);
12310: if (0xd800 <= u && u <= 0xdbff && i + 1 < l) {
12311: int v = s.charAt (i + 1);
12312: if (0xdc00 <= v && v <= 0xdfff) {
12313: u = 0x10000 + ((u & 0x3ff) << 10) + (v & 0x3ff);
12314: i++;
12315: }
12316: }
12317: if ((u & 0xffffff80) == 0) {
12318: sb.append ((char) u);
12319: } else if ((u & 0xfffff800) == 0) {
12320: u = (0x0000c080 |
12321: (u & 0x000007c0) << 2 |
12322: (u & 0x0000003f));
12323: sb.append ((char) (u >> 8)).append ((char) (u & 0xff));
12324: } else if ((u & 0xffff0000) == 0 && !(0xd800 <= u && u <= 0xdfff)) {
12325: u = (0x00e08080 |
12326: (u & 0x0000f000) << 4 |
12327: (u & 0x00000fc0) << 2 |
12328: (u & 0x0000003f));
12329: sb.append ((char) (u >> 16)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12330: } else if ((u & 0xffe00000) == 0) {
12331: u = (0xf0808080 |
12332: (u & 0x001c0000) << 6 |
12333: (u & 0x0003f000) << 4 |
12334: (u & 0x00000fc0) << 2 |
12335: (u & 0x0000003f));
12336: sb.append ((char) ((u >> 24) & 0xff)).append ((char) ((u >> 16) & 0xff)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12337: } else {
12338: sb.append ((char) 0xef).append ((char) 0xbf).append ((char) 0xbd);
12339: }
12340: }
12341: return sb.toString ();
12342: }
12343:
12344:
12345:
12346:
12347:
12348:
12349:
12350: public static String strDecodeUTF8 (String s) {
12351: StringBuilder sb = new StringBuilder ();
12352: int l = s.length ();
12353: for (int i = 0; i < l; i++) {
12354: int c = s.charAt (i) & 0xff;
12355: for (int k = ((c & 0x80) == 0x00 ? 0 :
12356: (c & 0xe0) == 0xc0 ? 1 :
12357: (c & 0xf0) == 0xe0 ? 2 :
12358: (c & 0xf8) == 0xf0 ? 3 :
12359: -1);
12360: --k >= 0; ) {
12361: c = c << 8 | (i + 1 < l ? s.charAt (++i) & 0xff : 0);
12362: }
12363: int u = ((c & 0xffffff80) == 0x00000000 ? c :
12364: (c & 0xffffe0c0) == 0x0000c080 ? ((c & 0x00001f00) >> 2 |
12365: (c & 0x0000003f)) :
12366: (c & 0xfff0c0c0) == 0x00e08080 ? ((c & 0x000f0000) >> 4 |
12367: (c & 0x00003f00) >> 2 |
12368: (c & 0x0000003f)) :
12369: (c & 0xf8c0c0c0) == 0xf0808080 ? ((c & 0x07000000) >> 6 |
12370: (c & 0x003f0000) >> 4 |
12371: (c & 0x00003f00) >> 2 |
12372: (c & 0x0000003f)) :
12373: 0xfffd);
12374: if (u <= 0x0000ffff) {
12375: sb.append (0xd800 <= u && u <= 0xdfff ? '\ufffd' :
12376: (char) u);
12377: } else if (u <= 0x0010ffff) {
12378: u -= 0x000010000;
12379: sb.append ((char) (0xd800 + ((u >> 10) & 0x3ff))).append ((char) (0xdc00 + (u & 0x3ff)));
12380: }
12381: }
12382: return sb.toString ();
12383: }
12384:
12385:
12386:
12387:
12388:
12389: public static final int[] IsURIChar = {
12390:
12391:
12392: 0b00000000_00000000_00000000_00000000,
12393: 0b00000000_00000110_11111111_11000000,
12394: 0b01111111_11111111_11111111_11100001,
12395: 0b01111111_11111111_11111111_11100010,
12396: };
12397: public static String strEncodeURI (String s) {
12398: s = strEncodeUTF8 (s);
12399: StringBuilder sb = new StringBuilder ();
12400: int l = s.length ();
12401: for (int i = 0; i < l; i++) {
12402: int c = s.charAt (i);
12403: if (c < 0x80 && IsURIChar[c >> 5] << c < 0) {
12404: sb.append ((char) c);
12405: } else {
12406: fmtHex2 (sb.append ('%'), c);
12407: }
12408: }
12409: return sb.toString ();
12410: }
12411:
12412:
12413:
12414:
12415:
12416: public static final byte[] strIsHexChar = {
12417:
12418: -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,
12419: -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,
12420: -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,
12421: -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,
12422: };
12423: public static String strDecodeURI (String s) {
12424: StringBuilder sb = new StringBuilder ();
12425: int l = s.length ();
12426: for (int i = 0; i < l; i++) {
12427: int c = s.charAt (i);
12428: if (c == '%' && i + 2 < l) {
12429: int d = s.charAt (i + 1);
12430: int e = s.charAt (i + 2);
12431: if (d < 0x80 && (d = strIsHexChar[d]) >= 0 &&
12432: e < 0x80 && (e = strIsHexChar[e]) >= 0) {
12433: sb.append ((char) (d << 4 | e));
12434: } else {
12435: sb.append ((char) c);
12436: }
12437: } else {
12438: sb.append ((char) c);
12439: }
12440: }
12441: return sb.toString ();
12442: }
12443:
12444:
12445:
12446:
12447:
12448:
12449:
12450:
12451: public static BufferedImage createImage (int width, int height, String pattern, int... rgbs) {
12452: BufferedImage image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
12453: int[] bitmap = ((DataBufferInt) image.getRaster ().getDataBuffer ()).getData ();
12454: int length = width * height;
12455: for (int i = 0; i < length; i++) {
12456: char c = pattern.charAt (i);
12457: bitmap[i] = rgbs[c < '0' ? 0 : Character.digit (c, 16)];
12458: }
12459: return image;
12460: }
12461:
12462:
12463:
12464: public static ImageIcon createImageIcon (int width, int height, String pattern, int... rgbs) {
12465: return new ImageIcon (createImage (width, height, pattern, rgbs));
12466: }
12467:
12468:
12469:
12470: public static TexturePaint createTexturePaint (int width, int height, String pattern, int... rgbs) {
12471: return new TexturePaint (createImage (width, height, pattern, rgbs), new Rectangle (0, 0, width, height));
12472: }
12473:
12474:
12475:
12476: public static BufferedImage loadImage (String name) {
12477: BufferedImage image = null;
12478: try {
12479: image = ImageIO.read (new File (name));
12480: } catch (Exception e) {
12481: }
12482: return image;
12483: }
12484:
12485:
12486:
12487:
12488: public static boolean saveImage (BufferedImage image, String name) {
12489: return saveImage (image, name, 0.75F);
12490: }
12491: public static boolean saveImage (BufferedImage image, String name, float quality) {
12492: int index = name.lastIndexOf (".");
12493: if (index < 0) {
12494: return false;
12495: }
12496: if (name.substring (index).equalsIgnoreCase (".ico")) {
12497: return saveIcon (name, image);
12498: }
12499: Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix (name.substring (index + 1));
12500: if (!iterator.hasNext ()) {
12501: return false;
12502: }
12503: ImageWriter imageWriter = iterator.next ();
12504: ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam ();
12505: if (imageWriteParam.canWriteCompressed ()) {
12506: imageWriteParam.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);
12507: imageWriteParam.setCompressionQuality (quality);
12508: }
12509: try {
12510: File file = new File (name);
12511: ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream (file);
12512: imageWriter.setOutput (imageOutputStream);
12513: imageWriter.write (null, new IIOImage (image, null, null), imageWriteParam);
12514: imageOutputStream.close ();
12515: } catch (Exception e) {
12516:
12517: return false;
12518: }
12519: return true;
12520: }
12521:
12522:
12523:
12524:
12525:
12526:
12527:
12528:
12529:
12530:
12531:
12532:
12533:
12534:
12535:
12536:
12537:
12538:
12539:
12540:
12541:
12542:
12543:
12544:
12545:
12546:
12547:
12548:
12549:
12550:
12551:
12552:
12553:
12554:
12555:
12556:
12557:
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: public static boolean saveIcon (String fileName, BufferedImage... arrayImage) {
12595: int iconCount = arrayImage.length;
12596: int[][] arrayPaletTable = new int[iconCount][];
12597: int[] arrayPaletCount = new int[iconCount];
12598: int[] arrayPixelBits = new int[iconCount];
12599: int[] arrayPatternLineSize = new int[iconCount];
12600: int[] arrayMaskLineSize = new int[iconCount];
12601: int[] arrayImageSize = new int[iconCount];
12602: int[] arrayImageOffset = new int[iconCount];
12603: int fileSize = 6 + 16 * iconCount;
12604: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
12605: BufferedImage image = arrayImage[iconNumber];
12606: int width = image.getWidth ();
12607: int height = image.getHeight ();
12608:
12609: int[] paletTable = new int[256];
12610: int paletCount = 0;
12611: countPalet:
12612: for (int y = height - 1; y >= 0; y--) {
12613: for (int x = 0; x < width; x++) {
12614: int rgb = image.getRGB (x, y);
12615: if (rgb >>> 24 != 0xff) {
12616: continue;
12617: }
12618: int l = 0;
12619: int r = paletCount;
12620: while (l < r) {
12621: int m = l + r >> 1;
12622: if (paletTable[m] < rgb) {
12623: l = m + 1;
12624: } else {
12625: r = m;
12626: }
12627: }
12628: if (l == paletCount || paletTable[l] != rgb) {
12629: if (paletCount == 256) {
12630: paletCount = 0;
12631: break countPalet;
12632: }
12633: for (int i = paletCount; i > l; i--) {
12634: paletTable[i] = paletTable[i - 1];
12635: }
12636: paletTable[l] = rgb;
12637: paletCount++;
12638: }
12639: }
12640: }
12641: int pixelBits = (paletCount == 0 ? 24 :
12642: paletCount > 16 ? 8 :
12643: paletCount > 4 ? 4 :
12644: paletCount > 2 ? 2 :
12645: 1);
12646: int patternLineSize = pixelBits * width + 31 >> 5 << 2;
12647: int maskLineSize = width + 31 >> 5 << 2;
12648: int imageSize = 40 + 4 * paletCount + patternLineSize * height + maskLineSize * height;
12649: arrayPaletTable[iconNumber] = paletTable;
12650: arrayPaletCount[iconNumber] = paletCount;
12651: arrayPixelBits[iconNumber] = pixelBits;
12652: arrayPatternLineSize[iconNumber] = patternLineSize;
12653: arrayMaskLineSize[iconNumber] = maskLineSize;
12654: arrayImageSize[iconNumber] = imageSize;
12655: arrayImageOffset[iconNumber] = fileSize;
12656: fileSize += imageSize;
12657: }
12658: byte[] bb = new byte[fileSize];
12659:
12660: ByteArray.byaWiw (bb, 0, 0);
12661: ByteArray.byaWiw (bb, 2, 1);
12662: ByteArray.byaWiw (bb, 4, iconCount);
12663: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
12664: BufferedImage image = arrayImage[iconNumber];
12665: int width = image.getWidth ();
12666: int height = image.getHeight ();
12667: int[] paletTable = arrayPaletTable[iconNumber];
12668: int paletCount = arrayPaletCount[iconNumber];
12669: int pixelBits = arrayPixelBits[iconNumber];
12670: int patternLineSize = arrayPatternLineSize[iconNumber];
12671: int maskLineSize = arrayMaskLineSize[iconNumber];
12672: int imageSize = arrayImageSize[iconNumber];
12673: int imageOffset = arrayImageOffset[iconNumber];
12674:
12675: int o = 6 + 16 * iconNumber;
12676: ByteArray.byaWb (bb, o, width);
12677: ByteArray.byaWb (bb, o + 1, height);
12678: ByteArray.byaWb (bb, o + 2, paletCount);
12679: ByteArray.byaWb (bb, o + 3, 0);
12680: ByteArray.byaWiw (bb, o + 4, 1);
12681: ByteArray.byaWiw (bb, o + 6, pixelBits);
12682: ByteArray.byaWil (bb, o + 8, imageSize);
12683: ByteArray.byaWil (bb, o + 12, imageOffset);
12684:
12685: o = imageOffset;
12686: ByteArray.byaWil (bb, o, 40);
12687: ByteArray.byaWil (bb, o + 4, width);
12688: ByteArray.byaWil (bb, o + 8, height * 2);
12689: ByteArray.byaWiw (bb, o + 12, 1);
12690: ByteArray.byaWiw (bb, o + 14, pixelBits);
12691: ByteArray.byaWil (bb, o + 16, 0);
12692: ByteArray.byaWil (bb, o + 20, 0);
12693: ByteArray.byaWil (bb, o + 24, 0);
12694: ByteArray.byaWil (bb, o + 28, 0);
12695: ByteArray.byaWil (bb, o + 32, paletCount);
12696: ByteArray.byaWil (bb, o + 36, 0);
12697:
12698: o += 40;
12699: for (int i = 0; i < paletCount; i++) {
12700: ByteArray.byaWil (bb, o, paletTable[i] & 0x00ffffff);
12701: o += 4;
12702: }
12703:
12704: for (int y = height - 1; y >= 0; y--) {
12705: for (int x = 0; x < width; x++) {
12706: int rgb = image.getRGB (x, y);
12707: if (rgb >>> 24 != 0xff) {
12708: continue;
12709: }
12710: if (pixelBits == 24) {
12711: bb[o + 3 * x] = (byte) rgb;
12712: bb[o + 3 * x + 1] = (byte) (rgb >> 8);
12713: bb[o + 3 * x + 2] = (byte) (rgb >> 16);
12714: continue;
12715: }
12716: int l = 0;
12717: int r = paletCount;
12718: while (l < r) {
12719: int m = l + r >> 1;
12720: if (paletTable[m] < rgb) {
12721: l = m + 1;
12722: } else {
12723: r = m;
12724: }
12725: }
12726: if (l != 0) {
12727: if (pixelBits == 8) {
12728: bb[o + x] = (byte) l;
12729: } else if (pixelBits == 4) {
12730: bb[o + (x >> 1)] |= (byte) (l << ((~x & 1) << 2));
12731: } else if (pixelBits == 2) {
12732: bb[o + (x >> 2)] |= (byte) (l << ((~x & 3) << 1));
12733: } else {
12734: bb[o + (x >> 3)] |= (byte) (l << (~x & 7));
12735: }
12736: }
12737: }
12738: o += patternLineSize;
12739: }
12740:
12741: for (int y = height - 1; y >= 0; y--) {
12742: for (int x = 0; x < width; x++) {
12743: int rgb = image.getRGB (x, y);
12744: if (rgb >>> 24 != 0xff) {
12745: bb[o + (x >> 3)] |= (byte) (1 << (~x & 7));
12746: }
12747: }
12748: o += maskLineSize;
12749: }
12750: }
12751: return rscPutFile (fileName, bb, 0, fileSize);
12752: }
12753:
12754:
12755:
12756: }
12757:
12758:
12759: