Beispiel #1
0
  /** Loads the given program file (HACK or ASM) into the ROM. */
  public synchronized void loadProgram(String fileName) throws ProgramException {
    short[] program = null;

    if (displayChanges) ((ROMGUI) gui).showMessage("Loading...");

    try {
      program =
          HackAssemblerTranslator.loadProgram(
              fileName, Definitions.ROM_SIZE, HackAssemblerTranslator.NOP);

      mem = program;

      if (displayChanges) {
        gui.setContents(mem);

        ((ROMGUI) gui).setProgram(fileName);

        ((ROMGUI) gui).hideMessage();
        gui.hideHighlight();
      }

      notifyProgramListeners(ProgramEvent.LOAD, fileName);

    } catch (AssemblerException ae) {
      if (displayChanges) ((ROMGUI) gui).hideMessage();
      throw new ProgramException(ae.getMessage());
    }
  }
Beispiel #2
0
  /** Constructs a new ROM with the given ROM GUI. */
  public ROM(ROMGUI gui) {
    super(Definitions.ROM_SIZE, gui);
    setNullValue(HackAssemblerTranslator.NOP, true);
    listeners = new Vector();

    if (hasGUI) {
      gui.addProgramListener((ProgramEventListener) this);
      gui.setNumericFormat(ASM_FORMAT); // enable assembler
      //          gui.setNumericFormat(BINARY_FORMAT); // disable assembler
    }
  }