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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef ILLUSIONS_ILLUSIONS_DUCKMAN_H 24 #define ILLUSIONS_ILLUSIONS_DUCKMAN_H 25 26 #include "illusions/illusions.h" 27 #include "common/algorithm.h" 28 #include "common/stack.h" 29 30 namespace Illusions { 31 32 class Dictionary; 33 class ScriptStack; 34 class DuckmanDialogSystem; 35 class DuckmanMenuSystem; 36 class DuckmanVideoPlayer; 37 38 struct Cursor_Duckman { 39 int _gameState; 40 Control *_control; 41 Common::Point _position; 42 uint32 _objectId; 43 int _actorIndex; 44 int _savedActorIndex; 45 bool _field14[14]; 46 Control *_currOverlappedControl; 47 uint32 _sequenceId1; 48 uint32 _sequenceId2; 49 uint32 _notifyThreadId30; 50 int16 *_op113_choiceOfsPtr; 51 int _dialogItemsCount; 52 uint32 _overlappedObjectId; 53 uint32 _field3C; 54 uint32 _field40; 55 }; 56 57 struct ScreenShakerPoint { 58 int16 x, y; 59 }; 60 61 struct ScreenShakeEffect { 62 uint32 _duration; 63 uint _pointsCount; 64 const ScreenShakerPoint *_points; 65 }; 66 67 struct ScreenShaker { 68 uint _pointsIndex; 69 uint _pointsCount; 70 bool _finished; 71 uint32 _duration; 72 uint32 _nextTime; 73 uint32 _notifyThreadId; 74 const ScreenShakerPoint *_points; 75 }; 76 77 struct OpCall; 78 79 class IllusionsEngine_Duckman : public IllusionsEngine { 80 public: 81 IllusionsEngine_Duckman(OSystem *syst, const IllusionsGameDescription *gd); 82 protected: 83 Common::Error run() override; 84 bool hasFeature(EngineFeature f) const override; 85 public: 86 87 uint32 _prevSceneId; 88 uint32 _theSceneId; 89 uint32 _theThreadId; 90 uint32 _globalSceneId; 91 92 uint _activeScenesCount; 93 uint32 _activeScenes[6]; 94 95 Cursor_Duckman _cursor; 96 Control *_currWalkOverlappedControl; 97 98 DuckmanDialogSystem *_dialogSys; 99 100 int _savedInventoryActorIndex; 101 102 ScreenShaker *_screenShaker; 103 DuckmanMenuSystem *_menuSystem; 104 DuckmanVideoPlayer *_videoPlayer; 105 106 void initInput(); 107 108 void initUpdateFunctions(); 109 int updateScript(uint flags); 110 111 void startScreenShaker(uint pointsCount, uint32 duration, const ScreenShakerPoint *points, uint32 threadId); 112 void stopScreenShaker(); 113 int updateScreenShaker(uint flags); 114 115 void startFader(int duration, int minValue, int maxValue, int firstIndex, int lastIndex, uint32 threadId); 116 void updateFader() override; 117 void clearFader() override; 118 void pauseFader() override; 119 void unpauseFader() override; 120 121 int updateVideoPlayer(uint flags); 122 void playVideo(uint32 videoId, uint32 callingThreadId); 123 bool isVideoPlaying() override; 124 125 void setDefaultTextCoords() override; 126 127 void loadSpecialCode(uint32 resId) override; 128 void unloadSpecialCode(uint32 resId) override; 129 void notifyThreadId(uint32 &threadId) override; 130 bool testMainActorFastWalk(Control *control) override; 131 bool testMainActorCollision(Control *control) override; 132 Control *getObjectControl(uint32 objectId) override; 133 Common::Point getNamedPointPosition(uint32 namedPointId) override; 134 uint32 getPriorityFromBase(int16 priority) override; 135 uint32 getCurrentScene() override; 136 uint32 getPrevScene() override; 137 138 bool isCursorObject(uint32 actorTypeId, uint32 objectId) override; 139 void setCursorControlRoutine(Control *control) override; 140 void placeCursorControl(Control *control, uint32 sequenceId) override; 141 void setCursorControl(Control *control) override; 142 void showCursor() override; 143 void hideCursor() override; 144 void initCursor(); 145 void setCursorActorIndex(int actorIndex, int a, int b); 146 void enableCursorVerb(int verbNum); 147 void disableCursorVerb(int verbNum); 148 void setCursorHandMode(int mode); 149 void setCursorInventoryMode(int mode, int value); 150 void startCursorHoldingObject(uint32 objectId, uint32 sequenceId); 151 void stopCursorHoldingObject(); 152 void cursorControlRoutine(Control *control, uint32 deltaTime); 153 154 void startScriptThreadSimple(uint32 threadId, uint32 callingThreadId) override; 155 void startScriptThread(uint32 threadId, uint32 callingThreadId); 156 void startScriptThread2(uint32 threadId, uint32 callingThreadId, uint32 unk); 157 uint32 startAbortableTimerThread(uint32 duration, uint32 threadId); 158 uint32 startTimerThread(uint32 duration, uint32 threadId); 159 uint32 startAbortableThread(byte *scriptCodeIp1, byte *scriptCodeIp2, uint32 callingThreadId); 160 uint32 startTalkThread(uint32 objectId, uint32 talkId, uint32 sequenceId1, 161 uint32 sequenceId2, uint32 callingThreadId); 162 uint32 startTempScriptThread(byte *scriptCodeIp, uint32 callingThreadId, 163 uint32 value8, uint32 valueC, uint32 value10) override; 164 void resumeFromSavegame(uint32 callingThreadId); 165 166 void newScriptThread(uint32 threadId, uint32 callingThreadId, uint notifyFlags, 167 byte *scriptCodeIp); 168 uint32 newTimerThread(uint32 duration, uint32 callingThreadId, bool isAbortable); 169 uint32 newTempThreadId(); 170 171 void initActiveScenes(); 172 void pushActiveScene(uint32 sceneId); 173 void popActiveScene(); 174 bool loadScene(uint32 sceneId); 175 bool enterScene(uint32 sceneId, uint32 threadId); 176 void exitScene(); 177 bool changeScene(uint32 sceneId, uint32 threadId, uint32 callerThreadId); 178 void enterPause(uint32 sceneId, uint32 threadId); 179 void leavePause(uint32 sceneId, uint32 threadId); 180 void dumpActiveScenes(uint32 sceneId, uint32 threadId); 181 void dumpCurrSceneFiles(uint32 sceneId, uint32 threadId); 182 183 void pause(uint32 callerThreadId); 184 void unpause(uint32 callerThreadId); 185 186 void setSceneIdThreadId(uint32 theSceneId, uint32 theThreadId); 187 bool findTriggerCause(uint32 sceneId, uint32 verbId, uint32 objectId2, uint32 objectId, uint32 &codeOffs); 188 void reset(); 189 190 uint32 getObjectActorTypeId(uint32 objectId); 191 192 Common::Point convertMousePos(Common::Point mousePos); 193 void startCursorSequence(); 194 int getCursorActorIndex(); 195 void updateGameState2(); 196 void playSoundEffect(int index); 197 bool getTriggerCause(uint32 verbId, uint32 objectId2, uint32 objectId, uint32 &outThreadId); 198 uint32 runTriggerCause(uint32 verbId, uint32 objectId2, uint32 objectId); 199 void playTriggerCauseSound(uint32 verbId, uint32 objectId2, uint32 objectId); 200 201 bool loadSavegameFromScript(int16 slotNum, uint32 callingThreadId); 202 bool saveSavegameFromScript(int16 slotNum, uint32 callingThreadId); 203 void activateSavegame(uint32 callingThreadId); 204 205 }; 206 207 } // End of namespace Illusions 208 209 #endif // ILLUSIONS_ILLUSIONS_H 210