[Scummvm-cvs-logs] SF.net SVN: scummvm: [29286] scummvm/trunk/engines/cruise

yazoo at users.sourceforge.net yazoo at users.sourceforge.net
Sun Oct 28 14:21:01 CET 2007


Revision: 29286
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29286&view=rev
Author:   yazoo
Date:     2007-10-28 06:21:01 -0700 (Sun, 28 Oct 2007)

Log Message:
-----------
Implement cursors

Modified Paths:
--------------
    scummvm/trunk/engines/cruise/cruise.cpp
    scummvm/trunk/engines/cruise/cruise_main.cpp
    scummvm/trunk/engines/cruise/cruise_main.h
    scummvm/trunk/engines/cruise/function.cpp
    scummvm/trunk/engines/cruise/mouse.cpp
    scummvm/trunk/engines/cruise/mouse.h
    scummvm/trunk/engines/cruise/saveload.cpp
    scummvm/trunk/engines/cruise/vars.cpp
    scummvm/trunk/engines/cruise/vars.h
    scummvm/trunk/engines/cruise/volume.cpp

Modified: scummvm/trunk/engines/cruise/cruise.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cruise.cpp	2007-10-28 13:14:23 UTC (rev 29285)
+++ scummvm/trunk/engines/cruise/cruise.cpp	2007-10-28 13:21:01 UTC (rev 29286)
@@ -92,6 +92,7 @@
 }
 
 int CruiseEngine::go() {
+	Cruise::changeCursor(Cruise::CURSOR_NORMAL);
 	CursorMan.showMouse(true);
 
 	Cruise::mainLoop();

Modified: scummvm/trunk/engines/cruise/cruise_main.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cruise_main.cpp	2007-10-28 13:14:23 UTC (rev 29285)
+++ scummvm/trunk/engines/cruise/cruise_main.cpp	2007-10-28 13:21:01 UTC (rev 29286)
@@ -71,12 +71,10 @@
 }
 
 void loadPakedFileToMem(int fileIdx, uint8 *buffer) {
-	//changeCursor(1);
+	changeCursor(CURSOR_DISK);
 
-	currentVolumeFile.seek(volumePtrToFileDescriptor[fileIdx].offset,
-	    SEEK_SET);
-	currentVolumeFile.read(buffer,
-	    volumePtrToFileDescriptor[fileIdx].size);
+	currentVolumeFile.seek(volumePtrToFileDescriptor[fileIdx].offset, SEEK_SET);
+	currentVolumeFile.read(buffer, volumePtrToFileDescriptor[fileIdx].size);
 }
 
 int loadScriptSub1(int scriptIdx, int param) {
@@ -1078,7 +1076,7 @@
 	// test both buttons
 	if (((button & 3) == 3) || keyboardVar == 0x44 || keyboardVar == 0x53)
 	{
-		changeCursor(0);
+		changeCursor(CURSOR_NORMAL);
 		keyboardVar = 0;
 		return (playerMenu(mouseX, mouseY));
 	}
@@ -1457,7 +1455,7 @@
 				 * }
 				 * else */
 				{
-					changeCursor(0);
+					changeCursor(CURSOR_NORMAL);
 				}
 
 				if (main7) {
@@ -1534,10 +1532,6 @@
 	return (0);
 }
 
-void changeCursor(uint16 cursorType) {
-	//printf("changeCursor %d\n", cursorType);
-}
-
 void *mallocAndZero(int32 size) {
 	void *ptr;
 

Modified: scummvm/trunk/engines/cruise/cruise_main.h
===================================================================
--- scummvm/trunk/engines/cruise/cruise_main.h	2007-10-28 13:14:23 UTC (rev 29285)
+++ scummvm/trunk/engines/cruise/cruise_main.h	2007-10-28 13:21:01 UTC (rev 29286)
@@ -90,13 +90,13 @@
     const uint8 * string);
 void removeExtention(const char *name, char *buffer);
 void resetRaster(uint8 * rasterPtr, int32 rasterSize);
-void changeCursor(uint16 cursorType);
 void resetPtr2(scriptInstanceStruct * ptr);
 void getFileExtention(const char *name, char *buffer);
 void *allocAndZero(int size);
 void freeStuff2(void);
 char *getObjectName(int index, uint8 * string);
 void mainLoop(void);
+void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton, int16 *pMouseY);
 
 } // End of namespace Cruise
 

Modified: scummvm/trunk/engines/cruise/function.cpp
===================================================================
--- scummvm/trunk/engines/cruise/function.cpp	2007-10-28 13:14:23 UTC (rev 29285)
+++ scummvm/trunk/engines/cruise/function.cpp	2007-10-28 13:21:01 UTC (rev 29286)
@@ -436,7 +436,7 @@
 		result = loadBackground((char *)bgName, bgIdx);
 	}
 
-	changeCursor(0);
+	changeCursor(CURSOR_NORMAL);
 
 	return result;
 }
@@ -485,7 +485,7 @@
 		saveVar6[0] = 0;
 	}
 
-	changeCursor(0);
+	changeCursor(CURSOR_NORMAL);
 	return 0;
 }
 
@@ -512,7 +512,7 @@
 		result = loadFullBundle(name, param1);
 	}
 
-	changeCursor(0);
+	changeCursor(CURSOR_NORMAL);
 	return result;
 }
 

Modified: scummvm/trunk/engines/cruise/mouse.cpp
===================================================================
--- scummvm/trunk/engines/cruise/mouse.cpp	2007-10-28 13:14:23 UTC (rev 29285)
+++ scummvm/trunk/engines/cruise/mouse.cpp	2007-10-28 13:21:01 UTC (rev 29286)
@@ -24,30 +24,144 @@
  */
 
 #include "cruise/cruise_main.h"
+#include "graphics/cursorman.h"
 
 namespace Cruise {
 
 int16 main10;
-#if 0
-void getMouseStatus(int16 *pMouseVar, int16 *pMouseX, int16 *pMouseButton,
-	    int16 *pMouseY) {
-	// mouseStatusStruct localStatus;
 
-	// OSystem_GetMouseStatus(&localStatus);
+	static const byte mouseCursorNormal[] = {
+		0x00, 0x00, 0x40, 0x00, 0x60, 0x00, 0x70, 0x00,
+		0x78, 0x00, 0x7C, 0x00, 0x7E, 0x00, 0x7F, 0x00,
+		0x7F, 0x80, 0x7C, 0x00, 0x6C, 0x00, 0x46, 0x00,
+		0x06, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00,
 
-	*pMouseX = 0;
-	*pMouseY = 0;
+		0xC0, 0x00, 0xE0, 0x00, 0xF0, 0x00, 0xF8, 0x00,
+		0xFC, 0x00, 0xFE, 0x00, 0xFF, 0x00, 0xFF, 0x80,
+		0xFF, 0xC0, 0xFF, 0xC0, 0xFE, 0x00, 0xFF, 0x00,
+		0xCF, 0x00, 0x07, 0x80, 0x07, 0x80, 0x03, 0x80
+	};
 
-	*pMouseButton = 0;
-/*
-  if (localStatus.left)
-    *pMouseButton |= 1;
-  if (localStatus.right)
-    *pMouseButton |= 2;
-  if (localStatus.middle)
-    *pMouseButton |= 4;
-	*/
-}
-#endif
+	static const byte mouseCursorDisk[] = {
+		0x7F, 0xFC, 0x9F, 0x12, 0x9F, 0x12, 0x9F, 0x12,
+		0x9F, 0x12, 0x9F, 0xE2, 0x80, 0x02, 0x9F, 0xF2,
+		0xA0, 0x0A, 0xA0, 0x0A, 0xA0, 0x0A, 0xA0, 0x0A,
+		0xA0, 0x0A, 0xA0, 0x0A, 0x7F, 0xFC, 0x00, 0x00,
 
+		0x7F, 0xFC, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE,
+		0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE,
+		0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE,
+		0xFF, 0xFE, 0xFF, 0xFE, 0x7F, 0xFC, 0x00, 0x00
+	};
+
+	static const byte mouseCursorCross[] = {
+		0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
+		0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7C, 0x7C,
+		0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
+		0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+		0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80,
+		0x03, 0x80, 0x03, 0x80, 0xFF, 0xFE, 0xFE, 0xFE,
+		0xFF, 0xFE, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80,
+		0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00
+	};
+
+	static const byte mouseCursorNoMouse[] = {
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+	};
+
+	static const byte mouseCursorWalk[] = {
+		0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x01, 0xE0,
+		0x3F, 0xF0, 0x03, 0x38, 0x1B, 0xDC, 0x1B, 0xCC,
+		0x03, 0xCC, 0x03, 0x80, 0x07, 0x00, 0x0E, 0xC0,
+		0x1C, 0xE0, 0x18, 0x70, 0x18, 0x38, 0x18, 0x18,
+
+		0x07, 0xE0, 0x07, 0xE0, 0x07, 0xE0, 0x03, 0xF0,
+		0x07, 0xF8, 0x07, 0xFC, 0x3F, 0xFE, 0x3F, 0xFE,
+		0x07, 0xFE, 0x07, 0xC0, 0x0F, 0x80, 0x1F, 0xE0,
+		0x3F, 0xF0, 0x3C, 0xF8, 0x3C, 0x7C, 0x3C, 0x3C
+	};
+
+	static const byte mouseCursorExit[] = {
+		0x7f, 0xf8, 0x60, 0x18, 0x60, 0x18, 0x60, 0x18,
+		0x60, 0x00, 0x60, 0x08, 0x60, 0x0c, 0x60, 0xfe,
+		0x60, 0xfe, 0x60, 0x0c, 0x60, 0x08, 0x60, 0x00,
+		0x60, 0x18, 0x60, 0x18, 0x60, 0x18, 0x7f, 0xf8,
+
+		0xff, 0xfc, 0xf0, 0x3c, 0xf0, 0x3c, 0xf0, 0x3c,
+		0xf0, 0x00, 0xf0, 0x1c, 0xf0, 0x1e, 0xf1, 0xff,
+		0xf1, 0xff, 0xf0, 0x1e, 0xf0, 0x1c, 0xf0, 0x00,
+		0xf0, 0x3c, 0xf0, 0x3c, 0xf0, 0x3c, 0xff, 0xfc
+	};
+
+	static const byte mouseCursorMagnifyingGlass[] = {
+		0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0x02, 0x02,
+		0x02, 0x02, 0x02, 0x02, 0x00, 0x22, 0x00, 0x02,
+		0x07, 0x82, 0x03, 0x82, 0x07, 0x9e, 0xfe, 0x80,
+		0xfc, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+		0x00, 0x00, 0x07, 0xff, 0x07, 0xff, 0x06, 0x03,
+		0x06, 0x03, 0x06, 0x03, 0x00, 0x23, 0x0f, 0xc3,
+		0x0f, 0xc3, 0x07, 0xc3, 0xff, 0xdf, 0xff, 0xdf,
+		0xfe, 0xc0, 0xfc, 0x00, 0xf8, 0x00, 0x00, 0x00
+	};
+
+	struct MouseCursor {
+		int hotspotX;
+		int hotspotY;
+		const byte *bitmap;
+	};
+	
+	static const MouseCursor mouseCursors[] = {
+		{ 1, 1, mouseCursorNormal },
+		{ 0, 0, mouseCursorDisk },
+		{ 7, 7, mouseCursorCross },
+		{ 0, 0, mouseCursorNoMouse },
+		{ 10, 6, mouseCursorWalk },
+		{ 10, 6, mouseCursorExit },
+		{ 10, 6, mouseCursorMagnifyingGlass }
+	};
+
+	CursorType currentCursor = CURSOR_NOMOUSE;
+
+	static const byte cursorPalette[] = {
+		0, 0, 0, 0xff,
+		0xff, 0xff, 0xff, 0xff
+	};
+
+	void changeCursor(CursorType eType)
+	{
+		assert(eType >= 0 && eType < CURSOR_MAX);
+		if (currentCursor != eType) {
+			byte mouseCursor[16 * 16];
+			const MouseCursor *mc = &mouseCursors[eType];
+			const byte *src = mc->bitmap;
+			for (int i = 0; i < 32; ++i) {
+				int offs = i * 8;
+				for (byte mask = 0x80; mask != 0; mask >>= 1) {
+					if (src[0] & mask) {
+						mouseCursor[offs] = 1;
+					} else if (src[32] & mask) {
+						mouseCursor[offs] = 0;
+					} else {
+						mouseCursor[offs] = 0xFF;
+					}
+					++offs;
+				}
+				++src;
+			}
+			CursorMan.replaceCursor(mouseCursor, 16, 16, mc->hotspotX, mc->hotspotY);
+			CursorMan.replaceCursorPalette(cursorPalette, 0, 2);
+			currentCursor = eType;
+		}
+	}
+
 } // End of namespace Cruise

Modified: scummvm/trunk/engines/cruise/mouse.h
===================================================================
--- scummvm/trunk/engines/cruise/mouse.h	2007-10-28 13:14:23 UTC (rev 29285)
+++ scummvm/trunk/engines/cruise/mouse.h	2007-10-28 13:21:01 UTC (rev 29286)
@@ -28,11 +28,24 @@
 
 namespace Cruise {
 
-extern int16 main10;
+	extern int16 main10;
 
-void getMouseStatus(int16 * pMouseVar, int16 * pMouseX, int16 * pMouseButton,
-    int16 * pMouseY);
+	enum CursorType
+	{
+		CURSOR_NORMAL = 0,
+		CURSOR_DISK = 1,
+		CURSOR_CROSS = 2,
+		CURSOR_NOMOUSE = 3,
+		CURSOR_WALK = 4,
+		CURSOR_EXIT = 5,
+		CURSOR_MAGNIFYING_GLASS = 6,
 
+		CURSOR_MAX = 7,
+	};
+
+	void changeCursor(CursorType eType);
+	extern CursorType currentCursor;
+
 } // End of namespace Cruise
 
 #endif

Modified: scummvm/trunk/engines/cruise/saveload.cpp
===================================================================
--- scummvm/trunk/engines/cruise/saveload.cpp	2007-10-28 13:14:23 UTC (rev 29285)
+++ scummvm/trunk/engines/cruise/saveload.cpp	2007-10-28 13:21:01 UTC (rev 29286)
@@ -404,7 +404,7 @@
 
 	// to finish
 
-	changeCursor(0);
+	changeCursor(CURSOR_NORMAL);
 	mainDraw(1);
 	flipScreen();
 

Modified: scummvm/trunk/engines/cruise/vars.cpp
===================================================================
--- scummvm/trunk/engines/cruise/vars.cpp	2007-10-28 13:14:23 UTC (rev 29285)
+++ scummvm/trunk/engines/cruise/vars.cpp	2007-10-28 13:21:01 UTC (rev 29286)
@@ -71,8 +71,6 @@
 Common::File currentVolumeFile;
 #endif
 
-int16 currentCursor;
-
 int16 volumeNumEntry;
 fileEntry *volumePtrToFileDescriptor = NULL;
 

Modified: scummvm/trunk/engines/cruise/vars.h
===================================================================
--- scummvm/trunk/engines/cruise/vars.h	2007-10-28 13:14:23 UTC (rev 29285)
+++ scummvm/trunk/engines/cruise/vars.h	2007-10-28 13:21:01 UTC (rev 29286)
@@ -174,8 +174,6 @@
 extern Common::File currentVolumeFile;
 #endif
 
-extern int16 currentCursor;
-
 extern int16 volumeNumEntry;
 extern fileEntry *volumePtrToFileDescriptor;
 

Modified: scummvm/trunk/engines/cruise/volume.cpp
===================================================================
--- scummvm/trunk/engines/cruise/volume.cpp	2007-10-28 13:14:23 UTC (rev 29285)
+++ scummvm/trunk/engines/cruise/volume.cpp	2007-10-28 13:21:01 UTC (rev 29286)
@@ -77,7 +77,7 @@
 		return (-14);
 	}
 
-	changeCursor(1);
+	changeCursor(CURSOR_DISK);
 
 	currentVolumeFile.read(&volumeNumberOfEntry, 2);
 	currentVolumeFile.read(&volumeSizeOfEntry, 2);


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