Examples > text-adventures COMPANION ZMACHINE.JS (18/28) step() { const start = this.pc; const op = this.mem[this.pc++]; let form, num, ops; if (op === 0xbe && this.version >= 5) { form = 'ext'; num = this.mem[this.pc++]; ops = this.fetchOperands(this.typeByte(this.mem[this.pc++])); } else if (op >= 0xc0) { num = op & 0x1f; form = op & 0x20 ? 'var' : '2op'; let types = this.typeByte(this.mem[this.pc++]); if (form === 'var' && (num === 0x0c || num === 0x1a)) types = types.concat(this.typeByte(this.mem[this.pc++])); ops = this.fetchOperands(types); } else if (op >= 0x80) { num = op & 0x0f; const t = (op >> 4) & 3; form = t === 3 ? '0op' : '1op'; ops = this.fetchOperands([t]); } else { form = '2op'; num = op & 0x1f; ops = this.fetchOperands([op & 0x40 ? 2 : 1, op & 0x20 ? 2 : 1]); } try { this.exec(form, num, ops); } catch (e) { if (e instanceof Restored) return; if (e instanceof ZError && !e.message.includes(' at pc ')) { e.message += ` at pc ${start.toString(16)} (${form} ${num})`; } throw e; } } store(v) { this.writeVar(this.mem[this.pc++], v); } Next: 40 Companion zmachine.js (19/28)