ScummVM API documentation
actors.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  * Prototypes of actor functions
21  */
22 
23 #ifndef TINSEL_ACTOR_H // prevent multiple includes
24 #define TINSEL_ACTOR_H
25 
26 
27 #include "tinsel/dw.h" // for SCNHANDLE
28 #include "tinsel/events.h" // for TINSEL_EVENT
29 #include "tinsel/palette.h" // for COLORREF
30 #include "tinsel/movers.h" // for MOVER *
31 
32 namespace Common {
33 class Serializer;
34 }
35 
36 namespace Tinsel {
37 
38 struct FREEL;
39 struct INT_CONTEXT;
40 struct MOVER;
41 struct OBJECT;
42 struct ACTORINFO;
43 struct Z_POSITIONS;
44 
45 #define ACTORTAG_KEY 0x1000000
46 #define OTH_RELATEDACTOR 0x00000fff
47 #define OTH_RELATIVE 0x00001000
48 #define OTH_ABSOLUTE 0x00002000
49 #define MAX_TAGACTORS 10
50 #define NUM_ZPOSITIONS 200 // Reasonable-sounding number
51 #define MAX_REELS 6
52 
53 struct TAGACTORDATA {
54  // Copies of compiled data
55  int id;
56  SCNHANDLE hTagText; // handle to tag text
57  int32 tagPortionV; // which portion is active
58  int32 tagPortionH; // which portion is active
59  SCNHANDLE hActorCode; // The actor's script
60 
61  int tagFlags;
62  SCNHANDLE hOverrideTag; // Override tag.
63 };
64 
65 struct SAVED_ACTOR {
66  short actorID;
67  short zFactor;
68  bool bAlive;
69  bool bHidden;
71  short presRnum;
72  short presPlayX, presPlayY;
73 };
74 
75 struct Z_POSITIONS {
76  short actor;
77  short column;
78  int z;
79 };
80 
81 struct ACTORDATA {
82  int32 masking;
85  SCNHANDLE hTagText; // tag (Tinsel V2)
86  int32 tagPortionV; // defines tag area (Tinsel V2)
87  int32 tagPortionH; // defines tag area (Tinsel V2)
88 };
89 
90 /*----------------------------------------------------------------------*/
91 
92 class Actor {
93 public:
94  Actor();
95  virtual ~Actor();
96 
97  int GetLeadId();
98  SCNHANDLE GetActorTagHandle(int ano);
99  void ToggleActor(int ano, bool show);
100  SCNHANDLE GetActorCode(int ano);
101  SCNHANDLE GetTaggedActorCode(int ano);
102  void RunCodeToCompletion(int ano);
103  int GetCount() { return _numActors; }
104 
105  void RegisterActors(int num);
106  void SetLeadId(int rid);
107  bool ActorIsGhost(int actor);
108  void StartTaggedActors(SCNHANDLE ah, int numActors, bool bRunScript);
109  void DropActors(); // No actor reels running
110 
111  void DisableActor(int actor);
112  void EnableActor(int actor);
113 
114  void Tag_Actor(int ano, SCNHANDLE tagtext, int tp);
115  void UnTagActor(int ano);
116  void ReTagActor(int ano);
117  int TagType(int ano);
118 
119  bool actorAlive(int ano);
120  int32 actorMaskType(int ano);
121  void GetActorPos(int ano, int *x, int *y);
122  void GetActorMidTop(int ano, int *x, int *y);
123  int GetActorLeft(int ano);
124  int GetActorRight(int ano);
125  int GetActorTop(int ano);
126  int GetActorBottom(int ano);
127  bool ActorHidden(int ano);
128  bool HideMovingActor(int id, int sf);
129  void unHideMovingActor(int id);
130  void restoreMovement(int id);
131  void storeActorReel(int ano, const FREEL *reel, SCNHANDLE hFilm, OBJECT *pobj, int reelnum, int x, int y);
132  const FREEL *actorReel(int ano);
133 
134  void SetActorPlayFilm(int ano, SCNHANDLE hFilm);
135  SCNHANDLE GetActorPlayFilm(int ano);
136  void SetActorTalkFilm(int ano, SCNHANDLE hFilm);
137  SCNHANDLE GetActorTalkFilm(int ano);
138 
139  void SetActorTalking(int ano, bool tf);
140  bool ActorIsTalking(int ano);
141  void SetActorLatestFilm(int ano, SCNHANDLE hFilm);
142  SCNHANDLE GetActorLatestFilm(int ano);
143 
144  void UpdateActorEsc(int ano, bool escOn, int escEvent);
145  void UpdateActorEsc(int ano, int escEvent);
146  bool ActorEsc(int ano);
147  int ActorEev(int ano);
148  void StoreActorPos(int ano, int x, int y);
149  void StoreActorSteps(int ano, int steps);
150  int GetActorSteps(int ano);
151 
152  void StoreActorZpos(int ano, int z, int column = -1);
153  int GetActorZpos(int ano, int column);
154  void IncLoopCount(int ano);
155  int GetLoopCount(int ano);
156  SCNHANDLE GetActorTag(int ano);
157  void FirstTaggedActor();
158  int NextTaggedActor();
159  int NextTaggedActor(int previous);
160  int AsetZPos(OBJECT *pObj, int y, int32 zFactor);
161 
162  void storeActorAttr(int ano, int r1, int g1, int b1);
163  COLORREF GetActorRGB(int ano);
164  void SetActorRGB(int ano, COLORREF color);
165  void SetActorZfactor(int ano, uint32 zFactor);
166  uint32 GetActorZfactor(int ano);
167  void SetActorsOn();
168  void ActorsLife(int id, bool bAlive);
169  void dwEndActor(int ano);
170 
171  void SetActorPointedTo(int actor, bool bPointedTo);
172  bool ActorIsPointedTo(int actor);
173  void SetActorTagWanted(int actor, bool bTagWanted, bool bCursor, SCNHANDLE hOverrideTag);
174  bool ActorTagIsWanted(int actor);
175  bool InHotSpot(int ano, int curX, int curY);
176  int FrontTaggedActor();
177  void GetActorTagPos(int actor, int *pTagX, int *pTagY, bool bAbsolute);
178  bool IsTaggedActor(int actor);
179 
180  void StoreActorPresFilm(int ano, SCNHANDLE hFilm, int x, int y);
181  SCNHANDLE GetActorPresFilm(int ano);
182  int GetActorFilmNumber(int ano);
183 
184  void StoreActorReel(int actor, int column, OBJECT *pObj);
185  void NotPlayingReel(int actor, int filmNumber, int column);
186  bool ActorReelPlaying(int actor, int column);
187 
188  int SaveActors(SAVED_ACTOR *sActorInfo);
189  void RestoreActors(int numActors, SAVED_ACTOR *sActorInfo);
190 
191  void SaveZpositions(void *zpp);
192  void RestoreZpositions(void *zpp);
193 
194  void SaveActorZ(byte *saveActorZ);
195  void RestoreActorZ(byte *saveActorZ);
196 
197  int TaggedActorIndex(int actor);
198 
199  void syncAllActorsAlive(Common::Serializer &s);
200 
201 private:
202  void StartActor(const ACTORDATA *ad, bool bRunScript);
203  void GetActorTagPortion(int ano, unsigned *top, unsigned *bottom, unsigned *left, unsigned *right);
204 
205  ACTORINFO *_actorInfo;
206  COLORREF _defaultColor; // Text color
207  bool _actorsOn;
208  int ti;
209  TAGACTORDATA _taggedActors[MAX_TAGACTORS];
210  int _numTaggedActors;
211  uint8 *_zFactors;
212  Z_POSITIONS _zPositions[NUM_ZPOSITIONS];
213  int _leadActorId; // The lead actor
214  int _numActors; // The total number of actors in the game
215 };
216 
217 /*----------------------------------------------------------------------*/
218 
219 void ActorEvent(int ano, TINSEL_EVENT event, PLR_EVENT be);
220 void ActorEvent(CORO_PARAM, int ano, TINSEL_EVENT tEvent, bool bWait, int myEscape, bool *result = NULL);
221 void ActorEvent(int ano, TINSEL_EVENT tEvent, bool bWait, int myEscape, bool *result = NULL);
222 void ShowActor(CORO_PARAM, int ano);
223 void HideActor(CORO_PARAM, int ano);
224 void RestoreActorProcess(int id, INT_CONTEXT *pic, bool savegameFlag);
225 
226 } // End of namespace Tinsel
227 
228 #endif /* TINSEL_ACTOR_H */
SCNHANDLE hActorId
handle actor ID string index
Definition: actors.h:83
uint32 SCNHANDLE
Definition: dw.h:31
int32 masking
type of actor masking (Tinsel V1)
Definition: actors.h:82
SCNHANDLE hActorCode
handle to actor script
Definition: actors.h:84
Definition: actors.h:53
Definition: actors.h:81
Definition: actors.h:92
Definition: actors.h:75
Definition: serializer.h:79
Definition: movers.h:50
TINSEL_EVENT
Definition: events.h:91
SCNHANDLE presFilm
the film that reel belongs to
Definition: actors.h:70
Definition: actors.h:65
Definition: object.h:73
#define CORO_PARAM
Definition: coroutines.h:107
Definition: algorithm.h:29
Definition: actors.h:36
Definition: film.h:32
Definition: pcode.h:54
short presRnum
the present reel number
Definition: actors.h:71