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 
24 
25 #include "engines/engine.h"
26 
27 #include "common/config-manager.h"
28 
29 #include "scumm/scumm_v7.h"
30 #include "scumm/sound.h"
31 
32 #include "scumm/insane/insane.h"
33 
34 namespace Scumm {
35 
runScene(int arraynum)36 void Insane::runScene(int arraynum) {
37 	_insaneIsRunning = true;
38 	_player = _vm->_splayer;
39 	_player->insanity(true);
40 
41 	_numberArray = arraynum;
42 
43 	// zeroValues1()
44 	_objArray2Idx = 0;
45 	_objArray2Idx2 = 0;
46 	// zeroValues2()
47 	_objArray1Idx = 0;
48 	_objArray1Idx2 = 0;
49 	// zeroValues3()
50 	_currScenePropIdx = 0;
51 	_currScenePropSubIdx = 0;
52 	_currTrsMsg = 0;
53 
54 	smush_warpMouse(160, 100, -1);
55 	putActors();
56 	readState();
57 
58 	debugC(DEBUG_INSANE, "INSANE Arg: %d", readArray(0));
59 
60 	switch (readArray(0)) {
61 	case 1:
62 		initScene(1);
63 		setupValues();
64 		if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS))
65 			smlayer_setActorCostume(0, 2, readArray(9));
66 		else
67 			smlayer_setActorCostume(0, 2, readArray(10));
68 		smlayer_putActor(0, 2, _actor[0].x, _actor[0].y1 + 190, _smlayer_room2);
69 		startVideo("minedriv.san", 1, 32, 12, 0);
70 		break;
71 	case 2:
72 		setupValues();
73 		if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS))
74 			smlayer_setActorCostume(0, 2, readArray(10));
75 		else
76 			smlayer_setActorCostume(0, 2, readArray(11));
77 		smlayer_putActor(0, 2, _actor[0].x, _actor[0].y1 + 190, _smlayer_room2);
78 
79 		_mainRoadPos = readArray(2);
80 		if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS)) {
81 			initScene(5);
82 			startVideo("tovista.san", 1, 32, 12, 0);
83 		} else if (_mainRoadPos == _posBrokenTruck) {
84 			initScene(5);
85 			startVideo("tovista2.san", 1, 32, 12, 0);
86 		} else if (_mainRoadPos == _posBrokenCar) {
87 			initScene(5);
88 			startVideo("tovista2.san", 1, 32, 12, 0, _smush_tovista2Flu, 60);
89 		} else {
90 			initScene(4);
91 			startVideo("tovista1.san", 1, 32, 12, 0);
92 		}
93 		break;
94 	case 3:
95 		setupValues();
96 		if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS))
97 			smlayer_setActorCostume(0, 2, readArray(10));
98 		else
99 			smlayer_setActorCostume(0, 2, readArray(11));
100 		smlayer_putActor(0, 2, _actor[0].x, _actor[0].y1 + 190, _smlayer_room2);
101 		_mainRoadPos = readArray(2);
102 		if (_mainRoadPos == _posBrokenTruck) {
103 			initScene(6);
104 			startVideo("toranch.san", 1, 32, 12, 0, _smush_toranchFlu, 300);
105 		} else if (_mainRoadPos == _posBrokenCar) {
106 			initScene(6);
107 			startVideo("toranch.san", 1, 32, 12, 0, _smush_toranchFlu, 240);
108 		} else {
109 			initScene(6);
110 			startVideo("toranch.san", 1, 32, 12, 0);
111 		}
112 		break;
113 	case 4:
114 		_firstBattle = true;
115 		_currEnemy = EN_ROTT1;
116 		initScene(13);
117 		startVideo("minefite.san", 1, 32, 12, 0);
118 		break;
119 	case 5:
120 		writeArray(1, _val54d);
121 		initScene(24);
122 		startVideo("rottopen.san", 1, 32, 12, 0);
123 		break;
124 	case 6:
125 		initScene(1);
126 		setupValues();
127 		smlayer_setFluPalette(_smush_roadrashRip, 1);
128 		smlayer_setActorCostume(0, 2, readArray(10));
129 		smlayer_putActor(0, 2, _actor[0].x, _actor[0].y1 + 190, _smlayer_room2);
130 		startVideo("minedriv.san", 1, 32, 12, 0, _smush_minedrivFlu, 420);
131 		break;
132 	case 7:
133 	case 8:
134 	case 9:
135 		break;
136 	case 10:
137 		initScene(26);
138 		writeArray(1, _val54d);
139 		startVideo("credits.san", 1, 32, 12, 0);
140 		break;
141 	default:
142 		error("Unknown FT_INSANE mode %d", readArray(0));
143 	}
144 
145 	putActors();
146 	_enemy[EN_ROTT3].maxdamage = 120;
147 
148 	_insaneIsRunning = false;
149 	_player->insanity(false);
150 
151 	if (!((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS))) {
152 		writeArray(50, _actor[0].inventory[INV_CHAIN]);
153 		writeArray(51, _actor[0].inventory[INV_CHAINSAW]);
154 		writeArray(52, _actor[0].inventory[INV_MACE]);
155 		writeArray(53, _actor[0].inventory[INV_2X4]);
156 		writeArray(54, _actor[0].inventory[INV_WRENCH]);
157 		writeArray(55, _actor[0].inventory[INV_DUST]);
158 		writeArray(56, _enemy[EN_CAVEFISH].isEmpty);
159 		writeArray(337, _enemy[EN_TORQUE].occurences);
160 		writeArray(329, _enemy[EN_ROTT1].occurences);
161 		writeArray(330, _enemy[EN_ROTT2].occurences);
162 		writeArray(331, _enemy[EN_ROTT3].occurences);
163 		writeArray(332, _enemy[EN_VULTF1].occurences);
164 		writeArray(333, _enemy[EN_VULTM1].occurences);
165 		writeArray(334, _enemy[EN_VULTF2].occurences);
166 		writeArray(335, _enemy[EN_VULTM2].occurences);
167 		writeArray(336, _enemy[EN_CAVEFISH].occurences);
168 		writeArray(339, _enemy[EN_VULTF2].isEmpty);
169 		writeArray(340, _enemy[EN_VULTM2].isEmpty);
170 	}
171 
172 	_vm->_sound->stopAllSounds(); // IMUSE_StopAllSounds();
173 }
174 
initScene(int sceneId)175 int Insane::initScene(int sceneId) {
176 	debugC(DEBUG_INSANE, "initScene(%d)", sceneId);
177 
178 	if (_needSceneSwitch)
179 		return 1;
180 
181 	stopSceneSounds(_currSceneId); // do it for previous scene
182 	loadSceneData(sceneId, 0, 1);
183 	if (loadSceneData(sceneId, 0, 2)) {
184 		setSceneCostumes(sceneId);
185 		_sceneData2Loaded = 0;
186 		_sceneData1Loaded = 0;
187 	} else
188 		_sceneData2Loaded = 1;
189 
190 	_currSceneId = sceneId;
191 
192 	return 1;
193 }
194 
stopSceneSounds(int sceneId)195 void Insane::stopSceneSounds(int sceneId) {
196 	int flag = 0;
197 
198 	debugC(DEBUG_INSANE, "stopSceneSounds(%d)", sceneId);
199 
200 	switch (sceneId) {
201 	case 1:
202 		smlayer_stopSound(88);
203 		smlayer_stopSound(86);
204 		smlayer_stopSound(87);
205 		flag = 1;
206 		break;
207 	case 18:
208 	case 19:
209 		smlayer_stopSound(88);
210 		flag = 1;
211 		break;
212 	case 17:
213 		smlayer_stopSound(88);
214 		smlayer_stopSound(94);
215 		flag = 1;
216 		break;
217 	case 2:
218 	case 7:
219 	case 8:
220 		flag = 1;
221 		break;
222 	case 3:
223 	case 21:
224 		flag = 1;
225 		// fall through
226 	case 13:
227 		if (_actor[0].runningSound != 0)
228 			smlayer_stopSound(_actor[0].runningSound);
229 		_actor[0].runningSound = 0;
230 
231 		if (_actor[1].runningSound != 0)
232 			smlayer_stopSound(_actor[1].runningSound);
233 		_actor[1].runningSound = 0;
234 
235 		if (_currScenePropIdx != 0)
236 			shutCurrentScene();
237 
238 		_currScenePropSubIdx = 0;
239 		_currTrsMsg = 0;
240 		_actor[0].defunct = 0;
241 		_actor[0].scenePropSubIdx = 0;
242 		_actor[0].field_54 = 0;
243 		_actor[1].defunct = 0;
244 		_actor[1].scenePropSubIdx = 0;
245 		_actor[1].field_54 = 0;
246 		if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS)) {
247 			smlayer_stopSound(59);
248 			smlayer_stopSound(63);
249 		} else {
250 			smlayer_stopSound(89);
251 			smlayer_stopSound(90);
252 			smlayer_stopSound(91);
253 			smlayer_stopSound(92);
254 			smlayer_stopSound(93);
255 			smlayer_stopSound(95);
256 			smlayer_stopSound(87);
257 		}
258 		break;
259 	case 4:
260 	case 5:
261 	case 6:
262 		smlayer_stopSound(88);
263 		smlayer_stopSound(86);
264 		flag = 1;
265 		break;
266 	case 24:
267 		smlayer_stopSound(90);
268 		break;
269 	case 9:
270 	case 10:
271 	case 11:
272 	case 12:
273 	case 14:
274 	case 15:
275 	case 16:
276 	case 20:
277 	case 22:
278 	case 23:
279 	default:
280 		break;
281 	}
282 	if (!flag)
283 		return;
284 
285 	smlayer_setActorCostume(0, 2, 0);
286 	smlayer_setActorCostume(0, 0, 0);
287 	smlayer_setActorCostume(0, 1, 0);
288 	smlayer_setActorCostume(1, 2, 0);
289 	smlayer_setActorCostume(1, 0, 0);
290 	smlayer_setActorCostume(1, 1, 0);
291 
292 	return;
293 }
294 
shutCurrentScene()295 void Insane::shutCurrentScene() {
296 	debugC(DEBUG_INSANE, "shutCurrentScene()");
297 
298 	_currScenePropIdx = 0;
299 	_currTrsMsg = 0;
300 	_currScenePropSubIdx = 0;
301 	_actor[1].scenePropSubIdx = 0;
302 	_actor[1].defunct = 0;
303 
304 	if (_actor[1].runningSound != 0) {
305 		smlayer_stopSound(_actor[1].runningSound);
306 		_actor[1].runningSound = 0;
307 	}
308 
309 	_actor[0].scenePropSubIdx = 0;
310 	_actor[0].defunct = 0;
311 
312 	if (_actor[0].runningSound != 0) {
313 		smlayer_stopSound(_actor[0].runningSound);
314 		_actor[0].runningSound = 0;
315 	}
316 
317 	_battleScene = true;
318 }
319 
320 
321 // insane_loadSceneData1 & insane_loadSceneData2
loadSceneData(int scene,int flag,int phase)322 int Insane::loadSceneData(int scene, int flag, int phase) {
323 	if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS))
324 		return 1;
325 
326 	int retvalue = 1;
327 
328 	debugC(DEBUG_INSANE, "Insane::loadSceneData(%d, %d, %d)", scene, flag, phase);
329 
330 	switch (scene) {
331 	case 1:
332 		smlayer_loadSound(88, flag, phase);
333 		smlayer_loadSound(86, flag, phase);
334 		smlayer_loadSound(87, flag, phase);
335 		smlayer_loadCostume(10, phase);
336 		break;
337 	case 4:
338 	case 5:
339 	case 6:
340 		smlayer_loadSound(88, flag, phase);
341 		smlayer_loadCostume(11, phase);
342 		break;
343 	case 3:
344 	case 13:
345 		switch (_currEnemy) {
346 		case EN_TORQUE:
347 			smlayer_loadSound(59, flag, phase);
348 			smlayer_loadSound(93, flag, phase);
349 			smlayer_loadCostume(57, phase);
350 			smlayer_loadCostume(37, phase);
351 			break;
352 		case EN_ROTT1:
353 			smlayer_loadSound(201, flag, phase);
354 			smlayer_loadSound(194, flag, phase);
355 			smlayer_loadSound(195, flag, phase);
356 			smlayer_loadSound(199, flag, phase);
357 			smlayer_loadSound(205, flag, phase);
358 			smlayer_loadSound(212, flag, phase);
359 			smlayer_loadSound(198, flag, phase);
360 			smlayer_loadSound(203, flag, phase);
361 			smlayer_loadSound(213, flag, phase);
362 			smlayer_loadSound(215, flag, phase);
363 			smlayer_loadSound(216, flag, phase);
364 			smlayer_loadSound(217, flag, phase);
365 			smlayer_loadSound(218, flag, phase);
366 			smlayer_loadSound(90, flag, phase);
367 			smlayer_loadCostume(26, phase);
368 			smlayer_loadCostume(16, phase);
369 			smlayer_loadCostume(17, phase);
370 			smlayer_loadCostume(27, phase);
371 			break;
372 		case EN_ROTT2:
373 			smlayer_loadSound(242, flag, phase);
374 			smlayer_loadSound(244, flag, phase);
375 			smlayer_loadSound(236, flag, phase);
376 			smlayer_loadSound(238, flag, phase);
377 			smlayer_loadSound(239, flag, phase);
378 			smlayer_loadSound(240, flag, phase);
379 			smlayer_loadSound(258, flag, phase);
380 			smlayer_loadSound(259, flag, phase);
381 			smlayer_loadSound(260, flag, phase);
382 			smlayer_loadSound(243, flag, phase);
383 			smlayer_loadSound(244, flag, phase);
384 			smlayer_loadSound(245, flag, phase);
385 			smlayer_loadSound(246, flag, phase);
386 			smlayer_loadSound(233, flag, phase);
387 			smlayer_loadSound(234, flag, phase);
388 			smlayer_loadSound(241, flag, phase);
389 			smlayer_loadSound(242, flag, phase);
390 			smlayer_loadSound(90, flag, phase);
391 			smlayer_loadCostume(28, phase);
392 			smlayer_loadCostume(16, phase);
393 			smlayer_loadCostume(17, phase);
394 			smlayer_loadCostume(42, phase);
395 			break;
396 		case EN_ROTT3:
397 			smlayer_loadSound(223, flag, phase);
398 			smlayer_loadSound(224, flag, phase);
399 			smlayer_loadSound(225, flag, phase);
400 			smlayer_loadSound(226, flag, phase);
401 			smlayer_loadSound(228, flag, phase);
402 			smlayer_loadSound(229, flag, phase);
403 			smlayer_loadSound(230, flag, phase);
404 			smlayer_loadSound(232, flag, phase);
405 			smlayer_loadSound(220, flag, phase);
406 			smlayer_loadSound(221, flag, phase);
407 			smlayer_loadSound(222, flag, phase);
408 			smlayer_loadSound(90, flag, phase);
409 			smlayer_loadCostume(15, phase);
410 			smlayer_loadCostume(16, phase);
411 			smlayer_loadCostume(17, phase);
412 			smlayer_loadCostume(43, phase);
413 			smlayer_loadCostume(47, phase);
414 			break;
415 		case EN_VULTF1:
416 			smlayer_loadSound(282, flag, phase);
417 			smlayer_loadSound(283, flag, phase);
418 			smlayer_loadSound(284, flag, phase);
419 			smlayer_loadSound(285, flag, phase);
420 			smlayer_loadSound(286, flag, phase);
421 			smlayer_loadSound(287, flag, phase);
422 			smlayer_loadSound(279, flag, phase);
423 			smlayer_loadSound(280, flag, phase);
424 			smlayer_loadSound(281, flag, phase);
425 			smlayer_loadSound(277, flag, phase);
426 			smlayer_loadSound(288, flag, phase);
427 			smlayer_loadSound(278, flag, phase);
428 			smlayer_loadSound(91, flag, phase);
429 			smlayer_loadCostume(29, phase);
430 			smlayer_loadCostume(33, phase);
431 			smlayer_loadCostume(32, phase);
432 			smlayer_loadCostume(37, phase);
433 			break;
434 		case EN_VULTM1:
435 			smlayer_loadSound(160, flag, phase);
436 			smlayer_loadSound(161, flag, phase);
437 			smlayer_loadSound(174, flag, phase);
438 			smlayer_loadSound(167, flag, phase);
439 			smlayer_loadSound(163, flag, phase);
440 			smlayer_loadSound(164, flag, phase);
441 			smlayer_loadSound(170, flag, phase);
442 			smlayer_loadSound(166, flag, phase);
443 			smlayer_loadSound(175, flag, phase);
444 			smlayer_loadSound(162, flag, phase);
445 			smlayer_loadSound(91, flag, phase);
446 			smlayer_loadCostume(30, phase);
447 			smlayer_loadCostume(33, phase);
448 			smlayer_loadCostume(32, phase);
449 			smlayer_loadCostume(36, phase);
450 			break;
451 		case EN_VULTF2:
452 			smlayer_loadSound(263, flag, phase);
453 			smlayer_loadSound(264, flag, phase);
454 			smlayer_loadSound(265, flag, phase);
455 			smlayer_loadSound(266, flag, phase);
456 			smlayer_loadSound(267, flag, phase);
457 			smlayer_loadSound(268, flag, phase);
458 			smlayer_loadSound(270, flag, phase);
459 			smlayer_loadSound(271, flag, phase);
460 			smlayer_loadSound(275, flag, phase);
461 			smlayer_loadSound(276, flag, phase);
462 			smlayer_loadSound(261, flag, phase);
463 			smlayer_loadSound(262, flag, phase);
464 			smlayer_loadSound(263, flag, phase);
465 			smlayer_loadSound(274, flag, phase);
466 			smlayer_loadSound(91, flag, phase);
467 			smlayer_loadCostume(31, phase);
468 			smlayer_loadCostume(33, phase);
469 			smlayer_loadCostume(32, phase);
470 			smlayer_loadCostume(35, phase);
471 			smlayer_loadCostume(46, phase);
472 			break;
473 		case EN_VULTM2:
474 			smlayer_loadSound(179, flag, phase);
475 			smlayer_loadSound(183, flag, phase);
476 			smlayer_loadSound(184, flag, phase);
477 			smlayer_loadSound(186, flag, phase);
478 			smlayer_loadSound(191, flag, phase);
479 			smlayer_loadSound(192, flag, phase);
480 			smlayer_loadSound(180, flag, phase);
481 			smlayer_loadSound(101, flag, phase);
482 			smlayer_loadSound(289, flag, phase);
483 			smlayer_loadSound(177, flag, phase);
484 			smlayer_loadSound(178, flag, phase);
485 			smlayer_loadSound(290, flag, phase);
486 			smlayer_loadSound(102, flag, phase);
487 			smlayer_loadSound(91, flag, phase);
488 			smlayer_loadCostume(34, phase);
489 			smlayer_loadCostume(33, phase);
490 			smlayer_loadCostume(32, phase);
491 			smlayer_loadCostume(44, phase);
492 			smlayer_loadCostume(45, phase);
493 			break;
494 		case EN_CAVEFISH:
495 			smlayer_loadSound(291, flag, phase);
496 			smlayer_loadSound(100, flag, phase);
497 			smlayer_loadSound(92, flag, phase);
498 			smlayer_loadCostume(39, phase);
499 			smlayer_loadCostume(40, phase);
500 			smlayer_loadCostume(41, phase);
501 			break;
502 		default:
503 			retvalue = 0;
504 			break;
505 		}
506 		smlayer_loadSound(64, flag, phase);
507 		smlayer_loadSound(65, flag, phase);
508 		smlayer_loadSound(66, flag, phase);
509 		smlayer_loadSound(67, flag, phase);
510 		smlayer_loadSound(68, flag, phase);
511 		smlayer_loadSound(69, flag, phase);
512 		smlayer_loadSound(70, flag, phase);
513 		smlayer_loadSound(71, flag, phase);
514 		smlayer_loadSound(72, flag, phase);
515 		smlayer_loadSound(73, flag, phase);
516 		smlayer_loadSound(74, flag, phase);
517 		smlayer_loadSound(75, flag, phase);
518 		smlayer_loadSound(76, flag, phase);
519 		smlayer_loadSound(77, flag, phase);
520 		smlayer_loadSound(78, flag, phase);
521 		smlayer_loadSound(79, flag, phase);
522 		smlayer_loadSound(80, flag, phase);
523 		smlayer_loadSound(81, flag, phase);
524 		smlayer_loadSound(82, flag, phase);
525 		smlayer_loadSound(83, flag, phase);
526 		smlayer_loadSound(84, flag, phase);
527 		smlayer_loadSound(85, flag, phase);
528 		smlayer_loadSound(86, flag, phase);
529 		smlayer_loadSound(87, flag, phase);
530 		smlayer_loadSound(62, flag, phase);
531 		smlayer_loadSound(63, flag, phase);
532 		smlayer_loadSound(60, flag, phase);
533 		smlayer_loadSound(61, flag, phase);
534 		smlayer_loadSound(315, flag, phase);
535 		smlayer_loadSound(316, flag, phase);
536 		smlayer_loadSound(317, flag, phase);
537 		smlayer_loadSound(98, flag, phase);
538 		smlayer_loadSound(318, flag, phase);
539 		smlayer_loadSound(96, flag, phase);
540 		smlayer_loadSound(97, flag, phase);
541 		smlayer_loadSound(95, flag, phase);
542 		smlayer_loadSound(89, flag, phase);
543 		smlayer_loadCostume(12, phase);
544 		smlayer_loadCostume(13, phase);
545 		smlayer_loadCostume(14, phase);
546 		smlayer_loadCostume(18, phase);
547 		smlayer_loadCostume(22, phase);
548 		smlayer_loadCostume(19, phase);
549 		smlayer_loadCostume(38, phase);
550 		smlayer_loadCostume(20, phase);
551 		smlayer_loadCostume(21, phase);
552 		smlayer_loadCostume(23, phase);
553 		smlayer_loadCostume(24, phase);
554 		smlayer_loadCostume(25, phase);
555 		break;
556 	case 21:
557 	case 24:
558 	case 25:
559 		smlayer_loadSound(223, flag, phase);
560 		smlayer_loadSound(224, flag, phase);
561 		smlayer_loadSound(225, flag, phase);
562 		smlayer_loadSound(226, flag, phase);
563 		smlayer_loadSound(228, flag, phase);
564 		smlayer_loadSound(229, flag, phase);
565 		smlayer_loadSound(230, flag, phase);
566 		smlayer_loadSound(232, flag, phase);
567 		smlayer_loadSound(90, flag, phase);
568 		smlayer_loadCostume(15, phase);
569 		smlayer_loadCostume(16, phase);
570 		smlayer_loadCostume(17, phase);
571 		smlayer_loadCostume(43, phase);
572 		smlayer_loadSound(62, flag, phase);
573 		smlayer_loadSound(63, flag, phase);
574 		smlayer_loadSound(60, flag, phase);
575 		smlayer_loadSound(61, flag, phase);
576 		smlayer_loadSound(315, flag, phase);
577 		smlayer_loadSound(316, flag, phase);
578 		smlayer_loadSound(317, flag, phase);
579 		smlayer_loadSound(98, flag, phase);
580 		smlayer_loadSound(318, flag, phase);
581 		smlayer_loadSound(96, flag, phase);
582 		smlayer_loadSound(97, flag, phase);
583 		smlayer_loadSound(95, flag, phase);
584 		smlayer_loadSound(89, flag, phase);
585 		smlayer_loadCostume(12, phase);
586 		smlayer_loadCostume(13, phase);
587 		smlayer_loadCostume(14, phase);
588 		smlayer_loadCostume(18, phase);
589 		smlayer_loadCostume(22, phase);
590 		break;
591 	case 17:
592 		smlayer_loadSound(88, flag, phase);
593 		smlayer_loadSound(94, flag, phase);
594 		break;
595 	case 2:
596 	case 7:
597 	case 8:
598 	case 9:
599 	case 10:
600 	case 11:
601 	case 12:
602 	case 14:
603 	case 15:
604 	case 16:
605 	case 18:
606 	case 19:
607 	case 20:
608 	case 22:
609 	case 23:
610 		break;
611 	default:
612 		retvalue = 0;
613 		break;
614 	}
615 	if (phase == 1) {
616 		_sceneData1Loaded = 1;
617 	}
618 	return retvalue;
619 }
620 
setSceneCostumes(int sceneId)621 void Insane::setSceneCostumes(int sceneId) {
622 	debugC(DEBUG_INSANE, "Insane::setSceneCostumes(%d)", sceneId);
623 
624 	switch (sceneId) {
625 	case 1:
626 		if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS))
627 			smlayer_setActorCostume(0, 2, readArray(9));
628 		else
629 			smlayer_setActorCostume(0, 2, readArray(10));
630 		smlayer_putActor(0, 2, _actor[0].x, _actor[0].y1 + 190, _smlayer_room2);
631 		smlayer_setFluPalette(_smush_roadrashRip, 0);
632 		setupValues();
633 		break;
634 	case 17:
635 		smlayer_setFluPalette(_smush_goglpaltRip, 0);
636 		setupValues();
637 		break;
638 	case 2:
639 		if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS))
640 			smlayer_setActorCostume(0, 2, readArray(9));
641 		else
642 			smlayer_setActorCostume(0, 2, readArray(10));
643 		setupValues();
644 		break;
645 	case 13:
646 		setEnemyCostumes();
647 		smlayer_setFluPalette(_smush_roadrashRip, 0);
648 		break;
649 	case 21:
650 		_currEnemy = EN_ROTT3; //PATCH
651 		setEnemyCostumes();
652 		_actor[1].y = 200;
653 		smlayer_setFluPalette(_smush_roadrashRip, 0);
654 		break;
655 	case 4:
656 	case 5:
657 	case 6:
658 		if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS))
659 			smlayer_setActorCostume(0, 2, readArray(10));
660 		else
661 			smlayer_setActorCostume(0, 2, readArray(11));
662 		smlayer_putActor(0, 2, _actor[0].x, _actor[0].y1+190, _smlayer_room2);
663 		setupValues();
664 		break;
665 	case 7:
666 	case 8:
667 		writeArray(4, 0);
668 		break;
669 	default:
670 		break;
671 	}
672 }
673 
setEnemyCostumes()674 void Insane::setEnemyCostumes() {
675 	int i;
676 
677 	debugC(DEBUG_INSANE, "setEnemyCostumes(%d)", _currEnemy);
678 
679 	if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS)) {
680 		smlayer_setActorCostume(0, 2, readArray(11));
681 		smlayer_setActorCostume(0, 0, readArray(13));
682 		smlayer_setActorCostume(0, 1, readArray(12));
683 	} else {
684 		smlayer_setActorCostume(0, 2, readArray(12));
685 		smlayer_setActorCostume(0, 0, readArray(14));
686 		smlayer_setActorCostume(0, 1, readArray(13));
687 	}
688 	smlayer_setActorLayer(0, 1, 1);
689 	smlayer_setActorLayer(0, 2, 5);
690 	smlayer_setActorLayer(0, 0, 10);
691 	smlayer_putActor(0, 2, _actor[0].x+11, _actor[0].y1+102, _smlayer_room2);
692 	smlayer_putActor(0, 1, _actor[0].x, _actor[0].y1+200, _smlayer_room2);
693 	smlayer_putActor(0, 0, _actor[0].x, _actor[0].y1+200, _smlayer_room2);
694 
695 	if (_currEnemy == EN_CAVEFISH) {
696 		smlayer_setActorCostume(1, 2, readArray(_enemy[_currEnemy].costume4));
697 		_actor[1].act[2].room = 1;
698 		_actor[1].act[1].room = 0;
699 		_actor[1].act[0].room = 0;
700 		_actor[1].act[2].animTilt = 1;
701 		_actor[1].field_8 = 98;
702 		_actor[1].act[2].state = 98;
703 		_actor[1].act[0].state = 98;
704 		_actor[1].act[1].state = 98;
705 
706 		smlayer_putActor(1, 2, _actor[1].x + _actor[1].act[2].tilt - 17,
707 						 _actor[1].y + _actor[1].y1 - 98, _smlayer_room2);
708 	} else if (_currEnemy == EN_TORQUE) {
709 		smlayer_setActorCostume(1, 2, readArray(_enemy[_currEnemy].costume4));
710 		_actor[1].act[2].room = 1;
711 		_actor[1].act[1].room = 0;
712 		_actor[1].act[0].room = 0;
713 		_actor[1].field_8 = 1;
714 		_actor[1].act[2].state = 1;
715 		_actor[1].act[0].state = 1;
716 		_actor[1].act[1].state = 1;
717 		smlayer_putActor(1, 2, _actor[1].x + _actor[1].act[2].tilt - 17,
718 						 _actor[1].y + _actor[1].y1 - 98, _smlayer_room2);
719 	} else {
720 		_actor[1].act[2].room = 1;
721 		_actor[1].act[1].room = 1;
722 		_actor[1].act[0].room = 1;
723 
724 		if (_enemy[_currEnemy].costume4)
725 			smlayer_setActorCostume(1, 2, readArray(_enemy[_currEnemy].costume4));
726 
727 		if (_enemy[_currEnemy].costume5)
728 			smlayer_setActorCostume(1, 0, readArray(_enemy[_currEnemy].costume5));
729 
730 		if (_enemy[_currEnemy].costume6)
731 			smlayer_setActorCostume(1, 1, readArray(_enemy[_currEnemy].costume6));
732 
733 		_actor[1].field_8 = 1;
734 		_actor[1].act[2].state = 1;
735 		_actor[1].act[0].state = 1;
736 		_actor[1].act[1].state = 1;
737 
738 		if (_actor[1].act[2].room != 0)
739 			smlayer_putActor(1, 2, _actor[1].x + _actor[1].act[2].tilt - 17,
740 							 _actor[1].y + _actor[1].y1 - 98,
741 							 _smlayer_room2);
742 	}
743 
744 	if (_actor[1].act[1].room != 0)
745 		smlayer_putActor(1, 1, _actor[1].x, _actor[1].y + _actor[1].y1,
746 						 _smlayer_room2);
747 
748 	if (_actor[1].act[0].room != 0)
749 		smlayer_putActor(1, 0, _actor[1].x, _actor[1].y + _actor[1].y1,
750 						 _smlayer_room2);
751 
752 	smlayer_setActorLayer(1, 1, 1);
753 	smlayer_setActorLayer(1, 2, 5);
754 	smlayer_setActorLayer(1, 0, 10);
755 
756 	_actor[1].damage = 0;
757 	_actor[1].x = 250;
758 	_actor[1].y = 300;
759 	_actor[1].cursorX = 0;
760 	_actor[1].tilt = 0;
761 	_actor[1].weapon = -1;
762 	_actor[1].weaponClass = 2;
763 	_enemy[_currEnemy].occurences++;
764 	_actor[1].maxdamage = _enemy[_currEnemy].maxdamage;
765 	_actor[1].enemyHandler = _enemy[_currEnemy].handler;
766 	_actor[1].animWeaponClass = 0;
767 	for (i = 0; i < 8; i++)
768 		_actor[1].inventory[i] = 0;
769 	_actor[0].damage = 0;
770 	_actor[0].x = 100;
771 	_actor[0].y = 200;
772 	_actor[0].weapon = INV_HAND;
773 	_actor[0].weaponClass = 2;
774 	_actor[0].animWeaponClass = 0;
775 	_actor[0].newFacingFlag = 2;
776 	_actor[0].curFacingFlag = 0;
777 	_actor[0].tilt = 0;
778 	_actor[0].field_8 = 1;
779 	_actor[0].act[2].state = 1;
780 	_actor[0].act[2].animTilt = 1;
781 	_actor[0].act[0].state = 0;
782 	_actor[0].act[1].state = 1;
783 	_actor[0].act[2].room = 1;
784 	_actor[0].act[1].room = 1;
785 	_actor[0].act[0].room = 1;
786 	_actor[0].cursorX = 0;
787 	_actor[0].defunct = 0;
788 	_actor[0].scenePropSubIdx = 0;
789 	_actor[0].field_54 = 0;
790 	_actor[0].runningSound = 0;
791 	_actor[0].lost = false;
792 	_actor[0].kicking = false;
793 	_actor[0].field_44 = false;
794 	_actor[1].inventory[_enemy[_currEnemy].weapon] = 1;
795 	_actor[0].field_48 = false;
796 	_actor[1].defunct = 0;
797 	_actor[1].scenePropSubIdx = 0;
798 	_actor[1].field_54 = 0;
799 	_actor[1].runningSound = 0;
800 	_actor[1].lost = false;
801 	_actor[1].kicking = false;
802 	_actor[1].field_44 = false;
803 	_actor[1].field_48 = false;
804 	if (_enemy[_currEnemy].initializer != -1)
805 		enemyInitializer(_enemy[_currEnemy].initializer, _actor[1].damage,
806 							 _actor[0].damage, _actor[1].probability);
807 
808 	smush_warpMouse(160, 100, -1);
809 }
810 
procPreRendering()811 void Insane::procPreRendering() {
812 	_smush_isSanFileSetup = 0; // FIXME: This shouldn't be here
813 
814 	switchSceneIfNeeded();
815 
816 	if (_sceneData1Loaded) {
817 		_val115_ = true;
818 		if (!_keyboardDisable) {
819 			smush_changeState(1);
820 			_keyboardDisable = 1;
821 		}
822 	} else {
823 		_val115_ = false;
824 		if (_keyboardDisable) {
825 			smush_changeState(0);
826 			_keyboardDisable = 0;
827 		}
828 	}
829 }
830 
procPostRendering(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)831 void Insane::procPostRendering(byte *renderBitmap, int32 codecparam, int32 setupsan12,
832 							   int32 setupsan13, int32 curFrame, int32 maxFrame) {
833 	int32 tmpSnd;
834 	bool needMore = false;
835 
836 	if (!_keyboardDisable) {
837 		switch (_currSceneId) {
838 		case 12:
839 			postCase11(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
840 			break;
841 		case 1:
842 			postCase0(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
843 			if (!smlayer_isSoundRunning(88))
844 				smlayer_startSfx(88);
845 			smlayer_soundSetPan(88, ((_actor[0].x+160)>>2)+64);
846 			if (_tiresRustle) {
847 				if (!smlayer_isSoundRunning(87))
848 					smlayer_startSfx(87);
849 			} else {
850 				smlayer_stopSound(87);
851 			}
852 			break;
853 		case 18:
854 		case 19:
855 			postCase17(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
856 			smlayer_stopSound(95);
857 			smlayer_stopSound(87);
858 			smlayer_stopSound(88);
859 			if (!smlayer_isSoundRunning(88))
860 				smlayer_startSfx(88);
861 			break;
862 		case 17:
863 			postCase16(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
864 			if (!smlayer_isSoundRunning(88))
865 				smlayer_startSfx(88);
866 			break;
867 		case 2:
868 			postCase1(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
869 			break;
870 		case 3:
871 			postCase2(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
872 			needMore = true;
873 			if (!smlayer_isSoundRunning(89)) {
874 				smlayer_startSfx(89);
875 				smlayer_soundSetPriority(89, 100);
876 			}
877 			tmpSnd = _enemy[_currEnemy].sound;
878 			if (!smlayer_isSoundRunning(tmpSnd)) {
879 				smlayer_startSfx(tmpSnd);
880 				smlayer_soundSetPriority(tmpSnd, 100);
881 			}
882 			smlayer_soundSetPan(89, ((_actor[0].x+160)>>2)+64);
883 			smlayer_soundSetPan(tmpSnd, ((_actor[1].x+160)>>2)+64);
884 			if (!_tiresRustle) {
885 				smlayer_stopSound(87);
886 			} else {
887 				if (!smlayer_isSoundRunning(87))
888 					smlayer_startSfx(87);
889 			}
890 			break;
891 		case 21:
892 			postCase20(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
893 			needMore = true;
894 			if (!smlayer_isSoundRunning(89)) {
895 				smlayer_startSfx(89);
896 				smlayer_soundSetPriority(89, 100);
897 			}
898 			tmpSnd = _enemy[_currEnemy].sound;
899 			if (!smlayer_isSoundRunning(tmpSnd)) {
900 				smlayer_startSfx(tmpSnd);
901 				smlayer_soundSetPriority(tmpSnd, 100);
902 			}
903 			smlayer_soundSetPan(89, ((_actor[0].x+160)>>2)+64);
904 			smlayer_soundSetPan(tmpSnd, ((_actor[1].x+160)>>2)+64);
905 			break;
906 		case 4:
907 		case 5:
908 			postCase3(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
909 			if (!smlayer_isSoundRunning(88))
910 				smlayer_startSfx(88);
911 			smlayer_soundSetPan(88, ((_actor[0].x+160)>>2)+64);
912 			break;
913 		case 6:
914 			postCase5(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
915 			if (!smlayer_isSoundRunning(88))
916 				smlayer_startSfx(88);
917 			smlayer_soundSetPan(88, ((_actor[0].x+160)>>2)+64);
918 			break;
919 		case 7:
920 		case 8:
921 			postCase6(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
922 			break;
923 		case 9:
924 		case 23:
925 			postCase8(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
926 			break;
927 		case 10:
928 			postCase9(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
929 			break;
930 		case 11:
931 		case 20:
932 		case 22:
933 			postCase10(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
934 			break;
935 		case 14:
936 			postCase23(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
937 			break;
938 		case 13:
939 			postCase12(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
940 			needMore = true;
941 			if (!smlayer_isSoundRunning(89)) {
942 				smlayer_startSfx(89);
943 				smlayer_soundSetPriority(89, 100);
944 			}
945 			tmpSnd = _enemy[_currEnemy].sound;
946 			if (!smlayer_isSoundRunning(tmpSnd)) {
947 				smlayer_startSfx(tmpSnd);
948 				smlayer_soundSetPriority(tmpSnd, 100);
949 			}
950 			smlayer_soundSetPan(89, ((_actor[0].x+160)>>2)+64);
951 			smlayer_soundSetPan(tmpSnd, ((_actor[1].x+160)>>2)+64);
952 			break;
953 		case 24:
954 			if (!smlayer_isSoundRunning(90)) {
955 				smlayer_startSfx(90);
956 				smlayer_soundSetPriority(90, 100);
957 			}
958 			postCase23(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
959 			break;
960 		case 15:
961 		case 16:
962 			postCase14(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
963 			break;
964 		case 25:
965 		case 26:
966 		default:
967 			break;
968 		}
969 
970 		if (_currScenePropIdx)
971 			postCaseAll(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
972 
973 		_actor[0].frame++;
974 		_actor[0].act[3].frame++;
975 		_actor[0].act[2].frame++;
976 		_actor[0].act[1].frame++;
977 		_actor[0].act[0].frame++;
978 		_actor[1].act[3].frame++;
979 		_actor[1].frame++;
980 		_actor[1].act[2].frame++;
981 		_actor[1].act[1].frame++;
982 		_actor[1].act[0].frame++;
983 	}
984 
985 	if (!_val115_) {
986 		smlayer_overrideDrawActorAt(&renderBitmap[0], renderBitmap[2], renderBitmap[3]);
987 		_isBenCut = 0;
988 	}
989 
990 	if (_isBenCut)
991 		smlayer_drawSomething(renderBitmap, codecparam, 89, 56, 1, _smush_bencutNut, 0, 0, 0);
992 
993 	if (!_keyboardDisable)
994 		_vm->processActors();
995 
996 	if (needMore)
997 		postCaseMore(renderBitmap, codecparam, setupsan12, setupsan13, curFrame, maxFrame);
998 
999 	_tiresRustle = false;
1000 }
1001 
postCase11(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1002 void Insane::postCase11(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1003 						int32 setupsan13, int32 curFrame, int32 maxFrame) {
1004 	if (curFrame >= maxFrame && !_needSceneSwitch) {
1005 		if (_firstBattle) {
1006 			smush_setToFinish();
1007 		} else {
1008 			if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS))
1009 				queueSceneSwitch(1, 0, "minedriv.san", 64, 0, 0, 0);
1010 			else
1011 				queueSceneSwitch(1, _smush_minedrivFlu, "minedriv.san", 64, 0,
1012 							 _continueFrame, 1300);
1013 		}
1014 	}
1015 	_roadBranch = false;
1016 	_roadStop = false;
1017 }
1018 
postCase0(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1019 void Insane::postCase0(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1020 					   int32 setupsan13, int32 curFrame, int32 maxFrame) {
1021 	turnBen(true);
1022 
1023 	if (!curFrame || curFrame == 420)
1024 		smlayer_setFluPalette(_smush_roadrashRip, 0);
1025 
1026 	if (curFrame >= maxFrame)
1027 		smush_rewindCurrentSan(1088, -1, -1);
1028 
1029 	_roadBumps = false;
1030 	_roadBranch = false;
1031 	_roadStop = false;
1032 	_benHasGoggles = false;
1033 	_mineCaveIsNear = false;
1034 	_continueFrame1 = curFrame;
1035 }
1036 
postCase17(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1037 void Insane::postCase17(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1038 						int32 setupsan13, int32 curFrame, int32 maxFrame) {
1039 	if (curFrame >= maxFrame && !_needSceneSwitch) {
1040 		if (_currSceneId == 18) {
1041 			queueSceneSwitch(17, _smush_minedrivFlu, "minedriv.san", 64, 0,
1042 							 _continueFrame1, 1300);
1043 			writeArray(9, 1);
1044 		} else {
1045 			queueSceneSwitch(1, _smush_minedrivFlu, "minedriv.san", 64, 0,
1046 							 _continueFrame1, 1300);
1047 			writeArray(9, 0);
1048 		}
1049 	}
1050 	_roadBranch = false;
1051 	_roadStop = false;
1052 }
1053 
postCase16(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1054 void Insane::postCase16(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1055 						int32 setupsan13, int32 curFrame, int32 maxFrame) {
1056 	char buf[12];
1057 	int32 tmp;
1058 
1059 	turnBen(true);
1060 	sprintf(buf, "^f01%02o", curFrame & 0x3f);
1061 	smlayer_showStatusMsg(-1, renderBitmap, codecparam, 180, 168, 1, 2, 0, "%s", buf);
1062 	tmp = 400-curFrame;
1063 
1064 	if (tmp < 0)
1065 		tmp += 1300;
1066 
1067 	sprintf(buf, "^f01%04d", tmp);
1068 	smlayer_showStatusMsg(-1, renderBitmap, codecparam, 202, 168, 1, 2, 0, "%s", buf);
1069 
1070 	sprintf(buf, "^f01%02o", curFrame & 0xff);
1071 	smlayer_showStatusMsg(-1, renderBitmap, codecparam, 240, 168, 1, 2, 0, "%s", buf);
1072 	smlayer_showStatusMsg(-1, renderBitmap, codecparam, 170, 43, 1, 2, 0, "%s", buf);
1073 
1074 	smlayer_drawSomething(renderBitmap, codecparam, 0, 0, 1, _smush_bensgoggNut, 0, 0, 0);
1075 
1076 	if (!_objectDetected)
1077 		smlayer_drawSomething(renderBitmap, codecparam, 24, 170, 1,
1078 							  _smush_iconsNut, 23, 0, 0);
1079 
1080 	if (!curFrame)
1081 		smlayer_setFluPalette(_smush_goglpaltRip, 0);
1082 
1083 	if (curFrame >= maxFrame) {
1084 		smush_rewindCurrentSan(1088, -1, -1);
1085 		smlayer_setFluPalette(_smush_goglpaltRip, 0);
1086 	}
1087 	_roadBumps = false;
1088 	_mineCaveIsNear = false;
1089 	_roadBranch = false;
1090 	_roadStop = false;
1091 	_objectDetected = false;
1092 	_counter1++;
1093 	_continueFrame1 = curFrame;
1094 	if (_counter1 >= 10)
1095 		_counter1 = 0;
1096 }
1097 
postCase1(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1098 void Insane::postCase1(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1099 					   int32 setupsan13, int32 curFrame, int32 maxFrame) {
1100 	struct fluConf *flu;
1101 
1102 	if ((curFrame >= maxFrame) && !_needSceneSwitch) {
1103 		flu = &_fluConf[14 + _iactSceneId2];
1104 		if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS))
1105 			queueSceneSwitch(4, 0, "tovista.san", 64, 0, 0, 0);
1106 		else
1107 			queueSceneSwitch(flu->sceneId, *flu->fluPtr, flu->filenamePtr, 64, 0,
1108 							 flu->startFrame, flu->numFrames);
1109 	}
1110 	_roadBranch = false;
1111 	_roadStop = false;
1112 }
1113 
postCase2(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1114 void Insane::postCase2(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1115 					   int32 setupsan13, int32 curFrame, int32 maxFrame) {
1116 	turnBen(_battleScene != 0);
1117 	turnEnemy(true);
1118 
1119 	if (!curFrame)
1120 		smlayer_setFluPalette(_smush_roadrashRip, 0);
1121 
1122 	if (curFrame >= maxFrame)
1123 		smush_rewindCurrentSan(1088, -1, -1);
1124 
1125 	_roadBumps = false;
1126 	_roadBranch = false;
1127 	_roadStop = false;
1128 	_continueFrame = curFrame;
1129 }
1130 
postCase20(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1131 void Insane::postCase20(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1132 						int32 setupsan13, int32 curFrame, int32 maxFrame) {
1133 	turnBen(true);
1134 	turnEnemy(true);
1135 
1136 	if (curFrame >= maxFrame)
1137 		smush_rewindCurrentSan(1088, -1, -1);
1138 
1139 	_roadBumps = false;
1140 	_roadBranch = false;
1141 	_roadStop = false;
1142 	_continueFrame = curFrame;
1143 }
1144 
postCase3(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1145 void Insane::postCase3(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1146 					   int32 setupsan13, int32 curFrame, int32 maxFrame) {
1147 	turnBen(true);
1148 
1149 	if (_actor[0].x >= 158 && _actor[0].x <= 168) {
1150 		if (!smlayer_isSoundRunning(86))
1151 			smlayer_startSfx(86);
1152 	} else {
1153 		if (smlayer_isSoundRunning(86))
1154 			smlayer_stopSound(86);
1155 	}
1156 
1157 	if (curFrame >= maxFrame) {
1158 		if (_currSceneId == 4) {
1159 			if (!_needSceneSwitch) {
1160 				if (readArray(6)) {
1161 					if (readArray(4))
1162 						queueSceneSwitch(14, 0, "hitdust2.san", 64, 0, 0, 0);
1163 					else
1164 						queueSceneSwitch(14, 0, "hitdust4.san", 64, 0, 0, 0);
1165 				} else {
1166 					if (readArray(4))
1167 						queueSceneSwitch(14, 0, "hitdust1.san", 64, 0, 0, 0);
1168 					else
1169 						queueSceneSwitch(14, 0, "hitdust3.san", 64, 0, 0, 0);
1170 				}
1171 			}
1172 		} else {
1173 			if (readArray(4)) {
1174 				if (!_needSceneSwitch)
1175 					queueSceneSwitch(15, 0, "vistthru.san", 64, 0, 0, 0);
1176 			} else {
1177 				writeArray(1, _posVista);
1178 				smush_setToFinish();
1179 			}
1180 		}
1181 	}
1182 
1183 	_carIsBroken = false;
1184 	_roadStop = false;
1185 	_roadBranch = false;
1186 	_iactSceneId = 0;
1187 }
1188 
postCase5(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1189 void Insane::postCase5(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1190 					   int32 setupsan13, int32 curFrame, int32 maxFrame) {
1191 	turnBen(true);
1192 
1193 	if (_actor[0].x >= 158 && _actor[0].x <= 168) {
1194 		if (!smlayer_isSoundRunning(86))
1195 			smlayer_startSfx(86);
1196 	} else {
1197 		if (smlayer_isSoundRunning(86))
1198 			smlayer_stopSound(86);
1199 	}
1200 
1201 	if (curFrame >= maxFrame) {
1202 		if (readArray(4)) {
1203 			if (!_needSceneSwitch)
1204 				queueSceneSwitch(15, 0, "chasthru.san", 64, 0, 0, 0);
1205 		} else {
1206 			if (readArray(5)) {
1207 				writeArray(1, _val57d);
1208 				smush_setToFinish();
1209 			} else {
1210 				writeArray(4, 1);
1211 				queueSceneSwitch(15, 0, "chasout.san", 64, 0, 0, 0);
1212 			}
1213 		}
1214 	}
1215 
1216 	_carIsBroken = false;
1217 	_roadStop = false;
1218 	_roadBranch = false;
1219 	_iactSceneId = 0;
1220 }
1221 
postCase6(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1222 void Insane::postCase6(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1223 					   int32 setupsan13, int32 curFrame, int32 maxFrame) {
1224 	struct fluConf *flu;
1225 
1226 	if ((curFrame >= maxFrame) && !_needSceneSwitch) {
1227 		if (_currSceneId == 8)
1228 			flu = &_fluConf[7 + _iactSceneId2];
1229 		else
1230 			flu = &_fluConf[0 + _iactSceneId2];
1231 
1232 		if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS))
1233 			queueSceneSwitch(1, 0, "minedriv.san", 64, 0, 0, 0);
1234 		else
1235 			queueSceneSwitch(flu->sceneId, *flu->fluPtr, flu->filenamePtr, 64, 0,
1236 							 flu->startFrame, flu->numFrames);
1237 	}
1238 	_roadBranch = false;
1239 	_roadStop = false;
1240 }
1241 
postCase8(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1242 void Insane::postCase8(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1243 					   int32 setupsan13, int32 curFrame, int32 maxFrame) {
1244 	if (curFrame >= maxFrame && !_needSceneSwitch) {
1245 		_actor[0].damage = 0;
1246 
1247 		if (_firstBattle) {
1248 			queueSceneSwitch(13, _smush_minefiteFlu, "minefite.san", 64, 0,
1249 							 _continueFrame, 1300);
1250 		} else {
1251 			if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS)) {
1252 				queueSceneSwitch(1, 0, "minedriv.san", 64, 0, 0, 0);
1253 			} else {
1254 				if (_currSceneId == 23) {
1255 					queueSceneSwitch(21, 0, "rottfite.san", 64, 0, 0, 0);
1256 				} else {
1257 					queueSceneSwitch(1, _smush_minedrivFlu, "minedriv.san", 64, 0,
1258 							 _continueFrame, 1300);
1259 				}
1260 			}
1261 		}
1262 	}
1263 
1264 	_roadBranch = false;
1265 	_roadStop = false;
1266 }
1267 
postCase9(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1268 void Insane::postCase9(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1269 					   int32 setupsan13, int32 curFrame, int32 maxFrame) {
1270 	if (curFrame >= maxFrame && !_needSceneSwitch) {
1271 		_actor[0].damage = 0;
1272 		queueSceneSwitch(1, _smush_minedrivFlu, "minedriv.san", 64, 0,
1273 						 _continueFrame1, 1300);
1274 	}
1275 	_roadBranch = false;
1276 	_roadStop = false;
1277 }
1278 
postCase10(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1279 void Insane::postCase10(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1280 						int32 setupsan13, int32 curFrame, int32 maxFrame) {
1281 	if (curFrame >= maxFrame && !_needSceneSwitch) {
1282 		_actor[0].damage = 0;
1283 
1284 		switch (_currSceneId) {
1285 		case 20:
1286 			writeArray(8, 1);
1287 			queueSceneSwitch(12, 0, "liftgog.san", 0, 0, 0, 0);
1288 			break;
1289 		case 22:
1290 			writeArray(1, _val54d);
1291 			smush_setToFinish();
1292 			break;
1293 		default:
1294 			if (_actor[0].inventory[_enemy[_currEnemy].weapon]) {
1295 				queueSceneSwitch(1, _smush_minedrivFlu, "minedriv.san", 64, 0,
1296 								 _continueFrame, 1300);
1297 				break;
1298 			}
1299 
1300 			switch (_enemy[_currEnemy].weapon) {
1301 			case INV_CHAIN:
1302 				_actor[0].inventory[INV_CHAIN] = 1;
1303 				queueSceneSwitch(12, 0, "liftchay.san", 0, 0, 0, 0);
1304 				break;
1305 			case INV_CHAINSAW:
1306 				_actor[0].inventory[INV_CHAINSAW] = 1;
1307 				queueSceneSwitch(12, 0, "liftsaw.san", 0, 0, 0, 0);
1308 				break;
1309 			case INV_MACE:
1310 				_actor[0].inventory[INV_MACE] = 1;
1311 				queueSceneSwitch(12, 0, "liftmace.san", 0, 0, 0, 0);
1312 				break;
1313 			case INV_2X4:
1314 				_actor[0].inventory[INV_2X4] = 1;
1315 				queueSceneSwitch(12, 0, "liftbord.san", 0, 0, 0, 0);
1316 				break;
1317 			default:
1318 				queueSceneSwitch(1, _smush_minedrivFlu, "minedriv.san", 64, 0,
1319 								 _continueFrame, 1300);
1320 				break;
1321 			}
1322 		}
1323 	}
1324 
1325 	_roadBranch = false;
1326 	_roadStop = false;
1327 }
1328 
postCase12(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1329 void Insane::postCase12(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1330 						int32 setupsan13, int32 curFrame, int32 maxFrame) {
1331 	if (_actor[1].y <= 200) {
1332 		initScene(3);
1333 		_actor[1].y = 200;
1334 
1335 		switch (_currEnemy) {
1336 		case EN_ROTT2:
1337 			turnBen(true);
1338 
1339 			if (_enemy[EN_ROTT2].occurences <= 1)
1340 				prepareScenePropScene(32, 0, 1);
1341 			else
1342 				prepareScenePropScene(33, 0, 1);
1343 			break;
1344 		case EN_ROTT3:
1345 			turnBen(true);
1346 
1347 			if (_enemy[EN_ROTT3].occurences <= 1)
1348 				prepareScenePropScene(25, 0, 1);
1349 			break;
1350 		case EN_VULTF1:
1351 			turnBen(true);
1352 
1353 			if (_enemy[EN_VULTF1].occurences <= 1)
1354 				prepareScenePropScene(2, 0, 1);
1355 			break;
1356 		case EN_VULTF2:
1357 			turnBen(true);
1358 
1359 			if (_enemy[EN_VULTF2].occurences <= 1)
1360 				prepareScenePropScene(9, 0, 1);
1361 			else
1362 				prepareScenePropScene(16, 0, 1);
1363 			break;
1364 		case EN_VULTM2:
1365 			if (_enemy[EN_VULTM2].occurences <= 1) {
1366 				turnBen(false);
1367 				prepareScenePropScene(18, 0, 1);
1368 				_battleScene = false;
1369 			} else
1370 				turnBen(true);
1371 			break;
1372 		case EN_TORQUE:
1373 			turnBen(false);
1374 			writeArray(1, _posFatherTorque);
1375 			smush_setToFinish();
1376 			break;
1377 		case EN_ROTT1:
1378 		case EN_VULTM1:
1379 		case EN_CAVEFISH:
1380 		default:
1381 			turnBen(true);
1382 			break;
1383 		}
1384 	} else {
1385 		switch (_currEnemy) {
1386 		case EN_VULTM2:
1387 			if (_enemy[EN_VULTM2].occurences <= 1)
1388 				turnBen(false);
1389 			else
1390 				turnBen(true);
1391 			break;
1392 		case EN_TORQUE:
1393 			turnBen(false);
1394 			if (_actor[1].y == 300)
1395 				prepareScenePropScene(57, 1, 0);
1396 			break;
1397 		default:
1398 			turnBen(true);
1399 		}
1400 		_actor[1].y -= (_actor[1].y - 200) / 20 + 1;
1401 	}
1402 
1403 	turnEnemy(false);
1404 
1405 	if (curFrame == 0)
1406 		smlayer_setFluPalette(_smush_roadrashRip, 0);
1407 
1408 	if (curFrame >= maxFrame)
1409 		smush_rewindCurrentSan(1088, -1, -1);
1410 
1411 	_roadBranch = false;
1412 	_roadStop = false;
1413 	_continueFrame = curFrame;
1414 }
1415 
postCase23(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1416 void Insane::postCase23(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1417 						int32 setupsan13, int32 curFrame, int32 maxFrame) {
1418 	if (curFrame >= maxFrame) {
1419 		if (_currSceneId == 24) {
1420 			queueSceneSwitch(21, 0, "rottfite.san", 64, 0, 0, 0);
1421 		} else {
1422 			if (readArray(6) && readArray(4))
1423 				queueSceneSwitch(16, 0, "limocrsh.san", 64, 0, 0, 0);
1424 			else
1425 				queueSceneSwitch(5, 0, "tovista2.san", 64, 0, 0, 290);
1426 		}
1427 	}
1428 	_roadBranch = false;
1429 	_roadStop = false;
1430 }
1431 
postCase14(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1432 void Insane::postCase14(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1433 						int32 setupsan13, int32 curFrame, int32 maxFrame) {
1434 	if (curFrame >= maxFrame) {
1435 		if (_currSceneId == 16) {
1436 			writeArray(4, 0);
1437 			writeArray(5, 1);
1438 			writeArray(1, _posBrokenCar);
1439 			writeArray(3, _posBrokenTruck);
1440 			smush_setToFinish();
1441 		} else {
1442 			switch (_tempSceneId) {
1443 			case 5:
1444 				queueSceneSwitch(6, 0, "toranch.san", 64, 0, 0, 530);
1445 				break;
1446 			case 6:
1447 				queueSceneSwitch(4, 0, "tovista1.san", 64, 0, 0, 230);
1448 				break;
1449 			default:
1450 				break;
1451 			}
1452 		}
1453 	}
1454 
1455 	_roadBranch = false;
1456 	_roadStop = false;
1457 }
1458 
postCaseAll(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1459 void Insane::postCaseAll(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1460 						 int32 setupsan13, int32 curFrame, int32 maxFrame) {
1461 	struct sceneProp *tsceneProp;
1462 
1463 	tsceneProp = &_sceneProp[_currScenePropIdx + _currScenePropSubIdx];
1464 	if (tsceneProp->actor != -1) {
1465 		if (_actor[tsceneProp->actor].field_54) {
1466 			tsceneProp->counter++;
1467 			if (!_actor[tsceneProp->actor].runningSound || ConfMan.getBool("subtitles")) {
1468 				if (_actor[tsceneProp->actor].act[3].state == 72 &&
1469 					_currTrsMsg) {
1470 					_player->setPaletteValue(0, tsceneProp->r, tsceneProp->g, tsceneProp->b);
1471 					_player->setPaletteValue(1, tsceneProp->r, tsceneProp->g, tsceneProp->b);
1472 					_player->setPaletteValue(0, 0, 0, 0);
1473 					smlayer_showStatusMsg(-1, renderBitmap, codecparam, 160, 20, 1, 2, 5,
1474 										  "^f00%s", _currTrsMsg);
1475 				}
1476 			}
1477 		} else {
1478 			_currScenePropSubIdx = tsceneProp->index;
1479 			if (_currScenePropSubIdx && _currScenePropIdx) {
1480 				tsceneProp = &_sceneProp[_currScenePropIdx + _currScenePropSubIdx];
1481 				tsceneProp->counter = 0;
1482 				if (tsceneProp->trsId)
1483 					_currTrsMsg = handleTrsTag(tsceneProp->trsId);
1484 				else
1485 					_currTrsMsg = 0;
1486 
1487 				if (tsceneProp->actor != -1) {
1488 					_actor[tsceneProp->actor].field_54 = 1;
1489 					_actor[tsceneProp->actor].act[3].state = 117;
1490 					_actor[tsceneProp->actor].scenePropSubIdx = _currScenePropSubIdx;
1491 				}
1492 			} else {
1493 				_currScenePropIdx = 0;
1494 				_currTrsMsg = 0;
1495 				_currScenePropSubIdx = 0;
1496 				_actor[0].defunct = 0;
1497 				_actor[1].defunct = 0;
1498 				_battleScene = true;
1499 			}
1500 		}
1501 	}
1502 	_roadBranch = false;
1503 	_roadStop = false;
1504 	_continueFrame = curFrame;
1505 }
1506 
postCaseMore(byte * renderBitmap,int32 codecparam,int32 setupsan12,int32 setupsan13,int32 curFrame,int32 maxFrame)1507 void Insane::postCaseMore(byte *renderBitmap, int32 codecparam, int32 setupsan12,
1508 						  int32 setupsan13, int32 curFrame, int32 maxFrame) {
1509 	if (_actor[0].weapon <= 7) {
1510 		smlayer_drawSomething(renderBitmap, codecparam, 5, 160, 1, _smush_iconsNut,
1511 							  _actor[0].weapon + 11, 0, 0);
1512 	}
1513 }
1514 
1515 }
1516