diff options
author | Matthew Hoops | 2011-09-15 20:39:37 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-09-15 20:39:37 -0400 |
commit | 1ac6abaeff4813d75abd4ac58a13e22eaef2ab71 (patch) | |
tree | ccc967c4c43cc10654805f9308879b878fe0e6dc /engines/pegasus/timers.h | |
parent | d3fde69770b5a3065fa3ae1da76e443d6d185147 (diff) | |
download | scummvm-rg350-1ac6abaeff4813d75abd4ac58a13e22eaef2ab71.tar.gz scummvm-rg350-1ac6abaeff4813d75abd4ac58a13e22eaef2ab71.tar.bz2 scummvm-rg350-1ac6abaeff4813d75abd4ac58a13e22eaef2ab71.zip |
PEGASUS: Stub off the base timebase code
This is not tested, and hopefully just works without anymore changes. I hate QuickTime :P
Diffstat (limited to 'engines/pegasus/timers.h')
-rwxr-xr-x | engines/pegasus/timers.h | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/engines/pegasus/timers.h b/engines/pegasus/timers.h index e4bb41086f..9ce3093820 100755 --- a/engines/pegasus/timers.h +++ b/engines/pegasus/timers.h @@ -26,6 +26,10 @@ #ifndef PEGASUS_TIMERS_H #define PEGASUS_TIMERS_H +#include "common/rational.h" + +#include "pegasus/constants.h" + namespace Pegasus { class Idler { @@ -45,6 +49,168 @@ protected: bool _isIdling; }; +enum { + kLoopTimeBase = 1, + kPalindromeLoopTimeBase = 2, + kMaintainTimeBaseZero = 4 +}; + +class TimeBaseCallBack; + +class TimeBase { +friend class TimeBaseCallBack; +public: + TimeBase(const TimeScale = kDefaultTimeScale); + virtual ~TimeBase(); + + virtual void setTime(const TimeValue, const TimeScale = 0); + virtual TimeValue getTime(const TimeScale = 0); + + virtual void setScale(const TimeScale scale) { _preferredScale = scale; } + virtual TimeScale getScale() const { return _preferredScale; } + + virtual void setRate(const Common::Rational); + virtual Common::Rational getRate() const { return _rate; } + + virtual void start(); + virtual void stop(); + virtual bool isRunning(); + + virtual void pause(); + virtual void resume(); + bool isPaused() const { return _paused; } + + virtual void setFlags(const uint32 flags) { _flags = flags; } + virtual uint32 getFlags() const { return _flags; } + + virtual void setStart(const TimeValue, const TimeScale = 0); + virtual TimeValue getStart(const TimeScale = 0) const; + + virtual void setStop(const TimeValue, const TimeScale = 0); + virtual TimeValue getStop(const TimeScale = 0) const; + + virtual void setSegment(const TimeValue, const TimeValue, const TimeScale = 0); + virtual void getSegment(TimeValue&, TimeValue&, const TimeScale = 0) const; + + virtual TimeValue getDuration(const TimeScale = 0) const; + + virtual void setMasterTimeBase(TimeBase *timeBase); + + void disposeAllCallBacks(); + + // ScummVM's API additions (to replace the need for actual timers) + void checkCallBacks(); + +protected: + void addCallBack(TimeBaseCallBack *); + void removeCallBack(TimeBaseCallBack *); + + TimeBase *_master; + TimeScale _preferredScale; + TimeBaseCallBack *_callBackList; + Common::Rational _rate, _pausedRate; + bool _paused; + uint32 _startTime, _startScale; + uint32 _stopTime, _stopScale; + int32 _timeOffset; + uint32 _flags; + TimeValue _pausedTime; + +private: + Common::Rational getEffectiveRate() const; + + Common::List<TimeBase *> _slaves; +}; + +// Type passed to initCallBack() +enum CallBackType { + kCallBackNone = 0, + kCallBackAtTime = 1, + kCallBackAtExtremes = 4 +}; + +// Trigger passed to scheduleCallBack() +enum CallBackTrigger { + kTriggerNone = 0, + + // AtTime flags + kTriggerTimeFwd = 1, + + // AtExtremes flags + kTriggerAtStart = 1, + kTriggerAtStop = 2 +}; + +class TimeBaseCallBack { +friend class TimeBase; + +public: + TimeBaseCallBack(); + virtual ~TimeBaseCallBack(); + + void initCallBack(TimeBase *, CallBackType type); + + void releaseCallBack(); + + void scheduleCallBack(CallBackTrigger trigger, uint32 param2, uint32 param3); + void cancelCallBack(); + +protected: + virtual void callBack() = 0; + + TimeBase *_timeBase; + + // Owned and operated by TimeBase; + TimeBaseCallBack *_nextCallBack; + + // Our storage of the QuickTime timer crap + CallBackType _type; + CallBackTrigger _trigger; + uint32 _param2, _param3; + +private: + void disposeCallBack(); +}; + +class IdlerTimeBase : public Idler, public TimeBase { +public: + IdlerTimeBase(); + virtual ~IdlerTimeBase() { stopIdling(); } + + TimeValue getLastTime() const { return _lastTime; } + +protected: + virtual void useIdleTime(); + virtual void timeChanged(const TimeValue) {} + + TimeValue _lastTime; + +}; + +class Notification; + +class NotificationCallBack : public TimeBaseCallBack { +public: + NotificationCallBack(); + virtual ~NotificationCallBack() {} + + void setNotification(Notification *notifier) { _notifier = notifier; } + + void setCallBackFlag(const tNotificationFlags flag) { _callBackFlag = flag; } + tNotificationFlags getCallBackFlag() const { return _callBackFlag; } + +protected: + void callBack(); + + Notification *_notifier; + tNotificationFlags _callBackFlag; +}; + +class DynamicElement : public TimeBase { +public: + TimeValue percentSeconds(const uint32 percent) { return getScale() * percent / 100; } +}; + } // End of namespace Pegasus #endif |