[Scummvm-cvs-logs] CVS: scummvm/kyra codecs.h,1.2,1.3 cpsimage.cpp,1.2,1.3 font.cpp,1.3,1.4 kyra.cpp,1.10,1.11 kyra.h,1.4,1.5 palette.cpp,1.3,1.4 resource.cpp,1.6,1.7 resource.h,1.4,1.5 script.cpp,1.7,1.8 script.h,1.3,1.4 script_v1.cpp,1.5,1.6 wsamovie.cpp,1.3,1.4 wsamovie.h,1.2,1.3

Eugene Sandulenko sev at users.sourceforge.net
Sun Nov 14 12:12:03 CET 2004


Update of /cvsroot/scummvm/scummvm/kyra
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16271

Modified Files:
	codecs.h cpsimage.cpp font.cpp kyra.cpp kyra.h palette.cpp 
	resource.cpp resource.h script.cpp script.h script_v1.cpp 
	wsamovie.cpp wsamovie.h 
Log Message:
Patch #1066256. Mostly indentation fixes and some debug messages removed.


Index: codecs.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/codecs.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- codecs.h	30 Oct 2004 21:51:56 -0000	1.2
+++ codecs.h	14 Nov 2004 20:11:22 -0000	1.3
@@ -29,14 +29,14 @@
 #include "common/scummsys.h"
 
 namespace Kyra {
-	class Compression 
-	{
-	public:
-		static int decode80(const uint8* image_in, uint8* image_out);
-		static int decode40(const uint8* image_in, uint8* image_out);
-		static int decode3(const uint8* image_in, uint8* image_out, int s);
-		static int decode2(const uint8* s, uint8* d, int cb_s);
-	};
+class Compression 
+{
+public:
+	static int decode80(const uint8* image_in, uint8* image_out);
+	static int decode40(const uint8* image_in, uint8* image_out);
+	static int decode3(const uint8* image_in, uint8* image_out, int s);
+	static int decode2(const uint8* s, uint8* d, int cb_s);
+};
 } // end of namespace Kyra
 
 #endif

Index: cpsimage.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/cpsimage.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cpsimage.cpp	11 Nov 2004 13:35:21 -0000	1.2
+++ cpsimage.cpp	14 Nov 2004 20:11:22 -0000	1.3
@@ -27,159 +27,159 @@
 
 namespace Kyra {
 
-	struct CPSResource {
-		uint32 size;
-		uint16 width;
-	};
+struct CPSResource {
+	uint32 size;
+	uint16 width;
+};
 
-	static const CPSResource CPSResourceTable[] = {
-		{ 64000, 320 }, { 7740, 180 }, { 46080, 320 }, { 0, 0 }
-	};
-	
-	static int16 getWidthFromCPSRes(uint32 size) {
-		int16 c = 0;
-	
-		for (; CPSResourceTable[c].size; ++c) {
-			if (CPSResourceTable[c].size == size)
-				return CPSResourceTable[c].width;
-		}
+static const CPSResource CPSResourceTable[] = {
+	{ 64000, 320 }, { 7740, 180 }, { 46080, 320 }, { 0, 0 }
+};
 	
-		return -1;
+static int16 getWidthFromCPSRes(uint32 size) {
+	int16 c = 0;
+
+	for (; CPSResourceTable[c].size; ++c) {
+		if (CPSResourceTable[c].size == size)
+			return CPSResourceTable[c].width;
 	}
 
-	CPSImage::CPSImage(uint8* buffer, uint32 size) {
-		if (!buffer) {
-			error("resource created without data");
-		}
-		_ownPalette = 0;
-		Common::MemoryReadStream bufferstream(buffer, size);
-		
-		// reads in the Header
-		_cpsHeader._filesize = bufferstream.readUint16LE() + 2;
-		_cpsHeader._format = bufferstream.readUint16LE();
-		_cpsHeader._imagesize = bufferstream.readUint16LE();
-		_cpsHeader._pal = bufferstream.readUint32LE();
+	return -1;
+}
+
+CPSImage::CPSImage(uint8* buffer, uint32 size) {
+	if (!buffer) {
+		error("resource created without data");
+	}
+	_ownPalette = 0;
+	Common::MemoryReadStream bufferstream(buffer, size);
+	
+	// reads in the Header
+	_cpsHeader._filesize = bufferstream.readUint16LE() + 2;
+	_cpsHeader._format = bufferstream.readUint16LE();
+	_cpsHeader._imagesize = bufferstream.readUint16LE();
+	_cpsHeader._pal = bufferstream.readUint32LE();
 		
-		// lets check a bit
-		if(_cpsHeader._pal == 0x3000000) {
-			// if this was a compressed palette you should have strange graphics
-			
-			uint8* palbuffer = new uint8[768];
-			assert(palbuffer);
-			
-			bufferstream.read(palbuffer, 768 * sizeof(uint8));
+	// lets check a bit
+	if(_cpsHeader._pal == 0x3000000) {
+		// if this was a compressed palette you should have strange graphics
 			
-			_ownPalette = new Palette(palbuffer, 768);
-			assert(palbuffer);
-		}
+		uint8* palbuffer = new uint8[768];
+		assert(palbuffer);
 		
-		_image = new uint8[_cpsHeader._imagesize];
-		assert(_image);
+		bufferstream.read(palbuffer, 768 * sizeof(uint8));
+			
+		_ownPalette = new Palette(palbuffer, 768);
+		assert(palbuffer);
+	}
+	
+	_image = new uint8[_cpsHeader._imagesize];
+	assert(_image);
 		
-		uint8* imagebuffer = &buffer[bufferstream.pos()];
-		assert(imagebuffer);
+	uint8* imagebuffer = &buffer[bufferstream.pos()];
+	assert(imagebuffer);
 		
-		if(_cpsHeader._format == 4) {
-			Compression::decode80(imagebuffer, _image);
-		} else if(_cpsHeader._format == 3) {
-			Compression::decode3(imagebuffer, _image, _cpsHeader._imagesize);
-		} else {
-			error("unknown CPS format %d", _cpsHeader._format);
-		}
+	if(_cpsHeader._format == 4) {
+		Compression::decode80(imagebuffer, _image);
+	} else if(_cpsHeader._format == 3) {
+		Compression::decode3(imagebuffer, _image, _cpsHeader._imagesize);
+	} else {
+		error("unknown CPS format %d", _cpsHeader._format);
+	}
 		
-		int16 width = getWidthFromCPSRes(_cpsHeader._imagesize);
+	int16 width = getWidthFromCPSRes(_cpsHeader._imagesize);
 		
-		if(width == -1) {
-			warning("unknown CPS width(imagesize: %d)", _cpsHeader._imagesize);
-			delete [] buffer;
-			return;
-		}
+	if(width == -1) {
+		warning("unknown CPS width(imagesize: %d)", _cpsHeader._imagesize);
+		delete [] buffer;
+		return;
+	}
 		
-		_width = (uint16)width;
-		_height = _cpsHeader._imagesize / _width;
+	_width = (uint16)width;
+	_height = _cpsHeader._imagesize / _width;
 		
-		_transparency = -1;
+	_transparency = -1;
 		
-		delete [] buffer;
-	}
+	delete [] buffer;
+}
 	
-	CPSImage::~CPSImage() {
-		delete [] _image;
-		delete _ownPalette;
-	}
+CPSImage::~CPSImage() {
+	delete [] _image;
+	delete _ownPalette;
+}
 	
-	void CPSImage::drawToPlane(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 x, uint16 y) {
-		uint8* src = _image;
-		uint8* dst = &plane[y * planepitch + x];
-		uint32 copysize = planepitch - x;
+void CPSImage::drawToPlane(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 x, uint16 y) {
+	uint8* src = _image;
+	uint8* dst = &plane[y * planepitch + x];
+	uint32 copysize = planepitch - x;
+	
+	if (copysize > _width)
+		copysize = _width;
+	
+	if (_transparency == -1) {
+		// 'fast' blitting
+		for (uint16 y_ = 0; y_ < _height && y + y_ < planeheight; ++y_) {
+			memcpy(dst, src, copysize * sizeof(uint8));
+			dst += planepitch;
+			src += _width;
+		}
 		
-		if (copysize > _width)
-			copysize = _width;
+	} else {
+		// oh no! we have transparency so we have a very slow copy :/
 		
-		if (_transparency == -1) {
-			// 'fast' blitting
-			for (uint16 y_ = 0; y_ < _height && y + y_ < planeheight; ++y_) {
-				memcpy(dst, src, copysize * sizeof(uint8));
-				dst += planepitch;
-				src += _width;
-			}
-			
-		} else {
-			// oh no! we have transparency so we have a very slow copy :/
-			
-			for (uint16 yadd = 0; yadd < _height; ++yadd) {
-				for (uint16 xadd = 0; xadd < copysize; ++xadd) {
-					if (*src == _transparency) {
-						++dst;
-						++src;
-					} else {
-						*dst++ = *src++;
-					}
+		for (uint16 yadd = 0; yadd < _height; ++yadd) {
+			for (uint16 xadd = 0; xadd < copysize; ++xadd) {
+				if (*src == _transparency) {
+					++dst;
+					++src;
+				} else {
+					*dst++ = *src++;
 				}
-				
-				src += _width - copysize;
-				dst += planepitch - copysize;
 			}
+			
+			src += _width - copysize;
+			dst += planepitch - copysize;
 		}
 	}
+}
 	
-	void CPSImage::drawToPlane(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 x, uint16 y,
-								uint16 srcx, uint16 srcy, uint16 srcwidth, uint16 srcheight) {
-		uint8* src = &_image[srcy * _width + srcx];
-		uint8* dst = &plane[y * planepitch + x];
-		uint32 copysize = planepitch - x;
+void CPSImage::drawToPlane(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 x, uint16 y,
+							uint16 srcx, uint16 srcy, uint16 srcwidth, uint16 srcheight) {
+	uint8* src = &_image[srcy * _width + srcx];
+	uint8* dst = &plane[y * planepitch + x];
+	uint32 copysize = planepitch - x;
+	
+	if (srcwidth > _width)
+		srcwidth = _width;
+	
+	if (copysize > srcwidth)
+		copysize = srcwidth;
 		
-		if (srcwidth > _width)
-			srcwidth = _width;
+	if (_transparency == -1) {
+		// 'fast' blitting
+		for (uint16 y_ = 0; y_ < srcheight && y + y_ < planeheight; ++y_) {
+			memcpy(dst, src, copysize * sizeof(uint8));
+			dst += planepitch;
+			src += _width;
+		}
 		
-		if (copysize > srcwidth)
-			copysize = srcwidth;
+	} else {
+		// oh no! we have transparency so we have a very slow copy :/
 		
-		if (_transparency == -1) {
-			// 'fast' blitting
-			for (uint16 y_ = 0; y_ < srcheight && y + y_ < planeheight; ++y_) {
-				memcpy(dst, src, copysize * sizeof(uint8));
-				dst += planepitch;
-				src += _width;
-			}
-			
-		} else {
-			// oh no! we have transparency so we have a very slow copy :/
-			
-			for (uint16 yadd = 0; yadd < srcheight; ++yadd) {
-				for (uint16 xadd = 0; xadd < copysize; ++xadd) {
-					if (*src == _transparency) {
-						++dst;
-						++src;
-					} else {
-						*dst++ = *src++;
-					}
+		for (uint16 yadd = 0; yadd < srcheight; ++yadd) {
+			for (uint16 xadd = 0; xadd < copysize; ++xadd) {
+				if (*src == _transparency) {
+					++dst;
+					++src;
+				} else {
+					*dst++ = *src++;
 				}
-				
-				dst += planepitch - copysize;
-				src += _width - copysize;
 			}
+			
+			dst += planepitch - copysize;
+			src += _width - copysize;
 		}
 	}
+}
 } // end of namespace Kyra
 

Index: font.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/font.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- font.cpp	30 Oct 2004 18:02:48 -0000	1.3
+++ font.cpp	14 Nov 2004 20:11:22 -0000	1.4
@@ -29,301 +29,299 @@
 #endif
 
 namespace Kyra {
-	const uint16 FontHeader_Magic1 = 0x0500;
-	const uint16 FontHeader_Magic2 = 0x000e;
-	const uint16 FontHeader_Magic3 = 0x0014;
-	
-	Font::Font(uint8* buffer, uint32 size) {
-		if (!buffer) {
-			error("resource created without data");
-		}
-			
-		_buffer = buffer;
-		
-		Common::MemoryReadStream bufferstream(buffer, size);
-		
-		bufferstream.read(&_fontHeader, sizeof(_fontHeader));
-		
-		// tests for the magic values
-		if(_fontHeader._magic1 != FontHeader_Magic1 || _fontHeader._magic2 != FontHeader_Magic2 ||
-			_fontHeader._magic3 != FontHeader_Magic3) {
-			error("magic vars in the fontheader are corrupt\n"
-				  "_magic1 = 0x%x, _magic2 = 0x%x, _magic3 = 0x%x",
-				_fontHeader._magic1, _fontHeader._magic2, _fontHeader._magic3);
-		}
-		
-		// init all the pointers
-		_offsetTable = (uint16*)&buffer[bufferstream.pos()];
-		_charWidth = &buffer[_fontHeader._charWidthOffset];
-		_charHeight = (uint16*)&buffer[_fontHeader._charHeightOffset];
-		_charBits = &buffer[_fontHeader._charBitsOffset];
-		
-		// now prerender =)
-		preRenderAllChars(bufferstream.pos());
+const uint16 FontHeader_Magic1 = 0x0500;
+const uint16 FontHeader_Magic2 = 0x000e;
+const uint16 FontHeader_Magic3 = 0x0014;
 
-		// This value seems to be a version or language variable
-		// Known Values
-		// ------------
-		// Russian Floppy:			0x1010
-		// German Floppy and English CD:	0x1011
-		// Kyrandia 2 should be 0x1012
-		debug("_version = 0x%x", _fontHeader._version);
-  
-		delete [] _buffer;
-		_buffer = 0;
-		_offsetTable = 0;
-		_charHeight = 0;
-		_charWidth = 0;
-		_charBits = 0;
+Font::Font(uint8* buffer, uint32 size) {
+	if (!buffer) {
+		error("resource created without data");
 	}
-	
-	Font::~Font() {
 		
+	_buffer = buffer;
+	
+	Common::MemoryReadStream bufferstream(buffer, size);
+	
+	bufferstream.read(&_fontHeader, sizeof(_fontHeader));
+	
+	// tests for the magic values
+	if(_fontHeader._magic1 != FontHeader_Magic1 || _fontHeader._magic2 != FontHeader_Magic2 ||
+		_fontHeader._magic3 != FontHeader_Magic3) {
+		error("magic vars in the fontheader are corrupt\n"
+			  "_magic1 = 0x%x, _magic2 = 0x%x, _magic3 = 0x%x",
+			_fontHeader._magic1, _fontHeader._magic2, _fontHeader._magic3);
 	}
 	
-	uint32 Font::getStringWidth(const char* string, char terminator) {
-		uint32 strsize;
-		
-		for (strsize = 0; string[strsize] != terminator && string[strsize] != '\0'; ++strsize)
-			;
+	// init all the pointers
+	_offsetTable = (uint16*)&buffer[bufferstream.pos()];
+	_charWidth = &buffer[_fontHeader._charWidthOffset];
+	_charHeight = (uint16*)&buffer[_fontHeader._charHeightOffset];
+	_charBits = &buffer[_fontHeader._charBitsOffset];
+	
+	// now prerender =)
+	preRenderAllChars(bufferstream.pos());
+
+	// This value seems to be a version or language variable
+	// Known Values
+	// ------------
+	// Russian Floppy:			0x1010
+	// German Floppy and English/German CD:	0x1011
+	debug("Font::_version = 0x%x", _fontHeader._version);
+ 
+	delete [] _buffer;
+	_buffer = 0;
+	_offsetTable = 0;
+	_charHeight = 0;
+	_charWidth = 0;
+	_charBits = 0;
+}
+	
+Font::~Font() {
+	// FIXME: Release memory of the prerendered chars
+}
+	
+uint32 Font::getStringWidth(const char* string, char terminator) {
+	uint32 strsize;
 		
-		uint32 stringwidth = 0;
+	for (strsize = 0; string[strsize] != terminator && string[strsize] != '\0'; ++strsize)
+		;
 		
-		for (uint32 pos = 0; pos < strsize; ++pos) {
-			stringwidth += _preRenderedChars[string[pos]].width;
-		}
+	uint32 stringwidth = 0;
 		
-		return stringwidth;
+	for (uint32 pos = 0; pos < strsize; ++pos) {
+		stringwidth += _preRenderedChars[string[pos]].width;
 	}
-	
-	const uint8* Font::getChar(char c, uint8* width, uint8* height, uint8* heightadd) {
-		PreRenderedChar& c_ = _preRenderedChars[c];
 		
-		*width = c_.width;
-		*height = c_.height;
-		*heightadd = c_.heightadd;
-		
-		return c_.c;
-	}
+	return stringwidth;
+}
 	
-	// splits up the String in a word	
-	const char* Font::getNextWord(const char* string, uint32* size) {
-		uint32 startpos = 0;
-		*size = 0;
-		
-		// gets start of the word
-		for (; string[startpos] == ' '; ++startpos)
-			;
-					
-		// not counting size
-		for (*size = 0; string[startpos + *size] != ' ' && string[startpos + *size] != '\0'; ++(*size))
-			;
-		
-		++(*size);
-      				
-		return &string[startpos];
-	}
+const uint8* Font::getChar(char c, uint8* width, uint8* height, uint8* heightadd) {
+	PreRenderedChar& c_ = _preRenderedChars[c];
 	
-	// Move this to Font declaration?
-	struct WordChunk {
-		const char* _string;
-		uint32 _size;
-	};
+	*width = c_.width;
+	*height = c_.height;
+	*heightadd = c_.heightadd;
 	
-	void Font::drawStringToPlane(const char* string,
-								uint8* plane, uint16 planewidth, uint16 planeheight,
-								uint16 x, uint16 y, uint8 color) {
+	return c_.c;
+}
+	
+// splits up the String in a word	
+const char* Font::getNextWord(const char* string, uint32* size) {
+	uint32 startpos = 0;
+	*size = 0;
+	
+	// gets start of the word
+	for (; string[startpos] == ' '; ++startpos)
+		;
+				
+	// not counting size
+	for (*size = 0; string[startpos + *size] != ' ' && string[startpos + *size] != '\0'; ++(*size))
+		;
+	
+	++(*size);
+				
+	return &string[startpos];
+}
+	
+// Move this to Font declaration?
+struct WordChunk {
+	const char* _string;
+	uint32 _size;
+};
+
+void Font::drawStringToPlane(const char* string,
+				uint8* plane, uint16 planewidth, uint16 planeheight,
+				uint16 x, uint16 y, uint8 color) {
 								
-		// lets do it word after word
-		Common::Array<WordChunk> words;
-		
-		uint32 lastPos = 0;
-		uint32 lastSize = 0;
-		uint32 strlgt = strlen(string);
+	// lets do it word after word
+	Common::Array<WordChunk> words;
+	
+	uint32 lastPos = 0;
+	uint32 lastSize = 0;
+	uint32 strlgt = strlen(string);
+	
+	while (true) {
+		WordChunk newchunk;
+		newchunk._string = getNextWord(&string[lastPos], &lastSize);
+		newchunk._size = lastSize;
+		lastPos += lastSize;	
+  		
+		words.push_back(newchunk);
+			
+		if (lastPos >= strlgt)
+			break;
+	}
 		
-		while (true) {
-			WordChunk newchunk;
-			newchunk._string = getNextWord(&string[lastPos], &lastSize);
-			newchunk._size = lastSize;
-
-			lastPos += lastSize;	
-   		
-			words.push_back(newchunk);
+	uint16 current_x = x, current_y = y;
+	uint8 heighest = 0;
+	
+	const uint8* src = 0;
+	uint8 width = 0, height = 0, heightadd = 0;
+	
+	// now the have alle of these words
+	for (uint32 tmp = 0; tmp < words.size(); ++tmp) {
+		lastSize = getStringWidth(words[tmp]._string, ' ');
 			
-			if (lastPos >= strlgt)
-				break;
+		// adjust x position
+		if (current_x + lastSize >= planewidth) {
+			// hmm lets move it a bit to the left
+			if (current_x == x && (int16)planewidth - (int16)lastSize >= 0) {
+				current_x = planewidth - lastSize;
+			} else {
+				current_x = x;
+				if (heighest) 
+					current_y += heighest + 2;
+				else // now we are using just the fist char :)
+					current_y += _preRenderedChars[words[tmp]._string[0]].height;
+				heighest = 0;
+			}
 		}
 		
-		uint16 current_x = x, current_y = y;
-		uint8 heighest = 0;
-		
-		const uint8* src = 0;
-		uint8 width = 0, height = 0, heightadd = 0;
+		// TODO: maybe test if current_y >= planeheight ?
 		
-		// now the have alle of these words
-		for (uint32 tmp = 0; tmp < words.size(); ++tmp) {
-			lastSize = getStringWidth(words[tmp]._string, ' ');
-			
-			// adjust x position
-			if (current_x + lastSize >= planewidth) {
-				// hmm lets move it a bit to the left
-				if (current_x == x && (int16)planewidth - (int16)lastSize >= 0) {
-					current_x = planewidth - lastSize;
-				} else {
-					current_x = x;
-					if (heighest) 
-						current_y += heighest + 2;
-					else // now we are using just the fist char :)
-						current_y += _preRenderedChars[words[tmp]._string[0]].height;
-					heighest = 0;
-				}
-			}
+		// output word :)
+		for (lastPos = 0; lastPos < words[tmp]._size; ++lastPos) {
+			if (words[tmp]._string[lastPos] == '\0')
+				break;
+				
+			// gets our char :)
+			src = getChar(words[tmp]._string[lastPos], &width, &height, &heightadd);
 			
-			// TODO: maybe test if current_y >= planeheight ?
+			// lets draw our char
+			drawCharToPlane(src, color, width, height, plane, planewidth, planeheight, current_x, current_y + heightadd);
 			
-			// output word :)
-			for (lastPos = 0; lastPos < words[tmp]._size; ++lastPos) {
-				if (words[tmp]._string[lastPos] == '\0')
-					break;
-					
-				// gets our char :)
-				src = getChar(words[tmp]._string[lastPos], &width, &height, &heightadd);
-				
-				// lets draw our char
-				drawCharToPlane(src, color, width, height, plane, planewidth, planeheight, current_x, current_y + heightadd);
-				
-				current_x += width;
-				heighest = MAX(heighest, height);
-			}
+			current_x += width;
+			heighest = MAX(heighest, height);
 		}
 	}
+}
 	
-	void Font::drawCharToPlane(const uint8* c, uint8 color, uint8 width, uint8 height,
-							uint8* plane, uint16 planewidth, uint16 planeheight, uint16 x, uint16 y) {
-		const uint8* src = c;					
-		
-		// blit them to the screen
-		for (uint8 yadd = 0; yadd < height; ++yadd) {
-			for (uint8 xadd = 0; xadd < width; ++xadd) {
-				switch(*src) {					
-				case 1:
-					plane[(y + yadd) * planewidth + x + xadd] = color;
-					break;
-					
-				case 2:
-					plane[(y + yadd) * planewidth + x + xadd] = 14;
-					break;
-					
-				case 3:
-					plane[(y + yadd) * planewidth + x + xadd] = 0;
-					break;
-					
-				default:
-					// nothing to do now
-					break;
-				};
+void Font::drawCharToPlane(const uint8* c, uint8 color, uint8 width, uint8 height,
+				uint8* plane, uint16 planewidth, uint16 planeheight, uint16 x, uint16 y) {
+	const uint8* src = c;					
+	
+	// blit them to the screen
+	for (uint8 yadd = 0; yadd < height; ++yadd) {
+		for (uint8 xadd = 0; xadd < width; ++xadd) {
+			switch(*src) {					
+			case 1:
+				plane[(y + yadd) * planewidth + x + xadd] = color;
+				break;
 				
-				++src;
-			}
+			case 2:
+				plane[(y + yadd) * planewidth + x + xadd] = 14;
+				break;
+				
+			case 3:
+				plane[(y + yadd) * planewidth + x + xadd] = 0;
+				break;
+				
+			default:
+				// nothing to do now
+				break;
+			};
+			
+			++src;
 		}
 	}
+}
 	
-	void Font::preRenderAllChars(uint16 offsetTableOffset) {
-		uint16 startOffset = _offsetTable[0];
-		uint16 currentOffset = offsetTableOffset;
-		uint8 currentChar = 0;
+void Font::preRenderAllChars(uint16 offsetTableOffset) {
+	uint16 startOffset = _offsetTable[0];
+	uint16 currentOffset = offsetTableOffset;
+	uint8 currentChar = 0;
+	
+	for (; currentOffset < startOffset; ++currentChar, currentOffset += sizeof(uint16)) {
+		// lets prerender the char :)
+		
+		PreRenderedChar newChar;
+		
+		newChar.c = new uint8[(_charHeight[currentChar] >> 8) * _charWidth[currentChar]];
+		assert(newChar.c);
+		memset(newChar.c, 0, sizeof(uint8) * (_charHeight[currentChar] >> 8) * _charWidth[currentChar]);
+		newChar.height = (_charHeight[currentChar] >> 8);
+		newChar.width = _charWidth[currentChar];
+		newChar.heightadd = _charHeight[currentChar] & 0xFF;
+		
+		uint8* src = _buffer + _offsetTable[currentChar];
+		uint8* dst = &newChar.c[0];
+		uint8 index = 0;
 		
-		for (; currentOffset < startOffset; ++currentChar, currentOffset += sizeof(uint16)) {
-			// lets prerender the char :)
-			
-			PreRenderedChar newChar;
-			
-			newChar.c = new uint8[(_charHeight[currentChar] >> 8) * _charWidth[currentChar]];
-			assert(newChar.c);
-			memset(newChar.c, 0, sizeof(uint8) * (_charHeight[currentChar] >> 8) * _charWidth[currentChar]);
-			newChar.height = (_charHeight[currentChar] >> 8);
-			newChar.width = _charWidth[currentChar];
-			newChar.heightadd = _charHeight[currentChar] & 0xFF;
-			
-			uint8* src = _buffer + _offsetTable[currentChar];
-			uint8* dst = &newChar.c[0];
-			uint8 index = 0;
-			
 #ifdef DUMP_FILES
-			static char filename[32] = { 0 };
-			sprintf(filename, "dumps/char%d.dmp", currentChar);
-			FILE* dump = fopen(filename, "w+");
-			assert(dump);
-			
-			fprintf(dump, "This should be a '%c'\n", currentChar);
+		static char filename[32] = { 0 };
+		sprintf(filename, "dumps/char%d.dmp", currentChar);
+		FILE* dump = fopen(filename, "w+");
+		assert(dump);
+		
+		fprintf(dump, "This should be a '%c'\n", currentChar);
 #endif
 			
-			// prerender the char
-			for (uint8 yadd = 0; yadd < newChar.height; ++yadd) {
-				for (uint8 xadd = 0; xadd < newChar.width; ++xadd) {
-					if (xadd % 2) {
-						index = ((*src) & 0xF0) >> 4;
-						++src;
-					} else {
-						index = (*src) & 0x0F;
-					}
-					
-					switch(index) {
-					case 1:
+		// prerender the char
+		for (uint8 yadd = 0; yadd < newChar.height; ++yadd) {
+			for (uint8 xadd = 0; xadd < newChar.width; ++xadd) {
+				if (xadd % 2) {
+					index = ((*src) & 0xF0) >> 4;
+					++src;
+				} else {
+					index = (*src) & 0x0F;
+				}
+				
+				switch(index) {
+				case 1:
 #ifdef DUMP_FILES
-						fprintf(dump, "#");
+					fprintf(dump, "#");
 #endif
-						dst[yadd * newChar.width + xadd] = 1;
-						break;
-					
-					case 2:
+					dst[yadd * newChar.width + xadd] = 1;
+					break;
+				
+				case 2:
 #ifdef DUMP_FILES
-						fprintf(dump, "$");
+					fprintf(dump, "$");
 #endif
-						dst[yadd * newChar.width + xadd] = 2;
-						break;
-					
-					case 3:
+					dst[yadd * newChar.width + xadd] = 2;
+					break;
+				
+				case 3:
 #ifdef DUMP_FILES
-						fprintf(dump, "§");
+					fprintf(dump, "§");
 #endif
-						dst[yadd * newChar.width + xadd] = 3;
-						break;
-					
-					default:
+					dst[yadd * newChar.width + xadd] = 3;
+					break;
+				
+				default:
 #ifdef DUMP_FILES
-						fprintf(dump, "%d", index);
+					fprintf(dump, "%d", index);
 #endif
-						break;
-					};
-				}
+					break;
+				};
+			}
 				
-				if (newChar.width % 2) {
-					++src;
-				}
+			if (newChar.width % 2) {
+				++src;
+			}
 #ifdef DUMP_FILES
-				fprintf(dump, "\n");
+			fprintf(dump, "\n");
 #endif
-			}
+		}
 			
 #ifdef DUMP_FILES
-			fprintf(dump, "\nThis is the created map:\n");
-			// now print the whole thing again
-			for (uint8 yadd = 0; yadd < newChar.height; ++yadd) {
-				for (uint8 xadd = 0; xadd < newChar.width; ++xadd) {
-					fprintf(dump, "%d", dst[yadd * newChar.width + xadd]);
-				}
-				fprintf(dump, "\n");
+		fprintf(dump, "\nThis is the created map:\n");
+		// now print the whole thing again
+		for (uint8 yadd = 0; yadd < newChar.height; ++yadd) {
+			for (uint8 xadd = 0; xadd < newChar.width; ++xadd) {
+				fprintf(dump, "%d", dst[yadd * newChar.width + xadd]);
 			}
-			fclose(dump);
+			fprintf(dump, "\n");
+		}
+		fclose(dump);
 #endif
-			
-			_preRenderedChars[currentChar] = newChar;
-			
-			if (currentChar == 255) {
-				break;
-			}
+		
+		_preRenderedChars[currentChar] = newChar;
+		
+		if (currentChar == 255) {
+			break;
 		}
 	}
+}
 } // end of namespace Kyra
 

Index: kyra.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/kyra.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- kyra.cpp	14 Nov 2004 14:46:56 -0000	1.10
+++ kyra.cpp	14 Nov 2004 20:11:22 -0000	1.11
@@ -52,7 +52,7 @@
 	{"kyra1cd", "Legend of Kyrandia (CD)",  GF_TALKIE | GF_KYRA1,  "CHAPTER1.VRM"},
 	{"kyra2", "Hand of Fate (Floppy)", GF_FLOPPY | GF_KYRA2, 0 },
 	{"kyra2cd", "Hand of Fate (CD)", GF_TALKIE | GF_KYRA2, "AUDIO.PAK"},
-	{"kyra3", "Malcom's Revenge", GF_TALKIE | GF_KYRA3, "K3INTRO0.VQA"},
+	{"kyra3", "Malcolm's Revenge", GF_TALKIE | GF_KYRA3, "K3INTRO0.VQA"},
 	{0, 0, 0, 0}
 };
 
@@ -188,7 +188,7 @@
 void KyraEngine::go() {
 	warning("Kyrandia Engine ::go()");
 	// starts the init script
-	/*if (!_currentScript->startScript(kSetupScene)) {
+/*	if (!_currentScript->startScript(kSetupScene)) {
 		error("couldn't init '_STARTUP.EMC' script");
 	}
 

Index: kyra.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/kyra.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- kyra.h	11 Nov 2004 13:35:21 -0000	1.4
+++ kyra.h	14 Nov 2004 20:11:22 -0000	1.5
@@ -45,12 +45,12 @@
 };
 
 namespace Kyra {
-	class Resourcemanager;
-	class CPSImage;
-	class Font;
-	class Palette;
-	class VMContext;
-	class MusicPlayer;
+class Resourcemanager;
+class CPSImage;
+class Font;
+class Palette;
+class VMContext;
+class MusicPlayer;
 
 class KyraEngine : public Engine {
 public:

Index: palette.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/palette.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- palette.cpp	11 Nov 2004 13:35:21 -0000	1.3
+++ palette.cpp	14 Nov 2004 20:11:22 -0000	1.4
@@ -27,54 +27,54 @@
 
 namespace Kyra {
 
-	Palette::Palette(uint8* data, uint32 size) {
-		if (!data) {
-			error("resource created without data");
-		}
+Palette::Palette(uint8* data, uint32 size) {
+	if (!data) {
+		error("resource created without data");
+	}
+	
+	if (size != 768) {
+		Common::MemoryReadStream datastream(data, size);
 		
-		if (size != 768) {
-			Common::MemoryReadStream datastream(data, size);
-			
-			datastream.readSint32LE();
-			int imageSize = datastream.readSint16LE();
-			
-			if (imageSize != 768) {
-				error("decompresed palette is not 768 byte long!");
-			}
-			
-			// lets uncompress this palette :)
-			_palette = new uint8[imageSize];
-			assert(_palette);
-			
-			// made decompression
-			if (Compression::decode80(data + 10, _palette) != 768) {
-				error("decode80 decompressesize != 768 bytes");
-			}
-			
-			delete [] data;
-			data = _palette;
-		}
+		datastream.readSint32LE();
+		int imageSize = datastream.readSint16LE();
 		
-		// hmm.. common/system.h Docu is wrong or SDL Backend has a bug :)
-		// a palette should have this order:
-		// R1-G1-B1-A1-R2-G2-B2-A2-...
-		// so we need 4 bytes per color
-		_palette = new uint8[256 * 4];
+		if (imageSize != 768) {
+			error("decompresed palette is not 768 byte long!");
+		}
 		
-		uint8* currentpossrc = &data[0];
-		uint8* currentposdst = &_palette[0];
+		// lets uncompress this palette :)
+		_palette = new uint8[imageSize];
+		assert(_palette);
 		
-		// creates the original pallette (only first 6 bits are used)
-		for (uint32 i = 0; i < 256; i++) {
-			currentposdst[0] = currentpossrc[0] << 2;
-			currentposdst[1] = currentpossrc[1] << 2;
-			currentposdst[2] = currentpossrc[2] << 2;
-			currentpossrc += 3;
-			currentposdst += 4;
+		// made decompression
+		if (Compression::decode80(data + 10, _palette) != 768) {
+			error("decode80 decompressesize != 768 bytes");
 		}
 		
 		delete [] data;
+		data = _palette;
+	}
+		
+	// hmm.. common/system.h Docu is wrong or SDL Backend has a bug :)
+	// a palette should have this order:
+	// R1-G1-B1-A1-R2-G2-B2-A2-...
+	// so we need 4 bytes per color
+	_palette = new uint8[256 * 4];
+		
+	uint8* currentpossrc = &data[0];
+	uint8* currentposdst = &_palette[0];
+		
+	// creates the original pallette (only first 6 bits are used)
+	for (uint32 i = 0; i < 256; i++) {
+		currentposdst[0] = currentpossrc[0] << 2;
+		currentposdst[1] = currentpossrc[1] << 2;
+		currentposdst[2] = currentpossrc[2] << 2;
+		currentpossrc += 3;
+		currentposdst += 4;
 	}
+		
+	delete [] data;
+}
 
 } // end of namespace Kyra
 

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/resource.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- resource.cpp	11 Nov 2004 13:35:21 -0000	1.6
+++ resource.cpp	14 Nov 2004 20:11:22 -0000	1.7
@@ -27,242 +27,241 @@
 #include "script.h"
 
 namespace Kyra {
-	Resourcemanager::Resourcemanager(KyraEngine* engine) {
-		_engine = engine;
-		
-		// prefetches all PAK Files
-		
-		// ugly a hardcoded list
-		// TODO: use the FS Backend to get all .PAK Files and load them
-		// or any other thing to get all files
-		static const char* kyra1Filelist[] = {
-			"A_E.PAK", "DAT.PAK", "F_L.PAK", "MAP_5.PAK", "MSC.PAK", "M_S.PAK",
-			"S_Z.PAK", "WSA1.PAK", "WSA2.PAK", "WSA3.PAK", "WSA4.PAK", "WSA5.PAK",
-			"WSA6.PAK", 0
-		};
+Resourcemanager::Resourcemanager(KyraEngine* engine) {
+	_engine = engine;
 		
-		static const char* kyra1CDFilelist[] = {
-			"ADL.PAK", "BRINS.PAK", "CLIFF.PAK", "ENTER.PAK", "FORESTA.PAK", "GEM.PAK", "INTRO1.PAK",
-			"LEPHOLE.PAK", "OAKS.PAK", "SPELL.PAK", "WILLOW.PAK", "ALCHEMY.PAK", "BROKEN.PAK", "COL.PAK",
-			"EXTHEAL.PAK", "FORESTB.PAK", "GEMCUT.PAK", "INTRO2.PAK", "LIBRARY.PAK", "PLATEAU.PAK", "SPRING.PAK",
-			"WISE.PAK", "ALGAE.PAK", "BURN.PAK", "DARMS.PAK", "EXTPOT.PAK", "FORESTC.PAK", "GENCAVB.PAK",
-			"INTRO3.PAK", "MISC.PAK", "PLTCAVE.PAK", "SQUARE.PAK", "XEDGE.PAK", "ALTAR.PAK", "CASTLE.PAK",
-			"DEAD.PAK", "EXTSPEL.PAK", "FOUNTN.PAK", "GENHALL.PAK", "INTRO4.PAK", "MIX.PAK", "POTION.PAK",
-			"STARTUP.PAK", "XEDGEB.PAK", "ARCH.PAK", "CATACOM.PAK", "DNSTAIR.PAK", "FALLS.PAK", "FOYER.PAK",
-			"GEN_CAV.PAK", "KITCHEN.PAK", "MOONCAV.PAK", "RUBY.PAK", "STUMP.PAK", "XEDGEC.PAK", "BALCONY.PAK",
-			"CAVE.PAK", "DRAGON.PAK", "FESTSTH.PAK", "FSOUTH.PAK", "GLADE.PAK", "KYRAGEM.PAK", "NCLIFF.PAK",
-			"SICKWIL.PAK", "TEMPLE.PAK", "XMI.PAK", "BELROOM.PAK",  "CAVEB.PAK", "EDGE.PAK", "FGOWEST.PAK",
-			"FSOUTHB.PAK", "GRAVE.PAK", "LAGOON.PAK", "NCLIFFB.PAK", "SND.PAK", "TRUNK.PAK", "ZROCK.PAK",
-			"BONKBG.PAK", "CGATE.PAK", "EDGEB.PAK", "FINALE.PAK", "FWSTSTH.PAK", "GRTHALL.PAK", "LANDING.PAK",
-			"NWCLIFB.PAK", "SONG.PAK", "UPSTAIR.PAK", "BRIDGE.PAK", "CHASM.PAK", "EMCAV.PAK", "FNORTH.PAK",
-			"GATECV.PAK", "HEALER.PAK", "LAVA.PAK", "NWCLIFF.PAK", "SORROW.PAK", "WELL.PAK", 0
-		};
+	// prefetches all PAK Files
+	
+	// ugly a hardcoded list
+	// TODO: use the FS Backend to get all .PAK Files and load them
+	// or any other thing to get all files
+	static const char* kyra1Filelist[] = {
+		"A_E.PAK", "DAT.PAK", "F_L.PAK", "MAP_5.PAK", "MSC.PAK", "M_S.PAK",
+		"S_Z.PAK", "WSA1.PAK", "WSA2.PAK", "WSA3.PAK", "WSA4.PAK", "WSA5.PAK",
+		"WSA6.PAK", 0
+	};
+	
+	static const char* kyra1CDFilelist[] = {
+		"ADL.PAK", "BRINS.PAK", "CLIFF.PAK", "ENTER.PAK", "FORESTA.PAK", "GEM.PAK", "INTRO1.PAK",
+		"LEPHOLE.PAK", "OAKS.PAK", "SPELL.PAK", "WILLOW.PAK", "ALCHEMY.PAK", "BROKEN.PAK", "COL.PAK",
+		"EXTHEAL.PAK", "FORESTB.PAK", "GEMCUT.PAK", "INTRO2.PAK", "LIBRARY.PAK", "PLATEAU.PAK", "SPRING.PAK",
+		"WISE.PAK", "ALGAE.PAK", "BURN.PAK", "DARMS.PAK", "EXTPOT.PAK", "FORESTC.PAK", "GENCAVB.PAK",
+		"INTRO3.PAK", "MISC.PAK", "PLTCAVE.PAK", "SQUARE.PAK", "XEDGE.PAK", "ALTAR.PAK", "CASTLE.PAK",
+		"DEAD.PAK", "EXTSPEL.PAK", "FOUNTN.PAK", "GENHALL.PAK", "INTRO4.PAK", "MIX.PAK", "POTION.PAK",
+		"STARTUP.PAK", "XEDGEB.PAK", "ARCH.PAK", "CATACOM.PAK", "DNSTAIR.PAK", "FALLS.PAK", "FOYER.PAK",
+		"GEN_CAV.PAK", "KITCHEN.PAK", "MOONCAV.PAK", "RUBY.PAK", "STUMP.PAK", "XEDGEC.PAK", "BALCONY.PAK",
+		"CAVE.PAK", "DRAGON.PAK", "FESTSTH.PAK", "FSOUTH.PAK", "GLADE.PAK", "KYRAGEM.PAK", "NCLIFF.PAK",
+		"SICKWIL.PAK", "TEMPLE.PAK", "XMI.PAK", "BELROOM.PAK",  "CAVEB.PAK", "EDGE.PAK", "FGOWEST.PAK",
+		"FSOUTHB.PAK", "GRAVE.PAK", "LAGOON.PAK", "NCLIFFB.PAK", "SND.PAK", "TRUNK.PAK", "ZROCK.PAK",
+		"BONKBG.PAK", "CGATE.PAK", "EDGEB.PAK", "FINALE.PAK", "FWSTSTH.PAK", "GRTHALL.PAK", "LANDING.PAK",
+		"NWCLIFB.PAK", "SONG.PAK", "UPSTAIR.PAK", "BRIDGE.PAK", "CHASM.PAK", "EMCAV.PAK", "FNORTH.PAK",
+		"GATECV.PAK", "HEALER.PAK", "LAVA.PAK", "NWCLIFF.PAK", "SORROW.PAK", "WELL.PAK", 0
+	};
 		
-		const char** usedFilelist = 0;
+	const char** usedFilelist = 0;
 		
-		if (_engine->game() == KYRA1)
-			usedFilelist = kyra1Filelist;
-		else if (_engine->game() == KYRA1CD)
-			usedFilelist = kyra1CDFilelist;
-		else
-			error("no filelist found for this game");
-
-		for (uint32 tmp = 0; usedFilelist[tmp]; ++tmp) {
-			// prefetch file
-			PAKFile* file = new PAKFile(usedFilelist[tmp]);
-			assert(file);			
+	if (_engine->game() == KYRA1)
+		usedFilelist = kyra1Filelist;
+	else if (_engine->game() == KYRA1CD)
+		usedFilelist = kyra1CDFilelist;
+	else
+		error("no filelist found for this game");
 
-			if (file->isOpen() && file->isValid())
-				_pakfiles.push_back(file);
-			else
-				debug("couldn't load file '%s' correctly", usedFilelist[tmp]);
-		}
+	for (uint32 tmp = 0; usedFilelist[tmp]; ++tmp) {
+		// prefetch file
+		PAKFile* file = new PAKFile(usedFilelist[tmp]);
+		assert(file);			
+			
+		if (file->isOpen() && file->isValid())
+			_pakfiles.push_back(file);
+		else
+			debug("couldn't load file '%s' correctly", usedFilelist[tmp]);
 	}
+}
 	
-	Resourcemanager::~Resourcemanager() {
-		Common::List<PAKFile*>::iterator start = _pakfiles.begin();
-
-		for (;start != _pakfiles.end(); ++start) {
-			delete *start;
-			*start = 0;
-		}
+Resourcemanager::~Resourcemanager() {
+	Common::List<PAKFile*>::iterator start = _pakfiles.begin();
+		
+	for (;start != _pakfiles.end(); ++start) {
+		delete *start;
+		*start = 0;
 	}
+}
 	
-	uint8* Resourcemanager::fileData(const char* file, uint32* size) {
-		uint8* buffer = 0;
-		File file_;
-
-		// test to open it in the main dir
-		if (file_.open(file)) {
+uint8* Resourcemanager::fileData(const char* file, uint32* size) {
+	uint8* buffer = 0;
+	File file_;
 		
-			*size = file_.size();
-			
-			buffer = new uint8[*size];
-			assert(buffer);
+	// test to open it in the main dir
+	if (file_.open(file)) {
+	
+		*size = file_.size();
+		buffer = new uint8[*size];
+		assert(buffer);
 			
-			file_.read(buffer, *size);
+		file_.read(buffer, *size);
 			
-			file_.close();
-		
-		} else {
-			// opens the file in a PAK File
-			Common::List<PAKFile*>::iterator start = _pakfiles.begin();
+		file_.close();
+	
+	} else {
+		// opens the file in a PAK File
+		Common::List<PAKFile*>::iterator start = _pakfiles.begin();
 
-			for (;start != _pakfiles.end(); ++start) {
-				*size = (*start)->getFileSize(file);
+		for (;start != _pakfiles.end(); ++start) {
+			*size = (*start)->getFileSize(file);
 
-				if (!(*size))
-					continue;
+			if (!(*size))
+				continue;
 
-				buffer = new uint8[*size];
-				assert(buffer);
+			buffer = new uint8[*size];
+			assert(buffer);
 
-				// creates a copy of the file
-				memcpy(buffer, (*start)->getFile(file), *size);
+			// creates a copy of the file
+			memcpy(buffer, (*start)->getFile(file), *size);
 
-				break;
-			}
-			
+			break;
 		}
 		
-		if (!buffer || !(*size)) {
-			return 0;
-		}
+	}
 		
-		return buffer;
+	if (!buffer || !(*size)) {
+		return 0;
 	}
+		
+	return buffer;
+}
 	
-	Palette* Resourcemanager::loadPalette(const char* file)	{
-		uint32 size = 0;
-		uint8* buffer = 0;
-		buffer = fileData(file, &size);
-		if (!buffer) {
-			warning("ResMgr: Failed loading palette %s", file);
-			return 0;
-		}
-		return new Palette(buffer, size);
+Palette* Resourcemanager::loadPalette(const char* file)	{
+	uint32 size = 0;
+	uint8* buffer = 0;
+	buffer = fileData(file, &size);
+	if (!buffer) {
+		warning("ResMgr: Failed loading palette %s", file);
+		return 0;
 	}
+	return new Palette(buffer, size);
+}
 	
-	CPSImage* Resourcemanager::loadImage(const char* file) {
-		uint32 size = 0;
-		uint8* buffer = 0;
-		buffer = fileData(file, &size);
-		if (!buffer)
-			return 0;
-		return new CPSImage(buffer, size);
-	}
+CPSImage* Resourcemanager::loadImage(const char* file) {
+	uint32 size = 0;
+	uint8* buffer = 0;
+	buffer = fileData(file, &size);
+	if (!buffer)
+		return 0;
+	return new CPSImage(buffer, size);
+}
 	
-	Font* Resourcemanager::loadFont(const char* file) {
-		uint32 size = 0;
-		uint8* buffer = 0;
-		buffer = fileData(file, &size);
-		if (!buffer)
-			return 0;
-		return new Font(buffer, size);
-	}
+Font* Resourcemanager::loadFont(const char* file) {
+	uint32 size = 0;
+	uint8* buffer = 0;
+	buffer = fileData(file, &size);
+	if (!buffer)
+		return 0;
+	return new Font(buffer, size);
+}
 	
-	Movie* Resourcemanager::loadMovie(const char* file) {
-		// TODO: we have to check the Extenion to create the right movie
-		uint32 size = 0;
-		uint8* buffer = 0;
-		buffer = fileData(file, &size);
-		if (!buffer || !size)
-			return 0;
-		if (_engine->game() == KYRA1 || _engine->game() == KYRA1CD)
-			return new WSAMovieV1(buffer, size, _engine->game());
-		else
-			return new WSAMovieV2(buffer, size);
-	}
+Movie* Resourcemanager::loadMovie(const char* file) {
+	// TODO: we have to check the Extenion to create the right movie
+	uint32 size = 0;
+	uint8* buffer = 0;
+	buffer = fileData(file, &size);
+	if (!buffer || !size)
+		return 0;
+	if (_engine->game() == KYRA1 || _engine->game() == KYRA1CD)
+		return new WSAMovieV1(buffer, size, _engine->game());
+	else
+		return new WSAMovieV2(buffer, size);
+}
 
-	VMContext* Resourcemanager::loadScript(const char* file) {
-		VMContext* context = new VMContext(_engine);
-		context->loadScript(file);
-		return context;
-	}
+VMContext* Resourcemanager::loadScript(const char* file) {
+	VMContext* context = new VMContext(_engine);
+	context->loadScript(file);
+	return context;
+}
 	
 ///////////////////////////////////////////
 // Pak file manager
-	#define PAKFile_Iterate Common::List<PakChunk*>::iterator start=_files.begin();start != _files.end(); ++start
-	PAKFile::PAKFile(/*const Common::String &path, */const Common::String& file) {
-		File pakfile;
-		_buffer = 0;
-		_open = false;
-
-		if (!pakfile.open(file.c_str())){ /*, File::kFileReadMode, path.c_str())) {*/
-			printf("pakfile couldn't open %s\n", file.c_str());
-			return;
-		}
+#define PAKFile_Iterate Common::List<PakChunk*>::iterator start=_files.begin();start != _files.end(); ++start
+PAKFile::PAKFile(/*const Common::String &path, */const Common::String& file) {
+	File pakfile;
+	_buffer = 0;
+	_open = false;
+		
+	if (!pakfile.open(file.c_str())){ /*, File::kFileReadMode, path.c_str())) {*/
+		printf("pakfile couldn't open %s\n", file.c_str());
+		return;
+	}
 
-		uint32 filesize = pakfile.size();
-		_buffer = new uint8[filesize];
-		assert(_buffer);
+	uint32 filesize = pakfile.size();
+	_buffer = new uint8[filesize];
+	assert(_buffer);
 
-		pakfile.read(_buffer, filesize);
-		pakfile.close();
+	pakfile.read(_buffer, filesize);
+	pakfile.close();
 
-		// works with the file
-		uint32 pos = 0, startoffset = 0, endoffset = 0;
+	// works with the file
+	uint32 pos = 0, startoffset = 0, endoffset = 0;
 
-		startoffset = READ_LE_UINT32(_buffer + pos);
-		pos += 4;
+	startoffset = READ_LE_UINT32(_buffer + pos);
+	pos += 4;
 
-		while (pos < filesize) {
-			PakChunk* chunk = new PakChunk;
-			assert(chunk);
+	while (pos < filesize) {
+		PakChunk* chunk = new PakChunk;
+		assert(chunk);
 
-			// saves the name
-			chunk->_name = reinterpret_cast<const char*>(_buffer + pos);
-			pos += strlen(chunk->_name) + 1;
-			if(!(*chunk->_name))
-				break;
+		// saves the name
+		chunk->_name = reinterpret_cast<const char*>(_buffer + pos);
+		pos += strlen(chunk->_name) + 1;
+		if(!(*chunk->_name))
+			break;
 
-			endoffset = READ_LE_UINT32(_buffer + pos);
-			pos += 4;
-			
-			if (endoffset == 0) {
-				endoffset = filesize;
-			}
+		endoffset = READ_LE_UINT32(_buffer + pos);
+		pos += 4;
+		
+		if (endoffset == 0) {
+			endoffset = filesize;
+		}
 
-			chunk->_data = _buffer + startoffset;
-			chunk->_size = endoffset - startoffset;
+		chunk->_data = _buffer + startoffset;
+		chunk->_size = endoffset - startoffset;
 
-			_files.push_back(chunk);
-			
-			if (endoffset == filesize)
-				break;
+		_files.push_back(chunk);
+		
+		if (endoffset == filesize)
+			break;
 
-			startoffset = endoffset;
-		}
-		_open = true;
+		startoffset = endoffset;
 	}
+	_open = true;
+}
 
-	PAKFile::~PAKFile() {
-		delete [] _buffer;
-		_buffer = 0;
-		_open = false;
+PAKFile::~PAKFile() {
+	delete [] _buffer;
+	_buffer = 0;
+	_open = false;
 
-		for (PAKFile_Iterate) {
-			delete *start;
-			*start = 0;
-		}
+	for (PAKFile_Iterate) {
+		delete *start;
+		*start = 0;
 	}
+}
 
-	const uint8* PAKFile::getFile(const char* file) {
-		for (PAKFile_Iterate) {
-			if (!scumm_stricmp((*start)->_name, file))
-				return (*start)->_data;
-		}
-
-		return 0;
+const uint8* PAKFile::getFile(const char* file) {
+	for (PAKFile_Iterate) {
+		if (!scumm_stricmp((*start)->_name, file))
+			return (*start)->_data;
 	}
 
-	uint32 PAKFile::getFileSize(const char* file) {
-		for (PAKFile_Iterate) {
-			if (!scumm_stricmp((*start)->_name, file))
-				return (*start)->_size;
-		}
+	return 0;
+}
 
-		return 0;
+uint32 PAKFile::getFileSize(const char* file) {
+	for (PAKFile_Iterate) {
+		if (!scumm_stricmp((*start)->_name, file))
+			return (*start)->_size;
 	}
+	
+	return 0;
+}
 } // end of namespace Kyra
 

Index: resource.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/resource.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- resource.h	11 Nov 2004 13:35:21 -0000	1.4
+++ resource.h	14 Nov 2004 20:11:22 -0000	1.5
@@ -32,167 +32,165 @@
 
 namespace Kyra {
 
-	// standard Package format for Kyrandia games
-	class PAKFile {
-		struct PakChunk {
-			const char* _name;
-			const uint8* _data;
-			uint32 _size;
-		};
-
-	public:
-
-		PAKFile(const Common::String& file);
-		~PAKFile();
+// standard Package format for Kyrandia games
+class PAKFile {
+	struct PakChunk {
+		const char* _name;
+		const uint8* _data;
+		uint32 _size;
+	};
 
-		const uint8* getFile(const char* file);
-		uint32 getFileSize(const char* file);
+public:
 
-		bool isValid(void) {return (_buffer != 0);}
-		bool isOpen(void) {return _open;}
-	private:
-		bool _open;
-		uint8* _buffer; // the whole file
-		Common::List<PakChunk*> _files; // the entries
+	PAKFile(const Common::String& file);
+	~PAKFile();
 
-	};
+	const uint8* getFile(const char* file);
+	uint32 getFileSize(const char* file);
 
-	// some resource types
-	class Palette;
-	class CPSImage;
-	class Font;
-	class Movie;
-	class VMContext;
+	bool isValid(void) {return (_buffer != 0);}
+	bool isOpen(void) {return _open;}
+private:
+	bool _open;
+	uint8* _buffer; // the whole file
+	Common::List<PakChunk*> _files; // the entries
+};
 
-	// out resource manager
-	class Resourcemanager {
-		typedef Common::String string;
+// some resource types
+class Palette;
+class CPSImage;
+class Font;
+class Movie;
+class VMContext;
 
-	public:
+// out resource manager
+class Resourcemanager {
+	typedef Common::String string;
 
-		Resourcemanager(KyraEngine* engine);
-		virtual ~Resourcemanager();
+public:
 
-		uint8* fileData(const char* file, uint32* size);
+	Resourcemanager(KyraEngine* engine);
+	virtual ~Resourcemanager();
 
-		Palette* loadPalette(const char* file);
-		CPSImage* loadImage(const char* file);
-		Font* loadFont(const char* file);
-		Movie* loadMovie(const char* file);
-		VMContext* loadScript(const char* file);
+	uint8* fileData(const char* file, uint32* size);
 
-	protected:
-		KyraEngine* _engine;
+	Palette* loadPalette(const char* file);
+	CPSImage* loadImage(const char* file);
+	Font* loadFont(const char* file);
+	Movie* loadMovie(const char* file);
+	VMContext* loadScript(const char* file);
 
-		Common::List<PAKFile*> _pakfiles;
+protected:
+	KyraEngine* _engine;
 
-	};
+	Common::List<PAKFile*> _pakfiles;
 
-	class Palette {
+};
 
-	public:
+class Palette {
 
-		Palette(uint8* data, uint32 size);
-		~Palette() { delete [] _palette; }
+public:
+		
+	Palette(uint8* data, uint32 size);
+	~Palette() { delete [] _palette; }
 
-		uint8* getData(void) { return _palette; }
+	uint8* getData(void) { return _palette; }
 
-	protected:
+protected:
 
-		uint8* _palette;
+	uint8* _palette;
 
-	};
+};
 
-	class CPSImage {
+class CPSImage {
 
-	public:
+public:
 
-		CPSImage(uint8* buffer, uint32 size);
-		~CPSImage();
+	CPSImage(uint8* buffer, uint32 size);
+	~CPSImage();
 
-		Palette* palette(void) { return _ownPalette; }
-		bool hasPalette(void) { return (_ownPalette != 0); }
+	Palette* palette(void) { return _ownPalette; }
+	bool hasPalette(void) { return (_ownPalette != 0); }
 
-		// if col == -1 then no transparany
-		void transparency(int16 col) { _transparency = col; }
+	// if col == -1 then no transparany
+	void transparency(int16 col) { _transparency = col; }
 
-		void drawToPlane(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 x, uint16 y);
-		void drawToPlane(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 x, uint16 y,
-						uint16 srcx, uint16 srcy, uint16 srcwidth, uint16 srcheight);
+	void drawToPlane(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 x, uint16 y);
+	void drawToPlane(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 x, uint16 y,
+			uint16 srcx, uint16 srcy, uint16 srcwidth, uint16 srcheight);
 
-		// only for testing :)
-		uint8 getColor(uint16 x, uint16 y) { return _image[y * _width + x]; }
+	// only for testing :)
+	uint8 getColor(uint16 x, uint16 y) { return _image[y * _width + x]; }
 		
-		uint8& operator[](uint16 index) { if(index > _width * _height) return _image[0]; return _image[index]; }
-
-	protected:
+	uint8& operator[](uint16 index) { if(index > _width * _height) return _image[0]; return _image[index]; }
 
-		struct CPSHeader {
-			uint16 _filesize;
-			uint16 _format;
-			uint16 _imagesize;
-			uint32 _pal;
-		} _cpsHeader;
+protected:
 
-		Palette* _ownPalette;
-		uint8* _image;
+	struct CPSHeader {
+		uint16 _filesize;
+		uint16 _format;
+		uint16 _imagesize;
+		uint32 _pal;
+	} _cpsHeader;
 
-		uint16 _width, _height;
-		int16 _transparency;
-	};
+	Palette* _ownPalette;
+	uint8* _image;
 
-	class Font {
+	uint16 _width, _height;
+	int16 _transparency;
+};
 
-	public:
+class Font {
 
-		Font(uint8* buffer, uint32 size);
-		~Font();
+public:
 
-		uint32 getStringWidth(const char* string, char terminator = '\0');
-		void drawStringToPlane(const char* string,
-								uint8* plane, uint16 planewidth, uint16 planeheight,
-								uint16 x, uint16 y, uint8 color);
+	Font(uint8* buffer, uint32 size);
+	~Font();
 
-	protected:
+	uint32 getStringWidth(const char* string, char terminator = '\0');
+	void drawStringToPlane(const char* string,
+				uint8* plane, uint16 planewidth, uint16 planeheight,
+				uint16 x, uint16 y, uint8 color);
 
-		void drawCharToPlane(const uint8* c, uint8 color, uint8 width, uint8 height,
-							uint8* plane, uint16 planewidth, uint16 planeheight, uint16 x, uint16 y);
-		const uint8* getChar(char c, uint8* width, uint8* height, uint8* heightadd);
-		const char* getNextWord(const char* string, uint32* size);
+protected:
 
-		void preRenderAllChars(uint16 offsetTableOffset);
+	void drawCharToPlane(const uint8* c, uint8 color, uint8 width, uint8 height,
+				uint8* plane, uint16 planewidth, uint16 planeheight, uint16 x, uint16 y);
+	const uint8* getChar(char c, uint8* width, uint8* height, uint8* heightadd);
+	const char* getNextWord(const char* string, uint32* size);
 
-		uint8* _buffer;
+	void preRenderAllChars(uint16 offsetTableOffset);
 
-		uint16* _offsetTable;
-		uint8* _charWidth;
-		uint16* _charHeight;
-		uint8* _charBits;
+	uint8* _buffer;
+	uint16* _offsetTable;
+	uint8* _charWidth;
+	uint16* _charHeight;
+	uint8* _charBits;
 
-		// the chars I call 'prerendered' aren't really prerendered
-		// they are only 'decoded'
-		struct PreRenderedChar {
-			uint8* c;
-			uint8 width, height, heightadd;
-		};
+	// the chars I call 'prerendered' aren't really prerendered
+	// they are only 'decoded'
+	struct PreRenderedChar {
+		uint8* c;
+		uint8 width, height, heightadd;
+	};
 
-		Common::Map<uint8, PreRenderedChar> _preRenderedChars; // our prerendered chars :)
+	Common::Map<uint8, PreRenderedChar> _preRenderedChars; // our prerendered chars :)
 
-		// INFO:
-		// _magic1 = 0x0500
-		// _magic2 = 0x000e
-		// _magic3 = 0x0014
+	// INFO:
+	// _magic1 = 0x0500
+	// _magic2 = 0x000e
+	// _magic3 = 0x0014
 #pragma START_PACK_STRUCTS
-		struct FontHeader {
-			uint16 _size;
-			uint16 _magic1, _magic2, _magic3;
-			uint16 _charWidthOffset, _charBitsOffset, _charHeightOffset;
-			uint16 _version;
-			uint16 _countChars;
-			uint8 _width, _height;
-		} GCC_PACK _fontHeader;
+	struct FontHeader {
+		uint16 _size;
+		uint16 _magic1, _magic2, _magic3;
+		uint16 _charWidthOffset, _charBitsOffset, _charHeightOffset;
+		uint16 _version;
+		uint16 _countChars;
+		uint8 _width, _height;
+	} GCC_PACK _fontHeader;
 #pragma END_PACK_STRUCTS
-	};
+};
 } // end of namespace Kyra
 
 #endif

Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/script.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- script.cpp	11 Nov 2004 13:35:21 -0000	1.7
+++ script.cpp	14 Nov 2004 20:11:22 -0000	1.8
@@ -31,534 +31,533 @@
 #define OPCODE(x) { &VMContext::x, #x }
 
 namespace Kyra {
-	VMContext::VMContext(KyraEngine* engine) {
-		_engine = engine;
-		_error = false;
+VMContext::VMContext(KyraEngine* engine) {
+	_engine = engine;
+	_error = false;
 		
-		// now we create a list of all Command/Opcode procs and so
[...1004 lines suppressed...]
+			(this->*currentProc)();
+		} else {
+			c1_unknownCommand();
+		}
+		
+		if (_error) {
+			_scriptState = kScriptError;
+			break;
+		}
+			
+		if (scriptStateAtStart != _scriptState) {
+			break;
 		}
-	
-		return _scriptState;
 	}
+
+	return _scriptState;
+}
 } // end of namespace Kyra

Index: script.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/script.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- script.h	11 Nov 2004 13:35:21 -0000	1.3
+++ script.h	14 Nov 2004 20:11:22 -0000	1.4
@@ -23,135 +23,136 @@
 #define VM_H
 
 namespace Kyra {
-	// TODO:
-	// find out more script functions
-	enum ScriptFunc {
-		kSetupScene = 0,
-		kClickEvent = 1, // _registers[1] and _registers[2] are mouse x, y _registers[4] is action
-		kActorEvent = 2,
-		kEnterEvent = 4,
-		kExitEvent = 5,
-		kLoadResources = 7
-	};
+// TODO:
+// find out more script functions
+enum ScriptFunc {
+	kSetupScene = 0,
+	kClickEvent = 1, // _registers[1] and _registers[2] are mouse x, y _registers[4] is action
+	kActorEvent = 2,
+	kEnterEvent = 4,
+	kExitEvent = 5,
+	kLoadResources = 7
+};
+
+enum ScriptState {
+	kScriptStopped = 0,
+	kScriptRunning = 1,
+	kScriptWaiting = 2,
+	kScriptError = 3
+};
 	
-	enum ScriptState {
-		kScriptStopped = 0,
-		kScriptRunning = 1,
-		kScriptWaiting = 2,
-		kScriptError = 3
-	};
+	
+class VMContext {
 
-	class VMContext {
+public:
+
+	VMContext(KyraEngine* engine);
+	~VMContext() { delete [] _scriptFile; }
 	
-	public:
+	void loadScript(const char* file);
 	
-		VMContext(KyraEngine* engine);
-		~VMContext() { delete [] _scriptFile; }
-		
-		void loadScript(const char* file);
-		
-		const char* stringAtIndex(int32 index);
-		
-		// TODO: check for 'over'flow
-		void pushStack(int32 value) { _stack[_stackPos++] = value; }		
-		void registerValue(int32 reg, int32 value) { _registers[reg] = value; }
-		int32 checkReg(int32 reg) { return _registers[reg]; }
-		
-		uint32 state(void) { return _scriptState; }
-		
-		bool startScript(int32 func);
-		uint32 contScript(void);
+	const char* stringAtIndex(int32 index);
 	
-	protected:
-		KyraEngine* _engine;
-		uint8* _scriptFile;
-		uint32 _scriptFileSize;
-		
-		uint32 _scriptState;
-		uint32 _delay;
-		
-		int32 _registers[32]; // registers of the interpreter
-		int32 _stack[64]; // our stack
-		
-		// TODO: check for 'under'flow
-		int32 popStack(void) { return _stack[--_stackPos]; }
-		int32& topStack(void) { return _stack[_stackPos]; }
-		
-		uint32 _returnValue;
-		
-		int32 _nextScriptPos;
-		int32 _instructionPos;
-		int32 _stackPos;
-		int32 _tempPos;
-		
-		// used by command & opcode procs
-		uint16 _argument;
-		uint8 _currentCommand;
-		uint32 _currentOpcode;
-		
-		int32 param(int32 index);
-		const char* paramString(int32 index) { return stringAtIndex(param(index)); }
-		
-		bool _error;	// used by all command- and opcodefuncs
-		
-		enum ScriptChunkTypes {
-			kForm = 0,
-			kEmc2Ordr = 1,
-			kText = 2,
-			kData = 3,
-			kCountChunkTypes
-		};
-		
-		struct ScriptChunk {
-			uint32 _size;
-			uint8* _data; // by TEXT used for count of texts, by EMC2ODRD it is used for a count of somewhat
-			uint8* _additional; // currently only used for TEXT
-		};
-		
-		ScriptChunk _chunks[kCountChunkTypes];
+	// TODO: check for 'over'flow
+	void pushStack(int32 value) { _stack[_stackPos++] = value; }		
+	void registerValue(int32 reg, int32 value) { _registers[reg] = value; }
+	int32 checkReg(int32 reg) { return _registers[reg]; }
+	
+	uint32 state(void) { return _scriptState; }
+	
+	bool startScript(int32 func);
+	uint32 contScript(void);
 
-		typedef void (VMContext::*CommandProc)();
-		struct CommandEntry {
-			CommandProc proc;
-			const char* desc;
-		};
+protected:
+	KyraEngine* _engine;
+	uint8* _scriptFile;
+	uint32 _scriptFileSize;
+	
+	uint32 _scriptState;
+	uint32 _delay;
+	
+	int32 _registers[32]; // registers of the interpreter
+	int32 _stack[64]; // our stack
+	
+	// TODO: check for 'under'flow
+	int32 popStack(void) { return _stack[--_stackPos]; }
+	int32& topStack(void) { return _stack[_stackPos]; }
+	
+	uint32 _returnValue;
 		
-		typedef void (VMContext::*OpcodeProc)();
-		struct OpcodeEntry {
-			OpcodeProc proc;
-			const char* desc;
-		};
+	int32 _nextScriptPos;
+	int32 _instructionPos;
+	int32 _stackPos;
+	int32 _tempPos;
+	
+	// used by command & opcode procs
+	uint16 _argument;
+	uint8 _currentCommand;
+	uint32 _currentOpcode;
+	
+	int32 param(int32 index);
+	const char* paramString(int32 index) { return stringAtIndex(param(index)); }
+	
+	bool _error;	// used by all command- and opcodefuncs
+	
+	enum ScriptChunkTypes {
+		kForm = 0,
+		kEmc2Ordr = 1,
+		kText = 2,
+		kData = 3,
+		kCountChunkTypes
+	};
+	
+	struct ScriptChunk {
+		uint32 _size;
+		uint8* _data; // by TEXT used for count of texts, by EMC2ODRD it is used for a count of somewhat
+		uint8* _additional; // currently only used for TEXT
+	};
+	
+	ScriptChunk _chunks[kCountChunkTypes];
+
+	typedef void (VMContext::*CommandProc)();
+	struct CommandEntry {
+		CommandProc proc;
+		const char* desc;
+	};
 		
-		uint16 _numCommands;
-		const CommandEntry* _commands;
-		uint16 _numOpcodes;
-		const OpcodeEntry* _opcodes;
-  
-	protected:
- 		// the command procs
- 		void c1_goToLine(void);			// 0x00
- 		void c1_setReturn(void);		// 0x01
- 		void c1_pushRetRec(void);		// 0x02
- 		void c1_push(void);			// 0x03 & 0x04
- 		void c1_pushVar(void);			// 0x05
- 		void c1_pushFrameNeg(void);		// 0x06
- 		void c1_pushFramePos(void);		// 0x07
- 		void c1_popRetRec(void);		// 0x08
- 		void c1_popVar(void);			// 0x09
- 		void c1_popFrameNeg(void);		// 0x0A
- 		void c1_popFramePos(void);		// 0x0B
- 		void c1_addToSP(void);			// 0x0C
- 		void c1_subFromSP(void);		// 0x0D
-   		void c1_execOpcode(void);		// 0x0E
-   		void c1_ifNotGoTo(void);		// 0x0F
-   		void c1_negate(void);			// 0x10
-   		void c1_evaluate(void);			// 0x11
-		void c1_unknownCommand(void);
-  
-		// the opcode procs
-		void o1_0x68(void);			// 0x68
-		void o1_unknownOpcode(void);
+	typedef void (VMContext::*OpcodeProc)();
+	struct OpcodeEntry {
+		OpcodeProc proc;
+		const char* desc;
 	};
+	
+	uint16 _numCommands;
+	const CommandEntry* _commands;
+	uint16 _numOpcodes;
+	const OpcodeEntry* _opcodes;
+ 
+protected:
+	// the command procs
+	void c1_goToLine(void);			// 0x00
+	void c1_setReturn(void);		// 0x01
+	void c1_pushRetRec(void);		// 0x02
+	void c1_push(void);			// 0x03 & 0x04
+	void c1_pushVar(void);			// 0x05
+	void c1_pushFrameNeg(void);		// 0x06
+	void c1_pushFramePos(void);		// 0x07
+	void c1_popRetRec(void);		// 0x08
+	void c1_popVar(void);			// 0x09
+	void c1_popFrameNeg(void);		// 0x0A
+	void c1_popFramePos(void);		// 0x0B
+	void c1_addToSP(void);			// 0x0C
+	void c1_subFromSP(void);		// 0x0D
+	void c1_execOpcode(void);		// 0x0E
+	void c1_ifNotGoTo(void);		// 0x0F
+	void c1_negate(void);			// 0x10
+	void c1_evaluate(void);			// 0x11
+	void c1_unknownCommand(void);
+  
+	// the opcode procs
+	void o1_0x68(void);			// 0x68
+	void o1_unknownOpcode(void);
+};
 } // end of namespace Kyra
 
 #endif

Index: script_v1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/script_v1.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- script_v1.cpp	11 Nov 2004 13:35:21 -0000	1.5
+++ script_v1.cpp	14 Nov 2004 20:11:22 -0000	1.6
@@ -25,219 +25,219 @@
 #include "script.h"
 
 namespace Kyra {
-	// Command procs
+// Command procs
+
+void VMContext::c1_unknownCommand(void) {
+	debug("unknown command '0x%x'.", _currentCommand);
+	debug("\targument: '0x%x'", _argument);
 	
-	void VMContext::c1_unknownCommand(void) {
-		debug("unknown command '0x%x'.", _currentCommand);
-		debug("\targument: '0x%x'", _argument);
+	_error = true;
+}
+
+void VMContext::c1_goToLine(void) {
+	_instructionPos = _argument << 1;
+}
+
+void VMContext::c1_setReturn(void) {
+	_returnValue = _argument;
+}
+
+void VMContext::c1_pushRetRec(void) {
+	if (!_argument) {
+		pushStack(_returnValue);
+	} else {
+		int32 rec = ((int16)_tempPos << 16) | ((_instructionPos >> 1) + 1);
+		pushStack(rec);
+		_tempPos = _instructionPos;
+	}
+}
+
+void VMContext::c1_push(void) {
+	pushStack(_argument);
+}
+
+void VMContext::c1_pushVar(void) {
+	pushStack(_registers[_argument]);
+}
+
+void VMContext::c1_pushFrameNeg(void) {
+	pushStack(_stack[_tempPos + _argument]);
+}
+
+void VMContext::c1_pushFramePos(void) {
+	pushStack(_stack[_tempPos - _argument]);
+}
+
+void VMContext::c1_popRetRec(void) {
+	if (!_argument) {
+		_returnValue = popStack();
+	} else {
+		if (_stackPos <= 0) {
+			_scriptState = kScriptStopped;
+		}
+		int32 rec = popStack();
 		
-		_error = true;
+		_tempPos = (int16)((rec & 0xFFFF0000) >> 16);
+		_instructionPos = (rec & 0x0000FFFF) * 2;
 	}
-	
-	void VMContext::c1_goToLine(void) {
+}
+
+void VMContext::c1_popVar(void) {
+	_registers[_argument] = popStack();
+}
+
+void VMContext::c1_popFrameNeg(void) {
+	_stack[_tempPos + _argument] = popStack();
+}
+
+void VMContext::c1_popFramePos(void) {
+	_stack[_tempPos - _argument] = popStack();
+}
+
+void VMContext::c1_addToSP(void) {
+	_stackPos -= _argument;
+}
+
+void VMContext::c1_subFromSP(void) {
+	_stackPos += _argument;
+}
+
+void VMContext::c1_execOpcode(void) {
+	if (_argument < _numOpcodes) {
+		OpcodeProc proc = _opcodes[_argument].proc;
+		(this->*proc)();
+	} else {
+		error("Invalid opcode 0x%X", _argument);
+	}
+}
+
+void VMContext::c1_ifNotGoTo(void) {
+	if (!popStack()) {
 		_instructionPos = _argument << 1;
 	}
+}
+
+void VMContext::c1_negate(void) {
+	switch(_argument) {
+	case 0:
+		topStack() = !topStack();
+		break;
 	
-	void VMContext::c1_setReturn(void) {
-		_returnValue = _argument;
-	}
+	case 1:
+		topStack() = -topStack();
+		break;
 	
-	void VMContext::c1_pushRetRec(void) {
-		if (!_argument) {
-			pushStack(_returnValue);
-		} else {
-			int32 rec = ((int16)_tempPos << 16) | ((_instructionPos >> 1) + 1);
-			pushStack(rec);
-			_tempPos = _instructionPos;
-		}
-	}
+	case 2:
+		topStack() = ~topStack();
+		break;
 	
-	void VMContext::c1_push(void) {
-		pushStack(_argument);
-	}
+	default:
+		debug("unkown negate instruction %d", _argument);
+		_error = true;
+		break;
+	};
+}
+
+void VMContext::c1_evaluate(void) {
+	int32 x, y;
+	int32 res = false;
 	
-	void VMContext::c1_pushVar(void) {
-		pushStack(_registers[_argument]);
-	}
+	x = popStack();
+	y = popStack();
 	
-	void VMContext::c1_pushFrameNeg(void) {
-		pushStack(_stack[_tempPos + _argument]);
-	}
+	switch(_argument) {
+	case 0:
+		res = x && y;
+		break;
 	
-	void VMContext::c1_pushFramePos(void) {
-		pushStack(_stack[_tempPos - _argument]);
-	}
+	case 1:
+		res = x || y;
+		break;
 	
-	void VMContext::c1_popRetRec(void) {
-		if (!_argument) {
-			_returnValue = popStack();
-		} else {
-			if (_stackPos <= 0) {
-				_scriptState = kScriptStopped;
-			}
-			int32 rec = popStack();
-			
-			_tempPos = (int16)((rec & 0xFFFF0000) >> 16);
-			_instructionPos = (rec & 0x0000FFFF) * 2;
-		}
-	}
+	case 3:
+		res = x != y;
+		break;
 	
-	void VMContext::c1_popVar(void) {
-		_registers[_argument] = popStack();
-	}
+	case 4:
+		res = x < y;
+		break;
 	
-	void VMContext::c1_popFrameNeg(void) {
-		_stack[_tempPos + _argument] = popStack();
-	}
+	case 5:
+		res = x <= y;
+		break;
+		
+	case 6:
+		res = x > y;
+		break;
 	
-	void VMContext::c1_popFramePos(void) {
-		_stack[_tempPos - _argument] = popStack();
-	}
+	case 7:
+		res = x >= y;
+		break;
 	
-	void VMContext::c1_addToSP(void) {
-		_stackPos -= _argument;
-	}
+	case 8:
+		res = x + y;
+		break;
+		
+	case 9:
+		res = x - y;
+		break;
 	
-	void VMContext::c1_subFromSP(void) {
-		_stackPos += _argument;
-	}
+	case 10:
+		res = x * y;
+		break;
+		
+	case 11:
+		res = x / y;
+		break;
 	
-	void VMContext::c1_execOpcode(void) {
-		if (_argument < _numOpcodes) {
-			OpcodeProc proc = _opcodes[_argument].proc;
-			(this->*proc)();
-		} else {
-			error("Invalid opcode 0x%X", _argument);
-		}
-	}
+	case 12:
+		res = x >> y;
+		break;
 	
-	void VMContext::c1_ifNotGoTo(void) {
-		if (!popStack()) {
-			_instructionPos = _argument << 1;
-		}
-	}
+	case 13:
+		res = x << y;
+		break;
 	
-	void VMContext::c1_negate(void) {
-		switch(_argument) {
-		case 0:
-			topStack() = !topStack();
-			break;
-		
-		case 1:
-			topStack() = -topStack();
-			break;
-		
-		case 2:
-			topStack() = ~topStack();
-			break;
-		
-		default:
-			debug("unkown negate instruction %d", _argument);
-			_error = true;
-			break;
-		};
-	}
+	case 14:
+		res = x & y;
+		break;
 	
-	void VMContext::c1_evaluate(void) {
-		int32 x, y;
-		int32 res = false;
-		
-		x = popStack();
-		y = popStack();
-		
-		switch(_argument) {
-		case 0:
-			res = x && y;
-			break;
-		
-		case 1:
-			res = x || y;
-			break;
-		
-		case 3:
-			res = x != y;
-			break;
-		
-		case 4:
-			res = x < y;
-			break;
-		
-		case 5:
-			res = x <= y;
-			break;
-			
-		case 6:
-			res = x > y;
-			break;
-		
-		case 7:
-			res = x >= y;
-			break;
-		
-		case 8:
-			res = x + y;
-			break;
-			
-		case 9:
-			res = x - y;
-			break;
-		
-		case 10:
-			res = x * y;
-			break;
-		
-		case 11:
-			res = x / y;
-			break;
-		
-		case 12:
-			res = x >> y;
-			break;
-		
-		case 13:
-			res = x << y;
-			break;
-		
-		case 14:
-			res = x & y;
-			break;
-		
-		case 15:
-			res = x | y;
-			break;
-		
-		case 16:
-			res = x % y;
-			break;
-		
-		case 17:
-			res = x ^ y;
-			break;
-		
-		default:
-			debug("unknown evaluate command");
-			break;
-		};
-		
-		pushStack(res);
-	}
-
-	// opcode procs
-	void VMContext::o1_unknownOpcode(void) {
-		_error = true;
+	case 15:
+		res = x | y;
+		break;
+	
+	case 16:
+		res = x % y;
+		break;
+	
+	case 17:
+		res = x ^ y;
+		break;
+	
+	default:
+		debug("unknown evaluate command");
+		break;
+	};
+	
+	pushStack(res);
+}
 
-		debug("unknown opcode '0x%x'.", _argument);
-		debug("parameters:\n"
-			"Param0: %d\nParam1: %d\nParam2: %d\nParam3: %d\nParam4: %d\nParam5: %d\n"
-			"Param0 as a string: %s\nParam1 as a string: %s\nParam2 as a string: %s\n"
-			"Param3 as a string: %s\nParam4 as a string: %s\nParam5 as a string: %s\n",
-			param(0), param(1), param(2), param(3), param(5), param(5),
-			paramString(0), paramString(1), paramString(2), paramString(3), 
-			paramString(4), paramString(5));
-	}
+// opcode procs
+void VMContext::o1_unknownOpcode(void) {
+	_error = true;
+		
+	debug("unknown opcode '0x%x'.", _argument);
+	debug("parameters:\n"
+		"Param0: %d\nParam1: %d\nParam2: %d\nParam3: %d\nParam4: %d\nParam5: %d\n"
+		"Param0 as a string: %s\nParam1 as a string: %s\nParam2 as a string: %s\n"
+		"Param3 as a string: %s\nParam4 as a string: %s\nParam5 as a string: %s\n",
+		param(0), param(1), param(2), param(3), param(5), param(5),
+		paramString(0), paramString(1), paramString(2), paramString(3), 
+		paramString(4), paramString(5));
+}
 
-	void VMContext::o1_0x68(void) {
-		debug("o1_0x68 was called with param0: '%d'", param(0));
-		_error = true;
-	}
+void VMContext::o1_0x68(void) {
+	debug("o1_0x68 was called with param0: '0x%x'", param(0));
+	_error = true;
+}
 } // end of namespace Kyra

Index: wsamovie.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/wsamovie.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- wsamovie.cpp	11 Nov 2004 13:35:21 -0000	1.3
+++ wsamovie.cpp	14 Nov 2004 20:11:22 -0000	1.4
@@ -30,403 +30,405 @@
 #endif
 
 namespace Kyra {
-	WSAMovieV1::WSAMovieV1(uint8* data, uint32 size, uint8 gameid) {
-		if (!data) {
-			error("resource created without data");
-		}
-
-		_background = 0;
-		_currentFrame = 0;
-		_ownPalette = 0;
-		_offsetTable = 0;
-		_prefetchedFrame = 0xFFFE;
-		_buffer = data;
+WSAMovieV1::WSAMovieV1(uint8* data, uint32 size, uint8 gameid) {
+	if (!data) {
+		error("resource created without data");
+	}
 
-		// I like these Streams .... =)
-		Common::MemoryReadStream datastream(data, size);
+	_background = 0;
+	_currentFrame = 0;
+	_ownPalette = 0;
+	_offsetTable = 0;
+	_prefetchedFrame = 0xFFFE;
+	_buffer = data;
 		
-		datastream.read(&_wsaHeader, sizeof(_wsaHeader));
+	// I like these Streams .... =)
+	Common::MemoryReadStream datastream(data, size);
+		
+	datastream.read(&_wsaHeader, sizeof(_wsaHeader));
 
 #ifdef DUMP_FILES
-		FILE* wsaheader = fopen("dumps/wsaheader.txt", "w+");
+	// TODO: make Linux/BSD conform
+	FILE* wsaheader = fopen("dumps/wsaheader.txt", "w+");
 		
-		if (wsaheader) {
-			for (uint32 pos = 0; pos < sizeof(_wsaHeader); ++pos)
-				fprintf(wsaheader, "%d pos. byte: %d\n", pos + 1, ((uint8*)&_wsaHeader)[pos]);
-			fprintf(wsaheader, "\n");
-			for (uint32 pos = 0; pos < sizeof(_wsaHeader) / 2; ++pos)
-				fprintf(wsaheader, "%d pos. word: %d\n", pos + 1, ((uint16*)&_wsaHeader)[pos]);
-			fprintf(wsaheader, "\n");
-			for (uint32 pos = 0; pos < sizeof(_wsaHeader) / 4; ++pos)
-				fprintf(wsaheader, "%d pos. dword: %d\n", pos + 1, ((uint32*)&_wsaHeader)[pos]);
-		}
-		fclose(wsaheader);
+	if (wsaheader) {
+		for (uint32 pos = 0; pos < sizeof(_wsaHeader); ++pos)
+			fprintf(wsaheader, "%d pos. byte: %d\n", pos + 1, ((uint8*)&_wsaHeader)[pos]);
+		fprintf(wsaheader, "\n");
+		for (uint32 pos = 0; pos < sizeof(_wsaHeader) / 2; ++pos)
+			fprintf(wsaheader, "%d pos. word: %d\n", pos + 1, ((uint16*)&_wsaHeader)[pos]);
+		fprintf(wsaheader, "\n");
+		for (uint32 pos = 0; pos < sizeof(_wsaHeader) / 4; ++pos)
+			fprintf(wsaheader, "%d pos. dword: %d\n", pos + 1, ((uint32*)&_wsaHeader)[pos]);
+	}
+	fclose(wsaheader);
 #endif
 
-		if (gameid == KYRA1CD) {
-			uint16 tmp = _wsaHeader._delta;
-			_wsaHeader._delta = _wsaHeader._type;
-			_wsaHeader._type = tmp;
-			
-			// skip 2 bytes
-			datastream.readUint16LE();
-		}
-		
-		debug("_wsaHeader._numFrames = %d", _wsaHeader._numFrames);
-		debug("_wsaHeader._width = %d", _wsaHeader._width);
-		debug("_wsaHeader._height = %d", _wsaHeader._height);
-		debug("_wsaHeader._xPos = %d", _wsaHeader._xPos);
-		debug("_wsaHeader._yPos = %d", _wsaHeader._yPos);
-		debug("_wsaHeader._delta = %d", _wsaHeader._delta);
-		debug("_wsaHeader._type = %d", _wsaHeader._type);
+	if (gameid == KYRA1CD) {
+		uint16 tmp = _wsaHeader._delta;
+		_wsaHeader._delta = _wsaHeader._type;
+		_wsaHeader._type = tmp;
 		
-		// check for version
-		if (_wsaHeader._type) {
-			error("loading a WSA version 2 with the WSA version 1 loader");
-		}
+		// skip 2 bytes
+		datastream.readUint16LE();
+	}
 		
-		uint16 offsetAdd = 0;
+	debug("_wsaHeader._numFrames = %d", _wsaHeader._numFrames);
+	debug("_wsaHeader._width = %d", _wsaHeader._width);
+	debug("_wsaHeader._height = %d", _wsaHeader._height);
+	debug("_wsaHeader._xPos = %d", _wsaHeader._xPos);
+	debug("_wsaHeader._yPos = %d", _wsaHeader._yPos);
+	debug("_wsaHeader._delta = %d", _wsaHeader._delta);
+	debug("_wsaHeader._type = %d", _wsaHeader._type);
 		
-		// checks now for own palette
-		if (_wsaHeader._type % 2) {
-			// don't now if this will work right, because a few lines before we use
-			// _wsaHeader._type for detect the version of the WSA movie,
-			// but this code was from FreeKyra Tools so I think it will work
-			
-			// if this is a packed palette we have a problem :)
-			offsetAdd = 768 /* 0x300 */;
-		}
+	// check for version
+	if (_wsaHeader._type) {
+		error("loading a WSA version 2 with the WSA version 1 loader");
+	}
 		
-		// last frame seems every time to be a empty one
-		_frameCount = _wsaHeader._numFrames - 1;
-		_offsetTable = new uint32[_wsaHeader._numFrames + 2];
-		assert(_offsetTable);
+	uint16 offsetAdd = 0;
 		
-		// loads the offset table
-		for (uint32 tmp = 0; tmp < (uint32)_wsaHeader._numFrames + 2; ++tmp) {
-			_offsetTable[tmp] = datastream.readUint32LE() + offsetAdd;
-		}
+	// checks now for own palette
+	if (_wsaHeader._type % 2) {
+		// don't now if this will work right, because a few lines before we use
+		// _wsaHeader._type for detect the version of the WSA movie,
+		// but this code was from FreeKyra Tools so I think it will work
 		
-		if (offsetAdd) {
-			uint8* palbuffer = new uint8[offsetAdd];
-			assert(palbuffer);
-			
-			datastream.read(palbuffer, offsetAdd);
-			
-			_ownPalette = new Palette(palbuffer, offsetAdd);
-			assert(_ownPalette);
-		}
-
-		// FIXME: Confirm the default value here?
-		_transparency = -1;
+		// if this is a packed palette we have a problem :)
+		offsetAdd = 768 /* 0x300 */;
 	}
+		
+	// last frame seems every time to be a empty one
+	_frameCount = _wsaHeader._numFrames - 1;
+	_offsetTable = new uint32[_wsaHeader._numFrames + 2];
+	assert(_offsetTable);
 	
-	WSAMovieV1::~WSAMovieV1() {
-		delete [] _buffer;
-		delete [] _offsetTable;
-		delete [] _currentFrame;
-		delete _ownPalette;
+	// loads the offset table
+	for (uint32 tmp = 0; tmp < (uint32)_wsaHeader._numFrames + 2; ++tmp) {
+		_offsetTable[tmp] = datastream.readUint32LE() + offsetAdd;
+	}
+		
+	if (offsetAdd) {
+		uint8* palbuffer = new uint8[offsetAdd];
+		assert(palbuffer);
+		
+		datastream.read(palbuffer, offsetAdd);
+		
+		_ownPalette = new Palette(palbuffer, offsetAdd);
+		assert(_ownPalette);
 	}
+
+	// FIXME: Confirm the default value here?
+	// LordHoto: What is the 'default' value? 0?
+	_transparency = -1;
+}
 	
-	const uint8* WSAMovieV1::loadFrame(uint16 frame, uint16* width, uint16* height) {
-		if (width) *width = _wsaHeader._width;
-		if (height) *height = _wsaHeader._height;
+WSAMovieV1::~WSAMovieV1() {
+	delete [] _buffer;
+	delete [] _offsetTable;
+	delete [] _currentFrame;
+	delete _ownPalette;
+}
+	
+const uint8* WSAMovieV1::loadFrame(uint16 frame, uint16* width, uint16* height) {
+	if (width) *width = _wsaHeader._width;
+	if (height) *height = _wsaHeader._height;
 			
-		if (frame == _prefetchedFrame) {
-			return _currentFrame;
+	if (frame == _prefetchedFrame) {
+		return _currentFrame;
+	} else {
+		if (!_currentFrame) {
+			_currentFrame = new uint8[_wsaHeader._width * _wsaHeader._height];
+			assert(_currentFrame);
+			memset(_currentFrame, 0, sizeof(uint8) * _wsaHeader._width * _wsaHeader._height);
+		}
+			
+		if (frame >= _wsaHeader._numFrames)
+			return 0;
+				
+		uint8* frameData = 0;
+		static uint8 image40[64000]; // I think this will crash on Plam OS :)
+		memset(image40, 0, ARRAYSIZE(image40));
+		
+		if (frame == _prefetchedFrame + 1) {
+			frameData = _buffer + _offsetTable[frame];
+			Compression::decode80(frameData, image40);
+			Compression::decode40(image40, _currentFrame);
 		} else {
-			if (!_currentFrame) {
-				_currentFrame = new uint8[_wsaHeader._width * _wsaHeader._height];
-				assert(_currentFrame);
+			if (_background) {
+				setImageBackground(_background, _backWidth, _backHeight);
+			} else {
 				memset(_currentFrame, 0, sizeof(uint8) * _wsaHeader._width * _wsaHeader._height);
 			}
 			
-			if (frame >= _wsaHeader._numFrames)
-				return 0;
-				
-			uint8* frameData = 0;
-			static uint8 image40[64000]; // I think this will crash on Plam OS :)
-			memset(image40, 0, ARRAYSIZE(image40));
-			
-			if (frame == _prefetchedFrame + 1) {
-				frameData = _buffer + _offsetTable[frame];
+			for (uint32 i = 0; i <= frame; ++i)
+			{
+				frameData = _buffer + _offsetTable[i];
 				Compression::decode80(frameData, image40);
 				Compression::decode40(image40, _currentFrame);
-			} else {
-				if (_background) {
-					setImageBackground(_background, _backWidth, _backHeight);
-				} else {
-					memset(_currentFrame, 0, sizeof(uint8) * _wsaHeader._width * _wsaHeader._height);
-				}
-
-				for (uint32 i = 0; i <= frame; ++i)
-				{
-					frameData = _buffer + _offsetTable[i];
-					Compression::decode80(frameData, image40);
-					Compression::decode40(image40, _currentFrame);
-				}
 			}
-			
-			_prefetchedFrame = frame;
-			return _currentFrame;
 		}
-		
-		return 0;
-	}
-	
-	void WSAMovieV1::renderFrame(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 frame) {
-		if (!loadFrame(frame, 0, 0))
-			return;
-
-		uint8* src = _currentFrame;
-		uint8* dst = &plane[_wsaHeader._yPos * planepitch + _wsaHeader._xPos];
-		uint32 copysize = planepitch - _wsaHeader._xPos;
-		
-		if (copysize > _wsaHeader._width)
-			copysize = _wsaHeader._width;
 			
-		if (_transparency == -1) {
-			for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < planeheight; ++y_) {
-				memcpy(dst, src, copysize * sizeof(uint8));
-				dst += planepitch;
-				src += _wsaHeader._width;
-			}
-		} else {
-			for (uint16 yadd = 0; yadd < _wsaHeader._height; ++yadd) {
-				for (uint16 xadd = 0; xadd < copysize; ++xadd) {
-					if (*src == _transparency) {
-						++dst;
-						++src;
-					} else {
-						*dst++ = *src++;
-					}
-				}
-				
-				src += _wsaHeader._width - copysize;
-				dst += planepitch - copysize;
-			}
-		}
+		_prefetchedFrame = frame;
+		return _currentFrame;
 	}
-	
-	void WSAMovieV1::setImageBackground(uint8* plane, uint16 planepitch, uint16 height) {
-		assert(plane);
 		
-		_background = plane;
-		_backWidth = planepitch; _backHeight = height;
+	return 0;
+}
+	
+void WSAMovieV1::renderFrame(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 frame) {
+	if (!loadFrame(frame, 0, 0))
+		return;
 
-		if (!_currentFrame) {
-			_currentFrame = new uint8[_wsaHeader._width * _wsaHeader._height];
-			assert(_currentFrame);
-		}
-		
-		memset(_currentFrame, 0, sizeof(uint8) * _wsaHeader._width * _wsaHeader._height);
-		
-		uint8* src = &plane[_wsaHeader._yPos * planepitch + _wsaHeader._xPos];
-		uint8* dst = _currentFrame;
-		uint32 copysize = planepitch - _wsaHeader._xPos;
-		
-		if (copysize > _wsaHeader._width)
-			copysize = _wsaHeader._width;
+	uint8* src = _currentFrame;
+	uint8* dst = &plane[_wsaHeader._yPos * planepitch + _wsaHeader._xPos];
+	uint32 copysize = planepitch - _wsaHeader._xPos;
+	
+	if (copysize > _wsaHeader._width)
+		copysize = _wsaHeader._width;
 		
-		// now copy the rect of the plane
-		for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < height; ++y_) {
+	if (_transparency == -1) {
+		for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < planeheight; ++y_) {
 			memcpy(dst, src, copysize * sizeof(uint8));
-			dst += _wsaHeader._width;
-			src += planepitch;
+			dst += planepitch;
+			src += _wsaHeader._width;
 		}
-		
-		for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < height; ++y_) {
-			for (uint16 x = 0; x < _wsaHeader._width; ++x) {
-				_currentFrame[y_ * _wsaHeader._width + x] ^= 0;
+	} else {
+		for (uint16 yadd = 0; yadd < _wsaHeader._height; ++yadd) {
+			for (uint16 xadd = 0; xadd < copysize; ++xadd) {
+				if (*src == _transparency) {
+					++dst;
+					++src;
+				} else {
+					*dst++ = *src++;
+				}
 			}
+			
+			src += _wsaHeader._width - copysize;
+			dst += planepitch - copysize;
 		}
-		
-		_prefetchedFrame = 0xFFFE;
 	}
+}
 	
-	// Kyrandia 2+ Movies
-	WSAMovieV2::WSAMovieV2(uint8* data, uint32 size) {
-		if (!data) {
-			error("resource created without data");
-		}
+void WSAMovieV1::setImageBackground(uint8* plane, uint16 planepitch, uint16 height) {
+	assert(plane);
 		
-		_background = 0;
-		_currentFrame = 0;
-		_ownPalette = 0;
-		_offsetTable = 0;
-		_prefetchedFrame = 0xFFFE;
-		_looping = false;
-		_buffer = data;
+	_background = plane;
+	_backWidth = planepitch; _backHeight = height;
 
-		// I like these Streams .... =)
-		Common::MemoryReadStream datastream(data, size);
-		
-		datastream.read(&_wsaHeader, sizeof(_wsaHeader));
+	if (!_currentFrame) {
+		_currentFrame = new uint8[_wsaHeader._width * _wsaHeader._height];
+		assert(_currentFrame);
+	}
 		
-		// check for version
-		if (!_wsaHeader._type) {
-			error("loading a WSA version 1 with the WSA version 2 loader");
+	memset(_currentFrame, 0, sizeof(uint8) * _wsaHeader._width * _wsaHeader._height);
+	
+	uint8* src = &plane[_wsaHeader._yPos * planepitch + _wsaHeader._xPos];
+	uint8* dst = _currentFrame;
+	uint32 copysize = planepitch - _wsaHeader._xPos;
+	
+	if (copysize > _wsaHeader._width)
+		copysize = _wsaHeader._width;
+	
+	// now copy the rect of the plane
+	for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < height; ++y_) {
+		memcpy(dst, src, copysize * sizeof(uint8));
+		dst += _wsaHeader._width;
+		src += planepitch;
+	}
+	
+	for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < height; ++y_) {
+		for (uint16 x = 0; x < _wsaHeader._width; ++x) {
+			_currentFrame[y_ * _wsaHeader._width + x] ^= 0;
 		}
+	}
+	
+	_prefetchedFrame = 0xFFFE;
+}
+	
+// Kyrandia 2+ Movies
+WSAMovieV2::WSAMovieV2(uint8* data, uint32 size) {
+	if (!data) {
+		error("resource created without data");
+	}
+	
+	_background = 0;
+	_currentFrame = 0;
+	_ownPalette = 0;
+	_offsetTable = 0;
+	_prefetchedFrame = 0xFFFE;
+	_looping = false;
+	_buffer = data;
 		
-		uint16 offsetAdd = 0;
-		
-		// checks now for own palette
-		if (_wsaHeader._type % 2) {
-			// don't now if this will work right, because a few lines before we use
-			// _wsaHeader._type for detect the version of the WSA movie,
-			// but this code was from FreeKyra Tools so I think it will work
-			
-			// if this is a packed palette we have a problem :)
-			offsetAdd = 768 /* 0x300 */;
-		}
+	// I like these Streams .... =)
+	Common::MemoryReadStream datastream(data, size);
 		
-		_offsetTable = new uint32[_wsaHeader._numFrames + 2];
-		assert(_offsetTable);
+	datastream.read(&_wsaHeader, sizeof(_wsaHeader));
 		
-		// loads the offset table
-		for (uint32 tmp = 0; tmp < (uint32)_wsaHeader._numFrames + 2; ++tmp) {
-			_offsetTable[tmp] = datastream.readUint32LE() + offsetAdd;
-		}
+	// check for version
+	if (!_wsaHeader._type) {
+		error("loading a WSA version 1 with the WSA version 2 loader");
+	}
+	
+	uint16 offsetAdd = 0;
+	
+	// checks now for own palette
+	if (_wsaHeader._type % 2) {
+		// don't now if this will work right, because a few lines before we use
+		// _wsaHeader._type for detect the version of the WSA movie,
+		// but this code was from FreeKyra Tools so I think it will work
 		
-		if (offsetAdd) {
-			uint8* palbuffer = new uint8[offsetAdd];
-			assert(palbuffer);
-			
-			datastream.read(palbuffer, offsetAdd);
-			
-			_ownPalette = new Palette(palbuffer, offsetAdd);
-			assert(_ownPalette);
-		}
+		// if this is a packed palette we have a problem :)
+		offsetAdd = 768 /* 0x300 */;
+	}
+	
+	_offsetTable = new uint32[_wsaHeader._numFrames + 2];
+	assert(_offsetTable);
+	
+	// loads the offset table
+	for (uint32 tmp = 0; tmp < (uint32)_wsaHeader._numFrames + 2; ++tmp) {
+		_offsetTable[tmp] = datastream.readUint32LE() + offsetAdd;
+	}
+	
+	if (offsetAdd) {
+		uint8* palbuffer = new uint8[offsetAdd];
+		assert(palbuffer);
 		
-		if (_offsetTable[_wsaHeader._numFrames + 1] - offsetAdd) {
-			++_wsaHeader._numFrames;
-			_looping = true;
-		}
+		datastream.read(palbuffer, offsetAdd);
 		
-		_frameCount = _wsaHeader._numFrames;
+		_ownPalette = new Palette(palbuffer, offsetAdd);
+		assert(_ownPalette);
 	}
 	
-	WSAMovieV2::~WSAMovieV2() {
-		delete [] _buffer;
-		delete [] _offsetTable;
-		delete [] _currentFrame;
-		delete _ownPalette;
+	if (_offsetTable[_wsaHeader._numFrames + 1] - offsetAdd) {
+		++_wsaHeader._numFrames;
+		_looping = true;
 	}
 	
-	const uint8* WSAMovieV2::loadFrame(uint16 frame, uint16* width, uint16* height) {
-		if (width) *width = _wsaHeader._width;
-		if (height) *height = _wsaHeader._height;
+	_frameCount = _wsaHeader._numFrames;
+}
+	
+WSAMovieV2::~WSAMovieV2() {
+	delete [] _buffer;
+	delete [] _offsetTable;
+	delete [] _currentFrame;
+	delete _ownPalette;
+}
+
+const uint8* WSAMovieV2::loadFrame(uint16 frame, uint16* width, uint16* height) {
+	if (width) *width = _wsaHeader._width;
+	if (height) *height = _wsaHeader._height;
+		
+	if (frame == _prefetchedFrame) {
+		return _currentFrame;
+	} else {
+		if (!_currentFrame) {
+			_currentFrame = new uint8[_wsaHeader._width * _wsaHeader._height];
+			assert(_currentFrame);
+			memset(_currentFrame, 0, sizeof(uint8) * _wsaHeader._width * _wsaHeader._height);
+		}
+		
+		if (frame >= _wsaHeader._numFrames)
+			return 0;
 			
-		if (frame == _prefetchedFrame) {
-			return _currentFrame;
+		uint8* frameData = 0;
+		static uint8 image40[64000]; // I think this will crash on Plam OS :)
+		memset(image40, 0, ARRAYSIZE(image40));
+		
+		if (frame == _prefetchedFrame + 1) {
+			frameData = _buffer + _offsetTable[frame];
+			Compression::decode80(frameData, image40);
+			Compression::decode40(image40, _currentFrame);
 		} else {
-			if (!_currentFrame) {
-				_currentFrame = new uint8[_wsaHeader._width * _wsaHeader._height];
-				assert(_currentFrame);
+			if (_background) {
+				setImageBackground(_background, _backWidth, _backHeight);
+			} else {
 				memset(_currentFrame, 0, sizeof(uint8) * _wsaHeader._width * _wsaHeader._height);
 			}
-			
-			if (frame >= _wsaHeader._numFrames)
-				return 0;
 				
-			uint8* frameData = 0;
-			static uint8 image40[64000]; // I think this will crash on Plam OS :)
-			memset(image40, 0, ARRAYSIZE(image40));
-			
-			if (frame == _prefetchedFrame + 1) {
-				frameData = _buffer + _offsetTable[frame];
+			for (uint32 i = 0; i <= frame; ++i)
+			{
+				frameData = _buffer + _offsetTable[i];
 				Compression::decode80(frameData, image40);
 				Compression::decode40(image40, _currentFrame);
-			} else {
-				if (_background) {
-					setImageBackground(_background, _backWidth, _backHeight);
-				} else {
-					memset(_currentFrame, 0, sizeof(uint8) * _wsaHeader._width * _wsaHeader._height);
-				}
-				
-				for (uint32 i = 0; i <= frame; ++i)
-				{
-					frameData = _buffer + _offsetTable[i];
-					Compression::decode80(frameData, image40);
-					Compression::decode40(image40, _currentFrame);
-				}
 			}
-			
-			_prefetchedFrame = frame;
-			return _currentFrame;
 		}
 		
-		return 0;
+		_prefetchedFrame = frame;
+		return _currentFrame;
 	}
 	
-	void WSAMovieV2::renderFrame(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 frame) {
-		if (!loadFrame(frame, 0, 0))
-			return;
-			
-		uint8* src = _currentFrame;
-		uint8* dst = &plane[_wsaHeader._yPos * planepitch + _wsaHeader._xPos];
-		uint32 copysize = planepitch - _wsaHeader._xPos;
+	return 0;
+}
+	
+void WSAMovieV2::renderFrame(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 frame) {
+	if (!loadFrame(frame, 0, 0))
+		return;
 		
-		if (copysize > _wsaHeader._width)
-			copysize = _wsaHeader._width;
-			
-		if (_transparency == -1) {
-			for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < planeheight; ++y_) {
-				memcpy(dst, src, copysize * sizeof(uint8));
-				dst += planepitch;
-				src += _wsaHeader._width;
-			}
-		} else {
-			for (uint16 yadd = 0; yadd < _wsaHeader._height; ++yadd) {
-				for (uint16 xadd = 0; xadd < copysize; ++xadd) {
-					if (*src == _transparency) {
-						++dst;
-						++src;
-					} else {
-						*dst++ = *src++;
-					}
+	uint8* src = _currentFrame;
+	uint8* dst = &plane[_wsaHeader._yPos * planepitch + _wsaHeader._xPos];
+	uint32 copysize = planepitch - _wsaHeader._xPos;
+	
+	if (copysize > _wsaHeader._width)
+		copysize = _wsaHeader._width;
+		
+	if (_transparency == -1) {
+		for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < planeheight; ++y_) {
+			memcpy(dst, src, copysize * sizeof(uint8));
+			dst += planepitch;
+			src += _wsaHeader._width;
+		}
+	} else {
+		for (uint16 yadd = 0; yadd < _wsaHeader._height; ++yadd) {
+			for (uint16 xadd = 0; xadd < copysize; ++xadd) {
+				if (*src == _transparency) {
+					++dst;
+					++src;
+				} else {
+					*dst++ = *src++;
 				}
-				
-				src += _wsaHeader._width - copysize;
-				dst += planepitch - copysize;
 			}
+			
+			src += _wsaHeader._width - copysize;
+			dst += planepitch - copysize;
 		}
 	}
+}
 	
-	void WSAMovieV2::setImageBackground(uint8* plane, uint16 planepitch, uint16 height) {
-		assert(plane);
-		
-		_background = plane;
-		_backWidth = planepitch; _backHeight = height;
-		
-		if (!_currentFrame) {
-			_currentFrame = new uint8[_wsaHeader._width * _wsaHeader._height];
-			assert(_currentFrame);
-		}
-		
-		memset(_currentFrame, 0, sizeof(uint8) * _wsaHeader._width * _wsaHeader._height);
-		
-		uint8* src = &plane[_wsaHeader._yPos * planepitch + _wsaHeader._xPos];
-		uint8* dst = _currentFrame;
-		uint32 copysize = planepitch - _wsaHeader._xPos;
+void WSAMovieV2::setImageBackground(uint8* plane, uint16 planepitch, uint16 height) {
+	assert(plane);
+	
+	_background = plane;
+	_backWidth = planepitch; _backHeight = height;
 		
-		if (copysize > _wsaHeader._width)
-			copysize = _wsaHeader._width;
+	if (!_currentFrame) {
+		_currentFrame = new uint8[_wsaHeader._width * _wsaHeader._height];
+		assert(_currentFrame);
+	}
 		
-		// now copy the rect of the plane
-		for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < height; ++y_) {
-			memcpy(dst, src, copysize * sizeof(uint8));
-			dst += _wsaHeader._width;
-			src += planepitch;
-		}
+	memset(_currentFrame, 0, sizeof(uint8) * _wsaHeader._width * _wsaHeader._height);
+	
+	uint8* src = &plane[_wsaHeader._yPos * planepitch + _wsaHeader._xPos];
+	uint8* dst = _currentFrame;
+	uint32 copysize = planepitch - _wsaHeader._xPos;
+	
+	if (copysize > _wsaHeader._width)
+		copysize = _wsaHeader._width;
 		
-		for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < height; ++y_) {
-			for (uint16 x = 0; x < _wsaHeader._width; ++x) {
-				_currentFrame[y_ * _wsaHeader._width + x] ^= 0;
-			}
+	// now copy the rect of the plane
+	for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < height; ++y_) {
+		memcpy(dst, src, copysize * sizeof(uint8));
+		dst += _wsaHeader._width;
+		src += planepitch;
+	}
+	
+	for (uint16 y_ = 0; y_ < _wsaHeader._height && _wsaHeader._yPos + y_ < height; ++y_) {
+		for (uint16 x = 0; x < _wsaHeader._width; ++x) {
+			_currentFrame[y_ * _wsaHeader._width + x] ^= 0;
 		}
-		
-		_prefetchedFrame = 0xFFFE;
 	}
+	
+	_prefetchedFrame = 0xFFFE;
+}
 } // end of namespace Kyra
 

Index: wsamovie.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/kyra/wsamovie.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- wsamovie.h	11 Nov 2004 13:35:21 -0000	1.2
+++ wsamovie.h	14 Nov 2004 20:11:22 -0000	1.3
@@ -26,109 +26,109 @@
 
 namespace Kyra {
 
-	// a generic movie
-	class Movie {
+// a generic movie
+class Movie {
 	
-	public:
+public:
 	
-		virtual ~Movie() { _transparency = -1; _ownPalette = 0; _frameCount = 0; }
-		
-		virtual void renderFrame(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 frame) = 0;
-		virtual const uint8* loadFrame(uint16 frame, uint16* width = 0, uint16* height = 0) = 0;
-		virtual uint16 countFrames(void) { return _frameCount; }
+	virtual ~Movie() { _transparency = -1; _ownPalette = 0; _frameCount = 0; }
 		
-		// could be deleted(not imdiantly maybe it's needed sometime)
-		virtual void transparency(int16 color) { _transparency = color; }
-		virtual void position(uint16 x, uint16 y) = 0;
+	virtual void renderFrame(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 frame) = 0;
+	virtual const uint8* loadFrame(uint16 frame, uint16* width = 0, uint16* height = 0) = 0;
+	virtual uint16 countFrames(void) { return _frameCount; }
 		
-		virtual bool hasPalette(void) { return (_ownPalette != 0); }
-		virtual Palette* palette(void) { return _ownPalette; }
+	// could be deleted(not imdiantly maybe it's needed sometime)
+	virtual void transparency(int16 color) { _transparency = color; }
+	virtual void position(uint16 x, uint16 y) = 0;
 		
-		virtual bool looping(void) { return false; }
-		virtual uint32 frameChange(void) { return 100; }		
-		virtual void setImageBackground(uint8* plane, uint16 planepitch, uint16 height) {};
+	virtual bool hasPalette(void) { return (_ownPalette != 0); }
+	virtual Palette* palette(void) { return _ownPalette; }
 	
-	protected:
-		int16 _transparency;
-		uint16 _frameCount;
-		Palette* _ownPalette;
-	};
+	virtual bool looping(void) { return false; }
+	virtual uint32 frameChange(void) { return 100; }		
+	virtual void setImageBackground(uint8* plane, uint16 planepitch, uint16 height) {};
 	
-	// movie format for Kyrandia 1
-	class WSAMovieV1 : public Movie {
+protected:
+	int16 _transparency;
+	uint16 _frameCount;
+	Palette* _ownPalette;
+};
+
+// movie format for Kyrandia 1
+class WSAMovieV1 : public Movie {
 	
-	public:
+public:
 	
-		WSAMovieV1(uint8* data, uint32 size, uint8 gameid);
-		~WSAMovieV1();
-		
-		void renderFrame(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 frame);
-		const uint8* loadFrame(uint16 frame, uint16* width, uint16* height);
-		void setImageBackground(uint8* plane, uint16 planepitch, uint16 height);
+	WSAMovieV1(uint8* data, uint32 size, uint8 gameid);
+	~WSAMovieV1();
 		
-		void position(uint16 x, uint16 y) { _wsaHeader._xPos = x; _wsaHeader._yPos = y; }
-	protected:
+	void renderFrame(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 frame);
+	const uint8* loadFrame(uint16 frame, uint16* width, uint16* height);
+	void setImageBackground(uint8* plane, uint16 planepitch, uint16 height);
 	
-		uint8* _buffer;
+	void position(uint16 x, uint16 y) { _wsaHeader._xPos = x; _wsaHeader._yPos = y; }
+protected:
+	
+	uint8* _buffer;
 	
 #pragma START_PACK_STRUCTS	
-		struct WSAHeader {
-			uint16 _numFrames; // All right
-			uint16 _width; // All right
-			uint16 _height; // All right
-			uint8 _xPos; // is wrong
-			uint8 _yPos; // is wrong
-			uint16 _delta; // should be right
-			uint16 _type; // should be right
-		} GCC_PACK _wsaHeader;
+	struct WSAHeader {
+		uint16 _numFrames; // All right
+		uint16 _width; // All right
+		uint16 _height; // All right
+		uint8 _xPos; // is wrong
+		uint8 _yPos; // is wrong
+		uint16 _delta; // is wrong
+		uint16 _type; // is wrong
+	} GCC_PACK _wsaHeader;
 #pragma END_PACK_STRUCTS
 
-		uint32* _offsetTable;
-		
-		uint8* _currentFrame;
-		uint16 _prefetchedFrame;
-		
-		uint8* _background; // only a pointer to the screen
-		uint16 _backWidth, _backHeight;
-	};
+	uint32* _offsetTable;
 	
-	// movie format for Kyrandia 2+
-	class WSAMovieV2 : public Movie {
+	uint8* _currentFrame;
+	uint16 _prefetchedFrame;
 	
-	public:
-		WSAMovieV2(uint8* data, uint32 size);
-		~WSAMovieV2();
+	uint8* _background; // only a pointer to the screen
+	uint16 _backWidth, _backHeight;
+};
 	
-		void renderFrame(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 frame);
-		const uint8* loadFrame(uint16 frame, uint16* width, uint16* height);
-		void setImageBackground(uint8* plane, uint16 planepitch, uint16 height);
-		
-		void position(uint16 x, uint16 y) { _wsaHeader._xPos = x; _wsaHeader._yPos = y; }
-		bool looping(void) { return _looping; }
-	protected:
+// movie format for Kyrandia 2+
+class WSAMovieV2 : public Movie {
 	
-		uint8* _buffer;
-		
-		struct WSAHeader {
-			uint16 _numFrames; // All right
-			uint16 _width; // should be right
-			uint16 _height; // should be right
-			uint16 _xPos; // could be wrong
-			uint16 _yPos; // could be wrong
-			uint16 _delta; // could be wrong
-			uint16 _type; // should be right
-		} GCC_PACK _wsaHeader;
-		
-		uint32* _offsetTable;
-		
-		uint8* _currentFrame;
-		uint16 _prefetchedFrame;
-		
-		uint8* _background; // only a pointer to the screen
-		uint16 _backWidth, _backHeight;
+public:
+	WSAMovieV2(uint8* data, uint32 size);
+	~WSAMovieV2();
+	
+	void renderFrame(uint8* plane, uint16 planepitch, uint16 planeheight, uint16 frame);
+	const uint8* loadFrame(uint16 frame, uint16* width, uint16* height);
+	void setImageBackground(uint8* plane, uint16 planepitch, uint16 height);
+	
+	void position(uint16 x, uint16 y) { _wsaHeader._xPos = x; _wsaHeader._yPos = y; }
+	bool looping(void) { return _looping; }
+protected:
+	
+	uint8* _buffer;
 		
-		bool _looping;
-	};
+	struct WSAHeader {
+		uint16 _numFrames; // All right
+		uint16 _width; // should be right
+		uint16 _height; // should be right
+		uint16 _xPos; // could be wrong
+		uint16 _yPos; // could be wrong
+		uint16 _delta; // could be wrong
+		uint16 _type; // should be right
+	} GCC_PACK _wsaHeader;
+	
+	uint32* _offsetTable;
+	
+	uint8* _currentFrame;
+	uint16 _prefetchedFrame;
+	
+	uint8* _background; // only a pointer to the screen
+	uint16 _backWidth, _backHeight;
+	
+	bool _looping;
+};
 } // end of namespace Kyra
 
 #endif





More information about the Scummvm-git-logs mailing list