ScummVM API documentation
mortevielle.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 /*
23  * This code is based on original Mortville Manor DOS source code
24  * Copyright (c) 1987-1989 Lankhor
25  */
26 
27 #ifndef MORTEVIELLE_MORTEVIELLE_H
28 #define MORTEVIELLE_MORTEVIELLE_H
29 
30 #include "common/events.h"
31 #include "common/file.h"
32 #include "common/random.h"
33 #include "common/rect.h"
34 #include "common/stack.h"
35 #include "engines/engine.h"
36 #include "common/error.h"
37 #include "graphics/surface.h"
38 #include "mortevielle/debugger.h"
39 #include "mortevielle/dialogs.h"
40 #include "mortevielle/graphics.h"
41 #include "mortevielle/menu.h"
42 #include "mortevielle/mouse.h"
43 #include "mortevielle/saveload.h"
44 #include "mortevielle/sound.h"
45 #include "mortevielle/outtext.h"
46 #include "mortevielle/detection.h"
47 
48 namespace Mortevielle {
49 
50 // Debug channels
51 enum {
52  kMortevielleCore = 1 << 0,
53  kMortevielleGraphics = 1 << 1,
54  kMortevielleSounds = 1 << 2
55 };
56 
57 // Game languages
58 enum {
59  MORTDAT_LANG_FRENCH = 0,
60  MORTDAT_LANG_ENGLISH = 1,
61  MORTDAT_LANG_GERMAN = 2
62 };
63 
64 // Static string list
65 enum {
66  S_YES_NO = 0, S_GO_TO = 1, S_SOMEONE_ENTERS = 2, S_COOL = 3, S_LOURDE = 4,
67  S_MALSAINE = 5, S_IDEM = 6, S_YOU = 7, S_ARE = 8, S_ALONE = 9,
68  S_HEAR_NOISE = 10, S_SHOULD_HAVE_NOTICED = 11, S_NUMBER_OF_HINTS = 12,
69  S_WANT_TO_WAKE_UP = 13, S_OKAY = 14, S_SAVE_LOAD = 15, S_RESTART = 18, S_F3 = 19,
70  S_F8 = 20, S_HIDE_SELF = 21, S_TAKE = 22, S_PROBE = 23, S_RAISE = 24, S_SUITE = 25,
71  S_STOP = 26, S_USE_DEP_MENU = 27, S_LIFT = 28, S_READ = 29,
72  S_LOOK = 30, S_SEARCH = 31, S_OPEN = 32, S_PUT = 33, S_TURN = 34, S_TIE = 35, S_CLOSE = 36,
73  S_HIT = 37, S_POSE = 38, S_SMASH = 39,
74 
75  S_SMELL = 40, S_SCRATCH = 41, S_PROBE2 = 42, S_BEFORE_USE_DEP_MENU = 43, S_DAY = 44
76 };
77 
78 enum DataType {
79  kStaticStrings = 0,
80  kGameStrings = 1
81 };
82 
83 #define SCREEN_WIDTH 640
84 #define SCREEN_HEIGHT 400
85 #define SCREEN_ORIG_HEIGHT 200
86 #define MORT_DAT_REQUIRED_VERSION 1
87 #define MORT_DAT "mort.dat"
88 #define GAME_FRAME_DELAY (1000 / 50)
89 #define DISK_ACCESS_DELAY 1000
90 
91 const int kTime1 = 410;
92 const int kTime2 = 250;
93 
94 const int kAcha = 492;
95 const int kFleche = 1758;
96 
97 const int kAsoul = 154;
98 const int kAouvr = 282;
99 const int kAsearch = 387;
100 const int kArcf = 1272;
101 const int kArep = 1314;
102 const int kAmzon = 1650;
103 const int kArega = 0;
104 
105 const int kMaxDialogIndex = 9000;
106 const int kMaxDialogHint = 600;
107 
108 const int kDescriptionStringIndex = 0; // Unused
109 const int kInventoryStringIndex = 186;
110 const int kQuestionStringIndex = 247;
111 const int kDialogStringIndex = 292;
112 const int kMenuPlaceStringIndex = 435;
113 const int kStartingScreenStringIndex = 456;
114 const int kMenuActionStringIndex = 476;
115 const int kMenuSelfStringIndex = 497;
116 const int kMenuSayStringIndex = 502;
117 const int kMaxPatt = 20;
118 
119 const int kResolutionScaler = 2;
120 /*
121 18 "It's already open$",
122 26 "A photograph$"
123 */
124 enum Places {
125  OWN_ROOM = 0, GREEN_ROOM = 1, PURPLE_ROOM = 2, TOILETS = 3, DARKBLUE_ROOM = 4,
126  BLUE_ROOM = 5, RED_ROOM = 6, BATHROOM = 7, GREEN_ROOM2 = 8, JULIA_ROOM = 9,
127  DINING_ROOM = 10, BUREAU = 11, KITCHEN = 12, ATTIC = 13, CELLAR = 14,
128  LANDING = 15, CRYPT = 16, SECRET_PASSAGE = 17, ROOM18 = 18, MOUNTAIN = 19,
129  CHAPEL = 20, MANOR_FRONT = 21, MANOR_BACK = 22, INSIDE_WELL = 23, WELL = 24,
130  DOOR = 25, ROOM26 = 26, COAT_ARMS = 27
131 };
132 
133 struct SaveStruct {
134  int _faithScore;
135  byte _pctHintFound[11];
136  byte _availableQuestion[43];
137  byte _inventory[31];
138  int _currPlace;
139  int _atticBallHoleObjectId;
140  int _atticRodHoleObjectId;
141  int _cellarObjectId;
142  int _secretPassageObjectId;
143  int _wellObjectId;
144  int _selectedObjectId;
145  int _purpleRoomObjectId;
146  int _cryptObjectId;
147  bool _alreadyEnteredManor;
148  byte _fullHour;
149 };
150 
151 struct Hint {
152  int _hintId;
153  byte _point;
154 };
155 
156 class MortevielleEngine : public Engine {
157 private:
158  const MortevielleGameDescription *_gameDescription;
159  Common::Stack<int> _keypresses;
160  uint32 _lastGameFrame;
161  Common::Point _mousePos;
162  Common::StringArray _engineStrings;
163  Common::StringArray _gameStrings;
164 
165  int _menuOpcode;
166 
167  bool _inMainGameLoop; // Flag when the main game loop is active
168  bool _quitGame; // Quit game flag. Originally called 'arret'
169  bool _endGame; // End game flag. Originally called 'solu'
170  bool _loseGame; // Lose game flag. Originally called 'perdu'
171  bool _txxFileFl; // Flag used to determine if texts are from the original files or from a DAT file
172  bool _roomPresenceLuc;
173  bool _roomPresenceIda;
174  bool _purpleRoomPresenceLeo;
175  bool _roomPresenceGuy;
176  bool _roomPresenceEva;
177  bool _roomPresenceMax;
178  bool _roomPresenceBob;
179  bool _roomPresencePat;
180  bool _toiletsPresenceBobMax;
181  bool _bathRoomPresenceBobMax;
182  bool _juliaRoomPresenceLeo;
183  bool _hiddenHero;
184  bool _heroSearching;
185  bool _keyPressedEsc;
186  bool _reloadCFIEC;
187  bool _col;
188  bool _syn;
189  bool _obpart;
190  bool _anyone;
191  bool _uptodatePresence;
192 
193  int _textColor;
194  int _place;
195  int _manorDistance;
196  int _currBitIndex;
197  int _currDay;
198  int _currHour;
199  int _currHalfHour;
200  int _day;
201  int _hour;
202  int _minute;
203  int _curSearchObjId;
204  int _controlMenu;
205  int _startTime;
206  int _endTime;
207  Common::Point _stdPal[91][17];
208 
209  int _x26KeyCount;
210  int _roomDoorId;
211  int _openObjCount;
212  int _takeObjCount;
213  int _num;
214  int _searchCount;
215  bool _introSpeechPlayed;
216  int _inGameHourDuration;
217  int _x;
218  int _y;
219  int _currentHourCount;
220  int _currentTime;
221  int _pauseStartTime;
222 
223  Common::String _hintPctMessage;
224  byte *_cfiecBuffer;
225  int _cfiecBufferSize;
226  int _openObjects[7];
227  uint16 _dialogIndexArray[kMaxDialogIndex + 1];
228  Hint _dialogHintArray[kMaxDialogHint + 1];
229 
230  Common::ErrorCode initialize();
231  Common::ErrorCode loadMortDat();
232  void readStaticStrings(Common::File &f, int dataSize, DataType dataType);
233  void loadFont(Common::File &f);
234  bool handleEvents();
235  void addKeypress(Common::Event &evt);
236  void initMouse();
237  void showIntroduction();
238  void mainGame();
239  void playGame();
240  void handleAction();
241  void loadPalette();
242  void loadTexts();
243  void loadCFIEC();
244  void loadCFIPH();
245  void showTitleScreen();
246  int readclock();
247  void palette(int v1);
248  int checkLeoMaxRandomPresence();
249  void interactNPC();
250  void initCaveOrCellar();
251  void displayControlMenu();
252  void displayItemInHand(int objId);
253  void resetRoomVariables(int roomId);
254  int getPresenceStats(int &rand, int faithScore, int roomId);
255  void setPresenceFlags(int roomId);
256  void testKey(bool d);
257  void exitRoom();
258  void getReadDescription(int objId);
259  void getSearchDescription(int objId);
260  int checkLeaveSecretPassage();
261  void startDialog(int16 rep);
262  void endSearch();
263  int convertCharacterIndexToBitIndex(int characterIndex);
264  int convertBitIndexToCharacterIndex(int bitIndex);
265  void clearUpperLeftPart();
266  void clearDescriptionBar();
267  void clearVerbBar();
268  void clearUpperRightPart();
269  int getRandomNumber(int minval, int maxval);
270  void showMoveMenuAlert();
271  void showConfigScreen();
272  void decodeNumber(byte *pStart, int count);
273  void resetVariables();
274  void music();
275  void drawRightFrame();
276  void prepareRoom();
277  void drawClock();
278  void checkManorDistance();
279  void gotoManorFront();
280  void gotoManorBack();
281  void gotoDiningRoom();
282  bool checkInventory(int objectId);
283  void loseGame();
284  void floodedInWell();
285  void displayDiningRoom();
286  void startMusicOrSpeech(int so);
287  void setTextColor(int col);
288  void prepareScreenType1();
289  void prepareScreenType2();
290  void prepareScreenType3();
291  void updateHour(int &day, int &hour, int &minute);
292  void getKnockAnswer();
293  int getPresenceStatsGreenRoom();
294  int getPresenceStatsPurpleRoom();
295  int getPresenceStatsToilets();
296  int getPresenceStatsBlueRoom();
297  int getPresenceStatsRedRoom();
298  int getPresenceStatsDiningRoom(int &hour);
299  int getPresenceStatsBureau(int &hour);
300  int getPresenceStatsKitchen();
301  int getPresenceStatsAttic();
302  int getPresenceStatsLanding();
303  int getPresenceStatsChapel(int &hour);
304  int getPresenceBitIndex(int roomId);
305  void setPresenceGreenRoom(int roomId);
306  void setPresencePurpleRoom();
307  void setPresenceBlueRoom();
308  void setPresenceRedRoom(int roomId);
309  int setPresenceDiningRoom(int hour);
310  int setPresenceBureau(int hour);
311  int setPresenceKitchen();
312  int setPresenceLanding();
313  int setPresenceChapel(int hour);
314  void setRandomPresenceGreenRoom(int faithScore);
315  void setRandomPresencePurpleRoom(int faithScore);
316  void setRandomPresenceBlueRoom(int faithScore);
317  void setRandomPresenceRedRoom(int faithScore);
318  void setRandomPresenceJuliaRoom(int faithScore);
319  void setRandomPresenceDiningRoom(int faithScore);
320  void setRandomPresenceBureau(int faithScore);
321  void setRandomPresenceKitchen(int faithScore);
322  void setRandomPresenceAttic(int faithScore);
323  void setRandomPresenceLanding(int faithScore);
324  void setRandomPresenceChapel(int faithScore);
325  void loadPlaces();
326  void resetPresenceInRooms(int roomId);
327  void showPeoplePresent(int bitIndex);
328  int selectCharacters(int min, int max);
329  void fctMove();
330  void fctTake();
331  void fctInventoryTake();
332  void fctLift();
333  void fctRead();
334  void fctSelfRead();
335  void fctLook();
336  void fctSelftLook();
337  void fctSearch();
338  void fctSelfSearch();
339  void fctOpen();
340  void fctPlace();
341  void fctTurn();
342  void fctSelfHide();
343  void fctAttach();
344  void fctClose();
345  void fctKnock();
346  void fctSelfPut();
347  void fctListen();
348  void fctEat();
349  void fctEnter();
350  void fctSleep();
351  void fctForce();
352  void fctLeave();
353  void fctWait();
354  void fctSound();
355  void fctDiscuss();
356  void fctSmell();
357  void fctScratch();
358  void endGame();
359  void askRestart();
360  void handleOpcode();
361  void prepareDisplayText();
362  bool decryptNextChar(char &c, int &idx, byte &pt);
363  void displayStatusArrow();
364  void displayStatusInDescriptionBar(char stat);
365  void displayQuestionText(Common::String s, int cmd);
366  void displayTextInDescriptionBar(int x, int y, int nb, int mesgId);
367  void displayTextInVerbBar(Common::String text);
368  void displayTextBlock(Common::String text);
369  void mapMessageId(int &mesgId);
370  void resetOpenObjects();
371  void setCoordinates(int sx);
372  void drawPicture();
373  void drawPictureWithText();
374  void addObjectToInventory(int objectId);
375  void putInHand(int &objId);
376  void initMaxAnswer();
377  void displayAnimFrame(int frameNum, int animId);
378  int getFirstObject();
379  void prepareNextObject();
380  void putObject();
381  void resetObjectPlace();
382  void resetCoreVar();
383  void drawDiscussionBox();
384  void displayNarrativePicture(int af, int ob);
385  void menuUp();
386  void displayLookScreen(int objId);
387 
388  void adzon();
389 
390 public:
391  Common::Point _prevPos;
392  int _currMenu;
393  int _currAction;
394  int _drawingSizeArr[108];
395  int _charAnswerCount[9];
396  int _charAnswerMax[9];
397  byte _tabdon[4001];
398  bool _soundOff;
399  bool _outsideOnlyFl;
400  bool _destinationOk;
401  bool _largestClearScreen;
402  float _addFix;
403  int _savedBitIndex;
404  int _numpal;
405  int _key;
406  bool _mouseClick;
407  SaveStruct _coreVar, _saveStruct;
408 
409  int _maff;
410  int _caff;
411  int _crep;
412  int _is; // ???
413 
414  byte _destinationArray[7][25];
415 
416  byte *_curPict;
417  byte *_curAnim;
418  byte *_rightFramePict;
419 
420  PaletteManager _paletteManager;
421  GfxSurface _backgroundSurface;
422  Common::RandomSource _randomSource;
423 
424  ScreenSurface *_screenSurface;
425  SoundManager *_soundManager;
426  SavegameManager *_savegameManager;
427  Menu *_menu;
428  MouseHandler *_mouse;
429  TextHandler *_text;
430  DialogManager *_dialogManager;
431 
432  MortevielleEngine(OSystem *system, const MortevielleGameDescription *gameDesc);
433  ~MortevielleEngine() override;
434  bool hasFeature(EngineFeature f) const override;
435  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
436  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
437  Common::Error loadGameState(int slot) override;
438  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
439  Common::Error run() override;
440  void pauseEngineIntern(bool pause) override;
441  uint32 getGameFlags() const;
442  Common::Language getLanguage() const;
443  Common::Language getOriginalLanguage() const;
444  bool useOriginalData() const;
445  static Common::String generateSaveFilename(const Common::String &target, int slot);
446  Common::String getSaveStateName(int slot) const override {
447  return generateSaveFilename(_targetName, slot);
448  }
449 
450  int getChar();
451  bool keyPressed();
452  Common::Point getMousePos() const { return _mousePos; }
453  void setMousePos(const Common::Point &pt);
454  bool getMouseClick() const { return _mouseClick; }
455  void setMouseClick(bool v) { _mouseClick = v; }
456  Common::String getEngineString(int idx) const { return _engineStrings[idx]; }
457  Common::String getGameString(int idx) const { return _gameStrings[idx]; }
458 
459  void delay(int amount);
460  void gameLoaded();
461  void initGame();
462  void displayAloneText();
463  void displayInterScreenMessage(int mesgId);
464  void draw(int x, int y);
465  void charToHour();
466  void hourToChar();
467  Common::String getString(int num);
468  void setPal(int n);
469  Common::String copy(const Common::String &s, int idx, size_t size);
470  void testKeyboard();
471  int getPresence(int roomId);
472  void displayEmptyHand();
473  void displayPicture(const byte *pic, int x, int y);
474 
475  int gettKeyPressed();
476  void handleDescriptionText(int f, int mesgId);
477  int getAnimOffset(int frameNum, int animNum);
478 
479  void clearScreen();
480 };
481 
482 extern MortevielleEngine *g_vm;
483 
484 } // End of namespace Mortevielle
485 
486 #endif
Definition: detection.h:34
Definition: str.h:59
Definition: menu.h:49
Definition: debugger.h:28
EngineFeature
Definition: engine.h:250
Definition: error.h:84
Definition: sound.h:58
Definition: mortevielle.h:133
Definition: random.h:44
Definition: graphics.h:85
ErrorCode
Definition: error.h:47
Common::String getSaveStateName(int slot) const override
Definition: mortevielle.h:446
Definition: mouse.h:35
Out copy(In first, In last, Out dst)
Definition: algorithm.h:52
Definition: saveload.h:51
Definition: outtext.h:35
Definition: ustr.h:57
Definition: file.h:47
Definition: events.h:198
Definition: rect.h:45
Definition: graphics.h:50
Definition: dialogs.h:44
Definition: mortevielle.h:156
Definition: graphics.h:38
Definition: system.h:167
Definition: mortevielle.h:151
Definition: engine.h:143
Language
Definition: language.h:45