[Scummvm-cvs-logs] CVS: scummvm timer.cpp,1.4,1.5 timer.h,1.4,1.5

Max Horn fingolfin at users.sourceforge.net
Tue Aug 13 17:15:13 CEST 2002


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv8554

Modified Files:
	timer.cpp timer.h 
Log Message:
unix line endings

Index: timer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/timer.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- timer.cpp	8 Aug 2002 21:54:49 -0000	1.4
+++ timer.cpp	14 Aug 2002 00:14:50 -0000	1.5
@@ -1,163 +1,163 @@
-/* ScummVM - Scumm Interpreter
- * Copyright (C) 2002 The ScummVM project
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- * $Header$
- */
-
-#include "stdafx.h"
-#include "scumm.h"
-#include "scummsys.h"
-#include "timer.h"
-
-static Scumm * scumm;
-
-Timer::Timer(Scumm * parent) {
-	_initialized = false;
-	_timerRunning = false;
-	scumm = _scumm = parent;
-}
-
-Timer::~Timer() {
-	release ();
-}
-
-static int timer_handler (int t)
-{
-	scumm->_timer->handler (&t);
-	return t;
-}
-
-int Timer::handler(int * t) {
-	uint32 interval, l;
-
-	_osystem->lock_mutex(_mutex);
-
-	if (_timerRunning) {
-		_lastTime = _thisTime;
-		_thisTime = _osystem->get_msecs();
-		interval = _thisTime - _lastTime;
-
-		for (l = 0; l < MAX_TIMERS; l++) {
-			if ((_timerSlots[l].procedure) && (_timerSlots[l].interval > 0)) {
-				_timerSlots[l].counter -= interval;
-				if (_timerSlots[l].counter <= 0) {
-					_timerSlots[l].counter += _timerSlots[l].interval;
-					_timerSlots[l].procedure (0);
-				}
-			}
-		}
-	}
-
-	_osystem->unlock_mutex(_mutex);
-
-	return *t;
-}
-
-bool Timer::init() {
-	int32 l;
-
-	_osystem = _scumm->_system;
-	if (_osystem == NULL) {
-		printf("Timer: OSystem not initialized !\n");
-		return false;
-	}
-
-	if (_initialized == true) 
-		return true;
-
-	for (l = 0; l < MAX_TIMERS; l++) {
-		_timerSlots[l].procedure = NULL;
-		_timerSlots[l].interval = 0;
-		_timerSlots[l].counter = 0;
-	}
-
-	_mutex = _osystem->create_mutex();
-	_thisTime = _osystem->get_msecs();
-	_osystem->set_timer (10, &timer_handler);
-
-	_timerRunning = true;
-	_initialized = true;
-	return true;
-}
-
-void Timer::release() {
-	int32 l;
-
-	if (_initialized == false) 
-		return;
-
-	_timerRunning = false;
-	_initialized = false;
-
-	for (l = 0; l < MAX_TIMERS; l++) {
-		_timerSlots[l].procedure = NULL;
-		_timerSlots[l].interval = 0;
-		_timerSlots[l].counter = 0;
-	}
-	_osystem->delete_mutex(_mutex);
-
-}
-
-bool Timer::installProcedure (int ((*procedure)(int)), int32 interval) {
-	int32 l;
-	bool found = false;
-
-	if (_initialized == false) {
-		printf ("Timer: is not initialized !");
-		return false;
-	}
-
-	_timerRunning = false;
-	for (l = 0; l < MAX_TIMERS; l++) {
-		if (!_timerSlots[l].procedure) {
-			_timerSlots[l].procedure = procedure;
-			_timerSlots[l].interval = interval;
-			_timerSlots[l].counter = interval;
-			found = true;
-			break;
-		}
-	}
-
-	_timerRunning = true;
-	if (!found)	{
-		printf ("Can't find free slot !");
-		return false;
-	}
-
-	return true;
-}
-
-void Timer::releaseProcedure (int ((*procedure)(int))) {
-	int32 l;
-
-	if (_initialized == false) {
-		printf ("Timer: is not initialized !");
-		return;
-	}
-
-	_timerRunning = false;
-	for (l = 0; l < MAX_TIMERS; l++) {
-		if (_timerSlots[l].procedure == procedure) {
-			_timerSlots[l].procedure = 0;
-			_timerSlots[l].interval = 0;
-			_timerSlots[l].counter = 0;
-		}
-	}
-	_timerRunning = true;
-}
-
-
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2002 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * $Header$
+ */
+
+#include "stdafx.h"
+#include "scumm.h"
+#include "scummsys.h"
+#include "timer.h"
+
+static Scumm * scumm;
+
+Timer::Timer(Scumm * parent) {
+	_initialized = false;
+	_timerRunning = false;
+	scumm = _scumm = parent;
+}
+
+Timer::~Timer() {
+	release ();
+}
+
+static int timer_handler (int t)
+{
+	scumm->_timer->handler (&t);
+	return t;
+}
+
+int Timer::handler(int * t) {
+	uint32 interval, l;
+
+	_osystem->lock_mutex(_mutex);
+
+	if (_timerRunning) {
+		_lastTime = _thisTime;
+		_thisTime = _osystem->get_msecs();
+		interval = _thisTime - _lastTime;
+
+		for (l = 0; l < MAX_TIMERS; l++) {
+			if ((_timerSlots[l].procedure) && (_timerSlots[l].interval > 0)) {
+				_timerSlots[l].counter -= interval;
+				if (_timerSlots[l].counter <= 0) {
+					_timerSlots[l].counter += _timerSlots[l].interval;
+					_timerSlots[l].procedure (0);
+				}
+			}
+		}
+	}
+
+	_osystem->unlock_mutex(_mutex);
+
+	return *t;
+}
+
+bool Timer::init() {
+	int32 l;
+
+	_osystem = _scumm->_system;
+	if (_osystem == NULL) {
+		printf("Timer: OSystem not initialized !\n");
+		return false;
+	}
+
+	if (_initialized == true) 
+		return true;
+
+	for (l = 0; l < MAX_TIMERS; l++) {
+		_timerSlots[l].procedure = NULL;
+		_timerSlots[l].interval = 0;
+		_timerSlots[l].counter = 0;
+	}
+
+	_mutex = _osystem->create_mutex();
+	_thisTime = _osystem->get_msecs();
+	_osystem->set_timer (10, &timer_handler);
+
+	_timerRunning = true;
+	_initialized = true;
+	return true;
+}
+
+void Timer::release() {
+	int32 l;
+
+	if (_initialized == false) 
+		return;
+
+	_timerRunning = false;
+	_initialized = false;
+
+	for (l = 0; l < MAX_TIMERS; l++) {
+		_timerSlots[l].procedure = NULL;
+		_timerSlots[l].interval = 0;
+		_timerSlots[l].counter = 0;
+	}
+	_osystem->delete_mutex(_mutex);
+
+}
+
+bool Timer::installProcedure (int ((*procedure)(int)), int32 interval) {
+	int32 l;
+	bool found = false;
+
+	if (_initialized == false) {
+		printf ("Timer: is not initialized !");
+		return false;
+	}
+
+	_timerRunning = false;
+	for (l = 0; l < MAX_TIMERS; l++) {
+		if (!_timerSlots[l].procedure) {
+			_timerSlots[l].procedure = procedure;
+			_timerSlots[l].interval = interval;
+			_timerSlots[l].counter = interval;
+			found = true;
+			break;
+		}
+	}
+
+	_timerRunning = true;
+	if (!found)	{
+		printf ("Can't find free slot !");
+		return false;
+	}
+
+	return true;
+}
+
+void Timer::releaseProcedure (int ((*procedure)(int))) {
+	int32 l;
+
+	if (_initialized == false) {
+		printf ("Timer: is not initialized !");
+		return;
+	}
+
+	_timerRunning = false;
+	for (l = 0; l < MAX_TIMERS; l++) {
+		if (_timerSlots[l].procedure == procedure) {
+			_timerSlots[l].procedure = 0;
+			_timerSlots[l].interval = 0;
+			_timerSlots[l].counter = 0;
+		}
+	}
+	_timerRunning = true;
+}
+
+

Index: timer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/timer.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- timer.h	9 Aug 2002 10:48:47 -0000	1.4
+++ timer.h	14 Aug 2002 00:14:50 -0000	1.5
@@ -25,6 +25,8 @@
 
 #define MAX_TIMERS 3
 
+typedef int (*TimerProc)(int);
+
 #ifdef __MORPHOS__
 #include "morphos/morphos_timer.h"
 #else
@@ -33,34 +35,31 @@
 
 class Timer {
 
-protected:
-
 private:
-	OSystem * _osystem;
-	Scumm * _scumm;
+	OSystem *_osystem;
+	Scumm *_scumm;
 	bool _initialized;
 	bool _timerRunning;
-	void * _timerHandler;
+	void *_timerHandler;
 	int32 _thisTime;
 	int32 _lastTime;
-	void * _mutex;
+	void *_mutex;
 
-struct TimerSlots
-{
-	int ((*procedure)(int));
-	int32 interval;
-	int32 counter;
-} _timerSlots [MAX_TIMERS];
+	struct TimerSlots {
+		int ((*procedure) (int));
+		int32 interval;
+		int32 counter;
+	} _timerSlots[MAX_TIMERS];
 
 public:
-	Timer(Scumm * system);
-	~Timer();
+	  Timer(Scumm *system);
+	 ~Timer();
 
-	int handler(int * t);
+	int handler(int *t);
 	bool init();
 	void release();
-	bool installProcedure (int ((*procedure)(int)), int32 interval);
-	void releaseProcedure (int ((*procedure)(int)));
+	bool installProcedure(TimerProc procedure, int32 interval);
+	void releaseProcedure(TimerProc procedure);
 };
 
 #endif





More information about the Scummvm-git-logs mailing list