diff options
Diffstat (limited to 'engines/kyra')
-rw-r--r-- | engines/kyra/kyra_v1.cpp | 46 | ||||
-rw-r--r-- | engines/kyra/sound.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/sound.h | 8 | ||||
-rw-r--r-- | engines/kyra/sound_adlib.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/sound_intern.h | 4 | ||||
-rw-r--r-- | engines/kyra/sound_midi.cpp | 20 | ||||
-rw-r--r-- | engines/kyra/sound_towns.cpp | 4 |
7 files changed, 67 insertions, 21 deletions
diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index 7f4f1ec2c7..f108082e13 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -84,7 +84,7 @@ KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags) } void KyraEngine_v1::pauseEngineIntern(bool pause) { - Engine::pauseEngineIntern(pause); + _sound->pause(pause); _timer->pause(pause); } @@ -350,23 +350,43 @@ int KyraEngine_v1::checkInput(Button *buttonList, bool mainLoop, int eventFlag) } void KyraEngine_v1::setupKeyMap() { - static const Common::KeyCode keyboardEvents[] = { - Common::KEYCODE_SPACE, Common::KEYCODE_RETURN, Common::KEYCODE_UP, Common::KEYCODE_KP8, - Common::KEYCODE_RIGHT, Common::KEYCODE_KP6, Common::KEYCODE_DOWN, Common::KEYCODE_KP2, - Common::KEYCODE_KP5, Common::KEYCODE_LEFT, Common::KEYCODE_KP4, Common::KEYCODE_HOME, - Common::KEYCODE_KP7, Common::KEYCODE_PAGEUP, Common::KEYCODE_KP9, Common::KEYCODE_F1, - Common::KEYCODE_F2, Common::KEYCODE_F3, Common::KEYCODE_o, Common::KEYCODE_r, - Common::KEYCODE_SLASH, Common::KEYCODE_ESCAPE + struct KeyMapEntry { + Common::KeyCode kcScummVM; + int16 kcDOS; + int16 kcPC98; }; - static const int16 keyCodesDOS[] = { 61, 43, 96, 96, 102, 102, 98, 98, 97, 92, 92, 91, 91, 101, 101, 112, 113, 114, 25, 20, 55, 110}; - static const int16 keyCodesPC98[] = { 53, 29, 68, 68, 73, 73, 76, 76, 72, 71, 71, 67, 67, 69, 69, 99, 100, 101, 25, 20, 55, 1 }; +#define KC(x) Common::KEYCODE_##x + static const KeyMapEntry keys[] = { + { KC(SPACE), 61, 53 }, + { KC(RETURN), 43, 29 }, + { KC(UP), 96, 68 }, + { KC(KP8), 96, 68 }, + { KC(RIGHT), 102, 73 }, + { KC(KP6), 102, 73 }, + { KC(DOWN), 98, 76 }, + { KC(KP2), 98, 76 }, + { KC(KP5), 97, 72 }, + { KC(LEFT), 92, 71 }, + { KC(KP4), 92, 71 }, + { KC(HOME), 91, 67 }, + { KC(KP7), 91, 67 }, + { KC(PAGEUP), 101, 69 }, + { KC(KP9), 101, 69 }, + { KC(F1), 112, 99 }, + { KC(F2), 113, 100 }, + { KC(F3), 114, 101 }, + { KC(o), 25, 25 }, + { KC(r), 20, 20 }, + { KC(SLASH), 55, 55 }, + { KC(ESCAPE), 110, 1 }, + }; +#undef KC - const int16 *keyCodes = _flags.platform == Common::kPlatformPC98 ? keyCodesPC98 : keyCodesDOS; _keyMap.clear(); - for (int i = 0; i < ARRAYSIZE(keyboardEvents); i++) - _keyMap[keyboardEvents[i]] = keyCodes[i]; + for (int i = 0; i < ARRAYSIZE(keys); i++) + _keyMap[keys[i].kcScummVM] = (_flags.platform == Common::kPlatformPC98) ? keys[i].kcPC98 : keys[i].kcDOS; } void KyraEngine_v1::updateInput() { diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp index 4da35cc28b..3713537afd 100644 --- a/engines/kyra/sound.cpp +++ b/engines/kyra/sound.cpp @@ -43,6 +43,10 @@ Sound::Sound(KyraEngine_v1 *vm, Audio::Mixer *mixer) Sound::~Sound() { } +void Sound::pause(bool paused) { + _mixer->pauseAll(paused); +} + bool Sound::voiceFileIsPresent(const char *file) { for (int i = 0; _supportedCodecs[i].fileext; ++i) { Common::String f = file; diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h index 4f8e54212f..566b37ff43 100644 --- a/engines/kyra/sound.h +++ b/engines/kyra/sound.h @@ -101,7 +101,7 @@ public: /** * Load a sound file for playing music - * (and somtimes sound effects) from. + * (and sometimes sound effects) from. */ virtual void loadSoundFile(Common::String file) = 0; @@ -153,6 +153,11 @@ public: */ virtual void beginFadeOut() = 0; + /** + * Stops all audio playback when paused. Continues after end of pause. + */ + virtual void pause(bool paused); + void enableMusic(int enable) { _musicEnabled = enable; } int musicEnabled() const { return _musicEnabled; } void enableSFX(bool enable) { _sfxEnabled = enable; } @@ -275,6 +280,7 @@ public: void stopAllSoundEffects() { _sfx->stopAllSoundEffects(); } void beginFadeOut() { _music->beginFadeOut(); } + void pause(bool paused) { _music->pause(paused); _sfx->pause(paused); } private: Sound *_music, *_sfx; }; diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp index 6ca01c65f3..75041b8161 100644 --- a/engines/kyra/sound_adlib.cpp +++ b/engines/kyra/sound_adlib.cpp @@ -1558,7 +1558,7 @@ int AdLibDriver::update_changeExtraLevel2(uint8 *&dataptr, Channel &channel, uin return 0; } -// Apart from initialising to zero, these two functions are the only ones that +// Apart from initializing to zero, these two functions are the only ones that // modify _vibratoAndAMDepthBits. int AdLibDriver::update_setAMDepth(uint8 *&dataptr, Channel &channel, uint8 value) { diff --git a/engines/kyra/sound_intern.h b/engines/kyra/sound_intern.h index 488dbc3742..2ba0890789 100644 --- a/engines/kyra/sound_intern.h +++ b/engines/kyra/sound_intern.h @@ -71,6 +71,8 @@ public: void stopAllSoundEffects(); void beginFadeOut(); + + void pause(bool paused); private: static void onTimer(void *data); @@ -139,8 +141,6 @@ private: TownsEuphonyDriver *_driver; - Common::Mutex _mutex; - bool _cdaPlaying; const uint8 *_musicFadeTable; diff --git a/engines/kyra/sound_midi.cpp b/engines/kyra/sound_midi.cpp index 00f6c9329e..6c003d0a11 100644 --- a/engines/kyra/sound_midi.cpp +++ b/engines/kyra/sound_midi.cpp @@ -714,6 +714,26 @@ void SoundMidiPC::beginFadeOut() { _fadeStartTime = _vm->_system->getMillis(); } +void SoundMidiPC::pause(bool paused) { + // Stop all mixer related sounds + Sound::pause(paused); + + Common::StackLock lock(_mutex); + + if (paused) { + _music->setMidiDriver(0); + for (int i = 0; i < 3; i++) + _sfx[i]->setMidiDriver(0); + for (int i = 0; i < 16; i++) + _output->stopNotesOnChannel(i); + } else { + _music->setMidiDriver(_output); + for (int i = 0; i < 3; ++i) + _sfx[i]->setMidiDriver(_output); + // Possible TODO (IMHO unnecessary): restore notes and/or update _fadeStartTime + } +} + void SoundMidiPC::onTimer(void *data) { SoundMidiPC *midi = (SoundMidiPC *)data; diff --git a/engines/kyra/sound_towns.cpp b/engines/kyra/sound_towns.cpp index 9a9892c9a4..73d435f3e5 100644 --- a/engines/kyra/sound_towns.cpp +++ b/engines/kyra/sound_towns.cpp @@ -297,8 +297,6 @@ bool SoundTowns::loadInstruments() { if (!twm) return false; - Common::StackLock lock(_mutex); - Screen::decodeFrame4(twm, _musicTrackData, 50570); for (int i = 0; i < 128; i++) _driver->loadInstrument(0, i, &_musicTrackData[i * 48 + 8]); @@ -322,8 +320,6 @@ bool SoundTowns::loadInstruments() { } void SoundTowns::playEuphonyTrack(uint32 offset, int loop) { - Common::StackLock lock(_mutex); - uint8 *twm = _vm->resource()->fileData("twmusic.pak", 0); Screen::decodeFrame4(twm + 19312 + offset, _musicTrackData, 50570); delete[] twm; |