ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 GOT_GAME_SCRIPT_H
23 #define GOT_GAME_SCRIPT_H
24 
25 #include "got/data/defines.h"
26 #include "got/gfx/gfx_pics.h"
27 
28 namespace Got {
29 
30 typedef void (*ScriptEndFn)();
31 
32 enum ScriptPause {
33  SCRIPT_READY, SCRIPT_PAUSED, SCRIPT_RESUMING
34 };
35 
36 class Scripts {
37 public:
38  Scripts();
39  ~Scripts();
40 
41  void executeScript(long index, const Gfx::Pics &speakerIcon, ScriptEndFn endFn = nullptr);
42  void pause();
43  void resume();
44  void setAskResponse(int option);
45  void runIfResuming();
46 
47 private:
48  ScriptEndFn _endFn = nullptr;
49  long _numVar[26] = {}; // numeric variables
50  char _strVar[26][81] = {}; // string vars
51  char _lineLabel[32][9] = {}; // line label look up table
52  char *_linePtr[32] = {}; // line label pointers
53  char *_newPtr = nullptr;
54  int _numLabels = 0; // number of labels
55  char *_gosubStack[32] = {}; // stack for GOSUB return addresses
56  int _gosubPtr = 0; // GOSUB stack pointer
57  char *_forStack[11] = {}; // FOR stack
58  long _forVal[11] = {}; // current FOR value
59  int8 _forVar[11] = {}; // ending FOR value (target var)
60  int8 _forPtr = 0; // FOR stack pointer
61  char *_buffPtr = nullptr; // pointer to current command
62  char *_buffEnd = nullptr; // pointer to end of buffer
63  char *_buffer = nullptr; // buffer space (alloc'ed)
64  long _scrIndex = 0;
65  Gfx::Pics _scrPic;
66  long _lValue = 0;
67  long _lTemp = 0;
68  char _tempS[255] = {};
69  ScriptPause _paused = SCRIPT_READY;
70  int _askVar = -1;
71 
72 private:
73  int readScriptFile();
74  void scriptError(int err_num);
75  int getCommand();
76  int skipColon();
77  int calcValue();
78  int getNextValue();
79  int calcString(int mode);
80  void getStr();
81  int getInternalVariable();
82  int execCommand(int num);
83  int getLine(char *src, char *dst);
84  void scriptEntry() {}
85  void scriptExit();
86 
87  int cmd_goto();
88  int cmd_if();
89  int cmd_run();
90  int cmd_addJewels();
91  int cmd_addHealth();
92  int cmd_addMagic();
93  int cmd_addKeys();
94  int cmd_addScore();
95  int cmd_say(int mode, int type);
96  int cmd_ask();
97  int cmd_sound();
98  int cmd_setTile();
99  int cmd_itemGive();
100  int cmd_itemTake();
101  int cmd_setFlag();
102  int cmd_ltoa();
103  int cmd_pause();
104  int cmd_visible();
105  int cmd_random();
106  int cmd_exec();
107 
108  void scr_func1();
109  void scr_func2();
110  void scr_func3();
111  void scr_func4();
112  void scr_func5();
113 
114  typedef void (Scripts:: *ScrFunction)();
115  static ScrFunction scr_func[5];
116 
117  void runScript(bool firstTime = true);
118  void scriptLoop();
119 
120 };
121 
122 extern void executeScript(long index, const Gfx::Pics &speakerIcon,
123  ScriptEndFn endFn = nullptr);
124 
125 } // namespace Got
126 
127 #endif
Definition: gfx_pics.h:77
Definition: script.h:36
Definition: console.h:28