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 SCUMM_SCRIPT_H
23 #define SCUMM_SCRIPT_H
24 
25 #include "common/func.h"
26 
27 namespace Scumm {
28 
29 typedef Common::Functor0<void> Opcode;
30 
32  Opcode *proc;
33 #ifndef REDUCE_MEMORY_USAGE
34  const char *desc;
35 #endif
36 
37 #ifndef REDUCE_MEMORY_USAGE
38  OpcodeEntry() : proc(0), desc(0) {}
39 #else
40  OpcodeEntry() : proc(0) {}
41 #endif
42  ~OpcodeEntry() {
43  setProc(0, 0);
44  }
45 
46  void setProc(Opcode *p, const char *d) {
47  if (proc != p) {
48  delete proc;
49  proc = p;
50  }
51 #ifndef REDUCE_MEMORY_USAGE
52  desc = d;
53 #endif
54  }
55 };
56 
57 
58 // This is to help devices with small memory (PDA, smartphones, ...)
59 // to save abit of memory used by opcode names in the Scumm engine.
60 #ifndef REDUCE_MEMORY_USAGE
61 # define _OPCODE(ver, x) setProc(new Common::Functor0Mem<void, ver>(this, &ver::x), #x)
62 #else
63 # define _OPCODE(ver, x) setProc(new Common::Functor0Mem<void, ver>(this, &ver::x), "")
64 #endif
65 
74 enum {
75  NUM_SCRIPT_SLOT = 80,
76  NUM_SCRIPT_LOCAL = 25
77 };
78 
79 /* Script status type (slot.status) */
80 enum {
81  ssDead = 0,
82  ssPaused = 1,
83  ssRunning = 2
84 };
85 
86 struct ScriptSlot {
87  uint32 offs;
88  int32 delay;
89  uint16 number;
90  uint16 delayFrameCount;
91  bool freezeResistant, recursive;
92  bool didexec;
93  byte status;
94  byte where;
95  byte freezeCount;
96  byte cutsceneOverride;
97  byte cycle;
98 };
99 
100 struct NestedScript {
101  uint16 number;
102  uint8 where;
103  uint8 slot;
104 };
105 
106 enum {
112 
117 };
118 
120  uint32 cutScenePtr[kMaxCutsceneNum];
121  byte cutSceneScript[kMaxCutsceneNum];
122  int16 cutSceneData[kMaxCutsceneNum];
123  int16 cutSceneScriptIndex;
124  byte cutSceneStackPointer;
125  ScriptSlot slot[NUM_SCRIPT_SLOT];
126  // Why does localvar have space for one extra local variable?
127  int32 localvar[NUM_SCRIPT_SLOT][NUM_SCRIPT_LOCAL + 1];
128 
130  byte numNestedScripts;
131 };
132 
133 } // End of namespace Scumm
134 
135 #endif
Definition: script.h:31
Definition: script.h:119
Definition: script.h:111
Definition: noncopyable.h:39
Definition: script.h:116
Definition: script.h:86
Definition: actor.h:30
Definition: script.h:100