コード例 #1
0
  public void run() {
    RAM memory = Emulator.computer.memory;
    Emulator.computer.pause();
    int pos = memory.readWordRaw(startingAddressPointer);
    for (Line line : lines) {
      int nextPos = pos + line.getLength() + 1;
      memory.write(pos++, (byte) (nextPos & 0x0ff), false, true);
      memory.write(pos++, (byte) (nextPos >> 8 & 0x0ff), false, true);
      memory.write(pos++, (byte) (line.getNumber() & 0x0ff), false, true);
      memory.write(pos++, (byte) (line.getNumber() >> 8 & 0x0ff), false, true);
      boolean isFirst = true;
      for (Command command : line.getCommands()) {
        if (!isFirst) {
          memory.write(pos++, (byte) ':', false, true);
        }
        isFirst = false;
        for (Command.ByteOrToken part : command.parts) {
          memory.write(pos++, part.getByte(), false, true);
        }
      }
      memory.write(pos++, (byte) 0, false, true);
    }
    memory.write(pos++, (byte) 0, false, true);
    memory.write(pos++, (byte) 0, false, true);
    memory.write(pos++, (byte) 0, false, true);
    memory.write(pos++, (byte) 0, false, true);

    //        Emulator.computer.cpu.setProgramCounter(BASIC_RUN);
    Emulator.computer.resume();
  }
コード例 #2
0
 public static void brun(File binary, int address) throws FileNotFoundException, IOException {
   // If it was halted already, then it was initiated outside of an opcode execution
   // If it was not yet halted, then it is the case that the CPU is processing another opcode
   // So if that is the case, the program counter will need to be decremented here to compensate
   // TODO: Find a better mousetrap for this one -- it's an ugly hack
   Emulator.computer.pause();
   FileInputStream in = new FileInputStream(binary);
   byte[] data = new byte[in.available()];
   in.read(data);
   RAM ram = Emulator.computer.getMemory();
   for (int i = 0; i < data.length; i++) {
     ram.write(address + i, data[i], false, true);
   }
   CPU cpu = Emulator.computer.getCpu();
   Emulator.computer.getCpu().setProgramCounter(address);
   Emulator.computer.resume();
 }