Ticket #8349: timer-v6.patch

File timer-v6.patch, 30.0 KB (added by fingolfin, 20 years ago)
  • backends/midi/adlib.cpp

    RCS file: /cvsroot/scummvm/scummvm/backends/midi/adlib.cpp,v
    retrieving revision 1.58
    diff -u -d -r1.58 adlib.cpp
     
    1919 */
    2020
    2121#include "stdafx.h"
     22
     23#include "common/system.h"
     24#include "common/util.h"
     25
    2226#include "sound/mididrv.h"
    2327#include "sound/fmopl.h"
    2428#include "sound/mixer.h"
    25 #include "common/util.h"
    2629
    2730#define BASE_FREQ 250
    2831#define FIXP_SHIFT 16
     
    559562        void setPitchBendRange(byte channel, uint range);
    560563        void sysEx_customInstrument(byte channel, uint32 type, byte *instr);
    561564
    562         void setTimerCallback(void *timer_param, Timer::TimerProc timer_proc);
     565        void setTimerCallback(void *timer_param, OSystem::TimerProc timer_proc);
    563566        uint32 getBaseTempo() {
    564567                return 1000000 / BASE_FREQ;
    565568        }
     
    575578        byte *_adlib_reg_cache;
    576579        SoundMixer *_mixer;
    577580
    578         Timer::TimerProc _timer_proc;
     581        OSystem::TimerProc _timer_proc;
    579582        void *_timer_param;
    580583
    581584        int _adlib_timer_counter;
     
    964967        _parts[channel].sysEx_customInstrument(type, instr);
    965968}
    966969
    967 void MidiDriver_ADLIB::setTimerCallback(void *timer_param, Timer::TimerProc timer_proc) {
     970void MidiDriver_ADLIB::setTimerCallback(void *timer_param, OSystem::TimerProc timer_proc) {
    968971        _timer_proc = timer_proc;
    969972        _timer_param = timer_param;
    970973}
  • backends/midi/ym2612.cpp

    RCS file: /cvsroot/scummvm/scummvm/backends/midi/ym2612.cpp,v
    retrieving revision 1.23
    diff -u -d -r1.23 ym2612.cpp
     
    2323 */
    2424
    2525#include "stdafx.h"
     26
     27#include "common/system.h"
    2628#include "common/util.h"
     29
    2730#include "sound/mididrv.h"
    2831#include "sound/mixer.h"
    2932
     
    166169
    167170        bool _isOpen;
    168171        SoundMixer *_mixer;
    169         Timer::TimerProc _timer_proc;
     172        OSystem::TimerProc _timer_proc;
    170173        void *_timer_param;
    171174        int _next_tick;
    172175        int _samples_per_tick;
     
    193196        void setPitchBendRange(byte channel, uint range) { }
    194197        void sysEx(byte *msg, uint16 length);
    195198
    196         void setTimerCallback(void *timer_param, Timer::TimerProc timer_proc);
     199        void setTimerCallback(void *timer_param, OSystem::TimerProc timer_proc);
    197200        uint32 getBaseTempo() { return 1000000 / BASE_FREQ; }
    198201
    199202        MidiChannel *allocateChannel() { return 0; }
     
    768771        _mixer->setupPremix(0, 0);
    769772}
    770773
    771 void MidiDriver_YM2612::setTimerCallback(void *timer_param, Timer::TimerProc timer_proc) {
     774void MidiDriver_YM2612::setTimerCallback(void *timer_param, OSystem::TimerProc timer_proc) {
    772775        _timer_proc = timer_proc;
    773776        _timer_param = timer_param;
    774777}
  • backends/sdl/sdl-common.h

    RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl-common.h,v
    retrieving revision 1.62
    diff -u -d -r1.62 sdl-common.h
     
    3030#include "backends/intern.h"
    3131
    3232#include <SDL.h>
     33#include <SDL_thread.h>
    3334
    3435#ifndef _WIN32_WCE
    3536// Uncomment this to enable the 'on screen display' code.
    3637#define USE_OSD 1
    3738#endif
    3839
     40#ifndef OLD_TIMER
    3941class OSystem_SDL : public OSystem {
     42#else
     43class OSystem_SDL : public OSystemWithDefaultTimerCode {
     44#endif
    4045public:
    4146        OSystem_SDL();
    4247        virtual ~OSystem_SDL();
     
    103108        void quit();
    104109
    105110
     111#ifdef OLD_TIMER
    106112        // Add a callback timer
    107         void setTimerCallback(TimerProc callback, int timer);
    108 
     113        void setTimerCallback(TimerCallback callback, int timer);
     114#else
     115        // Install/Remove callback timer
     116        bool installTimerProc(TimerProc procedure, int32 interval, void *refCon);
     117        void removeTimerProc(TimerProc procedure);
     118#endif
    109119        // Mutex handling
    110120        MutexRef createMutex();
    111121        void lockMutex(MutexRef mutex);
     
    208218        bool cksum_valid;
    209219        int CKSUM_NUM;
    210220
     221#ifndef OLD_TIMER
     222        // Timer Management
     223        #define SDL_MAX_TIMERS 5
     224        #define THREAD_RUN 0
     225        #define THREAD_REMOVE 1
     226
     227        class TimerSlot {
     228        friend class OSystem_SDL;
     229        private:
     230                TimerProc _threadFunc;
     231                SDL_Thread *_threadHandle;
     232                int _threadState;
     233                double _interval;
     234                void *_refCon;
     235                double _startTime;
     236                double _lastTime;
     237
     238                bool wait();
     239                void thread();
     240        public:
     241                static int threadHandler(void *slotRef);
     242        } _timerSlots[SDL_MAX_TIMERS];
     243
     244        MutexRef _timerMutex;
     245
     246        bool createTimer();
     247        void deleteTimer();
     248        void resetTimerSlot(int slot);
     249#endif
     250
    211251        // Keyboard mouse emulation
    212252        struct KbdMouse {       
    213253                int16 x, y, x_vel, y_vel, x_max, y_max, x_down_count, y_down_count;
  • backends/sdl/sdl.cpp

    RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v
    retrieving revision 1.72
    diff -u -d -r1.72 sdl.cpp
     
    8181        setup_icon();
    8282#endif
    8383
     84#ifndef OLD_TIMER
     85        createTimer();
     86#endif
     87
    8488        // enable joystick
    8589        if (joystick_num > -1 && SDL_NumJoysticks() > 0) {
    8690                printf("Using joystick: %s\n", SDL_JoystickName(0));
     
    118122OSystem_SDL::~OSystem_SDL() {
    119123//      unload_gfx_mode();
    120124
     125#ifndef OLD_TIMER
     126        deleteTimer();
     127#endif
     128
    121129        if (_dirty_checksums)
    122130                free(_dirty_checksums);
    123131        free(_currentPalette);
     
    136144        SDL_Delay(msecs);
    137145}
    138146
    139 void OSystem_SDL::setTimerCallback(TimerProc callback, int timer) {
     147#ifdef OLD_TIMER
     148void OSystem_SDL::setTimerCallback(TimerCallback callback, int timer) {
    140149        SDL_SetTimer(timer, (SDL_TimerCallback) callback);
    141150}
     151#else
     152
     153bool OSystem_SDL::createTimer() {
     154        _timerMutex = createMutex();
     155
     156        for (int i = 0; i < SDL_MAX_TIMERS; i++) {
     157                resetTimerSlot(i);
     158        }
     159
     160        return true;
     161}
     162
     163void OSystem_SDL::deleteTimer() {
     164        {
     165                Common::StackLock lock(_timerMutex);
     166                for (int i = 0; i < SDL_MAX_TIMERS; i++) {
     167                        if (_timerSlots[i]._threadFunc) {
     168                                _timerSlots[i]._threadState = THREAD_REMOVE;
     169                                SDL_WaitThread(_timerSlots[i]._threadHandle, NULL);
     170                                resetTimerSlot(i);
     171                        }
     172                }
     173        }
     174
     175        deleteMutex(_timerMutex);
     176}
     177
     178void OSystem_SDL::resetTimerSlot(int slot) {
     179        _timerSlots[slot]._threadHandle = NULL;
     180        _timerSlots[slot]._threadFunc = NULL;
     181        _timerSlots[slot]._threadState = THREAD_REMOVE;
     182        _timerSlots[slot]._interval = 0.0;
     183        _timerSlots[slot]._refCon = NULL;
     184        _timerSlots[slot]._startTime = 0.0;
     185        _timerSlots[slot]._lastTime = 0.0;
     186}
     187
     188bool OSystem_SDL::installTimerProc(TimerProc procedure, int32 interval, void *refCon) {
     189        assert(interval > 0);
     190        Common::StackLock lock(_timerMutex);
     191
     192        for (int i = 0; i < SDL_MAX_TIMERS; i++) {
     193                if (!_timerSlots[i]._threadFunc) {
     194                        _timerSlots[i]._threadFunc = procedure;
     195                        _timerSlots[i]._interval = interval;
     196                        _timerSlots[i]._refCon = refCon;
     197                        _timerSlots[i]._startTime = SDL_GetTicks() * 1000.0;
     198                        _timerSlots[i]._lastTime = _timerSlots[i]._startTime;
     199                        _timerSlots[i]._threadState = THREAD_RUN;
     200                        _timerSlots[i]._threadHandle = SDL_CreateThread(_timerSlots[i].threadHandler, (void *)&_timerSlots[i]);
     201                        if (_timerSlots[i]._threadHandle == NULL) {
     202                                resetTimerSlot(i);
     203                                warning("SDL Timer, installTimerProc() Couldn't create thread!");
     204                                return false;
     205                        }
     206                        return true;
     207                }
     208        }
     209
     210        warning("SDL Timer, installTimerProc() Couldn't find free timer slot!");
     211        return false;
     212}
     213
     214void OSystem_SDL::removeTimerProc(TimerProc procedure) {
     215        assert(procedure);
     216        Common::StackLock lock(_timerMutex);
     217
     218        for (int i = 0; i < SDL_MAX_TIMERS; i++) {
     219                if (_timerSlots[i]._threadFunc == procedure) {
     220                        _timerSlots[i]._threadState = THREAD_REMOVE;
     221                        SDL_WaitThread(_timerSlots[i]._threadHandle, NULL);
     222                        resetTimerSlot(i);
     223                }
     224        }
     225}
     226
     227bool OSystem_SDL::TimerSlot::wait() {
     228        double interval = 0.0;
     229
     230        if (_threadState == THREAD_REMOVE) {
     231                return false;
     232        }
     233
     234        double currentTime = SDL_GetTicks() * 1000.0;
     235
     236        if ((currentTime - _lastTime) < _interval) {
     237                double elapsedTime = (currentTime - _startTime);
     238                interval = _interval - (elapsedTime - ((uint32)(elapsedTime / _interval) * _interval));
     239        }
     240
     241        SDL_Delay((uint32)(interval / 1000.0));
     242        _lastTime = SDL_GetTicks() * 1000.0;
     243
     244        return true;
     245}
     246
     247void OSystem_SDL::TimerSlot::thread() {
     248        do {
     249                (_threadFunc)(_refCon);
     250        } while (wait());
     251}
     252
     253int OSystem_SDL::TimerSlot::threadHandler(void *slotRef) {
     254        TimerSlot *slot = (TimerSlot *)slotRef;
     255        slot->thread();
     256        return 0;
     257}
     258#endif
    142259
    143260void OSystem_SDL::setWindowCaption(const char *caption) {
    144261        SDL_WM_SetCaption(caption, caption);
  • backends/wince/wince-sdl.cpp

    RCS file: /cvsroot/scummvm/scummvm/backends/wince/wince-sdl.cpp,v
    retrieving revision 1.14
    diff -u -d -r1.14 wince-sdl.cpp
     
    2626#include "base/gameDetector.h"
    2727#include "base/engine.h"
    2828#include "base/plugins.h"
    29 #include "common/timer.h"
    3029
    3130#include "common/config-manager.h"
    3231
  • base/engine.cpp

    RCS file: /cvsroot/scummvm/scummvm/base/engine.cpp,v
    retrieving revision 1.20
    diff -u -d -r1.20 engine.cpp
     
    2626#include "base/gameDetector.h"
    2727#include "common/config-manager.h"
    2828#include "common/file.h"
    29 #include "common/timer.h"
    3029#include "sound/mixer.h"
    3130
    3231/* FIXME - BIG HACK for MidiEmu */
     
    3938        g_engine = this;
    4039        _mixer = GameDetector::createMixer();
    4140
    42         _timer = g_timer;
    43 
    4441        // Add default file directory
    4542        File::addDefaultDirectory(_gameDataPath);
    4643
  • base/engine.h

    RCS file: /cvsroot/scummvm/scummvm/base/engine.h,v
    retrieving revision 1.12
    diff -u -d -r1.12 engine.h
     
    2626#include "common/system.h"
    2727
    2828class SoundMixer;
    29 class Timer;
    3029
    3130class Engine {
    3231public:
    3332        OSystem *_system;
    3433        SoundMixer *_mixer;
    35         Timer * _timer;
    3634
    3735protected:
    3836        const Common::String _gameDataPath;
  • base/main.cpp

    RCS file: /cvsroot/scummvm/scummvm/base/main.cpp,v
    retrieving revision 1.48
    diff -u -d -r1.48 main.cpp
     
    3636#include "common/config-manager.h"
    3737#include "common/file.h"
    3838#include "common/scaler.h"      // For GFX_NORMAL
    39 #include "common/timer.h"
    4039#include "gui/newgui.h"
    4140#include "gui/launcher.h"
    4241#include "gui/message.h"
     
    365364        // at an earlier point, though!)
    366365        OSystem *system = OSystem::instance();
    367366
    368         // Create the timer services
    369         g_timer = new Timer(system);
    370 
    371367        // Set initial window caption
    372368        system->setWindowCaption(gScummVMFullVersion);
    373369
     
    394390        //}
    395391
    396392        // ...and quit (the return 0 should never be reached)
    397         delete g_timer;
    398393        system->quit();
    399394        delete system;
    400395        return 0;
  • common/module.mk

    RCS file: /cvsroot/scummvm/scummvm/common/module.mk,v
    retrieving revision 1.18
    diff -u -d -r1.18 module.mk
     
    66        common/md5.o \
    77        common/str.o \
    88        common/stream.o \
    9         common/timer.o \
    109        common/util.o \
    1110        common/savefile.o \
    1211        common/system.o
  • common/system.cpp

    RCS file: /cvsroot/scummvm/scummvm/common/system.cpp,v
    retrieving revision 1.12
    diff -u -d -r1.12 system.cpp
     
    5959}
    6060
    6161OSystem *OSystem::instance() {
    62         if (!s_system)
     62        if (!s_system) {
    6363                s_system = createSystem();
     64                assert(s_system);
     65                s_system->init();
     66        }
    6467        return s_system;
    6568}
    6669
     
    9295        dialog.runModal();
    9396}
    9497
     98#pragma mark -
     99
    95100SaveFileManager *OSystem::get_savefile_manager() {
    96101        return new DefaultSaveFileManager();
    97102}
    98103
     104OSystemWithDefaultTimerCode::OSystemWithDefaultTimerCode() {
     105        _timerMutex = NULL;
     106        _timerCallback = NULL;
     107        _timerLastTime = 0;
     108}
     109
     110void OSystemWithDefaultTimerCode::init() {
     111        _timerMutex = createMutex();
     112
     113        for (int i = 0; i < MAX_TIMERS; i++) {
     114                _timerSlots[i].procedure = NULL;
     115                _timerSlots[i].interval = 0;
     116                _timerSlots[i].counter = 0;
     117        }
     118
     119        _timerThisTime = get_msecs();
     120
     121        // Set the timer last, after everything has been initialised
     122        setTimerCallback(&timerCallback, 10);
     123}
     124
     125void OSystemWithDefaultTimerCode::deinit() {
     126        // Remove the timer callback.
     127        // Note: backends *must* gurantee that after this method call returns,
     128        // the handler is not in use anymore; else race condtions could occurs.
     129        setTimerCallback(0, 0);
     130
     131        {
     132                Common::StackLock lock(_timerMutex);
     133                for (int i = 0; i < MAX_TIMERS; i++) {
     134                        _timerSlots[i].procedure = NULL;
     135                        _timerSlots[i].interval = 0;
     136                        _timerSlots[i].counter = 0;
     137                }
     138        }
     139
     140        deleteMutex(_timerMutex);
     141}
     142
     143bool OSystemWithDefaultTimerCode::installTimerProc(TimerProc proc, int32 interval, void *refCon) {
     144        assert(interval > 0);
     145        Common::StackLock lock(_timerMutex);
     146
     147        for (int l = 0; l < MAX_TIMERS; l++) {
     148                if (!_timerSlots[l].procedure) {
     149                        _timerSlots[l].procedure = proc;
     150                        _timerSlots[l].interval = interval;
     151                        _timerSlots[l].counter = interval;
     152                        _timerSlots[l].refCon = refCon;
     153                        return true;
     154                }
     155        }
     156
     157        warning("Couldn't find free timer slot!");
     158        return false;
     159}
     160
     161void OSystemWithDefaultTimerCode::removeTimerProc(TimerProc proc) {
     162        Common::StackLock lock(_timerMutex);
     163
     164        for (int l = 0; l < MAX_TIMERS; l++) {
     165                if (_timerSlots[l].procedure == proc) {
     166                        _timerSlots[l].procedure = 0;
     167                        _timerSlots[l].interval = 0;
     168                        _timerSlots[l].counter = 1;     // Work around a problem when a timer proc removes its
     169                        _timerSlots[l].refCon = 0;
     170                }
     171        }
     172}
     173
     174int OSystemWithDefaultTimerCode::timerCallback(int t) {
     175        return ((OSystemWithDefaultTimerCode *)g_system)->timerMain(t);
     176}
     177
     178int OSystemWithDefaultTimerCode::timerMain(int t) {
     179        Common::StackLock lock(_timerMutex);
     180        uint32 interval, l;
     181
     182        _timerLastTime = _timerThisTime;
     183        _timerThisTime = get_msecs();
     184        interval = 1000 * (_timerThisTime - _timerLastTime);
     185
     186        for (l = 0; l < MAX_TIMERS; l++) {
     187                if (_timerSlots[l].procedure && _timerSlots[l].interval > 0) {
     188                        _timerSlots[l].counter -= interval;
     189                        while (_timerSlots[l].counter <= 0) {
     190                                // A small paranoia check which catches the case where
     191                                // a timer removes itself (which it never should do).
     192                                assert(_timerSlots[l].procedure && _timerSlots[l].interval > 0);
     193                                _timerSlots[l].counter += _timerSlots[l].interval;
     194                                _timerSlots[l].procedure(_timerSlots[l].refCon);
     195                        }
     196                }
     197        }
     198
     199        return t;
     200}
     201
    99202#pragma mark -
    100203
    101204
  • common/system.h

    RCS file: /cvsroot/scummvm/scummvm/common/system.h,v
    retrieving revision 1.68
    diff -u -d -r1.68 system.h
     
    4949         */
    5050        static OSystem *instance();
    5151
     52protected:
     53        /** Internal init function, called by instance(). */
     54        virtual void init() {}
     55
    5256public:
    5357
    5458        /** Empty virtual destructor. DO NOT REMOVE! */
     
    367371        /** @name Events and Time */
    368372        //@{
    369373
    370         typedef int (*TimerProc)(int interval);
    371 
    372374        /**
    373375         * The types of events backends may generate.
    374376         * @see Event
     
    454456        /** Delay/sleep for the specified amount of milliseconds. */
    455457        virtual void delay_msecs(uint msecs) = 0;
    456458
     459        typedef void (*TimerProc)(void *refCon);
    457460        /**
    458          * Set the timer callback, a function which is periodically invoked by the
    459          * backend. This can for example be done via a background thread.
    460          * There is at most one active timer; if this method is called while there
    461          * is already an active timer, then the new timer callback should replace
    462          * the previous one. In particular, passing a callback pointer value of 0
    463          * is legal and can be used to clear the current timer callback.
    464          * @see Common::Timer
    465          * @note The implementation of this method must be 'atomic' in the sense
    466          *       that when the method returns, the previously set callback must
    467          *       not be in use anymore (in particular, if timers are implemented
    468          *       via threads, then it must be ensured that the timer thread is
    469          *       not using the old callback function anymore).
     461         * Install a new timer callback. It will from now be called every interval microseconds.
     462         * The timer may be invoked from a separate thread. Hence any timer code should be
     463         * written following the same safety guidelines as any other threaded code.
    470464         *
    471          * @param callback      pointer to the callback. May be 0 to reset the timer
    472          * @param interval      the interval (in milliseconds) between invocations
    473          *                  of the callback
     465         * @note Although the interval is specified in microseconds, the actual timer resolution
     466         *       may be lower. In particular, with the SDL backend the timer resolution is 10ms.
     467         * @param proc          the callback
     468         * @param interval      the interval in which the timer shall be invoked (in microseconds)
     469         * @param refCon        an arbitrary void pointer; will be passed to the timer callback
     470         * @return      true if the timer was installed successfully, false otherwise
    474471         */
    475         virtual void setTimerCallback(TimerProc callback, int interval) = 0;
     472        virtual bool installTimerProc(TimerProc proc, int32 interval, void *refCon) = 0;
     473
     474        /**
     475         * Remove the given timer callback. It will not be invoked anymore.
     476         */
     477        virtual void removeTimerProc(TimerProc proc) = 0;
    476478
    477479        //@}
    478480
     
    627629        //@}
    628630};
    629631
     632
     633/**
     634 * This class provides a default implementation of the new OSystem timer API
     635 * by emulating it using the old timer API. This makes it easy to get old
     636 * backends to work with the new code, and also makes it easier to write new
     637 * backends from scratch.
     638 */
     639class OSystemWithDefaultTimerCode : public OSystem {
     640public:
     641        OSystemWithDefaultTimerCode();
     642
     643        bool installTimerProc(TimerProc proc, int32 interval, void *refCon);
     644        void removeTimerProc(TimerProc proc);
     645
     646        typedef int (*TimerCallback)(int interval);
     647
     648        /**
     649         * Set the timer callback, a function which is periodically invoked by the
     650         * backend. This can for example be done via a background thread.
     651         * There is at most one active timer; if this method is called while there
     652         * is already an active timer, then the new timer callback should replace
     653         * the previous one. In particular, passing a callback pointer value of 0
     654         * is legal and can be used to clear the current timer callback.
     655         * @see Common::Timer
     656         * @note The implementation of this method must be 'atomic' in the sense
     657         *       that when the method returns, the previously set callback must
     658         *       not be in use anymore (in particular, if timers are implemented
     659         *       via threads, then it must be ensured that the timer thread is
     660         *       not using the old callback function anymore).
     661         *
     662         * @param callback      pointer to the callback. May be 0 to reset the timer
     663         * @param interval      the interval (in milliseconds) between invocations
     664         *                  of the callback
     665         */
     666        virtual void setTimerCallback(TimerCallback callback, int interval) = 0;
     667
     668protected:
     669        void init();
     670
     671        // TODO: The deinit() methods currently is never called. However, that
     672        // should hopefully never be a problem, since the quit() method of classes
     673        // derived from this class should remove any timer callbacks anyway...
     674        void deinit();
     675
     676private:
     677        #define MAX_TIMERS 2
     678
     679        MutexRef _timerMutex;
     680        void *_timerCallback;
     681        int32 _timerThisTime;
     682        int32 _timerLastTime;
     683
     684        struct TimerSlots {
     685                TimerProc procedure;
     686                int32 interval;
     687                int32 counter;
     688                void *refCon;
     689        } _timerSlots[MAX_TIMERS];
     690
     691        static int timerCallback(int t);
     692        int timerMain(int t);
     693};
     694
    630695/** The global OSystem instance. Inited in main(). */
    631696#define g_system        (OSystem::instance())
    632697
  • queen/queen.cpp

    RCS file: /cvsroot/scummvm/scummvm/queen/queen.cpp,v
    retrieving revision 1.90
    diff -u -d -r1.90 queen.cpp
     
    2828
    2929#include "common/config-manager.h"
    3030#include "common/file.h"
    31 #include "common/timer.h"
    3231
    3332#include "queen/queen.h"
    3433#include "queen/bankman.h"
  • saga/render.cpp

    RCS file: /cvsroot/scummvm/scummvm/saga/render.cpp,v
    retrieving revision 1.31
    diff -u -d -r1.31 render.cpp
     
    3838#include "saga/objectmap.h"
    3939
    4040#include "saga/render.h"
    41 #include <common/timer.h>
    4241
    4342namespace Saga {
    4443
     
    6261        GAME_GetDisplayInfo(&disp_info);
    6362
    6463        // Initialize FPS timer callback
    65         g_timer->installTimerProc(&fpsTimerCallback, 1000000, this);
     64        system->installTimerProc(&fpsTimerCallback, 1000000, this);
    6665
    6766        // Create background buffer
    6867        _bg_buf_w = disp_info.logical_w;
  • scumm/midiparser_ro.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/midiparser_ro.cpp,v
    retrieving revision 1.6
    diff -u -d -r1.6 midiparser_ro.cpp
     
    2020 */
    2121
    2222#include "stdafx.h"
     23
     24#include "common/util.h"
     25
    2326#include "sound/midiparser.h"
    2427#include "sound/mididrv.h"
    25 #include "common/util.h"
    2628
    2729
    2830namespace Scumm {
  • scumm/sound.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
    retrieving revision 1.381
    diff -u -d -r1.381 sound.cpp
     
    2929#include "scumm/sound.h"
    3030
    3131#include "common/config-manager.h"
    32 #include "common/timer.h"
    3332#include "common/util.h"
    3433
    3534#include "sound/audiocd.h"
     
    11221121        else
    11231122                timer_interval = 101;
    11241123
    1125         _vm->_timer->removeTimerProc(&cd_timer_handler);
    1126         _vm->_timer->installTimerProc(&cd_timer_handler, 1000 * timer_interval, _vm);
     1124        _vm->_system->removeTimerProc(&cd_timer_handler);
     1125        _vm->_system->installTimerProc(&cd_timer_handler, 1000 * timer_interval, _vm);
    11271126}
    11281127
    11291128void Sound::stopCDTimer() {
    1130         _vm->_timer->removeTimerProc(&cd_timer_handler);
     1129        _vm->_system->removeTimerProc(&cd_timer_handler);
    11311130}
    11321131
    11331132void Sound::playCDTrack(int track, int numLoops, int startFrame, int duration) {
  • scumm/imuse_digi/dimuse.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi/dimuse.cpp,v
    retrieving revision 1.108
    diff -u -d -r1.108 dimuse.cpp
     
    1919 */
    2020
    2121#include "stdafx.h"
    22 #include "common/timer.h"
    2322
    2423#include "scumm/actor.h"
    2524#include "scumm/scumm.h"
     
    5554                _track[l] = new Track;
    5655                _track[l]->used = false;
    5756        }
    58         _vm->_timer->installTimerProc(timer_handler, 1000000 / _callbackFps, this);
     57        _vm->_system->installTimerProc(timer_handler, 1000000 / _callbackFps, this);
    5958}
    6059
    6160IMuseDigital::~IMuseDigital() {
    6261        stopAllSounds();
    63         _vm->_timer->removeTimerProc(timer_handler);
     62        _vm->_system->removeTimerProc(timer_handler);
    6463        for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
    6564                delete _track[l];
    6665        }
  • scumm/imuse_digi/dimuse_script.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi/dimuse_script.cpp,v
    retrieving revision 1.24
    diff -u -d -r1.24 dimuse_script.cpp
     
    1919 */
    2020
    2121#include "stdafx.h"
    22 #include "common/timer.h"
    2322
    2423#include "scumm/actor.h"
    2524#include "scumm/scumm.h"
  • scumm/imuse_digi/dimuse_track.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/imuse_digi/dimuse_track.cpp,v
    retrieving revision 1.33
    diff -u -d -r1.33 dimuse_track.cpp
     
    1919 */
    2020
    2121#include "stdafx.h"
    22 #include "common/timer.h"
    2322
    2423#include "scumm/actor.h"
    2524#include "scumm/scumm.h"
  • scumm/smush/smush_player.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_player.cpp,v
    retrieving revision 1.130
    diff -u -d -r1.130 smush_player.cpp
     
    2626#include "common/config-manager.h"
    2727#include "common/file.h"
    2828#include "common/util.h"
    29 #include "common/timer.h"
    3029
    3130#include "scumm/bomp.h"
    3231#include "scumm/imuse_digi/dimuse.h"
     
    255254        _vm->setDirtyColors(0, 255);
    256255        _dst = _vm->virtscr[0].getPixels(0, 0);
    257256        _smixer = new SmushMixer(_vm->_mixer);
    258         g_timer->installTimerProc(&timerCallback, _speed, this);
     257        _vm->_system->installTimerProc(&timerCallback, _speed, this);
    259258}
    260259
    261260void SmushPlayer::release() {
    262         _vm->_timer->removeTimerProc(&timerCallback);
     261        _vm->_system->removeTimerProc(&timerCallback);
    263262
    264263        _vm->_smushVideoShouldFinish = true;
    265264
  • sky/sky.cpp

    RCS file: /cvsroot/scummvm/scummvm/sky/sky.cpp,v
    retrieving revision 1.147
    diff -u -d -r1.147 sky.cpp
     
    2828
    2929#include "common/config-manager.h"
    3030#include "common/file.h"
    31 #include "common/timer.h"
    3231
    3332#include "sky/compact.h"
    3433#include "sky/control.h"
     
    296295        _skyMouse->useLogicInstance(_skyLogic);
    297296       
    298297        // initialize timer *after* _skyScreen has been initialized.
    299         _timer->installTimerProc(&timerHandler, 1000000 / 50, this); //call 50 times per second
     298        _system->installTimerProc(&timerHandler, 1000000 / 50, this); //call 50 times per second
    300299
    301300        _skyControl = new Control(_saveFileMan, _skyScreen, _skyDisk, _skyMouse, _skyText, _skyMusic, _skyLogic, _skySound, _system, getSavePath());
    302301        _skyLogic->useControlInstance(_skyControl);
  • sound/mididrv.h

    RCS file: /cvsroot/scummvm/scummvm/sound/mididrv.h,v
    retrieving revision 1.36
    diff -u -d -r1.36 mididrv.h
     
    2424#define SOUND_MIDIDRV_H
    2525
    2626#include "common/scummsys.h"
    27 #include "common/timer.h"
     27#include "common/system.h"
    2828
    2929class MidiChannel;
    3030class SoundMixer;
     
    125125        virtual void metaEvent (byte type, byte*data, uint16 length) { }
    126126
    127127        // Timing functions - MidiDriver now operates timers
    128         virtual void setTimerCallback (void *timer_param, Timer::TimerProc timer_proc) = 0;
     128        virtual void setTimerCallback (void *timer_param, OSystem::TimerProc timer_proc) = 0;
    129129        virtual uint32 getBaseTempo (void) = 0;
    130130
    131131        // Channel allocation functions
  • sound/mpu401.cpp

    RCS file: /cvsroot/scummvm/scummvm/sound/mpu401.cpp,v
    retrieving revision 1.26
    diff -u -d -r1.26 mpu401.cpp
     
    1919 */
    2020
    2121#include "stdafx.h"
    22 #include "mpu401.h"
    23 #include "common/timer.h"
     22
     23#include "common/system.h"
    2424#include "common/util.h"        // for ARRAYSIZE
    2525
     26#include "sound/mpu401.h"
     27
    2628void MidiChannel_MPU401::init(MidiDriver_MPU401 *owner, byte channel) {
    2729        _owner = owner;
    2830        _channel = channel;
     
    9395
    9496void MidiDriver_MPU401::close() {
    9597        if (_timer_proc)
    96                 g_timer->removeTimerProc(_timer_proc);
     98                g_system->removeTimerProc(_timer_proc);
    9799        _timer_proc = 0;
    98100        for (int i = 0; i < 16; ++i)
    99101                send (0x7B << 8 | 0xB0 | i);
     
    125127        return NULL;
    126128}
    127129
    128 void MidiDriver_MPU401::setTimerCallback(void *timer_param, Timer::TimerProc timer_proc) {
     130void MidiDriver_MPU401::setTimerCallback(void *timer_param, OSystem::TimerProc timer_proc) {
    129131        if (!_timer_proc || !timer_proc) {
    130132                if (_timer_proc)
    131                         g_timer->removeTimerProc(_timer_proc);
     133                        g_system->removeTimerProc(_timer_proc);
    132134                _timer_proc = timer_proc;
    133135                if (timer_proc)
    134                         g_timer->installTimerProc(timer_proc, 10000, timer_param);
     136                        g_system->installTimerProc(timer_proc, 10000, timer_param);
    135137        }
    136138}
  • sound/mpu401.h

    RCS file: /cvsroot/scummvm/scummvm/sound/mpu401.h,v
    retrieving revision 1.19
    diff -u -d -r1.19 mpu401.h
     
    2323#define SOUND_MPU401_H
    2424
    2525#include "stdafx.h"
     26
    2627#include "common/system.h"
    27 #include "mididrv.h"
     28
     29#include "sound/mididrv.h"
    2830
    2931////////////////////////////////////////
    3032//
     
    7173class MidiDriver_MPU401 : public MidiDriver {
    7274private:
    7375        MidiChannel_MPU401 _midi_channels [16];
    74         Timer::TimerProc _timer_proc;
     76        OSystem::TimerProc _timer_proc;
    7577        uint16 _channel_mask;
    7678
    7779public:
    7880        MidiDriver_MPU401();
    7981
    8082        virtual void close();
    81         void setTimerCallback(void *timer_param, Timer::TimerProc timer_proc);
     83        void setTimerCallback(void *timer_param, OSystem::TimerProc timer_proc);
    8284        uint32 getBaseTempo(void) { return 10000; }
    8385        uint32 property(int prop, uint32 param);
    8486
  • sword1/sword1.cpp

    RCS file: /cvsroot/scummvm/scummvm/sword1/sword1.cpp,v
    retrieving revision 1.51
    diff -u -d -r1.51 sword1.cpp
     
    2727#include "base/plugins.h"
    2828#include "common/config-manager.h"
    2929#include "common/file.h"
    30 #include "common/timer.h"
    3130
    3231#include "memman.h"
    3332#include "resman.h"