22 #ifndef TOUCHE_TOUCHE_H 23 #define TOUCHE_TOUCHE_H 25 #include "common/array.h" 26 #include "common/endian.h" 27 #include "common/file.h" 28 #include "common/random.h" 29 #include "common/rect.h" 30 #include "common/util.h" 32 #include "audio/mixer.h" 34 #include "engines/engine.h" 36 #include "touche/console.h" 51 kToucheActionSkipOrQuit,
52 kToucheActionOpenOptions,
53 kToucheActionEnableFastWalk,
54 kToucheActionDisableFastWalk,
55 kToucheActionToggleFastMode,
56 kToucheActionToggleTalkTextMode,
57 kToucheActionSkipDialogue
68 Area(int16 x, int16 y, int16 w, int16 h) {
78 const int dy = r.top - rect.top;
85 if (rect.top > r.top) {
91 if (rect.bottom < r.bottom) {
92 r.bottom = rect.bottom;
94 return (r.
right > r.
left && r.bottom > r.top);
101 int16 currentAnimCounter;
113 int16 prevWalkDataNum;
115 int16 inventoryItems[4];
118 int16 currentWalkBox;
119 uint16 prevPointsDataNum;
121 int16 facingDirection;
122 int16 currentAnimSpeed;
123 int16 framesList[16];
124 int16 framesListCount;
132 int16 followingKeyCharNum;
133 int16 followingKeyCharPos;
134 uint16 sequenceDataIndex;
135 uint16 sequenceDataOffset;
136 int16 walkPointsListIndex;
137 int16 walkPointsList[40];
138 uint16 scriptDataStartOffset;
139 uint16 scriptDataOffset;
140 int16 *scriptStackPtr;
142 int16 waitingKeyChar;
143 int16 waitingKeyCharPosTable[3];
144 int16 scriptStackTable[40];
153 int16 *stackDataBasePtr;
155 int16 stackDataTable[500];
157 void init(uint8 *data) {
159 stackDataPtr = stackDataBasePtr = &stackDataTable[499];
164 uint8 readByte(uint32 offs)
const {
165 return *(dataPtr + offs);
168 int16 readWord(uint32 offs)
const {
169 return READ_LE_UINT16(dataPtr + offs);
172 uint8 readNextByte() {
173 uint8 val = readByte(dataOffset);
178 int16 readNextWord() {
179 int16 val = readWord(dataOffset);
187 int16 talkingKeyChar;
204 int16 displayCounter;
216 displayRect.
left = 0;
217 displayRect.bottom = 0;
218 displayRect.
right = 0;
301 kDebugEngine = 1 << 0,
302 kDebugGraphics = 1 << 1,
303 kDebugResource = 1 << 2,
304 kDebugOpcodes = 1 << 3,
306 kDebugCharset = 1 << 5
310 kResourceTypeRoomImage = 0,
311 kResourceTypeSequence,
312 kResourceTypeSpriteImage,
313 kResourceTypeIconImage,
314 kResourceTypeRoomInfo,
315 kResourceTypeProgram,
321 kTalkModeTextOnly = 0,
323 kTalkModeVoiceAndText,
328 kScriptStopped = 1 << 0,
329 kScriptPaused = 1 << 1
338 kInventoryCharacter = 0,
339 kInventoryMoneyDisplay,
341 kInventorySilverCoins,
357 kStartupEpisode = 90,
359 kCycleDelay = 1000 / (1193180 / 32768),
365 kMaxProgramDataSize = 61440,
371 kStringTypeConversation
376 kGameStateOptionsDialog,
377 kGameStateQuitDialog,
407 kActionScrollUpSaves,
408 kActionScrollDownSaves,
409 kActionPerformSaveLoad,
410 kActionCancelSaveLoad
414 kMenuSettingsMode = 0,
420 kButtonBorder = 1 << 0,
421 kButtonText = 1 << 1,
422 kButtonArrow = 1 << 2
439 char saveLoadDescriptionsTable[kMaxSaveStates][33];
441 void removeLastCharFromDescription(
int slot) {
442 char *description = saveLoadDescriptionsTable[slot];
443 int descriptionLen = strlen(description);
444 if (descriptionLen > 0) {
446 description[descriptionLen] = 0;
450 void addCharToDescription(
int slot,
char chr) {
451 char *description = saveLoadDescriptionsTable[slot];
452 int descriptionLen = strlen(description);
454 description[descriptionLen] = chr;
455 description[descriptionLen + 1] = 0;
459 const Button *findButtonUnderCursor(
int cursorX,
int cursorY)
const {
460 for (uint i = 0; i < buttonsCount; ++i) {
461 const Button *button = &buttonsTable[i];
462 if (cursorX >= button->x && cursorX < button->x + button->w &&
463 cursorY >= button->y && cursorY < button->y + button->h) {
473 Common::String generateGameStateFileName(
const char *target,
int slot,
bool prefixOnly =
false);
474 int getGameStateFileSlot(
const char *filename);
486 NUM_CONVERSATION_CHOICES = 40,
487 NUM_TALK_ENTRIES = 16,
488 NUM_ANIMATION_ENTRIES = 4,
489 NUM_INVENTORY_ITEMS = 100,
490 NUM_DIRTY_RECTS = 30,
497 ~ToucheEngine()
override;
502 void syncSoundSettings()
override;
507 void readConfigurationSettings();
508 void writeConfigurationSettings();
510 void processEvents(
bool handleKeyEvents =
true);
512 int16 getRandomNumber(
int max);
513 void changePaletteRange();
514 void playSoundInRange();
515 void resetSortedKeyCharsTable();
516 void setupEpisode(
int num);
517 void setupNewEpisode();
518 void drawKeyChar(
KeyChar *key);
520 void runKeyCharScript(
KeyChar *key);
521 void runCurrentKeyCharScript(
int mode);
522 void executeScriptOpcode(int16 param);
523 void initKeyChars(
int keyChar);
524 void setKeyCharTextColor(
int keyChar, uint16 color);
525 void waitForKeyCharPosition(
int keyChar);
526 void setKeyCharBox(
int keyChar,
int value);
527 void setKeyCharFrame(
int keyChar, int16 type, int16 value1, int16 value2);
528 void setKeyCharFacingDirection(
int keyChar, int16 dir);
529 void initKeyCharScript(
int keyChar, int16 spriteNum, int16 seqDataIndex, int16 seqDataOffs);
530 uint16 findProgramKeyCharScriptOffset(
int keyChar)
const;
531 bool scrollRoom(
int keyChar);
532 void drawIcon(
int x,
int y,
int num);
533 void centerScreenToKeyChar(
int keyChar);
534 void waitForKeyCharsSet();
536 void fadePalette(
int firstColor,
int colorCount,
int scale,
int scaleInc,
int fadingStepsCount);
537 void fadePaletteFromFlags();
538 void moveKeyChar(uint8 *dst,
int dstPitch,
KeyChar *key);
539 void changeKeyCharFrame(
KeyChar *key,
int keyChar);
540 void setKeyCharRandomFrame(
KeyChar *key);
541 void setKeyCharMoney();
542 const char *getString(
int num)
const;
543 int getStringWidth(
int num)
const;
544 void drawString(uint16 color,
int x,
int y, int16 num, StringType strType = kStringTypeDefault);
545 void drawGameString(uint16 color,
int x1,
int y,
const char *str);
546 int restartKeyCharScriptOnAction(
int action,
int obj1,
int obj2);
547 void buildSpriteScalingTable(
int z1,
int z2);
548 void drawSpriteOnBackdrop(
int num,
int x,
int y);
549 void updateTalkFrames(
int keyChar);
550 void setKeyCharTalkingFrame(
int keyChar);
551 void lockUnlockHitBox(
int num,
int lock);
553 void showCursor(
bool show);
554 void setCursor(
int num);
555 void setDefaultCursor(
int num);
556 void handleLeftMouseButtonClickOnInventory();
557 void handleRightMouseButtonClickOnInventory();
558 void handleMouseInput(
int flag);
559 void handleMouseClickOnRoom(
int flag);
560 void handleMouseClickOnInventory(
int flag);
561 void scrollScreenToPos(
int num);
562 void clearRoomArea();
563 void startNewMusic();
564 void startNewSound();
566 int handleActionMenuUnderCursor(
const int16 *actions,
int offs,
int y,
int str);
568 void redrawBackground();
569 void addRoomArea(
int num,
int flag);
570 void updateRoomAreas(
int num,
int flags);
571 void setRoomAreaState(
int num, uint16 state);
572 void findAndRedrawRoomRegion(
int num);
573 void updateRoomRegions();
574 void redrawRoomRegion(
int num,
bool markForRedraw);
576 void initInventoryObjectsTable();
577 void initInventoryLists();
578 void setupInventoryAreas();
579 void drawInventory(
int index,
int flag);
580 void drawAmountOfMoneyInInventory();
581 void packInventoryItems(
int index);
582 void appendItemToInventoryList(
int index);
583 void addItemToInventory(
int inventory, int16 item);
584 void removeItemFromInventory(
int inventory, int16 item);
586 void resetTalkingVars();
587 int updateKeyCharTalk(
int pauseFlag);
588 const char *formatTalkText(
int *y,
int *h,
const char *text);
589 void addToTalkTable(
int talkingKeyChar,
int num,
int otherKeyChar);
590 void removeFromTalkTable(
int keyChar);
591 void addConversationChoice(int16 num);
592 void removeConversationChoice(int16 num);
593 void runConversationScript(uint16 offset);
594 void findConversationByNum(int16 num);
595 void clearConversationChoices();
596 void scrollDownConversationChoice();
597 void scrollUpConversationChoice();
598 void drawCharacterConversation();
599 void drawConversationString(
int num, uint16 color);
600 void clearConversationArea();
601 void setupConversationScript(
int num);
602 void handleConversation();
604 void buildWalkPointsList(
int keyChar);
605 int findWalkDataNum(
int pointNum1,
int pointNum2);
606 void changeWalkPath(
int num1,
int num2, int16 val);
607 void adjustKeyCharPosToWalkBox(
KeyChar *key,
int moveType);
608 void lockWalkPath(
int num1,
int num2);
609 void unlockWalkPath(
int num1,
int num2);
610 void resetPointsData(
int num);
611 bool sortPointsData(
int num1,
int num2);
612 void updateKeyCharWalkPath(
KeyChar *key, int16 dx, int16 dy, int16 dz);
613 void markWalkPoints(
int keyChar);
614 void buildWalkPath(
int dstPosX,
int dstPosY,
int keyChar);
616 void addToAnimationTable(
int num,
int posNum,
int keyChar,
int delayCounter);
617 void copyAnimationImage(
int dstX,
int dstY,
int w,
int h,
const uint8 *src,
int srcX,
int srcY,
int fillColor);
619 void processAnimationTable();
620 void clearAnimationTable();
623 void clearDirtyRects();
624 void setPalette(
int firstColor,
int colorCount,
int redScale,
int greenScale,
int blueScale);
625 void updateScreenArea(
int x,
int y,
int w,
int h);
626 void updateEntireScreen();
627 void updateDirtyScreenAreas();
628 void updatePalette();
657 void op_testGreater();
658 void op_testEquals();
660 void op_fetchScriptWord();
661 void op_testGreaterOrEquals();
662 void op_testLowerOrEquals();
663 void op_testNotEquals();
664 void op_endConversation();
665 void op_stopScript();
668 void op_fetchScriptByte();
669 void op_getKeyCharWalkBox();
670 void op_startSound();
671 void op_moveKeyCharToPos();
673 void op_updateRoom();
675 void op_loadSprite();
676 void op_loadSequence();
677 void op_setKeyCharBox();
678 void op_initKeyCharScript();
679 void op_setKeyCharFrame();
680 void op_setKeyCharDirection();
681 void op_clearConversationChoices();
682 void op_addConversationChoice();
683 void op_removeConversationChoice();
684 void op_getInventoryItem();
685 void op_setInventoryItem();
686 void op_startEpisode();
687 void op_setConversationNum();
688 void op_enableInput();
689 void op_disableInput();
690 void op_faceKeyChar();
691 void op_getKeyCharCurrentAnim();
692 void op_getCurrentKeyChar();
693 void op_isKeyCharActive();
694 void op_setPalette();
695 void op_changeWalkPath();
696 void op_lockWalkPath();
697 void op_initializeKeyChar();
698 void op_setupWaitingKeyChars();
699 void op_updateRoomAreas();
700 void op_unlockWalkPath();
701 void op_addItemToInventoryAndRedraw();
702 void op_giveItemTo();
703 void op_setHitBoxText();
704 void op_fadePalette();
705 void op_getInventoryItemFlags();
706 void op_drawInventory();
707 void op_stopKeyCharScript();
708 void op_restartKeyCharScript();
709 void op_getKeyCharCurrentWalkBox();
710 void op_getKeyCharPointsDataNum();
711 void op_setupFollowingKeyChar();
712 void op_startAnimation();
713 void op_setKeyCharTextColor();
714 void op_startMusic();
716 void op_setKeyCharDelay();
717 void op_lockHitBox();
718 void op_removeItemFromInventory();
719 void op_unlockHitBox();
720 void op_addRoomArea();
721 void op_setKeyCharFlags();
722 void op_unsetKeyCharFlags();
723 void op_loadSpeechSegment();
724 void op_drawSpriteOnBackdrop();
725 void op_startPaletteFadeIn();
726 void op_startPaletteFadeOut();
727 void op_setRoomAreaState();
729 void res_openDataFile();
730 void res_closeDataFile();
731 void res_allocateTables();
732 void res_deallocateTables();
733 uint32 res_getDataOffset(ResourceType type,
int num, uint32 *size = NULL);
734 void res_loadSpriteImage(
int num, uint8 *dst);
735 void res_loadProgram(
int num);
736 void res_decodeProgramData();
737 void res_loadRoom(
int num);
738 void res_loadSprite(
int num,
int index);
739 void res_loadSequence(
int num,
int index);
740 void res_decodeScanLineImageRLE(uint8 *dst,
int lineWidth);
741 void res_loadBackdrop();
742 void res_loadImage(
int num, uint8 *dst);
743 void res_loadImageHelper(uint8 *imgData,
int imgWidth,
int imgHeight);
744 void res_loadSound(
int flag,
int num);
745 void res_stopSound();
746 void res_loadMusic(
int num);
747 void res_loadSpeech(
int num);
748 void res_loadSpeechSegment(
int num);
749 void res_stopSpeech();
751 void drawButton(
Button *button);
753 void handleMenuAction(
MenuData *menu,
int actionId);
754 void handleOptions(
int forceDisplay);
755 void drawActionsPanel(
int dstX,
int dstY,
int deltaX,
int deltaY);
756 void drawConversationPanelBorder(
int dstY,
int srcX,
int srcY);
757 void drawConversationPanel();
758 void printStatusString(
const char *str);
759 void clearStatusString();
760 int displayQuitDialog();
761 void displayTextMode(
int str);
772 void startMusic(
int num);
775 int getMusicVolume();
776 void setMusicVolume(
int volume);
777 void adjustMusicVolume(
int diff);
782 bool _inp_leftMouseButtonPressed;
783 bool _inp_rightMouseButtonPressed;
784 int _disabledInputCounter;
785 bool _hideInventoryTexts;
786 GameState _gameState;
787 bool _displayQuitDialog;
788 int _saveLoadCurrentPage;
789 int _saveLoadCurrentSlot;
792 int _currentMusicNum;
795 int _newSoundPriority;
796 int _playSoundCounter;
801 int16 _inventoryList1[101];
802 int16 _inventoryList2[101];
803 int16 _inventoryList3[7];
805 int16 _inventoryItemsInfoTable[NUM_INVENTORY_ITEMS];
806 int16 *_inventoryVar1;
807 int16 *_inventoryVar2;
808 int _currentCursorObject;
813 int _talkListCurrent;
814 bool _talkTextRectDefined;
815 bool _talkTextDisplayed;
816 bool _talkTextInitialized;
819 int _keyCharTalkCounter;
820 int _talkTableLastTalkingKeyChar;
821 int _talkTableLastOtherKeyChar;
822 int _talkTableLastStringNum;
823 int _objectDescriptionNum;
826 bool _conversationChoicesUpdated;
827 int _conversationReplyNum;
828 bool _conversationEnded;
829 int _conversationNum;
830 int _scrollConversationChoiceOffset;
831 int _currentConversation;
832 bool _disableConversationScript;
833 bool _conversationAreaCleared;
836 int16 _flagsTable[NUM_FLAGS];
837 KeyChar _keyCharsTable[NUM_KEYCHARS];
838 KeyChar *_sortedKeyCharsTable[NUM_KEYCHARS];
839 int _currentKeyCharNum;
842 int _currentEpisodeNum;
844 int _currentAmountOfMoney;
845 int _giveItemToKeyCharNum;
846 int _giveItemToObjectNum;
847 int _giveItemToCounter;
849 int _waitingSetKeyCharNum1;
850 int _waitingSetKeyCharNum2;
851 int _waitingSetKeyCharNum3;
852 uint8 _updatedRoomAreasTable[200];
855 int _currentObjectNum;
856 int _processRandomPaletteCounter;
857 int16 _spriteScalingIndex[1000];
858 int16 _spriteScalingTable[1000];
866 const OpcodeProc *_opcodesTable;
871 int _compressedSpeechData;
874 uint8 *_backdropBuffer;
877 uint8 *_sequenceDataTable[NUM_SEQUENCES];
879 uint32 _programDataSize;
885 int _currentBitmapWidth;
886 int _currentBitmapHeight;
887 int _currentImageWidth;
888 int _currentImageHeight;
891 uint8 *_programTextDataPtr;
906 bool _roomNeedRedraw;
907 int _fullRedrawCounter;
908 int _menuRedrawCounter;
909 uint8 *_offscreenBuffer;
910 uint8 _paletteBuffer[256 * 3];
912 int _dirtyRectsTableCount;
914 static const uint8 _directionsTable[NUM_DIRECTIONS];
EngineFeature
Definition: engine.h:253
static String format(MSVC_PRINTF const char *fmt,...) GCC_PRINTF(1
int16 right
Definition: rect.h:146
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
int16 left
Definition: rect.h:145
Common::String getSaveStateName(int slot) const override
Definition: touche.h:636
Language
Definition: language.h:45