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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Sat Jan 9 20:12:53 CET 2010


Revision: 47204
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47204&view=rev
Author:   m_kiewitz
Date:     2010-01-09 19:12:53 +0000 (Sat, 09 Jan 2010)

Log Message:
-----------
SCI: kPortrait almost fully implemented (animation bitmaps still missing)

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

Modified: scummvm/trunk/engines/sci/graphics/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/gui.cpp	2010-01-09 18:51:25 UTC (rev 47203)
+++ scummvm/trunk/engines/sci/graphics/gui.cpp	2010-01-09 19:12:53 UTC (rev 47204)
@@ -850,15 +850,14 @@
 	return NULL_REG;
 }
 
-void SciGui::portraitShow(Common::String resourceName, Common::Point position, uint16 resourceNum, uint16 noun, uint16 verb, uint16 cond, uint16 seq) {
+void SciGui::portraitShow(Common::String resourceName, Common::Point position, uint16 resourceId, uint16 noun, uint16 verb, uint16 cond, uint16 seq) {
 	Portrait *myPortrait = new Portrait(_s->resMan, _screen, _palette, _audio, resourceName);
 	// TODO: cache portraits
 	// adjust given coordinates to curPort (but dont adjust coordinates on upscaledHires_Save_Box and give us hires coordinates
 	//  on kDrawCel, yeah this whole stuff makes sense)
 	position.x += _gfx->GetPort()->left; position.y += _gfx->GetPort()->top;
 	position.x *= 2; position.y *= 2;
-	myPortrait->setupAudio(resourceNum, noun, verb, cond, seq);
-	myPortrait->draw(position);
+	myPortrait->doit(position, resourceId, noun, verb, cond, seq);
 	delete myPortrait;
 }
 

Modified: scummvm/trunk/engines/sci/graphics/portrait.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/portrait.cpp	2010-01-09 18:51:25 UTC (rev 47203)
+++ scummvm/trunk/engines/sci/graphics/portrait.cpp	2010-01-09 19:12:53 UTC (rev 47204)
@@ -108,25 +108,67 @@
 	// TODO: Read animation bitmaps
 }
 
-void Portrait::setupAudio(uint16 resourceId, uint16 noun, uint16 verb, uint16 cond, uint16 seq) {
-	uint32 number = ((noun & 0xff) << 24) | ((verb & 0xff) << 16) | ((cond & 0xff) << 8) | (seq & 0xff);
+void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint16 verb, uint16 cond, uint16 seq) {
+	_position = position;
 
+	// Now init audio and sync resource
+	uint32 audioNumber = ((noun & 0xff) << 24) | ((verb & 0xff) << 16) | ((cond & 0xff) << 8) | (seq & 0xff);
+	ResourceId syncResourceId = ResourceId(kResourceTypeSync36, resourceId, noun, verb, cond, seq);
+	Resource *syncResource = _resMan->findResource(syncResourceId, true);
+	uint syncOffset = 0;
+
+	// Draw base bitmap
+	drawMainBitmap();
+
+	// Start playing audio...
 	_audio->stopAudio();
-	_audio->startAudio(resourceId, number);
+	_audio->startAudio(resourceId, audioNumber);
+
+	// Do animation depending on sync resource till audio is done playing
+	int16 syncCue;
+	int timerPosition, curPosition;
+
+	timerPosition = 0;
+	while (syncOffset < syncResource->size - 2) {
+		timerPosition += (int16)READ_LE_UINT16(syncResource->data + syncOffset);
+		syncOffset += 2;
+		if (syncOffset < syncResource->size - 2) {
+			syncCue = (int16)READ_LE_UINT16(syncResource->data + syncOffset);
+			syncOffset += 2;
+		} else {
+			syncCue = -1;
+		}
+		// 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::draw(Common::Point position) {
+void Portrait::drawMainBitmap() {
 	byte *data = _mainBitmapData;
 	_palette->set(&_portraitPalette, 1);
 	for (int y = 0; y < _height; y++) {
 		for (int x = 0; x < _width; x++) {
-			_screen->putPixelOnDisplay(position.x + x, position.y + y, _portraitPalette.mapping[*data++]);
+			_screen->putPixelOnDisplay(_position.x + x, _position.y + y, _portraitPalette.mapping[*data++]);
 		}
 	}
 
 	Common::Rect mainBitmap = Common::Rect(_width, _height);
-	mainBitmap.moveTo(position.x, position.y);
+	mainBitmap.moveTo(_position.x, _position.y);
 	_screen->copyDisplayRectToScreen(mainBitmap);
+	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 18:51:25 UTC (rev 47203)
+++ scummvm/trunk/engines/sci/graphics/portrait.h	2010-01-09 19:12:53 UTC (rev 47204)
@@ -34,10 +34,12 @@
 	~Portrait();
 
 	void setupAudio(uint16 resourceId, uint16 noun, uint16 verb, uint16 cond, uint16 seq);
-	void draw(Common::Point position);
+	void doit(Common::Point position, uint16 resourceId, uint16 noun, uint16 verb, uint16 cond, uint16 seq);
 
 private:
 	void init();
+	void drawMainBitmap();
+	void drawBitmap(int16 bitmapNr);
 
 	ResourceManager *_resMan;
 	Screen *_screen;
@@ -56,6 +58,8 @@
 	Palette _portraitPalette;
 
 	byte *_mainBitmapData;
+
+	Common::Point _position;
 };
 
 } // End of namespace Sci


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