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: public static final String PRG_TITLE = "XEiJ (X68000 Emulator in Java)";
44: public static final String PRG_VERSION = "0.25.11.08";
45: public static final String PRG_AUTHOR = "Makoto Kamada";
46: public static final String PRG_WEBPAGE = "https://stdkmd.net/xeij/";
47:
48: public static final String PRG_JAVA_VENDOR = "Oracle Corporation";
49: public static final String PRG_JAVA_VERSION = "25.0.1";
50: public static final String PRG_OS_ARCH = "amd64";
51: public static final String PRG_OS_NAME = "Windows 11";
52:
53:
54:
55:
56:
57:
58:
59: public static final boolean TEST_BIT_0_SHIFT = false;
60: public static final boolean TEST_BIT_1_SHIFT = false;
61: public static final boolean TEST_BIT_2_SHIFT = true;
62: public static final boolean TEST_BIT_3_SHIFT = true;
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80: public static final boolean SHORT_SATURATION_CAST = false;
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92: public static final Charset ISO_8859_1 = Charset.forName ("ISO-8859-1");
93: static {
94: if (false) {
95:
96: StringBuilder sb = new StringBuilder ();
97: for (int i = 0; i < 256; i++) {
98: sb.append ((char) i);
99: }
100: byte[] bb = sb.toString ().getBytes (ISO_8859_1);
101: for (int i = 0; i < 256; i++) {
102: System.out.printf ("%02x %02x %s\n", i, bb[i] & 255, i == (bb[i] & 255) ? "OK" : "ERROR");
103: }
104: }
105: }
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118: public static String prgJavaVendor;
119: public static String prgJavaVersion;
120: public static String prgOsArch;
121: public static String prgOsName;
122: public static boolean prgIsLinux;
123: public static boolean prgIsMac;
124: public static boolean prgIsWindows;
125:
126: public static boolean prgCaseIgnored;
127:
128: public static boolean prgVerbose;
129:
130: public static String[] prgArgs;
131:
132:
133:
134: public static void main (String[] args) {
135:
136:
137:
138:
139: if (true) {
140: try {
141: String def = System.getProperty ("os.name").toLowerCase ().contains ("win") ? "C:\\Temp" : "/tmp";
142: Stream.of (new File (System.getProperty ("java.io.tmpdir", def),
143: "jSerialComm").getCanonicalFile ().toPath (),
144: new File (System.getProperty ("user.home", def),
145: ".jSerialComm").getCanonicalFile ().toPath ())
146: .filter (Files::exists)
147: .forEach (dir -> {
148: try {
149: Files.walk (dir)
150: .sorted (Comparator.reverseOrder ())
151: .forEach (path -> {
152: if (Files.exists (path)) {
153: try {
154: Files.delete (path);
155:
156: } catch (IOException ioe) {
157: System.err.println ("Failed to delete: " + path + " (" + ioe.getMessage () + ")");
158: }
159: }
160: });
161: } catch (IOException ioe) {
162: System.err.println ("Failed to walk: " + dir + " (" + ioe.getMessage () + ")");
163: }
164: });
165: } catch (IOException ioe) {
166: }
167: }
168:
169: prgArgs = args;
170:
171:
172: SwingUtilities.invokeLater (new Runnable () {
173: @Override public void run () {
174: new XEiJ ();
175: }
176: });
177:
178: }
179:
180:
181:
182: public XEiJ () {
183:
184: prgJavaVendor = System.getProperty ("java.vendor");
185: prgJavaVersion = System.getProperty ("java.version");
186: prgOsArch = System.getProperty ("os.arch");
187: prgOsName = System.getProperty ("os.name");
188: prgIsLinux = 0 <= prgOsName.indexOf ("Linux");
189: prgIsMac = 0 <= prgOsName.indexOf ("Mac");
190: prgIsWindows = 0 <= prgOsName.indexOf ("Windows");
191:
192: System.out.print ("\n" +
193: "-------------------------------------------------\n" +
194: PRG_TITLE + " version " + PRG_VERSION + "\n" +
195: "-------------------------------------------------\n");
196:
197:
198:
199:
200: prgCaseIgnored = new File ("A").equals (new File ("a"));
201: fmtInit ();
202: Multilingual.mlnInit ();
203:
204: System.out.println (Multilingual.mlnJapanese ? "java.vendor は " + prgJavaVendor + " です" :
205: "java.vendor is " + prgJavaVendor);
206: System.out.println (Multilingual.mlnJapanese ? "java.version は " + prgJavaVersion + " です" :
207: "java.version is " + prgJavaVersion);
208: System.out.println (Multilingual.mlnJapanese ? "os.arch は " + prgOsArch + " です" :
209: "os.arch is " + prgOsArch);
210: System.out.println (Multilingual.mlnJapanese ? "os.name は " + prgOsName + " です" :
211: "os.name is " + prgOsName);
212:
213: rbtInit ();
214:
215: Settings.sgsInit ();
216: LnF.lnfInit ();
217: Bubble.bblInit ();
218:
219: CharacterCode.chrInit ();
220:
221: TickerQueue.tkqInit ();
222:
223: RS232CTerminal.trmInit ();
224:
225: xt3Init ();
226: mdlInit ();
227:
228: if (InstructionBreakPoint.IBP_ON) {
229: InstructionBreakPoint.ibpInit ();
230: }
231: if (DataBreakPoint.DBP_ON) {
232: DataBreakPoint.dbpInit ();
233: }
234: busInit ();
235: MainMemory.mmrInit ();
236: ROM.romInit ();
237: CRTC.crtInit ();
238: VideoController.vcnInit ();
239: HD63450.dmaInit ();
240: svsInit ();
241: MC68901.mfpInit ();
242: RP5C15.rtcInit ();
243: sysInit ();
244: if (OPMLog.OLG_ON) {
245: OPMLog.olgInit ();
246: }
247: OPM.opmInit ();
248: ADPCM.pcmInit ();
249: FDC.fdcInit ();
250: HDC.hdcInit ();
251: if (HostCDROM.HCD_ENABLED) {
252: HostCDROM.hcdInit ();
253: }
254: SPC.spcInit ();
255: Z8530.sccInit ();
256: IOInterrupt.ioiInit ();
257: SpriteScreen.sprInit ();
258: bnkInit ();
259: SRAM.smrInit ();
260:
261: PPI.ppiInit ();
262: PrinterPort.prnInit ();
263: Indicator.indInit ();
264:
265: SlowdownTest.sdtInit ();
266: Keyboard.kbdInit ();
267: CONDevice.conInit ();
268: Mouse.musInit ();
269: pnlInit ();
270: frmInit ();
271:
272: dbgInit ();
273: RegisterList.drpInit ();
274: DisassembleList.ddpInit ();
275: MemoryDumpList.dmpInit ();
276: LogicalSpaceMonitor.atwInit ();
277: PhysicalSpaceMonitor.paaInit ();
278: DebugConsole.dgtInit ();
279: if (BranchLog.BLG_ON) {
280: BranchLog.blgInit ();
281: }
282: if (ProgramFlowVisualizer.PFV_ON) {
283: ProgramFlowVisualizer.pfvInit ();
284: }
285: if (RasterBreakPoint.RBP_ON) {
286: RasterBreakPoint.rbpInit ();
287: }
288: if (ScreenModeTest.SMT_ON) {
289: ScreenModeTest.smtInit ();
290: }
291: if (RootPointerList.RTL_ON) {
292: RootPointerList.rtlInit ();
293: }
294: if (SpritePatternViewer.SPV_ON) {
295: SpritePatternViewer.spvInit ();
296: }
297: if (ATCMonitor.ACM_ON) {
298: ATCMonitor.acmInit ();
299: }
300:
301: SoundSource.sndInit ();
302: FEFunction.fpkInit ();
303: mpuInit ();
304: MC68060.mmuInit ();
305: SoundMonitor.smnInit ();
306: HFS.hfsInit ();
307:
308: GIFAnimation.gifInit ();
309: TextCopy.txcInit ();
310: ButtonFunction.bfnInit ();
311:
312:
313:
314: Settings.sgsMakeMenu ();
315: mdlMakeMenu ();
316: FDC.fdcMakeMenu ();
317: HDC.hdcMakeMenu ();
318: SPC.spcMakeMenu ();
319: mpuMakeMenu ();
320: SRAM.smrMakeMenu ();
321: clpMake ();
322: pnlMake ();
323: mnbMakeMenu ();
324: frmMake ();
325: dbgMakePopup ();
326:
327:
328: final String flags = (
329: "" +
330: (EFPBox.CIR_DEBUG_TRACE ? " EFPBox.CIR_DEBUG_TRACE" : "") +
331: (FDC.FDC_DEBUG_TRACE ? " FDC.FDC_DEBUG_TRACE" : "") +
332: (FEFunction.FPK_DEBUG_TRACE ? " FEFunction.FPK_DEBUG_TRACE" : "") +
333: (HD63450.DMA_DEBUG_TRACE != 0 ? " HD63450.DMA_DEBUG_TRACE" : "") +
334: (HDC.HDC_DEBUG_TRACE ? " HDC.HDC_DEBUG_TRACE" : "") +
335: (HDC.HDC_DEBUG_COMMAND ? " HDC.HDC_DEBUG_COMMAND" : "") +
336: (HFS.HFS_DEBUG_TRACE ? " HFS.HFS_DEBUG_TRACE" : "") +
337: (HFS.HFS_DEBUG_FILE_INFO ? " HFS.HFS_DEBUG_FILE_INFO" : "") +
338: (HFS.HFS_COMMAND_TRACE ? " HFS.HFS_COMMAND_TRACE" : "") +
339: (HFS.HFS_BUFFER_TRACE ? " HFS.HFS_BUFFER_TRACE" : "") +
340: (IOInterrupt.IOI_DEBUG_TRACE ? " IOInterrupt.IOI_DEBUG_TRACE" : "") +
341: (Keyboard.KBD_DEBUG_LED ? " Keyboard.KBD_DEBUG_LED" : "") +
342: (MC68060.MMU_DEBUG_COMMAND ? " MC68060.MMU_DEBUG_COMMAND" : "") +
343: (MC68060.MMU_DEBUG_TRANSLATION ? " MC68060.MMU_DEBUG_TRANSLATION" : "") +
344: (MC68060.MMU_NOT_ALLOCATE_CACHE ? " MC68060.MMU_NOT_ALLOCATE_CACHE" : "") +
345: (RP5C15.RTC_DEBUG_TRACE ? " RP5C15.RTC_DEBUG_TRACE" : "") +
346: (SPC.SPC_DEBUG_ON ? " SPC.SPC_DEBUG_ON" : "") +
347: (Z8530.SCC_DEBUG_ON ? " Z8530.SCC_DEBUG_ON" : "")
348: );
349: if (!"".equals (flags)) {
350: pnlExitFullScreen (true);
351: JOptionPane.showMessageDialog (null, "debug flags:" + flags);
352: }
353:
354:
355:
356:
357: tmrStart ();
358:
359: Keyboard.kbdStart ();
360: Mouse.musStart ();
361: pnlStart ();
362: frmStart ();
363: SoundSource.sndStart ();
364:
365: if (DataBreakPoint.DBP_ON) {
366: DataBreakPoint.dbpStart ();
367: }
368: if (RasterBreakPoint.RBP_ON) {
369: RasterBreakPoint.rbpStart ();
370: }
371: if (ScreenModeTest.SMT_ON) {
372: ScreenModeTest.smtStart ();
373: }
374: if (OPMLog.OLG_ON) {
375: OPMLog.olgStart ();
376: }
377: SoundMonitor.smnStart ();
378: RS232CTerminal.trmStart ();
379: PPI.ppiStart ();
380: PrinterPort.prnStart ();
381: if (BranchLog.BLG_ON) {
382: BranchLog.blgStart ();
383: }
384: if (ProgramFlowVisualizer.PFV_ON) {
385: ProgramFlowVisualizer.pfvStart ();
386: }
387: RegisterList.drpStart ();
388: DisassembleList.ddpStart ();
389: MemoryDumpList.dmpStart ();
390: LogicalSpaceMonitor.atwStart ();
391: PhysicalSpaceMonitor.paaStart ();
392: DebugConsole.dgtStart ();
393: if (RootPointerList.RTL_ON) {
394: RootPointerList.rtlStart ();
395: }
396: if (SpritePatternViewer.SPV_ON) {
397: SpritePatternViewer.spvStart ();
398: }
399: if (ATCMonitor.ACM_ON) {
400: ATCMonitor.acmStart ();
401: }
402: ButtonFunction.bfnStart ();
403:
404: if (Settings.sgsSaveiconValue != null) {
405: String[] a = Settings.sgsSaveiconValue.split (",");
406: if (0 < a.length) {
407: saveIcon (a[0], LnF.LNF_ICON_IMAGES);
408: if (1 < a.length) {
409: saveImage (LnF.LNF_ICON_IMAGE_16, a[1]);
410: if (2 < a.length) {
411: saveImage (LnF.LNF_ICON_IMAGE_32, a[2]);
412: if (3 < a.length) {
413: saveImage (LnF.LNF_ICON_IMAGE_48, a[3]);
414: }
415: }
416: }
417: }
418: prgTini ();
419: return;
420: }
421:
422:
423: mpuReset (-1, -1);
424:
425: pnlBoot2 ();
426:
427: }
428:
429:
430:
431:
432:
433: public static void prgTini () {
434: try {
435: if (OPMLog.OLG_ON) {
436: OPMLog.olgTini ();
437: }
438: ButtonFunction.bfnTini ();
439: TextCopy.txcTini ();
440: GIFAnimation.gifTini ();
441: SoundSource.sndTini ();
442: Keyboard.kbdTini ();
443: Mouse.musTini ();
444: CONDevice.conTini ();
445: PPI.ppiTini ();
446: PrinterPort.prnTini ();
447: FDC.fdcTini ();
448: HDC.hdcTini ();
449: if (HostCDROM.HCD_ENABLED) {
450: HostCDROM.hcdTini ();
451: }
452: SPC.spcTini ();
453: HFS.hfsTini ();
454: Z8530.sccTini ();
455: CRTC.crtTini ();
456: SpriteScreen.sprTini ();
457: pnlTini ();
458: bnkTini ();
459: ROM.romTini ();
460: xt3Tini ();
461: mdlTini ();
462: SRAM.smrTini ();
463: tmrTini ();
464: busTini ();
465: RS232CTerminal.trmTini ();
466: LnF.lnfTini ();
467: Settings.sgsTini ();
468: } catch (Exception e) {
469: e.printStackTrace ();
470: }
471: System.exit (0);
472: }
473:
474:
475:
476: public static void prgOpenJavaDialog () {
477: pnlExitFullScreen (true);
478: JOptionPane.showMessageDialog (
479: frmFrame,
480: ComponentFactory.createGridPanel (
481: 3,
482: 6,
483: "paddingLeft=6,paddingRight=6",
484: "italic,right;left;left",
485: "italic,center;colSpan=3,widen",
486: "",
487:
488: null,
489: Multilingual.mlnJapanese ? "実行中" : "Running",
490: Multilingual.mlnJapanese ? "推奨" : "Recommended",
491:
492: ComponentFactory.createHorizontalSeparator (),
493:
494: Multilingual.mlnJapanese ? "Java のベンダー" : "Java Vendor",
495: prgJavaVendor,
496: PRG_JAVA_VENDOR,
497:
498: Multilingual.mlnJapanese ? "Java のバージョン" : "Java Version",
499: prgJavaVersion,
500: PRG_JAVA_VERSION,
501:
502: Multilingual.mlnJapanese ? "OS のアーキテクチャ" : "OS Architecture",
503: prgOsArch,
504: PRG_OS_ARCH,
505:
506: Multilingual.mlnJapanese ? "OS の名前" : "OS Name",
507: prgOsName,
508: PRG_OS_NAME
509: ),
510: Multilingual.mlnJapanese ? "Java 実行環境の情報" : "Java runtime environment information",
511: JOptionPane.PLAIN_MESSAGE);
512: }
513:
514:
515:
516: public static void prgOpenAboutDialog () {
517: pnlExitFullScreen (true);
518: JOptionPane.showMessageDialog (
519: frmFrame,
520: ComponentFactory.createGridPanel (
521: 2, 4, "paddingLeft=6,paddingRight=6", "italic,right;left", "", "",
522: Multilingual.mlnJapanese ? "タイトル" : "Title" ,
523: PRG_TITLE,
524: Multilingual.mlnJapanese ? "バージョン" : "Version",
525: PRG_VERSION,
526: Multilingual.mlnJapanese ? "作者" : "Author" ,
527: PRG_AUTHOR,
528: Multilingual.mlnJapanese ? "ウェブページ" : "Webpage",
529: PRG_WEBPAGE
530: ),
531: Multilingual.mlnJapanese ? "バージョン情報" : "Version information",
532: JOptionPane.PLAIN_MESSAGE);
533: }
534:
535:
536:
537: public static void prgOpenXEiJLicenseDialog () {
538: pnlExitFullScreen (true);
539: JOptionPane.showMessageDialog (
540: frmFrame,
541: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_XEiJ.txt"), 550, 300),
542: Multilingual.mlnJapanese ? "XEiJ 使用許諾条件" : "XEiJ License",
543: JOptionPane.PLAIN_MESSAGE);
544: }
545:
546:
547:
548: public static void prgOpenSHARPLicenseDialog () {
549: pnlExitFullScreen (true);
550: JOptionPane.showMessageDialog (
551: frmFrame,
552: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_FSHARP.txt", "Shift_JIS"), 550, 300),
553: Multilingual.mlnJapanese ? "無償公開された X68000 の基本ソフトウェア製品の許諾条件" : "License of the basic software products for X68000 that were distributed free of charge",
554: JOptionPane.PLAIN_MESSAGE);
555: }
556:
557:
558:
559: public static void prgOpenYmfmLicenseDialog () {
560: pnlExitFullScreen (true);
561: JOptionPane.showMessageDialog (
562: frmFrame,
563: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_ymfm.txt"), 550, 300),
564: "ymfm License",
565: JOptionPane.PLAIN_MESSAGE);
566: }
567:
568:
569:
570: public static void prgOpenJSerialCommLicenseDialog () {
571: pnlExitFullScreen (true);
572: JOptionPane.showMessageDialog (
573: frmFrame,
574: ComponentFactory.createVerticalSplitPane (
575: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-APACHE-2.0"), 550, 300),
576: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-LGPL-3.0"), 550, 300)
577: ),
578: "jSerialComm License",
579: JOptionPane.PLAIN_MESSAGE);
580: }
581:
582:
583:
584: public static void prgPrintClass (Object o) {
585: System.out.println (o.toString ());
586:
587: try {
588: Stack<Class<?>> s = new Stack<Class<?>> ();
589: for (Class<?> c = o.getClass (); c != null; c = c.getSuperclass ()) {
590: s.push (c);
591: }
592: for (int i = 0; !s.empty (); i++) {
593: for (int j = 0; j < i; j++) {
594: System.out.print (" ");
595: }
596: System.out.println (s.pop ().getName ());
597: }
598: } catch (Exception e) {
599: }
600: }
601:
602:
603:
604:
605: public static void prgPrintStackTrace () {
606: Exception e = new Exception ();
607: e.fillInStackTrace ();
608: prgPrintStackTraceOf (e);
609: }
610: public static void prgPrintStackTraceOf (Exception e) {
611:
612: System.out.println ("------------------------------------------------");
613: System.out.println (e.toString ());
614: System.out.println ("\t" + e.getMessage ());
615: for (StackTraceElement ste : e.getStackTrace ()) {
616: System.out.println ("\tat " + ste.toString ());
617: }
618: System.out.println ("------------------------------------------------");
619: }
620:
621:
622:
623:
624: public static boolean prgStopDone = false;
625: public static void prgStopOnce () {
626: if (!prgStopDone) {
627: prgStopDone = true;
628: mpuStop (null);
629: }
630: }
631:
632:
633:
634:
635:
636:
637:
638:
639:
640:
641:
642:
643:
644:
645:
646:
647:
648:
649:
650:
651:
652:
653:
654:
655:
656:
657:
658:
659:
660:
661:
662: public static final long TMR_FREQ = 1000000000000L;
663:
664:
665: public static final long TMR_DELAY = 10L;
666: public static final long TMR_INTERVAL = 10L;
667:
668:
669: public static java.util.Timer tmrTimer;
670:
671:
672:
673: public static void tmrStart () {
674: tmrTimer = new java.util.Timer ();
675: }
676:
677:
678:
679: public static void tmrTini () {
680: if (tmrTimer != null) {
681: tmrTimer.cancel ();
682: }
683: }
684:
685:
686:
687:
688:
689:
690:
691:
692:
693:
694:
695:
696:
697:
698:
699:
700:
701:
702:
703:
704:
705:
706:
707:
708:
709:
710:
711:
712:
713:
714:
715:
716:
717:
718:
719: public static final int PNL_BM_OFFSET_BITS = 10;
720: public static final int PNL_BM_WIDTH = 1 << PNL_BM_OFFSET_BITS;
721: public static final int PNL_BM_HEIGHT = 1024;
722:
723:
724: public static final int PNL_ASPECT_KEYS = 4;
725: public static final int PNL_ASPECT_VALUES = 4;
726: public static final int[] PNL_ASPECT_DEFAULT_VALUE = { 0, 0, 0, 3 };
727: public static final String[] PNL_ASPECT_RESOLUTION_NAME = { "256x256", "384x256", "512x512", "768x512" };
728: public static final String[] PNL_ASPECT_SCREEN_NAME = { "4:3", "7:5", "13:9", "3:2" };
729: public static final String[] PNL_ASPECT_PIXEL_NAME = { "8:9", "14:15", "26:27", "1:1" };
730: public static final float[] PNL_ASPECT_SCREEN_RATIO = { 4.0F / 3.0F, 7.0F / 5.0F, 13.0F / 9.0F, 3.0F / 2.0F };
731: public static final float[] PNL_ASPECT_PIXEL_RATIO = { 8.0F / 9.0F, 14.0F / 15.0F, 26.0F / 27.0F, 1.0F / 1.0F };
732: public static final float[][] PNL_ASPECT_MATRIX = {
733: PNL_ASPECT_SCREEN_RATIO,
734: PNL_ASPECT_PIXEL_RATIO,
735: PNL_ASPECT_SCREEN_RATIO,
736: PNL_ASPECT_PIXEL_RATIO,
737: };
738: public static int[] pnlAspectMap;
739: public static float[] pnlAspectTable;
740:
741:
742: public static final int PNL_MIN_WIDTH = 64;
743: public static final int PNL_MIN_HEIGHT = 64;
744: public static int pnlScreenWidth;
745: public static int pnlScreenHeight;
746: public static float pnlStretchMode;
747: public static int pnlStretchWidth;
748:
749: public static boolean PNL_ROTATION_ON = true;
750: public static int pnlRotationMode;
751: public static AffineTransform pnlRotationTransformLeft;
752: public static AffineTransform pnlRotationTransformRight;
753: public static double pnlMatrixL00, pnlMatrixL10, pnlMatrixL01, pnlMatrixL11, pnlMatrixL02, pnlMatrixL12;
754: public static double pnlMatrixR00, pnlMatrixR10, pnlMatrixR01, pnlMatrixR11, pnlMatrixR02, pnlMatrixR12;
755: public static double pnlInverseL00, pnlInverseL10, pnlInverseL01, pnlInverseL11, pnlInverseL02, pnlInverseL12;
756: public static double pnlInverseR00, pnlInverseR10, pnlInverseR01, pnlInverseR11, pnlInverseR02, pnlInverseR12;
757: public static int pnlRotatedWidth;
758: public static int pnlRotatedHeight;
759:
760: public static int pnlZoomWidth;
761: public static int pnlZoomHeight;
762: public static int pnlZoomRatioOutX;
763: public static int pnlZoomRatioOutY;
764: public static int pnlZoomRatioInX;
765: public static int pnlZoomRatioInY;
766: public static int pnlWidth;
767: public static int pnlHeight;
768: public static Dimension pnlSize;
769: public static int pnlScreenX1;
770: public static int pnlScreenX2;
771: public static int pnlScreenX3;
772: public static int pnlScreenX4;
773: public static int pnlScreenY1;
774: public static int pnlScreenY2;
775: public static int pnlScreenY3;
776: public static int pnlScreenY4;
777: public static int pnlKeyboardX;
778: public static int pnlKeyboardY;
779: public static int pnlMinimumWidth;
780: public static int pnlMinimumHeight;
781: public static int pnlGlobalX;
782: public static int pnlGlobalY;
783:
784:
785: public static final boolean PNL_FILL_BACKGROUND = true;
786: public static boolean pnlFillBackgroundRequest;
787: public static boolean pnlIsFullScreenSupported;
788: public static boolean pnlPrevKeyboardOn;
789: public static boolean pnlHideKeyboard;
790:
791:
792:
793:
794:
795: public static Object pnlInterpolation;
796:
797:
798: public static final double PNL_MIN_RATE = 1.0;
799: public static final double PNL_MAX_RATE = 1000.0;
800: public static final double PNL_DEFAULT_RATE = 59.94;
801: public static double pnlRefreshRate;
802: public static double pnlFixedRate;
803: public static boolean pnlAdjustVsync;
804:
805:
806:
807:
808:
809:
810:
811:
812:
813:
814:
815:
816:
817:
818:
819:
820:
821:
822:
823:
824:
825:
826:
827:
828:
829:
830:
831:
832:
833:
834:
835:
836:
837:
838:
839:
840:
841:
842:
843:
844:
845:
846:
847:
848:
849:
850:
851:
852:
853: public static final boolean PNL_STEREOSCOPIC_ON = true;
854:
855: public static final boolean PNL_USE_THREAD = true;
856:
857: public static BufferedImage[] pnlScreenImageLeftArray;
858: public static BufferedImage[] pnlScreenImageRightArray;
859:
860: public static BufferedImage[] pnlScreenSubImageLeftArray;
861: public static BufferedImage[] pnlScreenSubImageRightArray;
862:
863: public static int[][] pnlBMLeftArray;
864: public static int[][] pnlBMRightArray;
865: public static volatile int pnlBMWrite;
866: public static volatile int pnlBMRead;
867:
868: public static BufferedImage pnlScreenImageLeft;
869: public static BufferedImage pnlScreenImageRight;
870:
871: public static BufferedImage pnlScreenSubImageLeft;
872: public static BufferedImage pnlScreenSubImageRight;
873:
874: public static int[] pnlBMLeft;
875: public static int[] pnlBMRight;
876:
877: public static int[] pnlBM;
878: public static boolean pnlStereoscopicOn;
879: public static final int PNL_NAKED_EYE_CROSSING = 0;
880: public static final int PNL_NAKED_EYE_PARALLEL = 1;
881: public static final int PNL_SIDE_BY_SIDE = 2;
882: public static final int PNL_TOP_AND_BOTTOM = 3;
883: public static int pnlStereoscopicMethod;
884: public static int pnlStereoscopicFactor;
885: public static int pnlStereoscopicShutter;
886:
887:
888: public static JPanel pnlPanel;
889:
890: public static Thread pnlThread;
891: public static long pnlWakeupTime;
892: public static long pnlWakeupTimeMNP;
893: public static final boolean PNL_USE_CANVAS = PNL_USE_THREAD && true;
894:
895: public static boolean pnlUseCanvasRequest;
896: public static boolean pnlUseCanvas;
897: public static Canvas pnlCanvas;
898: public static Component pnlCanvasOrPanel;
899:
900:
901:
902:
903: public static int pnlFixedScale;
904: public static SpinnerNumberModel pnlFixedModel;
905: public static JSpinner pnlFixedSpinner;
906:
907:
908:
909: public static void pnlInit () {
910: pnlInit2 ();
911:
912:
913:
914:
915: pnlFixedScale = Math.max (10, Math.min (1000, Settings.sgsGetInt ("fixedscale")));
916:
917:
918: pnlAspectMap = new int[PNL_ASPECT_KEYS];
919: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
920: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[key];
921: String screenName = Settings.sgsGetString ("aspectratio" + resolutionName);
922: int value = PNL_ASPECT_DEFAULT_VALUE[key];
923: for (int tempValue = 0; tempValue < PNL_ASPECT_VALUES; tempValue++) {
924: if (PNL_ASPECT_SCREEN_NAME[tempValue].equals (screenName)) {
925: value = tempValue;
926: break;
927: }
928: }
929: pnlAspectMap[key] = value;
930: }
931: pnlAspectTable = new float[8];
932: pnlUpdateAspectTable ();
933:
934:
935: switch (Settings.sgsGetString ("interpolation").toLowerCase ()) {
936: case "nearest":
937: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
938: break;
939: case "bilinear":
940: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
941: break;
942: case "bicubic":
943: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
944: break;
945: default:
946: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
947: }
948:
949:
950: pnlRefreshRate = 0.0;
951: {
952: String s = Settings.sgsGetString ("refreshrate");
953: if (!s.equals ("")) {
954: try {
955: double rate = Double.parseDouble (s);
956: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
957: pnlRefreshRate = rate;
958: }
959: } catch (NumberFormatException nfe) {
960: }
961: }
962: }
963: pnlFixedRate = pnlRefreshRate;
964: pnlAdjustVsync = Settings.sgsGetOnOff ("adjustvsync");
965:
966: pnlPrevKeyboardOn = true;
967:
968: pnlHideKeyboard = Settings.sgsGetOnOff ("hidekeyboard");
969:
970:
971: if (PNL_USE_THREAD) {
972: pnlScreenImageLeftArray = new BufferedImage[4];
973: pnlScreenImageRightArray = new BufferedImage[4];
974: if (PNL_ROTATION_ON) {
975: pnlScreenSubImageLeftArray = new BufferedImage[4];
976: pnlScreenSubImageRightArray = new BufferedImage[4];
977: }
978: pnlBMLeftArray = new int[4][];
979: pnlBMRightArray = new int[4][];
980: for (int n = 0; n < 4; n++) {
981: pnlScreenImageLeftArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
982: pnlScreenImageRightArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
983: if (PNL_ROTATION_ON) {
984: pnlScreenSubImageLeftArray[n] = null;
985: pnlScreenSubImageRightArray[n] = null;
986: }
987: pnlBMLeftArray[n] = ((DataBufferInt) pnlScreenImageLeftArray[n].getRaster ().getDataBuffer ()).getData ();
988: pnlBMRightArray[n] = ((DataBufferInt) pnlScreenImageRightArray[n].getRaster ().getDataBuffer ()).getData ();
989: }
990: pnlBMWrite = 0;
991: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
992: pnlBMRead = 0;
993: pnlThread = null;
994: pnlWakeupTime = 0L;
995: pnlWakeupTimeMNP = 0L;
996: if (PNL_USE_CANVAS) {
997: pnlUseCanvasRequest = Settings.sgsGetOnOff ("usecanvas");
998: pnlUseCanvas = pnlUseCanvasRequest;
999: pnlCanvas = null;
1000: }
1001: } else {
1002: pnlScreenImageLeft = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1003: pnlScreenImageRight = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1004: if (PNL_ROTATION_ON) {
1005: pnlScreenSubImageLeft = null;
1006: pnlScreenSubImageRight = null;
1007: }
1008: pnlBMLeft = ((DataBufferInt) pnlScreenImageLeft.getRaster ().getDataBuffer ()).getData ();
1009: pnlBMRight = ((DataBufferInt) pnlScreenImageRight.getRaster ().getDataBuffer ()).getData ();
1010: pnlBM = pnlBMLeft;
1011: }
1012: pnlStereoscopicOn = Settings.sgsGetOnOff ("stereoscopic");
1013: switch (Settings.sgsGetString ("stereoscopicmethod").toLowerCase ()) {
1014: case "nakedeyecrossing":
1015: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
1016: break;
1017: case "nakedeyeparallel":
1018: pnlStereoscopicMethod = PNL_NAKED_EYE_PARALLEL;
1019: break;
1020: case "sidebyside":
1021: pnlStereoscopicMethod = PNL_SIDE_BY_SIDE;
1022: break;
1023: case "topandbottom":
1024: pnlStereoscopicMethod = PNL_TOP_AND_BOTTOM;
1025: break;
1026: default:
1027: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
1028: }
1029: pnlStereoscopicFactor = pnlStereoscopicOn && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1030: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1031: pnlStereoscopicShutter = 0;
1032:
1033:
1034: pnlScreenWidth = 768;
1035: pnlScreenHeight = 512;
1036: pnlStretchMode = 1.0F;
1037: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchMode);
1038:
1039: if (PNL_ROTATION_ON) {
1040: pnlRotationMode = Settings.sgsGetInt ("rotation", 0);
1041: if (pnlRotationMode < 0 || 3 < pnlRotationMode) {
1042: pnlRotationMode = 0;
1043: }
1044: pnlRotationTransformLeft = new AffineTransform ();
1045: pnlRotationTransformRight = new AffineTransform ();
1046: }
1047: pnlRotatedWidth = pnlStretchWidth;
1048: pnlRotatedHeight = pnlScreenHeight;
1049: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1050: pnlRotatedWidth = pnlScreenHeight;
1051: pnlRotatedHeight = pnlStretchWidth;
1052: }
1053:
1054: pnlZoomWidth = pnlRotatedWidth;
1055: pnlZoomHeight = pnlRotatedHeight;
1056: pnlWidth = Math.max (pnlZoomWidth * pnlStereoscopicFactor, Keyboard.kbdWidth);
1057: pnlHeight = pnlZoomHeight + Keyboard.kbdHeight;
1058: pnlSize = new Dimension (pnlWidth, pnlHeight);
1059: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1060: pnlScreenY1 = 0;
1061: pnlArrangementCommon ();
1062: pnlMinimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
1063: pnlMinimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
1064: pnlGlobalX = 0;
1065: pnlGlobalY = 0;
1066:
1067:
1068: if (!PNL_FILL_BACKGROUND) {
1069: pnlFillBackgroundRequest = true;
1070: }
1071:
1072:
1073: pnlFixedModel = new SpinnerNumberModel (pnlFixedScale, 10, 1000, 1);
1074: pnlFixedSpinner = ComponentFactory.createNumberSpinner (pnlFixedModel, 4, new ChangeListener () {
1075: @Override public void stateChanged (ChangeEvent ce) {
1076: if (pnlMode != PNL_FIXEDSCALE) {
1077: pnlSetMode (PNL_FIXEDSCALE);
1078: } else {
1079: pnlUpdateArrangement ();
1080: }
1081: }
1082: });
1083:
1084: }
1085:
1086:
1087:
1088: public static double pnlGetRefreshRate () {
1089: double rate = 0.0;
1090: GraphicsConfiguration gc = frmFrame.getGraphicsConfiguration ();
1091: if (gc != null) {
1092: GraphicsDevice gd = gc.getDevice ();
1093: DisplayMode dm = gd.getDisplayMode ();
1094: int i = dm.getRefreshRate ();
1095: if (i != DisplayMode.REFRESH_RATE_UNKNOWN) {
1096: rate = (i == 23 ? 23.98 :
1097: i == 29 ? 29.97 :
1098: i == 59 ? 59.94 :
1099: i == 119 ? 119.88 :
1100: i == 239 ? 239.76 :
1101: (double) i);
1102: if (rate < PNL_MIN_RATE || PNL_MAX_RATE < rate) {
1103: rate = 0.0;
1104: }
1105: }
1106: }
1107: if (rate == 0.0) {
1108: rate = PNL_DEFAULT_RATE;
1109: System.out.printf (Multilingual.mlnJapanese ?
1110: "ホストのリフレッシュレートを取得できません。デフォルトの %.2f Hz を使います\n" :
1111: "Cannot get host refresh rate. Use default %.2f Hz\n", rate);
1112: } else {
1113: System.out.printf (Multilingual.mlnJapanese ?
1114: "ホストのリフレッシュレートは %.2f Hz です\n" :
1115: "Host refresh rate is %.2f Hz\n", rate);
1116: }
1117: return rate;
1118: }
1119:
1120:
1121: public static void pnlSetStereoscopic (boolean on, int method) {
1122: if (pnlStereoscopicOn != on || pnlStereoscopicMethod != method) {
1123: pnlStereoscopicMethod = method;
1124: pnlStereoscopicFactor = on && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1125: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1126: if (!pnlStereoscopicOn && on) {
1127: if (PNL_USE_THREAD) {
1128: for (int n = 0; n < 4; n++) {
1129: System.arraycopy (pnlBMLeftArray[n], 0, pnlBMRightArray[n], 0, 1024 * 1024);
1130: }
1131: } else {
1132: System.arraycopy (pnlBMLeft, 0, pnlBMRight, 0, 1024 * 1024);
1133: }
1134: } else if (pnlStereoscopicOn && !on) {
1135: if (PNL_USE_THREAD) {
1136: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
1137: } else {
1138: pnlBM = pnlBMLeft;
1139: }
1140: }
1141: pnlStereoscopicOn = on;
1142: pnlUpdateArrangement ();
1143: }
1144: }
1145:
1146:
1147: public static void pnlTini () {
1148: pnlTini2 ();
1149: if (PNL_USE_THREAD) {
1150: if (pnlThread != null) {
1151: pnlThread.interrupt ();
1152: try {
1153: pnlThread.join ();
1154: } catch (InterruptedException ie) {
1155: }
1156: pnlThread = null;
1157: }
1158: }
1159:
1160:
1161: Settings.sgsPutInt ("fixedscale", pnlFixedScale);
1162:
1163:
1164: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
1165: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[key];
1166: int value = pnlAspectMap[key];
1167: String screenName = PNL_ASPECT_SCREEN_NAME[value];
1168: Settings.sgsPutString ("aspectratio" + resolutionName, screenName);
1169: }
1170:
1171:
1172: Settings.sgsPutString ("interpolation",
1173: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR ? "nearest" :
1174: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR ? "bilinear" :
1175: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC ? "bicubic" :
1176: "bilinear");
1177:
1178: if (pnlRefreshRate != PNL_DEFAULT_RATE) {
1179: Settings.sgsPutString ("refreshrate",
1180: pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate));
1181: }
1182: Settings.sgsPutOnOff ("adjustvsync", pnlAdjustVsync);
1183:
1184: Settings.sgsPutOnOff ("hidekeyboard", pnlHideKeyboard);
1185:
1186: if (PNL_USE_CANVAS) {
1187: Settings.sgsPutOnOff ("usecanvas", pnlUseCanvasRequest);
1188: }
1189:
1190:
1191: Settings.sgsPutOnOff ("stereoscopic", pnlStereoscopicOn);
1192: Settings.sgsPutString ("stereoscopicmethod",
1193: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ? "nakedeyecrossing" :
1194: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL ? "nakedeyeparallel" :
1195: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ? "sidebyside" :
1196: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM ? "topandbottom" :
1197: "nakedeyecrossing");
1198:
1199:
1200: if (PNL_ROTATION_ON) {
1201: Settings.sgsPutInt ("rotation", pnlRotationMode);
1202: }
1203:
1204: }
1205:
1206:
1207:
1208: public static void pnlUpdateAspectTable () {
1209: float[] ratio = new float[PNL_ASPECT_KEYS];
1210: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
1211: int value = pnlAspectMap[key];
1212: ratio[key] = PNL_ASPECT_MATRIX[key][value];
1213: }
1214: pnlAspectTable[0] = ratio[0] * 2.0F;
1215: pnlAspectTable[1] = ratio[2];
1216: pnlAspectTable[2] = ratio[3];
1217: pnlAspectTable[3] = ratio[3];
1218: pnlAspectTable[4] = ratio[1] * 4.0F;
1219: pnlAspectTable[5] = ratio[1] * 2.0F;
1220: pnlAspectTable[6] = ratio[3];
1221: pnlAspectTable[7] = ratio[3];
1222: }
1223:
1224:
1225:
1226: public static void pnlMake () {
1227: pnlMake2 ();
1228:
1229:
1230: if (PNL_USE_CANVAS && pnlUseCanvas) {
1231: pnlCanvas = new Canvas ();
1232: pnlPanel = new JPanel (new BorderLayout (0, 0));
1233: pnlPanel.add (pnlCanvas, BorderLayout.CENTER);
1234: pnlCanvasOrPanel = pnlCanvas;
1235: } else {
1236: pnlPanel = new JPanel () {
1237: @Override protected void paintComponent (Graphics g) {
1238: pnlPaintCommon (g);
1239: }
1240: @Override protected void paintBorder (Graphics g) {
1241: }
1242: @Override protected void paintChildren (Graphics g) {
1243: }
1244: };
1245: pnlCanvasOrPanel = pnlPanel;
1246: }
1247: pnlPanel.setBackground (Color.black);
1248: pnlPanel.setOpaque (true);
1249: pnlPanel.setPreferredSize (pnlSize);
1250:
1251: if (Mouse.musCursorAvailable) {
1252: pnlPanel.setCursor (Mouse.musCursorArray[1]);
1253: }
1254:
1255: }
1256:
1257:
1258:
1259: public static void pnlPaintCommon (Graphics g) {
1260: Graphics2D g2 = (Graphics2D) g;
1261: if (PNL_FILL_BACKGROUND || pnlFillBackgroundRequest) {
1262: if (!PNL_FILL_BACKGROUND) {
1263: pnlFillBackgroundRequest = false;
1264: }
1265: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1266: g2.setColor (Color.black);
1267: g2.fillRect (0, 0, pnlWidth, pnlHeight);
1268: }
1269: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, pnlInterpolation);
1270: if (PNL_USE_THREAD) {
1271: int d = pnlBMWrite - pnlBMRead;
1272: if (false) {
1273: System.out.print (d);
1274: }
1275: if (d < 1) {
1276: pnlBMRead += d - 1;
1277: } else if (3 < d) {
1278: pnlBMRead += d - 3;
1279: }
1280: int n = pnlBMRead++ & 3;
1281: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1282: BufferedImage leftImage;
1283: BufferedImage rightImage;
1284: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1285: leftImage = pnlScreenImageRightArray[n];
1286: rightImage = pnlScreenImageLeftArray[n];
1287: } else {
1288:
1289:
1290:
1291: leftImage = pnlScreenImageLeftArray[n];
1292: rightImage = pnlScreenImageRightArray[n];
1293: }
1294: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1295: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1296: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1297: } else {
1298: g2.drawImage (leftImage,
1299: pnlScreenX1, pnlScreenY1,
1300: pnlScreenX2, pnlScreenY2,
1301: 0, 0, pnlScreenWidth, pnlScreenHeight,
1302: null);
1303: g2.drawImage (rightImage,
1304: pnlScreenX3, pnlScreenY3,
1305: pnlScreenX4, pnlScreenY4,
1306: 0, 0, pnlScreenWidth, pnlScreenHeight,
1307: null);
1308: }
1309: } else {
1310: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1311: g2.drawImage (pnlScreenSubImageLeftArray[n], pnlRotationTransformLeft, null);
1312: } else {
1313: g2.drawImage (pnlScreenImageLeftArray[n],
1314: pnlScreenX1, pnlScreenY1,
1315: pnlScreenX2, pnlScreenY2,
1316: 0, 0, pnlScreenWidth, pnlScreenHeight,
1317: null);
1318: }
1319: }
1320: } else {
1321: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1322: BufferedImage leftImage;
1323: BufferedImage rightImage;
1324: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1325: leftImage = pnlScreenImageRight;
1326: rightImage = pnlScreenImageLeft;
1327: } else {
1328:
1329:
1330:
1331: leftImage = pnlScreenImageLeft;
1332: rightImage = pnlScreenImageRight;
1333: }
1334: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1335: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1336: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1337: } else {
1338: g2.drawImage (leftImage,
1339: pnlScreenX1, pnlScreenY1,
1340: pnlScreenX2, pnlScreenY2,
1341: 0, 0, pnlScreenWidth, pnlScreenHeight,
1342: null);
1343: g2.drawImage (rightImage,
1344: pnlScreenX3, pnlScreenY3,
1345: pnlScreenX4, pnlScreenY4,
1346: 0, 0, pnlScreenWidth, pnlScreenHeight,
1347: null);
1348: }
1349: } else {
1350: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1351: g2.drawImage (pnlScreenImageLeft, pnlRotationTransformLeft, null);
1352: } else {
1353: g2.drawImage (pnlScreenImageLeft,
1354: pnlScreenX1, pnlScreenY1,
1355: pnlScreenX2, pnlScreenY2,
1356: 0, 0, pnlScreenWidth, pnlScreenHeight,
1357: null);
1358: }
1359: }
1360: }
1361: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1362: g2.drawImage (Keyboard.kbdImage, pnlKeyboardX, pnlKeyboardY, null);
1363:
1364: if (TextCopy.txcEncloseEachTime && 0 <= TextCopy.txcRow1) {
1365: int x = TextCopy.txcCol1 << 3;
1366: int w = (TextCopy.txcCol2 - TextCopy.txcCol1 + 1) << 3;
1367: int y = TextCopy.txcRow1 << 4;
1368: int h = (TextCopy.txcRow2 - TextCopy.txcRow1 + 1) << 4;
1369: x -= CRTC.crtR10TxXCurr;
1370: y -= CRTC.crtR11TxYCurr;
1371: g2.setColor (Color.red);
1372: if (PNL_ROTATION_ON) {
1373: AffineTransform savedTransform = g2.getTransform ();
1374: g2.setTransform (pnlRotationTransformLeft);
1375: g2.drawRect (x, y, w, h);
1376: g2.setTransform (savedTransform);
1377: } else {
1378: g2.drawRect (pnlScreenX1 + ((x * pnlZoomRatioOutX) >> 16),
1379: pnlScreenY1 + ((y * pnlZoomRatioOutY) >> 16),
1380: ((w * pnlZoomRatioOutX) >> 16) - 1,
1381: ((h * pnlZoomRatioOutY) >> 16) - 1);
1382: }
1383: }
1384: if (Bubble.BBL_ON) {
1385: Bubble.bblDraw (g2);
1386: }
1387: }
1388:
1389:
1390:
1391:
1392: public static void pnlStart () {
1393: pnlStart2 ();
1394:
1395:
1396: ComponentFactory.addListener (
1397: pnlPanel,
1398: new ComponentAdapter () {
1399: @Override public void componentResized (ComponentEvent ce) {
1400: pnlUpdateArrangement ();
1401: }
1402: });
1403:
1404: if (PNL_USE_THREAD) {
1405: if (PNL_USE_CANVAS && pnlUseCanvas) {
1406: pnlCanvas.createBufferStrategy (2);
1407: pnlThread = new Thread () {
1408: @Override public void run () {
1409: do {
1410: BufferStrategy bs = pnlCanvas.getBufferStrategy ();
1411: if (bs != null) {
1412: Graphics g = bs.getDrawGraphics ();
1413: pnlPaintCommon (g);
1414: g.dispose ();
1415: bs.show ();
1416: }
1417: } while (!isInterrupted () && pnlWakeupCommon ());
1418: }
1419: };
1420: } else {
1421: pnlThread = new Thread () {
1422: @Override public void run () {
1423: do {
1424: pnlPanel.repaint ();
1425: if (!pnlWakeupCommon ()) {
1426: break;
1427: }
1428: } while (!isInterrupted () && pnlWakeupCommon ());
1429: }
1430: };
1431: }
1432: pnlWakeupTime = System.currentTimeMillis ();
1433: pnlWakeupTimeMNP = 0L;
1434: pnlThread.start ();
1435: }
1436:
1437: }
1438:
1439: public static boolean pnlWakeupCommon () {
1440: long t = System.currentTimeMillis ();
1441: if (CRTC.crtTotalLength == 0L) {
1442: pnlWakeupTime += 40L;
1443: } else {
1444: pnlWakeupTime += CRTC.crtTotalLength;
1445: pnlWakeupTimeMNP += CRTC.crtTotalLengthMNP;
1446: if (1000000000L <= pnlWakeupTimeMNP) {
1447: pnlWakeupTime++;
1448: pnlWakeupTimeMNP -= 1000000000L;
1449: }
1450: }
1451: pnlWakeupTime = Math.max (pnlWakeupTime, t + 4L);
1452: try {
1453: Thread.sleep (pnlWakeupTime - t);
1454: } catch (InterruptedException ie) {
1455: return false;
1456: }
1457: return true;
1458: }
1459:
1460:
1461:
1462:
1463:
1464: public static void pnlExitFullScreen (boolean dialog) {
1465: if (prgIsMac || !dialog) {
1466: pnlSetFullScreenOn (false);
1467: }
1468: }
1469:
1470:
1471:
1472: public static void pnlToggleFullScreen () {
1473: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1474: pnlSetMode (PNL_FULLSCREEN);
1475: } else {
1476: pnlSetMode (pnlPrevMode);
1477: }
1478: }
1479:
1480:
1481:
1482: public static void pnlToggleMaximized () {
1483: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1484: pnlSetMode (PNL_MAXIMIZED);
1485: } else {
1486: pnlSetMode (pnlPrevMode);
1487: }
1488: }
1489:
1490:
1491:
1492: public static void pnlSetFullScreenOn (boolean on) {
1493: if (on) {
1494: pnlSetMode (PNL_FULLSCREEN);
1495: } else if (pnlMode == PNL_FULLSCREEN) {
1496: pnlSetMode (pnlPrevMode);
1497: }
1498: }
1499:
1500:
1501:
1502:
1503: public static void pnlSetFitInWindowOn (boolean on) {
1504: if (!on) {
1505: pnlSetMode (PNL_FIXEDSCALE);
1506: } else if (pnlMode == PNL_FIXEDSCALE) {
1507: pnlSetMode (PNL_FITINWINDOW);
1508: }
1509: }
1510:
1511:
1512:
1513:
1514:
1515:
1516:
1517:
1518:
1519:
1520: public static void pnlUpdateArrangement () {
1521: pnlWidth = pnlPanel.getWidth ();
1522: pnlHeight = pnlPanel.getHeight ();
1523: frmMarginWidth = frmFrame.getWidth () - pnlWidth;
1524: frmMarginHeight = frmFrame.getHeight () - pnlHeight;
1525: pnlStretchMode = pnlAspectTable[CRTC.crtHRLCurr << 2 | CRTC.crtHResoCurr];
1526: pnlScreenWidth = Math.max (PNL_MIN_WIDTH, (CRTC.crtR03HDispEndCurr - CRTC.crtR02HBackEndCurr) << 3);
1527: pnlScreenHeight = Math.max (PNL_MIN_HEIGHT, (CRTC.crtR07VDispEndCurr - CRTC.crtR06VBackEndCurr) << (CRTC.crtInterlace || CRTC.crtSlit ? 1 : 0));
1528: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchMode);
1529: if (RasterBreakPoint.RBP_ON) {
1530:
1531: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
1532: RasterBreakPoint.rbpUpdateFrame ();
1533: }
1534: }
1535:
1536: pnlFixedScale = pnlFixedModel.getNumber ().intValue ();
1537:
1538: pnlRotatedWidth = pnlStretchWidth;
1539: pnlRotatedHeight = pnlScreenHeight;
1540: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1541: pnlRotatedWidth = pnlScreenHeight;
1542: pnlRotatedHeight = pnlStretchWidth;
1543: }
1544: if (pnlMode == PNL_FIXEDSCALE) {
1545:
1546:
1547:
1548:
1549:
1550: pnlZoomWidth = (pnlRotatedWidth * pnlFixedScale + 50) * 5243 >>> 19;
1551: pnlZoomHeight = (pnlRotatedHeight * pnlFixedScale + 50) * 5243 >>> 19;
1552: int width = Math.max (Math.max (PNL_MIN_WIDTH, pnlZoomWidth * pnlStereoscopicFactor), Keyboard.kbdWidth);
1553: int height = Math.max (PNL_MIN_HEIGHT, pnlZoomHeight) + Keyboard.kbdHeight;
1554: pnlScreenX1 = (width - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1555: pnlScreenY1 = (height - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1556: if (pnlWidth != width || pnlHeight != height) {
1557: pnlWidth = width;
1558: pnlHeight = height;
1559: pnlMinimumWidth = width;
1560: pnlMinimumHeight = height;
1561: pnlSize.setSize (width, height);
1562: pnlPanel.setMinimumSize (pnlSize);
1563: pnlPanel.setMaximumSize (pnlSize);
1564: pnlPanel.setPreferredSize (pnlSize);
1565: }
1566: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1567: frmFrame.setMinimumSize (frmMinimumSize);
1568: frmFrame.setMaximumSize (frmMinimumSize);
1569: frmFrame.setPreferredSize (frmMinimumSize);
1570: frmFrame.setResizable (false);
1571: frmFrame.pack ();
1572: } else {
1573:
1574: if (pnlWidth * pnlRotatedHeight >= (pnlHeight - Keyboard.kbdHeight) * (pnlRotatedWidth * pnlStereoscopicFactor)) {
1575:
1576:
1577:
1578:
1579:
1580:
1581:
1582:
1583:
1584:
1585:
1586:
1587: pnlZoomHeight = pnlHeight - Keyboard.kbdHeight;
1588: pnlZoomWidth = (pnlZoomHeight * pnlRotatedWidth + (pnlRotatedHeight >> 1)) / pnlRotatedHeight;
1589: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1590: pnlScreenX1 = ((pnlWidth >> 1) - (pnlZoomWidth >> 1)) >> 1;
1591: } else {
1592: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1593: }
1594: pnlScreenY1 = 0;
1595: } else {
1596:
1597:
1598:
1599:
1600:
1601:
1602:
1603:
1604:
1605:
1606:
1607:
1608:
1609:
1610:
1611:
1612: pnlZoomWidth = pnlWidth / pnlStereoscopicFactor;
1613: pnlZoomHeight = (pnlZoomWidth * pnlStereoscopicFactor * pnlRotatedHeight + (pnlRotatedWidth * pnlStereoscopicFactor >> 1)) / (pnlRotatedWidth * pnlStereoscopicFactor);
1614: pnlScreenX1 = 0;
1615: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM) {
1616: pnlScreenY1 = (((pnlHeight - Keyboard.kbdHeight) >> 1) - (pnlZoomHeight >> 1)) >> 1;
1617: } else {
1618: pnlScreenY1 = (pnlHeight - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1619: }
1620: }
1621:
1622: int minimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
1623: int minimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
1624: if (pnlMinimumWidth != minimumWidth || pnlMinimumHeight != minimumHeight) {
1625: pnlMinimumWidth = minimumWidth;
1626: pnlMinimumHeight = minimumHeight;
1627: }
1628: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1629: frmFrame.setMinimumSize (frmMinimumSize);
1630: frmFrame.setMaximumSize (null);
1631: frmFrame.setResizable (true);
1632: }
1633:
1634: pnlArrangementCommon ();
1635: Mouse.musUpdateSpeedRatio ();
1636: if (!PNL_FILL_BACKGROUND) {
1637: pnlFillBackgroundRequest = true;
1638: }
1639: }
1640:
1641: public static void pnlArrangementCommon () {
1642: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1643: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1644: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) {
1645: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1646: pnlScreenX3 = pnlScreenX2;
1647: pnlScreenX4 = pnlScreenX3 + pnlZoomWidth;
1648: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1649: pnlScreenY3 = pnlScreenY1;
1650: pnlScreenY4 = pnlScreenY2;
1651: } else if (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1652: pnlScreenX2 = pnlScreenX1 + (pnlZoomWidth >> 1);
1653: pnlScreenX3 = pnlScreenX2;
1654: pnlScreenX4 = pnlScreenX3 + (pnlZoomWidth >> 1);
1655: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1656: pnlScreenY3 = pnlScreenY1;
1657: pnlScreenY4 = pnlScreenY2;
1658: } else {
1659: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1660: pnlScreenX3 = pnlScreenX1;
1661: pnlScreenX4 = pnlScreenX2;
1662: pnlScreenY2 = pnlScreenY1 + (pnlZoomHeight >> 1);
1663: pnlScreenY3 = pnlScreenY2;
1664: pnlScreenY4 = pnlScreenY3 + (pnlZoomHeight >> 1);
1665: }
1666: } else {
1667: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
1668: pnlScreenX3 = pnlScreenX1;
1669: pnlScreenX4 = pnlScreenX2;
1670: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
1671: pnlScreenY3 = pnlScreenY1;
1672: pnlScreenY4 = pnlScreenY2;
1673: }
1674: pnlKeyboardX = (pnlWidth - Keyboard.kbdWidth) >> 1;
1675: pnlKeyboardY = pnlScreenY4;
1676: pnlZoomRatioOutX = ((pnlZoomWidth * pnlStereoscopicFactor) << 16) / pnlScreenWidth;
1677: pnlZoomRatioOutY = (pnlZoomHeight << 16) / pnlScreenHeight;
1678: pnlZoomRatioInX = (pnlScreenWidth << 16) / (pnlZoomWidth * pnlStereoscopicFactor);
1679: pnlZoomRatioInY = (pnlScreenHeight << 16) / pnlZoomHeight;
1680: if (PNL_ROTATION_ON) {
1681:
1682: if (PNL_USE_THREAD) {
1683: for (int n = 0; n < 4; n++) {
1684: pnlScreenSubImageLeftArray[n] = pnlScreenImageLeftArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1685: pnlScreenSubImageRightArray[n] = pnlScreenImageRightArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1686: }
1687: } else {
1688: pnlScreenSubImageLeft = pnlScreenImageLeft.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1689: pnlScreenSubImageRight = pnlScreenImageRight.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
1690: }
1691:
1692:
1693:
1694:
1695: double ax = 0.0;
1696: double ay = 0.0;
1697: double bx = (double) pnlScreenWidth;
1698: double by = (double) pnlScreenHeight;
1699: double l00, l10, l01, l11, l02, l12;
1700: double r00, r10, r01, r11, r02, r12;
1701: if (pnlRotationMode == 0) {
1702: double cx = (double) pnlScreenX1;
1703: double cy = (double) pnlScreenY1;
1704: double dx = (double) pnlScreenX2;
1705: double dy = (double) pnlScreenY2;
1706: l00 = (cx - dx) / (ax - bx);
1707: l10 = 0.0;
1708: l01 = 0.0;
1709: l11 = (cy - dy) / (ay - by);
1710: l02 = (ax * dx - bx * cx) / (ax - bx);
1711: l12 = (ay * dy - by * cy) / (ay - by);
1712: cx = (double) pnlScreenX3;
1713: cy = (double) pnlScreenY3;
1714: dx = (double) pnlScreenX4;
1715: dy = (double) pnlScreenY4;
1716: r00 = (cx - dx) / (ax - bx);
1717: r10 = 0.0;
1718: r01 = 0.0;
1719: r11 = (cy - dy) / (ay - by);
1720: r02 = (ax * dx - bx * cx) / (ax - bx);
1721: r12 = (ay * dy - by * cy) / (ay - by);
1722: } else if (pnlRotationMode == 1) {
1723: double cx = (double) pnlScreenX1;
1724: double cy = (double) pnlScreenY1;
1725: double dx = (double) pnlScreenX2;
1726: double dy = (double) pnlScreenY2;
1727: l00 = 0.0;
1728: l10 = (dy - cy) / (ax - bx);
1729: l01 = (cx - dx) / (ay - by);
1730: l11 = 0.0;
1731: l02 = (ay * dx - by * cx) / (ay - by);
1732: l12 = (ax * cy - bx * dy) / (ax - bx);
1733: cx = (double) pnlScreenX3;
1734: cy = (double) pnlScreenY3;
1735: dx = (double) pnlScreenX4;
1736: dy = (double) pnlScreenY4;
1737: r00 = 0.0;
1738: r10 = (dy - cy) / (ax - bx);
1739: r01 = (cx - dx) / (ay - by);
1740: r11 = 0.0;
1741: r02 = (ay * dx - by * cx) / (ay - by);
1742: r12 = (ax * cy - bx * dy) / (ax - bx);
1743: } else if (pnlRotationMode == 2) {
1744: double cx = (double) pnlScreenX1;
1745: double cy = (double) pnlScreenY1;
1746: double dx = (double) pnlScreenX2;
1747: double dy = (double) pnlScreenY2;
1748: l00 = (dx - cx) / (ax - bx);
1749: l10 = 0.0;
1750: l01 = 0.0;
1751: l11 = (dy - cy) / (ay - by);
1752: l02 = (ax * cx - bx * dx) / (ax - bx);
1753: l12 = (ay * cy - by * dy) / (ay - by);
1754: cx = (double) pnlScreenX3;
1755: cy = (double) pnlScreenY3;
1756: dx = (double) pnlScreenX4;
1757: dy = (double) pnlScreenY4;
1758: r00 = (dx - cx) / (ax - bx);
1759: r10 = 0.0;
1760: r01 = 0.0;
1761: r11 = (dy - cy) / (ay - by);
1762: r02 = (ax * cx - bx * dx) / (ax - bx);
1763: r12 = (ay * cy - by * dy) / (ay - by);
1764: } else {
1765: double cx = (double) pnlScreenX1;
1766: double cy = (double) pnlScreenY1;
1767: double dx = (double) pnlScreenX2;
1768: double dy = (double) pnlScreenY2;
1769: l00 = 0.0;
1770: l10 = (cy - dy) / (ax - bx);
1771: l01 = (dx - cx) / (ay - by);
1772: l11 = 0.0;
1773: l02 = (ay * cx - by * dx) / (ay - by);
1774: l12 = (ax * dy - bx * cy) / (ax - bx);
1775: cx = (double) pnlScreenX3;
1776: cy = (double) pnlScreenY3;
1777: dx = (double) pnlScreenX4;
1778: dy = (double) pnlScreenY4;
1779: r00 = 0.0;
1780: r10 = (cy - dy) / (ax - bx);
1781: r01 = (dx - cx) / (ay - by);
1782: r11 = 0.0;
1783: r02 = (ay * cx - by * dx) / (ay - by);
1784: r12 = (ax * dy - bx * cy) / (ax - bx);
1785: }
1786: pnlRotationTransformLeft.setTransform (l00, l10, l01, l11, l02, l12);
1787: pnlRotationTransformRight.setTransform (r00, r10, r01, r11, r02, r12);
1788: pnlMatrixL00 = l00;
1789: pnlMatrixL10 = l10;
1790: pnlMatrixL01 = l01;
1791: pnlMatrixL11 = l11;
1792: pnlMatrixL02 = l02;
1793: pnlMatrixL12 = l12;
1794: pnlMatrixR00 = r00;
1795: pnlMatrixR10 = r10;
1796: pnlMatrixR01 = r01;
1797: pnlMatrixR11 = r11;
1798: pnlMatrixR02 = r02;
1799: pnlMatrixR12 = r12;
1800:
1801:
1802:
1803:
1804:
1805:
1806: double d = l00 * l11 - l01 * l10;
1807: pnlInverseL00 = l11 / d;
1808: pnlInverseL10 = -l10 / d;
1809: pnlInverseL01 = -l01 / d;
1810: pnlInverseL11 = l00 / d;
1811: pnlInverseL02 = (l01 * l12 - l02 * l11) / d;
1812: pnlInverseL12 = (l02 * l10 - l00 * l12) / d;
1813: d = r00 * r11 - r01 * r10;
1814: pnlInverseR00 = r11 / d;
1815: pnlInverseR10 = -r10 / d;
1816: pnlInverseR01 = -r01 / d;
1817: pnlInverseR11 = r00 / d;
1818: pnlInverseR02 = (r01 * r12 - r02 * r11) / d;
1819: pnlInverseR12 = (r02 * r10 - r00 * r12) / d;
1820: }
1821: }
1822:
1823:
1824:
1825:
1826: public static final int PNL_UNDEFINED = 0;
1827: public static final int PNL_FIXEDSCALE = 1;
1828: public static final int PNL_FITINWINDOW = 2;
1829: public static final int PNL_FULLSCREEN = 3;
1830: public static final int PNL_MAXIMIZED = 4;
1831: public static int pnlModeRequest;
1832: public static int pnlMode;
1833: public static int pnlPrevMode;
1834:
1835:
1836: public static JRadioButtonMenuItem mnbFullScreenMenuItem;
1837: public static JRadioButtonMenuItem mnbMaximizedMenuItem;
1838: public static JRadioButtonMenuItem mnbFitInWindowMenuItem;
1839: public static JRadioButtonMenuItem mnbFixedScaleMenuItem;
1840:
1841:
1842: public static int PNL_BOOT_DELAY = 500;
1843: public static javax.swing.Timer pnlBootTimer;
1844:
1845:
1846:
1847: public static void pnlInit2 () {
1848: pnlModeRequest = PNL_UNDEFINED;
1849: pnlMode = PNL_FITINWINDOW;
1850: pnlPrevMode = PNL_FITINWINDOW;
1851: switch (Settings.sgsGetString ("scaling").toLowerCase ()) {
1852: case "fullscreen":
1853: pnlModeRequest = PNL_FULLSCREEN;
1854: break;
1855: case "maximized":
1856: pnlModeRequest = PNL_MAXIMIZED;
1857: break;
1858: case "fitinwindow":
1859: break;
1860: case "fixedscale":
1861: pnlMode = PNL_FIXEDSCALE;
1862: break;
1863: }
1864: }
1865:
1866:
1867:
1868: public static void pnlTini2 () {
1869: Settings.sgsPutString ("scaling",
1870: pnlMode == PNL_FULLSCREEN ? "fullscreen" :
1871: pnlMode == PNL_MAXIMIZED ? "maximized" :
1872: pnlMode == PNL_FITINWINDOW ? "fitinwindow" :
1873: "fixedscale");
1874: }
1875:
1876:
1877:
1878: public static void pnlMake2 () {
1879:
1880: ActionListener listener = new ActionListener () {
1881: @Override public void actionPerformed (ActionEvent ae) {
1882: String command = ae.getActionCommand ();
1883: switch (command) {
1884: case "Full screen":
1885: pnlSetMode (PNL_FULLSCREEN);
1886: break;
1887: case "Maximized":
1888: pnlSetMode (PNL_MAXIMIZED);
1889: break;
1890: case "Fit in window":
1891: pnlSetMode (PNL_FITINWINDOW);
1892: break;
1893: case "Fixed scale":
1894: pnlSetMode (PNL_FIXEDSCALE);
1895: break;
1896: }
1897: }
1898: };
1899: ButtonGroup group = new ButtonGroup ();
1900: mnbFullScreenMenuItem = ComponentFactory.setEnabled (
1901: Multilingual.mlnText (
1902: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FULLSCREEN, "Full screen", listener),
1903: "ja", "全画面表示"),
1904: pnlIsFullScreenSupported);
1905: mnbMaximizedMenuItem = Multilingual.mlnText (
1906: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_MAXIMIZED, "Maximized", listener),
1907: "ja", "最大化");
1908: mnbFitInWindowMenuItem = Multilingual.mlnText (
1909: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FITINWINDOW, "Fit in window", 'W', MNB_MODIFIERS, listener),
1910: "ja", "ウインドウに合わせる");
1911: mnbFixedScaleMenuItem = Multilingual.mlnText (
1912: ComponentFactory.createRadioButtonMenuItem (group, pnlMode == PNL_FIXEDSCALE, "Fixed scale", 'X', MNB_MODIFIERS, listener),
1913: "ja", "固定倍率");
1914: }
1915:
1916:
1917:
1918: public static void pnlStart2 () {
1919:
1920: frmFrame.addWindowStateListener (new WindowStateListener () {
1921: @Override public void windowStateChanged (WindowEvent we) {
1922: int state = frmFrame.getExtendedState ();
1923: if (pnlMode != PNL_MAXIMIZED &&
1924: (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
1925: pnlSetMode (PNL_MAXIMIZED);
1926: } else if (pnlMode == PNL_MAXIMIZED &&
1927: (state & Frame.MAXIMIZED_BOTH) != Frame.MAXIMIZED_BOTH) {
1928: pnlSetMode (pnlPrevMode);
1929: }
1930: }
1931: });
1932: }
1933:
1934:
1935:
1936: public static void pnlBoot2 () {
1937: if (pnlModeRequest != PNL_UNDEFINED) {
1938: pnlBootTimer = new javax.swing.Timer (PNL_BOOT_DELAY, new ActionListener () {
1939: public void actionPerformed (ActionEvent ae) {
1940: if (pnlModeRequest == PNL_FULLSCREEN) {
1941: mnbFullScreenMenuItem.doClick ();
1942: } else if (pnlModeRequest == PNL_MAXIMIZED) {
1943: mnbMaximizedMenuItem.doClick ();
1944: }
1945: pnlBootTimer.stop ();
1946: pnlBootTimer = null;
1947: }
1948: });
1949: pnlBootTimer.start ();
1950: }
1951: }
1952:
1953:
1954:
1955: public static void pnlSetMode (int mode) {
1956: do {
1957:
1958: if (pnlMode == mode) {
1959: break;
1960: }
1961:
1962: String text = null;
1963: if (mode == PNL_FULLSCREEN) {
1964: if (!pnlIsFullScreenSupported) {
1965: JOptionPane.showMessageDialog (
1966: frmFrame,
1967: Multilingual.mlnJapanese ?
1968: "全画面表示に対応していません" :
1969: "Full screen is not supported");
1970: break;
1971: }
1972: if (Bubble.BBL_ON) {
1973: text = ButtonFunction.bfnFullScreenText ();
1974: if (text == null) {
1975: JOptionPane.showMessageDialog (
1976: frmFrame,
1977: Multilingual.mlnJapanese ?
1978: "全画面表示を終了するキーまたはボタンがありません" :
1979: "No key or button to exit full screen");
1980: break;
1981: }
1982: }
1983: }
1984:
1985: if (pnlMode == PNL_FULLSCREEN) {
1986: pnlMode = pnlPrevMode;
1987: if (Bubble.BBL_ON) {
1988: Bubble.bblEnd ();
1989: }
1990: if (frmScreenDevice.getFullScreenWindow () == frmFrame) {
1991: frmScreenDevice.setFullScreenWindow (null);
1992: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.FRAME);
1993: }
1994: frmFrame.setJMenuBar (mnbMenuBar);
1995: if (pnlHideKeyboard) {
1996: if (pnlPrevKeyboardOn) {
1997: Keyboard.kbdSetOn (true);
1998: }
1999: }
2000: } else if (pnlMode == PNL_MAXIMIZED) {
2001: pnlMode = pnlPrevMode;
2002: if ((frmFrame.getExtendedState () & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
2003: frmFrame.setExtendedState (Frame.NORMAL);
2004: }
2005: }
2006:
2007: if (mode == PNL_FULLSCREEN) {
2008: pnlPrevMode = pnlMode;
2009: if (pnlHideKeyboard) {
2010: pnlPrevKeyboardOn = Keyboard.kbdImage != null;
2011: if (pnlPrevKeyboardOn) {
2012: Keyboard.kbdSetOn (false);
2013: }
2014: }
2015: frmFrame.setJMenuBar (null);
2016: if (frmScreenDevice.getFullScreenWindow () != frmFrame) {
2017: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.NONE);
2018: frmScreenDevice.setFullScreenWindow (frmFrame);
2019: }
2020: if (Bubble.BBL_ON) {
2021: if (text != null) {
2022: Bubble.bblStart (text + (Multilingual.mlnJapanese ? "で全画面表示を終了" : " to exit full screen"), 5000L);
2023: }
2024: }
2025: } else if (mode == PNL_MAXIMIZED) {
2026: pnlPrevMode = pnlMode;
2027: frmFrame.setExtendedState (Frame.MAXIMIZED_BOTH);
2028: }
2029: pnlMode = mode;
2030:
2031:
2032: pnlUpdateArrangement ();
2033: } while (false);
2034:
2035: if (pnlMode == PNL_FIXEDSCALE) {
2036: if (!mnbFixedScaleMenuItem.isSelected ()) {
2037: mnbFixedScaleMenuItem.setSelected (true);
2038: }
2039: } else if (pnlMode == PNL_FITINWINDOW) {
2040: if (!mnbFitInWindowMenuItem.isSelected ()) {
2041: mnbFitInWindowMenuItem.setSelected (true);
2042: }
2043: } else if (pnlMode == PNL_FULLSCREEN) {
2044: if (!mnbFullScreenMenuItem.isSelected ()) {
2045: mnbFullScreenMenuItem.setSelected (true);
2046: }
2047: } else if (pnlMode == PNL_MAXIMIZED) {
2048: if (!mnbMaximizedMenuItem.isSelected ()) {
2049: mnbMaximizedMenuItem.setSelected (true);
2050: }
2051: }
2052: }
2053:
2054:
2055:
2056:
2057:
2058:
2059: public static Robot rbtRobot;
2060:
2061:
2062: public static void rbtInit () {
2063:
2064:
2065: rbtRobot = null;
2066: try {
2067: rbtRobot = new Robot ();
2068: } catch (Exception e) {
2069: }
2070:
2071: }
2072:
2073:
2074:
2075:
2076:
2077:
2078:
2079: public static final int MNB_MODIFIERS = InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK;
2080:
2081:
2082: public static JMenuBar mnbMenuBar;
2083:
2084:
2085: public static JMenu mnbFileMenu;
2086: public static JMenu mnbDisplayMenu;
2087: public static JMenu mnbSoundMenu;
2088: public static JMenu mnbInputMenu;
2089: public static JMenu mnbConfigMenu;
2090: public static JMenu mnbLanguageMenu;
2091:
2092:
2093:
2094:
2095:
2096: public static JMenuItem mnbQuitMenuItem;
2097: public static JCheckBoxMenuItem mnbStereoscopicMenuItem;
2098: public static JCheckBoxMenuItem mnbPlayMenuItem;
2099: public static JMenuItem mnbPasteMenuItem;
2100: public static JRadioButtonMenuItem mnbStandardKeyboardMenuItem;
2101: public static JRadioButtonMenuItem mnbCompactKeyboardMenuItem;
2102: public static JRadioButtonMenuItem mnbNoKeyboardMenuItem;
2103: public static JLabel mnbVolumeLabel;
2104:
2105:
2106:
2107:
2108:
2109:
2110: public static JMenu mnbMakeFontSizeMenu () {
2111:
2112: ActionListener actionListener = new ActionListener () {
2113: @Override public void actionPerformed (ActionEvent ae) {
2114: String command = ae.getActionCommand ();
2115: switch (command) {
2116: case "Very small":
2117: LnF.lnfFontSizeRequest = 10;
2118: break;
2119: case "Small":
2120: LnF.lnfFontSizeRequest = 12;
2121: break;
2122: case "Medium":
2123: LnF.lnfFontSizeRequest = 14;
2124: break;
2125: case "Large":
2126: LnF.lnfFontSizeRequest = 16;
2127: break;
2128: case "Very large":
2129: LnF.lnfFontSizeRequest = 18;
2130: break;
2131: default:
2132: System.out.println ("unknown action command " + command);
2133: }
2134: }
2135: };
2136:
2137: ButtonGroup fontSizeGroup = new ButtonGroup ();
2138:
2139: return Multilingual.mlnText (
2140: ComponentFactory.createMenu (
2141: "Font size",
2142: Multilingual.mlnText (
2143: ComponentFactory.pointSize (
2144: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 10, "Very small", actionListener),
2145: 10),
2146: "ja", "極小"),
2147: Multilingual.mlnText (
2148: ComponentFactory.pointSize (
2149: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 12, "Small", actionListener),
2150: 12),
2151: "ja", "小"),
2152: Multilingual.mlnText (
2153: ComponentFactory.pointSize (
2154: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 14, "Medium", actionListener),
2155: 14),
2156: "ja", "中"),
2157: Multilingual.mlnText (
2158: ComponentFactory.pointSize (
2159: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 16, "Large", actionListener),
2160: 16),
2161: "ja", "大"),
2162: Multilingual.mlnText (
2163: ComponentFactory.pointSize (
2164: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 18, "Very large", actionListener),
2165: 18),
2166: "ja", "極大")),
2167: "ja", "フォントサイズ");
2168: }
2169:
2170:
2171:
2172: public static final DecimalSpinner[] mnbColorSpinners = new DecimalSpinner[9];
2173: public static final int[] mnbColorRGB = new int[15];
2174: public static JPanel mnbColorPanel;
2175:
2176:
2177:
2178: public static void mnbColorHSBToRGB () {
2179: for (int i = 0; i <= 14; i++) {
2180: int[] t = LnF.LNF_HSB_INTERPOLATION_TABLE[i];
2181: float h = (float) (t[0] * LnF.lnfHSB[0] + t[1] * LnF.lnfHSB[1] + t[2] * LnF.lnfHSB[2]) / (49.0F * 360.0F);
2182: float s = (float) (t[0] * LnF.lnfHSB[3] + t[1] * LnF.lnfHSB[4] + t[2] * LnF.lnfHSB[5]) / (49.0F * 100.0F);
2183: float b = (float) (t[0] * LnF.lnfHSB[6] + t[1] * LnF.lnfHSB[7] + t[2] * LnF.lnfHSB[8]) / (49.0F * 100.0F);
2184: mnbColorRGB[i] = Color.HSBtoRGB (h,
2185: Math.max (0.0F, Math.min (1.0F, s)),
2186: Math.max (0.0F, Math.min (1.0F, b)));
2187: }
2188: }
2189:
2190:
2191:
2192: public static JMenu mnbMakeColorMenu () {
2193: mnbColorHSBToRGB ();
2194:
2195: mnbColorPanel = ComponentFactory.setColor (
2196: ComponentFactory.setFixedSize (
2197: new JPanel () {
2198: @Override protected void paintComponent (Graphics g) {
2199: super.paintComponent (g);
2200: for (int i = 0; i <= 14; i++) {
2201: g.setColor (new Color (mnbColorRGB[i]));
2202: g.fillRect (LnF.lnfFontSize * i, 0, LnF.lnfFontSize, LnF.lnfFontSize * 5);
2203: }
2204: }
2205: },
2206: LnF.lnfFontSize * 15, LnF.lnfFontSize * 5),
2207: Color.white, Color.black);
2208:
2209: ChangeListener changeListener = new ChangeListener () {
2210: @Override public void stateChanged (ChangeEvent ce) {
2211: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
2212: LnF.lnfHSB[spinner.getOption ()] = spinner.getIntValue ();
2213: mnbColorHSBToRGB ();
2214: mnbColorPanel.repaint ();
2215: }
2216: };
2217:
2218: ActionListener actionListener = new ActionListener () {
2219: @Override public void actionPerformed (ActionEvent ae) {
2220: String command = ae.getActionCommand ();
2221: switch (command) {
2222: case "Reset to default values":
2223: for (int i = 0; i < 9; i++) {
2224: LnF.lnfHSB[i] = LnF.LNF_DEFAULT_HSB[i];
2225: mnbColorSpinners[i].setIntValue (LnF.lnfHSB[i]);
2226: }
2227: mnbColorHSBToRGB ();
2228: mnbColorPanel.repaint ();
2229: break;
2230: default:
2231: System.out.println ("unknown action command " + command);
2232: }
2233: }
2234: };
2235:
2236: for (int i = 0; i < 9; i++) {
2237: mnbColorSpinners[i] = ComponentFactory.createDecimalSpinner (
2238: LnF.lnfHSB[i], 0, i < 3 ? 720 : 100, 1, i, changeListener);
2239: }
2240:
2241: return Multilingual.mlnText (
2242: ComponentFactory.createMenu (
2243: "Color",
2244: ComponentFactory.createHorizontalBox (
2245: mnbColorSpinners[0],
2246: mnbColorSpinners[1],
2247: mnbColorSpinners[2],
2248: ComponentFactory.createLabel ("H °"),
2249: Box.createHorizontalGlue ()
2250: ),
2251: ComponentFactory.createHorizontalBox (
2252: mnbColorSpinners[3],
2253: mnbColorSpinners[4],
2254: mnbColorSpinners[5],
2255: ComponentFactory.createLabel ("S%"),
2256: Box.createHorizontalGlue ()
2257: ),
2258: ComponentFactory.createHorizontalBox (
2259: mnbColorSpinners[6],
2260: mnbColorSpinners[7],
2261: mnbColorSpinners[8],
2262: ComponentFactory.createLabel ("B%"),
2263: Box.createHorizontalGlue ()
2264: ),
2265: ComponentFactory.createHorizontalBox (
2266: ComponentFactory.setLineBorder (mnbColorPanel),
2267: Box.createHorizontalGlue ()
2268: ),
2269: Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset to default values", actionListener), "ja", "初期値に戻す")
2270: ),
2271: "ja", "色");
2272: }
2273:
2274:
2275:
2276:
2277:
2278: public static JMenu mnbMakeLanguageMenu () {
2279:
2280: ActionListener actionListener = new ActionListener () {
2281: @Override public void actionPerformed (ActionEvent ae) {
2282: String command = ae.getActionCommand ();
2283: switch (command) {
2284: case "English":
2285: Multilingual.mlnChange ("en");
2286: break;
2287: case "日本語":
2288: Multilingual.mlnChange ("ja");
2289: break;
2290: default:
2291: System.out.println ("unknown action command " + command);
2292: }
2293: }
2294: };
2295:
2296: ButtonGroup languageGroup = new ButtonGroup ();
2297:
2298: return mnbLanguageMenu = Multilingual.mlnText (
2299: ComponentFactory.createMenu (
2300: "Language", 'L',
2301: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnEnglish, "English", actionListener),
2302: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnJapanese, "日本語", actionListener),
2303: ComponentFactory.createHorizontalSeparator (),
2304: mnbMakeFontSizeMenu (),
2305: mnbMakeColorMenu ()
2306: ),
2307: "ja", "言語");
2308: }
2309:
2310:
2311:
2312:
2313:
2314: public static void mnbMakeMenu () {
2315:
2316:
2317: ActionListener listener = new ActionListener () {
2318: @Override public void actionPerformed (ActionEvent ae) {
2319: Object source = ae.getSource ();
2320: String command = ae.getActionCommand ();
2321: switch (command) {
2322:
2323:
2324: case "Quit":
2325: prgTini ();
2326: break;
2327:
2328:
2329: case "50%":
2330: case "75%":
2331: case "100%":
2332: case "150%":
2333: case "200%":
2334: pnlFixedModel.setValue (Integer.valueOf (Integer.parseInt (command.substring (0, command.length () - 1))));
2335: break;
2336: case "Nearest neighbor":
2337: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
2338: break;
2339: case "Bilinear":
2340: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
2341: break;
2342: case "Bicubic":
2343: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
2344: break;
2345:
2346: case "Use canvas":
2347: pnlUseCanvasRequest = ((JCheckBoxMenuItem) source).isSelected ();
2348: break;
2349:
2350: case "Draw all changed pictures":
2351: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2352: CRTC.crtIntermittentInterval = 0;
2353: }
2354: break;
2355: case "Draw a changed picture once every two times":
2356: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2357: CRTC.crtIntermittentInterval = 1;
2358: }
2359: break;
2360: case "Draw a changed picture once every three times":
2361: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2362: CRTC.crtIntermittentInterval = 2;
2363: }
2364: break;
2365: case "Draw a changed picture once every four times":
2366: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2367: CRTC.crtIntermittentInterval = 3;
2368: }
2369: break;
2370: case "Draw a changed picture once every five times":
2371: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2372: CRTC.crtIntermittentInterval = 4;
2373: }
2374: break;
2375:
2376: case "Stereoscopic viewing":
2377: pnlSetStereoscopic (((JCheckBoxMenuItem) source).isSelected (), pnlStereoscopicMethod);
2378: break;
2379: case "Naked-eye crossing":
2380: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_CROSSING);
2381: break;
2382: case "Naked-eye parallel":
2383: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_PARALLEL);
2384: break;
2385: case "Side-by-side":
2386: pnlSetStereoscopic (pnlStereoscopicOn, PNL_SIDE_BY_SIDE);
2387: break;
2388: case "Top-and-bottom":
2389: pnlSetStereoscopic (pnlStereoscopicOn, PNL_TOP_AND_BOTTOM);
2390: break;
2391:
2392: case "Sprite pattern viewer":
2393: if (SpritePatternViewer.SPV_ON) {
2394: SpritePatternViewer.spvOpen ();
2395: }
2396: break;
2397: case "Screen mode test":
2398: if (ScreenModeTest.SMT_ON) {
2399: ScreenModeTest.smtOpen ();
2400: }
2401: break;
2402:
2403:
2404: case "Play":
2405: SoundSource.sndSetPlayOn (((JCheckBoxMenuItem) source).isSelected ());
2406: break;
2407: case "OPM output":
2408: OPM.opmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2409: break;
2410: case "OPM log":
2411: OPMLog.olgOpen ();
2412: break;
2413:
2414: case "PCM output":
2415: ADPCM.pcmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2416: break;
2417: case "Sound thinning":
2418: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.THINNING_MONO : SoundSource.SNDRateConverter.THINNING_STEREO;
2419: break;
2420: case "Sound linear interpolation":
2421: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.LINEAR_MONO : SoundSource.SNDRateConverter.LINEAR_STEREO;
2422: break;
2423: case "Sound piecewise-constant area interpolation":
2424: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000;
2425: break;
2426: case "Sound linear area interpolation":
2427: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000;
2428: break;
2429: case "Sound monitor":
2430: SoundMonitor.smnOpen ();
2431: break;
2432: case "PCM piecewise-constant interpolation":
2433: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_CONSTANT);
2434: break;
2435: case "PCM linear interpolation":
2436: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_LINEAR);
2437: break;
2438: case "PCM hermite interpolation":
2439: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_HERMITE);
2440: break;
2441: case "PCM 8MHz/4MHz":
2442: ADPCM.pcmOSCFreqRequest = 0;
2443: break;
2444: case "PCM 8MHz/16MHz":
2445: ADPCM.pcmOSCFreqRequest = 1;
2446: break;
2447:
2448:
2449: case "Paste":
2450: CONDevice.conDoPaste ();
2451: break;
2452: case "No keyboard":
2453: Keyboard.kbdSetOn (false);
2454: pnlUpdateArrangement ();
2455: break;
2456: case "Standard keyboard":
2457: Keyboard.kbdSetType (Keyboard.KBD_STANDARD_TYPE);
2458: Keyboard.kbdSetOn (true);
2459: pnlUpdateArrangement ();
2460: break;
2461: case "Compact keyboard":
2462: Keyboard.kbdSetType (Keyboard.KBD_COMPACT_TYPE);
2463: Keyboard.kbdSetOn (true);
2464: pnlUpdateArrangement ();
2465: break;
2466: case "Hide keyboard in full screen":
2467: pnlHideKeyboard = ((JCheckBoxMenuItem) source).isSelected ();
2468: if (pnlMode == PNL_FULLSCREEN) {
2469: pnlUpdateArrangement ();
2470: }
2471: break;
2472: case "Key assignments":
2473: Keyboard.kbdOpen ();
2474: break;
2475: case "Joystick port settings":
2476: PPI.ppiOpen ();
2477: break;
2478:
2479:
2480: case "RS-232C and terminal":
2481: RS232CTerminal.trmOpen ();
2482: break;
2483:
2484: case "Console":
2485: DebugConsole.dgtOpen ();
2486: break;
2487: case "Register list":
2488: RegisterList.drpOpen ();
2489: break;
2490: case "Disassemble list":
2491: DisassembleList.ddpOpen (-1, -1, true);
2492: break;
2493: case "Memory dump list":
2494: MemoryDumpList.dmpOpen (-1, -1, true);
2495: break;
2496: case "Logical space monitor":
2497: LogicalSpaceMonitor.atwOpen ();
2498: break;
2499: case "Physical space monitor":
2500: PhysicalSpaceMonitor.paaOpen ();
2501: break;
2502: case "Address translation caches monitor":
2503: if (ATCMonitor.ACM_ON) {
2504: ATCMonitor.acmOpen ();
2505: }
2506: break;
2507: case "Branch log":
2508: if (BranchLog.BLG_ON) {
2509: BranchLog.blgOpen (BranchLog.BLG_SELECT_NONE);
2510: }
2511: break;
2512: case "Program flow visualizer":
2513: if (ProgramFlowVisualizer.PFV_ON) {
2514: ProgramFlowVisualizer.pfvOpen ();
2515: }
2516: break;
2517: case "Raster break point":
2518: if (RasterBreakPoint.RBP_ON) {
2519: RasterBreakPoint.rbpOpen ();
2520: }
2521: break;
2522: case "Data break point":
2523: if (DataBreakPoint.DBP_ON) {
2524: DataBreakPoint.dbpOpen ();
2525: }
2526: break;
2527: case "Root pointer list":
2528: if (RootPointerList.RTL_ON) {
2529: RootPointerList.rtlOpen ();
2530: }
2531: break;
2532:
2533:
2534: case "Adjust clock to host":
2535: RP5C15.rtcSetByHost ();
2536: break;
2537:
2538:
2539:
2540: case "Printer":
2541: PrinterPort.prnOpen ();
2542: break;
2543:
2544: case "Mouse button status":
2545: Mouse.musOutputButtonStatus = ((JCheckBoxMenuItem) source).isSelected ();
2546: break;
2547:
2548: case "Java runtime environment information":
2549: prgOpenJavaDialog ();
2550: break;
2551: case "Version information":
2552: prgOpenAboutDialog ();
2553: break;
2554: case "XEiJ License":
2555: prgOpenXEiJLicenseDialog ();
2556: break;
2557: case "FSHARP License":
2558: prgOpenSHARPLicenseDialog ();
2559: break;
2560: case "ymfm License":
2561: prgOpenYmfmLicenseDialog ();
2562: break;
2563: case "jSerialComm License":
2564: prgOpenJSerialCommLicenseDialog ();
2565: break;
2566:
2567: default:
2568: System.out.println ("unknown action command " + command);
2569:
2570: }
2571: }
2572: };
2573:
2574:
2575: ActionListener mainMemoryListener = new ActionListener () {
2576: @Override public void actionPerformed (ActionEvent ae) {
2577: Object source = ae.getSource ();
2578: String command = ae.getActionCommand ();
2579: switch (command) {
2580: case "1MB":
2581: MainMemory.mmrMemorySizeRequest = 0x00100000;
2582: break;
2583: case "2MB":
2584: MainMemory.mmrMemorySizeRequest = 0x00200000;
2585: break;
2586: case "4MB":
2587: MainMemory.mmrMemorySizeRequest = 0x00400000;
2588: break;
2589: case "6MB":
2590: MainMemory.mmrMemorySizeRequest = 0x00600000;
2591: break;
2592: case "8MB":
2593: MainMemory.mmrMemorySizeRequest = 0x00800000;
2594: break;
2595: case "10MB":
2596: MainMemory.mmrMemorySizeRequest = 0x00a00000;
2597: break;
2598: case "12MB":
2599: MainMemory.mmrMemorySizeRequest = 0x00c00000;
2600: break;
2601: case "Save contents on exit":
2602: MainMemory.mmrMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2603: break;
2604: }
2605: }
2606: };
2607: ButtonGroup mainMemoryGroup = new ButtonGroup ();
2608: JMenu mainMemoryMenu = Multilingual.mlnText (
2609: ComponentFactory.createMenu (
2610: "Main memory",
2611: Multilingual.mlnText (
2612: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00100000, "1MB", mainMemoryListener),
2613: "ja", "1MB"),
2614: Multilingual.mlnText (
2615: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00200000, "2MB", mainMemoryListener),
2616: "ja", "2MB"),
2617: Multilingual.mlnText (
2618: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00400000, "4MB", mainMemoryListener),
2619: "ja", "4MB"),
2620: Multilingual.mlnText (
2621: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00600000, "6MB", mainMemoryListener),
2622: "ja", "6MB"),
2623: Multilingual.mlnText (
2624: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00800000, "8MB", mainMemoryListener),
2625: "ja", "8MB"),
2626: Multilingual.mlnText (
2627: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00a00000, "10MB", mainMemoryListener),
2628: "ja", "10MB"),
2629: Multilingual.mlnText (
2630: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00c00000, "12MB", mainMemoryListener),
2631: "ja", "12MB"),
2632: ComponentFactory.createHorizontalSeparator (),
2633: Multilingual.mlnText (
2634: ComponentFactory.createCheckBoxMenuItem (MainMemory.mmrMemorySaveOn, "Save contents on exit", mainMemoryListener),
2635: "ja", "終了時に内容を保存する"),
2636: SRAM.smrModifyMemorySizeMenuItem
2637: ),
2638: "ja", "メインメモリ");
2639:
2640:
2641: ActionListener highMemoryListener = new ActionListener () {
2642: @Override public void actionPerformed (ActionEvent ae) {
2643: Object source = ae.getSource ();
2644: String command = ae.getActionCommand ();
2645: switch (command) {
2646: case "None":
2647: busHighMemorySize = 0 << 20;
2648: break;
2649: case "16MB":
2650: busHighMemorySize = 16 << 20;
2651: break;
2652: case "Save contents on exit":
2653: busHighMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2654: break;
2655: }
2656: }
2657: };
2658: ButtonGroup highMemoryGroup = new ButtonGroup ();
2659: JMenu highMemoryMenu = Multilingual.mlnText (
2660: ComponentFactory.createMenu (
2661: "High memory on X68030/Xellent30",
2662: Multilingual.mlnText (
2663: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 0 << 20, "None", highMemoryListener),
2664: "ja", "なし"),
2665: Multilingual.mlnText (
2666: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 16 << 20, "16MB", highMemoryListener),
2667: "ja", "16MB"),
2668: ComponentFactory.createHorizontalSeparator (),
2669: Multilingual.mlnText (
2670: ComponentFactory.createCheckBoxMenuItem (busHighMemorySaveOn, "Save contents on exit", highMemoryListener),
2671: "ja", "終了時に内容を保存する")
2672: ),
2673: "ja", "X68030/Xellent30 のハイメモリ");
2674:
2675:
2676: ActionListener localMemoryListener = new ActionListener () {
2677: @Override public void actionPerformed (ActionEvent ae) {
2678: Object source = ae.getSource ();
2679: String command = ae.getActionCommand ();
2680: switch (command) {
2681: case "None":
2682: busLocalMemorySize = 0 << 20;
2683: break;
2684: case "16MB":
2685: busLocalMemorySize = 16 << 20;
2686: break;
2687: case "32MB":
2688: busLocalMemorySize = 32 << 20;
2689: break;
2690: case "64MB":
2691: busLocalMemorySize = 64 << 20;
2692: break;
2693: case "128MB":
2694: busLocalMemorySize = 128 << 20;
2695: break;
2696: case "256MB":
2697: busLocalMemorySize = 256 << 20;
2698: break;
2699: case "384MB":
2700: busLocalMemorySize = 384 << 20;
2701: break;
2702: case "512MB":
2703: busLocalMemorySize = 512 << 20;
2704: break;
2705: case "768MB":
2706: busLocalMemorySize = 768 << 20;
2707: break;
2708: case "Save contents on exit":
2709: busLocalMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
2710: break;
2711: case "Available on X68000":
2712: busHimem68000 = ((JCheckBoxMenuItem) source).isSelected ();
2713: break;
2714: case "Available on X68030/Xellent30":
2715: busHighMemory060turboOn = ((JCheckBoxMenuItem) source).isSelected ();
2716: break;
2717: }
2718: }
2719: };
2720: ButtonGroup localMenoryGroup = new ButtonGroup ();
2721: JMenu localMemoryMenu = Multilingual.mlnText (
2722: ComponentFactory.createMenu (
2723: "High memory on 060turbo",
2724: Multilingual.mlnText (
2725: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 0 << 20, "None", localMemoryListener),
2726: "ja", "なし"),
2727: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 16 << 20, "16MB", localMemoryListener),
2728: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 32 << 20, "32MB", localMemoryListener),
2729: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 64 << 20, "64MB", localMemoryListener),
2730: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 128 << 20, "128MB", localMemoryListener),
2731: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 256 << 20, "256MB", localMemoryListener),
2732: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 384 << 20, "384MB", localMemoryListener),
2733: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 512 << 20, "512MB", localMemoryListener),
2734: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 768 << 20, "768MB", localMemoryListener),
2735: ComponentFactory.createHorizontalSeparator (),
2736: Multilingual.mlnText (
2737: ComponentFactory.createCheckBoxMenuItem (busLocalMemorySaveOn, "Save contents on exit", localMemoryListener),
2738: "ja", "終了時に内容を保存する"),
2739: ComponentFactory.createHorizontalSeparator (),
2740: Multilingual.mlnText (
2741: ComponentFactory.createCheckBoxMenuItem (busHimem68000, "Available on X68000", localMemoryListener),
2742: "ja", "X68000 でも有効"),
2743: Multilingual.mlnText (
2744: ComponentFactory.createCheckBoxMenuItem (busHighMemory060turboOn, "Available on X68030/Xellent30", localMemoryListener),
2745: "ja", "X68030/Xellent30 でも有効")
2746: ),
2747: "ja", "060turbo のハイメモリ");
2748:
2749:
2750: ActionListener xellent30Listener = new ActionListener () {
2751: @Override public void actionPerformed (ActionEvent ae) {
2752: Object source = ae.getSource ();
2753: String command = ae.getActionCommand ();
2754: switch (command) {
2755: case "$00EC0000-$00EC3FFF":
2756: xt3DIPSW = 0;
2757: break;
2758: case "$00EC4000-$00EC7FFF":
2759: xt3DIPSW = 1;
2760: break;
2761: case "$00EC8000-$00ECBFFF":
2762: xt3DIPSW = 2;
2763: break;
2764: case "$00ECC000-$00ECFFFF":
2765: xt3DIPSW = 3;
2766: break;
2767: case "256KB":
2768: xt3MemorySizeRequest = 1 << 18;
2769: break;
2770: case "1MB":
2771: xt3MemorySizeRequest = 1 << 20;
2772: break;
2773: case "Save contents on exit":
2774: xt3MemorySave = ((JCheckBoxMenuItem) source).isSelected ();
2775: break;
2776: }
2777: }
2778: };
2779: ButtonGroup xellent30PortGroup = new ButtonGroup ();
2780: ButtonGroup xellent30SizeGroup = new ButtonGroup ();
2781: JMenu xellent30Menu = ComponentFactory.createMenu (
2782: "Xellent30",
2783: ComponentFactory.createRadioButtonMenuItem (
2784: xellent30PortGroup,
2785: xt3DIPSW == 0,
2786: "$00EC0000-$00EC3FFF",
2787: xellent30Listener),
2788: ComponentFactory.createRadioButtonMenuItem (
2789: xellent30PortGroup,
2790: xt3DIPSW == 1,
2791: "$00EC4000-$00EC7FFF",
2792: xellent30Listener),
2793: ComponentFactory.createRadioButtonMenuItem (
2794: xellent30PortGroup,
2795: xt3DIPSW == 2,
2796: "$00EC8000-$00ECBFFF",
2797: xellent30Listener),
2798: ComponentFactory.createRadioButtonMenuItem (
2799: xellent30PortGroup,
2800: xt3DIPSW == 3,
2801: "$00ECC000-$00ECFFFF",
2802: xellent30Listener),
2803: ComponentFactory.createHorizontalSeparator (),
2804: ComponentFactory.createRadioButtonMenuItem (
2805: xellent30SizeGroup,
2806: xt3MemorySizeRequest == 1 << 18,
2807: "256KB",
2808: xellent30Listener),
2809: ComponentFactory.createRadioButtonMenuItem (
2810: xellent30SizeGroup,
2811: xt3MemorySizeRequest == 1 << 20,
2812: "1MB",
2813: xellent30Listener),
2814: ComponentFactory.createHorizontalSeparator (),
2815: Multilingual.mlnText (
2816: ComponentFactory.createCheckBoxMenuItem (xt3MemorySave, "Save contents on exit", xellent30Listener),
2817: "ja", "終了時に内容を保存する")
2818: );
2819:
2820:
2821: JMenu rotationMenu = null;
2822: if (PNL_ROTATION_ON) {
2823: ActionListener rotationListener = new ActionListener () {
2824: @Override public void actionPerformed (ActionEvent ae) {
2825: String command = ae.getActionCommand ();
2826: switch (command) {
2827: case "No rotation (landscape)":
2828: pnlRotationMode = 0;
2829: pnlUpdateArrangement ();
2830: break;
2831: case "90-degree rotation (portrait)":
2832: pnlRotationMode = 1;
2833: pnlUpdateArrangement ();
2834: break;
2835: case "180-degree rotation":
2836: pnlRotationMode = 2;
2837: pnlUpdateArrangement ();
2838: break;
2839: case "270-degree rotation":
2840: pnlRotationMode = 3;
2841: pnlUpdateArrangement ();
2842: break;
2843: default:
2844: System.out.println ("unknown action command " + command);
2845: }
2846: }
2847: };
2848: ButtonGroup rotationGroup = new ButtonGroup ();
2849: rotationMenu = Multilingual.mlnText (
2850: ComponentFactory.createMenu (
2851: "Rotation",
2852: Multilingual.mlnText (
2853: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 0, "No rotation (landscape)", rotationListener),
2854: "ja", "回転なし (横画面)"),
2855: Multilingual.mlnText (
2856: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 1, "90-degree rotation (portrait)", rotationListener),
2857: "ja", "90 度回転 (縦画面)"),
2858: Multilingual.mlnText (
2859: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 2, "180-degree rotation", rotationListener),
2860: "ja", "180 度回転"),
2861: Multilingual.mlnText (
2862: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 3, "270-degree rotation", rotationListener),
2863: "ja", "270 度回転")
2864: ),
2865: "ja", "回転");
2866: }
2867:
2868:
2869: ActionListener aspectListener = new ActionListener () {
2870: @Override public void actionPerformed (ActionEvent ae) {
2871: String command = ae.getActionCommand ();
2872: int i = command.indexOf (',');
2873: int key = Integer.parseInt (command.substring (0, i));
2874: int value = Integer.parseInt (command.substring (i + 1));
2875: pnlAspectMap[key] = value;
2876: pnlUpdateAspectTable ();
2877: pnlUpdateArrangement ();
2878: }
2879: };
2880: JMenu aspectMenu = ComponentFactory.createMenu ("Aspect ratio");
2881: for (int key = 0; key < PNL_ASPECT_KEYS; key++) {
2882: if (key != 0) {
2883: aspectMenu.add (ComponentFactory.createHorizontalSeparator ());
2884: }
2885: ButtonGroup group = new ButtonGroup ();
2886: for (int value = 0; value < PNL_ASPECT_VALUES; value++) {
2887: aspectMenu.add (
2888: ComponentFactory.setText (
2889: ComponentFactory.createRadioButtonMenuItem (
2890: group,
2891: pnlAspectMap[key] == value,
2892: key + "," + value,
2893: aspectListener
2894: ),
2895: (PNL_ASPECT_MATRIX[key] == PNL_ASPECT_SCREEN_RATIO ?
2896: String.format ("%s %s (%.3f)",
2897: PNL_ASPECT_RESOLUTION_NAME[key],
2898: PNL_ASPECT_SCREEN_NAME[value],
2899: PNL_ASPECT_SCREEN_RATIO[value]) :
2900: String.format ("%s %s (%.3f) @ %s (%.3f)",
2901: PNL_ASPECT_RESOLUTION_NAME[key],
2902: PNL_ASPECT_SCREEN_NAME[value],
2903: PNL_ASPECT_SCREEN_RATIO[value],
2904: PNL_ASPECT_PIXEL_NAME[value],
2905: PNL_ASPECT_PIXEL_RATIO[value]))
2906: )
2907: );
2908: }
2909: }
2910: aspectMenu = Multilingual.mlnText (aspectMenu, "ja", "アスペクト比");
2911:
2912:
2913: ActionListener scanlineListener = new ActionListener () {
2914: @Override public void actionPerformed (ActionEvent ae) {
2915:
2916: String command = ae.getActionCommand ();
2917: switch (command) {
2918: case "Off":
2919: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.OFF;
2920: CRTC.crtAllStamp += 2;
2921: break;
2922: case "Weak":
2923: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.WEAK;
2924: CRTC.crtAllStamp += 2;
2925: break;
2926: case "Medium":
2927: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.MEDIUM;
2928: CRTC.crtAllStamp += 2;
2929: break;
2930: case "Strong":
2931: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.STRONG;
2932: CRTC.crtAllStamp += 2;
2933: break;
2934: case "Black":
2935: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.BLACK;
2936: CRTC.crtAllStamp += 2;
2937: break;
2938: }
2939: }
2940: };
2941: ButtonGroup scanlineGroup = new ButtonGroup ();
2942: JMenu scanlineMenu =
2943: Multilingual.mlnText (
2944: ComponentFactory.createMenu (
2945: "Scanline effect",
2946: Multilingual.mlnText (
2947: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.OFF, "Off", scanlineListener),
2948: "ja", "なし"),
2949: Multilingual.mlnText (
2950: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.WEAK, "Weak", scanlineListener),
2951: "ja", "弱"),
2952: Multilingual.mlnText (
2953: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.MEDIUM, "Medium", scanlineListener),
2954: "ja", "中"),
2955: Multilingual.mlnText (
2956: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.STRONG, "Strong", scanlineListener),
2957: "ja", "強"),
2958: Multilingual.mlnText (
2959: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.BLACK, "Black", scanlineListener),
2960: "ja", "黒")
2961: ),
2962: "ja", "走査線エフェクト");
2963:
2964:
2965: JTextField refreshRateTextField = ComponentFactory.createNumberField (pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate), 8);
2966: refreshRateTextField.addActionListener (
2967: new ActionListener () {
2968: @Override public void actionPerformed (ActionEvent ae) {
2969: JTextField textField = (JTextField) ae.getSource ();
2970: pnlRefreshRate = 0.0;
2971: String s = textField.getText ();
2972: if (!s.equals ("")) {
2973: double rate = 0.0;
2974: try {
2975: rate = Double.parseDouble (s);
2976: } catch (NumberFormatException nfe) {
2977: }
2978: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
2979: pnlRefreshRate = rate;
2980: } else {
2981: textField.setText ("");
2982: }
2983: }
2984: pnlFixedRate = pnlRefreshRate;
2985: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
2986: pnlFixedRate = pnlGetRefreshRate ();
2987: }
2988: CRTC.crtUpdateLength ();
2989: }
2990: });
2991:
2992: ButtonGroup unitGroup = new ButtonGroup ();
2993: ButtonGroup frameGroup = new ButtonGroup ();
2994: ButtonGroup hintGroup = new ButtonGroup ();
2995: ButtonGroup vgaGroup = new ButtonGroup ();
2996: ButtonGroup intermittentGroup = new ButtonGroup ();
2997: ButtonGroup sterescopicGroup = new ButtonGroup ();
2998: ButtonGroup soundInterpolationGroup = new ButtonGroup ();
2999: ButtonGroup adpcmInterpolationGroup = new ButtonGroup ();
3000: ButtonGroup adpcmOSCFreqGroup = new ButtonGroup ();
3001: ButtonGroup keyboardGroup = new ButtonGroup ();
3002: ButtonGroup spritesGroup = new ButtonGroup ();
3003:
3004:
3005: DecimalSpinner[] freqSpinner = new DecimalSpinner[3];
3006: ChangeListener freqListener = new ChangeListener () {
3007: @Override public void stateChanged (ChangeEvent ce) {
3008: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
3009: int i = spinner.getOption ();
3010: CRTC.crtFreqsRequest[i] = spinner.getIntValue ();
3011: }
3012: };
3013: for (int i = 0; i < 3; i++) {
3014: freqSpinner[i] = ComponentFactory.createDecimalSpinner (
3015: CRTC.crtFreqsRequest[i], CRTC.CRT_MIN_FREQ, CRTC.CRT_MAX_FREQ, 1000000, i, freqListener
3016: );
3017: }
3018: DecimalSpinner sprrasSpinner = ComponentFactory.createDecimalSpinner (
3019: SpriteScreen.sprSpritesPerRaster, 0, 1016, 1, 0,
3020: new ChangeListener () {
3021: @Override public void stateChanged (ChangeEvent ce) {
3022: SpriteScreen.sprSpritesPerRaster = ((DecimalSpinner) ce.getSource ()).getIntValue ();
3023: }
3024: });
3025: ActionListener modificationListener = new ActionListener () {
3026: @Override public void actionPerformed (ActionEvent ae) {
3027: Object source = ae.getSource ();
3028: String command = ae.getActionCommand ();
3029: switch (command) {
3030:
3031: case "Adjust to host refresh rate":
3032: pnlAdjustVsync = ((JCheckBoxMenuItem) source).isSelected ();
3033: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3034: pnlFixedRate = pnlGetRefreshRate ();
3035: }
3036: CRTC.crtUpdateLength ();
3037: break;
3038: case "* Reset to default values":
3039: for (int i = 0; i < 3; i++) {
3040: if (CRTC.crtFreqsRequest[i] != CRTC.CRT_DEFAULT_FREQS[i]) {
3041: CRTC.crtFreqsRequest[i] = CRTC.CRT_DEFAULT_FREQS[i];
3042: freqSpinner[i].setIntValue (CRTC.crtFreqsRequest[i]);
3043: }
3044: }
3045: break;
3046: case "1024-dot non-interlaced":
3047: CRTC.crtEleventhBitRequest = ((JCheckBoxMenuItem) source).isSelected ();
3048: break;
3049: case "Can write 0 to bit 0 of CRTC R00":
3050: CRTC.crtR00Bit0Zero = ((JCheckBoxMenuItem) source).isSelected ();
3051: break;
3052:
3053: case "Extended graphic screen":
3054: CRTC.crtExtendedGraphicRequest = ((JCheckBoxMenuItem) source).isSelected ();
3055: break;
3056:
3057: case "Spherical scrolling of text screen":
3058: CRTC.crtSetSphericalScrolling (((JCheckBoxMenuItem) source).isSelected ());
3059: break;
3060:
3061: case "128 sprites":
3062: SpriteScreen.sprNumberOfSpritesRequest = 128;
3063: break;
3064: case "256 sprites":
3065: SpriteScreen.sprNumberOfSpritesRequest = 256;
3066: break;
3067: case "504 sprites":
3068: SpriteScreen.sprNumberOfSpritesRequest = 512;
3069: break;
3070: case "1016 sprites":
3071: SpriteScreen.sprNumberOfSpritesRequest = 1024;
3072: break;
3073:
3074:
3075:
3076: case "4096 patterns":
3077: SpriteScreen.sprBankOnRequest = ((JCheckBoxMenuItem) source).isSelected ();
3078: break;
3079: case "Sprites displayed in 768x512":
3080: SpriteScreen.spr768x512Request = ((JCheckBoxMenuItem) source).isSelected ();
3081: break;
3082: case "BG1 displayed in 512x512":
3083: SpriteScreen.spr512bg1Request = ((JCheckBoxMenuItem) source).isSelected ();
3084: break;
3085: case "Row and column scroll":
3086: if (SpriteScreen.SPR_RC_SCROLL_ON) {
3087: SpriteScreen.sprRcScrollRequest = ((JCheckBoxMenuItem) source).isSelected ();
3088: }
3089: break;
3090: case "** Reset to default values":
3091: if (SpriteScreen.sprSpritesPerRaster != 32) {
3092: SpriteScreen.sprSpritesPerRaster = 32;
3093: sprrasSpinner.setIntValue (SpriteScreen.sprSpritesPerRaster);
3094: }
3095: break;
3096: }
3097: }
3098: };
3099: JMenu modificationMenu =
3100: Multilingual.mlnText (
3101: ComponentFactory.createMenu (
3102: "Modification",
3103: Multilingual.mlnText (
3104: ComponentFactory.createMenu (
3105: "Dot clock",
3106: Multilingual.mlnText (
3107: ComponentFactory.createCheckBoxMenuItem (pnlAdjustVsync, "Adjust to host refresh rate", modificationListener),
3108: "ja", "ホストのリフレッシュレートに合わせる"),
3109: ComponentFactory.createHorizontalBox (
3110: Box.createHorizontalStrut (20),
3111: refreshRateTextField,
3112: ComponentFactory.createLabel (" Hz"),
3113: Box.createHorizontalGlue ()
3114: ),
3115: ComponentFactory.createHorizontalSeparator (),
3116: ComponentFactory.createHorizontalBox (
3117: Box.createHorizontalStrut (20),
3118: Multilingual.mlnText (ComponentFactory.createLabel ("Dot clock oscillattor"), "ja", "ドットクロックオシレータ"),
3119: Box.createHorizontalGlue ()
3120: ),
3121: ComponentFactory.createHorizontalBox (
3122: Box.createHorizontalStrut (20),
3123: freqSpinner[0],
3124: ComponentFactory.createLabel (" Hz *"),
3125: Box.createHorizontalGlue ()
3126: ),
3127: ComponentFactory.createHorizontalBox (
3128: Box.createHorizontalStrut (20),
3129: freqSpinner[1],
3130: ComponentFactory.createLabel (" Hz *"),
3131: Box.createHorizontalGlue ()
3132: ),
3133: ComponentFactory.createHorizontalBox (
3134: Box.createHorizontalStrut (20),
3135: freqSpinner[2],
3136: ComponentFactory.createLabel (" Hz *"),
3137: Box.createHorizontalGlue ()
3138: ),
3139: Multilingual.mlnText (
3140: ComponentFactory.createMenuItem ("* Reset to default values", modificationListener),
3141: "ja", "* 初期値に戻す"),
3142: ComponentFactory.createHorizontalSeparator (),
3143: Multilingual.mlnText (
3144: ComponentFactory.createCheckBoxMenuItem (CRTC.crtEleventhBitRequest, "1024-dot non-interlaced", modificationListener),
3145: "ja", "1024 ドットノンインターレース"),
3146: Multilingual.mlnText (
3147: ComponentFactory.createCheckBoxMenuItem (CRTC.crtR00Bit0Zero, "Can write 0 to bit 0 of CRTC R00", modificationListener),
3148: "ja", "CRTC R00 のビット 0 に 0 を書き込める")
3149: ),
3150: "ja", "ドットクロック"),
3151: Multilingual.mlnText (
3152: ComponentFactory.createMenu (
3153: "Graphic screen",
3154: !CRTC.CRT_EXTENDED_GRAPHIC ? null : Multilingual.mlnText (
3155: ComponentFactory.createCheckBoxMenuItem (CRTC.crtExtendedGraphicRequest, "Extended graphic screen", modificationListener),
3156: "ja", "拡張グラフィック画面")
3157: ),
3158: "ja", "グラフィック画面"),
3159: Multilingual.mlnText (
3160: ComponentFactory.createMenu (
3161: "Text screen",
3162: Multilingual.mlnText (
3163: ComponentFactory.createCheckBoxMenuItem (CRTC.crtSphericalScrolling, "Spherical scrolling of text screen", modificationListener),
3164: "ja", "テキスト画面の球面スクロール")
3165: ),
3166: "ja", "テキスト画面"),
3167: Multilingual.mlnText (
3168: ComponentFactory.createMenu (
3169: "Sprite screen",
3170: Multilingual.mlnText (
3171: ComponentFactory.createRadioButtonMenuItem (
3172: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 128, "128 sprites", modificationListener),
3173: "ja", "128 枚のスプライト"),
3174: Multilingual.mlnText (
3175: ComponentFactory.createRadioButtonMenuItem (
3176: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 256, "256 sprites", modificationListener),
3177: "ja", "256 枚のスプライト"),
3178: Multilingual.mlnText (
3179: ComponentFactory.createRadioButtonMenuItem (
3180: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 512, "504 sprites", modificationListener),
3181: "ja", "504 枚のスプライト"),
3182: Multilingual.mlnText (
3183: ComponentFactory.createRadioButtonMenuItem (
3184: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 1024, "1016 sprites", modificationListener),
3185: "ja", "1016 枚のスプライト"),
3186:
3187:
3188:
3189:
3190: ComponentFactory.createHorizontalSeparator (),
3191: Multilingual.mlnText (
3192: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprBankOnRequest, "4096 patterns", modificationListener),
3193: "ja", "4096 個のパターン"),
3194: Multilingual.mlnText (
3195: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr768x512Request, "Sprites displayed in 768x512", modificationListener),
3196: "ja", "768x512 でスプライトを表示"),
3197: Multilingual.mlnText (
3198: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr512bg1Request, "BG1 displayed in 512x512", modificationListener),
3199: "ja", "512x512 で BG1 を表示"),
3200: !SpriteScreen.SPR_RC_SCROLL_ON ? null : Multilingual.mlnText (
3201: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprRcScrollRequest, "Row and column scroll", modificationListener),
3202: "ja", "行スクロールと列スクロール"),
3203: ComponentFactory.createHorizontalSeparator (),
3204: ComponentFactory.createHorizontalBox (
3205: Box.createHorizontalStrut (20),
3206: Multilingual.mlnText (ComponentFactory.createLabel ("Number of sprites per raster"), "ja", "ラスタあたりのスプライトの枚数"),
3207: Box.createHorizontalGlue ()
3208: ),
3209: ComponentFactory.createHorizontalBox (
3210: Box.createHorizontalStrut (20),
3211: sprrasSpinner,
3212: ComponentFactory.createLabel (" *"),
3213: Box.createHorizontalGlue ()
3214: ),
3215: Multilingual.mlnText (
3216: ComponentFactory.createMenuItem ("** Reset to default values", modificationListener),
3217: "ja", "** 初期値に戻す")
3218: ),
3219: "ja", "スプライト画面")
3220: ),
3221: "ja", "改造");
3222:
3223:
3224: mnbMenuBar = ComponentFactory.createMenuBar (
3225:
3226:
3227: mnbFileMenu = Multilingual.mlnText (
3228: ComponentFactory.createMenu (
3229: "File", 'F',
3230:
3231: FDC.fdcMenu,
3232:
3233: HDC.hdcMenu,
3234:
3235: SPC.spcMenu,
3236:
3237: HFS.hfsMenu,
3238: ComponentFactory.createHorizontalSeparator (),
3239: mnbQuitMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Quit", 'Q', MNB_MODIFIERS, listener), "ja", "終了")
3240: ),
3241: "ja", "ファイル"),
3242:
3243:
3244: mpuMenu,
3245:
3246:
3247: mnbDisplayMenu = Multilingual.mlnText (
3248: ComponentFactory.createMenu (
3249: "Display", 'D',
3250: mnbFullScreenMenuItem,
3251: mnbMaximizedMenuItem,
3252: mnbFitInWindowMenuItem,
3253: mnbFixedScaleMenuItem,
3254: ComponentFactory.createHorizontalBox (
3255: Box.createHorizontalStrut (20),
3256: pnlFixedSpinner,
3257: ComponentFactory.createLabel ("%"),
3258: Box.createHorizontalGlue ()
3259: ),
3260: ComponentFactory.createMenuItem ("50%", listener),
3261: ComponentFactory.createMenuItem ("75%", listener),
3262: ComponentFactory.createMenuItem ("100%", listener),
3263: ComponentFactory.createMenuItem ("150%", listener),
3264: ComponentFactory.createMenuItem ("200%", listener),
3265:
3266: rotationMenu,
3267:
3268: aspectMenu,
3269:
3270: Multilingual.mlnText (
3271: ComponentFactory.createMenu (
3272: "Interpolation algorithm",
3273: Multilingual.mlnText (
3274: ComponentFactory.createRadioButtonMenuItem (
3275: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
3276: "Nearest neighbor", listener),
3277: "ja", "最近傍補間"),
3278: Multilingual.mlnText (
3279: ComponentFactory.createRadioButtonMenuItem (
3280: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR,
3281: "Bilinear", listener),
3282: "ja", "線形補間"),
3283: Multilingual.mlnText (
3284: ComponentFactory.createRadioButtonMenuItem (
3285: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC,
3286: "Bicubic", listener),
3287: "ja", "三次補間")
3288: ),
3289: "ja", "補間アルゴリズム"),
3290:
3291: scanlineMenu,
3292: !PNL_USE_CANVAS ? null : Multilingual.mlnText (
3293: ComponentFactory.createCheckBoxMenuItem (pnlUseCanvasRequest, "Use canvas", listener),
3294: "ja", "キャンバスを使う"),
3295:
3296: !CRTC.CRT_ENABLE_INTERMITTENT ? null : Multilingual.mlnText (
3297: ComponentFactory.createMenu (
3298: "Intermittent drawing",
3299: Multilingual.mlnText (
3300: ComponentFactory.createRadioButtonMenuItem (
3301: intermittentGroup, CRTC.crtIntermittentInterval == 0, "Draw all changed pictures", listener),
3302: "ja", "変化した画像をすべて描画する"),
3303: Multilingual.mlnText (
3304: ComponentFactory.createRadioButtonMenuItem (
3305: intermittentGroup, CRTC.crtIntermittentInterval == 1, "Draw a changed picture once every two times", listener),
3306: "ja", "変化した画像を 2 回に 1 回描画する"),
3307: Multilingual.mlnText (
3308: ComponentFactory.createRadioButtonMenuItem (
3309: intermittentGroup, CRTC.crtIntermittentInterval == 2, "Draw a changed picture once every three times", listener),
3310: "ja", "変化した画像を 3 回に 1 回描画する"),
3311: Multilingual.mlnText (
3312: ComponentFactory.createRadioButtonMenuItem (
3313: intermittentGroup, CRTC.crtIntermittentInterval == 3, "Draw a changed picture once every four times", listener),
3314: "ja", "変化した画像を 4 回に 1 回描画する"),
3315: Multilingual.mlnText (
3316: ComponentFactory.createRadioButtonMenuItem (
3317: intermittentGroup, CRTC.crtIntermittentInterval == 4, "Draw a changed picture once every five times", listener),
3318: "ja", "変化した画像を 5 回に 1 回描画する")
3319: ),
3320: "ja", "間欠描画"),
3321:
3322: !PNL_STEREOSCOPIC_ON ? null : ComponentFactory.createHorizontalSeparator (),
3323: mnbStereoscopicMenuItem = !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3324: ComponentFactory.createCheckBoxMenuItem (pnlStereoscopicOn, "Stereoscopic viewing", 'T', listener),
3325: "ja", "立体視"),
3326: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3327: ComponentFactory.createMenu (
3328: "Stereoscopic settings",
3329: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3330: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3331: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING,
3332: "Naked-eye crossing", listener),
3333: "ja", "裸眼交差法"),
3334: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3335: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3336: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL,
3337: "Naked-eye parallel", listener),
3338: "ja", "裸眼平行法"),
3339: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3340: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3341: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE,
3342: "Side-by-side", listener),
3343: "ja", "サイドバイサイド"),
3344: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3345: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3346: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM,
3347: "Top-and-bottom", listener),
3348: "ja", "トップアンドボトム")
3349: ),
3350: "ja", "立体視設定"),
3351:
3352: ComponentFactory.createHorizontalSeparator (),
3353: GIFAnimation.gifStartRecordingMenuItem,
3354: GIFAnimation.gifSettingsMenu,
3355:
3356: ComponentFactory.createHorizontalSeparator (),
3357: modificationMenu,
3358:
3359: SpritePatternViewer.SPV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Sprite pattern viewer", listener), "ja", "スプライトパターンビュア") : null,
3360: ScreenModeTest.SMT_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Screen mode test", listener), "ja", "表示モードテスト") : null
3361: ),
3362: "ja", "画面"),
3363:
3364:
3365: mnbSoundMenu = ComponentFactory.setEnabled (
3366: Multilingual.mlnText (
3367: ComponentFactory.createMenu (
3368: "Sound", 'S',
3369: mnbPlayMenuItem = ComponentFactory.setEnabled (
3370: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (SoundSource.sndPlayOn, "Play", 'P', MNB_MODIFIERS, listener), "ja", "音声出力"),
3371: SoundSource.sndLine != null),
3372:
3373:
3374:
3375: ComponentFactory.createHorizontalBox (
3376: Box.createHorizontalGlue (),
3377: Multilingual.mlnText (ComponentFactory.createLabel ("Volume "), "ja", "音量 "),
3378: mnbVolumeLabel = ComponentFactory.createLabel (String.valueOf (SoundSource.sndVolume)),
3379: Box.createHorizontalGlue ()
3380: ),
3381:
3382:
3383: ComponentFactory.setPreferredSize (
3384: ComponentFactory.createHorizontalSlider (
3385: 0,
3386: SoundSource.SND_VOLUME_MAX,
3387: SoundSource.sndVolume,
3388: SoundSource.SND_VOLUME_STEP,
3389: 1,
3390: new ChangeListener () {
3391: @Override public void stateChanged (ChangeEvent ce) {
3392: SoundSource.sndSetVolume (((JSlider) ce.getSource ()).getValue ());
3393: }
3394: }),
3395: LnF.lnfFontSize * 18, LnF.lnfFontSize * 2 + 28),
3396: Multilingual.mlnText (
3397: ComponentFactory.createMenu (
3398: "Sound interpolation",
3399: Multilingual.mlnText (
3400: ComponentFactory.createRadioButtonMenuItem (
3401: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.THINNING_STEREO,
3402: "Sound thinning", listener),
3403: "ja", "音声 間引き"),
3404: Multilingual.mlnText (
3405: ComponentFactory.createRadioButtonMenuItem (
3406: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_STEREO,
3407: "Sound linear interpolation", listener),
3408: "ja", "音声 線形補間"),
3409: ComponentFactory.setEnabled (
3410: Multilingual.mlnText (
3411: ComponentFactory.createRadioButtonMenuItem (
3412: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000,
3413: "Sound piecewise-constant area interpolation", listener),
3414: "ja", "音声 区分定数面積補間"),
3415: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000),
3416: ComponentFactory.setEnabled (
3417: Multilingual.mlnText (
3418: ComponentFactory.createRadioButtonMenuItem (
3419: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000,
3420: "Sound linear area interpolation", listener),
3421: "ja", "音声 線形面積補間"),
3422: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000)
3423: ),
3424: "ja", "音声補間"),
3425: Multilingual.mlnText (ComponentFactory.createMenuItem ("Sound monitor", listener), "ja", "音声モニタ"),
3426:
3427: ComponentFactory.createHorizontalSeparator (),
3428:
3429: ComponentFactory.setEnabled (
3430: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (OPM.opmOutputMask != 0, "OPM output", listener), "ja", "OPM 出力"),
3431: SoundSource.sndLine != null),
3432: !OPMLog.OLG_ON ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("OPM log", listener), "ja", "OPM ログ"),
3433:
3434: ComponentFactory.createHorizontalSeparator (),
3435:
3436: ComponentFactory.setEnabled (
3437: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ADPCM.pcmOutputOn, "PCM output", listener), "ja", "PCM 出力"),
3438: SoundSource.sndLine != null),
3439: Multilingual.mlnText (
3440: ComponentFactory.createMenu (
3441: "PCM interpolation",
3442: Multilingual.mlnText (
3443: ComponentFactory.createRadioButtonMenuItem (
3444: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_CONSTANT,
3445: "PCM piecewise-constant interpolation", listener),
3446: "ja", "PCM 区分定数補間"),
3447: Multilingual.mlnText (
3448: ComponentFactory.createRadioButtonMenuItem (
3449: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_LINEAR,
3450: "PCM linear interpolation", listener),
3451: "ja", "PCM 線形補間"),
3452: Multilingual.mlnText (
3453: ComponentFactory.createRadioButtonMenuItem (
3454: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_HERMITE,
3455: "PCM hermite interpolation", listener),
3456: "ja", "PCM エルミート補間")
3457: ),
3458: "ja", "PCM 補間"),
3459: Multilingual.mlnText (
3460: ComponentFactory.createMenu (
3461: "PCM source oscillator frequency",
3462: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 0, "PCM 8MHz/4MHz", listener),
3463: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 1, "PCM 8MHz/16MHz", listener)
3464: ),
3465: "ja", "PCM 原発振周波数")
3466: ),
3467: "ja", "音声"),
3468: SoundSource.sndLine != null),
3469:
3470:
3471: mnbInputMenu = Multilingual.mlnText (
3472: ComponentFactory.createMenu (
3473: "Input", 'I',
3474: mnbPasteMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Paste", 'V', MNB_MODIFIERS, listener), "ja", "貼り付け"),
3475: CONDevice.conSettingsMenu,
3476: TextCopy.txcMakeMenuItem (),
3477: TextCopy.txcMakeSettingMenu (),
3478: ComponentFactory.createHorizontalSeparator (),
3479: mnbNoKeyboardMenuItem = Multilingual.mlnText (
3480: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, !Keyboard.kbdOn, "No keyboard", 'K', MNB_MODIFIERS, listener),
3481: "ja", "キーボードなし"),
3482: mnbStandardKeyboardMenuItem = Multilingual.mlnText (
3483: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_STANDARD_TYPE, "Standard keyboard", listener),
3484: "ja", "標準キーボード"),
3485: mnbCompactKeyboardMenuItem = Multilingual.mlnText (
3486: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_COMPACT_TYPE, "Compact keyboard", listener),
3487: "ja", "コンパクトキーボード"),
3488: Multilingual.mlnText (
3489: ComponentFactory.createCheckBoxMenuItem (pnlHideKeyboard, "Hide keyboard in full screen", listener),
3490: "ja", "全画面表示のときキーボードを隠す"),
3491: Multilingual.mlnText (ComponentFactory.createMenuItem ("Key assignments", listener), "ja", "キー割り当て"),
3492: ButtonFunction.bfnMakeMenuItem (),
3493: SRAM.smrRepeatDelayMenu,
3494: SRAM.smrRepeatIntervalMenu,
3495: !Keyboard.KBD_ZKEY_ON ? null : Keyboard.kbdZKeyMenu,
3496: ComponentFactory.createHorizontalSeparator (),
3497: Mouse.musSeamlessMouseCheckBox,
3498: Mouse.musFollowScrollCheckBox,
3499: Mouse.musCtrlRightCheckBox,
3500: Mouse.musEdgeAccelerationCheckBox,
3501: Mouse.musMouseCursorSpeedBox,
3502: Mouse.musSpeedSlider,
3503: Mouse.musHostsPixelUnitsCheckBox,
3504: ComponentFactory.createHorizontalSeparator (),
3505: Multilingual.mlnText (ComponentFactory.createMenuItem ("Joystick port settings", listener), "ja", "ジョイスティックポート設定")
3506: ),
3507: "ja", "入力"),
3508:
3509:
3510: mnbConfigMenu = Multilingual.mlnText (
3511: ComponentFactory.createMenu (
3512: "Config", 'G',
3513: Multilingual.mlnText (ComponentFactory.createMenuItem ("RS-232C and terminal", listener), "ja", "RS-232C とターミナル"),
3514: Multilingual.mlnText (
3515: ComponentFactory.createMenu (
3516: "Debug",
3517: Multilingual.mlnText (ComponentFactory.createMenuItem ("Console", listener), "ja", "コンソール"),
3518: Multilingual.mlnText (ComponentFactory.createMenuItem ("Register list", listener), "ja", "レジスタリスト"),
3519: Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble list", listener), "ja", "逆アセンブルリスト"),
3520: Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory dump list", listener), "ja", "メモリダンプリスト"),
3521: Multilingual.mlnText (ComponentFactory.createMenuItem ("Logical space monitor", listener), "ja", "論理空間モニタ"),
3522: Multilingual.mlnText (ComponentFactory.createMenuItem ("Physical space monitor", listener), "ja", "物理空間モニタ"),
3523: ATCMonitor.ACM_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Address translation caches monitor", listener), "ja", "アドレス変換キャッシュモニタ") : null,
3524: BranchLog.BLG_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Branch log", listener), "ja", "分岐ログ") : null,
3525: ProgramFlowVisualizer.PFV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Program flow visualizer", listener), "ja", "プログラムフロービジュアライザ") : null,
3526: RasterBreakPoint.RBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Raster break point", listener), "ja", "ラスタブレークポイント") : null,
3527: DataBreakPoint.DBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Data break point", listener), "ja", "データブレークポイント") : null,
3528: RootPointerList.RTL_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Root pointer list", listener), "ja", "ルートポインタリスト") : null,
3529: ComponentFactory.createHorizontalSeparator (),
3530: SRAM.smrRomdbMenu
3531: ),
3532: "ja", "デバッグ"),
3533: SRAM.smrBootMenu,
3534: mainMemoryMenu,
3535: highMemoryMenu,
3536: localMemoryMenu,
3537: xellent30Menu,
3538: ComponentFactory.createHorizontalSeparator (),
3539: ComponentFactory.createMenu (
3540: "RTC",
3541: Multilingual.mlnText (
3542: ComponentFactory.createMenuItem ("Adjust clock to host", listener),
3543: "ja", "時計をホストに合わせる")
3544: ),
3545: SRAM.smrMenu,
3546: Settings.sgsMenu,
3547: ComponentFactory.createHorizontalSeparator (),
3548: Multilingual.mlnText (ComponentFactory.createMenuItem ("Printer", listener), "ja", "プリンタ"),
3549: ROM.romMenu,
3550: Multilingual.mlnText (
3551: ComponentFactory.createMenu (
3552: "Miscellaneous",
3553: SlowdownTest.sdtCheckBoxMenuItem,
3554: SlowdownTest.sdtBox,
3555: Multilingual.mlnText (
3556: ComponentFactory.createCheckBoxMenuItem (Mouse.musOutputButtonStatus, "Mouse button status", listener),
3557: "ja", "マウスのボタンの状態"),
3558: Z8530.SCC_DEBUG_ON ? Z8530.sccDebugMenu : null
3559: ),
3560: "ja", "その他"),
3561: ComponentFactory.createHorizontalSeparator (),
3562: Multilingual.mlnText (
3563: ComponentFactory.createMenuItem ("Java runtime environment information", listener),
3564: "ja", "Java 実行環境の情報"),
3565: Multilingual.mlnText (
3566: ComponentFactory.createMenuItem ("Version information", listener),
3567: "ja", "バージョン情報"),
3568: Multilingual.mlnText (
3569: ComponentFactory.createMenu (
3570: "License",
3571: Multilingual.mlnText (ComponentFactory.createMenuItem ("XEiJ License", listener), "ja", "XEiJ 使用許諾条件"),
3572: Multilingual.mlnText (ComponentFactory.createMenuItem ("FSHARP License", listener), "ja", "FSHARP 許諾条件"),
3573: Multilingual.mlnText (ComponentFactory.createMenuItem ("ymfm License", listener), "ja", "ymfm License"),
3574: Multilingual.mlnText (ComponentFactory.createMenuItem ("jSerialComm License", listener), "ja", "jSerialComm License")
3575: ),
3576: "ja", "使用許諾条件")
3577: ),
3578: "ja", "設定"),
3579:
3580: mnbMakeLanguageMenu (),
3581:
3582:
3583: Box.createHorizontalGlue (),
3584: ComponentFactory.createVerticalBox (
3585: Box.createVerticalGlue (),
3586: Indicator.indBox,
3587: Box.createVerticalGlue ()
3588: ),
3589: Box.createHorizontalGlue ()
3590:
3591: );
3592: }
3593:
3594:
3595:
3596:
3597:
3598:
3599:
3600: public static boolean frmIsActive;
3601:
3602:
3603: public static JFrame frmFrame;
3604: public static int frmMarginWidth;
3605: public static int frmMarginHeight;
3606: public static Dimension frmMinimumSize;
3607:
3608:
3609: public static GraphicsDevice frmScreenDevice;
3610:
3611:
3612: public static DropTarget frmDropTarget;
3613:
3614:
3615:
3616: public static void frmInit () {
3617: frmIsActive = false;
3618: frmScreenDevice = GraphicsEnvironment.getLocalGraphicsEnvironment ().getDefaultScreenDevice ();
3619: pnlIsFullScreenSupported = frmScreenDevice.isFullScreenSupported ();
3620: }
3621:
3622:
3623:
3624: public static void frmMake () {
3625:
3626:
3627: frmFrame = ComponentFactory.createRestorableFrame (
3628: Settings.SGS_FRM_FRAME_KEY,
3629: PRG_TITLE + " version " + PRG_VERSION,
3630: mnbMenuBar,
3631: pnlPanel);
3632: frmUpdateTitle ();
3633: frmFrame.setIconImage (LnF.LNF_ICON_IMAGE_48);
3634: frmFrame.setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);
3635:
3636:
3637:
3638:
3639: frmMarginWidth = frmFrame.getWidth () - pnlPanel.getWidth ();
3640: frmMarginHeight = frmFrame.getHeight () - pnlPanel.getHeight ();
3641: frmMinimumSize = new Dimension (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
3642: frmFrame.setMinimumSize (frmMinimumSize);
3643:
3644:
3645:
3646: frmDropTarget = new DropTarget (pnlPanel, DnDConstants.ACTION_COPY, new DropTargetAdapter () {
3647: @Override public void dragOver (DropTargetDragEvent dtde) {
3648: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
3649: dtde.acceptDrag (DnDConstants.ACTION_COPY);
3650: return;
3651: }
3652: dtde.rejectDrag ();
3653: }
3654: @Override public void drop (DropTargetDropEvent dtde) {
3655: try {
3656: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
3657: dtde.acceptDrop (DnDConstants.ACTION_COPY);
3658: boolean reset = false;
3659: int fdu0 = -1;
3660: int fdu = 0;
3661: int hdu0 = -1;
3662: int hdu = 0;
3663: int scu0 = -1;
3664: int scu = 0;
3665: int hfu0 = -1;
3666: int hfu = 0;
3667: for (Object o : (java.util.List) dtde.getTransferable ().getTransferData (DataFlavor.javaFileListFlavor)) {
3668: if (o instanceof File) {
3669: File file = (File) o;
3670: if (file.isFile ()) {
3671: if (FDC.fdcFileFilter.accept (file)) {
3672: if (fdu < FDC.FDC_MAX_UNITS &&
3673: FDC.fdcUnitArray[fdu].insert (file.getPath (), false)) {
3674: if (fdu0 < 0) {
3675: fdu0 = fdu;
3676: }
3677: fdu++;
3678: continue;
3679: }
3680: }
3681: if (HDC.hdcFileFilter.accept (file)) {
3682: if (hdu < 16 &&
3683: HDC.hdcUnitArray[hdu].insert (file.getPath (), false)) {
3684: if (hdu0 < 0) {
3685: hdu0 = hdu;
3686: }
3687: hdu++;
3688: continue;
3689: }
3690: }
3691: if (SPC.spcFileFilter.accept (file)) {
3692: if (scu < 16 &&
3693: SPC.spcUnitArray[scu].insert (file.getPath (), false)) {
3694: if (scu0 < 0) {
3695: scu0 = scu;
3696: }
3697: scu++;
3698: continue;
3699: }
3700: }
3701: }
3702: if (HFS.hfsFileFilter.accept (file)) {
3703: if (hfu < HFS.HFS_MAX_UNITS &&
3704: HFS.hfsUnitArray[hfu].insert (file.getPath (), false)) {
3705: if (hfu0 < 0) {
3706: hfu0 = hfu;
3707: }
3708: hfu++;
3709: continue;
3710: }
3711: }
3712: }
3713: reset = false;
3714: }
3715: dtde.dropComplete (true);
3716: if (reset) {
3717: if (fdu0 >= 0) {
3718: mpuReset (0x9070 | fdu0 << 8, -1);
3719: } else if (hdu0 >= 0) {
3720: mpuReset (0x8000 | hdu0 << 8, -1);
3721: } else if (scu0 >= 0) {
3722: mpuReset (0xa000, SPC.SPC_HANDLE_EX + (scu0 << 2));
3723: } else if (hfu0 >= 0) {
3724: HFS.hfsBootUnit = hfu0;
3725: mpuReset (0xa000, HFS.HFS_BOOT_HANDLE);
3726: }
3727: }
3728: return;
3729: }
3730: } catch (UnsupportedFlavorException ufe) {
3731:
3732: } catch (IOException ioe) {
3733:
3734: }
3735: dtde.rejectDrop();
3736: }
3737: });
3738:
3739: }
3740:
3741:
3742:
3743: public static void frmUpdateTitle () {
3744: frmFrame.setTitle ((currentAccelerator == ACCELERATOR_HYBRID ? "X68000 Hybrid" :
3745: currentModel.getName () +
3746: (currentAccelerator == ACCELERATOR_XELLENT30 ? " with Xellent30" :
3747: currentAccelerator == ACCELERATOR_060TURBO ? " with 060turbo" :
3748: currentAccelerator == ACCELERATOR_060TURBOPRO ? " with 060turboPRO" : "")) +
3749: " - " + PRG_TITLE + " version " + PRG_VERSION);
3750: }
3751:
3752:
3753:
3754: public static void frmStart () {
3755:
3756:
3757:
3758:
3759:
3760:
3761:
3762:
3763: ComponentFactory.addListener (
3764: frmFrame,
3765: new WindowAdapter () {
3766: @Override public void windowActivated (WindowEvent we) {
3767: frmIsActive = true;
3768: }
3769: @Override public void windowClosing (WindowEvent we) {
3770: prgTini ();
3771: }
3772: @Override public void windowDeactivated (WindowEvent we) {
3773: frmIsActive = false;
3774:
3775: }
3776: @Override public void windowOpened (WindowEvent we) {
3777: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3778: pnlFixedRate = pnlGetRefreshRate ();
3779: }
3780: }
3781: });
3782:
3783:
3784:
3785:
3786: ComponentFactory.addListener (
3787: frmFrame,
3788: new ComponentAdapter () {
3789: @Override public void componentMoved (ComponentEvent ce) {
3790: Point p = pnlPanel.getLocationOnScreen ();
3791: pnlGlobalX = p.x;
3792: pnlGlobalY = p.y;
3793: }
3794: @Override public void componentResized (ComponentEvent ce) {
3795: Point p = pnlPanel.getLocationOnScreen ();
3796: pnlGlobalX = p.x;
3797: pnlGlobalY = p.y;
3798: }
3799: });
3800:
3801: }
3802:
3803:
3804:
3805:
3806:
3807:
3808: public static BufferedImage clpClipboardImage;
3809: public static String clpClipboardString;
3810: public static Clipboard clpClipboard;
3811: public static Transferable clpImageContents;
3812: public static Transferable clpStringContents;
3813: public static ClipboardOwner clpClipboardOwner;
3814: public static boolean clpIsClipboardOwner;
3815:
3816:
3817:
3818:
3819: public static void clpMake () {
3820: Toolkit toolkit = Toolkit.getDefaultToolkit ();
3821: clpClipboard = null;
3822: try {
3823: clpClipboard = toolkit.getSystemClipboard ();
3824: } catch (Exception e) {
3825: return;
3826: }
3827: clpClipboardImage = null;
3828: clpClipboardString = null;
3829: clpImageContents = new Transferable () {
3830: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
3831: if (flavor == DataFlavor.imageFlavor) {
3832: return clpClipboardImage;
3833: } else {
3834: throw new UnsupportedFlavorException (flavor);
3835: }
3836: }
3837: public DataFlavor[] getTransferDataFlavors () {
3838: return new DataFlavor[] { DataFlavor.imageFlavor };
3839: }
3840: public boolean isDataFlavorSupported (DataFlavor flavor) {
3841: return flavor == DataFlavor.imageFlavor;
3842: }
3843: };
3844: clpStringContents = new Transferable () {
3845: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
3846: if (flavor == DataFlavor.stringFlavor) {
3847: return clpClipboardString;
3848: } else {
3849: throw new UnsupportedFlavorException (flavor);
3850: }
3851: }
3852: public DataFlavor[] getTransferDataFlavors () {
3853: return new DataFlavor[] { DataFlavor.stringFlavor };
3854: }
3855: public boolean isDataFlavorSupported (DataFlavor flavor) {
3856: return flavor == DataFlavor.stringFlavor;
3857: }
3858: };
3859: clpIsClipboardOwner = false;
3860:
3861:
3862: clpClipboardOwner = new ClipboardOwner () {
3863: @Override public void lostOwnership (Clipboard clipboard, Transferable contents) {
3864: clpIsClipboardOwner = false;
3865: }
3866: };
3867:
3868:
3869: clpClipboard.addFlavorListener (new FlavorListener () {
3870: @Override public void flavorsChanged (FlavorEvent fe) {
3871: boolean available = false;
3872: try {
3873: available = clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor);
3874: } catch (IllegalStateException ise) {
3875: }
3876: if (mnbPasteMenuItem != null) {
3877: mnbPasteMenuItem.setEnabled (available);
3878: }
3879: }
3880: });
3881: if (!clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor)) {
3882: if (mnbPasteMenuItem != null) {
3883: mnbPasteMenuItem.setEnabled (false);
3884: }
3885: }
3886: }
3887:
3888:
3889:
3890: public static void clpCopy (String s) {
3891: if (clpClipboard != null && s != null) {
3892: clpClipboardString = s;
3893: try {
3894: clpClipboard.setContents (clpStringContents, clpClipboardOwner);
3895: clpIsClipboardOwner = true;
3896: } catch (Exception e) {
3897: return;
3898: }
3899: }
3900: }
3901:
3902:
3903:
3904:
3905:
3906:
3907:
3908:
3909:
3910:
3911:
3912:
3913:
3914:
3915:
3916:
3917:
3918:
3919:
3920:
3921:
3922:
3923:
3924: public static int xt3DIPSWRequest;
3925: public static int xt3DIPSW;
3926: public static int xt3PortAddress;
3927:
3928:
3929: public static int xt3MemorySizeRequest;
3930: public static int xt3MemorySize;
3931: public static boolean xt3MemoryEnabled;
3932: public static int xt3MemoryPosition;
3933: public static int xt3MemoryStart;
3934: public static final byte[] xt3MemoryArray = new byte[1 << 20];
3935: public static boolean xt3MemorySave;
3936:
3937:
3938: public static int xt3SavedPC;
3939: public static final int[] xt3SavedRn = new int[16];
3940:
3941:
3942: public static void xt3Init () {
3943:
3944:
3945: xt3DIPSWRequest = Math.max (0, Math.min (3, Settings.sgsGetInt ("xt3dipsw")));
3946: xt3DIPSW = xt3DIPSWRequest;
3947:
3948:
3949: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
3950:
3951:
3952: int memoryKB = Settings.sgsGetInt ("xt3memorykb");
3953: if (!(memoryKB == 1 << 8 || memoryKB == 1 << 10)) {
3954: memoryKB = 1 << 8;
3955: }
3956: xt3MemorySizeRequest = memoryKB << 10;
3957: xt3MemorySize = xt3MemorySizeRequest;
3958:
3959:
3960: xt3MemoryEnabled = false;
3961:
3962:
3963: xt3MemoryPosition = 11 << 20;
3964:
3965:
3966: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
3967:
3968:
3969:
3970: byte[] memoryArray = Settings.sgsGetData ("xt3memorydata");
3971: Arrays.fill (xt3MemoryArray,
3972: (byte) 0);
3973: if (memoryArray.length != 0) {
3974: System.arraycopy (memoryArray, 0,
3975: xt3MemoryArray, 0,
3976: Math.min (memoryArray.length, xt3MemoryArray.length));
3977: if (memoryArray.length < xt3MemoryArray.length) {
3978: Arrays.fill (xt3MemoryArray,
3979: memoryArray.length,
3980: xt3MemoryArray.length,
3981: (byte) 0);
3982: }
3983: }
3984:
3985:
3986: xt3MemorySave = Settings.sgsGetOnOff ("xt3memorysave");
3987:
3988:
3989: xt3SavedPC = 0;
3990:
3991: Arrays.fill (xt3SavedRn, 0);
3992:
3993: xt3Reset ();
3994: }
3995:
3996:
3997: public static void xt3Tini () {
3998:
3999:
4000: Settings.sgsPutInt ("xt3dipsw", xt3DIPSW);
4001:
4002:
4003: Settings.sgsPutInt ("xt3memorykb", xt3MemorySizeRequest >> 10);
4004:
4005:
4006: boolean zero = true;
4007: if (xt3MemorySave) {
4008: for (int i = 0; i < 1 << 20; i++) {
4009: if (xt3MemoryArray[i] != 0) {
4010: zero = false;
4011: break;
4012: }
4013: }
4014: }
4015: Settings.sgsCurrentMap.put ("xt3memorydata",
4016: zero ? "" :
4017: ByteArray.byaEncodeBase64 (ByteArray.byaEncodeGzip (xt3MemoryArray, 0, 1 << 20)));
4018:
4019:
4020: Settings.sgsPutOnOff ("xt3memorysave", xt3MemorySave);
4021:
4022: }
4023:
4024:
4025: public static void xt3Reset () {
4026:
4027:
4028: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4029:
4030:
4031: xt3MemorySize = xt3MemorySizeRequest;
4032:
4033:
4034: xt3MemoryEnabled = false;
4035:
4036:
4037: xt3MemoryPosition = 11 << 20;
4038:
4039:
4040: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4041:
4042:
4043: xt3SavedPC = 0;
4044: Arrays.fill (xt3SavedRn, 0);
4045:
4046: }
4047:
4048:
4049: public static int xt3PortRead () {
4050: return (currentIsSecond ? 4 : 0) | (xt3MemoryEnabled ? 2 : 0) | (xt3MemoryPosition == 11 << 20 ? 0 : 1);
4051: }
4052:
4053:
4054: public static void xt3PortWrite (int d) {
4055: boolean nextIsSecond = (d & 4) != 0;
4056: boolean memoryEnabled = (d & 2) != 0;
4057: int memoryPosition = (d & 1) == 0 ? 11 << 20 : 15 << 20;
4058:
4059: if (xt3MemoryEnabled != memoryEnabled ||
4060: xt3MemoryPosition != memoryPosition) {
4061: if (xt3MemoryEnabled) {
4062: if (xt3MemoryPosition == 11 << 20) {
4063: if (MainMemory.mmrMemorySizeCurrent < 12 << 20) {
4064: busSuper (MemoryMappedDevice.MMD_NUL, (12 << 20) - xt3MemorySize, 12 << 20);
4065: } else {
4066: busUser (MemoryMappedDevice.MMD_MMR, (12 << 20) - xt3MemorySize, 12 << 20);
4067: }
4068: } else {
4069: busSuper (MemoryMappedDevice.MMD_ROM, (16 << 20) - xt3MemorySize, 16 << 20);
4070: }
4071: }
4072: xt3MemoryEnabled = memoryEnabled;
4073: xt3MemoryPosition = memoryPosition;
4074: if (xt3MemoryEnabled) {
4075: if (xt3MemoryPosition == 11 << 20) {
4076: busUser (MemoryMappedDevice.MMD_XTM, (12 << 20) - xt3MemorySize, 12 << 20);
4077: } else {
4078: busUser (MemoryMappedDevice.MMD_XTM, (16 << 20) - xt3MemorySize, 16 << 20);
4079: }
4080: }
4081: }
4082:
4083: if (currentIsSecond != nextIsSecond) {
4084:
4085: if (nextIsSecond) {
4086:
4087:
4088: xt3SavedPC = regPC;
4089: System.arraycopy (regRn, 0, xt3SavedRn, 0, 16);
4090:
4091:
4092: if (mpuTask != null) {
4093: mpuClockLimit = 0L;
4094: System.out.println (Multilingual.mlnJapanese ?
4095: Model.MPU_NAMES[currentFirstMPU] + " を停止します" :
4096: Model.MPU_NAMES[currentFirstMPU] + " stops");
4097: mpuTask.cancel ();
4098: mpuTask = null;
4099: }
4100:
4101:
4102: tmrTimer.schedule (new TimerTask () {
4103: @Override public void run () {
4104:
4105:
4106: currentIsSecond = true;
4107: currentMPU = currentSecondMPU;
4108: mpuSetCurrentClock (specifiedSecondClock);
4109:
4110: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
4111: MC68EC030.m30DivZeroVFlag = false;
4112: }
4113:
4114: RegisterList.drpSetMPU ();
4115: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4116: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4117: MC68060.mmuReset ();
4118:
4119: mpuIgnoreAddressError = true;
4120: fpuBox = fpuMotherboardCoprocessor;
4121: fpuBox.epbReset ();
4122: fpuFPn = fpuBox.epbFPn;
4123: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
4124: mpuSetWait ();
4125:
4126: regSRT1 = regSRT0 = 0;
4127: regSRS = REG_SR_S;
4128: regSRM = 0;
4129: regSRI = REG_SR_I;
4130: regCCR = 0;
4131: Arrays.fill (regRn, 0);
4132:
4133: regRn[15] = MainMemory.mmrRls (0x00000000);
4134: regPC = MainMemory.mmrRls (0x00000004);
4135:
4136: mpuIMR = 0;
4137: mpuIRR = 0;
4138: if (MC68901.MFP_DELAYED_INTERRUPT) {
4139: mpuDIRR = 0;
4140: }
4141: mpuISR = 0;
4142:
4143: mpuStart ();
4144: }
4145: }, TMR_DELAY);
4146:
4147: } else {
4148:
4149:
4150: if (mpuTask != null) {
4151: mpuClockLimit = 0L;
4152: System.out.println (Multilingual.mlnJapanese ? "MC68EC030 を停止します" : "MC68EC030 stops");
4153: mpuTask.cancel ();
4154: mpuTask = null;
4155: }
4156:
4157:
4158: tmrTimer.schedule (new TimerTask () {
4159: @Override public void run () {
4160:
4161:
4162: currentIsSecond = false;
4163: currentMPU = currentFirstMPU;
4164: mpuSetCurrentClock (specifiedFirstClock);
4165:
4166: RegisterList.drpSetMPU ();
4167: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4168: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4169: MC68060.mmuReset ();
4170:
4171: mpuIgnoreAddressError = false;
4172: mpuCacheOn = false;
4173: mpuSetWait ();
4174:
4175: regSRT1 = regSRT0 = 0;
4176: regSRS = REG_SR_S;
4177: regSRM = 0;
4178: regSRI = REG_SR_I;
4179: regCCR = 0;
4180:
4181: regPC = xt3SavedPC;
4182: System.arraycopy (xt3SavedRn, 0, regRn, 0, 16);
4183:
4184: mpuIMR = 0;
4185: mpuIRR = 0;
4186: if (MC68901.MFP_DELAYED_INTERRUPT) {
4187: mpuDIRR = 0;
4188: }
4189: mpuISR = 0;
4190:
4191: mpuStart ();
4192: }
4193: }, TMR_DELAY);
4194:
4195: }
4196: }
4197: }
4198:
4199:
4200:
4201:
4202:
4203:
4204: public static JMenu mdlMenu;
4205:
4206: public static JRadioButtonMenuItem mdlShodaiMenuItem;
4207: public static JRadioButtonMenuItem mdlACEMenuItem;
4208: public static JRadioButtonMenuItem mdlEXPERTMenuItem;
4209: public static JRadioButtonMenuItem mdlPROMenuItem;
4210: public static JRadioButtonMenuItem mdlSUPERMenuItem;
4211: public static JRadioButtonMenuItem mdlXVIMenuItem;
4212: public static JRadioButtonMenuItem mdlXellent30MenuItem;
4213: public static JRadioButtonMenuItem mdlCompactMenuItem;
4214: public static JRadioButtonMenuItem mdlHybridMenuItem;
4215: public static JRadioButtonMenuItem mdl060turboPROMenuItem;
4216: public static JRadioButtonMenuItem mdlX68030MenuItem;
4217: public static JRadioButtonMenuItem mdl030CompactMenuItem;
4218: public static JRadioButtonMenuItem mdl060turboMenuItem;
4219: public static JCheckBoxMenuItem mdlMC68010MenuItem;
4220:
4221: public static JMenu coproFPUMenu;
4222:
4223:
4224: public static final int ACCELERATOR_HYBRID = 1;
4225: public static final int ACCELERATOR_XELLENT30 = 2;
4226: public static final int ACCELERATOR_060TURBO = 3;
4227: public static final int ACCELERATOR_060TURBOPRO = 4;
4228: public static final double MHZ_HYBRID_VALUE = 100.0 / 3.0;
4229: public static final String MHZ_HYBRID_STRING = "33.3";
4230: public static final double MHZ_060TURBO_VALUE = 50.0;
4231: public static final String MHZ_060TURBO_STRING = "50";
4232:
4233:
4234:
4235: public static Model specifiedModel;
4236: public static int specifiedAccelerator;
4237: public static boolean mpu010;
4238:
4239: public static boolean specifiedIsSecond;
4240: public static int specifiedFirstMPU;
4241: public static int specifiedSecondMPU;
4242: public static int specifiedMPU;
4243:
4244: public static double specifiedFirstClock;
4245: public static double specifiedSecondClock;
4246: public static double specifiedClock;
4247:
4248: public static int specifiedCopro0;
4249: public static int specifiedCopro1;
4250: public static int specifiedCopro2;
4251: public static int specifiedOnchipFPU;
4252:
4253:
4254:
4255: public static Model currentModel;
4256: public static int currentAccelerator;
4257:
4258: public static boolean currentIsSecond;
4259: public static int currentFirstMPU;
4260: public static int currentSecondMPU;
4261: public static int currentMPU;
4262:
4263:
4264: public static int currentCopro0;
4265: public static int currentCopro1;
4266: public static int currentCopro2;
4267: public static int currentOnchipFPU;
4268:
4269:
4270:
4271: public static void mdlInit () {
4272:
4273:
4274: specifiedModel = Model.COMPACT;
4275: specifiedAccelerator = ACCELERATOR_HYBRID;
4276: mpu010 = Settings.sgsGetOnOff ("mpu010");
4277: {
4278: String paramModel = Settings.sgsGetString ("model");
4279: switch (paramModel.toLowerCase ()) {
4280: case "":
4281: case "none":
4282: case "hybrid":
4283: specifiedModel = Model.COMPACT;
4284: specifiedAccelerator = ACCELERATOR_HYBRID;
4285: break;
4286: case "xellent30":
4287: specifiedModel = Model.XVI;
4288: specifiedAccelerator = ACCELERATOR_XELLENT30;
4289: break;
4290: case "060turbo":
4291: specifiedModel = Model.X68030;
4292: specifiedAccelerator = ACCELERATOR_060TURBO;
4293: break;
4294: case "060turbopro":
4295: specifiedModel = Model.PRO;
4296: specifiedAccelerator = ACCELERATOR_060TURBOPRO;
4297: break;
4298: default:
4299: Model model = Model.fromTypeOrSynonym (paramModel);
4300: if (model != null) {
4301: specifiedModel = model;
4302: specifiedAccelerator = 0;
4303: } else {
4304: System.out.println (Multilingual.mlnJapanese ?
4305: paramModel + " は不明な機種です" :
4306: paramModel + " is unknown model");
4307: specifiedModel = Model.COMPACT;
4308: specifiedAccelerator = ACCELERATOR_HYBRID;
4309: }
4310: }
4311: }
4312:
4313: specifiedIsSecond = false;
4314: specifiedFirstMPU = specifiedModel.getMPU ();
4315: specifiedSecondMPU = Model.MPU_MC68EC030;
4316: {
4317: String[] paramMPUs = Settings.sgsGetString ("mpu").split (",");
4318: for (int i = 0; i < 2; i++) {
4319: int mpu = 0;
4320: String paramMPU = i < paramMPUs.length ? paramMPUs[i] : "";
4321: switch (paramMPU) {
4322: case "":
4323: case "none":
4324: case "-1":
4325: mpu = (i == 0 ?
4326: (specifiedAccelerator == ACCELERATOR_060TURBO ||
4327: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4328: specifiedModel.getMPU ()) :
4329: Model.MPU_MC68EC030);
4330: break;
4331: case "0":
4332: case "68000":
4333: case "mc68000":
4334: mpu = Model.MPU_MC68000;
4335: break;
4336: case "1":
4337: case "68010":
4338: case "mc68010":
4339: mpu = Model.MPU_MC68010;
4340: break;
4341:
4342:
4343:
4344:
4345:
4346: case "3":
4347: case "68ec030":
4348: case "mc68ec030":
4349: mpu = Model.MPU_MC68EC030;
4350: break;
4351:
4352:
4353:
4354:
4355:
4356:
4357:
4358:
4359:
4360:
4361:
4362:
4363:
4364:
4365:
4366:
4367:
4368: case "6":
4369: case "68060":
4370: case "mc68060":
4371: mpu = Model.MPU_MC68060;
4372: break;
4373: default:
4374: Model model = Model.fromTypeOrSynonym (paramMPU);
4375: if (model != null) {
4376: mpu = model.getMPU ();
4377: } else {
4378: System.out.println (Multilingual.mlnJapanese ?
4379: paramMPU + " は不明な MPU です" :
4380: paramMPU + " is unknown MPU");
4381: mpu = specifiedModel.getMPU ();
4382: }
4383: }
4384: if (i == 0) {
4385: specifiedFirstMPU = mpu;
4386: } else {
4387: specifiedSecondMPU = mpu;
4388: }
4389: }
4390: }
4391: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
4392:
4393: specifiedFirstClock = specifiedModel.getClock ();
4394: specifiedSecondClock = specifiedFirstClock * 2.0;
4395: {
4396: String[] paramClocks = Settings.sgsGetString ("clock").split (",");
4397: for (int i = 0; i < 2; i++) {
4398: double clock = 0.0;
4399: String paramClock = i < paramClocks.length ? paramClocks[i] : "";
4400: switch (paramClock.toLowerCase ()) {
4401: case "":
4402: case "none":
4403: case "-1":
4404: clock = (i == 0 ?
4405: (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4406: specifiedAccelerator == ACCELERATOR_060TURBO ||
4407: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4408: specifiedModel.getClock ()) :
4409: specifiedFirstClock * 2.0);
4410: break;
4411: case "hybrid":
4412: clock = MHZ_HYBRID_VALUE;
4413: break;
4414: case "060turbo":
4415: case "060turbopro":
4416: clock = MHZ_060TURBO_VALUE;
4417: break;
4418: case "16.7":
4419: case "xellent30":
4420: clock = 50.0 / 3.0;
4421: break;
4422: case "33.3":
4423: clock = 100.0 / 3.0;
4424: break;
4425: case "66.7":
4426: clock = 200.0 / 3.0;
4427: break;
4428: default:
4429: if (paramClock.matches ("^(?:" +
4430: "[-+]?" +
4431: "(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)" +
4432: "(?:[Ee][-+]?[0-9]+)?" +
4433: ")$")) {
4434: double d = Double.parseDouble (paramClock);
4435: if (1.0 <= d && d <= 1000.0) {
4436: clock = d;
4437: }
4438: } else {
4439: System.out.println (Multilingual.mlnJapanese ?
4440: paramClock + " は不明な動作周波数です" :
4441: paramClock + " is unknown clock frequency");
4442: clock = specifiedModel.getClock ();
4443: }
4444: }
4445: if (i == 0) {
4446: specifiedFirstClock = clock;
4447: } else {
4448: specifiedSecondClock = clock;
4449: }
4450: }
4451: }
4452: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4453:
4454: specifiedCopro0 = 15 & Settings.sgsGetInt ("copro0", 2);
4455: if (!((7 & specifiedCopro0) == 0 ||
4456: (7 & specifiedCopro0) == 1 ||
4457: (7 & specifiedCopro0) == 2 ||
4458: (7 & specifiedCopro0) == 7)) {
4459: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4460: }
4461: specifiedCopro1 = 15 & Settings.sgsGetInt ("copro1", 2);
4462: if (!((7 & specifiedCopro1) == 0 ||
4463: (7 & specifiedCopro1) == 1 ||
4464: (7 & specifiedCopro1) == 2 ||
4465: (7 & specifiedCopro1) == 7)) {
4466: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4467: }
4468: specifiedCopro2 = 15 & Settings.sgsGetInt ("copro2", 2);
4469: if (!((7 & specifiedCopro2) == 0 ||
4470: (7 & specifiedCopro2) == 1 ||
4471: (7 & specifiedCopro2) == 2 ||
4472: (7 & specifiedCopro2) == 7)) {
4473: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4474: }
4475: specifiedOnchipFPU = 15 & Settings.sgsGetInt ("onchipfpu", 7);
4476: if (!((7 & specifiedOnchipFPU) == 0 ||
4477: (7 & specifiedOnchipFPU) == 6 ||
4478: (7 & specifiedOnchipFPU) == 7)) {
4479: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4480: }
4481:
4482:
4483: currentModel = specifiedModel;
4484: currentAccelerator = specifiedAccelerator;
4485:
4486: currentIsSecond = specifiedIsSecond;
4487: currentFirstMPU = specifiedFirstMPU;
4488: currentSecondMPU = specifiedSecondMPU;
4489: currentMPU = specifiedMPU;
4490:
4491:
4492: currentCopro0 = specifiedCopro0;
4493: currentCopro1 = specifiedCopro1;
4494: currentCopro2 = specifiedCopro2;
4495: currentOnchipFPU = specifiedOnchipFPU;
4496:
4497:
4498: mpuUtilOn = Settings.sgsGetOnOff ("util");
4499: mpuUtilRatio = fmtParseInt (Settings.sgsGetString ("ratio"), 0, 1, 100, 100);
4500:
4501: mpuArbFreqMHz = fmtParseInt (Settings.sgsGetString ("mhz"), 0, 1, 1000, 100);
4502: if (mpuUtilOn) {
4503: mpuArbFreqOn = false;
4504: } else {
4505: mpuArbFreqOn = !(specifiedClock == 10.0 ||
4506: specifiedClock == 50.0 / 3.0 ||
4507: specifiedClock == 25.0 ||
4508: specifiedClock == 100.0 / 3.0 ||
4509: specifiedClock == 50.0 ||
4510: specifiedClock == 200.0 / 3.0 ||
4511: specifiedClock == 75.0 ||
4512: specifiedClock == 100.0);
4513: if (mpuArbFreqOn) {
4514: mpuArbFreqMHz = (int) specifiedClock;
4515: }
4516: }
4517:
4518:
4519: mpuROMWaitCycles = 0;
4520: mpuRAMWaitCycles = 0;
4521: mpuCacheOn = false;
4522:
4523: mpuNoWaitTime.ram = 0;
4524: mpuNoWaitTime.gvram = 0;
4525: mpuNoWaitTime.tvram = 0;
4526: mpuNoWaitTime.crtc = 0;
4527: mpuNoWaitTime.palet = 0;
4528: mpuNoWaitTime.vicon = 0;
4529: mpuNoWaitTime.dmac = 0;
4530: mpuNoWaitTime.mfp = 0;
4531: mpuNoWaitTime.rtc = 0;
4532: mpuNoWaitTime.prnport = 0;
4533: mpuNoWaitTime.sysport = 0;
4534: mpuNoWaitTime.opm = 0;
4535: mpuNoWaitTime.adpcm = 0;
4536: mpuNoWaitTime.fdc = 0;
4537: mpuNoWaitTime.fdd = 0;
4538: mpuNoWaitTime.hdc = 0;
4539: mpuNoWaitTime.scc = 0;
4540: mpuNoWaitTime.ppi = 0;
4541: mpuNoWaitTime.ioi = 0;
4542: mpuNoWaitTime.sprc = 0;
4543: mpuNoWaitTime.sram = 0;
4544: mpuNoWaitTime.rom = 0;
4545: mpuNoWaitTime.ramlong = mpuNoWaitTime.ram << 1;
4546: mpuNoWaitTime.romlong = mpuNoWaitTime.rom << 1;
4547:
4548: dmaNoWaitTime.ram = 0;
4549: dmaNoWaitTime.gvram = 0;
4550: dmaNoWaitTime.tvram = 0;
4551: dmaNoWaitTime.crtc = 0;
4552: dmaNoWaitTime.palet = 0;
4553: dmaNoWaitTime.vicon = 0;
4554: dmaNoWaitTime.dmac = 0;
4555: dmaNoWaitTime.mfp = 0;
4556: dmaNoWaitTime.rtc = 0;
4557: dmaNoWaitTime.prnport = 0;
4558: dmaNoWaitTime.sysport = 0;
4559: dmaNoWaitTime.opm = 0;
4560: dmaNoWaitTime.adpcm = 0;
4561: dmaNoWaitTime.fdc = 0;
4562: dmaNoWaitTime.fdd = 0;
4563: dmaNoWaitTime.hdc = 0;
4564: dmaNoWaitTime.scc = 0;
4565: dmaNoWaitTime.ppi = 0;
4566: dmaNoWaitTime.ioi = 0;
4567: dmaNoWaitTime.sprc = 0;
4568: dmaNoWaitTime.sram = 0;
4569: dmaNoWaitTime.rom = 0;
4570: dmaNoWaitTime.ramlong = dmaNoWaitTime.ram << 1;
4571: dmaNoWaitTime.romlong = dmaNoWaitTime.rom << 1;
4572:
4573:
4574: busWaitCyclesRequest = Settings.sgsGetOnOff ("waitcycles");
4575: busWaitCycles = busWaitCyclesRequest;
4576: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
4577:
4578: }
4579:
4580: public static void mdlTini () {
4581:
4582: Settings.sgsPutString ("model",
4583: specifiedAccelerator == ACCELERATOR_HYBRID ? "Hybrid" :
4584: specifiedAccelerator == ACCELERATOR_XELLENT30 ? "Xellent30" :
4585: specifiedAccelerator == ACCELERATOR_060TURBO ? "060turbo" :
4586: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? "060turboPRO" :
4587: specifiedModel.getSynonym () != null ? specifiedModel.getSynonym () :
4588: specifiedModel.getType ());
4589: Settings.sgsPutOnOff ("mpu010", mpu010);
4590:
4591:
4592: int defaultFirstMPU = (specifiedAccelerator == ACCELERATOR_060TURBO ||
4593: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4594: specifiedModel.getMPU ());
4595: int defaultSecondMPU = Model.MPU_MC68EC030;
4596: Settings.sgsPutString ("mpu",
4597: (specifiedFirstMPU == defaultFirstMPU ? "" :
4598: Model.mpuNameOf (specifiedFirstMPU)) +
4599: (specifiedSecondMPU == defaultSecondMPU ? "" :
4600: "," + Model.mpuNameOf (specifiedSecondMPU)));
4601:
4602:
4603:
4604:
4605: double defaultFirstClock = (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
4606: specifiedAccelerator == ACCELERATOR_060TURBO ||
4607: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
4608: specifiedModel.getClock ());
4609: double defaultSecondClock = defaultFirstClock * 2.0;
4610: Settings.sgsPutString ("clock",
4611: (specifiedFirstClock == defaultFirstClock ? "" :
4612: specifiedFirstClock == 50.0 / 3.0 ? "16.7" :
4613: specifiedFirstClock == 100.0 / 3.0 ? "33.3" :
4614: specifiedFirstClock == 200.0 / 3.0 ? "66.7" :
4615: String.valueOf ((int) specifiedFirstClock)) +
4616: (specifiedSecondClock == defaultSecondClock ? "" :
4617: "," + (specifiedSecondClock == 50.0 / 3.0 ? "16.7" :
4618: specifiedSecondClock == 100.0 / 3.0 ? "33.3" :
4619: specifiedSecondClock == 200.0 / 3.0 ? "66.7" :
4620: String.valueOf ((int) specifiedSecondClock))));
4621:
4622: Settings.sgsPutInt ("copro0", specifiedCopro0);
4623: Settings.sgsPutInt ("copro1", specifiedCopro1);
4624: Settings.sgsPutInt ("copro2", specifiedCopro2);
4625: Settings.sgsPutInt ("onchipfpu", specifiedOnchipFPU);
4626:
4627: Settings.sgsPutOnOff ("util",
4628: mpuUtilOn);
4629: Settings.sgsPutString ("ratio",
4630: String.valueOf (mpuUtilRatio));
4631:
4632: Settings.sgsPutString ("mhz",
4633: String.valueOf (mpuArbFreqMHz));
4634:
4635: Settings.sgsPutOnOff ("waitcycles", busWaitCyclesRequest);
4636: }
4637:
4638: public static void mdlMakeMenu () {
4639:
4640:
4641: ActionListener listener = new ActionListener () {
4642: @Override public void actionPerformed (ActionEvent ae) {
4643: Object source = ae.getSource ();
4644: switch (ae.getActionCommand ()) {
4645: case "X68000 (10MHz)":
4646: mdlRequestModel (Model.SHODAI, 0);
4647: mpuReset (-1, -1);
4648: break;
4649: case "X68000 ACE (10MHz)":
4650: mdlRequestModel (Model.ACE, 0);
4651: mpuReset (-1, -1);
4652: break;
4653: case "X68000 EXPERT (10MHz)":
4654: mdlRequestModel (Model.EXPERT, 0);
4655: mpuReset (-1, -1);
4656: break;
4657: case "X68000 PRO (10MHz)":
4658: mdlRequestModel (Model.PRO, 0);
4659: mpuReset (-1, -1);
4660: break;
4661: case "X68000 SUPER (10MHz)":
4662: mdlRequestModel (Model.SUPER, 0);
4663: mpuReset (-1, -1);
4664: break;
4665: case "X68000 XVI (16.7MHz)":
4666: mdlRequestModel (Model.XVI, 0);
4667: mpuReset (-1, -1);
4668: break;
4669: case "X68000 Compact (16.7MHz)":
4670: mdlRequestModel (Model.COMPACT, 0);
4671: mpuReset (-1, -1);
4672: break;
4673:
4674: case "X68030 (25MHz)":
4675: mdlRequestModel (Model.X68030, 0);
4676: mpuReset (-1, -1);
4677: break;
4678: case "X68030 Compact (25MHz)":
4679: mdlRequestModel (Model.X68030COMPACT, 0);
4680: mpuReset (-1, -1);
4681: break;
4682:
4683: case "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)":
4684: mdlRequestModel (Model.COMPACT, ACCELERATOR_HYBRID);
4685: mpuReset (-1, -1);
4686: break;
4687: case "Xellent30 (33.3MHz)":
4688: mdlRequestModel (Model.XVI, ACCELERATOR_XELLENT30);
4689: mpuReset (-1, -1);
4690: break;
4691: case "060turbo (" + MHZ_060TURBO_STRING + "MHz)":
4692: mdlRequestModel (Model.X68030, ACCELERATOR_060TURBO);
4693: mpuReset (-1, -1);
4694: break;
4695: case "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)":
4696: mdlRequestModel (Model.PRO, ACCELERATOR_060TURBOPRO);
4697: mpuReset (-1, -1);
4698: break;
4699:
4700: case "MC68010":
4701: mpu010 = ((JCheckBoxMenuItem) source).isSelected ();
4702: break;
4703:
4704: }
4705: }
4706: };
4707:
4708:
4709: ButtonGroup modelGroup = new ButtonGroup ();
4710: mdlMenu = Multilingual.mlnText (
4711: ComponentFactory.createMenu (
4712: "Change the model and reset",
4713: mdlShodaiMenuItem = ComponentFactory.createRadioButtonMenuItem (
4714: modelGroup,
4715: specifiedModel == Model.SHODAI,
4716: "X68000 (10MHz)",
4717: listener),
4718: mdlACEMenuItem = ComponentFactory.createRadioButtonMenuItem (
4719: modelGroup,
4720: specifiedModel == Model.ACE,
4721: "X68000 ACE (10MHz)",
4722: listener),
4723: mdlEXPERTMenuItem = ComponentFactory.createRadioButtonMenuItem (
4724: modelGroup,
4725: specifiedModel == Model.EXPERT,
4726: "X68000 EXPERT (10MHz)",
4727: listener),
4728: mdlPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
4729: modelGroup,
4730: specifiedModel == Model.PRO && specifiedAccelerator == 0,
4731: "X68000 PRO (10MHz)",
4732: listener),
4733: mdlSUPERMenuItem = ComponentFactory.createRadioButtonMenuItem (
4734: modelGroup,
4735: specifiedModel == Model.SUPER,
4736: "X68000 SUPER (10MHz)",
4737: listener),
4738: mdlXVIMenuItem = ComponentFactory.createRadioButtonMenuItem (
4739: modelGroup,
4740: specifiedModel == Model.XVI && specifiedAccelerator == 0,
4741: "X68000 XVI (16.7MHz)",
4742: listener),
4743: mdlCompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
4744: modelGroup,
4745: specifiedModel == Model.COMPACT && specifiedAccelerator == 0,
4746: "X68000 Compact (16.7MHz)",
4747: listener),
4748:
4749: ComponentFactory.createHorizontalSeparator (),
4750:
4751: mdlX68030MenuItem = ComponentFactory.createRadioButtonMenuItem (
4752: modelGroup,
4753: specifiedModel == Model.X68030 && specifiedAccelerator == 0,
4754: "X68030 (25MHz)",
4755: listener),
4756: mdl030CompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
4757: modelGroup,
4758: specifiedModel == Model.X68030COMPACT,
4759: "X68030 Compact (25MHz)",
4760: listener),
4761:
4762: ComponentFactory.createHorizontalSeparator (),
4763:
4764: mdlHybridMenuItem = ComponentFactory.createRadioButtonMenuItem (
4765: modelGroup,
4766: specifiedModel == Model.COMPACT && specifiedAccelerator == ACCELERATOR_HYBRID,
4767: "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)",
4768: listener),
4769: mdlXellent30MenuItem = ComponentFactory.createRadioButtonMenuItem (
4770: modelGroup,
4771: specifiedModel == Model.XVI && specifiedAccelerator == ACCELERATOR_XELLENT30,
4772: "Xellent30 (33.3MHz)",
4773: listener),
4774: mdl060turboMenuItem = ComponentFactory.createRadioButtonMenuItem (
4775: modelGroup,
4776: specifiedModel == Model.X68030 && specifiedAccelerator == ACCELERATOR_060TURBO,
4777: "060turbo (" + MHZ_060TURBO_STRING + "MHz)",
4778: listener),
4779: mdl060turboPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
4780: modelGroup,
4781: specifiedModel == Model.PRO && specifiedAccelerator == ACCELERATOR_060TURBOPRO,
4782: "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)",
4783: listener),
4784:
4785: ComponentFactory.createHorizontalSeparator (),
4786:
4787: mdlMC68010MenuItem = ComponentFactory.createCheckBoxMenuItem (
4788: mpu010,
4789: "MC68010",
4790: listener)
4791: ),
4792: "ja", "機種を変更してリセット");
4793:
4794:
4795: ActionListener copro0Listener = new ActionListener () {
4796: @Override public void actionPerformed (ActionEvent ae) {
4797: String command = ae.getActionCommand ();
4798: switch (command) {
4799: case "Not installed":
4800: specifiedCopro0 = (8 & specifiedCopro0) | 0;
4801: break;
4802: case "MC68881":
4803: specifiedCopro0 = (8 & specifiedCopro0) | 1;
4804: break;
4805: case "MC68882":
4806: specifiedCopro0 = (8 & specifiedCopro0) | 2;
4807: break;
4808: case "Full specification":
4809: specifiedCopro0 = (8 & specifiedCopro0) | 7;
4810: break;
4811: case "Extended precision (19 digits)":
4812: specifiedCopro0 = 0 | (7 & specifiedCopro0);
4813: break;
4814: case "Triple precision (24 digits)":
4815: specifiedCopro0 = 8 | (7 & specifiedCopro0);
4816: break;
4817: default:
4818: System.out.println ("unknown action command " + command);
4819: }
4820: }
4821: };
4822:
4823: ActionListener copro1Listener = new ActionListener () {
4824: @Override public void actionPerformed (ActionEvent ae) {
4825: String command = ae.getActionCommand ();
4826: switch (command) {
4827: case "Not installed":
4828: specifiedCopro1 = (8 & specifiedCopro1) | 0;
4829: break;
4830: case "MC68881":
4831: specifiedCopro1 = (8 & specifiedCopro1) | 1;
4832: break;
4833: case "MC68882":
4834: specifiedCopro1 = (8 & specifiedCopro1) | 2;
4835: break;
4836: case "Full specification":
4837: specifiedCopro1 = (8 & specifiedCopro1) | 7;
4838: break;
4839: case "Extended precision (19 digits)":
4840: specifiedCopro1 = 0 | (7 & specifiedCopro1);
4841: break;
4842: case "Triple precision (24 digits)":
4843: specifiedCopro1 = 8 | (7 & specifiedCopro1);
4844: break;
4845: default:
4846: System.out.println ("unknown action command " + command);
4847: }
4848: }
4849: };
4850:
4851: ActionListener copro2Listener = new ActionListener () {
4852: @Override public void actionPerformed (ActionEvent ae) {
4853: String command = ae.getActionCommand ();
4854: switch (command) {
4855: case "Not installed":
4856: specifiedCopro2 = (8 & specifiedCopro2) | 0;
4857: break;
4858: case "MC68881":
4859: specifiedCopro2 = (8 & specifiedCopro2) | 1;
4860: break;
4861: case "MC68882":
4862: specifiedCopro2 = (8 & specifiedCopro2) | 2;
4863: break;
4864: case "Full specification":
4865: specifiedCopro2 = (8 & specifiedCopro2) | 7;
4866: break;
4867: case "Extended precision (19 digits)":
4868: specifiedCopro2 = 0 | (7 & specifiedCopro2);
4869: break;
4870: case "Triple precision (24 digits)":
4871: specifiedCopro2 = 8 | (7 & specifiedCopro2);
4872: break;
4873: default:
4874: System.out.println ("unknown action command " + command);
4875: }
4876: }
4877: };
4878:
4879: ActionListener onchipFPUListener = new ActionListener () {
4880: @Override public void actionPerformed (ActionEvent ae) {
4881: String command = ae.getActionCommand ();
4882: switch (command) {
4883: case "Not installed":
4884: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 0;
4885: break;
4886: case "MC68060":
4887: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 6;
4888: break;
4889: case "Full specification":
4890: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
4891: break;
4892: case "Extended precision (19 digits)":
4893: specifiedOnchipFPU = 0 | (7 & specifiedOnchipFPU);
4894: break;
4895: case "Triple precision (24 digits)":
4896: specifiedOnchipFPU = 8 | (7 & specifiedOnchipFPU);
4897: break;
4898: default:
4899: System.out.println ("unknown action command " + command);
4900: }
4901: }
4902: };
4903:
4904: ButtonGroup copro00Group = new ButtonGroup ();
4905: ButtonGroup copro01Group = new ButtonGroup ();
4906: ButtonGroup copro10Group = new ButtonGroup ();
4907: ButtonGroup copro11Group = new ButtonGroup ();
4908: ButtonGroup copro20Group = new ButtonGroup ();
4909: ButtonGroup copro21Group = new ButtonGroup ();
4910: ButtonGroup onchipFPU0Group = new ButtonGroup ();
4911: ButtonGroup onchipFPU1Group = new ButtonGroup ();
4912:
4913: coproFPUMenu = Multilingual.mlnText (
4914: ComponentFactory.createMenu (
4915: "Coprocessor and on-chip FPU",
4916:
4917: Multilingual.mlnText (
4918: ComponentFactory.createMenu (
4919: "Motherboard coprocessor",
4920: Multilingual.mlnText (
4921: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 0, "Not installed", copro0Listener),
4922: "ja", "なし"),
4923: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 1, "MC68881", copro0Listener),
4924: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 2, "MC68882", copro0Listener),
4925: Multilingual.mlnText (
4926: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 7, "Full specification", copro0Listener),
4927: "ja", "フルスペック"),
4928: ComponentFactory.createHorizontalSeparator (),
4929: Multilingual.mlnText (
4930: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) == 0, "Extended precision (19 digits)", copro0Listener),
4931: "ja", "拡張精度 (19 桁)"),
4932: Multilingual.mlnText (
4933: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) != 0, "Triple precision (24 digits)", copro0Listener),
4934: "ja", "三倍精度 (24 桁)")),
4935: "ja", "マザーボードコプロセッサ"),
4936:
4937: Multilingual.mlnText (
4938: ComponentFactory.createMenu (
4939: "Extension coprocessor #1",
4940: Multilingual.mlnText (
4941: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 0, "Not installed", copro1Listener),
4942: "ja", "なし"),
4943: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 1, "MC68881", copro1Listener),
4944: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 2, "MC68882", copro1Listener),
4945: Multilingual.mlnText (
4946: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 7, "Full specification", copro1Listener),
4947: "ja", "フルスペック"),
4948: ComponentFactory.createHorizontalSeparator (),
4949: Multilingual.mlnText (
4950: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) == 0, "Extended precision (19 digits)", copro1Listener),
4951: "ja", "拡張精度 (19 桁)"),
4952: Multilingual.mlnText (
4953: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) != 0, "Triple precision (24 digits)", copro1Listener),
4954: "ja", "三倍精度 (24 桁)")),
4955: "ja", "拡張コプロセッサ #1"),
4956:
4957: Multilingual.mlnText (
4958: ComponentFactory.createMenu (
4959: "Extension coprocessor #2",
4960: Multilingual.mlnText (
4961: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 0, "Not installed", copro2Listener),
4962: "ja", "なし"),
4963: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 1, "MC68881", copro2Listener),
4964: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 2, "MC68882", copro2Listener),
4965: Multilingual.mlnText (
4966: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 7, "Full specification", copro2Listener),
4967: "ja", "フルスペック"),
4968: ComponentFactory.createHorizontalSeparator (),
4969: Multilingual.mlnText (
4970: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) == 0, "Extended precision (19 digits)", copro2Listener),
4971: "ja", "拡張精度 (19 桁)"),
4972: Multilingual.mlnText (
4973: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) != 0, "Triple precision (24 digits)", copro2Listener),
4974: "ja", "三倍精度 (24 桁)")),
4975: "ja", "拡張コプロセッサ #2"),
4976:
4977: Multilingual.mlnText (
4978: ComponentFactory.createMenu (
4979: "On-chip FPU",
4980: Multilingual.mlnText (
4981: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 0, "Not installed", onchipFPUListener),
4982: "ja", "なし"),
4983: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 6, "MC68060", onchipFPUListener),
4984: Multilingual.mlnText (
4985: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 7, "Full specification", onchipFPUListener),
4986: "ja", "フルスペック"),
4987: ComponentFactory.createHorizontalSeparator (),
4988: Multilingual.mlnText (
4989: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) == 0, "Extended precision (19 digits)", onchipFPUListener),
4990: "ja", "拡張精度 (19 桁)"),
4991: Multilingual.mlnText (
4992: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) != 0, "Triple precision (24 digits)", onchipFPUListener),
4993: "ja", "三倍精度 (24 桁)")),
4994: "ja", "オンチップ FPU")),
4995: "ja", "コプロセッサとオンチップ FPU");
4996:
4997: }
4998:
4999: public static void mdlRequestModel (Model model, int accelerator) {
5000: specifiedModel = model;
5001: specifiedAccelerator = accelerator;
5002:
5003: specifiedIsSecond = false;
5004: specifiedFirstMPU = specifiedModel.getMPU ();
5005: specifiedSecondMPU = Model.MPU_MC68EC030;
5006: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
5007: specifiedFirstClock = specifiedModel.getClock ();
5008: specifiedSecondClock = specifiedFirstClock * 2.0;
5009: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5010:
5011: switch (accelerator) {
5012: case ACCELERATOR_HYBRID:
5013: specifiedFirstClock = MHZ_HYBRID_VALUE;
5014: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5015: break;
5016: case ACCELERATOR_XELLENT30:
5017: break;
5018: case ACCELERATOR_060TURBO:
5019: case ACCELERATOR_060TURBOPRO:
5020: specifiedFirstMPU = Model.MPU_MC68060;
5021: specifiedFirstClock = MHZ_060TURBO_VALUE;
5022: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5023: }
5024:
5025: mpuUtilOn = false;
5026: mpuArbFreqOn = false;
5027: mpuSetCurrentClock (specifiedClock);
5028:
5029: if (accelerator == ACCELERATOR_HYBRID) {
5030: mdlHybridMenuItem.setSelected (true);
5031: } else if (accelerator == ACCELERATOR_XELLENT30) {
5032: mdlXellent30MenuItem.setSelected (true);
5033: } else if (accelerator == ACCELERATOR_060TURBO) {
5034: mdl060turboMenuItem.setSelected (true);
5035: } else if (accelerator == ACCELERATOR_060TURBOPRO) {
5036: mdl060turboPROMenuItem.setSelected (true);
5037: } else if (specifiedModel == Model.SHODAI) {
5038: mdlShodaiMenuItem.setSelected (true);
5039: } else if (specifiedModel == Model.ACE) {
5040: mdlACEMenuItem.setSelected (true);
5041: } else if (specifiedModel == Model.EXPERT) {
5042: mdlEXPERTMenuItem.setSelected (true);
5043: } else if (specifiedModel == Model.PRO) {
5044: mdlPROMenuItem.setSelected (true);
5045: } else if (specifiedModel == Model.SUPER) {
5046: mdlSUPERMenuItem.setSelected (true);
5047: } else if (specifiedModel == Model.XVI) {
5048: mdlXVIMenuItem.setSelected (true);
5049: } else if (specifiedModel == Model.COMPACT) {
5050: mdlCompactMenuItem.setSelected (true);
5051: } else if (specifiedModel == Model.X68030) {
5052: mdlX68030MenuItem.setSelected (true);
5053: } else if (specifiedModel == Model.X68030COMPACT) {
5054: mdl030CompactMenuItem.setSelected (true);
5055: }
5056:
5057:
5058: HDC.hdcSASIMenuItem.setSelected (!currentModel.isSCSI ());
5059: SPC.spcSCSIINMenuItem.setSelected (currentModel.isSCSI ());
5060: }
5061:
5062:
5063:
5064:
5065:
5066:
5067:
5068: public static final boolean MPU_INLINE_EXCEPTION = true;
5069: public static final boolean MPU_COMPOUND_POSTINCREMENT = false;
5070:
5071: public static final boolean MPU_SWITCH_MISC_OPCODE = false;
5072: public static final boolean MPU_SWITCH_BCC_CONDITION = false;
5073: public static final boolean MPU_SWITCH_BCC_OFFSET = false;
5074: public static final boolean MPU_SWITCH_SCC_CONDITION = true;
5075:
5076: public static final boolean MPU_OMIT_EXTRA_READ = false;
5077: public static final boolean MPU_OMIT_OFFSET_READ = false;
5078:
5079:
5080:
5081:
5082: public static final long FAR_FUTURE = 0x7fffffffffffffffL;
5083:
5084:
5085:
5086:
5087:
5088:
5089:
5090:
5091: public static final int REG_SR_T1 = 0b10000000_00000000;
5092: public static final int REG_SR_T0 = 0b01000000_00000000;
5093:
5094:
5095:
5096:
5097:
5098:
5099: public static final int REG_SR_S = 0b00100000_00000000;
5100: public static final int REG_SR_M = 0b00010000_00000000;
5101:
5102: public static final int REG_SR_I = 0b00000111_00000000;
5103:
5104:
5105: public static final int REG_CCR_X = 0b00000000_00010000;
5106: public static final int REG_CCR_N = 0b00000000_00001000;
5107: public static final int REG_CCR_Z = 0b00000000_00000100;
5108: public static final int REG_CCR_V = 0b00000000_00000010;
5109: public static final int REG_CCR_C = 0b00000000_00000001;
5110: public static final int REG_CCR_MASK = REG_CCR_X | REG_CCR_N | REG_CCR_Z | REG_CCR_V | REG_CCR_C;
5111:
5112: public static char[] REG_CCRXMAP = "00000000000000001111111111111111".toCharArray ();
5113: public static char[] REG_CCRNMAP = "00000000111111110000000011111111".toCharArray ();
5114: public static char[] REG_CCRZMAP = "00001111000011110000111100001111".toCharArray ();
5115: public static char[] REG_CCRVMAP = "00110011001100110011001100110011".toCharArray ();
5116: public static char[] REG_CCRCMAP = "01010101010101010101010101010101".toCharArray ();
5117:
5118:
5119:
5120: public static final int MPU_IOI_INTERRUPT_LEVEL = 1;
5121: public static final int MPU_EB2_INTERRUPT_LEVEL = 2;
5122: public static final int MPU_DMA_INTERRUPT_LEVEL = 3;
5123: public static final int MPU_SCC_INTERRUPT_LEVEL = 5;
5124: public static final int MPU_MFP_INTERRUPT_LEVEL = 6;
5125: public static final int MPU_SYS_INTERRUPT_LEVEL = 7;
5126: public static final int MPU_IOI_INTERRUPT_MASK = 0x80 >> MPU_IOI_INTERRUPT_LEVEL;
5127: public static final int MPU_EB2_INTERRUPT_MASK = 0x80 >> MPU_EB2_INTERRUPT_LEVEL;
5128: public static final int MPU_DMA_INTERRUPT_MASK = 0x80 >> MPU_DMA_INTERRUPT_LEVEL;
5129: public static final int MPU_SCC_INTERRUPT_MASK = 0x80 >> MPU_SCC_INTERRUPT_LEVEL;
5130: public static final int MPU_MFP_INTERRUPT_MASK = 0x80 >> MPU_MFP_INTERRUPT_LEVEL;
5131: public static final int MPU_SYS_INTERRUPT_MASK = 0x80 >> MPU_SYS_INTERRUPT_LEVEL;
5132:
5133: public static final boolean MPU_INTERRUPT_SWITCH = true;
5134:
5135:
5136: public static final boolean T = true;
5137: public static final boolean F = false;
5138:
5139: public static final int CCCC_T = 0b0000;
5140: public static final int CCCC_F = 0b0001;
5141: public static final int CCCC_HI = 0b0010;
5142: public static final int CCCC_LS = 0b0011;
5143: public static final int CCCC_CC = 0b0100;
5144: public static final int CCCC_CS = 0b0101;
5145: public static final int CCCC_NE = 0b0110;
5146: public static final int CCCC_EQ = 0b0111;
5147: public static final int CCCC_VC = 0b1000;
5148: public static final int CCCC_VS = 0b1001;
5149: public static final int CCCC_PL = 0b1010;
5150: public static final int CCCC_MI = 0b1011;
5151: public static final int CCCC_GE = 0b1100;
5152: public static final int CCCC_LT = 0b1101;
5153: public static final int CCCC_GT = 0b1110;
5154: public static final int CCCC_LE = 0b1111;
5155:
5156:
5157:
5158:
5159:
5160:
5161: public static final boolean[] BCCMAP = {
5162: 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,
5163: 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,
5164: 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,
5165: 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,
5166: 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,
5167: 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,
5168: 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,
5169: 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,
5170: 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,
5171: 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,
5172: 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,
5173: 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,
5174: 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,
5175: 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,
5176: 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,
5177: 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,
5178: };
5179:
5180:
5181: public static final char[] MPU_CCCMAP = (
5182: "11111111111111111111111111111111" +
5183: "00000000000000000000000000000000" +
5184: "10100000101000001010000010100000" +
5185: "01011111010111110101111101011111" +
5186: "10101010101010101010101010101010" +
5187: "01010101010101010101010101010101" +
5188: "11110000111100001111000011110000" +
5189: "00001111000011110000111100001111" +
5190: "11001100110011001100110011001100" +
5191: "00110011001100110011001100110011" +
5192: "11111111000000001111111100000000" +
5193: "00000000111111110000000011111111" +
5194: "11001100001100111100110000110011" +
5195: "00110011110011000011001111001100" +
5196: "11000000001100001100000000110000" +
5197: "00111111110011110011111111001111").toCharArray ();
5198:
5199:
5200:
5201: public static final int MPU_CC_T = 0b11111111111111111111111111111111;
5202: public static final int MPU_CC_F = 0b00000000000000000000000000000000;
5203: public static final int MPU_CC_HI = 0b10100000101000001010000010100000;
5204: public static final int MPU_CC_LS = 0b01011111010111110101111101011111;
5205: public static final int MPU_CC_HS = 0b10101010101010101010101010101010;
5206: public static final int MPU_CC_LO = 0b01010101010101010101010101010101;
5207: public static final int MPU_CC_NE = 0b11110000111100001111000011110000;
5208: public static final int MPU_CC_EQ = 0b00001111000011110000111100001111;
5209: public static final int MPU_CC_VC = 0b11001100110011001100110011001100;
5210: public static final int MPU_CC_VS = 0b00110011001100110011001100110011;
5211: public static final int MPU_CC_PL = 0b11111111000000001111111100000000;
5212: public static final int MPU_CC_MI = 0b00000000111111110000000011111111;
5213: public static final int MPU_CC_GE = 0b11001100001100111100110000110011;
5214: public static final int MPU_CC_LT = 0b00110011110011000011001111001100;
5215: public static final int MPU_CC_GT = 0b11000000001100001100000000110000;
5216: public static final int MPU_CC_LE = 0b00111111110011110011111111001111;
5217:
5218:
5219:
5220:
5221:
5222:
5223:
5224:
5225:
5226:
5227:
5228:
5229:
5230:
5231:
5232:
5233:
5234:
5235:
5236:
5237:
5238:
5239:
5240:
5241:
5242:
5243:
5244:
5245:
5246:
5247:
5248:
5249:
5250:
5251:
5252:
5253:
5254:
5255:
5256:
5257:
5258:
5259:
5260:
5261:
5262:
5263:
5264:
5265:
5266: 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);
5267:
5268:
5269:
5270: public static final int[] MPU_BITREV_TABLE_0 = new int[2048];
5271: public static final int[] MPU_BITREV_TABLE_1 = new int[2048];
5272: public static final int[] MPU_BITREV_TABLE_2 = new int[2048];
5273: static {
5274: for (int i = 0; i < 2048; i++) {
5275: MPU_BITREV_TABLE_2[i] = (MPU_BITREV_TABLE_1[i] = (MPU_BITREV_TABLE_0[i] = Integer.reverse (i)) >>> 11) >>> 11;
5276: }
5277: }
5278:
5279:
5280:
5281: public static final int EA_DR = 0b000_000;
5282: public static final int EA_AR = 0b001_000;
5283: public static final int EA_MM = 0b010_000;
5284: public static final int EA_MP = 0b011_000;
5285: public static final int EA_MN = 0b100_000;
5286: public static final int EA_MW = 0b101_000;
5287: public static final int EA_MX = 0b110_000;
5288: public static final int EA_ZW = 0b111_000;
5289: public static final int EA_ZL = 0b111_001;
5290: public static final int EA_PW = 0b111_010;
5291: public static final int EA_PX = 0b111_011;
5292: public static final int EA_IM = 0b111_100;
5293: public static final int MMM_DR = EA_DR >> 3;
5294: public static final int MMM_AR = EA_AR >> 3;
5295: public static final int MMM_MM = EA_MM >> 3;
5296: public static final int MMM_MP = EA_MP >> 3;
5297: public static final int MMM_MN = EA_MN >> 3;
5298: public static final int MMM_MW = EA_MW >> 3;
5299: public static final int MMM_MX = EA_MX >> 3;
5300: public static final long EAM_DR = 0xff00000000000000L >>> EA_DR;
5301: public static final long EAM_AR = 0xff00000000000000L >>> EA_AR;
5302: public static final long EAM_MM = 0xff00000000000000L >>> EA_MM;
5303: public static final long EAM_MP = 0xff00000000000000L >>> EA_MP;
5304: public static final long EAM_MN = 0xff00000000000000L >>> EA_MN;
5305: public static final long EAM_MW = 0xff00000000000000L >>> EA_MW;
5306: public static final long EAM_MX = 0xff00000000000000L >>> EA_MX;
5307: public static final long EAM_ZW = 0x8000000000000000L >>> EA_ZW;
5308: public static final long EAM_ZL = 0x8000000000000000L >>> EA_ZL;
5309: public static final long EAM_PW = 0x8000000000000000L >>> EA_PW;
5310: public static final long EAM_PX = 0x8000000000000000L >>> EA_PX;
5311: public static final long EAM_IM = 0x8000000000000000L >>> EA_IM;
5312: 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;
5313: public static final long EAM_ALT = EAM_DR|EAM_AR|EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5314: 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;
5315: 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 ;
5316: public static final long EAM_DLT = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5317: public static final long EAM_DCN = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5318: public static final long EAM_DCL = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5319: 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;
5320: public static final long EAM_MEM = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5321: public static final long EAM_MLT = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5322: public static final long EAM_RDL = EAM_MM|EAM_MP |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5323: public static final long EAM_WTL = EAM_MM |EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5324: public static final long EAM_CNT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5325: public static final long EAM_CLT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5326:
5327:
5328:
5329:
5330:
5331:
5332:
5333:
5334:
5335:
5336:
5337: public static final int[] regRn = new int[16 + 1];
5338:
5339:
5340: public static int regPC;
5341: public static int regPC0;
5342:
5343:
5344: public static int regOC;
5345:
5346:
5347: public static int regSRT1;
5348: public static int regSRT0;
5349: public static int mpuTraceFlag;
5350: public static int regSRS;
5351: public static int regSRM;
5352: public static int regSRI;
5353:
5354:
5355: public static int regCCR;
5356:
5357:
5358:
5359:
5360:
5361:
5362:
5363:
5364:
5365:
5366:
5367:
5368:
5369:
5370:
5371:
5372:
5373:
5374:
5375:
5376: public static int mpuIMR;
5377:
5378:
5379:
5380:
5381:
5382:
5383: public static int mpuIRR;
5384: public static int mpuDIRR;
5385:
5386:
5387:
5388:
5389:
5390:
5391:
5392:
5393: public static int mpuISR;
5394:
5395:
5396: public static int mpuSFC;
5397: public static int mpuDFC;
5398: public static int mpuCACR;
5399:
5400:
5401:
5402:
5403:
5404: public static int mpuBUSCR;
5405: public static int mpuUSP;
5406: public static int mpuVBR;
5407: public static int mpuCAAR;
5408: public static int mpuMSP;
5409: public static int mpuISP;
5410:
5411:
5412:
5413: public static int mpuPCR;
5414:
5415:
5416:
5417: public static final int MPU_060_REV = 7;
5418:
5419:
5420:
5421: public static long mpuClockTime;
5422: public static long mpuClockLimit;
5423: public static double mpuClockMHz;
5424: public static double mpuCurrentMHz;
5425: public static int mpuCycleCount;
5426: public static long mpuCycleUnit;
5427: public static long mpuModifiedUnit;
5428: public static long dmaCycleUnit;
5429:
5430:
5431:
5432: public static TimerTask mpuTask;
5433:
5434:
5435: public static int mpuBootDevice;
5436: public static int mpuROMBootHandle;
5437: public static int mpuSavedBootDevice;
5438: public static int mpuSavedROMBootHandle;
5439:
5440:
5441: public static boolean mpuIgnoreAddressError;
5442:
5443:
5444: public static int mpuROMWaitCycles;
5445: public static int mpuRAMWaitCycles;
5446: public static boolean mpuCacheOn;
5447: public static final class WaitTime {
5448: public long ram;
5449: public long gvram;
5450: public long tvram;
5451: public long crtc;
5452: public long palet;
5453: public long vicon;
5454: public long dmac;
5455: public long mfp;
5456: public long rtc;
5457: public long prnport;
5458: public long sysport;
5459: public long opm;
5460: public long adpcm;
5461: public long fdc;
5462: public long fdd;
5463: public long hdc;
5464: public long scc;
5465: public long ppi;
5466: public long ioi;
5467: public long sprc;
5468: public long sram;
5469: public long rom;
5470: public long ramlong;
5471: public long romlong;
5472: }
5473: public static final WaitTime mpuNoWaitTime = new WaitTime ();
5474: public static final WaitTime dmaNoWaitTime = new WaitTime ();
5475: public static final WaitTime mpuWaitTime = new WaitTime ();
5476: public static final WaitTime dmaWaitTime = new WaitTime ();
5477: public static boolean busWaitCyclesRequest;
5478: public static boolean busWaitCycles;
5479: public static WaitTime busWaitTime;
5480:
5481:
5482: public static boolean mpuArbFreqOn;
5483: public static int mpuArbFreqMHz;
5484: public static SpinnerNumberModel mpuArbFreqModel;
5485: public static JSpinner mpuArbFreqSpinner;
5486: public static JRadioButtonMenuItem mpuArbFreqRadioButtonMenuItem;
5487:
5488:
5489: public static boolean mpuUtilOn;
5490: public static int mpuUtilRatio;
5491: public static SpinnerNumberModel mpuUtilModel;
5492: public static JSpinner mpuUtilSpinner;
5493: public static JRadioButtonMenuItem mpuUtilRadioButtonMenuItem;
5494:
5495:
5496: public static final int MPU_ADJUSTMENT_INTERVAL = 100;
5497: public static int mpuAdjustmentCounter;
5498: public static long mpuTotalNano;
5499: public static long mpuLastNano;
5500: public static double mpuCoreNano1;
5501: public static double mpuCoreNano2;
5502:
5503:
5504: public static JMenu mpuMenu;
5505: public static JMenuItem mpuResetMenuItem;
5506: public static JMenuItem mpuOpt1ResetMenuItem;
5507: public static JRadioButtonMenuItem mpuClock10MenuItem;
5508: public static JRadioButtonMenuItem mpuClock16MenuItem;
5509: public static JRadioButtonMenuItem mpuClock25MenuItem;
5510: public static JRadioButtonMenuItem mpuClock33MenuItem;
5511: public static JRadioButtonMenuItem mpuClock50MenuItem;
5512: public static JRadioButtonMenuItem mpuClock66MenuItem;
5513: public static JRadioButtonMenuItem mpuClock75MenuItem;
5514: public static JRadioButtonMenuItem mpuClock100MenuItem;
5515:
5516:
5517: public static ActionListener mpuDebugActionListener;
5518: public static ArrayList<AbstractButton> mpuButtonsRunning;
5519: public static ArrayList<AbstractButton> mpuButtonsStopped;
5520: public static ArrayList<JCheckBox> mpuOriIllegalCheckBoxList;
5521: public static ArrayList<JCheckBox> mpuStopOnErrorCheckBoxList;
5522: public static ArrayList<JCheckBox> mpuStopAtStartCheckBoxList;
5523:
5524: public static int mpuAdvanceCount;
5525: public static int mpuStepCount;
5526: public static boolean mpuContinue;
5527: public static int mpuUntilReturnSRS;
5528: public static int mpuUntilReturnRP;
5529: public static int mpuUntilReturnPC0;
5530: public static int mpuUntilReturnSP;
5531:
5532:
5533:
5534:
5535:
5536:
5537:
5538:
5539:
5540:
5541:
5542:
5543:
5544:
5545:
5546:
5547:
5548:
5549:
5550:
5551:
5552:
5553:
5554:
5555:
5556:
5557:
5558:
5559:
5560:
5561:
5562:
5563:
5564:
5565:
5566:
5567:
5568:
5569:
5570:
5571:
5572:
5573:
5574:
5575:
5576:
5577:
5578:
5579:
5580:
5581:
5582:
5583:
5584:
5585:
5586:
5587:
5588:
5589:
5590:
5591:
5592:
5593:
5594:
5595:
5596:
5597:
5598:
5599:
5600:
5601:
5602:
5603:
5604: public static final boolean MPU_SXMENU = false;
5605:
5606:
5607:
5608: public static void mpuInit () {
5609:
5610: mpuIgnoreAddressError = false;
5611:
5612:
5613:
5614: fpuInit ();
5615:
5616: mpuClockTime = 0L;
5617: mpuClockLimit = 0L;
5618: mpuCycleCount = 0;
5619:
5620: mpuTask = null;
5621:
5622: M68kException.m6eSignal = new M68kException ();
5623: M68kException.m6eNumber = 0;
5624: M68kException.m6eAddress = 0;
5625: M68kException.m6eDirection = MPU_WR_WRITE;
5626: M68kException.m6eSize = MPU_SS_BYTE;
5627:
5628: mpuBootDevice = -1;
5629: mpuROMBootHandle = -1;
5630: mpuSavedBootDevice = -1;
5631: mpuSavedROMBootHandle = -1;
5632:
5633:
5634:
5635:
5636:
5637:
5638:
5639:
5640:
5641:
5642:
5643:
5644:
5645:
5646:
5647: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
5648: mpuTotalNano = 0L;
5649: mpuLastNano = System.nanoTime ();
5650: mpuCoreNano1 = mpuCoreNano2 = 0.5 * 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
5651:
5652: mpuButtonsRunning = new ArrayList<AbstractButton> ();
5653: mpuButtonsStopped = new ArrayList<AbstractButton> ();
5654:
5655: mpuOriIllegalCheckBoxList = new ArrayList<JCheckBox> ();
5656: mpuStopOnErrorCheckBoxList = new ArrayList<JCheckBox> ();
5657: mpuStopAtStartCheckBoxList = new ArrayList<JCheckBox> ();
5658:
5659: mpuAdvanceCount = 0;
5660: mpuStepCount = 0;
5661: mpuContinue = false;
5662: mpuUntilReturnSRS = 0;
5663: mpuUntilReturnRP = 0;
5664: mpuUntilReturnPC0 = 0;
5665: mpuUntilReturnSP = 0;
5666:
5667:
5668: mpuDebugActionListener = new ActionListener () {
5669: @Override public void actionPerformed (ActionEvent ae) {
5670: Object source = ae.getSource ();
5671: switch (ae.getActionCommand ()) {
5672: case "Stop":
5673: if (RootPointerList.RTL_ON) {
5674: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
5675: RootPointerList.rtlCurrentUserTaskIsStoppable) {
5676: mpuStop (null);
5677: }
5678: } else {
5679: mpuStop (null);
5680: }
5681: break;
5682: case "Trace":
5683: mpuAdvance (1);
5684: break;
5685: case "Trace 10 times":
5686: mpuAdvance (10);
5687: break;
5688: case "Trace 100 times":
5689: mpuAdvance (100);
5690: break;
5691: case "Step":
5692: mpuStep (1);
5693: break;
5694: case "Step 10 times":
5695: mpuStep (10);
5696: break;
5697: case "Step 100 times":
5698: mpuStep (100);
5699: break;
5700: case "Step until return":
5701: mpuStepUntilReturn ();
5702: break;
5703: case "Run":
5704: mpuStart ();
5705: break;
5706:
5707: case "Consider ORI.B #$00,D0 as an illegal instruction" :
5708: if (DBG_ORI_BYTE_ZERO_D0) {
5709: dbgOriByteZeroD0 = ((JCheckBox) source).isSelected ();
5710: for (JCheckBox checkBox : mpuOriIllegalCheckBoxList) {
5711: if (checkBox.isSelected () != dbgOriByteZeroD0) {
5712: checkBox.setSelected (dbgOriByteZeroD0);
5713: }
5714: }
5715: }
5716: break;
5717: case "Stop on error":
5718: dbgStopOnError = ((JCheckBox) source).isSelected ();
5719: for (JCheckBox checkBox : mpuStopOnErrorCheckBoxList) {
5720: if (checkBox.isSelected () != dbgStopOnError) {
5721: checkBox.setSelected (dbgStopOnError);
5722: }
5723: }
5724: break;
5725: case "Stop at execution start position":
5726: dbgStopAtStart = ((JCheckBox) source).isSelected ();
5727: for (JCheckBox checkBox : mpuStopAtStartCheckBoxList) {
5728: if (checkBox.isSelected () != dbgStopAtStart) {
5729: checkBox.setSelected (dbgStopAtStart);
5730: }
5731: }
5732: break;
5733: }
5734: }
5735: };
5736:
5737: }
5738:
5739:
5740:
5741: public static JCheckBox mpuMakeOriIllegalCheckBox () {
5742: JCheckBox checkBox = Multilingual.mlnToolTipText (
5743: ComponentFactory.createIconCheckBox (
5744: DBG_ORI_BYTE_ZERO_D0 ? dbgOriByteZeroD0 : null,
5745: LnF.LNF_ORI_BYTE_ZERO_D0_IMAGE,
5746: LnF.LNF_ORI_BYTE_ZERO_D0_SELECTED_IMAGE,
5747: "Consider ORI.B #$00,D0 as an illegal instruction", mpuDebugActionListener),
5748: "ja", "ORI.B #$00,D0 を不当命令とみなす");
5749: mpuOriIllegalCheckBoxList.add (checkBox);
5750: return checkBox;
5751: }
5752:
5753:
5754:
5755: public static JCheckBox mpuMakeStopOnErrorCheckBox () {
5756: JCheckBox checkBox = Multilingual.mlnToolTipText (
5757: ComponentFactory.createIconCheckBox (
5758: dbgStopOnError,
5759: LnF.LNF_STOP_ON_ERROR_IMAGE,
5760: LnF.LNF_STOP_ON_ERROR_SELECTED_IMAGE,
5761: "Stop on error", mpuDebugActionListener),
5762: "ja", "エラーで停止する");
5763: mpuStopOnErrorCheckBoxList.add (checkBox);
5764: return checkBox;
5765: }
5766:
5767:
5768:
5769: public static JCheckBox mpuMakeStopAtStartCheckBox () {
5770: JCheckBox checkBox = Multilingual.mlnToolTipText (
5771: ComponentFactory.createIconCheckBox (
5772: dbgStopAtStart,
5773: LnF.LNF_STOP_AT_START_IMAGE,
5774: LnF.LNF_STOP_AT_START_SELECTED_IMAGE,
5775: "Stop at execution start position", mpuDebugActionListener),
5776: "ja", "実行開始位置で停止する");
5777: mpuStopAtStartCheckBoxList.add (checkBox);
5778: return checkBox;
5779: }
5780:
5781:
5782: public static void mpuMakeMenu () {
5783:
5784: ButtonGroup unitGroup = new ButtonGroup ();
5785: ActionListener listener = new ActionListener () {
5786: @Override public void actionPerformed (ActionEvent ae) {
5787: Object source = ae.getSource ();
5788: switch (ae.getActionCommand ()) {
5789: case "Reset":
5790: mpuReset (-1, -1);
5791: break;
5792: case "Hold down OPT.1 and reset":
5793: mpuReset (0, -1);
5794: break;
5795: case "Interrupt":
5796: sysInterrupt ();
5797: break;
5798: case "10MHz":
5799: mpuArbFreqOn = false;
5800: mpuUtilOn = false;
5801: mpuSetCurrentClock (10.0);
5802: break;
5803: case "16.7MHz":
5804: mpuArbFreqOn = false;
5805: mpuUtilOn = false;
5806: mpuSetCurrentClock (50.0 / 3.0);
5807: break;
5808: case "25MHz":
5809: mpuArbFreqOn = false;
5810: mpuUtilOn = false;
5811: mpuSetCurrentClock (25.0);
5812: break;
5813: case "33.3MHz":
5814: mpuArbFreqOn = false;
5815: mpuUtilOn = false;
5816: mpuSetCurrentClock (100.0 / 3.0);
5817: break;
5818: case "50MHz":
5819: mpuArbFreqOn = false;
5820: mpuUtilOn = false;
5821: mpuSetCurrentClock (50.0);
5822: break;
5823: case "66.7MHz":
5824: mpuArbFreqOn = false;
5825: mpuUtilOn = false;
5826: mpuSetCurrentClock (200.0 / 3.0);
5827: break;
5828: case "75MHz":
5829: mpuArbFreqOn = false;
5830: mpuUtilOn = false;
5831: mpuSetCurrentClock (75.0);
5832: break;
5833: case "100MHz":
5834: mpuArbFreqOn = false;
5835: mpuUtilOn = false;
5836: mpuSetCurrentClock (100.0);
5837: break;
5838: case "Arbitrary frequency":
5839: mpuArbFreqOn = true;
5840: mpuUtilOn = false;
5841: mpuSetCurrentClock ((double) mpuArbFreqMHz);
5842: break;
5843: case "Arbitrary load factor":
5844: mpuArbFreqOn = false;
5845: mpuUtilOn = true;
5846: break;
5847: case "FE function instruction":
5848: FEFunction.fpkOn = ((JCheckBoxMenuItem) source).isSelected ();
5849: break;
5850: case "Reject FLOATn.X":
5851: FEFunction.fpkRejectFloatOn = ((JCheckBoxMenuItem) source).isSelected ();
5852: break;
5853: case "Cut FC2 pin":
5854: busRequestCutFC2Pin = ((JCheckBoxMenuItem) source).isSelected ();
5855: break;
5856: case "Wait cycles":
5857: busWaitCyclesRequest = ((JCheckBoxMenuItem) source).isSelected ();
5858: break;
5859: case "Use IPLROM 1.6":
5860: ROM.romIPLROM16On = ((JCheckBoxMenuItem) source).isSelected ();
5861: break;
5862: case "Increase IPLROM to 256KB":
5863: ROM.romIPLROM256KOn = ((JCheckBoxMenuItem) source).isSelected ();
5864: break;
5865:
5866: case "Run / Stop":
5867: if (((JCheckBox) source).isSelected ()) {
5868: mpuStart ();
5869: } else {
5870: if (RootPointerList.RTL_ON) {
5871: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
5872: RootPointerList.rtlCurrentUserTaskIsStoppable) {
5873: mpuStop (null);
5874: }
5875: } else {
5876: mpuStop (null);
5877: }
5878: }
5879: pnlPanel.requestFocusInWindow ();
5880: break;
5881: }
5882: }
5883: };
5884: mpuMenu = ComponentFactory.createMenu (
5885: "MPU", 'M',
5886: mpuResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset", 'R', MNB_MODIFIERS, listener), "ja", "リセット"),
5887: mpuOpt1ResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Hold down OPT.1 and reset", 'O', MNB_MODIFIERS, listener), "ja", "OPT.1 を押しながらリセット"),
5888: Multilingual.mlnText (ComponentFactory.createMenuItem ("Interrupt", listener), "ja", "インタラプト"),
5889: ComponentFactory.createHorizontalSeparator (),
5890: mdlMenu,
5891: ComponentFactory.createHorizontalSeparator (),
5892: mpuClock10MenuItem = ComponentFactory.createRadioButtonMenuItem (
5893: unitGroup,
5894: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 10.0,
5895: "10MHz",
5896: listener),
5897: mpuClock16MenuItem = ComponentFactory.createRadioButtonMenuItem (
5898: unitGroup,
5899: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0 / 3.0,
5900: "16.7MHz",
5901: listener),
5902: mpuClock25MenuItem = ComponentFactory.createRadioButtonMenuItem (
5903: unitGroup,
5904: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 25.0,
5905: "25MHz",
5906: listener),
5907: mpuClock33MenuItem = ComponentFactory.createRadioButtonMenuItem (
5908: unitGroup,
5909: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0 / 3.0,
5910: "33.3MHz",
5911: listener),
5912: mpuClock50MenuItem = ComponentFactory.createRadioButtonMenuItem (
5913: unitGroup,
5914: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0,
5915: "50MHz",
5916: listener),
5917: mpuClock66MenuItem = ComponentFactory.createRadioButtonMenuItem (
5918: unitGroup,
5919: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 200.0 / 3.0,
5920: "66.7MHz",
5921: listener),
5922: mpuClock75MenuItem = ComponentFactory.createRadioButtonMenuItem (
5923: unitGroup,
5924: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 75.0,
5925: "75MHz",
5926: listener),
5927: mpuClock100MenuItem = ComponentFactory.createRadioButtonMenuItem (
5928: unitGroup,
5929: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0,
5930: "100MHz",
5931: listener),
5932: mpuArbFreqRadioButtonMenuItem = Multilingual.mlnText (
5933: ComponentFactory.createRadioButtonMenuItem (
5934: unitGroup,
5935: mpuArbFreqOn,
5936: "Arbitrary frequency",
5937: listener),
5938: "ja", "任意の周波数"),
5939: ComponentFactory.createHorizontalBox (
5940: Box.createHorizontalStrut (20),
5941: mpuArbFreqSpinner = ComponentFactory.createNumberSpinner (
5942: mpuArbFreqModel = new SpinnerNumberModel (mpuArbFreqMHz, 1, 1000, 1),
5943: 4,
5944: new ChangeListener () {
5945: @Override public void stateChanged (ChangeEvent ce) {
5946:
5947: mpuArbFreqMHz = mpuArbFreqModel.getNumber ().intValue ();
5948: if (mpuArbFreqOn) {
5949: mpuSetCurrentClock ((double) mpuArbFreqMHz);
5950: }
5951: }
5952: }
5953: ),
5954: ComponentFactory.createLabel ("MHz"),
5955: Box.createHorizontalGlue ()
5956: ),
5957: mpuUtilRadioButtonMenuItem = Multilingual.mlnText (
5958: ComponentFactory.createRadioButtonMenuItem (
5959: unitGroup,
5960: mpuUtilOn,
5961: "Arbitrary load factor",
5962: listener),
5963: "ja", "任意の負荷率"),
5964: ComponentFactory.createHorizontalBox (
5965: Box.createHorizontalStrut (20),
5966: mpuUtilSpinner = ComponentFactory.createNumberSpinner (
5967: mpuUtilModel = new SpinnerNumberModel (mpuUtilRatio, 1, 100, 1),
5968: 4,
5969: new ChangeListener () {
5970: @Override public void stateChanged (ChangeEvent ce) {
5971:
5972: mpuUtilRatio = mpuUtilModel.getNumber ().intValue ();
5973: }
5974: }
5975: ),
5976: ComponentFactory.createLabel ("%"),
5977: Box.createHorizontalGlue ()
5978: ),
5979: ComponentFactory.createHorizontalSeparator (),
5980:
5981: coproFPUMenu,
5982:
5983: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkOn, "FE function instruction", listener), "ja", "FE ファンクション命令"),
5984: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkRejectFloatOn, "Reject FLOATn.X", listener), "ja", "FLOATn.X を組み込まない"),
5985: ComponentFactory.createHorizontalSeparator (),
5986: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busRequestCutFC2Pin, "Cut FC2 pin", listener), "ja", "FC2 ピンをカットする"),
5987: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busWaitCyclesRequest, "Wait cycles", listener), "ja", "ウェイトサイクル"),
5988: ComponentFactory.createHorizontalSeparator (),
5989: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM16On, "Use IPLROM 1.6", listener), "ja", "IPLROM 1.6 を使う"),
5990: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM256KOn, "Increase IPLROM to 256KB", listener), "ja", "IPLROM を 256KB に増やす")
5991: );
5992: }
5993:
5994:
5995: public static void mpuSetCurrentClock (double clock) {
5996: specifiedClock = clock;
5997: if (currentIsSecond) {
5998: specifiedSecondClock = clock;
5999: } else {
6000: specifiedFirstClock = clock;
6001: }
6002: if (!mpuArbFreqOn && !mpuUtilOn) {
6003: if (specifiedClock == 10.0) {
6004: mpuClock10MenuItem.setSelected (true);
6005: } else if (specifiedClock == 50.0 / 3.0) {
6006: mpuClock16MenuItem.setSelected (true);
6007: } else if (specifiedClock == 25.0) {
6008: mpuClock25MenuItem.setSelected (true);
6009: } else if (specifiedClock == 100.0 / 3.0) {
6010: mpuClock33MenuItem.setSelected (true);
6011: } else if (specifiedClock == 50.0) {
6012: mpuClock50MenuItem.setSelected (true);
6013: } else if (specifiedClock == 200.0 / 3.0) {
6014: mpuClock66MenuItem.setSelected (true);
6015: } else if (specifiedClock == 75.0) {
6016: mpuClock75MenuItem.setSelected (true);
6017: } else if (specifiedClock == 100.0) {
6018: mpuClock100MenuItem.setSelected (true);
6019: }
6020: }
6021: mpuClockMHz = specifiedClock;
6022: mpuSetClockMHz (mpuClockMHz);
6023: }
6024:
6025:
6026:
6027:
6028:
6029:
6030:
6031:
6032:
6033:
6034:
6035: public static void mpuSetClockMHz (double mhz) {
6036: mhz = Math.max (1.0, Math.min (1000.0, mhz));
6037: double lastMHz = mpuCurrentMHz;
6038: mpuCurrentMHz = mhz;
6039: mpuCycleUnit = (long) (((double) TMR_FREQ / 1000000.0) / mhz + 0.5);
6040:
6041: mpuModifiedUnit = (currentMPU == Model.MPU_MC68EC030 ||
6042: currentMPU == Model.MPU_MC68030 ?
6043: (long) (((double) TMR_FREQ * 3.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6044: currentMPU == Model.MPU_MC68LC040 ||
6045: currentMPU == Model.MPU_MC68040 ?
6046: (long) (((double) TMR_FREQ * 2.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6047: mpuCycleUnit);
6048: if (lastMHz != mhz) {
6049: mpuSetWait ();
6050: }
6051: }
6052:
6053:
6054:
6055:
6056:
6057:
6058:
6059:
6060:
6061:
6062:
6063:
6064:
6065:
6066:
6067:
6068:
6069:
6070:
6071:
6072:
6073:
6074:
6075:
6076:
6077:
6078:
6079:
6080:
6081:
6082:
6083:
6084:
6085:
6086:
6087:
6088:
6089:
6090:
6091:
6092:
6093:
6094:
6095:
6096:
6097:
6098:
6099:
6100:
6101:
6102:
6103:
6104:
6105:
6106:
6107:
6108:
6109:
6110:
6111:
6112:
6113:
6114:
6115:
6116:
6117:
6118:
6119:
6120:
6121:
6122:
6123:
6124:
6125:
6126:
6127:
6128:
6129:
6130:
6131:
6132:
6133: public static void mpuSetWait () {
6134:
6135: if (currentMPU <= Model.MPU_MC68010) {
6136: mpuWaitTime.ram = mpuCycleUnit >> 3;
6137: mpuWaitTime.vicon = (long) (mpuCycleUnit * 0.6);
6138: mpuWaitTime.crtc =
6139: mpuWaitTime.prnport =
6140: mpuWaitTime.sysport =
6141: mpuWaitTime.sprc =
6142: mpuWaitTime.sram =
6143: mpuWaitTime.rom = mpuCycleUnit;
6144: mpuWaitTime.gvram = (long) (mpuCycleUnit * 1.1);
6145: mpuWaitTime.rtc =
6146: mpuWaitTime.opm =
6147: mpuWaitTime.adpcm =
6148: mpuWaitTime.fdc =
6149: mpuWaitTime.fdd =
6150: mpuWaitTime.hdc =
6151: mpuWaitTime.ppi =
6152: mpuWaitTime.ioi = (long) (mpuCycleUnit * 1.7);
6153: mpuWaitTime.tvram = mpuCycleUnit * 2;
6154: mpuWaitTime.palet = (long) (mpuCycleUnit * 2.6);
6155: mpuWaitTime.mfp = (long) (mpuCycleUnit * 4.3);
6156: mpuWaitTime.scc = mpuCycleUnit * 6;
6157: mpuWaitTime.dmac = mpuCycleUnit * 15;
6158: mpuWaitTime.ramlong = mpuWaitTime.ram << 1;
6159: mpuWaitTime.romlong = mpuWaitTime.rom << 1;
6160: } else if (currentMPU <= Model.MPU_MC68030) {
6161: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6162: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6163: mpuWaitTime.sram = mpuCycleUnit * 2;
6164: mpuWaitTime.prnport =
6165: mpuWaitTime.sysport = mpuCycleUnit * 4;
6166: mpuWaitTime.gvram =
6167: mpuWaitTime.crtc =
6168: mpuWaitTime.vicon =
6169: mpuWaitTime.sprc = mpuCycleUnit * 6;
6170: mpuWaitTime.tvram = mpuCycleUnit * 7;
6171: mpuWaitTime.palet = mpuCycleUnit * 11;
6172: mpuWaitTime.opm =
6173: mpuWaitTime.adpcm =
6174: mpuWaitTime.fdc =
6175: mpuWaitTime.fdd =
6176: mpuWaitTime.hdc =
6177: mpuWaitTime.ppi =
6178: mpuWaitTime.ioi = mpuCycleUnit * 15;
6179: mpuWaitTime.mfp = mpuCycleUnit * 19;
6180: mpuWaitTime.rtc = mpuCycleUnit * 28;
6181: mpuWaitTime.dmac = mpuCycleUnit * 34;
6182: mpuWaitTime.scc = mpuCycleUnit * 38;
6183: mpuWaitTime.ramlong = mpuWaitTime.ram;
6184: mpuWaitTime.romlong = mpuWaitTime.rom;
6185: } else {
6186: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6187: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6188: mpuWaitTime.sram = mpuCycleUnit * 13;
6189: mpuWaitTime.prnport =
6190: mpuWaitTime.sysport = mpuCycleUnit * 17;
6191: mpuWaitTime.gvram =
6192: mpuWaitTime.crtc =
6193: mpuWaitTime.vicon =
6194: mpuWaitTime.sprc = mpuCycleUnit * 21;
6195: mpuWaitTime.tvram = mpuCycleUnit * 22;
6196: mpuWaitTime.palet = mpuCycleUnit * 33;
6197: mpuWaitTime.opm =
6198: mpuWaitTime.adpcm =
6199: mpuWaitTime.fdc =
6200: mpuWaitTime.fdd =
6201: mpuWaitTime.hdc =
6202: mpuWaitTime.ppi =
6203: mpuWaitTime.ioi = mpuCycleUnit * 37;
6204: mpuWaitTime.mfp = mpuCycleUnit * 47;
6205: mpuWaitTime.dmac = mpuCycleUnit * 73;
6206: mpuWaitTime.rtc = mpuCycleUnit * 77;
6207: mpuWaitTime.scc = mpuCycleUnit * 97;
6208: mpuWaitTime.ramlong = mpuWaitTime.ram;
6209: mpuWaitTime.romlong = mpuWaitTime.rom;
6210: }
6211: if (true) {
6212: mpuNoWaitTime.sram = mpuWaitTime.sram;
6213: mpuNoWaitTime.rom = mpuWaitTime.rom;
6214: mpuNoWaitTime.romlong = mpuWaitTime.romlong;
6215: }
6216:
6217: dmaWaitTime.ram = dmaCycleUnit >> 3;
6218: dmaWaitTime.sram = 0;
6219: dmaWaitTime.rom = 0;
6220: dmaWaitTime.gvram =
6221: dmaWaitTime.crtc =
6222: dmaWaitTime.vicon =
6223: dmaWaitTime.prnport =
6224: dmaWaitTime.sysport =
6225: dmaWaitTime.sprc = dmaCycleUnit;
6226: dmaWaitTime.tvram =
6227: dmaWaitTime.rtc =
6228: dmaWaitTime.opm =
6229: dmaWaitTime.adpcm =
6230: dmaWaitTime.fdc =
6231: dmaWaitTime.fdd =
6232: dmaWaitTime.hdc =
6233: dmaWaitTime.ppi =
6234: dmaWaitTime.ioi = dmaCycleUnit * 2;
6235: dmaWaitTime.palet = dmaCycleUnit * 3;
6236: dmaWaitTime.mfp = dmaCycleUnit * 4;
6237: dmaWaitTime.scc = dmaCycleUnit * 6;
6238: dmaWaitTime.dmac = dmaCycleUnit * 15;
6239: dmaWaitTime.ramlong = dmaWaitTime.ram << 1;
6240: dmaWaitTime.romlong = dmaWaitTime.rom << 1;
6241: }
6242:
6243:
6244:
6245:
6246:
6247: public static void mpuReset (int device, int romHandle) {
6248:
6249: mpuBootDevice = device;
6250: mpuROMBootHandle = romHandle;
6251:
6252:
6253:
6254:
6255:
6256:
6257:
6258:
6259:
6260:
6261:
6262:
6263: if (mpuBootDevice == -1) {
6264: if (mpuSavedBootDevice != -1) {
6265: mpuBootDevice = mpuSavedBootDevice;
6266: mpuROMBootHandle = mpuSavedROMBootHandle;
6267: mpuSavedBootDevice = -1;
6268: mpuSavedROMBootHandle = -1;
6269: }
6270: } else {
6271: if (mpuSavedBootDevice == -1) {
6272: mpuSavedBootDevice = MainMemory.mmrRwz (0x00ed0018);
6273: mpuSavedROMBootHandle = MainMemory.mmrRls (0x00ed000c);
6274: }
6275: }
6276:
6277:
6278: if (mpu010) {
6279: if (specifiedFirstMPU == Model.MPU_MC68000) {
6280: specifiedFirstMPU = Model.MPU_MC68010;
6281: }
6282: if (specifiedSecondMPU == Model.MPU_MC68000) {
6283: specifiedSecondMPU = Model.MPU_MC68010;
6284: }
6285: } else {
6286: if (specifiedFirstMPU == Model.MPU_MC68010) {
6287: specifiedFirstMPU = Model.MPU_MC68000;
6288: }
6289: if (specifiedSecondMPU == Model.MPU_MC68010) {
6290: specifiedSecondMPU = Model.MPU_MC68000;
6291: }
6292: }
6293:
6294:
6295: specifiedIsSecond = false;
6296: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
6297: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
6298:
6299: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
6300: MC68EC030.m30DivZeroVFlag = false;
6301: }
6302:
6303: if (mpuTask != null) {
6304: mpuClockLimit = 0L;
6305: System.out.println (Multilingual.mlnJapanese ?
6306: "MPU を停止します" :
6307: "MPU stops");
6308: mpuTask.cancel ();
6309: mpuTask = null;
6310: }
6311:
6312: tmrTimer.schedule (new TimerTask () {
6313: @Override public void run () {
6314:
6315:
6316:
6317: currentModel = specifiedModel;
6318: currentAccelerator = specifiedAccelerator;
6319: frmUpdateTitle ();
6320:
6321: currentIsSecond = specifiedIsSecond;
6322: currentFirstMPU = specifiedFirstMPU;
6323: currentSecondMPU = specifiedSecondMPU;
6324: currentMPU = specifiedMPU;
6325:
6326: mpuSetCurrentClock (specifiedClock);
6327:
6328: currentCopro0 = specifiedCopro0;
6329: currentCopro1 = specifiedCopro1;
6330: currentCopro2 = specifiedCopro2;
6331: currentOnchipFPU = specifiedOnchipFPU;
6332:
6333:
6334: if (currentMPU < Model.MPU_MC68020) {
6335: if (busHimem68000) {
6336: busRequestExMemoryStart = 0x10000000;
6337: busRequestExMemorySize = busLocalMemorySize;
6338: busRequestExMemoryArray = busLocalMemoryArray;
6339: } else {
6340: busRequestExMemoryStart = 0x10000000;
6341: busRequestExMemorySize = 0 << 20;
6342: busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
6343: }
6344: } else if (currentMPU < Model.MPU_MC68LC040) {
6345: if (busHighMemory060turboOn) {
6346: busRequestExMemoryStart = 0x10000000;
6347: busRequestExMemorySize = busLocalMemorySize;
6348: busRequestExMemoryArray = busLocalMemoryArray;
6349: } else {
6350: busRequestExMemoryStart = 0x01000000;
6351: busRequestExMemorySize = busHighMemorySize;
6352: busRequestExMemoryArray = busHighMemoryArray;
6353: }
6354: } else {
6355: busRequestExMemoryStart = 0x10000000;
6356: busRequestExMemorySize = busLocalMemorySize;
6357: busRequestExMemoryArray = busLocalMemoryArray;
6358: }
6359: busUpdateMemoryMap ();
6360:
6361:
6362: ROM.romReset ();
6363:
6364: RegisterList.drpSetMPU ();
6365:
6366: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
6367: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6368: MC68060.mmuReset ();
6369:
6370:
6371: if (Model.MPU_MC68020 <= currentMPU) {
6372: if ((7 & currentCopro0) == 1) {
6373: fpuMotherboardCoprocessor.epbSetMC68881 ();
6374: } else if ((7 & currentCopro0) == 2) {
6375: fpuMotherboardCoprocessor.epbSetMC68882 ();
6376: } else {
6377: fpuMotherboardCoprocessor.epbSetFullSpec ();
6378: }
6379: if ((8 & currentCopro0) == 0) {
6380: fpuMotherboardCoprocessor.epbSetExtended ();
6381: } else {
6382: fpuMotherboardCoprocessor.epbSetTriple ();
6383: }
6384: }
6385:
6386: if ((7 & currentCopro1) == 1) {
6387: fpuCoproboard1.epbSetMC68881 ();
6388: } else if ((7 & currentCopro1) == 2) {
6389: fpuCoproboard1.epbSetMC68882 ();
6390: } else {
6391: fpuCoproboard1.epbSetFullSpec ();
6392: }
6393: if ((8 & currentCopro1) == 0) {
6394: fpuCoproboard1.epbSetExtended ();
6395: } else {
6396: fpuCoproboard1.epbSetTriple ();
6397: }
6398:
6399: if ((7 & currentCopro2) == 1) {
6400: fpuCoproboard2.epbSetMC68881 ();
6401: } else if ((7 & currentCopro2) == 2) {
6402: fpuCoproboard2.epbSetMC68882 ();
6403: } else {
6404: fpuCoproboard2.epbSetFullSpec ();
6405: }
6406: if ((8 & currentCopro2) == 0) {
6407: fpuCoproboard2.epbSetExtended ();
6408: } else {
6409: fpuCoproboard2.epbSetTriple ();
6410: }
6411:
6412: if (Model.MPU_MC68040 <= currentMPU) {
6413: if ((7 & currentOnchipFPU) == 6) {
6414: fpuOnChipFPU.epbSetMC68060 ();
6415: } else {
6416: fpuOnChipFPU.epbSetFullSpec ();
6417: }
6418: if ((8 & currentOnchipFPU) == 0) {
6419: fpuOnChipFPU.epbSetExtended ();
6420: } else {
6421: fpuOnChipFPU.epbSetTriple ();
6422: }
6423: }
6424:
6425: if (!currentModel.isX68030 ()) {
6426: dmaCycleUnit = TMR_FREQ / 10000000L;
6427: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6428: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6429: mpuROMWaitCycles = 1;
6430: mpuRAMWaitCycles = 0;
6431: } else {
6432: dmaCycleUnit = TMR_FREQ / 12500000L;
6433: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
6434: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
6435: mpuROMWaitCycles = 0;
6436: mpuRAMWaitCycles = 0;
6437: }
6438:
6439: busWaitCycles = busWaitCyclesRequest;
6440: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
6441:
6442: HD63450.dmaReadCycles = (currentModel.isPRO () ? 6 :
6443: currentModel.isCompact () ? 4 :
6444: 5);
6445: HD63450.dmaWriteCycles = (currentModel.isPRO () ? 6 :
6446: 5);
6447:
6448: if (currentMPU < Model.MPU_MC68020) {
6449:
6450: mpuIgnoreAddressError = false;
6451:
6452: mpuCacheOn = false;
6453:
6454: } else if (currentMPU < Model.MPU_MC68040) {
6455:
6456: mpuIgnoreAddressError = true;
6457: fpuBox = fpuMotherboardCoprocessor;
6458: fpuBox.epbReset ();
6459: fpuFPn = fpuBox.epbFPn;
6460:
6461: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
6462:
6463: } else {
6464:
6465: mpuIgnoreAddressError = true;
6466: fpuBox = fpuOnChipFPU;
6467: fpuBox.epbReset ();
6468: fpuFPn = fpuBox.epbFPn;
6469:
6470: mpuPCR = 0x04300500 | MPU_060_REV << 8;
6471: mpuCacheOn = (mpuCACR & 0x80008000) != 0;
6472:
6473: }
6474:
6475: mpuSetWait ();
6476:
6477:
6478: regSRT1 = regSRT0 = 0;
6479: regSRS = REG_SR_S;
6480: regSRM = 0;
6481: regSRI = REG_SR_I;
6482: regCCR = 0;
6483: Arrays.fill (regRn, 0);
6484:
6485: regRn[15] = MainMemory.mmrRls (0x00ff0000);
6486: regPC = MainMemory.mmrRls (0x00ff0004);
6487:
6488: MainMemory.mmrReset ();
6489:
6490: busReset ();
6491: if (InstructionBreakPoint.IBP_ON) {
6492: InstructionBreakPoint.ibpOp1MemoryMap = InstructionBreakPoint.ibpOp1SuperMap;
6493: InstructionBreakPoint.ibpReset ();
6494: }
6495: if (BranchLog.BLG_ON) {
6496: BranchLog.blgReset ();
6497: }
6498:
6499: mpuIMR = 0;
6500: mpuIRR = 0;
6501: if (MC68901.MFP_DELAYED_INTERRUPT) {
6502: mpuDIRR = 0;
6503: }
6504: mpuISR = 0;
6505:
6506:
6507: mpuStart ();
6508: }
6509: }, TMR_DELAY);
6510:
6511: }
6512:
6513:
6514:
6515: public static void mpuStopAndStart () {
6516: if (mpuTask == null) {
6517: mpuStart ();
6518: } else {
6519: if (RootPointerList.RTL_ON) {
6520: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6521: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6522: mpuStop (null);
6523: }
6524: } else {
6525: mpuStop (null);
6526: }
6527: }
6528: }
6529:
6530:
6531:
6532:
6533:
6534: public static void mpuStart () {
6535: if (mpuTask != null) {
6536: mpuClockLimit = 0L;
6537: System.out.println (Multilingual.mlnJapanese ?
6538: "MPU を停止します" :
6539: "MPU stops");
6540: mpuTask.cancel ();
6541: mpuTask = null;
6542: }
6543:
6544: for (AbstractButton button : mpuButtonsStopped) {
6545: button.setEnabled (false);
6546: }
6547: DisassembleList.ddpStoppedBy = null;
6548: System.out.println (Model.mpuNameOf (currentMPU) + (Multilingual.mlnJapanese ? " を起動します" : " starts up"));
6549: mpuTask = new TimerTask () {
6550: @Override public void run () {
6551: mpuContinue = true;
6552: mpuClockLimit = mpuClockTime + TMR_FREQ * TMR_INTERVAL / 1000;
6553: mpuExecuteCore ();
6554: }
6555: };
6556: tmrTimer.scheduleAtFixedRate (mpuTask, TMR_DELAY, TMR_INTERVAL);
6557:
6558: for (AbstractButton button : mpuButtonsRunning) {
6559: button.setEnabled (true);
6560: }
6561: }
6562:
6563:
6564:
6565: public static void mpuExecuteCore () {
6566:
6567: long nanoStart = System.nanoTime ();
6568:
6569: busSuper (RP5C15.rtcFirst, 0x00e8a000, 0x00e8c000);
6570:
6571:
6572: if (currentMPU < Model.MPU_MC68010) {
6573: MC68000.mpuCore ();
6574: } else if (currentMPU < Model.MPU_MC68020) {
6575: MC68010.mpuCore ();
6576: } else if (currentMPU < Model.MPU_MC68LC040) {
6577: MC68EC030.mpuCore ();
6578: } else {
6579: MC68060.mpuCore ();
6580: }
6581:
6582: if (dbgVisibleMask != 0) {
6583: dbgUpdate ();
6584: }
6585:
6586: long nanoEnd = System.nanoTime ();
6587: mpuTotalNano += nanoEnd - nanoStart;
6588: if (--mpuAdjustmentCounter == 0) {
6589:
6590: final double expectedNano = 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
6591:
6592: double coreNano0 = (double) mpuTotalNano;
6593: mpuTotalNano = 0L;
6594: double coreNanoA = (coreNano0 * 2.0 + mpuCoreNano1 + mpuCoreNano2) * 0.25;
6595: mpuCoreNano2 = mpuCoreNano1;
6596: mpuCoreNano1 = coreNano0;
6597:
6598:
6599:
6600: double actualPercent = Math.max (1.0, 100.0 * coreNanoA / expectedNano);
6601:
6602: double maxPercent = SoundSource.sndPlayOn ? 90.0 : 100.0;
6603:
6604:
6605:
6606:
6607: if (mpuUtilOn) {
6608:
6609: double targetPercent = Math.min (maxPercent, (double) mpuUtilRatio);
6610: mpuSetClockMHz ((1.2 - 0.2 * actualPercent / targetPercent) * mpuCurrentMHz);
6611: } else {
6612: mpuSetClockMHz (Math.min (maxPercent / actualPercent,
6613: 1.2 - 0.2 * mpuCurrentMHz / mpuClockMHz) * mpuCurrentMHz);
6614: }
6615: Indicator.indUpdate (actualPercent);
6616: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
6617: }
6618: }
6619:
6620:
6621:
6622:
6623: public static void mpuStop (String message) {
6624:
6625: mpuAdvanceCount = 0;
6626: mpuStepCount = 0;
6627: mpuContinue = false;
6628: mpuStop1 (message);
6629: }
6630: public static void mpuStop1 (String message) {
6631: if (mpuTask == null) {
6632: return;
6633: }
6634: DisassembleList.ddpStoppedBy = message;
6635: mpuClockLimit = 0L;
6636: System.out.println (Multilingual.mlnJapanese ?
6637: "MPU を停止します" :
6638: "MPU stops");
6639: mpuTask.cancel ();
6640: mpuTask = null;
6641:
6642: if (mpuStepCount != 0 && mpuContinue) {
6643: if (mpuStepCount == -1 || --mpuStepCount != 0) {
6644: mpuStep (mpuStepCount);
6645: return;
6646: }
6647: }
6648: mpuAdvanceCount = 0;
6649: mpuStepCount = 0;
6650: mpuContinue = false;
6651:
6652: for (AbstractButton button : mpuButtonsRunning) {
6653: button.setEnabled (false);
6654: }
6655: tmrTimer.schedule (new TimerTask () {
6656: @Override public void run () {
6657: mpuUpdateWindow ();
6658: }
6659: }, TMR_DELAY);
6660: }
6661:
6662:
6663:
6664:
6665:
6666:
6667: public static void mpuAdvance (int n) {
6668: if (mpuTask != null) {
6669: return;
6670: }
6671: mpuAdvanceCount = n;
6672: DisassembleList.ddpStoppedBy = null;
6673: mpuTask = new TimerTask () {
6674: @Override public void run () {
6675: mpuContinue = true;
6676: do {
6677: mpuClockLimit = mpuClockTime + 1L;
6678: mpuExecuteCore ();
6679: } while (mpuContinue && --mpuAdvanceCount != 0);
6680: mpuClockLimit = 0L;
6681: if (mpuTask != null) {
6682: mpuTask.cancel ();
6683: mpuTask = null;
6684: }
6685: if (mpuStepCount != 0 && mpuContinue) {
6686: if (mpuStepCount == -1 || --mpuStepCount != 0) {
6687: mpuStep (mpuStepCount);
6688: return;
6689: }
6690: }
6691: mpuAdvanceCount = 0;
6692: mpuStepCount = 0;
6693: mpuContinue = false;
6694: mpuUpdateWindow ();
6695: }
6696: };
6697: tmrTimer.schedule (mpuTask, TMR_DELAY);
6698: }
6699:
6700:
6701:
6702:
6703:
6704:
6705: public static void mpuStep (int n) {
6706: if (mpuTask != null) {
6707: return;
6708: }
6709: mpuStepCount = n;
6710: Disassembler.disDisassemble (new StringBuilder (), regPC, regSRS);
6711: if ((Disassembler.disStatus & (Disassembler.DIS_ALWAYS_BRANCH | Disassembler.DIS_SOMETIMES_BRANCH)) != 0) {
6712: if (mpuStepCount == -1 &&
6713: (Disassembler.disOC == 0x4e73 ||
6714: Disassembler.disOC == 0x4e74 ||
6715: Disassembler.disOC == 0x4e75 ||
6716: Disassembler.disOC == 0x4e77) &&
6717: mpuUntilReturnSRS == regSRS &&
6718: (currentMPU < Model.MPU_MC68LC040 ||
6719: mpuUntilReturnRP == (regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP)) &&
6720: mpuUntilReturnPC0 != regPC0 &&
6721: Integer.compareUnsigned (mpuUntilReturnSP, regRn[15]) <= 0) {
6722: mpuAdvanceCount = 0;
6723: mpuStepCount = 0;
6724: mpuContinue = false;
6725: mpuUpdateWindow ();
6726: return;
6727: }
6728: mpuAdvance (1);
6729: } else {
6730: if (InstructionBreakPoint.IBP_ON) {
6731: InstructionBreakPoint.ibpInstant (Disassembler.disPC, DisassembleList.ddpSupervisorMode);
6732: mpuStart ();
6733: }
6734: }
6735: }
6736:
6737:
6738:
6739:
6740:
6741:
6742:
6743:
6744:
6745:
6746:
6747: public static void mpuStepUntilReturn () {
6748: if (mpuTask != null) {
6749: return;
6750: }
6751: mpuUntilReturnSRS = regSRS;
6752: mpuUntilReturnRP = regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP;
6753: mpuUntilReturnPC0 = regPC0;
6754: mpuUntilReturnSP = regRn[15];
6755: mpuStep (-1);
6756: }
6757:
6758:
6759:
6760: public static void mpuUpdateWindow () {
6761: if (dbgVisibleMask != 0) {
6762: if ((dbgVisibleMask & DBG_DDP_VISIBLE_MASK) != 0) {
6763: DisassembleList.ddpBacktraceRecord = -1L;
6764: DisassembleList.ddpUpdate (-1, -1, false);
6765: }
6766: if (BranchLog.BLG_ON) {
6767: if ((dbgVisibleMask & DBG_BLG_VISIBLE_MASK) != 0) {
6768: BranchLog.blgUpdate (BranchLog.BLG_SELECT_NEWEST);
6769: }
6770: }
6771: if (ProgramFlowVisualizer.PFV_ON) {
6772: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
6773: ProgramFlowVisualizer.pfvUpdate ();
6774: }
6775: }
6776: if (RasterBreakPoint.RBP_ON) {
6777: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
6778: RasterBreakPoint.rbpUpdateFrame ();
6779: }
6780: }
6781: if (ScreenModeTest.SMT_ON) {
6782: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
6783: ScreenModeTest.smtUpdateFrame ();
6784: }
6785: }
6786: if (RootPointerList.RTL_ON) {
6787: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
6788: RootPointerList.rtlUpdateFrame ();
6789: }
6790: }
6791: if (SpritePatternViewer.SPV_ON) {
6792: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
6793: SpritePatternViewer.spvUpdateFrame ();
6794: }
6795: }
6796: if (ATCMonitor.ACM_ON) {
6797: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
6798: ATCMonitor.acmUpdateFrame ();
6799: }
6800: }
6801: }
6802:
6803: if (DebugConsole.dgtRequestRegs != 0) {
6804: if ((DebugConsole.dgtRequestRegs & 1) != 0) {
6805: ExpressionEvaluator.ElementType.ETY_COMMAND_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
6806: }
6807: if ((DebugConsole.dgtRequestRegs & 2) != 0) {
6808: ExpressionEvaluator.ElementType.ETY_COMMAND_FLOAT_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
6809: }
6810: if ((DebugConsole.dgtRequestRegs & 4) != 0) {
6811: DebugConsole.dgtPrintPrompt ();
6812: }
6813: DebugConsole.dgtRequestRegs = 0;
6814: }
6815:
6816: for (AbstractButton button : mpuButtonsRunning) {
6817: button.setEnabled (false);
6818: }
6819:
6820: for (AbstractButton button : mpuButtonsStopped) {
6821: button.setEnabled (true);
6822: }
6823: }
6824:
6825:
6826:
6827: public static JButton mpuMakeBreakButton () {
6828: return mpuAddButtonRunning (
6829: Multilingual.mlnToolTipText (
6830: ComponentFactory.createImageButton (
6831: LnF.LNF_BREAK_IMAGE,
6832: LnF.LNF_BREAK_DISABLED_IMAGE,
6833: "Stop", mpuDebugActionListener),
6834: "ja", "停止")
6835: );
6836: }
6837:
6838:
6839:
6840: public static JButton mpuMakeTraceButton () {
6841: return mpuAddButtonStopped (
6842: Multilingual.mlnToolTipText (
6843: ComponentFactory.createImageButton (
6844: LnF.LNF_TRACE_IMAGE,
6845: LnF.LNF_TRACE_DISABLED_IMAGE,
6846: "Trace", mpuDebugActionListener),
6847: "ja", "トレース")
6848: );
6849: }
6850:
6851:
6852:
6853: public static JButton mpuMakeTrace10Button () {
6854: return mpuAddButtonStopped (
6855: Multilingual.mlnToolTipText (
6856: ComponentFactory.createImageButton (
6857: LnF.LNF_TRACE_10_IMAGE,
6858: LnF.LNF_TRACE_10_DISABLED_IMAGE,
6859: "Trace 10 times", mpuDebugActionListener),
6860: "ja", "トレース 10 回")
6861: );
6862: }
6863:
6864:
6865:
6866: public static JButton mpuMakeTrace100Button () {
6867: return mpuAddButtonStopped (
6868: Multilingual.mlnToolTipText (
6869: ComponentFactory.createImageButton (
6870: LnF.LNF_TRACE_100_IMAGE,
6871: LnF.LNF_TRACE_100_DISABLED_IMAGE,
6872: "Trace 100 times", mpuDebugActionListener),
6873: "ja", "トレース 100 回")
6874: );
6875: }
6876:
6877:
6878:
6879: public static JButton mpuMakeStepButton () {
6880: return mpuAddButtonStopped (
6881: Multilingual.mlnToolTipText (
6882: ComponentFactory.createImageButton (
6883: LnF.LNF_STEP_IMAGE,
6884: LnF.LNF_STEP_DISABLED_IMAGE,
6885: "Step", mpuDebugActionListener),
6886: "ja", "ステップ")
6887: );
6888: }
6889:
6890:
6891:
6892: public static JButton mpuMakeStep10Button () {
6893: return mpuAddButtonStopped (
6894: Multilingual.mlnToolTipText (
6895: ComponentFactory.createImageButton (
6896: LnF.LNF_STEP_10_IMAGE,
6897: LnF.LNF_STEP_10_DISABLED_IMAGE,
6898: "Step 10 times", mpuDebugActionListener),
6899: "ja", "ステップ 10 回")
6900: );
6901: }
6902:
6903:
6904:
6905: public static JButton mpuMakeStep100Button () {
6906: return mpuAddButtonStopped (
6907: Multilingual.mlnToolTipText (
6908: ComponentFactory.createImageButton (
6909: LnF.LNF_STEP_100_IMAGE,
6910: LnF.LNF_STEP_100_DISABLED_IMAGE,
6911: "Step 100 times", mpuDebugActionListener),
6912: "ja", "ステップ 100 回")
6913: );
6914: }
6915:
6916:
6917:
6918: public static JButton mpuMakeReturnButton () {
6919: return mpuAddButtonStopped (
6920: Multilingual.mlnToolTipText (
6921: ComponentFactory.createImageButton (
6922: LnF.LNF_STEP_UNTIL_RETURN_IMAGE,
6923: LnF.LNF_STEP_UNTIL_RETURN_DISABLED_IMAGE,
6924: "Step until return", mpuDebugActionListener),
6925: "ja", "ステップアンティルリターン")
6926: );
6927: }
6928:
6929:
6930:
6931: public static JButton mpuMakeRunButton () {
6932: return mpuAddButtonStopped (
6933: Multilingual.mlnToolTipText (
6934: ComponentFactory.createImageButton (
6935: LnF.LNF_RUN_IMAGE,
6936: LnF.LNF_RUN_DISABLED_IMAGE,
6937: "Run", mpuDebugActionListener),
6938: "ja", "実行")
6939: );
6940: }
6941:
6942:
6943:
6944: public static <T extends AbstractButton> T mpuAddButtonRunning (T button) {
6945: button.setEnabled (mpuTask != null);
6946: mpuButtonsRunning.add (button);
6947: return button;
6948: }
6949:
6950:
6951:
6952: public static <T extends AbstractButton> T mpuAddButtonStopped (T button) {
6953: button.setEnabled (mpuTask == null);
6954: mpuButtonsStopped.add (button);
6955: return button;
6956: }
6957:
6958:
6959:
6960:
6961:
6962:
6963:
6964:
6965:
6966:
6967:
6968:
6969:
6970:
6971:
6972:
6973: public static final int EMX_OPCODE_BASE = 0x4e00;
6974: public static final int EMX_OPCODE_HFSBOOT = EMX_OPCODE_BASE + 0x00;
6975: public static final int EMX_OPCODE_HFSINST = EMX_OPCODE_BASE + 0x01;
6976: public static final int EMX_OPCODE_HFSSTR = EMX_OPCODE_BASE + 0x02;
6977: public static final int EMX_OPCODE_HFSINT = EMX_OPCODE_BASE + 0x03;
6978: public static final int EMX_OPCODE_EMXNOP = EMX_OPCODE_BASE + 0x04;
6979: public static final int EMX_OPCODE_EMXWAIT = EMX_OPCODE_BASE + 0x05;
6980:
6981: public static final String[] EMX_MNEMONIC_ARRAY = {
6982: "hfsboot",
6983: "hfsinst",
6984: "hfsstr",
6985: "hfsint",
6986: "emxnop",
6987: "emxwait",
6988: };
6989:
6990:
6991:
6992:
6993: public static void emxNop () {
6994: if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x00007140) {
6995: int head = regRn[9];
6996: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
6997:
6998:
6999: emxPatchPCM8A (head, tail);
7000:
7001:
7002: emxCheckRSDRV202 (head, tail);
7003: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000716c) {
7004: int head = regRn[9];
7005: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7006:
7007:
7008: emxPatch060turbosys (head, tail);
7009:
7010:
7011: if (Z8530.SCC_FSX_MOUSE) {
7012: emxCheckFSX (head, tail);
7013: }
7014:
7015:
7016: if (HFS.HFS_USE_TWENTY_ONE) {
7017: emxCheckTwentyOne (head, tail);
7018: }
7019:
7020:
7021: LabeledAddress.lblClear ();
7022: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000972c) {
7023: int head = regRn[8] + 256;
7024:
7025: int tail = MC68060.mmuPeekLong (head - 208, 1);
7026:
7027:
7028: emxCheckBSIO021 (head, tail);
7029:
7030:
7031: emxPatchPCM8A (head, tail);
7032:
7033:
7034: emxCheckTMSIO031 (head, tail);
7035:
7036:
7037: LabeledAddress.lblClear ();
7038:
7039:
7040: if (dbgStopAtStart) {
7041: InstructionBreakPoint.ibpInstant (regRn[12], 0);
7042: }
7043: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000a090) {
7044: int head = regRn[8] + 256;
7045: int tail = MC68060.mmuPeekLongData (regRn[8] + 8, 1);
7046: String name = MC68060.mmuPeekStringZ (head - 60, 1);
7047: if (name.equalsIgnoreCase ("fsx.x")) {
7048:
7049:
7050: if (Z8530.SCC_FSX_MOUSE) {
7051: emxCheckFSX (head, tail);
7052: }
7053: }
7054: if (name.equalsIgnoreCase ("TwentyOne.x")) {
7055:
7056:
7057: if (HFS.HFS_USE_TWENTY_ONE) {
7058: emxCheckTwentyOne (head, tail);
7059: }
7060: }
7061: }
7062: }
7063:
7064: public static final int[] emxPCM8AFFMap = {
7065: 0x00000138, 0x000001f6, 0x00000394, 0x000011ec, 0x0000120a, 0x00001400, 0x00001814, 0x00001870, 0x00001882, 0x0000188a,
7066: 0x00001892, 0x000018a2, 0x000018a8, 0x000018ca, 0x000018d4, 0x000018e0, 0x000018e8, 0x00001908, 0x000019e4, 0x00001afa,
7067: 0x00001b58, 0x00001b7c, 0x00001bac, 0x00001c38, 0x00001ccc, 0x000021f8, 0x00002250, 0x00002258, 0x00002290, 0x000022a6,
7068: 0x000022b0, 0x000022c0, 0x000022c8, 0x000022de, 0x000022ea, 0x000030c8, 0x000030de, 0x000030e6, 0x000030ea, 0x000030f6,
7069: 0x00003112, 0x00003188, 0x0000334c, 0x0000338a, 0x000033a2, 0x000033c4, 0x000033d0, 0x0000341a, 0x00003428, 0x00003496,
7070: 0x000034a6, 0x000034d6, 0x0000fe0e, 0x0000fec8, 0x0000feec, 0x0000ff46, 0x0000ff4e,
7071: };
7072:
7073:
7074:
7075: public static void emxPatchPCM8A (int head, int tail) {
7076: if (head + 0x0000ff60 <= tail &&
7077: MC68060.mmuPeekLongData (head + 0x10f8, 1) == 0x50434d38 &&
7078: MC68060.mmuPeekLongData (head + 0x10fc, 1) == 0x41313032) {
7079: System.out.println (Multilingual.mlnJapanese ?
7080: "PCM8A.X 1.02 があります" :
7081: "PCM8A.X 1.02 exists");
7082: int patched = 0;
7083: int failed = 0;
7084:
7085: for (int offset : emxPCM8AFFMap) {
7086: if (MC68060.mmuPeekByteZeroData (head + offset, 1) == 0xff) {
7087: MC68060.mmuPokeByteData (head + offset, 0x00, 1);
7088: patched++;
7089: } else {
7090: failed++;
7091: }
7092: }
7093: if (patched != 0) {
7094: System.out.printf (Multilingual.mlnJapanese ?
7095: "PCM8A.X 1.02 にパッチをあてました (%d/%d)\n" :
7096: "PCM8A.X 1.02 was patched (%d/%d)\n",
7097: patched, patched + failed);
7098: }
7099: }
7100: }
7101:
7102:
7103:
7104: public static void emxPatch060turbosys (int head, int tail) {
7105:
7106:
7107:
7108:
7109: if (head + 0x00002000 <= tail &&
7110: MC68060.mmuPeekLongData (head + 0x00000ec0, 1) == 0x203c302e &&
7111: MC68060.mmuPeekLongData (head + 0x00000ec4, 1) == 0x3536227c &&
7112: MC68060.mmuPeekLongData (head + 0x00000ec8, 1) == 0x30363054) {
7113: System.out.println (Multilingual.mlnJapanese ?
7114: "060turbo.sys 0.56 があります" :
7115: "060turbo.sys 0.56 exists");
7116:
7117:
7118:
7119: int patched = 0;
7120: int failed = 0;
7121: if (MC68060.mmuPeekLongData (head + 0x000021e6, 1) == 0x08f90004 &&
7122: MC68060.mmuPeekLongData (head + 0x000021ea, 1) == 0x00ed0070) {
7123: MC68060.mmuPokeWordData (head + 0x000021e6, 0x0839, 1);
7124: patched++;
7125: } else {
7126: failed++;
7127: }
7128: System.out.printf (Multilingual.mlnJapanese ?
7129: "060turbo.sys 0.56 にパッチをあてました (%d/%d)\n" :
7130: "060turbo.sys 0.56 was patched (%d/%d)\n",
7131: patched, patched + failed);
7132: }
7133: }
7134:
7135:
7136:
7137: public static void emxCheckFSX (int head, int tail) {
7138: if (Z8530.SCC_FSX_MOUSE) {
7139: if (head + 0x00063200 <= tail &&
7140: "\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))) {
7141: System.out.println (Multilingual.mlnJapanese ?
7142: "FSX.X 3.10 があります" :
7143: "FSX.X 3.10 exists");
7144: Z8530.sccFSXMouseHook = head + 0x04f82a;
7145: Z8530.sccFSXMouseWork = head + 0x063184;
7146: }
7147: }
7148: }
7149:
7150:
7151:
7152:
7153:
7154:
7155: public static void emxCheckRSDRV202 (int head, int tail) {
7156: if (head + 0x000ea6 <= tail &&
7157: MC68060.mmuPeekEquals (head + 0x000e4e, "RS-232C DRIVER for X68000 version 2.02")) {
7158: if (RS232CTerminal.trmRSDRV202Head != head) {
7159: RS232CTerminal.trmRSDRV202Head = head;
7160: int[] patchData = {
7161:
7162:
7163: 0x05f8, 0x000a, 0x000b,
7164:
7165: 0x0600, 0xd040, 0x2048,
7166:
7167: 0x060e, 0x3030, 0x4e90,
7168: 0x0610, 0x0000, 0x2048,
7169:
7170: 0x074e, 0x0821, 0x2041,
7171: 0x0750, 0x0410, 0x3200,
7172: 0x0752, 0x0207, 0x303c,
7173: 0x0754, 0x0102, 0x0823,
7174: 0x0756, 0x0080, 0xe268,
7175: 0x0758, 0x003f, 0x72fe,
7176: 0x075a, 0x001f, 0xd141,
7177: 0x075c, 0x000e, 0x2208,
7178: 0x075e, 0x0006, 0x4e75,
7179:
7180:
7181: 0x0ab0, 0x0040, 0x0400,
7182: 0x0ad2, 0x0040, 0x0400,
7183: 0x0af4, 0x0040, 0x0400,
7184: 0x0b16, 0x0040, 0x0400,
7185: 0x0b38, 0x0040, 0x0400,
7186:
7187:
7188: 0x0cae, 0x0009, 0x000b,
7189: };
7190: int patched = 0;
7191: int failed = 0;
7192: for (int i = 0; i < patchData.length; i += 3) {
7193: int a = head + patchData[i];
7194: int b = patchData[i + 1];
7195: int c = patchData[i + 2];
7196: int d = MC68060.mmuPeekWordZeroData (a, 1);
7197: if (d == b) {
7198: MC68060.mmuPokeWordData (a, c, 1);
7199: patched++;
7200: } else if (d != c) {
7201: failed++;
7202: }
7203: }
7204: System.out.printf ("RSDRV.SYS 2.02 found at %08X and patched (%d/%d)\n", head, patched, patched + failed);
7205: }
7206: }
7207: }
7208:
7209:
7210:
7211:
7212:
7213: public static void emxCheckTMSIO031 (int head, int tail) {
7214: if (head + 0x000fc4 <= tail &&
7215: MC68060.mmuPeekEquals (head + 0x000d1c, "TMSIO version 0.31 Copyright (C) 1990-93 by Miki Hoshino")) {
7216: if (RS232CTerminal.trmTMSIO031Head != head) {
7217: RS232CTerminal.trmTMSIO031Head = head;
7218: System.out.printf ("TMSIO 0.31 found at %08X\n", head);
7219: }
7220: }
7221: }
7222:
7223:
7224:
7225:
7226:
7227: public static void emxCheckBSIO021 (int head, int tail) {
7228: if (head + 0x001c2c <= tail &&
7229: MC68060.mmuPeekEquals (head + 0x001a66, "BSIO version 0.21 Copyright (C) 1994 By BAZU")) {
7230: if (RS232CTerminal.trmBSIO021Head != head) {
7231: RS232CTerminal.trmBSIO021Head = head;
7232: System.out.printf ("BSIO 0.21 found at %08X\n", head);
7233: }
7234: }
7235: }
7236:
7237:
7238:
7239: public static void emxCheckTwentyOne (int head, int tail) {
7240: if (HFS.HFS_USE_TWENTY_ONE &&
7241: head + 64 <= tail) {
7242: if (MainMemory.mmrTwentyOneOptionAddress != 0 ||
7243: MainMemory.mmrHumanVersion <= 0) {
7244: return;
7245: }
7246: int name1 = MC68060.mmuPeekLongData (head + 14, 1);
7247: if (name1 == ('*' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7248: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7249: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '*')) {
7250: MainMemory.mmrTwentyOneOptionAddress = -1;
7251: }
7252: } else if (name1 == ('?' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7253: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7254: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '?') ||
7255: name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | 'E')) {
7256: System.out.println (Multilingual.mlnJapanese ?
7257: "TwentyOne.x があります" :
7258: "TwentyOne.x exists");
7259: MainMemory.mmrTwentyOneOptionAddress = head + 22;
7260: }
7261: }
7262: }
7263: }
7264:
7265:
7266:
7267:
7268:
7269:
7270:
7271:
7272:
7273:
7274:
7275:
7276:
7277:
7278:
7279:
7280:
7281:
7282:
7283:
7284:
7285:
7286:
7287:
7288:
7289:
7290:
7291:
7292:
7293:
7294:
7295:
7296:
7297:
7298:
7299:
7300:
7301:
7302:
7303:
7304:
7305:
7306:
7307:
7308:
7309:
7310:
7311:
7312:
7313:
7314:
7315: public static final boolean IRP_BITREV_REVERSE = false;
7316: public static final boolean IRP_BITREV_SHIFT = false;
7317: public static final boolean IRP_BITREV_TABLE = true;
7318:
7319: public static final boolean IRP_MOVEM_MAINMEMORY = true;
7320: public static final boolean IRP_MOVEM_EXPAND = false;
7321: public static final boolean IRP_MOVEM_LOOP = false;
7322: public static final boolean IRP_MOVEM_SHIFT_LEFT = false;
7323: public static final boolean IRP_MOVEM_SHIFT_RIGHT = true;
7324: public static final boolean IRP_MOVEM_ZEROS = false;
7325:
7326:
7327: public static void irpReset () {
7328:
7329: CRTC.crtReset ();
7330: VideoController.vcnReset ();
7331: HD63450.dmaReset ();
7332: MC68901.mfpReset ();
7333: Keyboard.kbdReset ();
7334: RP5C15.rtcReset ();
7335: PrinterPort.prnReset ();
7336: SoundSource.sndReset ();
7337: OPM.opmReset ();
7338: ADPCM.pcmReset ();
7339: FDC.fdcReset ();
7340: IOInterrupt.ioiReset ();
7341: eb2Reset ();
7342: if (HostCDROM.HCD_ENABLED) {
7343: HostCDROM.hcdReset ();
7344: }
7345: SPC.spcReset ();
7346: Z8530.sccReset ();
7347: RS232CTerminal.trmReset ();
7348: PPI.ppiReset ();
7349: HFS.hfsReset ();
7350: SpriteScreen.sprReset ();
7351:
7352: xt3Reset ();
7353: SRAM.smrReset ();
7354: CONDevice.conReset ();
7355: TextCopy.txcReset ();
7356: }
7357:
7358:
7359:
7360:
7361:
7362:
7363:
7364:
7365:
7366:
7367:
7368:
7369:
7370:
7371:
7372:
7373:
7374:
7375:
7376:
7377:
7378:
7379:
7380:
7381:
7382:
7383:
7384:
7385:
7386:
7387:
7388:
7389:
7390:
7391:
7392:
7393:
7394:
7395:
7396:
7397:
7398:
7399:
7400:
7401:
7402:
7403:
7404:
7405:
7406:
7407:
7408:
7409:
7410:
7411:
7412:
7413:
7414:
7415:
7416:
7417:
7418:
7419:
7420:
7421:
7422:
7423:
7424:
7425:
7426:
7427:
7428:
7429:
7430:
7431:
7432:
7433:
7434:
7435:
7436:
7437:
7438:
7439:
7440:
7441:
7442:
7443:
7444:
7445:
7446:
7447:
7448:
7449:
7450:
7451:
7452:
7453:
7454:
7455:
7456:
7457:
7458:
7459:
7460:
7461:
7462:
7463:
7464:
7465:
7466:
7467:
7468:
7469:
7470:
7471:
7472:
7473:
7474:
7475:
7476:
7477:
7478:
7479:
7480:
7481:
7482:
7483:
7484:
7485:
7486:
7487:
7488:
7489:
7490:
7491:
7492:
7493:
7494:
7495:
7496:
7497:
7498:
7499:
7500:
7501:
7502:
7503:
7504:
7505:
7506:
7507:
7508:
7509:
7510:
7511:
7512:
7513:
7514:
7515:
7516:
7517:
7518:
7519:
7520:
7521:
7522:
7523:
7524:
7525:
7526:
7527:
7528:
7529:
7530:
7531:
7532:
7533:
7534:
7535:
7536:
7537:
7538:
7539:
7540:
7541:
7542:
7543:
7544:
7545:
7546:
7547:
7548:
7549:
7550:
7551:
7552:
7553:
7554:
7555:
7556:
7557:
7558:
7559:
7560:
7561:
7562:
7563:
7564:
7565:
7566:
7567:
7568:
7569:
7570:
7571:
7572:
7573:
7574:
7575:
7576:
7577:
7578:
7579:
7580:
7581:
7582:
7583:
7584:
7585:
7586:
7587:
7588:
7589:
7590:
7591:
7592:
7593:
7594:
7595:
7596:
7597:
7598:
7599:
7600:
7601:
7602:
7603:
7604:
7605:
7606:
7607:
7608:
7609:
7610:
7611:
7612:
7613:
7614:
7615:
7616:
7617:
7618:
7619:
7620:
7621:
7622:
7623:
7624:
7625:
7626:
7627:
7628:
7629:
7630:
7631:
7632:
7633:
7634:
7635:
7636:
7637:
7638:
7639:
7640:
7641:
7642:
7643:
7644:
7645:
7646:
7647:
7648:
7649:
7650:
7651:
7652:
7653:
7654:
7655:
7656:
7657:
7658:
7659:
7660:
7661:
7662:
7663:
7664:
7665:
7666:
7667:
7668:
7669:
7670:
7671:
7672:
7673:
7674:
7675:
7676:
7677:
7678:
7679:
7680:
7681:
7682:
7683:
7684:
7685:
7686:
7687:
7688:
7689:
7690:
7691:
7692:
7693:
7694:
7695:
7696:
7697:
7698:
7699:
7700:
7701:
7702:
7703:
7704:
7705:
7706:
7707:
7708:
7709:
7710:
7711:
7712:
7713:
7714:
7715:
7716:
7717:
7718:
7719:
7720:
7721:
7722:
7723:
7724:
7725:
7726:
7727:
7728:
7729:
7730:
7731:
7732:
7733:
7734:
7735:
7736:
7737:
7738:
7739:
7740:
7741:
7742:
7743:
7744:
7745:
7746:
7747:
7748:
7749:
7750:
7751:
7752:
7753:
7754:
7755:
7756:
7757:
7758:
7759:
7760:
7761:
7762:
7763:
7764:
7765:
7766:
7767:
7768:
7769:
7770:
7771:
7772:
7773:
7774:
7775:
7776:
7777:
7778:
7779:
7780:
7781:
7782:
7783:
7784:
7785:
7786:
7787:
7788:
7789:
7790:
7791:
7792:
7793:
7794:
7795:
7796:
7797:
7798:
7799:
7800:
7801:
7802:
7803:
7804:
7805:
7806:
7807:
7808:
7809:
7810:
7811:
7812:
7813:
7814:
7815:
7816:
7817:
7818:
7819:
7820:
7821:
7822:
7823:
7824:
7825:
7826:
7827:
7828:
7829:
7830:
7831:
7832:
7833:
7834:
7835:
7836:
7837:
7838:
7839:
7840:
7841:
7842:
7843:
7844:
7845:
7846:
7847:
7848:
7849:
7850:
7851:
7852:
7853:
7854:
7855:
7856:
7857:
7858:
7859:
7860:
7861:
7862:
7863:
7864:
7865:
7866:
7867:
7868:
7869:
7870:
7871:
7872:
7873:
7874:
7875:
7876:
7877:
7878:
7879:
7880:
7881:
7882:
7883:
7884:
7885:
7886:
7887:
7888:
7889:
7890:
7891:
7892:
7893:
7894:
7895:
7896:
7897:
7898:
7899:
7900:
7901:
7902:
7903:
7904:
7905:
7906:
7907:
7908:
7909:
7910:
7911:
7912:
7913:
7914:
7915:
7916:
7917:
7918:
7919:
7920:
7921:
7922:
7923:
7924:
7925:
7926:
7927:
7928:
7929:
7930:
7931:
7932:
7933:
7934:
7935:
7936:
7937:
7938:
7939:
7940:
7941:
7942:
7943: 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);
7944:
7945: public static final boolean EFA_SEPARATE_AR = false;
7946:
7947:
7948:
7949:
7950:
7951:
7952: public static final boolean BUS_SPLIT_UNALIGNED_LONG = false;
7953:
7954:
7955: public static final int BUS_MOTHER_BITS = 24;
7956: public static final int BUS_MOTHER_SIZE = BUS_MOTHER_BITS < 32 ? 1 << BUS_MOTHER_BITS : 0;
7957: public static final int BUS_MOTHER_MASK = BUS_MOTHER_SIZE - 1;
7958:
7959: public static final int BUS_ARRAY_SIZE = BUS_MOTHER_SIZE;
7960:
7961:
7962: public static final int BUS_PAGE_BITS = 12;
7963: public static final int BUS_PAGE_SIZE = 1 << BUS_PAGE_BITS;
7964: public static final int BUS_PAGE_COUNT = 1 << (32 - BUS_PAGE_BITS);
7965:
7966:
7967: public static final int MPU_SS_BYTE = 0;
7968: public static final int MPU_SS_WORD = 1;
7969: public static final int MPU_SS_LONG = 2;
7970:
7971:
7972: public static final int MPU_WR_WRITE = 0;
7973: public static final int MPU_WR_READ = 1;
7974:
7975:
7976: public static final int MPU_US_USER = 0;
7977: public static final int MPU_US_SUPERVISOR = 1;
7978:
7979:
7980: public static final MemoryMappedDevice[] busUserMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
7981: public static final MemoryMappedDevice[] busSuperMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
7982: public static MemoryMappedDevice[] busMemoryMap;
7983:
7984:
7985: public static boolean busHimem68000;
7986:
7987:
7988: public static final int BUS_HIGH_MEMORY_START = 0x01000000;
7989: public static int busHighMemorySize;
7990: public static byte[] busHighMemoryArray;
7991: public static boolean busHighMemorySaveOn;
7992: public static boolean busHighMemory060turboOn;
7993:
7994:
7995: public static final int BUS_LOCAL_MEMORY_START = 0x10000000;
7996: public static int busLocalMemorySize;
7997: public static byte[] busLocalMemoryArray;
7998: public static boolean busLocalMemorySaveOn;
7999:
8000:
8001: public static final byte[] BUS_DUMMY_MEMORY_ARRAY = new byte[0];
8002: public static int busRequestExMemoryStart;
8003: public static int busRequestExMemorySize;
8004: public static byte[] busRequestExMemoryArray;
8005: public static int busExMemoryStart;
8006: public static int busExMemorySize;
8007: public static byte[] busExMemoryArray;
8008:
8009:
8010: public static boolean busRequestCutFC2Pin;
8011: public static boolean busCutFC2Pin;
8012:
8013:
8014:
8015: public static void busInit () {
8016:
8017:
8018: if (!DataBreakPoint.DBP_ON) {
8019: busMemoryMap = busSuperMap;
8020: }
8021:
8022:
8023: int highMemorySizeMB = Settings.sgsGetInt ("highmemory");
8024: busHighMemorySize = highMemorySizeMB == 16 ? highMemorySizeMB << 20 : 0 << 20;
8025: if (busHighMemorySize == 0) {
8026: System.out.println (Multilingual.mlnJapanese ?
8027: "X68030/Xellent30 のハイメモリはありません" :
8028: "X68030/Xellent30 high memory does not exists");
8029: } else {
8030: System.out.printf (Multilingual.mlnJapanese ?
8031: "X68030/Xellent30 のハイメモリのサイズは %dMB です\n" :
8032: "X68030/Xellent30 high memory size is %dMB\n",
8033: busHighMemorySize >> 20);
8034: }
8035: busHighMemoryArray = new byte[busHighMemorySize];
8036:
8037: busHimem68000 = Settings.sgsGetOnOff ("himem68000");
8038:
8039: busHighMemorySaveOn = Settings.sgsGetOnOff ("highmemorysave");
8040: busHighMemory060turboOn = Settings.sgsGetOnOff ("highmemory060turbo");
8041:
8042: byte[] highMemoryArray = Settings.sgsGetData ("highmemorydata");
8043: if (busHighMemorySize != 0) {
8044: if (highMemoryArray.length != 0) {
8045: System.out.println (Multilingual.mlnJapanese ?
8046: "X68030/Xellent30 のハイメモリのデータを復元します" :
8047: "X68030/Xellent30 high memory data is restored");
8048: System.arraycopy (highMemoryArray, 0, busHighMemoryArray, 0, Math.min (highMemoryArray.length, busHighMemorySize));
8049: } else {
8050: System.out.println (Multilingual.mlnJapanese ?
8051: "X68030/Xellent30 のハイメモリをゼロクリアします" :
8052: "X68030/Xellent30 high memory is zero-cleared");
8053: }
8054: if (highMemoryArray.length < busHighMemorySize) {
8055: Arrays.fill (busHighMemoryArray, highMemoryArray.length, busHighMemorySize, (byte) 0);
8056: }
8057: }
8058:
8059:
8060: int localMemorySizeMB = Settings.sgsGetInt ("localmemory");
8061: busLocalMemorySize = (localMemorySizeMB == 16 ||
8062: localMemorySizeMB == 32 ||
8063: localMemorySizeMB == 64 ||
8064: localMemorySizeMB == 128 ||
8065: localMemorySizeMB == 256 ||
8066: localMemorySizeMB == 384 ||
8067: localMemorySizeMB == 512 ||
8068: localMemorySizeMB == 768 ?
8069: localMemorySizeMB << 20 :
8070: 128 << 20);
8071: if (busLocalMemorySize == 0) {
8072: System.out.println (Multilingual.mlnJapanese ?
8073: "060turbo のハイメモリはありません" :
8074: "060turbo high memory does not exists");
8075: } else {
8076: System.out.printf (Multilingual.mlnJapanese ?
8077: "060turbo のハイメモリのサイズは %dMB です\n" :
8078: "060turbo high memory size is %dMB\n",
8079: busLocalMemorySize >> 20);
8080: }
8081: busLocalMemoryArray = new byte[busLocalMemorySize];
8082:
8083: busLocalMemorySaveOn = Settings.sgsGetOnOff ("localmemorysave");
8084:
8085: byte[] localMemoryArray = Settings.sgsGetData ("localmemorydata");
8086: if (busLocalMemorySize != 0) {
8087: if (localMemoryArray.length != 0) {
8088: System.out.println (Multilingual.mlnJapanese ?
8089: "060turbo のハイメモリのデータを復元します" :
8090: "060turbo high memory data is restored");
8091: System.arraycopy (localMemoryArray, 0, busLocalMemoryArray, 0, Math.min (localMemoryArray.length, busLocalMemorySize));
8092: } else {
8093: System.out.println (Multilingual.mlnJapanese ?
8094: "060turbo のハイメモリをゼロクリアします" :
8095: "060turbo high memory is zero-cleared");
8096: }
8097: if (localMemoryArray.length < busLocalMemorySize) {
8098: Arrays.fill (busLocalMemoryArray, localMemoryArray.length, busLocalMemorySize, (byte) 0);
8099: }
8100: }
8101:
8102:
8103: busExMemoryStart = busRequestExMemoryStart = 0x10000000;
8104: busExMemorySize = busRequestExMemorySize = 0 << 20;
8105: busExMemoryArray = busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
8106:
8107:
8108: busRequestCutFC2Pin = Settings.sgsGetOnOff ("cutfc2pin");
8109: busCutFC2Pin = !busRequestCutFC2Pin;
8110:
8111: busUpdateMemoryMap ();
8112:
8113: }
8114:
8115:
8116:
8117: public static void busTini () {
8118: Settings.sgsPutOnOff ("himem68000", busHimem68000);
8119: Settings.sgsPutInt ("highmemory", busHighMemorySize >>> 20);
8120: Settings.sgsPutOnOff ("highmemorysave", busHighMemorySaveOn);
8121: Settings.sgsPutOnOff ("highmemory060turbo", busHighMemory060turboOn);
8122: Settings.sgsPutData ("highmemorydata", busHighMemorySaveOn ? busHighMemoryArray : new byte[0]);
8123: Settings.sgsPutInt ("localmemory", busLocalMemorySize >>> 20);
8124: Settings.sgsPutOnOff ("localmemorysave", busLocalMemorySaveOn);
8125: Settings.sgsPutData ("localmemorydata", busLocalMemorySaveOn ? busLocalMemoryArray : new byte[0]);
8126: Settings.sgsPutOnOff ("cutfc2pin", busRequestCutFC2Pin);
8127: }
8128:
8129: public static void busUpdateMemoryMap () {
8130: if (busExMemoryStart == busRequestExMemoryStart &&
8131: busExMemorySize == busRequestExMemorySize &&
8132: busExMemoryArray == busRequestExMemoryArray &&
8133: busExMemoryArray.length == busExMemorySize &&
8134: busCutFC2Pin == busRequestCutFC2Pin) {
8135: return;
8136: }
8137:
8138: busExMemoryStart = busRequestExMemoryStart;
8139: busExMemorySize = busRequestExMemorySize;
8140: busExMemoryArray = busRequestExMemoryArray;
8141: if (busExMemoryArray.length != busExMemorySize) {
8142: byte[] newArray = new byte[busExMemorySize];
8143: int copySize = Math.min (busExMemoryArray.length, busExMemorySize);
8144: if (copySize > 0) {
8145: System.arraycopy (busExMemoryArray, 0, newArray, 0, copySize);
8146: }
8147: if (busExMemoryArray == busHighMemoryArray) {
8148: busHighMemoryArray = newArray;
8149: } else if (busExMemoryArray == busLocalMemoryArray) {
8150: busLocalMemoryArray = newArray;
8151: }
8152: busExMemoryArray = newArray;
8153: }
8154:
8155: busCutFC2Pin = busRequestCutFC2Pin;
8156:
8157:
8158:
8159:
8160:
8161:
8162:
8163:
8164:
8165:
8166:
8167:
8168: busSuper (MemoryMappedDevice.MMD_MMR, 0x00000000, 0x00002000);
8169: busUser ( MemoryMappedDevice.MMD_MMR, 0x00002000, 0x00c00000);
8170:
8171:
8172:
8173:
8174:
8175:
8176:
8177:
8178:
8179:
8180:
8181:
8182:
8183:
8184:
8185:
8186:
8187:
8188:
8189:
8190:
8191:
8192:
8193:
8194: busSuper (MemoryMappedDevice.MMD_GE0, 0x00c00000, 0x00c80000);
8195: busSuper (MemoryMappedDevice.MMD_GE1, 0x00c80000, 0x00d00000);
8196: busSuper (MemoryMappedDevice.MMD_GE2, 0x00d00000, 0x00d80000);
8197: busSuper (MemoryMappedDevice.MMD_GE3, 0x00d80000, 0x00e00000);
8198:
8199:
8200:
8201:
8202: busSuper (MemoryMappedDevice.MMD_TXT, 0x00e00000, 0x00e80000);
8203:
8204:
8205:
8206:
8207: busSuper (MemoryMappedDevice.MMD_CRT, 0x00e80000, 0x00e82000);
8208:
8209:
8210:
8211:
8212:
8213: busSuper (MemoryMappedDevice.MMD_VCN, 0x00e82000, 0x00e84000);
8214:
8215:
8216:
8217:
8218: busSuper (MemoryMappedDevice.MMD_DMA, 0x00e84000, 0x00e86000);
8219:
8220:
8221:
8222:
8223: busSuper (MemoryMappedDevice.MMD_SVS, 0x00e86000, 0x00e88000);
8224:
8225:
8226:
8227:
8228: busSuper (MemoryMappedDevice.MMD_MFP, 0x00e88000, 0x00e8a000);
8229:
8230:
8231:
8232:
8233: busSuper (MemoryMappedDevice.MMD_RTC_FIRST, 0x00e8a000, 0x00e8c000);
8234:
8235:
8236:
8237:
8238: busSuper (MemoryMappedDevice.MMD_PRN, 0x00e8c000, 0x00e8e000);
8239:
8240:
8241:
8242:
8243: busSuper (MemoryMappedDevice.MMD_SYS, 0x00e8e000, 0x00e90000);
8244:
8245:
8246:
8247:
8248: busSuper (MemoryMappedDevice.MMD_OPM, 0x00e90000, 0x00e92000);
8249:
8250:
8251:
8252:
8253: busSuper (MemoryMappedDevice.MMD_PCM, 0x00e92000, 0x00e94000);
8254:
8255:
8256:
8257:
8258: busSuper (MemoryMappedDevice.MMD_FDC, 0x00e94000, 0x00e96000);
8259:
8260:
8261:
8262:
8263:
8264: busSuper (MemoryMappedDevice.MMD_HDC, 0x00e96000, 0x00e98000);
8265:
8266:
8267:
8268:
8269: busSuper (MemoryMappedDevice.MMD_SCC, 0x00e98000, 0x00e9a000);
8270:
8271:
8272:
8273:
8274: busSuper (MemoryMappedDevice.MMD_PPI, 0x00e9a000, 0x00e9c000);
8275:
8276:
8277:
8278:
8279: busSuper (MemoryMappedDevice.MMD_IOI, 0x00e9c000, 0x00e9e000);
8280:
8281:
8282:
8283:
8284:
8285:
8286:
8287:
8288:
8289: busSuper (MemoryMappedDevice.MMD_XB1, 0x00e9e000, 0x00ea0000);
8290:
8291:
8292:
8293:
8294:
8295: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ea0000, 0x00eae000);
8296:
8297:
8298:
8299:
8300:
8301:
8302:
8303:
8304:
8305:
8306:
8307:
8308:
8309:
8310:
8311: busSuper (MemoryMappedDevice.MMD_XB2, 0x00eae000, 0x00eb0000);
8312:
8313:
8314:
8315:
8316:
8317:
8318:
8319:
8320: busSuper (MemoryMappedDevice.MMD_SPR, 0x00eb0000, 0x00ec0000);
8321:
8322:
8323:
8324:
8325:
8326:
8327:
8328:
8329:
8330:
8331:
8332:
8333:
8334: busSuper (MemoryMappedDevice.MMD_XB3, 0x00ec0000, 0x00ed0000);
8335:
8336:
8337:
8338:
8339:
8340:
8341: busSuper (MemoryMappedDevice.MMD_SMR, 0x00ed0000, 0x00ed0000 + 16384);
8342: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ed0000 + 16384, 0x00ed0000 + 65536);
8343:
8344:
8345:
8346:
8347:
8348:
8349:
8350:
8351: busSuper (MemoryMappedDevice.MMD_XB4, 0x00ee0000, 0x00f00000);
8352:
8353:
8354:
8355:
8356:
8357:
8358:
8359:
8360:
8361:
8362: busSuper (MemoryMappedDevice.MMD_CG1, 0x00f00000, 0x00f40000);
8363:
8364:
8365:
8366:
8367:
8368:
8369:
8370: busSuper (MemoryMappedDevice.MMD_CG2, 0x00f40000, 0x00fc0000);
8371:
8372:
8373:
8374:
8375:
8376:
8377:
8378:
8379:
8380:
8381:
8382:
8383:
8384:
8385: busSuper (MemoryMappedDevice.MMD_ROM, 0x00fc0000, 0x01000000);
8386:
8387: }
8388:
8389: public static void busReset () {
8390: if (regSRS != 0) {
8391: if (DataBreakPoint.DBP_ON) {
8392: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpSuperMap;
8393: } else {
8394: busMemoryMap = busSuperMap;
8395: }
8396: } else {
8397: if (DataBreakPoint.DBP_ON) {
8398: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpUserMap;
8399: } else {
8400: busMemoryMap = busUserMap;
8401: }
8402: }
8403: }
8404:
8405:
8406:
8407:
8408:
8409: public static void busUser (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8410: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8411: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8412: if (false &&
8413: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8414: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8415: System.out.printf ("ERROR: busUser (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8416: }
8417: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8418: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8419: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8420: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8421: int startPage = blockStartPage + motherStartPage;
8422: int endPage = blockStartPage + motherEndPage;
8423: for (int page = startPage; page < endPage; page++) {
8424: MemoryMappedDevice superMmd = exMemoryStartPage <= page && page < exMemoryEndPage ? MemoryMappedDevice.MMD_XMM : mmd;
8425: busUserMap[page] = busSuperMap[page] = superMmd;
8426: if (InstructionBreakPoint.IBP_ON) {
8427: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8428: InstructionBreakPoint.ibpUserMap[page] = superMmd;
8429: }
8430: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8431: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8432: }
8433: }
8434: if (DataBreakPoint.DBP_ON) {
8435: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8436: DataBreakPoint.dbpUserMap[page] = superMmd;
8437: }
8438: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8439: DataBreakPoint.dbpSuperMap[page] = superMmd;
8440: }
8441: }
8442: }
8443: }
8444: }
8445:
8446:
8447:
8448:
8449:
8450: public static void busSuper (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
8451: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
8452: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
8453: if (false &&
8454: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
8455: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
8456: System.out.printf ("ERROR: busSuper (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
8457: }
8458: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
8459: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
8460: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
8461: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
8462: int startPage = blockStartPage + motherStartPage;
8463: int endPage = blockStartPage + motherEndPage;
8464: for (int page = startPage; page < endPage; page++) {
8465: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
8466: MemoryMappedDevice userMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : busCutFC2Pin ? mmd : MemoryMappedDevice.MMD_NUL;
8467: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
8468: busUserMap[page] = userMmd;
8469: busSuperMap[page] = superMmd;
8470: if (InstructionBreakPoint.IBP_ON) {
8471: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
8472: InstructionBreakPoint.ibpUserMap[page] = userMmd;
8473: }
8474: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
8475: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
8476: }
8477: }
8478: if (DataBreakPoint.DBP_ON) {
8479: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
8480: DataBreakPoint.dbpUserMap[page] = userMmd;
8481: }
8482: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
8483: DataBreakPoint.dbpSuperMap[page] = superMmd;
8484: }
8485: }
8486: }
8487: }
8488: }
8489:
8490:
8491:
8492: public static byte busPbs (int a) {
8493: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a);
8494: }
8495:
8496:
8497:
8498: public static int busPbz (int a) {
8499: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a);
8500: }
8501:
8502:
8503:
8504: public static int busPws (int a) {
8505: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8506: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
8507: } else {
8508: int a1 = a + 1;
8509: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
8510: }
8511: }
8512:
8513:
8514:
8515: public static int busPwse (int a) {
8516: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
8517: }
8518:
8519:
8520:
8521: public static int busPwz (int a) {
8522: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8523: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
8524: } else {
8525: int a1 = a + 1;
8526: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
8527: }
8528: }
8529:
8530:
8531:
8532: public static int busPwze (int a) {
8533: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
8534: }
8535:
8536:
8537:
8538: public static int busPls (int a) {
8539: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8540: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
8541: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8542: int a2 = a + 2;
8543: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a) << 16 | busSuperMap[a2 >>> BUS_PAGE_BITS].mmdPwz (a2);
8544: } else {
8545: int a1 = a + 1;
8546: int a3 = a + 3;
8547: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 24 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPwz (a1) << 8 | busSuperMap[a3 >>> BUS_PAGE_BITS].mmdPbz (a3);
8548: }
8549: }
8550:
8551:
8552:
8553: public static int busPlsf (int a) {
8554: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
8555: }
8556:
8557:
8558:
8559: public static long busPqs (int a) {
8560: return (long) busPls (a) << 32 | busPls (a + 4) & 0xffffffffL;
8561: }
8562:
8563:
8564:
8565: public static int busSearchByte (int start, int end, int c) {
8566: for (int a = start; a < end; a++) {
8567: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) == c) {
8568: return a;
8569: }
8570: }
8571: return -1;
8572: }
8573: public static int busSearchWord (int start, int end, int c) {
8574: for (int a = start; a < end; a += 2) {
8575: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) == c) {
8576: return a;
8577: }
8578: }
8579: return -1;
8580: }
8581: public static int busSearchByteArray (int start, int end, int[] array) {
8582: int l = array.length;
8583: end -= l;
8584: int c = array[0];
8585: a:
8586: for (int a = start; a <= end; a++) {
8587: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) != c) {
8588: continue a;
8589: }
8590: for (int i = 1, b = a + 1; i < l; i++, b++) {
8591: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPbz (b) != array[i]) {
8592: continue a;
8593: }
8594: }
8595: return a;
8596: }
8597: return -1;
8598: }
8599: public static int busSearchWordArray (int start, int end, int[] array) {
8600: int l = array.length;
8601: end -= l;
8602: int c = array[0];
8603: a:
8604: for (int a = start; a <= end; a += 2) {
8605: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) != c) {
8606: continue a;
8607: }
8608: for (int i = 1, b = a + 2; i < l; i++, b += 2) {
8609: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPwz (b) != array[i]) {
8610: continue a;
8611: }
8612: }
8613: return a;
8614: }
8615: return -1;
8616: }
8617:
8618:
8619:
8620:
8621: public static byte busRbs (int a) throws M68kException {
8622: if (DataBreakPoint.DBP_ON) {
8623: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
8624: } else {
8625: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
8626: }
8627: }
8628:
8629:
8630:
8631: public static int busRbz (int a) throws M68kException {
8632: if (DataBreakPoint.DBP_ON) {
8633: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
8634: } else {
8635: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
8636: }
8637: }
8638:
8639:
8640:
8641: public static int busRws (int a) throws M68kException {
8642: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8643: if (DataBreakPoint.DBP_ON) {
8644: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8645: } else {
8646: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8647: }
8648: } else if (mpuIgnoreAddressError) {
8649: int a1 = a + 1;
8650: if (DataBreakPoint.DBP_ON) {
8651: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8652: } else {
8653: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8654: }
8655: } else {
8656: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8657: M68kException.m6eAddress = a;
8658: M68kException.m6eDirection = MPU_WR_READ;
8659: M68kException.m6eSize = MPU_SS_WORD;
8660: throw M68kException.m6eSignal;
8661: }
8662: }
8663:
8664:
8665:
8666:
8667: public static int busRwse (int a) throws M68kException {
8668: if (DataBreakPoint.DBP_ON) {
8669: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8670: } else {
8671: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
8672: }
8673: }
8674:
8675:
8676:
8677: public static int busRwz (int a) throws M68kException {
8678: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8679: if (DataBreakPoint.DBP_ON) {
8680: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8681: } else {
8682: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8683: }
8684: } else if (mpuIgnoreAddressError) {
8685: int a1 = a + 1;
8686: if (DataBreakPoint.DBP_ON) {
8687: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8688: } else {
8689: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
8690: }
8691: } else {
8692: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8693: M68kException.m6eAddress = a;
8694: M68kException.m6eDirection = MPU_WR_READ;
8695: M68kException.m6eSize = MPU_SS_WORD;
8696: throw M68kException.m6eSignal;
8697: }
8698: }
8699:
8700:
8701:
8702:
8703: public static int busRwze (int a) throws M68kException {
8704: if (DataBreakPoint.DBP_ON) {
8705: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8706: } else {
8707: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
8708: }
8709: }
8710:
8711:
8712:
8713: public static int busRls (int a) throws M68kException {
8714: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8715: if (DataBreakPoint.DBP_ON) {
8716: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8717: } else {
8718: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8719: }
8720: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8721: int a2 = a + 2;
8722: if (BUS_SPLIT_UNALIGNED_LONG) {
8723: if (DataBreakPoint.DBP_ON) {
8724: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8725: } else {
8726: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8727: }
8728: } else {
8729: MemoryMappedDevice mmd;
8730: MemoryMappedDevice mmd2;
8731: if (DataBreakPoint.DBP_ON) {
8732: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8733: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8734: } else {
8735: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8736: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8737: }
8738: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
8739: }
8740: } else if (mpuIgnoreAddressError) {
8741: int a1 = a + 1;
8742: int a3 = a + 3;
8743: if (DataBreakPoint.DBP_ON) {
8744: 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);
8745: } else {
8746: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 24 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRwz (a1) << 8 | busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdRbz (a3);
8747: }
8748: } else {
8749: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8750: M68kException.m6eAddress = a;
8751: M68kException.m6eDirection = MPU_WR_READ;
8752: M68kException.m6eSize = MPU_SS_LONG;
8753: throw M68kException.m6eSignal;
8754: }
8755: }
8756:
8757:
8758:
8759:
8760: public static int busRlse (int a) throws M68kException {
8761: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8762: if (DataBreakPoint.DBP_ON) {
8763: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8764: } else {
8765: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8766: }
8767: } else {
8768: int a2 = a + 2;
8769: if (BUS_SPLIT_UNALIGNED_LONG) {
8770: if (DataBreakPoint.DBP_ON) {
8771: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8772: } else {
8773: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
8774: }
8775: } else {
8776: MemoryMappedDevice mmd;
8777: MemoryMappedDevice mmd2;
8778: if (DataBreakPoint.DBP_ON) {
8779: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8780: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8781: } else {
8782: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8783: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8784: }
8785: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
8786: }
8787: }
8788: }
8789:
8790:
8791:
8792:
8793: public static int busRlsf (int a) throws M68kException {
8794: if (DataBreakPoint.DBP_ON) {
8795: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8796: } else {
8797: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
8798: }
8799: }
8800:
8801:
8802:
8803: public static long busRqs (int a) throws M68kException {
8804: return (long) busRls (a) << 32 | busRls (a + 4) & 0xffffffffL;
8805: }
8806:
8807:
8808:
8809: public static void busWb (int a, int d) throws M68kException {
8810: if (DataBreakPoint.DBP_ON) {
8811: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
8812: } else {
8813: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
8814: }
8815: }
8816:
8817:
8818:
8819: public static void busWw (int a, int d) throws M68kException {
8820: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8821: if (DataBreakPoint.DBP_ON) {
8822: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8823: } else {
8824: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8825: }
8826: } else if (mpuIgnoreAddressError) {
8827: int a1 = a + 1;
8828: if (DataBreakPoint.DBP_ON) {
8829: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
8830: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
8831: } else {
8832: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
8833: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
8834: }
8835: } else {
8836: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
8837: M68kException.m6eAddress = a;
8838: M68kException.m6eDirection = MPU_WR_WRITE;
8839: M68kException.m6eSize = MPU_SS_WORD;
8840: throw M68kException.m6eSignal;
8841: }
8842: }
8843:
8844:
8845:
8846:
8847: public static void busWwe (int a, int d) throws M68kException {
8848: if (DataBreakPoint.DBP_ON) {
8849: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8850: } else {
8851: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8852: }
8853: }
8854:
8855:
8856:
8857: public static void busWl (int a, int d) throws M68kException {
8858: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8859: if (DataBreakPoint.DBP_ON) {
8860: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8861: } else {
8862: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8863: }
8864: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8865: int a2 = a + 2;
8866: if (BUS_SPLIT_UNALIGNED_LONG) {
8867: if (DataBreakPoint.DBP_ON) {
8868: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8869: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8870: } else {
8871: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8872: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8873: }
8874: } else {
8875: MemoryMappedDevice mmd;
8876: MemoryMappedDevice mmd2;
8877: if (DataBreakPoint.DBP_ON) {
8878: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8879: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8880: } else {
8881: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8882: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8883: }
8884: if (mmd == mmd2) {
8885: mmd.mmdWl (a, d);
8886: } else {
8887: mmd.mmdWw (a, d >> 16);
8888: mmd2.mmdWw (a2, d);
8889: }
8890: }
8891: } else if (mpuIgnoreAddressError) {
8892: int a1 = a + 1;
8893: int a3 = a + 3;
8894: if (DataBreakPoint.DBP_ON) {
8895: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
8896: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
8897: DataBreakPoint.dbpMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
8898: } else {
8899: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
8900: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
8901: busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, 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_LONG;
8908: throw M68kException.m6eSignal;
8909: }
8910: }
8911:
8912:
8913:
8914:
8915: public static void busWlf (int a, int d) throws M68kException {
8916: if (DataBreakPoint.DBP_ON) {
8917: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8918: } else {
8919: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8920: }
8921: }
8922:
8923:
8924:
8925:
8926: public static void busWle (int a, int d) throws M68kException {
8927: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8928: if (DataBreakPoint.DBP_ON) {
8929: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8930: } else {
8931: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8932: }
8933: } else {
8934: int a2 = a + 2;
8935: if (BUS_SPLIT_UNALIGNED_LONG) {
8936: if (DataBreakPoint.DBP_ON) {
8937: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8938: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8939: } else {
8940: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
8941: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
8942: }
8943: } else {
8944: MemoryMappedDevice mmd;
8945: MemoryMappedDevice mmd2;
8946: if (DataBreakPoint.DBP_ON) {
8947: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8948: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
8949: } else {
8950: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8951: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8952: }
8953: if (mmd == mmd2) {
8954: mmd.mmdWl (a, d);
8955: } else {
8956: mmd.mmdWw (a, d >> 16);
8957: mmd2.mmdWw (a2, d);
8958: }
8959: }
8960: }
8961: }
8962:
8963:
8964:
8965: public static void busWq (int a, long d) throws M68kException {
8966: busWl (a, (int) (d >>> 32));
8967: busWl (a + 4, (int) d);
8968: }
8969:
8970:
8971:
8972:
8973:
8974: public static void busRbb (int a, byte[] bb, int o, int l) throws M68kException {
8975: if (false) {
8976: for (int i = 0; i < l; i++) {
8977: int ai = a + i;
8978: if (DataBreakPoint.DBP_ON) {
8979: bb[o + i] = DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
8980: } else {
8981: bb[o + i] = busMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
8982: }
8983: }
8984: } else {
8985: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
8986: while (l > 0) {
8987: MemoryMappedDevice mmd;
8988: if (DataBreakPoint.DBP_ON) {
8989: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8990: } else {
8991: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8992: }
8993: int s = l <= r ? l : r;
8994: l -= s;
8995: if (true) {
8996: for (s -= 16; s >= 0; s -= 16) {
8997: bb[o ] = mmd.mmdRbs (a );
8998: bb[o + 1] = mmd.mmdRbs (a + 1);
8999: bb[o + 2] = mmd.mmdRbs (a + 2);
9000: bb[o + 3] = mmd.mmdRbs (a + 3);
9001: bb[o + 4] = mmd.mmdRbs (a + 4);
9002: bb[o + 5] = mmd.mmdRbs (a + 5);
9003: bb[o + 6] = mmd.mmdRbs (a + 6);
9004: bb[o + 7] = mmd.mmdRbs (a + 7);
9005: bb[o + 8] = mmd.mmdRbs (a + 8);
9006: bb[o + 9] = mmd.mmdRbs (a + 9);
9007: bb[o + 10] = mmd.mmdRbs (a + 10);
9008: bb[o + 11] = mmd.mmdRbs (a + 11);
9009: bb[o + 12] = mmd.mmdRbs (a + 12);
9010: bb[o + 13] = mmd.mmdRbs (a + 13);
9011: bb[o + 14] = mmd.mmdRbs (a + 14);
9012: bb[o + 15] = mmd.mmdRbs (a + 15);
9013: a += 16;
9014: o += 16;
9015: }
9016: s += 16;
9017: }
9018: for (int i = 0; i < s; i++) {
9019: bb[o + i] = mmd.mmdRbs (a + i);
9020: }
9021: a += s;
9022: o += s;
9023: r = BUS_PAGE_SIZE;
9024: }
9025: }
9026: }
9027:
9028:
9029:
9030: public static void busWbb (int a, byte[] bb, int o, int l) throws M68kException {
9031: if (false) {
9032: for (int i = 0; i < l; i++) {
9033: int ai = a + i;
9034: if (DataBreakPoint.DBP_ON) {
9035: DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9036: } else {
9037: busMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9038: }
9039: }
9040: } else {
9041: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9042: while (l > 0) {
9043: MemoryMappedDevice mmd;
9044: if (DataBreakPoint.DBP_ON) {
9045: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9046: } else {
9047: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9048: }
9049: int s = l <= r ? l : r;
9050: l -= s;
9051: if (true) {
9052: for (s -= 16; s >= 0; s -= 16) {
9053: mmd.mmdWb (a , bb[o ]);
9054: mmd.mmdWb (a + 1, bb[o + 1]);
9055: mmd.mmdWb (a + 2, bb[o + 2]);
9056: mmd.mmdWb (a + 3, bb[o + 3]);
9057: mmd.mmdWb (a + 4, bb[o + 4]);
9058: mmd.mmdWb (a + 5, bb[o + 5]);
9059: mmd.mmdWb (a + 6, bb[o + 6]);
9060: mmd.mmdWb (a + 7, bb[o + 7]);
9061: mmd.mmdWb (a + 8, bb[o + 8]);
9062: mmd.mmdWb (a + 9, bb[o + 9]);
9063: mmd.mmdWb (a + 10, bb[o + 10]);
9064: mmd.mmdWb (a + 11, bb[o + 11]);
9065: mmd.mmdWb (a + 12, bb[o + 12]);
9066: mmd.mmdWb (a + 13, bb[o + 13]);
9067: mmd.mmdWb (a + 14, bb[o + 14]);
9068: mmd.mmdWb (a + 15, bb[o + 15]);
9069: a += 16;
9070: o += 16;
9071: }
9072: s += 16;
9073: }
9074: for (int i = 0; i < s; i++) {
9075: mmd.mmdWb (a + i, bb[o + i]);
9076: }
9077: a += s;
9078: o += s;
9079: r = BUS_PAGE_SIZE;
9080: }
9081: }
9082: }
9083:
9084:
9085:
9086: public static void busVb (int a, int d) {
9087: try {
9088: if (DataBreakPoint.DBP_ON) {
9089: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9090: } else {
9091: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9092: }
9093: } catch (M68kException e) {
9094: }
9095: }
9096:
9097:
9098:
9099: public static void busVw (int a, int d) {
9100: try {
9101: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9102: if (DataBreakPoint.DBP_ON) {
9103: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9104: } else {
9105: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9106: }
9107: }
9108: } catch (M68kException e) {
9109: }
9110: }
9111:
9112:
9113:
9114: public static void busVl (int a, int d) {
9115: try {
9116: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9117: if (DataBreakPoint.DBP_ON) {
9118: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9119: } else {
9120: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9121: }
9122: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9123: int a2 = a + 2;
9124: MemoryMappedDevice mmd;
9125: MemoryMappedDevice mmd2;
9126: if (DataBreakPoint.DBP_ON) {
9127: mmd = (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS];
9128: mmd2 = (regSRS != 0 ? busSuperMap : busUserMap)[a2 >>> BUS_PAGE_BITS];
9129: } else {
9130: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9131: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9132: }
9133: if (mmd == mmd2) {
9134: mmd.mmdWl (a, d);
9135: } else {
9136: mmd.mmdWw (a, d >> 16);
9137: mmd2.mmdWw (a2, d);
9138: }
9139: }
9140: } catch (M68kException e) {
9141: }
9142: }
9143:
9144:
9145:
9146:
9147:
9148: public static final int SVS_AREASET = 0x00e86001;
9149:
9150:
9151:
9152:
9153:
9154:
9155:
9156:
9157:
9158: public static void svsInit () {
9159: }
9160:
9161:
9162:
9163:
9164:
9165:
9166:
9167:
9168:
9169:
9170:
9171:
9172:
9173:
9174:
9175:
9176:
9177:
9178:
9179:
9180:
9181:
9182:
9183:
9184:
9185:
9186:
9187:
9188:
9189:
9190:
9191:
9192:
9193:
9194:
9195: public static boolean sysNMIFlag;
9196:
9197:
9198:
9199: public static void sysInit () {
9200: sysNMIFlag = false;
9201: }
9202:
9203:
9204:
9205:
9206:
9207:
9208: public static int sysAcknowledge () {
9209: return M68kException.M6E_LEVEL_7_INTERRUPT_AUTOVECTOR;
9210: }
9211:
9212:
9213:
9214:
9215: public static void sysDone () {
9216: if (sysNMIFlag) {
9217: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9218: }
9219: }
9220:
9221:
9222:
9223: public static void sysInterrupt () {
9224: sysNMIFlag = true;
9225: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9226: }
9227:
9228:
9229:
9230: public static void sysResetNMI () {
9231: sysNMIFlag = false;
9232: }
9233:
9234:
9235:
9236:
9237:
9238:
9239: public static final int EB2_SPC_REQUEST = 0x4000;
9240: public static final int EB2_SPC_VECTOR = 0xf6;
9241:
9242:
9243:
9244: public static int eb2Request;
9245:
9246:
9247:
9248: public static void eb2Reset () {
9249: eb2Request = 0;
9250: }
9251:
9252:
9253:
9254:
9255:
9256: public static void eb2Interrupt (int mask) {
9257: eb2Request |= mask;
9258: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9259: }
9260:
9261:
9262:
9263:
9264:
9265:
9266:
9267: public static int eb2Acknowledge () {
9268: if ((eb2Request & EB2_SPC_REQUEST) != 0) {
9269: eb2Request &= ~EB2_SPC_REQUEST;
9270: return EB2_SPC_VECTOR;
9271: }
9272: return 0;
9273: }
9274:
9275:
9276:
9277:
9278:
9279: public static void eb2Done () {
9280: if (eb2Request != 0) {
9281: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9282: }
9283: }
9284:
9285:
9286:
9287:
9288:
9289:
9290:
9291:
9292:
9293:
9294:
9295:
9296:
9297:
9298:
9299:
9300:
9301:
9302:
9303:
9304:
9305:
9306:
9307:
9308:
9309:
9310:
9311:
9312:
9313:
9314:
9315:
9316:
9317:
9318:
9319:
9320:
9321:
9322:
9323:
9324:
9325:
9326:
9327:
9328:
9329:
9330:
9331:
9332:
9333:
9334:
9335:
9336:
9337:
9338:
9339:
9340:
9341:
9342:
9343:
9344:
9345:
9346:
9347:
9348: public static final int BNK_SIZE = 1024 * 1024 * 32;
9349: public static byte[] bnkMemory;
9350: public static int bnkPageStart;
9351: public static boolean bnkOn;
9352:
9353: public static void bnkInit () {
9354: bnkMemory = new byte[BNK_SIZE];
9355: byte[] array = Settings.sgsGetData ("bankdata");
9356: if (array.length != 0) {
9357: System.arraycopy (array, 0, bnkMemory, 0, Math.min (array.length, BNK_SIZE));
9358: }
9359: bnkPageStart = 0;
9360:
9361: bnkOn = false;
9362: }
9363:
9364: public static void bnkTini () {
9365: Settings.sgsPutData ("bankdata", bnkMemory, 0, BNK_SIZE);
9366: }
9367:
9368:
9369:
9370:
9371:
9372:
9373:
9374: public static ExpressionEvaluator fpuMotherboardCoprocessor;
9375: public static ExpressionEvaluator fpuOnChipFPU;
9376: public static ExpressionEvaluator fpuBox;
9377:
9378:
9379: public static EFPBox fpuCoproboard1;
9380: public static EFPBox fpuCoproboard2;
9381:
9382:
9383: public static EFPBox.EFP[] fpuFPn;
9384:
9385:
9386:
9387: public static final int FPU_FPCR_BSUN = 0b00000000_00000000_10000000_00000000;
9388: public static final int FPU_FPCR_SNAN = 0b00000000_00000000_01000000_00000000;
9389: public static final int FPU_FPCR_OPERR = 0b00000000_00000000_00100000_00000000;
9390: public static final int FPU_FPCR_OVFL = 0b00000000_00000000_00010000_00000000;
9391: public static final int FPU_FPCR_UNFL = 0b00000000_00000000_00001000_00000000;
9392: public static final int FPU_FPCR_DZ = 0b00000000_00000000_00000100_00000000;
9393: public static final int FPU_FPCR_INEX2 = 0b00000000_00000000_00000010_00000000;
9394: public static final int FPU_FPCR_INEX1 = 0b00000000_00000000_00000001_00000000;
9395:
9396:
9397: public static final int FPU_FPCR_PE = 0b00000000_00000000_00000000_00000000;
9398: public static final int FPU_FPCR_PS = 0b00000000_00000000_00000000_01000000;
9399: public static final int FPU_FPCR_PD = 0b00000000_00000000_00000000_10000000;
9400:
9401: public static final int FPU_FPCR_RN = 0b00000000_00000000_00000000_00000000;
9402: public static final int FPU_FPCR_RZ = 0b00000000_00000000_00000000_00010000;
9403: public static final int FPU_FPCR_RM = 0b00000000_00000000_00000000_00100000;
9404: public static final int FPU_FPCR_RP = 0b00000000_00000000_00000000_00110000;
9405:
9406:
9407:
9408: public static final int FPU_FPSR_N = 0b00001000_00000000_00000000_00000000;
9409: public static final int FPU_FPSR_Z = 0b00000100_00000000_00000000_00000000;
9410: public static final int FPU_FPSR_I = 0b00000010_00000000_00000000_00000000;
9411: public static final int FPU_FPSR_NAN = 0b00000001_00000000_00000000_00000000;
9412:
9413: public static final int FPU_FPSR_S = 0b00000000_10000000_00000000_00000000;
9414: public static final int FPU_FPSR_QUOTIENT = 0b00000000_01111111_00000000_00000000;
9415:
9416: public static final int FPU_FPSR_EXC_BSUN = 0b00000000_00000000_10000000_00000000;
9417: public static final int FPU_FPSR_EXC_SNAN = 0b00000000_00000000_01000000_00000000;
9418: public static final int FPU_FPSR_EXC_OPERR = 0b00000000_00000000_00100000_00000000;
9419: public static final int FPU_FPSR_EXC_OVFL = 0b00000000_00000000_00010000_00000000;
9420: public static final int FPU_FPSR_EXC_UNFL = 0b00000000_00000000_00001000_00000000;
9421: public static final int FPU_FPSR_EXC_DZ = 0b00000000_00000000_00000100_00000000;
9422: public static final int FPU_FPSR_EXC_INEX2 = 0b00000000_00000000_00000010_00000000;
9423: public static final int FPU_FPSR_EXC_INEX1 = 0b00000000_00000000_00000001_00000000;
9424:
9425: public static final int FPU_FPSR_AEXC_IOP = 0b00000000_00000000_00000000_10000000;
9426: public static final int FPU_FPSR_AEXC_OVFL = 0b00000000_00000000_00000000_01000000;
9427: public static final int FPU_FPSR_AEXC_UNFL = 0b00000000_00000000_00000000_00100000;
9428: public static final int FPU_FPSR_AEXC_DZ = 0b00000000_00000000_00000000_00010000;
9429: public static final int FPU_FPSR_AEXC_INEX = 0b00000000_00000000_00000000_00001000;
9430:
9431:
9432:
9433:
9434:
9435:
9436:
9437: public static final int[] FPU_FPSR_EXC_TO_AEXC = new int[256];
9438:
9439:
9440:
9441:
9442:
9443:
9444:
9445:
9446:
9447:
9448:
9449:
9450:
9451:
9452:
9453:
9454:
9455:
9456:
9457:
9458:
9459:
9460:
9461:
9462: public static final boolean[] FPU_CCMAP_882 = {
9463:
9464:
9465: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9466: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9467: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9468: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9469: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9470: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9471: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9472: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9473: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9474: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9475: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9476: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9477: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9478: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9479: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9480: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9481:
9482:
9483: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9484: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9485: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9486: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9487: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9488: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9489: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9490: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9491: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9492: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9493: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9494: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9495: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9496: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9497: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9498: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9499:
9500: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9501: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9502: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9503: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9504: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9505: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9506: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9507: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9508: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9509: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9510: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9511: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9512: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9513: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9514: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9515: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9516:
9517: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9518: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9519: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9520: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9521: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9522: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9523: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9524: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
9525: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9526: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9527: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9528: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9529: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9530: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9531: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
9532: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9533: };
9534:
9535:
9536:
9537:
9538:
9539:
9540:
9541: public static final boolean[] FPU_CCMAP_060 = {
9542:
9543:
9544: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9545: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9546: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9547: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9548: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9549: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9550: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9551: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9552: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9553: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9554: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9555: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9556: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9557: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9558: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9559: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9560:
9561:
9562: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9563: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9564: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9565: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9566: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9567: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9568: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9569: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9570: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9571: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9572: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9573: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9574: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9575: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9576: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9577: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9578:
9579: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9580: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9581: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9582: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9583: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9584: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9585: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9586: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9587: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9588: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9589: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9590: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9591: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9592: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9593: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9594: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9595:
9596: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
9597: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
9598: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
9599: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
9600: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
9601: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
9602: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
9603: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
9604: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
9605: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
9606: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
9607: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
9608: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
9609: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
9610: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
9611: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
9612: };
9613:
9614:
9615:
9616:
9617: public static void fpuInit () {
9618: for (int i = 0; i < 256; i++) {
9619: 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) |
9620: ((i << 8 & FPU_FPSR_EXC_OVFL) != 0 ? FPU_FPSR_AEXC_OVFL : 0) |
9621: ((i << 8 & (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2)) == (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2) ? FPU_FPSR_AEXC_UNFL : 0) |
9622: ((i << 8 & FPU_FPSR_EXC_DZ) != 0 ? FPU_FPSR_AEXC_DZ : 0) |
9623: ((i << 8 & (FPU_FPSR_EXC_OVFL | FPU_FPSR_EXC_INEX2 | FPU_FPSR_EXC_INEX1)) != 0 ? FPU_FPSR_AEXC_INEX : 0));
9624: }
9625:
9626: fpuMotherboardCoprocessor = new ExpressionEvaluator ();
9627:
9628: fpuOnChipFPU = new ExpressionEvaluator ();
9629:
9630: fpuBox = currentMPU < Model.MPU_MC68LC040 ? fpuMotherboardCoprocessor : fpuOnChipFPU;
9631:
9632: fpuFPn = fpuBox.epbFPn;
9633:
9634: fpuCoproboard1 = new EFPBox ();
9635: fpuCoproboard2 = new EFPBox ();
9636: }
9637:
9638:
9639:
9640:
9641:
9642:
9643: public static final boolean DBG_ORI_BYTE_ZERO_D0 = true;
9644:
9645: public static boolean dbgHexSelected;
9646: public static int dbgHexValue;
9647: public static int dbgSupervisorMode;
9648: public static JPopupMenu dbgPopupMenu;
9649: public static JMenu dbgPopupIBPMenu;
9650: public static SpinnerNumberModel dbgPopupIBPCurrentModel;
9651: public static int dbgPopupIBPCurrentValue;
9652: public static SpinnerNumberModel dbgPopupIBPThresholdModel;
9653: public static int dbgPopupIBPThresholdValue;
9654: public static JMenuItem dbgPopupIBPClearMenuItem;
9655: public static JMenu dbgPopupHexMenu;
9656: public static JMenuItem dbgPopupDisMenuItem;
9657: public static JMenuItem dbgPopupMemMenuItem;
9658: public static JMenuItem dbgPopupCopyMenuItem;
9659: public static JMenuItem dbgPopupSelectAllMenuItem;
9660: public static JTextArea dbgPopupTextArea;
9661: public static int dbgEventMask;
9662: public static boolean dbgStopOnError;
9663: public static boolean dbgOriByteZeroD0;
9664: public static boolean dbgStopAtStart;
9665:
9666:
9667:
9668: public static final char[] DBG_SPACES = (
9669:
9670:
9671: " ").toCharArray ();
9672:
9673: public static final int DBG_DRP_VISIBLE_MASK = 1;
9674: public static final int DBG_DDP_VISIBLE_MASK = 2;
9675: public static final int DBG_DMP_VISIBLE_MASK = 4;
9676: public static final int DBG_BLG_VISIBLE_MASK = 8;
9677: public static final int DBG_PFV_VISIBLE_MASK = 16;
9678: public static final int DBG_RBP_VISIBLE_MASK = 32;
9679: public static final int DBG_DBP_VISIBLE_MASK = 64;
9680: public static final int DBG_SMT_VISIBLE_MASK = 128;
9681: public static final int DBG_ATW_VISIBLE_MASK = 256;
9682: public static final int DBG_PAA_VISIBLE_MASK = 512;
9683: public static final int DBG_RTL_VISIBLE_MASK = 1024;
9684: public static final int DBG_SPV_VISIBLE_MASK = 2048;
9685: public static final int DBG_ACM_VISIBLE_MASK = 4096;
9686: public static int dbgVisibleMask;
9687:
9688:
9689:
9690: public static void dbgInit () {
9691: dbgVisibleMask = 0;
9692: dbgHexSelected = false;
9693: dbgHexValue = 0;
9694: dbgSupervisorMode = 1;
9695: dbgPopupMenu = null;
9696: dbgPopupDisMenuItem = null;
9697: dbgPopupMemMenuItem = null;
9698: dbgPopupCopyMenuItem = null;
9699: dbgPopupSelectAllMenuItem = null;
9700: dbgPopupIBPMenu = null;
9701: dbgPopupIBPCurrentModel = null;
9702: dbgPopupIBPCurrentValue = 0;
9703: dbgPopupIBPThresholdModel = null;
9704: dbgPopupIBPThresholdValue = 0;
9705: dbgPopupHexMenu = null;
9706: dbgPopupTextArea = null;
9707: dbgEventMask = 0;
9708: dbgStopOnError = false;
9709: if (DBG_ORI_BYTE_ZERO_D0) {
9710: dbgOriByteZeroD0 = false;
9711: }
9712: dbgStopAtStart = false;
9713: }
9714:
9715:
9716:
9717: public static void dbgMakePopup () {
9718:
9719:
9720: ActionListener popupActionListener = new ActionListener () {
9721: @Override public void actionPerformed (ActionEvent ae) {
9722: switch (ae.getActionCommand ()) {
9723: case "Disassemble":
9724: DisassembleList.ddpBacktraceRecord = -1L;
9725: DisassembleList.ddpOpen (dbgHexValue, dbgSupervisorMode, false);
9726: break;
9727: case "Memory Dump":
9728: MemoryDumpList.dmpOpen (dbgHexValue, dbgSupervisorMode != 0 ? 5 : 1, false);
9729: break;
9730: case "Run to Here":
9731: if (InstructionBreakPoint.IBP_ON) {
9732: if (mpuTask == null) {
9733: InstructionBreakPoint.ibpInstant (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
9734: mpuStart ();
9735: }
9736: }
9737: break;
9738: case "Set Breakpoint":
9739: if (InstructionBreakPoint.IBP_ON) {
9740: InstructionBreakPoint.ibpPut (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode, dbgPopupIBPCurrentValue, dbgPopupIBPThresholdValue, null);
9741: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
9742: }
9743: break;
9744: case "Clear Breakpoint":
9745: if (InstructionBreakPoint.IBP_ON) {
9746: InstructionBreakPoint.ibpRemove (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
9747: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
9748: }
9749: break;
9750: case "Copy":
9751: dbgCopy ();
9752: break;
9753: case "Select All":
9754: dbgSelectAll ();
9755: break;
9756: }
9757: }
9758: };
9759: dbgPopupMenu = ComponentFactory.createPopupMenu (
9760: dbgPopupIBPMenu =
9761: InstructionBreakPoint.IBP_ON ?
9762: ComponentFactory.createMenu (
9763: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
9764: Multilingual.mlnText (ComponentFactory.createMenuItem ("Run to Here", 'R', popupActionListener), "ja", "ここまで実行"),
9765: ComponentFactory.createHorizontalSeparator (),
9766: Multilingual.mlnText (ComponentFactory.createMenuItem ("Set Breakpoint", 'S', popupActionListener), "ja", "ブレークポイントを設定"),
9767: ComponentFactory.createHorizontalBox (
9768: Box.createHorizontalStrut (7),
9769: Box.createHorizontalGlue (),
9770: ComponentFactory.setPreferredSize (
9771: Multilingual.mlnText (ComponentFactory.createLabel ("current"), "ja", "現在値"),
9772: 60, 16),
9773: ComponentFactory.createNumberSpinner (dbgPopupIBPCurrentModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
9774: @Override public void stateChanged (ChangeEvent ce) {
9775: dbgPopupIBPCurrentValue = dbgPopupIBPCurrentModel.getNumber ().intValue ();
9776: }
9777: }),
9778: Box.createHorizontalGlue ()
9779: ),
9780: ComponentFactory.createHorizontalBox (
9781: Box.createHorizontalStrut (7),
9782: Box.createHorizontalGlue (),
9783: ComponentFactory.setPreferredSize (
9784: Multilingual.mlnText (ComponentFactory.createLabel ("threshold"), "ja", "閾値"),
9785: 60, 16),
9786: ComponentFactory.createNumberSpinner (dbgPopupIBPThresholdModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
9787: @Override public void stateChanged (ChangeEvent ce) {
9788: dbgPopupIBPThresholdValue = dbgPopupIBPThresholdModel.getNumber ().intValue ();
9789: }
9790: }),
9791: Box.createHorizontalGlue ()
9792: ),
9793: dbgPopupIBPClearMenuItem =
9794: Multilingual.mlnText (ComponentFactory.createMenuItem ("Clear Breakpoint", 'C', popupActionListener), "ja", "ブレークポイントを消去")
9795: ) :
9796: null,
9797: dbgPopupHexMenu =
9798: ComponentFactory.createMenu (
9799: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
9800: dbgPopupDisMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble", 'D', popupActionListener), "ja", "逆アセンブル"),
9801: dbgPopupMemMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory Dump", 'M', popupActionListener), "ja", "メモリダンプ")
9802: ),
9803: dbgPopupCopyMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Copy", 'C', popupActionListener), "ja", "コピー"),
9804: dbgPopupSelectAllMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Select All", 'A', popupActionListener), "ja", "すべて選択")
9805: );
9806:
9807: }
9808:
9809:
9810:
9811: public static void dbgShowPopup (MouseEvent me, JTextArea textArea, boolean dis) {
9812: dbgEventMask++;
9813: int x = me.getX ();
9814: int y = me.getY ();
9815:
9816: int p = textArea.viewToModel2D (me.getPoint ());
9817: DisassembleList.ddpPopupAddress = -1;
9818: if (dis) {
9819: int i = Arrays.binarySearch (DisassembleList.ddpSplitArray, 1, DisassembleList.ddpItemCount, p + 1);
9820: i = (i >> 31 ^ i) - 1;
9821: DisassembleList.ddpPopupAddress = DisassembleList.ddpAddressArray[i];
9822: }
9823: int start = textArea.getSelectionStart ();
9824: int end = textArea.getSelectionEnd ();
9825: String text = textArea.getText ();
9826: int length = text.length ();
9827: if ((start == end ||
9828: p < start || end <= p) &&
9829: 0 <= p && p < length && isWord (text.charAt (p))) {
9830:
9831: for (start = p; 0 < start && isWord (text.charAt (start - 1)); start--) {
9832: }
9833: for (end = p + 1; end < length && isWord (text.charAt (end)); end++) {
9834: }
9835: textArea.select (start, end);
9836: }
9837: dbgHexSelected = false;
9838: if (start < end) {
9839: textArea.requestFocusInWindow ();
9840:
9841:
9842:
9843:
9844:
9845: dbgHexValue = 0;
9846: int n = 0;
9847: for (int i = start; i < end; i++) {
9848: int t;
9849: if ((t = Character.digit (text.charAt (i), 16)) >= 0) {
9850: dbgHexValue = dbgHexValue << 4 | t;
9851: if (n >= 8 ||
9852: i + 1 >= end || (t = Character.digit (text.charAt (i + 1), 16)) < 0) {
9853: n = 0;
9854: break;
9855: }
9856: dbgHexValue = dbgHexValue << 4 | t;
9857: n += 2;
9858: i++;
9859: } else if (isWord (text.charAt (i))) {
9860: n = 0;
9861: break;
9862: }
9863: }
9864: dbgHexSelected = n > 0;
9865: try {
9866:
9867: Rectangle r = textArea.modelToView2D (start).getBounds ();
9868:
9869: Rectangle s = textArea.modelToView2D (end - 1).getBounds ();
9870: if (r.y == s.y) {
9871:
9872: y = r.y + r.height;
9873: }
9874: } catch (BadLocationException ble) {
9875: }
9876: }
9877:
9878: if (InstructionBreakPoint.IBP_ON) {
9879: if (dis && mpuTask == null && DisassembleList.ddpPopupAddress != -1) {
9880: ComponentFactory.setText (dbgPopupIBPMenu, fmtHex8 (DisassembleList.ddpPopupAddress));
9881: TreeMap<Integer,InstructionBreakPoint.InstructionBreakRecord> pointTable = InstructionBreakPoint.ibpPointTable;
9882: InstructionBreakPoint.InstructionBreakRecord r = pointTable.get (DisassembleList.ddpPopupAddress);
9883: if (r != null) {
9884: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = r.ibrValue));
9885: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = r.ibrThreshold));
9886: dbgPopupIBPClearMenuItem.setEnabled (true);
9887: } else {
9888: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = 0));
9889: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = 0));
9890: dbgPopupIBPClearMenuItem.setEnabled (false);
9891: }
9892: ComponentFactory.setVisible (dbgPopupIBPMenu, true);
9893: } else {
9894: ComponentFactory.setVisible (dbgPopupIBPMenu, false);
9895: }
9896: }
9897:
9898: if (dbgHexSelected) {
9899: ComponentFactory.setText (dbgPopupHexMenu, fmtHex8 (dbgHexValue));
9900: ComponentFactory.setVisible (dbgPopupHexMenu, true);
9901: } else {
9902: ComponentFactory.setVisible (dbgPopupHexMenu, false);
9903: }
9904:
9905: ComponentFactory.setEnabled (dbgPopupCopyMenuItem, clpClipboard != null && start < end);
9906:
9907: ComponentFactory.setEnabled (dbgPopupSelectAllMenuItem, clpClipboard != null);
9908:
9909: dbgPopupTextArea = textArea;
9910: dbgPopupMenu.show (textArea, x, y);
9911: dbgEventMask--;
9912: }
9913:
9914: public static boolean isWord (char c) {
9915: return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '_';
9916: }
9917:
9918:
9919:
9920: public static void dbgCopy () {
9921: clpCopy (dbgPopupTextArea.getSelectedText ());
9922: }
9923:
9924:
9925:
9926: public static void dbgSelectAll () {
9927: if (clpClipboard != null) {
9928:
9929: dbgEventMask++;
9930: dbgPopupTextArea.selectAll ();
9931: dbgPopupTextArea.requestFocusInWindow ();
9932: dbgEventMask--;
9933: }
9934: }
9935:
9936:
9937:
9938:
9939: public static void dbgUpdate () {
9940: if ((dbgVisibleMask & DBG_DRP_VISIBLE_MASK) != 0) {
9941: RegisterList.drpUpdate ();
9942: }
9943: if (ProgramFlowVisualizer.PFV_ON) {
9944: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
9945: if (ProgramFlowVisualizer.pfvTimer == 0) {
9946: ProgramFlowVisualizer.pfvUpdate ();
9947: } else {
9948: ProgramFlowVisualizer.pfvTimer--;
9949: }
9950: }
9951: }
9952: if (RasterBreakPoint.RBP_ON) {
9953: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
9954: if (RasterBreakPoint.rbpTimer == 0) {
9955: RasterBreakPoint.rbpUpdateFrame ();
9956: } else {
9957: RasterBreakPoint.rbpTimer--;
9958: }
9959: }
9960: }
9961: if (ScreenModeTest.SMT_ON) {
9962: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
9963: if (ScreenModeTest.smtTimer == 0) {
9964: ScreenModeTest.smtUpdateFrame ();
9965: } else {
9966: ScreenModeTest.smtTimer--;
9967: }
9968: }
9969: }
9970: if (RootPointerList.RTL_ON) {
9971: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
9972: if (RootPointerList.rtlTimer == 0) {
9973: RootPointerList.rtlTimer = RootPointerList.RTL_INTERVAL - 1;
9974: RootPointerList.rtlUpdateFrame ();
9975: } else {
9976: RootPointerList.rtlTimer--;
9977: }
9978: }
9979: }
9980: if (SpritePatternViewer.SPV_ON) {
9981: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
9982: if (SpritePatternViewer.spvTimer == 0) {
9983: SpritePatternViewer.spvTimer = SpritePatternViewer.SPV_INTERVAL - 1;
9984: SpritePatternViewer.spvUpdateFrame ();
9985: } else {
9986: SpritePatternViewer.spvTimer--;
9987: }
9988: }
9989: }
9990: if (ATCMonitor.ACM_ON) {
9991: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
9992: if (ATCMonitor.acmTimer == 0) {
9993: ATCMonitor.acmTimer = ATCMonitor.ACM_INTERVAL - 1;
9994: ATCMonitor.acmUpdateFrame ();
9995: } else {
9996: ATCMonitor.acmTimer--;
9997: }
9998: }
9999: }
10000: }
10001:
10002:
10003:
10004:
10005:
10006:
10007:
10008:
10009:
10010:
10011:
10012:
10013:
10014:
10015:
10016:
10017:
10018:
10019:
10020:
10021:
10022:
10023: public static boolean dbgDoStopOnError () {
10024: if (MainMemory.mmrHumanVersion <= 0) {
10025: return true;
10026: }
10027: if ((regOC & 0xff00) == 0xff00 &&
10028: M68kException.m6eNumber == M68kException.M6E_PRIVILEGE_VIOLATION) {
10029: return false;
10030: }
10031: String message = (
10032: M68kException.m6eNumber < 0 ?
10033: fmtHex8 (new StringBuilder ("breaked").append (" at "), regPC0).toString () :
10034: M68kException.m6eNumber <= M68kException.M6E_ADDRESS_ERROR ?
10035: fmtHex8 (fmtHex8 (new StringBuilder ("ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10036: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10037: .append (" at "), regPC0).toString () :
10038: fmtHex8 (new StringBuilder (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10039: .append (" at "), regPC0).toString ()
10040: );
10041: System.out.println (message);
10042: if (!(M68kException.m6eNumber == M68kException.M6E_ACCESS_FAULT &&
10043: 0x0000e100 <= regPC0 && regPC0 < 0x0000e500)) {
10044: mpuStop (message);
10045: return true;
10046: }
10047: return false;
10048: }
10049:
10050:
10051:
10052: public static void dbgDoubleBusFault () {
10053: String message =
10054: fmtHex8 (fmtHex8 (new StringBuilder ("FATAL ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10055: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10056: .append (" at "), regPC0).toString ();
10057: System.out.println (message);
10058: mpuStop (message);
10059: }
10060:
10061:
10062:
10063:
10064:
10065:
10066: public static final HashMap<String,byte[]> rscResourceCache = new HashMap<String,byte[]> ();
10067:
10068:
10069:
10070:
10071:
10072:
10073: public static byte[] rscGetResource (String name, int... sizes) {
10074: byte[] array = rscResourceCache.get (name);
10075: if (array != null) {
10076: return array;
10077: }
10078: array = new byte[1024 * 64];
10079: int size = 0;
10080: try (BufferedInputStream bis = new BufferedInputStream (XEiJ.class.getResourceAsStream ("../data/" + name))) {
10081: for (;;) {
10082: if (size == array.length) {
10083: byte[] newArray = new byte[array.length * 2];
10084: System.arraycopy (array, 0, newArray, 0, size);
10085: array = newArray;
10086: }
10087: int step = bis.read (array, size, array.length - size);
10088: if (step == -1) {
10089: break;
10090: }
10091: size += step;
10092: }
10093: if (size < array.length) {
10094: byte[] newArray = new byte[size];
10095: System.arraycopy (array, 0, newArray, 0, size);
10096: array = newArray;
10097: }
10098: boolean fit = sizes.length == 0;
10099: if (!fit) {
10100: for (int i = 0; i < sizes.length; i++) {
10101: if (size == sizes[i]) {
10102: fit = true;
10103: break;
10104: }
10105: }
10106: }
10107: if (fit) {
10108: System.out.println (Multilingual.mlnJapanese ?
10109: name + " を読み込みました" :
10110: name + " was read");
10111: rscResourceCache.put (name, array);
10112: return array;
10113: }
10114: System.out.println (Multilingual.mlnJapanese ?
10115: name + " のサイズが違います" :
10116: name + " has wrong size");
10117: return null;
10118: } catch (IOException ioe) {
10119: }
10120:
10121: System.out.println (Multilingual.mlnJapanese ?
10122: name + " を読み込めません" :
10123: name + " cannot be read");
10124: return null;
10125: }
10126:
10127:
10128:
10129: public static String rscGetResourceText (String name) {
10130: return rscGetResourceText (name, "UTF-8");
10131: }
10132: public static String rscGetResourceText (String name, String charset) {
10133: byte[] array = rscGetResource (name);
10134: if (name != null) {
10135: try {
10136: return new String (array, charset);
10137: } catch (UnsupportedEncodingException uee) {
10138: }
10139: }
10140: return "";
10141: }
10142:
10143: public static final Pattern RSC_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10144: public static String rscLastFileName = null;
10145:
10146:
10147:
10148:
10149:
10150:
10151: public static byte[] rscGetFile (String names, int... sizes) {
10152: for (String name : names.split (",")) {
10153: name = name.trim ();
10154: if (name.length () == 0 || name.equalsIgnoreCase ("none")) {
10155: continue;
10156: }
10157: String[] zipSplittedName = RSC_ZIP_SEPARATOR.split (name, 2);
10158: InputStream is = null;
10159: if (zipSplittedName.length < 2) {
10160: File file = new File (name);
10161: if (file.isFile ()) {
10162: try {
10163: is = new FileInputStream (file);
10164: } catch (IOException ioe) {
10165: }
10166: } else {
10167: System.out.println (Multilingual.mlnJapanese ?
10168: name + " がありません" :
10169: name + " does not exist");
10170: continue;
10171: }
10172: } else {
10173: String zipName = zipSplittedName[0];
10174: String entryName = zipSplittedName[1];
10175: if (new File (zipName).isFile ()) {
10176: try {
10177: ZipFile zipFile = new ZipFile (zipName);
10178: ZipEntry zipEntry = zipFile.getEntry (entryName);
10179: if (zipEntry != null) {
10180: is = zipFile.getInputStream (zipEntry);
10181: } else {
10182: System.out.println (Multilingual.mlnJapanese ?
10183: zipName + " に " + zipEntry + " がありません" :
10184: zipName + " does not include " + zipEntry);
10185: }
10186: } catch (IOException ioe) {
10187: }
10188: } else {
10189: System.out.println (Multilingual.mlnJapanese ?
10190: zipName + " がありません" :
10191: zipName + " does not exist");
10192: continue;
10193: }
10194: }
10195: if (is != null) {
10196: try {
10197: is = new BufferedInputStream (is);
10198: if (name.toLowerCase ().endsWith (".gz")) {
10199: is = new GZIPInputStream (is);
10200: }
10201: byte[] array = new byte[1024 * 64];
10202: int size = 0;
10203: for (;;) {
10204: if (size == array.length) {
10205: byte[] newArray = new byte[array.length * 2];
10206: System.arraycopy (array, 0, newArray, 0, size);
10207: array = newArray;
10208: }
10209: int step = is.read (array, size, array.length - size);
10210: if (step == -1) {
10211: break;
10212: }
10213: size += step;
10214: }
10215: is.close ();
10216: is = null;
10217: if (size < array.length) {
10218: byte[] newArray = new byte[size];
10219: System.arraycopy (array, 0, newArray, 0, size);
10220: array = newArray;
10221: }
10222: boolean fit = sizes.length == 0;
10223: if (!fit) {
10224: for (int i = 0; i < sizes.length; i++) {
10225: if (size == sizes[i]) {
10226: fit = true;
10227: break;
10228: }
10229: }
10230: }
10231: if (fit) {
10232: System.out.println (Multilingual.mlnJapanese ?
10233: name + " を読み込みました" :
10234: name + " was read");
10235: rscLastFileName = name;
10236: return array;
10237: }
10238: System.out.println (Multilingual.mlnJapanese ?
10239: name + " のサイズが違います" :
10240: name + " has wrong size");
10241: continue;
10242: } catch (IOException ioe) {
10243: }
10244: if (is != null) {
10245: try {
10246: is.close ();
10247: is = null;
10248: } catch (IOException ioe) {
10249: }
10250: }
10251: }
10252: System.out.println (Multilingual.mlnJapanese ?
10253: name + " を読み込めません" :
10254: name + " cannot be read");
10255: }
10256:
10257:
10258:
10259: return null;
10260: }
10261:
10262:
10263:
10264:
10265: public static String rscGetTextFile (String name) {
10266: return rscGetTextFile (name, "UTF-8");
10267: }
10268: public static String rscGetTextFile (String name, String charset) {
10269: byte[] array = rscGetFile (name);
10270: if (array != null) {
10271: try {
10272: return new String (array, charset);
10273: } catch (UnsupportedEncodingException uee) {
10274: }
10275: }
10276: return "";
10277: }
10278:
10279:
10280:
10281: public static final int RSC_A_MASK = 1;
10282: public static final int RSC_R_MASK = 2;
10283: public static final int RSC_I_MASK = 4;
10284: public static final String RSC_A_EN = "Abort";
10285: public static final String RSC_R_EN = "Retry";
10286: public static final String RSC_I_EN = "Ignore";
10287: public static final String RSC_A_JA = "中止";
10288: public static final String RSC_R_JA = "再実行";
10289: public static final String RSC_I_JA = "無視";
10290: public static final String[][] RSC_EN_OPTIONS = {
10291: { RSC_A_EN },
10292: { RSC_A_EN },
10293: { RSC_R_EN },
10294: { RSC_A_EN, RSC_R_EN },
10295: { RSC_I_EN },
10296: { RSC_A_EN, RSC_I_EN },
10297: { RSC_R_EN, RSC_I_EN },
10298: { RSC_A_EN, RSC_R_EN, RSC_I_EN },
10299: };
10300: public static final String[][] RSC_JA_OPTIONS = {
10301: { RSC_A_JA },
10302: { RSC_A_JA },
10303: { RSC_R_JA },
10304: { RSC_A_JA, RSC_R_JA },
10305: { RSC_I_JA },
10306: { RSC_A_JA, RSC_I_JA },
10307: { RSC_R_JA, RSC_I_JA },
10308: { RSC_A_JA, RSC_R_JA, RSC_I_JA },
10309: };
10310: public static int rscShowError (String message, int mask) {
10311: System.out.println (message);
10312: mask &= RSC_A_MASK | RSC_R_MASK | RSC_I_MASK;
10313: if (mask == 0) {
10314: mask = RSC_A_MASK;
10315: }
10316: String[] options = (Multilingual.mlnJapanese ? RSC_JA_OPTIONS : RSC_EN_OPTIONS)[mask];
10317: int def = Integer.numberOfTrailingZeros (mask);
10318: pnlExitFullScreen (true);
10319: int bit = JOptionPane.showOptionDialog (
10320: null,
10321: message,
10322: Multilingual.mlnJapanese ? "ファイル操作エラー" : "File operation error",
10323: JOptionPane.YES_NO_CANCEL_OPTION,
10324: JOptionPane.ERROR_MESSAGE,
10325: null,
10326: options,
10327: options[def]);
10328: if (bit == JOptionPane.CLOSED_OPTION) {
10329: bit = def;
10330: }
10331: return 1 << bit;
10332: }
10333:
10334:
10335:
10336:
10337:
10338:
10339: public static boolean rscPutTextFile (String name, String string) {
10340: return rscPutTextFile (name, string, "UTF-8");
10341: }
10342: public static boolean rscPutTextFile (String name, ArrayList<String> strings) {
10343: return rscPutTextFile (name, strings, "UTF-8");
10344: }
10345: public static boolean rscPutTextFile (String name, String string, String charset) {
10346: ArrayList<String> strings = new ArrayList<String> ();
10347: strings.add (string);
10348: return rscPutTextFile (name, strings, charset);
10349: }
10350: public static boolean rscPutTextFile (String name, ArrayList<String> strings, String charset) {
10351: String nameTmp = name + ".tmp";
10352: String nameBak = name + ".bak";
10353: File file = new File (name);
10354: File fileTmp = new File (nameTmp);
10355: File fileBak = new File (nameBak);
10356:
10357: File parentDirectory = file.getParentFile ();
10358: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10359: if (!parentDirectory.mkdirs ()) {
10360: System.out.println (parentDirectory.getPath () + (Multilingual.mlnJapanese ? " を作れません" : " cannot be created"));
10361: return false;
10362: }
10363: }
10364:
10365: if (fileTmp.exists ()) {
10366: if (!fileTmp.delete ()) {
10367: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10368: return false;
10369: }
10370: }
10371:
10372: try (BufferedWriter bw = new BufferedWriter (new FileWriter (nameTmp, Charset.forName (charset)))) {
10373: for (String string : strings) {
10374: bw.write (string);
10375: }
10376: } catch (IOException ioe) {
10377: ioe.printStackTrace ();
10378: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " に書き出せません" : " cannot be written"));
10379: return false;
10380: }
10381:
10382: boolean fileExists = file.exists ();
10383: if (fileExists) {
10384:
10385: if (fileBak.exists ()) {
10386: if (!fileBak.delete ()) {
10387: System.out.println (nameBak + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
10388: return false;
10389: }
10390: }
10391:
10392: if (!file.renameTo (fileBak)) {
10393: System.out.println (name + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + nameBak + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10394: return false;
10395: }
10396: }
10397:
10398: if (!fileTmp.renameTo (file)) {
10399: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + name + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
10400: return false;
10401: }
10402: if (fileExists) {
10403: System.out.println (name + (Multilingual.mlnJapanese ? " を更新しました" : " was updated"));
10404: } else {
10405: System.out.println (name + (Multilingual.mlnJapanese ? " を作りました" : " was created"));
10406: }
10407: return true;
10408: }
10409:
10410:
10411:
10412:
10413:
10414:
10415:
10416:
10417:
10418: public static boolean rscPutFile (String name, byte[] array) {
10419: return rscPutFile (name, array, 0, array.length, (long) array.length);
10420: }
10421: public static boolean rscPutFile (String name, byte[] array, int offset, int length) {
10422: return rscPutFile (name, array, offset, length, (long) length);
10423: }
10424: public static boolean rscPutFile (String name, byte[] array, int offset, int length, long longLength2) {
10425: if (RSC_ZIP_SEPARATOR.matcher (name).matches ()) {
10426:
10427: return false;
10428: }
10429: File file = new File (name);
10430: boolean fileExists = file.isFile ();
10431: if (fileExists && file.length () == longLength2) {
10432: comparison:
10433: {
10434: try (BufferedInputStream bis = new BufferedInputStream (new FileInputStream (file))) {
10435: byte[] buffer = new byte[(int) Math.min (Math.max ((long) length, longLength2 - (long) length), (long) (1024 * 1024))];
10436: int position = 0;
10437: while (position < length) {
10438: int step = bis.read (buffer, 0, Math.min (buffer.length, length - position));
10439: if (step == -1) {
10440: break comparison;
10441: }
10442: int offsetPosition = offset + position;
10443: for (int i = 0; i < step; i++) {
10444: if (buffer[i] != array[offsetPosition + i]) {
10445: break comparison;
10446: }
10447: }
10448: position += step;
10449: }
10450: long longPosition2 = (long) length;
10451: while (longPosition2 < longLength2) {
10452: int step = bis.read (buffer, 0, (int) Math.min ((long) buffer.length, longLength2 - longPosition2));
10453: if (step == -1) {
10454: break comparison;
10455: }
10456: for (int i = 0; i < step; i++) {
10457: if (buffer[i] != 0) {
10458: break comparison;
10459: }
10460: }
10461: longPosition2 += (long) step;
10462: }
10463: return true;
10464: } catch (IOException ioe) {
10465: }
10466: }
10467: }
10468: String nameTmp = name + ".tmp";
10469: File fileTmp = new File (nameTmp);
10470: String nameBak = name + ".bak";
10471: File fileBak = new File (nameBak);
10472: retry:
10473: for (;;) {
10474: File parentDirectory = file.getParentFile ();
10475: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
10476: String parentName = parentDirectory.getPath ();
10477: if (parentDirectory.mkdirs ()) {
10478: System.out.println (Multilingual.mlnJapanese ?
10479: parentName + " を作りました" :
10480: parentName + " was created");
10481: } else {
10482: switch (rscShowError (Multilingual.mlnJapanese ?
10483: parentName + " を作れません" :
10484: parentName + " cannot be created",
10485: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10486: case RSC_A_MASK:
10487: break retry;
10488: case RSC_R_MASK:
10489: continue retry;
10490: }
10491: }
10492: }
10493: if (fileTmp.isFile ()) {
10494: if (!fileTmp.delete ()) {
10495: switch (rscShowError (Multilingual.mlnJapanese ?
10496: nameTmp + " を削除できません" :
10497: nameTmp + " cannot be deleted",
10498: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10499: case RSC_A_MASK:
10500: break retry;
10501: case RSC_R_MASK:
10502: continue retry;
10503: }
10504: }
10505: }
10506: try (OutputStream os = name.toLowerCase ().endsWith (".gz") ?
10507: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10508: {
10509:
10510: def.setLevel (Deflater.DEFAULT_COMPRESSION);
10511:
10512: }
10513: } :
10514: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10515:
10516: os.write (array, offset, length);
10517:
10518:
10519: if ((long) length < longLength2) {
10520: byte[] buffer = new byte[(int) Math.min (longLength2 - (long) length, (long) (1024 * 1024))];
10521: Arrays.fill (buffer, 0, buffer.length, (byte) 0);
10522: long longPosition2 = (long) length;
10523: while (longPosition2 < longLength2) {
10524: int step = (int) Math.min ((long) buffer.length, longLength2 - longPosition2);
10525: os.write (buffer, 0, step);
10526: longPosition2 += (long) step;
10527: }
10528: }
10529: } catch (IOException ioe) {
10530: switch (rscShowError (Multilingual.mlnJapanese ?
10531: nameTmp + " に書き出せません" :
10532: nameTmp + " cannot be written",
10533: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10534: case RSC_A_MASK:
10535: break retry;
10536: case RSC_R_MASK:
10537: continue retry;
10538: }
10539: }
10540: if (fileExists && file.isFile ()) {
10541: if (fileBak.isFile ()) {
10542: if (!fileBak.delete ()) {
10543: switch (rscShowError (Multilingual.mlnJapanese ?
10544: nameBak + " を削除できません" :
10545: nameBak + " cannot be deleted",
10546: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10547: case RSC_A_MASK:
10548: break retry;
10549: case RSC_R_MASK:
10550: continue retry;
10551: }
10552: }
10553: }
10554: if (!file.renameTo (fileBak)) {
10555: switch (rscShowError (Multilingual.mlnJapanese ?
10556: name + " を " + nameBak + " にリネームできません" :
10557: name + " cannot be renamed to " + nameBak,
10558: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10559: case RSC_A_MASK:
10560: break retry;
10561: case RSC_R_MASK:
10562: continue retry;
10563: }
10564: }
10565: }
10566: if (fileTmp.renameTo (file)) {
10567: if (fileExists) {
10568: System.out.println (Multilingual.mlnJapanese ?
10569: name + " を更新しました" :
10570: name + " was updated");
10571: } else {
10572: System.out.println (Multilingual.mlnJapanese ?
10573: name + " を作りました" :
10574: name + " was created");
10575: }
10576: return true;
10577: } else {
10578: switch (rscShowError (Multilingual.mlnJapanese ?
10579: nameTmp + " を " + name + " にリネームできません" :
10580: nameTmp + " cannot be renamed to " + name,
10581: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
10582: case RSC_A_MASK:
10583: break retry;
10584: case RSC_R_MASK:
10585: continue retry;
10586: }
10587: }
10588: break;
10589: }
10590: if (fileExists) {
10591: System.out.println (Multilingual.mlnJapanese ?
10592: name + " を更新できません" :
10593: name + " cannot be updated");
10594: } else {
10595: System.out.println (Multilingual.mlnJapanese ?
10596: name + " を作れません" :
10597: name + " cannot be created");
10598: }
10599: return false;
10600: }
10601:
10602:
10603:
10604:
10605:
10606:
10607: public static final Pattern ISM_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10608:
10609:
10610:
10611:
10612:
10613:
10614:
10615:
10616:
10617:
10618:
10619: public static InputStream ismOpen (String name) {
10620: InputStream in = null;
10621: in = ismOpen (name, false);
10622: if (in == null && name.indexOf ('/') < 0 && name.indexOf ('\\') < 0) {
10623: in = ismOpen (name, true);
10624: }
10625: return in;
10626: }
10627: public static InputStream ismOpen (String name, boolean useGetResource) {
10628: boolean gzipped = name.toLowerCase ().endsWith (".gz");
10629: String[] zipSplittedName = ISM_ZIP_SEPARATOR.split (name, 2);
10630: String fileName = zipSplittedName[0];
10631: String zipEntryName = zipSplittedName.length < 2 ? null : zipSplittedName[1];
10632: InputStream in = null;
10633: try {
10634: if (useGetResource) {
10635: if (false) {
10636: URL url = XEiJ.class.getResource (fileName);
10637: if (url != null) {
10638: in = url.openStream ();
10639: }
10640: } else {
10641: in = XEiJ.class.getResourceAsStream (fileName);
10642: }
10643: } else {
10644: File file = new File (fileName);
10645: if (file.exists ()) {
10646: in = new FileInputStream (file);
10647: }
10648: }
10649: if (in != null && zipEntryName != null) {
10650: ZipInputStream zin = new ZipInputStream (in);
10651: in = null;
10652: ZipEntry entry;
10653: while ((entry = zin.getNextEntry ()) != null) {
10654: if (zipEntryName.equals (entry.getName ())) {
10655: in = zin;
10656: break;
10657: }
10658: }
10659: if (in == null) {
10660: System.out.println (Multilingual.mlnJapanese ? fileName + " の中に " + zipEntryName + " がありません" :
10661: zipEntryName + " does not exist in " + fileName);
10662: }
10663: }
10664: if (in != null && gzipped) {
10665: in = new GZIPInputStream (in);
10666: }
10667: if (in != null) {
10668: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " を読み込みます" :
10669: (useGetResource ? "Reading resource file " : "Reading file ") + name);
10670: return new BufferedInputStream (in);
10671: }
10672: } catch (Exception ioe) {
10673: if (prgVerbose) {
10674: prgPrintStackTraceOf (ioe);
10675: }
10676: }
10677: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " が見つかりません" :
10678: (useGetResource ? "Resource file " : "File ") + name + " is not found");
10679: return null;
10680: }
10681:
10682:
10683:
10684:
10685:
10686:
10687:
10688:
10689: public static int ismRead (InputStream in, byte[] bb, int o, int l) {
10690: try {
10691: int k = 0;
10692: while (k < l) {
10693: int t = in.read (bb, o + k, l - k);
10694: if (t < 0) {
10695: break;
10696: }
10697: k += t;
10698: }
10699: return k;
10700: } catch (IOException ioe) {
10701: if (prgVerbose) {
10702: prgPrintStackTraceOf (ioe);
10703: }
10704: }
10705: return -1;
10706: }
10707:
10708:
10709:
10710:
10711:
10712:
10713:
10714:
10715: public static int ismSkip (InputStream in, int l) {
10716: try {
10717: int k = 0;
10718: while (k < l) {
10719:
10720:
10721: if (in.read () < 0) {
10722: break;
10723: }
10724: k++;
10725: if (k < l) {
10726: int t = (int) in.skip ((long) (l - k));
10727: if (t < 0) {
10728: break;
10729: }
10730: k += t;
10731: }
10732: }
10733: return k;
10734: } catch (IOException ioe) {
10735: if (prgVerbose) {
10736: prgPrintStackTraceOf (ioe);
10737: }
10738: }
10739: return -1;
10740: }
10741:
10742:
10743:
10744:
10745:
10746: public static void ismClose (InputStream in) {
10747: try {
10748: if (in != null) {
10749: in.close ();
10750: }
10751: } catch (IOException ioe) {
10752: if (prgVerbose) {
10753: prgPrintStackTraceOf (ioe);
10754: }
10755: }
10756: }
10757:
10758:
10759:
10760:
10761:
10762:
10763: public static int ismLength (String name, int maxLength) {
10764: int length;
10765: InputStream in = ismOpen (name);
10766: if (in == null) {
10767: length = -1;
10768: } else {
10769: length = ismSkip (in, maxLength);
10770: ismClose (in);
10771: }
10772: return length;
10773: }
10774:
10775:
10776:
10777:
10778:
10779:
10780:
10781:
10782:
10783:
10784:
10785:
10786:
10787:
10788: public static boolean ismLoad (byte[] bb, int o, int l, String names) {
10789: for (String name : names.split (",")) {
10790: if (name.length () != 0) {
10791: InputStream in = ismOpen (name);
10792: if (in != null) {
10793: int k = ismRead (in, bb, o, l);
10794: ismClose (in);
10795: if (k == l) {
10796: return true;
10797: }
10798: }
10799: }
10800: }
10801: return false;
10802: }
10803:
10804:
10805:
10806:
10807:
10808:
10809:
10810:
10811:
10812: public static boolean ismSave (byte[] bb, int offset, long length, String path, boolean verbose) {
10813: if (ISM_ZIP_SEPARATOR.split (path, 2).length != 1) {
10814: if (verbose) {
10815: pnlExitFullScreen (true);
10816: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? path + " に書き出せません" : "Cannot write " + path);
10817: }
10818: return false;
10819: }
10820: long step = 0;
10821: byte[] zz = null;
10822: long pointer = (long) (bb.length - offset);
10823: if (pointer < length) {
10824: step = Math.min (1024L * 512, length - pointer);
10825: zz = new byte[(int) step];
10826: Arrays.fill (zz, (byte) 0);
10827: }
10828:
10829: File file = new File (path);
10830:
10831: if (step == 0 &&
10832: file.exists () && file.length () == length) {
10833:
10834: if (length == 0L) {
10835: return true;
10836: }
10837: InputStream in = ismOpen (path);
10838: if (in != null) {
10839: int l = (int) length;
10840: byte[] tt = new byte[l];
10841: int k = ismRead (in, tt, 0, l);
10842: ismClose (in);
10843: if (k == l &&
10844: Arrays.equals (tt, bb.length == l ? bb : Arrays.copyOfRange (bb, offset, offset + l))) {
10845: return true;
10846: }
10847: }
10848: }
10849:
10850: String pathTmp = path + ".tmp";
10851: String pathBak = path + ".bak";
10852: File fileTmp = new File (pathTmp);
10853: File fileBak = new File (pathBak);
10854:
10855: if (fileTmp.exists ()) {
10856: if (!fileTmp.delete ()) {
10857: if (verbose) {
10858: pnlExitFullScreen (true);
10859: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " を削除できません" : "Cannot delete " + pathTmp);
10860: }
10861: return false;
10862: }
10863: }
10864:
10865: try (OutputStream out = path.toLowerCase ().endsWith (".gz") ?
10866: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10867: {
10868:
10869: def.setLevel (Deflater.DEFAULT_COMPRESSION);
10870:
10871: }
10872: } :
10873: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
10874: if (step == 0) {
10875: out.write (bb, offset, (int) length);
10876: } else {
10877: out.write (bb, offset, (int) pointer);
10878: for (; pointer < length; pointer += step) {
10879: out.write (zz, 0, (int) Math.min (step, length - pointer));
10880: }
10881: }
10882: } catch (IOException ioe) {
10883: if (verbose) {
10884: prgPrintStackTraceOf (ioe);
10885: pnlExitFullScreen (true);
10886: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " に書き出せません" : "Cannot write " + pathTmp);
10887: }
10888: return false;
10889: }
10890:
10891:
10892: if (file.exists ()) {
10893: if (fileBak.exists ()) {
10894: if (!fileBak.delete ()) {
10895: if (verbose) {
10896: pnlExitFullScreen (true);
10897: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathBak + " を削除できません" : "Cannot delete " + pathBak);
10898: }
10899: return false;
10900: }
10901: }
10902: if (!file.renameTo (fileBak)) {
10903: if (verbose) {
10904: pnlExitFullScreen (true);
10905: JOptionPane.showMessageDialog (
10906: null, Multilingual.mlnJapanese ? path + " を " + pathBak + " にリネームできません" : "Cannot rename " + path + " to " + pathBak);
10907: }
10908: return false;
10909: }
10910: }
10911:
10912:
10913: if (!fileTmp.renameTo (file)) {
10914: if (verbose) {
10915: pnlExitFullScreen (true);
10916: JOptionPane.showMessageDialog (
10917: null, Multilingual.mlnJapanese ? pathTmp + " を " + path + " にリネームできません" : "Cannot rename " + pathTmp + " to " + path);
10918: }
10919: return false;
10920: }
10921: return true;
10922: }
10923:
10924:
10925:
10926:
10927:
10928:
10929:
10930: public static final char[] FMT_TEMP = new char[32];
10931:
10932:
10933:
10934:
10935:
10936:
10937:
10938:
10939:
10940:
10941:
10942: public static final char[] FMT_AIN4_BASE = ".......*..*...**.*...*.*.**..****...*..**.*.*.****..**.****.****".toCharArray ();
10943: public static final char[] FMT_BIN4_BASE = "0000000100100011010001010110011110001001101010111100110111101111".toCharArray ();
10944:
10945:
10946:
10947:
10948:
10949:
10950:
10951:
10952: public static void fmtAin4 (char[] a, int o, int x) {
10953: a[o ] = (char) (x >> 1 & 4 ^ 46);
10954: a[o + 1] = (char) (x & 4 ^ 46);
10955: a[o + 2] = (char) (x << 1 & 4 ^ 46);
10956: a[o + 3] = (char) (x << 2 & 4 ^ 46);
10957: }
10958: public static void fmtBin4 (char[] a, int o, int x) {
10959: a[o ] = (char) (x >>> 3 & 1 | 48);
10960: a[o + 1] = (char) (x >>> 2 & 1 | 48);
10961: a[o + 2] = (char) (x >>> 1 & 1 | 48);
10962: a[o + 3] = (char) (x & 1 | 48);
10963: }
10964: public static String fmtAin4 (int x) {
10965: return String.valueOf (FMT_AIN4_BASE, (x & 15) << 2, 4);
10966: }
10967: public static String fmtBin4 (int x) {
10968: return String.valueOf (FMT_BIN4_BASE, (x & 15) << 2, 4);
10969: }
10970: public static StringBuilder fmtAin4 (StringBuilder sb, int x) {
10971: return sb.append (FMT_AIN4_BASE, (x & 15) << 2, 6);
10972: }
10973: public static StringBuilder fmtBin4 (StringBuilder sb, int x) {
10974: return sb.append (FMT_BIN4_BASE, (x & 15) << 2, 6);
10975: }
10976:
10977:
10978:
10979:
10980:
10981:
10982:
10983:
10984: public static void fmtAin6 (char[] a, int o, int x) {
10985: a[o ] = (char) (x >> 3 & 4 ^ 46);
10986: a[o + 1] = (char) (x >> 2 & 4 ^ 46);
10987: a[o + 2] = (char) (x >> 1 & 4 ^ 46);
10988: a[o + 3] = (char) (x & 4 ^ 46);
10989: a[o + 4] = (char) (x << 1 & 4 ^ 46);
10990: a[o + 5] = (char) (x << 2 & 4 ^ 46);
10991: }
10992: public static void fmtBin6 (char[] a, int o, int x) {
10993: a[o ] = (char) (x >>> 5 & 1 | 48);
10994: a[o + 1] = (char) (x >>> 4 & 1 | 48);
10995: a[o + 2] = (char) (x >>> 3 & 1 | 48);
10996: a[o + 3] = (char) (x >>> 2 & 1 | 48);
10997: a[o + 4] = (char) (x >>> 1 & 1 | 48);
10998: a[o + 5] = (char) (x & 1 | 48);
10999: }
11000: public static String fmtAin6 (int x) {
11001: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11002: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11003: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11004: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11005: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11006: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11007: return String.valueOf (FMT_TEMP, 0, 6);
11008: }
11009: public static String fmtBin6 (int x) {
11010: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11011: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11012: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11013: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11014: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11015: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11016: return String.valueOf (FMT_TEMP, 0, 6);
11017: }
11018: public static StringBuilder fmtAin6 (StringBuilder sb, int x) {
11019: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11020: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11021: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11022: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11023: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11024: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11025: return sb.append (FMT_TEMP, 0, 6);
11026: }
11027: public static StringBuilder fmtBin6 (StringBuilder sb, int x) {
11028: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11029: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11030: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11031: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11032: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11033: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11034: return sb.append (FMT_TEMP, 0, 6);
11035: }
11036:
11037:
11038:
11039:
11040:
11041:
11042:
11043:
11044: public static void fmtAin8 (char[] a, int o, int x) {
11045: a[o ] = (char) (x >> 5 & 4 ^ 46);
11046: a[o + 1] = (char) (x >> 4 & 4 ^ 46);
11047: a[o + 2] = (char) (x >> 3 & 4 ^ 46);
11048: a[o + 3] = (char) (x >> 2 & 4 ^ 46);
11049: a[o + 4] = (char) (x >> 1 & 4 ^ 46);
11050: a[o + 5] = (char) (x & 4 ^ 46);
11051: a[o + 6] = (char) (x << 1 & 4 ^ 46);
11052: a[o + 7] = (char) (x << 2 & 4 ^ 46);
11053: }
11054: public static void fmtBin8 (char[] a, int o, int x) {
11055: a[o ] = (char) (x >>> 7 & 1 | 48);
11056: a[o + 1] = (char) (x >>> 6 & 1 | 48);
11057: a[o + 2] = (char) (x >>> 5 & 1 | 48);
11058: a[o + 3] = (char) (x >>> 4 & 1 | 48);
11059: a[o + 4] = (char) (x >>> 3 & 1 | 48);
11060: a[o + 5] = (char) (x >>> 2 & 1 | 48);
11061: a[o + 6] = (char) (x >>> 1 & 1 | 48);
11062: a[o + 7] = (char) (x & 1 | 48);
11063: }
11064: public static String fmtAin8 (int x) {
11065: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11066: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11067: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11068: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11069: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11070: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11071: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11072: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11073: return String.valueOf (FMT_TEMP, 0, 8);
11074: }
11075: public static String fmtBin8 (int x) {
11076: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11077: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11078: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11079: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11080: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11081: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11082: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11083: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11084: return String.valueOf (FMT_TEMP, 0, 8);
11085: }
11086: public static StringBuilder fmtAin8 (StringBuilder sb, int x) {
11087: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11088: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11089: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11090: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11091: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11092: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11093: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11094: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11095: return sb.append (FMT_TEMP, 0, 8);
11096: }
11097: public static StringBuilder fmtBin8 (StringBuilder sb, int x) {
11098: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11099: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11100: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11101: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11102: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11103: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11104: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11105: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11106: return sb.append (FMT_TEMP, 0, 8);
11107: }
11108:
11109:
11110:
11111:
11112:
11113:
11114:
11115:
11116: public static void fmtAin12 (char[] a, int o, int x) {
11117: a[o ] = (char) (x >> 9 & 4 ^ 46);
11118: a[o + 1] = (char) (x >> 8 & 4 ^ 46);
11119: a[o + 2] = (char) (x >> 7 & 4 ^ 46);
11120: a[o + 3] = (char) (x >> 6 & 4 ^ 46);
11121: a[o + 4] = (char) (x >> 5 & 4 ^ 46);
11122: a[o + 5] = (char) (x >> 4 & 4 ^ 46);
11123: a[o + 6] = (char) (x >> 3 & 4 ^ 46);
11124: a[o + 7] = (char) (x >> 2 & 4 ^ 46);
11125: a[o + 8] = (char) (x >> 1 & 4 ^ 46);
11126: a[o + 9] = (char) (x & 4 ^ 46);
11127: a[o + 10] = (char) (x << 1 & 4 ^ 46);
11128: a[o + 11] = (char) (x << 2 & 4 ^ 46);
11129: }
11130: public static void fmtBin12 (char[] a, int o, int x) {
11131: a[o ] = (char) (x >>> 11 & 1 | 48);
11132: a[o + 1] = (char) (x >>> 10 & 1 | 48);
11133: a[o + 2] = (char) (x >>> 9 & 1 | 48);
11134: a[o + 3] = (char) (x >>> 8 & 1 | 48);
11135: a[o + 4] = (char) (x >>> 7 & 1 | 48);
11136: a[o + 5] = (char) (x >>> 6 & 1 | 48);
11137: a[o + 6] = (char) (x >>> 5 & 1 | 48);
11138: a[o + 7] = (char) (x >>> 4 & 1 | 48);
11139: a[o + 8] = (char) (x >>> 3 & 1 | 48);
11140: a[o + 9] = (char) (x >>> 2 & 1 | 48);
11141: a[o + 10] = (char) (x >>> 1 & 1 | 48);
11142: a[o + 11] = (char) (x & 1 | 48);
11143: }
11144: public static String fmtAin12 (int x) {
11145: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11146: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11147: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11148: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11149: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11150: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11151: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11152: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11153: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11154: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11155: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11156: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11157: return String.valueOf (FMT_TEMP, 0, 12);
11158: }
11159: public static String fmtBin12 (int x) {
11160: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11161: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11162: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11163: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11164: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11165: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11166: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11167: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11168: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11169: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11170: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11171: FMT_TEMP[11] = (char) (x & 1 | 48);
11172: return String.valueOf (FMT_TEMP, 0, 12);
11173: }
11174: public static StringBuilder fmtAin12 (StringBuilder sb, int x) {
11175: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11176: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11177: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11178: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11179: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11180: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11181: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11182: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11183: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11184: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11185: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11186: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11187: return sb.append (FMT_TEMP, 0, 12);
11188: }
11189: public static StringBuilder fmtBin12 (StringBuilder sb, int x) {
11190: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11191: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11192: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11193: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11194: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11195: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11196: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11197: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11198: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11199: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11200: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11201: FMT_TEMP[11] = (char) (x & 1 | 48);
11202: return sb.append (FMT_TEMP, 0, 12);
11203: }
11204:
11205:
11206:
11207:
11208:
11209:
11210:
11211:
11212: public static void fmtAin16 (char[] a, int o, int x) {
11213: a[o ] = (char) (x >> 13 & 4 ^ 46);
11214: a[o + 1] = (char) (x >> 12 & 4 ^ 46);
11215: a[o + 2] = (char) (x >> 11 & 4 ^ 46);
11216: a[o + 3] = (char) (x >> 10 & 4 ^ 46);
11217: a[o + 4] = (char) (x >> 9 & 4 ^ 46);
11218: a[o + 5] = (char) (x >> 8 & 4 ^ 46);
11219: a[o + 6] = (char) (x >> 7 & 4 ^ 46);
11220: a[o + 7] = (char) (x >> 6 & 4 ^ 46);
11221: a[o + 8] = (char) (x >> 5 & 4 ^ 46);
11222: a[o + 9] = (char) (x >> 4 & 4 ^ 46);
11223: a[o + 10] = (char) (x >> 3 & 4 ^ 46);
11224: a[o + 11] = (char) (x >> 2 & 4 ^ 46);
11225: a[o + 12] = (char) (x >> 1 & 4 ^ 46);
11226: a[o + 13] = (char) (x & 4 ^ 46);
11227: a[o + 14] = (char) (x << 1 & 4 ^ 46);
11228: a[o + 15] = (char) (x << 2 & 4 ^ 46);
11229: }
11230: public static void fmtBin16 (char[] a, int o, int x) {
11231: a[o ] = (char) (x >>> 15 & 1 | 48);
11232: a[o + 1] = (char) (x >>> 14 & 1 | 48);
11233: a[o + 2] = (char) (x >>> 13 & 1 | 48);
11234: a[o + 3] = (char) (x >>> 12 & 1 | 48);
11235: a[o + 4] = (char) (x >>> 11 & 1 | 48);
11236: a[o + 5] = (char) (x >>> 10 & 1 | 48);
11237: a[o + 6] = (char) (x >>> 9 & 1 | 48);
11238: a[o + 7] = (char) (x >>> 8 & 1 | 48);
11239: a[o + 8] = (char) (x >>> 7 & 1 | 48);
11240: a[o + 9] = (char) (x >>> 6 & 1 | 48);
11241: a[o + 10] = (char) (x >>> 5 & 1 | 48);
11242: a[o + 11] = (char) (x >>> 4 & 1 | 48);
11243: a[o + 12] = (char) (x >>> 3 & 1 | 48);
11244: a[o + 13] = (char) (x >>> 2 & 1 | 48);
11245: a[o + 14] = (char) (x >>> 1 & 1 | 48);
11246: a[o + 15] = (char) (x & 1 | 48);
11247: }
11248: public static String fmtAin16 (int x) {
11249: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11250: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11251: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11252: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11253: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11254: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11255: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11256: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11257: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11258: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11259: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11260: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11261: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11262: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11263: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11264: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11265: return String.valueOf (FMT_TEMP, 0, 16);
11266: }
11267: public static String fmtBin16 (int x) {
11268: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11269: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11270: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11271: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11272: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11273: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11274: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11275: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11276: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11277: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11278: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11279: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11280: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11281: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11282: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11283: FMT_TEMP[15] = (char) (x & 1 | 48);
11284: return String.valueOf (FMT_TEMP, 0, 16);
11285: }
11286: public static StringBuilder fmtAin16 (StringBuilder sb, int x) {
11287: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11288: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11289: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11290: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11291: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11292: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11293: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11294: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11295: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11296: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11297: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11298: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11299: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11300: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11301: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11302: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11303: return sb.append (FMT_TEMP, 0, 16);
11304: }
11305: public static StringBuilder fmtBin16 (StringBuilder sb, int x) {
11306: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11307: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11308: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11309: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11310: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11311: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11312: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11313: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11314: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11315: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11316: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11317: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11318: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11319: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11320: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11321: FMT_TEMP[15] = (char) (x & 1 | 48);
11322: return sb.append (FMT_TEMP, 0, 16);
11323: }
11324:
11325:
11326:
11327:
11328:
11329:
11330:
11331:
11332: public static void fmtAin24 (char[] a, int o, int x) {
11333: a[o ] = (char) (x >> 21 & 4 ^ 46);
11334: a[o + 1] = (char) (x >> 20 & 4 ^ 46);
11335: a[o + 2] = (char) (x >> 19 & 4 ^ 46);
11336: a[o + 3] = (char) (x >> 18 & 4 ^ 46);
11337: a[o + 4] = (char) (x >> 17 & 4 ^ 46);
11338: a[o + 5] = (char) (x >> 16 & 4 ^ 46);
11339: a[o + 6] = (char) (x >> 15 & 4 ^ 46);
11340: a[o + 7] = (char) (x >> 14 & 4 ^ 46);
11341: a[o + 8] = (char) (x >> 13 & 4 ^ 46);
11342: a[o + 9] = (char) (x >> 12 & 4 ^ 46);
11343: a[o + 10] = (char) (x >> 11 & 4 ^ 46);
11344: a[o + 11] = (char) (x >> 10 & 4 ^ 46);
11345: a[o + 12] = (char) (x >> 9 & 4 ^ 46);
11346: a[o + 13] = (char) (x >> 8 & 4 ^ 46);
11347: a[o + 14] = (char) (x >> 7 & 4 ^ 46);
11348: a[o + 15] = (char) (x >> 6 & 4 ^ 46);
11349: a[o + 16] = (char) (x >> 5 & 4 ^ 46);
11350: a[o + 17] = (char) (x >> 4 & 4 ^ 46);
11351: a[o + 18] = (char) (x >> 3 & 4 ^ 46);
11352: a[o + 19] = (char) (x >> 2 & 4 ^ 46);
11353: a[o + 20] = (char) (x >> 1 & 4 ^ 46);
11354: a[o + 21] = (char) (x & 4 ^ 46);
11355: a[o + 22] = (char) (x << 1 & 4 ^ 46);
11356: a[o + 23] = (char) (x << 2 & 4 ^ 46);
11357: }
11358: public static void fmtBin24 (char[] a, int o, int x) {
11359: a[o ] = (char) (x >>> 23 & 1 | 48);
11360: a[o + 1] = (char) (x >>> 22 & 1 | 48);
11361: a[o + 2] = (char) (x >>> 21 & 1 | 48);
11362: a[o + 3] = (char) (x >>> 20 & 1 | 48);
11363: a[o + 4] = (char) (x >>> 19 & 1 | 48);
11364: a[o + 5] = (char) (x >>> 18 & 1 | 48);
11365: a[o + 6] = (char) (x >>> 17 & 1 | 48);
11366: a[o + 7] = (char) (x >>> 16 & 1 | 48);
11367: a[o + 8] = (char) (x >>> 15 & 1 | 48);
11368: a[o + 9] = (char) (x >>> 14 & 1 | 48);
11369: a[o + 10] = (char) (x >>> 13 & 1 | 48);
11370: a[o + 11] = (char) (x >>> 12 & 1 | 48);
11371: a[o + 12] = (char) (x >>> 11 & 1 | 48);
11372: a[o + 13] = (char) (x >>> 10 & 1 | 48);
11373: a[o + 14] = (char) (x >>> 9 & 1 | 48);
11374: a[o + 15] = (char) (x >>> 8 & 1 | 48);
11375: a[o + 16] = (char) (x >>> 7 & 1 | 48);
11376: a[o + 17] = (char) (x >>> 6 & 1 | 48);
11377: a[o + 18] = (char) (x >>> 5 & 1 | 48);
11378: a[o + 19] = (char) (x >>> 4 & 1 | 48);
11379: a[o + 20] = (char) (x >>> 3 & 1 | 48);
11380: a[o + 21] = (char) (x >>> 2 & 1 | 48);
11381: a[o + 22] = (char) (x >>> 1 & 1 | 48);
11382: a[o + 23] = (char) (x & 1 | 48);
11383: }
11384: public static String fmtAin24 (int x) {
11385: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11386: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11387: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11388: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11389: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11390: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11391: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11392: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11393: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11394: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11395: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11396: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11397: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11398: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11399: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11400: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11401: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11402: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11403: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11404: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11405: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11406: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11407: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11408: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11409: return String.valueOf (FMT_TEMP, 0, 24);
11410: }
11411: public static String fmtBin24 (int x) {
11412: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11413: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11414: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11415: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11416: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11417: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11418: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11419: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11420: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11421: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11422: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11423: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11424: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11425: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11426: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11427: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11428: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11429: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11430: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11431: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11432: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11433: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11434: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11435: FMT_TEMP[23] = (char) (x & 1 | 48);
11436: return String.valueOf (FMT_TEMP, 0, 24);
11437: }
11438: public static StringBuilder fmtAin24 (StringBuilder sb, int x) {
11439: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
11440: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
11441: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
11442: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
11443: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
11444: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
11445: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
11446: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
11447: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
11448: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
11449: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
11450: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
11451: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
11452: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
11453: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
11454: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
11455: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
11456: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
11457: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
11458: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
11459: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
11460: FMT_TEMP[21] = (char) (x & 4 ^ 46);
11461: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
11462: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
11463: return sb.append (FMT_TEMP, 0, 24);
11464: }
11465: public static StringBuilder fmtBin24 (StringBuilder sb, int x) {
11466: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
11467: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
11468: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
11469: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
11470: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
11471: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
11472: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
11473: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
11474: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
11475: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
11476: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
11477: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
11478: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
11479: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
11480: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
11481: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
11482: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
11483: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
11484: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
11485: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
11486: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
11487: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
11488: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
11489: FMT_TEMP[23] = (char) (x & 1 | 48);
11490: return sb.append (FMT_TEMP, 0, 24);
11491: }
11492:
11493:
11494:
11495:
11496:
11497:
11498:
11499:
11500:
11501:
11502:
11503:
11504:
11505:
11506:
11507:
11508:
11509:
11510:
11511:
11512:
11513:
11514:
11515:
11516:
11517:
11518:
11519:
11520:
11521:
11522:
11523:
11524:
11525: public static char fmtHexc (int x) {
11526: x &= 15;
11527: return (char) ((((9 - x) >> 4) & 7) + 48 + x);
11528: }
11529: public static void fmtHex1 (char[] a, int o, int x) {
11530: x &= 15;
11531: a[o] = (char) ((((9 - x) >> 4) & 7) + 48 + x);
11532: }
11533: public static String fmtHex1 (int x) {
11534: x &= 15;
11535: return Character.toString ((char) ((((9 - x) >> 4) & 7) + 48 + x));
11536: }
11537: public static StringBuilder fmtHex1 (StringBuilder sb, int x) {
11538: x &= 15;
11539: return sb.append ((char) ((((9 - x) >> 4) & 7) + 48 + x));
11540: }
11541:
11542:
11543:
11544:
11545:
11546:
11547: public static void fmtHex2 (char[] a, int o, int x) {
11548: int x0 = x & 15;
11549: int x1 = x >>> 4 & 15;
11550: a[o ] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
11551: a[o + 1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
11552: }
11553: public static String fmtHex2 (int x) {
11554:
11555: int x0 = x & 15;
11556: int x1 = x >>> 4 & 15;
11557: FMT_TEMP[0] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
11558: FMT_TEMP[1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
11559: return String.valueOf (FMT_TEMP, 0, 2);
11560: }
11561: public static StringBuilder fmtHex2 (StringBuilder sb, int x) {
11562: int x0 = x & 15;
11563: int x1 = x >>> 4 & 15;
11564: return (sb.
11565: append ((char) ((((9 - x1) >> 4) & 7) + 48 + x1)).
11566: append ((char) ((((9 - x0) >> 4) & 7) + 48 + x0)));
11567: }
11568:
11569:
11570:
11571:
11572:
11573:
11574: public static void fmtHex4 (char[] a, int o, int x) {
11575: int t;
11576: t = (char) x >>> 12;
11577: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11578: t = x >>> 8 & 15;
11579: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11580: t = x >>> 4 & 15;
11581: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11582: t = x & 15;
11583: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11584: }
11585: public static String fmtHex4 (int x) {
11586:
11587: int t;
11588: t = (char) x >>> 12;
11589: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11590: t = x >>> 8 & 15;
11591: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11592: t = x >>> 4 & 15;
11593: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11594: t = x & 15;
11595: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11596: return String.valueOf (FMT_TEMP, 0, 4);
11597: }
11598: public static StringBuilder fmtHex4 (StringBuilder sb, int x) {
11599:
11600: int t;
11601: t = (char) x >>> 12;
11602: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11603: t = x >>> 8 & 15;
11604: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11605: t = x >>> 4 & 15;
11606: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11607: t = x & 15;
11608: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11609: return sb.append (FMT_TEMP, 0, 4);
11610: }
11611:
11612:
11613:
11614:
11615:
11616:
11617: public static void fmtHex6 (char[] a, int o, int x) {
11618: int t;
11619: t = x >>> 20 & 15;
11620: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11621: t = x >>> 16 & 15;
11622: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11623: t = (char) x >>> 12;
11624: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11625: t = x >>> 8 & 15;
11626: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11627: t = x >>> 4 & 15;
11628: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11629: t = x & 15;
11630: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11631: }
11632: public static String fmtHex6 (int x) {
11633:
11634: int t;
11635: t = x >>> 20 & 15;
11636: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11637: t = x >>> 16 & 15;
11638: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11639: t = (char) x >>> 12;
11640: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11641: t = x >>> 8 & 15;
11642: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11643: t = x >>> 4 & 15;
11644: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11645: t = x & 15;
11646: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11647: return String.valueOf (FMT_TEMP, 0, 6);
11648: }
11649: public static StringBuilder fmtHex6 (StringBuilder sb, int x) {
11650:
11651: int t;
11652: t = x >>> 20 & 15;
11653: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11654: t = x >>> 16 & 15;
11655: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11656: t = (char) x >>> 12;
11657: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11658: t = x >>> 8 & 15;
11659: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11660: t = x >>> 4 & 15;
11661: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11662: t = x & 15;
11663: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11664: return sb.append (FMT_TEMP, 0, 6);
11665: }
11666:
11667:
11668:
11669:
11670:
11671:
11672: public static void fmtHex8 (char[] a, int o, int x) {
11673: int t;
11674: t = x >>> 28;
11675: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11676: t = x >>> 24 & 15;
11677: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11678: t = x >>> 20 & 15;
11679: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11680: t = x >>> 16 & 15;
11681: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11682: t = (char) x >>> 12;
11683: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11684: t = x >>> 8 & 15;
11685: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11686: t = x >>> 4 & 15;
11687: a[o + 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11688: t = x & 15;
11689: a[o + 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11690: }
11691: public static String fmtHex8 (int x) {
11692:
11693: int t;
11694: t = x >>> 28;
11695: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11696: t = x >>> 24 & 15;
11697: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11698: t = x >>> 20 & 15;
11699: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11700: t = x >>> 16 & 15;
11701: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11702: t = (char) x >>> 12;
11703: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11704: t = x >>> 8 & 15;
11705: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11706: t = x >>> 4 & 15;
11707: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11708: t = x & 15;
11709: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11710: return String.valueOf (FMT_TEMP, 0, 8);
11711: }
11712: public static StringBuilder fmtHex8 (StringBuilder sb, int x) {
11713:
11714: int t;
11715: t = x >>> 28;
11716: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11717: t = x >>> 24 & 15;
11718: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11719: t = x >>> 20 & 15;
11720: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11721: t = x >>> 16 & 15;
11722: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11723: t = (char) x >>> 12;
11724: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11725: t = x >>> 8 & 15;
11726: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11727: t = x >>> 4 & 15;
11728: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11729: t = x & 15;
11730: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11731: return sb.append (FMT_TEMP, 0, 8);
11732: }
11733:
11734: public static StringBuilder fmtHex16 (StringBuilder sb, long x) {
11735:
11736: int s, t;
11737: s = (int) (x >>> 32);
11738: t = s >>> 28;
11739: FMT_TEMP[ 0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11740: t = s >>> 24 & 15;
11741: FMT_TEMP[ 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11742: t = s >>> 20 & 15;
11743: FMT_TEMP[ 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11744: t = s >>> 16 & 15;
11745: FMT_TEMP[ 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11746: t = (char) s >>> 12;
11747: FMT_TEMP[ 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11748: t = s >>> 8 & 15;
11749: FMT_TEMP[ 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11750: t = s >>> 4 & 15;
11751: FMT_TEMP[ 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11752: t = s & 15;
11753: FMT_TEMP[ 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11754: s = (int) x;
11755: t = s >>> 28;
11756: FMT_TEMP[ 8] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11757: t = s >>> 24 & 15;
11758: FMT_TEMP[ 9] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11759: t = s >>> 20 & 15;
11760: FMT_TEMP[10] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11761: t = s >>> 16 & 15;
11762: FMT_TEMP[11] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11763: t = (char) s >>> 12;
11764: FMT_TEMP[12] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11765: t = s >>> 8 & 15;
11766: FMT_TEMP[13] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11767: t = s >>> 4 & 15;
11768: FMT_TEMP[14] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11769: t = s & 15;
11770: FMT_TEMP[15] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
11771: return sb.append (FMT_TEMP, 0, 16);
11772: }
11773:
11774:
11775:
11776:
11777:
11778:
11779:
11780:
11781:
11782:
11783:
11784:
11785:
11786:
11787:
11788:
11789:
11790:
11791:
11792:
11793:
11794:
11795:
11796:
11797:
11798:
11799:
11800:
11801:
11802:
11803:
11804:
11805:
11806:
11807:
11808:
11809:
11810:
11811:
11812:
11813:
11814:
11815:
11816:
11817:
11818:
11819:
11820:
11821:
11822:
11823:
11824:
11825:
11826:
11827:
11828:
11829:
11830:
11831:
11832:
11833:
11834:
11835:
11836:
11837:
11838:
11839:
11840:
11841: public static final int[] FMT_BCD4 = new int[10000];
11842: public static final int[] FMT_DCB4 = new int[65536];
11843:
11844:
11845:
11846:
11847: public static void fmtInit () {
11848: Arrays.fill (FMT_DCB4, -1);
11849: int i = 0;
11850: int x = 0;
11851: for (int a = 0; a < 10; a++) {
11852: for (int b = 0; b < 10; b++) {
11853: for (int c = 0; c < 10; c++) {
11854: FMT_DCB4[FMT_BCD4[i ] = x ] = i;
11855: FMT_DCB4[FMT_BCD4[i + 1] = x + 1] = i + 1;
11856: FMT_DCB4[FMT_BCD4[i + 2] = x + 2] = i + 2;
11857: FMT_DCB4[FMT_BCD4[i + 3] = x + 3] = i + 3;
11858: FMT_DCB4[FMT_BCD4[i + 4] = x + 4] = i + 4;
11859: FMT_DCB4[FMT_BCD4[i + 5] = x + 5] = i + 5;
11860: FMT_DCB4[FMT_BCD4[i + 6] = x + 6] = i + 6;
11861: FMT_DCB4[FMT_BCD4[i + 7] = x + 7] = i + 7;
11862: FMT_DCB4[FMT_BCD4[i + 8] = x + 8] = i + 8;
11863: FMT_DCB4[FMT_BCD4[i + 9] = x + 9] = i + 9;
11864: i += 10;
11865: x += 1 << 4;
11866: }
11867: x += 6 << 4;
11868: }
11869: x += 6 << 8;
11870: }
11871: }
11872:
11873:
11874:
11875: public static int fmtBcd4 (int x) {
11876:
11877:
11878:
11879:
11880:
11881:
11882:
11883:
11884:
11885: return FMT_BCD4[Math.max (0, Math.min (9999, x))];
11886: }
11887:
11888:
11889:
11890: public static int fmtBcd8 (int x) {
11891: x = Math.max (0, Math.min (99999999, x));
11892:
11893:
11894: int q = (int) ((long) x * 109951163L >>> 40);
11895:
11896: return FMT_BCD4[q] << 16 | FMT_BCD4[x - 10000 * q];
11897: }
11898:
11899:
11900:
11901: public static long fmtBcd12 (long x) {
11902: x = Math.max (0L, Math.min (999999999999L, x));
11903: int q = (int) ((double) x / 100000000.0);
11904: int r = (int) (x - 100000000L * q);
11905:
11906:
11907: int rq = (int) ((long) r * 109951163L >>> 40);
11908:
11909: return (long) FMT_BCD4[q] << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
11910: }
11911:
11912:
11913:
11914: public static long fmtBcd16 (long x) {
11915: x = Math.max (0L, Math.min (9999999999999999L, x));
11916: int q = x <= (1L << 53) ? (int) ((double) x / 100000000.0) : (int) (x / 100000000L);
11917: int r = (int) (x - 100000000L * q);
11918:
11919:
11920: int qq = (int) ((long) q * 109951163L >>> 40);
11921:
11922:
11923:
11924: int rq = (int) ((long) r * 109951163L >>> 40);
11925:
11926: return (long) (FMT_BCD4[qq] << 16 | FMT_BCD4[q - 10000 * qq]) << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
11927: }
11928:
11929:
11930:
11931:
11932:
11933:
11934: public static int fmtCA02u (char[] a, int o, int x) {
11935: if (x < 0 || 99 < x) {
11936: x = 99;
11937: }
11938: x = FMT_BCD4[x];
11939: a[o ] = (char) ('0' | x >>> 4);
11940: a[o + 1] = (char) ('0' | x & 15);
11941: return o + 2;
11942: }
11943: public static StringBuilder fmtSB02u (StringBuilder sb, int x) {
11944: return sb.append (FMT_TEMP, 0, fmtCA02u (FMT_TEMP, 0, x));
11945: }
11946:
11947:
11948:
11949:
11950:
11951: public static int fmtCA2u (char[] a, int o, int x) {
11952: if (x < 0 || 99 < x) {
11953: x = 99;
11954: }
11955: x = FMT_BCD4[x];
11956: if (x <= 0x000f) {
11957: a[o++] = (char) ('0' | x);
11958: } else {
11959: a[o++] = (char) ('0' | x >>> 4);
11960: a[o++] = (char) ('0' | x & 15);
11961: }
11962: return o;
11963: }
11964: public static StringBuilder fmtSB2u (StringBuilder sb, int x) {
11965: return sb.append (FMT_TEMP, 0, fmtCA2u (FMT_TEMP, 0, x));
11966: }
11967:
11968:
11969:
11970:
11971:
11972: public static int fmtCA04u (char[] a, int o, int x) {
11973: if (x < 0 || 9999 < x) {
11974: x = 9999;
11975: }
11976: x = FMT_BCD4[x];
11977: a[o ] = (char) ('0' | x >>> 12);
11978: a[o + 1] = (char) ('0' | x >>> 8 & 15);
11979: a[o + 2] = (char) ('0' | x >>> 4 & 15);
11980: a[o + 3] = (char) ('0' | x & 15);
11981: return o + 4;
11982: }
11983: public static StringBuilder fmtSB04u (StringBuilder sb, int x) {
11984: return sb.append (FMT_TEMP, 0, fmtCA04u (FMT_TEMP, 0, x));
11985: }
11986:
11987:
11988:
11989:
11990:
11991: public static int fmtCA4u (char[] a, int o, int x) {
11992: if (x < 0 || 9999 < x) {
11993: x = 9999;
11994: }
11995: x = FMT_BCD4[x];
11996: if (x <= 0x000f) {
11997: a[o++] = (char) ('0' | x);
11998: } else if (x <= 0x00ff) {
11999: a[o++] = (char) ('0' | x >>> 4);
12000: a[o++] = (char) ('0' | x & 15);
12001: } else if (x <= 0x0fff) {
12002: a[o++] = (char) ('0' | x >>> 8);
12003: a[o++] = (char) ('0' | x >>> 4 & 15);
12004: a[o++] = (char) ('0' | x & 15);
12005: } else {
12006: a[o++] = (char) ('0' | x >>> 12);
12007: a[o++] = (char) ('0' | x >>> 8 & 15);
12008: a[o++] = (char) ('0' | x >>> 4 & 15);
12009: a[o++] = (char) ('0' | x & 15);
12010: }
12011: return o;
12012: }
12013: public static StringBuilder fmtSB4u (StringBuilder sb, int x) {
12014: return sb.append (FMT_TEMP, 0, fmtCA4u (FMT_TEMP, 0, x));
12015: }
12016:
12017:
12018:
12019:
12020:
12021: public static int fmtCA08u (char[] a, int o, int x) {
12022: if (x < 0 || 99999999 < x) {
12023: x = 99999999;
12024: }
12025:
12026:
12027: int h = (int) ((long) x * 109951163L >>> 40);
12028: return fmtCA04u (a, fmtCA04u (a, o, h), x - h * 10000);
12029: }
12030: public static StringBuilder fmtSB08u (StringBuilder sb, int x) {
12031: return sb.append (FMT_TEMP, 0, fmtCA08u (FMT_TEMP, 0, x));
12032: }
12033:
12034:
12035:
12036:
12037:
12038: public static int fmtCA8u (char[] a, int o, int x) {
12039: if (x < 0 || 99999999 < x) {
12040: x = 99999999;
12041: }
12042: if (x <= 9999) {
12043: return fmtCA4u (a, o, x);
12044: } else {
12045:
12046:
12047: int h = (int) ((long) x * 109951163L >>> 40);
12048: return fmtCA04u (a, fmtCA4u (a, o, h), x - h * 10000);
12049: }
12050: }
12051: public static StringBuilder fmtSB8u (StringBuilder sb, int x) {
12052: return sb.append (FMT_TEMP, 0, fmtCA8u (FMT_TEMP, 0, x));
12053: }
12054:
12055:
12056:
12057:
12058:
12059: public static int fmtCAd (char[] a, int o, long x) {
12060: if (x < 0L) {
12061: x = -x;
12062: a[o++] = '-';
12063: }
12064: if (x <= 99999999L) {
12065: return fmtCA8u (a, o, (int) x);
12066: } else if (x <= 9999999999999999L) {
12067: long h = x / 100000000L;
12068: return fmtCA08u (a, fmtCA8u (a, o, (int) h), (int) (x - h * 100000000L));
12069: } else {
12070: long hh = x / 10000000000000000L;
12071: x -= hh * 10000000000000000L;
12072: long h = x / 100000000L;
12073: return fmtCA08u (a, fmtCA08u (a, fmtCA4u (a, o, (int) hh), (int) h), (int) (x - h * 100000000L));
12074: }
12075: }
12076: public static StringBuilder fmtSBd (StringBuilder sb, long x) {
12077: return sb.append (FMT_TEMP, 0, fmtCAd (FMT_TEMP, 0, x));
12078: }
12079:
12080:
12081:
12082:
12083:
12084:
12085: public static int fmtCAnd (char[] a, int o, int n, long x) {
12086: int t = fmtCAd (a, o, x);
12087: n += o;
12088: if (t < n) {
12089: int i = n;
12090: while (o < t) {
12091: a[--i] = a[--t];
12092: }
12093: while (o < i) {
12094: a[--i] = ' ';
12095: }
12096: t = n;
12097: }
12098: return t;
12099: }
12100: public static StringBuilder fmtSBnd (StringBuilder sb, int n, int x) {
12101: return sb.append (FMT_TEMP, 0, fmtCAnd (FMT_TEMP, 0, n, x));
12102: }
12103:
12104:
12105:
12106:
12107:
12108:
12109:
12110:
12111:
12112:
12113:
12114:
12115:
12116: public static int fmtParseInt (String s, int i, int min, int max, int err) {
12117: return fmtParseIntRadix (s, i, min, max, err, 10);
12118: }
12119: public static int fmtParseIntRadix (String s, int i, int min, int max, int err, int radix) {
12120: if (s == null) {
12121: return err;
12122: }
12123: int l = s.length ();
12124: int c = i < l ? s.charAt (i++) : -1;
12125:
12126: while (c == ' ' || c == '\t') {
12127: c = i < l ? s.charAt (i++) : -1;
12128: }
12129:
12130: int n = 0;
12131: if (c == '+') {
12132: c = i < l ? s.charAt (i++) : -1;
12133: } else if (c == '-') {
12134: n = 1;
12135: c = i < l ? s.charAt (i++) : -1;
12136: }
12137:
12138:
12139:
12140:
12141: int o;
12142: int p;
12143: if (c == '$') {
12144: o = 0x07ffffff + n;
12145: p = 15 + n & 15;
12146: radix = 16;
12147: c = i < l ? s.charAt (i++) : -1;
12148: } else if (radix == 16) {
12149: o = 0x07ffffff + n;
12150: p = 15 + n & 15;
12151: } else if (radix == 8) {
12152: o = 0x0fffffff + n;
12153: p = 7 + n & 7;
12154: } else if (radix == 2) {
12155: o = 0x3fffffff + n;
12156: p = 1 + n & 1;
12157: } else {
12158: o = 214748364;
12159: p = 7 + n;
12160: radix = 10;
12161: }
12162:
12163: int x = Character.digit (c, radix);
12164: if (x < 0) {
12165: return err;
12166: }
12167: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12168: while (c >= 0) {
12169: int t = x - o;
12170: if (t > 0 || t == 0 && c > p) {
12171: return err;
12172: }
12173: x = x * radix + c;
12174: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12175: }
12176: if (n != 0) {
12177: x = -x;
12178: }
12179: return min <= x && x <= max ? x : err;
12180: }
12181:
12182:
12183:
12184:
12185:
12186:
12187:
12188:
12189:
12190:
12191: public static long matMax3 (long x1, long x2, long x3) {
12192: return Math.max (Math.max (x1, x2), x3);
12193: }
12194: public static long matMax4 (long x1, long x2, long x3, long x4) {
12195: return Math.max (Math.max (x1, x2), Math.max (x3, x4));
12196: }
12197: public static long matMax5 (long x1, long x2, long x3, long x4, long x5) {
12198: return Math.max (Math.max (Math.max (x1, x2), Math.max (x3, x4)), x5);
12199: }
12200:
12201:
12202:
12203:
12204:
12205: public static long matMin3 (long x1, long x2, long x3) {
12206: return Math.min (Math.min (x1, x2), x3);
12207: }
12208: public static long matMin4 (long x1, long x2, long x3, long x4) {
12209: return Math.min (Math.min (x1, x2), Math.min (x3, x4));
12210: }
12211: public static long matMin5 (long x1, long x2, long x3, long x4, long x5) {
12212: return Math.min (Math.min (Math.min (x1, x2), Math.min (x3, x4)), x5);
12213: }
12214:
12215:
12216:
12217:
12218:
12219:
12220:
12221:
12222:
12223:
12224:
12225:
12226: public static String strEncodeUTF8 (String s) {
12227: StringBuilder sb = new StringBuilder ();
12228: int l = s.length ();
12229: for (int i = 0; i < l; i++) {
12230: int u = s.charAt (i);
12231: if (0xd800 <= u && u <= 0xdbff && i + 1 < l) {
12232: int v = s.charAt (i + 1);
12233: if (0xdc00 <= v && v <= 0xdfff) {
12234: u = 0x10000 + ((u & 0x3ff) << 10) + (v & 0x3ff);
12235: i++;
12236: }
12237: }
12238: if ((u & 0xffffff80) == 0) {
12239: sb.append ((char) u);
12240: } else if ((u & 0xfffff800) == 0) {
12241: u = (0x0000c080 |
12242: (u & 0x000007c0) << 2 |
12243: (u & 0x0000003f));
12244: sb.append ((char) (u >> 8)).append ((char) (u & 0xff));
12245: } else if ((u & 0xffff0000) == 0 && !(0xd800 <= u && u <= 0xdfff)) {
12246: u = (0x00e08080 |
12247: (u & 0x0000f000) << 4 |
12248: (u & 0x00000fc0) << 2 |
12249: (u & 0x0000003f));
12250: sb.append ((char) (u >> 16)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12251: } else if ((u & 0xffe00000) == 0) {
12252: u = (0xf0808080 |
12253: (u & 0x001c0000) << 6 |
12254: (u & 0x0003f000) << 4 |
12255: (u & 0x00000fc0) << 2 |
12256: (u & 0x0000003f));
12257: sb.append ((char) ((u >> 24) & 0xff)).append ((char) ((u >> 16) & 0xff)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12258: } else {
12259: sb.append ((char) 0xef).append ((char) 0xbf).append ((char) 0xbd);
12260: }
12261: }
12262: return sb.toString ();
12263: }
12264:
12265:
12266:
12267:
12268:
12269:
12270:
12271: public static String strDecodeUTF8 (String s) {
12272: StringBuilder sb = new StringBuilder ();
12273: int l = s.length ();
12274: for (int i = 0; i < l; i++) {
12275: int c = s.charAt (i) & 0xff;
12276: for (int k = ((c & 0x80) == 0x00 ? 0 :
12277: (c & 0xe0) == 0xc0 ? 1 :
12278: (c & 0xf0) == 0xe0 ? 2 :
12279: (c & 0xf8) == 0xf0 ? 3 :
12280: -1);
12281: --k >= 0; ) {
12282: c = c << 8 | (i + 1 < l ? s.charAt (++i) & 0xff : 0);
12283: }
12284: int u = ((c & 0xffffff80) == 0x00000000 ? c :
12285: (c & 0xffffe0c0) == 0x0000c080 ? ((c & 0x00001f00) >> 2 |
12286: (c & 0x0000003f)) :
12287: (c & 0xfff0c0c0) == 0x00e08080 ? ((c & 0x000f0000) >> 4 |
12288: (c & 0x00003f00) >> 2 |
12289: (c & 0x0000003f)) :
12290: (c & 0xf8c0c0c0) == 0xf0808080 ? ((c & 0x07000000) >> 6 |
12291: (c & 0x003f0000) >> 4 |
12292: (c & 0x00003f00) >> 2 |
12293: (c & 0x0000003f)) :
12294: 0xfffd);
12295: if (u <= 0x0000ffff) {
12296: sb.append (0xd800 <= u && u <= 0xdfff ? '\ufffd' :
12297: (char) u);
12298: } else if (u <= 0x0010ffff) {
12299: u -= 0x000010000;
12300: sb.append ((char) (0xd800 + ((u >> 10) & 0x3ff))).append ((char) (0xdc00 + (u & 0x3ff)));
12301: }
12302: }
12303: return sb.toString ();
12304: }
12305:
12306:
12307:
12308:
12309:
12310: public static final int[] IsURIChar = {
12311:
12312:
12313: 0b00000000_00000000_00000000_00000000,
12314: 0b00000000_00000110_11111111_11000000,
12315: 0b01111111_11111111_11111111_11100001,
12316: 0b01111111_11111111_11111111_11100010,
12317: };
12318: public static String strEncodeURI (String s) {
12319: s = strEncodeUTF8 (s);
12320: StringBuilder sb = new StringBuilder ();
12321: int l = s.length ();
12322: for (int i = 0; i < l; i++) {
12323: int c = s.charAt (i);
12324: if (c < 0x80 && IsURIChar[c >> 5] << c < 0) {
12325: sb.append ((char) c);
12326: } else {
12327: fmtHex2 (sb.append ('%'), c);
12328: }
12329: }
12330: return sb.toString ();
12331: }
12332:
12333:
12334:
12335:
12336:
12337: public static final byte[] strIsHexChar = {
12338:
12339: -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,
12340: -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,
12341: -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,
12342: -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,
12343: };
12344: public static String strDecodeURI (String s) {
12345: StringBuilder sb = new StringBuilder ();
12346: int l = s.length ();
12347: for (int i = 0; i < l; i++) {
12348: int c = s.charAt (i);
12349: if (c == '%' && i + 2 < l) {
12350: int d = s.charAt (i + 1);
12351: int e = s.charAt (i + 2);
12352: if (d < 0x80 && (d = strIsHexChar[d]) >= 0 &&
12353: e < 0x80 && (e = strIsHexChar[e]) >= 0) {
12354: sb.append ((char) (d << 4 | e));
12355: } else {
12356: sb.append ((char) c);
12357: }
12358: } else {
12359: sb.append ((char) c);
12360: }
12361: }
12362: return sb.toString ();
12363: }
12364:
12365:
12366:
12367:
12368:
12369:
12370:
12371:
12372: public static BufferedImage createImage (int width, int height, String pattern, int... rgbs) {
12373: BufferedImage image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
12374: int[] bitmap = ((DataBufferInt) image.getRaster ().getDataBuffer ()).getData ();
12375: int length = width * height;
12376: for (int i = 0; i < length; i++) {
12377: char c = pattern.charAt (i);
12378: bitmap[i] = rgbs[c < '0' ? 0 : Character.digit (c, 16)];
12379: }
12380: return image;
12381: }
12382:
12383:
12384:
12385: public static ImageIcon createImageIcon (int width, int height, String pattern, int... rgbs) {
12386: return new ImageIcon (createImage (width, height, pattern, rgbs));
12387: }
12388:
12389:
12390:
12391: public static TexturePaint createTexturePaint (int width, int height, String pattern, int... rgbs) {
12392: return new TexturePaint (createImage (width, height, pattern, rgbs), new Rectangle (0, 0, width, height));
12393: }
12394:
12395:
12396:
12397: public static BufferedImage loadImage (String name) {
12398: BufferedImage image = null;
12399: try {
12400: image = ImageIO.read (new File (name));
12401: } catch (Exception e) {
12402: }
12403: return image;
12404: }
12405:
12406:
12407:
12408:
12409: public static boolean saveImage (BufferedImage image, String name) {
12410: return saveImage (image, name, 0.75F);
12411: }
12412: public static boolean saveImage (BufferedImage image, String name, float quality) {
12413: int index = name.lastIndexOf (".");
12414: if (index < 0) {
12415: return false;
12416: }
12417: if (name.substring (index).equalsIgnoreCase (".ico")) {
12418: return saveIcon (name, image);
12419: }
12420: Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix (name.substring (index + 1));
12421: if (!iterator.hasNext ()) {
12422: return false;
12423: }
12424: ImageWriter imageWriter = iterator.next ();
12425: ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam ();
12426: if (imageWriteParam.canWriteCompressed ()) {
12427: imageWriteParam.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);
12428: imageWriteParam.setCompressionQuality (quality);
12429: }
12430: try {
12431: File file = new File (name);
12432: ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream (file);
12433: imageWriter.setOutput (imageOutputStream);
12434: imageWriter.write (null, new IIOImage (image, null, null), imageWriteParam);
12435: imageOutputStream.close ();
12436: } catch (Exception e) {
12437:
12438: return false;
12439: }
12440: return true;
12441: }
12442:
12443:
12444:
12445:
12446:
12447:
12448:
12449:
12450:
12451:
12452:
12453:
12454:
12455:
12456:
12457:
12458:
12459:
12460:
12461:
12462:
12463:
12464:
12465:
12466:
12467:
12468:
12469:
12470:
12471:
12472:
12473:
12474:
12475:
12476:
12477:
12478:
12479:
12480:
12481:
12482:
12483:
12484:
12485:
12486:
12487:
12488:
12489:
12490:
12491:
12492:
12493:
12494:
12495:
12496:
12497:
12498:
12499:
12500:
12501:
12502:
12503:
12504:
12505:
12506:
12507:
12508:
12509:
12510:
12511:
12512:
12513:
12514:
12515: public static boolean saveIcon (String fileName, BufferedImage... arrayImage) {
12516: int iconCount = arrayImage.length;
12517: int[][] arrayPaletTable = new int[iconCount][];
12518: int[] arrayPaletCount = new int[iconCount];
12519: int[] arrayPixelBits = new int[iconCount];
12520: int[] arrayPatternLineSize = new int[iconCount];
12521: int[] arrayMaskLineSize = new int[iconCount];
12522: int[] arrayImageSize = new int[iconCount];
12523: int[] arrayImageOffset = new int[iconCount];
12524: int fileSize = 6 + 16 * iconCount;
12525: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
12526: BufferedImage image = arrayImage[iconNumber];
12527: int width = image.getWidth ();
12528: int height = image.getHeight ();
12529:
12530: int[] paletTable = new int[256];
12531: int paletCount = 0;
12532: countPalet:
12533: for (int y = height - 1; y >= 0; y--) {
12534: for (int x = 0; x < width; x++) {
12535: int rgb = image.getRGB (x, y);
12536: if (rgb >>> 24 != 0xff) {
12537: continue;
12538: }
12539: int l = 0;
12540: int r = paletCount;
12541: while (l < r) {
12542: int m = l + r >> 1;
12543: if (paletTable[m] < rgb) {
12544: l = m + 1;
12545: } else {
12546: r = m;
12547: }
12548: }
12549: if (l == paletCount || paletTable[l] != rgb) {
12550: if (paletCount == 256) {
12551: paletCount = 0;
12552: break countPalet;
12553: }
12554: for (int i = paletCount; i > l; i--) {
12555: paletTable[i] = paletTable[i - 1];
12556: }
12557: paletTable[l] = rgb;
12558: paletCount++;
12559: }
12560: }
12561: }
12562: int pixelBits = (paletCount == 0 ? 24 :
12563: paletCount > 16 ? 8 :
12564: paletCount > 4 ? 4 :
12565: paletCount > 2 ? 2 :
12566: 1);
12567: int patternLineSize = pixelBits * width + 31 >> 5 << 2;
12568: int maskLineSize = width + 31 >> 5 << 2;
12569: int imageSize = 40 + 4 * paletCount + patternLineSize * height + maskLineSize * height;
12570: arrayPaletTable[iconNumber] = paletTable;
12571: arrayPaletCount[iconNumber] = paletCount;
12572: arrayPixelBits[iconNumber] = pixelBits;
12573: arrayPatternLineSize[iconNumber] = patternLineSize;
12574: arrayMaskLineSize[iconNumber] = maskLineSize;
12575: arrayImageSize[iconNumber] = imageSize;
12576: arrayImageOffset[iconNumber] = fileSize;
12577: fileSize += imageSize;
12578: }
12579: byte[] bb = new byte[fileSize];
12580:
12581: ByteArray.byaWiw (bb, 0, 0);
12582: ByteArray.byaWiw (bb, 2, 1);
12583: ByteArray.byaWiw (bb, 4, iconCount);
12584: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
12585: BufferedImage image = arrayImage[iconNumber];
12586: int width = image.getWidth ();
12587: int height = image.getHeight ();
12588: int[] paletTable = arrayPaletTable[iconNumber];
12589: int paletCount = arrayPaletCount[iconNumber];
12590: int pixelBits = arrayPixelBits[iconNumber];
12591: int patternLineSize = arrayPatternLineSize[iconNumber];
12592: int maskLineSize = arrayMaskLineSize[iconNumber];
12593: int imageSize = arrayImageSize[iconNumber];
12594: int imageOffset = arrayImageOffset[iconNumber];
12595:
12596: int o = 6 + 16 * iconNumber;
12597: ByteArray.byaWb (bb, o, width);
12598: ByteArray.byaWb (bb, o + 1, height);
12599: ByteArray.byaWb (bb, o + 2, paletCount);
12600: ByteArray.byaWb (bb, o + 3, 0);
12601: ByteArray.byaWiw (bb, o + 4, 1);
12602: ByteArray.byaWiw (bb, o + 6, pixelBits);
12603: ByteArray.byaWil (bb, o + 8, imageSize);
12604: ByteArray.byaWil (bb, o + 12, imageOffset);
12605:
12606: o = imageOffset;
12607: ByteArray.byaWil (bb, o, 40);
12608: ByteArray.byaWil (bb, o + 4, width);
12609: ByteArray.byaWil (bb, o + 8, height * 2);
12610: ByteArray.byaWiw (bb, o + 12, 1);
12611: ByteArray.byaWiw (bb, o + 14, pixelBits);
12612: ByteArray.byaWil (bb, o + 16, 0);
12613: ByteArray.byaWil (bb, o + 20, 0);
12614: ByteArray.byaWil (bb, o + 24, 0);
12615: ByteArray.byaWil (bb, o + 28, 0);
12616: ByteArray.byaWil (bb, o + 32, paletCount);
12617: ByteArray.byaWil (bb, o + 36, 0);
12618:
12619: o += 40;
12620: for (int i = 0; i < paletCount; i++) {
12621: ByteArray.byaWil (bb, o, paletTable[i] & 0x00ffffff);
12622: o += 4;
12623: }
12624:
12625: for (int y = height - 1; y >= 0; y--) {
12626: for (int x = 0; x < width; x++) {
12627: int rgb = image.getRGB (x, y);
12628: if (rgb >>> 24 != 0xff) {
12629: continue;
12630: }
12631: if (pixelBits == 24) {
12632: bb[o + 3 * x] = (byte) rgb;
12633: bb[o + 3 * x + 1] = (byte) (rgb >> 8);
12634: bb[o + 3 * x + 2] = (byte) (rgb >> 16);
12635: continue;
12636: }
12637: int l = 0;
12638: int r = paletCount;
12639: while (l < r) {
12640: int m = l + r >> 1;
12641: if (paletTable[m] < rgb) {
12642: l = m + 1;
12643: } else {
12644: r = m;
12645: }
12646: }
12647: if (l != 0) {
12648: if (pixelBits == 8) {
12649: bb[o + x] = (byte) l;
12650: } else if (pixelBits == 4) {
12651: bb[o + (x >> 1)] |= (byte) (l << ((~x & 1) << 2));
12652: } else if (pixelBits == 2) {
12653: bb[o + (x >> 2)] |= (byte) (l << ((~x & 3) << 1));
12654: } else {
12655: bb[o + (x >> 3)] |= (byte) (l << (~x & 7));
12656: }
12657: }
12658: }
12659: o += patternLineSize;
12660: }
12661:
12662: for (int y = height - 1; y >= 0; y--) {
12663: for (int x = 0; x < width; x++) {
12664: int rgb = image.getRGB (x, y);
12665: if (rgb >>> 24 != 0xff) {
12666: bb[o + (x >> 3)] |= (byte) (1 << (~x & 7));
12667: }
12668: }
12669: o += maskLineSize;
12670: }
12671: }
12672: return rscPutFile (fileName, bb, 0, fileSize);
12673: }
12674:
12675:
12676:
12677: }
12678:
12679:
12680: