aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
authorJohannes Schickel2008-04-20 13:44:44 +0000
committerJohannes Schickel2008-04-20 13:44:44 +0000
commitcdfcab93153fd660e633a98e48a441cbf1cda4b9 (patch)
tree8dd522770766fd5e84dde895751bc8407a102b3d /engines/kyra
parent78c675278b1a232d2058b2d85eb089bfdec64b12 (diff)
downloadscummvm-rg350-cdfcab93153fd660e633a98e48a441cbf1cda4b9.tar.gz
scummvm-rg350-cdfcab93153fd660e633a98e48a441cbf1cda4b9.tar.bz2
scummvm-rg350-cdfcab93153fd660e633a98e48a441cbf1cda4b9.zip
Implemented opcodes:
- 6: o3_getCharacterFacing - 7: o3_getCharacterScene - 13: o3_trySceneChange - 32: o3_checkForItem - 46: o3_addSpecialExit - 63: o3_drawSceneShape - 75: o3_update - 80: o3_enterNewScene - 86: o3_setMalcolmPos - 154: o3_setupSceneAnimObject svn-id: r31596
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/items_v3.cpp9
-rw-r--r--engines/kyra/kyra_v3.cpp4
-rw-r--r--engines/kyra/kyra_v3.h19
-rw-r--r--engines/kyra/scene_v3.cpp3
-rw-r--r--engines/kyra/script_v3.cpp130
5 files changed, 153 insertions, 12 deletions
diff --git a/engines/kyra/items_v3.cpp b/engines/kyra/items_v3.cpp
index 7ec48c647d..993a6599f7 100644
--- a/engines/kyra/items_v3.cpp
+++ b/engines/kyra/items_v3.cpp
@@ -51,6 +51,15 @@ int KyraEngine_v3::findFreeItem() {
return -1;
}
+int KyraEngine_v3::findItem(uint16 sceneId, uint16 id) {
+ debugC(9, kDebugLevelMain, "KyraEngine_v3::findItem(%u, %u)", sceneId, id);
+ for (int i = 0; i < 50; ++i) {
+ if (_itemList[i].id == id && _itemList[i].sceneId == sceneId)
+ return i;
+ }
+ return -1;
+}
+
int KyraEngine_v3::checkItemCollision(int x, int y) {
debugC(9, kDebugLevelMain, "KyraEngine_v3::checkItemCollision(%d, %d)", x, y);
int itemIndex = -1;
diff --git a/engines/kyra/kyra_v3.cpp b/engines/kyra/kyra_v3.cpp
index af0e8687e4..5088f3557b 100644
--- a/engines/kyra/kyra_v3.cpp
+++ b/engines/kyra/kyra_v3.cpp
@@ -111,6 +111,7 @@ KyraEngine_v3::KyraEngine_v3(OSystem *system, const GameFlags &flags) : KyraEngi
_deathHandler = -1;
_moveFacingTable = 0;
_unkHandleSceneChangeFlag = false;
+ memset(_sceneShapeDescs, 0, sizeof(_sceneShapeDescs));
}
KyraEngine_v3::~KyraEngine_v3() {
@@ -441,7 +442,8 @@ bool KyraEngine_v3::snd_voiceIsPlaying() {
void KyraEngine_v3::snd_stopVoice() {
debugC(9, kDebugLevelMain, "KyraEngine_v3::snd_stopVoice()");
- _soundDigital->stopSound(_voiceSoundChannel);
+ if (_voiceSoundChannel != -1)
+ _soundDigital->stopSound(_voiceSoundChannel);
}
void KyraEngine_v3::playStudioSFX(const char *str) {
diff --git a/engines/kyra/kyra_v3.h b/engines/kyra/kyra_v3.h
index 5706e0f575..1005547433 100644
--- a/engines/kyra/kyra_v3.h
+++ b/engines/kyra/kyra_v3.h
@@ -274,6 +274,7 @@ private:
void resetItemList();
int findFreeItem();
+ int findItem(uint16 item, uint16 scene);
void initItems();
@@ -391,6 +392,14 @@ private:
int8 _sceneDatPalette[45];
int8 _sceneDatLayerTable[15];
+ struct SceneShapeDesc {
+ // the original saves those variables, we don't, since
+ // they are just needed on scene load
+ /*int x, y;
+ int w, h;*/
+ int drawX, drawY;
+ };
+ SceneShapeDesc _sceneShapeDescs[20];
int getDrawLayer(int x, int y);
@@ -525,22 +534,31 @@ private:
int o3_refreshCharacter(ScriptState *script);
int o3_getCharacterX(ScriptState *script);
int o3_getCharacterY(ScriptState *script);
+ int o3_getCharacterFacing(ScriptState *script);
+ int o3_getCharacterScene(ScriptState *script);
+ int o3_trySceneChange(ScriptState *script);
int o3_showSceneFileMessage(ScriptState *script);
int o3_showBadConscience(ScriptState *script);
int o3_hideBadConscience(ScriptState *script);
int o3_objectChat(ScriptState *script);
+ int o3_checkForItem(ScriptState *script);
int o3_defineItem(ScriptState *script);
int o3_queryGameFlag(ScriptState *script);
int o3_resetGameFlag(ScriptState *script);
int o3_setGameFlag(ScriptState *script);
int o3_getHandItem(ScriptState *script);
int o3_hideMouse(ScriptState *script);
+ int o3_addSpecialExit(ScriptState *script);
int o3_setMousePos(ScriptState *script);
int o3_showMouse(ScriptState *script);
int o3_badConscienceChat(ScriptState *script);
int o3_delay(ScriptState *script);
int o3_setSceneFilename(ScriptState *script);
+ int o3_drawSceneShape(ScriptState *script);
int o3_checkInRect(ScriptState *script);
+ int o3_update(ScriptState *script);
+ int o3_enterNewScene(ScriptState *script);
+ int o3_setMalcolmPos(ScriptState *script);
int o3_stopMusic(ScriptState *script);
int o3_playMusicTrack(ScriptState *script);
int o3_playSoundEffect(ScriptState *script);
@@ -555,6 +573,7 @@ private:
int o3_querySpecialSceneScriptState(ScriptState *script);
int o3_setHiddenItemsEntry(ScriptState *script);
int o3_getHiddenItemsEntry(ScriptState *script);
+ int o3_setupSceneAnimObject(ScriptState *script);
int o3_removeSceneAnimObject(ScriptState *script);
int o3_setVocHigh(ScriptState *script);
int o3_getVocHigh(ScriptState *script);
diff --git a/engines/kyra/scene_v3.cpp b/engines/kyra/scene_v3.cpp
index e849493307..74beb6ba30 100644
--- a/engines/kyra/scene_v3.cpp
+++ b/engines/kyra/scene_v3.cpp
@@ -410,7 +410,8 @@ void KyraEngine_v3::initSceneScript(int unk1) {
int16 y = stream->readSint16LE();
int16 w = stream->readSint16LE();
int16 h = stream->readSint16LE();
- stream->seek(4, SEEK_CUR);
+ _sceneShapeDescs[i].drawX = stream->readSint16LE();
+ _sceneShapeDescs[i].drawY = stream->readSint16LE();
_sceneShapes[i] = _screen->encodeShape(x, y, w, h, 0);
assert(_sceneShapes[i]);
musicUpdate(0);
diff --git a/engines/kyra/script_v3.cpp b/engines/kyra/script_v3.cpp
index ddab206790..3aea21fca4 100644
--- a/engines/kyra/script_v3.cpp
+++ b/engines/kyra/script_v3.cpp
@@ -98,6 +98,35 @@ int KyraEngine_v3::o3_getCharacterY(ScriptState *script) {
return _mainCharacter.y1;
}
+int KyraEngine_v3::o3_getCharacterFacing(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_getCharacterFacing(%p) ()", (const void *)script);
+ return _mainCharacter.facing;
+}
+
+int KyraEngine_v3::o3_getCharacterScene(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_getCharacterScene(%p) ()", (const void *)script);
+ return _mainCharacter.sceneId;
+}
+
+int KyraEngine_v3::o3_trySceneChange(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_trySceneChange(%p) (%d, %d, %d, %d)", (const void *)script,
+ stackPos(0), stackPos(1), stackPos(2), stackPos(3));
+
+ _unkHandleSceneChangeFlag = 1;
+ int success = inputSceneChange(stackPos(0), stackPos(1), stackPos(2), stackPos(3));
+ _unkHandleSceneChangeFlag = 0;
+
+ if (success) {
+ _scriptInterpreter->initScript(script, script->dataPtr);
+ _unk4 = 0;
+ _unk3 = -1;
+ _unk5 = 1;
+ return 0;
+ } else {
+ return (_unk4 != 0) ? 1 : 0;
+ }
+}
+
int KyraEngine_v3::o3_showSceneFileMessage(ScriptState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_showSceneFileMessage(%p) (%d)", (const void *)script, stackPos(0));
showMessage((const char*)getTableEntry(_scenesFile, stackPos(0)), 0xFF, 0xF0);
@@ -127,6 +156,11 @@ int KyraEngine_v3::o3_objectChat(ScriptState *script) {
return 0;
}
+int KyraEngine_v3::o3_checkForItem(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_checkForItem(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
+ return findItem(stackPos(0), stackPos(1)) == -1 ? 0 : 1;
+}
+
int KyraEngine_v3::o3_defineItem(ScriptState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_defineItem(%p) (%d, %d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2), stackPos(3));
int freeItem = findFreeItem();
@@ -167,6 +201,20 @@ int KyraEngine_v3::o3_hideMouse(ScriptState *script) {
return 0;
}
+int KyraEngine_v3::o3_addSpecialExit(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_addSpecialExit(%p) (%d, %d, %d, %d, %d)", (const void *)script,
+ stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4));
+ if (_specialExitCount < 5) {
+ _specialExitTable[_specialExitCount+0] = stackPos(0);
+ _specialExitTable[_specialExitCount+5] = stackPos(1);
+ _specialExitTable[_specialExitCount+10] = stackPos(2) + stackPos(0) - 1;
+ _specialExitTable[_specialExitCount+15] = stackPos(3) + stackPos(1) - 1;
+ _specialExitTable[_specialExitCount+20] = stackPos(4);
+ ++_specialExitCount;
+ }
+ return 0;
+}
+
int KyraEngine_v3::o3_setMousePos(ScriptState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_setMousePos(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
setMousePos(stackPos(0), stackPos(1));
@@ -206,6 +254,16 @@ int KyraEngine_v3::o3_setSceneFilename(ScriptState *script) {
return 0;
}
+int KyraEngine_v3::o3_drawSceneShape(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_drawSceneShape(%p) (%d, %d, %d)", (const void *)script, stackPos(0), stackPos(1), stackPos(2));
+ const int shape = stackPos(0);
+
+ int x = _sceneShapeDescs[shape].drawX;
+ int y = _sceneShapeDescs[shape].drawY;
+ _screen->drawShape(stackPos(2), _sceneShapes[shape], x, y, 2, (stackPos(1) != 0) ? 1 : 0);
+ return 0;
+}
+
int KyraEngine_v3::o3_checkInRect(ScriptState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_checkInRect(%p) (%d, %d, %d, %d, %d, %d)", (const void *)script,
stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5));
@@ -231,6 +289,48 @@ int KyraEngine_v3::o3_checkInRect(ScriptState *script) {
}
}
+int KyraEngine_v3::o3_update(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_update(%p) (%d)", (const void *)script, stackPos(0));
+ for (int times = stackPos(0); times != 0; --times) {
+ if (_chatText)
+ updateWithText();
+ else
+ update();
+ }
+ return 0;
+}
+
+int KyraEngine_v3::o3_enterNewScene(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_enterNewScene(%p) (%d, %d, %d, %d, %d)", (const void *)script, stackPos(0),
+ stackPos(1), stackPos(2), stackPos(3), stackPos(4));
+
+ _screen->hideMouse();
+ enterNewScene(stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4));
+
+ _unk5 = 1;
+
+ if (_mainCharX == -1 || _mainCharY == -1) {
+ _mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing];
+ updateCharacterAnim(0);
+ }
+ _screen->showMouse();
+
+ return 0;
+}
+
+int KyraEngine_v3::o3_setMalcolmPos(ScriptState *script) {
+ debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_setMalcolmPos(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
+ _mainCharX = stackPos(0);
+ _mainCharY = stackPos(1);
+
+ if (_mainCharX == -1 && _mainCharY == -1)
+ _mainCharacter.animFrame = 87;
+ else
+ _mainCharacter.animFrame = _characterFrameTable[_mainCharacter.facing];
+
+ return 0;
+}
+
int KyraEngine_v3::o3_stopMusic(ScriptState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_stopMusic(%p) ()", (const void *)script);
stopMusicTrack();
@@ -408,6 +508,16 @@ int KyraEngine_v3::o3_getHiddenItemsEntry(ScriptState *script) {
return (int16)_hiddenItems[stackPos(0)];
}
+int KyraEngine_v3::o3_setupSceneAnimObject(ScriptState *script) {
+ debugC(9, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_setupSceneAnimObject(%p) (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, '%s')", (const void *)script,
+ stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7), stackPos(8), stackPos(9),
+ stackPos(10), stackPos(11), stackPosString(12));
+ musicUpdate(0);
+ setupSceneAnimObject(stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5), stackPos(6), stackPos(7), stackPos(8),
+ stackPos(9), stackPos(10), stackPos(11), stackPosString(12));
+ return 0;
+}
+
int KyraEngine_v3::o3_removeSceneAnimObject(ScriptState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_removeSceneAnimObject(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1));
removeSceneAnimObject(stackPos(0), stackPos(1));
@@ -483,8 +593,8 @@ void KyraEngine_v3::setupOpcodeTable() {
// 0x04
Opcode(o3_getCharacterX),
Opcode(o3_getCharacterY),
- OpcodeUnImpl(),
- OpcodeUnImpl(),
+ Opcode(o3_getCharacterFacing),
+ Opcode(o3_getCharacterScene),
// 0x08
OpcodeUnImpl(),
Opcode(o3_dummy),
@@ -492,7 +602,7 @@ void KyraEngine_v3::setupOpcodeTable() {
OpcodeUnImpl(),
// 0x0c
OpcodeUnImpl(),
- OpcodeUnImpl(),
+ Opcode(o3_trySceneChange),
OpcodeUnImpl(),
OpcodeUnImpl(),
// 0x10
@@ -516,7 +626,7 @@ void KyraEngine_v3::setupOpcodeTable() {
OpcodeUnImpl(),
Opcode(o3_objectChat),
// 0x20
- OpcodeUnImpl(),
+ Opcode(o3_checkForItem),
Opcode(o3_dummy),
OpcodeUnImpl(),
Opcode(o3_defineItem),
@@ -533,7 +643,7 @@ void KyraEngine_v3::setupOpcodeTable() {
// 0x2c
Opcode(o3_getHandItem),
Opcode(o3_hideMouse),
- OpcodeUnImpl(),
+ Opcode(o3_addSpecialExit),
Opcode(o3_setMousePos),
// 0x30
Opcode(o3_showMouse),
@@ -554,7 +664,7 @@ void KyraEngine_v3::setupOpcodeTable() {
OpcodeUnImpl(),
OpcodeUnImpl(),
OpcodeUnImpl(),
- OpcodeUnImpl(),
+ Opcode(o3_drawSceneShape),
// 0x40
Opcode(o3_checkInRect),
OpcodeUnImpl(),
@@ -569,21 +679,21 @@ void KyraEngine_v3::setupOpcodeTable() {
Opcode(o3_dummy),
Opcode(o3_dummy),
OpcodeUnImpl(),
- OpcodeUnImpl(),
+ Opcode(o3_update),
// 0x4c
OpcodeUnImpl(),
OpcodeUnImpl(),
OpcodeUnImpl(),
OpcodeUnImpl(),
// 0x50
- OpcodeUnImpl(),
+ Opcode(o3_enterNewScene),
OpcodeUnImpl(),
OpcodeUnImpl(),
Opcode(o3_dummy),
// 0x54
Opcode(o3_dummy),
Opcode(o3_dummy),
- OpcodeUnImpl(),
+ Opcode(o3_setMalcolmPos),
Opcode(o3_stopMusic),
// 0x58
Opcode(o3_playMusicTrack),
@@ -668,7 +778,7 @@ void KyraEngine_v3::setupOpcodeTable() {
// 0x98
OpcodeUnImpl(),
OpcodeUnImpl(),
- OpcodeUnImpl(),
+ Opcode(o3_setupSceneAnimObject),
Opcode(o3_removeSceneAnimObject),
// 0x9c
OpcodeUnImpl(),