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
27namespace Scumm {
28
29typedef 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
74enum {
75 NUM_SCRIPT_SLOT = 80,
76 NUM_SCRIPT_LOCAL = 25
77};
78
79/* Script status type (slot.status) */
80enum {
81 ssDead = 0,
82 ssPaused = 1,
83 ssRunning = 2
84};
85
86struct 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
101 uint16 number;
102 uint8 where;
103 uint8 slot;
104};
105
106enum {
112
117 kMaxScriptNestingHE = 40
118};
119
120enum {
121 kScriptNumEXCD = 10001,
122 kScriptNumENCD = 10002
123};
124
126#define ROOM_VAL(val) (0x8000 + (val))
127
129 uint32 cutScenePtr[kMaxCutsceneNum];
130 byte cutSceneScript[kMaxCutsceneNum];
131 int16 cutSceneData[kMaxCutsceneNum];
132 int16 cutSceneScriptIndex;
133 byte cutSceneStackPointer;
134 ScriptSlot slot[NUM_SCRIPT_SLOT];
135 // Why does localvar have space for one extra local variable?
136 int32 localvar[NUM_SCRIPT_SLOT][NUM_SCRIPT_LOCAL + 1];
137
138 NestedScript nest[kMaxScriptNestingHE]; // Changed from 15 to 40 because of later HE games
139 byte numNestedScripts;
140};
141
142} // End of namespace Scumm
143
144#endif
Definition: noncopyable.h:39
Definition: actor.h:30
@ kMaxCutsceneNum
Definition: script.h:111
@ kMaxScriptNesting
Definition: script.h:116
Definition: script.h:100
Definition: script.h:31
Definition: script.h:86
Definition: script.h:128