$estr = function() { return js.Boot.__string_rec(this,''); }
hiscumm = {}
hiscumm.SPUTMObject = function(p) { if( p === $_ ) return; {
	null;
}}
hiscumm.SPUTMObject.__name__ = ["hiscumm","SPUTMObject"];
hiscumm.SPUTMObject.prototype.image = null;
hiscumm.SPUTMObject.prototype.__class__ = hiscumm.SPUTMObject;
hiscumm.ChunkReader = function(bytes) { if( bytes === $_ ) return; {
	this.reader = bytes;
	this.reset();
}}
hiscumm.ChunkReader.__name__ = ["hiscumm","ChunkReader"];
hiscumm.ChunkReader.chunkIDToStr = function(name) {
	return (String.fromCharCode(new noneko.Int32(name.value >> 24).value) + String.fromCharCode(new noneko.Int32(new noneko.Int32(name.value >> 16).value & new noneko.Int32(255).value).value) + String.fromCharCode(new noneko.Int32(new noneko.Int32(name.value >> 8).value & new noneko.Int32(255).value).value) + String.fromCharCode(new noneko.Int32(name.value & new noneko.Int32(255).value).value));
}
hiscumm.ChunkReader.prototype.chunkID = null;
hiscumm.ChunkReader.prototype.chunkName = function() {
	if(noneko.Int32.compare(this.chunkID,new noneko.Int32(0)) == 0) return "????";
	return hiscumm.ChunkReader.chunkIDToStr(this.chunkID);
}
hiscumm.ChunkReader.prototype.chunkOffs = null;
hiscumm.ChunkReader.prototype.chunkSize = null;
hiscumm.ChunkReader.prototype.nextChunk = function() {
	if(this.chunkOffs >= 0) this.reader.seek(this.chunkOffs + this.chunkSize,utils.Seek.SeekBegin);
	try {
		this.chunkOffs = this.reader.tell();
		this.chunkID = noneko.Int32.read(this.reader,true);
		this.chunkSize = noneko.Int32.read(this.reader,true).value;
	}
	catch( $e0 ) {
		{
			var e = $e0;
			{
				return false;
			}
		}
	}
	return true;
}
hiscumm.ChunkReader.prototype.readChunkData = function() {
	var mem = new utils.JSByteIO();
	mem.prepare(this.chunkSize);
	mem.writeInput(this.reader);
	return mem;
}
hiscumm.ChunkReader.prototype.reader = null;
hiscumm.ChunkReader.prototype.reset = function() {
	this.chunkID = new noneko.Int32(0);
	this.chunkSize = 0;
	this.chunkOffs = -1;
}
hiscumm.ChunkReader.prototype.__class__ = hiscumm.ChunkReader;
utils = {}
utils.Seekable = function() { }
utils.Seekable.__name__ = ["utils","Seekable"];
utils.Seekable.prototype.seek = null;
utils.Seekable.prototype.tell = null;
utils.Seekable.prototype.__class__ = utils.Seekable;
noneko = {}
noneko.Output = function() { }
noneko.Output.__name__ = ["noneko","Output"];
noneko.Output.prototype.close = null;
noneko.Output.prototype.flush = null;
noneko.Output.prototype.prepare = null;
noneko.Output.prototype.write = null;
noneko.Output.prototype.writeBytes = null;
noneko.Output.prototype.writeChar = null;
noneko.Output.prototype.writeDouble = null;
noneko.Output.prototype.writeDoubleB = null;
noneko.Output.prototype.writeFloat = null;
noneko.Output.prototype.writeFloatB = null;
noneko.Output.prototype.writeFullBytes = null;
noneko.Output.prototype.writeInput = null;
noneko.Output.prototype.writeInt16 = null;
noneko.Output.prototype.writeInt24 = null;
noneko.Output.prototype.writeInt32 = null;
noneko.Output.prototype.writeInt8 = null;
noneko.Output.prototype.writeUInt16 = null;
noneko.Output.prototype.writeUInt16B = null;
noneko.Output.prototype.writeUInt24 = null;
noneko.Output.prototype.writeUInt24B = null;
noneko.Output.prototype.writeUInt32 = null;
noneko.Output.prototype.writeUInt32B = null;
noneko.Output.prototype.__class__ = noneko.Output;
noneko.Input = function() { }
noneko.Input.__name__ = ["noneko","Input"];
noneko.Input.prototype.close = null;
noneko.Input.prototype.read = null;
noneko.Input.prototype.readAll = null;
noneko.Input.prototype.readBytes = null;
noneko.Input.prototype.readChar = null;
noneko.Input.prototype.readDouble = null;
noneko.Input.prototype.readDoubleB = null;
noneko.Input.prototype.readFloat = null;
noneko.Input.prototype.readFloatB = null;
noneko.Input.prototype.readFullBytes = null;
noneko.Input.prototype.readInt16 = null;
noneko.Input.prototype.readInt24 = null;
noneko.Input.prototype.readInt32 = null;
noneko.Input.prototype.readInt8 = null;
noneko.Input.prototype.readLine = null;
noneko.Input.prototype.readUInt16 = null;
noneko.Input.prototype.readUInt16B = null;
noneko.Input.prototype.readUInt24 = null;
noneko.Input.prototype.readUInt24B = null;
noneko.Input.prototype.readUInt32 = null;
noneko.Input.prototype.readUInt32B = null;
noneko.Input.prototype.readUntil = null;
noneko.Input.prototype.__class__ = noneko.Input;
utils.JSByteIO = function(arr) { if( arr === $_ ) return; {
	if(arr == null) {
		this.bytes = new Array();
	}
	else {
		this.bytes = arr;
	}
	this.pos = 0;
}}
utils.JSByteIO.__name__ = ["utils","JSByteIO"];
utils.JSByteIO.fromURL = function(url) {
	var res = new utils.JSByteIO();
	var req = new js.XMLHttpRequest();
	req.open("GET",url,false);
	req.overrideMimeType("text/plain; charset=x-user-defined");
	req.send(null);
	var str = ((req.status != 200)?"":req.responseText);
	haxe.Log.trace("XMLHttpRequest: Loaded " + str.length + " bytes",{ fileName : "JSByteIO.hx", lineNumber : 390, className : "utils.JSByteIO", methodName : "fromURL"});
	res.prepare(str.length);
	res.write(str);
	res.pos = 0;
	return res;
}
utils.JSByteIO.prototype.bytes = null;
utils.JSByteIO.prototype.close = function() {
	this.bytes = null;
}
utils.JSByteIO.prototype.flush = function() {
	null;
}
utils.JSByteIO.prototype.pos = null;
utils.JSByteIO.prototype.prepare = function(nbytes) {
	var i = nbytes - 1;
	while(i >= 0) {
		this.bytes[i] = 0;
		i -= 1;
	}
}
utils.JSByteIO.prototype.read = function(nbytes) {
	var buf = new StringBuf();
	while(nbytes > 0) {
		buf.addChar(this.bytes[this.pos]);
		this.pos += 1;
		nbytes -= 1;
	}
	return buf.toString();
}
utils.JSByteIO.prototype.readAll = function(bufsize) {
	return this.read(this.bytes.length);
}
utils.JSByteIO.prototype.readBytes = function(s,p,len) {
	return 0;
}
utils.JSByteIO.prototype.readChar = function() {
	if(this.pos + 1 > this.bytes.length) throw new noneko.Eof();
	var c = this.bytes[this.pos];
	this.pos += 1;
	return c;
}
utils.JSByteIO.prototype.readDouble = function() {
	return 0;
}
utils.JSByteIO.prototype.readDoubleB = function() {
	return 0;
}
utils.JSByteIO.prototype.readFloat = function() {
	return 0;
}
utils.JSByteIO.prototype.readFloatB = function() {
	return 0;
}
utils.JSByteIO.prototype.readFullBytes = function(s,pos,len) {
	return noneko.IOTools.readFullBytes(this,s,pos,len);
}
utils.JSByteIO.prototype.readInt16 = function() {
	var ch1 = this.readChar();
	var ch2 = this.readChar();
	var n = ch1 | (ch2 << 8);
	if((ch2 & 128) != 0) return n - 65536;
	return n;
}
utils.JSByteIO.prototype.readInt24 = function() {
	return noneko.IOTools.readInt24(this);
}
utils.JSByteIO.prototype.readInt32 = function() {
	var ch1 = this.readChar();
	var ch2 = this.readChar();
	var ch3 = this.readChar();
	var ch4 = this.readChar();
	if((ch4 & 128) != 0) {
		if((ch4 & 64) == 0) throw noneko.Error.Overflow;
		return ((ch1 | (ch2 << 8)) | (ch3 << 16)) | ((ch4 & 127) << 24);
	}
	else {
		if((ch4 & 64) != 0) throw noneko.Error.Overflow;
		return ((ch1 | (ch2 << 8)) | (ch3 << 16)) | (ch4 << 24);
	}
}
utils.JSByteIO.prototype.readInt8 = function() {
	var n = this.readChar();
	if(n >= 128) return n - 256;
	return n;
}
utils.JSByteIO.prototype.readLine = function() {
	return noneko.IOTools.readLine(this);
}
utils.JSByteIO.prototype.readUInt16 = function() {
	var ch1 = this.readChar();
	var ch2 = this.readChar();
	return ch1 | (ch2 << 8);
}
utils.JSByteIO.prototype.readUInt16B = function() {
	var ch1 = this.readChar();
	var ch2 = this.readChar();
	return ch2 | (ch1 << 8);
}
utils.JSByteIO.prototype.readUInt24 = function() {
	return noneko.IOTools.readUInt24(this);
}
utils.JSByteIO.prototype.readUInt24B = function() {
	return noneko.IOTools.readUInt24B(this);
}
utils.JSByteIO.prototype.readUInt32 = function() {
	var ch1 = this.readChar();
	var ch2 = this.readChar();
	var ch3 = this.readChar();
	var ch4 = this.readChar();
	if(ch4 >= 64) throw noneko.Error.Overflow;
	return ((ch1 | (ch2 << 8)) | (ch3 << 16)) | (ch4 << 24);
}
utils.JSByteIO.prototype.readUInt32B = function() {
	var ch1 = this.readChar();
	var ch2 = this.readChar();
	var ch3 = this.readChar();
	var ch4 = this.readChar();
	if(ch1 >= 64) throw noneko.Error.Overflow;
	return ((ch4 | (ch3 << 8)) | (ch2 << 16)) | (ch1 << 24);
}
utils.JSByteIO.prototype.readUntil = function(end) {
	return noneko.IOTools.readUntil(this,end);
}
utils.JSByteIO.prototype.seek = function(p,pos) {
	var $e = (pos);
	switch( $e[1] ) {
	case 0:
	{
		this.pos = this.bytes.length - p;
	}break;
	case 1:
	{
		this.pos += p;
	}break;
	case 2:
	{
		this.pos = p;
	}break;
	}
}
utils.JSByteIO.prototype.tell = function() {
	return this.pos;
}
utils.JSByteIO.prototype.write = function(s) {
	var i = 0;
	{
		var _g1 = 0, _g = s.length;
		while(_g1 < _g) {
			var i1 = _g1++;
			this.writeChar(s.charCodeAt(i1));
		}
	}
}
utils.JSByteIO.prototype.writeBytes = function(s,p,len) {
	var opos = this.pos;
	try {
		this.write(s.substr(p,len));
	}
	catch( $e1 ) {
		{
			var e = $e1;
			{
				return 0;
			}
		}
	}
	return this.pos - opos;
}
utils.JSByteIO.prototype.writeChar = function(c) {
	if(this.pos + 1 > this.bytes.length) throw new noneko.Eof();
	c = (c & 255);
	this.bytes[this.pos] = c;
	this.pos += 1;
}
utils.JSByteIO.prototype.writeDouble = function(c) {
	null;
}
utils.JSByteIO.prototype.writeDoubleB = function(c) {
	null;
}
utils.JSByteIO.prototype.writeFloat = function(c) {
	null;
}
utils.JSByteIO.prototype.writeFloatB = function(c) {
	null;
}
utils.JSByteIO.prototype.writeFullBytes = function(s,pos,len) {
	this.writeBytes(s,pos,len);
}
utils.JSByteIO.prototype.writeInput = function(i,bufsize) {
	try {
		while(this.pos != this.bytes.length) this.writeChar(i.readChar());
	}
	catch( $e2 ) {
		{
			var e = $e2;
			{
				return;
			}
		}
	}
}
utils.JSByteIO.prototype.writeInt16 = function(x) {
	if(x < -32768 || x > 32767) throw noneko.Error.Overflow;
	if(x < 0) this.writeUInt16(65536 + x);
	else this.writeUInt16(x);
}
utils.JSByteIO.prototype.writeInt24 = function(x) {
	{
		if(x < 0 || x > 16777215) throw noneko.Error.Overflow;
		this.writeChar(x & 255);
		this.writeChar((x >> 8) & 255);
		this.writeChar(x >> 16);
	}
}
utils.JSByteIO.prototype.writeInt32 = function(x) {
	if(x < 0) throw noneko.Error.Overflow;
	this.writeChar(x & 255);
	this.writeChar((x >> 8) & 255);
	this.writeChar((x >> 16) & 255);
	this.writeChar(x >>> 24);
}
utils.JSByteIO.prototype.writeInt8 = function(c) {
	if(c < -128 || c > 127) throw noneko.Error.Overflow;
	this.writeChar(c & 255);
}
utils.JSByteIO.prototype.writeUInt16 = function(x) {
	if(x < 0 || x > 65535) throw noneko.Error.Overflow;
	this.writeChar(x & 255);
	this.writeChar(x >> 8);
}
utils.JSByteIO.prototype.writeUInt16B = function(x) {
	if(x < 0 || x > 65535) throw noneko.Error.Overflow;
	this.writeChar(x >> 8);
	this.writeChar(x & 255);
}
utils.JSByteIO.prototype.writeUInt24 = function(x) {
	return function($this) {
		var $r;
		if(x < -8388608 || x > 8388607) throw noneko.Error.Overflow;
		$r = (x < 0?$this.writeUInt24(16777216 + x):$this.writeUInt24(x));
		return $r;
	}(this);
}
utils.JSByteIO.prototype.writeUInt24B = function(x) {
	return function($this) {
		var $r;
		if(x < 0 || x > 16777215) throw noneko.Error.Overflow;
		$this.writeChar(x >> 16);
		$this.writeChar((x >> 8) & 255);
		$r = $this.writeChar(x & 255);
		return $r;
	}(this);
}
utils.JSByteIO.prototype.writeUInt32 = function(x) {
	if(x < 0) throw noneko.Error.Overflow;
	this.writeInt32(x);
}
utils.JSByteIO.prototype.writeUInt32B = function(x) {
	if(x < 0) throw noneko.Error.Overflow;
	this.writeChar(x >>> 24);
	this.writeChar((x >> 16) & 255);
	this.writeChar((x >> 8) & 255);
	this.writeChar(x & 255);
}
utils.JSByteIO.prototype.__class__ = utils.JSByteIO;
utils.JSByteIO.__interfaces__ = [utils.Seekable,noneko.Output,noneko.Input];
noneko.IOTools = function() { }
noneko.IOTools.__name__ = ["noneko","IOTools"];
noneko.IOTools.readFullBytes = function(io_in,s,pos,len) {
	while(len > 0) {
		var k = io_in.readBytes(s,pos,len);
		pos += k;
		len -= k;
	}
}
noneko.IOTools.readInt24 = function(io_in) {
	var ch1 = io_in.readChar();
	var ch2 = io_in.readChar();
	var ch3 = io_in.readChar();
	var n = (ch1 | (ch2 << 8)) | (ch3 << 16);
	if((ch3 & 128) != 0) return n - (1 << 24);
	else return n;
}
noneko.IOTools.readLine = function(io_in) {
	var buf = new StringBuf();
	var last;
	var s;
	try {
		while((last = io_in.readChar()) != 10) buf.addChar(last);
		s = buf.toString();
		if(s.charCodeAt(s.length - 1) == 13) s = s.substr(0,-1);
	}
	catch( $e3 ) {
		{
			var e = $e3;
			{
				s = buf.toString();
			}
		}
	}
	return s;
}
noneko.IOTools.readUInt24 = function(io_in) {
	var ch1 = io_in.readChar();
	var ch2 = io_in.readChar();
	var ch3 = io_in.readChar();
	return (ch1 | (ch2 << 8)) | (ch3 << 16);
}
noneko.IOTools.readUInt24B = function(io_in) {
	var ch1 = io_in.readChar();
	var ch2 = io_in.readChar();
	var ch3 = io_in.readChar();
	return (ch3 | (ch2 << 8)) | (ch1 << 16);
}
noneko.IOTools.readUntil = function(io_in,end) {
	var buf = new StringBuf();
	var last;
	while((last = io_in.readChar()) != end) buf.addChar(last);
	return buf.toString();
}
noneko.IOTools.write = function(io_out,s) {
	var l = s.length;
	var p = 0;
	while(l > 0) {
		var k = 0;
		if(k == 0) throw noneko.Error.Blocked;
		p += k;
		l -= k;
	}
}
noneko.IOTools.writeFullBytes = function(io_out,s,pos,len) {
	while(len > 0) {
		var k = 0;
		pos += k;
		len -= k;
	}
}
noneko.IOTools.writeInt24 = function(io_out,x) {
	if(x < 0 || x > 16777215) throw noneko.Error.Overflow;
	io_out.writeChar(x & 255);
	io_out.writeChar((x >> 8) & 255);
	io_out.writeChar(x >> 16);
}
noneko.IOTools.writeUInt24 = function(io_out,x) {
	if(x < -8388608 || x > 8388607) throw noneko.Error.Overflow;
	if(x < 0) io_out.writeUInt24(16777216 + x);
	else io_out.writeUInt24(x);
}
noneko.IOTools.writeUInt24B = function(io_out,x) {
	if(x < 0 || x > 16777215) throw noneko.Error.Overflow;
	io_out.writeChar(x >> 16);
	io_out.writeChar((x >> 8) & 255);
	io_out.writeChar(x & 255);
}
noneko.IOTools.prototype.__class__ = noneko.IOTools;
hiscumm.SPUTMImage = function(width,height,num_zplanes) { if( width === $_ ) return; {
	this.zplanes = new Array();
	if(num_zplanes > 0) this.zplanes[num_zplanes - 1] = null;
	this.data = new justjs.BitmapData(width,height,false,0);
}}
hiscumm.SPUTMImage.__name__ = ["hiscumm","SPUTMImage"];
hiscumm.SPUTMImage.dtrace = function(msg) {
	null;
}
hiscumm.SPUTMImage.readBit = function(bit,cl,bits) {
	cl--;
	bit = (bits & 1);
	bits >>= 1;
	hiscumm.SPUTMImage.dtrace("READ_BIT cl=" + cl + ", bit=" + bit + ", bits=" + bits);
}
hiscumm.SPUTMImage.fillBits = function(cl,bits,smap) {
	if(cl < 8) {
		bits |= (smap.readChar()) << cl;
		cl += 8;
		hiscumm.SPUTMImage.dtrace("FILL_BITS cl=" + cl + ", bits=" + bits);
	}
}
hiscumm.SPUTMImage.unkDecodeA = function(pixels,stride,smap,height,pal_mod,decomp_mask,decomp_shr) {
	var color = smap.readChar();
	var bits = 0;
	bits = smap.readChar();
	var cl = 8;
	var bit = 0;
	var incm;
	var reps;
	while(true) {
		var x = 8;
		while(true) {
			if(cl < 8) {
				bits |= (smap.readChar()) << cl;
				cl += 8;
				hiscumm.SPUTMImage.dtrace("FILL_BITS cl=" + cl + ", bits=" + bits);
			}
			pixels.writeUInt32(color + pal_mod);
			hiscumm.SPUTMImage.pixels_written++;
			while(true) {
				{
					cl--;
					bit = (bits & 1);
					bits >>= 1;
					hiscumm.SPUTMImage.dtrace("READ_BIT cl=" + cl + ", bit=" + bit + ", bits=" + bits);
				}
				if(bit > 0) {
					{
						cl--;
						bit = (bits & 1);
						bits >>= 1;
						hiscumm.SPUTMImage.dtrace("READ_BIT cl=" + cl + ", bit=" + bit + ", bits=" + bits);
					}
					if(bit == 0) {
						if(cl < 8) {
							bits |= (smap.readChar()) << cl;
							cl += 8;
							hiscumm.SPUTMImage.dtrace("FILL_BITS cl=" + cl + ", bits=" + bits);
						}
						color = (bits & decomp_mask);
						bits >>= decomp_shr;
						cl -= decomp_shr;
					}
					else {
						incm = (bits & 7) - 4;
						cl -= 3;
						bits >>= 3;
						if(incm != 0) {
							color += incm;
							hiscumm.SPUTMImage.dtrace("incm " + incm);
						}
						else {
							if(cl < 8) {
								bits |= (smap.readChar()) << cl;
								cl += 8;
								hiscumm.SPUTMImage.dtrace("FILL_BITS cl=" + cl + ", bits=" + bits);
							}
							reps = (bits & 255);
							while(true) {
								x--;
								if(x == 0) {
									x = 8;
									pixels.seek(stride - (8 * 4),utils.Seek.SeekCur);
									height--;
									if(height == 0) {
										hiscumm.SPUTMImage.dtrace("HEIGHT EXIT " + height);
										return;
									}
								}
								pixels.writeUInt32(color + pal_mod);
								hiscumm.SPUTMImage.pixels_written++;
								reps--;
								if(hiscumm.SPUTMImage.dtrace_on && reps == 0) break;
								if(reps < 0) break;
							}
							bits >>= 8;
							bits |= (smap.readChar()) << (cl - 8);
							continue;
						}
					}
				}
				else null;
				break;
			}
			hiscumm.SPUTMImage.dtrace("END againPos");
			x--;
			if(x == 0) break;
		}
		pixels.seek(stride - (8 * 4),utils.Seek.SeekCur);
		height--;
		hiscumm.SPUTMImage.dtrace("NXT H " + height);
		if(height == 0) break;
	}
}
hiscumm.SPUTMImage.unkDecodeA_trans = function(pixels,stride,smap,height,pal_mod,transparentColor,decomp_mask,decomp_shr) {
	haxe.Log.trace("CRAP",{ fileName : "SPUTMImage.hx", lineNumber : 426, className : "hiscumm.SPUTMImage", methodName : "unkDecodeA_trans"});
}
hiscumm.SPUTMImage.unkDecodeB = function(pixels,stride,smap,height,pal_mod,decomp_mask,decomp_shr) {
	var color = smap.readChar();
	var bits = 0;
	bits = smap.readChar();
	var cl = 8;
	var bit = 100;
	var inc = -1;
	while(true) {
		var x = 8;
		while(true) {
			if(cl < 8) {
				bits |= (smap.readChar()) << cl;
				cl += 8;
				hiscumm.SPUTMImage.dtrace("FILL_BITS cl=" + cl + ", bits=" + bits);
			}
			pixels.writeUInt32(color + pal_mod);
			{
				cl--;
				bit = (bits & 1);
				bits >>= 1;
				hiscumm.SPUTMImage.dtrace("READ_BIT cl=" + cl + ", bit=" + bit + ", bits=" + bits);
			}
			if(bit > 0) {
				{
					cl--;
					bit = (bits & 1);
					bits >>= 1;
					hiscumm.SPUTMImage.dtrace("READ_BIT cl=" + cl + ", bit=" + bit + ", bits=" + bits);
				}
				if(bit == 0) {
					if(cl < 8) {
						bits |= (smap.readChar()) << cl;
						cl += 8;
						hiscumm.SPUTMImage.dtrace("FILL_BITS cl=" + cl + ", bits=" + bits);
					}
					color = (bits & decomp_mask);
					bits >>= decomp_shr;
					cl -= decomp_shr;
					inc = -1;
				}
				else {
					{
						cl--;
						bit = (bits & 1);
						bits >>= 1;
						hiscumm.SPUTMImage.dtrace("READ_BIT cl=" + cl + ", bit=" + bit + ", bits=" + bits);
					}
					if(bit == 0) {
						color += inc;
					}
					else {
						inc = -inc;
						color += inc;
					}
				}
			}
			if(--x == 0) break;
		}
		pixels.seek(stride - (8 * 4),utils.Seek.SeekCur);
		if(--height == 0) break;
	}
}
hiscumm.SPUTMImage.unkDecodeB_trans = function(pixels,stride,smap,height,pal_mod,transparentColor,decomp_mask,decomp_shr) {
	haxe.Log.trace("CRAP 3",{ fileName : "SPUTMImage.hx", lineNumber : 488, className : "hiscumm.SPUTMImage", methodName : "unkDecodeB_trans"});
}
hiscumm.SPUTMImage.unkDecodeC = function(pixels,stride,smap,height,pal_mod,decomp_mask,decomp_shr) {
	var color = smap.readChar();
	var bits = 0;
	bits = smap.readChar();
	var cl = 8;
	var bit = 100;
	var inc = -1;
	var x = 8;
	while(true) {
		var h = height;
		while(true) {
			if(cl < 8) {
				bits |= (smap.readChar()) << cl;
				cl += 8;
				hiscumm.SPUTMImage.dtrace("FILL_BITS cl=" + cl + ", bits=" + bits);
			}
			pixels.writeUInt32(color + pal_mod);
			pixels.seek(stride - 4,utils.Seek.SeekCur);
			h--;
			{
				cl--;
				bit = (bits & 1);
				bits >>= 1;
				hiscumm.SPUTMImage.dtrace("READ_BIT cl=" + cl + ", bit=" + bit + ", bits=" + bits);
			}
			if(bit > 0) {
				{
					cl--;
					bit = (bits & 1);
					bits >>= 1;
					hiscumm.SPUTMImage.dtrace("READ_BIT cl=" + cl + ", bit=" + bit + ", bits=" + bits);
				}
				if(bit == 0) {
					if(cl < 8) {
						bits |= (smap.readChar()) << cl;
						cl += 8;
						hiscumm.SPUTMImage.dtrace("FILL_BITS cl=" + cl + ", bits=" + bits);
					}
					color = (bits & decomp_mask);
					bits >>= decomp_shr;
					cl -= decomp_shr;
					inc = -1;
					if(h == 0) break;
					else continue;
				}
				{
					cl--;
					bit = (bits & 1);
					bits >>= 1;
					hiscumm.SPUTMImage.dtrace("READ_BIT cl=" + cl + ", bit=" + bit + ", bits=" + bits);
				}
				if(bit == 0) {
					color += inc;
					if(h == 0) break;
					else continue;
				}
			}
			else {
				if(h == 0) break;
				else continue;
			}
			inc = -inc;
			color += inc;
			if(h == 0) break;
		}
		pixels.seek(-((height * stride) - 4),utils.Seek.SeekCur);
		x--;
		if(x == 0) break;
	}
}
hiscumm.SPUTMImage.unkDecodeC_trans = function(pixels,stride,smap,height,pal_mod,transparentColor,decomp_mask,decomp_shr) {
	haxe.Log.trace("CRAP 5",{ fileName : "SPUTMImage.hx", lineNumber : 569, className : "hiscumm.SPUTMImage", methodName : "unkDecodeC_trans"});
}
hiscumm.SPUTMImage.prototype.data = null;
hiscumm.SPUTMImage.prototype.decode = function(stride,width,height,smap,transparentColor) {
	var i;
	var offs = (width >> 3);
	var type;
	var decomp_shr;
	var decomp_mask;
	var stripe_size;
	if(height == 144) hiscumm.SPUTMImage.dtrace_on = true;
	var offsets = new Array();
	offsets[offs - 1] = 0;
	var pixels = new utils.JSByteIO();
	pixels.prepare(width * height * 4);
	{
		var _g = 0;
		while(_g < offs) {
			var i1 = _g++;
			offsets[i1] = smap.readUInt32();
		}
	}
	{
		var _g = 0;
		while(_g < offs) {
			var i1 = _g++;
			var o = offsets[i1] - 8;
			if(i1 + 1 < offs) stripe_size = offsets[i1 + 1] - offsets[i1];
			else stripe_size = utils.SeekableTools.getSeekableLength(smap) - o;
			hiscumm.SPUTMImage.dtrace(stripe_size + "=size, " + o + "=pos, " + offs + "=dest");
			stripe_size--;
			smap.seek(o,utils.Seek.SeekBegin);
			type = smap.readChar();
			hiscumm.SPUTMImage.dtrace("type=" + type + " @ " + o);
			decomp_shr = type % 10;
			decomp_mask = 255 >> (8 - decomp_shr);
			hiscumm.SPUTMImage.dtrace("decomp shr " + decomp_shr + " " + decomp_mask);
			if(type == 104 && o == 6555) hiscumm.SPUTMImage.dtrace_override = false;
			else hiscumm.SPUTMImage.dtrace_override = true;
			if(type > 13 && type < 19) {
				pixels.seek(i1 * 8 * 4,utils.Seek.SeekBegin);
				hiscumm.SPUTMImage.unkDecodeC(pixels,stride * 4,smap,height,0,decomp_mask,decomp_shr);
			}
			else if(type > 23 && type < 29) {
				pixels.seek(i1 * 8 * 4,utils.Seek.SeekBegin);
				hiscumm.SPUTMImage.unkDecodeB(pixels,stride * 4,smap,height,0,decomp_mask,decomp_shr);
			}
			else if(type > 33 && type < 39) {
				pixels.seek(i1 * 8 * 4,utils.Seek.SeekBegin);
				if(transparentColor < 0) hiscumm.SPUTMImage.unkDecodeC(pixels,stride * 4,smap,height,0,decomp_mask,decomp_shr);
				else hiscumm.SPUTMImage.unkDecodeC_trans(pixels,stride * 4,smap,height,0,transparentColor,decomp_mask,decomp_shr);
			}
			else if(type > 43 && type < 49) {
				pixels.seek(i1 * 8 * 4,utils.Seek.SeekBegin);
				if(transparentColor < 0) hiscumm.SPUTMImage.unkDecodeB(pixels,stride * 4,smap,height,0,decomp_mask,decomp_shr);
				else hiscumm.SPUTMImage.unkDecodeB_trans(pixels,stride * 4,smap,height,0,transparentColor,decomp_mask,decomp_shr);
			}
			else if(type > 64 && type < 69) {
				pixels.seek(i1 * 8 * 4,utils.Seek.SeekBegin);
				hiscumm.SPUTMImage.unkDecodeA(pixels,stride * 4,smap,height,0,decomp_mask,decomp_shr);
			}
			else if(type > 103 && type < 109) {
				pixels.seek(i1 * 8 * 4,utils.Seek.SeekBegin);
				hiscumm.SPUTMImage.unkDecodeA(pixels,stride * 4,smap,height,0,decomp_mask,decomp_shr);
			}
			else if(type > 83 && type < 129) {
				pixels.seek(i1 * 8 * 4,utils.Seek.SeekBegin);
				if(transparentColor < 0) hiscumm.SPUTMImage.unkDecodeA(pixels,stride * 4,smap,height,0,decomp_mask,decomp_shr);
				else hiscumm.SPUTMImage.unkDecodeA_trans(pixels,stride * 4,smap,height,0,transparentColor,decomp_mask,decomp_shr);
			}
			else {
				hiscumm.SPUTMImage.dtrace("Unknown codec type " + type);
				return false;
			}
		}
	}
	hiscumm.SPUTMImage.dtrace("setting pixels " + width + "x" + height + "(" + utils.SeekableTools.getSeekableLength(pixels) + ")");
	this.data.lock();
	var end = utils.SeekableTools.getSeekableLength(pixels);
	var nonblanks = 0;
	pixels.seek(0,utils.Seek.SeekBegin);
	while(end != 0) {
		if(pixels.readChar() != 0) nonblanks++;
		end--;
	}
	pixels.seek(0,utils.Seek.SeekBegin);
	this.data.setPixels(new noflash.Rectangle(0,0,width,height),pixels);
	this.data.unlock();
	hiscumm.SPUTMImage.dtrace_on = false;
	return true;
}
hiscumm.SPUTMImage.prototype.decodeZPlane = function(idx,stride,width,height,zplane,transparentColor) {
	return true;
}
hiscumm.SPUTMImage.prototype.load = function(reader) {
	var i;
	var chunkID = noneko.Int32.read(reader,true);
	var chunkSize = noneko.Int32.read(reader,true).value;
	if(hiscumm.SPUTMResourceChunk.identify(chunkID) != hiscumm.SPUTMResourceChunkType.CHUNK_SMAP) {
		haxe.Log.trace("Bad image type " + (String.fromCharCode(new noneko.Int32(chunkID.value >> 24).value) + String.fromCharCode(new noneko.Int32(new noneko.Int32(chunkID.value >> 16).value & new noneko.Int32(255).value).value) + String.fromCharCode(new noneko.Int32(new noneko.Int32(chunkID.value >> 8).value & new noneko.Int32(255).value).value) + String.fromCharCode(new noneko.Int32(chunkID.value & new noneko.Int32(255).value).value)),{ fileName : "SPUTMImage.hx", lineNumber : 117, className : "hiscumm.SPUTMImage", methodName : "load"});
		return false;
	}
	else {
		haxe.Log.trace("smap size == " + (chunkSize - 8),{ fileName : "SPUTMImage.hx", lineNumber : 122, className : "hiscumm.SPUTMImage", methodName : "load"});
		var smap = new utils.JSByteIO();
		smap.prepare(chunkSize - 7);
		smap.writeInput(reader);
		smap.seek(0,utils.Seek.SeekBegin);
		reader.seek(-1,utils.Seek.SeekCur);
		hiscumm.SPUTMImage.pixels_written = 0;
		if(!this.decode(this.data.width,this.data.width,this.data.height,smap,-1)) {
			haxe.Log.trace("Bad image data",{ fileName : "SPUTMImage.hx", lineNumber : 132, className : "hiscumm.SPUTMImage", methodName : "load"});
			return false;
		}
		if(this.data.width != 8) {
			haxe.Log.trace(hiscumm.SPUTMImage.pixels_written + " pixels written",{ fileName : "SPUTMImage.hx", lineNumber : 138, className : "hiscumm.SPUTMImage", methodName : "load"});
		}
		haxe.Log.trace("loaded smap",{ fileName : "SPUTMImage.hx", lineNumber : 142, className : "hiscumm.SPUTMImage", methodName : "load"});
	}
	{
		var _g1 = 0, _g = this.zplanes.length;
		while(_g1 < _g) {
			var i1 = _g1++;
			chunkID = noneko.Int32.read(reader,true);
			chunkSize = noneko.Int32.read(reader,true).value;
			haxe.Log.trace("zplane ChunkID == " + (String.fromCharCode(new noneko.Int32(chunkID.value >> 24).value) + String.fromCharCode(new noneko.Int32(new noneko.Int32(chunkID.value >> 16).value & new noneko.Int32(255).value).value) + String.fromCharCode(new noneko.Int32(new noneko.Int32(chunkID.value >> 8).value & new noneko.Int32(255).value).value) + String.fromCharCode(new noneko.Int32(chunkID.value & new noneko.Int32(255).value).value)),{ fileName : "SPUTMImage.hx", lineNumber : 150, className : "hiscumm.SPUTMImage", methodName : "load"});
			var zplane = new utils.JSByteIO();
			zplane.prepare(chunkSize - 8);
			zplane.writeInput(reader);
			zplane.seek(0,utils.Seek.SeekBegin);
			haxe.Log.trace("Dec",{ fileName : "SPUTMImage.hx", lineNumber : 157, className : "hiscumm.SPUTMImage", methodName : "load"});
			if(!this.decodeZPlane(i1,this.data.width >> 3,this.data.width,this.data.height,zplane,-1)) {
				haxe.Log.trace("Bad zplane data",{ fileName : "SPUTMImage.hx", lineNumber : 161, className : "hiscumm.SPUTMImage", methodName : "load"});
				return false;
			}
		}
	}
	return true;
}
hiscumm.SPUTMImage.prototype.nuke = function() {
	var i;
	{
		var _g1 = 0, _g = this.zplanes.length;
		while(_g1 < _g) {
			var i1 = _g1++;
			this.zplanes[i1].dispose();
			this.zplanes[i1] = null;
		}
	}
	this.zplanes = null;
	this.data.dispose();
}
hiscumm.SPUTMImage.prototype.zplanes = null;
hiscumm.SPUTMImage.prototype.__class__ = hiscumm.SPUTMImage;
haxe = {}
haxe.Log = function() { }
haxe.Log.__name__ = ["haxe","Log"];
haxe.Log.trace = function(v,infos) {
	js.Boot.__trace(v,infos);
}
haxe.Log.clear = function() {
	js.Boot.__clear_trace();
}
haxe.Log.prototype.__class__ = haxe.Log;
noneko.Error = { __ename__ : ["noneko","Error"], __constructs__ : ["Blocked","Closed","Overflow","Custom"] }
noneko.Error.Blocked = ["Blocked",0];
noneko.Error.Blocked.toString = $estr;
noneko.Error.Blocked.__enum__ = noneko.Error;
noneko.Error.Closed = ["Closed",1];
noneko.Error.Closed.toString = $estr;
noneko.Error.Closed.__enum__ = noneko.Error;
noneko.Error.Custom = function(e) { var $x = ["Custom",3,e]; $x.__enum__ = noneko.Error; $x.toString = $estr; return $x; }
noneko.Error.Overflow = ["Overflow",2];
noneko.Error.Overflow.toString = $estr;
noneko.Error.Overflow.__enum__ = noneko.Error;
utils.Seek = { __ename__ : ["utils","Seek"], __constructs__ : ["SeekEnd","SeekCur","SeekBegin"] }
utils.Seek.SeekBegin = ["SeekBegin",2];
utils.Seek.SeekBegin.toString = $estr;
utils.Seek.SeekBegin.__enum__ = utils.Seek;
utils.Seek.SeekCur = ["SeekCur",1];
utils.Seek.SeekCur.toString = $estr;
utils.Seek.SeekCur.__enum__ = utils.Seek;
utils.Seek.SeekEnd = ["SeekEnd",0];
utils.Seek.SeekEnd.toString = $estr;
utils.Seek.SeekEnd.__enum__ = utils.Seek;
StringBuf = function(p) { if( p === $_ ) return; {
	this.b = "";
}}
StringBuf.__name__ = ["StringBuf"];
StringBuf.prototype.add = function(x) {
	this.b += x;
}
StringBuf.prototype.addChar = function(c) {
	this.b += String.fromCharCode(c);
}
StringBuf.prototype.addSub = function(s,pos,len) {
	this.b += s.substr(pos,len);
}
StringBuf.prototype.b = null;
StringBuf.prototype.toString = function() {
	return this.b;
}
StringBuf.prototype.__class__ = StringBuf;
hiscumm.SPUTMCostume = function(num) { if( num === $_ ) return; {
	this.id = num;
}}
hiscumm.SPUTMCostume.__name__ = ["hiscumm","SPUTMCostume"];
hiscumm.SPUTMCostume.prototype.id = null;
hiscumm.SPUTMCostume.prototype.nuke = function() {
	null;
}
hiscumm.SPUTMCostume.prototype.__class__ = hiscumm.SPUTMCostume;
hiscumm.SPUTMResourceFactory = function(p) { if( p === $_ ) return; {
	this.name = "UNKNOWN";
}}
hiscumm.SPUTMResourceFactory.__name__ = ["hiscumm","SPUTMResourceFactory"];
hiscumm.SPUTMResourceFactory.prototype.load = function(num,reader) {
	return null;
}
hiscumm.SPUTMResourceFactory.prototype.name = null;
hiscumm.SPUTMResourceFactory.prototype.__class__ = hiscumm.SPUTMResourceFactory;
hiscumm.SPUTMCostumeFactory = function(p) { if( p === $_ ) return; {
	hiscumm.SPUTMResourceFactory.apply(this,[]);
	this.name = "COSTUME";
}}
hiscumm.SPUTMCostumeFactory.__name__ = ["hiscumm","SPUTMCostumeFactory"];
hiscumm.SPUTMCostumeFactory.__super__ = hiscumm.SPUTMResourceFactory;
for(var k in hiscumm.SPUTMResourceFactory.prototype ) hiscumm.SPUTMCostumeFactory.prototype[k] = hiscumm.SPUTMResourceFactory.prototype[k];
hiscumm.SPUTMCostumeFactory.prototype.load = function(idx,reader) {
	var chunkID = noneko.Int32.read(reader,true);
	var chunkSize = noneko.Int32.read(reader,true).value;
	if(hiscumm.SPUTMResourceChunk.identify(chunkID) != hiscumm.SPUTMResourceChunkType.CHUNK_COST) {
		haxe.Log.trace("Bad costume block (" + (String.fromCharCode(new noneko.Int32(chunkID.value >> 24).value) + String.fromCharCode(new noneko.Int32(new noneko.Int32(chunkID.value >> 16).value & new noneko.Int32(255).value).value) + String.fromCharCode(new noneko.Int32(new noneko.Int32(chunkID.value >> 8).value & new noneko.Int32(255).value).value) + String.fromCharCode(new noneko.Int32(chunkID.value & new noneko.Int32(255).value).value)) + " )",{ fileName : "SPUTMCostume.hx", lineNumber : 66, className : "hiscumm.SPUTMCostumeFactory", methodName : "load"});
		return null;
	}
	var instance = new hiscumm.SPUTMCostume(idx);
	return instance;
}
hiscumm.SPUTMCostumeFactory.prototype.__class__ = hiscumm.SPUTMCostumeFactory;
noflash = {}
noflash.Rectangle = function(x,y,w,h) { if( x === $_ ) return; {
	this.x = x;
	this.y = y;
	this.width = w;
	this.height = h;
}}
noflash.Rectangle.__name__ = ["noflash","Rectangle"];
noflash.Rectangle.prototype.clone = function() {
	return new noflash.Rectangle(this.x,this.y,this.width,this.height);
}
noflash.Rectangle.prototype.height = null;
noflash.Rectangle.prototype.intersection = function(other) {
	var dx = this.x;
	var dy = this.y;
	var dw = this.width;
	var dh = this.height;
	if(dx < other.x) {
		this.width -= (other.x - dx);
		dx = other.x;
	}
	if(dy < other.y) {
		this.height -= (other.y - dy);
		dy = other.y;
	}
	if(dx >= other.x + other.width) {
		this.width -= (other.x + other.width - dx);
		dx = other.x + other.width;
	}
	if(dy > other.y + other.height) {
		this.height -= (other.y + other.height - dy);
		dy = other.y + other.height;
	}
	if(dx + dw > other.x + other.width) {
		this.width = (other.x + other.width) - dx;
	}
	if(dx + dh > other.x + other.height) {
		this.height = (other.y + other.height) - dy;
	}
	return new noflash.Rectangle(dx,dy,dw,dh);
}
noflash.Rectangle.prototype.width = null;
noflash.Rectangle.prototype.x = null;
noflash.Rectangle.prototype.y = null;
noflash.Rectangle.prototype.__class__ = noflash.Rectangle;
hiscumm.SPUTMRoom = function(num) { if( num === $_ ) return; {
	this.id = num;
	this.scripts = new Array();
	this.objects = new Array();
	this.palettes = new Array();
	this.image = null;
	this.entry = null;
	this.exit = null;
	this.current_palette = null;
}}
hiscumm.SPUTMRoom.__name__ = ["hiscumm","SPUTMRoom"];
hiscumm.SPUTMRoom.prototype.current_palette = null;
hiscumm.SPUTMRoom.prototype.entry = null;
hiscumm.SPUTMRoom.prototype.exit = null;
hiscumm.SPUTMRoom.prototype.height = null;
hiscumm.SPUTMRoom.prototype.id = null;
hiscumm.SPUTMRoom.prototype.image = null;
hiscumm.SPUTMRoom.prototype.nuke = function() {
	if(this.image != null) this.image.nuke();
	this.image = null;
}
hiscumm.SPUTMRoom.prototype.num_zplane = null;
hiscumm.SPUTMRoom.prototype.objects = null;
hiscumm.SPUTMRoom.prototype.palettes = null;
hiscumm.SPUTMRoom.prototype.scripts = null;
hiscumm.SPUTMRoom.prototype.width = null;
hiscumm.SPUTMRoom.prototype.__class__ = hiscumm.SPUTMRoom;
hiscumm.SPUTMRoomFactory = function(p) { if( p === $_ ) return; {
	hiscumm.SPUTMResourceFactory.apply(this,[]);
	this.name = "ROOM";
}}
hiscumm.SPUTMRoomFactory.__name__ = ["hiscumm","SPUTMRoomFactory"];
hiscumm.SPUTMRoomFactory.__super__ = hiscumm.SPUTMResourceFactory;
for(var k in hiscumm.SPUTMResourceFactory.prototype ) hiscumm.SPUTMRoomFactory.prototype[k] = hiscumm.SPUTMResourceFactory.prototype[k];
hiscumm.SPUTMRoomFactory.prototype.load = function(idx,reader) {
	var chunkID = noneko.Int32.read(reader,true);
	var chunkSize = noneko.Int32.read(reader,true).value;
	if(hiscumm.SPUTMResourceChunk.identify(chunkID) != hiscumm.SPUTMResourceChunkType.CHUNK_ROOM) {
		haxe.Log.trace("Bad room block (" + (String.fromCharCode(new noneko.Int32(chunkID.value >> 24).value) + String.fromCharCode(new noneko.Int32(new noneko.Int32(chunkID.value >> 16).value & new noneko.Int32(255).value).value) + String.fromCharCode(new noneko.Int32(new noneko.Int32(chunkID.value >> 8).value & new noneko.Int32(255).value).value) + String.fromCharCode(new noneko.Int32(chunkID.value & new noneko.Int32(255).value).value)) + ")",{ fileName : "SPUTMRoom.hx", lineNumber : 100, className : "hiscumm.SPUTMRoomFactory", methodName : "load"});
		return null;
	}
	var room = new hiscumm.SPUTMRoom(idx);
	var croom = new hiscumm.ChunkReader(reader);
	var num;
	var num_lscr = 0;
	var i;
	var base_ptr;
	var num_pal;
	while(croom.nextChunk()) {
		var $e = (hiscumm.SPUTMResourceChunk.identify(croom.chunkID));
		switch( $e[1] ) {
		case 15:
		{
			room.width = reader.readUInt16();
			room.height = reader.readUInt16();
			num = reader.readUInt16();
			if(num > 0) room.objects[num - 1] = null;
		}break;
		case 16:
		{
			null;
		}break;
		case 17:
		{
			null;
		}break;
		case 18:
		{
			chunkID = noneko.Int32.read(reader,true);
			chunkSize = noneko.Int32.read(reader,true).value;
			if(hiscumm.SPUTMResourceChunk.identify(chunkID) != hiscumm.SPUTMResourceChunkType.CHUNK_WRAP) {
				haxe.Log.trace("Bad room WRAP block " + chunkID,{ fileName : "SPUTMRoom.hx", lineNumber : 135, className : "hiscumm.SPUTMRoomFactory", methodName : "load"});
				return null;
			}
			chunkID = noneko.Int32.read(reader,true);
			chunkSize = noneko.Int32.read(reader,true).value;
			if(hiscumm.SPUTMResourceChunk.identify(chunkID) != hiscumm.SPUTMResourceChunkType.CHUNK_OFFS) {
				haxe.Log.trace("Bad room OFFS block " + chunkID,{ fileName : "SPUTMRoom.hx", lineNumber : 144, className : "hiscumm.SPUTMRoomFactory", methodName : "load"});
				return null;
			}
			base_ptr = reader.tell() - 8;
			num_pal = Math.round((chunkSize - 8) / 4);
			var offset = new Array();
			if(num_pal > 0) {
				offset[num_pal - 1] = 0;
				{
					var _g = 0;
					while(_g < num_pal) {
						var i1 = _g++;
						offset[i1] = base_ptr + reader.readUInt32();
					}
				}
				room.palettes[num_pal - 1] = null;
				{
					var _g = 0;
					while(_g < num_pal) {
						var i1 = _g++;
						reader.seek(offset[i1],utils.Seek.SeekBegin);
						chunkID = noneko.Int32.read(reader,true);
						chunkSize = noneko.Int32.read(reader,true).value;
						if(hiscumm.SPUTMResourceChunk.identify(chunkID) != hiscumm.SPUTMResourceChunkType.CHUNK_APAL) {
							haxe.Log.trace("Bad room APAL block " + chunkID,{ fileName : "SPUTMRoom.hx", lineNumber : 171, className : "hiscumm.SPUTMRoomFactory", methodName : "load"});
							return null;
						}
						room.palettes[i1] = new hiscumm.SPUTMPalette(reader);
					}
				}
			}
		}break;
		case 19:
		{
			haxe.Log.trace("RMIM == " + croom.chunkName(),{ fileName : "SPUTMRoom.hx", lineNumber : 180, className : "hiscumm.SPUTMRoomFactory", methodName : "load"});
			chunkID = noneko.Int32.read(reader,true);
			chunkSize = noneko.Int32.read(reader,true).value;
			room.num_zplane = reader.readUInt16();
			chunkID = noneko.Int32.read(reader,true);
			chunkSize = noneko.Int32.read(reader,true).value;
			if(hiscumm.SPUTMResourceChunk.identify(chunkID) != hiscumm.SPUTMResourceChunkType.CHUNK_IM00) {
				haxe.Log.trace("Bad room image block " + chunkID,{ fileName : "SPUTMRoom.hx", lineNumber : 192, className : "hiscumm.SPUTMRoomFactory", methodName : "load"});
				return null;
			}
			room.image = new hiscumm.SPUTMImage(room.width,room.height,room.num_zplane);
			if(!(room.image.load(reader))) {
				haxe.Log.trace("Problem loading room image!",{ fileName : "SPUTMRoom.hx", lineNumber : 199, className : "hiscumm.SPUTMRoomFactory", methodName : "load"});
				room.image = null;
				return null;
			}
			haxe.Log.trace("Room image appears to have loaded!",{ fileName : "SPUTMRoom.hx", lineNumber : 204, className : "hiscumm.SPUTMRoomFactory", methodName : "load"});
		}break;
		case 20:
		{
			null;
		}break;
		case 21:
		{
			null;
		}break;
		case 22:
		{
			var script = new hiscumm.SCUMMScript(516751360);
			script.code = new utils.JSByteIO();
			script.size = croom.chunkSize - 8;
			script.code.prepare(script.size);
			script.code.writeInput(reader);
			room.exit = script;
		}break;
		case 23:
		{
			var script = new hiscumm.SCUMMScript(248315904);
			script.code = new utils.JSByteIO();
			script.size = croom.chunkSize - 8;
			script.code.prepare(script.size);
			script.code.writeInput(reader);
			room.entry = script;
		}break;
		case 24:
		{
			num = reader.readUInt16();
			if(num > 0) room.scripts[num - 1] = null;
		}break;
		case 25:
		{
			if(num_lscr >= room.scripts.length) {
				haxe.Log.trace("Too many local scripts in room!",{ fileName : "SPUTMRoom.hx", lineNumber : 245, className : "hiscumm.SPUTMRoomFactory", methodName : "load"});
				return null;
			}
			i = reader.readChar();
			if(i < 200 || i - 200 >= room.scripts.length) {
				haxe.Log.trace("Invalid script id " + i,{ fileName : "SPUTMRoom.hx", lineNumber : 252, className : "hiscumm.SPUTMRoomFactory", methodName : "load"});
				return null;
			}
			var script = new hiscumm.SCUMMScript(i + 200);
			script.code = new utils.JSByteIO();
			script.size = croom.chunkSize - 9;
			script.code.prepare(script.size);
			haxe.Log.trace("Read local script " + i,{ fileName : "SPUTMRoom.hx", lineNumber : 261, className : "hiscumm.SPUTMRoomFactory", methodName : "load"});
			script.code.writeInput(reader);
			room.scripts[i] = script;
			num_lscr++;
		}break;
		case 26:
		{
			null;
		}break;
		case 27:
		{
			null;
		}break;
		case 28:
		{
			null;
		}break;
		default:{
			haxe.Log.trace("Room chunk " + croom.chunkName() + " (" + croom.chunkID + ")",{ fileName : "SPUTMRoom.hx", lineNumber : 274, className : "hiscumm.SPUTMRoomFactory", methodName : "load"});
		}break;
		}
	}
	return room;
}
hiscumm.SPUTMRoomFactory.prototype.__class__ = hiscumm.SPUTMRoomFactory;
hiscumm.SCUMM6 = function() { }
hiscumm.SCUMM6.__name__ = ["hiscumm","SCUMM6"];
hiscumm.SCUMM6.pushByte = function(engine,vm_stack,thread) {
	vm_stack.push(thread.readByte());
}
hiscumm.SCUMM6.pushWord = function(engine,vm_stack,thread) {
	vm_stack.push(thread.readShortSigned());
}
hiscumm.SCUMM6.readByte = function(engine,vm_stack,thread) {
	vm_stack.push(engine.readVar(thread.readByte(),thread));
}
hiscumm.SCUMM6.readWord = function(engine,vm_stack,thread) {
	vm_stack.push(engine.readVar(thread.readShort(),thread));
}
hiscumm.SCUMM6.readArrayByte = function(engine,vm_stack,thread) {
	var addr;
	var x;
	var vaddr;
	vaddr = thread.readByte();
	addr = engine.readVar(vaddr,thread);
	x = vm_stack.pop();
	vm_stack.push(engine.readArray(addr,0,x));
}
hiscumm.SCUMM6.readArrayWord = function(engine,vm_stack,thread) {
	var addr;
	var x;
	var vaddr;
	vaddr = thread.readShort();
	addr = engine.readVar(vaddr,thread);
	x = vm_stack.pop();
	vm_stack.push(engine.readArray(addr,0,x));
}
hiscumm.SCUMM6.readArray2Byte = function(engine,vm_stack,thread) {
	var addr;
	var x;
	var y;
	var vaddr;
	vaddr = thread.readByte();
	addr = engine.readVar(vaddr,thread);
	x = vm_stack.pop();
	y = vm_stack.pop();
	vm_stack.push(engine.readArray(addr,y,x));
}
hiscumm.SCUMM6.readArray2Word = function(engine,vm_stack,thread) {
	var addr;
	var x;
	var y;
	var vaddr;
	vaddr = thread.readShort();
	addr = engine.readVar(vaddr,thread);
	x = vm_stack.pop();
	y = vm_stack.pop();
	vm_stack.push(engine.readArray(addr,y,x));
}
hiscumm.SCUMM6.doDUP = function(engine,vm_stack,thread) {
	var a = vm_stack.pop();
	vm_stack.push(a);
	vm_stack.push(a);
}
hiscumm.SCUMM6.testNOT = function(engine,vm_stack,thread) {
	vm_stack.push((vm_stack.pop() == 0?1:0));
}
hiscumm.SCUMM6.testEQ = function(engine,vm_stack,thread) {
	var a = vm_stack.pop();
	vm_stack.push((vm_stack.pop() == a?1:0));
}
hiscumm.SCUMM6.testNEQ = function(engine,vm_stack,thread) {
	var a = vm_stack.pop();
	vm_stack.push((vm_stack.pop() != a?1:0));
}
hiscumm.SCUMM6.testGT = function(engine,vm_stack,thread) {
	var a = vm_stack.pop();
	vm_stack.push((vm_stack.pop() > a?1:0));
}
hiscumm.SCUMM6.testLT = function(engine,vm_stack,thread) {
	var a = vm_stack.pop();
	vm_stack.push((vm_stack.pop() < a?1:0));
}
hiscumm.SCUMM6.testLE = function(engine,vm_stack,thread) {
	var a = vm_stack.pop();
	vm_stack.push((vm_stack.pop() <= a?1:0));
}
hiscumm.SCUMM6.testGE = function(engine,vm_stack,thread) {
	var a = vm_stack.pop();
	vm_stack.push((vm_stack.pop() >= a?1:0));
}
hiscumm.SCUMM6.doADD = function(engine,vm_stack,thread) {
	var a = vm_stack.pop();
	vm_stack.push(vm_stack.pop() + a);
}
hiscumm.SCUMM6.doSUB = function(engine,vm_stack,thread) {
	var a = vm_stack.pop();
	vm_stack.push(vm_stack.pop() - a);
}
hiscumm.SCUMM6.doMUL = function(engine,vm_stack,thread) {
	var a = vm_stack.pop();
	vm_stack.push(vm_stack.pop() * a);
}
hiscumm.SCUMM6.doDIV = function(engine,vm_stack,thread) {
	var a = vm_stack.pop();
	vm_stack.push(Std["int"](vm_stack.pop() / a));
}
hiscumm.SCUMM6.testAND = function(engine,vm_stack,thread) {
	vm_stack.push(((vm_stack.pop() == 1 && vm_stack.pop() == 1)?1:0));
}
hiscumm.SCUMM6.testOR = function(engine,vm_stack,thread) {
	vm_stack.push(((vm_stack.pop() == 1 || vm_stack.pop() == 1)?1:0));
}
hiscumm.SCUMM6.pop = function(engine,vm_stack,thread) {
	vm_stack.pop();
}
hiscumm.SCUMM6.writeByte = function(engine,vm_stack,thread) {
	engine.writeVar(thread.readByte(),vm_stack.pop(),thread);
}
hiscumm.SCUMM6.writeWord = function(engine,vm_stack,thread) {
	engine.writeVar(thread.readShort(),vm_stack.pop(),thread);
}
hiscumm.SCUMM6.writeArrayByte = function(engine,vm_stack,thread) {
	var value;
	var x;
	var vaddr;
	vaddr = engine.readVar(thread.readByte(),thread);
	value = vm_stack.pop();
	x = vm_stack.pop();
	engine.writeArray(vaddr,0,x,value);
}
hiscumm.SCUMM6.writeArrayWord = function(engine,vm_stack,thread) {
	var value;
	var x;
	var vaddr;
	vaddr = engine.readVar(thread.readShort(),thread);
	value = vm_stack.pop();
	x = vm_stack.pop();
	engine.writeArray(vaddr,0,x,value);
}
hiscumm.SCUMM6.writeArray2Byte = function(engine,vm_stack,thread) {
	var value;
	var x;
	var y;
	var vaddr;
	vaddr = engine.readVar(thread.readByte(),thread);
	value = vm_stack.pop();
	x = vm_stack.pop();
	y = vm_stack.pop();
	engine.writeArray(vaddr,y,x,value);
}
hiscumm.SCUMM6.writeArray2Word = function(engine,vm_stack,thread) {
	var value;
	var x;
	var y;
	var vaddr;
	vaddr = engine.readVar(thread.readShort(),thread);
	value = vm_stack.pop();
	x = vm_stack.pop();
	y = vm_stack.pop();
	engine.writeArray(vaddr,y,x,value);
}
hiscumm.SCUMM6.incByte = function(engine,vm_stack,thread) {
	var vaddr = thread.readByte();
	engine.writeVar(vaddr,engine.readVar(vaddr,thread) + 1,thread);
}
hiscumm.SCUMM6.incWord = function(engine,vm_stack,thread) {
	var vaddr = thread.readShort();
	engine.writeVar(vaddr,engine.readVar(vaddr,thread) + 1,thread);
}
hiscumm.SCUMM6.incArrayByte = function(engine,vm_stack,thread) {
	var addr = engine.readVar(thread.readByte(),thread);
	var base = vm_stack.pop();
	engine.writeArray(addr,0,base,engine.readArray(addr,0,base) + 1);
}
hiscumm.SCUMM6.incArrayWord = function(engine,vm_stack,thread) {
	var addr = engine.readVar(thread.readShort(),thread);
	var base = vm_stack.pop();
	engine.writeArray(addr,0,base,engine.readArray(addr,0,base) + 1);
}
hiscumm.SCUMM6.decByte = function(engine,vm_stack,thread) {
	var vaddr = thread.readByte();
	engine.writeVar(vaddr,engine.readVar(vaddr,thread) - 1,thread);
}
hiscumm.SCUMM6.decWord = function(engine,vm_stack,thread) {
	var vaddr = thread.readShort();
	engine.writeVar(vaddr,engine.readVar(vaddr,thread) - 1,thread);
}
hiscumm.SCUMM6.decArrayByte = function(engine,vm_stack,thread) {
	var addr = engine.readVar(thread.readByte(),thread);
	var base = vm_stack.pop();
	engine.writeArray(addr,0,base,engine.readArray(addr,0,base) - 1);
}
hiscumm.SCUMM6.decArrayWord = function(engine,vm_stack,thread) {
	var addr = engine.readVar(thread.readShort(),thread);
	var base = vm_stack.pop();
	engine.writeArray(addr,0,base,engine.readArray(addr,0,base) - 1);
}
hiscumm.SCUMM6.jmpNotZero = function(engine,vm_stack,thread) {
	var offs = thread.readShortSigned();
	var val = vm_stack.pop();
	if(val != 0) thread.jumpRel(offs);
}
hiscumm.SCUMM6.jmpZero = function(engine,vm_stack,thread) {
	var offs = thread.readShortSigned();
	var val = vm_stack.pop();
	if(val == 0) thread.jumpRel(offs);
}
hiscumm.SCUMM6.startScript = function(engine,vm_stack,thread) {
	var num_args = vm_stack.pop();
	var args = new Array();
	if(num_args > 0) args[num_args - 1] = 0;
	args[0] = num_args;
	while(num_args > 0) {
		args[num_args - 1] = vm_stack.pop();
		num_args--;
	}
	var script = vm_stack.pop();
	var flags = vm_stack.pop();
	var id = hiscumm.SCUMMThread.startScript(flags,script,args);
	if(id < 0) {
		haxe.Log.trace("Failed to exec startScript!",{ fileName : "SCUMM6.hx", lineNumber : 366, className : "hiscumm.SCUMM6", methodName : "startScript"});
		thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
		return;
	}
	hiscumm.SCUMMThread.vm_next_thread = hiscumm.SCUMMThread.vm_threads[id];
	thread.return_state = hiscumm.SPUTMState.SPUTM_START_SCRIPT;
}
hiscumm.SCUMM6.startScriptQuick = function(engine,vm_stack,thread) {
	var num_args = vm_stack.pop();
	var args = new Array();
	if(num_args > 0) args[num_args - 1] = 0;
	args[0] = num_args;
	while(num_args > 0) {
		args[num_args - 1] = vm_stack.pop();
		num_args--;
	}
	var script = vm_stack.pop();
	var id = hiscumm.SCUMMThread.startScript(0,script,args);
	if(id < 0) {
		haxe.Log.trace("Failed to exec startScript!",{ fileName : "SCUMM6.hx", lineNumber : 393, className : "hiscumm.SCUMM6", methodName : "startScriptQuick"});
		thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
		return;
	}
	hiscumm.SCUMMThread.vm_next_thread = hiscumm.SCUMMThread.vm_threads[id];
	thread.return_state = hiscumm.SPUTMState.SPUTM_START_SCRIPT;
}
hiscumm.SCUMM6.startObject = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.drawObject = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.drawObjectAt = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.drawBlastObject = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.drawBlastObjectWindow = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.stopObjectCode = function(engine,vm_stack,thread) {
	thread.stop();
}
hiscumm.SCUMM6.endCutscene = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.cutscene = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.stopMusic = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.freezeUnfreeze = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.cursorOp = function(engine,vm_stack,thread) {
	var subOp = thread.readByte();
	var a;
	switch(subOp) {
	case 144:{
		null;
	}break;
	case 145:{
		null;
	}break;
	case 146:{
		null;
	}break;
	case 147:{
		null;
	}break;
	case 148:{
		null;
	}break;
	case 149:{
		null;
	}break;
	case 150:{
		null;
	}break;
	case 151:{
		null;
	}break;
	case 153:{
		var obj;
		var room;
		room = vm_stack.pop();
		obj = vm_stack.pop();
	}break;
	case 154:{
		a = vm_stack.pop();
	}break;
	case 156:{
		vm_stack.pop();
	}break;
	case 157:{
		null;
	}break;
	case 214:{
		vm_stack.pop();
	}break;
	default:{
		haxe.Log.trace("default cursorOp",{ fileName : "SCUMM6.hx", lineNumber : 503, className : "hiscumm.SCUMM6", methodName : "cursorOp"});
		thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
	}break;
	}
}
hiscumm.SCUMM6.breakScript = function(engine,vm_stack,thread) {
	thread.cycle = hiscumm.SCUMMThread.vm_cycle + 1;
}
hiscumm.SCUMM6.ifClassOfIs = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.setClass = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getObjectState = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.setObjectState = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.setObjectOwner = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getObjectOwner = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.jmp = function(engine,vm_stack,thread) {
	thread.jumpRel(thread.readShortSigned());
}
hiscumm.SCUMM6.startSound = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.stopSound = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.startMusic = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.stopObjectScript = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.panCameraTo = function(engine,vm_stack,thread) {
	haxe.Log.trace("panCameraTo=" + vm_stack.pop(),{ fileName : "SCUMM6.hx", lineNumber : 574, className : "hiscumm.SCUMM6", methodName : "panCameraTo"});
}
hiscumm.SCUMM6.followCameraActor = function(engine,vm_stack,thread) {
	haxe.Log.trace("followCameraActor=" + vm_stack.pop(),{ fileName : "SCUMM6.hx", lineNumber : 580, className : "hiscumm.SCUMM6", methodName : "followCameraActor"});
}
hiscumm.SCUMM6.setCameraAt = function(engine,vm_stack,thread) {
	haxe.Log.trace("setCameraAt=" + vm_stack.pop(),{ fileName : "SCUMM6.hx", lineNumber : 586, className : "hiscumm.SCUMM6", methodName : "setCameraAt"});
}
hiscumm.SCUMM6.startRoom = function(engine,vm_stack,thread) {
	engine.setNextRoom(vm_stack.pop());
	thread.return_state = hiscumm.SPUTMState.SPUTM_OPEN_ROOM;
}
hiscumm.SCUMM6.stopScript = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.walkActorToObject = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.walkActorTo = function(engine,vm_stack,thread) {
	var y = vm_stack.pop();
	var x = vm_stack.pop();
	var actornum = vm_stack.pop();
	haxe.Log.trace("walkActorTo=" + x + "," + y + "," + actornum,{ fileName : "SCUMM6.hx", lineNumber : 612, className : "hiscumm.SCUMM6", methodName : "walkActorTo"});
}
hiscumm.SCUMM6.putActorAt = function(engine,vm_stack,thread) {
	var room;
	var x;
	var y;
	var act;
	var a;
	room = vm_stack.pop();
	y = vm_stack.pop();
	x = vm_stack.pop();
	act = vm_stack.pop();
}
hiscumm.SCUMM6.putActorAtObject = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.faceActor = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.animateActor = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.doSentence = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.pickupObject = function(engine,vm_stack,thread) {
	var room = vm_stack.pop();
	var obj = vm_stack.pop();
}
hiscumm.SCUMM6.startRoomWithEgo = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getRandomNumber = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
	var max = vm_stack.pop();
	vm_stack.push(Std.random(max));
}
hiscumm.SCUMM6.getRandomNumberRange = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
	var max = vm_stack.pop();
	var min = vm_stack.pop();
	vm_stack.push(min + (Std.random(max) % (max - min)));
}
hiscumm.SCUMM6.getActorMoving = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.isScriptRunning = function(engine,vm_stack,thread) {
	var id = vm_stack.pop();
	vm_stack.push((hiscumm.SCUMMThread.isScriptRunning(id)?1:0));
}
hiscumm.SCUMM6.getActorRoom = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getObjectX = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getObjectY = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getObjectOldDir = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getActorWalkBox = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getActorCostume = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.findInventory = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getInventoryCount = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getVerbFrom = function(engine,vm_stack,thread) {
	var y = vm_stack.pop();
	var x = vm_stack.pop();
	var r = 0;
	vm_stack.push(r);
}
hiscumm.SCUMM6.beginOverride = function(engine,vm_stack,thread) {
	if(!thread.beginOverride()) {
		thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
		return;
	}
	thread.jumpRel(3);
	engine.writeVar(5,1,thread);
}
hiscumm.SCUMM6.endOverride = function(engine,vm_stack,thread) {
	thread.endOverride();
	engine.writeVar(5,0,thread);
}
hiscumm.SCUMM6.setObjectName = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.isSoundRunning = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.setBoxFlags = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.createBoxMatrix = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.resourceOp = function(engine,vm_stack,thread) {
	var subOp = thread.readByte();
	var res = vm_stack.pop();
	if(subOp == 101) return;
	haxe.Log.trace(subOp + ", " + thread.script.code.tell(),{ fileName : "SCUMM6.hx", lineNumber : 788, className : "hiscumm.SCUMM6", methodName : "resourceOp"});
	if(subOp >= 100 && subOp <= 103) {
		if(engine.vm_res[subOp - 100].loadResource(res) == null) {
			haxe.Log.trace("Bad resource",{ fileName : "SCUMM6.hx", lineNumber : 794, className : "hiscumm.SCUMM6", methodName : "resourceOp"});
			thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
		}
		return;
	}
	else if(subOp >= 104 && subOp <= 107) {
		if(!engine.vm_res[subOp - 104].nukeResource(res)) {
			haxe.Log.trace("Bad resource",{ fileName : "SCUMM6.hx", lineNumber : 803, className : "hiscumm.SCUMM6", methodName : "resourceOp"});
			thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
		}
		return;
	}
	else if(subOp >= 108 && subOp <= 111) {
		if(!engine.vm_res[subOp - 108].res[res].lock()) {
			haxe.Log.trace("Bad resource",{ fileName : "SCUMM6.hx", lineNumber : 812, className : "hiscumm.SCUMM6", methodName : "resourceOp"});
			thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
		}
		return;
	}
	else if(subOp >= 128 && subOp <= 115) {
		if(engine.vm_res[subOp - 128].res[res].unlock()) {
			haxe.Log.trace("Bad resource",{ fileName : "SCUMM6.hx", lineNumber : 821, className : "hiscumm.SCUMM6", methodName : "resourceOp"});
			thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
		}
		return;
	}
	switch(subOp) {
	case 117:{
		if(engine.vm_res[4].loadResource(res) == null) {
			haxe.Log.trace("Bad resource",{ fileName : "SCUMM6.hx", lineNumber : 832, className : "hiscumm.SCUMM6", methodName : "resourceOp"});
			thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
		}
		return;
	}break;
	case 119:{
		vm_stack.pop();
	}break;
	}
}
hiscumm.SCUMM6.roomOp = function(engine,vm_stack,thread) {
	var a;
	var b;
	var c;
	var d;
	var e;
	var subOp = thread.readByte();
	switch(subOp) {
	case 172:{
		b = vm_stack.pop();
		a = vm_stack.pop();
		engine.writeVar(17,a,thread);
		engine.writeVar(18,b,thread);
	}break;
	case 174:{
		b = vm_stack.pop();
		a = vm_stack.pop();
		engine.initScreens(a,b);
	}break;
	case 175:{
		d = vm_stack.pop();
		c = vm_stack.pop();
		b = vm_stack.pop();
		a = vm_stack.pop();
	}break;
	case 176:{
		null;
	}break;
	case 177:{
		null;
	}break;
	case 179:{
		c = vm_stack.pop();
		b = vm_stack.pop();
		a = vm_stack.pop();
	}break;
	case 180:{
		b = vm_stack.pop();
		a = vm_stack.pop();
	}break;
	case 181:{
		a = vm_stack.pop();
	}break;
	case 182:{
		e = vm_stack.pop();
		d = vm_stack.pop();
		c = vm_stack.pop();
		b = vm_stack.pop();
		a = vm_stack.pop();
	}break;
	case 183:{
		e = vm_stack.pop();
		d = vm_stack.pop();
		c = vm_stack.pop();
		b = vm_stack.pop();
		a = vm_stack.pop();
	}break;
	case 184:{
		haxe.Log.trace("save string n/a",{ fileName : "SCUMM6.hx", lineNumber : 934, className : "hiscumm.SCUMM6", methodName : "roomOp"});
		thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
	}break;
	case 185:{
		haxe.Log.trace("load string n/a",{ fileName : "SCUMM6.hx", lineNumber : 940, className : "hiscumm.SCUMM6", methodName : "roomOp"});
		thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
	}break;
	case 186:{
		d = vm_stack.pop();
		c = vm_stack.pop();
		b = vm_stack.pop();
		a = vm_stack.pop();
	}break;
	case 187:{
		b = vm_stack.pop();
		a = vm_stack.pop();
	}break;
	case 213:{
		a = vm_stack.pop();
	}break;
	default:{
		haxe.Log.trace("roomOps N/A (" + subOp + ")",{ fileName : "SCUMM6.hx", lineNumber : 966, className : "hiscumm.SCUMM6", methodName : "roomOp"});
		thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
	}break;
	}
}
hiscumm.SCUMM6.actorOp = function(engine,vm_stack,thread) {
	var a = null;
	var i;
	var j;
	var k;
	var args;
	var subOp = thread.readByte();
	if(subOp == 197) {
		engine.vm_current_actor = engine.getActor(vm_stack.pop());
		return;
	}
	a = engine.vm_current_actor;
	if(a == null) return;
	switch(subOp) {
	case 76:{
		vm_stack.pop();
	}break;
	case 77:{
		j = vm_stack.pop();
		i = vm_stack.pop();
	}break;
	case 78:{
		var num_args = vm_stack.pop();
		var args1 = new Array();
		if(num_args > 0) args1[num_args - 1] = 0;
		args1[0] = num_args;
		while(num_args > 0) {
			args1[num_args - 1] = vm_stack.pop();
			num_args--;
		}
	}break;
	case 79:{
		vm_stack.pop();
	}break;
	case 80:{
		vm_stack.pop();
		vm_stack.pop();
	}break;
	case 81:{
		vm_stack.pop();
	}break;
	case 82:{
		vm_stack.pop();
		vm_stack.pop();
		vm_stack.pop();
	}break;
	case 83:{
		null;
	}break;
	case 84:{
		vm_stack.pop();
	}break;
	case 85:{
		null;
	}break;
	case 86:{
		j = vm_stack.pop();
		i = vm_stack.pop();
	}break;
	case 87:{
		vm_stack.pop();
	}break;
	case 88:{
		i = thread.getStrLen();
		thread.jumpRel(i + 1);
	}break;
	case 89:{
		vm_stack.pop();
	}break;
	case 91:{
		vm_stack.pop();
	}break;
	case 92:{
		i = vm_stack.pop();
	}break;
	case 93:{
		null;
	}break;
	case 225:{
		vm_stack.pop();
	}break;
	case 94:{
		vm_stack.pop();
	}break;
	case 95:{
		null;
	}break;
	case 96:{
		null;
	}break;
	case 97:{
		vm_stack.pop();
	}break;
	case 98:{
		vm_stack.pop();
	}break;
	case 99:{
		vm_stack.pop();
		vm_stack.pop();
	}break;
	case 198:{
		i = vm_stack.pop();
		vm_stack.pop();
	}break;
	case 215:{
		null;
	}break;
	case 216:{
		null;
	}break;
	case 217:{
		null;
	}break;
	case 227:{
		vm_stack.pop();
	}break;
	case 228:{
		vm_stack.pop();
	}break;
	case 229:{
		null;
	}break;
	case 230:{
		vm_stack.pop();
	}break;
	case 231:{
		vm_stack.pop();
	}break;
	case 233:{
		null;
	}break;
	case 234:{
		null;
	}break;
	case 235:{
		vm_stack.pop();
	}break;
	default:{
		haxe.Log.trace("Default actorOps case!",{ fileName : "SCUMM6.hx", lineNumber : 1127, className : "hiscumm.SCUMM6", methodName : "actorOp"});
		thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
	}break;
	}
}
hiscumm.SCUMM6.verbOp = function(engine,vm_stack,thread) {
	var a;
	var b;
	var i;
	var slot;
	var subOp = thread.readByte();
	if(subOp == 196) {
		vm_stack.pop();
		return;
	}
	switch(subOp) {
	case 124:{
		a = vm_stack.pop();
	}break;
	case 125:{
		a = thread.getStrLen();
		thread.jumpRel(a + 1);
	}break;
	case 126:{
		vm_stack.pop();
	}break;
	case 127:{
		vm_stack.pop();
	}break;
	case 128:{
		vm_stack.pop();
		vm_stack.pop();
	}break;
	case 129:{
		null;
	}break;
	case 130:{
		null;
	}break;
	case 131:{
		null;
	}break;
	case 132:{
		null;
	}break;
	case 133:{
		vm_stack.pop();
	}break;
	case 134:{
		null;
	}break;
	case 135:{
		vm_stack.pop();
	}break;
	case 136:{
		vm_stack.pop();
	}break;
	case 137:{
		a = vm_stack.pop();
		if(a == 0) {
			i = thread.getStrLen();
			thread.jumpRel(i + 1);
		}
	}break;
	case 139:{
		b = vm_stack.pop();
		a = vm_stack.pop();
	}break;
	case 140:{
		vm_stack.pop();
	}break;
	case 255:{
		null;
	}break;
	default:{
		haxe.Log.trace("Default verbOps case!",{ fileName : "SCUMM6.hx", lineNumber : 1189, className : "hiscumm.SCUMM6", methodName : "verbOp"});
		thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
	}break;
	}
}
hiscumm.SCUMM6.getActorFrom = function(engine,vm_stack,thread) {
	var y = vm_stack.pop();
	var x = vm_stack.pop();
	var r = 0;
	vm_stack.push(r);
}
hiscumm.SCUMM6.findObject = function(engine,vm_stack,thread) {
	var y = vm_stack.pop();
	var x = vm_stack.pop();
	var r = 0;
	vm_stack.push(r);
}
hiscumm.SCUMM6.pseudoRoom = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getActorElevation = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getVerbEntrypoint = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.arrayOps = function(engine,vm_stack,thread) {
	var subOp = thread.readByte();
	var array = thread.readShort();
	var b;
	var c;
	var d = engine.readVar(array,thread);
	var y;
	var len;
	switch(subOp) {
	case 205:{
		b = vm_stack.pop();
		len = thread.getStrLen();
		engine.nukeArray(d);
		d = engine.defineArray(hiscumm.SPUTMArrayType.ARRAY_STRING,0,b + len + 1);
		var adata = engine.vm_array[d].data;
		len = thread.getStrLen() + 1;
		y = -1;
		c = b;
		while(len > 0) {
			adata[c] = thread.readByte();
			c++;
			len--;
		}
		haxe.Log.trace("ARRAY = \"" + engine.vm_array[d].toString() + "\"",{ fileName : "SCUMM6.hx", lineNumber : 1258, className : "hiscumm.SCUMM6", methodName : "arrayOps"});
	}break;
	case 208:{
		b = vm_stack.pop();
		len = vm_stack.pop();
		if(d == 0) {
			d = engine.defineArray(hiscumm.SPUTMArrayType.ARRAY_INT,0,b + len);
		}
		var ainst = engine.vm_array[d];
		c = b;
		while(len > 0) {
			ainst.set(0,c,vm_stack.pop());
			len--;
			c++;
		}
	}break;
	case 212:{
		b = vm_stack.pop();
		len = vm_stack.pop();
		if(d == 0) {
			haxe.Log.trace("2dim array needs to be dim'd!",{ fileName : "SCUMM6.hx", lineNumber : 1284, className : "hiscumm.SCUMM6", methodName : "arrayOps"});
			thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
			return;
		}
		var temp = new Array();
		c = len - 1;
		while(c > -1) {
			temp[c] = vm_stack.pop();
			c--;
		}
		y = vm_stack.pop();
		var ainst = engine.vm_array[d];
		c = len - 1;
		while(c > 0) {
			ainst.set(y,b + c,temp[y]);
			c--;
		}
	}break;
	default:{
		haxe.Log.trace("Invalid subop!",{ fileName : "SCUMM6.hx", lineNumber : 1308, className : "hiscumm.SCUMM6", methodName : "arrayOps"});
		thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
		return;
	}break;
	}
	engine.writeVar(array,d,thread);
}
hiscumm.SCUMM6.saveRestoreVerbs = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.drawBox = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getActorWidth = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.wait = function(engine,vm_stack,thread) {
	var actnum = 0;
	var offs = -2;
	var a;
	var subOp = thread.readByte();
	switch(subOp) {
	case 168:{
		offs = thread.readShortSigned();
		actnum = vm_stack.pop();
		return;
	}break;
	case 169:{
		return;
	}break;
	case 170:{
		return;
	}break;
	case 171:{
		return;
	}break;
	case 226:{
		offs = thread.readShortSigned();
		actnum = vm_stack.pop();
		return;
	}break;
	case 232:{
		offs = thread.readShortSigned();
		actnum = vm_stack.pop();
		return;
	}break;
	default:{
		haxe.Log.trace("Default waitOps case!",{ fileName : "SCUMM6.hx", lineNumber : 1390, className : "hiscumm.SCUMM6", methodName : "wait"});
		thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
	}break;
	}
	thread.jumpRel(offs);
	thread.cycle = hiscumm.SCUMMThread.vm_cycle + 1;
}
hiscumm.SCUMM6.getActorXScale = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getActorAnimCounter = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.soundKludge = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.isAnyOf = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.systemOps = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.isActorInBox = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.delay = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.delaySeconds = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.delayMinutes = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.stopSentence = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.print = function(engine,vm_stack,thread) {
	var subOp = thread.readByte();
	switch(subOp) {
	case 65:{
		vm_stack.pop();
		vm_stack.pop();
	}break;
	case 66:{
		null;
	}break;
	case 67:{
		vm_stack.pop();
	}break;
	case 69:{
		null;
	}break;
	case 71:{
		null;
	}break;
	case 72:{
		null;
	}break;
	case 74:{
		null;
	}break;
	case 75:{
		thread.jumpRel(thread.getStrLen() + 1);
		vm_stack.pop();
	}break;
	case 254:{
		null;
	}break;
	case 255:{
		null;
	}break;
	default:{
		haxe.Log.trace("print default case!",{ fileName : "SCUMM6.hx", lineNumber : 1471, className : "hiscumm.SCUMM6", methodName : "print"});
	}break;
	}
}
hiscumm.SCUMM6.printCursor = function(engine,vm_stack,thread) {
	var subOp = thread.readByte();
	switch(subOp) {
	case 65:{
		vm_stack.pop();
		vm_stack.pop();
	}break;
	case 66:{
		null;
	}break;
	case 67:{
		vm_stack.pop();
	}break;
	case 69:{
		null;
	}break;
	case 71:{
		null;
	}break;
	case 72:{
		null;
	}break;
	case 74:{
		null;
	}break;
	case 75:{
		thread.jumpRel(thread.getStrLen() + 1);
		vm_stack.pop();
	}break;
	case 254:{
		null;
	}break;
	case 255:{
		null;
	}break;
	default:{
		haxe.Log.trace("print default case!",{ fileName : "SCUMM6.hx", lineNumber : 1498, className : "hiscumm.SCUMM6", methodName : "printCursor"});
	}break;
	}
}
hiscumm.SCUMM6.printDebug = function(engine,vm_stack,thread) {
	var subOp = thread.readByte();
	switch(subOp) {
	case 65:{
		vm_stack.pop();
		vm_stack.pop();
	}break;
	case 66:{
		null;
	}break;
	case 67:{
		vm_stack.pop();
	}break;
	case 69:{
		null;
	}break;
	case 71:{
		null;
	}break;
	case 72:{
		null;
	}break;
	case 74:{
		null;
	}break;
	case 75:{
		thread.jumpRel(thread.getStrLen() + 1);
		vm_stack.pop();
	}break;
	case 254:{
		null;
	}break;
	case 255:{
		null;
	}break;
	default:{
		haxe.Log.trace("print default case!",{ fileName : "SCUMM6.hx", lineNumber : 1525, className : "hiscumm.SCUMM6", methodName : "printDebug"});
	}break;
	}
}
hiscumm.SCUMM6.printSystem = function(engine,vm_stack,thread) {
	var subOp = thread.readByte();
	switch(subOp) {
	case 65:{
		vm_stack.pop();
		vm_stack.pop();
	}break;
	case 66:{
		null;
	}break;
	case 67:{
		vm_stack.pop();
	}break;
	case 69:{
		null;
	}break;
	case 71:{
		null;
	}break;
	case 72:{
		null;
	}break;
	case 74:{
		null;
	}break;
	case 75:{
		thread.jumpRel(thread.getStrLen() + 1);
		vm_stack.pop();
	}break;
	case 254:{
		null;
	}break;
	case 255:{
		null;
	}break;
	default:{
		haxe.Log.trace("print default case!",{ fileName : "SCUMM6.hx", lineNumber : 1552, className : "hiscumm.SCUMM6", methodName : "printSystem"});
	}break;
	}
}
hiscumm.SCUMM6.printActor = function(engine,vm_stack,thread) {
	var subOp = thread.readByte();
	switch(subOp) {
	case 65:{
		vm_stack.pop();
		vm_stack.pop();
	}break;
	case 66:{
		null;
	}break;
	case 67:{
		vm_stack.pop();
	}break;
	case 69:{
		null;
	}break;
	case 71:{
		null;
	}break;
	case 72:{
		null;
	}break;
	case 74:{
		null;
	}break;
	case 75:{
		thread.jumpRel(thread.getStrLen() + 1);
		vm_stack.pop();
	}break;
	case 254:{
		null;
	}break;
	case 255:{
		null;
	}break;
	default:{
		haxe.Log.trace("print default case!",{ fileName : "SCUMM6.hx", lineNumber : 1579, className : "hiscumm.SCUMM6", methodName : "printActor"});
	}break;
	}
}
hiscumm.SCUMM6.printEgo = function(engine,vm_stack,thread) {
	var subOp = thread.readByte();
	switch(subOp) {
	case 65:{
		vm_stack.pop();
		vm_stack.pop();
	}break;
	case 66:{
		null;
	}break;
	case 67:{
		vm_stack.pop();
	}break;
	case 69:{
		null;
	}break;
	case 71:{
		null;
	}break;
	case 72:{
		null;
	}break;
	case 74:{
		null;
	}break;
	case 75:{
		thread.jumpRel(thread.getStrLen() + 1);
		vm_stack.pop();
	}break;
	case 254:{
		null;
	}break;
	case 255:{
		null;
	}break;
	default:{
		haxe.Log.trace("print default case!",{ fileName : "SCUMM6.hx", lineNumber : 1606, className : "hiscumm.SCUMM6", methodName : "printEgo"});
	}break;
	}
}
hiscumm.SCUMM6.talkActor = function(engine,vm_stack,thread) {
	var actornum = vm_stack.pop();
	thread.jumpRel(thread.getStrLen() + 1);
}
hiscumm.SCUMM6.talkEgo = function(engine,vm_stack,thread) {
	vm_stack.push(engine.readVar(1,thread));
	hiscumm.SCUMM6.talkActor(engine,vm_stack,thread);
}
hiscumm.SCUMM6.dimArray = function(engine,vm_stack,thread) {
	var arrayType;
	var subOp = thread.readByte();
	var array;
	var d;
	switch(subOp) {
	case 199:{
		arrayType = hiscumm.SPUTMArrayType.ARRAY_INT;
	}break;
	case 200:{
		arrayType = hiscumm.SPUTMArrayType.ARRAY_BIT;
	}break;
	case 201:{
		arrayType = hiscumm.SPUTMArrayType.ARRAY_NIBBLE;
	}break;
	case 202:{
		arrayType = hiscumm.SPUTMArrayType.ARRAY_BYTE;
	}break;
	case 203:{
		arrayType = hiscumm.SPUTMArrayType.ARRAY_STRING;
	}break;
	case 204:{
		engine.nukeArray(engine.readVar(thread.readShort(),thread));
		return;
	}break;
	default:{
		haxe.Log.trace("dimArray default!",{ fileName : "SCUMM6.hx", lineNumber : 1652, className : "hiscumm.SCUMM6", methodName : "dimArray"});
		thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
	}break;
	}
	array = thread.readShort();
	haxe.Log.trace(array,{ fileName : "SCUMM6.hx", lineNumber : 1657, className : "hiscumm.SCUMM6", methodName : "dimArray"});
	d = engine.readVar(array,thread);
	engine.nukeArray(d);
	d = engine.defineArray(arrayType,0,vm_stack.pop());
	engine.writeVar(array,d,thread);
}
hiscumm.SCUMM6.dummy = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.startObjectQuick = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.startScriptRecursive = function(engine,vm_stack,thread) {
	var num_args = vm_stack.pop();
	var args = new Array();
	if(num_args > 0) args[num_args - 1] = 0;
	args[0] = num_args;
	while(num_args > 0) {
		args[num_args - 1] = vm_stack.pop();
		num_args--;
	}
	var script = vm_stack.pop();
	var id = hiscumm.SCUMMThread.startScript(hiscumm.SCUMMThread.THREAD_FLAG_RECURSIVE,script,args);
	if(id < 0) {
		haxe.Log.trace("Failed to exec startScript!",{ fileName : "SCUMM6.hx", lineNumber : 1694, className : "hiscumm.SCUMM6", methodName : "startScriptRecursive"});
		thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
		return;
	}
	hiscumm.SCUMMThread.vm_next_thread = hiscumm.SCUMMThread.vm_threads[id];
	thread.return_state = hiscumm.SPUTMState.SPUTM_START_SCRIPT;
}
hiscumm.SCUMM6.dimArray2 = function(engine,vm_stack,thread) {
	var arrayType;
	var subOp = thread.readByte();
	var array;
	var d;
	var b;
	var a;
	switch(subOp) {
	case 199:{
		arrayType = hiscumm.SPUTMArrayType.ARRAY_INT;
	}break;
	case 200:{
		arrayType = hiscumm.SPUTMArrayType.ARRAY_BIT;
	}break;
	case 201:{
		arrayType = hiscumm.SPUTMArrayType.ARRAY_NIBBLE;
	}break;
	case 202:{
		arrayType = hiscumm.SPUTMArrayType.ARRAY_BYTE;
	}break;
	case 203:{
		arrayType = hiscumm.SPUTMArrayType.ARRAY_STRING;
	}break;
	case 204:{
		engine.nukeArray(engine.readVar(thread.readShort(),thread));
		return;
	}break;
	default:{
		haxe.Log.trace("dimArray default!",{ fileName : "SCUMM6.hx", lineNumber : 1729, className : "hiscumm.SCUMM6", methodName : "dimArray2"});
		thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
	}break;
	}
	array = thread.readShort();
	b = vm_stack.pop();
	a = vm_stack.pop();
	d = engine.readVar(array,thread);
	engine.nukeArray(d);
	d = engine.defineArray(arrayType,a,b);
	engine.writeVar(array,d,thread);
}
hiscumm.SCUMM6.abs = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.distObjectObject = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.distObjectPt = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.distPtPt = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.kernelGetFunctions = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.kernelSetFunctions = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.breakScriptNTimes = function(engine,vm_stack,thread) {
	var n = vm_stack.pop();
	thread.cycle = hiscumm.SCUMMThread.vm_cycle + n;
}
hiscumm.SCUMM6.pickOneOf = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.pickOneOfDefault = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.stampObject = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getDateTime = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.stopTalking = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getAnimateVariable = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.shuffle = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.jumpToScript = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.bitAND = function(engine,vm_stack,thread) {
	var a = vm_stack.pop();
	vm_stack.push(vm_stack.pop() & a);
}
hiscumm.SCUMM6.bitOR = function(engine,vm_stack,thread) {
	var a = vm_stack.pop();
	vm_stack.push(vm_stack.pop() | a);
}
hiscumm.SCUMM6.isRoomScriptRunning = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.findAllObjects = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getPixel = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.pickRandomVar = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.setBoxSet = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getActorLayer = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.getObjectNewDir = function(engine,vm_stack,thread) {
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.invalid = function(engine,vm_stack,thread) {
	haxe.Log.trace("Invalid opcode!",{ fileName : "SCUMM6.hx", lineNumber : 1870, className : "hiscumm.SCUMM6", methodName : "invalid"});
	thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
}
hiscumm.SCUMM6.prototype.__class__ = hiscumm.SCUMM6;
hiscumm.SPUTMPalette = function(data) { if( data === $_ ) return; {
	utils.JSByteIO.apply(this,[]);
	this.prepare(256 * 3);
	this.writeInput(data);
	this.seek(0,utils.Seek.SeekBegin);
}}
hiscumm.SPUTMPalette.__name__ = ["hiscumm","SPUTMPalette"];
hiscumm.SPUTMPalette.__super__ = utils.JSByteIO;
for(var k in utils.JSByteIO.prototype ) hiscumm.SPUTMPalette.prototype[k] = utils.JSByteIO.prototype[k];
hiscumm.SPUTMPalette.prototype.__class__ = hiscumm.SPUTMPalette;
noflash.Point = function(x,y) { if( x === $_ ) return; {
	this.x = x;
	this.y = y;
}}
noflash.Point.__name__ = ["noflash","Point"];
noflash.Point.prototype.x = null;
noflash.Point.prototype.y = null;
noflash.Point.prototype.__class__ = noflash.Point;
hiscumm.SPUTMDisplayPalette = function(p) { if( p === $_ ) return; {
	var i;
	this.list = new Array();
	this.list[255] = 0;
	{
		var _g = 0;
		while(_g < 255) {
			var i1 = _g++;
			this.list[i1] = 0;
		}
	}
}}
hiscumm.SPUTMDisplayPalette.__name__ = ["hiscumm","SPUTMDisplayPalette"];
hiscumm.SPUTMDisplayPalette.prototype.list = null;
hiscumm.SPUTMDisplayPalette.prototype.load = function(palette) {
	var i;
	var r;
	var g;
	var b;
	palette.seek(0,utils.Seek.SeekBegin);
	{
		var _g = 0;
		while(_g < 256) {
			var i1 = _g++;
			r = palette.readChar();
			g = palette.readChar();
			b = palette.readChar();
			this.list[i1] = (((r << 16) | (g << 8)) | b);
		}
	}
}
hiscumm.SPUTMDisplayPalette.prototype.mapTo = function(bmap) {
	bmap.fastPaletteRemap(this.list);
}
hiscumm.SPUTMDisplayPalette.prototype.__class__ = hiscumm.SPUTMDisplayPalette;
hiscumm.SPUTMSoundFactory = function(p) { if( p === $_ ) return; {
	hiscumm.SPUTMResourceFactory.apply(this,[]);
	this.name = "SOUND";
}}
hiscumm.SPUTMSoundFactory.__name__ = ["hiscumm","SPUTMSoundFactory"];
hiscumm.SPUTMSoundFactory.__super__ = hiscumm.SPUTMResourceFactory;
for(var k in hiscumm.SPUTMResourceFactory.prototype ) hiscumm.SPUTMSoundFactory.prototype[k] = hiscumm.SPUTMResourceFactory.prototype[k];
hiscumm.SPUTMSoundFactory.prototype.__class__ = hiscumm.SPUTMSoundFactory;
hiscumm.SPUTMCharsetFactory = function(p) { if( p === $_ ) return; {
	hiscumm.SPUTMResourceFactory.apply(this,[]);
	this.name = "CHARSET";
}}
hiscumm.SPUTMCharsetFactory.__name__ = ["hiscumm","SPUTMCharsetFactory"];
hiscumm.SPUTMCharsetFactory.__super__ = hiscumm.SPUTMResourceFactory;
for(var k in hiscumm.SPUTMResourceFactory.prototype ) hiscumm.SPUTMCharsetFactory.prototype[k] = hiscumm.SPUTMResourceFactory.prototype[k];
hiscumm.SPUTMCharsetFactory.prototype.__class__ = hiscumm.SPUTMCharsetFactory;
hiscumm.SPUTMArrayType = { __ename__ : ["hiscumm","SPUTMArrayType"], __constructs__ : ["ARRAY_BIT","ARRAY_NIBBLE","ARRAY_BYTE","ARRAY_STRING","ARRAY_INT","ARRAY_DWORD","ARRAY_NUM"] }
hiscumm.SPUTMArrayType.ARRAY_BIT = ["ARRAY_BIT",0];
hiscumm.SPUTMArrayType.ARRAY_BIT.toString = $estr;
hiscumm.SPUTMArrayType.ARRAY_BIT.__enum__ = hiscumm.SPUTMArrayType;
hiscumm.SPUTMArrayType.ARRAY_BYTE = ["ARRAY_BYTE",2];
hiscumm.SPUTMArrayType.ARRAY_BYTE.toString = $estr;
hiscumm.SPUTMArrayType.ARRAY_BYTE.__enum__ = hiscumm.SPUTMArrayType;
hiscumm.SPUTMArrayType.ARRAY_DWORD = ["ARRAY_DWORD",5];
hiscumm.SPUTMArrayType.ARRAY_DWORD.toString = $estr;
hiscumm.SPUTMArrayType.ARRAY_DWORD.__enum__ = hiscumm.SPUTMArrayType;
hiscumm.SPUTMArrayType.ARRAY_INT = ["ARRAY_INT",4];
hiscumm.SPUTMArrayType.ARRAY_INT.toString = $estr;
hiscumm.SPUTMArrayType.ARRAY_INT.__enum__ = hiscumm.SPUTMArrayType;
hiscumm.SPUTMArrayType.ARRAY_NIBBLE = ["ARRAY_NIBBLE",1];
hiscumm.SPUTMArrayType.ARRAY_NIBBLE.toString = $estr;
hiscumm.SPUTMArrayType.ARRAY_NIBBLE.__enum__ = hiscumm.SPUTMArrayType;
hiscumm.SPUTMArrayType.ARRAY_NUM = ["ARRAY_NUM",6];
hiscumm.SPUTMArrayType.ARRAY_NUM.toString = $estr;
hiscumm.SPUTMArrayType.ARRAY_NUM.__enum__ = hiscumm.SPUTMArrayType;
hiscumm.SPUTMArrayType.ARRAY_STRING = ["ARRAY_STRING",3];
hiscumm.SPUTMArrayType.ARRAY_STRING.toString = $estr;
hiscumm.SPUTMArrayType.ARRAY_STRING.__enum__ = hiscumm.SPUTMArrayType;
hiscumm.SPUTMArray = function(type,x,y) { if( type === $_ ) return; {
	this.atype = type;
	this.dim1 = x;
	this.dim2 = y;
	this.data = new Array();
	this.data[(x * y) - 1] = 0;
}}
hiscumm.SPUTMArray.__name__ = ["hiscumm","SPUTMArray"];
hiscumm.SPUTMArray.toArrayType = function(t) {
	switch(t) {
	case 0:{
		return hiscumm.SPUTMArrayType.ARRAY_BIT;
	}break;
	case 1:{
		return hiscumm.SPUTMArrayType.ARRAY_NIBBLE;
	}break;
	case 2:{
		return hiscumm.SPUTMArrayType.ARRAY_BYTE;
	}break;
	case 3:{
		return hiscumm.SPUTMArrayType.ARRAY_STRING;
	}break;
	case 4:{
		return hiscumm.SPUTMArrayType.ARRAY_INT;
	}break;
	case 5:{
		return hiscumm.SPUTMArrayType.ARRAY_DWORD;
	}break;
	default:{
		return hiscumm.SPUTMArrayType.ARRAY_NUM;
	}break;
	}
}
hiscumm.SPUTMArray.prototype.atype = null;
hiscumm.SPUTMArray.prototype.data = null;
hiscumm.SPUTMArray.prototype.dim1 = null;
hiscumm.SPUTMArray.prototype.dim2 = null;
hiscumm.SPUTMArray.prototype.get = function(y,x) {
	var real_value = this.data[x + (this.dim2 * y)];
	if(this.atype == hiscumm.SPUTMArrayType.ARRAY_INT) return (((real_value & 32768) != 0)?real_value - 65536:real_value);
	else return real_value;
}
hiscumm.SPUTMArray.prototype.set = function(y,x,value) {
	var real_value = value;
	var $e = (this.atype);
	switch( $e[1] ) {
	case 0:
	{
		real_value = (real_value & 1);
	}break;
	case 1:
	{
		real_value = (real_value & 15);
	}break;
	case 2:
	{
		real_value = (real_value & 255);
	}break;
	case 3:
	{
		real_value = value;
	}break;
	case 4:
	{
		real_value = ((((value < 0)?(65536 + value):value)) & 65535);
	}break;
	case 5:
	{
		real_value = value;
	}break;
	case 6:
	{
		real_value = value;
	}break;
	}
	this.data[x + (this.dim2 * y)] = real_value;
}
hiscumm.SPUTMArray.prototype.toString = function() {
	var str = "";
	var d;
	{
		var _g = 0, _g1 = this.data;
		while(_g < _g1.length) {
			var d1 = _g1[_g];
			++_g;
			if(d1 == 0) continue;
			str += String.fromCharCode(d1);
		}
	}
	return str;
}
hiscumm.SPUTMArray.prototype.__class__ = hiscumm.SPUTMArray;
hiscumm.SPUTMActor = function(num) { if( num === $_ ) return; {
	this.id = num;
}}
hiscumm.SPUTMActor.__name__ = ["hiscumm","SPUTMActor"];
hiscumm.SPUTMActor.prototype.id = null;
hiscumm.SPUTMActor.prototype.__class__ = hiscumm.SPUTMActor;
hiscumm.SPUTMState = { __ename__ : ["hiscumm","SPUTMState"], __constructs__ : ["SPUTM_ERROR","SPUTM_NONE","SPUTM_BOOT","SPUTM_BEGIN_CYCLE","SPUTM_START_SCRIPT","SPUTM_RUNNING","SPUTM_OPEN_ROOM","SPUTM_RUN_PRE_EXIT","SPUTM_RUN_EXCD","SPUTM_RUN_POST_EXIT","SPUTM_SETUP_ROOM","SPUTM_RUN_PRE_ENTRY","SPUTM_RUN_ENCD","SPUTM_RUN_POST_ENTRY","SPUTM_OK"] }
hiscumm.SPUTMState.SPUTM_BEGIN_CYCLE = ["SPUTM_BEGIN_CYCLE",3];
hiscumm.SPUTMState.SPUTM_BEGIN_CYCLE.toString = $estr;
hiscumm.SPUTMState.SPUTM_BEGIN_CYCLE.__enum__ = hiscumm.SPUTMState;
hiscumm.SPUTMState.SPUTM_BOOT = ["SPUTM_BOOT",2];
hiscumm.SPUTMState.SPUTM_BOOT.toString = $estr;
hiscumm.SPUTMState.SPUTM_BOOT.__enum__ = hiscumm.SPUTMState;
hiscumm.SPUTMState.SPUTM_ERROR = ["SPUTM_ERROR",0];
hiscumm.SPUTMState.SPUTM_ERROR.toString = $estr;
hiscumm.SPUTMState.SPUTM_ERROR.__enum__ = hiscumm.SPUTMState;
hiscumm.SPUTMState.SPUTM_NONE = ["SPUTM_NONE",1];
hiscumm.SPUTMState.SPUTM_NONE.toString = $estr;
hiscumm.SPUTMState.SPUTM_NONE.__enum__ = hiscumm.SPUTMState;
hiscumm.SPUTMState.SPUTM_OK = ["SPUTM_OK",14];
hiscumm.SPUTMState.SPUTM_OK.toString = $estr;
hiscumm.SPUTMState.SPUTM_OK.__enum__ = hiscumm.SPUTMState;
hiscumm.SPUTMState.SPUTM_OPEN_ROOM = ["SPUTM_OPEN_ROOM",6];
hiscumm.SPUTMState.SPUTM_OPEN_ROOM.toString = $estr;
hiscumm.SPUTMState.SPUTM_OPEN_ROOM.__enum__ = hiscumm.SPUTMState;
hiscumm.SPUTMState.SPUTM_RUNNING = ["SPUTM_RUNNING",5];
hiscumm.SPUTMState.SPUTM_RUNNING.toString = $estr;
hiscumm.SPUTMState.SPUTM_RUNNING.__enum__ = hiscumm.SPUTMState;
hiscumm.SPUTMState.SPUTM_RUN_ENCD = ["SPUTM_RUN_ENCD",12];
hiscumm.SPUTMState.SPUTM_RUN_ENCD.toString = $estr;
hiscumm.SPUTMState.SPUTM_RUN_ENCD.__enum__ = hiscumm.SPUTMState;
hiscumm.SPUTMState.SPUTM_RUN_EXCD = ["SPUTM_RUN_EXCD",8];
hiscumm.SPUTMState.SPUTM_RUN_EXCD.toString = $estr;
hiscumm.SPUTMState.SPUTM_RUN_EXCD.__enum__ = hiscumm.SPUTMState;
hiscumm.SPUTMState.SPUTM_RUN_POST_ENTRY = ["SPUTM_RUN_POST_ENTRY",13];
hiscumm.SPUTMState.SPUTM_RUN_POST_ENTRY.toString = $estr;
hiscumm.SPUTMState.SPUTM_RUN_POST_ENTRY.__enum__ = hiscumm.SPUTMState;
hiscumm.SPUTMState.SPUTM_RUN_POST_EXIT = ["SPUTM_RUN_POST_EXIT",9];
hiscumm.SPUTMState.SPUTM_RUN_POST_EXIT.toString = $estr;
hiscumm.SPUTMState.SPUTM_RUN_POST_EXIT.__enum__ = hiscumm.SPUTMState;
hiscumm.SPUTMState.SPUTM_RUN_PRE_ENTRY = ["SPUTM_RUN_PRE_ENTRY",11];
hiscumm.SPUTMState.SPUTM_RUN_PRE_ENTRY.toString = $estr;
hiscumm.SPUTMState.SPUTM_RUN_PRE_ENTRY.__enum__ = hiscumm.SPUTMState;
hiscumm.SPUTMState.SPUTM_RUN_PRE_EXIT = ["SPUTM_RUN_PRE_EXIT",7];
hiscumm.SPUTMState.SPUTM_RUN_PRE_EXIT.toString = $estr;
hiscumm.SPUTMState.SPUTM_RUN_PRE_EXIT.__enum__ = hiscumm.SPUTMState;
hiscumm.SPUTMState.SPUTM_SETUP_ROOM = ["SPUTM_SETUP_ROOM",10];
hiscumm.SPUTMState.SPUTM_SETUP_ROOM.toString = $estr;
hiscumm.SPUTMState.SPUTM_SETUP_ROOM.__enum__ = hiscumm.SPUTMState;
hiscumm.SPUTMState.SPUTM_START_SCRIPT = ["SPUTM_START_SCRIPT",4];
hiscumm.SPUTMState.SPUTM_START_SCRIPT.toString = $estr;
hiscumm.SPUTMState.SPUTM_START_SCRIPT.__enum__ = hiscumm.SPUTMState;
hiscumm.SPUTM = function(resources) { if( resources === $_ ) return; {
	hiscumm.SPUTM.instance = this;
	var index = new hiscumm.ChunkReader(resources[0]);
	var reader = resources[0];
	var size = 0;
	var i;
	this.vm_files = resources;
	this.view_flags = 0;
	this.view = new justjs.Bitmap();
	this.view_palette = new hiscumm.SPUTMDisplayPalette();
	this.setSize(320,200);
	this.vm_next_room = null;
	hiscumm.SCUMMThread.optable = hiscumm.SCUMM6.optable;
	hiscumm.SCUMMThread.suboptable = hiscumm.SCUMM6.suboptable;
	while(index.nextChunk()) {
		var $e = (hiscumm.SPUTMResourceChunk.identify(index.chunkID));
		switch( $e[1] ) {
		case 0:
		{
			null;
		}break;
		case 1:
		{
			size = reader.readUInt16();
			this.vm_vars = new Array();
			this.vm_vars[size - 1] = 0;
			{
				var _g1 = 0, _g = this.vm_vars.length;
				while(_g1 < _g) {
					var i1 = _g1++;
					this.vm_vars[i1] = 0;
				}
			}
			this.initVars();
			reader.readUInt16();
			size = ((reader.readUInt16() + 31) & -32);
			this.num_bitvars = size;
			this.vm_bitvars = new Array();
			this.vm_bitvars[(size >> 5) - 1] = new noneko.Int32(0);
			{
				var _g1 = 0, _g = size >> 5;
				while(_g1 < _g) {
					var i1 = _g1++;
					this.vm_bitvars[i1] = new noneko.Int32(0);
				}
			}
			this.vm_num_localobject = reader.readUInt16();
			size = reader.readUInt16();
			this.vm_array = new Array();
			this.vm_array[size - 1] = null;
			reader.readUInt16();
			size = reader.readUInt16();
			size = reader.readUInt16();
			size = reader.readUInt16();
			this.vm_res = new Array();
			this.vm_res[3] = new hiscumm.SPUTMResourceList(reader.readUInt16(),new hiscumm.SPUTMRoomFactory());
			this.vm_res[0] = new hiscumm.SPUTMResourceList(reader.readUInt16(),new hiscumm.SCUMMScriptFactory());
			this.vm_res[1] = new hiscumm.SPUTMResourceList(reader.readUInt16(),new hiscumm.SPUTMSoundFactory());
			this.vm_res[4] = new hiscumm.SPUTMResourceList(reader.readUInt16(),new hiscumm.SPUTMCharsetFactory());
			this.vm_res[2] = new hiscumm.SPUTMResourceList(reader.readUInt16(),new hiscumm.SPUTMCostumeFactory());
			this.vm_res[5] = new hiscumm.SPUTMResourceList(reader.readUInt16(),null);
		}break;
		case 2:
		{
			var rooms = this.vm_res[3].res;
			var nfiles = 0;
			size = reader.readUInt16();
			if(size != rooms.length) {
				haxe.Log.trace("Invalid room index block! ( " + size + ", act " + rooms.length + ")",{ fileName : "SPUTM.hx", lineNumber : 599, className : "hiscumm.SPUTM", methodName : "new"});
				return;
			}
			{
				var _g = 0;
				while(_g < size) {
					var i1 = _g++;
					var res = new hiscumm.SPUTMResource();
					rooms[i1] = res;
					res.file = reader.readChar();
					res.room = i1;
					nfiles = (res.file > nfiles?res.file:nfiles);
				}
			}
			if(nfiles > this.vm_files.length) {
				haxe.Log.trace("Warning: files missing! (" + nfiles + " referenced, " + this.vm_files.length + " avail)",{ fileName : "SPUTM.hx", lineNumber : 617, className : "hiscumm.SPUTM", methodName : "new"});
			}
			{
				var _g = 0;
				while(_g < size) {
					var i1 = _g++;
					rooms[i1].offset = reader.readUInt32();
				}
			}
			{
				var _g1 = 1, _g = this.vm_files.length;
				while(_g1 < _g) {
					var i1 = _g1++;
					this.loadResourceOffsets(resources[i1]);
				}
			}
		}break;
		case 3:
		{
			this.vm_res[0].loadResourceIndexes(reader);
		}break;
		case 4:
		{
			this.vm_res[1].loadResourceIndexes(reader);
		}break;
		case 5:
		{
			this.vm_res[2].loadResourceIndexes(reader);
		}break;
		case 6:
		{
			this.vm_res[4].loadResourceIndexes(reader);
		}break;
		case 7:
		{
			this.vm_res[5].loadResourceIndexesAlt(reader);
		}break;
		case 8:
		{
			size = reader.readUInt16();
			while(size != 0) {
				var dim1 = reader.readUInt16();
				var dim2 = reader.readUInt16();
				var atype = hiscumm.SPUTMArray.toArrayType(reader.readUInt16());
				this.writeVar(size,this.defineArray(atype,dim1,dim2),null);
			}
		}break;
		default:{
			haxe.Log.trace("INVALID CHUNK!",{ fileName : "SPUTM.hx", lineNumber : 662, className : "hiscumm.SPUTM", methodName : "new"});
		}break;
		}
	}
	this.vm_actors = new Array();
	this.vm_actors[15] = null;
	{
		var _g = 0;
		while(_g < 16) {
			var i1 = _g++;
			this.vm_actors[i1] = new hiscumm.SPUTMActor(i1);
		}
	}
	this.vm_current_actor = null;
	hiscumm.SCUMMThread.init(this.vm_res[0]);
}}
hiscumm.SPUTM.__name__ = ["hiscumm","SPUTM"];
hiscumm.SPUTM.prototype.curTime = null;
hiscumm.SPUTM.prototype.defineArray = function(type,dim1,dim2) {
	var id = this.getFreeArrayId();
	if(id == -1) return -1;
	this.vm_array[id] = new hiscumm.SPUTMArray(type,dim1,dim2);
	return id;
}
hiscumm.SPUTM.prototype.draw = function() {
	var sx;
	var dx;
	var w;
	var h;
	var x;
	var y;
	var a;
	if(this.view_palette == null) return;
	this.view_camera_x = hiscumm.SCUMMThread.varIn(this.vm_vars[2]);
	if(this.view_camera_x > hiscumm.SCUMMThread.varIn(this.vm_vars[18])) this.view_camera_x = hiscumm.SCUMMThread.varIn(this.vm_vars[18]);
	if(this.view_camera_x > hiscumm.SCUMMThread.varIn(this.vm_vars[17])) this.view_camera_x = hiscumm.SCUMMThread.varIn(this.vm_vars[17]);
	if(this.view_width < 320 || this.view_height < 200 || this.vm_room == null) return;
	h = this.vm_room.height;
	if(this.view_room_start + h != this.view_room_end) haxe.Log.trace("View setup doesn't match the room height!",{ fileName : "SPUTM.hx", lineNumber : 1242, className : "hiscumm.SPUTM", methodName : "draw"});
	if(this.view_room_start + h > this.view_height) h = this.view_height - this.view_room_start;
	if(h <= 0) return;
	w = this.vm_room.width;
	if(w > this.view_width) w = this.view_width;
	sx = Std["int"](this.view_camera_x - w / 2);
	if(sx + w / 2 > this.vm_room.width) sx = this.vm_room.width - w;
	if(sx < 0) sx = 0;
	dx = Std["int"]((this.view_width - w) / 2);
	this.view_data.lock();
	this.view_data.fillRect(this.view_data.rect,-16777216 | 16711711);
	var srect = new noflash.Rectangle(sx,0,w,h);
	var dpoint = new noflash.Point(dx,this.view_room_start);
	this.view_data.copyPixels(this.vm_room.image.data,srect,dpoint,null,hiscumm.SPUTMDisplayPalette.NULL_POINT,false);
	this.view_palette.mapTo(this.view_data);
	this.view_data.unlock();
}
hiscumm.SPUTM.prototype.flip = function() {
	null;
}
hiscumm.SPUTM.prototype.getActor = function(idx) {
	if(idx < this.vm_actors.length) return this.vm_actors[idx];
	return null;
}
hiscumm.SPUTM.prototype.getFreeArrayId = function() {
	var i;
	{
		var _g1 = 1, _g = this.vm_array.length;
		while(_g1 < _g) {
			var i1 = _g1++;
			if(this.vm_array[i1] == null) return i1;
		}
	}
	return -1;
}
hiscumm.SPUTM.prototype.getRoomScript = function(num) {
	if(this.vm_room == null || (num - 200 >= this.vm_room.scripts.length)) return null;
	return this.vm_room.scripts[num - 200];
}
hiscumm.SPUTM.prototype.getTimer = function() {
	return haxe.Timer.stamp() * 1000;
}
hiscumm.SPUTM.prototype.getVar = function(addr) {
	return hiscumm.SCUMMThread.varOut(this.vm_vars[addr]);
}
hiscumm.SPUTM.prototype.handleState = function(state) {
	var r;
	var $e = (state);
	switch( $e[1] ) {
	case 6:
	{
		this.vm_vars[72] = this.vm_next_room.id;
		return hiscumm.SPUTMState.SPUTM_RUN_PRE_EXIT;
	}break;
	case 7:
	{
		if(this.vm_vars[30] != 0) {
			r = hiscumm.SCUMMThread.startScript(0,this.vm_vars[30],null);
			if(r < 0) {
				haxe.Log.trace("Failed to start pre-exit script!",{ fileName : "SPUTM.hx", lineNumber : 955, className : "hiscumm.SPUTM", methodName : "handleState"});
				return hiscumm.SPUTMState.SPUTM_ERROR;
			}
			hiscumm.SCUMMThread.switchToThread(r,hiscumm.SPUTMState.SPUTM_RUN_EXCD);
			return hiscumm.SPUTMState.SPUTM_RUNNING;
		}
		return hiscumm.SPUTMState.SPUTM_RUN_EXCD;
	}break;
	case 8:
	{
		if(this.vm_room != null && this.vm_room.exit != null) {
			r = hiscumm.SCUMMThread.startThread(this.vm_room.exit,0,0,null);
			if(r < 0) {
				haxe.Log.trace("Failed to start room exit script!",{ fileName : "SPUTM.hx", lineNumber : 972, className : "hiscumm.SPUTM", methodName : "handleState"});
				return hiscumm.SPUTMState.SPUTM_ERROR;
			}
			hiscumm.SCUMMThread.switchToThread(r,hiscumm.SPUTMState.SPUTM_RUN_POST_EXIT);
			return hiscumm.SPUTMState.SPUTM_RUNNING;
		}
		return hiscumm.SPUTMState.SPUTM_RUN_POST_EXIT;
	}break;
	case 9:
	{
		if(this.vm_vars[31] != 0) {
			r = hiscumm.SCUMMThread.startScript(0,this.vm_vars[31],null);
			if(r < 0) {
				haxe.Log.trace("Failed to start post-exit script!",{ fileName : "SPUTM.hx", lineNumber : 989, className : "hiscumm.SPUTM", methodName : "handleState"});
				return hiscumm.SPUTMState.SPUTM_ERROR;
			}
			hiscumm.SCUMMThread.switchToThread(r,hiscumm.SPUTMState.SPUTM_SETUP_ROOM);
			return hiscumm.SPUTMState.SPUTM_RUNNING;
		}
		return hiscumm.SPUTMState.SPUTM_SETUP_ROOM;
	}break;
	case 10:
	{
		if(this.vm_next_room == null) {
			return hiscumm.SPUTMState.SPUTM_RUNNING;
		}
		else {
			var room = this.vm_next_room;
			if(room == null) {
				haxe.Log.trace("Invalid room or room isn't loaded!",{ fileName : "SPUTM.hx", lineNumber : 1011, className : "hiscumm.SPUTM", methodName : "handleState"});
				return hiscumm.SPUTMState.SPUTM_ERROR;
			}
			if(room.palettes.length > 0) {
				room.current_palette = room.palettes[0];
				this.view_palette.load(room.current_palette);
				this.view_flags |= hiscumm.SPUTM.VIEW_PALETTE_CHANGED;
			}
			this.vm_vars[17] = Std["int"](this.view_width / 2);
			this.vm_vars[18] = hiscumm.SCUMMThread.varIn(room.width - this.vm_vars[17]);
			this.vm_vars[4] = room.id;
			this.vm_room = room;
		}
		return hiscumm.SPUTMState.SPUTM_RUN_PRE_ENTRY;
	}break;
	case 11:
	{
		if(this.vm_vars[28] != 0) {
			r = hiscumm.SCUMMThread.startScript(0,this.vm_vars[28],null);
			if(r < 0) {
				haxe.Log.trace("Failed to start pre-entry script!",{ fileName : "SPUTM.hx", lineNumber : 1038, className : "hiscumm.SPUTM", methodName : "handleState"});
				return hiscumm.SPUTMState.SPUTM_ERROR;
			}
			hiscumm.SCUMMThread.switchToThread(r,hiscumm.SPUTMState.SPUTM_RUN_ENCD);
			return hiscumm.SPUTMState.SPUTM_RUNNING;
		}
		return hiscumm.SPUTMState.SPUTM_RUN_ENCD;
	}break;
	case 12:
	{
		if(this.vm_room.entry != null) {
			haxe.Log.trace("RUNNING ENTRY",{ fileName : "SPUTM.hx", lineNumber : 1051, className : "hiscumm.SPUTM", methodName : "handleState"});
			r = hiscumm.SCUMMThread.startThread(this.vm_room.entry,0,0,null);
			if(r < 0) {
				haxe.Log.trace("Failed to start room entry script!",{ fileName : "SPUTM.hx", lineNumber : 1055, className : "hiscumm.SPUTM", methodName : "handleState"});
				return hiscumm.SPUTMState.SPUTM_ERROR;
			}
			hiscumm.SCUMMThread.switchToThread(r,hiscumm.SPUTMState.SPUTM_RUN_POST_ENTRY);
			return hiscumm.SPUTMState.SPUTM_RUNNING;
		}
		return hiscumm.SPUTMState.SPUTM_RUN_POST_ENTRY;
	}break;
	case 13:
	{
		if(this.vm_vars[29] != 0) {
			r = hiscumm.SCUMMThread.startScript(0,this.vm_vars[29],null);
			if(r < 0) {
				haxe.Log.trace("Failed to start post-entry script!",{ fileName : "SPUTM.hx", lineNumber : 1071, className : "hiscumm.SPUTM", methodName : "handleState"});
				return hiscumm.SPUTMState.SPUTM_ERROR;
			}
			hiscumm.SCUMMThread.switchToThread(r,hiscumm.SPUTMState.SPUTM_RUNNING);
		}
		return hiscumm.SPUTMState.SPUTM_RUNNING;
	}break;
	default:{
		return hiscumm.SPUTMState.SPUTM_ERROR;
	}break;
	}
}
hiscumm.SPUTM.prototype.incVar = function(addr,value) {
	this.vm_vars[addr] = hiscumm.SCUMMThread.varIn(hiscumm.SCUMMThread.varOut(this.vm_vars[addr]) + value);
}
hiscumm.SPUTM.prototype.initScreens = function(start,end) {
	this.view_room_start = start;
	this.view_room_end = end;
}
hiscumm.SPUTM.prototype.initVars = function() {
	this.vm_vars[48] = 0;
	this.vm_vars[49] = 19;
	this.vm_vars[40] = 1400;
	this.vm_vars[51] = 1;
	this.vm_vars[67] = 3;
	this.vm_vars[76] = 10000;
	this.vm_vars[41] = 320;
	this.vm_vars[54] = 200;
	this.vm_vars[37] = 4;
}
hiscumm.SPUTM.prototype.lastTime = null;
hiscumm.SPUTM.prototype.loadResourceOffsets = function(reader) {
	var resource = new hiscumm.ChunkReader(reader);
	resource.nextChunk();
	if(hiscumm.SPUTMResourceChunk.identify(resource.chunkID) != hiscumm.SPUTMResourceChunkType.CHUNK_LECF) {
		haxe.Log.trace("Invalid resource file (got " + resource.chunkName() + ")",{ fileName : "SPUTM.hx", lineNumber : 702, className : "hiscumm.SPUTM", methodName : "loadResourceOffsets"});
		return false;
	}
	resource.reset();
	resource.nextChunk();
	if(hiscumm.SPUTMResourceChunk.identify(resource.chunkID) != hiscumm.SPUTMResourceChunkType.CHUNK_LOFF) {
		haxe.Log.trace("Invalid resource file (got " + resource.chunkName() + ")",{ fileName : "SPUTM.hx", lineNumber : 710, className : "hiscumm.SPUTM", methodName : "loadResourceOffsets"});
		return false;
	}
	var rooms = this.vm_res[3].res;
	var i;
	var num = reader.readChar();
	{
		var _g = 0;
		while(_g < num) {
			var i1 = _g++;
			var room_no = reader.readChar();
			if(room_no > rooms.length) {
				haxe.Log.trace("Bad room number? (" + room_no + ")",{ fileName : "SPUTM.hx", lineNumber : 722, className : "hiscumm.SPUTM", methodName : "loadResourceOffsets"});
				return false;
			}
			rooms[room_no].offset = reader.readUInt32();
		}
	}
	return true;
}
hiscumm.SPUTM.prototype.nukeArray = function(idx) {
	this.vm_array[idx] = null;
}
hiscumm.SPUTM.prototype.num_bitvars = null;
hiscumm.SPUTM.prototype.onTick = function(ms) {
	try {
		var r = hiscumm.SCUMMThread.processThreads(1,this.curTime);
		if(r < 0) {
			haxe.Log.trace("Script error!",{ fileName : "SPUTM.hx", lineNumber : 1150, className : "hiscumm.SPUTM", methodName : "onTick"});
			this.stop();
			return;
		}
	}
	catch( $e4 ) {
		{
			var unknown = $e4;
			{
				haxe.Log.trace("Internal exception, aborting! (state=" + hiscumm.SCUMMThread.vm_state + ")",{ fileName : "SPUTM.hx", lineNumber : 1157, className : "hiscumm.SPUTM", methodName : "onTick"});
				haxe.Log.trace(unknown,{ fileName : "SPUTM.hx", lineNumber : 1158, className : "hiscumm.SPUTM", methodName : "onTick"});
				this.stop();
			}
		}
	}
	this.processPalette();
	if((this.view_flags & hiscumm.SPUTM.VIEW_PALETTE_CHANGED) > 0) {
		this.updatePalette();
		this.view_flags &= ~hiscumm.SPUTM.VIEW_PALETTE_CHANGED;
	}
	this.draw();
	this.updateActors();
	this.flip();
}
hiscumm.SPUTM.prototype.onTime = function() {
	this.curTime = haxe.Timer.stamp();
	this.onTick(this.curTime - this.lastTime);
	this.lastTime = this.curTime;
}
hiscumm.SPUTM.prototype.processPalette = function() {
	null;
}
hiscumm.SPUTM.prototype.readArray = function(idx,y,x) {
	var array = this.vm_array[idx];
	return array.get(y,x);
}
hiscumm.SPUTM.prototype.readVar = function(addr,thread) {
	var idx;
	if((addr & 32768) > 0) {
		idx = (addr & 32767);
		if(idx >= this.num_bitvars) {
			haxe.Log.trace("Invalid bit var " + idx,{ fileName : "SPUTM.hx", lineNumber : 815, className : "hiscumm.SPUTM", methodName : "readVar"});
			thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
			return 0;
		}
		return new noneko.Int32(new noneko.Int32(this.vm_bitvars[idx >> 5].value >> (idx & 31)).value & new noneko.Int32(1).value).value;
	}
	else if((addr & 16384) > 0) {
		idx = (addr & 16383);
		if(thread == null || idx >= thread.vars.length) {
			haxe.Log.trace("Invalid local var " + idx,{ fileName : "SPUTM.hx", lineNumber : 829, className : "hiscumm.SPUTM", methodName : "readVar"});
			thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
			return 0;
		}
		return hiscumm.SCUMMThread.varOut(thread.vars[idx]);
	}
	else {
		idx = (addr & 16383);
		if(addr >= this.vm_vars.length) {
			haxe.Log.trace("Invalid global var " + idx,{ fileName : "SPUTM.hx", lineNumber : 841, className : "hiscumm.SPUTM", methodName : "readVar"});
			thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
			return 0;
		}
		return hiscumm.SCUMMThread.varOut(this.vm_vars[idx]);
	}
}
hiscumm.SPUTM.prototype.run = function() {
	this.lastTime = this.getTimer();
	this.time = new haxe.Timer(hiscumm.SPUTM.UPDATE_INTERVAL);
	this.time.run = function() {
		hiscumm.SPUTM.instance.onTime();
	}
}
hiscumm.SPUTM.prototype.setNextRoom = function(idx) {
	var room = this.vm_res[3].res[idx].instance;
	if(room != null) {
		this.vm_next_room = room;
		return true;
	}
	else {
		return false;
	}
}
hiscumm.SPUTM.prototype.setSize = function(width,height) {
	this.view_width = width;
	this.view_height = height;
	if(this.view_data != null) this.view_data.dispose();
	this.view_data = new justjs.BitmapData(this.view_width,this.view_height,false,-65281);
	js.Lib.document.getElementById("sputm:display").appendChild(this.view_data.canvas);
	this.view_data.canvas.setAttribute("id","SPUTMOut");
	this.view_data.canvas.setAttribute("style","border: 2px solid black");
	this.view.bitmapData = this.view_data;
}
hiscumm.SPUTM.prototype.setVar = function(addr,value) {
	this.vm_vars[addr] = ((((value < 0)?(65536 + value):value)) & 65535);
}
hiscumm.SPUTM.prototype.stop = function() {
	this.time.stop();
}
hiscumm.SPUTM.prototype.time = null;
hiscumm.SPUTM.prototype.updateActors = function() {
	null;
}
hiscumm.SPUTM.prototype.updatePalette = function() {
	null;
}
hiscumm.SPUTM.prototype.view = null;
hiscumm.SPUTM.prototype.view_camera_x = null;
hiscumm.SPUTM.prototype.view_data = null;
hiscumm.SPUTM.prototype.view_flags = null;
hiscumm.SPUTM.prototype.view_height = null;
hiscumm.SPUTM.prototype.view_palette = null;
hiscumm.SPUTM.prototype.view_room_end = null;
hiscumm.SPUTM.prototype.view_room_start = null;
hiscumm.SPUTM.prototype.view_width = null;
hiscumm.SPUTM.prototype.vm_actors = null;
hiscumm.SPUTM.prototype.vm_array = null;
hiscumm.SPUTM.prototype.vm_bitvars = null;
hiscumm.SPUTM.prototype.vm_current_actor = null;
hiscumm.SPUTM.prototype.vm_files = null;
hiscumm.SPUTM.prototype.vm_next_room = null;
hiscumm.SPUTM.prototype.vm_num_localobject = null;
hiscumm.SPUTM.prototype.vm_res = null;
hiscumm.SPUTM.prototype.vm_room = null;
hiscumm.SPUTM.prototype.vm_vars = null;
hiscumm.SPUTM.prototype.writeArray = function(idx,y,x,value) {
	var array = this.vm_array[idx];
	var real_value;
	array.set(y,x,value);
}
hiscumm.SPUTM.prototype.writeVar = function(addr,value,thread) {
	var idx;
	if((addr & 32768) > 0) {
		idx = (addr & 32767);
		if(idx > this.num_bitvars) {
			haxe.Log.trace("Invalid bit var " + idx,{ fileName : "SPUTM.hx", lineNumber : 864, className : "hiscumm.SPUTM", methodName : "writeVar"});
			thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
			return;
		}
		this.vm_bitvars[idx >> 5] = new noneko.Int32(this.vm_bitvars[idx >> 5].value & new noneko.Int32(~new noneko.Int32(new noneko.Int32(1).value << (idx & 31)).value).value);
		this.vm_bitvars[idx >> 5] = new noneko.Int32(this.vm_bitvars[idx >> 5].value | new noneko.Int32((value & 1) << (idx & 31)).value);
	}
	else if((addr & 16384) > 0) {
		idx = (addr & 16383);
		if(thread == null || idx >= thread.vars.length) {
			haxe.Log.trace("Invalid local var " + idx,{ fileName : "SPUTM.hx", lineNumber : 885, className : "hiscumm.SPUTM", methodName : "writeVar"});
			thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
			return;
		}
		thread.vars[idx] = ((((value < 0)?(65536 + value):value)) & 65535);
	}
	else {
		idx = (addr & 16383);
		if(addr >= this.vm_vars.length) {
			haxe.Log.trace("Invalid global var " + idx,{ fileName : "SPUTM.hx", lineNumber : 897, className : "hiscumm.SPUTM", methodName : "writeVar"});
			thread.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
			return;
		}
		this.vm_vars[idx] = ((((value < 0)?(65536 + value):value)) & 65535);
	}
}
hiscumm.SPUTM.prototype.__class__ = hiscumm.SPUTM;
noneko.Int32 = function(in_value) { if( in_value === $_ ) return; {
	this.value = in_value;
}}
noneko.Int32.__name__ = ["noneko","Int32"];
noneko.Int32.add = function(a,b) {
	return new noneko.Int32(a.value + b.value);
}
noneko.Int32.address = function(addr) {
	return new noneko.Int32(0);
}
noneko.Int32.and = function(a,b) {
	return new noneko.Int32(a.value & b.value);
}
noneko.Int32.compare = function(a,b) {
	return (((a.value == b.value)?0:((a.value < b.value)?-1:1)));
}
noneko.Int32.complement = function(a) {
	return new noneko.Int32(~a.value);
}
noneko.Int32.div = function(a,b) {
	return new noneko.Int32(Math.round(a.value / b.value));
}
noneko.Int32.make = function(a,b) {
	return new noneko.Int32((a << 16) + b);
}
noneko.Int32.mod = function(a,b) {
	return new noneko.Int32(a.value % b.value);
}
noneko.Int32.mul = function(a,b) {
	return new noneko.Int32(a.value * b.value);
}
noneko.Int32.neg = function(a) {
	return new noneko.Int32(-a.value);
}
noneko.Int32.ofInt = function(a) {
	return new noneko.Int32(a);
}
noneko.Int32.or = function(a,b) {
	return new noneko.Int32(a.value | b.value);
}
noneko.Int32.read = function(i,b) {
	var f = (b?$closure(i,"readUInt16B"):$closure(i,"readUInt16"));
	var a = f();
	return (b?new noneko.Int32((a << 16) + f()):new noneko.Int32((f() << 16) + a));
}
noneko.Int32.shl = function(a,b) {
	return new noneko.Int32(a.value << b);
}
noneko.Int32.shr = function(a,b) {
	return new noneko.Int32(a.value >> b);
}
noneko.Int32.sub = function(a,b) {
	return new noneko.Int32(a.value - b.value);
}
noneko.Int32.toFloat = function(a) {
	return function($this) {
		var $r;
		var tmp = a.value;
		$r = (Std["is"](tmp,Float)?tmp:function($this) {
			var $r;
			throw "Class cast error";
			return $r;
		}($this));
		return $r;
	}(this);
}
noneko.Int32.toInt = function(a) {
	return a.value;
}
noneko.Int32.ushr = function(a,b) {
	return new noneko.Int32(a.value >>> b);
}
noneko.Int32.write = function(o,i,b) {
	var low = new noneko.Int32(i.value & new noneko.Int32(65535).value);
	var high = new noneko.Int32(i.value >>> 16);
	if(b) {
		o.writeUInt16B(high);
		o.writeUInt16B(low);
	}
	else {
		o.writeUInt16(low);
		o.writeUInt16(high);
	}
}
noneko.Int32.xor = function(a,b) {
	return new noneko.Int32(a.value ^ b.value);
}
noneko.Int32.prototype.value = null;
noneko.Int32.prototype.__class__ = noneko.Int32;
haxe.Firebug = function() { }
haxe.Firebug.__name__ = ["haxe","Firebug"];
haxe.Firebug.detect = function() {
	try {
		return console != null && console.error != null;
	}
	catch( $e5 ) {
		{
			var e = $e5;
			{
				return false;
			}
		}
	}
}
haxe.Firebug.redirectTraces = function() {
	haxe.Log.trace = $closure(haxe.Firebug,"trace");
	js.Lib.setErrorHandler($closure(haxe.Firebug,"onError"));
}
haxe.Firebug.onError = function(err,stack) {
	var buf = err + "\n";
	{
		var _g = 0;
		while(_g < stack.length) {
			var s = stack[_g];
			++_g;
			buf += "Called from " + s + "\n";
		}
	}
	haxe.Firebug.trace(buf,null);
	return true;
}
haxe.Firebug.trace = function(v,inf) {
	var type = (inf != null && inf.customParams != null?inf.customParams[0]:null);
	if(type != "warn" && type != "info" && type != "debug" && type != "error") type = (inf == null?"error":"log");
	console[type](((inf == null?"":inf.fileName + ":" + inf.lineNumber + " : ")) + Std.string(v));
}
haxe.Firebug.prototype.__class__ = haxe.Firebug;
IntIter = function(min,max) { if( min === $_ ) return; {
	this.min = min;
	this.max = max;
}}
IntIter.__name__ = ["IntIter"];
IntIter.prototype.hasNext = function() {
	return this.min < this.max;
}
IntIter.prototype.max = null;
IntIter.prototype.min = null;
IntIter.prototype.next = function() {
	return this.min++;
}
IntIter.prototype.__class__ = IntIter;
haxe.Timer = function(time) { if( time === $_ ) return; {
	this.id = haxe.Timer.arr.length;
	haxe.Timer.arr[this.id] = this;
	this.timerId = window.setInterval("haxe.Timer.arr[" + this.id + "].run();",time);
}}
haxe.Timer.__name__ = ["haxe","Timer"];
haxe.Timer.delayed = function(f,time) {
	return function() {
		var t = new haxe.Timer(time);
		t.run = function() {
			t.stop();
			f();
		}
	}
}
haxe.Timer.queue = function(f,time) {
	haxe.Timer.fqueue.push(f);
	(haxe.Timer.delayed(function() {
		(haxe.Timer.fqueue.shift())();
	},(time == null?0:time)))();
}
haxe.Timer.stamp = function() {
	return Date.now().getTime() / 1000;
}
haxe.Timer.prototype.id = null;
haxe.Timer.prototype.run = function() {
	null;
}
haxe.Timer.prototype.stop = function() {
	if(this.id == null) return;
	window.clearInterval(this.timerId);
	haxe.Timer.arr[this.id] = null;
	if(this.id > 100 && this.id == haxe.Timer.arr.length - 1) {
		var p = this.id - 1;
		while(p >= 0 && haxe.Timer.arr[p] == null) p--;
		haxe.Timer.arr = haxe.Timer.arr.slice(0,p + 1);
	}
	this.id = null;
}
haxe.Timer.prototype.timerId = null;
haxe.Timer.prototype.__class__ = haxe.Timer;
hiscumm.JSTest = function() { }
hiscumm.JSTest.__name__ = ["hiscumm","JSTest"];
hiscumm.JSTest.resources = null;
hiscumm.JSTest.engine = null;
hiscumm.JSTest.main = function() {
	haxe.Log.trace("Preloading resources",{ fileName : "JSTest.hx", lineNumber : 38, className : "hiscumm.JSTest", methodName : "main"});
	hiscumm.JSTest.resources = new Array();
	hiscumm.JSTest.resources.push(utils.JSByteIO.fromURL("SCUMMC.000"));
	hiscumm.JSTest.resources.push(utils.JSByteIO.fromURL("SCUMMC.001"));
	haxe.Log.trace("Resources loaded",{ fileName : "JSTest.hx", lineNumber : 42, className : "hiscumm.JSTest", methodName : "main"});
	hiscumm.JSTest.engine = new hiscumm.SPUTM(hiscumm.JSTest.resources);
	haxe.Log.trace("Engine init",{ fileName : "JSTest.hx", lineNumber : 46, className : "hiscumm.JSTest", methodName : "main"});
	hiscumm.JSTest.engine.run();
}
hiscumm.JSTest.prototype.__class__ = hiscumm.JSTest;
Std = function() { }
Std.__name__ = ["Std"];
Std["is"] = function(v,t) {
	return js.Boot.__instanceof(v,t);
}
Std.string = function(s) {
	return js.Boot.__string_rec(s,"");
}
Std["int"] = function(x) {
	if(x < 0) return Math.ceil(x);
	return Math.floor(x);
}
Std.bool = function(x) {
	return (x !== 0 && x != null && x !== false);
}
Std.parseInt = function(x) {
	{
		var v = parseInt(x);
		if(Math.isNaN(v)) return null;
		return v;
	}
}
Std.parseFloat = function(x) {
	return parseFloat(x);
}
Std.chr = function(x) {
	return String.fromCharCode(x);
}
Std.ord = function(x) {
	if(x == "") return null;
	else return x.charCodeAt(0);
}
Std.random = function(x) {
	return Math.floor(Math.random() * x);
}
Std.resource = function(name) {
	return js.Boot.__res[name];
}
Std.prototype.__class__ = Std;
List = function(p) { if( p === $_ ) return; {
	this.length = 0;
}}
List.__name__ = ["List"];
List.prototype.add = function(item) {
	var x = [item,null];
	if(this.h == null) this.h = x;
	else this.q[1] = x;
	this.q = x;
	this.length++;
}
List.prototype.clear = function() {
	this.h = null;
	this.length = 0;
}
List.prototype.filter = function(f) {
	var l2 = new List();
	var l = this.h;
	while(l != null) {
		var v = l[0];
		l = l[1];
		if(f(v)) l2.add(v);
	}
	return l2;
}
List.prototype.first = function() {
	return (this.h == null?null:this.h[0]);
}
List.prototype.h = null;
List.prototype.isEmpty = function() {
	return (this.h == null);
}
List.prototype.iterator = function() {
	return { h : this.h, hasNext : function() {
		return (this.h != null);
	}, next : function() {
		{
			if(this.h == null) return null;
			var x = this.h[0];
			this.h = this.h[1];
			return x;
		}
	}}
}
List.prototype.join = function(sep) {
	var s = new StringBuf();
	var first = true;
	var l = this.h;
	while(l != null) {
		if(first) first = false;
		else s.add(sep);
		s.add(l[0]);
		l = l[1];
	}
	return s.toString();
}
List.prototype.last = function() {
	return (this.q == null?null:this.q[0]);
}
List.prototype.length = null;
List.prototype.map = function(f) {
	var b = new List();
	var l = this.h;
	while(l != null) {
		var v = l[0];
		l = l[1];
		b.add(f(v));
	}
	return b;
}
List.prototype.pop = function() {
	if(this.h == null) return null;
	var x = this.h[0];
	this.h = this.h[1];
	if(this.h == null) this.q = null;
	this.length--;
	return x;
}
List.prototype.push = function(item) {
	var x = [item,this.h];
	this.h = x;
	if(this.q == null) this.q = x;
	this.length++;
}
List.prototype.q = null;
List.prototype.remove = function(v) {
	var prev = null;
	var l = this.h;
	while(l != null) {
		if(l[0] == v) {
			if(prev == null) this.h = l[1];
			else prev[1] = l[1];
			if(this.q == l) this.q = prev;
			this.length--;
			return true;
		}
		prev = l;
		l = l[1];
	}
	return false;
}
List.prototype.toString = function() {
	var s = new StringBuf();
	var first = true;
	var l = this.h;
	s.add("{");
	while(l != null) {
		if(first) first = false;
		else s.add(", ");
		s.add(l[0]);
		l = l[1];
	}
	s.add("}");
	return s.toString();
}
List.prototype.__class__ = List;
hiscumm.SCUMMStack = function(p) { if( p === $_ ) return; {
	this.list = new List();
}}
hiscumm.SCUMMStack.__name__ = ["hiscumm","SCUMMStack"];
hiscumm.SCUMMStack.prototype.list = null;
hiscumm.SCUMMStack.prototype.pop = function() {
	return hiscumm.SCUMMThread.varOut(this.list.pop());
}
hiscumm.SCUMMStack.prototype.push = function(val) {
	this.list.push(((((val < 0)?(65536 + val):val)) & 65535));
}
hiscumm.SCUMMStack.prototype.__class__ = hiscumm.SCUMMStack;
hiscumm.SCUMMThreadState = { __ename__ : ["hiscumm","SCUMMThreadState"], __constructs__ : ["THREAD_NONE","THREAD_STOPPED","THREAD_RUNNING","THREAD_PENDED","THREAD_DELAYED","THREAD_FROZEN"] }
hiscumm.SCUMMThreadState.THREAD_DELAYED = ["THREAD_DELAYED",4];
hiscumm.SCUMMThreadState.THREAD_DELAYED.toString = $estr;
hiscumm.SCUMMThreadState.THREAD_DELAYED.__enum__ = hiscumm.SCUMMThreadState;
hiscumm.SCUMMThreadState.THREAD_FROZEN = ["THREAD_FROZEN",5];
hiscumm.SCUMMThreadState.THREAD_FROZEN.toString = $estr;
hiscumm.SCUMMThreadState.THREAD_FROZEN.__enum__ = hiscumm.SCUMMThreadState;
hiscumm.SCUMMThreadState.THREAD_NONE = ["THREAD_NONE",0];
hiscumm.SCUMMThreadState.THREAD_NONE.toString = $estr;
hiscumm.SCUMMThreadState.THREAD_NONE.__enum__ = hiscumm.SCUMMThreadState;
hiscumm.SCUMMThreadState.THREAD_PENDED = ["THREAD_PENDED",3];
hiscumm.SCUMMThreadState.THREAD_PENDED.toString = $estr;
hiscumm.SCUMMThreadState.THREAD_PENDED.__enum__ = hiscumm.SCUMMThreadState;
hiscumm.SCUMMThreadState.THREAD_RUNNING = ["THREAD_RUNNING",2];
hiscumm.SCUMMThreadState.THREAD_RUNNING.toString = $estr;
hiscumm.SCUMMThreadState.THREAD_RUNNING.__enum__ = hiscumm.SCUMMThreadState;
hiscumm.SCUMMThreadState.THREAD_STOPPED = ["THREAD_STOPPED",1];
hiscumm.SCUMMThreadState.THREAD_STOPPED.toString = $estr;
hiscumm.SCUMMThreadState.THREAD_STOPPED.__enum__ = hiscumm.SCUMMThreadState;
hiscumm.SCUMMThread = function(in_id) { if( in_id === $_ ) return; {
	this.id = in_id;
	this.script = null;
	this.flags = 0;
	this.ptr = 0;
	this.op_start = 0;
	this.cycle = 0;
	this.delay = 0;
	this.parent = null;
	this.vars = new Array();
	this.vars[15] = 0;
	this.override_stack = new List();
	this.state = hiscumm.SCUMMThreadState.THREAD_STOPPED;
	this.next_state = hiscumm.SPUTMState.SPUTM_NONE;
	this.return_state = hiscumm.SPUTMState.SPUTM_NONE;
	this.script = null;
}}
hiscumm.SCUMMThread.__name__ = ["hiscumm","SCUMMThread"];
hiscumm.SCUMMThread.optable = null;
hiscumm.SCUMMThread.suboptable = null;
hiscumm.SCUMMThread.vm_threads = null;
hiscumm.SCUMMThread.vm_current_thread = null;
hiscumm.SCUMMThread.vm_next_thread = null;
hiscumm.SCUMMThread.vm_state = null;
hiscumm.SCUMMThread.vm_cycle = null;
hiscumm.SCUMMThread.vm_scripts = null;
hiscumm.SCUMMThread.vm_stack = null;
hiscumm.SCUMMThread.vm_time = null;
hiscumm.SCUMMThread.init = function(scripts) {
	hiscumm.SCUMMThread.vm_stack = new hiscumm.SCUMMStack();
	hiscumm.SCUMMThread.vm_scripts = scripts;
	hiscumm.SCUMMThread.vm_threads = new Array();
	hiscumm.SCUMMThread.vm_threads[15] = null;
	{
		var _g = 0;
		while(_g < 16) {
			var i = _g++;
			hiscumm.SCUMMThread.vm_threads[i] = new hiscumm.SCUMMThread(i);
		}
	}
	hiscumm.SCUMMThread.vm_current_thread = null;
	hiscumm.SCUMMThread.vm_next_thread = null;
	hiscumm.SCUMMThread.vm_cycle = 0;
	hiscumm.SCUMMThread.vm_time = 0;
	hiscumm.SCUMMThread.vm_state = hiscumm.SPUTMState.SPUTM_BOOT;
}
hiscumm.SCUMMThread.startScript = function(flags,num,args) {
	var script;
	if(num >= 200) {
		if((script = hiscumm.SPUTM.instance.getRoomScript(num)) == null) {
			haxe.Log.trace("Bad local script " + num,{ fileName : "SCUMM.hx", lineNumber : 388, className : "hiscumm.SCUMMThread", methodName : "startScript"});
			return -1;
		}
	}
	else {
		script = hiscumm.SCUMMThread.vm_scripts.loadResource(num);
		if(script == null) {
			haxe.Log.trace("Failed to load global script " + num,{ fileName : "SCUMM.hx", lineNumber : 398, className : "hiscumm.SCUMMThread", methodName : "startScript"});
			return -1;
		}
	}
	if((flags & hiscumm.SCUMMThread.THREAD_FLAG_RECURSIVE) != 0) hiscumm.SCUMMThread.stopScript(num);
	return hiscumm.SCUMMThread.startThread(function($this) {
		var $r;
		var tmp = script;
		$r = (Std["is"](tmp,hiscumm.SCUMMScript)?tmp:function($this) {
			var $r;
			throw "Class cast error";
			return $r;
		}($this));
		return $r;
	}(this),0,flags,args);
}
hiscumm.SCUMMThread.stopScript = function(id) {
	var i = 0;
	var n = 0;
	{
		var _g1 = 0, _g = hiscumm.SCUMMThread.vm_threads.length;
		while(_g1 < _g) {
			var i1 = _g1++;
			var thread = hiscumm.SCUMMThread.vm_threads[i1];
			if(thread.state == hiscumm.SCUMMThreadState.THREAD_STOPPED || thread.script == null || thread.script.id != id) continue;
			thread.stop();
			n++;
		}
	}
	return n;
}
hiscumm.SCUMMThread.startThread = function(script,ptr,flags,args) {
	var i;
	var thread;
	thread = hiscumm.SCUMMThread.getFreeThread();
	if(thread == null) {
		haxe.Log.trace("No Threads left to start script " + script.id,{ fileName : "SCUMM.hx", lineNumber : 441, className : "hiscumm.SCUMMThread", methodName : "startThread"});
		return -1;
	}
	thread.start(script,flags,ptr,hiscumm.SCUMMThread.vm_cycle,args,null);
	return thread.id;
}
hiscumm.SCUMMThread.isScriptRunning = function(id) {
	var thread = null;
	{
		var _g = 0, _g1 = hiscumm.SCUMMThread.vm_threads;
		while(_g < _g1.length) {
			var thread1 = _g1[_g];
			++_g;
			if(thread1.state == hiscumm.SCUMMThreadState.THREAD_STOPPED || thread1.script == null || thread1.script.id != id) continue;
			return true;
		}
	}
	return false;
}
hiscumm.SCUMMThread.getFreeThread = function() {
	var thread = null;
	{
		var _g = 0, _g1 = hiscumm.SCUMMThread.vm_threads;
		while(_g < _g1.length) {
			var thread1 = _g1[_g];
			++_g;
			if(thread1.state == hiscumm.SCUMMThreadState.THREAD_STOPPED) return thread1;
		}
	}
	return null;
}
hiscumm.SCUMMThread.switchToThread = function(thid,next_state) {
	var thread = hiscumm.SCUMMThread.vm_threads[thid];
	hiscumm.SCUMMThread.vm_current_thread.state = hiscumm.SCUMMThreadState.THREAD_PENDED;
	thread.parent = hiscumm.SCUMMThread.vm_current_thread;
	thread.next_state = next_state;
	hiscumm.SCUMMThread.vm_current_thread = thread;
}
hiscumm.SCUMMThread.processThreads = function(cycles,now) {
	var i = 0;
	var r = 0;
	var delta = 0;
	var now1 = 0;
	var parent = null;
	var thread = null;
	while(cycles > 0) {
		var $e = (hiscumm.SCUMMThread.vm_state);
		switch( $e[1] ) {
		case 0:
		{
			return -1;
		}break;
		case 2:
		{
			haxe.Log.trace("boot state",{ fileName : "SCUMM.hx", lineNumber : 505, className : "hiscumm.SCUMMThread", methodName : "processThreads"});
			r = hiscumm.SCUMMThread.startScript(0,1,null);
			haxe.Log.trace("Started",{ fileName : "SCUMM.hx", lineNumber : 507, className : "hiscumm.SCUMMThread", methodName : "processThreads"});
			if(r < 0) {
				haxe.Log.trace("Failed to start boot script!",{ fileName : "SCUMM.hx", lineNumber : 510, className : "hiscumm.SCUMMThread", methodName : "processThreads"});
				return r;
			}
			hiscumm.SCUMMThread.vm_state = hiscumm.SPUTMState.SPUTM_BEGIN_CYCLE;
		}break;
		case 3:
		{
			if(now1 < hiscumm.SCUMMThread.vm_time) delta = 0;
			else delta = now1 - hiscumm.SCUMMThread.vm_time;
			{
				var _g = 0, _g1 = hiscumm.SCUMMThread.vm_threads;
				while(_g < _g1.length) {
					var thread1 = _g1[_g];
					++_g;
					if(thread1.state != hiscumm.SCUMMThreadState.THREAD_DELAYED) continue;
					if((thread1.flags & hiscumm.SCUMMThread.THREAD_FLAG_DELAYED) == 0) thread1.flags |= hiscumm.SCUMMThread.THREAD_FLAG_DELAYED;
					else if(thread1.delay > delta) thread1.delay -= delta;
					else {
						thread1.delay = 0;
						thread1.flags &= -3;
						thread1.state = hiscumm.SCUMMThreadState.THREAD_RUNNING;
					}
				}
			}
			i = hiscumm.SPUTM.instance.getVar(19);
			hiscumm.SPUTM.instance.setVar(46,0);
			hiscumm.SPUTM.instance.incVar(11,i);
			hiscumm.SPUTM.instance.incVar(12,i);
			hiscumm.SPUTM.instance.incVar(13,i);
			hiscumm.SCUMMThread.vm_state = hiscumm.SPUTMState.SPUTM_RUNNING;
			hiscumm.SCUMMThread.vm_time = now1;
		}break;
		case 4:
		{
			parent = hiscumm.SCUMMThread.vm_current_thread;
			hiscumm.SCUMMThread.vm_current_thread = hiscumm.SCUMMThread.vm_next_thread;
			hiscumm.SCUMMThread.vm_next_thread = null;
			hiscumm.SCUMMThread.vm_current_thread.parent = parent;
			if(parent != null) parent.state = hiscumm.SCUMMThreadState.THREAD_PENDED;
			hiscumm.SCUMMThread.vm_state = hiscumm.SPUTMState.SPUTM_RUNNING;
		}break;
		case 5:
		{
			cycles--;
			hiscumm.SCUMMThread.vm_cycle++;
			if(hiscumm.SCUMMThread.vm_current_thread == null) {
				i = 0;
				{
					var _g = 0, _g1 = hiscumm.SCUMMThread.vm_threads;
					while(_g < _g1.length) {
						var thread1 = _g1[_g];
						++_g;
						if(thread1.state == hiscumm.SCUMMThreadState.THREAD_RUNNING && thread1.cycle <= hiscumm.SCUMMThread.vm_cycle) break;
						i++;
					}
				}
				if(i >= hiscumm.SCUMMThread.vm_threads.length) {
					cycles--;
					hiscumm.SCUMMThread.vm_cycle++;
					hiscumm.SCUMMThread.vm_state = hiscumm.SPUTMState.SPUTM_BEGIN_CYCLE;
					continue;
				}
				hiscumm.SCUMMThread.vm_current_thread = hiscumm.SCUMMThread.vm_threads[i];
			}
			var res_state = hiscumm.SCUMMThread.vm_current_thread.run();
			if(res_state == hiscumm.SPUTMState.SPUTM_ERROR) {
				haxe.Log.trace("Error running script",{ fileName : "SCUMM.hx", lineNumber : 594, className : "hiscumm.SCUMMThread", methodName : "processThreads"});
				return -1;
			}
			else if(res_state != hiscumm.SPUTMState.SPUTM_NONE) {
				haxe.Log.trace("switch to " + res_state,{ fileName : "SCUMM.hx", lineNumber : 599, className : "hiscumm.SCUMMThread", methodName : "processThreads"});
				hiscumm.SCUMMThread.vm_state = res_state;
				continue;
			}
			if(hiscumm.SCUMMThread.vm_current_thread.cycle <= hiscumm.SCUMMThread.vm_cycle) hiscumm.SCUMMThread.vm_current_thread.cycle = hiscumm.SCUMMThread.vm_cycle + 1;
			if(hiscumm.SCUMMThread.vm_current_thread.next_state != hiscumm.SPUTMState.SPUTM_NONE) {
				hiscumm.SCUMMThread.vm_state = hiscumm.SCUMMThread.vm_current_thread.next_state;
				parent = hiscumm.SCUMMThread.vm_current_thread.parent;
				if(parent != null) parent.state = hiscumm.SCUMMThreadState.THREAD_RUNNING;
				hiscumm.SCUMMThread.vm_current_thread.next_state = hiscumm.SPUTMState.SPUTM_NONE;
				hiscumm.SCUMMThread.vm_current_thread.parent = null;
				hiscumm.SCUMMThread.vm_current_thread = parent;
				continue;
			}
			if(hiscumm.SCUMMThread.vm_current_thread.parent != null && hiscumm.SCUMMThread.vm_current_thread.parent.state == hiscumm.SCUMMThreadState.THREAD_PENDED) {
				parent = hiscumm.SCUMMThread.vm_current_thread.parent;
				hiscumm.SCUMMThread.vm_current_thread.parent = null;
				parent.state = hiscumm.SCUMMThreadState.THREAD_RUNNING;
				hiscumm.SCUMMThread.vm_current_thread = parent;
				haxe.Log.trace("switch to parent (" + parent + ")",{ fileName : "SCUMM.hx", lineNumber : 633, className : "hiscumm.SCUMMThread", methodName : "processThreads"});
				continue;
			}
			else {
				hiscumm.SCUMMThread.vm_current_thread = null;
			}
		}break;
		default:{
			hiscumm.SCUMMThread.vm_state = hiscumm.SPUTM.instance.handleState(hiscumm.SCUMMThread.vm_state);
			if(hiscumm.SCUMMThread.vm_state == hiscumm.SPUTMState.SPUTM_ERROR) {
				haxe.Log.trace("Invalid State! " + hiscumm.SCUMMThread.vm_state,{ fileName : "SCUMM.hx", lineNumber : 647, className : "hiscumm.SCUMMThread", methodName : "processThreads"});
				return -1;
			}
		}break;
		}
	}
	return r;
}
hiscumm.SCUMMThread.varIn = function(x) {
	return ((((x < 0)?(65536 + x):x)) & 65535);
}
hiscumm.SCUMMThread.varOut = function(x) {
	return (((x & 32768) != 0)?x - 65536:x);
}
hiscumm.SCUMMThread.prototype.beginOverride = function() {
	if(this.script.code.tell() + 3 > this.script.size) return false;
	this.override_stack.push(this.script.code.tell());
	return true;
}
hiscumm.SCUMMThread.prototype.cycle = null;
hiscumm.SCUMMThread.prototype.delay = null;
hiscumm.SCUMMThread.prototype.doOp = function() {
	var r;
	var op;
	op = this.script.code.readChar();
	if(hiscumm.SCUMMThread.optable[op] == null) {
		haxe.Log.trace(op + " not implemented!",{ fileName : "SCUMM.hx", lineNumber : 205, className : "hiscumm.SCUMMThread", methodName : "doOp"});
		this.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
		return;
	}
	hiscumm.SCUMMThread.optable[op](hiscumm.SPUTM.instance,hiscumm.SCUMMThread.vm_stack,this);
	if(this.return_state == hiscumm.SPUTMState.SPUTM_ERROR) {
		haxe.Log.trace("Error execing opcode " + op + " in script " + this.script.id + " @ " + this.ptr,{ fileName : "SCUMM.hx", lineNumber : 214, className : "hiscumm.SCUMMThread", methodName : "doOp"});
		haxe.Log.trace(this.script.code.readChar(),{ fileName : "SCUMM.hx", lineNumber : 215, className : "hiscumm.SCUMMThread", methodName : "doOp"});
		haxe.Log.trace(this.script.code.readChar(),{ fileName : "SCUMM.hx", lineNumber : 216, className : "hiscumm.SCUMMThread", methodName : "doOp"});
		haxe.Log.trace(this.script.code.readChar(),{ fileName : "SCUMM.hx", lineNumber : 217, className : "hiscumm.SCUMMThread", methodName : "doOp"});
		haxe.Log.trace(this.script.code.readChar(),{ fileName : "SCUMM.hx", lineNumber : 218, className : "hiscumm.SCUMMThread", methodName : "doOp"});
		haxe.Log.trace(this.script.code.readChar(),{ fileName : "SCUMM.hx", lineNumber : 219, className : "hiscumm.SCUMMThread", methodName : "doOp"});
		haxe.Log.trace(this.script.code.readChar(),{ fileName : "SCUMM.hx", lineNumber : 220, className : "hiscumm.SCUMMThread", methodName : "doOp"});
		haxe.Log.trace(this.script.code.readChar(),{ fileName : "SCUMM.hx", lineNumber : 221, className : "hiscumm.SCUMMThread", methodName : "doOp"});
		haxe.Log.trace(this.script.code.readChar(),{ fileName : "SCUMM.hx", lineNumber : 222, className : "hiscumm.SCUMMThread", methodName : "doOp"});
	}
}
hiscumm.SCUMMThread.prototype.doOverride = function() {
	this.script.code.seek(this.override_stack.pop(),utils.Seek.SeekBegin);
	return true;
}
hiscumm.SCUMMThread.prototype.endOverride = function() {
	this.override_stack.pop();
	return true;
}
hiscumm.SCUMMThread.prototype.flags = null;
hiscumm.SCUMMThread.prototype.getStrLen = function() {
	var oldPos = this.script.code.tell();
	var cur = -1;
	while((this.script.size - this.script.code.tell()) != 0) {
		cur = this.script.code.readChar();
		if(cur == 0) break;
		if(cur == 255) {
			var type = this.script.code.readChar();
			if((type < 1 || type > 3) && type != 8) {
				this.script.code.readUInt16();
			}
		}
	}
	cur = this.script.code.tell() - oldPos;
	this.script.code.seek(oldPos,utils.Seek.SeekBegin);
	return cur - 1;
}
hiscumm.SCUMMThread.prototype.id = null;
hiscumm.SCUMMThread.prototype.jump = function(pos) {
	if(pos < 0 || pos >= this.script.size) {
		this.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
		return;
	}
	this.script.code.seek(pos,utils.Seek.SeekBegin);
}
hiscumm.SCUMMThread.prototype.jumpRel = function(offset) {
	var newpos = this.script.code.tell() + offset;
	if(newpos < 0 || newpos >= this.script.size) {
		this.return_state = hiscumm.SPUTMState.SPUTM_ERROR;
		return;
	}
	this.script.code.seek(newpos,utils.Seek.SeekBegin);
}
hiscumm.SCUMMThread.prototype.next_state = null;
hiscumm.SCUMMThread.prototype.op_start = null;
hiscumm.SCUMMThread.prototype.override_stack = null;
hiscumm.SCUMMThread.prototype.parent = null;
hiscumm.SCUMMThread.prototype.printArgs = function() {
	{
		var _g = 0, _g1 = this.vars;
		while(_g < _g1.length) {
			var tvar = _g1[_g];
			++_g;
			if(tvar != 0) haxe.Log.trace("VAR=" + tvar,{ fileName : "SCUMM.hx", lineNumber : 333, className : "hiscumm.SCUMMThread", methodName : "printArgs"});
		}
	}
}
hiscumm.SCUMMThread.prototype.ptr = null;
hiscumm.SCUMMThread.prototype.readByte = function() {
	return this.script.code.readChar();
}
hiscumm.SCUMMThread.prototype.readShort = function() {
	return this.script.code.readUInt16();
}
hiscumm.SCUMMThread.prototype.readShortSigned = function() {
	return this.script.code.readInt16();
}
hiscumm.SCUMMThread.prototype.return_state = null;
hiscumm.SCUMMThread.prototype.run = function() {
	var i = 0;
	this.script.code.seek(this.ptr,utils.Seek.SeekBegin);
	this.return_state = hiscumm.SPUTMState.SPUTM_NONE;
	while(this.state == hiscumm.SCUMMThreadState.THREAD_RUNNING && this.cycle <= hiscumm.SCUMMThread.vm_cycle) {
		this.op_start = this.ptr;
		if(this.script.code.tell() >= this.script.size) {
			haxe.Log.trace("End of script, abort!",{ fileName : "SCUMM.hx", lineNumber : 303, className : "hiscumm.SCUMMThread", methodName : "run"});
			return hiscumm.SPUTMState.SPUTM_ERROR;
		}
		this.doOp();
		if(this.return_state != hiscumm.SPUTMState.SPUTM_NONE) {
			break;
		}
	}
	this.ptr = this.script.code.tell();
	return this.return_state;
}
hiscumm.SCUMMThread.prototype.script = null;
hiscumm.SCUMMThread.prototype.start = function(in_script,in_flags,in_ptr,in_cycle,in_args,in_parent) {
	var i;
	this.script = in_script;
	this.flags = in_flags;
	this.ptr = in_ptr;
	this.cycle = in_cycle;
	this.parent = in_parent;
	this.delay = 0;
	if(in_args != null) {
		{
			var _g1 = 0, _g = in_args.length;
			while(_g1 < _g) {
				var i1 = _g1++;
				this.vars[i1] = in_args[i1];
			}
		}
	}
	else {
		{
			var _g1 = 0, _g = this.vars.length;
			while(_g1 < _g) {
				var i1 = _g1++;
				this.vars[i1] = 0;
			}
		}
	}
	this.state = hiscumm.SCUMMThreadState.THREAD_RUNNING;
}
hiscumm.SCUMMThread.prototype.state = null;
hiscumm.SCUMMThread.prototype.stop = function() {
	this.state = hiscumm.SCUMMThreadState.THREAD_STOPPED;
}
hiscumm.SCUMMThread.prototype.vars = null;
hiscumm.SCUMMThread.prototype.__class__ = hiscumm.SCUMMThread;
hiscumm.SCUMMScript = function(num) { if( num === $_ ) return; {
	this.id = num;
	this.code = null;
}}
hiscumm.SCUMMScript.__name__ = ["hiscumm","SCUMMScript"];
hiscumm.SCUMMScript.prototype.code = null;
hiscumm.SCUMMScript.prototype.id = null;
hiscumm.SCUMMScript.prototype.nuke = function() {
	null;
}
hiscumm.SCUMMScript.prototype.size = null;
hiscumm.SCUMMScript.prototype.__class__ = hiscumm.SCUMMScript;
hiscumm.SCUMMScriptFactory = function(p) { if( p === $_ ) return; {
	hiscumm.SPUTMResourceFactory.apply(this,[]);
	this.name = "SCRIPT";
}}
hiscumm.SCUMMScriptFactory.__name__ = ["hiscumm","SCUMMScriptFactory"];
hiscumm.SCUMMScriptFactory.__super__ = hiscumm.SPUTMResourceFactory;
for(var k in hiscumm.SPUTMResourceFactory.prototype ) hiscumm.SCUMMScriptFactory.prototype[k] = hiscumm.SPUTMResourceFactory.prototype[k];
hiscumm.SCUMMScriptFactory.prototype.load = function(idx,reader) {
	var chunkID = noneko.Int32.read(reader,true);
	var chunkSize = noneko.Int32.read(reader,true).value;
	if(hiscumm.SPUTMResourceChunk.identify(chunkID) != hiscumm.SPUTMResourceChunkType.CHUNK_SCRP) {
		haxe.Log.trace("Bad script block (" + (String.fromCharCode(new noneko.Int32(chunkID.value >> 24).value) + String.fromCharCode(new noneko.Int32(new noneko.Int32(chunkID.value >> 16).value & new noneko.Int32(255).value).value) + String.fromCharCode(new noneko.Int32(new noneko.Int32(chunkID.value >> 8).value & new noneko.Int32(255).value).value) + String.fromCharCode(new noneko.Int32(chunkID.value & new noneko.Int32(255).value).value)) + " )",{ fileName : "SCUMM.hx", lineNumber : 703, className : "hiscumm.SCUMMScriptFactory", methodName : "load"});
		return null;
	}
	var instance = new hiscumm.SCUMMScript(idx);
	instance.code = new utils.JSByteIO();
	instance.code.prepare(chunkSize - 8);
	instance.code.writeInput(reader);
	instance.size = chunkSize - 8;
	return instance;
}
hiscumm.SCUMMScriptFactory.prototype.__class__ = hiscumm.SCUMMScriptFactory;
noneko.Eof = function(p) { if( p === $_ ) return; {
	null;
}}
noneko.Eof.__name__ = ["noneko","Eof"];
noneko.Eof.prototype.toString = function() {
	return "EOF";
}
noneko.Eof.prototype.__class__ = noneko.Eof;
noflash.ByteArray = function(p) { if( p === $_ ) return; {
	this.endian = "littleEndian";
	this.length = 0;
	this.position = 0;
	this.objectEncoding = noflash.ByteArray.defaultObjectEncoding;
	this.bytesAvailable = 0;
}}
noflash.ByteArray.__name__ = ["noflash","ByteArray"];
noflash.ByteArray.prototype.bytesAvailable = null;
noflash.ByteArray.prototype.compress = function() {
	null;
}
noflash.ByteArray.prototype.endian = null;
noflash.ByteArray.prototype.flipInt = function(num) {
	return 0;
}
noflash.ByteArray.prototype.flipShort = function(num) {
	return 0;
}
noflash.ByteArray.prototype.length = null;
noflash.ByteArray.prototype.objectEncoding = null;
noflash.ByteArray.prototype.position = null;
noflash.ByteArray.prototype.readBoolean = function() {
	return false;
}
noflash.ByteArray.prototype.readByte = function() {
	return 0;
}
noflash.ByteArray.prototype.readBytes = function(bytes,offset,length) {
	null;
}
noflash.ByteArray.prototype.readDouble = function() {
	return 0;
}
noflash.ByteArray.prototype.readFloat = function() {
	return 0;
}
noflash.ByteArray.prototype.readInt = function() {
	return 0;
}
noflash.ByteArray.prototype.readMultiByte = function(length,charSet) {
	return "";
}
noflash.ByteArray.prototype.readObject = function() {
	return null;
}
noflash.ByteArray.prototype.readShort = function() {
	return 0;
}
noflash.ByteArray.prototype.readUTF = function() {
	return "";
}
noflash.ByteArray.prototype.readUTFBytes = function(length) {
	return "";
}
noflash.ByteArray.prototype.readUnsignedByte = function() {
	return 0;
}
noflash.ByteArray.prototype.readUnsignedInt = function() {
	return 0;
}
noflash.ByteArray.prototype.readUnsignedShort = function() {
	return 0;
}
noflash.ByteArray.prototype.toString = function() {
	return "";
}
noflash.ByteArray.prototype.uncompress = function() {
	null;
}
noflash.ByteArray.prototype.writeBoolean = function(value) {
	null;
}
noflash.ByteArray.prototype.writeByte = function(value) {
	null;
}
noflash.ByteArray.prototype.writeBytes = function(bytes,offset,length) {
	null;
}
noflash.ByteArray.prototype.writeDouble = function(value) {
	null;
}
noflash.ByteArray.prototype.writeFloat = function(value) {
	null;
}
noflash.ByteArray.prototype.writeInt = function(value) {
	null;
}
noflash.ByteArray.prototype.writeMultiByte = function(value,charSet) {
	null;
}
noflash.ByteArray.prototype.writeObject = function(object) {
	null;
}
noflash.ByteArray.prototype.writeShort = function(value) {
	null;
}
noflash.ByteArray.prototype.writeUTF = function(value) {
	null;
}
noflash.ByteArray.prototype.writeUTFBytes = function(value) {
	null;
}
noflash.ByteArray.prototype.writeUnsignedInt = function(value) {
	null;
}
noflash.ByteArray.prototype.__class__ = noflash.ByteArray;
js = {}
js.Lib = function() { }
js.Lib.__name__ = ["js","Lib"];
js.Lib.isIE = null;
js.Lib.isOpera = null;
js.Lib.alert = function(v) {
	alert(js.Boot.__string_rec(v,""));
}
js.Lib.eval = function(code) {
	return eval(code);
}
js.Lib.setErrorHandler = function(f) {
	js.Lib.onerror = f;
}
js.Lib.prototype.__class__ = js.Lib;
js.Boot = function() { }
js.Boot.__name__ = ["js","Boot"];
js.Boot.__unhtml = function(s) {
	return s.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;");
}
js.Boot.__trace = function(v,i) {
	{
		var msg = (i != null?i.fileName + ":" + i.lineNumber + ": ":"");
		msg += js.Boot.__unhtml(js.Boot.__string_rec(v,"")) + "<br/>";
		var d = document.getElementById("haxe:trace");
		if(d == null) alert("No haxe:trace element defined\n" + msg);
		else d.innerHTML += msg;
	}
}
js.Boot.__clear_trace = function() {
	{
		var d = document.getElementById("haxe:trace");
		if(d != null) d.innerHTML = "";
		else null;
	}
}
js.Boot.__closure = function(o,f) {
	{
		var m = o[f];
		if(m == null) return null;
		var f1 = function() {
			return m.apply(o,arguments);
		}
		f1.scope = o;
		f1.method = m;
		return f1;
	}
}
js.Boot.__string_rec = function(o,s) {
	{
		if(o == null) return "null";
		if(s.length >= 5) return "<...>";
		var t = typeof(o);
		if(t == "function" && (o.__name__ != null || o.__ename__ != null)) t = "object";
		switch(t) {
		case "object":{
			if(o instanceof Array) {
				if(o.__enum__ != null) {
					if(o.length == 2) return o[0];
					var str = o[0] + "(";
					s += "\t";
					{
						var _g1 = 2, _g = o.length;
						while(_g1 < _g) {
							var i = _g1++;
							if(i != 2) str += "," + js.Boot.__string_rec(o[i],s);
							else str += js.Boot.__string_rec(o[i],s);
						}
					}
					return str + ")";
				}
				var l = o.length;
				var i;
				var str = "[";
				s += "\t";
				{
					var _g = 0;
					while(_g < l) {
						var i1 = _g++;
						str += ((i1 > 0?",":"")) + js.Boot.__string_rec(o[i1],s);
					}
				}
				str += "]";
				return str;
			}
			var tostr;
			try {
				tostr = o.toString;
			}
			catch( $e6 ) {
				{
					var e = $e6;
					{
						return "???";
					}
				}
			}
			if(tostr != null && tostr != Object.toString) {
				var s2 = o.toString();
				if(s2 != "[object Object]") return s2;
			}
			var k;
			var str = "{\n";
			s += "\t";
			var hasp = (o.hasOwnProperty != null);
			for( var k in o ) { ;
			if(hasp && !o.hasOwnProperty(k)) continue;
			if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__") continue;
			if(str.length != 2) str += ", \n";
			str += s + k + " : " + js.Boot.__string_rec(o[k],s);
			}
			s = s.substring(1);
			str += "\n" + s + "}";
			return str;
		}break;
		case "function":{
			return "<function>";
		}break;
		case "string":{
			return o;
		}break;
		default:{
			return String(o);
		}break;
		}
	}
}
js.Boot.__interfLoop = function(cc,cl) {
	if(cc == null) return false;
	if(cc == cl) return true;
	var intf = cc.__interfaces__;
	if(intf != null) {
		var _g1 = 0, _g = intf.length;
		while(_g1 < _g) {
			var i = _g1++;
			var i1 = intf[i];
			if(i1 == cl || js.Boot.__interfLoop(i1,cl)) return true;
		}
	}
	return js.Boot.__interfLoop(cc.__super__,cl);
}
js.Boot.__instanceof = function(o,cl) {
	{
		try {
			if(o instanceof cl) {
				if(cl == Array) return (o.__enum__ == null);
				return true;
			}
			if(js.Boot.__interfLoop(o.__class__,cl)) return true;
		}
		catch( $e7 ) {
			{
				var e = $e7;
				{
					if(cl == null) return false;
				}
			}
		}
		switch(cl) {
		case Int:{
			return (Math.ceil(o) === o) && isFinite(o);
		}break;
		case Float:{
			return typeof(o) == "number";
		}break;
		case Bool:{
			return (o === true || o === false);
		}break;
		case String:{
			return typeof(o) == "string";
		}break;
		case Dynamic:{
			return true;
		}break;
		default:{
			if(o != null && o.__enum__ == cl) return true;
			return false;
		}break;
		}
	}
}
js.Boot.__init = function() {
	{
		js.Lib.isIE = (document.all != null && window.opera == null);
		js.Lib.isOpera = (window.opera != null);
		Array.prototype.copy = Array.prototype.slice;
		Array.prototype.insert = function(i,x) {
			this.splice(i,0,x);
		}
		Array.prototype.remove = function(obj) {
			var i = 0;
			var l = this.length;
			while(i < l) {
				if(this[i] == obj) {
					this.splice(i,1);
					return true;
				}
				i++;
			}
			return false;
		}
		Array.prototype.iterator = function() {
			return { cur : 0, arr : this, hasNext : function() {
				return this.cur < this.arr.length;
			}, next : function() {
				return this.arr[this.cur++];
			}}
		}
		String.prototype.__class__ = String;
		String.__name__ = ["String"];
		Array.prototype.__class__ = Array;
		Array.__name__ = ["Array"];
		var cca = String.prototype.charCodeAt;
		String.prototype.charCodeAt = function(i) {
			var x = cca.call(this,i);
			if(isNaN(x)) return null;
			return x;
		}
		var oldsub = String.prototype.substr;
		String.prototype.substr = function(pos,len) {
			if(pos != null && pos != 0 && len != null && len < 0) return "";
			if(len == null) len = this.length;
			if(pos < 0) {
				pos = this.length + pos;
				if(pos < 0) pos = 0;
			}
			else if(len < 0) {
				len = this.length + len - pos;
			}
			return oldsub.apply(this,[pos,len]);
		}
		Int = new Object();
		Dynamic = new Object();
		Float = Number;
		Bool = new Object();
		Bool["true"] = true;
		Bool["false"] = false;
		$closure = js.Boot.__closure;
	}
}
js.Boot.prototype.__class__ = js.Boot;
hiscumm.SPUTMResourceChunkType = { __ename__ : ["hiscumm","SPUTMResourceChunkType"], __constructs__ : ["CHUNK_RNAM","CHUNK_MAXS","CHUNK_DROO","CHUNK_DSCR","CHUNK_DSOU","CHUNK_DCOS","CHUNK_DCHR","CHUNK_DOBJ","CHUNK_AARY","CHUNK_LECF","CHUNK_LOFF","CHUNK_SCRP","CHUNK_COST","CHUNK_ROOM","CHUNK_SMAP","CHUNK_RMHD","CHUNK_CYCL","CHUNK_TRNS","CHUNK_PALS","CHUNK_RMIM","CHUNK_OBIM","CHUNK_OBCD","CHUNK_EXCD","CHUNK_ENCD","CHUNK_NLSC","CHUNK_LSCR","CHUNK_BOXD","CHUNK_BOXM","CHUNK_SCAL","CHUNK_IM00","CHUNK_WRAP","CHUNK_OFFS","CHUNK_APAL","CHUNK_UNKNOWN"] }
hiscumm.SPUTMResourceChunkType.CHUNK_AARY = ["CHUNK_AARY",8];
hiscumm.SPUTMResourceChunkType.CHUNK_AARY.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_AARY.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_APAL = ["CHUNK_APAL",32];
hiscumm.SPUTMResourceChunkType.CHUNK_APAL.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_APAL.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_BOXD = ["CHUNK_BOXD",26];
hiscumm.SPUTMResourceChunkType.CHUNK_BOXD.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_BOXD.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_BOXM = ["CHUNK_BOXM",27];
hiscumm.SPUTMResourceChunkType.CHUNK_BOXM.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_BOXM.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_COST = ["CHUNK_COST",12];
hiscumm.SPUTMResourceChunkType.CHUNK_COST.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_COST.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_CYCL = ["CHUNK_CYCL",16];
hiscumm.SPUTMResourceChunkType.CHUNK_CYCL.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_CYCL.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_DCHR = ["CHUNK_DCHR",6];
hiscumm.SPUTMResourceChunkType.CHUNK_DCHR.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_DCHR.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_DCOS = ["CHUNK_DCOS",5];
hiscumm.SPUTMResourceChunkType.CHUNK_DCOS.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_DCOS.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_DOBJ = ["CHUNK_DOBJ",7];
hiscumm.SPUTMResourceChunkType.CHUNK_DOBJ.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_DOBJ.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_DROO = ["CHUNK_DROO",2];
hiscumm.SPUTMResourceChunkType.CHUNK_DROO.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_DROO.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_DSCR = ["CHUNK_DSCR",3];
hiscumm.SPUTMResourceChunkType.CHUNK_DSCR.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_DSCR.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_DSOU = ["CHUNK_DSOU",4];
hiscumm.SPUTMResourceChunkType.CHUNK_DSOU.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_DSOU.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_ENCD = ["CHUNK_ENCD",23];
hiscumm.SPUTMResourceChunkType.CHUNK_ENCD.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_ENCD.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_EXCD = ["CHUNK_EXCD",22];
hiscumm.SPUTMResourceChunkType.CHUNK_EXCD.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_EXCD.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_IM00 = ["CHUNK_IM00",29];
hiscumm.SPUTMResourceChunkType.CHUNK_IM00.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_IM00.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_LECF = ["CHUNK_LECF",9];
hiscumm.SPUTMResourceChunkType.CHUNK_LECF.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_LECF.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_LOFF = ["CHUNK_LOFF",10];
hiscumm.SPUTMResourceChunkType.CHUNK_LOFF.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_LOFF.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_LSCR = ["CHUNK_LSCR",25];
hiscumm.SPUTMResourceChunkType.CHUNK_LSCR.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_LSCR.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_MAXS = ["CHUNK_MAXS",1];
hiscumm.SPUTMResourceChunkType.CHUNK_MAXS.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_MAXS.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_NLSC = ["CHUNK_NLSC",24];
hiscumm.SPUTMResourceChunkType.CHUNK_NLSC.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_NLSC.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_OBCD = ["CHUNK_OBCD",21];
hiscumm.SPUTMResourceChunkType.CHUNK_OBCD.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_OBCD.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_OBIM = ["CHUNK_OBIM",20];
hiscumm.SPUTMResourceChunkType.CHUNK_OBIM.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_OBIM.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_OFFS = ["CHUNK_OFFS",31];
hiscumm.SPUTMResourceChunkType.CHUNK_OFFS.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_OFFS.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_PALS = ["CHUNK_PALS",18];
hiscumm.SPUTMResourceChunkType.CHUNK_PALS.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_PALS.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_RMHD = ["CHUNK_RMHD",15];
hiscumm.SPUTMResourceChunkType.CHUNK_RMHD.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_RMHD.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_RMIM = ["CHUNK_RMIM",19];
hiscumm.SPUTMResourceChunkType.CHUNK_RMIM.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_RMIM.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_RNAM = ["CHUNK_RNAM",0];
hiscumm.SPUTMResourceChunkType.CHUNK_RNAM.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_RNAM.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_ROOM = ["CHUNK_ROOM",13];
hiscumm.SPUTMResourceChunkType.CHUNK_ROOM.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_ROOM.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_SCAL = ["CHUNK_SCAL",28];
hiscumm.SPUTMResourceChunkType.CHUNK_SCAL.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_SCAL.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_SCRP = ["CHUNK_SCRP",11];
hiscumm.SPUTMResourceChunkType.CHUNK_SCRP.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_SCRP.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_SMAP = ["CHUNK_SMAP",14];
hiscumm.SPUTMResourceChunkType.CHUNK_SMAP.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_SMAP.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_TRNS = ["CHUNK_TRNS",17];
hiscumm.SPUTMResourceChunkType.CHUNK_TRNS.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_TRNS.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_UNKNOWN = ["CHUNK_UNKNOWN",33];
hiscumm.SPUTMResourceChunkType.CHUNK_UNKNOWN.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_UNKNOWN.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunkType.CHUNK_WRAP = ["CHUNK_WRAP",30];
hiscumm.SPUTMResourceChunkType.CHUNK_WRAP.toString = $estr;
hiscumm.SPUTMResourceChunkType.CHUNK_WRAP.__enum__ = hiscumm.SPUTMResourceChunkType;
hiscumm.SPUTMResourceChunk = function(a,b) { if( a === $_ ) return; {
	this.chunkID = b;
	this.chunkType = a;
}}
hiscumm.SPUTMResourceChunk.__name__ = ["hiscumm","SPUTMResourceChunk"];
hiscumm.SPUTMResourceChunk.identify = function(value) {
	{
		var _g = 0, _g1 = hiscumm.SPUTMResourceChunk.chunkTypes;
		while(_g < _g1.length) {
			var ct = _g1[_g];
			++_g;
			if(noneko.Int32.compare(ct.chunkID,value) == 0) return ct.chunkType;
		}
	}
	return hiscumm.SPUTMResourceChunkType.CHUNK_UNKNOWN;
}
hiscumm.SPUTMResourceChunk.prototype.chunkID = null;
hiscumm.SPUTMResourceChunk.prototype.chunkType = null;
hiscumm.SPUTMResourceChunk.prototype.__class__ = hiscumm.SPUTMResourceChunk;
hiscumm.SPUTMResource = function(p) { if( p === $_ ) return; {
	this.instance = null;
	this.flags = 0;
	this.file = -1;
	this.room = -1;
	this.offset = 0;
}}
hiscumm.SPUTMResource.__name__ = ["hiscumm","SPUTMResource"];
hiscumm.SPUTMResource.prototype.file = null;
hiscumm.SPUTMResource.prototype.flags = null;
hiscumm.SPUTMResource.prototype.instance = null;
hiscumm.SPUTMResource.prototype.isLocked = function() {
	return (this.flags & hiscumm.SPUTMResource.FLAG_LOCKED);
}
hiscumm.SPUTMResource.prototype.lock = function() {
	this.flags |= hiscumm.SPUTMResource.FLAG_LOCKED;
	return true;
}
hiscumm.SPUTMResource.prototype.nuke = function() {
	this.instance.nuke();
	this.instance = null;
	if(this.isLocked() != 0) this.unlock();
	return true;
}
hiscumm.SPUTMResource.prototype.offset = null;
hiscumm.SPUTMResource.prototype.room = null;
hiscumm.SPUTMResource.prototype.unlock = function() {
	this.flags &= -2;
	return true;
}
hiscumm.SPUTMResource.prototype.__class__ = hiscumm.SPUTMResource;
hiscumm.SPUTMResourceList = function(num,fct) { if( num === $_ ) return; {
	this.res = new Array();
	this.res[num - 1] = null;
	this.num_res = num;
	this.factory = fct;
}}
hiscumm.SPUTMResourceList.__name__ = ["hiscumm","SPUTMResourceList"];
hiscumm.SPUTMResourceList.prototype.factory = null;
hiscumm.SPUTMResourceList.prototype.loadResource = function(idx) {
	var resource = this.res[idx];
	if(idx != 0) haxe.Log.trace("Loading resource " + idx + " from file " + resource.file + ", room " + resource.room + " (" + this.factory.name + ")",{ fileName : "SPUTMResource.hx", lineNumber : 312, className : "hiscumm.SPUTMResourceList", methodName : "loadResource"});
	else {
		haxe.Log.trace("Invalid resource 0!",{ fileName : "SPUTMResource.hx", lineNumber : 315, className : "hiscumm.SPUTMResourceList", methodName : "loadResource"});
		return null;
	}
	var reader = hiscumm.SPUTM.instance.vm_files[resource.file];
	reader.seek(resource.offset,utils.Seek.SeekBegin);
	resource.instance = this.factory.load(idx,reader);
	return resource.instance;
}
hiscumm.SPUTMResourceList.prototype.loadResourceIndexes = function(reader) {
	var i;
	var sputm = hiscumm.SPUTM.instance;
	var rooms = sputm.vm_res[3].res;
	var resource;
	var num;
	num = reader.readUInt16();
	if(num != this.num_res) {
		haxe.Log.trace("Invalid index block!",{ fileName : "SPUTMResource.hx", lineNumber : 251, className : "hiscumm.SPUTMResourceList", methodName : "loadResourceIndexes"});
		return;
	}
	{
		var _g = 0;
		while(_g < num) {
			var i1 = _g++;
			resource = new hiscumm.SPUTMResource();
			this.res[i1] = resource;
			resource.room = reader.readChar();
			if(resource.room >= sputm.vm_res[3].res.length) {
				resource.room = 0;
				continue;
			}
			resource.file = sputm.vm_res[3].res[resource.room].file;
		}
	}
	{
		var _g = 0;
		while(_g < num) {
			var i1 = _g++;
			resource = this.res[i1];
			resource.offset = reader.readUInt32() + sputm.vm_res[3].res[resource.room].offset;
		}
	}
}
hiscumm.SPUTMResourceList.prototype.loadResourceIndexesAlt = function(reader) {
	var i;
	var sputm = hiscumm.SPUTM.instance;
	var rooms = sputm.vm_res[3].res;
	var resource;
	var num;
	num = reader.readUInt16();
	if(num != this.num_res) {
		haxe.Log.trace("Invalid index block!",{ fileName : "SPUTMResource.hx", lineNumber : 293, className : "hiscumm.SPUTMResourceList", methodName : "loadResourceIndexesAlt"});
		return;
	}
	{
		var _g = 0;
		while(_g < num) {
			var i1 = _g++;
			resource = new hiscumm.SPUTMResource();
			this.res[i1] = resource;
			resource.room = reader.readChar();
		}
	}
}
hiscumm.SPUTMResourceList.prototype.nukeResource = function(idx) {
	return this.res[idx].nuke();
}
hiscumm.SPUTMResourceList.prototype.num_res = null;
hiscumm.SPUTMResourceList.prototype.res = null;
hiscumm.SPUTMResourceList.prototype.__class__ = hiscumm.SPUTMResourceList;
justjs = {}
justjs.Bitmap = function(p) { if( p === $_ ) return; {
	null;
}}
justjs.Bitmap.__name__ = ["justjs","Bitmap"];
justjs.Bitmap.prototype.bitmapData = null;
justjs.Bitmap.prototype.dispose = function() {
	this.bitmapData.dispose();
	this.bitmapData = null;
}
justjs.Bitmap.prototype.__class__ = justjs.Bitmap;
utils.SeekableTools = function() { }
utils.SeekableTools.__name__ = ["utils","SeekableTools"];
utils.SeekableTools.getSeekableLength = function(s) {
	var old_pos = s.tell();
	s.seek(0,utils.Seek.SeekEnd);
	var new_pos = s.tell();
	s.seek(old_pos,utils.Seek.SeekBegin);
	return new_pos;
}
utils.SeekableTools.prototype.__class__ = utils.SeekableTools;
justjs.BitmapData = function(width,height,param,flags) { if( width === $_ ) return; {
	this.width = width;
	this.height = height;
	this.canvas = js.Lib.document.createElement("canvas");
	this.canvas.setAttribute("width",width);
	this.canvas.setAttribute("height",height);
	var ctx = this.canvas.getContext("2d");
	this.pixels = ctx.getImageData(0,0,this.canvas.width,this.canvas.height);
}}
justjs.BitmapData.__name__ = ["justjs","BitmapData"];
justjs.BitmapData.prototype.canvas = null;
justjs.BitmapData.prototype.copyPixels = function(source_bmap,rect,dest,alpha,alphaPoint,merge) {
	var context = this.canvas.getContext("2d");
	var source_stride = source_bmap.pixels.width;
	var dest_stride = this.pixels.width;
	var sx = 0;
	var sy = 0;
	var sw = 0;
	var sh = 0;
	if(rect == null) {
		sx = 0;
		sy = 0;
		sw = source_bmap.pixels.width;
		sh = source_bmap.pixels.height;
	}
	else {
		sx = rect.x;
		sy = rect.y;
		sw = rect.width;
		sh = rect.height;
	}
	var dx = dest.x;
	var dy = dest.y;
	var dw = sw;
	var dh = sh;
	var src_data = source_bmap.pixels.data;
	var dst_data = this.pixels.data;
	var end_pixels = rect.width * rect.height;
	var count = 0;
	var cur_sx = sx;
	var cur_sy = sy;
	var cur_dx = dx;
	var cur_dy = dy;
	while(count != end_pixels) {
		var src_r = 0;
		if(cur_sx > source_bmap.pixels.width || cur_sy > source_bmap.pixels.height || cur_sx < 0 || cur_sy < 0) {
			src_r = 0;
		}
		else {
			var pos = ((cur_sy * source_stride) + cur_sx) * 4;
			src_r = src_data[pos];
		}
		if(!(cur_dx >= this.pixels.width || cur_dy >= this.pixels.height || cur_dx < 0 || cur_dy < 0)) {
			var pos = ((cur_dy * dest_stride) + cur_dx) * 4;
			dst_data[pos] = src_r;
		}
		cur_sx += 1;
		cur_dx += 1;
		if(cur_sx >= (sx + sw)) {
			cur_sx = sx;
			cur_sy += 1;
		}
		if(cur_dx >= (dx + dw)) {
			cur_dx = dx;
			cur_dy += 1;
		}
		count++;
	}
	context.putImageData(this.pixels,0,0);
}
justjs.BitmapData.prototype.dispose = function() {
	this.pixels = null;
	this.canvas = null;
}
justjs.BitmapData.prototype.fastPaletteRemap = function(correct_colors) {
	var context = this.canvas.getContext("2d");
	var end_pos = this.pixels.width * this.pixels.height;
	var cur_pos = 0;
	var writ = 0;
	var data = this.pixels.data;
	var color = 0;
	while(cur_pos != end_pos) {
		color = correct_colors[data[writ]];
		data[writ] = ((color >> 16) & 255);
		writ++;
		data[writ] = ((color >> 8) & 255);
		writ++;
		data[writ] = (color & 255);
		writ += 2;
		cur_pos++;
	}
	context.putImageData(this.pixels,0,0);
}
justjs.BitmapData.prototype.fillRect = function(rect,color) {
	var context = this.canvas.getContext("2d");
	var dx = 0;
	var dy = 0;
	var dw = 0;
	var dh = 0;
	var stride = this.pixels.width;
	if(rect == null) {
		dx = 0;
		dy = 0;
		dw = this.pixels.width;
		dh = this.pixels.height;
	}
	else {
		var clipped_rect = rect.intersection(new noflash.Rectangle(0,0,this.pixels.width,this.pixels.height));
		dx = clipped_rect.x;
		dy = clipped_rect.y;
		dw = clipped_rect.width;
		dh = clipped_rect.height;
	}
	var start_pos = ((dy * stride) + dx) * 4;
	var end_pos = (((dy + dh) * stride) + (dx + dw)) * 4;
	var cur_pos = start_pos;
	var cur_x = 0;
	var cur_row = 0;
	var data = this.pixels.data;
	while(cur_pos != end_pos) {
		if(cur_x == dw) {
			cur_row += 1;
			cur_pos = start_pos + (cur_row * stride);
			cur_x = 0;
		}
		data[cur_pos] = color;
		cur_pos += 1;
		data[cur_pos] = color;
		cur_pos += 1;
		data[cur_pos] = color;
		cur_pos += 1;
		data[cur_pos] = 255;
		cur_pos += 1;
		cur_x += 1;
	}
	context.putImageData(this.pixels,0,0);
}
justjs.BitmapData.prototype.height = null;
justjs.BitmapData.prototype.imgdata = null;
justjs.BitmapData.prototype.lock = function() {
	null;
}
justjs.BitmapData.prototype.paletteMap = function(bmap,rect,point,zeros,zeros2,list,Void) {
	var context = this.canvas.getContext("2d");
	var old_imgdata = null;
}
justjs.BitmapData.prototype.pixels = null;
justjs.BitmapData.prototype.rect = null;
justjs.BitmapData.prototype.setPixels = function(rect,colors) {
	var context = this.canvas.getContext("2d");
	var end = utils.SeekableTools.getSeekableLength(colors);
	var data = this.pixels.data;
	var pos = 0;
	while(end > 0) {
		data[pos] = colors.readChar();
		data[pos + 1] = colors.readChar();
		data[pos + 2] = colors.readChar();
		data[pos + 3] = 255;
		colors.readChar();
		pos += 4;
		end -= 4;
	}
	context.putImageData(this.pixels,0,0);
}
justjs.BitmapData.prototype.unlock = function() {
	null;
}
justjs.BitmapData.prototype.width = null;
justjs.BitmapData.prototype.__class__ = justjs.BitmapData;
$Main = function() { }
$Main.__name__ = ["@Main"];
$Main.prototype.__class__ = $Main;
$_ = {}
js.Boot.__res = {}
js.Boot.__init();
{
	Date.now = function() {
		return new Date();
	}
	Date.fromTime = function(t) {
		var d = new Date();
		d["setTime"](t);
		return d;
	}
	Date.fromString = function(s) {
		switch(s.length) {
		case 8:{
			var k = s.split(":");
			var d = new Date();
			d["setTime"](0);
			d["setUTCHours"](k[0]);
			d["setUTCMinutes"](k[1]);
			d["setUTCSeconds"](k[2]);
			return d;
		}break;
		case 10:{
			var k = s.split("-");
			return new Date(k[0],k[1] - 1,k[2],0,0,0);
		}break;
		case 19:{
			var k = s.split(" ");
			var y = k[0].split("-");
			var t = k[1].split(":");
			return new Date(y[0],y[1] - 1,y[2],t[0],t[1],t[2]);
		}break;
		default:{
			throw "Invalid date format : " + s;
		}break;
		}
	}
	Date.prototype["toString"] = function() {
		var m = this.getMonth() + 1;
		var d = this.getDate();
		var h = this.getHours();
		var mi = this.getMinutes();
		var s = this.getSeconds();
		return this.getFullYear() + "-" + ((m < 10?"0" + m:"" + m)) + "-" + ((d < 10?"0" + d:"" + d)) + " " + ((h < 10?"0" + h:"" + h)) + ":" + ((mi < 10?"0" + mi:"" + mi)) + ":" + ((s < 10?"0" + s:"" + s));
	}
	Date.prototype.__class__ = Date;
	Date.__name__ = ["Date"];
}
{
	Math.NaN = Number["NaN"];
	Math.NEGATIVE_INFINITY = Number["NEGATIVE_INFINITY"];
	Math.POSITIVE_INFINITY = Number["POSITIVE_INFINITY"];
	Math.isFinite = function(i) {
		return isFinite(i);
	}
	Math.isNaN = function(i) {
		return isNaN(i);
	}
}
{
	
			onerror = function(msg,url,line) {
				var f = js.Lib.onerror;
				if( f == null )
					return false;
				return f(msg,[url+":"+line]);
			}
		;
}
{
	js["XMLHttpRequest"] = (window.XMLHttpRequest?XMLHttpRequest:(window.ActiveXObject?function() {
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch( $e8 ) {
			{
				var e = $e8;
				{
					try {
						return new ActiveXObject("Microsoft.XMLHTTP");
					}
					catch( $e9 ) {
						{
							var e1 = $e9;
							{
								throw "Unable to create XMLHttpRequest object.";
							}
						}
					}
				}
			}
		}
	}:function($this) {
		var $r;
		throw "Unable to create XMLHttpRequest object.";
		return $r;
	}(this)));
}
hiscumm.SPUTMImage.ZP = 0;
hiscumm.SPUTMImage.pixels_written = 0;
hiscumm.SPUTMImage.dtrace_on = false;
hiscumm.SPUTMImage.dtrace_override = false;
hiscumm.SCUMM6.optable = [$closure(hiscumm.SCUMM6,"pushByte"),$closure(hiscumm.SCUMM6,"pushWord"),$closure(hiscumm.SCUMM6,"readByte"),$closure(hiscumm.SCUMM6,"readWord"),null,null,$closure(hiscumm.SCUMM6,"readArrayByte"),$closure(hiscumm.SCUMM6,"readArrayWord"),null,null,$closure(hiscumm.SCUMM6,"readArray2Byte"),$closure(hiscumm.SCUMM6,"readArray2Word"),$closure(hiscumm.SCUMM6,"doDUP"),$closure(hiscumm.SCUMM6,"testNOT"),$closure(hiscumm.SCUMM6,"testEQ"),$closure(hiscumm.SCUMM6,"testNEQ"),$closure(hiscumm.SCUMM6,"testGT"),$closure(hiscumm.SCUMM6,"testLT"),$closure(hiscumm.SCUMM6,"testLE"),$closure(hiscumm.SCUMM6,"testGE"),$closure(hiscumm.SCUMM6,"doADD"),$closure(hiscumm.SCUMM6,"doSUB"),$closure(hiscumm.SCUMM6,"doMUL"),$closure(hiscumm.SCUMM6,"doDIV"),$closure(hiscumm.SCUMM6,"testAND"),$closure(hiscumm.SCUMM6,"testOR"),$closure(hiscumm.SCUMM6,"pop"),null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,$closure(hiscumm.SCUMM6,"writeByte"),$closure(hiscumm.SCUMM6,"writeWord"),null,null,$closure(hiscumm.SCUMM6,"writeArrayByte"),$closure(hiscumm.SCUMM6,"writeArrayWord"),null,null,$closure(hiscumm.SCUMM6,"writeArray2Byte"),$closure(hiscumm.SCUMM6,"writeArray2Word"),null,null,$closure(hiscumm.SCUMM6,"incByte"),$closure(hiscumm.SCUMM6,"incWord"),null,null,$closure(hiscumm.SCUMM6,"incArrayByte"),$closure(hiscumm.SCUMM6,"incArrayWord"),null,null,$closure(hiscumm.SCUMM6,"decByte"),$closure(hiscumm.SCUMM6,"decWord"),null,null,$closure(hiscumm.SCUMM6,"decArrayByte"),$closure(hiscumm.SCUMM6,"decArrayWord"),$closure(hiscumm.SCUMM6,"jmpNotZero"),$closure(hiscumm.SCUMM6,"jmpZero"),$closure(hiscumm.SCUMM6,"startScript"),$closure(hiscumm.SCUMM6,"startScriptQuick"),$closure(hiscumm.SCUMM6,"startObject"),$closure(hiscumm.SCUMM6,"drawObject"),$closure(hiscumm.SCUMM6,"drawObjectAt"),$closure(hiscumm.SCUMM6,"drawBlastObject"),$closure(hiscumm.SCUMM6,"drawBlastObjectWindow"),$closure(hiscumm.SCUMM6,"stopObjectCode")].concat([$closure(hiscumm.SCUMM6,"stopObjectCode"),$closure(hiscumm.SCUMM6,"endCutscene"),$closure(hiscumm.SCUMM6,"cutscene"),$closure(hiscumm.SCUMM6,"stopMusic"),$closure(hiscumm.SCUMM6,"freezeUnfreeze"),$closure(hiscumm.SCUMM6,"cursorOp"),$closure(hiscumm.SCUMM6,"breakScript"),$closure(hiscumm.SCUMM6,"ifClassOfIs"),$closure(hiscumm.SCUMM6,"setClass"),$closure(hiscumm.SCUMM6,"getObjectState"),$closure(hiscumm.SCUMM6,"setObjectState"),$closure(hiscumm.SCUMM6,"setObjectOwner"),$closure(hiscumm.SCUMM6,"getObjectOwner"),$closure(hiscumm.SCUMM6,"jmp"),$closure(hiscumm.SCUMM6,"startSound"),$closure(hiscumm.SCUMM6,"stopSound"),$closure(hiscumm.SCUMM6,"startMusic"),$closure(hiscumm.SCUMM6,"stopObjectScript"),$closure(hiscumm.SCUMM6,"panCameraTo"),$closure(hiscumm.SCUMM6,"followCameraActor"),$closure(hiscumm.SCUMM6,"setCameraAt"),$closure(hiscumm.SCUMM6,"startRoom"),$closure(hiscumm.SCUMM6,"stopScript"),$closure(hiscumm.SCUMM6,"walkActorToObject"),$closure(hiscumm.SCUMM6,"walkActorTo"),$closure(hiscumm.SCUMM6,"putActorAt"),$closure(hiscumm.SCUMM6,"putActorAtObject"),$closure(hiscumm.SCUMM6,"faceActor"),$closure(hiscumm.SCUMM6,"animateActor"),$closure(hiscumm.SCUMM6,"doSentence"),$closure(hiscumm.SCUMM6,"pickupObject"),$closure(hiscumm.SCUMM6,"startRoomWithEgo"),null,$closure(hiscumm.SCUMM6,"getRandomNumber"),$closure(hiscumm.SCUMM6,"getRandomNumberRange"),null,$closure(hiscumm.SCUMM6,"getActorMoving"),$closure(hiscumm.SCUMM6,"isScriptRunning"),$closure(hiscumm.SCUMM6,"getActorRoom"),$closure(hiscumm.SCUMM6,"getObjectX"),$closure(hiscumm.SCUMM6,"getObjectY"),$closure(hiscumm.SCUMM6,"getObjectOldDir"),$closure(hiscumm.SCUMM6,"getActorWalkBox"),$closure(hiscumm.SCUMM6,"getActorCostume"),$closure(hiscumm.SCUMM6,"findInventory"),$closure(hiscumm.SCUMM6,"getInventoryCount"),$closure(hiscumm.SCUMM6,"getVerbFrom"),$closure(hiscumm.SCUMM6,"beginOverride"),$closure(hiscumm.SCUMM6,"endOverride"),$closure(hiscumm.SCUMM6,"setObjectName"),$closure(hiscumm.SCUMM6,"isSoundRunning"),$closure(hiscumm.SCUMM6,"setBoxFlags"),$closure(hiscumm.SCUMM6,"createBoxMatrix"),$closure(hiscumm.SCUMM6,"resourceOp"),$closure(hiscumm.SCUMM6,"roomOp"),$closure(hiscumm.SCUMM6,"actorOp"),$closure(hiscumm.SCUMM6,"verbOp"),$closure(hiscumm.SCUMM6,"getActorFrom"),$closure(hiscumm.SCUMM6,"findObject"),$closure(hiscumm.SCUMM6,"pseudoRoom"),$closure(hiscumm.SCUMM6,"getActorElevation"),$closure(hiscumm.SCUMM6,"getVerbEntrypoint"),$closure(hiscumm.SCUMM6,"arrayOps"),$closure(hiscumm.SCUMM6,"saveRestoreVerbs"),$closure(hiscumm.SCUMM6,"drawBox"),$closure(hiscumm.SCUMM6,"pop"),$closure(hiscumm.SCUMM6,"getActorWidth"),$closure(hiscumm.SCUMM6,"wait"),$closure(hiscumm.SCUMM6,"getActorXScale"),$closure(hiscumm.SCUMM6,"getActorAnimCounter"),$closure(hiscumm.SCUMM6,"soundKludge"),$closure(hiscumm.SCUMM6,"isAnyOf"),$closure(hiscumm.SCUMM6,"systemOps"),$closure(hiscumm.SCUMM6,"isActorInBox"),$closure(hiscumm.SCUMM6,"delay"),$closure(hiscumm.SCUMM6,"delaySeconds"),$closure(hiscumm.SCUMM6,"delayMinutes"),$closure(hiscumm.SCUMM6,"stopSentence"),$closure(hiscumm.SCUMM6,"print"),$closure(hiscumm.SCUMM6,"printCursor"),$closure(hiscumm.SCUMM6,"printDebug"),$closure(hiscumm.SCUMM6,"printSystem"),$closure(hiscumm.SCUMM6,"printActor"),$closure(hiscumm.SCUMM6,"printEgo"),$closure(hiscumm.SCUMM6,"talkActor"),$closure(hiscumm.SCUMM6,"talkEgo"),$closure(hiscumm.SCUMM6,"dimArray"),$closure(hiscumm.SCUMM6,"dummy"),$closure(hiscumm.SCUMM6,"startObjectQuick"),$closure(hiscumm.SCUMM6,"startScriptRecursive"),$closure(hiscumm.SCUMM6,"dimArray2"),null,null,null,$closure(hiscumm.SCUMM6,"abs"),$closure(hiscumm.SCUMM6,"distObjectObject"),$closure(hiscumm.SCUMM6,"distObjectPt"),$closure(hiscumm.SCUMM6,"distPtPt"),$closure(hiscumm.SCUMM6,"kernelGetFunctions"),$closure(hiscumm.SCUMM6,"kernelSetFunctions"),$closure(hiscumm.SCUMM6,"breakScriptNTimes")]).concat([$closure(hiscumm.SCUMM6,"pickOneOf"),$closure(hiscumm.SCUMM6,"pickOneOfDefault"),$closure(hiscumm.SCUMM6,"stampObject"),null,null,$closure(hiscumm.SCUMM6,"getDateTime"),$closure(hiscumm.SCUMM6,"stopTalking"),$closure(hiscumm.SCUMM6,"getAnimateVariable"),null,$closure(hiscumm.SCUMM6,"shuffle"),$closure(hiscumm.SCUMM6,"jumpToScript"),$closure(hiscumm.SCUMM6,"bitAND"),$closure(hiscumm.SCUMM6,"bitOR"),$closure(hiscumm.SCUMM6,"isRoomScriptRunning"),null,null,null,null,$closure(hiscumm.SCUMM6,"findAllObjects"),null,null,null,$closure(hiscumm.SCUMM6,"getPixel"),null,$closure(hiscumm.SCUMM6,"pickRandomVar"),$closure(hiscumm.SCUMM6,"setBoxSet"),null,null,null,null,null,null,null,$closure(hiscumm.SCUMM6,"getActorLayer"),$closure(hiscumm.SCUMM6,"getObjectNewDir"),null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]);
hiscumm.SCUMM6.suboptable = [];
hiscumm.SPUTMDisplayPalette.NULL_POINT = new noflash.Point(0,0);
hiscumm.SPUTM.instance = null;
hiscumm.SPUTM.RES_SCRIPT = 0;
hiscumm.SPUTM.RES_SOUND = 1;
hiscumm.SPUTM.RES_COSTUME = 2;
hiscumm.SPUTM.RES_ROOM = 3;
hiscumm.SPUTM.RES_CHARSET = 4;
hiscumm.SPUTM.RES_OBJECT = 5;
hiscumm.SPUTM.RES_MAX = 6;
hiscumm.SPUTM.BLANK_INDEX = 16711711;
hiscumm.SPUTM.VAR_KEYPRESS = 0;
hiscumm.SPUTM.VAR_EGO = 1;
hiscumm.SPUTM.VAR_CAMERA_POS_X = 2;
hiscumm.SPUTM.VAR_HAVE_MSG = 3;
hiscumm.SPUTM.VAR_ROOM = 4;
hiscumm.SPUTM.VAR_OVERRIDE = 5;
hiscumm.SPUTM.VAR_MACHINE_SPEED = 6;
hiscumm.SPUTM.VAR_ME = 7;
hiscumm.SPUTM.VAR_NUM_ACTOR = 8;
hiscumm.SPUTM.VAR_SOUND_MODE = 9;
hiscumm.SPUTM.VAR_CURRENT_DRIVE = 10;
hiscumm.SPUTM.VAR_TIMER1 = 11;
hiscumm.SPUTM.VAR_TIMER2 = 12;
hiscumm.SPUTM.VAR_TIMER3 = 13;
hiscumm.SPUTM.VAR_MUSIC_TIMER = 14;
hiscumm.SPUTM.VAR_ACTOR_RANGE_MIN = 15;
hiscumm.SPUTM.VAR_ACTOR_RANGE_MAX = 16;
hiscumm.SPUTM.VAR_CAMERA_MIN_X = 17;
hiscumm.SPUTM.VAR_CAMERA_MAX_X = 18;
hiscumm.SPUTM.VAR_TIMER_NEXT = 19;
hiscumm.SPUTM.VAR_VIRTUAL_MOUSE_X = 20;
hiscumm.SPUTM.VAR_VIRTUAL_MOUSE_Y = 21;
hiscumm.SPUTM.VAR_ROOM_RESOURCE = 22;
hiscumm.SPUTM.VAR_LAST_SOUND = 23;
hiscumm.SPUTM.VAR_CUTSCENE_EXIT_KEY = 24;
hiscumm.SPUTM.VAR_TALK_ACTOR = 25;
hiscumm.SPUTM.VAR_CAMERA_FAST_X = 26;
hiscumm.SPUTM.VAR_CAMERA_SCRIPT = 27;
hiscumm.SPUTM.VAR_PRE_ENTRY_SCRIPT = 28;
hiscumm.SPUTM.VAR_POST_ENTRY_SCRIPT = 29;
hiscumm.SPUTM.VAR_PRE_EXIT_SCRIPT = 30;
hiscumm.SPUTM.VAR_POST_EXIT_SCRIPT = 31;
hiscumm.SPUTM.VAR_VERB_SCRIPT = 32;
hiscumm.SPUTM.VAR_SENTENCE_SCRIPT = 33;
hiscumm.SPUTM.VAR_INVENTORY_SCRIPT = 34;
hiscumm.SPUTM.VAR_CUTSCENE_START_SCRIPT = 35;
hiscumm.SPUTM.VAR_CUTSCENE_END_SCRIPT = 36;
hiscumm.SPUTM.VAR_CHARINC = 37;
hiscumm.SPUTM.VAR_WALK_TO_OBJECT = 38;
hiscumm.SPUTM.VAR_DEBUG_MODE = 39;
hiscumm.SPUTM.VAR_HEAP_SPACE = 40;
hiscumm.SPUTM.VAR_ROOM_WIDTH = 41;
hiscumm.SPUTM.VAR_RESTART_KEY = 42;
hiscumm.SPUTM.VAR_PAUSE_KEY = 43;
hiscumm.SPUTM.VAR_MOUSE_X = 44;
hiscumm.SPUTM.VAR_MOUSE_Y = 45;
hiscumm.SPUTM.VAR_TIMER = 46;
hiscumm.SPUTM.VAR_TIMER4 = 47;
hiscumm.SPUTM.VAR_SOUNDCARD = 48;
hiscumm.SPUTM.VAR_VIDEOMODE = 49;
hiscumm.SPUTM.VAR_MAINMENU_KEY = 50;
hiscumm.SPUTM.VAR_FIXED_DISK = 51;
hiscumm.SPUTM.VAR_CURSOR_STATE = 52;
hiscumm.SPUTM.VAR_USERPUT = 53;
hiscumm.SPUTM.VAR_ROOM_HEIGHT = 54;
hiscumm.SPUTM.VAR_UNKNOWN1 = 55;
hiscumm.SPUTM.VAR_SOUND_RESULT = 56;
hiscumm.SPUTM.VAR_TALK_STOP_KEY = 57;
hiscumm.SPUTM.VAR_UNKNOWN2 = 58;
hiscumm.SPUTM.VAR_FADE_DELAY = 59;
hiscumm.SPUTM.VAR_NO_SUBTITLES = 60;
hiscumm.SPUTM.VAR_GUI_ENTRY_SCRIPT = 61;
hiscumm.SPUTM.VAR_GUI_EXIT_SCRIPT = 62;
hiscumm.SPUTM.VAR_UNKNOWN3 = 63;
hiscumm.SPUTM.VAR_SOUND_PARAM0 = 64;
hiscumm.SPUTM.VAR_SOUND_PARAM1 = 65;
hiscumm.SPUTM.VAR_SOUND_PARAM2 = 66;
hiscumm.SPUTM.VAR_INPUT_MODE = 67;
hiscumm.SPUTM.VAR_MEMORY_PERFORMANCE = 68;
hiscumm.SPUTM.VAR_VIDEO_PERFORMANCE = 69;
hiscumm.SPUTM.VAR_ROOM_FLAG = 70;
hiscumm.SPUTM.VAR_GAME_LOADED = 71;
hiscumm.SPUTM.VAR_NEW_ROOM = 72;
hiscumm.SPUTM.VAR_UNKNOWN4 = 73;
hiscumm.SPUTM.VAR_LEFT_BUTTON_HOLD = 74;
hiscumm.SPUTM.VAR_RIGHT_BUTTON_HOLD = 75;
hiscumm.SPUTM.VAR_EMS_SPACE = 76;
hiscumm.SPUTM.VAR_UNKNOWN50 = 77;
hiscumm.SPUTM.VAR_UNKNOWN51 = 78;
hiscumm.SPUTM.VAR_UNKNOWN52 = 79;
hiscumm.SPUTM.VAR_UNKNOWN53 = 80;
hiscumm.SPUTM.VAR_UNKNOWN54 = 81;
hiscumm.SPUTM.VAR_UNKNOWN55 = 82;
hiscumm.SPUTM.VAR_UNKNOWN56 = 83;
hiscumm.SPUTM.VAR_UNKNOWN57 = 84;
hiscumm.SPUTM.VAR_UNKNOWN58 = 85;
hiscumm.SPUTM.VAR_UNKNOWN59 = 86;
hiscumm.SPUTM.VAR_UNKNOWN510 = 87;
hiscumm.SPUTM.VAR_UNKNOWN511 = 88;
hiscumm.SPUTM.VAR_UNKNOWN512 = 89;
hiscumm.SPUTM.VAR_GAME_DISK_MSG = 90;
hiscumm.SPUTM.VAR_OPEN_FAILED_MSG = 91;
hiscumm.SPUTM.VAR_READ_ERROR_MSG = 92;
hiscumm.SPUTM.VAR_PAUSE_MSG = 93;
hiscumm.SPUTM.VAR_RESTART_MSG = 94;
hiscumm.SPUTM.VAR_QUIT_MSG = 95;
hiscumm.SPUTM.VAR_SAVE_BUTTON = 96;
hiscumm.SPUTM.VAR_LOAD_BUTTON = 97;
hiscumm.SPUTM.VAR_PLAY_BUTTON = 98;
hiscumm.SPUTM.VAR_CANCEL_BUTTON = 99;
hiscumm.SPUTM.VAR_QUIT_BUTTON = 100;
hiscumm.SPUTM.VAR_OK_BUTTON = 101;
hiscumm.SPUTM.VAR_SAVE_DISK_MSG = 102;
hiscumm.SPUTM.VAR_ENTER_NAME_MSG = 103;
hiscumm.SPUTM.VAR_NOT_SAVED_MSG = 104;
hiscumm.SPUTM.VAR_NOT_LOADED_MSG = 105;
hiscumm.SPUTM.VAR_SAVE_MSG = 106;
hiscumm.SPUTM.VAR_LOAD_MSG = 107;
hiscumm.SPUTM.VAR_SAVE_MENU_TITLE = 108;
hiscumm.SPUTM.VAR_LOAD_MENU_TITLE = 109;
hiscumm.SPUTM.VAR_GUI_COLORS = 110;
hiscumm.SPUTM.VAR_DEBUG_PASSWORD = 111;
hiscumm.SPUTM.VAR_UNKNOWN60 = 112;
hiscumm.SPUTM.VAR_UNKNOWN61 = 113;
hiscumm.SPUTM.VAR_UNKNOWN62 = 114;
hiscumm.SPUTM.VAR_UNKNOWN63 = 115;
hiscumm.SPUTM.VAR_UNKNOWN64 = 116;
hiscumm.SPUTM.VAR_MAIN_MENU_TITLE = 117;
hiscumm.SPUTM.VAR_RANDOM_NUM = 118;
hiscumm.SPUTM.VAR_TIMEDATE_YEAR = 119;
hiscumm.SPUTM.VAR_UNKNOWN70 = 120;
hiscumm.SPUTM.VAR_UNKNOWN71 = 121;
hiscumm.SPUTM.VAR_GAME_VERSION = 122;
hiscumm.SPUTM.VAR_CHARSET_MASK = 123;
hiscumm.SPUTM.VAR_UNKNOWN8 = 124;
hiscumm.SPUTM.VAR_TIMEDATE_HOUR = 125;
hiscumm.SPUTM.VAR_TIMEDATE_MINUTE = 126;
hiscumm.SPUTM.VAR_UNKNOWN9 = 127;
hiscumm.SPUTM.VAR_TIMEDATE_DAY = 128;
hiscumm.SPUTM.VAR_TIMEDATE_MONTH = 129;
hiscumm.SPUTM.UPDATE_INTERVAL = 10;
hiscumm.SPUTM.inTick = false;
hiscumm.SPUTM.VIEW_PALETTE_CHANGED = 1;
haxe.Timer.arr = new Array();
haxe.Timer.fqueue = new Array();
hiscumm.SCUMMThread.MAX_OVERRIDE = 8;
hiscumm.SCUMMThread.THREAD_FLAG_RECURSIVE = 1;
hiscumm.SCUMMThread.THREAD_FLAG_DELAYED = 2;
noflash.ByteArray.defaultObjectEncoding = 0;
js.Lib.document = document;
js.Lib.window = window;
js.Lib.onerror = null;
hiscumm.SPUTMResourceChunk.chunkTypes = [new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_RNAM,new noneko.Int32((21070 << 16) + 16717)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_MAXS,new noneko.Int32((19777 << 16) + 22611)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_DROO,new noneko.Int32((17490 << 16) + 20303)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_DSCR,new noneko.Int32((17491 << 16) + 17234)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_DSOU,new noneko.Int32((17491 << 16) + 20309)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_DCOS,new noneko.Int32((17475 << 16) + 20307)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_DCHR,new noneko.Int32((17475 << 16) + 18514)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_DOBJ,new noneko.Int32((17487 << 16) + 16970)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_AARY,new noneko.Int32((16705 << 16) + 21081)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_LECF,new noneko.Int32((19525 << 16) + 17222)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_LOFF,new noneko.Int32((19535 << 16) + 17990)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_SCRP,new noneko.Int32((21315 << 16) + 21072)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_COST,new noneko.Int32((17231 << 16) + 21332)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_ROOM,new noneko.Int32((21071 << 16) + 20301)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_SMAP,new noneko.Int32((21325 << 16) + 16720)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_RMHD,new noneko.Int32((21069 << 16) + 18500)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_CYCL,new noneko.Int32((17241 << 16) + 17228)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_TRNS,new noneko.Int32((21586 << 16) + 20051)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_PALS,new noneko.Int32((20545 << 16) + 19539)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_RMIM,new noneko.Int32((21069 << 16) + 18765)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_OBIM,new noneko.Int32((20290 << 16) + 18765)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_OBCD,new noneko.Int32((20290 << 16) + 17220)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_EXCD,new noneko.Int32((17752 << 16) + 17220)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_ENCD,new noneko.Int32((17742 << 16) + 17220)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_NLSC,new noneko.Int32((20044 << 16) + 21315)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_LSCR,new noneko.Int32((19539 << 16) + 17234)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_BOXD,new noneko.Int32((16975 << 16) + 22596)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_BOXM,new noneko.Int32((16975 << 16) + 22605)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_SCAL,new noneko.Int32((21315 << 16) + 16716)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_IM00,new noneko.Int32((18765 << 16) + 12336)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_WRAP,new noneko.Int32((22354 << 16) + 16720)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_OFFS,new noneko.Int32((20294 << 16) + 18003)),new hiscumm.SPUTMResourceChunk(hiscumm.SPUTMResourceChunkType.CHUNK_APAL,new noneko.Int32((16720 << 16) + 16716))];
hiscumm.SPUTMResource.FLAG_LOCKED = 1;
$Main.init = hiscumm.JSTest.main();

