Esempio n. 1
0
 public static ApplesoftProgram fromMemory(RAM memory) {
   int startAddress = memory.readWordRaw(startingAddressPointer);
   int nextCheck = memory.readWordRaw(startAddress);
   int pos = startAddress;
   List<Byte> bytes = new ArrayList<>();
   while (nextCheck != 0) {
     while (pos < nextCheck + 2) {
       bytes.add(memory.readRaw(pos++));
     }
     nextCheck = memory.readWordRaw(nextCheck);
   }
   return fromBinary(bytes, startAddress);
 }
Esempio n. 2
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();
  }