Timer services are now available through g_timer, so

you don't have to go through the Engine to get to them.

svn-id: r10450
This commit is contained in:
Jamieson Christian 2003-09-27 23:59:00 +00:00
parent 072bf0f476
commit 4dcb829e78
3 changed files with 11 additions and 6 deletions

View File

@ -41,7 +41,8 @@ Engine::Engine(GameDetector *detector, OSystem *syst)
g_system = _system; // FIXME - BIG HACK for MidiEmu
_timer = new Timer(_system);
extern Timer *g_timer;
_timer = g_timer;
}
Engine::~Engine() {

View File

@ -34,6 +34,7 @@
#include "base/plugins.h"
#include "common/config-file.h"
#include "common/scaler.h" // For GFX_NORMAL
#include "common/timer.h"
#include "gui/newgui.h"
#include "gui/launcher.h"
#include "gui/message.h"
@ -84,6 +85,7 @@ const char *gScummVMFullVersion = "ScummVM 0.5.3cvs (" __DATE__ " " __TIME__ ")"
Config *g_config = 0;
NewGui *g_gui = 0;
Timer *g_timer = 0;
#if defined(WIN32) && defined(NO_CONSOLE)
#include <cstdio>
@ -305,6 +307,9 @@ int main(int argc, char *argv[]) {
prop.gfx_mode = GFX_NORMAL;
system->property(OSystem::PROP_SET_GFX_MODE, &prop);
}
// Create the timer services
g_timer = new Timer (system);
// Create the game engine
Engine *engine = detector.createEngine(system);

View File

@ -24,6 +24,7 @@
#include "common/timer.h"
#include "common/util.h" // for ARRAYSIZE
extern Timer *g_timer;
void MidiChannel_MPU401::init(MidiDriver_MPU401 *owner, byte channel) {
_owner = owner;
@ -94,9 +95,8 @@ MidiDriver_MPU401::MidiDriver_MPU401() :
}
void MidiDriver_MPU401::close() {
// FIXME: I'd really prefer a g_timer instead of going through g_engine
if (_timer_proc)
g_engine->_timer->releaseProcedure (_timer_proc);
g_timer->releaseProcedure (_timer_proc);
_timer_proc = 0;
for (int i = 0; i < 16; ++i)
send (0x7B << 8 | 0xB0 | i);
@ -129,12 +129,11 @@ MidiChannel *MidiDriver_MPU401::allocateChannel() {
}
void MidiDriver_MPU401::setTimerCallback (void *timer_param, TimerProc timer_proc) {
// FIXME: I'd really prefer a g_timer instead of going through g_engine
if (!_timer_proc || !timer_proc) {
if (_timer_proc)
g_engine->_timer->releaseProcedure (_timer_proc);
g_timer->releaseProcedure (_timer_proc);
_timer_proc = timer_proc;
if (timer_proc)
g_engine->_timer->installProcedure (timer_proc, 10000, timer_param);
g_timer->installProcedure (timer_proc, 10000, timer_param);
}
}