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  bool _v2;
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 
94  int32 pop();
95  int32 top();
96 
97  Common::String getString(int id);
98  Common::String popString() {
99  return getString(pop());
100  }
101  Common::String popText();
102  uint32 popColor();
103 
104 #define AGDS_PROCESS_METHOD(opcode, method) \
105  void method();
106 #define AGDS_PROCESS_METHOD_C(opcode, method) \
107  void method(int8);
108 #define AGDS_PROCESS_METHOD_B(opcode, method) \
109  void method(uint8);
110 #define AGDS_PROCESS_METHOD_W(opcode, method) \
111  void method(int16);
112 #define AGDS_PROCESS_METHOD_U(opcode, method) \
113  void method(uint16);
114 #define AGDS_PROCESS_METHOD_UD(opcode, method) \
115  void method(int32);
116 #define AGDS_PROCESS_METHOD_UU(opcode, method) \
117  void method(uint16, uint16);
118 
119  AGDS_OPCODE_LIST(AGDS_PROCESS_METHOD,
120  AGDS_PROCESS_METHOD_C, AGDS_PROCESS_METHOD_B, AGDS_PROCESS_METHOD_W,
121  AGDS_PROCESS_METHOD_U, AGDS_PROCESS_METHOD_UD, AGDS_PROCESS_METHOD_UU)
122 
123  void moveCharacter(bool usermove);
124  void tell(bool npc, const Common::String &sound);
125  void tell(bool npc) { tell(npc, Common::String()); }
126 
127  Common::String getCloneVarName(const Common::String &arg1, const Common::String &arg2);
128 
129  void suspend(ProcessExitCode exitCode, const Common::String &arg1, const Common::String &arg2 = Common::String());
130  void suspend(ProcessExitCode exitCode, int arg1 = 0, int arg2 = 0);
131 
132  ProcessExitCode resume();
133  void suspendIfPassive();
134 
135  void setupAnimation(const AnimationPtr &animation);
136  void attachInventoryObjectToMouse(bool flag);
137  void leaveCharacter(const Common::String &name, const Common::String &regionName, int dir);
138  void removeScreenObject(const Common::String &name);
139 
140 public:
141  Process(AGDSEngine *engine, const ObjectPtr &object, unsigned ip, bool v2);
142  unsigned entryPoint() const {
143  return _entryPoint;
144  }
145 
146  static Common::String disassemble(const ObjectPtr &object, bool v2);
147 
148  ObjectPtr getObject() const {
149  return _object;
150  }
151 
152  const Common::String &getName() const {
153  return _object->getName();
154  }
155 
156  const Common::String &parentScreenName() const {
157  return _parentScreen;
158  }
159 
160  Status status() const {
161  return _status;
162  }
163 
164  bool active() const {
165  return _status == kStatusActive;
166  }
167  bool passive() const {
168  return _status == kStatusPassive;
169  }
170  void activate();
171  void deactivate();
172  void done();
173  void fail();
174 
175  bool finished() const {
176  return _status == kStatusDone || _status == kStatusError;
177  }
178 
179  void run();
180 
181  ProcessExitCode getExitCode() const {
182  return _exitCode;
183  }
184 
185  const Common::String &getExitArg1() const {
186  return _exitArg1;
187  }
188 
189  int getExitIntArg1() const {
190  return _exitIntArg1;
191  }
192 
193  const Common::String &getExitArg2() const {
194  return _exitArg2;
195  }
196 
197  int getExitIntArg2() const {
198  return _exitIntArg2;
199  }
200 
201  void setMousePosition(Common::Point mousePosition) {
202  _mousePosition = mousePosition;
203  }
204  void updateWithCurrentMousePosition();
205 
206  const Common::String &phaseVar() const {
207  return _phaseVar;
208  }
209 
210  const AnimationPtr &processAnimation() const {
211  return _processAnimation;
212  }
213 
214  void removeProcessAnimation();
215 };
216 
217 } // End of namespace AGDS
218 
219 #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