zdata.length) { Debug.write("Invalid file: bad length: " + dataLength); return; } var sum = 0; for (var i = 64; i < dataLength; i++) sum = (sum+zdata[i])%65536; if (sum != getWord(28)) { Debug.write("Invalid file: bad checksum: " + getWord(28)); return; } Debug.write("High memory: " + getWord(4)); Debug.write("Initial PC: " + getWord(6)); brk = getWord(14); zmemory = zdata.slice(0, brk); // init header values setByte(1,28); // flags setByte(16,getByte(16)&2); // flags setByte(30,1); // interp number setByte(31,65); // interp version setByte(32,this.rows); setByte(33,this.cols); setWord(34,this.cols); setWord(36,this.rows); setByte(38,1); setByte(39,1); setByte(44,0); setByte(45,1); setByte(50,1); setByte(41,0); // zscreen.setNotifyResize(function() { // setByte(32,this.rows); // setByte(33,this.cols); // setWord(34,this.cols); // setWord(36,this.rows); // }); extraCharTable = { 155:0x0e4, 156:0x0f6, 157:0x0fc, 158:0x0c4, 159:0x0d6, 160:0x0dc, 161:0x0df, 162:0x0bb, 163:0x0ab, 164:0x0eb, 165:0x0ef, 166:0x0ff, 167:0x0cb, 168:0x0cf, 169:0x0e1, 170:0x0e9, 171:0x0ed, 172:0x0f3, 173:0x0fa, 174:0x0fd, 175:0x0c1, 176:0x0c9, 177:0x0cd, 178:0x0d3, 179:0x0da, 180:0x0dd, 181:0x0e0, 182:0x0e8, 183:0x0ec, 184:0x0f2, 185:0x0f9, 186:0x0c0, 187:0x0c8, 188:0x0cc, 189:0x0d2, 190:0x0d9, 191:0x0e2, 192:0x0ea, 193:0x0ee, 194:0x0f4, 195:0x0fb, 196:0x0c2, 197:0x0ca, 198:0x0ce, 199:0x0d4, 200:0x0db, 201:0x0e5, 202:0x0c5, 203:0x0f8, 204:0x0d8, 205:0x0e3, 206:0x0f1, 207:0x0f5, 208:0x0c3, 209:0x0d1, 210:0x0d5, 211:0x0e6, 212:0x0c6, 213:0x0e7, 214:0x0c7, 215:0x0fe, 216:0x0f0, 217:0x0de, 218:0x0d0, 219:0x0a3, 220:0x153, 221:0x152, 222:0x0a1, 223:0x0bf, 224:63, 225:63, 226:63, 227:63, 228:63, 229:63, 230:63, 231:63, 232:63, 233:63, 234:63, 235:63, 236:63, 237:63, 238:63, 239:63, 240:63, 241:63, 242:63, 243:63, 244:63, 245:63, 246:63, 247:63, 248:63, 249:63, 250:63, 251:63 }; // FIXME: specified table charTable = [["a","b","c","d","e","f","g","h","i","j","k","l","m", "n","o","p","q","r","s","t","u","v","w","x","y","z"], ["A","B","C","D","E","F","G","H","I","J","K","L","M", "N","O","P","Q","R","S","T","U","V","W","X","Y","Z"], [null,"\n","0","1","2","3","4","5","6","7","8","9",".", ",","!","?","_","#","'","\"","/","\\","-",":","(",")"]]; if (getWord(52)) { for (var i = 0; i < 26; i++) { charTable[0][i] = String.fromCharCode(getByte(getWord(52)+i)); charTable[1][i]=String.fromCharCode(getByte(getWord(52)+26+i)); if (i > 1) charTable[2][i] = String.fromCharCode( getByte(getWord(52)+52+i)); } } invCharTable = {}; for (var i = 0; i < 26; i++) { invCharTable[charTable[0][i].charCodeAt(0)] = i+6; invCharTable[charTable[1][i].charCodeAt(0)] = 32+i+6; if (i > 0) invCharTable[charTable[2][i].charCodeAt(0)] = 64+i+6; } stackFrame.pc = getWord(6); // start the mainloop if (!this.mainloopDelegate) { this.mainloopDelegate = new LzDelegate(this, "mainloop"); } LzTimer.addTimer(this.mainloopDelegate, this.mainloopDelay); ]]> 0) { if (keys[0] != this.lastKey) { zscreen.receiveKey(keys[0]); this.lastKey = keys[0]; } } else { this.lastKey = ""; } // handle cursor blinking // this.blinkcount -= 1; // if (this.blinkcount <= 0) // { // zscreen.cursorOn = !zscreen.cursorOn; // zscreen.positionCursor(); // this.blinkcount = 50; // } } this.scheduleMainLoop(); ]]> LzTimer.resetTimer(this.mainloopDelegate, this.mainloopDelay); >> 16) & 255, (n >>> 8) & 255, n & 255); //r += String.fromCharCode((n >>> 16) & 255, (n >>> 8) & 255, n & 255); data[data.length] = (n >>> 16) & 255; data[data.length] = (n >>> 8) & 255; data[data.length] = (n & 255); } // remove any zero pad that was added to make this a multiple of 24 bits //return r.substr(0, r.length - p.length); return data.slice(0, data.length - p.length); ]]>