run method

void run([
  1. Engine? machineOverride
])

Runs the Z-Machine using the detected machine version from the story file. This can be overridden by passing machineOverride to the function. Doing so will cause given Engine to be used for execution.

Implementation

void run([Engine? machineOverride]) {
  _assertLoaded();

  if (machineOverride != null) {
    engine = machineOverride;
    engine.mem = MemoryMap(rawBytes);
    engine.visitHeader();
  }

  //for main routine only.
  engine.programCounter--;

  // visit the main 'routine' (call stack required empty)
  engine.visitRoutine([]);

  //push dummy result store onto the call stack
  engine.callStack.push(0);

  //push dummy return address onto the call stack
  engine.callStack.push(0);

  if (inBreak) {
    callAsync(Debugger.startBreak);
  } else {
    log.finest("run() callAsync(runIt)");
    callAsync(runIt);
  }
}