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.01.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.1";
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 "** Reset to default values":
2333: if (SpriteScreen.sprSpritesPerRaster != 32) {
2334: SpriteScreen.sprSpritesPerRaster = 32;
2335: sprrasSpinner.setIntValue (SpriteScreen.sprSpritesPerRaster);
2336: }
2337: break;
2338: case "Can write 0 to bit 0 of CRTC R00":
2339: CRTC.crtR00Bit0Zero = ((JCheckBoxMenuItem) source).isSelected ();
2340: break;
2341: }
2342: }
2343: };
2344: JMenu modificationMenu =
2345: Multilingual.mlnText (
2346: ComponentFactory.createMenu (
2347: "Modification",
2348: !CRTC.CRT_EXTENDED_GRAPHIC ? null : Multilingual.mlnText (
2349: ComponentFactory.createCheckBoxMenuItem (CRTC.crtExtendedGraphicRequest, "Extended graphic screen", modificationListener),
2350: "ja", "拡張グラフィック画面"),
2351: Multilingual.mlnText (
2352: ComponentFactory.createCheckBoxMenuItem (CRTC.crtEleventhBitRequest, "1024-dot non-interlaced", modificationListener),
2353: "ja", "1024 ドットノンインターレース"),
2354: Multilingual.mlnText (
2355: ComponentFactory.createCheckBoxMenuItem (CRTC.crtSphericalScrolling, "Spherical scrolling of text screen", modificationListener),
2356: "ja", "テキスト画面の球面スクロール"),
2357: ComponentFactory.createHorizontalSeparator (),
2358: ComponentFactory.createHorizontalBox (
2359: Box.createHorizontalStrut (20),
2360: Multilingual.mlnText (ComponentFactory.createLabel ("Dot clock oscillattor"), "ja", "ドットクロックオシレータ"),
2361: Box.createHorizontalGlue ()
2362: ),
2363: ComponentFactory.createHorizontalBox (
2364: Box.createHorizontalStrut (20),
2365: freqSpinner[0],
2366: ComponentFactory.createLabel (" Hz *"),
2367: Box.createHorizontalGlue ()
2368: ),
2369: ComponentFactory.createHorizontalBox (
2370: Box.createHorizontalStrut (20),
2371: freqSpinner[1],
2372: ComponentFactory.createLabel (" Hz *"),
2373: Box.createHorizontalGlue ()
2374: ),
2375: ComponentFactory.createHorizontalBox (
2376: Box.createHorizontalStrut (20),
2377: freqSpinner[2],
2378: ComponentFactory.createLabel (" Hz *"),
2379: Box.createHorizontalGlue ()
2380: ),
2381: Multilingual.mlnText (
2382: ComponentFactory.createMenuItem ("* Reset to default values", modificationListener),
2383: "ja", "* 初期値に戻す"),
2384: ComponentFactory.createHorizontalSeparator (),
2385: Multilingual.mlnText (
2386: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprDoubleSpritesRequest, "256 sprites", modificationListener),
2387: "ja", "スプライト 256 枚"),
2388: ComponentFactory.createHorizontalSeparator (),
2389: ComponentFactory.createHorizontalBox (
2390: Box.createHorizontalStrut (20),
2391: Multilingual.mlnText (ComponentFactory.createLabel ("Number of sprites per raster"), "ja", "ラスタあたりのスプライトの枚数"),
2392: Box.createHorizontalGlue ()
2393: ),
2394: ComponentFactory.createHorizontalBox (
2395: Box.createHorizontalStrut (20),
2396: sprrasSpinner,
2397: ComponentFactory.createLabel (" **"),
2398: Box.createHorizontalGlue ()
2399: ),
2400: Multilingual.mlnText (
2401: ComponentFactory.createMenuItem ("** Reset to default values", modificationListener),
2402: "ja", "** 初期値に戻す"),
2403: ComponentFactory.createHorizontalSeparator (),
2404: Multilingual.mlnText (
2405: ComponentFactory.createCheckBoxMenuItem (CRTC.crtR00Bit0Zero, "Can write 0 to bit 0 of CRTC R00", modificationListener),
2406: "ja", "CRTC R00 のビット 0 に 0 を書き込める")
2407: ),
2408: "ja", "改造");
2409:
2410:
2411: mnbMenuBar = ComponentFactory.createMenuBar (
2412:
2413:
2414: mnbFileMenu = Multilingual.mlnText (
2415: ComponentFactory.createMenu (
2416: "File", 'F',
2417:
2418: FDC.fdcMenu,
2419:
2420: HDC.hdcMenu,
2421:
2422: SPC.spcMenu,
2423:
2424: HFS.hfsMenu,
2425: ComponentFactory.createHorizontalSeparator (),
2426: mnbQuitMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Quit", 'Q', MNB_MODIFIERS, listener), "ja", "終了")
2427: ),
2428: "ja", "ファイル"),
2429:
2430:
2431: mpuMenu,
2432:
2433:
2434: mnbDisplayMenu = Multilingual.mlnText (
2435: ComponentFactory.createMenu (
2436: "Display", 'D',
2437: mnbFullscreenMenuItem = ComponentFactory.setEnabled (
2438: Multilingual.mlnText (
2439: ComponentFactory.createRadioButtonMenuItem (
2440: fullGroup, pnlFullscreenOn,
2441: "Full screen", KeyEvent.VK_F11, listener), "ja", "全画面表示"),
2442: pnlIsFullscreenSupported),
2443: mnbFitInWindowMenuItem = ComponentFactory.setEnabled (
2444: Multilingual.mlnText (
2445: ComponentFactory.createRadioButtonMenuItem (
2446: fullGroup, !pnlFullscreenOn && pnlFitInWindowOn,
2447: "Fit in window", 'W', MNB_MODIFIERS, listener), "ja", "ウインドウに合わせる"),
2448: pnlIsFitInWindowSupported),
2449: mnbFixedScaleMenuItem = Multilingual.mlnText (
2450: ComponentFactory.createRadioButtonMenuItem (
2451: fullGroup, !pnlFullscreenOn && !pnlFitInWindowOn,
2452: "Fixed scale", 'X', MNB_MODIFIERS, listener), "ja", "固定倍率"),
2453: ComponentFactory.createHorizontalBox (
2454: Box.createHorizontalStrut (20),
2455: pnlFixedSpinner,
2456: ComponentFactory.createLabel ("%"),
2457: Box.createHorizontalGlue ()
2458: ),
2459: ComponentFactory.createMenuItem ("50%", listener),
2460: ComponentFactory.createMenuItem ("75%", listener),
2461: ComponentFactory.createMenuItem ("100%", listener),
2462: ComponentFactory.createMenuItem ("150%", listener),
2463: ComponentFactory.createMenuItem ("200%", listener),
2464:
2465: aspectMenu,
2466:
2467: Multilingual.mlnText (
2468: ComponentFactory.createMenu (
2469: "Interpolation algorithm",
2470: Multilingual.mlnText (
2471: ComponentFactory.createRadioButtonMenuItem (
2472: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
2473: "Nearest neighbor", listener),
2474: "ja", "最近傍補間"),
2475: Multilingual.mlnText (
2476: ComponentFactory.createRadioButtonMenuItem (
2477: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR,
2478: "Bilinear", listener),
2479: "ja", "線形補間"),
2480: Multilingual.mlnText (
2481: ComponentFactory.createRadioButtonMenuItem (
2482: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC,
2483: "Bicubic", listener),
2484: "ja", "三次補間")
2485: ),
2486: "ja", "補間アルゴリズム"),
2487:
2488: scanlineMenu,
2489:
2490: !CRTC.CRT_ENABLE_INTERMITTENT ? null : Multilingual.mlnText (
2491: ComponentFactory.createMenu (
2492: "Intermittent drawing",
2493: Multilingual.mlnText (
2494: ComponentFactory.createRadioButtonMenuItem (
2495: intermittentGroup, CRTC.crtIntermittentInterval == 0, "Draw all changed pictures", listener),
2496: "ja", "変化した画像をすべて描画する"),
2497: Multilingual.mlnText (
2498: ComponentFactory.createRadioButtonMenuItem (
2499: intermittentGroup, CRTC.crtIntermittentInterval == 1, "Draw a changed picture once every two times", listener),
2500: "ja", "変化した画像を 2 回に 1 回描画する"),
2501: Multilingual.mlnText (
2502: ComponentFactory.createRadioButtonMenuItem (
2503: intermittentGroup, CRTC.crtIntermittentInterval == 2, "Draw a changed picture once every three times", listener),
2504: "ja", "変化した画像を 3 回に 1 回描画する"),
2505: Multilingual.mlnText (
2506: ComponentFactory.createRadioButtonMenuItem (
2507: intermittentGroup, CRTC.crtIntermittentInterval == 3, "Draw a changed picture once every four times", listener),
2508: "ja", "変化した画像を 4 回に 1 回描画する"),
2509: Multilingual.mlnText (
2510: ComponentFactory.createRadioButtonMenuItem (
2511: intermittentGroup, CRTC.crtIntermittentInterval == 4, "Draw a changed picture once every five times", listener),
2512: "ja", "変化した画像を 5 回に 1 回描画する")
2513: ),
2514: "ja", "間欠描画"),
2515:
2516: !PNL_STEREOSCOPIC_ON ? null : ComponentFactory.createHorizontalSeparator (),
2517: mnbStereoscopicMenuItem = !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
2518: ComponentFactory.createCheckBoxMenuItem (pnlStereoscopicOn, "Stereoscopic viewing", 'T', listener),
2519: "ja", "立体視"),
2520: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
2521: ComponentFactory.createMenu (
2522: "Stereoscopic settings",
2523: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
2524: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
2525: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING,
2526: "Naked-eye crossing", listener),
2527: "ja", "裸眼交差法"),
2528: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
2529: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
2530: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL,
2531: "Naked-eye parallel", listener),
2532: "ja", "裸眼平行法"),
2533: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
2534: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
2535: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE,
2536: "Side-by-side", listener),
2537: "ja", "サイドバイサイド"),
2538: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
2539: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
2540: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM,
2541: "Top-and-bottom", listener),
2542: "ja", "トップアンドボトム")
2543: ),
2544: "ja", "立体視設定"),
2545:
2546: ComponentFactory.createHorizontalSeparator (),
2547: GIFAnimation.gifStartRecordingMenuItem,
2548: GIFAnimation.gifSettingsMenu,
2549:
2550: ComponentFactory.createHorizontalSeparator (),
2551: modificationMenu,
2552:
2553: SpritePatternViewer.SPV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Sprite pattern viewer", listener), "ja", "スプライトパターンビュア") : null,
2554: ScreenModeTest.SMT_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Screen mode test", listener), "ja", "表示モードテスト") : null
2555: ),
2556: "ja", "画面"),
2557:
2558:
2559: mnbSoundMenu = ComponentFactory.setEnabled (
2560: Multilingual.mlnText (
2561: ComponentFactory.createMenu (
2562: "Sound", 'S',
2563: mnbPlayMenuItem = ComponentFactory.setEnabled (
2564: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (SoundSource.sndPlayOn, "Play", 'P', MNB_MODIFIERS, listener), "ja", "音声出力"),
2565: SoundSource.sndLine != null),
2566:
2567:
2568:
2569: ComponentFactory.createHorizontalBox (
2570: Box.createHorizontalGlue (),
2571: Multilingual.mlnText (ComponentFactory.createLabel ("Volume "), "ja", "音量 "),
2572: mnbVolumeLabel = ComponentFactory.createLabel (String.valueOf (SoundSource.sndVolume)),
2573: Box.createHorizontalGlue ()
2574: ),
2575:
2576:
2577: ComponentFactory.setPreferredSize (
2578: ComponentFactory.createHorizontalSlider (
2579: 0,
2580: SoundSource.SND_VOLUME_MAX,
2581: SoundSource.sndVolume,
2582: SoundSource.SND_VOLUME_STEP,
2583: 1,
2584: new ChangeListener () {
2585: @Override public void stateChanged (ChangeEvent ce) {
2586: SoundSource.sndSetVolume (((JSlider) ce.getSource ()).getValue ());
2587: }
2588: }),
2589: LnF.lnfFontSize * 18, LnF.lnfFontSize * 2 + 28),
2590: Multilingual.mlnText (
2591: ComponentFactory.createMenu (
2592: "Sound interpolation",
2593: Multilingual.mlnText (
2594: ComponentFactory.createRadioButtonMenuItem (
2595: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.THINNING_STEREO,
2596: "Sound thinning", listener),
2597: "ja", "音声 間引き"),
2598: Multilingual.mlnText (
2599: ComponentFactory.createRadioButtonMenuItem (
2600: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_STEREO,
2601: "Sound linear interpolation", listener),
2602: "ja", "音声 線形補間"),
2603: ComponentFactory.setEnabled (
2604: Multilingual.mlnText (
2605: ComponentFactory.createRadioButtonMenuItem (
2606: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000,
2607: "Sound piecewise-constant area interpolation", listener),
2608: "ja", "音声 区分定数面積補間"),
2609: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000),
2610: ComponentFactory.setEnabled (
2611: Multilingual.mlnText (
2612: ComponentFactory.createRadioButtonMenuItem (
2613: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000,
2614: "Sound linear area interpolation", listener),
2615: "ja", "音声 線形面積補間"),
2616: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000)
2617: ),
2618: "ja", "音声補間"),
2619: Multilingual.mlnText (ComponentFactory.createMenuItem ("Sound monitor", listener), "ja", "音声モニタ"),
2620:
2621: ComponentFactory.createHorizontalSeparator (),
2622:
2623: ComponentFactory.setEnabled (
2624: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (OPM.opmOutputMask != 0, "OPM output", listener), "ja", "OPM 出力"),
2625: SoundSource.sndLine != null),
2626: !OPMLog.OLG_ON ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("OPM log", listener), "ja", "OPM ログ"),
2627:
2628: ComponentFactory.createHorizontalSeparator (),
2629:
2630: ComponentFactory.setEnabled (
2631: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ADPCM.pcmOutputOn, "PCM output", listener), "ja", "PCM 出力"),
2632: SoundSource.sndLine != null),
2633: Multilingual.mlnText (
2634: ComponentFactory.createMenu (
2635: "PCM interpolation",
2636: Multilingual.mlnText (
2637: ComponentFactory.createRadioButtonMenuItem (
2638: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_CONSTANT,
2639: "PCM piecewise-constant interpolation", listener),
2640: "ja", "PCM 区分定数補間"),
2641: Multilingual.mlnText (
2642: ComponentFactory.createRadioButtonMenuItem (
2643: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_LINEAR,
2644: "PCM linear interpolation", listener),
2645: "ja", "PCM 線形補間"),
2646: Multilingual.mlnText (
2647: ComponentFactory.createRadioButtonMenuItem (
2648: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_HERMITE,
2649: "PCM hermite interpolation", listener),
2650: "ja", "PCM エルミート補間")
2651: ),
2652: "ja", "PCM 補間"),
2653: Multilingual.mlnText (
2654: ComponentFactory.createMenu (
2655: "PCM source oscillator frequency",
2656: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 0, "PCM 8MHz/4MHz", listener),
2657: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 1, "PCM 8MHz/16MHz", listener)
2658: ),
2659: "ja", "PCM 原発振周波数")
2660: ),
2661: "ja", "音声"),
2662: SoundSource.sndLine != null),
2663:
2664:
2665: mnbInputMenu = Multilingual.mlnText (
2666: ComponentFactory.createMenu (
2667: "Input", 'I',
2668: mnbPasteMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Paste", 'V', MNB_MODIFIERS, listener), "ja", "貼り付け"),
2669: CONDevice.conSettingsMenu,
2670: TextCopy.txcMakeMenuItem (),
2671: TextCopy.txcMakeSettingMenu (),
2672: ComponentFactory.createHorizontalSeparator (),
2673: mnbNoKeyboardMenuItem = Multilingual.mlnText (
2674: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, !Keyboard.kbdOn, "No keyboard", 'K', MNB_MODIFIERS, listener),
2675: "ja", "キーボードなし"),
2676: mnbStandardKeyboardMenuItem = Multilingual.mlnText (
2677: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_STANDARD_TYPE, "Standard keyboard", listener),
2678: "ja", "標準キーボード"),
2679: mnbCompactKeyboardMenuItem = Multilingual.mlnText (
2680: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_COMPACT_TYPE, "Compact keyboard", listener),
2681: "ja", "コンパクトキーボード"),
2682: Multilingual.mlnText (ComponentFactory.createMenuItem ("Key assignments", listener), "ja", "キー割り当て"),
2683: ButtonFunction.bfnMakeMenuItem (),
2684: SRAM.smrRepeatDelayMenu,
2685: SRAM.smrRepeatIntervalMenu,
2686: !Keyboard.KBD_ZKEY_ON ? null : Keyboard.kbdZKeyMenu,
2687: ComponentFactory.createHorizontalSeparator (),
2688: Mouse.musSeamlessMouseCheckBox,
2689: Mouse.musCtrlRightCheckBox,
2690: Mouse.musEdgeAccelerationCheckBox,
2691: Mouse.musMouseCursorSpeedBox,
2692: Mouse.musSpeedSlider,
2693: Mouse.musHostsPixelUnitsCheckBox,
2694: ComponentFactory.createHorizontalSeparator (),
2695: Multilingual.mlnText (ComponentFactory.createMenuItem ("Joystick port settings", listener), "ja", "ジョイスティックポート設定")
2696: ),
2697: "ja", "入力"),
2698:
2699:
2700: mnbConfigMenu = Multilingual.mlnText (
2701: ComponentFactory.createMenu (
2702: "Config", 'G',
2703: Multilingual.mlnText (ComponentFactory.createMenuItem ("RS-232C and terminal", listener), "ja", "RS-232C とターミナル"),
2704: Multilingual.mlnText (
2705: ComponentFactory.createMenu (
2706: "Debug",
2707: Multilingual.mlnText (ComponentFactory.createMenuItem ("Console", listener), "ja", "コンソール"),
2708: Multilingual.mlnText (ComponentFactory.createMenuItem ("Register list", listener), "ja", "レジスタリスト"),
2709: Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble list", listener), "ja", "逆アセンブルリスト"),
2710: Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory dump list", listener), "ja", "メモリダンプリスト"),
2711: Multilingual.mlnText (ComponentFactory.createMenuItem ("Logical space monitor", listener), "ja", "論理空間モニタ"),
2712: Multilingual.mlnText (ComponentFactory.createMenuItem ("Physical space monitor", listener), "ja", "物理空間モニタ"),
2713: ATCMonitor.ACM_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Address translation caches monitor", listener), "ja", "アドレス変換キャッシュモニタ") : null,
2714: BranchLog.BLG_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Branch log", listener), "ja", "分岐ログ") : null,
2715: ProgramFlowVisualizer.PFV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Program flow visualizer", listener), "ja", "プログラムフロービジュアライザ") : null,
2716: RasterBreakPoint.RBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Raster break point", listener), "ja", "ラスタブレークポイント") : null,
2717: DataBreakPoint.DBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Data break point", listener), "ja", "データブレークポイント") : null,
2718: RootPointerList.RTL_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Root pointer list", listener), "ja", "ルートポインタリスト") : null,
2719: ComponentFactory.createHorizontalSeparator (),
2720: SRAM.smrROMDBMenuItem
2721: ),
2722: "ja", "デバッグ"),
2723: SRAM.smrBootMenu,
2724: mainMemoryMenu,
2725: highMemoryMenu,
2726: localMemoryMenu,
2727: xellent30Menu,
2728: ComponentFactory.createHorizontalSeparator (),
2729: ComponentFactory.createMenu (
2730: "RTC",
2731: Multilingual.mlnText (
2732: ComponentFactory.createMenuItem ("Adjust clock to host", listener),
2733: "ja", "時計をホストに合わせる")
2734: ),
2735: SRAM.smrMenu,
2736: Settings.sgsMenu,
2737: ComponentFactory.createHorizontalSeparator (),
2738: Multilingual.mlnText (ComponentFactory.createMenuItem ("Printer", listener), "ja", "プリンタ"),
2739: ROM.romMenu,
2740: Multilingual.mlnText (
2741: ComponentFactory.createMenu (
2742: "Miscellaneous",
2743: SlowdownTest.sdtCheckBoxMenuItem,
2744: SlowdownTest.sdtBox,
2745: Multilingual.mlnText (
2746: ComponentFactory.createCheckBoxMenuItem (Mouse.musOutputButtonStatus, "Mouse button status", listener),
2747: "ja", "マウスのボタンの状態"),
2748: Z8530.SCC_DEBUG_ON ? Z8530.sccDebugMenu : null
2749: ),
2750: "ja", "その他"),
2751: ComponentFactory.createHorizontalSeparator (),
2752: Multilingual.mlnText (
2753: ComponentFactory.createMenuItem ("Java runtime environment information", listener),
2754: "ja", "Java 実行環境の情報"),
2755: Multilingual.mlnText (
2756: ComponentFactory.createMenuItem ("Version information", listener),
2757: "ja", "バージョン情報"),
2758: Multilingual.mlnText (
2759: ComponentFactory.createMenu (
2760: "License",
2761: Multilingual.mlnText (ComponentFactory.createMenuItem ("XEiJ License", listener), "ja", "XEiJ 使用許諾条件"),
2762: Multilingual.mlnText (ComponentFactory.createMenuItem ("FSHARP License", listener), "ja", "FSHARP 許諾条件"),
2763: Multilingual.mlnText (ComponentFactory.createMenuItem ("ymfm License", listener), "ja", "ymfm License"),
2764: Multilingual.mlnText (ComponentFactory.createMenuItem ("jSerialComm License", listener), "ja", "jSerialComm License")
2765: ),
2766: "ja", "使用許諾条件")
2767: ),
2768: "ja", "設定"),
2769:
2770: mnbMakeLanguageMenu (),
2771:
2772:
2773: Box.createHorizontalGlue (),
2774: ComponentFactory.createVerticalBox (
2775: Box.createVerticalGlue (),
2776: Indicator.indBox,
2777: Box.createVerticalGlue ()
2778: ),
2779: Box.createHorizontalGlue ()
2780:
2781: );
2782: }
2783:
2784:
2785:
2786:
2787:
2788:
2789:
2790: public static boolean frmIsActive;
2791:
2792:
2793: public static JFrame frmFrame;
2794: public static int frmMarginWidth;
2795: public static int frmMarginHeight;
2796: public static Dimension frmMinimumSize;
2797:
2798:
2799: public static GraphicsDevice frmScreenDevice;
2800:
2801:
2802: public static DropTarget frmDropTarget;
2803:
2804:
2805:
2806: public static void frmInit () {
2807: frmIsActive = false;
2808: frmScreenDevice = GraphicsEnvironment.getLocalGraphicsEnvironment ().getDefaultScreenDevice ();
2809: pnlIsFullscreenSupported = frmScreenDevice.isFullScreenSupported ();
2810: pnlIsFitInWindowSupported = true;
2811: }
2812:
2813:
2814:
2815: public static void frmMake () {
2816:
2817:
2818: frmFrame = ComponentFactory.createRestorableFrame (
2819: Settings.SGS_FRM_FRAME_KEY,
2820: PRG_TITLE + " version " + PRG_VERSION,
2821: mnbMenuBar,
2822: pnlPanel);
2823: frmUpdateTitle ();
2824: frmFrame.setIconImage (LnF.LNF_ICON_IMAGE_48);
2825: frmFrame.setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);
2826:
2827:
2828:
2829: frmMarginWidth = frmFrame.getWidth () - pnlWidth;
2830: frmMarginHeight = frmFrame.getHeight () - pnlHeight;
2831: frmMinimumSize = new Dimension (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
2832: frmFrame.setMinimumSize (frmMinimumSize);
2833:
2834:
2835:
2836: frmDropTarget = new DropTarget (pnlPanel, DnDConstants.ACTION_COPY, new DropTargetAdapter () {
2837: @Override public void dragOver (DropTargetDragEvent dtde) {
2838: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
2839: dtde.acceptDrag (DnDConstants.ACTION_COPY);
2840: return;
2841: }
2842: dtde.rejectDrag ();
2843: }
2844: @Override public void drop (DropTargetDropEvent dtde) {
2845: try {
2846: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
2847: dtde.acceptDrop (DnDConstants.ACTION_COPY);
2848: boolean reset = false;
2849: int fdu0 = -1;
2850: int fdu = 0;
2851: int hdu0 = -1;
2852: int hdu = 0;
2853: int scu0 = -1;
2854: int scu = 0;
2855: int hfu0 = -1;
2856: int hfu = 0;
2857: for (Object o : (java.util.List) dtde.getTransferable ().getTransferData (DataFlavor.javaFileListFlavor)) {
2858: if (o instanceof File) {
2859: File file = (File) o;
2860: if (file.isFile ()) {
2861: if (FDC.fdcFileFilter.accept (file)) {
2862: if (fdu < FDC.FDC_MAX_UNITS &&
2863: FDC.fdcUnitArray[fdu].insert (file.getPath (), false)) {
2864: if (fdu0 < 0) {
2865: fdu0 = fdu;
2866: }
2867: fdu++;
2868: continue;
2869: }
2870: }
2871: if (HDC.hdcFileFilter.accept (file)) {
2872: if (hdu < 16 &&
2873: HDC.hdcUnitArray[hdu].insert (file.getPath (), false)) {
2874: if (hdu0 < 0) {
2875: hdu0 = hdu;
2876: }
2877: hdu++;
2878: continue;
2879: }
2880: }
2881: if (SPC.spcFileFilter.accept (file)) {
2882: if (scu < 16 &&
2883: SPC.spcUnitArray[scu].insert (file.getPath (), false)) {
2884: if (scu0 < 0) {
2885: scu0 = scu;
2886: }
2887: scu++;
2888: continue;
2889: }
2890: }
2891: }
2892: if (HFS.hfsFileFilter.accept (file)) {
2893: if (hfu < HFS.HFS_MAX_UNITS &&
2894: HFS.hfsUnitArray[hfu].insert (file.getPath (), false)) {
2895: if (hfu0 < 0) {
2896: hfu0 = hfu;
2897: }
2898: hfu++;
2899: continue;
2900: }
2901: }
2902: }
2903: reset = false;
2904: }
2905: dtde.dropComplete (true);
2906: if (reset) {
2907: if (fdu0 >= 0) {
2908: mpuReset (0x9070 | fdu0 << 8, -1);
2909: } else if (hdu0 >= 0) {
2910: mpuReset (0x8000 | hdu0 << 8, -1);
2911: } else if (scu0 >= 0) {
2912: mpuReset (0xa000, SPC.SPC_HANDLE_EX + (scu0 << 2));
2913: } else if (hfu0 >= 0) {
2914: HFS.hfsBootUnit = hfu0;
2915: mpuReset (0xa000, HFS.HFS_BOOT_HANDLE);
2916: }
2917: }
2918: return;
2919: }
2920: } catch (UnsupportedFlavorException ufe) {
2921:
2922: } catch (IOException ioe) {
2923:
2924: }
2925: dtde.rejectDrop();
2926: }
2927: });
2928:
2929: }
2930:
2931:
2932:
2933: public static void frmUpdateTitle () {
2934: frmFrame.setTitle ((currentAccelerator == ACCELERATOR_HYBRID ? "X68000 Hybrid" :
2935: currentModel.getName () +
2936: (currentAccelerator == ACCELERATOR_XELLENT30 ? " with Xellent30" :
2937: currentAccelerator == ACCELERATOR_060TURBO ? " with 060turbo" :
2938: currentAccelerator == ACCELERATOR_060TURBOPRO ? " with 060turboPRO" : "")) +
2939: " - " + PRG_TITLE + " version " + PRG_VERSION);
2940: }
2941:
2942:
2943:
2944: public static void frmStart () {
2945:
2946:
2947:
2948:
2949:
2950:
2951:
2952:
2953: ComponentFactory.addListener (
2954: frmFrame,
2955: new WindowAdapter () {
2956: @Override public void windowActivated (WindowEvent we) {
2957: frmIsActive = true;
2958: }
2959: @Override public void windowClosing (WindowEvent we) {
2960: prgTini ();
2961: }
2962: @Override public void windowDeactivated (WindowEvent we) {
2963: frmIsActive = false;
2964:
2965: }
2966: });
2967:
2968:
2969:
2970:
2971: ComponentFactory.addListener (
2972: frmFrame,
2973: new ComponentAdapter () {
2974: @Override public void componentMoved (ComponentEvent ce) {
2975: Point p = pnlPanel.getLocationOnScreen ();
2976: pnlGlobalX = p.x;
2977: pnlGlobalY = p.y;
2978: }
2979: @Override public void componentResized (ComponentEvent ce) {
2980: Point p = pnlPanel.getLocationOnScreen ();
2981: pnlGlobalX = p.x;
2982: pnlGlobalY = p.y;
2983: }
2984: });
2985:
2986: }
2987:
2988:
2989:
2990:
2991: public static void frmSetFullscreenOn (boolean on) {
2992: pnlFullscreenOn = on;
2993:
2994: if (on) {
2995: if (frmScreenDevice.getFullScreenWindow () != frmFrame) {
2996: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.NONE);
2997: frmScreenDevice.setFullScreenWindow (frmFrame);
2998: }
2999: } else {
3000: if (frmScreenDevice.getFullScreenWindow () == frmFrame) {
3001: frmScreenDevice.setFullScreenWindow (null);
3002: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.FRAME);
3003: }
3004: }
3005:
3006:
3007: }
3008:
3009:
3010:
3011:
3012:
3013:
3014: public static BufferedImage clpClipboardImage;
3015: public static String clpClipboardString;
3016: public static Clipboard clpClipboard;
3017: public static Transferable clpImageContents;
3018: public static Transferable clpStringContents;
3019: public static ClipboardOwner clpClipboardOwner;
3020: public static boolean clpIsClipboardOwner;
3021:
3022:
3023:
3024:
3025: public static void clpMake () {
3026: Toolkit toolkit = Toolkit.getDefaultToolkit ();
3027: clpClipboard = null;
3028: try {
3029: clpClipboard = toolkit.getSystemClipboard ();
3030: } catch (Exception e) {
3031: return;
3032: }
3033: clpClipboardImage = null;
3034: clpClipboardString = null;
3035: clpImageContents = new Transferable () {
3036: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
3037: if (flavor == DataFlavor.imageFlavor) {
3038: return clpClipboardImage;
3039: } else {
3040: throw new UnsupportedFlavorException (flavor);
3041: }
3042: }
3043: public DataFlavor[] getTransferDataFlavors () {
3044: return new DataFlavor[] { DataFlavor.imageFlavor };
3045: }
3046: public boolean isDataFlavorSupported (DataFlavor flavor) {
3047: return flavor == DataFlavor.imageFlavor;
3048: }
3049: };
3050: clpStringContents = new Transferable () {
3051: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
3052: if (flavor == DataFlavor.stringFlavor) {
3053: return clpClipboardString;
3054: } else {
3055: throw new UnsupportedFlavorException (flavor);
3056: }
3057: }
3058: public DataFlavor[] getTransferDataFlavors () {
3059: return new DataFlavor[] { DataFlavor.stringFlavor };
3060: }
3061: public boolean isDataFlavorSupported (DataFlavor flavor) {
3062: return flavor == DataFlavor.stringFlavor;
3063: }
3064: };
3065: clpIsClipboardOwner = false;
3066:
3067:
3068: clpClipboardOwner = new ClipboardOwner () {
3069: @Override public void lostOwnership (Clipboard clipboard, Transferable contents) {
3070: clpIsClipboardOwner = false;
3071: }
3072: };
3073:
3074:
3075: clpClipboard.addFlavorListener (new FlavorListener () {
3076: @Override public void flavorsChanged (FlavorEvent fe) {
3077: boolean available = false;
3078: try {
3079: available = clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor);
3080: } catch (IllegalStateException ise) {
3081: }
3082: if (mnbPasteMenuItem != null) {
3083: mnbPasteMenuItem.setEnabled (available);
3084: }
3085: }
3086: });
3087: if (!clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor)) {
3088: if (mnbPasteMenuItem != null) {
3089: mnbPasteMenuItem.setEnabled (false);
3090: }
3091: }
3092: }
3093:
3094:
3095:
3096: public static void clpCopy (String s) {
3097: if (clpClipboard != null && s != null) {
3098: clpClipboardString = s;
3099: try {
3100: clpClipboard.setContents (clpStringContents, clpClipboardOwner);
3101: clpIsClipboardOwner = true;
3102: } catch (Exception e) {
3103: return;
3104: }
3105: }
3106: }
3107:
3108:
3109:
3110:
3111:
3112:
3113:
3114:
3115:
3116:
3117:
3118:
3119:
3120:
3121:
3122:
3123:
3124:
3125:
3126:
3127:
3128:
3129:
3130: public static int xt3DIPSWRequest;
3131: public static int xt3DIPSW;
3132: public static int xt3PortAddress;
3133:
3134:
3135: public static int xt3MemorySizeRequest;
3136: public static int xt3MemorySize;
3137: public static boolean xt3MemoryEnabled;
3138: public static int xt3MemoryPosition;
3139: public static int xt3MemoryStart;
3140: public static final byte[] xt3MemoryArray = new byte[1 << 20];
3141: public static boolean xt3MemorySave;
3142:
3143:
3144: public static int xt3SavedPC;
3145: public static final int[] xt3SavedRn = new int[16];
3146:
3147:
3148: public static void xt3Init () {
3149:
3150:
3151: xt3DIPSWRequest = Math.max (0, Math.min (3, Settings.sgsGetInt ("xt3dipsw")));
3152: xt3DIPSW = xt3DIPSWRequest;
3153:
3154:
3155: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
3156:
3157:
3158: int memoryKB = Settings.sgsGetInt ("xt3memorykb");
3159: if (!(memoryKB == 1 << 8 || memoryKB == 1 << 10)) {
3160: memoryKB = 1 << 8;
3161: }
3162: xt3MemorySizeRequest = memoryKB << 10;
3163: xt3MemorySize = xt3MemorySizeRequest;
3164:
3165:
3166: xt3MemoryEnabled = false;
3167:
3168:
3169: xt3MemoryPosition = 11 << 20;
3170:
3171:
3172: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
3173:
3174:
3175:
3176: byte[] memoryArray = Settings.sgsGetData ("xt3memorydata");
3177: Arrays.fill (xt3MemoryArray,
3178: (byte) 0);
3179: if (memoryArray.length != 0) {
3180: System.arraycopy (memoryArray, 0,
3181: xt3MemoryArray, 0,
3182: Math.min (memoryArray.length, xt3MemoryArray.length));
3183: if (memoryArray.length < xt3MemoryArray.length) {
3184: Arrays.fill (xt3MemoryArray,
3185: memoryArray.length,
3186: xt3MemoryArray.length,
3187: (byte) 0);
3188: }
3189: }
3190:
3191:
3192: xt3MemorySave = Settings.sgsGetOnOff ("xt3memorysave");
3193:
3194:
3195: xt3SavedPC = 0;
3196:
3197: Arrays.fill (xt3SavedRn, 0);
3198:
3199: xt3Reset ();
3200: }
3201:
3202:
3203: public static void xt3Tini () {
3204:
3205:
3206: Settings.sgsPutInt ("xt3dipsw", xt3DIPSW);
3207:
3208:
3209: Settings.sgsPutInt ("xt3memorykb", xt3MemorySizeRequest >> 10);
3210:
3211:
3212: boolean zero = true;
3213: if (xt3MemorySave) {
3214: for (int i = 0; i < 1 << 20; i++) {
3215: if (xt3MemoryArray[i] != 0) {
3216: zero = false;
3217: break;
3218: }
3219: }
3220: }
3221: Settings.sgsCurrentMap.put ("xt3memorydata",
3222: zero ? "" :
3223: ByteArray.byaEncodeBase64 (ByteArray.byaEncodeGzip (xt3MemoryArray, 0, 1 << 20)));
3224:
3225:
3226: Settings.sgsPutOnOff ("xt3memorysave", xt3MemorySave);
3227:
3228: }
3229:
3230:
3231: public static void xt3Reset () {
3232:
3233:
3234: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
3235:
3236:
3237: xt3MemorySize = xt3MemorySizeRequest;
3238:
3239:
3240: xt3MemoryEnabled = false;
3241:
3242:
3243: xt3MemoryPosition = 11 << 20;
3244:
3245:
3246: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
3247:
3248:
3249: xt3SavedPC = 0;
3250: Arrays.fill (xt3SavedRn, 0);
3251:
3252: }
3253:
3254:
3255: public static int xt3PortRead () {
3256: return (currentIsSecond ? 4 : 0) | (xt3MemoryEnabled ? 2 : 0) | (xt3MemoryPosition == 11 << 20 ? 0 : 1);
3257: }
3258:
3259:
3260: public static void xt3PortWrite (int d) {
3261: boolean nextIsSecond = (d & 4) != 0;
3262: boolean memoryEnabled = (d & 2) != 0;
3263: int memoryPosition = (d & 1) == 0 ? 11 << 20 : 15 << 20;
3264:
3265: if (xt3MemoryEnabled != memoryEnabled ||
3266: xt3MemoryPosition != memoryPosition) {
3267: if (xt3MemoryEnabled) {
3268: if (xt3MemoryPosition == 11 << 20) {
3269: if (MainMemory.mmrMemorySizeCurrent < 12 << 20) {
3270: busSuper (MemoryMappedDevice.MMD_NUL, (12 << 20) - xt3MemorySize, 12 << 20);
3271: } else {
3272: busUser (MemoryMappedDevice.MMD_MMR, (12 << 20) - xt3MemorySize, 12 << 20);
3273: }
3274: } else {
3275: busSuper (MemoryMappedDevice.MMD_ROM, (16 << 20) - xt3MemorySize, 16 << 20);
3276: }
3277: }
3278: xt3MemoryEnabled = memoryEnabled;
3279: xt3MemoryPosition = memoryPosition;
3280: if (xt3MemoryEnabled) {
3281: if (xt3MemoryPosition == 11 << 20) {
3282: busUser (MemoryMappedDevice.MMD_XTM, (12 << 20) - xt3MemorySize, 12 << 20);
3283: } else {
3284: busUser (MemoryMappedDevice.MMD_XTM, (16 << 20) - xt3MemorySize, 16 << 20);
3285: }
3286: }
3287: }
3288:
3289: if (currentIsSecond != nextIsSecond) {
3290:
3291: if (nextIsSecond) {
3292:
3293:
3294: xt3SavedPC = regPC;
3295: System.arraycopy (regRn, 0, xt3SavedRn, 0, 16);
3296:
3297:
3298: if (mpuTask != null) {
3299: mpuClockLimit = 0L;
3300: System.out.println (Multilingual.mlnJapanese ?
3301: Model.MPU_NAMES[currentFirstMPU] + " を停止します" :
3302: Model.MPU_NAMES[currentFirstMPU] + " stops");
3303: mpuTask.cancel ();
3304: mpuTask = null;
3305: }
3306:
3307:
3308: tmrTimer.schedule (new TimerTask () {
3309: @Override public void run () {
3310:
3311:
3312: currentIsSecond = true;
3313: currentMPU = currentSecondMPU;
3314: mpuSetCurrentClock (specifiedSecondClock);
3315:
3316: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
3317: MC68EC030.m30DivZeroVFlag = false;
3318: }
3319:
3320: RegisterList.drpSetMPU ();
3321: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
3322: mpuPCR = 0x04300500 | MPU_060_REV << 8;
3323: MC68060.mmuReset ();
3324:
3325: mpuIgnoreAddressError = true;
3326: fpuBox = fpuMotherboardCoprocessor;
3327: if (currentFPU == 2) {
3328: fpuBox.epbSetMC68882 ();
3329: } else {
3330: fpuBox.epbSetMC68881 ();
3331: }
3332: if (currentTriplePrecision) {
3333: fpuBox.epbSetTriple ();
3334: } else {
3335: fpuBox.epbSetExtended ();
3336: }
3337: fpuBox.epbReset ();
3338: fpuFPn = fpuBox.epbFPn;
3339: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
3340: mpuSetWait ();
3341:
3342: regSRT1 = regSRT0 = 0;
3343: regSRS = REG_SR_S;
3344: regSRM = 0;
3345: regSRI = REG_SR_I;
3346: regCCR = 0;
3347: Arrays.fill (regRn, 0);
3348:
3349: regRn[15] = MainMemory.mmrRls (0x00000000);
3350: regPC = MainMemory.mmrRls (0x00000004);
3351:
3352: mpuIMR = 0;
3353: mpuIRR = 0;
3354: if (MC68901.MFP_DELAYED_INTERRUPT) {
3355: mpuDIRR = 0;
3356: }
3357: mpuISR = 0;
3358:
3359: mpuStart ();
3360: }
3361: }, TMR_DELAY);
3362:
3363: } else {
3364:
3365:
3366: if (mpuTask != null) {
3367: mpuClockLimit = 0L;
3368: System.out.println (Multilingual.mlnJapanese ? "MC68EC030 を停止します" : "MC68EC030 stops");
3369: mpuTask.cancel ();
3370: mpuTask = null;
3371: }
3372:
3373:
3374: tmrTimer.schedule (new TimerTask () {
3375: @Override public void run () {
3376:
3377:
3378: currentIsSecond = false;
3379: currentMPU = currentFirstMPU;
3380: mpuSetCurrentClock (specifiedFirstClock);
3381:
3382: RegisterList.drpSetMPU ();
3383: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
3384: mpuPCR = 0x04300500 | MPU_060_REV << 8;
3385: MC68060.mmuReset ();
3386:
3387: mpuIgnoreAddressError = false;
3388: mpuCacheOn = false;
3389: mpuSetWait ();
3390:
3391: regSRT1 = regSRT0 = 0;
3392: regSRS = REG_SR_S;
3393: regSRM = 0;
3394: regSRI = REG_SR_I;
3395: regCCR = 0;
3396:
3397: regPC = xt3SavedPC;
3398: System.arraycopy (xt3SavedRn, 0, regRn, 0, 16);
3399:
3400: mpuIMR = 0;
3401: mpuIRR = 0;
3402: if (MC68901.MFP_DELAYED_INTERRUPT) {
3403: mpuDIRR = 0;
3404: }
3405: mpuISR = 0;
3406:
3407: mpuStart ();
3408: }
3409: }, TMR_DELAY);
3410:
3411: }
3412: }
3413: }
3414:
3415:
3416:
3417:
3418:
3419:
3420: public static JMenu mdlMenu;
3421:
3422: public static JRadioButtonMenuItem mdlShodaiMenuItem;
3423: public static JRadioButtonMenuItem mdlACEMenuItem;
3424: public static JRadioButtonMenuItem mdlEXPERTMenuItem;
3425: public static JRadioButtonMenuItem mdlPROMenuItem;
3426: public static JRadioButtonMenuItem mdlSUPERMenuItem;
3427: public static JRadioButtonMenuItem mdlXVIMenuItem;
3428: public static JRadioButtonMenuItem mdlXellent30MenuItem;
3429: public static JRadioButtonMenuItem mdlCompactMenuItem;
3430: public static JRadioButtonMenuItem mdlHybridMenuItem;
3431: public static JRadioButtonMenuItem mdl060turboPROMenuItem;
3432: public static JRadioButtonMenuItem mdlX68030MenuItem;
3433: public static JRadioButtonMenuItem mdl030CompactMenuItem;
3434: public static JRadioButtonMenuItem mdl060turboMenuItem;
3435: public static JCheckBoxMenuItem mdlMC68010MenuItem;
3436:
3437: public static JRadioButtonMenuItem fpuMenuItem0;
3438: public static JRadioButtonMenuItem fpuMenuItem1;
3439: public static JRadioButtonMenuItem fpuMenuItem2;
3440: public static JCheckBoxMenuItem fpuMenuItem3;
3441:
3442:
3443: public static final int ACCELERATOR_HYBRID = 1;
3444: public static final int ACCELERATOR_XELLENT30 = 2;
3445: public static final int ACCELERATOR_060TURBO = 3;
3446: public static final int ACCELERATOR_060TURBOPRO = 4;
3447: public static final double MHZ_HYBRID_VALUE = 100.0 / 3.0;
3448: public static final String MHZ_HYBRID_STRING = "33.3";
3449: public static final double MHZ_060TURBO_VALUE = 50.0;
3450: public static final String MHZ_060TURBO_STRING = "50";
3451:
3452:
3453:
3454: public static Model specifiedModel;
3455: public static int specifiedAccelerator;
3456:
3457: public static boolean specifiedIsSecond;
3458: public static int specifiedFirstMPU;
3459: public static int specifiedSecondMPU;
3460: public static int specifiedMPU;
3461:
3462: public static double specifiedFirstClock;
3463: public static double specifiedSecondClock;
3464: public static double specifiedClock;
3465:
3466: public static int specifiedFPU;
3467: public static boolean specifiedTriplePrecision;
3468: public static boolean specifiedFullSpecification;
3469:
3470:
3471:
3472: public static Model currentModel;
3473: public static int currentAccelerator;
3474:
3475: public static boolean currentIsSecond;
3476: public static int currentFirstMPU;
3477: public static int currentSecondMPU;
3478: public static int currentMPU;
3479:
3480:
3481: public static int currentFPU;
3482: public static boolean currentTriplePrecision;
3483: public static boolean currentFullSpecification;
3484:
3485:
3486:
3487: public static void mdlInit () {
3488:
3489:
3490: specifiedModel = Model.COMPACT;
3491: specifiedAccelerator = ACCELERATOR_HYBRID;
3492: {
3493: String paramModel = Settings.sgsGetString ("model");
3494: switch (paramModel.toLowerCase ()) {
3495: case "":
3496: case "none":
3497: case "hybrid":
3498: specifiedModel = Model.COMPACT;
3499: specifiedAccelerator = ACCELERATOR_HYBRID;
3500: break;
3501: case "xellent30":
3502: specifiedModel = Model.XVI;
3503: specifiedAccelerator = ACCELERATOR_XELLENT30;
3504: break;
3505: case "060turbo":
3506: specifiedModel = Model.X68030;
3507: specifiedAccelerator = ACCELERATOR_060TURBO;
3508: break;
3509: case "060turbopro":
3510: specifiedModel = Model.PRO;
3511: specifiedAccelerator = ACCELERATOR_060TURBOPRO;
3512: break;
3513: default:
3514: Model model = Model.fromTypeOrSynonym (paramModel);
3515: if (model != null) {
3516: specifiedModel = model;
3517: specifiedAccelerator = 0;
3518: } else {
3519: System.out.println (Multilingual.mlnJapanese ?
3520: paramModel + " は不明な機種です" :
3521: paramModel + " is unknown model");
3522: specifiedModel = Model.COMPACT;
3523: specifiedAccelerator = ACCELERATOR_HYBRID;
3524: }
3525: }
3526: }
3527:
3528: specifiedIsSecond = false;
3529: specifiedFirstMPU = specifiedModel.getMPU ();
3530: specifiedSecondMPU = Model.MPU_MC68EC030;
3531: {
3532: String[] paramMPUs = Settings.sgsGetString ("mpu").split (",");
3533: for (int i = 0; i < 2; i++) {
3534: int mpu = 0;
3535: String paramMPU = i < paramMPUs.length ? paramMPUs[i] : "";
3536: switch (paramMPU) {
3537: case "":
3538: case "none":
3539: case "-1":
3540: mpu = (i == 0 ?
3541: (specifiedAccelerator == ACCELERATOR_060TURBO ||
3542: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
3543: specifiedModel.getMPU ()) :
3544: Model.MPU_MC68EC030);
3545: break;
3546: case "0":
3547: case "68000":
3548: case "mc68000":
3549: mpu = Model.MPU_MC68000;
3550: break;
3551: case "1":
3552: case "68010":
3553: case "mc68010":
3554: mpu = Model.MPU_MC68010;
3555: break;
3556:
3557:
3558:
3559:
3560:
3561: case "3":
3562: case "68ec030":
3563: case "mc68ec030":
3564: mpu = Model.MPU_MC68EC030;
3565: break;
3566:
3567:
3568:
3569:
3570:
3571:
3572:
3573:
3574:
3575:
3576:
3577:
3578:
3579:
3580:
3581:
3582:
3583: case "6":
3584: case "68060":
3585: case "mc68060":
3586: mpu = Model.MPU_MC68060;
3587: break;
3588: default:
3589: Model model = Model.fromTypeOrSynonym (paramMPU);
3590: if (model != null) {
3591: mpu = model.getMPU ();
3592: } else {
3593: System.out.println (Multilingual.mlnJapanese ?
3594: paramMPU + " は不明な MPU です" :
3595: paramMPU + " is unknown MPU");
3596: mpu = specifiedModel.getMPU ();
3597: }
3598: }
3599: if (i == 0) {
3600: specifiedFirstMPU = mpu;
3601: } else {
3602: specifiedSecondMPU = mpu;
3603: }
3604: }
3605: }
3606: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
3607:
3608: specifiedFirstClock = specifiedModel.getClock ();
3609: specifiedSecondClock = specifiedFirstClock * 2.0;
3610: {
3611: String[] paramClocks = Settings.sgsGetString ("clock").split (",");
3612: for (int i = 0; i < 2; i++) {
3613: double clock = 0.0;
3614: String paramClock = i < paramClocks.length ? paramClocks[i] : "";
3615: switch (paramClock.toLowerCase ()) {
3616: case "":
3617: case "none":
3618: case "-1":
3619: clock = (i == 0 ?
3620: (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
3621: specifiedAccelerator == ACCELERATOR_060TURBO ||
3622: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
3623: specifiedModel.getClock ()) :
3624: specifiedFirstClock * 2.0);
3625: break;
3626: case "hybrid":
3627: clock = MHZ_HYBRID_VALUE;
3628: break;
3629: case "060turbo":
3630: case "060turbopro":
3631: clock = MHZ_060TURBO_VALUE;
3632: break;
3633: case "16.7":
3634: case "xellent30":
3635: clock = 50.0 / 3.0;
3636: break;
3637: case "33.3":
3638: clock = 100.0 / 3.0;
3639: break;
3640: case "66.7":
3641: clock = 200.0 / 3.0;
3642: break;
3643: default:
3644: if (paramClock.matches ("^(?:" +
3645: "[-+]?" +
3646: "(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)" +
3647: "(?:[Ee][-+]?[0-9]+)?" +
3648: ")$")) {
3649: double d = Double.parseDouble (paramClock);
3650: if (1.0 <= d && d <= 1000.0) {
3651: clock = d;
3652: }
3653: } else {
3654: System.out.println (Multilingual.mlnJapanese ?
3655: paramClock + " は不明な動作周波数です" :
3656: paramClock + " is unknown clock frequency");
3657: clock = specifiedModel.getClock ();
3658: }
3659: }
3660: if (i == 0) {
3661: specifiedFirstClock = clock;
3662: } else {
3663: specifiedSecondClock = clock;
3664: }
3665: }
3666: }
3667: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
3668:
3669: specifiedFPU = 0;
3670: specifiedTriplePrecision = false;
3671: specifiedFullSpecification = false;
3672: {
3673: int paramFPUMode = fmtParseInt (Settings.sgsGetString ("fpumode"), 0, 0, 2, 0);
3674: if (paramFPUMode == 0) {
3675: specifiedFPU = 0;
3676: specifiedTriplePrecision = false;
3677: } else if (paramFPUMode == 1) {
3678: specifiedFPU = Model.FPU_MC68882;
3679: specifiedTriplePrecision = false;
3680: } else if (paramFPUMode == 2) {
3681: specifiedFPU = Model.FPU_MC68882;
3682: specifiedTriplePrecision = true;
3683: }
3684: specifiedFullSpecification = Settings.sgsGetOnOff ("fullspecfpu");
3685: }
3686:
3687:
3688:
3689: currentModel = specifiedModel;
3690: currentAccelerator = specifiedAccelerator;
3691:
3692: currentIsSecond = specifiedIsSecond;
3693: currentFirstMPU = specifiedFirstMPU;
3694: currentSecondMPU = specifiedSecondMPU;
3695: currentMPU = specifiedMPU;
3696:
3697:
3698: currentFPU = specifiedFPU;
3699: currentTriplePrecision = specifiedTriplePrecision;
3700: currentFullSpecification = specifiedFullSpecification;
3701:
3702:
3703: mpuUtilOn = Settings.sgsGetOnOff ("util");
3704: mpuUtilRatio = fmtParseInt (Settings.sgsGetString ("ratio"), 0, 1, 100, 100);
3705:
3706: mpuArbFreqMHz = fmtParseInt (Settings.sgsGetString ("mhz"), 0, 1, 1000, 100);
3707: if (mpuUtilOn) {
3708: mpuArbFreqOn = false;
3709: } else {
3710: mpuArbFreqOn = !(specifiedClock == 10.0 ||
3711: specifiedClock == 50.0 / 3.0 ||
3712: specifiedClock == 25.0 ||
3713: specifiedClock == 100.0 / 3.0 ||
3714: specifiedClock == 50.0 ||
3715: specifiedClock == 200.0 / 3.0 ||
3716: specifiedClock == 75.0 ||
3717: specifiedClock == 100.0);
3718: if (mpuArbFreqOn) {
3719: mpuArbFreqMHz = (int) specifiedClock;
3720: }
3721: }
3722:
3723:
3724: mpuROMWaitCycles = 0;
3725: mpuRAMWaitCycles = 0;
3726: mpuCacheOn = false;
3727:
3728: mpuNoWaitTime.ram = 0;
3729: mpuNoWaitTime.gvram = 0;
3730: mpuNoWaitTime.tvram = 0;
3731: mpuNoWaitTime.crtc = 0;
3732: mpuNoWaitTime.palet = 0;
3733: mpuNoWaitTime.vicon = 0;
3734: mpuNoWaitTime.dmac = 0;
3735: mpuNoWaitTime.mfp = 0;
3736: mpuNoWaitTime.rtc = 0;
3737: mpuNoWaitTime.prnport = 0;
3738: mpuNoWaitTime.sysport = 0;
3739: mpuNoWaitTime.opm = 0;
3740: mpuNoWaitTime.adpcm = 0;
3741: mpuNoWaitTime.fdc = 0;
3742: mpuNoWaitTime.fdd = 0;
3743: mpuNoWaitTime.hdc = 0;
3744: mpuNoWaitTime.scc = 0;
3745: mpuNoWaitTime.ppi = 0;
3746: mpuNoWaitTime.ioi = 0;
3747: mpuNoWaitTime.sprc = 0;
3748: mpuNoWaitTime.sram = 0;
3749: mpuNoWaitTime.rom = 0;
3750: mpuNoWaitTime.ramlong = mpuNoWaitTime.ram << 1;
3751: mpuNoWaitTime.romlong = mpuNoWaitTime.rom << 1;
3752:
3753: dmaNoWaitTime.ram = 0;
3754: dmaNoWaitTime.gvram = 0;
3755: dmaNoWaitTime.tvram = 0;
3756: dmaNoWaitTime.crtc = 0;
3757: dmaNoWaitTime.palet = 0;
3758: dmaNoWaitTime.vicon = 0;
3759: dmaNoWaitTime.dmac = 0;
3760: dmaNoWaitTime.mfp = 0;
3761: dmaNoWaitTime.rtc = 0;
3762: dmaNoWaitTime.prnport = 0;
3763: dmaNoWaitTime.sysport = 0;
3764: dmaNoWaitTime.opm = 0;
3765: dmaNoWaitTime.adpcm = 0;
3766: dmaNoWaitTime.fdc = 0;
3767: dmaNoWaitTime.fdd = 0;
3768: dmaNoWaitTime.hdc = 0;
3769: dmaNoWaitTime.scc = 0;
3770: dmaNoWaitTime.ppi = 0;
3771: dmaNoWaitTime.ioi = 0;
3772: dmaNoWaitTime.sprc = 0;
3773: dmaNoWaitTime.sram = 0;
3774: dmaNoWaitTime.rom = 0;
3775: dmaNoWaitTime.ramlong = dmaNoWaitTime.ram << 1;
3776: dmaNoWaitTime.romlong = dmaNoWaitTime.rom << 1;
3777:
3778:
3779: busWaitCyclesRequest = Settings.sgsGetOnOff ("waitcycles");
3780: busWaitCycles = busWaitCyclesRequest;
3781: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
3782:
3783: }
3784:
3785: public static void mdlTini () {
3786:
3787: Settings.sgsPutString ("model",
3788: specifiedAccelerator == ACCELERATOR_HYBRID ? "Hybrid" :
3789: specifiedAccelerator == ACCELERATOR_XELLENT30 ? "Xellent30" :
3790: specifiedAccelerator == ACCELERATOR_060TURBO ? "060turbo" :
3791: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? "060turboPRO" :
3792: specifiedModel.getSynonym () != null ? specifiedModel.getSynonym () :
3793: specifiedModel.getType ());
3794:
3795:
3796: int defaultFirstMPU = (specifiedAccelerator == ACCELERATOR_060TURBO ||
3797: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
3798: specifiedModel.getMPU ());
3799: int defaultSecondMPU = Model.MPU_MC68EC030;
3800: Settings.sgsPutString ("mpu",
3801: (specifiedFirstMPU == defaultFirstMPU ? "" :
3802: Model.mpuNameOf (specifiedFirstMPU)) +
3803: (specifiedSecondMPU == defaultSecondMPU ? "" :
3804: "," + Model.mpuNameOf (specifiedSecondMPU)));
3805:
3806:
3807:
3808:
3809: double defaultFirstClock = (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
3810: specifiedAccelerator == ACCELERATOR_060TURBO ||
3811: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
3812: specifiedModel.getClock ());
3813: double defaultSecondClock = defaultFirstClock * 2.0;
3814: Settings.sgsPutString ("clock",
3815: (specifiedFirstClock == defaultFirstClock ? "" :
3816: specifiedFirstClock == 50.0 / 3.0 ? "16.7" :
3817: specifiedFirstClock == 100.0 / 3.0 ? "33.3" :
3818: specifiedFirstClock == 200.0 / 3.0 ? "66.7" :
3819: String.valueOf ((int) specifiedFirstClock)) +
3820: (specifiedSecondClock == defaultSecondClock ? "" :
3821: "," + (specifiedSecondClock == 50.0 / 3.0 ? "16.7" :
3822: specifiedSecondClock == 100.0 / 3.0 ? "33.3" :
3823: specifiedSecondClock == 200.0 / 3.0 ? "66.7" :
3824: String.valueOf ((int) specifiedSecondClock))));
3825:
3826: Settings.sgsPutInt ("fpumode",
3827: specifiedFPU == 0 ? 0 :
3828: !specifiedTriplePrecision ? 1 :
3829: 2);
3830: Settings.sgsPutOnOff ("fullspecfpu",
3831: specifiedFullSpecification);
3832:
3833: Settings.sgsPutOnOff ("util",
3834: mpuUtilOn);
3835: Settings.sgsPutString ("ratio",
3836: String.valueOf (mpuUtilRatio));
3837:
3838: Settings.sgsPutString ("mhz",
3839: String.valueOf (mpuArbFreqMHz));
3840:
3841: Settings.sgsPutOnOff ("waitcycles", busWaitCyclesRequest);
3842: }
3843:
3844: public static void mdlMakeMenu () {
3845:
3846:
3847: ActionListener listener = new ActionListener () {
3848: @Override public void actionPerformed (ActionEvent ae) {
3849: Object source = ae.getSource ();
3850: switch (ae.getActionCommand ()) {
3851: case "X68000 (10MHz)":
3852: mdlRequestModel (Model.SHODAI, 0);
3853: mpuReset (-1, -1);
3854: break;
3855: case "X68000 ACE (10MHz)":
3856: mdlRequestModel (Model.ACE, 0);
3857: mpuReset (-1, -1);
3858: break;
3859: case "X68000 EXPERT (10MHz)":
3860: mdlRequestModel (Model.EXPERT, 0);
3861: mpuReset (-1, -1);
3862: break;
3863: case "X68000 PRO (10MHz)":
3864: mdlRequestModel (Model.PRO, 0);
3865: mpuReset (-1, -1);
3866: break;
3867: case "X68000 SUPER (10MHz)":
3868: mdlRequestModel (Model.SUPER, 0);
3869: mpuReset (-1, -1);
3870: break;
3871: case "X68000 XVI (16.7MHz)":
3872: mdlRequestModel (Model.XVI, 0);
3873: mpuReset (-1, -1);
3874: break;
3875: case "X68000 Compact (16.7MHz)":
3876: mdlRequestModel (Model.COMPACT, 0);
3877: mpuReset (-1, -1);
3878: break;
3879:
3880: case "X68030 (25MHz)":
3881: mdlRequestModel (Model.X68030, 0);
3882: mpuReset (-1, -1);
3883: break;
3884: case "X68030 Compact (25MHz)":
3885: mdlRequestModel (Model.X68030COMPACT, 0);
3886: mpuReset (-1, -1);
3887: break;
3888:
3889: case "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)":
3890: mdlRequestModel (Model.COMPACT, ACCELERATOR_HYBRID);
3891: mpuReset (-1, -1);
3892: break;
3893: case "Xellent30 (33.3MHz)":
3894: mdlRequestModel (Model.XVI, ACCELERATOR_XELLENT30);
3895: mpuReset (-1, -1);
3896: break;
3897: case "060turbo (" + MHZ_060TURBO_STRING + "MHz)":
3898: mdlRequestModel (Model.X68030, ACCELERATOR_060TURBO);
3899: mpuReset (-1, -1);
3900: break;
3901: case "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)":
3902: mdlRequestModel (Model.PRO, ACCELERATOR_060TURBOPRO);
3903: mpuReset (-1, -1);
3904: break;
3905:
3906: case "MC68010":
3907:
3908: break;
3909:
3910: case "No FPU":
3911: specifiedFPU = 0;
3912: specifiedTriplePrecision = false;
3913: break;
3914: case "Extended precision (19 digit)":
3915: specifiedFPU = Model.FPU_MC68882;
3916: specifiedTriplePrecision = false;
3917: break;
3918: case "Triple precision (24 digit)":
3919: specifiedFPU = Model.FPU_MC68882;
3920: specifiedTriplePrecision = true;
3921: break;
3922: case "Full specification FPU":
3923: specifiedFullSpecification = ((JCheckBoxMenuItem) source).isSelected ();
3924: break;
3925:
3926: }
3927: }
3928: };
3929:
3930:
3931: ButtonGroup modelGroup = new ButtonGroup ();
3932: mdlMenu = Multilingual.mlnText (
3933: ComponentFactory.createMenu (
3934: "Change the model and reset",
3935: mdlShodaiMenuItem = ComponentFactory.createRadioButtonMenuItem (
3936: modelGroup,
3937: specifiedModel == Model.SHODAI,
3938: "X68000 (10MHz)",
3939: listener),
3940: mdlACEMenuItem = ComponentFactory.createRadioButtonMenuItem (
3941: modelGroup,
3942: specifiedModel == Model.ACE,
3943: "X68000 ACE (10MHz)",
3944: listener),
3945: mdlEXPERTMenuItem = ComponentFactory.createRadioButtonMenuItem (
3946: modelGroup,
3947: specifiedModel == Model.EXPERT,
3948: "X68000 EXPERT (10MHz)",
3949: listener),
3950: mdlPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
3951: modelGroup,
3952: specifiedModel == Model.PRO && specifiedAccelerator == 0,
3953: "X68000 PRO (10MHz)",
3954: listener),
3955: mdlSUPERMenuItem = ComponentFactory.createRadioButtonMenuItem (
3956: modelGroup,
3957: specifiedModel == Model.SUPER,
3958: "X68000 SUPER (10MHz)",
3959: listener),
3960: mdlXVIMenuItem = ComponentFactory.createRadioButtonMenuItem (
3961: modelGroup,
3962: specifiedModel == Model.XVI && specifiedAccelerator == 0,
3963: "X68000 XVI (16.7MHz)",
3964: listener),
3965: mdlCompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
3966: modelGroup,
3967: specifiedModel == Model.COMPACT && specifiedAccelerator == 0,
3968: "X68000 Compact (16.7MHz)",
3969: listener),
3970:
3971: ComponentFactory.createHorizontalSeparator (),
3972:
3973: mdlX68030MenuItem = ComponentFactory.createRadioButtonMenuItem (
3974: modelGroup,
3975: specifiedModel == Model.X68030 && specifiedAccelerator == 0,
3976: "X68030 (25MHz)",
3977: listener),
3978: mdl030CompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
3979: modelGroup,
3980: specifiedModel == Model.X68030COMPACT,
3981: "X68030 Compact (25MHz)",
3982: listener),
3983:
3984: ComponentFactory.createHorizontalSeparator (),
3985:
3986: mdlHybridMenuItem = ComponentFactory.createRadioButtonMenuItem (
3987: modelGroup,
3988: specifiedModel == Model.COMPACT && specifiedAccelerator == ACCELERATOR_HYBRID,
3989: "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)",
3990: listener),
3991: mdlXellent30MenuItem = ComponentFactory.createRadioButtonMenuItem (
3992: modelGroup,
3993: specifiedModel == Model.XVI && specifiedAccelerator == ACCELERATOR_XELLENT30,
3994: "Xellent30 (33.3MHz)",
3995: listener),
3996: mdl060turboMenuItem = ComponentFactory.createRadioButtonMenuItem (
3997: modelGroup,
3998: specifiedModel == Model.X68030 && specifiedAccelerator == ACCELERATOR_060TURBO,
3999: "060turbo (" + MHZ_060TURBO_STRING + "MHz)",
4000: listener),
4001: mdl060turboPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
4002: modelGroup,
4003: specifiedModel == Model.PRO && specifiedAccelerator == ACCELERATOR_060TURBOPRO,
4004: "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)",
4005: listener),
4006:
4007: ComponentFactory.createHorizontalSeparator (),
4008:
4009: mdlMC68010MenuItem = ComponentFactory.createCheckBoxMenuItem (
4010: specifiedMPU == Model.MPU_MC68010,
4011: "MC68010",
4012: listener)
4013: ),
4014: "ja", "機種を変更してリセット");
4015:
4016: ButtonGroup fpuGroup = new ButtonGroup ();
4017: fpuMenuItem0 = ComponentFactory.setEnabled (
4018: Multilingual.mlnText (
4019: ComponentFactory.createRadioButtonMenuItem (
4020: fpuGroup,
4021: specifiedFPU == 0,
4022: "No FPU",
4023: listener),
4024: "ja", "FPU なし"),
4025: Model.MPU_MC68020 <= specifiedFirstMPU ||
4026: Model.MPU_MC68020 <= specifiedSecondMPU);
4027: fpuMenuItem1 = ComponentFactory.setEnabled (
4028: Multilingual.mlnText (
4029: ComponentFactory.createRadioButtonMenuItem (
4030: fpuGroup,
4031: specifiedFPU != 0 && !specifiedTriplePrecision,
4032: "Extended precision (19 digit)",
4033: listener),
4034: "ja", "拡張精度 (19 桁)"),
4035: Model.MPU_MC68020 <= specifiedFirstMPU ||
4036: Model.MPU_MC68020 <= specifiedSecondMPU);
4037: fpuMenuItem2 = ComponentFactory.setEnabled (
4038: Multilingual.mlnText (
4039: ComponentFactory.createRadioButtonMenuItem (
4040: fpuGroup,
4041: specifiedFPU != 0 && specifiedTriplePrecision,
4042: "Triple precision (24 digit)",
4043: listener),
4044: "ja", "三倍精度 (24 桁)"),
4045: Model.MPU_MC68020 <= specifiedFirstMPU ||
4046: Model.MPU_MC68020 <= specifiedSecondMPU);
4047: fpuMenuItem3 = ComponentFactory.setEnabled (
4048: Multilingual.mlnText (
4049: ComponentFactory.createCheckBoxMenuItem (
4050: specifiedFullSpecification,
4051: "Full specification FPU",
4052: listener),
4053: "ja", "フルスペック FPU"),
4054: Model.MPU_MC68040 <= specifiedFirstMPU ||
4055: Model.MPU_MC68040 <= specifiedSecondMPU);
4056:
4057: }
4058:
4059: public static void mdlRequestModel (Model model, int accelerator) {
4060: specifiedModel = model;
4061: specifiedAccelerator = accelerator;
4062:
4063: specifiedIsSecond = false;
4064: specifiedFirstMPU = specifiedModel.getMPU ();
4065: specifiedSecondMPU = Model.MPU_MC68EC030;
4066: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
4067: specifiedFirstClock = specifiedModel.getClock ();
4068: specifiedSecondClock = specifiedFirstClock * 2.0;
4069: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4070:
4071: if (specifiedFirstMPU == Model.MPU_MC68000 &&
4072: mdlMC68010MenuItem.isSelected ()) {
4073: specifiedFirstMPU = Model.MPU_MC68010;
4074: }
4075:
4076: switch (accelerator) {
4077: case ACCELERATOR_HYBRID:
4078: specifiedFirstClock = MHZ_HYBRID_VALUE;
4079: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4080: break;
4081: case ACCELERATOR_XELLENT30:
4082: break;
4083: case ACCELERATOR_060TURBO:
4084: case ACCELERATOR_060TURBOPRO:
4085: specifiedFirstMPU = Model.MPU_MC68060;
4086: specifiedFirstClock = MHZ_060TURBO_VALUE;
4087: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
4088: }
4089:
4090: mpuUtilOn = false;
4091: mpuArbFreqOn = false;
4092: mpuSetCurrentClock (specifiedClock);
4093:
4094: if (accelerator == ACCELERATOR_HYBRID) {
4095: mdlHybridMenuItem.setSelected (true);
4096: } else if (accelerator == ACCELERATOR_XELLENT30) {
4097: mdlXellent30MenuItem.setSelected (true);
4098: } else if (accelerator == ACCELERATOR_060TURBO) {
4099: mdl060turboMenuItem.setSelected (true);
4100: } else if (accelerator == ACCELERATOR_060TURBOPRO) {
4101: mdl060turboPROMenuItem.setSelected (true);
4102: } else if (specifiedModel == Model.SHODAI) {
4103: mdlShodaiMenuItem.setSelected (true);
4104: } else if (specifiedModel == Model.ACE) {
4105: mdlACEMenuItem.setSelected (true);
4106: } else if (specifiedModel == Model.EXPERT) {
4107: mdlEXPERTMenuItem.setSelected (true);
4108: } else if (specifiedModel == Model.PRO) {
4109: mdlPROMenuItem.setSelected (true);
4110: } else if (specifiedModel == Model.SUPER) {
4111: mdlSUPERMenuItem.setSelected (true);
4112: } else if (specifiedModel == Model.XVI) {
4113: mdlXVIMenuItem.setSelected (true);
4114: } else if (specifiedModel == Model.COMPACT) {
4115: mdlCompactMenuItem.setSelected (true);
4116: } else if (specifiedModel == Model.X68030) {
4117: mdlX68030MenuItem.setSelected (true);
4118: } else if (specifiedModel == Model.X68030COMPACT) {
4119: mdl030CompactMenuItem.setSelected (true);
4120: }
4121:
4122: fpuMenuItem0.setEnabled (Model.MPU_MC68020 <= specifiedFirstMPU ||
4123: Model.MPU_MC68020 <= specifiedSecondMPU);
4124: fpuMenuItem1.setEnabled (Model.MPU_MC68020 <= specifiedFirstMPU ||
4125: Model.MPU_MC68020 <= specifiedSecondMPU);
4126: fpuMenuItem2.setEnabled (Model.MPU_MC68020 <= specifiedFirstMPU ||
4127: Model.MPU_MC68020 <= specifiedSecondMPU);
4128: fpuMenuItem3.setEnabled (Model.MPU_MC68040 <= specifiedFirstMPU ||
4129: Model.MPU_MC68040 <= specifiedSecondMPU);
4130:
4131: HDC.hdcSASIMenuItem.setSelected (!currentModel.isSCSI ());
4132: SPC.spcSCSIINMenuItem.setSelected (currentModel.isSCSI ());
4133: }
4134:
4135:
4136:
4137:
4138:
4139:
4140:
4141: public static final boolean MPU_INLINE_EXCEPTION = true;
4142: public static final boolean MPU_COMPOUND_POSTINCREMENT = false;
4143:
4144: public static final boolean MPU_SWITCH_MISC_OPCODE = false;
4145: public static final boolean MPU_SWITCH_BCC_CONDITION = false;
4146: public static final boolean MPU_SWITCH_BCC_OFFSET = false;
4147: public static final boolean MPU_SWITCH_SCC_CONDITION = true;
4148:
4149: public static final boolean MPU_OMIT_EXTRA_READ = false;
4150: public static final boolean MPU_OMIT_OFFSET_READ = false;
4151:
4152:
4153:
4154:
4155: public static final long FAR_FUTURE = 0x7fffffffffffffffL;
4156:
4157:
4158:
4159:
4160:
4161:
4162:
4163:
4164: public static final int REG_SR_T1 = 0b10000000_00000000;
4165: public static final int REG_SR_T0 = 0b01000000_00000000;
4166:
4167:
4168:
4169:
4170:
4171:
4172: public static final int REG_SR_S = 0b00100000_00000000;
4173: public static final int REG_SR_M = 0b00010000_00000000;
4174:
4175: public static final int REG_SR_I = 0b00000111_00000000;
4176:
4177:
4178: public static final int REG_CCR_X = 0b00000000_00010000;
4179: public static final int REG_CCR_N = 0b00000000_00001000;
4180: public static final int REG_CCR_Z = 0b00000000_00000100;
4181: public static final int REG_CCR_V = 0b00000000_00000010;
4182: public static final int REG_CCR_C = 0b00000000_00000001;
4183: public static final int REG_CCR_MASK = REG_CCR_X | REG_CCR_N | REG_CCR_Z | REG_CCR_V | REG_CCR_C;
4184:
4185: public static char[] REG_CCRXMAP = "00000000000000001111111111111111".toCharArray ();
4186: public static char[] REG_CCRNMAP = "00000000111111110000000011111111".toCharArray ();
4187: public static char[] REG_CCRZMAP = "00001111000011110000111100001111".toCharArray ();
4188: public static char[] REG_CCRVMAP = "00110011001100110011001100110011".toCharArray ();
4189: public static char[] REG_CCRCMAP = "01010101010101010101010101010101".toCharArray ();
4190:
4191:
4192:
4193: public static final int MPU_IOI_INTERRUPT_LEVEL = 1;
4194: public static final int MPU_EB2_INTERRUPT_LEVEL = 2;
4195: public static final int MPU_DMA_INTERRUPT_LEVEL = 3;
4196: public static final int MPU_SCC_INTERRUPT_LEVEL = 5;
4197: public static final int MPU_MFP_INTERRUPT_LEVEL = 6;
4198: public static final int MPU_SYS_INTERRUPT_LEVEL = 7;
4199: public static final int MPU_IOI_INTERRUPT_MASK = 0x80 >> MPU_IOI_INTERRUPT_LEVEL;
4200: public static final int MPU_EB2_INTERRUPT_MASK = 0x80 >> MPU_EB2_INTERRUPT_LEVEL;
4201: public static final int MPU_DMA_INTERRUPT_MASK = 0x80 >> MPU_DMA_INTERRUPT_LEVEL;
4202: public static final int MPU_SCC_INTERRUPT_MASK = 0x80 >> MPU_SCC_INTERRUPT_LEVEL;
4203: public static final int MPU_MFP_INTERRUPT_MASK = 0x80 >> MPU_MFP_INTERRUPT_LEVEL;
4204: public static final int MPU_SYS_INTERRUPT_MASK = 0x80 >> MPU_SYS_INTERRUPT_LEVEL;
4205:
4206: public static final boolean MPU_INTERRUPT_SWITCH = true;
4207:
4208:
4209: public static final boolean T = true;
4210: public static final boolean F = false;
4211:
4212: public static final int CCCC_T = 0b0000;
4213: public static final int CCCC_F = 0b0001;
4214: public static final int CCCC_HI = 0b0010;
4215: public static final int CCCC_LS = 0b0011;
4216: public static final int CCCC_CC = 0b0100;
4217: public static final int CCCC_CS = 0b0101;
4218: public static final int CCCC_NE = 0b0110;
4219: public static final int CCCC_EQ = 0b0111;
4220: public static final int CCCC_VC = 0b1000;
4221: public static final int CCCC_VS = 0b1001;
4222: public static final int CCCC_PL = 0b1010;
4223: public static final int CCCC_MI = 0b1011;
4224: public static final int CCCC_GE = 0b1100;
4225: public static final int CCCC_LT = 0b1101;
4226: public static final int CCCC_GT = 0b1110;
4227: public static final int CCCC_LE = 0b1111;
4228:
4229:
4230:
4231:
4232:
4233:
4234: public static final boolean[] BCCMAP = {
4235: 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,
4236: 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,
4237: 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,
4238: 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,
4239: 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,
4240: 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,
4241: 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,
4242: 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,
4243: 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,
4244: 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,
4245: 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,
4246: 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,
4247: 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,
4248: 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,
4249: 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,
4250: 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,
4251: };
4252:
4253:
4254: public static final char[] MPU_CCCMAP = (
4255: "11111111111111111111111111111111" +
4256: "00000000000000000000000000000000" +
4257: "10100000101000001010000010100000" +
4258: "01011111010111110101111101011111" +
4259: "10101010101010101010101010101010" +
4260: "01010101010101010101010101010101" +
4261: "11110000111100001111000011110000" +
4262: "00001111000011110000111100001111" +
4263: "11001100110011001100110011001100" +
4264: "00110011001100110011001100110011" +
4265: "11111111000000001111111100000000" +
4266: "00000000111111110000000011111111" +
4267: "11001100001100111100110000110011" +
4268: "00110011110011000011001111001100" +
4269: "11000000001100001100000000110000" +
4270: "00111111110011110011111111001111").toCharArray ();
4271:
4272:
4273:
4274: public static final int MPU_CC_T = 0b11111111111111111111111111111111;
4275: public static final int MPU_CC_F = 0b00000000000000000000000000000000;
4276: public static final int MPU_CC_HI = 0b10100000101000001010000010100000;
4277: public static final int MPU_CC_LS = 0b01011111010111110101111101011111;
4278: public static final int MPU_CC_HS = 0b10101010101010101010101010101010;
4279: public static final int MPU_CC_LO = 0b01010101010101010101010101010101;
4280: public static final int MPU_CC_NE = 0b11110000111100001111000011110000;
4281: public static final int MPU_CC_EQ = 0b00001111000011110000111100001111;
4282: public static final int MPU_CC_VC = 0b11001100110011001100110011001100;
4283: public static final int MPU_CC_VS = 0b00110011001100110011001100110011;
4284: public static final int MPU_CC_PL = 0b11111111000000001111111100000000;
4285: public static final int MPU_CC_MI = 0b00000000111111110000000011111111;
4286: public static final int MPU_CC_GE = 0b11001100001100111100110000110011;
4287: public static final int MPU_CC_LT = 0b00110011110011000011001111001100;
4288: public static final int MPU_CC_GT = 0b11000000001100001100000000110000;
4289: public static final int MPU_CC_LE = 0b00111111110011110011111111001111;
4290:
4291:
4292:
4293:
4294:
4295:
4296:
4297:
4298:
4299:
4300:
4301:
4302:
4303:
4304:
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: 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);
4340:
4341:
4342:
4343: public static final int[] MPU_BITREV_TABLE_0 = new int[2048];
4344: public static final int[] MPU_BITREV_TABLE_1 = new int[2048];
4345: public static final int[] MPU_BITREV_TABLE_2 = new int[2048];
4346: static {
4347: for (int i = 0; i < 2048; i++) {
4348: MPU_BITREV_TABLE_2[i] = (MPU_BITREV_TABLE_1[i] = (MPU_BITREV_TABLE_0[i] = Integer.reverse (i)) >>> 11) >>> 11;
4349: }
4350: }
4351:
4352:
4353:
4354: public static final int EA_DR = 0b000_000;
4355: public static final int EA_AR = 0b001_000;
4356: public static final int EA_MM = 0b010_000;
4357: public static final int EA_MP = 0b011_000;
4358: public static final int EA_MN = 0b100_000;
4359: public static final int EA_MW = 0b101_000;
4360: public static final int EA_MX = 0b110_000;
4361: public static final int EA_ZW = 0b111_000;
4362: public static final int EA_ZL = 0b111_001;
4363: public static final int EA_PW = 0b111_010;
4364: public static final int EA_PX = 0b111_011;
4365: public static final int EA_IM = 0b111_100;
4366: public static final int MMM_DR = EA_DR >> 3;
4367: public static final int MMM_AR = EA_AR >> 3;
4368: public static final int MMM_MM = EA_MM >> 3;
4369: public static final int MMM_MP = EA_MP >> 3;
4370: public static final int MMM_MN = EA_MN >> 3;
4371: public static final int MMM_MW = EA_MW >> 3;
4372: public static final int MMM_MX = EA_MX >> 3;
4373: public static final long EAM_DR = 0xff00000000000000L >>> EA_DR;
4374: public static final long EAM_AR = 0xff00000000000000L >>> EA_AR;
4375: public static final long EAM_MM = 0xff00000000000000L >>> EA_MM;
4376: public static final long EAM_MP = 0xff00000000000000L >>> EA_MP;
4377: public static final long EAM_MN = 0xff00000000000000L >>> EA_MN;
4378: public static final long EAM_MW = 0xff00000000000000L >>> EA_MW;
4379: public static final long EAM_MX = 0xff00000000000000L >>> EA_MX;
4380: public static final long EAM_ZW = 0x8000000000000000L >>> EA_ZW;
4381: public static final long EAM_ZL = 0x8000000000000000L >>> EA_ZL;
4382: public static final long EAM_PW = 0x8000000000000000L >>> EA_PW;
4383: public static final long EAM_PX = 0x8000000000000000L >>> EA_PX;
4384: public static final long EAM_IM = 0x8000000000000000L >>> EA_IM;
4385: 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;
4386: public static final long EAM_ALT = EAM_DR|EAM_AR|EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
4387: 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;
4388: 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 ;
4389: public static final long EAM_DLT = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
4390: public static final long EAM_DCN = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
4391: public static final long EAM_DCL = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
4392: 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;
4393: public static final long EAM_MEM = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
4394: public static final long EAM_MLT = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
4395: public static final long EAM_RDL = EAM_MM|EAM_MP |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
4396: public static final long EAM_WTL = EAM_MM |EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
4397: public static final long EAM_CNT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
4398: public static final long EAM_CLT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
4399:
4400:
4401:
4402:
4403:
4404:
4405:
4406:
4407:
4408:
4409:
4410: public static final int[] regRn = new int[16 + 1];
4411:
4412:
4413: public static int regPC;
4414: public static int regPC0;
4415:
4416:
4417: public static int regOC;
4418:
4419:
4420: public static int regSRT1;
4421: public static int regSRT0;
4422: public static int mpuTraceFlag;
4423: public static int regSRS;
4424: public static int regSRM;
4425: public static int regSRI;
4426:
4427:
4428: public static int regCCR;
4429:
4430:
4431:
4432:
4433:
4434:
4435:
4436:
4437:
4438:
4439:
4440:
4441:
4442:
4443:
4444:
4445:
4446:
4447:
4448:
4449: public static int mpuIMR;
4450:
4451:
4452:
4453:
4454:
4455:
4456: public static int mpuIRR;
4457: public static int mpuDIRR;
4458:
4459:
4460:
4461:
4462:
4463:
4464:
4465:
4466: public static int mpuISR;
4467:
4468:
4469: public static int mpuSFC;
4470: public static int mpuDFC;
4471: public static int mpuCACR;
4472:
4473:
4474:
4475:
4476:
4477: public static int mpuBUSCR;
4478: public static int mpuUSP;
4479: public static int mpuVBR;
4480: public static int mpuCAAR;
4481: public static int mpuMSP;
4482: public static int mpuISP;
4483:
4484:
4485:
4486: public static int mpuPCR;
4487:
4488:
4489:
4490: public static final int MPU_060_REV = 7;
4491:
4492:
4493:
4494: public static long mpuClockTime;
4495: public static long mpuClockLimit;
4496: public static double mpuClockMHz;
4497: public static double mpuCurrentMHz;
4498: public static int mpuCycleCount;
4499: public static long mpuCycleUnit;
4500: public static long mpuModifiedUnit;
4501: public static long dmaCycleUnit;
4502:
4503:
4504:
4505: public static TimerTask mpuTask;
4506:
4507:
4508: public static int mpuBootDevice;
4509: public static int mpuROMBootHandle;
4510: public static int mpuSavedBootDevice;
4511: public static int mpuSavedROMBootHandle;
4512:
4513:
4514: public static boolean mpuIgnoreAddressError;
4515:
4516:
4517: public static int mpuROMWaitCycles;
4518: public static int mpuRAMWaitCycles;
4519: public static boolean mpuCacheOn;
4520: public static final class WaitTime {
4521: public long ram;
4522: public long gvram;
4523: public long tvram;
4524: public long crtc;
4525: public long palet;
4526: public long vicon;
4527: public long dmac;
4528: public long mfp;
4529: public long rtc;
4530: public long prnport;
4531: public long sysport;
4532: public long opm;
4533: public long adpcm;
4534: public long fdc;
4535: public long fdd;
4536: public long hdc;
4537: public long scc;
4538: public long ppi;
4539: public long ioi;
4540: public long sprc;
4541: public long sram;
4542: public long rom;
4543: public long ramlong;
4544: public long romlong;
4545: }
4546: public static final WaitTime mpuNoWaitTime = new WaitTime ();
4547: public static final WaitTime dmaNoWaitTime = new WaitTime ();
4548: public static final WaitTime mpuWaitTime = new WaitTime ();
4549: public static final WaitTime dmaWaitTime = new WaitTime ();
4550: public static boolean busWaitCyclesRequest;
4551: public static boolean busWaitCycles;
4552: public static WaitTime busWaitTime;
4553:
4554:
4555: public static boolean mpuArbFreqOn;
4556: public static int mpuArbFreqMHz;
4557: public static SpinnerNumberModel mpuArbFreqModel;
4558: public static JSpinner mpuArbFreqSpinner;
4559: public static JRadioButtonMenuItem mpuArbFreqRadioButtonMenuItem;
4560:
4561:
4562: public static boolean mpuUtilOn;
4563: public static int mpuUtilRatio;
4564: public static SpinnerNumberModel mpuUtilModel;
4565: public static JSpinner mpuUtilSpinner;
4566: public static JRadioButtonMenuItem mpuUtilRadioButtonMenuItem;
4567:
4568:
4569: public static final int MPU_ADJUSTMENT_INTERVAL = 100;
4570: public static int mpuAdjustmentCounter;
4571: public static long mpuTotalNano;
4572: public static long mpuLastNano;
4573: public static double mpuCoreNano1;
4574: public static double mpuCoreNano2;
4575:
4576:
4577: public static JMenu mpuMenu;
4578: public static JMenuItem mpuResetMenuItem;
4579: public static JMenuItem mpuOpt1ResetMenuItem;
4580: public static JRadioButtonMenuItem mpuClock10MenuItem;
4581: public static JRadioButtonMenuItem mpuClock16MenuItem;
4582: public static JRadioButtonMenuItem mpuClock25MenuItem;
4583: public static JRadioButtonMenuItem mpuClock33MenuItem;
4584: public static JRadioButtonMenuItem mpuClock50MenuItem;
4585: public static JRadioButtonMenuItem mpuClock66MenuItem;
4586: public static JRadioButtonMenuItem mpuClock75MenuItem;
4587: public static JRadioButtonMenuItem mpuClock100MenuItem;
4588:
4589:
4590: public static ActionListener mpuDebugActionListener;
4591: public static ArrayList<AbstractButton> mpuButtonsRunning;
4592: public static ArrayList<AbstractButton> mpuButtonsStopped;
4593: public static ArrayList<JCheckBox> mpuOriIllegalCheckBoxList;
4594: public static ArrayList<JCheckBox> mpuStopOnErrorCheckBoxList;
4595: public static ArrayList<JCheckBox> mpuStopAtStartCheckBoxList;
4596:
4597: public static int mpuAdvanceCount;
4598: public static int mpuStepCount;
4599: public static boolean mpuContinue;
4600: public static int mpuUntilReturnSRS;
4601: public static int mpuUntilReturnRP;
4602: public static int mpuUntilReturnPC0;
4603: public static int mpuUntilReturnSP;
4604:
4605:
4606:
4607:
4608:
4609:
4610:
4611:
4612:
4613:
4614:
4615:
4616:
4617:
4618:
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: public static final boolean MPU_SXMENU = false;
4678:
4679:
4680:
4681: public static void mpuInit () {
4682:
4683: mpuIgnoreAddressError = false;
4684:
4685:
4686:
4687: fpuInit ();
4688:
4689: mpuClockTime = 0L;
4690: mpuClockLimit = 0L;
4691: mpuCycleCount = 0;
4692:
4693: mpuTask = null;
4694:
4695: M68kException.m6eSignal = new M68kException ();
4696: M68kException.m6eNumber = 0;
4697: M68kException.m6eAddress = 0;
4698: M68kException.m6eDirection = MPU_WR_WRITE;
4699: M68kException.m6eSize = MPU_SS_BYTE;
4700:
4701: mpuBootDevice = -1;
4702: mpuROMBootHandle = -1;
4703: mpuSavedBootDevice = -1;
4704: mpuSavedROMBootHandle = -1;
4705:
4706:
4707:
4708:
4709:
4710:
4711:
4712:
4713:
4714:
4715:
4716:
4717:
4718:
4719:
4720: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
4721: mpuTotalNano = 0L;
4722: mpuLastNano = System.nanoTime ();
4723: mpuCoreNano1 = mpuCoreNano2 = 0.5 * 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
4724:
4725: mpuButtonsRunning = new ArrayList<AbstractButton> ();
4726: mpuButtonsStopped = new ArrayList<AbstractButton> ();
4727:
4728: mpuOriIllegalCheckBoxList = new ArrayList<JCheckBox> ();
4729: mpuStopOnErrorCheckBoxList = new ArrayList<JCheckBox> ();
4730: mpuStopAtStartCheckBoxList = new ArrayList<JCheckBox> ();
4731:
4732: mpuAdvanceCount = 0;
4733: mpuStepCount = 0;
4734: mpuContinue = false;
4735: mpuUntilReturnSRS = 0;
4736: mpuUntilReturnRP = 0;
4737: mpuUntilReturnPC0 = 0;
4738: mpuUntilReturnSP = 0;
4739:
4740:
4741: mpuDebugActionListener = new ActionListener () {
4742: @Override public void actionPerformed (ActionEvent ae) {
4743: Object source = ae.getSource ();
4744: switch (ae.getActionCommand ()) {
4745: case "Stop":
4746: if (RootPointerList.RTL_ON) {
4747: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
4748: RootPointerList.rtlCurrentUserTaskIsStoppable) {
4749: mpuStop (null);
4750: }
4751: } else {
4752: mpuStop (null);
4753: }
4754: break;
4755: case "Trace":
4756: mpuAdvance (1);
4757: break;
4758: case "Trace 10 times":
4759: mpuAdvance (10);
4760: break;
4761: case "Trace 100 times":
4762: mpuAdvance (100);
4763: break;
4764: case "Step":
4765: mpuStep (1);
4766: break;
4767: case "Step 10 times":
4768: mpuStep (10);
4769: break;
4770: case "Step 100 times":
4771: mpuStep (100);
4772: break;
4773: case "Step until return":
4774: mpuStepUntilReturn ();
4775: break;
4776: case "Run":
4777: mpuStart ();
4778: break;
4779:
4780: case "Consider ORI.B #$00,D0 as an illegal instruction" :
4781: if (DBG_ORI_BYTE_ZERO_D0) {
4782: dbgOriByteZeroD0 = ((JCheckBox) source).isSelected ();
4783: for (JCheckBox checkBox : mpuOriIllegalCheckBoxList) {
4784: if (checkBox.isSelected () != dbgOriByteZeroD0) {
4785: checkBox.setSelected (dbgOriByteZeroD0);
4786: }
4787: }
4788: }
4789: break;
4790: case "Stop on error":
4791: dbgStopOnError = ((JCheckBox) source).isSelected ();
4792: for (JCheckBox checkBox : mpuStopOnErrorCheckBoxList) {
4793: if (checkBox.isSelected () != dbgStopOnError) {
4794: checkBox.setSelected (dbgStopOnError);
4795: }
4796: }
4797: break;
4798: case "Stop at execution start position":
4799: dbgStopAtStart = ((JCheckBox) source).isSelected ();
4800: for (JCheckBox checkBox : mpuStopAtStartCheckBoxList) {
4801: if (checkBox.isSelected () != dbgStopAtStart) {
4802: checkBox.setSelected (dbgStopAtStart);
4803: }
4804: }
4805: break;
4806: }
4807: }
4808: };
4809:
4810: }
4811:
4812:
4813:
4814: public static JCheckBox mpuMakeOriIllegalCheckBox () {
4815: JCheckBox checkBox = Multilingual.mlnToolTipText (
4816: ComponentFactory.createIconCheckBox (
4817: DBG_ORI_BYTE_ZERO_D0 ? dbgOriByteZeroD0 : null,
4818: LnF.LNF_ORI_BYTE_ZERO_D0_IMAGE,
4819: LnF.LNF_ORI_BYTE_ZERO_D0_SELECTED_IMAGE,
4820: "Consider ORI.B #$00,D0 as an illegal instruction", mpuDebugActionListener),
4821: "ja", "ORI.B #$00,D0 を不当命令とみなす");
4822: mpuOriIllegalCheckBoxList.add (checkBox);
4823: return checkBox;
4824: }
4825:
4826:
4827:
4828: public static JCheckBox mpuMakeStopOnErrorCheckBox () {
4829: JCheckBox checkBox = Multilingual.mlnToolTipText (
4830: ComponentFactory.createIconCheckBox (
4831: dbgStopOnError,
4832: LnF.LNF_STOP_ON_ERROR_IMAGE,
4833: LnF.LNF_STOP_ON_ERROR_SELECTED_IMAGE,
4834: "Stop on error", mpuDebugActionListener),
4835: "ja", "エラーで停止する");
4836: mpuStopOnErrorCheckBoxList.add (checkBox);
4837: return checkBox;
4838: }
4839:
4840:
4841:
4842: public static JCheckBox mpuMakeStopAtStartCheckBox () {
4843: JCheckBox checkBox = Multilingual.mlnToolTipText (
4844: ComponentFactory.createIconCheckBox (
4845: dbgStopAtStart,
4846: LnF.LNF_STOP_AT_START_IMAGE,
4847: LnF.LNF_STOP_AT_START_SELECTED_IMAGE,
4848: "Stop at execution start position", mpuDebugActionListener),
4849: "ja", "実行開始位置で停止する");
4850: mpuStopAtStartCheckBoxList.add (checkBox);
4851: return checkBox;
4852: }
4853:
4854:
4855: public static void mpuMakeMenu () {
4856:
4857: ButtonGroup unitGroup = new ButtonGroup ();
4858: ActionListener listener = new ActionListener () {
4859: @Override public void actionPerformed (ActionEvent ae) {
4860: Object source = ae.getSource ();
4861: switch (ae.getActionCommand ()) {
4862: case "Reset":
4863: mpuReset (-1, -1);
4864: break;
4865: case "Hold down OPT.1 and reset":
4866: mpuReset (0, -1);
4867: break;
4868: case "Interrupt":
4869: sysInterrupt ();
4870: break;
4871: case "10MHz":
4872: mpuArbFreqOn = false;
4873: mpuUtilOn = false;
4874: mpuSetCurrentClock (10.0);
4875: break;
4876: case "16.7MHz":
4877: mpuArbFreqOn = false;
4878: mpuUtilOn = false;
4879: mpuSetCurrentClock (50.0 / 3.0);
4880: break;
4881: case "25MHz":
4882: mpuArbFreqOn = false;
4883: mpuUtilOn = false;
4884: mpuSetCurrentClock (25.0);
4885: break;
4886: case "33.3MHz":
4887: mpuArbFreqOn = false;
4888: mpuUtilOn = false;
4889: mpuSetCurrentClock (100.0 / 3.0);
4890: break;
4891: case "50MHz":
4892: mpuArbFreqOn = false;
4893: mpuUtilOn = false;
4894: mpuSetCurrentClock (50.0);
4895: break;
4896: case "66.7MHz":
4897: mpuArbFreqOn = false;
4898: mpuUtilOn = false;
4899: mpuSetCurrentClock (200.0 / 3.0);
4900: break;
4901: case "75MHz":
4902: mpuArbFreqOn = false;
4903: mpuUtilOn = false;
4904: mpuSetCurrentClock (75.0);
4905: break;
4906: case "100MHz":
4907: mpuArbFreqOn = false;
4908: mpuUtilOn = false;
4909: mpuSetCurrentClock (100.0);
4910: break;
4911: case "Arbitrary frequency":
4912: mpuArbFreqOn = true;
4913: mpuUtilOn = false;
4914: mpuSetCurrentClock ((double) mpuArbFreqMHz);
4915: break;
4916: case "Arbitrary load factor":
4917: mpuArbFreqOn = false;
4918: mpuUtilOn = true;
4919: break;
4920: case "FE function instruction":
4921: FEFunction.fpkOn = ((JCheckBoxMenuItem) source).isSelected ();
4922: break;
4923: case "Reject FLOATn.X":
4924: FEFunction.fpkRejectFloatOn = ((JCheckBoxMenuItem) source).isSelected ();
4925: break;
4926: case "Cut FC2 pin":
4927: busRequestCutFC2Pin = ((JCheckBoxMenuItem) source).isSelected ();
4928: break;
4929: case "Wait cycles":
4930: busWaitCyclesRequest = ((JCheckBoxMenuItem) source).isSelected ();
4931: break;
4932: case "Use IPLROM 1.6":
4933: ROM.romIPLROM16On = ((JCheckBoxMenuItem) source).isSelected ();
4934: break;
4935: case "Increase IPLROM to 256KB":
4936: ROM.romIPLROM256KOn = ((JCheckBoxMenuItem) source).isSelected ();
4937: break;
4938:
4939: case "Run / Stop":
4940: if (((JCheckBox) source).isSelected ()) {
4941: mpuStart ();
4942: } else {
4943: if (RootPointerList.RTL_ON) {
4944: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
4945: RootPointerList.rtlCurrentUserTaskIsStoppable) {
4946: mpuStop (null);
4947: }
4948: } else {
4949: mpuStop (null);
4950: }
4951: }
4952: pnlPanel.requestFocusInWindow ();
4953: break;
4954: }
4955: }
4956: };
4957: mpuMenu = ComponentFactory.createMenu (
4958: "MPU", 'M',
4959: mpuResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset", 'R', MNB_MODIFIERS, listener), "ja", "リセット"),
4960: mpuOpt1ResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Hold down OPT.1 and reset", 'O', MNB_MODIFIERS, listener), "ja", "OPT.1 を押しながらリセット"),
4961: Multilingual.mlnText (ComponentFactory.createMenuItem ("Interrupt", listener), "ja", "インタラプト"),
4962: ComponentFactory.createHorizontalSeparator (),
4963: mdlMenu,
4964: ComponentFactory.createHorizontalSeparator (),
4965: mpuClock10MenuItem = ComponentFactory.createRadioButtonMenuItem (
4966: unitGroup,
4967: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 10.0,
4968: "10MHz",
4969: listener),
4970: mpuClock16MenuItem = ComponentFactory.createRadioButtonMenuItem (
4971: unitGroup,
4972: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0 / 3.0,
4973: "16.7MHz",
4974: listener),
4975: mpuClock25MenuItem = ComponentFactory.createRadioButtonMenuItem (
4976: unitGroup,
4977: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 25.0,
4978: "25MHz",
4979: listener),
4980: mpuClock33MenuItem = ComponentFactory.createRadioButtonMenuItem (
4981: unitGroup,
4982: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0 / 3.0,
4983: "33.3MHz",
4984: listener),
4985: mpuClock50MenuItem = ComponentFactory.createRadioButtonMenuItem (
4986: unitGroup,
4987: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0,
4988: "50MHz",
4989: listener),
4990: mpuClock66MenuItem = ComponentFactory.createRadioButtonMenuItem (
4991: unitGroup,
4992: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 200.0 / 3.0,
4993: "66.7MHz",
4994: listener),
4995: mpuClock75MenuItem = ComponentFactory.createRadioButtonMenuItem (
4996: unitGroup,
4997: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 75.0,
4998: "75MHz",
4999: listener),
5000: mpuClock100MenuItem = ComponentFactory.createRadioButtonMenuItem (
5001: unitGroup,
5002: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0,
5003: "100MHz",
5004: listener),
5005: mpuArbFreqRadioButtonMenuItem = Multilingual.mlnText (
5006: ComponentFactory.createRadioButtonMenuItem (
5007: unitGroup,
5008: mpuArbFreqOn,
5009: "Arbitrary frequency",
5010: listener),
5011: "ja", "任意の周波数"),
5012: ComponentFactory.createHorizontalBox (
5013: Box.createHorizontalStrut (20),
5014: mpuArbFreqSpinner = ComponentFactory.createNumberSpinner (
5015: mpuArbFreqModel = new SpinnerNumberModel (mpuArbFreqMHz, 1, 1000, 1),
5016: 4,
5017: new ChangeListener () {
5018: @Override public void stateChanged (ChangeEvent ce) {
5019:
5020: mpuArbFreqMHz = mpuArbFreqModel.getNumber ().intValue ();
5021: if (mpuArbFreqOn) {
5022: mpuSetCurrentClock ((double) mpuArbFreqMHz);
5023: }
5024: }
5025: }
5026: ),
5027: ComponentFactory.createLabel ("MHz"),
5028: Box.createHorizontalGlue ()
5029: ),
5030: mpuUtilRadioButtonMenuItem = Multilingual.mlnText (
5031: ComponentFactory.createRadioButtonMenuItem (
5032: unitGroup,
5033: mpuUtilOn,
5034: "Arbitrary load factor",
5035: listener),
5036: "ja", "任意の負荷率"),
5037: ComponentFactory.createHorizontalBox (
5038: Box.createHorizontalStrut (20),
5039: mpuUtilSpinner = ComponentFactory.createNumberSpinner (
5040: mpuUtilModel = new SpinnerNumberModel (mpuUtilRatio, 1, 100, 1),
5041: 4,
5042: new ChangeListener () {
5043: @Override public void stateChanged (ChangeEvent ce) {
5044:
5045: mpuUtilRatio = mpuUtilModel.getNumber ().intValue ();
5046: }
5047: }
5048: ),
5049: ComponentFactory.createLabel ("%"),
5050: Box.createHorizontalGlue ()
5051: ),
5052: ComponentFactory.createHorizontalSeparator (),
5053: fpuMenuItem0,
5054: fpuMenuItem1,
5055: fpuMenuItem2,
5056: fpuMenuItem3,
5057: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkOn, "FE function instruction", listener), "ja", "FE ファンクション命令"),
5058: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkRejectFloatOn, "Reject FLOATn.X", listener), "ja", "FLOATn.X を組み込まない"),
5059: ComponentFactory.createHorizontalSeparator (),
5060: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busRequestCutFC2Pin, "Cut FC2 pin", listener), "ja", "FC2 ピンをカットする"),
5061: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busWaitCyclesRequest, "Wait cycles", listener), "ja", "ウェイトサイクル"),
5062: ComponentFactory.createHorizontalSeparator (),
5063: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM16On, "Use IPLROM 1.6", listener), "ja", "IPLROM 1.6 を使う"),
5064: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM256KOn, "Increase IPLROM to 256KB", listener), "ja", "IPLROM を 256KB に増やす")
5065: );
5066: }
5067:
5068:
5069: public static void mpuSetCurrentClock (double clock) {
5070: specifiedClock = clock;
5071: if (currentIsSecond) {
5072: specifiedSecondClock = clock;
5073: } else {
5074: specifiedFirstClock = clock;
5075: }
5076: if (!mpuArbFreqOn && !mpuUtilOn) {
5077: if (specifiedClock == 10.0) {
5078: mpuClock10MenuItem.setSelected (true);
5079: } else if (specifiedClock == 50.0 / 3.0) {
5080: mpuClock16MenuItem.setSelected (true);
5081: } else if (specifiedClock == 25.0) {
5082: mpuClock25MenuItem.setSelected (true);
5083: } else if (specifiedClock == 100.0 / 3.0) {
5084: mpuClock33MenuItem.setSelected (true);
5085: } else if (specifiedClock == 50.0) {
5086: mpuClock50MenuItem.setSelected (true);
5087: } else if (specifiedClock == 200.0 / 3.0) {
5088: mpuClock66MenuItem.setSelected (true);
5089: } else if (specifiedClock == 75.0) {
5090: mpuClock75MenuItem.setSelected (true);
5091: } else if (specifiedClock == 100.0) {
5092: mpuClock100MenuItem.setSelected (true);
5093: }
5094: }
5095: mpuClockMHz = specifiedClock;
5096: mpuSetClockMHz (mpuClockMHz);
5097: }
5098:
5099:
5100:
5101:
5102:
5103:
5104:
5105:
5106:
5107:
5108:
5109: public static void mpuSetClockMHz (double mhz) {
5110: mhz = Math.max (1.0, Math.min (1000.0, mhz));
5111: double lastMHz = mpuCurrentMHz;
5112: mpuCurrentMHz = mhz;
5113: mpuCycleUnit = (long) (((double) TMR_FREQ / 1000000.0) / mhz + 0.5);
5114:
5115: mpuModifiedUnit = (currentMPU == Model.MPU_MC68EC030 ||
5116: currentMPU == Model.MPU_MC68030 ?
5117: (long) (((double) TMR_FREQ * 3.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
5118: currentMPU == Model.MPU_MC68LC040 ||
5119: currentMPU == Model.MPU_MC68040 ?
5120: (long) (((double) TMR_FREQ * 2.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
5121: mpuCycleUnit);
5122: if (lastMHz != mhz) {
5123: mpuSetWait ();
5124: }
5125: }
5126:
5127:
5128:
5129:
5130:
5131:
5132:
5133:
5134:
5135:
5136:
5137:
5138:
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: public static void mpuSetWait () {
5208:
5209: if (currentMPU <= Model.MPU_MC68010) {
5210: mpuWaitTime.ram = mpuCycleUnit >> 3;
5211: mpuWaitTime.vicon = (long) (mpuCycleUnit * 0.6);
5212: mpuWaitTime.crtc =
5213: mpuWaitTime.prnport =
5214: mpuWaitTime.sysport =
5215: mpuWaitTime.sprc =
5216: mpuWaitTime.sram =
5217: mpuWaitTime.rom = mpuCycleUnit;
5218: mpuWaitTime.gvram = (long) (mpuCycleUnit * 1.1);
5219: mpuWaitTime.rtc =
5220: mpuWaitTime.opm =
5221: mpuWaitTime.adpcm =
5222: mpuWaitTime.fdc =
5223: mpuWaitTime.fdd =
5224: mpuWaitTime.hdc =
5225: mpuWaitTime.ppi =
5226: mpuWaitTime.ioi = (long) (mpuCycleUnit * 1.7);
5227: mpuWaitTime.tvram = mpuCycleUnit * 2;
5228: mpuWaitTime.palet = (long) (mpuCycleUnit * 2.6);
5229: mpuWaitTime.mfp = (long) (mpuCycleUnit * 4.3);
5230: mpuWaitTime.scc = mpuCycleUnit * 6;
5231: mpuWaitTime.dmac = mpuCycleUnit * 15;
5232: mpuWaitTime.ramlong = mpuWaitTime.ram << 1;
5233: mpuWaitTime.romlong = mpuWaitTime.rom << 1;
5234: } else if (currentMPU <= Model.MPU_MC68030) {
5235: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
5236: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
5237: mpuWaitTime.sram = mpuCycleUnit * 2;
5238: mpuWaitTime.prnport =
5239: mpuWaitTime.sysport = mpuCycleUnit * 4;
5240: mpuWaitTime.gvram =
5241: mpuWaitTime.crtc =
5242: mpuWaitTime.vicon =
5243: mpuWaitTime.sprc = mpuCycleUnit * 6;
5244: mpuWaitTime.tvram = mpuCycleUnit * 7;
5245: mpuWaitTime.palet = mpuCycleUnit * 11;
5246: mpuWaitTime.opm =
5247: mpuWaitTime.adpcm =
5248: mpuWaitTime.fdc =
5249: mpuWaitTime.fdd =
5250: mpuWaitTime.hdc =
5251: mpuWaitTime.ppi =
5252: mpuWaitTime.ioi = mpuCycleUnit * 15;
5253: mpuWaitTime.mfp = mpuCycleUnit * 19;
5254: mpuWaitTime.rtc = mpuCycleUnit * 28;
5255: mpuWaitTime.dmac = mpuCycleUnit * 34;
5256: mpuWaitTime.scc = mpuCycleUnit * 38;
5257: mpuWaitTime.ramlong = mpuWaitTime.ram;
5258: mpuWaitTime.romlong = mpuWaitTime.rom;
5259: } else {
5260: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
5261: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
5262: mpuWaitTime.sram = mpuCycleUnit * 13;
5263: mpuWaitTime.prnport =
5264: mpuWaitTime.sysport = mpuCycleUnit * 17;
5265: mpuWaitTime.gvram =
5266: mpuWaitTime.crtc =
5267: mpuWaitTime.vicon =
5268: mpuWaitTime.sprc = mpuCycleUnit * 21;
5269: mpuWaitTime.tvram = mpuCycleUnit * 22;
5270: mpuWaitTime.palet = mpuCycleUnit * 33;
5271: mpuWaitTime.opm =
5272: mpuWaitTime.adpcm =
5273: mpuWaitTime.fdc =
5274: mpuWaitTime.fdd =
5275: mpuWaitTime.hdc =
5276: mpuWaitTime.ppi =
5277: mpuWaitTime.ioi = mpuCycleUnit * 37;
5278: mpuWaitTime.mfp = mpuCycleUnit * 47;
5279: mpuWaitTime.dmac = mpuCycleUnit * 73;
5280: mpuWaitTime.rtc = mpuCycleUnit * 77;
5281: mpuWaitTime.scc = mpuCycleUnit * 97;
5282: mpuWaitTime.ramlong = mpuWaitTime.ram;
5283: mpuWaitTime.romlong = mpuWaitTime.rom;
5284: }
5285: if (true) {
5286: mpuNoWaitTime.sram = mpuWaitTime.sram;
5287: mpuNoWaitTime.rom = mpuWaitTime.rom;
5288: mpuNoWaitTime.romlong = mpuWaitTime.romlong;
5289: }
5290:
5291: dmaWaitTime.ram = dmaCycleUnit >> 3;
5292: dmaWaitTime.sram = 0;
5293: dmaWaitTime.rom = 0;
5294: dmaWaitTime.gvram =
5295: dmaWaitTime.crtc =
5296: dmaWaitTime.vicon =
5297: dmaWaitTime.prnport =
5298: dmaWaitTime.sysport =
5299: dmaWaitTime.sprc = dmaCycleUnit;
5300: dmaWaitTime.tvram =
5301: dmaWaitTime.rtc =
5302: dmaWaitTime.opm =
5303: dmaWaitTime.adpcm =
5304: dmaWaitTime.fdc =
5305: dmaWaitTime.fdd =
5306: dmaWaitTime.hdc =
5307: dmaWaitTime.ppi =
5308: dmaWaitTime.ioi = dmaCycleUnit * 2;
5309: dmaWaitTime.palet = dmaCycleUnit * 3;
5310: dmaWaitTime.mfp = dmaCycleUnit * 4;
5311: dmaWaitTime.scc = dmaCycleUnit * 6;
5312: dmaWaitTime.dmac = dmaCycleUnit * 15;
5313: dmaWaitTime.ramlong = dmaWaitTime.ram << 1;
5314: dmaWaitTime.romlong = dmaWaitTime.rom << 1;
5315: }
5316:
5317:
5318:
5319:
5320:
5321: public static void mpuReset (int device, int romHandle) {
5322:
5323: mpuBootDevice = device;
5324: mpuROMBootHandle = romHandle;
5325:
5326:
5327:
5328:
5329:
5330:
5331:
5332:
5333:
5334:
5335:
5336:
5337: if (mpuBootDevice == -1) {
5338: if (mpuSavedBootDevice != -1) {
5339: mpuBootDevice = mpuSavedBootDevice;
5340: mpuROMBootHandle = mpuSavedROMBootHandle;
5341: mpuSavedBootDevice = -1;
5342: mpuSavedROMBootHandle = -1;
5343: }
5344: } else {
5345: if (mpuSavedBootDevice == -1) {
5346: mpuSavedBootDevice = MainMemory.mmrRwz (0x00ed0018);
5347: mpuSavedROMBootHandle = MainMemory.mmrRls (0x00ed000c);
5348: }
5349: }
5350:
5351:
5352: specifiedIsSecond = false;
5353: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
5354: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5355:
5356: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
5357: MC68EC030.m30DivZeroVFlag = false;
5358: }
5359:
5360: if (mpuTask != null) {
5361: mpuClockLimit = 0L;
5362: System.out.println (Multilingual.mlnJapanese ?
5363: "MPU を停止します" :
5364: "MPU stops");
5365: mpuTask.cancel ();
5366: mpuTask = null;
5367: }
5368:
5369: tmrTimer.schedule (new TimerTask () {
5370: @Override public void run () {
5371:
5372:
5373:
5374: currentModel = specifiedModel;
5375: currentAccelerator = specifiedAccelerator;
5376: frmUpdateTitle ();
5377:
5378: currentIsSecond = specifiedIsSecond;
5379: currentFirstMPU = specifiedFirstMPU;
5380: currentSecondMPU = specifiedSecondMPU;
5381: currentMPU = specifiedMPU;
5382:
5383: mpuSetCurrentClock (specifiedClock);
5384:
5385: currentFPU = specifiedFPU;
5386: currentTriplePrecision = specifiedTriplePrecision;
5387: currentFullSpecification = specifiedFullSpecification;
5388:
5389:
5390: if (currentMPU < Model.MPU_MC68020) {
5391: if (busHimem68000) {
5392: busRequestExMemoryStart = 0x10000000;
5393: busRequestExMemorySize = busLocalMemorySize;
5394: busRequestExMemoryArray = busLocalMemoryArray;
5395: } else {
5396: busRequestExMemoryStart = 0x10000000;
5397: busRequestExMemorySize = 0 << 20;
5398: busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
5399: }
5400: } else if (currentMPU < Model.MPU_MC68LC040) {
5401: if (busHighMemory060turboOn) {
5402: busRequestExMemoryStart = 0x10000000;
5403: busRequestExMemorySize = busLocalMemorySize;
5404: busRequestExMemoryArray = busLocalMemoryArray;
5405: } else {
5406: busRequestExMemoryStart = 0x01000000;
5407: busRequestExMemorySize = busHighMemorySize;
5408: busRequestExMemoryArray = busHighMemoryArray;
5409: }
5410: } else {
5411: busRequestExMemoryStart = 0x10000000;
5412: busRequestExMemorySize = busLocalMemorySize;
5413: busRequestExMemoryArray = busLocalMemoryArray;
5414: }
5415: busUpdateMemoryMap ();
5416:
5417:
5418: ROM.romReset ();
5419:
5420: RegisterList.drpSetMPU ();
5421:
5422: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
5423: mpuPCR = 0x04300500 | MPU_060_REV << 8;
5424: MC68060.mmuReset ();
5425:
5426: if (!currentModel.isX68030 ()) {
5427: dmaCycleUnit = TMR_FREQ / 10000000L;
5428: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
5429: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
5430: mpuROMWaitCycles = 1;
5431: mpuRAMWaitCycles = 0;
5432: } else {
5433: dmaCycleUnit = TMR_FREQ / 12500000L;
5434: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
5435: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
5436: mpuROMWaitCycles = 0;
5437: mpuRAMWaitCycles = 0;
5438: }
5439:
5440: busWaitCycles = busWaitCyclesRequest;
5441: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
5442:
5443: HD63450.dmaReadCycles = (currentModel.isPRO () ? 6 :
5444: currentModel.isCompact () ? 4 :
5445: 5);
5446: HD63450.dmaWriteCycles = (currentModel.isPRO () ? 6 :
5447: 5);
5448:
5449: if (currentMPU < Model.MPU_MC68020) {
5450:
5451: mpuIgnoreAddressError = false;
5452:
5453: mpuCacheOn = false;
5454:
5455: } else if (currentMPU < Model.MPU_MC68040) {
5456:
5457: mpuIgnoreAddressError = true;
5458: fpuBox = fpuMotherboardCoprocessor;
5459: if (currentFPU == 2) {
5460: fpuBox.epbSetMC68882 ();
5461: } else {
5462: fpuBox.epbSetMC68881 ();
5463: }
5464: if (currentTriplePrecision) {
5465: fpuBox.epbSetTriple ();
5466: } else {
5467: fpuBox.epbSetExtended ();
5468: }
5469: fpuBox.epbReset ();
5470: fpuFPn = fpuBox.epbFPn;
5471:
5472: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
5473:
5474: } else {
5475:
5476: mpuIgnoreAddressError = true;
5477: fpuBox = fpuOnChipFPU;
5478: if (currentFullSpecification) {
5479: fpuBox.epbSetFullSpec ();
5480:
5481:
5482: } else {
5483: fpuBox.epbSetMC68060 ();
5484: }
5485: if (currentTriplePrecision) {
5486: fpuBox.epbSetTriple ();
5487: } else {
5488: fpuBox.epbSetExtended ();
5489: }
5490: fpuBox.epbReset ();
5491: fpuFPn = fpuBox.epbFPn;
5492:
5493: mpuPCR = 0x04300500 | MPU_060_REV << 8;
5494: mpuCacheOn = (mpuCACR & 0x80008000) != 0;
5495:
5496: }
5497:
5498: mpuSetWait ();
5499:
5500:
5501: regSRT1 = regSRT0 = 0;
5502: regSRS = REG_SR_S;
5503: regSRM = 0;
5504: regSRI = REG_SR_I;
5505: regCCR = 0;
5506: Arrays.fill (regRn, 0);
5507:
5508: regRn[15] = MainMemory.mmrRls (0x00ff0000);
5509: regPC = MainMemory.mmrRls (0x00ff0004);
5510:
5511: MainMemory.mmrReset ();
5512:
5513: busReset ();
5514: if (InstructionBreakPoint.IBP_ON) {
5515: InstructionBreakPoint.ibpOp1MemoryMap = InstructionBreakPoint.ibpOp1SuperMap;
5516: InstructionBreakPoint.ibpReset ();
5517: }
5518: if (BranchLog.BLG_ON) {
5519: BranchLog.blgReset ();
5520: }
5521:
5522: mpuIMR = 0;
5523: mpuIRR = 0;
5524: if (MC68901.MFP_DELAYED_INTERRUPT) {
5525: mpuDIRR = 0;
5526: }
5527: mpuISR = 0;
5528:
5529:
5530: mpuStart ();
5531: }
5532: }, TMR_DELAY);
5533:
5534: }
5535:
5536:
5537:
5538: public static void mpuStopAndStart () {
5539: if (mpuTask == null) {
5540: mpuStart ();
5541: } else {
5542: if (RootPointerList.RTL_ON) {
5543: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
5544: RootPointerList.rtlCurrentUserTaskIsStoppable) {
5545: mpuStop (null);
5546: }
5547: } else {
5548: mpuStop (null);
5549: }
5550: }
5551: }
5552:
5553:
5554:
5555:
5556:
5557: public static void mpuStart () {
5558: if (mpuTask != null) {
5559: mpuClockLimit = 0L;
5560: System.out.println (Multilingual.mlnJapanese ?
5561: "MPU を停止します" :
5562: "MPU stops");
5563: mpuTask.cancel ();
5564: mpuTask = null;
5565: }
5566:
5567: for (AbstractButton button : mpuButtonsStopped) {
5568: button.setEnabled (false);
5569: }
5570: DisassembleList.ddpStoppedBy = null;
5571: System.out.println (Model.mpuNameOf (currentMPU) + (Multilingual.mlnJapanese ? " を起動します" : " starts up"));
5572: mpuTask = new TimerTask () {
5573: @Override public void run () {
5574: mpuContinue = true;
5575: mpuClockLimit = mpuClockTime + TMR_FREQ * TMR_INTERVAL / 1000;
5576: mpuExecuteCore ();
5577: }
5578: };
5579: tmrTimer.scheduleAtFixedRate (mpuTask, TMR_DELAY, TMR_INTERVAL);
5580:
5581: for (AbstractButton button : mpuButtonsRunning) {
5582: button.setEnabled (true);
5583: }
5584: }
5585:
5586:
5587:
5588: public static void mpuExecuteCore () {
5589:
5590: long nanoStart = System.nanoTime ();
5591:
5592: busSuper (RP5C15.rtcFirst, 0x00e8a000, 0x00e8c000);
5593:
5594:
5595: if (currentMPU < Model.MPU_MC68010) {
5596: MC68000.mpuCore ();
5597: } else if (currentMPU < Model.MPU_MC68020) {
5598: MC68010.mpuCore ();
5599: } else if (currentMPU < Model.MPU_MC68LC040) {
5600: MC68EC030.mpuCore ();
5601: } else {
5602: MC68060.mpuCore ();
5603: }
5604:
5605: if (dbgVisibleMask != 0) {
5606: dbgUpdate ();
5607: }
5608:
5609: long nanoEnd = System.nanoTime ();
5610: mpuTotalNano += nanoEnd - nanoStart;
5611: if (--mpuAdjustmentCounter == 0) {
5612:
5613: final double expectedNano = 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
5614:
5615: double coreNano0 = (double) mpuTotalNano;
5616: mpuTotalNano = 0L;
5617: double coreNanoA = (coreNano0 * 2.0 + mpuCoreNano1 + mpuCoreNano2) * 0.25;
5618: mpuCoreNano2 = mpuCoreNano1;
5619: mpuCoreNano1 = coreNano0;
5620:
5621:
5622:
5623: double actualPercent = Math.max (1.0, 100.0 * coreNanoA / expectedNano);
5624:
5625: double maxPercent = SoundSource.sndPlayOn ? 90.0 : 100.0;
5626:
5627:
5628:
5629:
5630: if (mpuUtilOn) {
5631:
5632: double targetPercent = Math.min (maxPercent, (double) mpuUtilRatio);
5633: mpuSetClockMHz ((1.2 - 0.2 * actualPercent / targetPercent) * mpuCurrentMHz);
5634: } else {
5635: mpuSetClockMHz (Math.min (maxPercent / actualPercent,
5636: 1.2 - 0.2 * mpuCurrentMHz / mpuClockMHz) * mpuCurrentMHz);
5637: }
5638: Indicator.indUpdate (actualPercent);
5639: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
5640: }
5641: }
5642:
5643:
5644:
5645:
5646: public static void mpuStop (String message) {
5647:
5648: mpuAdvanceCount = 0;
5649: mpuStepCount = 0;
5650: mpuContinue = false;
5651: mpuStop1 (message);
5652: }
5653: public static void mpuStop1 (String message) {
5654: if (mpuTask == null) {
5655: return;
5656: }
5657: DisassembleList.ddpStoppedBy = message;
5658: mpuClockLimit = 0L;
5659: System.out.println (Multilingual.mlnJapanese ?
5660: "MPU を停止します" :
5661: "MPU stops");
5662: mpuTask.cancel ();
5663: mpuTask = null;
5664:
5665: if (mpuStepCount != 0 && mpuContinue) {
5666: if (mpuStepCount == -1 || --mpuStepCount != 0) {
5667: mpuStep (mpuStepCount);
5668: return;
5669: }
5670: }
5671: mpuAdvanceCount = 0;
5672: mpuStepCount = 0;
5673: mpuContinue = false;
5674:
5675: for (AbstractButton button : mpuButtonsRunning) {
5676: button.setEnabled (false);
5677: }
5678: tmrTimer.schedule (new TimerTask () {
5679: @Override public void run () {
5680: mpuUpdateWindow ();
5681: }
5682: }, TMR_DELAY);
5683: }
5684:
5685:
5686:
5687:
5688:
5689:
5690: public static void mpuAdvance (int n) {
5691: if (mpuTask != null) {
5692: return;
5693: }
5694: mpuAdvanceCount = n;
5695: DisassembleList.ddpStoppedBy = null;
5696: mpuTask = new TimerTask () {
5697: @Override public void run () {
5698: mpuContinue = true;
5699: do {
5700: mpuClockLimit = mpuClockTime + 1L;
5701: mpuExecuteCore ();
5702: } while (mpuContinue && --mpuAdvanceCount != 0);
5703: mpuClockLimit = 0L;
5704: if (mpuTask != null) {
5705: mpuTask.cancel ();
5706: mpuTask = null;
5707: }
5708: if (mpuStepCount != 0 && mpuContinue) {
5709: if (mpuStepCount == -1 || --mpuStepCount != 0) {
5710: mpuStep (mpuStepCount);
5711: return;
5712: }
5713: }
5714: mpuAdvanceCount = 0;
5715: mpuStepCount = 0;
5716: mpuContinue = false;
5717: mpuUpdateWindow ();
5718: }
5719: };
5720: tmrTimer.schedule (mpuTask, TMR_DELAY);
5721: }
5722:
5723:
5724:
5725:
5726:
5727:
5728: public static void mpuStep (int n) {
5729: if (mpuTask != null) {
5730: return;
5731: }
5732: mpuStepCount = n;
5733: Disassembler.disDisassemble (new StringBuilder (), regPC, regSRS);
5734: if ((Disassembler.disStatus & (Disassembler.DIS_ALWAYS_BRANCH | Disassembler.DIS_SOMETIMES_BRANCH)) != 0) {
5735: if (mpuStepCount == -1 &&
5736: (Disassembler.disOC == 0x4e73 ||
5737: Disassembler.disOC == 0x4e74 ||
5738: Disassembler.disOC == 0x4e75 ||
5739: Disassembler.disOC == 0x4e77) &&
5740: mpuUntilReturnSRS == regSRS &&
5741: (currentMPU < Model.MPU_MC68LC040 ||
5742: mpuUntilReturnRP == (regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP)) &&
5743: mpuUntilReturnPC0 != regPC0 &&
5744: Integer.compareUnsigned (mpuUntilReturnSP, regRn[15]) <= 0) {
5745: mpuAdvanceCount = 0;
5746: mpuStepCount = 0;
5747: mpuContinue = false;
5748: mpuUpdateWindow ();
5749: return;
5750: }
5751: mpuAdvance (1);
5752: } else {
5753: if (InstructionBreakPoint.IBP_ON) {
5754: InstructionBreakPoint.ibpInstant (Disassembler.disPC, DisassembleList.ddpSupervisorMode);
5755: mpuStart ();
5756: }
5757: }
5758: }
5759:
5760:
5761:
5762:
5763:
5764:
5765:
5766:
5767:
5768:
5769:
5770: public static void mpuStepUntilReturn () {
5771: if (mpuTask != null) {
5772: return;
5773: }
5774: mpuUntilReturnSRS = regSRS;
5775: mpuUntilReturnRP = regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP;
5776: mpuUntilReturnPC0 = regPC0;
5777: mpuUntilReturnSP = regRn[15];
5778: mpuStep (-1);
5779: }
5780:
5781:
5782:
5783: public static void mpuUpdateWindow () {
5784: if (dbgVisibleMask != 0) {
5785: if ((dbgVisibleMask & DBG_DDP_VISIBLE_MASK) != 0) {
5786: DisassembleList.ddpBacktraceRecord = -1L;
5787: DisassembleList.ddpUpdate (-1, -1, false);
5788: }
5789: if (BranchLog.BLG_ON) {
5790: if ((dbgVisibleMask & DBG_BLG_VISIBLE_MASK) != 0) {
5791: BranchLog.blgUpdate (BranchLog.BLG_SELECT_NEWEST);
5792: }
5793: }
5794: if (ProgramFlowVisualizer.PFV_ON) {
5795: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
5796: ProgramFlowVisualizer.pfvUpdate ();
5797: }
5798: }
5799: if (RasterBreakPoint.RBP_ON) {
5800: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
5801: RasterBreakPoint.rbpUpdateFrame ();
5802: }
5803: }
5804: if (ScreenModeTest.SMT_ON) {
5805: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
5806: ScreenModeTest.smtUpdateFrame ();
5807: }
5808: }
5809: if (RootPointerList.RTL_ON) {
5810: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
5811: RootPointerList.rtlUpdateFrame ();
5812: }
5813: }
5814: if (SpritePatternViewer.SPV_ON) {
5815: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
5816: SpritePatternViewer.spvUpdateFrame ();
5817: }
5818: }
5819: if (ATCMonitor.ACM_ON) {
5820: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
5821: ATCMonitor.acmUpdateFrame ();
5822: }
5823: }
5824: }
5825:
5826: if (DebugConsole.dgtRequestRegs != 0) {
5827: if ((DebugConsole.dgtRequestRegs & 1) != 0) {
5828: ExpressionEvaluator.ElementType.ETY_COMMAND_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
5829: }
5830: if ((DebugConsole.dgtRequestRegs & 2) != 0) {
5831: ExpressionEvaluator.ElementType.ETY_COMMAND_FLOAT_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
5832: }
5833: if ((DebugConsole.dgtRequestRegs & 4) != 0) {
5834: DebugConsole.dgtPrintPrompt ();
5835: }
5836: DebugConsole.dgtRequestRegs = 0;
5837: }
5838:
5839: for (AbstractButton button : mpuButtonsRunning) {
5840: button.setEnabled (false);
5841: }
5842:
5843: for (AbstractButton button : mpuButtonsStopped) {
5844: button.setEnabled (true);
5845: }
5846: }
5847:
5848:
5849:
5850: public static JButton mpuMakeBreakButton () {
5851: return mpuAddButtonRunning (
5852: Multilingual.mlnToolTipText (
5853: ComponentFactory.createImageButton (
5854: LnF.LNF_BREAK_IMAGE,
5855: LnF.LNF_BREAK_DISABLED_IMAGE,
5856: "Stop", mpuDebugActionListener),
5857: "ja", "停止")
5858: );
5859: }
5860:
5861:
5862:
5863: public static JButton mpuMakeTraceButton () {
5864: return mpuAddButtonStopped (
5865: Multilingual.mlnToolTipText (
5866: ComponentFactory.createImageButton (
5867: LnF.LNF_TRACE_IMAGE,
5868: LnF.LNF_TRACE_DISABLED_IMAGE,
5869: "Trace", mpuDebugActionListener),
5870: "ja", "トレース")
5871: );
5872: }
5873:
5874:
5875:
5876: public static JButton mpuMakeTrace10Button () {
5877: return mpuAddButtonStopped (
5878: Multilingual.mlnToolTipText (
5879: ComponentFactory.createImageButton (
5880: LnF.LNF_TRACE_10_IMAGE,
5881: LnF.LNF_TRACE_10_DISABLED_IMAGE,
5882: "Trace 10 times", mpuDebugActionListener),
5883: "ja", "トレース 10 回")
5884: );
5885: }
5886:
5887:
5888:
5889: public static JButton mpuMakeTrace100Button () {
5890: return mpuAddButtonStopped (
5891: Multilingual.mlnToolTipText (
5892: ComponentFactory.createImageButton (
5893: LnF.LNF_TRACE_100_IMAGE,
5894: LnF.LNF_TRACE_100_DISABLED_IMAGE,
5895: "Trace 100 times", mpuDebugActionListener),
5896: "ja", "トレース 100 回")
5897: );
5898: }
5899:
5900:
5901:
5902: public static JButton mpuMakeStepButton () {
5903: return mpuAddButtonStopped (
5904: Multilingual.mlnToolTipText (
5905: ComponentFactory.createImageButton (
5906: LnF.LNF_STEP_IMAGE,
5907: LnF.LNF_STEP_DISABLED_IMAGE,
5908: "Step", mpuDebugActionListener),
5909: "ja", "ステップ")
5910: );
5911: }
5912:
5913:
5914:
5915: public static JButton mpuMakeStep10Button () {
5916: return mpuAddButtonStopped (
5917: Multilingual.mlnToolTipText (
5918: ComponentFactory.createImageButton (
5919: LnF.LNF_STEP_10_IMAGE,
5920: LnF.LNF_STEP_10_DISABLED_IMAGE,
5921: "Step 10 times", mpuDebugActionListener),
5922: "ja", "ステップ 10 回")
5923: );
5924: }
5925:
5926:
5927:
5928: public static JButton mpuMakeStep100Button () {
5929: return mpuAddButtonStopped (
5930: Multilingual.mlnToolTipText (
5931: ComponentFactory.createImageButton (
5932: LnF.LNF_STEP_100_IMAGE,
5933: LnF.LNF_STEP_100_DISABLED_IMAGE,
5934: "Step 100 times", mpuDebugActionListener),
5935: "ja", "ステップ 100 回")
5936: );
5937: }
5938:
5939:
5940:
5941: public static JButton mpuMakeReturnButton () {
5942: return mpuAddButtonStopped (
5943: Multilingual.mlnToolTipText (
5944: ComponentFactory.createImageButton (
5945: LnF.LNF_STEP_UNTIL_RETURN_IMAGE,
5946: LnF.LNF_STEP_UNTIL_RETURN_DISABLED_IMAGE,
5947: "Step until return", mpuDebugActionListener),
5948: "ja", "ステップアンティルリターン")
5949: );
5950: }
5951:
5952:
5953:
5954: public static JButton mpuMakeRunButton () {
5955: return mpuAddButtonStopped (
5956: Multilingual.mlnToolTipText (
5957: ComponentFactory.createImageButton (
5958: LnF.LNF_RUN_IMAGE,
5959: LnF.LNF_RUN_DISABLED_IMAGE,
5960: "Run", mpuDebugActionListener),
5961: "ja", "実行")
5962: );
5963: }
5964:
5965:
5966:
5967: public static <T extends AbstractButton> T mpuAddButtonRunning (T button) {
5968: button.setEnabled (mpuTask != null);
5969: mpuButtonsRunning.add (button);
5970: return button;
5971: }
5972:
5973:
5974:
5975: public static <T extends AbstractButton> T mpuAddButtonStopped (T button) {
5976: button.setEnabled (mpuTask == null);
5977: mpuButtonsStopped.add (button);
5978: return button;
5979: }
5980:
5981:
5982:
5983:
5984:
5985:
5986:
5987:
5988:
5989:
5990:
5991:
5992:
5993:
5994:
5995:
5996: public static final int EMX_OPCODE_BASE = 0x4e00;
5997: public static final int EMX_OPCODE_HFSBOOT = EMX_OPCODE_BASE + 0x00;
5998: public static final int EMX_OPCODE_HFSINST = EMX_OPCODE_BASE + 0x01;
5999: public static final int EMX_OPCODE_HFSSTR = EMX_OPCODE_BASE + 0x02;
6000: public static final int EMX_OPCODE_HFSINT = EMX_OPCODE_BASE + 0x03;
6001: public static final int EMX_OPCODE_EMXNOP = EMX_OPCODE_BASE + 0x04;
6002: public static final int EMX_OPCODE_EMXWAIT = EMX_OPCODE_BASE + 0x05;
6003:
6004: public static final String[] EMX_MNEMONIC_ARRAY = {
6005: "hfsboot",
6006: "hfsinst",
6007: "hfsstr",
6008: "hfsint",
6009: "emxnop",
6010: "emxwait",
6011: };
6012:
6013:
6014:
6015:
6016: public static void emxNop () {
6017: if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x00007140) {
6018: int head = regRn[9];
6019: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
6020:
6021:
6022: emxPatchPCM8A (head, tail);
6023:
6024:
6025: emxCheckRSDRV202 (head, tail);
6026: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000716c) {
6027: int head = regRn[9];
6028: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
6029:
6030:
6031: emxPatch060turbosys (head, tail);
6032:
6033:
6034: if (Z8530.SCC_FSX_MOUSE) {
6035: emxCheckFSX (head, tail);
6036: }
6037:
6038:
6039: if (HFS.HFS_USE_TWENTY_ONE) {
6040: emxCheckTwentyOne (head, tail);
6041: }
6042:
6043:
6044: LabeledAddress.lblClear ();
6045: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000972c) {
6046: int head = regRn[8] + 256;
6047:
6048: int tail = MC68060.mmuPeekLong (head - 208, 1);
6049:
6050:
6051: emxCheckBSIO021 (head, tail);
6052:
6053:
6054: emxPatchPCM8A (head, tail);
6055:
6056:
6057: emxCheckTMSIO031 (head, tail);
6058:
6059:
6060: LabeledAddress.lblClear ();
6061:
6062:
6063: if (dbgStopAtStart) {
6064: InstructionBreakPoint.ibpInstant (regRn[12], 0);
6065: }
6066: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000a090) {
6067: int head = regRn[8] + 256;
6068: int tail = MC68060.mmuPeekLongData (regRn[8] + 8, 1);
6069: String name = MC68060.mmuPeekStringZ (head - 60, 1);
6070: if (name.equalsIgnoreCase ("fsx.x")) {
6071:
6072:
6073: if (Z8530.SCC_FSX_MOUSE) {
6074: emxCheckFSX (head, tail);
6075: }
6076: }
6077: if (name.equalsIgnoreCase ("TwentyOne.x")) {
6078:
6079:
6080: if (HFS.HFS_USE_TWENTY_ONE) {
6081: emxCheckTwentyOne (head, tail);
6082: }
6083: }
6084: }
6085: }
6086:
6087: public static final int[] emxPCM8AFFMap = {
6088: 0x00000138, 0x000001f6, 0x00000394, 0x000011ec, 0x0000120a, 0x00001400, 0x00001814, 0x00001870, 0x00001882, 0x0000188a,
6089: 0x00001892, 0x000018a2, 0x000018a8, 0x000018ca, 0x000018d4, 0x000018e0, 0x000018e8, 0x00001908, 0x000019e4, 0x00001afa,
6090: 0x00001b58, 0x00001b7c, 0x00001bac, 0x00001c38, 0x00001ccc, 0x000021f8, 0x00002250, 0x00002258, 0x00002290, 0x000022a6,
6091: 0x000022b0, 0x000022c0, 0x000022c8, 0x000022de, 0x000022ea, 0x000030c8, 0x000030de, 0x000030e6, 0x000030ea, 0x000030f6,
6092: 0x00003112, 0x00003188, 0x0000334c, 0x0000338a, 0x000033a2, 0x000033c4, 0x000033d0, 0x0000341a, 0x00003428, 0x00003496,
6093: 0x000034a6, 0x000034d6, 0x0000fe0e, 0x0000fec8, 0x0000feec, 0x0000ff46, 0x0000ff4e,
6094: };
6095:
6096:
6097:
6098: public static void emxPatchPCM8A (int head, int tail) {
6099: if (head + 0x0000ff60 <= tail &&
6100: MC68060.mmuPeekLongData (head + 0x10f8, 1) == 0x50434d38 &&
6101: MC68060.mmuPeekLongData (head + 0x10fc, 1) == 0x41313032) {
6102: System.out.println (Multilingual.mlnJapanese ?
6103: "PCM8A.X 1.02 があります" :
6104: "PCM8A.X 1.02 exists");
6105: int patched = 0;
6106: int failed = 0;
6107:
6108: for (int offset : emxPCM8AFFMap) {
6109: if (MC68060.mmuPeekByteZeroData (head + offset, 1) == 0xff) {
6110: MC68060.mmuPokeByteData (head + offset, 0x00, 1);
6111: patched++;
6112: } else {
6113: failed++;
6114: }
6115: }
6116: if (patched != 0) {
6117: System.out.printf (Multilingual.mlnJapanese ?
6118: "PCM8A.X 1.02 にパッチをあてました (%d/%d)\n" :
6119: "PCM8A.X 1.02 was patched (%d/%d)\n",
6120: patched, patched + failed);
6121: }
6122: }
6123: }
6124:
6125:
6126:
6127: public static void emxPatch060turbosys (int head, int tail) {
6128:
6129:
6130:
6131:
6132: if (head + 0x00002000 <= tail &&
6133: MC68060.mmuPeekLongData (head + 0x00000ec0, 1) == 0x203c302e &&
6134: MC68060.mmuPeekLongData (head + 0x00000ec4, 1) == 0x3536227c &&
6135: MC68060.mmuPeekLongData (head + 0x00000ec8, 1) == 0x30363054) {
6136: System.out.println (Multilingual.mlnJapanese ?
6137: "060turbo.sys 0.56 があります" :
6138: "060turbo.sys 0.56 exists");
6139:
6140:
6141:
6142: int patched = 0;
6143: int failed = 0;
6144: if (MC68060.mmuPeekLongData (head + 0x000021e6, 1) == 0x08f90004 &&
6145: MC68060.mmuPeekLongData (head + 0x000021ea, 1) == 0x00ed0070) {
6146: MC68060.mmuPokeWordData (head + 0x000021e6, 0x0839, 1);
6147: patched++;
6148: } else {
6149: failed++;
6150: }
6151: System.out.printf (Multilingual.mlnJapanese ?
6152: "060turbo.sys 0.56 にパッチをあてました (%d/%d)\n" :
6153: "060turbo.sys 0.56 was patched (%d/%d)\n",
6154: patched, patched + failed);
6155: }
6156: }
6157:
6158:
6159:
6160: public static void emxCheckFSX (int head, int tail) {
6161: if (Z8530.SCC_FSX_MOUSE) {
6162: if (head + 0x00063200 <= tail &&
6163: "\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))) {
6164: System.out.println (Multilingual.mlnJapanese ?
6165: "FSX.X 3.10 があります" :
6166: "FSX.X 3.10 exists");
6167: Z8530.sccFSXMouseHook = head + 0x04f82a;
6168: Z8530.sccFSXMouseWork = head + 0x063184;
6169: }
6170: }
6171: }
6172:
6173:
6174:
6175:
6176:
6177:
6178: public static void emxCheckRSDRV202 (int head, int tail) {
6179: if (head + 0x000ea6 <= tail &&
6180: MC68060.mmuPeekEquals (head + 0x000e4e, "RS-232C DRIVER for X68000 version 2.02")) {
6181: if (RS232CTerminal.trmRSDRV202Head != head) {
6182: RS232CTerminal.trmRSDRV202Head = head;
6183: int[] patchData = {
6184:
6185:
6186: 0x05f8, 0x000a, 0x000b,
6187:
6188: 0x0600, 0xd040, 0x2048,
6189:
6190: 0x060e, 0x3030, 0x4e90,
6191: 0x0610, 0x0000, 0x2048,
6192:
6193: 0x074e, 0x0821, 0x2041,
6194: 0x0750, 0x0410, 0x3200,
6195: 0x0752, 0x0207, 0x303c,
6196: 0x0754, 0x0102, 0x0823,
6197: 0x0756, 0x0080, 0xe268,
6198: 0x0758, 0x003f, 0x72fe,
6199: 0x075a, 0x001f, 0xd141,
6200: 0x075c, 0x000e, 0x2208,
6201: 0x075e, 0x0006, 0x4e75,
6202:
6203:
6204: 0x0ab0, 0x0040, 0x0400,
6205: 0x0ad2, 0x0040, 0x0400,
6206: 0x0af4, 0x0040, 0x0400,
6207: 0x0b16, 0x0040, 0x0400,
6208: 0x0b38, 0x0040, 0x0400,
6209:
6210:
6211: 0x0cae, 0x0009, 0x000b,
6212: };
6213: int patched = 0;
6214: int failed = 0;
6215: for (int i = 0; i < patchData.length; i += 3) {
6216: int a = head + patchData[i];
6217: int b = patchData[i + 1];
6218: int c = patchData[i + 2];
6219: int d = MC68060.mmuPeekWordZeroData (a, 1);
6220: if (d == b) {
6221: MC68060.mmuPokeWordData (a, c, 1);
6222: patched++;
6223: } else if (d != c) {
6224: failed++;
6225: }
6226: }
6227: System.out.printf ("RSDRV.SYS 2.02 found at %08X and patched (%d/%d)\n", head, patched, patched + failed);
6228: }
6229: }
6230: }
6231:
6232:
6233:
6234:
6235:
6236: public static void emxCheckTMSIO031 (int head, int tail) {
6237: if (head + 0x000fc4 <= tail &&
6238: MC68060.mmuPeekEquals (head + 0x000d1c, "TMSIO version 0.31 Copyright (C) 1990-93 by Miki Hoshino")) {
6239: if (RS232CTerminal.trmTMSIO031Head != head) {
6240: RS232CTerminal.trmTMSIO031Head = head;
6241: System.out.printf ("TMSIO 0.31 found at %08X\n", head);
6242: }
6243: }
6244: }
6245:
6246:
6247:
6248:
6249:
6250: public static void emxCheckBSIO021 (int head, int tail) {
6251: if (head + 0x001c2c <= tail &&
6252: MC68060.mmuPeekEquals (head + 0x001a66, "BSIO version 0.21 Copyright (C) 1994 By BAZU")) {
6253: if (RS232CTerminal.trmBSIO021Head != head) {
6254: RS232CTerminal.trmBSIO021Head = head;
6255: System.out.printf ("BSIO 0.21 found at %08X\n", head);
6256: }
6257: }
6258: }
6259:
6260:
6261:
6262: public static void emxCheckTwentyOne (int head, int tail) {
6263: if (HFS.HFS_USE_TWENTY_ONE &&
6264: head + 64 <= tail) {
6265: if (MainMemory.mmrTwentyOneOptionAddress != 0 ||
6266: MainMemory.mmrHumanVersion <= 0) {
6267: return;
6268: }
6269: int name1 = MC68060.mmuPeekLongData (head + 14, 1);
6270: if (name1 == ('*' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
6271: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
6272: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '*')) {
6273: MainMemory.mmrTwentyOneOptionAddress = -1;
6274: }
6275: } else if (name1 == ('?' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
6276: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
6277: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '?') ||
6278: name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | 'E')) {
6279: System.out.println (Multilingual.mlnJapanese ?
6280: "TwentyOne.x があります" :
6281: "TwentyOne.x exists");
6282: MainMemory.mmrTwentyOneOptionAddress = head + 22;
6283: }
6284: }
6285: }
6286: }
6287:
6288:
6289:
6290:
6291:
6292:
6293:
6294:
6295:
6296:
6297:
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: public static final boolean IRP_BITREV_REVERSE = false;
6339: public static final boolean IRP_BITREV_SHIFT = false;
6340: public static final boolean IRP_BITREV_TABLE = true;
6341:
6342: public static final boolean IRP_MOVEM_MAINMEMORY = true;
6343: public static final boolean IRP_MOVEM_EXPAND = false;
6344: public static final boolean IRP_MOVEM_LOOP = false;
6345: public static final boolean IRP_MOVEM_SHIFT_LEFT = false;
6346: public static final boolean IRP_MOVEM_SHIFT_RIGHT = true;
6347: public static final boolean IRP_MOVEM_ZEROS = false;
6348:
6349:
6350: public static void irpReset () {
6351:
6352: CRTC.crtReset ();
6353: VideoController.vcnReset ();
6354: HD63450.dmaReset ();
6355: MC68901.mfpReset ();
6356: Keyboard.kbdReset ();
6357: RP5C15.rtcReset ();
6358: PrinterPort.prnReset ();
6359: SoundSource.sndReset ();
6360: OPM.opmReset ();
6361: ADPCM.pcmReset ();
6362: FDC.fdcReset ();
6363: IOInterrupt.ioiReset ();
6364: eb2Reset ();
6365: SPC.spcReset ();
6366: if (SUK.SUK_ON) {
6367: SUK.sukReset ();
6368: }
6369: Z8530.sccReset ();
6370: RS232CTerminal.trmReset ();
6371: PPI.ppiReset ();
6372: HFS.hfsReset ();
6373: SpriteScreen.sprReset ();
6374:
6375: xt3Reset ();
6376: SRAM.smrReset ();
6377: CONDevice.conReset ();
6378: TextCopy.txcReset ();
6379: }
6380:
6381:
6382:
6383:
6384:
6385:
6386:
6387:
6388:
6389:
6390:
6391:
6392:
6393:
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: 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);
6967:
6968: public static final boolean EFA_SEPARATE_AR = false;
6969:
6970:
6971:
6972:
6973:
6974:
6975: public static final boolean BUS_SPLIT_UNALIGNED_LONG = false;
6976:
6977:
6978: public static final int BUS_MOTHER_BITS = 24;
6979: public static final int BUS_MOTHER_SIZE = BUS_MOTHER_BITS < 32 ? 1 << BUS_MOTHER_BITS : 0;
6980: public static final int BUS_MOTHER_MASK = BUS_MOTHER_SIZE - 1;
6981:
6982: public static final int BUS_DUMMY_4BIT_PAGE = BUS_MOTHER_SIZE;
6983: public static final int BUS_DUMMY_4BIT_SIZE = 2 * 512 * 512;
6984:
6985: public static final int BUS_MODIFIED_256_PAGE = BUS_DUMMY_4BIT_PAGE + BUS_DUMMY_4BIT_SIZE;
6986: public static final int BUS_MODIFIED_256_SIZE = 2 * 1024 * 1024;
6987:
6988: public static final int BUS_MODIFIED_65536_PAGE = BUS_MODIFIED_256_PAGE + BUS_MODIFIED_256_SIZE;
6989: public static final int BUS_MODIFIED_65536_SIZE = 2 * 1024 * 1024;
6990:
6991: public static final int BUS_ARRAY_SIZE = BUS_MODIFIED_65536_PAGE + BUS_MODIFIED_65536_SIZE;
6992:
6993:
6994: public static final int BUS_PAGE_BITS = 12;
6995: public static final int BUS_PAGE_SIZE = 1 << BUS_PAGE_BITS;
6996: public static final int BUS_PAGE_COUNT = 1 << (32 - BUS_PAGE_BITS);
6997:
6998:
6999: public static final int MPU_SS_BYTE = 0;
7000: public static final int MPU_SS_WORD = 1;
7001: public static final int MPU_SS_LONG = 2;
7002:
7003:
7004: public static final int MPU_WR_WRITE = 0;
7005: public static final int MPU_WR_READ = 1;
7006:
7007:
7008: public static final int MPU_US_USER = 0;
7009: public static final int MPU_US_SUPERVISOR = 1;
7010:
7011:
7012: public static final MemoryMappedDevice[] busUserMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
7013: public static final MemoryMappedDevice[] busSuperMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
7014: public static MemoryMappedDevice[] busMemoryMap;
7015:
7016:
7017: public static boolean busHimem68000;
7018:
7019:
7020: public static final int BUS_HIGH_MEMORY_START = 0x01000000;
7021: public static int busHighMemorySize;
7022: public static byte[] busHighMemoryArray;
7023: public static boolean busHighMemorySaveOn;
7024: public static boolean busHighMemory060turboOn;
7025:
7026:
7027: public static final int BUS_LOCAL_MEMORY_START = 0x10000000;
7028: public static int busLocalMemorySize;
7029: public static byte[] busLocalMemoryArray;
7030: public static boolean busLocalMemorySaveOn;
7031:
7032:
7033: public static final byte[] BUS_DUMMY_MEMORY_ARRAY = new byte[0];
7034: public static int busRequestExMemoryStart;
7035: public static int busRequestExMemorySize;
7036: public static byte[] busRequestExMemoryArray;
7037: public static int busExMemoryStart;
7038: public static int busExMemorySize;
7039: public static byte[] busExMemoryArray;
7040:
7041:
7042: public static boolean busRequestCutFC2Pin;
7043: public static boolean busCutFC2Pin;
7044:
7045:
7046:
7047: public static void busInit () {
7048:
7049:
7050: if (!DataBreakPoint.DBP_ON) {
7051: busMemoryMap = busSuperMap;
7052: }
7053:
7054:
7055: int highMemorySizeMB = Settings.sgsGetInt ("highmemory");
7056: busHighMemorySize = highMemorySizeMB == 16 ? highMemorySizeMB << 20 : 0 << 20;
7057: if (busHighMemorySize == 0) {
7058: System.out.println (Multilingual.mlnJapanese ?
7059: "X68030/Xellent30 のハイメモリはありません" :
7060: "X68030/Xellent30 high memory does not exists");
7061: } else {
7062: System.out.printf (Multilingual.mlnJapanese ?
7063: "X68030/Xellent30 のハイメモリのサイズは %dMB です\n" :
7064: "X68030/Xellent30 high memory size is %dMB\n",
7065: busHighMemorySize >> 20);
7066: }
7067: busHighMemoryArray = new byte[busHighMemorySize];
7068:
7069: busHimem68000 = Settings.sgsGetOnOff ("himem68000");
7070:
7071: busHighMemorySaveOn = Settings.sgsGetOnOff ("highmemorysave");
7072: busHighMemory060turboOn = Settings.sgsGetOnOff ("highmemory060turbo");
7073:
7074: byte[] highMemoryArray = Settings.sgsGetData ("highmemorydata");
7075: if (busHighMemorySize != 0) {
7076: if (highMemoryArray.length != 0) {
7077: System.out.println (Multilingual.mlnJapanese ?
7078: "X68030/Xellent30 のハイメモリのデータを復元します" :
7079: "X68030/Xellent30 high memory data is restored");
7080: System.arraycopy (highMemoryArray, 0, busHighMemoryArray, 0, Math.min (highMemoryArray.length, busHighMemorySize));
7081: } else {
7082: System.out.println (Multilingual.mlnJapanese ?
7083: "X68030/Xellent30 のハイメモリをゼロクリアします" :
7084: "X68030/Xellent30 high memory is zero-cleared");
7085: }
7086: if (highMemoryArray.length < busHighMemorySize) {
7087: Arrays.fill (busHighMemoryArray, highMemoryArray.length, busHighMemorySize, (byte) 0);
7088: }
7089: }
7090:
7091:
7092: int localMemorySizeMB = Settings.sgsGetInt ("localmemory");
7093: busLocalMemorySize = (localMemorySizeMB == 16 ||
7094: localMemorySizeMB == 32 ||
7095: localMemorySizeMB == 64 ||
7096: localMemorySizeMB == 128 ||
7097: localMemorySizeMB == 256 ||
7098: localMemorySizeMB == 384 ||
7099: localMemorySizeMB == 512 ||
7100: localMemorySizeMB == 768 ?
7101: localMemorySizeMB << 20 :
7102: 128 << 20);
7103: if (busLocalMemorySize == 0) {
7104: System.out.println (Multilingual.mlnJapanese ?
7105: "060turbo のハイメモリはありません" :
7106: "060turbo high memory does not exists");
7107: } else {
7108: System.out.printf (Multilingual.mlnJapanese ?
7109: "060turbo のハイメモリのサイズは %dMB です\n" :
7110: "060turbo high memory size is %dMB\n",
7111: busLocalMemorySize >> 20);
7112: }
7113: busLocalMemoryArray = new byte[busLocalMemorySize];
7114:
7115: busLocalMemorySaveOn = Settings.sgsGetOnOff ("localmemorysave");
7116:
7117: byte[] localMemoryArray = Settings.sgsGetData ("localmemorydata");
7118: if (busLocalMemorySize != 0) {
7119: if (localMemoryArray.length != 0) {
7120: System.out.println (Multilingual.mlnJapanese ?
7121: "060turbo のハイメモリのデータを復元します" :
7122: "060turbo high memory data is restored");
7123: System.arraycopy (localMemoryArray, 0, busLocalMemoryArray, 0, Math.min (localMemoryArray.length, busLocalMemorySize));
7124: } else {
7125: System.out.println (Multilingual.mlnJapanese ?
7126: "060turbo のハイメモリをゼロクリアします" :
7127: "060turbo high memory is zero-cleared");
7128: }
7129: if (localMemoryArray.length < busLocalMemorySize) {
7130: Arrays.fill (busLocalMemoryArray, localMemoryArray.length, busLocalMemorySize, (byte) 0);
7131: }
7132: }
7133:
7134:
7135: busExMemoryStart = busRequestExMemoryStart = 0x10000000;
7136: busExMemorySize = busRequestExMemorySize = 0 << 20;
7137: busExMemoryArray = busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
7138:
7139:
7140: busRequestCutFC2Pin = Settings.sgsGetOnOff ("cutfc2pin");
7141: busCutFC2Pin = !busRequestCutFC2Pin;
7142:
7143: busUpdateMemoryMap ();
7144:
7145: }
7146:
7147:
7148:
7149: public static void busTini () {
7150: Settings.sgsPutOnOff ("himem68000", busHimem68000);
7151: Settings.sgsPutInt ("highmemory", busHighMemorySize >>> 20);
7152: Settings.sgsPutOnOff ("highmemorysave", busHighMemorySaveOn);
7153: Settings.sgsPutOnOff ("highmemory060turbo", busHighMemory060turboOn);
7154: Settings.sgsPutData ("highmemorydata", busHighMemorySaveOn ? busHighMemoryArray : new byte[0]);
7155: Settings.sgsPutInt ("localmemory", busLocalMemorySize >>> 20);
7156: Settings.sgsPutOnOff ("localmemorysave", busLocalMemorySaveOn);
7157: Settings.sgsPutData ("localmemorydata", busLocalMemorySaveOn ? busLocalMemoryArray : new byte[0]);
7158: Settings.sgsPutOnOff ("cutfc2pin", busRequestCutFC2Pin);
7159: }
7160:
7161: public static void busUpdateMemoryMap () {
7162: if (busExMemoryStart == busRequestExMemoryStart &&
7163: busExMemorySize == busRequestExMemorySize &&
7164: busExMemoryArray == busRequestExMemoryArray &&
7165: busExMemoryArray.length == busExMemorySize &&
7166: busCutFC2Pin == busRequestCutFC2Pin) {
7167: return;
7168: }
7169:
7170: busExMemoryStart = busRequestExMemoryStart;
7171: busExMemorySize = busRequestExMemorySize;
7172: busExMemoryArray = busRequestExMemoryArray;
7173: if (busExMemoryArray.length != busExMemorySize) {
7174: byte[] newArray = new byte[busExMemorySize];
7175: int copySize = Math.min (busExMemoryArray.length, busExMemorySize);
7176: if (copySize > 0) {
7177: System.arraycopy (busExMemoryArray, 0, newArray, 0, copySize);
7178: }
7179: if (busExMemoryArray == busHighMemoryArray) {
7180: busHighMemoryArray = newArray;
7181: } else if (busExMemoryArray == busLocalMemoryArray) {
7182: busLocalMemoryArray = newArray;
7183: }
7184: busExMemoryArray = newArray;
7185: }
7186:
7187: busCutFC2Pin = busRequestCutFC2Pin;
7188:
7189:
7190:
7191:
7192:
7193:
7194:
7195:
7196:
7197:
7198:
7199:
7200: busSuper (MemoryMappedDevice.MMD_MMR, 0x00000000, 0x00002000);
7201: busUser ( MemoryMappedDevice.MMD_MMR, 0x00002000, 0x00c00000);
7202:
7203:
7204:
7205:
7206:
7207:
7208:
7209:
7210:
7211:
7212:
7213:
7214:
7215:
7216:
7217:
7218:
7219:
7220:
7221:
7222:
7223:
7224:
7225:
7226: busSuper (MemoryMappedDevice.MMD_GE0, 0x00c00000, 0x00c80000);
7227: busSuper (MemoryMappedDevice.MMD_GE1, 0x00c80000, 0x00d00000);
7228: busSuper (MemoryMappedDevice.MMD_GE2, 0x00d00000, 0x00d80000);
7229: busSuper (MemoryMappedDevice.MMD_GE3, 0x00d80000, 0x00e00000);
7230:
7231:
7232:
7233:
7234: busSuper (MemoryMappedDevice.MMD_TXT, 0x00e00000, 0x00e80000);
7235:
7236:
7237:
7238:
7239: busSuper (MemoryMappedDevice.MMD_CRT, 0x00e80000, 0x00e82000);
7240:
7241:
7242:
7243:
7244:
7245: busSuper (MemoryMappedDevice.MMD_VCN, 0x00e82000, 0x00e84000);
7246:
7247:
7248:
7249:
7250: busSuper (MemoryMappedDevice.MMD_DMA, 0x00e84000, 0x00e86000);
7251:
7252:
7253:
7254:
7255: busSuper (MemoryMappedDevice.MMD_SVS, 0x00e86000, 0x00e88000);
7256:
7257:
7258:
7259:
7260: busSuper (MemoryMappedDevice.MMD_MFP, 0x00e88000, 0x00e8a000);
7261:
7262:
7263:
7264:
7265: busSuper (MemoryMappedDevice.MMD_RTC_FIRST, 0x00e8a000, 0x00e8c000);
7266:
7267:
7268:
7269:
7270: busSuper (MemoryMappedDevice.MMD_PRN, 0x00e8c000, 0x00e8e000);
7271:
7272:
7273:
7274:
7275: busSuper (MemoryMappedDevice.MMD_SYS, 0x00e8e000, 0x00e90000);
7276:
7277:
7278:
7279:
7280: busSuper (MemoryMappedDevice.MMD_OPM, 0x00e90000, 0x00e92000);
7281:
7282:
7283:
7284:
7285: busSuper (MemoryMappedDevice.MMD_PCM, 0x00e92000, 0x00e94000);
7286:
7287:
7288:
7289:
7290: busSuper (MemoryMappedDevice.MMD_FDC, 0x00e94000, 0x00e96000);
7291:
7292:
7293:
7294:
7295:
7296: busSuper (MemoryMappedDevice.MMD_HDC, 0x00e96000, 0x00e98000);
7297:
7298:
7299:
7300:
7301: busSuper (MemoryMappedDevice.MMD_SCC, 0x00e98000, 0x00e9a000);
7302:
7303:
7304:
7305:
7306: busSuper (MemoryMappedDevice.MMD_PPI, 0x00e9a000, 0x00e9c000);
7307:
7308:
7309:
7310:
7311: busSuper (MemoryMappedDevice.MMD_IOI, 0x00e9c000, 0x00e9e000);
7312:
7313:
7314:
7315:
7316:
7317:
7318:
7319:
7320:
7321: busSuper (MemoryMappedDevice.MMD_XB1, 0x00e9e000, 0x00ea0000);
7322:
7323:
7324:
7325:
7326:
7327: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ea0000, 0x00eae000);
7328:
7329:
7330:
7331:
7332:
7333:
7334:
7335:
7336:
7337:
7338:
7339:
7340:
7341: busSuper (MemoryMappedDevice.MMD_XB2, 0x00eae000, 0x00eb0000);
7342:
7343:
7344:
7345:
7346:
7347:
7348:
7349:
7350: busSuper (MemoryMappedDevice.MMD_SPR, 0x00eb0000, 0x00ec0000);
7351:
7352:
7353:
7354:
7355:
7356:
7357:
7358:
7359:
7360: busSuper (MemoryMappedDevice.MMD_XB3, 0x00ec0000, 0x00ed0000);
7361:
7362:
7363:
7364:
7365:
7366:
7367: busSuper (MemoryMappedDevice.MMD_SMR, 0x00ed0000, 0x00ed0000 + 16384);
7368: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ed0000 + 16384, 0x00ed0000 + 65536);
7369:
7370:
7371:
7372:
7373:
7374:
7375:
7376:
7377: busSuper (MemoryMappedDevice.MMD_XB4, 0x00ee0000, 0x00f00000);
7378:
7379:
7380:
7381:
7382:
7383:
7384:
7385:
7386:
7387:
7388: busSuper (MemoryMappedDevice.MMD_CG1, 0x00f00000, 0x00f40000);
7389:
7390:
7391:
7392:
7393:
7394:
7395:
7396: busSuper (MemoryMappedDevice.MMD_CG2, 0x00f40000, 0x00fc0000);
7397:
7398:
7399:
7400:
7401:
7402:
7403:
7404:
7405:
7406:
7407:
7408:
7409:
7410:
7411: busSuper (MemoryMappedDevice.MMD_ROM, 0x00fc0000, 0x01000000);
7412:
7413: }
7414:
7415: public static void busReset () {
7416: if (regSRS != 0) {
7417: if (DataBreakPoint.DBP_ON) {
7418: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpSuperMap;
7419: } else {
7420: busMemoryMap = busSuperMap;
7421: }
7422: } else {
7423: if (DataBreakPoint.DBP_ON) {
7424: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpUserMap;
7425: } else {
7426: busMemoryMap = busUserMap;
7427: }
7428: }
7429: }
7430:
7431:
7432:
7433:
7434:
7435: public static void busUser (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
7436: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
7437: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
7438: if (false &&
7439: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
7440: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
7441: System.out.printf ("ERROR: busUser (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
7442: }
7443: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
7444: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
7445: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
7446: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
7447: int startPage = blockStartPage + motherStartPage;
7448: int endPage = blockStartPage + motherEndPage;
7449: for (int page = startPage; page < endPage; page++) {
7450: MemoryMappedDevice superMmd = exMemoryStartPage <= page && page < exMemoryEndPage ? MemoryMappedDevice.MMD_XMM : mmd;
7451: busUserMap[page] = busSuperMap[page] = superMmd;
7452: if (InstructionBreakPoint.IBP_ON) {
7453: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
7454: InstructionBreakPoint.ibpUserMap[page] = superMmd;
7455: }
7456: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
7457: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
7458: }
7459: }
7460: if (DataBreakPoint.DBP_ON) {
7461: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
7462: DataBreakPoint.dbpUserMap[page] = superMmd;
7463: }
7464: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
7465: DataBreakPoint.dbpSuperMap[page] = superMmd;
7466: }
7467: }
7468: }
7469: }
7470: }
7471:
7472:
7473:
7474:
7475:
7476: public static void busSuper (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
7477: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
7478: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
7479: if (false &&
7480: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
7481: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
7482: System.out.printf ("ERROR: busSuper (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
7483: }
7484: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
7485: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
7486: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
7487: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
7488: int startPage = blockStartPage + motherStartPage;
7489: int endPage = blockStartPage + motherEndPage;
7490: for (int page = startPage; page < endPage; page++) {
7491: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
7492: MemoryMappedDevice userMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : busCutFC2Pin ? mmd : MemoryMappedDevice.MMD_NUL;
7493: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
7494: busUserMap[page] = userMmd;
7495: busSuperMap[page] = superMmd;
7496: if (InstructionBreakPoint.IBP_ON) {
7497: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
7498: InstructionBreakPoint.ibpUserMap[page] = userMmd;
7499: }
7500: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
7501: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
7502: }
7503: }
7504: if (DataBreakPoint.DBP_ON) {
7505: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
7506: DataBreakPoint.dbpUserMap[page] = userMmd;
7507: }
7508: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
7509: DataBreakPoint.dbpSuperMap[page] = superMmd;
7510: }
7511: }
7512: }
7513: }
7514: }
7515:
7516:
7517:
7518: public static byte busPbs (int a) {
7519: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a);
7520: }
7521:
7522:
7523:
7524: public static int busPbz (int a) {
7525: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a);
7526: }
7527:
7528:
7529:
7530: public static int busPws (int a) {
7531: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7532: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
7533: } else {
7534: int a1 = a + 1;
7535: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
7536: }
7537: }
7538:
7539:
7540:
7541: public static int busPwse (int a) {
7542: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
7543: }
7544:
7545:
7546:
7547: public static int busPwz (int a) {
7548: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7549: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
7550: } else {
7551: int a1 = a + 1;
7552: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
7553: }
7554: }
7555:
7556:
7557:
7558: public static int busPwze (int a) {
7559: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
7560: }
7561:
7562:
7563:
7564: public static int busPls (int a) {
7565: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
7566: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
7567: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7568: int a2 = a + 2;
7569: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a) << 16 | busSuperMap[a2 >>> BUS_PAGE_BITS].mmdPwz (a2);
7570: } else {
7571: int a1 = a + 1;
7572: int a3 = a + 3;
7573: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 24 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPwz (a1) << 8 | busSuperMap[a3 >>> BUS_PAGE_BITS].mmdPbz (a3);
7574: }
7575: }
7576:
7577:
7578:
7579: public static int busPlsf (int a) {
7580: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
7581: }
7582:
7583:
7584:
7585: public static long busPqs (int a) {
7586: return (long) busPls (a) << 32 | busPls (a + 4) & 0xffffffffL;
7587: }
7588:
7589:
7590:
7591: public static int busSearchByte (int start, int end, int c) {
7592: for (int a = start; a < end; a++) {
7593: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) == c) {
7594: return a;
7595: }
7596: }
7597: return -1;
7598: }
7599: public static int busSearchWord (int start, int end, int c) {
7600: for (int a = start; a < end; a += 2) {
7601: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) == c) {
7602: return a;
7603: }
7604: }
7605: return -1;
7606: }
7607: public static int busSearchByteArray (int start, int end, int[] array) {
7608: int l = array.length;
7609: end -= l;
7610: int c = array[0];
7611: a:
7612: for (int a = start; a <= end; a++) {
7613: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) != c) {
7614: continue a;
7615: }
7616: for (int i = 1, b = a + 1; i < l; i++, b++) {
7617: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPbz (b) != array[i]) {
7618: continue a;
7619: }
7620: }
7621: return a;
7622: }
7623: return -1;
7624: }
7625: public static int busSearchWordArray (int start, int end, int[] array) {
7626: int l = array.length;
7627: end -= l;
7628: int c = array[0];
7629: a:
7630: for (int a = start; a <= end; a += 2) {
7631: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) != c) {
7632: continue a;
7633: }
7634: for (int i = 1, b = a + 2; i < l; i++, b += 2) {
7635: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPwz (b) != array[i]) {
7636: continue a;
7637: }
7638: }
7639: return a;
7640: }
7641: return -1;
7642: }
7643:
7644:
7645:
7646:
7647: public static byte busRbs (int a) throws M68kException {
7648: if (DataBreakPoint.DBP_ON) {
7649: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
7650: } else {
7651: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
7652: }
7653: }
7654:
7655:
7656:
7657: public static int busRbz (int a) throws M68kException {
7658: if (DataBreakPoint.DBP_ON) {
7659: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
7660: } else {
7661: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
7662: }
7663: }
7664:
7665:
7666:
7667: public static int busRws (int a) throws M68kException {
7668: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7669: if (DataBreakPoint.DBP_ON) {
7670: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
7671: } else {
7672: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
7673: }
7674: } else if (mpuIgnoreAddressError) {
7675: int a1 = a + 1;
7676: if (DataBreakPoint.DBP_ON) {
7677: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
7678: } else {
7679: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
7680: }
7681: } else {
7682: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
7683: M68kException.m6eAddress = a;
7684: M68kException.m6eDirection = MPU_WR_READ;
7685: M68kException.m6eSize = MPU_SS_WORD;
7686: throw M68kException.m6eSignal;
7687: }
7688: }
7689:
7690:
7691:
7692:
7693: public static int busRwse (int a) throws M68kException {
7694: if (DataBreakPoint.DBP_ON) {
7695: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
7696: } else {
7697: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
7698: }
7699: }
7700:
7701:
7702:
7703: public static int busRwz (int a) throws M68kException {
7704: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7705: if (DataBreakPoint.DBP_ON) {
7706: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
7707: } else {
7708: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
7709: }
7710: } else if (mpuIgnoreAddressError) {
7711: int a1 = a + 1;
7712: if (DataBreakPoint.DBP_ON) {
7713: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
7714: } else {
7715: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
7716: }
7717: } else {
7718: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
7719: M68kException.m6eAddress = a;
7720: M68kException.m6eDirection = MPU_WR_READ;
7721: M68kException.m6eSize = MPU_SS_WORD;
7722: throw M68kException.m6eSignal;
7723: }
7724: }
7725:
7726:
7727:
7728:
7729: public static int busRwze (int a) throws M68kException {
7730: if (DataBreakPoint.DBP_ON) {
7731: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
7732: } else {
7733: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
7734: }
7735: }
7736:
7737:
7738:
7739: public static int busRls (int a) throws M68kException {
7740: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
7741: if (DataBreakPoint.DBP_ON) {
7742: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
7743: } else {
7744: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
7745: }
7746: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7747: int a2 = a + 2;
7748: if (BUS_SPLIT_UNALIGNED_LONG) {
7749: if (DataBreakPoint.DBP_ON) {
7750: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
7751: } else {
7752: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
7753: }
7754: } else {
7755: MemoryMappedDevice mmd;
7756: MemoryMappedDevice mmd2;
7757: if (DataBreakPoint.DBP_ON) {
7758: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
7759: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
7760: } else {
7761: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
7762: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
7763: }
7764: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
7765: }
7766: } else if (mpuIgnoreAddressError) {
7767: int a1 = a + 1;
7768: int a3 = a + 3;
7769: if (DataBreakPoint.DBP_ON) {
7770: 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);
7771: } else {
7772: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 24 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRwz (a1) << 8 | busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdRbz (a3);
7773: }
7774: } else {
7775: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
7776: M68kException.m6eAddress = a;
7777: M68kException.m6eDirection = MPU_WR_READ;
7778: M68kException.m6eSize = MPU_SS_LONG;
7779: throw M68kException.m6eSignal;
7780: }
7781: }
7782:
7783:
7784:
7785:
7786: public static int busRlse (int a) throws M68kException {
7787: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
7788: if (DataBreakPoint.DBP_ON) {
7789: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
7790: } else {
7791: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
7792: }
7793: } else {
7794: int a2 = a + 2;
7795: if (BUS_SPLIT_UNALIGNED_LONG) {
7796: if (DataBreakPoint.DBP_ON) {
7797: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
7798: } else {
7799: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
7800: }
7801: } else {
7802: MemoryMappedDevice mmd;
7803: MemoryMappedDevice mmd2;
7804: if (DataBreakPoint.DBP_ON) {
7805: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
7806: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
7807: } else {
7808: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
7809: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
7810: }
7811: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
7812: }
7813: }
7814: }
7815:
7816:
7817:
7818:
7819: public static int busRlsf (int a) throws M68kException {
7820: if (DataBreakPoint.DBP_ON) {
7821: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
7822: } else {
7823: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
7824: }
7825: }
7826:
7827:
7828:
7829: public static long busRqs (int a) throws M68kException {
7830: return (long) busRls (a) << 32 | busRls (a + 4) & 0xffffffffL;
7831: }
7832:
7833:
7834:
7835: public static void busWb (int a, int d) throws M68kException {
7836: if (DataBreakPoint.DBP_ON) {
7837: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
7838: } else {
7839: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
7840: }
7841: }
7842:
7843:
7844:
7845: public static void busWw (int a, int d) throws M68kException {
7846: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7847: if (DataBreakPoint.DBP_ON) {
7848: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
7849: } else {
7850: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
7851: }
7852: } else if (mpuIgnoreAddressError) {
7853: int a1 = a + 1;
7854: if (DataBreakPoint.DBP_ON) {
7855: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
7856: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
7857: } else {
7858: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
7859: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
7860: }
7861: } else {
7862: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
7863: M68kException.m6eAddress = a;
7864: M68kException.m6eDirection = MPU_WR_WRITE;
7865: M68kException.m6eSize = MPU_SS_WORD;
7866: throw M68kException.m6eSignal;
7867: }
7868: }
7869:
7870:
7871:
7872:
7873: public static void busWwe (int a, int d) throws M68kException {
7874: if (DataBreakPoint.DBP_ON) {
7875: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
7876: } else {
7877: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
7878: }
7879: }
7880:
7881:
7882:
7883: public static void busWl (int a, int d) throws M68kException {
7884: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
7885: if (DataBreakPoint.DBP_ON) {
7886: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
7887: } else {
7888: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
7889: }
7890: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
7891: int a2 = a + 2;
7892: if (BUS_SPLIT_UNALIGNED_LONG) {
7893: if (DataBreakPoint.DBP_ON) {
7894: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
7895: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
7896: } else {
7897: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
7898: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
7899: }
7900: } else {
7901: MemoryMappedDevice mmd;
7902: MemoryMappedDevice mmd2;
7903: if (DataBreakPoint.DBP_ON) {
7904: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
7905: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
7906: } else {
7907: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
7908: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
7909: }
7910: if (mmd == mmd2) {
7911: mmd.mmdWl (a, d);
7912: } else {
7913: mmd.mmdWw (a, d >> 16);
7914: mmd2.mmdWw (a2, d);
7915: }
7916: }
7917: } else if (mpuIgnoreAddressError) {
7918: int a1 = a + 1;
7919: int a3 = a + 3;
7920: if (DataBreakPoint.DBP_ON) {
7921: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
7922: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
7923: DataBreakPoint.dbpMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
7924: } else {
7925: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
7926: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
7927: busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
7928: }
7929: } else {
7930: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
7931: M68kException.m6eAddress = a;
7932: M68kException.m6eDirection = MPU_WR_WRITE;
7933: M68kException.m6eSize = MPU_SS_LONG;
7934: throw M68kException.m6eSignal;
7935: }
7936: }
7937:
7938:
7939:
7940:
7941: public static void busWlf (int a, int d) throws M68kException {
7942: if (DataBreakPoint.DBP_ON) {
7943: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
7944: } else {
7945: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
7946: }
7947: }
7948:
7949:
7950:
7951:
7952: public static void busWle (int a, int d) throws M68kException {
7953: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
7954: if (DataBreakPoint.DBP_ON) {
7955: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
7956: } else {
7957: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
7958: }
7959: } else {
7960: int a2 = a + 2;
7961: if (BUS_SPLIT_UNALIGNED_LONG) {
7962: if (DataBreakPoint.DBP_ON) {
7963: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
7964: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
7965: } else {
7966: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
7967: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
7968: }
7969: } else {
7970: MemoryMappedDevice mmd;
7971: MemoryMappedDevice mmd2;
7972: if (DataBreakPoint.DBP_ON) {
7973: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
7974: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
7975: } else {
7976: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
7977: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
7978: }
7979: if (mmd == mmd2) {
7980: mmd.mmdWl (a, d);
7981: } else {
7982: mmd.mmdWw (a, d >> 16);
7983: mmd2.mmdWw (a2, d);
7984: }
7985: }
7986: }
7987: }
7988:
7989:
7990:
7991: public static void busWq (int a, long d) throws M68kException {
7992: busWl (a, (int) (d >>> 32));
7993: busWl (a + 4, (int) d);
7994: }
7995:
7996:
7997:
7998:
7999:
8000: public static void busRbb (int a, byte[] bb, int o, int l) throws M68kException {
8001: if (false) {
8002: for (int i = 0; i < l; i++) {
8003: int ai = a + i;
8004: if (DataBreakPoint.DBP_ON) {
8005: bb[o + i] = DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
8006: } else {
8007: bb[o + i] = busMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
8008: }
8009: }
8010: } else {
8011: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
8012: while (l > 0) {
8013: MemoryMappedDevice mmd;
8014: if (DataBreakPoint.DBP_ON) {
8015: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8016: } else {
8017: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8018: }
8019: int s = l <= r ? l : r;
8020: l -= s;
8021: if (true) {
8022: for (s -= 16; s >= 0; s -= 16) {
8023: bb[o ] = mmd.mmdRbs (a );
8024: bb[o + 1] = mmd.mmdRbs (a + 1);
8025: bb[o + 2] = mmd.mmdRbs (a + 2);
8026: bb[o + 3] = mmd.mmdRbs (a + 3);
8027: bb[o + 4] = mmd.mmdRbs (a + 4);
8028: bb[o + 5] = mmd.mmdRbs (a + 5);
8029: bb[o + 6] = mmd.mmdRbs (a + 6);
8030: bb[o + 7] = mmd.mmdRbs (a + 7);
8031: bb[o + 8] = mmd.mmdRbs (a + 8);
8032: bb[o + 9] = mmd.mmdRbs (a + 9);
8033: bb[o + 10] = mmd.mmdRbs (a + 10);
8034: bb[o + 11] = mmd.mmdRbs (a + 11);
8035: bb[o + 12] = mmd.mmdRbs (a + 12);
8036: bb[o + 13] = mmd.mmdRbs (a + 13);
8037: bb[o + 14] = mmd.mmdRbs (a + 14);
8038: bb[o + 15] = mmd.mmdRbs (a + 15);
8039: a += 16;
8040: o += 16;
8041: }
8042: s += 16;
8043: }
8044: for (int i = 0; i < s; i++) {
8045: bb[o + i] = mmd.mmdRbs (a + i);
8046: }
8047: a += s;
8048: o += s;
8049: r = BUS_PAGE_SIZE;
8050: }
8051: }
8052: }
8053:
8054:
8055:
8056: public static void busWbb (int a, byte[] bb, int o, int l) throws M68kException {
8057: if (false) {
8058: for (int i = 0; i < l; i++) {
8059: int ai = a + i;
8060: if (DataBreakPoint.DBP_ON) {
8061: DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
8062: } else {
8063: busMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
8064: }
8065: }
8066: } else {
8067: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
8068: while (l > 0) {
8069: MemoryMappedDevice mmd;
8070: if (DataBreakPoint.DBP_ON) {
8071: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
8072: } else {
8073: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8074: }
8075: int s = l <= r ? l : r;
8076: l -= s;
8077: if (true) {
8078: for (s -= 16; s >= 0; s -= 16) {
8079: mmd.mmdWb (a , bb[o ]);
8080: mmd.mmdWb (a + 1, bb[o + 1]);
8081: mmd.mmdWb (a + 2, bb[o + 2]);
8082: mmd.mmdWb (a + 3, bb[o + 3]);
8083: mmd.mmdWb (a + 4, bb[o + 4]);
8084: mmd.mmdWb (a + 5, bb[o + 5]);
8085: mmd.mmdWb (a + 6, bb[o + 6]);
8086: mmd.mmdWb (a + 7, bb[o + 7]);
8087: mmd.mmdWb (a + 8, bb[o + 8]);
8088: mmd.mmdWb (a + 9, bb[o + 9]);
8089: mmd.mmdWb (a + 10, bb[o + 10]);
8090: mmd.mmdWb (a + 11, bb[o + 11]);
8091: mmd.mmdWb (a + 12, bb[o + 12]);
8092: mmd.mmdWb (a + 13, bb[o + 13]);
8093: mmd.mmdWb (a + 14, bb[o + 14]);
8094: mmd.mmdWb (a + 15, bb[o + 15]);
8095: a += 16;
8096: o += 16;
8097: }
8098: s += 16;
8099: }
8100: for (int i = 0; i < s; i++) {
8101: mmd.mmdWb (a + i, bb[o + i]);
8102: }
8103: a += s;
8104: o += s;
8105: r = BUS_PAGE_SIZE;
8106: }
8107: }
8108: }
8109:
8110:
8111:
8112: public static void busVb (int a, int d) {
8113: try {
8114: if (DataBreakPoint.DBP_ON) {
8115: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWb (a, d);
8116: } else {
8117: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
8118: }
8119: } catch (M68kException e) {
8120: }
8121: }
8122:
8123:
8124:
8125: public static void busVw (int a, int d) {
8126: try {
8127: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8128: if (DataBreakPoint.DBP_ON) {
8129: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8130: } else {
8131: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
8132: }
8133: }
8134: } catch (M68kException e) {
8135: }
8136: }
8137:
8138:
8139:
8140: public static void busVl (int a, int d) {
8141: try {
8142: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
8143: if (DataBreakPoint.DBP_ON) {
8144: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8145: } else {
8146: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
8147: }
8148: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
8149: int a2 = a + 2;
8150: MemoryMappedDevice mmd;
8151: MemoryMappedDevice mmd2;
8152: if (DataBreakPoint.DBP_ON) {
8153: mmd = (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS];
8154: mmd2 = (regSRS != 0 ? busSuperMap : busUserMap)[a2 >>> BUS_PAGE_BITS];
8155: } else {
8156: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
8157: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
8158: }
8159: if (mmd == mmd2) {
8160: mmd.mmdWl (a, d);
8161: } else {
8162: mmd.mmdWw (a, d >> 16);
8163: mmd2.mmdWw (a2, d);
8164: }
8165: }
8166: } catch (M68kException e) {
8167: }
8168: }
8169:
8170:
8171:
8172:
8173:
8174:
8175:
8176:
8177:
8178:
8179:
8180:
8181:
8182:
8183:
8184:
8185:
8186:
8187:
8188:
8189:
8190:
8191:
8192:
8193:
8194:
8195:
8196:
8197:
8198:
8199:
8200:
8201:
8202:
8203:
8204:
8205:
8206: public static void graInit () {
8207: }
8208:
8209:
8210:
8211:
8212:
8213:
8214:
8215:
8216: public static void txtInit () {
8217: }
8218:
8219:
8220:
8221:
8222:
8223: public static final int SVS_AREASET = 0x00e86001;
8224:
8225:
8226:
8227:
8228:
8229:
8230:
8231:
8232:
8233: public static void svsInit () {
8234: }
8235:
8236:
8237:
8238:
8239:
8240:
8241:
8242:
8243:
8244:
8245:
8246:
8247:
8248:
8249:
8250:
8251:
8252:
8253:
8254:
8255:
8256:
8257:
8258:
8259:
8260:
8261:
8262:
8263:
8264:
8265:
8266:
8267:
8268:
8269:
8270: public static boolean sysNMIFlag;
8271:
8272:
8273:
8274: public static void sysInit () {
8275: sysNMIFlag = false;
8276: }
8277:
8278:
8279:
8280:
8281:
8282:
8283: public static int sysAcknowledge () {
8284: return M68kException.M6E_LEVEL_7_INTERRUPT_AUTOVECTOR;
8285: }
8286:
8287:
8288:
8289:
8290: public static void sysDone () {
8291: if (sysNMIFlag) {
8292: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
8293: }
8294: }
8295:
8296:
8297:
8298: public static void sysInterrupt () {
8299: sysNMIFlag = true;
8300: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
8301: }
8302:
8303:
8304:
8305: public static void sysResetNMI () {
8306: sysNMIFlag = false;
8307: }
8308:
8309:
8310:
8311:
8312:
8313:
8314: public static final int EB2_SPC_REQUEST = 0x4000;
8315: public static final int EB2_SPC_VECTOR = 0xf6;
8316:
8317:
8318:
8319: public static int eb2Request;
8320:
8321:
8322:
8323: public static void eb2Reset () {
8324: eb2Request = 0;
8325: }
8326:
8327:
8328:
8329:
8330:
8331: public static void eb2Interrupt (int mask) {
8332: eb2Request |= mask;
8333: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
8334: }
8335:
8336:
8337:
8338:
8339:
8340:
8341:
8342: public static int eb2Acknowledge () {
8343: if ((eb2Request & EB2_SPC_REQUEST) != 0) {
8344: eb2Request &= ~EB2_SPC_REQUEST;
8345: return EB2_SPC_VECTOR;
8346: }
8347: return 0;
8348: }
8349:
8350:
8351:
8352:
8353:
8354: public static void eb2Done () {
8355: if (eb2Request != 0) {
8356: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
8357: }
8358: }
8359:
8360:
8361:
8362:
8363:
8364:
8365:
8366:
8367:
8368:
8369:
8370:
8371:
8372:
8373:
8374:
8375:
8376:
8377:
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: public static final int BNK_SIZE = 1024 * 1024 * 32;
8445: public static byte[] bnkMemory;
8446: public static int bnkPageStart;
8447: public static boolean bnkOn;
8448:
8449: public static void bnkInit () {
8450: bnkMemory = new byte[BNK_SIZE];
8451: byte[] array = Settings.sgsGetData ("bankdata");
8452: if (array.length != 0) {
8453: System.arraycopy (array, 0, bnkMemory, 0, Math.min (array.length, BNK_SIZE));
8454: }
8455: bnkPageStart = 0;
8456:
8457: bnkOn = false;
8458: }
8459:
8460: public static void bnkTini () {
8461: Settings.sgsPutData ("bankdata", bnkMemory, 0, BNK_SIZE);
8462: }
8463:
8464:
8465:
8466:
8467:
8468:
8469:
8470: public static ExpressionEvaluator fpuMotherboardCoprocessor;
8471: public static ExpressionEvaluator fpuOnChipFPU;
8472: public static ExpressionEvaluator fpuBox;
8473:
8474:
8475: public static EFPBox fpuCoproboard1;
8476: public static EFPBox fpuCoproboard2;
8477:
8478:
8479: public static EFPBox.EFP[] fpuFPn;
8480:
8481:
8482:
8483: public static final int FPU_FPCR_BSUN = 0b00000000_00000000_10000000_00000000;
8484: public static final int FPU_FPCR_SNAN = 0b00000000_00000000_01000000_00000000;
8485: public static final int FPU_FPCR_OPERR = 0b00000000_00000000_00100000_00000000;
8486: public static final int FPU_FPCR_OVFL = 0b00000000_00000000_00010000_00000000;
8487: public static final int FPU_FPCR_UNFL = 0b00000000_00000000_00001000_00000000;
8488: public static final int FPU_FPCR_DZ = 0b00000000_00000000_00000100_00000000;
8489: public static final int FPU_FPCR_INEX2 = 0b00000000_00000000_00000010_00000000;
8490: public static final int FPU_FPCR_INEX1 = 0b00000000_00000000_00000001_00000000;
8491:
8492:
8493: public static final int FPU_FPCR_PE = 0b00000000_00000000_00000000_00000000;
8494: public static final int FPU_FPCR_PS = 0b00000000_00000000_00000000_01000000;
8495: public static final int FPU_FPCR_PD = 0b00000000_00000000_00000000_10000000;
8496:
8497: public static final int FPU_FPCR_RN = 0b00000000_00000000_00000000_00000000;
8498: public static final int FPU_FPCR_RZ = 0b00000000_00000000_00000000_00010000;
8499: public static final int FPU_FPCR_RM = 0b00000000_00000000_00000000_00100000;
8500: public static final int FPU_FPCR_RP = 0b00000000_00000000_00000000_00110000;
8501:
8502:
8503:
8504: public static final int FPU_FPSR_N = 0b00001000_00000000_00000000_00000000;
8505: public static final int FPU_FPSR_Z = 0b00000100_00000000_00000000_00000000;
8506: public static final int FPU_FPSR_I = 0b00000010_00000000_00000000_00000000;
8507: public static final int FPU_FPSR_NAN = 0b00000001_00000000_00000000_00000000;
8508:
8509: public static final int FPU_FPSR_S = 0b00000000_10000000_00000000_00000000;
8510: public static final int FPU_FPSR_QUOTIENT = 0b00000000_01111111_00000000_00000000;
8511:
8512: public static final int FPU_FPSR_EXC_BSUN = 0b00000000_00000000_10000000_00000000;
8513: public static final int FPU_FPSR_EXC_SNAN = 0b00000000_00000000_01000000_00000000;
8514: public static final int FPU_FPSR_EXC_OPERR = 0b00000000_00000000_00100000_00000000;
8515: public static final int FPU_FPSR_EXC_OVFL = 0b00000000_00000000_00010000_00000000;
8516: public static final int FPU_FPSR_EXC_UNFL = 0b00000000_00000000_00001000_00000000;
8517: public static final int FPU_FPSR_EXC_DZ = 0b00000000_00000000_00000100_00000000;
8518: public static final int FPU_FPSR_EXC_INEX2 = 0b00000000_00000000_00000010_00000000;
8519: public static final int FPU_FPSR_EXC_INEX1 = 0b00000000_00000000_00000001_00000000;
8520:
8521: public static final int FPU_FPSR_AEXC_IOP = 0b00000000_00000000_00000000_10000000;
8522: public static final int FPU_FPSR_AEXC_OVFL = 0b00000000_00000000_00000000_01000000;
8523: public static final int FPU_FPSR_AEXC_UNFL = 0b00000000_00000000_00000000_00100000;
8524: public static final int FPU_FPSR_AEXC_DZ = 0b00000000_00000000_00000000_00010000;
8525: public static final int FPU_FPSR_AEXC_INEX = 0b00000000_00000000_00000000_00001000;
8526:
8527:
8528:
8529:
8530:
8531:
8532:
8533: public static final int[] FPU_FPSR_EXC_TO_AEXC = new int[256];
8534:
8535:
8536:
8537:
8538:
8539:
8540:
8541:
8542:
8543:
8544:
8545:
8546:
8547:
8548:
8549:
8550:
8551:
8552:
8553:
8554:
8555:
8556:
8557:
8558: public static final boolean[] FPU_CCMAP_882 = {
8559:
8560:
8561: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
8562: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
8563: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
8564: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
8565: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
8566: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
8567: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
8568: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
8569: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
8570: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
8571: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
8572: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
8573: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
8574: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
8575: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
8576: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
8577:
8578:
8579: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
8580: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
8581: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
8582: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
8583: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
8584: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
8585: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
8586: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
8587: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
8588: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
8589: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
8590: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
8591: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
8592: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
8593: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
8594: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
8595:
8596: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
8597: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
8598: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
8599: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
8600: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
8601: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
8602: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
8603: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
8604: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
8605: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
8606: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
8607: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
8608: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
8609: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
8610: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
8611: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
8612:
8613: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
8614: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
8615: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
8616: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
8617: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
8618: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
8619: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
8620: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
8621: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
8622: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
8623: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
8624: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
8625: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
8626: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
8627: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
8628: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
8629: };
8630:
8631:
8632:
8633:
8634:
8635:
8636:
8637: public static final boolean[] FPU_CCMAP_060 = {
8638:
8639:
8640: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
8641: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
8642: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
8643: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
8644: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
8645: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
8646: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
8647: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
8648: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
8649: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
8650: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
8651: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
8652: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
8653: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
8654: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
8655: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
8656:
8657:
8658: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
8659: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
8660: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
8661: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
8662: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
8663: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
8664: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
8665: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
8666: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
8667: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
8668: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
8669: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
8670: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
8671: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
8672: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
8673: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
8674:
8675: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
8676: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
8677: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
8678: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
8679: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
8680: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
8681: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
8682: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
8683: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
8684: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
8685: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
8686: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
8687: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
8688: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
8689: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
8690: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
8691:
8692: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
8693: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
8694: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
8695: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
8696: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
8697: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
8698: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
8699: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
8700: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
8701: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
8702: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
8703: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
8704: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
8705: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
8706: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
8707: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
8708: };
8709:
8710:
8711:
8712:
8713: public static void fpuInit () {
8714: for (int i = 0; i < 256; i++) {
8715: 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) |
8716: ((i << 8 & FPU_FPSR_EXC_OVFL) != 0 ? FPU_FPSR_AEXC_OVFL : 0) |
8717: ((i << 8 & (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2)) == (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2) ? FPU_FPSR_AEXC_UNFL : 0) |
8718: ((i << 8 & FPU_FPSR_EXC_DZ) != 0 ? FPU_FPSR_AEXC_DZ : 0) |
8719: ((i << 8 & (FPU_FPSR_EXC_OVFL | FPU_FPSR_EXC_INEX2 | FPU_FPSR_EXC_INEX1)) != 0 ? FPU_FPSR_AEXC_INEX : 0));
8720: }
8721:
8722: fpuMotherboardCoprocessor = new ExpressionEvaluator ();
8723:
8724: fpuOnChipFPU = new ExpressionEvaluator ();
8725:
8726: fpuBox = currentMPU < Model.MPU_MC68LC040 ? fpuMotherboardCoprocessor : fpuOnChipFPU;
8727:
8728: fpuFPn = fpuBox.epbFPn;
8729:
8730: fpuCoproboard1 = new EFPBox ();
8731: fpuCoproboard1.epbSetMC68881 ();
8732: fpuCoproboard2 = new EFPBox ();
8733: fpuCoproboard2.epbSetMC68881 ();
8734: }
8735:
8736:
8737:
8738:
8739:
8740:
8741: public static final boolean DBG_ORI_BYTE_ZERO_D0 = true;
8742:
8743: public static boolean dbgHexSelected;
8744: public static int dbgHexValue;
8745: public static int dbgSupervisorMode;
8746: public static JPopupMenu dbgPopupMenu;
8747: public static JMenu dbgPopupIBPMenu;
8748: public static SpinnerNumberModel dbgPopupIBPCurrentModel;
8749: public static int dbgPopupIBPCurrentValue;
8750: public static SpinnerNumberModel dbgPopupIBPThresholdModel;
8751: public static int dbgPopupIBPThresholdValue;
8752: public static JMenuItem dbgPopupIBPClearMenuItem;
8753: public static JMenu dbgPopupHexMenu;
8754: public static JMenuItem dbgPopupDisMenuItem;
8755: public static JMenuItem dbgPopupMemMenuItem;
8756: public static JMenuItem dbgPopupCopyMenuItem;
8757: public static JMenuItem dbgPopupSelectAllMenuItem;
8758: public static JTextArea dbgPopupTextArea;
8759: public static int dbgEventMask;
8760: public static boolean dbgStopOnError;
8761: public static boolean dbgOriByteZeroD0;
8762: public static boolean dbgStopAtStart;
8763:
8764:
8765:
8766: public static final char[] DBG_SPACES = (
8767:
8768:
8769: " ").toCharArray ();
8770:
8771: public static final int DBG_DRP_VISIBLE_MASK = 1;
8772: public static final int DBG_DDP_VISIBLE_MASK = 2;
8773: public static final int DBG_DMP_VISIBLE_MASK = 4;
8774: public static final int DBG_BLG_VISIBLE_MASK = 8;
8775: public static final int DBG_PFV_VISIBLE_MASK = 16;
8776: public static final int DBG_RBP_VISIBLE_MASK = 32;
8777: public static final int DBG_DBP_VISIBLE_MASK = 64;
8778: public static final int DBG_SMT_VISIBLE_MASK = 128;
8779: public static final int DBG_ATW_VISIBLE_MASK = 256;
8780: public static final int DBG_PAA_VISIBLE_MASK = 512;
8781: public static final int DBG_RTL_VISIBLE_MASK = 1024;
8782: public static final int DBG_SPV_VISIBLE_MASK = 2048;
8783: public static final int DBG_ACM_VISIBLE_MASK = 4096;
8784: public static int dbgVisibleMask;
8785:
8786:
8787:
8788: public static void dbgInit () {
8789: dbgVisibleMask = 0;
8790: dbgHexSelected = false;
8791: dbgHexValue = 0;
8792: dbgSupervisorMode = 1;
8793: dbgPopupMenu = null;
8794: dbgPopupDisMenuItem = null;
8795: dbgPopupMemMenuItem = null;
8796: dbgPopupCopyMenuItem = null;
8797: dbgPopupSelectAllMenuItem = null;
8798: dbgPopupIBPMenu = null;
8799: dbgPopupIBPCurrentModel = null;
8800: dbgPopupIBPCurrentValue = 0;
8801: dbgPopupIBPThresholdModel = null;
8802: dbgPopupIBPThresholdValue = 0;
8803: dbgPopupHexMenu = null;
8804: dbgPopupTextArea = null;
8805: dbgEventMask = 0;
8806: dbgStopOnError = false;
8807: if (DBG_ORI_BYTE_ZERO_D0) {
8808: dbgOriByteZeroD0 = false;
8809: }
8810: dbgStopAtStart = false;
8811: }
8812:
8813:
8814:
8815: public static void dbgMakePopup () {
8816:
8817:
8818: ActionListener popupActionListener = new ActionListener () {
8819: @Override public void actionPerformed (ActionEvent ae) {
8820: switch (ae.getActionCommand ()) {
8821: case "Disassemble":
8822: DisassembleList.ddpBacktraceRecord = -1L;
8823: DisassembleList.ddpOpen (dbgHexValue, dbgSupervisorMode, false);
8824: break;
8825: case "Memory Dump":
8826: MemoryDumpList.dmpOpen (dbgHexValue, dbgSupervisorMode, false);
8827: break;
8828: case "Run to Here":
8829: if (InstructionBreakPoint.IBP_ON) {
8830: if (mpuTask == null) {
8831: InstructionBreakPoint.ibpInstant (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
8832: mpuStart ();
8833: }
8834: }
8835: break;
8836: case "Set Breakpoint":
8837: if (InstructionBreakPoint.IBP_ON) {
8838: InstructionBreakPoint.ibpPut (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode, dbgPopupIBPCurrentValue, dbgPopupIBPThresholdValue, null);
8839: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
8840: }
8841: break;
8842: case "Clear Breakpoint":
8843: if (InstructionBreakPoint.IBP_ON) {
8844: InstructionBreakPoint.ibpRemove (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
8845: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
8846: }
8847: break;
8848: case "Copy":
8849: dbgCopy ();
8850: break;
8851: case "Select All":
8852: dbgSelectAll ();
8853: break;
8854: }
8855: }
8856: };
8857: dbgPopupMenu = ComponentFactory.createPopupMenu (
8858: dbgPopupIBPMenu =
8859: InstructionBreakPoint.IBP_ON ?
8860: ComponentFactory.createMenu (
8861: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
8862: Multilingual.mlnText (ComponentFactory.createMenuItem ("Run to Here", 'R', popupActionListener), "ja", "ここまで実行"),
8863: ComponentFactory.createHorizontalSeparator (),
8864: Multilingual.mlnText (ComponentFactory.createMenuItem ("Set Breakpoint", 'S', popupActionListener), "ja", "ブレークポイントを設定"),
8865: ComponentFactory.createHorizontalBox (
8866: Box.createHorizontalStrut (7),
8867: Box.createHorizontalGlue (),
8868: ComponentFactory.setPreferredSize (
8869: Multilingual.mlnText (ComponentFactory.createLabel ("current"), "ja", "現在値"),
8870: 60, 16),
8871: ComponentFactory.createNumberSpinner (dbgPopupIBPCurrentModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
8872: @Override public void stateChanged (ChangeEvent ce) {
8873: dbgPopupIBPCurrentValue = dbgPopupIBPCurrentModel.getNumber ().intValue ();
8874: }
8875: }),
8876: Box.createHorizontalGlue ()
8877: ),
8878: ComponentFactory.createHorizontalBox (
8879: Box.createHorizontalStrut (7),
8880: Box.createHorizontalGlue (),
8881: ComponentFactory.setPreferredSize (
8882: Multilingual.mlnText (ComponentFactory.createLabel ("threshold"), "ja", "閾値"),
8883: 60, 16),
8884: ComponentFactory.createNumberSpinner (dbgPopupIBPThresholdModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
8885: @Override public void stateChanged (ChangeEvent ce) {
8886: dbgPopupIBPThresholdValue = dbgPopupIBPThresholdModel.getNumber ().intValue ();
8887: }
8888: }),
8889: Box.createHorizontalGlue ()
8890: ),
8891: dbgPopupIBPClearMenuItem =
8892: Multilingual.mlnText (ComponentFactory.createMenuItem ("Clear Breakpoint", 'C', popupActionListener), "ja", "ブレークポイントを消去")
8893: ) :
8894: null,
8895: dbgPopupHexMenu =
8896: ComponentFactory.createMenu (
8897: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
8898: dbgPopupDisMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble", 'D', popupActionListener), "ja", "逆アセンブル"),
8899: dbgPopupMemMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory Dump", 'M', popupActionListener), "ja", "メモリダンプ")
8900: ),
8901: dbgPopupCopyMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Copy", 'C', popupActionListener), "ja", "コピー"),
8902: dbgPopupSelectAllMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Select All", 'A', popupActionListener), "ja", "すべて選択")
8903: );
8904:
8905: }
8906:
8907:
8908:
8909: public static void dbgShowPopup (MouseEvent me, JTextArea textArea, boolean dis) {
8910: dbgEventMask++;
8911: int x = me.getX ();
8912: int y = me.getY ();
8913:
8914: int p = textArea.viewToModel2D (me.getPoint ());
8915: DisassembleList.ddpPopupAddress = -1;
8916: if (dis) {
8917: int i = Arrays.binarySearch (DisassembleList.ddpSplitArray, 1, DisassembleList.ddpItemCount, p + 1);
8918: i = (i >> 31 ^ i) - 1;
8919: DisassembleList.ddpPopupAddress = DisassembleList.ddpAddressArray[i];
8920: }
8921: int start = textArea.getSelectionStart ();
8922: int end = textArea.getSelectionEnd ();
8923: String text = textArea.getText ();
8924: int length = text.length ();
8925: if ((start == end ||
8926: p < start || end <= p) &&
8927: 0 <= p && p < length && isWord (text.charAt (p))) {
8928:
8929: for (start = p; 0 < start && isWord (text.charAt (start - 1)); start--) {
8930: }
8931: for (end = p + 1; end < length && isWord (text.charAt (end)); end++) {
8932: }
8933: textArea.select (start, end);
8934: }
8935: dbgHexSelected = false;
8936: if (start < end) {
8937: textArea.requestFocusInWindow ();
8938:
8939:
8940:
8941:
8942:
8943: dbgHexValue = 0;
8944: int n = 0;
8945: for (int i = start; i < end; i++) {
8946: int t;
8947: if ((t = Character.digit (text.charAt (i), 16)) >= 0) {
8948: dbgHexValue = dbgHexValue << 4 | t;
8949: if (n >= 8 ||
8950: i + 1 >= end || (t = Character.digit (text.charAt (i + 1), 16)) < 0) {
8951: n = 0;
8952: break;
8953: }
8954: dbgHexValue = dbgHexValue << 4 | t;
8955: n += 2;
8956: i++;
8957: } else if (isWord (text.charAt (i))) {
8958: n = 0;
8959: break;
8960: }
8961: }
8962: dbgHexSelected = n > 0;
8963: try {
8964:
8965: Rectangle r = textArea.modelToView2D (start).getBounds ();
8966:
8967: Rectangle s = textArea.modelToView2D (end - 1).getBounds ();
8968: if (r.y == s.y) {
8969:
8970: y = r.y + r.height;
8971: }
8972: } catch (BadLocationException ble) {
8973: }
8974: }
8975:
8976: if (InstructionBreakPoint.IBP_ON) {
8977: if (dis && mpuTask == null && DisassembleList.ddpPopupAddress != -1) {
8978: ComponentFactory.setText (dbgPopupIBPMenu, fmtHex8 (DisassembleList.ddpPopupAddress));
8979: TreeMap<Integer,InstructionBreakPoint.InstructionBreakRecord> pointTable = InstructionBreakPoint.ibpPointTable;
8980: InstructionBreakPoint.InstructionBreakRecord r = pointTable.get (DisassembleList.ddpPopupAddress);
8981: if (r != null) {
8982: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = r.ibrValue));
8983: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = r.ibrThreshold));
8984: dbgPopupIBPClearMenuItem.setEnabled (true);
8985: } else {
8986: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = 0));
8987: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = 0));
8988: dbgPopupIBPClearMenuItem.setEnabled (false);
8989: }
8990: ComponentFactory.setVisible (dbgPopupIBPMenu, true);
8991: } else {
8992: ComponentFactory.setVisible (dbgPopupIBPMenu, false);
8993: }
8994: }
8995:
8996: if (dbgHexSelected) {
8997: ComponentFactory.setText (dbgPopupHexMenu, fmtHex8 (dbgHexValue));
8998: ComponentFactory.setVisible (dbgPopupHexMenu, true);
8999: } else {
9000: ComponentFactory.setVisible (dbgPopupHexMenu, false);
9001: }
9002:
9003: ComponentFactory.setEnabled (dbgPopupCopyMenuItem, clpClipboard != null && start < end);
9004:
9005: ComponentFactory.setEnabled (dbgPopupSelectAllMenuItem, clpClipboard != null);
9006:
9007: dbgPopupTextArea = textArea;
9008: dbgPopupMenu.show (textArea, x, y);
9009: dbgEventMask--;
9010: }
9011:
9012: public static boolean isWord (char c) {
9013: return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '_';
9014: }
9015:
9016:
9017:
9018: public static void dbgCopy () {
9019: clpCopy (dbgPopupTextArea.getSelectedText ());
9020: }
9021:
9022:
9023:
9024: public static void dbgSelectAll () {
9025: if (clpClipboard != null) {
9026:
9027: dbgEventMask++;
9028: dbgPopupTextArea.selectAll ();
9029: dbgPopupTextArea.requestFocusInWindow ();
9030: dbgEventMask--;
9031: }
9032: }
9033:
9034:
9035:
9036:
9037: public static void dbgUpdate () {
9038: if ((dbgVisibleMask & DBG_DRP_VISIBLE_MASK) != 0) {
9039: RegisterList.drpUpdate ();
9040: }
9041: if (ProgramFlowVisualizer.PFV_ON) {
9042: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
9043: if (ProgramFlowVisualizer.pfvTimer == 0) {
9044: ProgramFlowVisualizer.pfvUpdate ();
9045: } else {
9046: ProgramFlowVisualizer.pfvTimer--;
9047: }
9048: }
9049: }
9050: if (RasterBreakPoint.RBP_ON) {
9051: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
9052: if (RasterBreakPoint.rbpTimer == 0) {
9053: RasterBreakPoint.rbpUpdateFrame ();
9054: } else {
9055: RasterBreakPoint.rbpTimer--;
9056: }
9057: }
9058: }
9059: if (ScreenModeTest.SMT_ON) {
9060: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
9061: if (ScreenModeTest.smtTimer == 0) {
9062: ScreenModeTest.smtUpdateFrame ();
9063: } else {
9064: ScreenModeTest.smtTimer--;
9065: }
9066: }
9067: }
9068: if (RootPointerList.RTL_ON) {
9069: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
9070: if (RootPointerList.rtlTimer == 0) {
9071: RootPointerList.rtlTimer = RootPointerList.RTL_INTERVAL - 1;
9072: RootPointerList.rtlUpdateFrame ();
9073: } else {
9074: RootPointerList.rtlTimer--;
9075: }
9076: }
9077: }
9078: if (SpritePatternViewer.SPV_ON) {
9079: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
9080: if (SpritePatternViewer.spvTimer == 0) {
9081: SpritePatternViewer.spvTimer = SpritePatternViewer.SPV_INTERVAL - 1;
9082: SpritePatternViewer.spvUpdateFrame ();
9083: } else {
9084: SpritePatternViewer.spvTimer--;
9085: }
9086: }
9087: }
9088: if (ATCMonitor.ACM_ON) {
9089: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
9090: if (ATCMonitor.acmTimer == 0) {
9091: ATCMonitor.acmTimer = ATCMonitor.ACM_INTERVAL - 1;
9092: ATCMonitor.acmUpdateFrame ();
9093: } else {
9094: ATCMonitor.acmTimer--;
9095: }
9096: }
9097: }
9098: }
9099:
9100:
9101:
9102:
9103:
9104:
9105:
9106:
9107:
9108:
9109:
9110:
9111:
9112:
9113:
9114:
9115:
9116:
9117:
9118:
9119:
9120:
9121: public static boolean dbgDoStopOnError () {
9122: if (MainMemory.mmrHumanVersion <= 0) {
9123: return true;
9124: }
9125: if ((regOC & 0xff00) == 0xff00 &&
9126: M68kException.m6eNumber == M68kException.M6E_PRIVILEGE_VIOLATION) {
9127: return false;
9128: }
9129: String message = (
9130: M68kException.m6eNumber < 0 ?
9131: fmtHex8 (new StringBuilder ("breaked").append (" at "), regPC0).toString () :
9132: M68kException.m6eNumber <= M68kException.M6E_ADDRESS_ERROR ?
9133: fmtHex8 (fmtHex8 (new StringBuilder ("ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
9134: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
9135: .append (" at "), regPC0).toString () :
9136: fmtHex8 (new StringBuilder (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
9137: .append (" at "), regPC0).toString ()
9138: );
9139: System.out.println (message);
9140: if (!(M68kException.m6eNumber == M68kException.M6E_ACCESS_FAULT &&
9141: 0x0000e100 <= regPC0 && regPC0 < 0x0000e500)) {
9142: mpuStop (message);
9143: return true;
9144: }
9145: return false;
9146: }
9147:
9148:
9149:
9150: public static void dbgDoubleBusFault () {
9151: String message =
9152: fmtHex8 (fmtHex8 (new StringBuilder ("FATAL ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
9153: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
9154: .append (" at "), regPC0).toString ();
9155: System.out.println (message);
9156: mpuStop (message);
9157: }
9158:
9159:
9160:
9161:
9162:
9163:
9164: public static final HashMap<String,byte[]> rscResourceCache = new HashMap<String,byte[]> ();
9165:
9166:
9167:
9168:
9169:
9170:
9171: public static byte[] rscGetResource (String name, int... sizes) {
9172: byte[] array = rscResourceCache.get (name);
9173: if (array != null) {
9174: return array;
9175: }
9176: array = new byte[1024 * 64];
9177: int size = 0;
9178: try (BufferedInputStream bis = new BufferedInputStream (XEiJ.class.getResourceAsStream ("../data/" + name))) {
9179: for (;;) {
9180: if (size == array.length) {
9181: byte[] newArray = new byte[array.length * 2];
9182: System.arraycopy (array, 0, newArray, 0, size);
9183: array = newArray;
9184: }
9185: int step = bis.read (array, size, array.length - size);
9186: if (step == -1) {
9187: break;
9188: }
9189: size += step;
9190: }
9191: if (size < array.length) {
9192: byte[] newArray = new byte[size];
9193: System.arraycopy (array, 0, newArray, 0, size);
9194: array = newArray;
9195: }
9196: boolean fit = sizes.length == 0;
9197: if (!fit) {
9198: for (int i = 0; i < sizes.length; i++) {
9199: if (size == sizes[i]) {
9200: fit = true;
9201: break;
9202: }
9203: }
9204: }
9205: if (fit) {
9206: System.out.println (Multilingual.mlnJapanese ?
9207: name + " を読み込みました" :
9208: name + " was read");
9209: rscResourceCache.put (name, array);
9210: return array;
9211: }
9212: System.out.println (Multilingual.mlnJapanese ?
9213: name + " のサイズが違います" :
9214: name + " has wrong size");
9215: return null;
9216: } catch (IOException ioe) {
9217: }
9218:
9219: System.out.println (Multilingual.mlnJapanese ?
9220: name + " を読み込めません" :
9221: name + " cannot be read");
9222: return null;
9223: }
9224:
9225:
9226:
9227: public static String rscGetResourceText (String name) {
9228: return rscGetResourceText (name, "UTF-8");
9229: }
9230: public static String rscGetResourceText (String name, String charset) {
9231: byte[] array = rscGetResource (name);
9232: if (name != null) {
9233: try {
9234: return new String (array, charset);
9235: } catch (UnsupportedEncodingException uee) {
9236: }
9237: }
9238: return "";
9239: }
9240:
9241: public static final Pattern RSC_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
9242: public static String rscLastFileName = null;
9243:
9244:
9245:
9246:
9247:
9248:
9249: public static byte[] rscGetFile (String names, int... sizes) {
9250: for (String name : names.split (",")) {
9251: name = name.trim ();
9252: if (name.length () == 0 || name.equalsIgnoreCase ("none")) {
9253: continue;
9254: }
9255: String[] zipSplittedName = RSC_ZIP_SEPARATOR.split (name, 2);
9256: InputStream is = null;
9257: if (zipSplittedName.length < 2) {
9258: File file = new File (name);
9259: if (file.isFile ()) {
9260: try {
9261: is = new FileInputStream (file);
9262: } catch (IOException ioe) {
9263: }
9264: } else {
9265: System.out.println (Multilingual.mlnJapanese ?
9266: name + " がありません" :
9267: name + " does not exist");
9268: continue;
9269: }
9270: } else {
9271: String zipName = zipSplittedName[0];
9272: String entryName = zipSplittedName[1];
9273: if (new File (zipName).isFile ()) {
9274: try {
9275: ZipFile zipFile = new ZipFile (zipName);
9276: ZipEntry zipEntry = zipFile.getEntry (entryName);
9277: if (zipEntry != null) {
9278: is = zipFile.getInputStream (zipEntry);
9279: } else {
9280: System.out.println (Multilingual.mlnJapanese ?
9281: zipName + " に " + zipEntry + " がありません" :
9282: zipName + " does not include " + zipEntry);
9283: }
9284: } catch (IOException ioe) {
9285: }
9286: } else {
9287: System.out.println (Multilingual.mlnJapanese ?
9288: zipName + " がありません" :
9289: zipName + " does not exist");
9290: continue;
9291: }
9292: }
9293: if (is != null) {
9294: try {
9295: is = new BufferedInputStream (is);
9296: if (name.toLowerCase ().endsWith (".gz")) {
9297: is = new GZIPInputStream (is);
9298: }
9299: byte[] array = new byte[1024 * 64];
9300: int size = 0;
9301: for (;;) {
9302: if (size == array.length) {
9303: byte[] newArray = new byte[array.length * 2];
9304: System.arraycopy (array, 0, newArray, 0, size);
9305: array = newArray;
9306: }
9307: int step = is.read (array, size, array.length - size);
9308: if (step == -1) {
9309: break;
9310: }
9311: size += step;
9312: }
9313: is.close ();
9314: is = null;
9315: if (size < array.length) {
9316: byte[] newArray = new byte[size];
9317: System.arraycopy (array, 0, newArray, 0, size);
9318: array = newArray;
9319: }
9320: boolean fit = sizes.length == 0;
9321: if (!fit) {
9322: for (int i = 0; i < sizes.length; i++) {
9323: if (size == sizes[i]) {
9324: fit = true;
9325: break;
9326: }
9327: }
9328: }
9329: if (fit) {
9330: System.out.println (Multilingual.mlnJapanese ?
9331: name + " を読み込みました" :
9332: name + " was read");
9333: rscLastFileName = name;
9334: return array;
9335: }
9336: System.out.println (Multilingual.mlnJapanese ?
9337: name + " のサイズが違います" :
9338: name + " has wrong size");
9339: continue;
9340: } catch (IOException ioe) {
9341: }
9342: if (is != null) {
9343: try {
9344: is.close ();
9345: is = null;
9346: } catch (IOException ioe) {
9347: }
9348: }
9349: }
9350: System.out.println (Multilingual.mlnJapanese ?
9351: name + " を読み込めません" :
9352: name + " cannot be read");
9353: }
9354:
9355:
9356:
9357: return null;
9358: }
9359:
9360:
9361:
9362:
9363: public static String rscGetTextFile (String name) {
9364: return rscGetTextFile (name, "UTF-8");
9365: }
9366: public static String rscGetTextFile (String name, String charset) {
9367: byte[] array = rscGetFile (name);
9368: if (array != null) {
9369: try {
9370: return new String (array, charset);
9371: } catch (UnsupportedEncodingException uee) {
9372: }
9373: }
9374: return "";
9375: }
9376:
9377:
9378:
9379: public static final int RSC_A_MASK = 1;
9380: public static final int RSC_R_MASK = 2;
9381: public static final int RSC_I_MASK = 4;
9382: public static final String RSC_A_EN = "Abort";
9383: public static final String RSC_R_EN = "Retry";
9384: public static final String RSC_I_EN = "Ignore";
9385: public static final String RSC_A_JA = "中止";
9386: public static final String RSC_R_JA = "再実行";
9387: public static final String RSC_I_JA = "無視";
9388: public static final String[][] RSC_EN_OPTIONS = {
9389: { RSC_A_EN },
9390: { RSC_A_EN },
9391: { RSC_R_EN },
9392: { RSC_A_EN, RSC_R_EN },
9393: { RSC_I_EN },
9394: { RSC_A_EN, RSC_I_EN },
9395: { RSC_R_EN, RSC_I_EN },
9396: { RSC_A_EN, RSC_R_EN, RSC_I_EN },
9397: };
9398: public static final String[][] RSC_JA_OPTIONS = {
9399: { RSC_A_JA },
9400: { RSC_A_JA },
9401: { RSC_R_JA },
9402: { RSC_A_JA, RSC_R_JA },
9403: { RSC_I_JA },
9404: { RSC_A_JA, RSC_I_JA },
9405: { RSC_R_JA, RSC_I_JA },
9406: { RSC_A_JA, RSC_R_JA, RSC_I_JA },
9407: };
9408: public static int rscShowError (String message, int mask) {
9409: System.out.println (message);
9410: mask &= RSC_A_MASK | RSC_R_MASK | RSC_I_MASK;
9411: if (mask == 0) {
9412: mask = RSC_A_MASK;
9413: }
9414: String[] options = (Multilingual.mlnJapanese ? RSC_JA_OPTIONS : RSC_EN_OPTIONS)[mask];
9415: int def = Integer.numberOfTrailingZeros (mask);
9416: pnlExitFullScreen (true);
9417: int bit = JOptionPane.showOptionDialog (
9418: null,
9419: message,
9420: Multilingual.mlnJapanese ? "ファイル操作エラー" : "File operation error",
9421: JOptionPane.YES_NO_CANCEL_OPTION,
9422: JOptionPane.ERROR_MESSAGE,
9423: null,
9424: options,
9425: options[def]);
9426: if (bit == JOptionPane.CLOSED_OPTION) {
9427: bit = def;
9428: }
9429: return 1 << bit;
9430: }
9431:
9432:
9433:
9434:
9435:
9436:
9437: public static boolean rscPutTextFile (String name, String string) {
9438: return rscPutTextFile (name, string, "UTF-8");
9439: }
9440: public static boolean rscPutTextFile (String name, ArrayList<String> strings) {
9441: return rscPutTextFile (name, strings, "UTF-8");
9442: }
9443: public static boolean rscPutTextFile (String name, String string, String charset) {
9444: ArrayList<String> strings = new ArrayList<String> ();
9445: strings.add (string);
9446: return rscPutTextFile (name, strings, charset);
9447: }
9448: public static boolean rscPutTextFile (String name, ArrayList<String> strings, String charset) {
9449: String nameTmp = name + ".tmp";
9450: String nameBak = name + ".bak";
9451: File file = new File (name);
9452: File fileTmp = new File (nameTmp);
9453: File fileBak = new File (nameBak);
9454:
9455: File parentDirectory = file.getParentFile ();
9456: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
9457: if (!parentDirectory.mkdirs ()) {
9458: System.out.println (parentDirectory.getPath () + (Multilingual.mlnJapanese ? " を作れません" : " cannot be created"));
9459: return false;
9460: }
9461: }
9462:
9463: if (fileTmp.exists ()) {
9464: if (!fileTmp.delete ()) {
9465: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
9466: return false;
9467: }
9468: }
9469:
9470: try (BufferedWriter bw = new BufferedWriter (new FileWriter (nameTmp, Charset.forName (charset)))) {
9471: for (String string : strings) {
9472: bw.write (string);
9473: }
9474: } catch (IOException ioe) {
9475: ioe.printStackTrace ();
9476: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " に書き出せません" : " cannot be written"));
9477: return false;
9478: }
9479:
9480: boolean fileExists = file.exists ();
9481: if (fileExists) {
9482:
9483: if (fileBak.exists ()) {
9484: if (!fileBak.delete ()) {
9485: System.out.println (nameBak + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
9486: return false;
9487: }
9488: }
9489:
9490: if (!file.renameTo (fileBak)) {
9491: System.out.println (name + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + nameBak + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
9492: return false;
9493: }
9494: }
9495:
9496: if (!fileTmp.renameTo (file)) {
9497: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + name + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
9498: return false;
9499: }
9500: if (fileExists) {
9501: System.out.println (name + (Multilingual.mlnJapanese ? " を更新しました" : " was updated"));
9502: } else {
9503: System.out.println (name + (Multilingual.mlnJapanese ? " を作りました" : " was created"));
9504: }
9505: return true;
9506: }
9507:
9508:
9509:
9510:
9511:
9512:
9513:
9514:
9515:
9516: public static boolean rscPutFile (String name, byte[] array) {
9517: return rscPutFile (name, array, 0, array.length, (long) array.length);
9518: }
9519: public static boolean rscPutFile (String name, byte[] array, int offset, int length) {
9520: return rscPutFile (name, array, offset, length, (long) length);
9521: }
9522: public static boolean rscPutFile (String name, byte[] array, int offset, int length, long longLength2) {
9523: if (RSC_ZIP_SEPARATOR.matcher (name).matches ()) {
9524:
9525: return false;
9526: }
9527: File file = new File (name);
9528: boolean fileExists = file.isFile ();
9529: if (fileExists && file.length () == longLength2) {
9530: comparison:
9531: {
9532: try (BufferedInputStream bis = new BufferedInputStream (new FileInputStream (file))) {
9533: byte[] buffer = new byte[(int) Math.min (Math.max ((long) length, longLength2 - (long) length), (long) (1024 * 1024))];
9534: int position = 0;
9535: while (position < length) {
9536: int step = bis.read (buffer, 0, Math.min (buffer.length, length - position));
9537: if (step == -1) {
9538: break comparison;
9539: }
9540: int offsetPosition = offset + position;
9541: for (int i = 0; i < step; i++) {
9542: if (buffer[i] != array[offsetPosition + i]) {
9543: break comparison;
9544: }
9545: }
9546: position += step;
9547: }
9548: long longPosition2 = (long) length;
9549: while (longPosition2 < longLength2) {
9550: int step = bis.read (buffer, 0, (int) Math.min ((long) buffer.length, longLength2 - longPosition2));
9551: if (step == -1) {
9552: break comparison;
9553: }
9554: for (int i = 0; i < step; i++) {
9555: if (buffer[i] != 0) {
9556: break comparison;
9557: }
9558: }
9559: longPosition2 += (long) step;
9560: }
9561: return true;
9562: } catch (IOException ioe) {
9563: }
9564: }
9565: }
9566: String nameTmp = name + ".tmp";
9567: File fileTmp = new File (nameTmp);
9568: String nameBak = name + ".bak";
9569: File fileBak = new File (nameBak);
9570: retry:
9571: for (;;) {
9572: File parentDirectory = file.getParentFile ();
9573: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
9574: String parentName = parentDirectory.getPath ();
9575: if (parentDirectory.mkdirs ()) {
9576: System.out.println (Multilingual.mlnJapanese ?
9577: parentName + " を作りました" :
9578: parentName + " was created");
9579: } else {
9580: switch (rscShowError (Multilingual.mlnJapanese ?
9581: parentName + " を作れません" :
9582: parentName + " cannot be created",
9583: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
9584: case RSC_A_MASK:
9585: break retry;
9586: case RSC_R_MASK:
9587: continue retry;
9588: }
9589: }
9590: }
9591: if (fileTmp.isFile ()) {
9592: if (!fileTmp.delete ()) {
9593: switch (rscShowError (Multilingual.mlnJapanese ?
9594: nameTmp + " を削除できません" :
9595: nameTmp + " cannot be deleted",
9596: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
9597: case RSC_A_MASK:
9598: break retry;
9599: case RSC_R_MASK:
9600: continue retry;
9601: }
9602: }
9603: }
9604: try (OutputStream os = name.toLowerCase ().endsWith (".gz") ?
9605: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
9606: {
9607:
9608: def.setLevel (Deflater.DEFAULT_COMPRESSION);
9609:
9610: }
9611: } :
9612: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
9613:
9614: os.write (array, offset, length);
9615:
9616:
9617: if ((long) length < longLength2) {
9618: byte[] buffer = new byte[(int) Math.min (longLength2 - (long) length, (long) (1024 * 1024))];
9619: Arrays.fill (buffer, 0, buffer.length, (byte) 0);
9620: long longPosition2 = (long) length;
9621: while (longPosition2 < longLength2) {
9622: int step = (int) Math.min ((long) buffer.length, longLength2 - longPosition2);
9623: os.write (buffer, 0, step);
9624: longPosition2 += (long) step;
9625: }
9626: }
9627: } catch (IOException ioe) {
9628: switch (rscShowError (Multilingual.mlnJapanese ?
9629: nameTmp + " に書き出せません" :
9630: nameTmp + " cannot be written",
9631: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
9632: case RSC_A_MASK:
9633: break retry;
9634: case RSC_R_MASK:
9635: continue retry;
9636: }
9637: }
9638: if (fileExists && file.isFile ()) {
9639: if (fileBak.isFile ()) {
9640: if (!fileBak.delete ()) {
9641: switch (rscShowError (Multilingual.mlnJapanese ?
9642: nameBak + " を削除できません" :
9643: nameBak + " cannot be deleted",
9644: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
9645: case RSC_A_MASK:
9646: break retry;
9647: case RSC_R_MASK:
9648: continue retry;
9649: }
9650: }
9651: }
9652: if (!file.renameTo (fileBak)) {
9653: switch (rscShowError (Multilingual.mlnJapanese ?
9654: name + " を " + nameBak + " にリネームできません" :
9655: name + " cannot be renamed to " + nameBak,
9656: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
9657: case RSC_A_MASK:
9658: break retry;
9659: case RSC_R_MASK:
9660: continue retry;
9661: }
9662: }
9663: }
9664: if (fileTmp.renameTo (file)) {
9665: if (fileExists) {
9666: System.out.println (Multilingual.mlnJapanese ?
9667: name + " を更新しました" :
9668: name + " was updated");
9669: } else {
9670: System.out.println (Multilingual.mlnJapanese ?
9671: name + " を作りました" :
9672: name + " was created");
9673: }
9674: return true;
9675: } else {
9676: switch (rscShowError (Multilingual.mlnJapanese ?
9677: nameTmp + " を " + name + " にリネームできません" :
9678: nameTmp + " cannot be renamed to " + name,
9679: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
9680: case RSC_A_MASK:
9681: break retry;
9682: case RSC_R_MASK:
9683: continue retry;
9684: }
9685: }
9686: break;
9687: }
9688: if (fileExists) {
9689: System.out.println (Multilingual.mlnJapanese ?
9690: name + " を更新できません" :
9691: name + " cannot be updated");
9692: } else {
9693: System.out.println (Multilingual.mlnJapanese ?
9694: name + " を作れません" :
9695: name + " cannot be created");
9696: }
9697: return false;
9698: }
9699:
9700:
9701:
9702:
9703:
9704:
9705: public static final Pattern ISM_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
9706:
9707:
9708:
9709:
9710:
9711:
9712:
9713:
9714:
9715:
9716:
9717: public static InputStream ismOpen (String name) {
9718: InputStream in = null;
9719: in = ismOpen (name, false);
9720: if (in == null && name.indexOf ('/') < 0 && name.indexOf ('\\') < 0) {
9721: in = ismOpen (name, true);
9722: }
9723: return in;
9724: }
9725: public static InputStream ismOpen (String name, boolean useGetResource) {
9726: boolean gzipped = name.toLowerCase ().endsWith (".gz");
9727: String[] zipSplittedName = ISM_ZIP_SEPARATOR.split (name, 2);
9728: String fileName = zipSplittedName[0];
9729: String zipEntryName = zipSplittedName.length < 2 ? null : zipSplittedName[1];
9730: InputStream in = null;
9731: try {
9732: if (useGetResource) {
9733: if (false) {
9734: URL url = XEiJ.class.getResource (fileName);
9735: if (url != null) {
9736: in = url.openStream ();
9737: }
9738: } else {
9739: in = XEiJ.class.getResourceAsStream (fileName);
9740: }
9741: } else {
9742: File file = new File (fileName);
9743: if (file.exists ()) {
9744: in = new FileInputStream (file);
9745: }
9746: }
9747: if (in != null && zipEntryName != null) {
9748: ZipInputStream zin = new ZipInputStream (in);
9749: in = null;
9750: ZipEntry entry;
9751: while ((entry = zin.getNextEntry ()) != null) {
9752: if (zipEntryName.equals (entry.getName ())) {
9753: in = zin;
9754: break;
9755: }
9756: }
9757: if (in == null) {
9758: System.out.println (Multilingual.mlnJapanese ? fileName + " の中に " + zipEntryName + " がありません" :
9759: zipEntryName + " does not exist in " + fileName);
9760: }
9761: }
9762: if (in != null && gzipped) {
9763: in = new GZIPInputStream (in);
9764: }
9765: if (in != null) {
9766: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " を読み込みます" :
9767: (useGetResource ? "Reading resource file " : "Reading file ") + name);
9768: return new BufferedInputStream (in);
9769: }
9770: } catch (Exception ioe) {
9771: if (prgVerbose) {
9772: prgPrintStackTraceOf (ioe);
9773: }
9774: }
9775: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " が見つかりません" :
9776: (useGetResource ? "Resource file " : "File ") + name + " is not found");
9777: return null;
9778: }
9779:
9780:
9781:
9782:
9783:
9784:
9785:
9786:
9787: public static int ismRead (InputStream in, byte[] bb, int o, int l) {
9788: try {
9789: int k = 0;
9790: while (k < l) {
9791: int t = in.read (bb, o + k, l - k);
9792: if (t < 0) {
9793: break;
9794: }
9795: k += t;
9796: }
9797: return k;
9798: } catch (IOException ioe) {
9799: if (prgVerbose) {
9800: prgPrintStackTraceOf (ioe);
9801: }
9802: }
9803: return -1;
9804: }
9805:
9806:
9807:
9808:
9809:
9810:
9811:
9812:
9813: public static int ismSkip (InputStream in, int l) {
9814: try {
9815: int k = 0;
9816: while (k < l) {
9817:
9818:
9819: if (in.read () < 0) {
9820: break;
9821: }
9822: k++;
9823: if (k < l) {
9824: int t = (int) in.skip ((long) (l - k));
9825: if (t < 0) {
9826: break;
9827: }
9828: k += t;
9829: }
9830: }
9831: return k;
9832: } catch (IOException ioe) {
9833: if (prgVerbose) {
9834: prgPrintStackTraceOf (ioe);
9835: }
9836: }
9837: return -1;
9838: }
9839:
9840:
9841:
9842:
9843:
9844: public static void ismClose (InputStream in) {
9845: try {
9846: if (in != null) {
9847: in.close ();
9848: }
9849: } catch (IOException ioe) {
9850: if (prgVerbose) {
9851: prgPrintStackTraceOf (ioe);
9852: }
9853: }
9854: }
9855:
9856:
9857:
9858:
9859:
9860:
9861: public static int ismLength (String name, int maxLength) {
9862: int length;
9863: InputStream in = ismOpen (name);
9864: if (in == null) {
9865: length = -1;
9866: } else {
9867: length = ismSkip (in, maxLength);
9868: ismClose (in);
9869: }
9870: return length;
9871: }
9872:
9873:
9874:
9875:
9876:
9877:
9878:
9879:
9880:
9881:
9882:
9883:
9884:
9885:
9886: public static boolean ismLoad (byte[] bb, int o, int l, String names) {
9887: for (String name : names.split (",")) {
9888: if (name.length () != 0) {
9889: InputStream in = ismOpen (name);
9890: if (in != null) {
9891: int k = ismRead (in, bb, o, l);
9892: ismClose (in);
9893: if (k == l) {
9894: return true;
9895: }
9896: }
9897: }
9898: }
9899: return false;
9900: }
9901:
9902:
9903:
9904:
9905:
9906:
9907:
9908:
9909:
9910: public static boolean ismSave (byte[] bb, int offset, long length, String path, boolean verbose) {
9911: if (ISM_ZIP_SEPARATOR.split (path, 2).length != 1) {
9912: if (verbose) {
9913: pnlExitFullScreen (true);
9914: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? path + " に書き出せません" : "Cannot write " + path);
9915: }
9916: return false;
9917: }
9918: long step = 0;
9919: byte[] zz = null;
9920: long pointer = (long) (bb.length - offset);
9921: if (pointer < length) {
9922: step = Math.min (1024L * 512, length - pointer);
9923: zz = new byte[(int) step];
9924: Arrays.fill (zz, (byte) 0);
9925: }
9926:
9927: File file = new File (path);
9928:
9929: if (step == 0 &&
9930: file.exists () && file.length () == length) {
9931:
9932: if (length == 0L) {
9933: return true;
9934: }
9935: InputStream in = ismOpen (path);
9936: if (in != null) {
9937: int l = (int) length;
9938: byte[] tt = new byte[l];
9939: int k = ismRead (in, tt, 0, l);
9940: ismClose (in);
9941: if (k == l &&
9942: Arrays.equals (tt, bb.length == l ? bb : Arrays.copyOfRange (bb, offset, offset + l))) {
9943: return true;
9944: }
9945: }
9946: }
9947:
9948: String pathTmp = path + ".tmp";
9949: String pathBak = path + ".bak";
9950: File fileTmp = new File (pathTmp);
9951: File fileBak = new File (pathBak);
9952:
9953: if (fileTmp.exists ()) {
9954: if (!fileTmp.delete ()) {
9955: if (verbose) {
9956: pnlExitFullScreen (true);
9957: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " を削除できません" : "Cannot delete " + pathTmp);
9958: }
9959: return false;
9960: }
9961: }
9962:
9963: try (OutputStream out = path.toLowerCase ().endsWith (".gz") ?
9964: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
9965: {
9966:
9967: def.setLevel (Deflater.DEFAULT_COMPRESSION);
9968:
9969: }
9970: } :
9971: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
9972: if (step == 0) {
9973: out.write (bb, offset, (int) length);
9974: } else {
9975: out.write (bb, offset, (int) pointer);
9976: for (; pointer < length; pointer += step) {
9977: out.write (zz, 0, (int) Math.min (step, length - pointer));
9978: }
9979: }
9980: } catch (IOException ioe) {
9981: if (verbose) {
9982: prgPrintStackTraceOf (ioe);
9983: pnlExitFullScreen (true);
9984: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " に書き出せません" : "Cannot write " + pathTmp);
9985: }
9986: return false;
9987: }
9988:
9989:
9990: if (file.exists ()) {
9991: if (fileBak.exists ()) {
9992: if (!fileBak.delete ()) {
9993: if (verbose) {
9994: pnlExitFullScreen (true);
9995: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathBak + " を削除できません" : "Cannot delete " + pathBak);
9996: }
9997: return false;
9998: }
9999: }
10000: if (!file.renameTo (fileBak)) {
10001: if (verbose) {
10002: pnlExitFullScreen (true);
10003: JOptionPane.showMessageDialog (
10004: null, Multilingual.mlnJapanese ? path + " を " + pathBak + " にリネームできません" : "Cannot rename " + path + " to " + pathBak);
10005: }
10006: return false;
10007: }
10008: }
10009:
10010:
10011: if (!fileTmp.renameTo (file)) {
10012: if (verbose) {
10013: pnlExitFullScreen (true);
10014: JOptionPane.showMessageDialog (
10015: null, Multilingual.mlnJapanese ? pathTmp + " を " + path + " にリネームできません" : "Cannot rename " + pathTmp + " to " + path);
10016: }
10017: return false;
10018: }
10019: return true;
10020: }
10021:
10022:
10023:
10024:
10025:
10026:
10027:
10028: public static final char[] FMT_TEMP = new char[32];
10029:
10030:
10031:
10032:
10033:
10034:
10035:
10036:
10037:
10038:
10039:
10040: public static final char[] FMT_AIN4_BASE = ".......*..*...**.*...*.*.**..****...*..**.*.*.****..**.****.****".toCharArray ();
10041: public static final char[] FMT_BIN4_BASE = "0000000100100011010001010110011110001001101010111100110111101111".toCharArray ();
10042:
10043:
10044:
10045:
10046:
10047:
10048:
10049:
10050: public static void fmtAin4 (char[] a, int o, int x) {
10051: a[o ] = (char) (x >> 1 & 4 ^ 46);
10052: a[o + 1] = (char) (x & 4 ^ 46);
10053: a[o + 2] = (char) (x << 1 & 4 ^ 46);
10054: a[o + 3] = (char) (x << 2 & 4 ^ 46);
10055: }
10056: public static void fmtBin4 (char[] a, int o, int x) {
10057: a[o ] = (char) (x >>> 3 & 1 | 48);
10058: a[o + 1] = (char) (x >>> 2 & 1 | 48);
10059: a[o + 2] = (char) (x >>> 1 & 1 | 48);
10060: a[o + 3] = (char) (x & 1 | 48);
10061: }
10062: public static String fmtAin4 (int x) {
10063: return String.valueOf (FMT_AIN4_BASE, (x & 15) << 2, 4);
10064: }
10065: public static String fmtBin4 (int x) {
10066: return String.valueOf (FMT_BIN4_BASE, (x & 15) << 2, 4);
10067: }
10068: public static StringBuilder fmtAin4 (StringBuilder sb, int x) {
10069: return sb.append (FMT_AIN4_BASE, (x & 15) << 2, 6);
10070: }
10071: public static StringBuilder fmtBin4 (StringBuilder sb, int x) {
10072: return sb.append (FMT_BIN4_BASE, (x & 15) << 2, 6);
10073: }
10074:
10075:
10076:
10077:
10078:
10079:
10080:
10081:
10082: public static void fmtAin6 (char[] a, int o, int x) {
10083: a[o ] = (char) (x >> 3 & 4 ^ 46);
10084: a[o + 1] = (char) (x >> 2 & 4 ^ 46);
10085: a[o + 2] = (char) (x >> 1 & 4 ^ 46);
10086: a[o + 3] = (char) (x & 4 ^ 46);
10087: a[o + 4] = (char) (x << 1 & 4 ^ 46);
10088: a[o + 5] = (char) (x << 2 & 4 ^ 46);
10089: }
10090: public static void fmtBin6 (char[] a, int o, int x) {
10091: a[o ] = (char) (x >>> 5 & 1 | 48);
10092: a[o + 1] = (char) (x >>> 4 & 1 | 48);
10093: a[o + 2] = (char) (x >>> 3 & 1 | 48);
10094: a[o + 3] = (char) (x >>> 2 & 1 | 48);
10095: a[o + 4] = (char) (x >>> 1 & 1 | 48);
10096: a[o + 5] = (char) (x & 1 | 48);
10097: }
10098: public static String fmtAin6 (int x) {
10099: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
10100: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
10101: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
10102: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
10103: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
10104: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
10105: return String.valueOf (FMT_TEMP, 0, 6);
10106: }
10107: public static String fmtBin6 (int x) {
10108: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
10109: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
10110: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
10111: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
10112: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
10113: FMT_TEMP[ 5] = (char) (x & 1 | 48);
10114: return String.valueOf (FMT_TEMP, 0, 6);
10115: }
10116: public static StringBuilder fmtAin6 (StringBuilder sb, int x) {
10117: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
10118: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
10119: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
10120: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
10121: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
10122: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
10123: return sb.append (FMT_TEMP, 0, 6);
10124: }
10125: public static StringBuilder fmtBin6 (StringBuilder sb, int x) {
10126: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
10127: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
10128: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
10129: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
10130: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
10131: FMT_TEMP[ 5] = (char) (x & 1 | 48);
10132: return sb.append (FMT_TEMP, 0, 6);
10133: }
10134:
10135:
10136:
10137:
10138:
10139:
10140:
10141:
10142: public static void fmtAin8 (char[] a, int o, int x) {
10143: a[o ] = (char) (x >> 5 & 4 ^ 46);
10144: a[o + 1] = (char) (x >> 4 & 4 ^ 46);
10145: a[o + 2] = (char) (x >> 3 & 4 ^ 46);
10146: a[o + 3] = (char) (x >> 2 & 4 ^ 46);
10147: a[o + 4] = (char) (x >> 1 & 4 ^ 46);
10148: a[o + 5] = (char) (x & 4 ^ 46);
10149: a[o + 6] = (char) (x << 1 & 4 ^ 46);
10150: a[o + 7] = (char) (x << 2 & 4 ^ 46);
10151: }
10152: public static void fmtBin8 (char[] a, int o, int x) {
10153: a[o ] = (char) (x >>> 7 & 1 | 48);
10154: a[o + 1] = (char) (x >>> 6 & 1 | 48);
10155: a[o + 2] = (char) (x >>> 5 & 1 | 48);
10156: a[o + 3] = (char) (x >>> 4 & 1 | 48);
10157: a[o + 4] = (char) (x >>> 3 & 1 | 48);
10158: a[o + 5] = (char) (x >>> 2 & 1 | 48);
10159: a[o + 6] = (char) (x >>> 1 & 1 | 48);
10160: a[o + 7] = (char) (x & 1 | 48);
10161: }
10162: public static String fmtAin8 (int x) {
10163: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
10164: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
10165: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
10166: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
10167: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
10168: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
10169: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
10170: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
10171: return String.valueOf (FMT_TEMP, 0, 8);
10172: }
10173: public static String fmtBin8 (int x) {
10174: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
10175: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
10176: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
10177: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
10178: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
10179: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
10180: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
10181: FMT_TEMP[ 7] = (char) (x & 1 | 48);
10182: return String.valueOf (FMT_TEMP, 0, 8);
10183: }
10184: public static StringBuilder fmtAin8 (StringBuilder sb, int x) {
10185: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
10186: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
10187: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
10188: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
10189: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
10190: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
10191: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
10192: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
10193: return sb.append (FMT_TEMP, 0, 8);
10194: }
10195: public static StringBuilder fmtBin8 (StringBuilder sb, int x) {
10196: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
10197: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
10198: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
10199: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
10200: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
10201: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
10202: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
10203: FMT_TEMP[ 7] = (char) (x & 1 | 48);
10204: return sb.append (FMT_TEMP, 0, 8);
10205: }
10206:
10207:
10208:
10209:
10210:
10211:
10212:
10213:
10214: public static void fmtAin12 (char[] a, int o, int x) {
10215: a[o ] = (char) (x >> 9 & 4 ^ 46);
10216: a[o + 1] = (char) (x >> 8 & 4 ^ 46);
10217: a[o + 2] = (char) (x >> 7 & 4 ^ 46);
10218: a[o + 3] = (char) (x >> 6 & 4 ^ 46);
10219: a[o + 4] = (char) (x >> 5 & 4 ^ 46);
10220: a[o + 5] = (char) (x >> 4 & 4 ^ 46);
10221: a[o + 6] = (char) (x >> 3 & 4 ^ 46);
10222: a[o + 7] = (char) (x >> 2 & 4 ^ 46);
10223: a[o + 8] = (char) (x >> 1 & 4 ^ 46);
10224: a[o + 9] = (char) (x & 4 ^ 46);
10225: a[o + 10] = (char) (x << 1 & 4 ^ 46);
10226: a[o + 11] = (char) (x << 2 & 4 ^ 46);
10227: }
10228: public static void fmtBin12 (char[] a, int o, int x) {
10229: a[o ] = (char) (x >>> 11 & 1 | 48);
10230: a[o + 1] = (char) (x >>> 10 & 1 | 48);
10231: a[o + 2] = (char) (x >>> 9 & 1 | 48);
10232: a[o + 3] = (char) (x >>> 8 & 1 | 48);
10233: a[o + 4] = (char) (x >>> 7 & 1 | 48);
10234: a[o + 5] = (char) (x >>> 6 & 1 | 48);
10235: a[o + 6] = (char) (x >>> 5 & 1 | 48);
10236: a[o + 7] = (char) (x >>> 4 & 1 | 48);
10237: a[o + 8] = (char) (x >>> 3 & 1 | 48);
10238: a[o + 9] = (char) (x >>> 2 & 1 | 48);
10239: a[o + 10] = (char) (x >>> 1 & 1 | 48);
10240: a[o + 11] = (char) (x & 1 | 48);
10241: }
10242: public static String fmtAin12 (int x) {
10243: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
10244: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
10245: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
10246: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
10247: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
10248: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
10249: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
10250: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
10251: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
10252: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
10253: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
10254: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
10255: return String.valueOf (FMT_TEMP, 0, 12);
10256: }
10257: public static String fmtBin12 (int x) {
10258: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
10259: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
10260: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
10261: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
10262: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
10263: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
10264: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
10265: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
10266: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
10267: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
10268: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
10269: FMT_TEMP[11] = (char) (x & 1 | 48);
10270: return String.valueOf (FMT_TEMP, 0, 12);
10271: }
10272: public static StringBuilder fmtAin12 (StringBuilder sb, int x) {
10273: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
10274: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
10275: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
10276: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
10277: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
10278: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
10279: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
10280: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
10281: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
10282: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
10283: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
10284: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
10285: return sb.append (FMT_TEMP, 0, 12);
10286: }
10287: public static StringBuilder fmtBin12 (StringBuilder sb, int x) {
10288: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
10289: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
10290: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
10291: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
10292: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
10293: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
10294: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
10295: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
10296: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
10297: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
10298: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
10299: FMT_TEMP[11] = (char) (x & 1 | 48);
10300: return sb.append (FMT_TEMP, 0, 12);
10301: }
10302:
10303:
10304:
10305:
10306:
10307:
10308:
10309:
10310: public static void fmtAin16 (char[] a, int o, int x) {
10311: a[o ] = (char) (x >> 13 & 4 ^ 46);
10312: a[o + 1] = (char) (x >> 12 & 4 ^ 46);
10313: a[o + 2] = (char) (x >> 11 & 4 ^ 46);
10314: a[o + 3] = (char) (x >> 10 & 4 ^ 46);
10315: a[o + 4] = (char) (x >> 9 & 4 ^ 46);
10316: a[o + 5] = (char) (x >> 8 & 4 ^ 46);
10317: a[o + 6] = (char) (x >> 7 & 4 ^ 46);
10318: a[o + 7] = (char) (x >> 6 & 4 ^ 46);
10319: a[o + 8] = (char) (x >> 5 & 4 ^ 46);
10320: a[o + 9] = (char) (x >> 4 & 4 ^ 46);
10321: a[o + 10] = (char) (x >> 3 & 4 ^ 46);
10322: a[o + 11] = (char) (x >> 2 & 4 ^ 46);
10323: a[o + 12] = (char) (x >> 1 & 4 ^ 46);
10324: a[o + 13] = (char) (x & 4 ^ 46);
10325: a[o + 14] = (char) (x << 1 & 4 ^ 46);
10326: a[o + 15] = (char) (x << 2 & 4 ^ 46);
10327: }
10328: public static void fmtBin16 (char[] a, int o, int x) {
10329: a[o ] = (char) (x >>> 15 & 1 | 48);
10330: a[o + 1] = (char) (x >>> 14 & 1 | 48);
10331: a[o + 2] = (char) (x >>> 13 & 1 | 48);
10332: a[o + 3] = (char) (x >>> 12 & 1 | 48);
10333: a[o + 4] = (char) (x >>> 11 & 1 | 48);
10334: a[o + 5] = (char) (x >>> 10 & 1 | 48);
10335: a[o + 6] = (char) (x >>> 9 & 1 | 48);
10336: a[o + 7] = (char) (x >>> 8 & 1 | 48);
10337: a[o + 8] = (char) (x >>> 7 & 1 | 48);
10338: a[o + 9] = (char) (x >>> 6 & 1 | 48);
10339: a[o + 10] = (char) (x >>> 5 & 1 | 48);
10340: a[o + 11] = (char) (x >>> 4 & 1 | 48);
10341: a[o + 12] = (char) (x >>> 3 & 1 | 48);
10342: a[o + 13] = (char) (x >>> 2 & 1 | 48);
10343: a[o + 14] = (char) (x >>> 1 & 1 | 48);
10344: a[o + 15] = (char) (x & 1 | 48);
10345: }
10346: public static String fmtAin16 (int x) {
10347: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
10348: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
10349: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
10350: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
10351: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
10352: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
10353: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
10354: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
10355: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
10356: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
10357: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
10358: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
10359: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
10360: FMT_TEMP[13] = (char) (x & 4 ^ 46);
10361: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
10362: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
10363: return String.valueOf (FMT_TEMP, 0, 16);
10364: }
10365: public static String fmtBin16 (int x) {
10366: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
10367: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
10368: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
10369: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
10370: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
10371: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
10372: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
10373: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
10374: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
10375: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
10376: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
10377: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
10378: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
10379: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
10380: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
10381: FMT_TEMP[15] = (char) (x & 1 | 48);
10382: return String.valueOf (FMT_TEMP, 0, 16);
10383: }
10384: public static StringBuilder fmtAin16 (StringBuilder sb, int x) {
10385: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
10386: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
10387: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
10388: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
10389: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
10390: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
10391: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
10392: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
10393: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
10394: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
10395: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
10396: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
10397: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
10398: FMT_TEMP[13] = (char) (x & 4 ^ 46);
10399: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
10400: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
10401: return sb.append (FMT_TEMP, 0, 16);
10402: }
10403: public static StringBuilder fmtBin16 (StringBuilder sb, int x) {
10404: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
10405: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
10406: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
10407: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
10408: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
10409: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
10410: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
10411: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
10412: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
10413: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
10414: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
10415: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
10416: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
10417: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
10418: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
10419: FMT_TEMP[15] = (char) (x & 1 | 48);
10420: return sb.append (FMT_TEMP, 0, 16);
10421: }
10422:
10423:
10424:
10425:
10426:
10427:
10428:
10429:
10430: public static void fmtAin24 (char[] a, int o, int x) {
10431: a[o ] = (char) (x >> 21 & 4 ^ 46);
10432: a[o + 1] = (char) (x >> 20 & 4 ^ 46);
10433: a[o + 2] = (char) (x >> 19 & 4 ^ 46);
10434: a[o + 3] = (char) (x >> 18 & 4 ^ 46);
10435: a[o + 4] = (char) (x >> 17 & 4 ^ 46);
10436: a[o + 5] = (char) (x >> 16 & 4 ^ 46);
10437: a[o + 6] = (char) (x >> 15 & 4 ^ 46);
10438: a[o + 7] = (char) (x >> 14 & 4 ^ 46);
10439: a[o + 8] = (char) (x >> 13 & 4 ^ 46);
10440: a[o + 9] = (char) (x >> 12 & 4 ^ 46);
10441: a[o + 10] = (char) (x >> 11 & 4 ^ 46);
10442: a[o + 11] = (char) (x >> 10 & 4 ^ 46);
10443: a[o + 12] = (char) (x >> 9 & 4 ^ 46);
10444: a[o + 13] = (char) (x >> 8 & 4 ^ 46);
10445: a[o + 14] = (char) (x >> 7 & 4 ^ 46);
10446: a[o + 15] = (char) (x >> 6 & 4 ^ 46);
10447: a[o + 16] = (char) (x >> 5 & 4 ^ 46);
10448: a[o + 17] = (char) (x >> 4 & 4 ^ 46);
10449: a[o + 18] = (char) (x >> 3 & 4 ^ 46);
10450: a[o + 19] = (char) (x >> 2 & 4 ^ 46);
10451: a[o + 20] = (char) (x >> 1 & 4 ^ 46);
10452: a[o + 21] = (char) (x & 4 ^ 46);
10453: a[o + 22] = (char) (x << 1 & 4 ^ 46);
10454: a[o + 23] = (char) (x << 2 & 4 ^ 46);
10455: }
10456: public static void fmtBin24 (char[] a, int o, int x) {
10457: a[o ] = (char) (x >>> 23 & 1 | 48);
10458: a[o + 1] = (char) (x >>> 22 & 1 | 48);
10459: a[o + 2] = (char) (x >>> 21 & 1 | 48);
10460: a[o + 3] = (char) (x >>> 20 & 1 | 48);
10461: a[o + 4] = (char) (x >>> 19 & 1 | 48);
10462: a[o + 5] = (char) (x >>> 18 & 1 | 48);
10463: a[o + 6] = (char) (x >>> 17 & 1 | 48);
10464: a[o + 7] = (char) (x >>> 16 & 1 | 48);
10465: a[o + 8] = (char) (x >>> 15 & 1 | 48);
10466: a[o + 9] = (char) (x >>> 14 & 1 | 48);
10467: a[o + 10] = (char) (x >>> 13 & 1 | 48);
10468: a[o + 11] = (char) (x >>> 12 & 1 | 48);
10469: a[o + 12] = (char) (x >>> 11 & 1 | 48);
10470: a[o + 13] = (char) (x >>> 10 & 1 | 48);
10471: a[o + 14] = (char) (x >>> 9 & 1 | 48);
10472: a[o + 15] = (char) (x >>> 8 & 1 | 48);
10473: a[o + 16] = (char) (x >>> 7 & 1 | 48);
10474: a[o + 17] = (char) (x >>> 6 & 1 | 48);
10475: a[o + 18] = (char) (x >>> 5 & 1 | 48);
10476: a[o + 19] = (char) (x >>> 4 & 1 | 48);
10477: a[o + 20] = (char) (x >>> 3 & 1 | 48);
10478: a[o + 21] = (char) (x >>> 2 & 1 | 48);
10479: a[o + 22] = (char) (x >>> 1 & 1 | 48);
10480: a[o + 23] = (char) (x & 1 | 48);
10481: }
10482: public static String fmtAin24 (int x) {
10483: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
10484: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
10485: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
10486: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
10487: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
10488: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
10489: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
10490: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
10491: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
10492: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
10493: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
10494: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
10495: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
10496: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
10497: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
10498: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
10499: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
10500: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
10501: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
10502: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
10503: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
10504: FMT_TEMP[21] = (char) (x & 4 ^ 46);
10505: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
10506: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
10507: return String.valueOf (FMT_TEMP, 0, 24);
10508: }
10509: public static String fmtBin24 (int x) {
10510: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
10511: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
10512: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
10513: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
10514: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
10515: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
10516: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
10517: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
10518: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
10519: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
10520: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
10521: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
10522: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
10523: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
10524: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
10525: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
10526: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
10527: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
10528: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
10529: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
10530: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
10531: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
10532: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
10533: FMT_TEMP[23] = (char) (x & 1 | 48);
10534: return String.valueOf (FMT_TEMP, 0, 24);
10535: }
10536: public static StringBuilder fmtAin24 (StringBuilder sb, int x) {
10537: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
10538: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
10539: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
10540: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
10541: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
10542: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
10543: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
10544: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
10545: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
10546: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
10547: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
10548: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
10549: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
10550: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
10551: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
10552: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
10553: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
10554: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
10555: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
10556: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
10557: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
10558: FMT_TEMP[21] = (char) (x & 4 ^ 46);
10559: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
10560: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
10561: return sb.append (FMT_TEMP, 0, 24);
10562: }
10563: public static StringBuilder fmtBin24 (StringBuilder sb, int x) {
10564: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
10565: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
10566: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
10567: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
10568: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
10569: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
10570: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
10571: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
10572: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
10573: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
10574: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
10575: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
10576: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
10577: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
10578: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
10579: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
10580: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
10581: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
10582: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
10583: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
10584: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
10585: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
10586: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
10587: FMT_TEMP[23] = (char) (x & 1 | 48);
10588: return sb.append (FMT_TEMP, 0, 24);
10589: }
10590:
10591:
10592:
10593:
10594:
10595:
10596:
10597:
10598:
10599:
10600:
10601:
10602:
10603:
10604:
10605:
10606:
10607:
10608:
10609:
10610:
10611:
10612:
10613:
10614:
10615:
10616:
10617:
10618:
10619:
10620:
10621:
10622:
10623: public static char fmtHexc (int x) {
10624: x &= 15;
10625: return (char) ((((9 - x) >> 4) & 7) + 48 + x);
10626: }
10627: public static void fmtHex1 (char[] a, int o, int x) {
10628: x &= 15;
10629: a[o] = (char) ((((9 - x) >> 4) & 7) + 48 + x);
10630: }
10631: public static String fmtHex1 (int x) {
10632: x &= 15;
10633: return Character.toString ((char) ((((9 - x) >> 4) & 7) + 48 + x));
10634: }
10635: public static StringBuilder fmtHex1 (StringBuilder sb, int x) {
10636: x &= 15;
10637: return sb.append ((char) ((((9 - x) >> 4) & 7) + 48 + x));
10638: }
10639:
10640:
10641:
10642:
10643:
10644:
10645: public static void fmtHex2 (char[] a, int o, int x) {
10646: int x0 = x & 15;
10647: int x1 = x >>> 4 & 15;
10648: a[o ] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
10649: a[o + 1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
10650: }
10651: public static String fmtHex2 (int x) {
10652:
10653: int x0 = x & 15;
10654: int x1 = x >>> 4 & 15;
10655: FMT_TEMP[0] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
10656: FMT_TEMP[1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
10657: return String.valueOf (FMT_TEMP, 0, 2);
10658: }
10659: public static StringBuilder fmtHex2 (StringBuilder sb, int x) {
10660: int x0 = x & 15;
10661: int x1 = x >>> 4 & 15;
10662: return (sb.
10663: append ((char) ((((9 - x1) >> 4) & 7) + 48 + x1)).
10664: append ((char) ((((9 - x0) >> 4) & 7) + 48 + x0)));
10665: }
10666:
10667:
10668:
10669:
10670:
10671:
10672: public static void fmtHex4 (char[] a, int o, int x) {
10673: int t;
10674: t = (char) x >>> 12;
10675: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10676: t = x >>> 8 & 15;
10677: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10678: t = x >>> 4 & 15;
10679: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10680: t = x & 15;
10681: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10682: }
10683: public static String fmtHex4 (int x) {
10684:
10685: int t;
10686: t = (char) x >>> 12;
10687: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10688: t = x >>> 8 & 15;
10689: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10690: t = x >>> 4 & 15;
10691: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10692: t = x & 15;
10693: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10694: return String.valueOf (FMT_TEMP, 0, 4);
10695: }
10696: public static StringBuilder fmtHex4 (StringBuilder sb, int x) {
10697:
10698: int t;
10699: t = (char) x >>> 12;
10700: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10701: t = x >>> 8 & 15;
10702: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10703: t = x >>> 4 & 15;
10704: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10705: t = x & 15;
10706: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10707: return sb.append (FMT_TEMP, 0, 4);
10708: }
10709:
10710:
10711:
10712:
10713:
10714:
10715: public static void fmtHex6 (char[] a, int o, int x) {
10716: int t;
10717: t = x >>> 20 & 15;
10718: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10719: t = x >>> 16 & 15;
10720: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10721: t = (char) x >>> 12;
10722: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10723: t = x >>> 8 & 15;
10724: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10725: t = x >>> 4 & 15;
10726: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10727: t = x & 15;
10728: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10729: }
10730: public static String fmtHex6 (int x) {
10731:
10732: int t;
10733: t = x >>> 20 & 15;
10734: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10735: t = x >>> 16 & 15;
10736: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10737: t = (char) x >>> 12;
10738: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10739: t = x >>> 8 & 15;
10740: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10741: t = x >>> 4 & 15;
10742: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10743: t = x & 15;
10744: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10745: return String.valueOf (FMT_TEMP, 0, 6);
10746: }
10747: public static StringBuilder fmtHex6 (StringBuilder sb, int x) {
10748:
10749: int t;
10750: t = x >>> 20 & 15;
10751: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10752: t = x >>> 16 & 15;
10753: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10754: t = (char) x >>> 12;
10755: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10756: t = x >>> 8 & 15;
10757: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10758: t = x >>> 4 & 15;
10759: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10760: t = x & 15;
10761: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10762: return sb.append (FMT_TEMP, 0, 6);
10763: }
10764:
10765:
10766:
10767:
10768:
10769:
10770: public static void fmtHex8 (char[] a, int o, int x) {
10771: int t;
10772: t = x >>> 28;
10773: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10774: t = x >>> 24 & 15;
10775: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10776: t = x >>> 20 & 15;
10777: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10778: t = x >>> 16 & 15;
10779: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10780: t = (char) x >>> 12;
10781: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10782: t = x >>> 8 & 15;
10783: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10784: t = x >>> 4 & 15;
10785: a[o + 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10786: t = x & 15;
10787: a[o + 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10788: }
10789: public static String fmtHex8 (int x) {
10790:
10791: int t;
10792: t = x >>> 28;
10793: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10794: t = x >>> 24 & 15;
10795: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10796: t = x >>> 20 & 15;
10797: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10798: t = x >>> 16 & 15;
10799: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10800: t = (char) x >>> 12;
10801: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10802: t = x >>> 8 & 15;
10803: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10804: t = x >>> 4 & 15;
10805: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10806: t = x & 15;
10807: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10808: return String.valueOf (FMT_TEMP, 0, 8);
10809: }
10810: public static StringBuilder fmtHex8 (StringBuilder sb, 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 sb.append (FMT_TEMP, 0, 8);
10830: }
10831:
10832: public static StringBuilder fmtHex16 (StringBuilder sb, long x) {
10833:
10834: int s, t;
10835: s = (int) (x >>> 32);
10836: t = s >>> 28;
10837: FMT_TEMP[ 0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10838: t = s >>> 24 & 15;
10839: FMT_TEMP[ 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10840: t = s >>> 20 & 15;
10841: FMT_TEMP[ 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10842: t = s >>> 16 & 15;
10843: FMT_TEMP[ 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10844: t = (char) s >>> 12;
10845: FMT_TEMP[ 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10846: t = s >>> 8 & 15;
10847: FMT_TEMP[ 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10848: t = s >>> 4 & 15;
10849: FMT_TEMP[ 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10850: t = s & 15;
10851: FMT_TEMP[ 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10852: s = (int) x;
10853: t = s >>> 28;
10854: FMT_TEMP[ 8] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10855: t = s >>> 24 & 15;
10856: FMT_TEMP[ 9] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10857: t = s >>> 20 & 15;
10858: FMT_TEMP[10] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10859: t = s >>> 16 & 15;
10860: FMT_TEMP[11] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10861: t = (char) s >>> 12;
10862: FMT_TEMP[12] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10863: t = s >>> 8 & 15;
10864: FMT_TEMP[13] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10865: t = s >>> 4 & 15;
10866: FMT_TEMP[14] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10867: t = s & 15;
10868: FMT_TEMP[15] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
10869: return sb.append (FMT_TEMP, 0, 16);
10870: }
10871:
10872:
10873:
10874:
10875:
10876:
10877:
10878:
10879:
10880:
10881:
10882:
10883:
10884:
10885:
10886:
10887:
10888:
10889:
10890:
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: public static final int[] FMT_BCD4 = new int[10000];
10940: public static final int[] FMT_DCB4 = new int[65536];
10941:
10942:
10943:
10944:
10945: public static void fmtInit () {
10946: Arrays.fill (FMT_DCB4, -1);
10947: int i = 0;
10948: int x = 0;
10949: for (int a = 0; a < 10; a++) {
10950: for (int b = 0; b < 10; b++) {
10951: for (int c = 0; c < 10; c++) {
10952: FMT_DCB4[FMT_BCD4[i ] = x ] = i;
10953: FMT_DCB4[FMT_BCD4[i + 1] = x + 1] = i + 1;
10954: FMT_DCB4[FMT_BCD4[i + 2] = x + 2] = i + 2;
10955: FMT_DCB4[FMT_BCD4[i + 3] = x + 3] = i + 3;
10956: FMT_DCB4[FMT_BCD4[i + 4] = x + 4] = i + 4;
10957: FMT_DCB4[FMT_BCD4[i + 5] = x + 5] = i + 5;
10958: FMT_DCB4[FMT_BCD4[i + 6] = x + 6] = i + 6;
10959: FMT_DCB4[FMT_BCD4[i + 7] = x + 7] = i + 7;
10960: FMT_DCB4[FMT_BCD4[i + 8] = x + 8] = i + 8;
10961: FMT_DCB4[FMT_BCD4[i + 9] = x + 9] = i + 9;
10962: i += 10;
10963: x += 1 << 4;
10964: }
10965: x += 6 << 4;
10966: }
10967: x += 6 << 8;
10968: }
10969: }
10970:
10971:
10972:
10973: public static int fmtBcd4 (int x) {
10974:
10975:
10976:
10977:
10978:
10979:
10980:
10981:
10982:
10983: return FMT_BCD4[Math.max (0, Math.min (9999, x))];
10984: }
10985:
10986:
10987:
10988: public static int fmtBcd8 (int x) {
10989: x = Math.max (0, Math.min (99999999, x));
10990:
10991:
10992: int q = (int) ((long) x * 109951163L >>> 40);
10993:
10994: return FMT_BCD4[q] << 16 | FMT_BCD4[x - 10000 * q];
10995: }
10996:
10997:
10998:
10999: public static long fmtBcd12 (long x) {
11000: x = Math.max (0L, Math.min (999999999999L, x));
11001: int q = (int) ((double) x / 100000000.0);
11002: int r = (int) (x - 100000000L * q);
11003:
11004:
11005: int rq = (int) ((long) r * 109951163L >>> 40);
11006:
11007: return (long) FMT_BCD4[q] << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
11008: }
11009:
11010:
11011:
11012: public static long fmtBcd16 (long x) {
11013: x = Math.max (0L, Math.min (9999999999999999L, x));
11014: int q = x <= (1L << 53) ? (int) ((double) x / 100000000.0) : (int) (x / 100000000L);
11015: int r = (int) (x - 100000000L * q);
11016:
11017:
11018: int qq = (int) ((long) q * 109951163L >>> 40);
11019:
11020:
11021:
11022: int rq = (int) ((long) r * 109951163L >>> 40);
11023:
11024: return (long) (FMT_BCD4[qq] << 16 | FMT_BCD4[q - 10000 * qq]) << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
11025: }
11026:
11027:
11028:
11029:
11030:
11031:
11032: public static int fmtCA02u (char[] a, int o, int x) {
11033: if (x < 0 || 99 < x) {
11034: x = 99;
11035: }
11036: x = FMT_BCD4[x];
11037: a[o ] = (char) ('0' | x >>> 4);
11038: a[o + 1] = (char) ('0' | x & 15);
11039: return o + 2;
11040: }
11041: public static StringBuilder fmtSB02u (StringBuilder sb, int x) {
11042: return sb.append (FMT_TEMP, 0, fmtCA02u (FMT_TEMP, 0, x));
11043: }
11044:
11045:
11046:
11047:
11048:
11049: public static int fmtCA2u (char[] a, int o, int x) {
11050: if (x < 0 || 99 < x) {
11051: x = 99;
11052: }
11053: x = FMT_BCD4[x];
11054: if (x <= 0x000f) {
11055: a[o++] = (char) ('0' | x);
11056: } else {
11057: a[o++] = (char) ('0' | x >>> 4);
11058: a[o++] = (char) ('0' | x & 15);
11059: }
11060: return o;
11061: }
11062: public static StringBuilder fmtSB2u (StringBuilder sb, int x) {
11063: return sb.append (FMT_TEMP, 0, fmtCA2u (FMT_TEMP, 0, x));
11064: }
11065:
11066:
11067:
11068:
11069:
11070: public static int fmtCA04u (char[] a, int o, int x) {
11071: if (x < 0 || 9999 < x) {
11072: x = 9999;
11073: }
11074: x = FMT_BCD4[x];
11075: a[o ] = (char) ('0' | x >>> 12);
11076: a[o + 1] = (char) ('0' | x >>> 8 & 15);
11077: a[o + 2] = (char) ('0' | x >>> 4 & 15);
11078: a[o + 3] = (char) ('0' | x & 15);
11079: return o + 4;
11080: }
11081: public static StringBuilder fmtSB04u (StringBuilder sb, int x) {
11082: return sb.append (FMT_TEMP, 0, fmtCA04u (FMT_TEMP, 0, x));
11083: }
11084:
11085:
11086:
11087:
11088:
11089: public static int fmtCA4u (char[] a, int o, int x) {
11090: if (x < 0 || 9999 < x) {
11091: x = 9999;
11092: }
11093: x = FMT_BCD4[x];
11094: if (x <= 0x000f) {
11095: a[o++] = (char) ('0' | x);
11096: } else if (x <= 0x00ff) {
11097: a[o++] = (char) ('0' | x >>> 4);
11098: a[o++] = (char) ('0' | x & 15);
11099: } else if (x <= 0x0fff) {
11100: a[o++] = (char) ('0' | x >>> 8);
11101: a[o++] = (char) ('0' | x >>> 4 & 15);
11102: a[o++] = (char) ('0' | x & 15);
11103: } else {
11104: a[o++] = (char) ('0' | x >>> 12);
11105: a[o++] = (char) ('0' | x >>> 8 & 15);
11106: a[o++] = (char) ('0' | x >>> 4 & 15);
11107: a[o++] = (char) ('0' | x & 15);
11108: }
11109: return o;
11110: }
11111: public static StringBuilder fmtSB4u (StringBuilder sb, int x) {
11112: return sb.append (FMT_TEMP, 0, fmtCA4u (FMT_TEMP, 0, x));
11113: }
11114:
11115:
11116:
11117:
11118:
11119: public static int fmtCA08u (char[] a, int o, int x) {
11120: if (x < 0 || 99999999 < x) {
11121: x = 99999999;
11122: }
11123:
11124:
11125: int h = (int) ((long) x * 109951163L >>> 40);
11126: return fmtCA04u (a, fmtCA04u (a, o, h), x - h * 10000);
11127: }
11128: public static StringBuilder fmtSB08u (StringBuilder sb, int x) {
11129: return sb.append (FMT_TEMP, 0, fmtCA08u (FMT_TEMP, 0, x));
11130: }
11131:
11132:
11133:
11134:
11135:
11136: public static int fmtCA8u (char[] a, int o, int x) {
11137: if (x < 0 || 99999999 < x) {
11138: x = 99999999;
11139: }
11140: if (x <= 9999) {
11141: return fmtCA4u (a, o, x);
11142: } else {
11143:
11144:
11145: int h = (int) ((long) x * 109951163L >>> 40);
11146: return fmtCA04u (a, fmtCA4u (a, o, h), x - h * 10000);
11147: }
11148: }
11149: public static StringBuilder fmtSB8u (StringBuilder sb, int x) {
11150: return sb.append (FMT_TEMP, 0, fmtCA8u (FMT_TEMP, 0, x));
11151: }
11152:
11153:
11154:
11155:
11156:
11157: public static int fmtCAd (char[] a, int o, long x) {
11158: if (x < 0L) {
11159: x = -x;
11160: a[o++] = '-';
11161: }
11162: if (x <= 99999999L) {
11163: return fmtCA8u (a, o, (int) x);
11164: } else if (x <= 9999999999999999L) {
11165: long h = x / 100000000L;
11166: return fmtCA08u (a, fmtCA8u (a, o, (int) h), (int) (x - h * 100000000L));
11167: } else {
11168: long hh = x / 10000000000000000L;
11169: x -= hh * 10000000000000000L;
11170: long h = x / 100000000L;
11171: return fmtCA08u (a, fmtCA08u (a, fmtCA4u (a, o, (int) hh), (int) h), (int) (x - h * 100000000L));
11172: }
11173: }
11174: public static StringBuilder fmtSBd (StringBuilder sb, long x) {
11175: return sb.append (FMT_TEMP, 0, fmtCAd (FMT_TEMP, 0, x));
11176: }
11177:
11178:
11179:
11180:
11181:
11182:
11183: public static int fmtCAnd (char[] a, int o, int n, long x) {
11184: int t = fmtCAd (a, o, x);
11185: n += o;
11186: if (t < n) {
11187: int i = n;
11188: while (o < t) {
11189: a[--i] = a[--t];
11190: }
11191: while (o < i) {
11192: a[--i] = ' ';
11193: }
11194: t = n;
11195: }
11196: return t;
11197: }
11198: public static StringBuilder fmtSBnd (StringBuilder sb, int n, int x) {
11199: return sb.append (FMT_TEMP, 0, fmtCAnd (FMT_TEMP, 0, n, x));
11200: }
11201:
11202:
11203:
11204:
11205:
11206:
11207:
11208:
11209:
11210:
11211:
11212:
11213:
11214: public static int fmtParseInt (String s, int i, int min, int max, int err) {
11215: return fmtParseIntRadix (s, i, min, max, err, 10);
11216: }
11217: public static int fmtParseIntRadix (String s, int i, int min, int max, int err, int radix) {
11218: if (s == null) {
11219: return err;
11220: }
11221: int l = s.length ();
11222: int c = i < l ? s.charAt (i++) : -1;
11223:
11224: while (c == ' ' || c == '\t') {
11225: c = i < l ? s.charAt (i++) : -1;
11226: }
11227:
11228: int n = 0;
11229: if (c == '+') {
11230: c = i < l ? s.charAt (i++) : -1;
11231: } else if (c == '-') {
11232: n = 1;
11233: c = i < l ? s.charAt (i++) : -1;
11234: }
11235:
11236:
11237:
11238:
11239: int o;
11240: int p;
11241: if (c == '$') {
11242: o = 0x07ffffff + n;
11243: p = 15 + n & 15;
11244: radix = 16;
11245: c = i < l ? s.charAt (i++) : -1;
11246: } else if (radix == 16) {
11247: o = 0x07ffffff + n;
11248: p = 15 + n & 15;
11249: } else if (radix == 8) {
11250: o = 0x0fffffff + n;
11251: p = 7 + n & 7;
11252: } else if (radix == 2) {
11253: o = 0x3fffffff + n;
11254: p = 1 + n & 1;
11255: } else {
11256: o = 214748364;
11257: p = 7 + n;
11258: radix = 10;
11259: }
11260:
11261: int x = Character.digit (c, radix);
11262: if (x < 0) {
11263: return err;
11264: }
11265: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
11266: while (c >= 0) {
11267: int t = x - o;
11268: if (t > 0 || t == 0 && c > p) {
11269: return err;
11270: }
11271: x = x * radix + c;
11272: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
11273: }
11274: if (n != 0) {
11275: x = -x;
11276: }
11277: return min <= x && x <= max ? x : err;
11278: }
11279:
11280:
11281:
11282:
11283:
11284:
11285:
11286:
11287:
11288:
11289: public static long matMax3 (long x1, long x2, long x3) {
11290: return Math.max (Math.max (x1, x2), x3);
11291: }
11292: public static long matMax4 (long x1, long x2, long x3, long x4) {
11293: return Math.max (Math.max (x1, x2), Math.max (x3, x4));
11294: }
11295: public static long matMax5 (long x1, long x2, long x3, long x4, long x5) {
11296: return Math.max (Math.max (Math.max (x1, x2), Math.max (x3, x4)), x5);
11297: }
11298:
11299:
11300:
11301:
11302:
11303: public static long matMin3 (long x1, long x2, long x3) {
11304: return Math.min (Math.min (x1, x2), x3);
11305: }
11306: public static long matMin4 (long x1, long x2, long x3, long x4) {
11307: return Math.min (Math.min (x1, x2), Math.min (x3, x4));
11308: }
11309: public static long matMin5 (long x1, long x2, long x3, long x4, long x5) {
11310: return Math.min (Math.min (Math.min (x1, x2), Math.min (x3, x4)), x5);
11311: }
11312:
11313:
11314:
11315:
11316:
11317:
11318:
11319:
11320:
11321:
11322:
11323:
11324: public static String strEncodeUTF8 (String s) {
11325: StringBuilder sb = new StringBuilder ();
11326: int l = s.length ();
11327: for (int i = 0; i < l; i++) {
11328: int u = s.charAt (i);
11329: if (0xd800 <= u && u <= 0xdbff && i + 1 < l) {
11330: int v = s.charAt (i + 1);
11331: if (0xdc00 <= v && v <= 0xdfff) {
11332: u = 0x10000 + ((u & 0x3ff) << 10) + (v & 0x3ff);
11333: i++;
11334: }
11335: }
11336: if ((u & 0xffffff80) == 0) {
11337: sb.append ((char) u);
11338: } else if ((u & 0xfffff800) == 0) {
11339: u = (0x0000c080 |
11340: (u & 0x000007c0) << 2 |
11341: (u & 0x0000003f));
11342: sb.append ((char) (u >> 8)).append ((char) (u & 0xff));
11343: } else if ((u & 0xffff0000) == 0 && !(0xd800 <= u && u <= 0xdfff)) {
11344: u = (0x00e08080 |
11345: (u & 0x0000f000) << 4 |
11346: (u & 0x00000fc0) << 2 |
11347: (u & 0x0000003f));
11348: sb.append ((char) (u >> 16)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
11349: } else if ((u & 0xffe00000) == 0) {
11350: u = (0xf0808080 |
11351: (u & 0x001c0000) << 6 |
11352: (u & 0x0003f000) << 4 |
11353: (u & 0x00000fc0) << 2 |
11354: (u & 0x0000003f));
11355: sb.append ((char) ((u >> 24) & 0xff)).append ((char) ((u >> 16) & 0xff)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
11356: } else {
11357: sb.append ((char) 0xef).append ((char) 0xbf).append ((char) 0xbd);
11358: }
11359: }
11360: return sb.toString ();
11361: }
11362:
11363:
11364:
11365:
11366:
11367:
11368:
11369: public static String strDecodeUTF8 (String s) {
11370: StringBuilder sb = new StringBuilder ();
11371: int l = s.length ();
11372: for (int i = 0; i < l; i++) {
11373: int c = s.charAt (i) & 0xff;
11374: for (int k = ((c & 0x80) == 0x00 ? 0 :
11375: (c & 0xe0) == 0xc0 ? 1 :
11376: (c & 0xf0) == 0xe0 ? 2 :
11377: (c & 0xf8) == 0xf0 ? 3 :
11378: -1);
11379: --k >= 0; ) {
11380: c = c << 8 | (i + 1 < l ? s.charAt (++i) & 0xff : 0);
11381: }
11382: int u = ((c & 0xffffff80) == 0x00000000 ? c :
11383: (c & 0xffffe0c0) == 0x0000c080 ? ((c & 0x00001f00) >> 2 |
11384: (c & 0x0000003f)) :
11385: (c & 0xfff0c0c0) == 0x00e08080 ? ((c & 0x000f0000) >> 4 |
11386: (c & 0x00003f00) >> 2 |
11387: (c & 0x0000003f)) :
11388: (c & 0xf8c0c0c0) == 0xf0808080 ? ((c & 0x07000000) >> 6 |
11389: (c & 0x003f0000) >> 4 |
11390: (c & 0x00003f00) >> 2 |
11391: (c & 0x0000003f)) :
11392: 0xfffd);
11393: if (u <= 0x0000ffff) {
11394: sb.append (0xd800 <= u && u <= 0xdfff ? '\ufffd' :
11395: (char) u);
11396: } else if (u <= 0x0010ffff) {
11397: u -= 0x000010000;
11398: sb.append ((char) (0xd800 + ((u >> 10) & 0x3ff))).append ((char) (0xdc00 + (u & 0x3ff)));
11399: }
11400: }
11401: return sb.toString ();
11402: }
11403:
11404:
11405:
11406:
11407:
11408: public static final int[] IsURIChar = {
11409:
11410:
11411: 0b00000000_00000000_00000000_00000000,
11412: 0b00000000_00000110_11111111_11000000,
11413: 0b01111111_11111111_11111111_11100001,
11414: 0b01111111_11111111_11111111_11100010,
11415: };
11416: public static String strEncodeURI (String s) {
11417: s = strEncodeUTF8 (s);
11418: StringBuilder sb = new StringBuilder ();
11419: int l = s.length ();
11420: for (int i = 0; i < l; i++) {
11421: int c = s.charAt (i);
11422: if (c < 0x80 && IsURIChar[c >> 5] << c < 0) {
11423: sb.append ((char) c);
11424: } else {
11425: fmtHex2 (sb.append ('%'), c);
11426: }
11427: }
11428: return sb.toString ();
11429: }
11430:
11431:
11432:
11433:
11434:
11435: public static final byte[] strIsHexChar = {
11436:
11437: -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,
11438: -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,
11439: -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,
11440: -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,
11441: };
11442: public static String strDecodeURI (String s) {
11443: StringBuilder sb = new StringBuilder ();
11444: int l = s.length ();
11445: for (int i = 0; i < l; i++) {
11446: int c = s.charAt (i);
11447: if (c == '%' && i + 2 < l) {
11448: int d = s.charAt (i + 1);
11449: int e = s.charAt (i + 2);
11450: if (d < 0x80 && (d = strIsHexChar[d]) >= 0 &&
11451: e < 0x80 && (e = strIsHexChar[e]) >= 0) {
11452: sb.append ((char) (d << 4 | e));
11453: } else {
11454: sb.append ((char) c);
11455: }
11456: } else {
11457: sb.append ((char) c);
11458: }
11459: }
11460: return sb.toString ();
11461: }
11462:
11463:
11464:
11465:
11466:
11467:
11468:
11469:
11470: public static BufferedImage createImage (int width, int height, String pattern, int... rgbs) {
11471: BufferedImage image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
11472: int[] bitmap = ((DataBufferInt) image.getRaster ().getDataBuffer ()).getData ();
11473: int length = width * height;
11474: for (int i = 0; i < length; i++) {
11475: char c = pattern.charAt (i);
11476: bitmap[i] = rgbs[c < '0' ? 0 : Character.digit (c, 16)];
11477: }
11478: return image;
11479: }
11480:
11481:
11482:
11483: public static ImageIcon createImageIcon (int width, int height, String pattern, int... rgbs) {
11484: return new ImageIcon (createImage (width, height, pattern, rgbs));
11485: }
11486:
11487:
11488:
11489: public static TexturePaint createTexturePaint (int width, int height, String pattern, int... rgbs) {
11490: return new TexturePaint (createImage (width, height, pattern, rgbs), new Rectangle (0, 0, width, height));
11491: }
11492:
11493:
11494:
11495: public static BufferedImage loadImage (String name) {
11496: BufferedImage image = null;
11497: try {
11498: image = ImageIO.read (new File (name));
11499: } catch (Exception e) {
11500: }
11501: return image;
11502: }
11503:
11504:
11505:
11506:
11507: public static boolean saveImage (BufferedImage image, String name) {
11508: return saveImage (image, name, 0.75F);
11509: }
11510: public static boolean saveImage (BufferedImage image, String name, float quality) {
11511: int index = name.lastIndexOf (".");
11512: if (index < 0) {
11513: return false;
11514: }
11515: if (name.substring (index).equalsIgnoreCase (".ico")) {
11516: return saveIcon (name, image);
11517: }
11518: Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix (name.substring (index + 1));
11519: if (!iterator.hasNext ()) {
11520: return false;
11521: }
11522: ImageWriter imageWriter = iterator.next ();
11523: ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam ();
11524: if (imageWriteParam.canWriteCompressed ()) {
11525: imageWriteParam.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);
11526: imageWriteParam.setCompressionQuality (quality);
11527: }
11528: try {
11529: File file = new File (name);
11530: ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream (file);
11531: imageWriter.setOutput (imageOutputStream);
11532: imageWriter.write (null, new IIOImage (image, null, null), imageWriteParam);
11533: imageOutputStream.close ();
11534: } catch (Exception e) {
11535:
11536: return false;
11537: }
11538: return true;
11539: }
11540:
11541:
11542:
11543:
11544:
11545:
11546:
11547:
11548:
11549:
11550:
11551:
11552:
11553:
11554:
11555:
11556:
11557:
11558:
11559:
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: public static boolean saveIcon (String fileName, BufferedImage... arrayImage) {
11614: int iconCount = arrayImage.length;
11615: int[][] arrayPaletTable = new int[iconCount][];
11616: int[] arrayPaletCount = new int[iconCount];
11617: int[] arrayPixelBits = new int[iconCount];
11618: int[] arrayPatternLineSize = new int[iconCount];
11619: int[] arrayMaskLineSize = new int[iconCount];
11620: int[] arrayImageSize = new int[iconCount];
11621: int[] arrayImageOffset = new int[iconCount];
11622: int fileSize = 6 + 16 * iconCount;
11623: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
11624: BufferedImage image = arrayImage[iconNumber];
11625: int width = image.getWidth ();
11626: int height = image.getHeight ();
11627:
11628: int[] paletTable = new int[256];
11629: int paletCount = 0;
11630: countPalet:
11631: for (int y = height - 1; y >= 0; y--) {
11632: for (int x = 0; x < width; x++) {
11633: int rgb = image.getRGB (x, y);
11634: if (rgb >>> 24 != 0xff) {
11635: continue;
11636: }
11637: int l = 0;
11638: int r = paletCount;
11639: while (l < r) {
11640: int m = l + r >> 1;
11641: if (paletTable[m] < rgb) {
11642: l = m + 1;
11643: } else {
11644: r = m;
11645: }
11646: }
11647: if (l == paletCount || paletTable[l] != rgb) {
11648: if (paletCount == 256) {
11649: paletCount = 0;
11650: break countPalet;
11651: }
11652: for (int i = paletCount; i > l; i--) {
11653: paletTable[i] = paletTable[i - 1];
11654: }
11655: paletTable[l] = rgb;
11656: paletCount++;
11657: }
11658: }
11659: }
11660: int pixelBits = (paletCount == 0 ? 24 :
11661: paletCount > 16 ? 8 :
11662: paletCount > 4 ? 4 :
11663: paletCount > 2 ? 2 :
11664: 1);
11665: int patternLineSize = pixelBits * width + 31 >> 5 << 2;
11666: int maskLineSize = width + 31 >> 5 << 2;
11667: int imageSize = 40 + 4 * paletCount + patternLineSize * height + maskLineSize * height;
11668: arrayPaletTable[iconNumber] = paletTable;
11669: arrayPaletCount[iconNumber] = paletCount;
11670: arrayPixelBits[iconNumber] = pixelBits;
11671: arrayPatternLineSize[iconNumber] = patternLineSize;
11672: arrayMaskLineSize[iconNumber] = maskLineSize;
11673: arrayImageSize[iconNumber] = imageSize;
11674: arrayImageOffset[iconNumber] = fileSize;
11675: fileSize += imageSize;
11676: }
11677: byte[] bb = new byte[fileSize];
11678:
11679: ByteArray.byaWiw (bb, 0, 0);
11680: ByteArray.byaWiw (bb, 2, 1);
11681: ByteArray.byaWiw (bb, 4, iconCount);
11682: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
11683: BufferedImage image = arrayImage[iconNumber];
11684: int width = image.getWidth ();
11685: int height = image.getHeight ();
11686: int[] paletTable = arrayPaletTable[iconNumber];
11687: int paletCount = arrayPaletCount[iconNumber];
11688: int pixelBits = arrayPixelBits[iconNumber];
11689: int patternLineSize = arrayPatternLineSize[iconNumber];
11690: int maskLineSize = arrayMaskLineSize[iconNumber];
11691: int imageSize = arrayImageSize[iconNumber];
11692: int imageOffset = arrayImageOffset[iconNumber];
11693:
11694: int o = 6 + 16 * iconNumber;
11695: ByteArray.byaWb (bb, o, width);
11696: ByteArray.byaWb (bb, o + 1, height);
11697: ByteArray.byaWb (bb, o + 2, paletCount);
11698: ByteArray.byaWb (bb, o + 3, 0);
11699: ByteArray.byaWiw (bb, o + 4, 1);
11700: ByteArray.byaWiw (bb, o + 6, pixelBits);
11701: ByteArray.byaWil (bb, o + 8, imageSize);
11702: ByteArray.byaWil (bb, o + 12, imageOffset);
11703:
11704: o = imageOffset;
11705: ByteArray.byaWil (bb, o, 40);
11706: ByteArray.byaWil (bb, o + 4, width);
11707: ByteArray.byaWil (bb, o + 8, height * 2);
11708: ByteArray.byaWiw (bb, o + 12, 1);
11709: ByteArray.byaWiw (bb, o + 14, pixelBits);
11710: ByteArray.byaWil (bb, o + 16, 0);
11711: ByteArray.byaWil (bb, o + 20, 0);
11712: ByteArray.byaWil (bb, o + 24, 0);
11713: ByteArray.byaWil (bb, o + 28, 0);
11714: ByteArray.byaWil (bb, o + 32, paletCount);
11715: ByteArray.byaWil (bb, o + 36, 0);
11716:
11717: o += 40;
11718: for (int i = 0; i < paletCount; i++) {
11719: ByteArray.byaWil (bb, o, paletTable[i] & 0x00ffffff);
11720: o += 4;
11721: }
11722:
11723: for (int y = height - 1; y >= 0; y--) {
11724: for (int x = 0; x < width; x++) {
11725: int rgb = image.getRGB (x, y);
11726: if (rgb >>> 24 != 0xff) {
11727: continue;
11728: }
11729: if (pixelBits == 24) {
11730: bb[o + 3 * x] = (byte) rgb;
11731: bb[o + 3 * x + 1] = (byte) (rgb >> 8);
11732: bb[o + 3 * x + 2] = (byte) (rgb >> 16);
11733: continue;
11734: }
11735: int l = 0;
11736: int r = paletCount;
11737: while (l < r) {
11738: int m = l + r >> 1;
11739: if (paletTable[m] < rgb) {
11740: l = m + 1;
11741: } else {
11742: r = m;
11743: }
11744: }
11745: if (l != 0) {
11746: if (pixelBits == 8) {
11747: bb[o + x] = (byte) l;
11748: } else if (pixelBits == 4) {
11749: bb[o + (x >> 1)] |= (byte) (l << ((~x & 1) << 2));
11750: } else if (pixelBits == 2) {
11751: bb[o + (x >> 2)] |= (byte) (l << ((~x & 3) << 1));
11752: } else {
11753: bb[o + (x >> 3)] |= (byte) (l << (~x & 7));
11754: }
11755: }
11756: }
11757: o += patternLineSize;
11758: }
11759:
11760: for (int y = height - 1; y >= 0; y--) {
11761: for (int x = 0; x < width; x++) {
11762: int rgb = image.getRGB (x, y);
11763: if (rgb >>> 24 != 0xff) {
11764: bb[o + (x >> 3)] |= (byte) (1 << (~x & 7));
11765: }
11766: }
11767: o += maskLineSize;
11768: }
11769: }
11770: return rscPutFile (fileName, bb, 0, fileSize);
11771: }
11772:
11773:
11774:
11775: }
11776:
11777:
11778: