ScummVM API documentation
process.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 PROCESS_H
23#define PROCESS_H
24
25#include "agds/object.h"
26#include "agds/opcode.h"
27#include "agds/processExitCode.h"
28#include "common/debug.h"
29#include "common/language.h"
30#include "common/scummsys.h"
31#include "common/stack.h"
32
33namespace AGDS {
34
35class AGDSEngine;
36class Screen;
37class Animation;
38using AnimationPtr = Common::SharedPtr<Animation>;
39
40class Process {
41public:
42 enum Status { kStatusActive,
43 kStatusPassive,
44 kStatusDone,
45 kStatusError };
46
47private:
49
50 AGDSEngine *_engine;
51 Common::String _parentScreen;
52 ObjectPtr _object;
53 StackType _stack;
54 unsigned _entryPoint;
55 unsigned _ip, _lastIp;
56 Status _status;
57 bool _exited;
58 ProcessExitCode _exitCode;
59 Common::String _exitArg1, _exitArg2;
60 int _exitIntArg1, _exitIntArg2;
61 int _tileWidth, _tileHeight;
62 int _tileResource;
63 int _tileIndex;
64 Common::String _phaseVar;
65 int _timer;
66 int _animationCycles;
67 bool _animationLoop;
68 Common::Point _animationPosition;
69 int _animationZ;
70 int _animationDelay;
71 int _animationRandom;
72 bool _phaseVarControlled;
73 int _animationSpeed;
74 bool _samplePeriodic;
75 bool _sampleAmbient;
76 int32 _sampleVolume;
77 Common::Point _mousePosition;
78 int _filmSubtitlesResource;
79 AnimationPtr _processAnimation;
80 int _version;
81 Common::Language _language;
82
83private:
84 void debug(const char *str, ...);
85 void error(const char *str, ...);
86
87 void push(bool);
88
89 uint8 next();
90 uint16 next16() {
91 uint8 l = next();
92 uint16 h = next();
93 return (h << 8) | l;
94 }
95 uint16 nextOpcode();
96
97 int32 pop();
98 int32 top();
99
100 Common::String getString(int id);
101 Common::String popString() {
102 return getString(pop());
103 }
104 Common::String popText();
105 uint32 popColor();
106
107#define AGDS_PROCESS_METHOD(opcode, method) \
108 void method();
109#define AGDS_PROCESS_METHOD_C(opcode, method) \
110 void method(int8);
111#define AGDS_PROCESS_METHOD_B(opcode, method) \
112 void method(uint8);
113#define AGDS_PROCESS_METHOD_W(opcode, method) \
114 void method(int16);
115#define AGDS_PROCESS_METHOD_U(opcode, method) \
116 void method(uint16);
117#define AGDS_PROCESS_METHOD_UD(opcode, method) \
118 void method(int32);
119#define AGDS_PROCESS_METHOD_UU(opcode, method) \
120 void method(uint16, uint16);
121
122 AGDS_OPCODE_LIST(AGDS_PROCESS_METHOD,
123 AGDS_PROCESS_METHOD_C, AGDS_PROCESS_METHOD_B, AGDS_PROCESS_METHOD_W,
124 AGDS_PROCESS_METHOD_U, AGDS_PROCESS_METHOD_UD, AGDS_PROCESS_METHOD_UU)
125
126 void moveCharacter(bool usermove);
127 void tell(bool npc, const Common::String &sound);
128 void tell(bool npc) { tell(npc, Common::String()); }
129
130 Common::String getCloneVarName(const Common::String &arg1, const Common::String &arg2);
131
132 void suspend(ProcessExitCode exitCode, const Common::String &arg1, const Common::String &arg2 = Common::String());
133 void suspend(ProcessExitCode exitCode, int arg1 = 0, int arg2 = 0);
134
135 ProcessExitCode resume();
136 void suspendIfPassive();
137
138 void setupAnimation(const AnimationPtr &animation);
139 void attachInventoryObjectToMouse(bool flag);
140 void leaveCharacter(const Common::String &name, const Common::String &regionName, int dir);
141 void removeScreenObject(const Common::String &name);
142
143public:
144 Process(AGDSEngine *engine, const ObjectPtr &object, unsigned ip, int version, Common::Language language);
145 unsigned entryPoint() const {
146 return _entryPoint;
147 }
148
149 static Common::String disassemble(const ObjectPtr &object, int version);
150
151 ObjectPtr getObject() const {
152 return _object;
153 }
154
155 const Common::String &getName() const {
156 return _object->getName();
157 }
158
159 const Common::String &parentScreenName() const {
160 return _parentScreen;
161 }
162
163 Status status() const {
164 return _status;
165 }
166
167 bool active() const {
168 return _status == kStatusActive;
169 }
170 bool passive() const {
171 return _status == kStatusPassive;
172 }
173 void activate();
174 void deactivate();
175 void done();
176 void fail();
177
178 bool finished() const {
179 return _status == kStatusDone || _status == kStatusError;
180 }
181
182 void run();
183
184 ProcessExitCode getExitCode() const {
185 return _exitCode;
186 }
187
188 const Common::String &getExitArg1() const {
189 return _exitArg1;
190 }
191
192 int getExitIntArg1() const {
193 return _exitIntArg1;
194 }
195
196 const Common::String &getExitArg2() const {
197 return _exitArg2;
198 }
199
200 int getExitIntArg2() const {
201 return _exitIntArg2;
202 }
203
204 void setMousePosition(Common::Point mousePosition) {
205 _mousePosition = mousePosition;
206 }
207 void updateWithCurrentMousePosition();
208
209 const Common::String &phaseVar() const {
210 return _phaseVar;
211 }
212
213 const AnimationPtr &processAnimation() const {
214 return _processAnimation;
215 }
216
217 void removeProcessAnimation();
218};
219
220} // End of namespace AGDS
221
222#endif /* AGDS_PROCESS_H */
Definition: agds.h:82
Definition: process.h:40
Definition: str.h:59
Language
Definition: language.h:45
Definition: rect.h:144
Definition: atari-screen.h:58