ScummVM API documentation
script.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 TOLTECS_SCRIPT_H
23 #define TOLTECS_SCRIPT_H
24 
25 #include "common/func.h"
26 
27 namespace Toltecs {
28 
29 const int kMaxScriptSlots = 50;
30 const int kScriptStackSize = 4096 + 4;
31 
32 enum VarType {
33  vtByte,
34  vtWord
35 };
36 
37 typedef Common::Functor0<void> ScriptFunction;
38 
40 public:
43 
44  void loadScript(uint resIndex, uint slotIndex);
45  void setMainScript(uint slotIndex);
46  void runScript();
47 
48  byte *getSlotData(int slotIndex) const { return _slots[slotIndex].data; }
49 
50  int16 getGameVar(uint variable);
51  void setGameVar(uint variable, int16 value);
52 
53  void saveState(Common::WriteStream *out);
54  void loadState(Common::ReadStream *in);
55 
56  void setSwitchLocalDataNear(bool newValue) { _switchLocalDataNear = newValue; }
57 
58 protected:
59 
60  struct ScriptRegs {
61  int16 reg0;
62  int16 reg1;
63  int16 reg2;
64  int16 reg3;
65  int16 reg4;
66  int16 reg5;
67  int16 reg6;
68  int16 sp;
69  int16 reg8;
70  };
71 
72  struct ScriptSlot {
73  byte *data;
74  int32 size;
75  uint resIndex;
76  };
77 
78  ToltecsEngine *_vm;
80  Common::Array<const char *> _scriptFuncNames;
81 
82  byte *_stack;
83 
84  byte *_code, *_subCode, *_codeStart;
85  byte *_localData;
86  bool _switchLocalDataNear, _switchLocalDataFar, _switchLocalDataToStack;
87  bool _cmpBitTest;
88 
89  ScriptSlot _slots[kMaxScriptSlots];
90 
91  ScriptRegs _regs;
92  int16 _savedSp;
93 
94  byte readByte();
95  int16 readInt16();
96 
97  void execOpcode(byte opcode);
98 
99  void setupScriptFunctions();
100  void execScriptFunction(uint16 index);
101 
102  byte arg8(int16 offset);
103  int16 arg16(int16 offset);
104 
105  void pushInt16(int16 value);
106  int16 popInt16();
107 
108  void localWrite8(int16 offset, byte value);
109  byte localRead8(int16 offset);
110  void localWrite16(int16 offset, int16 value);
111  int16 localRead16(int16 offset);
112  byte *localPtr(int16 offset);
113 
114  void sfNop();
115  void sfGetGameVar();
116  void sfSetGameVar();
117  void sfUpdateScreen();
118  void sfGetRandomNumber();
119  void sfDrawGuiTextMulti();
120  void sfUpdateVerbLine();
121  void sfSetFontColor();
122  void sfGetTalkTextDuration();
123  void sfTalk();
124  void sfFindPaletteFragment();
125  void sfClearPaletteFragments();
126  void sfAddPaletteFragment();
127  void sfSetDeltaAnimPalette();
128  void sfSetUnkPaletteEffect();
129  void sfBuildColorTransTable();
130  void sfSetDeltaMainPalette();
131  void sfLoadScript();
132  void sfRegisterFont();
133  void sfLoadAddPalette();
134  void sfLoadScene();
135  void sfSetGuiHeight();
136  void sfFindMouseInRectIndex1();
137  void sfFindMouseInRectIndex2();
138  void sfDrawGuiImage();
139  void sfAddAnimatedSpriteNoLoop();
140  void sfAddAnimatedSprite();
141  void sfAddStaticSprite();
142  void sfAddAnimatedSpriteScaled();
143  void sfFindPath();
144  void sfWalk();
145  void sfScrollCameraUp();
146  void sfScrollCameraDown();
147  void sfScrollCameraLeft();
148  void sfScrollCameraRight();
149  void sfScrollCameraUpEx();
150  void sfScrollCameraDownEx();
151  void sfScrollCameraLeftEx();
152  void sfScrollCameraRightEx();
153  void sfSetCamera();
154  void sfGetCameraChanged();
155  void sfGetRgbModifiertAtPoint();
156  void sfStartAnim();
157  void sfAnimNextFrame();
158  void sfGetAnimFrameNumber();
159  void sfGetAnimStatus();
160  void sfStartShakeScreen();
161  void sfStopShakeScreen();
162  void sfStartSequence();
163  void sfEndSequence();
164  void sfSetSequenceVolume();
165  void sfPlayPositionalSound();
166  void sfPlaySound2();
167  void sfClearScreen();
168  void sfHandleInput();
169  void sfRunOptionsScreen();
170  void sfPrecacheSprites();
171  void sfPrecacheSounds1();
172  void sfDeletePrecachedFiles();
173  void sfPrecacheSounds2();
174  void sfRestoreStackPtr();
175  void sfSaveStackPtr();
176  void sfPlayMovie();
177 
178 };
179 
180 
181 } // End of namespace Toltecs
182 
183 #endif /* TOLTECS_H */
Definition: animation.h:28
Definition: stream.h:77
Definition: array.h:52
Definition: toltecs.h:94
Definition: stream.h:385
Definition: script.h:39