[Scummvm-cvs-logs] SF.net SVN: scummvm:[47206] scummvm/trunk/engines/sci/graphics

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Sat Jan 9 21:38:23 CET 2010


Revision: 47206
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47206&view=rev
Author:   m_kiewitz
Date:     2010-01-09 20:38:22 +0000 (Sat, 09 Jan 2010)

Log Message:
-----------
SCI: kPortrait - animation included, doesnt seem right currently coordinate offset is missing (cause i cant find it) and mouth movement doesnt seem right...at least the basics work and graphic data is fine

Modified Paths:
--------------
    scummvm/trunk/engines/sci/graphics/portrait.cpp
    scummvm/trunk/engines/sci/graphics/portrait.h

Modified: scummvm/trunk/engines/sci/graphics/portrait.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/portrait.cpp	2010-01-09 19:32:39 UTC (rev 47205)
+++ scummvm/trunk/engines/sci/graphics/portrait.cpp	2010-01-09 20:38:22 UTC (rev 47206)
@@ -82,7 +82,8 @@
 	}
 	_width = READ_LE_UINT16(_fileData + 3);
 	_height = READ_LE_UINT16(_fileData + 5);
-	_animationCount = READ_LE_UINT16(_fileData + 7);
+	_bitmapCount = READ_LE_UINT16(_fileData + 7);
+	_bitmaps = new PortraitBitmap[_bitmapCount];
 
 	_portraitPaletteSize = READ_LE_UINT16(_fileData + 13);
 	byte *data = _fileData + 17;
@@ -98,14 +99,17 @@
 		palNr++; palSize += 3;
 	}
 
-	// Read main bitmap
-	assert(READ_LE_UINT16(data + 4) == _height);
-	assert(READ_LE_UINT16(data + 6) == _width);
-	data += 14; // Skip over bitmap header
-	_mainBitmapData = data;
-	data += _height * _width;
-	
-	// TODO: Read animation bitmaps
+	// Read all bitmaps
+	PortraitBitmap *curBitmap = _bitmaps;
+	uint16 bitmapNr;
+
+	for (bitmapNr = 0; bitmapNr < _bitmapCount; bitmapNr++) {
+		curBitmap->height = READ_LE_UINT16(data + 4);
+		curBitmap->width = READ_LE_UINT16(data + 6);
+		curBitmap->rawBitmap = data + 14;
+		data += 14 + (curBitmap->height * curBitmap->width);
+		curBitmap++;
+	}
 }
 
 void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint16 verb, uint16 cond, uint16 seq) {
@@ -118,57 +122,61 @@
 	uint syncOffset = 0;
 
 	// Draw base bitmap
-	drawMainBitmap();
+	_palette->set(&_portraitPalette, 1);
+	drawBitmap(0);
 
 	// Start playing audio...
 	_audio->stopAudio();
 	_audio->startAudio(resourceId, audioNumber);
 
 	// Do animation depending on sync resource till audio is done playing
-	int16 syncCue;
+	// TODO: This whole mess doesnt seem to be correct currently
+	uint16 syncCue;
 	int timerPosition, curPosition;
-
-	timerPosition = 0;
 	while (syncOffset < syncResource->size - 2) {
-		timerPosition += (int16)READ_LE_UINT16(syncResource->data + syncOffset);
+		timerPosition = (int16)READ_LE_UINT16(syncResource->data + syncOffset);
 		syncOffset += 2;
 		if (syncOffset < syncResource->size - 2) {
-			syncCue = (int16)READ_LE_UINT16(syncResource->data + syncOffset);
+			syncCue = READ_LE_UINT16(syncResource->data + syncOffset);
 			syncOffset += 2;
 		} else {
-			syncCue = -1;
+			syncCue = 0xFFFF;
 		}
+
+		if (syncCue != 0xFFFF) {
+			// Display animation bitmap
+			syncCue++; // TODO: Not sure if 0 means main bitmap or animation-frame 0
+			if (syncCue < _bitmapCount) {
+				drawBitmap(syncCue);
+			} else {
+				warning("kPortrait: sync information tried to draw non-existant %d", syncCue);
+			}
+		}
+
 		// Wait till syncTime passed, then show specific animation bitmap
 		do {
 			g_system->delayMillis(10);
 			curPosition = _audio->getAudioPosition();
 		} while ((curPosition != -1) && (curPosition < timerPosition));
-
-		if (syncCue >= 0) {
-			// Display animation bitmap
-			drawBitmap(syncCue);
-			warning("display animation %d", syncCue);
-		}
 	}
 }
 
-void Portrait::drawMainBitmap() {
-	byte *data = _mainBitmapData;
-	_palette->set(&_portraitPalette, 1);
-	for (int y = 0; y < _height; y++) {
-		for (int x = 0; x < _width; x++) {
+// TODO: coordinate offset is missing...can't find it in the bitmap header nor in the main header
+void Portrait::drawBitmap(uint16 bitmapNr) {
+	byte *data = _bitmaps[bitmapNr].rawBitmap;
+	uint16 bitmapHeight = _bitmaps[bitmapNr].height;
+	uint16 bitmapWidth = _bitmaps[bitmapNr].width;
+
+	for (int y = 0; y < bitmapHeight; y++) {
+		for (int x = 0; x < bitmapWidth; x++) {
 			_screen->putPixelOnDisplay(_position.x + x, _position.y + y, _portraitPalette.mapping[*data++]);
 		}
 	}
 
-	Common::Rect mainBitmap = Common::Rect(_width, _height);
-	mainBitmap.moveTo(_position.x, _position.y);
-	_screen->copyDisplayRectToScreen(mainBitmap);
+	Common::Rect bitmapRect = Common::Rect(bitmapWidth, bitmapHeight);
+	bitmapRect.moveTo(_position.x, _position.y);
+	_screen->copyDisplayRectToScreen(bitmapRect);
 	g_system->updateScreen();
 }
 
-void Portrait::drawBitmap(int16 bitmapNr) {
-	// 0 seems to be main bitmap
-}
-
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/graphics/portrait.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/portrait.h	2010-01-09 19:32:39 UTC (rev 47205)
+++ scummvm/trunk/engines/sci/graphics/portrait.h	2010-01-09 20:38:22 UTC (rev 47206)
@@ -28,6 +28,11 @@
 
 namespace Sci {
 
+struct PortraitBitmap {
+	int16 width, height;
+	byte *rawBitmap;
+};
+
 class Portrait {
 public:
 	Portrait(ResourceManager *resMan, Screen *screen, SciPalette *palette, AudioPlayer *audio, Common::String resourceName);
@@ -38,8 +43,7 @@
 
 private:
 	void init();
-	void drawMainBitmap();
-	void drawBitmap(int16 bitmapNr);
+	void drawBitmap(uint16 bitmapNr);
 
 	ResourceManager *_resMan;
 	Screen *_screen;
@@ -53,11 +57,11 @@
 
 	uint16 _height;
 	uint16 _width;
-	uint16 _animationCount;
 	uint16 _portraitPaletteSize;
 	Palette _portraitPalette;
 
-	byte *_mainBitmapData;
+	uint16 _bitmapCount;
+	PortraitBitmap *_bitmaps;
 
 	Common::Point _position;
 };


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