aboutsummaryrefslogtreecommitdiff
path: root/engines/gnap/gnap.h
blob: aa8de62de149c3b72f0afd3d2403b0e936158e77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

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

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

#ifndef GNAP_H
#define GNAP_H

#include "common/array.h"
#include "common/events.h"
#include "common/file.h"
#include "common/memstream.h"
#include "common/random.h"
#include "common/savefile.h"
#include "common/serializer.h"
#include "common/str.h"
#include "common/substream.h"
#include "common/system.h"
#include "common/winexe.h"
#include "common/winexe_pe.h"
#include "engines/engine.h"
#include "graphics/pixelformat.h"
#include "graphics/wincursor.h"

#include "gnap/debugger.h"
#include "gnap/resource.h"
#include "gnap/scenes/scenecore.h"

struct ADGameDescription;

namespace Gnap {

class DatManager;
class SequenceResource;
class SpriteResource;
class GameSys;
class SoundMan;

#define GNAP_SAVEGAME_VERSION 1

struct MouseButtonState {
	bool _left;
	bool _right;
	MouseButtonState() : _left(false), _right(false) {
	}
};

struct Hotspot {
	int16 _x1, _y1, _x2, _y2;
	uint16 _flags;
	int _id;
	bool isPointInside(int16 x, int16 y) const {
		return x >= _x1 && x <= _x2 && y >= _y1 && y <= _y2;
	}
	bool isFlag(uint16 flag) const {
		return (_flags & flag) != 0;
	}
};

struct GridStruct {
	int _deltaX, _deltaY;
	int _gridX1, _gridY1;
	int _sequenceId;
	int _id;
};

const int kMaxGridStructs = 30;
const int kMaxTimers = 10;

enum GnapDebugChannels {
	kDebugBasic	= 1 << 0
};

enum {
	SF_NONE             = 0x0000,
	SF_LOOK_CURSOR		= 0x0001,
	SF_GRAB_CURSOR		= 0x0002,
	SF_TALK_CURSOR		= 0x0004,
	SF_PLAT_CURSOR		= 0x0008,
	SF_DISABLED			= 0x0010,
	SF_WALKABLE			= 0x0020,
	SF_EXIT_L_CURSOR	= 0x0040,
	SF_EXIT_R_CURSOR	= 0x0080,
	SF_EXIT_U_CURSOR	= 0x0100,
	SF_EXIT_D_CURSOR	= 0x0200,
	SF_EXIT_NW_CURSOR	= 0x0400,
	SF_EXIT_NE_CURSOR	= 0x0800,
	SF_EXIT_SW_CURSOR	= 0x1000,
	SF_EXIT_SE_CURSOR	= 0x2000
};

enum {
	LOOK_CURSOR		= 0,
	GRAB_CURSOR		= 1,
	TALK_CURSOR		= 2,
	PLAT_CURSOR		= 3,
	NOLOOK_CURSOR	= 4,
	NOGRAB_CURSOR	= 5,
	NOTALK_CURSOR	= 6,
	NOPLAT_CURSOR	= 7,
	EXIT_L_CURSOR	= 8,
	EXIT_R_CURSOR	= 9,
	EXIT_U_CURSOR	= 10,
	EXIT_D_CURSOR	= 11,
	EXIT_NE_CURSOR	= 12,
	EXIT_NW_CURSOR	= 13,
	EXIT_SE_CURSOR	= 14,
	EXIT_SW_CURSOR	= 15,
	WAIT_CURSOR		= 16
};

enum {
	gskPullOutDevice			= 0,
	gskPullOutDeviceNonWorking	= 1,
	gskIdle						= 2,
	gskBrainPulsating			= 3,
	gskImpossible				= 4,
	gskScratchingHead			= 5,
	gskDeflect					= 6,
	gskUseDevice				= 7,
	gskMoan1					= 8,
	gskMoan2					= 9
};

enum {
	kItemMagazine			= 0,
	kItemMud				= 1,
	kItemGrass				= 2,
	kItemDisguise			= 3,
	kItemNeedle				= 4,
	kItemTwig				= 5,
	kItemGas				= 6,
	kItemKeys				= 7,
	kItemDice				= 8,
	kItemTongs				= 9,
	kItemQuarter			= 10,
	kItemQuarterWithHole	= 11,
	kItemDiceQuarterHole	= 12,
	kItemWrench				= 13,
	kItemCowboyHat			= 14,
	kItemGroceryStoreHat	= 15,
	kItemBanana				= 16,
	kItemTickets			= 17,
	kItemPicture			= 18,
	kItemEmptyBucket		= 19,
	kItemBucketWithBeer		= 20,
	kItemBucketWithPill		= 21,
	kItemPill				= 22,
	kItemHorn				= 23,
	kItemJoint				= 24,
	kItemChickenBucket		= 25,
	kItemGum				= 26,
	kItemSpring				= 27,
	kItemLightbulb			= 28,
	kItemCereals			= 29
};

enum {
	kGFPlatypus				= 0,
	kGFMudTaken				= 1,
	kGFNeedleTaken			= 2,
	kGFTwigTaken			= 3,
	kGFUnk04				= 4,
	kGFKeysTaken			= 5,
	kGFGrassTaken			= 6,
	kGFBarnPadlockOpen		= 7,
	kGFTruckFilledWithGas	= 8,
	kGFTruckKeysUsed		= 9,
	kGFPlatyPussDisguised	= 10,
	kGFSceneFlag1			= 11,
	kGFGnapControlsToyUFO	= 12,
	kGFUnk13				= 13, // Tongue Fight Won?
	kGFUnk14				= 14,
	kGFSpringTaken			= 15,
	kGFUnk16				= 16,
	kGFJointTaken			= 17,
	kGFUnk18				= 18,
	kGFGroceryStoreHatTaken	= 19,
	kGFPictureTaken			= 20,
	kGFUnk21				= 21,
	kGFUnk22				= 22,
	kGFUnk23				= 23,
	kGFUnk24				= 24,
	kGFUnk25				= 25,
	kGFPlatypusTalkingToAssistant = 26,
	kGFUnk27				= 27,
	kGFUnk28				= 28,
	kGFGasTaken				= 29,
	kGFUnk30				= 30,
	kGFUnk31				= 31
};

/*
	Game flags
		0	1			With Platypus
		1	2			Mud taken
		2	4			Needle taken
		3	8			Twig taken
		4	0x10
		5	0x20		Keys taken
		6	0x40		Grass taken
		7	0x80		Barn padlock open
		8	0x100		Truck filled with gas
		9	0x200		Truck keys used
		10	0x400		Platypus disguised
		11	0x800		Scene flag 1
		12	0x1000		Gnap controls toy ufo
		13	0x2000
		14	0x4000
		15	0x8000		Spring taken
		16	0x10000
		17	0x20000		Joint taken
		18	0x40000
		19	0x80000		Grocery store hat taken
		20	0x100000	Picture taken
		21	0x200000
		22	0x400000
		23	0x800000
		24	0x1000000
		25	0x2000000
		26	0x4000000	Platypus talking with toy shop assistant
		27	0x8000000
		28	0x10000000
		29	0x20000000	Gas taken
		30	0x40000000
		31	0x80000000


*/

	// 0x7AB	Gnap walks to the right 1
	// 0x7AC	Gnap walks to the right 2
	// 0x7AF	Gnap walks to the left 1
	// 0x7B0	Gnap walks to the left 2

struct Scene49Obstacle {
	int _currSequenceId;
	int _closerSequenceId;
	int _passedSequenceId;
	int _splashSequenceId;
	int _collisionSequenceId;
	int _prevId;
	int _currId;
	int _laneNum;
};

struct Scene51Item {
	int _currSequenceId;
	int _droppedSequenceId;
	int _x, _y;
	int _collisionX;
	bool _canCatch;
	bool _isCollision;
	int _x2;
	int _id;
};

enum Facing {
	kDirNone = 0,
	kDirBottomRight = 1,
	kDirBottomLeft = 3,
	kDirUnk4 = 4,
	kDirUpLeft = 5,
	kDirUpRight = 7
};

struct GnapSavegameHeader {
	uint8 _version;
	Common::String _saveName;
	Graphics::Surface *_thumbnail;
	int _year, _month, _day;
	int _hour, _minute;
};

class GnapEngine : public Engine {
protected:
	Common::Error run();
	virtual bool hasFeature(EngineFeature f) const;
public:
	GnapEngine(OSystem *syst, const ADGameDescription *gd);
	~GnapEngine();
private:
	const ADGameDescription *_gameDescription;
	Graphics::PixelFormat _pixelFormat;
	int _loadGameSlot;

public:	
	Common::RandomSource *_random;
	
	Common::PEResources *_exe;
	
	DatManager *_dat;
	SpriteCache *_spriteCache;
	SoundCache *_soundCache;
	SequenceCache *_sequenceCache;
	GameSys *_gameSys;
	SoundMan *_soundMan;
	Debugger *_debugger;
	Scene *_scene;

	int _lastUpdateClock;
	
	int _debugLevel;
	bool _gameDone;
	
	byte _keyPressState[512];
	byte _keyDownState[512];
	
	bool _isPaused;
	Graphics::Surface *_pauseSprite;
	int _timers[kMaxTimers], _savedTimers[kMaxTimers];
	
	MouseButtonState _mouseButtonState;
	MouseButtonState _mouseClickState;
	
	uint32 _keyStatus1[2];
	
	bool _sceneSavegameLoaded, _wasSavegameLoaded;
	
	Graphics::Surface *_backgroundSurface;
	int _prevSceneNum, _currentSceneNum, _newSceneNum;	
	bool _sceneDone, _sceneWaiting;

	uint32 _inventory, _gameFlags;
	
	Hotspot _hotspots[20];
	Common::Point _hotspotsWalkPos[20];
	int _hotspotsCount;
	int _sceneClickedHotspot;
	
	bool _isWaiting;
	bool _isLeavingScene;
	
	bool _isStockDatLoaded;

	int _newCursorValue, _cursorValue;

	int _verbCursor, _cursorIndex;
	int _mouseX, _mouseY;
	int _leftClickMouseX, _leftClickMouseY;
	
	Graphics::Surface *_grabCursorSprite;
	int _currGrabCursorX, _currGrabCursorY;
	int _grabCursorSpriteIndex, _newGrabCursorSpriteIndex;
	
	Graphics::Surface *_fullScreenSprite;
	int _fullScreenSpriteId;
	
	int _deviceX1, _deviceY1, _deviceX2, _deviceY2;
	
	int _soundTimerIndexA;
	int _soundTimerIndexB;
	int _soundTimerIndexC;
	int _idleTimerIndex;
	
	void updateEvents();
	void gameUpdateTick();
	void saveTimers();
	void restoreTimers();
	
	void pauseGame();
	void resumeGame();
	void updatePause();
	
	int getRandom(int max);
	
	int readSavegameDescription(int savegameNum, Common::String &description);
	int loadSavegame(int savegameNum);
	Common::Error saveGameState(int slot, const Common::String &desc);
	Common::Error loadGameState(int slot);
	Common::String generateSaveName(int slot);
	void synchronize(Common::Serializer &s);
	void writeSavegameHeader(Common::OutSaveFile *out, GnapSavegameHeader &header);
	static bool readSavegameHeader(Common::InSaveFile *in, GnapSavegameHeader &header);
	
	void delayTicks(int a1);
	void delayTicksCursor(int a1);
	
	void setHotspot(int index, int16 x1, int16 y1, int16 x2, int16 y2, uint16 flags = 0,
		int16 walkX = -1, int16 walkY = -1);
	int getHotspotIndexAtPos(int16 x, int16 y);
	void updateCursorByHotspot();
	int getClickedHotspotId();
	
	int getInventoryItemSpriteNum(int index);
	
	void updateMouseCursor();
	void setVerbCursor(int verbCursor);
	void setCursor(int cursorIndex);
	void showCursor();
	void hideCursor();
	
	void setGrabCursorSprite(int index);
	void createGrabCursorSprite(int spriteId);
	void freeGrabCursorSprite();
	void updateGrabCursorSprite(int x, int y);
	
	void invClear();
	void invAdd(int itemId);
	void invRemove(int itemId);
	bool invHas(int itemId);
	
	void clearFlags();
	void setFlag(int num);
	void clearFlag(int num);
	bool isFlag(int num);
	
	Graphics::Surface *addFullScreenSprite(int resourceId, int id);
	void removeFullScreenSprite();
	void showFullScreenSprite(int resourceId);
	
	void queueInsertDeviceIcon();
	void insertDeviceIconActive();
	void removeDeviceIconActive();
	void setDeviceHotspot(int hotspotIndex, int x1, int y1, int x2, int y2);
	
	int getSequenceTotalDuration(int resourceId);
	
	bool isSoundPlaying(int resourceId);
	void playSound(int resourceId, bool looping);
	void stopSound(int resourceId);
	void setSoundVolume(int resourceId, int volume);

	void updateTimers();
	
	void initGameFlags(int num);
	void loadStockDat();

	void mainLoop();
	void initScene();
	void endSceneInit();
	void afterScene();
	
	int initSceneLogic();
	void runSceneLogic();
	
	void checkGameKeys();
	
	void startSoundTimerA(int timerIndex);
	int playSoundA();
	void startSoundTimerB(int timerIndex);
	int playSoundB();
	void startSoundTimerC(int timerIndex);
	int playSoundC();
	void startIdleTimer(int timerIndex);
	void updateIdleTimer();
	
	void screenEffect(int dir, byte r, byte g, byte b);
	
	bool isKeyStatus1(int key);
	bool isKeyStatus2(int key);
	void clearKeyStatus1(int key);
	void clearAllKeyStatus1();
	
	void deleteSurface(Graphics::Surface **surface);
	
	// Menu
	int _menuStatus;
	int _menuSpritesIndex;
	bool _menuDone;
	Graphics::Surface *_menuBackgroundSurface;
	Graphics::Surface *_menuQuitQuerySprite;
	Graphics::Surface *_largeSprite;
	Graphics::Surface *_menuSaveLoadSprite;
	Graphics::Surface *_menuSprite2;
	Graphics::Surface *_menuSprite1;	
	char _savegameFilenames[7][30];
	Graphics::Surface *_savegameSprites[7];
	Graphics::Surface *_spriteHandle;
	Graphics::Surface *_cursorSprite;
	int _menuInventoryIndices[30];
	Graphics::Surface *_menuInventorySprites[30];
	int _savegameIndex;
	void createMenuSprite();
	void freeMenuSprite();
	void initMenuHotspots1();
	void initMenuHotspots2();
	void initMenuQuitQueryHotspots();
	void initSaveLoadHotspots();
	void drawInventoryFrames();
	void insertInventorySprites();
	void removeInventorySprites();	
	void runMenu();
	void updateMenuStatusInventory();
	void updateMenuStatusMainMenu();
	void updateMenuStatusSaveGame();
	void updateMenuStatusLoadGame();
	void updateMenuStatusQueryQuit();
	
	// Grid common
	int _gnapGridX, _gnapGridY;
	int _platGridX, _platGridY;
	int _gridMinX, _gridMinY;
	int _gridMaxX, _gridMaxY;
	bool isPointBlocked(int gridX, int gridY);
	void initSceneGrid(int gridMinX, int gridMinY, int gridMaxX, int gridMaxY);
	bool testWalk(int animationIndex, int someStatus, int gridX1, int gridY1, int gridX2, int gridY2);

	// Gnap walking
	int _gnapWalkNodesCount;
	GridStruct _gnapWalkNodes[kMaxGridStructs];
	int _gnapX, _gnapY;
	int _gnapWalkDestX, _gnapWalkDestY;
	int _gnapWalkDeltaX, _gnapWalkDeltaY, _gnapWalkDirX, _gnapWalkDirY, _gnapWalkDirXIncr, _gnapWalkDirYIncr;

	int getGnapWalkSequenceId(int deltaX, int deltaY);
	int getGnapWalkStopSequenceId(int deltaX, int deltaY);
	Facing getGnapWalkFacing(int deltaX, int deltaY);
	bool gridSub41F08B(int gridX, int gridY);
	bool gridSub41F5FC(int gridX, int gridY, int index);
	bool gridSub41FAD5(int gridX, int gridY, int index);
	bool gnapFindPath3(int gridX, int gridY);
	bool gnapWalkTo(int gridX, int gridY, int animationIndex, int sequenceId, int flags);
	void gnapWalkStep();
	
	// Platypus walking
	int _platWalkNodesCount;
	GridStruct _platWalkNodes[kMaxGridStructs];
	int _platX, _platY;
	int _platWalkDestX, _platWalkDestY;
	int _platWalkDeltaX, _platWalkDeltaY, _platWalkDirX, _platWalkDirY, _platWalkDirXIncr, _platWalkDirYIncr;
	
	int getPlatypusWalkSequenceId(int deltaX, int deltaY);
	bool gridSub423750(int gridX, int gridY);
	bool gridSub423CC1(int gridX, int gridY, int index);
	bool gridSub42419A(int gridX, int gridY, int index);
	bool platFindPath3(int gridX, int gridY);
	bool platypusWalkTo(int gridX, int gridY, int animationIndex, int sequenceId, int flags);
	void platypusWalkStep();
	void platypusMakeRoom();

	// Gnap
	Facing _gnapIdleFacing;
	int _gnapActionStatus;
	int _gnapBrainPulseNum, _gnapBrainPulseRndValue;
	int _gnapSequenceId, _gnapSequenceDatNum, _gnapId;

	int getGnapSequenceId(int kind, int gridX, int gridY);
	int getGnapShowSequenceId(int index, int gridX, int gridY);
	void gnapIdle();
	void gnapActionIdle(int sequenceId);
	void playGnapSequence(int sequenceId);
	void playGnapImpossible(int gridX, int gridY);
	void playGnapScratchingHead(int gridX, int gridY);
	void playGnapMoan1(int gridX, int gridY);
	void playGnapMoan2(int gridX, int gridY);
	void playGnapBrainPulsating(int gridX, int gridY);
	void playGnapPullOutDevice(int gridX, int gridY);
	void playGnapPullOutDeviceNonWorking(int gridX, int gridY);
	void playGnapUseDevice(int gridX, int gridY);
	void playGnapIdle(int gridX, int gridY);
	void playGnapShowItem(int itemIndex, int gridLookX, int gridLookY);
	void playGnapShowCurrItem(int gridX, int gridY, int gridLookX, int gridLookY);
	void updateGnapIdleSequence();
	void updateGnapIdleSequence2();
	void initGnapPos(int gridX, int gridY, Facing facing);
	void gnapInitBrainPulseRndValue();
	void gnapUseDeviceOnPlatypuss();
	void doCallback(int callback);
	bool gnapPlatypusAction(int gridX, int gridY, int platSequenceId, int callback);
	void gnapKissPlatypus(int callback);
	void gnapUseJointOnPlatypus();
	void gnapUseDisguiseOnPlatypus();
	
	// Platypus
	Facing _platypusFacing;
	int _platypusActionStatus;
	int _platypusSequenceId, _platypusSequenceDatNum, _platypusId;
	int getPlatypusSequenceId();
	void playPlatypusSequence(int sequenceId);
	void updatePlatypusIdleSequence();
	void platypusSub426234();
	void initPlatypusPos(int gridX, int gridY, Facing facing);
	
	// Scenes
	
	int _toyUfoNextSequenceId, _toyUfoSequenceId;
	int _toyUfoId;
	int _toyUfoActionStatus;
	int _toyUfoX;
	int _toyUfoY;
	
	void initGlobalSceneVars();

    bool sceneXX_sub_4466B1();
	void sceneXX_playRandomSound(int timerIndex);
	void playSequences(int fullScreenSpriteId, int sequenceId1, int sequenceId2, int sequenceId3);

	// Shared by scenes 17 & 18
	int _s18_garbageCanPos;

	// Scene 4x
	void toyUfoSetStatus(int flagNum);
	int toyUfoGetSequenceId();
	bool toyUfoCheckTimer();
	void toyUfoFlyTo(int destX, int destY, int minX, int maxX, int minY, int maxY, int animationIndex);

	// Scene 49
	int _s49_scoreBarPos, _s49_scoreLevel;
	bool _s49_scoreBarFlash;
	int _s49_obstacleIndex;
	Scene49Obstacle _s49_obstacles[5];
	int _s49_truckSequenceId, _s49_truckId, _s49_truckLaneNum;
	int scene49_init();
	void scene49_updateHotspots();
	void scene49_checkObstacles();
	void scene49_updateObstacle(int id);
	void scene49_increaseScore(int amount);
	void scene49_decreaseScore(int amount);
	void scene49_refreshScoreBar();
	void scene49_clearObstacle(int index);
	void scene49_run();
	void scene49_updateAnimations();

	// Scene 50
	bool _s50_fightDone;
	int _s50_timesPlayed, _s50_timesPlayedModifier;
	int _s50_attackCounter;
	int _s50_roundNum, _s50_timeRemaining;
	int _s50_leftTongueRoundsWon, _s50_rightTongueRoundsWon;
	int _s50_leftTongueEnergyBarPos, _s50_rightTongueEnergyBarPos;
	int _s50_leftTongueSequenceId, _s50_leftTongueId;
	int _s50_leftTongueNextSequenceId, _s50_leftTongueNextId, _s50_leftTongueNextIdCtr;
	int _s50_rightTongueSequenceId, _s50_rightTongueId;
	int _s50_rightTongueNextSequenceId, _s50_rightTongueNextId, _s50_rightTongueNextIdCtr;
	int _s50_leftTongueEnergy, _s50_rightTongueEnergy;
	int scene50_init();
	void scene50_updateHotspots();
	bool scene50_tongueWinsRound(int tongueNum);
	void scene50_playWinAnim(int tongueNum, bool fightOver);
	void scene50_delayTicks();
	void scene50_initRound();
	bool scene50_updateCountdown();
	void scene50_drawCountdown(int value);
	void scene50_playTonguesIdle();
	void scene50_playRoundAnim(int roundNum);
	bool scene50_updateEnergyBars(int newLeftBarPos, int newRightBarPos);
	void scene50_waitForAnim(int animationIndex);
	int scene50_checkInput();
	int scene50_getRightTongueAction();
	void scene50_updateAnimations();
	int scene50_getRightTongueActionTicks();
	int scene50_getLeftTongueNextId();
	int scene50_getRightTongueNextId();
	void scene50_playWinBadgeAnim(int tongueNum);
	void scene50_run();
	
	// Scene 51
	int _s51_cashAmount;
	int _s51_digits[4];
	int _s51_digitSequenceIds[4];
	int _s51_guySequenceId, _s51_guyNextSequenceId;
	int _s51_itemsCaughtCtr;
	int _s51_dropSpeedTicks;
	int _s51_nextDropItemKind, _s51_itemInsertX, _s51_itemInsertDirection;
	int _s51_platypusSequenceId, _s51_platypusNextSequenceId, _s51_platypusJumpSequenceId;
	bool _s51_dropLoseCash;
	int _s51_itemsCtr,_s51_itemsCtr1, _s51_itemsCtr2;
	Scene51Item _s51_items[6];

	int scene51_init();
	void scene51_updateHotspots();
	void scene51_clearItem(Scene51Item *item);
	void scene51_dropNextItem();
	void scene51_updateItemAnimations();
	int scene51_checkCollision(int sequenceId);
	void scene51_updateItemAnimation(Scene51Item *item, int index);
	void scene51_removeCollidedItems();
	int scene51_itemIsCaught(Scene51Item *item);
	bool scene51_isJumpingRight(int sequenceId);
	bool scene51_isJumpingLeft(int sequenceId);
	bool scene51_isJumping(int sequenceId);
	void scene51_waitForAnim(int animationIndex);
	int scene51_getPosRight(int sequenceId);
	int scene51_getPosLeft(int sequenceId);
	void scene51_playIntroAnim();
	void scene51_updateGuyAnimation();
	int scene51_incCashAmount(int sequenceId);
	void scene51_winMinigame();
	void scene51_playCashAppearAnim();
	void scene51_updateCash(int amount);
	void scene51_drawDigit(int digit, int position);
	void scene51_initCashDisplay();
	void scene51_run();
	
	// Scene 52
	int _s52_liveAlienRows;
	int _s52_gameScore;
	bool _s52_soundToggle;
	int _s52_arcadeScreenLeft;
	int _s52_arcadeScreenRight;
	int _s52_arcadeScreenBottom;
	int _s52_shipsLeft;
	int _s52_shieldSpriteIds[3];
	int _s52_shieldPosX[3];
	int _s52_shipPosX;
	int _s52_shipCannonPosX, _s52_shipCannonPosY;
	bool _s52_shipCannonFiring;
	bool _s52_shipCannonFired; 
	int _s52_shipCannonWidth, _s52_shipCannonHeight;
	int _s52_shipCannonTopY;
	int _s52_shipMidX, _s52_shipMidY;
	bool _s52_shipFlag;
	bool _s52_aliensInitialized;
	int _s52_alienSpeed, _s52_alienDirection;
	int _s52_alienWidth, _s52_alienHeight;
	int _s52_alienLeftX, _s52_alienTopY;
	int _s52_alienRowDownCtr;
	int _s52_alienRowKind[7];
	int _s52_alienRowAnims[7];
	int _s52_alienRowIds[7];
	int _s52_alienRowXOfs[7];
	int _s52_alienCannonFired[3];
	int _s52_alienCannonPosX[3];
	int _s52_alienCannonPosY[3];
	int _s52_alienCannonSequenceIds[3];
	int _s52_alienCannonIds[3];
	bool _s52_alienWave, _s52_alienSingle;
	int _s52_alienCounter;
	bool _s52_bottomAlienFlag;
	int _s52_aliensCount;
	int _s52_items[8][5];
	int _s52_nextUfoSequenceId, _s52_ufoSequenceId;
	int scene52_init();
	void scene52_updateHotspots();
	void scene52_update();
	void scene52_initShipCannon(int bottomY);
	void scene52_initAlienCannons();
	void scene52_fireShipCannon(int posX);
	void scene52_fireAlienCannon();
	int scene52_getFreeShipCannon();
	int scene52_getFreeAlienCannon();
	void scene52_updateShipCannon();
	void scene52_updateAlienCannons();
	void scene52_initAliens();
	void scene52_initAlienRowKind(int rowNum, int alienKind);
	void scene52_insertAlienRow(int rowNum);
	void scene52_insertAlienRowAliens(int rowNum);
	void scene52_updateAlienRow(int rowNum);
	void scene52_moveDownAlienRow();
	int scene52_updateHitAlien();
	int scene52_getHitAlienNum(int rowNum);
	int scene52_alienCannonHitShip(int cannonNum);
	int scene52_alienCannonHitShield(int cannonNum);
	bool scene52_shipCannonHitShield(int cannonNum);
	bool scene52_shipCannonHitAlien();
	void scene52_shipExplode();
	bool scene52_checkAlienRow(int rowNum);
	void scene52_updateAlienRowXOfs();
	void scene52_initAlienSize();
	void scene52_playSound();
	void scene52_updateAliens();
	void scene52_updateAlien(int rowNum);
	void scene52_loseShip();
	void scene52_initShields();
	void scene52_initAnims();
	void scene52_drawScore(int score);
	void scene52_run();
	
	// Scene 53
	int _s53_currHandSequenceId;
	bool _s53_isGnapPhoning;
	int _s53_callsMadeCtr;
	uint _s53_callsRndUsed;
	int scene53_init();
	void scene53_updateHotspots();
	int scene53_pressPhoneNumberButton(int phoneNumber, int buttonNum);
	int scene53_getRandomCallIndex();
	void scene53_runRandomCall();
	void scene53_runChitChatLine();
	void scene53_run();

	// Scene 54
	void scene54_initCutscene1();
	void scene54_initCutscene2();
};

} // End of namespace Gnap

#endif // GNAP_H