// Path: simulator/src/org/z64sim/memory/Memory.java
// public class Memory {
// 
//     private static MemoryTopComponent window = null;
//     //private static Program program = null;
//     private static Program program = new Program(); // aggiunto per evitare nullPointerException
// 
//     // This class cannot be instantiated
//     private Memory() {
//     }
// 
//     public static Program getProgram() {
//         return program;
//     }
// 
//     public static void setProgram(Program program) {
//         Memory.program = program;
//     }
//     
//     public static void setWindow(MemoryTopComponent w) {
//         Memory.window = w;
//     }
// 
//     public static MemoryTopComponent getWindow() {
//         return Memory.window;
//     }
// 
//     public static void redrawMemory() {
//         if (Memory.window != null) {
//             Memory.window.memoryTable.setModel(new MemoryTableModel());
//             int _startRow = (int) (Memory.program._start / 8);
// 
//             // Select the row corresponding to the entry point
//             Memory.window.memoryTable.setRowSelectionInterval(_startRow, _startRow);
// 
//             // Scroll to that row
//             Memory.window.memoryTable.scrollRectToVisible(new Rectangle(Memory.window.memoryTable.getCellRect(_startRow, 0, true)));
// 
//             // Show the panel
//             Memory.window.requestVisible();
//         }
//         
//     }
// 
// }
// 
// Path: simulator/src/org/z64sim/simulator/Simulator.java
// public class Simulator {
//     
//     private static SimulatorMulticycleTopComponent multicycleWindow = null;
//     
//     private Simulator() {}
//     
//     public static synchronized void setMulticycle(SimulatorMulticycleTopComponent mc)  {
//         Simulator.multicycleWindow = mc;
//     }
//     
//     public static synchronized void resetMulticycle(SimulatorMulticycleTopComponent mc)  {
//         if(Simulator.multicycleWindow == mc)
//             Simulator.multicycleWindow = null;
//     }
//     
//     public static boolean activate() {
//         if(multicycleWindow != null) {
//             multicycleWindow.requestFocusInWindow();
//             multicycleWindow.checkEnabled();
//             return true;
//         }
//         return false;
//     }
//     
// }


import javax.swing.JOptionPane;
import org.jdesktop.beansbinding.Converter;
import org.netbeans.api.settings.ConvertAsProperties;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.windows.TopComponent;
import org.openide.util.NbBundle.Messages;
import org.z64sim.memory.Memory;
import org.z64sim.simulator.Simulator;
    private javax.swing.JTextField RCX_view;
    private javax.swing.JLabel RDI_label;
    private javax.swing.JTextField RDI_view;
    private javax.swing.JLabel RDX_label;
    private javax.swing.JTextField RDX_view;
    private javax.swing.JLabel RIP_label;
    private javax.swing.JTextField RIP_view;
    private javax.swing.JLabel RSI_label;
    private javax.swing.JTextField RSI_view;
    private javax.swing.JLabel RSP_label;
    private javax.swing.JTextField RSP_view;
    private javax.swing.JPanel Registers;
    private javax.swing.JCheckBox SF;
    private javax.swing.JCheckBox ZF;
    private javax.swing.Box.Filler filler1;
    private javax.swing.JToolBar.Separator jSeparator1;
    public javax.swing.JToolBar multicycleToolbar;
    private javax.swing.JButton run;
    private javax.swing.JSlider speedSlider;
    private javax.swing.JLabel speedValue;
    private javax.swing.JLabel speed_label;
    private javax.swing.JButton step;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

    @Override
    public void componentOpened() {
        checkEnabled();

        // Register this window as the current Multicycle Simulator
// Path: simulator/src/org/z64sim/memory/Memory.java
// public class Memory {
// 
//     private static MemoryTopComponent window = null;
//     //private static Program program = null;
//     private static Program program = new Program(); // aggiunto per evitare nullPointerException
// 
//     // This class cannot be instantiated
//     private Memory() {
//     }
// 
//     public static Program getProgram() {
//         return program;
//     }
// 
//     public static void setProgram(Program program) {
//         Memory.program = program;
//     }
//     
//     public static void setWindow(MemoryTopComponent w) {
//         Memory.window = w;
//     }
// 
//     public static MemoryTopComponent getWindow() {
//         return Memory.window;
//     }
// 
//     public static void redrawMemory() {
//         if (Memory.window != null) {
//             Memory.window.memoryTable.setModel(new MemoryTableModel());
//             int _startRow = (int) (Memory.program._start / 8);
// 
//             // Select the row corresponding to the entry point
//             Memory.window.memoryTable.setRowSelectionInterval(_startRow, _startRow);
// 
//             // Scroll to that row
//             Memory.window.memoryTable.scrollRectToVisible(new Rectangle(Memory.window.memoryTable.getCellRect(_startRow, 0, true)));
// 
//             // Show the panel
//             Memory.window.requestVisible();
//         }
//         
//     }
// 
// }
// 
// Path: simulator/src/org/z64sim/simulator/Simulator.java
// public class Simulator {
//     
//     private static SimulatorMulticycleTopComponent multicycleWindow = null;
//     
//     private Simulator() {}
//     
//     public static synchronized void setMulticycle(SimulatorMulticycleTopComponent mc)  {
//         Simulator.multicycleWindow = mc;
//     }
//     
//     public static synchronized void resetMulticycle(SimulatorMulticycleTopComponent mc)  {
//         if(Simulator.multicycleWindow == mc)
//             Simulator.multicycleWindow = null;
//     }
//     
//     public static boolean activate() {
//         if(multicycleWindow != null) {
//             multicycleWindow.requestFocusInWindow();
//             multicycleWindow.checkEnabled();
//             return true;
//         }
//         return false;
//     }
//     
// }


// Path: simulator/src/org/z64sim/simulator/multicycle/SimulatorMulticycleTopComponent.java
import javax.swing.JOptionPane;
import org.jdesktop.beansbinding.Converter;
import org.netbeans.api.settings.ConvertAsProperties;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.windows.TopComponent;
import org.openide.util.NbBundle.Messages;
import org.z64sim.memory.Memory;
import org.z64sim.simulator.Simulator;

    private javax.swing.JTextField RCX_view;
    private javax.swing.JLabel RDI_label;
    private javax.swing.JTextField RDI_view;
    private javax.swing.JLabel RDX_label;
    private javax.swing.JTextField RDX_view;
    private javax.swing.JLabel RIP_label;
    private javax.swing.JTextField RIP_view;
    private javax.swing.JLabel RSI_label;
    private javax.swing.JTextField RSI_view;
    private javax.swing.JLabel RSP_label;
    private javax.swing.JTextField RSP_view;
    private javax.swing.JPanel Registers;
    private javax.swing.JCheckBox SF;
    private javax.swing.JCheckBox ZF;
    private javax.swing.Box.Filler filler1;
    private javax.swing.JToolBar.Separator jSeparator1;
    public javax.swing.JToolBar multicycleToolbar;
    private javax.swing.JButton run;
    private javax.swing.JSlider speedSlider;
    private javax.swing.JLabel speedValue;
    private javax.swing.JLabel speed_label;
    private javax.swing.JButton step;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

    @Override
    public void componentOpened() {
        checkEnabled();

        // Register this window as the current Multicycle Simulator
        Simulator.setMulticycle(this);