aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2008-12-06 11:35:31 +0000
committerPaul Gilbert2008-12-06 11:35:31 +0000
commitb697026ae0a26ec9f0e5bac3a4eae1fa6dd36e79 (patch)
tree7c5b4eeb97cce3acaa9ab912472acbda1e06bcdc /engines
parentf2497e5ef7c8d5de6f9712c21a66f664bfe43163 (diff)
downloadscummvm-rg350-b697026ae0a26ec9f0e5bac3a4eae1fa6dd36e79.tar.gz
scummvm-rg350-b697026ae0a26ec9f0e5bac3a4eae1fa6dd36e79.tar.bz2
scummvm-rg350-b697026ae0a26ec9f0e5bac3a4eae1fa6dd36e79.zip
Library routine and interpreter fixes for the DW1 demo
svn-id: r35257
Diffstat (limited to 'engines')
-rw-r--r--engines/tinsel/bg.cpp36
-rw-r--r--engines/tinsel/pcode.cpp13
-rw-r--r--engines/tinsel/tinlib.cpp2
-rw-r--r--engines/tinsel/tinsel.h1
4 files changed, 41 insertions, 11 deletions
diff --git a/engines/tinsel/bg.cpp b/engines/tinsel/bg.cpp
index 96b03292cb..41628a55e8 100644
--- a/engines/tinsel/bg.cpp
+++ b/engines/tinsel/bg.cpp
@@ -189,6 +189,33 @@ static void BGmainProcess(CORO_PARAM, const void *param) {
}
/**
+ * Runs secondary reels for a scene background
+ */
+static void BGotherProcess(CORO_PARAM, const void *param) {
+ // COROUTINE
+ CORO_BEGIN_CONTEXT;
+ OBJECT *pObj;
+ ANIM anim;
+ CORO_END_CONTEXT(_ctx);
+
+ const FREEL *pReel = (const FREEL *)param;
+ const MULTI_INIT *pmi = (const MULTI_INIT *)LockMem(FROM_LE_32(pReel->mobj));
+
+ CORO_BEGIN_CODE(_ctx);
+
+ // Initialise and insert the object, and initialise its script.
+ _ctx->pObj = MultiInitObject(pmi);
+ MultiInsertObject(GetPlayfieldList(FIELD_WORLD), _ctx->pObj);
+
+ InitStepAnimScript(&_ctx->anim, pBG[0], FROM_LE_32(pReel->script), BGspeed);
+
+ while (StepAnimScript(&_ctx->anim) != ScriptFinished)
+ CORO_SLEEP(1);
+
+ CORO_END_CODE;
+}
+
+/**
* AetBgPal()
*/
void SetBackPal(SCNHANDLE hPal) {
@@ -222,7 +249,9 @@ void StartupBackground(CORO_PARAM, SCNHANDLE hFilm) {
hBackground = hFilm; // Save handle in case of Save_Scene()
pim = GetImageFromFilm(hFilm, 0, NULL, NULL, &pfilm);
- SetBackPal(FROM_LE_32(pim->hImgPal));
+
+ if (!TinselV0)
+ SetBackPal(FROM_LE_32(pim->hImgPal));
// Extract the film speed
BGspeed = ONE_SECOND / FROM_LE_32(pfilm->frate);
@@ -230,6 +259,11 @@ void StartupBackground(CORO_PARAM, SCNHANDLE hFilm) {
// Start display process for each reel in the film
g_scheduler->createProcess(PID_REEL, BGmainProcess, &pfilm->reels[0], sizeof(FREEL));
+ if (TinselV0) {
+ for (uint i = 1; i < FROM_LE_32(pfilm->numreels); ++i)
+ g_scheduler->createProcess(PID_REEL, BGotherProcess, &pfilm->reels[i], sizeof(FREEL));
+ }
+
if (pBG[0] == NULL)
ControlStartOff();
diff --git a/engines/tinsel/pcode.cpp b/engines/tinsel/pcode.cpp
index c92a366403..81e7459c71 100644
--- a/engines/tinsel/pcode.cpp
+++ b/engines/tinsel/pcode.cpp
@@ -405,8 +405,7 @@ static int32 Fetch(byte opcode, byte *code, int &ip) {
int32 tmp;
if (TinselV0) {
// Fetch a 32 bit value.
- tmp = (int32)READ_LE_UINT32(code + ip);
- ip += 4;
+ tmp = (int32)READ_LE_UINT32(code + ip++ * 4);
} else if (opcode & OPSIZE8) {
// Fetch and sign extend a 8 bit value to 32 bits.
tmp = *(int8 *)(code + ip);
@@ -430,12 +429,9 @@ void Interpret(CORO_PARAM, INT_CONTEXT *ic) {
do {
int tmp, tmp2;
int ip = ic->ip;
- byte opcode = ic->code[ip++];
- if (TinselV0) {
- ip += 3; // DW1 demo opcodes are 4 bytes long
- if ((opcode & OPMASK) > OP_IMM)
- opcode += 3;
- }
+ byte opcode = ic->code[ip++ * (TinselV0 ? 4 : 1)];
+ if (TinselV0 && ((opcode & OPMASK) > OP_IMM))
+ opcode += 3;
debug(7, "ip=%d Opcode %d (-> %d)", ic->ip, opcode, opcode & OPMASK);
switch (opcode & OPMASK) {
@@ -493,7 +489,6 @@ void Interpret(CORO_PARAM, INT_CONTEXT *ic) {
case OP_CALL: // procedure call
tmp = Fetch(opcode, ic->code, ip);
- if (TinselV0) tmp *= 4;
//assert(0 <= tmp && tmp < codeSize); // TODO: Verify jumps are not out of bounds
ic->stack[ic->sp + 1] = 0; // static link
ic->stack[ic->sp + 2] = ic->bp; // dynamic link
diff --git a/engines/tinsel/tinlib.cpp b/engines/tinsel/tinlib.cpp
index b9e8972b69..241a319360 100644
--- a/engines/tinsel/tinlib.cpp
+++ b/engines/tinsel/tinlib.cpp
@@ -187,7 +187,7 @@ const MASTER_LIB_CODES DW1DEMO_CODES[] = {
PLAY, PLAYSAMPLE, PREPARESCENE, PRINT, PRINTOBJ, PRINTTAG, RESTORESCENE, SAVESCENE,
SCANICON, SCROLL, SETACTOR, SETBLOCK, HIGHEST_LIBCODE, SETTAG, SETTIMER, SHOWPOS,
SPLAY, STAND, STANDTAG, STOPWALK, HIGHEST_LIBCODE, SWALK, TAGACTOR, TALK,
- SCREENYPOS, UNTAGACTOR, VIBRATE, WAITFRAME, WAITTIME, WALK, WALKINGACTOR, WALKPOLY,
+ SCREENYPOS, UNTAGACTOR, VIBRATE, WAITKEY, WAITTIME, WALK, WALKINGACTOR, WALKPOLY,
WALKTAG, RANDOM, TIMER
};
diff --git a/engines/tinsel/tinsel.h b/engines/tinsel/tinsel.h
index 8e15755d4e..6870896f06 100644
--- a/engines/tinsel/tinsel.h
+++ b/engines/tinsel/tinsel.h
@@ -120,6 +120,7 @@ typedef bool (*KEYFPTR)(const Common::KeyState &);
#define TinselVersion (_vm->getVersion())
#define TinselV0 (TinselVersion == TINSEL_V0)
+#define TinselV1 (TinselVersion == TINSEL_V1)
#define TinselV2 (TinselVersion == TINSEL_V2)
class TinselEngine : public Engine {