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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Thu Jan 7 11:31:48 CET 2010


Revision: 47105
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47105&view=rev
Author:   m_kiewitz
Date:     2010-01-07 10:31:29 +0000 (Thu, 07 Jan 2010)

Log Message:
-----------
SCI: some portrait work (kq6 now shows the main bitmap as portrait, coordinates still messed up)

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

Modified: scummvm/trunk/engines/sci/graphics/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/gui.cpp	2010-01-07 10:22:31 UTC (rev 47104)
+++ scummvm/trunk/engines/sci/graphics/gui.cpp	2010-01-07 10:31:29 UTC (rev 47105)
@@ -39,6 +39,7 @@
 #include "sci/graphics/animate.h"
 #include "sci/graphics/controls.h"
 #include "sci/graphics/menu.h"
+#include "sci/graphics/portrait.h"
 #include "sci/graphics/robot.h"
 #include "sci/graphics/text.h"
 #include "sci/graphics/transitions.h"
@@ -827,10 +828,15 @@
 }
 
 reg_t SciGui::portraitLoad(Common::String resourceName) {
+	//Portrait *myPortrait = new Portrait(_s->resMan, _screen, _palette, resourceName);
 	return NULL_REG;
 }
 
 void SciGui::portraitShow(Common::String resourceName, Common::Point position, uint16 resourceNum, uint16 noun, uint16 verb, uint16 cond, uint16 seq) {
+	Portrait *myPortrait = new Portrait(_s->resMan, _screen, _palette, resourceName);
+	// TODO: cache portraits
+	myPortrait->draw(position);
+	delete myPortrait;
 }
 
 void SciGui::portraitUnload(uint16 portraitId) {

Modified: scummvm/trunk/engines/sci/graphics/portrait.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/portrait.cpp	2010-01-07 10:22:31 UTC (rev 47104)
+++ scummvm/trunk/engines/sci/graphics/portrait.cpp	2010-01-07 10:31:29 UTC (rev 47105)
@@ -47,12 +47,13 @@
 	// .BIN files are loaded from actors directory and from .\ directory
 	// header:
 	// 3 bytes "WIN"
+	// 2 bytes main width (should be the same as first bitmap header width)
 	// 2 bytes main height (should be the same as first bitmap header height)
-	// 2 bytes main width (should be the same as first bitmap header width)
 	// 2 bytes animation count
 	// 2 bytes unknown
 	// 2 bytes unknown
 	// 4 bytes paletteSize (base 1)
+	//  -> 17 bytes
 	// paletteSize bytes paletteData
 	// 14 bytes bitmap header
 	//  -> 4 bytes unknown
@@ -61,6 +62,63 @@
 	//  -> 6 bytes unknown
 	// height * width bitmap data
 	// another animation count times bitmap header and data
+	Common::SeekableReadStream *file = 0;
+	_fileName = "actors/" + _resourceName + ".bin";
+	file = SearchMan.createReadStreamForMember(_fileName);
+	if (!file) {
+		_fileName = _resourceName + ".bin";
+		file = SearchMan.createReadStreamForMember(_fileName);
+		if (!file)
+			error("portrait %s.bin not found", _resourceName.c_str());
+	}
+	_fileSize = file->size();
+	_fileData = new byte[_fileSize];
+	file->read(_fileData, _fileSize);
+	delete file;
+
+	if (strncmp((char *)_fileData, "WIN", 3)) {
+		error("portrait %s doesn't have valid header", _resourceName.c_str());
+	}
+	_width = READ_LE_UINT16(_fileData + 3);
+	_height = READ_LE_UINT16(_fileData + 5);
+	_animationCount = READ_LE_UINT16(_fileData + 7);
+
+	_portraitPaletteSize = READ_LE_UINT16(_fileData + 13);
+	byte *data = _fileData + 17;
+	// Read palette
+	memset(&_portraitPalette, 0, sizeof(Palette));
+	uint16 palSize = 0, palNr = 0;
+	while (palSize < _portraitPaletteSize) {
+		_portraitPalette.colors[palNr].b = *data++;
+		_portraitPalette.colors[palNr].g = *data++;
+		_portraitPalette.colors[palNr].r = *data++;
+		_portraitPalette.colors[palNr].used = 1;
+		_portraitPalette.intensity[palNr] = 100;
+		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
 }
 
+void Portrait::draw(Common::Point position) {
+	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++]);
+		}
+	}
+
+	Common::Rect mainBitmap = Common::Rect(_width, _height);
+	mainBitmap.moveTo(position.x, position.y);
+	_screen->copyDisplayRectToScreen(mainBitmap);
+}
+
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/graphics/portrait.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/portrait.h	2010-01-07 10:22:31 UTC (rev 47104)
+++ scummvm/trunk/engines/sci/graphics/portrait.h	2010-01-07 10:31:29 UTC (rev 47105)
@@ -33,6 +33,8 @@
 	Portrait(ResourceManager *resMan, Screen *screen, SciPalette *palette, Common::String resourceName);
 	~Portrait();
 
+	void draw(Common::Point position);
+
 private:
 	void init();
 
@@ -41,7 +43,17 @@
 	SciPalette *_palette;
 
 	Common::String _resourceName;
-	byte *_resourceData;
+	Common::String _fileName;
+	byte *_fileData;
+	int32 _fileSize;
+
+	uint16 _height;
+	uint16 _width;
+	uint16 _animationCount;
+	uint16 _portraitPaletteSize;
+	Palette _portraitPalette;
+
+	byte *_mainBitmapData;
 };
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/graphics/screen.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/screen.cpp	2010-01-07 10:22:31 UTC (rev 47104)
+++ scummvm/trunk/engines/sci/graphics/screen.cpp	2010-01-07 10:31:29 UTC (rev 47105)
@@ -106,6 +106,13 @@
 	}
 }
 
+// This copies a rect to screen w/o scaling adjustment and is only meant to be used on hires graphics used in upscaled hires mode
+void Screen::copyDisplayRectToScreen(const Common::Rect &rect) {
+	if (!_upscaledHires)
+		error("copyDisplayRectToScreen: not in upscaled hires mode");
+	g_system->copyRectToScreen(_activeScreen + rect.top * _displayWidth + rect.left, _displayWidth, rect.left, rect.top, rect.width(), rect.height());
+}
+
 void Screen::copyRectToScreen(const Common::Rect &rect, int16 x, int16 y) {
 	if (!_upscaledHires)  {
 		g_system->copyRectToScreen(_activeScreen + rect.top * _displayWidth + rect.left, _displayWidth, x, y, rect.width(), rect.height());

Modified: scummvm/trunk/engines/sci/graphics/screen.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/screen.h	2010-01-07 10:22:31 UTC (rev 47104)
+++ scummvm/trunk/engines/sci/graphics/screen.h	2010-01-07 10:31:29 UTC (rev 47105)
@@ -57,6 +57,7 @@
 	void copyFromScreen(byte *buffer);
 	void syncWithFramebuffer();
 	void copyRectToScreen(const Common::Rect &rect);
+	void copyDisplayRectToScreen(const Common::Rect &rect);
 	void copyRectToScreen(const Common::Rect &rect, int16 x, int16 y);
 
 	byte getDrawingMask(byte color, byte prio, byte control);


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