aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/player_v2.h
diff options
context:
space:
mode:
authorMax Horn2010-10-25 16:42:24 +0000
committerMax Horn2010-10-25 16:42:24 +0000
commit075919756fdc2f5edfec0734b1fe822d2a303ad4 (patch)
tree061ad5860c191a2252832929cb46e9a9eb34efaf /engines/scumm/player_v2.h
parentd2a7a840c786d0ea0e08267b95da25f655a1f322 (diff)
downloadscummvm-rg350-075919756fdc2f5edfec0734b1fe822d2a303ad4.tar.gz
scummvm-rg350-075919756fdc2f5edfec0734b1fe822d2a303ad4.tar.bz2
scummvm-rg350-075919756fdc2f5edfec0734b1fe822d2a303ad4.zip
SCUMM: Move shared code of Player_V2 & Player_V2CMS to new common base class
svn-id: r53830
Diffstat (limited to 'engines/scumm/player_v2.h')
-rw-r--r--engines/scumm/player_v2.h93
1 files changed, 5 insertions, 88 deletions
diff --git a/engines/scumm/player_v2.h b/engines/scumm/player_v2.h
index 22a70f1b32..6a0b3d6d5e 100644
--- a/engines/scumm/player_v2.h
+++ b/engines/scumm/player_v2.h
@@ -26,84 +26,35 @@
#ifndef SCUMM_PLAYER_V2_H
#define SCUMM_PLAYER_V2_H
-#include "common/scummsys.h"
-#include "common/mutex.h"
-#include "scumm/music.h"
-#include "sound/audiostream.h"
-#include "sound/mixer.h"
+#include "scumm/player_v2base.h"
namespace Scumm {
-class ScummEngine;
-
-#include "common/pack-start.h" // START STRUCT PACKING
-
-struct channel_data {
- uint16 time_left; // 00
- uint16 next_cmd; // 02
- uint16 base_freq; // 04
- uint16 freq_delta; // 06
- uint16 freq; // 08
- uint16 volume; // 10
- uint16 volume_delta; // 12
- uint16 tempo; // 14
- uint16 inter_note_pause; // 16
- uint16 transpose; // 18
- uint16 note_length; // 20
- uint16 hull_curve; // 22
- uint16 hull_offset; // 24
- uint16 hull_counter; // 26
- uint16 freqmod_table; // 28
- uint16 freqmod_offset; // 30
- uint16 freqmod_incr; // 32
- uint16 freqmod_multiplier; // 34
- uint16 freqmod_modulo; // 36
- uint16 unknown[4]; // 38 - 44
- uint16 music_timer; // 46
- uint16 music_script_nr; // 48
-} PACKED_STRUCT;
-
-#include "common/pack-end.h" // END STRUCT PACKING
-
-
/**
* Scumm V2 PC-Speaker MIDI driver.
* This simulates the pc speaker sound, which is driven by the 8253 (square
* wave generator) and a low-band filter.
*/
-class Player_V2 : public Audio::AudioStream, public MusicEngine {
+class Player_V2 : public Player_V2Base {
public:
Player_V2(ScummEngine *scumm, Audio::Mixer *mixer, bool pcjr);
virtual ~Player_V2();
+ // MusicEngine API
virtual void setMusicVolume(int vol);
virtual void startSound(int sound);
virtual void stopSound(int sound);
virtual void stopAllSounds();
- virtual int getMusicTimer();
+// virtual int getMusicTimer();
virtual int getSoundStatus(int sound) const;
// AudioStream API
- int readBuffer(int16 *buffer, const int numSamples) {
- do_mix(buffer, numSamples / 2);
- return numSamples;
- }
+ int readBuffer(int16 *buffer, const int numSamples);
bool isStereo() const { return true; }
bool endOfData() const { return false; }
int getRate() const { return _sampleRate; }
protected:
- bool _isV3Game;
- Audio::Mixer *_mixer;
- Audio::SoundHandle _soundHandle;
- ScummEngine *_vm;
-
- bool _pcjr;
- int _header_len;
-
- uint32 _sampleRate;
- uint32 _next_tick;
- uint32 _tick_len;
unsigned int _update_step;
unsigned int _decay;
int _level;
@@ -113,47 +64,13 @@ protected:
int _timer_count[4];
int _timer_output;
- int _current_nr;
- byte *_current_data;
- int _next_nr;
- byte *_next_data;
- byte *_retaddr;
-
- Common::Mutex _mutex;
-
-private:
- union ChannelInfo {
- channel_data d;
- uint16 array[sizeof(channel_data)/2];
- };
-
- int _music_timer;
- int _music_timer_ctr;
- int _ticks_per_music_timer;
-
- const uint16 *_freqs_table;
-
- ChannelInfo _channels[5];
-
protected:
- virtual void nextTick();
- virtual void clear_channel(int i);
- virtual void chainSound(int nr, byte *data);
- virtual void chainNextSound();
-
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);
-
-private:
- void do_mix(int16 *buf, uint len);
-
- void set_pcjr(bool pcjr);
- void execute_cmd(ChannelInfo *channel);
- void next_freqs(ChannelInfo *channel);
};
} // End of namespace Scumm