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