~ubuntu-branches/ubuntu/raring/scummvm/raring

« back to all changes in this revision

Viewing changes to engines/gob/init.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Moritz Muehlenhoff
  • Date: 2011-05-25 19:02:23 UTC
  • mto: (21.1.2 sid)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: james.westby@ubuntu.com-20110525190223-fiqm0oaec714xk31
Tags: upstream-1.3.0
ImportĀ upstreamĀ versionĀ 1.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * along with this program; if not, write to the Free Software
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
20
 *
21
 
 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/tags/release-1-2-1/engines/gob/init.cpp $
22
 
 * $Id: init.cpp 51869 2010-08-08 00:43:45Z drmccoy $
 
21
 * $URL$
 
22
 * $Id$
23
23
 *
24
24
 */
25
25
 
53
53
}
54
54
 
55
55
void Init::cleanup() {
56
 
        _vm->_video->freeDriver();
57
56
        _vm->_global->_primarySurfDesc.reset();
58
57
 
59
58
        _vm->_sound->speakerOff();
60
59
        _vm->_sound->blasterStop(0);
61
 
        _vm->_dataIO->closeDataFile();
 
60
        _vm->_dataIO->closeArchive(true);
62
61
}
63
62
 
64
63
void Init::doDemo() {
65
64
        if (_vm->isSCNDemo()) {
66
65
                // This is a non-interactive demo with a SCN script and VMD videos
67
66
 
68
 
                _vm->_video->setPrePalette();
69
 
 
70
67
                SCNPlayer scnPlayer(_vm);
71
68
 
72
69
                if (_vm->_demoIndex > 0)
84
81
}
85
82
 
86
83
void Init::initGame() {
87
 
        byte *infBuf;
88
 
        char *infPtr;
89
 
        char *infEnd;
90
 
        char buffer[128];
91
 
 
92
84
        initVideo();
93
85
        updateConfig();
94
86
 
95
87
        if (!_vm->isDemo()) {
96
 
                if (_vm->_dataIO->existData(_vm->_startStk.c_str()))
97
 
                        _vm->_dataIO->openDataFile(_vm->_startStk.c_str());
 
88
                if (_vm->_dataIO->hasFile(_vm->_startStk))
 
89
                        _vm->_dataIO->openArchive(_vm->_startStk, true);
98
90
        }
99
91
 
100
92
        _vm->_util->initInput();
129
121
                return;
130
122
        }
131
123
 
132
 
        if (!_vm->_dataIO->existData("intro.inf")) {
 
124
        Common::SeekableReadStream *infFile = _vm->_dataIO->getFile("intro.inf");
 
125
        if (!infFile) {
133
126
 
134
127
                for (int i = 0; i < 4; i++)
135
128
                        _vm->_draw->loadFont(i, _fontNames[i]);
136
129
 
137
130
        } else {
138
 
                infBuf = _vm->_dataIO->getData("intro.inf");
139
 
                infPtr = (char *)infBuf;
140
 
 
141
 
                infEnd = (char *)(infBuf + _vm->_dataIO->getDataSize("intro.inf"));
142
 
 
143
 
                for (int i = 0; i < 8; i++, infPtr++) {
144
 
                        int j;
145
 
 
146
 
                        for (j = 0; infPtr < infEnd && *infPtr >= ' '; j++, infPtr++)
147
 
                                buffer[j] = *infPtr;
148
 
                        buffer[j] = 0;
149
 
 
150
 
                        strcat(buffer, ".let");
151
 
 
152
 
                        _vm->_draw->loadFont(i, buffer);
153
 
 
154
 
                        if ((infPtr + 1) >= infEnd)
155
 
                                break;
156
 
 
157
 
                        infPtr++;
 
131
 
 
132
                for (int i = 0; i < 8; i++) {
 
133
                        if (infFile->eos())
 
134
                                break;
 
135
 
 
136
                        Common::String font = infFile->readLine();
 
137
                        if (infFile->eos() && font.empty())
 
138
                                break;
 
139
 
 
140
                        font += ".let";
 
141
 
 
142
                        _vm->_draw->loadFont(i, font.c_str());
158
143
                }
159
 
                delete[] infBuf;
 
144
 
 
145
                delete infFile;
160
146
        }
161
147
 
162
 
        if (_vm->_dataIO->existData(_vm->_startTot.c_str())) {
 
148
        if (_vm->_dataIO->hasFile(_vm->_startTot)) {
163
149
                _vm->_inter->allocateVars(Script::getVariablesCount(_vm->_startTot.c_str(), _vm));
164
150
 
165
 
                strcpy(_vm->_game->_curTotFile, _vm->_startTot.c_str());
 
151
                _vm->_game->_curTotFile = _vm->_startTot;
166
152
 
167
153
                _vm->_sound->cdTest(1, "GOB");
168
154
                _vm->_sound->cdLoadLIC("gob.lic");
169
155
 
170
156
                // Search for a Coktel logo animation or image to display
171
 
                if (_vm->_dataIO->existData("coktel.imd")) {
 
157
                if (_vm->_dataIO->hasFile("coktel.imd")) {
172
158
                        _vm->_draw->initScreen();
173
159
                        _vm->_draw->_cursorIndex = -1;
174
160
 
182
168
                        }
183
169
 
184
170
                        _vm->_draw->closeScreen();
185
 
                } else if (_vm->_dataIO->existData("coktel.clt")) {
186
 
                        _vm->_draw->initScreen();
187
 
                        _vm->_util->clearPalette();
188
 
 
189
 
                        DataStream *stream = _vm->_dataIO->getDataStream("coktel.clt");
190
 
                        stream->read((byte *)_vm->_draw->_vgaPalette, 768);
191
 
                        delete stream;
192
 
 
193
 
                        if (_vm->_dataIO->existData("coktel.ims")) {
194
 
                                byte *sprBuf;
195
 
 
196
 
                                sprBuf = _vm->_dataIO->getData("coktel.ims");
197
 
                                _vm->_video->drawPackedSprite(sprBuf, 320, 200, 0, 0, 0,
198
 
                                                *_vm->_draw->_frontSurface);
199
 
                                _vm->_palAnim->fade(_palDesc, 0, 0);
200
 
                                _vm->_util->delay(500);
201
 
 
202
 
                                delete[] sprBuf;
 
171
                } else if (_vm->_dataIO->hasFile("coktel.clt")) {
 
172
                        Common::SeekableReadStream *stream = _vm->_dataIO->getFile("coktel.clt");
 
173
                        if (stream) {
 
174
                                _vm->_draw->initScreen();
 
175
                                _vm->_util->clearPalette();
 
176
 
 
177
                                stream->read((byte *)_vm->_draw->_vgaPalette, 768);
 
178
                                delete stream;
 
179
 
 
180
                                int32 size;
 
181
                                byte *sprite = _vm->_dataIO->getFile("coktel.ims", size);
 
182
                                if (sprite) {
 
183
                                        _vm->_video->drawPackedSprite(sprite, 320, 200, 0, 0, 0,
 
184
                                                        *_vm->_draw->_frontSurface);
 
185
                                        _vm->_palAnim->fade(_palDesc, 0, 0);
 
186
                                        _vm->_util->delay(500);
 
187
 
 
188
                                        delete[] sprite;
 
189
                                }
 
190
 
 
191
                                _vm->_draw->closeScreen();
203
192
                        }
204
 
                        _vm->_draw->closeScreen();
205
193
                }
206
194
 
207
195
                _vm->_game->start();
212
200
        }
213
201
 
214
202
        delete _palDesc;
215
 
        _vm->_dataIO->closeDataFile();
 
203
        _vm->_dataIO->closeArchive(true);
216
204
        _vm->_video->initPrimary(-1);
217
205
        cleanup();
218
206
}