2004-04-12 21:40:49 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2005-01-01 16:20:17 +00:00
|
|
|
* Copyright (C) 2004-2005 The ScummVM project
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
* The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-05-01 14:05:10 +00:00
|
|
|
// Scripting module private header
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
#ifndef SAGA_SCRIPT_H
|
|
|
|
#define SAGA_SCRIPT_H
|
|
|
|
|
2005-07-14 17:46:21 +00:00
|
|
|
#include "saga/font.h"
|
2004-12-15 00:24:12 +00:00
|
|
|
#include "saga/list.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
namespace Saga {
|
|
|
|
|
2005-04-22 01:38:27 +00:00
|
|
|
#define COMMON_BUFFER_SIZE 1024 // Why 1024?
|
2004-08-12 23:57:45 +00:00
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
#define S_LUT_ENTRYLEN_ITECD 22
|
|
|
|
#define S_LUT_ENTRYLEN_ITEDISK 16
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
#define SCRIPT_TBLENTRY_LEN 4
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-10-27 21:32:28 +00:00
|
|
|
#define SCRIPT_MAX 5000
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-21 01:33:28 +00:00
|
|
|
#define ITE_SCRIPT_FUNCTION_MAX 78
|
|
|
|
#define IHNM_SCRIPT_FUNCTION_MAX 105
|
2005-01-21 21:55:54 +00:00
|
|
|
#define DEFAULT_THREAD_STACK_SIZE 256
|
|
|
|
|
|
|
|
enum AddressTypes {
|
|
|
|
kAddressCommon = 0, // offset from global variables
|
|
|
|
kAddressStatic = 1, // offset from global variables
|
|
|
|
kAddressModule = 2, // offset from start of module
|
|
|
|
kAddressStack = 3, // offset from stack
|
2005-01-21 23:16:38 +00:00
|
|
|
kAddressThread = 4 // offset from thread structure
|
2005-01-21 21:55:54 +00:00
|
|
|
/* kAddressId = 5, // offset from const id object
|
|
|
|
kAddressIdIndirect = 6, // offset from stack id object
|
|
|
|
kAddressIndex = 7 // index from id*/
|
|
|
|
};
|
2004-08-12 23:57:45 +00:00
|
|
|
|
2004-12-25 11:17:03 +00:00
|
|
|
enum VerbTypes {
|
|
|
|
kVerbNone = 0,
|
2005-01-13 22:42:49 +00:00
|
|
|
kVerbPickUp = 1,
|
2004-12-25 11:17:03 +00:00
|
|
|
kVerbLookAt = 2,
|
|
|
|
kVerbWalkTo = 3,
|
2005-01-13 22:42:49 +00:00
|
|
|
kVerbTalkTo = 4,
|
2004-12-25 11:17:03 +00:00
|
|
|
kVerbOpen = 5,
|
|
|
|
kVerbClose = 6,
|
|
|
|
kVerbGive = 7,
|
|
|
|
kVerbUse = 8,
|
|
|
|
kVerbOptions = 9,
|
|
|
|
kVerbEnter = 10,
|
|
|
|
kVerbLeave = 11,
|
|
|
|
kVerbBegin = 12,
|
|
|
|
kVerbWalkOnly = 13,
|
2005-01-13 22:42:49 +00:00
|
|
|
kVerbLookOnly = 14,
|
|
|
|
|
|
|
|
kVerbTypesMax = kVerbLookOnly + 1
|
2004-08-12 23:57:45 +00:00
|
|
|
};
|
|
|
|
|
2004-10-27 02:27:54 +00:00
|
|
|
#define STHREAD_TIMESLICE 8
|
2004-08-12 23:57:45 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
enum ThreadVarTypes {
|
|
|
|
kThreadVarObject = 0,
|
|
|
|
kThreadVarWithObject = 1,
|
|
|
|
kThreadVarAction = 2,
|
|
|
|
kThreadVarActor = 3,
|
|
|
|
|
|
|
|
kThreadVarMax = kThreadVarActor + 1
|
2004-10-09 07:39:46 +00:00
|
|
|
};
|
|
|
|
|
2004-12-21 06:49:07 +00:00
|
|
|
enum ThreadFlags {
|
2004-10-27 02:27:54 +00:00
|
|
|
kTFlagNone = 0,
|
|
|
|
kTFlagWaiting = 1, // wait for even denoted in waitType
|
|
|
|
kTFlagFinished = 2,
|
|
|
|
kTFlagAborted = 4,
|
2005-01-03 21:17:32 +00:00
|
|
|
kTFlagAsleep = kTFlagWaiting | kTFlagFinished | kTFlagAborted // Combination of all flags which can halt a thread
|
2004-10-27 02:27:54 +00:00
|
|
|
};
|
|
|
|
|
2004-12-21 06:49:07 +00:00
|
|
|
enum ThreadWaitTypes {
|
|
|
|
kWaitTypeNone = 0, // waiting for nothing
|
|
|
|
kWaitTypeDelay = 1, // waiting for a timer
|
|
|
|
kWaitTypeSpeech = 2, // waiting for speech to finish
|
|
|
|
kWaitTypeDialogEnd = 3, // waiting for my dialog to finish
|
|
|
|
kWaitTypeDialogBegin = 4, // waiting for other dialog to finish
|
|
|
|
kWaitTypeWalk = 5, // waiting to finish walking
|
|
|
|
kWaitTypeRequest = 6, // a request is up
|
2005-01-06 16:07:46 +00:00
|
|
|
kWaitTypePause = 7,
|
2005-06-19 14:06:20 +00:00
|
|
|
kWaitTypePlacard = 8,
|
|
|
|
kWaitTypeStatusTextInput = 9
|
2004-12-21 06:49:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum OpCodes {
|
2005-01-21 23:25:54 +00:00
|
|
|
opNextBlock = 1,
|
|
|
|
opDup = 2,
|
|
|
|
opDrop = 3,
|
|
|
|
opZero = 4,
|
|
|
|
opOne = 5,
|
|
|
|
opConstint = 6,
|
|
|
|
//...
|
|
|
|
opStrlit = 8,
|
|
|
|
//...
|
|
|
|
opGetFlag = 0xB,
|
|
|
|
opGetInt = 0xC,
|
|
|
|
//...
|
|
|
|
opPutFlag = 0xf,
|
|
|
|
opPutInt = 0x10,
|
|
|
|
//...
|
|
|
|
opPutFlagV = 0x13,
|
|
|
|
opPutIntV = 0x14,
|
2004-12-22 21:04:50 +00:00
|
|
|
//...
|
2005-01-21 23:25:54 +00:00
|
|
|
opCall = 0x17,
|
2004-12-22 21:04:50 +00:00
|
|
|
opCcall = 0x18,
|
|
|
|
opCcallV = 0x19,
|
2005-01-03 21:17:32 +00:00
|
|
|
opEnter = 0x1A,
|
|
|
|
opReturn = 0x1B,
|
|
|
|
opReturnV = 0x1C,
|
2005-01-22 14:43:49 +00:00
|
|
|
opJmp = 0x1D,
|
|
|
|
opJmpTrueV = 0x1E,
|
|
|
|
opJmpFalseV = 0x1F,
|
|
|
|
opJmpTrue = 0x20,
|
|
|
|
opJmpFalse = 0x21,
|
|
|
|
opJmpSwitch = 0x22,
|
|
|
|
//...
|
|
|
|
opJmpRandom = 0x24,
|
|
|
|
opNegate = 0x25,
|
|
|
|
opNot = 0x26,
|
|
|
|
opCompl = 0x27,
|
|
|
|
opIncV = 0x28,
|
|
|
|
opDecV = 0x29,
|
|
|
|
opPostInc = 0x2A,
|
|
|
|
opPostDec = 0x2B,
|
2005-01-22 15:28:24 +00:00
|
|
|
opAdd = 0x2C,
|
|
|
|
opSub = 0x2D,
|
|
|
|
opMul = 0x2E,
|
|
|
|
opDiv = 0x2F,
|
|
|
|
opMod = 0x30,
|
|
|
|
//...
|
|
|
|
opEq = 0x33,
|
|
|
|
opNe = 0x34,
|
|
|
|
opGt = 0x35,
|
|
|
|
opLt = 0x36,
|
|
|
|
opGe = 0x37,
|
|
|
|
opLe = 0x38,
|
|
|
|
//...
|
|
|
|
opRsh = 0x3F,
|
|
|
|
opLsh = 0x40,
|
|
|
|
opAnd = 0x41,
|
|
|
|
opOr = 0x42,
|
|
|
|
opXor = 0x43,
|
|
|
|
opLAnd = 0x44,
|
|
|
|
opLOr = 0x45,
|
|
|
|
opLXor = 0x46,
|
2004-12-22 21:04:50 +00:00
|
|
|
//...
|
2005-01-17 20:17:06 +00:00
|
|
|
opSpeak = 0x53,
|
|
|
|
opDialogBegin = 0x54,
|
|
|
|
opDialogEnd = 0x55,
|
2005-01-22 16:32:30 +00:00
|
|
|
opReply = 0x56,
|
|
|
|
opAnimate = 0x57
|
2004-10-27 02:27:54 +00:00
|
|
|
};
|
|
|
|
|
2004-12-22 21:04:50 +00:00
|
|
|
enum CycleFlags {
|
2005-01-17 20:17:06 +00:00
|
|
|
kCyclePong = 1 << 0,
|
|
|
|
kCycleOnce = 1 << 1,
|
|
|
|
kCycleRandom = 1 << 2,
|
|
|
|
kCycleReverse = 1 << 3
|
2004-12-22 21:04:50 +00:00
|
|
|
};
|
2004-12-24 20:44:39 +00:00
|
|
|
|
2004-12-29 21:49:25 +00:00
|
|
|
enum WalkFlags {
|
2005-01-17 20:17:06 +00:00
|
|
|
kWalkBackPedal = 1 << 0,
|
|
|
|
kWalkAsync = 1 << 1,
|
|
|
|
kWalkUseAngle = 1 << 2,
|
|
|
|
kWalkFace = 1 << 5
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ReplyFlags {
|
|
|
|
kReplyOnce = 1 << 0,
|
|
|
|
kReplySummary = 1 << 1,
|
|
|
|
kReplyCondition = 1 << 2
|
2004-12-29 21:49:25 +00:00
|
|
|
};
|
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
struct EntryPoint {
|
|
|
|
uint16 nameOffset;
|
|
|
|
uint16 offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VoiceLUT {
|
|
|
|
uint16 voicesCount;
|
|
|
|
uint16 *voices;
|
|
|
|
void freeMem() {
|
|
|
|
free(voices);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ModuleData {
|
|
|
|
bool loaded; // is it loaded or not?
|
|
|
|
int scriptResourceId;
|
|
|
|
int stringsResourceId;
|
|
|
|
int voicesResourceId;
|
|
|
|
|
|
|
|
byte *moduleBase; // all base module
|
|
|
|
uint16 moduleBaseSize; // base module size
|
|
|
|
uint16 staticSize; // size of static data
|
|
|
|
uint staticOffset; // offset of static data begining in _commonBuffer
|
|
|
|
|
|
|
|
uint16 entryPointsTableOffset; // offset of entrypoint table in moduleBase
|
|
|
|
uint16 entryPointsCount;
|
|
|
|
EntryPoint *entryPoints;
|
|
|
|
|
|
|
|
StringsTable strings;
|
|
|
|
VoiceLUT voiceLUT;
|
|
|
|
void freeMem() {
|
|
|
|
strings.freeMem();
|
|
|
|
voiceLUT.freeMem();
|
|
|
|
free(moduleBase);
|
|
|
|
free(entryPoints);
|
|
|
|
memset(this, 0x0, sizeof(*this));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class ScriptThread {
|
|
|
|
public:
|
|
|
|
uint16 *_stackBuf;
|
|
|
|
uint16 _stackSize; // stack size in uint16
|
|
|
|
|
|
|
|
uint16 _stackTopIndex;
|
|
|
|
uint16 _frameIndex;
|
|
|
|
|
|
|
|
uint16 _threadVars[kThreadVarMax];
|
2004-08-12 23:57:45 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
byte *_moduleBase; //
|
|
|
|
uint16 _moduleBaseSize;
|
2004-08-12 23:57:45 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
byte *_commonBase; //
|
|
|
|
byte *_staticBase; //
|
|
|
|
VoiceLUT *_voiceLUT; //
|
|
|
|
StringsTable *_strings; //
|
2004-09-23 06:46:44 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
int _flags; // ThreadFlags
|
|
|
|
int _waitType; // ThreadWaitTypes
|
|
|
|
uint _sleepTime;
|
|
|
|
void *_threadObj; // which object we're handling
|
2004-09-23 06:46:44 +00:00
|
|
|
|
2005-01-22 14:43:49 +00:00
|
|
|
int16 _returnValue;
|
2004-09-23 06:46:44 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
uint16 _instructionOffset; // Instruction offset
|
2004-10-09 07:39:46 +00:00
|
|
|
|
2004-10-03 17:11:23 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
public:
|
|
|
|
byte *baseAddress(byte addrMode) {
|
2005-01-22 14:16:00 +00:00
|
|
|
switch (addrMode) {
|
|
|
|
case kAddressCommon:
|
|
|
|
return _commonBase;
|
|
|
|
case kAddressStatic:
|
|
|
|
return _staticBase;
|
|
|
|
case kAddressModule:
|
|
|
|
return _moduleBase;
|
|
|
|
case kAddressStack:
|
|
|
|
return (byte*)&_stackBuf[_frameIndex];
|
|
|
|
case kAddressThread:
|
|
|
|
return (byte*)_threadVars;
|
|
|
|
default:
|
|
|
|
return _commonBase;
|
2005-01-21 21:55:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 stackTop() {
|
|
|
|
return (int16)_stackBuf[_stackTopIndex];
|
2004-09-23 06:46:44 +00:00
|
|
|
}
|
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
uint pushedSize() {
|
2005-04-03 17:23:02 +00:00
|
|
|
return _stackSize - _stackTopIndex - 2;
|
2004-09-23 06:46:44 +00:00
|
|
|
}
|
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
void push(int16 value) {
|
|
|
|
if (_stackTopIndex <= 0) {
|
|
|
|
error("ScriptThread::push() stack overflow");
|
|
|
|
}
|
|
|
|
_stackBuf[--_stackTopIndex] = (uint16)value;
|
2004-09-23 06:46:44 +00:00
|
|
|
}
|
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
int16 pop() {
|
|
|
|
if (_stackTopIndex >= _stackSize) {
|
2005-06-15 14:42:40 +00:00
|
|
|
error("ScriptThread::pop() stack underflow");
|
2005-01-21 21:55:54 +00:00
|
|
|
}
|
|
|
|
return (int16)_stackBuf[_stackTopIndex++];
|
2004-09-23 06:46:44 +00:00
|
|
|
}
|
2004-12-21 06:49:07 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
|
|
|
|
// wait stuff
|
|
|
|
void wait(int waitType) {
|
|
|
|
_waitType = waitType;
|
|
|
|
_flags |= kTFlagWaiting;
|
2004-12-21 06:49:07 +00:00
|
|
|
}
|
2004-12-15 00:24:12 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
void waitWalk(void *threadObj) {
|
2004-12-24 20:44:39 +00:00
|
|
|
wait(kWaitTypeWalk);
|
2005-01-21 21:55:54 +00:00
|
|
|
_threadObj = threadObj;
|
2004-12-24 20:44:39 +00:00
|
|
|
}
|
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
void waitDelay(int sleepTime) {
|
2004-12-24 20:44:39 +00:00
|
|
|
wait(kWaitTypeDelay);
|
2005-01-21 21:55:54 +00:00
|
|
|
_sleepTime = sleepTime;
|
2004-12-24 20:44:39 +00:00
|
|
|
}
|
|
|
|
|
2005-01-15 20:12:49 +00:00
|
|
|
ScriptThread() {
|
2005-01-21 21:55:54 +00:00
|
|
|
memset(this, 0xFE, sizeof(*this));
|
|
|
|
_stackBuf = NULL;
|
|
|
|
}
|
|
|
|
~ScriptThread() {
|
|
|
|
free(_stackBuf);
|
2005-01-15 20:12:49 +00:00
|
|
|
}
|
2004-08-12 23:57:45 +00:00
|
|
|
};
|
|
|
|
|
2005-01-15 20:12:49 +00:00
|
|
|
typedef SortedList<ScriptThread> ScriptThreadList;
|
2004-12-15 00:24:12 +00:00
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-06-19 14:06:20 +00:00
|
|
|
#define SCRIPTFUNC_PARAMS ScriptThread *thread, int nArgs, bool &disContinue
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-01 22:48:40 +00:00
|
|
|
class Script {
|
|
|
|
public:
|
2005-01-18 21:13:44 +00:00
|
|
|
StringsTable _mainStrings;
|
|
|
|
|
2005-01-28 19:25:41 +00:00
|
|
|
Script(SagaEngine *vm);
|
2004-08-01 22:48:40 +00:00
|
|
|
~Script();
|
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
void loadModule(int scriptModuleNumber);
|
|
|
|
void freeModules();
|
2004-08-01 22:48:40 +00:00
|
|
|
|
2004-08-01 23:47:19 +00:00
|
|
|
bool isVoiceLUTPresent() const { return _voiceLUTPresent; }
|
2005-01-08 20:30:07 +00:00
|
|
|
|
|
|
|
void doVerb();
|
2005-04-18 20:03:14 +00:00
|
|
|
void showVerb(int statusColor = -1);
|
2005-01-08 20:30:07 +00:00
|
|
|
void setVerb(int verb);
|
2005-01-13 22:42:49 +00:00
|
|
|
int getCurrentVerb() const { return _currentVerb; }
|
2005-01-15 20:12:49 +00:00
|
|
|
void setPointerVerb();
|
2005-01-15 23:46:43 +00:00
|
|
|
void whichObject(const Point& mousePoint);
|
|
|
|
void hitObject(bool leftButton);
|
|
|
|
void playfieldClick(const Point& mousePoint, bool leftButton);
|
2005-01-15 20:12:49 +00:00
|
|
|
|
|
|
|
void setLeftButtonVerb(int verb);
|
2005-01-13 22:42:49 +00:00
|
|
|
int getLeftButtonVerb() const { return _leftButtonVerb; }
|
2005-01-15 20:12:49 +00:00
|
|
|
void setRightButtonVerb(int verb);
|
2005-01-13 22:42:49 +00:00
|
|
|
int getRightButtonVerb() const { return _rightButtonVerb; }
|
2005-01-15 20:12:49 +00:00
|
|
|
void setNonPlayfieldVerb() {
|
|
|
|
setRightButtonVerb(kVerbNone);
|
|
|
|
_pointerObject = ID_NOTHING;
|
|
|
|
_currentObject[_firstObjectSet ? 1 : 0] = ID_NOTHING;
|
|
|
|
}
|
2005-01-15 23:46:43 +00:00
|
|
|
void setNoPendingVerb() {
|
|
|
|
_pendingVerb = kVerbNone;
|
|
|
|
_currentObject[0] = _currentObject[0] = ID_NOTHING;
|
|
|
|
setPointerVerb();
|
|
|
|
}
|
2004-08-01 23:47:19 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
private:
|
2005-01-28 19:25:41 +00:00
|
|
|
SagaEngine *_vm;
|
2004-08-01 23:47:19 +00:00
|
|
|
bool _voiceLUTPresent;
|
2005-07-19 19:05:52 +00:00
|
|
|
ResourceContext *_scriptContext;
|
2005-01-21 21:55:54 +00:00
|
|
|
|
|
|
|
uint16 _modulesLUTEntryLen;
|
|
|
|
ModuleData *_modules;
|
|
|
|
int _modulesCount;
|
2005-07-14 17:46:21 +00:00
|
|
|
TextListEntry *_placardTextEntry;
|
2005-04-21 01:30:07 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
friend class SagaEngine;
|
|
|
|
byte *_commonBuffer;
|
2005-01-21 21:55:54 +00:00
|
|
|
uint _commonBufferSize;
|
2005-04-21 01:30:07 +00:00
|
|
|
|
|
|
|
private:
|
2005-01-21 21:55:54 +00:00
|
|
|
uint _staticSize;
|
|
|
|
|
2004-12-15 00:24:12 +00:00
|
|
|
ScriptThreadList _threadList;
|
2005-01-18 21:13:44 +00:00
|
|
|
|
2005-01-21 21:55:54 +00:00
|
|
|
ScriptThread *_conversingThread;
|
2005-01-08 20:30:07 +00:00
|
|
|
|
|
|
|
//verb
|
|
|
|
bool _firstObjectSet;
|
|
|
|
bool _secondObjectNeeded;
|
|
|
|
uint16 _currentObject[2];
|
2005-01-15 20:12:49 +00:00
|
|
|
int16 _currentObjectFlags[2];
|
2005-01-08 20:30:07 +00:00
|
|
|
int _currentVerb;
|
|
|
|
int _stickyVerb;
|
|
|
|
int _leftButtonVerb;
|
|
|
|
int _rightButtonVerb;
|
2005-01-15 20:12:49 +00:00
|
|
|
|
2005-01-15 23:46:43 +00:00
|
|
|
public:
|
|
|
|
uint16 _pendingObject[2];
|
|
|
|
int _pendingVerb;
|
2005-01-15 20:12:49 +00:00
|
|
|
uint16 _pointerObject;
|
2004-12-21 06:49:07 +00:00
|
|
|
|
2004-10-27 02:27:54 +00:00
|
|
|
bool _skipSpeeches;
|
|
|
|
bool _abortEnabled;
|
|
|
|
|
2004-08-12 23:57:45 +00:00
|
|
|
public:
|
2005-01-21 21:55:54 +00:00
|
|
|
ScriptThread *createThread(uint16 scriptModuleNumber, uint16 scriptEntryPointNumber);
|
2005-01-15 20:12:49 +00:00
|
|
|
int executeThread(ScriptThread *thread, int entrypointNumber);
|
2005-06-19 14:06:20 +00:00
|
|
|
void executeThreads(uint msec);
|
2005-01-15 20:12:49 +00:00
|
|
|
void completeThread(void);
|
2005-03-29 17:54:53 +00:00
|
|
|
void abortAllThreads(void);
|
2004-12-21 06:49:07 +00:00
|
|
|
|
2004-12-24 10:22:01 +00:00
|
|
|
void wakeUpActorThread(int waitType, void *threadObj);
|
2004-12-21 06:49:07 +00:00
|
|
|
void wakeUpThreads(int waitType);
|
|
|
|
void wakeUpThreadsDelayed(int waitType, int sleepTime);
|
2004-08-12 23:57:45 +00:00
|
|
|
|
|
|
|
private:
|
2005-01-21 21:55:54 +00:00
|
|
|
void loadModuleBase(ModuleData &module, const byte *resourcePointer, size_t resourceLength);
|
|
|
|
void loadModuleVoiceLUT(ModuleData &module, const byte *resourcePointer, size_t resourceLength);
|
2004-08-12 23:57:45 +00:00
|
|
|
|
2005-03-29 17:54:53 +00:00
|
|
|
// runThread returns true if we should break running of other threads
|
|
|
|
bool runThread(ScriptThread *thread, uint instructionLimit);
|
2005-01-21 21:55:54 +00:00
|
|
|
void setThreadEntrypoint(ScriptThread *thread, int entrypointNumber);
|
2005-01-17 20:17:06 +00:00
|
|
|
|
2005-01-17 23:11:31 +00:00
|
|
|
public:
|
|
|
|
void finishDialog(int replyID, int flags, int bitOffset);
|
|
|
|
|
2004-08-12 23:57:45 +00:00
|
|
|
private:
|
2005-01-21 21:55:54 +00:00
|
|
|
|
2005-01-22 19:21:38 +00:00
|
|
|
typedef void (Script::*ScriptFunctionType)(SCRIPTFUNC_PARAMS);
|
2004-08-12 23:57:45 +00:00
|
|
|
|
2004-12-24 11:11:01 +00:00
|
|
|
struct ScriptFunctionDescription {
|
|
|
|
ScriptFunctionType scriptFunction;
|
|
|
|
const char *scriptFunctionName;
|
|
|
|
};
|
|
|
|
const ScriptFunctionDescription *_scriptFunctionsList;
|
2004-08-12 23:57:45 +00:00
|
|
|
|
|
|
|
void setupScriptFuncList(void);
|
2004-10-27 21:32:28 +00:00
|
|
|
|
2005-01-22 19:21:38 +00:00
|
|
|
void sfPutString(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfWait(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfTakeObject(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfIsCarried(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfStatusBar(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfMainMode(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfScriptWalkTo(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfScriptDoAction(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfSetActorFacing(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfStartBgdAnim(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfStopBgdAnim(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfLockUser(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfPreDialog(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfKillActorThreads(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfFaceTowards(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfSetFollower(SCRIPTFUNC_PARAMS);
|
2005-01-22 21:40:54 +00:00
|
|
|
void sfScriptGotoScene(SCRIPTFUNC_PARAMS);
|
|
|
|
|
2005-04-24 15:17:38 +00:00
|
|
|
void sfSetObjImage(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfSetObjName(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfGetObjImage(SCRIPTFUNC_PARAMS);
|
2005-06-19 14:06:20 +00:00
|
|
|
void sfGetNumber(SCRIPTFUNC_PARAMS);
|
2005-01-22 19:21:38 +00:00
|
|
|
void sfScriptOpenDoor(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfScriptCloseDoor(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfSetBgdAnimSpeed(SCRIPTFUNC_PARAMS);
|
|
|
|
void SF_cycleColors(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfDoCenterActor(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfStartBgdAnimSpeed(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfScriptWalkToAsync(SCRIPTFUNC_PARAMS);
|
2005-04-16 20:59:24 +00:00
|
|
|
void sfEnableZone(SCRIPTFUNC_PARAMS);
|
2005-01-22 19:21:38 +00:00
|
|
|
void sfSetActorState(SCRIPTFUNC_PARAMS);
|
2005-01-22 21:40:54 +00:00
|
|
|
void sfScriptMoveTo(SCRIPTFUNC_PARAMS);
|
2005-04-17 11:53:25 +00:00
|
|
|
void sfSceneEq(SCRIPTFUNC_PARAMS);
|
2005-04-23 12:34:35 +00:00
|
|
|
void sfDropObject(SCRIPTFUNC_PARAMS);
|
2005-01-22 19:21:38 +00:00
|
|
|
void sfFinishBgdAnim(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfSwapActors(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfSimulSpeech(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfScriptWalk(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfCycleFrames(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfSetFrame(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfSetPortrait(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfSetProtagPortrait(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfChainBgdAnim(SCRIPTFUNC_PARAMS);
|
2005-04-16 11:03:34 +00:00
|
|
|
void sfScriptSpecialWalk(SCRIPTFUNC_PARAMS);
|
2005-01-22 19:21:38 +00:00
|
|
|
void sfPlaceActor(SCRIPTFUNC_PARAMS);
|
2005-04-17 11:53:25 +00:00
|
|
|
void sfCheckUserInterrupt(SCRIPTFUNC_PARAMS);
|
2005-04-16 11:03:34 +00:00
|
|
|
void sfScriptWalkRelative(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfScriptMoveRelative(SCRIPTFUNC_PARAMS);
|
2005-05-22 01:20:47 +00:00
|
|
|
void sfSimulSpeech2(SCRIPTFUNC_PARAMS);
|
2005-01-22 19:21:38 +00:00
|
|
|
void sfPlacard(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfPlacardOff(SCRIPTFUNC_PARAMS);
|
2005-04-21 01:30:07 +00:00
|
|
|
void sfSetProtagState(SCRIPTFUNC_PARAMS);
|
2005-01-22 19:21:38 +00:00
|
|
|
void sfResumeBgdAnim(SCRIPTFUNC_PARAMS);
|
2005-06-05 16:53:53 +00:00
|
|
|
void sfThrowActor(SCRIPTFUNC_PARAMS);
|
2005-01-22 21:40:54 +00:00
|
|
|
void sfWaitWalk(SCRIPTFUNC_PARAMS);
|
2005-04-16 16:55:35 +00:00
|
|
|
void sfScriptSceneID(SCRIPTFUNC_PARAMS);
|
2005-06-05 16:53:53 +00:00
|
|
|
void sfChangeActorScene(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfScriptClimb(SCRIPTFUNC_PARAMS);
|
2005-01-22 19:21:38 +00:00
|
|
|
void sfSetDoorState(SCRIPTFUNC_PARAMS);
|
2005-06-12 21:21:14 +00:00
|
|
|
void sfSetActorZ(SCRIPTFUNC_PARAMS);
|
2005-06-15 19:26:32 +00:00
|
|
|
void sfScriptText(SCRIPTFUNC_PARAMS);
|
2005-06-12 21:21:14 +00:00
|
|
|
void sfGetActorX(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfGetActorY(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfEraseDelta(SCRIPTFUNC_PARAMS);
|
2005-01-22 19:21:38 +00:00
|
|
|
void sfPlayMusic(SCRIPTFUNC_PARAMS);
|
2005-07-01 17:29:23 +00:00
|
|
|
void sfPickClimbOutPos(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfTossRif(SCRIPTFUNC_PARAMS);
|
2005-06-20 12:17:22 +00:00
|
|
|
void sfShowControls(SCRIPTFUNC_PARAMS);
|
2005-07-03 20:02:56 +00:00
|
|
|
void sfShowMap(SCRIPTFUNC_PARAMS);
|
2005-05-23 02:23:34 +00:00
|
|
|
void sfPuzzleWon(SCRIPTFUNC_PARAMS);
|
2005-01-22 19:21:38 +00:00
|
|
|
void sfEnableEscape(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfPlaySound(SCRIPTFUNC_PARAMS);
|
2005-06-19 21:18:00 +00:00
|
|
|
void sfPlayLoopedSound(SCRIPTFUNC_PARAMS);
|
2005-04-16 20:59:24 +00:00
|
|
|
void sfGetDeltaFrame(SCRIPTFUNC_PARAMS);
|
2005-05-18 18:28:10 +00:00
|
|
|
void sfShowProtect(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfProtectResult(SCRIPTFUNC_PARAMS);
|
2005-01-22 19:21:38 +00:00
|
|
|
void sfRand(SCRIPTFUNC_PARAMS);
|
2005-06-19 21:18:00 +00:00
|
|
|
void sfFadeMusic(SCRIPTFUNC_PARAMS);
|
2005-07-21 01:33:28 +00:00
|
|
|
void sfScriptStartCutAway(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfReturnFromCutAway(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfEndCutAway(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfGetMouseClicks(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfResetMouseClicks(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfWaitFrames(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfScriptFade(SCRIPTFUNC_PARAMS);
|
2005-06-19 21:18:00 +00:00
|
|
|
void sfPlayVoice(SCRIPTFUNC_PARAMS);
|
2005-07-21 01:33:28 +00:00
|
|
|
void sfVstopFX(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfVstopLoopedFX(SCRIPTFUNC_PARAMS);
|
|
|
|
void sfDemoIsInteractive(SCRIPTFUNC_PARAMS);
|
2005-07-21 22:13:06 +00:00
|
|
|
void sf94(SCRIPTFUNC_PARAMS);
|
2005-07-21 01:33:28 +00:00
|
|
|
void sfDebugShowData(SCRIPTFUNC_PARAMS);
|
2005-01-28 03:47:12 +00:00
|
|
|
void SF_stub(SCRIPTFUNC_PARAMS);
|
2005-07-21 01:33:28 +00:00
|
|
|
void sfNull(SCRIPTFUNC_PARAMS);
|
2004-08-01 22:48:40 +00:00
|
|
|
};
|
2004-04-12 21:40:49 +00:00
|
|
|
|
|
|
|
} // End of namespace Saga
|
|
|
|
|
|
|
|
#endif
|