ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
insane.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 #if !defined(SCUMM_INSANE_H) && defined(ENABLE_SCUMM_7_8)
23 #define SCUMM_INSANE_H
24 
25 #include "scumm/nut_renderer.h"
26 
27 #include "scumm/smush/smush_player.h"
28 
29 namespace Scumm {
30 
31 #define INV_CHAIN 0
32 #define INV_CHAINSAW 1
33 #define INV_MACE 2
34 #define INV_2X4 3
35 #define INV_WRENCH 4
36 #define INV_BOOT 5
37 #define INV_HAND 6
38 #define INV_DUST 7
39 
40 #define EN_ROTT1 0 // rottwheeler
41 #define EN_ROTT2 1 // rottwheeler
42 #define EN_ROTT3 2 // rottwheeler
43 #define EN_VULTF1 3 // vulture (redhead female1)
44 #define EN_VULTM1 4 // vulture (male with glasses)
45 #define EN_VULTF2 5 // vulture (redhead female2)
46 #define EN_VULTM2 6 // vulture (initialized as rottwheeler) (male)
47 #define EN_CAVEFISH 7 // Cavefish Maximum Fish
48 #define EN_TORQUE 8 // Father Torque
49 #define EN_BEN 9 // used only with handler
50 
51 class Insane {
52  public:
53  Insane(ScummEngine_v7 *scumm);
54  ~Insane();
55 
56  void setSmushParams(int speed);
57  void setSmushPlayer(SmushPlayer *player);
58  void runScene(int arraynum);
59 
60  void procPreRendering();
61  void procPostRendering(byte *renderBitmap, int32 codecparam, int32 setupsan12,
62  int32 setupsan13, int32 curFrame, int32 maxFrame);
63  void procIACT(byte *renderBitmap, int32 codecparam, int32 setupsan12,
64  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags, int16 par1,
65  int16 par2, int16 par3, int16 par4);
66  void procSKIP(int32 subSize, Common::SeekableReadStream &b);
67  void escapeKeyHandler();
68 
69  bool isInsaneActive() { return _insaneIsRunning; }
70  void syncCurrentSanFlags();
71 
72  private:
73 
74  ScummEngine_v7 *_vm;
75  SmushPlayer *_player;
76 
77  int32 _speed;
78  bool _insaneIsRunning;
79 
80  int32 _numberArray;
81  int32 _emulTimerId;
82  int32 _emulateInterrupt;
83  int32 _flag1d;
84  int32 _mainTimerId;
85  int32 _objArray1Idx;
86  int32 _objArray1Idx2;
87  int32 _objArray1[101];
88  int32 _objArray2Idx;
89  int32 _objArray2Idx2;
90  int32 _objArray2[101];
91  byte _currSceneId;
92  int32 _timer1Flag;
93  int32 _timer3Id;
94  int32 _timer4Id;
95  int32 _timer6Id;
96  int32 _timer7Id;
97  int32 _timerSpriteId;
98  byte _temp2SceneId;
99  byte _tempSceneId;
100  int32 _currEnemy;
101  int32 _currScenePropIdx;
102  int32 _currScenePropSubIdx;
103  const char *_currTrsMsg;
104  int16 _sceneData2Loaded;
105  int16 _sceneData1Loaded;
106  int16 _keyboardDisable;
107  bool _needSceneSwitch;
108  int32 _idx2Exceeded;
109  bool _beenCheated;
110  bool _tiresRustle;
111  int _keybOldDx;
112  int _keybOldDy;
113  int _velocityX;
114  int _velocityY;
115  int _keybX;
116  int _keybY;
117  int32 _firstBattle;
118  bool _weaponBenJustSwitched;
119  bool _kickBenProgress;
120  int32 _battleScene;
121  bool _kickEnemyProgress;
122  bool _weaponEnemyJustSwitched;
123  int32 _enHdlVar[9][9];
124  int32 _smlayer_room;
125  int32 _smlayer_room2;
126  byte *_smush_roadrashRip; // FIXME: combine them in array
127  byte *_smush_roadrsh2Rip;
128  byte *_smush_roadrsh3Rip;
129  byte *_smush_goglpaltRip;
130  byte *_smush_tovista1Flu;
131  byte *_smush_tovista2Flu;
132  byte *_smush_toranchFlu;
133  byte *_smush_minedrivFlu;
134  byte *_smush_minefiteFlu;
135  NutRenderer *_smush_bencutNut;
136  NutRenderer *_smush_bensgoggNut;
137  NutRenderer *_smush_iconsNut;
138  NutRenderer *_smush_icons2Nut;
139  bool _smush_isSanFileSetup;
140  bool _isBenCut;
141  int _smush_smushState;
142  int _continueFrame;
143  int _continueFrame1;
144  int _counter1;
145  int _iactSceneId;
146  int _iactSceneId2;
147  int _smush_setupsan17;
148  int32 _smush_setupsan1;
149  int16 _smush_curSanFlags;
150  int32 _smush_setupsan4;
151  int16 _smush_frameStep;
152  int16 _smush_curFrame;
153  int16 _smush_frameNum1;
154  int16 _smush_frameNum2;
155  byte _smush_earlyFluContents[0x31a];
156  int16 _enemyState[10][10];
157  byte _iactBits[0x80];
158  int16 _mainRoadPos;
159  int16 _posBrokenCar;
160  int16 _posBrokenTruck;
161  int16 _posFatherTorque;
162  int16 _posCave;
163  int16 _posVista;
164  bool _roadBranch;
165  bool _roadStop;
166  bool _carIsBroken;
167  bool _benHasGoggles;
168  bool _mineCaveIsNear;
169  bool _objectDetected;
170  bool _roadBumps;
171  int32 _approachAnim;
172  int32 _val54d;
173  int32 _val57d;
174  bool _val115_;
175  int32 _val211d;
176  int32 _val213d;
177  int32 _metEnemiesListTail;
178  int32 _metEnemiesList[12];
179 
180  struct enemy {
181  int32 handler;
182  int32 initializer;
183  int16 occurrences;
184  int32 maxdamage;
185  int32 isEmpty;
186  int32 weapon;
187  int32 sound;
188  char filename[20];
189  int32 costume4;
190  int32 costume6;
191  int32 costume5;
192  int16 costumevar;
193  int32 maxframe;
194  int32 apprAnim;
195  };
196 
197  struct enemy _enemy[9];
198 
199  struct fluConf {
200  int sceneId;
201  byte **fluPtr;
202  const char *filenamePtr;
203  int startFrame;
204  int numFrames;
205  };
206 
207  struct fluConf _fluConf[21];
208 
209  struct sceneProp {
210  int32 actor; // main actor number, -1 if not applicable
211  int32 sound;
212  int32 trsId;
213  byte r;
214  byte g;
215  byte b;
216  int32 counter;
217  int32 maxCounter;
218  int32 index;
219  };
220 
221  struct sceneProp _sceneProp[139];
222 
223  struct act {
224  int32 actor;
225  byte state;
226  int32 room;
227  int32 animTilt;
228  int32 tilt;
229  int32 frame;
230  };
231 
232  struct actor {
233  int32 damage;
234  int32 maxdamage;
235  int32 field_8;
236  int32 frame;
237  int32 tilt;
238  int32 cursorX;
239  int32 speed;
240  int32 x;
241  int32 y;
242  int32 y1;
243  int32 x1;
244  int16 weaponClass;
245  int16 animWeaponClass;
246  int16 newFacingFlag;
247  int16 curFacingFlag;
248  bool lost;
249  bool kicking;
250  bool field_44;
251  bool field_48; // unused
252  bool defunct;
253  int32 scenePropSubIdx;
254  int32 field_54;
255  int32 runningSound;
256  int32 weapon;
257  bool inventory[8];
258  int32 probability;
259  int32 enemyHandler;
260  struct act act[4];
261  };
262 
263  struct actor _actor[2];
264 
265  void initvars();
266  void readFileToMem(const char *name, byte **buf);
267  void startVideo(const char *filename, int num, int argC, int frameRate,
268  int doMainLoop, byte *fluPtr = 0, int32 startFrame = 0);
269  void smush_warpMouse(int x, int y, int buttons);
270  void putActors();
271  void readState();
272  int initScene(int sceneId);
273  void stopSceneSounds(int sceneId);
274  void shutCurrentScene();
275  int loadSceneData(int scene, int flag, int phase);
276  void setSceneCostumes(int sceneId);
277  void setupValues();
278  void setEnemyCostumes ();
279  void smlayer_stopSound (int idx);
280  int smlayer_loadSound(int id, int flag, int phase);
281  int smlayer_loadCostume(int id, int phase);
282  void smlayer_setActorCostume(int actornum, int act, int costume);
283  void smlayer_putActor(int actornum, int act, int x, int y, byte room);
284  void smlayer_setActorLayer(int actornum, int act, int layer);
285  void smlayer_setFluPalette(byte *pal, int shut_flag);
286 
287  int32 readArray(int item);
288  void writeArray(int item, int value);
289 
290  bool idx1Compare();
291  bool idx2Compare();
292  int32 idx1Tweak();
293  int32 idx2Tweak();
294  void smush_setToFinish();
295  void postCase11(byte *renderBitmap, int32 codecparam, int32 setupsan12,
296  int32 setupsan13, int32 curFrame, int32 maxFrame);
297  void postCase0(byte *renderBitmap, int32 codecparam, int32 setupsan12,
298  int32 setupsan13, int32 curFrame, int32 maxFrame);
299  void postCase17(byte *renderBitmap, int32 codecparam, int32 setupsan12,
300  int32 setupsan13, int32 curFrame, int32 maxFrame);
301  void postCase16(byte *renderBitmap, int32 codecparam, int32 setupsan12,
302  int32 setupsan13, int32 curFrame, int32 maxFrame);
303  void postCase1(byte *renderBitmap, int32 codecparam, int32 setupsan12,
304  int32 setupsan13, int32 curFrame, int32 maxFrame);
305  void postCase2(byte *renderBitmap, int32 codecparam, int32 setupsan12,
306  int32 setupsan13, int32 curFrame, int32 maxFrame);
307  void postCase20(byte *renderBitmap, int32 codecparam, int32 setupsan12,
308  int32 setupsan13, int32 curFrame, int32 maxFrame);
309  void postCase3(byte *renderBitmap, int32 codecparam, int32 setupsan12,
310  int32 setupsan13, int32 curFrame, int32 maxFrame);
311  void postCase5(byte *renderBitmap, int32 codecparam, int32 setupsan12,
312  int32 setupsan13, int32 curFrame, int32 maxFrame);
313  void postCase6(byte *renderBitmap, int32 codecparam, int32 setupsan12,
314  int32 setupsan13, int32 curFrame, int32 maxFrame);
315  void postCase8(byte *renderBitmap, int32 codecparam, int32 setupsan12,
316  int32 setupsan13, int32 curFrame, int32 maxFrame);
317  void postCase9(byte *renderBitmap, int32 codecparam, int32 setupsan12,
318  int32 setupsan13, int32 curFrame, int32 maxFrame);
319  void postCase10(byte *renderBitmap, int32 codecparam, int32 setupsan12,
320  int32 setupsan13, int32 curFrame, int32 maxFrame);
321  void postCase12(byte *renderBitmap, int32 codecparam, int32 setupsan12,
322  int32 setupsan13, int32 curFrame, int32 maxFrame);
323  void postCase23(byte *renderBitmap, int32 codecparam, int32 setupsan12,
324  int32 setupsan13, int32 curFrame, int32 maxFrame);
325  void postCase14(byte *renderBitmap, int32 codecparam, int32 setupsan12,
326  int32 setupsan13, int32 curFrame, int32 maxFrame);
327  void postCaseAll(byte *renderBitmap, int32 codecparam, int32 setupsan12,
328  int32 setupsan13, int32 curFrame, int32 maxFrame);
329  void postCaseMore(byte *renderBitmap, int32 codecparam, int32 setupsan12,
330  int32 setupsan13, int32 curFrame, int32 maxFrame);
331  void switchSceneIfNeeded();
332  int smush_changeState(int state);
333  void init_actStruct(int actornum, int actnum, int32 actorval, byte state,
334  int32 room, int32 animtilt, int32 tilt, int32 frame);
335  void init_enemyStruct(int n, int32 handler, int32 initializer,
336  int16 occurrences, int32 maxdamage, int32 isEmpty,
337  int32 field_14, int32 sound, const char *filename,
338  int32 costume4, int32 costume6, int32 costume5,
339  int16 field_2C, int32 field_30, int32 field_34);
340  int32 enemyHandler(int n, int32, int32, int32);
341  int32 enemyInitializer(int n, int32, int32, int32);
342  int32 enemy0handler(int32, int32, int32);
343  int32 enemy0initializer(int32, int32, int32);
344  int32 enemy1handler(int32, int32, int32);
345  int32 enemy1initializer(int32, int32, int32);
346  int32 enemy2handler(int32, int32, int32);
347  int32 enemy2initializer(int32, int32, int32);
348  int32 enemy3handler(int32, int32, int32);
349  int32 enemy3initializer(int32, int32, int32);
350  int32 enemy4handler(int32, int32, int32);
351  int32 enemy4initializer(int32, int32, int32);
352  int32 enemy5handler(int32, int32, int32);
353  int32 enemy5initializer(int32, int32, int32);
354  int32 enemy6handler(int32, int32, int32);
355  int32 enemy6initializer(int32, int32, int32);
356  int32 enemy7handler(int32, int32, int32);
357  int32 enemy7initializer(int32, int32, int32);
358  int32 enemy8handler(int32, int32, int32);
359  int32 enemy8initializer(int32, int32, int32);
360  int32 enemyBenHandler(int32, int32, int32);
361  bool smlayer_isSoundRunning(int32 sound);
362  bool smlayer_startSfx(int32 sound);
363  bool smlayer_startVoice(int32 sound);
364  void smlayer_soundSetPan(int32 sound, int32 pan);
365  void smlayer_soundSetPriority(int32 sound, int32 priority);
366  void smlayer_drawSomething(byte *renderBitmap, int32 codecparam,
367  int32 arg_8, int32 arg_C, int32 arg_10, NutRenderer *nutfileptr,
368  int32 arg_18, int32 arg_1C, int32 arg_20);
369  void smlayer_overrideDrawActorAt(byte *, byte, byte);
370  void queueSceneSwitch(int32 sceneId, byte *fluPtr, const char *filename,
371  int32 arg_C, int32 arg_10, int32 startFrame, int32 numFrames);
372  void turnBen(bool battle);
373  void smush_rewindCurrentSan(int arg_0, int arg_4, int arg_8);
374  void smlayer_showStatusMsg(int32 arg_0, byte *renderBitmap, int32 codecparam,
375  int32 x, int32 y, int32 arg_14, int32 arg_18,
376  int32 arg_1C, const char *formatString, const char *str);
377  void init_fluConfStruct(int n, int sceneId, byte **fluPtr,
378  const char *filenamePtr, int startFrame, int numFrames);
379  int32 processBenOnRoad(bool flag);
380  void mineChooseRoad(int32 arg_0);
381  void actor02Reaction(int32 buttons);
382  void actor00Reaction(int32 buttons);
383  void actor01Reaction(int32 buttons);
384  void actor03Reaction(int32 buttons);
385  void turnEnemy(bool battle);
386  int32 actionBen();
387  void chooseBenWeaponAnim(int buttons);
388  void setBenAnimation(int32 actornum, int anim);
389  int calcTilt(int speed);
390  bool smush_eitherNotStartNewFrame();
391  void smlayer_setActorFacing(int actornum, int actnum, int frame, int direction);
392  int32 weaponMaxRange(int32 actornum);
393  int32 weaponMinRange(int32 actornum);
394  void switchBenWeapon();
395  void prepareScenePropScene(int32 scenePropNum, bool arg_4, bool arg_8);
396  int32 calcBenDamage(bool arg_0, bool arg_4);
397  int32 weaponDamage(int32 actornum);
398  bool weaponBenIsEffective();
399  bool actor1StateFlags(int state);
400  bool actor0StateFlags1(int state);
401  bool actor0StateFlags2(int state);
402  bool loadScenePropSounds(int32 scenePropNum);
403  void init_scenePropStruct(int32 n, int32 n1, int32 actornum, int32 sound, int32 trsId,
404  byte r, byte g, byte b, int32 counter, int32 maxCounter,
405  int32 index);
406  int32 setBenState();
407  bool smlayer_actorNeedRedraw(int actornum, int actnum);
408  void reinitActors();
409  const char *handleTrsTag(int32 trsId);
410  void ouchSoundBen();
411  int32 smush_setupSanWithFlu(const char *filename, int32 setupsan2, int32 step1,
412  int32 step2, int32 setupsan1, byte *fluPtr, int32 numFrames);
413  void smush_setupSanFromStart(const char *filename, int32 setupsan2, int32 step1,
414  int32 step2, int32 setupsan1);
415  void smush_setFrameSteps(int32 step1, int32 step2);
416  void smush_setupSanFile(const char *filename, int32 offset, int32 contFrame);
417  void drawSpeedyActor(int32 arg_0);
418  void actor11Reaction(int32 buttons);
419  void actor12Reaction(int32 buttons);
420  void actor13Reaction(int32 buttons);
421  void actor10Reaction(int32 buttons);
422  int32 actionEnemy();
423  int32 processKeyboard();
424  int32 processMouse();
425  void setEnemyAnimation(int32 actornum, int anim);
426  void chooseEnemyWeaponAnim(int32 buttons);
427  void switchEnemyWeapon();
428  void setEnemyState();
429  int32 calcEnemyDamage(bool arg_0, bool arg_4);
430  void ouchSoundEnemy();
431  bool weaponEnemyIsEffective();
432  void iactScene1(byte *renderBitmap, int32 codecparam, int32 setupsan12,
433  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
434  int16 par1, int16 par2, int16 par3, int16 par4);
435  void iactScene3(byte *renderBitmap, int32 codecparam, int32 setupsan12,
436  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
437  int16 command, int16 par1, int16, int16);
438  void iactScene4(byte *renderBitmap, int32 codecparam, int32 setupsan12,
439  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
440  int16 par1, int16 par2, int16 par3, int16 par4);
441  void iactScene6(byte *renderBitmap, int32 codecparam, int32 setupsan12,
442  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
443  int16 par1, int16 par2, int16 par3, int16 par4);
444  void iactScene17(byte *renderBitmap, int32 codecparam, int32 setupsan12,
445  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
446  int16 par1, int16 par2, int16 par3, int16 par4);
447  void iactScene21(byte *renderBitmap, int32 codecparam, int32 setupsan12,
448  int32 setupsan13, Common::SeekableReadStream &b, int32 size, int32 flags,
449  int16 par1, int16 par2, int16 par3, int16 par4);
450  bool isBitSet(int n);
451  void setBit(int n);
452  void clearBit(int n);
453  void chooseEnemy();
454  void removeEmptyEnemies();
455  void removeEnemyFromMetList(int32);
456 };
457 } // End of namespace Insane
458 
459 #endif
Definition: stream.h:745
Definition: actor.h:30