ScummVM API documentation
carnival.h
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 modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (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, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef CARNIVAL_CARNIVAL_H
23#define CARNIVAL_CARNIVAL_H
24
25#include "bolt/bolt.h"
26
27namespace Bolt {
28
29namespace Carnival {
30
31class CarnivalEngine;
32typedef int16 (CarnivalEngine::*SideShowHandler)(int16 prevBooth);
33
35 SideShowHandler *handlers;
36 int16 count;
37 int16 minIndex;
38 int16 maxIndex;
39};
40
41typedef struct FredEntityState {
42 uint16 flags;
43 int16 frameCountdown;
44 int16 animMode;
45 int16 frameIndex;
46 byte *animTable;
47 int16 direction;
48 int32 xPos;
49 int32 yPos;
50 int32 prevXPos;
51 int32 prevYPos;
52 int16 speed;
53 byte *pathTable;
54 int16 pathIndex;
55
57 flags = 0;
58 frameCountdown = 0;
59 animMode = 0;
60 frameIndex = 0;
61 animTable = nullptr;
62 direction = 0;
63 xPos = 0;
64 yPos = 0;
65 prevXPos = 0;
66 prevYPos = 0;
67 speed = 0;
68 pathTable = nullptr;
69 pathIndex = 0;
70 }
72
73// HUCK GAME
74
75typedef struct HuckState {
76 int16 levelNumber;
77 int16 slotIndex[10];
78 int16 levelComplete;
79 int16 drawTable1[24];
80 int16 drawTable2[24];
81 int16 giftCount;
82 int16 hasCycle;
83 int16 selectionPending;
84 int16 selected1Slot;
85 int16 selected2Slot;
86 int16 selected1SpriteId;
87 int16 selected2SpriteId;
88
89 HuckState() {
90 levelNumber = 0;
91 memset(slotIndex, 0, sizeof(slotIndex));
92 levelComplete = 0;
93 memset(drawTable1, 0, sizeof(drawTable1));
94 memset(drawTable2, 0, sizeof(drawTable2));
95 giftCount = 0;
96 hasCycle = 0;
97 selectionPending = 0;
98 selected1Slot = 0;
99 selected2Slot = 0;
100 selected1SpriteId = 0;
101 selected2SpriteId = 0;
102 }
103} HuckState;
104
105// GEORGE GAME
106
107typedef struct GeorgeEntityState {
108 uint16 flags;
109 int16 frameCountdown;
110 int16 animMode;
111 int16 variant;
112 int16 frameIndex;
113 byte *animTable;
114 int32 joyInput;
115 int32 x;
116 int32 y;
117 int32 prevX;
118 int32 prevY;
119 int32 velX;
120 int32 velY;
121 int32 accelX;
122 int32 accelY;
123 byte *pathTable;
124 int16 pathIndex;
125
127 flags = 0;
128 frameCountdown = 0;
129 animMode = 0;
130 variant = 0;
131 frameIndex = 0;
132 animTable = nullptr;
133 joyInput = 0;
134 x = 0;
135 y = 0;
136 prevX = 0;
137 prevY = 0;
138 velX = 0;
139 velY = 0;
140 accelX = 0;
141 accelY = 0;
142 pathTable = nullptr;
143 pathIndex = 0;
144 }
146
147// SCOOBY GAME
148
149typedef struct ScoobyState {
150 int16 levelNumber;
151 int16 slotIndex[10];
152 int16 levelComplete;
153 int16 wallStates[25][4];
154 int16 scoobyCell;
155 int16 scoobySavedCell;
156 int16 leftNeighbor;
157 int16 rightNeighbor;
158 int16 upNeighbor;
159 int16 downNeighbor;
160 int16 activeLevel;
161 int16 scoobyX;
162 int16 scoobyY;
163 int16 velocityX;
164 int16 velocityY;
165 int16 targetVelocityX;
166 int16 targetVelocityY;
167 int16 transitionTarget;
168 int16 currentAnim;
169 int16 direction;
170 int16 spriteFrameCount;
171 byte *frameData[6];
172
173 ScoobyState() {
174 levelNumber = 0;
175
176 for (int i = 0; i < 10; i++)
177 slotIndex[i] = 0;
178
179 levelComplete = 0;
180
181 for (int i = 0; i < 25; i++)
182 for (int j = 0; j < 4; j++)
183 wallStates[i][j] = 0;
184
185 scoobyCell = 0;
186 scoobySavedCell = 0;
187 leftNeighbor = 0;
188 rightNeighbor = 0;
189 upNeighbor = 0;
190 downNeighbor = 0;
191 activeLevel = 0;
192 scoobyX = 0;
193 scoobyY = 0;
194 velocityX = 0;
195 velocityY = 0;
196 targetVelocityX = 0;
197 targetVelocityY = 0;
198 transitionTarget = 0;
199 currentAnim = 0;
200 direction = 0;
201 spriteFrameCount = 0;
202
203 for (int i = 0; i < 6; i++)
204 frameData[i] = nullptr;
205 }
207
208typedef struct ScoobyRect {
209 int16 left;
210 int16 right;
211 int16 top;
212 int16 bottom;
213
214 ScoobyRect() {
215 left = 0;
216 right = 0;
217 top = 0;
218 bottom = 0;
219 }
220} ScoobyRect;
221
222// TOPCAT GAME
223
224typedef struct TopCatAnim {
225 int16 animType;
226 int16 animIndex;
227 int16 transitionToNextQuestionFlag;
228 int16 *seqPtr;
229
230 TopCatAnim() {
231 animType = 0;
232 animIndex = 0;
233 transitionToNextQuestionFlag = 0;
234 seqPtr = nullptr;
235 }
236} TopCatAnim;
237
238// YOGI GAME
239
240typedef struct YogiState {
241 int16 levelNumber;
242 int16 currentSlot;
243 int16 levelIndex[10];
244 int16 slotIndex[10];
245 int16 levelComplete;
246 int16 basketSound[24];
247 int16 basketState[24];
248 int16 basketCount;
249 int16 matchCount;
250 int16 selectionPending;
251 int16 selected1Slot;
252 int16 selected2Slot;
253 int16 sound1;
254 int16 sound2;
255
256 YogiState() {
257 levelNumber = 0;
258 currentSlot = 0;
259 memset(levelIndex, 0, sizeof(levelIndex));
260 memset(slotIndex, 0, sizeof(slotIndex));
261 levelComplete = 0;
262 memset(basketSound, 0, sizeof(basketSound));
263 memset(basketState, 0, sizeof(basketState));
264 basketCount = 0;
265 matchCount = 0;
266 selectionPending = 0;
267 selected1Slot = 0;
268 selected2Slot = 0;
269 sound1 = 0;
270 sound2 = 0;
271 }
272} YogiState;
273
275public:
276 CarnivalEngine(OSystem *syst, const ADGameDescription *gameDesc);
277
278protected:
279 // xpMain
280 void boltMain() override;
281 int16 displayDemoPict(int16 prevBooth);
282
283 void initCallbacks() override;
284
285 // Booth
286 void startCycle(byte *cycleResource);
287 void displayBooth(int16 page);
288 void playAVOverBooth(int16 animIndex);
289 int16 hucksBooth(int16 prevBooth);
290 int16 fredsBooth(int16 prevBooth);
291 int16 scoobysBooth(int16 prevBooth);
292 int16 yogisBooth(int16 prevBooth);
293 int16 georgesBooth(int16 prevBooth);
294 int16 topCatsBooth(int16 prevBooth);
295 int16 mainEntrance(int16 prevBooth);
296 bool loadBooth(int16 boothId);
297 void unloadBooth();
298 int16 openBooth(int16 boothId);
299 void closeBooth();
300 void playTour();
301 void finishPlayingHelp(int16 activeHotspot);
302 int16 hotSpotActive(int16 hotspot);
303 void hoverHotSpot();
304 int16 boothEventLoop();
305 void resetInactivityState();
306 bool handleButtonPress(int16 hotspot);
307 void blastColors(byte **paletteTable, int16 index, int16 mode);
308 void setColors(int16 index);
309 void restoreColors(int16 index);
310 void loadColors();
311 void shiftColorMap(byte *colorMap, int16 delta);
312 void playBoothAV();
313 void mainEntranceHelpBlink();
314 void boothHelpBlink();
315 void tourPaletteCycleStep();
316 void fadeToBlack(int16 steps);
317 void flushInput();
318 int16 winALetter(int16 prevBooth);
319 int16 endDemo(int16 prevBooth);
320
321 int16 _lettersWon = 0;
322 bool _allLettersWonFlag = false;
323 int _displayMode = 0;
324 int32 _displayX = 0;
325 int32 _displayY = 0;
326 int32 _displayWidth = 0;
327 int32 _displayHeight = 0;
328
329 int16 _boothLoadedMask = 0;
330 int16 _currentBoothScene = 0;
331 int16 _boothNumHotspots = 0;
332 int16 _boothNumAnimations = 0;
333 byte *_boothSceneDesc = nullptr;
334 byte *_boothHotPalDescs[4];
335 Common::Rect _boothHotspotDescs[8];
336 byte *_boothAnimDescs[7];
337 byte *_boothAnimPalDescs[4];
338 byte _savedPalettes[7][30];
339 byte _savedHotPalettes[4][9];
340 byte *_boothPalCycleData = nullptr;
341 XPPicDesc _boothLetterSprite;
342 bool _needInitCursorPos = true;
343 byte *_boothVisitSignOn = nullptr;
344 byte *_boothVisitSignOff = nullptr;
345 byte _leftDoorNavTable[3] = { 3, 2, 4 };
346 byte _rightDoorNavTable[3] = { 1, 0, 5 };
347
348 int16 _cursorX = 0;
349 int16 _cursorY = 0;
350 int16 _hoveredHotspot = 0;
351 uint32 _helpTimer = 0;
352 int16 _keyReleased = 0;
353 int16 _keyLeft = 0;
354 int16 _keyRight = 0;
355 int16 _keyUp = 0;
356 int16 _keyDown = 0;
357 int16 _helpFlag = 0;
358 int16 _keyEnter = 0;
359
360 int16 _tourStep = 0;
361 int16 _helpPlaying = 0;
362 int16 _helpIsIdle = 0;
363 int16 _idleHelpAudioAvailable = 1;
364
365 int16 _huckWins = 0;
366 int16 _fredWins = 0;
367 int16 _scoobyWins = 0;
368 int16 _yogiWins = 0;
369 int16 _georgeWins = 0;
370 int16 _topCatWins = 0;
371
372 // Barker
373 BarkerTable *createBarker(int16 minIndex, int16 maxIndex);
374 void freeBarker(BarkerTable *table);
375 bool registerSideShow(BarkerTable *table, SideShowHandler handler, int16 boothId);
376 int16 barker(BarkerTable *table, int16 startBooth);
377 bool checkError();
378
379 int16 _currentBoothId = 0;
380
381 // --- MINIGAMES ---
382
383 // --- FRED ---
384 int16 fredGame(int16 prevBooth);
385 bool initFred();
386 void cleanUpFred();
387 bool initFredLevel(int16 levelGroup, int16 palGroup);
388 void termFredLevel(int16 levelGroup, int16 palGroup);
389 void swapFredAnimEntry();
390 void swapFredAnimDesc();
391 void swapFredLevelDesc();
392 int16 playFred();
393 int16 helpFred();
394 void hiliteFredHelpObject(byte *entry, int16 highlight);
395 void helpAnimStep();
396 bool spawnBalloon();
397 int16 calcBalloonSpawnDelay();
398 int16 selectBalloonRow();
399 void setFredAnimMode(FredEntityState *state, int16 mode);
400 void renderFredScene();
401 void getFredSoundInfo(BOLTLib *lib, int16 memberId, SoundInfo *soundInfo);
402 void playFredSound(SoundInfo *oneShot, SoundInfo *loop);
403 void updateFredSound();
404
405 static void resolveAllRefsCb();
406 static void swapFredAnimEntryCb();
407 static void swapFredAnimDescCb();
408 static void swapFredLevelDescCb();
409
410 BOLTLib *_fredBoltLib = nullptr;
411 BOLTCallbacks _fredBoltCallbacks;
412
413 static BOLTCallback _fredTypeLoadCallbacks[28];
414 static BOLTCallback _fredTypeFreeCallbacks[28];
415
416 byte *_fredLevelPtr = nullptr;
417 byte *_fredBackground = nullptr;
418 byte *_fredBalloonString = nullptr;
419 byte *_fredPalette = nullptr;
420 byte *_fredFacingLeftRect = nullptr;
421 byte *_fredFacingRightRect = nullptr;
422 byte *_fredTurningRect = nullptr;
423 byte *_fredBalloonRect = nullptr;
424 byte *_fredHelpEntries = nullptr;
425 byte *_fredPlayButton = nullptr;
426 byte *_fredSprites[10] = { nullptr };
427 FredEntityState **_fredEntitiesTable = nullptr;
428
429 byte *_fredRowBounds = nullptr;
430 byte *_fredShuffleTable = nullptr;
431 byte *_fredCycleRaw = nullptr;
432 byte *_fredBalloonSprite = nullptr;
433 byte *_fredPathMatrix = nullptr;
434 byte *_fredCurrentHelpObject = nullptr;
435 byte *_fredHoveredEntry = nullptr;
436
437 SoundInfo _fredSounds[4];
438
439 SoundInfo *_fredCurrentSound = nullptr;
440 SoundInfo *_fredLoopSound = nullptr;
441 SoundInfo *_fredPendingOneShot = nullptr;
442 SoundInfo *_fredPendingLoop = nullptr;
443
444 FredEntityState _fredSprite;
445
446 int16 _fredSaveData[3] = { 0, 0, 0 };
447 int16 _fredLevelIndex = 0;
448
449 int16 _fredBalloonSpawnDelay = 0;
450 int16 _fredBalloonSearchIdx = 0;
451 uint32 _fredTimer = 0;
452 int16 _fredHelpStep = -1;
453 int16 _fredShowHelp = 1;
454
455 XPCycleState _fredCycleSpecs[4];
456
457 // --- GEORGE ---
458 int16 georgeGame(int16 prevBooth);
459 bool initGeorge();
460 void cleanUpGeorge();
461 bool initGeorgeLevel(int16 level, int16 variant);
462 void termGeorgeLevel(int16 level, int16 variant);
463 void swapGeorgeFrameArray();
464 void swapGeorgeHelpEntry();
465 void swapGeorgeThresholds();
466 int16 playGeorge();
467 int16 helpGeorge();
468 void hiliteGeorgeHelpObject(byte *entry, int16 highlight);
469 void advanceHelpAnimation();
470 bool spawnSatellite();
471 int16 getRandomSatelliteWait();
472 int16 getRandomAsteroidRow();
473 bool confirmAsteroidHitTest();
474 bool spawnAsteroid();
475 int16 getRandomAsteroidWait();
476 int16 getAsteroidRow();
477 void setGeorgeAnimMode(GeorgeEntityState *sat, int16 mode);
478 void setSatelliteAnimMode(GeorgeEntityState *sat, int16 mode, int16 variant);
479 void setAsteroidAnimMode(GeorgeEntityState *sat, int16 mode, int16 variant);
480 void drawFlyingObjects();
481 void getGeorgeSoundInfo(BOLTLib *boltLib, int16 member, SoundInfo *outInfo, byte priority);
482 void playGeorgeSound(SoundInfo *newSound, SoundInfo *nextSound);
483 void updateGeorgeSound();
484
485 static void swapGeorgeFrameArrayCb();
486 static void swapGeorgeHelpEntryCb();
487 static void swapGeorgeThresholdsCb();
488
489 BOLTLib *_georgeBoltLib = nullptr;
490 BOLTCallbacks _georgeBoltCallbacks;
491
492 static BOLTCallback _georgeTypeLoadCallbacks[28];
493 static BOLTCallback _georgeTypeFreeCallbacks[28];
494
495 byte *_georgePrevActiveHelpObject = nullptr;
496 byte *_georgeActiveHelpObject = nullptr;
497 int16 _georgeHelpStep = -1;
498 int16 _georgeHelpActive = 1;
499
500 GeorgeEntityState **_georgeEntityList = nullptr;
501 int16 _georgeCarIdx = 0;
502 int16 _georgeNumSatellites = 0;
503 int16 _georgeFirstAsteroidIdx = 0;
504 int16 _georgeTotalSatellites = 0;
505 byte *_georgeCarPics[3] = { nullptr };
506 byte *_georgeHelpObjects = nullptr;
507 byte *_georgeHelpSequence = nullptr;
508 uint32 _georgeHelpTimer = 0;
509 byte *_georgeSatelliteShuffleTable = nullptr;
510 byte *_georgeAsteroidShuffleTable = nullptr;
511 int16 *_georgeSatelliteThresholds = nullptr;
512 int16 *_georgeAsteroidThresholds = nullptr;
513 byte *_georgeSatellitePaths = nullptr;
514 byte *_georgeAsteroidPaths = nullptr;
515 byte *_georgeCollisionRect = nullptr;
516 byte *_georgeSatelliteCollisionRects = nullptr;
517 byte *_georgeAsteroidCollisionRects = nullptr;
518 byte *_georgeSatelliteGfx = nullptr;
519 byte *_georgeAsteroidGfx = nullptr;
520 int16 _georgeSatelliteWait = 0;
521 int16 _georgeAsteroidWait = 0;
522 int16 _georgeSatelliteSearchIdx = 0;
523 int16 _georgeAsteroidSearchIdx = 0;
524 int16 _georgeHitSearchIdx = 0;
525 byte *_georgeBgPic = nullptr;
526 byte *_georgePalette = nullptr;
527 byte *_georgePalCycleRawData = nullptr;
528 XPCycleState _georgePalCycleSpecs[4];
529 int16 _georgeCollectedSatellitesNum = 0;
530 SoundInfo _georgeSoundCarStartUp;
531 SoundInfo _georgeSoundCarGoesAway;
532 SoundInfo _georgeSoundCarLoopHi;
533 SoundInfo _georgeSoundCarLoopLo;
534 SoundInfo _georgeSoundCarTumble;
535 SoundInfo **_georgeSatelliteSoundList = nullptr;
536 byte _georgeSoundChannelCounter = 0;
537 SoundInfo *_georgeSoundToPlay = nullptr;
538 SoundInfo *_georgeSoundCurrent = nullptr;
539 SoundInfo *_georgeSoundQueued = nullptr;
540 SoundInfo *_georgeSoundNext = nullptr;
541 int16 _georgeSaveData[3] = { 0 };
542 int16 *_georgeThresholds = nullptr;
543
544 // --- HUCK ---
545 void playSoundMapHuck(int16 memberId);
546 void waitSoundMapHuck();
547 void setHuckColors(int16 which);
548 void restoreHuckColors(int16 which);
549 void startHuckShuffleTimer();
550 void drawGift(int16 slot);
551 void drawHuckGifts();
552 void checkHuckLevelComplete();
553 bool initHuckDisplay();
554 bool loadHuckResources();
555 void unloadHuckResources();
556 bool initHuckLevel();
557 bool resumeHuckLevel();
558 bool initHuck();
559 void huckToggleBlinking(int16 *state, int16 which);
560 void huckUpdateHotSpots(int16 x, int16 y);
561 int16 findGift(int16 x, int16 y);
562 bool handleGiftSelect(int16 x, int16 y);
563 void huckHandleActionButton(int16 x, int16 y);
564 void giftSwap();
565 void resolveHuckSelection();
566 void handleEvent(int16 eventType, uint32 eventData);
567 void playHuck();
568 void cleanUpHuck();
569 int16 huckGame(int16 prevBooth);
570 void swapHuckWordArray();
571 void swapHuckWords();
572
573 static void swapHuckWordArrayCb();
574 static void swapHuckWordsCb();
575
576 BOLTLib *_huckBoltLib = nullptr;
577 BOLTCallbacks _huckBoltCallbacks;
578
579 static BOLTCallback _huckTypeLoadCallbacks[27];
580 static BOLTCallback _huckTypeFreeCallbacks[27];
581
582 int16 _huckSoundPlaying = 0;
583 int16 _huckHotSpotCount = 0;
584 int16 _huckActionState = 0;
585 uint32 _huckScreensaverTimer = 0;
586 uint32 _huckBlinkTimer = 0;
587 int16 _huckScreensaverFlag = 0;
588 int16 _huckBlinkFlag = 0;
589 uint32 _huckShuffleTimer = 0;
590 int16 _huckGlobal[30] = { 0 };
591 HuckState _huckState;
592 byte *_huckGiftPic = nullptr;
593 byte *_huckBgPic = nullptr;
594 int16 _huckGiftGroupId = 0;
595 int16 _huckVariantGroupId = 0;
596 byte *_huckBgDisplayPic = nullptr;
597 int16 _huckScrollOffset = 0;
598 int16 _huckPalRange[8] = { 0 };
599 int16 _huckReturnBooth = 0;
600 int16 _huckExitFlag = 0;
601 int16 _huckCursorX = 0;
602 int16 _huckCursorY = 0;
603 byte _huckPalSave0[15] = { 0 };
604 byte _huckPalHighlight0[15] = { 0 };
605 byte _huckPalSave1[15] = { 0 };
606 byte _huckPalHighlight1[15] = { 0 };
607 XPPicDesc _huckScratchPic;
608
609 // --- SCOOBY ---
610 bool loadScoobyBaseAssets();
611 void cleanUpScoobyBaseAssets();
612 void displayPicClipHack(byte *pic, int16 offsetX, int16 offsetY, int16 *clipRect, int16 displayMode);
613 void drawMovingWalls(int16 cellIdx, int16 direction, int16 picFrame, int16 bgFrame);
614 void drawAllMovingWalls();
615 void animateTransition(int16 memberIdx);
616 void clearPictMSb(byte *pic);
617 void initScoobyLevelGraphics();
618 bool initScoobyLevelAssets();
619 void cleanUpScoobyLevelGraphics();
620 void setScoobySpriteDirection(int16 startMember);
621 void playSoundMapScooby(int16 memberIdx);
622 void playWallSound();
623 void animateWalls();
624 void decideDirection();
625 void updateScoobySound();
626 void setScoobySound(int16 mode);
627 void updateScoobyLocation();
628 void updateScoobyWalls();
629 void updateScoobyDirection(int16 inputDir);
630 void updateScoobyTransition();
631 bool initScoobyLevel();
632 bool resumeScoobyLevel();
633 bool initScooby();
634 void cleanUpScooby();
635 int16 helpScooby();
636 void hiliteScoobyHelpObject(byte *entry, int16 highlight);
637 int16 xpDirToBOLTDir(uint32 xpDir);
638 int16 playScooby();
639 int16 scoobyGame(int16 prevBooth);
640 void swapScoobyHelpEntry();
641 void swapScoobyWordArray();
642
643 static void swapScoobyHelpEntryCb();
644 static void swapScoobyWordArrayCb();
645
646 BOLTLib *_scoobyBoltLib = nullptr;
647 BOLTCallbacks _scoobyBoltCallbacks;
648
649 static BOLTCallback _scoobyTypeLoadCallbacks[28];
650 static BOLTCallback _scoobyTypeFreeCallbacks[28];
651
652 int16 _scoobySoundMode = 0;
653 int16 _scoobySoundPlaying = 0;
654 int16 _scoobyShowHelp = 1;
655
656 int16 _scoobyLastInputDir = 0;
657 int16 _scoobyTransitionFrom = 0;
658 int16 _scoobyTransitionTarget = 0;
659 int16 _scoobyTransitionVelX = 0;
660 int16 _scoobyTransitionVelY = 0;
661 XPPicDesc _scoobyTempPic;
662 byte _scoobyGlobalSaveData[0x3C] = { 0 };
663 ScoobyState _scoobyGameState;
664 SSprite _scoobySprite;
665 byte *_scoobyBaseData = nullptr;
666 byte *_scoobyBgPic = nullptr;
667 byte *_scoobyWallPicsA[4] = { nullptr };
668 byte *_scoobyWallPicsB[5] = { nullptr };
669 ScoobyRect _scoobyCellBounds[25];
670 Common::Point _scoobyLevelStartXY[25];
671 byte *_scoobyLevelData = nullptr;
672 int16 _scoobySelectedGraphicsGroup = 0;
673 int16 _scoobyDifficulty = 0;
674 int16 _scoobyLevelCount = 0;
675 int16 _scoobyMoveRequested = 0;
676 int16 _scoobyTransitioning = 0;
677 int16 _scoobyDesiredDir = 0;
678 int16 _scoobyInputHoldCount = 0;
679 int16 _scoobyWallAnimating = 0;
680 int16 _scoobyWallAnimStep = 0;
681 int16 _scoobyWallsToOpen = 0;
682 int16 _scoobyWallsToClose = 0;
683
684 // --- TOPCAT ---
685 int16 topCatGame(int16 prevBooth);
686 bool initTopCat();
687 void cleanUpTopCat();
688 int16 playTopCat();
689 int16 handleActionButton(int16 *result);
690 void queueAnim(int16 animType, int16 param);
691 bool maintainAnim(int16 soundEvent);
692 void maintainIdleSound(int16 decrement);
693 bool startNextAnim(int16 *playAnswerAnim);
694 void setAnimType(int16 newType);
695 void highlightObject(byte *entry, int16 highlight);
696 bool setupNextQuestion();
697 void adjustColors(byte *pic, int8 shift);
698 void shuffleTopCatQuestions();
699 void shuffleTopCatPermutations();
700 void getTopCatSoundInfo(BOLTLib *lib, int16 memberId, SoundInfo *soundInfo);
701 void setScoreLights(int16 litMask);
702 void swapTopCatHelpEntry();
703
704 static void swapTopCatHelpEntryCb();
705
706 RTFResource *_topCatRtfHandle = nullptr;
707 RTFResource *_topCatAvHandle = nullptr;
708 BOLTLib *_topCatBoltLib = nullptr;
709 BOLTCallbacks _topCatBoltCallbacks;
710
711 static BOLTCallback _topCatTypeLoadCallbacks[26];
712 static BOLTCallback _topCatTypeFreeCallbacks[26];
713
714 byte *_topCatBackgroundPalette = nullptr;
715 byte *_topCatBackground = nullptr;
716 byte *_topCatBackgroundAnimationPalette = nullptr;
717 byte *_topCatGraphicsAssets = nullptr;
718
719 int16 _topCatBackgroundAnimFrame = 0;
720 int16 _topCatMaxBackgroundAnimFrames = 0;
721 int16 _topCatCurrentAnimType = 0;
722 int16 _topCatAnimStateMachineStep = 0;
723 int16 _topCatAnimQueueSize = 0;
724 int16 _topCatQueuedSoundFrames = 0;
725 byte *_topCatButtonsPalette = nullptr;
726 byte *_topCatBlinkEntries = nullptr;
727 byte *_topCatLightsPalette = nullptr;
728 int16 *_topCatBlinkSeqPtr = nullptr;
729 byte *_topCatSelectedChoiceOverlayGfx = nullptr;
730 byte *_topCatCycleData = nullptr;
731 XPCycleState _topCatCycleSpecs[4];
732 byte *_topCatShuffledQuestions = nullptr;
733 byte *_topCatShuffledAnswers = nullptr;
734 byte *_topCatAnswersPermutations = nullptr;
735 byte *_topCatAnswers = nullptr;
736 byte *_topCatAnswersScreenPositions = nullptr;
737 int16 _topCatSavedScore = 0;
738 int16 _topCatSaveHistory = 0;
739 int16 _topCatScore = 0;
740 int16 _topCatShuffledQuestionsArrayIdx = 0;
741 uint32 _topCatBlinkTimer = 0;
742 SoundInfo _topCatSoundInfo;
743 byte _topCatSavedShuffledQuestions[60] = { 0 };
744 byte _topCatSavedShuffledAnswers[60] = { 0 };
745 byte _topCatSavedAnswersPermutations[60 * 3] = { 0 };
746 byte _topCatSaveBuffer[302] = { 0 };
747 byte *_topCatHoveredEntry = nullptr;
748 byte *_topCatHelpButton = nullptr;
749 byte *_topCatBackButton = nullptr;
750 byte *_topCatBlinkEntry = nullptr;
751 int16 _topCatCycleStep = 0;
752 int16 _topCatDrawnQuestionId = 0;
753 int16 _topCatCurrentAnswerIdx = 0;
754 XPCycleState _topCatChoiceCycleState[4];
755 TopCatAnim _topCatAnimQueue[3];
756 int16 _topCatCorrectAnimIdx = 0;
757 int16 _topCatWrongAnimIdx = 0;
758 int16 _topCatShouldPlayAnswerAnim = 0;
759 int16 _topCatMaintainSoundFlag = 0;
760 int16 _topCatPermTableA[3] = { 0, 1, 2 };
761 int16 _topCatPermTableB[3] = { 0, 1, 2 };
762 int16 _topCatBlinkSeq0[5] = { 0x01, 0x00, 0x01, 0x00, 0x01 };
763 int16 _topCatBlinkSeq1[5] = { 0x03, 0x01, 0x03, 0x01, 0x03 };
764 int16 _topCatBlinkSeq2[5] = { 0x07, 0x03, 0x07, 0x03, 0x07 };
765 int16 _topCatBlinkSeq3[5] = { 0x0F, 0x07, 0x0F, 0x07, 0x0F };
766 int16 _topCatBlinkSeq4[5] = { 0x1F, 0x0F, 0x1F, 0x0F, 0x1F };
767 int16 _topCatBlinkSeq5[5] = { 0x3F, 0x1F, 0x3F, 0x1F, 0x3F };
768 int16 _topCatBlinkSeq6[25] = {
769 0x09, 0x12, 0x24, 0x09, 0x12, 0x24,
770 0x09, 0x12, 0x24, 0x09, 0x12, 0x24,
771 0x09, 0x12, 0x24, 0x09, 0x12, 0x24,
772 0x09, 0x12, 0x24, 0x09, 0x12, 0x24,
773 0x3F
774 };
775
776 int16 *_topCatBlinkSeqTable[7] = {
777 _topCatBlinkSeq0, _topCatBlinkSeq1, _topCatBlinkSeq2,
778 _topCatBlinkSeq3, _topCatBlinkSeq4, _topCatBlinkSeq5,
779 _topCatBlinkSeq6
780 };
781
782 // --- YOGI ---
783 void playSoundMapYogi(int16 memberId);
784 void waitSoundMapYogi();
785 void stopSoundYogi();
786 void setYogiColors(int16 which);
787 void restoreYogiColors(int16 which);
788 void drawBasket(int16 slot, byte *basketSprite);
789 void drawAllBaskets();
790 void handleYogiMatch();
791 bool loadYogiBgPic();
792 void unloadYogiBgPic();
793 void drawYogiLevel();
794 bool loadYogiLevel();
795 void unloadYogiResources();
796 bool initYogiLevel();
797 bool resumeYogiLevel();
798 bool initYogi();
799 void yogiToggleBlinking(int16 which, int16 *state);
800 void yogiUpdateHotSpots(int16 x, int16 y);
801 int16 findBasket(int16 x, int16 y);
802 void resolveYogiSelection();
803 bool handleBasketSelect(int16 x, int16 y);
804 void yogiHandleActionButton(int16 x, int16 y);
805 void handleYogiEvent(int16 eventType, uint32 eventData);
806 void playYogi();
807 void cleanUpYogi();
808 int16 yogiGame(int16 prevBooth);
809
810 void swapYogiAllWords();
811 void swapYogiFirstWord();
812
813 static void swapYogiAllWordsCb();
814 static void swapYogiFirstWordCb();
815
816 BOLTLib *_yogiBoltLib = nullptr;
817 BOLTCallbacks _yogiBoltCallbacks;
818
819 static BOLTCallback _yogiTypeLoadCallbacks[27];
820 static BOLTCallback _yogiTypeFreeCallbacks[27];
821
822 int16 _yogiSoundPlaying = 0;
823 int16 _yogiSoundActive = 0;
824 int16 _yogiHotSpotCount = 0;
825 int16 _yogiAnimActive = 0;
826 uint32 _yogiBlinkTimer1 = 0;
827 uint32 _yogiBlinkTimer2 = 0;
828 int16 _yogiBlinkState1 = 0;
829 int16 _yogiBlinkState2 = 0;
830 int16 _yogiGlobal[0xA0] = { 0 };
831 YogiState _yogiState;
832 byte *_yogiBasketPic = nullptr;
833 int16 _yogiLevelGroupId = 0;
834 byte *_yogiBgPic = nullptr;
835 byte *_yogiNormalSprite = nullptr;
836 byte *_yogiHlSprite = nullptr;
837 byte *_yogiAnimSprite = nullptr;
838 int16 _yogiSpriteStride = 0;
839 int16 _yogiSpriteHeight = 0;
840 int16 _yogiPalRange[8] = { 0 };
841 int16 _yogiReturnBooth = 0;
842 int16 _yogiExitFlag = 0;
843 int16 _yogiLevelId = 0;
844 int16 _yogiCursorX = 0;
845 int16 _yogiCursorY = 0;
846 byte _yogiPalSave0[15] = { 0 };
847 byte _yogiPalHighlight0[15] = { 0 };
848 byte _yogiPalSave1[15] = { 0 };
849 byte _yogiPalHighlight1[15] = { 0 };
850 XPPicDesc _yogiScratchBuf;
851};
852
853} // End of namespace Carnival
854
855} // End of namespace Bolt
856
857#endif // CARNIVAL_CARNIVAL_H
Definition: bolt.h:306
Definition: carnival.h:274
Definition: system.h:166
Definition: advancedDetector.h:164
Definition: bolt.h:70
Definition: bolt.h:148
Definition: carnival.h:34
Definition: carnival.h:41
Definition: carnival.h:107
Definition: carnival.h:75
Definition: carnival.h:208
Definition: carnival.h:149
Definition: carnival.h:224
Definition: carnival.h:240
Definition: bolt.h:167
Definition: bolt.h:224
Definition: bolt.h:292
Definition: xplib.h:52
Definition: xplib.h:68
Definition: rect.h:144
Definition: rect.h:536