ScummVM API documentation
logic.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 SKY_LOGIC_H
23 #define SKY_LOGIC_H
24 
25 #include "common/util.h"
26 #include "common/random.h"
27 
28 namespace Sky {
29 
30 struct Compact;
31 
32 enum scriptVariableOffsets {
33  RESULT = 0,
34  SCREEN = 1,
35  LOGIC_LIST_NO = 2,
36  MOUSE_LIST_NO = 6,
37  DRAW_LIST_NO = 8,
38  CUR_ID = 12,
39  MOUSE_STATUS = 13,
40  MOUSE_STOP = 14,
41  BUTTON = 15,
42  SPECIAL_ITEM = 17,
43  GET_OFF = 18,
44  CURSOR_ID = 22,
45  SAFEX = 25,
46  SAFEY = 26,
47  PLAYER_X = 27,
48  PLAYER_Y = 28,
49  PLAYER_MOOD = 29,
50  PLAYER_SCREEN = 30,
51  HIT_ID = 37,
52  LAYER_0_ID = 41,
53  LAYER_1_ID = 42,
54  LAYER_2_ID = 43,
55  LAYER_3_ID = 44,
56  GRID_1_ID = 45,
57  GRID_2_ID = 46,
58  GRID_3_ID = 47,
59  THE_CHOSEN_ONE = 51,
60  TEXT1 = 53,
61  MENU_LENGTH = 100,
62  SCROLL_OFFSET = 101,
63  MENU = 102,
64  OBJECT_HELD = 103,
65  LAMB_GREET = 109,
66  RND = 115,
67  CUR_SECTION = 143,
68  JOEY_SECTION = 145,
69  LAMB_SECTION = 146,
70  KNOWS_PORT = 190,
71  GOT_SPONSOR = 240,
72  GOT_JAMMER = 258,
73  CONSOLE_TYPE = 345,
74  S15_FLOOR = 450,
75  FOREMAN_FRIEND = 451,
76  REICH_DOOR_FLAG = 470,
77  CARD_STATUS = 479,
78  CARD_FIX = 480,
79  GUARDIAN_THERE = 640,
80  FS_COMMAND = 643,
81  ENTER_DIGITS = 644,
82  LINC_DIGIT_0 = 646,
83  LINC_DIGIT_1 = 647,
84  LINC_DIGIT_2 = 648,
85  LINC_DIGIT_3 = 649,
86  LINC_DIGIT_4 = 650,
87  LINC_DIGIT_5 = 651,
88  LINC_DIGIT_6 = 651,
89  LINC_DIGIT_7 = 653,
90  LINC_DIGIT_8 = 654,
91  LINC_DIGIT_9 = 655,
92  DOOR_67_68_FLAG = 678,
93  SC70_IRIS_FLAG = 693,
94  DOOR_73_75_FLAG = 704,
95  SC76_CABINET1_FLAG = 709,
96  SC76_CABINET2_FLAG = 710,
97  SC76_CABINET3_FLAG = 711,
98  DOOR_77_78_FLAG = 719,
99  SC80_EXIT_FLAG = 720,
100  SC31_LIFT_FLAG = 793,
101  SC32_LIFT_FLAG = 797,
102  SC33_SHED_DOOR_FLAG = 798,
103  BAND_PLAYING = 804,
104  COLSTON_AT_TABLE = 805,
105  SC36_NEXT_DEALER = 806,
106  SC36_DOOR_FLAG = 807,
107  SC37_DOOR_FLAG = 808,
108  SC40_LOCKER_1_FLAG = 817,
109  SC40_LOCKER_2_FLAG = 818,
110  SC40_LOCKER_3_FLAG = 819,
111  SC40_LOCKER_4_FLAG = 820,
112  SC40_LOCKER_5_FLAG = 821
113 };
114 
115 #define NUM_SKY_SCRIPTVARS 838
116 
117 class AutoRoute;
118 class Control;
119 class Disk;
120 class Grid;
121 class Mouse;
122 class MusicBase;
123 class Screen;
124 class Sound;
125 class Text;
126 class SkyCompact;
127 
128 class Logic;
129 
130 typedef void (Logic::*LogicTable) ();
131 typedef bool (Logic::*McodeTable) (uint32, uint32, uint32);
132 
133 class Logic {
134 public:
135  Logic(
136  SkyCompact *skyCompact,
137  Screen *skyScreen,
138  Disk *skyDisk,
139  Text *skyText,
140  MusicBase *skyMusic,
141  Mouse *skyMouse,
142  Sound *skySound);
143  ~Logic();
144  void engine();
145  void useControlInstance(Control *control) { _skyControl = control; }
146 
147  uint16 mouseScript(uint32 scrNum, Compact *scriptComp);
148 
149  static uint32 _scriptVariables[NUM_SKY_SCRIPTVARS];
150  Grid *_skyGrid;
151 
152  uint16 script(uint16 scriptNo, uint16 offset);
153  void initScreen0();
154  void parseSaveData(uint32 *data);
155 
156 private:
157  void setupLogicTable();
158  void setupMcodeTable();
159  const LogicTable *_logicTable;
160  const McodeTable *_mcodeTable;
161 
162 protected:
163  void push(uint32);
164  uint32 pop();
165  void checkModuleLoaded(uint16 moduleNo);
166  bool isCollision(Compact *cpt);
167  void initScriptVariables();
168  void mainAnim();
169  void runGetOff();
170  void stopAndWait();
171  bool checkProtection();
172 
173  void nop();
174  void logicScript();
175  void autoRoute();
176  void arAnim();
177  void arTurn();
178  void alt();
179  void anim();
180  void turn();
181  void cursor();
182  void talk();
183  void listen();
184  void stopped();
185  void choose();
186  void frames();
187  void pause();
188  void waitSync();
189  void simpleAnim();
190 
191  bool fnCacheChip(uint32 a, uint32 b, uint32 c);
192  bool fnCacheFast(uint32 a, uint32 b, uint32 c);
193  bool fnDrawScreen(uint32 a, uint32 b, uint32 c);
194  bool fnAr(uint32 a, uint32 b, uint32 c);
195  bool fnArAnimate(uint32 a, uint32 b, uint32 c);
196  bool fnIdle(uint32 a, uint32 b, uint32 c);
197  bool fnInteract(uint32 a, uint32 b, uint32 c);
198  bool fnStartSub(uint32 a, uint32 b, uint32 c);
199  bool fnTheyStartSub(uint32 a, uint32 b, uint32 c);
200  bool fnAssignBase(uint32 a, uint32 b, uint32 c);
201  bool fnDiskMouse(uint32 a, uint32 b, uint32 c);
202  bool fnNormalMouse(uint32 a, uint32 b, uint32 c);
203  bool fnBlankMouse(uint32 a, uint32 b, uint32 c);
204  bool fnCrossMouse(uint32 a, uint32 b, uint32 c);
205  bool fnCursorRight(uint32 a, uint32 b, uint32 c);
206  bool fnCursorLeft(uint32 a, uint32 b, uint32 c);
207  bool fnCursorDown(uint32 a, uint32 b, uint32 c);
208  bool fnOpenHand(uint32 a, uint32 b, uint32 c);
209  bool fnCloseHand(uint32 a, uint32 b, uint32 c);
210  bool fnGetTo(uint32 a, uint32 b, uint32 c);
211  bool fnSetToStand(uint32 a, uint32 b, uint32 c);
212  bool fnTurnTo(uint32 a, uint32 b, uint32 c);
213  bool fnArrived(uint32 a, uint32 b, uint32 c);
214  bool fnLeaving(uint32 a, uint32 b, uint32 c);
215  bool fnSetAlternate(uint32 a, uint32 b, uint32 c);
216  bool fnAltSetAlternate(uint32 a, uint32 b, uint32 c);
217  bool fnKillId(uint32 a, uint32 b, uint32 c);
218  bool fnNoHuman(uint32 a, uint32 b, uint32 c);
219  bool fnAddHuman(uint32 a, uint32 b, uint32 c);
220  bool fnAddButtons(uint32 a, uint32 b, uint32 c);
221  bool fnNoButtons(uint32 a, uint32 b, uint32 c);
222  bool fnSetStop(uint32 a, uint32 b, uint32 c);
223  bool fnClearStop(uint32 a, uint32 b, uint32 c);
224  bool fnPointerText(uint32 a, uint32 b, uint32 c);
225  bool fnQuit(uint32 a, uint32 b, uint32 c);
226  bool fnSpeakMe(uint32 targetId, uint32 mesgNum, uint32 animNum);
227  bool fnSpeakMeDir(uint32 targetId, uint32 mesgNum, uint32 animNum);
228  bool fnSpeakWait(uint32 a, uint32 b, uint32 c);
229  bool fnSpeakWaitDir(uint32 a, uint32 b, uint32 c);
230  bool fnChooser(uint32 a, uint32 b, uint32 c);
231  bool fnHighlight(uint32 a, uint32 b, uint32 c);
232  bool fnTextKill(uint32 a, uint32 b, uint32 c);
233  bool fnStopMode(uint32 a, uint32 b, uint32 c);
234  bool fnWeWait(uint32 a, uint32 b, uint32 c);
235  bool fnSendSync(uint32 a, uint32 b, uint32 c);
236  bool fnSendFastSync(uint32 a, uint32 b, uint32 c);
237  bool fnSendRequest(uint32 a, uint32 b, uint32 c);
238  bool fnClearRequest(uint32 a, uint32 b, uint32 c);
239  bool fnCheckRequest(uint32 a, uint32 b, uint32 c);
240  bool fnStartMenu(uint32 a, uint32 b, uint32 c);
241  bool fnUnhighlight(uint32 a, uint32 b, uint32 c);
242  bool fnFaceId(uint32 a, uint32 b, uint32 c);
243  bool fnForeground(uint32 a, uint32 b, uint32 c);
244  bool fnBackground(uint32 a, uint32 b, uint32 c);
245  bool fnNewBackground(uint32 a, uint32 b, uint32 c);
246  bool fnSort(uint32 a, uint32 b, uint32 c);
247  bool fnNoSpriteEngine(uint32 a, uint32 b, uint32 c);
248  bool fnNoSpritesA6(uint32 a, uint32 b, uint32 c);
249  bool fnResetId(uint32 a, uint32 b, uint32 c);
250  bool fnToggleGrid(uint32 a, uint32 b, uint32 c);
251  bool fnPause(uint32 a, uint32 b, uint32 c);
252  bool fnRunAnimMod(uint32 a, uint32 b, uint32 c);
253  bool fnSimpleMod(uint32 a, uint32 b, uint32 c);
254  bool fnRunFrames(uint32 a, uint32 b, uint32 c);
255  bool fnAwaitSync(uint32 a, uint32 b, uint32 c);
256  bool fnIncMegaSet(uint32 a, uint32 b, uint32 c);
257  bool fnDecMegaSet(uint32 a, uint32 b, uint32 c);
258  bool fnSetMegaSet(uint32 a, uint32 b, uint32 c);
259  bool fnMoveItems(uint32 a, uint32 b, uint32 c);
260  bool fnNewList(uint32 a, uint32 b, uint32 c);
261  bool fnAskThis(uint32 a, uint32 b, uint32 c);
262  bool fnRandom(uint32 a, uint32 b, uint32 c);
263  bool fnPersonHere(uint32 a, uint32 b, uint32 c);
264  bool fnToggleMouse(uint32 a, uint32 b, uint32 c);
265  bool fnMouseOn(uint32 a, uint32 b, uint32 c);
266  bool fnMouseOff(uint32 a, uint32 b, uint32 c);
267  bool fnFetchX(uint32 a, uint32 b, uint32 c);
268  bool fnFetchY(uint32 a, uint32 b, uint32 c);
269  bool fnTestList(uint32 a, uint32 b, uint32 c);
270  bool fnFetchPlace(uint32 a, uint32 b, uint32 c);
271  bool fnCustomJoey(uint32 a, uint32 b, uint32 c);
272  bool fnSetPalette(uint32 a, uint32 b, uint32 c);
273  bool fnTextModule(uint32 a, uint32 b, uint32 c);
274  bool fnChangeName(uint32 a, uint32 b, uint32 c);
275  bool fnMiniLoad(uint32 a, uint32 b, uint32 c);
276  bool fnFlushBuffers(uint32 a, uint32 b, uint32 c);
277  bool fnFlushChip(uint32 a, uint32 b, uint32 c);
278  bool fnSaveCoods(uint32 a, uint32 b, uint32 c);
279  bool fnPlotGrid(uint32 a, uint32 b, uint32 c);
280  bool fnRemoveGrid(uint32 a, uint32 b, uint32 c);
281  bool fnEyeball(uint32 a, uint32 b, uint32 c);
282  bool fnCursorUp(uint32 a, uint32 b, uint32 c);
283  bool fnLeaveSection(uint32 a, uint32 b, uint32 c);
284  bool fnEnterSection(uint32 sectionNo, uint32 b, uint32 c);
285  bool fnRestoreGame(uint32 a, uint32 b, uint32 c);
286  bool fnRestartGame(uint32 a, uint32 b, uint32 c);
287  bool fnNewSwingSeq(uint32 a, uint32 b, uint32 c);
288  bool fnWaitSwingEnd(uint32 a, uint32 b, uint32 c);
289  bool fnSkipIntroCode(uint32 a, uint32 b, uint32 c);
290  bool fnBlankScreen(uint32 a, uint32 b, uint32 c);
291  bool fnPrintCredit(uint32 a, uint32 b, uint32 c);
292  bool fnLookAt(uint32 a, uint32 b, uint32 c);
293  bool fnLincTextModule(uint32 a, uint32 b, uint32 c);
294  bool fnTextKill2(uint32 a, uint32 b, uint32 c);
295  bool fnSetFont(uint32 a, uint32 b, uint32 c);
296  bool fnStartFx(uint32 a, uint32 b, uint32 c);
297  bool fnStopFx(uint32 a, uint32 b, uint32 c);
298  bool fnStartMusic(uint32 a, uint32 b, uint32 c);
299  bool fnStopMusic(uint32 a, uint32 b, uint32 c);
300  bool fnFadeDown(uint32 a, uint32 b, uint32 c);
301  bool fnFadeUp(uint32 a, uint32 b, uint32 c);
302  bool fnQuitToDos(uint32 a, uint32 b, uint32 c);
303  bool fnPauseFx(uint32 a, uint32 b, uint32 c);
304  bool fnUnPauseFx(uint32 a, uint32 b, uint32 c);
305  bool fnPrintf(uint32 a, uint32 b, uint32 c);
306 
307  void stdSpeak(Compact *target, uint32 textNum, uint32 animNum, uint32 base);
308  void fnExec(uint16 num, uint32 a, uint32 b, uint32 c);
309 
310  uint16 *_moduleList[16];
311  uint32 _stack[20];
312  byte _stackPtr;
313 
314  Compact *_compact;
315 
316  uint32 _objectList[30];
317 
318  uint32 _currentSection;
319 
321 
322  SkyCompact *_skyCompact;
323  Screen *_skyScreen;
324  Disk *_skyDisk;
325  Text *_skyText;
326  MusicBase *_skyMusic;
327  Sound *_skySound;
328  AutoRoute *_skyAutoRoute;
329  Mouse *_skyMouse;
330  Control *_skyControl;
331 
332  friend class Debugger;
333 };
334 
335 } // End of namespace Sky
336 
337 #endif
Definition: autoroute.h:34
Definition: logic.h:133
Definition: struc.h:78
Definition: grid.h:35
Definition: musicbase.h:50
Definition: random.h:44
Definition: default_display_client.h:78
Definition: disk.h:37
Definition: debug.h:36
Definition: screen.h:56
Definition: sound.h:47
Definition: mouse.h:36
Definition: text.h:48
Definition: compact.h:58
Definition: autoroute.h:28
Definition: control.h:181