aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
authorathrxx2019-12-24 18:31:13 +0100
committerathrxx2019-12-30 17:51:34 +0100
commitcb01975aec75c17ba527f99c3988f728afdc714f (patch)
treea32271b2112bc652abe4d4c02b17d1f801e02ca8 /engines/kyra
parentd5b963a3b997067c874e6fb21445266bc4a1e766 (diff)
downloadscummvm-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')
-rw-r--r--engines/kyra/engine/kyra_hof.cpp14
-rw-r--r--engines/kyra/engine/kyra_hof.h5
-rw-r--r--engines/kyra/engine/kyra_v1.cpp17
-rw-r--r--engines/kyra/kyra_v1.h2
-rw-r--r--engines/kyra/resource/staticres.cpp25
-rw-r--r--engines/kyra/sequence/sequences_v2.cpp3
6 files changed, 59 insertions, 7 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));
diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h
index dc6662c5c3..b9e56632d2 100644
--- a/engines/kyra/kyra_v1.h
+++ b/engines/kyra/kyra_v1.h
@@ -290,6 +290,8 @@ protected:
Common::List<Event> _eventList;
typedef Common::HashMap<Common::KeyCode, int16, KeyCodeHash> KeyMap;
KeyMap _keyMap;
+ bool _asciiCodeEvents;
+ bool _kbEventSkip;
// config specific
virtual void registerDefaultSettings();
diff --git a/engines/kyra/resource/staticres.cpp b/engines/kyra/resource/staticres.cpp
index 5461fe3c57..8f7e41b886 100644
--- a/engines/kyra/resource/staticres.cpp
+++ b/engines/kyra/resource/staticres.cpp
@@ -1469,6 +1469,31 @@ const int8 KyraEngine_HoF::_pcSpkSfxMap[] = {
const int KyraEngine_HoF::_pcSpkSfxMapSize = ARRAYSIZE(KyraEngine_HoF::_pcSpkSfxMap);
+const int16 KyraEngine_HoF::_keyboardSounds[190] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 201, -1, 184, 73,
+
+ 74, 212, 78, 184, 104, 185, 99, 102, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 121, 108, 20,
+
+ 22, 25, 168, 171, 207, 174, 38, 39, 40, 41,
+ 44, 109, 46, 178, 180, 53, 181, 56, 106, 182,
+ 59, 62, 183, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 92, 15, 107, 191, -1, 134,
+ -1, 197, -1, 205, 152, 139, -1, -1, -1, -1
+};
+
void KyraEngine_HoF::initInventoryButtonList() {
delete[] _inventoryButtons;
diff --git a/engines/kyra/sequence/sequences_v2.cpp b/engines/kyra/sequence/sequences_v2.cpp
index 4c32357684..e9648c08a3 100644
--- a/engines/kyra/sequence/sequences_v2.cpp
+++ b/engines/kyra/sequence/sequences_v2.cpp
@@ -103,7 +103,8 @@ void KyraEngine_v2::processAnimationScript(int allowSkip, int resetChar) {
delay(10, true);
if (skipFlag()) {
- resetSkipFlag();
+ if (!_kbEventSkip || _eventList.front().event.type != Common::EVENT_KEYDOWN)
+ resetSkipFlag();
if (allowSkip)
break;
}