diff options
Diffstat (limited to 'backends/morphos')
| -rw-r--r-- | backends/morphos/morphos.cpp | 68 | ||||
| -rw-r--r-- | backends/morphos/morphos.h | 15 | 
2 files changed, 53 insertions, 30 deletions
diff --git a/backends/morphos/morphos.cpp b/backends/morphos/morphos.cpp index 87b55f6cf0..91215f0cd1 100644 --- a/backends/morphos/morphos.cpp +++ b/backends/morphos/morphos.cpp @@ -147,6 +147,8 @@ OSystem_MorphOS::OSystem_MorphOS(int game_id, SCALERTYPE gfx_mode, bool full_scr  	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 @@ void OSystem_MorphOS::copy_rect(const byte *src, int pitch, int x, int y, int w,  	if (w <= 0 || h <= 0)  		return; +	AUTO_LOCK +  	if (MouseDrawn)  	{  		if (MOUSE_INTERSECTS(x, y, w, h)) @@ -1074,38 +1078,38 @@ void OSystem_MorphOS::move_screen(int dx, int dy, int height) {  	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 @@ bool OSystem_MorphOS::AddUpdateRect(WORD x, WORD y, WORD w, WORD h)  void OSystem_MorphOS::update_screen()  { +	AUTO_LOCK +  	DrawMouse();  	if (!ScreenChanged) @@ -1528,6 +1534,8 @@ void OSystem_MorphOS::hide_overlay()  void OSystem_MorphOS::clear_overlay()  { +	AUTO_LOCK +  	UBYTE *src = (UBYTE *) ScummBuffer;  	UBYTE *dest = (UBYTE *) OvlBitMap;  	copy_rect((byte *) OvlSavedBuffer, ScummBufferWidth, 0, 0, ScummBufferWidth, ScummBufferHeight); diff --git a/backends/morphos/morphos.h b/backends/morphos/morphos.h index 8730149bcc..71985b263e 100644 --- a/backends/morphos/morphos.h +++ b/backends/morphos/morphos.h @@ -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 @@ class OSystem_MorphOS : public OSystem  		Region 		 *UpdateRegion;  		Region 		 *NewUpdateRegion;  		ULONG			  UpdateRects; +		SignalSemaphore CritSec;  		/* Overlay-related attributes */  		APTR 		 OvlBitMap; @@ -205,6 +207,19 @@ class OSystem_MorphOS : public OSystem  		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[]);  extern OSystem_MorphOS *TheSystem;  | 
