22#ifndef CARNIVAL_CARNIVAL_H
23#define CARNIVAL_CARNIVAL_H
32typedef int16 (CarnivalEngine::*SideShowHandler)(int16 prevBooth);
35 SideShowHandler *handlers;
83 int16 selectionPending;
86 int16 selected1SpriteId;
87 int16 selected2SpriteId;
91 memset(slotIndex, 0,
sizeof(slotIndex));
93 memset(drawTable1, 0,
sizeof(drawTable1));
94 memset(drawTable2, 0,
sizeof(drawTable2));
100 selected1SpriteId = 0;
101 selected2SpriteId = 0;
109 int16 frameCountdown;
153 int16 wallStates[25][4];
155 int16 scoobySavedCell;
165 int16 targetVelocityX;
166 int16 targetVelocityY;
167 int16 transitionTarget;
170 int16 spriteFrameCount;
176 for (
int i = 0; i < 10; i++)
181 for (
int i = 0; i < 25; i++)
182 for (
int j = 0; j < 4; j++)
183 wallStates[i][j] = 0;
198 transitionTarget = 0;
201 spriteFrameCount = 0;
203 for (
int i = 0; i < 6; i++)
204 frameData[i] =
nullptr;
227 int16 transitionToNextQuestionFlag;
233 transitionToNextQuestionFlag = 0;
243 int16 levelIndex[10];
246 int16 basketSound[24];
247 int16 basketState[24];
250 int16 selectionPending;
259 memset(levelIndex, 0,
sizeof(levelIndex));
260 memset(slotIndex, 0,
sizeof(slotIndex));
262 memset(basketSound, 0,
sizeof(basketSound));
263 memset(basketState, 0,
sizeof(basketState));
266 selectionPending = 0;
280 void boltMain()
override;
281 int16 displayDemoPict(int16 prevBooth);
283 void initCallbacks()
override;
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);
298 int16 openBooth(int16 boothId);
301 void finishPlayingHelp(int16 activeHotspot);
302 int16 hotSpotActive(int16 hotspot);
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);
311 void shiftColorMap(
byte *colorMap, int16 delta);
313 void mainEntranceHelpBlink();
314 void boothHelpBlink();
315 void tourPaletteCycleStep();
316 void fadeToBlack(int16 steps);
318 int16 winALetter(int16 prevBooth);
319 int16 endDemo(int16 prevBooth);
321 int16 _lettersWon = 0;
322 bool _allLettersWonFlag =
false;
323 int _displayMode = 0;
326 int32 _displayWidth = 0;
327 int32 _displayHeight = 0;
329 int16 _boothLoadedMask = 0;
330 int16 _currentBoothScene = 0;
331 int16 _boothNumHotspots = 0;
332 int16 _boothNumAnimations = 0;
333 byte *_boothSceneDesc =
nullptr;
334 byte *_boothHotPalDescs[4];
336 byte *_boothAnimDescs[7];
337 byte *_boothAnimPalDescs[4];
338 byte _savedPalettes[7][30];
339 byte _savedHotPalettes[4][9];
340 byte *_boothPalCycleData =
nullptr;
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 };
350 int16 _hoveredHotspot = 0;
351 uint32 _helpTimer = 0;
352 int16 _keyReleased = 0;
361 int16 _helpPlaying = 0;
362 int16 _helpIsIdle = 0;
363 int16 _idleHelpAudioAvailable = 1;
367 int16 _scoobyWins = 0;
369 int16 _georgeWins = 0;
370 int16 _topCatWins = 0;
373 BarkerTable *createBarker(int16 minIndex, int16 maxIndex);
375 bool registerSideShow(
BarkerTable *table, SideShowHandler handler, int16 boothId);
376 int16 barker(
BarkerTable *table, int16 startBooth);
379 int16 _currentBoothId = 0;
384 int16 fredGame(int16 prevBooth);
387 bool initFredLevel(int16 levelGroup, int16 palGroup);
388 void termFredLevel(int16 levelGroup, int16 palGroup);
389 void swapFredAnimEntry();
390 void swapFredAnimDesc();
391 void swapFredLevelDesc();
394 void hiliteFredHelpObject(
byte *entry, int16 highlight);
397 int16 calcBalloonSpawnDelay();
398 int16 selectBalloonRow();
400 void renderFredScene();
403 void updateFredSound();
405 static void resolveAllRefsCb();
406 static void swapFredAnimEntryCb();
407 static void swapFredAnimDescCb();
408 static void swapFredLevelDescCb();
410 BOLTLib *_fredBoltLib =
nullptr;
413 static BOLTCallback _fredTypeLoadCallbacks[28];
414 static BOLTCallback _fredTypeFreeCallbacks[28];
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 };
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;
441 SoundInfo *_fredPendingOneShot =
nullptr;
446 int16 _fredSaveData[3] = { 0, 0, 0 };
447 int16 _fredLevelIndex = 0;
449 int16 _fredBalloonSpawnDelay = 0;
450 int16 _fredBalloonSearchIdx = 0;
451 uint32 _fredTimer = 0;
452 int16 _fredHelpStep = -1;
453 int16 _fredShowHelp = 1;
458 int16 georgeGame(int16 prevBooth);
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();
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();
480 void drawFlyingObjects();
481 void getGeorgeSoundInfo(
BOLTLib *boltLib, int16 member,
SoundInfo *outInfo,
byte priority);
483 void updateGeorgeSound();
485 static void swapGeorgeFrameArrayCb();
486 static void swapGeorgeHelpEntryCb();
487 static void swapGeorgeThresholdsCb();
489 BOLTLib *_georgeBoltLib =
nullptr;
492 static BOLTCallback _georgeTypeLoadCallbacks[28];
493 static BOLTCallback _georgeTypeFreeCallbacks[28];
495 byte *_georgePrevActiveHelpObject =
nullptr;
496 byte *_georgeActiveHelpObject =
nullptr;
497 int16 _georgeHelpStep = -1;
498 int16 _georgeHelpActive = 1;
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;
529 int16 _georgeCollectedSatellitesNum = 0;
535 SoundInfo **_georgeSatelliteSoundList =
nullptr;
536 byte _georgeSoundChannelCounter = 0;
538 SoundInfo *_georgeSoundCurrent =
nullptr;
541 int16 _georgeSaveData[3] = { 0 };
542 int16 *_georgeThresholds =
nullptr;
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();
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);
565 void resolveHuckSelection();
566 void handleEvent(int16 eventType, uint32 eventData);
569 int16 huckGame(int16 prevBooth);
570 void swapHuckWordArray();
571 void swapHuckWords();
573 static void swapHuckWordArrayCb();
574 static void swapHuckWordsCb();
576 BOLTLib *_huckBoltLib =
nullptr;
579 static BOLTCallback _huckTypeLoadCallbacks[27];
580 static BOLTCallback _huckTypeFreeCallbacks[27];
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 };
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 };
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();
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();
634 void cleanUpScooby();
636 void hiliteScoobyHelpObject(
byte *entry, int16 highlight);
637 int16 xpDirToBOLTDir(uint32 xpDir);
639 int16 scoobyGame(int16 prevBooth);
640 void swapScoobyHelpEntry();
641 void swapScoobyWordArray();
643 static void swapScoobyHelpEntryCb();
644 static void swapScoobyWordArrayCb();
646 BOLTLib *_scoobyBoltLib =
nullptr;
649 static BOLTCallback _scoobyTypeLoadCallbacks[28];
650 static BOLTCallback _scoobyTypeFreeCallbacks[28];
652 int16 _scoobySoundMode = 0;
653 int16 _scoobySoundPlaying = 0;
654 int16 _scoobyShowHelp = 1;
656 int16 _scoobyLastInputDir = 0;
657 int16 _scoobyTransitionFrom = 0;
658 int16 _scoobyTransitionTarget = 0;
659 int16 _scoobyTransitionVelX = 0;
660 int16 _scoobyTransitionVelY = 0;
662 byte _scoobyGlobalSaveData[0x3C] = { 0 };
665 byte *_scoobyBaseData =
nullptr;
666 byte *_scoobyBgPic =
nullptr;
667 byte *_scoobyWallPicsA[4] = {
nullptr };
668 byte *_scoobyWallPicsB[5] = {
nullptr };
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;
685 int16 topCatGame(int16 prevBooth);
687 void cleanUpTopCat();
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();
704 static void swapTopCatHelpEntryCb();
708 BOLTLib *_topCatBoltLib =
nullptr;
711 static BOLTCallback _topCatTypeLoadCallbacks[26];
712 static BOLTCallback _topCatTypeFreeCallbacks[26];
714 byte *_topCatBackgroundPalette =
nullptr;
715 byte *_topCatBackground =
nullptr;
716 byte *_topCatBackgroundAnimationPalette =
nullptr;
717 byte *_topCatGraphicsAssets =
nullptr;
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;
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;
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;
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,
776 int16 *_topCatBlinkSeqTable[7] = {
777 _topCatBlinkSeq0, _topCatBlinkSeq1, _topCatBlinkSeq2,
778 _topCatBlinkSeq3, _topCatBlinkSeq4, _topCatBlinkSeq5,
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();
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);
808 int16 yogiGame(int16 prevBooth);
810 void swapYogiAllWords();
811 void swapYogiFirstWord();
813 static void swapYogiAllWordsCb();
814 static void swapYogiFirstWordCb();
816 BOLTLib *_yogiBoltLib =
nullptr;
819 static BOLTCallback _yogiTypeLoadCallbacks[27];
820 static BOLTCallback _yogiTypeFreeCallbacks[27];
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 };
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 };
Definition: carnival.h:274
Definition: advancedDetector.h:164
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