ScummVM API documentation
tucker.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 TUCKER_TUCKER_H
23 #define TUCKER_TUCKER_H
24 
25 #include "common/file.h"
26 #include "common/util.h"
27 #include "common/endian.h"
28 #include "common/events.h"
29 #include "common/random.h"
30 #include "common/savefile.h"
31 #include "common/stream.h"
32 
33 #include "video/flic_decoder.h"
34 
35 #include "audio/mixer.h"
36 
37 #include "engines/engine.h"
38 
39 #include "tucker/console.h"
40 #include "tucker/detection.h"
41 
42 namespace Audio {
43 class RewindableAudioStream;
44 } // End of namespace Audio
45 
54 namespace Tucker {
55 
56 enum TUCKERAction {
57  kActionNone,
58  kActionSkipSpeech,
59  kActionFastMode,
60  kActionPause,
61  kActionTogglePanelStyle,
62  kActionToggleTextSpeech,
63  kActionHelp,
64  kActionEscape
65 };
66 
67 enum CursorStyle {
68  kCursorNormal = 0,
69  kCursorTalk = 1,
70  kCursorArrowRight = 2,
71  kCursorArrowUp = 3,
72  kCursorArrowLeft = 4,
73  kCursorArrowDown = 5,
74  kCursorMap = 6
75 };
76 
77 enum CursorState {
78  kCursorStateNormal = 0,
79  kCursorStateDialog = 1,
80  kCursorStateDisabledHidden = 2
81 };
82 
83 enum PanelState {
84  kPanelStateNormal = 0,
85  kPanelStateShrinking = 1,
86  kPanelStateExpanding = 2
87 };
88 
89 enum PanelStyle {
90  kPanelStyleVerbs = 0,
91  kPanelStyleIcons = 1
92 };
93 
94 enum PanelType {
95  kPanelTypeNormal = 0,
96  kPanelTypeEmpty = 1,
97  kPanelTypeLoadSavePlayQuit = 2,
98  kPanelTypeLoadSaveSavegame = 3
99 };
100 
101 enum Verb {
102  kVerbWalk = 0,
103  kVerbLook = 1,
104  kVerbTalk = 2,
105  kVerbOpen = 3,
106  kVerbClose = 4,
107  kVerbGive = 5,
108  kVerbTake = 6,
109  kVerbMove = 7,
110  kVerbUse = 8,
111 
112  kVerbFirst = kVerbWalk,
113  kVerbLast = kVerbUse
114 };
115 
116 enum VerbPreposition {
117  kVerbPrepositionNone = 0,
118 
119  kVerbPrepositionWith = 11,
120  kVerbPrepositionTo = 12
121 };
122 
123 enum Part {
124  kPartInit = 0,
125  kPartOne = 1,
126  kPartTwo = 2,
127  kPartThree = 3
128 };
129 
130 enum Location {
131  kLocationNone = 0,
132 
133  kLocationHotelRoom = 1,
134  kLocationBackAlley = 2,
135  kLocationSeedyStreet = 3,
136  kLocationBakersShop = 4,
137  kLocationBakersKitchen = 5,
138  kLocationStripJoint = 6,
139  kLocationPoliceHQ = 7,
140  kLocationPoliceCell = 8,
141  kLocationMall = 9,
142  kLocationFishShop = 10,
143  kLocationBurgerJoint = 11,
144  kLocationRecordShop = 12,
145  kLocationDentist = 13,
146  kLocationPlugShop = 14,
147  kLocationTouristInfo = 15,
148  kLocationPark = 16,
149  kLocationRoystonsHomeHallway = 17,
150  kLocationRoystonsHomeBoxroom = 18,
151  kLocationDocks = 19,
152  kLocationOutsideMuseum = 20,
153  kLocationInsideMuseum = 21,
154  kLocationFishingTrawler = 22,
155  kLocationWarehouseCutscene = 23,
156  kLocationStoreRoom = 24,
157  kLocationVentSystem = 25,
158  kLocationSubwayTunnel = 26,
159  kLocationStrangeRoom = 27,
160  kLocationTopCorridor = 28,
161  kLocationSubmarineHangar = 29,
162  kLocationBunkRoom = 30,
163  kLocationBottomCorridor = 31,
164  kLocationKitchen = 32,
165  kLocationCommandCentre = 33,
166  kLocationSubmarineHatch = 34,
167  kLocationSubmarineWalkway = 35,
168  kLocationSubmarineBridge = 36,
169  kLocationSubmarineOffice = 37,
170  kLocationSubmarineEngineRoom = 38,
171  kLocationLuxuryApartment = 39,
172  kLocationFarDocks = 40,
173  kLocationAlleyway = 41,
174  kLocationBasement = 42,
175  kLocationTateTowerEntrance = 43,
176  kLocationRooftop = 44,
177  kLocationConferenceRoom = 45,
178  kLocationAnteChamber = 46,
179  kLocationHelipad = 47,
180  kLocationCorridor = 48,
181  kLocationWaitingRoom = 49,
182  kLocationkLocationCorridorCutscene = 50,
183  kLocationCells = 51,
184  kLocationMachineRoom = 52,
185  kLocationRecordShopPartThree = 53,
186  kLocationPlugShopPartThree = 54,
187  kLocationTouristInfoPartThree = 55,
188  kLocationDentistPartThree = 56,
189  kLocationFishShopPartThree = 57,
190  kLocationInsideMuseumPartThree = 58,
191  kLocationBakersShopPartThree = 59,
192  kLocationStripJointPartThree = 60,
193  kLocationParkPartThree = 61,
194  kLocationDocksPartThree = 62,
195  kLocationTV = 63,
196  kLocationSewer = 64,
197  kLocationSeedyStreetPartThree = 65,
198  kLocationMallPartThree = 66,
199  kLocationBurgerJointPartThree = 67,
200  kLocationOutsideMuseumPartThree = 68,
201  kLocation69Cutscene = 69,
202  kLocationComputerScreen = 70,
203  kLocationParkCutscene = 71,
204  kLocationSeedyStreetCutscene = 72,
205  kLocationJesusCutscene1 = 73,
206  kLocationCredits = 74,
207  kLocation75Cutscene = 75,
208  kLocationBeachCutscene = 76,
209  kLocationHospitalCutscene = 77,
210  kLocation78Cutscene = 78,
211  kLocationElvisCutscene = 79,
212  kLocationPyramidCutscene = 80,
213  kLocationCleopatraCutscene = 81,
214  kLocationJesusCutscene2 = 82,
215 
216  kLocationNewPart = 98,
217  kLocationMap = 99,
218 
219  kLocationInit = 1,
220  kLocationInitDemo = 9
221 };
222 
223 struct Action {
224  int _key;
225  int _testFlag1Num;
226  int _testFlag1Value;
227  int _testFlag2Num;
228  int _testFlag2Value;
229  int _speech;
230  int _flipX;
231  int _index;
232  int _delay;
233  int _setFlagNum;
234  int _setFlagValue;
235  int _fxNum;
236  int _fxDelay;
237 };
238 
239 struct Sprite {
240  int _state;
241  int _gfxBackgroundOffset;
242  int _updateDelay;
243  int _backgroundOffset;
244  int _stateIndex;
245  int _counter;
246  int _colorType;
247  int _animationFrame;
248  int _firstFrame;
249  uint8 *_animationData;
250  int _prevState;
251  int _defaultUpdateDelay;
252  int _xSource;
253  int _yMaxBackground;
254  bool _disabled;
255  bool _flipX;
256  bool _needUpdate;
257  bool _nextAnimationFrame;
258  bool _prevAnimationFrame;
259 };
260 
261 struct CharPos {
262  int _xPos;
263  int _yPos;
264  int _xSize;
265  int _ySize;
266  int _xWalkTo;
267  int _yWalkTo;
268  int _flagNum;
269  int _flagValue;
270  int _direction;
271  int _name;
272  int _description;
273 };
274 
275 struct SpriteFrame {
276  int _sourceOffset;
277  int _xOffset;
278  int _yOffset;
279  int _xSize;
280  int _ySize;
281 };
282 
284  int _numParts;
285  int _rotateFlag; // Useless variable
286  int _firstFrameIndex;
287 };
288 
289 struct Data {
290  int _sourceOffset;
291  int _xSize;
292  int _ySize;
293  int _xDest;
294  int _yDest;
295  int _index;
296 };
297 
299  int _graphicNum;
300  int _animInitCounter;
301  int _animCurrentCounter;
302  int _animLastCounter;
303  int _getFlag;
304  int _inventoryNum;
305  int _flagNum;
306  int _flagValue;
307  int _selectable;
308  int _standX;
309  int _standY;
310  bool _drawFlag;
311 };
312 
314  int _xPos;
315  int _yPos;
316  int _xSize;
317  int _ySize;
318  int _textNum;
319  Location _location;
320  int _toX;
321  int _toY;
322  int _toX2;
323  int _toY2;
324  int _toWalkX2;
325  int _toWalkY2;
326  int _standX;
327  int _standY;
328  CursorStyle _cursorStyle;
329 };
330 
332  int _startFxSpriteState;
333  int _startFxSpriteNum;
334  int _updateType;
335  int _stopFxSpriteState;
336  int _stopFxSpriteNum;
337  int _offset;
338  int _type;
339  int _volume;
340  int _flagValueStartFx;
341  int _flagValueStopFx;
342  int _flagNum;
343  int _num;
344 };
345 
347  int _flag;
348  int _offset;
349  int _volume;
350  int _num;
351 };
352 
353 enum {
354  kScreenWidth = 320,
355  kScreenHeight = 200,
356  kScreenPitch = 640,
357  kFadePaletteStep = 5,
358  kDefaultCharSpeechSoundCounter = 1,
359  kMaxSoundVolume = 127,
360  kLastSaveSlot = 99,
361  kAutoSaveSlot = kLastSaveSlot
362 };
363 
364 enum InputKey {
365  kInputKeyPause = 0,
366  kInputKeyEscape,
367  kInputKeyTogglePanelStyle,
368  kInputKeyToggleTextSpeech,
369  kInputKeyHelp,
370  kInputKeySkipSpeech,
371 
372  kInputKeyCount
373 };
374 
375 enum CompressedSoundType {
376  kSoundTypeFx,
377  kSoundTypeMusic,
378  kSoundTypeSpeech,
379  kSoundTypeIntro
380 };
381 
383 public:
384 
385  CompressedSound() : _compressedSoundType(-1), _compressedSoundFlags(0) {}
386 
387  void openFile();
388  void closeFile();
389  Audio::RewindableAudioStream *load(CompressedSoundType type, int num);
390 
391 private:
392 
393  int _compressedSoundType;
394  uint16 _compressedSoundFlags;
395  Common::File _fCompressedSound;
396 };
397 
398 inline int scaleMixerVolume(int volume, int max = 100) {
399  if (volume > max) {
400  // This happens for instance for Bud's line, "Is that the
401  // great mystery invention you had hidden away?" in the intro,
402  // which is played at volume 110 out of 100. This made it very
403  // hard to hear. I'm not sure if this was a bug in the original
404  // game, or if it had the ability to amplify sounds.
405  warning("scaleMixerVolume: Adjusting volume %d to %d", volume, max);
406  volume = max;
407  }
408  return volume * Audio::Mixer::kMaxChannelVolume / max;
409 }
410 
411 Common::String generateGameStateFileName(const char *target, int slot, bool prefixOnly = false);
412 
414 
415 class TuckerEngine: public Engine {
416 public:
417 
418  enum {
419  kLocationAnimationsTableSize = 20,
420  kLocationObjectsTableSize = 10,
421  kActionsTableSize = 100,
422  kFlagsTableSize = 300,
423  kLocationSoundsTableSize = 30,
424  kLocationMusicsTableSize = 4,
425  kSpriteFramesTableSize = 200,
426  kSprA02TableSize = 20,
427  kSprC02TableSize = 40,
428  kDataTableSize = 500,
429  kSpeechHistoryTableSize = 5,
430  kMaxCharacters = 8,
431  kMaxDirtyRects = 32
432  };
433 
434  struct SavegameHeader {
435  uint16 version;
436  uint32 flags;
437  Common::String description;
438  uint32 saveDate;
439  uint32 saveTime;
440  uint32 playTime;
441  Graphics::Surface *thumbnail;
442  };
443 
444  enum SavegameError {
445  kSavegameNoError = 0,
446  kSavegameInvalidTypeError,
447  kSavegameInvalidVersionError,
448  kSavegameNotFoundError,
449  kSavegameIoError
450  };
451 
452  TuckerEngine(OSystem *system, Common::Language language, uint32 flags);
453  ~TuckerEngine() override;
454 
455  Common::Error run() override;
456  bool hasFeature(EngineFeature f) const override;
457 
458  WARN_UNUSED_RESULT static SavegameError readSavegameHeader(Common::InSaveFile *file, SavegameHeader &header, bool skipThumbnail = true);
459  WARN_UNUSED_RESULT static SavegameError readSavegameHeader(const char *target, int slot, SavegameHeader &header);
460  bool canSaveAutosaveCurrently() override;
461 
462  static bool isAutosaveAllowed(const char *target);
463 protected:
464 
465  int getRandomNumber();
466  void allocateBuffers();
467  void freeBuffers();
468  void resetVariables();
469  void mainLoop();
470  void waitForTimer(int ticksCount);
471  void parseEvents();
472  void updateCursorPos(int x, int y);
473  void setCursorStyle(CursorStyle style);
474  void setCursorState(CursorState state);
475  void showCursor(bool visible);
476  void setupNewLocation();
477  void copyLocBitmap(const char *filename, int offset, bool isMask);
478  void updateMouseState();
479  void updateCharPositionHelper();
480  void updateCharPosition();
481  void updateFlagsForCharPosition();
482  void fadeOutPalette(int colorsCount = 256);
483  void fadeInPalette(int colorsCount = 256);
484  void fadePaletteColor(int color, int step);
485  void setBlackPalette();
486  void updateCursor();
487  void stopSounds();
488  void playSounds();
489  void updateCharactersPath();
490  void setSoundVolumeDistance();
491  void updateData3DrawFlag();
492  void updateData3();
493  void updateSfxData3_1();
494  void updateSfxData3_2();
495  void saveOrLoad();
496  void handleMouseOnPanel();
497  void togglePanelStyle();
498  void redrawPanelOverBackground();
499  void drawConversationTexts();
500  void updateScreenScrolling();
501  void updateGameHints();
502  void startCharacterSounds();
503  void updateSoundsTypes3_4();
504  void drawData3();
505  void execData3PreUpdate();
506  void drawBackgroundSprites();
507  void drawCurrentSprite();
508  void setVolumeSound(int index, int volume);
509  void setVolumeMusic(int index, int volume);
510  void startSound(int offset, int index, int volume);
511  void stopSound(int index);
512  bool isSoundPlaying(int index);
513  void startMusic(int offset, int index, int volume);
514  void stopMusic(int index);
515  void startSpeechSound(int num, int volume);
516  void stopSpeechSound();
517  bool isSpeechSoundPlaying();
518  void rememberSpeechSound();
519  void redrawPanelItems();
520  void redrawPanelItemsHelper();
521  void drawSprite(int i);
522  void clearItemsGfx();
523  void drawPausedInfoBar();
524  const uint8 *getStringBuf(int type) const;
525  void drawInfoString();
526  void drawGameHintString();
527  void updateCharacterAnimation();
528  void execData3PostUpdate();
529  void addObjectToInventory(int num);
530  void removeObjectFromInventory(int num);
531  void handleMap();
532  void clearSprites();
533  void updateSprites();
534  void updateSprite(int i);
535  void drawStringInteger(int num, int x, int y, int digits);
536  void drawStringAlt(int x, int y, int color, const uint8 *str, int strLen = -1);
537  void drawItemString(int x, int num, const uint8 *str);
538  void drawCreditsString(int x, int y, int num);
539  void updateCharSpeechSound(bool displayText);
540  void updateItemsGfxColors(int bit0, int bit7);
541  bool testLocationMask(int x, int y);
542  int getStringWidth(int num, const uint8 *ptr);
543  int getPositionForLine(int num, const uint8 *ptr);
544  void resetCharacterAnimationIndex(int count);
545  int readTableInstructionCode(int *index);
546  int readTableInstructionParam(int len);
547  int executeTableInstruction();
548  void moveUpInventoryObjects();
549  void moveDownInventoryObjects();
550  void setActionVerbUnderCursor();
551  int getObjectUnderCursor();
552  void setSelectedObjectKey();
553  void setCharacterAnimation(int count, int spr);
554  bool testLocationMaskArea(int xBase, int yBase, int xPos, int yPos);
555  void handleMouseClickOnInventoryObject();
556  int setCharacterUnderCursor();
557  int setLocationAnimationUnderCursor();
558  void setActionForInventoryObject();
559  void setActionState();
560  void playSpeechForAction(int i);
561  void drawSpeechText(int xStart, int y, const uint8 *dataPtr, int num, int color);
562  bool splitSpeechTextLines(const uint8 *dataPtr, int pos, int x, int &lineCharsCount, int &lineWidth);
563  void drawSpeechTextLine(const uint8 *dataPtr, int pos, int count, int x, int y, uint8 color);
564  void redrawScreen(int offset);
565  void redrawScreenRect(const Common::Rect &clip, const Common::Rect &dirty);
566  void addDirtyRect(int x, int y, int w, int h);
567 
568  void execData3PreUpdate_locationNum1();
569  void execData3PreUpdate_locationNum1Helper1();
570  void execData3PreUpdate_locationNum1Helper2();
571  int execData3PreUpdate_locationNum1Helper3(int dx, int dy);
572  void execData3PostUpdate_locationNum1();
573  void updateSprite_locationNum2();
574  void execData3PreUpdate_locationNum2();
575  void execData3PreUpdate_locationNum2Helper();
576  void updateSprite_locationNum3_0(int i);
577  void updateSprite_locationNum3_1(int i);
578  void updateSprite_locationNum3_2(int i);
579  void execData3PreUpdate_locationNum3();
580  void updateSprite_locationNum4(int i);
581  void execData3PreUpdate_locationNum4();
582  void updateSprite_locationNum5_0();
583  void updateSprite_locationNum5_1(int i);
584  void updateSprite_locationNum6_0(int i);
585  void updateSprite_locationNum6_1(int i);
586  void updateSprite_locationNum6_2(int i);
587  void execData3PreUpdate_locationNum6();
588  void execData3PreUpdate_locationNum6Helper1();
589  void execData3PreUpdate_locationNum6Helper2(int dstOffset, const uint8 *src);
590  void execData3PreUpdate_locationNum6Helper3(int dstOffset, const uint8 *src);
591  void execData3PostUpdate_locationNum6();
592  void updateSprite_locationNum7_0(int i);
593  void updateSprite_locationNum7_1(int i);
594  void updateSprite_locationNum8_0(int i);
595  void updateSprite_locationNum8_1(int i);
596  void execData3PostUpdate_locationNum8();
597  void updateSprite_locationNum9_0(int i);
598  void updateSprite_locationNum9_1(int i);
599  void updateSprite_locationNum9_2(int i);
600  void execData3PreUpdate_locationNum9();
601  void execData3PostUpdate_locationNum9();
602  void updateSprite_locationNum10();
603  void execData3PreUpdate_locationNum10();
604  void updateSprite_locationNum11_0(int i);
605  void updateSprite_locationNum11_1(int i);
606  void updateSprite_locationNum11_2(int i);
607  void updateSprite_locationNum11_3(int i);
608  void updateSprite_locationNum11_4(int i);
609  void updateSprite_locationNum12_0(int i);
610  void updateSprite_locationNum12_1(int i);
611  void execData3PreUpdate_locationNum12();
612  void updateSprite_locationNum13(int i);
613  void execData3PreUpdate_locationNum13();
614  void updateSprite_locationNum14(int i);
615  void execData3Update_locationNum14();
616  void execData3PreUpdate_locationNum14();
617  void execData3PreUpdate_locationNum14Helper1(int i);
618  void execData3PreUpdate_locationNum14Helper2(int i);
619  void execData3PostUpdate_locationNum14();
620  void updateSprite_locationNum15_0(int i);
621  void updateSprite_locationNum15_1(int i);
622  void updateSprite_locationNum15_2(int i);
623  void execData3PreUpdate_locationNum15();
624  void updateSprite_locationNum16_0(int i);
625  void updateSprite_locationNum16_1(int i);
626  void updateSprite_locationNum16_2(int i);
627  void execData3PreUpdate_locationNum16();
628  void updateSprite_locationNum17();
629  void updateSprite_locationNum18();
630  void updateSprite_locationNum19_0(int i);
631  void updateSprite_locationNum19_1(int i);
632  void updateSprite_locationNum19_2(int i);
633  void updateSprite_locationNum19_3(int i);
634  void execData3PreUpdate_locationNum19();
635  void updateSprite_locationNum21();
636  void execData3PreUpdate_locationNum21();
637  void execData3PostUpdate_locationNum21();
638  void updateSprite_locationNum22();
639  void execData3PreUpdate_locationNum22();
640  void updateSprite_locationNum23_0(int i);
641  void updateSprite_locationNum23_1(int i);
642  void updateSprite_locationNum23_2(int i);
643  void updateSprite_locationNum23_3(int i);
644  void updateSprite_locationNum24_0(int i);
645  void updateSprite_locationNum24_1(int i);
646  void updateSprite_locationNum24_2(int i);
647  void updateSprite_locationNum24_3(int i);
648  void execData3PreUpdate_locationNum24();
649  void execData3PostUpdate_locationNum24();
650  void execData3PreUpdate_locationNum25();
651  void updateSprite_locationNum26_0(int i);
652  void updateSprite_locationNum26_1(int i);
653  void execData3PreUpdate_locationNum26();
654  void updateSprite_locationNum27(int i);
655  void execData3PreUpdate_locationNum27();
656  void execData3PostUpdate_locationNum27();
657  void updateSprite_locationNum28_0(int i);
658  void updateSprite_locationNum28_1(int i);
659  void updateSprite_locationNum28_2(int i);
660  void execData3PreUpdate_locationNum28();
661  void execData3PostUpdate_locationNum28();
662  void updateSprite_locationNum29_0(int i);
663  void updateSprite_locationNum29_1(int i);
664  void updateSprite_locationNum29_2(int i);
665  void execData3PreUpdate_locationNum29();
666  void updateSprite_locationNum30_34(int i);
667  void execData3PreUpdate_locationNum30();
668  void updateSprite_locationNum31_0(int i);
669  void updateSprite_locationNum31_1(int i);
670  void execData3PreUpdate_locationNum31();
671  void updateSprite_locationNum32_0(int i);
672  void execData3PreUpdate_locationNum32();
673  void execData3PostUpdate_locationNum32();
674  void updateSprite_locationNum33_0(int i);
675  void updateSprite_locationNum33_1(int i);
676  void updateSprite_locationNum33_2(int i);
677  void execData3PreUpdate_locationNum33();
678  void execData3PreUpdate_locationNum34();
679  void execData3PreUpdate_locationNum35();
680  void updateSprite_locationNum36(int i);
681  void execData3PreUpdate_locationNum36();
682  void updateSprite_locationNum37(int i);
683  void execData3PreUpdate_locationNum38();
684  void updateSprite_locationNum41(int i);
685  void execData3PreUpdate_locationNum41();
686  void updateSprite_locationNum42(int i);
687  void execData3PreUpdate_locationNum42();
688  void updateSprite_locationNum43_2(int i);
689  void updateSprite_locationNum43_3(int i);
690  void updateSprite_locationNum43_4(int i);
691  void updateSprite_locationNum43_5(int i);
692  void updateSprite_locationNum43_6(int i);
693  void execData3PreUpdate_locationNum43();
694  void execData3PreUpdate_locationNum44();
695  void updateSprite_locationNum48(int i);
696  void updateSprite_locationNum49(int i);
697  void execData3PreUpdate_locationNum49();
698  void updateSprite_locationNum50(int i);
699  void updateSprite_locationNum51(int i);
700  void execData3PreUpdate_locationNum52();
701  void updateSprite_locationNum53_0(int i);
702  void updateSprite_locationNum53_1(int i);
703  void execData3PreUpdate_locationNum53();
704  void updateSprite_locationNum54(int i);
705  void updateSprite_locationNum55(int i);
706  void updateSprite_locationNum56(int i);
707  void updateSprite_locationNum57_0(int i);
708  void updateSprite_locationNum57_1(int i);
709  void execData3PreUpdate_locationNum57();
710  void updateSprite_locationNum58(int i);
711  void execData3PreUpdate_locationNum58();
712  void updateSprite_locationNum59(int i);
713  void updateSprite_locationNum60_0(int i);
714  void updateSprite_locationNum60_1(int i);
715  void execData3PostUpdate_locationNum60();
716  void updateSprite_locationNum61_0(int i);
717  void updateSprite_locationNum61_1(int i);
718  void updateSprite_locationNum61_2(int i);
719  void execData3PreUpdate_locationNum61();
720  void updateSprite_locationNum63_0(int i);
721  void updateSprite_locationNum63_1(int i);
722  void updateSprite_locationNum63_2(int i);
723  void updateSprite_locationNum63_3(int i);
724  void updateSprite_locationNum63_4(int i);
725  void execData3PreUpdate_locationNum63();
726  void execData3PreUpdate_locationNum64();
727  void updateSprite_locationNum65(int i);
728  void execData3PreUpdate_locationNum65();
729  void updateSprite_locationNum66_0(int i);
730  void updateSprite_locationNum66_1(int i);
731  void updateSprite_locationNum66_2(int i);
732  void updateSprite_locationNum66_3(int i);
733  void updateSprite_locationNum66_4(int i);
734  void execData3PreUpdate_locationNum66();
735  void execData3PostUpdate_locationNum66();
736  void updateSprite_locationNum69_1(int i);
737  void updateSprite_locationNum69_2(int i);
738  void updateSprite_locationNum69_3(int i);
739  void execData3PreUpdate_locationNum70();
740  void execData3PreUpdate_locationNum70Helper();
741  void updateSprite_locationNum71(int i);
742  void updateSprite_locationNum72(int i);
743  void updateSprite_locationNum74(int i);
744  void updateSprite_locationNum79(int i);
745  void updateSprite_locationNum81_0(int i);
746  void updateSprite_locationNum81_1(int i);
747  void updateSprite_locationNum82(int i);
748 
749  template<class S> SavegameError saveOrLoadGameStateData(S &s);
750  Common::Error loadGameState(int slot) override;
751  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
752  SavegameError writeSavegameHeader(Common::OutSaveFile *file, SavegameHeader &header);
753  int getAutosaveSlot() const override { return kAutoSaveSlot; }
754  Common::String getSaveStateName(int slot) const override {
755  return Common::String::format("%s.%d", _targetName.c_str(), slot);
756  }
757 
758  bool canLoadOrSave() const;
759  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
760  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
761  virtual bool existsSavegame();
762 
763  void handleIntroSequence();
764  void handleCreditsSequence();
765  void handleCongratulationsSequence();
766  void handleNewPartSequence();
767  void handleMeanwhileSequence();
768  void handleMapSequence();
769  void copyMapRect(int x, int y, int w, int h);
770  bool handleSpecialObjectSelectionSequence();
771 
772  uint8 *loadFile(const char *filename, uint8 *p);
773  void loadImage(const char *filename, uint8 *dst, int a);
774  void loadCursor();
775  void loadCharset();
776  void loadCharset2();
777  void loadCharsetHelper();
778  void loadCharSizeDta();
779  void loadPanel();
780  void loadBudSpr();
781  int loadCTable01(int *framesCount);
782  void loadCTable02();
783  void loadLoc();
784  void loadObj();
785  void loadData();
786  int loadDataHelper(int offset, int index);
787  void loadPanObj();
788  void loadData3();
789  void loadData4();
790  void loadActionFile();
791  void loadCharPos();
792  void loadSprA02_01();
793  void unloadSprA02_01();
794  void loadSprC02_01();
795  void unloadSprC02_01();
796  void loadFx();
797  void loadSound(Audio::Mixer::SoundType type, int num, int volume, bool loop, Audio::SoundHandle *handle);
798  void loadActionsTable();
799 
801  AnimationSequencePlayer *_player;
802  CompressedSound _compressedSound;
803  Common::Language _gameLang;
804  uint32 _gameFlags;
805  int _startSlot;
806 
807  bool _quitGame;
808  bool _fastMode;
809  int _syncCounter;
810  uint32 _lastFrameTime;
811  int _mainLoopCounter1;
812  int _mainLoopCounter2;
813  int _timerCounter2;
814  int _flagsTable[kFlagsTableSize];
815  Part _part;
816  Part _currentPart;
817  Location _location;
818  Location _nextLocation;
819  bool _gamePaused;
820  bool _gameDebug;
821  bool _displayGameHints;
822  int _execData3Counter;
823  int _currentSaveLoadGameState;
824  int _gameHintsIndex;
825  int _gameHintsCounter;
826  int _gameHintsStringNum;
827 
828  bool _displaySpeechText;
829  bool _displayHintsText;
830 
831  int _fileLoadSize;
832  uint8 *_loadTempBuf;
833  uint8 *_cursorGfxBuf;
834  uint8 *_charsetGfxBuf;
835  uint8 *_panelGfxBuf;
836  uint8 *_itemsGfxBuf;
837  uint8 *_spritesGfxBuf;
838  uint8 *_locationBackgroundGfxBuf;
839  uint8 *_data5Buf;
840  uint8 *_data3GfxBuf;
841  uint8 *_quadBackgroundGfxBuf;
842  uint8 *_objTxtBuf;
843  uint8 *_panelObjectsGfxBuf;
844  uint8 *_ptTextBuf;
845  uint8 *_infoBarBuf;
846  uint8 *_bgTextBuf;
847  uint8 *_charNameBuf;
848  uint8 *_locationBackgroundMaskBuf;
849  uint8 *_csDataBuf;
850  int _csDataSize;
851  uint8 _charWidthTable[256];
852  const uint8 *_locationWidthTable;
853  uint8 *_locationHeightTable;
854 
855  int _mousePosX, _mousePosY;
856  int _prevMousePosX, _prevMousePosY;
857  int _mouseButtonsMask;
858  int _mouseClick;
859  int _saveOrLoadGamePanel;
860  int _mouseIdleCounter;
861  bool _leftMouseButtonPressed;
862  bool _rightMouseButtonPressed;
863  bool _mouseWheelUp;
864  bool _mouseWheelDown;
865  int _lastKeyPressed;
866  bool _inputKeys[kInputKeyCount];
867  CursorStyle _cursorStyle;
868  CursorState _cursorState;
869  bool _updateCursorFlag;
870 
871  PanelStyle _panelStyle;
872  PanelState _panelState;
873  PanelType _panelType;
874  bool _forceRedrawPanelItems;
875  int _redrawPanelItemsCounter;
876  int _panelObjectsOffsetTable[50];
877  int _switchPanelCounter;
878  int _conversationOptionsCount;
879  bool _fadedPanel;
880  bool _panelLockedFlag;
881  int _conversationOptionLinesCount;
882  int _inventoryItemsState[50];
883  int _inventoryObjectsList[40];
884  int _inventoryObjectsOffset;
885  int _inventoryObjectsCount;
886  int _lastInventoryObjectIndex;
887 
888  uint8 *_sprA02Table[kSprA02TableSize];
889  uint8 *_sprC02Table[kSprC02TableSize];
890  Action _actionsTable[kActionsTableSize];
891  int _actionsCount;
892  LocationObject _locationObjectsTable[kLocationObjectsTableSize];
893  int _locationObjectsCount;
894  Sprite _spritesTable[kMaxCharacters];
895  int _spritesCount;
896  LocationAnimation _locationAnimationsTable[kLocationAnimationsTableSize];
897  int _locationAnimationsCount;
898  Data _dataTable[kDataTableSize];
899  int _dataCount;
900  CharPos _charPosTable[kMaxCharacters];
901  int _charPosCount;
902  LocationSound _locationSoundsTable[kLocationSoundsTableSize];
903  int _locationSoundsCount;
904  LocationMusic _locationMusicsTable[kLocationMusicsTableSize];
905  int _locationMusicsCount;
906 
907  int _currentFxSet;
908  int _currentFxDist;
909  int _currentFxScale;
910  int _currentFxVolume;
911  int _currentFxIndex;
912  int _speechSoundNum;
913  int _speechVolume;
914  Audio::SoundHandle _sfxHandles[kLocationSoundsTableSize];
915  Audio::SoundHandle _musicHandles[kLocationMusicsTableSize];
916  Audio::SoundHandle _speechHandle;
917  int _miscSoundFxNum[2];
918  int _speechHistoryTable[kSpeechHistoryTableSize];
919  int _charSpeechSoundCounter;
920  int _miscSoundFxDelayCounter[2];
921  int _characterSoundFxDelayCounter;
922  int _characterSoundFxNum;
923  int _speechSoundBaseNum;
924 
925  int _pendingActionIndex;
926  int _pendingActionDelay;
927  int _charPositionFlagNum;
928  int _charPositionFlagValue;
929  Verb _actionVerb;
930  Verb _currentActionVerb;
931  Verb _previousActionVerb;
932  int _nextAction;
933  int _selectedObjectNum;
934  int _selectedObjectType;
935  int _selectedCharacterNum;
936  int _actionObj1Type, _actionObj2Type;
937  int _actionObj1Num, _actionObj2Num;
938  bool _actionRequiresTwoObjects;
939  bool _actionVerbLocked;
940  int _actionPosX;
941  int _actionPosY;
942  bool _selectedObjectLocationMask;
943  struct {
944  int _xDefaultPos;
945  int _yDefaultPos;
946  int _xPos;
947  int _yPos;
948  Location _locationObjectLocation;
949  int _locationObjectToX;
950  int _locationObjectToY;
951  int _locationObjectToX2;
952  int _locationObjectToY2;
953  int _locationObjectToWalkX2;
954  int _locationObjectToWalkY2;
955  } _selectedObject;
956  int _selectedCharacterDirection;
957  int _selectedCharacter2Num;
958  int _currentActionObj1Num, _currentActionObj2Num;
959  int _currentInfoString1SourceType, _currentInfoString2SourceType;
960  int _speechActionCounterTable[9];
961  int _actionCharacterNum;
962 
963  bool _csDataLoaded;
964  bool _csDataHandled;
965  bool _stopActionOnSoundFlag;
966  bool _stopActionOnSpeechFlag;
967  bool _stopActionOnPanelLock;
968  int _csDataTableCount;
969  int _stopActionCounter;
970  int _actionTextColor;
971  int _nextTableToLoadIndex;
972  int _nextTableToLoadTable[6];
973  int _soundInstructionIndex;
974  const uint8 *_tableInstructionsPtr;
975  int _tableInstructionObj1Table[6];
976  int _tableInstructionObj2Table[6];
977  bool _tableInstructionFlag;
978  int _tableInstructionItemNum1, _tableInstructionItemNum2;
979  int _instructionsActionsTable[6];
980  bool _validInstructionId;
981 
982  SpriteFrame _spriteFramesTable[kSpriteFramesTableSize];
983  SpriteAnimation _spriteAnimationsTable[200];
984  int _spriteAnimationFramesTable[500];
985  int _spriteAnimationFrameIndex;
986  int _backgroundSpriteCurrentFrame;
987  int _backgroundSpriteLastFrame;
988  int _backgroundSpriteCurrentAnimation;
989  bool _disableCharactersPath;
990  bool _skipCurrentCharacterDraw;
991  int _xPosCurrent;
992  int _yPosCurrent;
993  const uint8 *_characterSpeechDataPtr;
994  int _ptTextOffset;
995  int _characterAnimationsTable[200];
996  int _characterStateTable[200];
997  int _backgroundSprOffset;
998  int _mainSpritesBaseOffset;
999  int _currentSpriteAnimationLength;
1000  int _currentSpriteAnimationFrame;
1001  int _currentSpriteAnimationFrame2;
1002  int _characterAnimationIndex;
1003  int _characterFacingDirection;
1004  int _characterPrevFacingDirection;
1005  bool _characterBackFrontFacing;
1006  bool _characterPrevBackFrontFacing;
1007  int _characterAnimationNum;
1008  int _noCharacterAnimationChange;
1009  int _characterSpriteAnimationFrameCounter;
1010  bool _locationMaskIgnore;
1011  int _locationMaskType;
1012  int _locationMaskCounter;
1013  int _handleMapCounter;
1014  bool _noPositionChangeAfterMap;
1015  bool _changeBackgroundSprite;
1016  bool _updateSpriteFlag1;
1017  bool _updateSpriteFlag2;
1018 
1019  bool _mirroredDrawing;
1020  uint8 *_loadLocBufPtr;
1021  uint8 *_backgroundSpriteDataPtr;
1022  int _locationHeight;
1023  int _scrollOffset;
1024  int _currentGfxBackgroundCounter;
1025  uint8 *_currentGfxBackground;
1026  int _fadePaletteCounter;
1027  uint8 _currentPalette[768];
1028  bool _fullRedraw;
1029  int _dirtyRectsPrevCount, _dirtyRectsCount;
1030  Common::Rect _dirtyRectsTable[kMaxDirtyRects];
1031 
1032  int _updateLocationFadePaletteCounter;
1033  int _updateLocationCounter;
1034  int _updateLocationPos;
1035  int _updateLocationXPosTable[5], _updateLocationYPosTable[5];
1036  int _updateLocationFlagsTable[5];
1037  int _updateLocationXPosTable2[10], _updateLocationYPosTable2[10];
1038  int _updateLocationYMaxTable[3];
1039  int _updateLocation14Step[10];
1040  int _updateLocation14ObjNum[10];
1041  int _updateLocation14Delay[10];
1042  int _updateLocationCounter2;
1043  bool _updateLocationFlag;
1044  int _updateLocation70StringLen;
1045  uint8 _updateLocation70String[20];
1046 
1047  static const uint8 _locationWidthTableGame[85];
1048  static const uint8 _locationWidthTableDemo[70];
1049  static const uint8 _sprA02LookupTable[88];
1050  static const uint8 _sprC02LookupTable[100];
1051  static const uint8 _sprC02LookupTable2[100];
1052  static const int _staticData3Table[1600];
1053  static uint8 _locationHeightTableGame[80];
1054  static uint8 _locationHeightTableDemo[70];
1055  static int _objectKeysPosXTable[80];
1056  static int _objectKeysPosYTable[80];
1057  static int _objectKeysLocationTable[80];
1058  static int _mapSequenceFlagsLocationTable[70];
1059  static const uint8 _charWidthCharset1[224];
1060  static const uint8 _charWidthCharset2[58];
1061 };
1062 
1063 enum {
1064  kFirstAnimationSequenceGame = 17,
1065  kFirstAnimationSequenceDemo = 13
1066 };
1067 
1068 enum AnimationSoundType {
1069  kAnimationSoundType8BitsRAW,
1070  kAnimationSoundType16BitsRAW,
1071  kAnimationSoundTypeWAV
1072 };
1073 
1074 enum {
1075  kSoundsList_Seq3_4,
1076  kSoundsList_Seq9_10,
1077  kSoundsList_Seq21_20,
1078  kSoundsList_Seq13_14,
1079  kSoundsList_Seq15_16,
1080  kSoundsList_Seq27_28,
1081  kSoundsList_Seq17_18,
1082  kSoundsList_Seq19_20
1083 };
1084 
1086  int timestamp;
1087  int index;
1088  int num;
1089  int volume;
1090  int opcode;
1091 };
1092 
1094  int musicIndex;
1095  int musicVolume;
1096  int soundList1Count;
1097  int soundList2Count;
1098  int soundSeqDataCount;
1099  const SoundSequenceData *soundSeqData;
1100 };
1101 
1103 public:
1104 
1105  enum {
1106  kSequenceFrameTime = 55
1107  };
1108 
1110  int num;
1111  int frameTime;
1112  void (AnimationSequencePlayer::*load)();
1113  void (AnimationSequencePlayer::*play)();
1114  };
1115 
1116  AnimationSequencePlayer(OSystem *system, Audio::Mixer *mixer, Common::EventManager *event, CompressedSound *sound, int num);
1118 
1119  void mainLoop();
1120 
1121 private:
1122 
1123  void syncTime();
1124  void loadSounds(int num);
1125  Audio::RewindableAudioStream *loadSound(int index, AnimationSoundType type);
1126  void updateSounds();
1127  void fadeInPalette();
1128  void fadeOutPalette();
1129  void unloadAnimation();
1130  uint8 *loadPicture(const char *fileName);
1131  void openAnimation(int index, const char *fileName);
1132  bool decodeNextAnimationFrame(int index, bool copyDirtyRects = true);
1133  void loadIntroSeq17_18();
1134  void playIntroSeq17_18();
1135  void loadIntroSeq19_20();
1136  void playIntroSeq19_20();
1137  void displayLoadingScreen();
1138  void initPicPart4();
1139  void drawPicPart4();
1140  void loadIntroSeq3_4();
1141  void playIntroSeq3_4();
1142  void drawPic2Part10();
1143  void drawPic1Part10();
1144  void loadIntroSeq9_10();
1145  void playIntroSeq9_10();
1146  void loadIntroSeq21_22();
1147  void playIntroSeq21_22();
1148  void loadIntroSeq13_14();
1149  void playIntroSeq13_14();
1150  void loadIntroSeq15_16();
1151  void playIntroSeq15_16();
1152  void loadIntroSeq27_28();
1153  void playIntroSeq27_28();
1154  void getRGBPalette(int index);
1155 
1156  OSystem *_system;
1157  Audio::Mixer *_mixer;
1158  Common::EventManager *_event;
1159  CompressedSound *_compressedSound;
1160 
1161  int _seqNum;
1162  bool _changeToNextSequence;
1163  const SequenceUpdateFunc *_updateFunc;
1164  int _updateFuncIndex;
1165  Video::FlicDecoder _flicPlayer[2];
1166  uint8 _animationPalette[256 * 3];
1167  int _soundSeqDataCount;
1168  int _soundSeqDataIndex;
1169  const SoundSequenceData *_soundSeqData;
1170  uint8 *_offscreenBuffer;
1171  int _updateScreenWidth;
1172  bool _updateScreenPicture;
1173  int _updateScreenCounter;
1174  int _updateScreenIndex;
1175  int _frameCounter;
1176  int _frameTime;
1177  uint32 _lastFrameTime;
1178  uint8 *_picBufPtr, *_pic2BufPtr;
1179  Audio::SoundHandle _soundsHandle[15];
1180  Audio::SoundHandle _sfxHandle;
1181  Audio::SoundHandle _musicHandle;
1182 
1183  static const SoundSequenceDataList _soundSeqDataList[];
1184  static const char *const _audioFileNamesTable[];
1185 };
1186 
1187 } // namespace Tucker
1188 
1189 #endif
Definition: tucker.h:223
Definition: str.h:59
Definition: tucker.h:382
Definition: surface.h:67
EngineFeature
Definition: engine.h:253
static String format(MSVC_PRINTF const char *fmt,...) GCC_PRINTF(1
Definition: savefile.h:54
Definition: error.h:84
void warning(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: random.h:44
Definition: tucker.h:313
Definition: rect.h:144
Definition: tucker.h:346
Definition: tucker.h:261
Definition: stream.h:745
Definition: tucker.h:415
Definition: tucker.h:1102
Definition: tucker.h:275
Definition: tucker.h:434
Definition: tucker.h:298
Definition: mixer.h:49
Definition: flic_decoder.h:49
SoundType
Definition: mixer.h:62
Definition: mixer.h:59
int getAutosaveSlot() const override
Definition: tucker.h:753
Definition: ustr.h:57
Definition: file.h:47
Definition: tucker.h:289
Definition: console.h:27
bool skipThumbnail(Common::SeekableReadStream &in)
Definition: tucker.h:331
Definition: tucker.h:239
Definition: audiostream.h:109
Definition: mixer.h:71
Definition: tucker.h:283
Definition: system.h:161
Common::String getSaveStateName(int slot) const override
Definition: tucker.h:754
Definition: events.h:472
Definition: engine.h:144
Definition: tucker.h:1085
Definition: system.h:38
Language
Definition: language.h:45
Definition: tucker.h:1093