diff options
author | athrxx | 2019-12-24 18:31:13 +0100 |
---|---|---|
committer | athrxx | 2019-12-30 17:51:34 +0100 |
commit | cb01975aec75c17ba527f99c3988f728afdc714f (patch) | |
tree | a32271b2112bc652abe4d4c02b17d1f801e02ca8 /engines/kyra/engine | |
parent | d5b963a3b997067c874e6fb21445266bc4a1e766 (diff) | |
download | scummvm-rg350-cb01975aec75c17ba527f99c3988f728afdc714f.tar.gz scummvm-rg350-cb01975aec75c17ba527f99c3988f728afdc714f.tar.bz2 scummvm-rg350-cb01975aec75c17ba527f99c3988f728afdc714f.zip |
KYRA: (HOF) - fix bug #11289 (Secret potion issue)
- added a missing function that causes keyboard key presses to trigger certain sound effects
- improve keyboard responsiveness during idle animations (HOF only)
Diffstat (limited to 'engines/kyra/engine')
-rw-r--r-- | engines/kyra/engine/kyra_hof.cpp | 14 | ||||
-rw-r--r-- | engines/kyra/engine/kyra_hof.h | 5 | ||||
-rw-r--r-- | engines/kyra/engine/kyra_v1.cpp | 17 |
3 files changed, 30 insertions, 6 deletions
diff --git a/engines/kyra/engine/kyra_hof.cpp b/engines/kyra/engine/kyra_hof.cpp index ef8b119c0d..1d60c04035 100644 --- a/engines/kyra/engine/kyra_hof.cpp +++ b/engines/kyra/engine/kyra_hof.cpp @@ -71,6 +71,7 @@ KyraEngine_HoF::KyraEngine_HoF(OSystem *system, const GameFlags &flags) : KyraEn _unkHandleSceneChangeFlag = false; _pathfinderFlag = 0; _mouseX = _mouseY = 0; + _asciiCodeEvents = _kbEventSkip = true; _nextIdleAnim = 0; _lastIdleScript = -1; @@ -453,8 +454,8 @@ void KyraEngine_HoF::runLoop() { handleInput(_mouseX, _mouseY); } - //if (queryGameFlag(0x1EE) && inputFlag) - // sub_13B19(inputFlag); + if (queryGameFlag(0x1EE) && inputFlag) + processKeyboardSfx(inputFlag); _system->delayMillis(10); } @@ -1193,6 +1194,15 @@ int KyraEngine_HoF::inputSceneChange(int x, int y, int unk1, int unk2) { return refreshNPC; } +void KyraEngine_HoF::processKeyboardSfx(int inputFlag) { + if ((inputFlag & 0xFF) >= ARRAYSIZE(_keyboardSounds)) + return; + int16 track = _keyboardSounds[inputFlag & 0xFF]; + if (track == -1) + return; + snd_playSoundEffect(track); +} + int KyraEngine_HoF::getCharacterWalkspeed() const { return _timer->getDelay(0); } diff --git a/engines/kyra/engine/kyra_hof.h b/engines/kyra/engine/kyra_hof.h index 588efbb5ab..27638132bb 100644 --- a/engines/kyra/engine/kyra_hof.h +++ b/engines/kyra/engine/kyra_hof.h @@ -122,6 +122,11 @@ protected: int inputSceneChange(int x, int y, int unk1, int unk2); + // special case + void processKeyboardSfx(int inputFlag); + + static const int16 _keyboardSounds[190]; + // gfx/animation specific bool _inventorySaved; void backUpPage0(); diff --git a/engines/kyra/engine/kyra_v1.cpp b/engines/kyra/engine/kyra_v1.cpp index e42ede460d..fc43919b57 100644 --- a/engines/kyra/engine/kyra_v1.cpp +++ b/engines/kyra/engine/kyra_v1.cpp @@ -65,6 +65,7 @@ KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags) _isSaveAllowed = false; _mouseX = _mouseY = 0; + _asciiCodeEvents = _kbEventSkip = false; // sets up all engine specific debug levels DebugMan.addDebugChannel(kDebugLevelScriptFuncs, "ScriptFuncs", "Script function debug level"); @@ -277,13 +278,15 @@ int KyraEngine_v1::checkInput(Button *buttonList, bool mainLoop, int eventFlag) } } else { KeyMap::const_iterator keycode = _keyMap.find(event.kbd.keycode); - if (keycode != _keyMap.end()) { + if (_asciiCodeEvents) { + keys = event.kbd.ascii; + } else if (keycode != _keyMap.end()) { keys = keycode->_value; if (event.kbd.flags & Common::KBD_SHIFT) keys |= 0x100; } else { keys = 0; - } + } // When we got an keypress, which we might need to handle, // break the event loop and pass it to GUI code. @@ -433,6 +436,13 @@ void KyraEngine_v1::setupKeyMap() { _keyMap.clear(); + // If we have an engine that wants ASCII codes instead of key codes, we can skip the setup of the key map. + // In that case we simply return the ASCII codes from the event manager. At least until I know better I + // trust that the ASCII codes we get from our event manager are the same identical codes. If that assumption + // turns out to be wrong I can still implement the original conversion method... + if (_asciiCodeEvents) + return; + for (int i = 0; i < ARRAYSIZE(keys); i++) _keyMap[keys[i].kcScummVM] = (_flags.gameID != GI_EOB1 && _flags.platform == Common::kPlatformPC98) ? keys[i].kcPC98 : ((_flags.platform == Common::kPlatformFMTowns) ? keys[i].kcFMTowns : keys[i].kcDOS); } @@ -453,7 +463,7 @@ void KyraEngine_v1::updateInput() { else if (event.kbd.keycode == Common::KEYCODE_q && event.kbd.hasFlags(Common::KBD_CTRL)) quitGame(); else - _eventList.push_back(event); + _eventList.push_back(Event(event, _kbEventSkip)); break; case Common::EVENT_LBUTTONDOWN: @@ -507,7 +517,6 @@ void KyraEngine_v1::resetSkipFlag(bool removeEvent) { } } - int KyraEngine_v1::setGameFlag(int flag) { assert((flag >> 3) >= 0 && (flag >> 3) <= ARRAYSIZE(_flagsTable)); _flagsTable[flag >> 3] |= (1 << (flag & 7)); |