ScummVM API documentation
scriptresource.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 ILLUSIONS_SCRIPTRESOURCE_H
23 #define ILLUSIONS_SCRIPTRESOURCE_H
24 
25 #include "illusions/resourcesystem.h"
26 #include "common/file.h"
27 
28 namespace Illusions {
29 
30 class IllusionsEngine;
31 
33 public:
34  ScriptResourceLoader(IllusionsEngine *vm) : _vm(vm) {}
35  ~ScriptResourceLoader() override {}
36  void load(Resource *resource) override;
37  bool isFlag(int flag) override;
38 protected:
39  IllusionsEngine *_vm;
40 };
41 
42 class Properties {
43 public:
44  Properties();
45  void init(uint count, byte *properties);
46  void clear();
47  bool get(uint32 propertyId);
48  void set(uint32 propertyId, bool value);
49  uint32 getSize();
50  void writeToStream(Common::WriteStream *out);
51  bool readFromStream(Common::ReadStream *in);
52 public:
53  uint _count;
54  byte *_properties;
55  void getProperyPos(uint32 propertyId, uint &index, byte &mask);
56 };
57 
59 public:
60  BlockCounters();
61  void init(uint count, byte *blockCounters);
62  void clear();
63  byte get(uint index);
64  void set(uint index, byte value);
65  byte getC0(uint index);
66  void setC0(uint index, byte value);
67  uint32 getSize();
68  void writeToStream(Common::WriteStream *out);
69  bool readFromStream(Common::ReadStream *in);
70 public:
71  uint _count;
72  byte *_blockCounters;
73 };
74 
75 struct TriggerCause {
76  uint32 _verbId;
77  uint32 _objectId2;
78  uint32 _codeOffs;
79  void load(Common::SeekableReadStream &stream);
80 };
81 
83 public:
84  TriggerObject();
85  ~TriggerObject();
86  void load(byte *dataStart, Common::SeekableReadStream &stream);
87  bool findTriggerCause(uint32 verbId, uint32 objectId2, uint32 &codeOffs);
88  void fixupSceneInfosDuckman();
89 public:
90  uint32 _objectId;
91  uint _causesCount;
92  TriggerCause *_causes;
93 };
94 
95 class SceneInfo {
96 public:
97  SceneInfo();
98  ~SceneInfo();
99  void load(byte *dataStart, Common::SeekableReadStream &stream);
100  bool findTriggerCause(uint32 verbId, uint32 objectId2, uint32 objectId, uint32 &codeOffs);
101  void getResources(uint &resourcesCount, uint32 *&resources);
102  void fixupSceneInfosDuckman();
103 protected:
104  uint16 _id;
105  uint16 _unk;
106  uint16 *_name;
107  uint _triggerObjectsCount;
108  TriggerObject *_triggerObjects;
109  uint _resourcesCount;
110  uint32 *_resources;
111  TriggerObject *findTriggerObject(uint32 objectId);
112 };
113 
115 public:
116  ScriptResource();
117  ~ScriptResource();
118  void load(Resource *resource);
119  byte *getThreadCode(uint32 threadId);
120  byte *getCode(uint32 codeOffs);
121  SceneInfo *getSceneInfo(uint32 index);
122  uint32 getObjectActorTypeId(uint32 objectId);
123  uint32 getMainActorObjectId() const { return _mainActorObjectId; }
124 public:
125  byte *_data;
126  uint32 _dataSize;
127  Properties _properties;
128  BlockCounters _blockCounters;
129  uint _codeCount;
130  uint32 *_codeOffsets;
131  uint _sceneInfosCount;
132  SceneInfo *_sceneInfos;
133  // Duckman specific
134  uint32 _soundIds[27];
135  uint _objectMapCount;
136  uint32 *_objectMap;
137  uint32 _mainActorObjectId;
138  void fixupSceneInfosDuckman();
139 };
140 
142 public:
144  void load(Resource *resource) override;
145  void unload() override;
146 public:
147  IllusionsEngine *_vm;
148 };
149 
150 } // End of namespace Illusions
151 
152 #endif // ILLUSIONS_ACTORRESOURCE_H
Definition: scriptresource.h:58
Definition: stream.h:77
Definition: actor.h:34
Definition: stream.h:745
Definition: resourcesystem.h:51
Definition: scriptresource.h:95
Definition: scriptresource.h:141
Definition: scriptresource.h:75
Definition: resourcesystem.h:42
Definition: scriptresource.h:32
Definition: resourcesystem.h:78
Definition: stream.h:385
Definition: scriptresource.h:114
Definition: scriptresource.h:42
Definition: scriptresource.h:82
Definition: illusions.h:80