示例#1
0
  public IdeMain() {
    cpu = new Dcpu();
    debugger = new Debugger();
    debugger.breakpointListener =
        new PreListener<Character>() {
          public void preExecute(Character arg) {
            breakpointHit(arg);
          }
        };
    debugger.attachTo(cpu);
    asmMap = new AsmMap();

    MonitorLEM1802 monitor = new MonitorLEM1802();
    cpu.attach(monitor);
    MonitorWindow window = new MonitorWindow(cpu, monitor, false);
    window.show();

    Sped3 sped = new Sped3();
    cpu.attach(sped);
    SpedWindow spedWindow = new SpedWindow(cpu, sped, false);
    spedWindow.show();
    spedWindow.getFrame().setSize(600, 600);

    GenericClock clock = new GenericClock(MonitorLEM1802.MANUFACTURER_ID); // Nya Elektriska
    GenericKeyboard keyboard = new GenericKeyboard(MonitorLEM1802.MANUFACTURER_ID, 16);
    cpu.attach(clock);
    cpu.attach(keyboard);
    window.addKeyListener(keyboard);

    fileChooser = new JFileChooser();
    fileChooser.setCurrentDirectory(new File("."));

    registersModel = new RegistersModel(cpu, debugger);
    registersTable.setModel(registersModel);
    memoryModel = new MemoryModel(cpu, debugger);
    memoryTable.setModel(memoryModel);

    sourceRowHeader = new SourceRowHeader(sourceTextarea, srcBreakpoints);
    sourceRowHeader.setBackground(Color.LIGHT_GRAY);
    sourceScrollPane.setRowHeaderView(sourceRowHeader);

    frame = new JFrame("JA-DCPU IDE");
    frame.setContentPane(rootPanel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);

    openSrcButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            openSrc();
          }
        });
    asmButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            assemble();
          }
        });
    saveSrcButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveSrc();
          }
        });
    hardResetButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cpu.memzero();
            memoryModel.fireUpdate(0, RAM_SIZE);
            cpu.reset();
            registersModel.fireUpdate();
          }
        });
    resetButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cpu.reset();
            registersModel.fireUpdate();
          }
        });
    saveBinButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveBin();
          }
        });
    openBinButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            openBin();
          }
        });
    stepButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            step();
          }
        });
    breakpointButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            toggleBreakpoint();
          }
        });
    runButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            debugger.breakpointsHalt = true;
            runCpu();
          }
        });
    execButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            debugger.breakpointsHalt = false;
            runCpu();
          }
        });
    pauseButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cpu.halt = true;
          }
        });
  }
示例#2
0
 /**
  * Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR
  * call it in your code!
  *
  * @noinspection ALL
  */
 private void $$$setupUI$$$() {
   rootPanel = new JPanel();
   rootPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1));
   final JToolBar toolBar1 = new JToolBar();
   rootPanel.add(
       toolBar1,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           new Dimension(-1, 20),
           null,
           0,
           false));
   openSrcButton = new JButton();
   openSrcButton.setText("Open Src");
   openSrcButton.setToolTipText("Open source file");
   toolBar1.add(openSrcButton);
   openBinButton = new JButton();
   openBinButton.setEnabled(true);
   openBinButton.setText("Open Bin");
   openBinButton.setToolTipText("Open and disassemble binaries");
   toolBar1.add(openBinButton);
   saveSrcButton = new JButton();
   saveSrcButton.setEnabled(true);
   saveSrcButton.setText("Save Src");
   saveSrcButton.setToolTipText("Save sources");
   toolBar1.add(saveSrcButton);
   saveBinButton = new JButton();
   saveBinButton.setEnabled(true);
   saveBinButton.setText("Save Bin");
   saveBinButton.setToolTipText("Save assembled binary");
   toolBar1.add(saveBinButton);
   final JToolBar.Separator toolBar$Separator1 = new JToolBar.Separator();
   toolBar1.add(toolBar$Separator1);
   asmButton = new JButton();
   asmButton.setText("Asm");
   asmButton.setToolTipText("Assemble sources");
   toolBar1.add(asmButton);
   final JToolBar.Separator toolBar$Separator2 = new JToolBar.Separator();
   toolBar1.add(toolBar$Separator2);
   hardResetButton = new JButton();
   hardResetButton.setEnabled(true);
   hardResetButton.setText("Hard Reset");
   hardResetButton.setToolTipText("Hard Reset - zeroize memory and reupload binary");
   toolBar1.add(hardResetButton);
   resetButton = new JButton();
   resetButton.setEnabled(true);
   resetButton.setText("Reset");
   resetButton.setToolTipText("Reset CPU (registers to zero)");
   toolBar1.add(resetButton);
   execButton = new JButton();
   execButton.setEnabled(true);
   execButton.setText("Exec");
   execButton.setToolTipText("Run forever");
   toolBar1.add(execButton);
   pauseButton = new JButton();
   pauseButton.setEnabled(false);
   pauseButton.setText("Pause");
   pauseButton.setToolTipText("Pause execution");
   toolBar1.add(pauseButton);
   runButton = new JButton();
   runButton.setEnabled(true);
   runButton.setText("Run");
   runButton.setToolTipText("Run until breakpoint/reserved");
   toolBar1.add(runButton);
   stepButton = new JButton();
   stepButton.setEnabled(true);
   stepButton.setText("Step");
   stepButton.setToolTipText("Execute one instruction");
   toolBar1.add(stepButton);
   final JToolBar.Separator toolBar$Separator3 = new JToolBar.Separator();
   toolBar1.add(toolBar$Separator3);
   breakpointButton = new JButton();
   breakpointButton.setEnabled(true);
   breakpointButton.setText("Breakpoint");
   breakpointButton.setToolTipText("Toggle breakpoint on instruction address");
   toolBar1.add(breakpointButton);
   final JPanel panel1 = new JPanel();
   panel1.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1));
   rootPanel.add(
       panel1,
       new GridConstraints(
           1,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           null,
           null,
           null,
           0,
           false));
   final JLabel label1 = new JLabel();
   label1.setText("Source");
   panel1.add(
       label1,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JLabel label2 = new JLabel();
   label2.setText("Memory");
   panel1.add(
       label2,
       new GridConstraints(
           0,
           1,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final JLabel label3 = new JLabel();
   label3.setText("Registers");
   panel1.add(
       label3,
       new GridConstraints(
           0,
           2,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   memoryScrollPane = new JScrollPane();
   panel1.add(
       memoryScrollPane,
       new GridConstraints(
           1,
           1,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           new Dimension(600, -1),
           null,
           0,
           false));
   memoryTable = new JTable();
   memoryScrollPane.setViewportView(memoryTable);
   final JScrollPane scrollPane1 = new JScrollPane();
   panel1.add(
       scrollPane1,
       new GridConstraints(
           1,
           2,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           new Dimension(100, -1),
           null,
           0,
           false));
   registersTable = new JTable();
   scrollPane1.setViewportView(registersTable);
   sourceScrollPane = new JScrollPane();
   panel1.add(
       sourceScrollPane,
       new GridConstraints(
           1,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           new Dimension(500, 400),
           null,
           0,
           false));
   sourceTextarea = new JTextArea();
   sourceTextarea.setFont(new Font("Courier New", sourceTextarea.getFont().getStyle(), 12));
   sourceTextarea.setText(
       "; Input your program here\n            set a, 1\n            add a, 1\n            ife a, 2\n                set a, 3\n:mainloop\n            ife [message + I], 0\n                set pc, end\n            set a, [message + I]\n            add a, 0xA100\n            set [0x8000 + I], a\n            add i, 1\n            set pc, mainloop\n:message    dat \"Hello, world!\", 0\n:end        set pc, end");
   sourceScrollPane.setViewportView(sourceTextarea);
   final JPanel panel2 = new JPanel();
   panel2.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1));
   panel2.setVisible(false);
   rootPanel.add(
       panel2,
       new GridConstraints(
           2,
           0,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           null,
           null,
           null,
           0,
           false));
   consoleTextarea = new JTextArea();
   consoleTextarea.setEditable(true);
   panel2.add(
       consoleTextarea,
       new GridConstraints(
           1,
           0,
           1,
           3,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_BOTH,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           null,
           new Dimension(150, 200),
           null,
           0,
           false));
   final JLabel label4 = new JLabel();
   label4.setText("Console");
   panel2.add(
       label4,
       new GridConstraints(
           0,
           0,
           1,
           1,
           GridConstraints.ANCHOR_WEST,
           GridConstraints.FILL_NONE,
           GridConstraints.SIZEPOLICY_FIXED,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   clearButton = new JButton();
   clearButton.setText("Clear");
   panel2.add(
       clearButton,
       new GridConstraints(
           0,
           1,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
           GridConstraints.SIZEPOLICY_FIXED,
           null,
           null,
           null,
           0,
           false));
   final Spacer spacer1 = new Spacer();
   panel2.add(
       spacer1,
       new GridConstraints(
           0,
           2,
           1,
           1,
           GridConstraints.ANCHOR_CENTER,
           GridConstraints.FILL_HORIZONTAL,
           GridConstraints.SIZEPOLICY_WANT_GROW,
           1,
           null,
           null,
           null,
           0,
           false));
 }