ScummVM API documentation
myst_state.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 MYST_SAVELOAD_H
23#define MYST_SAVELOAD_H
24
25#include "common/savefile.h"
26#include "common/file.h"
27#include "common/str.h"
28
29#include "engines/savestate.h"
30
31namespace Common {
32class Serializer;
33}
34
35namespace Mohawk {
36
37class MohawkEngine_Myst;
38
40 uint8 saveDay;
41 uint8 saveMonth;
42 uint16 saveYear;
43
44 uint8 saveHour;
45 uint8 saveMinute;
46
47 uint32 totalPlayTime;
48
49 bool autoSave;
50
51 Common::String saveDescription;
52
54 bool sync(Common::Serializer &s);
55};
56
57// Page being held
58enum HeldPage {
59 kNoPage = 0,
60 kBlueLibraryPage = 1,
61 kBlueSeleniticPage = 2,
62 kBlueMechanicalPage = 3,
63 kBlueStoneshipPage = 4,
64 kBlueChannelwoodPage = 5,
65 kBlueFirePlacePage = 6,
66 kRedLibraryPage = 7,
67 kRedSeleniticPage = 8,
68 kRedMechanicalPage = 9,
69 kRedStoneshipPage = 10,
70 kRedChannelwoodPage = 11,
71 kRedFirePlacePage = 12,
72 kWhitePage = 13
73};
74
75// Age the player is in
76enum ActiveAge {
77 kSelenitic = 0,
78 kStoneship = 1,
79 kMystLibrary = 2,
80 kMechanical = 3,
81 kChannelwood = 4,
82 kIntro = 5,
83 kDni = 6,
84 kMystStart = 7,
85 kCredits = 8,
86 kSirrusEnding = 9,
87 kAchenarEnding = 10
88};
89
90// Various states that Atrus can be in when in Dni
91enum DniEnding {
92 kDniNotVisited = 0, // Player hasn't been to Dni/K'veer yet
93 kAtrusWantsPage = 1, // Player is in Dni with the white page
94 kAtrusLeaves = 2, // Atrus leaves Dni after receiving the white page
95 kForgotPage = 3, // Player has entered Dni without bringing the white page
96 kBooksDestroyed = 4 // Atrus returns to Dni after previously leaving
97 // and destroying the books of his sons
98};
99
101public:
102 static const int kAutoSaveSlot;
103
106
107 static SaveStateDescriptor querySaveMetaInfos(const MetaEngine *metaEngine, int slot);
108 static Common::String querySaveDescription(int slot);
109
110 void reset();
111 bool load(int slot);
112 bool save(int slot, const Common::String &desc, const Graphics::Surface *thumbnail, bool autosave);
113 static bool deleteSave(int slot);
114
115 void addZipDest(MystStack stack, uint16 view);
116 bool isReachableZipDest(MystStack stack, uint16 view);
117
118 /* 8 Game Global Variables :
119 0 = Unknown - Fixed at 2
120 1 = Current Age / Stack
121 2 = Page Being Held
122 3 = Unknown - Fixed at 1
123 4 = Slide Transitions
124 5 = Ending
125 6 = Red Pages in Book
126 7 = Blue Pages in Book
127 */
128 struct Globals {
129 uint16 u0;
130 ActiveAge currentAge;
131 HeldPage heldPage;
132 uint16 u1;
133 uint16 transitions; // Unused in ScummVM
134 uint16 zipMode; // Unused in ScummVM
135 uint16 redPagesInBook;
136 uint16 bluePagesInBook;
137 DniEnding ending;
138 } _globals;
139
140 /* 50 Myst Specific Variables :
141 0 = Marker Switch Near Cabin
142 1 = Marker Switch Near Clock Tower
143 2 = Marker Switch on Dock
144 3 = Marker Switch Near Ship Pool
145 4 = Marker Switch Near Gears
146 5 = Marker Switch Near Generator Room
147 6 = Marker Switch Near Stellar Observatory
148 7 = Marker Switch Near Rocket Ship
149 8 = Fireplace, Opened Green Book Before
150 9 = Ship State
151 10 = Cabin Gas Valve Position
152 11 = Clock Tower Hour Hand Position
153 12 = Clock Tower Minute Hand Position
154 13 = Clock Tower Puzzle Solved / Gears Open
155 14 = Clock Tower Gear Bridge
156 15 = Generator Breaker State
157 16 = Generator Button State
158 17 = Generator Voltage State
159 18 = Library Bookcase Door
160 19 = Dock Imager Numeric Selection
161 20 = Dock Imager Active
162 21 = Unknown #1 - Fixed at 0
163 22 = Unknown #2 - Fixed at 0
164 23 = Unknown #3 - Fixed at 0
165 24 = Unknown #4 - Fixed at 0
166 25 = Tower Rotation Angle
167 26 = Boxes For Ship Float Puzzle
168 27 = Tree Boiler Pilot Light Lit
169 28 = Stellar Observatory Viewer, Control Setting Day
170 29 = Stellar Observatory Lights
171 30 = Stellar Observatory Viewer, Control Setting Month
172 31 = Stellar Observatory Viewer, Control Setting Time
173 32 = Stellar Observatory Viewer, Control Setting Year
174 33 = Stellar Observatory Viewer, Target Day
175 34 = Stellar Observatory Viewer, Target Month
176 35 = Stellar Observatory Viewer, Target Time
177 36 = Stellar Observatory Viewer, Target Year
178 37 = Cabin Safe Combination
179 38 = Channelwood Tree Position
180 39 = Checksum? #1
181 40 = Checksum? #2
182 41 = Rocketship Music Puzzle Slider #1 Position
183 42 = Rocketship Music Puzzle Slider #2 Position
184 43 = Rocketship Music Puzzle Slider #3 Position
185 44 = Rocketship Music Puzzle Slider #4 Position
186 45 = Rocketship Music Puzzle Slider #5 Position
187 46 = Unknown #5
188 47 = Unknown #6
189 48 = Unknown #7
190 49 = Unknown #8
191 */
192 struct Myst {
193 uint32 cabinMarkerSwitch;
194 uint32 clockTowerMarkerSwitch;
195 uint32 dockMarkerSwitch;
196 uint32 poolMarkerSwitch;
197 uint32 gearsMarkerSwitch;
198 uint32 generatorMarkerSwitch;
199 uint32 observatoryMarkerSwitch;
200 uint32 rocketshipMarkerSwitch;
201 uint16 greenBookOpenedBefore;
202 uint16 shipFloating;
203 uint16 cabinValvePosition;
204 uint16 clockTowerHourPosition;
205 uint16 clockTowerMinutePosition;
206 uint16 gearsOpen;
207 uint16 clockTowerBridgeOpen;
208 uint16 generatorBreakers;
209 uint16 generatorButtons;
210 uint16 generatorVoltage;
211 uint16 libraryBookcaseDoor;
212 uint16 imagerSelection;
213 uint16 imagerActive;
214 uint16 imagerWaterErased;
215 uint16 imagerMountainErased;
216 uint16 imagerAtrusErased;
217 uint16 imagerMarkerErased;
218 uint16 towerRotationAngle;
219 uint16 courtyardImageBoxes;
220 uint16 cabinPilotLightLit;
221 uint16 observatoryDaySetting;
222 uint16 observatoryLights;
223 uint16 observatoryMonthSetting;
224 uint16 observatoryTimeSetting;
225 uint16 observatoryYearSetting;
226 uint16 observatoryDayTarget;
227 uint16 observatoryMonthTarget;
228 uint16 observatoryTimeTarget;
229 uint16 observatoryYearTarget;
230 uint16 cabinSafeCombination;
231 uint16 treePosition;
232 uint32 treeLastMoveTime;
233 uint16 rocketSliderPosition[5];
234 uint16 observatoryDaySlider;
235 uint16 observatoryMonthSlider;
236 uint16 observatoryYearSlider;
237 uint16 observatoryTimeSlider;
238 } _myst;
239
240 /* 7 Channelwood Specific Variables :
241 0 = Water Pump Bridge State
242 1 = Lower Walkway to Upper Walkway Elevator State
243 2 = Lower Walkway to Upper Walkway Spiral Stair Lower Door State
244 3 = Extendable Pipe State
245 4 = Water Valve States
246 5 = Achenar's Holoprojector Selection
247 6 = Lower Walkway to Upper Walkway Spiral Stair Upper Door State
248 */
249 struct Channelwood {
250 uint32 waterPumpBridgeState;
251 uint32 elevatorState;
252 uint32 stairsLowerDoorState;
253 uint32 pipeState;
254 uint16 waterValveStates;
255 uint16 holoprojectorSelection;
256 uint16 stairsUpperDoorState;
257 } _channelwood;
258
259 /* 8 Mech Specific Variables :
260 0 = Achenar's Room Secret Panel State
261 1 = Sirrus' Room Secret Panel State
262 2 = Fortress Staircase State
263 3 = Fortress Elevator Rotation
264 4 = Code Lock Shape #1 (Left)
265 5 = Code Lock Shape #2
266 6 = Code Lock Shape #3
267 7 = Code Lock Shape #4 (Right)
268 */
269 struct Mechanical {
270 uint32 achenarCrateOpened;
271 uint16 achenarPanelState;
272 uint16 sirrusPanelState;
273 uint16 staircaseState;
274 uint16 elevatorRotation;
275 uint16 codeShape[4];
276 } _mechanical;
277
278 /* 18 Selenitic Specific Variables :
279 0 = Sound Pickup At Water Pool
280 1 = Sound Pickup At Volcanic Crack
281 2 = Sound Pickup At Clock
282 3 = Sound Pickup At Crystal Rocks
283 4 = Sound Pickup At Windy Tunnel
284 5 = Sound Receiver Doors
285 6 = Windy Tunnel Lights
286 7 = Sound Receiver Current Input
287 8 = Sound Receiver Input #0 (Water Pool) Angle Value
288 9 = Sound Receiver Input #1 (Volcanic Crack) Angle Value
289 10 = Sound Receiver Input #2 (Clock) Angle Value
290 11 = Sound Receiver Input #3 (Crystal Rocks) Angle Value
291 12 = Sound Receiver Input #4 (Windy Tunnel) Angle Value
292 13 = Sound Lock Slider #1 (Left) Position
293 14 = Sound Lock Slider #2 Position
294 15 = Sound Lock Slider #3 Position
295 16 = Sound Lock Slider #4 Position
296 17 = Sound Lock Slider #5 (Right) Position
297 */
298 struct Selenitic {
299 uint32 emitterEnabledWater;
300 uint32 emitterEnabledVolcano;
301 uint32 emitterEnabledClock;
302 uint32 emitterEnabledCrystal;
303 uint32 emitterEnabledWind;
304 uint32 soundReceiverOpened;
305 uint32 tunnelLightsSwitchedOn;
306 uint16 soundReceiverCurrentSource;
307 uint16 soundReceiverPositions[5];
308 uint16 soundLockSliderPositions[5];
309 } _selenitic;
310
311 /* 14 Stoneship Specific Variables :
312 0 = Light State
313 1 = Secret side door opened
314 2 = Water Pump State
315 3 = Lighthouse Trapdoor State
316 4 = Lighthouse Chest Water State
317 5 = Lighthouse Chest Valve State
318 6 = Lighthouse Chest Open State
319 7 = Lighthouse Trapdoor Key State
320 8 = Lighthouse Battery Duration
321 9 = Lighthouse Battery Power Good
322 10 = Lighthouse Battery Depletion Time
323 */
324 struct Stoneship {
325 uint32 lightState;
326 uint16 sideDoorOpened;
327 uint16 pumpState;
328 uint16 trapdoorState;
329 uint16 chestWaterState;
330 uint16 chestValveState;
331 uint16 chestOpenState;
332 uint16 trapdoorKeyState;
333 uint32 generatorDuration;
334 uint16 generatorPowerAvailable;
335 uint32 generatorDepletionTime;
336 } _stoneship;
337
338 MystSaveMetadata _metadata;
339
340private:
341 void syncGameState(Common::Serializer &s, bool isME);
342 static Common::String buildSaveFilename(int slot);
343 static Common::String buildMetadataFilename(int slot);
344 bool loadState(int slot);
345 void loadMetadata(int slot);
346 bool saveState(int slot);
347 void updateMetadateForSaving(const Common::String &desc, bool autoSave);
348 bool saveMetadata(int slot, const Graphics::Surface *thumbnail);
349
350 // The values in these regions are lists of VIEW resources
351 // which correspond to visited zip destinations
352
353 typedef uint16 ZipDests[41];
354
355 ZipDests _mystReachableZipDests;
356
357 ZipDests _channelwoodReachableZipDests;
358
359 ZipDests _mechReachableZipDests;
360
361 ZipDests _seleniticReachableZipDests;
362
363 ZipDests _stoneshipReachableZipDests;
364
366 Common::SaveFileManager *_saveFileMan;
367};
368
369} // End of namespace Mohawk
370
371#endif
Definition: savefile.h:142
Definition: serializer.h:80
Definition: str.h:59
Definition: metaengine.h:202
Definition: myst.h:129
Definition: myst_state.h:100
Definition: savestate.h:56
Definition: algorithm.h:29
Definition: bitmap.h:32
Definition: surface.h:67
Definition: myst_state.h:249
Definition: myst_state.h:128
Definition: myst_state.h:269
Definition: myst_state.h:192
Definition: myst_state.h:298
Definition: myst_state.h:324
Definition: myst_state.h:39