[Scummvm-cvs-logs] CVS: scummvm/backends/morphos morphos.cpp,1.20,1.21 morphos.h,1.10,1.11

Ruediger Hanke tomjoad at users.sourceforge.net
Sun May 4 06:14:11 CEST 2003


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

Modified Files:
	morphos.cpp morphos.h 
Log Message:


Index: morphos.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/morphos/morphos.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- morphos.cpp	26 Apr 2003 11:43:44 -0000	1.20
+++ morphos.cpp	4 May 2003 13:00:42 -0000	1.21
@@ -147,6 +147,8 @@
 	OvlBitMap = NULL;
 	OvlSavedBuffer = NULL;
 
+	InitSemaphore(&CritSec);
+
 	TimerBase = (Library*) TimerIORequest->tr_node.io_Device;
 	ScummNoCursor = (UWORD *) AllocVec(16, MEMF_CLEAR);
 	UpdateRegion = NewRegion();
@@ -998,6 +1000,8 @@
 	if (w <= 0 || h <= 0)
 		return;
 
+	AUTO_LOCK
+
 	if (MouseDrawn)
 	{
 		if (MOUSE_INTERSECTS(x, y, w, h))
@@ -1074,38 +1078,38 @@
 	if ((dx == 0) && (dy == 0))
 		return;
 
-	if (dx == 0) {
-		// vertical movement
-		if (dy > 0) {
-			// move down
-			// copy from bottom to top
-			for (int y = height - 1; y >= dy; y--)
-				copy_rect((byte *)ScummBuffer + ScummBufferWidth * (y - dy), ScummBufferWidth, 0, y, ScummBufferWidth, 1);
-		} else {
-			// move up
-			// copy from top to bottom
-			for (int y = 0; y < height + dx; y++)
-				copy_rect((byte *)ScummBuffer + ScummBufferWidth * (y - dy), ScummBufferWidth, 0, y, ScummBufferWidth, 1);
-		}
-	} else if (dy == 0) {
-		// horizontal movement
-		if (dx > 0) {
-			// move right
-			// copy from right to left
-			for (int x = ScummBufferWidth - 1; x >= dx; x--)
-				copy_rect((byte *)ScummBuffer + x - dx, ScummBufferWidth, x, 0, 1, height);
-		} else {
-			// move left
-			// copy from left to right
-			for (int x = 0; x < ScummBufferWidth; x++)
-				copy_rect((byte *)ScummBuffer + x - dx, ScummBufferWidth, x, 0, 1, height);
-		}
-	} else {
-		// free movement
-		// not neccessary for now
-	}
+	UpdateRects = 26;
+	Rectangle update_rect = { 0, 0, ScummBufferWidth, ScummBufferHeight };
+	OrRectRegion(NewUpdateRegion, &update_rect);
+	ScreenChanged = true;
 
+	UndrawMouse();
+
+	// vertical movement
+	if (dy > 0) {
+		// move down
+		// copy from bottom to top
+		for (int y = height - 1; y >= dy; y--)
+			copy_rect((byte *)ScummBuffer + ScummBufferWidth * (y - dy), ScummBufferWidth, 0, y, ScummBufferWidth, 1);
+	} else if (dy < 0) {
+		// move up
+		// copy from top to bottom
+		for (int y = dy; y < height; y++)
+			copy_rect((byte *)ScummBuffer + ScummBufferWidth * (y - dy), ScummBufferWidth, 0, y, ScummBufferWidth, 1);
+	}
 
+	// horizontal movement
+	if (dx > 0) {
+		// move right
+		// copy from right to left
+		for (int x = ScummBufferWidth - 1; x >= dx; x--)
+			copy_rect((byte *)ScummBuffer + x - dx, ScummBufferWidth, x, 0, 1, height);
+	} else if (dx < 0) {
+		// move left
+		// copy from left to right
+		for (int x = dx; x < ScummBufferWidth; x++)
+			copy_rect((byte *)ScummBuffer + x - dx, ScummBufferWidth, x, 0, 1, height);
+	}
 }
 
 
@@ -1137,6 +1141,8 @@
 
 void OSystem_MorphOS::update_screen()
 {
+	AUTO_LOCK
+
 	DrawMouse();
 
 	if (!ScreenChanged)
@@ -1528,6 +1534,8 @@
 
 void OSystem_MorphOS::clear_overlay()
 {
+	AUTO_LOCK
+
 	UBYTE *src = (UBYTE *) ScummBuffer;
 	UBYTE *dest = (UBYTE *) OvlBitMap;
 	copy_rect((byte *) OvlSavedBuffer, ScummBufferWidth, 0, 0, ScummBufferWidth, ScummBufferHeight);

Index: morphos.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/morphos/morphos.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- morphos.h	9 Jan 2003 20:09:19 -0000	1.10
+++ morphos.h	4 May 2003 13:00:43 -0000	1.11
@@ -29,6 +29,7 @@
 #include <intuition/intuition.h>
 #include <intuition/screens.h>
 #include <libraries/cdda.h>
+#include <proto/exec.h>
 
 #include "morphos_scaler.h"
 
@@ -165,6 +166,7 @@
 		Region 		 *UpdateRegion;
 		Region 		 *NewUpdateRegion;
 		ULONG			  UpdateRects;
+		SignalSemaphore CritSec;
 
 		/* Overlay-related attributes */
 		APTR 		 OvlBitMap;
@@ -204,6 +206,19 @@
 		/* Game-related attributes */
 		int   GameID;
 };
+
+class AutoLock
+{
+	public:
+		AutoLock(SignalSemaphore* s) : sem(s) { ObtainSemaphore(sem); }
+		~AutoLock() { ReleaseSemaphore(sem); }
+
+	private:
+		SignalSemaphore* sem;
+};
+
+#define AUTO_LOCK	 AutoLock cs(&CritSec);
+
 
 int morphos_main(int argc, char *argv[]);
 





More information about the Scummvm-git-logs mailing list