ScummVM API documentation
avalanche.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 the original source code of Lord Avalot d'Argent version 1.3.
24 * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
25 */
26
27#ifndef AVALANCHE_AVALANCHE_H
28#define AVALANCHE_AVALANCHE_H
29
30#include "avalanche/console.h"
31#include "avalanche/graphics.h"
32#include "avalanche/parser.h"
33#include "avalanche/avalot.h"
34#include "avalanche/dialogs.h"
35#include "avalanche/background.h"
36#include "avalanche/sequence.h"
37#include "avalanche/timer.h"
38#include "avalanche/animation.h"
39#include "avalanche/dropdown.h"
40#include "avalanche/closing.h"
41#include "avalanche/sound.h"
42#include "avalanche/nim.h"
43#include "avalanche/clock.h"
44#include "avalanche/ghostroom.h"
45#include "avalanche/help.h"
46#include "avalanche/shootemup.h"
47#include "avalanche/mainmenu.h"
48#include "avalanche/highscore.h"
49
50#include "common/error.h"
51#include "common/serializer.h"
52
53#include "engines/engine.h"
54
55#include "graphics/cursorman.h"
56
57namespace Common {
58class RandomSource;
59}
60
61namespace Avalanche {
62
63struct AvalancheGameDescription;
64class TitleScreen;
65class Intro;
66
67class Outro;
68
69static const int kSavegameVersion = 2;
70
71enum Pitch {
72 kPitchInvalid,
73 kPitchLower,
74 kPitchSame,
75 kPitchHigher
76};
77
78class AvalancheEngine : public Engine {
79public:
80 byte _saveNum; // number of times this game has been saved
81
82 Clock *_clock;
83 GraphicManager *_graphics;
84 Parser *_parser;
85 Dialogs *_dialogs;
86 Background *_background;
87 Sequence *_sequence;
88 Timer *_timer;
89 Animation *_animation;
90 DropDownMenu *_dropdown;
91 Closing *_closing;
92 SoundHandler *_sound;
93 Nim *_nim;
94 GhostRoom *_ghostroom;
95 Help *_help;
96 HighScore *_highscore;
97 Intro *_intro;
98 Outro *_outro;
99 TitleScreen *_titleScreen;
100
102 ~AvalancheEngine() override;
103
104 Common::ErrorCode initialize();
105
107
108 const AvalancheGameDescription *_gameDescription;
109 uint32 getFeatures() const;
110 const char *getGameId() const;
111 Common::Platform getPlatform() const;
112 bool hasFeature(EngineFeature f) const override;
113 const char *getCopyrightString() const;
114
115 void synchronize(Common::Serializer &sz);
116 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
117 Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
118 bool saveGame(const int16 slot, const Common::String &desc);
119 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
120 Common::Error loadGameState(int slot) override;
121 bool loadGame(const int16 slot);
122 Common::String expandDate(int d, int m, int y);
123 uint32 getTimeInSeconds();
124
125 void updateEvents();
126 bool getEvent(Common::Event &event); // A wrapper around _eventMan->pollEvent(), so we can use it in Scrolls::normscroll() for example.
127 Common::Point getMousePos();
128
129protected:
130 // Engine APIs
131 Common::Error run() override;
132
133public:
134 // For Thinkabout:
135 static const bool kThing = true;
136 static const bool kPerson = false;
137
138 static const char kSpludwicksOrder[3];
139
140 static const uint16 kNotes[12];
141
142 bool _holdLeftMouse;
143
144 // If this is greater than zero, the next line you type is stored in the DNA in a position dictated by the value.
145 // If a scroll comes up, or you leave the room, it's automatically set to zero.
146 byte _interrogation;
147
148 // Former DNA structure
149 byte _carryNum; // How many objects you're carrying...
150 bool _objects[kObjectNum]; // ...and which ones they are.
151 int16 _score; // your score, of course
152 int32 _money; // your current amount of dosh
153 Room _room; // your current room
154 bool _wonNim; // Have you *won* Nim? (That's harder.)
155 byte _wineState; // 0=good (Notts), 1=passable(Argent) ... 3=vinegar.
156 bool _cwytalotGone; // Has Cwytalot rushed off to Jerusalem yet?
157 byte _passwordNum; // Number of the passw for this game.
158 bool _aylesIsAwake; // pretty obvious!
159 byte _drawbridgeOpen; // Between 0 (shut) and 4 (open).
160 byte _avariciusTalk; // How much Avaricius has said to you.
161 bool _rottenOnion; // And has it rotted?
162 bool _onionInVinegar; // Is the onion in the vinegar?
163 byte _givenToSpludwick; // 0 = nothing given, 1 = onion...
164 byte _brummieStairs; // Progression through the stairs trick.
165 byte _cardiffQuestionNum; // Things you get asked in Cardiff.
166 bool _avvyIsAwake; // Well? Is Avvy awake? (Screen 1 only.)
167 bool _avvyInBed; // True if Avvy's in bed, but awake.
168 bool _userMovesAvvy; // If this is false, the user has no control over Avvy's movements.
169 byte _npcFacing; // If there's an NPC in the current room which turns it's head according to Avvy's movement (keep looking at him), this variable tells which way it's facing at the moment.
170 bool _givenBadgeToIby; // Have you given the badge to Iby yet?
171 bool _friarWillTieYouUp; // If you're going to get tied up.
172 bool _tiedUp; // You ARE tied up!
173 byte _boxContent; // 0 = money (sixpence), 254 = empty, any other number implies the contents of the box.
174 bool _talkedToCrapulus; // Pretty self-explanatory.
175 byte _jacquesState; // 0=asleep, 1=awake, 2=gets up, 3=gone.
176 bool _bellsAreRinging; // Is Jacques ringing the bells?
177 bool _standingOnDais; // In room 71, inside Cardiff Castle.
178 bool _takenPen; // Have you taken the pen (in Cardiff?)
179 bool _arrowInTheDoor; // Did the arrow hit the wall?
180 Common::String _favoriteDrink, _favoriteSong, _worstPlaceOnEarth, _spareEvening; // Personalisation str's
181 uint32 _startTime; // When did you start playing this session?
182 uint32 _totalTime; // Your total time playing this game, in seconds. Updated only at saving and loading.
183 byte _jumpStatus; // Fixes how high you're jumping.
184 bool _mushroomGrowing; // Is the mushroom growing in 42?
185 bool _crapulusWillTell; // Will Crapulus tell you about Spludwick being away?
186 bool _enterCatacombsFromLustiesRoom;
187 bool _teetotal; // Are we touching any more drinks?
188 byte _malagauche; // Position of Malagauche. See Celer for more info.
189 char _drinking; // What's he getting you?
190 bool _enteredLustiesRoomAsMonk;
191 byte _catacombX, _catacombY; // XY coords in the catacombs.
192 bool _avvysInTheCupboard; // On screen 22.
193 bool _geidaFollows; // Is Geida following you?
194 bool _givenPotionToGeida; // Does Geida have the potion?
195 bool _lustieIsAsleep; // Is BDL asleep?
196 bool _beenTiedUp; // In r__Robins.
197 bool _sittingInPub; // Are you sitting down in the pub?
198 byte _spurgeTalkCount; // Count for talking to Spurge.
199 bool _metAvaroid;
200 bool _takenMushroom, _givenPenToAyles, _askedDogfoodAboutNim;
201 // End of former DNA Structure
202
203 bool _showDebugLines;
204 byte _lineNum; // Number of lines.
205 LineType _lines[50]; // For Also.
206 bool _dropsOk;
207 bool _cheat; // CHECKME: Currently unused
208 bool _letMeOut;
209 byte _thinks;
210 bool _thinkThing;
211 bool _animationsEnabled; // If set to TRUE, it stops the animation system working. This prevents display of the new sprites before the new picture is loaded or during the display of a scroll. Original name: seescroll.
212 char _objectList[10];
213 // Called .free() for them in ~Gyro().
214
215 byte _currentMouse; // current mouse-void
216 Common::String *_also[31][2];
217 PedType _peds[15];
218 MagicType _magics[15];
219 MagicType _portals[7];
220 FieldType _fields[30];
221 byte _fieldNum;
222 Common::String _listen;
223 byte _cp, _ledStatus;
224 FontType _font;
225 bool _alive;
226 byte _subjectNum; // The same thing.
227 People _him, _her;
228 byte _it;
229 uint32 _roomCycles; // Set to 0 when you enter a room, added to in every loop. Cycles since you've been in this room.
230
231 bool _doingSpriteRun; // Only set to True if we're doing a sprite_run at this moment. This stops the trippancy system from moving any of the sprites.
232 bool _soundFx;
233
234 bool _isLoaded; // Is it a loaded gamestate?
235
236 void callVerb(VerbCode id);
237 void loadBackground(byte num);
238 void loadRoom(byte num);
239 void thinkAbout(byte object, bool type); // Hey!!! Get it and put it!!!
240 void incScore(byte num); // Add on no. of points
241 void fxToggle();
242 void refreshObjectList();
243 void errorLed();
244 void fadeOut();
245 void fadeIn();
246 void drawDirection(); // Draws the little icon at the left end of the text input field.
247 void gameOver();
248 uint16 bearing(byte whichPed); // Returns the bearing from ped 'whichped' to Avvy, in degrees.
249
250 // There are two kinds of redraw: Major and Minor. Minor is what happens when you load a game, etc.
251 // Major was replaced with GraphicManager::refreshScreen(), it redraws EVERYTHING.
252 void minorRedraw();
253
254 void spriteRun();
255
256 Common::String intToStr(int32 num);
257 void newGame(); // This sets up the DNA for a completely new game.
258 bool getFlag(char x);
259 bool decreaseMoney(uint16 amount); // Called pennycheck in the original.
260
261 Common::String getName(People whose);
262 Common::String getItem(byte which); // Called get_better in the original.
263 Common::String f5Does(); // This procedure determines what f5 does.
264
265 void openDoor(Room whither, byte ped, byte magicnum); // Handles slidey-open doors.
266 void flipRoom(Room room, byte ped);
267
268 void setRoom(People persId, Room roomId);
269 Room getRoom(People persId);
270private:
271 static const int16 kMaxSprites = 2; // Current max no. of sprites.
272 static Room _whereIs[29];
273
274 // Will be used in dusk() and dawn().
275 bool _fxHidden;
276 byte _fxPal[16][16][3];
277
278 bool _spludwickAtHome; // Is Spludwick at home?
279 bool _passedCwytalotInHerts; // Have you passed Cwytalot in Herts?
280 bool _holdTheDawn; // If this is true, calling Dawn will do nothing. It's used, for example, at the start, to stop Load from dawning.
281 byte _lastRoom;
282 byte _lastRoomNotMap;
283 byte _roomCount[100]; // Add one to each every time you enter a room
284 Common::String _mouseText;
285 Common::String _flags;
286 Common::String _roomnName; // Name of actual room
287 int8 _scoreToDisplay[3];
288
289 Common::String readAlsoStringFromFile(Common::File &file);
290 void runAvalot();
291 void init();
292 void initVariables();
293 void setup();
294 void scram(Common::String &str);
295 void unScramble();
296 void handleKeyDown(Common::Event &event); // To replace Basher::keyboard_link() and Basher::typein().
297 void enterNewTown();
298 void findPeople(byte room);
299 void putGeidaAt(byte whichPed, byte ped);
300 void guideAvvy(Common::Point cursorPos);
301 void enterRoom(Room room, byte ped);
302 void exitRoom(byte x);
303 void drawToolbar();
304 void drawScore();
305 void useCompass(const Common::Point &cursorPos); // Click on the compass on the toolbar to control Avvy's movement.
306 void checkClick();
307 void fixFlashers();
308 void loadAlso(byte num);
309 void resetAllVariables();
310 void resetVariables();
311};
312
313} // End of namespace Avalanche
314
315#endif // AVALANCHE_AVALANCHE_H
Definition: animation.h:92
Definition: avalanche.h:78
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false) override
bool hasFeature(EngineFeature f) const override
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Common::Error run() override
Common::Error loadGameState(int slot) override
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: background.h:47
Definition: clock.h:36
Definition: closing.h:37
Definition: dialogs.h:39
Definition: dropdown.h:118
Definition: ghostroom.h:43
Definition: graphics.h:50
Definition: help.h:35
Definition: highscore.h:39
Definition: intro.h:41
Definition: nim.h:32
Definition: outro.h:34
Definition: parser.h:39
Definition: sequence.h:35
Definition: sound.h:33
Definition: timer.h:35
Definition: titlescreen.h:32
Definition: error.h:81
Definition: file.h:47
Definition: random.h:44
Definition: serializer.h:80
Definition: str.h:59
Definition: ustr.h:57
Definition: engine.h:149
EngineFeature
Definition: engine.h:282
Definition: system.h:166
ErrorCode
Definition: error.h:47
Platform
Definition: platform.h:93
Definition: algorithm.h:29
Definition: detection.h:32
Definition: avalot.h:50
Definition: avalot.h:54
Definition: avalot.h:45
Definition: avalot.h:40
Definition: events.h:218
Definition: rect.h:144