[Scummvm-cvs-logs] CVS: scummvm/common engine.cpp,1.3,1.4 engine.h,1.3,1.4 system.h,1.3,1.4 timer.cpp,1.3,1.4 timer.h,1.3,1.4

Pawe? Ko?odziejski aquadran at users.sourceforge.net
Wed Sep 18 03:23:04 CEST 2002


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

Modified Files:
	engine.cpp engine.h system.h timer.cpp timer.h 
Log Message:
Timer is handled in Engine now

Index: engine.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/engine.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- engine.cpp	8 Sep 2002 01:08:11 -0000	1.3
+++ engine.cpp	18 Sep 2002 10:22:35 -0000	1.4
@@ -40,11 +40,13 @@
 	/* FIXME - BIG HACK for MidiEmu */
 	g_system = _system;
 	g_mixer = _mixer;
+	_timer = new Timer(this);
 }
 
 Engine::~Engine()
 {
 	delete _mixer;
+	delete _timer;
 }
 
 const char *Engine::getSavePath() const

Index: engine.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/engine.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- engine.h	8 Sep 2002 01:08:11 -0000	1.3
+++ engine.h	18 Sep 2002 10:22:35 -0000	1.4
@@ -38,6 +38,7 @@
 public:
 	OSystem *_system;
 	SoundMixer *_mixer;
+	Timer * _timer;
 
 protected:
 	char *_gameDataPath;

Index: system.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/system.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- system.h	9 Sep 2002 05:56:10 -0000	1.3
+++ system.h	18 Sep 2002 10:22:35 -0000	1.4
@@ -25,6 +25,8 @@
 
 #include "scummsys.h"
 
+class Timer;
+
 // Interface to the ScummVM backend
 
 class OSystem {

Index: timer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/timer.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- timer.cpp	8 Sep 2002 01:08:11 -0000	1.3
+++ timer.cpp	18 Sep 2002 10:22:35 -0000	1.4
@@ -23,26 +23,22 @@
 #include "stdafx.h"
 #include "scummsys.h"
 #include "timer.h"
-#include "scumm/scumm.h"
 
-// FIXME - this shouldn't use Scumm, but rather Engine (so that e.g. we can
-// reuse the code for Simon).
-
-static Scumm * scumm;
+static Engine * eng;
 
-Timer::Timer(Scumm * parent) {
+Timer::Timer(Engine * engine) {
 	_initialized = false;
 	_timerRunning = false;
-	scumm = _scumm = parent;
+	eng = _engine = engine;
 }
 
 Timer::~Timer() {
-	release ();
+	release();
 }
 
 static int timer_handler (int t)
 {
-	scumm->_timer->handler (&t);
+	eng->_timer->handler(&t);
 	return t;
 }
 
@@ -51,7 +47,7 @@
 
 	if (_timerRunning) {
 		_lastTime = _thisTime;
-		_thisTime = _osystem->get_msecs();
+		_thisTime = _engine->_system->get_msecs();
 		interval = _thisTime - _lastTime;
 
 		for (l = 0; l < MAX_TIMERS; l++) {
@@ -59,7 +55,7 @@
 				_timerSlots[l].counter -= interval;
 				if (_timerSlots[l].counter <= 0) {
 					_timerSlots[l].counter += _timerSlots[l].interval;
-					_timerSlots[l].procedure (_scumm);
+					_timerSlots[l].procedure (_engine);
 				}
 			}
 		}
@@ -71,11 +67,10 @@
 bool Timer::init() {
 	int32 l;
 
-	_osystem = _scumm->_system;
-	if (_osystem == NULL) {
-		printf("Timer: OSystem not initialized !\n");
-		return false;
-	}
+	if (_engine->_system == NULL) {
+ 		printf("Timer: OSystem not initialized !\n");
+ 		return false;
+ 	}
 
 	if (_initialized == true) 
 		return true;
@@ -86,8 +81,8 @@
 		_timerSlots[l].counter = 0;
 	}
 
-	_thisTime = _osystem->get_msecs();
-	_osystem->set_timer (10, &timer_handler);
+	_thisTime = _engine->_system->get_msecs();
+	_engine->_system->set_timer(10, &timer_handler);
 
 	_timerRunning = true;
 	_initialized = true;
@@ -101,7 +96,7 @@
 		return;
 
 	_timerRunning = false;
-	_osystem->set_timer (0, NULL);
+	_engine->_system->set_timer(0, NULL);
 	_initialized = false;
 
 	for (l = 0; l < MAX_TIMERS; l++) {

Index: timer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/timer.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- timer.h	31 Aug 2002 09:50:35 -0000	1.3
+++ timer.h	18 Sep 2002 10:22:35 -0000	1.4
@@ -22,24 +22,20 @@
 #define TIMER_H
 
 #include "scummsys.h"
+#include "engine.h"
 
 #define MAX_TIMERS 5
 
-class Scumm;
-
-typedef void (*TimerProc)(Scumm *);
+typedef void (*TimerProc)(void *);
 
 #ifdef __MORPHOS__
 #include "morphos_timer.h"
 #else
 
-class OSystem;
-
 class Timer {
 
 private:
-	OSystem *_osystem;
-	Scumm *_scumm;
+	Engine *_engine;
 	bool _initialized;
 	bool _timerRunning;
 	void *_timerHandler;
@@ -53,7 +49,7 @@
 	} _timerSlots[MAX_TIMERS];
 
 public:
-	  Timer(Scumm *system);
+	  Timer(Engine *engine);
 	 ~Timer();
 
 	int handler(int *t);





More information about the Scummvm-git-logs mailing list