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  * Additional copyright for this file:
8  * Copyright (C) 1995-1997 Presto Studios, Inc.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23  *
24  */
25 
26 #include "pegasus/compass.h"
27 #include "pegasus/energymonitor.h"
28 #include "pegasus/interface.h"
29 #include "pegasus/pegasus.h"
30 #include "pegasus/ai/ai_area.h"
31 #include "pegasus/items/biochips/biochipitem.h"
32 #include "pegasus/items/inventory/inventoryitem.h"
33 
34 namespace Pegasus {
35 
36 Interface *g_interface = 0;
37 
Interface()38 Interface::Interface() : InputHandler(0), _interfaceNotification(kInterfaceNotificationID, (NotificationManager *)((PegasusEngine *)g_engine)),
39 			_currentItemSpot(kCurrentItemSpotID), _currentBiochipSpot(kCurrentBiochipSpotID),
40 			_background1(kInterface1ID), _background2(kInterface2ID), _background3(kInterface3ID),
41 			_background4(kInterface4ID), _datePicture(kDateID), _inventoryPush(kInventoryPushID),
42 			_inventoryLid(kInventoryLidID, kNoDisplayElement),
43 			_inventoryPanel(kNoDisplayElement, (InputHandler *)((PegasusEngine *)g_engine), ((PegasusEngine *)g_engine)->getItemsInventory()),
44 			_biochipPush(kBiochipPushID), _biochipLid(kBiochipLidID, kNoDisplayElement),
45 			_biochipPanel(kNoDisplayElement, (InputHandler *)((PegasusEngine *)g_engine), ((PegasusEngine *)g_engine)->getBiochipsInventory()) {
46 	g_energyMonitor = 0;
47 	_previousHandler = 0;
48 	_inventoryRaised = false;
49 	_biochipRaised = false;
50 	_playingEndMessage = false;
51 	g_interface = this;
52 }
53 
~Interface()54 Interface::~Interface() {
55 	throwAwayInterface();
56 	g_interface = 0;
57 }
58 
throwAwayInterface()59 void Interface::throwAwayInterface() {
60 	g_allHotspots.removeOneHotspot(kCurrentItemSpotID);
61 	g_allHotspots.removeOneHotspot(kCurrentBiochipSpotID);
62 
63 	throwAwayBackground();
64 	throwAwayDateMonitor();
65 	throwAwayEnergyMonitor();
66 	throwAwayAIArea();
67 	throwAwayCompass();
68 	throwAwayNotifications();
69 	throwAwayInventoryPanel();
70 	throwAwayBiochipPanel();
71 }
72 
validateBackground()73 void Interface::validateBackground() {
74 	if (!_background1.isSurfaceValid()) {
75 		_background1.initFromPICTFile("Images/Interface/3DInterface Left");
76 		_background2.initFromPICTFile("Images/Interface/3DInterface Top");
77 		_background3.initFromPICTFile("Images/Interface/3DInterface Right");
78 		_background4.initFromPICTFile("Images/Interface/3DInterface Bottom");
79 
80 		_background1.setDisplayOrder(kBackground1Order);
81 		_background1.startDisplaying();
82 		_background1.moveElementTo(kBackground1Left, kBackground1Top);
83 
84 		_background2.setDisplayOrder(kBackground2Order);
85 		_background2.startDisplaying();
86 		_background2.moveElementTo(kBackground2Left, kBackground2Top);
87 
88 		_background3.setDisplayOrder(kBackground2Order);
89 		_background3.startDisplaying();
90 		_background3.moveElementTo(kBackground3Left, kBackground3Top);
91 
92 		_background4.setDisplayOrder(kBackground4Order);
93 		_background4.startDisplaying();
94 		_background4.moveElementTo(kBackground4Left, kBackground4Top);
95 
96 		_background1.show();
97 		_background2.show();
98 		_background3.show();
99 		_background4.show();
100 	}
101 }
102 
throwAwayBackground()103 void Interface::throwAwayBackground() {
104 	_background1.stopDisplaying();
105 	_background1.deallocateSurface();
106 	_background2.stopDisplaying();
107 	_background2.deallocateSurface();
108 	_background3.stopDisplaying();
109 	_background3.deallocateSurface();
110 	_background4.stopDisplaying();
111 	_background4.deallocateSurface();
112 }
113 
validateDateMonitor()114 void Interface::validateDateMonitor() {
115 	if (!_datePicture.isSurfaceValid()) {
116 		_datePicture.setDisplayOrder(kDateOrder);
117 		_datePicture.startDisplaying();
118 		_datePicture.moveElementTo(kDateLeft, kDateTop);
119 		_datePicture.show();
120 	}
121 }
122 
throwAwayDateMonitor()123 void Interface::throwAwayDateMonitor() {
124 	_datePicture.stopDisplaying();
125 	_datePicture.deallocateSurface();
126 }
127 
setDate(const uint16 dateResID)128 void Interface::setDate(const uint16 dateResID) {
129 	validateDateMonitor();
130 	_datePicture.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, dateResID);
131 	_datePicture.triggerRedraw();
132 }
133 
validateCompass()134 void Interface::validateCompass() {
135 	if (!g_compass) {
136 		new Compass();
137 		g_compass->initCompass();
138 		g_compass->setDisplayOrder(kCompassOrder);
139 		g_compass->startDisplaying();
140 		g_compass->moveElementTo(kCompassLeft, kCompassTop);
141 		g_compass->show();
142 	}
143 }
144 
throwAwayCompass()145 void Interface::throwAwayCompass() {
146 	delete g_compass;
147 }
148 
validateNotifications()149 void Interface::validateNotifications() {
150 	_interfaceNotification.notifyMe(this, kInterfaceNotificationFlags, kInterfaceNotificationFlags);
151 	_inventoryLidCallBack.setNotification(&_interfaceNotification);
152 	_inventoryPushCallBack.setNotification(&_interfaceNotification);
153 	_biochipLidCallBack.setNotification(&_interfaceNotification);
154 	_biochipPushCallBack.setNotification(&_interfaceNotification);
155 }
156 
throwAwayNotifications()157 void Interface::throwAwayNotifications() {
158 	_interfaceNotification.cancelNotification(this);
159 }
160 
validateAIArea()161 void Interface::validateAIArea() {
162 	if (!g_AIArea) {
163 		new AIArea((InputHandler *)((PegasusEngine *)g_engine));
164 		if (g_AIArea)
165 			g_AIArea->initAIArea();
166 	}
167 }
168 
throwAwayAIArea()169 void Interface::throwAwayAIArea() {
170 	delete g_AIArea;
171 }
172 
validateInventoryPanel()173 void Interface::validateInventoryPanel() {
174 	if (!_inventoryPanel.isSurfaceValid()) {
175 		_inventoryPanel.initInventoryImage(&_inventoryPush);
176 		_inventoryPanel.moveElementTo(kInventoryPushLeft, kInventoryPushTop);
177 		_inventoryPush.setSlideDirection(kSlideUpMask);
178 		_inventoryPush.setInAndOutElements(&_inventoryPanel, 0);
179 		_inventoryPush.setDisplayOrder(kInventoryPushOrder);
180 		_inventoryPush.startDisplaying();
181 
182 		_inventoryLid.useFileName("Images/Lids/Inventory Lid Sequence");
183 		_inventoryLid.useTransparent(true);
184 		_inventoryLid.openFrameSequence();
185 		_inventoryLid.moveElementTo(kInventoryLidLeft, kInventoryLidTop);
186 		_inventoryLid.setDisplayOrder(kInventoryLidOrder);
187 		_inventoryLid.startDisplaying();
188 
189 		if (((PegasusEngine *)g_engine)->isDVD()) {
190 			_inventoryOpenSound.initFromAIFFFile("Sounds/Items/Inventory Panel Open.aif");
191 			_inventoryCloseSound.initFromAIFFFile("Sounds/Items/Inventory Panel Close.aif");
192 		}
193 
194 		_inventoryPushCallBack.initCallBack(&_inventoryPush, kCallBackAtExtremes);
195 		_inventoryLidCallBack.initCallBack(&_inventoryLid, kCallBackAtExtremes);
196 
197 		_inventoryUp = false;
198 		_inventoryRaised = false;
199 
200 		Item *item = getCurrentInventoryItem();
201 		if (item)
202 			item->select();
203 	}
204 }
205 
throwAwayInventoryPanel()206 void Interface::throwAwayInventoryPanel() {
207 	_inventoryPanel.stopDisplaying();
208 	_inventoryPanel.throwAwayInventoryImage();
209 	_inventoryPush.stopDisplaying();
210 	_inventoryLid.stopDisplaying();
211 	_inventoryLid.closeFrameSequence();
212 	_inventoryPushCallBack.releaseCallBack();
213 	_inventoryLidCallBack.releaseCallBack();
214 
215 	Item *item = getCurrentInventoryItem();
216 	if (item)
217 		item->deselect();
218 
219 	_inventoryUp = false;
220 	_inventoryRaised = false;
221 }
222 
validateBiochipPanel()223 void Interface::validateBiochipPanel() {
224 	if (!_biochipPanel.isSurfaceValid()) {
225 		_biochipPanel.initInventoryImage(&_biochipPush);
226 		_biochipPanel.moveElementTo(kBiochipPushLeft, kBiochipPushTop);
227 		_biochipPush.setSlideDirection(kSlideUpMask);
228 		_biochipPush.setInAndOutElements(&_biochipPanel, 0);
229 		_biochipPush.setDisplayOrder(kBiochipPushOrder);
230 		_biochipPush.startDisplaying();
231 
232 		_biochipLid.useFileName("Images/Lids/Biochip Lid Sequence");
233 		_biochipLid.useTransparent(true);
234 		_biochipLid.openFrameSequence();
235 		_biochipLid.moveElementTo(kBiochipLidLeft, kBiochipLidTop);
236 		_biochipLid.setDisplayOrder(kBiochipLidOrder);
237 		_biochipLid.startDisplaying();
238 
239 		if (((PegasusEngine *)g_engine)->isDVD()) {
240 			_biochipOpenSound.initFromAIFFFile("Sounds/Items/Biochip Panel Open.aif");
241 			_biochipCloseSound.initFromAIFFFile("Sounds/Items/Biochip Panel Close.aif");
242 		}
243 
244 		_biochipPushCallBack.initCallBack(&_biochipPush, kCallBackAtExtremes);
245 		_biochipLidCallBack.initCallBack(&_biochipLid, kCallBackAtExtremes);
246 
247 		_biochipUp = false;
248 		_biochipRaised = false;
249 
250 		Item *item = getCurrentBiochip();
251 		if (item)
252 			item->select();
253 	}
254 }
255 
throwAwayBiochipPanel()256 void Interface::throwAwayBiochipPanel() {
257 	_biochipPanel.stopDisplaying();
258 	_biochipPanel.throwAwayInventoryImage();
259 	_biochipPush.stopDisplaying();
260 	_biochipLid.stopDisplaying();
261 	_biochipLid.closeFrameSequence();
262 	_biochipPushCallBack.releaseCallBack();
263 	_biochipLidCallBack.releaseCallBack();
264 
265 	Item *item = getCurrentBiochip();
266 	if (item)
267 		item->deselect();
268 
269 	_biochipUp = false;
270 	_biochipRaised = false;
271 }
272 
validateEnergyMonitor()273 void Interface::validateEnergyMonitor() {
274 	if (!g_energyMonitor)
275 		new EnergyMonitor();
276 }
277 
throwAwayEnergyMonitor()278 void Interface::throwAwayEnergyMonitor() {
279 	delete g_energyMonitor;
280 }
281 
createInterface()282 void Interface::createInterface() {
283 	validateBackground();
284 	validateDateMonitor();
285 	validateCompass();
286 	validateNotifications();
287 	validateAIArea();
288 	validateBiochipPanel();
289 	validateInventoryPanel();
290 	validateEnergyMonitor();
291 
292 	if (!g_allHotspots.findHotspotByID(kCurrentItemSpotID)) {
293 		_currentItemSpot.setArea(Common::Rect(76, 334, 172, 430));
294 		_currentItemSpot.setHotspotFlags(kShellSpotFlag);
295 		_currentItemSpot.setActive();
296 		g_allHotspots.push_back(&_currentItemSpot);
297 	}
298 
299 	if (!g_allHotspots.findHotspotByID(kCurrentBiochipSpotID)) {
300 		_currentBiochipSpot.setArea(Common::Rect(364, 334, 460, 430));
301 		_currentBiochipSpot.setHotspotFlags(kShellSpotFlag);
302 		_currentBiochipSpot.setActive();
303 		g_allHotspots.push_back(&_currentBiochipSpot);
304 	}
305 }
306 
addInventoryItem(InventoryItem * item)307 InventoryResult Interface::addInventoryItem(InventoryItem *item) {
308 	return _inventoryPanel.addInventoryItem(item);
309 }
310 
removeInventoryItem(InventoryItem * item)311 InventoryResult Interface::removeInventoryItem(InventoryItem *item) {
312 	return _inventoryPanel.removeInventoryItem(item);
313 }
314 
removeAllItemsFromInventory()315 void Interface::removeAllItemsFromInventory() {
316 	_inventoryPanel.removeAllItems();
317 }
318 
getCurrentInventoryItem()319 InventoryItem *Interface::getCurrentInventoryItem() {
320 	return (InventoryItem *)_inventoryPanel.getCurrentItem();
321 }
322 
setCurrentInventoryItem(InventoryItem * item)323 void Interface::setCurrentInventoryItem(InventoryItem *item) {
324 	setCurrentInventoryItemID(item->getObjectID());
325 }
326 
setCurrentInventoryItemID(ItemID id)327 void Interface::setCurrentInventoryItemID(ItemID id) {
328 	_inventoryPanel.setCurrentItemID(id);
329 }
330 
addBiochip(BiochipItem * item)331 InventoryResult Interface::addBiochip(BiochipItem *item) {
332 	return _biochipPanel.addInventoryItem(item);
333 }
334 
removeAllItemsFromBiochips()335 void Interface::removeAllItemsFromBiochips() {
336 	_biochipPanel.removeAllItems();
337 }
338 
getCurrentBiochip()339 BiochipItem *Interface::getCurrentBiochip() {
340 	return (BiochipItem *)_biochipPanel.getCurrentItem();
341 }
342 
setCurrentBiochip(BiochipItem * item)343 void Interface::setCurrentBiochip(BiochipItem *item) {
344 	setCurrentBiochipID(item->getObjectID());
345 }
346 
setCurrentBiochipID(ItemID id)347 void Interface::setCurrentBiochipID(ItemID id) {
348 	_biochipPanel.setCurrentItemID(id);
349 }
350 
receiveNotification(Notification * notification,const NotificationFlags flags)351 void Interface::receiveNotification(Notification *notification, const NotificationFlags flags) {
352 	if (notification == &_interfaceNotification) {
353 		switch (flags) {
354 		case kInventoryLidOpenFlag:
355 			inventoryLidOpen(true);
356 			break;
357 		case kInventoryLidClosedFlag:
358 			inventoryLidClosed();
359 			break;
360 		case kInventoryDrawerUpFlag:
361 			inventoryDrawerUp();
362 			break;
363 		case kInventoryDrawerDownFlag:
364 			inventoryDrawerDown(true);
365 			break;
366 		case kBiochipLidOpenFlag:
367 			biochipLidOpen(true);
368 			break;
369 		case kBiochipLidClosedFlag:
370 			biochipLidClosed();
371 			break;
372 		case kBiochipDrawerUpFlag:
373 			biochipDrawerUp();
374 			break;
375 		case kBiochipDrawerDownFlag:
376 			biochipDrawerDown(true);
377 			break;
378 		}
379 	}
380 }
381 
raiseInventoryDrawer(const bool doCallBacks)382 void Interface::raiseInventoryDrawer(const bool doCallBacks) {
383 	if (!_biochipUp)
384 		_previousHandler = InputHandler::getCurrentHandler();
385 
386 	InputHandler::setInputHandler(&_inventoryPanel);
387 	_inventoryUp = true;
388 	_inventoryPanel.activateInventoryPicture();
389 
390 	if (doCallBacks) {
391 		_inventoryLidCallBack.setCallBackFlag(kInventoryLidOpenFlag);
392 		_inventoryLidCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
393 	}
394 
395 	_inventoryLid.show();
396 	_inventoryPush.show();
397 	_inventoryLid.start();
398 
399 	if (((PegasusEngine *)g_engine)->isDVD()) {
400 		_inventoryCloseSound.stopSound();
401 		_inventoryOpenSound.playSound();
402 	}
403 }
404 
playEndMessage()405 void Interface::playEndMessage() {
406 	raiseInventoryDrawerForMessage();
407 	_playingEndMessage = true;
408 	_inventoryPanel.playEndMessage(&_inventoryPush);
409 	lowerInventoryDrawerForMessage();
410 	_playingEndMessage = false;
411 }
412 
raiseInventoryDrawerForMessage()413 void Interface::raiseInventoryDrawerForMessage() {
414 	_inventoryPanel.disableLooping();
415 	raiseInventoryDrawerSync();
416 }
417 
lowerInventoryDrawerForMessage()418 void Interface::lowerInventoryDrawerForMessage() {
419 	lowerInventoryDrawerSync();
420 }
421 
inventoryLidOpen(const bool doCallBacks)422 void Interface::inventoryLidOpen(const bool doCallBacks) {
423 	_inventoryLid.stop();
424 
425 	if (doCallBacks) {
426 		_inventoryPushCallBack.setCallBackFlag(kInventoryDrawerUpFlag);
427 		_inventoryPushCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
428 	}
429 
430 	FaderMoveSpec moveSpec;
431 	moveSpec.makeTwoKnotFaderSpec(60, 0, 0, 15, 1000);
432 	_inventoryPush.startFader(moveSpec);
433 }
434 
inventoryDrawerUp()435 void Interface::inventoryDrawerUp() {
436 	_inventoryPush.stopFader();
437 	_inventoryPanel.panelUp();
438 	_inventoryRaised = true;
439 }
440 
isInventoryUp()441 bool Interface::isInventoryUp() {
442 	return _inventoryRaised;
443 }
444 
isInventoryDown()445 bool Interface::isInventoryDown() {
446 	return !_inventoryUp;
447 }
448 
lowerInventoryDrawer(const bool doCallBacks)449 void Interface::lowerInventoryDrawer(const bool doCallBacks) {
450 	if (_inventoryRaised) {
451 		_inventoryRaised = false;
452 
453 		if (!_playingEndMessage)
454 			_inventoryPanel.deactivateInventoryPicture();
455 
456 		if (doCallBacks) {
457 			_inventoryPushCallBack.setCallBackFlag(kInventoryDrawerDownFlag);
458 			_inventoryPushCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
459 		}
460 
461 		FaderMoveSpec moveSpec;
462 		moveSpec.makeTwoKnotFaderSpec(60, 0, 1000, 15, 0);
463 		_inventoryPush.startFader(moveSpec);
464 
465 		if (((PegasusEngine *)g_engine)->isDVD()) {
466 			_inventoryOpenSound.stopSound();
467 			_inventoryCloseSound.playSound();
468 		}
469 	}
470 }
471 
inventoryDrawerDown(const bool doCallBacks)472 void Interface::inventoryDrawerDown(const bool doCallBacks) {
473 	_inventoryPush.stopFader();
474 
475 	if (doCallBacks) {
476 		_inventoryLidCallBack.setCallBackFlag(kInventoryLidClosedFlag);
477 		_inventoryLidCallBack.scheduleCallBack(kTriggerAtStart, 0, 0);
478 	}
479 
480 	_inventoryLid.setRate(-1);
481 }
482 
inventoryLidClosed()483 void Interface::inventoryLidClosed() {
484 	_inventoryLid.stop();
485 
486 	if (!_biochipUp)
487 		InputHandler::setInputHandler(_previousHandler);
488 
489 	_inventoryLid.hide();
490 	_inventoryPush.hide();
491 	_inventoryUp = false;
492 }
493 
raiseBiochipDrawer(const bool doCallBacks)494 void Interface::raiseBiochipDrawer(const bool doCallBacks) {
495 	if (!_inventoryUp)
496 		_previousHandler = InputHandler::getCurrentHandler();
497 
498 	InputHandler::setInputHandler(&_biochipPanel);
499 	_biochipUp = true;
500 	_biochipPanel.activateInventoryPicture();
501 
502 	if (doCallBacks) {
503 		_biochipLidCallBack.setCallBackFlag(kBiochipLidOpenFlag);
504 		_biochipLidCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
505 	}
506 
507 	_biochipLid.show();
508 	_biochipPush.show();
509 	_biochipLid.start();
510 
511 	if (((PegasusEngine *)g_engine)->isDVD()) {
512 		_biochipCloseSound.stopSound();
513 		_biochipOpenSound.playSound();
514 	}
515 }
516 
biochipLidOpen(const bool doCallBacks)517 void Interface::biochipLidOpen(const bool doCallBacks) {
518 	_biochipLid.stop();
519 
520 	if (doCallBacks) {
521 		_biochipPushCallBack.setCallBackFlag(kBiochipDrawerUpFlag);
522 		_biochipPushCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
523 	}
524 
525 	FaderMoveSpec moveSpec;
526 	moveSpec.makeTwoKnotFaderSpec(60, 0, 0, 9, 1000);
527 	_biochipPush.startFader(moveSpec);
528 }
529 
biochipDrawerUp()530 void Interface::biochipDrawerUp() {
531 	_biochipPush.stopFader();
532 	_biochipPanel.panelUp();
533 	_biochipRaised = true;
534 }
535 
lowerBiochipDrawer(const bool doCallBacks)536 void Interface::lowerBiochipDrawer(const bool doCallBacks) {
537 	if (_biochipRaised) {
538 		_biochipRaised = false;
539 		_biochipPanel.deactivateInventoryPicture();
540 
541 		if (doCallBacks) {
542 			_biochipPushCallBack.setCallBackFlag(kBiochipDrawerDownFlag);
543 			_biochipPushCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
544 		}
545 
546 		FaderMoveSpec moveSpec;
547 		moveSpec.makeTwoKnotFaderSpec(60, 0, 1000, 9, 0);
548 		_biochipPush.startFader(moveSpec);
549 
550 		if (((PegasusEngine *)g_engine)->isDVD()) {
551 			_biochipOpenSound.stopSound();
552 			_biochipCloseSound.playSound();
553 		}
554 	}
555 }
556 
biochipDrawerDown(const bool doCallBacks)557 void Interface::biochipDrawerDown(const bool doCallBacks) {
558 	_biochipPush.stopFader();
559 
560 	if (doCallBacks) {
561 		_biochipLidCallBack.setCallBackFlag(kBiochipLidClosedFlag);
562 		_biochipLidCallBack.scheduleCallBack(kTriggerAtStart, 0, 0);
563 	}
564 
565 	_biochipLid.setRate(-1);
566 }
567 
biochipLidClosed()568 void Interface::biochipLidClosed() {
569 	_biochipLid.stop();
570 
571 	if (!_inventoryUp)
572 		InputHandler::setInputHandler(_previousHandler);
573 
574 	_biochipLid.hide();
575 	_biochipPush.hide();
576 	_biochipUp = false;
577 }
578 
calibrateCompass()579 void Interface::calibrateCompass() {
580 	uint32 currentValue = g_compass->getFaderValue();
581 	FaderMoveSpec compassMove;
582 	compassMove.makeTwoKnotFaderSpec(15, 0, currentValue, 30, currentValue + 360);
583 
584 	g_compass->startFader(compassMove);
585 
586 	PegasusEngine *vm = (PegasusEngine *)g_engine;
587 
588 	while (g_compass->isFading()) {
589 		vm->refreshDisplay();
590 		g_system->delayMillis(10);
591 	}
592 
593 	vm->refreshDisplay();
594 	g_compass->setFaderValue(currentValue);
595 }
596 
calibrateEnergyBar()597 void Interface::calibrateEnergyBar() {
598 	g_energyMonitor->calibrateEnergyBar();
599 }
600 
raiseInventoryDrawerSync()601 void Interface::raiseInventoryDrawerSync() {
602 	PegasusEngine *vm = (PegasusEngine *)g_engine;
603 
604 	raiseInventoryDrawer(false);
605 
606 	while (_inventoryLid.isRunning()) {
607 		InputDevice.pumpEvents();
608 		vm->checkCallBacks();
609 		vm->refreshDisplay();
610 		g_system->delayMillis(10);
611 	}
612 
613 	vm->refreshDisplay();
614 	inventoryLidOpen(false);
615 
616 	while (_inventoryPush.isFading()) {
617 		InputDevice.pumpEvents();
618 		vm->checkCallBacks();
619 		vm->refreshDisplay();
620 		g_system->delayMillis(10);
621 	}
622 
623 	vm->refreshDisplay();
624 	inventoryDrawerUp();
625 }
626 
lowerInventoryDrawerSync()627 void Interface::lowerInventoryDrawerSync() {
628 	PegasusEngine *vm = (PegasusEngine *)g_engine;
629 
630 	lowerInventoryDrawer(false);
631 
632 	while (_inventoryPush.isFading()) {
633 		InputDevice.pumpEvents();
634 		vm->checkCallBacks();
635 		vm->refreshDisplay();
636 		g_system->delayMillis(10);
637 	}
638 
639 	vm->refreshDisplay();
640 	inventoryDrawerDown(false);
641 
642 	while (_inventoryLid.isRunning()) {
643 		InputDevice.pumpEvents();
644 		vm->checkCallBacks();
645 		vm->refreshDisplay();
646 		g_system->delayMillis(10);
647 	}
648 
649 	vm->refreshDisplay();
650 	inventoryLidClosed();
651 }
652 
raiseBiochipDrawerSync()653 void Interface::raiseBiochipDrawerSync() {
654 	PegasusEngine *vm = (PegasusEngine *)g_engine;
655 
656 	raiseBiochipDrawer(false);
657 
658 	while (_biochipLid.isRunning()) {
659 		InputDevice.pumpEvents();
660 		vm->checkCallBacks();
661 		vm->refreshDisplay();
662 		g_system->delayMillis(10);
663 	}
664 
665 	vm->refreshDisplay();
666 	biochipLidOpen(false);
667 
668 	while (_biochipPush.isFading()) {
669 		InputDevice.pumpEvents();
670 		vm->checkCallBacks();
671 		vm->refreshDisplay();
672 		g_system->delayMillis(10);
673 	}
674 
675 	vm->refreshDisplay();
676 	biochipDrawerUp();
677 }
678 
lowerBiochipDrawerSync()679 void Interface::lowerBiochipDrawerSync() {
680 	PegasusEngine *vm = (PegasusEngine *)g_engine;
681 
682 	lowerBiochipDrawer(false);
683 
684 	while (_biochipPush.isFading()) {
685 		InputDevice.pumpEvents();
686 		vm->checkCallBacks();
687 		vm->refreshDisplay();
688 		g_system->delayMillis(10);
689 	}
690 
691 	vm->refreshDisplay();
692 	biochipDrawerDown(false);
693 
694 	while (_biochipLid.isRunning()) {
695 		InputDevice.pumpEvents();
696 		vm->checkCallBacks();
697 		vm->refreshDisplay();
698 		g_system->delayMillis(10);
699 	}
700 
701 	vm->refreshDisplay();
702 	biochipLidClosed();
703 }
704 
705 } // End of namespace Pegasus
706