Skip to content

Commit

Permalink
PEGASUS: Fader values should be signed
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Hoops committed Sep 27, 2011
1 parent 02781cf commit 59d6b03
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions engines/pegasus/compass.cpp
Expand Up @@ -53,8 +53,8 @@ void Compass::deallocateCompass() {
_compassImage.deallocateSurface();
}

void Compass::setFaderValue(const uint32 angle) {
int16 a = (int32)angle % 360;
void Compass::setFaderValue(const int32 angle) {
int16 a = angle % 360;

if (a < 0)
a += 360;
Expand Down
2 changes: 1 addition & 1 deletion engines/pegasus/compass.h
Expand Up @@ -43,7 +43,7 @@ class Compass : public FaderAnimation {
void deallocateCompass();
bool isCompassValid() const { return _compassImage.isSurfaceValid(); }

void setFaderValue(const uint32);
void setFaderValue(const int32);

protected:
void draw(const Common::Rect &);
Expand Down
16 changes: 8 additions & 8 deletions engines/pegasus/fader.cpp
Expand Up @@ -35,13 +35,13 @@ Fader::Fader() {
_currentFaderMove._numKnots = 0;
}

void Fader::setFaderValue(const uint32 newValue) {
void Fader::setFaderValue(const int32 newValue) {
_currentValue = newValue;
}

bool Fader::initFaderMove(const FaderMoveSpec &spec) {
bool faderMoves = false;
uint32 value = 0;
int32 value = 0;

if (spec._numKnots > 0) {
stopFader();
Expand Down Expand Up @@ -135,7 +135,7 @@ void Fader::timeChanged(const TimeValue newTime) {
if (_currentFaderMove._knots[i].knotTime > newTime)
break;

uint32 newValue;
int32 newValue;
if (i == 0)
newValue = _currentFaderMove._knots[0].knotValue;
else if (i == _currentFaderMove._numKnots)
Expand All @@ -148,13 +148,13 @@ void Fader::timeChanged(const TimeValue newTime) {
}
}

void FaderMoveSpec::makeOneKnotFaderSpec(const uint32 knotValue) {
void FaderMoveSpec::makeOneKnotFaderSpec(const int32 knotValue) {
_numKnots = 1;
_knots[0].knotTime = 0;
_knots[0].knotValue = knotValue;
}

void FaderMoveSpec::makeTwoKnotFaderSpec(const TimeScale faderScale, const TimeValue time1, const uint32 value1, const TimeValue time2, const uint32 value2) {
void FaderMoveSpec::makeTwoKnotFaderSpec(const TimeScale faderScale, const TimeValue time1, const int32 value1, const TimeValue time2, const int32 value2) {
_numKnots = 2;
_faderScale = faderScale;
_knots[0].knotTime = time1;
Expand All @@ -163,7 +163,7 @@ void FaderMoveSpec::makeTwoKnotFaderSpec(const TimeScale faderScale, const TimeV
_knots[1].knotValue = value2;
}

void FaderMoveSpec::insertFaderKnot(const TimeValue knotTime, const uint32 knotValue) {
void FaderMoveSpec::insertFaderKnot(const TimeValue knotTime, const int32 knotValue) {
if (_numKnots != kMaxFaderKnots) {
uint32 index;
for (index = 0; index < _numKnots; index++) {
Expand All @@ -184,7 +184,7 @@ void FaderMoveSpec::insertFaderKnot(const TimeValue knotTime, const uint32 knotV
}
}

void FaderAnimation::setFaderValue(const uint32 newValue) {
void FaderAnimation::setFaderValue(const int32 newValue) {
if (getFaderValue() != newValue) {
Fader::setFaderValue(newValue);
triggerRedraw();
Expand All @@ -203,7 +203,7 @@ void SoundFader::attachSound(Sound *sound) {
_sound = sound;
}

void SoundFader::setFaderValue(const uint32 newVolume) {
void SoundFader::setFaderValue(const int32 newVolume) {
if (_sound)
_sound->setVolume((newVolume * _masterVolume) >> 8);

Expand Down
22 changes: 11 additions & 11 deletions engines/pegasus/fader.h
Expand Up @@ -49,19 +49,19 @@ friend class Fader;
void setFaderScale(const TimeScale scale) { _faderScale = scale; }
TimeScale getFaderScale() const { return _faderScale; }

void makeOneKnotFaderSpec(const uint32);
void makeTwoKnotFaderSpec(const TimeScale, const TimeValue, const uint32, const TimeValue, const uint32);
void makeOneKnotFaderSpec(const int32);
void makeTwoKnotFaderSpec(const TimeScale, const TimeValue, const int32, const TimeValue, const int32);

void insertFaderKnot(const TimeValue, const uint32);
void insertFaderKnot(const TimeValue, const int32);

uint32 getNumKnots() const { return _numKnots; }
uint32 getNthKnotTime(const uint32 index) const { return _knots[index].knotTime; }
uint32 getNthKnotValue(const uint32 index) const { return _knots[index].knotValue; }
TimeValue getNthKnotTime(const uint32 index) const { return _knots[index].knotTime; }
int32 getNthKnotValue(const uint32 index) const { return _knots[index].knotValue; }

protected:
struct FaderKnot {
TimeValue knotTime;
uint32 knotValue;
int32 knotValue;
};

TimeScale _faderScale;
Expand All @@ -76,8 +76,8 @@ class Fader : public IdlerTimeBase {
Fader();
virtual ~Fader() {}

virtual void setFaderValue(const uint32);
uint32 getFaderValue() const { return _currentValue; }
virtual void setFaderValue(const int32);
int32 getFaderValue() const { return _currentValue; }
virtual void startFader(const FaderMoveSpec &);
virtual void startFaderSync(const FaderMoveSpec &);
virtual void loopFader(const FaderMoveSpec &);
Expand All @@ -93,7 +93,7 @@ class Fader : public IdlerTimeBase {
bool initFaderMove(const FaderMoveSpec &);
virtual void timeChanged(const TimeValue);

uint32 _currentValue;
int32 _currentValue;
FaderMoveSpec _currentFaderMove;
};

Expand All @@ -102,7 +102,7 @@ class FaderAnimation : public DisplayElement, public Fader {
FaderAnimation(const tDisplayElementID id) : DisplayElement(id) {}
virtual ~FaderAnimation() {}

void setFaderValue(const uint32);
void setFaderValue(const int32);
};

class Sound;
Expand All @@ -113,7 +113,7 @@ friend class Sound;
SoundFader();
virtual ~SoundFader() {}

void setFaderValue(const uint32);
void setFaderValue(const int32);

void setMasterVolume(const uint16);
uint16 getMasterVolume() const { return _masterVolume; }
Expand Down
2 changes: 1 addition & 1 deletion engines/pegasus/transition.cpp
Expand Up @@ -51,7 +51,7 @@ void ScreenFader::doFadeInSync(const TimeValue duration, const TimeValue scale,
startFaderSync(spec);
}

void ScreenFader::setFaderValue(const uint32 value) {
void ScreenFader::setFaderValue(const int32 value) {
if (value != getFaderValue()) {
Fader::setFaderValue(value);

Expand Down
2 changes: 1 addition & 1 deletion engines/pegasus/transition.h
Expand Up @@ -38,7 +38,7 @@ class ScreenFader : public Fader {
void doFadeOutSync(const TimeValue = kOneSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, const uint32 = getBlack());
void doFadeInSync(const TimeValue = kHalfSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, const uint32 = getBlack());

void setFaderValue(const uint32);
void setFaderValue(const int32);

protected:
uint32 _fadeTarget;
Expand Down

0 comments on commit 59d6b03

Please sign in to comment.