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" 56 Area(int16 x, int16 y, int16 w, int16 h) {
66 const int dy = r.top - rect.top;
73 if (rect.top > r.top) {
79 if (rect.bottom < r.bottom) {
80 r.bottom = rect.bottom;
82 return (r.
right > r.
left && r.bottom > r.top);
89 int16 currentAnimCounter;
101 int16 prevWalkDataNum;
103 int16 inventoryItems[4];
106 int16 currentWalkBox;
107 uint16 prevPointsDataNum;
109 int16 facingDirection;
110 int16 currentAnimSpeed;
111 int16 framesList[16];
112 int16 framesListCount;
120 int16 followingKeyCharNum;
121 int16 followingKeyCharPos;
122 uint16 sequenceDataIndex;
123 uint16 sequenceDataOffset;
124 int16 walkPointsListIndex;
125 int16 walkPointsList[40];
126 uint16 scriptDataStartOffset;
127 uint16 scriptDataOffset;
128 int16 *scriptStackPtr;
130 int16 waitingKeyChar;
131 int16 waitingKeyCharPosTable[3];
132 int16 scriptStackTable[40];
141 int16 *stackDataBasePtr;
143 int16 stackDataTable[500];
145 void init(uint8 *data) {
147 stackDataPtr = stackDataBasePtr = &stackDataTable[499];
152 uint8 readByte(uint32 offs)
const {
153 return *(dataPtr + offs);
156 int16 readWord(uint32 offs)
const {
157 return READ_LE_UINT16(dataPtr + offs);
160 uint8 readNextByte() {
161 uint8 val = readByte(dataOffset);
166 int16 readNextWord() {
167 int16 val = readWord(dataOffset);
175 int16 talkingKeyChar;
192 int16 displayCounter;
204 displayRect.
left = 0;
205 displayRect.bottom = 0;
206 displayRect.
right = 0;
289 kDebugEngine = 1 << 0,
290 kDebugGraphics = 1 << 1,
291 kDebugResource = 1 << 2,
292 kDebugOpcodes = 1 << 3,
294 kDebugCharset = 1 << 5
298 kResourceTypeRoomImage = 0,
299 kResourceTypeSequence,
300 kResourceTypeSpriteImage,
301 kResourceTypeIconImage,
302 kResourceTypeRoomInfo,
303 kResourceTypeProgram,
309 kTalkModeTextOnly = 0,
311 kTalkModeVoiceAndText,
316 kScriptStopped = 1 << 0,
317 kScriptPaused = 1 << 1
326 kInventoryCharacter = 0,
327 kInventoryMoneyDisplay,
329 kInventorySilverCoins,
345 kStartupEpisode = 90,
347 kCycleDelay = 1000 / (1193180 / 32768),
353 kMaxProgramDataSize = 61440,
359 kStringTypeConversation
364 kGameStateOptionsDialog,
365 kGameStateQuitDialog,
395 kActionScrollUpSaves,
396 kActionScrollDownSaves,
397 kActionPerformSaveLoad,
398 kActionCancelSaveLoad
402 kMenuSettingsMode = 0,
408 kButtonBorder = 1 << 0,
409 kButtonText = 1 << 1,
410 kButtonArrow = 1 << 2
427 char saveLoadDescriptionsTable[kMaxSaveStates][33];
429 void removeLastCharFromDescription(
int slot) {
430 char *description = saveLoadDescriptionsTable[slot];
431 int descriptionLen = strlen(description);
432 if (descriptionLen > 0) {
434 description[descriptionLen] = 0;
438 void addCharToDescription(
int slot,
char chr) {
439 char *description = saveLoadDescriptionsTable[slot];
440 int descriptionLen = strlen(description);
442 description[descriptionLen] = chr;
443 description[descriptionLen + 1] = 0;
447 const Button *findButtonUnderCursor(
int cursorX,
int cursorY)
const {
448 for (uint i = 0; i < buttonsCount; ++i) {
449 const Button *button = &buttonsTable[i];
450 if (cursorX >= button->x && cursorX < button->x + button->w &&
451 cursorY >= button->y && cursorY < button->y + button->h) {
461 Common::String generateGameStateFileName(
const char *target,
int slot,
bool prefixOnly =
false);
462 int getGameStateFileSlot(
const char *filename);
474 NUM_CONVERSATION_CHOICES = 40,
475 NUM_TALK_ENTRIES = 16,
476 NUM_ANIMATION_ENTRIES = 4,
477 NUM_INVENTORY_ITEMS = 100,
478 NUM_DIRTY_RECTS = 30,
485 ~ToucheEngine()
override;
490 void syncSoundSettings()
override;
495 void readConfigurationSettings();
496 void writeConfigurationSettings();
498 void processEvents(
bool handleKeyEvents =
true);
500 int16 getRandomNumber(
int max);
501 void changePaletteRange();
502 void playSoundInRange();
503 void resetSortedKeyCharsTable();
504 void setupEpisode(
int num);
505 void setupNewEpisode();
506 void drawKeyChar(
KeyChar *key);
508 void runKeyCharScript(
KeyChar *key);
509 void runCurrentKeyCharScript(
int mode);
510 void executeScriptOpcode(int16 param);
511 void initKeyChars(
int keyChar);
512 void setKeyCharTextColor(
int keyChar, uint16 color);
513 void waitForKeyCharPosition(
int keyChar);
514 void setKeyCharBox(
int keyChar,
int value);
515 void setKeyCharFrame(
int keyChar, int16 type, int16 value1, int16 value2);
516 void setKeyCharFacingDirection(
int keyChar, int16 dir);
517 void initKeyCharScript(
int keyChar, int16 spriteNum, int16 seqDataIndex, int16 seqDataOffs);
518 uint16 findProgramKeyCharScriptOffset(
int keyChar)
const;
519 bool scrollRoom(
int keyChar);
520 void drawIcon(
int x,
int y,
int num);
521 void centerScreenToKeyChar(
int keyChar);
522 void waitForKeyCharsSet();
524 void fadePalette(
int firstColor,
int colorCount,
int scale,
int scaleInc,
int fadingStepsCount);
525 void fadePaletteFromFlags();
526 void moveKeyChar(uint8 *dst,
int dstPitch,
KeyChar *key);
527 void changeKeyCharFrame(
KeyChar *key,
int keyChar);
528 void setKeyCharRandomFrame(
KeyChar *key);
529 void setKeyCharMoney();
530 const char *getString(
int num)
const;
531 int getStringWidth(
int num)
const;
532 void drawString(uint16 color,
int x,
int y, int16 num, StringType strType = kStringTypeDefault);
533 void drawGameString(uint16 color,
int x1,
int y,
const char *str);
534 int restartKeyCharScriptOnAction(
int action,
int obj1,
int obj2);
535 void buildSpriteScalingTable(
int z1,
int z2);
536 void drawSpriteOnBackdrop(
int num,
int x,
int y);
537 void updateTalkFrames(
int keyChar);
538 void setKeyCharTalkingFrame(
int keyChar);
539 void lockUnlockHitBox(
int num,
int lock);
541 void showCursor(
bool show);
542 void setCursor(
int num);
543 void setDefaultCursor(
int num);
544 void handleLeftMouseButtonClickOnInventory();
545 void handleRightMouseButtonClickOnInventory();
546 void handleMouseInput(
int flag);
547 void handleMouseClickOnRoom(
int flag);
548 void handleMouseClickOnInventory(
int flag);
549 void scrollScreenToPos(
int num);
550 void clearRoomArea();
551 void startNewMusic();
552 void startNewSound();
554 int handleActionMenuUnderCursor(
const int16 *actions,
int offs,
int y,
int str);
556 void redrawBackground();
557 void addRoomArea(
int num,
int flag);
558 void updateRoomAreas(
int num,
int flags);
559 void setRoomAreaState(
int num, uint16 state);
560 void findAndRedrawRoomRegion(
int num);
561 void updateRoomRegions();
562 void redrawRoomRegion(
int num,
bool markForRedraw);
564 void initInventoryObjectsTable();
565 void initInventoryLists();
566 void setupInventoryAreas();
567 void drawInventory(
int index,
int flag);
568 void drawAmountOfMoneyInInventory();
569 void packInventoryItems(
int index);
570 void appendItemToInventoryList(
int index);
571 void addItemToInventory(
int inventory, int16 item);
572 void removeItemFromInventory(
int inventory, int16 item);
574 void resetTalkingVars();
575 int updateKeyCharTalk(
int pauseFlag);
576 const char *formatTalkText(
int *y,
int *h,
const char *text);
577 void addToTalkTable(
int talkingKeyChar,
int num,
int otherKeyChar);
578 void removeFromTalkTable(
int keyChar);
579 void addConversationChoice(int16 num);
580 void removeConversationChoice(int16 num);
581 void runConversationScript(uint16 offset);
582 void findConversationByNum(int16 num);
583 void clearConversationChoices();
584 void scrollDownConversationChoice();
585 void scrollUpConversationChoice();
586 void drawCharacterConversation();
587 void drawConversationString(
int num, uint16 color);
588 void clearConversationArea();
589 void setupConversationScript(
int num);
590 void handleConversation();
592 void buildWalkPointsList(
int keyChar);
593 int findWalkDataNum(
int pointNum1,
int pointNum2);
594 void changeWalkPath(
int num1,
int num2, int16 val);
595 void adjustKeyCharPosToWalkBox(
KeyChar *key,
int moveType);
596 void lockWalkPath(
int num1,
int num2);
597 void unlockWalkPath(
int num1,
int num2);
598 void resetPointsData(
int num);
599 bool sortPointsData(
int num1,
int num2);
600 void updateKeyCharWalkPath(
KeyChar *key, int16 dx, int16 dy, int16 dz);
601 void markWalkPoints(
int keyChar);
602 void buildWalkPath(
int dstPosX,
int dstPosY,
int keyChar);
604 void addToAnimationTable(
int num,
int posNum,
int keyChar,
int delayCounter);
605 void copyAnimationImage(
int dstX,
int dstY,
int w,
int h,
const uint8 *src,
int srcX,
int srcY,
int fillColor);
607 void processAnimationTable();
608 void clearAnimationTable();
611 void clearDirtyRects();
612 void setPalette(
int firstColor,
int colorCount,
int redScale,
int greenScale,
int blueScale);
613 void updateScreenArea(
int x,
int y,
int w,
int h);
614 void updateEntireScreen();
615 void updateDirtyScreenAreas();
616 void updatePalette();
645 void op_testGreater();
646 void op_testEquals();
648 void op_fetchScriptWord();
649 void op_testGreaterOrEquals();
650 void op_testLowerOrEquals();
651 void op_testNotEquals();
652 void op_endConversation();
653 void op_stopScript();
656 void op_fetchScriptByte();
657 void op_getKeyCharWalkBox();
658 void op_startSound();
659 void op_moveKeyCharToPos();
661 void op_updateRoom();
663 void op_loadSprite();
664 void op_loadSequence();
665 void op_setKeyCharBox();
666 void op_initKeyCharScript();
667 void op_setKeyCharFrame();
668 void op_setKeyCharDirection();
669 void op_clearConversationChoices();
670 void op_addConversationChoice();
671 void op_removeConversationChoice();
672 void op_getInventoryItem();
673 void op_setInventoryItem();
674 void op_startEpisode();
675 void op_setConversationNum();
676 void op_enableInput();
677 void op_disableInput();
678 void op_faceKeyChar();
679 void op_getKeyCharCurrentAnim();
680 void op_getCurrentKeyChar();
681 void op_isKeyCharActive();
682 void op_setPalette();
683 void op_changeWalkPath();
684 void op_lockWalkPath();
685 void op_initializeKeyChar();
686 void op_setupWaitingKeyChars();
687 void op_updateRoomAreas();
688 void op_unlockWalkPath();
689 void op_addItemToInventoryAndRedraw();
690 void op_giveItemTo();
691 void op_setHitBoxText();
692 void op_fadePalette();
693 void op_getInventoryItemFlags();
694 void op_drawInventory();
695 void op_stopKeyCharScript();
696 void op_restartKeyCharScript();
697 void op_getKeyCharCurrentWalkBox();
698 void op_getKeyCharPointsDataNum();
699 void op_setupFollowingKeyChar();
700 void op_startAnimation();
701 void op_setKeyCharTextColor();
702 void op_startMusic();
704 void op_setKeyCharDelay();
705 void op_lockHitBox();
706 void op_removeItemFromInventory();
707 void op_unlockHitBox();
708 void op_addRoomArea();
709 void op_setKeyCharFlags();
710 void op_unsetKeyCharFlags();
711 void op_loadSpeechSegment();
712 void op_drawSpriteOnBackdrop();
713 void op_startPaletteFadeIn();
714 void op_startPaletteFadeOut();
715 void op_setRoomAreaState();
717 void res_openDataFile();
718 void res_closeDataFile();
719 void res_allocateTables();
720 void res_deallocateTables();
721 uint32 res_getDataOffset(ResourceType type,
int num, uint32 *size = NULL);
722 void res_loadSpriteImage(
int num, uint8 *dst);
723 void res_loadProgram(
int num);
724 void res_decodeProgramData();
725 void res_loadRoom(
int num);
726 void res_loadSprite(
int num,
int index);
727 void res_loadSequence(
int num,
int index);
728 void res_decodeScanLineImageRLE(uint8 *dst,
int lineWidth);
729 void res_loadBackdrop();
730 void res_loadImage(
int num, uint8 *dst);
731 void res_loadImageHelper(uint8 *imgData,
int imgWidth,
int imgHeight);
732 void res_loadSound(
int flag,
int num);
733 void res_stopSound();
734 void res_loadMusic(
int num);
735 void res_loadSpeech(
int num);
736 void res_loadSpeechSegment(
int num);
737 void res_stopSpeech();
739 void drawButton(
Button *button);
741 void handleMenuAction(
MenuData *menu,
int actionId);
742 void handleOptions(
int forceDisplay);
743 void drawActionsPanel(
int dstX,
int dstY,
int deltaX,
int deltaY);
744 void drawConversationPanelBorder(
int dstY,
int srcX,
int srcY);
745 void drawConversationPanel();
746 void printStatusString(
const char *str);
747 void clearStatusString();
748 int displayQuitDialog();
749 void displayTextMode(
int str);
760 void startMusic(
int num);
763 int getMusicVolume();
764 void setMusicVolume(
int volume);
765 void adjustMusicVolume(
int diff);
770 bool _inp_leftMouseButtonPressed;
771 bool _inp_rightMouseButtonPressed;
772 int _disabledInputCounter;
773 bool _hideInventoryTexts;
774 GameState _gameState;
775 bool _displayQuitDialog;
776 int _saveLoadCurrentPage;
777 int _saveLoadCurrentSlot;
780 int _currentMusicNum;
783 int _newSoundPriority;
784 int _playSoundCounter;
789 int16 _inventoryList1[101];
790 int16 _inventoryList2[101];
791 int16 _inventoryList3[7];
793 int16 _inventoryItemsInfoTable[NUM_INVENTORY_ITEMS];
794 int16 *_inventoryVar1;
795 int16 *_inventoryVar2;
796 int _currentCursorObject;
801 int _talkListCurrent;
802 bool _talkTextRectDefined;
803 bool _talkTextDisplayed;
804 bool _talkTextInitialized;
807 int _keyCharTalkCounter;
808 int _talkTableLastTalkingKeyChar;
809 int _talkTableLastOtherKeyChar;
810 int _talkTableLastStringNum;
811 int _objectDescriptionNum;
814 bool _conversationChoicesUpdated;
815 int _conversationReplyNum;
816 bool _conversationEnded;
817 int _conversationNum;
818 int _scrollConversationChoiceOffset;
819 int _currentConversation;
820 bool _disableConversationScript;
821 bool _conversationAreaCleared;
824 int16 _flagsTable[NUM_FLAGS];
825 KeyChar _keyCharsTable[NUM_KEYCHARS];
826 KeyChar *_sortedKeyCharsTable[NUM_KEYCHARS];
827 int _currentKeyCharNum;
830 int _currentEpisodeNum;
832 int _currentAmountOfMoney;
833 int _giveItemToKeyCharNum;
834 int _giveItemToObjectNum;
835 int _giveItemToCounter;
837 int _waitingSetKeyCharNum1;
838 int _waitingSetKeyCharNum2;
839 int _waitingSetKeyCharNum3;
840 uint8 _updatedRoomAreasTable[200];
843 int _currentObjectNum;
844 int _processRandomPaletteCounter;
845 int16 _spriteScalingIndex[1000];
846 int16 _spriteScalingTable[1000];
854 const OpcodeProc *_opcodesTable;
859 int _compressedSpeechData;
862 uint8 *_backdropBuffer;
865 uint8 *_sequenceDataTable[NUM_SEQUENCES];
867 uint32 _programDataSize;
873 int _currentBitmapWidth;
874 int _currentBitmapHeight;
875 int _currentImageWidth;
876 int _currentImageHeight;
879 uint8 *_programTextDataPtr;
894 bool _roomNeedRedraw;
895 int _fullRedrawCounter;
896 int _menuRedrawCounter;
897 uint8 *_offscreenBuffer;
898 uint8 _paletteBuffer[256 * 3];
900 int _dirtyRectsTableCount;
902 static const uint8 _directionsTable[NUM_DIRECTIONS];
EngineFeature
Definition: engine.h:250
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:624
Language
Definition: language.h:45