PhysicalSpaceMonitor.java
     1: //========================================================================================
     2: //  PhysicalSpaceMonitor.java
     3: //    en:Physical space monitor
     4: //    ja:物理空間モニタ
     5: //  Copyright (C) 2003-2024 Makoto Kamada
     6: //
     7: //  This file is part of the XEiJ (X68000 Emulator in Java).
     8: //  You can use, modify and redistribute the XEiJ if the conditions are met.
     9: //  Read the XEiJ License for more details.
    10: //  https://stdkmd.net/xeij/
    11: //========================================================================================
    12: 
    13: package xeij;
    14: 
    15: import java.awt.*;  //BasicStroke,BorderLayout,BoxLayout,Color,Component,Container,Cursor,Desktop,Dimension,Font,FlowLayout,Frame,Graphics,Graphics2D,GraphicsDevice,GraphicsEnvironment,GridLayout,Image,Insets,Paint,Point,Rectangle,RenderingHints,Robot,Shape,Stroke,TexturePaint,Toolkit
    16: import java.awt.event.*;  //ActionEvent,ActionListener,ComponentAdapter,ComponentEvent,ComponentListener,FocusAdapter,FocusEvent,FocusListener,InputEvent,KeyAdapter,KeyEvent,KeyListener,MouseAdapter,MouseEvent,MouseListener,MouseMotionAdapter,MouseWheelEvent,WindowAdapter,WindowEvent,WindowListener,WindowStateListener
    17: import java.lang.*;  //Boolean,Character,Class,Comparable,Double,Exception,Float,IllegalArgumentException,Integer,Long,Math,Number,Object,Runnable,SecurityException,String,StringBuilder,System
    18: import javax.swing.*;  //AbstractButton,AbstractSpinnerModel,Box,ButtonGroup,DefaultListModel,ImageIcon,JApplet,JButton,JCheckBox,JCheckBoxMenuItem,JComponent,JDialog,JFileChooser,JFrame,JLabel,JList,JMenu,JMenuBar,JMenuItem,JPanel,JRadioButton,JScrollPane,JSpinner,JTextArea,JTextField,JTextPane,JViewport,ScrollPaneConstants,SpinnerListModel,SpinnerNumberModel,SwingConstants,SwingUtilities,UIManager,UIDefaults,UnsupportedLookAndFeelException
    19: 
    20: public class PhysicalSpaceMonitor {
    21: 
    22:   public static JFrame paaFrame;  //ウインドウ
    23:   public static ScrollTextArea paaBoard;  //スクロールテキストエリア
    24:   public static JTextArea paaTextArea;  //テキストエリア
    25: 
    26:   //paaInit ()
    27:   //  初期化
    28:   public static void paaInit () {
    29:     paaFrame = null;
    30:   }  //paaInit()
    31: 
    32:   //paaStart ()
    33:   public static void paaStart () {
    34:     if (RestorableFrame.rfmGetOpened (Settings.SGS_PAA_FRAME_KEY)) {
    35:       paaOpen ();
    36:     }
    37:   }  //paaStart()
    38: 
    39:   //paaOpen ()
    40:   //  物理アドレス空間ウインドウを開く
    41:   //  既に開いているときは手前に持ってくる
    42:   public static void paaOpen () {
    43:     if (paaFrame == null) {
    44:       paaMake ();
    45:     }
    46:     paaUpdate ();
    47:     XEiJ.pnlExitFullScreen (false);
    48:     paaFrame.setVisible (true);
    49:     XEiJ.dbgVisibleMask |= XEiJ.DBG_PAA_VISIBLE_MASK;
    50:   }  //paaOpen()
    51: 
    52:   //paaMake ()
    53:   //  アドレス変換ウインドウを作る
    54:   public static void paaMake () {
    55: 
    56:     //スクロールテキストエリア
    57:     paaBoard = ComponentFactory.setPreferredSize (
    58:       ComponentFactory.setFont (new ScrollTextArea (), LnF.lnfMonospacedFont),
    59:       550, 300);
    60:     paaBoard.setMargin (new Insets (2, 4, 2, 4));
    61:     paaBoard.setHighlightCursorOn (true);
    62:     paaTextArea = paaBoard.getTextArea ();
    63:     paaTextArea.setEditable (false);
    64: 
    65:     //テキストエリアのマウスリスナー
    66:     ComponentFactory.addListener (
    67:       paaTextArea,
    68:       new MouseAdapter () {
    69:         @Override public void mousePressed (MouseEvent me) {
    70:           if (XEiJ.mpuTask == null && me.isPopupTrigger ()) {
    71:             XEiJ.dbgShowPopup (me, paaTextArea, false);
    72:           }
    73:         }
    74:         @Override public void mouseReleased (MouseEvent me) {
    75:           if (XEiJ.mpuTask == null && me.isPopupTrigger ()) {
    76:             XEiJ.dbgShowPopup (me, paaTextArea, false);
    77:           }
    78:         }
    79:       });
    80: 
    81:     //ボタンのアクションリスナー
    82:     ActionListener listener = new ActionListener () {
    83:       @Override public void actionPerformed (ActionEvent ae) {
    84:         Object source = ae.getSource ();
    85:         switch (ae.getActionCommand ()) {
    86:         case "Update":
    87:           paaUpdate ();
    88:           break;
    89:         }
    90:       }
    91:     };
    92: 
    93:     //ウインドウ
    94:     paaFrame = Multilingual.mlnTitle (
    95:       ComponentFactory.createRestorableSubFrame (
    96:         Settings.SGS_PAA_FRAME_KEY,
    97:         "Physical space monitor",
    98:         null,
    99:         ComponentFactory.createBorderPanel (
   100:           paaBoard,
   101:           ComponentFactory.createHorizontalBox (
   102:             Multilingual.mlnToolTipText (
   103:               ComponentFactory.createImageButton (
   104:                 XEiJ.createImage (
   105:                   20, 14,
   106:                   "11111111111111111111" +
   107:                   "1..................1" +
   108:                   "1.......1111.......1" +
   109:                   "1......111111.1....1" +
   110:                   "1.....11....111....1" +
   111:                   "1....11.....111....1" +
   112:                   "1....11....1111....1" +
   113:                   "1....11............1" +
   114:                   "1....11............1" +
   115:                   "1.....11....11.....1" +
   116:                   "1......111111......1" +
   117:                   "1.......1111.......1" +
   118:                   "1..................1" +
   119:                   "11111111111111111111",
   120:                   LnF.lnfRGB[0],
   121:                   LnF.lnfRGB[12]),
   122:                 "Update", listener),
   123:               "ja", "更新"),
   124:             Box.createHorizontalGlue ()
   125:             )
   126:           )
   127:         ),
   128:       "ja", "物理空間モニタ");
   129:     ComponentFactory.addListener (
   130:       paaFrame,
   131:       new WindowAdapter () {
   132:         @Override public void windowClosing (WindowEvent we) {
   133:           XEiJ.dbgVisibleMask &= ~XEiJ.DBG_PAA_VISIBLE_MASK;
   134:         }
   135:       });
   136: 
   137:   }  //paaMake()
   138: 
   139:   //paaUpdate ()
   140:   //  物理アドレス空間ウインドウを更新する
   141:   public static void paaUpdate () {
   142:     StringBuilder sb = new StringBuilder ();
   143:     sb.append (Multilingual.mlnJapanese ?
   144:                //xxxxxxx-xxxxxxxx  xxxxxxxxxxxxxxxxxxxxxxxxxx
   145:                "  物理アドレス       メモリマップトデバイス\n" :
   146:                "Physical address      Memory mapped device\n");
   147:     int a0 = 0;
   148:     MemoryMappedDevice mmd0Super = MemoryMappedDevice.MMD_NUL;
   149:     MemoryMappedDevice mmd0User = MemoryMappedDevice.MMD_NUL;
   150:     int page = 0;
   151:     for (; page < XEiJ.BUS_PAGE_COUNT; page++) {
   152:       MemoryMappedDevice mmd1Super = XEiJ.busSuperMap[page];
   153:       MemoryMappedDevice mmd1User = XEiJ.busUserMap[page];
   154:       if (mmd0Super != mmd1Super || mmd0User != mmd1User) {
   155:         int a1 = page << XEiJ.BUS_PAGE_BITS;
   156:         if (mmd0Super != MemoryMappedDevice.MMD_NUL) {
   157:           XEiJ.fmtHex8 (XEiJ.fmtHex8 (sb, a0).append ('-'), a1 - 1).append ("  ").append (mmd0Super.toString ());
   158:           if (mmd0User == MemoryMappedDevice.MMD_NUL) {
   159:             sb.append (Multilingual.mlnJapanese ? " [スーパーバイザ]" : " [Supervisor]");
   160:           }
   161:           sb.append ('\n');
   162:         }
   163:         a0 = a1;
   164:         mmd0Super = mmd1Super;
   165:         mmd0User = mmd1User;
   166:       }
   167:     }
   168:     if (mmd0Super != MemoryMappedDevice.MMD_NUL) {
   169:       XEiJ.fmtHex8 (XEiJ.fmtHex8 (sb, a0).append ('-'), 0 - 1).append ("  ").append (mmd0Super.toString ());
   170:       if (mmd0User == MemoryMappedDevice.MMD_NUL) {
   171:         sb.append (Multilingual.mlnJapanese ? " [スーパーバイザ]" : " [Supervisor]");
   172:       }
   173:       sb.append ('\n');
   174:     }
   175:     paaTextArea.setText (sb.toString ());
   176:     paaTextArea.setCaretPosition (0);
   177:   }  //paaUpdate()
   178: 
   179: }  //class PhysicalSpaceMonitor
   180: 
   181: 
   182: