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