diff options
-rw-r--r-- | engines/agi/preagi.cpp | 10 | ||||
-rw-r--r-- | engines/agi/preagi_winnie.cpp | 53 |
2 files changed, 56 insertions, 7 deletions
diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp index c1a6cd33fe..6ed3ff8ade 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 af26fe62d0..8af2bdbb41 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[]) { |