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