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 "gnap/gnap.h"
24 #include "gnap/gamesys.h"
25 #include "gnap/resource.h"
26 #include "gnap/scenes/group4.h"
27 
28 namespace Gnap {
29 
Scene40(GnapEngine * vm)30 Scene40::Scene40(GnapEngine *vm) : Scene(vm) {
31 }
32 
init()33 int Scene40::init() {
34 	GameSys& gameSys = *_vm->_gameSys;
35 
36 	gameSys.setAnimation(0, 0, 0);
37 	gameSys.setAnimation(0, 0, 1);
38 	return _vm->isFlag(kGFUnk23) ? 0x01 : 0x00;
39 }
40 
updateHotspots()41 void Scene40::updateHotspots() {
42 	_vm->setHotspot(kHS40Platypus, 0, 0, 0, 0, SF_WALKABLE | SF_DISABLED | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
43 	_vm->setHotspot(kHS40ExitCave, 169, 510, 264, 600, SF_EXIT_D_CURSOR, 0, 8);
44 	_vm->setHotspot(kHS40ExitToyStand, 238, 297, 328, 376, SF_EXIT_L_CURSOR, 0, 8);
45 	_vm->setHotspot(kHS40ExitBBQ, 328, 220, 401, 306, SF_EXIT_L_CURSOR, 0, 8);
46 	_vm->setHotspot(kHS40ExitUfo, 421, 215, 501, 282, SF_EXIT_U_CURSOR, 0, 8);
47 	_vm->setHotspot(kHS40ExitKissinBooth, 476, 284, 556, 345, SF_EXIT_R_CURSOR, 0, 8);
48 	_vm->setHotspot(kHS40ExitDancefloor, 317, 455, 445, 600, SF_EXIT_D_CURSOR, 0, 8);
49 	_vm->setHotspot(kHS40ExitShoe, 455, 346, 549, 417, SF_EXIT_D_CURSOR, 0, 8);
50 	_vm->setDeviceHotspot(kHS40Device, -1, -1, -1, -1);
51 	_vm->_hotspotsCount = 9;
52 }
53 
run()54 void Scene40::run() {
55 	PlayerGnap& gnap = *_vm->_gnap;
56 	PlayerPlat& plat = *_vm->_plat;
57 
58 	_vm->queueInsertDeviceIcon();
59 	_vm->endSceneInit();
60 
61 	while (!_vm->_sceneDone) {
62 		if (!_vm->isSoundPlaying(0x1094B))
63 			_vm->playSound(0x1094B, true);
64 
65 		_vm->updateMouseCursor();
66 		_vm->updateCursorByHotspot();
67 
68 		_vm->testWalk(0, 0, -1, -1, -1, -1);
69 
70 		_vm->_sceneClickedHotspot = _vm->getClickedHotspotId();
71 		_vm->updateGrabCursorSprite(0, 0);
72 
73 		switch (_vm->_sceneClickedHotspot) {
74 		case kHS40Device:
75 			_vm->runMenu();
76 			updateHotspots();
77 			break;
78 
79 		case kHS40Platypus:
80 			if (gnap._actionStatus < 0) {
81 				if (_vm->_grabCursorSpriteIndex >= 0) {
82 					gnap.playImpossible(plat._pos);
83 				} else {
84 					switch (_vm->_verbCursor) {
85 					case LOOK_CURSOR:
86 						gnap.playMoan1(plat._pos);
87 						break;
88 					case GRAB_CURSOR:
89 						gnap.kissPlatypus(0);
90 						break;
91 					case TALK_CURSOR:
92 						gnap.playBrainPulsating(plat._pos);
93 						plat.playSequence(plat.getSequenceId());
94 						break;
95 					case PLAT_CURSOR:
96 						gnap.playImpossible(plat._pos);
97 						break;
98 					default:
99 						break;
100 					}
101 				}
102 			}
103 			break;
104 
105 		case kHS40ExitCave:
106 			if (gnap._actionStatus < 0) {
107 				_vm->_newSceneNum = 39;
108 				_vm->_sceneDone = true;
109 			}
110 			break;
111 
112 		case kHS40ExitToyStand:
113 			if (gnap._actionStatus < 0) {
114 				_vm->_newSceneNum = 41;
115 				_vm->_sceneDone = true;
116 			}
117 			break;
118 
119 		case kHS40ExitBBQ:
120 			if (gnap._actionStatus < 0) {
121 				_vm->_newSceneNum = 42;
122 				_vm->_sceneDone = true;
123 			}
124 			break;
125 
126 		case kHS40ExitUfo:
127 			if (gnap._actionStatus < 0) {
128 				_vm->_newSceneNum = 43;
129 				_vm->_sceneDone = true;
130 			}
131 			break;
132 
133 		case kHS40ExitKissinBooth:
134 			if (gnap._actionStatus < 0) {
135 				_vm->_newSceneNum = 44;
136 				_vm->_sceneDone = true;
137 			}
138 			break;
139 
140 		case kHS40ExitDancefloor:
141 			if (gnap._actionStatus < 0) {
142 				_vm->_newSceneNum = 45;
143 				_vm->_sceneDone = true;
144 			}
145 			break;
146 
147 		case kHS40ExitShoe:
148 			if (gnap._actionStatus < 0) {
149 				_vm->_newSceneNum = 46;
150 				_vm->_sceneDone = true;
151 			}
152 			break;
153 
154 		default:
155 			if (_vm->_mouseClickState._left && gnap._actionStatus < 0)
156 				_vm->_mouseClickState._left = false;
157 			break;
158 
159 		}
160 
161 		updateAnimations();
162 		_vm->checkGameKeys();
163 
164 		if (_vm->isKeyStatus1(Common::KEYCODE_BACKSPACE)) {
165 			_vm->clearKeyStatus1(Common::KEYCODE_BACKSPACE);
166 			_vm->runMenu();
167 			updateHotspots();
168 		}
169 
170 		_vm->gameUpdateTick();
171 	}
172 }
173 
updateAnimations()174 void Scene40::updateAnimations() {
175 	GameSys& gameSys = *_vm->_gameSys;
176 	PlayerGnap& gnap = *_vm->_gnap;
177 
178 	if (gameSys.getAnimationStatus(0) == 2) {
179 		gameSys.setAnimation(0, 0, 0);
180 		if (gnap._actionStatus)
181 			gnap._actionStatus = -1;
182 		else
183 			_vm->_sceneDone = true;
184 	}
185 }
186 
187 /*****************************************************************************/
188 
Scene41(GnapEngine * vm)189 Scene41::Scene41(GnapEngine *vm) : Scene(vm) {
190 	_currKidSequenceId = -1;
191 	_nextKidSequenceId = -1;
192 	_currToyVendorSequenceId = -1;
193 	_nextToyVendorSequenceId = -1;
194 }
195 
init()196 int Scene41::init() {
197 	GameSys& gameSys = *_vm->_gameSys;
198 
199 	gameSys.setAnimation(0, 0, 0);
200 	gameSys.setAnimation(0, 0, 1);
201 	gameSys.setAnimation(0, 0, 2);
202 	return 0x129;
203 }
204 
updateHotspots()205 void Scene41::updateHotspots() {
206 	if (_vm->isFlag(kGFGnapControlsToyUFO)) {
207 		_vm->setHotspot(kHS41Platypus, 0, 0, 0, 0, SF_DISABLED);
208 		_vm->setHotspot(kHS41UfoExitLeft, 0, 0, 10, 500, SF_EXIT_L_CURSOR | SF_DISABLED);
209 		_vm->setHotspot(kHS41UfoExitRight, 790, 0, 799, 500, SF_EXIT_R_CURSOR);
210 		_vm->setHotspot(kHS41UfoWalkArea1, 0, 0, 800, 470, SF_DISABLED);
211 		_vm->setDeviceHotspot(kHS41UfoDevice, -1, -1, -1, -1);
212 		_vm->_hotspotsCount = 5;
213 	} else {
214 		_vm->setHotspot(kHS41Platypus, 0, 0, 0, 0, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
215 		_vm->setHotspot(kHS41ExitCave, 150, 590, 650, 600, SF_EXIT_D_CURSOR | SF_WALKABLE, 5, 9);
216 		_vm->setHotspot(kHS41Exit, 0, 100, 10, 599, SF_EXIT_L_CURSOR | SF_DISABLED, 0, 8);
217 		_vm->setHotspot(kHS41ExitBBQ, 790, 100, 799, 599, SF_EXIT_R_CURSOR | SF_WALKABLE, 10, 8);
218 		_vm->setHotspot(kHS41ToyVendor, 320, 150, 430, 310, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
219 		_vm->setHotspot(kHS41Kid, 615, 340, 710, 460, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
220 		_vm->setHotspot(kHS41ToyUfo, 0, 0, 0, 0, SF_GRAB_CURSOR);
221 		_vm->setHotspot(kHS41WalkArea1, 0, 0, 800, 470);
222 		_vm->setDeviceHotspot(kHS41Device, -1, -1, -1, -1);
223 		_vm->_hotspotsCount = 9;
224 	}
225 }
226 
run()227 void Scene41::run() {
228 	GameSys& gameSys = *_vm->_gameSys;
229 	PlayerGnap& gnap = *_vm->_gnap;
230 	PlayerPlat& plat = *_vm->_plat;
231 
232 	_vm->queueInsertDeviceIcon();
233 
234 	if (_vm->isFlag(kGFGnapControlsToyUFO)) {
235 		_vm->_toyUfoX = 770;
236 		if (_vm->_toyUfoY < 0 || _vm->_toyUfoY > 300)
237 			_vm->_toyUfoY = 150;
238 		if (!_vm->_timers[9])
239 			gnap._actionStatus = kAS41GiveBackToyUfo;
240 	} else {
241 		if (!_vm->isFlag(kGFUnk16) && !_vm->isFlag(kGFJointTaken) && !_vm->isFlag(kGFUnk18) && !_vm->isFlag(kGFGroceryStoreHatTaken))
242 			_vm->toyUfoSetStatus(kGFUnk16);
243 		_vm->_toyUfoX = 600;
244 		_vm->_toyUfoY = 200;
245 	}
246 
247 	_vm->_toyUfoId = 0;
248 	_vm->_toyUfoActionStatus = -1;
249 	_vm->_toyUfoSequenceId = _vm->toyUfoGetSequenceId();
250 	_vm->_toyUfoNextSequenceId = _vm->_toyUfoSequenceId;
251 
252 	gameSys.setAnimation(_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId, 2);
253 	gameSys.insertSequence(_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId, 0, 0, kSeqNone, 0, _vm->_toyUfoX - 274, _vm->_toyUfoY - 128);
254 	gameSys.insertSequence(0x128, 0, 0, 0, kSeqLoop, 0, 0, 0);
255 
256 	if (_vm->isFlag(kGFGnapControlsToyUFO))
257 		_currKidSequenceId = 0x11B;
258 	else
259 		_currKidSequenceId = 0x11D;
260 
261 	_nextKidSequenceId = -1;
262 
263 	gameSys.setAnimation(_currKidSequenceId, 1, 4);
264 	gameSys.insertSequence(_currKidSequenceId, 1, 0, 0, kSeqNone, 0, 0, 0);
265 
266 	_currToyVendorSequenceId = 0x118;
267 	_nextToyVendorSequenceId = -1;
268 
269 	gameSys.setAnimation(0x118, 1, 3);
270 	gameSys.insertSequence(_currToyVendorSequenceId, 1, 0, 0, kSeqNone, 0, 0, 0);
271 	gameSys.insertSequence(0x127, 2, 0, 0, kSeqNone, 0, 0, 0);
272 
273 	if (_vm->isFlag(kGFGnapControlsToyUFO)) {
274 		gnap._sequenceId = 0x120;
275 		gnap._sequenceDatNum = 0;
276 		gnap._idleFacing = kDirUpRight;
277 		gnap._pos = Common::Point(7, 7);
278 		gnap._id = 140;
279 		gameSys.insertSequence(0x120, 140, 0, 0, kSeqNone, 0, 0, 0);
280 		gameSys.setAnimation(makeRid(gnap._sequenceDatNum, gnap._sequenceId), gnap._id, 0);
281 		plat.initPos(8, 10, kDirBottomLeft);
282 		_vm->endSceneInit();
283 	} else if (_vm->_prevSceneNum == 45) {
284 		gnap.initPos(-1, 8, kDirUpRight);
285 		plat.initPos(-2, 8, kDirUpLeft);
286 		_vm->endSceneInit();
287 		plat.walkTo(Common::Point(1, 8), -1, 0x107C2, 1);
288 		gnap.walkTo(Common::Point(2, 8), -1, 0x107B9, 1);
289 	} else if (_vm->_prevSceneNum == 42) {
290 		gnap.initPos(11, 8, kDirUpRight);
291 		plat.initPos(11, 9, kDirUpLeft);
292 		_vm->endSceneInit();
293 		gnap.walkTo(Common::Point(8, 8), -1, 0x107BA, 1);
294 		plat.walkTo(Common::Point(9, 8), -1, 0x107D2, 1);
295 	} else {
296 		gnap.initPos(5, 8, kDirBottomRight);
297 		plat.initPos(6, 8, kDirBottomLeft);
298 		_vm->endSceneInit();
299 	}
300 
301 	_vm->_timers[4] = _vm->getRandom(100) + 100;
302 	_vm->_timers[5] = _vm->getRandom(30) + 20;
303 
304 	while (!_vm->_sceneDone) {
305 		if (!_vm->isSoundPlaying(0x1094B))
306 			_vm->playSound(0x1094B, true);
307 
308 		if (!_vm->isFlag(kGFGnapControlsToyUFO))
309 			_vm->_hotspots[kHS41ToyUfo]._rect = Common::Rect(_vm->_toyUfoX - 25, _vm->_toyUfoY - 20, _vm->_toyUfoX + 25, _vm->_toyUfoY + 20);
310 
311 		_vm->updateMouseCursor();
312 		_vm->updateCursorByHotspot();
313 
314 		_vm->testWalk(0, 0, -1, -1, -1, -1);
315 
316 		_vm->_sceneClickedHotspot = _vm->getClickedHotspotId();
317 		_vm->updateGrabCursorSprite(0, 0);
318 
319 		if (_vm->isFlag(kGFGnapControlsToyUFO)) {
320 			switch (_vm->_sceneClickedHotspot) {
321 			case kHS41UfoExitLeft:
322 				if (_vm->_toyUfoActionStatus < 0) {
323 					_vm->_isLeavingScene = true;
324 					_vm->_toyUfoActionStatus = kAS41ToyUfoLeaveScene;
325 					_vm->_newSceneNum = 45;
326 					_vm->toyUfoFlyTo(-35, -1, -35, 799, 0, 300, 2);
327 				}
328 				break;
329 
330 			case kHS41UfoExitRight:
331 				if (_vm->_toyUfoActionStatus < 0) {
332 					_vm->_isLeavingScene = true;
333 					_vm->_toyUfoActionStatus = kAS41ToyUfoLeaveScene;
334 					_vm->_newSceneNum = 42;
335 					_vm->toyUfoFlyTo(835, -1, 0, 835, 0, 300, 2);
336 				}
337 				break;
338 
339 			case kHS41UfoDevice:
340 				_vm->runMenu();
341 				updateHotspots();
342 				_vm->_timers[4] = _vm->getRandom(100) + 100;
343 				_vm->_timers[5] = _vm->getRandom(30) + 20;
344 				break;
345 
346 			default:
347 				break;
348 			}
349 		} else {
350 			switch (_vm->_sceneClickedHotspot) {
351 			case kHS41Device:
352 				_vm->runMenu();
353 				updateHotspots();
354 				_vm->_timers[4] = _vm->getRandom(100) + 100;
355 				_vm->_timers[5] = _vm->getRandom(30) + 20;
356 				break;
357 
358 			case kHS41Platypus:
359 				if (gnap._actionStatus < 0) {
360 					if (_vm->_grabCursorSpriteIndex >= 0) {
361 						gnap.playImpossible(plat._pos);
362 					} else {
363 						switch (_vm->_verbCursor) {
364 						case LOOK_CURSOR:
365 							gnap.playMoan1(plat._pos);
366 							break;
367 						case GRAB_CURSOR:
368 							gnap.kissPlatypus(0);
369 							break;
370 						case TALK_CURSOR:
371 							gnap.playBrainPulsating(plat._pos);
372 							plat.playSequence(plat.getSequenceId());
373 							break;
374 						case PLAT_CURSOR:
375 							gnap.playImpossible(plat._pos);
376 							break;
377 						default:
378 							break;
379 						}
380 					}
381 				}
382 				break;
383 
384 			case kHS41ExitCave:
385 				_vm->_isLeavingScene = true;
386 				gnap.walkTo(_vm->_hotspotsWalkPos[kHS41ExitCave], 0, 0x107AE, 1);
387 				gnap._actionStatus = kAS41LeaveScene;
388 				_vm->_newSceneNum = 40;
389 				break;
390 
391 			case kHS41Exit:
392 				_vm->_isLeavingScene = true;
393 				gnap.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS41Exit].x, -1), 0, 0x107AF, 1);
394 				gnap._actionStatus = kAS41LeaveScene;
395 				plat.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS41Exit].x, -1), -1, 0x107CF, 1);
396 				_vm->_newSceneNum = 45;
397 				break;
398 
399 			case kHS41ExitBBQ:
400 				_vm->_isLeavingScene = true;
401 				gnap.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS41ExitBBQ].x, -1), 0, 0x107AB, 1);
402 				gnap._actionStatus = kAS41LeaveScene;
403 				plat.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS41ExitBBQ].x, -1), -1, 0x107CD, 1);
404 				_vm->_newSceneNum = 42;
405 				break;
406 
407 			case kHS41ToyVendor:
408 				if (_vm->_grabCursorSpriteIndex == kItemDiceQuarterHole) {
409 					gnap._actionStatus = kAS41UseQuarterWithToyVendor;
410 					gnap.walkTo(Common::Point(4, 7), 0, 0x107BB, 9);
411 					gnap.playShowItem(_vm->_grabCursorSpriteIndex, 5, 0);
412 				} else if (_vm->_grabCursorSpriteIndex >= 0) {
413 					gnap.playShowCurrItem(Common::Point(4, 7), 5, 0);
414 				} else {
415 					switch (_vm->_verbCursor) {
416 					case LOOK_CURSOR:
417 						gnap.playMoan1(Common::Point(5, 0));
418 						break;
419 					case GRAB_CURSOR:
420 						gnap.playImpossible();
421 						break;
422 					case TALK_CURSOR:
423 						gnap._idleFacing = kDirUpRight;
424 						gnap.walkTo(Common::Point(4, 7), 0, gnap.getSequenceId(kGSBrainPulsating, Common::Point(0, 0)) | 0x10000, 1);
425 						gnap._actionStatus = kAS41TalkToyVendor;
426 						break;
427 					case PLAT_CURSOR:
428 						gnap.playImpossible();
429 						break;
430 					default:
431 						break;
432 					}
433 				}
434 				break;
435 
436 			case kHS41Kid:
437 				if (_vm->_grabCursorSpriteIndex == kItemChickenBucket) {
438 					gnap.walkTo(Common::Point(7, 7), 0, 0x107BB, 1);
439 					gnap._idleFacing = kDirUpRight;
440 					gnap._actionStatus = kAS41UseChickenBucketWithKid;
441 				} else if (_vm->_grabCursorSpriteIndex >= 0) {
442 					gnap.playShowCurrItem(Common::Point(7, 7), 8, 0);
443 				} else {
444 					switch (_vm->_verbCursor) {
445 					case LOOK_CURSOR:
446 						gnap.playScratchingHead(Common::Point(9, 0));
447 						break;
448 					case GRAB_CURSOR:
449 						gnap.walkTo(Common::Point(7, 7), 0, 0x107BB, 1);
450 						gnap._idleFacing = kDirUpRight;
451 						gnap._actionStatus = kAS41GrabKid;
452 						break;
453 					case TALK_CURSOR:
454 						gnap._idleFacing = kDirUpRight;
455 						gnap.walkTo(Common::Point(7, 7), 0, gnap.getSequenceId(kGSBrainPulsating, Common::Point(0, 0)) | 0x10000, 1);
456 						break;
457 					case PLAT_CURSOR:
458 						gnap.playImpossible();
459 						break;
460 					default:
461 						break;
462 					}
463 				}
464 				break;
465 
466 			case kHS41ToyUfo:
467 				if (_vm->_grabCursorSpriteIndex == kItemGum) {
468 					gnap.playPullOutDevice(Common::Point(9, 0));
469 					gameSys.setAnimation(makeRid(gnap._sequenceDatNum, gnap._sequenceId), gnap._id, 0);
470 					gnap._actionStatus = kAS41UseGumWithToyUfo;
471 				}
472 				break;
473 
474 			case kHS41WalkArea1:
475 				if (gnap._actionStatus < 0)
476 					gnap.walkTo(Common::Point(-1, -1), -1, -1, 1);
477 				break;
478 
479 			default:
480 				break;
481 			}
482 		}
483 
484 		if (_vm->isFlag(kGFGnapControlsToyUFO)) {
485 			if (!_vm->_timers[9] && gnap._actionStatus < 0) {
486 				gnap._actionStatus = kAS41GiveBackToyUfo;
487 				if (gnap._sequenceId == 0x121 || gnap._sequenceId == 0x122) {
488 					gameSys.insertSequence(0x123, gnap._id, makeRid(gnap._sequenceDatNum, gnap._sequenceId), gnap._id, kSeqSyncWait, 0, 0, 0);
489 					gnap._sequenceId = 0x123;
490 					gnap._sequenceDatNum = 0;
491 					gameSys.setAnimation(0x123, gnap._id, 0);
492 				}
493 			}
494 		}
495 
496 		if (_vm->_mouseClickState._left && gnap._actionStatus < 0) {
497 			_vm->_mouseClickState._left = false;
498 			if (_vm->isFlag(kGFGnapControlsToyUFO)) {
499 				int sequenceId;
500 				if (_vm->_leftClickMouseX >= 400) {
501 					if (gnap._sequenceId == 0x11F || gnap._sequenceId == 0x120 || gnap._sequenceId == 0x123 || gnap._sequenceId == 0x126)
502 						sequenceId = 0x120;
503 					else if (_vm->_leftClickMouseX - _vm->_toyUfoX >= 400)
504 						sequenceId = 0x126;
505 					else
506 						sequenceId = 0x123;
507 				} else {
508 					if (gnap._sequenceId == 0x121 || gnap._sequenceId == 0x125 || gnap._sequenceId == 0x122)
509 						sequenceId = 0x122;
510 					else if (_vm->_toyUfoX - _vm->_leftClickMouseX >= 400)
511 						sequenceId = 0x125;
512 					else
513 						sequenceId = 0x121;
514 				}
515 				gameSys.insertSequence(sequenceId, gnap._id, makeRid(gnap._sequenceDatNum, gnap._sequenceId), gnap._id, kSeqSyncWait, 0, 0, 0);
516 				gnap._sequenceId = sequenceId;
517 				gnap._sequenceDatNum = 0;
518 				gameSys.setAnimation(sequenceId, gnap._id, 0);
519 				_vm->_toyUfoActionStatus = kAS41ToyUfoRefresh;
520 				_vm->toyUfoFlyTo(-1, -1, 0, 799, 0, 300, 2);
521 			} else {
522 				gnap.walkTo(Common::Point(-1, -1), -1, -1, 1);
523 			}
524 		}
525 
526 		updateAnimations();
527 
528 		if (!_vm->_isLeavingScene) {
529 			if (plat._actionStatus < 0)
530 				plat.updateIdleSequence();
531 			if (gnap._actionStatus < 0 && !_vm->isFlag(kGFGnapControlsToyUFO))
532 				gnap.updateIdleSequence();
533 			if (!_vm->_timers[4]) {
534 				_vm->_timers[4] = _vm->getRandom(100) + 100;
535 				if (gnap._actionStatus < 0 && plat._actionStatus < 0 && _vm->_toyUfoActionStatus == -1 && _nextToyVendorSequenceId == -1) {
536 					switch (_vm->getRandom(3)) {
537 					case 0:
538 						_nextToyVendorSequenceId = 0x113;
539 						break;
540 					case 1:
541 						_nextToyVendorSequenceId = 0x117;
542 						break;
543 					case 2:
544 						_nextToyVendorSequenceId = 0x119;
545 						break;
546 					default:
547 						break;
548 					}
549 					if (_nextToyVendorSequenceId == _currToyVendorSequenceId)
550 						_nextToyVendorSequenceId = -1;
551 				}
552 			}
553 			if (!_vm->_timers[5]) {
554 				_vm->_timers[5] = _vm->getRandom(30) + 20;
555 				if (gnap._actionStatus < 0 && plat._actionStatus < 0 && _vm->_toyUfoActionStatus == -1 && _nextKidSequenceId == -1) {
556 					if (_vm->isFlag(kGFGnapControlsToyUFO))
557 						_nextKidSequenceId = 0x11B;
558 					else if (_vm->getRandom(3) != 0)
559 						_nextKidSequenceId = 0x11D;
560 					else
561 						_nextKidSequenceId = 0x11E;
562 				}
563 			}
564 		}
565 
566 		_vm->checkGameKeys();
567 
568 		if (_vm->isKeyStatus1(Common::KEYCODE_BACKSPACE)) {
569 			_vm->clearKeyStatus1(Common::KEYCODE_BACKSPACE);
570 			_vm->runMenu();
571 			updateHotspots();
572 			_vm->_timers[4] = _vm->getRandom(100) + 100;
573 			_vm->_timers[5] = _vm->getRandom(30) + 20;
574 		}
575 		_vm->gameUpdateTick();
576 	}
577 }
578 
updateAnimations()579 void Scene41::updateAnimations() {
580 	GameSys& gameSys = *_vm->_gameSys;
581 	PlayerGnap& gnap = *_vm->_gnap;
582 
583 	if (gameSys.getAnimationStatus(0) == 2) {
584 		switch (gnap._actionStatus) {
585 		case kAS41LeaveScene:
586 			gameSys.setAnimation(0, 0, 0);
587 			_vm->_sceneDone = true;
588 			gnap._actionStatus = -1;
589 			break;
590 		case kAS41UseQuarterWithToyVendor:
591 			gameSys.setAnimation(0, 0, 0);
592 			_nextToyVendorSequenceId = 0x114;
593 			gnap._actionStatus = -1;
594 			break;
595 		case kAS41TalkToyVendor:
596 			gameSys.setAnimation(0, 0, 0);
597 			_nextToyVendorSequenceId = 0x116;
598 			gnap._actionStatus = -1;
599 			break;
600 		case kAS41UseGumWithToyUfo:
601 			gameSys.setAnimation(0, 0, 0);
602 			gnap.playUseDevice(Common::Point(9, 0));
603 			gnap._actionStatus = -1;
604 			_vm->setGrabCursorSprite(-1);
605 			_vm->invRemove(kItemGum);
606 			_vm->_toyUfoActionStatus = kAS41UfoGumAttached;
607 			break;
608 		case kAS41UseChickenBucketWithKid:
609 			if (gameSys.getAnimationStatus(4) == 2) {
610 				_vm->_timers[2] = _vm->getRandom(30) + 20;
611 				_vm->_timers[3] = _vm->getRandom(50) + 200;
612 				_vm->setGrabCursorSprite(-1);
613 				gameSys.insertSequence(0x11F, gnap._id, makeRid(gnap._sequenceDatNum, gnap._sequenceId), gnap._id, kSeqSyncWait, 0, 0, 0);
614 				gnap._sequenceId = 0x11F;
615 				gnap._sequenceDatNum = 0;
616 				gameSys.setAnimation(0x11F, gnap._id, 0);
617 				_nextKidSequenceId = 0x11A;
618 				gameSys.insertSequence(0x11A, 1, _currKidSequenceId, 1, kSeqSyncWait, 0, 0, 0);
619 				gameSys.setAnimation(_nextKidSequenceId, 1, 4);
620 				_currKidSequenceId = _nextKidSequenceId;
621 				_nextKidSequenceId = 0x11B;
622 				_vm->_timers[5] = _vm->getRandom(30) + 20;
623 				gnap._actionStatus = -1;
624 				_vm->setFlag(kGFGnapControlsToyUFO);
625 				updateHotspots();
626 				_vm->_timers[9] = 600;
627 			}
628 			break;
629 		case kAS41GrabKid:
630 			if (gameSys.getAnimationStatus(3) == 2 && gameSys.getAnimationStatus(4) == 2) {
631 				_vm->_timers[2] = _vm->getRandom(30) + 20;
632 				_vm->_timers[3] = _vm->getRandom(50) + 200;
633 				gameSys.insertSequence(0x110, gnap._id, makeRid(gnap._sequenceDatNum, gnap._sequenceId), gnap._id, kSeqSyncWait, 0, 0, 0);
634 				gnap._sequenceId = 0x110;
635 				gnap._sequenceDatNum = 0;
636 				gameSys.setAnimation(0x110, gnap._id, 0);
637 				_nextToyVendorSequenceId = 0x111;
638 				gameSys.insertSequence(0x111, 1, _currToyVendorSequenceId, 1, kSeqSyncWait, 0, 0, 0);
639 				gameSys.setAnimation(_nextToyVendorSequenceId, 1, 3);
640 				_currToyVendorSequenceId = _nextToyVendorSequenceId;
641 				_nextToyVendorSequenceId = -1;
642 				_vm->_timers[4] = _vm->getRandom(100) + 100;
643 				_nextKidSequenceId = 0x10F;
644 				gameSys.insertSequence(0x10F, 1, _currKidSequenceId, 1, kSeqSyncWait, 0, 0, 0);
645 				gameSys.setAnimation(_nextKidSequenceId, 1, 4);
646 				_currKidSequenceId = _nextKidSequenceId;
647 				_nextKidSequenceId = -1;
648 				_vm->_timers[5] = _vm->getRandom(30) + 20;
649 				gnap._actionStatus = -1;
650 			}
651 			break;
652 		case kAS41GiveBackToyUfo:
653 			if (gameSys.getAnimationStatus(3) == 2 && gameSys.getAnimationStatus(4) == 2) {
654 				_vm->_timers[2] = _vm->getRandom(30) + 20;
655 				_vm->_timers[3] = _vm->getRandom(50) + 200;
656 				gameSys.insertSequence(0x124, gnap._id,
657 					makeRid(gnap._sequenceDatNum, gnap._sequenceId), gnap._id,
658 					kSeqSyncWait, 0, 0, 0);
659 				gnap._sequenceId = 0x124;
660 				gnap._sequenceDatNum = 0;
661 				gameSys.setAnimation(0x124, gnap._id, 0);
662 				_nextToyVendorSequenceId = 0x112;
663 				gameSys.insertSequence(0x112, 1, _currToyVendorSequenceId, 1, kSeqSyncWait, 0, 0, 0);
664 				gameSys.setAnimation(_nextToyVendorSequenceId, 1, 3);
665 				_currToyVendorSequenceId = _nextToyVendorSequenceId;
666 				_nextToyVendorSequenceId = -1;
667 				_vm->_timers[4] = _vm->getRandom(100) + 100;
668 				_nextKidSequenceId = 0x11C;
669 				gameSys.insertSequence(0x11C, 1, _currKidSequenceId, 1, kSeqSyncWait, 0, 0, 0);
670 				gameSys.setAnimation(_nextKidSequenceId, 1, 4);
671 				_currKidSequenceId = _nextKidSequenceId;
672 				_nextKidSequenceId = -1;
673 				_vm->_timers[5] = _vm->getRandom(30) + 20;
674 				gnap._actionStatus = -1;
675 				_vm->clearFlag(kGFGnapControlsToyUFO);
676 				updateHotspots();
677 			}
678 			break;
679 		default:
680 			break;
681 		}
682 	}
683 
684 	if (gameSys.getAnimationStatus(2) == 2) {
685 		switch (_vm->_toyUfoActionStatus) {
686 		case kAS41ToyUfoLeaveScene:
687 			_vm->_sceneDone = true;
688 			break;
689 		case kAS41UfoGumAttached:
690 			_vm->_toyUfoNextSequenceId = 0x873;
691 			gameSys.insertSequence(0x10873, _vm->_toyUfoId, _vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId,
692 				kSeqSyncWait, 0, _vm->_toyUfoX - 365, _vm->_toyUfoY - 128);
693 			_vm->_toyUfoSequenceId = _vm->_toyUfoNextSequenceId;
694 			gameSys.setAnimation(_vm->_toyUfoNextSequenceId | 0x10000, _vm->_toyUfoId, 2);
695 			_vm->toyUfoSetStatus(kGFJointTaken);
696 			break;
697 		default:
698 			_vm->_toyUfoNextSequenceId = _vm->toyUfoGetSequenceId();
699 			gameSys.insertSequence(_vm->_toyUfoNextSequenceId | 0x10000, _vm->_toyUfoId + 1, _vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId,
700 				kSeqSyncWait, 0, _vm->_toyUfoX - 274, _vm->_toyUfoY - 128);
701 			_vm->_toyUfoSequenceId = _vm->_toyUfoNextSequenceId;
702 			++_vm->_toyUfoId;
703 			gameSys.setAnimation(_vm->_toyUfoNextSequenceId | 0x10000, _vm->_toyUfoId, 2);
704 			break;
705 		}
706 		_vm->_toyUfoActionStatus = -1;
707 	}
708 
709 	if (gameSys.getAnimationStatus(3) == 2 && _nextToyVendorSequenceId != -1) {
710 		gameSys.insertSequence(_nextToyVendorSequenceId, 1, _currToyVendorSequenceId, 1, kSeqSyncWait, 0, 0, 0);
711 		gameSys.setAnimation(_nextToyVendorSequenceId, 1, 3);
712 		_currToyVendorSequenceId = _nextToyVendorSequenceId;
713 		_nextToyVendorSequenceId = -1;
714 		_vm->_timers[4] = _vm->getRandom(100) + 100;
715 	}
716 
717 	if (gameSys.getAnimationStatus(4) == 2 && _nextKidSequenceId != -1) {
718 		gameSys.insertSequence(_nextKidSequenceId, 1, _currKidSequenceId, 1, kSeqSyncWait, 0, 0, 0);
719 		gameSys.setAnimation(_nextKidSequenceId, 1, 4);
720 		_currKidSequenceId = _nextKidSequenceId;
721 		_nextKidSequenceId = -1;
722 		_vm->_timers[5] = _vm->getRandom(30) + 20;
723 		if (_currKidSequenceId == 0x11E) {
724 			_vm->_toyUfoActionStatus = kAS41ToyUfoRefresh;
725 			_vm->toyUfoFlyTo(_vm->getRandom(300) + 500, _vm->getRandom(225) + 75, 0, 799, 0, 300, 2);
726 		}
727 	}
728 }
729 
730 /*****************************************************************************/
731 
Scene42(GnapEngine * vm)732 Scene42::Scene42(GnapEngine *vm) : Scene(vm) {
733 	_currBBQVendorSequenceId = -1;
734 	_nextBBQVendorSequenceId = -1;
735 }
736 
init()737 int Scene42::init() {
738 	GameSys& gameSys = *_vm->_gameSys;
739 
740 	gameSys.setAnimation(0, 0, 0);
741 	gameSys.setAnimation(0, 0, 1);
742 	gameSys.setAnimation(0, 0, 2);
743 	if (_vm->isFlag(kGFPictureTaken) || (_vm->isFlag(kGFUnk18) && _vm->isFlag(kGFUnk23)))
744 		return 0x153;
745 	return 0x152;
746 }
747 
updateHotspots()748 void Scene42::updateHotspots() {
749 	if (_vm->isFlag(kGFGnapControlsToyUFO)) {
750 		_vm->setHotspot(kHS42Platypus, 0, 0, 0, 0, SF_DISABLED);
751 		_vm->setHotspot(kHS42UfoExitLeft, 0, 0, 10, 599, SF_EXIT_L_CURSOR);
752 		_vm->setHotspot(kHS42UfoExitRight, 790, 0, 799, 599, SF_EXIT_R_CURSOR);
753 		_vm->setHotspot(kHS42UfoHotSauce, 335, 110, 440, 175, SF_DISABLED);
754 		_vm->setDeviceHotspot(kHS42UfoDevice, -1, 534, -1, 599);
755 		if ((_vm->isFlag(kGFPictureTaken) || _vm->isFlag(kGFUnk18)) && _vm->isFlag(kGFUnk23) && !_vm->isFlag(kGFUnk24))
756 			_vm->_hotspots[kHS42UfoHotSauce]._flags = SF_GRAB_CURSOR;
757 		_vm->_hotspotsCount = 5;
758 	} else {
759 		_vm->setHotspot(kHS42Platypus, 0, 0, 0, 0, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
760 		_vm->setHotspot(kHS42ExitUfoParty, 150, 585, 650, 600, SF_EXIT_D_CURSOR | SF_WALKABLE, 5, 9);
761 		_vm->setHotspot(kHS42ExitToyStand, 0, 100, 10, 599, SF_EXIT_L_CURSOR, 0, 8);
762 		_vm->setHotspot(kHS42ExitUfo, 790, 100, 799, 599, SF_EXIT_R_CURSOR, 10, 8);
763 		_vm->setHotspot(kHS42BBQVendor, 410, 200, 520, 365, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 4, 8);
764 		_vm->setHotspot(kHS42ChickenLeg, 530, 340, 620, 430, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 8, 7);
765 		_vm->setHotspot(kHS42WalkArea1, 0, 0, 800, 445);
766 		_vm->setHotspot(kHS42WalkArea2, 240, 0, 550, 495);
767 		_vm->setDeviceHotspot(kHS42Device, -1, -1, -1, -1);
768 		_vm->_hotspotsCount = 9;
769 	}
770 }
771 
run()772 void Scene42::run() {
773 	GameSys& gameSys = *_vm->_gameSys;
774 	PlayerGnap& gnap = *_vm->_gnap;
775 	PlayerPlat& plat = *_vm->_plat;
776 
777 	_vm->queueInsertDeviceIcon();
778 
779 	_currBBQVendorSequenceId = 0x14A;
780 	_nextBBQVendorSequenceId = -1;
781 
782 	gameSys.setAnimation(0x14A, 1, 2);
783 	gameSys.insertSequence(_currBBQVendorSequenceId, 1, 0, 0, kSeqNone, 0, 0, 0);
784 
785 	if (_vm->isFlag(kGFGnapControlsToyUFO)) {
786 		_vm->_toyUfoId = 0;
787 		_vm->_toyUfoActionStatus = -1;
788 		if (_vm->_prevSceneNum == 43 && _vm->isFlag(kGFUnk18)) {
789 			_vm->_toyUfoSequenceId = 0x872;
790 			_vm->_toyUfoNextSequenceId = _vm->toyUfoGetSequenceId();
791 			gameSys.insertSequence(_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId, 0, 0, kSeqNone, 0, 0, 0);
792 			_vm->_toyUfoX = 317;
793 			_vm->_toyUfoY = 61;
794 			_vm->toyUfoSetStatus(kGFJointTaken);
795 			_vm->setFlag(kGFPictureTaken);
796 			_vm->_timers[9] = 600;
797 		} else {
798 			_vm->_toyUfoSequenceId = _vm->toyUfoGetSequenceId();
799 			_vm->_toyUfoNextSequenceId = _vm->_toyUfoSequenceId;
800 			if (_vm->_prevSceneNum == 41)
801 				_vm->_toyUfoX = 30;
802 			else
803 				_vm->_toyUfoX = 770;
804 			gameSys.insertSequence(_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId, 0, 0, kSeqNone, 0, _vm->_toyUfoX - 274, _vm->_toyUfoY - 128);
805 		}
806 		gameSys.setAnimation(_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId, 3);
807 		_vm->endSceneInit();
808 		if (_vm->_toyUfoSequenceId == 0x872)
809 			_vm->setGrabCursorSprite(-1);
810 	} else if (_vm->_prevSceneNum == 41) {
811 		gnap.initPos(-1, 8, kDirUpRight);
812 		plat.initPos(-1, 9, kDirUpLeft);
813 		_vm->endSceneInit();
814 		gnap.walkTo(Common::Point(2, 8), -1, 0x107B9, 1);
815 		plat.walkTo(Common::Point(1, 8), -1, 0x107C2, 1);
816 	} else if (_vm->_prevSceneNum == 43) {
817 		gnap.initPos(11, 8, kDirUpRight);
818 		plat.initPos(11, 9, kDirUpLeft);
819 		_vm->endSceneInit();
820 		gnap.walkTo(Common::Point(8, 8), -1, 0x107BA, 1);
821 		plat.walkTo(Common::Point(9, 8), -1, 0x107D2, 1);
822 	} else {
823 		gnap.initPos(5, 11, kDirUpRight);
824 		plat.initPos(6, 11, kDirUpLeft);
825 		_vm->endSceneInit();
826 		gnap.walkTo(Common::Point(5, 8), -1, 0x107BA, 1);
827 		plat.walkTo(Common::Point(6, 8), -1, 0x107C2, 1);
828 	}
829 
830 	while (!_vm->_sceneDone) {
831 		if (!_vm->isSoundPlaying(0x1094B))
832 			_vm->playSound(0x1094B, true);
833 
834 		_vm->updateMouseCursor();
835 		_vm->updateCursorByHotspot();
836 
837 		_vm->testWalk(0, 0, -1, -1, -1, -1);
838 
839 		_vm->_sceneClickedHotspot = _vm->getClickedHotspotId();
840 		_vm->updateGrabCursorSprite(0, 0);
841 
842 		if (_vm->isFlag(kGFGnapControlsToyUFO)) {
843 			switch (_vm->_sceneClickedHotspot) {
844 			case kHS42UfoExitLeft:
845 				if (_vm->_toyUfoActionStatus < 0) {
846 					_vm->_isLeavingScene = true;
847 					_vm->_toyUfoActionStatus = kAS42ToyUfoLeaveScene;
848 					_vm->_newSceneNum = 41;
849 					_vm->toyUfoFlyTo(-35, -1, -35, 799, 0, 300, 3);
850 				}
851 				break;
852 
853 			case kHS42UfoExitRight:
854 				if (_vm->_toyUfoActionStatus < 0) {
855 					_vm->_isLeavingScene = true;
856 					_vm->_toyUfoActionStatus = kAS42ToyUfoLeaveScene;
857 					_vm->_newSceneNum = 43;
858 					_vm->toyUfoFlyTo(835, -1, 0, 835, 0, 300, 3);
859 				}
860 				break;
861 
862 			case kHS42UfoHotSauce:
863 				if (_vm->isFlag(kGFJointTaken)) {
864 					_vm->_toyUfoActionStatus = kAS42ToyUfoPickUpHotSauce;
865 					_vm->toyUfoFlyTo(384, 77, 0, 799, 0, 300, 3);
866 					_vm->_timers[9] = 600;
867 				} else {
868 					_vm->_toyUfoActionStatus = kAS42ToyUfoRefresh;
869 					_vm->toyUfoFlyTo(-1, -1, 0, 799, 0, 300, 3);
870 				}
871 				break;
872 
873 			case kHS42UfoDevice:
874 				_vm->runMenu();
875 				updateHotspots();
876 				break;
877 
878 			default:
879 				break;
880 			}
881 		} else {
882 			switch (_vm->_sceneClickedHotspot) {
883 			case kHS42Device:
884 				_vm->runMenu();
885 				updateHotspots();
886 				_vm->_timers[4] = _vm->getRandom(20) + 30;
887 				break;
888 
889 			case kHS42Platypus:
890 				if (gnap._actionStatus < 0) {
891 					if (_vm->_grabCursorSpriteIndex >= 0) {
892 						gnap.playImpossible(plat._pos);
893 					} else {
894 						switch (_vm->_verbCursor) {
895 						case LOOK_CURSOR:
896 							gnap.playMoan1(plat._pos);
897 							break;
898 						case GRAB_CURSOR:
899 							gnap.kissPlatypus(0);
900 							break;
901 						case TALK_CURSOR:
902 							gnap.playBrainPulsating(plat._pos);
903 							plat.playSequence(plat.getSequenceId());
904 							break;
905 						case PLAT_CURSOR:
906 							gnap.playImpossible(plat._pos);
907 							break;
908 						default:
909 							break;
910 						}
911 					}
912 				}
913 				break;
914 
915 			case kHS42ExitUfoParty:
916 				_vm->_isLeavingScene = true;
917 				gnap.walkTo(Common::Point(gnap._pos.x, _vm->_hotspotsWalkPos[kHS42ExitUfoParty].y), 0, 0x107AE, 1);
918 				gnap._actionStatus = kAS42LeaveScene;
919 				plat.walkTo(Common::Point(plat._pos.x, _vm->_hotspotsWalkPos[kHS42ExitUfoParty].y), -1, 0x107C7, 1);
920 				_vm->_newSceneNum = 40;
921 				break;
922 
923 			case kHS42ExitToyStand:
924 				_vm->_isLeavingScene = true;
925 				gnap.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS42ExitToyStand].x, gnap._pos.y), 0, 0x107AF, 1);
926 				gnap._actionStatus = kAS42LeaveScene;
927 				plat.walkTo(_vm->_hotspotsWalkPos[kHS42ExitToyStand], -1, 0x107CF, 1);
928 				_vm->_newSceneNum = 41;
929 				break;
930 
931 			case kHS42ExitUfo:
932 				_vm->_isLeavingScene = true;
933 				gnap.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS42ExitUfo].x, gnap._pos.y), 0, 0x107AB, 1);
934 				gnap._actionStatus = kAS42LeaveScene;
935 				plat.walkTo(_vm->_hotspotsWalkPos[kHS42ExitUfo], -1, 0x107CD, 1);
936 				_vm->_newSceneNum = 43;
937 				break;
938 
939 			case kHS42BBQVendor:
940 				if (_vm->_grabCursorSpriteIndex == kItemDiceQuarterHole) {
941 					gnap.walkTo(_vm->_hotspotsWalkPos[kHS42BBQVendor], 0, 0x107BB, 1);
942 					gnap._actionStatus = kAS42UseQuarterWithBBQVendor;
943 					if (plat._pos.y < 9)
944 						plat.walkTo(Common::Point(plat._pos.x, 9), -1, -1, 1);
945 				} else if (_vm->_grabCursorSpriteIndex >= 0) {
946 					gnap.playShowCurrItem(_vm->_hotspotsWalkPos[kHS42BBQVendor], _vm->_hotspotsWalkPos[kHS42BBQVendor].x + 1, 0);
947 				} else {
948 					switch (_vm->_verbCursor) {
949 					case LOOK_CURSOR:
950 						gnap.playScratchingHead(Common::Point(_vm->_hotspotsWalkPos[kHS42BBQVendor].x - 1, 0));
951 						break;
952 					case TALK_CURSOR:
953 						gnap._idleFacing = kDirUpRight;
954 						gnap.walkTo(_vm->_hotspotsWalkPos[kHS42BBQVendor], 0, gnap.getSequenceId(kGSBrainPulsating, Common::Point(0, 0)) | 0x10000, 1);
955 						gnap._actionStatus = kAS42TalkBBQVendor;
956 						break;
957 					case GRAB_CURSOR:
958 					case PLAT_CURSOR:
959 						gnap.playImpossible();
960 						break;
961 					default:
962 						break;
963 					}
964 				}
965 				break;
966 
967 			case kHS42ChickenLeg:
968 				if (_vm->_grabCursorSpriteIndex >= 0) {
969 					gnap.playShowCurrItem(_vm->_hotspotsWalkPos[kHS42ChickenLeg], _vm->_hotspotsWalkPos[kHS42ChickenLeg].x - 1, 0);
970 				} else {
971 					switch (_vm->_verbCursor) {
972 					case LOOK_CURSOR:
973 						gnap.playScratchingHead(Common::Point(_vm->_hotspotsWalkPos[kHS42ChickenLeg].x - 1, 0));
974 						break;
975 					case GRAB_CURSOR:
976 						gnap.walkTo(_vm->_hotspotsWalkPos[kHS42ChickenLeg], 0, 0x107BC, 1);
977 						gnap._actionStatus = kAS42GrabChickenLeg;
978 						break;
979 					case TALK_CURSOR:
980 					case PLAT_CURSOR:
981 						gnap.playImpossible();
982 						break;
983 					default:
984 						break;
985 					}
986 				}
987 				break;
988 
989 			case kHS42WalkArea1:
990 			case kHS42WalkArea2:
991 				if (gnap._actionStatus < 0)
992 					gnap.walkTo(Common::Point(-1, -1), -1, -1, 1);
993 				break;
994 
995 			default:
996 				break;
997 			}
998 		}
999 
1000 		if (_vm->_mouseClickState._left && gnap._actionStatus < 0) {
1001 			_vm->_mouseClickState._left = false;
1002 			if (_vm->isFlag(kGFGnapControlsToyUFO)) {
1003 				_vm->_toyUfoActionStatus = kAS42ToyUfoRefresh;
1004 				_vm->toyUfoFlyTo(-1, -1, 0, 799, 0, 300, 3);
1005 			} else {
1006 				gnap.walkTo(Common::Point(-1, -1), -1, -1, 1);
1007 			}
1008 		}
1009 
1010 		updateAnimations();
1011 
1012 		_vm->toyUfoCheckTimer();
1013 
1014 		if (!_vm->_isLeavingScene) {
1015 			if (plat._actionStatus < 0 && !_vm->isFlag(kGFGnapControlsToyUFO))
1016 				plat.updateIdleSequence();
1017 			if (gnap._actionStatus < 0 && !_vm->isFlag(kGFGnapControlsToyUFO))
1018 				gnap.updateIdleSequence();
1019 			if (!_vm->_timers[4]) {
1020 				_vm->_timers[4] = _vm->getRandom(20) + 30;
1021 				if (gnap._actionStatus < 0 && plat._actionStatus < 0 && _nextBBQVendorSequenceId == -1) {
1022 					switch (_vm->getRandom(8)) {
1023 					case 0:
1024 						_nextBBQVendorSequenceId = 0x14C;
1025 						break;
1026 					case 1:
1027 					case 2:
1028 						_nextBBQVendorSequenceId = 0x149;
1029 						break;
1030 					case 3:
1031 					case 4:
1032 					case 5:
1033 					case 6:
1034 						_nextBBQVendorSequenceId = 0x14D;
1035 						break;
1036 					case 7:
1037 						_nextBBQVendorSequenceId = 0x14A;
1038 						break;
1039 					default:
1040 						break;
1041 					}
1042 					if (_nextBBQVendorSequenceId == _currBBQVendorSequenceId && _nextBBQVendorSequenceId != 0x14D)
1043 						_nextBBQVendorSequenceId = -1;
1044 				}
1045 			}
1046 		}
1047 
1048 		_vm->checkGameKeys();
1049 
1050 		if (_vm->isKeyStatus1(Common::KEYCODE_BACKSPACE)) {
1051 			_vm->clearKeyStatus1(Common::KEYCODE_BACKSPACE);
1052 			_vm->runMenu();
1053 			updateHotspots();
1054 			_vm->_timers[4] = _vm->getRandom(20) + 30;
1055 		}
1056 
1057 		_vm->gameUpdateTick();
1058 	}
1059 }
1060 
updateAnimations()1061 void Scene42::updateAnimations() {
1062 	GameSys& gameSys = *_vm->_gameSys;
1063 	PlayerGnap& gnap = *_vm->_gnap;
1064 
1065 	if (gameSys.getAnimationStatus(0) == 2) {
1066 		switch (gnap._actionStatus) {
1067 		case kAS42LeaveScene:
1068 			gameSys.setAnimation(0, 0, 0);
1069 			gnap._actionStatus = -1;
1070 			_vm->_sceneDone = true;
1071 			break;
1072 		case kAS42TalkBBQVendor:
1073 			gameSys.setAnimation(0, 0, 0);
1074 			gnap._actionStatus = -1;
1075 			_nextBBQVendorSequenceId = 0x14B;
1076 			break;
1077 		case kAS42UseQuarterWithBBQVendor:
1078 		case kAS42GrabChickenLeg:
1079 			if (gameSys.getAnimationStatus(2) == 2) {
1080 				int sequenceId;
1081 				if (gnap._actionStatus == kAS42UseQuarterWithBBQVendor) {
1082 					_vm->invRemove(kItemDiceQuarterHole);
1083 					_vm->invAdd(kItemChickenBucket);
1084 					_vm->setGrabCursorSprite(-1);
1085 					sequenceId = 0x150;
1086 					_nextBBQVendorSequenceId = 0x148;
1087 				} else if (_vm->isFlag(kGFUnk27)) {
1088 					if (_vm->isFlag(kGFUnk28)) {
1089 						sequenceId = 0x7B7;
1090 						_nextBBQVendorSequenceId = 0x145;
1091 					} else {
1092 						_vm->setFlag(kGFUnk28);
1093 						sequenceId = 0x14F;
1094 						_nextBBQVendorSequenceId = 0x147;
1095 					}
1096 				} else {
1097 					_vm->setFlag(kGFUnk27);
1098 					sequenceId = 0x14E;
1099 					_nextBBQVendorSequenceId = 0x146;
1100 				}
1101 				if (sequenceId == 0x7B7) {
1102 					gameSys.insertSequence(0x107B7, gnap._id,
1103 						makeRid(gnap._sequenceDatNum, gnap._sequenceId), gnap._id,
1104 						kSeqSyncWait, _vm->getSequenceTotalDuration(_nextBBQVendorSequenceId),
1105 						75 * gnap._pos.x - gnap._gridX, 48 * gnap._pos.y - gnap._gridY);
1106 					gnap._sequenceDatNum = 1;
1107 				} else {
1108 					gameSys.insertSequence(sequenceId, gnap._id,
1109 						makeRid(gnap._sequenceDatNum, gnap._sequenceId), gnap._id,
1110 						kSeqSyncWait, 0, 0, 0);
1111 					gnap._sequenceDatNum = 0;
1112 				}
1113 				gnap._sequenceId = sequenceId;
1114 				gameSys.setAnimation(sequenceId | (gnap._sequenceDatNum << 16), gnap._id, 0);
1115 				if (gnap._actionStatus == kAS42UseQuarterWithBBQVendor)
1116 					gnap._actionStatus = kAS42UseQuarterWithBBQVendorDone;
1117 				else
1118 					gnap._actionStatus = -1;
1119 				gameSys.insertSequence(_nextBBQVendorSequenceId, 1, _currBBQVendorSequenceId, 1, kSeqSyncWait, 0, 0, 0);
1120 				gameSys.setAnimation(_nextBBQVendorSequenceId, 1, 2);
1121 				_currBBQVendorSequenceId = _nextBBQVendorSequenceId;
1122 				if (_nextBBQVendorSequenceId == 0x145)
1123 					_nextBBQVendorSequenceId = 0x14A;
1124 				else
1125 					_nextBBQVendorSequenceId = -1;
1126 				_vm->_timers[4] = _vm->getRandom(20) + 30;
1127 				_vm->_timers[2] = _vm->getRandom(30) + 20;
1128 				_vm->_timers[3] = _vm->getRandom(50) + 200;
1129 			}
1130 			break;
1131 		case kAS42UseQuarterWithBBQVendorDone:
1132 			gameSys.setAnimation(0, 0, 0);
1133 			_vm->setGrabCursorSprite(kItemChickenBucket);
1134 			gnap._actionStatus = -1;
1135 			break;
1136 		default:
1137 			gameSys.setAnimation(0, 0, 0);
1138 			gnap._actionStatus = -1;
1139 			break;
1140 		}
1141 	}
1142 
1143 	if (gameSys.getAnimationStatus(2) == 2 && _nextBBQVendorSequenceId != -1) {
1144 		gameSys.insertSequence(_nextBBQVendorSequenceId, 1, _currBBQVendorSequenceId, 1, kSeqSyncWait, 0, 0, 0);
1145 		gameSys.setAnimation(_nextBBQVendorSequenceId, 1, 2);
1146 		_currBBQVendorSequenceId = _nextBBQVendorSequenceId;
1147 		_nextBBQVendorSequenceId = -1;
1148 		_vm->_timers[4] = _vm->getRandom(20) + 30;
1149 	}
1150 
1151 	if (gameSys.getAnimationStatus(3) == 2) {
1152 		switch (_vm->_toyUfoActionStatus) {
1153 		case kAS42ToyUfoLeaveScene:
1154 			_vm->_sceneDone = true;
1155 			break;
1156 		case kAS42ToyUfoPickUpHotSauce:
1157 			gameSys.insertSequence(0x10870, _vm->_toyUfoId, _vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId, kSeqSyncWait, 0, 0, 0);
1158 			_vm->setFlag(kGFUnk24);
1159 			updateHotspots();
1160 			_vm->toyUfoSetStatus(kGFGroceryStoreHatTaken);
1161 			_vm->_toyUfoSequenceId = 0x870;
1162 			gameSys.setAnimation(0x10870, _vm->_toyUfoId, 3);
1163 			_vm->_toyUfoActionStatus = -1;
1164 			_vm->_toyUfoX = 0x181;
1165 			_vm->_toyUfoY = 53;
1166 			break;
1167 		default:
1168 			if (_vm->_toyUfoSequenceId == 0x872) {
1169 				_vm->hideCursor();
1170 				_vm->addFullScreenSprite(0x13E, 255);
1171 				gameSys.setAnimation(0x151, 256, 0);
1172 				gameSys.insertSequence(0x151, 256, 0, 0, kSeqNone, 0, 0, 0);
1173 				while (gameSys.getAnimationStatus(0) != 2 && !_vm->_gameDone)
1174 					_vm->gameUpdateTick();
1175 				_vm->removeFullScreenSprite();
1176 				_vm->showCursor();
1177 			}
1178 			_vm->_toyUfoNextSequenceId = _vm->toyUfoGetSequenceId();
1179 			gameSys.setAnimation(_vm->_toyUfoNextSequenceId | 0x10000, (_vm->_toyUfoId + 1) % 10, 3);
1180 			gameSys.insertSequence(_vm->_toyUfoNextSequenceId | 0x10000, (_vm->_toyUfoId + 1) % 10,
1181 				_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId,
1182 				kSeqSyncWait, 0, _vm->_toyUfoX - 274, _vm->_toyUfoY - 128);
1183 			_vm->_toyUfoSequenceId = _vm->_toyUfoNextSequenceId;
1184 			_vm->_toyUfoId = (_vm->_toyUfoId + 1) % 10;
1185 			break;
1186 		}
1187 		_vm->_toyUfoActionStatus = -1;
1188 	}
1189 }
1190 
1191 /*****************************************************************************/
1192 
Scene43(GnapEngine * vm)1193 Scene43::Scene43(GnapEngine *vm) : Scene(vm) {
1194 	_currTwoHeadedGuySequenceId = -1;
1195 	_nextTwoHeadedGuySequenceId = -1;
1196 }
1197 
init()1198 int Scene43::init() {
1199 	GameSys& gameSys = *_vm->_gameSys;
1200 
1201 	gameSys.setAnimation(0, 0, 0);
1202 	gameSys.setAnimation(0, 0, 1);
1203 	gameSys.setAnimation(0, 0, 2);
1204 	return 0x13F;
1205 }
1206 
updateHotspots()1207 void Scene43::updateHotspots() {
1208 	if (_vm->isFlag(kGFGnapControlsToyUFO)) {
1209 		_vm->setHotspot(kHS43Platypus, 0, 0, 0, 0, SF_DISABLED);
1210 		_vm->setHotspot(kHS43UfoExitLeft, 0, 0, 10, 599, SF_EXIT_L_CURSOR);
1211 		_vm->setHotspot(kHS43UfoExitRight, 790, 0, 799, 599, SF_EXIT_R_CURSOR);
1212 		_vm->setHotspot(kHS43UfoKey, 140, 170, 185, 260, SF_GRAB_CURSOR);
1213 		_vm->setHotspot(kHS43UfoBucket, 475, 290, 545, 365, SF_DISABLED);
1214 		_vm->setDeviceHotspot(kHS43UfoDevice, -1, 534, -1, 599);
1215 		if (_vm->isFlag(kGFGroceryStoreHatTaken))
1216 			_vm->_hotspots[kHS43UfoBucket]._flags = SF_GRAB_CURSOR;
1217 		// NOTE Bug in the original. Key hotspot wasn't disabled.
1218 		if (_vm->isFlag(kGFUnk14))
1219 			_vm->_hotspots[kHS43UfoKey]._flags = SF_DISABLED;
1220 		_vm->_hotspotsCount = 6;
1221 	} else {
1222 		_vm->setHotspot(kHS43Platypus, 0, 0, 0, 0, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
1223 		_vm->setHotspot(kHS43ExitUfoParty, 150, 580, 650, 600, SF_EXIT_D_CURSOR | SF_WALKABLE, 5, 9);
1224 		_vm->setHotspot(kHS43ExitBBQ, 0, 100, 10, 599, SF_EXIT_L_CURSOR, 0, 8);
1225 		_vm->setHotspot(kHS43ExitKissinBooth, 790, 100, 799, 599, SF_EXIT_R_CURSOR, 10, 8);
1226 		_vm->setHotspot(kHS43TwoHeadedGuy, 470, 240, 700, 470, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
1227 		_vm->setHotspot(kHS43Key, 140, 170, 185, 260, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
1228 		_vm->setHotspot(kHS43Ufo, 110, 0, 690, 350, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
1229 		_vm->setHotspot(kHS43WalkArea1, 0, 0, 800, 445);
1230 		_vm->setHotspot(kHS43WalkArea2, 465, 0, 800, 493);
1231 		_vm->setDeviceHotspot(kHS43Device, -1, -1, -1, -1);
1232 		if (_vm->isFlag(kGFUnk14))
1233 			_vm->_hotspots[kHS43Key]._flags = SF_DISABLED;
1234 		_vm->_hotspotsCount = 10;
1235 	}
1236 }
1237 
run()1238 void Scene43::run() {
1239 	GameSys& gameSys = *_vm->_gameSys;
1240 	PlayerGnap& gnap = *_vm->_gnap;
1241 	PlayerPlat& plat = *_vm->_plat;
1242 
1243 	_vm->queueInsertDeviceIcon();
1244 
1245 	if (!_vm->isFlag(kGFUnk14))
1246 		gameSys.insertSequence(0x1086F, 1, 0, 0, kSeqNone, 0, 0, 0);
1247 
1248 	_currTwoHeadedGuySequenceId = 0x13C;
1249 	_nextTwoHeadedGuySequenceId = -1;
1250 
1251 	gameSys.setAnimation(0x13C, 1, 2);
1252 	gameSys.insertSequence(_currTwoHeadedGuySequenceId, 1, 0, 0, kSeqNone, 0, 0, 0);
1253 
1254 	if (_vm->isFlag(kGFGnapControlsToyUFO)) {
1255 		_vm->_toyUfoId = 0;
1256 		_vm->_toyUfoActionStatus = -1;
1257 		_vm->_toyUfoSequenceId = _vm->toyUfoGetSequenceId();
1258 		_vm->_toyUfoNextSequenceId = _vm->_toyUfoSequenceId;
1259 		if (_vm->_prevSceneNum == 42)
1260 			_vm->_toyUfoX = 30;
1261 		else
1262 			_vm->_toyUfoX = 770;
1263 		gameSys.setAnimation(_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId, 3);
1264 		gameSys.insertSequence(_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId, 0, 0, kSeqNone, 0, _vm->_toyUfoX - 274, _vm->_toyUfoY - 128);
1265 		_vm->endSceneInit();
1266 	} else {
1267 		switch (_vm->_prevSceneNum) {
1268 		case 42:
1269 			gnap.initPos(-1, 8, kDirUpRight);
1270 			plat.initPos(-1, 9, kDirUpLeft);
1271 			_vm->endSceneInit();
1272 			gnap.walkTo(Common::Point(2, 8), -1, 0x107B9, 1);
1273 			plat.walkTo(Common::Point(1, 8), -1, 0x107C2, 1);
1274 			break;
1275 		case 44:
1276 			gnap.initPos(11, 8, kDirUpRight);
1277 			plat.initPos(11, 9, kDirUpLeft);
1278 			_vm->endSceneInit();
1279 			gnap.walkTo(Common::Point(8, 8), -1, 0x107BA, 1);
1280 			plat.walkTo(Common::Point(9, 8), -1, 0x107D2, 1);
1281 			break;
1282 		case 54:
1283 			gnap.initPos(4, 7, kDirBottomLeft);
1284 			plat.initPos(11, 8, kDirUpLeft);
1285 			_vm->endSceneInit();
1286 			plat.walkTo(Common::Point(9, 8), -1, 0x107D2, 1);
1287 			break;
1288 		default:
1289 			gnap.initPos(5, 11, kDirUpRight);
1290 			plat.initPos(6, 11, kDirUpLeft);
1291 			_vm->endSceneInit();
1292 			gnap.walkTo(Common::Point(5, 8), -1, 0x107BA, 1);
1293 			plat.walkTo(Common::Point(6, 8), -1, 0x107C2, 1);
1294 			break;
1295 		}
1296 	}
1297 
1298 	while (!_vm->_sceneDone) {
1299 		if (!_vm->isSoundPlaying(0x1094B))
1300 			_vm->playSound(0x1094B, true);
1301 
1302 		_vm->updateMouseCursor();
1303 		_vm->updateCursorByHotspot();
1304 
1305 		_vm->testWalk(0, 0, -1, -1, -1, -1);
1306 
1307 		_vm->_sceneClickedHotspot = _vm->getClickedHotspotId();
1308 		_vm->updateGrabCursorSprite(0, 0);
1309 
1310 		if (_vm->isFlag(kGFGnapControlsToyUFO)) {
1311 			switch (_vm->_sceneClickedHotspot) {
1312 			case kHS43UfoDevice:
1313 				_vm->runMenu();
1314 				updateHotspots();
1315 				_vm->_timers[4] = _vm->getRandom(100) + 100;
1316 				break;
1317 
1318 			case kHS43UfoExitLeft:
1319 				if (_vm->_toyUfoActionStatus < 0) {
1320 					_vm->_isLeavingScene = true;
1321 					_vm->_toyUfoActionStatus = 4;
1322 					_vm->_newSceneNum = 42;
1323 					_vm->toyUfoFlyTo(-35, -1, -35, 799, 0, 300, 3);
1324 				}
1325 				break;
1326 
1327 			case kHS43UfoExitRight:
1328 				if (_vm->_toyUfoActionStatus < 0) {
1329 					_vm->_isLeavingScene = true;
1330 					_vm->_toyUfoActionStatus = 4;
1331 					_vm->_newSceneNum = 44;
1332 					_vm->toyUfoFlyTo(835, -1, 0, 835, 0, 300, 3);
1333 				}
1334 				break;
1335 
1336 			case kHS43UfoKey:
1337 				if (_vm->isFlag(kGFJointTaken)) {
1338 					_vm->_toyUfoActionStatus = 6;
1339 					_vm->toyUfoFlyTo(163, 145, 0, 799, 0, 300, 3);
1340 				} else {
1341 					_vm->_toyUfoActionStatus = 5;
1342 					_vm->toyUfoFlyTo(-1, -1, 0, 799, 0, 300, 3);
1343 				}
1344 				break;
1345 
1346 			case kHS43UfoBucket:
1347 				_vm->_toyUfoActionStatus = 7;
1348 				_vm->toyUfoFlyTo(497, 143, 0, 799, 0, 300, 3);
1349 				_vm->_timers[9] = 600;
1350 				break;
1351 
1352 			default:
1353 				break;
1354 			}
1355 		} else {
1356 			switch (_vm->_sceneClickedHotspot) {
1357 			case kHS43Device:
1358 				_vm->runMenu();
1359 				updateHotspots();
1360 				_vm->_timers[4] = _vm->getRandom(100) + 100;
1361 				break;
1362 
1363 			case kHS43Platypus:
1364 				if (gnap._actionStatus < 0) {
1365 					if (_vm->_grabCursorSpriteIndex >= 0) {
1366 						gnap.playImpossible(plat._pos);
1367 					} else {
1368 						switch (_vm->_verbCursor) {
1369 						case LOOK_CURSOR:
1370 							gnap.playMoan1(plat._pos);
1371 							break;
1372 						case GRAB_CURSOR:
1373 							gnap.kissPlatypus(0);
1374 							break;
1375 						case TALK_CURSOR:
1376 							gnap.playBrainPulsating(plat._pos);
1377 							plat.playSequence(plat.getSequenceId());
1378 							break;
1379 						case PLAT_CURSOR:
1380 							gnap.playImpossible(plat._pos);
1381 							break;
1382 						default:
1383 							break;
1384 						}
1385 					}
1386 				}
1387 				break;
1388 
1389 			case kHS43ExitUfoParty:
1390 				_vm->_isLeavingScene = true;
1391 				gnap.walkTo(_vm->_hotspotsWalkPos[kHS43ExitUfoParty], 0, 0x107AE, 1);
1392 				gnap._actionStatus = 0;
1393 				plat.walkTo(_vm->_hotspotsWalkPos[kHS43ExitUfoParty], -1, 0x107C7, 1);
1394 				_vm->_newSceneNum = 40;
1395 				break;
1396 
1397 			case kHS43ExitBBQ:
1398 				_vm->_isLeavingScene = true;
1399 				gnap.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS43ExitBBQ].x, gnap._pos.y), 0, 0x107AF, 1);
1400 				gnap._actionStatus = 0;
1401 				plat.walkTo(_vm->_hotspotsWalkPos[kHS43ExitBBQ], -1, 0x107CF, 1);
1402 				_vm->_newSceneNum = 42;
1403 				break;
1404 
1405 			case kHS43ExitKissinBooth:
1406 				_vm->_isLeavingScene = true;
1407 				gnap.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS43ExitKissinBooth].x, gnap._pos.y), 0, 0x107AB, 1);
1408 				gnap._actionStatus = 0;
1409 				plat.walkTo(_vm->_hotspotsWalkPos[kHS43ExitKissinBooth], -1, 0x107CD, 1);
1410 				_vm->_newSceneNum = 44;
1411 				break;
1412 
1413 			case kHS43TwoHeadedGuy:
1414 				if (_vm->_grabCursorSpriteIndex >= 0) {
1415 					gnap.playShowCurrItem(Common::Point(6, 8), 7, 0);
1416 				} else {
1417 					switch (_vm->_verbCursor) {
1418 					case LOOK_CURSOR:
1419 						gnap.playScratchingHead(Common::Point(7, 0));
1420 						break;
1421 					case TALK_CURSOR:
1422 							gnap._idleFacing = kDirUpRight;
1423 							gnap.walkTo(Common::Point(5, 8), 0, gnap.getSequenceId(kGSBrainPulsating, Common::Point(0, 0)) | 0x10000, 1);
1424 							gnap._actionStatus = 2;
1425 						break;
1426 					case GRAB_CURSOR:
1427 					case PLAT_CURSOR:
1428 						gnap.playImpossible();
1429 						break;
1430 					default:
1431 						break;
1432 					}
1433 				}
1434 				break;
1435 
1436 			case kHS43Key:
1437 			case kHS43Ufo:
1438 				if (_vm->_grabCursorSpriteIndex >= 0) {
1439 					gnap.playShowCurrItem(Common::Point(3, 7), 2, 0);
1440 				} else {
1441 					switch (_vm->_verbCursor) {
1442 					case LOOK_CURSOR:
1443 						gnap.playScratchingHead();
1444 						break;
1445 					case GRAB_CURSOR:
1446 						gnap._idleFacing = kDirUpRight;
1447 						gnap.walkTo(Common::Point(3, 7), 0, 67515, 1);
1448 						gnap._actionStatus = 1;
1449 						break;
1450 					case TALK_CURSOR:
1451 					case PLAT_CURSOR:
1452 						gnap.playImpossible();
1453 						break;
1454 					default:
1455 						break;
1456 					}
1457 				}
1458 				break;
1459 
1460 			case kHS43WalkArea1:
1461 			case kHS43WalkArea2:
1462 				if (gnap._actionStatus < 0)
1463 					gnap.walkTo(Common::Point(-1, -1), -1, -1, 1);
1464 				break;
1465 
1466 			default:
1467 				break;
1468 			}
1469 		}
1470 
1471 		if (_vm->_mouseClickState._left && gnap._actionStatus < 0) {
1472 			_vm->_mouseClickState._left = false;
1473 			if (_vm->isFlag(kGFGnapControlsToyUFO) && (_vm->_toyUfoActionStatus == 5 || _vm->_toyUfoActionStatus == -1)) {
1474 				_vm->_toyUfoActionStatus = 5;
1475 				_vm->toyUfoFlyTo(-1, -1, 0, 799, 0, 300, 3);
1476 			} else {
1477 				gnap.walkTo(Common::Point(-1, -1), -1, -1, 1);
1478 			}
1479 		}
1480 
1481 		updateAnimations();
1482 
1483 		_vm->toyUfoCheckTimer();
1484 
1485 		if (!_vm->_isLeavingScene) {
1486 			if (plat._actionStatus < 0 && !_vm->isFlag(kGFGnapControlsToyUFO))
1487 				plat.updateIdleSequence();
1488 			if (gnap._actionStatus < 0 && !_vm->isFlag(kGFGnapControlsToyUFO))
1489 				gnap.updateIdleSequence();
1490 			if (!_vm->_timers[4] && (!_vm->isFlag(kGFGnapControlsToyUFO) || !_vm->isFlag(kGFGroceryStoreHatTaken))) {
1491 				_vm->_timers[4] = _vm->getRandom(100) + 100;
1492 				if (gnap._actionStatus < 0 && plat._actionStatus < 0 && _nextTwoHeadedGuySequenceId == -1) {
1493 					switch (_vm->getRandom(5)) {
1494 					case 0:
1495 						_nextTwoHeadedGuySequenceId = 0x13C;
1496 						break;
1497 					case 1:
1498 						_nextTwoHeadedGuySequenceId = 0x134;
1499 						break;
1500 					case 2:
1501 						_nextTwoHeadedGuySequenceId = 0x135;
1502 						break;
1503 					case 3:
1504 						_nextTwoHeadedGuySequenceId = 0x136;
1505 						break;
1506 					case 4:
1507 						_nextTwoHeadedGuySequenceId = 0x13A;
1508 						break;
1509 					default:
1510 						break;
1511 					}
1512 					if (_nextTwoHeadedGuySequenceId == _currTwoHeadedGuySequenceId)
1513 						_nextTwoHeadedGuySequenceId = -1;
1514 				}
1515 			}
1516 		}
1517 
1518 		_vm->checkGameKeys();
1519 
1520 		if (_vm->isKeyStatus1(Common::KEYCODE_BACKSPACE)) {
1521 			_vm->clearKeyStatus1(Common::KEYCODE_BACKSPACE);
1522 			_vm->runMenu();
1523 			updateHotspots();
1524 			_vm->_timers[4] = _vm->getRandom(100) + 100;
1525 		}
1526 
1527 		_vm->gameUpdateTick();
1528 	}
1529 
1530 	if (_vm->_newSceneNum == 54)
1531 		_vm->clearFlag(kGFGnapControlsToyUFO);
1532 }
1533 
updateAnimations()1534 void Scene43::updateAnimations() {
1535 	GameSys& gameSys = *_vm->_gameSys;
1536 	PlayerGnap& gnap = *_vm->_gnap;
1537 
1538 	if (gameSys.getAnimationStatus(0) == 2) {
1539 		switch (gnap._actionStatus) {
1540 		case 0:
1541 			gameSys.setAnimation(0, 0, 0);
1542 			_vm->_sceneDone = true;
1543 			break;
1544 
1545 		case 1:
1546 			if (gameSys.getAnimationStatus(2) == 2) {
1547 				_vm->_timers[2] = _vm->getRandom(30) + 20;
1548 				_vm->_timers[3] = _vm->getRandom(50) + 200;
1549 				gameSys.insertSequence(0x13D, gnap._id, makeRid(gnap._sequenceDatNum, gnap._sequenceId), gnap._id, kSeqSyncWait, 0, 0, 0);
1550 				gnap._sequenceId = 0x13D;
1551 				gnap._sequenceDatNum = 0;
1552 				gameSys.setAnimation(0x13D, gnap._id, 0);
1553 				_nextTwoHeadedGuySequenceId = 0x13B;
1554 				gameSys.insertSequence(0x13B, 1, _currTwoHeadedGuySequenceId, 1, kSeqSyncWait, 0, 0, 0);
1555 				gameSys.setAnimation(_nextTwoHeadedGuySequenceId, 1, 2);
1556 				_currTwoHeadedGuySequenceId = _nextTwoHeadedGuySequenceId;
1557 				_nextTwoHeadedGuySequenceId = -1;
1558 				_vm->_timers[4] = _vm->getRandom(100) + 100;
1559 				gnap._actionStatus = -1;
1560 			}
1561 			break;
1562 
1563 		default:
1564 			gameSys.setAnimation(0, 0, 0);
1565 			gnap._actionStatus = -1;
1566 			break;
1567 		}
1568 	}
1569 
1570 	if (gameSys.getAnimationStatus(2) == 2) {
1571 		if (_currTwoHeadedGuySequenceId == 0x13A) {
1572 			if (_vm->isFlag(kGFGroceryStoreHatTaken)) {
1573 				_nextTwoHeadedGuySequenceId = 0x13E;
1574 				_vm->stopSound(0x108F6);
1575 			} else if (_vm->getRandom(2) != 0) {
1576 				_nextTwoHeadedGuySequenceId = 0x137;
1577 			} else {
1578 				_nextTwoHeadedGuySequenceId = 0x138;
1579 			}
1580 		} else if (_currTwoHeadedGuySequenceId == 0x13E) {
1581 			_vm->_sceneDone = true;
1582 			_vm->_newSceneNum = 54;
1583 		}
1584 		if (_nextTwoHeadedGuySequenceId != -1) {
1585 			gameSys.insertSequence(_nextTwoHeadedGuySequenceId, 1, _currTwoHeadedGuySequenceId, 1, kSeqSyncWait, 0, 0, 0);
1586 			gameSys.setAnimation(_nextTwoHeadedGuySequenceId, 1, 2);
1587 			_currTwoHeadedGuySequenceId = _nextTwoHeadedGuySequenceId;
1588 			_nextTwoHeadedGuySequenceId = -1;
1589 			_vm->_timers[4] = _vm->getRandom(100) + 100;
1590 		}
1591 	}
1592 
1593 	if (gameSys.getAnimationStatus(3) == 2) {
1594 		switch (_vm->_toyUfoActionStatus) {
1595 		case 4:
1596 			_vm->_sceneDone = true;
1597 			_vm->_toyUfoActionStatus = -1;
1598 			break;
1599 		case 6:
1600 			gameSys.insertSequence(0x10871, _vm->_toyUfoId, _vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId, kSeqSyncWait, 0, 0, 0);
1601 			gameSys.removeSequence(0x1086F, 1, true);
1602 			_vm->setFlag(kGFUnk14);
1603 			updateHotspots();
1604 			_vm->toyUfoSetStatus(kGFUnk18);
1605 			_vm->_toyUfoSequenceId = 0x871;
1606 			gameSys.setAnimation(0x10871, _vm->_toyUfoId, 3);
1607 			_vm->_toyUfoActionStatus = -1;
1608 			_vm->_toyUfoX = 96;
1609 			_vm->_toyUfoY = 131;
1610 			break;
1611 		case 7:
1612 			gameSys.insertSequence(0x10874, _vm->_toyUfoId, _vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId, kSeqSyncWait, 0, 0, 0);
1613 			_vm->_toyUfoSequenceId = 0x874;
1614 			gameSys.setAnimation(0x10874, _vm->_toyUfoId, 3);
1615 			_vm->_toyUfoActionStatus = 8;
1616 			_vm->setFlag(kGFJointTaken);
1617 			gnap._actionStatus = 3;
1618 			break;
1619 		case 8:
1620 			_nextTwoHeadedGuySequenceId = 0x13A;
1621 			_vm->_toyUfoX = 514;
1622 			_vm->_toyUfoY = 125;
1623 			_vm->toyUfoFlyTo(835, 125, 0, 835, 0, 300, 3);
1624 			_vm->_toyUfoActionStatus = 9;
1625 			break;
1626 		case 9:
1627 			// Nothing
1628 			break;
1629 		default:
1630 			_vm->_toyUfoNextSequenceId = _vm->toyUfoGetSequenceId();
1631 			gameSys.insertSequence(_vm->_toyUfoNextSequenceId | 0x10000, _vm->_toyUfoId + 1,
1632 				_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId,
1633 				kSeqSyncWait, 0, _vm->_toyUfoX - 274, _vm->_toyUfoY - 128);
1634 			_vm->_toyUfoSequenceId = _vm->_toyUfoNextSequenceId;
1635 			++_vm->_toyUfoId;
1636 			gameSys.setAnimation(_vm->_toyUfoNextSequenceId | 0x10000, _vm->_toyUfoId, 3);
1637 			_vm->_toyUfoActionStatus = -1;
1638 			break;
1639 		}
1640 	}
1641 }
1642 
1643 /*****************************************************************************/
1644 
Scene44(GnapEngine * vm)1645 Scene44::Scene44(GnapEngine *vm) : Scene(vm) {
1646 	_nextSpringGuySequenceId = -1;
1647 	_nextKissingLadySequenceId = -1;
1648 	_currSpringGuySequenceId = -1;
1649 	_currKissingLadySequenceId = -1;
1650 }
1651 
init()1652 int Scene44::init() {
1653 	GameSys& gameSys = *_vm->_gameSys;
1654 
1655 	gameSys.setAnimation(0, 0, 0);
1656 	gameSys.setAnimation(0, 0, 1);
1657 	gameSys.setAnimation(0, 0, 2);
1658 	gameSys.setAnimation(0, 0, 3);
1659 	return 0xFF;
1660 }
1661 
updateHotspots()1662 void Scene44::updateHotspots() {
1663 	if (_vm->isFlag(kGFGnapControlsToyUFO)) {
1664 		_vm->setHotspot(kHS44Platypus, 0, 0, 0, 0, SF_DISABLED);
1665 		_vm->setHotspot(kHS44UfoExitLeft, 0, 0, 10, 599, SF_EXIT_L_CURSOR);
1666 		_vm->setHotspot(kHS44UfoExitRight, 790, 0, 799, 599, SF_EXIT_R_CURSOR);
1667 		_vm->setDeviceHotspot(kHS44UfoDevice, -1, 534, -1, 599);
1668 		_vm->_hotspotsCount = 4;
1669 	} else {
1670 		_vm->setHotspot(kHS44Platypus, 0, 0, 0, 0, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
1671 		_vm->setHotspot(kHS44ExitUfoParty, 150, 580, 650, 600, SF_EXIT_D_CURSOR | SF_WALKABLE, 5, 9);
1672 		_vm->setHotspot(kHS44ExitUfo, 0, 100, 10, 599, SF_EXIT_L_CURSOR, 0, 8);
1673 		_vm->setHotspot(kHS44ExitShow, 790, 100, 799, 599, SF_EXIT_R_CURSOR, 10, 8);
1674 		_vm->setHotspot(kHS44KissingLady, 300, 160, 400, 315, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 5, 7);
1675 		_vm->setHotspot(kHS44Spring, 580, 310, 635, 375, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 7, 8);
1676 		_vm->setHotspot(kHS44SpringGuy, 610, 375, 690, 515, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 7, 8);
1677 		_vm->setHotspot(kHS44WalkArea1, 0, 0, 800, 445);
1678 		_vm->setHotspot(kHS44WalkArea2, 617, 0, 800, 600);
1679 		_vm->setDeviceHotspot(kHS44Device, -1, -1, -1, -1);
1680 		if (_vm->isFlag(kGFUnk13))
1681 			_vm->_hotspots[kHS44KissingLady]._flags = SF_DISABLED;
1682 		if (_vm->isFlag(kGFSpringTaken))
1683 			_vm->_hotspots[kHS44Spring]._flags = SF_DISABLED;
1684 		_vm->_hotspotsCount = 10;
1685 	}
1686 }
1687 
run()1688 void Scene44::run() {
1689 	GameSys& gameSys = *_vm->_gameSys;
1690 	PlayerGnap& gnap = *_vm->_gnap;
1691 	PlayerPlat& plat = *_vm->_plat;
1692 
1693 	_vm->queueInsertDeviceIcon();
1694 
1695 	gameSys.insertSequence(0xF7, 0, 0, 0, kSeqLoop, 0, 0, 0);
1696 	gameSys.insertSequence(0xFC, 256, 0, 0, kSeqNone, 0, 0, 0);
1697 
1698 	if (_vm->isFlag(kGFSpringTaken))
1699 		_currSpringGuySequenceId = 0xF8;
1700 	else
1701 		_currSpringGuySequenceId = 0xF9;
1702 
1703 	_nextSpringGuySequenceId = -1;
1704 	gameSys.setAnimation(_currSpringGuySequenceId, 1, 4);
1705 	gameSys.insertSequence(_currSpringGuySequenceId, 1, 0, 0, kSeqNone, 0, 0, 0);
1706 
1707 	if (_vm->isFlag(kGFUnk13)) {
1708 		if (_vm->_prevSceneNum != 50 || _vm->_sceneSavegameLoaded) {
1709 			_currKissingLadySequenceId = 0xF6;
1710 			_nextKissingLadySequenceId = -1;
1711 		} else {
1712 			_vm->setGrabCursorSprite(kItemGum);
1713 			_currKissingLadySequenceId = 0xF5;
1714 			_nextKissingLadySequenceId = 0xF6;
1715 			gameSys.setAnimation(0xF5, 1, 2);
1716 		}
1717 	} else {
1718 		_currKissingLadySequenceId = 0xEC;
1719 		_nextKissingLadySequenceId = -1;
1720 		gameSys.setAnimation(0xEC, 1, 2);
1721 	}
1722 
1723 	gameSys.insertSequence(_currKissingLadySequenceId, 1, 0, 0, kSeqNone, 0, 0, 0);
1724 
1725 	if (_vm->isFlag(kGFGnapControlsToyUFO)) {
1726 		_vm->_toyUfoId = 0;
1727 		_vm->_toyUfoActionStatus = -1;
1728 		_vm->_toyUfoSequenceId = _vm->toyUfoGetSequenceId();
1729 		_vm->_toyUfoNextSequenceId = _vm->_toyUfoSequenceId;
1730 		if (_vm->_prevSceneNum == 43)
1731 			_vm->_toyUfoX = 30;
1732 		else
1733 			_vm->_toyUfoX = 770;
1734 		gameSys.setAnimation(_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId, 3);
1735 		gameSys.insertSequence(_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId, 0, 0, kSeqNone, 0, _vm->_toyUfoX - 274, _vm->_toyUfoY - 128);
1736 		_vm->endSceneInit();
1737 	} else {
1738 		switch (_vm->_prevSceneNum) {
1739 		case 43:
1740 			gnap.initPos(-1, 8, kDirUpRight);
1741 			plat.initPos(-1, 7, kDirUpLeft);
1742 			_vm->endSceneInit();
1743 			gnap.walkTo(Common::Point(2, 8), -1, 0x107B9, 1);
1744 			plat.walkTo(Common::Point(1, 8), -1, 0x107C2, 1);
1745 			break;
1746 		case 46:
1747 			gnap.initPos(11, 8, kDirUpRight);
1748 			plat.initPos(11, 8, kDirUpLeft);
1749 			_vm->endSceneInit();
1750 			gnap.walkTo(Common::Point(6, 8), -1, 0x107BA, 1);
1751 			plat.walkTo(Common::Point(7, 8), -1, 0x107D2, 1);
1752 			break;
1753 		case 50:
1754 			gnap.initPos(4, 8, kDirBottomRight);
1755 			if (_vm->_sceneSavegameLoaded) {
1756 				plat.initPos(_vm->_hotspotsWalkPos[4].x, _vm->_hotspotsWalkPos[4].y, kDirIdleRight);
1757 			} else if (!_vm->isFlag(kGFUnk13)) {
1758 				_vm->_timers[0] = 50;
1759 				_vm->_timers[1] = 20;
1760 				plat._pos = Common::Point(5, 8);
1761 				plat._sequenceId = 0xFD;
1762 				plat._idleFacing = kDirIdleLeft;
1763 				plat._id = 160;
1764 				plat._sequenceDatNum = 0;
1765 				gameSys.insertSequence(0xFD, 160, 0, 0, kSeqNone, 0, 0, 0);
1766 			}
1767 			_vm->endSceneInit();
1768 			break;
1769 		default:
1770 			gnap.initPos(5, 11, kDirUpRight);
1771 			plat.initPos(6, 11, kDirUpLeft);
1772 			_vm->endSceneInit();
1773 			plat.walkTo(Common::Point(6, 8), -1, 0x107C2, 1);
1774 			gnap.walkTo(Common::Point(5, 8), -1, 0x107BA, 1);
1775 			break;
1776 		}
1777 	}
1778 
1779 	while (!_vm->_sceneDone) {
1780 		if (!_vm->isSoundPlaying(0x1094B))
1781 			_vm->playSound(0x1094B, true);
1782 
1783 		_vm->updateMouseCursor();
1784 		_vm->updateCursorByHotspot();
1785 
1786 		_vm->testWalk(0, 0, -1, -1, -1, -1);
1787 
1788 		_vm->_sceneClickedHotspot = _vm->getClickedHotspotId();
1789 		_vm->updateGrabCursorSprite(0, 0);
1790 
1791 		if (_vm->isFlag(kGFGnapControlsToyUFO)) {
1792 			switch (_vm->_sceneClickedHotspot) {
1793 			case kHS44UfoExitLeft:
1794 				if (_vm->_toyUfoActionStatus < 0) {
1795 					_vm->_isLeavingScene = true;
1796 					_vm->_toyUfoActionStatus = 6;
1797 					_vm->_newSceneNum = 43;
1798 					_vm->toyUfoFlyTo(-35, -1, -35, 799, 0, 300, 3);
1799 				}
1800 				break;
1801 
1802 			case kHS44UfoExitRight:
1803 				if (_vm->_toyUfoActionStatus < 0) {
1804 					_vm->_isLeavingScene = true;
1805 					_vm->_toyUfoActionStatus = 6;
1806 					_vm->_newSceneNum = 46;
1807 					_vm->toyUfoFlyTo(835, -1, 0, 835, 0, 300, 3);
1808 				}
1809 				break;
1810 
1811 			case kHS44UfoDevice:
1812 				_vm->runMenu();
1813 				updateHotspots();
1814 				_vm->_timers[4] = _vm->getRandom(20) + 20;
1815 				break;
1816 
1817 			default:
1818 				break;
1819 			}
1820 		} else if (_vm->_sceneClickedHotspot <= 9) {
1821 			switch (_vm->_sceneClickedHotspot) {
1822 			case kHS44Device:
1823 				_vm->runMenu();
1824 				updateHotspots();
1825 				_vm->_timers[4] = _vm->getRandom(20) + 20;
1826 				break;
1827 
1828 			case kHS44Platypus:
1829 				if (gnap._actionStatus < 0) {
1830 					if (_vm->_grabCursorSpriteIndex >= 0) {
1831 						gnap.playImpossible(plat._pos);
1832 					} else {
1833 						switch (_vm->_verbCursor) {
1834 						case LOOK_CURSOR:
1835 							gnap.playMoan1(plat._pos);
1836 							break;
1837 						case GRAB_CURSOR:
1838 							gnap.kissPlatypus(0);
1839 							break;
1840 						case TALK_CURSOR:
1841 							gnap.playBrainPulsating(plat._pos);
1842 							plat.playSequence(plat.getSequenceId());
1843 							break;
1844 						case PLAT_CURSOR:
1845 							gnap.playImpossible(plat._pos);
1846 							break;
1847 						default:
1848 							break;
1849 						}
1850 					}
1851 				}
1852 				break;
1853 
1854 			case kHS44ExitUfoParty:
1855 				_vm->_isLeavingScene = true;
1856 				gnap.walkTo(_vm->_hotspotsWalkPos[kHS44ExitUfoParty], 0, 0x107AE, 1);
1857 				gnap._actionStatus = 0;
1858 				_vm->_newSceneNum = 40;
1859 				break;
1860 
1861 			case kHS44ExitUfo:
1862 				_vm->_isLeavingScene = true;
1863 				gnap.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS44ExitUfo].x, gnap._pos.y), 0, 0x107AF, 1);
1864 				gnap._actionStatus = 0;
1865 				plat.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS44ExitUfo].x, plat._pos.y), -1, 0x107CF, 1);
1866 				_vm->_newSceneNum = 43;
1867 				break;
1868 
1869 			case kHS44ExitShow:
1870 				_vm->_isLeavingScene = true;
1871 				gnap.walkTo(_vm->_hotspotsWalkPos[kHS44ExitShow], 0, 0x107AB, 1);
1872 				gnap._actionStatus = 0;
1873 				_vm->_newSceneNum = 46;
1874 				break;
1875 
1876 			case kHS44KissingLady:
1877 				if (_vm->_grabCursorSpriteIndex >= 0) {
1878 					gnap._actionStatus = 2;
1879 					gnap.walkTo(_vm->_hotspotsWalkPos[kHS44KissingLady], 0, -1, 9);
1880 					gnap.playShowItem(_vm->_grabCursorSpriteIndex, _vm->_hotspotsWalkPos[kHS44KissingLady].x - 1, _vm->_hotspotsWalkPos[kHS44KissingLady].y);
1881 				} else {
1882 					switch (_vm->_verbCursor) {
1883 					case LOOK_CURSOR:
1884 						gnap.playScratchingHead(Common::Point(4, 3));
1885 						break;
1886 					case GRAB_CURSOR:
1887 						gnap.playImpossible();
1888 						break;
1889 					case TALK_CURSOR:
1890 						gnap._idleFacing = kDirUpLeft;
1891 						gnap.walkTo(_vm->_hotspotsWalkPos[kHS44KissingLady], 0, gnap.getSequenceId(kGSBrainPulsating, Common::Point(0, 0)) | 0x10000, 1);
1892 						gnap._actionStatus = 1;
1893 						break;
1894 					case PLAT_CURSOR:
1895 						gnap.useDeviceOnPlatypus();
1896 						plat.walkTo(Common::Point(6, 7), 1, 0x107D2, 1);
1897 						if (gnap._pos == Common::Point(7, 7))
1898 							gnap.walkStep();
1899 						gnap.playIdle(Common::Point(5, 7));
1900 						plat._actionStatus = 4;
1901 						break;
1902 					default:
1903 						break;
1904 					}
1905 				}
1906 				break;
1907 
1908 			case kHS44Spring:
1909 				if (_vm->_grabCursorSpriteIndex >= 0) {
1910 					gnap.playShowCurrItem(_vm->_hotspotsWalkPos[kHS44Spring], 8, 0);
1911 				} else {
1912 					switch (_vm->_verbCursor) {
1913 					case LOOK_CURSOR:
1914 						gnap.playScratchingHead(Common::Point(8, 7));
1915 						break;
1916 					case GRAB_CURSOR:
1917 						gnap.playPullOutDevice(Common::Point(8, 0));
1918 						gnap.playUseDevice(Common::Point(8, 0));
1919 						_nextSpringGuySequenceId = 0xFB;
1920 						_vm->invAdd(kItemSpring);
1921 						_vm->setFlag(kGFSpringTaken);
1922 						updateHotspots();
1923 						break;
1924 					case TALK_CURSOR:
1925 						gnap.playImpossible();
1926 						break;
1927 					case PLAT_CURSOR:
1928 						gnap.playImpossible();
1929 						break;
1930 					default:
1931 						break;
1932 					}
1933 				}
1934 				break;
1935 
1936 			case kHS44SpringGuy:
1937 				if (_vm->_grabCursorSpriteIndex >= 0) {
1938 					gnap.playShowCurrItem(_vm->_hotspotsWalkPos[kHS44SpringGuy], 8, 0);
1939 				} else {
1940 					switch (_vm->_verbCursor) {
1941 					case LOOK_CURSOR:
1942 						if (_vm->isFlag(kGFSpringTaken))
1943 							gnap.playMoan1(Common::Point(8, 7));
1944 						else
1945 							gnap.playScratchingHead(Common::Point(8, 7));
1946 						break;
1947 					case TALK_CURSOR:
1948 						gnap._idleFacing = kDirUpRight;
1949 						gnap.walkTo(_vm->_hotspotsWalkPos[kHS44SpringGuy], -1, gnap.getSequenceId(kGSBrainPulsating, Common::Point(0, 0)) | 0x10000, 1);
1950 						break;
1951 					case GRAB_CURSOR:
1952 					case PLAT_CURSOR:
1953 						gnap.playImpossible();
1954 						break;
1955 					default:
1956 						break;
1957 					}
1958 				}
1959 				break;
1960 
1961 			case kHS44WalkArea1:
1962 			case kHS44WalkArea2:
1963 				if (gnap._actionStatus < 0)
1964 					gnap.walkTo(Common::Point(-1, -1), -1, -1, 1);
1965 				break;
1966 
1967 			default:
1968 				break;
1969 			}
1970 		}
1971 
1972 		if (_vm->_mouseClickState._left && gnap._actionStatus < 0) {
1973 			_vm->_mouseClickState._left = false;
1974 			if (_vm->isFlag(kGFGnapControlsToyUFO)) {
1975 				_vm->_toyUfoActionStatus = 7;
1976 				_vm->toyUfoFlyTo(-1, -1, 0, 799, 0, 300, 3);
1977 			} else {
1978 				gnap.walkTo(Common::Point(-1, -1), -1, -1, 1);
1979 			}
1980 		}
1981 
1982 		updateAnimations();
1983 		_vm->toyUfoCheckTimer();
1984 
1985 		if (!_vm->_isLeavingScene) {
1986 			if (plat._actionStatus < 0 && !_vm->isFlag(kGFGnapControlsToyUFO) && _currKissingLadySequenceId != 0xF5)
1987 				plat.updateIdleSequence();
1988 			if (gnap._actionStatus < 0 && !_vm->isFlag(kGFGnapControlsToyUFO))
1989 				gnap.updateIdleSequence();
1990 			if (!_vm->_timers[4]) {
1991 				_vm->_timers[4] = _vm->getRandom(20) + 20;
1992 				if (gnap._actionStatus < 0 && plat._actionStatus < 0 && _nextKissingLadySequenceId == -1) {
1993 					switch (_vm->getRandom(20)) {
1994 					case 0:
1995 						_nextKissingLadySequenceId = 0xED;
1996 						break;
1997 					case 1:
1998 						_nextKissingLadySequenceId = 0xEE;
1999 						break;
2000 					case 2:
2001 						_nextKissingLadySequenceId = 0xF0;
2002 						break;
2003 					case 3:
2004 						_nextKissingLadySequenceId = 0xF3;
2005 						break;
2006 					case 4:
2007 						_nextKissingLadySequenceId = 0xF4;
2008 						break;
2009 					default:
2010 						_nextKissingLadySequenceId = 0xEC;
2011 						break;
2012 					}
2013 					if (_nextKissingLadySequenceId != 0xEC && _nextKissingLadySequenceId == _currKissingLadySequenceId)
2014 						_nextKissingLadySequenceId = -1;
2015 				}
2016 			}
2017 			if (!_vm->_timers[5]) {
2018 				_vm->_timers[5] = _vm->getRandom(20) + 20;
2019 				if (gnap._actionStatus < 0 && plat._actionStatus < 0 && _nextSpringGuySequenceId == -1) {
2020 					if (_vm->getRandom(5) != 0) {
2021 						if (!_vm->isFlag(kGFSpringTaken))
2022 							_nextSpringGuySequenceId = 0xF9;
2023 					} else {
2024 						if (_vm->isFlag(kGFSpringTaken))
2025 							_nextSpringGuySequenceId = 0xF8;
2026 						else
2027 							_nextSpringGuySequenceId = 0xFA;
2028 					}
2029 				}
2030 			}
2031 		}
2032 
2033 		_vm->checkGameKeys();
2034 
2035 		if (_vm->isKeyStatus1(Common::KEYCODE_BACKSPACE)) {
2036 			_vm->clearKeyStatus1(Common::KEYCODE_BACKSPACE);
2037 			_vm->runMenu();
2038 			updateHotspots();
2039 			_vm->_timers[4] = _vm->getRandom(20) + 20;
2040 		}
2041 
2042 		_vm->gameUpdateTick();
2043 	}
2044 }
2045 
updateAnimations()2046 void Scene44::updateAnimations() {
2047 	GameSys& gameSys = *_vm->_gameSys;
2048 	PlayerGnap& gnap = *_vm->_gnap;
2049 	PlayerPlat& plat = *_vm->_plat;
2050 
2051 	if (gameSys.getAnimationStatus(0) == 2) 	{
2052 		gameSys.setAnimation(0, 0, 0);
2053 		switch (gnap._actionStatus) {
2054 		case 0:
2055 			_vm->_sceneDone = true;
2056 			break;
2057 		case 1:
2058 			_nextKissingLadySequenceId = 0xEF;
2059 			break;
2060 		case 2:
2061 			_nextKissingLadySequenceId = 0xF2;
2062 			break;
2063 		default:
2064 			break;
2065 		}
2066 		gnap._actionStatus = -1;
2067 	}
2068 
2069 	if (gameSys.getAnimationStatus(1) == 2) {
2070 		gameSys.setAnimation(0, 0, 1);
2071 		switch (plat._actionStatus) {
2072 		case 4:
2073 			if (gameSys.getAnimationStatus(2) == 2) {
2074 				gameSys.insertSequence(0xFE, plat._id, plat._sequenceId | (plat._sequenceDatNum << 16), plat._id, kSeqSyncWait, 0, 0, 0);
2075 				plat._sequenceId = 0xFE;
2076 				plat._sequenceDatNum = 0;
2077 				gameSys.setAnimation(0xFE, plat._id, 1);
2078 				gameSys.removeSequence(_currKissingLadySequenceId, 1, true);
2079 				plat._actionStatus = 5;
2080 			}
2081 			break;
2082 		case 5:
2083 			_vm->_sceneDone = true;
2084 			_vm->_newSceneNum = 50;
2085 			break;
2086 		default:
2087 			plat._actionStatus = -1;
2088 			break;
2089 		}
2090 	}
2091 
2092 	if (gameSys.getAnimationStatus(2) == 2) {
2093 		if (_nextKissingLadySequenceId == 0xF6) {
2094 			gameSys.insertSequence(_nextKissingLadySequenceId, 1, _currKissingLadySequenceId, 1, kSeqSyncWait, 0, 0, 0);
2095 			plat.initPos(5, 8, kDirIdleLeft);
2096 			_currKissingLadySequenceId = _nextKissingLadySequenceId;
2097 			_nextKissingLadySequenceId = -1;
2098 			gameSys.setAnimation(0, 0, 2);
2099 		} else if (_nextKissingLadySequenceId != -1) {
2100 			gameSys.insertSequence(_nextKissingLadySequenceId, 1, _currKissingLadySequenceId, 1, kSeqSyncWait, 0, 0, 0);
2101 			gameSys.setAnimation(_nextKissingLadySequenceId, 1, 2);
2102 			_currKissingLadySequenceId = _nextKissingLadySequenceId;
2103 			_nextKissingLadySequenceId = -1;
2104 			_vm->_timers[4] = _vm->getRandom(20) + 20;
2105 		}
2106 	}
2107 
2108 	if (gameSys.getAnimationStatus(4) == 2) {
2109 		if (_currSpringGuySequenceId == 0xFB) {
2110 			_vm->setGrabCursorSprite(kItemSpring);
2111 			_nextSpringGuySequenceId = 0xF8;
2112 		}
2113 		if (_nextSpringGuySequenceId != -1) {
2114 			gameSys.insertSequence(_nextSpringGuySequenceId, 1, _currSpringGuySequenceId, 1, kSeqSyncWait, 0, 0, 0);
2115 			gameSys.setAnimation(_nextSpringGuySequenceId, 1, 4);
2116 			_currSpringGuySequenceId = _nextSpringGuySequenceId;
2117 			_nextSpringGuySequenceId = -1;
2118 			_vm->_timers[5] = _vm->getRandom(20) + 20;
2119 		}
2120 	}
2121 
2122 	if (gameSys.getAnimationStatus(3) == 2) {
2123 		switch (_vm->_toyUfoActionStatus) {
2124 		case 6:
2125 			_vm->_sceneDone = true;
2126 			break;
2127 		default:
2128 			_vm->_toyUfoNextSequenceId = _vm->toyUfoGetSequenceId();
2129 			gameSys.insertSequence(_vm->_toyUfoNextSequenceId | 0x10000, _vm->_toyUfoId + 1,
2130 				_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId,
2131 				kSeqSyncWait, 0, _vm->_toyUfoX - 274, _vm->_toyUfoY - 128);
2132 			_vm->_toyUfoSequenceId = _vm->_toyUfoNextSequenceId;
2133 			++_vm->_toyUfoId;
2134 			gameSys.setAnimation(_vm->_toyUfoNextSequenceId | 0x10000, _vm->_toyUfoId, 3);
2135 			break;
2136 		}
2137 		_vm->_toyUfoActionStatus = -1;
2138 	}
2139 }
2140 
2141 /*****************************************************************************/
2142 
Scene45(GnapEngine * vm)2143 Scene45::Scene45(GnapEngine *vm) : Scene(vm) {
2144 	_currDancerSequenceId = -1;
2145 }
2146 
init()2147 int Scene45::init() {
2148 	GameSys& gameSys = *_vm->_gameSys;
2149 
2150 	gameSys.setAnimation(0, 0, 0);
2151 	gameSys.setAnimation(0, 0, 1);
2152 	gameSys.setAnimation(0, 0, 2);
2153 	gameSys.setAnimation(0, 0, 3);
2154 	gameSys.setAnimation(0, 0, 4);
2155 	gameSys.setAnimation(0, 0, 5);
2156 	return _vm->isFlag(kGFUnk23) ? 0xA2 : 0xA1;
2157 }
2158 
updateHotspots()2159 void Scene45::updateHotspots() {
2160 	if (_vm->isFlag(kGFGnapControlsToyUFO)) {
2161 		_vm->setHotspot(kHS45Platypus, 0, 0, 0, 0, SF_DISABLED);
2162 		_vm->setHotspot(kHS45UfoExitLeft, 0, 0, 10, 599, SF_EXIT_L_CURSOR);
2163 		_vm->setHotspot(kHS45UfoExitRight, 794, 0, 799, 599, SF_EXIT_R_CURSOR | SF_DISABLED);
2164 		_vm->setDeviceHotspot(kHS45UfoDevice, -1, 534, -1, 599);
2165 		_vm->_hotspotsCount = 4;
2166 	} else {
2167 		_vm->setHotspot(kHS45Platypus, 0, 0, 0, 0, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
2168 		_vm->setHotspot(kHS45ExitUfoParty, 150, 580, 650, 600, SF_EXIT_D_CURSOR | SF_WALKABLE, 5, 9);
2169 		_vm->setHotspot(kHS45ExitShoe, 0, 100, 10, 599, SF_EXIT_L_CURSOR, 0, 8);
2170 		_vm->setHotspot(kHS45ExitRight, 794, 100, 799, 599, SF_EXIT_R_CURSOR | SF_DISABLED, 10, 8);
2171 		_vm->setHotspot(kHS45ExitDiscoBall, 200, 0, 600, 10, SF_DISABLED);
2172 		_vm->setHotspot(kHS45DiscoBall, 370, 10, 470, 125, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 6, 7);
2173 		_vm->setHotspot(kHS45WalkArea1, 0, 0, 800, 472);
2174 		_vm->setDeviceHotspot(kHS45Device, -1, -1, -1, -1);
2175 		if (_vm->isFlag(kGFUnk22)) {
2176 			_vm->_hotspots[kHS45Platypus]._flags = SF_DISABLED;
2177 			_vm->_hotspots[kHS45ExitUfoParty]._flags = SF_DISABLED;
2178 			_vm->_hotspots[kHS45ExitShoe]._flags = SF_DISABLED;
2179 			_vm->_hotspots[kHS45ExitRight]._flags = SF_DISABLED;
2180 			_vm->_hotspots[kHS45ExitDiscoBall]._flags = SF_EXIT_U_CURSOR;
2181 		}
2182 		if (_vm->isFlag(kGFUnk23) || _vm->isFlag(kGFUnk22))
2183 			_vm->_hotspots[kHS45DiscoBall]._flags = SF_DISABLED;
2184 		_vm->_hotspotsCount = 8;
2185 	}
2186 }
2187 
run()2188 void Scene45::run() {
2189 	GameSys& gameSys = *_vm->_gameSys;
2190 	PlayerGnap& gnap = *_vm->_gnap;
2191 	PlayerPlat& plat = *_vm->_plat;
2192 
2193 	if (!_vm->isSoundPlaying(0x1094A))
2194 		_vm->playSound(0x1094A, true);
2195 
2196 	_vm->queueInsertDeviceIcon();
2197 
2198 	gameSys.insertSequence(0x96, 1, 0, 0, kSeqNone, 0, 0, 0);
2199 	gameSys.setAnimation(0x96, 1, 3);
2200 	gameSys.insertSequence(0x99, 1, 0, 0, kSeqNone, 0, 0, 0);
2201 	gameSys.setAnimation(0x99, 1, 4);
2202 	_currDancerSequenceId = 0x8F;
2203 	gameSys.setAnimation(_currDancerSequenceId, 1, 2);
2204 	gameSys.insertSequence(_currDancerSequenceId, 1, 0, 0, kSeqNone, 0, 0, 0);
2205 
2206 	if (_vm->isFlag(kGFGnapControlsToyUFO)) {
2207 		_vm->_toyUfoId = 0;
2208 		_vm->_toyUfoActionStatus = -1;
2209 		_vm->_toyUfoSequenceId = _vm->toyUfoGetSequenceId();
2210 		_vm->_toyUfoNextSequenceId = _vm->_toyUfoSequenceId;
2211 		if (_vm->_prevSceneNum == 46)
2212 			_vm->_toyUfoX = 30;
2213 		else
2214 			_vm->_toyUfoX = 770;
2215 		gameSys.setAnimation(_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId, 5);
2216 		gameSys.insertSequence(_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId, 0, 0, kSeqNone, 0, _vm->_toyUfoX - 274, _vm->_toyUfoY - 128);
2217 		_vm->endSceneInit();
2218 	} else if (_vm->isFlag(kGFUnk22)) {
2219 		gnap._sequenceId = 0x9E;
2220 		gnap._sequenceDatNum = 0;
2221 		gnap._id = 1;
2222 		gameSys.setAnimation(0x9E, 1, 0);
2223 		gnap._actionStatus = 1;
2224 		gameSys.insertSequence(gnap._sequenceId, gnap._id, 0, 0, kSeqNone, 0, 0, 0);
2225 		plat.initPos(4, 8, kDirIdleLeft);
2226 		_vm->endSceneInit();
2227 	} else if (_vm->_prevSceneNum == 46) {
2228 		gnap.initPos(-1, 8, kDirUpRight);
2229 		plat.initPos(-1, 9, kDirUpLeft);
2230 		_vm->endSceneInit();
2231 		plat.walkTo(Common::Point(4, 8), -1, 0x107C2, 1);
2232 		gnap.walkTo(Common::Point(2, 7), -1, 0x107B9, 1);
2233 	} else if (_vm->_prevSceneNum == 41) {
2234 		gnap.initPos(11, 8, kDirUpRight);
2235 		plat.initPos(11, 9, kDirUpLeft);
2236 		_vm->endSceneInit();
2237 		plat.walkTo(Common::Point(4, 8), -1, 0x107D2, 1);
2238 		gnap.walkTo(Common::Point(10, 9), -1, 0x107BA, 1);
2239 	} else {
2240 		gnap.initPos(2, 11, kDirUpRight);
2241 		plat.initPos(6, 11, kDirUpLeft);
2242 		_vm->endSceneInit();
2243 		plat.walkTo(Common::Point(4, 8), -1, 0x107C2, 1);
2244 		gnap.walkTo(Common::Point(2, 7), -1, 0x107B9, 1);
2245 	}
2246 
2247 	if (!_vm->isFlag(kGFUnk21) && !_vm->isFlag(kGFGnapControlsToyUFO)) {
2248 		_vm->setFlag(kGFUnk21);
2249 		_vm->setGrabCursorSprite(-1);
2250 		gameSys.setAnimation(0x9D, gnap._id, 0);
2251 		gameSys.insertSequence(0x9D, gnap._id, makeRid(gnap._sequenceDatNum, gnap._sequenceId), gnap._id, kSeqSyncWait, 0, 0, 0);
2252 		while (gameSys.getAnimationStatus(0) != 2 && !_vm->_gameDone) {
2253 			_vm->gameUpdateTick();
2254 			if (gameSys.getAnimationStatus(2) == 2) {
2255 				gameSys.setAnimation(0, 0, 2);
2256 				int newSeqId = _vm->getRandom(7) + 0x8F;
2257 				gameSys.insertSequence(newSeqId, 1, _currDancerSequenceId, 1, kSeqSyncWait, 0, 0, 0);
2258 				gameSys.setAnimation(newSeqId, 1, 2);
2259 				_currDancerSequenceId = newSeqId;
2260 			}
2261 			if (gameSys.getAnimationStatus(3) == 2 && gameSys.getAnimationStatus(4) == 2) {
2262 				gameSys.insertSequence(0x96, 1, 0x96, 1, kSeqSyncWait, 0, 0, 0);
2263 				gameSys.setAnimation(0x96, 1, 3);
2264 				gameSys.insertSequence(0x99, 1, 0x99, 1, kSeqSyncWait, 0, 0, 0);
2265 				gameSys.setAnimation(0x99, 1, 4);
2266 			}
2267 		}
2268 		gnap._sequenceId = 0x9D;
2269 		gnap._sequenceDatNum = 0;
2270 		_vm->hideCursor();
2271 		_vm->addFullScreenSprite(0x8A, 255);
2272 		gameSys.setAnimation(0xA0, 256, 0);
2273 		gameSys.insertSequence(0xA0, 256, 0, 0, kSeqNone, 0, 0, 0);
2274 		while (gameSys.getAnimationStatus(0) != 2 && !_vm->_gameDone)
2275 			_vm->gameUpdateTick();
2276 		gameSys.setAnimation(0x107BD, gnap._id, 0);
2277 		gameSys.insertSequence(0x107BD, gnap._id,
2278 			makeRid(gnap._sequenceDatNum, gnap._sequenceId), gnap._id,
2279 			kSeqSyncWait, 0, 75 * gnap._pos.x - gnap._gridX, 48 * gnap._pos.y - gnap._gridY);
2280 		_vm->removeFullScreenSprite();
2281 		_vm->showCursor();
2282 		gnap._sequenceId = 0x7BD;
2283 		gnap._sequenceDatNum = 1;
2284 	}
2285 
2286 	plat.playSequence(0x9A);
2287 	gameSys.setAnimation(plat._sequenceId, plat._id, 1);
2288 
2289 	while (!_vm->_sceneDone) {
2290 		if (!_vm->isSoundPlaying(0x1094A))
2291 			_vm->playSound(0x1094A, true);
2292 
2293 		_vm->updateMouseCursor();
2294 		_vm->updateCursorByHotspot();
2295 
2296 		_vm->testWalk(0, 0, -1, -1, -1, -1);
2297 
2298 		_vm->_sceneClickedHotspot = _vm->getClickedHotspotId();
2299 		_vm->updateGrabCursorSprite(0, 0);
2300 
2301 		if (_vm->isFlag(kGFGnapControlsToyUFO)) {
2302 			switch (_vm->_sceneClickedHotspot) {
2303 			case kHS45UfoExitLeft:
2304 				if (_vm->_toyUfoActionStatus < 0) {
2305 					_vm->_isLeavingScene = true;
2306 					_vm->_toyUfoActionStatus = 2;
2307 					_vm->_newSceneNum = 46;
2308 					_vm->toyUfoFlyTo(-35, -1, -35, 799, 0, 300, 5);
2309 				}
2310 				break;
2311 
2312 			case kHS45UfoExitRight:
2313 				if (_vm->_toyUfoActionStatus < 0) {
2314 					_vm->_isLeavingScene = true;
2315 					_vm->_toyUfoActionStatus = 2;
2316 					_vm->_newSceneNum = 41;
2317 					_vm->toyUfoFlyTo(835, -1, 0, 835, 0, 300, 5);
2318 				}
2319 				break;
2320 
2321 			case kHS45UfoDevice:
2322 				_vm->runMenu();
2323 				updateHotspots();
2324 				break;
2325 
2326 			default:
2327 				break;
2328 			}
2329 		} else {
2330 			switch (_vm->_sceneClickedHotspot) {
2331 			case kHS45Device:
2332 				_vm->runMenu();
2333 				updateHotspots();
2334 				break;
2335 
2336 			case kHS45Platypus:
2337 				if (gnap._actionStatus < 0) {
2338 					if (_vm->_grabCursorSpriteIndex >= 0) {
2339 						gnap.playImpossible(plat._pos);
2340 					} else {
2341 						switch (_vm->_verbCursor) {
2342 						case LOOK_CURSOR:
2343 							gnap.playMoan1(plat._pos);
2344 							break;
2345 						case GRAB_CURSOR:
2346 							gnap.kissPlatypus(0);
2347 							plat.playSequence(0x9A);
2348 							gameSys.setAnimation(plat._sequenceId, plat._id, 1);
2349 							break;
2350 						case TALK_CURSOR:
2351 							gnap.playBrainPulsating(plat._pos);
2352 							plat.playSequence(plat.getSequenceId());
2353 							break;
2354 						case PLAT_CURSOR:
2355 							gnap.playImpossible(plat._pos);
2356 							break;
2357 						default:
2358 							break;
2359 						}
2360 					}
2361 				}
2362 				break;
2363 
2364 			case kHS45ExitUfoParty:
2365 				if (gnap._actionStatus < 0) {
2366 					_vm->_isLeavingScene = true;
2367 					gnap.walkTo(Common::Point(gnap._pos.x, _vm->_hotspotsWalkPos[kHS45ExitUfoParty].y), 0, 0x107AE, 1);
2368 					gnap._actionStatus = 0;
2369 					_vm->_newSceneNum = 40;
2370 				}
2371 				break;
2372 
2373 			case kHS45ExitShoe:
2374 				if (gnap._actionStatus < 0) {
2375 					_vm->_isLeavingScene = true;
2376 					gnap.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS45ExitShoe].x, gnap._pos.y), 0, 0x107AF, 1);
2377 					gnap._actionStatus = 0;
2378 					plat.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS45ExitShoe].x, plat._pos.y), -1, 0x107CF, 1);
2379 					_vm->_newSceneNum = 46;
2380 				}
2381 				break;
2382 
2383 			case kHS45ExitRight:
2384 				if (gnap._actionStatus < 0) {
2385 					_vm->_isLeavingScene = true;
2386 					gnap.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS45ExitRight].x, gnap._pos.y), 0, 0x107AB, 1);
2387 					gnap._actionStatus = 0;
2388 					plat.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS45ExitRight].x, plat._pos.y), -1, 0x107CD, 1);
2389 					_vm->_newSceneNum = 41;
2390 				}
2391 				break;
2392 
2393 			case kHS45ExitDiscoBall:
2394 				_vm->clearFlag(kGFUnk22);
2395 				_vm->setFlag(kGFUnk23);
2396 				_vm->_sceneDone = true;
2397 				_vm->_newSceneNum = 54;
2398 				break;
2399 
2400 			case kHS45DiscoBall:
2401 				if (gnap._actionStatus < 0) {
2402 					if (_vm->_grabCursorSpriteIndex == kItemSpring) {
2403 						gnap.walkTo(_vm->_hotspotsWalkPos[kHS45DiscoBall], 0, 0x9F, 5);
2404 						gnap._actionStatus = 1;
2405 						_vm->setGrabCursorSprite(-1);
2406 						_vm->invRemove(kItemSpring);
2407 					} else if (_vm->_grabCursorSpriteIndex >= 0) {
2408 						gnap.playShowItem(_vm->_grabCursorSpriteIndex, 5, 0);
2409 					} else {
2410 						switch (_vm->_verbCursor) {
2411 						case LOOK_CURSOR:
2412 							gnap.playScratchingHead(Common::Point(5, 0));
2413 							break;
2414 						case GRAB_CURSOR:
2415 						case TALK_CURSOR:
2416 						case PLAT_CURSOR:
2417 							gnap.playImpossible();
2418 							break;
2419 						default:
2420 							break;
2421 						}
2422 					}
2423 				}
2424 				break;
2425 
2426 			case kHS45WalkArea1:
2427 				if (gnap._actionStatus < 0)
2428 					gnap.walkTo(Common::Point(-1, -1), -1, -1, 1);
2429 				break;
2430 
2431 			default:
2432 				break;
2433 			}
2434 		}
2435 
2436 		if (_vm->_mouseClickState._left && gnap._actionStatus < 0) {
2437 			_vm->_mouseClickState._left = false;
2438 			if (_vm->isFlag(kGFGnapControlsToyUFO)) {
2439 				_vm->_toyUfoActionStatus = 3;
2440 				_vm->toyUfoFlyTo(-1, -1, 0, 799, 0, 300, 5);
2441 			} else {
2442 				gnap.walkTo(Common::Point(-1, -1), -1, -1, 1);
2443 			}
2444 		}
2445 
2446 		updateAnimations();
2447 		_vm->toyUfoCheckTimer();
2448 
2449 		if (!_vm->_isLeavingScene && gnap._actionStatus < 0 && !_vm->isFlag(kGFGnapControlsToyUFO))
2450 			gnap.updateIdleSequence();
2451 
2452 		_vm->checkGameKeys();
2453 
2454 		if (_vm->isKeyStatus1(Common::KEYCODE_BACKSPACE)) {
2455 			_vm->clearKeyStatus1(Common::KEYCODE_BACKSPACE);
2456 			_vm->runMenu();
2457 			updateHotspots();
2458 		}
2459 
2460 		_vm->gameUpdateTick();
2461 	}
2462 
2463 	_vm->_sceneWaiting = false;
2464 }
2465 
updateAnimations()2466 void Scene45::updateAnimations() {
2467 	GameSys& gameSys = *_vm->_gameSys;
2468 	PlayerGnap& gnap = *_vm->_gnap;
2469 	PlayerPlat& plat = *_vm->_plat;
2470 
2471 	if (gameSys.getAnimationStatus(0) == 2) {
2472 		gameSys.setAnimation(0, 0, 0);
2473 		switch (gnap._actionStatus) {
2474 		case 0:
2475 			_vm->_sceneDone = true;
2476 			break;
2477 		case 1:
2478 			_vm->_sceneWaiting = true;
2479 			_vm->setFlag(kGFUnk22);
2480 			updateHotspots();
2481 			gameSys.insertSequence(0x9E, gnap._id, makeRid(gnap._sequenceDatNum, gnap._sequenceId), gnap._id, kSeqSyncWait, 0, 0, 0);
2482 			gnap._sequenceId = 0x9E;
2483 			gnap._sequenceDatNum = 0;
2484 			gameSys.setAnimation(0x9E, gnap._id, 0);
2485 			break;
2486 		default:
2487 			gnap._actionStatus = -1;
2488 			break;
2489 		}
2490 	}
2491 
2492 	if (gameSys.getAnimationStatus(1) == 2) {
2493 		gameSys.setAnimation(0, 0, 1);
2494 		if (_vm->getRandom(2) != 0)
2495 			plat.playSequence(0x9B);
2496 		else
2497 			plat.playSequence(0x9C);
2498 		gameSys.setAnimation(plat._sequenceId, plat._id, 1);
2499 	}
2500 
2501 	if (gameSys.getAnimationStatus(2) == 2) {
2502 		gameSys.setAnimation(0, 0, 2);
2503 		int newSeqId = _vm->getRandom(7) + 0x8F;
2504 		gameSys.insertSequence(newSeqId, 1, _currDancerSequenceId, 1, kSeqSyncWait, 0, 0, 0);
2505 		gameSys.setAnimation(newSeqId, 1, 2);
2506 		_currDancerSequenceId = newSeqId;
2507 	}
2508 
2509 	if (gameSys.getAnimationStatus(3) == 2 && gameSys.getAnimationStatus(4) == 2) {
2510 		gameSys.insertSequence(0x96, 1, 0x96, 1, kSeqSyncWait, 0, 0, 0);
2511 		gameSys.setAnimation(0x96, 1, 3);
2512 		gameSys.insertSequence(0x99, 1, 0x99, 1, kSeqSyncWait, 0, 0, 0);
2513 		gameSys.setAnimation(0x99, 1, 4);
2514 	}
2515 
2516 	if (gameSys.getAnimationStatus(5) == 2) {
2517 		switch (_vm->_toyUfoActionStatus) {
2518 		case 2:
2519 			_vm->_sceneDone = true;
2520 			break;
2521 		default:
2522 			_vm->_toyUfoNextSequenceId = _vm->toyUfoGetSequenceId();
2523 			gameSys.insertSequence(_vm->_toyUfoNextSequenceId | 0x10000, _vm->_toyUfoId + 1,
2524 				_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId,
2525 				kSeqSyncWait, 0, _vm->_toyUfoX - 274, _vm->_toyUfoY - 128);
2526 			_vm->_toyUfoSequenceId = _vm->_toyUfoNextSequenceId;
2527 			++_vm->_toyUfoId;
2528 			gameSys.setAnimation(_vm->_toyUfoNextSequenceId | 0x10000, _vm->_toyUfoId, 5);
2529 			break;
2530 		}
2531 		_vm->_toyUfoActionStatus = -1;
2532 	}
2533 }
2534 
2535 /*****************************************************************************/
2536 
Scene46(GnapEngine * vm)2537 Scene46::Scene46(GnapEngine *vm) : Scene(vm) {
2538 	_currSackGuySequenceId = -1;
2539 	_nextItchyGuySequenceId = -1;
2540 	_nextSackGuySequenceId = -1;
2541 	_currItchyGuySequenceId = -1;
2542 }
2543 
init()2544 int Scene46::init() {
2545 	GameSys& gameSys = *_vm->_gameSys;
2546 
2547 	gameSys.setAnimation(0, 0, 0);
2548 	gameSys.setAnimation(0, 0, 1);
2549 	gameSys.setAnimation(0, 0, 2);
2550 	gameSys.setAnimation(0, 0, 3);
2551 	gameSys.setAnimation(0, 0, 4);
2552 	return 0x4E;
2553 }
2554 
updateHotspots()2555 void Scene46::updateHotspots() {
2556 	if (_vm->isFlag(kGFGnapControlsToyUFO)) {
2557 		_vm->setHotspot(kHS46Platypus, 0, 0, 0, 0, SF_DISABLED);
2558 		_vm->setHotspot(kHS46UfoExitLeft, 0, 0, 10, 599, SF_EXIT_L_CURSOR);
2559 		_vm->setHotspot(kHS46UfoExitRight, 790, 0, 799, 599, SF_EXIT_R_CURSOR);
2560 		_vm->setDeviceHotspot(kHS46UfoDevice, -1, 534, -1, 599);
2561 		_vm->_hotspotsCount = 4;
2562 	} else {
2563 		_vm->setHotspot(kHS46Platypus, 0, 0, 0, 0, SF_WALKABLE | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR);
2564 		_vm->setHotspot(kHS46ExitUfoParty, 150, 580, 650, 600, SF_EXIT_D_CURSOR | SF_WALKABLE, 5, 9);
2565 		_vm->setHotspot(kHS46ExitKissinBooth, 0, 100, 10, 599, SF_EXIT_L_CURSOR, 0, 8);
2566 		_vm->setHotspot(kHS46ExitDisco, 790, 100, 799, 599, SF_EXIT_R_CURSOR, 10, 8);
2567 		_vm->setHotspot(kHS46SackGuy, 180, 370, 235, 490, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 3, 8);
2568 		_vm->setHotspot(kHS46ItchyGuy, 535, 210, 650, 480, SF_PLAT_CURSOR | SF_TALK_CURSOR | SF_GRAB_CURSOR | SF_LOOK_CURSOR, 6, 8);
2569 		_vm->setHotspot(kHS46WalkArea1, 0, 0, 800, 485);
2570 		_vm->setDeviceHotspot(kHS46Device, -1, -1, -1, -1);
2571 		_vm->_hotspotsCount = 8;
2572 	}
2573 }
2574 
run()2575 void Scene46::run() {
2576 	GameSys& gameSys = *_vm->_gameSys;
2577 	PlayerGnap& gnap = *_vm->_gnap;
2578 	PlayerPlat& plat = *_vm->_plat;
2579 
2580 	_vm->queueInsertDeviceIcon();
2581 	gameSys.insertSequence(0x4D, 0, 0, 0, kSeqLoop, 0, 0, 0);
2582 
2583 	_currSackGuySequenceId = 0x4B;
2584 	_nextSackGuySequenceId = -1;
2585 	gameSys.setAnimation(0x4B, 1, 3);
2586 	gameSys.insertSequence(_currSackGuySequenceId, 1, 0, 0, kSeqNone, 0, 0, 0);
2587 
2588 	_currItchyGuySequenceId = 0x47;
2589 	_nextItchyGuySequenceId = -1;
2590 	gameSys.setAnimation(0x47, 1, 4);
2591 	gameSys.insertSequence(_currItchyGuySequenceId, 1, 0, 0, kSeqNone, 0, 0, 0);
2592 
2593 	if (_vm->isFlag(kGFGnapControlsToyUFO)) {
2594 		_vm->_toyUfoId = 0;
2595 		_vm->_toyUfoActionStatus = -1;
2596 		_vm->_toyUfoSequenceId = _vm->toyUfoGetSequenceId();
2597 		_vm->_toyUfoNextSequenceId = _vm->_toyUfoSequenceId;
2598 		if (_vm->_prevSceneNum == 44)
2599 			_vm->_toyUfoX = 30;
2600 		else
2601 			_vm->_toyUfoX = 770;
2602 		gameSys.setAnimation(_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId, 2);
2603 		gameSys.insertSequence(_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId, 0, 0, kSeqNone, 0, _vm->_toyUfoX - 274, _vm->_toyUfoY - 128);
2604 		_vm->endSceneInit();
2605 	} else if (_vm->_prevSceneNum == 44) {
2606 		gnap.initPos(-1, 8, kDirUpRight);
2607 		plat.initPos(-1, 8, kDirUpLeft);
2608 		_vm->endSceneInit();
2609 		plat.walkTo(Common::Point(1, 8), -1, 0x107C2, 1);
2610 		gnap.walkTo(Common::Point(2, 8), -1, 0x107B9, 1);
2611 	} else if (_vm->_prevSceneNum == 45) {
2612 		gnap.initPos(11, 8, kDirUpRight);
2613 		plat.initPos(12, 8, kDirUpLeft);
2614 		_vm->endSceneInit();
2615 		gnap.walkTo(Common::Point(8, 8), -1, 0x107BA, 1);
2616 		plat.walkTo(Common::Point(9, 8), -1, 0x107D2, 1);
2617 	} else {
2618 		gnap.initPos(5, 11, kDirUpRight);
2619 		plat.initPos(6, 11, kDirUpLeft);
2620 		_vm->endSceneInit();
2621 		plat.walkTo(Common::Point(5, 8), -1, 0x107C2, 1);
2622 		gnap.walkTo(Common::Point(6, 8), -1, 0x107BA, 1);
2623 	}
2624 
2625 	_vm->_timers[4] = _vm->getRandom(50) + 80;
2626 	_vm->_timers[5] = _vm->getRandom(50) + 80;
2627 
2628 	while (!_vm->_sceneDone) {
2629 		if (!_vm->isSoundPlaying(0x1094B))
2630 			_vm->playSound(0x1094B, true);
2631 
2632 		_vm->updateMouseCursor();
2633 		_vm->updateCursorByHotspot();
2634 
2635 		_vm->testWalk(0, 0, -1, -1, -1, -1);
2636 
2637 		_vm->_sceneClickedHotspot = _vm->getClickedHotspotId();
2638 		_vm->updateGrabCursorSprite(0, 0);
2639 
2640 		if (_vm->isFlag(kGFGnapControlsToyUFO)) {
2641 			switch (_vm->_sceneClickedHotspot) {
2642 			case kHS46UfoExitLeft:
2643 				if (_vm->_toyUfoActionStatus < 0) {
2644 					_vm->_isLeavingScene = true;
2645 					_vm->_toyUfoActionStatus = 3;
2646 					_vm->_newSceneNum = 44;
2647 					_vm->toyUfoFlyTo(-35, -1, -35, 799, 0, 300, 2);
2648 				}
2649 				break;
2650 
2651 			case kHS46UfoExitRight:
2652 				if (_vm->_toyUfoActionStatus < 0) {
2653 					_vm->_isLeavingScene = true;
2654 					_vm->_toyUfoActionStatus = 3;
2655 					_vm->_newSceneNum = 45;
2656 					_vm->toyUfoFlyTo(835, -1, 0, 835, 0, 300, 2);
2657 				}
2658 				break;
2659 
2660 			case kHS46UfoDevice:
2661 				_vm->runMenu();
2662 				updateHotspots();
2663 				break;
2664 
2665 			default:
2666 				break;
2667 			}
2668 		} else {
2669 			switch (_vm->_sceneClickedHotspot) {
2670 			case kHS46Device:
2671 				_vm->runMenu();
2672 				updateHotspots();
2673 				break;
2674 
2675 			case kHS46Platypus:
2676 				if (gnap._actionStatus < 0) {
2677 					if (_vm->_grabCursorSpriteIndex >= 0) {
2678 						gnap.playImpossible(plat._pos);
2679 					} else {
2680 						switch (_vm->_verbCursor) {
2681 						case LOOK_CURSOR:
2682 							gnap.playMoan1(plat._pos);
2683 							break;
2684 						case GRAB_CURSOR:
2685 							gnap.kissPlatypus(0);
2686 							break;
2687 						case TALK_CURSOR:
2688 							gnap.playBrainPulsating(plat._pos);
2689 							plat.playSequence(plat.getSequenceId());
2690 							break;
2691 						case PLAT_CURSOR:
2692 							gnap.playImpossible(plat._pos);
2693 							break;
2694 						default:
2695 							break;
2696 						}
2697 					}
2698 				}
2699 				break;
2700 
2701 			case kHS46SackGuy:
2702 				if (_vm->_grabCursorSpriteIndex >= 0) {
2703 					gnap.playShowCurrItem(_vm->_hotspotsWalkPos[kHS46SackGuy], 2, 0);
2704 				} else {
2705 					switch (_vm->_verbCursor) {
2706 					case LOOK_CURSOR:
2707 						gnap.playMoan1(Common::Point(_vm->_hotspotsWalkPos[kHS46SackGuy].x + 1, 0));
2708 						break;
2709 					case TALK_CURSOR:
2710 						gnap._idleFacing = kDirUpLeft;
2711 						gnap.walkTo(_vm->_hotspotsWalkPos[kHS46SackGuy], 0, gnap.getSequenceId(kGSBrainPulsating, Common::Point(0, 0)) | 0x10000, 1);
2712 						gnap._actionStatus = 2;
2713 						break;
2714 					case GRAB_CURSOR:
2715 					case PLAT_CURSOR:
2716 						gnap.playImpossible();
2717 						break;
2718 					default:
2719 						break;
2720 					}
2721 				}
2722 				break;
2723 
2724 			case kHS46ItchyGuy:
2725 				if (_vm->_grabCursorSpriteIndex >= 0) {
2726 					gnap.playShowCurrItem(_vm->_hotspotsWalkPos[kHS46ItchyGuy], 7, 0);
2727 				} else {
2728 					switch (_vm->_verbCursor) {
2729 					case LOOK_CURSOR:
2730 						gnap.playMoan1(Common::Point(_vm->_hotspotsWalkPos[kHS46ItchyGuy].x - 1, 0));
2731 						break;
2732 					case TALK_CURSOR:
2733 						gnap._idleFacing = kDirUpRight;
2734 						gnap.walkTo(_vm->_hotspotsWalkPos[kHS46ItchyGuy], 0, gnap.getSequenceId(kGSBrainPulsating, Common::Point(0, 0)) | 0x10000, 1);
2735 						gnap._actionStatus = 1;
2736 						break;
2737 					case GRAB_CURSOR:
2738 					case PLAT_CURSOR:
2739 						gnap.playImpossible();
2740 						break;
2741 					default:
2742 						break;
2743 					}
2744 				}
2745 				break;
2746 
2747 			case kHS46ExitUfoParty:
2748 				_vm->_isLeavingScene = true;
2749 				gnap.walkTo(Common::Point(gnap._pos.x, _vm->_hotspotsWalkPos[kHS46ExitUfoParty].y), 0, 0x107AE, 1);
2750 				gnap._actionStatus = 0;
2751 				_vm->_newSceneNum = 40;
2752 				break;
2753 
2754 			case kHS46ExitKissinBooth:
2755 				_vm->_isLeavingScene = true;
2756 				gnap.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS46ExitKissinBooth].x, gnap._pos.y), 0, 0x107AF, 1);
2757 				gnap._actionStatus = 0;
2758 				plat.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS46ExitKissinBooth].x, plat._pos.y), -1, 0x107CF, 1);
2759 				_vm->_newSceneNum = 44;
2760 				break;
2761 
2762 			case kHS46ExitDisco:
2763 				_vm->_isLeavingScene = true;
2764 				gnap.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS46ExitDisco].x, gnap._pos.y), 0, 0x107AB, 1);
2765 				gnap._actionStatus = 0;
2766 				plat.walkTo(Common::Point(_vm->_hotspotsWalkPos[kHS46ExitDisco].x, plat._pos.y), -1, 0x107CD, 1);
2767 				_vm->_newSceneNum = 45;
2768 				break;
2769 
2770 			case kHS46WalkArea1:
2771 				if (gnap._actionStatus < 0)
2772 					gnap.walkTo(Common::Point(-1, -1), -1, -1, 1);
2773 				break;
2774 
2775 			default:
2776 				break;
2777 			}
2778 		}
2779 
2780 		if (_vm->_mouseClickState._left && gnap._actionStatus < 0) {
2781 			_vm->_mouseClickState._left = false;
2782 			if (_vm->isFlag(kGFGnapControlsToyUFO)) {
2783 				_vm->_toyUfoActionStatus = 4;
2784 				_vm->toyUfoFlyTo(-1, -1, 0, 799, 0, 300, 2);
2785 			} else {
2786 				gnap.walkTo(Common::Point(-1, -1), -1, -1, 1);
2787 			}
2788 		}
2789 
2790 		updateAnimations();
2791 		_vm->toyUfoCheckTimer();
2792 
2793 		if (!_vm->_isLeavingScene) {
2794 			if (plat._actionStatus < 0 && !_vm->isFlag(kGFGnapControlsToyUFO))
2795 				plat.updateIdleSequence();
2796 			if (gnap._actionStatus < 0 && !_vm->isFlag(kGFGnapControlsToyUFO))
2797 				gnap.updateIdleSequence();
2798 			if (!_vm->_timers[4]) {
2799 				_vm->_timers[4] = _vm->getRandom(50) + 80;
2800 				if (gnap._actionStatus < 0 && plat._actionStatus < 0 && _nextItchyGuySequenceId == -1) {
2801 					if (_vm->getRandom(2) != 0)
2802 						_nextItchyGuySequenceId = 0x49;
2803 					else
2804 						_nextItchyGuySequenceId = 0x48;
2805 				}
2806 			}
2807 			if (!_vm->_timers[5]) {
2808 				_vm->_timers[5] = _vm->getRandom(50) + 80;
2809 				if (gnap._actionStatus < 0 && plat._actionStatus < 0 && _nextSackGuySequenceId == -1)
2810 					_nextSackGuySequenceId = 0x4C;
2811 			}
2812 		}
2813 
2814 		_vm->checkGameKeys();
2815 
2816 		if (_vm->isKeyStatus1(Common::KEYCODE_BACKSPACE)) {
2817 			_vm->clearKeyStatus1(Common::KEYCODE_BACKSPACE);
2818 			_vm->runMenu();
2819 			updateHotspots();
2820 		}
2821 
2822 		_vm->gameUpdateTick();
2823 	}
2824 }
2825 
updateAnimations()2826 void Scene46::updateAnimations() {
2827 	GameSys& gameSys = *_vm->_gameSys;
2828 	PlayerGnap& gnap = *_vm->_gnap;
2829 
2830 	if (gameSys.getAnimationStatus(0) == 2) {
2831 		gameSys.setAnimation(0, 0, 0);
2832 		switch (gnap._actionStatus) {
2833 		case 0:
2834 			_vm->_sceneDone = true;
2835 			break;
2836 		case 1:
2837 			_nextItchyGuySequenceId = 0x46;
2838 			break;
2839 		case 2:
2840 			_nextSackGuySequenceId = 0x4A;
2841 			break;
2842 		default:
2843 			break;
2844 		}
2845 		gnap._actionStatus = -1;
2846 	}
2847 
2848 	if (gameSys.getAnimationStatus(3) == 2 && _nextSackGuySequenceId != -1) {
2849 		gameSys.insertSequence(_nextSackGuySequenceId, 1, _currSackGuySequenceId, 1, kSeqSyncWait, 0, 0, 0);
2850 		gameSys.setAnimation(_nextSackGuySequenceId, 1, 3);
2851 		_currSackGuySequenceId = _nextSackGuySequenceId;
2852 		_nextSackGuySequenceId = -1;
2853 		_vm->_timers[5] = _vm->getRandom(50) + 80;
2854 	}
2855 
2856 	if (gameSys.getAnimationStatus(4) == 2 && _nextItchyGuySequenceId != -1) {
2857 		gameSys.insertSequence(_nextItchyGuySequenceId, 1, _currItchyGuySequenceId, 1, kSeqSyncWait, 0, 0, 0);
2858 		gameSys.setAnimation(_nextItchyGuySequenceId, 1, 4);
2859 		_currItchyGuySequenceId = _nextItchyGuySequenceId;
2860 		_nextItchyGuySequenceId = -1;
2861 		_vm->_timers[4] = _vm->getRandom(50) + 80;
2862 	}
2863 
2864 	if (gameSys.getAnimationStatus(2) == 2) {
2865 		switch (_vm->_toyUfoActionStatus) {
2866 		case 3:
2867 			_vm->_sceneDone = true;
2868 			break;
2869 		default:
2870 			_vm->_toyUfoNextSequenceId = _vm->toyUfoGetSequenceId();
2871 			gameSys.insertSequence(_vm->_toyUfoNextSequenceId | 0x10000, _vm->_toyUfoId + 1,
2872 				_vm->_toyUfoSequenceId | 0x10000, _vm->_toyUfoId,
2873 				kSeqSyncWait, 0, _vm->_toyUfoX - 274, _vm->_toyUfoY - 128);
2874 			_vm->_toyUfoSequenceId = _vm->_toyUfoNextSequenceId;
2875 			++_vm->_toyUfoId;
2876 			gameSys.setAnimation(_vm->_toyUfoNextSequenceId | 0x10000, _vm->_toyUfoId, 2);
2877 			break;
2878 		}
2879 		_vm->_toyUfoActionStatus = -1;
2880 	}
2881 }
2882 
2883 } // End of namespace Gnap
2884