aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions/bbdou/illusions_bbdou.cpp
blob: 0c16ad5959d85bee7e9cfa62c09d3e17af7f18f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#include "illusions/bbdou/illusions_bbdou.h"
#include "illusions/actor.h"
#include "illusions/camera.h"
#include "illusions/cursor.h"
#include "illusions/dictionary.h"
#include "illusions/fileresourcereader.h"
#include "illusions/graphics.h"
#include "illusions/input.h"
#include "illusions/resources/actorresource.h"
#include "illusions/resources/backgroundresource.h"
#include "illusions/resources/fontresource.h"
#include "illusions/resources/scriptresource.h"
#include "illusions/resources/soundresource.h"
#include "illusions/resources/talkresource.h"
#include "illusions/resourcesystem.h"
#include "illusions/screen.h"
#include "illusions/screentext.h"
#include "illusions/scriptstack.h"
#include "illusions/bbdou/scriptopcodes_bbdou.h"
#include "illusions/sound.h"
#include "illusions/specialcode.h"
#include "illusions/bbdou/bbdou_specialcode.h"
#include "illusions/thread.h"
#include "illusions/time.h"
#include "illusions/updatefunctions.h"

#include "illusions/threads/abortablethread.h"
#include "illusions/threads/scriptthread.h"
#include "illusions/threads/talkthread.h"
#include "illusions/threads/timerthread.h"

#include "audio/audiostream.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
#include "common/error.h"
#include "common/fs.h"
#include "common/timer.h"
#include "engines/util.h"
#include "graphics/cursorman.h"
#include "graphics/font.h"
#include "graphics/fontman.h"
#include "graphics/palette.h"
#include "graphics/surface.h"

namespace Illusions {

// ActiveScenes

ActiveScenes::ActiveScenes() {
	clear();
}

void ActiveScenes::clear() {
	_stack.clear();
}

void ActiveScenes::push(uint32 sceneId) {
	ActiveScene activeScene;
	activeScene._sceneId = sceneId;
	activeScene._pauseCtr = 0;
	_stack.push(activeScene);
}

void ActiveScenes::pop() {
	_stack.pop();
}

void ActiveScenes::pauseActiveScene() {
	++_stack.top()._pauseCtr;
}

void ActiveScenes::unpauseActiveScene() {
	--_stack.top()._pauseCtr;
}

uint ActiveScenes::getActiveScenesCount() {
	return _stack.size();
}

void ActiveScenes::getActiveSceneInfo(uint index, uint32 *sceneId, int *pauseCtr) {
	if (sceneId)
		*sceneId = _stack[index - 1]._sceneId;
	if (pauseCtr)
		*pauseCtr = _stack[index - 1]._pauseCtr;
}

uint32 ActiveScenes::getCurrentScene() {
	if (_stack.size() > 0)
		return _stack.top()._sceneId;
	return 0;
}

bool ActiveScenes::isSceneActive(uint32 sceneId) {
	for (uint i = 0; i < _stack.size(); ++i) {
		if (_stack[i]._sceneId == sceneId && _stack[i]._pauseCtr <= 0)
			return true;
	}
	return false;
}

// IllusionsEngine_BBDOU

IllusionsEngine_BBDOU::IllusionsEngine_BBDOU(OSystem *syst, const IllusionsGameDescription *gd)
	: IllusionsEngine(syst, gd) {
}

Common::Error IllusionsEngine_BBDOU::run() {

	// Init search paths
	const Common::FSNode gameDataDir(ConfMan.get("path"));
	SearchMan.addSubDirectoryMatching(gameDataDir, "music");
	SearchMan.addSubDirectoryMatching(gameDataDir, "resource");
	SearchMan.addSubDirectoryMatching(gameDataDir, "resrem");
	SearchMan.addSubDirectoryMatching(gameDataDir, "savegame");
	SearchMan.addSubDirectoryMatching(gameDataDir, "sfx", 0, 2);
	SearchMan.addSubDirectoryMatching(gameDataDir, "video");
	SearchMan.addSubDirectoryMatching(gameDataDir, "voice");

	_dict = new Dictionary();

	_resReader = new ResourceReaderFileReader();

	_resSys = new ResourceSystem(this);
	_resSys->addResourceLoader(0x00060000, new ActorResourceLoader(this));
	_resSys->addResourceLoader(0x00080000, new SoundGroupResourceLoader(this));
	_resSys->addResourceLoader(0x000D0000, new ScriptResourceLoader(this));
	_resSys->addResourceLoader(0x000F0000, new TalkResourceLoader(this));
	_resSys->addResourceLoader(0x00100000, new ActorResourceLoader(this));
	_resSys->addResourceLoader(0x00110000, new BackgroundResourceLoader(this));
	_resSys->addResourceLoader(0x00120000, new FontResourceLoader(this));
	_resSys->addResourceLoader(0x00170000, new SpecialCodeLoader(this));

	_screen = new Screen16Bit(this, 640, 480);
	_screenPalette = new NullScreenPalette();
	_screenText = new ScreenText(this);
	_input = new Input();
	_actorInstances = new ActorInstanceList(this);
	_backgroundInstances = new BackgroundInstanceList(this);
	_camera = new Camera(this);
	_controls = new Controls(this);
	_cursor = new Cursor(this);
	_talkItems = new TalkInstanceList(this);
	_triggerFunctions = new TriggerFunctions();
	_threads = new ThreadList(this);
	_updateFunctions = new UpdateFunctions();
	_soundMan = new SoundMan(this);

	_screen->setColorKey1(0xF81F);

	initInput();

	initUpdateFunctions();

	_fader = 0;

	_scriptOpcodes = new ScriptOpcodes_BBDOU(this);
	_stack = new ScriptStack();

	// TODO Move to own class
	_resGetCtr = 0;
	_unpauseControlActorFlag = false;
	_lastUpdateTime = 0;

	_pauseCtr = 0;
	_field8 = 1;
	_fieldA = 0;
	ConfMan.registerDefault("talkspeed", 240);
	_subtitleDuration = (uint16)ConfMan.getInt("talkspeed");

	_globalSceneId = 0x00010003;

	setDefaultTextCoords();

	_resSys->loadResource(0x000D0001, 0, 0);

	_doScriptThreadInit = false;
	startScriptThread(0x00020004, 0, 0, 0, 0);
	_doScriptThreadInit = true;

	_walkthroughStarted = false;

	while (!shouldQuit()) {
		if (_walkthroughStarted) {
			//enterScene(0x10003, 0);
			startScriptThread(0x00020404, 0, 0, 0, 0);
			_walkthroughStarted = false;
		}
		runUpdateFunctions();
		_system->updateScreen();
		updateEvents();
	}

	delete _stack;
	delete _scriptOpcodes;

	delete _soundMan;
	delete _updateFunctions;
	delete _threads;
	delete _triggerFunctions;
	delete _talkItems;
	delete _cursor;
	delete _controls;
	delete _camera;
	delete _backgroundInstances;
	delete _actorInstances;
	delete _input;
	delete _screenText;
	delete _screen;
	delete _resSys;
	delete _resReader;
	delete _dict;

	debug("Ok");

	return Common::kNoError;
}

bool IllusionsEngine_BBDOU::hasFeature(EngineFeature f) const {
	return
		false;
		/*
		(f == kSupportsRTL) ||
		(f == kSupportsLoadingDuringRuntime) ||
		(f == kSupportsSavingDuringRuntime);
		*/
}

void IllusionsEngine_BBDOU::initInput() {
	// TODO Check if these are correct...
	_input->setInputEvent(kEventLeftClick, 0x01)
		.addMouseButton(MOUSE_LEFT_BUTTON)
		.addKey(Common::KEYCODE_RETURN);
	_input->setInputEvent(kEventRightClick, 0x02)
		.addMouseButton(MOUSE_RIGHT_BUTTON);
	_input->setInputEvent(kEventInventory, 0x04)
		.addMouseButton(MOUSE_RIGHT_BUTTON)
		.addKey(Common::KEYCODE_TAB);
	_input->setInputEvent(kEventAbort, 0x08)
		.addKey(Common::KEYCODE_ESCAPE);
	_input->setInputEvent(kEventSkip, 0x10)
		.addKey(Common::KEYCODE_SPACE);
	_input->setInputEvent(kEventF1, 0x20)
		.addKey(Common::KEYCODE_F1);
	_input->setInputEvent(kEventUp, 0x40)
		.addKey(Common::KEYCODE_UP);
	_input->setInputEvent(kEventDown, 0x80)
		.addMouseButton(MOUSE_RIGHT_BUTTON)
		.addKey(Common::KEYCODE_DOWN);
}

#define UPDATEFUNCTION(priority, sceneId, callback) \
	_updateFunctions->add(priority, sceneId, new Common::Functor1Mem<uint, int, IllusionsEngine_BBDOU> \
		(this, &IllusionsEngine_BBDOU::callback));

void IllusionsEngine_BBDOU::initUpdateFunctions() {
	UPDATEFUNCTION(30, 0, updateScript);
	UPDATEFUNCTION(50, 0, updateActors);
	UPDATEFUNCTION(60, 0, updateSequences);
	UPDATEFUNCTION(70, 0, updateGraphics);
	UPDATEFUNCTION(90, 0, updateSprites);
	UPDATEFUNCTION(120, 0, updateSoundMan);
}

#undef UPDATEFUNCTION

int IllusionsEngine_BBDOU::updateScript(uint flags) {
	_threads->updateThreads();
	return 1;
}

bool IllusionsEngine_BBDOU::causeIsDeclared(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId) {
	uint32 codeOffs;
	return
		_triggerFunctions->find(sceneId, verbId, objectId2, objectId) ||
		findTriggerCause(sceneId, verbId, objectId2, objectId, codeOffs);
}

void IllusionsEngine_BBDOU::causeDeclare(uint32 verbId, uint32 objectId2, uint32 objectId, TriggerFunctionCallback *callback) {
	_triggerFunctions->add(getCurrentScene(), verbId, objectId2, objectId, callback);
}

uint32 IllusionsEngine_BBDOU::causeTrigger(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId, uint32 callingThreadId) {
	uint32 codeOffs;
	uint32 causeThreadId = 0;
	TriggerFunction *triggerFunction = _triggerFunctions->find(sceneId, verbId, objectId2, objectId);
	if (triggerFunction) {
		triggerFunction->run(callingThreadId);
	} else if (findTriggerCause(sceneId, verbId, objectId2, objectId, codeOffs)) {
		causeThreadId = startTempScriptThread(_scriptResource->getCode(codeOffs),
			callingThreadId, verbId, objectId2, objectId);
	}
	return causeThreadId;
}

void IllusionsEngine_BBDOU::setDefaultTextCoords() {
	WidthHeight dimensions;
	dimensions._width = 480;
	dimensions._height = 48;
	Common::Point pt(320, 448);
	setDefaultTextDimensions(dimensions);
	setDefaultTextPosition(pt);
}

void IllusionsEngine_BBDOU::loadSpecialCode(uint32 resId) {
	_specialCode = new BbdouSpecialCode(this);
	_specialCode->init();
}

void IllusionsEngine_BBDOU::unloadSpecialCode(uint32 resId) {
	delete _specialCode;
	_specialCode = 0;
}

void IllusionsEngine_BBDOU::notifyThreadId(uint32 &threadId) {
	if (threadId) {
		uint32 tempThreadId = threadId;
		threadId = 0;
		_threads->notifyId(tempThreadId);
	}
}

bool IllusionsEngine_BBDOU::testMainActorFastWalk(Control *control) {
	return false;
}

bool IllusionsEngine_BBDOU::testMainActorCollision(Control *control) {
	// Not used in BBDOU
	return false;
}

Control *IllusionsEngine_BBDOU::getObjectControl(uint32 objectId) {
	return _dict->getObjectControl(objectId);
}

Common::Point IllusionsEngine_BBDOU::getNamedPointPosition(uint32 namedPointId) {
	Common::Point pt;
	if (_backgroundInstances->findActiveBackgroundNamedPoint(namedPointId, pt) ||
		_actorInstances->findNamedPoint(namedPointId, pt) ||
		_controls->findNamedPoint(namedPointId, pt))
		return pt;
	// TODO
	switch (namedPointId) {
	case 0x70001:
		return Common::Point(0, 0);
	case 0x70002:
		return Common::Point(640, 0);
	case 0x70023:
		return Common::Point(320, 240);
	}
	debug("getNamedPointPosition(%08X) UNKNOWN", namedPointId);
	return Common::Point(0, 0);
}

uint32 IllusionsEngine_BBDOU::getPriorityFromBase(int16 priority) {
	return 32000000 * priority;
}

uint32 IllusionsEngine_BBDOU::getCurrentScene() {
	return _activeScenes.getCurrentScene();
}

uint32 IllusionsEngine_BBDOU::getPrevScene() {
	return _prevSceneId;
}

bool IllusionsEngine_BBDOU::isCursorObject(uint32 actorTypeId, uint32 objectId) {
	return actorTypeId == 0x50001 && objectId == Illusions::CURSOR_OBJECT_ID;
}

void IllusionsEngine_BBDOU::setCursorControlRoutine(Control *control) {
	control->_actor->setControlRoutine(new Common::Functor2Mem<Control*, uint32, void, IllusionsEngine_BBDOU>
		(this, &IllusionsEngine_BBDOU::cursorControlRoutine));
}

void IllusionsEngine_BBDOU::placeCursorControl(Control *control, uint32 sequenceId) {
	_cursor->place(control, sequenceId);
}

void IllusionsEngine_BBDOU::setCursorControl(Control *control) {
	_cursor->setControl(control);
}

void IllusionsEngine_BBDOU::showCursor() {
	_cursor->show();
}

void IllusionsEngine_BBDOU::hideCursor() {
	_cursor->hide();
}

void IllusionsEngine_BBDOU::cursorControlRoutine(Control *control, uint32 deltaTime) {
	control->_actor->_seqCodeValue1 = 100 * deltaTime;
	if (control->_actor->_flags & Illusions::ACTOR_FLAG_IS_VISIBLE) {
		switch (_cursor->_status) {
		case 2:
			// Unused nullsub_1(control);
			break;
		case 3:
			// TODO _vm->_shellMgr->handleMouse(control);
			break;
		}
	}
}

void IllusionsEngine_BBDOU::startScriptThreadSimple(uint32 threadId, uint32 callingThreadId) {
	startScriptThread(threadId, callingThreadId, 0, 0, 0);
}

void IllusionsEngine_BBDOU::startScriptThread(uint32 threadId, uint32 callingThreadId,
	uint32 value8, uint32 valueC, uint32 value10) {
	debug(2, "Starting script thread %08X", threadId);
	byte *scriptCodeIp = _scriptResource->getThreadCode(threadId);
	newScriptThread(threadId, callingThreadId, 0, scriptCodeIp, value8, valueC, value10);
}

void IllusionsEngine_BBDOU::startAnonScriptThread(int32 threadId, uint32 callingThreadId,
	uint32 value8, uint32 valueC, uint32 value10) {
	debug(2, "Starting anonymous script thread %08X", threadId);
	uint32 tempThreadId = newTempThreadId();
	byte *scriptCodeIp = _scriptResource->getThreadCode(threadId);
	scriptCodeIp = _scriptResource->getThreadCode(threadId);
	newScriptThread(tempThreadId, callingThreadId, 0, scriptCodeIp, value8, valueC, value10);
}

uint32 IllusionsEngine_BBDOU::startAbortableTimerThread(uint32 duration, uint32 threadId) {
	return newTimerThread(duration, threadId, true);
}

uint32 IllusionsEngine_BBDOU::startTimerThread(uint32 duration, uint32 threadId) {
	return newTimerThread(duration, threadId, false);
}

uint32 IllusionsEngine_BBDOU::startAbortableThread(byte *scriptCodeIp1, byte *scriptCodeIp2, uint32 callingThreadId) {
	uint32 tempThreadId = newTempThreadId();
	debug(2, "Starting abortable thread %08X", tempThreadId);
	uint32 scriptThreadId = startTempScriptThread(scriptCodeIp1, tempThreadId, 0, 0, 0);
	AbortableThread *abortableThread = new AbortableThread(this, tempThreadId, callingThreadId, 0,
		scriptThreadId, scriptCodeIp2);
	_threads->startThread(abortableThread);
	return tempThreadId;
}

uint32 IllusionsEngine_BBDOU::startTalkThread(int16 duration, uint32 objectId, uint32 talkId, uint32 sequenceId1,
	uint32 sequenceId2, uint32 namedPointId, uint32 callingThreadId) {
	debug(2, "Starting talk thread");
	uint32 tempThreadId = newTempThreadId();
	_threads->endTalkThreadsNoNotify();
	TalkThread *talkThread = new TalkThread(this, tempThreadId, callingThreadId, 0,
		duration, objectId, talkId, sequenceId1, sequenceId2, namedPointId);
	_threads->startThread(talkThread);
	return tempThreadId;
}

void IllusionsEngine_BBDOU::resumeFromSavegame(uint32 callingThreadId) {
	// TODO
}

uint32 IllusionsEngine_BBDOU::startTempScriptThread(byte *scriptCodeIp, uint32 callingThreadId,
	uint32 value8, uint32 valueC, uint32 value10) {
	uint32 tempThreadId = newTempThreadId();
	debug(2, "Starting temp script thread %08X", tempThreadId);
	newScriptThread(tempThreadId, callingThreadId, 0, scriptCodeIp, value8, valueC, value10);
	return tempThreadId;
}

void IllusionsEngine_BBDOU::newScriptThread(uint32 threadId, uint32 callingThreadId, uint notifyFlags,
	byte *scriptCodeIp, uint32 value8, uint32 valueC, uint32 value10) {
	ScriptThread *scriptThread = new ScriptThread(this, threadId, callingThreadId, notifyFlags,
		scriptCodeIp, value8, valueC, value10);
	_threads->startThread(scriptThread);
	if (_pauseCtr > 0)
		scriptThread->pause();
	if (_doScriptThreadInit) {
		int updateResult = kTSRun;
		while (scriptThread->_pauseCtr <= 0 && updateResult != kTSTerminate && updateResult != kTSYield) {
			updateResult = scriptThread->update();
		}
	}
}

uint32 IllusionsEngine_BBDOU::newTimerThread(uint32 duration, uint32 callingThreadId, bool isAbortable) {
	uint32 tempThreadId = newTempThreadId();
	TimerThread *timerThread = new TimerThread(this, tempThreadId, callingThreadId, 0,
		duration, isAbortable);
	_threads->startThread(timerThread);
	return tempThreadId;
}

uint32 IllusionsEngine_BBDOU::newTempThreadId() {
	uint32 threadId = _nextTempThreadId + 2 * _scriptResource->_codeCount;
	if (threadId > 65535) {
		_nextTempThreadId = 0;
		threadId = 2 * _scriptResource->_codeCount;
	}
	++_nextTempThreadId;
	return 0x00020000 | threadId;
}

bool IllusionsEngine_BBDOU::enterScene(uint32 sceneId, uint32 threadId) {
	SceneInfo *sceneInfo = _scriptResource->getSceneInfo(sceneId & 0xFFFF);
	if (!sceneInfo) {
		dumpActiveScenes(_globalSceneId, threadId);
		sceneId = _theSceneId;
	}
	_activeScenes.push(sceneId);
	return sceneInfo != 0;
}

void IllusionsEngine_BBDOU::exitScene(uint32 threadId) {
	uint32 sceneId = _activeScenes.getCurrentScene();
	_updateFunctions->terminateByScene(sceneId);
	_threads->terminateThreadsBySceneId(sceneId, threadId);
	_controls->destroyControlsBySceneId(sceneId);
	_triggerFunctions->removeBySceneId(sceneId);
	_resSys->unloadResourcesBySceneId(sceneId);
	_activeScenes.pop();
}

void IllusionsEngine_BBDOU::enterPause(uint32 threadId) {
	uint32 sceneId = _activeScenes.getCurrentScene();
	_camera->pushCameraMode();
	_threads->suspendThreadsBySceneId(sceneId, threadId);
	_controls->pauseControlsBySceneId(sceneId);
	_actorInstances->pauseBySceneId(sceneId);
	_backgroundInstances->pauseBySceneId(sceneId);
	_activeScenes.pauseActiveScene();
}

void IllusionsEngine_BBDOU::leavePause(uint32 threadId) {
	uint32 sceneId = _activeScenes.getCurrentScene();
	_backgroundInstances->unpauseBySceneId(sceneId);
	_actorInstances->unpauseBySceneId(sceneId);
	_controls->unpauseControlsBySceneId(sceneId);
	_threads->notifyThreadsBySceneId(sceneId, threadId);
	_camera->popCameraMode();
	_activeScenes.unpauseActiveScene();
}

void IllusionsEngine_BBDOU::dumpActiveScenes(uint32 sceneId, uint32 threadId) {
	uint activeScenesCount = _activeScenes.getActiveScenesCount();
	while (activeScenesCount > 0) {
		uint32 activeSceneId;
		_activeScenes.getActiveSceneInfo(activeScenesCount, &activeSceneId, 0);
		if (activeSceneId == sceneId)
			break;
		exitScene(threadId);
		--activeScenesCount;
	}
	_camera->clearCameraModeStack();
}

void IllusionsEngine_BBDOU::enterMenuPause() {
	// TODO suspendAudio();
	_screenText->clearText();
}

void IllusionsEngine_BBDOU::leaveMenuPause() {
	_screenText->removeText();
	// TODO unsuspendAudio();
}

void IllusionsEngine_BBDOU::setSceneIdThreadId(uint32 theSceneId, uint32 theThreadId) {
	_theSceneId = theSceneId;
	_theThreadId = theThreadId;
}

bool IllusionsEngine_BBDOU::findTriggerCause(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId, uint32 &codeOffs) {
	SceneInfo *sceneInfo = _scriptResource->getSceneInfo(sceneId & 0xFFFF);
	if (sceneInfo)
		return sceneInfo->findTriggerCause(verbId, objectId2, objectId, codeOffs);
	return false;
}

void IllusionsEngine_BBDOU::reset() {
	_scriptResource->_blockCounters.clear();
	_scriptResource->_properties.clear();
	// TODO script_sub_417FF0(1, 0);
}

} // End of namespace Illusions