[Scummvm-cvs-logs] SF.net SVN: scummvm: [24027] scummvm/trunk/engines/agos

kirben at users.sourceforge.net kirben at users.sourceforge.net
Sat Sep 30 08:47:48 CEST 2006


Revision: 24027
          http://svn.sourceforge.net/scummvm/?rev=24027&view=rev
Author:   kirben
Date:     2006-09-29 23:47:41 -0700 (Fri, 29 Sep 2006)

Log Message:
-----------
Add mouse cursor support for PP and minor cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/agos/agos.cpp
    scummvm/trunk/engines/agos/agos.h
    scummvm/trunk/engines/agos/cursor.cpp
    scummvm/trunk/engines/agos/items.cpp

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2006-09-30 05:57:44 UTC (rev 24026)
+++ scummvm/trunk/engines/agos/agos.cpp	2006-09-30 06:47:41 UTC (rev 24027)
@@ -167,9 +167,12 @@
 	_subtitles = false;
 
 	_animatePointer = 0;
-	_mouseCursor = 0;
+	_maxCursorWidth = 0;
+	_maxCursorHeight = 0;
 	_mouseAnim = 0;
 	_mouseAnimMax = 0;
+	_mouseCursor = 0;
+	_mouseData = 0;
 	_oldMouseCursor = 0;
 	_currentMouseCursor = 0;
 	_currentMouseAnim = 0;
@@ -607,6 +610,7 @@
 
 	allocItemHeap();
 	allocTablesHeap();
+	initMouse();
 
 	_variableArray = (int16 *)calloc(_numVars, sizeof(int16));
 	_variableArray2 = (int16 *)calloc(_numVars, sizeof(int16));
@@ -1367,9 +1371,9 @@
 
 byte *AGOSEngine::allocBlock(uint32 size) {
 	byte *block, *blockEnd;
-	uint i;
+	int vgaMemSize = _vgaMemSize;
 
-	for (i = 0; i < _vgaMemSize / size; i++) {
+	do {
 		block = _vgaMemPtr;
 		blockEnd = block + size;
 
@@ -1387,7 +1391,7 @@
 			_vgaMemPtr = blockEnd;
 			return block;
 		}
-	}
+	} while (vgaMemSize--);
 
 	error("allocBlock: Couldn't find free block");
 }

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2006-09-30 05:57:44 UTC (rev 24026)
+++ scummvm/trunk/engines/agos/agos.h	2006-09-30 06:47:41 UTC (rev 24027)
@@ -330,16 +330,12 @@
 	int _mouseX, _mouseY;
 	int _mouseXOld, _mouseYOld;
 
-	enum {
-	    kMaxCursorWidth = 40,
-	    kMaxCursorHeight = 40
-	};
-
-	byte _mouseData[kMaxCursorWidth * kMaxCursorHeight];
+	byte *_mouseData;
 	byte _animatePointer;
-	byte _mouseCursor, _mouseAnim, _mouseAnimMax;
-	byte _currentMouseCursor, _currentMouseAnim;
-	byte _oldMouseCursor, _oldMouseAnimMax;
+	byte _maxCursorWidth, _maxCursorHeight;
+	byte _mouseAnim, _mouseAnimMax, _mouseCursor;
+	byte _currentMouseAnim, _currentMouseCursor;
+	byte _oldMouseAnimMax, _oldMouseCursor;
 	uint _mouseHideCount;
 	bool _mouseToggle;
 
@@ -687,6 +683,8 @@
 
 	void handleMouseMoved();
 	void pollMouseXY();
+	void initMouse();
+	void loadMouseImage();
 	void drawMousePointer();
 	void drawMousePointer_FF();
 	void drawMousePart(int image, byte x, byte y);

Modified: scummvm/trunk/engines/agos/cursor.cpp
===================================================================
--- scummvm/trunk/engines/agos/cursor.cpp	2006-09-30 05:57:44 UTC (rev 24026)
+++ scummvm/trunk/engines/agos/cursor.cpp	2006-09-30 06:47:41 UTC (rev 24027)
@@ -226,14 +226,49 @@
 	  0xff,0xff,0xff,0xff,0xff,0xff,0xe5,0xe5,0xe5,0xff,0xff,0xff,0xff,0xff,0xff,0xff },
 };
 
-void AGOSEngine::drawMousePointer() {
-	if (getGameType() == GType_SIMON2) {
-		CursorMan.replaceCursor(_simon2_cursors[_mouseCursor], 16, 16, 7, 7);
-	} else {
-		CursorMan.replaceCursor(_simon1_cursor, 16, 16, 0, 0);
-	}
-}
+// Feeble Files specific
+static const byte _mouseOffs[29 * 32] = {
+	6,0,15,21,16,21,14,21,15,21,16,21,16,21,16,21,15,21,15,21,15,21,14,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
-	6,0,15,21,16,21,14,21,15,21,16,21,16,21,16,21,15,21,15,21,15,21,14,21,12,21,12,21,12,21,12,21,
-	6,2,10,12,9,12,8,11,7,10,6,9,4,8,3,7,1,7,0,6,3,7,4,8,6,9,7,10,8,11,9,12,
-	0,0,0,0,0,0,0,0,0,1,0,3,0,3,0,4,1,4,1,3,2,3,2,2,1,3,0,4,0,3,0,0,
+void AGOSEngine::initMouse() {
+	if (getGameType() == GType_PP) {
+		_maxCursorWidth = 75;
+		_maxCursorHeight = 97;
+		_mouseData = (byte *)calloc(_maxCursorWidth * _maxCursorHeight, 1);
+	} else if (getGameType() == GType_FF) {
+		_maxCursorWidth = 40;
+		_maxCursorHeight = 40;
+		_mouseData = (byte *)calloc(_maxCursorWidth * _maxCursorHeight, 1);
+	}
+}
 
-	0,0,5,16,4,19,2,21,1,21,1,21,1,21,1,18,3,9,6,2,6,0,3,6,4,12,4,13,4,13,4,14,
-	0,0,6,13,5,15,4,16,3,19,2,19,2,19,2,18,1,16,4,10,7,3,7,0,4,2,4,6,0,0,0,0,
+void AGOSEngine::loadMouseImage() {
+	loadZone(_variableArray[500]);
+	VgaPointersEntry *vpe = &_vgaBufferPointers[_variableArray[500]];
 
-	0,0,7,0,7,1,8,1,11,1,13,1,9,1,6,1,6,0,6,0,6,0,7,0,11,0,13,0,9,0,7,0,
+	byte *src = vpe->vgaFile2 + READ_LE_UINT32(vpe->vgaFile2 + _variableArray[501] * 8);
+	memcpy(_mouseData, src, _maxCursorWidth * _maxCursorHeight);
+}
 
-	0,0,7,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+void AGOSEngine::drawMousePointer() {
+	if (getGameType() == GType_PP) {
+		CursorMan.replaceCursor(_mouseData, _maxCursorWidth, _maxCursorHeight, 37, 48, 0);
+	} else if (getGameType() == GType_SIMON2) {
+		CursorMan.replaceCursor(_simon2_cursors[_mouseCursor], 16, 16, 7, 7);
+	} else {
+		CursorMan.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,12,5,10,6,9,7,8,7,7,8,6,9,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-	0,0,2,3,3,2,3,4,3,4,3,5,3,4,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-
-	0,0,7,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-	0,0,9,9,9,10,8,11,7,11,7,11,8,11,9,10,9,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-	0,0,10,7,10,6,10,5,10,4,10,3,10,4,10,5,10,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-};
-
 void AGOSEngine::drawMousePointer_FF() {
 	uint cursor;
 	int image, offs;
@@ -449,7 +471,7 @@
 			hotspotY += 18;
 		}
 
-		CursorMan.replaceCursor(_mouseData, kMaxCursorWidth, kMaxCursorHeight, hotspotX, hotspotY, 0);
+		CursorMan.replaceCursor(_mouseData, _maxCursorWidth, _maxCursorHeight, hotspotX, hotspotY, 0);
 	}
 }
 
@@ -458,7 +480,7 @@
 	byte *src;
 	int width, height;
 
-	byte *dst = _mouseData + y * kMaxCursorWidth + x;
+	byte *dst = _mouseData + y * _maxCursorWidth + x;
 
 	src = vpe->vgaFile2 + image * 8;
 	width = READ_LE_UINT16(src + 6);
@@ -466,8 +488,8 @@
 
 	src = vpe->vgaFile2 + READ_LE_UINT32(src);
 
-	assert(width + x <= kMaxCursorWidth);
-	assert(height + y <= kMaxCursorWidth);
+	assert(width + x <= _maxCursorWidth);
+	assert(height + y <= _maxCursorWidth);
 
 	for (int h = 0; h < height; h++) {
 		for (int w = 0; w < width; w++) {
@@ -475,7 +497,7 @@
 				dst[w] = src[w];
 		}
 		src += width;
-		dst += kMaxCursorWidth;
+		dst += _maxCursorWidth;
 	}
 }
 

Modified: scummvm/trunk/engines/agos/items.cpp
===================================================================
--- scummvm/trunk/engines/agos/items.cpp	2006-09-30 05:57:44 UTC (rev 24026)
+++ scummvm/trunk/engines/agos/items.cpp	2006-09-30 06:47:41 UTC (rev 24027)
@@ -2580,6 +2580,7 @@
 	// 38: load mouse image
 	getVarOrByte();
 	getNextItemPtr();
+	loadMouseImage();
 }
 
 void AGOSEngine::o4_setShortText() {


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