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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef AGS_ENGINE_GAME_SAVEGAME_INTERNAL_H
24 #define AGS_ENGINE_GAME_SAVEGAME_INTERNAL_H
25 
26 #include "ags/lib/std/memory.h"
27 #include "ags/lib/std/vector.h"
28 #include "ags/shared/ac/common_defines.h"
29 #include "ags/shared/game/room_struct.h"
30 #include "ags/shared/gfx/bitmap.h"
31 #include "ags/engine/media/audio/audio_defines.h"
32 
33 namespace AGS3 {
34 namespace AGS {
35 namespace Engine {
36 
37 using AGS::Shared::Bitmap;
38 
39 typedef std::shared_ptr<Bitmap> PBitmap;
40 
41 // PreservedParams keeps old values of particular gameplay
42 // parameters that are saved before the save restoration
43 // and either applied or compared to new values after
44 // loading save data
45 struct PreservedParams {
46 	// Whether speech and audio packages available
47 	int SpeechVOX;
48 	int MusicVOX;
49 	// Script global data sizes
50 	int GlScDataSize;
51 	std::vector<int> ScMdDataSize;
52 
53 	PreservedParams();
54 };
55 
56 enum GameViewCamFlags {
57 	kSvgGameAutoRoomView = 0x01
58 };
59 
60 enum CameraSaveFlags {
61 	kSvgCamPosLocked = 0x01
62 };
63 
64 enum ViewportSaveFlags {
65 	kSvgViewportVisible = 0x01
66 };
67 
68 // RestoredData keeps certain temporary data to help with
69 // the restoration process
70 struct RestoredData {
71 	int                     FPS;
72 	// Unserialized bitmaps for dynamic surfaces
73 	std::vector<Bitmap *>    DynamicSurfaces;
74 	// Scripts global data
75 	struct ScriptData {
76 		std::shared_ptr<char> Data;
77 		size_t              Len;
78 
79 		ScriptData();
80 	};
81 	ScriptData              GlobalScript;
82 	std::vector<ScriptData> ScriptModules;
83 	// Room data (has to be be preserved until room is loaded)
84 	PBitmap                 RoomBkgScene[MAX_ROOM_BGFRAMES];
85 	int16_t                 RoomLightLevels[MAX_ROOM_REGIONS];
86 	int32_t                 RoomTintLevels[MAX_ROOM_REGIONS];
87 	int16_t                 RoomZoomLevels1[MAX_WALK_AREAS + 1];
88 	int16_t                 RoomZoomLevels2[MAX_WALK_AREAS + 1];
89 	RoomVolumeMod           RoomVolume;
90 	// Mouse cursor parameters
91 	int                     CursorID;
92 	int                     CursorMode;
93 	// General audio
94 	struct ChannelInfo {
95 		int ClipID = 0;
96 		int Pos = 0;
97 		int Priority = 0;
98 		int Repeat = 0;
99 		int Vol = 0;
100 		int VolAsPercent = 0;
101 		int Pan = 0;
102 		int PanAsPercent = 0;
103 		int Speed = 0;
104 		// since version 1
105 		int XSource = -1;
106 		int YSource = -1;
107 		int MaxDist = 0;
108 	};
109 	ChannelInfo             AudioChans[MAX_SOUND_CHANNELS + 1];
110 	// Ambient sounds
111 	int                     DoAmbient[MAX_SOUND_CHANNELS];
112 	// Viewport and camera data, has to be preserved and applied only after
113 	// room gets loaded, because we must clamp these to room parameters.
114 	struct ViewportData {
115 		int ID = -1;
116 		int Flags = 0;
117 		int Left = 0;
118 		int Top = 0;
119 		int Width = 0;
120 		int Height = 0;
121 		int ZOrder = 0;
122 		int CamID = -1;
123 	};
124 	struct CameraData {
125 		int ID = -1;
126 		int Flags = 0;
127 		int Left = 0;
128 		int Top = 0;
129 		int Width = 0;
130 		int Height = 0;
131 	};
132 	std::vector<ViewportData> Viewports;
133 	std::vector<CameraData> Cameras;
134 	int32_t Camera0_Flags = 0; // flags for primary camera, when data is read in legacy order
135 
136 	RestoredData();
137 };
138 
139 } // namespace Engine
140 } // namespace AGS
141 } // namespace AGS3
142 
143 #endif
144