removed duplicate g_timer object (one was global, one was static to timer.cpp); set g_system earlier (might prevent a few race conditions)

svn-id: r10471
This commit is contained in:
Max Horn 2003-09-28 21:08:48 +00:00
parent 84ed3e272d
commit 17bf7b95aa
10 changed files with 17 additions and 27 deletions

View File

@ -22,7 +22,6 @@
#include "sound/mididrv.h"
#include "sound/fmopl.h"
#include "sound/mixer.h"
#include "base/engine.h" // for g_system
#include "common/util.h"
#define BASE_FREQ 250

View File

@ -31,7 +31,6 @@
#include "stdafx.h"
#include "sound/mpu401.h"
#include "base/engine.h" // for g_system
#include "common/util.h"
#include "morphos.h"
#include "morphos_sound.h"

View File

@ -20,7 +20,6 @@
#include "stdafx.h"
#include "sound/mpu401.h"
#include "base/engine.h" // for g_system
#include "common/util.h"
#include "Pa1Lib.h"

View File

@ -29,7 +29,6 @@
#include "sound/mixer.h"
/* FIXME - BIG HACK for MidiEmu */
OSystem *g_system = 0;
Engine *g_engine = 0;
Engine::Engine(GameDetector *detector, OSystem *syst)
@ -39,9 +38,6 @@ Engine::Engine(GameDetector *detector, OSystem *syst)
_gameDataPath = detector->_gameDataPath;
g_system = _system; // FIXME - BIG HACK for MidiEmu
extern Timer *g_timer;
_timer = g_timer;
}

View File

@ -49,7 +49,7 @@ enum GameId {
GID_SWORD2_FIRST,
GID_SWORD2_LAST = GID_SWORD2_FIRST + 9,
//Flight of the Amazon Queen
// Flight of the Amazon Queen
GID_QUEEN_FIRST,
GID_QUEEN_LAST = GID_QUEEN_FIRST + 9
};
@ -60,9 +60,6 @@ class GameDetector;
class Timer;
struct TargetSettings;
/* FIXME - BIG HACK for MidiEmu */
extern OSystem *g_system;
class Engine {
public:
OSystem *_system;

View File

@ -85,7 +85,7 @@ const char *gScummVMFullVersion = "ScummVM 0.5.3cvs (" __DATE__ " " __TIME__ ")"
Config *g_config = 0;
NewGui *g_gui = 0;
Timer *g_timer = 0;
OSystem *g_system = 0;
#if defined(WIN32) && defined(NO_CONSOLE)
#include <cstdio>
@ -197,10 +197,6 @@ static void launcherDialog(GameDetector &detector, OSystem *system) {
system->set_palette(dummy_palette, 0, 16);
// FIXME - hack we use because LauncherDialog accesses g_system
extern OSystem *g_system;
g_system = system;
LauncherDialog dlg(g_gui, detector);
dlg.runModal();
}
@ -281,6 +277,7 @@ int main(int argc, char *argv[]) {
// Create the system object
OSystem *system = detector.createSystem();
g_system = system;
// Set initial window caption
prop.caption = "ScummVM";
@ -309,7 +306,7 @@ int main(int argc, char *argv[]) {
}
// Create the timer services
g_timer = new Timer (system);
g_timer = new Timer(system);
// Create the game engine
Engine *engine = detector.createEngine(system);

View File

@ -349,4 +349,7 @@ public:
//@}
};
/** The global OSystem instance. Inited in main(). */
extern OSystem *g_system;
#endif

View File

@ -25,7 +25,7 @@
#include "common/timer.h"
#include "common/util.h"
static Timer *g_timer = NULL;
Timer *g_timer = NULL;
Timer::Timer(OSystem *system) :
_system(system),

View File

@ -60,6 +60,8 @@ protected:
int handler(int t);
};
extern Timer *g_timer;
#endif
#endif

View File

@ -24,8 +24,6 @@
#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;
_channel = channel;
@ -45,7 +43,7 @@ void MidiChannel_MPU401::noteOff (byte note) {
}
void MidiChannel_MPU401::noteOn(byte note, byte velocity) {
_owner->send (velocity << 16 | note << 8 | 0x90 | _channel);
_owner->send(velocity << 16 | note << 8 | 0x90 | _channel);
}
void MidiChannel_MPU401::programChange(byte program) {
@ -61,11 +59,11 @@ void MidiChannel_MPU401::controlChange(byte control, byte value) {
}
void MidiChannel_MPU401::pitchBendFactor(byte value) {
_owner->setPitchBendRange (_channel, value);
_owner->setPitchBendRange(_channel, value);
}
void MidiChannel_MPU401::sysEx_customInstrument(uint32 type, byte *instr) {
_owner->sysEx_customInstrument (_channel, type, instr);
_owner->sysEx_customInstrument(_channel, type, instr);
}
const char *MidiDriver::getErrorName(int error_code) {
@ -96,7 +94,7 @@ MidiDriver_MPU401::MidiDriver_MPU401() :
void MidiDriver_MPU401::close() {
if (_timer_proc)
g_timer->releaseProcedure (_timer_proc);
g_timer->releaseProcedure(_timer_proc);
_timer_proc = 0;
for (int i = 0; i < 16; ++i)
send (0x7B << 8 | 0xB0 | i);
@ -122,7 +120,7 @@ MidiChannel *MidiDriver_MPU401::allocateChannel() {
chan = &_midi_channels[i];
if (!chan->_allocated) {
chan->allocate();
return (chan);
return chan;
}
}
return NULL;
@ -131,9 +129,9 @@ MidiChannel *MidiDriver_MPU401::allocateChannel() {
void MidiDriver_MPU401::setTimerCallback (void *timer_param, TimerProc timer_proc) {
if (!_timer_proc || !timer_proc) {
if (_timer_proc)
g_timer->releaseProcedure (_timer_proc);
g_timer->releaseProcedure(_timer_proc);
_timer_proc = timer_proc;
if (timer_proc)
g_timer->installProcedure (timer_proc, 10000, timer_param);
g_timer->installProcedure(timer_proc, 10000, timer_param);
}
}