コード例 #1
0
ファイル: ROM.java プロジェクト: kingpinzs/nand2tetris-emu
  /** 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());
    }
  }