[Scummvm-cvs-logs] scummvm master -> 69e7e117433904737c9c399c09b1c9e87394b500

lordhoto lordhoto at gmail.com
Sun Feb 26 01:41:42 CET 2012


This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
83ce8da935 IPHONE: Implement 16bpp color support.
3b1e4b5bdc IPHONE: Let hi-color games directly draw onto the screen texture buffer.
69ab2a5279 IPHONE: Enable 16bpp support in configure.
7be7ef5a71 IPHONE: Update default build settings. (Disable scalers, mt32, timidity).
69e7e11743 NEWS: Mention iPhone's AR and 16bpp support.


Commit: 83ce8da9359d0f015165d8e75c37776a7a49474e
    https://github.com/scummvm/scummvm/commit/83ce8da9359d0f015165d8e75c37776a7a49474e
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-25T16:01:19-08:00

Commit Message:
IPHONE: Implement 16bpp color support.

This feature is currently disabled by default.

Changed paths:
    backends/platform/iphone/osys_main.cpp
    backends/platform/iphone/osys_main.h
    backends/platform/iphone/osys_video.mm



diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index 790e192..0f63a13 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -55,8 +55,7 @@ SoundProc OSystem_IPHONE::s_soundCallback = NULL;
 void *OSystem_IPHONE::s_soundParam = NULL;
 
 OSystem_IPHONE::OSystem_IPHONE() :
-	_mixer(NULL),
-	_mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0),
+	_mixer(NULL), _lastMouseTap(0), _queuedEventTime(0),
 	_mouseNeedTextureUpdate(false), _secondaryTapped(false), _lastSecondaryTap(0),
 	_screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false),
 	_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false),
@@ -73,6 +72,7 @@ OSystem_IPHONE::~OSystem_IPHONE() {
 
 	delete _mixer;
 	_framebuffer.free();
+	_mouseBuffer.free();
 }
 
 int OSystem_IPHONE::timerHandler(int t) {
diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h
index 675fc96..5d0f60c 100644
--- a/backends/platform/iphone/osys_main.h
+++ b/backends/platform/iphone/osys_main.h
@@ -75,10 +75,11 @@ protected:
 
 	bool _mouseCursorPaletteEnabled;
 	uint16 _mouseCursorPalette[256];
-	byte *_mouseBuf;
-	byte _mouseKeyColor;
+	Graphics::Surface _mouseBuffer;
+	uint16 _mouseKeyColor;
 	bool _mouseDirty;
 	bool _mouseNeedTextureUpdate;
+
 	long _lastMouseDown;
 	long _lastMouseTap;
 	long _queuedEventTime;
@@ -127,6 +128,11 @@ public:
 	virtual int16 getHeight();
 	virtual int16 getWidth();
 
+#ifdef USE_RGB_COLOR
+	virtual Graphics::PixelFormat getScreenFormat() const { return _framebuffer.format; }
+	virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const;
+#endif
+
 	virtual PaletteManager *getPaletteManager() { return this; }
 protected:
 	// PaletteManager API
diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm
index 080b476..258b183 100644
--- a/backends/platform/iphone/osys_video.mm
+++ b/backends/platform/iphone/osys_video.mm
@@ -24,9 +24,10 @@
 #define FORBIDDEN_SYMBOL_ALLOW_ALL
 
 #include "osys_main.h"
-
 #include "iphone_video.h"
 
+#include "graphics/conversion.h"
+
 void OSystem_IPHONE::initVideoContext() {
 	_videoContext = [g_iPhoneViewInstance getVideoContext];
 }
@@ -55,14 +56,35 @@ int OSystem_IPHONE::getGraphicsMode() const {
 	return _videoContext->graphicsMode;
 }
 
+#ifdef USE_RGB_COLOR
+Common::List<Graphics::PixelFormat> OSystem_IPHONE::getSupportedFormats() const {
+	Common::List<Graphics::PixelFormat> list;
+	// RGB565
+	list.push_back(Graphics::createPixelFormat<565>());
+	// CLUT8
+	list.push_back(Graphics::PixelFormat::createFormatCLUT8());
+	return list;
+}
+#endif
+
 void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) {
-	//printf("initSize(%i, %i)\n", width, height);
+	//printf("initSize(%u, %u, %p)\n", width, height, (const void *)format);
 
 	_videoContext->screenWidth = width;
 	_videoContext->screenHeight = height;
 	_videoContext->shakeOffsetY = 0;
 
-	_framebuffer.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+	if (!format || format->bytesPerPixel == 1) {
+		_framebuffer.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+	} else {
+#if 0
+		printf("bytesPerPixel: %u RGBAlosses: %u,%u,%u,%u RGBAshifts: %u,%u,%u,%u\n", format->bytesPerPixel,
+		       format->rLoss, format->gLoss, format->bLoss, format->aLoss,
+		       format->rShift, format->gShift, format->bShift, format->aShift);
+#endif
+		assert(Graphics::createPixelFormat<565>() == *format);
+		_framebuffer.create(width, height, *format);
+	}
 
 	_fullScreenIsDirty = false;
 	dirtyFullScreen();
@@ -146,13 +168,12 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y,
 		_dirtyRects.push_back(Common::Rect(x, y, x + w, y + h));
 	}
 
-
 	byte *dst = (byte *)_framebuffer.getBasePtr(x, y);
-	if (_framebuffer.pitch == pitch && pitch == w)
-		memcpy(dst, buf, h * w);
-	else {
+	if (_framebuffer.pitch == pitch && _framebuffer.w == w) {
+		memcpy(dst, buf, h * pitch);
+	} else {
 		do {
-			memcpy(dst, buf, w);
+			memcpy(dst, buf, w * _framebuffer.format.bytesPerPixel);
 			buf += pitch;
 			dst += _framebuffer.pitch;
 		} while (--h);
@@ -206,13 +227,23 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) {
 
 	const byte *src = (const byte *)_framebuffer.getBasePtr(dirtyRect.left, dirtyRect.top);
 	byte *dstRaw = (byte *)_videoContext->screenTexture.getBasePtr(dirtyRect.left, dirtyRect.top);
-	for (int y = h; y > 0; y--) {
-		uint16 *dst = (uint16 *)dstRaw;
-		for (int x = w; x > 0; x--)
-			*dst++ = _gamePalette[*src++];
 
-		dstRaw += _videoContext->screenTexture.pitch;
-		src += _framebuffer.pitch - w;
+	if (_framebuffer.format.bytesPerPixel == 1) {
+		// When we use CLUT8 do a color look up
+		for (int y = h; y > 0; y--) {
+			uint16 *dst = (uint16 *)dstRaw;
+			for (int x = w; x > 0; x--)
+				*dst++ = _gamePalette[*src++];
+
+			dstRaw += _videoContext->screenTexture.pitch;
+			src += _framebuffer.pitch - w;
+		}
+	} else {
+		do {
+			memcpy(dstRaw, src, w * _framebuffer.format.bytesPerPixel);
+			dstRaw += _videoContext->screenTexture.pitch;
+			src += _framebuffer.pitch;
+		} while (--h);
 	}
 }
 
@@ -350,13 +381,16 @@ void OSystem_IPHONE::dirtyFullOverlayScreen() {
 void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) {
 	//printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale);
 
-	if (_mouseBuf != NULL && (_videoContext->mouseWidth != w || _videoContext->mouseHeight != h)) {
-		free(_mouseBuf);
-		_mouseBuf = NULL;
-	}
+	const Graphics::PixelFormat pixelFormat = format ? *format : Graphics::PixelFormat::createFormatCLUT8();
+#if 0
+	printf("bytesPerPixel: %u RGBAlosses: %u,%u,%u,%u RGBAshifts: %u,%u,%u,%u\n", pixelFormat.bytesPerPixel,
+	       pixelFormat.rLoss, pixelFormat.gLoss, pixelFormat.bLoss, pixelFormat.aLoss,
+	       pixelFormat.rShift, pixelFormat.gShift, pixelFormat.bShift, pixelFormat.aShift);
+#endif
+	assert(pixelFormat.bytesPerPixel == 1 || pixelFormat.bytesPerPixel == 2);
 
-	if (_mouseBuf == NULL)
-		_mouseBuf = (byte *)malloc(w * h);
+	if (_mouseBuffer.w != w || _mouseBuffer.h != h || _mouseBuffer.format != pixelFormat || !_mouseBuffer.pixels)
+		_mouseBuffer.create(w, h, pixelFormat);
 
 	_videoContext->mouseWidth = w;
 	_videoContext->mouseHeight = h;
@@ -364,9 +398,9 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot
 	_videoContext->mouseHotspotX = hotspotX;
 	_videoContext->mouseHotspotY = hotspotY;
 
-	_mouseKeyColor = (byte)keycolor;
+	_mouseKeyColor = keycolor;
 
-	memcpy(_mouseBuf, buf, w * h);
+	memcpy(_mouseBuffer.getBasePtr(0, 0), buf, h * _mouseBuffer.pitch);
 
 	_mouseDirty = true;
 	_mouseNeedTextureUpdate = true;
@@ -394,20 +428,45 @@ void OSystem_IPHONE::updateMouseTexture() {
 	if (mouseTexture.w != texWidth || mouseTexture.h != texHeight)
 		mouseTexture.create(texWidth, texHeight, Graphics::createPixelFormat<5551>());
 
-	const uint16 *palette;
-	if (_mouseCursorPaletteEnabled)
-		palette = _mouseCursorPalette;
-	else
-		palette = _gamePaletteRGBA5551;
-
-	uint16 *mouseBuf = (uint16 *)mouseTexture.getBasePtr(0, 0);
-	for (uint x = 0; x < _videoContext->mouseWidth; ++x) {
-		for (uint y = 0; y < _videoContext->mouseHeight; ++y) {
-			const byte color = _mouseBuf[y * _videoContext->mouseWidth + x];
-			if (color != _mouseKeyColor)
-				mouseBuf[y * texWidth + x] = palette[color] | 0x1;
-			else
-				mouseBuf[y * texWidth + x] = 0x0;
+	if (_mouseBuffer.format.bytesPerPixel == 1) {
+		const uint16 *palette;
+		if (_mouseCursorPaletteEnabled)
+			palette = _mouseCursorPalette;
+		else
+			palette = _gamePaletteRGBA5551;
+
+		uint16 *mouseBuf = (uint16 *)mouseTexture.getBasePtr(0, 0);
+		for (uint x = 0; x < _videoContext->mouseWidth; ++x) {
+			for (uint y = 0; y < _videoContext->mouseHeight; ++y) {
+				const byte color = *(const byte *)_mouseBuffer.getBasePtr(x, y);
+				if (color != _mouseKeyColor)
+					mouseBuf[y * texWidth + x] = palette[color] | 0x1;
+				else
+					mouseBuf[y * texWidth + x] = 0x0;
+			}
+		}
+	} else {
+		if (crossBlit((byte *)mouseTexture.getBasePtr(0, 0), (const byte *)_mouseBuffer.getBasePtr(0, 0), mouseTexture.pitch,
+			          _mouseBuffer.pitch, _mouseBuffer.w, _mouseBuffer.h, mouseTexture.format, _mouseBuffer.format)) {
+			if (!_mouseBuffer.format.aBits()) {
+				// Apply color keying since the original cursor had no alpha channel.
+				const uint16 *src = (const uint16 *)_mouseBuffer.getBasePtr(0, 0);
+				uint8 *dstRaw = (uint8 *)mouseTexture.getBasePtr(0, 0);
+
+				for (uint y = 0; y < _mouseBuffer.h; ++y, dstRaw += mouseTexture.pitch) {
+					uint16 *dst = (uint16 *)dstRaw;
+					for (uint x = 0; x < _mouseBuffer.w; ++x, ++dst) {
+						if (*src++ == _mouseKeyColor)
+							*dst &= ~1;
+						else
+							*dst |= 1;
+					}
+				}
+			}
+		} else {
+			// TODO: Log this!
+			// Make the cursor all transparent... we really need a better fallback ;-).
+			memset(mouseTexture.getBasePtr(0, 0), 0, mouseTexture.h * mouseTexture.pitch);
 		}
 	}
 


Commit: 3b1e4b5bdcdd67db03c6d225c0a7985d8ce35d3b
    https://github.com/scummvm/scummvm/commit/3b1e4b5bdcdd67db03c6d225c0a7985d8ce35d3b
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-25T16:25:18-08:00

Commit Message:
IPHONE: Let hi-color games directly draw onto the screen texture buffer.

This avoids an unecessary copying step from the framebuffer to the texture
buffer.

Changed paths:
    backends/platform/iphone/iphone_video.h
    backends/platform/iphone/iphone_video.mm
    backends/platform/iphone/osys_main.cpp
    backends/platform/iphone/osys_video.mm



diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h
index 168f9a4..55a4acb 100644
--- a/backends/platform/iphone/iphone_video.h
+++ b/backends/platform/iphone/iphone_video.h
@@ -75,6 +75,7 @@
 
 - (void)drawRect:(CGRect)frame;
 
+- (void)createScreenTexture;
 - (void)initSurface;
 - (void)setViewTransformation;
 
diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm
index 0ddb90b..04aaf59 100644
--- a/backends/platform/iphone/iphone_video.mm
+++ b/backends/platform/iphone/iphone_video.mm
@@ -443,13 +443,17 @@ const char *iPhone_getDocumentsDir() {
 	}
 }
 
-- (void)initSurface {
-	uint screenTexWidth = getSizeNextPOT(_videoContext.screenWidth);
-	uint screenTexHeight = getSizeNextPOT(_videoContext.screenHeight);
+- (void)createScreenTexture {
+	const uint screenTexWidth = getSizeNextPOT(_videoContext.screenWidth);
+	const uint screenTexHeight = getSizeNextPOT(_videoContext.screenHeight);
 
 	_gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _videoContext.screenWidth / (GLfloat)screenTexWidth;
 	_gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _videoContext.screenHeight / (GLfloat)screenTexHeight;
 
+	_videoContext.screenTexture.create(screenTexWidth, screenTexHeight, Graphics::createPixelFormat<565>());
+}
+
+- (void)initSurface {
 	int screenWidth, screenHeight;
 	[self setUpOrientation:[[UIDevice currentDevice] orientation] width:&screenWidth height:&screenHeight];
 
@@ -467,8 +471,6 @@ const char *iPhone_getDocumentsDir() {
 	glGenTextures(1, &_overlayTexture); printOpenGLError();
 	[self setFilterModeForTexture:_overlayTexture];
 
-	_videoContext.screenTexture.create(screenTexWidth, screenTexHeight, Graphics::createPixelFormat<565>());
-
 	glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError();
 
 	[self clearColorBuffer];
diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index 0f63a13..f3e0d97 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -71,7 +71,11 @@ OSystem_IPHONE::~OSystem_IPHONE() {
 	AudioQueueDispose(s_AudioQueue.queue, true);
 
 	delete _mixer;
-	_framebuffer.free();
+	// Prevent accidental freeing of the screen texture here. This needs to be
+	// checked since we might use the screen texture as framebuffer in the case
+	// of hi-color games for example.
+	if (_framebuffer.pixels == _videoContext->screenTexture.pixels)
+		_framebuffer.free();
 	_mouseBuffer.free();
 }
 
diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm
index 258b183..2b5e78b 100644
--- a/backends/platform/iphone/osys_video.mm
+++ b/backends/platform/iphone/osys_video.mm
@@ -74,6 +74,16 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm
 	_videoContext->screenHeight = height;
 	_videoContext->shakeOffsetY = 0;
 
+	// In case we use the screen texture as frame buffer we reset the pixels
+	// pointer here to avoid freeing the screen texture.
+	if (_framebuffer.pixels == _videoContext->screenTexture.pixels)
+		_framebuffer.pixels = 0;
+
+	// Create the screen texture right here. We need to do this here, since
+	// when a game requests hi-color mode, we actually set the framebuffer
+	// to the texture buffer to avoid an additional copy step.
+	[g_iPhoneViewInstance performSelectorOnMainThread:@selector(createScreenTexture) withObject:nil waitUntilDone: YES];
+
 	if (!format || format->bytesPerPixel == 1) {
 		_framebuffer.create(width, height, Graphics::PixelFormat::createFormatCLUT8());
 	} else {
@@ -82,8 +92,13 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm
 		       format->rLoss, format->gLoss, format->bLoss, format->aLoss,
 		       format->rShift, format->gShift, format->bShift, format->aShift);
 #endif
-		assert(Graphics::createPixelFormat<565>() == *format);
-		_framebuffer.create(width, height, *format);
+		assert(_videoContext->screenTexture.format == *format);
+		// We directly draw on the screen texture in hi-color mode. Thus
+		// we copy over its settings here and just replace the width and
+		// height to avoid any problems.
+		_framebuffer = _videoContext->screenTexture;
+		_framebuffer.w = width;
+		_framebuffer.h = height;
 	}
 
 	_fullScreenIsDirty = false;
@@ -222,28 +237,24 @@ void OSystem_IPHONE::internUpdateScreen() {
 }
 
 void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) {
+	// We only need to do a color look up for CLUT8
+	if (_framebuffer.format.bytesPerPixel != 1)
+		return;
+
 	int h = dirtyRect.bottom - dirtyRect.top;
 	int w = dirtyRect.right - dirtyRect.left;
 
 	const byte *src = (const byte *)_framebuffer.getBasePtr(dirtyRect.left, dirtyRect.top);
 	byte *dstRaw = (byte *)_videoContext->screenTexture.getBasePtr(dirtyRect.left, dirtyRect.top);
 
-	if (_framebuffer.format.bytesPerPixel == 1) {
-		// When we use CLUT8 do a color look up
-		for (int y = h; y > 0; y--) {
-			uint16 *dst = (uint16 *)dstRaw;
-			for (int x = w; x > 0; x--)
-				*dst++ = _gamePalette[*src++];
+	// When we use CLUT8 do a color look up
+	for (int y = h; y > 0; y--) {
+		uint16 *dst = (uint16 *)dstRaw;
+		for (int x = w; x > 0; x--)
+			*dst++ = _gamePalette[*src++];
 
-			dstRaw += _videoContext->screenTexture.pitch;
-			src += _framebuffer.pitch - w;
-		}
-	} else {
-		do {
-			memcpy(dstRaw, src, w * _framebuffer.format.bytesPerPixel);
-			dstRaw += _videoContext->screenTexture.pitch;
-			src += _framebuffer.pitch;
-		} while (--h);
+		dstRaw += _videoContext->screenTexture.pitch;
+		src += _framebuffer.pitch - w;
 	}
 }
 


Commit: 69ab2a5279922179a4344f616fe83d9b66ec38c4
    https://github.com/scummvm/scummvm/commit/69ab2a5279922179a4344f616fe83d9b66ec38c4
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-25T16:29:56-08:00

Commit Message:
IPHONE: Enable 16bpp support in configure.

Changed paths:
    configure



diff --git a/configure b/configure
index 27f56da..ce88a23 100755
--- a/configure
+++ b/configure
@@ -2756,7 +2756,7 @@ esac
 # Enable 16bit support only for backends which support it
 #
 case $_backend in
-	android | bada | dingux | dreamcast | gph | maemo | openpandora | psp | samsungtv | sdl | webos | wii)
+	android | bada | dingux | dreamcast | gph | iphone | maemo | openpandora | psp | samsungtv | sdl | webos | wii)
 		if test "$_16bit" = auto ; then
 			_16bit=yes
 		else


Commit: 7be7ef5a71daca9e85daaa07b42b619e6cdefb3f
    https://github.com/scummvm/scummvm/commit/7be7ef5a71daca9e85daaa07b42b619e6cdefb3f
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-25T16:31:22-08:00

Commit Message:
IPHONE: Update default build settings. (Disable scalers, mt32, timidity).

I took the freedom of also removing the unused OBJCFLAGS flag with this.

Changed paths:
    configure



diff --git a/configure b/configure
index ce88a23..7cb3987 100755
--- a/configure
+++ b/configure
@@ -2366,8 +2366,10 @@ if test -n "$_host"; then
 		iphone)
 			DEFINES="$DEFINES -DIPHONE"
 			_backend="iphone"
-			_build_hq_scalers=no
+			_build_scalers=no
+			_mt32emu=no
 			_seq_midi=no
+			_timidity=no
 			;;
 		m68k-atari-mint)
 			DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE"
@@ -2639,7 +2641,6 @@ case $_backend in
 	gph)
 		;;
 	iphone)
-		OBJCFLAGS="$OBJCFLAGS --std=c99"
 		LIBS="$LIBS -lobjc -framework UIKit -framework CoreGraphics -framework OpenGLES"
 		LIBS="$LIBS -framework QuartzCore -framework GraphicsServices -framework CoreFoundation"
 		LIBS="$LIBS -framework Foundation -framework AudioToolbox -framework CoreAudio"


Commit: 69e7e117433904737c9c399c09b1c9e87394b500
    https://github.com/scummvm/scummvm/commit/69e7e117433904737c9c399c09b1c9e87394b500
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2012-02-25T16:33:47-08:00

Commit Message:
NEWS: Mention iPhone's AR and 16bpp support.

Changed paths:
    NEWS



diff --git a/NEWS b/NEWS
index 8ce6709..7f40704 100644
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,8 @@ For a more comprehensive changelog of the latest experimental code, see:
    - Changed "F5 (menu)" gesture to open up the global main menu instead.
    - Added support for custom cursor palettes, this makes the moderm theme use
      the red pointer cursor for example.
+   - Added aspect ratio correction feature.
+   - Implemented 16 bits per pixel support for games.
 
  Windows port:
    - Changed default savegames location for Windows NT4/2000/XP/Vista/7.






More information about the Scummvm-git-logs mailing list