43 Companion zmachine.js (22/28)

        case 0x02: { const c = a ? this.child(a) : 0; this.store(c); return this.branch(c !== 0); }
        case 0x03: return this.store(a ? this.parent(a) : 0);
        case 0x04: return this.store(this.propLen(a));
        case 0x05: return this.pokeVar(a, s16(this.peekVar(a)) + 1);
        case 0x06: return this.pokeVar(a, s16(this.peekVar(a)) - 1);
        case 0x07: return this.print(this.decode(a).text);
        case 0x08: return this.call(a, [], this.mem[this.pc++]);
        case 0x09: if (a) this.removeObj(a); return;
        case 0x0a: if (a) this.print(this.objectName(a)); return;
        case 0x0b: return this.ret(a);
        case 0x0c: this.pc += s16(a) - 2; return;
        case 0x0d: return this.print(this.decode(this.stringAddr(a)).text);
        case 0x0e: return this.store(this.peekVar(a));
        case 0x0f:
          if (v <= 4) return this.store(~a);
          return this.call(a, [], -1);
      }
    } else if (form === '0op') {
      switch (num) {
        case 0x00: return this.ret(1);
        case 0x01: return this.ret(0);
        case 0x02: { const { text, end } = this.decode(this.pc); this.pc = end; return this.print(text); }
        case 0x03: { const { text, end } = this.decode(this.pc); this.pc = end; this.print(text + '\n'); return this.ret(1); }
        case 0x04: return;
        case 0x05: return v <= 3 ? this.branch(this.doSave()) : this.store(this.doSave() ? 1 : 0);
‹ PreviousReader file (.txt)Next ›