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