aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/kyra/kyra_v2.cpp7
-rw-r--r--engines/kyra/kyra_v2.h4
-rw-r--r--engines/kyra/script_v2.cpp16
3 files changed, 21 insertions, 6 deletions
diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp
index 90192c3518..b0082e8db1 100644
--- a/engines/kyra/kyra_v2.cpp
+++ b/engines/kyra/kyra_v2.cpp
@@ -102,6 +102,7 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi
_colorCodeFlag1 = 0;
_colorCodeFlag2 = -1;
_scriptCountDown = 0;
+ memset(_inputColorCode, 0, 7);
_gamePlayBuffer = 0;
_unkBuf500Bytes = 0;
@@ -699,14 +700,14 @@ void KyraEngine_v2::updateMouse() {
yOffset = 9;
}
- if (type != 0 && _handItemSet != type) {
+ if (type != 0 && _handItemSet != type && _screen->isMouseVisible()) {
_mouseState = _handItemSet = type;
_screen->hideMouse();
_screen->setMouseCursor(xOffset, yOffset, getShapePtr(shapeIndex));
_screen->showMouse();
}
- if (type == 0 && _handItemSet != _itemInHand) {
+ if (type == 0 && _handItemSet != _itemInHand && _screen->isMouseVisible()) {
if ((mouse.y > 145) || (mouse.x > 6 && mouse.x < 312 && mouse.y > 6 && mouse.y < 135)) {
_mouseState = 0;
_handItemSet = _itemInHand;
@@ -2224,7 +2225,7 @@ void KyraEngine_v2::setupOpcodeTable() {
Opcode(o2_getCountDown),
Opcode(o2_dummy),
Opcode(o2_dummy),
- OpcodeUnImpl(),
+ Opcode(o2_pressColorKey),
// 0x80
Opcode(o2_objectChat),
OpcodeUnImpl(),
diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h
index c145c79727..4f2f696305 100644
--- a/engines/kyra/kyra_v2.h
+++ b/engines/kyra/kyra_v2.h
@@ -993,6 +993,7 @@ protected:
int o2_addCauldronStateTableEntry(ScriptState *script);
int o2_setCountDown(ScriptState *script);
int o2_getCountDown(ScriptState *script);
+ int o2_pressColorKey(ScriptState *script);
int o2_objectChat(ScriptState *script);
int o2_getColorCodeFlag1(ScriptState *script);
int o2_setColorCodeFlag1(ScriptState *script);
@@ -1120,7 +1121,8 @@ protected:
// color code related vars
int _colorCodeFlag1;
int _colorCodeFlag2;
- uint8 _colorCode[7];
+ uint8 _presetColorCode[7];
+ uint8 _inputColorCode[7];
uint32 _scriptCountDown;
};
diff --git a/engines/kyra/script_v2.cpp b/engines/kyra/script_v2.cpp
index 0fe07ab93a..1f1275547a 100644
--- a/engines/kyra/script_v2.cpp
+++ b/engines/kyra/script_v2.cpp
@@ -720,6 +720,18 @@ int KyraEngine_v2::o2_getCountDown(ScriptState *script) {
return (time > _scriptCountDown) ? 0 : (_scriptCountDown - time) / _tickLength;
}
+int KyraEngine_v2::o2_pressColorKey(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "o2_pressColorKey(%p) (%d)", (const void *)script, stackPos(0));
+ for (int i = 6; i; i--)
+ _inputColorCode[i] = _inputColorCode[i - 1];
+ _inputColorCode[0] = stackPos(0) & 0xff;
+ for (int i = 0; i < 7; i++) {
+ if (_presetColorCode[i] != _inputColorCode[6 - i])
+ return 0;
+ }
+ return 1;
+}
+
int KyraEngine_v2::o2_objectChat(ScriptState *script) {
debugC(3, kDebugLevelScriptFuncs, "o2_objectChat(%p) ('%s', %d)", (const void *)script, stackPosString(0), stackPos(1));
if (_flags.isTalkie)
@@ -753,12 +765,12 @@ int KyraEngine_v2::o2_setColorCodeFlag2(ScriptState *script) {
int KyraEngine_v2::o2_getColorCodeValue(ScriptState *script) {
debugC(3, kDebugLevelScriptFuncs, "o2_getColorCodeValue(%p) (%d)", (const void *)script, stackPos(0));
- return _colorCode[stackPos(0)];
+ return _presetColorCode[stackPos(0)];
}
int KyraEngine_v2::o2_setColorCodeValue(ScriptState *script) {
debugC(3, kDebugLevelScriptFuncs, "o2_setColorCodeValue(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
- _colorCode[stackPos(0)] = stackPos(1) & 0xff;
+ _presetColorCode[stackPos(0)] = stackPos(1) & 0xff;
return stackPos(1) & 0xff;
}