diff options
| author | Paweł Kołodziejski | 2002-09-18 10:22:36 +0000 |
|---|---|---|
| committer | Paweł Kołodziejski | 2002-09-18 10:22:36 +0000 |
| commit | 462d26937c17961834e4226add1766d273ecd517 (patch) | |
| tree | 87357adc7b555d818e18b384503f258f87c5bc96 /common | |
| parent | 9280c6bfbd9b6a39f4e61588f50dacdc80dbf305 (diff) | |
| download | scummvm-rg350-462d26937c17961834e4226add1766d273ecd517.tar.gz scummvm-rg350-462d26937c17961834e4226add1766d273ecd517.tar.bz2 scummvm-rg350-462d26937c17961834e4226add1766d273ecd517.zip | |
Timer is handled in Engine now
svn-id: r4964
Diffstat (limited to 'common')
| -rw-r--r-- | common/engine.cpp | 2 | ||||
| -rw-r--r-- | common/engine.h | 1 | ||||
| -rw-r--r-- | common/system.h | 2 | ||||
| -rw-r--r-- | common/timer.cpp | 33 | ||||
| -rw-r--r-- | common/timer.h | 12 |
5 files changed, 23 insertions, 27 deletions
diff --git a/common/engine.cpp b/common/engine.cpp index a31db7d641..7aa9100f81 100644 --- a/common/engine.cpp +++ b/common/engine.cpp @@ -40,11 +40,13 @@ Engine::Engine(GameDetector *detector, OSystem *syst) /* 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 diff --git a/common/engine.h b/common/engine.h index 944acce1c0..08874ec5c5 100644 --- a/common/engine.h +++ b/common/engine.h @@ -38,6 +38,7 @@ class Engine { public: OSystem *_system; SoundMixer *_mixer; + Timer * _timer; protected: char *_gameDataPath; diff --git a/common/system.h b/common/system.h index c0fabec1b4..97e7ebcca2 100644 --- a/common/system.h +++ b/common/system.h @@ -25,6 +25,8 @@ #include "scummsys.h" +class Timer; + // Interface to the ScummVM backend class OSystem { diff --git a/common/timer.cpp b/common/timer.cpp index 1c184a4d4e..1cb4dda6c6 100644 --- a/common/timer.cpp +++ b/common/timer.cpp @@ -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 Engine * eng; -static Scumm * scumm; - -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 @@ int Timer::handler(int * t) { 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 @@ int Timer::handler(int * t) { _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 @@ int Timer::handler(int * t) { 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 @@ bool Timer::init() { _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 @@ void Timer::release() { return; _timerRunning = false; - _osystem->set_timer (0, NULL); + _engine->_system->set_timer(0, NULL); _initialized = false; for (l = 0; l < MAX_TIMERS; l++) { diff --git a/common/timer.h b/common/timer.h index d575b73a4c..00a1a2f6b1 100644 --- a/common/timer.h +++ b/common/timer.h @@ -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 @@ private: } _timerSlots[MAX_TIMERS]; public: - Timer(Scumm *system); + Timer(Engine *engine); ~Timer(); int handler(int *t); |
