scummvm/engines/myst3/script.h

139 lines
4 KiB
C
Raw Normal View History

2009-09-15 17:53:36 +02:00
/* Residual - A 3D game interpreter
*
* Residual is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the AUTHORS
* file distributed with this source distribution.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library 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
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
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 {
2011-09-03 15:39:16 +02:00
class Myst3Engine;
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 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);
const Common::String describeCommand(uint16 op);
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);
struct Command {
Command() {}
Command(uint16 o, CommandProc p, const char *d) : op(o), proc(p), desc(d) {}
uint16 op;
CommandProc proc;
const char *desc;
};
2009-09-15 17:53:36 +02:00
2011-09-03 15:39:16 +02:00
Myst3Engine *_vm;
Common::Array<Command> _commands;
2011-09-04 20:08:37 +02:00
void runOp(Context &c, const Opcode &op);
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);
2011-09-04 20:08:37 +02:00
DECLARE_OPCODE(stopWholeScript);
DECLARE_OPCODE(sunspotAdd);
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);
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);
DECLARE_OPCODE(varRotateValue3);
DECLARE_OPCODE(continueToNextScript);
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);
DECLARE_OPCODE(goToNode);
DECLARE_OPCODE(goToRoomNode);
2011-09-04 11:16:27 +02:00
DECLARE_OPCODE(runScriptsFromNode);
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_ */