diff options
author | Max Horn | 2003-09-19 14:43:57 +0000 |
---|---|---|
committer | Max Horn | 2003-09-19 14:43:57 +0000 |
commit | 0c8df2838793316b1ed182ad66d569dbbae8312d (patch) | |
tree | 9d467eda645e3690734ee20cea0b00d2c9ffa2f2 /scumm | |
parent | abdc8f1247e81b689584b8aca6f4de70768d065b (diff) | |
download | scummvm-rg350-0c8df2838793316b1ed182ad66d569dbbae8312d.tar.gz scummvm-rg350-0c8df2838793316b1ed182ad66d569dbbae8312d.tar.bz2 scummvm-rg350-0c8df2838793316b1ed182ad66d569dbbae8312d.zip |
cleanup; some more fixed need afnow that the premix proc is expected to generate stereo data; (we probably should add a common base class for Player_V1/V2 instead of deriving V1 from V2)
svn-id: r10312
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/player_v1.cpp | 41 | ||||
-rw-r--r-- | scumm/player_v1.h | 15 | ||||
-rw-r--r-- | scumm/player_v2.cpp | 22 | ||||
-rw-r--r-- | scumm/player_v2.h | 34 |
4 files changed, 51 insertions, 61 deletions
diff --git a/scumm/player_v1.cpp b/scumm/player_v1.cpp index 3236e2cf63..57288ae2a5 100644 --- a/scumm/player_v1.cpp +++ b/scumm/player_v1.cpp @@ -56,7 +56,6 @@ void Player_V1::chainSound(int nr, byte *data) { _current_nr = nr; _current_data = data; _repeat_chunk = _next_chunk = data + (_pcjr ? 2 : 4); - _music_timer = 0; debug(4, "Chaining new sound %d", nr); if (_pcjr) @@ -512,43 +511,23 @@ void Player_V1::set_mplex(uint mplex) { _tick_len = _mplex_step * mplex; } -void Player_V1::do_mix(int16 *data, uint len) { - mutex_up(); - uint step; - - do { - step = len; - if (step > (_next_tick >> FIXP_SHIFT)) - step = (_next_tick >> FIXP_SHIFT); +void Player_V1::nextTick() { + if (_next_chunk) { if (_pcjr) - generatePCjrSamples(data, step); + nextPCjrCmd(); else - generateSpkSamples(data, step); - data += 2 * step; - _next_tick -= step << FIXP_SHIFT; - - if (!(_next_tick >> FIXP_SHIFT)) { - _next_tick += _tick_len; - if (_next_chunk) { - if (_pcjr) - nextPCjrCmd(); - else - nextSpeakerCmd(); - } - } - } while (len -= step); - mutex_down(); + nextSpeakerCmd(); + } } void Player_V1::generateSpkSamples(int16 *data, uint len) { uint i; - memset (data, 0, sizeof(int16) * len); + memset(data, 0, 2 * sizeof(int16) * len); if (_channels[0].freq == 0) { if (_forced_level) { - for (i = 0; i < len; i++) { - data[i] = _volumetable[0]; - } + for (i = 0; i < len; i++) + data[2*i] = data[2*i+1] = _volumetable[0]; debug(9, "speaker: %8x: forced one", _tick_len); } else if (!_level) { return; @@ -566,11 +545,11 @@ void Player_V1::generatePCjrSamples(int16 *data, uint len) { uint freq, vol; bool hasdata = false; - memset(data, 0, sizeof(int16) * len); + memset(data, 0, 2 * sizeof(int16) * len); if (_forced_level) { for (i = 0; i < len; i++) - data[i] = _volumetable[0]; + data[2*i] = data[2*i+1] = _volumetable[0]; hasdata = true; debug(9, "channel[4]: %8x: forced one", _tick_len); } diff --git a/scumm/player_v1.h b/scumm/player_v1.h index 9adada0097..238e914999 100644 --- a/scumm/player_v1.h +++ b/scumm/player_v1.h @@ -53,24 +53,25 @@ public: int getMusicTimer() const; protected: + virtual void nextTick(); + virtual void clear_channel(int i); + virtual void chainSound(int nr, byte *data); + + virtual void generateSpkSamples(int16 *data, uint len); + virtual void generatePCjrSamples(int16 *data, uint len); + void restartSound(); void next_speaker_cmd(ChannelInfo *channel); - void clear_channel(int i); - void chainSound(int nr, byte *data); - - void do_mix(int16 *buf, uint len); void set_mplex(uint mplex); void parseSpeakerChunk(); void nextSpeakerCmd(); void parsePCjrChunk(); void nextPCjrCmd(); - void generateSpkSamples(int16 *data, uint len); - void generatePCjrSamples(int16 *data, uint len); +private: channel_data_v1 _channels[4]; -private: byte *_next_chunk; byte *_repeat_chunk; uint _chunk_type; diff --git a/scumm/player_v2.cpp b/scumm/player_v2.cpp index a3809b1b0a..2001087cc3 100644 --- a/scumm/player_v2.cpp +++ b/scumm/player_v2.cpp @@ -838,22 +838,26 @@ void Player_V2::do_mix(int16 *data, uint len) { _next_tick -= step << FIXP_SHIFT; if (!(_next_tick >> FIXP_SHIFT)) { - for (int i = 0; i < 4; i++) { - if (!_channels[i].d.time_left) - continue; - next_freqs(&_channels[i]); - } _next_tick += _tick_len; - if (_music_timer_ctr++ >= _ticks_per_music_timer) { - _music_timer_ctr = 0; - _music_timer++; - } + nextTick(); } } while (len -= step); mutex_down(); } +void Player_V2::nextTick() { + for (int i = 0; i < 4; i++) { + if (!_channels[i].d.time_left) + continue; + next_freqs(&_channels[i]); + } + if (_music_timer_ctr++ >= _ticks_per_music_timer) { + _music_timer_ctr = 0; + _music_timer++; + } +} + void Player_V2::lowPassFilter(int16 *sample, uint len) { for (uint i = 0; i < len; i++) { _level = (_level * _decay diff --git a/scumm/player_v2.h b/scumm/player_v2.h index 86218dda5a..a718b50bab 100644 --- a/scumm/player_v2.h +++ b/scumm/player_v2.h @@ -102,42 +102,48 @@ protected: unsigned int _RNG; unsigned int _volumetable[16]; - int _music_timer; - int _music_timer_ctr; - int _ticks_per_music_timer; int _timer_count[4]; int _timer_output; - const uint16 *_freqs_table; - - ChannelInfo _channels[5]; - int _current_nr; byte *_current_data; int _next_nr; byte *_next_data; byte *_retaddr; +private: + int _music_timer; + int _music_timer_ctr; + int _ticks_per_music_timer; + + const uint16 *_freqs_table; + OSystem::MutexRef _mutex; + ChannelInfo _channels[5]; + +protected: void mutex_up() { _system->lock_mutex (_mutex); } void mutex_down() { _system->unlock_mutex (_mutex); } - virtual void set_pcjr(bool pcjr); - void execute_cmd(ChannelInfo *channel); - virtual void next_freqs(ChannelInfo *channel); + virtual void nextTick(); virtual void clear_channel(int i); virtual void chainSound(int nr, byte *data); virtual void chainNextSound(); - static void premix_proc(void *param, int16 *buf, uint len); - virtual void do_mix (int16 *buf, uint len); + virtual void generateSpkSamples(int16 *data, uint len); + virtual void generatePCjrSamples(int16 *data, uint len); void lowPassFilter(int16 *data, uint len); void squareGenerator(int channel, int freq, int vol, int noiseFeedback, int16 *sample, uint len); - void generateSpkSamples(int16 *data, uint len); - void generatePCjrSamples(int16 *data, uint len); +private: + static void premix_proc(void *param, int16 *buf, uint len); + void do_mix(int16 *buf, uint len); + + void set_pcjr(bool pcjr); + void execute_cmd(ChannelInfo *channel); + void next_freqs(ChannelInfo *channel); }; #endif |