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