[Scummvm-cvs-logs] CVS: scummvm/backends/morphos morphos.cpp,1.17,1.18 morphos.h,1.9,1.10

Ruediger Hanke tomjoad at users.sourceforge.net
Thu Jan 9 12:10:09 CET 2003


Update of /cvsroot/scummvm/scummvm/backends/morphos
In directory sc8-pr-cvs1:/tmp/cvs-serv28542

Modified Files:
	morphos.cpp morphos.h 
Log Message:
Added warp_mouse func to MorphOS backend

Index: morphos.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/morphos/morphos.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- morphos.cpp	25 Dec 2002 17:22:01 -0000	1.17
+++ morphos.cpp	9 Jan 2003 20:09:18 -0000	1.18
@@ -34,6 +34,7 @@
 #include <dos/dostags.h>
 #include <intuition/screens.h>
 #include <cybergraphics/cybergraphics.h>
+#include <devices/input.h>
 #include <devices/inputevent.h>
 #include <intuition/intuition.h>
 
@@ -112,9 +113,33 @@
 	strcpy(ScummWndTitle, "ScummVM MorphOS");
 	TimerMsgPort = NULL;
 	TimerIORequest = NULL;
+	InputMsgPort = NULL;
+	InputIORequest = NULL;
 
 	OpenATimer(&TimerMsgPort, (IORequest **) &TimerIORequest, UNIT_MICROHZ);
 
+	if ((InputMsgPort = CreateMsgPort()))
+	{
+		if ((InputIORequest = (IOStdReq*) CreateIORequest(InputMsgPort, sizeof (IOStdReq))))
+		{
+			if ((OpenDevice("input.device", NULL, (IORequest *) InputIORequest, NULL)))
+			{
+				DeleteIORequest(InputIORequest);
+				DeleteMsgPort(InputMsgPort);
+				InputIORequest = NULL;
+				InputMsgPort = NULL;
+			}
+		}
+		else
+		{
+			DeleteMsgPort(InputMsgPort);
+			InputMsgPort = NULL;
+		}
+	}
+
+	if (!InputIORequest)
+		warning("input.device could not be opened");
+
 	OvlCMap = GetColorMap(256);
 	OvlBitMap = NULL;
 	OvlSavedBuffer = NULL;
@@ -163,6 +188,15 @@
 		CDDA_ReleaseDrive(CDrive);
 	}
 
+	if (InputIORequest)
+	{
+		CloseDevice((IORequest *) InputIORequest);
+		DeleteIORequest((IORequest *) InputIORequest);
+	}
+
+	if (InputMsgPort)
+		DeleteMsgPort(InputMsgPort);
+
 	if (TimerIORequest)
 	{
 		CloseDevice((IORequest *) TimerIORequest);
@@ -862,6 +896,43 @@
 	return false;
 }
 
+void OSystem_MorphOS::warp_mouse(int x, int y)
+{
+	if (InputIORequest)
+	{
+		InputEvent* 	 FakeIE;
+		IEPointerPixel* NewPixel;
+	
+		/*
+		 * Fake a mousemove input event
+		 */
+		if ((FakeIE = (InputEvent*) AllocVec(sizeof (InputEvent), MEMF_PUBLIC)))
+		{
+			if ((NewPixel = (IEPointerPixel*) AllocVec(sizeof (IEPointerPixel), MEMF_PUBLIC)))
+			{
+				NewPixel->iepp_Screen = ScummWindow->WScreen;
+				NewPixel->iepp_Position.X = x + ScummWindow->LeftEdge + ScummWindow->BorderLeft;
+				NewPixel->iepp_Position.Y = x+ScummWindow->TopEdge + ScummWindow->BorderTop;
+
+				FakeIE->ie_EventAddress = NewPixel;
+				FakeIE->ie_NextEvent = NULL;
+				FakeIE->ie_Class = IECLASS_NEWPOINTERPOS;
+				FakeIE->ie_SubClass = IESUBCLASS_PIXEL;
+				FakeIE->ie_Code = IECODE_NOBUTTON;
+				FakeIE->ie_Qualifier = NULL;
+
+				InputIORequest->io_Data = FakeIE;
+				InputIORequest->io_Length = sizeof (InputEvent);
+				InputIORequest->io_Command = IND_WRITEEVENT;
+				DoIO((IORequest *) InputIORequest);
+
+				FreeVec(NewPixel);
+			}
+			FreeVec(FakeIE);
+		}
+	}
+}
+
 void OSystem_MorphOS::set_shake_pos(int shake_pos)
 {
 	ScummShakePos = shake_pos;
@@ -1435,11 +1506,17 @@
 
 	do
 	{
-		for (x = 0; x < ScummBufferWidth; x++)
+/*		  for (x = 0; x < ScummBufferWidth; x++)
+		{
+			*buf++ = (src[0]*31/255 << 11) | (src[1]*63/255 << 5) | src[2]*31/255;
+			src += 3;
+		}*/
+		for (x = 0; x < pitch; x++)
 		{
 			*buf++ = (src[0]*31/255 << 11) | (src[1]*63/255 << 5) | src[2]*31/255;
 			src += 3;
 		}
+		src += (ScummBufferWidth-pitch)*3;
 	} while (--h);
 }
 
@@ -1451,6 +1528,8 @@
 	LONG last_col[2] = { -1, -1 };
 	LONG last_pen[2] = { -1, -1 };
 
+	printf("copy_rect_overlay(%d, %d, %d, %d, %d)\n", pitch, x, y, w, h);
+	if (w > pitch) w = pitch;
 	bmap = (UBYTE*) AllocVec(w*h, MEMF_ANY);
 	if (bmap)
 	{
@@ -1481,7 +1560,7 @@
 					*bmap_dest++ = last_pen[0];
 				}
 			}
-			dest += ScummBufferWidth*3-w*3;
+			dest += (ScummBufferWidth-w)*3;
 			ovl += pitch-w;
 		}
 		copy_rect(bmap, w, x, y, w, h);

Index: morphos.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/morphos/morphos.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- morphos.h	25 Dec 2002 17:22:01 -0000	1.9
+++ morphos.h	9 Jan 2003 20:09:19 -0000	1.10
@@ -94,6 +94,9 @@
 		// Returns true if an event was retrieved.
 		virtual bool poll_event(Event *event);
 
+		// Moves mouse pointer to specified position
+		virtual void warp_mouse(int x, int y);
+
 		// Set the function to be invoked whenever samples need to be generated
 		virtual bool set_sound_proc(void *param, SoundProc *proc, byte format);
 				  void fill_sound    (byte * stream, int len);
@@ -191,6 +194,8 @@
 		int   MouseOldWidth, MouseOldHeight;
 		int   MouseHotspotX, MouseHotspotY;
 		byte *MouseImage, MouseBackup[MAX_MOUSE_W*MAX_MOUSE_H];
+		MsgPort* InputMsgPort;
+		IOStdReq*InputIORequest;
 
 		/* Timer-related attributes */
 		MsgPort 	   *TimerMsgPort;





More information about the Scummvm-git-logs mailing list