[Scummvm-cvs-logs] SF.net SVN: scummvm:[41204] scummvm/branches/gsoc2009-16bit

upthorn at users.sourceforge.net upthorn at users.sourceforge.net
Sat Jun 6 01:59:40 CEST 2009


Revision: 41204
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41204&view=rev
Author:   upthorn
Date:     2009-06-05 23:59:40 +0000 (Fri, 05 Jun 2009)

Log Message:
-----------
Fixes ScummEngine_v70he::setDefaultCursor to work in 16-bit, using a temporary hack.

Modified Paths:
--------------
    scummvm/branches/gsoc2009-16bit/engines/scumm/cursor.cpp
    scummvm/branches/gsoc2009-16bit/graphics/cursorman.cpp
    scummvm/branches/gsoc2009-16bit/graphics/cursorman.h
    scummvm/branches/gsoc2009-16bit/gui/GuiManager.cpp
    scummvm/branches/gsoc2009-16bit/gui/ThemeEngine.cpp

Modified: scummvm/branches/gsoc2009-16bit/engines/scumm/cursor.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/engines/scumm/cursor.cpp	2009-06-05 23:49:05 UTC (rev 41203)
+++ scummvm/branches/gsoc2009-16bit/engines/scumm/cursor.cpp	2009-06-05 23:59:40 UTC (rev 41204)
@@ -112,7 +112,7 @@
 
 void ScummEngine::updateCursor() {
 	int transColor = (_game.heversion >= 80) ? 5 : 255;
-	if (_game.features & GF_16BIT_COLOR && _hePalettes) {
+	if (_game.features & GF_16BIT_COLOR) {
 		//HACK Had to make a second method to avoid many, many linker errors from other engines
 		//this requires ENABLE_16BIT to be defined in the Scumm project, again, because I #ifdef'ed
 		//the method's definition and declaration in cursorman.h 
@@ -176,9 +176,14 @@
 	static const byte palette[] = {0,    0,    0,    0,
 								   0xff, 0xff, 0xff, 0,
 								   0,    0,    0,    0};
+	
+	if (_bitDepth == 2) {
+		for (i = 0; i < 1024; i++)
+			WRITE_UINT16(_grabbedCursor + i * 2, 5);
+	} else {
+		memset(_grabbedCursor, 5, sizeof(_grabbedCursor));
+	}
 
-	memset(_grabbedCursor, 5, sizeof(_grabbedCursor));
-
 	_cursor.hotspotX = _cursor.hotspotY = 2;
 	src = default_he_cursor;
 
@@ -190,10 +195,16 @@
 		for (j = 0; j < 32; j++) {
 			switch ((p & (0x3 << 14)) >> 14) {
 				case 1:
-					_grabbedCursor[32 * i + j] = 0xfe;
+					if (_bitDepth == 2)
+						WRITE_UINT16(_grabbedCursor + 64 * i + j * 2, get16BitColor(palette[4], palette[5], palette[6]));
+					else
+						_grabbedCursor[32 * i + j] = 0xfe;
 					break;
 				case 2:
-					_grabbedCursor[32 * i + j] = 0xfd;
+					if (_bitDepth == 2)
+						WRITE_UINT16(_grabbedCursor + 64 * i + j * 2, get16BitColor(palette[0], palette[1], palette[2]));
+					else
+						_grabbedCursor[32 * i + j] = 0xfd;
 					break;
 				default:
 					break;
@@ -205,9 +216,11 @@
 		}
 	}
 
-	// Since white color position is not guaranteed
-	// we setup our own palette if supported by backend
-	CursorMan.replaceCursorPalette(palette, 0xfd, 3);
+	if (_bitDepth == 1) {
+		// Since white color position is not guaranteed
+		// we setup our own palette if supported by backend
+		CursorMan.replaceCursorPalette(palette, 0xfd, 3);
+	}
 
 	updateCursor();
 }

Modified: scummvm/branches/gsoc2009-16bit/graphics/cursorman.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/graphics/cursorman.cpp	2009-06-05 23:49:05 UTC (rev 41203)
+++ scummvm/branches/gsoc2009-16bit/graphics/cursorman.cpp	2009-06-05 23:59:40 UTC (rev 41204)
@@ -56,7 +56,34 @@
 	// Should work, even if there's just a dummy cursor on the stack.
 	return g_system->showMouse(visible);
 }
+#ifdef ENABLE_16BIT
+void CursorManager::pushCursor16(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint16 keycolor, int targetScale) {
+	Cursor16 *cur = new Cursor16(buf, w, h, hotspotX, hotspotY, keycolor, targetScale);
 
+	cur->_visible = isVisible();
+	_cursor16Stack.push(cur);
+
+	if (buf) {
+		g_system->setMouseCursor16(cur->_data, w, h, hotspotX, hotspotY, keycolor, targetScale);
+	}
+}
+
+void CursorManager::popCursor16() {
+	if (_cursor16Stack.empty())
+		return;
+
+	Cursor16 *cur = _cursor16Stack.pop();
+	delete cur;
+
+	if (!_cursorStack.empty()) {
+		cur = _cursor16Stack.top();
+		g_system->setMouseCursor16(cur->_data, cur->_width, cur->_height, cur->_hotspotX, cur->_hotspotY, cur->_keycolor, cur->_targetScale);
+	}
+
+	g_system->showMouse(isVisible());
+}
+#endif
+
 void CursorManager::pushCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int targetScale) {
 	Cursor *cur = new Cursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale);
 
@@ -104,7 +131,7 @@
 //HACK Made a separate method to avoid massive linker errors on every engine
 void CursorManager::replaceCursor16(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint16 keycolor, int targetScale) {
 	if (_cursorStack.empty()) {
-		pushCursor(buf, w, h, hotspotX, hotspotY, keycolor, targetScale);
+		pushCursor16(buf, w, h, hotspotX, hotspotY, keycolor, targetScale);
 		return;
 	}
 

Modified: scummvm/branches/gsoc2009-16bit/graphics/cursorman.h
===================================================================
--- scummvm/branches/gsoc2009-16bit/graphics/cursorman.h	2009-06-05 23:49:05 UTC (rev 41203)
+++ scummvm/branches/gsoc2009-16bit/graphics/cursorman.h	2009-06-05 23:59:40 UTC (rev 41204)
@@ -64,6 +64,13 @@
 	 */
 	void popCursor();
 
+#ifdef ENABLE_16BIT
+	//HACK This is such a incredible hack
+	//I really need to make the one method 
+	//work under multiple bitdepths
+	void pushCursor16(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint16 keycolor = 65535, int targetScale = 1);
+	void popCursor16();
+#endif
 	/**
 	 * Replace the current cursor on the stack. If the stack is empty, the
 	 * cursor is pushed instead. It's a slightly more optimized way of
@@ -137,7 +144,37 @@
 private:
 	friend class Common::Singleton<SingletonBaseType>;
 	CursorManager();
+#ifdef ENABLE_16BIT
+	struct Cursor16 {
+		byte *_data;
+		bool _visible;
+		uint _width;
+		uint _height;
+		int _hotspotX;
+		int _hotspotY;
+		uint16 _keycolor;
+		byte _targetScale;
 
+		uint _size;
+
+		Cursor16(const byte *data, uint w, uint h, int hotspotX, int hotspotY, uint16 keycolor = 65535, int targetScale = 1) {
+			_size = w * h * 2;
+			_data = new byte[_size];
+			if (data && _data)
+				memcpy(_data, data, _size);
+			_width = w;
+			_height = h;
+			_hotspotX = hotspotX;
+			_hotspotY = hotspotY;
+			_keycolor = keycolor;
+			_targetScale = targetScale;
+		}
+
+		~Cursor16() {
+			delete[] _data;
+		}
+	};
+#endif
 	struct Cursor {
 		byte *_data;
 		bool _visible;
@@ -197,6 +234,9 @@
 	};
 
 	Common::Stack<Cursor *> _cursorStack;
+#ifdef ENABLE_16BIT
+	Common::Stack<Cursor16 *> _cursor16Stack;
+#endif
 	Common::Stack<Palette *> _cursorPaletteStack;
 };
 

Modified: scummvm/branches/gsoc2009-16bit/gui/GuiManager.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/gui/GuiManager.cpp	2009-06-05 23:49:05 UTC (rev 41203)
+++ scummvm/branches/gsoc2009-16bit/gui/GuiManager.cpp	2009-06-05 23:59:40 UTC (rev 41204)
@@ -135,8 +135,12 @@
 	delete _theme;
 
 	if (_useStdCursor) {
+#ifdef ENABLE_16BIT
+		CursorMan.popCursor16();
+#else
 		CursorMan.popCursorPalette();
 		CursorMan.popCursor();
+#endif
 	}
 
 	//
@@ -382,8 +386,12 @@
 
 void GuiManager::restoreState() {
 	if (_useStdCursor) {
+#ifdef ENABLE_16BIT
+		CursorMan.popCursor16();
+#else
 		CursorMan.popCursor();
 		CursorMan.popCursorPalette();
+#endif
 	}
 
 	_system->updateScreen();

Modified: scummvm/branches/gsoc2009-16bit/gui/ThemeEngine.cpp
===================================================================
--- scummvm/branches/gsoc2009-16bit/gui/ThemeEngine.cpp	2009-06-05 23:49:05 UTC (rev 41203)
+++ scummvm/branches/gsoc2009-16bit/gui/ThemeEngine.cpp	2009-06-05 23:59:40 UTC (rev 41204)
@@ -462,8 +462,12 @@
 	_system->hideOverlay();
 
 	if (_useCursor) {
+#ifdef ENABLE_16BIT
+		CursorMan.popCursor16();
+#else
 		CursorMan.popCursorPalette();
 		CursorMan.popCursor();
+#endif
 	}
 
 	_enabled = false;


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