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 SAGA2_H
24 #define SAGA2_H
25 
26 #include "common/debug.h"
27 #include "common/random.h"
28 #include "common/serializer.h"
29 #include "common/system.h"
30 
31 #include "engines/engine.h"
32 
33 #include "saga2/console.h"
34 #include "saga2/gfx.h"
35 #include "saga2/idtypes.h"
36 #include "saga2/weapons.h"
37 #include "saga2/vdraw.h"
38 
39 namespace Video {
40 class SmackerDecoder;
41 }
42 
43 namespace Common {
44 class MemoryWriteStreamDynamic;
45 }
46 
47 namespace Saga2 {
48 
49 class ContainerManager;
50 class Timer;
51 class TimerList;
52 class BandList;
53 class ActorAppearance;
54 class PathRequest;
55 class MotionTask;
56 class MotionTaskList;
57 class CMassWeightIndicator;
58 class GrabInfo;
59 class CImageCache;
60 class SensorList;
61 class Sensor;
62 class EffectDisplayPrototypeList;
63 class SpellDisplayPrototypeList;
64 class DisplayNodeList;
65 class SpellDisplayList;
66 class gMousePointer;
67 class ActiveRegion;
68 class gToolBase;
69 class Properties;
70 class PlayerActor;
71 class ProtoObj;
72 class ActorProto;
73 class HandleArray;
74 class TileActivityTaskList;
75 class TaskStackList;
76 class TaskList;
77 class Deejay;
78 class frameSmoother;
79 class frameCounter;
80 class CMapFeature;
81 class AudioInterface;
82 class PaletteManager;
83 class ActorManager;
84 class CalenderTime;
85 class TileModeManager;
86 
87 enum {
88 	kDebugResources = 1 << 0,
89 	kDebugActors    = 1 << 1,
90 	kDebugScripts   = 1 << 2,
91 	kDebugEventLoop = 1 << 3,
92 	kDebugInit      = 1 << 4,
93 	kDebugTiles     = 1 << 5,
94 	kDebugPalettes  = 1 << 6,
95 	kDebugLoading   = 1 << 7,
96 	kDebugTimers    = 1 << 8,
97 	kDebugPath      = 1 << 9,
98 	kDebugTasks     = 1 << 10,
99 	kDebugSound     = 1 << 11,
100 	kDebugSaveload  = 1 << 12,
101 	kDebugSensors   = 1 << 13
102 };
103 
104 #define TICKSPERSECOND (728L/10L)
105 
106 class Saga2Engine : public Engine {
107 public:
108 	Saga2Engine(OSystem *syst);
109 	~Saga2Engine();
110 
111 	Common::Error run() override;
112 	bool hasFeature(EngineFeature f) const override;
canLoadGameStateCurrently()113 	bool canLoadGameStateCurrently() override { return true; }
canSaveGameStateCurrently()114 	bool canSaveGameStateCurrently() override { return true; }
115 	Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
116 	Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
117 	Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave) override;
118 	Common::Error loadGameState(int slot) override;
119 	void syncSoundSettings() override;
120 
121 	Common::String getSavegameFile(int num);
122 
123 	void syncGameStream(Common::Serializer &s);
124 
125 	void loadExeResources();
126 	void freeExeResources();
127 
128 	// itevideo.cpp
129 	void startVideo(const char *fileName, int x, int y);
130 	bool checkVideo(void);
131 	void endVideo(void);
132 	void abortVideo(void);
133 
134 	void readConfig();
135 	void saveConfig();
136 
137 public:
138 	// We need random numbers
139 	Common::RandomSource *_rnd;
140 	Console *_console;
141 	Renderer *_renderer;
142 	AudioInterface *_audio;
143 	PaletteManager *_pal;
144 	ActorManager *_act;
145 	CalenderTime *_calender;
146 	TileModeManager *_tmm;
147 	ContainerManager *_cnm;
148 
149 	WeaponStuff _weaponRack[kMaxWeapons];
150 	weaponID _loadedWeapons;
151 	Common::Array<char *> _nameList;
152 	Common::Array<PlayerActor *> _playerList;
153 	Common::Array<ProtoObj *> _objectProtos;
154 	Common::Array<ActorProto *> _actorProtos;
155 	Common::Array<CMapFeature *> _mapFeatures;
156 	Common::List<TimerList *> _timerLists;
157 	Common::List<Timer *> _timers;
158 	Common::List<ActorAppearance *> _appearanceLRU;
159 	Common::List<PathRequest *> _pathQueue;
160 	Common::List<SensorList *> _sensorListList;
161 	Common::List<Sensor *> _sensorList;
162 	Common::List<CMassWeightIndicator *> _indList;
163 	Common::List<int> _platformLRU;
164 	BandList *_bandList;
165 	MotionTaskList *_mTaskList;
166 	CImageCache *_imageCache;
167 	GrabInfo *_mouseInfo;
168 	EffectDisplayPrototypeList *_edpList;
169 	SpellDisplayPrototypeList *_sdpList;
170 	DisplayNodeList *_mainDisplayList;
171 	SpellDisplayList *_activeSpells;
172 	gMousePointer *_pointer;
173 	ActiveRegion *_activeRegionList;
174 	gToolBase *_toolBase;
175 	Properties *_properties;
176 	HandleArray *_tileImageBanks;
177 	TileActivityTaskList *_aTaskList;
178 	TaskStackList *_stackList;
179 	TaskList *_taskList;
180 	Deejay *_grandMasterFTA;
181 	frameSmoother *_frate;
182 	frameCounter *_lrate;
183 
184 	gDisplayPort _mainPort;
185 	gPort _backPort;
186 	gPixelMap _tileDrawMap;
187 
188 	bool _gameRunning;
189 	bool _autoAggression;
190 	bool _autoWeapon;
191 	bool _showNight;
192 	bool _speechText;
193 	bool _speechVoice;
194 
195 	bool _teleportOnClick;
196 	bool _teleportOnMap;
197 	bool _showPosition;
198 	bool _showStats;
199 
200 	bool _indivControlsFlag;
201 	bool _userControlsSetup;
202 	int _fadeDepth;
203 	int _currentMapNum;
204 
205 
206 private:
207 	Video::SmackerDecoder *_smkDecoder;
208 	int _videoX, _videoY;
209 };
210 
211 extern Saga2Engine *g_vm;
212 
213 } // End of namespace Saga2
214 
215 #endif
216