[Scummvm-cvs-logs] SF.net SVN: scummvm:[35376] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Mon Dec 15 06:16:24 CET 2008


Revision: 35376
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35376&view=rev
Author:   drmccoy
Date:     2008-12-15 05:16:23 +0000 (Mon, 15 Dec 2008)

Log Message:
-----------
Support for Urban Runner's new cursors (frames out of 16bit color VMDs)

Modified Paths:
--------------
    scummvm/trunk/engines/gob/coktelvideo.cpp
    scummvm/trunk/engines/gob/coktelvideo.h
    scummvm/trunk/engines/gob/inter_v6.cpp
    scummvm/trunk/engines/gob/video_v6.cpp
    scummvm/trunk/engines/gob/videoplayer.cpp

Modified: scummvm/trunk/engines/gob/coktelvideo.cpp
===================================================================
--- scummvm/trunk/engines/gob/coktelvideo.cpp	2008-12-15 05:08:25 UTC (rev 35375)
+++ scummvm/trunk/engines/gob/coktelvideo.cpp	2008-12-15 05:16:23 UTC (rev 35376)
@@ -920,18 +920,17 @@
 		}
 	}
 
-	if (handle == 0) {
-		// _field_463 = 1;
-	} else if (handle == 1) {
-		// _field_463 = 0;
-	} else if (handle == 2) {
-		// _field_463 = 2;
-	} else {
+	if (handle > 2) {
 		warning("VMD Version incorrect (%d, %d, %d)", headerLength, handle, _version);
 		unload();
 		return false;
 	}
 
+	_bytesPerPixel = handle + 1;
+
+	if (_bytesPerPixel > 1)
+		_features |= kFeaturesFullColor;
+
 	_flags = _stream->readUint16LE();
 	_partsPerFrame = _stream->readUint16LE();
 	_firstFramePos = _stream->readUint32LE();
@@ -946,14 +945,15 @@
 	_frameDataSize = _stream->readUint32LE();
 	_vidBufferSize = _stream->readUint32LE();
 
+	if (_bytesPerPixel > 1)
+		_frameDataSize = _vidBufferSize = 0;
 	// 0x322 (802)
 
 	if (_hasVideo) {
-		_vidBufferSize = _frameDataSize = 312200;
-/*		if ((_frameDataSize == 0) || (_frameDataSize > 1048576))
-			_frameDataSize = _width * _height + 500;
+		if ((_frameDataSize == 0) || (_frameDataSize > 1048576))
+			_frameDataSize = _width * _height + 1000;
 		if ((_vidBufferSize == 0) || (_vidBufferSize > 1048576))
-			_vidBufferSize = _frameDataSize;*/
+			_vidBufferSize = _frameDataSize;
 
 		_frameData = new byte[_frameDataSize];
 		assert(_frameData);
@@ -1092,6 +1092,13 @@
 	clear();
 }
 
+int16 Vmd::getWidth() const {
+	if (_bytesPerPixel == 2)
+		return _width >> 1;
+
+	return _width;
+}
+
 void Vmd::setXY(int16 x, int16 y) {
 
 	for (int i = 0; i < _framesCount; i++) {
@@ -1166,6 +1173,8 @@
 
 	_soundBytesPerSample = 1;
 	_soundStereo = 0;
+
+	_bytesPerPixel = 1;
 }
 
 CoktelVideo::State Vmd::processFrame(uint16 frame) {
@@ -1613,4 +1622,55 @@
 	return stream;
 }
 
+void Vmd::copyCurrentFrame(byte *dest,
+		uint16 left, uint16 top, uint16 width, uint16 height,
+		uint16 x, uint16 y, uint16 pitch, int16 transp) {
+
+	if (_bytesPerPixel != 2)
+		Imd::copyCurrentFrame(dest, left, top, width, height, x, y, pitch, transp);
+
+	if (!_vidMem)
+		return;
+
+	int16 vWidth = _width >> 1;
+
+	if (((left + width) > vWidth) || ((top + height) > _height))
+		return;
+
+	assert(_palLUT);
+
+	SierraLight *dither = new SierraLight(width, height, _palLUT);
+
+	uint16 *vidMem = (uint16 *) _vidMem;
+	dest += pitch * y;
+	vidMem += vWidth * top;
+
+	for (int i = 0; i < height; i++) {
+		byte *d = dest + x;
+		uint16 *s = vidMem + left;
+
+		for (int j = 0; j < width; j++, s++) {
+			byte r = ((*s & 0x7C00) >> 10) << 1;
+			byte g = ((*s & 0x03E0) >>  5) << 1;
+			byte b = ((*s & 0x001F) >>  0) << 1;
+			byte dY, dU, dV;
+
+			PaletteLUT::RGB2YUV(r << 2, g << 2, b << 2, dY, dU, dV);
+
+			byte p = dither->dither(dY, dU, dV, j);
+
+			if ((dY == 0) || ((r == 0) && (g == 0) && (b == 0)))
+				*d++ = 0;
+			else
+				*d++ = p;
+		}
+
+		dither->nextLine();
+		dest += pitch;
+		vidMem += vWidth;
+	}
+
+	delete dither;
+}
+
 } // End of namespace Gob

Modified: scummvm/trunk/engines/gob/coktelvideo.h
===================================================================
--- scummvm/trunk/engines/gob/coktelvideo.h	2008-12-15 05:08:25 UTC (rev 35375)
+++ scummvm/trunk/engines/gob/coktelvideo.h	2008-12-15 05:16:23 UTC (rev 35376)
@@ -315,12 +315,18 @@
 	bool load(Common::SeekableReadStream &stream);
 	void unload();
 
+	int16 getWidth() const;
+
 	void setXY(int16 x, int16 y);
 
 	void seekFrame(int32 frame, int16 whence = SEEK_SET, bool restart = false);
 
 	State nextFrame();
 
+	virtual void copyCurrentFrame(byte *dest,
+			uint16 left, uint16 top, uint16 width, uint16 height,
+			uint16 x, uint16 y, uint16 pitch, int16 transp = -1);
+
 protected:
 	enum PartType {
 		kPartTypeSeparator = 0,
@@ -366,6 +372,8 @@
 	byte _soundBytesPerSample;
 	byte _soundStereo; // (0: mono, 1: old-style stereo, 2: new-style stereo)
 
+	byte _bytesPerPixel;
+
 	PaletteLUT *_palLUT;
 	Indeo3 *_codecIndeo3;
 

Modified: scummvm/trunk/engines/gob/inter_v6.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v6.cpp	2008-12-15 05:08:25 UTC (rev 35375)
+++ scummvm/trunk/engines/gob/inter_v6.cpp	2008-12-15 05:16:23 UTC (rev 35376)
@@ -753,52 +753,65 @@
 }
 
 bool Inter_v6::o6_loadCursor(OpFuncParams &params) {
-	int16 width, height;
-	byte *dataBuf;
-	int16 id;
-	int8 index;
+	int16 id = load16();
 
-	id = load16();
+	if ((id == -1) || (id == -2)) {
+		char file[10];
 
-	if (id == -1) {
-		byte str[10];
+		if (id == -1) {
+			for (int i = 0; i < 9; i++)
+				file[i] = *_vm->_global->_inter_execPtr++;
+		} else
+			strncpy(file, GET_VAR_STR(load16()), 10);
 
-		for (int i = 0; i < 9; i++)
-			str[i] = *_vm->_global->_inter_execPtr++;
+		file[9] = '\0';
 
-		str[9] = '\0';
+		uint16 start = load16();
+		int8 index = (int8) *_vm->_global->_inter_execPtr++;
 
-		uint16 var1 = load16();
-		int8 var2 = *_vm->_global->_inter_execPtr++;
+		int vmdSlot = _vm->_vidPlayer->slotOpen(file);
 
-		warning("Urban Stub: loadCursor %d: \"%s\", %d, %d", id, str, var1, var2);
+		if (vmdSlot == -1) {
+			warning("Can't open video \"%s\" as cursor", file);
+			return false;
+		}
 
-	} else if (id == -2) {
+		int16 framesCount = _vm->_vidPlayer->getFramesCount(vmdSlot);
 
-		uint16 var1 = load16();
-		uint16 var2 = load16();
-		int8 var3 = *_vm->_global->_inter_execPtr++;
+		for (int i = 0; i < framesCount; i++) {
+			_vm->_vidPlayer->slotPlay(vmdSlot);
+			_vm->_vidPlayer->slotCopyFrame(vmdSlot, _vm->_draw->_cursorSprites->getVidMem(),
+					0, 0, _vm->_draw->_cursorWidth, _vm->_draw->_cursorWidth,
+					(start + i) * _vm->_draw->_cursorWidth, 0,
+					_vm->_draw->_cursorSprites->getWidth());
+		}
 
-		warning("Urban Stub: loadCursor %d: %d, %d, %d", id, var1, var2, var3);
+		_vm->_vidPlayer->slotClose(vmdSlot);
 
-	} else {
-		index = (int8) *_vm->_global->_inter_execPtr++;
+		_vm->_draw->_cursorAnimLow[index] = start;
+		_vm->_draw->_cursorAnimHigh[index] = framesCount + start - 1;
+		_vm->_draw->_cursorAnimDelays[index] = 10;
 
-		if ((index * _vm->_draw->_cursorWidth) >= _vm->_draw->_cursorSprites->getWidth())
-			return false;
+		return false;
+	}
 
-		dataBuf = _vm->_game->loadTotResource(id, 0, &width, &height);
+	int8 index = (int8) *_vm->_global->_inter_execPtr++;
 
-		_vm->_video->fillRect(_vm->_draw->_cursorSprites,
-				index * _vm->_draw->_cursorWidth, 0,
-				index * _vm->_draw->_cursorWidth + _vm->_draw->_cursorWidth - 1,
-				_vm->_draw->_cursorHeight - 1, 0);
+	if ((index * _vm->_draw->_cursorWidth) >= _vm->_draw->_cursorSprites->getWidth())
+		return false;
 
-		_vm->_video->drawPackedSprite(dataBuf, width, height,
-				index * _vm->_draw->_cursorWidth, 0, 0, _vm->_draw->_cursorSprites);
-		_vm->_draw->_cursorAnimLow[index] = 0;
-	}
+	int16 width, height;
+	byte *dataBuf = _vm->_game->loadTotResource(id, 0, &width, &height);
 
+	_vm->_video->fillRect(_vm->_draw->_cursorSprites,
+			index * _vm->_draw->_cursorWidth, 0,
+			index * _vm->_draw->_cursorWidth + _vm->_draw->_cursorWidth - 1,
+			_vm->_draw->_cursorHeight - 1, 0);
+
+	_vm->_video->drawPackedSprite(dataBuf, width, height,
+			index * _vm->_draw->_cursorWidth, 0, 0, _vm->_draw->_cursorSprites);
+	_vm->_draw->_cursorAnimLow[index] = 0;
+
 	return false;
 }
 

Modified: scummvm/trunk/engines/gob/video_v6.cpp
===================================================================
--- scummvm/trunk/engines/gob/video_v6.cpp	2008-12-15 05:08:25 UTC (rev 35375)
+++ scummvm/trunk/engines/gob/video_v6.cpp	2008-12-15 05:16:23 UTC (rev 35376)
@@ -107,20 +107,6 @@
 	const byte *dataU = dataY +  (dataWidth * dataHeight);
 	const byte *dataV = dataU + ((dataWidth * dataHeight) >> 4);
 
-/*
-	if (destDesc->field_14 == 1) {
-		SurfaceDesc *tmpSurf = _vid_initSurfDesc(2, width, height, 0);
-
-		sub_46126(tmpSurf, 0, 0, dataWidth, dataHeight, width, height, dataY, dataU, dataV);
-
-		_vid_drawSprite(tmpSurf, destDesc, 0, 0, width - 1, height - 1, x, y, 0);
-
-		_vid_freeSurfDesc(tmpSurf);
-
-		return;
-	}
-*/
-
 	drawYUV(destDesc, x, y, dataWidth, dataHeight, width, height, dataY, dataU, dataV);
 
 }

Modified: scummvm/trunk/engines/gob/videoplayer.cpp
===================================================================
--- scummvm/trunk/engines/gob/videoplayer.cpp	2008-12-15 05:08:25 UTC (rev 35375)
+++ scummvm/trunk/engines/gob/videoplayer.cpp	2008-12-15 05:16:23 UTC (rev 35376)
@@ -360,8 +360,6 @@
 		return -1;
 	}
 
-	assert((video->getVideo()->getFeatures() & CoktelVideo::kFeaturesFullColor) == 0);
-
 	video->getVideo()->setVideoMemory();
 	video->getVideo()->enableSound(*_vm->_mixer);
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list