[Scummvm-cvs-logs] SF.net SVN: scummvm:[43631] scummvm/trunk

dhewg at users.sourceforge.net dhewg at users.sourceforge.net
Sat Aug 22 10:49:23 CEST 2009


Revision: 43631
          http://scummvm.svn.sourceforge.net/scummvm/?rev=43631&view=rev
Author:   dhewg
Date:     2009-08-22 08:49:23 +0000 (Sat, 22 Aug 2009)

Log Message:
-----------
16bit support for the Wii port

Modified Paths:
--------------
    scummvm/trunk/backends/platform/wii/osystem.cpp
    scummvm/trunk/backends/platform/wii/osystem.h
    scummvm/trunk/backends/platform/wii/osystem_gfx.cpp
    scummvm/trunk/configure

Modified: scummvm/trunk/backends/platform/wii/osystem.cpp
===================================================================
--- scummvm/trunk/backends/platform/wii/osystem.cpp	2009-08-22 07:18:15 UTC (rev 43630)
+++ scummvm/trunk/backends/platform/wii/osystem.cpp	2009-08-22 08:49:23 UTC (rev 43631)
@@ -52,6 +52,11 @@
 	_currentHeight(0),
 
 	_activeGraphicsMode(0),
+#ifdef USE_RGB_COLOR
+	_texturePF(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)),
+	_screenPF(Graphics::PixelFormat::createFormatCLUT8()),
+	_cursorPF(Graphics::PixelFormat::createFormatCLUT8()),
+#endif
 
 	_fullscreen(false),
 

Modified: scummvm/trunk/backends/platform/wii/osystem.h
===================================================================
--- scummvm/trunk/backends/platform/wii/osystem.h	2009-08-22 07:18:15 UTC (rev 43630)
+++ scummvm/trunk/backends/platform/wii/osystem.h	2009-08-22 08:49:23 UTC (rev 43631)
@@ -75,6 +75,11 @@
 	u16 _currentWidth, _currentHeight;
 
 	s32 _activeGraphicsMode;
+#ifdef USE_RGB_COLOR
+	const Graphics::PixelFormat _texturePF;
+	Graphics::PixelFormat _screenPF;
+	Graphics::PixelFormat _cursorPF;
+#endif
 
 	bool _fullscreen;
 
@@ -82,7 +87,7 @@
 	s32 _mouseX, _mouseY;
 	u32 _mouseWidth, _mouseHeight;
 	s32 _mouseHotspotX, _mouseHotspotY;
-	u8 _mouseKeyColor;
+	u16 _mouseKeyColor;
 	u8 *_mouseCursor;
 
 	bool _kbd_active;
@@ -119,6 +124,10 @@
 	virtual const GraphicsMode *getSupportedGraphicsModes() const;
 	virtual int getDefaultGraphicsMode() const;
 	virtual bool setGraphicsMode(int mode);
+#ifdef USE_RGB_COLOR
+	virtual Graphics::PixelFormat getScreenFormat() const;
+	virtual Common::List<Graphics::PixelFormat> getSupportedFormats();
+#endif
 	virtual int getGraphicsMode() const;
 	virtual void initSize(uint width, uint height,
 							const Graphics::PixelFormat *format);

Modified: scummvm/trunk/backends/platform/wii/osystem_gfx.cpp
===================================================================
--- scummvm/trunk/backends/platform/wii/osystem_gfx.cpp	2009-08-22 07:18:15 UTC (rev 43630)
+++ scummvm/trunk/backends/platform/wii/osystem_gfx.cpp	2009-08-22 08:49:23 UTC (rev 43631)
@@ -21,6 +21,8 @@
 
 #include <malloc.h>
 
+#include "graphics/conversion.h"
+
 #include "osystem.h"
 #include "gx_supp.h"
 
@@ -143,22 +145,72 @@
 	return _activeGraphicsMode;
 }
 
+#ifdef USE_RGB_COLOR
+Graphics::PixelFormat OSystem_Wii::getScreenFormat() const {
+	return _screenPF;
+}
+
+Common::List<Graphics::PixelFormat> OSystem_Wii::getSupportedFormats() {
+	Common::List<Graphics::PixelFormat> res;
+	res.push_back(_texturePF);
+	res.push_back(Graphics::PixelFormat::createFormatCLUT8());
+
+	return res;
+}
+#endif
+
 void OSystem_Wii::initSize(uint width, uint height,
 							const Graphics::PixelFormat *format) {
+	bool update = false;
+
+#ifdef USE_RGB_COLOR
+	Graphics::PixelFormat newFormat;
+	if (format)
+		newFormat = *format;
+	else
+		newFormat = Graphics::PixelFormat::createFormatCLUT8();
+
+	if (newFormat.bytesPerPixel > 2)
+		newFormat = Graphics::PixelFormat::createFormatCLUT8();
+
+	if (_screenPF != newFormat) {
+		_screenPF = newFormat;
+		update = true;
+	}
+#endif
+
 	if (_gameWidth != width || _gameHeight != height) {
-		printf("initSize %u %u\n", width, height);
-
 		assert((width <= 640) && (height <= 480));
 
 		_gameWidth = width;
 		_gameHeight = height;
+		update = true;
+	}
 
+	if (update) {
+#ifdef USE_RGB_COLOR
+		printf("initSize %u*%u*%u (%u,%u,%u)\n",
+				_gameWidth, _gameHeight,
+				_screenPF.bytesPerPixel * 8,
+				_screenPF.rShift, _screenPF.gShift, _screenPF.bShift);
+#else
+		printf("initSize %u*%u\n", _gameWidth, _gameHeight);
+#endif
+
 		if(_gamePixels)
 			free(_gamePixels);
 
+		size_t bufsize;
+
+#ifdef USE_RGB_COLOR
+		_gamePixels = (u8 *) memalign(32, _gameWidth * _gameHeight *
+										_screenPF.bytesPerPixel);
+		memset(_gamePixels, 0, _gameWidth * _gameHeight *
+				_screenPF.bytesPerPixel);
+#else
 		_gamePixels = (u8 *) memalign(32, _gameWidth * _gameHeight);
 		memset(_gamePixels, 0, _gameWidth * _gameHeight);
-
+#endif
 		if (!_overlayVisible) {
 			_currentWidth = _gameWidth;
 			_currentHeight = _gameHeight;
@@ -178,6 +230,10 @@
 }
 
 void OSystem_Wii::setPalette(const byte *colors, uint start, uint num) {
+#ifdef USE_RGB_COLOR
+	assert(_screenPF.bytesPerPixel == 1);
+#endif
+
 	const byte *p = colors;
 	for (uint i = 0; i < num; ++i) {
 		_palette[start + i] = Graphics::RGBToColor<Graphics::ColorMasks<565> >(p[0], p[1], p[2]);
@@ -214,37 +270,36 @@
 
 void OSystem_Wii::copyRectToScreen(const byte *buf, int pitch, int x, int y,
 									int w, int h) {
-	if (x < 0) {
-		w += x;
-		buf -= x;
-		x = 0;
-	}
+	assert(x >= 0 && x < _gameWidth);
+	assert(y >= 0 && y < _gameHeight);
+	assert(w > 0 && x + w <= _gameWidth);
+	assert(h > 0 && y + h <= _gameHeight);
 
-	if (y < 0) {
-		h += y;
-		buf -= y * pitch;
-		y = 0;
-	}
-
-	if (w > _gameWidth - x)
-		w = _gameWidth - x;
-
-	if (h > _gameHeight - y)
-		h = _gameHeight - y;
-
-	if (w <= 0 || h <= 0)
-		return;
-
-	byte *dst = _gamePixels + y * _gameWidth + x;
-	if (_gameWidth == pitch && pitch == w) {
-		memcpy(dst, buf, h * w);
+#ifdef USE_RGB_COLOR
+	if (_screenPF.bytesPerPixel > 1) {
+		if (!Graphics::crossBlit(_gamePixels +
+									y * _gameWidth * _screenPF.bytesPerPixel +
+									x * _screenPF.bytesPerPixel,
+									buf, _gameWidth * _screenPF.bytesPerPixel,
+									pitch, w, h, _texturePF, _screenPF)) {
+			printf("crossBlit failed\n");
+			::abort();
+		}
 	} else {
-		do {
-			memcpy(dst, buf, w);
-			buf += pitch;
-			dst += _gameWidth;
-		} while (--h);
+#endif
+		byte *dst = _gamePixels + y * _gameWidth + x;
+		if (_gameWidth == pitch && pitch == w) {
+			memcpy(dst, buf, h * w);
+		} else {
+			do {
+				memcpy(dst, buf, w);
+				buf += pitch;
+				dst += _gameWidth;
+			} while (--h);
+		}
+#ifdef USE_RGB_COLOR
 	}
+#endif
 }
 
 void OSystem_Wii::updateScreen() {
@@ -252,6 +307,9 @@
 	static s16 msx, msy, mox, moy, mskip;
 	static u16 mpx, mpy;
 	static u8 *s;
+#ifdef USE_RGB_COLOR
+	static u16 *s2;
+#endif
 	static u16 *d, *p;
 
 	u32 now = getMillis();
@@ -268,12 +326,21 @@
 	if (_overlayVisible) {
 		memcpy(_texture, _overlayPixels, _overlaySize);
 	} else {
-		for (y = 0; y < _gameHeight; ++y) {
-			for (x = 0; x < _gameWidth; ++x)
-				_texture[h + x] = _palette[_gamePixels[h + x]];
+#ifdef USE_RGB_COLOR
+		if (_screenPF.bytesPerPixel > 1) {
+			memcpy(_texture, _gamePixels,
+					_gameWidth * _gameHeight * _screenPF.bytesPerPixel);
+		} else {
+#endif
+			for (y = 0; y < _gameHeight; ++y) {
+				for (x = 0; x < _gameWidth; ++x)
+					_texture[h + x] = _palette[_gamePixels[h + x]];
 
-			h += _gameWidth;
+				h += _gameWidth;
+			}
+#ifdef USE_RGB_COLOR
 		}
+#endif
 	}
 
 	if (_mouseVisible) {
@@ -309,25 +376,51 @@
 		skip = _currentWidth - mpx;
 		mskip = _mouseWidth - mpx;
 
-		s = _mouseCursor + moy * _mouseWidth + mox;
-		d = _texture + (msy * _currentWidth + msx);
+#ifdef USE_RGB_COLOR
+		if (_cursorPF.bytesPerPixel > 1) {
+			s2 = (u16 *) _mouseCursor + moy * _mouseWidth + mox;
+			d = _texture + (msy * _currentWidth + msx);
 
-		for (y = 0; y < mpy; ++y) {
-			for (x = 0; x < mpx; ++x) {
-				if (*s == _mouseKeyColor) {
-					s++;
-					d++;
+			for (y = 0; y < mpy; ++y) {
+				for (x = 0; x < mpx; ++x) {
+					if (*s2 == _mouseKeyColor) {
+						s2++;
+						d++;
 
-					continue;
+						continue;
+					}
+
+					*d++ = *s2;
+					s2++;
 				}
 
-				*d++ = p[*s];
-				s++;
+				d += skip;
+				s2 += mskip;
 			}
+		} else {
+#endif
+			s = _mouseCursor + moy * _mouseWidth + mox;
+			d = _texture + (msy * _currentWidth + msx);
 
-			d += skip;
-			s += mskip;
+			for (y = 0; y < mpy; ++y) {
+				for (x = 0; x < mpx; ++x) {
+					if (*s == _mouseKeyColor) {
+						s++;
+						d++;
+
+						continue;
+					}
+
+					*d++ = p[*s];
+					s++;
+				}
+
+				d += skip;
+				s += mskip;
+			}
+#ifdef USE_RGB_COLOR
 		}
+#endif
 	}
 
 	GX_Render(_currentWidth, _currentHeight, (u8 *) _texture,
@@ -339,7 +432,11 @@
 	_surface.w = _gameWidth;
 	_surface.h = _gameHeight;
 	_surface.pitch = _gameWidth;
+#ifdef USE_RGB_COLOR
+	_surface.bytesPerPixel = _screenPF.bytesPerPixel;
+#else
 	_surface.bytesPerPixel = 1;
+#endif
 
 	return &_surface;
 }
@@ -452,16 +549,32 @@
 									const Graphics::PixelFormat *format) {
 	(void) cursorTargetScale; // TODO
 
+#ifdef USE_RGB_COLOR
+	if (!format)
+		_cursorPF = Graphics::PixelFormat::createFormatCLUT8();
+	else
+		_cursorPF = *format;
+
+	if (_cursorPF.bytesPerPixel > 1)
+		_mouseKeyColor = keycolor & 0xffff;
+	else
+#endif
+		_mouseKeyColor = keycolor & 0xff;
+
 	_mouseWidth = w;
 	_mouseHeight = h;
 	_mouseHotspotX = hotspotX;
 	_mouseHotspotY = hotspotY;
-	_mouseKeyColor = keycolor & 0xff;
 
 	if (_mouseCursor)
 		free(_mouseCursor);
 
+#ifdef USE_RGB_COLOR
+	_mouseCursor = (u8 *) memalign(32, w * h * _cursorPF.bytesPerPixel);
+	memcpy(_mouseCursor, buf, w * h * _cursorPF.bytesPerPixel);
+#else
 	_mouseCursor = (u8 *) memalign(32, w * h);
 	memcpy(_mouseCursor, buf, w * h);
+#endif
 }
 

Modified: scummvm/trunk/configure
===================================================================
--- scummvm/trunk/configure	2009-08-22 07:18:15 UTC (rev 43630)
+++ scummvm/trunk/configure	2009-08-22 08:49:23 UTC (rev 43631)
@@ -1498,7 +1498,7 @@
 # Enable 16bit support only for backends which support it
 #
 case $_backend in
-	sdl)
+	sdl | wii)
 		if test "$_16bit" = auto ; then
 			_16bit=yes
 		else


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