24 Companion zmachine.js (3/28)
setupHeader() {
const v = this.version;
if (v <= 3) {
// bit 4: status line NOT available (clear), bit 5: split screen available
this.mem[0x01] = (this.mem[0x01] & ~0x70) | 0x20;
} else {
// bold, italic, fixed font; no colours, pictures, sound or timed input
this.mem[0x01] = (this.mem[0x01] & ~0xbf) | 0x1c;
this.mem[0x1e] = 6; // interpreter number: IBM PC
this.mem[0x1f] = 0x41; // version 'A'
this.mem[0x20] = 255; // screen height: infinite
this.mem[0x21] = this.screenWidth;
}
if (v >= 5) {
this.ww(0x22, this.screenWidth);
this.ww(0x24, 255);
this.mem[0x26] = 1;
this.mem[0x27] = 1;
this.mem[0x2c] = 1; // default colours
this.mem[0x2d] = 1;
// flags 2: we can't do pictures, mouse, colours, sound or menus. Undo works.
this.ww(0x10, this.rw(0x10) & ~(0x08 | 0x20 | 0x40 | 0x80 | 0x100));
}
this.ww(0x32, 0x0101); // standard 1.1
}
loadTables() {
const v = this.version;
this.abbrevs = this.rw(0x18);
this.objects = this.rw(0x0a);
this.globals = this.rw(0x0c);
this.dictionary = this.rw(0x08);
this.routineOffset = v === 7 ? this.rw(0x28) * 8 : 0;
this.stringOffset = v === 7 ? this.rw(0x2a) * 8 : 0;
this.packScale = v <= 3 ? 2 : v <= 7 ? 4 : 8;