2012-01-10 20:41:51 +01:00
|
|
|
/* ResidualVM - A 3D game interpreter
|
2009-09-15 17:53:36 +02:00
|
|
|
*
|
2012-01-10 20:41:51 +01:00
|
|
|
* ResidualVM is the legal property of its developers, whose names
|
2009-09-15 17:53:36 +02:00
|
|
|
* are too numerous to list here. Please refer to the AUTHORS
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
2012-01-05 10:07:48 +01:00
|
|
|
* 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.
|
2009-09-15 17:53:36 +02:00
|
|
|
|
2012-01-05 10:07:48 +01:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2009-09-15 17:53:36 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-01-05 10:07:48 +01:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2009-09-15 17:53:36 +02:00
|
|
|
|
2012-01-05 10:07:48 +01:00
|
|
|
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-09-15 17:53:36 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-09-03 15:39:16 +02:00
|
|
|
#ifndef SCRIPT_H_
|
|
|
|
#define SCRIPT_H_
|
2009-09-15 17:53:36 +02:00
|
|
|
|
2011-09-03 15:39:16 +02:00
|
|
|
#include "common/array.h"
|
2009-09-15 17:53:36 +02:00
|
|
|
|
2011-09-03 15:39:16 +02:00
|
|
|
namespace Myst3 {
|
2009-09-15 18:45:55 +02:00
|
|
|
|
2011-09-03 15:39:16 +02:00
|
|
|
class Myst3Engine;
|
2012-01-09 12:26:15 +01:00
|
|
|
class Puzzles;
|
2011-09-03 15:39:16 +02:00
|
|
|
struct Opcode;
|
2009-09-15 17:53:36 +02:00
|
|
|
|
2011-09-04 20:08:37 +02:00
|
|
|
#define DECLARE_OPCODE(x) void x(Context &c, const Opcode &cmd)
|
2011-09-03 19:19:25 +02:00
|
|
|
|
2011-09-03 15:39:16 +02:00
|
|
|
class Script {
|
|
|
|
public:
|
|
|
|
Script(Myst3Engine *vm);
|
|
|
|
virtual ~Script();
|
2009-09-15 17:53:36 +02:00
|
|
|
|
2011-09-04 21:58:40 +02:00
|
|
|
bool run(const Common::Array<Opcode> *script);
|
2011-10-15 10:02:30 +02:00
|
|
|
const Common::String describeOpcode(const Opcode &opcode);
|
2011-09-03 15:39:16 +02:00
|
|
|
|
|
|
|
private:
|
2011-09-04 20:08:37 +02:00
|
|
|
struct Context {
|
|
|
|
bool endScript;
|
|
|
|
bool result;
|
2011-09-04 21:58:40 +02:00
|
|
|
const Common::Array<Opcode> *script;
|
2011-09-04 20:08:37 +02:00
|
|
|
Common::Array<Opcode>::const_iterator op;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef void (Script::*CommandProc)(Context &c, const Opcode &cmd);
|
2011-09-03 19:19:25 +02:00
|
|
|
|
2011-10-15 10:02:30 +02:00
|
|
|
enum ArgumentType {
|
|
|
|
kUnknown,
|
|
|
|
kVar,
|
|
|
|
kValue,
|
|
|
|
kEvalValue,
|
|
|
|
kCondition
|
|
|
|
};
|
|
|
|
|
2011-09-03 19:19:25 +02:00
|
|
|
struct Command {
|
|
|
|
Command() {}
|
2011-10-15 10:02:30 +02:00
|
|
|
Command(uint16 o, CommandProc p, const char *d, uint8 argc, ...) : op(o), proc(p), desc(d) {
|
|
|
|
va_list types;
|
|
|
|
|
|
|
|
for(int j = 0; j < 5; j++)
|
|
|
|
argType[j] = kUnknown;
|
|
|
|
|
|
|
|
va_start(types, argc);
|
|
|
|
for(int j = 0; j < argc; j++)
|
|
|
|
argType[j] = (ArgumentType) va_arg(types, int);
|
|
|
|
va_end(types);
|
|
|
|
}
|
2011-09-03 19:19:25 +02:00
|
|
|
|
|
|
|
uint16 op;
|
|
|
|
CommandProc proc;
|
|
|
|
const char *desc;
|
2011-10-15 10:02:30 +02:00
|
|
|
|
|
|
|
ArgumentType argType[5];
|
2011-09-03 19:19:25 +02:00
|
|
|
};
|
2009-09-15 17:53:36 +02:00
|
|
|
|
2011-09-03 15:39:16 +02:00
|
|
|
Myst3Engine *_vm;
|
2012-01-09 12:26:15 +01:00
|
|
|
Puzzles *_puzzles;
|
|
|
|
|
2011-09-03 19:19:25 +02:00
|
|
|
Common::Array<Command> _commands;
|
|
|
|
|
2011-10-15 10:02:30 +02:00
|
|
|
const Command &findCommand(uint16 op);
|
|
|
|
const Common::String describeCommand(uint16 op);
|
|
|
|
const Common::String describeArgument(ArgumentType type, int16 value);
|
|
|
|
|
2011-09-04 20:08:37 +02:00
|
|
|
void runOp(Context &c, const Opcode &op);
|
2011-09-11 10:15:41 +02:00
|
|
|
void goToElse(Context &c);
|
2011-09-03 19:19:25 +02:00
|
|
|
|
2011-09-24 18:47:23 +02:00
|
|
|
void runScriptForVarDrawFramesHelper(uint16 var, int32 startValue, int32 endValue, uint16 script, int32 numFrames);
|
|
|
|
|
2011-10-15 10:02:30 +02:00
|
|
|
DECLARE_OPCODE(badOpcode);
|
|
|
|
|
2011-09-04 21:58:40 +02:00
|
|
|
DECLARE_OPCODE(nodeCubeInit);
|
2011-09-05 20:13:48 +02:00
|
|
|
DECLARE_OPCODE(nodeCubeInitIndex);
|
|
|
|
DECLARE_OPCODE(nodeFrameInit);
|
|
|
|
DECLARE_OPCODE(nodeFrameInitCond);
|
|
|
|
DECLARE_OPCODE(nodeFrameInitIndex);
|
2012-01-06 08:54:17 +01:00
|
|
|
DECLARE_OPCODE(nodeMenuInit);
|
2011-09-04 20:08:37 +02:00
|
|
|
DECLARE_OPCODE(stopWholeScript);
|
2011-12-26 21:00:19 +01:00
|
|
|
DECLARE_OPCODE(spotItemAdd);
|
|
|
|
DECLARE_OPCODE(spotItemAddCond);
|
|
|
|
DECLARE_OPCODE(spotItemAddCondFade);
|
2012-01-12 13:59:21 +01:00
|
|
|
DECLARE_OPCODE(spotItemAddMenu);
|
2011-09-24 08:58:00 +02:00
|
|
|
DECLARE_OPCODE(movieInitLooping);
|
|
|
|
DECLARE_OPCODE(movieInitCondLooping);
|
2011-09-18 13:05:49 +02:00
|
|
|
DECLARE_OPCODE(movieInitCond);
|
2011-09-24 08:58:00 +02:00
|
|
|
DECLARE_OPCODE(movieInitPreloadLooping);
|
|
|
|
DECLARE_OPCODE(movieInitCondPreloadLooping);
|
2011-09-18 13:05:49 +02:00
|
|
|
DECLARE_OPCODE(movieInitCondPreload);
|
2011-09-24 08:58:00 +02:00
|
|
|
DECLARE_OPCODE(movieInitFrameVar);
|
|
|
|
DECLARE_OPCODE(movieInitFrameVarPreload);
|
|
|
|
DECLARE_OPCODE(movieInitOverrridePosition);
|
|
|
|
DECLARE_OPCODE(movieInitScriptedPosition);
|
2011-09-04 20:08:37 +02:00
|
|
|
DECLARE_OPCODE(sunspotAdd);
|
2012-01-05 12:22:58 +01:00
|
|
|
DECLARE_OPCODE(sunspotAddIntensity);
|
|
|
|
DECLARE_OPCODE(sunspotAddVarIntensity);
|
|
|
|
DECLARE_OPCODE(sunspotAddIntensityColor);
|
|
|
|
DECLARE_OPCODE(sunspotAddVarIntensityColor);
|
|
|
|
DECLARE_OPCODE(sunspotAddIntensityRadius);
|
|
|
|
DECLARE_OPCODE(sunspotAddVarIntensityRadius);
|
|
|
|
DECLARE_OPCODE(sunspotAddIntColorRadius);
|
|
|
|
DECLARE_OPCODE(sunspotAddVarIntColorRadius);
|
2011-12-26 11:54:28 +01:00
|
|
|
DECLARE_OPCODE(inventoryAddFront);
|
|
|
|
DECLARE_OPCODE(inventoryAddBack);
|
|
|
|
DECLARE_OPCODE(inventoryRemove);
|
|
|
|
DECLARE_OPCODE(inventoryReset);
|
2012-01-09 18:38:29 +01:00
|
|
|
DECLARE_OPCODE(inventoryAddSaavChapter);
|
2011-09-04 20:08:37 +02:00
|
|
|
DECLARE_OPCODE(varSetZero);
|
|
|
|
DECLARE_OPCODE(varSetOne);
|
|
|
|
DECLARE_OPCODE(varSetTwo);
|
|
|
|
DECLARE_OPCODE(varSetOneHundred);
|
2011-09-04 11:16:27 +02:00
|
|
|
DECLARE_OPCODE(varSetValue);
|
2011-09-05 20:13:48 +02:00
|
|
|
DECLARE_OPCODE(varToggle);
|
|
|
|
DECLARE_OPCODE(varSetOneIfZero);
|
2011-10-15 10:02:30 +02:00
|
|
|
DECLARE_OPCODE(varRandRange);
|
2012-01-03 13:24:17 +01:00
|
|
|
DECLARE_OPCODE(polarToRect);
|
2011-09-05 20:13:48 +02:00
|
|
|
DECLARE_OPCODE(varRemoveBits);
|
|
|
|
DECLARE_OPCODE(varToggleBits);
|
|
|
|
DECLARE_OPCODE(varCopy);
|
|
|
|
DECLARE_OPCODE(varSetBitsFromVar);
|
|
|
|
DECLARE_OPCODE(varSetBits);
|
|
|
|
DECLARE_OPCODE(varApplyMask);
|
|
|
|
DECLARE_OPCODE(varSwap);
|
|
|
|
DECLARE_OPCODE(varIncrement);
|
|
|
|
DECLARE_OPCODE(varIncrementMax);
|
|
|
|
DECLARE_OPCODE(varIncrementMaxLooping);
|
|
|
|
DECLARE_OPCODE(varAddValueMaxLooping);
|
|
|
|
DECLARE_OPCODE(varDecrement);
|
|
|
|
DECLARE_OPCODE(varDecrementMin);
|
|
|
|
DECLARE_OPCODE(varAddValueMax);
|
|
|
|
DECLARE_OPCODE(varSubValueMin);
|
|
|
|
DECLARE_OPCODE(varZeroRange);
|
|
|
|
DECLARE_OPCODE(varCopyRange);
|
|
|
|
DECLARE_OPCODE(varSetRange);
|
2011-09-04 20:08:37 +02:00
|
|
|
DECLARE_OPCODE(varIncrementMaxTen);
|
|
|
|
DECLARE_OPCODE(varAddValue);
|
|
|
|
DECLARE_OPCODE(varArrayAddValue);
|
|
|
|
DECLARE_OPCODE(varAddVarValue);
|
|
|
|
DECLARE_OPCODE(varSubValue);
|
|
|
|
DECLARE_OPCODE(varSubVarValue);
|
|
|
|
DECLARE_OPCODE(varModValue);
|
|
|
|
DECLARE_OPCODE(varMultValue);
|
|
|
|
DECLARE_OPCODE(varMultVarValue);
|
|
|
|
DECLARE_OPCODE(varDivValue);
|
|
|
|
DECLARE_OPCODE(varDivVarValue);
|
|
|
|
DECLARE_OPCODE(varMinValue);
|
|
|
|
DECLARE_OPCODE(varClipValue);
|
2011-09-24 18:47:23 +02:00
|
|
|
DECLARE_OPCODE(varClipChangeBound);
|
|
|
|
DECLARE_OPCODE(varAbsoluteSubValue);
|
|
|
|
DECLARE_OPCODE(varAbsoluteSubVar);
|
|
|
|
DECLARE_OPCODE(varRatioToPercents);
|
2011-09-04 20:08:37 +02:00
|
|
|
DECLARE_OPCODE(varRotateValue3);
|
2011-09-11 10:15:41 +02:00
|
|
|
DECLARE_OPCODE(ifElse);
|
2011-09-04 20:08:37 +02:00
|
|
|
DECLARE_OPCODE(ifCondition);
|
|
|
|
DECLARE_OPCODE(ifCond1AndCond2);
|
|
|
|
DECLARE_OPCODE(ifCond1OrCond2);
|
|
|
|
DECLARE_OPCODE(ifOneVarSetInRange);
|
|
|
|
DECLARE_OPCODE(ifVarEqualsValue);
|
|
|
|
DECLARE_OPCODE(ifVarNotEqualsValue);
|
|
|
|
DECLARE_OPCODE(ifVar1EqualsVar2);
|
|
|
|
DECLARE_OPCODE(ifVar1NotEqualsVar2);
|
|
|
|
DECLARE_OPCODE(ifVarSupEqValue);
|
|
|
|
DECLARE_OPCODE(ifVarInfEqValue);
|
|
|
|
DECLARE_OPCODE(ifVarInRange);
|
|
|
|
DECLARE_OPCODE(ifVarNotInRange);
|
|
|
|
DECLARE_OPCODE(ifVar1SupEqVar2);
|
|
|
|
DECLARE_OPCODE(ifVar1SupVar2);
|
|
|
|
DECLARE_OPCODE(ifVar1InfEqVar2);
|
|
|
|
DECLARE_OPCODE(ifVarHasAllBitsSet);
|
|
|
|
DECLARE_OPCODE(ifVarHasNoBitsSet);
|
|
|
|
DECLARE_OPCODE(ifVarHasSomeBitsSet);
|
2012-01-06 13:38:00 +01:00
|
|
|
DECLARE_OPCODE(ifMouseIsInRect);
|
2012-01-08 20:57:20 +01:00
|
|
|
DECLARE_OPCODE(chooseNextNode);
|
|
|
|
DECLARE_OPCODE(goToNodeTransition);
|
|
|
|
DECLARE_OPCODE(goToNodeTrans2);
|
|
|
|
DECLARE_OPCODE(goToNodeTrans1);
|
2011-09-03 19:19:25 +02:00
|
|
|
DECLARE_OPCODE(goToRoomNode);
|
2012-01-04 14:59:35 +01:00
|
|
|
DECLARE_OPCODE(zipToNode);
|
|
|
|
DECLARE_OPCODE(zipToRoomNode);
|
2011-10-15 21:21:46 +02:00
|
|
|
DECLARE_OPCODE(moviePlay);
|
|
|
|
DECLARE_OPCODE(moviePlaySynchronized);
|
2011-12-29 21:14:05 +01:00
|
|
|
DECLARE_OPCODE(runScriptWhileCond);
|
|
|
|
DECLARE_OPCODE(runScriptWhileCondEachXFrames);
|
2011-09-24 18:47:23 +02:00
|
|
|
DECLARE_OPCODE(runScriptForVar);
|
|
|
|
DECLARE_OPCODE(runScriptForVarEachXFrames);
|
|
|
|
DECLARE_OPCODE(runScriptForVarStartVar);
|
|
|
|
DECLARE_OPCODE(runScriptForVarStartVarEachXFrames);
|
|
|
|
DECLARE_OPCODE(runScriptForVarEndVar);
|
|
|
|
DECLARE_OPCODE(runScriptForVarEndVarEachXFrames);
|
|
|
|
DECLARE_OPCODE(runScriptForVarStartEndVar);
|
|
|
|
DECLARE_OPCODE(runScriptForVarStartEndVarEachXFrames);
|
|
|
|
DECLARE_OPCODE(drawFramesForVar);
|
|
|
|
DECLARE_OPCODE(drawFramesForVarEachTwoFrames);
|
|
|
|
DECLARE_OPCODE(drawFramesForVarStartEndVarEachTwoFrames);
|
|
|
|
DECLARE_OPCODE(runScript);
|
2012-01-09 12:26:15 +01:00
|
|
|
DECLARE_OPCODE(runPuzzle1);
|
|
|
|
DECLARE_OPCODE(runPuzzle2);
|
|
|
|
DECLARE_OPCODE(runPuzzle3);
|
|
|
|
DECLARE_OPCODE(runPuzzle4);
|
2012-01-13 17:51:45 +01:00
|
|
|
DECLARE_OPCODE(newGame);
|
2012-01-09 12:26:15 +01:00
|
|
|
|
2011-09-03 15:39:16 +02:00
|
|
|
};
|
2009-09-15 17:53:36 +02:00
|
|
|
|
2011-09-03 15:39:16 +02:00
|
|
|
} /* namespace Myst3 */
|
|
|
|
#endif /* SCRIPT_H_ */
|