[Scummvm-cvs-logs] CVS: scummvm/scumm imuse.cpp,2.48,2.49
Jamieson Christian
jamieson630 at users.sourceforge.net
Wed May 21 13:24:02 CEST 2003
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sky/compacts 0compact.h,1.4,1.5 101comp.h,1.4,1.5 102comp.h,1.4,1.5 10comp.h,1.5,1.6 11comp.h,1.5,1.6 12comp.h,1.5,1.6 13comp.h,1.5,1.6 14comp.h,1.5,1.6 15comp.h,1.5,1.6 16comp.h,1.5,1.6 17comp.h,1.5,1.6 18comp.h,1.5,1.6 19comp.h,1.5,1.6 1compact.h,1.4,1.5 20comp.h,1.5,1.6 21comp.h,1.5,1.6 22comp.h,1.5,1.6 23comp.h,1.5,1.6 24comp.h,1.5,1.6 25comp.h,1.5,1.6 26comp.h,1.5,1.6 27comp.h,1.5,1.6 28comp.h,1.5,1.6 29comp.h,1.5,1.6 2compact.h,1.5,1.6 30comp.h,1.5,1.6 31comp.h,1.5,1.6 32comp.h,1.5,1.6 33comp.h,1.5,1.6 34comp.h,1.5,1.6 36comp.h,1.5,1.6 37comp.h,1.5,1.6 38comp.h,1.5,1.6 39comp.h,1.5,1.6 3compact.h,1.5,1.6 40comp.h,1.5,1.6 41comp.h,1.5,1.6 42comp.h,1.4,1.5 44comp.h,1.5,1.6 45comp.h,1.5,1.6 46comp.h,1.5,1.6 47comp.h,1.5,1.6 48comp.h,1.5,1.6 4compact.h,1.5,1.6 5compact.h,1.5,1.6 65comp.h,1.5,1.6 66comp.h,1.4,1.5 67comp.h,1.5,1.6 68comp.h,1.5,1.6 69comp.h,1.5,1.6 70comp.h,1.5,1.6 71comp.h,1.5,1.6 72comp.h,1.5,1.6 73comp.h,1.5,1.6 74comp.h,1.5,1.6 75comp.h,1.5,1.6 76comp.h,1.5,1.6 77comp.h,1.5,1.6 78comp.h,1.5,1.6 79comp.h,1.5,1.6 80comp.h,1.4,1.5 81comp.h,1.4,1.5 82comp.h,1.4,1.5 85comp.h,1.4,1.5 90comp.h,1.5,1.6 91comp.h,1.5,1.6 92comp.h,1.5,1.6 93comp.h,1.5,1.6 94comp.h,1.5,1.6 95comp.h,1.5,1.6 96comp.h,1.5,1.6 9compact.h,1.5,1.6 linc_gen.h,1.4,1.5 lincmenu.h,1.4,1.5 objects.h,1.4,1.5 z_compac.h,1.5,1.6
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm script_v2.cpp,2.99,2.100
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv8555/scummvm/scumm
Modified Files:
imuse.cpp
Log Message:
Replaced VolumeFader with more generic ParameterFader
Index: imuse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/imuse.cpp,v
retrieving revision 2.48
retrieving revision 2.49
diff -u -d -r2.48 -r2.49
--- imuse.cpp 21 May 2003 19:33:50 -0000 2.48
+++ imuse.cpp 21 May 2003 20:23:01 -0000 2.49
@@ -65,12 +65,21 @@
int set(byte cls, byte value, byte chan);
};
-struct ParameterFade {
+struct ParameterFader {
+ enum {
+ pfVolume = 1,
+ pfTranspose = 3,
+ pfSpeed = 4
+ };
+
int param;
int start;
int end;
uint32 total_time;
uint32 current_time;
+
+ ParameterFader() { param = 0; }
+ void init() { param = 0; }
};
struct DeferredCommand {
@@ -79,27 +88,6 @@
int a, b, c, d, e, f;
};
-struct VolumeFader {
- Player *player;
- bool active;
- byte curvol;
- uint16 speed_lo_max, num_steps;
- int8 speed_hi;
- int8 direction;
- int8 speed_lo;
- uint16 speed_lo_counter;
-
- void initialize() {
- active = false;
- }
- void on_timer(bool probe);
- byte fading_to();
-
- VolumeFader() {
- memset(this,0,sizeof(VolumeFader));
- }
-};
-
struct Player {
IMuseInternal *_se;
MidiDriver *_midi;
@@ -137,8 +125,7 @@
bool _abort;
HookDatas _hook;
- ParameterFade _parameterFades[4];
- VolumeFader _volumeFader;
+ ParameterFader _parameterFaders[4];
bool _mt32emulate;
bool _isGM;
@@ -173,7 +160,7 @@
void play_active_notes();
void cancel_volume_fade();
- void addParameterTransition (int param, int target, int time);
+ int addParameterFader (int param, int target, int time);
void transitionParameters();
static void decode_sysex_bytes(byte *src, byte *dst, int len);
@@ -194,7 +181,6 @@
int scan(uint totrack, uint tobeat, uint totick);
int query_param(int param);
- int fade_vol(byte vol, int time);
bool is_fading_out();
void sequencer_timer();
@@ -758,7 +744,6 @@
for (i = ARRAYSIZE(_players); i != 0; i--, player++) {
player->_active = false;
player->_se = this;
- player->_volumeFader.initialize();
}
}
@@ -940,63 +925,6 @@
}
}
-void VolumeFader::on_timer(bool probe) {
- byte newvol;
-
- newvol = curvol + speed_hi;
- speed_lo_counter += speed_lo;
-
- if (speed_lo_counter >= speed_lo_max) {
- speed_lo_counter -= speed_lo_max;
- newvol += direction;
- }
-
- if (curvol != newvol) {
- curvol = newvol;
- if (!newvol) {
- if (!probe)
- player->clear();
- active = false;
- return;
- }
- if (!probe)
- player->set_vol(newvol);
- }
-
- if (!--num_steps) {
- active = false;
- }
-}
-
-byte VolumeFader::fading_to() {
- byte newvol;
- byte orig_curvol;
- uint16 orig_speed_lo_counter, orig_num_steps;
-
- if (!active)
- return 127;
-
- // It would be so much easier to just store the fade-to volume in a
- // variable, but then we'd have to break savegame compatibility. So
- // instead we do a "dry run" fade.
-
- orig_speed_lo_counter = speed_lo_counter;
- orig_num_steps = num_steps;
- orig_curvol = curvol;
-
- while (active)
- on_timer(true);
-
- active = true;
- newvol = curvol;
-
- speed_lo_counter = orig_speed_lo_counter;
- num_steps = orig_num_steps;
- curvol = orig_curvol;
-
- return newvol;
-}
-
int IMuseInternal::getSoundStatus(int sound) {
int i;
Player *player;
@@ -1281,8 +1209,8 @@
// Sam and Max: Parameter transition
player = this->get_player_byid (b);
if (player)
- player->addParameterTransition (d, e, f);
- return 0;
+ return player->addParameterFader (d, e, f);
+ return -1;
case 15:
// Sam & Max: Set hook for a "maybe" jump
@@ -1397,7 +1325,7 @@
case 12:
return player->_hook.set(c, d, e);
case 13:
- return player->fade_vol(c, d);
+ return player->addParameterFader (ParameterFader::pfVolume, c, d);
case 14:
return enqueue_trigger(b, c);
case 15:
@@ -1724,37 +1652,16 @@
//
////////////////////////////////////////
-int Player::fade_vol(byte vol, int time) {
- VolumeFader *vf;
+bool Player::is_fading_out() {
int i;
-
- cancel_volume_fade();
- if (time == 0) {
- set_vol(vol);
- return 0;
- }
-
- vf = &_volumeFader;
-
- vf->active = true;
- vf->player = this;
- vf->num_steps = vf->speed_lo_max = time;
- vf->curvol = _volume;
- i = (vol - vf->curvol);
- vf->speed_hi = i / time;
- if (i < 0) {
- i = -i;
- vf->direction = -1;
- } else {
- vf->direction = 1;
+ for (i = 0; i < ARRAYSIZE(_parameterFaders); ++i) {
+ if (_parameterFaders[i].param == ParameterFader::pfVolume &&
+ _parameterFaders[i].end == 0)
+ {
+ return true;
+ }
}
- vf->speed_lo = i % time;
- vf->speed_lo_counter = 0;
- return 0;
-}
-
-bool Player::is_fading_out() {
- return (_volumeFader.active && _volumeFader.direction < 0 && _volumeFader.fading_to() == 0);
+ return false;
}
void Player::clear() {
@@ -1769,6 +1676,7 @@
bool Player::startSound (int sound, MidiDriver *midi) {
void *mdhd;
+ int i;
mdhd = _se->findTag(sound, MDHD_TAG, 0);
if (mdhd == NULL) {
@@ -1789,13 +1697,14 @@
_priority = 0x80;
_volume = 0x7F;
_vol_chan = 0xFFFF;
-
_vol_eff = (_se->get_channel_volume(0xFFFF) << 7) >> 7;
-
_pan = 0;
_transpose = 0;
_detune = 0;
+ for (i = 0; i < ARRAYSIZE(_parameterFaders); ++i)
+ _parameterFaders[i].init();
+
hook_clear();
if (start_seq_sound(sound) != 0) {
_active = false;
@@ -1861,7 +1770,13 @@
}
void Player::cancel_volume_fade() {
- _volumeFader.active = false;
+ int i;
+ for (i = 0; i < ARRAYSIZE(_parameterFaders); ++i) {
+ if (_parameterFaders[i].param == ParameterFader::pfVolume) {
+ _parameterFaders[i].param = 0;
+ break;
+ }
+ }
}
void Player::uninit_parts() {
@@ -2683,8 +2598,6 @@
uint32 curpos, topos;
uint32 pos;
-// assert(totrack >= 0 && tobeat >= 0 && totick >= 0); // Those are all unsigned numbers anyway...
-
if (!_active)
return -1;
@@ -2847,6 +2760,12 @@
// that are occuring.
transitionParameters();
+ // Since the volume parameter can cause
+ // the player to be deactivated, check
+ // to make sure we're still active.
+ if (!_active)
+ return;
+
counter = _timer_counter + _timer_speed;
_timer_counter = counter & 0xFFFF;
_cur_pos += counter >> 16;
@@ -2878,10 +2797,6 @@
}
}
}
-
- // Now handle any volume fades
- if (_volumeFader.active)
- _volumeFader.on_timer (false);
}
void IMuseInternal::handleDeferredCommands (MidiDriver *midi) {
@@ -2926,16 +2841,16 @@
// "time" is referenced as hundredths of a second.
// IS THAT CORRECT??
// We convert it to microseconds before prceeding
-void Player::addParameterTransition (int param, int target, int time) {
+int Player::addParameterFader (int param, int target, int time) {
int start;
switch (param) {
- case 1:
+ case ParameterFader::pfVolume:
// Volume fades are handled differently.
- fade_vol (target, time);
- return;
+ start = _volume;
+ break;
- case 3:
+ case ParameterFader::pfTranspose:
// FIXME: Is this transpose? And what's the scale?
// It's set to fade to -2400 in the tunnel of love.
warning ("parameterTransition(3) outside Tunnel of Love?");
@@ -2943,7 +2858,7 @@
target /= 200;
break;
- case 4:
+ case ParameterFader::pfSpeed:
// FIXME: Is the speed from 0-100?
// Right now I convert it to 0-128.
start = _speed;
@@ -2953,17 +2868,17 @@
case 127:
// FIXME: This MIGHT fade ALL supported parameters,
// but I'm not sure.
- return;
+ return 0;
default:
- warning ("Unknown transition parameter %d", param);
- return;
+ warning ("Player::addParameterFader(): Unknown parameter %d", param);
+ return 0; // Should be -1, but we'll let the script think it worked.
}
- ParameterFade *ptr = &_parameterFades[0];
- ParameterFade *best = 0;
+ ParameterFader *ptr = &_parameterFaders[0];
+ ParameterFader *best = 0;
int i;
- for (i = ARRAYSIZE(_parameterFades); i; --i, ++ptr) {
+ for (i = ARRAYSIZE(_parameterFaders); i; --i, ++ptr) {
if (ptr->param == param) {
best = ptr;
start = ptr->end;
@@ -2979,16 +2894,21 @@
best->end = target;
best->total_time = (uint32) time * 10000;
best->current_time = 0;
+ } else {
+ warning ("IMuse Player %d: Out of parameter faders", _id);
+ return -1;
}
+
+ return 0;
}
void Player::transitionParameters() {
uint32 advance = _midi->getBaseTempo() / 500;
int value;
- ParameterFade *ptr = &_parameterFades[0];
+ ParameterFader *ptr = &_parameterFaders[0];
int i;
- for (i = ARRAYSIZE(_parameterFades); i; --i, ++ptr) {
+ for (i = ARRAYSIZE(_parameterFaders); i; --i, ++ptr) {
if (!ptr->param)
continue;
@@ -2998,12 +2918,21 @@
value = (int32) ptr->start + (int32) (ptr->end - ptr->start) * (int32) ptr->current_time / (int32) ptr->total_time;
switch (ptr->param) {
- case 4:
+ case ParameterFader::pfVolume:
+ // Volume.
+ if (!value) {
+ clear();
+ return;
+ }
+ set_vol ((byte) value);
+ break;
+
+ case ParameterFader::pfSpeed:
// Speed.
set_speed ((byte) value);
break;
- case 3:
+ case ParameterFader::pfTranspose:
// FIXME: Is this really transpose?
set_transpose (0, value);
break;
@@ -3098,15 +3027,15 @@
};
const SaveLoadEntry volumeFaderEntries[] = {
- MKREF(VolumeFader, player, TYPE_PLAYER, VER_V8),
- MKLINE(VolumeFader, active, sleUint8, VER_V8),
- MKLINE(VolumeFader, curvol, sleUint8, VER_V8),
- MKLINE(VolumeFader, speed_lo_max, sleUint16, VER_V8),
- MKLINE(VolumeFader, num_steps, sleUint16, VER_V8),
- MKLINE(VolumeFader, speed_hi, sleInt8, VER_V8),
- MKLINE(VolumeFader, direction, sleInt8, VER_V8),
- MKLINE(VolumeFader, speed_lo, sleInt8, VER_V8),
- MKLINE(VolumeFader, speed_lo_counter, sleUint16, VER_V8),
+ MK_OBSOLETE_REF(VolumeFader, player, TYPE_PLAYER, VER_V8, VER_V16),
+ MK_OBSOLETE(VolumeFader, active, sleUint8, VER_V8, VER_V16),
+ MK_OBSOLETE(VolumeFader, curvol, sleUint8, VER_V8, VER_V16),
+ MK_OBSOLETE(VolumeFader, speed_lo_max, sleUint16, VER_V8, VER_V16),
+ MK_OBSOLETE(VolumeFader, num_steps, sleUint16, VER_V8, VER_V16),
+ MK_OBSOLETE(VolumeFader, speed_hi, sleInt8, VER_V8, VER_V16),
+ MK_OBSOLETE(VolumeFader, direction, sleInt8, VER_V8, VER_V16),
+ MK_OBSOLETE(VolumeFader, speed_lo, sleInt8, VER_V8, VER_V16),
+ MK_OBSOLETE(VolumeFader, speed_lo_counter, sleUint16, VER_V8, VER_V16),
MKEND()
};
@@ -3163,13 +3092,11 @@
}
}
- // Volume faders used to be managed by IMuseInternal, but
- // they are now maintained by each individual player.
+ // VolumeFader has been replaced with the more generic ParameterFader.
{
int i;
- for (i = 0; i < ARRAYSIZE(_players); ++i) {
- ser->saveLoadEntries (&_players[i]._volumeFader, volumeFaderEntries);
- }
+ for (i = 0; i < 8; ++i)
+ ser->saveLoadEntries (0, volumeFaderEntries);
}
if (!ser->isSaving()) {
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sky/compacts 0compact.h,1.4,1.5 101comp.h,1.4,1.5 102comp.h,1.4,1.5 10comp.h,1.5,1.6 11comp.h,1.5,1.6 12comp.h,1.5,1.6 13comp.h,1.5,1.6 14comp.h,1.5,1.6 15comp.h,1.5,1.6 16comp.h,1.5,1.6 17comp.h,1.5,1.6 18comp.h,1.5,1.6 19comp.h,1.5,1.6 1compact.h,1.4,1.5 20comp.h,1.5,1.6 21comp.h,1.5,1.6 22comp.h,1.5,1.6 23comp.h,1.5,1.6 24comp.h,1.5,1.6 25comp.h,1.5,1.6 26comp.h,1.5,1.6 27comp.h,1.5,1.6 28comp.h,1.5,1.6 29comp.h,1.5,1.6 2compact.h,1.5,1.6 30comp.h,1.5,1.6 31comp.h,1.5,1.6 32comp.h,1.5,1.6 33comp.h,1.5,1.6 34comp.h,1.5,1.6 36comp.h,1.5,1.6 37comp.h,1.5,1.6 38comp.h,1.5,1.6 39comp.h,1.5,1.6 3compact.h,1.5,1.6 40comp.h,1.5,1.6 41comp.h,1.5,1.6 42comp.h,1.4,1.5 44comp.h,1.5,1.6 45comp.h,1.5,1.6 46comp.h,1.5,1.6 47comp.h,1.5,1.6 48comp.h,1.5,1.6 4compact.h,1.5,1.6 5compact.h,1.5,1.6 65comp.h,1.5,1.6 66comp.h,1.4,1.5 67comp.h,1.5,1.6 68comp.h,1.5,1.6 69comp.h,1.5,1.6 70comp.h,1.5,1.6 71comp.h,1.5,1.6 72comp.h,1.5,1.6 73comp.h,1.5,1.6 74comp.h,1.5,1.6 75comp.h,1.5,1.6 76comp.h,1.5,1.6 77comp.h,1.5,1.6 78comp.h,1.5,1.6 79comp.h,1.5,1.6 80comp.h,1.4,1.5 81comp.h,1.4,1.5 82comp.h,1.4,1.5 85comp.h,1.4,1.5 90comp.h,1.5,1.6 91comp.h,1.5,1.6 92comp.h,1.5,1.6 93comp.h,1.5,1.6 94comp.h,1.5,1.6 95comp.h,1.5,1.6 96comp.h,1.5,1.6 9compact.h,1.5,1.6 linc_gen.h,1.4,1.5 lincmenu.h,1.4,1.5 objects.h,1.4,1.5 z_compac.h,1.5,1.6
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm script_v2.cpp,2.99,2.100
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list