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:     paaFrame.setVisible (true);
    48:     XEiJ.dbgVisibleMask |= XEiJ.DBG_PAA_VISIBLE_MASK;
    49:   }  //paaOpen()
    50: 
    51:   //paaMake ()
    52:   //  アドレス変換ウインドウを作る
    53:   public static void paaMake () {
    54: 
    55:     //スクロールテキストエリア
    56:     paaBoard = ComponentFactory.setPreferredSize (
    57:       ComponentFactory.setFont (new ScrollTextArea (), LnF.lnfMonospacedFont),
    58:       550, 300);
    59:     paaBoard.setMargin (new Insets (2, 4, 2, 4));
    60:     paaBoard.setHighlightCursorOn (true);
    61:     paaTextArea = paaBoard.getTextArea ();
    62:     paaTextArea.setEditable (false);
    63: 
    64:     //テキストエリアのマウスリスナー
    65:     ComponentFactory.addListener (
    66:       paaTextArea,
    67:       new MouseAdapter () {
    68:         @Override public void mousePressed (MouseEvent me) {
    69:           if (XEiJ.mpuTask == null && me.isPopupTrigger ()) {
    70:             XEiJ.dbgShowPopup (me, paaTextArea, false);
    71:           }
    72:         }
    73:         @Override public void mouseReleased (MouseEvent me) {
    74:           if (XEiJ.mpuTask == null && me.isPopupTrigger ()) {
    75:             XEiJ.dbgShowPopup (me, paaTextArea, false);
    76:           }
    77:         }
    78:       });
    79: 
    80:     //ボタンのアクションリスナー
    81:     ActionListener listener = new ActionListener () {
    82:       @Override public void actionPerformed (ActionEvent ae) {
    83:         Object source = ae.getSource ();
    84:         switch (ae.getActionCommand ()) {
    85:         case "Update":
    86:           paaUpdate ();
    87:           break;
    88:         }
    89:       }
    90:     };
    91: 
    92:     //ウインドウ
    93:     paaFrame = Multilingual.mlnTitle (
    94:       ComponentFactory.createRestorableSubFrame (
    95:         Settings.SGS_PAA_FRAME_KEY,
    96:         "Physical space monitor",
    97:         null,
    98:         ComponentFactory.createBorderPanel (
    99:           paaBoard,
   100:           ComponentFactory.createHorizontalBox (
   101:             Multilingual.mlnToolTipText (
   102:               ComponentFactory.createImageButton (
   103:                 XEiJ.createImage (
   104:                   20, 14,
   105:                   "11111111111111111111" +
   106:                   "1..................1" +
   107:                   "1.......1111.......1" +
   108:                   "1......111111.1....1" +
   109:                   "1.....11....111....1" +
   110:                   "1....11.....111....1" +
   111:                   "1....11....1111....1" +
   112:                   "1....11............1" +
   113:                   "1....11............1" +
   114:                   "1.....11....11.....1" +
   115:                   "1......111111......1" +
   116:                   "1.......1111.......1" +
   117:                   "1..................1" +
   118:                   "11111111111111111111",
   119:                   LnF.lnfRGB[0],
   120:                   LnF.lnfRGB[12]),
   121:                 "Update", listener),
   122:               "ja", "更新"),
   123:             Box.createHorizontalGlue ()
   124:             )
   125:           )
   126:         ),
   127:       "ja", "物理空間モニタ");
   128:     ComponentFactory.addListener (
   129:       paaFrame,
   130:       new WindowAdapter () {
   131:         @Override public void windowClosing (WindowEvent we) {
   132:           XEiJ.dbgVisibleMask &= ~XEiJ.DBG_PAA_VISIBLE_MASK;
   133:         }
   134:       });
   135: 
   136:   }  //paaMake()
   137: 
   138:   //paaUpdate ()
   139:   //  物理アドレス空間ウインドウを更新する
   140:   public static void paaUpdate () {
   141:     StringBuilder sb = new StringBuilder ();
   142:     sb.append (Multilingual.mlnJapanese ?
   143:                //xxxxxxx-xxxxxxxx  xxxxxxxxxxxxxxxxxxxxxxxxxx
   144:                "  物理アドレス       メモリマップトデバイス\n" :
   145:                "Physical address      Memory mapped device\n");
   146:     int a0 = 0;
   147:     MemoryMappedDevice mmd0Super = MemoryMappedDevice.MMD_NUL;
   148:     MemoryMappedDevice mmd0User = MemoryMappedDevice.MMD_NUL;
   149:     int page = 0;
   150:     for (; page < XEiJ.BUS_PAGE_COUNT; page++) {
   151:       MemoryMappedDevice mmd1Super = XEiJ.busSuperMap[page];
   152:       MemoryMappedDevice mmd1User = XEiJ.busUserMap[page];
   153:       if (mmd0Super != mmd1Super || mmd0User != mmd1User) {
   154:         int a1 = page << XEiJ.BUS_PAGE_BITS;
   155:         if (mmd0Super != MemoryMappedDevice.MMD_NUL) {
   156:           XEiJ.fmtHex8 (XEiJ.fmtHex8 (sb, a0).append ('-'), a1 - 1).append ("  ").append (mmd0Super.toString ());
   157:           if (mmd0User == MemoryMappedDevice.MMD_NUL) {
   158:             sb.append (Multilingual.mlnJapanese ? " [スーパーバイザ]" : " [Supervisor]");
   159:           }
   160:           sb.append ('\n');
   161:         }
   162:         a0 = a1;
   163:         mmd0Super = mmd1Super;
   164:         mmd0User = mmd1User;
   165:       }
   166:     }
   167:     if (mmd0Super != MemoryMappedDevice.MMD_NUL) {
   168:       XEiJ.fmtHex8 (XEiJ.fmtHex8 (sb, a0).append ('-'), 0 - 1).append ("  ").append (mmd0Super.toString ());
   169:       if (mmd0User == MemoryMappedDevice.MMD_NUL) {
   170:         sb.append (Multilingual.mlnJapanese ? " [スーパーバイザ]" : " [Supervisor]");
   171:       }
   172:       sb.append ('\n');
   173:     }
   174:     paaTextArea.setText (sb.toString ());
   175:     paaTextArea.setCaretPosition (0);
   176:   }  //paaUpdate()
   177: 
   178: }  //class PhysicalSpaceMonitor
   179: 
   180: 
   181: