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 DIRECTOR_DIRECTOR_H
24 #define DIRECTOR_DIRECTOR_H
25 
26 #include "common/random.h"
27 #include "common/substream.h"
28 
29 #include "common/hashmap.h"
30 #include "engines/engine.h"
31 #include "director/cast.h"
32 
33 #define CHANNEL_COUNT 30
34 
35 namespace Common {
36 class MacResManager;
37 }
38 
39 namespace Graphics {
40 class MacWindowManager;
41 typedef Common::Array<byte *> MacPatterns;
42 }
43 
44 namespace Director {
45 
46 enum DirectorGameID {
47 	GID_GENERIC,
48 	GID_TEST
49 };
50 
51 class Archive;
52 struct DirectorGameDescription;
53 class DirectorSound;
54 class Lingo;
55 class Score;
56 class Cast;
57 
58 enum {
59 	kDebugLingoExec		= 1 << 0,
60 	kDebugLingoCompile	= 1 << 1,
61 	kDebugLoading		= 1 << 2,
62 	kDebugImages		= 1 << 3,
63 	kDebugText			= 1 << 4,
64 	kDebugEvents		= 1 << 5,
65 	kDebugLingoParse	= 1 << 6
66 };
67 
68 struct MovieReference {
69 	Common::String movie;
70 	Common::String frameS;
71 	int frameI;
72 
MovieReferenceMovieReference73 	MovieReference() { frameI = -1; }
74 };
75 
76 extern byte defaultPalette[768];
77 
78 class DirectorEngine : public ::Engine {
79 public:
80 	DirectorEngine(OSystem *syst, const DirectorGameDescription *gameDesc);
81 	~DirectorEngine();
82 
83 	// Detection related functions
84 
85 	DirectorGameID getGameID() const;
86 	uint16 getVersion() const;
87 	Common::Platform getPlatform() const;
88 	Common::Language getLanguage() const;
89 	Common::String getEXEName() const;
getSoundManager()90 	DirectorSound *getSoundManager() const { return _soundManager; }
getMacWindowManager()91 	Graphics::MacWindowManager *getMacWindowManager() const { return _wm; }
getMainArchive()92 	Archive *getMainArchive() const { return _mainArchive; }
getLingo()93 	Lingo *getLingo() const { return _lingo; }
getCurrentScore()94 	Score *getCurrentScore() const { return _currentScore; }
getSharedScore()95 	Score *getSharedScore() const { return _sharedScore; }
96 	void setPalette(byte *palette, uint16 count);
97 	bool hasFeature(EngineFeature f) const;
getPalette()98 	const byte *getPalette() const { return _currentPalette; }
getPaletteColorCount()99 	uint16 getPaletteColorCount() const { return _currentPaletteLength; }
100 	void loadSharedCastsFrom(Common::String filename);
101 	void loadPatterns();
102 	Graphics::MacPatterns &getPatterns();
103 
104 	void loadInitialMovie(const Common::String movie);
105 	Archive *openMainArchive(const Common::String movie);
106 	Archive *createArchive();
107 	void cleanupMainArchive();
108 
109 	void processEvents(); // evetns.cpp
110 	void setDraggedSprite(uint16 id); // events.cpp
111 
getSharedDIB()112 	Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *getSharedDIB() const { return _sharedDIB; }
getSharedBMP()113 	Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *getSharedBMP() const { return _sharedBMP; }
getSharedSTXT()114 	Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *getSharedSTXT() const { return _sharedSTXT; }
115 	Common::HashMap<int, CastType> *getSharedCastTypes();
116 
117 	Common::HashMap<Common::String, Score *> *_movies;
118 
119 	Common::RandomSource _rnd;
120 	Graphics::MacWindowManager *_wm;
121 
122 public:
123 	int _colorDepth;
124 	unsigned char _key;
125 	int _keyCode;
126 	int _machineType;
127 	bool _playbackPaused;
128 	bool _skipFrameAdvance;
129 
130 	MovieReference _nextMovie;
131 	Common::List<MovieReference> _movieStack;
132 
133 protected:
134 	virtual Common::Error run();
135 
136 private:
137 	const DirectorGameDescription *_gameDescription;
138 
139 	Common::HashMap<Common::String, Score *> *scanMovies(const Common::String &folder);
140 	void loadEXE(const Common::String movie);
141 	void loadEXEv3(Common::SeekableReadStream *stream);
142 	void loadEXEv4(Common::SeekableReadStream *stream);
143 	void loadEXEv5(Common::SeekableReadStream *stream);
144 	void loadEXEv7(Common::SeekableReadStream *stream);
145 	void loadEXERIFX(Common::SeekableReadStream *stream, uint32 offset);
146 	void loadMac(const Common::String movie);
147 
148 	Score *_sharedScore;
149 	Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *_sharedDIB;
150 	Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *_sharedSTXT;
151 	Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *_sharedSound;
152 	Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *_sharedBMP;
153 
154 	Archive *_mainArchive;
155 	Common::MacResManager *_macBinary;
156 	DirectorSound *_soundManager;
157 	byte *_currentPalette;
158 	uint16 _currentPaletteLength;
159 	Lingo *_lingo;
160 
161 	Score *_currentScore;
162 
163 	Graphics::MacPatterns _director3Patterns;
164 	Graphics::MacPatterns _director3QuickDrawPatterns;
165 
166 	Common::String _sharedCastFile;
167 	Common::HashMap<int, CastType> _dummyCastType;
168 
169 	bool _draggingSprite;
170 	uint16 _draggingSpriteId;
171 	Common::Point _draggingSpritePos;
172 
173 private:
174 	void testFontScaling();
175 	void testFonts();
176 };
177 
178 extern DirectorEngine *g_director;
179 
180 } // End of namespace Director
181 
182 #endif
183