[Scummvm-cvs-logs] scummvm master -> 40f40303effec7d1055fc9212fd6cc8267f88585
clone2727
clone2727 at gmail.com
Sun Aug 14 19:22:07 CEST 2011
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
de6390dddb AGI: Make the sound code use AgiBase instead of AgiEngine
40f40303ef AGI: Enable sound support for Winnie DOS
Commit: de6390dddbf4f73f3adc68585232f4d4bd836e13
https://github.com/scummvm/scummvm/commit/de6390dddbf4f73f3adc68585232f4d4bd836e13
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-08-14T10:10:43-07:00
Commit Message:
AGI: Make the sound code use AgiBase instead of AgiEngine
In preparation of using the sound code with Winnie
Changed paths:
engines/agi/agi.cpp
engines/agi/agi.h
engines/agi/preagi.h
engines/agi/sound.cpp
engines/agi/sound.h
engines/agi/sound_2gs.cpp
engines/agi/sound_2gs.h
engines/agi/sound_coco3.cpp
engines/agi/sound_coco3.h
engines/agi/sound_midi.cpp
engines/agi/sound_midi.h
engines/agi/sound_pcjr.cpp
engines/agi/sound_pcjr.h
engines/agi/sound_sarien.cpp
engines/agi/sound_sarien.h
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 4cb45e8..4bebf97 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -504,6 +504,7 @@ AgiBase::AgiBase(OSystem *syst, const AGIGameDescription *gameDesc) : Engine(sys
_noSaveLoadAllowed = false;
_rnd = new Common::RandomSource("agi");
+ _sound = 0;
initFeatures();
initVersion();
@@ -511,6 +512,11 @@ AgiBase::AgiBase(OSystem *syst, const AGIGameDescription *gameDesc) : Engine(sys
AgiBase::~AgiBase() {
delete _rnd;
+
+ if (_sound) {
+ _sound->deinitSound();
+ delete _sound;
+ }
}
AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBase(syst, gameDesc) {
@@ -682,8 +688,6 @@ AgiEngine::~AgiEngine() {
agiDeinit();
delete _loader;
- _sound->deinitSound();
- delete _sound;
_gfx->deinitVideo();
delete _sprites;
delete _picture;
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 24c2744..080373d 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -789,6 +789,8 @@ public:
AgiGame _game;
Common::RandomSource *_rnd;
+ SoundMgr *_sound;
+
Mouse _mouse;
bool _noSaveLoadAllowed;
@@ -899,7 +901,6 @@ public:
char _lastSentence[40];
SpritesMgr *_sprites;
- SoundMgr *_sound;
PictureMgr *_picture;
AgiLoader *_loader; // loader
diff --git a/engines/agi/preagi.h b/engines/agi/preagi.h
index 1a17849..bb77786 100644
--- a/engines/agi/preagi.h
+++ b/engines/agi/preagi.h
@@ -49,7 +49,6 @@ public:
return _gameId;
}
- //SoundMgr *_sound;
PictureMgr *_picture;
PreAGI_Console *_console;
GUI::Debugger *getDebugger() { return _console; }
diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp
index 10074ef..2a776d8 100644
--- a/engines/agi/sound.cpp
+++ b/engines/agi/sound.cpp
@@ -177,7 +177,7 @@ void SoundMgr::soundIsFinished() {
_endflag = -1;
}
-SoundMgr::SoundMgr(AgiEngine *agi, Audio::Mixer *pMixer) {
+SoundMgr::SoundMgr(AgiBase *agi, Audio::Mixer *pMixer) {
_vm = agi;
_endflag = -1;
_playingSound = -1;
diff --git a/engines/agi/sound.h b/engines/agi/sound.h
index bd175d3..6fd8dd5 100644
--- a/engines/agi/sound.h
+++ b/engines/agi/sound.h
@@ -71,7 +71,7 @@ class SoundMgr;
class SoundGen {
public:
- SoundGen(AgiEngine *vm, Audio::Mixer *pMixer) : _vm(vm), _mixer(pMixer) {
+ SoundGen(AgiBase *vm, Audio::Mixer *pMixer) : _vm(vm), _mixer(pMixer) {
_sampleRate = pMixer->getOutputRate();
}
@@ -80,7 +80,7 @@ public:
virtual void play(int resnum) = 0;
virtual void stop(void) = 0;
- AgiEngine *_vm;
+ AgiBase *_vm;
Audio::Mixer *_mixer;
Audio::SoundHandle _soundHandle;
@@ -133,7 +133,7 @@ protected:
class SoundMgr {
public:
- SoundMgr(AgiEngine *agi, Audio::Mixer *pMixer);
+ SoundMgr(AgiBase *agi, Audio::Mixer *pMixer);
~SoundMgr();
void setVolume(uint8 volume);
@@ -149,7 +149,7 @@ public:
private:
int _endflag;
- AgiEngine *_vm;
+ AgiBase *_vm;
SoundGen *_soundGen;
diff --git a/engines/agi/sound_2gs.cpp b/engines/agi/sound_2gs.cpp
index 38e256a..c5cfa12 100644
--- a/engines/agi/sound_2gs.cpp
+++ b/engines/agi/sound_2gs.cpp
@@ -33,7 +33,7 @@
namespace Agi {
-SoundGen2GS::SoundGen2GS(AgiEngine *vm, Audio::Mixer *pMixer) : SoundGen(vm, pMixer) {
+SoundGen2GS::SoundGen2GS(AgiBase *vm, Audio::Mixer *pMixer) : SoundGen(vm, pMixer) {
// Allocate memory for the wavetable
_wavetable = new int8[SIERRASTANDARD_SIZE];
diff --git a/engines/agi/sound_2gs.h b/engines/agi/sound_2gs.h
index 9123e18..89ffc3f 100644
--- a/engines/agi/sound_2gs.h
+++ b/engines/agi/sound_2gs.h
@@ -215,7 +215,7 @@ private:
class SoundGen2GS : public SoundGen, public Audio::AudioStream {
public:
- SoundGen2GS(AgiEngine *vm, Audio::Mixer *pMixer);
+ SoundGen2GS(AgiBase *vm, Audio::Mixer *pMixer);
~SoundGen2GS();
void play(int resnum);
diff --git a/engines/agi/sound_coco3.cpp b/engines/agi/sound_coco3.cpp
index 281f2cb..64818e4 100644
--- a/engines/agi/sound_coco3.cpp
+++ b/engines/agi/sound_coco3.cpp
@@ -34,7 +34,7 @@ static int cocoFrequencies[] = {
2093, 2217, 2349, 2489, 2637, 2793, 2959, 3135, 3322, 3520, 3729, 3951
};
-SoundGenCoCo3::SoundGenCoCo3(AgiEngine *vm, Audio::Mixer *pMixer) : SoundGen(vm, pMixer) {
+SoundGenCoCo3::SoundGenCoCo3(AgiBase *vm, Audio::Mixer *pMixer) : SoundGen(vm, pMixer) {
}
SoundGenCoCo3::~SoundGenCoCo3() {
diff --git a/engines/agi/sound_coco3.h b/engines/agi/sound_coco3.h
index 7058b77..d24acf5 100644
--- a/engines/agi/sound_coco3.h
+++ b/engines/agi/sound_coco3.h
@@ -42,7 +42,7 @@ struct CoCoNote {
class SoundGenCoCo3 : public SoundGen, public Audio::AudioStream {
public:
- SoundGenCoCo3(AgiEngine *vm, Audio::Mixer *pMixer);
+ SoundGenCoCo3(AgiBase *vm, Audio::Mixer *pMixer);
~SoundGenCoCo3();
void play(int resnum);
diff --git a/engines/agi/sound_midi.cpp b/engines/agi/sound_midi.cpp
index 0cbaa4a..47d3540 100644
--- a/engines/agi/sound_midi.cpp
+++ b/engines/agi/sound_midi.cpp
@@ -69,7 +69,7 @@ MIDISound::MIDISound(uint8 *data, uint32 len, int resnum, SoundMgr &manager) : A
warning("Error creating MIDI sound from resource %d (Type %d, length %d)", resnum, _type, len);
}
-SoundGenMIDI::SoundGenMIDI(AgiEngine *vm, Audio::Mixer *pMixer) : SoundGen(vm, pMixer), _isGM(false) {
+SoundGenMIDI::SoundGenMIDI(AgiBase *vm, Audio::Mixer *pMixer) : SoundGen(vm, pMixer), _isGM(false) {
MidiPlayer::createDriver(MDT_MIDI | MDT_ADLIB);
int ret = _driver->open();
diff --git a/engines/agi/sound_midi.h b/engines/agi/sound_midi.h
index 92a4002..36bd66e 100644
--- a/engines/agi/sound_midi.h
+++ b/engines/agi/sound_midi.h
@@ -45,7 +45,7 @@ protected:
class SoundGenMIDI : public SoundGen, public Audio::MidiPlayer {
public:
- SoundGenMIDI(AgiEngine *vm, Audio::Mixer *pMixer);
+ SoundGenMIDI(AgiBase *vm, Audio::Mixer *pMixer);
void play(int resnum);
// We must overload stop() here to implement the pure virtual
diff --git a/engines/agi/sound_pcjr.cpp b/engines/agi/sound_pcjr.cpp
index 14525dc..d21baa4 100644
--- a/engines/agi/sound_pcjr.cpp
+++ b/engines/agi/sound_pcjr.cpp
@@ -102,7 +102,7 @@ const int8 dissolveDataV3[] = {
};
-SoundGenPCJr::SoundGenPCJr(AgiEngine *vm, Audio::Mixer *pMixer) : SoundGen(vm, pMixer) {
+SoundGenPCJr::SoundGenPCJr(AgiBase *vm, Audio::Mixer *pMixer) : SoundGen(vm, pMixer) {
_chanAllocated = 10240; // preallocate something which will most likely fit
_chanData = (int16 *)malloc(_chanAllocated << 1);
@@ -207,7 +207,7 @@ int SoundGenPCJr::volumeCalc(SndGenChan *chan) {
chan->attenuationCopy = attenuation;
attenuation &= 0x0F;
- attenuation += _vm->getvar(vVolume);
+ attenuation += _mixer->getVolumeForSoundType(Audio::Mixer::kSFXSoundType) / 17;
if (attenuation > 0x0F)
attenuation = 0x0F;
}
diff --git a/engines/agi/sound_pcjr.h b/engines/agi/sound_pcjr.h
index ec3fdff..1b4d1e9 100644
--- a/engines/agi/sound_pcjr.h
+++ b/engines/agi/sound_pcjr.h
@@ -73,7 +73,7 @@ struct ToneChan {
class SoundGenPCJr : public SoundGen, public Audio::AudioStream {
public:
- SoundGenPCJr(AgiEngine *vm, Audio::Mixer *pMixer);
+ SoundGenPCJr(AgiBase *vm, Audio::Mixer *pMixer);
~SoundGenPCJr();
void play(int resnum);
diff --git a/engines/agi/sound_sarien.cpp b/engines/agi/sound_sarien.cpp
index 9ea8569..a2baf89 100644
--- a/engines/agi/sound_sarien.cpp
+++ b/engines/agi/sound_sarien.cpp
@@ -65,7 +65,7 @@ static const int16 waveformMac[WAVEFORM_SIZE] = {
-175, -172, -165, -159, -137, -114, -67, -19
};
-SoundGenSarien::SoundGenSarien(AgiEngine *vm, Audio::Mixer *pMixer) : SoundGen(vm, pMixer), _chn() {
+SoundGenSarien::SoundGenSarien(AgiBase *vm, Audio::Mixer *pMixer) : SoundGen(vm, pMixer), _chn() {
_sndBuffer = (int16 *)calloc(2, BUFFER_SIZE);
memset(_sndBuffer, 0, BUFFER_SIZE << 1);
diff --git a/engines/agi/sound_sarien.h b/engines/agi/sound_sarien.h
index 22bfff3..04f274c 100644
--- a/engines/agi/sound_sarien.h
+++ b/engines/agi/sound_sarien.h
@@ -68,7 +68,7 @@ struct ChannelInfo {
class SoundGenSarien : public SoundGen, public Audio::AudioStream {
public:
- SoundGenSarien(AgiEngine *vm, Audio::Mixer *pMixer);
+ SoundGenSarien(AgiBase *vm, Audio::Mixer *pMixer);
~SoundGenSarien();
void play(int resnum);
Commit: 40f40303effec7d1055fc9212fd6cc8267f88585
https://github.com/scummvm/scummvm/commit/40f40303effec7d1055fc9212fd6cc8267f88585
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-08-14T10:14:37-07:00
Commit Message:
AGI: Enable sound support for Winnie DOS
Changed paths:
engines/agi/preagi.cpp
engines/agi/preagi_winnie.cpp
diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp
index c1a6cd3..6ed3ff8 100644
--- a/engines/agi/preagi.cpp
+++ b/engines/agi/preagi.cpp
@@ -63,10 +63,13 @@ void PreAgiEngine::initialize() {
// drivers, and I'm not sure what they are. For now, they might
// as well be called "PC Speaker" and "Not PC Speaker".
- switch (MidiDriver::getMusicType(MidiDriver::detectDevice(MDT_PCSPK))) {
+ switch (MidiDriver::getMusicType(MidiDriver::detectDevice(MDT_PCSPK|MDT_PCJR))) {
case MT_PCSPK:
_soundemu = SOUND_EMU_PC;
break;
+ case MT_PCJR:
+ _soundemu = SOUND_EMU_PCJR;
+ break;
default:
_soundemu = SOUND_EMU_NONE;
break;
@@ -89,9 +92,8 @@ void PreAgiEngine::initialize() {
}
_gfx = new GfxMgr(this);
- //_sound = new SoundMgr(this, _mixer);
+ _sound = new SoundMgr(this, _mixer);
_picture = new PictureMgr(this, _gfx);
- //_sprites = new SpritesMgr(this, _gfx);
_gfx->initMachine();
@@ -111,7 +113,7 @@ void PreAgiEngine::initialize() {
_game.lineMinPrint = 0; // hardcoded
_gfx->initVideo();
- //_sound->initSound();
+ _sound->initSound();
_speakerStream = new Audio::PCSpeaker(_mixer->getOutputRate());
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_speakerHandle,
diff --git a/engines/agi/preagi_winnie.cpp b/engines/agi/preagi_winnie.cpp
index af26fe6..8af2bdb 100644
--- a/engines/agi/preagi_winnie.cpp
+++ b/engines/agi/preagi_winnie.cpp
@@ -1110,9 +1110,56 @@ void Winnie::drawRoomPic() {
}
bool Winnie::playSound(ENUM_WTP_SOUND iSound) {
- //TODO
- warning ("STUB: playSound(%d)", iSound);
- return 1;
+ // TODO: Only DOS sound is supported, currently
+ if (_vm->getPlatform() != Common::kPlatformPC) {
+ warning("STUB: playSound(%d)", iSound);
+ return false;
+ }
+
+ Common::String fileName = Common::String::format(IDS_WTP_SND_DOS, iSound);
+
+ Common::File file;
+ if (!file.open(fileName))
+ return false;
+
+ uint32 size = file.size();
+ byte *data = new byte[size];
+ file.read(data, size);
+ file.close();
+
+ _vm->_game.sounds[0] = AgiSound::createFromRawResource(data, size, 0, *_vm->_sound, _vm->_soundemu);
+ _vm->_sound->startSound(0, 0);
+
+ bool cursorShowing = CursorMan.showMouse(false);
+ _vm->_system->updateScreen();
+
+ // Loop until the sound is done
+ bool skippedSound = false;
+ while (!_vm->shouldQuit() && _vm->_game.sounds[0]->isPlaying()) {
+ Common::Event event;
+ while (_vm->_system->getEventManager()->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ _vm->_sound->stopSound();
+ skippedSound = true;
+ break;
+ default:
+ break;
+ }
+ }
+
+ _vm->_system->delayMillis(10);
+ }
+
+ if (cursorShowing) {
+ CursorMan.showMouse(true);
+ _vm->_system->updateScreen();
+ }
+
+ delete _vm->_game.sounds[0];
+ _vm->_game.sounds[0] = 0;
+
+ return !_vm->shouldQuit() && !skippedSound;
}
void Winnie::clrMenuSel(int *iSel, int fCanSel[]) {
More information about the Scummvm-git-logs
mailing list