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