Search in sources :

Example 26 with MemoryDasm

use of sw_emulator.software.MemoryDasm in project jc64 by ice00.

the class ConstantCellEditor method stopCellEditing.

@Override
public boolean stopCellEditing() {
    String actual = textField.getText();
    if (constant == null)
        return super.stopCellEditing();
    if (actual == null || "".equals(actual))
        return super.stopCellEditing();
    String tmp = actual.toUpperCase();
    for (String val : M6510Dasm.mnemonics) {
        if (tmp.equals(val)) {
            textField.setBorder(red);
            return false;
        }
    }
    if (!constant.isAllowed(actual) || !constant.isCorrect(actual)) {
        textField.setBorder(red);
        return false;
    }
    for (MemoryDasm memory : memories) {
        if (actual.equals(memory.dasmLocation) || actual.equals(memory.userLocation)) {
            textField.setBorder(red);
            return false;
        }
    }
    return super.stopCellEditing();
}
Also used : MemoryDasm(sw_emulator.software.MemoryDasm)

Example 27 with MemoryDasm

use of sw_emulator.software.MemoryDasm in project jc64 by ice00.

the class JWizardDialog method initComponents.

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    jPanelUp = new javax.swing.JPanel();
    jLabelWizard = new javax.swing.JLabel();
    jPanelCn = new javax.swing.JPanel();
    jSplitPaneMain = new javax.swing.JSplitPane();
    jPanelMem = new javax.swing.JPanel();
    jPanelFrom = new javax.swing.JPanel();
    jPanelLo = new javax.swing.JPanel();
    jLabelLow = new javax.swing.JLabel();
    jScrollPaneLow = new javax.swing.JScrollPane();
    jTableLow = new javax.swing.JTable() {

        String[] hh = { "Memory address location in Hex", "Disassembler automatic comment", "User manual comment", "Disassembler automatic label", "User manual label", "User global comment", "Related location and data type", "Value in memory" };

        @Override
        protected JTableHeader createDefaultTableHeader() {
            return new JTableHeader(columnModel) {

                @Override
                public String getToolTipText(MouseEvent e) {
                    int col = columnAtPoint(e.getPoint());
                    int index = columnModel.getColumnIndexAtX(e.getPoint().x);
                    int realIndex = columnModel.getColumn(index).getModelIndex();
                    return hh[realIndex];
                }
            };
        }

        // Implement table cell tool tips.
        public String getToolTipText(MouseEvent e) {
            String tip = null;
            java.awt.Point p = e.getPoint();
            int rowIndex = rowAtPoint(p);
            int colIndex = columnAtPoint(p);
            int realColumnIndex = convertColumnIndexToModel(colIndex);
            try {
                MemoryDasm memory = dataTableModelMemoryLow.getData()[rowIndex];
                switch(dataTableModelMemoryLow.columns[realColumnIndex]) {
                    case ID:
                        if (!memory.isInside)
                            tip = "Memory outside of the program";
                        else if (memory.isCode)
                            tip = "Memory marked as code";
                        else if (memory.isData)
                            tip = "Memory marked as data";
                        else
                            tip = "Memory not marked as code or data";
                        break;
                    case DC:
                        if ((Boolean) getValueAt(rowIndex, colIndex))
                            tip = memory.dasmComment;
                        break;
                    case UC:
                        if ((Boolean) getValueAt(rowIndex, colIndex))
                            tip = memory.userComment;
                        break;
                    case DL:
                        if ((Boolean) getValueAt(rowIndex, colIndex))
                            tip = memory.dasmLocation;
                        break;
                    case UL:
                        if ((Boolean) getValueAt(rowIndex, colIndex))
                            tip = memory.userLocation;
                        break;
                    case UB:
                        if ((Boolean) getValueAt(rowIndex, colIndex))
                            tip = "<html>" + memory.userBlockComment.replace("\n", "<br>") + "</html>";
                        break;
                    case RE:
                        if (memory.type != ' ') {
                            MemoryDasm mem = dataTableModelMemoryLow.getData()[memory.related];
                            switch(memory.type) {
                                case '+':
                                    if (mem.userLocation != null && !"".equals(mem.userLocation))
                                        tip = mem.userLocation + "+" + (memory.address - memory.related);
                                    else if (mem.dasmLocation != null && !"".equals(mem.dasmLocation))
                                        tip = mem.dasmLocation + "+" + (memory.address - memory.related);
                                    else
                                        tip = "$" + Shared.ShortToExe(mem.address) + "+" + (memory.address - memory.related);
                                    break;
                                case '-':
                                    if (mem.userLocation != null && !"".equals(mem.userLocation))
                                        tip = mem.userLocation + (memory.address - memory.related);
                                    else if (mem.dasmLocation != null && !"".equals(mem.dasmLocation))
                                        tip = mem.dasmLocation + (memory.address - memory.related);
                                    else
                                        tip = "$" + Shared.ShortToExe(mem.address) + (memory.address - memory.related);
                                    break;
                                default:
                                    if (mem.userLocation != null && !"".equals(mem.userLocation))
                                        tip = "#" + memory.type + mem.userLocation;
                                    else if (mem.dasmLocation != null && !"".equals(mem.dasmLocation))
                                        tip = "#" + memory.type + mem.dasmLocation;
                                    else
                                        tip = "#" + memory.type + "$" + Shared.ShortToExe(mem.address);
                            }
                        } else if (memory.dataType != null) {
                            tip = memory.dataType.getDescription();
                        }
                        break;
                }
            } catch (RuntimeException e1) {
            // catch null pointer exception if mouse is over an empty line
            }
            return tip;
        }
    };
    jPanelSearchLow = new javax.swing.JPanel();
    jLabelSeachLow = new javax.swing.JLabel();
    jPanelTo = new javax.swing.JPanel();
    jPanelHigh = new javax.swing.JPanel();
    jLabelHigh = new javax.swing.JLabel();
    jScrollPaneHigh = new javax.swing.JScrollPane();
    jTableHigh = new javax.swing.JTable() {

        String[] hh = { "Memory address location in Hex", "Disassembler automatic comment", "User manual comment", "Disassembler automatic label", "User manual label", "User global comment", "Related location and data type", "Value in memory" };

        @Override
        protected JTableHeader createDefaultTableHeader() {
            return new JTableHeader(columnModel) {

                @Override
                public String getToolTipText(MouseEvent e) {
                    int col = columnAtPoint(e.getPoint());
                    int index = columnModel.getColumnIndexAtX(e.getPoint().x);
                    int realIndex = columnModel.getColumn(index).getModelIndex();
                    return hh[realIndex];
                }
            };
        }

        // Implement table cell tool tips.
        public String getToolTipText(MouseEvent e) {
            String tip = null;
            java.awt.Point p = e.getPoint();
            int rowIndex = rowAtPoint(p);
            int colIndex = columnAtPoint(p);
            int realColumnIndex = convertColumnIndexToModel(colIndex);
            try {
                MemoryDasm memory = dataTableModelMemoryHigh.getData()[rowIndex];
                switch(dataTableModelMemoryHigh.columns[realColumnIndex]) {
                    case ID:
                        if (!memory.isInside)
                            tip = "Memory outside of the program";
                        else if (memory.isCode)
                            tip = "Memory marked as code";
                        else if (memory.isData)
                            tip = "Memory marked as data";
                        else
                            tip = "Memory not marked as code or data";
                        break;
                    case DC:
                        if ((Boolean) getValueAt(rowIndex, colIndex))
                            tip = memory.dasmComment;
                        break;
                    case UC:
                        if ((Boolean) getValueAt(rowIndex, colIndex))
                            tip = memory.userComment;
                        break;
                    case DL:
                        if ((Boolean) getValueAt(rowIndex, colIndex))
                            tip = memory.dasmLocation;
                        break;
                    case UL:
                        if ((Boolean) getValueAt(rowIndex, colIndex))
                            tip = memory.userLocation;
                        break;
                    case UB:
                        if ((Boolean) getValueAt(rowIndex, colIndex))
                            tip = "<html>" + memory.userBlockComment.replace("\n", "<br>") + "</html>";
                        break;
                    case RE:
                        if (memory.type != ' ') {
                            MemoryDasm mem = dataTableModelMemoryHigh.getData()[memory.related];
                            switch(memory.type) {
                                case '+':
                                    if (mem.userLocation != null && !"".equals(mem.userLocation))
                                        tip = mem.userLocation + "+" + (memory.address - memory.related);
                                    else if (mem.dasmLocation != null && !"".equals(mem.dasmLocation))
                                        tip = mem.dasmLocation + "+" + (memory.address - memory.related);
                                    else
                                        tip = "$" + Shared.ShortToExe(mem.address) + "+" + (memory.address - memory.related);
                                    break;
                                case '-':
                                    if (mem.userLocation != null && !"".equals(mem.userLocation))
                                        tip = mem.userLocation + (memory.address - memory.related);
                                    else if (mem.dasmLocation != null && !"".equals(mem.dasmLocation))
                                        tip = mem.dasmLocation + (memory.address - memory.related);
                                    else
                                        tip = "$" + Shared.ShortToExe(mem.address) + (memory.address - memory.related);
                                    break;
                                default:
                                    if (mem.userLocation != null && !"".equals(mem.userLocation))
                                        tip = "#" + memory.type + mem.userLocation;
                                    else if (mem.dasmLocation != null && !"".equals(mem.dasmLocation))
                                        tip = "#" + memory.type + mem.dasmLocation;
                                    else
                                        tip = "#" + memory.type + "$" + Shared.ShortToExe(mem.address);
                            }
                        } else if (memory.dataType != null) {
                            tip = memory.dataType.getDescription();
                        }
                        break;
                }
            } catch (RuntimeException e1) {
            // catch null pointer exception if mouse is over an empty line
            }
            return tip;
        }
    };
    jPanelSearchHigh = new javax.swing.JPanel();
    jLabelSearchHigh = new javax.swing.JLabel();
    jPanelTable = new javax.swing.JPanel();
    jPanelText = new javax.swing.JPanel();
    jLabelText = new javax.swing.JLabel();
    jPanelCmd = new javax.swing.JPanel();
    jLabelSize = new javax.swing.JLabel();
    jSpinnerSize = new javax.swing.JSpinner();
    jButtonApply = new javax.swing.JButton();
    jLabelPrefix = new javax.swing.JLabel();
    jTextFieldPrefix = new javax.swing.JTextField();
    jLabelDigit = new javax.swing.JLabel();
    jSpinnerDigit = new javax.swing.JSpinner();
    jCheckBoxUpper = new javax.swing.JCheckBox();
    jLabelStart = new javax.swing.JLabel();
    jSpinnerStart = new javax.swing.JSpinner();
    jScrollPaneTable = new javax.swing.JScrollPane();
    jTable = new javax.swing.JTable();
    wizardTableCellRenderer = new WizardTableCellRenderer(jSpinnerSize);
    jTable.setDefaultRenderer(String.class, wizardTableCellRenderer);
    jPanelDn = new javax.swing.JPanel();
    jButtonReset = new javax.swing.JButton();
    jButtonClose = new javax.swing.JButton();
    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    jPanelUp.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jLabelWizard.setText("Wizard for automatic < and > addresses creation");
    jPanelUp.add(jLabelWizard);
    getContentPane().add(jPanelUp, java.awt.BorderLayout.PAGE_START);
    jSplitPaneMain.setDividerLocation(450);
    jSplitPaneMain.setVerifyInputWhenFocusTarget(false);
    jPanelMem.setLayout(new java.awt.GridLayout(0, 2));
    jPanelFrom.setLayout(new java.awt.BorderLayout());
    jLabelLow.setText("LOW");
    jPanelLo.add(jLabelLow);
    jPanelFrom.add(jPanelLo, java.awt.BorderLayout.PAGE_START);
    jTableLow.setModel(dataTableModelMemoryLow);
    jTableLow.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    jTableLow.setDefaultRenderer(Integer.class, memoryTableCellRenderer);
    jTableLow.getColumnModel().getColumn(0).setPreferredWidth(310);
    InputMap im = this.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    ActionMap am = this.getRootPane().getActionMap();
    // add custom action
    im.put(KeyStroke.getKeyStroke("control D"), "searchLow");
    am.put("searchLow", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            String addr = JOptionPane.showInputDialog("Search and go to a given HEX memory address");
            if (addr == null)
                return;
            try {
                int pos = Integer.parseInt(addr, 16);
                if (pos < 0 || pos > 0xFFFF)
                    return;
                jTableLow.getSelectionModel().setSelectionInterval(pos, pos);
                jTableLow.scrollRectToVisible(new Rectangle(jTableLow.getCellRect(pos, 0, true)));
            } catch (Exception e) {
            }
        }
    });
    ((InputMap) UIManager.get("Table.ancestorInputMap")).put(KeyStroke.getKeyStroke("control D"), "none");
    jTableLow.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jTableLowMouseClicked(evt);
        }
    });
    jScrollPaneLow.setViewportView(jTableLow);
    jPanelFrom.add(jScrollPaneLow, java.awt.BorderLayout.CENTER);
    jLabelSeachLow.setText("CTRL+D search");
    jPanelSearchLow.add(jLabelSeachLow);
    jPanelFrom.add(jPanelSearchLow, java.awt.BorderLayout.PAGE_END);
    jPanelMem.add(jPanelFrom);
    jPanelTo.setLayout(new java.awt.BorderLayout());
    jLabelHigh.setText("HIGH");
    jPanelHigh.add(jLabelHigh);
    jPanelTo.add(jPanelHigh, java.awt.BorderLayout.NORTH);
    jTableHigh.setModel(dataTableModelMemoryHigh);
    jTableHigh.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    jTableHigh.setDefaultRenderer(Integer.class, memoryTableCellRenderer);
    jTableHigh.getColumnModel().getColumn(0).setPreferredWidth(310);
    jTableHigh.getColumnModel().getColumn(0).setPreferredWidth(310);
    InputMap im1 = this.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    ActionMap am1 = this.getRootPane().getActionMap();
    // add custom action
    im1.put(KeyStroke.getKeyStroke("control F"), "searchHigh");
    am1.put("searchHigh", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            String addr = JOptionPane.showInputDialog("Search and go to a given HEX memory address");
            if (addr == null)
                return;
            try {
                int pos = Integer.parseInt(addr, 16);
                if (pos < 0 || pos > 0xFFFF)
                    return;
                jTableHigh.getSelectionModel().setSelectionInterval(pos, pos);
                jTableHigh.scrollRectToVisible(new Rectangle(jTableHigh.getCellRect(pos, 0, true)));
            } catch (Exception e) {
            }
        }
    });
    ((InputMap) UIManager.get("Table.ancestorInputMap")).put(KeyStroke.getKeyStroke("control F"), "none");
    jTableHigh.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jTableHighMouseClicked(evt);
        }
    });
    jScrollPaneHigh.setViewportView(jTableHigh);
    jPanelTo.add(jScrollPaneHigh, java.awt.BorderLayout.CENTER);
    jLabelSearchHigh.setText("CTRL+F search");
    jPanelSearchHigh.add(jLabelSearchHigh);
    jPanelTo.add(jPanelSearchHigh, java.awt.BorderLayout.PAGE_END);
    jPanelMem.add(jPanelTo);
    jSplitPaneMain.setLeftComponent(jPanelMem);
    jPanelTable.setLayout(new java.awt.BorderLayout());
    jPanelText.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jLabelText.setText("Preview of (combined)  memory address ");
    jPanelText.add(jLabelText);
    jPanelTable.add(jPanelText, java.awt.BorderLayout.NORTH);
    jLabelSize.setText("Table size:");
    jSpinnerSize.setModel(new javax.swing.SpinnerNumberModel(2, 1, 256, 1));
    jSpinnerSize.addChangeListener(new javax.swing.event.ChangeListener() {

        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            jSpinnerSizeStateChanged(evt);
        }
    });
    jButtonApply.setText("Apply");
    jButtonApply.setToolTipText("Apply the selected table/labels in memory");
    jButtonApply.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonApplyActionPerformed(evt);
        }
    });
    jLabelPrefix.setText("Prefix:");
    jTextFieldPrefix.addFocusListener(new java.awt.event.FocusAdapter() {

        public void focusLost(java.awt.event.FocusEvent evt) {
            jTextFieldPrefixFocusLost(evt);
        }
    });
    jLabelDigit.setText("Digit:");
    jSpinnerDigit.setModel(new javax.swing.SpinnerNumberModel(1, 1, 2, 1));
    jSpinnerDigit.setToolTipText("Min number of digits to use (can increase automatically)");
    jSpinnerDigit.addChangeListener(new javax.swing.event.ChangeListener() {

        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            jSpinnerDigitStateChanged(evt);
        }
    });
    jCheckBoxUpper.setText("Uppercase");
    jCheckBoxUpper.addItemListener(new java.awt.event.ItemListener() {

        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            jCheckBoxUpperItemStateChanged(evt);
        }
    });
    jLabelStart.setText("Start:");
    jSpinnerStart.setModel(new javax.swing.SpinnerNumberModel(0, 0, 255, 1));
    jSpinnerStart.addChangeListener(new javax.swing.event.ChangeListener() {

        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            jSpinnerStartStateChanged(evt);
        }
    });
    javax.swing.GroupLayout jPanelCmdLayout = new javax.swing.GroupLayout(jPanelCmd);
    jPanelCmd.setLayout(jPanelCmdLayout);
    jPanelCmdLayout.setHorizontalGroup(jPanelCmdLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanelCmdLayout.createSequentialGroup().addContainerGap().addComponent(jLabelSize).addGap(5, 5, 5).addComponent(jSpinnerSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addGap(26, 26, 26).addComponent(jLabelPrefix).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jTextFieldPrefix, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jLabelDigit).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jSpinnerDigit, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jLabelStart).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jSpinnerStart).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jCheckBoxUpper).addGap(18, 18, 18).addComponent(jButtonApply).addContainerGap()));
    jPanelCmdLayout.setVerticalGroup(jPanelCmdLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanelCmdLayout.createSequentialGroup().addGap(2, 2, 2).addGroup(jPanelCmdLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanelCmdLayout.createSequentialGroup().addGap(3, 3, 3).addComponent(jLabelSize)).addGroup(jPanelCmdLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jSpinnerSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabelPrefix).addComponent(jTextFieldPrefix, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabelDigit).addComponent(jSpinnerDigit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jButtonApply).addComponent(jCheckBoxUpper).addComponent(jLabelStart).addComponent(jSpinnerStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))).addGap(3, 3, 3)));
    jPanelTable.add(jPanelCmd, java.awt.BorderLayout.SOUTH);
    jScrollPaneTable.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    jScrollPaneTable.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    jScrollPaneTable.setPreferredSize(new java.awt.Dimension(700, 418));
    jTable.setModel(new javax.swing.table.DefaultTableModel(new Object[][] { { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null }, { null, null, null, null, null, null, null, null } }, new String[] { "1", "2", "3", "4", "5", "6", "7", "8" }) {

        Class[] types = new Class[] { java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class };

        boolean[] canEdit = new boolean[] { false, false, false, false, false, false, false, false };

        public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
        }

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
        }
    });
    jTable.setRowSelectionAllowed(false);
    jScrollPaneTable.setViewportView(jTable);
    jPanelTable.add(jScrollPaneTable, java.awt.BorderLayout.CENTER);
    jSplitPaneMain.setRightComponent(jPanelTable);
    javax.swing.GroupLayout jPanelCnLayout = new javax.swing.GroupLayout(jPanelCn);
    jPanelCn.setLayout(jPanelCnLayout);
    jPanelCnLayout.setHorizontalGroup(jPanelCnLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanelCnLayout.createSequentialGroup().addComponent(jSplitPaneMain, javax.swing.GroupLayout.DEFAULT_SIZE, 1149, Short.MAX_VALUE).addGap(0, 0, Short.MAX_VALUE)));
    jPanelCnLayout.setVerticalGroup(jPanelCnLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jSplitPaneMain, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 718, Short.MAX_VALUE));
    getContentPane().add(jPanelCn, java.awt.BorderLayout.CENTER);
    jPanelDn.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jButtonReset.setText("Reset");
    jButtonReset.setToolTipText("Clear all selection in this dialog");
    jButtonReset.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonResetActionPerformed(evt);
        }
    });
    jPanelDn.add(jButtonReset);
    jButtonClose.setText("Close");
    jButtonClose.setToolTipText("Close dialog");
    jButtonClose.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonCloseActionPerformed(evt);
        }
    });
    jPanelDn.add(jButtonClose);
    getContentPane().add(jPanelDn, java.awt.BorderLayout.PAGE_END);
    pack();
}
Also used : ActionEvent(java.awt.event.ActionEvent) Rectangle(java.awt.Rectangle) JTableHeader(javax.swing.table.JTableHeader) WizardTableCellRenderer(sw_emulator.swing.table.WizardTableCellRenderer) AbstractAction(javax.swing.AbstractAction) InputMap(javax.swing.InputMap) MemoryDasm(sw_emulator.software.MemoryDasm) MouseEvent(java.awt.event.MouseEvent) ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) MouseEvent(java.awt.event.MouseEvent)

Example 28 with MemoryDasm

use of sw_emulator.software.MemoryDasm in project jc64 by ice00.

the class JWizardDialog method popolate.

// End of variables declaration//GEN-END:variables
/**
 * Popolate the table with addresses
 *
 * @param rowLow low row position
 * @param rowHigh  high row position
 */
private void popolate(int rowLow, int rowHigh) {
    int row = -1;
    TableModel model = jTable.getModel();
    for (int i = 0; i < 256; i++) {
        if (i % 8 == 0)
            row++;
        model.setValueAt("", row, i % 8);
    }
    int size = (Integer) jSpinnerSize.getValue();
    if (hasError(rowLow, rowHigh, size))
        return;
    int address;
    String label;
    MemoryDasm mem;
    row = -1;
    for (int i = 0; i < size; i++) {
        if (i % 8 == 0)
            row++;
        address = (memory[rowLow + i].copy & 0xFF) + (memory[rowHigh + i].copy & 0xFF) * 256;
        mem = memory[address];
        if (mem.userLocation != null && !"".equals(mem.userLocation))
            label = mem.userLocation;
        else if (mem.dasmLocation != null && !"".equals(mem.dasmLocation))
            label = mem.dasmLocation;
        else
            label = "$" + Shared.ShortToExe((int) address);
        model.setValueAt(label, row, i % 8);
    }
}
Also used : MemoryDasm(sw_emulator.software.MemoryDasm) TableModel(javax.swing.table.TableModel)

Example 29 with MemoryDasm

use of sw_emulator.software.MemoryDasm in project jc64 by ice00.

the class FileManager method readProjectFile.

/**
 * Read the project from file
 *
 * @param file the file to read
 * @param project the project to fill from file
 * @return true if operation is ok
 */
public boolean readProjectFile(File file, Project project) {
    try {
        MemoryDasm mem;
        Relocate relocate;
        Patch patch;
        DataInputStream in;
        if (isGZipped(file))
            in = new DataInputStream(new GZIPInputStream(new BufferedInputStream(new FileInputStream(file))));
        else
            in = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
        byte version = in.readByte();
        project.name = in.readUTF();
        project.file = in.readUTF();
        project.description = in.readUTF();
        project.fileType = FileType.valueOf(in.readUTF());
        if (version > 0)
            project.targetType = TargetType.valueOf(in.readUTF());
        else
            project.targetType = TargetType.C64;
        int size = in.readInt();
        project.inB = new byte[size];
        // /in.read(project.inB);
        for (int i = 0; i < size; i++) {
            project.inB[i] = in.readByte();
        }
        size = in.readInt();
        project.memoryFlags = new byte[size];
        // /in.read(project.memoryFlags);
        for (int i = 0; i < size; i++) {
            project.memoryFlags[i] = in.readByte();
        }
        size = in.readInt();
        project.memory = new MemoryDasm[size];
        for (int i = 0; i < project.memory.length; i++) {
            mem = new MemoryDasm();
            mem.address = in.readInt();
            if (in.readBoolean())
                mem.dasmComment = in.readUTF();
            else
                mem.dasmComment = null;
            if (in.readBoolean())
                mem.userComment = in.readUTF();
            else
                mem.userComment = null;
            if (in.readBoolean())
                mem.userBlockComment = in.readUTF();
            else
                mem.userBlockComment = null;
            if (in.readBoolean())
                mem.dasmLocation = in.readUTF();
            else
                mem.dasmLocation = null;
            if (in.readBoolean())
                mem.userLocation = in.readUTF();
            else
                mem.userLocation = null;
            mem.isInside = in.readBoolean();
            mem.isCode = in.readBoolean();
            mem.isData = in.readBoolean();
            if (version > 0) {
                mem.isGarbage = in.readBoolean();
                mem.dataType = DataType.valueOf(in.readUTF());
            }
            // version 1
            mem.copy = in.readByte();
            mem.related = in.readInt();
            mem.type = in.readChar();
            if (project.fileType == FileType.MPR) {
                project.mpr = new MPR();
                project.mpr.getElements(project.inB);
            }
            if (version > 2) {
                // version 3
                mem.index = in.readByte();
            }
            project.memory[i] = mem;
        }
        // version 2
        if (version > 1)
            project.chip = in.readInt();
        if (version > 2) {
            // version 3
            for (int i = 0; i < Constant.COLS; i++) {
                for (int j = 0; j < Constant.MIN_ROWS; j++) {
                    if (in.readBoolean())
                        project.constant.table[i][j] = in.readUTF();
                    else
                        project.constant.table[i][j] = null;
                }
            }
        }
        if (version > 3) {
            // version 4
            size = in.readInt();
            if (size == 0)
                project.relocates = null;
            else {
                project.relocates = new Relocate[size];
                for (int i = 0; i < size; i++) {
                    relocate = new Relocate();
                    relocate.fromStart = in.readInt();
                    relocate.fromEnd = in.readInt();
                    relocate.toStart = in.readInt();
                    relocate.toEnd = in.readInt();
                    project.relocates[i] = relocate;
                }
            }
        }
        if (version > 4) {
            // version 5
            size = in.readInt();
            if (size == 0)
                project.patches = null;
            else {
                project.patches = new Patch[size];
                for (int i = 0; i < size; i++) {
                    patch = new Patch();
                    patch.address = in.readInt();
                    patch.value = in.readInt();
                    project.patches[i] = patch;
                }
            }
        }
        if (version > 5) {
            // version 6
            for (int i = 0; i < Constant.COLS; i++) {
                for (int j = Constant.MIN_ROWS; j < Constant.ROWS; j++) {
                    if (in.readBoolean())
                        project.constant.table[i][j] = in.readUTF();
                    else
                        project.constant.table[i][j] = null;
                }
            }
        }
    } catch (Exception e) {
        System.err.println(e);
        return false;
    }
    return true;
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) MemoryDasm(sw_emulator.software.MemoryDasm) BufferedInputStream(java.io.BufferedInputStream) DataInputStream(java.io.DataInputStream) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 30 with MemoryDasm

use of sw_emulator.software.MemoryDasm in project jc64 by ice00.

the class FileManager method writeProjectFile.

/**
 * Write the project output file
 *
 * @param file the file to write
 * @param project the project to write
 * @return true if operation is ok
 */
public boolean writeProjectFile(File file, Project project) {
    try {
        DataOutputStream out = new DataOutputStream(new GZIPOutputStream(new BufferedOutputStream(new FileOutputStream(file))));
        out.writeByte(project.ACTUAL_VERSION);
        out.writeUTF(project.name);
        out.writeUTF(project.file);
        out.writeUTF(project.description);
        out.writeUTF(project.fileType.name());
        // version 1
        out.writeUTF(project.targetType.name());
        out.writeInt(project.inB.length);
        out.write(project.inB);
        out.writeInt(project.memoryFlags.length);
        out.write(project.memoryFlags);
        out.writeInt(project.memory.length);
        for (MemoryDasm memory : project.memory) {
            out.writeInt(memory.address);
            if (memory.dasmComment != null) {
                out.writeBoolean(true);
                out.writeUTF(memory.dasmComment);
            } else {
                out.writeBoolean(false);
            }
            if (memory.userComment != null) {
                out.writeBoolean(true);
                out.writeUTF(memory.userComment);
            } else {
                out.writeBoolean(false);
            }
            if (memory.userBlockComment != null) {
                out.writeBoolean(true);
                out.writeUTF(memory.userBlockComment);
            } else {
                out.writeBoolean(false);
            }
            if (memory.dasmLocation != null) {
                out.writeBoolean(true);
                out.writeUTF(memory.dasmLocation);
            } else {
                out.writeBoolean(false);
            }
            if (memory.userLocation != null) {
                out.writeBoolean(true);
                out.writeUTF(memory.userLocation);
            } else {
                out.writeBoolean(false);
            }
            out.writeBoolean(memory.isInside);
            out.writeBoolean(memory.isCode);
            out.writeBoolean(memory.isData);
            // version 1
            out.writeBoolean(memory.isGarbage);
            // version 1
            out.writeUTF(memory.dataType.name());
            out.writeByte(memory.copy);
            out.writeInt(memory.related);
            out.writeChar(memory.type);
            // version 3
            out.writeByte(memory.index);
        }
        // version 2
        out.writeInt(project.chip);
        // version 3
        for (int i = 0; i < Constant.COLS; i++) {
            for (int j = 0; j < Constant.MIN_ROWS; j++) {
                if (project.constant.table[i][j] != null) {
                    out.writeBoolean(true);
                    out.writeUTF(project.constant.table[i][j]);
                } else {
                    out.writeBoolean(false);
                }
            }
        }
        // version 4
        if (project.relocates == null)
            out.writeInt(0);
        else {
            out.writeInt(project.relocates.length);
            for (Relocate relocate : project.relocates) {
                out.writeInt(relocate.fromStart);
                out.writeInt(relocate.fromEnd);
                out.writeInt(relocate.toStart);
                out.writeInt(relocate.toEnd);
            }
        }
        // version 5
        if (project.patches == null)
            out.writeInt(0);
        else {
            out.writeInt(project.patches.length);
            for (Patch patch : project.patches) {
                out.writeInt(patch.address);
                out.writeInt(patch.value);
            }
        }
        // version 6
        for (int i = 0; i < Constant.COLS; i++) {
            for (int j = Constant.MIN_ROWS; j < Constant.ROWS; j++) {
                if (project.constant.table[i][j] != null) {
                    out.writeBoolean(true);
                    out.writeUTF(project.constant.table[i][j]);
                } else {
                    out.writeBoolean(false);
                }
            }
        }
        out.flush();
        out.close();
    } catch (Exception e) {
        System.err.println(e);
        return false;
    }
    return true;
}
Also used : MemoryDasm(sw_emulator.software.MemoryDasm) GZIPOutputStream(java.util.zip.GZIPOutputStream) DataOutputStream(java.io.DataOutputStream) FileOutputStream(java.io.FileOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

MemoryDasm (sw_emulator.software.MemoryDasm)50 IOException (java.io.IOException)7 AWTException (java.awt.AWTException)6 JScrollPane (javax.swing.JScrollPane)6 JTable (javax.swing.JTable)5 BadLocationException (javax.swing.text.BadLocationException)5 Vector (java.util.Vector)4 Font (java.awt.Font)2 ActionEvent (java.awt.event.ActionEvent)2 MouseEvent (java.awt.event.MouseEvent)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 AbstractAction (javax.swing.AbstractAction)2 ActionMap (javax.swing.ActionMap)2 InputMap (javax.swing.InputMap)2 JTableHeader (javax.swing.table.JTableHeader)2 TableModel (javax.swing.table.TableModel)2 Rectangle (java.awt.Rectangle)1 Robot (java.awt.Robot)1 Clipboard (java.awt.datatransfer.Clipboard)1