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