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 | |
| 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
| -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 | ||||
| -rw-r--r-- | scumm/scummvm.cpp | 7 | ||||
| -rw-r--r-- | scumm/smush/scumm_renderer.cpp | 2 | ||||
| -rw-r--r-- | scumm/sound.cpp | 4 | 
8 files changed, 29 insertions, 34 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); diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index b04b0999ba..e67fbbc311 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -44,9 +44,9 @@ extern void GraphicsOff(void);  Scumm *g_scumm = 0; -void autosave(Scumm * scumm) +void autosave(void * engine)  { -	scumm->_doAutosave = true; +	g_scumm->_doAutosave = true;  }  void Scumm::initRandSeeds() @@ -106,8 +106,8 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)  	_newgui = new NewGui(this);  	_bundle = new Bundle(); -	_timer = new Timer(this);  	_sound = new Sound(this); +	_timer = Engine::_timer;  	_sound->_sound_volume_master = 0;  	_sound->_sound_volume_sfx = detector->_sfx_volume;	 @@ -159,7 +159,6 @@ Scumm::~Scumm ()  	delete _gui;  	delete _newgui;  	delete _bundle; -	delete _timer;  	delete _sound;  	delete _imuse;  	if (_existLanguageFile) delete _languageBuffer; diff --git a/scumm/smush/scumm_renderer.cpp b/scumm/smush/scumm_renderer.cpp index db09d5ccd6..184d03e4b7 100644 --- a/scumm/smush/scumm_renderer.cpp +++ b/scumm/smush/scumm_renderer.cpp @@ -198,7 +198,7 @@ ScummRenderer::ScummRenderer(Scumm * scumm, uint32 speed) :  static ScummRenderer * s_renderer; -static void smush_handler(Scumm * scumm) { +static void smush_handler(void * engine) {  	s_renderer->update();  } diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 5a0174afcc..2568edc606 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -828,8 +828,8 @@ uint32 Sound::decode12BitsSample(byte * src, byte ** dst, uint32 size) {  	return r;  } -static void music_handler (Scumm * scumm) { -	scumm->_sound->bundleMusicHandler(scumm); +static void music_handler (void * engine) { +	g_scumm->_sound->bundleMusicHandler(g_scumm);  }  #define OUTPUT_SIZE 66150 // ((22050 * 2 * 2) / 4) * 3 | 
