ScummVM API documentation
parallaction.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 PARALLACTION_PARALLACTION_H
23 #define PARALLACTION_PARALLACTION_H
24 
25 #include "common/str.h"
26 #include "common/stack.h"
27 #include "common/array.h"
28 #include "common/func.h"
29 #include "common/random.h"
30 #include "common/savefile.h"
31 #include "common/textconsole.h"
32 
33 #include "engines/engine.h"
34 
35 #include "parallaction/input.h"
36 #include "parallaction/inventory.h"
37 #include "parallaction/objects.h"
38 #include "parallaction/disk.h"
39 #include "parallaction/detection.h"
40 
41 #define PATH_LEN 200
42 
43 
53 namespace Parallaction {
54 
55 enum {
56  kDebugDisk = 1 << 0,
57  kDebugWalk = 1 << 1,
58  kDebugParser = 1 << 2,
59  kDebugDialogue = 1 << 3,
60  kDebugGraphics = 1 << 4,
61  kDebugExec = 1 << 5,
62  kDebugInput = 1 << 6,
63  kDebugAudio = 1 << 7,
64  kDebugMenu = 1 << 8,
65  kDebugInventory = 1 << 9
66 };
67 
68 enum EngineFlags {
69  kEnginePauseJobs = (1 << 1),
70  kEngineWalking = (1 << 3),
71  kEngineChangeLocation = (1 << 4),
72  kEngineBlockInput = (1 << 5),
73  kEngineDragging = (1 << 6),
74  kEngineTransformedDonna = (1 << 7),
75 
76  // BRA specific
77  kEngineReturn = (1 << 10)
78 };
79 
80 enum {
81  kEvNone = 0,
82  kEvSaveGame = 2000,
83  kEvLoadGame = 4000,
84  kEvIngameMenu = 8000
85 };
86 
87 
88 
89 
90 
91 extern uint32 g_engineFlags;
92 extern char g_saveData1[];
93 extern uint32 g_globalFlags;
94 extern const char *g_dinoName;
95 extern const char *g_donnaName;
96 extern const char *g_doughName;
97 extern const char *g_drkiName;
98 extern const char *g_minidinoName;
99 extern const char *g_minidonnaName;
100 extern const char *g_minidoughName;
101 extern const char *g_minidrkiName;
102 
103 
104 
105 
106 
107 
108 class Debugger;
109 class Gfx;
110 class Input;
111 class DialogueManager;
112 class MenuInputHelper;
113 class PathWalker_NS;
114 class PathWalker_BR;
115 class CommandExec;
116 class ProgramExec;
117 class SoundMan;
118 class SoundMan_ns;
119 class SoundMan_br;
120 class LocationParser_ns;
121 class LocationParser_br;
122 class ProgramParser_ns;
123 class ProgramParser_br;
124 class BalloonManager;
125 
126 struct Location {
127 
128  Common::Point _startPosition;
129  uint16 _startFrame;
130  char _name[100];
131 
132  CommandList _aCommands;
133  CommandList _commands;
134  Common::String _comment;
135  Common::String _endComment;
136 
137  ZoneList _zones;
138  AnimationList _animations;
139  ProgramList _programs;
140 
141  bool _hasSound;
142  char _soundFile[50];
143 
144  // NS specific
145  PointList _walkPoints;
146  Common::String _slideText[2];
147 
148  // BRA specific
149  int _zeta0;
150  int _zeta1;
151  int _zeta2;
152  CommandList _escapeCommands;
153  Common::Point _followerStartPosition;
154  uint16 _followerStartFrame;
155 
156 
157 protected:
158  int _gameType;
159 
160  bool keepZone_br(ZonePtr z);
161  bool keepZone_ns(ZonePtr z);
162  bool keepAnimation_ns(AnimationPtr a);
163  bool keepAnimation_br(AnimationPtr a);
164 
165  template<class T>
166  void freeList(Common::List<T> &list, bool removeAll, Common::MemFunc1<bool, T, Location> filter);
167 
168 public:
169  Location(int gameType);
170  ~Location();
171 
172  AnimationPtr findAnimation(const char *name);
173  ZonePtr findZone(const char *name);
174 
175  void cleanup(bool removeAll);
176  void freeZones(bool removeAll);
177 
178  int getScale(int z) const;
179 };
180 
181 
183  const char *_prefix;
184  const char *_suffix;
185  bool _dummy;
186  char _name[30];
187  char _baseName[30];
188  char _fullName[30];
189  static const char _prefixMini[];
190  static const char _suffixTras[];
191  static const char _empty[];
192  void dummify();
193 public:
194  CharacterName();
195  CharacterName(const char *name);
196  void bind(const char *name);
197  const char *getName() const;
198  const char *getBaseName() const;
199  const char *getFullName() const;
200  bool dummy() const;
201 };
202 
203 
204 struct Character {
205  AnimationPtr _ani;
206  GfxObj *_head;
207  GfxObj *_talk;
208 
209  Character();
210 
211 protected:
212  CharacterName _name;
213 
214 public:
215  void setName(const char *name);
216  const char *getName() const;
217  const char *getBaseName() const;
218  const char *getFullName() const;
219  bool dummy() const;
220 };
221 
222 
223 class SaveLoad;
224 
225 #define NUM_LOCATIONS 120
226 
227 class Parallaction : public Engine {
228  friend class Debugger;
229 
230 public:
231  int getGameType() const;
232  uint32 getFeatures() const;
233  Common::Language getLanguage() const;
234  Common::Platform getPlatform() const;
235 
236 protected: // members
237  bool detectGame();
238 
239 private:
240  const PARALLACTIONGameDescription *_gameDescription;
241  uint16 _language;
242 
243 public:
244  Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gameDesc);
245  ~Parallaction() override;
246 
247  // Engine APIs
248  virtual Common::Error init();
249  virtual Common::Error go() = 0;
250  Common::Error run() override {
251  Common::Error err;
252  err = init();
253  if (err.getCode() != Common::kNoError)
254  return err;
255  return go();
256  }
257 
258  bool hasFeature(EngineFeature f) const override;
259  void pauseEngineIntern(bool pause) override;
260 
261  // info
262  int32 _screenWidth;
263  int32 _screenHeight;
264  int32 _screenSize;
265  int _gameType;
266 
267  // subsystems
268  Gfx *_gfx;
269  Disk *_disk;
270  Input *_input;
271  SaveLoad *_saveLoad;
272  MenuInputHelper *_menuHelper;
274  SoundMan *_soundMan;
275 
276  // fonts
277  Font *_labelFont;
278  Font *_menuFont;
279  Font *_introFont;
280  Font *_dialogueFont;
281 
282  // game utilities
283  Table *_globalFlagsNames;
284  Table *_objectsNames;
285  GfxObj *_objects;
286  Table *_callableNames;
287  Table *_localFlagNames;
288  CommandExec *_cmdExec;
289  ProgramExec *_programExec;
290  BalloonManager *_balloonMan;
291  DialogueManager *_dialogueMan;
292  InventoryRenderer *_inventoryRenderer;
293  Inventory *_inventory; // inventory for the current character
294 
295  // game data
296  Character _char;
297  uint32 _localFlags[NUM_LOCATIONS];
298  char _locationNames[NUM_LOCATIONS][32];
299  int16 _currentLocationIndex;
300  uint16 _numLocations;
301  Location _location;
302  ZonePtr _activeZone;
303  char _characterName1[50]; // only used in changeCharacter
304  ZonePtr _zoneTrap;
305  ZonePtr _commentZone;
306  Common::String _newLocationName;
307 
308 protected:
309  void runGame();
310  void runGameFrame(int event);
311  void runGuiFrame();
312  void cleanupGui();
313  void runDialogueFrame();
314  void exitDialogueMode();
315  void runCommentFrame();
316  void enterCommentMode(ZonePtr z);
317  void exitCommentMode();
318  void updateView();
319  void drawAnimation(AnimationPtr anim);
320  void drawZone(ZonePtr zone);
321  void updateZones();
322  void doLocationEnterTransition();
323  void allocateLocationSlot(const char *name);
324  void finalizeLocationParsing();
325  void showLocationComment(const Common::String &text, bool end);
326  void destroyDialogueManager();
327 
328 public:
329  void beep();
330  void pauseJobs();
331  void resumeJobs();
332  uint getInternLanguage();
333  void setInternLanguage(uint id);
334  void enterDialogueMode(ZonePtr z);
335  void scheduleLocationSwitch(const char *location);
336  void showSlide(const char *name, int x = 0, int y = 0);
337 
338 public:
339  void setLocationFlags(uint32 flags);
340  void clearLocationFlags(uint32 flags);
341  void toggleLocationFlags(uint32 flags);
342  uint32 getLocationFlags();
343  bool checkSpecialZoneBox(ZonePtr z, uint32 type, uint x, uint y);
344  bool checkZoneBox(ZonePtr z, uint32 type, uint x, uint y);
345  bool checkZoneType(ZonePtr z, uint32 type);
346  bool checkLinkedAnimBox(ZonePtr z, uint32 type, uint x, uint y);
347  ZonePtr hitZone(uint32 type, uint16 x, uint16 y);
348  void runZone(ZonePtr z);
349  bool pickupItem(ZonePtr z);
350  void updateDoor(ZonePtr z, bool close);
351  void showZone(ZonePtr z, bool visible);
352  void highlightInventoryItem(ItemPosition pos);
353  int16 getHoverInventoryItem(int16 x, int16 y);
354  int addInventoryItem(ItemName item);
355  int addInventoryItem(ItemName item, uint32 value);
356  void dropItem(uint16 v);
357  bool isItemInInventory(int32 v);
358  const InventoryItem* getInventoryItem(int16 pos);
359  int16 getInventoryItemIndex(int16 pos);
360  void openInventory();
361  void closeInventory();
362 
363  virtual void parseLocation(const char* name) = 0;
364  virtual void changeLocation() = 0;
365  virtual void changeCharacter(const char *name) = 0;
366  virtual void callFunction(uint index, void* parm) = 0;
367  virtual void runPendingZones() = 0;
368  virtual void cleanupGame() = 0;
369  virtual void updateWalkers() = 0;
370  virtual void scheduleWalk(int16 x, int16 y, bool fromUser) = 0;
371  virtual DialogueManager *createDialogueManager(ZonePtr z) = 0;
372  virtual bool processGameEvent(int event) = 0;
373 };
374 
375 
376 
378 
379 public:
380  Parallaction_ns(OSystem* syst, const PARALLACTIONGameDescription *gameDesc);
381  ~Parallaction_ns() override;
382 
383  // Engine APIs
384  Common::Error init() override;
385  Common::Error go() override;
386 
387  SoundMan_ns* _soundManI;
388 
389  uint16 _score;
390  Common::String _password;
391 
392 
393 public:
394  void parseLocation(const char *filename) override;
395  void changeLocation() override;
396  void changeCharacter(const char *name) override;
397  void callFunction(uint index, void* parm) override;
398  void runPendingZones() override;
399  void cleanupGame() override;
400  void updateWalkers() override;
401  void scheduleWalk(int16 x, int16 y, bool fromUser) override;
402  DialogueManager *createDialogueManager(ZonePtr z) override;
403  bool processGameEvent(int event) override;
404  void cleanInventory(bool keepVerbs);
405  void changeBackground(const char *background, const char *mask = 0, const char *path = 0);
406 
407 private:
408  bool _inTestResult;
409  LocationParser_ns *_locationParser;
410  ProgramParser_ns *_programParser;
411 
412 private:
413  void initFonts();
414  void freeFonts();
415  void initResources();
416  void initInventory();
417  void destroyInventory();
418  void setupBalloonManager();
419  void startGui();
420  void startCreditSequence();
421  void startEndPartSequence();
422  void loadProgram(AnimationPtr a, const char *filename);
423  void freeLocation(bool removeAll);
424  void freeCharacter();
425  void destroyTestResultLabels();
426  void startMovingSarcophagus(ZonePtr sarc);
427  void stopMovingSarcophagus();
428 
429 
430  // callables data
431  typedef void (Parallaction_ns::*Callable)(void *);
432  const Callable *_callables;
433  ZonePtr _moveSarcGetZone;
434  ZonePtr _moveSarcExaZone;
435  ZonePtr _moveSarcGetZones[5];
436  ZonePtr _moveSarcExaZones[5];
437  uint16 num_foglie;
438 
439  int16 _sarcophagusDeltaX;
440  bool _movingSarcophagus; // sarcophagus stuff to be saved
441  uint16 _freeSarcophagusSlotX; // sarcophagus stuff to be saved
442  AnimationPtr _rightHandAnim;
443  bool _intro;
444  static const Callable _dosCallables[25];
445  static const Callable _amigaCallables[25];
446 
447  GfxObj *_testResultLabels[2];
448 
449  PathWalker_NS *_walker;
450 
451  // common callables
452  void _c_play_boogie(void *);
453  void _c_startIntro(void *);
454  void _c_endIntro(void *);
455  void _c_moveSheet(void *);
456  void _c_sketch(void *);
457  void _c_shade(void *);
458  void _c_score(void *);
459  void _c_fade(void *);
460  void _c_moveSarc(void *);
461  void _c_contaFoglie(void *);
462  void _c_zeroFoglie(void *);
463  void _c_trasformata(void *);
464  void _c_offMouse(void *);
465  void _c_onMouse(void *);
466  void _c_setMask(void *);
467  void _c_endComment(void *);
468  void _c_frankenstein(void *);
469  void _c_finito(void *);
470  void _c_ridux(void *);
471  void _c_testResult(void *);
472 
473  // dos specific callables
474  void _c_null(void *);
475 
476  // amiga specific callables
477  void _c_projector(void *);
478  void _c_HBOff(void *);
479  void _c_offSound(void *);
480  void _c_startMusic(void *);
481  void _c_closeMusic(void *);
482  void _c_HBOn(void *);
483 };
484 
485 
486 
487 #define NUM_ZONES 100
488 
490 
491 public:
492  Parallaction_br(OSystem* syst, const PARALLACTIONGameDescription *gameDesc);
493  ~Parallaction_br() override;
494 
495  Common::Error init() override;
496  Common::Error go() override;
497 
498 public:
499  void parseLocation(const char* name) override;
500  void changeLocation() override;
501  void changeCharacter(const char *name) override;
502  void callFunction(uint index, void* parm) override;
503  void runPendingZones() override;
504  void cleanupGame() override;
505  void updateWalkers() override;
506  void scheduleWalk(int16 x, int16 y, bool fromUser) override;
507  DialogueManager *createDialogueManager(ZonePtr z) override;
508  bool processGameEvent(int event) override;
509 
510  void setupSubtitles(const char *s, const char *s2, int y);
511  void clearSubtitles();
512 
513  Inventory *findInventory(const char *name);
514  void linkUnlinkedZoneAnimations();
515 
516  void testCounterCondition(const Common::String &name, int op, int value);
517  void restoreOrSaveZoneFlags(ZonePtr z, bool restore);
518 
519 public:
520  bool counterExists(const Common::String &name);
521  int getCounterValue(const Common::String &name);
522  void setCounterValue(const Common::String &name, int value);
523 
524  void setFollower(const Common::String &name);
525 
526  int getSfxStatus();
527  int getMusicStatus();
528  void enableSfx(bool enable);
529  void enableMusic(bool enable);
530 
531  const char **_audioCommandsNamesRes;
532  static const char *_partNames[];
533  int _part;
534  int _nextPart;
535 
536 
537 #if 0 // disabled since I couldn't find any references to lip sync in the scripts
538  int16 _lipSyncVal;
539  uint _subtitleLipSync;
540 #endif
541  int _subtitleY;
542  GfxObj *_subtitle[2];
543  ZonePtr _activeZone2;
544  uint32 _zoneFlags[NUM_LOCATIONS][NUM_ZONES];
545 
546 private:
547  LocationParser_br *_locationParser;
548  ProgramParser_br *_programParser;
549  SoundMan_br *_soundManI;
550  Inventory *_dinoInventory;
551  Inventory *_donnaInventory;
552  Inventory *_dougInventory;
553 
554  int32 _counters[32];
555  Table *_countersNames;
556 
557 private:
558  void initResources();
559  void initInventory();
560  void destroyInventory();
561 
562  void cleanInventory(bool keepVerbs);
563  void setupBalloonManager();
564  void initFonts();
565  void freeFonts();
566  void freeLocation(bool removeAll);
567  void loadProgram(AnimationPtr a, const char *filename);
568  void startGui(bool showSplash);
569  void startIngameMenu();
570  void freeCharacter();
571 
572  typedef void (Parallaction_br::*Callable)(void *);
573  const Callable *_callables;
574  static const Callable _dosCallables[6];
575  static const Callable _amigaCallables[6];
576 
577  Common::String _followerName;
578  AnimationPtr _follower;
579  PathWalker_BR *_walker;
580  int _ferrcycleMode;
581 
582  // dos callables
583  void _c_null(void *);
584  void _c_blufade(void *);
585  void _c_resetpalette(void *);
586  void _c_ferrcycle(void *);
587  void _c_lipsinc(void *);
588  void _c_albcycle(void *);
589  void _c_password(void *);
590 };
591 
592 extern Parallaction *g_vm;
593 
594 
595 } // End of namespace Parallaction
596 
597 
598 #endif
Definition: inventory.h:84
Definition: str.h:59
EngineFeature
Definition: engine.h:253
Definition: error.h:84
Definition: exec.h:86
ErrorCode getCode() const
Definition: error.h:115
Definition: walk.h:34
Definition: sound.h:92
Definition: random.h:44
Definition: graphics.h:431
No error occurred.
Definition: error.h:48
Definition: parallaction.h:182
Definition: inventory.h:32
Definition: parallaction.h:377
Definition: gui.h:37
Definition: disk.h:56
Definition: sound.h:183
Definition: debug.h:8
Definition: input.h:46
Definition: inventory.h:56
Definition: sound.h:52
Common::Error run() override
Definition: parallaction.h:250
Definition: func.h:195
Definition: rect.h:45
Definition: walk.h:60
Definition: parser.h:96
Definition: exec.h:191
Definition: saveload.h:29
Definition: graphics.h:53
Definition: system.h:161
Definition: parser.h:387
Definition: parser.h:247
Definition: graphics.h:409
Definition: parallaction.h:126
Definition: parser.h:321
Definition: engine.h:144
Definition: parallaction.h:489
Definition: debug.h:12
Definition: graphics.h:300
Definition: parallaction.h:204
Platform
Definition: platform.h:46
Language
Definition: language.h:45
Definition: objects.h:509