aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorEugene Sandulenko2004-10-27 22:17:11 +0000
committerEugene Sandulenko2004-10-27 22:17:11 +0000
commit213c4093bac6954e17be4311d9a7840402764780 (patch)
tree6591f3f90efb5552cc71ebf44b810dff0dba5b65 /saga
parentc7e5ab1f2d0f103de25da3c57cd30d5ee3ec7312 (diff)
downloadscummvm-rg350-213c4093bac6954e17be4311d9a7840402764780.tar.gz
scummvm-rg350-213c4093bac6954e17be4311d9a7840402764780.tar.bz2
scummvm-rg350-213c4093bac6954e17be4311d9a7840402764780.zip
Implement some script functions and report stubs.
svn-id: r15691
Diffstat (limited to 'saga')
-rw-r--r--saga/saga.h3
-rw-r--r--saga/scene.cpp6
-rw-r--r--saga/scene.h3
-rw-r--r--saga/script.h5
-rw-r--r--saga/sfuncs.cpp201
-rw-r--r--saga/sthread.cpp6
-rw-r--r--saga/xref.txt6
7 files changed, 169 insertions, 61 deletions
diff --git a/saga/saga.h b/saga/saga.h
index fe3f3f6e51..7c209a3afb 100644
--- a/saga/saga.h
+++ b/saga/saga.h
@@ -116,6 +116,9 @@ public:
Events *_events;
PalAnim *_palanim;
+ /** Random number generator */
+ Common::RandomSource _rnd;
+
private:
int decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outbuf, size_t outbuf_len);
int flipImage(byte *img_buf, int columns, int scanlines);
diff --git a/saga/scene.cpp b/saga/scene.cpp
index aa71c92e65..8f4d5fa4b4 100644
--- a/saga/scene.cpp
+++ b/saga/scene.cpp
@@ -411,6 +411,12 @@ int Scene::getInfo(SCENE_INFO *si) {
return SUCCESS;
}
+int Scene::getSceneLUT(int scene_num) {
+ assert((scene_num > 0) && (scene_num < _sceneMax));
+
+ return _sceneLUT[scene_num];
+};
+
int Scene::loadScene(int scene_num, int load_flag, SCENE_PROC scene_proc, SCENE_DESC *scene_desc_param, int fadeType) {
SCENE_INFO scene_info;
uint32 res_number = 0;
diff --git a/saga/scene.h b/saga/scene.h
index 0e8a459a86..44ed469127 100644
--- a/saga/scene.h
+++ b/saga/scene.h
@@ -238,6 +238,9 @@ class Scene {
void sceneInfoCmd(int argc, char *argv[]);
void sceneChangeCmd(int argc, char *argv[]);
+ int getSceneLUT(int num);
+ int currentSceneNumber() { return _sceneNumber; }
+
private:
int loadScene(int scene, int load_flag, SCENE_PROC scene_proc, SCENE_DESC *,
int fadeIn);
diff --git a/saga/script.h b/saga/script.h
index 71ebcefc4c..757cf933a8 100644
--- a/saga/script.h
+++ b/saga/script.h
@@ -301,6 +301,11 @@ private:
int SF_enableEscape(SCRIPTFUNC_PARAMS);
int SF_playSound(SCRIPTFUNC_PARAMS);
int SF_gotoScene(SCRIPTFUNC_PARAMS);
+ int SF_rand(SCRIPTFUNC_PARAMS);
+ int SF_sceneEq(SCRIPTFUNC_PARAMS);
+ int SF_placard(SCRIPTFUNC_PARAMS);
+ int SF_placardOff(SCRIPTFUNC_PARAMS);
+ int SF_fadeMusic(SCRIPTFUNC_PARAMS);
};
} // End of namespace Saga
diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp
index ac84580c1c..208631a365 100644
--- a/saga/sfuncs.cpp
+++ b/saga/sfuncs.cpp
@@ -37,6 +37,8 @@
#include "saga/script.h"
#include "saga/sdata.h"
+#include "saga/scene.h"
+
namespace Saga {
#define OPCODE(x) &Script::x
@@ -74,7 +76,7 @@ void Script::setupScriptFuncList(void) {
{28, 0, NULL},
{29, 2, OPCODE(SF_setActorState)},
{30, 3, OPCODE(SF_moveTo)},
- {31, 0, NULL},
+ {31, 1, OPCODE(SF_sceneEq)},
{32, 0, NULL},
{33, 1, OPCODE(SF_finishBgdAnim)},
{34, 2, OPCODE(SF_swapActors)},
@@ -91,8 +93,8 @@ void Script::setupScriptFuncList(void) {
{45, 5, OPCODE(SF_walkRelative)},
{46, 5, OPCODE(SF_moveRelative)},
{47, 0, NULL},
- {48, 0, NULL},
- {49, 0, NULL},
+ {48, 0, OPCODE(SF_placard)},
+ {49, 0, OPCODE(SF_placardOff)},
{50, 0, NULL},
{51, 0, NULL},
{52, 6, OPCODE(SF_throwActor)},
@@ -118,8 +120,8 @@ void Script::setupScriptFuncList(void) {
{72, 0, NULL},
{73, 0, NULL},
{74, 0, NULL},
- {75, 0, NULL},
- {76, 0, NULL},
+ {75, 1, OPCODE(SF_rand)},
+ {76, 0, OPCODE(SF_fadeMusic)},
{77, 0, NULL}
};
_SFuncList = SFuncList;
@@ -143,7 +145,9 @@ int Script::SF_sleep(SCRIPTFUNC_PARAMS) {
// Script function #2 (0x02)
int Script::SF_takeObject(SCRIPTFUNC_PARAMS) {
- thread->pop();
+ SDataWord_T param = thread->pop();
+
+ debug(1, "stub: SF_takeObject(%d)", param);
return SUCCESS;
}
@@ -211,10 +215,12 @@ int Script::SF_actorWalkTo(SCRIPTFUNC_PARAMS) {
// Script function #7 (0x07)
int Script::SF_doAction(SCRIPTFUNC_PARAMS) {
- thread->pop();
- thread->pop();
- thread->pop();
- thread->pop();
+ SDataWord_T param1 = thread->pop();
+ SDataWord_T param2 = thread->pop();
+ SDataWord_T param3 = thread->pop();
+ SDataWord_T param4 = thread->pop();
+
+ debug(1, "stub: SF_doAction(%d, %d, %d, %d)", param1, param2, param3, param4);
return SUCCESS;
}
@@ -246,14 +252,18 @@ int Script::SF_setFacing(SCRIPTFUNC_PARAMS) {
// Script function #9 (0x09)
int Script::SF_startBgdAnim(SCRIPTFUNC_PARAMS) {
- thread->pop();
- thread->pop();
+ SDataWord_T param1 = thread->pop();
+ SDataWord_T param2 = thread->pop();
+
+ debug(1, "stub: SF_startBgdAnim(%d, %d)", param1, param2);
return SUCCESS;
}
// Script function #10 (0x0A)
int Script::SF_stopBgdAnim(SCRIPTFUNC_PARAMS) {
- thread->pop();
+ SDataWord_T param = thread->pop();
+
+ debug(1, "stub: SF_stopBgdAnim(%d)", param);
return SUCCESS;
}
@@ -284,35 +294,45 @@ int Script::SF_dialogMode(SCRIPTFUNC_PARAMS) {
// Script function #14 (0x0E)
int Script::SF_faceTowards(SCRIPTFUNC_PARAMS) {
- thread->pop();
- thread->pop();
+ SDataWord_T param1 = thread->pop();
+ SDataWord_T param2 = thread->pop();
+
+ debug(1, "stub: SF_faceTowards(%d, %d)", param1, param2);
return SUCCESS;
}
// Script function #15 (0x0F)
int Script::SF_setFollower(SCRIPTFUNC_PARAMS) {
- thread->pop();
- thread->pop();
+ SDataWord_T param1 = thread->pop();
+ SDataWord_T param2 = thread->pop();
+
+ debug(1, "stub: SF_setFollower(%d, %d)", param1, param2);
return SUCCESS;
}
// Script function #16 (0x10)
int Script::SF_gotoScene(SCRIPTFUNC_PARAMS) {
- thread->pop();
- thread->pop();
+ SDataWord_T param1 = thread->pop();
+ SDataWord_T param2 = thread->pop();
+
+ debug(1, "stub: SF_gotoScene(%d, %d)", param1, param2);
return SUCCESS;
}
// Script function #23 (0x17)
int Script::SF_setBgdAnimSpeed(SCRIPTFUNC_PARAMS) {
- thread->pop();
- thread->pop();
+ SDataWord_T param1 = thread->pop();
+ SDataWord_T param2 = thread->pop();
+
+ debug(1, "stub: SF_setBgdAnimSpeed(%d, %d)", param1, param2);
return SUCCESS;
}
// Script function #25 (0x19)
int Script::SF_centerActor(SCRIPTFUNC_PARAMS) {
- thread->pop();
+ SDataWord_T param = thread->pop();
+
+ debug(1, "stub: SF_centerActor(%d)", param);
return SUCCESS;
}
@@ -378,8 +398,10 @@ int Script::SF_actorWalkToAsync(SCRIPTFUNC_PARAMS) {
// Script function #29 (0x1D)
int Script::SF_setActorState(SCRIPTFUNC_PARAMS) {
- thread->pop();
- thread->pop();
+ SDataWord_T param1 = thread->pop();
+ SDataWord_T param2 = thread->pop();
+
+ debug(1, "stub: SF_setActorState(%d, %d)", param1, param2);
return SUCCESS;
}
@@ -420,16 +442,32 @@ int Script::SF_moveTo(SCRIPTFUNC_PARAMS) {
return SUCCESS;
}
+// Script function #31 (0x21)
+int Script::SF_sceneEq(SCRIPTFUNC_PARAMS) {
+ SDataWord_T param = thread->pop();
+
+ if (_vm->_scene->getSceneLUT(param) == _vm->_scene->currentSceneNumber())
+ thread->retVal = 1;
+ else
+ thread->retVal = 0;
+ return SUCCESS;
+}
+
+
// Script function #33 (0x21)
int Script::SF_finishBgdAnim(SCRIPTFUNC_PARAMS) {
- thread->pop();
+ SDataWord_T param = thread->pop();
+
+ debug(1, "stub: SF_finishBgdAnim(%d)", param);
return SUCCESS;
}
// Script function #34 (0x22)
int Script::SF_swapActors(SCRIPTFUNC_PARAMS) {
- thread->pop();
- thread->pop();
+ SDataWord_T param1 = thread->pop();
+ SDataWord_T param2 = thread->pop();
+
+ debug(1, "stub: SF_swapActors(%d, %d)", param1, param2);
return SUCCESS;
}
@@ -587,10 +625,12 @@ int Script::SF_linkAnim(SCRIPTFUNC_PARAMS) {
// Script function #42 (0x2A)
int Script::SF_scriptSpecialWalk(SCRIPTFUNC_PARAMS) {
- thread->pop();
- thread->pop();
- thread->pop();
- thread->pop();
+ SDataWord_T param1 = thread->pop();
+ SDataWord_T param2 = thread->pop();
+ SDataWord_T param3 = thread->pop();
+ SDataWord_T param4 = thread->pop();
+
+ debug(1, "stub: SF_scriptSpecialWalk(%d, %d, %d, %d)", param1, param2, param3, param4);
return SUCCESS;
}
@@ -658,73 +698,103 @@ int Script::SF_checkUserInterrupt(SCRIPTFUNC_PARAMS) {
// Script function #45 (0x2D)
int Script::SF_walkRelative(SCRIPTFUNC_PARAMS) {
- thread->pop();
- thread->pop();
- thread->pop();
- thread->pop();
- thread->pop();
+ SDataWord_T param1 = thread->pop();
+ SDataWord_T param2 = thread->pop();
+ SDataWord_T param3 = thread->pop();
+ SDataWord_T param4 = thread->pop();
+ SDataWord_T param5 = thread->pop();
+
+ debug(1, "stub: SF_walkRelative(%d, %d, %d, %d, %d)", param1, param2, param3, param4, param5);
return SUCCESS;
}
// Script function #46 (0x2E)
int Script::SF_moveRelative(SCRIPTFUNC_PARAMS) {
- thread->pop();
- thread->pop();
- thread->pop();
- thread->pop();
- thread->pop();
+ SDataWord_T param1 = thread->pop();
+ SDataWord_T param2 = thread->pop();
+ SDataWord_T param3 = thread->pop();
+ SDataWord_T param4 = thread->pop();
+ SDataWord_T param5 = thread->pop();
+
+ debug(1, "stub: SF_moveRelative(%d, %d, %d, %d, %d)", param1, param2, param3, param4, param5);
+ return SUCCESS;
+}
+
+// Script function #48 (0x30)
+int Script::SF_placard(SCRIPTFUNC_PARAMS) {
+ debug(1, "stub: SF_placard()");
+ return SUCCESS;
+}
+
+// Script function #49 (0x31)
+int Script::SF_placardOff(SCRIPTFUNC_PARAMS) {
+ debug(1, "stub: SF_placardOff()");
return SUCCESS;
}
// Script function #52 (0x34)
int Script::SF_throwActor(SCRIPTFUNC_PARAMS) {
- thread->pop();
- thread->pop();
- thread->pop();
- thread->pop();
- thread->pop();
- thread->pop();
+ SDataWord_T param1 = thread->pop();
+ SDataWord_T param2 = thread->pop();
+ SDataWord_T param3 = thread->pop();
+ SDataWord_T param4 = thread->pop();
+ SDataWord_T param5 = thread->pop();
+ SDataWord_T param6 = thread->pop();
+
+ debug(1, "stub: SF_throwActor(%d, %d, %d, %d, %d, %d)", param1, param2, param3, param4, param5, param6);
return SUCCESS;
}
// Script function #53 (0x35)
int Script::SF_waitWalk(SCRIPTFUNC_PARAMS) {
- thread->pop();
+ SDataWord_T param = thread->pop();
+
+ debug(1, "stub: SF_waitWalk(%d)", param);
return SUCCESS;
}
// Script function #55 (0x37)
int Script::SF_changeActorScene(SCRIPTFUNC_PARAMS) {
- thread->pop();
- thread->pop();
+ SDataWord_T param1 = thread->pop();
+ SDataWord_T param2 = thread->pop();
+
+ debug(1, "stub: SF_changeActorScene(%d, %d)", param1, param2);
return SUCCESS;
}
// Script function #56 (0x38)
int Script::SF_climb(SCRIPTFUNC_PARAMS) {
- thread->pop();
- thread->pop();
- thread->pop();
- thread->pop();
+ SDataWord_T param1 = thread->pop();
+ SDataWord_T param2 = thread->pop();
+ SDataWord_T param3 = thread->pop();
+ SDataWord_T param4 = thread->pop();
+
+ debug(1, "stub: SF_climb(%d, %d, %d, %d)", param1, param2, param3, param4);
return SUCCESS;
}
// Script function #58 (0x3A)
int Script::SF_setActorZ(SCRIPTFUNC_PARAMS) {
- thread->pop();
- thread->pop();
+ SDataWord_T param1 = thread->pop();
+ SDataWord_T param2 = thread->pop();
+
+ debug(1, "stub: SF_setActorZ(%d, %d)", param1, param2);
return SUCCESS;
}
// Script function #60 (0x3C)
int Script::SF_getActorX(SCRIPTFUNC_PARAMS) {
- thread->pop();
+ SDataWord_T param = thread->pop();
+
+ debug(1, "stub: SF_getActorX(%d)", param);
return SUCCESS;
}
// Script function #61 (0x3D)
int Script::SF_getActorY(SCRIPTFUNC_PARAMS) {
- thread->pop();
+ SDataWord_T param = thread->pop();
+
+ debug(1, "stub: SF_getActorY(%d)", param);
return SUCCESS;
}
@@ -835,4 +905,19 @@ int Script::SF_playSound(SCRIPTFUNC_PARAMS) {
return SUCCESS;
}
+// Script function #75 (0x4d)
+int Script::SF_rand(SCRIPTFUNC_PARAMS) {
+ SDataWord_T param = thread->pop();
+
+ thread->retVal = (_vm->_rnd.getRandomNumber(param));
+
+ return SUCCESS;
+}
+
+// Script function #76 (0x4c)
+int Script::SF_fadeMusic(SCRIPTFUNC_PARAMS) {
+ debug(1, "stub: SF_fadeMusic()");
+ return SUCCESS;
+}
+
} // End of namespace Saga
diff --git a/saga/sthread.cpp b/saga/sthread.cpp
index c8be77c7fc..864b86d351 100644
--- a/saga/sthread.cpp
+++ b/saga/sthread.cpp
@@ -274,7 +274,7 @@ int Script::SThreadRun(SCRIPT_THREAD *thread, int instr_limit) {
saved_offset = thread->i_offset;
in_char = scriptS.readByte();
- debug(1, "Executing thread offset: %lu (%x) stack: %d", thread->i_offset, in_char, thread->stackSize());
+ debug(2, "Executing thread offset: %lu (%x) stack: %d", thread->i_offset, in_char, thread->stackSize());
switch (in_char) {
case 0x01: // nextblock
@@ -390,8 +390,8 @@ int Script::SThreadRun(SCRIPT_THREAD *thread, int instr_limit) {
sfunc = _SFuncList[func_num].sfunc_fp;
if (sfunc == NULL) {
- _vm->_console->print(S_WARN_PREFIX "%X: Undefined script function number: (%X)\n",
- thread->i_offset, func_num);
+ _vm->_console->print(S_WARN_PREFIX "%X: Undefined script function number: #%d (%X)\n",
+ thread->i_offset, func_num, func_num);
_vm->_console->print(S_WARN_PREFIX "Removing %d operand(s) from stack.\n", n_args);
for (i = 0; i < n_args; i++) {
thread->pop();
diff --git a/saga/xref.txt b/saga/xref.txt
index c31c033af8..0fd622a750 100644
--- a/saga/xref.txt
+++ b/saga/xref.txt
@@ -56,6 +56,7 @@ Scene.c
resInfo->entryScript _desc.sceneScriptNum
resInfo->preScript _desc.startScriptNum
resInfo->backgroundMusic _desc.musicRN
+ thisScene->ID currentSceneNumber()
Interp.c
========
@@ -73,3 +74,8 @@ Interp.c
Actor.c
=======
abortAllSpeeches() SThreadAbortAll()
+
+Main.c
+======
+ sceneIndexTable _scene->getSceneLUT()
+