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 #include "hopkins/objects.h"
24 #include "hopkins/dialogs.h"
25 #include "hopkins/files.h"
26 #include "hopkins/globals.h"
27 #include "hopkins/sound.h"
28 #include "hopkins/hopkins.h"
29
30 #include "common/system.h"
31 #include "graphics/palette.h"
32 #include "common/file.h"
33 #include "common/rect.h"
34 #include "engines/util.h"
35
36 namespace Hopkins {
37
ScriptManager(HopkinsEngine * vm)38 ScriptManager::ScriptManager(HopkinsEngine *vm) {
39 _vm = vm;
40 _tempObjectFl = false;
41 }
42
handleOpcode(const byte * dataP)43 int ScriptManager::handleOpcode(const byte *dataP) {
44 if (READ_BE_UINT16(dataP) != MKTAG16('F', 'C'))
45 return 0;
46
47 int opcodeType = 0;
48 int vbobFrameIndex = 0;
49
50 uint32 signature24 = READ_BE_UINT24(&dataP[2]);
51 switch (signature24) {
52 case MKTAG24('T', 'X', 'T'): {
53 vbobFrameIndex = dataP[6];
54 int mesgId = READ_LE_INT16(dataP + 13);
55 opcodeType = 1;
56 if (!_tempObjectFl) {
57 if (_vm->_globals->_saveData->_data[svField356] == 1) {
58 if (mesgId == 53)
59 mesgId = 644;
60 if (mesgId == 624)
61 mesgId = 639;
62 if (mesgId == 627)
63 mesgId = 630;
64 if (mesgId == 625)
65 mesgId = 639;
66 if (mesgId == 8)
67 mesgId = 637;
68 if (mesgId == 557)
69 mesgId = 636;
70 if (mesgId == 51)
71 mesgId = 644;
72 if (mesgId == 287)
73 mesgId = 636;
74 if (mesgId == 619)
75 mesgId = 633;
76 if (mesgId == 620)
77 mesgId = 634;
78 if (mesgId == 622)
79 mesgId = 644;
80 if (mesgId == 297)
81 mesgId = 636;
82 if (mesgId == 612 || mesgId == 613 || mesgId == 614 || mesgId == 134)
83 mesgId = 636;
84 if (mesgId == 615)
85 mesgId = 635;
86 if (mesgId == 618)
87 mesgId = 632;
88 if (mesgId == 611)
89 mesgId = 642;
90 if (mesgId == 610)
91 mesgId = 641;
92 if (mesgId == 18)
93 mesgId = 643;
94 if (mesgId == 602)
95 mesgId = 645;
96 if (mesgId == 603)
97 mesgId = 646;
98 if (mesgId == 604)
99 mesgId = 647;
100 if (mesgId == 607)
101 mesgId = 650;
102 if (mesgId == 605)
103 mesgId = 648;
104 if (mesgId == 606)
105 mesgId = 649;
106 if (mesgId == 601)
107 mesgId = 652;
108 if (mesgId == 37)
109 mesgId = 636;
110 if (mesgId == 595)
111 mesgId = 633;
112 if (mesgId == 596)
113 mesgId = 634;
114 if (mesgId == 532)
115 mesgId = 636;
116 if (mesgId == 599)
117 mesgId = 636;
118 if (mesgId == 363)
119 mesgId = 636;
120 }
121 if (!_vm->_soundMan->_soundOffFl && _vm->_soundMan->_soundFl) {
122 do {
123 if (_vm->shouldQuit())
124 return -1; // Exiting game
125 _vm->_events->refreshScreenAndEvents();
126 } while (_vm->_soundMan->_soundFl);
127 }
128 bool displayedTxtFl = false;
129 if (!_vm->_soundMan->_textOffFl) {
130 int textPosX = READ_LE_INT16(dataP + 9);
131 int textPosY = READ_LE_INT16(dataP + 11);
132 _vm->_fontMan->initTextBuffers(9, mesgId, _vm->_globals->_textFilename, 2 * textPosX, 2 * textPosY + 40, 6, dataP[7], 253);
133 _vm->_fontMan->showText(9);
134 displayedTxtFl = true;
135 }
136 if (!_vm->_soundMan->_voiceOffFl)
137 _vm->_soundMan->mixVoice(mesgId, 4, displayedTxtFl);
138 } else { // if (_tempObjectFl)
139 if (_vm->_globals->_saveData->_data[svField356]) {
140 _vm->_fontMan->initTextBuffers(9, 635, _vm->_globals->_textFilename, 55, 20, dataP[8], 35, 253);
141 bool displayedTxtFl = false;
142 if (!_vm->_soundMan->_textOffFl) {
143 _vm->_fontMan->showText(9);
144 displayedTxtFl = true;
145 }
146
147 if (!_vm->_soundMan->_voiceOffFl)
148 _vm->_soundMan->mixVoice(635, 4, displayedTxtFl);
149 } else {
150 int textPosX = READ_LE_INT16(dataP + 9);
151 if (!_vm->_soundMan->_textOffFl) {
152 switch (_vm->_globals->_language) {
153 case LANG_FR:
154 _vm->_fontMan->initTextBuffers(9, mesgId, "OBJET1.TXT", 2 * textPosX, 60, 6, dataP[7], 253);
155 break;
156 case LANG_EN:
157 _vm->_fontMan->initTextBuffers(9, mesgId, "OBJETAN.TXT", 2 * textPosX, 60, 6, dataP[7], 253);
158 break;
159 case LANG_SP:
160 _vm->_fontMan->initTextBuffers(9, mesgId, "OBJETES.TXT", 2 * textPosX, 60, 6, dataP[7], 253);
161 break;
162 default:
163 break;
164 }
165 }
166
167 bool displayedTxtFl = false;
168 if (!_vm->_soundMan->_textOffFl) {
169 _vm->_fontMan->showText(9);
170 displayedTxtFl = true;
171 }
172
173 if (!_vm->_soundMan->_voiceOffFl)
174 _vm->_soundMan->mixVoice(mesgId, 5, displayedTxtFl);
175 }
176 }
177 break;
178 }
179 case MKTAG24('B', 'O', 'B'):
180 if (!_vm->_objectsMan->_disableFl) {
181 int vbobIdx = dataP[5];
182 vbobFrameIndex = dataP[6];
183 int moveChange = dataP[7];
184 int vbobPosX = READ_LE_INT16(dataP + 8);
185 int vbobPosY = READ_LE_INT16(dataP + 10);
186 if (vbobIdx == 52) {
187 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, vbobPosX, READ_LE_INT16(dataP + 10), vbobFrameIndex);
188 } else if (vbobIdx == 51) {
189 _vm->_objectsMan->quickDisplayBobSprite(vbobFrameIndex);
190 } else if (vbobIdx != 50) {
191 _vm->_objectsMan->initVbob(_vm->_globals->_levelSpriteBuf, vbobIdx, vbobPosX, vbobPosY, vbobFrameIndex);
192 if (moveChange)
193 moveChange /= _vm->_globals->_speed;
194 if (moveChange > 1) {
195 do {
196 if (_vm->shouldQuit())
197 return -1; // Exiting game
198
199 --moveChange;
200 _vm->_events->refreshScreenAndEvents();
201 } while (moveChange);
202 }
203 }
204 }
205 opcodeType = 1;
206 break;
207 case MKTAG24('S', 'T', 'P'):
208 if (!_vm->_objectsMan->_disableFl) {
209 // HACK: This piece of code is a replacement to the missing STE opcode when entering the FBI lab.
210 if (_vm->_globals->_curRoomNum == 10) {
211 _vm->_globals->_prevScreenId = _vm->_globals->_screenId;
212 _vm->_globals->_saveData->_data[svLastPrevScreenId] = _vm->_globals->_screenId;
213 _vm->_globals->_screenId = _vm->_globals->_saveData->_data[svLastScreenId] = 10;
214 }
215 _vm->_objectsMan->_twoCharactersFl = false;
216 _vm->_objectsMan->_characterPos.x = READ_LE_INT16(dataP + 6);
217 _vm->_objectsMan->_characterPos.y = READ_LE_INT16(dataP + 8);
218 _vm->_objectsMan->_startSpriteIndex = dataP[5];
219 if (_vm->_objectsMan->_changeHeadFl) {
220 if (_vm->_globals->_saveData->_data[svField354] == 1
221 && _vm->_globals->_saveData->_cloneHopkins._pos.x && _vm->_globals->_saveData->_cloneHopkins._pos.y
222 && _vm->_globals->_saveData->_cloneHopkins._startSpriteIndex && _vm->_globals->_saveData->_cloneHopkins._location) {
223
224 _vm->_objectsMan->_characterPos = _vm->_globals->_saveData->_cloneHopkins._pos;
225 _vm->_objectsMan->_startSpriteIndex = _vm->_globals->_saveData->_cloneHopkins._startSpriteIndex;
226 }
227 if (_vm->_globals->_saveData->_data[svField356] == 1
228 && _vm->_globals->_saveData->_samantha._pos.x && _vm->_globals->_saveData->_samantha._pos.y
229 && _vm->_globals->_saveData->_samantha._startSpriteIndex && _vm->_globals->_saveData->_samantha._location) {
230 _vm->_objectsMan->_characterPos = _vm->_globals->_saveData->_samantha._pos;
231 _vm->_objectsMan->_startSpriteIndex = _vm->_globals->_saveData->_samantha._startSpriteIndex;
232 }
233 if (_vm->_globals->_saveData->_data[svField357] == 1
234 && _vm->_globals->_saveData->_realHopkins._pos.x && _vm->_globals->_saveData->_realHopkins._pos.y
235 && _vm->_globals->_saveData->_realHopkins._startSpriteIndex && _vm->_globals->_saveData->_realHopkins._location) {
236 _vm->_objectsMan->_characterPos = _vm->_globals->_saveData->_realHopkins._pos;
237 _vm->_objectsMan->_startSpriteIndex = _vm->_globals->_saveData->_realHopkins._startSpriteIndex;
238 }
239 }
240 if (_vm->_globals->_saveData->_data[svField356] == 1
241 && _vm->_globals->_saveData->_realHopkins._location == _vm->_globals->_screenId) {
242 _vm->_objectsMan->addStaticSprite(
243 _vm->_objectsMan->_headSprites,
244 _vm->_globals->_saveData->_realHopkins._pos,
245 1,
246 2,
247 _vm->_globals->_saveData->_realHopkins._zoomFactor,
248 false,
249 34,
250 190);
251 _vm->_objectsMan->animateSprite(1);
252 _vm->_objectsMan->_twoCharactersFl = true;
253 }
254 if (_vm->_globals->_saveData->_data[svField357] == 1
255 && _vm->_globals->_saveData->_data[svField355] == 1
256 && _vm->_globals->_saveData->_samantha._location == _vm->_globals->_screenId) {
257 _vm->_objectsMan->addStaticSprite(
258 _vm->_objectsMan->_headSprites,
259 _vm->_globals->_saveData->_samantha._pos,
260 1,
261 3,
262 _vm->_globals->_saveData->_samantha._zoomFactor,
263 false,
264 20,
265 127);
266 _vm->_objectsMan->animateSprite(1);
267 _vm->_objectsMan->_twoCharactersFl = true;
268 }
269 }
270 opcodeType = 1;
271 _vm->_objectsMan->_changeHeadFl = false;
272 break;
273 case MKTAG24('S', 'T', 'E'):
274 if (!_vm->_objectsMan->_disableFl) {
275 _vm->_globals->_prevScreenId = _vm->_globals->_screenId;
276 _vm->_globals->_saveData->_data[svLastPrevScreenId] = _vm->_globals->_screenId;
277 _vm->_globals->_screenId = _vm->_globals->_saveData->_data[svLastScreenId] = dataP[5];
278 vbobFrameIndex = dataP[6];
279 }
280 opcodeType = 1;
281 break;
282 case MKTAG24('B', 'O', 'F'):
283 if (!_vm->_objectsMan->_disableFl)
284 _vm->_objectsMan->disableVbob(READ_LE_INT16(dataP + 5));
285 opcodeType = 1;
286 break;
287 case MKTAG24('P', 'E', 'R'): {
288 int specialOpcode = READ_LE_INT16(dataP + 5);
289 if (!_vm->_globals->_saveData->_data[svAlternateSpriteFl] && !_vm->_globals->_saveData->_data[svField356]) {
290 vbobFrameIndex = 0;
291
292 switch (specialOpcode) {
293 case 1:
294 case 14:
295 if (_vm->_globals->_actionDirection == DIR_UP)
296 _vm->_objectsMan->doActionBack(4);
297 if (_vm->_globals->_actionDirection == DIR_RIGHT)
298 _vm->_objectsMan->doActionRight(4);
299 if (_vm->_globals->_actionDirection == DIR_UP_RIGHT)
300 _vm->_objectsMan->doActionDiagRight(4);
301 if (_vm->_globals->_actionDirection == DIR_DOWN)
302 _vm->_objectsMan->doActionFront(4);
303 if (_vm->_globals->_actionDirection == DIR_UP_LEFT)
304 _vm->_objectsMan->doActionDiagLeft(4);
305 if (_vm->_globals->_actionDirection == DIR_LEFT)
306 _vm->_objectsMan->doActionLeft(4);
307 break;
308 case 2:
309 if (_vm->_globals->_actionDirection == DIR_UP)
310 _vm->_objectsMan->doActionBack(7);
311 if (_vm->_globals->_actionDirection == DIR_RIGHT)
312 _vm->_objectsMan->doActionRight(7);
313 if (_vm->_globals->_actionDirection == DIR_UP_RIGHT)
314 _vm->_objectsMan->doActionDiagRight(7);
315 if (_vm->_globals->_actionDirection == DIR_DOWN)
316 _vm->_objectsMan->doActionFront(7);
317 if (_vm->_globals->_actionDirection == DIR_UP_LEFT)
318 _vm->_objectsMan->doActionDiagLeft(7);
319 if (_vm->_globals->_actionDirection == DIR_LEFT)
320 _vm->_objectsMan->doActionLeft(7);
321 if (_vm->_globals->_actionDirection == DIR_UP)
322 _vm->_objectsMan->doActionBack(8);
323 if (_vm->_globals->_actionDirection == DIR_RIGHT)
324 _vm->_objectsMan->doActionRight(8);
325 if (_vm->_globals->_actionDirection == DIR_UP_RIGHT)
326 _vm->_objectsMan->doActionDiagRight(8);
327 if (_vm->_globals->_actionDirection == DIR_DOWN)
328 _vm->_objectsMan->doActionFront(8);
329 if (_vm->_globals->_actionDirection == DIR_UP_LEFT)
330 _vm->_objectsMan->doActionDiagLeft(8);
331 if (_vm->_globals->_actionDirection == DIR_LEFT)
332 _vm->_objectsMan->doActionLeft(8);
333 break;
334 case 19:
335 case 4:
336 if (_vm->_globals->_actionDirection == DIR_UP)
337 _vm->_objectsMan->doActionBack(1);
338 if (_vm->_globals->_actionDirection == DIR_RIGHT)
339 _vm->_objectsMan->doActionRight(1);
340 if (_vm->_globals->_actionDirection == DIR_UP_RIGHT)
341 _vm->_objectsMan->doActionDiagRight(1);
342 if (_vm->_globals->_actionDirection == DIR_DOWN)
343 _vm->_objectsMan->doActionFront(1);
344 if (_vm->_globals->_actionDirection == DIR_UP_LEFT)
345 _vm->_objectsMan->doActionDiagLeft(1);
346 if (_vm->_globals->_actionDirection == DIR_LEFT)
347 _vm->_objectsMan->doActionLeft(1);
348 break;
349 case 5:
350 if (_vm->_globals->_actionDirection == DIR_UP)
351 _vm->_objectsMan->doActionBack(5);
352 if (_vm->_globals->_actionDirection == DIR_RIGHT)
353 _vm->_objectsMan->doActionRight(5);
354 if (_vm->_globals->_actionDirection == DIR_UP_RIGHT)
355 _vm->_objectsMan->doActionDiagRight(5);
356 if (_vm->_globals->_actionDirection == DIR_DOWN)
357 _vm->_objectsMan->doActionFront(5);
358 if (_vm->_globals->_actionDirection == DIR_UP_LEFT)
359 _vm->_objectsMan->doActionDiagLeft(5);
360 if (_vm->_globals->_actionDirection == DIR_LEFT)
361 _vm->_objectsMan->doActionLeft(5);
362 if (_vm->_globals->_actionDirection == DIR_UP)
363 _vm->_objectsMan->doActionBack(6);
364 if (_vm->_globals->_actionDirection == DIR_RIGHT)
365 _vm->_objectsMan->doActionRight(6);
366 if (_vm->_globals->_actionDirection == DIR_UP_RIGHT)
367 _vm->_objectsMan->doActionDiagRight(6);
368 if (_vm->_globals->_actionDirection == DIR_DOWN)
369 _vm->_objectsMan->doActionFront(6);
370 if (_vm->_globals->_actionDirection == DIR_UP_LEFT)
371 _vm->_objectsMan->doActionDiagLeft(6);
372 if (_vm->_globals->_actionDirection == DIR_LEFT)
373 _vm->_objectsMan->doActionLeft(6);
374 break;
375 case 17:
376 case 7:
377 if (_vm->_globals->_actionDirection == DIR_UP)
378 _vm->_objectsMan->doActionBack(2);
379 if (_vm->_globals->_actionDirection == DIR_RIGHT)
380 _vm->_objectsMan->doActionRight(2);
381 if (_vm->_globals->_actionDirection == DIR_UP_RIGHT)
382 _vm->_objectsMan->doActionDiagRight(2);
383 if (_vm->_globals->_actionDirection == DIR_DOWN)
384 _vm->_objectsMan->doActionFront(2);
385 if (_vm->_globals->_actionDirection == DIR_UP_LEFT)
386 _vm->_objectsMan->doActionDiagLeft(2);
387 if (_vm->_globals->_actionDirection == DIR_LEFT)
388 _vm->_objectsMan->doActionLeft(2);
389 break;
390 case 18:
391 case 8:
392 if (_vm->_globals->_actionDirection == DIR_UP)
393 _vm->_objectsMan->doActionBack(3);
394 if (_vm->_globals->_actionDirection == DIR_RIGHT)
395 _vm->_objectsMan->doActionRight(3);
396 if (_vm->_globals->_actionDirection == DIR_UP_RIGHT)
397 _vm->_objectsMan->doActionDiagRight(3);
398 if (_vm->_globals->_actionDirection == DIR_DOWN)
399 _vm->_objectsMan->doActionFront(3);
400 if (_vm->_globals->_actionDirection == DIR_UP_LEFT)
401 _vm->_objectsMan->doActionDiagLeft(3);
402 if (_vm->_globals->_actionDirection == DIR_LEFT)
403 _vm->_objectsMan->doActionLeft(3);
404 break;
405 case 9:
406 if (_vm->_globals->_actionDirection == DIR_UP)
407 _vm->_objectsMan->doActionBack(5);
408 if (_vm->_globals->_actionDirection == DIR_RIGHT)
409 _vm->_objectsMan->doActionRight(5);
410 if (_vm->_globals->_actionDirection == DIR_UP_RIGHT)
411 _vm->_objectsMan->doActionDiagRight(5);
412 if (_vm->_globals->_actionDirection == DIR_DOWN)
413 _vm->_objectsMan->doActionFront(5);
414 if (_vm->_globals->_actionDirection == DIR_UP_LEFT)
415 _vm->_objectsMan->doActionDiagLeft(5);
416 if (_vm->_globals->_actionDirection == DIR_LEFT)
417 _vm->_objectsMan->doActionLeft(5);
418 break;
419 case 10:
420 if (_vm->_globals->_actionDirection == DIR_UP)
421 _vm->_objectsMan->doActionBack(6);
422 if (_vm->_globals->_actionDirection == DIR_RIGHT)
423 _vm->_objectsMan->doActionRight(6);
424 if (_vm->_globals->_actionDirection == DIR_UP_RIGHT)
425 _vm->_objectsMan->doActionDiagRight(6);
426 if (_vm->_globals->_actionDirection == DIR_DOWN)
427 _vm->_objectsMan->doActionFront(6);
428 if (_vm->_globals->_actionDirection == DIR_UP_LEFT)
429 _vm->_objectsMan->doActionDiagLeft(6);
430 if (_vm->_globals->_actionDirection == DIR_LEFT)
431 _vm->_objectsMan->doActionLeft(6);
432 break;
433 case 15:
434 case 11:
435 if (_vm->_globals->_actionDirection == DIR_UP)
436 _vm->_objectsMan->doActionBack(7);
437 if (_vm->_globals->_actionDirection == DIR_RIGHT)
438 _vm->_objectsMan->doActionRight(7);
439 if (_vm->_globals->_actionDirection == DIR_UP_RIGHT)
440 _vm->_objectsMan->doActionDiagRight(7);
441 if (_vm->_globals->_actionDirection == DIR_DOWN)
442 _vm->_objectsMan->doActionFront(7);
443 if (_vm->_globals->_actionDirection == DIR_UP_LEFT)
444 _vm->_objectsMan->doActionDiagLeft(7);
445 if (_vm->_globals->_actionDirection == DIR_LEFT)
446 _vm->_objectsMan->doActionLeft(7);
447 break;
448 case 16:
449 case 12:
450 if (_vm->_globals->_actionDirection == DIR_UP)
451 _vm->_objectsMan->doActionBack(8);
452 if (_vm->_globals->_actionDirection == DIR_RIGHT)
453 _vm->_objectsMan->doActionRight(8);
454 if (_vm->_globals->_actionDirection == DIR_UP_RIGHT)
455 _vm->_objectsMan->doActionDiagRight(8);
456 if (_vm->_globals->_actionDirection == DIR_DOWN)
457 _vm->_objectsMan->doActionFront(8);
458 if (_vm->_globals->_actionDirection == DIR_UP_LEFT)
459 _vm->_objectsMan->doActionDiagLeft(8);
460 if (_vm->_globals->_actionDirection == DIR_LEFT)
461 _vm->_objectsMan->doActionLeft(8);
462 break;
463 default:
464 break;
465 }
466 }
467 opcodeType = 1;
468 break;
469 }
470 case MKTAG24('M', 'U', 'S'):
471 opcodeType = 1;
472 break;
473 case MKTAG24('W', 'A', 'I'): {
474 uint frameNumb = READ_LE_UINT16(dataP + 5) / _vm->_globals->_speed;
475 if (!frameNumb)
476 frameNumb = 1;
477 for (uint i = 0; i < frameNumb + 1; i++) {
478 if (_vm->shouldQuit())
479 return -1; // Exiting game
480
481 _vm->_events->refreshScreenAndEvents();
482 }
483 opcodeType = 1;
484 break;
485 }
486 case MKTAG24('O', 'B', 'P'):
487 opcodeType = 1;
488 _vm->_objectsMan->addObject(READ_LE_INT16(dataP + 5));
489 break;
490 case MKTAG24('O', 'B', 'M'):
491 opcodeType = 1;
492 _vm->_objectsMan->removeObject(READ_LE_INT16(dataP + 5));
493 break;
494 case MKTAG24('G', 'O', 'T'):
495 opcodeType = 2;
496 break;
497 case MKTAG24('Z', 'O', 'N'):
498 _vm->_linesMan->enableZone(READ_LE_INT16(dataP + 5));
499 opcodeType = 1;
500 break;
501 case MKTAG24('Z', 'O', 'F'):
502 _vm->_linesMan->disableZone(READ_LE_INT16(dataP + 5));
503 opcodeType = 1;
504 break;
505 case MKTAG24('E', 'X', 'I'):
506 opcodeType = 5;
507 break;
508 case MKTAG24('S', 'O', 'R'):
509 _vm->_globals->_exitId = READ_LE_INT16(dataP + 5);
510 opcodeType = 5;
511 break;
512 case MKTAG24('B', 'C', 'A'):
513 _vm->_objectsMan->disableHidingItem(READ_LE_INT16(dataP + 5));
514 opcodeType = 1;
515 break;
516 case MKTAG24('A', 'N', 'I'): {
517 int animId = READ_LE_INT16(dataP + 5);
518 if (animId <= 100)
519 _vm->_objectsMan->setBobAnimation(animId);
520 else
521 _vm->_objectsMan->stopBobAnimation(animId - 100);
522 opcodeType = 1;
523 break;
524 }
525 case MKTAG24('S', 'P', 'E'):
526 switch (READ_LE_INT16(dataP + 5)) {
527 case 6:
528 _vm->_objectsMan->removeSprite(0);
529 _vm->_objectsMan->setAndPlayAnim(20, 0, 14, true);
530 break;
531
532 case 7:
533 _vm->_talkMan->startAnimatedCharacterDialogue("rueh1.pe2");
534 break;
535
536 case 8:
537 _vm->_talkMan->startAnimatedCharacterDialogue("ruef1.pe2");
538 break;
539
540 case 10:
541 _vm->_talkMan->startAnimatedCharacterDialogue("bqeflic1.pe2");
542 break;
543
544 case 11:
545 _vm->_talkMan->startAnimatedCharacterDialogue("bqeflic2.pe2");
546 break;
547
548 case 12:
549 // Bank - negotiations between Hopkins and one of the killers
550 _vm->_fontMan->hideText(9);
551 _vm->_events->refreshScreenAndEvents();
552 _vm->_events->refreshScreenAndEvents();
553 _vm->_talkMan->startAnimatedCharacterDialogue("bqetueur.pe2");
554 break;
555
556 case 13:
557 // Bank - after negotiations, Hopkins enters the bank
558 _vm->_events->_mouseButton = _vm->_events->_curMouseButton;
559 _vm->_globals->_disableInventFl = true;
560 _vm->_graphicsMan->fadeOutLong();
561 _vm->_objectsMan->disableHidingBehavior();
562 _vm->_objectsMan->removeSprite(0);
563 _vm->_fontMan->hideText(5);
564 _vm->_fontMan->hideText(9);
565 _vm->_graphicsMan->endDisplayBob();
566 _vm->_objectsMan->clearScreen();
567
568 if ((_vm->getPlatform() != Common::kPlatformWindows) || !_vm->getIsDemo()) {
569 _vm->_soundMan->playSoundFile("SOUND17.WAV");
570 _vm->_graphicsMan->_fadingFl = true;
571 _vm->_animMan->playSequence2("HELICO.SEQ", 10, 4, 10);
572 }
573
574 _vm->_animMan->loadAnim("otage");
575 _vm->_graphicsMan->loadImage("IM05");
576 _vm->_graphicsMan->displayAllBob();
577
578 for (int i = 0; i <= 4; i++) {
579 if (_vm->shouldQuit())
580 return -1; // Exiting game
581
582 _vm->_events->refreshScreenAndEvents();
583 }
584
585 _vm->_events->mouseOff();
586 _vm->_graphicsMan->fadeInDefaultLength(_vm->_graphicsMan->_frontBuffer);
587 do {
588 if (_vm->shouldQuit())
589 return -1; // Exiting game
590
591 _vm->_events->refreshScreenAndEvents();
592 } while (_vm->_objectsMan->getBobAnimDataIdx(3) != 100);
593 _vm->_graphicsMan->fadeOutDefaultLength(_vm->_graphicsMan->_frontBuffer);
594 _vm->_graphicsMan->endDisplayBob();
595
596 // If uncensored, rip the throat of the hostage
597 if (!_vm->_globals->_censorshipFl) {
598 _vm->_soundMan->_specialSoundNum = 16;
599 _vm->_graphicsMan->_fadingFl = true;
600 _vm->_animMan->playAnim("EGORGE.ANM", "EGORGE.ANM", 50, 28, 500);
601 _vm->_soundMan->_specialSoundNum = 0;
602 }
603 _vm->_animMan->loadAnim("ASCEN");
604 _vm->_events->mouseOff();
605 _vm->_graphicsMan->loadImage("ASCEN");
606 _vm->_graphicsMan->displayAllBob();
607
608 for (int i = 0; i <= 4; i++) {
609 if (_vm->shouldQuit())
610 return -1; // Exiting game
611
612 _vm->_events->refreshScreenAndEvents();
613 }
614
615 _vm->_events->mouseOff();
616 _vm->_graphicsMan->fadeInDefaultLength(_vm->_graphicsMan->_frontBuffer);
617 _vm->_objectsMan->checkEventBobAnim(1, 0, 17, 3);
618 _vm->_graphicsMan->fadeOutDefaultLength(_vm->_graphicsMan->_frontBuffer);
619 _vm->_graphicsMan->endDisplayBob();
620
621 if ((_vm->getPlatform() == Common::kPlatformWindows) && _vm->getIsDemo())
622 _vm->_soundMan->playSoundFile("SOUND17.WAV");
623
624 _vm->_soundMan->_specialSoundNum = 14;
625 _vm->_graphicsMan->_fadingFl = true;
626 _vm->_animMan->playSequence2("ASSOM.SEQ", 10, 4, 500);
627 _vm->_soundMan->_specialSoundNum = 0;
628 _vm->_globals->_disableInventFl = false;
629 _vm->_objectsMan->_helicopterFl = true;
630 break;
631
632 case 16:
633 _vm->_talkMan->startAnimatedCharacterDialogue("ftoubib.pe2");
634 break;
635
636 case 17:
637 _vm->_talkMan->startAnimatedCharacterDialogue("flic2b.pe2");
638 break;
639
640 case 18:
641 _vm->_talkMan->startAnimatedCharacterDialogue("fjour.pe2");
642 break;
643
644 case 20:
645 _vm->_talkMan->startAnimatedCharacterDialogue("PUNK.pe2");
646 break;
647
648 case 21:
649 _vm->_talkMan->startAnimatedCharacterDialogue("MEDLEG.pe2");
650 break;
651
652 case 22:
653 _vm->_talkMan->animateObject("CADAVRE1.pe2");
654 break;
655
656 case 23:
657 _vm->_talkMan->startStaticCharacterDialogue("CHERCHE1.pe2");
658 break;
659
660 case 25:
661 _vm->_talkMan->startAnimatedCharacterDialogue("AGENT1.pe2");
662 break;
663
664 case 26:
665 _vm->_talkMan->startAnimatedCharacterDialogue("AGENT2.pe2");
666 break;
667
668 case 27:
669 if (_vm->_globals->_saveData->_data[svField94] != 1 || _vm->_globals->_saveData->_data[svField95] != 1)
670 _vm->_talkMan->startAnimatedCharacterDialogue("STANDAR.pe2");
671 else
672 _vm->_talkMan->startAnimatedCharacterDialogue("STANDAR1.pe2");
673 break;
674
675 case 29:
676 _vm->_globals->_disableInventFl = true;
677 _vm->_talkMan->animateObject("TELEP.pe2");
678 _vm->_globals->_disableInventFl = false;
679 break;
680
681 case 32:
682 _vm->_talkMan->startAnimatedCharacterDialogue("SAMAN.pe2");
683 break;
684
685 case 35:
686 if (!_vm->_soundMan->_soundOffFl) {
687 do {
688 if (_vm->shouldQuit())
689 return -1; // Exiting game
690
691 _vm->_events->refreshScreenAndEvents();
692 } while (_vm->_soundMan->_soundFl);
693 }
694 _vm->_talkMan->startAnimatedCharacterDialogue("PTLAB.pe2");
695 break;
696
697 case 36:
698 if (_vm->_globals->_saveData->_data[svField270] == 2 && _vm->_globals->_saveData->_data[svField94] == 1 && _vm->_globals->_saveData->_data[svField95] == 1)
699 _vm->_globals->_saveData->_data[svField270] = 3;
700
701 switch (_vm->_globals->_saveData->_data[svField270]) {
702 case 0:
703 _vm->_talkMan->startStaticCharacterDialogue("PATRON0.pe2");
704 break;
705 case 1:
706 _vm->_talkMan->startStaticCharacterDialogue("PATRON1.pe2");
707 break;
708 case 2:
709 _vm->_talkMan->startStaticCharacterDialogue("PATRON2.pe2");
710 break;
711 case 3:
712 _vm->_talkMan->startStaticCharacterDialogue("PATRON3.pe2");
713 break;
714 default:
715 if (_vm->_globals->_saveData->_data[svField270] > 3) {
716 _vm->_talkMan->startStaticCharacterDialogue("PATRON4.pe2");
717 _vm->_globals->_saveData->_data[svField270] = 5;
718 }
719 break;
720 }
721 break;
722
723 case 37:
724 _vm->_graphicsMan->_fadingFl = true;
725 _vm->_animMan->playSequence2("corde.SEQ", 32, 32, 100);
726 _vm->_graphicsMan->_noFadingFl = true;
727 break;
728
729 case 38:
730 _vm->_soundMan->loadSample(1, "SOUND44.WAV");
731 _vm->_soundMan->loadSample(2, "SOUND42.WAV");
732 _vm->_soundMan->loadSample(3, "SOUND41.WAV");
733 _vm->_soundMan->_specialSoundNum = 17;
734 _vm->_animMan->playSequence("grenade.SEQ", 1, 32, 100, false, false);
735 _vm->_soundMan->_specialSoundNum = 0;
736 _vm->_graphicsMan->_fadingFl = true;
737 _vm->_animMan->playAnim("CREVE17.ANM", "CREVE17.ANM", 24, 24, 200);
738 _vm->_soundMan->removeSample(1);
739 _vm->_soundMan->removeSample(2);
740 _vm->_soundMan->removeSample(3);
741 _vm->_graphicsMan->_noFadingFl = true;
742 break;
743
744 case 40:
745 _vm->_talkMan->startAnimatedCharacterDialogue("MAGE.pe2");
746 break;
747
748 case 41:
749 _vm->_talkMan->startAnimatedCharacterDialogue("MORT3.pe2");
750 break;
751
752 case 42:
753 _vm->_talkMan->startAnimatedCharacterDialogue("MORT2.pe2");
754 break;
755
756 case 43:
757 _vm->_talkMan->startAnimatedCharacterDialogue("MORT1.pe2");
758 break;
759
760 case 44:
761 _vm->_talkMan->startAnimatedCharacterDialogue("MORT3A.pe2");
762 break;
763
764 case 45:
765 _vm->_talkMan->startAnimatedCharacterDialogue("FEM3.pe2");
766 break;
767
768 case 46: {
769 _vm->_globals->_checkDistanceFl = true;
770 _vm->_linesMan->_route = (RouteItem *)NULL;
771 _vm->_linesMan->_route = _vm->_linesMan->findRoute(_vm->_objectsMan->getSpriteX(0), _vm->_objectsMan->getSpriteY(0), 564, 420);
772 _vm->_objectsMan->_zoneNum = -1;
773 do {
774 if (_vm->shouldQuit())
775 return -1; // Exiting game
776
777 _vm->_objectsMan->goHome();
778 _vm->_events->refreshScreenAndEvents();
779 } while (_vm->_linesMan->_route != (RouteItem *)NULL);
780 _vm->_objectsMan->removeSprite(0);
781 _vm->_globals->_checkDistanceFl = true;
782 _vm->_soundMan->loadSample(1, "SOUND44.WAV");
783 _vm->_soundMan->loadSample(2, "SOUND45.WAV");
784 _vm->_objectsMan->setMultiBobAnim(9, 10, 0, 0);
785 bool playFl = false;
786 for (;;) {
787 if (_vm->shouldQuit())
788 return -1; // Exiting game
789
790 switch (_vm->_objectsMan->getBobAnimDataIdx(9)) {
791 case 4:
792 case 16:
793 case 28:
794 if (!playFl) {
795 _vm->_soundMan->playSample(1);
796 playFl = true;
797 }
798 break;
799 case 5:
800 case 17:
801 case 29:
802 playFl = false;
803 break;
804 default:
805 break;
806 }
807
808 switch (_vm->_objectsMan->getBobAnimDataIdx(10)) {
809 case 10:
810 case 22:
811 case 33:
812 if (!playFl) {
813 _vm->_soundMan->playSample(2);
814 playFl = true;
815 }
816 break;
817 case 11:
818 playFl = false;
819 break;
820 case 12:
821 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 513, 249, 1);
822 break;
823 case 23:
824 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 513, 249, 2);
825 playFl = false;
826 break;
827 case 34:
828 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 513, 249, 3);
829 playFl = false;
830 break;
831 default:
832 break;
833 }
834 _vm->_events->refreshScreenAndEvents();
835 if (_vm->_objectsMan->getBobAnimDataIdx(9) == 36)
836 break;
837 }
838 _vm->_objectsMan->animateSprite(0);
839 _vm->_objectsMan->stopBobAnimation(9);
840 _vm->_objectsMan->stopBobAnimation(10);
841 _vm->_soundMan->removeSample(1);
842 _vm->_soundMan->removeSample(2);
843 break;
844 }
845
846 case 47:
847 _vm->_talkMan->startAnimatedCharacterDialogue("BARMAN.pe2");
848 break;
849
850 case 48:
851 _vm->_talkMan->startAnimatedCharacterDialogue("SAMAN2.pe2");
852 break;
853
854 case 49: {
855 _vm->_objectsMan->disableHidingBehavior();
856 _vm->_objectsMan->removeSprite(0);
857 _vm->_objectsMan->setMultiBobAnim(9, 10, 0, 0);
858
859 int endIdx;
860 if (_vm->_globals->_saveData->_data[svField133] == 1)
861 endIdx = 41;
862 else
863 endIdx = 12;
864 bool playFl = false;
865 for (;;) {
866 if (_vm->shouldQuit())
867 return -1; // Exiting game
868
869 switch (_vm->_objectsMan->getBobAnimDataIdx(9)) {
870 case 4:
871 case 18:
872 if (!playFl) {
873 _vm->_soundMan->directPlayWav("SOUND44.WAV");
874 playFl = true;
875 }
876 break;
877 case 5:
878 case 9:
879 playFl = false;
880 break;
881 default:
882 break;
883 }
884
885 switch (_vm->_objectsMan->getBobAnimDataIdx(10)) {
886 case 11:
887 if (!playFl) {
888 _vm->_soundMan->directPlayWav("SOUND45.WAV");
889 playFl = true;
890 }
891 break;
892 case 12:
893 playFl = false;
894 break;
895 default:
896 break;
897 }
898 _vm->_events->refreshScreenAndEvents();
899 if (_vm->_objectsMan->getBobAnimDataIdx(9) == endIdx)
900 break;
901 }
902
903 if (endIdx == 12) {
904 _vm->_objectsMan->animateSprite(0);
905 _vm->_objectsMan->stopBobAnimation(9);
906 }
907 _vm->_objectsMan->enableHidingBehavior();
908 break;
909 }
910
911 case 50:
912 _vm->_soundMan->playSoundFile("SOUND46.WAv");
913 _vm->_objectsMan->setAndPlayAnim(11, 0, 23, false);
914 break;
915
916 case 51: {
917 _vm->_graphicsMan->fadeOutLong();
918 _vm->_objectsMan->disableHidingBehavior();
919 _vm->_objectsMan->removeSprite(0);
920 _vm->_fontMan->hideText(5);
921 _vm->_fontMan->hideText(9);
922 _vm->_graphicsMan->endDisplayBob();
923 _vm->_graphicsMan->loadImage("IM20f");
924 _vm->_animMan->loadAnim("ANIM20f");
925 _vm->_graphicsMan->displayAllBob();
926 _vm->_events->mouseOff();
927 _vm->_graphicsMan->fadeInLong();
928 _vm->_soundMan->loadWav("SOUND46.WAV", 1);
929 bool playFl = false;
930 for (;;) {
931 if (_vm->shouldQuit())
932 return -1; // Exiting game
933
934 if (_vm->_objectsMan->getBobAnimDataIdx(12) == 5 && !playFl) {
935 _vm->_soundMan->playWav(1);
936 playFl = true;
937 }
938 _vm->_events->refreshScreenAndEvents();
939 if (_vm->_objectsMan->getBobAnimDataIdx(12) == 34)
940 break;
941 }
942 _vm->_objectsMan->stopBobAnimation(2);
943 _vm->_graphicsMan->fadeOutLong();
944 _vm->_graphicsMan->_noFadingFl = true;
945 _vm->_globals->_exitId = 20;
946 break;
947 }
948
949 case 52:
950 _vm->_globals->_introSpeechOffFl = true;
951 _vm->_talkMan->startAnimatedCharacterDialogue("GARDE.PE2");
952 _vm->_globals->_introSpeechOffFl = false;
953 break;
954
955 case 53:
956 _vm->_talkMan->startAnimatedCharacterDialogue("GARDE1.pe2");
957 break;
958
959 case 54:
960 _vm->_talkMan->startAnimatedCharacterDialogue("GARDE2.pe2");
961 break;
962
963 case 55:
964 _vm->_objectsMan->stopBobAnimation(1);
965 _vm->_objectsMan->setAndPlayAnim(15, 0, 12, false);
966 _vm->_objectsMan->stopBobAnimation(15);
967 _vm->_objectsMan->loadLinkFile("IM19a", true);
968 break;
969
970 case 56:
971 _vm->_globals->_characterSpriteBuf = _vm->_fileIO->loadFile("HOPFEM.SPR");
972 _vm->_globals->_characterType = CHARACTER_HOPKINS_CLONE;
973 _vm->_globals->_saveData->_data[svAlternateSpriteFl] = 1;
974 _vm->_globals->loadCharacterData();
975 _vm->_objectsMan->_sprite[0]._deltaX = 28;
976 _vm->_objectsMan->_sprite[0]._deltaY = 155;
977 _vm->_objectsMan->_sprite[0]._spriteData = _vm->_globals->_characterSpriteBuf;
978 _vm->_objectsMan->computeAndSetSpriteSize();
979 break;
980
981 case 57:
982 _vm->_globals->_characterSpriteBuf = _vm->_fileIO->loadFile("PERSO.SPR");
983 _vm->_globals->_characterType = CHARACTER_HOPKINS;
984 _vm->_globals->_saveData->_data[svAlternateSpriteFl] = 0;
985 _vm->_globals->loadCharacterData();
986 _vm->_objectsMan->_sprite[0]._deltaX = 34;
987 _vm->_objectsMan->_sprite[0]._deltaY = 190;
988 _vm->_objectsMan->_sprite[0]._spriteData = _vm->_globals->_characterSpriteBuf;
989 _vm->_objectsMan->computeAndSetSpriteSize();
990 break;
991
992 case 58:
993 _vm->_globals->_introSpeechOffFl = true;
994 _vm->_talkMan->startAnimatedCharacterDialogue("Gm1.PE2");
995 _vm->_globals->_saveData->_data[svField176] = 1;
996 _vm->_globals->_saveData->_data[svField270] = 2;
997 _vm->_globals->_introSpeechOffFl = false;
998 break;
999
1000 case 59: {
1001 _vm->_globals->_checkDistanceFl = true;
1002 _vm->_objectsMan->_oldCharacterPosX = _vm->_objectsMan->getSpriteX(0);
1003 _vm->_objectsMan->resetOldDirection();
1004 _vm->_objectsMan->resetHomeRateCounter();
1005 _vm->_linesMan->_route = (RouteItem *)NULL;
1006 _vm->_linesMan->_route = _vm->_linesMan->findRoute(_vm->_objectsMan->getSpriteX(0), _vm->_objectsMan->getSpriteY(0), 445, 332);
1007 _vm->_globals->_checkDistanceFl = true;
1008 do {
1009 if (_vm->shouldQuit())
1010 return -1; // Exiting game
1011
1012 _vm->_objectsMan->goHome();
1013 _vm->_events->refreshScreenAndEvents();
1014 } while (_vm->_linesMan->_route != (RouteItem *)NULL);
1015 _vm->_objectsMan->removeSprite(0);
1016 _vm->_objectsMan->setBobAnimation(7);
1017 _vm->_objectsMan->setBobAnimDataIdx(7, 0);
1018 bool playFl = false;
1019 _vm->_soundMan->loadSample(1, "SOUND40.WAV");
1020 for (;;) {
1021 if (_vm->shouldQuit())
1022 return -1; // Exiting game
1023
1024 switch (_vm->_objectsMan->getBobAnimDataIdx(7)) {
1025 case 10:
1026 case 18:
1027 if (!playFl) {
1028 _vm->_soundMan->playSample(1);
1029 playFl = true;
1030 }
1031 break;
1032 case 11:
1033 playFl = false;
1034 break;
1035 case 19:
1036 _vm->_objectsMan->setBobAnimation(3);
1037 playFl = false;
1038 break;
1039 default:
1040 break;
1041 }
1042 _vm->_events->refreshScreenAndEvents();
1043 if (_vm->_objectsMan->getBobAnimDataIdx(3) == 48)
1044 break;
1045 }
1046 _vm->_soundMan->removeSample(1);
1047 _vm->_objectsMan->setSpriteIndex(0, 62);
1048 _vm->_objectsMan->animateSprite(0);
1049 _vm->_objectsMan->setBobAnimation(6);
1050 _vm->_objectsMan->stopBobAnimation(7);
1051 _vm->_objectsMan->stopBobAnimation(3);
1052 break;
1053 }
1054
1055 case 62:
1056 _vm->_talkMan->animateObject("SBCADA.pe2");
1057 break;
1058
1059 case 65:
1060 _vm->_talkMan->animateObject("ScCADA.pe2");
1061 break;
1062
1063 case 80: {
1064 _vm->_objectsMan->removeSprite(0);
1065 _vm->_objectsMan->setBobAnimation(12);
1066 _vm->_objectsMan->setBobAnimation(13);
1067 _vm->_objectsMan->setBobAnimDataIdx(12, 0);
1068 _vm->_objectsMan->setBobAnimDataIdx(13, 0);
1069 _vm->_soundMan->loadWav("SOUND44.WAV", 1);
1070 _vm->_soundMan->loadWav("SOUND71.WAV", 2);
1071 bool playFl = false;
1072 for (;;) {
1073 if (_vm->shouldQuit())
1074 return -1; // Exiting game
1075
1076 switch (_vm->_objectsMan->getBobAnimDataIdx(12)) {
1077 case 4:
1078 if (!playFl) {
1079 _vm->_soundMan->playWav(1);
1080 playFl = true;
1081 }
1082 break;
1083 case 5:
1084 playFl = false;
1085 break;
1086 default:
1087 break;
1088 }
1089
1090 switch (_vm->_objectsMan->getBobAnimDataIdx(4)) {
1091 case 5:
1092 if (!playFl) {
1093 _vm->_soundMan->playWav(2);
1094 playFl = true;
1095 }
1096 break;
1097 case 6:
1098 playFl = false;
1099 break;
1100 default:
1101 break;
1102 }
1103
1104 if (_vm->_objectsMan->getBobAnimDataIdx(13) == 8) {
1105 _vm->_objectsMan->stopBobAnimation(13);
1106 _vm->_objectsMan->stopBobAnimation(3);
1107 _vm->_objectsMan->setBobAnimation(4);
1108 _vm->_objectsMan->setBobAnimDataIdx(4, 0);
1109 _vm->_objectsMan->setBobAnimDataIdx(13, 0);
1110 }
1111
1112 _vm->_events->refreshScreenAndEvents();
1113 if (_vm->_objectsMan->getBobAnimDataIdx(4) == 16)
1114 break;
1115 }
1116 _vm->_objectsMan->stopBobAnimation(12);
1117 _vm->_objectsMan->stopBobAnimation(4);
1118 _vm->_objectsMan->animateSprite(0);
1119 _vm->_objectsMan->loadLinkFile("IM27a", true);
1120 break;
1121 }
1122
1123 case 81: {
1124 _vm->_globals->_checkDistanceFl = true;
1125 _vm->_objectsMan->_oldCharacterPosX = _vm->_objectsMan->getSpriteX(0);
1126 _vm->_objectsMan->resetOldDirection();
1127 _vm->_objectsMan->resetHomeRateCounter();
1128 _vm->_linesMan->_route = (RouteItem *)NULL;
1129 _vm->_linesMan->_route = _vm->_linesMan->findRoute(_vm->_objectsMan->getSpriteX(0), _vm->_objectsMan->getSpriteY(0), 119, 268);
1130 _vm->_globals->_checkDistanceFl = true;
1131 do {
1132 if (_vm->shouldQuit())
1133 return -1; // Exiting game
1134
1135 _vm->_objectsMan->goHome();
1136 _vm->_events->refreshScreenAndEvents();
1137 } while (_vm->_linesMan->_route != (RouteItem *)NULL);
1138 _vm->_objectsMan->removeSprite(0);
1139 _vm->_objectsMan->setBobAnimation(11);
1140 _vm->_objectsMan->setBobAnimation(8);
1141 _vm->_objectsMan->setBobAnimDataIdx(11, 0);
1142 _vm->_objectsMan->setBobAnimDataIdx(8, 0);
1143 _vm->_soundMan->loadWav("SOUND44.WAV", 1);
1144 _vm->_soundMan->loadWav("SOUND48.WAV", 2);
1145 _vm->_soundMan->loadWav("SOUND49.WAV", 3);
1146 bool playFl = false;
1147 for (;;) {
1148 if (_vm->shouldQuit())
1149 return -1; // Exiting game
1150
1151 switch (_vm->_objectsMan->getBobAnimDataIdx(11)) {
1152 case 4:
1153 if (!playFl) {
1154 _vm->_soundMan->playWav(1);
1155 playFl = true;
1156 }
1157 break;
1158 case 5:
1159 playFl = false;
1160 break;
1161 default:
1162 break;
1163 }
1164
1165 switch (_vm->_objectsMan->getBobAnimDataIdx(8)) {
1166 case 11:
1167 if (!playFl) {
1168 _vm->_soundMan->playWav(2);
1169 playFl = true;
1170 }
1171 break;
1172 case 12:
1173 playFl = false;
1174 break;
1175 default:
1176 break;
1177 }
1178
1179 _vm->_events->refreshScreenAndEvents();
1180 if (_vm->_objectsMan->getBobAnimDataIdx(8) == 32)
1181 break;
1182 }
1183 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 201, 14, 1);
1184 _vm->_objectsMan->animateSprite(0);
1185 _vm->_objectsMan->stopBobAnimation(11);
1186 _vm->_objectsMan->stopBobAnimation(8);
1187 _vm->_objectsMan->setBobAnimation(5);
1188 _vm->_objectsMan->setBobAnimation(6);
1189 _vm->_objectsMan->setBobAnimDataIdx(5, 0);
1190 _vm->_objectsMan->setBobAnimDataIdx(6, 0);
1191 _vm->_soundMan->playWav(3);
1192 do {
1193 if (_vm->shouldQuit())
1194 return -1; // Exiting game
1195
1196 _vm->_events->refreshScreenAndEvents();
1197 } while (_vm->_objectsMan->getBobAnimDataIdx(5) != 74);
1198 _vm->_objectsMan->stopBobAnimation(5);
1199 _vm->_objectsMan->stopBobAnimation(6);
1200 _vm->_objectsMan->setBobAnimation(9);
1201 _vm->_objectsMan->setBobAnimation(7);
1202 break;
1203 }
1204
1205 case 83:
1206 _vm->_talkMan->startAnimatedCharacterDialogue("CVIGIL.pe2");
1207 break;
1208
1209 case 84:
1210 _vm->_globals->_introSpeechOffFl = true;
1211 _vm->_talkMan->startAnimatedCharacterDialogue("CVIGIL1.PE2");
1212 _vm->_globals->_introSpeechOffFl = false;
1213 break;
1214
1215 case 85:
1216 _vm->_objectsMan->stopBobAnimation(3);
1217 _vm->_objectsMan->setBobAnimation(5);
1218 _vm->_objectsMan->setBobAnimDataIdx(5, 0);
1219 do {
1220 if (_vm->shouldQuit())
1221 return -1; // Exiting game
1222
1223 _vm->_events->refreshScreenAndEvents();
1224 } while (_vm->_objectsMan->getBobAnimDataIdx(5) != 6);
1225 _vm->_objectsMan->stopBobAnimation(5);
1226 _vm->_objectsMan->setBobAnimation(6);
1227 _vm->_objectsMan->loadLinkFile("IM24a", true);
1228 break;
1229
1230 case 86:
1231 if (_vm->_globals->_saveData->_data[svField231] == 1) {
1232 _vm->_talkMan->startAnimatedCharacterDialogue("chotess1.pe2");
1233 } else {
1234 _vm->_globals->_introSpeechOffFl = true;
1235 _vm->_talkMan->startAnimatedCharacterDialogue("chotesse.pe2");
1236 _vm->_globals->_introSpeechOffFl = false;
1237 }
1238 break;
1239
1240 case 87:
1241 if (_vm->_globals->_saveData->_data[svField188])
1242 _vm->_talkMan->startAnimatedCharacterDialogue("stand2.pe2");
1243 else
1244 _vm->_talkMan->startAnimatedCharacterDialogue("stand1.pe2");
1245 break;
1246
1247 case 88:
1248 // Shooting target - Shooting at target
1249 if (_vm->_globals->_saveData->_data[svField183] == 1) {
1250 _vm->_objectsMan->setBobAnimDataIdx(1, 0);
1251 _vm->_objectsMan->setBobAnimDataIdx(2, 0);
1252 _vm->_objectsMan->setBobAnimation(1);
1253 _vm->_objectsMan->setBobAnimation(2);
1254 _vm->_soundMan->loadSample(1, "SOUND40.WAV");
1255 bool playFl = false;
1256 for (;;) {
1257 if (_vm->shouldQuit())
1258 return -1; // Exiting game
1259
1260 switch (_vm->_objectsMan->getBobAnimDataIdx(1)) {
1261 case 1:
1262 case 3:
1263 case 5:
1264 case 7:
1265 if (!playFl) {
1266 _vm->_soundMan->playSample(1);
1267 playFl = true;
1268 }
1269 break;
1270 case 2:
1271 case 4:
1272 case 6:
1273 case 8:
1274 playFl = false;
1275 break;
1276 default:
1277 break;
1278 }
1279 _vm->_events->refreshScreenAndEvents();
1280 if (_vm->_objectsMan->getBobAnimDataIdx(1) == 9)
1281 break;
1282 }
1283 _vm->_objectsMan->stopBobAnimation(1);
1284 _vm->_objectsMan->stopBobAnimation(2);
1285 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 283, 160, 6);
1286 _vm->_soundMan->removeSample(1);
1287 }
1288 if (_vm->_globals->_saveData->_data[svField183] == 2) {
1289 _vm->_objectsMan->setBobAnimDataIdx(1, 0);
1290 _vm->_objectsMan->setBobAnimDataIdx(3, 0);
1291 _vm->_objectsMan->setBobAnimation(1);
1292 _vm->_objectsMan->setBobAnimation(3);
1293 _vm->_soundMan->loadSample(1, "SOUND40.WAV");
1294 bool playFl = false;
1295 for (;;) {
1296 if (_vm->shouldQuit())
1297 return -1; // Exiting game
1298
1299 switch (_vm->_objectsMan->getBobAnimDataIdx(1)) {
1300 case 1:
1301 case 3:
1302 case 5:
1303 case 7:
1304 if (!playFl) {
1305 _vm->_soundMan->playSample(1);
1306 playFl = true;
1307 }
1308 break;
1309 case 2:
1310 case 4:
1311 case 6:
1312 case 8:
1313 playFl = false;
1314 break;
1315 default:
1316 break;
1317 }
1318 _vm->_events->refreshScreenAndEvents();
1319 if (_vm->_objectsMan->getBobAnimDataIdx(1) == 9)
1320 break;
1321 }
1322 _vm->_objectsMan->stopBobAnimation(1);
1323 _vm->_objectsMan->stopBobAnimation(3);
1324 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 283, 161, 8);
1325 _vm->_soundMan->removeSample(1);
1326 }
1327 break;
1328
1329 case 90:
1330 // Shooting target - Using the level
1331 _vm->_soundMan->playSoundFile("SOUND52.WAV");
1332 if (!_vm->_globals->_saveData->_data[svField186]) {
1333 _vm->_animMan->playSequence("CIB5A.SEQ", 1, 12, 1, false, false);
1334 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 155, 29, 0);
1335 } else if (_vm->_globals->_saveData->_data[svField186] == 1) {
1336 _vm->_animMan->playSequence("CIB5C.SEQ", 1, 12, 1, false, false);
1337 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 155, 29, 0);
1338 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 329, 87, 2);
1339 }
1340 break;
1341
1342 case 91:
1343 _vm->_soundMan->playSoundFile("SOUND52.WAV");
1344 if (!_vm->_globals->_saveData->_data[svField186]) {
1345 _vm->_animMan->playSequence("CIB5B.SEQ", 1, 12, 1, false, false);
1346 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 155, 29, 5);
1347 } else if (_vm->_globals->_saveData->_data[svField186] == 1) {
1348 _vm->_animMan->playSequence("CIB5D.SEQ", 1, 12, 1, false, false);
1349 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 155, 29, 5);
1350 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 283, 160, 6);
1351 }
1352 break;
1353
1354 case 92:
1355 _vm->_soundMan->playSoundFile("SOUND52.WAV");
1356 if (!_vm->_globals->_saveData->_data[svField184]) {
1357 _vm->_animMan->playSequence("CIB6A.SEQ", 1, 12, 1, false, false);
1358 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 155, 29, 0);
1359 } else if (_vm->_globals->_saveData->_data[svField184] == 1) {
1360 _vm->_animMan->playSequence("CIB6C.SEQ", 1, 12, 1, false, false);
1361 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 155, 29, 0);
1362 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 293, 139, 3);
1363 }
1364 break;
1365
1366 case 93:
1367 _vm->_soundMan->playSoundFile("SOUND52.WAV");
1368 if (!_vm->_globals->_saveData->_data[svField184]) {
1369 _vm->_animMan->playSequence("CIB6B.SEQ", 1, 12, 1, false, false);
1370 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 155, 29, 5);
1371 } else if (_vm->_globals->_saveData->_data[svField184] == 1) {
1372 _vm->_animMan->playSequence("CIB6D.SEQ", 1, 12, 1, false, false);
1373 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 155, 29, 5);
1374 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 283, 161, 8);
1375 }
1376 break;
1377
1378 case 94:
1379 if (!_vm->_globals->_saveData->_data[svField228])
1380 _vm->_talkMan->startAnimatedCharacterDialogue("flicn.pe2");
1381 else if (_vm->_globals->_saveData->_data[svField228] == 1)
1382 _vm->_talkMan->startAnimatedCharacterDialogue("flicn1.pe2");
1383 break;
1384
1385 case 95:
1386 _vm->_objectsMan->setBobAnimation(9);
1387 _vm->_objectsMan->setBobAnimation(10);
1388 _vm->_objectsMan->setBobAnimation(12);
1389 _vm->_objectsMan->setBobAnimDataIdx(9, 0);
1390 _vm->_objectsMan->setBobAnimDataIdx(10, 0);
1391 _vm->_objectsMan->setBobAnimDataIdx(12, 0);
1392 _vm->_objectsMan->removeSprite(0);
1393 do {
1394 if (_vm->shouldQuit())
1395 return -1; // Exiting game
1396
1397 _vm->_events->refreshScreenAndEvents();
1398 } while (_vm->_objectsMan->getBobAnimDataIdx(9) != 15);
1399 _vm->_objectsMan->stopBobAnimation(9);
1400 _vm->_objectsMan->animateSprite(0);
1401 _vm->_soundMan->playSoundFile("SOUND50.WAV");
1402 do {
1403 if (_vm->shouldQuit())
1404 return -1; // Exiting game
1405
1406 _vm->_events->refreshScreenAndEvents();
1407 } while (_vm->_objectsMan->getBobAnimDataIdx(12) != 117);
1408 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 830, 122, 0);
1409 _vm->_objectsMan->stopBobAnimation(12);
1410 _vm->_objectsMan->stopBobAnimation(10);
1411 _vm->_objectsMan->setBobAnimation(11);
1412 break;
1413
1414 case 98:
1415 _vm->_globals->_introSpeechOffFl = true;
1416 _vm->_talkMan->startAnimatedCharacterDialogue("CVIGIL2.PE2");
1417 _vm->_globals->_introSpeechOffFl = false;
1418 break;
1419
1420 case 100:
1421 _vm->_talkMan->startAnimatedCharacterDialogue("tourist.pe2");
1422 break;
1423
1424 case 101:
1425 _vm->_talkMan->startAnimatedCharacterDialogue("tahi1.pe2");
1426 break;
1427
1428 case 103:
1429 // Dice game
1430 _vm->_globals->_introSpeechOffFl = true;
1431 _vm->_talkMan->startAnimatedCharacterDialogue("tourist1.pe2");
1432 _vm->_globals->_introSpeechOffFl = false;
1433 _vm->_animMan->playAnim2("T421A.ANM", "T421.ANM", 100, 14, 500);
1434 _vm->_events->refreshScreenAndEvents();
1435 _vm->_events->refreshScreenAndEvents();
1436 _vm->_events->refreshScreenAndEvents();
1437 _vm->_globals->_introSpeechOffFl = true;
1438 _vm->_talkMan->startAnimatedCharacterDialogue("tourist2.pe2");
1439 _vm->_globals->_introSpeechOffFl = false;
1440 break;
1441
1442 case 104:
1443 _vm->_globals->_introSpeechOffFl = true;
1444 _vm->_talkMan->startAnimatedCharacterDialogue("tourist3.pe2");
1445 _vm->_globals->_introSpeechOffFl = false;
1446 break;
1447
1448 case 105:
1449 _vm->_globals->_checkDistanceFl = true;
1450 _vm->_objectsMan->_oldCharacterPosX = _vm->_objectsMan->getSpriteX(0);
1451 _vm->_objectsMan->resetOldDirection();
1452 _vm->_objectsMan->resetHomeRateCounter();
1453 _vm->_linesMan->_route = (RouteItem *)NULL;
1454 switch (_vm->_globals->_saveData->_data[svField253]) {
1455 case 1:
1456 _vm->_linesMan->_route = _vm->_linesMan->findRoute(_vm->_objectsMan->getSpriteX(0), _vm->_objectsMan->getSpriteY(0), 201, 294);
1457 break;
1458 case 2:
1459 _vm->_linesMan->_route = _vm->_linesMan->findRoute(_vm->_objectsMan->getSpriteX(0), _vm->_objectsMan->getSpriteY(0), 158, 338);
1460 break;
1461 default:
1462 if (_vm->_globals->_saveData->_data[svField253] > 2)
1463 _vm->_linesMan->_route = _vm->_linesMan->findRoute(_vm->_objectsMan->getSpriteX(0), _vm->_objectsMan->getSpriteY(0), 211, 393);
1464 break;
1465 }
1466 _vm->_globals->_checkDistanceFl = true;
1467 do {
1468 if (_vm->shouldQuit())
1469 return -1; // Exiting game
1470
1471 _vm->_objectsMan->goHome();
1472 _vm->_events->refreshScreenAndEvents();
1473 } while (_vm->_linesMan->_route != (RouteItem *)NULL);
1474 _vm->_objectsMan->removeSprite(0);
1475 _vm->_objectsMan->setSpriteIndex(0, 60);
1476 _vm->_soundMan->loadSample(1, "SOUND63.WAV");
1477 if (_vm->_globals->_saveData->_data[svField253] > 2) {
1478 _vm->_objectsMan->setBobAnimation(4);
1479 bool playFl = false;
1480 for (;;) {
1481 if (_vm->shouldQuit())
1482 return -1; // Exiting game
1483
1484 switch (_vm->_objectsMan->getBobAnimDataIdx(4)) {
1485 case 9:
1486 case 32:
1487 case 55:
1488 if (!playFl) {
1489 _vm->_soundMan->playSample(1);
1490 playFl = true;
1491 }
1492 break;
1493 case 10:
1494 case 33:
1495 case 56:
1496 playFl = false;
1497 break;
1498 default:
1499 break;
1500 }
1501 _vm->_events->refreshScreenAndEvents();
1502 if (_vm->_objectsMan->getBobAnimDataIdx(4) == 72)
1503 break;
1504 }
1505 _vm->_objectsMan->stopBobAnimation(4);
1506 }
1507 if (_vm->_globals->_saveData->_data[svField253] == 1) {
1508 _vm->_objectsMan->setBobAnimation(6);
1509 bool playFl = false;
1510 for (;;) {
1511 if (_vm->shouldQuit())
1512 return -1; // Exiting game
1513
1514 switch (_vm->_objectsMan->getBobAnimDataIdx(6)) {
1515 case 9:
1516 case 32:
1517 case 55:
1518 if (!playFl) {
1519 _vm->_soundMan->playSample(1);
1520 playFl = true;
1521 }
1522 break;
1523 case 10:
1524 case 33:
1525 case 56:
1526 playFl = false;
1527 break;
1528 default:
1529 break;
1530 }
1531 _vm->_events->refreshScreenAndEvents();
1532 if (_vm->_objectsMan->getBobAnimDataIdx(6) == 72)
1533 break;
1534 }
1535 _vm->_objectsMan->stopBobAnimation(6);
1536 }
1537 if (_vm->_globals->_saveData->_data[svField253] == 2) {
1538 _vm->_objectsMan->setBobAnimation(5);
1539 bool playFl = false;
1540 for (;;) {
1541 if (_vm->shouldQuit())
1542 return -1; // Exiting game
1543
1544 switch (_vm->_objectsMan->getBobAnimDataIdx(5)) {
1545 case 9:
1546 case 32:
1547 case 55:
1548 if (!playFl) {
1549 _vm->_soundMan->playSample(1);
1550 playFl = true;
1551 }
1552 break;
1553 case 10:
1554 case 33:
1555 case 56:
1556 playFl = false;
1557 break;
1558 default:
1559 break;
1560 }
1561 _vm->_events->refreshScreenAndEvents();
1562 if (_vm->_objectsMan->getBobAnimDataIdx(5) == 72)
1563 break;
1564 }
1565 _vm->_objectsMan->stopBobAnimation(5);
1566 }
1567 _vm->_objectsMan->animateSprite(0);
1568 _vm->_objectsMan->doActionBack(1);
1569 _vm->_soundMan->removeSample(1);
1570 break;
1571
1572 case 106:
1573 _vm->_objectsMan->removeSprite(0);
1574 _vm->_objectsMan->setBobAnimation(4);
1575 _vm->_objectsMan->setBobAnimDataIdx(4, 0);
1576 _vm->_soundMan->loadWav("SOUND61.WAV", 1);
1577 _vm->_soundMan->loadWav("SOUND62.WAV", 2);
1578 _vm->_soundMan->loadWav("SOUND61.WAV", 3);
1579 do {
1580 if (_vm->shouldQuit())
1581 return -1; // Exiting game
1582
1583 _vm->_events->refreshScreenAndEvents();
1584 } while (_vm->_objectsMan->getBobAnimDataIdx(4) != 10);
1585 _vm->_soundMan->playWav(1);
1586 do {
1587 if (_vm->shouldQuit())
1588 return -1; // Exiting game
1589
1590 _vm->_events->refreshScreenAndEvents();
1591 } while (_vm->_objectsMan->getBobAnimDataIdx(4) != 18);
1592 _vm->_soundMan->playWav(2);
1593 do {
1594 if (_vm->shouldQuit())
1595 return -1; // Exiting game
1596
1597 _vm->_events->refreshScreenAndEvents();
1598 } while (_vm->_objectsMan->getBobAnimDataIdx(4) != 62);
1599 _vm->_soundMan->playWav(3);
1600 do {
1601 if (_vm->shouldQuit())
1602 return -1; // Exiting game
1603
1604 _vm->_events->refreshScreenAndEvents();
1605 } while (_vm->_objectsMan->getBobAnimDataIdx(4) != 77);
1606 _vm->_objectsMan->stopBobAnimation(4);
1607 _vm->_objectsMan->animateSprite(0);
1608 break;
1609
1610 case 107:
1611 _vm->_objectsMan->removeSprite(0);
1612 _vm->_objectsMan->setBobAnimation(5);
1613 _vm->_objectsMan->setBobAnimDataIdx(5, 0);
1614 _vm->_soundMan->loadWav("SOUND61.WAV", 1);
1615 _vm->_soundMan->loadWav("SOUND62.WAV", 2);
1616 _vm->_soundMan->loadWav("SOUND61.WAV", 3);
1617 do {
1618 if (_vm->shouldQuit())
1619 return -1; // Exiting game
1620
1621 _vm->_events->refreshScreenAndEvents();
1622 } while (_vm->_objectsMan->getBobAnimDataIdx(5) != 10);
1623 _vm->_soundMan->playWav(1);
1624 do {
1625 if (_vm->shouldQuit())
1626 return -1; // Exiting game
1627
1628 _vm->_events->refreshScreenAndEvents();
1629 } while (_vm->_objectsMan->getBobAnimDataIdx(5) != 18);
1630 _vm->_soundMan->playWav(2);
1631 do {
1632 if (_vm->shouldQuit())
1633 return -1; // Exiting game
1634
1635 _vm->_events->refreshScreenAndEvents();
1636 } while (_vm->_objectsMan->getBobAnimDataIdx(5) != 38);
1637 _vm->_soundMan->playWav(3);
1638 do {
1639 if (_vm->shouldQuit())
1640 return -1; // Exiting game
1641
1642 _vm->_events->refreshScreenAndEvents();
1643 } while (_vm->_objectsMan->getBobAnimDataIdx(5) != 53);
1644 _vm->_objectsMan->stopBobAnimation(5);
1645 _vm->_objectsMan->animateSprite(0);
1646 break;
1647
1648 case 108:
1649 _vm->_globals->_introSpeechOffFl = true;
1650 _vm->_talkMan->startAnimatedCharacterDialogue("peche1.pe2");
1651 _vm->_globals->_introSpeechOffFl = false;
1652 break;
1653
1654 case 109:
1655 _vm->_globals->_introSpeechOffFl = true;
1656 _vm->_talkMan->startAnimatedCharacterDialogue("peche2.pe2");
1657 _vm->_globals->_introSpeechOffFl = false;
1658 break;
1659
1660 case 110:
1661 _vm->_globals->_introSpeechOffFl = true;
1662 _vm->_talkMan->startAnimatedCharacterDialogue("peche3.pe2");
1663 _vm->_globals->_introSpeechOffFl = false;
1664 break;
1665
1666 case 111:
1667 _vm->_globals->_introSpeechOffFl = true;
1668 _vm->_talkMan->startAnimatedCharacterDialogue("peche4.pe2");
1669 _vm->_globals->_introSpeechOffFl = false;
1670 break;
1671
1672 case 112:
1673 _vm->_globals->_introSpeechOffFl = true;
1674 _vm->_talkMan->startAnimatedCharacterDialogue("teint1.pe2");
1675 _vm->_globals->_introSpeechOffFl = false;
1676 break;
1677
1678 case 113:
1679 _vm->_talkMan->startAnimatedCharacterDialogue("teint.pe2");
1680 break;
1681
1682 case 114:
1683 _vm->_talkMan->startAnimatedCharacterDialogue("tahibar.pe2");
1684 break;
1685
1686 case 115:
1687 _vm->_talkMan->startAnimatedCharacterDialogue("ilebar.pe2");
1688 break;
1689
1690 case 116:
1691 _vm->_talkMan->startAnimatedCharacterDialogue("Profred.pe2");
1692 break;
1693
1694 case 170:
1695 _vm->_talkMan->startAnimatedCharacterDialogue("GRED.pe2");
1696 break;
1697
1698 case 171: {
1699 _vm->_globals->_introSpeechOffFl = true;
1700 _vm->_talkMan->startAnimatedCharacterDialogue("gred1.pe2");
1701 _vm->_globals->_introSpeechOffFl = false;
1702 _vm->_globals->_checkDistanceFl = true;
1703 _vm->_objectsMan->_oldCharacterPosX = _vm->_objectsMan->getSpriteX(0);
1704 _vm->_objectsMan->resetOldDirection();
1705 _vm->_objectsMan->resetHomeRateCounter();
1706 _vm->_globals->_checkDistanceFl = true;
1707 _vm->_linesMan->_route = (RouteItem *)NULL;
1708 _vm->_linesMan->_route = _vm->_linesMan->findRoute(_vm->_objectsMan->getSpriteX(0), _vm->_objectsMan->getSpriteY(0), 361, 325);
1709 _vm->_globals->_checkDistanceFl = true;
1710 _vm->_objectsMan->_zoneNum = -1;
1711 do {
1712 if (_vm->shouldQuit())
1713 return -1; // Exiting game
1714
1715 _vm->_objectsMan->goHome();
1716 _vm->_events->refreshScreenAndEvents();
1717 } while (_vm->_linesMan->_route != (RouteItem *)NULL);
1718 _vm->_globals->_exitId = 59;
1719 break;
1720 }
1721
1722 case 172:
1723 _vm->_talkMan->startAnimatedCharacterDialogue("GBLEU.pe2");
1724 break;
1725
1726 case 173: {
1727 _vm->_globals->_introSpeechOffFl = true;
1728 _vm->_talkMan->startAnimatedCharacterDialogue("gbleu1.pe2");
1729 _vm->_globals->_introSpeechOffFl = false;
1730 _vm->_globals->_checkDistanceFl = true;
1731 _vm->_objectsMan->_oldCharacterPosX = _vm->_objectsMan->getSpriteX(0);
1732 _vm->_objectsMan->resetOldDirection();
1733 _vm->_objectsMan->resetHomeRateCounter();
1734 _vm->_globals->_checkDistanceFl = true;
1735 _vm->_linesMan->_route = (RouteItem *)NULL;
1736 _vm->_linesMan->_route = _vm->_linesMan->findRoute(_vm->_objectsMan->getSpriteX(0), _vm->_objectsMan->getSpriteY(0), 361, 325);
1737 _vm->_globals->_checkDistanceFl = true;
1738 _vm->_objectsMan->_zoneNum = -1;
1739 do {
1740 if (_vm->shouldQuit())
1741 return -1; // Exiting game
1742
1743 _vm->_objectsMan->goHome();
1744 _vm->_events->refreshScreenAndEvents();
1745 } while (_vm->_linesMan->_route != (RouteItem *)NULL);
1746 _vm->_globals->_exitId = 59;
1747 break;
1748 }
1749
1750 case 174:
1751 _vm->_talkMan->startAnimatedCharacterDialogue("Profbl.pe2");
1752 break;
1753
1754 case 175:
1755 _vm->_objectsMan->setSpriteIndex(0, 55);
1756 _vm->_objectsMan->removeSprite(0);
1757 _vm->_objectsMan->setBobAnimation(9);
1758 _vm->_objectsMan->setBobAnimation(10);
1759 _vm->_objectsMan->setBobOffset(10, 300);
1760 _vm->_soundMan->playSoundFile("SOUND44.WAV");
1761 do {
1762 if (_vm->shouldQuit())
1763 return -1; // Exiting game
1764
1765 _vm->_events->refreshScreenAndEvents();
1766 } while (_vm->_objectsMan->getBobAnimDataIdx(10) != 7);
1767 _vm->_objectsMan->setBobAnimation(6);
1768 _vm->_objectsMan->stopBobAnimation(3);
1769 do {
1770 if (_vm->shouldQuit())
1771 return -1; // Exiting game
1772
1773 _vm->_events->refreshScreenAndEvents();
1774 } while (_vm->_objectsMan->getBobAnimDataIdx(6) != 10);
1775 _vm->_soundMan->playSoundFile("SOUND71.WAV");
1776 _vm->_objectsMan->setBobAnimation(7);
1777 _vm->_objectsMan->stopBobAnimation(4);
1778 do {
1779 if (_vm->shouldQuit())
1780 return -1; // Exiting game
1781
1782 _vm->_events->refreshScreenAndEvents();
1783 } while (_vm->_objectsMan->getBobAnimDataIdx(7) != 15);
1784 _vm->_objectsMan->stopBobAnimation(5);
1785 _vm->_objectsMan->setBobAnimation(8);
1786 _vm->_soundMan->playSoundFile("SOUND70.WAV");
1787 do {
1788 if (_vm->shouldQuit())
1789 return -1; // Exiting game
1790
1791 _vm->_events->refreshScreenAndEvents();
1792 } while (_vm->_objectsMan->getBobAnimDataIdx(8) != 76);
1793 _vm->_objectsMan->stopBobAnimation(6);
1794 _vm->_objectsMan->stopBobAnimation(7);
1795 _vm->_objectsMan->stopBobAnimation(8);
1796 _vm->_objectsMan->stopBobAnimation(9);
1797 _vm->_objectsMan->stopBobAnimation(10);
1798 _vm->_objectsMan->animateSprite(0);
1799 break;
1800
1801 case 176:
1802 _vm->_globals->_introSpeechOffFl = true;
1803 _vm->_talkMan->startAnimatedCharacterDialogue("gred2.pe2");
1804 _vm->_globals->_introSpeechOffFl = false;
1805 break;
1806
1807 case 177:
1808 _vm->_globals->_introSpeechOffFl = true;
1809 _vm->_talkMan->startAnimatedCharacterDialogue("gbleu2.pe2");
1810 _vm->_globals->_introSpeechOffFl = false;
1811 break;
1812
1813 case 200:
1814 _vm->_globals->_introSpeechOffFl = true;
1815 _vm->_talkMan->startAnimatedCharacterDialogue("Gm2.PE2");
1816 _vm->_globals->_introSpeechOffFl = false;
1817 break;
1818
1819 case 201:
1820 _vm->_objectsMan->setBobAnimation(3);
1821 do {
1822 if (_vm->shouldQuit())
1823 return -1; // Exiting game
1824
1825 _vm->_events->refreshScreenAndEvents();
1826 } while (_vm->_objectsMan->getBobAnimDataIdx(3) != 18);
1827 _vm->_objectsMan->stopBobAnimation(3);
1828 _vm->_objectsMan->setBobAnimation(4);
1829 break;
1830
1831 case 202:
1832 _vm->_globals->_introSpeechOffFl = true;
1833 _vm->_talkMan->startAnimatedCharacterDialogue("SVGARD2.PE2");
1834 _vm->_globals->_introSpeechOffFl = false;
1835 break;
1836
1837 case 203:
1838 _vm->_objectsMan->removeSprite(0);
1839 _vm->_objectsMan->setBobAnimation(4);
1840 do {
1841 if (_vm->shouldQuit())
1842 return -1; // Exiting game
1843
1844 _vm->_events->refreshScreenAndEvents();
1845 if (_vm->_objectsMan->getBobAnimDataIdx(4) == 18)
1846 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 18, 334, 0, false);
1847 } while (_vm->_objectsMan->getBobAnimDataIdx(4) != 26);
1848 _vm->_objectsMan->stopBobAnimation(4);
1849 _vm->_objectsMan->animateSprite(0);
1850 break;
1851
1852 case 204: {
1853 _vm->_objectsMan->removeSprite(0);
1854 _vm->_objectsMan->setBobAnimation(3);
1855 _vm->_soundMan->loadWav("SOUND67.WAV", 1);
1856 bool playFl = false;
1857 for (;;) {
1858 if (_vm->shouldQuit())
1859 return -1; // Exiting game
1860
1861 switch (_vm->_objectsMan->getBobAnimDataIdx(3)) {
1862 case 10:
1863 if (!playFl) {
1864 _vm->_soundMan->playWav(1);
1865 playFl = true;
1866 }
1867 break;
1868 case 11:
1869 playFl = false;
1870 break;
1871 default:
1872 break;
1873 }
1874 _vm->_events->refreshScreenAndEvents();
1875 if (_vm->_objectsMan->getBobAnimDataIdx(3) == 50)
1876 break;
1877 }
1878 _vm->_objectsMan->stopBobAnimation(3);
1879 _vm->_objectsMan->animateSprite(0);
1880 break;
1881 }
1882
1883 case 205: {
1884 _vm->_objectsMan->removeSprite(0);
1885 _vm->_objectsMan->setBobAnimation(4);
1886 _vm->_soundMan->loadWav("SOUND69.WAV", 1);
1887 bool playFl = false;
1888 for (;;) {
1889 if (_vm->shouldQuit())
1890 return -1; // Exiting game
1891
1892 switch (_vm->_objectsMan->getBobAnimDataIdx(4)) {
1893 case 10:
1894 if (!playFl) {
1895 _vm->_soundMan->playWav(1);
1896 playFl = true;
1897 }
1898 break;
1899 case 11:
1900 playFl = false;
1901 break;
1902 default:
1903 break;
1904 }
1905 _vm->_events->refreshScreenAndEvents();
1906 if (_vm->_objectsMan->getBobAnimDataIdx(4) == 24)
1907 break;
1908 }
1909 _vm->_objectsMan->stopBobAnimation(4);
1910 _vm->_objectsMan->animateSprite(0);
1911 break;
1912 }
1913
1914 case 207:
1915 _vm->_talkMan->animateObject("PANNEAU.PE2");
1916 break;
1917
1918 case 208: {
1919 _vm->_globals->_disableInventFl = true;
1920 if (_vm->_globals->_saveData->_data[svLastPrevScreenId] != _vm->_globals->_saveData->_data[svField401]) {
1921 _vm->_soundMan->_specialSoundNum = 208;
1922 _vm->_animMan->playSequence("SORT.SEQ", 10, 4, 10, true, false);
1923 _vm->_soundMan->_specialSoundNum = 0;
1924 }
1925 _vm->_globals->_checkDistanceFl = true;
1926 _vm->_linesMan->_route = (RouteItem *)NULL;
1927 _vm->_linesMan->_route = _vm->_linesMan->findRoute(_vm->_objectsMan->getSpriteX(0), _vm->_objectsMan->getSpriteY(0), 330, 418);
1928 _vm->_globals->_checkDistanceFl = true;
1929 _vm->_objectsMan->_zoneNum = 0;
1930 do {
1931 if (_vm->shouldQuit())
1932 return -1; // Exiting game
1933
1934 _vm->_objectsMan->goHome();
1935 _vm->_events->refreshScreenAndEvents();
1936 } while (_vm->_linesMan->_route != (RouteItem *)NULL);
1937 _vm->_objectsMan->setSpriteIndex(0, 64);
1938 _vm->_globals->_exitId = _vm->_globals->_saveData->_data[svField401];
1939 _vm->_globals->_disableInventFl = false;
1940 break;
1941 }
1942
1943 case 209: {
1944 _vm->_objectsMan->setBobAnimDataIdx(1, 0);
1945 _vm->_objectsMan->setBobAnimDataIdx(2, 0);
1946 _vm->_objectsMan->setSpriteIndex(0, 60);
1947 _vm->_objectsMan->stopBobAnimation(4);
1948 _vm->_objectsMan->setBobAnimation(1);
1949 do {
1950 if (_vm->shouldQuit())
1951 return -1; // Exiting game
1952
1953 _vm->_events->refreshScreenAndEvents();
1954 } while (_vm->_objectsMan->getBobAnimDataIdx(1) != 9);
1955 _vm->_objectsMan->stopBobAnimation(1);
1956 _vm->_linesMan->_route = (RouteItem *)NULL;
1957 _vm->_globals->_checkDistanceFl = true;
1958 _vm->_linesMan->_route = _vm->_linesMan->findRoute(_vm->_objectsMan->getSpriteX(0), _vm->_objectsMan->getSpriteY(0), 330, 314);
1959 _vm->_objectsMan->_zoneNum = 0;
1960 _vm->_globals->_checkDistanceFl = true;
1961 do {
1962 if (_vm->shouldQuit())
1963 return -1; // Exiting game
1964
1965 _vm->_objectsMan->goHome();
1966 _vm->_events->refreshScreenAndEvents();
1967 } while (_vm->_linesMan->_route != (RouteItem *)NULL);
1968 _vm->_objectsMan->setSpriteIndex(0, 64);
1969 _vm->_objectsMan->setBobAnimation(2);
1970 _vm->_soundMan->playSoundFile("SOUND66.WAV");
1971 do {
1972 if (_vm->shouldQuit())
1973 return -1; // Exiting game
1974
1975 _vm->_events->refreshScreenAndEvents();
1976 } while (_vm->_objectsMan->getBobAnimDataIdx(2) != 10);
1977 _vm->_objectsMan->stopBobAnimation(2);
1978 _vm->_objectsMan->setBobAnimation(4);
1979 break;
1980 }
1981
1982 case 210:
1983 _vm->_soundMan->_specialSoundNum = 210;
1984 _vm->_animMan->playSequence2("SECRET1.SEQ", 1, 12, 1, true);
1985 _vm->_soundMan->_specialSoundNum = 0;
1986 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 192, 152, 0);
1987 _vm->_objectsMan->setBobAnimation(9);
1988 _vm->_objectsMan->loadLinkFile("IM73a", true);
1989 _vm->_objectsMan->enableHidingBehavior();
1990 _vm->_objectsMan->setHidingUseCount(0);
1991 _vm->_objectsMan->setHidingUseCount(1);
1992 _vm->_graphicsMan->setColorPercentage2(252, 100, 100, 100);
1993 _vm->_graphicsMan->setColorPercentage2(253, 100, 100, 100);
1994 _vm->_graphicsMan->setColorPercentage2(251, 100, 100, 100);
1995 _vm->_graphicsMan->setColorPercentage2(254, 0, 0, 0);
1996 break;
1997
1998 case 211:
1999 _vm->_objectsMan->removeSprite(0);
2000 _vm->_objectsMan->disableHidingBehavior();
2001 _vm->_soundMan->_specialSoundNum = 211;
2002 _vm->_animMan->playSequence("SECRET2.SEQ", 1, 12, 100, false, true);
2003 _vm->_soundMan->_specialSoundNum = 0;
2004 _vm->_graphicsMan->_noFadingFl = true;
2005 _vm->_graphicsMan->fadeOutShort();
2006
2007 for (int i = 1; i <= 39; i++) {
2008 if (_vm->shouldQuit())
2009 return -1; // Exiting game
2010
2011 _vm->_events->refreshScreenAndEvents();
2012 }
2013
2014 _vm->_graphicsMan->setColorPercentage2(252, 100, 100, 100);
2015 _vm->_graphicsMan->setColorPercentage2(253, 100, 100, 100);
2016 _vm->_graphicsMan->setColorPercentage2(251, 100, 100, 100);
2017 _vm->_graphicsMan->setColorPercentage2(254, 0, 0, 0);
2018 break;
2019
2020 case 215:
2021 _vm->_globals->_introSpeechOffFl = true;
2022 _vm->_talkMan->startAnimatedCharacterDialogue("aviat.pe2");
2023 _vm->_globals->_introSpeechOffFl = false;
2024 break;
2025
2026 case 216:
2027 // Discuss with pilot just before Flight cutscene
2028 _vm->_globals->_introSpeechOffFl = true;
2029 _vm->_talkMan->startAnimatedCharacterDialogue("aviat1.pe2");
2030 _vm->_globals->_introSpeechOffFl = false;
2031 break;
2032
2033 case 229:
2034 _vm->_soundMan->_specialSoundNum = 229;
2035 _vm->_animMan->playSequence("MUR.SEQ", 1, 12, 1, false, false);
2036 _vm->_soundMan->_specialSoundNum = 0;
2037 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 340, 157, 2);
2038 break;
2039
2040 case 230: {
2041 _vm->_objectsMan->loadLinkFile("IM93a", true);
2042 _vm->_objectsMan->enableHidingBehavior();
2043 _vm->_globals->_checkDistanceFl = true;
2044 _vm->_objectsMan->_oldCharacterPosX = _vm->_objectsMan->getSpriteX(0);
2045 _vm->_objectsMan->resetOldDirection();
2046 _vm->_objectsMan->resetHomeRateCounter();
2047 _vm->_globals->_checkDistanceFl = true;
2048 _vm->_linesMan->_route = (RouteItem *)NULL;
2049 _vm->_linesMan->_route = _vm->_linesMan->findRoute(_vm->_objectsMan->getSpriteX(0), _vm->_objectsMan->getSpriteY(0), 488, 280);
2050 _vm->_globals->_checkDistanceFl = true;
2051 do {
2052 if (_vm->shouldQuit())
2053 return -1; // Exiting game
2054
2055 _vm->_objectsMan->goHome();
2056 _vm->_events->refreshScreenAndEvents();
2057 } while (_vm->_linesMan->_route != (RouteItem *)NULL);
2058 _vm->_objectsMan->removeSprite(0);
2059 bool playFl = false;
2060 _vm->_objectsMan->setBobAnimation(7);
2061 do {
2062 if (_vm->shouldQuit())
2063 return -1; // Exiting game
2064
2065 if (_vm->_objectsMan->getBobAnimDataIdx(7) == 9 && !playFl) {
2066 playFl = true;
2067 _vm->_soundMan->playSoundFile("SOUND81.WAV");
2068 }
2069 _vm->_events->refreshScreenAndEvents();
2070 } while (_vm->_objectsMan->getBobAnimDataIdx(7) != 15);
2071 _vm->_objectsMan->stopBobAnimation(7);
2072 _vm->_objectsMan->setSpriteX(0, 476);
2073 _vm->_objectsMan->setSpriteY(0, 278);
2074 _vm->_objectsMan->animateSprite(0);
2075 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 337, 154, 3);
2076 _vm->_objectsMan->loadLinkFile("IM93c", true);
2077 _vm->_objectsMan->enableHidingBehavior();
2078 break;
2079 }
2080
2081 case 231:
2082 _vm->_objectsMan->disableHidingBehavior();
2083 _vm->_objectsMan->removeSprite(0);
2084 _vm->_objectsMan->setBobAnimation(12);
2085 do {
2086 if (_vm->shouldQuit())
2087 return -1; // Exiting game
2088
2089 _vm->_events->refreshScreenAndEvents();
2090 } while (_vm->_objectsMan->getBobAnimDataIdx(12) != 6);
2091 _vm->_globals->_introSpeechOffFl = true;
2092 _vm->_talkMan->startAnimatedCharacterDialogue("PRMORT.pe2");
2093 _vm->_globals->_introSpeechOffFl = false;
2094 do {
2095 if (_vm->shouldQuit())
2096 return -1; // Exiting game
2097
2098 _vm->_events->refreshScreenAndEvents();
2099 } while (_vm->_objectsMan->getBobAnimDataIdx(12) != 12);
2100 _vm->_objectsMan->animateSprite(0);
2101 _vm->_objectsMan->stopBobAnimation(12);
2102 _vm->_objectsMan->enableHidingBehavior();
2103 break;
2104
2105 case 233: {
2106 _vm->_objectsMan->disableHidingBehavior();
2107 _vm->_objectsMan->removeSprite(0);
2108 _vm->_objectsMan->setBobAnimation(11);
2109 bool playFl = false;
2110 do {
2111 if (_vm->shouldQuit())
2112 return -1; // Exiting game
2113
2114 _vm->_events->refreshScreenAndEvents();
2115 if (_vm->_objectsMan->getBobAnimDataIdx(11) == 10 && !playFl)
2116 playFl = true;
2117 } while (_vm->_objectsMan->getBobAnimDataIdx(11) != 13);
2118 _vm->_objectsMan->stopBobAnimation(11);
2119 _vm->_objectsMan->enableHidingBehavior();
2120 _vm->_objectsMan->setBobAnimation(13);
2121 do {
2122 if (_vm->shouldQuit())
2123 return -1; // Exiting game
2124
2125 _vm->_events->refreshScreenAndEvents();
2126 } while (_vm->_objectsMan->getBobAnimDataIdx(13) != 48);
2127 _vm->_globals->_introSpeechOffFl = true;
2128 _vm->_talkMan->startAnimatedCharacterDialogue("HRADIO.PE2");
2129 _vm->_globals->_introSpeechOffFl = false;
2130 _vm->_graphicsMan->fadeOutLong();
2131 _vm->_objectsMan->stopBobAnimation(13);
2132 _vm->_graphicsMan->_noFadingFl = true;
2133 _vm->_globals->_exitId = 94;
2134 break;
2135 }
2136
2137 case 236: {
2138 if (_vm->_globals->_saveData->_data[svField341]) {
2139 switch (_vm->_globals->_saveData->_data[svField341]) {
2140 case 1:
2141 vbobFrameIndex = 6;
2142 break;
2143 case 2:
2144 vbobFrameIndex = 5;
2145 break;
2146 case 3:
2147 vbobFrameIndex = 4;
2148 break;
2149 default:
2150 break;
2151 }
2152 _vm->_soundMan->playSoundFile("SOUND83.WAV");
2153 _vm->_objectsMan->setAndPlayAnim(vbobFrameIndex, 26, 50, false);
2154
2155 switch (_vm->_globals->_saveData->_data[svField341]) {
2156 case 1:
2157 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 27, 117, 0);
2158 _vm->_globals->_saveData->_data[svField338] = 0;
2159 break;
2160 case 2:
2161 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 145, 166, 2);
2162 _vm->_globals->_saveData->_data[svField339] = 0;
2163 break;
2164 case 3:
2165 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 296, 212, 4);
2166 _vm->_globals->_saveData->_data[svField340] = 0;
2167 break;
2168 default:
2169 break;
2170 }
2171 }
2172 _vm->_soundMan->playSoundFile("SOUND83.WAV");
2173 _vm->_objectsMan->setAndPlayAnim(6, 0, 23, false);
2174 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 27, 117, 1);
2175 break;
2176 }
2177
2178 case 237: {
2179 switch (_vm->_globals->_saveData->_data[svField341]) {
2180 case 1:
2181 vbobFrameIndex = 6;
2182 break;
2183 case 2:
2184 vbobFrameIndex = 5;
2185 break;
2186 case 3:
2187 vbobFrameIndex = 4;
2188 break;
2189 default:
2190 break;
2191 }
2192
2193 if (_vm->_globals->_saveData->_data[svField341]) {
2194 _vm->_soundMan->playSoundFile("SOUND83.WAV");
2195 _vm->_objectsMan->setAndPlayAnim(vbobFrameIndex, 26, 50, false);
2196
2197 switch (_vm->_globals->_saveData->_data[svField341]) {
2198 case 1:
2199 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 27, 117, 0);
2200 _vm->_globals->_saveData->_data[svField338] = 0;
2201 break;
2202 case 2:
2203 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 145, 166, 2);
2204 _vm->_globals->_saveData->_data[svField339] = 0;
2205 break;
2206 case 3:
2207 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 296, 212, 4);
2208 _vm->_globals->_saveData->_data[svField340] = 0;
2209 break;
2210 default:
2211 break;
2212 }
2213 }
2214
2215 _vm->_soundMan->playSoundFile("SOUND83.WAV");
2216 _vm->_objectsMan->setAndPlayAnim(5, 0, 23, false);
2217 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 145, 166, 3);
2218 break;
2219 }
2220
2221 case 238: {
2222 switch (_vm->_globals->_saveData->_data[svField341]) {
2223 case 1:
2224 vbobFrameIndex = 6;
2225 break;
2226 case 2:
2227 vbobFrameIndex = 5;
2228 break;
2229 case 3:
2230 vbobFrameIndex = 4;
2231 break;
2232 default:
2233 break;
2234 }
2235
2236 if (_vm->_globals->_saveData->_data[svField341]) {
2237 _vm->_soundMan->playSoundFile("SOUND83.WAV");
2238 _vm->_objectsMan->setAndPlayAnim(vbobFrameIndex, 26, 50, false);
2239 switch (_vm->_globals->_saveData->_data[svField341]) {
2240 case 1:
2241 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 27, 117, 0);
2242 _vm->_globals->_saveData->_data[svField338] = 0;
2243 break;
2244 case 2:
2245 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 145, 166, 2);
2246 _vm->_globals->_saveData->_data[svField339] = 0;
2247 break;
2248 case 3:
2249 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 296, 212, 4);
2250 _vm->_globals->_saveData->_data[svField340] = 0;
2251 break;
2252 default:
2253 break;
2254 }
2255 }
2256 _vm->_soundMan->playSoundFile("SOUND83.WAV");
2257 _vm->_objectsMan->setAndPlayAnim(4, 0, 23, false);
2258 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 296, 212, 5);
2259 break;
2260 }
2261
2262 case 239:
2263 _vm->_objectsMan->removeSprite(0);
2264 _vm->_soundMan->playSoundFile("SOUND84.WAV");
2265 _vm->_objectsMan->setAndPlayAnim(16, 0, 10, false);
2266 break;
2267
2268 case 240: {
2269 _vm->_objectsMan->setBobAnimation(1);
2270 bool soundFlag = false;
2271 do {
2272 if (_vm->shouldQuit())
2273 return -1; // Exiting game
2274
2275 _vm->_events->refreshScreenAndEvents();
2276 switch (_vm->_objectsMan->getBobAnimDataIdx(1)) {
2277 case 12:
2278 if (!soundFlag) {
2279 _vm->_soundMan->playSoundFile("SOUND86.WAV");
2280 soundFlag = true;
2281 }
2282 break;
2283 case 13:
2284 // The original was starting then stopping sound at 25
2285 // It looked wrong so the check was set on 26
2286 case 26:
2287 soundFlag = false;
2288 break;
2289 case 25:
2290 if (!soundFlag) {
2291 _vm->_soundMan->playSoundFile("SOUND85.WAV");
2292 soundFlag = true;
2293 }
2294 break;
2295 default:
2296 break;
2297 }
2298 } while (_vm->_objectsMan->getBobAnimDataIdx(1) != 32);
2299 _vm->_objectsMan->stopBobAnimation(1);
2300 _vm->_objectsMan->setBobAnimation(2);
2301 _vm->_fontMan->hideText(9);
2302 bool displayedTxtFl = false;
2303 if (!_vm->_soundMan->_textOffFl) {
2304 _vm->_fontMan->initTextBuffers(9, 617, _vm->_globals->_textFilename, 91, 41, 3, 30, 253);
2305 _vm->_fontMan->showText(9);
2306 displayedTxtFl = true;
2307 }
2308 if (!_vm->_soundMan->_voiceOffFl)
2309 _vm->_soundMan->mixVoice(617, 4, displayedTxtFl);
2310 for (int i = 0; i <= 29; i++) {
2311 if (_vm->shouldQuit())
2312 return -1; // Exiting game
2313
2314 _vm->_events->refreshScreenAndEvents();
2315 }
2316 CharacterLocation *realHopkins = &_vm->_globals->_saveData->_realHopkins;
2317 realHopkins->_pos.x = _vm->_objectsMan->getSpriteX(0);
2318 realHopkins->_pos.y = _vm->_objectsMan->getSpriteY(0);
2319 realHopkins->_startSpriteIndex = 57;
2320 realHopkins->_location = 97;
2321 _vm->_globals->_saveData->_data[svHopkinsCloneFl] = 1;
2322 _vm->_globals->_saveData->_data[svField352] = 1;
2323 _vm->_globals->_saveData->_data[svField353] = 1;
2324 _vm->_globals->_saveData->_data[svField354] = 1;
2325 break;
2326 }
2327
2328 case 241:
2329 _vm->_talkMan->startAnimatedCharacterDialogue("RECEP.PE2");
2330 break;
2331
2332 // Resurrect Samantha's clone
2333 case 242: {
2334 _vm->_soundMan->playSoundFile("SOUND87.WAV");
2335 _vm->_animMan->playSequence("RESUF.SEQ", 1, 24, 1, false, true);
2336
2337 CharacterLocation *samantha = &_vm->_globals->_saveData->_samantha;
2338 samantha->_pos.x = 404;
2339 samantha->_pos.y = 395;
2340 samantha->_startSpriteIndex = 64;
2341 samantha->_location = _vm->_globals->_screenId;
2342 samantha->_zoomFactor = -(100 * (67 - (100 - abs(_vm->_globals->_spriteSize[790 / 2]))) / 67);
2343
2344 _vm->_globals->_saveData->_data[svField357] = 1;
2345 _vm->_globals->_saveData->_data[svField354] = 0;
2346 _vm->_globals->_saveData->_data[svField356] = 0;
2347 _vm->_globals->_saveData->_data[svField355] = 1;
2348 _vm->_objectsMan->_twoCharactersFl = true;
2349 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 373, 191, 3);
2350 _vm->_objectsMan->addStaticSprite(_vm->_objectsMan->_headSprites, samantha->_pos, 1, 3, samantha->_zoomFactor, false, 20, 127);
2351 _vm->_objectsMan->animateSprite(1);
2352 break;
2353 }
2354
2355 case 243:
2356 _vm->_soundMan->playSoundFile("SOUND88.WAV");
2357 if (_vm->_globals->_saveData->_data[svField341] == 2) {
2358 _vm->_animMan->playSequence("RESU.SEQ", 2, 24, 2, false, true);
2359 } else {
2360 _vm->_objectsMan->setAndPlayAnim(7, 0, 14, false);
2361 }
2362 break;
2363
2364 case 245:
2365 _vm->_soundMan->playSoundFile("SOUND89.WAV");
2366 _vm->_objectsMan->setAndPlayAnim(5, 0, 6, false);
2367 _vm->_linesMan->_zone[4]._destX = 276;
2368 _vm->_objectsMan->enableVerb(4, 19);
2369 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 285, 379, 0);
2370 _vm->_globals->_saveData->_data[svField399] = 1;
2371 break;
2372
2373 case 246:
2374 _vm->_objectsMan->removeSprite(0);
2375 _vm->_objectsMan->setAndPlayAnim(6, 0, 15, false);
2376 _vm->_objectsMan->_charactersEnabledFl = true;
2377 _vm->_graphicsMan->displayScreen(true);
2378 _vm->_animMan->playSequence2("TUNNEL.SEQ", 1, 18, 20, true);
2379 _vm->_graphicsMan->_noFadingFl = true;
2380 _vm->_graphicsMan->fadeOutLong();
2381 _vm->_objectsMan->_charactersEnabledFl = false;
2382 _vm->_globals->_exitId = 100;
2383 break;
2384
2385 case 600:
2386 if (!_vm->getIsDemo()) {
2387 _vm->_graphicsMan->_fadingFl = true;
2388 _vm->_graphicsMan->_fadeDefaultSpeed = 1;
2389 _vm->_animMan->playAnim("BOMBE1A.ANM", "BOMBE1.ANM", 100, 18, 100);
2390 }
2391 _vm->_graphicsMan->loadImage("BOMBEB");
2392 _vm->_graphicsMan->setColorPercentage(252, 100, 100, 100);
2393 _vm->_graphicsMan->setColorPercentage(253, 100, 100, 100);
2394 _vm->_graphicsMan->setColorPercentage(251, 100, 100, 100);
2395 _vm->_graphicsMan->setColorPercentage(254, 0, 0, 0);
2396 _vm->_graphicsMan->initScreen("BOMBE", 2, true);
2397 _vm->_graphicsMan->fadeInShort();
2398 break;
2399
2400 case 601:
2401 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 513, 163, 7, false);
2402 _vm->_objectsMan->setAndPlayAnim(2, 0, 16, true);
2403 break;
2404
2405 case 602:
2406 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 513, 163, 7, false);
2407 _vm->_objectsMan->setAndPlayAnim(4, 0, 16, true);
2408 break;
2409
2410 case 603:
2411 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 513, 163, 7, false);
2412 _vm->_objectsMan->setAndPlayAnim(3, 0, 16, true);
2413 _vm->_soundMan->_specialSoundNum = 199;
2414 _vm->_graphicsMan->_fadingFl = true;
2415 _vm->_animMan->playAnim("BOMBE2A.ANM", "BOMBE2.ANM", 50, 14, 500);
2416 _vm->_soundMan->_specialSoundNum = 0;
2417 memset(_vm->_graphicsMan->_frontBuffer, 0, 614400);
2418 _vm->_graphicsMan->_noFadingFl = true;
2419 _vm->_globals->_exitId = 151;
2420 break;
2421
2422 case 604:
2423 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 513, 163, 7, false);
2424 _vm->_objectsMan->setAndPlayAnim(1, 0, 16, true);
2425 _vm->_soundMan->_specialSoundNum = 199;
2426 _vm->_animMan->playAnim("BOMBE2A.ANM", "BOMBE2.ANM", 50, 14, 500);
2427 _vm->_soundMan->_specialSoundNum = 0;
2428 _vm->_graphicsMan->_noFadingFl = true;
2429 memset(_vm->_graphicsMan->_frontBuffer, 0, 614400);
2430 _vm->_globals->_exitId = 151;
2431 break;
2432
2433 case 605:
2434 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 513, 163, 7, false);
2435 _vm->_objectsMan->setAndPlayAnim(5, 0, 16, true);
2436 _vm->_graphicsMan->fadeOutShort();
2437 _vm->_soundMan->_specialSoundNum = 199;
2438 _vm->_graphicsMan->_fadingFl = true;
2439 _vm->_animMan->playAnim("BOMBE2A.ANM", "BOMBE2.ANM", 50, 14, 500);
2440 _vm->_soundMan->_specialSoundNum = 0;
2441 _vm->_graphicsMan->_noFadingFl = true;
2442 memset(_vm->_graphicsMan->_frontBuffer, 0, 614400);
2443 _vm->_globals->_exitId = 151;
2444 break;
2445
2446 case 606:
2447 _vm->_graphicsMan->fastDisplay(_vm->_globals->_levelSpriteBuf, 513, 163, 7, false);
2448 _vm->_objectsMan->setAndPlayAnim(6, 0, 16, true);
2449 if ((_vm->getPlatform() != Common::kPlatformWindows) || !_vm->getIsDemo()) {
2450 _vm->_animMan->playAnim("BOMBE3A.ANM", "BOMBE3.ANM", 50, 14, 500);
2451 memset(_vm->_graphicsMan->_frontBuffer, 0, 614400);
2452 }
2453 _vm->_globals->_exitId = 6;
2454 break;
2455
2456 case 607:
2457 // Display bomb plan
2458 if (!_vm->getIsDemo()) {
2459 memcpy(_vm->_graphicsMan->_oldPalette, _vm->_graphicsMan->_palette, 769);
2460 _vm->_animMan->playAnim2("PLAN.ANM", "PLAN.ANM", 50, 10, 800);
2461 }
2462 _vm->_graphicsMan->resetDirtyRects();
2463 break;
2464
2465 case 608:
2466 _vm->_objectsMan->stopBobAnimation(2);
2467 _vm->_objectsMan->stopBobAnimation(3);
2468 _vm->_objectsMan->stopBobAnimation(4);
2469 _vm->_objectsMan->stopBobAnimation(6);
2470 _vm->_objectsMan->stopBobAnimation(11);
2471 _vm->_objectsMan->stopBobAnimation(10);
2472 break;
2473
2474 case 609:
2475 _vm->_objectsMan->setBobAnimation(2);
2476 _vm->_objectsMan->setBobAnimation(3);
2477 _vm->_objectsMan->setBobAnimation(4);
2478 _vm->_objectsMan->setBobAnimation(6);
2479 _vm->_objectsMan->setBobAnimation(11);
2480 _vm->_objectsMan->setBobAnimation(10);
2481 break;
2482
2483 case 610:
2484 _vm->_objectsMan->stopBobAnimation(5);
2485 _vm->_objectsMan->stopBobAnimation(7);
2486 _vm->_objectsMan->stopBobAnimation(8);
2487 _vm->_objectsMan->stopBobAnimation(9);
2488 _vm->_objectsMan->stopBobAnimation(12);
2489 _vm->_objectsMan->stopBobAnimation(13);
2490 break;
2491
2492 case 611:
2493 _vm->_objectsMan->setBobAnimation(5);
2494 _vm->_objectsMan->setBobAnimation(7);
2495 _vm->_objectsMan->setBobAnimation(8);
2496 _vm->_objectsMan->setBobAnimation(9);
2497 _vm->_objectsMan->setBobAnimation(12);
2498 _vm->_objectsMan->setBobAnimation(13);
2499 break;
2500
2501 default:
2502 break;
2503 }
2504 opcodeType = 1;
2505 break;
2506 case MKTAG24('E', 'I', 'F'):
2507 opcodeType = 4;
2508 break;
2509 case MKTAG24('V', 'A', 'L'): {
2510 opcodeType = 1;
2511 int idx = READ_LE_INT16(dataP + 5);
2512 assert(idx >= 0 && idx < 2050);
2513 _vm->_globals->_saveData->_data[idx] = dataP[7];
2514 break;
2515 }
2516 case MKTAG24('A', 'D', 'D'):
2517 opcodeType = 1;
2518 _vm->_globals->_saveData->_data[READ_LE_INT16(dataP + 5)] += dataP[7];
2519 break;
2520 case MKTAG24('B', 'O', 'S'):
2521 opcodeType = 1;
2522 _vm->_objectsMan->setBobOffset(READ_LE_INT16(dataP + 5), READ_LE_INT16(dataP + 7));
2523 break;
2524 case MKTAG24('V', 'O', 'N'):
2525 _vm->_objectsMan->enableVerb(READ_LE_INT16(dataP + 5), READ_LE_INT16(dataP + 7));
2526 opcodeType = 1;
2527 break;
2528 case MKTAG24('Z', 'C', 'H'):
2529 _vm->_linesMan->_zone[READ_LE_INT16(dataP + 5)]._messageId = READ_LE_INT16(dataP + 7);
2530 opcodeType = 1;
2531 break;
2532 case MKTAG24('J', 'U', 'M'):
2533 _vm->_objectsMan->_jumpZone = READ_LE_INT16(dataP + 5);
2534 _vm->_objectsMan->_jumpVerb = READ_LE_INT16(dataP + 7);
2535 opcodeType = 6;
2536 break;
2537 case MKTAG24('S', 'O', 'U'): {
2538 int soundNum = READ_LE_INT16(dataP + 5);
2539
2540 Common::String file = Common::String::format("SOUND%d.WAV", soundNum);
2541 _vm->_soundMan->playSoundFile(file);
2542 opcodeType = 1;
2543 break;
2544 }
2545 case MKTAG24('V', 'O', 'F'):
2546 _vm->_objectsMan->disableVerb(READ_LE_INT16(dataP + 5), READ_LE_INT16(dataP + 7));
2547 opcodeType = 1;
2548 break;
2549 case MKTAG24('I', 'I', 'F'):
2550 opcodeType = 3;
2551 break;
2552 default:
2553 warning("Unhandled opcode %c%c%c", dataP[2], dataP[3], dataP[4]);
2554 break;
2555 }
2556
2557 return opcodeType;
2558 }
2559
2560
handleGoto(const byte * dataP)2561 int ScriptManager::handleGoto(const byte *dataP) {
2562 return READ_LE_INT16(dataP + 5);
2563 }
2564
handleIf(const byte * dataP,int offset)2565 int ScriptManager::handleIf(const byte *dataP, int offset) {
2566 int newOffset;
2567 int curOffset = offset;
2568 bool loopFl;
2569 do {
2570 loopFl = false;
2571 int tmpOffset = curOffset;
2572 int opcodeType;
2573 do {
2574 if (_vm->shouldQuit())
2575 return 0; // Exiting game
2576
2577 ++tmpOffset;
2578 if (tmpOffset > 400)
2579 error("Control if failed");
2580 opcodeType = checkOpcode(dataP + 20 * tmpOffset);
2581 } while (opcodeType != 4); // EIF
2582 newOffset = tmpOffset;
2583 tmpOffset = curOffset;
2584 do {
2585 if (_vm->shouldQuit())
2586 return 0; // Exiting game
2587
2588 ++tmpOffset;
2589 if (tmpOffset > 400)
2590 error("Control if failed ");
2591 if (checkOpcode(dataP + 20 * tmpOffset) == 3) { // IIF
2592 curOffset = newOffset;
2593 loopFl = true;
2594 break;
2595 }
2596 } while (newOffset != tmpOffset);
2597 } while (loopFl);
2598
2599 const byte *buf = dataP + 20 * offset;
2600 byte oper = buf[13];
2601 byte oper2 = buf[14];
2602 byte operType = buf[15];
2603 int saveDataIdx1 = READ_LE_INT16(buf + 5);
2604 int compVal1 = READ_LE_INT16(buf + 7);
2605 bool check1Fl = false;
2606 if ((oper == 1 && _vm->_globals->_saveData->_data[saveDataIdx1] == compVal1) ||
2607 (oper == 2 && _vm->_globals->_saveData->_data[saveDataIdx1] != compVal1) ||
2608 (oper == 3 && _vm->_globals->_saveData->_data[saveDataIdx1] <= compVal1) ||
2609 (oper == 4 && _vm->_globals->_saveData->_data[saveDataIdx1] >= compVal1) ||
2610 (oper == 5 && _vm->_globals->_saveData->_data[saveDataIdx1] > compVal1) ||
2611 (oper == 6 && _vm->_globals->_saveData->_data[saveDataIdx1] < compVal1))
2612 check1Fl = true;
2613
2614 bool check2Fl = false;
2615 if (operType != 3) {
2616 int saveDataIdx2 = READ_LE_INT16(buf + 9);
2617 int compVal2 = READ_LE_INT16(buf + 11);
2618 if ((oper2 == 1 && compVal2 == _vm->_globals->_saveData->_data[saveDataIdx2]) ||
2619 (oper2 == 2 && compVal2 != _vm->_globals->_saveData->_data[saveDataIdx2]) ||
2620 (oper2 == 3 && compVal2 >= _vm->_globals->_saveData->_data[saveDataIdx2]) ||
2621 (oper2 == 4 && compVal2 <= _vm->_globals->_saveData->_data[saveDataIdx2]) ||
2622 (oper2 == 5 && compVal2 < _vm->_globals->_saveData->_data[saveDataIdx2]) ||
2623 (oper2 == 6 && compVal2 > _vm->_globals->_saveData->_data[saveDataIdx2]))
2624 check2Fl = true;
2625 }
2626
2627 if ((operType == 3) && check1Fl) {
2628 return (offset + 1);
2629 } else if ((operType == 1) && check1Fl && check2Fl) {
2630 return (offset + 1);
2631 } else if ((operType == 2) && (check1Fl || check2Fl)) {
2632 return (offset + 1);
2633 }
2634
2635 return (newOffset + 1);
2636 }
2637
checkOpcode(const byte * dataP)2638 int ScriptManager::checkOpcode(const byte *dataP) {
2639 int result = 0;
2640 if (READ_BE_UINT16(dataP) != MKTAG16('F', 'C'))
2641 return result;
2642
2643 uint32 signature24 = READ_BE_UINT24(&dataP[2]);
2644 switch (signature24) {
2645 case MKTAG24('A', 'N', 'I'):
2646 case MKTAG24('B', 'C', 'A'):
2647 case MKTAG24('B', 'O', 'B'):
2648 case MKTAG24('B', 'O', 'F'):
2649 case MKTAG24('B', 'O', 'S'):
2650 case MKTAG24('M', 'U', 'S'):
2651 case MKTAG24('O', 'B', 'M'):
2652 case MKTAG24('O', 'B', 'P'):
2653 case MKTAG24('P', 'E', 'R'):
2654 case MKTAG24('S', 'O', 'U'):
2655 case MKTAG24('S', 'P', 'E'):
2656 case MKTAG24('T', 'X', 'T'):
2657 case MKTAG24('V', 'A', 'L'):
2658 case MKTAG24('V', 'O', 'F'):
2659 case MKTAG24('V', 'O', 'N'):
2660 case MKTAG24('Z', 'C', 'H'):
2661 case MKTAG24('Z', 'O', 'F'):
2662 case MKTAG24('Z', 'O', 'N'):
2663 result = 1;
2664 break;
2665 case MKTAG24('G', 'O', 'T'):
2666 result = 2;
2667 break;
2668 case MKTAG24('I', 'I', 'F'):
2669 result = 3;
2670 break;
2671 case MKTAG24('E', 'I', 'F'):
2672 result = 4;
2673 break;
2674 case MKTAG24('E', 'X', 'I'):
2675 case MKTAG24('S', 'O', 'R'):
2676 result = 5;
2677 break;
2678 case MKTAG24('J', 'U', 'M'):
2679 result = 6;
2680 break;
2681 default:
2682 warning("Unhandled opcode %c%c%c", dataP[2], dataP[3], dataP[4]);
2683 break;
2684 }
2685 return result;
2686 }
2687
2688 } // End of namespace Hopkins
2689