ScummVM API documentation
uc_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 #ifndef ULTIMA8_USECODE_UCPROCESS_H
22 #define ULTIMA8_USECODE_UCPROCESS_H
23 
24 #include "ultima/shared/std/containers.h"
25 #include "ultima/ultima8/kernel/process.h"
26 #include "ultima/ultima8/usecode/uc_stack.h"
27 
28 namespace Ultima {
29 namespace Ultima8 {
30 
31 class Usecode;
32 
33 // probably won't inherit from Process directly in the future
34 class UCProcess : public Process {
35  friend class UCMachine;
36  friend class Kernel;
37 public:
38  UCProcess();
39  UCProcess(uint16 classid, uint16 offset, uint32 this_ptr = 0,
40  int thissize = 0, const uint8 *args = 0, int argsize = 0);
41  ~UCProcess() override;
42 
43  ENABLE_RUNTIME_CLASSTYPE()
44 
45  void run() override;
46 
47  void terminate() override;
48 
49  void freeOnTerminate(uint16 index, int type);
50 
51  void setReturnValue(uint32 retval) {
52  _temp32 = retval;
53  }
54 
55  uint16 getClassId() const {
56  return _classId;
57  }
58 
59  Common::String dumpInfo() const override;
60 
61  bool loadData(Common::ReadStream *rs, uint32 version);
62  void saveData(Common::WriteStream *ws) override;
63 
64 protected:
65  void load(uint16 classid, uint16 offset, uint32 this_ptr = 0,
66  int thissize = 0, const uint8 *args = 0, int argsize = 0);
67  void call(uint16 classid, uint16 offset);
68  bool ret();
69 
70  // stack base pointer
71  uint16 _bp;
72 
73  Usecode *_usecode;
74 
75  uint16 _classId;
76  uint16 _ip;
77 
78  uint32 _temp32;
79 
80  // data stack
81  UCStack _stack;
82 
83  // "Free Me" list
84  Std::list<Common::Pair<uint16, int> > _freeOnTerminate;
85 };
86 
87 } // End of namespace Ultima8
88 } // End of namespace Ultima
89 
90 #endif
Definition: uc_process.h:34
Definition: str.h:59
Definition: stream.h:77
Definition: uc_stack.h:177
Definition: process.h:34
Common::String dumpInfo() const override
dump some info about this process to a string
Definition: detection.h:27
Definition: uc_machine.h:41
Definition: usecode.h:32
void terminate() override
terminate the process. This wakes up all processes waiting for it.
Definition: kernel.h:41
Definition: containers.h:200
Definition: stream.h:385
void saveData(Common::WriteStream *ws) override
save Process data