aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/items_v3.cpp8
-rw-r--r--engines/kyra/kyra_v3.cpp3
-rw-r--r--engines/kyra/kyra_v3.h15
-rw-r--r--engines/kyra/script_v3.cpp26
-rw-r--r--engines/kyra/sequences_v3.cpp78
-rw-r--r--engines/kyra/staticres.cpp8
-rw-r--r--engines/kyra/text_v3.cpp58
7 files changed, 187 insertions, 9 deletions
diff --git a/engines/kyra/items_v3.cpp b/engines/kyra/items_v3.cpp
index 12fd335fbf..1cbdf2ab40 100644
--- a/engines/kyra/items_v3.cpp
+++ b/engines/kyra/items_v3.cpp
@@ -499,7 +499,7 @@ bool KyraEngine_v3::itemListMagic(int handItem, int itemSlot) {
for (int i = 109; i <= 141; ++i) {
_animObjects[animObjIndex].shapeIndex = i+248;
_animObjects[animObjIndex].needRefresh = true;
- delay(1, true);
+ delay(1*_tickLength, true);
}
deleteItemAnimEntry(itemSlot);
@@ -549,7 +549,7 @@ bool KyraEngine_v3::itemListMagic(int handItem, int itemSlot) {
// Unlike the original we give points for when combining with scene items
if (resItem == 7) {
updateScore(35, 100);
- delay(60, true);
+ delay(60*_tickLength, true);
}
return true;
@@ -574,7 +574,7 @@ bool KyraEngine_v3::itemInventoryMagic(int handItem, int invSlot) {
_screen->drawShape(2, getShapePtr(i+248), 0, 144, 0, 0);
_screen->copyRegion(0, 144, _inventoryX[invSlot], _inventoryY[invSlot], 24, 20, 2, 0, Screen::CR_NO_P_CHECK);
_screen->updateScreen();
- delay(1, true);
+ delay(1*_tickLength, true);
}
_mainCharacter.inventory[invSlot] = 0xFFFF;
@@ -610,7 +610,7 @@ bool KyraEngine_v3::itemInventoryMagic(int handItem, int invSlot) {
// Unlike the original we give points for every language
if (resItem == 7) {
updateScore(35, 100);
- delay(60, true);
+ delay(60*_tickLength, true);
}
return true;
diff --git a/engines/kyra/kyra_v3.cpp b/engines/kyra/kyra_v3.cpp
index d6f68daf4f..20080f1783 100644
--- a/engines/kyra/kyra_v3.cpp
+++ b/engines/kyra/kyra_v3.cpp
@@ -136,6 +136,9 @@ KyraEngine_v3::KyraEngine_v3(OSystem *system, const GameFlags &flags) : KyraEngi
_mainButtonList = 0;
_mainButtonListInitialized = false;
_enableInventory = true;
+ _goodConscienceShown = false;
+ _goodConscienceAnim = -1;
+ _goodConsciencePosition = false;
}
KyraEngine_v3::~KyraEngine_v3() {
diff --git a/engines/kyra/kyra_v3.h b/engines/kyra/kyra_v3.h
index 518c34415d..aaaedf75d0 100644
--- a/engines/kyra/kyra_v3.h
+++ b/engines/kyra/kyra_v3.h
@@ -575,6 +575,9 @@ private:
void badConscienceChat(const char *str, int vocHigh, int vocLow);
void badConscienceChatWaitToFinish();
+ void goodConscienceChat(const char *str, int vocHigh, int vocLow);
+ void goodConscienceChatWaitToFinish();
+
void malcolmSceneStartupChat();
byte _newSceneDlgState[40];
@@ -622,6 +625,15 @@ private:
void showBadConscience();
void hideBadConscience();
+ bool _goodConscienceShown;
+ int _goodConscienceAnim;
+ bool _goodConsciencePosition;
+
+ static const uint8 _goodConscienceFrameTable[];
+
+ void showGoodConscience();
+ void hideGoodConscience();
+
// special script code
bool _temporaryScriptExecBit;
bool _useFrameTable;
@@ -763,6 +775,9 @@ private:
int o3_showSceneStringsMessage(ScriptState *script);
int o3_getRand(ScriptState *script);
int o3_setDeathHandler(ScriptState *script);
+ int o3_showGoodConscience(ScriptState *script);
+ int o3_goodConscienceChat(ScriptState *script);
+ int o3_hideGoodConscience(ScriptState *script);
int o3_waitForConfirmationClick(ScriptState *script);
int o3_defineRoomEntrance(ScriptState *script);
int o3_runTemporaryScript(ScriptState *script);
diff --git a/engines/kyra/script_v3.cpp b/engines/kyra/script_v3.cpp
index 93564c18e2..a2f5c28978 100644
--- a/engines/kyra/script_v3.cpp
+++ b/engines/kyra/script_v3.cpp
@@ -936,6 +936,26 @@ int KyraEngine_v3::o3_setDeathHandler(ScriptState *script) {
return 0;
}
+int KyraEngine_v3::o3_showGoodConscience(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_showGoodConscience(%p) ()", (const void *)script);
+ showGoodConscience();
+ return 0;
+}
+
+int KyraEngine_v3::o3_goodConscienceChat(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_goodConscienceChat(%p) (%d)", (const void *)script, stackPos(0));
+ int id = stackPos(0);
+ const char *str = (const char*)getTableEntry(_useActorBuffer ? _actorFile : _sceneStrings, id);
+ goodConscienceChat(str, _vocHigh, id);
+ return 0;
+}
+
+int KyraEngine_v3::o3_hideGoodConscience(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_hideGoodConscience(%p) ()", (const void *)script);
+ hideGoodConscience();
+ return 0;
+}
+
int KyraEngine_v3::o3_waitForConfirmationClick(ScriptState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o2_waitForConfirmationClick(%p) (%d)", (const void *)script, stackPos(0));
resetSkipFlag();
@@ -1545,10 +1565,10 @@ void KyraEngine_v3::setupOpcodeTable() {
Opcode(o3_getRand);
Opcode(o3_dummy);
Opcode(o3_setDeathHandler);
- OpcodeUnImpl();
+ Opcode(o3_showGoodConscience);
// 0x64
- OpcodeUnImpl();
- OpcodeUnImpl();
+ Opcode(o3_goodConscienceChat);
+ Opcode(o3_hideGoodConscience);
Opcode(o3_dummy);
Opcode(o3_dummy);
// 0x68
diff --git a/engines/kyra/sequences_v3.cpp b/engines/kyra/sequences_v3.cpp
index 0c833b1b3a..c2c25537b4 100644
--- a/engines/kyra/sequences_v3.cpp
+++ b/engines/kyra/sequences_v3.cpp
@@ -48,8 +48,8 @@ void KyraEngine_v3::showBadConscience() {
_badConsciencePosition = (_mainCharacter.x1 <= 160);
- //if (_goodConscienceShown)
- // _badConsciencePosition = !_goodConsciencePosition;
+ if (_goodConscienceShown)
+ _badConsciencePosition = !_goodConsciencePosition;
int anim = _badConscienceAnim + (_badConsciencePosition ? 0 : 8);
TalkObject &talkObject = _talkObjectList[1];
@@ -109,6 +109,80 @@ void KyraEngine_v3::hideBadConscience() {
setNextIdleAnimTimer();
}
+void KyraEngine_v3::showGoodConscience() {
+ debugC(9, kDebugLevelMain, "KyraEngine_v3::showGoodConscience()");
+
+ if (_goodConscienceShown)
+ return;
+
+ _goodConscienceShown = true;
+ ++_goodConscienceAnim;
+ _goodConscienceAnim %= 5;
+
+ setNextIdleAnimTimer();
+ _goodConsciencePosition = (_mainCharacter.x1 <= 160);
+
+ if (_badConscienceShown)
+ _goodConsciencePosition = !_badConsciencePosition;
+
+ int anim = _goodConscienceAnim + (_goodConsciencePosition ? 0 : 5);
+ TalkObject &talkObject = _talkObjectList[87];
+
+ if (_goodConsciencePosition)
+ talkObject.x = 290;
+ else
+ talkObject.x = 30;
+ talkObject.y = 30;
+
+ static const char *animFilenames[] = {
+ "STUFL00.WSA", "STUFL02.WSA", "STUFL04.WSA", "STUFL03.WSA", "STUFL01.WSA",
+ "STUFR00.WSA", "STUFR02.WSA", "STUFR04.WSA", "STUFR03.WSA", "STUFR01.WSA"
+ };
+
+ setupSceneAnimObject(0x0F, 9, 0, 187, -1, -1, -1, -1, 0, 0, 0, -1, animFilenames[anim]);
+ for (uint i = 0; i <= _goodConscienceFrameTable[_goodConscienceAnim]; ++i) {
+ if (i == 10)
+ playSoundEffect(0x7F, 0xC8);
+ updateSceneAnim(0x0F, i);
+ delay(2*_tickLength, true);
+ }
+
+ if (_mainCharacter.animFrame < 50 || _mainCharacter.animFrame > 87)
+ return;
+
+ if (_mainCharacter.y1 == -1 || (_mainCharacter.x1 != -1 && _mainCharacter.animFrame == 87) || _mainCharacter.animFrame == 87) {
+ _mainCharacter.animFrame = 87;
+ } else {
+ if (_goodConsciencePosition)
+ _mainCharacter.facing = 3;
+ else
+ _mainCharacter.facing = 5;
+ _mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing];
+ }
+
+ updateCharacterAnim(0);
+ refreshAnimObjectsIfNeed();
+}
+
+void KyraEngine_v3::hideGoodConscience() {
+ debugC(9, kDebugLevelMain, "KyraEngine_v3::hideGoodConscience()");
+ if (!_goodConscienceShown)
+ return;
+
+ _goodConscienceShown = false;
+ for (int frame = _goodConscienceFrameTable[_goodConscienceAnim+5]; frame >= 0; --frame) {
+ if (frame == 17)
+ playSoundEffect(0x31, 0xC8);
+ updateSceneAnim(0x0F, frame);
+ delay(1*_tickLength, true);
+ }
+
+ updateSceneAnim(0x0F, -1);
+ update();
+ removeSceneAnimObject(0x0F, 1);
+ setNextIdleAnimTimer();
+}
+
void KyraEngine_v3::runTemporaryScript(const char *filename, int allowSkip, int resetChar, int newShapes, int shapeUnload) {
debugC(9, kDebugLevelMain, "KyraEngine_v3::runTemporaryScript('%s', %d, %d, %d, %d)", filename, allowSkip, resetChar, newShapes, shapeUnload);
memset(&_temporaryScriptData, 0, sizeof(_temporaryScriptData));
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index e079bf4636..dca9342def 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -2344,6 +2344,14 @@ const uint8 KyraEngine_v3::_badConscienceFrameTable[] = {
0x24, 0x24, 0x24, 0x24, 0x24, 0x1D, 0x1D, 0x1D
};
+const uint8 KyraEngine_v3::_goodConscienceFrameTable[] = {
+ 0x13, 0x13, 0x13, 0x13, 0x13,
+ 0x13, 0x13, 0x13, 0x13, 0x13,
+ 0x13, 0x13, 0x13, 0x13, 0x13,
+ 0x15, 0x15, 0x15, 0x15, 0x15,
+ 0x1E, 0x1E, 0x1E, 0x1E, 0x1E
+};
+
const uint8 KyraEngine_v3::_chapterLowestScene[] = {
0x00, 0x00, 0x19, 0x2B, 0x33, 0x3B
};
diff --git a/engines/kyra/text_v3.cpp b/engines/kyra/text_v3.cpp
index ef931adb2b..0468c4729a 100644
--- a/engines/kyra/text_v3.cpp
+++ b/engines/kyra/text_v3.cpp
@@ -438,6 +438,64 @@ void KyraEngine_v3::badConscienceChatWaitToFinish() {
}
}
+void KyraEngine_v3::goodConscienceChat(const char *str, int vocHigh, int vocLow) {
+ debugC(9, kDebugLevelMain, "KyraEngine_v3::goodConscienceChat('%s', %d, %d)", str, vocHigh, vocLow);
+ if (!_goodConscienceShown)
+ return;
+
+ setNextIdleAnimTimer();
+ _chatVocHigh = _chatVocLow = -1;
+ objectChatInit(str, 87, vocHigh, vocLow);
+ _chatText = str;
+ _chatObject = 87;
+ goodConscienceChatWaitToFinish();
+ updateSceneAnim(0x0F, _goodConscienceFrameTable[_goodConscienceAnim+10]);
+ _text->restoreScreen();
+ update();
+ _chatText = 0;
+ _chatObject = -1;
+}
+
+void KyraEngine_v3::goodConscienceChatWaitToFinish() {
+ debugC(9, kDebugLevelMain, "KyraEngine_v3::goodConscienceChatWaitToFinish()");
+ if (_chatVocHigh) {
+ playVoice(_chatVocHigh, _chatVocLow);
+ _chatVocHigh = _chatVocLow = -1;
+ }
+
+ bool running = true;
+ const uint32 endTime = _chatEndTime;
+ resetSkipFlag();
+
+ uint32 nextFrame = _system->getMillis() + _rnd.getRandomNumberRng(3, 6) * _tickLength;
+
+ int frame = _goodConscienceFrameTable[_goodConscienceAnim+15];
+ while (running && !_quitFlag) {
+ if (nextFrame < _system->getMillis()) {
+ ++frame;
+ if (_goodConscienceFrameTable[_goodConscienceAnim+20] < frame)
+ frame = _goodConscienceFrameTable[_goodConscienceAnim+15];
+
+ updateSceneAnim(0x0F, frame);
+ updateWithText();
+
+ nextFrame = _system->getMillis() + _rnd.getRandomNumberRng(3, 6) * _tickLength;
+ }
+
+ updateWithText();
+
+ const uint32 curTime = _system->getMillis();
+ if ((textEnabled() && !speechEnabled() && curTime > endTime) || (speechEnabled() && !snd_voiceIsPlaying()) || skipFlag()) {
+ snd_stopVoice();
+ resetSkipFlag();
+ nextFrame = curTime;
+ running = false;
+ }
+
+ delay(10);
+ }
+}
+
void KyraEngine_v3::malcolmSceneStartupChat() {
debugC(9, kDebugLevelMain, "KyraEngine_v3::malcolmSceneStartupChat()");