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 #include "dreamweb/sound.h"
24 #include "dreamweb/dreamweb.h"
25
26 namespace DreamWeb {
27
28
29 typedef void (DreamWebEngine::*UseCallback)(void);
30
31 // Note: The callback pointer has been placed before the
32 // ID to keep MSVC happy (otherwise, it throws warnings
33 // that alignment of a member was sensitive to packing)
34 struct UseListEntry {
35 UseCallback callback;
36 const char *id;
37 };
38
useRoutine()39 void DreamWebEngine::useRoutine() {
40
41 static const UseListEntry kUseList[] = {
42 { &DreamWebEngine::useMon, "NETW" },
43 { &DreamWebEngine::useElevator1, "ELVA" },
44 { &DreamWebEngine::useElevator2, "ELVB" },
45 { &DreamWebEngine::useElevator3, "ELVC" },
46 { &DreamWebEngine::useElevator4, "ELVE" },
47 { &DreamWebEngine::useElevator5, "ELVF" },
48 { &DreamWebEngine::useChurchGate, "CGAT" },
49 { &DreamWebEngine::useStereo, "REMO" },
50 { &DreamWebEngine::useButtonA, "BUTA" },
51 { &DreamWebEngine::useWinch, "CBOX" },
52 { &DreamWebEngine::useLighter, "LITE" },
53 { &DreamWebEngine::usePlate, "PLAT" },
54 { &DreamWebEngine::useControl, "LIFT" },
55 { &DreamWebEngine::useWire, "WIRE" },
56 { &DreamWebEngine::useHandle, "HNDL" },
57 { &DreamWebEngine::useHatch, "HACH" },
58 { &DreamWebEngine::useElvDoor, "DOOR" },
59 { &DreamWebEngine::useCashCard, "CSHR" },
60 { &DreamWebEngine::useGun, "GUNA" },
61 { &DreamWebEngine::useCardReader1, "CRAA" },
62 { &DreamWebEngine::useCardReader2, "CRBB" },
63 { &DreamWebEngine::useCardReader3, "CRCC" },
64 { &DreamWebEngine::sitDownInBar, "SEAT" },
65 { &DreamWebEngine::useMenu, "MENU" },
66 { &DreamWebEngine::useCooker, "COOK" },
67 { &DreamWebEngine::callHotelLift, "ELCA" },
68 { &DreamWebEngine::callEdensLift, "EDCA" },
69 { &DreamWebEngine::callEdensDLift, "DDCA" },
70 { &DreamWebEngine::useAltar, "ALTR" },
71 { &DreamWebEngine::openHotelDoor, "LOKA" },
72 { &DreamWebEngine::openHotelDoor2, "LOKB" },
73 { &DreamWebEngine::openLouis, "ENTA" },
74 { &DreamWebEngine::openRyan, "ENTB" },
75 { &DreamWebEngine::openPoolBoss, "ENTE" },
76 { &DreamWebEngine::openYourNeighbor, "ENTC" },
77 { &DreamWebEngine::openEden, "ENTD" },
78 { &DreamWebEngine::openSarters, "ENTH" },
79 { &DreamWebEngine::wearWatch, "WWAT" },
80 { &DreamWebEngine::usePoolReader, "POOL" },
81 { &DreamWebEngine::wearShades, "WSHD" },
82 { &DreamWebEngine::grafittiDoor, "GRAF" },
83 { &DreamWebEngine::trapDoor, "TRAP" },
84 { &DreamWebEngine::edensCDPlayer, "CDPE" },
85 { &DreamWebEngine::openTVDoor, "DLOK" },
86 { &DreamWebEngine::useHole, "HOLE" },
87 { &DreamWebEngine::useDryer, "DRYR" },
88 { &DreamWebEngine::useChurchHole, "HOLY" },
89 { &DreamWebEngine::useWall, "WALL" },
90 { &DreamWebEngine::useDiary, "BOOK" },
91 { &DreamWebEngine::useAxe, "AXED" },
92 { &DreamWebEngine::useShield, "SHLD" },
93 { &DreamWebEngine::useRailing, "BCNY" },
94 { &DreamWebEngine::useCoveredBox, "LIDC" },
95 { &DreamWebEngine::useClearBox, "LIDU" },
96 { &DreamWebEngine::useOpenBox, "LIDO" },
97 { &DreamWebEngine::usePipe, "PIPE" },
98 { &DreamWebEngine::useBalcony, "BALC" },
99 { &DreamWebEngine::useWindow, "WIND" },
100 { &DreamWebEngine::viewFolder, "PAPR" },
101 { &DreamWebEngine::useTrainer, "UWTA" },
102 { &DreamWebEngine::useTrainer, "UWTB" },
103 { &DreamWebEngine::enterSymbol, "STAT" },
104 { &DreamWebEngine::openTomb, "TLID" },
105 { &DreamWebEngine::useSlab, "SLAB" },
106 { &DreamWebEngine::useCart, "CART" },
107 { &DreamWebEngine::useFullCart, "FCAR" },
108 { &DreamWebEngine::slabDoorA, "SLBA" },
109 { &DreamWebEngine::slabDoorB, "SLBB" },
110 { &DreamWebEngine::slabDoorC, "SLBC" },
111 { &DreamWebEngine::slabDoorD, "SLBD" },
112 { &DreamWebEngine::slabDoorE, "SLBE" },
113 { &DreamWebEngine::slabDoorF, "SLBF" },
114 { &DreamWebEngine::usePlinth, "PLIN" },
115 { &DreamWebEngine::useLadder, "LADD" },
116 { &DreamWebEngine::useLadderB, "LADB" },
117 { &DreamWebEngine::chewy, "GUMA" },
118 { &DreamWebEngine::wheelSound, "SQEE" },
119 { &DreamWebEngine::runTap, "TAPP" },
120 { &DreamWebEngine::playGuitar, "GUIT" },
121 { &DreamWebEngine::hotelControl, "CONT" },
122 { &DreamWebEngine::hotelBell, "BELL" },
123 };
124
125 if (_realLocation >= 50) {
126 if (_pointerPower == 0)
127 return;
128 _pointerPower = 0;
129 }
130
131 uint8 dummy;
132 void *obj = getAnyAd(&dummy, &dummy);
133
134 for (uint i = 0; i < ARRAYSIZE(kUseList); ++i) {
135 const UseListEntry &entry = kUseList[i];
136 if (objectMatches(obj, entry.id)) {
137 (this->*entry.callback)();
138 return;
139 }
140 }
141
142 delPointer();
143 const uint8 *obText = getObTextStart();
144 if (findNextColon(&obText) != 0) {
145 if (findNextColon(&obText) != 0) {
146 if (*obText != 0) {
147 useText(obText);
148 hangOnP(400);
149 putBackObStuff();
150 return;
151 }
152 }
153 }
154
155 createPanel();
156 showPanel();
157 showMan();
158 showExit();
159 obIcons();
160 printMessage(33, 100, 63, 241, true);
161 workToScreenM();
162 hangOnP(50);
163 putBackObStuff();
164 _commandType = 255;
165 }
166
useText(const uint8 * string)167 void DreamWebEngine::useText(const uint8 *string) {
168 createPanel();
169 showPanel();
170 showMan();
171 showExit();
172 obIcons();
173 printDirect(string, 36, 104, 241, true);
174 workToScreenM();
175 }
176
showFirstUse()177 void DreamWebEngine::showFirstUse() {
178 const uint8 *obText = getObTextStart();
179 findNextColon(&obText);
180 findNextColon(&obText);
181 useText(obText);
182 hangOnP(400);
183 }
184
showSecondUse()185 void DreamWebEngine::showSecondUse() {
186 const uint8 *obText = getObTextStart();
187 findNextColon(&obText);
188 findNextColon(&obText);
189 findNextColon(&obText);
190 useText(obText);
191 hangOnP(400);
192 }
193
edensCDPlayer()194 void DreamWebEngine::edensCDPlayer() {
195 showFirstUse();
196 _vars._watchingTime = 18 * 2;
197 _vars._reelToWatch = 25;
198 _vars._endWatchReel = 42;
199 _vars._watchSpeed = 1;
200 _vars._speedCount = 1;
201 _getBack = 1;
202 }
203
hotelBell()204 void DreamWebEngine::hotelBell() {
205 _sound->playChannel1(12);
206 showFirstUse();
207 putBackObStuff();
208 }
209
playGuitar()210 void DreamWebEngine::playGuitar() {
211 _sound->playChannel1(14);
212 showFirstUse();
213 putBackObStuff();
214 }
215
useElevator1()216 void DreamWebEngine::useElevator1() {
217 showFirstUse();
218 selectLocation();
219 _getBack = 1;
220 }
221
useElevator2()222 void DreamWebEngine::useElevator2() {
223 showFirstUse();
224
225 if (_vars._location == 23) // In pool hall
226 _newLocation = 31;
227 else
228 _newLocation = 23;
229
230 _vars._countToClose = 20;
231 _vars._countToOpen = 0;
232 _vars._watchingTime = 80;
233 _getBack = 1;
234 }
235
useElevator3()236 void DreamWebEngine::useElevator3() {
237 showFirstUse();
238 _vars._countToClose = 20;
239 _newLocation = 34;
240 _vars._reelToWatch = 46;
241 _vars._endWatchReel = 63;
242 _vars._watchSpeed = 1;
243 _vars._speedCount = 1;
244 _vars._watchingTime = 80;
245 _getBack = 1;
246 }
247
useElevator4()248 void DreamWebEngine::useElevator4() {
249 showFirstUse();
250 _vars._reelToWatch = 0;
251 _vars._endWatchReel = 11;
252 _vars._watchSpeed = 1;
253 _vars._speedCount = 1;
254 _vars._countToClose = 20;
255 _vars._watchingTime = 80;
256 _getBack = 1;
257 _newLocation = 24;
258 }
259
useElevator5()260 void DreamWebEngine::useElevator5() {
261 placeSetObject(4);
262 removeSetObject(0);
263 _newLocation = 20;
264 _vars._watchingTime = 80;
265 _vars._liftFlag = 1;
266 _vars._countToClose = 8;
267 _getBack = 1;
268 }
269
useHatch()270 void DreamWebEngine::useHatch() {
271 showFirstUse();
272 _newLocation = 40;
273 _getBack = 1;
274 }
275
wheelSound()276 void DreamWebEngine::wheelSound() {
277 _sound->playChannel1(17);
278 showFirstUse();
279 putBackObStuff();
280 }
281
callHotelLift()282 void DreamWebEngine::callHotelLift() {
283 _sound->playChannel1(12);
284 showFirstUse();
285 _vars._countToOpen = 8;
286 _getBack = 1;
287 _destination = 5;
288 _finalDest = 5;
289 autoSetWalk();
290 turnPathOn(4);
291 }
292
useShield()293 void DreamWebEngine::useShield() {
294 if (_realLocation != 20 || _vars._combatCount == 0) {
295 // Not in Sart room
296 showFirstUse();
297 putBackObStuff();
298 } else {
299 _vars._lastWeapon = 3;
300 showSecondUse();
301 _getBack = 1;
302 _vars._progressPoints++;
303 removeObFromInv();
304 }
305 }
306
useCoveredBox()307 void DreamWebEngine::useCoveredBox() {
308 _vars._progressPoints++;
309 showFirstUse();
310 _vars._watchingTime = 50;
311 _vars._reelToWatch = 41;
312 _vars._endWatchReel = 66;
313 _vars._watchSpeed = 1;
314 _vars._speedCount = 1;
315 _getBack = 1;
316 }
317
useRailing()318 void DreamWebEngine::useRailing() {
319 showFirstUse();
320 _vars._watchingTime = 80;
321 _vars._reelToWatch = 0;
322 _vars._endWatchReel = 30;
323 _vars._watchSpeed = 1;
324 _vars._speedCount = 1;
325 _getBack = 1;
326 _vars._manDead = 4;
327 }
328
wearWatch()329 void DreamWebEngine::wearWatch() {
330 if (_vars._watchOn == 1) {
331 // Already wearing watch
332 showSecondUse();
333 putBackObStuff();
334 } else {
335 showFirstUse();
336 _vars._watchOn = 1;
337 _getBack = 1;
338 uint8 dummy;
339 makeWorn((DynObject *)getAnyAd(&dummy, &dummy));
340 }
341 }
342
wearShades()343 void DreamWebEngine::wearShades() {
344 if (_vars._shadesOn == 1) {
345 // Already wearing shades
346 showSecondUse();
347 putBackObStuff();
348 } else {
349 _vars._shadesOn = 1;
350 showFirstUse();
351 _getBack = 1;
352 uint8 dummy;
353 makeWorn((DynObject *)getAnyAd(&dummy, &dummy));
354 }
355 }
356
useChurchHole()357 void DreamWebEngine::useChurchHole() {
358 showFirstUse();
359 _getBack = 1;
360 _vars._watchingTime = 28;
361 _vars._reelToWatch = 13;
362 _vars._endWatchReel = 26;
363 _vars._watchSpeed = 1;
364 _vars._speedCount = 1;
365 }
366
sitDownInBar()367 void DreamWebEngine::sitDownInBar() {
368 if (_vars._watchMode != 0xFF) {
369 // Sat down
370 showSecondUse();
371 putBackObStuff();
372 } else {
373 showFirstUse();
374 _vars._watchingTime = 50;
375 _vars._reelToWatch = 55;
376 _vars._endWatchReel = 71;
377 _vars._reelToHold = 73;
378 _vars._endOfHoldReel = 83;
379 _vars._watchSpeed = 1;
380 _vars._speedCount = 1;
381 _getBack = 1;
382 }
383 }
384
useDryer()385 void DreamWebEngine::useDryer() {
386 _sound->playChannel1(12);
387 showFirstUse();
388 _getBack = 1;
389 }
390
useBalcony()391 void DreamWebEngine::useBalcony() {
392 showFirstUse();
393 turnPathOn(6);
394 turnPathOff(0);
395 turnPathOff(1);
396 turnPathOff(2);
397 turnPathOff(3);
398 turnPathOff(4);
399 turnPathOff(5);
400 _vars._progressPoints++;
401 _mansPath = 6;
402 _destination = 6;
403 _finalDest = 6;
404 findXYFromPath();
405 switchRyanOff();
406 _resetManXY = 1;
407 _vars._watchingTime = 30 * 2;
408 _vars._reelToWatch = 183;
409 _vars._endWatchReel = 212;
410 _vars._watchSpeed = 1;
411 _vars._speedCount = 1;
412 _getBack = 1;
413 }
414
useWindow()415 void DreamWebEngine::useWindow() {
416 if (_mansPath != 6) {
417 // Not on balcony
418 showSecondUse();
419 putBackObStuff();
420 } else {
421 _vars._progressPoints++;
422 showFirstUse();
423 _newLocation = 29;
424 _getBack = 1;
425 }
426 }
427
trapDoor()428 void DreamWebEngine::trapDoor() {
429 _vars._progressPoints++;
430 showFirstUse();
431 switchRyanOff();
432 _vars._watchingTime = 20 * 2;
433 _vars._reelToWatch = 181;
434 _vars._endWatchReel = 197;
435 _newLocation = 26;
436 _vars._watchSpeed = 1;
437 _vars._speedCount = 1;
438 _getBack = 1;
439 }
440
callEdensLift()441 void DreamWebEngine::callEdensLift() {
442 showFirstUse();
443 _vars._countToOpen = 8;
444 _getBack = 1;
445 turnPathOn(2);
446 }
447
callEdensDLift()448 void DreamWebEngine::callEdensDLift() {
449 if (_vars._liftFlag == 1) {
450 // Eden's D here
451 showSecondUse();
452 putBackObStuff();
453 } else {
454 showFirstUse();
455 _vars._countToOpen = 8;
456 _getBack = 1;
457 turnPathOn(2);
458 }
459 }
460
openYourNeighbor()461 void DreamWebEngine::openYourNeighbor() {
462 enterCode(255, 255, 255, 255);
463 _getBack = 1;
464 }
465
openRyan()466 void DreamWebEngine::openRyan() {
467 enterCode(5, 1, 0, 6);
468 _getBack = 1;
469 }
470
openPoolBoss()471 void DreamWebEngine::openPoolBoss() {
472 enterCode(5, 2, 2, 2);
473 _getBack = 1;
474 }
475
openEden()476 void DreamWebEngine::openEden() {
477 enterCode(2, 8, 6, 5);
478 _getBack = 1;
479 }
480
openSarters()481 void DreamWebEngine::openSarters() {
482 enterCode(7, 8, 3, 3);
483 _getBack = 1;
484 }
485
openLouis()486 void DreamWebEngine::openLouis() {
487 enterCode(5, 2, 3, 8);
488 _getBack = 1;
489 }
490
491
useWall()492 void DreamWebEngine::useWall() {
493 showFirstUse();
494
495 if (_mansPath != 3) {
496 _vars._watchingTime = 30*2;
497 _vars._reelToWatch = 2;
498 _vars._endWatchReel = 31;
499 _vars._watchSpeed = 1;
500 _vars._speedCount = 1;
501 _getBack = 1;
502 turnPathOn(3);
503 turnPathOn(4);
504 turnPathOff(0);
505 turnPathOff(1);
506 turnPathOff(2);
507 turnPathOff(5);
508 _mansPath = 3;
509 _finalDest = 3;
510 findXYFromPath();
511 _resetManXY = 1;
512 switchRyanOff();
513 } else {
514 // Go back over
515 _vars._watchingTime = 30 * 2;
516 _vars._reelToWatch = 34;
517 _vars._endWatchReel = 60;
518 _vars._watchSpeed = 1;
519 _vars._speedCount = 1;
520 _getBack = 1;
521 turnPathOff(3);
522 turnPathOff(4);
523 turnPathOn(0);
524 turnPathOn(1);
525 turnPathOn(2);
526 turnPathOn(5);
527 _mansPath = 5;
528 _finalDest = 5;
529 findXYFromPath();
530 _resetManXY = 1;
531 switchRyanOff();
532 }
533 }
534
useLadder()535 void DreamWebEngine::useLadder() {
536 showFirstUse();
537 _mapX = _mapX - 11;
538 findRoomInLoc();
539 _facing = 6;
540 _turnToFace = 6;
541 _mansPath = 0;
542 _destination = 0;
543 _finalDest = 0;
544 findXYFromPath();
545 _resetManXY = 1;
546 _getBack = 1;
547 }
548
useLadderB()549 void DreamWebEngine::useLadderB() {
550 showFirstUse();
551 _mapX = _mapX + 11;
552 findRoomInLoc();
553 _facing = 2;
554 _turnToFace = 2;
555 _mansPath = 1;
556 _destination = 1;
557 _finalDest = 1;
558 findXYFromPath();
559 _resetManXY = 1;
560 _getBack = 1;
561 }
562
slabDoorA()563 void DreamWebEngine::slabDoorA() {
564 showFirstUse();
565 _getBack = 1;
566 _vars._watchSpeed = 1;
567 _vars._speedCount = 1;
568 _vars._reelToWatch = 13;
569 if (_vars._dreamNumber != 3) {
570 // Wrong
571 _vars._watchingTime = 40;
572 _vars._endWatchReel = 34;
573 _vars._watchSpeed = 1;
574 _vars._speedCount = 1;
575 } else {
576 _vars._progressPoints++;
577 _vars._watchingTime = 60;
578 _vars._endWatchReel = 42;
579 _newLocation = 47;
580 }
581 }
582
slabDoorB()583 void DreamWebEngine::slabDoorB() {
584 if (_vars._dreamNumber != 1) {
585 // Wrong
586 showFirstUse();
587 _getBack = 1;
588 _vars._watchSpeed = 1;
589 _vars._speedCount = 1;
590 _vars._reelToWatch = 44;
591 _vars._watchingTime = 40;
592 _vars._endWatchReel = 63;
593 _vars._watchSpeed = 1;
594 _vars._speedCount = 1;
595 } else {
596 if (!isRyanHolding("SHLD")) {
597 // No crystal
598 showPuzText(44, 200);
599 putBackObStuff();
600 } else {
601 // Got crystal
602 showFirstUse();
603 _vars._progressPoints++;
604 _getBack = 1;
605 _vars._watchSpeed = 1;
606 _vars._speedCount = 1;
607 _vars._reelToWatch = 44;
608 _vars._watchingTime = 60;
609 _vars._endWatchReel = 71;
610 _newLocation = 47;
611 }
612 }
613 }
614
slabDoorC()615 void DreamWebEngine::slabDoorC() {
616 showFirstUse();
617 _getBack = 1;
618 _vars._watchSpeed = 1;
619 _vars._speedCount = 1;
620 _vars._reelToWatch = 108;
621 if (_vars._dreamNumber != 4) {
622 // Wrong
623 _vars._watchingTime = 40;
624 _vars._endWatchReel = 127;
625 _vars._watchSpeed = 1;
626 _vars._speedCount = 1;
627 } else {
628 _vars._progressPoints++;
629 _vars._watchingTime = 60;
630 _vars._endWatchReel = 135;
631 _newLocation = 47;
632 }
633 }
634
slabDoorD()635 void DreamWebEngine::slabDoorD() {
636 showFirstUse();
637 _getBack = 1;
638 _vars._watchSpeed = 1;
639 _vars._speedCount = 1;
640 _vars._reelToWatch = 75;
641 if (_vars._dreamNumber != 0) {
642 // Wrong
643 _vars._watchingTime = 40;
644 _vars._endWatchReel = 94;
645 _vars._watchSpeed = 1;
646 _vars._speedCount = 1;
647 } else {
648 _vars._progressPoints++;
649 _vars._watchingTime = 60;
650 _vars._endWatchReel = 102;
651 _newLocation = 47;
652 }
653 }
654
slabDoorE()655 void DreamWebEngine::slabDoorE() {
656 showFirstUse();
657 _getBack = 1;
658 _vars._watchSpeed = 1;
659 _vars._speedCount = 1;
660 _vars._reelToWatch = 141;
661 if (_vars._dreamNumber != 5) {
662 // Wrong
663 _vars._watchingTime = 40;
664 _vars._endWatchReel = 160;
665 _vars._watchSpeed = 1;
666 _vars._speedCount = 1;
667 } else {
668 _vars._progressPoints++;
669 _vars._watchingTime = 60;
670 _vars._endWatchReel = 168;
671 _newLocation = 47;
672 }
673 }
674
slabDoorF()675 void DreamWebEngine::slabDoorF() {
676 showFirstUse();
677 _getBack = 1;
678 _vars._watchSpeed = 1;
679 _vars._speedCount = 1;
680 _vars._reelToWatch = 171;
681 if (_vars._dreamNumber != 2) {
682 // Wrong
683 _vars._watchingTime = 40;
684 _vars._endWatchReel = 189;
685 _vars._watchSpeed = 1;
686 _vars._speedCount = 1;
687 } else {
688 _vars._progressPoints++;
689 _vars._watchingTime = 60;
690 _vars._endWatchReel = 197;
691 _newLocation = 47;
692 }
693 }
694
defaultUseHandler(const char * id)695 bool DreamWebEngine::defaultUseHandler(const char *id) {
696 if (_withObject == 255) {
697 withWhat();
698 return true; // event handled
699 }
700
701 if (!compare(_withObject, _withType, id)) {
702 // Wrong item
703 showPuzText(14, 300);
704 putBackObStuff();
705 return true; // event handled
706 }
707
708 return false; // continue with the original event
709 }
710
useChurchGate()711 void DreamWebEngine::useChurchGate() {
712 if (defaultUseHandler("CUTT"))
713 return;
714
715 // Cut gate
716 showFirstUse();
717 _vars._watchingTime = 64 * 2;
718 _vars._reelToWatch = 4;
719 _vars._endWatchReel = 70;
720 _vars._watchSpeed = 1;
721 _vars._speedCount = 1;
722 _getBack = 1;
723 _vars._progressPoints++;
724 turnPathOn(3);
725 if (_vars._aideDead != 0)
726 turnPathOn(2); // Open church
727 }
728
useGun()729 void DreamWebEngine::useGun() {
730
731 if (_objectType != kExObjectType) {
732 // gun is not taken
733 showSecondUse();
734 putBackObStuff();
735
736 } else if (_realLocation == 22) {
737 // in pool room
738 showPuzText(34, 300);
739 _vars._lastWeapon = 1;
740 _vars._combatCount = 39;
741 _getBack = 1;
742 _vars._progressPoints++;
743
744 } else if (_realLocation == 25) {
745 // helicopter
746 showPuzText(34, 300);
747 _vars._lastWeapon = 1;
748 _vars._combatCount = 19;
749 _getBack = 1;
750 _vars._dreamNumber = 2;
751 _vars._roomAfterDream = 38;
752 _vars._sartainDead = 1;
753 _vars._progressPoints++;
754
755 } else if (_realLocation == 27) {
756 // in rock room
757 showPuzText(46, 300);
758 _pointerMode = 2;
759 _vars._rockstarDead = 1;
760 _vars._lastWeapon = 1;
761 _vars._newsItem = 1;
762 _getBack = 1;
763 _vars._roomAfterDream = 32;
764 _vars._dreamNumber = 0;
765 _vars._progressPoints++;
766
767 } else if (_realLocation == 8 && _mapX == 22 && _mapY == 40
768 && !isSetObOnMap(92) && _mansPath != 9) {
769 // by studio
770 _destination = 9;
771 _finalDest = 9;
772 autoSetWalk();
773 _vars._lastWeapon = 1;
774 _getBack = 1;
775 _vars._progressPoints++;
776
777 } else if (_realLocation == 6 && _mapX == 11 && _mapY == 20
778 && isSetObOnMap(5)) {
779 // sarters
780 _destination = 1;
781 _finalDest = 1;
782 autoSetWalk();
783 removeSetObject(5);
784 placeSetObject(6);
785 turnAnyPathOn(1, _roomNum - 1);
786 _vars._liftFlag = 1;
787 _vars._watchingTime = 40*2;
788 _vars._reelToWatch = 4;
789 _vars._endWatchReel = 43;
790 _vars._watchSpeed = 1;
791 _vars._speedCount = 1;
792 _getBack = 1;
793 _vars._progressPoints++;
794
795 } else if (_realLocation == 29) {
796 // aide
797 _getBack = 1;
798 resetLocation(13);
799 setLocation(12);
800 _destPos = 12;
801 _destination = 2;
802 _finalDest = 2;
803 autoSetWalk();
804 _vars._watchingTime = 164*2;
805 _vars._reelToWatch = 3;
806 _vars._endWatchReel = 164;
807 _vars._watchSpeed = 1;
808 _vars._speedCount = 1;
809 _vars._aideDead = 1;
810 _vars._dreamNumber = 3;
811 _vars._roomAfterDream = 33;
812 _vars._progressPoints++;
813
814 } else if (_realLocation == 23 && _mapX == 0 && _mapY == 50) {
815 // with boss
816 if (_mansPath != 5) {
817 _destination = 5;
818 _finalDest = 5;
819 autoSetWalk();
820 }
821 _vars._lastWeapon = 1;
822 _getBack = 1;
823
824 } else if (_realLocation == 8 && _mapX == 11 && _mapY == 10) {
825 // tv soldier
826 if (_mansPath != 2) {
827 _destination = 2;
828 _finalDest = 2;
829 autoSetWalk();
830 }
831 _vars._lastWeapon = 1;
832 _getBack = 1;
833
834 } else {
835 showFirstUse();
836 putBackObStuff();
837 }
838 }
839
useFullCart()840 void DreamWebEngine::useFullCart() {
841 _vars._progressPoints++;
842 turnAnyPathOn(2, _roomNum + 6);
843 _mansPath = 4;
844 _facing = 4;
845 _turnToFace = 4;
846 _finalDest = 4;
847 findXYFromPath();
848 _resetManXY = 1;
849 showFirstUse();
850 _vars._watchingTime = 72 * 2;
851 _vars._reelToWatch = 58;
852 _vars._endWatchReel = 142;
853 _vars._watchSpeed = 1;
854 _vars._speedCount = 1;
855 _getBack = 1;
856 }
857
useClearBox()858 void DreamWebEngine::useClearBox() {
859 if (defaultUseHandler("RAIL"))
860 return;
861
862 // Open box
863 _vars._progressPoints++;
864 showFirstUse();
865 _vars._watchingTime = 80;
866 _vars._reelToWatch = 67;
867 _vars._endWatchReel = 105;
868 _vars._watchSpeed = 1;
869 _vars._speedCount = 1;
870 _getBack = 1;
871 }
872
openTVDoor()873 void DreamWebEngine::openTVDoor() {
874 if (defaultUseHandler("ULOK"))
875 return;
876
877 // Key on TV
878 showFirstUse();
879 _vars._lockStatus = 0;
880 _getBack = 1;
881 }
882
usePlate()883 void DreamWebEngine::usePlate() {
884 if (_withObject == 255) {
885 withWhat();
886 return;
887 }
888
889 if (compare(_withObject, _withType, "SCRW")) {
890 // Unscrew plate
891 _sound->playChannel1(20);
892 showFirstUse();
893 placeSetObject(28);
894 placeSetObject(24);
895 removeSetObject(25);
896 placeFreeObject(0);
897 _vars._progressPoints++;
898 _getBack = 1;
899 } else if (compare(_withObject, _withType, "KNFE")) {
900 // Tried knife
901 showPuzText(54, 300);
902 putBackObStuff();
903 } else {
904 // Wrong item
905 showPuzText(14, 300);
906 putBackObStuff();
907 }
908 }
909
usePlinth()910 void DreamWebEngine::usePlinth() {
911 if (_withObject == 255) {
912 withWhat();
913 return;
914 }
915
916 if (!compare(_withObject, _withType, "DKEY")) {
917 // Wrong key
918 showFirstUse();
919 putBackObStuff();
920 } else {
921 _vars._progressPoints++;
922 showSecondUse();
923 _vars._watchingTime = 220;
924 _vars._reelToWatch = 0;
925 _vars._endWatchReel = 104;
926 _vars._watchSpeed = 1;
927 _vars._speedCount = 1;
928 _getBack = 1;
929 _newLocation = _vars._roomAfterDream;
930 }
931 }
932
useElvDoor()933 void DreamWebEngine::useElvDoor() {
934 if (defaultUseHandler("AXED"))
935 return;
936
937 // Axe on door
938 showPuzText(15, 300);
939 _vars._progressPoints++;
940 _vars._watchingTime = 46 * 2;
941 _vars._reelToWatch = 31;
942 _vars._endWatchReel = 77;
943 _vars._watchSpeed = 1;
944 _vars._speedCount = 1;
945 _getBack = 1;
946 }
947
useObject()948 void DreamWebEngine::useObject() {
949 _withObject = 255;
950
951 if (_commandType != 229) {
952 _commandType = 229;
953 commandWithOb(51, _objectType, _command);
954 }
955
956 if (_mouseButton == _oldButton)
957 return; // nouse
958
959 if (_mouseButton & 1)
960 useRoutine();
961 }
962
useWinch()963 void DreamWebEngine::useWinch() {
964 uint16 contentIndex = checkInside(40, 1);
965 if (contentIndex == kNumexobjects || !compare(contentIndex, kExObjectType, "FUSE")) {
966 // No winch
967 showFirstUse();
968 putBackObStuff();
969 return;
970 }
971
972 _vars._watchingTime = 217 * 2;
973 _vars._reelToWatch = 0;
974 _vars._endWatchReel = 217;
975 _vars._watchSpeed = 1;
976 _vars._speedCount = 1;
977 _destPos = 1;
978 _newLocation = 45;
979 _vars._dreamNumber = 1;
980 _vars._roomAfterDream = 44;
981 _vars._generalDead = 1;
982 _vars._newsItem = 2;
983 _getBack = 1;
984 _vars._progressPoints++;
985 }
986
useCart()987 void DreamWebEngine::useCart() {
988 if (defaultUseHandler("ROCK"))
989 return;
990
991 DynObject *exObject = getExAd(_withObject);
992 exObject->mapad[0] = 0;
993 removeSetObject(_command);
994 placeSetObject(_command + 1);
995 _vars._progressPoints++;
996 _sound->playChannel1(17);
997 showFirstUse();
998 _getBack = 1;
999 }
1000
useTrainer()1001 void DreamWebEngine::useTrainer() {
1002 uint8 dummy;
1003 DynObject *object = (DynObject *)getAnyAd(&dummy, &dummy);
1004 if (object->mapad[0] != 4) {
1005 notHeldError();
1006 } else {
1007 _vars._progressPoints++;
1008 makeWorn(object);
1009 showSecondUse();
1010 putBackObStuff();
1011 }
1012 }
1013
chewy()1014 void DreamWebEngine::chewy() {
1015 // Chewing a gum
1016 showFirstUse();
1017 uint8 dummy;
1018 DynObject *object = (DynObject *)getAnyAd(&dummy, &dummy);
1019 object->mapad[0] = 255;
1020 _getBack = 1;
1021 }
1022
useHole()1023 void DreamWebEngine::useHole() {
1024 if (defaultUseHandler("HNDA"))
1025 return;
1026
1027 showFirstUse();
1028 removeSetObject(86);
1029 DynObject *exObject = getExAd(_withObject);
1030 exObject->mapad[0] = 255;
1031 _vars._canMoveAltar = 1;
1032 _getBack = 1;
1033 }
1034
openHotelDoor()1035 void DreamWebEngine::openHotelDoor() {
1036 if (defaultUseHandler("KEYA"))
1037 return;
1038
1039 _sound->playChannel1(16);
1040 showFirstUse();
1041 _vars._lockStatus = 0;
1042 _getBack = 1;
1043 }
1044
openHotelDoor2()1045 void DreamWebEngine::openHotelDoor2() {
1046 if (defaultUseHandler("KEYA"))
1047 return;
1048
1049 _sound->playChannel1(16);
1050 showFirstUse();
1051 putBackObStuff();
1052 }
1053
grafittiDoor()1054 void DreamWebEngine::grafittiDoor() {
1055 if (defaultUseHandler("APEN"))
1056 return;
1057
1058 showFirstUse();
1059 putBackObStuff();
1060 }
1061
usePoolReader()1062 void DreamWebEngine::usePoolReader() {
1063 if (defaultUseHandler("MEMB"))
1064 return;
1065
1066 if (_vars._talkedToAttendant != 1) {
1067 // Can't open pool
1068 showSecondUse();
1069 putBackObStuff();
1070 } else {
1071 _sound->playChannel1(17);
1072 showFirstUse();
1073 _vars._countToOpen = 6;
1074 _getBack = 1;
1075 }
1076 }
1077
useCardReader1()1078 void DreamWebEngine::useCardReader1() {
1079 if (defaultUseHandler("CSHR"))
1080 return;
1081
1082 if (_vars._talkedToSparky == 0) {
1083 // Not yet
1084 showFirstUse();
1085 putBackObStuff();
1086 } else if (_vars._card1Money != 0) {
1087 // No cash
1088 showPuzText(17, 300);
1089 putBackObStuff();
1090 } else {
1091 // Get cash
1092 _sound->playChannel1(16);
1093 showPuzText(18, 300);
1094 _vars._progressPoints++;
1095 _vars._card1Money = 12432;
1096 _getBack = 1;
1097 }
1098 }
1099
useCardReader2()1100 void DreamWebEngine::useCardReader2() {
1101 if (defaultUseHandler("CSHR"))
1102 return;
1103
1104 if (_vars._talkedToBoss == 0) {
1105 // Haven't talked to boss
1106 showFirstUse();
1107 putBackObStuff();
1108 } else if (_vars._card1Money == 0) {
1109 // No cash
1110 showPuzText(20, 300);
1111 putBackObStuff();
1112 } else if (_vars._gunPassFlag == 2) {
1113 // Already got new
1114 showPuzText(22, 300);
1115 putBackObStuff();
1116 } else {
1117 _sound->playChannel1(18);
1118 showPuzText(19, 300);
1119 placeSetObject(94);
1120 _vars._gunPassFlag = 1;
1121 _vars._card1Money -= 2000;
1122 _vars._progressPoints++;
1123 _getBack = 1;
1124 }
1125 }
1126
useCardReader3()1127 void DreamWebEngine::useCardReader3() {
1128 if (defaultUseHandler("CSHR"))
1129 return;
1130
1131 if (_vars._talkedToRecep == 0) {
1132 // Haven't talked to receptionist
1133 showFirstUse();
1134 putBackObStuff();
1135 } else if (_vars._cardPassFlag != 0) {
1136 // Already used it
1137 showPuzText(26, 300);
1138 putBackObStuff();
1139 } else {
1140 _sound->playChannel1(16);
1141 showPuzText(25, 300);
1142 _vars._progressPoints++;
1143 _vars._card1Money -= 8300;
1144 _vars._cardPassFlag = 1;
1145 _getBack = 1;
1146 }
1147 }
1148
useLighter()1149 void DreamWebEngine::useLighter() {
1150 if (_withObject == 255) {
1151 withWhat();
1152 return;
1153 }
1154
1155 if (!compare(_withObject, _withType, "SMKE")) {
1156 showFirstUse();
1157 putBackObStuff();
1158 } else {
1159 showPuzText(9, 300);
1160 DynObject *withObj = getExAd(_withObject);
1161 withObj->mapad[0] = 255;
1162 _getBack = 1;
1163 }
1164 }
1165
useWire()1166 void DreamWebEngine::useWire() {
1167 if (_withObject == 255) {
1168 withWhat();
1169 return;
1170 }
1171
1172 if (compare(_withObject, _withType, "KNFE")) {
1173 removeSetObject(51);
1174 placeSetObject(52);
1175 showPuzText(11, 300);
1176 _vars._progressPoints++;
1177 _getBack = 1;
1178 return;
1179 }
1180
1181 if (compare(_withObject, _withType, "AXED")) {
1182 showPuzText(16, 300);
1183 putBackObStuff();
1184 return;
1185 }
1186
1187 showPuzText(14, 300);
1188 putBackObStuff();
1189 }
1190
openTomb()1191 void DreamWebEngine::openTomb() {
1192 _vars._progressPoints++;
1193 showFirstUse();
1194 _vars._watchingTime = 35 * 2;
1195 _vars._reelToWatch = 1;
1196 _vars._endWatchReel = 33;
1197 _vars._watchSpeed = 1;
1198 _vars._speedCount = 1;
1199 _getBack = 1;
1200 }
1201
hotelControl()1202 void DreamWebEngine::hotelControl() {
1203 if (_realLocation != 21 || _mapX != 33)
1204 showSecondUse(); // Not right control
1205 else
1206 showFirstUse();
1207
1208 putBackObStuff();
1209 }
1210
useCooker()1211 void DreamWebEngine::useCooker() {
1212 if (checkInside(_command, _objectType) == kNumexobjects)
1213 showFirstUse();
1214 else
1215 showSecondUse(); // Food inside
1216
1217 putBackObStuff();
1218 }
1219
placeFreeObject(uint8 index)1220 void DreamWebEngine::placeFreeObject(uint8 index) {
1221 findOrMake(index, 0, 1);
1222 getFreeAd(index)->mapad[0] = 0;
1223 }
1224
removeFreeObject(uint8 index)1225 void DreamWebEngine::removeFreeObject(uint8 index) {
1226 getFreeAd(index)->mapad[0] = 0xFF;
1227 }
1228
useControl()1229 void DreamWebEngine::useControl() {
1230 if (_withObject == 255) {
1231 withWhat();
1232 return;
1233 }
1234
1235 if (compare(_withObject, _withType, "KEYA")) { // Right key
1236 _sound->playChannel1(16);
1237 if (_vars._location == 21) { // Going down
1238 showPuzText(3, 300);
1239 _newLocation = 30;
1240 } else {
1241 showPuzText(0, 300);
1242 _newLocation = 21;
1243 }
1244
1245 _vars._countToClose = 8;
1246 _vars._countToOpen = 0;
1247 _vars._watchingTime = 80;
1248 _getBack = 1;
1249 return;
1250 }
1251
1252 if (_realLocation == 21) {
1253 if (compare(_withObject, _withType, "KNFE")) {
1254 // Jimmy controls
1255 placeSetObject(50);
1256 placeSetObject(51);
1257 placeSetObject(26);
1258 placeSetObject(30);
1259 removeSetObject(16);
1260 removeSetObject(17);
1261 _sound->playChannel1(14);
1262 showPuzText(10, 300);
1263 _vars._progressPoints++;
1264 _getBack = 1;
1265 } else if (compare(_withObject, _withType, "AXED")) {
1266 // Axe on controls
1267 showPuzText(16, 300);
1268 _vars._progressPoints++;
1269 putBackObStuff();
1270 } else {
1271 // Balls
1272 showFirstUse();
1273 putBackObStuff();
1274 }
1275 } else {
1276 // Balls
1277 showFirstUse();
1278 putBackObStuff();
1279 }
1280 }
1281
useSlab()1282 void DreamWebEngine::useSlab() {
1283 if (_withObject == 255) {
1284 withWhat();
1285 return;
1286 }
1287
1288 if (!compare(_withObject, _withType, "JEWL")) {
1289 showPuzText(14, 300);
1290 putBackObStuff();
1291 return;
1292 }
1293
1294 DynObject *exObject = getExAd(_withObject);
1295 exObject->mapad[0] = 0;
1296
1297 removeSetObject(_command);
1298 placeSetObject(_command + 1);
1299 if (_command + 1 == 54) {
1300 // Last slab
1301 turnPathOn(0);
1302 _vars._watchingTime = 22;
1303 _vars._reelToWatch = 35;
1304 _vars._endWatchReel = 48;
1305 _vars._watchSpeed = 1;
1306 _vars._speedCount = 1;
1307 }
1308
1309 _vars._progressPoints++;
1310 showFirstUse();
1311 _getBack = 1;
1312 }
1313
usePipe()1314 void DreamWebEngine::usePipe() {
1315 if (_withObject == 255) {
1316 withWhat();
1317 return;
1318 }
1319
1320 if (compare(_withObject, _withType, "CUPE")) {
1321 // Fill cup
1322 showPuzText(36, 300);
1323 putBackObStuff();
1324 DynObject *exObject = getExAd(_withObject);
1325 exObject->objId[3] = 'F'-'A'; // CUPE (empty cup) -> CUPF (full cup)
1326 return;
1327 } else if (compare(_withObject, _withType, "CUPF")) {
1328 // Already full
1329 showPuzText(35, 300);
1330 putBackObStuff();
1331 } else {
1332 showPuzText(14, 300);
1333 putBackObStuff();
1334 }
1335 }
1336
useOpenBox()1337 void DreamWebEngine::useOpenBox() {
1338 if (_withObject == 255) {
1339 withWhat();
1340 return;
1341 }
1342
1343 if (compare(_withObject, _withType, "CUPF")) {
1344 // Destroy open box
1345 _vars._progressPoints++;
1346 showPuzText(37, 300);
1347 DynObject *exObject = getExAd(_withObject);
1348 exObject->objId[3] = 'E'-'A'; // CUPF (full cup) -> CUPE (empty cup)
1349 _vars._watchingTime = 140;
1350 _vars._reelToWatch = 105;
1351 _vars._endWatchReel = 181;
1352 _vars._watchSpeed = 1;
1353 _vars._speedCount = 1;
1354 turnPathOn(4);
1355 _getBack = 1;
1356 return;
1357 }
1358
1359 if (compare(_withObject, _withType, "CUPE")) {
1360 // Open box wrong
1361 showPuzText(38, 300);
1362 putBackObStuff();
1363 return;
1364 }
1365
1366 showFirstUse();
1367 }
1368
runTap()1369 void DreamWebEngine::runTap() {
1370 if (_withObject == 255) {
1371 withWhat();
1372 return;
1373 }
1374
1375 if (compare(_withObject, _withType, "CUPE")) {
1376 // Fill cup from tap
1377 DynObject *exObject = getExAd(_withObject);
1378 exObject->objId[3] = 'F'-'A'; // CUPE (empty cup) -> CUPF (full cup)
1379 _sound->playChannel1(8);
1380 showPuzText(57, 300);
1381 putBackObStuff();
1382 return;
1383 }
1384
1385 if (compare(_withObject, _withType, "CUPF")) {
1386 // Cup from tap full
1387 showPuzText(58, 300);
1388 putBackObStuff();
1389 return;
1390 }
1391
1392 showPuzText(56, 300);
1393 putBackObStuff();
1394 }
1395
useAxe()1396 void DreamWebEngine::useAxe() {
1397 if (_realLocation != 22) {
1398 // Not in pool
1399 showFirstUse();
1400 return;
1401 }
1402
1403 if (_mapY == 10) {
1404 // Axe on door
1405 showPuzText(15, 300);
1406 _vars._progressPoints++;
1407 _vars._watchingTime = 46*2;
1408 _vars._reelToWatch = 31;
1409 _vars._endWatchReel = 77;
1410 _vars._watchSpeed = 1;
1411 _vars._speedCount = 1;
1412 _getBack = 1;
1413 return;
1414 }
1415
1416 showSecondUse();
1417 _vars._progressPoints++;
1418 _vars._lastWeapon = 2;
1419 _getBack = 1;
1420 removeObFromInv();
1421 }
1422
useHandle()1423 void DreamWebEngine::useHandle() {
1424 SetObject *object = getSetAd(findSetObject("CUTW"));
1425 if (object->mapad[0] == 255) {
1426 // Wire not cut
1427 showPuzText(12, 300);
1428 } else {
1429 // Wire has been cut
1430 showPuzText(13, 300);
1431 _newLocation = 22;
1432 }
1433
1434 _getBack = 1;
1435 }
1436
useAltar()1437 void DreamWebEngine::useAltar() {
1438 if (findExObject("CNDA") == 114 || findExObject("CNDB") == 114) {
1439 // Things on altar
1440 showFirstUse();
1441 _getBack = 1;
1442 return;
1443 }
1444
1445 if (_vars._canMoveAltar == 1) {
1446 // Move altar
1447 _vars._progressPoints++;
1448 showSecondUse();
1449 _vars._watchingTime = 160;
1450 _vars._reelToWatch = 81;
1451 _vars._endWatchReel = 174;
1452 _vars._watchSpeed = 1;
1453 _vars._speedCount = 1;
1454 setupTimedUse(47, 32, 98, 52, 76);
1455 _getBack = 1;
1456 } else {
1457 showPuzText(23, 300);
1458 _getBack = 1;
1459 }
1460 }
1461
withWhat()1462 void DreamWebEngine::withWhat() {
1463 uint8 commandLine[64] = "OBJECT NAME ONE ";
1464
1465 createPanel();
1466 showPanel();
1467 showMan();
1468 showExit();
1469
1470 copyName(_objectType, _command, commandLine);
1471 printMessage2(100, 21, 63, 200, false, 2);
1472 uint16 x = _lastXPos + 5;
1473 printDirect(commandLine, x, 21, 220, false);
1474 printMessage2(_lastXPos + 5, 21, 63, 200, false, 3);
1475
1476 fillRyan();
1477 _commandType = 255;
1478 readMouse();
1479 showPointer();
1480 workToScreen();
1481 delPointer();
1482 _invOpen = 2;
1483 }
1484
notHeldError()1485 void DreamWebEngine::notHeldError() {
1486 createPanel();
1487 showPanel();
1488 showMan();
1489 showExit();
1490 obIcons();
1491 printMessage2(64, 100, 63, 200 + 1, true, 1);
1492 workToScreenM();
1493 hangOnP(50);
1494 putBackObStuff();
1495 }
1496
useCashCard()1497 void DreamWebEngine::useCashCard() {
1498 getRidOfReels();
1499 loadKeypad();
1500 createPanel();
1501 showPanel();
1502 showExit();
1503 showMan();
1504 uint16 y = (!_foreignRelease) ? 120 : 120 - 3;
1505 showFrame(_keypadGraphics, 114, y, 39, 0);
1506 const uint8 *obText = getObTextStart();
1507 findNextColon(&obText);
1508 findNextColon(&obText);
1509 y = 98;
1510 printDirect(&obText, 36, &y, 36, 36 & 1);
1511 char amountStr[10];
1512 sprintf(amountStr, "%04d", _vars._card1Money / 10);
1513 _charShift = 91 * 2 + 75;
1514 printDirect((const uint8 *)amountStr, 160, 155, 240, 240 & 1);
1515 sprintf(amountStr, "%02d", (_vars._card1Money % 10) * 10);
1516 _charShift = 91 * 2 + 85;
1517 printDirect((const uint8 *)amountStr, 187, 155, 240, 240 & 1);
1518 _charShift = 0;
1519 workToScreenM();
1520 hangOnP(400);
1521 _keypadGraphics.clear();
1522 restoreReels();
1523 putBackObStuff();
1524 }
1525
useStereo()1526 void DreamWebEngine::useStereo() {
1527 // Handles the stereo in Ryan's apartment (accessible from the remote on
1528 // the couch)
1529
1530 if (_vars._location != 0) {
1531 showPuzText(4, 400);
1532 putBackObStuff();
1533 } else if (_mapX != 11) {
1534 showPuzText(5, 400);
1535 putBackObStuff();
1536 } else if (checkInside(findSetObject("CDPL"), 1) == kNumexobjects) {
1537 // No CD inside
1538 showPuzText(6, 400);
1539 putBackObStuff();
1540 uint8 dummy;
1541 DynObject *object = (DynObject *)getAnyAd(&dummy, &dummy);
1542 object->turnedOn = 255;
1543 } else {
1544 // CD inside
1545 uint8 dummy;
1546 DynObject *object = (DynObject *)getAnyAd(&dummy, &dummy);
1547 object->turnedOn ^= 1;
1548 if (object->turnedOn != 255)
1549 showPuzText(7, 400); // Stereo off
1550 else
1551 showPuzText(8, 400); // Stereo on
1552
1553 putBackObStuff();
1554 }
1555 }
1556
checkInside(uint16 command,uint16 type)1557 uint16 DreamWebEngine::checkInside(uint16 command, uint16 type) {
1558 for (uint16 index = 0; index < kNumexobjects; index++) {
1559 DynObject *object = getExAd(index);
1560 if (object->mapad[1] == command && object->mapad[0] == type)
1561 return index;
1562 }
1563
1564 return kNumexobjects;
1565 }
1566
showPuzText(uint16 command,uint16 count)1567 void DreamWebEngine::showPuzText(uint16 command, uint16 count) {
1568 createPanel();
1569 showPanel();
1570 showMan();
1571 showExit();
1572 obIcons();
1573 const uint8 *string = (const uint8 *)_puzzleText.getString(command);
1574 printDirect(string, 36, 104, 241, 241 & 1);
1575 workToScreenM();
1576 hangOnP(count);
1577 }
1578
useButtonA()1579 void DreamWebEngine::useButtonA() {
1580 if (!isSetObOnMap(95)) {
1581 showFirstUse();
1582 turnAnyPathOn(0, _roomNum - 1);
1583 removeSetObject(9);
1584 placeSetObject(95);
1585 _vars._watchingTime = 15 * 2;
1586 _vars._reelToWatch = 71;
1587 _vars._endWatchReel = 85;
1588 _vars._watchSpeed = 1;
1589 _vars._speedCount = 1;
1590 _getBack = 1;
1591 _vars._progressPoints++;
1592 } else {
1593 // Done this bit
1594 showSecondUse();
1595 putBackObStuff();
1596 }
1597 }
1598
1599
1600 } // End of namespace DreamWeb
1601