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.geom.*;
20: import java.awt.image.*;
21: import java.io.*;
22: import java.net.*;
23: import java.nio.charset.*;
24: import java.nio.file.*;
25: import java.util.*;
26: import java.util.regex.*;
27: import java.util.stream.*;
28: import java.util.zip.*;
29: import javax.imageio.*;
30: import javax.imageio.stream.*;
31: import javax.swing.*;
32: import javax.swing.event.*;
33: import javax.swing.text.*;
34:
35: public class XEiJ {
36:
37:
38:
39:
40:
41: static {
42: System.setProperty ("sun.java2d.d3d", "false");
43: System.setProperty ("sun.java2d.xrender", "false");
44: }
45:
46:
47: public static final String PRG_TITLE = "XEiJ (X68000 Emulator in Java)";
48: public static final String PRG_VERSION = "0.26.05.17";
49: public static final String PRG_AUTHOR = "Makoto Kamada";
50: public static final String PRG_WEBPAGE = "https://stdkmd.net/xeij/";
51:
52: public static final String PRG_JAVA_VENDOR = "Oracle Corporation";
53: public static final String PRG_JAVA_VERSION = "26.0.1";
54: public static final String PRG_OS_ARCH = "amd64";
55: public static final String PRG_OS_NAME = "Windows 11";
56:
57:
58:
59:
60:
61:
62:
63: public static final boolean TEST_BIT_0_SHIFT = false;
64: public static final boolean TEST_BIT_1_SHIFT = false;
65: public static final boolean TEST_BIT_2_SHIFT = true;
66: public static final boolean TEST_BIT_3_SHIFT = true;
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84: public static final boolean SHORT_SATURATION_CAST = false;
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96: public static final Charset ISO_8859_1 = Charset.forName ("ISO-8859-1");
97: static {
98: if (false) {
99:
100: StringBuilder sb = new StringBuilder ();
101: for (int i = 0; i < 256; i++) {
102: sb.append ((char) i);
103: }
104: byte[] bb = sb.toString ().getBytes (ISO_8859_1);
105: for (int i = 0; i < 256; i++) {
106: System.out.printf ("%02x %02x %s\n", i, bb[i] & 255, i == (bb[i] & 255) ? "OK" : "ERROR");
107: }
108: }
109: }
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122: public static String prgJavaVendor;
123: public static String prgJavaVersion;
124: public static String prgOsArch;
125: public static String prgOsName;
126: public static boolean prgIsLinux;
127: public static boolean prgIsMac;
128: public static boolean prgIsWindows;
129:
130: public static boolean prgCaseIgnored;
131:
132: public static boolean prgVerbose;
133: public static boolean prgTiniLog;
134:
135: public static String[] prgArgs;
136:
137:
138:
139: public static void main (String[] args) {
140:
141:
142:
143:
144: if (true) {
145: try {
146: String def = System.getProperty ("os.name").toLowerCase ().contains ("win") ? "C:\\Temp" : "/tmp";
147: Stream.of (new File (System.getProperty ("java.io.tmpdir", def),
148: "jSerialComm").getCanonicalFile ().toPath (),
149: new File (System.getProperty ("user.home", def),
150: ".jSerialComm").getCanonicalFile ().toPath ())
151: .filter (Files::exists)
152: .forEach (dir -> {
153: try {
154: Files.walk (dir)
155: .sorted (Comparator.reverseOrder ())
156: .forEach (path -> {
157: if (Files.exists (path)) {
158: try {
159: Files.delete (path);
160:
161: } catch (IOException ioe) {
162: System.err.println ("Failed to delete: " + path + " (" + ioe.getMessage () + ")");
163: }
164: }
165: });
166: } catch (IOException ioe) {
167: System.err.println ("Failed to walk: " + dir + " (" + ioe.getMessage () + ")");
168: }
169: });
170: } catch (IOException ioe) {
171: }
172: }
173:
174: prgArgs = args;
175:
176:
177: SwingUtilities.invokeLater (new Runnable () {
178: @Override public void run () {
179: new XEiJ ();
180: }
181: });
182:
183: }
184:
185:
186:
187: public XEiJ () {
188:
189: prgJavaVendor = System.getProperty ("java.vendor");
190: prgJavaVersion = System.getProperty ("java.version");
191: prgOsArch = System.getProperty ("os.arch");
192: prgOsName = System.getProperty ("os.name");
193: prgIsLinux = 0 <= prgOsName.indexOf ("Linux");
194: prgIsMac = 0 <= prgOsName.indexOf ("Mac");
195: prgIsWindows = 0 <= prgOsName.indexOf ("Windows");
196:
197: System.out.print ("\n" +
198: "-------------------------------------------------\n" +
199: PRG_TITLE + " version " + PRG_VERSION + "\n" +
200: "-------------------------------------------------\n");
201:
202:
203:
204:
205: prgCaseIgnored = new File ("A").equals (new File ("a"));
206: fmtInit ();
207: Multilingual.mlnInit ();
208:
209: System.out.println (Multilingual.mlnJapanese ? "java.vendor は " + prgJavaVendor + " です" :
210: "java.vendor is " + prgJavaVendor);
211: System.out.println (Multilingual.mlnJapanese ? "java.version は " + prgJavaVersion + " です" :
212: "java.version is " + prgJavaVersion);
213: System.out.println (Multilingual.mlnJapanese ? "os.arch は " + prgOsArch + " です" :
214: "os.arch is " + prgOsArch);
215: System.out.println (Multilingual.mlnJapanese ? "os.name は " + prgOsName + " です" :
216: "os.name is " + prgOsName);
217:
218: rbtInit ();
219:
220: Settings.sgsInit ();
221: LnF.lnfInit ();
222: Bubble.bblInit ();
223:
224: CharacterCode.chrInit ();
225:
226: TickerQueue.tkqInit ();
227:
228: RS232CTerminal.trmInit ();
229:
230: if (MercuryUnit.MU4_ON) {
231: MercuryUnit.mu4Init ();
232: }
233: xt3Init ();
234: mdlInit ();
235:
236: if (InstructionBreakPoint.IBP_ON) {
237: InstructionBreakPoint.ibpInit ();
238: }
239: if (DataBreakPoint.DBP_ON) {
240: DataBreakPoint.dbpInit ();
241: }
242: busInit ();
243: MainMemory.mmrInit ();
244: ROM.romInit ();
245: CRTC.crtInit ();
246: VideoController.vcnInit ();
247: HD63450.dmaInit ();
248: svsInit ();
249: MC68901.mfpInit ();
250: RP5C15.rtcInit ();
251: sysInit ();
252: if (OPMLog.OLG_ON) {
253: OPMLog.olgInit ();
254: }
255: OPM.opmInit ();
256: ADPCM.pcmInit ();
257: FDC.fdcInit ();
258: HDC.hdcInit ();
259: if (HostCDROM.HCD_ENABLED) {
260: HostCDROM.hcdInit ();
261: }
262: SPC.spcInit ();
263: Z8530.sccInit ();
264: IOInterrupt.ioiInit ();
265: SpriteScreen.sprInit ();
266: bnkInit ();
267: SRAM.smrInit ();
268:
269: PPI.ppiInit ();
270: PrinterPort.prnInit ();
271: Indicator.indInit ();
272:
273: SlowdownTest.sdtInit ();
274: Keyboard.kbdInit ();
275: CONDevice.conInit ();
276: Mouse.musInit ();
277: pnlInit ();
278: frmInit ();
279:
280: dbgInit ();
281: RegisterList.drpInit ();
282: DisassembleList.ddpInit ();
283: MemoryDumpList.dmpInit ();
284: LogicalSpaceMonitor.atwInit ();
285: PhysicalSpaceMonitor.paaInit ();
286: DebugConsole.dgtInit ();
287: if (BranchLog.BLG_ON) {
288: BranchLog.blgInit ();
289: }
290: if (ProgramFlowVisualizer.PFV_ON) {
291: ProgramFlowVisualizer.pfvInit ();
292: }
293: if (RasterBreakPoint.RBP_ON) {
294: RasterBreakPoint.rbpInit ();
295: }
296: if (ScreenModeTest.SMT_ON) {
297: ScreenModeTest.smtInit ();
298: }
299: if (RootPointerList.RTL_ON) {
300: RootPointerList.rtlInit ();
301: }
302: if (SpritePatternViewer.SPV_ON) {
303: SpritePatternViewer.spvInit ();
304: }
305: if (PaletteViewer.PLV_ON) {
306: PaletteViewer.plvInit ();
307: }
308: if (ATCMonitor.ACM_ON) {
309: ATCMonitor.acmInit ();
310: }
311:
312: SoundSource.sndInit ();
313: FEFunction.fpkInit ();
314: mpuInit ();
315: MC68060.mmuInit ();
316: SoundMonitor.smnInit ();
317: HFS.hfsInit ();
318:
319: GIFAnimation.gifInit ();
320: if (FlashingLights.FLR_ON) {
321: FlashingLights.flrInit ();
322: }
323: TextCopy.txcInit ();
324: ButtonFunction.bfnInit ();
325:
326:
327:
328: Settings.sgsMakeMenu ();
329: mdlMakeMenu ();
330: FDC.fdcMakeMenu ();
331: HDC.hdcMakeMenu ();
332: SPC.spcMakeMenu ();
333: SRAM.smrMakeMenu ();
334: mpuMakeMenu ();
335: clpMake ();
336: pnlMake ();
337: mnbMakeMenu ();
338: frmMake ();
339: dbgMakePopup ();
340:
341: if (FlashingLights.FLR_ON) {
342: FlashingLights.flrInform ();
343: }
344:
345:
346: final String flags = (
347: "" +
348: (EFPBox.CIR_DEBUG_TRACE ? " EFPBox.CIR_DEBUG_TRACE" : "") +
349: (FDC.FDC_DEBUG_TRACE ? " FDC.FDC_DEBUG_TRACE" : "") +
350: (FEFunction.FPK_DEBUG_TRACE ? " FEFunction.FPK_DEBUG_TRACE" : "") +
351: (HD63450.DMA_DEBUG_TRACE != 0 ? " HD63450.DMA_DEBUG_TRACE" : "") +
352: (HDC.HDC_DEBUG_TRACE ? " HDC.HDC_DEBUG_TRACE" : "") +
353: (HDC.HDC_DEBUG_COMMAND ? " HDC.HDC_DEBUG_COMMAND" : "") +
354: (HFS.HFS_DEBUG_TRACE ? " HFS.HFS_DEBUG_TRACE" : "") +
355: (HFS.HFS_DEBUG_FILE_INFO ? " HFS.HFS_DEBUG_FILE_INFO" : "") +
356: (HFS.HFS_COMMAND_TRACE ? " HFS.HFS_COMMAND_TRACE" : "") +
357: (HFS.HFS_BUFFER_TRACE ? " HFS.HFS_BUFFER_TRACE" : "") +
358: (IOInterrupt.IOI_DEBUG_TRACE ? " IOInterrupt.IOI_DEBUG_TRACE" : "") +
359: (Keyboard.KBD_DEBUG_LED ? " Keyboard.KBD_DEBUG_LED" : "") +
360: (MC68060.MMU_DEBUG_COMMAND ? " MC68060.MMU_DEBUG_COMMAND" : "") +
361: (MC68060.MMU_DEBUG_TRANSLATION ? " MC68060.MMU_DEBUG_TRANSLATION" : "") +
362: (MC68060.MMU_NOT_ALLOCATE_CACHE ? " MC68060.MMU_NOT_ALLOCATE_CACHE" : "") +
363: (RP5C15.RTC_DEBUG_TRACE ? " RP5C15.RTC_DEBUG_TRACE" : "") +
364: (SPC.SPC_DEBUG_ON ? " SPC.SPC_DEBUG_ON" : "") +
365: (Z8530.SCC_DEBUG_ON ? " Z8530.SCC_DEBUG_ON" : "")
366: );
367: if (!"".equals (flags)) {
368: pnlExitFullScreen (true);
369: JOptionPane.showMessageDialog (null, "debug flags:" + flags);
370: }
371:
372:
373:
374:
375: tmrStart ();
376:
377: Keyboard.kbdStart ();
378: Mouse.musStart ();
379: pnlStart ();
380: frmStart ();
381: SoundSource.sndStart ();
382:
383: if (DataBreakPoint.DBP_ON) {
384: DataBreakPoint.dbpStart ();
385: }
386: if (RasterBreakPoint.RBP_ON) {
387: RasterBreakPoint.rbpStart ();
388: }
389: if (ScreenModeTest.SMT_ON) {
390: ScreenModeTest.smtStart ();
391: }
392: if (OPMLog.OLG_ON) {
393: OPMLog.olgStart ();
394: }
395: SoundMonitor.smnStart ();
396: RS232CTerminal.trmStart ();
397: PPI.ppiStart ();
398: PrinterPort.prnStart ();
399: if (BranchLog.BLG_ON) {
400: BranchLog.blgStart ();
401: }
402: if (ProgramFlowVisualizer.PFV_ON) {
403: ProgramFlowVisualizer.pfvStart ();
404: }
405: RegisterList.drpStart ();
406: DisassembleList.ddpStart ();
407: MemoryDumpList.dmpStart ();
408: LogicalSpaceMonitor.atwStart ();
409: PhysicalSpaceMonitor.paaStart ();
410: DebugConsole.dgtStart ();
411: if (RootPointerList.RTL_ON) {
412: RootPointerList.rtlStart ();
413: }
414: if (SpritePatternViewer.SPV_ON) {
415: SpritePatternViewer.spvStart ();
416: }
417: if (PaletteViewer.PLV_ON) {
418: PaletteViewer.plvStart ();
419: }
420: if (ATCMonitor.ACM_ON) {
421: ATCMonitor.acmStart ();
422: }
423: ButtonFunction.bfnStart ();
424:
425: if (Settings.sgsSaveiconValue != null) {
426: String[] a = Settings.sgsSaveiconValue.split (",");
427: if (0 < a.length) {
428: saveIcon (a[0], LnF.LNF_ICON_IMAGES);
429: if (1 < a.length) {
430: saveImage (LnF.LNF_ICON_IMAGE_16, a[1]);
431: if (2 < a.length) {
432: saveImage (LnF.LNF_ICON_IMAGE_32, a[2]);
433: if (3 < a.length) {
434: saveImage (LnF.LNF_ICON_IMAGE_48, a[3]);
435: }
436: }
437: }
438: }
439: prgTini ();
440: return;
441: }
442:
443:
444: mpuReset (-1, -1);
445:
446: pnlBoot2 ();
447:
448: }
449:
450:
451:
452:
453:
454: public static void prgTini () {
455: if (prgTiniLog) {
456: System.out.println ("prgTini: call mpuStop");
457: }
458: mpuStop (null);
459: try {
460: if (OPMLog.OLG_ON) {
461: if (prgTiniLog) {
462: System.out.println ("prgTini: call orgTini");
463: }
464: OPMLog.olgTini ();
465: }
466: if (prgTiniLog) {
467: System.out.println ("prgTini: call bfnTini");
468: }
469: ButtonFunction.bfnTini ();
470: if (prgTiniLog) {
471: System.out.println ("prgTini: call txcTini");
472: }
473: TextCopy.txcTini ();
474: if (prgTiniLog) {
475: System.out.println ("prgTini: call gifTini");
476: }
477: GIFAnimation.gifTini ();
478: if (FlashingLights.FLR_ON) {
479: if (prgTiniLog) {
480: System.out.println ("prgTini: call flrTini");
481: }
482: FlashingLights.flrTini ();
483: }
484: if (prgTiniLog) {
485: System.out.println ("prgTini: call sndTini");
486: }
487: SoundSource.sndTini ();
488: if (prgTiniLog) {
489: System.out.println ("prgTini: call kbdTini");
490: }
491: Keyboard.kbdTini ();
492: if (prgTiniLog) {
493: System.out.println ("prgTini: call musTini");
494: }
495: Mouse.musTini ();
496: if (prgTiniLog) {
497: System.out.println ("prgTini: call conTini");
498: }
499: CONDevice.conTini ();
500: if (prgTiniLog) {
501: System.out.println ("prgTini: call ppiTini");
502: }
503: PPI.ppiTini ();
504: if (prgTiniLog) {
505: System.out.println ("prgTini: call prnTini");
506: }
507: PrinterPort.prnTini ();
508: if (prgTiniLog) {
509: System.out.println ("prgTini: call fdcTini");
510: }
511: FDC.fdcTini ();
512: if (prgTiniLog) {
513: System.out.println ("prgTini: call hdcTini");
514: }
515: HDC.hdcTini ();
516: if (HostCDROM.HCD_ENABLED) {
517: if (prgTiniLog) {
518: System.out.println ("prgTini: call hcdTini");
519: }
520: HostCDROM.hcdTini ();
521: }
522: if (prgTiniLog) {
523: System.out.println ("prgTini: call spcTini");
524: }
525: SPC.spcTini ();
526: if (prgTiniLog) {
527: System.out.println ("prgTini: call hfsTini");
528: }
529: HFS.hfsTini ();
530: if (prgTiniLog) {
531: System.out.println ("prgTini: call sccTini");
532: }
533: Z8530.sccTini ();
534: if (prgTiniLog) {
535: System.out.println ("prgTini: call crtTini");
536: }
537: CRTC.crtTini ();
538: if (prgTiniLog) {
539: System.out.println ("prgTini: call sprTini");
540: }
541: SpriteScreen.sprTini ();
542: if (prgTiniLog) {
543: System.out.println ("prgTini: call pnlTini");
544: }
545: pnlTini ();
546: if (prgTiniLog) {
547: System.out.println ("prgTini: call bnkTini");
548: }
549: bnkTini ();
550: if (prgTiniLog) {
551: System.out.println ("prgTini: call romTini");
552: }
553: ROM.romTini ();
554: if (MercuryUnit.MU4_ON) {
555: if (prgTiniLog) {
556: System.out.println ("prgTini: call mu4Tini");
557: }
558: MercuryUnit.mu4Tini ();
559: }
560: if (prgTiniLog) {
561: System.out.println ("prgTini: call xt3Tini");
562: }
563: xt3Tini ();
564: if (prgTiniLog) {
565: System.out.println ("prgTini: call mdlTini");
566: }
567: mdlTini ();
568: if (prgTiniLog) {
569: System.out.println ("prgTini: call smrTini");
570: }
571: SRAM.smrTini ();
572: if (prgTiniLog) {
573: System.out.println ("prgTini: call busTini");
574: }
575: busTini ();
576: if (SpritePatternViewer.SPV_ON) {
577: if (prgTiniLog) {
578: System.out.println ("prgTini: call spvTini");
579: }
580: SpritePatternViewer.spvTini ();
581: }
582: if (PaletteViewer.PLV_ON) {
583: if (prgTiniLog) {
584: System.out.println ("prgTini: call plvTini");
585: }
586: PaletteViewer.plvTini ();
587: }
588: if (prgTiniLog) {
589: System.out.println ("prgTini: call trmTini");
590: }
591: RS232CTerminal.trmTini ();
592: if (prgTiniLog) {
593: System.out.println ("prgTini: call lnfTini");
594: }
595: LnF.lnfTini ();
596: if (prgTiniLog) {
597: System.out.println ("prgTini: call tmrTini");
598: }
599: tmrTini ();
600: if (prgTiniLog) {
601: System.out.println ("prgTini: call sgsTini");
602: }
603: Settings.sgsTini ();
604: } catch (Exception e) {
605: e.printStackTrace ();
606: }
607: System.exit (0);
608: }
609:
610:
611:
612: public static void prgOpenJavaDialog () {
613: pnlExitFullScreen (true);
614: JOptionPane.showMessageDialog (
615: frmFrame,
616: ComponentFactory.createGridPanel (
617: 3,
618: 6,
619: "paddingLeft=6,paddingRight=6",
620: "italic,right;left;left",
621: "italic,center;colSpan=3,widen",
622: "",
623:
624: null,
625: Multilingual.mlnJapanese ? "実行中" : "Running",
626: Multilingual.mlnJapanese ? "推奨" : "Recommended",
627:
628: ComponentFactory.createHorizontalSeparator (),
629:
630: Multilingual.mlnJapanese ? "Java のベンダー" : "Java Vendor",
631: prgJavaVendor,
632: PRG_JAVA_VENDOR,
633:
634: Multilingual.mlnJapanese ? "Java のバージョン" : "Java Version",
635: prgJavaVersion,
636: PRG_JAVA_VERSION,
637:
638: Multilingual.mlnJapanese ? "OS のアーキテクチャ" : "OS Architecture",
639: prgOsArch,
640: PRG_OS_ARCH,
641:
642: Multilingual.mlnJapanese ? "OS の名前" : "OS Name",
643: prgOsName,
644: PRG_OS_NAME
645: ),
646: Multilingual.mlnJapanese ? "Java 実行環境の情報" : "Java runtime environment information",
647: JOptionPane.PLAIN_MESSAGE);
648: }
649:
650:
651:
652: public static void prgOpenAboutDialog () {
653: pnlExitFullScreen (true);
654: JOptionPane.showMessageDialog (
655: frmFrame,
656: ComponentFactory.createGridPanel (
657: 2, 4, "paddingLeft=6,paddingRight=6", "italic,right;left", "", "",
658: Multilingual.mlnJapanese ? "タイトル" : "Title" ,
659: PRG_TITLE,
660: Multilingual.mlnJapanese ? "バージョン" : "Version",
661: PRG_VERSION,
662: Multilingual.mlnJapanese ? "作者" : "Author" ,
663: PRG_AUTHOR,
664: Multilingual.mlnJapanese ? "ウェブページ" : "Webpage",
665: PRG_WEBPAGE
666: ),
667: Multilingual.mlnJapanese ? "バージョン情報" : "Version information",
668: JOptionPane.PLAIN_MESSAGE);
669: }
670:
671:
672:
673: public static void prgOpenXEiJLicenseDialog () {
674: pnlExitFullScreen (true);
675: JOptionPane.showMessageDialog (
676: frmFrame,
677: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_XEiJ.txt"), 550, 300),
678: Multilingual.mlnJapanese ? "XEiJ 使用許諾条件" : "XEiJ License",
679: JOptionPane.PLAIN_MESSAGE);
680: }
681:
682:
683:
684: public static void prgOpenSHARPLicenseDialog () {
685: pnlExitFullScreen (true);
686: JOptionPane.showMessageDialog (
687: frmFrame,
688: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_FSHARP.txt", "Shift_JIS"), 550, 300),
689: Multilingual.mlnJapanese ? "無償公開された X68000 の基本ソフトウェア製品の許諾条件" : "License of the basic software products for X68000 that were distributed free of charge",
690: JOptionPane.PLAIN_MESSAGE);
691: }
692:
693:
694:
695: public static void prgOpenYmfmLicenseDialog () {
696: pnlExitFullScreen (true);
697: JOptionPane.showMessageDialog (
698: frmFrame,
699: ComponentFactory.createScrollTextPane (rscGetResourceText ("license_ymfm.txt"), 550, 300),
700: "ymfm License",
701: JOptionPane.PLAIN_MESSAGE);
702: }
703:
704:
705:
706: public static void prgOpenJSerialCommLicenseDialog () {
707: pnlExitFullScreen (true);
708: JOptionPane.showMessageDialog (
709: frmFrame,
710: ComponentFactory.createVerticalSplitPane (
711: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-APACHE-2.0"), 550, 300),
712: ComponentFactory.createScrollTextPane (rscGetResourceText ("LICENSE-LGPL-3.0"), 550, 300)
713: ),
714: "jSerialComm License",
715: JOptionPane.PLAIN_MESSAGE);
716: }
717:
718:
719:
720: public static void prgPrintClass (Object o) {
721: System.out.println (o.toString ());
722:
723: try {
724: Stack<Class<?>> s = new Stack<Class<?>> ();
725: for (Class<?> c = o.getClass (); c != null; c = c.getSuperclass ()) {
726: s.push (c);
727: }
728: for (int i = 0; !s.empty (); i++) {
729: for (int j = 0; j < i; j++) {
730: System.out.print (" ");
731: }
732: System.out.println (s.pop ().getName ());
733: }
734: } catch (Exception e) {
735: }
736: }
737:
738:
739:
740:
741: public static void prgPrintStackTrace () {
742: Exception e = new Exception ();
743: e.fillInStackTrace ();
744: prgPrintStackTraceOf (e);
745: }
746: public static void prgPrintStackTraceOf (Exception e) {
747:
748: System.out.println ("------------------------------------------------");
749: System.out.println (e.toString ());
750: System.out.println ("\t" + e.getMessage ());
751: for (StackTraceElement ste : e.getStackTrace ()) {
752: System.out.println ("\tat " + ste.toString ());
753: }
754: System.out.println ("------------------------------------------------");
755: }
756:
757:
758:
759:
760: public static boolean prgStopDone = false;
761: public static void prgStopOnce () {
762: if (!prgStopDone) {
763: prgStopDone = true;
764: mpuStop (null);
765: }
766: }
767:
768:
769:
770:
771:
772:
773:
774:
775:
776:
777:
778:
779:
780:
781:
782:
783:
784:
785:
786:
787:
788:
789:
790:
791:
792:
793:
794:
795:
796:
797:
798: public static final long TMR_FREQ = 1000000000000L;
799:
800:
801: public static final long TMR_DELAY = 10L;
802: public static final long TMR_INTERVAL = 10L;
803:
804:
805: public static java.util.Timer tmrTimer;
806:
807:
808:
809: public static void tmrStart () {
810: tmrTimer = new java.util.Timer ();
811: }
812:
813:
814:
815: public static void tmrTini () {
816: if (tmrTimer != null) {
817: tmrTimer.cancel ();
818: }
819: }
820:
821:
822:
823:
824:
825:
826:
827:
828:
829:
830:
831:
832:
833:
834:
835:
836:
837:
838:
839:
840:
841:
842:
843:
844:
845:
846:
847:
848:
849:
850:
851:
852:
853:
854:
855: public static final int PNL_BM_OFFSET_BITS = 10;
856: public static final int PNL_BM_WIDTH = 1 << PNL_BM_OFFSET_BITS;
857: public static final int PNL_BM_HEIGHT = 1024;
858:
859:
860:
861:
862:
863: public static final String[] PNL_ASPECT_RESOLUTION_NAME = {
864: "256x256",
865: "384x256",
866: "512x512",
867: "640x480",
868: "768x512",
869: "1024x848",
870: };
871:
872: public static final int PNL_ASPECT_RESOLUTION_COUNT = PNL_ASPECT_RESOLUTION_NAME.length;
873:
874:
875: public static final String[] PNL_ASPECT_SCREEN_NAME = {
876: "1:1",
877: "64:53",
878: "4:3",
879: "7:5",
880: "13:9",
881: "3:2",
882: };
883:
884: public static final int PNL_ASPECT_RATIO_COUNT = PNL_ASPECT_SCREEN_NAME.length;
885:
886:
887:
888: public static final int[] PNL_ASPECT_DEFAULT_RATIO = {
889: 2,
890: 2,
891: 2,
892: 2,
893: 5,
894: 1,
895: };
896:
897:
898: public static final String[] PNL_ASPECT_PIXEL_NAME_02 = {
899: "1:1",
900: null,
901: "4:3",
902: "7:5",
903: "13:9",
904: "3:2",
905: };
906:
907:
908: public static final String[] PNL_ASPECT_PIXEL_NAME_14 = {
909: null,
910: null,
911: "8:9",
912: "14:15",
913: "26:27",
914: "1:1",
915: };
916:
917:
918: public static final String[] PNL_ASPECT_PIXEL_NAME_3 = {
919: null,
920: null,
921: "1:1",
922: "21:20",
923: "13:12",
924: "9:8",
925: };
926:
927:
928: public static final String[] PNL_ASPECT_PIXEL_NAME_5 = {
929: null,
930: "1:1",
931: "53:48",
932: "371:320",
933: "689:576",
934: "159:128",
935: };
936:
937:
938: public static final float[] PNL_ASPECT_SCREEN_RATIO = {
939: 1.0F / 1.0F,
940: 64.0F / 53.0F,
941: 4.0F / 3.0F,
942: 7.0F / 5.0F,
943: 13.0F / 9.0F,
944: 3.0F / 2.0F,
945: };
946:
947:
948: public static final float[] PNL_ASPECT_PIXEL_RATIO_02 = {
949: 1.0F / 1.0F,
950: 0.0F,
951: 4.0F / 3.0F,
952: 7.0F / 5.0F,
953: 13.0F / 9.0F,
954: 3.0F / 2.0F,
955: };
956:
957:
958: public static final float[] PNL_ASPECT_PIXEL_RATIO_14 = {
959: 0.0F,
960: 0.0F,
961: 8.0F / 9.0F,
962: 14.0F / 15.0F,
963: 26.0F / 27.0F,
964: 1.0F / 1.0F,
965: };
966:
967:
968: public static final float[] PNL_ASPECT_PIXEL_RATIO_3 = {
969: 0.0F,
970: 0.0F,
971: 1.0F / 1.0F,
972: 21.0F / 20.0F,
973: 13.0F / 12.0F,
974: 9.0F / 8.0F,
975: };
976:
977:
978: public static final float[] PNL_ASPECT_PIXEL_RATIO_5 = {
979: 0.0F,
980: 1.0F / 1.0F,
981: 53.0F / 48.0F,
982: 371.0F / 320.0F,
983: 689.0F / 576.0F,
984: 159.0F / 128.0F,
985: };
986:
987:
988: public static final String[][] PNL_ASPECT_NAME_MATRIX = {
989: PNL_ASPECT_PIXEL_NAME_02,
990: PNL_ASPECT_PIXEL_NAME_14,
991: PNL_ASPECT_PIXEL_NAME_02,
992: PNL_ASPECT_PIXEL_NAME_3,
993: PNL_ASPECT_PIXEL_NAME_14,
994: PNL_ASPECT_PIXEL_NAME_5,
995: };
996:
997:
998: public static final float[][] PNL_ASPECT_RATIO_MATRIX = {
999: PNL_ASPECT_PIXEL_RATIO_02,
1000: PNL_ASPECT_PIXEL_RATIO_14,
1001: PNL_ASPECT_PIXEL_RATIO_02,
1002: PNL_ASPECT_PIXEL_RATIO_3,
1003: PNL_ASPECT_PIXEL_RATIO_14,
1004: PNL_ASPECT_PIXEL_RATIO_5,
1005: };
1006:
1007:
1008: public static int[] pnlAspectMap;
1009:
1010:
1011: public static float[] pnlAspectTableX;
1012: public static float[] pnlAspectTableY;
1013:
1014:
1015: public static final int PNL_MIN_WIDTH = 64;
1016: public static final int PNL_MIN_HEIGHT = 64;
1017: public static int pnlScreenWidth;
1018: public static int pnlScreenHeight;
1019: public static float pnlStretchModeX;
1020: public static float pnlStretchModeY;
1021: public static int pnlStretchWidth;
1022: public static int pnlStretchHeight;
1023:
1024: public static boolean PNL_ROTATION_ON = true;
1025: public static int pnlRotationMode;
1026: public static AffineTransform pnlRotationTransformLeft;
1027: public static AffineTransform pnlRotationTransformRight;
1028: public static double pnlMatrixL00, pnlMatrixL10, pnlMatrixL01, pnlMatrixL11, pnlMatrixL02, pnlMatrixL12;
1029: public static double pnlMatrixR00, pnlMatrixR10, pnlMatrixR01, pnlMatrixR11, pnlMatrixR02, pnlMatrixR12;
1030: public static double pnlInverseL00, pnlInverseL10, pnlInverseL01, pnlInverseL11, pnlInverseL02, pnlInverseL12;
1031: public static double pnlInverseR00, pnlInverseR10, pnlInverseR01, pnlInverseR11, pnlInverseR02, pnlInverseR12;
1032: public static int pnlRotatedWidth;
1033: public static int pnlRotatedHeight;
1034:
1035: public static int pnlZoomWidth;
1036: public static int pnlZoomHeight;
1037: public static int pnlZoomRatioOutX;
1038: public static int pnlZoomRatioOutY;
1039: public static int pnlZoomRatioInX;
1040: public static int pnlZoomRatioInY;
1041: public static int pnlWidth;
1042: public static int pnlHeight;
1043: public static Dimension pnlSize;
1044: public static int pnlScreenX1;
1045: public static int pnlScreenX2;
1046: public static int pnlScreenX3;
1047: public static int pnlScreenX4;
1048: public static int pnlScreenY1;
1049: public static int pnlScreenY2;
1050: public static int pnlScreenY3;
1051: public static int pnlScreenY4;
1052: public static int pnlKeyboardX;
1053: public static int pnlKeyboardY;
1054: public static int pnlMinimumWidth;
1055: public static int pnlMinimumHeight;
1056: public static int pnlGlobalX;
1057: public static int pnlGlobalY;
1058:
1059:
1060: public static final boolean PNL_FILL_BACKGROUND = true;
1061: public static boolean pnlFillBackgroundRequest;
1062: public static boolean pnlIsFullScreenSupported;
1063: public static boolean pnlPrevKeyboardOn;
1064: public static boolean pnlHideKeyboard;
1065:
1066:
1067:
1068:
1069:
1070: public static Object pnlInterpolation;
1071:
1072:
1073: public static final double PNL_MIN_RATE = 1.0;
1074: public static final double PNL_MAX_RATE = 1000.0;
1075: public static final double PNL_DEFAULT_RATE = 59.94;
1076: public static double pnlRefreshRate;
1077: public static double pnlFixedRate;
1078: public static boolean pnlAdjustVsync;
1079:
1080:
1081:
1082:
1083:
1084:
1085:
1086:
1087:
1088:
1089:
1090:
1091:
1092:
1093:
1094:
1095:
1096:
1097:
1098:
1099:
1100:
1101:
1102:
1103:
1104:
1105:
1106:
1107:
1108:
1109:
1110:
1111:
1112:
1113:
1114:
1115:
1116:
1117:
1118:
1119:
1120:
1121:
1122:
1123:
1124:
1125:
1126:
1127:
1128: public static final boolean PNL_STEREOSCOPIC_ON = true;
1129:
1130: public static final boolean PNL_USE_THREAD = true;
1131:
1132: public static BufferedImage[] pnlScreenImageLeftArray;
1133: public static BufferedImage[] pnlScreenImageRightArray;
1134:
1135: public static BufferedImage[] pnlScreenSubImageLeftArray;
1136: public static BufferedImage[] pnlScreenSubImageRightArray;
1137:
1138: public static int[][] pnlBMLeftArray;
1139: public static int[][] pnlBMRightArray;
1140: public static volatile int pnlBMWrite;
1141: public static volatile int pnlBMRead;
1142:
1143: public static BufferedImage pnlScreenImageLeft;
1144: public static BufferedImage pnlScreenImageRight;
1145:
1146: public static BufferedImage pnlScreenSubImageLeft;
1147: public static BufferedImage pnlScreenSubImageRight;
1148:
1149: public static int[] pnlBMLeft;
1150: public static int[] pnlBMRight;
1151:
1152: public static int[] pnlBM;
1153: public static boolean pnlStereoscopicOn;
1154: public static final int PNL_NAKED_EYE_CROSSING = 0;
1155: public static final int PNL_NAKED_EYE_PARALLEL = 1;
1156: public static final int PNL_SIDE_BY_SIDE = 2;
1157: public static final int PNL_TOP_AND_BOTTOM = 3;
1158: public static int pnlStereoscopicMethod;
1159: public static int pnlStereoscopicFactor;
1160: public static int pnlStereoscopicShutter;
1161:
1162:
1163: public static JPanel pnlPanel;
1164:
1165: public static Thread pnlThread;
1166: public static boolean pnlInterrupted;
1167: public static long pnlWakeupTime;
1168: public static long pnlWakeupTimeMNP;
1169: public static final boolean PNL_USE_CANVAS = PNL_USE_THREAD && true;
1170:
1171: public static boolean pnlUseCanvasRequest;
1172: public static boolean pnlUseCanvas;
1173: public static Canvas pnlCanvas;
1174: public static Component pnlCanvasOrPanel;
1175:
1176:
1177:
1178:
1179: public static int pnlFixedScale;
1180: public static SpinnerNumberModel pnlFixedModel;
1181: public static JSpinner pnlFixedSpinner;
1182:
1183:
1184:
1185: public static void pnlInit () {
1186: pnlInit2 ();
1187:
1188:
1189:
1190:
1191: pnlFixedScale = Math.max (10, Math.min (1000, Settings.sgsGetInt ("fixedscale")));
1192:
1193:
1194: pnlAspectMap = new int[PNL_ASPECT_RESOLUTION_COUNT];
1195: for (int resolutionNumber = 0; resolutionNumber < PNL_ASPECT_RESOLUTION_COUNT; resolutionNumber++) {
1196: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[resolutionNumber];
1197: String screenName = Settings.sgsGetString ("aspectratio" + resolutionName);
1198: int ratioNumber = PNL_ASPECT_DEFAULT_RATIO[resolutionNumber];
1199: for (int tempRatioNumber = 0; tempRatioNumber < PNL_ASPECT_RATIO_COUNT; tempRatioNumber++) {
1200: if (PNL_ASPECT_RATIO_MATRIX[resolutionNumber][tempRatioNumber] == 0.0F) {
1201: continue;
1202: }
1203: if (PNL_ASPECT_SCREEN_NAME[tempRatioNumber].equals (screenName)) {
1204: ratioNumber = tempRatioNumber;
1205: break;
1206: }
1207: }
1208: pnlAspectMap[resolutionNumber] = ratioNumber;
1209: }
1210: pnlAspectTableX = new float[64];
1211: pnlAspectTableY = new float[64];
1212: pnlUpdateAspectTable ();
1213:
1214:
1215: switch (Settings.sgsGetString ("interpolation").toLowerCase ()) {
1216: case "nearest":
1217: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
1218: break;
1219: case "bilinear":
1220: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
1221: break;
1222: case "bicubic":
1223: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
1224: break;
1225: default:
1226: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
1227: }
1228:
1229:
1230: pnlRefreshRate = 0.0;
1231: {
1232: String s = Settings.sgsGetString ("refreshrate");
1233: if (!s.equals ("")) {
1234: try {
1235: double rate = Double.parseDouble (s);
1236: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
1237: pnlRefreshRate = rate;
1238: }
1239: } catch (NumberFormatException nfe) {
1240: }
1241: }
1242: }
1243: pnlFixedRate = pnlRefreshRate;
1244: pnlAdjustVsync = Settings.sgsGetOnOff ("adjustvsync");
1245:
1246: pnlPrevKeyboardOn = true;
1247:
1248: pnlHideKeyboard = Settings.sgsGetOnOff ("hidekeyboard");
1249:
1250:
1251: if (PNL_USE_THREAD) {
1252: pnlScreenImageLeftArray = new BufferedImage[4];
1253: pnlScreenImageRightArray = new BufferedImage[4];
1254: if (PNL_ROTATION_ON) {
1255: pnlScreenSubImageLeftArray = new BufferedImage[4];
1256: pnlScreenSubImageRightArray = new BufferedImage[4];
1257: }
1258: pnlBMLeftArray = new int[4][];
1259: pnlBMRightArray = new int[4][];
1260: for (int n = 0; n < 4; n++) {
1261: pnlScreenImageLeftArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1262: pnlScreenImageRightArray[n] = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1263: if (PNL_ROTATION_ON) {
1264: pnlScreenSubImageLeftArray[n] = null;
1265: pnlScreenSubImageRightArray[n] = null;
1266: }
1267: pnlBMLeftArray[n] = ((DataBufferInt) pnlScreenImageLeftArray[n].getRaster ().getDataBuffer ()).getData ();
1268: pnlBMRightArray[n] = ((DataBufferInt) pnlScreenImageRightArray[n].getRaster ().getDataBuffer ()).getData ();
1269: }
1270: pnlBMWrite = 0;
1271: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
1272: pnlBMRead = 0;
1273: pnlThread = null;
1274: pnlInterrupted = false;
1275: pnlWakeupTime = 0L;
1276: pnlWakeupTimeMNP = 0L;
1277: if (PNL_USE_CANVAS) {
1278: pnlUseCanvasRequest = Settings.sgsGetOnOff ("usecanvas");
1279: pnlUseCanvas = pnlUseCanvasRequest;
1280: pnlCanvas = null;
1281: }
1282: } else {
1283: pnlScreenImageLeft = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1284: pnlScreenImageRight = new BufferedImage (PNL_BM_WIDTH, PNL_BM_HEIGHT, BufferedImage.TYPE_INT_ARGB);
1285: if (PNL_ROTATION_ON) {
1286: pnlScreenSubImageLeft = null;
1287: pnlScreenSubImageRight = null;
1288: }
1289: pnlBMLeft = ((DataBufferInt) pnlScreenImageLeft.getRaster ().getDataBuffer ()).getData ();
1290: pnlBMRight = ((DataBufferInt) pnlScreenImageRight.getRaster ().getDataBuffer ()).getData ();
1291: pnlBM = pnlBMLeft;
1292: }
1293: pnlStereoscopicOn = Settings.sgsGetOnOff ("stereoscopic");
1294: switch (Settings.sgsGetString ("stereoscopicmethod").toLowerCase ()) {
1295: case "nakedeyecrossing":
1296: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
1297: break;
1298: case "nakedeyeparallel":
1299: pnlStereoscopicMethod = PNL_NAKED_EYE_PARALLEL;
1300: break;
1301: case "sidebyside":
1302: pnlStereoscopicMethod = PNL_SIDE_BY_SIDE;
1303: break;
1304: case "topandbottom":
1305: pnlStereoscopicMethod = PNL_TOP_AND_BOTTOM;
1306: break;
1307: default:
1308: pnlStereoscopicMethod = PNL_NAKED_EYE_CROSSING;
1309: }
1310: pnlStereoscopicFactor = pnlStereoscopicOn && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1311: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1312: pnlStereoscopicShutter = 0;
1313:
1314:
1315: pnlScreenWidth = 768;
1316: pnlScreenHeight = 512;
1317: pnlStretchModeX = 1.0F;
1318: pnlStretchModeY = 1.0F;
1319: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchModeX);
1320: pnlStretchHeight = Math.round ((float) pnlScreenHeight * pnlStretchModeY);
1321:
1322: if (PNL_ROTATION_ON) {
1323: pnlRotationMode = Settings.sgsGetInt ("rotation", 0);
1324: if (pnlRotationMode < 0 || 3 < pnlRotationMode) {
1325: pnlRotationMode = 0;
1326: }
1327: pnlRotationTransformLeft = new AffineTransform ();
1328: pnlRotationTransformRight = new AffineTransform ();
1329: }
1330: pnlRotatedWidth = pnlStretchWidth;
1331: pnlRotatedHeight = pnlStretchHeight;
1332: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1333: pnlRotatedWidth = pnlStretchHeight;
1334: pnlRotatedHeight = pnlStretchWidth;
1335: }
1336:
1337: pnlZoomWidth = pnlRotatedWidth;
1338: pnlZoomHeight = pnlRotatedHeight;
1339: pnlWidth = Math.max (pnlZoomWidth * pnlStereoscopicFactor, Keyboard.kbdWidth);
1340: pnlHeight = pnlZoomHeight + Keyboard.kbdHeight;
1341: pnlSize = new Dimension (pnlWidth, pnlHeight);
1342: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1343: pnlScreenY1 = 0;
1344: pnlArrangementCommon ();
1345: pnlMinimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
1346: pnlMinimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
1347: pnlGlobalX = 0;
1348: pnlGlobalY = 0;
1349:
1350:
1351: if (!PNL_FILL_BACKGROUND) {
1352: pnlFillBackgroundRequest = true;
1353: }
1354:
1355:
1356: pnlFixedModel = new SpinnerNumberModel (pnlFixedScale, 10, 1000, 1);
1357: pnlFixedSpinner = ComponentFactory.createNumberSpinner (pnlFixedModel, 4, new ChangeListener () {
1358: @Override public void stateChanged (ChangeEvent ce) {
1359: if (pnlMode != PNL_FIXEDSCALE) {
1360: pnlSetMode (PNL_FIXEDSCALE);
1361: } else {
1362: pnlUpdateArrangement ();
1363: }
1364: }
1365: });
1366:
1367: if (PNL_ROUNDED_CORNER_ON) {
1368: pnlRoundedCornerModel = new SpinnerNumberModel (pnlRoundedCornerRatio, 0, 50, 1);
1369: pnlRoundedCornerSpinner = ComponentFactory.createNumberSpinner (pnlRoundedCornerModel, 2, new ChangeListener () {
1370: @Override public void stateChanged (ChangeEvent ce) {
1371: pnlRoundedCornerRatio = pnlRoundedCornerModel.getNumber ().intValue ();
1372: if (PNL_ROUNDED_CORNER_TEST || pnlMode == PNL_FULLSCREEN) {
1373: pnlUpdateArrangement ();
1374: }
1375: }
1376: });
1377: }
1378:
1379: }
1380:
1381:
1382:
1383: public static double pnlGetRefreshRate () {
1384: double rate = 0.0;
1385: GraphicsConfiguration gc = frmFrame.getGraphicsConfiguration ();
1386: if (gc != null) {
1387: GraphicsDevice gd = gc.getDevice ();
1388: DisplayMode dm = gd.getDisplayMode ();
1389: int i = dm.getRefreshRate ();
1390: if (i != DisplayMode.REFRESH_RATE_UNKNOWN) {
1391: rate = (i == 23 ? 23.98 :
1392: i == 29 ? 29.97 :
1393: i == 59 ? 59.94 :
1394: i == 119 ? 119.88 :
1395: i == 239 ? 239.76 :
1396: (double) i);
1397: if (rate < PNL_MIN_RATE || PNL_MAX_RATE < rate) {
1398: rate = 0.0;
1399: }
1400: }
1401: }
1402: if (rate == 0.0) {
1403: rate = PNL_DEFAULT_RATE;
1404: System.out.printf (Multilingual.mlnJapanese ?
1405: "ホストのリフレッシュレートを取得できません。デフォルトの %.2f Hz を使います\n" :
1406: "Cannot get host refresh rate. Use default %.2f Hz\n", rate);
1407: } else {
1408: System.out.printf (Multilingual.mlnJapanese ?
1409: "ホストのリフレッシュレートは %.2f Hz です\n" :
1410: "Host refresh rate is %.2f Hz\n", rate);
1411: }
1412: return rate;
1413: }
1414:
1415:
1416: public static void pnlSetStereoscopic (boolean on, int method) {
1417: if (pnlStereoscopicOn != on || pnlStereoscopicMethod != method) {
1418: pnlStereoscopicMethod = method;
1419: pnlStereoscopicFactor = on && (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
1420: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) ? 2 : 1;
1421: if (!pnlStereoscopicOn && on) {
1422: if (PNL_USE_THREAD) {
1423: for (int n = 0; n < 4; n++) {
1424: System.arraycopy (pnlBMLeftArray[n], 0, pnlBMRightArray[n], 0, 1024 * 1024);
1425: }
1426: } else {
1427: System.arraycopy (pnlBMLeft, 0, pnlBMRight, 0, 1024 * 1024);
1428: }
1429: } else if (pnlStereoscopicOn && !on) {
1430: if (PNL_USE_THREAD) {
1431: pnlBM = pnlBMLeftArray[pnlBMWrite & 3];
1432: } else {
1433: pnlBM = pnlBMLeft;
1434: }
1435: }
1436: pnlStereoscopicOn = on;
1437: pnlUpdateArrangement ();
1438: }
1439: }
1440:
1441:
1442: public static void pnlTini () {
1443: pnlTini2 ();
1444: if (PNL_USE_THREAD) {
1445: if (pnlThread != null) {
1446: pnlInterrupted = true;
1447: try {
1448: pnlThread.join (100L);
1449: } catch (InterruptedException ie) {
1450: }
1451: pnlThread = null;
1452: }
1453: }
1454:
1455:
1456: Settings.sgsPutInt ("fixedscale", pnlFixedScale);
1457:
1458:
1459: for (int resolutionNumber = 0; resolutionNumber < PNL_ASPECT_RESOLUTION_COUNT; resolutionNumber++) {
1460: String resolutionName = PNL_ASPECT_RESOLUTION_NAME[resolutionNumber];
1461: int ratioNumber = pnlAspectMap[resolutionNumber];
1462: String screenName = PNL_ASPECT_SCREEN_NAME[ratioNumber];
1463: Settings.sgsPutString ("aspectratio" + resolutionName, screenName);
1464: }
1465:
1466:
1467: Settings.sgsPutString ("interpolation",
1468: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR ? "nearest" :
1469: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR ? "bilinear" :
1470: pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC ? "bicubic" :
1471: "bilinear");
1472:
1473: if (pnlRefreshRate != PNL_DEFAULT_RATE) {
1474: Settings.sgsPutString ("refreshrate",
1475: pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate));
1476: }
1477: Settings.sgsPutOnOff ("adjustvsync", pnlAdjustVsync);
1478:
1479: Settings.sgsPutOnOff ("hidekeyboard", pnlHideKeyboard);
1480:
1481: if (PNL_USE_CANVAS) {
1482: Settings.sgsPutOnOff ("usecanvas", pnlUseCanvasRequest);
1483: }
1484:
1485:
1486: Settings.sgsPutOnOff ("stereoscopic", pnlStereoscopicOn);
1487: Settings.sgsPutString ("stereoscopicmethod",
1488: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ? "nakedeyecrossing" :
1489: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL ? "nakedeyeparallel" :
1490: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ? "sidebyside" :
1491: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM ? "topandbottom" :
1492: "nakedeyecrossing");
1493:
1494:
1495: if (PNL_ROTATION_ON) {
1496: Settings.sgsPutInt ("rotation", pnlRotationMode);
1497: }
1498:
1499: }
1500:
1501:
1502:
1503: public static void pnlUpdateAspectTable () {
1504: float[] ratio = new float[PNL_ASPECT_RESOLUTION_COUNT];
1505: for (int resolutionNumber = 0; resolutionNumber < PNL_ASPECT_RESOLUTION_COUNT; resolutionNumber++) {
1506: int ratioNumber = pnlAspectMap[resolutionNumber];
1507: ratio[resolutionNumber] = PNL_ASPECT_RATIO_MATRIX[resolutionNumber][ratioNumber];
1508: }
1509: Arrays.fill (pnlAspectTableY, 1.0F);
1510:
1511: pnlAspectTableX[0b0_00_00] = ratio[0] * 2.0F;
1512: pnlAspectTableX[0b0_00_01] = ratio[2];
1513: pnlAspectTableX[0b0_00_10] = ratio[4];
1514: pnlAspectTableX[0b0_00_11] = ratio[3];
1515: pnlAspectTableX[0b0_01_00] = ratio[0] * 2.0F;
1516: pnlAspectTableX[0b0_01_01] = ratio[2];
1517: pnlAspectTableX[0b0_01_10] = ratio[4];
1518: pnlAspectTableX[0b0_01_11] = ratio[3];
1519: pnlAspectTableX[0b0_10_00] = ratio[0] * 4.0F;
1520: pnlAspectTableX[0b0_10_01] = ratio[2] * 2.0F;
1521: pnlAspectTableX[0b0_10_10] = ratio[4] * 2.0F;
1522: pnlAspectTableX[0b0_10_11] = ratio[3] * 2.0F;
1523: pnlAspectTableX[0b0_11_00] = ratio[0] * 4.0F;
1524: pnlAspectTableX[0b0_11_01] = ratio[2] * 2.0F;
1525: pnlAspectTableX[0b0_11_10] = ratio[4] * 2.0F;
1526: pnlAspectTableX[0b0_11_11] = ratio[3] * 2.0F;
1527: pnlAspectTableX[0b1_00_00] = ratio[0] * 2.0F;
1528: pnlAspectTableX[0b1_00_01] = ratio[1] * 2.0F;
1529: pnlAspectTableX[0b1_00_10] = ratio[4];
1530: pnlAspectTableX[0b1_00_11] = ratio[3];
1531: pnlAspectTableX[0b1_01_00] = ratio[0] * 2.0F;
1532: pnlAspectTableX[0b1_01_01] = ratio[1] * 2.0F;
1533: pnlAspectTableX[0b1_01_10] = ratio[4];
1534: pnlAspectTableX[0b1_01_11] = ratio[3];
1535: pnlAspectTableX[0b1_10_00] = ratio[0] * 4.0F;
1536: pnlAspectTableX[0b1_10_01] = ratio[1] * 2.0F;
1537: pnlAspectTableX[0b1_10_10] = ratio[4] * 2.0F;
1538: pnlAspectTableX[0b1_10_11] = ratio[3] * 2.0F;
1539: pnlAspectTableX[0b1_11_00] = ratio[0] * 4.0F;
1540: pnlAspectTableX[0b1_11_01] = ratio[1] * 2.0F;
1541: pnlAspectTableX[0b1_11_10] = ratio[4] * 2.0F;
1542: pnlAspectTableX[0b1_11_11] = ratio[3] * 2.0F;
1543:
1544: for (int i = 0; i < 32; i++) {
1545: pnlAspectTableX[32 + i] = pnlAspectTableX[i];
1546: }
1547:
1548: pnlAspectTableX[32 + 0b0_00_10] = ratio[5];
1549: pnlAspectTableY[32 + 0b0_00_10] = 2.0F;
1550: pnlAspectTableX[32 + 0b0_01_10] = ratio[5];
1551: pnlAspectTableY[32 + 0b0_01_10] = 2.0F;
1552: pnlAspectTableX[32 + 0b0_10_10] = ratio[5];
1553: pnlAspectTableX[32 + 0b0_11_10] = ratio[5];
1554: pnlAspectTableX[32 + 0b1_00_01] = ratio[5];
1555: pnlAspectTableX[32 + 0b1_01_01] = ratio[5];
1556: pnlAspectTableX[32 + 0b1_10_01] = ratio[5] * 2.0F;
1557: pnlAspectTableX[32 + 0b1_11_01] = ratio[5] * 2.0F;
1558: }
1559:
1560:
1561:
1562: public static void pnlMake () {
1563: pnlMake2 ();
1564:
1565:
1566: if (PNL_USE_CANVAS && pnlUseCanvas) {
1567: pnlCanvas = new Canvas ();
1568: pnlPanel = new JPanel (new BorderLayout (0, 0));
1569: pnlPanel.add (pnlCanvas, BorderLayout.CENTER);
1570: pnlCanvasOrPanel = pnlCanvas;
1571: } else {
1572: pnlPanel = new JPanel () {
1573: @Override protected void paintComponent (Graphics g) {
1574: pnlPaintCommon (g);
1575: }
1576: @Override protected void paintBorder (Graphics g) {
1577: }
1578: @Override protected void paintChildren (Graphics g) {
1579: }
1580: };
1581: pnlCanvasOrPanel = pnlPanel;
1582: }
1583: pnlPanel.setBackground (Color.black);
1584: pnlPanel.setOpaque (true);
1585: pnlPanel.setPreferredSize (pnlSize);
1586:
1587: if (Mouse.musCursorAvailable) {
1588: pnlPanel.setCursor (Mouse.musCursorArray[1]);
1589: }
1590:
1591: }
1592:
1593:
1594:
1595: public static void pnlPaintCommon (Graphics g) {
1596: Graphics2D g2 = (Graphics2D) g;
1597: if (PNL_FILL_BACKGROUND || pnlFillBackgroundRequest) {
1598: if (!PNL_FILL_BACKGROUND) {
1599: pnlFillBackgroundRequest = false;
1600: }
1601: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1602: g2.setColor (Color.black);
1603: g2.fillRect (0, 0, pnlWidth, pnlHeight);
1604: }
1605: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, pnlInterpolation);
1606: boolean compositeSet = false;
1607: if (FlashingLights.FLR_ON &&
1608: FlashingLights.flrScreen) {
1609: float brightness = FlashingLights.flrBrightness[pnlBMRead & 3];
1610: if (brightness < 1.0F) {
1611: g2.setComposite (
1612: AlphaComposite.getInstance (AlphaComposite.SRC_OVER, brightness));
1613: compositeSet = true;
1614: }
1615: }
1616: if (PNL_USE_THREAD) {
1617: int d = pnlBMWrite - pnlBMRead;
1618: if (false) {
1619: System.out.print (d);
1620: }
1621: if (d < 1) {
1622: pnlBMRead += d - 1;
1623: } else if (3 < d) {
1624: pnlBMRead += d - 3;
1625: }
1626: int n = pnlBMRead++ & 3;
1627: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1628: BufferedImage leftImage;
1629: BufferedImage rightImage;
1630: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1631: leftImage = pnlScreenImageRightArray[n];
1632: rightImage = pnlScreenImageLeftArray[n];
1633: } else {
1634:
1635:
1636:
1637: leftImage = pnlScreenImageLeftArray[n];
1638: rightImage = pnlScreenImageRightArray[n];
1639: }
1640: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1641: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1642: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1643: } else {
1644: g2.drawImage (leftImage,
1645: pnlScreenX1, pnlScreenY1,
1646: pnlScreenX2, pnlScreenY2,
1647: 0, 0, pnlScreenWidth, pnlScreenHeight,
1648: null);
1649: g2.drawImage (rightImage,
1650: pnlScreenX3, pnlScreenY3,
1651: pnlScreenX4, pnlScreenY4,
1652: 0, 0, pnlScreenWidth, pnlScreenHeight,
1653: null);
1654: }
1655: } else {
1656: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1657: g2.drawImage (pnlScreenSubImageLeftArray[n], pnlRotationTransformLeft, null);
1658: } else {
1659: g2.drawImage (pnlScreenImageLeftArray[n],
1660: pnlScreenX1, pnlScreenY1,
1661: pnlScreenX2, pnlScreenY2,
1662: 0, 0, pnlScreenWidth, pnlScreenHeight,
1663: null);
1664: }
1665: }
1666: } else {
1667: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
1668: BufferedImage leftImage;
1669: BufferedImage rightImage;
1670: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING) {
1671: leftImage = pnlScreenImageRight;
1672: rightImage = pnlScreenImageLeft;
1673: } else {
1674:
1675:
1676:
1677: leftImage = pnlScreenImageLeft;
1678: rightImage = pnlScreenImageRight;
1679: }
1680: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1681: g2.drawImage (leftImage, pnlRotationTransformLeft, null);
1682: g2.drawImage (rightImage, pnlRotationTransformRight, null);
1683: } else {
1684: g2.drawImage (leftImage,
1685: pnlScreenX1, pnlScreenY1,
1686: pnlScreenX2, pnlScreenY2,
1687: 0, 0, pnlScreenWidth, pnlScreenHeight,
1688: null);
1689: g2.drawImage (rightImage,
1690: pnlScreenX3, pnlScreenY3,
1691: pnlScreenX4, pnlScreenY4,
1692: 0, 0, pnlScreenWidth, pnlScreenHeight,
1693: null);
1694: }
1695: } else {
1696: if (PNL_ROTATION_ON && pnlRotationMode != 0) {
1697: g2.drawImage (pnlScreenImageLeft, pnlRotationTransformLeft, null);
1698: } else {
1699: g2.drawImage (pnlScreenImageLeft,
1700: pnlScreenX1, pnlScreenY1,
1701: pnlScreenX2, pnlScreenY2,
1702: 0, 0, pnlScreenWidth, pnlScreenHeight,
1703: null);
1704: }
1705: }
1706: }
1707: if (compositeSet) {
1708: g2.setComposite (
1709: AlphaComposite.getInstance (
1710: AlphaComposite.SRC_OVER,
1711: 1.0F));
1712: }
1713: g2.setRenderingHint (RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
1714: g2.drawImage (Keyboard.kbdImage, pnlKeyboardX, pnlKeyboardY, null);
1715:
1716: if (TextCopy.txcEncloseEachTime && 0 <= TextCopy.txcRow1) {
1717: int x = TextCopy.txcCol1 << 3;
1718: int w = (TextCopy.txcCol2 - TextCopy.txcCol1 + 1) << 3;
1719: int y = TextCopy.txcRow1 << 4;
1720: int h = (TextCopy.txcRow2 - TextCopy.txcRow1 + 1) << 4;
1721: x -= CRTC.crtR10TxXCurr;
1722: y -= CRTC.crtR11TxYCurr;
1723: g2.setColor (Color.red);
1724: if (PNL_ROTATION_ON) {
1725: AffineTransform savedTransform = g2.getTransform ();
1726: g2.transform (pnlRotationTransformLeft);
1727: g2.drawRect (x, y, w, h);
1728: g2.setTransform (savedTransform);
1729: } else {
1730: g2.drawRect (pnlScreenX1 + ((x * pnlZoomRatioOutX) >> 16),
1731: pnlScreenY1 + ((y * pnlZoomRatioOutY) >> 16),
1732: ((w * pnlZoomRatioOutX) >> 16) - 1,
1733: ((h * pnlZoomRatioOutY) >> 16) - 1);
1734: }
1735: }
1736: if (Bubble.BBL_ON) {
1737: Bubble.bblDraw (g2);
1738: }
1739: }
1740:
1741:
1742:
1743:
1744: public static void pnlStart () {
1745: pnlStart2 ();
1746:
1747:
1748: ComponentFactory.addListener (
1749: pnlPanel,
1750: new ComponentAdapter () {
1751: @Override public void componentResized (ComponentEvent ce) {
1752: pnlUpdateArrangement ();
1753: }
1754: });
1755:
1756: if (PNL_USE_THREAD) {
1757: if (PNL_USE_CANVAS && pnlUseCanvas) {
1758: pnlCanvas.createBufferStrategy (2);
1759: pnlThread = new Thread () {
1760: @Override public void run () {
1761: do {
1762: BufferStrategy bs = pnlCanvas.getBufferStrategy ();
1763: if (bs != null) {
1764: Graphics g = bs.getDrawGraphics ();
1765: pnlPaintCommon (g);
1766: g.dispose ();
1767: bs.show ();
1768: }
1769: } while (!pnlInterrupted && pnlWakeupCommon ());
1770: }
1771: };
1772: } else {
1773: pnlThread = new Thread () {
1774: @Override public void run () {
1775: do {
1776: pnlPanel.repaint ();
1777: } while (!pnlInterrupted && pnlWakeupCommon ());
1778: }
1779: };
1780: }
1781: pnlWakeupTime = System.currentTimeMillis ();
1782: pnlWakeupTimeMNP = 0L;
1783: pnlThread.start ();
1784: }
1785:
1786: }
1787:
1788: public static boolean pnlWakeupCommon () {
1789: long t = System.currentTimeMillis ();
1790: if (CRTC.crtTotalLength == 0L) {
1791: pnlWakeupTime += 40L;
1792: } else {
1793: pnlWakeupTime += CRTC.crtTotalLength;
1794: pnlWakeupTimeMNP += CRTC.crtTotalLengthMNP;
1795: if (1000000000L <= pnlWakeupTimeMNP) {
1796: pnlWakeupTime++;
1797: pnlWakeupTimeMNP -= 1000000000L;
1798: }
1799: }
1800: pnlWakeupTime = Math.max (pnlWakeupTime, t + 4L);
1801: try {
1802: Thread.sleep (pnlWakeupTime - t);
1803: } catch (InterruptedException ie) {
1804: return false;
1805: }
1806: return true;
1807: }
1808:
1809:
1810:
1811:
1812:
1813: public static void pnlExitFullScreen (boolean dialog) {
1814: if (prgIsMac || !dialog) {
1815: pnlSetFullScreenOn (false);
1816: }
1817: }
1818:
1819:
1820:
1821: public static void pnlToggleFullScreen () {
1822: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1823: pnlSetMode (PNL_FULLSCREEN);
1824: } else {
1825: pnlSetMode (pnlPrevMode);
1826: }
1827: }
1828:
1829:
1830:
1831: public static void pnlToggleMaximized () {
1832: if (pnlMode == PNL_FIXEDSCALE || pnlMode == PNL_FITINWINDOW) {
1833: pnlSetMode (PNL_MAXIMIZED);
1834: } else {
1835: pnlSetMode (pnlPrevMode);
1836: }
1837: }
1838:
1839:
1840:
1841: public static void pnlSetFullScreenOn (boolean on) {
1842: if (on) {
1843: pnlSetMode (PNL_FULLSCREEN);
1844: } else if (pnlMode == PNL_FULLSCREEN) {
1845: pnlSetMode (pnlPrevMode);
1846: }
1847: }
1848:
1849:
1850:
1851:
1852: public static void pnlSetFitInWindowOn (boolean on) {
1853: if (!on) {
1854: pnlSetMode (PNL_FIXEDSCALE);
1855: } else if (pnlMode == PNL_FIXEDSCALE) {
1856: pnlSetMode (PNL_FITINWINDOW);
1857: }
1858: }
1859:
1860:
1861:
1862:
1863:
1864:
1865:
1866:
1867:
1868:
1869: public static void pnlUpdateArrangement () {
1870: pnlWidth = pnlPanel.getWidth ();
1871: pnlHeight = pnlPanel.getHeight ();
1872: frmMarginWidth = frmFrame.getWidth () - pnlWidth;
1873: frmMarginHeight = frmFrame.getHeight () - pnlHeight;
1874: int stretchIndex = CRTC.crtHRLCurr << 4 | CRTC.crtVResoCurr << 2 | CRTC.crtHResoCurr;
1875: {
1876: int htotal = CRTC.crtR00HFrontEndCurr + 1;
1877: int vtotal = CRTC.crtR04VFrontEndCurr + 1;
1878: if (0 < htotal && 0 < vtotal) {
1879: int k = CRTC.crtHRLCurr << 3 | CRTC.crtHighResoCurr << 2 | CRTC.crtHResoCurr;
1880: double osc = (double) CRTC.crtFreqs[CRTC.CRT_OSCS[k]] * CRTC.crtVsyncMultiplier;
1881: int ratio = CRTC.CRT_DIVS[k];
1882: double hfreq = osc / (ratio * htotal << 3);
1883: if (24000.0 <= hfreq && hfreq < 25000.0) {
1884: stretchIndex += 32;
1885: }
1886: }
1887: }
1888: pnlStretchModeX = pnlAspectTableX[stretchIndex];
1889: pnlStretchModeY = pnlAspectTableY[stretchIndex];
1890: pnlScreenWidth = Math.max (PNL_MIN_WIDTH, (CRTC.crtR03HDispEndCurr - CRTC.crtR02HBackEndCurr) << 3);
1891: pnlScreenHeight = Math.max (PNL_MIN_HEIGHT, (CRTC.crtR07VDispEndCurr - CRTC.crtR06VBackEndCurr) << (CRTC.crtInterlace || CRTC.crtSlit ? 1 : 0));
1892: pnlStretchWidth = Math.round ((float) pnlScreenWidth * pnlStretchModeX);
1893: pnlStretchHeight = Math.round ((float) pnlScreenHeight * pnlStretchModeY);
1894: if (RasterBreakPoint.RBP_ON) {
1895:
1896: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
1897: RasterBreakPoint.rbpUpdateFrame ();
1898: }
1899: }
1900:
1901: pnlFixedScale = pnlFixedModel.getNumber ().intValue ();
1902:
1903: pnlRotatedWidth = pnlStretchWidth;
1904: pnlRotatedHeight = pnlStretchHeight;
1905: if (PNL_ROTATION_ON && ((pnlRotationMode & 1) != 0)) {
1906: pnlRotatedWidth = pnlStretchHeight;
1907: pnlRotatedHeight = pnlStretchWidth;
1908: }
1909: if (pnlMode == PNL_FIXEDSCALE) {
1910:
1911:
1912:
1913:
1914:
1915: pnlZoomWidth = (pnlRotatedWidth * pnlFixedScale + 50) * 5243 >>> 19;
1916: pnlZoomHeight = (pnlRotatedHeight * pnlFixedScale + 50) * 5243 >>> 19;
1917: int width = Math.max (Math.max (PNL_MIN_WIDTH, pnlZoomWidth * pnlStereoscopicFactor), Keyboard.kbdWidth);
1918: int height = Math.max (PNL_MIN_HEIGHT, pnlZoomHeight) + Keyboard.kbdHeight;
1919: pnlScreenX1 = (width - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1920: pnlScreenY1 = (height - pnlZoomHeight - Keyboard.kbdHeight) >> 1;
1921: if (pnlWidth != width || pnlHeight != height) {
1922: pnlWidth = width;
1923: pnlHeight = height;
1924: pnlMinimumWidth = width;
1925: pnlMinimumHeight = height;
1926: pnlSize.setSize (width, height);
1927: pnlPanel.setMinimumSize (pnlSize);
1928: pnlPanel.setMaximumSize (pnlSize);
1929: pnlPanel.setPreferredSize (pnlSize);
1930: }
1931: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
1932: frmFrame.setMinimumSize (frmMinimumSize);
1933: frmFrame.setMaximumSize (frmMinimumSize);
1934: frmFrame.setPreferredSize (frmMinimumSize);
1935: frmFrame.setResizable (false);
1936: frmFrame.pack ();
1937: } else {
1938:
1939: if (PNL_ROUNDED_CORNER_ON) {
1940:
1941: int screenWidth = pnlRotatedWidth * pnlStereoscopicFactor;
1942:
1943: int screenHeight = pnlRotatedHeight;
1944:
1945: int maximumWidth = pnlWidth;
1946:
1947: int maximumHeight = pnlHeight - Keyboard.kbdHeight;
1948:
1949:
1950:
1951: double cornerRadius = (!(PNL_ROUNDED_CORNER_TEST || pnlMode == PNL_FULLSCREEN) ||
1952: (pnlStereoscopicOn &&
1953: (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE ||
1954: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM)) ? 0 :
1955: Math.min (pnlWidth, pnlHeight) * (double) pnlRoundedCornerRatio / 100.0);
1956:
1957: double cornerWidth = cornerRadius * 2.0;
1958:
1959: double cornerHeight = cornerRadius * (Keyboard.kbdHeight != 0 ? 1.0 : 2.0);
1960:
1961: double straightWidth = maximumWidth - cornerWidth;
1962:
1963: double straightHeight = maximumHeight - cornerHeight;
1964: if (maximumHeight * screenWidth <= straightWidth * screenHeight) {
1965:
1966:
1967:
1968: pnlZoomHeight = maximumHeight;
1969:
1970: pnlZoomWidth = (pnlZoomHeight * screenWidth + (screenHeight >> 1)) / screenHeight;
1971:
1972: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
1973:
1974: pnlScreenX1 = ((maximumWidth >> 1) - (pnlZoomWidth >> 1)) >> 1;
1975: } else {
1976: pnlScreenX1 = (maximumWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
1977: }
1978: pnlScreenY1 = 0;
1979: } else if (maximumWidth * screenHeight <= straightHeight * screenWidth) {
1980:
1981:
1982:
1983: pnlZoomWidth = maximumWidth;
1984:
1985: pnlZoomHeight = (pnlZoomWidth * screenHeight + (screenWidth >> 1)) / screenWidth;
1986:
1987: pnlScreenX1 = 0;
1988: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM) {
1989:
1990: pnlScreenY1 = ((maximumHeight >> 1) - (pnlZoomHeight >> 1)) >> 1;
1991: } else {
1992: pnlScreenY1 = (maximumHeight - pnlZoomHeight) >> 1;
1993: }
1994: } else {
1995:
1996:
1997:
1998:
1999:
2000:
2001:
2002:
2003:
2004:
2005:
2006:
2007:
2008:
2009:
2010:
2011:
2012:
2013:
2014:
2015:
2016:
2017:
2018: double ax = 1.0;
2019: double ay = 0.0;
2020: double bx = 0.0;
2021: double by = 1.0;
2022: for (int i = 0; i < 4; i++) {
2023: double mx;
2024: double my;
2025: if (false) {
2026: double t = (ax * bx - ay * by) * 0.5;
2027: mx = Math.sqrt (0.5 + t);
2028: my = Math.sqrt (0.5 - t);
2029: } else {
2030: double sx = ax + bx;
2031: double sy = ay + by;
2032: double t = Math.cbrt (2.0 + 3.0 * (ax * bx * sx + ay * by * sy));
2033: mx = sx / t;
2034: my = sy / t;
2035: }
2036:
2037: double temporaryWidth = straightWidth + mx * cornerWidth;
2038:
2039: double temporaryHeight = straightHeight + my * cornerHeight;
2040: if (temporaryHeight * screenWidth <= temporaryWidth * screenHeight) {
2041:
2042:
2043: ax = mx;
2044: ay = my;
2045: } else {
2046:
2047: bx = mx;
2048: by = my;
2049: }
2050: }
2051:
2052:
2053:
2054:
2055:
2056:
2057:
2058:
2059:
2060:
2061:
2062:
2063: double t = (((straightHeight + ay * cornerHeight) * screenWidth
2064: - (straightWidth + ax * cornerWidth) * screenHeight)
2065: / ((bx - ax) * cornerWidth * screenHeight
2066: - (by - ay) * cornerHeight * screenWidth));
2067:
2068: pnlZoomWidth = (int) Math.round (straightWidth + (ax + (bx - ax) * t) * cornerWidth);
2069: if (false) {
2070:
2071: pnlZoomHeight = (int) Math.round (straightHeight + (ay + (by - ay) * t) * cornerHeight);
2072: } else {
2073:
2074: pnlZoomHeight = (pnlZoomWidth * screenHeight + (screenWidth >> 1)) / screenWidth;
2075: }
2076:
2077: pnlScreenX1 = (maximumWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
2078: pnlScreenY1 = (maximumHeight - pnlZoomHeight) >> 1;
2079: }
2080: } else {
2081: if (pnlWidth * pnlRotatedHeight >= (pnlHeight - Keyboard.kbdHeight) * (pnlRotatedWidth * pnlStereoscopicFactor)) {
2082:
2083:
2084:
2085:
2086:
2087:
2088:
2089:
2090:
2091:
2092:
2093:
2094: pnlZoomHeight = pnlHeight - Keyboard.kbdHeight;
2095: pnlZoomWidth = (pnlZoomHeight * pnlRotatedWidth + (pnlRotatedHeight >> 1)) / pnlRotatedHeight;
2096: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
2097: pnlScreenX1 = ((pnlWidth >> 1) - (pnlZoomWidth >> 1)) >> 1;
2098: } else {
2099: pnlScreenX1 = (pnlWidth - pnlZoomWidth * pnlStereoscopicFactor) >> 1;
2100: }
2101: pnlScreenY1 = 0;
2102: } else {
2103:
2104:
2105:
2106:
2107:
2108:
2109:
2110:
2111:
2112:
2113:
2114:
2115:
2116:
2117:
2118:
2119: pnlZoomWidth = pnlWidth / pnlStereoscopicFactor;
2120: pnlZoomHeight = (pnlZoomWidth * pnlStereoscopicFactor * pnlRotatedHeight + (pnlRotatedWidth * pnlStereoscopicFactor >> 1)) / (pnlRotatedWidth * pnlStereoscopicFactor);
2121: pnlScreenX1 = 0;
2122: if (pnlStereoscopicOn && pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM) {
2123: pnlScreenY1 = (((pnlHeight - Keyboard.kbdHeight) >> 1) - (pnlZoomHeight >> 1)) >> 1;
2124: } else {
2125: pnlScreenY1 = (pnlHeight - (pnlZoomHeight + Keyboard.kbdHeight)) >> 1;
2126: }
2127: }
2128: }
2129:
2130: int minimumWidth = Math.max (PNL_MIN_WIDTH, Keyboard.kbdWidth);
2131: int minimumHeight = PNL_MIN_HEIGHT + Keyboard.kbdHeight;
2132: if (pnlMinimumWidth != minimumWidth || pnlMinimumHeight != minimumHeight) {
2133: pnlMinimumWidth = minimumWidth;
2134: pnlMinimumHeight = minimumHeight;
2135: }
2136: frmMinimumSize.setSize (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
2137: frmFrame.setMinimumSize (frmMinimumSize);
2138: frmFrame.setMaximumSize (null);
2139: frmFrame.setResizable (true);
2140: }
2141:
2142: pnlArrangementCommon ();
2143: Mouse.musUpdateSpeedRatio ();
2144: if (!PNL_FILL_BACKGROUND) {
2145: pnlFillBackgroundRequest = true;
2146: }
2147: if (FlashingLights.FLR_ON &&
2148: FlashingLights.flrEnabled) {
2149: FlashingLights.flrMakeIndex ();
2150: }
2151: }
2152:
2153: public static void pnlArrangementCommon () {
2154: if (PNL_STEREOSCOPIC_ON && pnlStereoscopicOn) {
2155: if (pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING ||
2156: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL) {
2157: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
2158: pnlScreenX3 = pnlScreenX2;
2159: pnlScreenX4 = pnlScreenX3 + pnlZoomWidth;
2160: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
2161: pnlScreenY3 = pnlScreenY1;
2162: pnlScreenY4 = pnlScreenY2;
2163: } else if (pnlStereoscopicMethod == PNL_SIDE_BY_SIDE) {
2164: pnlScreenX2 = pnlScreenX1 + (pnlZoomWidth >> 1);
2165: pnlScreenX3 = pnlScreenX2;
2166: pnlScreenX4 = pnlScreenX3 + (pnlZoomWidth >> 1);
2167: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
2168: pnlScreenY3 = pnlScreenY1;
2169: pnlScreenY4 = pnlScreenY2;
2170: } else {
2171: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
2172: pnlScreenX3 = pnlScreenX1;
2173: pnlScreenX4 = pnlScreenX2;
2174: pnlScreenY2 = pnlScreenY1 + (pnlZoomHeight >> 1);
2175: pnlScreenY3 = pnlScreenY2;
2176: pnlScreenY4 = pnlScreenY3 + (pnlZoomHeight >> 1);
2177: }
2178: } else {
2179: pnlScreenX2 = pnlScreenX1 + pnlZoomWidth;
2180: pnlScreenX3 = pnlScreenX1;
2181: pnlScreenX4 = pnlScreenX2;
2182: pnlScreenY2 = pnlScreenY1 + pnlZoomHeight;
2183: pnlScreenY3 = pnlScreenY1;
2184: pnlScreenY4 = pnlScreenY2;
2185: }
2186: pnlKeyboardX = (pnlWidth - Keyboard.kbdWidth) >> 1;
2187: pnlKeyboardY = pnlScreenY4;
2188: pnlZoomRatioOutX = ((pnlZoomWidth * pnlStereoscopicFactor) << 16) / pnlScreenWidth;
2189: pnlZoomRatioOutY = (pnlZoomHeight << 16) / pnlScreenHeight;
2190: pnlZoomRatioInX = (pnlScreenWidth << 16) / (pnlZoomWidth * pnlStereoscopicFactor);
2191: pnlZoomRatioInY = (pnlScreenHeight << 16) / pnlZoomHeight;
2192: if (PNL_ROTATION_ON) {
2193:
2194: if (PNL_USE_THREAD) {
2195: for (int n = 0; n < 4; n++) {
2196: pnlScreenSubImageLeftArray[n] = pnlScreenImageLeftArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
2197: pnlScreenSubImageRightArray[n] = pnlScreenImageRightArray[n].getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
2198: }
2199: } else {
2200: pnlScreenSubImageLeft = pnlScreenImageLeft.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
2201: pnlScreenSubImageRight = pnlScreenImageRight.getSubimage (0, 0, pnlScreenWidth, pnlScreenHeight);
2202: }
2203:
2204:
2205:
2206:
2207: double ax = 0.0;
2208: double ay = 0.0;
2209: double bx = (double) pnlScreenWidth;
2210: double by = (double) pnlScreenHeight;
2211: double l00, l10, l01, l11, l02, l12;
2212: double r00, r10, r01, r11, r02, r12;
2213: if (pnlRotationMode == 0) {
2214: double cx = (double) pnlScreenX1;
2215: double cy = (double) pnlScreenY1;
2216: double dx = (double) pnlScreenX2;
2217: double dy = (double) pnlScreenY2;
2218: l00 = (cx - dx) / (ax - bx);
2219: l10 = 0.0;
2220: l01 = 0.0;
2221: l11 = (cy - dy) / (ay - by);
2222: l02 = (ax * dx - bx * cx) / (ax - bx);
2223: l12 = (ay * dy - by * cy) / (ay - by);
2224: cx = (double) pnlScreenX3;
2225: cy = (double) pnlScreenY3;
2226: dx = (double) pnlScreenX4;
2227: dy = (double) pnlScreenY4;
2228: r00 = (cx - dx) / (ax - bx);
2229: r10 = 0.0;
2230: r01 = 0.0;
2231: r11 = (cy - dy) / (ay - by);
2232: r02 = (ax * dx - bx * cx) / (ax - bx);
2233: r12 = (ay * dy - by * cy) / (ay - by);
2234: } else if (pnlRotationMode == 1) {
2235: double cx = (double) pnlScreenX1;
2236: double cy = (double) pnlScreenY1;
2237: double dx = (double) pnlScreenX2;
2238: double dy = (double) pnlScreenY2;
2239: l00 = 0.0;
2240: l10 = (dy - cy) / (ax - bx);
2241: l01 = (cx - dx) / (ay - by);
2242: l11 = 0.0;
2243: l02 = (ay * dx - by * cx) / (ay - by);
2244: l12 = (ax * cy - bx * dy) / (ax - bx);
2245: cx = (double) pnlScreenX3;
2246: cy = (double) pnlScreenY3;
2247: dx = (double) pnlScreenX4;
2248: dy = (double) pnlScreenY4;
2249: r00 = 0.0;
2250: r10 = (dy - cy) / (ax - bx);
2251: r01 = (cx - dx) / (ay - by);
2252: r11 = 0.0;
2253: r02 = (ay * dx - by * cx) / (ay - by);
2254: r12 = (ax * cy - bx * dy) / (ax - bx);
2255: } else if (pnlRotationMode == 2) {
2256: double cx = (double) pnlScreenX1;
2257: double cy = (double) pnlScreenY1;
2258: double dx = (double) pnlScreenX2;
2259: double dy = (double) pnlScreenY2;
2260: l00 = (dx - cx) / (ax - bx);
2261: l10 = 0.0;
2262: l01 = 0.0;
2263: l11 = (dy - cy) / (ay - by);
2264: l02 = (ax * cx - bx * dx) / (ax - bx);
2265: l12 = (ay * cy - by * dy) / (ay - by);
2266: cx = (double) pnlScreenX3;
2267: cy = (double) pnlScreenY3;
2268: dx = (double) pnlScreenX4;
2269: dy = (double) pnlScreenY4;
2270: r00 = (dx - cx) / (ax - bx);
2271: r10 = 0.0;
2272: r01 = 0.0;
2273: r11 = (dy - cy) / (ay - by);
2274: r02 = (ax * cx - bx * dx) / (ax - bx);
2275: r12 = (ay * cy - by * dy) / (ay - by);
2276: } else {
2277: double cx = (double) pnlScreenX1;
2278: double cy = (double) pnlScreenY1;
2279: double dx = (double) pnlScreenX2;
2280: double dy = (double) pnlScreenY2;
2281: l00 = 0.0;
2282: l10 = (cy - dy) / (ax - bx);
2283: l01 = (dx - cx) / (ay - by);
2284: l11 = 0.0;
2285: l02 = (ay * cx - by * dx) / (ay - by);
2286: l12 = (ax * dy - bx * cy) / (ax - bx);
2287: cx = (double) pnlScreenX3;
2288: cy = (double) pnlScreenY3;
2289: dx = (double) pnlScreenX4;
2290: dy = (double) pnlScreenY4;
2291: r00 = 0.0;
2292: r10 = (cy - dy) / (ax - bx);
2293: r01 = (dx - cx) / (ay - by);
2294: r11 = 0.0;
2295: r02 = (ay * cx - by * dx) / (ay - by);
2296: r12 = (ax * dy - bx * cy) / (ax - bx);
2297: }
2298: pnlRotationTransformLeft.setTransform (l00, l10, l01, l11, l02, l12);
2299: pnlRotationTransformRight.setTransform (r00, r10, r01, r11, r02, r12);
2300: pnlMatrixL00 = l00;
2301: pnlMatrixL10 = l10;
2302: pnlMatrixL01 = l01;
2303: pnlMatrixL11 = l11;
2304: pnlMatrixL02 = l02;
2305: pnlMatrixL12 = l12;
2306: pnlMatrixR00 = r00;
2307: pnlMatrixR10 = r10;
2308: pnlMatrixR01 = r01;
2309: pnlMatrixR11 = r11;
2310: pnlMatrixR02 = r02;
2311: pnlMatrixR12 = r12;
2312:
2313:
2314:
2315:
2316:
2317:
2318: double d = l00 * l11 - l01 * l10;
2319: pnlInverseL00 = l11 / d;
2320: pnlInverseL10 = -l10 / d;
2321: pnlInverseL01 = -l01 / d;
2322: pnlInverseL11 = l00 / d;
2323: pnlInverseL02 = (l01 * l12 - l02 * l11) / d;
2324: pnlInverseL12 = (l02 * l10 - l00 * l12) / d;
2325: d = r00 * r11 - r01 * r10;
2326: pnlInverseR00 = r11 / d;
2327: pnlInverseR10 = -r10 / d;
2328: pnlInverseR01 = -r01 / d;
2329: pnlInverseR11 = r00 / d;
2330: pnlInverseR02 = (r01 * r12 - r02 * r11) / d;
2331: pnlInverseR12 = (r02 * r10 - r00 * r12) / d;
2332: }
2333: }
2334:
2335:
2336:
2337:
2338: public static final int PNL_UNDEFINED = 0;
2339: public static final int PNL_FIXEDSCALE = 1;
2340: public static final int PNL_FITINWINDOW = 2;
2341: public static final int PNL_FULLSCREEN = 3;
2342: public static final int PNL_MAXIMIZED = 4;
2343: public static int pnlModeRequest;
2344: public static int pnlMode;
2345: public static int pnlPrevMode;
2346:
2347:
2348: public static JRadioButtonMenuItem mnbFullScreenMenuItem;
2349: public static JRadioButtonMenuItem mnbMaximizedMenuItem;
2350: public static JRadioButtonMenuItem mnbFitInWindowMenuItem;
2351: public static JRadioButtonMenuItem mnbFixedScaleMenuItem;
2352:
2353:
2354:
2355:
2356:
2357: public static boolean PNL_ROUNDED_CORNER_ON = true;
2358: public static boolean PNL_ROUNDED_CORNER_TEST = false;
2359: public static int pnlRoundedCornerRatio;
2360: public static SpinnerNumberModel pnlRoundedCornerModel;
2361: public static JSpinner pnlRoundedCornerSpinner;
2362:
2363:
2364: public static int PNL_BOOT_DELAY = 500;
2365: public static javax.swing.Timer pnlBootTimer;
2366:
2367:
2368:
2369: public static void pnlInit2 () {
2370: pnlModeRequest = PNL_UNDEFINED;
2371: pnlMode = PNL_FITINWINDOW;
2372: pnlPrevMode = PNL_FITINWINDOW;
2373: switch (Settings.sgsGetString ("scaling").toLowerCase ()) {
2374: case "fullscreen":
2375: pnlModeRequest = PNL_FULLSCREEN;
2376: break;
2377: case "maximized":
2378: pnlModeRequest = PNL_MAXIMIZED;
2379: break;
2380: case "fitinwindow":
2381: break;
2382: case "fixedscale":
2383: pnlMode = PNL_FIXEDSCALE;
2384: break;
2385: }
2386: if (PNL_ROUNDED_CORNER_ON) {
2387: pnlRoundedCornerRatio = Settings.sgsGetInt ("roundedcornerratio", 0, 0, 50);
2388: }
2389: }
2390:
2391:
2392:
2393: public static void pnlTini2 () {
2394: Settings.sgsPutString ("scaling",
2395: pnlMode == PNL_FULLSCREEN ? "fullscreen" :
2396: pnlMode == PNL_MAXIMIZED ? "maximized" :
2397: pnlMode == PNL_FITINWINDOW ? "fitinwindow" :
2398: "fixedscale");
2399: if (PNL_ROUNDED_CORNER_ON) {
2400: Settings.sgsPutInt ("roundedcornerratio", pnlRoundedCornerRatio);
2401: }
2402: }
2403:
2404:
2405:
2406: public static void pnlMake2 () {
2407:
2408: ActionListener listener = new ActionListener () {
2409: @Override public void actionPerformed (ActionEvent ae) {
2410: String command = ae.getActionCommand ();
2411: switch (command) {
2412: case "Full screen":
2413: pnlSetMode (PNL_FULLSCREEN);
2414: break;
2415: case "Maximized":
2416: pnlSetMode (PNL_MAXIMIZED);
2417: break;
2418: case "Resize the X68000 screen to fit the window":
2419: pnlSetMode (PNL_FITINWINDOW);
2420: break;
2421: case "Resize the window to fit the X68000 screen":
2422: pnlSetMode (PNL_FIXEDSCALE);
2423: break;
2424: }
2425: }
2426: };
2427: ButtonGroup group = new ButtonGroup ();
2428: mnbFullScreenMenuItem = ComponentFactory.setEnabled (
2429: Multilingual.mlnText (
2430: ComponentFactory.createRadioButtonMenuItem (
2431: group,
2432: pnlMode == PNL_FULLSCREEN,
2433: "Full screen",
2434: listener),
2435: "ja", "全画面表示"),
2436: pnlIsFullScreenSupported);
2437: mnbMaximizedMenuItem = Multilingual.mlnText (
2438: ComponentFactory.createRadioButtonMenuItem (
2439: group,
2440: pnlMode == PNL_MAXIMIZED,
2441: "Maximized",
2442: listener),
2443: "ja", "最大化");
2444: mnbFitInWindowMenuItem = Multilingual.mlnText (
2445: ComponentFactory.createRadioButtonMenuItem (
2446: group,
2447: pnlMode == PNL_FITINWINDOW,
2448: "Resize the X68000 screen to fit the window",
2449: 'W',
2450: MNB_MODIFIERS,
2451: listener),
2452: "ja", "X68000の画面をリサイズしてウインドウに合わせる");
2453: mnbFixedScaleMenuItem = Multilingual.mlnText (
2454: ComponentFactory.createRadioButtonMenuItem (
2455: group,
2456: pnlMode == PNL_FIXEDSCALE,
2457: "Resize the window to fit the X68000 screen",
2458: 'X',
2459: MNB_MODIFIERS,
2460: listener),
2461: "ja", "ウインドウをリサイズしてX68000の画面に合わせる");
2462: }
2463:
2464:
2465:
2466: public static void pnlStart2 () {
2467:
2468: frmFrame.addWindowStateListener (new WindowStateListener () {
2469: @Override public void windowStateChanged (WindowEvent we) {
2470: int state = frmFrame.getExtendedState ();
2471: if (pnlMode != PNL_MAXIMIZED &&
2472: (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
2473: pnlSetMode (PNL_MAXIMIZED);
2474: } else if (pnlMode == PNL_MAXIMIZED &&
2475: (state & Frame.MAXIMIZED_BOTH) != Frame.MAXIMIZED_BOTH) {
2476: pnlSetMode (pnlPrevMode);
2477: }
2478: }
2479: });
2480: }
2481:
2482:
2483:
2484: public static void pnlBoot2 () {
2485: if (pnlModeRequest != PNL_UNDEFINED) {
2486: pnlBootTimer = new javax.swing.Timer (PNL_BOOT_DELAY, new ActionListener () {
2487: public void actionPerformed (ActionEvent ae) {
2488: if (pnlModeRequest == PNL_FULLSCREEN) {
2489: mnbFullScreenMenuItem.doClick ();
2490: } else if (pnlModeRequest == PNL_MAXIMIZED) {
2491: mnbMaximizedMenuItem.doClick ();
2492: }
2493: pnlBootTimer.stop ();
2494: pnlBootTimer = null;
2495: }
2496: });
2497: pnlBootTimer.start ();
2498: }
2499: }
2500:
2501:
2502:
2503: public static void pnlSetMode (int mode) {
2504: do {
2505:
2506: if (pnlMode == mode) {
2507: break;
2508: }
2509:
2510: String text = null;
2511: if (mode == PNL_FULLSCREEN) {
2512: if (!pnlIsFullScreenSupported) {
2513: JOptionPane.showMessageDialog (
2514: frmFrame,
2515: Multilingual.mlnJapanese ?
2516: "全画面表示に対応していません" :
2517: "Full screen is not supported");
2518: break;
2519: }
2520: if (Bubble.BBL_ON) {
2521: text = ButtonFunction.bfnFullScreenText ();
2522: if (text == null) {
2523: JOptionPane.showMessageDialog (
2524: frmFrame,
2525: Multilingual.mlnJapanese ?
2526: "全画面表示を終了するキーまたはボタンがありません" :
2527: "No key or button to exit full screen");
2528: break;
2529: }
2530: }
2531: }
2532:
2533: if (pnlMode == PNL_FULLSCREEN) {
2534: pnlMode = pnlPrevMode;
2535: if (Bubble.BBL_ON) {
2536: Bubble.bblEnd ();
2537: }
2538: if (frmScreenDevice.getFullScreenWindow () == frmFrame) {
2539: frmScreenDevice.setFullScreenWindow (null);
2540: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.FRAME);
2541: }
2542: frmFrame.setJMenuBar (mnbMenuBar);
2543: if (pnlHideKeyboard) {
2544: if (pnlPrevKeyboardOn) {
2545: Keyboard.kbdSetOn (true);
2546: }
2547: }
2548: } else if (pnlMode == PNL_MAXIMIZED) {
2549: pnlMode = pnlPrevMode;
2550: if ((frmFrame.getExtendedState () & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
2551: frmFrame.setExtendedState (Frame.NORMAL);
2552: }
2553: }
2554:
2555: if (mode == PNL_FULLSCREEN) {
2556: pnlPrevMode = pnlMode;
2557: if (pnlHideKeyboard) {
2558: pnlPrevKeyboardOn = Keyboard.kbdImage != null;
2559: if (pnlPrevKeyboardOn) {
2560: Keyboard.kbdSetOn (false);
2561: }
2562: }
2563: frmFrame.setJMenuBar (null);
2564: if (frmScreenDevice.getFullScreenWindow () != frmFrame) {
2565: frmFrame.getRootPane().setWindowDecorationStyle (JRootPane.NONE);
2566: frmScreenDevice.setFullScreenWindow (frmFrame);
2567: }
2568: if (Bubble.BBL_ON) {
2569: if (text != null) {
2570: Bubble.bblStart (text + (Multilingual.mlnJapanese ? "で全画面表示を終了" : " to exit full screen"), 5000L);
2571: }
2572: }
2573: } else if (mode == PNL_MAXIMIZED) {
2574: pnlPrevMode = pnlMode;
2575: frmFrame.setExtendedState (Frame.MAXIMIZED_BOTH);
2576: }
2577: pnlMode = mode;
2578:
2579:
2580: pnlUpdateArrangement ();
2581: } while (false);
2582:
2583: if (pnlMode == PNL_FIXEDSCALE) {
2584: if (!mnbFixedScaleMenuItem.isSelected ()) {
2585: mnbFixedScaleMenuItem.setSelected (true);
2586: }
2587: } else if (pnlMode == PNL_FITINWINDOW) {
2588: if (!mnbFitInWindowMenuItem.isSelected ()) {
2589: mnbFitInWindowMenuItem.setSelected (true);
2590: }
2591: } else if (pnlMode == PNL_FULLSCREEN) {
2592: if (!mnbFullScreenMenuItem.isSelected ()) {
2593: mnbFullScreenMenuItem.setSelected (true);
2594: }
2595: } else if (pnlMode == PNL_MAXIMIZED) {
2596: if (!mnbMaximizedMenuItem.isSelected ()) {
2597: mnbMaximizedMenuItem.setSelected (true);
2598: }
2599: }
2600: }
2601:
2602:
2603:
2604:
2605:
2606:
2607: public static Robot rbtRobot;
2608:
2609:
2610: public static void rbtInit () {
2611:
2612:
2613: rbtRobot = null;
2614: try {
2615: rbtRobot = new Robot ();
2616: } catch (Exception e) {
2617: }
2618:
2619: }
2620:
2621:
2622:
2623:
2624:
2625:
2626:
2627: public static final int MNB_MODIFIERS = InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK;
2628:
2629:
2630: public static JMenuBar mnbMenuBar;
2631:
2632:
2633: public static JMenu mnbFileMenu;
2634: public static JMenu mnbDisplayMenu;
2635: public static JMenu mnbSoundMenu;
2636: public static JMenu mnbInputMenu;
2637: public static JMenu mnbConfigMenu;
2638: public static JMenu mnbLanguageMenu;
2639:
2640:
2641:
2642:
2643:
2644: public static JMenuItem mnbQuitMenuItem;
2645: public static JCheckBoxMenuItem mnbStereoscopicMenuItem;
2646: public static JCheckBoxMenuItem mnbPlayMenuItem;
2647: public static JMenuItem mnbPasteMenuItem;
2648: public static JRadioButtonMenuItem mnbStandardKeyboardMenuItem;
2649: public static JRadioButtonMenuItem mnbCompactKeyboardMenuItem;
2650: public static JRadioButtonMenuItem mnbNoKeyboardMenuItem;
2651: public static JLabel mnbVolumeLabel;
2652:
2653:
2654:
2655:
2656:
2657:
2658: public static JMenu mnbMakeFontSizeMenu () {
2659:
2660: ActionListener actionListener = new ActionListener () {
2661: @Override public void actionPerformed (ActionEvent ae) {
2662: String command = ae.getActionCommand ();
2663: switch (command) {
2664: case "Very small":
2665: LnF.lnfFontSizeRequest = 10;
2666: break;
2667: case "Small":
2668: LnF.lnfFontSizeRequest = 12;
2669: break;
2670: case "Medium":
2671: LnF.lnfFontSizeRequest = 14;
2672: break;
2673: case "Large":
2674: LnF.lnfFontSizeRequest = 16;
2675: break;
2676: case "Very large":
2677: LnF.lnfFontSizeRequest = 18;
2678: break;
2679: default:
2680: System.out.println ("unknown action command " + command);
2681: }
2682: }
2683: };
2684:
2685: ButtonGroup fontSizeGroup = new ButtonGroup ();
2686:
2687: return Multilingual.mlnText (
2688: ComponentFactory.createMenu (
2689: "Font size",
2690: Multilingual.mlnText (
2691: ComponentFactory.pointSize (
2692: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 10, "Very small", actionListener),
2693: 10),
2694: "ja", "極小"),
2695: Multilingual.mlnText (
2696: ComponentFactory.pointSize (
2697: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 12, "Small", actionListener),
2698: 12),
2699: "ja", "小"),
2700: Multilingual.mlnText (
2701: ComponentFactory.pointSize (
2702: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 14, "Medium", actionListener),
2703: 14),
2704: "ja", "中"),
2705: Multilingual.mlnText (
2706: ComponentFactory.pointSize (
2707: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 16, "Large", actionListener),
2708: 16),
2709: "ja", "大"),
2710: Multilingual.mlnText (
2711: ComponentFactory.pointSize (
2712: ComponentFactory.createRadioButtonMenuItem (fontSizeGroup, LnF.lnfFontSizeRequest == 18, "Very large", actionListener),
2713: 18),
2714: "ja", "極大")),
2715: "ja", "フォントサイズ");
2716: }
2717:
2718:
2719:
2720: public static final DecimalSpinner[] mnbColorSpinners = new DecimalSpinner[9];
2721: public static final int[] mnbColorRGB = new int[15];
2722: public static JPanel mnbColorPanel;
2723:
2724:
2725:
2726: public static void mnbColorHSBToRGB () {
2727: for (int i = 0; i <= 14; i++) {
2728: int[] t = LnF.LNF_HSB_INTERPOLATION_TABLE[i];
2729: float h = (float) (t[0] * LnF.lnfHSB[0] + t[1] * LnF.lnfHSB[1] + t[2] * LnF.lnfHSB[2]) / (49.0F * 360.0F);
2730: float s = (float) (t[0] * LnF.lnfHSB[3] + t[1] * LnF.lnfHSB[4] + t[2] * LnF.lnfHSB[5]) / (49.0F * 100.0F);
2731: float b = (float) (t[0] * LnF.lnfHSB[6] + t[1] * LnF.lnfHSB[7] + t[2] * LnF.lnfHSB[8]) / (49.0F * 100.0F);
2732: mnbColorRGB[i] = Color.HSBtoRGB (h,
2733: Math.max (0.0F, Math.min (1.0F, s)),
2734: Math.max (0.0F, Math.min (1.0F, b)));
2735: }
2736: }
2737:
2738:
2739:
2740: public static JMenu mnbMakeColorMenu () {
2741: mnbColorHSBToRGB ();
2742:
2743: mnbColorPanel = ComponentFactory.setColor (
2744: ComponentFactory.setFixedSize (
2745: new JPanel () {
2746: @Override protected void paintComponent (Graphics g) {
2747: super.paintComponent (g);
2748: for (int i = 0; i <= 14; i++) {
2749: g.setColor (new Color (mnbColorRGB[i]));
2750: g.fillRect (LnF.lnfFontSize * i, 0, LnF.lnfFontSize, LnF.lnfFontSize * 5);
2751: }
2752: }
2753: },
2754: LnF.lnfFontSize * 15, LnF.lnfFontSize * 5),
2755: Color.white, Color.black);
2756:
2757: ChangeListener changeListener = new ChangeListener () {
2758: @Override public void stateChanged (ChangeEvent ce) {
2759: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
2760: LnF.lnfHSB[spinner.getOption ()] = spinner.getIntValue ();
2761: mnbColorHSBToRGB ();
2762: mnbColorPanel.repaint ();
2763: }
2764: };
2765:
2766: ActionListener actionListener = new ActionListener () {
2767: @Override public void actionPerformed (ActionEvent ae) {
2768: String command = ae.getActionCommand ();
2769: switch (command) {
2770: case "Reset to default values":
2771: for (int i = 0; i < 9; i++) {
2772: LnF.lnfHSB[i] = LnF.LNF_DEFAULT_HSB[i];
2773: mnbColorSpinners[i].setIntValue (LnF.lnfHSB[i]);
2774: }
2775: mnbColorHSBToRGB ();
2776: mnbColorPanel.repaint ();
2777: break;
2778: default:
2779: System.out.println ("unknown action command " + command);
2780: }
2781: }
2782: };
2783:
2784: for (int i = 0; i < 9; i++) {
2785: mnbColorSpinners[i] = ComponentFactory.createDecimalSpinner (
2786: LnF.lnfHSB[i], 0, i < 3 ? 720 : 100, 1, i, changeListener);
2787: }
2788:
2789: return Multilingual.mlnText (
2790: ComponentFactory.createMenu (
2791: "Color",
2792: ComponentFactory.createHorizontalBox (
2793: mnbColorSpinners[0],
2794: mnbColorSpinners[1],
2795: mnbColorSpinners[2],
2796: ComponentFactory.createLabel ("H °"),
2797: Box.createHorizontalGlue ()
2798: ),
2799: ComponentFactory.createHorizontalBox (
2800: mnbColorSpinners[3],
2801: mnbColorSpinners[4],
2802: mnbColorSpinners[5],
2803: ComponentFactory.createLabel ("S%"),
2804: Box.createHorizontalGlue ()
2805: ),
2806: ComponentFactory.createHorizontalBox (
2807: mnbColorSpinners[6],
2808: mnbColorSpinners[7],
2809: mnbColorSpinners[8],
2810: ComponentFactory.createLabel ("B%"),
2811: Box.createHorizontalGlue ()
2812: ),
2813: ComponentFactory.createHorizontalBox (
2814: ComponentFactory.setLineBorder (mnbColorPanel),
2815: Box.createHorizontalGlue ()
2816: ),
2817: Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset to default values", actionListener), "ja", "初期値に戻す")
2818: ),
2819: "ja", "色");
2820: }
2821:
2822:
2823:
2824:
2825:
2826: public static JMenu mnbMakeLanguageMenu () {
2827:
2828: ActionListener actionListener = new ActionListener () {
2829: @Override public void actionPerformed (ActionEvent ae) {
2830: String command = ae.getActionCommand ();
2831: switch (command) {
2832: case "English":
2833: Multilingual.mlnChange ("en");
2834: break;
2835: case "日本語":
2836: Multilingual.mlnChange ("ja");
2837: break;
2838: default:
2839: System.out.println ("unknown action command " + command);
2840: }
2841: }
2842: };
2843:
2844: ButtonGroup languageGroup = new ButtonGroup ();
2845:
2846: return mnbLanguageMenu = Multilingual.mlnText (
2847: ComponentFactory.createMenu (
2848: "Language", 'L',
2849: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnEnglish, "English", actionListener),
2850: ComponentFactory.createRadioButtonMenuItem (languageGroup, Multilingual.mlnJapanese, "日本語", actionListener)
2851: ),
2852: "ja", "言語");
2853: }
2854:
2855:
2856:
2857:
2858:
2859: public static void mnbMakeMenu () {
2860:
2861:
2862: ActionListener listener = new ActionListener () {
2863: @Override public void actionPerformed (ActionEvent ae) {
2864: Object source = ae.getSource ();
2865: String command = ae.getActionCommand ();
2866: switch (command) {
2867:
2868:
2869: case "Quit":
2870: prgTini ();
2871: break;
2872:
2873:
2874: case "50%":
2875: case "75%":
2876: case "100%":
2877: case "150%":
2878: case "200%":
2879: pnlFixedModel.setValue (Integer.valueOf (Integer.parseInt (command.substring (0, command.length () - 1))));
2880: break;
2881: case "Nearest neighbor":
2882: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
2883: break;
2884: case "Bilinear":
2885: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
2886: break;
2887: case "Bicubic":
2888: pnlInterpolation = RenderingHints.VALUE_INTERPOLATION_BICUBIC;
2889: break;
2890:
2891: case "Use canvas":
2892: pnlUseCanvasRequest = ((JCheckBoxMenuItem) source).isSelected ();
2893: break;
2894:
2895: case "Draw all changed pictures":
2896: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2897: CRTC.crtIntermittentInterval = 0;
2898: }
2899: break;
2900: case "Draw a changed picture once every two times":
2901: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2902: CRTC.crtIntermittentInterval = 1;
2903: }
2904: break;
2905: case "Draw a changed picture once every three times":
2906: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2907: CRTC.crtIntermittentInterval = 2;
2908: }
2909: break;
2910: case "Draw a changed picture once every four times":
2911: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2912: CRTC.crtIntermittentInterval = 3;
2913: }
2914: break;
2915: case "Draw a changed picture once every five times":
2916: if (CRTC.CRT_ENABLE_INTERMITTENT) {
2917: CRTC.crtIntermittentInterval = 4;
2918: }
2919: break;
2920:
2921: case "Stereoscopic viewing":
2922: pnlSetStereoscopic (((JCheckBoxMenuItem) source).isSelected (), pnlStereoscopicMethod);
2923: break;
2924: case "Naked-eye crossing":
2925: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_CROSSING);
2926: break;
2927: case "Naked-eye parallel":
2928: pnlSetStereoscopic (pnlStereoscopicOn, PNL_NAKED_EYE_PARALLEL);
2929: break;
2930: case "Side-by-side":
2931: pnlSetStereoscopic (pnlStereoscopicOn, PNL_SIDE_BY_SIDE);
2932: break;
2933: case "Top-and-bottom":
2934: pnlSetStereoscopic (pnlStereoscopicOn, PNL_TOP_AND_BOTTOM);
2935: break;
2936:
2937: case "Sprite pattern viewer":
2938: if (SpritePatternViewer.SPV_ON) {
2939: SpritePatternViewer.spvOpen ();
2940: }
2941: break;
2942: case "Palette viewer":
2943: if (PaletteViewer.PLV_ON) {
2944: PaletteViewer.plvOpen ();
2945: }
2946: break;
2947: case "Screen mode test":
2948: if (ScreenModeTest.SMT_ON) {
2949: ScreenModeTest.smtOpen ();
2950: }
2951: break;
2952:
2953:
2954: case "Play":
2955: SoundSource.sndSetPlayOn (((JCheckBoxMenuItem) source).isSelected ());
2956: break;
2957: case "OPM output":
2958: OPM.opmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2959: break;
2960: case "OPM log":
2961: OPMLog.olgOpen ();
2962: break;
2963:
2964: case "PCM output":
2965: ADPCM.pcmSetOutputOn (((JCheckBoxMenuItem) source).isSelected ());
2966: break;
2967: case "Sound thinning":
2968: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.THINNING_MONO : SoundSource.SNDRateConverter.THINNING_STEREO;
2969: break;
2970: case "Sound linear interpolation":
2971: SoundSource.sndRateConverter = SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.LINEAR_MONO : SoundSource.SNDRateConverter.LINEAR_STEREO;
2972: break;
2973: case "Sound piecewise-constant area interpolation":
2974: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000;
2975: break;
2976: case "Sound linear area interpolation":
2977: SoundSource.sndRateConverter = SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000;
2978: break;
2979: case "Sound monitor":
2980: SoundMonitor.smnOpen ();
2981: break;
2982: case "PCM piecewise-constant interpolation":
2983: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_CONSTANT);
2984: break;
2985: case "PCM linear interpolation":
2986: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_LINEAR);
2987: break;
2988: case "PCM hermite interpolation":
2989: ADPCM.pcmSetInterpolationAlgorithm (ADPCM.PCM_INTERPOLATION_HERMITE);
2990: break;
2991: case "PCM 8MHz/4MHz":
2992: ADPCM.pcmOSCFreqRequest = 0;
2993: break;
2994: case "PCM 8MHz/16MHz":
2995: ADPCM.pcmOSCFreqRequest = 1;
2996: break;
2997: case "Mercury-Unit V4 (MK-MU1)":
2998: MercuryUnit.mu4OnRequest = ((JCheckBoxMenuItem) source).isSelected ();
2999: break;
3000: case "MU4 output":
3001: MercuryUnit.mu4OutputEnable = ((JCheckBoxMenuItem) source).isSelected ();
3002: break;
3003:
3004:
3005: case "Paste":
3006: CONDevice.conDoPaste ();
3007: break;
3008: case "No keyboard":
3009: Keyboard.kbdSetOn (false);
3010: pnlUpdateArrangement ();
3011: break;
3012: case "Standard keyboard":
3013: Keyboard.kbdSetType (Keyboard.KBD_STANDARD_TYPE);
3014: Keyboard.kbdSetOn (true);
3015: pnlUpdateArrangement ();
3016: break;
3017: case "Compact keyboard":
3018: Keyboard.kbdSetType (Keyboard.KBD_COMPACT_TYPE);
3019: Keyboard.kbdSetOn (true);
3020: pnlUpdateArrangement ();
3021: break;
3022: case "Hide keyboard in full screen":
3023: pnlHideKeyboard = ((JCheckBoxMenuItem) source).isSelected ();
3024: if (pnlMode == PNL_FULLSCREEN) {
3025: pnlUpdateArrangement ();
3026: }
3027: break;
3028: case "Key assignments":
3029: Keyboard.kbdOpen ();
3030: break;
3031: case "Joystick port settings":
3032: PPI.ppiOpen ();
3033: break;
3034:
3035:
3036: case "RS-232C and terminal":
3037: RS232CTerminal.trmOpen ();
3038: break;
3039:
3040: case "Console":
3041: DebugConsole.dgtOpen ();
3042: break;
3043: case "Register list":
3044: RegisterList.drpOpen ();
3045: break;
3046: case "Disassemble list":
3047: DisassembleList.ddpOpen (-1, -1, true);
3048: break;
3049: case "Memory dump list":
3050: MemoryDumpList.dmpOpen (-1, -1, true);
3051: break;
3052: case "Logical space monitor":
3053: LogicalSpaceMonitor.atwOpen ();
3054: break;
3055: case "Physical space monitor":
3056: PhysicalSpaceMonitor.paaOpen ();
3057: break;
3058: case "Address translation caches monitor":
3059: if (ATCMonitor.ACM_ON) {
3060: ATCMonitor.acmOpen ();
3061: }
3062: break;
3063: case "Branch log":
3064: if (BranchLog.BLG_ON) {
3065: BranchLog.blgOpen (BranchLog.BLG_SELECT_NONE);
3066: }
3067: break;
3068: case "Program flow visualizer":
3069: if (ProgramFlowVisualizer.PFV_ON) {
3070: ProgramFlowVisualizer.pfvOpen ();
3071: }
3072: break;
3073: case "Raster break point":
3074: if (RasterBreakPoint.RBP_ON) {
3075: RasterBreakPoint.rbpOpen ();
3076: }
3077: break;
3078: case "Data break point":
3079: if (DataBreakPoint.DBP_ON) {
3080: DataBreakPoint.dbpOpen ();
3081: }
3082: break;
3083: case "Root pointer list":
3084: if (RootPointerList.RTL_ON) {
3085: RootPointerList.rtlOpen ();
3086: }
3087: break;
3088:
3089:
3090: case "Adjust clock to host":
3091: RP5C15.rtcSetByHost ();
3092: break;
3093:
3094:
3095:
3096: case "Printer":
3097: PrinterPort.prnOpen ();
3098: break;
3099:
3100: case "Print key and mouse button events":
3101: Mouse.musOutputButtonStatus = ((JCheckBoxMenuItem) source).isSelected ();
3102: break;
3103:
3104: case "Java runtime environment information":
3105: prgOpenJavaDialog ();
3106: break;
3107: case "Version information":
3108: prgOpenAboutDialog ();
3109: break;
3110: case "XEiJ License":
3111: prgOpenXEiJLicenseDialog ();
3112: break;
3113: case "FSHARP License":
3114: prgOpenSHARPLicenseDialog ();
3115: break;
3116: case "ymfm License":
3117: prgOpenYmfmLicenseDialog ();
3118: break;
3119: case "jSerialComm License":
3120: prgOpenJSerialCommLicenseDialog ();
3121: break;
3122:
3123: default:
3124: System.out.println ("unknown action command " + command);
3125:
3126: }
3127: }
3128: };
3129:
3130:
3131: ActionListener mainMemoryListener = new ActionListener () {
3132: @Override public void actionPerformed (ActionEvent ae) {
3133: Object source = ae.getSource ();
3134: String command = ae.getActionCommand ();
3135: switch (command) {
3136: case "1MB":
3137: MainMemory.mmrMemorySizeRequest = 0x00100000;
3138: break;
3139: case "2MB":
3140: MainMemory.mmrMemorySizeRequest = 0x00200000;
3141: break;
3142: case "4MB":
3143: MainMemory.mmrMemorySizeRequest = 0x00400000;
3144: break;
3145: case "6MB":
3146: MainMemory.mmrMemorySizeRequest = 0x00600000;
3147: break;
3148: case "8MB":
3149: MainMemory.mmrMemorySizeRequest = 0x00800000;
3150: break;
3151: case "10MB":
3152: MainMemory.mmrMemorySizeRequest = 0x00a00000;
3153: break;
3154: case "12MB":
3155: MainMemory.mmrMemorySizeRequest = 0x00c00000;
3156: break;
3157: case "Save contents on exit":
3158: MainMemory.mmrMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
3159: break;
3160: }
3161: }
3162: };
3163: ButtonGroup mainMemoryGroup = new ButtonGroup ();
3164: JMenu mainMemoryMenu = Multilingual.mlnText (
3165: ComponentFactory.createMenu (
3166: "Main memory",
3167: Multilingual.mlnText (
3168: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00100000, "1MB", mainMemoryListener),
3169: "ja", "1MB"),
3170: Multilingual.mlnText (
3171: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00200000, "2MB", mainMemoryListener),
3172: "ja", "2MB"),
3173: Multilingual.mlnText (
3174: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00400000, "4MB", mainMemoryListener),
3175: "ja", "4MB"),
3176: Multilingual.mlnText (
3177: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00600000, "6MB", mainMemoryListener),
3178: "ja", "6MB"),
3179: Multilingual.mlnText (
3180: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00800000, "8MB", mainMemoryListener),
3181: "ja", "8MB"),
3182: Multilingual.mlnText (
3183: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00a00000, "10MB", mainMemoryListener),
3184: "ja", "10MB"),
3185: Multilingual.mlnText (
3186: ComponentFactory.createRadioButtonMenuItem (mainMemoryGroup, MainMemory.mmrMemorySizeRequest == 0x00c00000, "12MB", mainMemoryListener),
3187: "ja", "12MB"),
3188: ComponentFactory.createHorizontalSeparator (),
3189: Multilingual.mlnText (
3190: ComponentFactory.createCheckBoxMenuItem (MainMemory.mmrMemorySaveOn, "Save contents on exit", mainMemoryListener),
3191: "ja", "終了時に内容を保存する"),
3192: SRAM.smrModifyMemorySizeMenuItem
3193: ),
3194: "ja", "メインメモリ");
3195:
3196:
3197: ActionListener highMemoryListener = new ActionListener () {
3198: @Override public void actionPerformed (ActionEvent ae) {
3199: Object source = ae.getSource ();
3200: String command = ae.getActionCommand ();
3201: switch (command) {
3202: case "None":
3203: busHighMemorySize = 0 << 20;
3204: break;
3205: case "16MB":
3206: busHighMemorySize = 16 << 20;
3207: break;
3208: case "Save contents on exit":
3209: busHighMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
3210: break;
3211: }
3212: }
3213: };
3214: ButtonGroup highMemoryGroup = new ButtonGroup ();
3215: JMenu highMemoryMenu = Multilingual.mlnText (
3216: ComponentFactory.createMenu (
3217: "High memory on X68030/Xellent30",
3218: Multilingual.mlnText (
3219: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 0 << 20, "None", highMemoryListener),
3220: "ja", "なし"),
3221: Multilingual.mlnText (
3222: ComponentFactory.createRadioButtonMenuItem (highMemoryGroup, busHighMemorySize == 16 << 20, "16MB", highMemoryListener),
3223: "ja", "16MB"),
3224: ComponentFactory.createHorizontalSeparator (),
3225: Multilingual.mlnText (
3226: ComponentFactory.createCheckBoxMenuItem (busHighMemorySaveOn, "Save contents on exit", highMemoryListener),
3227: "ja", "終了時に内容を保存する")
3228: ),
3229: "ja", "X68030/Xellent30 のハイメモリ");
3230:
3231:
3232: ActionListener localMemoryListener = new ActionListener () {
3233: @Override public void actionPerformed (ActionEvent ae) {
3234: Object source = ae.getSource ();
3235: String command = ae.getActionCommand ();
3236: switch (command) {
3237: case "None":
3238: busLocalMemorySize = 0 << 20;
3239: break;
3240: case "16MB":
3241: busLocalMemorySize = 16 << 20;
3242: break;
3243: case "32MB":
3244: busLocalMemorySize = 32 << 20;
3245: break;
3246: case "64MB":
3247: busLocalMemorySize = 64 << 20;
3248: break;
3249: case "128MB":
3250: busLocalMemorySize = 128 << 20;
3251: break;
3252: case "256MB":
3253: busLocalMemorySize = 256 << 20;
3254: break;
3255: case "384MB":
3256: busLocalMemorySize = 384 << 20;
3257: break;
3258: case "512MB":
3259: busLocalMemorySize = 512 << 20;
3260: break;
3261: case "768MB":
3262: busLocalMemorySize = 768 << 20;
3263: break;
3264: case "Save contents on exit":
3265: busLocalMemorySaveOn = ((JCheckBoxMenuItem) source).isSelected ();
3266: break;
3267: case "Available on X68000":
3268: busHimem68000 = ((JCheckBoxMenuItem) source).isSelected ();
3269: break;
3270: case "Available on X68030/Xellent30":
3271: busHighMemory060turboOn = ((JCheckBoxMenuItem) source).isSelected ();
3272: break;
3273: }
3274: }
3275: };
3276: ButtonGroup localMenoryGroup = new ButtonGroup ();
3277: JMenu localMemoryMenu = Multilingual.mlnText (
3278: ComponentFactory.createMenu (
3279: "High memory on 060turbo",
3280: Multilingual.mlnText (
3281: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 0 << 20, "None", localMemoryListener),
3282: "ja", "なし"),
3283: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 16 << 20, "16MB", localMemoryListener),
3284: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 32 << 20, "32MB", localMemoryListener),
3285: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 64 << 20, "64MB", localMemoryListener),
3286: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 128 << 20, "128MB", localMemoryListener),
3287: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 256 << 20, "256MB", localMemoryListener),
3288: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 384 << 20, "384MB", localMemoryListener),
3289: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 512 << 20, "512MB", localMemoryListener),
3290: ComponentFactory.createRadioButtonMenuItem (localMenoryGroup, busLocalMemorySize == 768 << 20, "768MB", localMemoryListener),
3291: ComponentFactory.createHorizontalSeparator (),
3292: Multilingual.mlnText (
3293: ComponentFactory.createCheckBoxMenuItem (busLocalMemorySaveOn, "Save contents on exit", localMemoryListener),
3294: "ja", "終了時に内容を保存する"),
3295: ComponentFactory.createHorizontalSeparator (),
3296: Multilingual.mlnText (
3297: ComponentFactory.createCheckBoxMenuItem (busHimem68000, "Available on X68000", localMemoryListener),
3298: "ja", "X68000 でも有効"),
3299: Multilingual.mlnText (
3300: ComponentFactory.createCheckBoxMenuItem (busHighMemory060turboOn, "Available on X68030/Xellent30", localMemoryListener),
3301: "ja", "X68030/Xellent30 でも有効")
3302: ),
3303: "ja", "060turbo のハイメモリ");
3304:
3305:
3306: ActionListener xellent30Listener = new ActionListener () {
3307: @Override public void actionPerformed (ActionEvent ae) {
3308: Object source = ae.getSource ();
3309: String command = ae.getActionCommand ();
3310: switch (command) {
3311: case "$00EC0000-$00EC3FFF":
3312: xt3DIPSW = 0;
3313: break;
3314: case "$00EC4000-$00EC7FFF":
3315: xt3DIPSW = 1;
3316: break;
3317: case "$00EC8000-$00ECBFFF":
3318: xt3DIPSW = 2;
3319: break;
3320: case "$00ECC000-$00ECFFFF":
3321: xt3DIPSW = 3;
3322: break;
3323: case "256KB":
3324: xt3MemorySizeRequest = 1 << 18;
3325: break;
3326: case "1MB":
3327: xt3MemorySizeRequest = 1 << 20;
3328: break;
3329: case "Save contents on exit":
3330: xt3MemorySave = ((JCheckBoxMenuItem) source).isSelected ();
3331: break;
3332: }
3333: }
3334: };
3335: ButtonGroup xellent30PortGroup = new ButtonGroup ();
3336: ButtonGroup xellent30SizeGroup = new ButtonGroup ();
3337: JMenu xellent30Menu = ComponentFactory.createMenu (
3338: "Xellent30",
3339: ComponentFactory.createRadioButtonMenuItem (
3340: xellent30PortGroup,
3341: xt3DIPSW == 0,
3342: "$00EC0000-$00EC3FFF",
3343: xellent30Listener),
3344: ComponentFactory.createRadioButtonMenuItem (
3345: xellent30PortGroup,
3346: xt3DIPSW == 1,
3347: "$00EC4000-$00EC7FFF",
3348: xellent30Listener),
3349: ComponentFactory.createRadioButtonMenuItem (
3350: xellent30PortGroup,
3351: xt3DIPSW == 2,
3352: "$00EC8000-$00ECBFFF",
3353: xellent30Listener),
3354: ComponentFactory.createRadioButtonMenuItem (
3355: xellent30PortGroup,
3356: xt3DIPSW == 3,
3357: "$00ECC000-$00ECFFFF",
3358: xellent30Listener),
3359: ComponentFactory.createHorizontalSeparator (),
3360: ComponentFactory.createRadioButtonMenuItem (
3361: xellent30SizeGroup,
3362: xt3MemorySizeRequest == 1 << 18,
3363: "256KB",
3364: xellent30Listener),
3365: ComponentFactory.createRadioButtonMenuItem (
3366: xellent30SizeGroup,
3367: xt3MemorySizeRequest == 1 << 20,
3368: "1MB",
3369: xellent30Listener),
3370: ComponentFactory.createHorizontalSeparator (),
3371: Multilingual.mlnText (
3372: ComponentFactory.createCheckBoxMenuItem (xt3MemorySave, "Save contents on exit", xellent30Listener),
3373: "ja", "終了時に内容を保存する")
3374: );
3375:
3376:
3377: JMenu rotationMenu = null;
3378: if (PNL_ROTATION_ON) {
3379: ActionListener rotationListener = new ActionListener () {
3380: @Override public void actionPerformed (ActionEvent ae) {
3381: String command = ae.getActionCommand ();
3382: switch (command) {
3383: case "No rotation (landscape)":
3384: pnlRotationMode = 0;
3385: pnlUpdateArrangement ();
3386: break;
3387: case "90-degree rotation (portrait)":
3388: pnlRotationMode = 1;
3389: pnlUpdateArrangement ();
3390: break;
3391: case "180-degree rotation":
3392: pnlRotationMode = 2;
3393: pnlUpdateArrangement ();
3394: break;
3395: case "270-degree rotation":
3396: pnlRotationMode = 3;
3397: pnlUpdateArrangement ();
3398: break;
3399: default:
3400: System.out.println ("unknown action command " + command);
3401: }
3402: }
3403: };
3404: ButtonGroup rotationGroup = new ButtonGroup ();
3405: rotationMenu = Multilingual.mlnText (
3406: ComponentFactory.createMenu (
3407: "Rotation",
3408: Multilingual.mlnText (
3409: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 0, "No rotation (landscape)", rotationListener),
3410: "ja", "回転なし (横画面)"),
3411: Multilingual.mlnText (
3412: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 1, "90-degree rotation (portrait)", rotationListener),
3413: "ja", "90 度回転 (縦画面)"),
3414: Multilingual.mlnText (
3415: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 2, "180-degree rotation", rotationListener),
3416: "ja", "180 度回転"),
3417: Multilingual.mlnText (
3418: ComponentFactory.createRadioButtonMenuItem (rotationGroup, pnlRotationMode == 3, "270-degree rotation", rotationListener),
3419: "ja", "270 度回転")
3420: ),
3421: "ja", "回転");
3422: }
3423:
3424:
3425: ActionListener aspectListener = new ActionListener () {
3426: @Override public void actionPerformed (ActionEvent ae) {
3427: String command = ae.getActionCommand ();
3428: int i = command.indexOf (',');
3429: int resolutionNumber = Integer.parseInt (command.substring (0, i));
3430: int ratioNumber = Integer.parseInt (command.substring (i + 1));
3431: pnlAspectMap[resolutionNumber] = ratioNumber;
3432: pnlUpdateAspectTable ();
3433: pnlUpdateArrangement ();
3434: }
3435: };
3436: JMenu aspectMenu = ComponentFactory.createMenu ("Aspect ratio");
3437: for (int resolutionNumber = 0; resolutionNumber < PNL_ASPECT_RESOLUTION_COUNT; resolutionNumber++) {
3438: JMenu menu = ComponentFactory.createMenu (PNL_ASPECT_RESOLUTION_NAME[resolutionNumber]);
3439: ButtonGroup group = new ButtonGroup ();
3440: for (int ratioNumber = 0; ratioNumber < PNL_ASPECT_RATIO_COUNT; ratioNumber++) {
3441: if (PNL_ASPECT_RATIO_MATRIX[resolutionNumber][ratioNumber] == 0.0F) {
3442: continue;
3443: }
3444: menu.add (
3445: ComponentFactory.setText (
3446: ComponentFactory.createRadioButtonMenuItem (
3447: group,
3448: pnlAspectMap[resolutionNumber] == ratioNumber,
3449: resolutionNumber + "," + ratioNumber,
3450: aspectListener
3451: ),
3452: (PNL_ASPECT_RATIO_MATRIX[resolutionNumber] == PNL_ASPECT_PIXEL_RATIO_02 ?
3453: String.format ("%s (%.3f)",
3454: PNL_ASPECT_SCREEN_NAME[ratioNumber],
3455: PNL_ASPECT_SCREEN_RATIO[ratioNumber]) :
3456: String.format ("%s (%.3f) @ %s (%.3f)",
3457: PNL_ASPECT_SCREEN_NAME[ratioNumber],
3458: PNL_ASPECT_SCREEN_RATIO[ratioNumber],
3459: PNL_ASPECT_NAME_MATRIX[resolutionNumber][ratioNumber],
3460: PNL_ASPECT_RATIO_MATRIX[resolutionNumber][ratioNumber]))
3461: )
3462: );
3463: }
3464: aspectMenu.add (menu);
3465: }
3466: aspectMenu = Multilingual.mlnText (aspectMenu, "ja", "アスペクト比");
3467:
3468:
3469: ActionListener scanlineListener = new ActionListener () {
3470: @Override public void actionPerformed (ActionEvent ae) {
3471:
3472: String command = ae.getActionCommand ();
3473: switch (command) {
3474: case "Off":
3475: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.OFF;
3476: CRTC.crtAllStamp += 2;
3477: break;
3478: case "Weak":
3479: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.WEAK;
3480: CRTC.crtAllStamp += 2;
3481: break;
3482: case "Medium":
3483: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.MEDIUM;
3484: CRTC.crtAllStamp += 2;
3485: break;
3486: case "Strong":
3487: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.STRONG;
3488: CRTC.crtAllStamp += 2;
3489: break;
3490: case "Black":
3491: CRTC.crtScanlineEffect = CRTC.ScanlineEffect.BLACK;
3492: CRTC.crtAllStamp += 2;
3493: break;
3494: }
3495: }
3496: };
3497: ButtonGroup scanlineGroup = new ButtonGroup ();
3498: JMenu scanlineMenu =
3499: Multilingual.mlnText (
3500: ComponentFactory.createMenu (
3501: "Scanline effect",
3502: Multilingual.mlnText (
3503: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.OFF, "Off", scanlineListener),
3504: "ja", "なし"),
3505: Multilingual.mlnText (
3506: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.WEAK, "Weak", scanlineListener),
3507: "ja", "弱"),
3508: Multilingual.mlnText (
3509: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.MEDIUM, "Medium", scanlineListener),
3510: "ja", "中"),
3511: Multilingual.mlnText (
3512: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.STRONG, "Strong", scanlineListener),
3513: "ja", "強"),
3514: Multilingual.mlnText (
3515: ComponentFactory.createRadioButtonMenuItem (scanlineGroup, CRTC.crtScanlineEffect == CRTC.ScanlineEffect.BLACK, "Black", scanlineListener),
3516: "ja", "黒")
3517: ),
3518: "ja", "走査線エフェクト");
3519:
3520:
3521: JTextField refreshRateTextField = ComponentFactory.createNumberField (pnlRefreshRate == 0.0 ? "" : String.valueOf (pnlRefreshRate), 8);
3522: refreshRateTextField.addActionListener (
3523: new ActionListener () {
3524: @Override public void actionPerformed (ActionEvent ae) {
3525: JTextField textField = (JTextField) ae.getSource ();
3526: pnlRefreshRate = 0.0;
3527: String s = textField.getText ();
3528: if (!s.equals ("")) {
3529: double rate = 0.0;
3530: try {
3531: rate = Double.parseDouble (s);
3532: } catch (NumberFormatException nfe) {
3533: }
3534: if (PNL_MIN_RATE <= rate && rate <= PNL_MAX_RATE) {
3535: pnlRefreshRate = rate;
3536: } else {
3537: textField.setText ("");
3538: }
3539: }
3540: pnlFixedRate = pnlRefreshRate;
3541: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3542: pnlFixedRate = pnlGetRefreshRate ();
3543: }
3544: CRTC.crtUpdateLength ();
3545: }
3546: });
3547:
3548: ButtonGroup unitGroup = new ButtonGroup ();
3549: ButtonGroup frameGroup = new ButtonGroup ();
3550: ButtonGroup hintGroup = new ButtonGroup ();
3551: ButtonGroup vgaGroup = new ButtonGroup ();
3552: ButtonGroup intermittentGroup = new ButtonGroup ();
3553: ButtonGroup sterescopicGroup = new ButtonGroup ();
3554: ButtonGroup soundInterpolationGroup = new ButtonGroup ();
3555: ButtonGroup adpcmInterpolationGroup = new ButtonGroup ();
3556: ButtonGroup adpcmOSCFreqGroup = new ButtonGroup ();
3557: ButtonGroup keyboardGroup = new ButtonGroup ();
3558: ButtonGroup spritesGroup = new ButtonGroup ();
3559:
3560:
3561: DecimalSpinner[] freqSpinner = new DecimalSpinner[3];
3562: ChangeListener freqListener = new ChangeListener () {
3563: @Override public void stateChanged (ChangeEvent ce) {
3564: DecimalSpinner spinner = (DecimalSpinner) ce.getSource ();
3565: int i = spinner.getOption ();
3566: CRTC.crtFreqsRequest[i] = spinner.getIntValue ();
3567: }
3568: };
3569: for (int i = 0; i < 3; i++) {
3570: freqSpinner[i] = ComponentFactory.createDecimalSpinner (
3571: CRTC.crtFreqsRequest[i], CRTC.CRT_MIN_FREQ, CRTC.CRT_MAX_FREQ, 1000000, i, freqListener
3572: );
3573: }
3574: DecimalSpinner sprrasSpinner = ComponentFactory.createDecimalSpinner (
3575: SpriteScreen.sprSpritesPerRaster, 0, 1016, 1, 0,
3576: new ChangeListener () {
3577: @Override public void stateChanged (ChangeEvent ce) {
3578: SpriteScreen.sprSpritesPerRaster = ((DecimalSpinner) ce.getSource ()).getIntValue ();
3579: }
3580: });
3581: ActionListener modificationListener = new ActionListener () {
3582: @Override public void actionPerformed (ActionEvent ae) {
3583: Object source = ae.getSource ();
3584: String command = ae.getActionCommand ();
3585: switch (command) {
3586:
3587: case "Adjust to host refresh rate":
3588: pnlAdjustVsync = ((JCheckBoxMenuItem) source).isSelected ();
3589: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
3590: pnlFixedRate = pnlGetRefreshRate ();
3591: }
3592: CRTC.crtUpdateLength ();
3593: break;
3594: case "* Reset to default values":
3595: for (int i = 0; i < 3; i++) {
3596: if (CRTC.crtFreqsRequest[i] != CRTC.CRT_DEFAULT_FREQS[i]) {
3597: CRTC.crtFreqsRequest[i] = CRTC.CRT_DEFAULT_FREQS[i];
3598: freqSpinner[i].setIntValue (CRTC.crtFreqsRequest[i]);
3599: }
3600: }
3601: break;
3602: case "1024-dot non-interlaced":
3603: CRTC.crtEleventhBitRequest = ((JCheckBoxMenuItem) source).isSelected ();
3604: break;
3605: case "Can write 0 to bit 0 of CRTC R00":
3606: CRTC.crtR00Bit0Zero = ((JCheckBoxMenuItem) source).isSelected ();
3607: break;
3608:
3609: case "Extended graphic screen":
3610: CRTC.crtExtendedGraphicRequest = ((JCheckBoxMenuItem) source).isSelected ();
3611: break;
3612:
3613: case "Spherical scrolling of text screen":
3614: CRTC.crtSetSphericalScrolling (((JCheckBoxMenuItem) source).isSelected ());
3615: break;
3616:
3617: case "128 sprites":
3618: SpriteScreen.sprNumberOfSpritesRequest = 128;
3619: break;
3620: case "256 sprites":
3621: SpriteScreen.sprNumberOfSpritesRequest = 256;
3622: break;
3623: case "504 sprites":
3624: SpriteScreen.sprNumberOfSpritesRequest = 512;
3625: break;
3626: case "1016 sprites":
3627: SpriteScreen.sprNumberOfSpritesRequest = 1024;
3628: break;
3629:
3630:
3631:
3632: case "Full pattern memory":
3633: SpriteScreen.sprFPMRequest = ((JCheckBoxMenuItem) source).isSelected ();
3634: break;
3635: case "4096 patterns":
3636: SpriteScreen.sprBankOnRequest = ((JCheckBoxMenuItem) source).isSelected ();
3637: break;
3638: case "Sprites displayed in 768x512":
3639: SpriteScreen.spr768x512Request = ((JCheckBoxMenuItem) source).isSelected ();
3640: break;
3641: case "BG1 displayed in 512x512":
3642: SpriteScreen.spr512bg1Request = ((JCheckBoxMenuItem) source).isSelected ();
3643: break;
3644: case "Row and column scroll":
3645: if (SpriteScreen.SPR_RC_SCROLL_ON) {
3646: SpriteScreen.sprRcScrollRequest = ((JCheckBoxMenuItem) source).isSelected ();
3647: }
3648: break;
3649: case "** Reset to default values":
3650: if (SpriteScreen.sprSpritesPerRaster != 32) {
3651: SpriteScreen.sprSpritesPerRaster = 32;
3652: sprrasSpinner.setIntValue (SpriteScreen.sprSpritesPerRaster);
3653: }
3654: break;
3655: }
3656: }
3657: };
3658: JMenu modificationMenu =
3659: Multilingual.mlnText (
3660: ComponentFactory.createMenu (
3661: "Modification",
3662: Multilingual.mlnText (
3663: ComponentFactory.createMenu (
3664: "Dot clock",
3665: Multilingual.mlnText (
3666: ComponentFactory.createCheckBoxMenuItem (pnlAdjustVsync, "Adjust to host refresh rate", modificationListener),
3667: "ja", "ホストのリフレッシュレートに合わせる"),
3668: ComponentFactory.createHorizontalBox (
3669: Box.createHorizontalStrut (20),
3670: refreshRateTextField,
3671: ComponentFactory.createLabel (" Hz"),
3672: Box.createHorizontalGlue ()
3673: ),
3674: ComponentFactory.createHorizontalSeparator (),
3675: ComponentFactory.createHorizontalBox (
3676: Box.createHorizontalStrut (20),
3677: Multilingual.mlnText (ComponentFactory.createLabel ("Dot clock oscillattor"), "ja", "ドットクロックオシレータ"),
3678: Box.createHorizontalGlue ()
3679: ),
3680: ComponentFactory.createHorizontalBox (
3681: Box.createHorizontalStrut (20),
3682: freqSpinner[0],
3683: ComponentFactory.createLabel (" Hz *"),
3684: Box.createHorizontalGlue ()
3685: ),
3686: ComponentFactory.createHorizontalBox (
3687: Box.createHorizontalStrut (20),
3688: freqSpinner[1],
3689: ComponentFactory.createLabel (" Hz *"),
3690: Box.createHorizontalGlue ()
3691: ),
3692: ComponentFactory.createHorizontalBox (
3693: Box.createHorizontalStrut (20),
3694: freqSpinner[2],
3695: ComponentFactory.createLabel (" Hz *"),
3696: Box.createHorizontalGlue ()
3697: ),
3698: Multilingual.mlnText (
3699: ComponentFactory.createMenuItem ("* Reset to default values", modificationListener),
3700: "ja", "* 初期値に戻す"),
3701: ComponentFactory.createHorizontalSeparator (),
3702: Multilingual.mlnText (
3703: ComponentFactory.createCheckBoxMenuItem (CRTC.crtEleventhBitRequest, "1024-dot non-interlaced", modificationListener),
3704: "ja", "1024 ドットノンインターレース"),
3705: Multilingual.mlnText (
3706: ComponentFactory.createCheckBoxMenuItem (CRTC.crtR00Bit0Zero, "Can write 0 to bit 0 of CRTC R00", modificationListener),
3707: "ja", "CRTC R00 のビット 0 に 0 を書き込める")
3708: ),
3709: "ja", "ドットクロック"),
3710: Multilingual.mlnText (
3711: ComponentFactory.createMenu (
3712: "Graphic screen",
3713: !CRTC.CRT_EXTENDED_GRAPHIC ? null : Multilingual.mlnText (
3714: ComponentFactory.createCheckBoxMenuItem (CRTC.crtExtendedGraphicRequest, "Extended graphic screen", modificationListener),
3715: "ja", "拡張グラフィック画面")
3716: ),
3717: "ja", "グラフィック画面"),
3718: Multilingual.mlnText (
3719: ComponentFactory.createMenu (
3720: "Text screen",
3721: Multilingual.mlnText (
3722: ComponentFactory.createCheckBoxMenuItem (CRTC.crtSphericalScrolling, "Spherical scrolling of text screen", modificationListener),
3723: "ja", "テキスト画面の球面スクロール")
3724: ),
3725: "ja", "テキスト画面"),
3726: Multilingual.mlnText (
3727: ComponentFactory.createMenu (
3728: "Sprite screen",
3729: Multilingual.mlnText (
3730: ComponentFactory.createRadioButtonMenuItem (
3731: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 128, "128 sprites", modificationListener),
3732: "ja", "128 枚のスプライト"),
3733: Multilingual.mlnText (
3734: ComponentFactory.createRadioButtonMenuItem (
3735: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 256, "256 sprites", modificationListener),
3736: "ja", "256 枚のスプライト"),
3737: Multilingual.mlnText (
3738: ComponentFactory.createRadioButtonMenuItem (
3739: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 512, "504 sprites", modificationListener),
3740: "ja", "504 枚のスプライト"),
3741: Multilingual.mlnText (
3742: ComponentFactory.createRadioButtonMenuItem (
3743: spritesGroup, SpriteScreen.sprNumberOfSpritesRequest == 1024, "1016 sprites", modificationListener),
3744: "ja", "1016 枚のスプライト"),
3745:
3746:
3747:
3748:
3749: ComponentFactory.createHorizontalSeparator (),
3750: Multilingual.mlnText (
3751: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprFPMRequest, "Full pattern memory", modificationListener),
3752: "ja", "フルパターンメモリ"),
3753: ComponentFactory.createHorizontalSeparator (),
3754: Multilingual.mlnText (
3755: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprBankOnRequest, "4096 patterns", modificationListener),
3756: "ja", "4096 個のパターン"),
3757: Multilingual.mlnText (
3758: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr768x512Request, "Sprites displayed in 768x512", modificationListener),
3759: "ja", "768x512 でスプライトを表示"),
3760: Multilingual.mlnText (
3761: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.spr512bg1Request, "BG1 displayed in 512x512", modificationListener),
3762: "ja", "512x512 で BG1 を表示"),
3763: !SpriteScreen.SPR_RC_SCROLL_ON ? null : Multilingual.mlnText (
3764: ComponentFactory.createCheckBoxMenuItem (SpriteScreen.sprRcScrollRequest, "Row and column scroll", modificationListener),
3765: "ja", "行スクロールと列スクロール"),
3766: ComponentFactory.createHorizontalSeparator (),
3767: ComponentFactory.createHorizontalBox (
3768: Box.createHorizontalStrut (20),
3769: Multilingual.mlnText (ComponentFactory.createLabel ("Number of sprites per raster"), "ja", "ラスタあたりのスプライトの枚数"),
3770: Box.createHorizontalGlue ()
3771: ),
3772: ComponentFactory.createHorizontalBox (
3773: Box.createHorizontalStrut (20),
3774: sprrasSpinner,
3775: ComponentFactory.createLabel (" **"),
3776: Box.createHorizontalGlue ()
3777: ),
3778: Multilingual.mlnText (
3779: ComponentFactory.createMenuItem ("** Reset to default values", modificationListener),
3780: "ja", "** 初期値に戻す")
3781: ),
3782: "ja", "スプライト画面")
3783: ),
3784: "ja", "改造");
3785:
3786:
3787: mnbMenuBar = ComponentFactory.createMenuBar (
3788:
3789:
3790: mnbFileMenu = Multilingual.mlnText (
3791: ComponentFactory.createMenu (
3792: "File", 'F',
3793:
3794: FDC.fdcMenu,
3795:
3796: HDC.hdcMenu,
3797:
3798: SPC.spcMenu,
3799:
3800: HFS.hfsMenu,
3801: ComponentFactory.createHorizontalSeparator (),
3802: mnbQuitMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Quit", 'Q', MNB_MODIFIERS, listener), "ja", "終了")
3803: ),
3804: "ja", "ファイル"),
3805:
3806:
3807: mpuMenu,
3808:
3809:
3810: mnbDisplayMenu = Multilingual.mlnText (
3811: ComponentFactory.createMenu (
3812: "Display", 'D',
3813: mnbFullScreenMenuItem,
3814: !PNL_ROUNDED_CORNER_ON ? null : ComponentFactory.createHorizontalBox (
3815: Box.createHorizontalStrut (20),
3816: Multilingual.mlnText (
3817: ComponentFactory.createLabel ("Rounded corner ratio "),
3818: "ja", "角丸率 "),
3819: pnlRoundedCornerSpinner,
3820: ComponentFactory.createLabel ("%"),
3821: Box.createHorizontalGlue ()
3822: ),
3823: mnbMaximizedMenuItem,
3824: mnbFitInWindowMenuItem,
3825: mnbFixedScaleMenuItem,
3826: ComponentFactory.createHorizontalBox (
3827: Box.createHorizontalStrut (20),
3828: pnlFixedSpinner,
3829: Multilingual.mlnText (
3830: ComponentFactory.createLabel ("% Scale factor"),
3831: "ja", "% 倍率"),
3832: Box.createHorizontalGlue ()
3833: ),
3834: ComponentFactory.createMenuItem ("50%", listener),
3835: ComponentFactory.createMenuItem ("75%", listener),
3836: ComponentFactory.createMenuItem ("100%", listener),
3837: ComponentFactory.createMenuItem ("150%", listener),
3838: ComponentFactory.createMenuItem ("200%", listener),
3839: ComponentFactory.createHorizontalSeparator (),
3840:
3841: rotationMenu,
3842:
3843: aspectMenu,
3844:
3845: Multilingual.mlnText (
3846: ComponentFactory.createMenu (
3847: "Interpolation algorithm",
3848: Multilingual.mlnText (
3849: ComponentFactory.createRadioButtonMenuItem (
3850: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR,
3851: "Nearest neighbor", listener),
3852: "ja", "最近傍補間"),
3853: Multilingual.mlnText (
3854: ComponentFactory.createRadioButtonMenuItem (
3855: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BILINEAR,
3856: "Bilinear", listener),
3857: "ja", "線形補間"),
3858: Multilingual.mlnText (
3859: ComponentFactory.createRadioButtonMenuItem (
3860: hintGroup, pnlInterpolation == RenderingHints.VALUE_INTERPOLATION_BICUBIC,
3861: "Bicubic", listener),
3862: "ja", "三次補間")
3863: ),
3864: "ja", "補間アルゴリズム"),
3865:
3866: scanlineMenu,
3867: !PNL_USE_CANVAS ? null : Multilingual.mlnText (
3868: ComponentFactory.createCheckBoxMenuItem (pnlUseCanvasRequest, "Use canvas", listener),
3869: "ja", "キャンバスを使う"),
3870:
3871: !CRTC.CRT_ENABLE_INTERMITTENT ? null : Multilingual.mlnText (
3872: ComponentFactory.createMenu (
3873: "Intermittent drawing",
3874: Multilingual.mlnText (
3875: ComponentFactory.createRadioButtonMenuItem (
3876: intermittentGroup, CRTC.crtIntermittentInterval == 0, "Draw all changed pictures", listener),
3877: "ja", "変化した画像をすべて描画する"),
3878: Multilingual.mlnText (
3879: ComponentFactory.createRadioButtonMenuItem (
3880: intermittentGroup, CRTC.crtIntermittentInterval == 1, "Draw a changed picture once every two times", listener),
3881: "ja", "変化した画像を 2 回に 1 回描画する"),
3882: Multilingual.mlnText (
3883: ComponentFactory.createRadioButtonMenuItem (
3884: intermittentGroup, CRTC.crtIntermittentInterval == 2, "Draw a changed picture once every three times", listener),
3885: "ja", "変化した画像を 3 回に 1 回描画する"),
3886: Multilingual.mlnText (
3887: ComponentFactory.createRadioButtonMenuItem (
3888: intermittentGroup, CRTC.crtIntermittentInterval == 3, "Draw a changed picture once every four times", listener),
3889: "ja", "変化した画像を 4 回に 1 回描画する"),
3890: Multilingual.mlnText (
3891: ComponentFactory.createRadioButtonMenuItem (
3892: intermittentGroup, CRTC.crtIntermittentInterval == 4, "Draw a changed picture once every five times", listener),
3893: "ja", "変化した画像を 5 回に 1 回描画する")
3894: ),
3895: "ja", "間欠描画"),
3896:
3897: !PNL_STEREOSCOPIC_ON ? null : ComponentFactory.createHorizontalSeparator (),
3898: mnbStereoscopicMenuItem = !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3899: ComponentFactory.createCheckBoxMenuItem (pnlStereoscopicOn, "Stereoscopic viewing", 'T', listener),
3900: "ja", "立体視"),
3901: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3902: ComponentFactory.createMenu (
3903: "Stereoscopic settings",
3904: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3905: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3906: pnlStereoscopicMethod == PNL_NAKED_EYE_CROSSING,
3907: "Naked-eye crossing", listener),
3908: "ja", "裸眼交差法"),
3909: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3910: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3911: pnlStereoscopicMethod == PNL_NAKED_EYE_PARALLEL,
3912: "Naked-eye parallel", listener),
3913: "ja", "裸眼平行法"),
3914: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3915: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3916: pnlStereoscopicMethod == PNL_SIDE_BY_SIDE,
3917: "Side-by-side", listener),
3918: "ja", "サイドバイサイド"),
3919: !PNL_STEREOSCOPIC_ON ? null : Multilingual.mlnText (
3920: ComponentFactory.createRadioButtonMenuItem (sterescopicGroup,
3921: pnlStereoscopicMethod == PNL_TOP_AND_BOTTOM,
3922: "Top-and-bottom", listener),
3923: "ja", "トップアンドボトム")
3924: ),
3925: "ja", "立体視設定"),
3926:
3927: ComponentFactory.createHorizontalSeparator (),
3928: GIFAnimation.gifStartRecordingMenuItem,
3929: GIFAnimation.gifSettingsMenu,
3930:
3931: ComponentFactory.createHorizontalSeparator (),
3932: modificationMenu,
3933:
3934: SpritePatternViewer.SPV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Sprite pattern viewer", listener), "ja", "スプライトパターンビュア") : null,
3935: PaletteViewer.PLV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Palette viewer", listener), "ja", "パレットビュア") : null,
3936: ScreenModeTest.SMT_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Screen mode test", listener), "ja", "表示モードテスト") : null
3937: ),
3938: "ja", "画面"),
3939:
3940:
3941: mnbSoundMenu = ComponentFactory.setEnabled (
3942: Multilingual.mlnText (
3943: ComponentFactory.createMenu (
3944: "Sound", 'S',
3945: mnbPlayMenuItem = ComponentFactory.setEnabled (
3946: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (SoundSource.sndPlayOn, "Play", 'P', MNB_MODIFIERS, listener), "ja", "音声出力"),
3947: SoundSource.sndLine != null),
3948:
3949:
3950:
3951: ComponentFactory.createHorizontalBox (
3952: Box.createHorizontalGlue (),
3953: Multilingual.mlnText (ComponentFactory.createLabel ("Volume "), "ja", "音量 "),
3954: mnbVolumeLabel = ComponentFactory.createLabel (String.valueOf (SoundSource.sndVolume)),
3955: Box.createHorizontalGlue ()
3956: ),
3957:
3958:
3959: ComponentFactory.setPreferredSize (
3960: ComponentFactory.createHorizontalSlider (
3961: 0,
3962: SoundSource.SND_VOLUME_MAX,
3963: SoundSource.sndVolume,
3964: SoundSource.SND_VOLUME_STEP,
3965: 1,
3966: new ChangeListener () {
3967: @Override public void stateChanged (ChangeEvent ce) {
3968: SoundSource.sndSetVolume (((JSlider) ce.getSource ()).getValue ());
3969: }
3970: }),
3971: LnF.lnfFontSize * 18, LnF.lnfFontSize * 2 + 28),
3972: Multilingual.mlnText (
3973: ComponentFactory.createMenu (
3974: "Sound interpolation",
3975: Multilingual.mlnText (
3976: ComponentFactory.createRadioButtonMenuItem (
3977: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.THINNING_STEREO,
3978: "Sound thinning", listener),
3979: "ja", "音声 間引き"),
3980: Multilingual.mlnText (
3981: ComponentFactory.createRadioButtonMenuItem (
3982: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_STEREO,
3983: "Sound linear interpolation", listener),
3984: "ja", "音声 線形補間"),
3985: ComponentFactory.setEnabled (
3986: Multilingual.mlnText (
3987: ComponentFactory.createRadioButtonMenuItem (
3988: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000,
3989: "Sound piecewise-constant area interpolation", listener),
3990: "ja", "音声 区分定数面積補間"),
3991: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000),
3992: ComponentFactory.setEnabled (
3993: Multilingual.mlnText (
3994: ComponentFactory.createRadioButtonMenuItem (
3995: soundInterpolationGroup, SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000,
3996: "Sound linear area interpolation", listener),
3997: "ja", "音声 線形面積補間"),
3998: SoundSource.SND_CHANNELS == 2 && SoundSource.SND_SAMPLE_FREQ == 48000)
3999: ),
4000: "ja", "音声補間"),
4001: Multilingual.mlnText (ComponentFactory.createMenuItem ("Sound monitor", listener), "ja", "音声モニタ"),
4002:
4003: ComponentFactory.createHorizontalSeparator (),
4004:
4005: ComponentFactory.setEnabled (
4006: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (OPM.opmOutputMask != 0, "OPM output", listener), "ja", "OPM 出力"),
4007: SoundSource.sndLine != null),
4008: !OPMLog.OLG_ON ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("OPM log", listener), "ja", "OPM ログ"),
4009:
4010: ComponentFactory.createHorizontalSeparator (),
4011:
4012: ComponentFactory.setEnabled (
4013: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ADPCM.pcmOutputOn, "PCM output", listener), "ja", "PCM 出力"),
4014: SoundSource.sndLine != null),
4015: Multilingual.mlnText (
4016: ComponentFactory.createMenu (
4017: "PCM interpolation",
4018: Multilingual.mlnText (
4019: ComponentFactory.createRadioButtonMenuItem (
4020: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_CONSTANT,
4021: "PCM piecewise-constant interpolation", listener),
4022: "ja", "PCM 区分定数補間"),
4023: Multilingual.mlnText (
4024: ComponentFactory.createRadioButtonMenuItem (
4025: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_LINEAR,
4026: "PCM linear interpolation", listener),
4027: "ja", "PCM 線形補間"),
4028: Multilingual.mlnText (
4029: ComponentFactory.createRadioButtonMenuItem (
4030: adpcmInterpolationGroup, ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_HERMITE,
4031: "PCM hermite interpolation", listener),
4032: "ja", "PCM エルミート補間")
4033: ),
4034: "ja", "PCM 補間"),
4035: Multilingual.mlnText (
4036: ComponentFactory.createMenu (
4037: "PCM source oscillator frequency",
4038: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 0, "PCM 8MHz/4MHz", listener),
4039: ComponentFactory.createRadioButtonMenuItem (adpcmOSCFreqGroup, ADPCM.pcmOSCFreqRequest == 1, "PCM 8MHz/16MHz", listener)
4040: ),
4041: "ja", "PCM 原発振周波数"),
4042:
4043: !MercuryUnit.MU4_ON ? null :
4044: ComponentFactory.createHorizontalSeparator (),
4045: !MercuryUnit.MU4_ON ? null :
4046: ComponentFactory.createCheckBoxMenuItem (
4047: MercuryUnit.mu4OnRequest,
4048: "Mercury-Unit V4 (MK-MU1)",
4049: listener),
4050: !MercuryUnit.MU4_ON ? null :
4051: Multilingual.mlnText (
4052: ComponentFactory.createCheckBoxMenuItem (
4053: MercuryUnit.mu4OutputEnable,
4054: "MU4 output",
4055: listener),
4056: "ja", "MU4 出力"),
4057: ComponentFactory.createHorizontalSeparator (),
4058: SRAM.smrStupsndMenu
4059: ),
4060: "ja", "音声"),
4061: SoundSource.sndLine != null),
4062:
4063:
4064: mnbInputMenu = Multilingual.mlnText (
4065: ComponentFactory.createMenu (
4066: "Input", 'I',
4067: mnbPasteMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Paste", 'V', MNB_MODIFIERS, listener), "ja", "貼り付け"),
4068: CONDevice.conSettingsMenu,
4069: TextCopy.txcMakeMenuItem (),
4070: TextCopy.txcMakeSettingMenu (),
4071: ComponentFactory.createHorizontalSeparator (),
4072: mnbNoKeyboardMenuItem = Multilingual.mlnText (
4073: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, !Keyboard.kbdOn, "No keyboard", 'K', MNB_MODIFIERS, listener),
4074: "ja", "キーボードなし"),
4075: mnbStandardKeyboardMenuItem = Multilingual.mlnText (
4076: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_STANDARD_TYPE, "Standard keyboard", listener),
4077: "ja", "標準キーボード"),
4078: mnbCompactKeyboardMenuItem = Multilingual.mlnText (
4079: ComponentFactory.createRadioButtonMenuItem (keyboardGroup, Keyboard.kbdOn && Keyboard.kbdType == Keyboard.KBD_COMPACT_TYPE, "Compact keyboard", listener),
4080: "ja", "コンパクトキーボード"),
4081: Multilingual.mlnText (
4082: ComponentFactory.createCheckBoxMenuItem (pnlHideKeyboard, "Hide keyboard in full screen", listener),
4083: "ja", "全画面表示のときキーボードを隠す"),
4084: Multilingual.mlnText (ComponentFactory.createMenuItem ("Key assignments", listener), "ja", "キー割り当て"),
4085: ButtonFunction.bfnMakeMenuItem (),
4086: SRAM.smrRepeatDelayMenu,
4087: SRAM.smrRepeatIntervalMenu,
4088: !Keyboard.KBD_ZKEY_ON ? null : Keyboard.kbdZKeyMenu,
4089: ComponentFactory.createHorizontalSeparator (),
4090: Mouse.musSeamlessMouseCheckBox,
4091: Mouse.musFollowScrollCheckBox,
4092: Mouse.musCtrlRightCheckBox,
4093: Mouse.musEdgeAccelerationCheckBox,
4094: Mouse.musMouseCursorSpeedBox,
4095: Mouse.musSpeedSlider,
4096: Mouse.musHostsPixelUnitsCheckBox,
4097: ComponentFactory.createHorizontalSeparator (),
4098: Multilingual.mlnText (ComponentFactory.createMenuItem ("Joystick port settings", listener), "ja", "ジョイスティックポート設定")
4099: ),
4100: "ja", "入力"),
4101:
4102:
4103: mnbConfigMenu = Multilingual.mlnText (
4104: ComponentFactory.createMenu (
4105: "Config", 'G',
4106: Multilingual.mlnText (ComponentFactory.createMenuItem ("RS-232C and terminal", listener), "ja", "RS-232C とターミナル"),
4107: Multilingual.mlnText (
4108: ComponentFactory.createMenu (
4109: "Debug",
4110: Multilingual.mlnText (ComponentFactory.createMenuItem ("Console", listener), "ja", "コンソール"),
4111: Multilingual.mlnText (ComponentFactory.createMenuItem ("Register list", listener), "ja", "レジスタリスト"),
4112: Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble list", listener), "ja", "逆アセンブルリスト"),
4113: Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory dump list", listener), "ja", "メモリダンプリスト"),
4114: Multilingual.mlnText (ComponentFactory.createMenuItem ("Logical space monitor", listener), "ja", "論理空間モニタ"),
4115: Multilingual.mlnText (ComponentFactory.createMenuItem ("Physical space monitor", listener), "ja", "物理空間モニタ"),
4116: ATCMonitor.ACM_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Address translation caches monitor", listener), "ja", "アドレス変換キャッシュモニタ") : null,
4117: BranchLog.BLG_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Branch log", listener), "ja", "分岐ログ") : null,
4118: ProgramFlowVisualizer.PFV_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Program flow visualizer", listener), "ja", "プログラムフロービジュアライザ") : null,
4119: RasterBreakPoint.RBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Raster break point", listener), "ja", "ラスタブレークポイント") : null,
4120: DataBreakPoint.DBP_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Data break point", listener), "ja", "データブレークポイント") : null,
4121: RootPointerList.RTL_ON ? Multilingual.mlnText (ComponentFactory.createMenuItem ("Root pointer list", listener), "ja", "ルートポインタリスト") : null,
4122: ComponentFactory.createHorizontalSeparator (),
4123: SRAM.smrRomdbMenu
4124: ),
4125: "ja", "デバッグ"),
4126: SRAM.smrBootMenu,
4127: mainMemoryMenu,
4128: highMemoryMenu,
4129: localMemoryMenu,
4130: xellent30Menu,
4131: ComponentFactory.createHorizontalSeparator (),
4132: ComponentFactory.createMenu (
4133: "RTC",
4134: Multilingual.mlnText (
4135: ComponentFactory.createMenuItem ("Adjust clock to host", listener),
4136: "ja", "時計をホストに合わせる")
4137: ),
4138: Z8530.sccMakeMenu (),
4139: SRAM.smrMenu,
4140: Settings.sgsMenu,
4141: ComponentFactory.createHorizontalSeparator (),
4142: Multilingual.mlnText (ComponentFactory.createMenuItem ("Printer", listener), "ja", "プリンタ"),
4143: ROM.romMenu,
4144: Multilingual.mlnText (
4145: ComponentFactory.createMenu (
4146: "Miscellaneous",
4147: SlowdownTest.sdtCheckBoxMenuItem,
4148: SlowdownTest.sdtBox,
4149: Multilingual.mlnText (
4150: ComponentFactory.createCheckBoxMenuItem (Mouse.musOutputButtonStatus, "Print key and mouse button events", listener),
4151: "ja", "キーとマウスのボタンのイベントを表示")
4152: ),
4153: "ja", "その他"),
4154: ComponentFactory.createHorizontalSeparator (),
4155: Multilingual.mlnText (
4156: ComponentFactory.createMenu (
4157: "Accessibility",
4158:
4159: !FlashingLights.FLR_ON ? null :
4160: FlashingLights.flrMakeMenu (),
4161: !FlashingLights.FLR_ON ? null :
4162: ComponentFactory.createHorizontalSeparator (),
4163:
4164: mnbMakeFontSizeMenu (),
4165:
4166: mnbMakeColorMenu ()
4167: ),
4168: "ja", "アクセシビリティ"),
4169: ComponentFactory.createHorizontalSeparator (),
4170: Multilingual.mlnText (
4171: ComponentFactory.createMenuItem ("Java runtime environment information", listener),
4172: "ja", "Java 実行環境の情報"),
4173: Multilingual.mlnText (
4174: ComponentFactory.createMenuItem ("Version information", listener),
4175: "ja", "バージョン情報"),
4176: Multilingual.mlnText (
4177: ComponentFactory.createMenu (
4178: "License",
4179: Multilingual.mlnText (ComponentFactory.createMenuItem ("XEiJ License", listener), "ja", "XEiJ 使用許諾条件"),
4180: Multilingual.mlnText (ComponentFactory.createMenuItem ("FSHARP License", listener), "ja", "FSHARP 許諾条件"),
4181: Multilingual.mlnText (ComponentFactory.createMenuItem ("ymfm License", listener), "ja", "ymfm License"),
4182: Multilingual.mlnText (ComponentFactory.createMenuItem ("jSerialComm License", listener), "ja", "jSerialComm License")
4183: ),
4184: "ja", "使用許諾条件")
4185: ),
4186: "ja", "設定"),
4187:
4188: mnbMakeLanguageMenu (),
4189:
4190:
4191: Box.createHorizontalGlue (),
4192: ComponentFactory.createVerticalBox (
4193: Box.createVerticalGlue (),
4194: Indicator.indBox,
4195: Box.createVerticalGlue ()
4196: ),
4197: Box.createHorizontalGlue ()
4198:
4199: );
4200: }
4201:
4202:
4203:
4204:
4205:
4206:
4207:
4208: public static boolean frmIsActive;
4209:
4210:
4211: public static JFrame frmFrame;
4212: public static int frmMarginWidth;
4213: public static int frmMarginHeight;
4214: public static Dimension frmMinimumSize;
4215:
4216:
4217: public static GraphicsDevice frmScreenDevice;
4218:
4219:
4220: public static DropTarget frmDropTarget;
4221:
4222:
4223:
4224: public static void frmInit () {
4225: frmIsActive = false;
4226: frmScreenDevice = GraphicsEnvironment.getLocalGraphicsEnvironment ().getDefaultScreenDevice ();
4227: pnlIsFullScreenSupported = frmScreenDevice.isFullScreenSupported ();
4228: }
4229:
4230:
4231:
4232: public static void frmMake () {
4233:
4234:
4235: frmFrame = ComponentFactory.createRestorableFrame (
4236: Settings.SGS_FRM_FRAME_KEY,
4237: PRG_TITLE + " version " + PRG_VERSION,
4238: mnbMenuBar,
4239: pnlPanel);
4240: frmUpdateTitle ();
4241: frmFrame.setIconImage (LnF.LNF_ICON_IMAGE_48);
4242: frmFrame.setDefaultCloseOperation (WindowConstants.DISPOSE_ON_CLOSE);
4243:
4244:
4245:
4246:
4247: frmMarginWidth = frmFrame.getWidth () - pnlPanel.getWidth ();
4248: frmMarginHeight = frmFrame.getHeight () - pnlPanel.getHeight ();
4249: frmMinimumSize = new Dimension (pnlMinimumWidth + frmMarginWidth, pnlMinimumHeight + frmMarginHeight);
4250: frmFrame.setMinimumSize (frmMinimumSize);
4251:
4252:
4253:
4254: frmDropTarget = new DropTarget (pnlPanel, DnDConstants.ACTION_COPY, new DropTargetAdapter () {
4255: @Override public void dragOver (DropTargetDragEvent dtde) {
4256: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
4257: dtde.acceptDrag (DnDConstants.ACTION_COPY);
4258: return;
4259: }
4260: dtde.rejectDrag ();
4261: }
4262: @Override public void drop (DropTargetDropEvent dtde) {
4263: try {
4264: if (dtde.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) {
4265: dtde.acceptDrop (DnDConstants.ACTION_COPY);
4266: boolean reset = false;
4267: int fdu0 = -1;
4268: int fdu = 0;
4269: int hdu0 = -1;
4270: int hdu = 0;
4271: int scu0 = -1;
4272: int scu = 0;
4273: int hfu0 = -1;
4274: int hfu = 0;
4275: for (Object o : (java.util.List) dtde.getTransferable ().getTransferData (DataFlavor.javaFileListFlavor)) {
4276: if (o instanceof File) {
4277: File file = (File) o;
4278: if (file.isFile ()) {
4279: if (FDC.fdcFileFilter.accept (file)) {
4280: if (fdu < FDC.FDC_MAX_UNITS &&
4281: FDC.fdcUnitArray[fdu].insert (file.getPath (), false)) {
4282: if (fdu0 < 0) {
4283: fdu0 = fdu;
4284: }
4285: fdu++;
4286: continue;
4287: }
4288: }
4289: if (HDC.hdcFileFilter.accept (file)) {
4290: if (hdu < 16 &&
4291: HDC.hdcUnitArray[hdu].insert (file.getPath (), false)) {
4292: if (hdu0 < 0) {
4293: hdu0 = hdu;
4294: }
4295: hdu++;
4296: continue;
4297: }
4298: }
4299: if (SPC.spcFileFilter.accept (file)) {
4300: if (scu < 16 &&
4301: SPC.spcUnitArray[scu].insert (file.getPath (), false)) {
4302: if (scu0 < 0) {
4303: scu0 = scu;
4304: }
4305: scu++;
4306: continue;
4307: }
4308: }
4309: }
4310: if (HFS.hfsFileFilter.accept (file)) {
4311: if (hfu < HFS.HFS_MAX_UNITS &&
4312: HFS.hfsUnitArray[hfu].insert (file.getPath (), false)) {
4313: if (hfu0 < 0) {
4314: hfu0 = hfu;
4315: }
4316: hfu++;
4317: continue;
4318: }
4319: }
4320: }
4321: reset = false;
4322: }
4323: dtde.dropComplete (true);
4324: if (reset) {
4325: if (fdu0 >= 0) {
4326: mpuReset (0x9070 | fdu0 << 8, -1);
4327: } else if (hdu0 >= 0) {
4328: mpuReset (0x8000 | hdu0 << 8, -1);
4329: } else if (scu0 >= 0) {
4330: mpuReset (0xa000, SPC.SPC_HANDLE_EX + (scu0 << 2));
4331: } else if (hfu0 >= 0) {
4332: HFS.hfsBootUnit = hfu0;
4333: mpuReset (0xa000, HFS.HFS_BOOT_HANDLE);
4334: }
4335: }
4336: return;
4337: }
4338: } catch (UnsupportedFlavorException ufe) {
4339:
4340: } catch (IOException ioe) {
4341:
4342: }
4343: dtde.rejectDrop();
4344: }
4345: });
4346:
4347: }
4348:
4349:
4350:
4351: public static void frmUpdateTitle () {
4352: frmFrame.setTitle ((currentAccelerator == ACCELERATOR_HYBRID ? "X68000 Hybrid" :
4353: currentModel.getName () +
4354: (currentAccelerator == ACCELERATOR_XELLENT30 ? " with Xellent30" :
4355: currentAccelerator == ACCELERATOR_060TURBO ? " with 060turbo" :
4356: currentAccelerator == ACCELERATOR_060TURBOPRO ? " with 060turboPRO" : "")) +
4357: " - " + PRG_TITLE + " version " + PRG_VERSION);
4358: }
4359:
4360:
4361:
4362: public static void frmStart () {
4363:
4364:
4365:
4366:
4367:
4368:
4369:
4370:
4371: ComponentFactory.addListener (
4372: frmFrame,
4373: new WindowAdapter () {
4374: @Override public void windowActivated (WindowEvent we) {
4375: frmIsActive = true;
4376: }
4377: @Override public void windowClosing (WindowEvent we) {
4378: prgTini ();
4379: }
4380: @Override public void windowDeactivated (WindowEvent we) {
4381: frmIsActive = false;
4382:
4383: }
4384: @Override public void windowOpened (WindowEvent we) {
4385: if (pnlAdjustVsync && pnlFixedRate == 0.0) {
4386: pnlFixedRate = pnlGetRefreshRate ();
4387: }
4388: }
4389: });
4390:
4391:
4392:
4393:
4394: ComponentFactory.addListener (
4395: frmFrame,
4396: new ComponentAdapter () {
4397: @Override public void componentMoved (ComponentEvent ce) {
4398: Point p = pnlPanel.getLocationOnScreen ();
4399: pnlGlobalX = p.x;
4400: pnlGlobalY = p.y;
4401: }
4402: @Override public void componentResized (ComponentEvent ce) {
4403: Point p = pnlPanel.getLocationOnScreen ();
4404: pnlGlobalX = p.x;
4405: pnlGlobalY = p.y;
4406: }
4407: });
4408:
4409: }
4410:
4411:
4412:
4413:
4414:
4415:
4416: public static BufferedImage clpClipboardImage;
4417: public static String clpClipboardString;
4418: public static Clipboard clpClipboard;
4419: public static Transferable clpImageContents;
4420: public static Transferable clpStringContents;
4421: public static ClipboardOwner clpClipboardOwner;
4422: public static boolean clpIsClipboardOwner;
4423:
4424:
4425:
4426:
4427: public static void clpMake () {
4428: Toolkit toolkit = Toolkit.getDefaultToolkit ();
4429: clpClipboard = null;
4430: try {
4431: clpClipboard = toolkit.getSystemClipboard ();
4432: } catch (Exception e) {
4433: return;
4434: }
4435: clpClipboardImage = null;
4436: clpClipboardString = null;
4437: clpImageContents = new Transferable () {
4438: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
4439: if (flavor == DataFlavor.imageFlavor) {
4440: return clpClipboardImage;
4441: } else {
4442: throw new UnsupportedFlavorException (flavor);
4443: }
4444: }
4445: public DataFlavor[] getTransferDataFlavors () {
4446: return new DataFlavor[] { DataFlavor.imageFlavor };
4447: }
4448: public boolean isDataFlavorSupported (DataFlavor flavor) {
4449: return flavor == DataFlavor.imageFlavor;
4450: }
4451: };
4452: clpStringContents = new Transferable () {
4453: public Object getTransferData (DataFlavor flavor) throws UnsupportedFlavorException {
4454: if (flavor == DataFlavor.stringFlavor) {
4455: return clpClipboardString;
4456: } else {
4457: throw new UnsupportedFlavorException (flavor);
4458: }
4459: }
4460: public DataFlavor[] getTransferDataFlavors () {
4461: return new DataFlavor[] { DataFlavor.stringFlavor };
4462: }
4463: public boolean isDataFlavorSupported (DataFlavor flavor) {
4464: return flavor == DataFlavor.stringFlavor;
4465: }
4466: };
4467: clpIsClipboardOwner = false;
4468:
4469:
4470: clpClipboardOwner = new ClipboardOwner () {
4471: @Override public void lostOwnership (Clipboard clipboard, Transferable contents) {
4472: clpIsClipboardOwner = false;
4473: }
4474: };
4475:
4476:
4477: clpClipboard.addFlavorListener (new FlavorListener () {
4478: @Override public void flavorsChanged (FlavorEvent fe) {
4479: boolean available = false;
4480: try {
4481: available = clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor);
4482: } catch (IllegalStateException ise) {
4483: }
4484: if (mnbPasteMenuItem != null) {
4485: mnbPasteMenuItem.setEnabled (available);
4486: }
4487: }
4488: });
4489: if (!clpClipboard.isDataFlavorAvailable (DataFlavor.stringFlavor)) {
4490: if (mnbPasteMenuItem != null) {
4491: mnbPasteMenuItem.setEnabled (false);
4492: }
4493: }
4494: }
4495:
4496:
4497:
4498: public static void clpCopy (String s) {
4499: if (clpClipboard != null && s != null) {
4500: clpClipboardString = s;
4501: try {
4502: clpClipboard.setContents (clpStringContents, clpClipboardOwner);
4503: clpIsClipboardOwner = true;
4504: } catch (Exception e) {
4505: return;
4506: }
4507: }
4508: }
4509:
4510:
4511:
4512:
4513:
4514:
4515:
4516:
4517:
4518:
4519:
4520:
4521:
4522:
4523:
4524:
4525:
4526:
4527:
4528:
4529:
4530:
4531:
4532: public static int xt3DIPSWRequest;
4533: public static int xt3DIPSW;
4534: public static int xt3PortAddress;
4535:
4536:
4537: public static int xt3MemorySizeRequest;
4538: public static int xt3MemorySize;
4539: public static boolean xt3MemoryEnabled;
4540: public static int xt3MemoryPosition;
4541: public static int xt3MemoryStart;
4542: public static final byte[] xt3MemoryArray = new byte[1 << 20];
4543: public static boolean xt3MemorySave;
4544:
4545:
4546: public static int xt3SavedPC;
4547: public static final int[] xt3SavedRn = new int[16];
4548:
4549:
4550: public static void xt3Init () {
4551:
4552:
4553: xt3DIPSWRequest = Math.max (0, Math.min (3, Settings.sgsGetInt ("xt3dipsw")));
4554: xt3DIPSW = xt3DIPSWRequest;
4555:
4556:
4557: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4558:
4559:
4560: int memoryKB = Settings.sgsGetInt ("xt3memorykb");
4561: if (!(memoryKB == 1 << 8 || memoryKB == 1 << 10)) {
4562: memoryKB = 1 << 8;
4563: }
4564: xt3MemorySizeRequest = memoryKB << 10;
4565: xt3MemorySize = xt3MemorySizeRequest;
4566:
4567:
4568: xt3MemoryEnabled = false;
4569:
4570:
4571: xt3MemoryPosition = 11 << 20;
4572:
4573:
4574: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4575:
4576:
4577:
4578: byte[] memoryArray = Settings.sgsGetData ("xt3memorydata");
4579: Arrays.fill (xt3MemoryArray,
4580: (byte) 0);
4581: if (memoryArray.length != 0) {
4582: System.arraycopy (memoryArray, 0,
4583: xt3MemoryArray, 0,
4584: Math.min (memoryArray.length, xt3MemoryArray.length));
4585: if (memoryArray.length < xt3MemoryArray.length) {
4586: Arrays.fill (xt3MemoryArray,
4587: memoryArray.length,
4588: xt3MemoryArray.length,
4589: (byte) 0);
4590: }
4591: }
4592:
4593:
4594: xt3MemorySave = Settings.sgsGetOnOff ("xt3memorysave");
4595:
4596:
4597: xt3SavedPC = 0;
4598:
4599: Arrays.fill (xt3SavedRn, 0);
4600:
4601: xt3Reset ();
4602: }
4603:
4604:
4605: public static void xt3Tini () {
4606:
4607:
4608: Settings.sgsPutInt ("xt3dipsw", xt3DIPSW);
4609:
4610:
4611: Settings.sgsPutInt ("xt3memorykb", xt3MemorySizeRequest >> 10);
4612:
4613:
4614: boolean zero = true;
4615: if (xt3MemorySave) {
4616: for (int i = 0; i < 1 << 20; i++) {
4617: if (xt3MemoryArray[i] != 0) {
4618: zero = false;
4619: break;
4620: }
4621: }
4622: }
4623: if (zero) {
4624: Settings.sgsCurrentMap.put ("xt3memorydata", "");
4625: } else {
4626: if (false) {
4627: Settings.sgsCurrentMap.put ("xt3memorydata",
4628: ByteArray.byaEncodeBase64 (ByteArray.byaEncodeGzip (xt3MemoryArray, 0, 1 << 20)));
4629: } else {
4630: Settings.sgsPutData ("xt3memorydata",
4631: Arrays.copyOf (xt3MemoryArray, 1 << 20));
4632: }
4633: }
4634:
4635: Settings.sgsPutOnOff ("xt3memorysave", xt3MemorySave);
4636:
4637: }
4638:
4639:
4640: public static void xt3Reset () {
4641:
4642:
4643: xt3PortAddress = 0x00ec0000 + (xt3DIPSW << 14);
4644:
4645:
4646: xt3MemorySize = xt3MemorySizeRequest;
4647:
4648:
4649: xt3MemoryEnabled = false;
4650:
4651:
4652: xt3MemoryPosition = 11 << 20;
4653:
4654:
4655: xt3MemoryStart = xt3MemoryPosition + (1 << 20) - xt3MemorySize;
4656:
4657:
4658: xt3SavedPC = 0;
4659: Arrays.fill (xt3SavedRn, 0);
4660:
4661: }
4662:
4663:
4664: public static int xt3PortRead () {
4665: return (currentIsSecond ? 4 : 0) | (xt3MemoryEnabled ? 2 : 0) | (xt3MemoryPosition == 11 << 20 ? 0 : 1);
4666: }
4667:
4668:
4669: public static void xt3PortWrite (int d) {
4670: boolean nextIsSecond = (d & 4) != 0;
4671: boolean memoryEnabled = (d & 2) != 0;
4672: int memoryPosition = (d & 1) == 0 ? 11 << 20 : 15 << 20;
4673:
4674: if (xt3MemoryEnabled != memoryEnabled ||
4675: xt3MemoryPosition != memoryPosition) {
4676: if (xt3MemoryEnabled) {
4677: if (xt3MemoryPosition == 11 << 20) {
4678: if (MainMemory.mmrMemorySizeCurrent < 12 << 20) {
4679: busSuper (MemoryMappedDevice.MMD_NUL, (12 << 20) - xt3MemorySize, 12 << 20);
4680: } else {
4681: busUser (MemoryMappedDevice.MMD_MMR, (12 << 20) - xt3MemorySize, 12 << 20);
4682: }
4683: } else {
4684: busSuper (MemoryMappedDevice.MMD_ROM, (16 << 20) - xt3MemorySize, 16 << 20);
4685: }
4686: }
4687: xt3MemoryEnabled = memoryEnabled;
4688: xt3MemoryPosition = memoryPosition;
4689: if (xt3MemoryEnabled) {
4690: if (xt3MemoryPosition == 11 << 20) {
4691: busUser (MemoryMappedDevice.MMD_XTM, (12 << 20) - xt3MemorySize, 12 << 20);
4692: } else {
4693: busUser (MemoryMappedDevice.MMD_XTM, (16 << 20) - xt3MemorySize, 16 << 20);
4694: }
4695: }
4696: }
4697:
4698: if (currentIsSecond != nextIsSecond) {
4699:
4700: if (nextIsSecond) {
4701:
4702:
4703: xt3SavedPC = regPC;
4704: System.arraycopy (regRn, 0, xt3SavedRn, 0, 16);
4705:
4706:
4707: if (mpuTask != null) {
4708: mpuClockLimit = 0L;
4709: System.out.println (Multilingual.mlnJapanese ?
4710: Model.MPU_NAMES[currentFirstMPU] + " を停止します" :
4711: Model.MPU_NAMES[currentFirstMPU] + " stops");
4712: mpuTask.cancel ();
4713: mpuTask = null;
4714: }
4715:
4716:
4717: tmrTimer.schedule (new TimerTask () {
4718: @Override public void run () {
4719:
4720:
4721: currentIsSecond = true;
4722: currentMPU = currentSecondMPU;
4723: mpuSetCurrentClock (specifiedSecondClock);
4724:
4725: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
4726: MC68EC030.m30DivZeroVFlag = false;
4727: }
4728:
4729: RegisterList.drpSetMPU ();
4730: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4731: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4732: MC68060.mmuReset ();
4733:
4734: mpuIgnoreAddressError = true;
4735: fpuBox = fpuMotherboardCoprocessor;
4736: fpuBox.epbReset ();
4737: fpuFPn = fpuBox.epbFPn;
4738: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
4739: mpuSetWait ();
4740:
4741: regSRT1 = regSRT0 = 0;
4742: regSRS = REG_SR_S;
4743: regSRM = 0;
4744: regSRI = REG_SR_I;
4745: regCCR = 0;
4746: Arrays.fill (regRn, 0);
4747:
4748: regRn[15] = MainMemory.mmrRls (0x00000000);
4749: regPC = MainMemory.mmrRls (0x00000004);
4750:
4751: mpuIMR = 0;
4752: mpuIRR = 0;
4753: if (MC68901.MFP_DELAYED_INTERRUPT) {
4754: mpuDIRR = 0;
4755: }
4756: mpuISR = 0;
4757:
4758: mpuStart ();
4759: }
4760: }, TMR_DELAY);
4761:
4762: } else {
4763:
4764:
4765: if (mpuTask != null) {
4766: mpuClockLimit = 0L;
4767: System.out.println (Multilingual.mlnJapanese ? "MC68EC030 を停止します" : "MC68EC030 stops");
4768: mpuTask.cancel ();
4769: mpuTask = null;
4770: }
4771:
4772:
4773: tmrTimer.schedule (new TimerTask () {
4774: @Override public void run () {
4775:
4776:
4777: currentIsSecond = false;
4778: currentMPU = currentFirstMPU;
4779: mpuSetCurrentClock (specifiedFirstClock);
4780:
4781: RegisterList.drpSetMPU ();
4782: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
4783: mpuPCR = 0x04300500 | MPU_060_REV << 8;
4784: MC68060.mmuReset ();
4785:
4786: mpuIgnoreAddressError = false;
4787: mpuCacheOn = false;
4788: mpuSetWait ();
4789:
4790: regSRT1 = regSRT0 = 0;
4791: regSRS = REG_SR_S;
4792: regSRM = 0;
4793: regSRI = REG_SR_I;
4794: regCCR = 0;
4795:
4796: regPC = xt3SavedPC;
4797: System.arraycopy (xt3SavedRn, 0, regRn, 0, 16);
4798:
4799: mpuIMR = 0;
4800: mpuIRR = 0;
4801: if (MC68901.MFP_DELAYED_INTERRUPT) {
4802: mpuDIRR = 0;
4803: }
4804: mpuISR = 0;
4805:
4806: mpuStart ();
4807: }
4808: }, TMR_DELAY);
4809:
4810: }
4811: }
4812: }
4813:
4814:
4815:
4816:
4817:
4818:
4819: public static JMenu mdlMenu;
4820:
4821: public static JRadioButtonMenuItem mdlShodaiMenuItem;
4822: public static JRadioButtonMenuItem mdlACEMenuItem;
4823: public static JRadioButtonMenuItem mdlEXPERTMenuItem;
4824: public static JRadioButtonMenuItem mdlPROMenuItem;
4825: public static JRadioButtonMenuItem mdlSUPERMenuItem;
4826: public static JRadioButtonMenuItem mdlXVIMenuItem;
4827: public static JRadioButtonMenuItem mdlXellent30MenuItem;
4828: public static JRadioButtonMenuItem mdlCompactMenuItem;
4829: public static JRadioButtonMenuItem mdlHybridMenuItem;
4830: public static JRadioButtonMenuItem mdl060turboPROMenuItem;
4831: public static JRadioButtonMenuItem mdlX68030MenuItem;
4832: public static JRadioButtonMenuItem mdl030CompactMenuItem;
4833: public static JRadioButtonMenuItem mdl060turboMenuItem;
4834: public static JCheckBoxMenuItem mdlMC68010MenuItem;
4835:
4836: public static JMenu coproFPUMenu;
4837:
4838:
4839: public static final int ACCELERATOR_HYBRID = 1;
4840: public static final int ACCELERATOR_XELLENT30 = 2;
4841: public static final int ACCELERATOR_060TURBO = 3;
4842: public static final int ACCELERATOR_060TURBOPRO = 4;
4843: public static final double MHZ_HYBRID_VALUE = 100.0 / 3.0;
4844: public static final String MHZ_HYBRID_STRING = "33.3";
4845: public static final double MHZ_060TURBO_VALUE = 50.0;
4846: public static final String MHZ_060TURBO_STRING = "50";
4847:
4848:
4849:
4850: public static Model specifiedModel;
4851: public static int specifiedAccelerator;
4852: public static boolean mpu010;
4853:
4854: public static boolean specifiedIsSecond;
4855: public static int specifiedFirstMPU;
4856: public static int specifiedSecondMPU;
4857: public static int specifiedMPU;
4858:
4859: public static double specifiedFirstClock;
4860: public static double specifiedSecondClock;
4861: public static double specifiedClock;
4862:
4863: public static int specifiedCopro0;
4864: public static int specifiedCopro1;
4865: public static int specifiedCopro2;
4866: public static int specifiedOnchipFPU;
4867:
4868:
4869:
4870: public static Model currentModel;
4871: public static int currentAccelerator;
4872:
4873: public static boolean currentIsSecond;
4874: public static int currentFirstMPU;
4875: public static int currentSecondMPU;
4876: public static int currentMPU;
4877:
4878:
4879: public static int currentCopro0;
4880: public static int currentCopro1;
4881: public static int currentCopro2;
4882: public static int currentOnchipFPU;
4883:
4884:
4885:
4886: public static void mdlInit () {
4887:
4888:
4889: specifiedModel = Model.COMPACT;
4890: specifiedAccelerator = ACCELERATOR_HYBRID;
4891: mpu010 = Settings.sgsGetOnOff ("mpu010");
4892: {
4893: String paramModel = Settings.sgsGetString ("model");
4894: switch (paramModel.toLowerCase ()) {
4895: case "":
4896: case "none":
4897: case "hybrid":
4898: specifiedModel = Model.COMPACT;
4899: specifiedAccelerator = ACCELERATOR_HYBRID;
4900: break;
4901: case "xellent30":
4902: specifiedModel = Model.XVI;
4903: specifiedAccelerator = ACCELERATOR_XELLENT30;
4904: break;
4905: case "060turbo":
4906: specifiedModel = Model.X68030;
4907: specifiedAccelerator = ACCELERATOR_060TURBO;
4908: break;
4909: case "060turbopro":
4910: specifiedModel = Model.PRO;
4911: specifiedAccelerator = ACCELERATOR_060TURBOPRO;
4912: break;
4913: default:
4914: Model model = Model.fromTypeOrSynonym (paramModel);
4915: if (model != null) {
4916: specifiedModel = model;
4917: specifiedAccelerator = 0;
4918: } else {
4919: System.out.println (Multilingual.mlnJapanese ?
4920: paramModel + " は不明な機種です" :
4921: paramModel + " is unknown model");
4922: specifiedModel = Model.COMPACT;
4923: specifiedAccelerator = ACCELERATOR_HYBRID;
4924: }
4925: }
4926: }
4927:
4928: specifiedIsSecond = false;
4929: specifiedFirstMPU = specifiedModel.getMPU ();
4930: specifiedSecondMPU = Model.MPU_MC68EC030;
4931: {
4932: String[] paramMPUs = Settings.sgsGetString ("mpu").split (",");
4933: for (int i = 0; i < 2; i++) {
4934: int mpu = 0;
4935: String paramMPU = i < paramMPUs.length ? paramMPUs[i] : "";
4936: switch (paramMPU) {
4937: case "":
4938: case "none":
4939: case "-1":
4940: mpu = (i == 0 ?
4941: (specifiedAccelerator == ACCELERATOR_060TURBO ||
4942: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
4943: specifiedModel.getMPU ()) :
4944: Model.MPU_MC68EC030);
4945: break;
4946: case "0":
4947: case "68000":
4948: case "mc68000":
4949: mpu = Model.MPU_MC68000;
4950: break;
4951: case "1":
4952: case "68010":
4953: case "mc68010":
4954: mpu = Model.MPU_MC68010;
4955: break;
4956:
4957:
4958:
4959:
4960:
4961: case "3":
4962: case "68ec030":
4963: case "mc68ec030":
4964: mpu = Model.MPU_MC68EC030;
4965: break;
4966:
4967:
4968:
4969:
4970:
4971:
4972:
4973:
4974:
4975:
4976:
4977:
4978:
4979:
4980:
4981:
4982:
4983: case "6":
4984: case "68060":
4985: case "mc68060":
4986: mpu = Model.MPU_MC68060;
4987: break;
4988: default:
4989: Model model = Model.fromTypeOrSynonym (paramMPU);
4990: if (model != null) {
4991: mpu = model.getMPU ();
4992: } else {
4993: System.out.println (Multilingual.mlnJapanese ?
4994: paramMPU + " は不明な MPU です" :
4995: paramMPU + " is unknown MPU");
4996: mpu = specifiedModel.getMPU ();
4997: }
4998: }
4999: if (i == 0) {
5000: specifiedFirstMPU = mpu;
5001: } else {
5002: specifiedSecondMPU = mpu;
5003: }
5004: }
5005: }
5006: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
5007:
5008: specifiedFirstClock = specifiedModel.getClock ();
5009: specifiedSecondClock = specifiedFirstClock * 2.0;
5010: {
5011: String[] paramClocks = Settings.sgsGetString ("clock").split (",");
5012: for (int i = 0; i < 2; i++) {
5013: double clock = 0.0;
5014: String paramClock = i < paramClocks.length ? paramClocks[i] : "";
5015: switch (paramClock.toLowerCase ()) {
5016: case "":
5017: case "none":
5018: case "-1":
5019: clock = (i == 0 ?
5020: (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
5021: specifiedAccelerator == ACCELERATOR_060TURBO ||
5022: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
5023: specifiedModel.getClock ()) :
5024: specifiedFirstClock * 2.0);
5025: break;
5026: case "hybrid":
5027: clock = MHZ_HYBRID_VALUE;
5028: break;
5029: case "060turbo":
5030: case "060turbopro":
5031: clock = MHZ_060TURBO_VALUE;
5032: break;
5033: case "16.7":
5034: case "xellent30":
5035: clock = 50.0 / 3.0;
5036: break;
5037: case "33.3":
5038: clock = 100.0 / 3.0;
5039: break;
5040: case "66.7":
5041: clock = 200.0 / 3.0;
5042: break;
5043: default:
5044: if (paramClock.matches ("^(?:" +
5045: "[-+]?" +
5046: "(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)" +
5047: "(?:[Ee][-+]?[0-9]+)?" +
5048: ")$")) {
5049: double d = Double.parseDouble (paramClock);
5050: if (1.0 <= d && d <= 1000.0) {
5051: clock = d;
5052: }
5053: } else {
5054: System.out.println (Multilingual.mlnJapanese ?
5055: paramClock + " は不明な動作周波数です" :
5056: paramClock + " is unknown clock frequency");
5057: clock = specifiedModel.getClock ();
5058: }
5059: }
5060: if (i == 0) {
5061: specifiedFirstClock = clock;
5062: } else {
5063: specifiedSecondClock = clock;
5064: }
5065: }
5066: }
5067: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5068:
5069: specifiedCopro0 = 15 & Settings.sgsGetInt ("copro0", 2);
5070: if (!((7 & specifiedCopro0) == 0 ||
5071: (7 & specifiedCopro0) == 1 ||
5072: (7 & specifiedCopro0) == 2 ||
5073: (7 & specifiedCopro0) == 7)) {
5074: specifiedCopro0 = (8 & specifiedCopro0) | 2;
5075: }
5076: specifiedCopro1 = 15 & Settings.sgsGetInt ("copro1", 2);
5077: if (!((7 & specifiedCopro1) == 0 ||
5078: (7 & specifiedCopro1) == 1 ||
5079: (7 & specifiedCopro1) == 2 ||
5080: (7 & specifiedCopro1) == 7)) {
5081: specifiedCopro1 = (8 & specifiedCopro1) | 2;
5082: }
5083: specifiedCopro2 = 15 & Settings.sgsGetInt ("copro2", 2);
5084: if (!((7 & specifiedCopro2) == 0 ||
5085: (7 & specifiedCopro2) == 1 ||
5086: (7 & specifiedCopro2) == 2 ||
5087: (7 & specifiedCopro2) == 7)) {
5088: specifiedCopro2 = (8 & specifiedCopro2) | 2;
5089: }
5090: specifiedOnchipFPU = 15 & Settings.sgsGetInt ("onchipfpu", 7);
5091: if (!((7 & specifiedOnchipFPU) == 0 ||
5092: (7 & specifiedOnchipFPU) == 6 ||
5093: (7 & specifiedOnchipFPU) == 7)) {
5094: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
5095: }
5096:
5097:
5098: currentModel = specifiedModel;
5099: currentAccelerator = specifiedAccelerator;
5100:
5101: currentIsSecond = specifiedIsSecond;
5102: currentFirstMPU = specifiedFirstMPU;
5103: currentSecondMPU = specifiedSecondMPU;
5104: currentMPU = specifiedMPU;
5105:
5106:
5107: currentCopro0 = specifiedCopro0;
5108: currentCopro1 = specifiedCopro1;
5109: currentCopro2 = specifiedCopro2;
5110: currentOnchipFPU = specifiedOnchipFPU;
5111:
5112:
5113: mpuUtilOn = Settings.sgsGetOnOff ("util");
5114: mpuUtilRatio = fmtParseInt (Settings.sgsGetString ("ratio"), 0, 1, 100, 100);
5115:
5116: mpuArbFreqMHz = fmtParseInt (Settings.sgsGetString ("mhz"), 0, 1, 1000, 100);
5117: if (mpuUtilOn) {
5118: mpuArbFreqOn = false;
5119: } else {
5120: mpuArbFreqOn = !(specifiedClock == 10.0 ||
5121: specifiedClock == 50.0 / 3.0 ||
5122: specifiedClock == 25.0 ||
5123: specifiedClock == 100.0 / 3.0 ||
5124: specifiedClock == 50.0 ||
5125: specifiedClock == 200.0 / 3.0 ||
5126: specifiedClock == 75.0 ||
5127: specifiedClock == 100.0);
5128: if (mpuArbFreqOn) {
5129: mpuArbFreqMHz = (int) specifiedClock;
5130: }
5131: }
5132:
5133:
5134: mpuROMWaitCycles = 0;
5135: mpuRAMWaitCycles = 0;
5136: mpuCacheOn = false;
5137:
5138: mpuNoWaitTime.ram = 0;
5139: mpuNoWaitTime.gvram = 0;
5140: mpuNoWaitTime.tvram = 0;
5141: mpuNoWaitTime.crtc = 0;
5142: mpuNoWaitTime.palet = 0;
5143: mpuNoWaitTime.vicon = 0;
5144: mpuNoWaitTime.dmac = 0;
5145: mpuNoWaitTime.mfp = 0;
5146: mpuNoWaitTime.rtc = 0;
5147: mpuNoWaitTime.prnport = 0;
5148: mpuNoWaitTime.sysport = 0;
5149: mpuNoWaitTime.opm = 0;
5150: mpuNoWaitTime.adpcm = 0;
5151: mpuNoWaitTime.fdc = 0;
5152: mpuNoWaitTime.fdd = 0;
5153: mpuNoWaitTime.hdc = 0;
5154: mpuNoWaitTime.scc = 0;
5155: mpuNoWaitTime.ppi = 0;
5156: mpuNoWaitTime.ioi = 0;
5157: mpuNoWaitTime.sprc = 0;
5158: mpuNoWaitTime.sram = 0;
5159: mpuNoWaitTime.rom = 0;
5160: mpuNoWaitTime.ramlong = mpuNoWaitTime.ram << 1;
5161: mpuNoWaitTime.romlong = mpuNoWaitTime.rom << 1;
5162:
5163: dmaNoWaitTime.ram = 0;
5164: dmaNoWaitTime.gvram = 0;
5165: dmaNoWaitTime.tvram = 0;
5166: dmaNoWaitTime.crtc = 0;
5167: dmaNoWaitTime.palet = 0;
5168: dmaNoWaitTime.vicon = 0;
5169: dmaNoWaitTime.dmac = 0;
5170: dmaNoWaitTime.mfp = 0;
5171: dmaNoWaitTime.rtc = 0;
5172: dmaNoWaitTime.prnport = 0;
5173: dmaNoWaitTime.sysport = 0;
5174: dmaNoWaitTime.opm = 0;
5175: dmaNoWaitTime.adpcm = 0;
5176: dmaNoWaitTime.fdc = 0;
5177: dmaNoWaitTime.fdd = 0;
5178: dmaNoWaitTime.hdc = 0;
5179: dmaNoWaitTime.scc = 0;
5180: dmaNoWaitTime.ppi = 0;
5181: dmaNoWaitTime.ioi = 0;
5182: dmaNoWaitTime.sprc = 0;
5183: dmaNoWaitTime.sram = 0;
5184: dmaNoWaitTime.rom = 0;
5185: dmaNoWaitTime.ramlong = dmaNoWaitTime.ram << 1;
5186: dmaNoWaitTime.romlong = dmaNoWaitTime.rom << 1;
5187:
5188:
5189: busWaitCyclesRequest = Settings.sgsGetOnOff ("waitcycles");
5190: busWaitCycles = busWaitCyclesRequest;
5191: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
5192:
5193: }
5194:
5195: public static void mdlTini () {
5196:
5197: Settings.sgsPutString ("model",
5198: specifiedAccelerator == ACCELERATOR_HYBRID ? "Hybrid" :
5199: specifiedAccelerator == ACCELERATOR_XELLENT30 ? "Xellent30" :
5200: specifiedAccelerator == ACCELERATOR_060TURBO ? "060turbo" :
5201: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? "060turboPRO" :
5202: specifiedModel.getSynonym () != null ? specifiedModel.getSynonym () :
5203: specifiedModel.getType ());
5204: Settings.sgsPutOnOff ("mpu010", mpu010);
5205:
5206:
5207: int defaultFirstMPU = (specifiedAccelerator == ACCELERATOR_060TURBO ||
5208: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? Model.MPU_MC68060 :
5209: specifiedModel.getMPU ());
5210: int defaultSecondMPU = Model.MPU_MC68EC030;
5211: Settings.sgsPutString ("mpu",
5212: (specifiedFirstMPU == defaultFirstMPU ? "" :
5213: Model.mpuNameOf (specifiedFirstMPU)) +
5214: (specifiedSecondMPU == defaultSecondMPU ? "" :
5215: "," + Model.mpuNameOf (specifiedSecondMPU)));
5216:
5217:
5218:
5219:
5220: double defaultFirstClock = (specifiedAccelerator == ACCELERATOR_HYBRID ? MHZ_HYBRID_VALUE :
5221: specifiedAccelerator == ACCELERATOR_060TURBO ||
5222: specifiedAccelerator == ACCELERATOR_060TURBOPRO ? MHZ_060TURBO_VALUE :
5223: specifiedModel.getClock ());
5224: double defaultSecondClock = defaultFirstClock * 2.0;
5225: Settings.sgsPutString ("clock",
5226: (specifiedFirstClock == defaultFirstClock ? "" :
5227: specifiedFirstClock == 50.0 / 3.0 ? "16.7" :
5228: specifiedFirstClock == 100.0 / 3.0 ? "33.3" :
5229: specifiedFirstClock == 200.0 / 3.0 ? "66.7" :
5230: String.valueOf ((int) specifiedFirstClock)) +
5231: (specifiedSecondClock == defaultSecondClock ? "" :
5232: "," + (specifiedSecondClock == 50.0 / 3.0 ? "16.7" :
5233: specifiedSecondClock == 100.0 / 3.0 ? "33.3" :
5234: specifiedSecondClock == 200.0 / 3.0 ? "66.7" :
5235: String.valueOf ((int) specifiedSecondClock))));
5236:
5237: Settings.sgsPutInt ("copro0", specifiedCopro0);
5238: Settings.sgsPutInt ("copro1", specifiedCopro1);
5239: Settings.sgsPutInt ("copro2", specifiedCopro2);
5240: Settings.sgsPutInt ("onchipfpu", specifiedOnchipFPU);
5241:
5242: Settings.sgsPutOnOff ("util",
5243: mpuUtilOn);
5244: Settings.sgsPutString ("ratio",
5245: String.valueOf (mpuUtilRatio));
5246:
5247: Settings.sgsPutString ("mhz",
5248: String.valueOf (mpuArbFreqMHz));
5249:
5250: Settings.sgsPutOnOff ("waitcycles", busWaitCyclesRequest);
5251: }
5252:
5253: public static void mdlMakeMenu () {
5254:
5255:
5256: ActionListener listener = new ActionListener () {
5257: @Override public void actionPerformed (ActionEvent ae) {
5258: Object source = ae.getSource ();
5259: switch (ae.getActionCommand ()) {
5260: case "X68000 (10MHz)":
5261: mdlRequestModel (Model.SHODAI, 0);
5262: mpuReset (-1, -1);
5263: break;
5264: case "X68000 ACE (10MHz)":
5265: mdlRequestModel (Model.ACE, 0);
5266: mpuReset (-1, -1);
5267: break;
5268: case "X68000 EXPERT (10MHz)":
5269: mdlRequestModel (Model.EXPERT, 0);
5270: mpuReset (-1, -1);
5271: break;
5272: case "X68000 PRO (10MHz)":
5273: mdlRequestModel (Model.PRO, 0);
5274: mpuReset (-1, -1);
5275: break;
5276: case "X68000 SUPER (10MHz)":
5277: mdlRequestModel (Model.SUPER, 0);
5278: mpuReset (-1, -1);
5279: break;
5280: case "X68000 XVI (16.7MHz)":
5281: mdlRequestModel (Model.XVI, 0);
5282: mpuReset (-1, -1);
5283: break;
5284: case "X68000 Compact (16.7MHz)":
5285: mdlRequestModel (Model.COMPACT, 0);
5286: mpuReset (-1, -1);
5287: break;
5288:
5289: case "X68030 (25MHz)":
5290: mdlRequestModel (Model.X68030, 0);
5291: mpuReset (-1, -1);
5292: break;
5293: case "X68030 Compact (25MHz)":
5294: mdlRequestModel (Model.X68030COMPACT, 0);
5295: mpuReset (-1, -1);
5296: break;
5297:
5298: case "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)":
5299: mdlRequestModel (Model.COMPACT, ACCELERATOR_HYBRID);
5300: mpuReset (-1, -1);
5301: break;
5302: case "Xellent30 (33.3MHz)":
5303: mdlRequestModel (Model.XVI, ACCELERATOR_XELLENT30);
5304: mpuReset (-1, -1);
5305: break;
5306: case "060turbo (" + MHZ_060TURBO_STRING + "MHz)":
5307: mdlRequestModel (Model.X68030, ACCELERATOR_060TURBO);
5308: mpuReset (-1, -1);
5309: break;
5310: case "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)":
5311: mdlRequestModel (Model.PRO, ACCELERATOR_060TURBOPRO);
5312: mpuReset (-1, -1);
5313: break;
5314:
5315: case "MC68010":
5316: mpu010 = ((JCheckBoxMenuItem) source).isSelected ();
5317: break;
5318:
5319: }
5320: }
5321: };
5322:
5323:
5324: ButtonGroup modelGroup = new ButtonGroup ();
5325: mdlMenu = Multilingual.mlnText (
5326: ComponentFactory.createMenu (
5327: "Change the model and reset",
5328: mdlShodaiMenuItem = ComponentFactory.createRadioButtonMenuItem (
5329: modelGroup,
5330: specifiedModel == Model.SHODAI,
5331: "X68000 (10MHz)",
5332: listener),
5333: mdlACEMenuItem = ComponentFactory.createRadioButtonMenuItem (
5334: modelGroup,
5335: specifiedModel == Model.ACE,
5336: "X68000 ACE (10MHz)",
5337: listener),
5338: mdlEXPERTMenuItem = ComponentFactory.createRadioButtonMenuItem (
5339: modelGroup,
5340: specifiedModel == Model.EXPERT,
5341: "X68000 EXPERT (10MHz)",
5342: listener),
5343: mdlPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
5344: modelGroup,
5345: specifiedModel == Model.PRO && specifiedAccelerator == 0,
5346: "X68000 PRO (10MHz)",
5347: listener),
5348: mdlSUPERMenuItem = ComponentFactory.createRadioButtonMenuItem (
5349: modelGroup,
5350: specifiedModel == Model.SUPER,
5351: "X68000 SUPER (10MHz)",
5352: listener),
5353: mdlXVIMenuItem = ComponentFactory.createRadioButtonMenuItem (
5354: modelGroup,
5355: specifiedModel == Model.XVI && specifiedAccelerator == 0,
5356: "X68000 XVI (16.7MHz)",
5357: listener),
5358: mdlCompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
5359: modelGroup,
5360: specifiedModel == Model.COMPACT && specifiedAccelerator == 0,
5361: "X68000 Compact (16.7MHz)",
5362: listener),
5363:
5364: ComponentFactory.createHorizontalSeparator (),
5365:
5366: mdlX68030MenuItem = ComponentFactory.createRadioButtonMenuItem (
5367: modelGroup,
5368: specifiedModel == Model.X68030 && specifiedAccelerator == 0,
5369: "X68030 (25MHz)",
5370: listener),
5371: mdl030CompactMenuItem = ComponentFactory.createRadioButtonMenuItem (
5372: modelGroup,
5373: specifiedModel == Model.X68030COMPACT,
5374: "X68030 Compact (25MHz)",
5375: listener),
5376:
5377: ComponentFactory.createHorizontalSeparator (),
5378:
5379: mdlHybridMenuItem = ComponentFactory.createRadioButtonMenuItem (
5380: modelGroup,
5381: specifiedModel == Model.COMPACT && specifiedAccelerator == ACCELERATOR_HYBRID,
5382: "X68000 Hybrid (" + MHZ_HYBRID_STRING + "MHz)",
5383: listener),
5384: mdlXellent30MenuItem = ComponentFactory.createRadioButtonMenuItem (
5385: modelGroup,
5386: specifiedModel == Model.XVI && specifiedAccelerator == ACCELERATOR_XELLENT30,
5387: "Xellent30 (33.3MHz)",
5388: listener),
5389: mdl060turboMenuItem = ComponentFactory.createRadioButtonMenuItem (
5390: modelGroup,
5391: specifiedModel == Model.X68030 && specifiedAccelerator == ACCELERATOR_060TURBO,
5392: "060turbo (" + MHZ_060TURBO_STRING + "MHz)",
5393: listener),
5394: mdl060turboPROMenuItem = ComponentFactory.createRadioButtonMenuItem (
5395: modelGroup,
5396: specifiedModel == Model.PRO && specifiedAccelerator == ACCELERATOR_060TURBOPRO,
5397: "060turboPRO (" + MHZ_060TURBO_STRING + "MHz)",
5398: listener),
5399:
5400: ComponentFactory.createHorizontalSeparator (),
5401:
5402: mdlMC68010MenuItem = ComponentFactory.createCheckBoxMenuItem (
5403: mpu010,
5404: "MC68010",
5405: listener)
5406: ),
5407: "ja", "機種を変更してリセット");
5408:
5409:
5410: ActionListener copro0Listener = new ActionListener () {
5411: @Override public void actionPerformed (ActionEvent ae) {
5412: String command = ae.getActionCommand ();
5413: switch (command) {
5414: case "Not installed":
5415: specifiedCopro0 = (8 & specifiedCopro0) | 0;
5416: break;
5417: case "MC68881":
5418: specifiedCopro0 = (8 & specifiedCopro0) | 1;
5419: break;
5420: case "MC68882":
5421: specifiedCopro0 = (8 & specifiedCopro0) | 2;
5422: break;
5423: case "Full specification":
5424: specifiedCopro0 = (8 & specifiedCopro0) | 7;
5425: break;
5426: case "Extended precision (19 digits)":
5427: specifiedCopro0 = 0 | (7 & specifiedCopro0);
5428: break;
5429: case "Triple precision (24 digits)":
5430: specifiedCopro0 = 8 | (7 & specifiedCopro0);
5431: break;
5432: default:
5433: System.out.println ("unknown action command " + command);
5434: }
5435: }
5436: };
5437:
5438: ActionListener copro1Listener = new ActionListener () {
5439: @Override public void actionPerformed (ActionEvent ae) {
5440: String command = ae.getActionCommand ();
5441: switch (command) {
5442: case "Not installed":
5443: specifiedCopro1 = (8 & specifiedCopro1) | 0;
5444: break;
5445: case "MC68881":
5446: specifiedCopro1 = (8 & specifiedCopro1) | 1;
5447: break;
5448: case "MC68882":
5449: specifiedCopro1 = (8 & specifiedCopro1) | 2;
5450: break;
5451: case "Full specification":
5452: specifiedCopro1 = (8 & specifiedCopro1) | 7;
5453: break;
5454: case "Extended precision (19 digits)":
5455: specifiedCopro1 = 0 | (7 & specifiedCopro1);
5456: break;
5457: case "Triple precision (24 digits)":
5458: specifiedCopro1 = 8 | (7 & specifiedCopro1);
5459: break;
5460: default:
5461: System.out.println ("unknown action command " + command);
5462: }
5463: }
5464: };
5465:
5466: ActionListener copro2Listener = new ActionListener () {
5467: @Override public void actionPerformed (ActionEvent ae) {
5468: String command = ae.getActionCommand ();
5469: switch (command) {
5470: case "Not installed":
5471: specifiedCopro2 = (8 & specifiedCopro2) | 0;
5472: break;
5473: case "MC68881":
5474: specifiedCopro2 = (8 & specifiedCopro2) | 1;
5475: break;
5476: case "MC68882":
5477: specifiedCopro2 = (8 & specifiedCopro2) | 2;
5478: break;
5479: case "Full specification":
5480: specifiedCopro2 = (8 & specifiedCopro2) | 7;
5481: break;
5482: case "Extended precision (19 digits)":
5483: specifiedCopro2 = 0 | (7 & specifiedCopro2);
5484: break;
5485: case "Triple precision (24 digits)":
5486: specifiedCopro2 = 8 | (7 & specifiedCopro2);
5487: break;
5488: default:
5489: System.out.println ("unknown action command " + command);
5490: }
5491: }
5492: };
5493:
5494: ActionListener onchipFPUListener = new ActionListener () {
5495: @Override public void actionPerformed (ActionEvent ae) {
5496: String command = ae.getActionCommand ();
5497: switch (command) {
5498: case "Not installed":
5499: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 0;
5500: break;
5501: case "MC68060":
5502: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 6;
5503: break;
5504: case "Full specification":
5505: specifiedOnchipFPU = (8 & specifiedOnchipFPU) | 7;
5506: break;
5507: case "Extended precision (19 digits)":
5508: specifiedOnchipFPU = 0 | (7 & specifiedOnchipFPU);
5509: break;
5510: case "Triple precision (24 digits)":
5511: specifiedOnchipFPU = 8 | (7 & specifiedOnchipFPU);
5512: break;
5513: default:
5514: System.out.println ("unknown action command " + command);
5515: }
5516: }
5517: };
5518:
5519: ButtonGroup copro00Group = new ButtonGroup ();
5520: ButtonGroup copro01Group = new ButtonGroup ();
5521: ButtonGroup copro10Group = new ButtonGroup ();
5522: ButtonGroup copro11Group = new ButtonGroup ();
5523: ButtonGroup copro20Group = new ButtonGroup ();
5524: ButtonGroup copro21Group = new ButtonGroup ();
5525: ButtonGroup onchipFPU0Group = new ButtonGroup ();
5526: ButtonGroup onchipFPU1Group = new ButtonGroup ();
5527:
5528: coproFPUMenu = Multilingual.mlnText (
5529: ComponentFactory.createMenu (
5530: "Coprocessor and on-chip FPU",
5531:
5532: Multilingual.mlnText (
5533: ComponentFactory.createMenu (
5534: "Motherboard coprocessor",
5535: Multilingual.mlnText (
5536: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 0, "Not installed", copro0Listener),
5537: "ja", "なし"),
5538: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 1, "MC68881", copro0Listener),
5539: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 2, "MC68882", copro0Listener),
5540: Multilingual.mlnText (
5541: ComponentFactory.createRadioButtonMenuItem (copro00Group, (7 & specifiedCopro0) == 7, "Full specification", copro0Listener),
5542: "ja", "フルスペック"),
5543: ComponentFactory.createHorizontalSeparator (),
5544: Multilingual.mlnText (
5545: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) == 0, "Extended precision (19 digits)", copro0Listener),
5546: "ja", "拡張精度 (19 桁)"),
5547: Multilingual.mlnText (
5548: ComponentFactory.createRadioButtonMenuItem (copro01Group, (8 & specifiedCopro0) != 0, "Triple precision (24 digits)", copro0Listener),
5549: "ja", "三倍精度 (24 桁)")),
5550: "ja", "マザーボードコプロセッサ"),
5551:
5552: Multilingual.mlnText (
5553: ComponentFactory.createMenu (
5554: "Extension coprocessor #1",
5555: Multilingual.mlnText (
5556: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 0, "Not installed", copro1Listener),
5557: "ja", "なし"),
5558: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 1, "MC68881", copro1Listener),
5559: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 2, "MC68882", copro1Listener),
5560: Multilingual.mlnText (
5561: ComponentFactory.createRadioButtonMenuItem (copro10Group, (7 & specifiedCopro1) == 7, "Full specification", copro1Listener),
5562: "ja", "フルスペック"),
5563: ComponentFactory.createHorizontalSeparator (),
5564: Multilingual.mlnText (
5565: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) == 0, "Extended precision (19 digits)", copro1Listener),
5566: "ja", "拡張精度 (19 桁)"),
5567: Multilingual.mlnText (
5568: ComponentFactory.createRadioButtonMenuItem (copro11Group, (8 & specifiedCopro1) != 0, "Triple precision (24 digits)", copro1Listener),
5569: "ja", "三倍精度 (24 桁)")),
5570: "ja", "拡張コプロセッサ #1"),
5571:
5572: Multilingual.mlnText (
5573: ComponentFactory.createMenu (
5574: "Extension coprocessor #2",
5575: Multilingual.mlnText (
5576: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 0, "Not installed", copro2Listener),
5577: "ja", "なし"),
5578: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 1, "MC68881", copro2Listener),
5579: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 2, "MC68882", copro2Listener),
5580: Multilingual.mlnText (
5581: ComponentFactory.createRadioButtonMenuItem (copro20Group, (7 & specifiedCopro2) == 7, "Full specification", copro2Listener),
5582: "ja", "フルスペック"),
5583: ComponentFactory.createHorizontalSeparator (),
5584: Multilingual.mlnText (
5585: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) == 0, "Extended precision (19 digits)", copro2Listener),
5586: "ja", "拡張精度 (19 桁)"),
5587: Multilingual.mlnText (
5588: ComponentFactory.createRadioButtonMenuItem (copro21Group, (8 & specifiedCopro2) != 0, "Triple precision (24 digits)", copro2Listener),
5589: "ja", "三倍精度 (24 桁)")),
5590: "ja", "拡張コプロセッサ #2"),
5591:
5592: Multilingual.mlnText (
5593: ComponentFactory.createMenu (
5594: "On-chip FPU",
5595: Multilingual.mlnText (
5596: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 0, "Not installed", onchipFPUListener),
5597: "ja", "なし"),
5598: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 6, "MC68060", onchipFPUListener),
5599: Multilingual.mlnText (
5600: ComponentFactory.createRadioButtonMenuItem (onchipFPU0Group, (7 & specifiedOnchipFPU) == 7, "Full specification", onchipFPUListener),
5601: "ja", "フルスペック"),
5602: ComponentFactory.createHorizontalSeparator (),
5603: Multilingual.mlnText (
5604: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) == 0, "Extended precision (19 digits)", onchipFPUListener),
5605: "ja", "拡張精度 (19 桁)"),
5606: Multilingual.mlnText (
5607: ComponentFactory.createRadioButtonMenuItem (onchipFPU1Group, (8 & specifiedOnchipFPU) != 0, "Triple precision (24 digits)", onchipFPUListener),
5608: "ja", "三倍精度 (24 桁)")),
5609: "ja", "オンチップ FPU")),
5610: "ja", "コプロセッサとオンチップ FPU");
5611:
5612: }
5613:
5614: public static void mdlRequestModel (Model model, int accelerator) {
5615: specifiedModel = model;
5616: specifiedAccelerator = accelerator;
5617:
5618: specifiedIsSecond = false;
5619: specifiedFirstMPU = specifiedModel.getMPU ();
5620: specifiedSecondMPU = Model.MPU_MC68EC030;
5621: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
5622: specifiedFirstClock = specifiedModel.getClock ();
5623: specifiedSecondClock = specifiedFirstClock * 2.0;
5624: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5625:
5626: switch (accelerator) {
5627: case ACCELERATOR_HYBRID:
5628: specifiedFirstClock = MHZ_HYBRID_VALUE;
5629: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5630: break;
5631: case ACCELERATOR_XELLENT30:
5632: break;
5633: case ACCELERATOR_060TURBO:
5634: case ACCELERATOR_060TURBOPRO:
5635: specifiedFirstMPU = Model.MPU_MC68060;
5636: specifiedFirstClock = MHZ_060TURBO_VALUE;
5637: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
5638: }
5639:
5640: mpuUtilOn = false;
5641: mpuArbFreqOn = false;
5642: mpuSetCurrentClock (specifiedClock);
5643:
5644: if (accelerator == ACCELERATOR_HYBRID) {
5645: mdlHybridMenuItem.setSelected (true);
5646: } else if (accelerator == ACCELERATOR_XELLENT30) {
5647: mdlXellent30MenuItem.setSelected (true);
5648: } else if (accelerator == ACCELERATOR_060TURBO) {
5649: mdl060turboMenuItem.setSelected (true);
5650: } else if (accelerator == ACCELERATOR_060TURBOPRO) {
5651: mdl060turboPROMenuItem.setSelected (true);
5652: } else if (specifiedModel == Model.SHODAI) {
5653: mdlShodaiMenuItem.setSelected (true);
5654: } else if (specifiedModel == Model.ACE) {
5655: mdlACEMenuItem.setSelected (true);
5656: } else if (specifiedModel == Model.EXPERT) {
5657: mdlEXPERTMenuItem.setSelected (true);
5658: } else if (specifiedModel == Model.PRO) {
5659: mdlPROMenuItem.setSelected (true);
5660: } else if (specifiedModel == Model.SUPER) {
5661: mdlSUPERMenuItem.setSelected (true);
5662: } else if (specifiedModel == Model.XVI) {
5663: mdlXVIMenuItem.setSelected (true);
5664: } else if (specifiedModel == Model.COMPACT) {
5665: mdlCompactMenuItem.setSelected (true);
5666: } else if (specifiedModel == Model.X68030) {
5667: mdlX68030MenuItem.setSelected (true);
5668: } else if (specifiedModel == Model.X68030COMPACT) {
5669: mdl030CompactMenuItem.setSelected (true);
5670: }
5671:
5672:
5673: HDC.hdcSASIMenuItem.setSelected (!currentModel.isSCSI ());
5674: SPC.spcSCSIINMenuItem.setSelected (currentModel.isSCSI ());
5675: }
5676:
5677:
5678:
5679:
5680:
5681:
5682:
5683: public static final boolean MPU_INLINE_EXCEPTION = true;
5684: public static final boolean MPU_COMPOUND_POSTINCREMENT = false;
5685:
5686: public static final boolean MPU_SWITCH_MISC_OPCODE = false;
5687: public static final boolean MPU_SWITCH_BCC_CONDITION = false;
5688: public static final boolean MPU_SWITCH_BCC_OFFSET = false;
5689: public static final boolean MPU_SWITCH_SCC_CONDITION = true;
5690:
5691: public static final boolean MPU_OMIT_EXTRA_READ = false;
5692: public static final boolean MPU_OMIT_OFFSET_READ = false;
5693:
5694:
5695:
5696:
5697: public static final long FAR_FUTURE = 0x7fffffffffffffffL;
5698:
5699:
5700:
5701:
5702:
5703:
5704:
5705:
5706: public static final int REG_SR_T1 = 0b10000000_00000000;
5707: public static final int REG_SR_T0 = 0b01000000_00000000;
5708:
5709:
5710:
5711:
5712:
5713:
5714: public static final int REG_SR_S = 0b00100000_00000000;
5715: public static final int REG_SR_M = 0b00010000_00000000;
5716:
5717: public static final int REG_SR_I = 0b00000111_00000000;
5718:
5719:
5720: public static final int REG_CCR_X = 0b00000000_00010000;
5721: public static final int REG_CCR_N = 0b00000000_00001000;
5722: public static final int REG_CCR_Z = 0b00000000_00000100;
5723: public static final int REG_CCR_V = 0b00000000_00000010;
5724: public static final int REG_CCR_C = 0b00000000_00000001;
5725: public static final int REG_CCR_MASK = REG_CCR_X | REG_CCR_N | REG_CCR_Z | REG_CCR_V | REG_CCR_C;
5726:
5727: public static char[] REG_CCRXMAP = "00000000000000001111111111111111".toCharArray ();
5728: public static char[] REG_CCRNMAP = "00000000111111110000000011111111".toCharArray ();
5729: public static char[] REG_CCRZMAP = "00001111000011110000111100001111".toCharArray ();
5730: public static char[] REG_CCRVMAP = "00110011001100110011001100110011".toCharArray ();
5731: public static char[] REG_CCRCMAP = "01010101010101010101010101010101".toCharArray ();
5732:
5733:
5734:
5735: public static final int MPU_IOI_INTERRUPT_LEVEL = 1;
5736: public static final int MPU_EB2_INTERRUPT_LEVEL = 2;
5737: public static final int MPU_DMA_INTERRUPT_LEVEL = 3;
5738: public static final int MPU_SCC_INTERRUPT_LEVEL = 5;
5739: public static final int MPU_MFP_INTERRUPT_LEVEL = 6;
5740: public static final int MPU_SYS_INTERRUPT_LEVEL = 7;
5741: public static final int MPU_IOI_INTERRUPT_MASK = 0x80 >> MPU_IOI_INTERRUPT_LEVEL;
5742: public static final int MPU_EB2_INTERRUPT_MASK = 0x80 >> MPU_EB2_INTERRUPT_LEVEL;
5743: public static final int MPU_DMA_INTERRUPT_MASK = 0x80 >> MPU_DMA_INTERRUPT_LEVEL;
5744: public static final int MPU_SCC_INTERRUPT_MASK = 0x80 >> MPU_SCC_INTERRUPT_LEVEL;
5745: public static final int MPU_MFP_INTERRUPT_MASK = 0x80 >> MPU_MFP_INTERRUPT_LEVEL;
5746: public static final int MPU_SYS_INTERRUPT_MASK = 0x80 >> MPU_SYS_INTERRUPT_LEVEL;
5747:
5748: public static final boolean MPU_INTERRUPT_SWITCH = true;
5749:
5750:
5751: public static final boolean T = true;
5752: public static final boolean F = false;
5753:
5754: public static final int CCCC_T = 0b0000;
5755: public static final int CCCC_F = 0b0001;
5756: public static final int CCCC_HI = 0b0010;
5757: public static final int CCCC_LS = 0b0011;
5758: public static final int CCCC_CC = 0b0100;
5759: public static final int CCCC_CS = 0b0101;
5760: public static final int CCCC_NE = 0b0110;
5761: public static final int CCCC_EQ = 0b0111;
5762: public static final int CCCC_VC = 0b1000;
5763: public static final int CCCC_VS = 0b1001;
5764: public static final int CCCC_PL = 0b1010;
5765: public static final int CCCC_MI = 0b1011;
5766: public static final int CCCC_GE = 0b1100;
5767: public static final int CCCC_LT = 0b1101;
5768: public static final int CCCC_GT = 0b1110;
5769: public static final int CCCC_LE = 0b1111;
5770:
5771:
5772:
5773:
5774:
5775:
5776: public static final boolean[] BCCMAP = {
5777: 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,
5778: 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,
5779: 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,
5780: 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,
5781: 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,
5782: 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,
5783: 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,
5784: 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,
5785: 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,
5786: 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,
5787: 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,
5788: 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,
5789: 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,
5790: 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,
5791: 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,
5792: 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,
5793: };
5794:
5795:
5796: public static final char[] MPU_CCCMAP = (
5797: "11111111111111111111111111111111" +
5798: "00000000000000000000000000000000" +
5799: "10100000101000001010000010100000" +
5800: "01011111010111110101111101011111" +
5801: "10101010101010101010101010101010" +
5802: "01010101010101010101010101010101" +
5803: "11110000111100001111000011110000" +
5804: "00001111000011110000111100001111" +
5805: "11001100110011001100110011001100" +
5806: "00110011001100110011001100110011" +
5807: "11111111000000001111111100000000" +
5808: "00000000111111110000000011111111" +
5809: "11001100001100111100110000110011" +
5810: "00110011110011000011001111001100" +
5811: "11000000001100001100000000110000" +
5812: "00111111110011110011111111001111").toCharArray ();
5813:
5814:
5815:
5816: public static final int MPU_CC_T = 0b11111111111111111111111111111111;
5817: public static final int MPU_CC_F = 0b00000000000000000000000000000000;
5818: public static final int MPU_CC_HI = 0b10100000101000001010000010100000;
5819: public static final int MPU_CC_LS = 0b01011111010111110101111101011111;
5820: public static final int MPU_CC_HS = 0b10101010101010101010101010101010;
5821: public static final int MPU_CC_LO = 0b01010101010101010101010101010101;
5822: public static final int MPU_CC_NE = 0b11110000111100001111000011110000;
5823: public static final int MPU_CC_EQ = 0b00001111000011110000111100001111;
5824: public static final int MPU_CC_VC = 0b11001100110011001100110011001100;
5825: public static final int MPU_CC_VS = 0b00110011001100110011001100110011;
5826: public static final int MPU_CC_PL = 0b11111111000000001111111100000000;
5827: public static final int MPU_CC_MI = 0b00000000111111110000000011111111;
5828: public static final int MPU_CC_GE = 0b11001100001100111100110000110011;
5829: public static final int MPU_CC_LT = 0b00110011110011000011001111001100;
5830: public static final int MPU_CC_GT = 0b11000000001100001100000000110000;
5831: public static final int MPU_CC_LE = 0b00111111110011110011111111001111;
5832:
5833:
5834:
5835:
5836:
5837:
5838:
5839:
5840:
5841:
5842:
5843:
5844:
5845:
5846:
5847:
5848:
5849:
5850:
5851:
5852:
5853:
5854:
5855:
5856:
5857:
5858:
5859:
5860:
5861:
5862:
5863:
5864:
5865:
5866:
5867:
5868:
5869:
5870:
5871:
5872:
5873:
5874:
5875:
5876:
5877:
5878:
5879:
5880:
5881: 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);
5882:
5883:
5884:
5885: public static final int[] MPU_BITREV_TABLE_0 = new int[2048];
5886: public static final int[] MPU_BITREV_TABLE_1 = new int[2048];
5887: public static final int[] MPU_BITREV_TABLE_2 = new int[2048];
5888: static {
5889: for (int i = 0; i < 2048; i++) {
5890: MPU_BITREV_TABLE_2[i] = (MPU_BITREV_TABLE_1[i] = (MPU_BITREV_TABLE_0[i] = Integer.reverse (i)) >>> 11) >>> 11;
5891: }
5892: }
5893:
5894:
5895:
5896: public static final int EA_DR = 0b000_000;
5897: public static final int EA_AR = 0b001_000;
5898: public static final int EA_MM = 0b010_000;
5899: public static final int EA_MP = 0b011_000;
5900: public static final int EA_MN = 0b100_000;
5901: public static final int EA_MW = 0b101_000;
5902: public static final int EA_MX = 0b110_000;
5903: public static final int EA_ZW = 0b111_000;
5904: public static final int EA_ZL = 0b111_001;
5905: public static final int EA_PW = 0b111_010;
5906: public static final int EA_PX = 0b111_011;
5907: public static final int EA_IM = 0b111_100;
5908: public static final int MMM_DR = EA_DR >> 3;
5909: public static final int MMM_AR = EA_AR >> 3;
5910: public static final int MMM_MM = EA_MM >> 3;
5911: public static final int MMM_MP = EA_MP >> 3;
5912: public static final int MMM_MN = EA_MN >> 3;
5913: public static final int MMM_MW = EA_MW >> 3;
5914: public static final int MMM_MX = EA_MX >> 3;
5915: public static final long EAM_DR = 0xff00000000000000L >>> EA_DR;
5916: public static final long EAM_AR = 0xff00000000000000L >>> EA_AR;
5917: public static final long EAM_MM = 0xff00000000000000L >>> EA_MM;
5918: public static final long EAM_MP = 0xff00000000000000L >>> EA_MP;
5919: public static final long EAM_MN = 0xff00000000000000L >>> EA_MN;
5920: public static final long EAM_MW = 0xff00000000000000L >>> EA_MW;
5921: public static final long EAM_MX = 0xff00000000000000L >>> EA_MX;
5922: public static final long EAM_ZW = 0x8000000000000000L >>> EA_ZW;
5923: public static final long EAM_ZL = 0x8000000000000000L >>> EA_ZL;
5924: public static final long EAM_PW = 0x8000000000000000L >>> EA_PW;
5925: public static final long EAM_PX = 0x8000000000000000L >>> EA_PX;
5926: public static final long EAM_IM = 0x8000000000000000L >>> EA_IM;
5927: 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;
5928: public static final long EAM_ALT = EAM_DR|EAM_AR|EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5929: 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;
5930: 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 ;
5931: public static final long EAM_DLT = EAM_DR |EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5932: public static final long EAM_DCN = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5933: public static final long EAM_DCL = EAM_DR |EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5934: 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;
5935: public static final long EAM_MEM = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5936: public static final long EAM_MLT = EAM_MM|EAM_MP|EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5937: public static final long EAM_RDL = EAM_MM|EAM_MP |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5938: public static final long EAM_WTL = EAM_MM |EAM_MN|EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5939: public static final long EAM_CNT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL|EAM_PW|EAM_PX ;
5940: public static final long EAM_CLT = EAM_MM |EAM_MW|EAM_MX|EAM_ZW|EAM_ZL ;
5941:
5942:
5943:
5944:
5945:
5946:
5947:
5948:
5949:
5950:
5951:
5952: public static final int[] regRn = new int[16 + 1];
5953:
5954:
5955: public static int regPC;
5956: public static int regPC0;
5957:
5958:
5959: public static int regOC;
5960:
5961:
5962: public static int regSRT1;
5963: public static int regSRT0;
5964: public static int mpuTraceFlag;
5965: public static int regSRS;
5966: public static int regSRM;
5967: public static int regSRI;
5968:
5969:
5970: public static int regCCR;
5971:
5972:
5973:
5974:
5975:
5976:
5977:
5978:
5979:
5980:
5981:
5982:
5983:
5984:
5985:
5986:
5987:
5988:
5989:
5990:
5991: public static int mpuIMR;
5992:
5993:
5994:
5995:
5996:
5997:
5998: public static int mpuIRR;
5999: public static int mpuDIRR;
6000:
6001:
6002:
6003:
6004:
6005:
6006:
6007:
6008: public static int mpuISR;
6009:
6010:
6011: public static int mpuSFC;
6012: public static int mpuDFC;
6013: public static int mpuCACR;
6014:
6015:
6016:
6017:
6018:
6019: public static int mpuBUSCR;
6020: public static int mpuUSP;
6021: public static int mpuVBR;
6022: public static int mpuCAAR;
6023: public static int mpuMSP;
6024: public static int mpuISP;
6025:
6026:
6027:
6028: public static int mpuPCR;
6029:
6030:
6031:
6032: public static final int MPU_060_REV = 7;
6033:
6034:
6035:
6036: public static long mpuClockTime;
6037: public static long mpuClockLimit;
6038: public static double mpuClockMHz;
6039: public static double mpuCurrentMHz;
6040: public static int mpuCycleCount;
6041: public static long mpuCycleUnit;
6042: public static long mpuModifiedUnit;
6043: public static long dmaCycleUnit;
6044:
6045:
6046:
6047: public static TimerTask mpuTask;
6048:
6049:
6050: public static int mpuBootDevice;
6051: public static int mpuROMBootHandle;
6052: public static int mpuSavedBootDevice;
6053: public static int mpuSavedROMBootHandle;
6054:
6055:
6056: public static boolean mpuIgnoreAddressError;
6057:
6058:
6059: public static int mpuROMWaitCycles;
6060: public static int mpuRAMWaitCycles;
6061: public static boolean mpuCacheOn;
6062: public static final class WaitTime {
6063: public long ram;
6064: public long gvram;
6065: public long tvram;
6066: public long crtc;
6067: public long palet;
6068: public long vicon;
6069: public long dmac;
6070: public long mfp;
6071: public long rtc;
6072: public long prnport;
6073: public long sysport;
6074: public long opm;
6075: public long adpcm;
6076: public long fdc;
6077: public long fdd;
6078: public long hdc;
6079: public long scc;
6080: public long ppi;
6081: public long ioi;
6082: public long sprc;
6083: public long sram;
6084: public long rom;
6085: public long ramlong;
6086: public long romlong;
6087: public boolean isDma;
6088: public WaitTime (boolean isDma) {
6089: this.isDma = isDma;
6090: }
6091: }
6092: public static final WaitTime mpuNoWaitTime = new WaitTime (false);
6093: public static final WaitTime dmaNoWaitTime = new WaitTime (true);
6094: public static final WaitTime mpuWaitTime = new WaitTime (false);
6095: public static final WaitTime dmaWaitTime = new WaitTime (true);
6096: public static boolean busWaitCyclesRequest;
6097: public static boolean busWaitCycles;
6098: public static WaitTime busWaitTime;
6099:
6100:
6101: public static boolean mpuArbFreqOn;
6102: public static int mpuArbFreqMHz;
6103: public static SpinnerNumberModel mpuArbFreqModel;
6104: public static JSpinner mpuArbFreqSpinner;
6105: public static JRadioButtonMenuItem mpuArbFreqRadioButtonMenuItem;
6106:
6107:
6108: public static boolean mpuUtilOn;
6109: public static int mpuUtilRatio;
6110: public static SpinnerNumberModel mpuUtilModel;
6111: public static JSpinner mpuUtilSpinner;
6112: public static JRadioButtonMenuItem mpuUtilRadioButtonMenuItem;
6113:
6114:
6115: public static final int MPU_ADJUSTMENT_INTERVAL = 100;
6116: public static int mpuAdjustmentCounter;
6117: public static long mpuTotalNano;
6118: public static long mpuLastNano;
6119: public static double mpuCoreNano1;
6120: public static double mpuCoreNano2;
6121:
6122:
6123: public static JMenu mpuMenu;
6124: public static JMenuItem mpuResetMenuItem;
6125: public static JMenuItem mpuOpt1ResetMenuItem;
6126: public static JRadioButtonMenuItem mpuClock10MenuItem;
6127: public static JRadioButtonMenuItem mpuClock16MenuItem;
6128: public static JRadioButtonMenuItem mpuClock25MenuItem;
6129: public static JRadioButtonMenuItem mpuClock33MenuItem;
6130: public static JRadioButtonMenuItem mpuClock50MenuItem;
6131: public static JRadioButtonMenuItem mpuClock66MenuItem;
6132: public static JRadioButtonMenuItem mpuClock75MenuItem;
6133: public static JRadioButtonMenuItem mpuClock100MenuItem;
6134:
6135:
6136: public static ActionListener mpuDebugActionListener;
6137: public static ArrayList<AbstractButton> mpuButtonsRunning;
6138: public static ArrayList<AbstractButton> mpuButtonsStopped;
6139: public static ArrayList<JCheckBox> mpuOriIllegalCheckBoxList;
6140: public static ArrayList<JCheckBox> mpuStopOnErrorCheckBoxList;
6141: public static ArrayList<JCheckBox> mpuStopAtStartCheckBoxList;
6142:
6143: public static int mpuAdvanceCount;
6144: public static int mpuStepCount;
6145: public static boolean mpuContinue;
6146: public static int mpuUntilReturnSRS;
6147: public static int mpuUntilReturnRP;
6148: public static int mpuUntilReturnPC0;
6149: public static int mpuUntilReturnSP;
6150:
6151:
6152:
6153:
6154:
6155:
6156:
6157:
6158:
6159:
6160:
6161:
6162:
6163:
6164:
6165:
6166:
6167:
6168:
6169:
6170:
6171:
6172:
6173:
6174:
6175:
6176:
6177:
6178:
6179:
6180:
6181:
6182:
6183:
6184:
6185:
6186:
6187:
6188:
6189:
6190:
6191:
6192:
6193:
6194:
6195:
6196:
6197:
6198:
6199:
6200:
6201:
6202:
6203:
6204:
6205:
6206:
6207:
6208:
6209:
6210:
6211:
6212:
6213:
6214:
6215:
6216:
6217:
6218:
6219:
6220:
6221:
6222:
6223: public static final boolean MPU_SXMENU = false;
6224:
6225:
6226:
6227: public static void mpuInit () {
6228:
6229: mpuIgnoreAddressError = false;
6230:
6231:
6232:
6233: fpuInit ();
6234:
6235: mpuClockTime = 0L;
6236: mpuClockLimit = 0L;
6237: mpuCycleCount = 0;
6238:
6239: mpuTask = null;
6240:
6241: M68kException.m6eSignal = new M68kException ();
6242: M68kException.m6eNumber = 0;
6243: M68kException.m6eAddress = 0;
6244: M68kException.m6eDirection = MPU_WR_WRITE;
6245: M68kException.m6eSize = MPU_SS_BYTE;
6246:
6247: mpuBootDevice = -1;
6248: mpuROMBootHandle = -1;
6249: mpuSavedBootDevice = -1;
6250: mpuSavedROMBootHandle = -1;
6251:
6252:
6253:
6254:
6255:
6256:
6257:
6258:
6259:
6260:
6261:
6262:
6263:
6264:
6265:
6266: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
6267: mpuTotalNano = 0L;
6268: mpuLastNano = System.nanoTime ();
6269: mpuCoreNano1 = mpuCoreNano2 = 0.5 * 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
6270:
6271: mpuButtonsRunning = new ArrayList<AbstractButton> ();
6272: mpuButtonsStopped = new ArrayList<AbstractButton> ();
6273:
6274: mpuOriIllegalCheckBoxList = new ArrayList<JCheckBox> ();
6275: mpuStopOnErrorCheckBoxList = new ArrayList<JCheckBox> ();
6276: mpuStopAtStartCheckBoxList = new ArrayList<JCheckBox> ();
6277:
6278: mpuAdvanceCount = 0;
6279: mpuStepCount = 0;
6280: mpuContinue = false;
6281: mpuUntilReturnSRS = 0;
6282: mpuUntilReturnRP = 0;
6283: mpuUntilReturnPC0 = 0;
6284: mpuUntilReturnSP = 0;
6285:
6286:
6287: mpuDebugActionListener = new ActionListener () {
6288: @Override public void actionPerformed (ActionEvent ae) {
6289: Object source = ae.getSource ();
6290: switch (ae.getActionCommand ()) {
6291: case "Stop":
6292: if (RootPointerList.RTL_ON) {
6293: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6294: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6295: mpuStop (null);
6296: }
6297: } else {
6298: mpuStop (null);
6299: }
6300: break;
6301: case "Trace":
6302: mpuAdvance (1);
6303: break;
6304: case "Trace 10 times":
6305: mpuAdvance (10);
6306: break;
6307: case "Trace 100 times":
6308: mpuAdvance (100);
6309: break;
6310: case "Step":
6311: mpuStep (1);
6312: break;
6313: case "Step 10 times":
6314: mpuStep (10);
6315: break;
6316: case "Step 100 times":
6317: mpuStep (100);
6318: break;
6319: case "Step until return":
6320: mpuStepUntilReturn ();
6321: break;
6322: case "Run":
6323: mpuStart ();
6324: break;
6325:
6326: case "Consider ORI.B #$00,D0 as an illegal instruction" :
6327: if (DBG_ORI_BYTE_ZERO_D0) {
6328: dbgOriByteZeroD0 = ((JCheckBox) source).isSelected ();
6329: for (JCheckBox checkBox : mpuOriIllegalCheckBoxList) {
6330: if (checkBox.isSelected () != dbgOriByteZeroD0) {
6331: checkBox.setSelected (dbgOriByteZeroD0);
6332: }
6333: }
6334: }
6335: break;
6336: case "Stop on error":
6337: dbgStopOnError = ((JCheckBox) source).isSelected ();
6338: for (JCheckBox checkBox : mpuStopOnErrorCheckBoxList) {
6339: if (checkBox.isSelected () != dbgStopOnError) {
6340: checkBox.setSelected (dbgStopOnError);
6341: }
6342: }
6343: break;
6344: case "Stop at execution start position":
6345: dbgStopAtStart = ((JCheckBox) source).isSelected ();
6346: for (JCheckBox checkBox : mpuStopAtStartCheckBoxList) {
6347: if (checkBox.isSelected () != dbgStopAtStart) {
6348: checkBox.setSelected (dbgStopAtStart);
6349: }
6350: }
6351: break;
6352: }
6353: }
6354: };
6355:
6356: }
6357:
6358:
6359:
6360: public static JCheckBox mpuMakeOriIllegalCheckBox () {
6361: JCheckBox checkBox = Multilingual.mlnToolTipText (
6362: ComponentFactory.createIconCheckBox (
6363: DBG_ORI_BYTE_ZERO_D0 ? dbgOriByteZeroD0 : null,
6364: LnF.LNF_ORI_BYTE_ZERO_D0_IMAGE,
6365: LnF.LNF_ORI_BYTE_ZERO_D0_SELECTED_IMAGE,
6366: "Consider ORI.B #$00,D0 as an illegal instruction", mpuDebugActionListener),
6367: "ja", "ORI.B #$00,D0 を不当命令とみなす");
6368: mpuOriIllegalCheckBoxList.add (checkBox);
6369: return checkBox;
6370: }
6371:
6372:
6373:
6374: public static JCheckBox mpuMakeStopOnErrorCheckBox () {
6375: JCheckBox checkBox = Multilingual.mlnToolTipText (
6376: ComponentFactory.createIconCheckBox (
6377: dbgStopOnError,
6378: LnF.LNF_STOP_ON_ERROR_IMAGE,
6379: LnF.LNF_STOP_ON_ERROR_SELECTED_IMAGE,
6380: "Stop on error", mpuDebugActionListener),
6381: "ja", "エラーで停止する");
6382: mpuStopOnErrorCheckBoxList.add (checkBox);
6383: return checkBox;
6384: }
6385:
6386:
6387:
6388: public static JCheckBox mpuMakeStopAtStartCheckBox () {
6389: JCheckBox checkBox = Multilingual.mlnToolTipText (
6390: ComponentFactory.createIconCheckBox (
6391: dbgStopAtStart,
6392: LnF.LNF_STOP_AT_START_IMAGE,
6393: LnF.LNF_STOP_AT_START_SELECTED_IMAGE,
6394: "Stop at execution start position", mpuDebugActionListener),
6395: "ja", "実行開始位置で停止する");
6396: mpuStopAtStartCheckBoxList.add (checkBox);
6397: return checkBox;
6398: }
6399:
6400:
6401:
6402:
6403:
6404: public static void mpuMakeMenu () {
6405:
6406: ButtonGroup unitGroup = new ButtonGroup ();
6407: ActionListener listener = new ActionListener () {
6408: @Override public void actionPerformed (ActionEvent ae) {
6409: Object source = ae.getSource ();
6410: switch (ae.getActionCommand ()) {
6411: case "Reset":
6412: mpuReset (-1, -1);
6413: break;
6414: case "Hold down OPT.1 and reset":
6415: mpuReset (0, -1);
6416: break;
6417: case "Interrupt":
6418: sysInterrupt ();
6419: break;
6420: case "10MHz":
6421: mpuArbFreqOn = false;
6422: mpuUtilOn = false;
6423: mpuSetCurrentClock (10.0);
6424: break;
6425: case "16.7MHz":
6426: mpuArbFreqOn = false;
6427: mpuUtilOn = false;
6428: mpuSetCurrentClock (50.0 / 3.0);
6429: break;
6430: case "25MHz":
6431: mpuArbFreqOn = false;
6432: mpuUtilOn = false;
6433: mpuSetCurrentClock (25.0);
6434: break;
6435: case "33.3MHz":
6436: mpuArbFreqOn = false;
6437: mpuUtilOn = false;
6438: mpuSetCurrentClock (100.0 / 3.0);
6439: break;
6440: case "50MHz":
6441: mpuArbFreqOn = false;
6442: mpuUtilOn = false;
6443: mpuSetCurrentClock (50.0);
6444: break;
6445: case "66.7MHz":
6446: mpuArbFreqOn = false;
6447: mpuUtilOn = false;
6448: mpuSetCurrentClock (200.0 / 3.0);
6449: break;
6450: case "75MHz":
6451: mpuArbFreqOn = false;
6452: mpuUtilOn = false;
6453: mpuSetCurrentClock (75.0);
6454: break;
6455: case "100MHz":
6456: mpuArbFreqOn = false;
6457: mpuUtilOn = false;
6458: mpuSetCurrentClock (100.0);
6459: break;
6460: case "Arbitrary frequency":
6461: mpuArbFreqOn = true;
6462: mpuUtilOn = false;
6463: mpuSetCurrentClock ((double) mpuArbFreqMHz);
6464: break;
6465: case "Arbitrary load factor":
6466: mpuArbFreqOn = false;
6467: mpuUtilOn = true;
6468: break;
6469: case "FE function instruction":
6470: FEFunction.fpkOn = ((JCheckBoxMenuItem) source).isSelected ();
6471: break;
6472: case "Reject FLOATn.X":
6473: FEFunction.fpkRejectFloatOn = ((JCheckBoxMenuItem) source).isSelected ();
6474: break;
6475: case "Cut FC2 pin":
6476: busRequestCutFC2Pin = ((JCheckBoxMenuItem) source).isSelected ();
6477: break;
6478: case "Wait cycles":
6479: busWaitCyclesRequest = ((JCheckBoxMenuItem) source).isSelected ();
6480: break;
6481: case "Use IPLROM 1.6":
6482: ROM.romIPLROM16On = ((JCheckBoxMenuItem) source).isSelected ();
6483: break;
6484: case "Increase IPLROM to 256KB":
6485: ROM.romIPLROM256KOn = ((JCheckBoxMenuItem) source).isSelected ();
6486: break;
6487:
6488: case "Run / Stop":
6489: if (((JCheckBox) source).isSelected ()) {
6490: mpuStart ();
6491: } else {
6492: if (RootPointerList.RTL_ON) {
6493: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
6494: RootPointerList.rtlCurrentUserTaskIsStoppable) {
6495: mpuStop (null);
6496: }
6497: } else {
6498: mpuStop (null);
6499: }
6500: }
6501: pnlPanel.requestFocusInWindow ();
6502: break;
6503: }
6504: }
6505: };
6506: mpuMenu = ComponentFactory.createMenu (
6507: "MPU", 'M',
6508: mpuResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset", 'R', MNB_MODIFIERS, listener), "ja", "リセット"),
6509: mpuOpt1ResetMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Hold down OPT.1 and reset", 'O', MNB_MODIFIERS, listener), "ja", "OPT.1 を押しながらリセット"),
6510: Multilingual.mlnText (ComponentFactory.createMenuItem ("Interrupt", listener), "ja", "インタラプト"),
6511: ComponentFactory.createHorizontalSeparator (),
6512: mdlMenu,
6513: ComponentFactory.createHorizontalSeparator (),
6514: mpuClock10MenuItem = ComponentFactory.createRadioButtonMenuItem (
6515: unitGroup,
6516: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 10.0,
6517: "10MHz",
6518: listener),
6519: mpuClock16MenuItem = ComponentFactory.createRadioButtonMenuItem (
6520: unitGroup,
6521: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0 / 3.0,
6522: "16.7MHz",
6523: listener),
6524: mpuClock25MenuItem = ComponentFactory.createRadioButtonMenuItem (
6525: unitGroup,
6526: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 25.0,
6527: "25MHz",
6528: listener),
6529: mpuClock33MenuItem = ComponentFactory.createRadioButtonMenuItem (
6530: unitGroup,
6531: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0 / 3.0,
6532: "33.3MHz",
6533: listener),
6534: mpuClock50MenuItem = ComponentFactory.createRadioButtonMenuItem (
6535: unitGroup,
6536: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 50.0,
6537: "50MHz",
6538: listener),
6539: mpuClock66MenuItem = ComponentFactory.createRadioButtonMenuItem (
6540: unitGroup,
6541: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 200.0 / 3.0,
6542: "66.7MHz",
6543: listener),
6544: mpuClock75MenuItem = ComponentFactory.createRadioButtonMenuItem (
6545: unitGroup,
6546: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 75.0,
6547: "75MHz",
6548: listener),
6549: mpuClock100MenuItem = ComponentFactory.createRadioButtonMenuItem (
6550: unitGroup,
6551: !mpuArbFreqOn && !mpuUtilOn && specifiedClock == 100.0,
6552: "100MHz",
6553: listener),
6554: mpuArbFreqRadioButtonMenuItem = Multilingual.mlnText (
6555: ComponentFactory.createRadioButtonMenuItem (
6556: unitGroup,
6557: mpuArbFreqOn,
6558: "Arbitrary frequency",
6559: listener),
6560: "ja", "任意の周波数"),
6561: ComponentFactory.createHorizontalBox (
6562: Box.createHorizontalStrut (20),
6563: mpuArbFreqSpinner = ComponentFactory.createNumberSpinner (
6564: mpuArbFreqModel = new SpinnerNumberModel (mpuArbFreqMHz, 1, 1000, 1),
6565: 4,
6566: new ChangeListener () {
6567: @Override public void stateChanged (ChangeEvent ce) {
6568:
6569: mpuArbFreqMHz = mpuArbFreqModel.getNumber ().intValue ();
6570: if (mpuArbFreqOn) {
6571: mpuSetCurrentClock ((double) mpuArbFreqMHz);
6572: }
6573: }
6574: }
6575: ),
6576: ComponentFactory.createLabel ("MHz"),
6577: Box.createHorizontalGlue ()
6578: ),
6579: mpuUtilRadioButtonMenuItem = Multilingual.mlnText (
6580: ComponentFactory.createRadioButtonMenuItem (
6581: unitGroup,
6582: mpuUtilOn,
6583: "Arbitrary load factor",
6584: listener),
6585: "ja", "任意の負荷率"),
6586: ComponentFactory.createHorizontalBox (
6587: Box.createHorizontalStrut (20),
6588: mpuUtilSpinner = ComponentFactory.createNumberSpinner (
6589: mpuUtilModel = new SpinnerNumberModel (mpuUtilRatio, 1, 100, 1),
6590: 4,
6591: new ChangeListener () {
6592: @Override public void stateChanged (ChangeEvent ce) {
6593:
6594: mpuUtilRatio = mpuUtilModel.getNumber ().intValue ();
6595: }
6596: }
6597: ),
6598: ComponentFactory.createLabel ("%"),
6599: Box.createHorizontalGlue ()
6600: ),
6601:
6602: ComponentFactory.createHorizontalSeparator (),
6603: coproFPUMenu,
6604: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkOn, "FE function instruction", listener), "ja", "FE ファンクション命令"),
6605: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (FEFunction.fpkRejectFloatOn, "Reject FLOATn.X", listener), "ja", "FLOATn.X を組み込まない"),
6606:
6607: ComponentFactory.createHorizontalSeparator (),
6608: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busRequestCutFC2Pin, "Cut FC2 pin", listener), "ja", "FC2 ピンをカットする"),
6609: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (busWaitCyclesRequest, "Wait cycles", listener), "ja", "ウェイトサイクル"),
6610: ComponentFactory.createHorizontalSeparator (),
6611: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM16On, "Use IPLROM 1.6", listener), "ja", "IPLROM 1.6 を使う"),
6612: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (ROM.romIPLROM256KOn, "Increase IPLROM to 256KB", listener), "ja", "IPLROM を 256KB に増やす"),
6613:
6614: ComponentFactory.createHorizontalSeparator (),
6615: SRAM.smrCacheMenu
6616: );
6617: }
6618:
6619:
6620: public static void mpuSetCurrentClock (double clock) {
6621: specifiedClock = clock;
6622: if (currentIsSecond) {
6623: specifiedSecondClock = clock;
6624: } else {
6625: specifiedFirstClock = clock;
6626: }
6627: if (!mpuArbFreqOn && !mpuUtilOn) {
6628: if (specifiedClock == 10.0) {
6629: mpuClock10MenuItem.setSelected (true);
6630: } else if (specifiedClock == 50.0 / 3.0) {
6631: mpuClock16MenuItem.setSelected (true);
6632: } else if (specifiedClock == 25.0) {
6633: mpuClock25MenuItem.setSelected (true);
6634: } else if (specifiedClock == 100.0 / 3.0) {
6635: mpuClock33MenuItem.setSelected (true);
6636: } else if (specifiedClock == 50.0) {
6637: mpuClock50MenuItem.setSelected (true);
6638: } else if (specifiedClock == 200.0 / 3.0) {
6639: mpuClock66MenuItem.setSelected (true);
6640: } else if (specifiedClock == 75.0) {
6641: mpuClock75MenuItem.setSelected (true);
6642: } else if (specifiedClock == 100.0) {
6643: mpuClock100MenuItem.setSelected (true);
6644: }
6645: }
6646: mpuClockMHz = specifiedClock;
6647: mpuSetClockMHz (mpuClockMHz);
6648: }
6649:
6650:
6651:
6652:
6653:
6654:
6655:
6656:
6657:
6658:
6659:
6660: public static void mpuSetClockMHz (double mhz) {
6661: mhz = Math.max (1.0, Math.min (1000.0, mhz));
6662: double lastMHz = mpuCurrentMHz;
6663: mpuCurrentMHz = mhz;
6664: mpuCycleUnit = (long) (((double) TMR_FREQ / 1000000.0) / mhz + 0.5);
6665:
6666: mpuModifiedUnit = (currentMPU == Model.MPU_MC68EC030 ||
6667: currentMPU == Model.MPU_MC68030 ?
6668: (long) (((double) TMR_FREQ * 3.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6669: currentMPU == Model.MPU_MC68LC040 ||
6670: currentMPU == Model.MPU_MC68040 ?
6671: (long) (((double) TMR_FREQ * 2.0 / (5.0 * 1000000.0)) / mhz + 0.5) :
6672: mpuCycleUnit);
6673: if (lastMHz != mhz) {
6674: mpuSetWait ();
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: public static void mpuSetWait () {
6759:
6760: if (currentMPU <= Model.MPU_MC68010) {
6761: mpuWaitTime.ram = mpuCycleUnit >> 3;
6762: mpuWaitTime.vicon = (long) (mpuCycleUnit * 0.6);
6763: mpuWaitTime.crtc =
6764: mpuWaitTime.prnport =
6765: mpuWaitTime.sysport =
6766: mpuWaitTime.sprc =
6767: mpuWaitTime.sram =
6768: mpuWaitTime.rom = mpuCycleUnit;
6769: mpuWaitTime.gvram = (long) (mpuCycleUnit * 1.1);
6770: mpuWaitTime.rtc =
6771: mpuWaitTime.opm =
6772: mpuWaitTime.adpcm =
6773: mpuWaitTime.fdc =
6774: mpuWaitTime.fdd =
6775: mpuWaitTime.hdc =
6776: mpuWaitTime.ppi =
6777: mpuWaitTime.ioi = (long) (mpuCycleUnit * 1.7);
6778: mpuWaitTime.tvram = mpuCycleUnit * 2;
6779: mpuWaitTime.palet = (long) (mpuCycleUnit * 2.6);
6780: mpuWaitTime.mfp = (long) (mpuCycleUnit * 4.3);
6781: mpuWaitTime.scc = mpuCycleUnit * 6;
6782: mpuWaitTime.dmac = mpuCycleUnit * 15;
6783: mpuWaitTime.ramlong = mpuWaitTime.ram << 1;
6784: mpuWaitTime.romlong = mpuWaitTime.rom << 1;
6785: } else if (currentMPU <= Model.MPU_MC68030) {
6786: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6787: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6788: mpuWaitTime.sram = mpuCycleUnit * 2;
6789: mpuWaitTime.prnport =
6790: mpuWaitTime.sysport = mpuCycleUnit * 4;
6791: mpuWaitTime.gvram =
6792: mpuWaitTime.crtc =
6793: mpuWaitTime.vicon =
6794: mpuWaitTime.sprc = mpuCycleUnit * 6;
6795: mpuWaitTime.tvram = mpuCycleUnit * 7;
6796: mpuWaitTime.palet = mpuCycleUnit * 11;
6797: mpuWaitTime.opm =
6798: mpuWaitTime.adpcm =
6799: mpuWaitTime.fdc =
6800: mpuWaitTime.fdd =
6801: mpuWaitTime.hdc =
6802: mpuWaitTime.ppi =
6803: mpuWaitTime.ioi = mpuCycleUnit * 15;
6804: mpuWaitTime.mfp = mpuCycleUnit * 19;
6805: mpuWaitTime.rtc = mpuCycleUnit * 28;
6806: mpuWaitTime.dmac = mpuCycleUnit * 34;
6807: mpuWaitTime.scc = mpuCycleUnit * 38;
6808: mpuWaitTime.ramlong = mpuWaitTime.ram;
6809: mpuWaitTime.romlong = mpuWaitTime.rom;
6810: } else {
6811: mpuWaitTime.ram = mpuCacheOn ? 0 : mpuCycleUnit * mpuRAMWaitCycles + (mpuCycleUnit >> 3);
6812: mpuWaitTime.rom = mpuCacheOn ? 0 : mpuCycleUnit * mpuROMWaitCycles;
6813: mpuWaitTime.sram = mpuCycleUnit * 13;
6814: mpuWaitTime.prnport =
6815: mpuWaitTime.sysport = mpuCycleUnit * 17;
6816: mpuWaitTime.gvram =
6817: mpuWaitTime.crtc =
6818: mpuWaitTime.vicon =
6819: mpuWaitTime.sprc = mpuCycleUnit * 21;
6820: mpuWaitTime.tvram = mpuCycleUnit * 22;
6821: mpuWaitTime.palet = mpuCycleUnit * 33;
6822: mpuWaitTime.opm =
6823: mpuWaitTime.adpcm =
6824: mpuWaitTime.fdc =
6825: mpuWaitTime.fdd =
6826: mpuWaitTime.hdc =
6827: mpuWaitTime.ppi =
6828: mpuWaitTime.ioi = mpuCycleUnit * 37;
6829: mpuWaitTime.mfp = mpuCycleUnit * 47;
6830: mpuWaitTime.dmac = mpuCycleUnit * 73;
6831: mpuWaitTime.rtc = mpuCycleUnit * 77;
6832: mpuWaitTime.scc = mpuCycleUnit * 97;
6833: mpuWaitTime.ramlong = mpuWaitTime.ram;
6834: mpuWaitTime.romlong = mpuWaitTime.rom;
6835: }
6836: if (true) {
6837:
6838: mpuNoWaitTime.sram = mpuWaitTime.sram;
6839: mpuNoWaitTime.rom = mpuWaitTime.rom;
6840: mpuNoWaitTime.romlong = mpuWaitTime.romlong;
6841: }
6842:
6843: dmaWaitTime.ram = dmaCycleUnit >> 3;
6844: dmaWaitTime.sram = 0;
6845: dmaWaitTime.rom = 0;
6846: dmaWaitTime.gvram =
6847: dmaWaitTime.crtc =
6848: dmaWaitTime.vicon =
6849: dmaWaitTime.prnport =
6850: dmaWaitTime.sysport =
6851: dmaWaitTime.sprc = dmaCycleUnit;
6852: dmaWaitTime.tvram =
6853: dmaWaitTime.rtc =
6854: dmaWaitTime.opm =
6855: dmaWaitTime.adpcm =
6856: dmaWaitTime.fdc =
6857: dmaWaitTime.fdd =
6858: dmaWaitTime.hdc =
6859: dmaWaitTime.ppi =
6860: dmaWaitTime.ioi = dmaCycleUnit * 2;
6861: dmaWaitTime.palet = dmaCycleUnit * 3;
6862: dmaWaitTime.mfp = dmaCycleUnit * 4;
6863: dmaWaitTime.scc = dmaCycleUnit * 6;
6864: dmaWaitTime.dmac = dmaCycleUnit * 15;
6865: dmaWaitTime.ramlong = dmaWaitTime.ram << 1;
6866: dmaWaitTime.romlong = dmaWaitTime.rom << 1;
6867: if (MC68060.CAT_ON) {
6868: if (Model.MPU_MC68LC060 <= currentMPU) {
6869: MC68060.catMainLongTime = mpuCycleUnit * 13;
6870: MC68060.catMainLineTime = mpuCycleUnit * 45;
6871: MC68060.catHighLongTime = mpuCycleUnit * 9;
6872: MC68060.catHighLineTime = mpuCycleUnit * 15;
6873: }
6874: }
6875: }
6876:
6877:
6878:
6879:
6880:
6881: public static void mpuReset (int device, int romHandle) {
6882:
6883: mpuBootDevice = device;
6884: mpuROMBootHandle = romHandle;
6885:
6886:
6887:
6888:
6889:
6890:
6891:
6892:
6893:
6894:
6895:
6896:
6897: if (mpuBootDevice == -1) {
6898: if (mpuSavedBootDevice != -1) {
6899: mpuBootDevice = mpuSavedBootDevice;
6900: mpuROMBootHandle = mpuSavedROMBootHandle;
6901: mpuSavedBootDevice = -1;
6902: mpuSavedROMBootHandle = -1;
6903: }
6904: } else {
6905: if (mpuSavedBootDevice == -1) {
6906: mpuSavedBootDevice = MainMemory.mmrRwz (0x00ed0018);
6907: mpuSavedROMBootHandle = MainMemory.mmrRls (0x00ed000c);
6908: }
6909: }
6910:
6911:
6912: if (mpu010) {
6913: if (specifiedFirstMPU == Model.MPU_MC68000) {
6914: specifiedFirstMPU = Model.MPU_MC68010;
6915: }
6916: if (specifiedSecondMPU == Model.MPU_MC68000) {
6917: specifiedSecondMPU = Model.MPU_MC68010;
6918: }
6919: } else {
6920: if (specifiedFirstMPU == Model.MPU_MC68010) {
6921: specifiedFirstMPU = Model.MPU_MC68000;
6922: }
6923: if (specifiedSecondMPU == Model.MPU_MC68010) {
6924: specifiedSecondMPU = Model.MPU_MC68000;
6925: }
6926: }
6927:
6928:
6929: specifiedIsSecond = false;
6930: specifiedMPU = specifiedIsSecond ? specifiedSecondMPU : specifiedFirstMPU;
6931: specifiedClock = specifiedIsSecond ? specifiedSecondClock : specifiedFirstClock;
6932:
6933: if (MC68EC030.M30_DIV_ZERO_V_FLAG) {
6934: MC68EC030.m30DivZeroVFlag = false;
6935: }
6936:
6937: if (mpuTask != null) {
6938: mpuClockLimit = 0L;
6939: System.out.println (Multilingual.mlnJapanese ?
6940: "MPU を停止します" :
6941: "MPU stops");
6942: mpuTask.cancel ();
6943: mpuTask = null;
6944: }
6945:
6946: tmrTimer.schedule (new TimerTask () {
6947: @Override public void run () {
6948:
6949:
6950:
6951: currentModel = specifiedModel;
6952: currentAccelerator = specifiedAccelerator;
6953: frmUpdateTitle ();
6954:
6955: currentIsSecond = specifiedIsSecond;
6956: currentFirstMPU = specifiedFirstMPU;
6957: currentSecondMPU = specifiedSecondMPU;
6958: currentMPU = specifiedMPU;
6959:
6960: mpuSetCurrentClock (specifiedClock);
6961:
6962: currentCopro0 = specifiedCopro0;
6963: currentCopro1 = specifiedCopro1;
6964: currentCopro2 = specifiedCopro2;
6965: currentOnchipFPU = specifiedOnchipFPU;
6966:
6967:
6968: if (currentMPU < Model.MPU_MC68020) {
6969: if (busHimem68000) {
6970: busRequestExMemoryStart = 0x10000000;
6971: busRequestExMemorySize = busLocalMemorySize;
6972: busRequestExMemoryArray = busLocalMemoryArray;
6973: } else {
6974: busRequestExMemoryStart = 0x10000000;
6975: busRequestExMemorySize = 0 << 20;
6976: busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
6977: }
6978: } else if (currentMPU < Model.MPU_MC68LC040) {
6979: if (busHighMemory060turboOn) {
6980: busRequestExMemoryStart = 0x10000000;
6981: busRequestExMemorySize = busLocalMemorySize;
6982: busRequestExMemoryArray = busLocalMemoryArray;
6983: } else {
6984: busRequestExMemoryStart = 0x01000000;
6985: busRequestExMemorySize = busHighMemorySize;
6986: busRequestExMemoryArray = busHighMemoryArray;
6987: }
6988: } else {
6989: busRequestExMemoryStart = 0x10000000;
6990: busRequestExMemorySize = busLocalMemorySize;
6991: busRequestExMemoryArray = busLocalMemoryArray;
6992: }
6993: busUpdateMemoryMap ();
6994:
6995:
6996: ROM.romReset ();
6997:
6998: RegisterList.drpSetMPU ();
6999:
7000: mpuSFC = mpuDFC = mpuCACR = mpuBUSCR = mpuUSP = mpuVBR = mpuCAAR = mpuMSP = mpuISP = 0;
7001: mpuPCR = 0x04300500 | MPU_060_REV << 8;
7002: MC68060.mmuReset ();
7003:
7004:
7005: if (Model.MPU_MC68020 <= currentMPU) {
7006: if ((7 & currentCopro0) == 1) {
7007: fpuMotherboardCoprocessor.epbSetMC68881 ();
7008: } else if ((7 & currentCopro0) == 2) {
7009: fpuMotherboardCoprocessor.epbSetMC68882 ();
7010: } else {
7011: fpuMotherboardCoprocessor.epbSetFullSpec ();
7012: }
7013: if ((8 & currentCopro0) == 0) {
7014: fpuMotherboardCoprocessor.epbSetExtended ();
7015: } else {
7016: fpuMotherboardCoprocessor.epbSetTriple ();
7017: }
7018: }
7019:
7020: if ((7 & currentCopro1) == 1) {
7021: fpuCoproboard1.epbSetMC68881 ();
7022: } else if ((7 & currentCopro1) == 2) {
7023: fpuCoproboard1.epbSetMC68882 ();
7024: } else {
7025: fpuCoproboard1.epbSetFullSpec ();
7026: }
7027: if ((8 & currentCopro1) == 0) {
7028: fpuCoproboard1.epbSetExtended ();
7029: } else {
7030: fpuCoproboard1.epbSetTriple ();
7031: }
7032:
7033: if ((7 & currentCopro2) == 1) {
7034: fpuCoproboard2.epbSetMC68881 ();
7035: } else if ((7 & currentCopro2) == 2) {
7036: fpuCoproboard2.epbSetMC68882 ();
7037: } else {
7038: fpuCoproboard2.epbSetFullSpec ();
7039: }
7040: if ((8 & currentCopro2) == 0) {
7041: fpuCoproboard2.epbSetExtended ();
7042: } else {
7043: fpuCoproboard2.epbSetTriple ();
7044: }
7045:
7046: if (Model.MPU_MC68040 <= currentMPU) {
7047: if ((7 & currentOnchipFPU) == 6) {
7048: fpuOnChipFPU.epbSetMC68060 ();
7049: } else {
7050: fpuOnChipFPU.epbSetFullSpec ();
7051: }
7052: if ((8 & currentOnchipFPU) == 0) {
7053: fpuOnChipFPU.epbSetExtended ();
7054: } else {
7055: fpuOnChipFPU.epbSetTriple ();
7056: }
7057: }
7058:
7059: if (!currentModel.isX68030 ()) {
7060: dmaCycleUnit = TMR_FREQ / 10000000L;
7061: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
7062: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
7063: mpuROMWaitCycles = 1;
7064: mpuRAMWaitCycles = 0;
7065: } else {
7066: dmaCycleUnit = TMR_FREQ / 12500000L;
7067: HD63450.dmaBurstInterval = dmaCycleUnit << 4 + (HD63450.dmaBT >> 2);
7068: HD63450.dmaBurstSpan = HD63450.dmaBurstInterval >> 1 + (HD63450.dmaBR & 3);
7069: mpuROMWaitCycles = 0;
7070: mpuRAMWaitCycles = 0;
7071: }
7072:
7073: busWaitCycles = busWaitCyclesRequest;
7074: busWaitTime = busWaitCycles ? mpuWaitTime : mpuNoWaitTime;
7075:
7076: HD63450.dmaReadCycles = (currentModel.isPRO () ? 6 :
7077: currentModel.isCompact () ? 4 :
7078: 5);
7079: HD63450.dmaWriteCycles = (currentModel.isPRO () ? 6 :
7080: 5);
7081:
7082: if (currentMPU < Model.MPU_MC68020) {
7083:
7084: mpuIgnoreAddressError = false;
7085:
7086: mpuCacheOn = false;
7087:
7088: } else if (currentMPU < Model.MPU_MC68040) {
7089:
7090: mpuIgnoreAddressError = true;
7091: fpuBox = fpuMotherboardCoprocessor;
7092: fpuBox.epbReset ();
7093: fpuFPn = fpuBox.epbFPn;
7094:
7095: mpuCacheOn = (mpuCACR & 0x00000101) != 0;
7096:
7097: } else {
7098:
7099: mpuIgnoreAddressError = true;
7100: fpuBox = fpuOnChipFPU;
7101: fpuBox.epbReset ();
7102: fpuFPn = fpuBox.epbFPn;
7103:
7104: mpuPCR = 0x04300500 | MPU_060_REV << 8;
7105: mpuCacheOn = (mpuCACR & 0x80008000) != 0;
7106: if (MC68060.CAT_ON) {
7107: if (Model.MPU_MC68LC060 <= currentMPU) {
7108: MC68060.catReset ();
7109: }
7110: }
7111:
7112: }
7113:
7114: mpuSetWait ();
7115:
7116:
7117: regSRT1 = regSRT0 = 0;
7118: regSRS = REG_SR_S;
7119: regSRM = 0;
7120: regSRI = REG_SR_I;
7121: regCCR = 0;
7122: Arrays.fill (regRn, 0);
7123:
7124: regRn[15] = MainMemory.mmrRls (0x00ff0000);
7125: regPC = MainMemory.mmrRls (0x00ff0004);
7126:
7127: MainMemory.mmrReset ();
7128:
7129: busReset ();
7130: if (InstructionBreakPoint.IBP_ON) {
7131: InstructionBreakPoint.ibpOp1MemoryMap = InstructionBreakPoint.ibpOp1SuperMap;
7132: InstructionBreakPoint.ibpReset ();
7133: }
7134: if (BranchLog.BLG_ON) {
7135: BranchLog.blgReset ();
7136: }
7137:
7138: mpuIMR = 0;
7139: mpuIRR = 0;
7140: if (MC68901.MFP_DELAYED_INTERRUPT) {
7141: mpuDIRR = 0;
7142: }
7143: mpuISR = 0;
7144:
7145:
7146: mpuStart ();
7147: }
7148: }, TMR_DELAY);
7149:
7150: }
7151:
7152:
7153:
7154: public static void mpuStopAndStart () {
7155: if (mpuTask == null) {
7156: mpuStart ();
7157: } else {
7158: if (RootPointerList.RTL_ON) {
7159: if (RootPointerList.rtlCurrentSupervisorTaskIsStoppable ||
7160: RootPointerList.rtlCurrentUserTaskIsStoppable) {
7161: mpuStop (null);
7162: }
7163: } else {
7164: mpuStop (null);
7165: }
7166: }
7167: }
7168:
7169:
7170:
7171:
7172:
7173: public static void mpuStart () {
7174: if (mpuTask != null) {
7175: mpuClockLimit = 0L;
7176: System.out.println (Multilingual.mlnJapanese ?
7177: "MPU を停止します" :
7178: "MPU stops");
7179: mpuTask.cancel ();
7180: mpuTask = null;
7181: }
7182:
7183: for (AbstractButton button : mpuButtonsStopped) {
7184: button.setEnabled (false);
7185: }
7186: DisassembleList.ddpStoppedBy = null;
7187: System.out.println (Model.mpuNameOf (currentMPU) + (Multilingual.mlnJapanese ? " を起動します" : " starts up"));
7188: mpuTask = new TimerTask () {
7189: @Override public void run () {
7190: mpuContinue = true;
7191: mpuClockLimit = mpuClockTime + TMR_FREQ * TMR_INTERVAL / 1000;
7192: mpuExecuteCore ();
7193: }
7194: };
7195: tmrTimer.scheduleAtFixedRate (mpuTask, TMR_DELAY, TMR_INTERVAL);
7196:
7197: for (AbstractButton button : mpuButtonsRunning) {
7198: button.setEnabled (true);
7199: }
7200: }
7201:
7202:
7203:
7204: public static void mpuExecuteCore () {
7205:
7206: long nanoStart = System.nanoTime ();
7207:
7208: busSuper (RP5C15.rtcFirst, 0x00e8a000, 0x00e8c000);
7209:
7210:
7211: if (currentMPU < Model.MPU_MC68010) {
7212: MC68000.mpuCore ();
7213: } else if (currentMPU < Model.MPU_MC68020) {
7214: MC68010.mpuCore ();
7215: } else if (currentMPU < Model.MPU_MC68LC040) {
7216: MC68EC030.mpuCore ();
7217: } else {
7218: MC68060.mpuCore ();
7219: }
7220:
7221: if (dbgVisibleMask != 0) {
7222: dbgUpdate ();
7223: }
7224:
7225: long nanoEnd = System.nanoTime ();
7226: mpuTotalNano += nanoEnd - nanoStart;
7227: if (--mpuAdjustmentCounter == 0) {
7228:
7229: final double expectedNano = 1e+6 * (double) (TMR_INTERVAL * MPU_ADJUSTMENT_INTERVAL);
7230:
7231: double coreNano0 = (double) mpuTotalNano;
7232: mpuTotalNano = 0L;
7233: double coreNanoA = (coreNano0 * 2.0 + mpuCoreNano1 + mpuCoreNano2) * 0.25;
7234: mpuCoreNano2 = mpuCoreNano1;
7235: mpuCoreNano1 = coreNano0;
7236:
7237:
7238:
7239: double actualPercent = Math.max (1.0, 100.0 * coreNanoA / expectedNano);
7240:
7241: double maxPercent = SoundSource.sndPlayOn ? 90.0 : 100.0;
7242:
7243:
7244:
7245:
7246: if (mpuUtilOn) {
7247:
7248: double targetPercent = Math.min (maxPercent, (double) mpuUtilRatio);
7249: mpuSetClockMHz ((1.2 - 0.2 * actualPercent / targetPercent) * mpuCurrentMHz);
7250: } else {
7251: mpuSetClockMHz (Math.min (maxPercent / actualPercent,
7252: 1.2 - 0.2 * mpuCurrentMHz / mpuClockMHz) * mpuCurrentMHz);
7253: }
7254: Indicator.indUpdate (actualPercent);
7255: mpuAdjustmentCounter = MPU_ADJUSTMENT_INTERVAL;
7256: }
7257: }
7258:
7259:
7260:
7261:
7262: public static void mpuStop (String message) {
7263:
7264: mpuAdvanceCount = 0;
7265: mpuStepCount = 0;
7266: mpuContinue = false;
7267: mpuStop1 (message);
7268: }
7269: public static void mpuStop1 (String message) {
7270: if (mpuTask == null) {
7271: return;
7272: }
7273: DisassembleList.ddpStoppedBy = message;
7274: mpuClockLimit = 0L;
7275: System.out.println (Multilingual.mlnJapanese ?
7276: "MPU を停止します" :
7277: "MPU stops");
7278: mpuTask.cancel ();
7279: mpuTask = null;
7280:
7281: if (mpuStepCount != 0 && mpuContinue) {
7282: if (mpuStepCount == -1 || --mpuStepCount != 0) {
7283: mpuStep (mpuStepCount);
7284: return;
7285: }
7286: }
7287: mpuAdvanceCount = 0;
7288: mpuStepCount = 0;
7289: mpuContinue = false;
7290:
7291: for (AbstractButton button : mpuButtonsRunning) {
7292: button.setEnabled (false);
7293: }
7294: tmrTimer.schedule (new TimerTask () {
7295: @Override public void run () {
7296: mpuUpdateWindow ();
7297: }
7298: }, TMR_DELAY);
7299: }
7300:
7301:
7302:
7303:
7304:
7305:
7306: public static void mpuAdvance (int n) {
7307: if (mpuTask != null) {
7308: return;
7309: }
7310: mpuAdvanceCount = n;
7311: DisassembleList.ddpStoppedBy = null;
7312: mpuTask = new TimerTask () {
7313: @Override public void run () {
7314: mpuContinue = true;
7315: do {
7316: mpuClockLimit = mpuClockTime + 1L;
7317: mpuExecuteCore ();
7318: } while (mpuContinue && --mpuAdvanceCount != 0);
7319: mpuClockLimit = 0L;
7320: if (mpuTask != null) {
7321: mpuTask.cancel ();
7322: mpuTask = null;
7323: }
7324: if (mpuStepCount != 0 && mpuContinue) {
7325: if (mpuStepCount == -1 || --mpuStepCount != 0) {
7326: mpuStep (mpuStepCount);
7327: return;
7328: }
7329: }
7330: mpuAdvanceCount = 0;
7331: mpuStepCount = 0;
7332: mpuContinue = false;
7333: mpuUpdateWindow ();
7334: }
7335: };
7336: tmrTimer.schedule (mpuTask, TMR_DELAY);
7337: }
7338:
7339:
7340:
7341:
7342:
7343:
7344: public static void mpuStep (int n) {
7345: if (mpuTask != null) {
7346: return;
7347: }
7348: mpuStepCount = n;
7349: Disassembler.disDisassemble (new StringBuilder (), regPC, regSRS);
7350: if ((Disassembler.disStatus & (Disassembler.DIS_ALWAYS_BRANCH | Disassembler.DIS_SOMETIMES_BRANCH)) != 0) {
7351: if (mpuStepCount == -1 &&
7352: (Disassembler.disOC == 0x4e73 ||
7353: Disassembler.disOC == 0x4e74 ||
7354: Disassembler.disOC == 0x4e75 ||
7355: Disassembler.disOC == 0x4e77) &&
7356: mpuUntilReturnSRS == regSRS &&
7357: (currentMPU < Model.MPU_MC68LC040 ||
7358: mpuUntilReturnRP == (regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP)) &&
7359: mpuUntilReturnPC0 != regPC0 &&
7360: Integer.compareUnsigned (mpuUntilReturnSP, regRn[15]) <= 0) {
7361: mpuAdvanceCount = 0;
7362: mpuStepCount = 0;
7363: mpuContinue = false;
7364: mpuUpdateWindow ();
7365: return;
7366: }
7367: mpuAdvance (1);
7368: } else {
7369: if (InstructionBreakPoint.IBP_ON) {
7370: InstructionBreakPoint.ibpInstant (Disassembler.disPC, DisassembleList.ddpSupervisorMode);
7371: mpuStart ();
7372: }
7373: }
7374: }
7375:
7376:
7377:
7378:
7379:
7380:
7381:
7382:
7383:
7384:
7385:
7386: public static void mpuStepUntilReturn () {
7387: if (mpuTask != null) {
7388: return;
7389: }
7390: mpuUntilReturnSRS = regSRS;
7391: mpuUntilReturnRP = regSRS != 0 ? MC68060.mmuSRP : MC68060.mmuURP;
7392: mpuUntilReturnPC0 = regPC0;
7393: mpuUntilReturnSP = regRn[15];
7394: mpuStep (-1);
7395: }
7396:
7397:
7398:
7399: public static void mpuUpdateWindow () {
7400: if (dbgVisibleMask != 0) {
7401: if ((dbgVisibleMask & DBG_DDP_VISIBLE_MASK) != 0) {
7402: DisassembleList.ddpBacktraceRecord = -1L;
7403: DisassembleList.ddpUpdate (-1, -1, false);
7404: }
7405: if (BranchLog.BLG_ON) {
7406: if ((dbgVisibleMask & DBG_BLG_VISIBLE_MASK) != 0) {
7407: BranchLog.blgUpdate (BranchLog.BLG_SELECT_NEWEST);
7408: }
7409: }
7410: if (ProgramFlowVisualizer.PFV_ON) {
7411: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
7412: ProgramFlowVisualizer.pfvUpdate ();
7413: }
7414: }
7415: if (RasterBreakPoint.RBP_ON) {
7416: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
7417: RasterBreakPoint.rbpUpdateFrame ();
7418: }
7419: }
7420: if (ScreenModeTest.SMT_ON) {
7421: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
7422: ScreenModeTest.smtUpdateFrame ();
7423: }
7424: }
7425: if (RootPointerList.RTL_ON) {
7426: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
7427: RootPointerList.rtlUpdateFrame ();
7428: }
7429: }
7430: if (SpritePatternViewer.SPV_ON) {
7431: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
7432: SpritePatternViewer.spvUpdateFrame ();
7433: }
7434: }
7435: if (PaletteViewer.PLV_ON) {
7436: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
7437: PaletteViewer.plvUpdateFrame ();
7438: }
7439: }
7440: if (ATCMonitor.ACM_ON) {
7441: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
7442: ATCMonitor.acmUpdateFrame ();
7443: }
7444: }
7445: }
7446:
7447: if (DebugConsole.dgtRequestRegs != 0) {
7448: if ((DebugConsole.dgtRequestRegs & 1) != 0) {
7449: ExpressionEvaluator.ElementType.ETY_COMMAND_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
7450: }
7451: if ((DebugConsole.dgtRequestRegs & 2) != 0) {
7452: ExpressionEvaluator.ElementType.ETY_COMMAND_FLOAT_REGS.etyEval (null, ExpressionEvaluator.EVM_COMMAND);
7453: }
7454: if ((DebugConsole.dgtRequestRegs & 4) != 0) {
7455: DebugConsole.dgtPrintPrompt ();
7456: }
7457: DebugConsole.dgtRequestRegs = 0;
7458: }
7459:
7460: for (AbstractButton button : mpuButtonsRunning) {
7461: button.setEnabled (false);
7462: }
7463:
7464: for (AbstractButton button : mpuButtonsStopped) {
7465: button.setEnabled (true);
7466: }
7467: }
7468:
7469:
7470:
7471: public static JButton mpuMakeBreakButton () {
7472: return mpuAddButtonRunning (
7473: Multilingual.mlnToolTipText (
7474: ComponentFactory.createImageButton (
7475: LnF.LNF_BREAK_IMAGE,
7476: LnF.LNF_BREAK_DISABLED_IMAGE,
7477: "Stop", mpuDebugActionListener),
7478: "ja", "停止")
7479: );
7480: }
7481:
7482:
7483:
7484: public static JButton mpuMakeTraceButton () {
7485: return mpuAddButtonStopped (
7486: Multilingual.mlnToolTipText (
7487: ComponentFactory.createImageButton (
7488: LnF.LNF_TRACE_IMAGE,
7489: LnF.LNF_TRACE_DISABLED_IMAGE,
7490: "Trace", mpuDebugActionListener),
7491: "ja", "トレース")
7492: );
7493: }
7494:
7495:
7496:
7497: public static JButton mpuMakeTrace10Button () {
7498: return mpuAddButtonStopped (
7499: Multilingual.mlnToolTipText (
7500: ComponentFactory.createImageButton (
7501: LnF.LNF_TRACE_10_IMAGE,
7502: LnF.LNF_TRACE_10_DISABLED_IMAGE,
7503: "Trace 10 times", mpuDebugActionListener),
7504: "ja", "トレース 10 回")
7505: );
7506: }
7507:
7508:
7509:
7510: public static JButton mpuMakeTrace100Button () {
7511: return mpuAddButtonStopped (
7512: Multilingual.mlnToolTipText (
7513: ComponentFactory.createImageButton (
7514: LnF.LNF_TRACE_100_IMAGE,
7515: LnF.LNF_TRACE_100_DISABLED_IMAGE,
7516: "Trace 100 times", mpuDebugActionListener),
7517: "ja", "トレース 100 回")
7518: );
7519: }
7520:
7521:
7522:
7523: public static JButton mpuMakeStepButton () {
7524: return mpuAddButtonStopped (
7525: Multilingual.mlnToolTipText (
7526: ComponentFactory.createImageButton (
7527: LnF.LNF_STEP_IMAGE,
7528: LnF.LNF_STEP_DISABLED_IMAGE,
7529: "Step", mpuDebugActionListener),
7530: "ja", "ステップ")
7531: );
7532: }
7533:
7534:
7535:
7536: public static JButton mpuMakeStep10Button () {
7537: return mpuAddButtonStopped (
7538: Multilingual.mlnToolTipText (
7539: ComponentFactory.createImageButton (
7540: LnF.LNF_STEP_10_IMAGE,
7541: LnF.LNF_STEP_10_DISABLED_IMAGE,
7542: "Step 10 times", mpuDebugActionListener),
7543: "ja", "ステップ 10 回")
7544: );
7545: }
7546:
7547:
7548:
7549: public static JButton mpuMakeStep100Button () {
7550: return mpuAddButtonStopped (
7551: Multilingual.mlnToolTipText (
7552: ComponentFactory.createImageButton (
7553: LnF.LNF_STEP_100_IMAGE,
7554: LnF.LNF_STEP_100_DISABLED_IMAGE,
7555: "Step 100 times", mpuDebugActionListener),
7556: "ja", "ステップ 100 回")
7557: );
7558: }
7559:
7560:
7561:
7562: public static JButton mpuMakeReturnButton () {
7563: return mpuAddButtonStopped (
7564: Multilingual.mlnToolTipText (
7565: ComponentFactory.createImageButton (
7566: LnF.LNF_STEP_UNTIL_RETURN_IMAGE,
7567: LnF.LNF_STEP_UNTIL_RETURN_DISABLED_IMAGE,
7568: "Step until return", mpuDebugActionListener),
7569: "ja", "ステップアンティルリターン")
7570: );
7571: }
7572:
7573:
7574:
7575: public static JButton mpuMakeRunButton () {
7576: return mpuAddButtonStopped (
7577: Multilingual.mlnToolTipText (
7578: ComponentFactory.createImageButton (
7579: LnF.LNF_RUN_IMAGE,
7580: LnF.LNF_RUN_DISABLED_IMAGE,
7581: "Run", mpuDebugActionListener),
7582: "ja", "実行")
7583: );
7584: }
7585:
7586:
7587:
7588: public static <T extends AbstractButton> T mpuAddButtonRunning (T button) {
7589: button.setEnabled (mpuTask != null);
7590: mpuButtonsRunning.add (button);
7591: return button;
7592: }
7593:
7594:
7595:
7596: public static <T extends AbstractButton> T mpuAddButtonStopped (T button) {
7597: button.setEnabled (mpuTask == null);
7598: mpuButtonsStopped.add (button);
7599: return button;
7600: }
7601:
7602:
7603:
7604:
7605:
7606:
7607:
7608:
7609:
7610:
7611:
7612:
7613:
7614:
7615:
7616:
7617: public static final int EMX_OPCODE_BASE = 0x4e00;
7618: public static final int EMX_OPCODE_HFSBOOT = EMX_OPCODE_BASE + 0x00;
7619: public static final int EMX_OPCODE_HFSINST = EMX_OPCODE_BASE + 0x01;
7620: public static final int EMX_OPCODE_HFSSTR = EMX_OPCODE_BASE + 0x02;
7621: public static final int EMX_OPCODE_HFSINT = EMX_OPCODE_BASE + 0x03;
7622: public static final int EMX_OPCODE_EMXNOP = EMX_OPCODE_BASE + 0x04;
7623: public static final int EMX_OPCODE_EMXWAIT = EMX_OPCODE_BASE + 0x05;
7624:
7625: public static final String[] EMX_MNEMONIC_ARRAY = {
7626: "hfsboot",
7627: "hfsinst",
7628: "hfsstr",
7629: "hfsint",
7630: "emxnop",
7631: "emxwait",
7632: };
7633:
7634:
7635:
7636:
7637: public static void emxNop () {
7638: if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x00007140) {
7639: int head = regRn[9];
7640: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7641:
7642:
7643: emxPatchPCM8A (head, tail);
7644:
7645:
7646: emxCheckRSDRV202 (head, tail);
7647: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000716c) {
7648: int head = regRn[9];
7649: int tail = MC68060.mmuPeekLongData (0x00001c00, 1);
7650:
7651:
7652: emxPatch060turbosys (head, tail);
7653:
7654:
7655: if (Z8530.SCC_FSX_MOUSE) {
7656: emxCheckFSX (head, tail);
7657: }
7658:
7659:
7660: if (HFS.HFS_USE_TWENTY_ONE) {
7661: emxCheckTwentyOne (head, tail);
7662: }
7663:
7664:
7665: LabeledAddress.lblClear ();
7666: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000972c) {
7667: int head = regRn[8] + 256;
7668:
7669: int tail = MC68060.mmuPeekLong (head - 208, 1);
7670:
7671:
7672: emxCheckBSIO021 (head, tail);
7673:
7674:
7675: emxPatchPCM8A (head, tail);
7676:
7677:
7678: emxCheckTMSIO031 (head, tail);
7679:
7680:
7681: LabeledAddress.lblClear ();
7682:
7683:
7684: if (dbgStopAtStart) {
7685: InstructionBreakPoint.ibpInstant (regRn[12], 0);
7686: }
7687: } else if (MainMemory.mmrHumanVersion == 0x0302 && regPC0 == 0x0000a090) {
7688: int head = regRn[8] + 256;
7689: int tail = MC68060.mmuPeekLongData (regRn[8] + 8, 1);
7690: String name = MC68060.mmuPeekStringZ (head - 60, 1);
7691: if (name.equalsIgnoreCase ("fsx.x")) {
7692:
7693:
7694: if (Z8530.SCC_FSX_MOUSE) {
7695: emxCheckFSX (head, tail);
7696: }
7697: }
7698: if (name.equalsIgnoreCase ("TwentyOne.x")) {
7699:
7700:
7701: if (HFS.HFS_USE_TWENTY_ONE) {
7702: emxCheckTwentyOne (head, tail);
7703: }
7704: }
7705: }
7706: }
7707:
7708: public static final int[] emxPCM8AFFMap = {
7709: 0x00000138, 0x000001f6, 0x00000394, 0x000011ec, 0x0000120a, 0x00001400, 0x00001814, 0x00001870, 0x00001882, 0x0000188a,
7710: 0x00001892, 0x000018a2, 0x000018a8, 0x000018ca, 0x000018d4, 0x000018e0, 0x000018e8, 0x00001908, 0x000019e4, 0x00001afa,
7711: 0x00001b58, 0x00001b7c, 0x00001bac, 0x00001c38, 0x00001ccc, 0x000021f8, 0x00002250, 0x00002258, 0x00002290, 0x000022a6,
7712: 0x000022b0, 0x000022c0, 0x000022c8, 0x000022de, 0x000022ea, 0x000030c8, 0x000030de, 0x000030e6, 0x000030ea, 0x000030f6,
7713: 0x00003112, 0x00003188, 0x0000334c, 0x0000338a, 0x000033a2, 0x000033c4, 0x000033d0, 0x0000341a, 0x00003428, 0x00003496,
7714: 0x000034a6, 0x000034d6, 0x0000fe0e, 0x0000fec8, 0x0000feec, 0x0000ff46, 0x0000ff4e,
7715: };
7716:
7717:
7718:
7719: public static void emxPatchPCM8A (int head, int tail) {
7720: if (head + 0x0000ff60 <= tail &&
7721: MC68060.mmuPeekLongData (head + 0x10f8, 1) == 0x50434d38 &&
7722: MC68060.mmuPeekLongData (head + 0x10fc, 1) == 0x41313032) {
7723: System.out.println (Multilingual.mlnJapanese ?
7724: "PCM8A.X 1.02 があります" :
7725: "PCM8A.X 1.02 exists");
7726: int patched = 0;
7727: int failed = 0;
7728:
7729: for (int offset : emxPCM8AFFMap) {
7730: if (MC68060.mmuPeekByteZeroData (head + offset, 1) == 0xff) {
7731: MC68060.mmuPokeByteData (head + offset, 0x00, 1);
7732: patched++;
7733: } else {
7734: failed++;
7735: }
7736: }
7737: if (patched != 0) {
7738: System.out.printf (Multilingual.mlnJapanese ?
7739: "PCM8A.X 1.02 にパッチをあてました (%d/%d)\n" :
7740: "PCM8A.X 1.02 was patched (%d/%d)\n",
7741: patched, patched + failed);
7742: }
7743: }
7744: }
7745:
7746:
7747:
7748: public static void emxPatch060turbosys (int head, int tail) {
7749:
7750:
7751:
7752:
7753: if (head + 0x00002000 <= tail &&
7754: MC68060.mmuPeekLongData (head + 0x00000ec0, 1) == 0x203c302e &&
7755: MC68060.mmuPeekLongData (head + 0x00000ec4, 1) == 0x3536227c &&
7756: MC68060.mmuPeekLongData (head + 0x00000ec8, 1) == 0x30363054) {
7757: System.out.println (Multilingual.mlnJapanese ?
7758: "060turbo.sys 0.56 があります" :
7759: "060turbo.sys 0.56 exists");
7760:
7761:
7762:
7763: int patched = 0;
7764: int failed = 0;
7765: if (MC68060.mmuPeekLongData (head + 0x000021e6, 1) == 0x08f90004 &&
7766: MC68060.mmuPeekLongData (head + 0x000021ea, 1) == 0x00ed0070) {
7767: MC68060.mmuPokeWordData (head + 0x000021e6, 0x0839, 1);
7768: patched++;
7769: } else {
7770: failed++;
7771: }
7772: System.out.printf (Multilingual.mlnJapanese ?
7773: "060turbo.sys 0.56 にパッチをあてました (%d/%d)\n" :
7774: "060turbo.sys 0.56 was patched (%d/%d)\n",
7775: patched, patched + failed);
7776: }
7777: }
7778:
7779:
7780:
7781: public static void emxCheckFSX (int head, int tail) {
7782: if (Z8530.SCC_FSX_MOUSE) {
7783: if (head + 0x00063200 <= tail &&
7784: "\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))) {
7785: System.out.println (Multilingual.mlnJapanese ?
7786: "FSX.X 3.10 があります" :
7787: "FSX.X 3.10 exists");
7788: Z8530.sccFSXMouseHook = head + 0x04f82a;
7789: Z8530.sccFSXMouseWork = head + 0x063184;
7790: }
7791: }
7792: }
7793:
7794:
7795:
7796:
7797:
7798:
7799: public static void emxCheckRSDRV202 (int head, int tail) {
7800: if (head + 0x000ea6 <= tail &&
7801: MC68060.mmuPeekEquals (head + 0x000e4e, "RS-232C DRIVER for X68000 version 2.02")) {
7802: if (RS232CTerminal.trmRSDRV202Head != head) {
7803: RS232CTerminal.trmRSDRV202Head = head;
7804: int[] patchData = {
7805:
7806:
7807: 0x05f8, 0x000a, 0x000b,
7808:
7809: 0x0600, 0xd040, 0x2048,
7810:
7811: 0x060e, 0x3030, 0x4e90,
7812: 0x0610, 0x0000, 0x2048,
7813:
7814: 0x074e, 0x0821, 0x2041,
7815: 0x0750, 0x0410, 0x3200,
7816: 0x0752, 0x0207, 0x303c,
7817: 0x0754, 0x0102, 0x0823,
7818: 0x0756, 0x0080, 0xe268,
7819: 0x0758, 0x003f, 0x72fe,
7820: 0x075a, 0x001f, 0xd141,
7821: 0x075c, 0x000e, 0x2208,
7822: 0x075e, 0x0006, 0x4e75,
7823:
7824:
7825: 0x0ab0, 0x0040, 0x0400,
7826: 0x0ad2, 0x0040, 0x0400,
7827: 0x0af4, 0x0040, 0x0400,
7828: 0x0b16, 0x0040, 0x0400,
7829: 0x0b38, 0x0040, 0x0400,
7830:
7831:
7832: 0x0cae, 0x0009, 0x000b,
7833: };
7834: int patched = 0;
7835: int failed = 0;
7836: for (int i = 0; i < patchData.length; i += 3) {
7837: int a = head + patchData[i];
7838: int b = patchData[i + 1];
7839: int c = patchData[i + 2];
7840: int d = MC68060.mmuPeekWordZeroData (a, 1);
7841: if (d == b) {
7842: MC68060.mmuPokeWordData (a, c, 1);
7843: patched++;
7844: } else if (d != c) {
7845: failed++;
7846: }
7847: }
7848: System.out.printf ("RSDRV.SYS 2.02 found at %08X and patched (%d/%d)\n", head, patched, patched + failed);
7849: }
7850: }
7851: }
7852:
7853:
7854:
7855:
7856:
7857: public static void emxCheckTMSIO031 (int head, int tail) {
7858: if (head + 0x000fc4 <= tail &&
7859: MC68060.mmuPeekEquals (head + 0x000d1c, "TMSIO version 0.31 Copyright (C) 1990-93 by Miki Hoshino")) {
7860: if (RS232CTerminal.trmTMSIO031Head != head) {
7861: RS232CTerminal.trmTMSIO031Head = head;
7862: System.out.printf ("TMSIO 0.31 found at %08X\n", head);
7863: }
7864: }
7865: }
7866:
7867:
7868:
7869:
7870:
7871: public static void emxCheckBSIO021 (int head, int tail) {
7872: if (head + 0x001c2c <= tail &&
7873: MC68060.mmuPeekEquals (head + 0x001a66, "BSIO version 0.21 Copyright (C) 1994 By BAZU")) {
7874: if (RS232CTerminal.trmBSIO021Head != head) {
7875: RS232CTerminal.trmBSIO021Head = head;
7876: System.out.printf ("BSIO 0.21 found at %08X\n", head);
7877: }
7878: }
7879: }
7880:
7881:
7882:
7883: public static void emxCheckTwentyOne (int head, int tail) {
7884: if (HFS.HFS_USE_TWENTY_ONE &&
7885: head + 64 <= tail) {
7886: if (MainMemory.mmrTwentyOneOptionAddress != 0 ||
7887: MainMemory.mmrHumanVersion <= 0) {
7888: return;
7889: }
7890: int name1 = MC68060.mmuPeekLongData (head + 14, 1);
7891: if (name1 == ('*' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7892: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7893: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '*')) {
7894: MainMemory.mmrTwentyOneOptionAddress = -1;
7895: }
7896: } else if (name1 == ('?' << 24 | 'T' << 16 | 'w' << 8 | 'e')) {
7897: int name2 = MC68060.mmuPeekLongData (head + 18, 1);
7898: if (name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | '?') ||
7899: name2 == ('n' << 24 | 't' << 16 | 'y' << 8 | 'E')) {
7900: System.out.println (Multilingual.mlnJapanese ?
7901: "TwentyOne.x があります" :
7902: "TwentyOne.x exists");
7903: MainMemory.mmrTwentyOneOptionAddress = head + 22;
7904: }
7905: }
7906: }
7907: }
7908:
7909:
7910:
7911:
7912:
7913:
7914:
7915:
7916:
7917:
7918:
7919:
7920:
7921:
7922:
7923:
7924:
7925:
7926:
7927:
7928:
7929:
7930:
7931:
7932:
7933:
7934:
7935:
7936:
7937:
7938:
7939:
7940:
7941:
7942:
7943:
7944:
7945:
7946:
7947:
7948:
7949:
7950:
7951:
7952:
7953:
7954:
7955:
7956:
7957:
7958:
7959: public static final boolean IRP_BITREV_REVERSE = false;
7960: public static final boolean IRP_BITREV_SHIFT = false;
7961: public static final boolean IRP_BITREV_TABLE = true;
7962:
7963: public static final boolean IRP_MOVEM_MAINMEMORY = true;
7964: public static final boolean IRP_MOVEM_EXPAND = false;
7965: public static final boolean IRP_MOVEM_LOOP = false;
7966: public static final boolean IRP_MOVEM_SHIFT_LEFT = false;
7967: public static final boolean IRP_MOVEM_SHIFT_RIGHT = true;
7968: public static final boolean IRP_MOVEM_ZEROS = false;
7969:
7970:
7971: public static void irpReset () {
7972: long t = System.nanoTime ();
7973:
7974: CRTC.crtReset ();
7975: VideoController.vcnReset ();
7976: HD63450.dmaReset ();
7977: MC68901.mfpReset ();
7978: Keyboard.kbdReset ();
7979: RP5C15.rtcReset ();
7980: PrinterPort.prnReset ();
7981: SoundSource.sndReset ();
7982: OPM.opmReset ();
7983: ADPCM.pcmReset ();
7984: FDC.fdcReset ();
7985: IOInterrupt.ioiReset ();
7986: eb2Reset ();
7987: if (HostCDROM.HCD_ENABLED) {
7988: HostCDROM.hcdReset ();
7989: }
7990: SPC.spcReset ();
7991: Z8530.sccReset ();
7992: RS232CTerminal.trmReset ();
7993: PPI.ppiReset ();
7994: HFS.hfsReset ();
7995: SpriteScreen.sprReset ();
7996:
7997: if (MercuryUnit.MU4_ON) {
7998: MercuryUnit.mu4Reset ();
7999: }
8000: xt3Reset ();
8001: SRAM.smrReset ();
8002: CONDevice.conReset ();
8003: TextCopy.txcReset ();
8004:
8005: mpuClockTime += Math.min (TMR_FREQ * 9 / 1000, (System.nanoTime () - t) * 1000L);
8006: }
8007:
8008:
8009:
8010:
8011:
8012:
8013:
8014:
8015:
8016:
8017:
8018:
8019:
8020:
8021:
8022:
8023:
8024:
8025:
8026:
8027:
8028:
8029:
8030:
8031:
8032:
8033:
8034:
8035:
8036:
8037:
8038:
8039:
8040:
8041:
8042:
8043:
8044:
8045:
8046:
8047:
8048:
8049:
8050:
8051:
8052:
8053:
8054:
8055:
8056:
8057:
8058:
8059:
8060:
8061:
8062:
8063:
8064:
8065:
8066:
8067:
8068:
8069:
8070:
8071:
8072:
8073:
8074:
8075:
8076:
8077:
8078:
8079:
8080:
8081:
8082:
8083:
8084:
8085:
8086:
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:
8127:
8128:
8129:
8130:
8131:
8132:
8133:
8134:
8135:
8136:
8137:
8138:
8139:
8140:
8141:
8142:
8143:
8144:
8145:
8146:
8147:
8148:
8149:
8150:
8151:
8152:
8153:
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:
8191:
8192:
8193:
8194:
8195:
8196:
8197:
8198:
8199:
8200:
8201:
8202:
8203:
8204:
8205:
8206:
8207:
8208:
8209:
8210:
8211:
8212:
8213:
8214:
8215:
8216:
8217:
8218:
8219:
8220:
8221:
8222:
8223:
8224:
8225:
8226:
8227:
8228:
8229:
8230:
8231:
8232:
8233:
8234:
8235:
8236:
8237:
8238:
8239:
8240:
8241:
8242:
8243:
8244:
8245:
8246:
8247:
8248:
8249:
8250:
8251:
8252:
8253:
8254:
8255:
8256:
8257:
8258:
8259:
8260:
8261:
8262:
8263:
8264:
8265:
8266:
8267:
8268:
8269:
8270:
8271:
8272:
8273:
8274:
8275:
8276:
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:
8365:
8366:
8367:
8368:
8369:
8370:
8371:
8372:
8373:
8374:
8375:
8376:
8377:
8378:
8379:
8380:
8381:
8382:
8383:
8384:
8385:
8386:
8387:
8388:
8389:
8390:
8391:
8392:
8393:
8394:
8395:
8396:
8397:
8398:
8399:
8400:
8401:
8402:
8403:
8404:
8405:
8406:
8407:
8408:
8409:
8410:
8411:
8412:
8413:
8414:
8415:
8416:
8417:
8418:
8419:
8420:
8421:
8422:
8423:
8424:
8425:
8426:
8427:
8428:
8429:
8430:
8431:
8432:
8433:
8434:
8435:
8436:
8437:
8438:
8439:
8440:
8441:
8442:
8443:
8444:
8445:
8446:
8447:
8448:
8449:
8450:
8451:
8452:
8453:
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:
8479:
8480:
8481:
8482:
8483:
8484:
8485:
8486:
8487:
8488:
8489:
8490:
8491:
8492:
8493:
8494:
8495:
8496:
8497:
8498:
8499:
8500:
8501:
8502:
8503:
8504:
8505:
8506:
8507:
8508:
8509:
8510:
8511:
8512:
8513:
8514:
8515:
8516:
8517:
8518:
8519:
8520:
8521:
8522:
8523:
8524:
8525:
8526:
8527:
8528:
8529:
8530:
8531:
8532:
8533:
8534:
8535:
8536:
8537:
8538:
8539:
8540:
8541:
8542:
8543:
8544:
8545:
8546:
8547:
8548:
8549:
8550:
8551:
8552:
8553:
8554:
8555:
8556:
8557:
8558:
8559:
8560:
8561:
8562:
8563:
8564:
8565:
8566:
8567:
8568:
8569:
8570:
8571:
8572:
8573:
8574:
8575:
8576:
8577:
8578:
8579:
8580:
8581:
8582:
8583:
8584:
8585:
8586:
8587:
8588:
8589:
8590:
8591:
8592:
8593: 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);
8594:
8595: public static final boolean EFA_SEPARATE_AR = false;
8596:
8597:
8598:
8599:
8600:
8601:
8602: public static final boolean BUS_SPLIT_UNALIGNED_LONG = false;
8603:
8604:
8605: public static final int BUS_MOTHER_BITS = 24;
8606: public static final int BUS_MOTHER_SIZE = BUS_MOTHER_BITS < 32 ? 1 << BUS_MOTHER_BITS : 0;
8607: public static final int BUS_MOTHER_MASK = BUS_MOTHER_SIZE - 1;
8608:
8609: public static final int BUS_ARRAY_SIZE = BUS_MOTHER_SIZE;
8610:
8611:
8612: public static final int BUS_PAGE_BITS = 12;
8613: public static final int BUS_PAGE_SIZE = 1 << BUS_PAGE_BITS;
8614: public static final int BUS_PAGE_COUNT = 1 << (32 - BUS_PAGE_BITS);
8615:
8616:
8617: public static final int MPU_SS_BYTE = 0;
8618: public static final int MPU_SS_WORD = 1;
8619: public static final int MPU_SS_LONG = 2;
8620:
8621:
8622: public static final int MPU_WR_WRITE = 0;
8623: public static final int MPU_WR_READ = 1;
8624:
8625:
8626: public static final int MPU_US_USER = 0;
8627: public static final int MPU_US_SUPERVISOR = 1;
8628:
8629:
8630: public static final MemoryMappedDevice[] busUserMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8631: public static final MemoryMappedDevice[] busSuperMap = new MemoryMappedDevice[BUS_PAGE_COUNT];
8632: public static MemoryMappedDevice[] busMemoryMap;
8633:
8634:
8635: public static boolean busHimem68000;
8636:
8637:
8638: public static final int BUS_HIGH_MEMORY_START = 0x01000000;
8639: public static int busHighMemorySize;
8640: public static byte[] busHighMemoryArray;
8641: public static boolean busHighMemorySaveOn;
8642: public static boolean busHighMemory060turboOn;
8643:
8644:
8645: public static final int BUS_LOCAL_MEMORY_START = 0x10000000;
8646: public static int busLocalMemorySize;
8647: public static byte[] busLocalMemoryArray;
8648: public static boolean busLocalMemorySaveOn;
8649:
8650:
8651: public static final byte[] BUS_DUMMY_MEMORY_ARRAY = new byte[0];
8652: public static int busRequestExMemoryStart;
8653: public static int busRequestExMemorySize;
8654: public static byte[] busRequestExMemoryArray;
8655: public static int busExMemoryStart;
8656: public static int busExMemorySize;
8657: public static byte[] busExMemoryArray;
8658:
8659:
8660: public static boolean busRequestCutFC2Pin;
8661: public static boolean busCutFC2Pin;
8662:
8663:
8664:
8665: public static void busInit () {
8666:
8667:
8668: if (!DataBreakPoint.DBP_ON) {
8669: busMemoryMap = busSuperMap;
8670: }
8671:
8672:
8673: int highMemorySizeMB = Settings.sgsGetInt ("highmemory");
8674: busHighMemorySize = highMemorySizeMB == 16 ? highMemorySizeMB << 20 : 0 << 20;
8675: if (busHighMemorySize == 0) {
8676: System.out.println (Multilingual.mlnJapanese ?
8677: "X68030/Xellent30 のハイメモリはありません" :
8678: "X68030/Xellent30 high memory does not exists");
8679: } else {
8680: System.out.printf (Multilingual.mlnJapanese ?
8681: "X68030/Xellent30 のハイメモリのサイズは %dMB です\n" :
8682: "X68030/Xellent30 high memory size is %dMB\n",
8683: busHighMemorySize >> 20);
8684: }
8685: busHighMemoryArray = new byte[busHighMemorySize];
8686:
8687: busHimem68000 = Settings.sgsGetOnOff ("himem68000");
8688:
8689: busHighMemorySaveOn = Settings.sgsGetOnOff ("highmemorysave");
8690: busHighMemory060turboOn = Settings.sgsGetOnOff ("highmemory060turbo");
8691:
8692: byte[] highMemoryArray = Settings.sgsGetData ("highmemorydata");
8693: if (busHighMemorySize != 0) {
8694: if (highMemoryArray.length != 0) {
8695: System.out.println (Multilingual.mlnJapanese ?
8696: "X68030/Xellent30 のハイメモリのデータを復元します" :
8697: "X68030/Xellent30 high memory data is restored");
8698: System.arraycopy (highMemoryArray, 0, busHighMemoryArray, 0, Math.min (highMemoryArray.length, busHighMemorySize));
8699: } else {
8700: System.out.println (Multilingual.mlnJapanese ?
8701: "X68030/Xellent30 のハイメモリをゼロクリアします" :
8702: "X68030/Xellent30 high memory is zero-cleared");
8703: }
8704: if (highMemoryArray.length < busHighMemorySize) {
8705: Arrays.fill (busHighMemoryArray, highMemoryArray.length, busHighMemorySize, (byte) 0);
8706: }
8707: }
8708:
8709:
8710: int localMemorySizeMB = Settings.sgsGetInt ("localmemory");
8711: busLocalMemorySize = (localMemorySizeMB == 16 ||
8712: localMemorySizeMB == 32 ||
8713: localMemorySizeMB == 64 ||
8714: localMemorySizeMB == 128 ||
8715: localMemorySizeMB == 256 ||
8716: localMemorySizeMB == 384 ||
8717: localMemorySizeMB == 512 ||
8718: localMemorySizeMB == 768 ?
8719: localMemorySizeMB << 20 :
8720: 128 << 20);
8721: if (busLocalMemorySize == 0) {
8722: System.out.println (Multilingual.mlnJapanese ?
8723: "060turbo のハイメモリはありません" :
8724: "060turbo high memory does not exists");
8725: } else {
8726: System.out.printf (Multilingual.mlnJapanese ?
8727: "060turbo のハイメモリのサイズは %dMB です\n" :
8728: "060turbo high memory size is %dMB\n",
8729: busLocalMemorySize >> 20);
8730: }
8731: busLocalMemoryArray = new byte[busLocalMemorySize];
8732:
8733: busLocalMemorySaveOn = Settings.sgsGetOnOff ("localmemorysave");
8734:
8735: byte[] localMemoryArray = Settings.sgsGetData ("localmemorydata");
8736: if (busLocalMemorySize != 0) {
8737: if (localMemoryArray.length != 0) {
8738: System.out.println (Multilingual.mlnJapanese ?
8739: "060turbo のハイメモリのデータを復元します" :
8740: "060turbo high memory data is restored");
8741: System.arraycopy (localMemoryArray, 0, busLocalMemoryArray, 0, Math.min (localMemoryArray.length, busLocalMemorySize));
8742: } else {
8743: System.out.println (Multilingual.mlnJapanese ?
8744: "060turbo のハイメモリをゼロクリアします" :
8745: "060turbo high memory is zero-cleared");
8746: }
8747: if (localMemoryArray.length < busLocalMemorySize) {
8748: Arrays.fill (busLocalMemoryArray, localMemoryArray.length, busLocalMemorySize, (byte) 0);
8749: }
8750: }
8751:
8752:
8753: busExMemoryStart = busRequestExMemoryStart = 0x10000000;
8754: busExMemorySize = busRequestExMemorySize = 0 << 20;
8755: busExMemoryArray = busRequestExMemoryArray = BUS_DUMMY_MEMORY_ARRAY;
8756:
8757:
8758: busRequestCutFC2Pin = Settings.sgsGetOnOff ("cutfc2pin");
8759: busCutFC2Pin = !busRequestCutFC2Pin;
8760:
8761: busUpdateMemoryMap ();
8762:
8763: }
8764:
8765:
8766:
8767: public static void busTini () {
8768: Settings.sgsPutOnOff ("himem68000", busHimem68000);
8769: Settings.sgsPutInt ("highmemory", busHighMemorySize >>> 20);
8770: Settings.sgsPutOnOff ("highmemorysave", busHighMemorySaveOn);
8771: Settings.sgsPutOnOff ("highmemory060turbo", busHighMemory060turboOn);
8772: Settings.sgsPutData ("highmemorydata",
8773: busHighMemorySaveOn ?
8774: Arrays.copyOf (busHighMemoryArray, busHighMemoryArray.length) :
8775: new byte[0]);
8776: Settings.sgsPutInt ("localmemory", busLocalMemorySize >>> 20);
8777: Settings.sgsPutOnOff ("localmemorysave", busLocalMemorySaveOn);
8778: Settings.sgsPutData ("localmemorydata",
8779: busLocalMemorySaveOn ?
8780: Arrays.copyOf (busLocalMemoryArray, busLocalMemoryArray.length) :
8781: new byte[0]);
8782: Settings.sgsPutOnOff ("cutfc2pin", busRequestCutFC2Pin);
8783: }
8784:
8785: public static void busUpdateMemoryMap () {
8786: if (busExMemoryStart == busRequestExMemoryStart &&
8787: busExMemorySize == busRequestExMemorySize &&
8788: busExMemoryArray == busRequestExMemoryArray &&
8789: busExMemoryArray.length == busExMemorySize &&
8790: busCutFC2Pin == busRequestCutFC2Pin) {
8791: return;
8792: }
8793:
8794: busExMemoryStart = busRequestExMemoryStart;
8795: busExMemorySize = busRequestExMemorySize;
8796: busExMemoryArray = busRequestExMemoryArray;
8797: if (busExMemoryArray.length != busExMemorySize) {
8798: byte[] newArray = new byte[busExMemorySize];
8799: int copySize = Math.min (busExMemoryArray.length, busExMemorySize);
8800: if (copySize > 0) {
8801: System.arraycopy (busExMemoryArray, 0, newArray, 0, copySize);
8802: }
8803: if (busExMemoryArray == busHighMemoryArray) {
8804: busHighMemoryArray = newArray;
8805: } else if (busExMemoryArray == busLocalMemoryArray) {
8806: busLocalMemoryArray = newArray;
8807: }
8808: busExMemoryArray = newArray;
8809: }
8810:
8811: busCutFC2Pin = busRequestCutFC2Pin;
8812:
8813:
8814:
8815:
8816:
8817:
8818:
8819:
8820:
8821:
8822:
8823:
8824: busSuper (MemoryMappedDevice.MMD_MMR, 0x00000000, 0x00002000);
8825: busUser ( MemoryMappedDevice.MMD_MMR, 0x00002000, 0x00c00000);
8826:
8827:
8828:
8829:
8830:
8831:
8832:
8833:
8834:
8835:
8836:
8837:
8838:
8839:
8840:
8841:
8842:
8843:
8844:
8845:
8846:
8847:
8848:
8849:
8850: busSuper (MemoryMappedDevice.MMD_GE0, 0x00c00000, 0x00c80000);
8851: busSuper (MemoryMappedDevice.MMD_GE1, 0x00c80000, 0x00d00000);
8852: busSuper (MemoryMappedDevice.MMD_GE2, 0x00d00000, 0x00d80000);
8853: busSuper (MemoryMappedDevice.MMD_GE3, 0x00d80000, 0x00e00000);
8854:
8855:
8856:
8857:
8858: busSuper (MemoryMappedDevice.MMD_TXT, 0x00e00000, 0x00e80000);
8859:
8860:
8861:
8862:
8863: busSuper (MemoryMappedDevice.MMD_CRT, 0x00e80000, 0x00e82000);
8864:
8865:
8866:
8867:
8868:
8869: busSuper (MemoryMappedDevice.MMD_VCN, 0x00e82000, 0x00e84000);
8870:
8871:
8872:
8873:
8874: busSuper (MemoryMappedDevice.MMD_DMA, 0x00e84000, 0x00e86000);
8875:
8876:
8877:
8878:
8879: busSuper (MemoryMappedDevice.MMD_SVS, 0x00e86000, 0x00e88000);
8880:
8881:
8882:
8883:
8884: busSuper (MemoryMappedDevice.MMD_MFP, 0x00e88000, 0x00e8a000);
8885:
8886:
8887:
8888:
8889: busSuper (MemoryMappedDevice.MMD_RTC_FIRST, 0x00e8a000, 0x00e8c000);
8890:
8891:
8892:
8893:
8894: busSuper (MemoryMappedDevice.MMD_PRN, 0x00e8c000, 0x00e8e000);
8895:
8896:
8897:
8898:
8899: busSuper (MemoryMappedDevice.MMD_SYS, 0x00e8e000, 0x00e90000);
8900:
8901:
8902:
8903:
8904: busSuper (MemoryMappedDevice.MMD_OPM, 0x00e90000, 0x00e92000);
8905:
8906:
8907:
8908:
8909: busSuper (MemoryMappedDevice.MMD_PCM, 0x00e92000, 0x00e94000);
8910:
8911:
8912:
8913:
8914: busSuper (MemoryMappedDevice.MMD_FDC, 0x00e94000, 0x00e96000);
8915:
8916:
8917:
8918:
8919:
8920: busSuper (MemoryMappedDevice.MMD_HDC, 0x00e96000, 0x00e98000);
8921:
8922:
8923:
8924:
8925: busSuper (MemoryMappedDevice.MMD_SCC, 0x00e98000, 0x00e9a000);
8926:
8927:
8928:
8929:
8930: busSuper (MemoryMappedDevice.MMD_PPI, 0x00e9a000, 0x00e9c000);
8931:
8932:
8933:
8934:
8935: busSuper (MemoryMappedDevice.MMD_IOI, 0x00e9c000, 0x00e9e000);
8936:
8937:
8938:
8939:
8940:
8941:
8942:
8943:
8944:
8945: busSuper (MemoryMappedDevice.MMD_XB1, 0x00e9e000, 0x00ea0000);
8946:
8947:
8948:
8949:
8950:
8951: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ea0000, 0x00eae000);
8952:
8953:
8954:
8955:
8956:
8957:
8958:
8959:
8960:
8961:
8962:
8963:
8964:
8965:
8966:
8967: busSuper (MemoryMappedDevice.MMD_XB2, 0x00eae000, 0x00eb0000);
8968:
8969:
8970:
8971:
8972:
8973:
8974:
8975:
8976: busSuper (MemoryMappedDevice.MMD_SPR, 0x00eb0000, 0x00ec0000);
8977:
8978:
8979:
8980:
8981:
8982:
8983:
8984:
8985:
8986:
8987:
8988:
8989:
8990: busSuper (MemoryMappedDevice.MMD_XB3, 0x00ec0000, 0x00ed0000);
8991:
8992:
8993:
8994:
8995:
8996:
8997: busSuper (MemoryMappedDevice.MMD_SMR, 0x00ed0000, 0x00ed0000 + 16384);
8998: busSuper (MemoryMappedDevice.MMD_NUL, 0x00ed0000 + 16384, 0x00ed0000 + 65536);
8999:
9000:
9001:
9002:
9003:
9004:
9005:
9006:
9007: busSuper (MemoryMappedDevice.MMD_XB4, 0x00ee0000, 0x00f00000);
9008:
9009:
9010:
9011:
9012:
9013:
9014:
9015:
9016:
9017:
9018: busSuper (MemoryMappedDevice.MMD_ROM, 0x00f00000, 0x00f40000);
9019:
9020:
9021:
9022:
9023:
9024:
9025:
9026: busSuper (MemoryMappedDevice.MMD_ROM, 0x00f40000, 0x00fc0000);
9027:
9028:
9029:
9030:
9031:
9032:
9033:
9034:
9035:
9036:
9037:
9038:
9039:
9040:
9041: busSuper (MemoryMappedDevice.MMD_ROM, 0x00fc0000, 0x01000000);
9042:
9043: }
9044:
9045: public static void busReset () {
9046: if (regSRS != 0) {
9047: if (DataBreakPoint.DBP_ON) {
9048: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpSuperMap;
9049: } else {
9050: busMemoryMap = busSuperMap;
9051: }
9052: } else {
9053: if (DataBreakPoint.DBP_ON) {
9054: DataBreakPoint.dbpMemoryMap = DataBreakPoint.dbpUserMap;
9055: } else {
9056: busMemoryMap = busUserMap;
9057: }
9058: }
9059: }
9060:
9061:
9062:
9063:
9064:
9065: public static void busUser (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
9066: if (MC68060.CAT_ON) {
9067: if (Model.MPU_MC68LC060 <= currentMPU) {
9068: mmd = (mmd == MemoryMappedDevice.MMD_MMR ? MemoryMappedDevice.MMD_MM6 :
9069: mmd == MemoryMappedDevice.MMD_ROM ? MemoryMappedDevice.MMD_RO6 :
9070: mmd);
9071: }
9072: }
9073: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
9074: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
9075: if (false &&
9076: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
9077: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
9078: System.out.printf ("ERROR: busUser (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
9079: }
9080: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
9081: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
9082: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
9083: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
9084: int startPage = blockStartPage + motherStartPage;
9085: int endPage = blockStartPage + motherEndPage;
9086: for (int page = startPage; page < endPage; page++) {
9087: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
9088: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
9089: if (MC68060.CAT_ON) {
9090: if (Model.MPU_MC68LC060 <= currentMPU &&
9091: isExMemory) {
9092: superMmd = MemoryMappedDevice.MMD_XM6;
9093: }
9094: }
9095: busUserMap[page] = busSuperMap[page] = superMmd;
9096: if (InstructionBreakPoint.IBP_ON) {
9097: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
9098: InstructionBreakPoint.ibpUserMap[page] = superMmd;
9099: }
9100: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
9101: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
9102: }
9103: }
9104: if (DataBreakPoint.DBP_ON) {
9105: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
9106: DataBreakPoint.dbpUserMap[page] = superMmd;
9107: }
9108: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
9109: DataBreakPoint.dbpSuperMap[page] = superMmd;
9110: }
9111: }
9112: }
9113: }
9114: }
9115:
9116:
9117:
9118:
9119:
9120: public static void busSuper (MemoryMappedDevice mmd, int motherStartAddress, int motherEndAddress) {
9121: if (MC68060.CAT_ON) {
9122: if (Model.MPU_MC68LC060 <= currentMPU) {
9123: mmd = (mmd == MemoryMappedDevice.MMD_MMR ? MemoryMappedDevice.MMD_MM6 :
9124: mmd == MemoryMappedDevice.MMD_ROM ? MemoryMappedDevice.MMD_RO6 :
9125: mmd);
9126: }
9127: }
9128: int motherStartPage = motherStartAddress >>> BUS_PAGE_BITS;
9129: int motherEndPage = motherEndAddress >>> BUS_PAGE_BITS;
9130: if (false &&
9131: (motherStartPage << BUS_PAGE_BITS != motherStartAddress ||
9132: motherEndPage << BUS_PAGE_BITS != motherEndAddress)) {
9133: System.out.printf ("ERROR: busSuper (\"%s\", 0x%08x, 0x%08x)\n", mmd.toString (), motherStartAddress, motherEndAddress);
9134: }
9135: int exMemoryStartPage = busExMemoryStart >>> BUS_PAGE_BITS;
9136: int exMemoryEndPage = exMemoryStartPage + (busExMemorySize >>> BUS_PAGE_BITS);
9137: for (int block = 0; block < 1 << 32 - BUS_MOTHER_BITS; block++) {
9138: int blockStartPage = block << BUS_MOTHER_BITS - BUS_PAGE_BITS;
9139: int startPage = blockStartPage + motherStartPage;
9140: int endPage = blockStartPage + motherEndPage;
9141: for (int page = startPage; page < endPage; page++) {
9142: boolean isExMemory = exMemoryStartPage <= page && page < exMemoryEndPage;
9143: MemoryMappedDevice userMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : busCutFC2Pin ? mmd : MemoryMappedDevice.MMD_NUL;
9144: MemoryMappedDevice superMmd = isExMemory ? MemoryMappedDevice.MMD_XMM : mmd;
9145: if (MC68060.CAT_ON) {
9146: if (Model.MPU_MC68LC060 <= currentMPU &&
9147: isExMemory) {
9148: userMmd = MemoryMappedDevice.MMD_XM6;
9149: superMmd = MemoryMappedDevice.MMD_XM6;
9150: }
9151: }
9152: busUserMap[page] = userMmd;
9153: busSuperMap[page] = superMmd;
9154: if (InstructionBreakPoint.IBP_ON) {
9155: if (InstructionBreakPoint.ibpUserMap[page] != MemoryMappedDevice.MMD_IBP) {
9156: InstructionBreakPoint.ibpUserMap[page] = userMmd;
9157: }
9158: if (InstructionBreakPoint.ibpSuperMap[page] != MemoryMappedDevice.MMD_IBP) {
9159: InstructionBreakPoint.ibpSuperMap[page] = superMmd;
9160: }
9161: }
9162: if (DataBreakPoint.DBP_ON) {
9163: if (DataBreakPoint.dbpUserMap[page] != MemoryMappedDevice.MMD_DBP) {
9164: DataBreakPoint.dbpUserMap[page] = userMmd;
9165: }
9166: if (DataBreakPoint.dbpSuperMap[page] != MemoryMappedDevice.MMD_DBP) {
9167: DataBreakPoint.dbpSuperMap[page] = superMmd;
9168: }
9169: }
9170: }
9171: }
9172: }
9173:
9174:
9175:
9176: public static byte busPbs (int a) {
9177: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a);
9178: }
9179:
9180:
9181:
9182: public static int busPbz (int a) {
9183: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a);
9184: }
9185:
9186:
9187:
9188: public static int busPws (int a) {
9189: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9190: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
9191: } else {
9192: int a1 = a + 1;
9193: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
9194: }
9195: }
9196:
9197:
9198:
9199: public static int busPwse (int a) {
9200: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a);
9201: }
9202:
9203:
9204:
9205: public static int busPwz (int a) {
9206: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9207: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
9208: } else {
9209: int a1 = a + 1;
9210: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) << 8 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPbz (a1);
9211: }
9212: }
9213:
9214:
9215:
9216: public static int busPwze (int a) {
9217: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a);
9218: }
9219:
9220:
9221:
9222: public static int busPls (int a) {
9223: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9224: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
9225: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9226: int a2 = a + 2;
9227: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPws (a) << 16 | busSuperMap[a2 >>> BUS_PAGE_BITS].mmdPwz (a2);
9228: } else {
9229: int a1 = a + 1;
9230: int a3 = a + 3;
9231: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPbs (a) << 24 | busSuperMap[a1 >>> BUS_PAGE_BITS].mmdPwz (a1) << 8 | busSuperMap[a3 >>> BUS_PAGE_BITS].mmdPbz (a3);
9232: }
9233: }
9234:
9235:
9236:
9237: public static int busPlsf (int a) {
9238: return busSuperMap[a >>> BUS_PAGE_BITS].mmdPls (a);
9239: }
9240:
9241:
9242:
9243: public static long busPqs (int a) {
9244: return (long) busPls (a) << 32 | busPls (a + 4) & 0xffffffffL;
9245: }
9246:
9247:
9248:
9249: public static int busSearchByte (int start, int end, int c) {
9250: for (int a = start; a < end; a++) {
9251: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) == c) {
9252: return a;
9253: }
9254: }
9255: return -1;
9256: }
9257: public static int busSearchWord (int start, int end, int c) {
9258: for (int a = start; a < end; a += 2) {
9259: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) == c) {
9260: return a;
9261: }
9262: }
9263: return -1;
9264: }
9265: public static int busSearchByteArray (int start, int end, int[] array) {
9266: int l = array.length;
9267: end -= l;
9268: int c = array[0];
9269: a:
9270: for (int a = start; a <= end; a++) {
9271: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPbz (a) != c) {
9272: continue a;
9273: }
9274: for (int i = 1, b = a + 1; i < l; i++, b++) {
9275: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPbz (b) != array[i]) {
9276: continue a;
9277: }
9278: }
9279: return a;
9280: }
9281: return -1;
9282: }
9283: public static int busSearchWordArray (int start, int end, int[] array) {
9284: int l = array.length;
9285: end -= l;
9286: int c = array[0];
9287: a:
9288: for (int a = start; a <= end; a += 2) {
9289: if (busSuperMap[a >>> BUS_PAGE_BITS].mmdPwz (a) != c) {
9290: continue a;
9291: }
9292: for (int i = 1, b = a + 2; i < l; i++, b += 2) {
9293: if (busSuperMap[b >>> BUS_PAGE_BITS].mmdPwz (b) != array[i]) {
9294: continue a;
9295: }
9296: }
9297: return a;
9298: }
9299: return -1;
9300: }
9301:
9302:
9303:
9304:
9305: public static byte busRbs (int a) throws M68kException {
9306: if (DataBreakPoint.DBP_ON) {
9307: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
9308: } else {
9309: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a);
9310: }
9311: }
9312:
9313:
9314:
9315: public static int busRbz (int a) throws M68kException {
9316: if (DataBreakPoint.DBP_ON) {
9317: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
9318: } else {
9319: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a);
9320: }
9321: }
9322:
9323:
9324:
9325: public static int busRws (int a) throws M68kException {
9326: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9327: if (DataBreakPoint.DBP_ON) {
9328: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
9329: } else {
9330: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
9331: }
9332: } else if (mpuIgnoreAddressError) {
9333: int a1 = a + 1;
9334: if (DataBreakPoint.DBP_ON) {
9335: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
9336: } else {
9337: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
9338: }
9339: } else {
9340: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9341: M68kException.m6eAddress = a;
9342: M68kException.m6eDirection = MPU_WR_READ;
9343: M68kException.m6eSize = MPU_SS_WORD;
9344: throw M68kException.m6eSignal;
9345: }
9346: }
9347:
9348:
9349:
9350:
9351: public static int busRwse (int a) throws M68kException {
9352: if (DataBreakPoint.DBP_ON) {
9353: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
9354: } else {
9355: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a);
9356: }
9357: }
9358:
9359:
9360:
9361: public static int busRwz (int a) throws M68kException {
9362: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9363: if (DataBreakPoint.DBP_ON) {
9364: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9365: } else {
9366: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9367: }
9368: } else if (mpuIgnoreAddressError) {
9369: int a1 = a + 1;
9370: if (DataBreakPoint.DBP_ON) {
9371: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
9372: } else {
9373: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbz (a) << 8 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRbz (a1);
9374: }
9375: } else {
9376: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9377: M68kException.m6eAddress = a;
9378: M68kException.m6eDirection = MPU_WR_READ;
9379: M68kException.m6eSize = MPU_SS_WORD;
9380: throw M68kException.m6eSignal;
9381: }
9382: }
9383:
9384:
9385:
9386:
9387: public static int busRwze (int a) throws M68kException {
9388: if (DataBreakPoint.DBP_ON) {
9389: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9390: } else {
9391: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRwz (a);
9392: }
9393: }
9394:
9395:
9396:
9397: public static int busRls (int a) throws M68kException {
9398: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9399: if (DataBreakPoint.DBP_ON) {
9400: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9401: } else {
9402: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9403: }
9404: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9405: int a2 = a + 2;
9406: if (BUS_SPLIT_UNALIGNED_LONG) {
9407: if (DataBreakPoint.DBP_ON) {
9408: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9409: } else {
9410: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9411: }
9412: } else {
9413: MemoryMappedDevice mmd;
9414: MemoryMappedDevice mmd2;
9415: if (DataBreakPoint.DBP_ON) {
9416: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9417: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9418: } else {
9419: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9420: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9421: }
9422: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
9423: }
9424: } else if (mpuIgnoreAddressError) {
9425: int a1 = a + 1;
9426: int a3 = a + 3;
9427: if (DataBreakPoint.DBP_ON) {
9428: 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);
9429: } else {
9430: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRbs (a) << 24 | busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdRwz (a1) << 8 | busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdRbz (a3);
9431: }
9432: } else {
9433: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9434: M68kException.m6eAddress = a;
9435: M68kException.m6eDirection = MPU_WR_READ;
9436: M68kException.m6eSize = MPU_SS_LONG;
9437: throw M68kException.m6eSignal;
9438: }
9439: }
9440:
9441:
9442:
9443:
9444: public static int busRlse (int a) throws M68kException {
9445: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9446: if (DataBreakPoint.DBP_ON) {
9447: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9448: } else {
9449: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9450: }
9451: } else {
9452: int a2 = a + 2;
9453: if (BUS_SPLIT_UNALIGNED_LONG) {
9454: if (DataBreakPoint.DBP_ON) {
9455: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9456: } else {
9457: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRws (a) << 16 | busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdRwz (a2);
9458: }
9459: } else {
9460: MemoryMappedDevice mmd;
9461: MemoryMappedDevice mmd2;
9462: if (DataBreakPoint.DBP_ON) {
9463: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9464: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9465: } else {
9466: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9467: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9468: }
9469: return mmd == mmd2 ? mmd.mmdRls (a) : mmd.mmdRws (a) << 16 | mmd2.mmdRwz (a2);
9470: }
9471: }
9472: }
9473:
9474:
9475:
9476:
9477: public static int busRlsf (int a) throws M68kException {
9478: if (DataBreakPoint.DBP_ON) {
9479: return DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9480: } else {
9481: return busMemoryMap[a >>> BUS_PAGE_BITS].mmdRls (a);
9482: }
9483: }
9484:
9485:
9486:
9487: public static long busRqs (int a) throws M68kException {
9488: return (long) busRls (a) << 32 | busRls (a + 4) & 0xffffffffL;
9489: }
9490:
9491:
9492:
9493: public static void busWb (int a, int d) throws M68kException {
9494: if (DataBreakPoint.DBP_ON) {
9495: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9496: } else {
9497: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9498: }
9499: }
9500:
9501:
9502:
9503: public static void busWw (int a, int d) throws M68kException {
9504: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9505: if (DataBreakPoint.DBP_ON) {
9506: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9507: } else {
9508: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9509: }
9510: } else if (mpuIgnoreAddressError) {
9511: int a1 = a + 1;
9512: if (DataBreakPoint.DBP_ON) {
9513: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
9514: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
9515: } else {
9516: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 8);
9517: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWb (a1, d);
9518: }
9519: } else {
9520: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9521: M68kException.m6eAddress = a;
9522: M68kException.m6eDirection = MPU_WR_WRITE;
9523: M68kException.m6eSize = MPU_SS_WORD;
9524: throw M68kException.m6eSignal;
9525: }
9526: }
9527:
9528:
9529:
9530:
9531: public static void busWwe (int a, int d) throws M68kException {
9532: if (DataBreakPoint.DBP_ON) {
9533: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9534: } else {
9535: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9536: }
9537: }
9538:
9539:
9540:
9541: public static void busWl (int a, int d) throws M68kException {
9542: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9543: if (DataBreakPoint.DBP_ON) {
9544: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9545: } else {
9546: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9547: }
9548: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9549: int a2 = a + 2;
9550: if (BUS_SPLIT_UNALIGNED_LONG) {
9551: if (DataBreakPoint.DBP_ON) {
9552: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9553: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9554: } else {
9555: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9556: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9557: }
9558: } else {
9559: MemoryMappedDevice mmd;
9560: MemoryMappedDevice mmd2;
9561: if (DataBreakPoint.DBP_ON) {
9562: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9563: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9564: } else {
9565: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9566: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9567: }
9568: if (mmd == mmd2) {
9569: mmd.mmdWl (a, d);
9570: } else {
9571: mmd.mmdWw (a, d >> 16);
9572: mmd2.mmdWw (a2, d);
9573: }
9574: }
9575: } else if (mpuIgnoreAddressError) {
9576: int a1 = a + 1;
9577: int a3 = a + 3;
9578: if (DataBreakPoint.DBP_ON) {
9579: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
9580: DataBreakPoint.dbpMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
9581: DataBreakPoint.dbpMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
9582: } else {
9583: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d >> 24);
9584: busMemoryMap[a1 >>> BUS_PAGE_BITS].mmdWw (a1, d >> 8);
9585: busMemoryMap[a3 >>> BUS_PAGE_BITS].mmdWb (a3, d);
9586: }
9587: } else {
9588: M68kException.m6eNumber = M68kException.M6E_ADDRESS_ERROR;
9589: M68kException.m6eAddress = a;
9590: M68kException.m6eDirection = MPU_WR_WRITE;
9591: M68kException.m6eSize = MPU_SS_LONG;
9592: throw M68kException.m6eSignal;
9593: }
9594: }
9595:
9596:
9597:
9598:
9599: public static void busWlf (int a, int d) throws M68kException {
9600: if (DataBreakPoint.DBP_ON) {
9601: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9602: } else {
9603: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9604: }
9605: }
9606:
9607:
9608:
9609:
9610: public static void busWle (int a, int d) throws M68kException {
9611: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9612: if (DataBreakPoint.DBP_ON) {
9613: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9614: } else {
9615: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9616: }
9617: } else {
9618: int a2 = a + 2;
9619: if (BUS_SPLIT_UNALIGNED_LONG) {
9620: if (DataBreakPoint.DBP_ON) {
9621: DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9622: DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9623: } else {
9624: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d >> 16);
9625: busMemoryMap[a2 >>> BUS_PAGE_BITS].mmdWw (a2, d);
9626: }
9627: } else {
9628: MemoryMappedDevice mmd;
9629: MemoryMappedDevice mmd2;
9630: if (DataBreakPoint.DBP_ON) {
9631: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9632: mmd2 = DataBreakPoint.dbpMemoryMap[a2 >>> BUS_PAGE_BITS];
9633: } else {
9634: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9635: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9636: }
9637: if (mmd == mmd2) {
9638: mmd.mmdWl (a, d);
9639: } else {
9640: mmd.mmdWw (a, d >> 16);
9641: mmd2.mmdWw (a2, d);
9642: }
9643: }
9644: }
9645: }
9646:
9647:
9648:
9649: public static void busWq (int a, long d) throws M68kException {
9650: busWl (a, (int) (d >>> 32));
9651: busWl (a + 4, (int) d);
9652: }
9653:
9654:
9655:
9656:
9657:
9658: public static void busRbb (int a, byte[] bb, int o, int l) throws M68kException {
9659: if (false) {
9660: for (int i = 0; i < l; i++) {
9661: int ai = a + i;
9662: if (DataBreakPoint.DBP_ON) {
9663: bb[o + i] = DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9664: } else {
9665: bb[o + i] = busMemoryMap[ai >>> BUS_PAGE_BITS].mmdRbs (ai);
9666: }
9667: }
9668: } else {
9669: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9670: while (l > 0) {
9671: MemoryMappedDevice mmd;
9672: if (DataBreakPoint.DBP_ON) {
9673: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9674: } else {
9675: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9676: }
9677: int s = l <= r ? l : r;
9678: l -= s;
9679: if (true) {
9680: for (s -= 16; s >= 0; s -= 16) {
9681: bb[o ] = mmd.mmdRbs (a );
9682: bb[o + 1] = mmd.mmdRbs (a + 1);
9683: bb[o + 2] = mmd.mmdRbs (a + 2);
9684: bb[o + 3] = mmd.mmdRbs (a + 3);
9685: bb[o + 4] = mmd.mmdRbs (a + 4);
9686: bb[o + 5] = mmd.mmdRbs (a + 5);
9687: bb[o + 6] = mmd.mmdRbs (a + 6);
9688: bb[o + 7] = mmd.mmdRbs (a + 7);
9689: bb[o + 8] = mmd.mmdRbs (a + 8);
9690: bb[o + 9] = mmd.mmdRbs (a + 9);
9691: bb[o + 10] = mmd.mmdRbs (a + 10);
9692: bb[o + 11] = mmd.mmdRbs (a + 11);
9693: bb[o + 12] = mmd.mmdRbs (a + 12);
9694: bb[o + 13] = mmd.mmdRbs (a + 13);
9695: bb[o + 14] = mmd.mmdRbs (a + 14);
9696: bb[o + 15] = mmd.mmdRbs (a + 15);
9697: a += 16;
9698: o += 16;
9699: }
9700: s += 16;
9701: }
9702: for (int i = 0; i < s; i++) {
9703: bb[o + i] = mmd.mmdRbs (a + i);
9704: }
9705: a += s;
9706: o += s;
9707: r = BUS_PAGE_SIZE;
9708: }
9709: }
9710: }
9711:
9712:
9713:
9714: public static void busWbb (int a, byte[] bb, int o, int l) throws M68kException {
9715: if (false) {
9716: for (int i = 0; i < l; i++) {
9717: int ai = a + i;
9718: if (DataBreakPoint.DBP_ON) {
9719: DataBreakPoint.dbpMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9720: } else {
9721: busMemoryMap[ai >>> BUS_PAGE_BITS].mmdWb (ai, bb[o + i]);
9722: }
9723: }
9724: } else {
9725: int r = (~a & BUS_PAGE_SIZE - 1) + 1;
9726: while (l > 0) {
9727: MemoryMappedDevice mmd;
9728: if (DataBreakPoint.DBP_ON) {
9729: mmd = DataBreakPoint.dbpMemoryMap[a >>> BUS_PAGE_BITS];
9730: } else {
9731: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9732: }
9733: int s = l <= r ? l : r;
9734: l -= s;
9735: if (true) {
9736: for (s -= 16; s >= 0; s -= 16) {
9737: mmd.mmdWb (a , bb[o ]);
9738: mmd.mmdWb (a + 1, bb[o + 1]);
9739: mmd.mmdWb (a + 2, bb[o + 2]);
9740: mmd.mmdWb (a + 3, bb[o + 3]);
9741: mmd.mmdWb (a + 4, bb[o + 4]);
9742: mmd.mmdWb (a + 5, bb[o + 5]);
9743: mmd.mmdWb (a + 6, bb[o + 6]);
9744: mmd.mmdWb (a + 7, bb[o + 7]);
9745: mmd.mmdWb (a + 8, bb[o + 8]);
9746: mmd.mmdWb (a + 9, bb[o + 9]);
9747: mmd.mmdWb (a + 10, bb[o + 10]);
9748: mmd.mmdWb (a + 11, bb[o + 11]);
9749: mmd.mmdWb (a + 12, bb[o + 12]);
9750: mmd.mmdWb (a + 13, bb[o + 13]);
9751: mmd.mmdWb (a + 14, bb[o + 14]);
9752: mmd.mmdWb (a + 15, bb[o + 15]);
9753: a += 16;
9754: o += 16;
9755: }
9756: s += 16;
9757: }
9758: for (int i = 0; i < s; i++) {
9759: mmd.mmdWb (a + i, bb[o + i]);
9760: }
9761: a += s;
9762: o += s;
9763: r = BUS_PAGE_SIZE;
9764: }
9765: }
9766: }
9767:
9768:
9769:
9770: public static void busVb (int a, int d) {
9771: try {
9772: if (DataBreakPoint.DBP_ON) {
9773: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9774: } else {
9775: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWb (a, d);
9776: }
9777: } catch (M68kException e) {
9778: }
9779: }
9780:
9781:
9782:
9783: public static void busVw (int a, int d) {
9784: try {
9785: if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9786: if (DataBreakPoint.DBP_ON) {
9787: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9788: } else {
9789: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWw (a, d);
9790: }
9791: }
9792: } catch (M68kException e) {
9793: }
9794: }
9795:
9796:
9797:
9798: public static void busVl (int a, int d) {
9799: try {
9800: if (TEST_BIT_0_SHIFT && TEST_BIT_1_SHIFT ? a << 30 == 0 : (a & 3) == 0) {
9801: if (DataBreakPoint.DBP_ON) {
9802: (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9803: } else {
9804: busMemoryMap[a >>> BUS_PAGE_BITS].mmdWl (a, d);
9805: }
9806: } else if (TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
9807: int a2 = a + 2;
9808: MemoryMappedDevice mmd;
9809: MemoryMappedDevice mmd2;
9810: if (DataBreakPoint.DBP_ON) {
9811: mmd = (regSRS != 0 ? busSuperMap : busUserMap)[a >>> BUS_PAGE_BITS];
9812: mmd2 = (regSRS != 0 ? busSuperMap : busUserMap)[a2 >>> BUS_PAGE_BITS];
9813: } else {
9814: mmd = busMemoryMap[a >>> BUS_PAGE_BITS];
9815: mmd2 = busMemoryMap[a2 >>> BUS_PAGE_BITS];
9816: }
9817: if (mmd == mmd2) {
9818: mmd.mmdWl (a, d);
9819: } else {
9820: mmd.mmdWw (a, d >> 16);
9821: mmd2.mmdWw (a2, d);
9822: }
9823: }
9824: } catch (M68kException e) {
9825: }
9826: }
9827:
9828:
9829:
9830:
9831:
9832: public static final int SVS_AREASET = 0x00e86001;
9833:
9834:
9835:
9836:
9837:
9838:
9839:
9840:
9841:
9842: public static void svsInit () {
9843: }
9844:
9845:
9846:
9847:
9848:
9849:
9850:
9851:
9852:
9853:
9854:
9855:
9856:
9857:
9858:
9859:
9860:
9861:
9862:
9863:
9864:
9865:
9866:
9867:
9868:
9869:
9870:
9871:
9872:
9873:
9874:
9875:
9876:
9877:
9878:
9879: public static boolean sysNMIFlag;
9880:
9881:
9882:
9883: public static void sysInit () {
9884: sysNMIFlag = false;
9885: }
9886:
9887:
9888:
9889:
9890:
9891:
9892: public static int sysAcknowledge () {
9893: return M68kException.M6E_LEVEL_7_INTERRUPT_AUTOVECTOR;
9894: }
9895:
9896:
9897:
9898:
9899: public static void sysDone () {
9900: if (sysNMIFlag) {
9901: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9902: }
9903: }
9904:
9905:
9906:
9907: public static void sysInterrupt () {
9908: sysNMIFlag = true;
9909: mpuIRR |= MPU_SYS_INTERRUPT_MASK;
9910: }
9911:
9912:
9913:
9914: public static void sysResetNMI () {
9915: sysNMIFlag = false;
9916: }
9917:
9918:
9919:
9920:
9921:
9922:
9923: public static final int EB2_SPC_REQUEST = 0x4000;
9924: public static final int EB2_SPC_VECTOR = 0xf6;
9925:
9926:
9927:
9928: public static int eb2Request;
9929:
9930:
9931:
9932: public static void eb2Reset () {
9933: eb2Request = 0;
9934: }
9935:
9936:
9937:
9938:
9939:
9940: public static void eb2Interrupt (int mask) {
9941: eb2Request |= mask;
9942: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9943: }
9944:
9945:
9946:
9947:
9948:
9949:
9950:
9951: public static int eb2Acknowledge () {
9952: if ((eb2Request & EB2_SPC_REQUEST) != 0) {
9953: eb2Request &= ~EB2_SPC_REQUEST;
9954: return EB2_SPC_VECTOR;
9955: }
9956: return 0;
9957: }
9958:
9959:
9960:
9961:
9962:
9963: public static void eb2Done () {
9964: if (eb2Request != 0) {
9965: mpuIRR |= MPU_EB2_INTERRUPT_MASK;
9966: }
9967: }
9968:
9969:
9970:
9971:
9972:
9973:
9974:
9975:
9976:
9977:
9978:
9979:
9980:
9981:
9982:
9983:
9984:
9985:
9986:
9987:
9988:
9989:
9990:
9991:
9992:
9993:
9994:
9995:
9996:
9997:
9998:
9999:
10000:
10001:
10002:
10003:
10004:
10005:
10006:
10007:
10008:
10009:
10010:
10011:
10012:
10013:
10014:
10015:
10016:
10017:
10018:
10019:
10020:
10021:
10022:
10023:
10024:
10025:
10026:
10027:
10028:
10029:
10030:
10031:
10032: public static final int BNK_SIZE = 1024 * 1024 * 32;
10033: public static byte[] bnkMemory;
10034: public static int bnkPageStart;
10035: public static boolean bnkOn;
10036:
10037: public static void bnkInit () {
10038: bnkMemory = new byte[BNK_SIZE];
10039: byte[] array = Settings.sgsGetData ("bankdata");
10040: if (array.length != 0) {
10041: System.arraycopy (array, 0, bnkMemory, 0, Math.min (array.length, BNK_SIZE));
10042: }
10043: bnkPageStart = 0;
10044:
10045: bnkOn = false;
10046: }
10047:
10048: public static void bnkTini () {
10049: Settings.sgsPutData ("bankdata",
10050: Arrays.copyOf (bnkMemory, BNK_SIZE));
10051: }
10052:
10053:
10054:
10055:
10056:
10057:
10058:
10059: public static ExpressionEvaluator fpuMotherboardCoprocessor;
10060: public static ExpressionEvaluator fpuOnChipFPU;
10061: public static ExpressionEvaluator fpuBox;
10062:
10063:
10064: public static EFPBox fpuCoproboard1;
10065: public static EFPBox fpuCoproboard2;
10066:
10067:
10068: public static EFPBox.EFP[] fpuFPn;
10069:
10070:
10071:
10072: public static final int FPU_FPCR_BSUN = 0b00000000_00000000_10000000_00000000;
10073: public static final int FPU_FPCR_SNAN = 0b00000000_00000000_01000000_00000000;
10074: public static final int FPU_FPCR_OPERR = 0b00000000_00000000_00100000_00000000;
10075: public static final int FPU_FPCR_OVFL = 0b00000000_00000000_00010000_00000000;
10076: public static final int FPU_FPCR_UNFL = 0b00000000_00000000_00001000_00000000;
10077: public static final int FPU_FPCR_DZ = 0b00000000_00000000_00000100_00000000;
10078: public static final int FPU_FPCR_INEX2 = 0b00000000_00000000_00000010_00000000;
10079: public static final int FPU_FPCR_INEX1 = 0b00000000_00000000_00000001_00000000;
10080:
10081:
10082: public static final int FPU_FPCR_PE = 0b00000000_00000000_00000000_00000000;
10083: public static final int FPU_FPCR_PS = 0b00000000_00000000_00000000_01000000;
10084: public static final int FPU_FPCR_PD = 0b00000000_00000000_00000000_10000000;
10085:
10086: public static final int FPU_FPCR_RN = 0b00000000_00000000_00000000_00000000;
10087: public static final int FPU_FPCR_RZ = 0b00000000_00000000_00000000_00010000;
10088: public static final int FPU_FPCR_RM = 0b00000000_00000000_00000000_00100000;
10089: public static final int FPU_FPCR_RP = 0b00000000_00000000_00000000_00110000;
10090:
10091:
10092:
10093: public static final int FPU_FPSR_N = 0b00001000_00000000_00000000_00000000;
10094: public static final int FPU_FPSR_Z = 0b00000100_00000000_00000000_00000000;
10095: public static final int FPU_FPSR_I = 0b00000010_00000000_00000000_00000000;
10096: public static final int FPU_FPSR_NAN = 0b00000001_00000000_00000000_00000000;
10097:
10098: public static final int FPU_FPSR_S = 0b00000000_10000000_00000000_00000000;
10099: public static final int FPU_FPSR_QUOTIENT = 0b00000000_01111111_00000000_00000000;
10100:
10101: public static final int FPU_FPSR_EXC_BSUN = 0b00000000_00000000_10000000_00000000;
10102: public static final int FPU_FPSR_EXC_SNAN = 0b00000000_00000000_01000000_00000000;
10103: public static final int FPU_FPSR_EXC_OPERR = 0b00000000_00000000_00100000_00000000;
10104: public static final int FPU_FPSR_EXC_OVFL = 0b00000000_00000000_00010000_00000000;
10105: public static final int FPU_FPSR_EXC_UNFL = 0b00000000_00000000_00001000_00000000;
10106: public static final int FPU_FPSR_EXC_DZ = 0b00000000_00000000_00000100_00000000;
10107: public static final int FPU_FPSR_EXC_INEX2 = 0b00000000_00000000_00000010_00000000;
10108: public static final int FPU_FPSR_EXC_INEX1 = 0b00000000_00000000_00000001_00000000;
10109:
10110: public static final int FPU_FPSR_AEXC_IOP = 0b00000000_00000000_00000000_10000000;
10111: public static final int FPU_FPSR_AEXC_OVFL = 0b00000000_00000000_00000000_01000000;
10112: public static final int FPU_FPSR_AEXC_UNFL = 0b00000000_00000000_00000000_00100000;
10113: public static final int FPU_FPSR_AEXC_DZ = 0b00000000_00000000_00000000_00010000;
10114: public static final int FPU_FPSR_AEXC_INEX = 0b00000000_00000000_00000000_00001000;
10115:
10116:
10117:
10118:
10119:
10120:
10121:
10122: public static final int[] FPU_FPSR_EXC_TO_AEXC = new int[256];
10123:
10124:
10125:
10126:
10127:
10128:
10129:
10130:
10131:
10132:
10133:
10134:
10135:
10136:
10137:
10138:
10139:
10140:
10141:
10142:
10143:
10144:
10145:
10146:
10147: public static final boolean[] FPU_CCMAP_882 = {
10148:
10149:
10150: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10151: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10152: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10153: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10154: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10155: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10156: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10157: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
10158: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10159: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10160: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10161: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10162: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10163: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10164: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
10165: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10166:
10167:
10168: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10169: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10170: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10171: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10172: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10173: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10174: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10175: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
10176: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10177: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10178: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10179: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10180: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10181: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10182: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
10183: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10184:
10185: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10186: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10187: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10188: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10189: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10190: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10191: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10192: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
10193: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10194: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10195: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10196: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10197: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10198: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10199: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
10200: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10201:
10202: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10203: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10204: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10205: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10206: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10207: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10208: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10209: T,F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,
10210: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10211: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10212: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10213: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10214: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10215: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10216: T,T,T,T,F,T,F,T,T,T,T,T,F,T,F,T,
10217: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10218: };
10219:
10220:
10221:
10222:
10223:
10224:
10225:
10226: public static final boolean[] FPU_CCMAP_060 = {
10227:
10228:
10229: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10230: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10231: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10232: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10233: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10234: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10235: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10236: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
10237: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10238: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10239: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10240: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10241: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10242: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10243: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
10244: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10245:
10246:
10247: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10248: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10249: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10250: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10251: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10252: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10253: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10254: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
10255: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10256: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10257: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10258: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10259: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10260: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10261: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
10262: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10263:
10264: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10265: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10266: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10267: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10268: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10269: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10270: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10271: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
10272: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10273: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10274: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10275: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10276: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10277: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10278: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
10279: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10280:
10281: F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,F,
10282: F,F,F,F,T,T,T,T,F,F,F,F,T,T,T,T,
10283: T,F,T,F,F,F,F,F,F,F,F,F,F,F,F,F,
10284: T,F,T,F,T,T,T,T,F,F,F,F,T,T,T,T,
10285: F,F,F,F,F,F,F,F,T,F,T,F,F,F,F,F,
10286: F,F,F,F,T,T,T,T,T,F,T,F,T,T,T,T,
10287: T,F,T,F,F,F,F,F,T,F,T,F,F,F,F,F,
10288: T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,
10289: F,T,F,T,F,T,F,T,F,T,F,T,F,T,F,T,
10290: F,T,F,T,T,T,T,T,F,T,F,T,T,T,T,T,
10291: T,T,T,T,F,T,F,T,F,T,F,T,F,T,F,T,
10292: T,T,T,T,T,T,T,T,F,T,F,T,T,T,T,T,
10293: F,T,F,T,F,T,F,T,T,T,T,T,F,T,F,T,
10294: F,T,F,T,T,T,T,T,T,T,T,T,T,T,T,T,
10295: T,T,T,T,F,F,F,F,T,T,T,T,F,F,F,F,
10296: T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,T,
10297: };
10298:
10299:
10300:
10301:
10302: public static void fpuInit () {
10303: for (int i = 0; i < 256; i++) {
10304: 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) |
10305: ((i << 8 & FPU_FPSR_EXC_OVFL) != 0 ? FPU_FPSR_AEXC_OVFL : 0) |
10306: ((i << 8 & (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2)) == (FPU_FPSR_EXC_UNFL | FPU_FPSR_EXC_INEX2) ? FPU_FPSR_AEXC_UNFL : 0) |
10307: ((i << 8 & FPU_FPSR_EXC_DZ) != 0 ? FPU_FPSR_AEXC_DZ : 0) |
10308: ((i << 8 & (FPU_FPSR_EXC_OVFL | FPU_FPSR_EXC_INEX2 | FPU_FPSR_EXC_INEX1)) != 0 ? FPU_FPSR_AEXC_INEX : 0));
10309: }
10310:
10311: fpuMotherboardCoprocessor = new ExpressionEvaluator ();
10312:
10313: fpuOnChipFPU = new ExpressionEvaluator ();
10314:
10315: fpuBox = currentMPU < Model.MPU_MC68LC040 ? fpuMotherboardCoprocessor : fpuOnChipFPU;
10316:
10317: fpuFPn = fpuBox.epbFPn;
10318:
10319: fpuCoproboard1 = new EFPBox ();
10320: fpuCoproboard2 = new EFPBox ();
10321: }
10322:
10323:
10324:
10325:
10326:
10327:
10328: public static final boolean DBG_ORI_BYTE_ZERO_D0 = true;
10329:
10330: public static boolean dbgHexSelected;
10331: public static int dbgHexValue;
10332: public static int dbgSupervisorMode;
10333: public static JPopupMenu dbgPopupMenu;
10334: public static JMenu dbgPopupIBPMenu;
10335: public static SpinnerNumberModel dbgPopupIBPCurrentModel;
10336: public static int dbgPopupIBPCurrentValue;
10337: public static SpinnerNumberModel dbgPopupIBPThresholdModel;
10338: public static int dbgPopupIBPThresholdValue;
10339: public static JMenuItem dbgPopupIBPClearMenuItem;
10340: public static JMenu dbgPopupHexMenu;
10341: public static JMenuItem dbgPopupDisMenuItem;
10342: public static JMenuItem dbgPopupMemMenuItem;
10343: public static JMenuItem dbgPopupCopyMenuItem;
10344: public static JMenuItem dbgPopupSelectAllMenuItem;
10345: public static JTextArea dbgPopupTextArea;
10346: public static int dbgEventMask;
10347: public static boolean dbgStopOnError;
10348: public static boolean dbgOriByteZeroD0;
10349: public static boolean dbgStopAtStart;
10350:
10351:
10352:
10353: public static final char[] DBG_SPACES = (
10354:
10355:
10356: " ").toCharArray ();
10357:
10358: public static final int DBG_DRP_VISIBLE_MASK = 1;
10359: public static final int DBG_DDP_VISIBLE_MASK = 2;
10360: public static final int DBG_DMP_VISIBLE_MASK = 4;
10361: public static final int DBG_BLG_VISIBLE_MASK = 8;
10362: public static final int DBG_PFV_VISIBLE_MASK = 16;
10363: public static final int DBG_RBP_VISIBLE_MASK = 32;
10364: public static final int DBG_DBP_VISIBLE_MASK = 64;
10365: public static final int DBG_SMT_VISIBLE_MASK = 128;
10366: public static final int DBG_ATW_VISIBLE_MASK = 256;
10367: public static final int DBG_PAA_VISIBLE_MASK = 512;
10368: public static final int DBG_RTL_VISIBLE_MASK = 1024;
10369: public static final int DBG_SPV_VISIBLE_MASK = 2048;
10370: public static final int DBG_PLV_VISIBLE_MASK = 4096;
10371: public static final int DBG_ACM_VISIBLE_MASK = 8192;
10372: public static int dbgVisibleMask;
10373:
10374:
10375:
10376: public static void dbgInit () {
10377: dbgVisibleMask = 0;
10378: dbgHexSelected = false;
10379: dbgHexValue = 0;
10380: dbgSupervisorMode = 1;
10381: dbgPopupMenu = null;
10382: dbgPopupDisMenuItem = null;
10383: dbgPopupMemMenuItem = null;
10384: dbgPopupCopyMenuItem = null;
10385: dbgPopupSelectAllMenuItem = null;
10386: dbgPopupIBPMenu = null;
10387: dbgPopupIBPCurrentModel = null;
10388: dbgPopupIBPCurrentValue = 0;
10389: dbgPopupIBPThresholdModel = null;
10390: dbgPopupIBPThresholdValue = 0;
10391: dbgPopupHexMenu = null;
10392: dbgPopupTextArea = null;
10393: dbgEventMask = 0;
10394: dbgStopOnError = false;
10395: if (DBG_ORI_BYTE_ZERO_D0) {
10396: dbgOriByteZeroD0 = false;
10397: }
10398: dbgStopAtStart = false;
10399: }
10400:
10401:
10402:
10403: public static void dbgMakePopup () {
10404:
10405:
10406: ActionListener popupActionListener = new ActionListener () {
10407: @Override public void actionPerformed (ActionEvent ae) {
10408: switch (ae.getActionCommand ()) {
10409: case "Disassemble":
10410: DisassembleList.ddpBacktraceRecord = -1L;
10411: DisassembleList.ddpOpen (dbgHexValue, dbgSupervisorMode, false);
10412: break;
10413: case "Memory Dump":
10414: MemoryDumpList.dmpOpen (dbgHexValue, dbgSupervisorMode != 0 ? 5 : 1, false);
10415: break;
10416: case "Run to Here":
10417: if (InstructionBreakPoint.IBP_ON) {
10418: if (mpuTask == null) {
10419: InstructionBreakPoint.ibpInstant (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
10420: mpuStart ();
10421: }
10422: }
10423: break;
10424: case "Set Breakpoint":
10425: if (InstructionBreakPoint.IBP_ON) {
10426: InstructionBreakPoint.ibpPut (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode, dbgPopupIBPCurrentValue, dbgPopupIBPThresholdValue, null);
10427: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
10428: }
10429: break;
10430: case "Clear Breakpoint":
10431: if (InstructionBreakPoint.IBP_ON) {
10432: InstructionBreakPoint.ibpRemove (DisassembleList.ddpPopupAddress, DisassembleList.ddpSupervisorMode);
10433: DisassembleList.ddpOpen (0, DisassembleList.ddpSupervisorMode, true);
10434: }
10435: break;
10436: case "Copy":
10437: dbgCopy ();
10438: break;
10439: case "Select All":
10440: dbgSelectAll ();
10441: break;
10442: }
10443: }
10444: };
10445: dbgPopupMenu = ComponentFactory.createPopupMenu (
10446: dbgPopupIBPMenu =
10447: InstructionBreakPoint.IBP_ON ?
10448: ComponentFactory.createMenu (
10449: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
10450: Multilingual.mlnText (ComponentFactory.createMenuItem ("Run to Here", 'R', popupActionListener), "ja", "ここまで実行"),
10451: ComponentFactory.createHorizontalSeparator (),
10452: Multilingual.mlnText (ComponentFactory.createMenuItem ("Set Breakpoint", 'S', popupActionListener), "ja", "ブレークポイントを設定"),
10453: ComponentFactory.createHorizontalBox (
10454: Box.createHorizontalStrut (7),
10455: Box.createHorizontalGlue (),
10456: ComponentFactory.setPreferredSize (
10457: Multilingual.mlnText (ComponentFactory.createLabel ("current"), "ja", "現在値"),
10458: 60, 16),
10459: ComponentFactory.createNumberSpinner (dbgPopupIBPCurrentModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
10460: @Override public void stateChanged (ChangeEvent ce) {
10461: dbgPopupIBPCurrentValue = dbgPopupIBPCurrentModel.getNumber ().intValue ();
10462: }
10463: }),
10464: Box.createHorizontalGlue ()
10465: ),
10466: ComponentFactory.createHorizontalBox (
10467: Box.createHorizontalStrut (7),
10468: Box.createHorizontalGlue (),
10469: ComponentFactory.setPreferredSize (
10470: Multilingual.mlnText (ComponentFactory.createLabel ("threshold"), "ja", "閾値"),
10471: 60, 16),
10472: ComponentFactory.createNumberSpinner (dbgPopupIBPThresholdModel = new SpinnerNumberModel (0, 0, 0x7fffffff, 1), 10, new ChangeListener () {
10473: @Override public void stateChanged (ChangeEvent ce) {
10474: dbgPopupIBPThresholdValue = dbgPopupIBPThresholdModel.getNumber ().intValue ();
10475: }
10476: }),
10477: Box.createHorizontalGlue ()
10478: ),
10479: dbgPopupIBPClearMenuItem =
10480: Multilingual.mlnText (ComponentFactory.createMenuItem ("Clear Breakpoint", 'C', popupActionListener), "ja", "ブレークポイントを消去")
10481: ) :
10482: null,
10483: dbgPopupHexMenu =
10484: ComponentFactory.createMenu (
10485: "XXXXXXXX", KeyEvent.VK_UNDEFINED,
10486: dbgPopupDisMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Disassemble", 'D', popupActionListener), "ja", "逆アセンブル"),
10487: dbgPopupMemMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Memory Dump", 'M', popupActionListener), "ja", "メモリダンプ")
10488: ),
10489: dbgPopupCopyMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Copy", 'C', popupActionListener), "ja", "コピー"),
10490: dbgPopupSelectAllMenuItem = Multilingual.mlnText (ComponentFactory.createMenuItem ("Select All", 'A', popupActionListener), "ja", "すべて選択")
10491: );
10492:
10493: }
10494:
10495:
10496:
10497: public static void dbgShowPopup (MouseEvent me, JTextArea textArea, boolean dis) {
10498: dbgEventMask++;
10499: int x = me.getX ();
10500: int y = me.getY ();
10501:
10502: int p = textArea.viewToModel2D (me.getPoint ());
10503: DisassembleList.ddpPopupAddress = -1;
10504: if (dis) {
10505: int i = Arrays.binarySearch (DisassembleList.ddpSplitArray, 1, DisassembleList.ddpItemCount, p + 1);
10506: i = (i >> 31 ^ i) - 1;
10507: DisassembleList.ddpPopupAddress = DisassembleList.ddpAddressArray[i];
10508: }
10509: int start = textArea.getSelectionStart ();
10510: int end = textArea.getSelectionEnd ();
10511: String text = textArea.getText ();
10512: int length = text.length ();
10513: if ((start == end ||
10514: p < start || end <= p) &&
10515: 0 <= p && p < length && isWord (text.charAt (p))) {
10516:
10517: for (start = p; 0 < start && isWord (text.charAt (start - 1)); start--) {
10518: }
10519: for (end = p + 1; end < length && isWord (text.charAt (end)); end++) {
10520: }
10521: textArea.select (start, end);
10522: }
10523: dbgHexSelected = false;
10524: if (start < end) {
10525: textArea.requestFocusInWindow ();
10526:
10527:
10528:
10529:
10530:
10531: dbgHexValue = 0;
10532: int n = 0;
10533: for (int i = start; i < end; i++) {
10534: int t;
10535: if ((t = Character.digit (text.charAt (i), 16)) >= 0) {
10536: dbgHexValue = dbgHexValue << 4 | t;
10537: if (n >= 8 ||
10538: i + 1 >= end || (t = Character.digit (text.charAt (i + 1), 16)) < 0) {
10539: n = 0;
10540: break;
10541: }
10542: dbgHexValue = dbgHexValue << 4 | t;
10543: n += 2;
10544: i++;
10545: } else if (isWord (text.charAt (i))) {
10546: n = 0;
10547: break;
10548: }
10549: }
10550: dbgHexSelected = n > 0;
10551: try {
10552:
10553: Rectangle r = textArea.modelToView2D (start).getBounds ();
10554:
10555: Rectangle s = textArea.modelToView2D (end - 1).getBounds ();
10556: if (r.y == s.y) {
10557:
10558: y = r.y + r.height;
10559: }
10560: } catch (BadLocationException ble) {
10561: }
10562: }
10563:
10564: if (InstructionBreakPoint.IBP_ON) {
10565: if (dis && mpuTask == null && DisassembleList.ddpPopupAddress != -1) {
10566: ComponentFactory.setText (dbgPopupIBPMenu, fmtHex8 (DisassembleList.ddpPopupAddress));
10567: TreeMap<Integer,InstructionBreakPoint.InstructionBreakRecord> pointTable = InstructionBreakPoint.ibpPointTable;
10568: InstructionBreakPoint.InstructionBreakRecord r = pointTable.get (DisassembleList.ddpPopupAddress);
10569: if (r != null) {
10570: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = r.ibrValue));
10571: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = r.ibrThreshold));
10572: dbgPopupIBPClearMenuItem.setEnabled (true);
10573: } else {
10574: dbgPopupIBPCurrentModel.setValue (Integer.valueOf (dbgPopupIBPCurrentValue = 0));
10575: dbgPopupIBPThresholdModel.setValue (Integer.valueOf (dbgPopupIBPThresholdValue = 0));
10576: dbgPopupIBPClearMenuItem.setEnabled (false);
10577: }
10578: ComponentFactory.setVisible (dbgPopupIBPMenu, true);
10579: } else {
10580: ComponentFactory.setVisible (dbgPopupIBPMenu, false);
10581: }
10582: }
10583:
10584: if (dbgHexSelected) {
10585: ComponentFactory.setText (dbgPopupHexMenu, fmtHex8 (dbgHexValue));
10586: ComponentFactory.setVisible (dbgPopupHexMenu, true);
10587: } else {
10588: ComponentFactory.setVisible (dbgPopupHexMenu, false);
10589: }
10590:
10591: ComponentFactory.setEnabled (dbgPopupCopyMenuItem, clpClipboard != null && start < end);
10592:
10593: ComponentFactory.setEnabled (dbgPopupSelectAllMenuItem, clpClipboard != null);
10594:
10595: dbgPopupTextArea = textArea;
10596: dbgPopupMenu.show (textArea, x, y);
10597: dbgEventMask--;
10598: }
10599:
10600: public static boolean isWord (char c) {
10601: return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '_';
10602: }
10603:
10604:
10605:
10606: public static void dbgCopy () {
10607: clpCopy (dbgPopupTextArea.getSelectedText ());
10608: }
10609:
10610:
10611:
10612: public static void dbgSelectAll () {
10613: if (clpClipboard != null) {
10614:
10615: dbgEventMask++;
10616: dbgPopupTextArea.selectAll ();
10617: dbgPopupTextArea.requestFocusInWindow ();
10618: dbgEventMask--;
10619: }
10620: }
10621:
10622:
10623:
10624:
10625: public static void dbgUpdate () {
10626: if ((dbgVisibleMask & DBG_DRP_VISIBLE_MASK) != 0) {
10627: RegisterList.drpUpdate ();
10628: }
10629: if (ProgramFlowVisualizer.PFV_ON) {
10630: if ((dbgVisibleMask & DBG_PFV_VISIBLE_MASK) != 0) {
10631: if (ProgramFlowVisualizer.pfvTimer == 0) {
10632: ProgramFlowVisualizer.pfvUpdate ();
10633: } else {
10634: ProgramFlowVisualizer.pfvTimer--;
10635: }
10636: }
10637: }
10638: if (RasterBreakPoint.RBP_ON) {
10639: if ((dbgVisibleMask & DBG_RBP_VISIBLE_MASK) != 0) {
10640: if (RasterBreakPoint.rbpTimer == 0) {
10641: RasterBreakPoint.rbpUpdateFrame ();
10642: } else {
10643: RasterBreakPoint.rbpTimer--;
10644: }
10645: }
10646: }
10647: if (ScreenModeTest.SMT_ON) {
10648: if ((dbgVisibleMask & DBG_SMT_VISIBLE_MASK) != 0) {
10649: if (ScreenModeTest.smtTimer == 0) {
10650: ScreenModeTest.smtUpdateFrame ();
10651: } else {
10652: ScreenModeTest.smtTimer--;
10653: }
10654: }
10655: }
10656: if (RootPointerList.RTL_ON) {
10657: if ((dbgVisibleMask & DBG_RTL_VISIBLE_MASK) != 0) {
10658: if (RootPointerList.rtlTimer == 0) {
10659: RootPointerList.rtlTimer = RootPointerList.RTL_INTERVAL - 1;
10660: RootPointerList.rtlUpdateFrame ();
10661: } else {
10662: RootPointerList.rtlTimer--;
10663: }
10664: }
10665: }
10666: if (SpritePatternViewer.SPV_ON) {
10667: if ((dbgVisibleMask & DBG_SPV_VISIBLE_MASK) != 0) {
10668: if (SpritePatternViewer.spvTimer == 0) {
10669: SpritePatternViewer.spvTimer = SpritePatternViewer.SPV_INTERVAL - 1;
10670: SpritePatternViewer.spvUpdateFrame ();
10671: } else {
10672: SpritePatternViewer.spvTimer--;
10673: }
10674: }
10675: }
10676: if (PaletteViewer.PLV_ON) {
10677: if ((dbgVisibleMask & DBG_PLV_VISIBLE_MASK) != 0) {
10678: if (PaletteViewer.plvTimer == 0) {
10679: PaletteViewer.plvTimer = PaletteViewer.PLV_INTERVAL - 1;
10680: PaletteViewer.plvUpdateFrame ();
10681: } else {
10682: PaletteViewer.plvTimer--;
10683: }
10684: }
10685: }
10686: if (ATCMonitor.ACM_ON) {
10687: if ((dbgVisibleMask & DBG_ACM_VISIBLE_MASK) != 0) {
10688: if (ATCMonitor.acmTimer == 0) {
10689: ATCMonitor.acmTimer = ATCMonitor.ACM_INTERVAL - 1;
10690: ATCMonitor.acmUpdateFrame ();
10691: } else {
10692: ATCMonitor.acmTimer--;
10693: }
10694: }
10695: }
10696: }
10697:
10698:
10699:
10700:
10701:
10702:
10703:
10704:
10705:
10706:
10707:
10708:
10709:
10710:
10711:
10712:
10713:
10714:
10715:
10716:
10717:
10718:
10719: public static boolean dbgDoStopOnError () {
10720: if (MainMemory.mmrHumanVersion <= 0) {
10721: return true;
10722: }
10723: if ((regOC & 0xff00) == 0xff00 &&
10724: M68kException.m6eNumber == M68kException.M6E_PRIVILEGE_VIOLATION) {
10725: return false;
10726: }
10727: String message = (
10728: M68kException.m6eNumber < 0 ?
10729: fmtHex8 (new StringBuilder ("breaked").append (" at "), regPC0).toString () :
10730: M68kException.m6eNumber <= M68kException.M6E_ADDRESS_ERROR ?
10731: fmtHex8 (fmtHex8 (new StringBuilder ("ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10732: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10733: .append (" at "), regPC0).toString () :
10734: fmtHex8 (new StringBuilder (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10735: .append (" at "), regPC0).toString ()
10736: );
10737: System.out.println (message);
10738: if (!(M68kException.m6eNumber == M68kException.M6E_ACCESS_FAULT &&
10739: 0x0000e100 <= regPC0 && regPC0 < 0x0000e500)) {
10740: mpuStop (message);
10741: return true;
10742: }
10743: return false;
10744: }
10745:
10746:
10747:
10748: public static void dbgDoubleBusFault () {
10749: String message =
10750: fmtHex8 (fmtHex8 (new StringBuilder ("FATAL ERROR: ").append (M68kException.M6E_ERROR_NAME[M68kException.m6eNumber])
10751: .append (M68kException.m6eDirection == 0 ? " on writing to " : " on reading from "), M68kException.m6eAddress)
10752: .append (" at "), regPC0).toString ();
10753: System.out.println (message);
10754: mpuStop (message);
10755: }
10756:
10757:
10758:
10759:
10760:
10761:
10762: public static final HashMap<String,byte[]> rscResourceCache = new HashMap<String,byte[]> ();
10763:
10764:
10765:
10766:
10767:
10768:
10769: public static byte[] rscGetResource (String name, int... sizes) {
10770: byte[] array = rscResourceCache.get (name);
10771: if (array != null) {
10772: return array;
10773: }
10774: array = new byte[1024 * 64];
10775: int size = 0;
10776: try (BufferedInputStream bis = new BufferedInputStream (XEiJ.class.getResourceAsStream ("../data/" + name))) {
10777: for (;;) {
10778: if (size == array.length) {
10779: byte[] newArray = new byte[array.length * 2];
10780: System.arraycopy (array, 0, newArray, 0, size);
10781: array = newArray;
10782: }
10783: int step = bis.read (array, size, array.length - size);
10784: if (step == -1) {
10785: break;
10786: }
10787: size += step;
10788: }
10789: if (size < array.length) {
10790: byte[] newArray = new byte[size];
10791: System.arraycopy (array, 0, newArray, 0, size);
10792: array = newArray;
10793: }
10794: boolean fit = sizes.length == 0;
10795: if (!fit) {
10796: for (int i = 0; i < sizes.length; i++) {
10797: if (size == sizes[i]) {
10798: fit = true;
10799: break;
10800: }
10801: }
10802: }
10803: if (fit) {
10804: System.out.println (Multilingual.mlnJapanese ?
10805: name + " を読み込みました" :
10806: name + " was read");
10807: rscResourceCache.put (name, array);
10808: return array;
10809: }
10810: System.out.println (Multilingual.mlnJapanese ?
10811: name + " のサイズが違います" :
10812: name + " has wrong size");
10813: return null;
10814: } catch (IOException ioe) {
10815: }
10816:
10817: System.out.println (Multilingual.mlnJapanese ?
10818: name + " を読み込めません" :
10819: name + " cannot be read");
10820: return null;
10821: }
10822:
10823:
10824:
10825: public static String rscGetResourceText (String name) {
10826: return rscGetResourceText (name, "UTF-8");
10827: }
10828: public static String rscGetResourceText (String name, String charset) {
10829: byte[] array = rscGetResource (name);
10830: if (name != null) {
10831: try {
10832: return new String (array, charset);
10833: } catch (UnsupportedEncodingException uee) {
10834: }
10835: }
10836: return "";
10837: }
10838:
10839: public static final Pattern RSC_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
10840: public static String rscLastFileName = null;
10841:
10842:
10843:
10844:
10845:
10846:
10847: public static byte[] rscGetFile (String names, int... sizes) {
10848: for (String name : names.split (",")) {
10849: name = name.trim ();
10850: if (name.length () == 0 || name.equalsIgnoreCase ("none")) {
10851: continue;
10852: }
10853: String[] zipSplittedName = RSC_ZIP_SEPARATOR.split (name, 2);
10854: InputStream is = null;
10855: if (zipSplittedName.length < 2) {
10856: File file = new File (name);
10857: if (file.isFile ()) {
10858: try {
10859: is = new FileInputStream (file);
10860: } catch (IOException ioe) {
10861: }
10862: } else {
10863: System.out.println (Multilingual.mlnJapanese ?
10864: name + " がありません" :
10865: name + " does not exist");
10866: continue;
10867: }
10868: } else {
10869: String zipName = zipSplittedName[0];
10870: String entryName = zipSplittedName[1];
10871: if (new File (zipName).isFile ()) {
10872: try {
10873: ZipFile zipFile = new ZipFile (zipName);
10874: ZipEntry zipEntry = zipFile.getEntry (entryName);
10875: if (zipEntry != null) {
10876: is = zipFile.getInputStream (zipEntry);
10877: } else {
10878: System.out.println (Multilingual.mlnJapanese ?
10879: zipName + " に " + zipEntry + " がありません" :
10880: zipName + " does not include " + zipEntry);
10881: }
10882: } catch (IOException ioe) {
10883: }
10884: } else {
10885: System.out.println (Multilingual.mlnJapanese ?
10886: zipName + " がありません" :
10887: zipName + " does not exist");
10888: continue;
10889: }
10890: }
10891: if (is != null) {
10892: try {
10893: is = new BufferedInputStream (is);
10894: if (name.toLowerCase ().endsWith (".gz")) {
10895: is = new GZIPInputStream (is);
10896: }
10897: byte[] array = new byte[1024 * 64];
10898: int size = 0;
10899: for (;;) {
10900: if (size == array.length) {
10901: byte[] newArray = new byte[array.length * 2];
10902: System.arraycopy (array, 0, newArray, 0, size);
10903: array = newArray;
10904: }
10905: int step = is.read (array, size, array.length - size);
10906: if (step == -1) {
10907: break;
10908: }
10909: size += step;
10910: }
10911: is.close ();
10912: is = null;
10913: if (size < array.length) {
10914: byte[] newArray = new byte[size];
10915: System.arraycopy (array, 0, newArray, 0, size);
10916: array = newArray;
10917: }
10918: boolean fit = sizes.length == 0;
10919: if (!fit) {
10920: for (int i = 0; i < sizes.length; i++) {
10921: if (size == sizes[i]) {
10922: fit = true;
10923: break;
10924: }
10925: }
10926: }
10927: if (fit) {
10928: System.out.println (Multilingual.mlnJapanese ?
10929: name + " を読み込みました" :
10930: name + " was read");
10931: rscLastFileName = name;
10932: return array;
10933: }
10934: System.out.println (Multilingual.mlnJapanese ?
10935: name + " のサイズが違います" :
10936: name + " has wrong size");
10937: continue;
10938: } catch (IOException ioe) {
10939: }
10940: if (is != null) {
10941: try {
10942: is.close ();
10943: is = null;
10944: } catch (IOException ioe) {
10945: }
10946: }
10947: }
10948: System.out.println (Multilingual.mlnJapanese ?
10949: name + " を読み込めません" :
10950: name + " cannot be read");
10951: }
10952:
10953:
10954:
10955: return null;
10956: }
10957:
10958:
10959:
10960:
10961: public static String rscGetTextFile (String name) {
10962: return rscGetTextFile (name, "UTF-8");
10963: }
10964: public static String rscGetTextFile (String name, String charset) {
10965: byte[] array = rscGetFile (name);
10966: if (array != null) {
10967: try {
10968: return new String (array, charset);
10969: } catch (UnsupportedEncodingException uee) {
10970: }
10971: }
10972: return "";
10973: }
10974:
10975:
10976:
10977: public static final int RSC_A_MASK = 1;
10978: public static final int RSC_R_MASK = 2;
10979: public static final int RSC_I_MASK = 4;
10980: public static final String RSC_A_EN = "Abort";
10981: public static final String RSC_R_EN = "Retry";
10982: public static final String RSC_I_EN = "Ignore";
10983: public static final String RSC_A_JA = "中止";
10984: public static final String RSC_R_JA = "再実行";
10985: public static final String RSC_I_JA = "無視";
10986: public static final String[][] RSC_EN_OPTIONS = {
10987: { RSC_A_EN },
10988: { RSC_A_EN },
10989: { RSC_R_EN },
10990: { RSC_A_EN, RSC_R_EN },
10991: { RSC_I_EN },
10992: { RSC_A_EN, RSC_I_EN },
10993: { RSC_R_EN, RSC_I_EN },
10994: { RSC_A_EN, RSC_R_EN, RSC_I_EN },
10995: };
10996: public static final String[][] RSC_JA_OPTIONS = {
10997: { RSC_A_JA },
10998: { RSC_A_JA },
10999: { RSC_R_JA },
11000: { RSC_A_JA, RSC_R_JA },
11001: { RSC_I_JA },
11002: { RSC_A_JA, RSC_I_JA },
11003: { RSC_R_JA, RSC_I_JA },
11004: { RSC_A_JA, RSC_R_JA, RSC_I_JA },
11005: };
11006: public static int rscShowError (String message, int mask) {
11007: System.out.println (message);
11008: mask &= RSC_A_MASK | RSC_R_MASK | RSC_I_MASK;
11009: if (mask == 0) {
11010: mask = RSC_A_MASK;
11011: }
11012: String[] options = (Multilingual.mlnJapanese ? RSC_JA_OPTIONS : RSC_EN_OPTIONS)[mask];
11013: int def = Integer.numberOfTrailingZeros (mask);
11014: pnlExitFullScreen (true);
11015: int bit = JOptionPane.showOptionDialog (
11016: null,
11017: message,
11018: Multilingual.mlnJapanese ? "ファイル操作エラー" : "File operation error",
11019: JOptionPane.YES_NO_CANCEL_OPTION,
11020: JOptionPane.ERROR_MESSAGE,
11021: null,
11022: options,
11023: options[def]);
11024: if (bit == JOptionPane.CLOSED_OPTION) {
11025: bit = def;
11026: }
11027: return 1 << bit;
11028: }
11029:
11030:
11031:
11032:
11033:
11034:
11035: public static boolean rscPutTextFile (String name, String string) {
11036: return rscPutTextFile (name, string, "UTF-8");
11037: }
11038: public static boolean rscPutTextFile (String name, ArrayList<String> strings) {
11039: return rscPutTextFile (name, strings, "UTF-8");
11040: }
11041: public static boolean rscPutTextFile (String name, String string, String charset) {
11042: ArrayList<String> strings = new ArrayList<String> ();
11043: strings.add (string);
11044: return rscPutTextFile (name, strings, charset);
11045: }
11046: public static boolean rscPutTextFile (String name, ArrayList<String> strings, String charset) {
11047: String nameTmp = name + ".tmp";
11048: String nameBak = name + ".bak";
11049: File file = new File (name);
11050: File fileTmp = new File (nameTmp);
11051: File fileBak = new File (nameBak);
11052:
11053: File parentDirectory = file.getParentFile ();
11054: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
11055: if (!parentDirectory.mkdirs ()) {
11056: System.out.println (parentDirectory.getPath () + (Multilingual.mlnJapanese ? " を作れません" : " cannot be created"));
11057: return false;
11058: }
11059: }
11060:
11061: if (fileTmp.exists ()) {
11062: if (!fileTmp.delete ()) {
11063: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
11064: return false;
11065: }
11066: }
11067:
11068: try (BufferedWriter bw = new BufferedWriter (new FileWriter (nameTmp, Charset.forName (charset)))) {
11069: for (String string : strings) {
11070: bw.write (string);
11071: }
11072: } catch (IOException ioe) {
11073: ioe.printStackTrace ();
11074: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " に書き出せません" : " cannot be written"));
11075: return false;
11076: }
11077:
11078: boolean fileExists = file.exists ();
11079: if (fileExists) {
11080:
11081: if (fileBak.exists ()) {
11082: if (!fileBak.delete ()) {
11083: System.out.println (nameBak + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be deleted"));
11084: return false;
11085: }
11086: }
11087:
11088: if (!file.renameTo (fileBak)) {
11089: System.out.println (name + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + nameBak + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
11090: return false;
11091: }
11092: }
11093:
11094: if (!fileTmp.renameTo (file)) {
11095: System.out.println (nameTmp + (Multilingual.mlnJapanese ? " を " : " cannot be renamed to ") + name + (Multilingual.mlnJapanese ? " にリネームできません" : ""));
11096: return false;
11097: }
11098: if (fileExists) {
11099: System.out.println (name + (Multilingual.mlnJapanese ? " を更新しました" : " was updated"));
11100: } else {
11101: System.out.println (name + (Multilingual.mlnJapanese ? " を作りました" : " was created"));
11102: }
11103: return true;
11104: }
11105:
11106:
11107:
11108:
11109:
11110:
11111:
11112:
11113:
11114: public static boolean rscPutFile (String name, byte[] array) {
11115: return rscPutFile (name, array, 0, array.length, (long) array.length);
11116: }
11117: public static boolean rscPutFile (String name, byte[] array, int offset, int length) {
11118: return rscPutFile (name, array, offset, length, (long) length);
11119: }
11120: public static boolean rscPutFile (String name, byte[] array, int offset, int length, long longLength2) {
11121: if (RSC_ZIP_SEPARATOR.matcher (name).matches ()) {
11122:
11123: return false;
11124: }
11125: File file = new File (name);
11126: boolean fileExists = file.isFile ();
11127: if (fileExists && file.length () == longLength2) {
11128: comparison:
11129: {
11130: try (BufferedInputStream bis = new BufferedInputStream (new FileInputStream (file))) {
11131: byte[] buffer = new byte[(int) Math.min (Math.max ((long) length, longLength2 - (long) length), (long) (1024 * 1024))];
11132: int position = 0;
11133: while (position < length) {
11134: int step = bis.read (buffer, 0, Math.min (buffer.length, length - position));
11135: if (step == -1) {
11136: break comparison;
11137: }
11138: int offsetPosition = offset + position;
11139: for (int i = 0; i < step; i++) {
11140: if (buffer[i] != array[offsetPosition + i]) {
11141: break comparison;
11142: }
11143: }
11144: position += step;
11145: }
11146: long longPosition2 = (long) length;
11147: while (longPosition2 < longLength2) {
11148: int step = bis.read (buffer, 0, (int) Math.min ((long) buffer.length, longLength2 - longPosition2));
11149: if (step == -1) {
11150: break comparison;
11151: }
11152: for (int i = 0; i < step; i++) {
11153: if (buffer[i] != 0) {
11154: break comparison;
11155: }
11156: }
11157: longPosition2 += (long) step;
11158: }
11159: return true;
11160: } catch (IOException ioe) {
11161: }
11162: }
11163: }
11164: String nameTmp = name + ".tmp";
11165: File fileTmp = new File (nameTmp);
11166: String nameBak = name + ".bak";
11167: File fileBak = new File (nameBak);
11168: retry:
11169: for (;;) {
11170: File parentDirectory = file.getParentFile ();
11171: if (parentDirectory != null && !parentDirectory.isDirectory ()) {
11172: String parentName = parentDirectory.getPath ();
11173: if (parentDirectory.mkdirs ()) {
11174: System.out.println (Multilingual.mlnJapanese ?
11175: parentName + " を作りました" :
11176: parentName + " was created");
11177: } else {
11178: switch (rscShowError (Multilingual.mlnJapanese ?
11179: parentName + " を作れません" :
11180: parentName + " cannot be created",
11181: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11182: case RSC_A_MASK:
11183: break retry;
11184: case RSC_R_MASK:
11185: continue retry;
11186: }
11187: }
11188: }
11189: if (fileTmp.isFile ()) {
11190: if (!fileTmp.delete ()) {
11191: switch (rscShowError (Multilingual.mlnJapanese ?
11192: nameTmp + " を削除できません" :
11193: nameTmp + " cannot be deleted",
11194: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11195: case RSC_A_MASK:
11196: break retry;
11197: case RSC_R_MASK:
11198: continue retry;
11199: }
11200: }
11201: }
11202: try (OutputStream os = name.toLowerCase ().endsWith (".gz") ?
11203: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11204: {
11205:
11206: def.setLevel (Deflater.DEFAULT_COMPRESSION);
11207:
11208: }
11209: } :
11210: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11211:
11212: os.write (array, offset, length);
11213:
11214:
11215: if ((long) length < longLength2) {
11216: byte[] buffer = new byte[(int) Math.min (longLength2 - (long) length, (long) (1024 * 1024))];
11217: Arrays.fill (buffer, 0, buffer.length, (byte) 0);
11218: long longPosition2 = (long) length;
11219: while (longPosition2 < longLength2) {
11220: int step = (int) Math.min ((long) buffer.length, longLength2 - longPosition2);
11221: os.write (buffer, 0, step);
11222: longPosition2 += (long) step;
11223: }
11224: }
11225: } catch (IOException ioe) {
11226: switch (rscShowError (Multilingual.mlnJapanese ?
11227: nameTmp + " に書き出せません" :
11228: nameTmp + " cannot be written",
11229: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11230: case RSC_A_MASK:
11231: break retry;
11232: case RSC_R_MASK:
11233: continue retry;
11234: }
11235: }
11236: if (fileExists && file.isFile ()) {
11237: if (fileBak.isFile ()) {
11238: if (!fileBak.delete ()) {
11239: switch (rscShowError (Multilingual.mlnJapanese ?
11240: nameBak + " を削除できません" :
11241: nameBak + " cannot be deleted",
11242: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11243: case RSC_A_MASK:
11244: break retry;
11245: case RSC_R_MASK:
11246: continue retry;
11247: }
11248: }
11249: }
11250: if (!file.renameTo (fileBak)) {
11251: switch (rscShowError (Multilingual.mlnJapanese ?
11252: name + " を " + nameBak + " にリネームできません" :
11253: name + " cannot be renamed to " + nameBak,
11254: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11255: case RSC_A_MASK:
11256: break retry;
11257: case RSC_R_MASK:
11258: continue retry;
11259: }
11260: }
11261: }
11262: if (fileTmp.renameTo (file)) {
11263: if (fileExists) {
11264: System.out.println (Multilingual.mlnJapanese ?
11265: name + " を更新しました" :
11266: name + " was updated");
11267: } else {
11268: System.out.println (Multilingual.mlnJapanese ?
11269: name + " を作りました" :
11270: name + " was created");
11271: }
11272: return true;
11273: } else {
11274: switch (rscShowError (Multilingual.mlnJapanese ?
11275: nameTmp + " を " + name + " にリネームできません" :
11276: nameTmp + " cannot be renamed to " + name,
11277: RSC_A_MASK | RSC_R_MASK | RSC_I_MASK)) {
11278: case RSC_A_MASK:
11279: break retry;
11280: case RSC_R_MASK:
11281: continue retry;
11282: }
11283: }
11284: break;
11285: }
11286: if (fileExists) {
11287: System.out.println (Multilingual.mlnJapanese ?
11288: name + " を更新できません" :
11289: name + " cannot be updated");
11290: } else {
11291: System.out.println (Multilingual.mlnJapanese ?
11292: name + " を作れません" :
11293: name + " cannot be created");
11294: }
11295: return false;
11296: }
11297:
11298:
11299:
11300:
11301:
11302:
11303: public static final Pattern ISM_ZIP_SEPARATOR = Pattern.compile ("(?<=\\.(?:jar|zip))(?:/|\\\\)(?=.)", Pattern.CASE_INSENSITIVE);
11304:
11305:
11306:
11307:
11308:
11309:
11310:
11311:
11312:
11313:
11314:
11315: public static InputStream ismOpen (String name) {
11316: InputStream in = null;
11317: in = ismOpen (name, false);
11318: if (in == null && name.indexOf ('/') < 0 && name.indexOf ('\\') < 0) {
11319: in = ismOpen (name, true);
11320: }
11321: return in;
11322: }
11323: public static InputStream ismOpen (String name, boolean useGetResource) {
11324: boolean gzipped = name.toLowerCase ().endsWith (".gz");
11325: String[] zipSplittedName = ISM_ZIP_SEPARATOR.split (name, 2);
11326: String fileName = zipSplittedName[0];
11327: String zipEntryName = zipSplittedName.length < 2 ? null : zipSplittedName[1];
11328: InputStream in = null;
11329: try {
11330: if (useGetResource) {
11331: if (false) {
11332: URL url = XEiJ.class.getResource (fileName);
11333: if (url != null) {
11334: in = url.openStream ();
11335: }
11336: } else {
11337: in = XEiJ.class.getResourceAsStream (fileName);
11338: }
11339: } else {
11340: File file = new File (fileName);
11341: if (file.exists ()) {
11342: in = new FileInputStream (file);
11343: }
11344: }
11345: if (in != null && zipEntryName != null) {
11346: ZipInputStream zin = new ZipInputStream (in);
11347: in = null;
11348: ZipEntry entry;
11349: while ((entry = zin.getNextEntry ()) != null) {
11350: if (zipEntryName.equals (entry.getName ())) {
11351: in = zin;
11352: break;
11353: }
11354: }
11355: if (in == null) {
11356: System.out.println (Multilingual.mlnJapanese ? fileName + " の中に " + zipEntryName + " がありません" :
11357: zipEntryName + " does not exist in " + fileName);
11358: }
11359: }
11360: if (in != null && gzipped) {
11361: in = new GZIPInputStream (in);
11362: }
11363: if (in != null) {
11364: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " を読み込みます" :
11365: (useGetResource ? "Reading resource file " : "Reading file ") + name);
11366: return new BufferedInputStream (in);
11367: }
11368: } catch (Exception ioe) {
11369: if (prgVerbose) {
11370: prgPrintStackTraceOf (ioe);
11371: }
11372: }
11373: System.out.println (Multilingual.mlnJapanese ? (useGetResource ? "リソースファイル " : "ファイル ") + name + " が見つかりません" :
11374: (useGetResource ? "Resource file " : "File ") + name + " is not found");
11375: return null;
11376: }
11377:
11378:
11379:
11380:
11381:
11382:
11383:
11384:
11385: public static int ismRead (InputStream in, byte[] bb, int o, int l) {
11386: try {
11387: int k = 0;
11388: while (k < l) {
11389: int t = in.read (bb, o + k, l - k);
11390: if (t < 0) {
11391: break;
11392: }
11393: k += t;
11394: }
11395: return k;
11396: } catch (IOException ioe) {
11397: if (prgVerbose) {
11398: prgPrintStackTraceOf (ioe);
11399: }
11400: }
11401: return -1;
11402: }
11403:
11404:
11405:
11406:
11407:
11408:
11409:
11410:
11411: public static int ismSkip (InputStream in, int l) {
11412: try {
11413: int k = 0;
11414: while (k < l) {
11415:
11416:
11417: if (in.read () < 0) {
11418: break;
11419: }
11420: k++;
11421: if (k < l) {
11422: int t = (int) in.skip ((long) (l - k));
11423: if (t < 0) {
11424: break;
11425: }
11426: k += t;
11427: }
11428: }
11429: return k;
11430: } catch (IOException ioe) {
11431: if (prgVerbose) {
11432: prgPrintStackTraceOf (ioe);
11433: }
11434: }
11435: return -1;
11436: }
11437:
11438:
11439:
11440:
11441:
11442: public static void ismClose (InputStream in) {
11443: try {
11444: if (in != null) {
11445: in.close ();
11446: }
11447: } catch (IOException ioe) {
11448: if (prgVerbose) {
11449: prgPrintStackTraceOf (ioe);
11450: }
11451: }
11452: }
11453:
11454:
11455:
11456:
11457:
11458:
11459: public static int ismLength (String name, int maxLength) {
11460: int length;
11461: InputStream in = ismOpen (name);
11462: if (in == null) {
11463: length = -1;
11464: } else {
11465: length = ismSkip (in, maxLength);
11466: ismClose (in);
11467: }
11468: return length;
11469: }
11470:
11471:
11472:
11473:
11474:
11475:
11476:
11477:
11478:
11479:
11480:
11481:
11482:
11483:
11484: public static boolean ismLoad (byte[] bb, int o, int l, String names) {
11485: for (String name : names.split (",")) {
11486: if (name.length () != 0) {
11487: InputStream in = ismOpen (name);
11488: if (in != null) {
11489: int k = ismRead (in, bb, o, l);
11490: ismClose (in);
11491: if (k == l) {
11492: return true;
11493: }
11494: }
11495: }
11496: }
11497: return false;
11498: }
11499:
11500:
11501:
11502:
11503:
11504:
11505:
11506:
11507:
11508: public static boolean ismSave (byte[] bb, int offset, long length, String path, boolean verbose) {
11509: if (ISM_ZIP_SEPARATOR.split (path, 2).length != 1) {
11510: if (verbose) {
11511: pnlExitFullScreen (true);
11512: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? path + " に書き出せません" : "Cannot write " + path);
11513: }
11514: return false;
11515: }
11516: long step = 0;
11517: byte[] zz = null;
11518: long pointer = (long) (bb.length - offset);
11519: if (pointer < length) {
11520: step = Math.min (1024L * 512, length - pointer);
11521: zz = new byte[(int) step];
11522: Arrays.fill (zz, (byte) 0);
11523: }
11524:
11525: File file = new File (path);
11526:
11527: if (step == 0 &&
11528: file.exists () && file.length () == length) {
11529:
11530: if (length == 0L) {
11531: return true;
11532: }
11533: InputStream in = ismOpen (path);
11534: if (in != null) {
11535: int l = (int) length;
11536: byte[] tt = new byte[l];
11537: int k = ismRead (in, tt, 0, l);
11538: ismClose (in);
11539: if (k == l &&
11540: Arrays.equals (tt, bb.length == l ? bb : Arrays.copyOfRange (bb, offset, offset + l))) {
11541: return true;
11542: }
11543: }
11544: }
11545:
11546: String pathTmp = path + ".tmp";
11547: String pathBak = path + ".bak";
11548: File fileTmp = new File (pathTmp);
11549: File fileBak = new File (pathBak);
11550:
11551: if (fileTmp.exists ()) {
11552: if (!fileTmp.delete ()) {
11553: if (verbose) {
11554: pnlExitFullScreen (true);
11555: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " を削除できません" : "Cannot delete " + pathTmp);
11556: }
11557: return false;
11558: }
11559: }
11560:
11561: try (OutputStream out = path.toLowerCase ().endsWith (".gz") ?
11562: new GZIPOutputStream (new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11563: {
11564:
11565: def.setLevel (Deflater.DEFAULT_COMPRESSION);
11566:
11567: }
11568: } :
11569: new BufferedOutputStream (new FileOutputStream (fileTmp))) {
11570: if (step == 0) {
11571: out.write (bb, offset, (int) length);
11572: } else {
11573: out.write (bb, offset, (int) pointer);
11574: for (; pointer < length; pointer += step) {
11575: out.write (zz, 0, (int) Math.min (step, length - pointer));
11576: }
11577: }
11578: } catch (IOException ioe) {
11579: if (verbose) {
11580: prgPrintStackTraceOf (ioe);
11581: pnlExitFullScreen (true);
11582: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathTmp + " に書き出せません" : "Cannot write " + pathTmp);
11583: }
11584: return false;
11585: }
11586:
11587:
11588: if (file.exists ()) {
11589: if (fileBak.exists ()) {
11590: if (!fileBak.delete ()) {
11591: if (verbose) {
11592: pnlExitFullScreen (true);
11593: JOptionPane.showMessageDialog (null, Multilingual.mlnJapanese ? pathBak + " を削除できません" : "Cannot delete " + pathBak);
11594: }
11595: return false;
11596: }
11597: }
11598: if (!file.renameTo (fileBak)) {
11599: if (verbose) {
11600: pnlExitFullScreen (true);
11601: JOptionPane.showMessageDialog (
11602: null, Multilingual.mlnJapanese ? path + " を " + pathBak + " にリネームできません" : "Cannot rename " + path + " to " + pathBak);
11603: }
11604: return false;
11605: }
11606: }
11607:
11608:
11609: if (!fileTmp.renameTo (file)) {
11610: if (verbose) {
11611: pnlExitFullScreen (true);
11612: JOptionPane.showMessageDialog (
11613: null, Multilingual.mlnJapanese ? pathTmp + " を " + path + " にリネームできません" : "Cannot rename " + pathTmp + " to " + path);
11614: }
11615: return false;
11616: }
11617: return true;
11618: }
11619:
11620:
11621:
11622:
11623:
11624:
11625:
11626: public static final char[] FMT_TEMP = new char[32];
11627:
11628:
11629:
11630:
11631:
11632:
11633:
11634:
11635:
11636:
11637:
11638: public static final char[] FMT_AIN4_BASE = ".......*..*...**.*...*.*.**..****...*..**.*.*.****..**.****.****".toCharArray ();
11639: public static final char[] FMT_BIN4_BASE = "0000000100100011010001010110011110001001101010111100110111101111".toCharArray ();
11640:
11641:
11642:
11643:
11644:
11645:
11646:
11647:
11648: public static void fmtAin4 (char[] a, int o, int x) {
11649: a[o ] = (char) (x >> 1 & 4 ^ 46);
11650: a[o + 1] = (char) (x & 4 ^ 46);
11651: a[o + 2] = (char) (x << 1 & 4 ^ 46);
11652: a[o + 3] = (char) (x << 2 & 4 ^ 46);
11653: }
11654: public static void fmtBin4 (char[] a, int o, int x) {
11655: a[o ] = (char) (x >>> 3 & 1 | 48);
11656: a[o + 1] = (char) (x >>> 2 & 1 | 48);
11657: a[o + 2] = (char) (x >>> 1 & 1 | 48);
11658: a[o + 3] = (char) (x & 1 | 48);
11659: }
11660: public static String fmtAin4 (int x) {
11661: return String.valueOf (FMT_AIN4_BASE, (x & 15) << 2, 4);
11662: }
11663: public static String fmtBin4 (int x) {
11664: return String.valueOf (FMT_BIN4_BASE, (x & 15) << 2, 4);
11665: }
11666: public static StringBuilder fmtAin4 (StringBuilder sb, int x) {
11667: return sb.append (FMT_AIN4_BASE, (x & 15) << 2, 6);
11668: }
11669: public static StringBuilder fmtBin4 (StringBuilder sb, int x) {
11670: return sb.append (FMT_BIN4_BASE, (x & 15) << 2, 6);
11671: }
11672:
11673:
11674:
11675:
11676:
11677:
11678:
11679:
11680: public static void fmtAin6 (char[] a, int o, int x) {
11681: a[o ] = (char) (x >> 3 & 4 ^ 46);
11682: a[o + 1] = (char) (x >> 2 & 4 ^ 46);
11683: a[o + 2] = (char) (x >> 1 & 4 ^ 46);
11684: a[o + 3] = (char) (x & 4 ^ 46);
11685: a[o + 4] = (char) (x << 1 & 4 ^ 46);
11686: a[o + 5] = (char) (x << 2 & 4 ^ 46);
11687: }
11688: public static void fmtBin6 (char[] a, int o, int x) {
11689: a[o ] = (char) (x >>> 5 & 1 | 48);
11690: a[o + 1] = (char) (x >>> 4 & 1 | 48);
11691: a[o + 2] = (char) (x >>> 3 & 1 | 48);
11692: a[o + 3] = (char) (x >>> 2 & 1 | 48);
11693: a[o + 4] = (char) (x >>> 1 & 1 | 48);
11694: a[o + 5] = (char) (x & 1 | 48);
11695: }
11696: public static String fmtAin6 (int x) {
11697: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11698: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11699: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11700: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11701: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11702: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11703: return String.valueOf (FMT_TEMP, 0, 6);
11704: }
11705: public static String fmtBin6 (int x) {
11706: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11707: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11708: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11709: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11710: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11711: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11712: return String.valueOf (FMT_TEMP, 0, 6);
11713: }
11714: public static StringBuilder fmtAin6 (StringBuilder sb, int x) {
11715: FMT_TEMP[ 0] = (char) (x >> 3 & 4 ^ 46);
11716: FMT_TEMP[ 1] = (char) (x >> 2 & 4 ^ 46);
11717: FMT_TEMP[ 2] = (char) (x >> 1 & 4 ^ 46);
11718: FMT_TEMP[ 3] = (char) (x & 4 ^ 46);
11719: FMT_TEMP[ 4] = (char) (x << 1 & 4 ^ 46);
11720: FMT_TEMP[ 5] = (char) (x << 2 & 4 ^ 46);
11721: return sb.append (FMT_TEMP, 0, 6);
11722: }
11723: public static StringBuilder fmtBin6 (StringBuilder sb, int x) {
11724: FMT_TEMP[ 0] = (char) (x >>> 5 & 1 | 48);
11725: FMT_TEMP[ 1] = (char) (x >>> 4 & 1 | 48);
11726: FMT_TEMP[ 2] = (char) (x >>> 3 & 1 | 48);
11727: FMT_TEMP[ 3] = (char) (x >>> 2 & 1 | 48);
11728: FMT_TEMP[ 4] = (char) (x >>> 1 & 1 | 48);
11729: FMT_TEMP[ 5] = (char) (x & 1 | 48);
11730: return sb.append (FMT_TEMP, 0, 6);
11731: }
11732:
11733:
11734:
11735:
11736:
11737:
11738:
11739:
11740: public static void fmtAin8 (char[] a, int o, int x) {
11741: a[o ] = (char) (x >> 5 & 4 ^ 46);
11742: a[o + 1] = (char) (x >> 4 & 4 ^ 46);
11743: a[o + 2] = (char) (x >> 3 & 4 ^ 46);
11744: a[o + 3] = (char) (x >> 2 & 4 ^ 46);
11745: a[o + 4] = (char) (x >> 1 & 4 ^ 46);
11746: a[o + 5] = (char) (x & 4 ^ 46);
11747: a[o + 6] = (char) (x << 1 & 4 ^ 46);
11748: a[o + 7] = (char) (x << 2 & 4 ^ 46);
11749: }
11750: public static void fmtBin8 (char[] a, int o, int x) {
11751: a[o ] = (char) (x >>> 7 & 1 | 48);
11752: a[o + 1] = (char) (x >>> 6 & 1 | 48);
11753: a[o + 2] = (char) (x >>> 5 & 1 | 48);
11754: a[o + 3] = (char) (x >>> 4 & 1 | 48);
11755: a[o + 4] = (char) (x >>> 3 & 1 | 48);
11756: a[o + 5] = (char) (x >>> 2 & 1 | 48);
11757: a[o + 6] = (char) (x >>> 1 & 1 | 48);
11758: a[o + 7] = (char) (x & 1 | 48);
11759: }
11760: public static String fmtAin8 (int x) {
11761: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11762: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11763: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11764: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11765: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11766: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11767: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11768: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11769: return String.valueOf (FMT_TEMP, 0, 8);
11770: }
11771: public static String fmtBin8 (int x) {
11772: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11773: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11774: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11775: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11776: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11777: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11778: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11779: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11780: return String.valueOf (FMT_TEMP, 0, 8);
11781: }
11782: public static StringBuilder fmtAin8 (StringBuilder sb, int x) {
11783: FMT_TEMP[ 0] = (char) (x >> 5 & 4 ^ 46);
11784: FMT_TEMP[ 1] = (char) (x >> 4 & 4 ^ 46);
11785: FMT_TEMP[ 2] = (char) (x >> 3 & 4 ^ 46);
11786: FMT_TEMP[ 3] = (char) (x >> 2 & 4 ^ 46);
11787: FMT_TEMP[ 4] = (char) (x >> 1 & 4 ^ 46);
11788: FMT_TEMP[ 5] = (char) (x & 4 ^ 46);
11789: FMT_TEMP[ 6] = (char) (x << 1 & 4 ^ 46);
11790: FMT_TEMP[ 7] = (char) (x << 2 & 4 ^ 46);
11791: return sb.append (FMT_TEMP, 0, 8);
11792: }
11793: public static StringBuilder fmtBin8 (StringBuilder sb, int x) {
11794: FMT_TEMP[ 0] = (char) (x >>> 7 & 1 | 48);
11795: FMT_TEMP[ 1] = (char) (x >>> 6 & 1 | 48);
11796: FMT_TEMP[ 2] = (char) (x >>> 5 & 1 | 48);
11797: FMT_TEMP[ 3] = (char) (x >>> 4 & 1 | 48);
11798: FMT_TEMP[ 4] = (char) (x >>> 3 & 1 | 48);
11799: FMT_TEMP[ 5] = (char) (x >>> 2 & 1 | 48);
11800: FMT_TEMP[ 6] = (char) (x >>> 1 & 1 | 48);
11801: FMT_TEMP[ 7] = (char) (x & 1 | 48);
11802: return sb.append (FMT_TEMP, 0, 8);
11803: }
11804:
11805:
11806:
11807:
11808:
11809:
11810:
11811:
11812: public static void fmtAin12 (char[] a, int o, int x) {
11813: a[o ] = (char) (x >> 9 & 4 ^ 46);
11814: a[o + 1] = (char) (x >> 8 & 4 ^ 46);
11815: a[o + 2] = (char) (x >> 7 & 4 ^ 46);
11816: a[o + 3] = (char) (x >> 6 & 4 ^ 46);
11817: a[o + 4] = (char) (x >> 5 & 4 ^ 46);
11818: a[o + 5] = (char) (x >> 4 & 4 ^ 46);
11819: a[o + 6] = (char) (x >> 3 & 4 ^ 46);
11820: a[o + 7] = (char) (x >> 2 & 4 ^ 46);
11821: a[o + 8] = (char) (x >> 1 & 4 ^ 46);
11822: a[o + 9] = (char) (x & 4 ^ 46);
11823: a[o + 10] = (char) (x << 1 & 4 ^ 46);
11824: a[o + 11] = (char) (x << 2 & 4 ^ 46);
11825: }
11826: public static void fmtBin12 (char[] a, int o, int x) {
11827: a[o ] = (char) (x >>> 11 & 1 | 48);
11828: a[o + 1] = (char) (x >>> 10 & 1 | 48);
11829: a[o + 2] = (char) (x >>> 9 & 1 | 48);
11830: a[o + 3] = (char) (x >>> 8 & 1 | 48);
11831: a[o + 4] = (char) (x >>> 7 & 1 | 48);
11832: a[o + 5] = (char) (x >>> 6 & 1 | 48);
11833: a[o + 6] = (char) (x >>> 5 & 1 | 48);
11834: a[o + 7] = (char) (x >>> 4 & 1 | 48);
11835: a[o + 8] = (char) (x >>> 3 & 1 | 48);
11836: a[o + 9] = (char) (x >>> 2 & 1 | 48);
11837: a[o + 10] = (char) (x >>> 1 & 1 | 48);
11838: a[o + 11] = (char) (x & 1 | 48);
11839: }
11840: public static String fmtAin12 (int x) {
11841: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11842: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11843: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11844: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11845: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11846: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11847: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11848: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11849: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11850: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11851: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11852: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11853: return String.valueOf (FMT_TEMP, 0, 12);
11854: }
11855: public static String fmtBin12 (int x) {
11856: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11857: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11858: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11859: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11860: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11861: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11862: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11863: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11864: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11865: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11866: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11867: FMT_TEMP[11] = (char) (x & 1 | 48);
11868: return String.valueOf (FMT_TEMP, 0, 12);
11869: }
11870: public static StringBuilder fmtAin12 (StringBuilder sb, int x) {
11871: FMT_TEMP[ 0] = (char) (x >> 9 & 4 ^ 46);
11872: FMT_TEMP[ 1] = (char) (x >> 8 & 4 ^ 46);
11873: FMT_TEMP[ 2] = (char) (x >> 7 & 4 ^ 46);
11874: FMT_TEMP[ 3] = (char) (x >> 6 & 4 ^ 46);
11875: FMT_TEMP[ 4] = (char) (x >> 5 & 4 ^ 46);
11876: FMT_TEMP[ 5] = (char) (x >> 4 & 4 ^ 46);
11877: FMT_TEMP[ 6] = (char) (x >> 3 & 4 ^ 46);
11878: FMT_TEMP[ 7] = (char) (x >> 2 & 4 ^ 46);
11879: FMT_TEMP[ 8] = (char) (x >> 1 & 4 ^ 46);
11880: FMT_TEMP[ 9] = (char) (x & 4 ^ 46);
11881: FMT_TEMP[10] = (char) (x << 1 & 4 ^ 46);
11882: FMT_TEMP[11] = (char) (x << 2 & 4 ^ 46);
11883: return sb.append (FMT_TEMP, 0, 12);
11884: }
11885: public static StringBuilder fmtBin12 (StringBuilder sb, int x) {
11886: FMT_TEMP[ 0] = (char) (x >>> 11 & 1 | 48);
11887: FMT_TEMP[ 1] = (char) (x >>> 10 & 1 | 48);
11888: FMT_TEMP[ 2] = (char) (x >>> 9 & 1 | 48);
11889: FMT_TEMP[ 3] = (char) (x >>> 8 & 1 | 48);
11890: FMT_TEMP[ 4] = (char) (x >>> 7 & 1 | 48);
11891: FMT_TEMP[ 5] = (char) (x >>> 6 & 1 | 48);
11892: FMT_TEMP[ 6] = (char) (x >>> 5 & 1 | 48);
11893: FMT_TEMP[ 7] = (char) (x >>> 4 & 1 | 48);
11894: FMT_TEMP[ 8] = (char) (x >>> 3 & 1 | 48);
11895: FMT_TEMP[ 9] = (char) (x >>> 2 & 1 | 48);
11896: FMT_TEMP[10] = (char) (x >>> 1 & 1 | 48);
11897: FMT_TEMP[11] = (char) (x & 1 | 48);
11898: return sb.append (FMT_TEMP, 0, 12);
11899: }
11900:
11901:
11902:
11903:
11904:
11905:
11906:
11907:
11908: public static void fmtAin16 (char[] a, int o, int x) {
11909: a[o ] = (char) (x >> 13 & 4 ^ 46);
11910: a[o + 1] = (char) (x >> 12 & 4 ^ 46);
11911: a[o + 2] = (char) (x >> 11 & 4 ^ 46);
11912: a[o + 3] = (char) (x >> 10 & 4 ^ 46);
11913: a[o + 4] = (char) (x >> 9 & 4 ^ 46);
11914: a[o + 5] = (char) (x >> 8 & 4 ^ 46);
11915: a[o + 6] = (char) (x >> 7 & 4 ^ 46);
11916: a[o + 7] = (char) (x >> 6 & 4 ^ 46);
11917: a[o + 8] = (char) (x >> 5 & 4 ^ 46);
11918: a[o + 9] = (char) (x >> 4 & 4 ^ 46);
11919: a[o + 10] = (char) (x >> 3 & 4 ^ 46);
11920: a[o + 11] = (char) (x >> 2 & 4 ^ 46);
11921: a[o + 12] = (char) (x >> 1 & 4 ^ 46);
11922: a[o + 13] = (char) (x & 4 ^ 46);
11923: a[o + 14] = (char) (x << 1 & 4 ^ 46);
11924: a[o + 15] = (char) (x << 2 & 4 ^ 46);
11925: }
11926: public static void fmtBin16 (char[] a, int o, int x) {
11927: a[o ] = (char) (x >>> 15 & 1 | 48);
11928: a[o + 1] = (char) (x >>> 14 & 1 | 48);
11929: a[o + 2] = (char) (x >>> 13 & 1 | 48);
11930: a[o + 3] = (char) (x >>> 12 & 1 | 48);
11931: a[o + 4] = (char) (x >>> 11 & 1 | 48);
11932: a[o + 5] = (char) (x >>> 10 & 1 | 48);
11933: a[o + 6] = (char) (x >>> 9 & 1 | 48);
11934: a[o + 7] = (char) (x >>> 8 & 1 | 48);
11935: a[o + 8] = (char) (x >>> 7 & 1 | 48);
11936: a[o + 9] = (char) (x >>> 6 & 1 | 48);
11937: a[o + 10] = (char) (x >>> 5 & 1 | 48);
11938: a[o + 11] = (char) (x >>> 4 & 1 | 48);
11939: a[o + 12] = (char) (x >>> 3 & 1 | 48);
11940: a[o + 13] = (char) (x >>> 2 & 1 | 48);
11941: a[o + 14] = (char) (x >>> 1 & 1 | 48);
11942: a[o + 15] = (char) (x & 1 | 48);
11943: }
11944: public static String fmtAin16 (int x) {
11945: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11946: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11947: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11948: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11949: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11950: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11951: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11952: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11953: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11954: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11955: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11956: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11957: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11958: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11959: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11960: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11961: return String.valueOf (FMT_TEMP, 0, 16);
11962: }
11963: public static String fmtBin16 (int x) {
11964: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
11965: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
11966: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
11967: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
11968: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
11969: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
11970: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
11971: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
11972: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
11973: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
11974: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
11975: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
11976: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
11977: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
11978: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
11979: FMT_TEMP[15] = (char) (x & 1 | 48);
11980: return String.valueOf (FMT_TEMP, 0, 16);
11981: }
11982: public static StringBuilder fmtAin16 (StringBuilder sb, int x) {
11983: FMT_TEMP[ 0] = (char) (x >> 13 & 4 ^ 46);
11984: FMT_TEMP[ 1] = (char) (x >> 12 & 4 ^ 46);
11985: FMT_TEMP[ 2] = (char) (x >> 11 & 4 ^ 46);
11986: FMT_TEMP[ 3] = (char) (x >> 10 & 4 ^ 46);
11987: FMT_TEMP[ 4] = (char) (x >> 9 & 4 ^ 46);
11988: FMT_TEMP[ 5] = (char) (x >> 8 & 4 ^ 46);
11989: FMT_TEMP[ 6] = (char) (x >> 7 & 4 ^ 46);
11990: FMT_TEMP[ 7] = (char) (x >> 6 & 4 ^ 46);
11991: FMT_TEMP[ 8] = (char) (x >> 5 & 4 ^ 46);
11992: FMT_TEMP[ 9] = (char) (x >> 4 & 4 ^ 46);
11993: FMT_TEMP[10] = (char) (x >> 3 & 4 ^ 46);
11994: FMT_TEMP[11] = (char) (x >> 2 & 4 ^ 46);
11995: FMT_TEMP[12] = (char) (x >> 1 & 4 ^ 46);
11996: FMT_TEMP[13] = (char) (x & 4 ^ 46);
11997: FMT_TEMP[14] = (char) (x << 1 & 4 ^ 46);
11998: FMT_TEMP[15] = (char) (x << 2 & 4 ^ 46);
11999: return sb.append (FMT_TEMP, 0, 16);
12000: }
12001: public static StringBuilder fmtBin16 (StringBuilder sb, int x) {
12002: FMT_TEMP[ 0] = (char) (x >>> 15 & 1 | 48);
12003: FMT_TEMP[ 1] = (char) (x >>> 14 & 1 | 48);
12004: FMT_TEMP[ 2] = (char) (x >>> 13 & 1 | 48);
12005: FMT_TEMP[ 3] = (char) (x >>> 12 & 1 | 48);
12006: FMT_TEMP[ 4] = (char) (x >>> 11 & 1 | 48);
12007: FMT_TEMP[ 5] = (char) (x >>> 10 & 1 | 48);
12008: FMT_TEMP[ 6] = (char) (x >>> 9 & 1 | 48);
12009: FMT_TEMP[ 7] = (char) (x >>> 8 & 1 | 48);
12010: FMT_TEMP[ 8] = (char) (x >>> 7 & 1 | 48);
12011: FMT_TEMP[ 9] = (char) (x >>> 6 & 1 | 48);
12012: FMT_TEMP[10] = (char) (x >>> 5 & 1 | 48);
12013: FMT_TEMP[11] = (char) (x >>> 4 & 1 | 48);
12014: FMT_TEMP[12] = (char) (x >>> 3 & 1 | 48);
12015: FMT_TEMP[13] = (char) (x >>> 2 & 1 | 48);
12016: FMT_TEMP[14] = (char) (x >>> 1 & 1 | 48);
12017: FMT_TEMP[15] = (char) (x & 1 | 48);
12018: return sb.append (FMT_TEMP, 0, 16);
12019: }
12020:
12021:
12022:
12023:
12024:
12025:
12026:
12027:
12028: public static void fmtAin24 (char[] a, int o, int x) {
12029: a[o ] = (char) (x >> 21 & 4 ^ 46);
12030: a[o + 1] = (char) (x >> 20 & 4 ^ 46);
12031: a[o + 2] = (char) (x >> 19 & 4 ^ 46);
12032: a[o + 3] = (char) (x >> 18 & 4 ^ 46);
12033: a[o + 4] = (char) (x >> 17 & 4 ^ 46);
12034: a[o + 5] = (char) (x >> 16 & 4 ^ 46);
12035: a[o + 6] = (char) (x >> 15 & 4 ^ 46);
12036: a[o + 7] = (char) (x >> 14 & 4 ^ 46);
12037: a[o + 8] = (char) (x >> 13 & 4 ^ 46);
12038: a[o + 9] = (char) (x >> 12 & 4 ^ 46);
12039: a[o + 10] = (char) (x >> 11 & 4 ^ 46);
12040: a[o + 11] = (char) (x >> 10 & 4 ^ 46);
12041: a[o + 12] = (char) (x >> 9 & 4 ^ 46);
12042: a[o + 13] = (char) (x >> 8 & 4 ^ 46);
12043: a[o + 14] = (char) (x >> 7 & 4 ^ 46);
12044: a[o + 15] = (char) (x >> 6 & 4 ^ 46);
12045: a[o + 16] = (char) (x >> 5 & 4 ^ 46);
12046: a[o + 17] = (char) (x >> 4 & 4 ^ 46);
12047: a[o + 18] = (char) (x >> 3 & 4 ^ 46);
12048: a[o + 19] = (char) (x >> 2 & 4 ^ 46);
12049: a[o + 20] = (char) (x >> 1 & 4 ^ 46);
12050: a[o + 21] = (char) (x & 4 ^ 46);
12051: a[o + 22] = (char) (x << 1 & 4 ^ 46);
12052: a[o + 23] = (char) (x << 2 & 4 ^ 46);
12053: }
12054: public static void fmtBin24 (char[] a, int o, int x) {
12055: a[o ] = (char) (x >>> 23 & 1 | 48);
12056: a[o + 1] = (char) (x >>> 22 & 1 | 48);
12057: a[o + 2] = (char) (x >>> 21 & 1 | 48);
12058: a[o + 3] = (char) (x >>> 20 & 1 | 48);
12059: a[o + 4] = (char) (x >>> 19 & 1 | 48);
12060: a[o + 5] = (char) (x >>> 18 & 1 | 48);
12061: a[o + 6] = (char) (x >>> 17 & 1 | 48);
12062: a[o + 7] = (char) (x >>> 16 & 1 | 48);
12063: a[o + 8] = (char) (x >>> 15 & 1 | 48);
12064: a[o + 9] = (char) (x >>> 14 & 1 | 48);
12065: a[o + 10] = (char) (x >>> 13 & 1 | 48);
12066: a[o + 11] = (char) (x >>> 12 & 1 | 48);
12067: a[o + 12] = (char) (x >>> 11 & 1 | 48);
12068: a[o + 13] = (char) (x >>> 10 & 1 | 48);
12069: a[o + 14] = (char) (x >>> 9 & 1 | 48);
12070: a[o + 15] = (char) (x >>> 8 & 1 | 48);
12071: a[o + 16] = (char) (x >>> 7 & 1 | 48);
12072: a[o + 17] = (char) (x >>> 6 & 1 | 48);
12073: a[o + 18] = (char) (x >>> 5 & 1 | 48);
12074: a[o + 19] = (char) (x >>> 4 & 1 | 48);
12075: a[o + 20] = (char) (x >>> 3 & 1 | 48);
12076: a[o + 21] = (char) (x >>> 2 & 1 | 48);
12077: a[o + 22] = (char) (x >>> 1 & 1 | 48);
12078: a[o + 23] = (char) (x & 1 | 48);
12079: }
12080: public static String fmtAin24 (int x) {
12081: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
12082: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
12083: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
12084: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
12085: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
12086: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
12087: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
12088: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
12089: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
12090: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
12091: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
12092: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
12093: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
12094: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
12095: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
12096: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
12097: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
12098: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
12099: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
12100: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
12101: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
12102: FMT_TEMP[21] = (char) (x & 4 ^ 46);
12103: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
12104: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
12105: return String.valueOf (FMT_TEMP, 0, 24);
12106: }
12107: public static String fmtBin24 (int x) {
12108: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
12109: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
12110: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
12111: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
12112: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
12113: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
12114: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
12115: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
12116: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
12117: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
12118: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
12119: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
12120: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
12121: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
12122: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
12123: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
12124: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
12125: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
12126: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
12127: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
12128: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
12129: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
12130: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
12131: FMT_TEMP[23] = (char) (x & 1 | 48);
12132: return String.valueOf (FMT_TEMP, 0, 24);
12133: }
12134: public static StringBuilder fmtAin24 (StringBuilder sb, int x) {
12135: FMT_TEMP[ 0] = (char) (x >> 21 & 4 ^ 46);
12136: FMT_TEMP[ 1] = (char) (x >> 20 & 4 ^ 46);
12137: FMT_TEMP[ 2] = (char) (x >> 19 & 4 ^ 46);
12138: FMT_TEMP[ 3] = (char) (x >> 18 & 4 ^ 46);
12139: FMT_TEMP[ 4] = (char) (x >> 17 & 4 ^ 46);
12140: FMT_TEMP[ 5] = (char) (x >> 16 & 4 ^ 46);
12141: FMT_TEMP[ 6] = (char) (x >> 15 & 4 ^ 46);
12142: FMT_TEMP[ 7] = (char) (x >> 14 & 4 ^ 46);
12143: FMT_TEMP[ 8] = (char) (x >> 13 & 4 ^ 46);
12144: FMT_TEMP[ 9] = (char) (x >> 12 & 4 ^ 46);
12145: FMT_TEMP[10] = (char) (x >> 11 & 4 ^ 46);
12146: FMT_TEMP[11] = (char) (x >> 10 & 4 ^ 46);
12147: FMT_TEMP[12] = (char) (x >> 9 & 4 ^ 46);
12148: FMT_TEMP[13] = (char) (x >> 8 & 4 ^ 46);
12149: FMT_TEMP[14] = (char) (x >> 7 & 4 ^ 46);
12150: FMT_TEMP[15] = (char) (x >> 6 & 4 ^ 46);
12151: FMT_TEMP[16] = (char) (x >> 5 & 4 ^ 46);
12152: FMT_TEMP[17] = (char) (x >> 4 & 4 ^ 46);
12153: FMT_TEMP[18] = (char) (x >> 3 & 4 ^ 46);
12154: FMT_TEMP[19] = (char) (x >> 2 & 4 ^ 46);
12155: FMT_TEMP[20] = (char) (x >> 1 & 4 ^ 46);
12156: FMT_TEMP[21] = (char) (x & 4 ^ 46);
12157: FMT_TEMP[22] = (char) (x << 1 & 4 ^ 46);
12158: FMT_TEMP[23] = (char) (x << 2 & 4 ^ 46);
12159: return sb.append (FMT_TEMP, 0, 24);
12160: }
12161: public static StringBuilder fmtBin24 (StringBuilder sb, int x) {
12162: FMT_TEMP[ 0] = (char) (x >>> 23 & 1 | 48);
12163: FMT_TEMP[ 1] = (char) (x >>> 22 & 1 | 48);
12164: FMT_TEMP[ 2] = (char) (x >>> 21 & 1 | 48);
12165: FMT_TEMP[ 3] = (char) (x >>> 20 & 1 | 48);
12166: FMT_TEMP[ 4] = (char) (x >>> 19 & 1 | 48);
12167: FMT_TEMP[ 5] = (char) (x >>> 18 & 1 | 48);
12168: FMT_TEMP[ 6] = (char) (x >>> 17 & 1 | 48);
12169: FMT_TEMP[ 7] = (char) (x >>> 16 & 1 | 48);
12170: FMT_TEMP[ 8] = (char) (x >>> 15 & 1 | 48);
12171: FMT_TEMP[ 9] = (char) (x >>> 14 & 1 | 48);
12172: FMT_TEMP[10] = (char) (x >>> 13 & 1 | 48);
12173: FMT_TEMP[11] = (char) (x >>> 12 & 1 | 48);
12174: FMT_TEMP[12] = (char) (x >>> 11 & 1 | 48);
12175: FMT_TEMP[13] = (char) (x >>> 10 & 1 | 48);
12176: FMT_TEMP[14] = (char) (x >>> 9 & 1 | 48);
12177: FMT_TEMP[15] = (char) (x >>> 8 & 1 | 48);
12178: FMT_TEMP[16] = (char) (x >>> 7 & 1 | 48);
12179: FMT_TEMP[17] = (char) (x >>> 6 & 1 | 48);
12180: FMT_TEMP[18] = (char) (x >>> 5 & 1 | 48);
12181: FMT_TEMP[19] = (char) (x >>> 4 & 1 | 48);
12182: FMT_TEMP[20] = (char) (x >>> 3 & 1 | 48);
12183: FMT_TEMP[21] = (char) (x >>> 2 & 1 | 48);
12184: FMT_TEMP[22] = (char) (x >>> 1 & 1 | 48);
12185: FMT_TEMP[23] = (char) (x & 1 | 48);
12186: return sb.append (FMT_TEMP, 0, 24);
12187: }
12188:
12189:
12190:
12191:
12192:
12193:
12194:
12195:
12196:
12197:
12198:
12199:
12200:
12201:
12202:
12203:
12204:
12205:
12206:
12207:
12208:
12209:
12210:
12211:
12212:
12213:
12214:
12215:
12216:
12217:
12218:
12219:
12220:
12221: public static char fmtHexc (int x) {
12222: x &= 15;
12223: return (char) ((((9 - x) >> 4) & 7) + 48 + x);
12224: }
12225: public static void fmtHex1 (char[] a, int o, int x) {
12226: x &= 15;
12227: a[o] = (char) ((((9 - x) >> 4) & 7) + 48 + x);
12228: }
12229: public static String fmtHex1 (int x) {
12230: x &= 15;
12231: return Character.toString ((char) ((((9 - x) >> 4) & 7) + 48 + x));
12232: }
12233: public static StringBuilder fmtHex1 (StringBuilder sb, int x) {
12234: x &= 15;
12235: return sb.append ((char) ((((9 - x) >> 4) & 7) + 48 + x));
12236: }
12237:
12238:
12239:
12240:
12241:
12242:
12243: public static void fmtHex2 (char[] a, int o, int x) {
12244: int x0 = x & 15;
12245: int x1 = x >>> 4 & 15;
12246: a[o ] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
12247: a[o + 1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
12248: }
12249: public static String fmtHex2 (int x) {
12250:
12251: int x0 = x & 15;
12252: int x1 = x >>> 4 & 15;
12253: FMT_TEMP[0] = (char) ((((9 - x1) >> 4) & 7) + 48 + x1);
12254: FMT_TEMP[1] = (char) ((((9 - x0) >> 4) & 7) + 48 + x0);
12255: return String.valueOf (FMT_TEMP, 0, 2);
12256: }
12257: public static StringBuilder fmtHex2 (StringBuilder sb, int x) {
12258: int x0 = x & 15;
12259: int x1 = x >>> 4 & 15;
12260: return (sb.
12261: append ((char) ((((9 - x1) >> 4) & 7) + 48 + x1)).
12262: append ((char) ((((9 - x0) >> 4) & 7) + 48 + x0)));
12263: }
12264:
12265:
12266:
12267:
12268:
12269:
12270: public static void fmtHex4 (char[] a, int o, int x) {
12271: int t;
12272: t = (char) x >>> 12;
12273: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12274: t = x >>> 8 & 15;
12275: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12276: t = x >>> 4 & 15;
12277: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12278: t = x & 15;
12279: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12280: }
12281: public static String fmtHex4 (int x) {
12282:
12283: int t;
12284: t = (char) x >>> 12;
12285: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12286: t = x >>> 8 & 15;
12287: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12288: t = x >>> 4 & 15;
12289: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12290: t = x & 15;
12291: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12292: return String.valueOf (FMT_TEMP, 0, 4);
12293: }
12294: public static StringBuilder fmtHex4 (StringBuilder sb, int x) {
12295:
12296: int t;
12297: t = (char) x >>> 12;
12298: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12299: t = x >>> 8 & 15;
12300: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12301: t = x >>> 4 & 15;
12302: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12303: t = x & 15;
12304: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12305: return sb.append (FMT_TEMP, 0, 4);
12306: }
12307:
12308:
12309:
12310:
12311:
12312:
12313: public static void fmtHex6 (char[] a, int o, int x) {
12314: int t;
12315: t = x >>> 20 & 15;
12316: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12317: t = x >>> 16 & 15;
12318: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12319: t = (char) x >>> 12;
12320: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12321: t = x >>> 8 & 15;
12322: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12323: t = x >>> 4 & 15;
12324: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12325: t = x & 15;
12326: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12327: }
12328: public static String fmtHex6 (int x) {
12329:
12330: int t;
12331: t = x >>> 20 & 15;
12332: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12333: t = x >>> 16 & 15;
12334: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12335: t = (char) x >>> 12;
12336: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12337: t = x >>> 8 & 15;
12338: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12339: t = x >>> 4 & 15;
12340: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12341: t = x & 15;
12342: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12343: return String.valueOf (FMT_TEMP, 0, 6);
12344: }
12345: public static StringBuilder fmtHex6 (StringBuilder sb, int x) {
12346:
12347: int t;
12348: t = x >>> 20 & 15;
12349: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12350: t = x >>> 16 & 15;
12351: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12352: t = (char) x >>> 12;
12353: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12354: t = x >>> 8 & 15;
12355: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12356: t = x >>> 4 & 15;
12357: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12358: t = x & 15;
12359: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12360: return sb.append (FMT_TEMP, 0, 6);
12361: }
12362:
12363:
12364:
12365:
12366:
12367:
12368: public static void fmtHex8 (char[] a, int o, int x) {
12369: int t;
12370: t = x >>> 28;
12371: a[o ] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12372: t = x >>> 24 & 15;
12373: a[o + 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12374: t = x >>> 20 & 15;
12375: a[o + 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12376: t = x >>> 16 & 15;
12377: a[o + 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12378: t = (char) x >>> 12;
12379: a[o + 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12380: t = x >>> 8 & 15;
12381: a[o + 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12382: t = x >>> 4 & 15;
12383: a[o + 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12384: t = x & 15;
12385: a[o + 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12386: }
12387: public static String fmtHex8 (int x) {
12388:
12389: int t;
12390: t = x >>> 28;
12391: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12392: t = x >>> 24 & 15;
12393: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12394: t = x >>> 20 & 15;
12395: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12396: t = x >>> 16 & 15;
12397: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12398: t = (char) x >>> 12;
12399: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12400: t = x >>> 8 & 15;
12401: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12402: t = x >>> 4 & 15;
12403: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12404: t = x & 15;
12405: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12406: return String.valueOf (FMT_TEMP, 0, 8);
12407: }
12408: public static StringBuilder fmtHex8 (StringBuilder sb, int x) {
12409:
12410: int t;
12411: t = x >>> 28;
12412: FMT_TEMP[0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12413: t = x >>> 24 & 15;
12414: FMT_TEMP[1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12415: t = x >>> 20 & 15;
12416: FMT_TEMP[2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12417: t = x >>> 16 & 15;
12418: FMT_TEMP[3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12419: t = (char) x >>> 12;
12420: FMT_TEMP[4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12421: t = x >>> 8 & 15;
12422: FMT_TEMP[5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12423: t = x >>> 4 & 15;
12424: FMT_TEMP[6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12425: t = x & 15;
12426: FMT_TEMP[7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12427: return sb.append (FMT_TEMP, 0, 8);
12428: }
12429:
12430: public static StringBuilder fmtHex16 (StringBuilder sb, long x) {
12431:
12432: int s, t;
12433: s = (int) (x >>> 32);
12434: t = s >>> 28;
12435: FMT_TEMP[ 0] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12436: t = s >>> 24 & 15;
12437: FMT_TEMP[ 1] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12438: t = s >>> 20 & 15;
12439: FMT_TEMP[ 2] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12440: t = s >>> 16 & 15;
12441: FMT_TEMP[ 3] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12442: t = (char) s >>> 12;
12443: FMT_TEMP[ 4] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12444: t = s >>> 8 & 15;
12445: FMT_TEMP[ 5] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12446: t = s >>> 4 & 15;
12447: FMT_TEMP[ 6] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12448: t = s & 15;
12449: FMT_TEMP[ 7] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12450: s = (int) x;
12451: t = s >>> 28;
12452: FMT_TEMP[ 8] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12453: t = s >>> 24 & 15;
12454: FMT_TEMP[ 9] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12455: t = s >>> 20 & 15;
12456: FMT_TEMP[10] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12457: t = s >>> 16 & 15;
12458: FMT_TEMP[11] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12459: t = (char) s >>> 12;
12460: FMT_TEMP[12] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12461: t = s >>> 8 & 15;
12462: FMT_TEMP[13] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12463: t = s >>> 4 & 15;
12464: FMT_TEMP[14] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12465: t = s & 15;
12466: FMT_TEMP[15] = (char) ((((9 - t) >> 4) & 7) + 48 + t);
12467: return sb.append (FMT_TEMP, 0, 16);
12468: }
12469:
12470:
12471:
12472:
12473:
12474:
12475:
12476:
12477:
12478:
12479:
12480:
12481:
12482:
12483:
12484:
12485:
12486:
12487:
12488:
12489:
12490:
12491:
12492:
12493:
12494:
12495:
12496:
12497:
12498:
12499:
12500:
12501:
12502:
12503:
12504:
12505:
12506:
12507:
12508:
12509:
12510:
12511:
12512:
12513:
12514:
12515:
12516:
12517:
12518:
12519:
12520:
12521:
12522:
12523:
12524:
12525:
12526:
12527:
12528:
12529:
12530:
12531:
12532:
12533:
12534:
12535:
12536:
12537: public static final int[] FMT_BCD4 = new int[10000];
12538: public static final int[] FMT_DCB4 = new int[65536];
12539:
12540:
12541:
12542:
12543: public static void fmtInit () {
12544: Arrays.fill (FMT_DCB4, -1);
12545: int i = 0;
12546: int x = 0;
12547: for (int a = 0; a < 10; a++) {
12548: for (int b = 0; b < 10; b++) {
12549: for (int c = 0; c < 10; c++) {
12550: FMT_DCB4[FMT_BCD4[i ] = x ] = i;
12551: FMT_DCB4[FMT_BCD4[i + 1] = x + 1] = i + 1;
12552: FMT_DCB4[FMT_BCD4[i + 2] = x + 2] = i + 2;
12553: FMT_DCB4[FMT_BCD4[i + 3] = x + 3] = i + 3;
12554: FMT_DCB4[FMT_BCD4[i + 4] = x + 4] = i + 4;
12555: FMT_DCB4[FMT_BCD4[i + 5] = x + 5] = i + 5;
12556: FMT_DCB4[FMT_BCD4[i + 6] = x + 6] = i + 6;
12557: FMT_DCB4[FMT_BCD4[i + 7] = x + 7] = i + 7;
12558: FMT_DCB4[FMT_BCD4[i + 8] = x + 8] = i + 8;
12559: FMT_DCB4[FMT_BCD4[i + 9] = x + 9] = i + 9;
12560: i += 10;
12561: x += 1 << 4;
12562: }
12563: x += 6 << 4;
12564: }
12565: x += 6 << 8;
12566: }
12567: }
12568:
12569:
12570:
12571: public static int fmtBcd4 (int x) {
12572:
12573:
12574:
12575:
12576:
12577:
12578:
12579:
12580:
12581: return FMT_BCD4[Math.max (0, Math.min (9999, x))];
12582: }
12583:
12584:
12585:
12586: public static int fmtBcd8 (int x) {
12587: x = Math.max (0, Math.min (99999999, x));
12588:
12589:
12590: int q = (int) ((long) x * 109951163L >>> 40);
12591:
12592: return FMT_BCD4[q] << 16 | FMT_BCD4[x - 10000 * q];
12593: }
12594:
12595:
12596:
12597: public static long fmtBcd12 (long x) {
12598: x = Math.max (0L, Math.min (999999999999L, x));
12599: int q = (int) ((double) x / 100000000.0);
12600: int r = (int) (x - 100000000L * q);
12601:
12602:
12603: int rq = (int) ((long) r * 109951163L >>> 40);
12604:
12605: return (long) FMT_BCD4[q] << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
12606: }
12607:
12608:
12609:
12610: public static long fmtBcd16 (long x) {
12611: x = Math.max (0L, Math.min (9999999999999999L, x));
12612: int q = x <= (1L << 53) ? (int) ((double) x / 100000000.0) : (int) (x / 100000000L);
12613: int r = (int) (x - 100000000L * q);
12614:
12615:
12616: int qq = (int) ((long) q * 109951163L >>> 40);
12617:
12618:
12619:
12620: int rq = (int) ((long) r * 109951163L >>> 40);
12621:
12622: return (long) (FMT_BCD4[qq] << 16 | FMT_BCD4[q - 10000 * qq]) << 32 | 0xffffffffL & (FMT_BCD4[rq] << 16 | FMT_BCD4[r - 10000 * rq]);
12623: }
12624:
12625:
12626:
12627:
12628:
12629:
12630: public static int fmtCA02u (char[] a, int o, int x) {
12631: if (x < 0 || 99 < x) {
12632: x = 99;
12633: }
12634: x = FMT_BCD4[x];
12635: a[o ] = (char) ('0' | x >>> 4);
12636: a[o + 1] = (char) ('0' | x & 15);
12637: return o + 2;
12638: }
12639: public static StringBuilder fmtSB02u (StringBuilder sb, int x) {
12640: return sb.append (FMT_TEMP, 0, fmtCA02u (FMT_TEMP, 0, x));
12641: }
12642:
12643:
12644:
12645:
12646:
12647: public static int fmtCA2u (char[] a, int o, int x) {
12648: if (x < 0 || 99 < x) {
12649: x = 99;
12650: }
12651: x = FMT_BCD4[x];
12652: if (x <= 0x000f) {
12653: a[o++] = (char) ('0' | x);
12654: } else {
12655: a[o++] = (char) ('0' | x >>> 4);
12656: a[o++] = (char) ('0' | x & 15);
12657: }
12658: return o;
12659: }
12660: public static StringBuilder fmtSB2u (StringBuilder sb, int x) {
12661: return sb.append (FMT_TEMP, 0, fmtCA2u (FMT_TEMP, 0, x));
12662: }
12663:
12664:
12665:
12666:
12667:
12668: public static int fmtCA04u (char[] a, int o, int x) {
12669: if (x < 0 || 9999 < x) {
12670: x = 9999;
12671: }
12672: x = FMT_BCD4[x];
12673: a[o ] = (char) ('0' | x >>> 12);
12674: a[o + 1] = (char) ('0' | x >>> 8 & 15);
12675: a[o + 2] = (char) ('0' | x >>> 4 & 15);
12676: a[o + 3] = (char) ('0' | x & 15);
12677: return o + 4;
12678: }
12679: public static StringBuilder fmtSB04u (StringBuilder sb, int x) {
12680: return sb.append (FMT_TEMP, 0, fmtCA04u (FMT_TEMP, 0, x));
12681: }
12682:
12683:
12684:
12685:
12686:
12687: public static int fmtCA4u (char[] a, int o, int x) {
12688: if (x < 0 || 9999 < x) {
12689: x = 9999;
12690: }
12691: x = FMT_BCD4[x];
12692: if (x <= 0x000f) {
12693: a[o++] = (char) ('0' | x);
12694: } else if (x <= 0x00ff) {
12695: a[o++] = (char) ('0' | x >>> 4);
12696: a[o++] = (char) ('0' | x & 15);
12697: } else if (x <= 0x0fff) {
12698: a[o++] = (char) ('0' | x >>> 8);
12699: a[o++] = (char) ('0' | x >>> 4 & 15);
12700: a[o++] = (char) ('0' | x & 15);
12701: } else {
12702: a[o++] = (char) ('0' | x >>> 12);
12703: a[o++] = (char) ('0' | x >>> 8 & 15);
12704: a[o++] = (char) ('0' | x >>> 4 & 15);
12705: a[o++] = (char) ('0' | x & 15);
12706: }
12707: return o;
12708: }
12709: public static StringBuilder fmtSB4u (StringBuilder sb, int x) {
12710: return sb.append (FMT_TEMP, 0, fmtCA4u (FMT_TEMP, 0, x));
12711: }
12712:
12713:
12714:
12715:
12716:
12717: public static int fmtCA08u (char[] a, int o, int x) {
12718: if (x < 0 || 99999999 < x) {
12719: x = 99999999;
12720: }
12721:
12722:
12723: int h = (int) ((long) x * 109951163L >>> 40);
12724: return fmtCA04u (a, fmtCA04u (a, o, h), x - h * 10000);
12725: }
12726: public static StringBuilder fmtSB08u (StringBuilder sb, int x) {
12727: return sb.append (FMT_TEMP, 0, fmtCA08u (FMT_TEMP, 0, x));
12728: }
12729:
12730:
12731:
12732:
12733:
12734: public static int fmtCA8u (char[] a, int o, int x) {
12735: if (x < 0 || 99999999 < x) {
12736: x = 99999999;
12737: }
12738: if (x <= 9999) {
12739: return fmtCA4u (a, o, x);
12740: } else {
12741:
12742:
12743: int h = (int) ((long) x * 109951163L >>> 40);
12744: return fmtCA04u (a, fmtCA4u (a, o, h), x - h * 10000);
12745: }
12746: }
12747: public static StringBuilder fmtSB8u (StringBuilder sb, int x) {
12748: return sb.append (FMT_TEMP, 0, fmtCA8u (FMT_TEMP, 0, x));
12749: }
12750:
12751:
12752:
12753:
12754:
12755: public static int fmtCAd (char[] a, int o, long x) {
12756: if (x < 0L) {
12757: x = -x;
12758: a[o++] = '-';
12759: }
12760: if (x <= 99999999L) {
12761: return fmtCA8u (a, o, (int) x);
12762: } else if (x <= 9999999999999999L) {
12763: long h = x / 100000000L;
12764: return fmtCA08u (a, fmtCA8u (a, o, (int) h), (int) (x - h * 100000000L));
12765: } else {
12766: long hh = x / 10000000000000000L;
12767: x -= hh * 10000000000000000L;
12768: long h = x / 100000000L;
12769: return fmtCA08u (a, fmtCA08u (a, fmtCA4u (a, o, (int) hh), (int) h), (int) (x - h * 100000000L));
12770: }
12771: }
12772: public static StringBuilder fmtSBd (StringBuilder sb, long x) {
12773: return sb.append (FMT_TEMP, 0, fmtCAd (FMT_TEMP, 0, x));
12774: }
12775:
12776:
12777:
12778:
12779:
12780:
12781: public static int fmtCAnd (char[] a, int o, int n, long x) {
12782: int t = fmtCAd (a, o, x);
12783: n += o;
12784: if (t < n) {
12785: int i = n;
12786: while (o < t) {
12787: a[--i] = a[--t];
12788: }
12789: while (o < i) {
12790: a[--i] = ' ';
12791: }
12792: t = n;
12793: }
12794: return t;
12795: }
12796: public static StringBuilder fmtSBnd (StringBuilder sb, int n, int x) {
12797: return sb.append (FMT_TEMP, 0, fmtCAnd (FMT_TEMP, 0, n, x));
12798: }
12799:
12800:
12801:
12802:
12803:
12804:
12805:
12806:
12807:
12808:
12809:
12810:
12811:
12812: public static int fmtParseInt (String s, int i, int min, int max, int err) {
12813: return fmtParseIntRadix (s, i, min, max, err, 10);
12814: }
12815: public static int fmtParseIntRadix (String s, int i, int min, int max, int err, int radix) {
12816: if (s == null) {
12817: return err;
12818: }
12819: int l = s.length ();
12820: int c = i < l ? s.charAt (i++) : -1;
12821:
12822: while (c == ' ' || c == '\t') {
12823: c = i < l ? s.charAt (i++) : -1;
12824: }
12825:
12826: int n = 0;
12827: if (c == '+') {
12828: c = i < l ? s.charAt (i++) : -1;
12829: } else if (c == '-') {
12830: n = 1;
12831: c = i < l ? s.charAt (i++) : -1;
12832: }
12833:
12834:
12835:
12836:
12837: int o;
12838: int p;
12839: if (c == '$') {
12840: o = 0x07ffffff + n;
12841: p = 15 + n & 15;
12842: radix = 16;
12843: c = i < l ? s.charAt (i++) : -1;
12844: } else if (radix == 16) {
12845: o = 0x07ffffff + n;
12846: p = 15 + n & 15;
12847: } else if (radix == 8) {
12848: o = 0x0fffffff + n;
12849: p = 7 + n & 7;
12850: } else if (radix == 2) {
12851: o = 0x3fffffff + n;
12852: p = 1 + n & 1;
12853: } else {
12854: o = 214748364;
12855: p = 7 + n;
12856: radix = 10;
12857: }
12858:
12859: int x = Character.digit (c, radix);
12860: if (x < 0) {
12861: return err;
12862: }
12863: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12864: while (c >= 0) {
12865: int t = x - o;
12866: if (t > 0 || t == 0 && c > p) {
12867: return err;
12868: }
12869: x = x * radix + c;
12870: c = i < l ? Character.digit (s.charAt (i++), radix) : -1;
12871: }
12872: if (n != 0) {
12873: x = -x;
12874: }
12875: return min <= x && x <= max ? x : err;
12876: }
12877:
12878:
12879:
12880:
12881:
12882:
12883:
12884:
12885:
12886:
12887: public static long matMax3 (long x1, long x2, long x3) {
12888: return Math.max (Math.max (x1, x2), x3);
12889: }
12890: public static long matMax4 (long x1, long x2, long x3, long x4) {
12891: return Math.max (Math.max (x1, x2), Math.max (x3, x4));
12892: }
12893: public static long matMax5 (long x1, long x2, long x3, long x4, long x5) {
12894: return Math.max (Math.max (Math.max (x1, x2), Math.max (x3, x4)), x5);
12895: }
12896:
12897:
12898:
12899:
12900:
12901: public static long matMin3 (long x1, long x2, long x3) {
12902: return Math.min (Math.min (x1, x2), x3);
12903: }
12904: public static long matMin4 (long x1, long x2, long x3, long x4) {
12905: return Math.min (Math.min (x1, x2), Math.min (x3, x4));
12906: }
12907: public static long matMin5 (long x1, long x2, long x3, long x4, long x5) {
12908: return Math.min (Math.min (Math.min (x1, x2), Math.min (x3, x4)), x5);
12909: }
12910:
12911:
12912:
12913:
12914:
12915:
12916:
12917:
12918:
12919:
12920:
12921:
12922: public static String strEncodeUTF8 (String s) {
12923: StringBuilder sb = new StringBuilder ();
12924: int l = s.length ();
12925: for (int i = 0; i < l; i++) {
12926: int u = s.charAt (i);
12927: if (0xd800 <= u && u <= 0xdbff && i + 1 < l) {
12928: int v = s.charAt (i + 1);
12929: if (0xdc00 <= v && v <= 0xdfff) {
12930: u = 0x10000 + ((u & 0x3ff) << 10) + (v & 0x3ff);
12931: i++;
12932: }
12933: }
12934: if ((u & 0xffffff80) == 0) {
12935: sb.append ((char) u);
12936: } else if ((u & 0xfffff800) == 0) {
12937: u = (0x0000c080 |
12938: (u & 0x000007c0) << 2 |
12939: (u & 0x0000003f));
12940: sb.append ((char) (u >> 8)).append ((char) (u & 0xff));
12941: } else if ((u & 0xffff0000) == 0 && !(0xd800 <= u && u <= 0xdfff)) {
12942: u = (0x00e08080 |
12943: (u & 0x0000f000) << 4 |
12944: (u & 0x00000fc0) << 2 |
12945: (u & 0x0000003f));
12946: sb.append ((char) (u >> 16)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12947: } else if ((u & 0xffe00000) == 0) {
12948: u = (0xf0808080 |
12949: (u & 0x001c0000) << 6 |
12950: (u & 0x0003f000) << 4 |
12951: (u & 0x00000fc0) << 2 |
12952: (u & 0x0000003f));
12953: sb.append ((char) ((u >> 24) & 0xff)).append ((char) ((u >> 16) & 0xff)).append ((char) ((u >> 8) & 0xff)).append ((char) (u & 0xff));
12954: } else {
12955: sb.append ((char) 0xef).append ((char) 0xbf).append ((char) 0xbd);
12956: }
12957: }
12958: return sb.toString ();
12959: }
12960:
12961:
12962:
12963:
12964:
12965:
12966:
12967: public static String strDecodeUTF8 (String s) {
12968: StringBuilder sb = new StringBuilder ();
12969: int l = s.length ();
12970: for (int i = 0; i < l; i++) {
12971: int c = s.charAt (i) & 0xff;
12972: for (int k = ((c & 0x80) == 0x00 ? 0 :
12973: (c & 0xe0) == 0xc0 ? 1 :
12974: (c & 0xf0) == 0xe0 ? 2 :
12975: (c & 0xf8) == 0xf0 ? 3 :
12976: -1);
12977: --k >= 0; ) {
12978: c = c << 8 | (i + 1 < l ? s.charAt (++i) & 0xff : 0);
12979: }
12980: int u = ((c & 0xffffff80) == 0x00000000 ? c :
12981: (c & 0xffffe0c0) == 0x0000c080 ? ((c & 0x00001f00) >> 2 |
12982: (c & 0x0000003f)) :
12983: (c & 0xfff0c0c0) == 0x00e08080 ? ((c & 0x000f0000) >> 4 |
12984: (c & 0x00003f00) >> 2 |
12985: (c & 0x0000003f)) :
12986: (c & 0xf8c0c0c0) == 0xf0808080 ? ((c & 0x07000000) >> 6 |
12987: (c & 0x003f0000) >> 4 |
12988: (c & 0x00003f00) >> 2 |
12989: (c & 0x0000003f)) :
12990: 0xfffd);
12991: if (u <= 0x0000ffff) {
12992: sb.append (0xd800 <= u && u <= 0xdfff ? '\ufffd' :
12993: (char) u);
12994: } else if (u <= 0x0010ffff) {
12995: u -= 0x000010000;
12996: sb.append ((char) (0xd800 + ((u >> 10) & 0x3ff))).append ((char) (0xdc00 + (u & 0x3ff)));
12997: }
12998: }
12999: return sb.toString ();
13000: }
13001:
13002:
13003:
13004:
13005:
13006: public static final int[] IsURIChar = {
13007:
13008:
13009: 0b00000000_00000000_00000000_00000000,
13010: 0b00000000_00000110_11111111_11000000,
13011: 0b01111111_11111111_11111111_11100001,
13012: 0b01111111_11111111_11111111_11100010,
13013: };
13014: public static String strEncodeURI (String s) {
13015: s = strEncodeUTF8 (s);
13016: StringBuilder sb = new StringBuilder ();
13017: int l = s.length ();
13018: for (int i = 0; i < l; i++) {
13019: int c = s.charAt (i);
13020: if (c < 0x80 && IsURIChar[c >> 5] << c < 0) {
13021: sb.append ((char) c);
13022: } else {
13023: fmtHex2 (sb.append ('%'), c);
13024: }
13025: }
13026: return sb.toString ();
13027: }
13028:
13029:
13030:
13031:
13032:
13033: public static final byte[] strIsHexChar = {
13034:
13035: -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,
13036: -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,
13037: -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,
13038: -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,
13039: };
13040: public static String strDecodeURI (String s) {
13041: StringBuilder sb = new StringBuilder ();
13042: int l = s.length ();
13043: for (int i = 0; i < l; i++) {
13044: int c = s.charAt (i);
13045: if (c == '%' && i + 2 < l) {
13046: int d = s.charAt (i + 1);
13047: int e = s.charAt (i + 2);
13048: if (d < 0x80 && (d = strIsHexChar[d]) >= 0 &&
13049: e < 0x80 && (e = strIsHexChar[e]) >= 0) {
13050: sb.append ((char) (d << 4 | e));
13051: } else {
13052: sb.append ((char) c);
13053: }
13054: } else {
13055: sb.append ((char) c);
13056: }
13057: }
13058: return sb.toString ();
13059: }
13060:
13061:
13062:
13063:
13064:
13065:
13066:
13067:
13068: public static BufferedImage createImage (int width, int height, String pattern, int... rgbs) {
13069: BufferedImage image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB);
13070: int[] bitmap = ((DataBufferInt) image.getRaster ().getDataBuffer ()).getData ();
13071: int length = width * height;
13072: for (int i = 0; i < length; i++) {
13073: char c = pattern.charAt (i);
13074: bitmap[i] = rgbs[c < '0' ? 0 : Character.digit (c, 16)];
13075: }
13076: return image;
13077: }
13078:
13079:
13080:
13081: public static ImageIcon createImageIcon (int width, int height, String pattern, int... rgbs) {
13082: return new ImageIcon (createImage (width, height, pattern, rgbs));
13083: }
13084:
13085:
13086:
13087: public static TexturePaint createTexturePaint (int width, int height, String pattern, int... rgbs) {
13088: return new TexturePaint (createImage (width, height, pattern, rgbs), new Rectangle (0, 0, width, height));
13089: }
13090:
13091:
13092:
13093: public static BufferedImage loadImage (String name) {
13094: BufferedImage image = null;
13095: try {
13096: image = ImageIO.read (new File (name));
13097: } catch (Exception e) {
13098: }
13099: return image;
13100: }
13101:
13102:
13103:
13104:
13105: public static boolean saveImage (BufferedImage image, String name) {
13106: return saveImage (image, name, 0.75F);
13107: }
13108: public static boolean saveImage (BufferedImage image, String name, float quality) {
13109: int index = name.lastIndexOf (".");
13110: if (index < 0) {
13111: return false;
13112: }
13113: if (name.substring (index).equalsIgnoreCase (".ico")) {
13114: return saveIcon (name, image);
13115: }
13116: Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix (name.substring (index + 1));
13117: if (!iterator.hasNext ()) {
13118: return false;
13119: }
13120: ImageWriter imageWriter = iterator.next ();
13121: ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam ();
13122: if (imageWriteParam.canWriteCompressed ()) {
13123: imageWriteParam.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);
13124: imageWriteParam.setCompressionQuality (quality);
13125: }
13126: try {
13127: File file = new File (name);
13128: ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream (file);
13129: imageWriter.setOutput (imageOutputStream);
13130: imageWriter.write (null, new IIOImage (image, null, null), imageWriteParam);
13131: imageOutputStream.close ();
13132: } catch (Exception e) {
13133:
13134: return false;
13135: }
13136: return true;
13137: }
13138:
13139:
13140:
13141:
13142:
13143:
13144:
13145:
13146:
13147:
13148:
13149:
13150:
13151:
13152:
13153:
13154:
13155:
13156:
13157:
13158:
13159:
13160:
13161:
13162:
13163:
13164:
13165:
13166:
13167:
13168:
13169:
13170:
13171:
13172:
13173:
13174:
13175:
13176:
13177:
13178:
13179:
13180:
13181:
13182:
13183:
13184:
13185:
13186:
13187:
13188:
13189:
13190:
13191:
13192:
13193:
13194:
13195:
13196:
13197:
13198:
13199:
13200:
13201:
13202:
13203:
13204:
13205:
13206:
13207:
13208:
13209:
13210:
13211: public static boolean saveIcon (String fileName, BufferedImage... arrayImage) {
13212: int iconCount = arrayImage.length;
13213: int[][] arrayPaletTable = new int[iconCount][];
13214: int[] arrayPaletCount = new int[iconCount];
13215: int[] arrayPixelBits = new int[iconCount];
13216: int[] arrayPatternLineSize = new int[iconCount];
13217: int[] arrayMaskLineSize = new int[iconCount];
13218: int[] arrayImageSize = new int[iconCount];
13219: int[] arrayImageOffset = new int[iconCount];
13220: int fileSize = 6 + 16 * iconCount;
13221: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
13222: BufferedImage image = arrayImage[iconNumber];
13223: int width = image.getWidth ();
13224: int height = image.getHeight ();
13225:
13226: int[] paletTable = new int[256];
13227: int paletCount = 0;
13228: countPalet:
13229: for (int y = height - 1; y >= 0; y--) {
13230: for (int x = 0; x < width; x++) {
13231: int rgb = image.getRGB (x, y);
13232: if (rgb >>> 24 != 0xff) {
13233: continue;
13234: }
13235: int l = 0;
13236: int r = paletCount;
13237: while (l < r) {
13238: int m = l + r >> 1;
13239: if (paletTable[m] < rgb) {
13240: l = m + 1;
13241: } else {
13242: r = m;
13243: }
13244: }
13245: if (l == paletCount || paletTable[l] != rgb) {
13246: if (paletCount == 256) {
13247: paletCount = 0;
13248: break countPalet;
13249: }
13250: for (int i = paletCount; i > l; i--) {
13251: paletTable[i] = paletTable[i - 1];
13252: }
13253: paletTable[l] = rgb;
13254: paletCount++;
13255: }
13256: }
13257: }
13258: int pixelBits = (paletCount == 0 ? 24 :
13259: paletCount > 16 ? 8 :
13260: paletCount > 4 ? 4 :
13261: paletCount > 2 ? 2 :
13262: 1);
13263: int patternLineSize = pixelBits * width + 31 >> 5 << 2;
13264: int maskLineSize = width + 31 >> 5 << 2;
13265: int imageSize = 40 + 4 * paletCount + patternLineSize * height + maskLineSize * height;
13266: arrayPaletTable[iconNumber] = paletTable;
13267: arrayPaletCount[iconNumber] = paletCount;
13268: arrayPixelBits[iconNumber] = pixelBits;
13269: arrayPatternLineSize[iconNumber] = patternLineSize;
13270: arrayMaskLineSize[iconNumber] = maskLineSize;
13271: arrayImageSize[iconNumber] = imageSize;
13272: arrayImageOffset[iconNumber] = fileSize;
13273: fileSize += imageSize;
13274: }
13275: byte[] bb = new byte[fileSize];
13276:
13277: ByteArray.byaWiw (bb, 0, 0);
13278: ByteArray.byaWiw (bb, 2, 1);
13279: ByteArray.byaWiw (bb, 4, iconCount);
13280: for (int iconNumber = 0; iconNumber < iconCount; iconNumber++) {
13281: BufferedImage image = arrayImage[iconNumber];
13282: int width = image.getWidth ();
13283: int height = image.getHeight ();
13284: int[] paletTable = arrayPaletTable[iconNumber];
13285: int paletCount = arrayPaletCount[iconNumber];
13286: int pixelBits = arrayPixelBits[iconNumber];
13287: int patternLineSize = arrayPatternLineSize[iconNumber];
13288: int maskLineSize = arrayMaskLineSize[iconNumber];
13289: int imageSize = arrayImageSize[iconNumber];
13290: int imageOffset = arrayImageOffset[iconNumber];
13291:
13292: int o = 6 + 16 * iconNumber;
13293: ByteArray.byaWb (bb, o, width);
13294: ByteArray.byaWb (bb, o + 1, height);
13295: ByteArray.byaWb (bb, o + 2, paletCount);
13296: ByteArray.byaWb (bb, o + 3, 0);
13297: ByteArray.byaWiw (bb, o + 4, 1);
13298: ByteArray.byaWiw (bb, o + 6, pixelBits);
13299: ByteArray.byaWil (bb, o + 8, imageSize);
13300: ByteArray.byaWil (bb, o + 12, imageOffset);
13301:
13302: o = imageOffset;
13303: ByteArray.byaWil (bb, o, 40);
13304: ByteArray.byaWil (bb, o + 4, width);
13305: ByteArray.byaWil (bb, o + 8, height * 2);
13306: ByteArray.byaWiw (bb, o + 12, 1);
13307: ByteArray.byaWiw (bb, o + 14, pixelBits);
13308: ByteArray.byaWil (bb, o + 16, 0);
13309: ByteArray.byaWil (bb, o + 20, 0);
13310: ByteArray.byaWil (bb, o + 24, 0);
13311: ByteArray.byaWil (bb, o + 28, 0);
13312: ByteArray.byaWil (bb, o + 32, paletCount);
13313: ByteArray.byaWil (bb, o + 36, 0);
13314:
13315: o += 40;
13316: for (int i = 0; i < paletCount; i++) {
13317: ByteArray.byaWil (bb, o, paletTable[i] & 0x00ffffff);
13318: o += 4;
13319: }
13320:
13321: for (int y = height - 1; y >= 0; y--) {
13322: for (int x = 0; x < width; x++) {
13323: int rgb = image.getRGB (x, y);
13324: if (rgb >>> 24 != 0xff) {
13325: continue;
13326: }
13327: if (pixelBits == 24) {
13328: bb[o + 3 * x] = (byte) rgb;
13329: bb[o + 3 * x + 1] = (byte) (rgb >> 8);
13330: bb[o + 3 * x + 2] = (byte) (rgb >> 16);
13331: continue;
13332: }
13333: int l = 0;
13334: int r = paletCount;
13335: while (l < r) {
13336: int m = l + r >> 1;
13337: if (paletTable[m] < rgb) {
13338: l = m + 1;
13339: } else {
13340: r = m;
13341: }
13342: }
13343: if (l != 0) {
13344: if (pixelBits == 8) {
13345: bb[o + x] = (byte) l;
13346: } else if (pixelBits == 4) {
13347: bb[o + (x >> 1)] |= (byte) (l << ((~x & 1) << 2));
13348: } else if (pixelBits == 2) {
13349: bb[o + (x >> 2)] |= (byte) (l << ((~x & 3) << 1));
13350: } else {
13351: bb[o + (x >> 3)] |= (byte) (l << (~x & 7));
13352: }
13353: }
13354: }
13355: o += patternLineSize;
13356: }
13357:
13358: for (int y = height - 1; y >= 0; y--) {
13359: for (int x = 0; x < width; x++) {
13360: int rgb = image.getRGB (x, y);
13361: if (rgb >>> 24 != 0xff) {
13362: bb[o + (x >> 3)] |= (byte) (1 << (~x & 7));
13363: }
13364: }
13365: o += maskLineSize;
13366: }
13367: }
13368: return rscPutFile (fileName, bb, 0, fileSize);
13369: }
13370:
13371:
13372:
13373: }
13374:
13375:
13376: