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 		default:
379 			break;
380 		}
381 	}
382 }
383 
raiseInventoryDrawer(const bool doCallBacks)384 void Interface::raiseInventoryDrawer(const bool doCallBacks) {
385 	if (!_biochipUp)
386 		_previousHandler = InputHandler::getCurrentHandler();
387 
388 	InputHandler::setInputHandler(&_inventoryPanel);
389 	_inventoryUp = true;
390 	_inventoryPanel.activateInventoryPicture();
391 
392 	if (doCallBacks) {
393 		_inventoryLidCallBack.setCallBackFlag(kInventoryLidOpenFlag);
394 		_inventoryLidCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
395 	}
396 
397 	_inventoryLid.show();
398 	_inventoryPush.show();
399 	_inventoryLid.start();
400 
401 	if (((PegasusEngine *)g_engine)->isDVD()) {
402 		_inventoryCloseSound.stopSound();
403 		_inventoryOpenSound.setVolume(((PegasusEngine *)g_engine)->getSoundFXLevel());
404 		_inventoryOpenSound.playSound();
405 	}
406 }
407 
playEndMessage()408 void Interface::playEndMessage() {
409 	raiseInventoryDrawerForMessage();
410 	_playingEndMessage = true;
411 	_inventoryPanel.playEndMessage(&_inventoryPush);
412 	lowerInventoryDrawerForMessage();
413 	_playingEndMessage = false;
414 }
415 
raiseInventoryDrawerForMessage()416 void Interface::raiseInventoryDrawerForMessage() {
417 	_inventoryPanel.disableLooping();
418 
419 	// The DVD version has a different image for the inventory
420 	// for the end message.
421 	if (((PegasusEngine *)g_engine)->isDVD()) {
422 		_inventoryPanel.setCommPicture();
423 		_inventoryPanel.throwAwayInventoryImage();
424 		_inventoryPanel.initInventoryImage(&_inventoryPush);
425 	}
426 
427 	raiseInventoryDrawerSync();
428 }
429 
lowerInventoryDrawerForMessage()430 void Interface::lowerInventoryDrawerForMessage() {
431 	lowerInventoryDrawerSync();
432 }
433 
inventoryLidOpen(const bool doCallBacks)434 void Interface::inventoryLidOpen(const bool doCallBacks) {
435 	_inventoryLid.stop();
436 
437 	if (doCallBacks) {
438 		_inventoryPushCallBack.setCallBackFlag(kInventoryDrawerUpFlag);
439 		_inventoryPushCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
440 	}
441 
442 	FaderMoveSpec moveSpec;
443 	moveSpec.makeTwoKnotFaderSpec(60, 0, 0, 15, 1000);
444 	_inventoryPush.startFader(moveSpec);
445 }
446 
inventoryDrawerUp()447 void Interface::inventoryDrawerUp() {
448 	_inventoryPush.stopFader();
449 	_inventoryPanel.panelUp();
450 	_inventoryRaised = true;
451 }
452 
isInventoryUp()453 bool Interface::isInventoryUp() {
454 	return _inventoryRaised;
455 }
456 
isInventoryDown()457 bool Interface::isInventoryDown() {
458 	return !_inventoryUp;
459 }
460 
lowerInventoryDrawer(const bool doCallBacks)461 void Interface::lowerInventoryDrawer(const bool doCallBacks) {
462 	if (_inventoryRaised) {
463 		_inventoryRaised = false;
464 
465 		if (!_playingEndMessage)
466 			_inventoryPanel.deactivateInventoryPicture();
467 
468 		if (doCallBacks) {
469 			_inventoryPushCallBack.setCallBackFlag(kInventoryDrawerDownFlag);
470 			_inventoryPushCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
471 		}
472 
473 		FaderMoveSpec moveSpec;
474 		moveSpec.makeTwoKnotFaderSpec(60, 0, 1000, 15, 0);
475 		_inventoryPush.startFader(moveSpec);
476 
477 		if (((PegasusEngine *)g_engine)->isDVD()) {
478 			_inventoryOpenSound.stopSound();
479 			_inventoryCloseSound.setVolume(((PegasusEngine *)g_engine)->getSoundFXLevel());
480 			_inventoryCloseSound.playSound();
481 		}
482 	}
483 }
484 
inventoryDrawerDown(const bool doCallBacks)485 void Interface::inventoryDrawerDown(const bool doCallBacks) {
486 	_inventoryPush.stopFader();
487 
488 	if (doCallBacks) {
489 		_inventoryLidCallBack.setCallBackFlag(kInventoryLidClosedFlag);
490 		_inventoryLidCallBack.scheduleCallBack(kTriggerAtStart, 0, 0);
491 	}
492 
493 	_inventoryLid.setRate(-1);
494 }
495 
inventoryLidClosed()496 void Interface::inventoryLidClosed() {
497 	_inventoryLid.stop();
498 
499 	if (!_biochipUp)
500 		InputHandler::setInputHandler(_previousHandler);
501 
502 	_inventoryLid.hide();
503 	_inventoryPush.hide();
504 	_inventoryUp = false;
505 }
506 
raiseBiochipDrawer(const bool doCallBacks)507 void Interface::raiseBiochipDrawer(const bool doCallBacks) {
508 	if (!_inventoryUp)
509 		_previousHandler = InputHandler::getCurrentHandler();
510 
511 	InputHandler::setInputHandler(&_biochipPanel);
512 	_biochipUp = true;
513 	_biochipPanel.activateInventoryPicture();
514 
515 	if (doCallBacks) {
516 		_biochipLidCallBack.setCallBackFlag(kBiochipLidOpenFlag);
517 		_biochipLidCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
518 	}
519 
520 	_biochipLid.show();
521 	_biochipPush.show();
522 	_biochipLid.start();
523 
524 	if (((PegasusEngine *)g_engine)->isDVD()) {
525 		_biochipCloseSound.stopSound();
526 		_biochipOpenSound.setVolume(((PegasusEngine *)g_engine)->getSoundFXLevel());
527 		_biochipOpenSound.playSound();
528 	}
529 }
530 
biochipLidOpen(const bool doCallBacks)531 void Interface::biochipLidOpen(const bool doCallBacks) {
532 	_biochipLid.stop();
533 
534 	if (doCallBacks) {
535 		_biochipPushCallBack.setCallBackFlag(kBiochipDrawerUpFlag);
536 		_biochipPushCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
537 	}
538 
539 	FaderMoveSpec moveSpec;
540 	moveSpec.makeTwoKnotFaderSpec(60, 0, 0, 9, 1000);
541 	_biochipPush.startFader(moveSpec);
542 }
543 
biochipDrawerUp()544 void Interface::biochipDrawerUp() {
545 	_biochipPush.stopFader();
546 	_biochipPanel.panelUp();
547 	_biochipRaised = true;
548 }
549 
lowerBiochipDrawer(const bool doCallBacks)550 void Interface::lowerBiochipDrawer(const bool doCallBacks) {
551 	if (_biochipRaised) {
552 		_biochipRaised = false;
553 		_biochipPanel.deactivateInventoryPicture();
554 
555 		if (doCallBacks) {
556 			_biochipPushCallBack.setCallBackFlag(kBiochipDrawerDownFlag);
557 			_biochipPushCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
558 		}
559 
560 		FaderMoveSpec moveSpec;
561 		moveSpec.makeTwoKnotFaderSpec(60, 0, 1000, 9, 0);
562 		_biochipPush.startFader(moveSpec);
563 
564 		if (((PegasusEngine *)g_engine)->isDVD()) {
565 			_biochipOpenSound.stopSound();
566 			_biochipCloseSound.setVolume(((PegasusEngine *)g_engine)->getSoundFXLevel());
567 			_biochipCloseSound.playSound();
568 		}
569 	}
570 }
571 
biochipDrawerDown(const bool doCallBacks)572 void Interface::biochipDrawerDown(const bool doCallBacks) {
573 	_biochipPush.stopFader();
574 
575 	if (doCallBacks) {
576 		_biochipLidCallBack.setCallBackFlag(kBiochipLidClosedFlag);
577 		_biochipLidCallBack.scheduleCallBack(kTriggerAtStart, 0, 0);
578 	}
579 
580 	_biochipLid.setRate(-1);
581 }
582 
biochipLidClosed()583 void Interface::biochipLidClosed() {
584 	_biochipLid.stop();
585 
586 	if (!_inventoryUp)
587 		InputHandler::setInputHandler(_previousHandler);
588 
589 	_biochipLid.hide();
590 	_biochipPush.hide();
591 	_biochipUp = false;
592 }
593 
calibrateCompass()594 void Interface::calibrateCompass() {
595 	uint32 currentValue = g_compass->getFaderValue();
596 	FaderMoveSpec compassMove;
597 	compassMove.makeTwoKnotFaderSpec(15, 0, currentValue, 30, currentValue + 360);
598 
599 	g_compass->startFader(compassMove);
600 
601 	PegasusEngine *vm = (PegasusEngine *)g_engine;
602 
603 	while (g_compass->isFading()) {
604 		vm->refreshDisplay();
605 		g_system->delayMillis(10);
606 	}
607 
608 	vm->refreshDisplay();
609 	g_compass->setFaderValue(currentValue);
610 }
611 
calibrateEnergyBar()612 void Interface::calibrateEnergyBar() {
613 	g_energyMonitor->calibrateEnergyBar();
614 }
615 
raiseInventoryDrawerSync()616 void Interface::raiseInventoryDrawerSync() {
617 	PegasusEngine *vm = (PegasusEngine *)g_engine;
618 
619 	raiseInventoryDrawer(false);
620 
621 	while (_inventoryLid.isRunning()) {
622 		InputDevice.pumpEvents();
623 		vm->checkCallBacks();
624 		vm->refreshDisplay();
625 		g_system->delayMillis(10);
626 	}
627 
628 	vm->refreshDisplay();
629 	inventoryLidOpen(false);
630 
631 	while (_inventoryPush.isFading()) {
632 		InputDevice.pumpEvents();
633 		vm->checkCallBacks();
634 		vm->refreshDisplay();
635 		g_system->delayMillis(10);
636 	}
637 
638 	vm->refreshDisplay();
639 	inventoryDrawerUp();
640 }
641 
lowerInventoryDrawerSync()642 void Interface::lowerInventoryDrawerSync() {
643 	PegasusEngine *vm = (PegasusEngine *)g_engine;
644 
645 	lowerInventoryDrawer(false);
646 
647 	while (_inventoryPush.isFading()) {
648 		InputDevice.pumpEvents();
649 		vm->checkCallBacks();
650 		vm->refreshDisplay();
651 		g_system->delayMillis(10);
652 	}
653 
654 	vm->refreshDisplay();
655 	inventoryDrawerDown(false);
656 
657 	while (_inventoryLid.isRunning()) {
658 		InputDevice.pumpEvents();
659 		vm->checkCallBacks();
660 		vm->refreshDisplay();
661 		g_system->delayMillis(10);
662 	}
663 
664 	vm->refreshDisplay();
665 	inventoryLidClosed();
666 }
667 
raiseBiochipDrawerSync()668 void Interface::raiseBiochipDrawerSync() {
669 	PegasusEngine *vm = (PegasusEngine *)g_engine;
670 
671 	raiseBiochipDrawer(false);
672 
673 	while (_biochipLid.isRunning()) {
674 		InputDevice.pumpEvents();
675 		vm->checkCallBacks();
676 		vm->refreshDisplay();
677 		g_system->delayMillis(10);
678 	}
679 
680 	vm->refreshDisplay();
681 	biochipLidOpen(false);
682 
683 	while (_biochipPush.isFading()) {
684 		InputDevice.pumpEvents();
685 		vm->checkCallBacks();
686 		vm->refreshDisplay();
687 		g_system->delayMillis(10);
688 	}
689 
690 	vm->refreshDisplay();
691 	biochipDrawerUp();
692 }
693 
lowerBiochipDrawerSync()694 void Interface::lowerBiochipDrawerSync() {
695 	PegasusEngine *vm = (PegasusEngine *)g_engine;
696 
697 	lowerBiochipDrawer(false);
698 
699 	while (_biochipPush.isFading()) {
700 		InputDevice.pumpEvents();
701 		vm->checkCallBacks();
702 		vm->refreshDisplay();
703 		g_system->delayMillis(10);
704 	}
705 
706 	vm->refreshDisplay();
707 	biochipDrawerDown(false);
708 
709 	while (_biochipLid.isRunning()) {
710 		InputDevice.pumpEvents();
711 		vm->checkCallBacks();
712 		vm->refreshDisplay();
713 		g_system->delayMillis(10);
714 	}
715 
716 	vm->refreshDisplay();
717 	biochipLidClosed();
718 }
719 
720 } // End of namespace Pegasus
721