diff options
author | Strangerke | 2017-01-03 16:24:12 -0800 |
---|---|---|
committer | Eugene Sandulenko | 2017-01-25 22:42:20 +0100 |
commit | b669a704e2c4bf13894f2729fbd8c63bdebba082 (patch) | |
tree | 20db4aeb929d6ed50b102939b82ed478e3e79384 /engines/cryo | |
parent | c667702f2c6f9e4adc301eb0a11f4c3c327076ad (diff) | |
download | scummvm-rg350-b669a704e2c4bf13894f2729fbd8c63bdebba082.tar.gz scummvm-rg350-b669a704e2c4bf13894f2729fbd8c63bdebba082.tar.bz2 scummvm-rg350-b669a704e2c4bf13894f2729fbd8c63bdebba082.zip |
CRYO: rename SoundChannel, get rid of soundraw
Diffstat (limited to 'engines/cryo')
-rw-r--r-- | engines/cryo/clsoundraw.cpp | 63 | ||||
-rw-r--r-- | engines/cryo/cryolib.cpp | 75 | ||||
-rw-r--r-- | engines/cryo/cryolib.h | 50 | ||||
-rw-r--r-- | engines/cryo/eden.cpp | 4 | ||||
-rw-r--r-- | engines/cryo/eden.h | 2 | ||||
-rw-r--r-- | engines/cryo/module.mk | 7 | ||||
-rw-r--r-- | engines/cryo/sound.cpp | 12 | ||||
-rw-r--r-- | engines/cryo/sound.h | 2 | ||||
-rw-r--r-- | engines/cryo/video.cpp | 6 | ||||
-rw-r--r-- | engines/cryo/video.h | 6 |
10 files changed, 106 insertions, 121 deletions
diff --git a/engines/cryo/clsoundraw.cpp b/engines/cryo/clsoundraw.cpp deleted file mode 100644 index 2bfaec1eb9..0000000000 --- a/engines/cryo/clsoundraw.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "cryo/cryolib.h" - -namespace Cryo { - -sound_t *CLSoundRaw_New(int16 length, float rate, int16 sampleSize, int16 mode) { - sound_t *sound = (sound_t *)malloc(sizeof(*sound)); - if (sound) { - sound->_maxLength = length; - sound->_rate = rate; - sound->_sampleSize = sampleSize; - sound->_buffer = nullptr; -// sound->sndHandle = CLMemory_AllocHandle(arg1 + 100); -// if(!sound->sndHandle) -// error("CLSoundRaw_New - Not enough memory"); -// else - CLSound_PrepareSample(sound, mode); - } else - error("CLSoundRaw_New - Not enough memory"); - - return sound; -} - -void CLSoundRaw_Free(sound_t *sound) { - while (sound->_locked) - ; -// CLMemory_FreeHandle(sound->sndHandle); - free(sound); -} - -void CLSoundRaw_AssignBuffer(sound_t *sound, void *buffer, int bufferOffs, int length) { - CLSound_SetLength(sound, length); - sound->_length = length; - char *buf = bufferOffs + (char *)buffer; -// if(CLSound_GetWantsDesigned()) -// CLSound_Signed2NonSigned(buf, length); - sound->_buffer = buf; -// if(sound->reversed && sound->sampleSize == 16) -// ReverseBlock16(buf, length); -} - -} // End of namespace Cryo diff --git a/engines/cryo/cryolib.cpp b/engines/cryo/cryolib.cpp index 3aa6e997d6..c9788549b2 100644 --- a/engines/cryo/cryolib.cpp +++ b/engines/cryo/cryolib.cpp @@ -341,24 +341,65 @@ void CLFile_Write(Common::File &handle, void *buffer, int32 *size) { ///// CLSound // base sound -void CLSound_PrepareSample(sound_t *sound, int16 mode) { - sound->_mode = mode; - sound->_locked = 0; - sound->_loopTimes = 0; - sound->_reversed = false; - sound->_unused32 = 0; - sound->_volume = 255; + +sound_t::sound_t(int16 length, float rate, int16 sampleSize, int16 mode) { + _sndHandle = nullptr; + _headerLen = 0; + _headerOffset = 0; + + _length = 0; + _mode = 0; + _locked = 0; + _loopStart = 0; + _loopTimes = 0; + _reversed = false; + _volume = 0; + + _maxLength = length; + _rate = rate; + _sampleSize = sampleSize; + _buffer = nullptr; + // sndHandle = CLMemory_AllocHandle(arg1 + 100); + // if(!sndHandle) + // error("CLSoundRaw_New - Not enough memory"); + // else + prepareSample(mode); +} + +sound_t::~sound_t() { + while (_locked) + ; +} + +void CLSoundRaw_AssignBuffer(sound_t *sound, void *buffer, int bufferOffs, int length) { + sound->setLength(length); + sound->_length = length; + char *buf = bufferOffs + (char *)buffer; + // if(CLSound_GetWantsDesigned()) + // CLSound_Signed2NonSigned(buf, length); + sound->_buffer = buf; + // if(sound->reversed && sound->sampleSize == 16) + // ReverseBlock16(buf, length); +} + +void sound_t::prepareSample(int16 mode) { + _mode = mode; + _locked = 0; + _loopTimes = 0; + _reversed = false; + _unused32 = 0; + _volume = 255; } -void CLSound_SetWantsDesigned(int16 designed) { +void sound_t::setWantsDesigned(int16 designed) { } -void CLSound_SetLength(sound_t *sound, int length) { +void sound_t::setLength(int length) { } ///// CLSoundChannel /// sound output device that plays queue of sounds -soundchannel_t::soundchannel_t(int arg1) { +SoundChannel::SoundChannel(int arg1) { _volumeLeft = _volumeRight = 255; _numSounds = 0; @@ -366,21 +407,21 @@ soundchannel_t::soundchannel_t(int arg1) { _sounds[i] = nullptr; } -soundchannel_t::~soundchannel_t() { +SoundChannel::~SoundChannel() { } -void soundchannel_t::stop() { +void SoundChannel::stop() { // _vm->_mixer->stopHandle(this); } -void soundchannel_t::play(sound_t *sound) { +void SoundChannel::play(sound_t *sound) { } -int16 soundchannel_t::getVolume() { +int16 SoundChannel::getVolume() { return (_volumeLeft + _volumeRight) / 2; } -void soundchannel_t::setVolume(int16 volume) { +void SoundChannel::setVolume(int16 volume) { if (volume < 0 || volume > 255) return; @@ -388,14 +429,14 @@ void soundchannel_t::setVolume(int16 volume) { _volumeRight = volume; } -void soundchannel_t::setVolumeRight(int16 volume) { +void SoundChannel::setVolumeRight(int16 volume) { if (volume < 0 || volume > 255) return; _volumeRight = volume; } -void soundchannel_t::setVolumeLeft(int16 volume) { +void SoundChannel::setVolumeLeft(int16 volume) { if (volume < 0 || volume > 255) return; diff --git a/engines/cryo/cryolib.h b/engines/cryo/cryolib.h index b6d72e303e..e9e1cd631f 100644 --- a/engines/cryo/cryolib.h +++ b/engines/cryo/cryolib.h @@ -136,30 +136,46 @@ struct hnm_t { }; typedef struct hnm_t hnm_t; -struct sound_t { - char *_sndHandle; - int16 _headerLen; +class sound_t { +private: int32 _headerOffset; int16 _unused0A; - char *_buffer; int _unused16; - int16 _maxLength; - float _rate; - int16 _sampleSize; - int _length; int16 _mode; - volatile int16 _locked; int32 _loopStart; int16 _loopTimes; - bool _reversed; int16 _unused32; int16 _volume; + +public: + sound_t(int16 length, float rate, int16 sampleSize, int16 mode); + ~sound_t(); + + void assignBuffer(void *buffer, int bufferOffs, int length); + void prepareSample(int16 mode); + void setWantsDesigned(int16 designed); + void setLength(int length); + + char *_sndHandle; + char *_buffer; + + float _rate; + + int16 _maxLength; + int16 _headerLen; + int16 _sampleSize; + + int _length; + + bool _reversed; + + volatile int16 _locked; }; #define kCryoMaxChSounds 10 -class soundchannel_t { +class SoundChannel { private: int16 _volumeLeft; int16 _volumeRight; @@ -168,8 +184,8 @@ private: sound_t *_sounds[kCryoMaxChSounds]; public: - soundchannel_t(int arg1); - ~soundchannel_t(); + SoundChannel(int arg1); + ~SoundChannel(); void stop(); void play(sound_t *sound); @@ -179,10 +195,6 @@ public: void setVolumeLeft(int16 volume); }; -sound_t *CLSoundRaw_New(int16 length, float rate, int16 sampleSize, int16 mode); -void CLSoundRaw_Free(sound_t *sound); -void CLSoundRaw_AssignBuffer(sound_t *sound, void *buffer, int bufferOffs, int length); - void SysBeep(int x); int32 TickCount(); void FlushEvents(int16 arg1, int16 arg2); @@ -210,10 +222,6 @@ void CLPalette_BeSystem(); void CLFile_Write(Common::File &handle, void *buffer, int32 *size); -void CLSound_PrepareSample(sound_t *sound, int16 mode); -void CLSound_SetWantsDesigned(int16 designed); -void CLSound_SetLength(sound_t *sound, int length); - void CRYOLib_ManagersInit(); void CRYOLib_ManagersDone(); diff --git a/engines/cryo/eden.cpp b/engines/cryo/eden.cpp index 5900a7ba7a..2df7644259 100644 --- a/engines/cryo/eden.cpp +++ b/engines/cryo/eden.cpp @@ -5734,9 +5734,9 @@ void EdenGame::run() { _vm->_video->setupSound(5, 0x2000, 8, 11025 * 65536.0 , 0); _vm->_video->setForceZero2Black(true); _vm->_video->setupTimer(12.5); - _voiceSound = CLSoundRaw_New(0, 11025 * 65536.0, 8, 0); + _voiceSound = new sound_t(0, 11025 * 65536.0, 8, 0); _hnmSoundChannel = _vm->_video->getSoundChannel(); - CLSound_SetWantsDesigned(1); // CHECKME: Used? + _voiceSound->setWantsDesigned(1); // CHECKME: Used? _musicChannel = new CSoundChannel(_vm->_mixer, 11025, false); _voiceChannel = new CSoundChannel(_vm->_mixer, 11025, false); diff --git a/engines/cryo/eden.h b/engines/cryo/eden.h index 90630d18e4..75c974a939 100644 --- a/engines/cryo/eden.h +++ b/engines/cryo/eden.h @@ -641,7 +641,7 @@ private: CSoundChannel *_musicChannel; CSoundChannel *_voiceChannel; - soundchannel_t *_hnmSoundChannel; + SoundChannel *_hnmSoundChannel; sound_t *_voiceSound; View *_view2; diff --git a/engines/cryo/module.mk b/engines/cryo/module.mk index be76752ea1..b82a7a182d 100644 --- a/engines/cryo/module.mk +++ b/engines/cryo/module.mk @@ -1,12 +1,11 @@ MODULE := engines/cryo MODULE_OBJS = \ - clsoundraw.o \ - cryolib.o \ - sound.o \ - eden.o \ cryo.o \ + cryolib.o \ detection.o \ + eden.o \ + sound.o \ staticdata.o \ video.o diff --git a/engines/cryo/sound.cpp b/engines/cryo/sound.cpp index 736ce049dd..597f05e7c8 100644 --- a/engines/cryo/sound.cpp +++ b/engines/cryo/sound.cpp @@ -74,10 +74,10 @@ SoundGroup::SoundGroup(CryoEngine *vm, int16 numSounds, int16 length, int16 samp if (numSounds < kCryoMaxClSounds)
_numSounds = numSounds;
else
- error("CLSoundGroup_New - numSounds >= kCryoMaxClSounds");
+ error("SoundGroup - numSounds >= kCryoMaxClSounds");
for (int i = 0; i < _numSounds; i++) {
- _sounds[i] = CLSoundRaw_New(length, rate, sampleSize, mode);
+ _sounds[i] = new sound_t(length, rate, sampleSize, mode);
_sounds[i]->_maxLength = length;
}
_soundIndex = 0;
@@ -88,7 +88,7 @@ SoundGroup::SoundGroup(CryoEngine *vm, int16 numSounds, int16 length, int16 samp // Original name: CLSoundGroup_Free
SoundGroup::~SoundGroup() {
for (int16 i = 0; i < _numSounds; i++)
- CLSoundRaw_Free(_sounds[i]);
+ delete(_sounds[i]);
}
// Original name: CLSoundGroup_Reverse16All
@@ -115,7 +115,7 @@ bool SoundGroup::assignDatas(void *buffer, int length, bool isSigned) { return false;
sound->_buffer = (char *)buffer;
- CLSound_SetLength(sound, length);
+ sound->setLength(length);
sound->_length = length;
// if(sound->reversed && sound->sampleSize == 16)
// ReverseBlock16(buffer, length);
@@ -143,7 +143,7 @@ bool SoundGroup::setDatas(void *data, int length, bool isSigned) { void *buffer = sound->_sndHandle + sound->_headerLen;
sound->_buffer = (char *)buffer;
memcpy(buffer, data, length);
- CLSound_SetLength(sound, length);
+ sound->setLength(length);
sound->_length = length;
// if(sound->reversed && sound->sampleSize == 16)
// ReverseBlock16(buffer, length);
@@ -158,7 +158,7 @@ bool SoundGroup::setDatas(void *data, int length, bool isSigned) { }
// Original name: CLSoundGroup_PlayNextSample
-void SoundGroup::playNextSample(soundchannel_t *ch) {
+void SoundGroup::playNextSample(SoundChannel *ch) {
ch->play(_sounds[_playIndex]);
if (_playIndex == _numSounds - 1)
_playIndex = 0;
diff --git a/engines/cryo/sound.h b/engines/cryo/sound.h index 13e12590b0..54c6f2dca2 100644 --- a/engines/cryo/sound.h +++ b/engines/cryo/sound.h @@ -56,7 +56,7 @@ public: void *getNextBuffer();
bool assignDatas(void *buffer, int length, bool isSigned);
bool setDatas(void *data, int length, bool isSigned);
- void playNextSample(soundchannel_t *ch);
+ void playNextSample(SoundChannel *ch);
sound_t *_sounds[kCryoMaxClSounds];
int16 _numSounds;
diff --git a/engines/cryo/video.cpp b/engines/cryo/video.cpp index d15985a51c..15e341174e 100644 --- a/engines/cryo/video.cpp +++ b/engines/cryo/video.cpp @@ -127,7 +127,7 @@ void HnmPlayer::wantsSound(bool sound) { // Original name: CLHNM_SetupSound void HnmPlayer::setupSound(int16 numSounds, int16 length, int16 sampleSize, float rate, int16 mode) { - _soundChannel = new soundchannel_t(mode); + _soundChannel = new SoundChannel(mode); _soundGroup = new SoundGroup(_vm, numSounds, length, sampleSize, rate, mode); if (sampleSize == 16) _soundGroup->reverse16All(); @@ -135,7 +135,7 @@ void HnmPlayer::setupSound(int16 numSounds, int16 length, int16 sampleSize, floa // Original name: CLHNM_SetupSoundADPCM void HnmPlayer::setupSoundADPCM(int16 numSounds, int16 length, int16 sampleSize, float rate, int16 mode) { - _soundChannelAdpcm = new soundchannel_t(mode); + _soundChannelAdpcm = new SoundChannel(mode); _soundGroupAdpcm = new SoundGroup(_vm, numSounds, length, sampleSize, rate, mode); } @@ -581,7 +581,7 @@ bool HnmPlayer::nextElement(hnm_t *hnm) { } // Original name: CLHNM_GetSoundChannel -soundchannel_t *HnmPlayer::getSoundChannel() { +SoundChannel *HnmPlayer::getSoundChannel() { return _soundChannel; } diff --git a/engines/cryo/video.h b/engines/cryo/video.h index 5d2e5999fe..144c8e03a4 100644 --- a/engines/cryo/video.h +++ b/engines/cryo/video.h @@ -70,9 +70,9 @@ private: void (*_customChunkHandler)(byte *buffer, int size, int16 id, char h6, char h7); - soundchannel_t *_soundChannel; + SoundChannel *_soundChannel; SoundGroup *_soundGroup; - soundchannel_t *_soundChannelAdpcm; + SoundChannel *_soundChannelAdpcm; SoundGroup *_soundGroupAdpcm; public: @@ -99,7 +99,7 @@ public: hnm_t *resetInternals(); void setFile(hnm_t *hnm, Common::File *file); - soundchannel_t *getSoundChannel(); + SoundChannel *getSoundChannel(); }; } // End of namespace Cryo |