1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "common/config-manager.h"
#include "common/debug-channels.h"
#include "common/error.h"
#include "graphics/macgui/macwindowmanager.h"
#include "director/director.h"
#include "director/archive.h"
#include "director/sound.h"
#include "director/lingo/lingo.h"
namespace Director {
DirectorEngine *g_director;
DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc),
_rnd("director") {
DebugMan.addDebugChannel(kDebugLingoExec, "lingoexec", "Lingo Execution");
DebugMan.addDebugChannel(kDebugLingoCompile, "lingocompile", "Lingo Compilation");
DebugMan.addDebugChannel(kDebugLoading, "loading", "Loading");
DebugMan.addDebugChannel(kDebugImages, "images", "Image drawing");
DebugMan.addDebugChannel(kDebugText, "text", "Text rendering");
g_director = this;
if (!_mixer->isReady())
error("Sound initialization failed");
// Setup mixer
syncSoundSettings();
// Load Patterns
loadPatterns();
_sharedCasts = nullptr;
_currentScore = nullptr;
_soundManager = nullptr;
_currentPalette = nullptr;
_currentPaletteLength = 0;
_lingo = nullptr;
_sharedCasts = nullptr;
_sharedSound = nullptr;
_sharedBMP = nullptr;
_sharedSTXT = nullptr;
_sharedDIB = nullptr;
_mainArchive = nullptr;
_macBinary = nullptr;
_movies = nullptr;
_wm = nullptr;
const Common::FSNode gameDataDir(ConfMan.get("path"));
SearchMan.addSubDirectoryMatching(gameDataDir, "data");
SearchMan.addSubDirectoryMatching(gameDataDir, "install");
_colorDepth = 8; // 256-color
_key = 0;
_keyCode = 0;
_machineType = 9; // Macintosh IIci
}
DirectorEngine::~DirectorEngine() {
delete _sharedSound;
delete _sharedBMP;
delete _sharedSTXT;
delete _sharedDIB;
delete _currentScore;
cleanupMainArchive();
delete _soundManager;
delete _lingo;
}
Common::Error DirectorEngine::run() {
debug("Starting v%d Director game", getVersion());
_currentPalette = nullptr;
_macBinary = nullptr;
_soundManager = nullptr;
_wm = new Graphics::MacWindowManager;
_lingo = new Lingo(this);
_soundManager = new DirectorSound();
if (getGameID() == GID_TEST) {
_mainArchive = nullptr;
_currentScore = nullptr;
_lingo->runTests();
return Common::kNoError;
}
//FIXME
//_mainArchive = new RIFFArchive();
//_mainArchive->openFile("bookshelf_example.mmm");
//testFont();
if (getPlatform() == Common::kPlatformWindows)
_sharedCastFile = "SHARDCST.MMM";
else
_sharedCastFile = "Shared Cast";
loadSharedCastsFrom(_sharedCastFile);
loadMainArchive();
_currentScore = new Score(this, _mainArchive);
debug(0, "Score name %s", _currentScore->getMacName().c_str());
_currentScore->loadArchive();
_currentScore->startLoop();
return Common::kNoError;
}
Common::HashMap<Common::String, Score *> *DirectorEngine::scanMovies(const Common::String &folder) {
Common::FSNode directory(folder);
Common::FSList movies;
const char *sharedMMMname;
if (getPlatform() == Common::kPlatformWindows)
sharedMMMname = "SHARDCST.MMM";
else
sharedMMMname = "Shared Cast";
Common::HashMap<Common::String, Score *> *nameMap = new Common::HashMap<Common::String, Score *>();
if (!directory.getChildren(movies, Common::FSNode::kListFilesOnly))
return nameMap;
if (!movies.empty()) {
for (Common::FSList::const_iterator i = movies.begin(); i != movies.end(); ++i) {
debugC(2, kDebugLoading, "File: %s", i->getName().c_str());
if (Common::matchString(i->getName().c_str(), sharedMMMname, true)) {
_sharedCastFile = i->getName();
continue;
}
Archive *arc = createArchive();
warning("name: %s", i->getName().c_str());
arc->openFile(i->getName());
Score *sc = new Score(this, arc);
nameMap->setVal(sc->getMacName(), sc);
debugC(2, kDebugLoading, "Movie name: \"%s\"", sc->getMacName().c_str());
}
}
return nameMap;
}
void DirectorEngine::setPalette(byte *palette, uint16 count) {
_currentPalette = palette;
_currentPaletteLength = count;
}
} // End of namespace Director
|