Coverage Report - uk.co.javagear.Debug
 
Classes in this File Line Coverage Branch Coverage Complexity
Debug
0% 
N/A 
1
 
 1  
 /*
 2  
  * Debug.java
 3  
  *
 4  
  * This file is part of JavaGear.
 5  
  *
 6  
  * JavaGear is free software; you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation; either version 2 of the License, or
 9  
  * (at your option) any later version.
 10  
  *
 11  
  * JavaGear is distributed in the hope that it will be useful,
 12  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14  
  * GNU General Public License for more details.
 15  
  *
 16  
  * You should have received a copy of the GNU General Public License
 17  
  * along with JavaGear; if not, write to the Free Software
 18  
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 19  
  */
 20  
 
 21  
 package uk.co.javagear;
 22  
 
 23  
 import java.awt.Container;
 24  
 import java.awt.Image;
 25  
 import java.awt.Toolkit;
 26  
 import java.awt.event.ActionEvent;
 27  
 import java.net.URL;
 28  
 import javax.swing.AbstractAction;
 29  
 import javax.swing.Action;
 30  
 import javax.swing.ImageIcon;
 31  
 import javax.swing.JFrame;
 32  
 import javax.swing.JPanel;
 33  
 import javax.swing.JScrollPane;
 34  
 import javax.swing.JSplitPane;
 35  
 import javax.swing.JTable;
 36  
 import javax.swing.JToolBar;
 37  
 
 38  
 /**
 39  
  * JavaGear debug frame.
 40  
  *
 41  
  * @author Copyright (C) 2002 Chris White
 42  
  * @version 16th March 2002
 43  
  * @see "JavaGear Final Project Report"
 44  
  */
 45  
 public final class Debug extends JFrame {
 46  
     
 47  
     /**
 48  
      * Pointer to CPU.
 49  
      */
 50  
     private Z80 cpu;
 51  
     
 52  
     /**
 53  
      * Pointer to VDP.
 54  
      */
 55  
     private Vdp vdp;
 56  
     
 57  
     /**
 58  
      * Pointer to Java ScreenPanel.
 59  
      */
 60  
     private Screen screenpanel;
 61  
     
 62  
     /**
 63  
      * Debug Frame Constructor.
 64  
      *
 65  
      * @param z Z80.
 66  
      * @param v Vdp.
 67  
      * @param s ScreenPanel.
 68  
      */
 69  0
     public Debug(Z80 z, Vdp v, Screen s) {
 70  0
         this.cpu = z;
 71  0
         this.vdp = v;
 72  0
         this.screenpanel = s;
 73  
         
 74  
         // Create 3 Main Tables
 75  0
         JTable regTable = new JTable(regValues, regNames);
 76  0
         JTable flagTable = new JTable(flagValues, flagNames);
 77  0
         JTable debugTable = new JTable(debugValues, debugNames);
 78  
         
 79  
         // create 3 Split Panes
 80  0
         JSplitPane regPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT
 81  
                 , new JScrollPane(regTable)
 82  
                 , new JScrollPane(flagTable));
 83  0
         JSplitPane debugPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT
 84  
                 , new JScrollPane(debugTable)
 85  
                 , regPane);
 86  0
         regPane.setResizeWeight(0.5);
 87  0
         debugPane.setResizeWeight(0.75);
 88  
         
 89  0
         final DebugInst debugins = new DebugInst(z, v, s, regTable, flagTable, debugTable);
 90  
         
 91  0
         Container contentPane = getContentPane();
 92  
         
 93  
         // add panel for debug buttons
 94  0
         JPanel panel = new JPanel();
 95  0
         contentPane.add(panel, "South");
 96  
         
 97  
         // Setup Toolbar buttons
 98  0
         Action inst1 = new AbstractAction("Execute 1 Instruction"
 99  0
                 , new ImageIcon(getImage("/images/debug1.gif"))) {
 100  
             public void actionPerformed(ActionEvent event) {
 101  0
                 debugins.execute(1);
 102  0
             }
 103  
         };
 104  0
         Action inst10 = new AbstractAction("Execute 10 Instructions"
 105  0
                 , new ImageIcon(getImage("/images/debug10.gif"))) {
 106  
             public void actionPerformed(ActionEvent event) {
 107  0
                 debugins.execute(10);
 108  0
             }
 109  
         };
 110  0
         Action inst100 = new AbstractAction("Execute 100 Instructions"
 111  0
                 , new ImageIcon(getImage("/images/debug100.gif"))) {
 112  
             public void actionPerformed(ActionEvent event) {
 113  0
                 debugins.execute(100);
 114  0
             }
 115  
         };
 116  0
         Action inst1000 = new AbstractAction("Execute 1000 Instructions"
 117  0
                 , new ImageIcon(getImage("/images/debug1000.gif"))) {
 118  
             public void actionPerformed(ActionEvent event) {
 119  0
                 debugins.execute(1000);
 120  0
             }
 121  
         };
 122  0
         Action inst10000 = new AbstractAction("Execute 10,000 Instructions"
 123  0
                 , new ImageIcon(getImage("/images/debug10k.gif"))) {
 124  
             public void actionPerformed(ActionEvent event) {
 125  0
                 debugins.execute(10000);
 126  0
             }
 127  
         };
 128  0
         Action inst100000 = new AbstractAction("Execute 100,000 Instructions"
 129  0
                 , new ImageIcon(getImage("/images/debug100k.gif"))) {
 130  
             public void actionPerformed(ActionEvent event) {
 131  0
                 debugins.execute(100000);
 132  0
             }
 133  
         };
 134  
         
 135  
         // Create Tool Bar
 136  0
         JToolBar bar = new JToolBar();
 137  0
         bar.add(inst1);
 138  0
         bar.add(inst10);
 139  0
         bar.add(inst100);
 140  0
         bar.add(inst1000);
 141  0
         bar.add(inst10000);
 142  0
         bar.add(inst100000);
 143  0
         contentPane.add(bar, "South");
 144  
         
 145  
         // add main pane and show it all
 146  0
         contentPane.add(debugPane, "Center");
 147  
         
 148  0
         setTitle("Z80 Debugger");
 149  0
         setSize(500, 375);
 150  0
         setResizable(false);
 151  0
     }
 152  
     
 153  
     
 154  
     /**
 155  
      * Get image within a JAR file.
 156  
      *
 157  
      * @param filename filename to read.
 158  
      * @return the image.
 159  
      */
 160  
     private Image getImage(String filename) {
 161  0
         URL imageURL = KeyFrame.class.getResource(filename);
 162  0
         return Toolkit.getDefaultToolkit().getImage(imageURL);
 163  
     }
 164  
     
 165  
     /**
 166  
      * Arrays holding table contents.
 167  
      */
 168  0
     private String[] debugNames = {"PC", "OPCODE", "MNEMONIC"};
 169  
     
 170  0
     private Object[][] debugValues = {
 171  
         {" ", " ", " "},
 172  
         {" ", " ", " "},
 173  
         {" ", " ", " "},
 174  
         {" ", " ", " "},
 175  
         {" ", " ", " "},
 176  
         {" ", " ", " "},
 177  
         {" ", " ", " "},
 178  
         {" ", " ", " "},
 179  
         {" ", " ", " "},
 180  
         {" ", " ", " "}
 181  
     };
 182  
     
 183  
     
 184  0
     private String[] regNames = {"A", "F", "B", "C", "D", "E", "H", "L", "IX", "IY", "R", "SP"};
 185  
     
 186  0
     private Object[][] regValues = {
 187  
         {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "},
 188  
         {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "}
 189  
     };
 190  
     
 191  
     
 192  0
     private String[] flagNames = {"SIGN", "ZERO", "BIT 5", "HC", "BIT 3", "PV", "NEG", "CARRY"};
 193  
     
 194  0
     private Object[][] flagValues = {
 195  
         {" ", " ", " ", " ", " ", " ", " ", " "},
 196  
         {" ", " ", " ", " ", " ", " ", " ", " "}
 197  
     };
 198  
     
 199  
 }