ScummVM API documentation
script_life.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TWINE_SCRIPTLIFE_H
23 #define TWINE_SCRIPTLIFE_H
24 
25 #include "common/scummsys.h"
26 #include "twine/scene/actor.h"
27 
28 namespace TwinE {
29 
31  int32 actorIdx;
32  ActorStruct *actor;
34  uint8 *opcodePtr; // local opcode script pointer
35 
36  LifeScriptContext(int32 _actorIdx, ActorStruct *_actor) : actorIdx(_actorIdx), actor(_actor), stream(_actor->_lifeScript, _actor->_lifeScriptSize) {
37  assert(actor->_offsetLife >= 0);
38  stream.skip(_actor->_offsetLife);
39  updateOpcodePos();
40  }
41 
42  void setOpcode(uint8 opcode) {
43  *opcodePtr = opcode;
44  }
45 
46  void updateOpcodePos() {
47  opcodePtr = actor->_lifeScript + stream.pos();
48  }
49 };
50 
54 typedef int32 ScriptLifeFunc(TwinEEngine *engine, LifeScriptContext &ctx);
55 
57  const char *name;
58  ScriptLifeFunc *function;
59 };
60 
62 enum LifeScriptOperators {
63  /*==*/kEqualTo = 0,
64  /*> */kGreaterThan = 1,
65  /*< */kLessThan = 2,
66  /*>=*/kGreaterThanOrEqualTo = 3,
67  /*<=*/kLessThanOrEqualTo = 4,kNotEqualTo = 5
69 };
70 
71 class ScriptLife {
72 private:
73  TwinEEngine *_engine;
74  const ScriptLifeFunction* _functionMap;
75  size_t _functionMapSize;
76 
77 public:
78  static int32 lEMPTY(TwinEEngine *engine, LifeScriptContext &ctx);
79  static int32 lEND(TwinEEngine *engine, LifeScriptContext &ctx);
80  static int32 lNOP(TwinEEngine *engine, LifeScriptContext &ctx);
81  static int32 lSNIF(TwinEEngine *engine, LifeScriptContext &ctx);
82  static int32 lOFFSET(TwinEEngine *engine, LifeScriptContext &ctx);
83  static int32 lNEVERIF(TwinEEngine *engine, LifeScriptContext &ctx);
84  static int32 lNO_IF(TwinEEngine *engine, LifeScriptContext &ctx);
85  static int32 lLABEL(TwinEEngine *engine, LifeScriptContext &ctx);
86  static int32 lRETURN(TwinEEngine *engine, LifeScriptContext &ctx);
87  static int32 lIF(TwinEEngine *engine, LifeScriptContext &ctx);
88  static int32 lSWIF(TwinEEngine *engine, LifeScriptContext &ctx);
89  static int32 lONEIF(TwinEEngine *engine, LifeScriptContext &ctx);
90  static int32 lELSE(TwinEEngine *engine, LifeScriptContext &ctx);
91  static int32 lBODY(TwinEEngine *engine, LifeScriptContext &ctx);
92  static int32 lBODY_OBJ(TwinEEngine *engine, LifeScriptContext &ctx);
93  static int32 lANIM(TwinEEngine *engine, LifeScriptContext &ctx);
94  static int32 lANIM_OBJ(TwinEEngine *engine, LifeScriptContext &ctx);
95  static int32 lSET_LIFE(TwinEEngine *engine, LifeScriptContext &ctx);
96  static int32 lSET_LIFE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx);
97  static int32 lSET_TRACK(TwinEEngine *engine, LifeScriptContext &ctx);
98  static int32 lSET_TRACK_OBJ(TwinEEngine *engine, LifeScriptContext &ctx);
99  static int32 lMESSAGE(TwinEEngine *engine, LifeScriptContext &ctx);
100  static int32 lFALLABLE(TwinEEngine *engine, LifeScriptContext &ctx);
101  static int32 lSET_DIRMODE(TwinEEngine *engine, LifeScriptContext &ctx);
102  static int32 lSET_DIRMODE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx);
103  static int32 lCAM_FOLLOW(TwinEEngine *engine, LifeScriptContext &ctx);
104  static int32 lSET_BEHAVIOUR(TwinEEngine *engine, LifeScriptContext &ctx);
105  static int32 lSET_FLAG_CUBE(TwinEEngine *engine, LifeScriptContext &ctx);
106  static int32 lCOMPORTEMENT(TwinEEngine *engine, LifeScriptContext &ctx);
107  static int32 lSET_COMPORTEMENT(TwinEEngine *engine, LifeScriptContext &ctx);
108  static int32 lSET_COMPORTEMENT_OBJ(TwinEEngine *engine, LifeScriptContext &ctx);
109  static int32 lEND_COMPORTEMENT(TwinEEngine *engine, LifeScriptContext &ctx);
110  static int32 lKILL_OBJ(TwinEEngine *engine, LifeScriptContext &ctx);
111  static int32 lSUICIDE(TwinEEngine *engine, LifeScriptContext &ctx);
112  static int32 lUSE_ONE_LITTLE_KEY(TwinEEngine *engine, LifeScriptContext &ctx);
113  static int32 lGIVE_GOLD_PIECES(TwinEEngine *engine, LifeScriptContext &ctx);
114  static int32 lEND_LIFE(TwinEEngine *engine, LifeScriptContext &ctx);
115  static int32 lSTOP_L_TRACK(TwinEEngine *engine, LifeScriptContext &ctx);
116  static int32 lRESTORE_L_TRACK(TwinEEngine *engine, LifeScriptContext &ctx);
117  static int32 lMESSAGE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx);
118  static int32 lINC_CHAPTER(TwinEEngine *engine, LifeScriptContext &ctx);
119  static int32 lFOUND_OBJECT(TwinEEngine *engine, LifeScriptContext &ctx);
120  static int32 lSET_DOOR_LEFT(TwinEEngine *engine, LifeScriptContext &ctx);
121  static int32 lSET_DOOR_RIGHT(TwinEEngine *engine, LifeScriptContext &ctx);
122  static int32 lSET_DOOR_UP(TwinEEngine *engine, LifeScriptContext &ctx);
123  static int32 lSET_DOOR_DOWN(TwinEEngine *engine, LifeScriptContext &ctx);
124  static int32 lGIVE_BONUS(TwinEEngine *engine, LifeScriptContext &ctx);
125  static int32 lCHANGE_CUBE(TwinEEngine *engine, LifeScriptContext &ctx);
126  static int32 lOBJ_COL(TwinEEngine *engine, LifeScriptContext &ctx);
127  static int32 lBRICK_COL(TwinEEngine *engine, LifeScriptContext &ctx);
128  static int32 lOR_IF(TwinEEngine *engine, LifeScriptContext &ctx);
129  static int32 lINVISIBLE(TwinEEngine *engine, LifeScriptContext &ctx);
130  static int32 lZOOM(TwinEEngine *engine, LifeScriptContext &ctx);
131  static int32 lPOS_POINT(TwinEEngine *engine, LifeScriptContext &ctx);
132  static int32 lSET_MAGIC_LEVEL(TwinEEngine *engine, LifeScriptContext &ctx);
133  static int32 lSUB_MAGIC_POINT(TwinEEngine *engine, LifeScriptContext &ctx);
134  static int32 lSET_LIFE_POINT_OBJ(TwinEEngine *engine, LifeScriptContext &ctx);
135  static int32 lSUB_LIFE_POINT_OBJ(TwinEEngine *engine, LifeScriptContext &ctx);
136  static int32 lHIT_OBJ(TwinEEngine *engine, LifeScriptContext &ctx);
137  static int32 lPLAY_FLA(TwinEEngine *engine, LifeScriptContext &ctx);
138  static int32 lINC_CLOVER_BOX(TwinEEngine *engine, LifeScriptContext &ctx);
139  static int32 lSET_USED_INVENTORY(TwinEEngine *engine, LifeScriptContext &ctx);
140  static int32 lADD_CHOICE(TwinEEngine *engine, LifeScriptContext &ctx);
141  static int32 lASK_CHOICE(TwinEEngine *engine, LifeScriptContext &ctx);
142  static int32 lBIG_MESSAGE(TwinEEngine *engine, LifeScriptContext &ctx);
143  static int32 lINIT_PINGOUIN(TwinEEngine *engine, LifeScriptContext &ctx);
144  static int32 lSET_HOLO_POS(TwinEEngine *engine, LifeScriptContext &ctx);
145  static int32 lCLR_HOLO_POS(TwinEEngine *engine, LifeScriptContext &ctx);
146  static int32 lADD_FUEL(TwinEEngine *engine, LifeScriptContext &ctx);
147  static int32 lSUB_FUEL(TwinEEngine *engine, LifeScriptContext &ctx);
148  static int32 lSET_GRM(TwinEEngine *engine, LifeScriptContext &ctx);
149  static int32 lSAY_MESSAGE(TwinEEngine *engine, LifeScriptContext &ctx);
150  static int32 lSAY_MESSAGE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx);
151  static int32 lFULL_POINT(TwinEEngine *engine, LifeScriptContext &ctx);
152  static int32 lBETA(TwinEEngine *engine, LifeScriptContext &ctx);
153  static int32 lGRM_OFF(TwinEEngine *engine, LifeScriptContext &ctx);
154  static int32 lFADE_PAL_RED(TwinEEngine *engine, LifeScriptContext &ctx);
155  static int32 lFADE_ALARM_RED(TwinEEngine *engine, LifeScriptContext &ctx);
156  static int32 lFADE_ALARM_PAL(TwinEEngine *engine, LifeScriptContext &ctx);
157  static int32 lFADE_RED_PAL(TwinEEngine *engine, LifeScriptContext &ctx);
158  static int32 lFADE_RED_ALARM(TwinEEngine *engine, LifeScriptContext &ctx);
159  static int32 lFADE_PAL_ALARM(TwinEEngine *engine, LifeScriptContext &ctx);
160  static int32 lEXPLODE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx);
161 
162  static int32 lASK_CHOICE_OBJ(TwinEEngine *engine, LifeScriptContext &ctx);
163  static int32 lSET_DARK_PAL(TwinEEngine *engine, LifeScriptContext &ctx);
164  static int32 lSET_NORMAL_PAL(TwinEEngine *engine, LifeScriptContext &ctx);
165  static int32 lMESSAGE_SENDELL(TwinEEngine *engine, LifeScriptContext &ctx);
166  static int32 lANIM_SET(TwinEEngine *engine, LifeScriptContext &ctx);
167  static int32 lHOLOMAP_TRAJ(TwinEEngine *engine, LifeScriptContext &ctx);
168  static int32 lGAME_OVER(TwinEEngine *engine, LifeScriptContext &ctx);
169  static int32 lTHE_END(TwinEEngine *engine, LifeScriptContext &ctx);
170  static int32 lPLAY_CD_TRACK(TwinEEngine *engine, LifeScriptContext &ctx);
171  static int32 lPROJ_ISO(TwinEEngine *engine, LifeScriptContext &ctx);
172  static int32 lPROJ_3D(TwinEEngine *engine, LifeScriptContext &ctx);
173  static int32 lTEXT(TwinEEngine *engine, LifeScriptContext &ctx);
174  static int32 lCLEAR_TEXT(TwinEEngine *engine, LifeScriptContext &ctx);
175  static int32 lBRUTAL_EXIT(TwinEEngine *engine, LifeScriptContext &ctx);
176 
177 public:
178  ScriptLife(TwinEEngine *engine, const ScriptLifeFunction* functionMap, size_t entries);
179 
180  virtual ~ScriptLife() {}
185  void doLife(int32 actorIdx);
186 };
187 
188 } // namespace TwinE
189 
190 #endif
Definition: actor.h:143
Definition: script_life.h:56
Definition: memstream.h:394
Definition: script_life.h:30
int64 pos() const override
Definition: memstream.h:427
Definition: script_life.h:71
Definition: twine.h:207
Definition: achievements_tables.h:27
virtual bool skip(uint32 offset)
Definition: stream.h:793