[Scummvm-cvs-logs] SF.net SVN: scummvm: [23464] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Thu Jul 20 22:40:12 CEST 2006


Revision: 23464
          http://svn.sourceforge.net/scummvm/?rev=23464&view=rev
Author:   drmccoy
Date:     2006-07-09 11:54:12 -0700 (Sun, 09 Jul 2006)

Log Message:
-----------
Instead of drawing the mouse cursor as a sprite, let the backend handle it

Modified Paths:
--------------
    scummvm/trunk/engines/gob/draw.cpp
    scummvm/trunk/engines/gob/draw.h
    scummvm/trunk/engines/gob/draw_v1.cpp
    scummvm/trunk/engines/gob/draw_v2.cpp
    scummvm/trunk/engines/gob/game.cpp
    scummvm/trunk/engines/gob/game_v1.cpp
    scummvm/trunk/engines/gob/inter_v1.cpp
    scummvm/trunk/engines/gob/inter_v2.cpp
    scummvm/trunk/engines/gob/video.h
    scummvm/trunk/engines/gob/video_v1.cpp
    scummvm/trunk/engines/gob/video_v2.cpp

Modified: scummvm/trunk/engines/gob/draw.cpp
===================================================================
--- scummvm/trunk/engines/gob/draw.cpp	2006-07-09 18:30:28 UTC (rev 23463)
+++ scummvm/trunk/engines/gob/draw.cpp	2006-07-09 18:54:12 UTC (rev 23464)
@@ -117,10 +117,11 @@
 		_cursorAnimDelays[i] = 0;
 	}
 
+	_showCursor = 0;
 	_cursorIndex = 0;
 	_transparentCursor = 0;
 	_cursorSprites = 0;
-	_cursorBack = 0;
+	_scummvmCursor = 0;
 	_cursorAnim = 0;
 
 	_palLoadData1[0] = 0;
@@ -261,6 +262,7 @@
 		return;
 	}
 
+	_showCursor = (_showCursor & ~2) | ((_showCursor & 1) << 1);
 	if (_applyPal) {
 		clearPalette();
 

Modified: scummvm/trunk/engines/gob/draw.h
===================================================================
--- scummvm/trunk/engines/gob/draw.h	2006-07-09 18:30:28 UTC (rev 23463)
+++ scummvm/trunk/engines/gob/draw.h	2006-07-09 18:54:12 UTC (rev 23464)
@@ -87,6 +87,12 @@
 	Video::Color _vgaPalette[256];
 	Video::Color _vgaSmallPalette[16];
 
+	// 0 (00b): No cursor
+	// 1 (01b): Cursor would be on _backSurface
+	// 2 (10b): Cursor would be on _frontSurface
+	// 3 (11b): Cursor would be on _backSurface and _frontSurface
+	uint8 _showCursor;
+
 	int16 _cursorX;
 	int16 _cursorY;
 	int16 _cursorWidth;
@@ -97,7 +103,8 @@
 
 	Video::SurfaceDesc *_cursorSprites;
 	Video::SurfaceDesc *_cursorSpritesBack;
-	Video::SurfaceDesc *_cursorBack;
+	Video::SurfaceDesc *_scummvmCursor;
+
 	int16 _cursorAnim;
 	int8 _cursorAnimLow[40];
 	int8 _cursorAnimHigh[40];

Modified: scummvm/trunk/engines/gob/draw_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/draw_v1.cpp	2006-07-09 18:30:28 UTC (rev 23463)
+++ scummvm/trunk/engines/gob/draw_v1.cpp	2006-07-09 18:54:12 UTC (rev 23464)
@@ -23,6 +23,7 @@
 
 #include "common/stdafx.h"
 #include "common/endian.h"
+#include "graphics/cursorman.h"
 
 #include "gob/gob.h"
 #include "gob/draw.h"
@@ -492,20 +493,9 @@
 void Draw_v1::blitCursor(void) {
 	if (_cursorIndex == -1)
 		return;
-
-	_cursorIndex = -1;
-
-	if (_noInvalidated) {
-		_vm->_video->drawSprite(_backSurface, _frontSurface,
-		    _cursorX, _cursorY,
-		    _cursorX + _cursorWidth - 1,
-		    _cursorY + _cursorHeight - 1, _cursorX,
-		    _cursorY, 0);
-	} else {
-		invalidateRect(_cursorX, _cursorY,
-		    _cursorX + _cursorWidth - 1,
-		    _cursorY + _cursorHeight - 1);
-	}
+	
+	if (_showCursor == 2)
+		_showCursor = 0;
 }
 
 void Draw_v1::animateCursor(int16 cursor) {
@@ -518,6 +508,7 @@
 	int16 maxY;
 	int16 cursorIndex;
 
+	_showCursor = 2;
 	cursorIndex = cursor;
 
 	if (cursorIndex == -1) {
@@ -556,9 +547,11 @@
 				_cursorAnim++;
 				_cursorTimeKey = _vm->_util->getTimeKey();
 			} else {
-/*				if (_noInvalidated &&
-					inter_mouseX == _cursorX &&	inter_mouseY == _cursorY)
-						return;*/
+				if ((_noInvalidated != 0) && (_vm->_global->_inter_mouseX == _cursorX) &&
+						(_vm->_global->_inter_mouseY == _cursorY)) {
+					_vm->_video->waitRetrace(_vm->_global->_videoMode);
+					return;
+				}
 			}
 		} else {
 			_cursorIndex = cursorIndex;
@@ -589,33 +582,27 @@
 		minY = MIN(newY, _cursorY);
 		maxX = MAX(_cursorX, newX) + _cursorWidth - 1;
 		maxY = MAX(_cursorY, newY) + _cursorHeight - 1;
-		_vm->_video->drawSprite(_backSurface, _cursorBack,
-		    newX, newY, newX + _cursorWidth - 1,
-		    newY + _cursorHeight - 1, 0, 0, 0);
 
-		_vm->_video->drawSprite(_cursorSprites, _backSurface,
-		    _cursorWidth * _cursorAnim, 0,
-		    _cursorWidth * (_cursorAnim + 1) - 1,
-		    _cursorHeight - 1, newX, newY, _transparentCursor);
+		_vm->_video->drawSprite(_cursorSprites, _scummvmCursor, _cursorWidth * _cursorAnim,
+				0, _cursorWidth * (_cursorAnim + 1) - 1, _cursorHeight - 1, 0, 0, 0);
+		CursorMan.replaceCursor(_scummvmCursor->vidPtr, _cursorWidth, _cursorHeight, 0, 0, 0);
 
-		if (_noInvalidated == 0) {
-			cursorIndex = _cursorIndex;
-			_cursorIndex = -1;
-			blitInvalidated();
-			_cursorIndex = cursorIndex;
-		} else {
-			_vm->_video->waitRetrace(_vm->_global->_videoMode);
+		if (_frontSurface != _backSurface) {
+			_showCursor = 3;
+			if (_noInvalidated == 0) {
+				int16 tmp = _cursorIndex;
+				_cursorIndex = -1;
+				blitInvalidated();
+				_cursorIndex = tmp;
+			} else {
+				_vm->_video->waitRetrace(_vm->_global->_videoMode);
+				if (minY < 50)
+					_vm->_util->delay(5);
+				_showCursor = 0;
+			}
 		}
-
-		_vm->_video->drawSprite(_backSurface, _frontSurface,
-		    minX, minY, maxX, maxY, minX, minY, 0);
-
-		_vm->_video->drawSprite(_cursorBack, _backSurface,
-		    0, 0, _cursorWidth - 1, _cursorHeight - 1,
-		    newX, newY, 0);
-	} else {
+	} else
 		blitCursor();
-	}
 
 	_cursorX = newX;
 	_cursorY = newY;

Modified: scummvm/trunk/engines/gob/draw_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/draw_v2.cpp	2006-07-09 18:30:28 UTC (rev 23463)
+++ scummvm/trunk/engines/gob/draw_v2.cpp	2006-07-09 18:54:12 UTC (rev 23464)
@@ -23,6 +23,7 @@
 
 #include "common/stdafx.h"
 #include "common/endian.h"
+#include "graphics/cursorman.h"
 
 #include "gob/gob.h"
 #include "gob/draw.h"
@@ -877,27 +878,11 @@
 }
 
 void Draw_v2::blitCursor(void) {
-	int16 width;
-	int16 height;
-
 	if (_cursorIndex == -1)
 		return;
-
-	_cursorIndex = -1;
-	width = _cursorWidth;
-	height = _cursorHeight;
-	if(_backSurface->width < (_cursorX + _cursorWidth))
-		width -= _cursorX;
-	if(_backSurface->height < (_cursorY + _cursorHeight))
-		height -= _cursorY;
-	if (_frontSurface == _backSurface)
-		_vm->_video->drawSprite(_cursorBack, _frontSurface, 0, 0, width - 1, height - 1,
-				_cursorX, _cursorY, 0);
-	else if (_noInvalidated == 0)
-		invalidateRect(_cursorX, _cursorY, _cursorX + width - 1, _cursorY + height - 1);
-	else
-		_vm->_video->drawSprite(_backSurface, _frontSurface, _cursorX, _cursorY,
-				_cursorX + width - 1, _cursorY + height - 1, _cursorX, _cursorY, 0);
+	
+	if (_showCursor == 2)
+		_showCursor = 0;
 }
 
 void Draw_v2::animateCursor(int16 cursor) {
@@ -909,9 +894,8 @@
 	int16 maxX;
 	int16 maxY;
 	int16 cursorIndex;
-	bool oldCursor;
 
-	oldCursor = _cursorIndex != -1;
+	_showCursor |= 2;
 
 	if (((_backSurface->width - 9) < _vm->_global->_inter_mouseX) ||
 			((_backSurface->height - 4) < _vm->_global->_inter_mouseY)) {
@@ -968,6 +952,8 @@
 			} else {
 				if ((_noInvalidated != 0) && (_vm->_global->_inter_mouseX == _cursorX) &&
 						(_vm->_global->_inter_mouseY == _cursorY)) {
+					if (!CursorMan.isVisible())
+						_showCursor = 0;
 					_vm->_video->waitRetrace(_vm->_global->_videoMode);
 					return;
 				}
@@ -1000,26 +986,16 @@
 		minY = MIN(newY, _cursorY);
 		maxX = MAX(_cursorX, newX) + _cursorWidth - 1;
 		maxY = MAX(_cursorY, newY) + _cursorHeight - 1;
-		if (_frontSurface == _backSurface) { // loc_177C2
-			if ((newX != _cursorX) || (newY != _cursorY)) {
-				if (oldCursor)
-					_vm->_video->drawSprite(_cursorBack, _frontSurface, 0, 0,
-							_cursorWidth - 1, _cursorHeight - 1, _cursorX, _cursorY, 0);
-				_vm->_video->drawSprite(_frontSurface, _cursorBack, newX, newY,
-						newX + _cursorWidth - 1, newY + _cursorHeight - 1, 0, 0, 0);
-				_vm->_video->drawSprite(_cursorSprites, _frontSurface,
-						cursorIndex * _cursorWidth, 0,
-						(cursorIndex * _cursorWidth) + _cursorWidth - 1, _cursorHeight - 1,
-						newX, newY, _transparentCursor);
-			}
-		} else { // loc_1787D
-			_vm->_video->drawSprite(_backSurface, _cursorBack, newX, newY,
-					newX + _cursorWidth - 1, newY + _cursorHeight - 1, 0, 0, 0);
-			_vm->_video->drawSprite(_cursorSprites, _backSurface,
-					cursorIndex * _cursorWidth, 0,
-					(cursorIndex * _cursorWidth) + _cursorWidth - 1, _cursorHeight - 1,
-					newX, newY, _transparentCursor);
+
+		_vm->_video->clearSurf(_scummvmCursor);
+		_vm->_video->drawSprite(_cursorSprites, _scummvmCursor, cursorIndex * _cursorWidth,
+				0, (cursorIndex * _cursorWidth) + _cursorWidth - 1, _cursorHeight - 1, 0, 0, 0);
+		CursorMan.replaceCursor(_scummvmCursor->vidPtr, _cursorWidth, _cursorHeight, 0, 0, 0);
+
+		if (_frontSurface != _backSurface) {
+			_showCursor |= 1;
 			if (_noInvalidated == 0) {
+				_showCursor = CursorMan.isVisible() ? 2 : 0;
 				int16 tmp = _cursorIndex;
 				_cursorIndex = -1;
 				blitInvalidated();
@@ -1028,15 +1004,15 @@
 				_vm->_video->waitRetrace(_vm->_global->_videoMode);
 				if (minY < 50)
 					_vm->_util->delay(5);
+				_showCursor = (_showCursor & ~2) | ((_showCursor & 1) << 1);
 			}
-			_vm->_video->drawSprite(_backSurface, _frontSurface,
-					minX, minY, maxX, maxY, minX, minY, 0);
-			_vm->_video->drawSprite(_cursorBack, _backSurface, 0, 0,
-					_cursorWidth - 1, _cursorHeight - 1, newX, newY, 0);
+			_showCursor &= ~1;
 		}
 	} else
 		blitCursor();
 
+	if (CursorMan.isVisible())
+		_showCursor = 2;
 	_cursorX = newX;
 	_cursorY = newY;
 }

Modified: scummvm/trunk/engines/gob/game.cpp
===================================================================
--- scummvm/trunk/engines/gob/game.cpp	2006-07-09 18:30:28 UTC (rev 23463)
+++ scummvm/trunk/engines/gob/game.cpp	2006-07-09 18:54:12 UTC (rev 23464)
@@ -675,7 +675,7 @@
 	delete[] _collisionAreas;
 
 	_vm->_video->freeSurfDesc(_vm->_draw->_cursorSprites);
-	_vm->_video->freeSurfDesc(_vm->_draw->_cursorBack);
+	_vm->_video->freeSurfDesc(_vm->_draw->_scummvmCursor);
 	_vm->_video->freeSurfDesc(_vm->_draw->_backSurface);
 }
 
@@ -985,7 +985,8 @@
 	// TODO: That assignment is not in the original assembly, why?
 	_vm->_draw->_cursorSpritesBack = _vm->_draw->_spritesArray[23];
 	_vm->_draw->_cursorSprites = _vm->_draw->_cursorSpritesBack;
-	_vm->_draw->_cursorBack = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 16, 16, 0);
+	_vm->_draw->_scummvmCursor =
+		_vm->_video->initSurfDesc(_vm->_global->_videoMode, 16, 16, SCUMMVM_CURSOR);
 
 	_vm->_draw->_spritesArray[20] = _vm->_draw->_frontSurface;
 	_vm->_draw->_spritesArray[21] = _vm->_draw->_backSurface;
@@ -999,7 +1000,7 @@
 // "DEVclosescreen"
 void Game::sub_BB28(void) {
 	_vm->_draw->freeSprite(23);
-	_vm->_video->freeSurfDesc(_vm->_draw->_cursorBack);
+	_vm->_video->freeSurfDesc(_vm->_draw->_scummvmCursor);
 	if (_off_2E51B != 0) {
 		memcpy(_vm->_draw->_frontSurface, _off_2E51B, sizeof(Video::SurfaceDesc));
 		_vm->_draw->_frontSurface->width = 320;

Modified: scummvm/trunk/engines/gob/game_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/game_v1.cpp	2006-07-09 18:30:28 UTC (rev 23463)
+++ scummvm/trunk/engines/gob/game_v1.cpp	2006-07-09 18:54:12 UTC (rev 23464)
@@ -622,7 +622,8 @@
 
 	_vm->_draw->_cursorAnimLow[1] = 0;
 	_vm->_draw->_cursorSprites = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 32, 16, 2);
-	_vm->_draw->_cursorBack = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 16, 16, 0);
+	_vm->_draw->_scummvmCursor =
+		_vm->_video->initSurfDesc(_vm->_global->_videoMode, 16, 16, SCUMMVM_CURSOR);
 	_vm->_draw->_renderFlags = 0;
 	_vm->_draw->_backDeltaX = 0;
 	_vm->_draw->_backDeltaY = 0;

Modified: scummvm/trunk/engines/gob/inter_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v1.cpp	2006-07-09 18:30:28 UTC (rev 23463)
+++ scummvm/trunk/engines/gob/inter_v1.cpp	2006-07-09 18:54:12 UTC (rev 23464)
@@ -804,7 +804,7 @@
 	    _vm->_draw->_cursorSprites->width != width * count) {
 
 		_vm->_video->freeSurfDesc(_vm->_draw->_cursorSprites);
-		_vm->_video->freeSurfDesc(_vm->_draw->_cursorBack);
+		_vm->_video->freeSurfDesc(_vm->_draw->_scummvmCursor);
 
 		_vm->_draw->_cursorWidth = width;
 		_vm->_draw->_cursorHeight = height;
@@ -822,9 +822,9 @@
 		    _vm->_draw->_cursorHeight, 2);
 		_vm->_draw->_spritesArray[23] = _vm->_draw->_cursorSprites;
 
-		_vm->_draw->_cursorBack =
+		_vm->_draw->_scummvmCursor =
 		    _vm->_video->initSurfDesc(_vm->_global->_videoMode, _vm->_draw->_cursorWidth,
-		    _vm->_draw->_cursorHeight, 0);
+		    _vm->_draw->_cursorHeight, SCUMMVM_CURSOR);
 		for (i = 0; i < 40; i++) {
 			_vm->_draw->_cursorAnimLow[i] = -1;
 			_vm->_draw->_cursorAnimDelays[i] = 0;

Modified: scummvm/trunk/engines/gob/inter_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v2.cpp	2006-07-09 18:30:28 UTC (rev 23463)
+++ scummvm/trunk/engines/gob/inter_v2.cpp	2006-07-09 18:54:12 UTC (rev 23464)
@@ -1812,7 +1812,7 @@
 	    _vm->_draw->_cursorSprites->width != width * count) {
 
 		_vm->_video->freeSurfDesc(_vm->_draw->_cursorSprites);
-		_vm->_video->freeSurfDesc(_vm->_draw->_cursorBack);
+		_vm->_video->freeSurfDesc(_vm->_draw->_scummvmCursor);
 
 		_vm->_draw->_cursorWidth = width;
 		_vm->_draw->_cursorHeight = height;
@@ -1830,9 +1830,9 @@
 		_vm->_draw->_cursorSpritesBack = _vm->_draw->_spritesArray[23];
 		_vm->_draw->_cursorSprites = _vm->_draw->_cursorSpritesBack;
 
-		_vm->_draw->_cursorBack =
+		_vm->_draw->_scummvmCursor =
 		    _vm->_video->initSurfDesc(_vm->_global->_videoMode, _vm->_draw->_cursorWidth,
-		    _vm->_draw->_cursorHeight, 0);
+		    _vm->_draw->_cursorHeight, SCUMMVM_CURSOR);
 		for (i = 0; i < 40; i++) {
 			_vm->_draw->_cursorAnimLow[i] = -1;
 			_vm->_draw->_cursorAnimDelays[i] = 0;

Modified: scummvm/trunk/engines/gob/video.h
===================================================================
--- scummvm/trunk/engines/gob/video.h	2006-07-09 18:30:28 UTC (rev 23463)
+++ scummvm/trunk/engines/gob/video.h	2006-07-09 18:54:12 UTC (rev 23464)
@@ -71,6 +71,7 @@
 #define PRIMARY_SURFACE		0x80
 #define RETURN_PRIMARY		0x01
 #define DISABLE_SPR_ALLOC	0x20
+#define SCUMMVM_CURSOR		0x100
 
 #if defined(START_PACK_STRUCTS)
 #pragma START_PACK_STRUCTS

Modified: scummvm/trunk/engines/gob/video_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/video_v1.cpp	2006-07-09 18:30:28 UTC (rev 23463)
+++ scummvm/trunk/engines/gob/video_v1.cpp	2006-07-09 18:54:12 UTC (rev 23464)
@@ -23,10 +23,12 @@
 
 #include "common/stdafx.h"
 #include "common/endian.h"
+#include "graphics/cursorman.h"
 
 #include "gob/gob.h"
 #include "gob/global.h"
 #include "gob/video.h"
+#include "gob/draw.h"
 
 namespace Gob {
 
@@ -36,6 +38,7 @@
 //XXX: Use this function to update the screen for now.
 //     This should be moved to a better location later on.
 void Video_v1::waitRetrace(int16) {
+	CursorMan.showMouse((bool) (_vm->_draw->_showCursor & 2));
 	if (_vm->_global->_pPrimarySurfDesc) {
 		g_system->copyRectToScreen(_vm->_global->_pPrimarySurfDesc->vidPtr, 320, 0, 0, 320, 200);
 		g_system->updateScreen();

Modified: scummvm/trunk/engines/gob/video_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/video_v2.cpp	2006-07-09 18:30:28 UTC (rev 23463)
+++ scummvm/trunk/engines/gob/video_v2.cpp	2006-07-09 18:54:12 UTC (rev 23464)
@@ -23,6 +23,7 @@
 
 #include "common/stdafx.h"
 #include "common/endian.h"
+#include "graphics/cursorman.h"
 
 #include "gob/gob.h"
 #include "gob/global.h"
@@ -37,6 +38,7 @@
 //XXX: Use this function to update the screen for now.
 //     This should be moved to a better location later on.
 void Video_v2::waitRetrace(int16) {
+	CursorMan.showMouse((bool) (_vm->_draw->_showCursor & 2));
 	if (_vm->_draw->_frontSurface) {
 		g_system->copyRectToScreen(_vm->_draw->_frontSurface->vidPtr, 320, 0, 0, 320, 200);
 		g_system->updateScreen();
@@ -106,7 +108,8 @@
 	else
 		flagsAnd2 = 0;
 
-	width = (width + 7) & 0xFFF8;
+	if ((flags & SCUMMVM_CURSOR) == 0)
+		width = (width + 7) & 0xFFF8;
 
 	if (flags & PRIMARY_SURFACE) {
 		_vm->_global->_primaryWidth = width;






More information about the Scummvm-git-logs mailing list