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